bundle.js 1.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539
  1. /******/ (function(modules) { // webpackBootstrap
  2. /******/ // The module cache
  3. /******/ var installedModules = {};
  4. /******/ // The require function
  5. /******/ function __webpack_require__(moduleId) {
  6. /******/ // Check if module is in cache
  7. /******/ if(installedModules[moduleId])
  8. /******/ return installedModules[moduleId].exports;
  9. /******/ // Create a new module (and put it into the cache)
  10. /******/ var module = installedModules[moduleId] = {
  11. /******/ exports: {},
  12. /******/ id: moduleId,
  13. /******/ loaded: false
  14. /******/ };
  15. /******/ // Execute the module function
  16. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  17. /******/ // Flag the module as loaded
  18. /******/ module.loaded = true;
  19. /******/ // Return the exports of the module
  20. /******/ return module.exports;
  21. /******/ }
  22. /******/ // expose the modules object (__webpack_modules__)
  23. /******/ __webpack_require__.m = modules;
  24. /******/ // expose the module cache
  25. /******/ __webpack_require__.c = installedModules;
  26. /******/ // __webpack_public_path__
  27. /******/ __webpack_require__.p = "";
  28. /******/ // Load entry module and return exports
  29. /******/ return __webpack_require__(0);
  30. /******/ })
  31. /************************************************************************/
  32. /******/ ([
  33. /* 0 */
  34. /***/ function(module, exports, __webpack_require__) {
  35. var React = __webpack_require__(1);
  36. var ReactDOM = __webpack_require__(158);
  37. var Demo = __webpack_require__(159);
  38. ReactDOM.render(React.createElement(Demo, null), document.getElementById('demo'));
  39. /***/ },
  40. /* 1 */
  41. /***/ function(module, exports, __webpack_require__) {
  42. 'use strict';
  43. module.exports = __webpack_require__(2);
  44. /***/ },
  45. /* 2 */
  46. /***/ function(module, exports, __webpack_require__) {
  47. /**
  48. * Copyright 2013-2015, Facebook, Inc.
  49. * All rights reserved.
  50. *
  51. * This source code is licensed under the BSD-style license found in the
  52. * LICENSE file in the root directory of this source tree. An additional grant
  53. * of patent rights can be found in the PATENTS file in the same directory.
  54. *
  55. * @providesModule React
  56. */
  57. 'use strict';
  58. var ReactDOM = __webpack_require__(3);
  59. var ReactDOMServer = __webpack_require__(148);
  60. var ReactIsomorphic = __webpack_require__(152);
  61. var assign = __webpack_require__(39);
  62. var deprecated = __webpack_require__(157);
  63. // `version` will be added here by ReactIsomorphic.
  64. var React = {};
  65. assign(React, ReactIsomorphic);
  66. assign(React, {
  67. // ReactDOM
  68. findDOMNode: deprecated('findDOMNode', 'ReactDOM', 'react-dom', ReactDOM, ReactDOM.findDOMNode),
  69. render: deprecated('render', 'ReactDOM', 'react-dom', ReactDOM, ReactDOM.render),
  70. unmountComponentAtNode: deprecated('unmountComponentAtNode', 'ReactDOM', 'react-dom', ReactDOM, ReactDOM.unmountComponentAtNode),
  71. // ReactDOMServer
  72. renderToString: deprecated('renderToString', 'ReactDOMServer', 'react-dom/server', ReactDOMServer, ReactDOMServer.renderToString),
  73. renderToStaticMarkup: deprecated('renderToStaticMarkup', 'ReactDOMServer', 'react-dom/server', ReactDOMServer, ReactDOMServer.renderToStaticMarkup)
  74. });
  75. React.__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOM;
  76. React.__SECRET_DOM_SERVER_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactDOMServer;
  77. module.exports = React;
  78. /***/ },
  79. /* 3 */
  80. /***/ function(module, exports, __webpack_require__) {
  81. /* WEBPACK VAR INJECTION */(function(process) {/**
  82. * Copyright 2013-2015, Facebook, Inc.
  83. * All rights reserved.
  84. *
  85. * This source code is licensed under the BSD-style license found in the
  86. * LICENSE file in the root directory of this source tree. An additional grant
  87. * of patent rights can be found in the PATENTS file in the same directory.
  88. *
  89. * @providesModule ReactDOM
  90. */
  91. /* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/
  92. 'use strict';
  93. var ReactCurrentOwner = __webpack_require__(5);
  94. var ReactDOMTextComponent = __webpack_require__(6);
  95. var ReactDefaultInjection = __webpack_require__(71);
  96. var ReactInstanceHandles = __webpack_require__(45);
  97. var ReactMount = __webpack_require__(28);
  98. var ReactPerf = __webpack_require__(18);
  99. var ReactReconciler = __webpack_require__(50);
  100. var ReactUpdates = __webpack_require__(54);
  101. var ReactVersion = __webpack_require__(146);
  102. var findDOMNode = __webpack_require__(91);
  103. var renderSubtreeIntoContainer = __webpack_require__(147);
  104. var warning = __webpack_require__(25);
  105. ReactDefaultInjection.inject();
  106. var render = ReactPerf.measure('React', 'render', ReactMount.render);
  107. var React = {
  108. findDOMNode: findDOMNode,
  109. render: render,
  110. unmountComponentAtNode: ReactMount.unmountComponentAtNode,
  111. version: ReactVersion,
  112. /* eslint-disable camelcase */
  113. unstable_batchedUpdates: ReactUpdates.batchedUpdates,
  114. unstable_renderSubtreeIntoContainer: renderSubtreeIntoContainer
  115. };
  116. // Inject the runtime into a devtools global hook regardless of browser.
  117. // Allows for debugging when the hook is injected on the page.
  118. /* eslint-enable camelcase */
  119. if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') {
  120. __REACT_DEVTOOLS_GLOBAL_HOOK__.inject({
  121. CurrentOwner: ReactCurrentOwner,
  122. InstanceHandles: ReactInstanceHandles,
  123. Mount: ReactMount,
  124. Reconciler: ReactReconciler,
  125. TextComponent: ReactDOMTextComponent
  126. });
  127. }
  128. if (process.env.NODE_ENV !== 'production') {
  129. var ExecutionEnvironment = __webpack_require__(9);
  130. if (ExecutionEnvironment.canUseDOM && window.top === window.self) {
  131. // First check if devtools is not installed
  132. if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') {
  133. // If we're in Chrome or Firefox, provide a download link if not installed.
  134. if (navigator.userAgent.indexOf('Chrome') > -1 && navigator.userAgent.indexOf('Edge') === -1 || navigator.userAgent.indexOf('Firefox') > -1) {
  135. console.debug('Download the React DevTools for a better development experience: ' + 'https://fb.me/react-devtools');
  136. }
  137. }
  138. // If we're in IE8, check to see if we are in compatibility mode and provide
  139. // information on preventing compatibility mode
  140. var ieCompatibilityMode = document.documentMode && document.documentMode < 8;
  141. process.env.NODE_ENV !== 'production' ? warning(!ieCompatibilityMode, 'Internet Explorer is running in compatibility mode; please add the ' + 'following tag to your HTML to prevent this from happening: ' + '<meta http-equiv="X-UA-Compatible" content="IE=edge" />') : undefined;
  142. var expectedFeatures = [
  143. // shims
  144. Array.isArray, Array.prototype.every, Array.prototype.forEach, Array.prototype.indexOf, Array.prototype.map, Date.now, Function.prototype.bind, Object.keys, String.prototype.split, String.prototype.trim,
  145. // shams
  146. Object.create, Object.freeze];
  147. for (var i = 0; i < expectedFeatures.length; i++) {
  148. if (!expectedFeatures[i]) {
  149. console.error('One or more ES5 shim/shams expected by React are not available: ' + 'https://fb.me/react-warning-polyfills');
  150. break;
  151. }
  152. }
  153. }
  154. }
  155. module.exports = React;
  156. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  157. /***/ },
  158. /* 4 */
  159. /***/ function(module, exports) {
  160. // shim for using process in browser
  161. var process = module.exports = {};
  162. // cached from whatever global is present so that test runners that stub it
  163. // don't break things. But we need to wrap it in a try catch in case it is
  164. // wrapped in strict mode code which doesn't define any globals. It's inside a
  165. // function because try/catches deoptimize in certain engines.
  166. var cachedSetTimeout;
  167. var cachedClearTimeout;
  168. function defaultSetTimout() {
  169. throw new Error('setTimeout has not been defined');
  170. }
  171. function defaultClearTimeout () {
  172. throw new Error('clearTimeout has not been defined');
  173. }
  174. (function () {
  175. try {
  176. if (typeof setTimeout === 'function') {
  177. cachedSetTimeout = setTimeout;
  178. } else {
  179. cachedSetTimeout = defaultSetTimout;
  180. }
  181. } catch (e) {
  182. cachedSetTimeout = defaultSetTimout;
  183. }
  184. try {
  185. if (typeof clearTimeout === 'function') {
  186. cachedClearTimeout = clearTimeout;
  187. } else {
  188. cachedClearTimeout = defaultClearTimeout;
  189. }
  190. } catch (e) {
  191. cachedClearTimeout = defaultClearTimeout;
  192. }
  193. } ())
  194. function runTimeout(fun) {
  195. if (cachedSetTimeout === setTimeout) {
  196. //normal enviroments in sane situations
  197. return setTimeout(fun, 0);
  198. }
  199. // if setTimeout wasn't available but was latter defined
  200. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  201. cachedSetTimeout = setTimeout;
  202. return setTimeout(fun, 0);
  203. }
  204. try {
  205. // when when somebody has screwed with setTimeout but no I.E. maddness
  206. return cachedSetTimeout(fun, 0);
  207. } catch(e){
  208. try {
  209. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  210. return cachedSetTimeout.call(null, fun, 0);
  211. } catch(e){
  212. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  213. return cachedSetTimeout.call(this, fun, 0);
  214. }
  215. }
  216. }
  217. function runClearTimeout(marker) {
  218. if (cachedClearTimeout === clearTimeout) {
  219. //normal enviroments in sane situations
  220. return clearTimeout(marker);
  221. }
  222. // if clearTimeout wasn't available but was latter defined
  223. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  224. cachedClearTimeout = clearTimeout;
  225. return clearTimeout(marker);
  226. }
  227. try {
  228. // when when somebody has screwed with setTimeout but no I.E. maddness
  229. return cachedClearTimeout(marker);
  230. } catch (e){
  231. try {
  232. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  233. return cachedClearTimeout.call(null, marker);
  234. } catch (e){
  235. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  236. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  237. return cachedClearTimeout.call(this, marker);
  238. }
  239. }
  240. }
  241. var queue = [];
  242. var draining = false;
  243. var currentQueue;
  244. var queueIndex = -1;
  245. function cleanUpNextTick() {
  246. if (!draining || !currentQueue) {
  247. return;
  248. }
  249. draining = false;
  250. if (currentQueue.length) {
  251. queue = currentQueue.concat(queue);
  252. } else {
  253. queueIndex = -1;
  254. }
  255. if (queue.length) {
  256. drainQueue();
  257. }
  258. }
  259. function drainQueue() {
  260. if (draining) {
  261. return;
  262. }
  263. var timeout = runTimeout(cleanUpNextTick);
  264. draining = true;
  265. var len = queue.length;
  266. while(len) {
  267. currentQueue = queue;
  268. queue = [];
  269. while (++queueIndex < len) {
  270. if (currentQueue) {
  271. currentQueue[queueIndex].run();
  272. }
  273. }
  274. queueIndex = -1;
  275. len = queue.length;
  276. }
  277. currentQueue = null;
  278. draining = false;
  279. runClearTimeout(timeout);
  280. }
  281. process.nextTick = function (fun) {
  282. var args = new Array(arguments.length - 1);
  283. if (arguments.length > 1) {
  284. for (var i = 1; i < arguments.length; i++) {
  285. args[i - 1] = arguments[i];
  286. }
  287. }
  288. queue.push(new Item(fun, args));
  289. if (queue.length === 1 && !draining) {
  290. runTimeout(drainQueue);
  291. }
  292. };
  293. // v8 likes predictible objects
  294. function Item(fun, array) {
  295. this.fun = fun;
  296. this.array = array;
  297. }
  298. Item.prototype.run = function () {
  299. this.fun.apply(null, this.array);
  300. };
  301. process.title = 'browser';
  302. process.browser = true;
  303. process.env = {};
  304. process.argv = [];
  305. process.version = ''; // empty string to avoid regexp issues
  306. process.versions = {};
  307. function noop() {}
  308. process.on = noop;
  309. process.addListener = noop;
  310. process.once = noop;
  311. process.off = noop;
  312. process.removeListener = noop;
  313. process.removeAllListeners = noop;
  314. process.emit = noop;
  315. process.binding = function (name) {
  316. throw new Error('process.binding is not supported');
  317. };
  318. process.cwd = function () { return '/' };
  319. process.chdir = function (dir) {
  320. throw new Error('process.chdir is not supported');
  321. };
  322. process.umask = function() { return 0; };
  323. /***/ },
  324. /* 5 */
  325. /***/ function(module, exports) {
  326. /**
  327. * Copyright 2013-2015, Facebook, Inc.
  328. * All rights reserved.
  329. *
  330. * This source code is licensed under the BSD-style license found in the
  331. * LICENSE file in the root directory of this source tree. An additional grant
  332. * of patent rights can be found in the PATENTS file in the same directory.
  333. *
  334. * @providesModule ReactCurrentOwner
  335. */
  336. 'use strict';
  337. /**
  338. * Keeps track of the current owner.
  339. *
  340. * The current owner is the component who should own any components that are
  341. * currently being constructed.
  342. */
  343. var ReactCurrentOwner = {
  344. /**
  345. * @internal
  346. * @type {ReactComponent}
  347. */
  348. current: null
  349. };
  350. module.exports = ReactCurrentOwner;
  351. /***/ },
  352. /* 6 */
  353. /***/ function(module, exports, __webpack_require__) {
  354. /* WEBPACK VAR INJECTION */(function(process) {/**
  355. * Copyright 2013-2015, Facebook, Inc.
  356. * All rights reserved.
  357. *
  358. * This source code is licensed under the BSD-style license found in the
  359. * LICENSE file in the root directory of this source tree. An additional grant
  360. * of patent rights can be found in the PATENTS file in the same directory.
  361. *
  362. * @providesModule ReactDOMTextComponent
  363. * @typechecks static-only
  364. */
  365. 'use strict';
  366. var DOMChildrenOperations = __webpack_require__(7);
  367. var DOMPropertyOperations = __webpack_require__(22);
  368. var ReactComponentBrowserEnvironment = __webpack_require__(26);
  369. var ReactMount = __webpack_require__(28);
  370. var assign = __webpack_require__(39);
  371. var escapeTextContentForBrowser = __webpack_require__(21);
  372. var setTextContent = __webpack_require__(20);
  373. var validateDOMNesting = __webpack_require__(70);
  374. /**
  375. * Text nodes violate a couple assumptions that React makes about components:
  376. *
  377. * - When mounting text into the DOM, adjacent text nodes are merged.
  378. * - Text nodes cannot be assigned a React root ID.
  379. *
  380. * This component is used to wrap strings in elements so that they can undergo
  381. * the same reconciliation that is applied to elements.
  382. *
  383. * TODO: Investigate representing React components in the DOM with text nodes.
  384. *
  385. * @class ReactDOMTextComponent
  386. * @extends ReactComponent
  387. * @internal
  388. */
  389. var ReactDOMTextComponent = function (props) {
  390. // This constructor and its argument is currently used by mocks.
  391. };
  392. assign(ReactDOMTextComponent.prototype, {
  393. /**
  394. * @param {ReactText} text
  395. * @internal
  396. */
  397. construct: function (text) {
  398. // TODO: This is really a ReactText (ReactNode), not a ReactElement
  399. this._currentElement = text;
  400. this._stringText = '' + text;
  401. // Properties
  402. this._rootNodeID = null;
  403. this._mountIndex = 0;
  404. },
  405. /**
  406. * Creates the markup for this text node. This node is not intended to have
  407. * any features besides containing text content.
  408. *
  409. * @param {string} rootID DOM ID of the root node.
  410. * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
  411. * @return {string} Markup for this text node.
  412. * @internal
  413. */
  414. mountComponent: function (rootID, transaction, context) {
  415. if (process.env.NODE_ENV !== 'production') {
  416. if (context[validateDOMNesting.ancestorInfoContextKey]) {
  417. validateDOMNesting('span', null, context[validateDOMNesting.ancestorInfoContextKey]);
  418. }
  419. }
  420. this._rootNodeID = rootID;
  421. if (transaction.useCreateElement) {
  422. var ownerDocument = context[ReactMount.ownerDocumentContextKey];
  423. var el = ownerDocument.createElement('span');
  424. DOMPropertyOperations.setAttributeForID(el, rootID);
  425. // Populate node cache
  426. ReactMount.getID(el);
  427. setTextContent(el, this._stringText);
  428. return el;
  429. } else {
  430. var escapedText = escapeTextContentForBrowser(this._stringText);
  431. if (transaction.renderToStaticMarkup) {
  432. // Normally we'd wrap this in a `span` for the reasons stated above, but
  433. // since this is a situation where React won't take over (static pages),
  434. // we can simply return the text as it is.
  435. return escapedText;
  436. }
  437. return '<span ' + DOMPropertyOperations.createMarkupForID(rootID) + '>' + escapedText + '</span>';
  438. }
  439. },
  440. /**
  441. * Updates this component by updating the text content.
  442. *
  443. * @param {ReactText} nextText The next text content
  444. * @param {ReactReconcileTransaction} transaction
  445. * @internal
  446. */
  447. receiveComponent: function (nextText, transaction) {
  448. if (nextText !== this._currentElement) {
  449. this._currentElement = nextText;
  450. var nextStringText = '' + nextText;
  451. if (nextStringText !== this._stringText) {
  452. // TODO: Save this as pending props and use performUpdateIfNecessary
  453. // and/or updateComponent to do the actual update for consistency with
  454. // other component types?
  455. this._stringText = nextStringText;
  456. var node = ReactMount.getNode(this._rootNodeID);
  457. DOMChildrenOperations.updateTextContent(node, nextStringText);
  458. }
  459. }
  460. },
  461. unmountComponent: function () {
  462. ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
  463. }
  464. });
  465. module.exports = ReactDOMTextComponent;
  466. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  467. /***/ },
  468. /* 7 */
  469. /***/ function(module, exports, __webpack_require__) {
  470. /* WEBPACK VAR INJECTION */(function(process) {/**
  471. * Copyright 2013-2015, Facebook, Inc.
  472. * All rights reserved.
  473. *
  474. * This source code is licensed under the BSD-style license found in the
  475. * LICENSE file in the root directory of this source tree. An additional grant
  476. * of patent rights can be found in the PATENTS file in the same directory.
  477. *
  478. * @providesModule DOMChildrenOperations
  479. * @typechecks static-only
  480. */
  481. 'use strict';
  482. var Danger = __webpack_require__(8);
  483. var ReactMultiChildUpdateTypes = __webpack_require__(16);
  484. var ReactPerf = __webpack_require__(18);
  485. var setInnerHTML = __webpack_require__(19);
  486. var setTextContent = __webpack_require__(20);
  487. var invariant = __webpack_require__(13);
  488. /**
  489. * Inserts `childNode` as a child of `parentNode` at the `index`.
  490. *
  491. * @param {DOMElement} parentNode Parent node in which to insert.
  492. * @param {DOMElement} childNode Child node to insert.
  493. * @param {number} index Index at which to insert the child.
  494. * @internal
  495. */
  496. function insertChildAt(parentNode, childNode, index) {
  497. // By exploiting arrays returning `undefined` for an undefined index, we can
  498. // rely exclusively on `insertBefore(node, null)` instead of also using
  499. // `appendChild(node)`. However, using `undefined` is not allowed by all
  500. // browsers so we must replace it with `null`.
  501. // fix render order error in safari
  502. // IE8 will throw error when index out of list size.
  503. var beforeChild = index >= parentNode.childNodes.length ? null : parentNode.childNodes.item(index);
  504. parentNode.insertBefore(childNode, beforeChild);
  505. }
  506. /**
  507. * Operations for updating with DOM children.
  508. */
  509. var DOMChildrenOperations = {
  510. dangerouslyReplaceNodeWithMarkup: Danger.dangerouslyReplaceNodeWithMarkup,
  511. updateTextContent: setTextContent,
  512. /**
  513. * Updates a component's children by processing a series of updates. The
  514. * update configurations are each expected to have a `parentNode` property.
  515. *
  516. * @param {array<object>} updates List of update configurations.
  517. * @param {array<string>} markupList List of markup strings.
  518. * @internal
  519. */
  520. processUpdates: function (updates, markupList) {
  521. var update;
  522. // Mapping from parent IDs to initial child orderings.
  523. var initialChildren = null;
  524. // List of children that will be moved or removed.
  525. var updatedChildren = null;
  526. for (var i = 0; i < updates.length; i++) {
  527. update = updates[i];
  528. if (update.type === ReactMultiChildUpdateTypes.MOVE_EXISTING || update.type === ReactMultiChildUpdateTypes.REMOVE_NODE) {
  529. var updatedIndex = update.fromIndex;
  530. var updatedChild = update.parentNode.childNodes[updatedIndex];
  531. var parentID = update.parentID;
  532. !updatedChild ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processUpdates(): Unable to find child %s of element. This ' + 'probably means the DOM was unexpectedly mutated (e.g., by the ' + 'browser), usually due to forgetting a <tbody> when using tables, ' + 'nesting tags like <form>, <p>, or <a>, or using non-SVG elements ' + 'in an <svg> parent. Try inspecting the child nodes of the element ' + 'with React ID `%s`.', updatedIndex, parentID) : invariant(false) : undefined;
  533. initialChildren = initialChildren || {};
  534. initialChildren[parentID] = initialChildren[parentID] || [];
  535. initialChildren[parentID][updatedIndex] = updatedChild;
  536. updatedChildren = updatedChildren || [];
  537. updatedChildren.push(updatedChild);
  538. }
  539. }
  540. var renderedMarkup;
  541. // markupList is either a list of markup or just a list of elements
  542. if (markupList.length && typeof markupList[0] === 'string') {
  543. renderedMarkup = Danger.dangerouslyRenderMarkup(markupList);
  544. } else {
  545. renderedMarkup = markupList;
  546. }
  547. // Remove updated children first so that `toIndex` is consistent.
  548. if (updatedChildren) {
  549. for (var j = 0; j < updatedChildren.length; j++) {
  550. updatedChildren[j].parentNode.removeChild(updatedChildren[j]);
  551. }
  552. }
  553. for (var k = 0; k < updates.length; k++) {
  554. update = updates[k];
  555. switch (update.type) {
  556. case ReactMultiChildUpdateTypes.INSERT_MARKUP:
  557. insertChildAt(update.parentNode, renderedMarkup[update.markupIndex], update.toIndex);
  558. break;
  559. case ReactMultiChildUpdateTypes.MOVE_EXISTING:
  560. insertChildAt(update.parentNode, initialChildren[update.parentID][update.fromIndex], update.toIndex);
  561. break;
  562. case ReactMultiChildUpdateTypes.SET_MARKUP:
  563. setInnerHTML(update.parentNode, update.content);
  564. break;
  565. case ReactMultiChildUpdateTypes.TEXT_CONTENT:
  566. setTextContent(update.parentNode, update.content);
  567. break;
  568. case ReactMultiChildUpdateTypes.REMOVE_NODE:
  569. // Already removed by the for-loop above.
  570. break;
  571. }
  572. }
  573. }
  574. };
  575. ReactPerf.measureMethods(DOMChildrenOperations, 'DOMChildrenOperations', {
  576. updateTextContent: 'updateTextContent'
  577. });
  578. module.exports = DOMChildrenOperations;
  579. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  580. /***/ },
  581. /* 8 */
  582. /***/ function(module, exports, __webpack_require__) {
  583. /* WEBPACK VAR INJECTION */(function(process) {/**
  584. * Copyright 2013-2015, Facebook, Inc.
  585. * All rights reserved.
  586. *
  587. * This source code is licensed under the BSD-style license found in the
  588. * LICENSE file in the root directory of this source tree. An additional grant
  589. * of patent rights can be found in the PATENTS file in the same directory.
  590. *
  591. * @providesModule Danger
  592. * @typechecks static-only
  593. */
  594. 'use strict';
  595. var ExecutionEnvironment = __webpack_require__(9);
  596. var createNodesFromMarkup = __webpack_require__(10);
  597. var emptyFunction = __webpack_require__(15);
  598. var getMarkupWrap = __webpack_require__(14);
  599. var invariant = __webpack_require__(13);
  600. var OPEN_TAG_NAME_EXP = /^(<[^ \/>]+)/;
  601. var RESULT_INDEX_ATTR = 'data-danger-index';
  602. /**
  603. * Extracts the `nodeName` from a string of markup.
  604. *
  605. * NOTE: Extracting the `nodeName` does not require a regular expression match
  606. * because we make assumptions about React-generated markup (i.e. there are no
  607. * spaces surrounding the opening tag and there is at least one attribute).
  608. *
  609. * @param {string} markup String of markup.
  610. * @return {string} Node name of the supplied markup.
  611. * @see http://jsperf.com/extract-nodename
  612. */
  613. function getNodeName(markup) {
  614. return markup.substring(1, markup.indexOf(' '));
  615. }
  616. var Danger = {
  617. /**
  618. * Renders markup into an array of nodes. The markup is expected to render
  619. * into a list of root nodes. Also, the length of `resultList` and
  620. * `markupList` should be the same.
  621. *
  622. * @param {array<string>} markupList List of markup strings to render.
  623. * @return {array<DOMElement>} List of rendered nodes.
  624. * @internal
  625. */
  626. dangerouslyRenderMarkup: function (markupList) {
  627. !ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Cannot render markup in a worker ' + 'thread. Make sure `window` and `document` are available globally ' + 'before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString for server rendering.') : invariant(false) : undefined;
  628. var nodeName;
  629. var markupByNodeName = {};
  630. // Group markup by `nodeName` if a wrap is necessary, else by '*'.
  631. for (var i = 0; i < markupList.length; i++) {
  632. !markupList[i] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyRenderMarkup(...): Missing markup.') : invariant(false) : undefined;
  633. nodeName = getNodeName(markupList[i]);
  634. nodeName = getMarkupWrap(nodeName) ? nodeName : '*';
  635. markupByNodeName[nodeName] = markupByNodeName[nodeName] || [];
  636. markupByNodeName[nodeName][i] = markupList[i];
  637. }
  638. var resultList = [];
  639. var resultListAssignmentCount = 0;
  640. for (nodeName in markupByNodeName) {
  641. if (!markupByNodeName.hasOwnProperty(nodeName)) {
  642. continue;
  643. }
  644. var markupListByNodeName = markupByNodeName[nodeName];
  645. // This for-in loop skips the holes of the sparse array. The order of
  646. // iteration should follow the order of assignment, which happens to match
  647. // numerical index order, but we don't rely on that.
  648. var resultIndex;
  649. for (resultIndex in markupListByNodeName) {
  650. if (markupListByNodeName.hasOwnProperty(resultIndex)) {
  651. var markup = markupListByNodeName[resultIndex];
  652. // Push the requested markup with an additional RESULT_INDEX_ATTR
  653. // attribute. If the markup does not start with a < character, it
  654. // will be discarded below (with an appropriate console.error).
  655. markupListByNodeName[resultIndex] = markup.replace(OPEN_TAG_NAME_EXP,
  656. // This index will be parsed back out below.
  657. '$1 ' + RESULT_INDEX_ATTR + '="' + resultIndex + '" ');
  658. }
  659. }
  660. // Render each group of markup with similar wrapping `nodeName`.
  661. var renderNodes = createNodesFromMarkup(markupListByNodeName.join(''), emptyFunction // Do nothing special with <script> tags.
  662. );
  663. for (var j = 0; j < renderNodes.length; ++j) {
  664. var renderNode = renderNodes[j];
  665. if (renderNode.hasAttribute && renderNode.hasAttribute(RESULT_INDEX_ATTR)) {
  666. resultIndex = +renderNode.getAttribute(RESULT_INDEX_ATTR);
  667. renderNode.removeAttribute(RESULT_INDEX_ATTR);
  668. !!resultList.hasOwnProperty(resultIndex) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Assigning to an already-occupied result index.') : invariant(false) : undefined;
  669. resultList[resultIndex] = renderNode;
  670. // This should match resultList.length and markupList.length when
  671. // we're done.
  672. resultListAssignmentCount += 1;
  673. } else if (process.env.NODE_ENV !== 'production') {
  674. console.error('Danger: Discarding unexpected node:', renderNode);
  675. }
  676. }
  677. }
  678. // Although resultList was populated out of order, it should now be a dense
  679. // array.
  680. !(resultListAssignmentCount === resultList.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Did not assign to every index of resultList.') : invariant(false) : undefined;
  681. !(resultList.length === markupList.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Danger: Expected markup to render %s nodes, but rendered %s.', markupList.length, resultList.length) : invariant(false) : undefined;
  682. return resultList;
  683. },
  684. /**
  685. * Replaces a node with a string of markup at its current position within its
  686. * parent. The markup must render into a single root node.
  687. *
  688. * @param {DOMElement} oldChild Child node to replace.
  689. * @param {string} markup Markup to render in place of the child node.
  690. * @internal
  691. */
  692. dangerouslyReplaceNodeWithMarkup: function (oldChild, markup) {
  693. !ExecutionEnvironment.canUseDOM ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot render markup in a ' + 'worker thread. Make sure `window` and `document` are available ' + 'globally before requiring React when unit testing or use ' + 'ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined;
  694. !markup ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Missing markup.') : invariant(false) : undefined;
  695. !(oldChild.tagName.toLowerCase() !== 'html') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'dangerouslyReplaceNodeWithMarkup(...): Cannot replace markup of the ' + '<html> node. This is because browser quirks make this unreliable ' + 'and/or slow. If you want to render to the root you must use ' + 'server rendering. See ReactDOMServer.renderToString().') : invariant(false) : undefined;
  696. var newChild;
  697. if (typeof markup === 'string') {
  698. newChild = createNodesFromMarkup(markup, emptyFunction)[0];
  699. } else {
  700. newChild = markup;
  701. }
  702. oldChild.parentNode.replaceChild(newChild, oldChild);
  703. }
  704. };
  705. module.exports = Danger;
  706. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  707. /***/ },
  708. /* 9 */
  709. /***/ function(module, exports) {
  710. /**
  711. * Copyright 2013-2015, Facebook, Inc.
  712. * All rights reserved.
  713. *
  714. * This source code is licensed under the BSD-style license found in the
  715. * LICENSE file in the root directory of this source tree. An additional grant
  716. * of patent rights can be found in the PATENTS file in the same directory.
  717. *
  718. * @providesModule ExecutionEnvironment
  719. */
  720. 'use strict';
  721. var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
  722. /**
  723. * Simple, lightweight module assisting with the detection and context of
  724. * Worker. Helps avoid circular dependencies and allows code to reason about
  725. * whether or not they are in a Worker, even if they never include the main
  726. * `ReactWorker` dependency.
  727. */
  728. var ExecutionEnvironment = {
  729. canUseDOM: canUseDOM,
  730. canUseWorkers: typeof Worker !== 'undefined',
  731. canUseEventListeners: canUseDOM && !!(window.addEventListener || window.attachEvent),
  732. canUseViewport: canUseDOM && !!window.screen,
  733. isInWorker: !canUseDOM // For now, this is true - might change in the future.
  734. };
  735. module.exports = ExecutionEnvironment;
  736. /***/ },
  737. /* 10 */
  738. /***/ function(module, exports, __webpack_require__) {
  739. /* WEBPACK VAR INJECTION */(function(process) {/**
  740. * Copyright 2013-2015, Facebook, Inc.
  741. * All rights reserved.
  742. *
  743. * This source code is licensed under the BSD-style license found in the
  744. * LICENSE file in the root directory of this source tree. An additional grant
  745. * of patent rights can be found in the PATENTS file in the same directory.
  746. *
  747. * @providesModule createNodesFromMarkup
  748. * @typechecks
  749. */
  750. /*eslint-disable fb-www/unsafe-html*/
  751. 'use strict';
  752. var ExecutionEnvironment = __webpack_require__(9);
  753. var createArrayFromMixed = __webpack_require__(11);
  754. var getMarkupWrap = __webpack_require__(14);
  755. var invariant = __webpack_require__(13);
  756. /**
  757. * Dummy container used to render all markup.
  758. */
  759. var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
  760. /**
  761. * Pattern used by `getNodeName`.
  762. */
  763. var nodeNamePattern = /^\s*<(\w+)/;
  764. /**
  765. * Extracts the `nodeName` of the first element in a string of markup.
  766. *
  767. * @param {string} markup String of markup.
  768. * @return {?string} Node name of the supplied markup.
  769. */
  770. function getNodeName(markup) {
  771. var nodeNameMatch = markup.match(nodeNamePattern);
  772. return nodeNameMatch && nodeNameMatch[1].toLowerCase();
  773. }
  774. /**
  775. * Creates an array containing the nodes rendered from the supplied markup. The
  776. * optionally supplied `handleScript` function will be invoked once for each
  777. * <script> element that is rendered. If no `handleScript` function is supplied,
  778. * an exception is thrown if any <script> elements are rendered.
  779. *
  780. * @param {string} markup A string of valid HTML markup.
  781. * @param {?function} handleScript Invoked once for each rendered <script>.
  782. * @return {array<DOMElement|DOMTextNode>} An array of rendered nodes.
  783. */
  784. function createNodesFromMarkup(markup, handleScript) {
  785. var node = dummyNode;
  786. !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup dummy not initialized') : invariant(false) : undefined;
  787. var nodeName = getNodeName(markup);
  788. var wrap = nodeName && getMarkupWrap(nodeName);
  789. if (wrap) {
  790. node.innerHTML = wrap[1] + markup + wrap[2];
  791. var wrapDepth = wrap[0];
  792. while (wrapDepth--) {
  793. node = node.lastChild;
  794. }
  795. } else {
  796. node.innerHTML = markup;
  797. }
  798. var scripts = node.getElementsByTagName('script');
  799. if (scripts.length) {
  800. !handleScript ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createNodesFromMarkup(...): Unexpected <script> element rendered.') : invariant(false) : undefined;
  801. createArrayFromMixed(scripts).forEach(handleScript);
  802. }
  803. var nodes = createArrayFromMixed(node.childNodes);
  804. while (node.lastChild) {
  805. node.removeChild(node.lastChild);
  806. }
  807. return nodes;
  808. }
  809. module.exports = createNodesFromMarkup;
  810. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  811. /***/ },
  812. /* 11 */
  813. /***/ function(module, exports, __webpack_require__) {
  814. /**
  815. * Copyright 2013-2015, Facebook, Inc.
  816. * All rights reserved.
  817. *
  818. * This source code is licensed under the BSD-style license found in the
  819. * LICENSE file in the root directory of this source tree. An additional grant
  820. * of patent rights can be found in the PATENTS file in the same directory.
  821. *
  822. * @providesModule createArrayFromMixed
  823. * @typechecks
  824. */
  825. 'use strict';
  826. var toArray = __webpack_require__(12);
  827. /**
  828. * Perform a heuristic test to determine if an object is "array-like".
  829. *
  830. * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
  831. * Joshu replied: "Mu."
  832. *
  833. * This function determines if its argument has "array nature": it returns
  834. * true if the argument is an actual array, an `arguments' object, or an
  835. * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
  836. *
  837. * It will return false for other array-like objects like Filelist.
  838. *
  839. * @param {*} obj
  840. * @return {boolean}
  841. */
  842. function hasArrayNature(obj) {
  843. return(
  844. // not null/false
  845. !!obj && (
  846. // arrays are objects, NodeLists are functions in Safari
  847. typeof obj == 'object' || typeof obj == 'function') &&
  848. // quacks like an array
  849. 'length' in obj &&
  850. // not window
  851. !('setInterval' in obj) &&
  852. // no DOM node should be considered an array-like
  853. // a 'select' element has 'length' and 'item' properties on IE8
  854. typeof obj.nodeType != 'number' && (
  855. // a real array
  856. Array.isArray(obj) ||
  857. // arguments
  858. 'callee' in obj ||
  859. // HTMLCollection/NodeList
  860. 'item' in obj)
  861. );
  862. }
  863. /**
  864. * Ensure that the argument is an array by wrapping it in an array if it is not.
  865. * Creates a copy of the argument if it is already an array.
  866. *
  867. * This is mostly useful idiomatically:
  868. *
  869. * var createArrayFromMixed = require('createArrayFromMixed');
  870. *
  871. * function takesOneOrMoreThings(things) {
  872. * things = createArrayFromMixed(things);
  873. * ...
  874. * }
  875. *
  876. * This allows you to treat `things' as an array, but accept scalars in the API.
  877. *
  878. * If you need to convert an array-like object, like `arguments`, into an array
  879. * use toArray instead.
  880. *
  881. * @param {*} obj
  882. * @return {array}
  883. */
  884. function createArrayFromMixed(obj) {
  885. if (!hasArrayNature(obj)) {
  886. return [obj];
  887. } else if (Array.isArray(obj)) {
  888. return obj.slice();
  889. } else {
  890. return toArray(obj);
  891. }
  892. }
  893. module.exports = createArrayFromMixed;
  894. /***/ },
  895. /* 12 */
  896. /***/ function(module, exports, __webpack_require__) {
  897. /* WEBPACK VAR INJECTION */(function(process) {/**
  898. * Copyright 2013-2015, Facebook, Inc.
  899. * All rights reserved.
  900. *
  901. * This source code is licensed under the BSD-style license found in the
  902. * LICENSE file in the root directory of this source tree. An additional grant
  903. * of patent rights can be found in the PATENTS file in the same directory.
  904. *
  905. * @providesModule toArray
  906. * @typechecks
  907. */
  908. 'use strict';
  909. var invariant = __webpack_require__(13);
  910. /**
  911. * Convert array-like objects to arrays.
  912. *
  913. * This API assumes the caller knows the contents of the data type. For less
  914. * well defined inputs use createArrayFromMixed.
  915. *
  916. * @param {object|function|filelist} obj
  917. * @return {array}
  918. */
  919. function toArray(obj) {
  920. var length = obj.length;
  921. // Some browse builtin objects can report typeof 'function' (e.g. NodeList in
  922. // old versions of Safari).
  923. !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : undefined;
  924. !(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : undefined;
  925. !(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : undefined;
  926. // Old IE doesn't give collections access to hasOwnProperty. Assume inputs
  927. // without method will throw during the slice call and skip straight to the
  928. // fallback.
  929. if (obj.hasOwnProperty) {
  930. try {
  931. return Array.prototype.slice.call(obj);
  932. } catch (e) {
  933. // IE < 9 does not support Array#slice on collections objects
  934. }
  935. }
  936. // Fall back to copying key by key. This assumes all keys have a value,
  937. // so will not preserve sparsely populated inputs.
  938. var ret = Array(length);
  939. for (var ii = 0; ii < length; ii++) {
  940. ret[ii] = obj[ii];
  941. }
  942. return ret;
  943. }
  944. module.exports = toArray;
  945. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  946. /***/ },
  947. /* 13 */
  948. /***/ function(module, exports, __webpack_require__) {
  949. /* WEBPACK VAR INJECTION */(function(process) {/**
  950. * Copyright 2013-2015, Facebook, Inc.
  951. * All rights reserved.
  952. *
  953. * This source code is licensed under the BSD-style license found in the
  954. * LICENSE file in the root directory of this source tree. An additional grant
  955. * of patent rights can be found in the PATENTS file in the same directory.
  956. *
  957. * @providesModule invariant
  958. */
  959. 'use strict';
  960. /**
  961. * Use invariant() to assert state which your program assumes to be true.
  962. *
  963. * Provide sprintf-style format (only %s is supported) and arguments
  964. * to provide information about what broke and what you were
  965. * expecting.
  966. *
  967. * The invariant message will be stripped in production, but the invariant
  968. * will remain to ensure logic does not differ in production.
  969. */
  970. function invariant(condition, format, a, b, c, d, e, f) {
  971. if (process.env.NODE_ENV !== 'production') {
  972. if (format === undefined) {
  973. throw new Error('invariant requires an error message argument');
  974. }
  975. }
  976. if (!condition) {
  977. var error;
  978. if (format === undefined) {
  979. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  980. } else {
  981. var args = [a, b, c, d, e, f];
  982. var argIndex = 0;
  983. error = new Error(format.replace(/%s/g, function () {
  984. return args[argIndex++];
  985. }));
  986. error.name = 'Invariant Violation';
  987. }
  988. error.framesToPop = 1; // we don't care about invariant's own frame
  989. throw error;
  990. }
  991. }
  992. module.exports = invariant;
  993. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  994. /***/ },
  995. /* 14 */
  996. /***/ function(module, exports, __webpack_require__) {
  997. /* WEBPACK VAR INJECTION */(function(process) {/**
  998. * Copyright 2013-2015, Facebook, Inc.
  999. * All rights reserved.
  1000. *
  1001. * This source code is licensed under the BSD-style license found in the
  1002. * LICENSE file in the root directory of this source tree. An additional grant
  1003. * of patent rights can be found in the PATENTS file in the same directory.
  1004. *
  1005. * @providesModule getMarkupWrap
  1006. */
  1007. /*eslint-disable fb-www/unsafe-html */
  1008. 'use strict';
  1009. var ExecutionEnvironment = __webpack_require__(9);
  1010. var invariant = __webpack_require__(13);
  1011. /**
  1012. * Dummy container used to detect which wraps are necessary.
  1013. */
  1014. var dummyNode = ExecutionEnvironment.canUseDOM ? document.createElement('div') : null;
  1015. /**
  1016. * Some browsers cannot use `innerHTML` to render certain elements standalone,
  1017. * so we wrap them, render the wrapped nodes, then extract the desired node.
  1018. *
  1019. * In IE8, certain elements cannot render alone, so wrap all elements ('*').
  1020. */
  1021. var shouldWrap = {};
  1022. var selectWrap = [1, '<select multiple="true">', '</select>'];
  1023. var tableWrap = [1, '<table>', '</table>'];
  1024. var trWrap = [3, '<table><tbody><tr>', '</tr></tbody></table>'];
  1025. var svgWrap = [1, '<svg xmlns="http://www.w3.org/2000/svg">', '</svg>'];
  1026. var markupWrap = {
  1027. '*': [1, '?<div>', '</div>'],
  1028. 'area': [1, '<map>', '</map>'],
  1029. 'col': [2, '<table><tbody></tbody><colgroup>', '</colgroup></table>'],
  1030. 'legend': [1, '<fieldset>', '</fieldset>'],
  1031. 'param': [1, '<object>', '</object>'],
  1032. 'tr': [2, '<table><tbody>', '</tbody></table>'],
  1033. 'optgroup': selectWrap,
  1034. 'option': selectWrap,
  1035. 'caption': tableWrap,
  1036. 'colgroup': tableWrap,
  1037. 'tbody': tableWrap,
  1038. 'tfoot': tableWrap,
  1039. 'thead': tableWrap,
  1040. 'td': trWrap,
  1041. 'th': trWrap
  1042. };
  1043. // Initialize the SVG elements since we know they'll always need to be wrapped
  1044. // consistently. If they are created inside a <div> they will be initialized in
  1045. // the wrong namespace (and will not display).
  1046. var svgElements = ['circle', 'clipPath', 'defs', 'ellipse', 'g', 'image', 'line', 'linearGradient', 'mask', 'path', 'pattern', 'polygon', 'polyline', 'radialGradient', 'rect', 'stop', 'text', 'tspan'];
  1047. svgElements.forEach(function (nodeName) {
  1048. markupWrap[nodeName] = svgWrap;
  1049. shouldWrap[nodeName] = true;
  1050. });
  1051. /**
  1052. * Gets the markup wrap configuration for the supplied `nodeName`.
  1053. *
  1054. * NOTE: This lazily detects which wraps are necessary for the current browser.
  1055. *
  1056. * @param {string} nodeName Lowercase `nodeName`.
  1057. * @return {?array} Markup wrap configuration, if applicable.
  1058. */
  1059. function getMarkupWrap(nodeName) {
  1060. !!!dummyNode ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Markup wrapping node not initialized') : invariant(false) : undefined;
  1061. if (!markupWrap.hasOwnProperty(nodeName)) {
  1062. nodeName = '*';
  1063. }
  1064. if (!shouldWrap.hasOwnProperty(nodeName)) {
  1065. if (nodeName === '*') {
  1066. dummyNode.innerHTML = '<link />';
  1067. } else {
  1068. dummyNode.innerHTML = '<' + nodeName + '></' + nodeName + '>';
  1069. }
  1070. shouldWrap[nodeName] = !dummyNode.firstChild;
  1071. }
  1072. return shouldWrap[nodeName] ? markupWrap[nodeName] : null;
  1073. }
  1074. module.exports = getMarkupWrap;
  1075. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  1076. /***/ },
  1077. /* 15 */
  1078. /***/ function(module, exports) {
  1079. /**
  1080. * Copyright 2013-2015, Facebook, Inc.
  1081. * All rights reserved.
  1082. *
  1083. * This source code is licensed under the BSD-style license found in the
  1084. * LICENSE file in the root directory of this source tree. An additional grant
  1085. * of patent rights can be found in the PATENTS file in the same directory.
  1086. *
  1087. * @providesModule emptyFunction
  1088. */
  1089. "use strict";
  1090. function makeEmptyFunction(arg) {
  1091. return function () {
  1092. return arg;
  1093. };
  1094. }
  1095. /**
  1096. * This function accepts and discards inputs; it has no side effects. This is
  1097. * primarily useful idiomatically for overridable function endpoints which
  1098. * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
  1099. */
  1100. function emptyFunction() {}
  1101. emptyFunction.thatReturns = makeEmptyFunction;
  1102. emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
  1103. emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
  1104. emptyFunction.thatReturnsNull = makeEmptyFunction(null);
  1105. emptyFunction.thatReturnsThis = function () {
  1106. return this;
  1107. };
  1108. emptyFunction.thatReturnsArgument = function (arg) {
  1109. return arg;
  1110. };
  1111. module.exports = emptyFunction;
  1112. /***/ },
  1113. /* 16 */
  1114. /***/ function(module, exports, __webpack_require__) {
  1115. /**
  1116. * Copyright 2013-2015, Facebook, Inc.
  1117. * All rights reserved.
  1118. *
  1119. * This source code is licensed under the BSD-style license found in the
  1120. * LICENSE file in the root directory of this source tree. An additional grant
  1121. * of patent rights can be found in the PATENTS file in the same directory.
  1122. *
  1123. * @providesModule ReactMultiChildUpdateTypes
  1124. */
  1125. 'use strict';
  1126. var keyMirror = __webpack_require__(17);
  1127. /**
  1128. * When a component's children are updated, a series of update configuration
  1129. * objects are created in order to batch and serialize the required changes.
  1130. *
  1131. * Enumerates all the possible types of update configurations.
  1132. *
  1133. * @internal
  1134. */
  1135. var ReactMultiChildUpdateTypes = keyMirror({
  1136. INSERT_MARKUP: null,
  1137. MOVE_EXISTING: null,
  1138. REMOVE_NODE: null,
  1139. SET_MARKUP: null,
  1140. TEXT_CONTENT: null
  1141. });
  1142. module.exports = ReactMultiChildUpdateTypes;
  1143. /***/ },
  1144. /* 17 */
  1145. /***/ function(module, exports, __webpack_require__) {
  1146. /* WEBPACK VAR INJECTION */(function(process) {/**
  1147. * Copyright 2013-2015, Facebook, Inc.
  1148. * All rights reserved.
  1149. *
  1150. * This source code is licensed under the BSD-style license found in the
  1151. * LICENSE file in the root directory of this source tree. An additional grant
  1152. * of patent rights can be found in the PATENTS file in the same directory.
  1153. *
  1154. * @providesModule keyMirror
  1155. * @typechecks static-only
  1156. */
  1157. 'use strict';
  1158. var invariant = __webpack_require__(13);
  1159. /**
  1160. * Constructs an enumeration with keys equal to their value.
  1161. *
  1162. * For example:
  1163. *
  1164. * var COLORS = keyMirror({blue: null, red: null});
  1165. * var myColor = COLORS.blue;
  1166. * var isColorValid = !!COLORS[myColor];
  1167. *
  1168. * The last line could not be performed if the values of the generated enum were
  1169. * not equal to their keys.
  1170. *
  1171. * Input: {key1: val1, key2: val2}
  1172. * Output: {key1: key1, key2: key2}
  1173. *
  1174. * @param {object} obj
  1175. * @return {object}
  1176. */
  1177. var keyMirror = function (obj) {
  1178. var ret = {};
  1179. var key;
  1180. !(obj instanceof Object && !Array.isArray(obj)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'keyMirror(...): Argument must be an object.') : invariant(false) : undefined;
  1181. for (key in obj) {
  1182. if (!obj.hasOwnProperty(key)) {
  1183. continue;
  1184. }
  1185. ret[key] = key;
  1186. }
  1187. return ret;
  1188. };
  1189. module.exports = keyMirror;
  1190. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  1191. /***/ },
  1192. /* 18 */
  1193. /***/ function(module, exports, __webpack_require__) {
  1194. /* WEBPACK VAR INJECTION */(function(process) {/**
  1195. * Copyright 2013-2015, Facebook, Inc.
  1196. * All rights reserved.
  1197. *
  1198. * This source code is licensed under the BSD-style license found in the
  1199. * LICENSE file in the root directory of this source tree. An additional grant
  1200. * of patent rights can be found in the PATENTS file in the same directory.
  1201. *
  1202. * @providesModule ReactPerf
  1203. * @typechecks static-only
  1204. */
  1205. 'use strict';
  1206. /**
  1207. * ReactPerf is a general AOP system designed to measure performance. This
  1208. * module only has the hooks: see ReactDefaultPerf for the analysis tool.
  1209. */
  1210. var ReactPerf = {
  1211. /**
  1212. * Boolean to enable/disable measurement. Set to false by default to prevent
  1213. * accidental logging and perf loss.
  1214. */
  1215. enableMeasure: false,
  1216. /**
  1217. * Holds onto the measure function in use. By default, don't measure
  1218. * anything, but we'll override this if we inject a measure function.
  1219. */
  1220. storedMeasure: _noMeasure,
  1221. /**
  1222. * @param {object} object
  1223. * @param {string} objectName
  1224. * @param {object<string>} methodNames
  1225. */
  1226. measureMethods: function (object, objectName, methodNames) {
  1227. if (process.env.NODE_ENV !== 'production') {
  1228. for (var key in methodNames) {
  1229. if (!methodNames.hasOwnProperty(key)) {
  1230. continue;
  1231. }
  1232. object[key] = ReactPerf.measure(objectName, methodNames[key], object[key]);
  1233. }
  1234. }
  1235. },
  1236. /**
  1237. * Use this to wrap methods you want to measure. Zero overhead in production.
  1238. *
  1239. * @param {string} objName
  1240. * @param {string} fnName
  1241. * @param {function} func
  1242. * @return {function}
  1243. */
  1244. measure: function (objName, fnName, func) {
  1245. if (process.env.NODE_ENV !== 'production') {
  1246. var measuredFunc = null;
  1247. var wrapper = function () {
  1248. if (ReactPerf.enableMeasure) {
  1249. if (!measuredFunc) {
  1250. measuredFunc = ReactPerf.storedMeasure(objName, fnName, func);
  1251. }
  1252. return measuredFunc.apply(this, arguments);
  1253. }
  1254. return func.apply(this, arguments);
  1255. };
  1256. wrapper.displayName = objName + '_' + fnName;
  1257. return wrapper;
  1258. }
  1259. return func;
  1260. },
  1261. injection: {
  1262. /**
  1263. * @param {function} measure
  1264. */
  1265. injectMeasure: function (measure) {
  1266. ReactPerf.storedMeasure = measure;
  1267. }
  1268. }
  1269. };
  1270. /**
  1271. * Simply passes through the measured function, without measuring it.
  1272. *
  1273. * @param {string} objName
  1274. * @param {string} fnName
  1275. * @param {function} func
  1276. * @return {function}
  1277. */
  1278. function _noMeasure(objName, fnName, func) {
  1279. return func;
  1280. }
  1281. module.exports = ReactPerf;
  1282. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  1283. /***/ },
  1284. /* 19 */
  1285. /***/ function(module, exports, __webpack_require__) {
  1286. /**
  1287. * Copyright 2013-2015, Facebook, Inc.
  1288. * All rights reserved.
  1289. *
  1290. * This source code is licensed under the BSD-style license found in the
  1291. * LICENSE file in the root directory of this source tree. An additional grant
  1292. * of patent rights can be found in the PATENTS file in the same directory.
  1293. *
  1294. * @providesModule setInnerHTML
  1295. */
  1296. /* globals MSApp */
  1297. 'use strict';
  1298. var ExecutionEnvironment = __webpack_require__(9);
  1299. var WHITESPACE_TEST = /^[ \r\n\t\f]/;
  1300. var NONVISIBLE_TEST = /<(!--|link|noscript|meta|script|style)[ \r\n\t\f\/>]/;
  1301. /**
  1302. * Set the innerHTML property of a node, ensuring that whitespace is preserved
  1303. * even in IE8.
  1304. *
  1305. * @param {DOMElement} node
  1306. * @param {string} html
  1307. * @internal
  1308. */
  1309. var setInnerHTML = function (node, html) {
  1310. node.innerHTML = html;
  1311. };
  1312. // Win8 apps: Allow all html to be inserted
  1313. if (typeof MSApp !== 'undefined' && MSApp.execUnsafeLocalFunction) {
  1314. setInnerHTML = function (node, html) {
  1315. MSApp.execUnsafeLocalFunction(function () {
  1316. node.innerHTML = html;
  1317. });
  1318. };
  1319. }
  1320. if (ExecutionEnvironment.canUseDOM) {
  1321. // IE8: When updating a just created node with innerHTML only leading
  1322. // whitespace is removed. When updating an existing node with innerHTML
  1323. // whitespace in root TextNodes is also collapsed.
  1324. // @see quirksmode.org/bugreports/archives/2004/11/innerhtml_and_t.html
  1325. // Feature detection; only IE8 is known to behave improperly like this.
  1326. var testElement = document.createElement('div');
  1327. testElement.innerHTML = ' ';
  1328. if (testElement.innerHTML === '') {
  1329. setInnerHTML = function (node, html) {
  1330. // Magic theory: IE8 supposedly differentiates between added and updated
  1331. // nodes when processing innerHTML, innerHTML on updated nodes suffers
  1332. // from worse whitespace behavior. Re-adding a node like this triggers
  1333. // the initial and more favorable whitespace behavior.
  1334. // TODO: What to do on a detached node?
  1335. if (node.parentNode) {
  1336. node.parentNode.replaceChild(node, node);
  1337. }
  1338. // We also implement a workaround for non-visible tags disappearing into
  1339. // thin air on IE8, this only happens if there is no visible text
  1340. // in-front of the non-visible tags. Piggyback on the whitespace fix
  1341. // and simply check if any non-visible tags appear in the source.
  1342. if (WHITESPACE_TEST.test(html) || html[0] === '<' && NONVISIBLE_TEST.test(html)) {
  1343. // Recover leading whitespace by temporarily prepending any character.
  1344. // \uFEFF has the potential advantage of being zero-width/invisible.
  1345. // UglifyJS drops U+FEFF chars when parsing, so use String.fromCharCode
  1346. // in hopes that this is preserved even if "\uFEFF" is transformed to
  1347. // the actual Unicode character (by Babel, for example).
  1348. // https://github.com/mishoo/UglifyJS2/blob/v2.4.20/lib/parse.js#L216
  1349. node.innerHTML = String.fromCharCode(0xFEFF) + html;
  1350. // deleteData leaves an empty `TextNode` which offsets the index of all
  1351. // children. Definitely want to avoid this.
  1352. var textNode = node.firstChild;
  1353. if (textNode.data.length === 1) {
  1354. node.removeChild(textNode);
  1355. } else {
  1356. textNode.deleteData(0, 1);
  1357. }
  1358. } else {
  1359. node.innerHTML = html;
  1360. }
  1361. };
  1362. }
  1363. }
  1364. module.exports = setInnerHTML;
  1365. /***/ },
  1366. /* 20 */
  1367. /***/ function(module, exports, __webpack_require__) {
  1368. /**
  1369. * Copyright 2013-2015, Facebook, Inc.
  1370. * All rights reserved.
  1371. *
  1372. * This source code is licensed under the BSD-style license found in the
  1373. * LICENSE file in the root directory of this source tree. An additional grant
  1374. * of patent rights can be found in the PATENTS file in the same directory.
  1375. *
  1376. * @providesModule setTextContent
  1377. */
  1378. 'use strict';
  1379. var ExecutionEnvironment = __webpack_require__(9);
  1380. var escapeTextContentForBrowser = __webpack_require__(21);
  1381. var setInnerHTML = __webpack_require__(19);
  1382. /**
  1383. * Set the textContent property of a node, ensuring that whitespace is preserved
  1384. * even in IE8. innerText is a poor substitute for textContent and, among many
  1385. * issues, inserts <br> instead of the literal newline chars. innerHTML behaves
  1386. * as it should.
  1387. *
  1388. * @param {DOMElement} node
  1389. * @param {string} text
  1390. * @internal
  1391. */
  1392. var setTextContent = function (node, text) {
  1393. node.textContent = text;
  1394. };
  1395. if (ExecutionEnvironment.canUseDOM) {
  1396. if (!('textContent' in document.documentElement)) {
  1397. setTextContent = function (node, text) {
  1398. setInnerHTML(node, escapeTextContentForBrowser(text));
  1399. };
  1400. }
  1401. }
  1402. module.exports = setTextContent;
  1403. /***/ },
  1404. /* 21 */
  1405. /***/ function(module, exports) {
  1406. /**
  1407. * Copyright 2013-2015, Facebook, Inc.
  1408. * All rights reserved.
  1409. *
  1410. * This source code is licensed under the BSD-style license found in the
  1411. * LICENSE file in the root directory of this source tree. An additional grant
  1412. * of patent rights can be found in the PATENTS file in the same directory.
  1413. *
  1414. * @providesModule escapeTextContentForBrowser
  1415. */
  1416. 'use strict';
  1417. var ESCAPE_LOOKUP = {
  1418. '&': '&amp;',
  1419. '>': '&gt;',
  1420. '<': '&lt;',
  1421. '"': '&quot;',
  1422. '\'': '&#x27;'
  1423. };
  1424. var ESCAPE_REGEX = /[&><"']/g;
  1425. function escaper(match) {
  1426. return ESCAPE_LOOKUP[match];
  1427. }
  1428. /**
  1429. * Escapes text to prevent scripting attacks.
  1430. *
  1431. * @param {*} text Text value to escape.
  1432. * @return {string} An escaped string.
  1433. */
  1434. function escapeTextContentForBrowser(text) {
  1435. return ('' + text).replace(ESCAPE_REGEX, escaper);
  1436. }
  1437. module.exports = escapeTextContentForBrowser;
  1438. /***/ },
  1439. /* 22 */
  1440. /***/ function(module, exports, __webpack_require__) {
  1441. /* WEBPACK VAR INJECTION */(function(process) {/**
  1442. * Copyright 2013-2015, Facebook, Inc.
  1443. * All rights reserved.
  1444. *
  1445. * This source code is licensed under the BSD-style license found in the
  1446. * LICENSE file in the root directory of this source tree. An additional grant
  1447. * of patent rights can be found in the PATENTS file in the same directory.
  1448. *
  1449. * @providesModule DOMPropertyOperations
  1450. * @typechecks static-only
  1451. */
  1452. 'use strict';
  1453. var DOMProperty = __webpack_require__(23);
  1454. var ReactPerf = __webpack_require__(18);
  1455. var quoteAttributeValueForBrowser = __webpack_require__(24);
  1456. var warning = __webpack_require__(25);
  1457. // Simplified subset
  1458. var VALID_ATTRIBUTE_NAME_REGEX = /^[a-zA-Z_][\w\.\-]*$/;
  1459. var illegalAttributeNameCache = {};
  1460. var validatedAttributeNameCache = {};
  1461. function isAttributeNameSafe(attributeName) {
  1462. if (validatedAttributeNameCache.hasOwnProperty(attributeName)) {
  1463. return true;
  1464. }
  1465. if (illegalAttributeNameCache.hasOwnProperty(attributeName)) {
  1466. return false;
  1467. }
  1468. if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
  1469. validatedAttributeNameCache[attributeName] = true;
  1470. return true;
  1471. }
  1472. illegalAttributeNameCache[attributeName] = true;
  1473. process.env.NODE_ENV !== 'production' ? warning(false, 'Invalid attribute name: `%s`', attributeName) : undefined;
  1474. return false;
  1475. }
  1476. function shouldIgnoreValue(propertyInfo, value) {
  1477. return value == null || propertyInfo.hasBooleanValue && !value || propertyInfo.hasNumericValue && isNaN(value) || propertyInfo.hasPositiveNumericValue && value < 1 || propertyInfo.hasOverloadedBooleanValue && value === false;
  1478. }
  1479. if (process.env.NODE_ENV !== 'production') {
  1480. var reactProps = {
  1481. children: true,
  1482. dangerouslySetInnerHTML: true,
  1483. key: true,
  1484. ref: true
  1485. };
  1486. var warnedProperties = {};
  1487. var warnUnknownProperty = function (name) {
  1488. if (reactProps.hasOwnProperty(name) && reactProps[name] || warnedProperties.hasOwnProperty(name) && warnedProperties[name]) {
  1489. return;
  1490. }
  1491. warnedProperties[name] = true;
  1492. var lowerCasedName = name.toLowerCase();
  1493. // data-* attributes should be lowercase; suggest the lowercase version
  1494. var standardName = DOMProperty.isCustomAttribute(lowerCasedName) ? lowerCasedName : DOMProperty.getPossibleStandardName.hasOwnProperty(lowerCasedName) ? DOMProperty.getPossibleStandardName[lowerCasedName] : null;
  1495. // For now, only warn when we have a suggested correction. This prevents
  1496. // logging too much when using transferPropsTo.
  1497. process.env.NODE_ENV !== 'production' ? warning(standardName == null, 'Unknown DOM property %s. Did you mean %s?', name, standardName) : undefined;
  1498. };
  1499. }
  1500. /**
  1501. * Operations for dealing with DOM properties.
  1502. */
  1503. var DOMPropertyOperations = {
  1504. /**
  1505. * Creates markup for the ID property.
  1506. *
  1507. * @param {string} id Unescaped ID.
  1508. * @return {string} Markup string.
  1509. */
  1510. createMarkupForID: function (id) {
  1511. return DOMProperty.ID_ATTRIBUTE_NAME + '=' + quoteAttributeValueForBrowser(id);
  1512. },
  1513. setAttributeForID: function (node, id) {
  1514. node.setAttribute(DOMProperty.ID_ATTRIBUTE_NAME, id);
  1515. },
  1516. /**
  1517. * Creates markup for a property.
  1518. *
  1519. * @param {string} name
  1520. * @param {*} value
  1521. * @return {?string} Markup string, or null if the property was invalid.
  1522. */
  1523. createMarkupForProperty: function (name, value) {
  1524. var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
  1525. if (propertyInfo) {
  1526. if (shouldIgnoreValue(propertyInfo, value)) {
  1527. return '';
  1528. }
  1529. var attributeName = propertyInfo.attributeName;
  1530. if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
  1531. return attributeName + '=""';
  1532. }
  1533. return attributeName + '=' + quoteAttributeValueForBrowser(value);
  1534. } else if (DOMProperty.isCustomAttribute(name)) {
  1535. if (value == null) {
  1536. return '';
  1537. }
  1538. return name + '=' + quoteAttributeValueForBrowser(value);
  1539. } else if (process.env.NODE_ENV !== 'production') {
  1540. warnUnknownProperty(name);
  1541. }
  1542. return null;
  1543. },
  1544. /**
  1545. * Creates markup for a custom property.
  1546. *
  1547. * @param {string} name
  1548. * @param {*} value
  1549. * @return {string} Markup string, or empty string if the property was invalid.
  1550. */
  1551. createMarkupForCustomAttribute: function (name, value) {
  1552. if (!isAttributeNameSafe(name) || value == null) {
  1553. return '';
  1554. }
  1555. return name + '=' + quoteAttributeValueForBrowser(value);
  1556. },
  1557. /**
  1558. * Sets the value for a property on a node.
  1559. *
  1560. * @param {DOMElement} node
  1561. * @param {string} name
  1562. * @param {*} value
  1563. */
  1564. setValueForProperty: function (node, name, value) {
  1565. var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
  1566. if (propertyInfo) {
  1567. var mutationMethod = propertyInfo.mutationMethod;
  1568. if (mutationMethod) {
  1569. mutationMethod(node, value);
  1570. } else if (shouldIgnoreValue(propertyInfo, value)) {
  1571. this.deleteValueForProperty(node, name);
  1572. } else if (propertyInfo.mustUseAttribute) {
  1573. var attributeName = propertyInfo.attributeName;
  1574. var namespace = propertyInfo.attributeNamespace;
  1575. // `setAttribute` with objects becomes only `[object]` in IE8/9,
  1576. // ('' + value) makes it output the correct toString()-value.
  1577. if (namespace) {
  1578. node.setAttributeNS(namespace, attributeName, '' + value);
  1579. } else if (propertyInfo.hasBooleanValue || propertyInfo.hasOverloadedBooleanValue && value === true) {
  1580. node.setAttribute(attributeName, '');
  1581. } else {
  1582. node.setAttribute(attributeName, '' + value);
  1583. }
  1584. } else {
  1585. var propName = propertyInfo.propertyName;
  1586. // Must explicitly cast values for HAS_SIDE_EFFECTS-properties to the
  1587. // property type before comparing; only `value` does and is string.
  1588. if (!propertyInfo.hasSideEffects || '' + node[propName] !== '' + value) {
  1589. // Contrary to `setAttribute`, object properties are properly
  1590. // `toString`ed by IE8/9.
  1591. node[propName] = value;
  1592. }
  1593. }
  1594. } else if (DOMProperty.isCustomAttribute(name)) {
  1595. DOMPropertyOperations.setValueForAttribute(node, name, value);
  1596. } else if (process.env.NODE_ENV !== 'production') {
  1597. warnUnknownProperty(name);
  1598. }
  1599. },
  1600. setValueForAttribute: function (node, name, value) {
  1601. if (!isAttributeNameSafe(name)) {
  1602. return;
  1603. }
  1604. if (value == null) {
  1605. node.removeAttribute(name);
  1606. } else {
  1607. node.setAttribute(name, '' + value);
  1608. }
  1609. },
  1610. /**
  1611. * Deletes the value for a property on a node.
  1612. *
  1613. * @param {DOMElement} node
  1614. * @param {string} name
  1615. */
  1616. deleteValueForProperty: function (node, name) {
  1617. var propertyInfo = DOMProperty.properties.hasOwnProperty(name) ? DOMProperty.properties[name] : null;
  1618. if (propertyInfo) {
  1619. var mutationMethod = propertyInfo.mutationMethod;
  1620. if (mutationMethod) {
  1621. mutationMethod(node, undefined);
  1622. } else if (propertyInfo.mustUseAttribute) {
  1623. node.removeAttribute(propertyInfo.attributeName);
  1624. } else {
  1625. var propName = propertyInfo.propertyName;
  1626. var defaultValue = DOMProperty.getDefaultValueForProperty(node.nodeName, propName);
  1627. if (!propertyInfo.hasSideEffects || '' + node[propName] !== defaultValue) {
  1628. node[propName] = defaultValue;
  1629. }
  1630. }
  1631. } else if (DOMProperty.isCustomAttribute(name)) {
  1632. node.removeAttribute(name);
  1633. } else if (process.env.NODE_ENV !== 'production') {
  1634. warnUnknownProperty(name);
  1635. }
  1636. }
  1637. };
  1638. ReactPerf.measureMethods(DOMPropertyOperations, 'DOMPropertyOperations', {
  1639. setValueForProperty: 'setValueForProperty',
  1640. setValueForAttribute: 'setValueForAttribute',
  1641. deleteValueForProperty: 'deleteValueForProperty'
  1642. });
  1643. module.exports = DOMPropertyOperations;
  1644. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  1645. /***/ },
  1646. /* 23 */
  1647. /***/ function(module, exports, __webpack_require__) {
  1648. /* WEBPACK VAR INJECTION */(function(process) {/**
  1649. * Copyright 2013-2015, Facebook, Inc.
  1650. * All rights reserved.
  1651. *
  1652. * This source code is licensed under the BSD-style license found in the
  1653. * LICENSE file in the root directory of this source tree. An additional grant
  1654. * of patent rights can be found in the PATENTS file in the same directory.
  1655. *
  1656. * @providesModule DOMProperty
  1657. * @typechecks static-only
  1658. */
  1659. 'use strict';
  1660. var invariant = __webpack_require__(13);
  1661. function checkMask(value, bitmask) {
  1662. return (value & bitmask) === bitmask;
  1663. }
  1664. var DOMPropertyInjection = {
  1665. /**
  1666. * Mapping from normalized, camelcased property names to a configuration that
  1667. * specifies how the associated DOM property should be accessed or rendered.
  1668. */
  1669. MUST_USE_ATTRIBUTE: 0x1,
  1670. MUST_USE_PROPERTY: 0x2,
  1671. HAS_SIDE_EFFECTS: 0x4,
  1672. HAS_BOOLEAN_VALUE: 0x8,
  1673. HAS_NUMERIC_VALUE: 0x10,
  1674. HAS_POSITIVE_NUMERIC_VALUE: 0x20 | 0x10,
  1675. HAS_OVERLOADED_BOOLEAN_VALUE: 0x40,
  1676. /**
  1677. * Inject some specialized knowledge about the DOM. This takes a config object
  1678. * with the following properties:
  1679. *
  1680. * isCustomAttribute: function that given an attribute name will return true
  1681. * if it can be inserted into the DOM verbatim. Useful for data-* or aria-*
  1682. * attributes where it's impossible to enumerate all of the possible
  1683. * attribute names,
  1684. *
  1685. * Properties: object mapping DOM property name to one of the
  1686. * DOMPropertyInjection constants or null. If your attribute isn't in here,
  1687. * it won't get written to the DOM.
  1688. *
  1689. * DOMAttributeNames: object mapping React attribute name to the DOM
  1690. * attribute name. Attribute names not specified use the **lowercase**
  1691. * normalized name.
  1692. *
  1693. * DOMAttributeNamespaces: object mapping React attribute name to the DOM
  1694. * attribute namespace URL. (Attribute names not specified use no namespace.)
  1695. *
  1696. * DOMPropertyNames: similar to DOMAttributeNames but for DOM properties.
  1697. * Property names not specified use the normalized name.
  1698. *
  1699. * DOMMutationMethods: Properties that require special mutation methods. If
  1700. * `value` is undefined, the mutation method should unset the property.
  1701. *
  1702. * @param {object} domPropertyConfig the config as described above.
  1703. */
  1704. injectDOMPropertyConfig: function (domPropertyConfig) {
  1705. var Injection = DOMPropertyInjection;
  1706. var Properties = domPropertyConfig.Properties || {};
  1707. var DOMAttributeNamespaces = domPropertyConfig.DOMAttributeNamespaces || {};
  1708. var DOMAttributeNames = domPropertyConfig.DOMAttributeNames || {};
  1709. var DOMPropertyNames = domPropertyConfig.DOMPropertyNames || {};
  1710. var DOMMutationMethods = domPropertyConfig.DOMMutationMethods || {};
  1711. if (domPropertyConfig.isCustomAttribute) {
  1712. DOMProperty._isCustomAttributeFunctions.push(domPropertyConfig.isCustomAttribute);
  1713. }
  1714. for (var propName in Properties) {
  1715. !!DOMProperty.properties.hasOwnProperty(propName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'injectDOMPropertyConfig(...): You\'re trying to inject DOM property ' + '\'%s\' which has already been injected. You may be accidentally ' + 'injecting the same DOM property config twice, or you may be ' + 'injecting two configs that have conflicting property names.', propName) : invariant(false) : undefined;
  1716. var lowerCased = propName.toLowerCase();
  1717. var propConfig = Properties[propName];
  1718. var propertyInfo = {
  1719. attributeName: lowerCased,
  1720. attributeNamespace: null,
  1721. propertyName: propName,
  1722. mutationMethod: null,
  1723. mustUseAttribute: checkMask(propConfig, Injection.MUST_USE_ATTRIBUTE),
  1724. mustUseProperty: checkMask(propConfig, Injection.MUST_USE_PROPERTY),
  1725. hasSideEffects: checkMask(propConfig, Injection.HAS_SIDE_EFFECTS),
  1726. hasBooleanValue: checkMask(propConfig, Injection.HAS_BOOLEAN_VALUE),
  1727. hasNumericValue: checkMask(propConfig, Injection.HAS_NUMERIC_VALUE),
  1728. hasPositiveNumericValue: checkMask(propConfig, Injection.HAS_POSITIVE_NUMERIC_VALUE),
  1729. hasOverloadedBooleanValue: checkMask(propConfig, Injection.HAS_OVERLOADED_BOOLEAN_VALUE)
  1730. };
  1731. !(!propertyInfo.mustUseAttribute || !propertyInfo.mustUseProperty) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Cannot require using both attribute and property: %s', propName) : invariant(false) : undefined;
  1732. !(propertyInfo.mustUseProperty || !propertyInfo.hasSideEffects) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Properties that have side effects must use property: %s', propName) : invariant(false) : undefined;
  1733. !(propertyInfo.hasBooleanValue + propertyInfo.hasNumericValue + propertyInfo.hasOverloadedBooleanValue <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'DOMProperty: Value can be one of boolean, overloaded boolean, or ' + 'numeric value, but not a combination: %s', propName) : invariant(false) : undefined;
  1734. if (process.env.NODE_ENV !== 'production') {
  1735. DOMProperty.getPossibleStandardName[lowerCased] = propName;
  1736. }
  1737. if (DOMAttributeNames.hasOwnProperty(propName)) {
  1738. var attributeName = DOMAttributeNames[propName];
  1739. propertyInfo.attributeName = attributeName;
  1740. if (process.env.NODE_ENV !== 'production') {
  1741. DOMProperty.getPossibleStandardName[attributeName] = propName;
  1742. }
  1743. }
  1744. if (DOMAttributeNamespaces.hasOwnProperty(propName)) {
  1745. propertyInfo.attributeNamespace = DOMAttributeNamespaces[propName];
  1746. }
  1747. if (DOMPropertyNames.hasOwnProperty(propName)) {
  1748. propertyInfo.propertyName = DOMPropertyNames[propName];
  1749. }
  1750. if (DOMMutationMethods.hasOwnProperty(propName)) {
  1751. propertyInfo.mutationMethod = DOMMutationMethods[propName];
  1752. }
  1753. DOMProperty.properties[propName] = propertyInfo;
  1754. }
  1755. }
  1756. };
  1757. var defaultValueCache = {};
  1758. /**
  1759. * DOMProperty exports lookup objects that can be used like functions:
  1760. *
  1761. * > DOMProperty.isValid['id']
  1762. * true
  1763. * > DOMProperty.isValid['foobar']
  1764. * undefined
  1765. *
  1766. * Although this may be confusing, it performs better in general.
  1767. *
  1768. * @see http://jsperf.com/key-exists
  1769. * @see http://jsperf.com/key-missing
  1770. */
  1771. var DOMProperty = {
  1772. ID_ATTRIBUTE_NAME: 'data-reactid',
  1773. /**
  1774. * Map from property "standard name" to an object with info about how to set
  1775. * the property in the DOM. Each object contains:
  1776. *
  1777. * attributeName:
  1778. * Used when rendering markup or with `*Attribute()`.
  1779. * attributeNamespace
  1780. * propertyName:
  1781. * Used on DOM node instances. (This includes properties that mutate due to
  1782. * external factors.)
  1783. * mutationMethod:
  1784. * If non-null, used instead of the property or `setAttribute()` after
  1785. * initial render.
  1786. * mustUseAttribute:
  1787. * Whether the property must be accessed and mutated using `*Attribute()`.
  1788. * (This includes anything that fails `<propName> in <element>`.)
  1789. * mustUseProperty:
  1790. * Whether the property must be accessed and mutated as an object property.
  1791. * hasSideEffects:
  1792. * Whether or not setting a value causes side effects such as triggering
  1793. * resources to be loaded or text selection changes. If true, we read from
  1794. * the DOM before updating to ensure that the value is only set if it has
  1795. * changed.
  1796. * hasBooleanValue:
  1797. * Whether the property should be removed when set to a falsey value.
  1798. * hasNumericValue:
  1799. * Whether the property must be numeric or parse as a numeric and should be
  1800. * removed when set to a falsey value.
  1801. * hasPositiveNumericValue:
  1802. * Whether the property must be positive numeric or parse as a positive
  1803. * numeric and should be removed when set to a falsey value.
  1804. * hasOverloadedBooleanValue:
  1805. * Whether the property can be used as a flag as well as with a value.
  1806. * Removed when strictly equal to false; present without a value when
  1807. * strictly equal to true; present with a value otherwise.
  1808. */
  1809. properties: {},
  1810. /**
  1811. * Mapping from lowercase property names to the properly cased version, used
  1812. * to warn in the case of missing properties. Available only in __DEV__.
  1813. * @type {Object}
  1814. */
  1815. getPossibleStandardName: process.env.NODE_ENV !== 'production' ? {} : null,
  1816. /**
  1817. * All of the isCustomAttribute() functions that have been injected.
  1818. */
  1819. _isCustomAttributeFunctions: [],
  1820. /**
  1821. * Checks whether a property name is a custom attribute.
  1822. * @method
  1823. */
  1824. isCustomAttribute: function (attributeName) {
  1825. for (var i = 0; i < DOMProperty._isCustomAttributeFunctions.length; i++) {
  1826. var isCustomAttributeFn = DOMProperty._isCustomAttributeFunctions[i];
  1827. if (isCustomAttributeFn(attributeName)) {
  1828. return true;
  1829. }
  1830. }
  1831. return false;
  1832. },
  1833. /**
  1834. * Returns the default property value for a DOM property (i.e., not an
  1835. * attribute). Most default values are '' or false, but not all. Worse yet,
  1836. * some (in particular, `type`) vary depending on the type of element.
  1837. *
  1838. * TODO: Is it better to grab all the possible properties when creating an
  1839. * element to avoid having to create the same element twice?
  1840. */
  1841. getDefaultValueForProperty: function (nodeName, prop) {
  1842. var nodeDefaults = defaultValueCache[nodeName];
  1843. var testElement;
  1844. if (!nodeDefaults) {
  1845. defaultValueCache[nodeName] = nodeDefaults = {};
  1846. }
  1847. if (!(prop in nodeDefaults)) {
  1848. testElement = document.createElement(nodeName);
  1849. nodeDefaults[prop] = testElement[prop];
  1850. }
  1851. return nodeDefaults[prop];
  1852. },
  1853. injection: DOMPropertyInjection
  1854. };
  1855. module.exports = DOMProperty;
  1856. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  1857. /***/ },
  1858. /* 24 */
  1859. /***/ function(module, exports, __webpack_require__) {
  1860. /**
  1861. * Copyright 2013-2015, Facebook, Inc.
  1862. * All rights reserved.
  1863. *
  1864. * This source code is licensed under the BSD-style license found in the
  1865. * LICENSE file in the root directory of this source tree. An additional grant
  1866. * of patent rights can be found in the PATENTS file in the same directory.
  1867. *
  1868. * @providesModule quoteAttributeValueForBrowser
  1869. */
  1870. 'use strict';
  1871. var escapeTextContentForBrowser = __webpack_require__(21);
  1872. /**
  1873. * Escapes attribute value to prevent scripting attacks.
  1874. *
  1875. * @param {*} value Value to escape.
  1876. * @return {string} An escaped string.
  1877. */
  1878. function quoteAttributeValueForBrowser(value) {
  1879. return '"' + escapeTextContentForBrowser(value) + '"';
  1880. }
  1881. module.exports = quoteAttributeValueForBrowser;
  1882. /***/ },
  1883. /* 25 */
  1884. /***/ function(module, exports, __webpack_require__) {
  1885. /* WEBPACK VAR INJECTION */(function(process) {/**
  1886. * Copyright 2014-2015, Facebook, Inc.
  1887. * All rights reserved.
  1888. *
  1889. * This source code is licensed under the BSD-style license found in the
  1890. * LICENSE file in the root directory of this source tree. An additional grant
  1891. * of patent rights can be found in the PATENTS file in the same directory.
  1892. *
  1893. * @providesModule warning
  1894. */
  1895. 'use strict';
  1896. var emptyFunction = __webpack_require__(15);
  1897. /**
  1898. * Similar to invariant but only logs a warning if the condition is not met.
  1899. * This can be used to log issues in development environments in critical
  1900. * paths. Removing the logging code for production environments will keep the
  1901. * same logic and follow the same code paths.
  1902. */
  1903. var warning = emptyFunction;
  1904. if (process.env.NODE_ENV !== 'production') {
  1905. warning = function (condition, format) {
  1906. for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
  1907. args[_key - 2] = arguments[_key];
  1908. }
  1909. if (format === undefined) {
  1910. throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
  1911. }
  1912. if (format.indexOf('Failed Composite propType: ') === 0) {
  1913. return; // Ignore CompositeComponent proptype check.
  1914. }
  1915. if (!condition) {
  1916. var argIndex = 0;
  1917. var message = 'Warning: ' + format.replace(/%s/g, function () {
  1918. return args[argIndex++];
  1919. });
  1920. if (typeof console !== 'undefined') {
  1921. console.error(message);
  1922. }
  1923. try {
  1924. // --- Welcome to debugging React ---
  1925. // This error was thrown as a convenience so that you can use this stack
  1926. // to find the callsite that caused this warning to fire.
  1927. throw new Error(message);
  1928. } catch (x) {}
  1929. }
  1930. };
  1931. }
  1932. module.exports = warning;
  1933. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  1934. /***/ },
  1935. /* 26 */
  1936. /***/ function(module, exports, __webpack_require__) {
  1937. /**
  1938. * Copyright 2013-2015, Facebook, Inc.
  1939. * All rights reserved.
  1940. *
  1941. * This source code is licensed under the BSD-style license found in the
  1942. * LICENSE file in the root directory of this source tree. An additional grant
  1943. * of patent rights can be found in the PATENTS file in the same directory.
  1944. *
  1945. * @providesModule ReactComponentBrowserEnvironment
  1946. */
  1947. 'use strict';
  1948. var ReactDOMIDOperations = __webpack_require__(27);
  1949. var ReactMount = __webpack_require__(28);
  1950. /**
  1951. * Abstracts away all functionality of the reconciler that requires knowledge of
  1952. * the browser context. TODO: These callers should be refactored to avoid the
  1953. * need for this injection.
  1954. */
  1955. var ReactComponentBrowserEnvironment = {
  1956. processChildrenUpdates: ReactDOMIDOperations.dangerouslyProcessChildrenUpdates,
  1957. replaceNodeWithMarkupByID: ReactDOMIDOperations.dangerouslyReplaceNodeWithMarkupByID,
  1958. /**
  1959. * If a particular environment requires that some resources be cleaned up,
  1960. * specify this in the injected Mixin. In the DOM, we would likely want to
  1961. * purge any cached node ID lookups.
  1962. *
  1963. * @private
  1964. */
  1965. unmountIDFromEnvironment: function (rootNodeID) {
  1966. ReactMount.purgeID(rootNodeID);
  1967. }
  1968. };
  1969. module.exports = ReactComponentBrowserEnvironment;
  1970. /***/ },
  1971. /* 27 */
  1972. /***/ function(module, exports, __webpack_require__) {
  1973. /* WEBPACK VAR INJECTION */(function(process) {/**
  1974. * Copyright 2013-2015, Facebook, Inc.
  1975. * All rights reserved.
  1976. *
  1977. * This source code is licensed under the BSD-style license found in the
  1978. * LICENSE file in the root directory of this source tree. An additional grant
  1979. * of patent rights can be found in the PATENTS file in the same directory.
  1980. *
  1981. * @providesModule ReactDOMIDOperations
  1982. * @typechecks static-only
  1983. */
  1984. 'use strict';
  1985. var DOMChildrenOperations = __webpack_require__(7);
  1986. var DOMPropertyOperations = __webpack_require__(22);
  1987. var ReactMount = __webpack_require__(28);
  1988. var ReactPerf = __webpack_require__(18);
  1989. var invariant = __webpack_require__(13);
  1990. /**
  1991. * Errors for properties that should not be updated with `updatePropertyByID()`.
  1992. *
  1993. * @type {object}
  1994. * @private
  1995. */
  1996. var INVALID_PROPERTY_ERRORS = {
  1997. dangerouslySetInnerHTML: '`dangerouslySetInnerHTML` must be set using `updateInnerHTMLByID()`.',
  1998. style: '`style` must be set using `updateStylesByID()`.'
  1999. };
  2000. /**
  2001. * Operations used to process updates to DOM nodes.
  2002. */
  2003. var ReactDOMIDOperations = {
  2004. /**
  2005. * Updates a DOM node with new property values. This should only be used to
  2006. * update DOM properties in `DOMProperty`.
  2007. *
  2008. * @param {string} id ID of the node to update.
  2009. * @param {string} name A valid property name, see `DOMProperty`.
  2010. * @param {*} value New value of the property.
  2011. * @internal
  2012. */
  2013. updatePropertyByID: function (id, name, value) {
  2014. var node = ReactMount.getNode(id);
  2015. !!INVALID_PROPERTY_ERRORS.hasOwnProperty(name) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'updatePropertyByID(...): %s', INVALID_PROPERTY_ERRORS[name]) : invariant(false) : undefined;
  2016. // If we're updating to null or undefined, we should remove the property
  2017. // from the DOM node instead of inadvertantly setting to a string. This
  2018. // brings us in line with the same behavior we have on initial render.
  2019. if (value != null) {
  2020. DOMPropertyOperations.setValueForProperty(node, name, value);
  2021. } else {
  2022. DOMPropertyOperations.deleteValueForProperty(node, name);
  2023. }
  2024. },
  2025. /**
  2026. * Replaces a DOM node that exists in the document with markup.
  2027. *
  2028. * @param {string} id ID of child to be replaced.
  2029. * @param {string} markup Dangerous markup to inject in place of child.
  2030. * @internal
  2031. * @see {Danger.dangerouslyReplaceNodeWithMarkup}
  2032. */
  2033. dangerouslyReplaceNodeWithMarkupByID: function (id, markup) {
  2034. var node = ReactMount.getNode(id);
  2035. DOMChildrenOperations.dangerouslyReplaceNodeWithMarkup(node, markup);
  2036. },
  2037. /**
  2038. * Updates a component's children by processing a series of updates.
  2039. *
  2040. * @param {array<object>} updates List of update configurations.
  2041. * @param {array<string>} markup List of markup strings.
  2042. * @internal
  2043. */
  2044. dangerouslyProcessChildrenUpdates: function (updates, markup) {
  2045. for (var i = 0; i < updates.length; i++) {
  2046. updates[i].parentNode = ReactMount.getNode(updates[i].parentID);
  2047. }
  2048. DOMChildrenOperations.processUpdates(updates, markup);
  2049. }
  2050. };
  2051. ReactPerf.measureMethods(ReactDOMIDOperations, 'ReactDOMIDOperations', {
  2052. dangerouslyReplaceNodeWithMarkupByID: 'dangerouslyReplaceNodeWithMarkupByID',
  2053. dangerouslyProcessChildrenUpdates: 'dangerouslyProcessChildrenUpdates'
  2054. });
  2055. module.exports = ReactDOMIDOperations;
  2056. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  2057. /***/ },
  2058. /* 28 */
  2059. /***/ function(module, exports, __webpack_require__) {
  2060. /* WEBPACK VAR INJECTION */(function(process) {/**
  2061. * Copyright 2013-2015, Facebook, Inc.
  2062. * All rights reserved.
  2063. *
  2064. * This source code is licensed under the BSD-style license found in the
  2065. * LICENSE file in the root directory of this source tree. An additional grant
  2066. * of patent rights can be found in the PATENTS file in the same directory.
  2067. *
  2068. * @providesModule ReactMount
  2069. */
  2070. 'use strict';
  2071. var DOMProperty = __webpack_require__(23);
  2072. var ReactBrowserEventEmitter = __webpack_require__(29);
  2073. var ReactCurrentOwner = __webpack_require__(5);
  2074. var ReactDOMFeatureFlags = __webpack_require__(41);
  2075. var ReactElement = __webpack_require__(42);
  2076. var ReactEmptyComponentRegistry = __webpack_require__(44);
  2077. var ReactInstanceHandles = __webpack_require__(45);
  2078. var ReactInstanceMap = __webpack_require__(47);
  2079. var ReactMarkupChecksum = __webpack_require__(48);
  2080. var ReactPerf = __webpack_require__(18);
  2081. var ReactReconciler = __webpack_require__(50);
  2082. var ReactUpdateQueue = __webpack_require__(53);
  2083. var ReactUpdates = __webpack_require__(54);
  2084. var assign = __webpack_require__(39);
  2085. var emptyObject = __webpack_require__(58);
  2086. var containsNode = __webpack_require__(59);
  2087. var instantiateReactComponent = __webpack_require__(62);
  2088. var invariant = __webpack_require__(13);
  2089. var setInnerHTML = __webpack_require__(19);
  2090. var shouldUpdateReactComponent = __webpack_require__(67);
  2091. var validateDOMNesting = __webpack_require__(70);
  2092. var warning = __webpack_require__(25);
  2093. var ATTR_NAME = DOMProperty.ID_ATTRIBUTE_NAME;
  2094. var nodeCache = {};
  2095. var ELEMENT_NODE_TYPE = 1;
  2096. var DOC_NODE_TYPE = 9;
  2097. var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
  2098. var ownerDocumentContextKey = '__ReactMount_ownerDocument$' + Math.random().toString(36).slice(2);
  2099. /** Mapping from reactRootID to React component instance. */
  2100. var instancesByReactRootID = {};
  2101. /** Mapping from reactRootID to `container` nodes. */
  2102. var containersByReactRootID = {};
  2103. if (process.env.NODE_ENV !== 'production') {
  2104. /** __DEV__-only mapping from reactRootID to root elements. */
  2105. var rootElementsByReactRootID = {};
  2106. }
  2107. // Used to store breadth-first search state in findComponentRoot.
  2108. var findComponentRootReusableArray = [];
  2109. /**
  2110. * Finds the index of the first character
  2111. * that's not common between the two given strings.
  2112. *
  2113. * @return {number} the index of the character where the strings diverge
  2114. */
  2115. function firstDifferenceIndex(string1, string2) {
  2116. var minLen = Math.min(string1.length, string2.length);
  2117. for (var i = 0; i < minLen; i++) {
  2118. if (string1.charAt(i) !== string2.charAt(i)) {
  2119. return i;
  2120. }
  2121. }
  2122. return string1.length === string2.length ? -1 : minLen;
  2123. }
  2124. /**
  2125. * @param {DOMElement|DOMDocument} container DOM element that may contain
  2126. * a React component
  2127. * @return {?*} DOM element that may have the reactRoot ID, or null.
  2128. */
  2129. function getReactRootElementInContainer(container) {
  2130. if (!container) {
  2131. return null;
  2132. }
  2133. if (container.nodeType === DOC_NODE_TYPE) {
  2134. return container.documentElement;
  2135. } else {
  2136. return container.firstChild;
  2137. }
  2138. }
  2139. /**
  2140. * @param {DOMElement} container DOM element that may contain a React component.
  2141. * @return {?string} A "reactRoot" ID, if a React component is rendered.
  2142. */
  2143. function getReactRootID(container) {
  2144. var rootElement = getReactRootElementInContainer(container);
  2145. return rootElement && ReactMount.getID(rootElement);
  2146. }
  2147. /**
  2148. * Accessing node[ATTR_NAME] or calling getAttribute(ATTR_NAME) on a form
  2149. * element can return its control whose name or ID equals ATTR_NAME. All
  2150. * DOM nodes support `getAttributeNode` but this can also get called on
  2151. * other objects so just return '' if we're given something other than a
  2152. * DOM node (such as window).
  2153. *
  2154. * @param {?DOMElement|DOMWindow|DOMDocument|DOMTextNode} node DOM node.
  2155. * @return {string} ID of the supplied `domNode`.
  2156. */
  2157. function getID(node) {
  2158. var id = internalGetID(node);
  2159. if (id) {
  2160. if (nodeCache.hasOwnProperty(id)) {
  2161. var cached = nodeCache[id];
  2162. if (cached !== node) {
  2163. !!isValid(cached, id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Two valid but unequal nodes with the same `%s`: %s', ATTR_NAME, id) : invariant(false) : undefined;
  2164. nodeCache[id] = node;
  2165. }
  2166. } else {
  2167. nodeCache[id] = node;
  2168. }
  2169. }
  2170. return id;
  2171. }
  2172. function internalGetID(node) {
  2173. // If node is something like a window, document, or text node, none of
  2174. // which support attributes or a .getAttribute method, gracefully return
  2175. // the empty string, as if the attribute were missing.
  2176. return node && node.getAttribute && node.getAttribute(ATTR_NAME) || '';
  2177. }
  2178. /**
  2179. * Sets the React-specific ID of the given node.
  2180. *
  2181. * @param {DOMElement} node The DOM node whose ID will be set.
  2182. * @param {string} id The value of the ID attribute.
  2183. */
  2184. function setID(node, id) {
  2185. var oldID = internalGetID(node);
  2186. if (oldID !== id) {
  2187. delete nodeCache[oldID];
  2188. }
  2189. node.setAttribute(ATTR_NAME, id);
  2190. nodeCache[id] = node;
  2191. }
  2192. /**
  2193. * Finds the node with the supplied React-generated DOM ID.
  2194. *
  2195. * @param {string} id A React-generated DOM ID.
  2196. * @return {DOMElement} DOM node with the suppled `id`.
  2197. * @internal
  2198. */
  2199. function getNode(id) {
  2200. if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
  2201. nodeCache[id] = ReactMount.findReactNodeByID(id);
  2202. }
  2203. return nodeCache[id];
  2204. }
  2205. /**
  2206. * Finds the node with the supplied public React instance.
  2207. *
  2208. * @param {*} instance A public React instance.
  2209. * @return {?DOMElement} DOM node with the suppled `id`.
  2210. * @internal
  2211. */
  2212. function getNodeFromInstance(instance) {
  2213. var id = ReactInstanceMap.get(instance)._rootNodeID;
  2214. if (ReactEmptyComponentRegistry.isNullComponentID(id)) {
  2215. return null;
  2216. }
  2217. if (!nodeCache.hasOwnProperty(id) || !isValid(nodeCache[id], id)) {
  2218. nodeCache[id] = ReactMount.findReactNodeByID(id);
  2219. }
  2220. return nodeCache[id];
  2221. }
  2222. /**
  2223. * A node is "valid" if it is contained by a currently mounted container.
  2224. *
  2225. * This means that the node does not have to be contained by a document in
  2226. * order to be considered valid.
  2227. *
  2228. * @param {?DOMElement} node The candidate DOM node.
  2229. * @param {string} id The expected ID of the node.
  2230. * @return {boolean} Whether the node is contained by a mounted container.
  2231. */
  2232. function isValid(node, id) {
  2233. if (node) {
  2234. !(internalGetID(node) === id) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactMount: Unexpected modification of `%s`', ATTR_NAME) : invariant(false) : undefined;
  2235. var container = ReactMount.findReactContainerForID(id);
  2236. if (container && containsNode(container, node)) {
  2237. return true;
  2238. }
  2239. }
  2240. return false;
  2241. }
  2242. /**
  2243. * Causes the cache to forget about one React-specific ID.
  2244. *
  2245. * @param {string} id The ID to forget.
  2246. */
  2247. function purgeID(id) {
  2248. delete nodeCache[id];
  2249. }
  2250. var deepestNodeSoFar = null;
  2251. function findDeepestCachedAncestorImpl(ancestorID) {
  2252. var ancestor = nodeCache[ancestorID];
  2253. if (ancestor && isValid(ancestor, ancestorID)) {
  2254. deepestNodeSoFar = ancestor;
  2255. } else {
  2256. // This node isn't populated in the cache, so presumably none of its
  2257. // descendants are. Break out of the loop.
  2258. return false;
  2259. }
  2260. }
  2261. /**
  2262. * Return the deepest cached node whose ID is a prefix of `targetID`.
  2263. */
  2264. function findDeepestCachedAncestor(targetID) {
  2265. deepestNodeSoFar = null;
  2266. ReactInstanceHandles.traverseAncestors(targetID, findDeepestCachedAncestorImpl);
  2267. var foundNode = deepestNodeSoFar;
  2268. deepestNodeSoFar = null;
  2269. return foundNode;
  2270. }
  2271. /**
  2272. * Mounts this component and inserts it into the DOM.
  2273. *
  2274. * @param {ReactComponent} componentInstance The instance to mount.
  2275. * @param {string} rootID DOM ID of the root node.
  2276. * @param {DOMElement} container DOM element to mount into.
  2277. * @param {ReactReconcileTransaction} transaction
  2278. * @param {boolean} shouldReuseMarkup If true, do not insert markup
  2279. */
  2280. function mountComponentIntoNode(componentInstance, rootID, container, transaction, shouldReuseMarkup, context) {
  2281. if (ReactDOMFeatureFlags.useCreateElement) {
  2282. context = assign({}, context);
  2283. if (container.nodeType === DOC_NODE_TYPE) {
  2284. context[ownerDocumentContextKey] = container;
  2285. } else {
  2286. context[ownerDocumentContextKey] = container.ownerDocument;
  2287. }
  2288. }
  2289. if (process.env.NODE_ENV !== 'production') {
  2290. if (context === emptyObject) {
  2291. context = {};
  2292. }
  2293. var tag = container.nodeName.toLowerCase();
  2294. context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(null, tag, null);
  2295. }
  2296. var markup = ReactReconciler.mountComponent(componentInstance, rootID, transaction, context);
  2297. componentInstance._renderedComponent._topLevelWrapper = componentInstance;
  2298. ReactMount._mountImageIntoNode(markup, container, shouldReuseMarkup, transaction);
  2299. }
  2300. /**
  2301. * Batched mount.
  2302. *
  2303. * @param {ReactComponent} componentInstance The instance to mount.
  2304. * @param {string} rootID DOM ID of the root node.
  2305. * @param {DOMElement} container DOM element to mount into.
  2306. * @param {boolean} shouldReuseMarkup If true, do not insert markup
  2307. */
  2308. function batchedMountComponentIntoNode(componentInstance, rootID, container, shouldReuseMarkup, context) {
  2309. var transaction = ReactUpdates.ReactReconcileTransaction.getPooled(
  2310. /* forceHTML */shouldReuseMarkup);
  2311. transaction.perform(mountComponentIntoNode, null, componentInstance, rootID, container, transaction, shouldReuseMarkup, context);
  2312. ReactUpdates.ReactReconcileTransaction.release(transaction);
  2313. }
  2314. /**
  2315. * Unmounts a component and removes it from the DOM.
  2316. *
  2317. * @param {ReactComponent} instance React component instance.
  2318. * @param {DOMElement} container DOM element to unmount from.
  2319. * @final
  2320. * @internal
  2321. * @see {ReactMount.unmountComponentAtNode}
  2322. */
  2323. function unmountComponentFromNode(instance, container) {
  2324. ReactReconciler.unmountComponent(instance);
  2325. if (container.nodeType === DOC_NODE_TYPE) {
  2326. container = container.documentElement;
  2327. }
  2328. // http://jsperf.com/emptying-a-node
  2329. while (container.lastChild) {
  2330. container.removeChild(container.lastChild);
  2331. }
  2332. }
  2333. /**
  2334. * True if the supplied DOM node has a direct React-rendered child that is
  2335. * not a React root element. Useful for warning in `render`,
  2336. * `unmountComponentAtNode`, etc.
  2337. *
  2338. * @param {?DOMElement} node The candidate DOM node.
  2339. * @return {boolean} True if the DOM element contains a direct child that was
  2340. * rendered by React but is not a root element.
  2341. * @internal
  2342. */
  2343. function hasNonRootReactChild(node) {
  2344. var reactRootID = getReactRootID(node);
  2345. return reactRootID ? reactRootID !== ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID) : false;
  2346. }
  2347. /**
  2348. * Returns the first (deepest) ancestor of a node which is rendered by this copy
  2349. * of React.
  2350. */
  2351. function findFirstReactDOMImpl(node) {
  2352. // This node might be from another React instance, so we make sure not to
  2353. // examine the node cache here
  2354. for (; node && node.parentNode !== node; node = node.parentNode) {
  2355. if (node.nodeType !== 1) {
  2356. // Not a DOMElement, therefore not a React component
  2357. continue;
  2358. }
  2359. var nodeID = internalGetID(node);
  2360. if (!nodeID) {
  2361. continue;
  2362. }
  2363. var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
  2364. // If containersByReactRootID contains the container we find by crawling up
  2365. // the tree, we know that this instance of React rendered the node.
  2366. // nb. isValid's strategy (with containsNode) does not work because render
  2367. // trees may be nested and we don't want a false positive in that case.
  2368. var current = node;
  2369. var lastID;
  2370. do {
  2371. lastID = internalGetID(current);
  2372. current = current.parentNode;
  2373. if (current == null) {
  2374. // The passed-in node has been detached from the container it was
  2375. // originally rendered into.
  2376. return null;
  2377. }
  2378. } while (lastID !== reactRootID);
  2379. if (current === containersByReactRootID[reactRootID]) {
  2380. return node;
  2381. }
  2382. }
  2383. return null;
  2384. }
  2385. /**
  2386. * Temporary (?) hack so that we can store all top-level pending updates on
  2387. * composites instead of having to worry about different types of components
  2388. * here.
  2389. */
  2390. var TopLevelWrapper = function () {};
  2391. TopLevelWrapper.prototype.isReactComponent = {};
  2392. if (process.env.NODE_ENV !== 'production') {
  2393. TopLevelWrapper.displayName = 'TopLevelWrapper';
  2394. }
  2395. TopLevelWrapper.prototype.render = function () {
  2396. // this.props is actually a ReactElement
  2397. return this.props;
  2398. };
  2399. /**
  2400. * Mounting is the process of initializing a React component by creating its
  2401. * representative DOM elements and inserting them into a supplied `container`.
  2402. * Any prior content inside `container` is destroyed in the process.
  2403. *
  2404. * ReactMount.render(
  2405. * component,
  2406. * document.getElementById('container')
  2407. * );
  2408. *
  2409. * <div id="container"> <-- Supplied `container`.
  2410. * <div data-reactid=".3"> <-- Rendered reactRoot of React
  2411. * // ... component.
  2412. * </div>
  2413. * </div>
  2414. *
  2415. * Inside of `container`, the first element rendered is the "reactRoot".
  2416. */
  2417. var ReactMount = {
  2418. TopLevelWrapper: TopLevelWrapper,
  2419. /** Exposed for debugging purposes **/
  2420. _instancesByReactRootID: instancesByReactRootID,
  2421. /**
  2422. * This is a hook provided to support rendering React components while
  2423. * ensuring that the apparent scroll position of its `container` does not
  2424. * change.
  2425. *
  2426. * @param {DOMElement} container The `container` being rendered into.
  2427. * @param {function} renderCallback This must be called once to do the render.
  2428. */
  2429. scrollMonitor: function (container, renderCallback) {
  2430. renderCallback();
  2431. },
  2432. /**
  2433. * Take a component that's already mounted into the DOM and replace its props
  2434. * @param {ReactComponent} prevComponent component instance already in the DOM
  2435. * @param {ReactElement} nextElement component instance to render
  2436. * @param {DOMElement} container container to render into
  2437. * @param {?function} callback function triggered on completion
  2438. */
  2439. _updateRootComponent: function (prevComponent, nextElement, container, callback) {
  2440. ReactMount.scrollMonitor(container, function () {
  2441. ReactUpdateQueue.enqueueElementInternal(prevComponent, nextElement);
  2442. if (callback) {
  2443. ReactUpdateQueue.enqueueCallbackInternal(prevComponent, callback);
  2444. }
  2445. });
  2446. if (process.env.NODE_ENV !== 'production') {
  2447. // Record the root element in case it later gets transplanted.
  2448. rootElementsByReactRootID[getReactRootID(container)] = getReactRootElementInContainer(container);
  2449. }
  2450. return prevComponent;
  2451. },
  2452. /**
  2453. * Register a component into the instance map and starts scroll value
  2454. * monitoring
  2455. * @param {ReactComponent} nextComponent component instance to render
  2456. * @param {DOMElement} container container to render into
  2457. * @return {string} reactRoot ID prefix
  2458. */
  2459. _registerComponent: function (nextComponent, container) {
  2460. !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '_registerComponent(...): Target container is not a DOM element.') : invariant(false) : undefined;
  2461. ReactBrowserEventEmitter.ensureScrollValueMonitoring();
  2462. var reactRootID = ReactMount.registerContainer(container);
  2463. instancesByReactRootID[reactRootID] = nextComponent;
  2464. return reactRootID;
  2465. },
  2466. /**
  2467. * Render a new component into the DOM.
  2468. * @param {ReactElement} nextElement element to render
  2469. * @param {DOMElement} container container to render into
  2470. * @param {boolean} shouldReuseMarkup if we should skip the markup insertion
  2471. * @return {ReactComponent} nextComponent
  2472. */
  2473. _renderNewRootComponent: function (nextElement, container, shouldReuseMarkup, context) {
  2474. // Various parts of our code (such as ReactCompositeComponent's
  2475. // _renderValidatedComponent) assume that calls to render aren't nested;
  2476. // verify that that's the case.
  2477. process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '_renderNewRootComponent(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from ' + 'render is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined;
  2478. var componentInstance = instantiateReactComponent(nextElement, null);
  2479. var reactRootID = ReactMount._registerComponent(componentInstance, container);
  2480. // The initial render is synchronous but any updates that happen during
  2481. // rendering, in componentWillMount or componentDidMount, will be batched
  2482. // according to the current batching strategy.
  2483. ReactUpdates.batchedUpdates(batchedMountComponentIntoNode, componentInstance, reactRootID, container, shouldReuseMarkup, context);
  2484. if (process.env.NODE_ENV !== 'production') {
  2485. // Record the root element in case it later gets transplanted.
  2486. rootElementsByReactRootID[reactRootID] = getReactRootElementInContainer(container);
  2487. }
  2488. return componentInstance;
  2489. },
  2490. /**
  2491. * Renders a React component into the DOM in the supplied `container`.
  2492. *
  2493. * If the React component was previously rendered into `container`, this will
  2494. * perform an update on it and only mutate the DOM as necessary to reflect the
  2495. * latest React component.
  2496. *
  2497. * @param {ReactComponent} parentComponent The conceptual parent of this render tree.
  2498. * @param {ReactElement} nextElement Component element to render.
  2499. * @param {DOMElement} container DOM element to render into.
  2500. * @param {?function} callback function triggered on completion
  2501. * @return {ReactComponent} Component instance rendered in `container`.
  2502. */
  2503. renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
  2504. !(parentComponent != null && parentComponent._reactInternalInstance != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'parentComponent must be a valid React Component') : invariant(false) : undefined;
  2505. return ReactMount._renderSubtreeIntoContainer(parentComponent, nextElement, container, callback);
  2506. },
  2507. _renderSubtreeIntoContainer: function (parentComponent, nextElement, container, callback) {
  2508. !ReactElement.isValidElement(nextElement) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOM.render(): Invalid component element.%s', typeof nextElement === 'string' ? ' Instead of passing an element string, make sure to instantiate ' + 'it by passing it to React.createElement.' : typeof nextElement === 'function' ? ' Instead of passing a component class, make sure to instantiate ' + 'it by passing it to React.createElement.' :
  2509. // Check if it quacks like an element
  2510. nextElement != null && nextElement.props !== undefined ? ' This may be caused by unintentionally loading two independent ' + 'copies of React.' : '') : invariant(false) : undefined;
  2511. process.env.NODE_ENV !== 'production' ? warning(!container || !container.tagName || container.tagName.toUpperCase() !== 'BODY', 'render(): Rendering components directly into document.body is ' + 'discouraged, since its children are often manipulated by third-party ' + 'scripts and browser extensions. This may lead to subtle ' + 'reconciliation issues. Try rendering into a container element created ' + 'for your app.') : undefined;
  2512. var nextWrappedElement = new ReactElement(TopLevelWrapper, null, null, null, null, null, nextElement);
  2513. var prevComponent = instancesByReactRootID[getReactRootID(container)];
  2514. if (prevComponent) {
  2515. var prevWrappedElement = prevComponent._currentElement;
  2516. var prevElement = prevWrappedElement.props;
  2517. if (shouldUpdateReactComponent(prevElement, nextElement)) {
  2518. var publicInst = prevComponent._renderedComponent.getPublicInstance();
  2519. var updatedCallback = callback && function () {
  2520. callback.call(publicInst);
  2521. };
  2522. ReactMount._updateRootComponent(prevComponent, nextWrappedElement, container, updatedCallback);
  2523. return publicInst;
  2524. } else {
  2525. ReactMount.unmountComponentAtNode(container);
  2526. }
  2527. }
  2528. var reactRootElement = getReactRootElementInContainer(container);
  2529. var containerHasReactMarkup = reactRootElement && !!internalGetID(reactRootElement);
  2530. var containerHasNonRootReactChild = hasNonRootReactChild(container);
  2531. if (process.env.NODE_ENV !== 'production') {
  2532. process.env.NODE_ENV !== 'production' ? warning(!containerHasNonRootReactChild, 'render(...): Replacing React-rendered children with a new root ' + 'component. If you intended to update the children of this node, ' + 'you should instead have the existing children update their state ' + 'and render the new components instead of calling ReactDOM.render.') : undefined;
  2533. if (!containerHasReactMarkup || reactRootElement.nextSibling) {
  2534. var rootElementSibling = reactRootElement;
  2535. while (rootElementSibling) {
  2536. if (internalGetID(rootElementSibling)) {
  2537. process.env.NODE_ENV !== 'production' ? warning(false, 'render(): Target node has markup rendered by React, but there ' + 'are unrelated nodes as well. This is most commonly caused by ' + 'white-space inserted around server-rendered markup.') : undefined;
  2538. break;
  2539. }
  2540. rootElementSibling = rootElementSibling.nextSibling;
  2541. }
  2542. }
  2543. }
  2544. var shouldReuseMarkup = containerHasReactMarkup && !prevComponent && !containerHasNonRootReactChild;
  2545. var component = ReactMount._renderNewRootComponent(nextWrappedElement, container, shouldReuseMarkup, parentComponent != null ? parentComponent._reactInternalInstance._processChildContext(parentComponent._reactInternalInstance._context) : emptyObject)._renderedComponent.getPublicInstance();
  2546. if (callback) {
  2547. callback.call(component);
  2548. }
  2549. return component;
  2550. },
  2551. /**
  2552. * Renders a React component into the DOM in the supplied `container`.
  2553. *
  2554. * If the React component was previously rendered into `container`, this will
  2555. * perform an update on it and only mutate the DOM as necessary to reflect the
  2556. * latest React component.
  2557. *
  2558. * @param {ReactElement} nextElement Component element to render.
  2559. * @param {DOMElement} container DOM element to render into.
  2560. * @param {?function} callback function triggered on completion
  2561. * @return {ReactComponent} Component instance rendered in `container`.
  2562. */
  2563. render: function (nextElement, container, callback) {
  2564. return ReactMount._renderSubtreeIntoContainer(null, nextElement, container, callback);
  2565. },
  2566. /**
  2567. * Registers a container node into which React components will be rendered.
  2568. * This also creates the "reactRoot" ID that will be assigned to the element
  2569. * rendered within.
  2570. *
  2571. * @param {DOMElement} container DOM element to register as a container.
  2572. * @return {string} The "reactRoot" ID of elements rendered within.
  2573. */
  2574. registerContainer: function (container) {
  2575. var reactRootID = getReactRootID(container);
  2576. if (reactRootID) {
  2577. // If one exists, make sure it is a valid "reactRoot" ID.
  2578. reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(reactRootID);
  2579. }
  2580. if (!reactRootID) {
  2581. // No valid "reactRoot" ID found, create one.
  2582. reactRootID = ReactInstanceHandles.createReactRootID();
  2583. }
  2584. containersByReactRootID[reactRootID] = container;
  2585. return reactRootID;
  2586. },
  2587. /**
  2588. * Unmounts and destroys the React component rendered in the `container`.
  2589. *
  2590. * @param {DOMElement} container DOM element containing a React component.
  2591. * @return {boolean} True if a component was found in and unmounted from
  2592. * `container`
  2593. */
  2594. unmountComponentAtNode: function (container) {
  2595. // Various parts of our code (such as ReactCompositeComponent's
  2596. // _renderValidatedComponent) assume that calls to render aren't nested;
  2597. // verify that that's the case. (Strictly speaking, unmounting won't cause a
  2598. // render but we still don't expect to be in a render call here.)
  2599. process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, 'unmountComponentAtNode(): Render methods should be a pure function ' + 'of props and state; triggering nested component updates from render ' + 'is not allowed. If necessary, trigger nested updates in ' + 'componentDidUpdate. Check the render method of %s.', ReactCurrentOwner.current && ReactCurrentOwner.current.getName() || 'ReactCompositeComponent') : undefined;
  2600. !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'unmountComponentAtNode(...): Target container is not a DOM element.') : invariant(false) : undefined;
  2601. var reactRootID = getReactRootID(container);
  2602. var component = instancesByReactRootID[reactRootID];
  2603. if (!component) {
  2604. // Check if the node being unmounted was rendered by React, but isn't a
  2605. // root node.
  2606. var containerHasNonRootReactChild = hasNonRootReactChild(container);
  2607. // Check if the container itself is a React root node.
  2608. var containerID = internalGetID(container);
  2609. var isContainerReactRoot = containerID && containerID === ReactInstanceHandles.getReactRootIDFromNodeID(containerID);
  2610. if (process.env.NODE_ENV !== 'production') {
  2611. process.env.NODE_ENV !== 'production' ? warning(!containerHasNonRootReactChild, 'unmountComponentAtNode(): The node you\'re attempting to unmount ' + 'was rendered by React and is not a top-level container. %s', isContainerReactRoot ? 'You may have accidentally passed in a React root node instead ' + 'of its container.' : 'Instead, have the parent component update its state and ' + 'rerender in order to remove this component.') : undefined;
  2612. }
  2613. return false;
  2614. }
  2615. ReactUpdates.batchedUpdates(unmountComponentFromNode, component, container);
  2616. delete instancesByReactRootID[reactRootID];
  2617. delete containersByReactRootID[reactRootID];
  2618. if (process.env.NODE_ENV !== 'production') {
  2619. delete rootElementsByReactRootID[reactRootID];
  2620. }
  2621. return true;
  2622. },
  2623. /**
  2624. * Finds the container DOM element that contains React component to which the
  2625. * supplied DOM `id` belongs.
  2626. *
  2627. * @param {string} id The ID of an element rendered by a React component.
  2628. * @return {?DOMElement} DOM element that contains the `id`.
  2629. */
  2630. findReactContainerForID: function (id) {
  2631. var reactRootID = ReactInstanceHandles.getReactRootIDFromNodeID(id);
  2632. var container = containersByReactRootID[reactRootID];
  2633. if (process.env.NODE_ENV !== 'production') {
  2634. var rootElement = rootElementsByReactRootID[reactRootID];
  2635. if (rootElement && rootElement.parentNode !== container) {
  2636. process.env.NODE_ENV !== 'production' ? warning(
  2637. // Call internalGetID here because getID calls isValid which calls
  2638. // findReactContainerForID (this function).
  2639. internalGetID(rootElement) === reactRootID, 'ReactMount: Root element ID differed from reactRootID.') : undefined;
  2640. var containerChild = container.firstChild;
  2641. if (containerChild && reactRootID === internalGetID(containerChild)) {
  2642. // If the container has a new child with the same ID as the old
  2643. // root element, then rootElementsByReactRootID[reactRootID] is
  2644. // just stale and needs to be updated. The case that deserves a
  2645. // warning is when the container is empty.
  2646. rootElementsByReactRootID[reactRootID] = containerChild;
  2647. } else {
  2648. process.env.NODE_ENV !== 'production' ? warning(false, 'ReactMount: Root element has been removed from its original ' + 'container. New container: %s', rootElement.parentNode) : undefined;
  2649. }
  2650. }
  2651. }
  2652. return container;
  2653. },
  2654. /**
  2655. * Finds an element rendered by React with the supplied ID.
  2656. *
  2657. * @param {string} id ID of a DOM node in the React component.
  2658. * @return {DOMElement} Root DOM node of the React component.
  2659. */
  2660. findReactNodeByID: function (id) {
  2661. var reactRoot = ReactMount.findReactContainerForID(id);
  2662. return ReactMount.findComponentRoot(reactRoot, id);
  2663. },
  2664. /**
  2665. * Traverses up the ancestors of the supplied node to find a node that is a
  2666. * DOM representation of a React component rendered by this copy of React.
  2667. *
  2668. * @param {*} node
  2669. * @return {?DOMEventTarget}
  2670. * @internal
  2671. */
  2672. getFirstReactDOM: function (node) {
  2673. return findFirstReactDOMImpl(node);
  2674. },
  2675. /**
  2676. * Finds a node with the supplied `targetID` inside of the supplied
  2677. * `ancestorNode`. Exploits the ID naming scheme to perform the search
  2678. * quickly.
  2679. *
  2680. * @param {DOMEventTarget} ancestorNode Search from this root.
  2681. * @pararm {string} targetID ID of the DOM representation of the component.
  2682. * @return {DOMEventTarget} DOM node with the supplied `targetID`.
  2683. * @internal
  2684. */
  2685. findComponentRoot: function (ancestorNode, targetID) {
  2686. var firstChildren = findComponentRootReusableArray;
  2687. var childIndex = 0;
  2688. var deepestAncestor = findDeepestCachedAncestor(targetID) || ancestorNode;
  2689. if (process.env.NODE_ENV !== 'production') {
  2690. // This will throw on the next line; give an early warning
  2691. process.env.NODE_ENV !== 'production' ? warning(deepestAncestor != null, 'React can\'t find the root component node for data-reactid value ' + '`%s`. If you\'re seeing this message, it probably means that ' + 'you\'ve loaded two copies of React on the page. At this time, only ' + 'a single copy of React can be loaded at a time.', targetID) : undefined;
  2692. }
  2693. firstChildren[0] = deepestAncestor.firstChild;
  2694. firstChildren.length = 1;
  2695. while (childIndex < firstChildren.length) {
  2696. var child = firstChildren[childIndex++];
  2697. var targetChild;
  2698. while (child) {
  2699. var childID = ReactMount.getID(child);
  2700. if (childID) {
  2701. // Even if we find the node we're looking for, we finish looping
  2702. // through its siblings to ensure they're cached so that we don't have
  2703. // to revisit this node again. Otherwise, we make n^2 calls to getID
  2704. // when visiting the many children of a single node in order.
  2705. if (targetID === childID) {
  2706. targetChild = child;
  2707. } else if (ReactInstanceHandles.isAncestorIDOf(childID, targetID)) {
  2708. // If we find a child whose ID is an ancestor of the given ID,
  2709. // then we can be sure that we only want to search the subtree
  2710. // rooted at this child, so we can throw out the rest of the
  2711. // search state.
  2712. firstChildren.length = childIndex = 0;
  2713. firstChildren.push(child.firstChild);
  2714. }
  2715. } else {
  2716. // If this child had no ID, then there's a chance that it was
  2717. // injected automatically by the browser, as when a `<table>`
  2718. // element sprouts an extra `<tbody>` child as a side effect of
  2719. // `.innerHTML` parsing. Optimistically continue down this
  2720. // branch, but not before examining the other siblings.
  2721. firstChildren.push(child.firstChild);
  2722. }
  2723. child = child.nextSibling;
  2724. }
  2725. if (targetChild) {
  2726. // Emptying firstChildren/findComponentRootReusableArray is
  2727. // not necessary for correctness, but it helps the GC reclaim
  2728. // any nodes that were left at the end of the search.
  2729. firstChildren.length = 0;
  2730. return targetChild;
  2731. }
  2732. }
  2733. firstChildren.length = 0;
  2734. true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findComponentRoot(..., %s): Unable to find element. This probably ' + 'means the DOM was unexpectedly mutated (e.g., by the browser), ' + 'usually due to forgetting a <tbody> when using tables, nesting tags ' + 'like <form>, <p>, or <a>, or using non-SVG elements in an <svg> ' + 'parent. ' + 'Try inspecting the child nodes of the element with React ID `%s`.', targetID, ReactMount.getID(ancestorNode)) : invariant(false) : undefined;
  2735. },
  2736. _mountImageIntoNode: function (markup, container, shouldReuseMarkup, transaction) {
  2737. !(container && (container.nodeType === ELEMENT_NODE_TYPE || container.nodeType === DOC_NODE_TYPE || container.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mountComponentIntoNode(...): Target container is not valid.') : invariant(false) : undefined;
  2738. if (shouldReuseMarkup) {
  2739. var rootElement = getReactRootElementInContainer(container);
  2740. if (ReactMarkupChecksum.canReuseMarkup(markup, rootElement)) {
  2741. return;
  2742. } else {
  2743. var checksum = rootElement.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
  2744. rootElement.removeAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
  2745. var rootMarkup = rootElement.outerHTML;
  2746. rootElement.setAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME, checksum);
  2747. var normalizedMarkup = markup;
  2748. if (process.env.NODE_ENV !== 'production') {
  2749. // because rootMarkup is retrieved from the DOM, various normalizations
  2750. // will have occurred which will not be present in `markup`. Here,
  2751. // insert markup into a <div> or <iframe> depending on the container
  2752. // type to perform the same normalizations before comparing.
  2753. var normalizer;
  2754. if (container.nodeType === ELEMENT_NODE_TYPE) {
  2755. normalizer = document.createElement('div');
  2756. normalizer.innerHTML = markup;
  2757. normalizedMarkup = normalizer.innerHTML;
  2758. } else {
  2759. normalizer = document.createElement('iframe');
  2760. document.body.appendChild(normalizer);
  2761. normalizer.contentDocument.write(markup);
  2762. normalizedMarkup = normalizer.contentDocument.documentElement.outerHTML;
  2763. document.body.removeChild(normalizer);
  2764. }
  2765. }
  2766. var diffIndex = firstDifferenceIndex(normalizedMarkup, rootMarkup);
  2767. var difference = ' (client) ' + normalizedMarkup.substring(diffIndex - 20, diffIndex + 20) + '\n (server) ' + rootMarkup.substring(diffIndex - 20, diffIndex + 20);
  2768. !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document using ' + 'server rendering but the checksum was invalid. This usually ' + 'means you rendered a different component type or props on ' + 'the client from the one on the server, or your render() ' + 'methods are impure. React cannot handle this case due to ' + 'cross-browser quirks by rendering at the document root. You ' + 'should look for environment dependent code in your components ' + 'and ensure the props are the same client and server side:\n%s', difference) : invariant(false) : undefined;
  2769. if (process.env.NODE_ENV !== 'production') {
  2770. process.env.NODE_ENV !== 'production' ? warning(false, 'React attempted to reuse markup in a container but the ' + 'checksum was invalid. This generally means that you are ' + 'using server rendering and the markup generated on the ' + 'server was not what the client was expecting. React injected ' + 'new markup to compensate which works but you have lost many ' + 'of the benefits of server rendering. Instead, figure out ' + 'why the markup being generated is different on the client ' + 'or server:\n%s', difference) : undefined;
  2771. }
  2772. }
  2773. }
  2774. !(container.nodeType !== DOC_NODE_TYPE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'You\'re trying to render a component to the document but ' + 'you didn\'t use server rendering. We can\'t do this ' + 'without using server rendering due to cross-browser quirks. ' + 'See ReactDOMServer.renderToString() for server rendering.') : invariant(false) : undefined;
  2775. if (transaction.useCreateElement) {
  2776. while (container.lastChild) {
  2777. container.removeChild(container.lastChild);
  2778. }
  2779. container.appendChild(markup);
  2780. } else {
  2781. setInnerHTML(container, markup);
  2782. }
  2783. },
  2784. ownerDocumentContextKey: ownerDocumentContextKey,
  2785. /**
  2786. * React ID utilities.
  2787. */
  2788. getReactRootID: getReactRootID,
  2789. getID: getID,
  2790. setID: setID,
  2791. getNode: getNode,
  2792. getNodeFromInstance: getNodeFromInstance,
  2793. isValid: isValid,
  2794. purgeID: purgeID
  2795. };
  2796. ReactPerf.measureMethods(ReactMount, 'ReactMount', {
  2797. _renderNewRootComponent: '_renderNewRootComponent',
  2798. _mountImageIntoNode: '_mountImageIntoNode'
  2799. });
  2800. module.exports = ReactMount;
  2801. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  2802. /***/ },
  2803. /* 29 */
  2804. /***/ function(module, exports, __webpack_require__) {
  2805. /**
  2806. * Copyright 2013-2015, Facebook, Inc.
  2807. * All rights reserved.
  2808. *
  2809. * This source code is licensed under the BSD-style license found in the
  2810. * LICENSE file in the root directory of this source tree. An additional grant
  2811. * of patent rights can be found in the PATENTS file in the same directory.
  2812. *
  2813. * @providesModule ReactBrowserEventEmitter
  2814. * @typechecks static-only
  2815. */
  2816. 'use strict';
  2817. var EventConstants = __webpack_require__(30);
  2818. var EventPluginHub = __webpack_require__(31);
  2819. var EventPluginRegistry = __webpack_require__(32);
  2820. var ReactEventEmitterMixin = __webpack_require__(37);
  2821. var ReactPerf = __webpack_require__(18);
  2822. var ViewportMetrics = __webpack_require__(38);
  2823. var assign = __webpack_require__(39);
  2824. var isEventSupported = __webpack_require__(40);
  2825. /**
  2826. * Summary of `ReactBrowserEventEmitter` event handling:
  2827. *
  2828. * - Top-level delegation is used to trap most native browser events. This
  2829. * may only occur in the main thread and is the responsibility of
  2830. * ReactEventListener, which is injected and can therefore support pluggable
  2831. * event sources. This is the only work that occurs in the main thread.
  2832. *
  2833. * - We normalize and de-duplicate events to account for browser quirks. This
  2834. * may be done in the worker thread.
  2835. *
  2836. * - Forward these native events (with the associated top-level type used to
  2837. * trap it) to `EventPluginHub`, which in turn will ask plugins if they want
  2838. * to extract any synthetic events.
  2839. *
  2840. * - The `EventPluginHub` will then process each event by annotating them with
  2841. * "dispatches", a sequence of listeners and IDs that care about that event.
  2842. *
  2843. * - The `EventPluginHub` then dispatches the events.
  2844. *
  2845. * Overview of React and the event system:
  2846. *
  2847. * +------------+ .
  2848. * | DOM | .
  2849. * +------------+ .
  2850. * | .
  2851. * v .
  2852. * +------------+ .
  2853. * | ReactEvent | .
  2854. * | Listener | .
  2855. * +------------+ . +-----------+
  2856. * | . +--------+|SimpleEvent|
  2857. * | . | |Plugin |
  2858. * +-----|------+ . v +-----------+
  2859. * | | | . +--------------+ +------------+
  2860. * | +-----------.--->|EventPluginHub| | Event |
  2861. * | | . | | +-----------+ | Propagators|
  2862. * | ReactEvent | . | | |TapEvent | |------------|
  2863. * | Emitter | . | |<---+|Plugin | |other plugin|
  2864. * | | . | | +-----------+ | utilities |
  2865. * | +-----------.--->| | +------------+
  2866. * | | | . +--------------+
  2867. * +-----|------+ . ^ +-----------+
  2868. * | . | |Enter/Leave|
  2869. * + . +-------+|Plugin |
  2870. * +-------------+ . +-----------+
  2871. * | application | .
  2872. * |-------------| .
  2873. * | | .
  2874. * | | .
  2875. * +-------------+ .
  2876. * .
  2877. * React Core . General Purpose Event Plugin System
  2878. */
  2879. var alreadyListeningTo = {};
  2880. var isMonitoringScrollValue = false;
  2881. var reactTopListenersCounter = 0;
  2882. // For events like 'submit' which don't consistently bubble (which we trap at a
  2883. // lower node than `document`), binding at `document` would cause duplicate
  2884. // events so we don't include them here
  2885. var topEventMapping = {
  2886. topAbort: 'abort',
  2887. topBlur: 'blur',
  2888. topCanPlay: 'canplay',
  2889. topCanPlayThrough: 'canplaythrough',
  2890. topChange: 'change',
  2891. topClick: 'click',
  2892. topCompositionEnd: 'compositionend',
  2893. topCompositionStart: 'compositionstart',
  2894. topCompositionUpdate: 'compositionupdate',
  2895. topContextMenu: 'contextmenu',
  2896. topCopy: 'copy',
  2897. topCut: 'cut',
  2898. topDoubleClick: 'dblclick',
  2899. topDrag: 'drag',
  2900. topDragEnd: 'dragend',
  2901. topDragEnter: 'dragenter',
  2902. topDragExit: 'dragexit',
  2903. topDragLeave: 'dragleave',
  2904. topDragOver: 'dragover',
  2905. topDragStart: 'dragstart',
  2906. topDrop: 'drop',
  2907. topDurationChange: 'durationchange',
  2908. topEmptied: 'emptied',
  2909. topEncrypted: 'encrypted',
  2910. topEnded: 'ended',
  2911. topError: 'error',
  2912. topFocus: 'focus',
  2913. topInput: 'input',
  2914. topKeyDown: 'keydown',
  2915. topKeyPress: 'keypress',
  2916. topKeyUp: 'keyup',
  2917. topLoadedData: 'loadeddata',
  2918. topLoadedMetadata: 'loadedmetadata',
  2919. topLoadStart: 'loadstart',
  2920. topMouseDown: 'mousedown',
  2921. topMouseMove: 'mousemove',
  2922. topMouseOut: 'mouseout',
  2923. topMouseOver: 'mouseover',
  2924. topMouseUp: 'mouseup',
  2925. topPaste: 'paste',
  2926. topPause: 'pause',
  2927. topPlay: 'play',
  2928. topPlaying: 'playing',
  2929. topProgress: 'progress',
  2930. topRateChange: 'ratechange',
  2931. topScroll: 'scroll',
  2932. topSeeked: 'seeked',
  2933. topSeeking: 'seeking',
  2934. topSelectionChange: 'selectionchange',
  2935. topStalled: 'stalled',
  2936. topSuspend: 'suspend',
  2937. topTextInput: 'textInput',
  2938. topTimeUpdate: 'timeupdate',
  2939. topTouchCancel: 'touchcancel',
  2940. topTouchEnd: 'touchend',
  2941. topTouchMove: 'touchmove',
  2942. topTouchStart: 'touchstart',
  2943. topVolumeChange: 'volumechange',
  2944. topWaiting: 'waiting',
  2945. topWheel: 'wheel'
  2946. };
  2947. /**
  2948. * To ensure no conflicts with other potential React instances on the page
  2949. */
  2950. var topListenersIDKey = '_reactListenersID' + String(Math.random()).slice(2);
  2951. function getListeningForDocument(mountAt) {
  2952. // In IE8, `mountAt` is a host object and doesn't have `hasOwnProperty`
  2953. // directly.
  2954. if (!Object.prototype.hasOwnProperty.call(mountAt, topListenersIDKey)) {
  2955. mountAt[topListenersIDKey] = reactTopListenersCounter++;
  2956. alreadyListeningTo[mountAt[topListenersIDKey]] = {};
  2957. }
  2958. return alreadyListeningTo[mountAt[topListenersIDKey]];
  2959. }
  2960. /**
  2961. * `ReactBrowserEventEmitter` is used to attach top-level event listeners. For
  2962. * example:
  2963. *
  2964. * ReactBrowserEventEmitter.putListener('myID', 'onClick', myFunction);
  2965. *
  2966. * This would allocate a "registration" of `('onClick', myFunction)` on 'myID'.
  2967. *
  2968. * @internal
  2969. */
  2970. var ReactBrowserEventEmitter = assign({}, ReactEventEmitterMixin, {
  2971. /**
  2972. * Injectable event backend
  2973. */
  2974. ReactEventListener: null,
  2975. injection: {
  2976. /**
  2977. * @param {object} ReactEventListener
  2978. */
  2979. injectReactEventListener: function (ReactEventListener) {
  2980. ReactEventListener.setHandleTopLevel(ReactBrowserEventEmitter.handleTopLevel);
  2981. ReactBrowserEventEmitter.ReactEventListener = ReactEventListener;
  2982. }
  2983. },
  2984. /**
  2985. * Sets whether or not any created callbacks should be enabled.
  2986. *
  2987. * @param {boolean} enabled True if callbacks should be enabled.
  2988. */
  2989. setEnabled: function (enabled) {
  2990. if (ReactBrowserEventEmitter.ReactEventListener) {
  2991. ReactBrowserEventEmitter.ReactEventListener.setEnabled(enabled);
  2992. }
  2993. },
  2994. /**
  2995. * @return {boolean} True if callbacks are enabled.
  2996. */
  2997. isEnabled: function () {
  2998. return !!(ReactBrowserEventEmitter.ReactEventListener && ReactBrowserEventEmitter.ReactEventListener.isEnabled());
  2999. },
  3000. /**
  3001. * We listen for bubbled touch events on the document object.
  3002. *
  3003. * Firefox v8.01 (and possibly others) exhibited strange behavior when
  3004. * mounting `onmousemove` events at some node that was not the document
  3005. * element. The symptoms were that if your mouse is not moving over something
  3006. * contained within that mount point (for example on the background) the
  3007. * top-level listeners for `onmousemove` won't be called. However, if you
  3008. * register the `mousemove` on the document object, then it will of course
  3009. * catch all `mousemove`s. This along with iOS quirks, justifies restricting
  3010. * top-level listeners to the document object only, at least for these
  3011. * movement types of events and possibly all events.
  3012. *
  3013. * @see http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html
  3014. *
  3015. * Also, `keyup`/`keypress`/`keydown` do not bubble to the window on IE, but
  3016. * they bubble to document.
  3017. *
  3018. * @param {string} registrationName Name of listener (e.g. `onClick`).
  3019. * @param {object} contentDocumentHandle Document which owns the container
  3020. */
  3021. listenTo: function (registrationName, contentDocumentHandle) {
  3022. var mountAt = contentDocumentHandle;
  3023. var isListening = getListeningForDocument(mountAt);
  3024. var dependencies = EventPluginRegistry.registrationNameDependencies[registrationName];
  3025. var topLevelTypes = EventConstants.topLevelTypes;
  3026. for (var i = 0; i < dependencies.length; i++) {
  3027. var dependency = dependencies[i];
  3028. if (!(isListening.hasOwnProperty(dependency) && isListening[dependency])) {
  3029. if (dependency === topLevelTypes.topWheel) {
  3030. if (isEventSupported('wheel')) {
  3031. ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'wheel', mountAt);
  3032. } else if (isEventSupported('mousewheel')) {
  3033. ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'mousewheel', mountAt);
  3034. } else {
  3035. // Firefox needs to capture a different mouse scroll event.
  3036. // @see http://www.quirksmode.org/dom/events/tests/scroll.html
  3037. ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topWheel, 'DOMMouseScroll', mountAt);
  3038. }
  3039. } else if (dependency === topLevelTypes.topScroll) {
  3040. if (isEventSupported('scroll', true)) {
  3041. ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topScroll, 'scroll', mountAt);
  3042. } else {
  3043. ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topScroll, 'scroll', ReactBrowserEventEmitter.ReactEventListener.WINDOW_HANDLE);
  3044. }
  3045. } else if (dependency === topLevelTypes.topFocus || dependency === topLevelTypes.topBlur) {
  3046. if (isEventSupported('focus', true)) {
  3047. ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topFocus, 'focus', mountAt);
  3048. ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelTypes.topBlur, 'blur', mountAt);
  3049. } else if (isEventSupported('focusin')) {
  3050. // IE has `focusin` and `focusout` events which bubble.
  3051. // @see http://www.quirksmode.org/blog/archives/2008/04/delegating_the.html
  3052. ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topFocus, 'focusin', mountAt);
  3053. ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelTypes.topBlur, 'focusout', mountAt);
  3054. }
  3055. // to make sure blur and focus event listeners are only attached once
  3056. isListening[topLevelTypes.topBlur] = true;
  3057. isListening[topLevelTypes.topFocus] = true;
  3058. } else if (topEventMapping.hasOwnProperty(dependency)) {
  3059. ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(dependency, topEventMapping[dependency], mountAt);
  3060. }
  3061. isListening[dependency] = true;
  3062. }
  3063. }
  3064. },
  3065. trapBubbledEvent: function (topLevelType, handlerBaseName, handle) {
  3066. return ReactBrowserEventEmitter.ReactEventListener.trapBubbledEvent(topLevelType, handlerBaseName, handle);
  3067. },
  3068. trapCapturedEvent: function (topLevelType, handlerBaseName, handle) {
  3069. return ReactBrowserEventEmitter.ReactEventListener.trapCapturedEvent(topLevelType, handlerBaseName, handle);
  3070. },
  3071. /**
  3072. * Listens to window scroll and resize events. We cache scroll values so that
  3073. * application code can access them without triggering reflows.
  3074. *
  3075. * NOTE: Scroll events do not bubble.
  3076. *
  3077. * @see http://www.quirksmode.org/dom/events/scroll.html
  3078. */
  3079. ensureScrollValueMonitoring: function () {
  3080. if (!isMonitoringScrollValue) {
  3081. var refresh = ViewportMetrics.refreshScrollValues;
  3082. ReactBrowserEventEmitter.ReactEventListener.monitorScrollValue(refresh);
  3083. isMonitoringScrollValue = true;
  3084. }
  3085. },
  3086. eventNameDispatchConfigs: EventPluginHub.eventNameDispatchConfigs,
  3087. registrationNameModules: EventPluginHub.registrationNameModules,
  3088. putListener: EventPluginHub.putListener,
  3089. getListener: EventPluginHub.getListener,
  3090. deleteListener: EventPluginHub.deleteListener,
  3091. deleteAllListeners: EventPluginHub.deleteAllListeners
  3092. });
  3093. ReactPerf.measureMethods(ReactBrowserEventEmitter, 'ReactBrowserEventEmitter', {
  3094. putListener: 'putListener',
  3095. deleteListener: 'deleteListener'
  3096. });
  3097. module.exports = ReactBrowserEventEmitter;
  3098. /***/ },
  3099. /* 30 */
  3100. /***/ function(module, exports, __webpack_require__) {
  3101. /**
  3102. * Copyright 2013-2015, Facebook, Inc.
  3103. * All rights reserved.
  3104. *
  3105. * This source code is licensed under the BSD-style license found in the
  3106. * LICENSE file in the root directory of this source tree. An additional grant
  3107. * of patent rights can be found in the PATENTS file in the same directory.
  3108. *
  3109. * @providesModule EventConstants
  3110. */
  3111. 'use strict';
  3112. var keyMirror = __webpack_require__(17);
  3113. var PropagationPhases = keyMirror({ bubbled: null, captured: null });
  3114. /**
  3115. * Types of raw signals from the browser caught at the top level.
  3116. */
  3117. var topLevelTypes = keyMirror({
  3118. topAbort: null,
  3119. topBlur: null,
  3120. topCanPlay: null,
  3121. topCanPlayThrough: null,
  3122. topChange: null,
  3123. topClick: null,
  3124. topCompositionEnd: null,
  3125. topCompositionStart: null,
  3126. topCompositionUpdate: null,
  3127. topContextMenu: null,
  3128. topCopy: null,
  3129. topCut: null,
  3130. topDoubleClick: null,
  3131. topDrag: null,
  3132. topDragEnd: null,
  3133. topDragEnter: null,
  3134. topDragExit: null,
  3135. topDragLeave: null,
  3136. topDragOver: null,
  3137. topDragStart: null,
  3138. topDrop: null,
  3139. topDurationChange: null,
  3140. topEmptied: null,
  3141. topEncrypted: null,
  3142. topEnded: null,
  3143. topError: null,
  3144. topFocus: null,
  3145. topInput: null,
  3146. topKeyDown: null,
  3147. topKeyPress: null,
  3148. topKeyUp: null,
  3149. topLoad: null,
  3150. topLoadedData: null,
  3151. topLoadedMetadata: null,
  3152. topLoadStart: null,
  3153. topMouseDown: null,
  3154. topMouseMove: null,
  3155. topMouseOut: null,
  3156. topMouseOver: null,
  3157. topMouseUp: null,
  3158. topPaste: null,
  3159. topPause: null,
  3160. topPlay: null,
  3161. topPlaying: null,
  3162. topProgress: null,
  3163. topRateChange: null,
  3164. topReset: null,
  3165. topScroll: null,
  3166. topSeeked: null,
  3167. topSeeking: null,
  3168. topSelectionChange: null,
  3169. topStalled: null,
  3170. topSubmit: null,
  3171. topSuspend: null,
  3172. topTextInput: null,
  3173. topTimeUpdate: null,
  3174. topTouchCancel: null,
  3175. topTouchEnd: null,
  3176. topTouchMove: null,
  3177. topTouchStart: null,
  3178. topVolumeChange: null,
  3179. topWaiting: null,
  3180. topWheel: null
  3181. });
  3182. var EventConstants = {
  3183. topLevelTypes: topLevelTypes,
  3184. PropagationPhases: PropagationPhases
  3185. };
  3186. module.exports = EventConstants;
  3187. /***/ },
  3188. /* 31 */
  3189. /***/ function(module, exports, __webpack_require__) {
  3190. /* WEBPACK VAR INJECTION */(function(process) {/**
  3191. * Copyright 2013-2015, Facebook, Inc.
  3192. * All rights reserved.
  3193. *
  3194. * This source code is licensed under the BSD-style license found in the
  3195. * LICENSE file in the root directory of this source tree. An additional grant
  3196. * of patent rights can be found in the PATENTS file in the same directory.
  3197. *
  3198. * @providesModule EventPluginHub
  3199. */
  3200. 'use strict';
  3201. var EventPluginRegistry = __webpack_require__(32);
  3202. var EventPluginUtils = __webpack_require__(33);
  3203. var ReactErrorUtils = __webpack_require__(34);
  3204. var accumulateInto = __webpack_require__(35);
  3205. var forEachAccumulated = __webpack_require__(36);
  3206. var invariant = __webpack_require__(13);
  3207. var warning = __webpack_require__(25);
  3208. /**
  3209. * Internal store for event listeners
  3210. */
  3211. var listenerBank = {};
  3212. /**
  3213. * Internal queue of events that have accumulated their dispatches and are
  3214. * waiting to have their dispatches executed.
  3215. */
  3216. var eventQueue = null;
  3217. /**
  3218. * Dispatches an event and releases it back into the pool, unless persistent.
  3219. *
  3220. * @param {?object} event Synthetic event to be dispatched.
  3221. * @param {boolean} simulated If the event is simulated (changes exn behavior)
  3222. * @private
  3223. */
  3224. var executeDispatchesAndRelease = function (event, simulated) {
  3225. if (event) {
  3226. EventPluginUtils.executeDispatchesInOrder(event, simulated);
  3227. if (!event.isPersistent()) {
  3228. event.constructor.release(event);
  3229. }
  3230. }
  3231. };
  3232. var executeDispatchesAndReleaseSimulated = function (e) {
  3233. return executeDispatchesAndRelease(e, true);
  3234. };
  3235. var executeDispatchesAndReleaseTopLevel = function (e) {
  3236. return executeDispatchesAndRelease(e, false);
  3237. };
  3238. /**
  3239. * - `InstanceHandle`: [required] Module that performs logical traversals of DOM
  3240. * hierarchy given ids of the logical DOM elements involved.
  3241. */
  3242. var InstanceHandle = null;
  3243. function validateInstanceHandle() {
  3244. var valid = InstanceHandle && InstanceHandle.traverseTwoPhase && InstanceHandle.traverseEnterLeave;
  3245. process.env.NODE_ENV !== 'production' ? warning(valid, 'InstanceHandle not injected before use!') : undefined;
  3246. }
  3247. /**
  3248. * This is a unified interface for event plugins to be installed and configured.
  3249. *
  3250. * Event plugins can implement the following properties:
  3251. *
  3252. * `extractEvents` {function(string, DOMEventTarget, string, object): *}
  3253. * Required. When a top-level event is fired, this method is expected to
  3254. * extract synthetic events that will in turn be queued and dispatched.
  3255. *
  3256. * `eventTypes` {object}
  3257. * Optional, plugins that fire events must publish a mapping of registration
  3258. * names that are used to register listeners. Values of this mapping must
  3259. * be objects that contain `registrationName` or `phasedRegistrationNames`.
  3260. *
  3261. * `executeDispatch` {function(object, function, string)}
  3262. * Optional, allows plugins to override how an event gets dispatched. By
  3263. * default, the listener is simply invoked.
  3264. *
  3265. * Each plugin that is injected into `EventsPluginHub` is immediately operable.
  3266. *
  3267. * @public
  3268. */
  3269. var EventPluginHub = {
  3270. /**
  3271. * Methods for injecting dependencies.
  3272. */
  3273. injection: {
  3274. /**
  3275. * @param {object} InjectedMount
  3276. * @public
  3277. */
  3278. injectMount: EventPluginUtils.injection.injectMount,
  3279. /**
  3280. * @param {object} InjectedInstanceHandle
  3281. * @public
  3282. */
  3283. injectInstanceHandle: function (InjectedInstanceHandle) {
  3284. InstanceHandle = InjectedInstanceHandle;
  3285. if (process.env.NODE_ENV !== 'production') {
  3286. validateInstanceHandle();
  3287. }
  3288. },
  3289. getInstanceHandle: function () {
  3290. if (process.env.NODE_ENV !== 'production') {
  3291. validateInstanceHandle();
  3292. }
  3293. return InstanceHandle;
  3294. },
  3295. /**
  3296. * @param {array} InjectedEventPluginOrder
  3297. * @public
  3298. */
  3299. injectEventPluginOrder: EventPluginRegistry.injectEventPluginOrder,
  3300. /**
  3301. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  3302. */
  3303. injectEventPluginsByName: EventPluginRegistry.injectEventPluginsByName
  3304. },
  3305. eventNameDispatchConfigs: EventPluginRegistry.eventNameDispatchConfigs,
  3306. registrationNameModules: EventPluginRegistry.registrationNameModules,
  3307. /**
  3308. * Stores `listener` at `listenerBank[registrationName][id]`. Is idempotent.
  3309. *
  3310. * @param {string} id ID of the DOM element.
  3311. * @param {string} registrationName Name of listener (e.g. `onClick`).
  3312. * @param {?function} listener The callback to store.
  3313. */
  3314. putListener: function (id, registrationName, listener) {
  3315. !(typeof listener === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected %s listener to be a function, instead got type %s', registrationName, typeof listener) : invariant(false) : undefined;
  3316. var bankForRegistrationName = listenerBank[registrationName] || (listenerBank[registrationName] = {});
  3317. bankForRegistrationName[id] = listener;
  3318. var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
  3319. if (PluginModule && PluginModule.didPutListener) {
  3320. PluginModule.didPutListener(id, registrationName, listener);
  3321. }
  3322. },
  3323. /**
  3324. * @param {string} id ID of the DOM element.
  3325. * @param {string} registrationName Name of listener (e.g. `onClick`).
  3326. * @return {?function} The stored callback.
  3327. */
  3328. getListener: function (id, registrationName) {
  3329. var bankForRegistrationName = listenerBank[registrationName];
  3330. return bankForRegistrationName && bankForRegistrationName[id];
  3331. },
  3332. /**
  3333. * Deletes a listener from the registration bank.
  3334. *
  3335. * @param {string} id ID of the DOM element.
  3336. * @param {string} registrationName Name of listener (e.g. `onClick`).
  3337. */
  3338. deleteListener: function (id, registrationName) {
  3339. var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
  3340. if (PluginModule && PluginModule.willDeleteListener) {
  3341. PluginModule.willDeleteListener(id, registrationName);
  3342. }
  3343. var bankForRegistrationName = listenerBank[registrationName];
  3344. // TODO: This should never be null -- when is it?
  3345. if (bankForRegistrationName) {
  3346. delete bankForRegistrationName[id];
  3347. }
  3348. },
  3349. /**
  3350. * Deletes all listeners for the DOM element with the supplied ID.
  3351. *
  3352. * @param {string} id ID of the DOM element.
  3353. */
  3354. deleteAllListeners: function (id) {
  3355. for (var registrationName in listenerBank) {
  3356. if (!listenerBank[registrationName][id]) {
  3357. continue;
  3358. }
  3359. var PluginModule = EventPluginRegistry.registrationNameModules[registrationName];
  3360. if (PluginModule && PluginModule.willDeleteListener) {
  3361. PluginModule.willDeleteListener(id, registrationName);
  3362. }
  3363. delete listenerBank[registrationName][id];
  3364. }
  3365. },
  3366. /**
  3367. * Allows registered plugins an opportunity to extract events from top-level
  3368. * native browser events.
  3369. *
  3370. * @param {string} topLevelType Record from `EventConstants`.
  3371. * @param {DOMEventTarget} topLevelTarget The listening component root node.
  3372. * @param {string} topLevelTargetID ID of `topLevelTarget`.
  3373. * @param {object} nativeEvent Native browser event.
  3374. * @return {*} An accumulation of synthetic events.
  3375. * @internal
  3376. */
  3377. extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
  3378. var events;
  3379. var plugins = EventPluginRegistry.plugins;
  3380. for (var i = 0; i < plugins.length; i++) {
  3381. // Not every plugin in the ordering may be loaded at runtime.
  3382. var possiblePlugin = plugins[i];
  3383. if (possiblePlugin) {
  3384. var extractedEvents = possiblePlugin.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
  3385. if (extractedEvents) {
  3386. events = accumulateInto(events, extractedEvents);
  3387. }
  3388. }
  3389. }
  3390. return events;
  3391. },
  3392. /**
  3393. * Enqueues a synthetic event that should be dispatched when
  3394. * `processEventQueue` is invoked.
  3395. *
  3396. * @param {*} events An accumulation of synthetic events.
  3397. * @internal
  3398. */
  3399. enqueueEvents: function (events) {
  3400. if (events) {
  3401. eventQueue = accumulateInto(eventQueue, events);
  3402. }
  3403. },
  3404. /**
  3405. * Dispatches all synthetic events on the event queue.
  3406. *
  3407. * @internal
  3408. */
  3409. processEventQueue: function (simulated) {
  3410. // Set `eventQueue` to null before processing it so that we can tell if more
  3411. // events get enqueued while processing.
  3412. var processingEventQueue = eventQueue;
  3413. eventQueue = null;
  3414. if (simulated) {
  3415. forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseSimulated);
  3416. } else {
  3417. forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel);
  3418. }
  3419. !!eventQueue ? process.env.NODE_ENV !== 'production' ? invariant(false, 'processEventQueue(): Additional events were enqueued while processing ' + 'an event queue. Support for this has not yet been implemented.') : invariant(false) : undefined;
  3420. // This would be a good time to rethrow if any of the event handlers threw.
  3421. ReactErrorUtils.rethrowCaughtError();
  3422. },
  3423. /**
  3424. * These are needed for tests only. Do not use!
  3425. */
  3426. __purge: function () {
  3427. listenerBank = {};
  3428. },
  3429. __getListenerBank: function () {
  3430. return listenerBank;
  3431. }
  3432. };
  3433. module.exports = EventPluginHub;
  3434. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  3435. /***/ },
  3436. /* 32 */
  3437. /***/ function(module, exports, __webpack_require__) {
  3438. /* WEBPACK VAR INJECTION */(function(process) {/**
  3439. * Copyright 2013-2015, Facebook, Inc.
  3440. * All rights reserved.
  3441. *
  3442. * This source code is licensed under the BSD-style license found in the
  3443. * LICENSE file in the root directory of this source tree. An additional grant
  3444. * of patent rights can be found in the PATENTS file in the same directory.
  3445. *
  3446. * @providesModule EventPluginRegistry
  3447. * @typechecks static-only
  3448. */
  3449. 'use strict';
  3450. var invariant = __webpack_require__(13);
  3451. /**
  3452. * Injectable ordering of event plugins.
  3453. */
  3454. var EventPluginOrder = null;
  3455. /**
  3456. * Injectable mapping from names to event plugin modules.
  3457. */
  3458. var namesToPlugins = {};
  3459. /**
  3460. * Recomputes the plugin list using the injected plugins and plugin ordering.
  3461. *
  3462. * @private
  3463. */
  3464. function recomputePluginOrdering() {
  3465. if (!EventPluginOrder) {
  3466. // Wait until an `EventPluginOrder` is injected.
  3467. return;
  3468. }
  3469. for (var pluginName in namesToPlugins) {
  3470. var PluginModule = namesToPlugins[pluginName];
  3471. var pluginIndex = EventPluginOrder.indexOf(pluginName);
  3472. !(pluginIndex > -1) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugins that do not exist in ' + 'the plugin ordering, `%s`.', pluginName) : invariant(false) : undefined;
  3473. if (EventPluginRegistry.plugins[pluginIndex]) {
  3474. continue;
  3475. }
  3476. !PluginModule.extractEvents ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Event plugins must implement an `extractEvents` ' + 'method, but `%s` does not.', pluginName) : invariant(false) : undefined;
  3477. EventPluginRegistry.plugins[pluginIndex] = PluginModule;
  3478. var publishedEvents = PluginModule.eventTypes;
  3479. for (var eventName in publishedEvents) {
  3480. !publishEventForPlugin(publishedEvents[eventName], PluginModule, eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.', eventName, pluginName) : invariant(false) : undefined;
  3481. }
  3482. }
  3483. }
  3484. /**
  3485. * Publishes an event so that it can be dispatched by the supplied plugin.
  3486. *
  3487. * @param {object} dispatchConfig Dispatch configuration for the event.
  3488. * @param {object} PluginModule Plugin publishing the event.
  3489. * @return {boolean} True if the event was successfully published.
  3490. * @private
  3491. */
  3492. function publishEventForPlugin(dispatchConfig, PluginModule, eventName) {
  3493. !!EventPluginRegistry.eventNameDispatchConfigs.hasOwnProperty(eventName) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'event name, `%s`.', eventName) : invariant(false) : undefined;
  3494. EventPluginRegistry.eventNameDispatchConfigs[eventName] = dispatchConfig;
  3495. var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames;
  3496. if (phasedRegistrationNames) {
  3497. for (var phaseName in phasedRegistrationNames) {
  3498. if (phasedRegistrationNames.hasOwnProperty(phaseName)) {
  3499. var phasedRegistrationName = phasedRegistrationNames[phaseName];
  3500. publishRegistrationName(phasedRegistrationName, PluginModule, eventName);
  3501. }
  3502. }
  3503. return true;
  3504. } else if (dispatchConfig.registrationName) {
  3505. publishRegistrationName(dispatchConfig.registrationName, PluginModule, eventName);
  3506. return true;
  3507. }
  3508. return false;
  3509. }
  3510. /**
  3511. * Publishes a registration name that is used to identify dispatched events and
  3512. * can be used with `EventPluginHub.putListener` to register listeners.
  3513. *
  3514. * @param {string} registrationName Registration name to add.
  3515. * @param {object} PluginModule Plugin publishing the event.
  3516. * @private
  3517. */
  3518. function publishRegistrationName(registrationName, PluginModule, eventName) {
  3519. !!EventPluginRegistry.registrationNameModules[registrationName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginHub: More than one plugin attempted to publish the same ' + 'registration name, `%s`.', registrationName) : invariant(false) : undefined;
  3520. EventPluginRegistry.registrationNameModules[registrationName] = PluginModule;
  3521. EventPluginRegistry.registrationNameDependencies[registrationName] = PluginModule.eventTypes[eventName].dependencies;
  3522. }
  3523. /**
  3524. * Registers plugins so that they can extract and dispatch events.
  3525. *
  3526. * @see {EventPluginHub}
  3527. */
  3528. var EventPluginRegistry = {
  3529. /**
  3530. * Ordered list of injected plugins.
  3531. */
  3532. plugins: [],
  3533. /**
  3534. * Mapping from event name to dispatch config
  3535. */
  3536. eventNameDispatchConfigs: {},
  3537. /**
  3538. * Mapping from registration name to plugin module
  3539. */
  3540. registrationNameModules: {},
  3541. /**
  3542. * Mapping from registration name to event name
  3543. */
  3544. registrationNameDependencies: {},
  3545. /**
  3546. * Injects an ordering of plugins (by plugin name). This allows the ordering
  3547. * to be decoupled from injection of the actual plugins so that ordering is
  3548. * always deterministic regardless of packaging, on-the-fly injection, etc.
  3549. *
  3550. * @param {array} InjectedEventPluginOrder
  3551. * @internal
  3552. * @see {EventPluginHub.injection.injectEventPluginOrder}
  3553. */
  3554. injectEventPluginOrder: function (InjectedEventPluginOrder) {
  3555. !!EventPluginOrder ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject event plugin ordering more than ' + 'once. You are likely trying to load more than one copy of React.') : invariant(false) : undefined;
  3556. // Clone the ordering so it cannot be dynamically mutated.
  3557. EventPluginOrder = Array.prototype.slice.call(InjectedEventPluginOrder);
  3558. recomputePluginOrdering();
  3559. },
  3560. /**
  3561. * Injects plugins to be used by `EventPluginHub`. The plugin names must be
  3562. * in the ordering injected by `injectEventPluginOrder`.
  3563. *
  3564. * Plugins can be injected as part of page initialization or on-the-fly.
  3565. *
  3566. * @param {object} injectedNamesToPlugins Map from names to plugin modules.
  3567. * @internal
  3568. * @see {EventPluginHub.injection.injectEventPluginsByName}
  3569. */
  3570. injectEventPluginsByName: function (injectedNamesToPlugins) {
  3571. var isOrderingDirty = false;
  3572. for (var pluginName in injectedNamesToPlugins) {
  3573. if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) {
  3574. continue;
  3575. }
  3576. var PluginModule = injectedNamesToPlugins[pluginName];
  3577. if (!namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== PluginModule) {
  3578. !!namesToPlugins[pluginName] ? process.env.NODE_ENV !== 'production' ? invariant(false, 'EventPluginRegistry: Cannot inject two different event plugins ' + 'using the same name, `%s`.', pluginName) : invariant(false) : undefined;
  3579. namesToPlugins[pluginName] = PluginModule;
  3580. isOrderingDirty = true;
  3581. }
  3582. }
  3583. if (isOrderingDirty) {
  3584. recomputePluginOrdering();
  3585. }
  3586. },
  3587. /**
  3588. * Looks up the plugin for the supplied event.
  3589. *
  3590. * @param {object} event A synthetic event.
  3591. * @return {?object} The plugin that created the supplied event.
  3592. * @internal
  3593. */
  3594. getPluginModuleForEvent: function (event) {
  3595. var dispatchConfig = event.dispatchConfig;
  3596. if (dispatchConfig.registrationName) {
  3597. return EventPluginRegistry.registrationNameModules[dispatchConfig.registrationName] || null;
  3598. }
  3599. for (var phase in dispatchConfig.phasedRegistrationNames) {
  3600. if (!dispatchConfig.phasedRegistrationNames.hasOwnProperty(phase)) {
  3601. continue;
  3602. }
  3603. var PluginModule = EventPluginRegistry.registrationNameModules[dispatchConfig.phasedRegistrationNames[phase]];
  3604. if (PluginModule) {
  3605. return PluginModule;
  3606. }
  3607. }
  3608. return null;
  3609. },
  3610. /**
  3611. * Exposed for unit testing.
  3612. * @private
  3613. */
  3614. _resetEventPlugins: function () {
  3615. EventPluginOrder = null;
  3616. for (var pluginName in namesToPlugins) {
  3617. if (namesToPlugins.hasOwnProperty(pluginName)) {
  3618. delete namesToPlugins[pluginName];
  3619. }
  3620. }
  3621. EventPluginRegistry.plugins.length = 0;
  3622. var eventNameDispatchConfigs = EventPluginRegistry.eventNameDispatchConfigs;
  3623. for (var eventName in eventNameDispatchConfigs) {
  3624. if (eventNameDispatchConfigs.hasOwnProperty(eventName)) {
  3625. delete eventNameDispatchConfigs[eventName];
  3626. }
  3627. }
  3628. var registrationNameModules = EventPluginRegistry.registrationNameModules;
  3629. for (var registrationName in registrationNameModules) {
  3630. if (registrationNameModules.hasOwnProperty(registrationName)) {
  3631. delete registrationNameModules[registrationName];
  3632. }
  3633. }
  3634. }
  3635. };
  3636. module.exports = EventPluginRegistry;
  3637. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  3638. /***/ },
  3639. /* 33 */
  3640. /***/ function(module, exports, __webpack_require__) {
  3641. /* WEBPACK VAR INJECTION */(function(process) {/**
  3642. * Copyright 2013-2015, Facebook, Inc.
  3643. * All rights reserved.
  3644. *
  3645. * This source code is licensed under the BSD-style license found in the
  3646. * LICENSE file in the root directory of this source tree. An additional grant
  3647. * of patent rights can be found in the PATENTS file in the same directory.
  3648. *
  3649. * @providesModule EventPluginUtils
  3650. */
  3651. 'use strict';
  3652. var EventConstants = __webpack_require__(30);
  3653. var ReactErrorUtils = __webpack_require__(34);
  3654. var invariant = __webpack_require__(13);
  3655. var warning = __webpack_require__(25);
  3656. /**
  3657. * Injected dependencies:
  3658. */
  3659. /**
  3660. * - `Mount`: [required] Module that can convert between React dom IDs and
  3661. * actual node references.
  3662. */
  3663. var injection = {
  3664. Mount: null,
  3665. injectMount: function (InjectedMount) {
  3666. injection.Mount = InjectedMount;
  3667. if (process.env.NODE_ENV !== 'production') {
  3668. process.env.NODE_ENV !== 'production' ? warning(InjectedMount && InjectedMount.getNode && InjectedMount.getID, 'EventPluginUtils.injection.injectMount(...): Injected Mount ' + 'module is missing getNode or getID.') : undefined;
  3669. }
  3670. }
  3671. };
  3672. var topLevelTypes = EventConstants.topLevelTypes;
  3673. function isEndish(topLevelType) {
  3674. return topLevelType === topLevelTypes.topMouseUp || topLevelType === topLevelTypes.topTouchEnd || topLevelType === topLevelTypes.topTouchCancel;
  3675. }
  3676. function isMoveish(topLevelType) {
  3677. return topLevelType === topLevelTypes.topMouseMove || topLevelType === topLevelTypes.topTouchMove;
  3678. }
  3679. function isStartish(topLevelType) {
  3680. return topLevelType === topLevelTypes.topMouseDown || topLevelType === topLevelTypes.topTouchStart;
  3681. }
  3682. var validateEventDispatches;
  3683. if (process.env.NODE_ENV !== 'production') {
  3684. validateEventDispatches = function (event) {
  3685. var dispatchListeners = event._dispatchListeners;
  3686. var dispatchIDs = event._dispatchIDs;
  3687. var listenersIsArr = Array.isArray(dispatchListeners);
  3688. var idsIsArr = Array.isArray(dispatchIDs);
  3689. var IDsLen = idsIsArr ? dispatchIDs.length : dispatchIDs ? 1 : 0;
  3690. var listenersLen = listenersIsArr ? dispatchListeners.length : dispatchListeners ? 1 : 0;
  3691. process.env.NODE_ENV !== 'production' ? warning(idsIsArr === listenersIsArr && IDsLen === listenersLen, 'EventPluginUtils: Invalid `event`.') : undefined;
  3692. };
  3693. }
  3694. /**
  3695. * Dispatch the event to the listener.
  3696. * @param {SyntheticEvent} event SyntheticEvent to handle
  3697. * @param {boolean} simulated If the event is simulated (changes exn behavior)
  3698. * @param {function} listener Application-level callback
  3699. * @param {string} domID DOM id to pass to the callback.
  3700. */
  3701. function executeDispatch(event, simulated, listener, domID) {
  3702. var type = event.type || 'unknown-event';
  3703. event.currentTarget = injection.Mount.getNode(domID);
  3704. if (simulated) {
  3705. ReactErrorUtils.invokeGuardedCallbackWithCatch(type, listener, event, domID);
  3706. } else {
  3707. ReactErrorUtils.invokeGuardedCallback(type, listener, event, domID);
  3708. }
  3709. event.currentTarget = null;
  3710. }
  3711. /**
  3712. * Standard/simple iteration through an event's collected dispatches.
  3713. */
  3714. function executeDispatchesInOrder(event, simulated) {
  3715. var dispatchListeners = event._dispatchListeners;
  3716. var dispatchIDs = event._dispatchIDs;
  3717. if (process.env.NODE_ENV !== 'production') {
  3718. validateEventDispatches(event);
  3719. }
  3720. if (Array.isArray(dispatchListeners)) {
  3721. for (var i = 0; i < dispatchListeners.length; i++) {
  3722. if (event.isPropagationStopped()) {
  3723. break;
  3724. }
  3725. // Listeners and IDs are two parallel arrays that are always in sync.
  3726. executeDispatch(event, simulated, dispatchListeners[i], dispatchIDs[i]);
  3727. }
  3728. } else if (dispatchListeners) {
  3729. executeDispatch(event, simulated, dispatchListeners, dispatchIDs);
  3730. }
  3731. event._dispatchListeners = null;
  3732. event._dispatchIDs = null;
  3733. }
  3734. /**
  3735. * Standard/simple iteration through an event's collected dispatches, but stops
  3736. * at the first dispatch execution returning true, and returns that id.
  3737. *
  3738. * @return {?string} id of the first dispatch execution who's listener returns
  3739. * true, or null if no listener returned true.
  3740. */
  3741. function executeDispatchesInOrderStopAtTrueImpl(event) {
  3742. var dispatchListeners = event._dispatchListeners;
  3743. var dispatchIDs = event._dispatchIDs;
  3744. if (process.env.NODE_ENV !== 'production') {
  3745. validateEventDispatches(event);
  3746. }
  3747. if (Array.isArray(dispatchListeners)) {
  3748. for (var i = 0; i < dispatchListeners.length; i++) {
  3749. if (event.isPropagationStopped()) {
  3750. break;
  3751. }
  3752. // Listeners and IDs are two parallel arrays that are always in sync.
  3753. if (dispatchListeners[i](event, dispatchIDs[i])) {
  3754. return dispatchIDs[i];
  3755. }
  3756. }
  3757. } else if (dispatchListeners) {
  3758. if (dispatchListeners(event, dispatchIDs)) {
  3759. return dispatchIDs;
  3760. }
  3761. }
  3762. return null;
  3763. }
  3764. /**
  3765. * @see executeDispatchesInOrderStopAtTrueImpl
  3766. */
  3767. function executeDispatchesInOrderStopAtTrue(event) {
  3768. var ret = executeDispatchesInOrderStopAtTrueImpl(event);
  3769. event._dispatchIDs = null;
  3770. event._dispatchListeners = null;
  3771. return ret;
  3772. }
  3773. /**
  3774. * Execution of a "direct" dispatch - there must be at most one dispatch
  3775. * accumulated on the event or it is considered an error. It doesn't really make
  3776. * sense for an event with multiple dispatches (bubbled) to keep track of the
  3777. * return values at each dispatch execution, but it does tend to make sense when
  3778. * dealing with "direct" dispatches.
  3779. *
  3780. * @return {*} The return value of executing the single dispatch.
  3781. */
  3782. function executeDirectDispatch(event) {
  3783. if (process.env.NODE_ENV !== 'production') {
  3784. validateEventDispatches(event);
  3785. }
  3786. var dispatchListener = event._dispatchListeners;
  3787. var dispatchID = event._dispatchIDs;
  3788. !!Array.isArray(dispatchListener) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'executeDirectDispatch(...): Invalid `event`.') : invariant(false) : undefined;
  3789. var res = dispatchListener ? dispatchListener(event, dispatchID) : null;
  3790. event._dispatchListeners = null;
  3791. event._dispatchIDs = null;
  3792. return res;
  3793. }
  3794. /**
  3795. * @param {SyntheticEvent} event
  3796. * @return {boolean} True iff number of dispatches accumulated is greater than 0.
  3797. */
  3798. function hasDispatches(event) {
  3799. return !!event._dispatchListeners;
  3800. }
  3801. /**
  3802. * General utilities that are useful in creating custom Event Plugins.
  3803. */
  3804. var EventPluginUtils = {
  3805. isEndish: isEndish,
  3806. isMoveish: isMoveish,
  3807. isStartish: isStartish,
  3808. executeDirectDispatch: executeDirectDispatch,
  3809. executeDispatchesInOrder: executeDispatchesInOrder,
  3810. executeDispatchesInOrderStopAtTrue: executeDispatchesInOrderStopAtTrue,
  3811. hasDispatches: hasDispatches,
  3812. getNode: function (id) {
  3813. return injection.Mount.getNode(id);
  3814. },
  3815. getID: function (node) {
  3816. return injection.Mount.getID(node);
  3817. },
  3818. injection: injection
  3819. };
  3820. module.exports = EventPluginUtils;
  3821. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  3822. /***/ },
  3823. /* 34 */
  3824. /***/ function(module, exports, __webpack_require__) {
  3825. /* WEBPACK VAR INJECTION */(function(process) {/**
  3826. * Copyright 2013-2015, Facebook, Inc.
  3827. * All rights reserved.
  3828. *
  3829. * This source code is licensed under the BSD-style license found in the
  3830. * LICENSE file in the root directory of this source tree. An additional grant
  3831. * of patent rights can be found in the PATENTS file in the same directory.
  3832. *
  3833. * @providesModule ReactErrorUtils
  3834. * @typechecks
  3835. */
  3836. 'use strict';
  3837. var caughtError = null;
  3838. /**
  3839. * Call a function while guarding against errors that happens within it.
  3840. *
  3841. * @param {?String} name of the guard to use for logging or debugging
  3842. * @param {Function} func The function to invoke
  3843. * @param {*} a First argument
  3844. * @param {*} b Second argument
  3845. */
  3846. function invokeGuardedCallback(name, func, a, b) {
  3847. try {
  3848. return func(a, b);
  3849. } catch (x) {
  3850. if (caughtError === null) {
  3851. caughtError = x;
  3852. }
  3853. return undefined;
  3854. }
  3855. }
  3856. var ReactErrorUtils = {
  3857. invokeGuardedCallback: invokeGuardedCallback,
  3858. /**
  3859. * Invoked by ReactTestUtils.Simulate so that any errors thrown by the event
  3860. * handler are sure to be rethrown by rethrowCaughtError.
  3861. */
  3862. invokeGuardedCallbackWithCatch: invokeGuardedCallback,
  3863. /**
  3864. * During execution of guarded functions we will capture the first error which
  3865. * we will rethrow to be handled by the top level error handler.
  3866. */
  3867. rethrowCaughtError: function () {
  3868. if (caughtError) {
  3869. var error = caughtError;
  3870. caughtError = null;
  3871. throw error;
  3872. }
  3873. }
  3874. };
  3875. if (process.env.NODE_ENV !== 'production') {
  3876. /**
  3877. * To help development we can get better devtools integration by simulating a
  3878. * real browser event.
  3879. */
  3880. if (typeof window !== 'undefined' && typeof window.dispatchEvent === 'function' && typeof document !== 'undefined' && typeof document.createEvent === 'function') {
  3881. var fakeNode = document.createElement('react');
  3882. ReactErrorUtils.invokeGuardedCallback = function (name, func, a, b) {
  3883. var boundFunc = func.bind(null, a, b);
  3884. var evtType = 'react-' + name;
  3885. fakeNode.addEventListener(evtType, boundFunc, false);
  3886. var evt = document.createEvent('Event');
  3887. evt.initEvent(evtType, false, false);
  3888. fakeNode.dispatchEvent(evt);
  3889. fakeNode.removeEventListener(evtType, boundFunc, false);
  3890. };
  3891. }
  3892. }
  3893. module.exports = ReactErrorUtils;
  3894. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  3895. /***/ },
  3896. /* 35 */
  3897. /***/ function(module, exports, __webpack_require__) {
  3898. /* WEBPACK VAR INJECTION */(function(process) {/**
  3899. * Copyright 2014-2015, Facebook, Inc.
  3900. * All rights reserved.
  3901. *
  3902. * This source code is licensed under the BSD-style license found in the
  3903. * LICENSE file in the root directory of this source tree. An additional grant
  3904. * of patent rights can be found in the PATENTS file in the same directory.
  3905. *
  3906. * @providesModule accumulateInto
  3907. */
  3908. 'use strict';
  3909. var invariant = __webpack_require__(13);
  3910. /**
  3911. *
  3912. * Accumulates items that must not be null or undefined into the first one. This
  3913. * is used to conserve memory by avoiding array allocations, and thus sacrifices
  3914. * API cleanness. Since `current` can be null before being passed in and not
  3915. * null after this function, make sure to assign it back to `current`:
  3916. *
  3917. * `a = accumulateInto(a, b);`
  3918. *
  3919. * This API should be sparingly used. Try `accumulate` for something cleaner.
  3920. *
  3921. * @return {*|array<*>} An accumulation of items.
  3922. */
  3923. function accumulateInto(current, next) {
  3924. !(next != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'accumulateInto(...): Accumulated items must not be null or undefined.') : invariant(false) : undefined;
  3925. if (current == null) {
  3926. return next;
  3927. }
  3928. // Both are not empty. Warning: Never call x.concat(y) when you are not
  3929. // certain that x is an Array (x could be a string with concat method).
  3930. var currentIsArray = Array.isArray(current);
  3931. var nextIsArray = Array.isArray(next);
  3932. if (currentIsArray && nextIsArray) {
  3933. current.push.apply(current, next);
  3934. return current;
  3935. }
  3936. if (currentIsArray) {
  3937. current.push(next);
  3938. return current;
  3939. }
  3940. if (nextIsArray) {
  3941. // A bit too dangerous to mutate `next`.
  3942. return [current].concat(next);
  3943. }
  3944. return [current, next];
  3945. }
  3946. module.exports = accumulateInto;
  3947. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  3948. /***/ },
  3949. /* 36 */
  3950. /***/ function(module, exports) {
  3951. /**
  3952. * Copyright 2013-2015, Facebook, Inc.
  3953. * All rights reserved.
  3954. *
  3955. * This source code is licensed under the BSD-style license found in the
  3956. * LICENSE file in the root directory of this source tree. An additional grant
  3957. * of patent rights can be found in the PATENTS file in the same directory.
  3958. *
  3959. * @providesModule forEachAccumulated
  3960. */
  3961. 'use strict';
  3962. /**
  3963. * @param {array} arr an "accumulation" of items which is either an Array or
  3964. * a single item. Useful when paired with the `accumulate` module. This is a
  3965. * simple utility that allows us to reason about a collection of items, but
  3966. * handling the case when there is exactly one item (and we do not need to
  3967. * allocate an array).
  3968. */
  3969. var forEachAccumulated = function (arr, cb, scope) {
  3970. if (Array.isArray(arr)) {
  3971. arr.forEach(cb, scope);
  3972. } else if (arr) {
  3973. cb.call(scope, arr);
  3974. }
  3975. };
  3976. module.exports = forEachAccumulated;
  3977. /***/ },
  3978. /* 37 */
  3979. /***/ function(module, exports, __webpack_require__) {
  3980. /**
  3981. * Copyright 2013-2015, Facebook, Inc.
  3982. * All rights reserved.
  3983. *
  3984. * This source code is licensed under the BSD-style license found in the
  3985. * LICENSE file in the root directory of this source tree. An additional grant
  3986. * of patent rights can be found in the PATENTS file in the same directory.
  3987. *
  3988. * @providesModule ReactEventEmitterMixin
  3989. */
  3990. 'use strict';
  3991. var EventPluginHub = __webpack_require__(31);
  3992. function runEventQueueInBatch(events) {
  3993. EventPluginHub.enqueueEvents(events);
  3994. EventPluginHub.processEventQueue(false);
  3995. }
  3996. var ReactEventEmitterMixin = {
  3997. /**
  3998. * Streams a fired top-level event to `EventPluginHub` where plugins have the
  3999. * opportunity to create `ReactEvent`s to be dispatched.
  4000. *
  4001. * @param {string} topLevelType Record from `EventConstants`.
  4002. * @param {object} topLevelTarget The listening component root node.
  4003. * @param {string} topLevelTargetID ID of `topLevelTarget`.
  4004. * @param {object} nativeEvent Native environment event.
  4005. */
  4006. handleTopLevel: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
  4007. var events = EventPluginHub.extractEvents(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget);
  4008. runEventQueueInBatch(events);
  4009. }
  4010. };
  4011. module.exports = ReactEventEmitterMixin;
  4012. /***/ },
  4013. /* 38 */
  4014. /***/ function(module, exports) {
  4015. /**
  4016. * Copyright 2013-2015, Facebook, Inc.
  4017. * All rights reserved.
  4018. *
  4019. * This source code is licensed under the BSD-style license found in the
  4020. * LICENSE file in the root directory of this source tree. An additional grant
  4021. * of patent rights can be found in the PATENTS file in the same directory.
  4022. *
  4023. * @providesModule ViewportMetrics
  4024. */
  4025. 'use strict';
  4026. var ViewportMetrics = {
  4027. currentScrollLeft: 0,
  4028. currentScrollTop: 0,
  4029. refreshScrollValues: function (scrollPosition) {
  4030. ViewportMetrics.currentScrollLeft = scrollPosition.x;
  4031. ViewportMetrics.currentScrollTop = scrollPosition.y;
  4032. }
  4033. };
  4034. module.exports = ViewportMetrics;
  4035. /***/ },
  4036. /* 39 */
  4037. /***/ function(module, exports) {
  4038. /**
  4039. * Copyright 2014-2015, Facebook, Inc.
  4040. * All rights reserved.
  4041. *
  4042. * This source code is licensed under the BSD-style license found in the
  4043. * LICENSE file in the root directory of this source tree. An additional grant
  4044. * of patent rights can be found in the PATENTS file in the same directory.
  4045. *
  4046. * @providesModule Object.assign
  4047. */
  4048. // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-object.assign
  4049. 'use strict';
  4050. function assign(target, sources) {
  4051. if (target == null) {
  4052. throw new TypeError('Object.assign target cannot be null or undefined');
  4053. }
  4054. var to = Object(target);
  4055. var hasOwnProperty = Object.prototype.hasOwnProperty;
  4056. for (var nextIndex = 1; nextIndex < arguments.length; nextIndex++) {
  4057. var nextSource = arguments[nextIndex];
  4058. if (nextSource == null) {
  4059. continue;
  4060. }
  4061. var from = Object(nextSource);
  4062. // We don't currently support accessors nor proxies. Therefore this
  4063. // copy cannot throw. If we ever supported this then we must handle
  4064. // exceptions and side-effects. We don't support symbols so they won't
  4065. // be transferred.
  4066. for (var key in from) {
  4067. if (hasOwnProperty.call(from, key)) {
  4068. to[key] = from[key];
  4069. }
  4070. }
  4071. }
  4072. return to;
  4073. }
  4074. module.exports = assign;
  4075. /***/ },
  4076. /* 40 */
  4077. /***/ function(module, exports, __webpack_require__) {
  4078. /**
  4079. * Copyright 2013-2015, Facebook, Inc.
  4080. * All rights reserved.
  4081. *
  4082. * This source code is licensed under the BSD-style license found in the
  4083. * LICENSE file in the root directory of this source tree. An additional grant
  4084. * of patent rights can be found in the PATENTS file in the same directory.
  4085. *
  4086. * @providesModule isEventSupported
  4087. */
  4088. 'use strict';
  4089. var ExecutionEnvironment = __webpack_require__(9);
  4090. var useHasFeature;
  4091. if (ExecutionEnvironment.canUseDOM) {
  4092. useHasFeature = document.implementation && document.implementation.hasFeature &&
  4093. // always returns true in newer browsers as per the standard.
  4094. // @see http://dom.spec.whatwg.org/#dom-domimplementation-hasfeature
  4095. document.implementation.hasFeature('', '') !== true;
  4096. }
  4097. /**
  4098. * Checks if an event is supported in the current execution environment.
  4099. *
  4100. * NOTE: This will not work correctly for non-generic events such as `change`,
  4101. * `reset`, `load`, `error`, and `select`.
  4102. *
  4103. * Borrows from Modernizr.
  4104. *
  4105. * @param {string} eventNameSuffix Event name, e.g. "click".
  4106. * @param {?boolean} capture Check if the capture phase is supported.
  4107. * @return {boolean} True if the event is supported.
  4108. * @internal
  4109. * @license Modernizr 3.0.0pre (Custom Build) | MIT
  4110. */
  4111. function isEventSupported(eventNameSuffix, capture) {
  4112. if (!ExecutionEnvironment.canUseDOM || capture && !('addEventListener' in document)) {
  4113. return false;
  4114. }
  4115. var eventName = 'on' + eventNameSuffix;
  4116. var isSupported = (eventName in document);
  4117. if (!isSupported) {
  4118. var element = document.createElement('div');
  4119. element.setAttribute(eventName, 'return;');
  4120. isSupported = typeof element[eventName] === 'function';
  4121. }
  4122. if (!isSupported && useHasFeature && eventNameSuffix === 'wheel') {
  4123. // This is the only way to test support for the `wheel` event in IE9+.
  4124. isSupported = document.implementation.hasFeature('Events.wheel', '3.0');
  4125. }
  4126. return isSupported;
  4127. }
  4128. module.exports = isEventSupported;
  4129. /***/ },
  4130. /* 41 */
  4131. /***/ function(module, exports) {
  4132. /**
  4133. * Copyright 2013-2015, Facebook, Inc.
  4134. * All rights reserved.
  4135. *
  4136. * This source code is licensed under the BSD-style license found in the
  4137. * LICENSE file in the root directory of this source tree. An additional grant
  4138. * of patent rights can be found in the PATENTS file in the same directory.
  4139. *
  4140. * @providesModule ReactDOMFeatureFlags
  4141. */
  4142. 'use strict';
  4143. var ReactDOMFeatureFlags = {
  4144. useCreateElement: false
  4145. };
  4146. module.exports = ReactDOMFeatureFlags;
  4147. /***/ },
  4148. /* 42 */
  4149. /***/ function(module, exports, __webpack_require__) {
  4150. /* WEBPACK VAR INJECTION */(function(process) {/**
  4151. * Copyright 2014-2015, Facebook, Inc.
  4152. * All rights reserved.
  4153. *
  4154. * This source code is licensed under the BSD-style license found in the
  4155. * LICENSE file in the root directory of this source tree. An additional grant
  4156. * of patent rights can be found in the PATENTS file in the same directory.
  4157. *
  4158. * @providesModule ReactElement
  4159. */
  4160. 'use strict';
  4161. var ReactCurrentOwner = __webpack_require__(5);
  4162. var assign = __webpack_require__(39);
  4163. var canDefineProperty = __webpack_require__(43);
  4164. // The Symbol used to tag the ReactElement type. If there is no native Symbol
  4165. // nor polyfill, then a plain number is used for performance.
  4166. var REACT_ELEMENT_TYPE = typeof Symbol === 'function' && Symbol['for'] && Symbol['for']('react.element') || 0xeac7;
  4167. var RESERVED_PROPS = {
  4168. key: true,
  4169. ref: true,
  4170. __self: true,
  4171. __source: true
  4172. };
  4173. /**
  4174. * Base constructor for all React elements. This is only used to make this
  4175. * work with a dynamic instanceof check. Nothing should live on this prototype.
  4176. *
  4177. * @param {*} type
  4178. * @param {*} key
  4179. * @param {string|object} ref
  4180. * @param {*} self A *temporary* helper to detect places where `this` is
  4181. * different from the `owner` when React.createElement is called, so that we
  4182. * can warn. We want to get rid of owner and replace string `ref`s with arrow
  4183. * functions, and as long as `this` and owner are the same, there will be no
  4184. * change in behavior.
  4185. * @param {*} source An annotation object (added by a transpiler or otherwise)
  4186. * indicating filename, line number, and/or other information.
  4187. * @param {*} owner
  4188. * @param {*} props
  4189. * @internal
  4190. */
  4191. var ReactElement = function (type, key, ref, self, source, owner, props) {
  4192. var element = {
  4193. // This tag allow us to uniquely identify this as a React Element
  4194. $$typeof: REACT_ELEMENT_TYPE,
  4195. // Built-in properties that belong on the element
  4196. type: type,
  4197. key: key,
  4198. ref: ref,
  4199. props: props,
  4200. // Record the component responsible for creating this element.
  4201. _owner: owner
  4202. };
  4203. if (process.env.NODE_ENV !== 'production') {
  4204. // The validation flag is currently mutative. We put it on
  4205. // an external backing store so that we can freeze the whole object.
  4206. // This can be replaced with a WeakMap once they are implemented in
  4207. // commonly used development environments.
  4208. element._store = {};
  4209. // To make comparing ReactElements easier for testing purposes, we make
  4210. // the validation flag non-enumerable (where possible, which should
  4211. // include every environment we run tests in), so the test framework
  4212. // ignores it.
  4213. if (canDefineProperty) {
  4214. Object.defineProperty(element._store, 'validated', {
  4215. configurable: false,
  4216. enumerable: false,
  4217. writable: true,
  4218. value: false
  4219. });
  4220. // self and source are DEV only properties.
  4221. Object.defineProperty(element, '_self', {
  4222. configurable: false,
  4223. enumerable: false,
  4224. writable: false,
  4225. value: self
  4226. });
  4227. // Two elements created in two different places should be considered
  4228. // equal for testing purposes and therefore we hide it from enumeration.
  4229. Object.defineProperty(element, '_source', {
  4230. configurable: false,
  4231. enumerable: false,
  4232. writable: false,
  4233. value: source
  4234. });
  4235. } else {
  4236. element._store.validated = false;
  4237. element._self = self;
  4238. element._source = source;
  4239. }
  4240. Object.freeze(element.props);
  4241. Object.freeze(element);
  4242. }
  4243. return element;
  4244. };
  4245. ReactElement.createElement = function (type, config, children) {
  4246. var propName;
  4247. // Reserved names are extracted
  4248. var props = {};
  4249. var key = null;
  4250. var ref = null;
  4251. var self = null;
  4252. var source = null;
  4253. if (config != null) {
  4254. ref = config.ref === undefined ? null : config.ref;
  4255. key = config.key === undefined ? null : '' + config.key;
  4256. self = config.__self === undefined ? null : config.__self;
  4257. source = config.__source === undefined ? null : config.__source;
  4258. // Remaining properties are added to a new props object
  4259. for (propName in config) {
  4260. if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  4261. props[propName] = config[propName];
  4262. }
  4263. }
  4264. }
  4265. // Children can be more than one argument, and those are transferred onto
  4266. // the newly allocated props object.
  4267. var childrenLength = arguments.length - 2;
  4268. if (childrenLength === 1) {
  4269. props.children = children;
  4270. } else if (childrenLength > 1) {
  4271. var childArray = Array(childrenLength);
  4272. for (var i = 0; i < childrenLength; i++) {
  4273. childArray[i] = arguments[i + 2];
  4274. }
  4275. props.children = childArray;
  4276. }
  4277. // Resolve default props
  4278. if (type && type.defaultProps) {
  4279. var defaultProps = type.defaultProps;
  4280. for (propName in defaultProps) {
  4281. if (typeof props[propName] === 'undefined') {
  4282. props[propName] = defaultProps[propName];
  4283. }
  4284. }
  4285. }
  4286. return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
  4287. };
  4288. ReactElement.createFactory = function (type) {
  4289. var factory = ReactElement.createElement.bind(null, type);
  4290. // Expose the type on the factory and the prototype so that it can be
  4291. // easily accessed on elements. E.g. `<Foo />.type === Foo`.
  4292. // This should not be named `constructor` since this may not be the function
  4293. // that created the element, and it may not even be a constructor.
  4294. // Legacy hook TODO: Warn if this is accessed
  4295. factory.type = type;
  4296. return factory;
  4297. };
  4298. ReactElement.cloneAndReplaceKey = function (oldElement, newKey) {
  4299. var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
  4300. return newElement;
  4301. };
  4302. ReactElement.cloneAndReplaceProps = function (oldElement, newProps) {
  4303. var newElement = ReactElement(oldElement.type, oldElement.key, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, newProps);
  4304. if (process.env.NODE_ENV !== 'production') {
  4305. // If the key on the original is valid, then the clone is valid
  4306. newElement._store.validated = oldElement._store.validated;
  4307. }
  4308. return newElement;
  4309. };
  4310. ReactElement.cloneElement = function (element, config, children) {
  4311. var propName;
  4312. // Original props are copied
  4313. var props = assign({}, element.props);
  4314. // Reserved names are extracted
  4315. var key = element.key;
  4316. var ref = element.ref;
  4317. // Self is preserved since the owner is preserved.
  4318. var self = element._self;
  4319. // Source is preserved since cloneElement is unlikely to be targeted by a
  4320. // transpiler, and the original source is probably a better indicator of the
  4321. // true owner.
  4322. var source = element._source;
  4323. // Owner will be preserved, unless ref is overridden
  4324. var owner = element._owner;
  4325. if (config != null) {
  4326. if (config.ref !== undefined) {
  4327. // Silently steal the ref from the parent.
  4328. ref = config.ref;
  4329. owner = ReactCurrentOwner.current;
  4330. }
  4331. if (config.key !== undefined) {
  4332. key = '' + config.key;
  4333. }
  4334. // Remaining properties override existing props
  4335. for (propName in config) {
  4336. if (config.hasOwnProperty(propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
  4337. props[propName] = config[propName];
  4338. }
  4339. }
  4340. }
  4341. // Children can be more than one argument, and those are transferred onto
  4342. // the newly allocated props object.
  4343. var childrenLength = arguments.length - 2;
  4344. if (childrenLength === 1) {
  4345. props.children = children;
  4346. } else if (childrenLength > 1) {
  4347. var childArray = Array(childrenLength);
  4348. for (var i = 0; i < childrenLength; i++) {
  4349. childArray[i] = arguments[i + 2];
  4350. }
  4351. props.children = childArray;
  4352. }
  4353. return ReactElement(element.type, key, ref, self, source, owner, props);
  4354. };
  4355. /**
  4356. * @param {?object} object
  4357. * @return {boolean} True if `object` is a valid component.
  4358. * @final
  4359. */
  4360. ReactElement.isValidElement = function (object) {
  4361. return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
  4362. };
  4363. module.exports = ReactElement;
  4364. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  4365. /***/ },
  4366. /* 43 */
  4367. /***/ function(module, exports, __webpack_require__) {
  4368. /* WEBPACK VAR INJECTION */(function(process) {/**
  4369. * Copyright 2013-2015, Facebook, Inc.
  4370. * All rights reserved.
  4371. *
  4372. * This source code is licensed under the BSD-style license found in the
  4373. * LICENSE file in the root directory of this source tree. An additional grant
  4374. * of patent rights can be found in the PATENTS file in the same directory.
  4375. *
  4376. * @providesModule canDefineProperty
  4377. */
  4378. 'use strict';
  4379. var canDefineProperty = false;
  4380. if (process.env.NODE_ENV !== 'production') {
  4381. try {
  4382. Object.defineProperty({}, 'x', { get: function () {} });
  4383. canDefineProperty = true;
  4384. } catch (x) {
  4385. // IE will fail on defineProperty
  4386. }
  4387. }
  4388. module.exports = canDefineProperty;
  4389. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  4390. /***/ },
  4391. /* 44 */
  4392. /***/ function(module, exports) {
  4393. /**
  4394. * Copyright 2014-2015, Facebook, Inc.
  4395. * All rights reserved.
  4396. *
  4397. * This source code is licensed under the BSD-style license found in the
  4398. * LICENSE file in the root directory of this source tree. An additional grant
  4399. * of patent rights can be found in the PATENTS file in the same directory.
  4400. *
  4401. * @providesModule ReactEmptyComponentRegistry
  4402. */
  4403. 'use strict';
  4404. // This registry keeps track of the React IDs of the components that rendered to
  4405. // `null` (in reality a placeholder such as `noscript`)
  4406. var nullComponentIDsRegistry = {};
  4407. /**
  4408. * @param {string} id Component's `_rootNodeID`.
  4409. * @return {boolean} True if the component is rendered to null.
  4410. */
  4411. function isNullComponentID(id) {
  4412. return !!nullComponentIDsRegistry[id];
  4413. }
  4414. /**
  4415. * Mark the component as having rendered to null.
  4416. * @param {string} id Component's `_rootNodeID`.
  4417. */
  4418. function registerNullComponentID(id) {
  4419. nullComponentIDsRegistry[id] = true;
  4420. }
  4421. /**
  4422. * Unmark the component as having rendered to null: it renders to something now.
  4423. * @param {string} id Component's `_rootNodeID`.
  4424. */
  4425. function deregisterNullComponentID(id) {
  4426. delete nullComponentIDsRegistry[id];
  4427. }
  4428. var ReactEmptyComponentRegistry = {
  4429. isNullComponentID: isNullComponentID,
  4430. registerNullComponentID: registerNullComponentID,
  4431. deregisterNullComponentID: deregisterNullComponentID
  4432. };
  4433. module.exports = ReactEmptyComponentRegistry;
  4434. /***/ },
  4435. /* 45 */
  4436. /***/ function(module, exports, __webpack_require__) {
  4437. /* WEBPACK VAR INJECTION */(function(process) {/**
  4438. * Copyright 2013-2015, Facebook, Inc.
  4439. * All rights reserved.
  4440. *
  4441. * This source code is licensed under the BSD-style license found in the
  4442. * LICENSE file in the root directory of this source tree. An additional grant
  4443. * of patent rights can be found in the PATENTS file in the same directory.
  4444. *
  4445. * @providesModule ReactInstanceHandles
  4446. * @typechecks static-only
  4447. */
  4448. 'use strict';
  4449. var ReactRootIndex = __webpack_require__(46);
  4450. var invariant = __webpack_require__(13);
  4451. var SEPARATOR = '.';
  4452. var SEPARATOR_LENGTH = SEPARATOR.length;
  4453. /**
  4454. * Maximum depth of traversals before we consider the possibility of a bad ID.
  4455. */
  4456. var MAX_TREE_DEPTH = 10000;
  4457. /**
  4458. * Creates a DOM ID prefix to use when mounting React components.
  4459. *
  4460. * @param {number} index A unique integer
  4461. * @return {string} React root ID.
  4462. * @internal
  4463. */
  4464. function getReactRootIDString(index) {
  4465. return SEPARATOR + index.toString(36);
  4466. }
  4467. /**
  4468. * Checks if a character in the supplied ID is a separator or the end.
  4469. *
  4470. * @param {string} id A React DOM ID.
  4471. * @param {number} index Index of the character to check.
  4472. * @return {boolean} True if the character is a separator or end of the ID.
  4473. * @private
  4474. */
  4475. function isBoundary(id, index) {
  4476. return id.charAt(index) === SEPARATOR || index === id.length;
  4477. }
  4478. /**
  4479. * Checks if the supplied string is a valid React DOM ID.
  4480. *
  4481. * @param {string} id A React DOM ID, maybe.
  4482. * @return {boolean} True if the string is a valid React DOM ID.
  4483. * @private
  4484. */
  4485. function isValidID(id) {
  4486. return id === '' || id.charAt(0) === SEPARATOR && id.charAt(id.length - 1) !== SEPARATOR;
  4487. }
  4488. /**
  4489. * Checks if the first ID is an ancestor of or equal to the second ID.
  4490. *
  4491. * @param {string} ancestorID
  4492. * @param {string} descendantID
  4493. * @return {boolean} True if `ancestorID` is an ancestor of `descendantID`.
  4494. * @internal
  4495. */
  4496. function isAncestorIDOf(ancestorID, descendantID) {
  4497. return descendantID.indexOf(ancestorID) === 0 && isBoundary(descendantID, ancestorID.length);
  4498. }
  4499. /**
  4500. * Gets the parent ID of the supplied React DOM ID, `id`.
  4501. *
  4502. * @param {string} id ID of a component.
  4503. * @return {string} ID of the parent, or an empty string.
  4504. * @private
  4505. */
  4506. function getParentID(id) {
  4507. return id ? id.substr(0, id.lastIndexOf(SEPARATOR)) : '';
  4508. }
  4509. /**
  4510. * Gets the next DOM ID on the tree path from the supplied `ancestorID` to the
  4511. * supplied `destinationID`. If they are equal, the ID is returned.
  4512. *
  4513. * @param {string} ancestorID ID of an ancestor node of `destinationID`.
  4514. * @param {string} destinationID ID of the destination node.
  4515. * @return {string} Next ID on the path from `ancestorID` to `destinationID`.
  4516. * @private
  4517. */
  4518. function getNextDescendantID(ancestorID, destinationID) {
  4519. !(isValidID(ancestorID) && isValidID(destinationID)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(%s, %s): Received an invalid React DOM ID.', ancestorID, destinationID) : invariant(false) : undefined;
  4520. !isAncestorIDOf(ancestorID, destinationID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getNextDescendantID(...): React has made an invalid assumption about ' + 'the DOM hierarchy. Expected `%s` to be an ancestor of `%s`.', ancestorID, destinationID) : invariant(false) : undefined;
  4521. if (ancestorID === destinationID) {
  4522. return ancestorID;
  4523. }
  4524. // Skip over the ancestor and the immediate separator. Traverse until we hit
  4525. // another separator or we reach the end of `destinationID`.
  4526. var start = ancestorID.length + SEPARATOR_LENGTH;
  4527. var i;
  4528. for (i = start; i < destinationID.length; i++) {
  4529. if (isBoundary(destinationID, i)) {
  4530. break;
  4531. }
  4532. }
  4533. return destinationID.substr(0, i);
  4534. }
  4535. /**
  4536. * Gets the nearest common ancestor ID of two IDs.
  4537. *
  4538. * Using this ID scheme, the nearest common ancestor ID is the longest common
  4539. * prefix of the two IDs that immediately preceded a "marker" in both strings.
  4540. *
  4541. * @param {string} oneID
  4542. * @param {string} twoID
  4543. * @return {string} Nearest common ancestor ID, or the empty string if none.
  4544. * @private
  4545. */
  4546. function getFirstCommonAncestorID(oneID, twoID) {
  4547. var minLength = Math.min(oneID.length, twoID.length);
  4548. if (minLength === 0) {
  4549. return '';
  4550. }
  4551. var lastCommonMarkerIndex = 0;
  4552. // Use `<=` to traverse until the "EOL" of the shorter string.
  4553. for (var i = 0; i <= minLength; i++) {
  4554. if (isBoundary(oneID, i) && isBoundary(twoID, i)) {
  4555. lastCommonMarkerIndex = i;
  4556. } else if (oneID.charAt(i) !== twoID.charAt(i)) {
  4557. break;
  4558. }
  4559. }
  4560. var longestCommonID = oneID.substr(0, lastCommonMarkerIndex);
  4561. !isValidID(longestCommonID) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'getFirstCommonAncestorID(%s, %s): Expected a valid React DOM ID: %s', oneID, twoID, longestCommonID) : invariant(false) : undefined;
  4562. return longestCommonID;
  4563. }
  4564. /**
  4565. * Traverses the parent path between two IDs (either up or down). The IDs must
  4566. * not be the same, and there must exist a parent path between them. If the
  4567. * callback returns `false`, traversal is stopped.
  4568. *
  4569. * @param {?string} start ID at which to start traversal.
  4570. * @param {?string} stop ID at which to end traversal.
  4571. * @param {function} cb Callback to invoke each ID with.
  4572. * @param {*} arg Argument to invoke the callback with.
  4573. * @param {?boolean} skipFirst Whether or not to skip the first node.
  4574. * @param {?boolean} skipLast Whether or not to skip the last node.
  4575. * @private
  4576. */
  4577. function traverseParentPath(start, stop, cb, arg, skipFirst, skipLast) {
  4578. start = start || '';
  4579. stop = stop || '';
  4580. !(start !== stop) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(...): Cannot traverse from and to the same ID, `%s`.', start) : invariant(false) : undefined;
  4581. var traverseUp = isAncestorIDOf(stop, start);
  4582. !(traverseUp || isAncestorIDOf(start, stop)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Cannot traverse from two IDs that do ' + 'not have a parent path.', start, stop) : invariant(false) : undefined;
  4583. // Traverse from `start` to `stop` one depth at a time.
  4584. var depth = 0;
  4585. var traverse = traverseUp ? getParentID : getNextDescendantID;
  4586. for (var id = start;; /* until break */id = traverse(id, stop)) {
  4587. var ret;
  4588. if ((!skipFirst || id !== start) && (!skipLast || id !== stop)) {
  4589. ret = cb(id, traverseUp, arg);
  4590. }
  4591. if (ret === false || id === stop) {
  4592. // Only break //after// visiting `stop`.
  4593. break;
  4594. }
  4595. !(depth++ < MAX_TREE_DEPTH) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'traverseParentPath(%s, %s, ...): Detected an infinite loop while ' + 'traversing the React DOM ID tree. This may be due to malformed IDs: %s', start, stop, id) : invariant(false) : undefined;
  4596. }
  4597. }
  4598. /**
  4599. * Manages the IDs assigned to DOM representations of React components. This
  4600. * uses a specific scheme in order to traverse the DOM efficiently (e.g. in
  4601. * order to simulate events).
  4602. *
  4603. * @internal
  4604. */
  4605. var ReactInstanceHandles = {
  4606. /**
  4607. * Constructs a React root ID
  4608. * @return {string} A React root ID.
  4609. */
  4610. createReactRootID: function () {
  4611. return getReactRootIDString(ReactRootIndex.createReactRootIndex());
  4612. },
  4613. /**
  4614. * Constructs a React ID by joining a root ID with a name.
  4615. *
  4616. * @param {string} rootID Root ID of a parent component.
  4617. * @param {string} name A component's name (as flattened children).
  4618. * @return {string} A React ID.
  4619. * @internal
  4620. */
  4621. createReactID: function (rootID, name) {
  4622. return rootID + name;
  4623. },
  4624. /**
  4625. * Gets the DOM ID of the React component that is the root of the tree that
  4626. * contains the React component with the supplied DOM ID.
  4627. *
  4628. * @param {string} id DOM ID of a React component.
  4629. * @return {?string} DOM ID of the React component that is the root.
  4630. * @internal
  4631. */
  4632. getReactRootIDFromNodeID: function (id) {
  4633. if (id && id.charAt(0) === SEPARATOR && id.length > 1) {
  4634. var index = id.indexOf(SEPARATOR, 1);
  4635. return index > -1 ? id.substr(0, index) : id;
  4636. }
  4637. return null;
  4638. },
  4639. /**
  4640. * Traverses the ID hierarchy and invokes the supplied `cb` on any IDs that
  4641. * should would receive a `mouseEnter` or `mouseLeave` event.
  4642. *
  4643. * NOTE: Does not invoke the callback on the nearest common ancestor because
  4644. * nothing "entered" or "left" that element.
  4645. *
  4646. * @param {string} leaveID ID being left.
  4647. * @param {string} enterID ID being entered.
  4648. * @param {function} cb Callback to invoke on each entered/left ID.
  4649. * @param {*} upArg Argument to invoke the callback with on left IDs.
  4650. * @param {*} downArg Argument to invoke the callback with on entered IDs.
  4651. * @internal
  4652. */
  4653. traverseEnterLeave: function (leaveID, enterID, cb, upArg, downArg) {
  4654. var ancestorID = getFirstCommonAncestorID(leaveID, enterID);
  4655. if (ancestorID !== leaveID) {
  4656. traverseParentPath(leaveID, ancestorID, cb, upArg, false, true);
  4657. }
  4658. if (ancestorID !== enterID) {
  4659. traverseParentPath(ancestorID, enterID, cb, downArg, true, false);
  4660. }
  4661. },
  4662. /**
  4663. * Simulates the traversal of a two-phase, capture/bubble event dispatch.
  4664. *
  4665. * NOTE: This traversal happens on IDs without touching the DOM.
  4666. *
  4667. * @param {string} targetID ID of the target node.
  4668. * @param {function} cb Callback to invoke.
  4669. * @param {*} arg Argument to invoke the callback with.
  4670. * @internal
  4671. */
  4672. traverseTwoPhase: function (targetID, cb, arg) {
  4673. if (targetID) {
  4674. traverseParentPath('', targetID, cb, arg, true, false);
  4675. traverseParentPath(targetID, '', cb, arg, false, true);
  4676. }
  4677. },
  4678. /**
  4679. * Same as `traverseTwoPhase` but skips the `targetID`.
  4680. */
  4681. traverseTwoPhaseSkipTarget: function (targetID, cb, arg) {
  4682. if (targetID) {
  4683. traverseParentPath('', targetID, cb, arg, true, true);
  4684. traverseParentPath(targetID, '', cb, arg, true, true);
  4685. }
  4686. },
  4687. /**
  4688. * Traverse a node ID, calling the supplied `cb` for each ancestor ID. For
  4689. * example, passing `.0.$row-0.1` would result in `cb` getting called
  4690. * with `.0`, `.0.$row-0`, and `.0.$row-0.1`.
  4691. *
  4692. * NOTE: This traversal happens on IDs without touching the DOM.
  4693. *
  4694. * @param {string} targetID ID of the target node.
  4695. * @param {function} cb Callback to invoke.
  4696. * @param {*} arg Argument to invoke the callback with.
  4697. * @internal
  4698. */
  4699. traverseAncestors: function (targetID, cb, arg) {
  4700. traverseParentPath('', targetID, cb, arg, true, false);
  4701. },
  4702. getFirstCommonAncestorID: getFirstCommonAncestorID,
  4703. /**
  4704. * Exposed for unit testing.
  4705. * @private
  4706. */
  4707. _getNextDescendantID: getNextDescendantID,
  4708. isAncestorIDOf: isAncestorIDOf,
  4709. SEPARATOR: SEPARATOR
  4710. };
  4711. module.exports = ReactInstanceHandles;
  4712. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  4713. /***/ },
  4714. /* 46 */
  4715. /***/ function(module, exports) {
  4716. /**
  4717. * Copyright 2013-2015, Facebook, Inc.
  4718. * All rights reserved.
  4719. *
  4720. * This source code is licensed under the BSD-style license found in the
  4721. * LICENSE file in the root directory of this source tree. An additional grant
  4722. * of patent rights can be found in the PATENTS file in the same directory.
  4723. *
  4724. * @providesModule ReactRootIndex
  4725. * @typechecks
  4726. */
  4727. 'use strict';
  4728. var ReactRootIndexInjection = {
  4729. /**
  4730. * @param {function} _createReactRootIndex
  4731. */
  4732. injectCreateReactRootIndex: function (_createReactRootIndex) {
  4733. ReactRootIndex.createReactRootIndex = _createReactRootIndex;
  4734. }
  4735. };
  4736. var ReactRootIndex = {
  4737. createReactRootIndex: null,
  4738. injection: ReactRootIndexInjection
  4739. };
  4740. module.exports = ReactRootIndex;
  4741. /***/ },
  4742. /* 47 */
  4743. /***/ function(module, exports) {
  4744. /**
  4745. * Copyright 2013-2015, Facebook, Inc.
  4746. * All rights reserved.
  4747. *
  4748. * This source code is licensed under the BSD-style license found in the
  4749. * LICENSE file in the root directory of this source tree. An additional grant
  4750. * of patent rights can be found in the PATENTS file in the same directory.
  4751. *
  4752. * @providesModule ReactInstanceMap
  4753. */
  4754. 'use strict';
  4755. /**
  4756. * `ReactInstanceMap` maintains a mapping from a public facing stateful
  4757. * instance (key) and the internal representation (value). This allows public
  4758. * methods to accept the user facing instance as an argument and map them back
  4759. * to internal methods.
  4760. */
  4761. // TODO: Replace this with ES6: var ReactInstanceMap = new Map();
  4762. var ReactInstanceMap = {
  4763. /**
  4764. * This API should be called `delete` but we'd have to make sure to always
  4765. * transform these to strings for IE support. When this transform is fully
  4766. * supported we can rename it.
  4767. */
  4768. remove: function (key) {
  4769. key._reactInternalInstance = undefined;
  4770. },
  4771. get: function (key) {
  4772. return key._reactInternalInstance;
  4773. },
  4774. has: function (key) {
  4775. return key._reactInternalInstance !== undefined;
  4776. },
  4777. set: function (key, value) {
  4778. key._reactInternalInstance = value;
  4779. }
  4780. };
  4781. module.exports = ReactInstanceMap;
  4782. /***/ },
  4783. /* 48 */
  4784. /***/ function(module, exports, __webpack_require__) {
  4785. /**
  4786. * Copyright 2013-2015, Facebook, Inc.
  4787. * All rights reserved.
  4788. *
  4789. * This source code is licensed under the BSD-style license found in the
  4790. * LICENSE file in the root directory of this source tree. An additional grant
  4791. * of patent rights can be found in the PATENTS file in the same directory.
  4792. *
  4793. * @providesModule ReactMarkupChecksum
  4794. */
  4795. 'use strict';
  4796. var adler32 = __webpack_require__(49);
  4797. var TAG_END = /\/?>/;
  4798. var ReactMarkupChecksum = {
  4799. CHECKSUM_ATTR_NAME: 'data-react-checksum',
  4800. /**
  4801. * @param {string} markup Markup string
  4802. * @return {string} Markup string with checksum attribute attached
  4803. */
  4804. addChecksumToMarkup: function (markup) {
  4805. var checksum = adler32(markup);
  4806. // Add checksum (handle both parent tags and self-closing tags)
  4807. return markup.replace(TAG_END, ' ' + ReactMarkupChecksum.CHECKSUM_ATTR_NAME + '="' + checksum + '"$&');
  4808. },
  4809. /**
  4810. * @param {string} markup to use
  4811. * @param {DOMElement} element root React element
  4812. * @returns {boolean} whether or not the markup is the same
  4813. */
  4814. canReuseMarkup: function (markup, element) {
  4815. var existingChecksum = element.getAttribute(ReactMarkupChecksum.CHECKSUM_ATTR_NAME);
  4816. existingChecksum = existingChecksum && parseInt(existingChecksum, 10);
  4817. var markupChecksum = adler32(markup);
  4818. return markupChecksum === existingChecksum;
  4819. }
  4820. };
  4821. module.exports = ReactMarkupChecksum;
  4822. /***/ },
  4823. /* 49 */
  4824. /***/ function(module, exports) {
  4825. /**
  4826. * Copyright 2013-2015, Facebook, Inc.
  4827. * All rights reserved.
  4828. *
  4829. * This source code is licensed under the BSD-style license found in the
  4830. * LICENSE file in the root directory of this source tree. An additional grant
  4831. * of patent rights can be found in the PATENTS file in the same directory.
  4832. *
  4833. * @providesModule adler32
  4834. */
  4835. 'use strict';
  4836. var MOD = 65521;
  4837. // adler32 is not cryptographically strong, and is only used to sanity check that
  4838. // markup generated on the server matches the markup generated on the client.
  4839. // This implementation (a modified version of the SheetJS version) has been optimized
  4840. // for our use case, at the expense of conforming to the adler32 specification
  4841. // for non-ascii inputs.
  4842. function adler32(data) {
  4843. var a = 1;
  4844. var b = 0;
  4845. var i = 0;
  4846. var l = data.length;
  4847. var m = l & ~0x3;
  4848. while (i < m) {
  4849. for (; i < Math.min(i + 4096, m); i += 4) {
  4850. b += (a += data.charCodeAt(i)) + (a += data.charCodeAt(i + 1)) + (a += data.charCodeAt(i + 2)) + (a += data.charCodeAt(i + 3));
  4851. }
  4852. a %= MOD;
  4853. b %= MOD;
  4854. }
  4855. for (; i < l; i++) {
  4856. b += a += data.charCodeAt(i);
  4857. }
  4858. a %= MOD;
  4859. b %= MOD;
  4860. return a | b << 16;
  4861. }
  4862. module.exports = adler32;
  4863. /***/ },
  4864. /* 50 */
  4865. /***/ function(module, exports, __webpack_require__) {
  4866. /**
  4867. * Copyright 2013-2015, Facebook, Inc.
  4868. * All rights reserved.
  4869. *
  4870. * This source code is licensed under the BSD-style license found in the
  4871. * LICENSE file in the root directory of this source tree. An additional grant
  4872. * of patent rights can be found in the PATENTS file in the same directory.
  4873. *
  4874. * @providesModule ReactReconciler
  4875. */
  4876. 'use strict';
  4877. var ReactRef = __webpack_require__(51);
  4878. /**
  4879. * Helper to call ReactRef.attachRefs with this composite component, split out
  4880. * to avoid allocations in the transaction mount-ready queue.
  4881. */
  4882. function attachRefs() {
  4883. ReactRef.attachRefs(this, this._currentElement);
  4884. }
  4885. var ReactReconciler = {
  4886. /**
  4887. * Initializes the component, renders markup, and registers event listeners.
  4888. *
  4889. * @param {ReactComponent} internalInstance
  4890. * @param {string} rootID DOM ID of the root node.
  4891. * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
  4892. * @return {?string} Rendered markup to be inserted into the DOM.
  4893. * @final
  4894. * @internal
  4895. */
  4896. mountComponent: function (internalInstance, rootID, transaction, context) {
  4897. var markup = internalInstance.mountComponent(rootID, transaction, context);
  4898. if (internalInstance._currentElement && internalInstance._currentElement.ref != null) {
  4899. transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
  4900. }
  4901. return markup;
  4902. },
  4903. /**
  4904. * Releases any resources allocated by `mountComponent`.
  4905. *
  4906. * @final
  4907. * @internal
  4908. */
  4909. unmountComponent: function (internalInstance) {
  4910. ReactRef.detachRefs(internalInstance, internalInstance._currentElement);
  4911. internalInstance.unmountComponent();
  4912. },
  4913. /**
  4914. * Update a component using a new element.
  4915. *
  4916. * @param {ReactComponent} internalInstance
  4917. * @param {ReactElement} nextElement
  4918. * @param {ReactReconcileTransaction} transaction
  4919. * @param {object} context
  4920. * @internal
  4921. */
  4922. receiveComponent: function (internalInstance, nextElement, transaction, context) {
  4923. var prevElement = internalInstance._currentElement;
  4924. if (nextElement === prevElement && context === internalInstance._context) {
  4925. // Since elements are immutable after the owner is rendered,
  4926. // we can do a cheap identity compare here to determine if this is a
  4927. // superfluous reconcile. It's possible for state to be mutable but such
  4928. // change should trigger an update of the owner which would recreate
  4929. // the element. We explicitly check for the existence of an owner since
  4930. // it's possible for an element created outside a composite to be
  4931. // deeply mutated and reused.
  4932. // TODO: Bailing out early is just a perf optimization right?
  4933. // TODO: Removing the return statement should affect correctness?
  4934. return;
  4935. }
  4936. var refsChanged = ReactRef.shouldUpdateRefs(prevElement, nextElement);
  4937. if (refsChanged) {
  4938. ReactRef.detachRefs(internalInstance, prevElement);
  4939. }
  4940. internalInstance.receiveComponent(nextElement, transaction, context);
  4941. if (refsChanged && internalInstance._currentElement && internalInstance._currentElement.ref != null) {
  4942. transaction.getReactMountReady().enqueue(attachRefs, internalInstance);
  4943. }
  4944. },
  4945. /**
  4946. * Flush any dirty changes in a component.
  4947. *
  4948. * @param {ReactComponent} internalInstance
  4949. * @param {ReactReconcileTransaction} transaction
  4950. * @internal
  4951. */
  4952. performUpdateIfNecessary: function (internalInstance, transaction) {
  4953. internalInstance.performUpdateIfNecessary(transaction);
  4954. }
  4955. };
  4956. module.exports = ReactReconciler;
  4957. /***/ },
  4958. /* 51 */
  4959. /***/ function(module, exports, __webpack_require__) {
  4960. /**
  4961. * Copyright 2013-2015, Facebook, Inc.
  4962. * All rights reserved.
  4963. *
  4964. * This source code is licensed under the BSD-style license found in the
  4965. * LICENSE file in the root directory of this source tree. An additional grant
  4966. * of patent rights can be found in the PATENTS file in the same directory.
  4967. *
  4968. * @providesModule ReactRef
  4969. */
  4970. 'use strict';
  4971. var ReactOwner = __webpack_require__(52);
  4972. var ReactRef = {};
  4973. function attachRef(ref, component, owner) {
  4974. if (typeof ref === 'function') {
  4975. ref(component.getPublicInstance());
  4976. } else {
  4977. // Legacy ref
  4978. ReactOwner.addComponentAsRefTo(component, ref, owner);
  4979. }
  4980. }
  4981. function detachRef(ref, component, owner) {
  4982. if (typeof ref === 'function') {
  4983. ref(null);
  4984. } else {
  4985. // Legacy ref
  4986. ReactOwner.removeComponentAsRefFrom(component, ref, owner);
  4987. }
  4988. }
  4989. ReactRef.attachRefs = function (instance, element) {
  4990. if (element === null || element === false) {
  4991. return;
  4992. }
  4993. var ref = element.ref;
  4994. if (ref != null) {
  4995. attachRef(ref, instance, element._owner);
  4996. }
  4997. };
  4998. ReactRef.shouldUpdateRefs = function (prevElement, nextElement) {
  4999. // If either the owner or a `ref` has changed, make sure the newest owner
  5000. // has stored a reference to `this`, and the previous owner (if different)
  5001. // has forgotten the reference to `this`. We use the element instead
  5002. // of the public this.props because the post processing cannot determine
  5003. // a ref. The ref conceptually lives on the element.
  5004. // TODO: Should this even be possible? The owner cannot change because
  5005. // it's forbidden by shouldUpdateReactComponent. The ref can change
  5006. // if you swap the keys of but not the refs. Reconsider where this check
  5007. // is made. It probably belongs where the key checking and
  5008. // instantiateReactComponent is done.
  5009. var prevEmpty = prevElement === null || prevElement === false;
  5010. var nextEmpty = nextElement === null || nextElement === false;
  5011. return(
  5012. // This has a few false positives w/r/t empty components.
  5013. prevEmpty || nextEmpty || nextElement._owner !== prevElement._owner || nextElement.ref !== prevElement.ref
  5014. );
  5015. };
  5016. ReactRef.detachRefs = function (instance, element) {
  5017. if (element === null || element === false) {
  5018. return;
  5019. }
  5020. var ref = element.ref;
  5021. if (ref != null) {
  5022. detachRef(ref, instance, element._owner);
  5023. }
  5024. };
  5025. module.exports = ReactRef;
  5026. /***/ },
  5027. /* 52 */
  5028. /***/ function(module, exports, __webpack_require__) {
  5029. /* WEBPACK VAR INJECTION */(function(process) {/**
  5030. * Copyright 2013-2015, Facebook, Inc.
  5031. * All rights reserved.
  5032. *
  5033. * This source code is licensed under the BSD-style license found in the
  5034. * LICENSE file in the root directory of this source tree. An additional grant
  5035. * of patent rights can be found in the PATENTS file in the same directory.
  5036. *
  5037. * @providesModule ReactOwner
  5038. */
  5039. 'use strict';
  5040. var invariant = __webpack_require__(13);
  5041. /**
  5042. * ReactOwners are capable of storing references to owned components.
  5043. *
  5044. * All components are capable of //being// referenced by owner components, but
  5045. * only ReactOwner components are capable of //referencing// owned components.
  5046. * The named reference is known as a "ref".
  5047. *
  5048. * Refs are available when mounted and updated during reconciliation.
  5049. *
  5050. * var MyComponent = React.createClass({
  5051. * render: function() {
  5052. * return (
  5053. * <div onClick={this.handleClick}>
  5054. * <CustomComponent ref="custom" />
  5055. * </div>
  5056. * );
  5057. * },
  5058. * handleClick: function() {
  5059. * this.refs.custom.handleClick();
  5060. * },
  5061. * componentDidMount: function() {
  5062. * this.refs.custom.initialize();
  5063. * }
  5064. * });
  5065. *
  5066. * Refs should rarely be used. When refs are used, they should only be done to
  5067. * control data that is not handled by React's data flow.
  5068. *
  5069. * @class ReactOwner
  5070. */
  5071. var ReactOwner = {
  5072. /**
  5073. * @param {?object} object
  5074. * @return {boolean} True if `object` is a valid owner.
  5075. * @final
  5076. */
  5077. isValidOwner: function (object) {
  5078. return !!(object && typeof object.attachRef === 'function' && typeof object.detachRef === 'function');
  5079. },
  5080. /**
  5081. * Adds a component by ref to an owner component.
  5082. *
  5083. * @param {ReactComponent} component Component to reference.
  5084. * @param {string} ref Name by which to refer to the component.
  5085. * @param {ReactOwner} owner Component on which to record the ref.
  5086. * @final
  5087. * @internal
  5088. */
  5089. addComponentAsRefTo: function (component, ref, owner) {
  5090. !ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'addComponentAsRefTo(...): Only a ReactOwner can have refs. You might ' + 'be adding a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : undefined;
  5091. owner.attachRef(ref, component);
  5092. },
  5093. /**
  5094. * Removes a component by ref from an owner component.
  5095. *
  5096. * @param {ReactComponent} component Component to dereference.
  5097. * @param {string} ref Name of the ref to remove.
  5098. * @param {ReactOwner} owner Component on which the ref is recorded.
  5099. * @final
  5100. * @internal
  5101. */
  5102. removeComponentAsRefFrom: function (component, ref, owner) {
  5103. !ReactOwner.isValidOwner(owner) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'removeComponentAsRefFrom(...): Only a ReactOwner can have refs. You might ' + 'be removing a ref to a component that was not created inside a component\'s ' + '`render` method, or you have multiple copies of React loaded ' + '(details: https://fb.me/react-refs-must-have-owner).') : invariant(false) : undefined;
  5104. // Check that `component` is still the current ref because we do not want to
  5105. // detach the ref if another component stole it.
  5106. if (owner.getPublicInstance().refs[ref] === component.getPublicInstance()) {
  5107. owner.detachRef(ref);
  5108. }
  5109. }
  5110. };
  5111. module.exports = ReactOwner;
  5112. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  5113. /***/ },
  5114. /* 53 */
  5115. /***/ function(module, exports, __webpack_require__) {
  5116. /* WEBPACK VAR INJECTION */(function(process) {/**
  5117. * Copyright 2015, Facebook, Inc.
  5118. * All rights reserved.
  5119. *
  5120. * This source code is licensed under the BSD-style license found in the
  5121. * LICENSE file in the root directory of this source tree. An additional grant
  5122. * of patent rights can be found in the PATENTS file in the same directory.
  5123. *
  5124. * @providesModule ReactUpdateQueue
  5125. */
  5126. 'use strict';
  5127. var ReactCurrentOwner = __webpack_require__(5);
  5128. var ReactElement = __webpack_require__(42);
  5129. var ReactInstanceMap = __webpack_require__(47);
  5130. var ReactUpdates = __webpack_require__(54);
  5131. var assign = __webpack_require__(39);
  5132. var invariant = __webpack_require__(13);
  5133. var warning = __webpack_require__(25);
  5134. function enqueueUpdate(internalInstance) {
  5135. ReactUpdates.enqueueUpdate(internalInstance);
  5136. }
  5137. function getInternalInstanceReadyForUpdate(publicInstance, callerName) {
  5138. var internalInstance = ReactInstanceMap.get(publicInstance);
  5139. if (!internalInstance) {
  5140. if (process.env.NODE_ENV !== 'production') {
  5141. // Only warn when we have a callerName. Otherwise we should be silent.
  5142. // We're probably calling from enqueueCallback. We don't want to warn
  5143. // there because we already warned for the corresponding lifecycle method.
  5144. process.env.NODE_ENV !== 'production' ? warning(!callerName, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor.displayName) : undefined;
  5145. }
  5146. return null;
  5147. }
  5148. if (process.env.NODE_ENV !== 'production') {
  5149. process.env.NODE_ENV !== 'production' ? warning(ReactCurrentOwner.current == null, '%s(...): Cannot update during an existing state transition ' + '(such as within `render`). Render methods should be a pure function ' + 'of props and state.', callerName) : undefined;
  5150. }
  5151. return internalInstance;
  5152. }
  5153. /**
  5154. * ReactUpdateQueue allows for state updates to be scheduled into a later
  5155. * reconciliation step.
  5156. */
  5157. var ReactUpdateQueue = {
  5158. /**
  5159. * Checks whether or not this composite component is mounted.
  5160. * @param {ReactClass} publicInstance The instance we want to test.
  5161. * @return {boolean} True if mounted, false otherwise.
  5162. * @protected
  5163. * @final
  5164. */
  5165. isMounted: function (publicInstance) {
  5166. if (process.env.NODE_ENV !== 'production') {
  5167. var owner = ReactCurrentOwner.current;
  5168. if (owner !== null) {
  5169. process.env.NODE_ENV !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing isMounted inside its render() function. ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined;
  5170. owner._warnedAboutRefsInRender = true;
  5171. }
  5172. }
  5173. var internalInstance = ReactInstanceMap.get(publicInstance);
  5174. if (internalInstance) {
  5175. // During componentWillMount and render this will still be null but after
  5176. // that will always render to something. At least for now. So we can use
  5177. // this hack.
  5178. return !!internalInstance._renderedComponent;
  5179. } else {
  5180. return false;
  5181. }
  5182. },
  5183. /**
  5184. * Enqueue a callback that will be executed after all the pending updates
  5185. * have processed.
  5186. *
  5187. * @param {ReactClass} publicInstance The instance to use as `this` context.
  5188. * @param {?function} callback Called after state is updated.
  5189. * @internal
  5190. */
  5191. enqueueCallback: function (publicInstance, callback) {
  5192. !(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
  5193. var internalInstance = getInternalInstanceReadyForUpdate(publicInstance);
  5194. // Previously we would throw an error if we didn't have an internal
  5195. // instance. Since we want to make it a no-op instead, we mirror the same
  5196. // behavior we have in other enqueue* methods.
  5197. // We also need to ignore callbacks in componentWillMount. See
  5198. // enqueueUpdates.
  5199. if (!internalInstance) {
  5200. return null;
  5201. }
  5202. if (internalInstance._pendingCallbacks) {
  5203. internalInstance._pendingCallbacks.push(callback);
  5204. } else {
  5205. internalInstance._pendingCallbacks = [callback];
  5206. }
  5207. // TODO: The callback here is ignored when setState is called from
  5208. // componentWillMount. Either fix it or disallow doing so completely in
  5209. // favor of getInitialState. Alternatively, we can disallow
  5210. // componentWillMount during server-side rendering.
  5211. enqueueUpdate(internalInstance);
  5212. },
  5213. enqueueCallbackInternal: function (internalInstance, callback) {
  5214. !(typeof callback === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'enqueueCallback(...): You called `setProps`, `replaceProps`, ' + '`setState`, `replaceState`, or `forceUpdate` with a callback that ' + 'isn\'t callable.') : invariant(false) : undefined;
  5215. if (internalInstance._pendingCallbacks) {
  5216. internalInstance._pendingCallbacks.push(callback);
  5217. } else {
  5218. internalInstance._pendingCallbacks = [callback];
  5219. }
  5220. enqueueUpdate(internalInstance);
  5221. },
  5222. /**
  5223. * Forces an update. This should only be invoked when it is known with
  5224. * certainty that we are **not** in a DOM transaction.
  5225. *
  5226. * You may want to call this when you know that some deeper aspect of the
  5227. * component's state has changed but `setState` was not called.
  5228. *
  5229. * This will not invoke `shouldComponentUpdate`, but it will invoke
  5230. * `componentWillUpdate` and `componentDidUpdate`.
  5231. *
  5232. * @param {ReactClass} publicInstance The instance that should rerender.
  5233. * @internal
  5234. */
  5235. enqueueForceUpdate: function (publicInstance) {
  5236. var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'forceUpdate');
  5237. if (!internalInstance) {
  5238. return;
  5239. }
  5240. internalInstance._pendingForceUpdate = true;
  5241. enqueueUpdate(internalInstance);
  5242. },
  5243. /**
  5244. * Replaces all of the state. Always use this or `setState` to mutate state.
  5245. * You should treat `this.state` as immutable.
  5246. *
  5247. * There is no guarantee that `this.state` will be immediately updated, so
  5248. * accessing `this.state` after calling this method may return the old value.
  5249. *
  5250. * @param {ReactClass} publicInstance The instance that should rerender.
  5251. * @param {object} completeState Next state.
  5252. * @internal
  5253. */
  5254. enqueueReplaceState: function (publicInstance, completeState) {
  5255. var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceState');
  5256. if (!internalInstance) {
  5257. return;
  5258. }
  5259. internalInstance._pendingStateQueue = [completeState];
  5260. internalInstance._pendingReplaceState = true;
  5261. enqueueUpdate(internalInstance);
  5262. },
  5263. /**
  5264. * Sets a subset of the state. This only exists because _pendingState is
  5265. * internal. This provides a merging strategy that is not available to deep
  5266. * properties which is confusing. TODO: Expose pendingState or don't use it
  5267. * during the merge.
  5268. *
  5269. * @param {ReactClass} publicInstance The instance that should rerender.
  5270. * @param {object} partialState Next partial state to be merged with state.
  5271. * @internal
  5272. */
  5273. enqueueSetState: function (publicInstance, partialState) {
  5274. var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setState');
  5275. if (!internalInstance) {
  5276. return;
  5277. }
  5278. var queue = internalInstance._pendingStateQueue || (internalInstance._pendingStateQueue = []);
  5279. queue.push(partialState);
  5280. enqueueUpdate(internalInstance);
  5281. },
  5282. /**
  5283. * Sets a subset of the props.
  5284. *
  5285. * @param {ReactClass} publicInstance The instance that should rerender.
  5286. * @param {object} partialProps Subset of the next props.
  5287. * @internal
  5288. */
  5289. enqueueSetProps: function (publicInstance, partialProps) {
  5290. var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'setProps');
  5291. if (!internalInstance) {
  5292. return;
  5293. }
  5294. ReactUpdateQueue.enqueueSetPropsInternal(internalInstance, partialProps);
  5295. },
  5296. enqueueSetPropsInternal: function (internalInstance, partialProps) {
  5297. var topLevelWrapper = internalInstance._topLevelWrapper;
  5298. !topLevelWrapper ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setProps(...): You called `setProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
  5299. // Merge with the pending element if it exists, otherwise with existing
  5300. // element props.
  5301. var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
  5302. var element = wrapElement.props;
  5303. var props = assign({}, element.props, partialProps);
  5304. topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
  5305. enqueueUpdate(topLevelWrapper);
  5306. },
  5307. /**
  5308. * Replaces all of the props.
  5309. *
  5310. * @param {ReactClass} publicInstance The instance that should rerender.
  5311. * @param {object} props New props.
  5312. * @internal
  5313. */
  5314. enqueueReplaceProps: function (publicInstance, props) {
  5315. var internalInstance = getInternalInstanceReadyForUpdate(publicInstance, 'replaceProps');
  5316. if (!internalInstance) {
  5317. return;
  5318. }
  5319. ReactUpdateQueue.enqueueReplacePropsInternal(internalInstance, props);
  5320. },
  5321. enqueueReplacePropsInternal: function (internalInstance, props) {
  5322. var topLevelWrapper = internalInstance._topLevelWrapper;
  5323. !topLevelWrapper ? process.env.NODE_ENV !== 'production' ? invariant(false, 'replaceProps(...): You called `replaceProps` on a ' + 'component with a parent. This is an anti-pattern since props will ' + 'get reactively updated when rendered. Instead, change the owner\'s ' + '`render` method to pass the correct value as props to the component ' + 'where it is created.') : invariant(false) : undefined;
  5324. // Merge with the pending element if it exists, otherwise with existing
  5325. // element props.
  5326. var wrapElement = topLevelWrapper._pendingElement || topLevelWrapper._currentElement;
  5327. var element = wrapElement.props;
  5328. topLevelWrapper._pendingElement = ReactElement.cloneAndReplaceProps(wrapElement, ReactElement.cloneAndReplaceProps(element, props));
  5329. enqueueUpdate(topLevelWrapper);
  5330. },
  5331. enqueueElementInternal: function (internalInstance, newElement) {
  5332. internalInstance._pendingElement = newElement;
  5333. enqueueUpdate(internalInstance);
  5334. }
  5335. };
  5336. module.exports = ReactUpdateQueue;
  5337. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  5338. /***/ },
  5339. /* 54 */
  5340. /***/ function(module, exports, __webpack_require__) {
  5341. /* WEBPACK VAR INJECTION */(function(process) {/**
  5342. * Copyright 2013-2015, Facebook, Inc.
  5343. * All rights reserved.
  5344. *
  5345. * This source code is licensed under the BSD-style license found in the
  5346. * LICENSE file in the root directory of this source tree. An additional grant
  5347. * of patent rights can be found in the PATENTS file in the same directory.
  5348. *
  5349. * @providesModule ReactUpdates
  5350. */
  5351. 'use strict';
  5352. var CallbackQueue = __webpack_require__(55);
  5353. var PooledClass = __webpack_require__(56);
  5354. var ReactPerf = __webpack_require__(18);
  5355. var ReactReconciler = __webpack_require__(50);
  5356. var Transaction = __webpack_require__(57);
  5357. var assign = __webpack_require__(39);
  5358. var invariant = __webpack_require__(13);
  5359. var dirtyComponents = [];
  5360. var asapCallbackQueue = CallbackQueue.getPooled();
  5361. var asapEnqueued = false;
  5362. var batchingStrategy = null;
  5363. function ensureInjected() {
  5364. !(ReactUpdates.ReactReconcileTransaction && batchingStrategy) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must inject a reconcile transaction class and batching ' + 'strategy') : invariant(false) : undefined;
  5365. }
  5366. var NESTED_UPDATES = {
  5367. initialize: function () {
  5368. this.dirtyComponentsLength = dirtyComponents.length;
  5369. },
  5370. close: function () {
  5371. if (this.dirtyComponentsLength !== dirtyComponents.length) {
  5372. // Additional updates were enqueued by componentDidUpdate handlers or
  5373. // similar; before our own UPDATE_QUEUEING wrapper closes, we want to run
  5374. // these new updates so that if A's componentDidUpdate calls setState on
  5375. // B, B will update before the callback A's updater provided when calling
  5376. // setState.
  5377. dirtyComponents.splice(0, this.dirtyComponentsLength);
  5378. flushBatchedUpdates();
  5379. } else {
  5380. dirtyComponents.length = 0;
  5381. }
  5382. }
  5383. };
  5384. var UPDATE_QUEUEING = {
  5385. initialize: function () {
  5386. this.callbackQueue.reset();
  5387. },
  5388. close: function () {
  5389. this.callbackQueue.notifyAll();
  5390. }
  5391. };
  5392. var TRANSACTION_WRAPPERS = [NESTED_UPDATES, UPDATE_QUEUEING];
  5393. function ReactUpdatesFlushTransaction() {
  5394. this.reinitializeTransaction();
  5395. this.dirtyComponentsLength = null;
  5396. this.callbackQueue = CallbackQueue.getPooled();
  5397. this.reconcileTransaction = ReactUpdates.ReactReconcileTransaction.getPooled( /* forceHTML */false);
  5398. }
  5399. assign(ReactUpdatesFlushTransaction.prototype, Transaction.Mixin, {
  5400. getTransactionWrappers: function () {
  5401. return TRANSACTION_WRAPPERS;
  5402. },
  5403. destructor: function () {
  5404. this.dirtyComponentsLength = null;
  5405. CallbackQueue.release(this.callbackQueue);
  5406. this.callbackQueue = null;
  5407. ReactUpdates.ReactReconcileTransaction.release(this.reconcileTransaction);
  5408. this.reconcileTransaction = null;
  5409. },
  5410. perform: function (method, scope, a) {
  5411. // Essentially calls `this.reconcileTransaction.perform(method, scope, a)`
  5412. // with this transaction's wrappers around it.
  5413. return Transaction.Mixin.perform.call(this, this.reconcileTransaction.perform, this.reconcileTransaction, method, scope, a);
  5414. }
  5415. });
  5416. PooledClass.addPoolingTo(ReactUpdatesFlushTransaction);
  5417. function batchedUpdates(callback, a, b, c, d, e) {
  5418. ensureInjected();
  5419. batchingStrategy.batchedUpdates(callback, a, b, c, d, e);
  5420. }
  5421. /**
  5422. * Array comparator for ReactComponents by mount ordering.
  5423. *
  5424. * @param {ReactComponent} c1 first component you're comparing
  5425. * @param {ReactComponent} c2 second component you're comparing
  5426. * @return {number} Return value usable by Array.prototype.sort().
  5427. */
  5428. function mountOrderComparator(c1, c2) {
  5429. return c1._mountOrder - c2._mountOrder;
  5430. }
  5431. function runBatchedUpdates(transaction) {
  5432. var len = transaction.dirtyComponentsLength;
  5433. !(len === dirtyComponents.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Expected flush transaction\'s stored dirty-components length (%s) to ' + 'match dirty-components array length (%s).', len, dirtyComponents.length) : invariant(false) : undefined;
  5434. // Since reconciling a component higher in the owner hierarchy usually (not
  5435. // always -- see shouldComponentUpdate()) will reconcile children, reconcile
  5436. // them before their children by sorting the array.
  5437. dirtyComponents.sort(mountOrderComparator);
  5438. for (var i = 0; i < len; i++) {
  5439. // If a component is unmounted before pending changes apply, it will still
  5440. // be here, but we assume that it has cleared its _pendingCallbacks and
  5441. // that performUpdateIfNecessary is a noop.
  5442. var component = dirtyComponents[i];
  5443. // If performUpdateIfNecessary happens to enqueue any new updates, we
  5444. // shouldn't execute the callbacks until the next render happens, so
  5445. // stash the callbacks first
  5446. var callbacks = component._pendingCallbacks;
  5447. component._pendingCallbacks = null;
  5448. ReactReconciler.performUpdateIfNecessary(component, transaction.reconcileTransaction);
  5449. if (callbacks) {
  5450. for (var j = 0; j < callbacks.length; j++) {
  5451. transaction.callbackQueue.enqueue(callbacks[j], component.getPublicInstance());
  5452. }
  5453. }
  5454. }
  5455. }
  5456. var flushBatchedUpdates = function () {
  5457. // ReactUpdatesFlushTransaction's wrappers will clear the dirtyComponents
  5458. // array and perform any updates enqueued by mount-ready handlers (i.e.,
  5459. // componentDidUpdate) but we need to check here too in order to catch
  5460. // updates enqueued by setState callbacks and asap calls.
  5461. while (dirtyComponents.length || asapEnqueued) {
  5462. if (dirtyComponents.length) {
  5463. var transaction = ReactUpdatesFlushTransaction.getPooled();
  5464. transaction.perform(runBatchedUpdates, null, transaction);
  5465. ReactUpdatesFlushTransaction.release(transaction);
  5466. }
  5467. if (asapEnqueued) {
  5468. asapEnqueued = false;
  5469. var queue = asapCallbackQueue;
  5470. asapCallbackQueue = CallbackQueue.getPooled();
  5471. queue.notifyAll();
  5472. CallbackQueue.release(queue);
  5473. }
  5474. }
  5475. };
  5476. flushBatchedUpdates = ReactPerf.measure('ReactUpdates', 'flushBatchedUpdates', flushBatchedUpdates);
  5477. /**
  5478. * Mark a component as needing a rerender, adding an optional callback to a
  5479. * list of functions which will be executed once the rerender occurs.
  5480. */
  5481. function enqueueUpdate(component) {
  5482. ensureInjected();
  5483. // Various parts of our code (such as ReactCompositeComponent's
  5484. // _renderValidatedComponent) assume that calls to render aren't nested;
  5485. // verify that that's the case. (This is called by each top-level update
  5486. // function, like setProps, setState, forceUpdate, etc.; creation and
  5487. // destruction of top-level components is guarded in ReactMount.)
  5488. if (!batchingStrategy.isBatchingUpdates) {
  5489. batchingStrategy.batchedUpdates(enqueueUpdate, component);
  5490. return;
  5491. }
  5492. dirtyComponents.push(component);
  5493. }
  5494. /**
  5495. * Enqueue a callback to be run at the end of the current batching cycle. Throws
  5496. * if no updates are currently being performed.
  5497. */
  5498. function asap(callback, context) {
  5499. !batchingStrategy.isBatchingUpdates ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates.asap: Can\'t enqueue an asap callback in a context where' + 'updates are not being batched.') : invariant(false) : undefined;
  5500. asapCallbackQueue.enqueue(callback, context);
  5501. asapEnqueued = true;
  5502. }
  5503. var ReactUpdatesInjection = {
  5504. injectReconcileTransaction: function (ReconcileTransaction) {
  5505. !ReconcileTransaction ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a reconcile transaction class') : invariant(false) : undefined;
  5506. ReactUpdates.ReactReconcileTransaction = ReconcileTransaction;
  5507. },
  5508. injectBatchingStrategy: function (_batchingStrategy) {
  5509. !_batchingStrategy ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a batching strategy') : invariant(false) : undefined;
  5510. !(typeof _batchingStrategy.batchedUpdates === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide a batchedUpdates() function') : invariant(false) : undefined;
  5511. !(typeof _batchingStrategy.isBatchingUpdates === 'boolean') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactUpdates: must provide an isBatchingUpdates boolean attribute') : invariant(false) : undefined;
  5512. batchingStrategy = _batchingStrategy;
  5513. }
  5514. };
  5515. var ReactUpdates = {
  5516. /**
  5517. * React references `ReactReconcileTransaction` using this property in order
  5518. * to allow dependency injection.
  5519. *
  5520. * @internal
  5521. */
  5522. ReactReconcileTransaction: null,
  5523. batchedUpdates: batchedUpdates,
  5524. enqueueUpdate: enqueueUpdate,
  5525. flushBatchedUpdates: flushBatchedUpdates,
  5526. injection: ReactUpdatesInjection,
  5527. asap: asap
  5528. };
  5529. module.exports = ReactUpdates;
  5530. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  5531. /***/ },
  5532. /* 55 */
  5533. /***/ function(module, exports, __webpack_require__) {
  5534. /* WEBPACK VAR INJECTION */(function(process) {/**
  5535. * Copyright 2013-2015, Facebook, Inc.
  5536. * All rights reserved.
  5537. *
  5538. * This source code is licensed under the BSD-style license found in the
  5539. * LICENSE file in the root directory of this source tree. An additional grant
  5540. * of patent rights can be found in the PATENTS file in the same directory.
  5541. *
  5542. * @providesModule CallbackQueue
  5543. */
  5544. 'use strict';
  5545. var PooledClass = __webpack_require__(56);
  5546. var assign = __webpack_require__(39);
  5547. var invariant = __webpack_require__(13);
  5548. /**
  5549. * A specialized pseudo-event module to help keep track of components waiting to
  5550. * be notified when their DOM representations are available for use.
  5551. *
  5552. * This implements `PooledClass`, so you should never need to instantiate this.
  5553. * Instead, use `CallbackQueue.getPooled()`.
  5554. *
  5555. * @class ReactMountReady
  5556. * @implements PooledClass
  5557. * @internal
  5558. */
  5559. function CallbackQueue() {
  5560. this._callbacks = null;
  5561. this._contexts = null;
  5562. }
  5563. assign(CallbackQueue.prototype, {
  5564. /**
  5565. * Enqueues a callback to be invoked when `notifyAll` is invoked.
  5566. *
  5567. * @param {function} callback Invoked when `notifyAll` is invoked.
  5568. * @param {?object} context Context to call `callback` with.
  5569. * @internal
  5570. */
  5571. enqueue: function (callback, context) {
  5572. this._callbacks = this._callbacks || [];
  5573. this._contexts = this._contexts || [];
  5574. this._callbacks.push(callback);
  5575. this._contexts.push(context);
  5576. },
  5577. /**
  5578. * Invokes all enqueued callbacks and clears the queue. This is invoked after
  5579. * the DOM representation of a component has been created or updated.
  5580. *
  5581. * @internal
  5582. */
  5583. notifyAll: function () {
  5584. var callbacks = this._callbacks;
  5585. var contexts = this._contexts;
  5586. if (callbacks) {
  5587. !(callbacks.length === contexts.length) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Mismatched list of contexts in callback queue') : invariant(false) : undefined;
  5588. this._callbacks = null;
  5589. this._contexts = null;
  5590. for (var i = 0; i < callbacks.length; i++) {
  5591. callbacks[i].call(contexts[i]);
  5592. }
  5593. callbacks.length = 0;
  5594. contexts.length = 0;
  5595. }
  5596. },
  5597. /**
  5598. * Resets the internal queue.
  5599. *
  5600. * @internal
  5601. */
  5602. reset: function () {
  5603. this._callbacks = null;
  5604. this._contexts = null;
  5605. },
  5606. /**
  5607. * `PooledClass` looks for this.
  5608. */
  5609. destructor: function () {
  5610. this.reset();
  5611. }
  5612. });
  5613. PooledClass.addPoolingTo(CallbackQueue);
  5614. module.exports = CallbackQueue;
  5615. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  5616. /***/ },
  5617. /* 56 */
  5618. /***/ function(module, exports, __webpack_require__) {
  5619. /* WEBPACK VAR INJECTION */(function(process) {/**
  5620. * Copyright 2013-2015, Facebook, Inc.
  5621. * All rights reserved.
  5622. *
  5623. * This source code is licensed under the BSD-style license found in the
  5624. * LICENSE file in the root directory of this source tree. An additional grant
  5625. * of patent rights can be found in the PATENTS file in the same directory.
  5626. *
  5627. * @providesModule PooledClass
  5628. */
  5629. 'use strict';
  5630. var invariant = __webpack_require__(13);
  5631. /**
  5632. * Static poolers. Several custom versions for each potential number of
  5633. * arguments. A completely generic pooler is easy to implement, but would
  5634. * require accessing the `arguments` object. In each of these, `this` refers to
  5635. * the Class itself, not an instance. If any others are needed, simply add them
  5636. * here, or in their own files.
  5637. */
  5638. var oneArgumentPooler = function (copyFieldsFrom) {
  5639. var Klass = this;
  5640. if (Klass.instancePool.length) {
  5641. var instance = Klass.instancePool.pop();
  5642. Klass.call(instance, copyFieldsFrom);
  5643. return instance;
  5644. } else {
  5645. return new Klass(copyFieldsFrom);
  5646. }
  5647. };
  5648. var twoArgumentPooler = function (a1, a2) {
  5649. var Klass = this;
  5650. if (Klass.instancePool.length) {
  5651. var instance = Klass.instancePool.pop();
  5652. Klass.call(instance, a1, a2);
  5653. return instance;
  5654. } else {
  5655. return new Klass(a1, a2);
  5656. }
  5657. };
  5658. var threeArgumentPooler = function (a1, a2, a3) {
  5659. var Klass = this;
  5660. if (Klass.instancePool.length) {
  5661. var instance = Klass.instancePool.pop();
  5662. Klass.call(instance, a1, a2, a3);
  5663. return instance;
  5664. } else {
  5665. return new Klass(a1, a2, a3);
  5666. }
  5667. };
  5668. var fourArgumentPooler = function (a1, a2, a3, a4) {
  5669. var Klass = this;
  5670. if (Klass.instancePool.length) {
  5671. var instance = Klass.instancePool.pop();
  5672. Klass.call(instance, a1, a2, a3, a4);
  5673. return instance;
  5674. } else {
  5675. return new Klass(a1, a2, a3, a4);
  5676. }
  5677. };
  5678. var fiveArgumentPooler = function (a1, a2, a3, a4, a5) {
  5679. var Klass = this;
  5680. if (Klass.instancePool.length) {
  5681. var instance = Klass.instancePool.pop();
  5682. Klass.call(instance, a1, a2, a3, a4, a5);
  5683. return instance;
  5684. } else {
  5685. return new Klass(a1, a2, a3, a4, a5);
  5686. }
  5687. };
  5688. var standardReleaser = function (instance) {
  5689. var Klass = this;
  5690. !(instance instanceof Klass) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Trying to release an instance into a pool of a different type.') : invariant(false) : undefined;
  5691. instance.destructor();
  5692. if (Klass.instancePool.length < Klass.poolSize) {
  5693. Klass.instancePool.push(instance);
  5694. }
  5695. };
  5696. var DEFAULT_POOL_SIZE = 10;
  5697. var DEFAULT_POOLER = oneArgumentPooler;
  5698. /**
  5699. * Augments `CopyConstructor` to be a poolable class, augmenting only the class
  5700. * itself (statically) not adding any prototypical fields. Any CopyConstructor
  5701. * you give this may have a `poolSize` property, and will look for a
  5702. * prototypical `destructor` on instances (optional).
  5703. *
  5704. * @param {Function} CopyConstructor Constructor that can be used to reset.
  5705. * @param {Function} pooler Customizable pooler.
  5706. */
  5707. var addPoolingTo = function (CopyConstructor, pooler) {
  5708. var NewKlass = CopyConstructor;
  5709. NewKlass.instancePool = [];
  5710. NewKlass.getPooled = pooler || DEFAULT_POOLER;
  5711. if (!NewKlass.poolSize) {
  5712. NewKlass.poolSize = DEFAULT_POOL_SIZE;
  5713. }
  5714. NewKlass.release = standardReleaser;
  5715. return NewKlass;
  5716. };
  5717. var PooledClass = {
  5718. addPoolingTo: addPoolingTo,
  5719. oneArgumentPooler: oneArgumentPooler,
  5720. twoArgumentPooler: twoArgumentPooler,
  5721. threeArgumentPooler: threeArgumentPooler,
  5722. fourArgumentPooler: fourArgumentPooler,
  5723. fiveArgumentPooler: fiveArgumentPooler
  5724. };
  5725. module.exports = PooledClass;
  5726. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  5727. /***/ },
  5728. /* 57 */
  5729. /***/ function(module, exports, __webpack_require__) {
  5730. /* WEBPACK VAR INJECTION */(function(process) {/**
  5731. * Copyright 2013-2015, Facebook, Inc.
  5732. * All rights reserved.
  5733. *
  5734. * This source code is licensed under the BSD-style license found in the
  5735. * LICENSE file in the root directory of this source tree. An additional grant
  5736. * of patent rights can be found in the PATENTS file in the same directory.
  5737. *
  5738. * @providesModule Transaction
  5739. */
  5740. 'use strict';
  5741. var invariant = __webpack_require__(13);
  5742. /**
  5743. * `Transaction` creates a black box that is able to wrap any method such that
  5744. * certain invariants are maintained before and after the method is invoked
  5745. * (Even if an exception is thrown while invoking the wrapped method). Whoever
  5746. * instantiates a transaction can provide enforcers of the invariants at
  5747. * creation time. The `Transaction` class itself will supply one additional
  5748. * automatic invariant for you - the invariant that any transaction instance
  5749. * should not be run while it is already being run. You would typically create a
  5750. * single instance of a `Transaction` for reuse multiple times, that potentially
  5751. * is used to wrap several different methods. Wrappers are extremely simple -
  5752. * they only require implementing two methods.
  5753. *
  5754. * <pre>
  5755. * wrappers (injected at creation time)
  5756. * + +
  5757. * | |
  5758. * +-----------------|--------|--------------+
  5759. * | v | |
  5760. * | +---------------+ | |
  5761. * | +--| wrapper1 |---|----+ |
  5762. * | | +---------------+ v | |
  5763. * | | +-------------+ | |
  5764. * | | +----| wrapper2 |--------+ |
  5765. * | | | +-------------+ | | |
  5766. * | | | | | |
  5767. * | v v v v | wrapper
  5768. * | +---+ +---+ +---------+ +---+ +---+ | invariants
  5769. * perform(anyMethod) | | | | | | | | | | | | maintained
  5770. * +----------------->|-|---|-|---|-->|anyMethod|---|---|-|---|-|-------->
  5771. * | | | | | | | | | | | |
  5772. * | | | | | | | | | | | |
  5773. * | | | | | | | | | | | |
  5774. * | +---+ +---+ +---------+ +---+ +---+ |
  5775. * | initialize close |
  5776. * +-----------------------------------------+
  5777. * </pre>
  5778. *
  5779. * Use cases:
  5780. * - Preserving the input selection ranges before/after reconciliation.
  5781. * Restoring selection even in the event of an unexpected error.
  5782. * - Deactivating events while rearranging the DOM, preventing blurs/focuses,
  5783. * while guaranteeing that afterwards, the event system is reactivated.
  5784. * - Flushing a queue of collected DOM mutations to the main UI thread after a
  5785. * reconciliation takes place in a worker thread.
  5786. * - Invoking any collected `componentDidUpdate` callbacks after rendering new
  5787. * content.
  5788. * - (Future use case): Wrapping particular flushes of the `ReactWorker` queue
  5789. * to preserve the `scrollTop` (an automatic scroll aware DOM).
  5790. * - (Future use case): Layout calculations before and after DOM updates.
  5791. *
  5792. * Transactional plugin API:
  5793. * - A module that has an `initialize` method that returns any precomputation.
  5794. * - and a `close` method that accepts the precomputation. `close` is invoked
  5795. * when the wrapped process is completed, or has failed.
  5796. *
  5797. * @param {Array<TransactionalWrapper>} transactionWrapper Wrapper modules
  5798. * that implement `initialize` and `close`.
  5799. * @return {Transaction} Single transaction for reuse in thread.
  5800. *
  5801. * @class Transaction
  5802. */
  5803. var Mixin = {
  5804. /**
  5805. * Sets up this instance so that it is prepared for collecting metrics. Does
  5806. * so such that this setup method may be used on an instance that is already
  5807. * initialized, in a way that does not consume additional memory upon reuse.
  5808. * That can be useful if you decide to make your subclass of this mixin a
  5809. * "PooledClass".
  5810. */
  5811. reinitializeTransaction: function () {
  5812. this.transactionWrappers = this.getTransactionWrappers();
  5813. if (this.wrapperInitData) {
  5814. this.wrapperInitData.length = 0;
  5815. } else {
  5816. this.wrapperInitData = [];
  5817. }
  5818. this._isInTransaction = false;
  5819. },
  5820. _isInTransaction: false,
  5821. /**
  5822. * @abstract
  5823. * @return {Array<TransactionWrapper>} Array of transaction wrappers.
  5824. */
  5825. getTransactionWrappers: null,
  5826. isInTransaction: function () {
  5827. return !!this._isInTransaction;
  5828. },
  5829. /**
  5830. * Executes the function within a safety window. Use this for the top level
  5831. * methods that result in large amounts of computation/mutations that would
  5832. * need to be safety checked. The optional arguments helps prevent the need
  5833. * to bind in many cases.
  5834. *
  5835. * @param {function} method Member of scope to call.
  5836. * @param {Object} scope Scope to invoke from.
  5837. * @param {Object?=} a Argument to pass to the method.
  5838. * @param {Object?=} b Argument to pass to the method.
  5839. * @param {Object?=} c Argument to pass to the method.
  5840. * @param {Object?=} d Argument to pass to the method.
  5841. * @param {Object?=} e Argument to pass to the method.
  5842. * @param {Object?=} f Argument to pass to the method.
  5843. *
  5844. * @return {*} Return value from `method`.
  5845. */
  5846. perform: function (method, scope, a, b, c, d, e, f) {
  5847. !!this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.perform(...): Cannot initialize a transaction when there ' + 'is already an outstanding transaction.') : invariant(false) : undefined;
  5848. var errorThrown;
  5849. var ret;
  5850. try {
  5851. this._isInTransaction = true;
  5852. // Catching errors makes debugging more difficult, so we start with
  5853. // errorThrown set to true before setting it to false after calling
  5854. // close -- if it's still set to true in the finally block, it means
  5855. // one of these calls threw.
  5856. errorThrown = true;
  5857. this.initializeAll(0);
  5858. ret = method.call(scope, a, b, c, d, e, f);
  5859. errorThrown = false;
  5860. } finally {
  5861. try {
  5862. if (errorThrown) {
  5863. // If `method` throws, prefer to show that stack trace over any thrown
  5864. // by invoking `closeAll`.
  5865. try {
  5866. this.closeAll(0);
  5867. } catch (err) {}
  5868. } else {
  5869. // Since `method` didn't throw, we don't want to silence the exception
  5870. // here.
  5871. this.closeAll(0);
  5872. }
  5873. } finally {
  5874. this._isInTransaction = false;
  5875. }
  5876. }
  5877. return ret;
  5878. },
  5879. initializeAll: function (startIndex) {
  5880. var transactionWrappers = this.transactionWrappers;
  5881. for (var i = startIndex; i < transactionWrappers.length; i++) {
  5882. var wrapper = transactionWrappers[i];
  5883. try {
  5884. // Catching errors makes debugging more difficult, so we start with the
  5885. // OBSERVED_ERROR state before overwriting it with the real return value
  5886. // of initialize -- if it's still set to OBSERVED_ERROR in the finally
  5887. // block, it means wrapper.initialize threw.
  5888. this.wrapperInitData[i] = Transaction.OBSERVED_ERROR;
  5889. this.wrapperInitData[i] = wrapper.initialize ? wrapper.initialize.call(this) : null;
  5890. } finally {
  5891. if (this.wrapperInitData[i] === Transaction.OBSERVED_ERROR) {
  5892. // The initializer for wrapper i threw an error; initialize the
  5893. // remaining wrappers but silence any exceptions from them to ensure
  5894. // that the first error is the one to bubble up.
  5895. try {
  5896. this.initializeAll(i + 1);
  5897. } catch (err) {}
  5898. }
  5899. }
  5900. }
  5901. },
  5902. /**
  5903. * Invokes each of `this.transactionWrappers.close[i]` functions, passing into
  5904. * them the respective return values of `this.transactionWrappers.init[i]`
  5905. * (`close`rs that correspond to initializers that failed will not be
  5906. * invoked).
  5907. */
  5908. closeAll: function (startIndex) {
  5909. !this.isInTransaction() ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Transaction.closeAll(): Cannot close transaction when none are open.') : invariant(false) : undefined;
  5910. var transactionWrappers = this.transactionWrappers;
  5911. for (var i = startIndex; i < transactionWrappers.length; i++) {
  5912. var wrapper = transactionWrappers[i];
  5913. var initData = this.wrapperInitData[i];
  5914. var errorThrown;
  5915. try {
  5916. // Catching errors makes debugging more difficult, so we start with
  5917. // errorThrown set to true before setting it to false after calling
  5918. // close -- if it's still set to true in the finally block, it means
  5919. // wrapper.close threw.
  5920. errorThrown = true;
  5921. if (initData !== Transaction.OBSERVED_ERROR && wrapper.close) {
  5922. wrapper.close.call(this, initData);
  5923. }
  5924. errorThrown = false;
  5925. } finally {
  5926. if (errorThrown) {
  5927. // The closer for wrapper i threw an error; close the remaining
  5928. // wrappers but silence any exceptions from them to ensure that the
  5929. // first error is the one to bubble up.
  5930. try {
  5931. this.closeAll(i + 1);
  5932. } catch (e) {}
  5933. }
  5934. }
  5935. }
  5936. this.wrapperInitData.length = 0;
  5937. }
  5938. };
  5939. var Transaction = {
  5940. Mixin: Mixin,
  5941. /**
  5942. * Token to look for to determine if an error occurred.
  5943. */
  5944. OBSERVED_ERROR: {}
  5945. };
  5946. module.exports = Transaction;
  5947. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  5948. /***/ },
  5949. /* 58 */
  5950. /***/ function(module, exports, __webpack_require__) {
  5951. /* WEBPACK VAR INJECTION */(function(process) {/**
  5952. * Copyright 2013-2015, Facebook, Inc.
  5953. * All rights reserved.
  5954. *
  5955. * This source code is licensed under the BSD-style license found in the
  5956. * LICENSE file in the root directory of this source tree. An additional grant
  5957. * of patent rights can be found in the PATENTS file in the same directory.
  5958. *
  5959. * @providesModule emptyObject
  5960. */
  5961. 'use strict';
  5962. var emptyObject = {};
  5963. if (process.env.NODE_ENV !== 'production') {
  5964. Object.freeze(emptyObject);
  5965. }
  5966. module.exports = emptyObject;
  5967. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  5968. /***/ },
  5969. /* 59 */
  5970. /***/ function(module, exports, __webpack_require__) {
  5971. /**
  5972. * Copyright 2013-2015, Facebook, Inc.
  5973. * All rights reserved.
  5974. *
  5975. * This source code is licensed under the BSD-style license found in the
  5976. * LICENSE file in the root directory of this source tree. An additional grant
  5977. * of patent rights can be found in the PATENTS file in the same directory.
  5978. *
  5979. * @providesModule containsNode
  5980. * @typechecks
  5981. */
  5982. 'use strict';
  5983. var isTextNode = __webpack_require__(60);
  5984. /*eslint-disable no-bitwise */
  5985. /**
  5986. * Checks if a given DOM node contains or is another DOM node.
  5987. *
  5988. * @param {?DOMNode} outerNode Outer DOM node.
  5989. * @param {?DOMNode} innerNode Inner DOM node.
  5990. * @return {boolean} True if `outerNode` contains or is `innerNode`.
  5991. */
  5992. function containsNode(_x, _x2) {
  5993. var _again = true;
  5994. _function: while (_again) {
  5995. var outerNode = _x,
  5996. innerNode = _x2;
  5997. _again = false;
  5998. if (!outerNode || !innerNode) {
  5999. return false;
  6000. } else if (outerNode === innerNode) {
  6001. return true;
  6002. } else if (isTextNode(outerNode)) {
  6003. return false;
  6004. } else if (isTextNode(innerNode)) {
  6005. _x = outerNode;
  6006. _x2 = innerNode.parentNode;
  6007. _again = true;
  6008. continue _function;
  6009. } else if (outerNode.contains) {
  6010. return outerNode.contains(innerNode);
  6011. } else if (outerNode.compareDocumentPosition) {
  6012. return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  6013. } else {
  6014. return false;
  6015. }
  6016. }
  6017. }
  6018. module.exports = containsNode;
  6019. /***/ },
  6020. /* 60 */
  6021. /***/ function(module, exports, __webpack_require__) {
  6022. /**
  6023. * Copyright 2013-2015, Facebook, Inc.
  6024. * All rights reserved.
  6025. *
  6026. * This source code is licensed under the BSD-style license found in the
  6027. * LICENSE file in the root directory of this source tree. An additional grant
  6028. * of patent rights can be found in the PATENTS file in the same directory.
  6029. *
  6030. * @providesModule isTextNode
  6031. * @typechecks
  6032. */
  6033. 'use strict';
  6034. var isNode = __webpack_require__(61);
  6035. /**
  6036. * @param {*} object The object to check.
  6037. * @return {boolean} Whether or not the object is a DOM text node.
  6038. */
  6039. function isTextNode(object) {
  6040. return isNode(object) && object.nodeType == 3;
  6041. }
  6042. module.exports = isTextNode;
  6043. /***/ },
  6044. /* 61 */
  6045. /***/ function(module, exports) {
  6046. /**
  6047. * Copyright 2013-2015, Facebook, Inc.
  6048. * All rights reserved.
  6049. *
  6050. * This source code is licensed under the BSD-style license found in the
  6051. * LICENSE file in the root directory of this source tree. An additional grant
  6052. * of patent rights can be found in the PATENTS file in the same directory.
  6053. *
  6054. * @providesModule isNode
  6055. * @typechecks
  6056. */
  6057. /**
  6058. * @param {*} object The object to check.
  6059. * @return {boolean} Whether or not the object is a DOM node.
  6060. */
  6061. 'use strict';
  6062. function isNode(object) {
  6063. return !!(object && (typeof Node === 'function' ? object instanceof Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'));
  6064. }
  6065. module.exports = isNode;
  6066. /***/ },
  6067. /* 62 */
  6068. /***/ function(module, exports, __webpack_require__) {
  6069. /* WEBPACK VAR INJECTION */(function(process) {/**
  6070. * Copyright 2013-2015, Facebook, Inc.
  6071. * All rights reserved.
  6072. *
  6073. * This source code is licensed under the BSD-style license found in the
  6074. * LICENSE file in the root directory of this source tree. An additional grant
  6075. * of patent rights can be found in the PATENTS file in the same directory.
  6076. *
  6077. * @providesModule instantiateReactComponent
  6078. * @typechecks static-only
  6079. */
  6080. 'use strict';
  6081. var ReactCompositeComponent = __webpack_require__(63);
  6082. var ReactEmptyComponent = __webpack_require__(68);
  6083. var ReactNativeComponent = __webpack_require__(69);
  6084. var assign = __webpack_require__(39);
  6085. var invariant = __webpack_require__(13);
  6086. var warning = __webpack_require__(25);
  6087. // To avoid a cyclic dependency, we create the final class in this module
  6088. var ReactCompositeComponentWrapper = function () {};
  6089. assign(ReactCompositeComponentWrapper.prototype, ReactCompositeComponent.Mixin, {
  6090. _instantiateReactComponent: instantiateReactComponent
  6091. });
  6092. function getDeclarationErrorAddendum(owner) {
  6093. if (owner) {
  6094. var name = owner.getName();
  6095. if (name) {
  6096. return ' Check the render method of `' + name + '`.';
  6097. }
  6098. }
  6099. return '';
  6100. }
  6101. /**
  6102. * Check if the type reference is a known internal type. I.e. not a user
  6103. * provided composite type.
  6104. *
  6105. * @param {function} type
  6106. * @return {boolean} Returns true if this is a valid internal type.
  6107. */
  6108. function isInternalComponentType(type) {
  6109. return typeof type === 'function' && typeof type.prototype !== 'undefined' && typeof type.prototype.mountComponent === 'function' && typeof type.prototype.receiveComponent === 'function';
  6110. }
  6111. /**
  6112. * Given a ReactNode, create an instance that will actually be mounted.
  6113. *
  6114. * @param {ReactNode} node
  6115. * @return {object} A new instance of the element's constructor.
  6116. * @protected
  6117. */
  6118. function instantiateReactComponent(node) {
  6119. var instance;
  6120. if (node === null || node === false) {
  6121. instance = new ReactEmptyComponent(instantiateReactComponent);
  6122. } else if (typeof node === 'object') {
  6123. var element = node;
  6124. !(element && (typeof element.type === 'function' || typeof element.type === 'string')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element type is invalid: expected a string (for built-in components) ' + 'or a class/function (for composite components) but got: %s.%s', element.type == null ? element.type : typeof element.type, getDeclarationErrorAddendum(element._owner)) : invariant(false) : undefined;
  6125. // Special case string values
  6126. if (typeof element.type === 'string') {
  6127. instance = ReactNativeComponent.createInternalComponent(element);
  6128. } else if (isInternalComponentType(element.type)) {
  6129. // This is temporarily available for custom components that are not string
  6130. // representations. I.e. ART. Once those are updated to use the string
  6131. // representation, we can drop this code path.
  6132. instance = new element.type(element);
  6133. } else {
  6134. instance = new ReactCompositeComponentWrapper();
  6135. }
  6136. } else if (typeof node === 'string' || typeof node === 'number') {
  6137. instance = ReactNativeComponent.createInstanceForText(node);
  6138. } else {
  6139. true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Encountered invalid React node of type %s', typeof node) : invariant(false) : undefined;
  6140. }
  6141. if (process.env.NODE_ENV !== 'production') {
  6142. process.env.NODE_ENV !== 'production' ? warning(typeof instance.construct === 'function' && typeof instance.mountComponent === 'function' && typeof instance.receiveComponent === 'function' && typeof instance.unmountComponent === 'function', 'Only React Components can be mounted.') : undefined;
  6143. }
  6144. // Sets up the instance. This can probably just move into the constructor now.
  6145. instance.construct(node);
  6146. // These two fields are used by the DOM and ART diffing algorithms
  6147. // respectively. Instead of using expandos on components, we should be
  6148. // storing the state needed by the diffing algorithms elsewhere.
  6149. instance._mountIndex = 0;
  6150. instance._mountImage = null;
  6151. if (process.env.NODE_ENV !== 'production') {
  6152. instance._isOwnerNecessary = false;
  6153. instance._warnedAboutRefsInRender = false;
  6154. }
  6155. // Internal instances should fully constructed at this point, so they should
  6156. // not get any new fields added to them at this point.
  6157. if (process.env.NODE_ENV !== 'production') {
  6158. if (Object.preventExtensions) {
  6159. Object.preventExtensions(instance);
  6160. }
  6161. }
  6162. return instance;
  6163. }
  6164. module.exports = instantiateReactComponent;
  6165. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  6166. /***/ },
  6167. /* 63 */
  6168. /***/ function(module, exports, __webpack_require__) {
  6169. /* WEBPACK VAR INJECTION */(function(process) {/**
  6170. * Copyright 2013-2015, Facebook, Inc.
  6171. * All rights reserved.
  6172. *
  6173. * This source code is licensed under the BSD-style license found in the
  6174. * LICENSE file in the root directory of this source tree. An additional grant
  6175. * of patent rights can be found in the PATENTS file in the same directory.
  6176. *
  6177. * @providesModule ReactCompositeComponent
  6178. */
  6179. 'use strict';
  6180. var ReactComponentEnvironment = __webpack_require__(64);
  6181. var ReactCurrentOwner = __webpack_require__(5);
  6182. var ReactElement = __webpack_require__(42);
  6183. var ReactInstanceMap = __webpack_require__(47);
  6184. var ReactPerf = __webpack_require__(18);
  6185. var ReactPropTypeLocations = __webpack_require__(65);
  6186. var ReactPropTypeLocationNames = __webpack_require__(66);
  6187. var ReactReconciler = __webpack_require__(50);
  6188. var ReactUpdateQueue = __webpack_require__(53);
  6189. var assign = __webpack_require__(39);
  6190. var emptyObject = __webpack_require__(58);
  6191. var invariant = __webpack_require__(13);
  6192. var shouldUpdateReactComponent = __webpack_require__(67);
  6193. var warning = __webpack_require__(25);
  6194. function getDeclarationErrorAddendum(component) {
  6195. var owner = component._currentElement._owner || null;
  6196. if (owner) {
  6197. var name = owner.getName();
  6198. if (name) {
  6199. return ' Check the render method of `' + name + '`.';
  6200. }
  6201. }
  6202. return '';
  6203. }
  6204. function StatelessComponent(Component) {}
  6205. StatelessComponent.prototype.render = function () {
  6206. var Component = ReactInstanceMap.get(this)._currentElement.type;
  6207. return Component(this.props, this.context, this.updater);
  6208. };
  6209. /**
  6210. * ------------------ The Life-Cycle of a Composite Component ------------------
  6211. *
  6212. * - constructor: Initialization of state. The instance is now retained.
  6213. * - componentWillMount
  6214. * - render
  6215. * - [children's constructors]
  6216. * - [children's componentWillMount and render]
  6217. * - [children's componentDidMount]
  6218. * - componentDidMount
  6219. *
  6220. * Update Phases:
  6221. * - componentWillReceiveProps (only called if parent updated)
  6222. * - shouldComponentUpdate
  6223. * - componentWillUpdate
  6224. * - render
  6225. * - [children's constructors or receive props phases]
  6226. * - componentDidUpdate
  6227. *
  6228. * - componentWillUnmount
  6229. * - [children's componentWillUnmount]
  6230. * - [children destroyed]
  6231. * - (destroyed): The instance is now blank, released by React and ready for GC.
  6232. *
  6233. * -----------------------------------------------------------------------------
  6234. */
  6235. /**
  6236. * An incrementing ID assigned to each component when it is mounted. This is
  6237. * used to enforce the order in which `ReactUpdates` updates dirty components.
  6238. *
  6239. * @private
  6240. */
  6241. var nextMountID = 1;
  6242. /**
  6243. * @lends {ReactCompositeComponent.prototype}
  6244. */
  6245. var ReactCompositeComponentMixin = {
  6246. /**
  6247. * Base constructor for all composite component.
  6248. *
  6249. * @param {ReactElement} element
  6250. * @final
  6251. * @internal
  6252. */
  6253. construct: function (element) {
  6254. this._currentElement = element;
  6255. this._rootNodeID = null;
  6256. this._instance = null;
  6257. // See ReactUpdateQueue
  6258. this._pendingElement = null;
  6259. this._pendingStateQueue = null;
  6260. this._pendingReplaceState = false;
  6261. this._pendingForceUpdate = false;
  6262. this._renderedComponent = null;
  6263. this._context = null;
  6264. this._mountOrder = 0;
  6265. this._topLevelWrapper = null;
  6266. // See ReactUpdates and ReactUpdateQueue.
  6267. this._pendingCallbacks = null;
  6268. },
  6269. /**
  6270. * Initializes the component, renders markup, and registers event listeners.
  6271. *
  6272. * @param {string} rootID DOM ID of the root node.
  6273. * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
  6274. * @return {?string} Rendered markup to be inserted into the DOM.
  6275. * @final
  6276. * @internal
  6277. */
  6278. mountComponent: function (rootID, transaction, context) {
  6279. this._context = context;
  6280. this._mountOrder = nextMountID++;
  6281. this._rootNodeID = rootID;
  6282. var publicProps = this._processProps(this._currentElement.props);
  6283. var publicContext = this._processContext(context);
  6284. var Component = this._currentElement.type;
  6285. // Initialize the public class
  6286. var inst;
  6287. var renderedElement;
  6288. // This is a way to detect if Component is a stateless arrow function
  6289. // component, which is not newable. It might not be 100% reliable but is
  6290. // something we can do until we start detecting that Component extends
  6291. // React.Component. We already assume that typeof Component === 'function'.
  6292. var canInstantiate = ('prototype' in Component);
  6293. if (canInstantiate) {
  6294. if (process.env.NODE_ENV !== 'production') {
  6295. ReactCurrentOwner.current = this;
  6296. try {
  6297. inst = new Component(publicProps, publicContext, ReactUpdateQueue);
  6298. } finally {
  6299. ReactCurrentOwner.current = null;
  6300. }
  6301. } else {
  6302. inst = new Component(publicProps, publicContext, ReactUpdateQueue);
  6303. }
  6304. }
  6305. if (!canInstantiate || inst === null || inst === false || ReactElement.isValidElement(inst)) {
  6306. renderedElement = inst;
  6307. inst = new StatelessComponent(Component);
  6308. }
  6309. if (process.env.NODE_ENV !== 'production') {
  6310. // This will throw later in _renderValidatedComponent, but add an early
  6311. // warning now to help debugging
  6312. if (inst.render == null) {
  6313. process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): No `render` method found on the returned component ' + 'instance: you may have forgotten to define `render`, returned ' + 'null/false from a stateless component, or tried to render an ' + 'element whose type is a function that isn\'t a React component.', Component.displayName || Component.name || 'Component') : undefined;
  6314. } else {
  6315. // We support ES6 inheriting from React.Component, the module pattern,
  6316. // and stateless components, but not ES6 classes that don't extend
  6317. process.env.NODE_ENV !== 'production' ? warning(Component.prototype && Component.prototype.isReactComponent || !canInstantiate || !(inst instanceof Component), '%s(...): React component classes must extend React.Component.', Component.displayName || Component.name || 'Component') : undefined;
  6318. }
  6319. }
  6320. // These should be set up in the constructor, but as a convenience for
  6321. // simpler class abstractions, we set them up after the fact.
  6322. inst.props = publicProps;
  6323. inst.context = publicContext;
  6324. inst.refs = emptyObject;
  6325. inst.updater = ReactUpdateQueue;
  6326. this._instance = inst;
  6327. // Store a reference from the instance back to the internal representation
  6328. ReactInstanceMap.set(inst, this);
  6329. if (process.env.NODE_ENV !== 'production') {
  6330. // Since plain JS classes are defined without any special initialization
  6331. // logic, we can not catch common errors early. Therefore, we have to
  6332. // catch them here, at initialization time, instead.
  6333. process.env.NODE_ENV !== 'production' ? warning(!inst.getInitialState || inst.getInitialState.isReactClassApproved, 'getInitialState was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Did you mean to define a state property instead?', this.getName() || 'a component') : undefined;
  6334. process.env.NODE_ENV !== 'production' ? warning(!inst.getDefaultProps || inst.getDefaultProps.isReactClassApproved, 'getDefaultProps was defined on %s, a plain JavaScript class. ' + 'This is only supported for classes created using React.createClass. ' + 'Use a static property to define defaultProps instead.', this.getName() || 'a component') : undefined;
  6335. process.env.NODE_ENV !== 'production' ? warning(!inst.propTypes, 'propTypes was defined as an instance property on %s. Use a static ' + 'property to define propTypes instead.', this.getName() || 'a component') : undefined;
  6336. process.env.NODE_ENV !== 'production' ? warning(!inst.contextTypes, 'contextTypes was defined as an instance property on %s. Use a ' + 'static property to define contextTypes instead.', this.getName() || 'a component') : undefined;
  6337. process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentShouldUpdate !== 'function', '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', this.getName() || 'A component') : undefined;
  6338. process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentDidUnmount !== 'function', '%s has a method called ' + 'componentDidUnmount(). But there is no such lifecycle method. ' + 'Did you mean componentWillUnmount()?', this.getName() || 'A component') : undefined;
  6339. process.env.NODE_ENV !== 'production' ? warning(typeof inst.componentWillRecieveProps !== 'function', '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', this.getName() || 'A component') : undefined;
  6340. }
  6341. var initialState = inst.state;
  6342. if (initialState === undefined) {
  6343. inst.state = initialState = null;
  6344. }
  6345. !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.state: must be set to an object or null', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
  6346. this._pendingStateQueue = null;
  6347. this._pendingReplaceState = false;
  6348. this._pendingForceUpdate = false;
  6349. if (inst.componentWillMount) {
  6350. inst.componentWillMount();
  6351. // When mounting, calls to `setState` by `componentWillMount` will set
  6352. // `this._pendingStateQueue` without triggering a re-render.
  6353. if (this._pendingStateQueue) {
  6354. inst.state = this._processPendingState(inst.props, inst.context);
  6355. }
  6356. }
  6357. // If not a stateless component, we now render
  6358. if (renderedElement === undefined) {
  6359. renderedElement = this._renderValidatedComponent();
  6360. }
  6361. this._renderedComponent = this._instantiateReactComponent(renderedElement);
  6362. var markup = ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, this._processChildContext(context));
  6363. if (inst.componentDidMount) {
  6364. transaction.getReactMountReady().enqueue(inst.componentDidMount, inst);
  6365. }
  6366. return markup;
  6367. },
  6368. /**
  6369. * Releases any resources allocated by `mountComponent`.
  6370. *
  6371. * @final
  6372. * @internal
  6373. */
  6374. unmountComponent: function () {
  6375. var inst = this._instance;
  6376. if (inst.componentWillUnmount) {
  6377. inst.componentWillUnmount();
  6378. }
  6379. ReactReconciler.unmountComponent(this._renderedComponent);
  6380. this._renderedComponent = null;
  6381. this._instance = null;
  6382. // Reset pending fields
  6383. // Even if this component is scheduled for another update in ReactUpdates,
  6384. // it would still be ignored because these fields are reset.
  6385. this._pendingStateQueue = null;
  6386. this._pendingReplaceState = false;
  6387. this._pendingForceUpdate = false;
  6388. this._pendingCallbacks = null;
  6389. this._pendingElement = null;
  6390. // These fields do not really need to be reset since this object is no
  6391. // longer accessible.
  6392. this._context = null;
  6393. this._rootNodeID = null;
  6394. this._topLevelWrapper = null;
  6395. // Delete the reference from the instance to this internal representation
  6396. // which allow the internals to be properly cleaned up even if the user
  6397. // leaks a reference to the public instance.
  6398. ReactInstanceMap.remove(inst);
  6399. // Some existing components rely on inst.props even after they've been
  6400. // destroyed (in event handlers).
  6401. // TODO: inst.props = null;
  6402. // TODO: inst.state = null;
  6403. // TODO: inst.context = null;
  6404. },
  6405. /**
  6406. * Filters the context object to only contain keys specified in
  6407. * `contextTypes`
  6408. *
  6409. * @param {object} context
  6410. * @return {?object}
  6411. * @private
  6412. */
  6413. _maskContext: function (context) {
  6414. var maskedContext = null;
  6415. var Component = this._currentElement.type;
  6416. var contextTypes = Component.contextTypes;
  6417. if (!contextTypes) {
  6418. return emptyObject;
  6419. }
  6420. maskedContext = {};
  6421. for (var contextName in contextTypes) {
  6422. maskedContext[contextName] = context[contextName];
  6423. }
  6424. return maskedContext;
  6425. },
  6426. /**
  6427. * Filters the context object to only contain keys specified in
  6428. * `contextTypes`, and asserts that they are valid.
  6429. *
  6430. * @param {object} context
  6431. * @return {?object}
  6432. * @private
  6433. */
  6434. _processContext: function (context) {
  6435. var maskedContext = this._maskContext(context);
  6436. if (process.env.NODE_ENV !== 'production') {
  6437. var Component = this._currentElement.type;
  6438. if (Component.contextTypes) {
  6439. this._checkPropTypes(Component.contextTypes, maskedContext, ReactPropTypeLocations.context);
  6440. }
  6441. }
  6442. return maskedContext;
  6443. },
  6444. /**
  6445. * @param {object} currentContext
  6446. * @return {object}
  6447. * @private
  6448. */
  6449. _processChildContext: function (currentContext) {
  6450. var Component = this._currentElement.type;
  6451. var inst = this._instance;
  6452. var childContext = inst.getChildContext && inst.getChildContext();
  6453. if (childContext) {
  6454. !(typeof Component.childContextTypes === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): childContextTypes must be defined in order to ' + 'use getChildContext().', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
  6455. if (process.env.NODE_ENV !== 'production') {
  6456. this._checkPropTypes(Component.childContextTypes, childContext, ReactPropTypeLocations.childContext);
  6457. }
  6458. for (var name in childContext) {
  6459. !(name in Component.childContextTypes) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', this.getName() || 'ReactCompositeComponent', name) : invariant(false) : undefined;
  6460. }
  6461. return assign({}, currentContext, childContext);
  6462. }
  6463. return currentContext;
  6464. },
  6465. /**
  6466. * Processes props by setting default values for unspecified props and
  6467. * asserting that the props are valid. Does not mutate its argument; returns
  6468. * a new props object with defaults merged in.
  6469. *
  6470. * @param {object} newProps
  6471. * @return {object}
  6472. * @private
  6473. */
  6474. _processProps: function (newProps) {
  6475. if (process.env.NODE_ENV !== 'production') {
  6476. var Component = this._currentElement.type;
  6477. if (Component.propTypes) {
  6478. this._checkPropTypes(Component.propTypes, newProps, ReactPropTypeLocations.prop);
  6479. }
  6480. }
  6481. return newProps;
  6482. },
  6483. /**
  6484. * Assert that the props are valid
  6485. *
  6486. * @param {object} propTypes Map of prop name to a ReactPropType
  6487. * @param {object} props
  6488. * @param {string} location e.g. "prop", "context", "child context"
  6489. * @private
  6490. */
  6491. _checkPropTypes: function (propTypes, props, location) {
  6492. // TODO: Stop validating prop types here and only use the element
  6493. // validation.
  6494. var componentName = this.getName();
  6495. for (var propName in propTypes) {
  6496. if (propTypes.hasOwnProperty(propName)) {
  6497. var error;
  6498. try {
  6499. // This is intentionally an invariant that gets caught. It's the same
  6500. // behavior as without this statement except with a better message.
  6501. !(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually ' + 'from React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
  6502. error = propTypes[propName](props, propName, componentName, location);
  6503. } catch (ex) {
  6504. error = ex;
  6505. }
  6506. if (error instanceof Error) {
  6507. // We may want to extend this logic for similar errors in
  6508. // top-level render calls, so I'm abstracting it away into
  6509. // a function to minimize refactoring in the future
  6510. var addendum = getDeclarationErrorAddendum(this);
  6511. if (location === ReactPropTypeLocations.prop) {
  6512. // Preface gives us something to blacklist in warning module
  6513. process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Composite propType: %s%s', error.message, addendum) : undefined;
  6514. } else {
  6515. process.env.NODE_ENV !== 'production' ? warning(false, 'Failed Context Types: %s%s', error.message, addendum) : undefined;
  6516. }
  6517. }
  6518. }
  6519. }
  6520. },
  6521. receiveComponent: function (nextElement, transaction, nextContext) {
  6522. var prevElement = this._currentElement;
  6523. var prevContext = this._context;
  6524. this._pendingElement = null;
  6525. this.updateComponent(transaction, prevElement, nextElement, prevContext, nextContext);
  6526. },
  6527. /**
  6528. * If any of `_pendingElement`, `_pendingStateQueue`, or `_pendingForceUpdate`
  6529. * is set, update the component.
  6530. *
  6531. * @param {ReactReconcileTransaction} transaction
  6532. * @internal
  6533. */
  6534. performUpdateIfNecessary: function (transaction) {
  6535. if (this._pendingElement != null) {
  6536. ReactReconciler.receiveComponent(this, this._pendingElement || this._currentElement, transaction, this._context);
  6537. }
  6538. if (this._pendingStateQueue !== null || this._pendingForceUpdate) {
  6539. this.updateComponent(transaction, this._currentElement, this._currentElement, this._context, this._context);
  6540. }
  6541. },
  6542. /**
  6543. * Perform an update to a mounted component. The componentWillReceiveProps and
  6544. * shouldComponentUpdate methods are called, then (assuming the update isn't
  6545. * skipped) the remaining update lifecycle methods are called and the DOM
  6546. * representation is updated.
  6547. *
  6548. * By default, this implements React's rendering and reconciliation algorithm.
  6549. * Sophisticated clients may wish to override this.
  6550. *
  6551. * @param {ReactReconcileTransaction} transaction
  6552. * @param {ReactElement} prevParentElement
  6553. * @param {ReactElement} nextParentElement
  6554. * @internal
  6555. * @overridable
  6556. */
  6557. updateComponent: function (transaction, prevParentElement, nextParentElement, prevUnmaskedContext, nextUnmaskedContext) {
  6558. var inst = this._instance;
  6559. var nextContext = this._context === nextUnmaskedContext ? inst.context : this._processContext(nextUnmaskedContext);
  6560. var nextProps;
  6561. // Distinguish between a props update versus a simple state update
  6562. if (prevParentElement === nextParentElement) {
  6563. // Skip checking prop types again -- we don't read inst.props to avoid
  6564. // warning for DOM component props in this upgrade
  6565. nextProps = nextParentElement.props;
  6566. } else {
  6567. nextProps = this._processProps(nextParentElement.props);
  6568. // An update here will schedule an update but immediately set
  6569. // _pendingStateQueue which will ensure that any state updates gets
  6570. // immediately reconciled instead of waiting for the next batch.
  6571. if (inst.componentWillReceiveProps) {
  6572. inst.componentWillReceiveProps(nextProps, nextContext);
  6573. }
  6574. }
  6575. var nextState = this._processPendingState(nextProps, nextContext);
  6576. var shouldUpdate = this._pendingForceUpdate || !inst.shouldComponentUpdate || inst.shouldComponentUpdate(nextProps, nextState, nextContext);
  6577. if (process.env.NODE_ENV !== 'production') {
  6578. process.env.NODE_ENV !== 'production' ? warning(typeof shouldUpdate !== 'undefined', '%s.shouldComponentUpdate(): Returned undefined instead of a ' + 'boolean value. Make sure to return true or false.', this.getName() || 'ReactCompositeComponent') : undefined;
  6579. }
  6580. if (shouldUpdate) {
  6581. this._pendingForceUpdate = false;
  6582. // Will set `this.props`, `this.state` and `this.context`.
  6583. this._performComponentUpdate(nextParentElement, nextProps, nextState, nextContext, transaction, nextUnmaskedContext);
  6584. } else {
  6585. // If it's determined that a component should not update, we still want
  6586. // to set props and state but we shortcut the rest of the update.
  6587. this._currentElement = nextParentElement;
  6588. this._context = nextUnmaskedContext;
  6589. inst.props = nextProps;
  6590. inst.state = nextState;
  6591. inst.context = nextContext;
  6592. }
  6593. },
  6594. _processPendingState: function (props, context) {
  6595. var inst = this._instance;
  6596. var queue = this._pendingStateQueue;
  6597. var replace = this._pendingReplaceState;
  6598. this._pendingReplaceState = false;
  6599. this._pendingStateQueue = null;
  6600. if (!queue) {
  6601. return inst.state;
  6602. }
  6603. if (replace && queue.length === 1) {
  6604. return queue[0];
  6605. }
  6606. var nextState = assign({}, replace ? queue[0] : inst.state);
  6607. for (var i = replace ? 1 : 0; i < queue.length; i++) {
  6608. var partial = queue[i];
  6609. assign(nextState, typeof partial === 'function' ? partial.call(inst, nextState, props, context) : partial);
  6610. }
  6611. return nextState;
  6612. },
  6613. /**
  6614. * Merges new props and state, notifies delegate methods of update and
  6615. * performs update.
  6616. *
  6617. * @param {ReactElement} nextElement Next element
  6618. * @param {object} nextProps Next public object to set as properties.
  6619. * @param {?object} nextState Next object to set as state.
  6620. * @param {?object} nextContext Next public object to set as context.
  6621. * @param {ReactReconcileTransaction} transaction
  6622. * @param {?object} unmaskedContext
  6623. * @private
  6624. */
  6625. _performComponentUpdate: function (nextElement, nextProps, nextState, nextContext, transaction, unmaskedContext) {
  6626. var inst = this._instance;
  6627. var hasComponentDidUpdate = Boolean(inst.componentDidUpdate);
  6628. var prevProps;
  6629. var prevState;
  6630. var prevContext;
  6631. if (hasComponentDidUpdate) {
  6632. prevProps = inst.props;
  6633. prevState = inst.state;
  6634. prevContext = inst.context;
  6635. }
  6636. if (inst.componentWillUpdate) {
  6637. inst.componentWillUpdate(nextProps, nextState, nextContext);
  6638. }
  6639. this._currentElement = nextElement;
  6640. this._context = unmaskedContext;
  6641. inst.props = nextProps;
  6642. inst.state = nextState;
  6643. inst.context = nextContext;
  6644. this._updateRenderedComponent(transaction, unmaskedContext);
  6645. if (hasComponentDidUpdate) {
  6646. transaction.getReactMountReady().enqueue(inst.componentDidUpdate.bind(inst, prevProps, prevState, prevContext), inst);
  6647. }
  6648. },
  6649. /**
  6650. * Call the component's `render` method and update the DOM accordingly.
  6651. *
  6652. * @param {ReactReconcileTransaction} transaction
  6653. * @internal
  6654. */
  6655. _updateRenderedComponent: function (transaction, context) {
  6656. var prevComponentInstance = this._renderedComponent;
  6657. var prevRenderedElement = prevComponentInstance._currentElement;
  6658. var nextRenderedElement = this._renderValidatedComponent();
  6659. if (shouldUpdateReactComponent(prevRenderedElement, nextRenderedElement)) {
  6660. ReactReconciler.receiveComponent(prevComponentInstance, nextRenderedElement, transaction, this._processChildContext(context));
  6661. } else {
  6662. // These two IDs are actually the same! But nothing should rely on that.
  6663. var thisID = this._rootNodeID;
  6664. var prevComponentID = prevComponentInstance._rootNodeID;
  6665. ReactReconciler.unmountComponent(prevComponentInstance);
  6666. this._renderedComponent = this._instantiateReactComponent(nextRenderedElement);
  6667. var nextMarkup = ReactReconciler.mountComponent(this._renderedComponent, thisID, transaction, this._processChildContext(context));
  6668. this._replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
  6669. }
  6670. },
  6671. /**
  6672. * @protected
  6673. */
  6674. _replaceNodeWithMarkupByID: function (prevComponentID, nextMarkup) {
  6675. ReactComponentEnvironment.replaceNodeWithMarkupByID(prevComponentID, nextMarkup);
  6676. },
  6677. /**
  6678. * @protected
  6679. */
  6680. _renderValidatedComponentWithoutOwnerOrContext: function () {
  6681. var inst = this._instance;
  6682. var renderedComponent = inst.render();
  6683. if (process.env.NODE_ENV !== 'production') {
  6684. // We allow auto-mocks to proceed as if they're returning null.
  6685. if (typeof renderedComponent === 'undefined' && inst.render._isMockFunction) {
  6686. // This is probably bad practice. Consider warning here and
  6687. // deprecating this convenience.
  6688. renderedComponent = null;
  6689. }
  6690. }
  6691. return renderedComponent;
  6692. },
  6693. /**
  6694. * @private
  6695. */
  6696. _renderValidatedComponent: function () {
  6697. var renderedComponent;
  6698. ReactCurrentOwner.current = this;
  6699. try {
  6700. renderedComponent = this._renderValidatedComponentWithoutOwnerOrContext();
  6701. } finally {
  6702. ReactCurrentOwner.current = null;
  6703. }
  6704. !(
  6705. // TODO: An `isValidNode` function would probably be more appropriate
  6706. renderedComponent === null || renderedComponent === false || ReactElement.isValidElement(renderedComponent)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.render(): A valid ReactComponent must be returned. You may have ' + 'returned undefined, an array or some other invalid object.', this.getName() || 'ReactCompositeComponent') : invariant(false) : undefined;
  6707. return renderedComponent;
  6708. },
  6709. /**
  6710. * Lazily allocates the refs object and stores `component` as `ref`.
  6711. *
  6712. * @param {string} ref Reference name.
  6713. * @param {component} component Component to store as `ref`.
  6714. * @final
  6715. * @private
  6716. */
  6717. attachRef: function (ref, component) {
  6718. var inst = this.getPublicInstance();
  6719. !(inst != null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Stateless function components cannot have refs.') : invariant(false) : undefined;
  6720. var publicComponentInstance = component.getPublicInstance();
  6721. if (process.env.NODE_ENV !== 'production') {
  6722. var componentName = component && component.getName ? component.getName() : 'a component';
  6723. process.env.NODE_ENV !== 'production' ? warning(publicComponentInstance != null, 'Stateless function components cannot be given refs ' + '(See ref "%s" in %s created by %s). ' + 'Attempts to access this ref will fail.', ref, componentName, this.getName()) : undefined;
  6724. }
  6725. var refs = inst.refs === emptyObject ? inst.refs = {} : inst.refs;
  6726. refs[ref] = publicComponentInstance;
  6727. },
  6728. /**
  6729. * Detaches a reference name.
  6730. *
  6731. * @param {string} ref Name to dereference.
  6732. * @final
  6733. * @private
  6734. */
  6735. detachRef: function (ref) {
  6736. var refs = this.getPublicInstance().refs;
  6737. delete refs[ref];
  6738. },
  6739. /**
  6740. * Get a text description of the component that can be used to identify it
  6741. * in error messages.
  6742. * @return {string} The name or null.
  6743. * @internal
  6744. */
  6745. getName: function () {
  6746. var type = this._currentElement.type;
  6747. var constructor = this._instance && this._instance.constructor;
  6748. return type.displayName || constructor && constructor.displayName || type.name || constructor && constructor.name || null;
  6749. },
  6750. /**
  6751. * Get the publicly accessible representation of this component - i.e. what
  6752. * is exposed by refs and returned by render. Can be null for stateless
  6753. * components.
  6754. *
  6755. * @return {ReactComponent} the public component instance.
  6756. * @internal
  6757. */
  6758. getPublicInstance: function () {
  6759. var inst = this._instance;
  6760. if (inst instanceof StatelessComponent) {
  6761. return null;
  6762. }
  6763. return inst;
  6764. },
  6765. // Stub
  6766. _instantiateReactComponent: null
  6767. };
  6768. ReactPerf.measureMethods(ReactCompositeComponentMixin, 'ReactCompositeComponent', {
  6769. mountComponent: 'mountComponent',
  6770. updateComponent: 'updateComponent',
  6771. _renderValidatedComponent: '_renderValidatedComponent'
  6772. });
  6773. var ReactCompositeComponent = {
  6774. Mixin: ReactCompositeComponentMixin
  6775. };
  6776. module.exports = ReactCompositeComponent;
  6777. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  6778. /***/ },
  6779. /* 64 */
  6780. /***/ function(module, exports, __webpack_require__) {
  6781. /* WEBPACK VAR INJECTION */(function(process) {/**
  6782. * Copyright 2014-2015, Facebook, Inc.
  6783. * All rights reserved.
  6784. *
  6785. * This source code is licensed under the BSD-style license found in the
  6786. * LICENSE file in the root directory of this source tree. An additional grant
  6787. * of patent rights can be found in the PATENTS file in the same directory.
  6788. *
  6789. * @providesModule ReactComponentEnvironment
  6790. */
  6791. 'use strict';
  6792. var invariant = __webpack_require__(13);
  6793. var injected = false;
  6794. var ReactComponentEnvironment = {
  6795. /**
  6796. * Optionally injectable environment dependent cleanup hook. (server vs.
  6797. * browser etc). Example: A browser system caches DOM nodes based on component
  6798. * ID and must remove that cache entry when this instance is unmounted.
  6799. */
  6800. unmountIDFromEnvironment: null,
  6801. /**
  6802. * Optionally injectable hook for swapping out mount images in the middle of
  6803. * the tree.
  6804. */
  6805. replaceNodeWithMarkupByID: null,
  6806. /**
  6807. * Optionally injectable hook for processing a queue of child updates. Will
  6808. * later move into MultiChildComponents.
  6809. */
  6810. processChildrenUpdates: null,
  6811. injection: {
  6812. injectEnvironment: function (environment) {
  6813. !!injected ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactCompositeComponent: injectEnvironment() can only be called once.') : invariant(false) : undefined;
  6814. ReactComponentEnvironment.unmountIDFromEnvironment = environment.unmountIDFromEnvironment;
  6815. ReactComponentEnvironment.replaceNodeWithMarkupByID = environment.replaceNodeWithMarkupByID;
  6816. ReactComponentEnvironment.processChildrenUpdates = environment.processChildrenUpdates;
  6817. injected = true;
  6818. }
  6819. }
  6820. };
  6821. module.exports = ReactComponentEnvironment;
  6822. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  6823. /***/ },
  6824. /* 65 */
  6825. /***/ function(module, exports, __webpack_require__) {
  6826. /**
  6827. * Copyright 2013-2015, Facebook, Inc.
  6828. * All rights reserved.
  6829. *
  6830. * This source code is licensed under the BSD-style license found in the
  6831. * LICENSE file in the root directory of this source tree. An additional grant
  6832. * of patent rights can be found in the PATENTS file in the same directory.
  6833. *
  6834. * @providesModule ReactPropTypeLocations
  6835. */
  6836. 'use strict';
  6837. var keyMirror = __webpack_require__(17);
  6838. var ReactPropTypeLocations = keyMirror({
  6839. prop: null,
  6840. context: null,
  6841. childContext: null
  6842. });
  6843. module.exports = ReactPropTypeLocations;
  6844. /***/ },
  6845. /* 66 */
  6846. /***/ function(module, exports, __webpack_require__) {
  6847. /* WEBPACK VAR INJECTION */(function(process) {/**
  6848. * Copyright 2013-2015, Facebook, Inc.
  6849. * All rights reserved.
  6850. *
  6851. * This source code is licensed under the BSD-style license found in the
  6852. * LICENSE file in the root directory of this source tree. An additional grant
  6853. * of patent rights can be found in the PATENTS file in the same directory.
  6854. *
  6855. * @providesModule ReactPropTypeLocationNames
  6856. */
  6857. 'use strict';
  6858. var ReactPropTypeLocationNames = {};
  6859. if (process.env.NODE_ENV !== 'production') {
  6860. ReactPropTypeLocationNames = {
  6861. prop: 'prop',
  6862. context: 'context',
  6863. childContext: 'child context'
  6864. };
  6865. }
  6866. module.exports = ReactPropTypeLocationNames;
  6867. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  6868. /***/ },
  6869. /* 67 */
  6870. /***/ function(module, exports) {
  6871. /**
  6872. * Copyright 2013-2015, Facebook, Inc.
  6873. * All rights reserved.
  6874. *
  6875. * This source code is licensed under the BSD-style license found in the
  6876. * LICENSE file in the root directory of this source tree. An additional grant
  6877. * of patent rights can be found in the PATENTS file in the same directory.
  6878. *
  6879. * @providesModule shouldUpdateReactComponent
  6880. * @typechecks static-only
  6881. */
  6882. 'use strict';
  6883. /**
  6884. * Given a `prevElement` and `nextElement`, determines if the existing
  6885. * instance should be updated as opposed to being destroyed or replaced by a new
  6886. * instance. Both arguments are elements. This ensures that this logic can
  6887. * operate on stateless trees without any backing instance.
  6888. *
  6889. * @param {?object} prevElement
  6890. * @param {?object} nextElement
  6891. * @return {boolean} True if the existing instance should be updated.
  6892. * @protected
  6893. */
  6894. function shouldUpdateReactComponent(prevElement, nextElement) {
  6895. var prevEmpty = prevElement === null || prevElement === false;
  6896. var nextEmpty = nextElement === null || nextElement === false;
  6897. if (prevEmpty || nextEmpty) {
  6898. return prevEmpty === nextEmpty;
  6899. }
  6900. var prevType = typeof prevElement;
  6901. var nextType = typeof nextElement;
  6902. if (prevType === 'string' || prevType === 'number') {
  6903. return nextType === 'string' || nextType === 'number';
  6904. } else {
  6905. return nextType === 'object' && prevElement.type === nextElement.type && prevElement.key === nextElement.key;
  6906. }
  6907. return false;
  6908. }
  6909. module.exports = shouldUpdateReactComponent;
  6910. /***/ },
  6911. /* 68 */
  6912. /***/ function(module, exports, __webpack_require__) {
  6913. /**
  6914. * Copyright 2014-2015, Facebook, Inc.
  6915. * All rights reserved.
  6916. *
  6917. * This source code is licensed under the BSD-style license found in the
  6918. * LICENSE file in the root directory of this source tree. An additional grant
  6919. * of patent rights can be found in the PATENTS file in the same directory.
  6920. *
  6921. * @providesModule ReactEmptyComponent
  6922. */
  6923. 'use strict';
  6924. var ReactElement = __webpack_require__(42);
  6925. var ReactEmptyComponentRegistry = __webpack_require__(44);
  6926. var ReactReconciler = __webpack_require__(50);
  6927. var assign = __webpack_require__(39);
  6928. var placeholderElement;
  6929. var ReactEmptyComponentInjection = {
  6930. injectEmptyComponent: function (component) {
  6931. placeholderElement = ReactElement.createElement(component);
  6932. }
  6933. };
  6934. function registerNullComponentID() {
  6935. ReactEmptyComponentRegistry.registerNullComponentID(this._rootNodeID);
  6936. }
  6937. var ReactEmptyComponent = function (instantiate) {
  6938. this._currentElement = null;
  6939. this._rootNodeID = null;
  6940. this._renderedComponent = instantiate(placeholderElement);
  6941. };
  6942. assign(ReactEmptyComponent.prototype, {
  6943. construct: function (element) {},
  6944. mountComponent: function (rootID, transaction, context) {
  6945. transaction.getReactMountReady().enqueue(registerNullComponentID, this);
  6946. this._rootNodeID = rootID;
  6947. return ReactReconciler.mountComponent(this._renderedComponent, rootID, transaction, context);
  6948. },
  6949. receiveComponent: function () {},
  6950. unmountComponent: function (rootID, transaction, context) {
  6951. ReactReconciler.unmountComponent(this._renderedComponent);
  6952. ReactEmptyComponentRegistry.deregisterNullComponentID(this._rootNodeID);
  6953. this._rootNodeID = null;
  6954. this._renderedComponent = null;
  6955. }
  6956. });
  6957. ReactEmptyComponent.injection = ReactEmptyComponentInjection;
  6958. module.exports = ReactEmptyComponent;
  6959. /***/ },
  6960. /* 69 */
  6961. /***/ function(module, exports, __webpack_require__) {
  6962. /* WEBPACK VAR INJECTION */(function(process) {/**
  6963. * Copyright 2014-2015, Facebook, Inc.
  6964. * All rights reserved.
  6965. *
  6966. * This source code is licensed under the BSD-style license found in the
  6967. * LICENSE file in the root directory of this source tree. An additional grant
  6968. * of patent rights can be found in the PATENTS file in the same directory.
  6969. *
  6970. * @providesModule ReactNativeComponent
  6971. */
  6972. 'use strict';
  6973. var assign = __webpack_require__(39);
  6974. var invariant = __webpack_require__(13);
  6975. var autoGenerateWrapperClass = null;
  6976. var genericComponentClass = null;
  6977. // This registry keeps track of wrapper classes around native tags.
  6978. var tagToComponentClass = {};
  6979. var textComponentClass = null;
  6980. var ReactNativeComponentInjection = {
  6981. // This accepts a class that receives the tag string. This is a catch all
  6982. // that can render any kind of tag.
  6983. injectGenericComponentClass: function (componentClass) {
  6984. genericComponentClass = componentClass;
  6985. },
  6986. // This accepts a text component class that takes the text string to be
  6987. // rendered as props.
  6988. injectTextComponentClass: function (componentClass) {
  6989. textComponentClass = componentClass;
  6990. },
  6991. // This accepts a keyed object with classes as values. Each key represents a
  6992. // tag. That particular tag will use this class instead of the generic one.
  6993. injectComponentClasses: function (componentClasses) {
  6994. assign(tagToComponentClass, componentClasses);
  6995. }
  6996. };
  6997. /**
  6998. * Get a composite component wrapper class for a specific tag.
  6999. *
  7000. * @param {ReactElement} element The tag for which to get the class.
  7001. * @return {function} The React class constructor function.
  7002. */
  7003. function getComponentClassForElement(element) {
  7004. if (typeof element.type === 'function') {
  7005. return element.type;
  7006. }
  7007. var tag = element.type;
  7008. var componentClass = tagToComponentClass[tag];
  7009. if (componentClass == null) {
  7010. tagToComponentClass[tag] = componentClass = autoGenerateWrapperClass(tag);
  7011. }
  7012. return componentClass;
  7013. }
  7014. /**
  7015. * Get a native internal component class for a specific tag.
  7016. *
  7017. * @param {ReactElement} element The element to create.
  7018. * @return {function} The internal class constructor function.
  7019. */
  7020. function createInternalComponent(element) {
  7021. !genericComponentClass ? process.env.NODE_ENV !== 'production' ? invariant(false, 'There is no registered component for the tag %s', element.type) : invariant(false) : undefined;
  7022. return new genericComponentClass(element.type, element.props);
  7023. }
  7024. /**
  7025. * @param {ReactText} text
  7026. * @return {ReactComponent}
  7027. */
  7028. function createInstanceForText(text) {
  7029. return new textComponentClass(text);
  7030. }
  7031. /**
  7032. * @param {ReactComponent} component
  7033. * @return {boolean}
  7034. */
  7035. function isTextComponent(component) {
  7036. return component instanceof textComponentClass;
  7037. }
  7038. var ReactNativeComponent = {
  7039. getComponentClassForElement: getComponentClassForElement,
  7040. createInternalComponent: createInternalComponent,
  7041. createInstanceForText: createInstanceForText,
  7042. isTextComponent: isTextComponent,
  7043. injection: ReactNativeComponentInjection
  7044. };
  7045. module.exports = ReactNativeComponent;
  7046. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  7047. /***/ },
  7048. /* 70 */
  7049. /***/ function(module, exports, __webpack_require__) {
  7050. /* WEBPACK VAR INJECTION */(function(process) {/**
  7051. * Copyright 2015, Facebook, Inc.
  7052. * All rights reserved.
  7053. *
  7054. * This source code is licensed under the BSD-style license found in the
  7055. * LICENSE file in the root directory of this source tree. An additional grant
  7056. * of patent rights can be found in the PATENTS file in the same directory.
  7057. *
  7058. * @providesModule validateDOMNesting
  7059. */
  7060. 'use strict';
  7061. var assign = __webpack_require__(39);
  7062. var emptyFunction = __webpack_require__(15);
  7063. var warning = __webpack_require__(25);
  7064. var validateDOMNesting = emptyFunction;
  7065. if (process.env.NODE_ENV !== 'production') {
  7066. // This validation code was written based on the HTML5 parsing spec:
  7067. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  7068. //
  7069. // Note: this does not catch all invalid nesting, nor does it try to (as it's
  7070. // not clear what practical benefit doing so provides); instead, we warn only
  7071. // for cases where the parser will give a parse tree differing from what React
  7072. // intended. For example, <b><div></div></b> is invalid but we don't warn
  7073. // because it still parses correctly; we do warn for other cases like nested
  7074. // <p> tags where the beginning of the second element implicitly closes the
  7075. // first, causing a confusing mess.
  7076. // https://html.spec.whatwg.org/multipage/syntax.html#special
  7077. var specialTags = ['address', 'applet', 'area', 'article', 'aside', 'base', 'basefont', 'bgsound', 'blockquote', 'body', 'br', 'button', 'caption', 'center', 'col', 'colgroup', 'dd', 'details', 'dir', 'div', 'dl', 'dt', 'embed', 'fieldset', 'figcaption', 'figure', 'footer', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'iframe', 'img', 'input', 'isindex', 'li', 'link', 'listing', 'main', 'marquee', 'menu', 'menuitem', 'meta', 'nav', 'noembed', 'noframes', 'noscript', 'object', 'ol', 'p', 'param', 'plaintext', 'pre', 'script', 'section', 'select', 'source', 'style', 'summary', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'track', 'ul', 'wbr', 'xmp'];
  7078. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-scope
  7079. var inScopeTags = ['applet', 'caption', 'html', 'table', 'td', 'th', 'marquee', 'object', 'template',
  7080. // https://html.spec.whatwg.org/multipage/syntax.html#html-integration-point
  7081. // TODO: Distinguish by namespace here -- for <title>, including it here
  7082. // errs on the side of fewer warnings
  7083. 'foreignObject', 'desc', 'title'];
  7084. // https://html.spec.whatwg.org/multipage/syntax.html#has-an-element-in-button-scope
  7085. var buttonScopeTags = inScopeTags.concat(['button']);
  7086. // https://html.spec.whatwg.org/multipage/syntax.html#generate-implied-end-tags
  7087. var impliedEndTags = ['dd', 'dt', 'li', 'option', 'optgroup', 'p', 'rp', 'rt'];
  7088. var emptyAncestorInfo = {
  7089. parentTag: null,
  7090. formTag: null,
  7091. aTagInScope: null,
  7092. buttonTagInScope: null,
  7093. nobrTagInScope: null,
  7094. pTagInButtonScope: null,
  7095. listItemTagAutoclosing: null,
  7096. dlItemTagAutoclosing: null
  7097. };
  7098. var updatedAncestorInfo = function (oldInfo, tag, instance) {
  7099. var ancestorInfo = assign({}, oldInfo || emptyAncestorInfo);
  7100. var info = { tag: tag, instance: instance };
  7101. if (inScopeTags.indexOf(tag) !== -1) {
  7102. ancestorInfo.aTagInScope = null;
  7103. ancestorInfo.buttonTagInScope = null;
  7104. ancestorInfo.nobrTagInScope = null;
  7105. }
  7106. if (buttonScopeTags.indexOf(tag) !== -1) {
  7107. ancestorInfo.pTagInButtonScope = null;
  7108. }
  7109. // See rules for 'li', 'dd', 'dt' start tags in
  7110. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  7111. if (specialTags.indexOf(tag) !== -1 && tag !== 'address' && tag !== 'div' && tag !== 'p') {
  7112. ancestorInfo.listItemTagAutoclosing = null;
  7113. ancestorInfo.dlItemTagAutoclosing = null;
  7114. }
  7115. ancestorInfo.parentTag = info;
  7116. if (tag === 'form') {
  7117. ancestorInfo.formTag = info;
  7118. }
  7119. if (tag === 'a') {
  7120. ancestorInfo.aTagInScope = info;
  7121. }
  7122. if (tag === 'button') {
  7123. ancestorInfo.buttonTagInScope = info;
  7124. }
  7125. if (tag === 'nobr') {
  7126. ancestorInfo.nobrTagInScope = info;
  7127. }
  7128. if (tag === 'p') {
  7129. ancestorInfo.pTagInButtonScope = info;
  7130. }
  7131. if (tag === 'li') {
  7132. ancestorInfo.listItemTagAutoclosing = info;
  7133. }
  7134. if (tag === 'dd' || tag === 'dt') {
  7135. ancestorInfo.dlItemTagAutoclosing = info;
  7136. }
  7137. return ancestorInfo;
  7138. };
  7139. /**
  7140. * Returns whether
  7141. */
  7142. var isTagValidWithParent = function (tag, parentTag) {
  7143. // First, let's check if we're in an unusual parsing mode...
  7144. switch (parentTag) {
  7145. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inselect
  7146. case 'select':
  7147. return tag === 'option' || tag === 'optgroup' || tag === '#text';
  7148. case 'optgroup':
  7149. return tag === 'option' || tag === '#text';
  7150. // Strictly speaking, seeing an <option> doesn't mean we're in a <select>
  7151. // but
  7152. case 'option':
  7153. return tag === '#text';
  7154. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intd
  7155. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incaption
  7156. // No special behavior since these rules fall back to "in body" mode for
  7157. // all except special table nodes which cause bad parsing behavior anyway.
  7158. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intr
  7159. case 'tr':
  7160. return tag === 'th' || tag === 'td' || tag === 'style' || tag === 'script' || tag === 'template';
  7161. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intbody
  7162. case 'tbody':
  7163. case 'thead':
  7164. case 'tfoot':
  7165. return tag === 'tr' || tag === 'style' || tag === 'script' || tag === 'template';
  7166. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-incolgroup
  7167. case 'colgroup':
  7168. return tag === 'col' || tag === 'template';
  7169. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-intable
  7170. case 'table':
  7171. return tag === 'caption' || tag === 'colgroup' || tag === 'tbody' || tag === 'tfoot' || tag === 'thead' || tag === 'style' || tag === 'script' || tag === 'template';
  7172. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inhead
  7173. case 'head':
  7174. return tag === 'base' || tag === 'basefont' || tag === 'bgsound' || tag === 'link' || tag === 'meta' || tag === 'title' || tag === 'noscript' || tag === 'noframes' || tag === 'style' || tag === 'script' || tag === 'template';
  7175. // https://html.spec.whatwg.org/multipage/semantics.html#the-html-element
  7176. case 'html':
  7177. return tag === 'head' || tag === 'body';
  7178. }
  7179. // Probably in the "in body" parsing mode, so we outlaw only tag combos
  7180. // where the parsing rules cause implicit opens or closes to be added.
  7181. // https://html.spec.whatwg.org/multipage/syntax.html#parsing-main-inbody
  7182. switch (tag) {
  7183. case 'h1':
  7184. case 'h2':
  7185. case 'h3':
  7186. case 'h4':
  7187. case 'h5':
  7188. case 'h6':
  7189. return parentTag !== 'h1' && parentTag !== 'h2' && parentTag !== 'h3' && parentTag !== 'h4' && parentTag !== 'h5' && parentTag !== 'h6';
  7190. case 'rp':
  7191. case 'rt':
  7192. return impliedEndTags.indexOf(parentTag) === -1;
  7193. case 'caption':
  7194. case 'col':
  7195. case 'colgroup':
  7196. case 'frame':
  7197. case 'head':
  7198. case 'tbody':
  7199. case 'td':
  7200. case 'tfoot':
  7201. case 'th':
  7202. case 'thead':
  7203. case 'tr':
  7204. // These tags are only valid with a few parents that have special child
  7205. // parsing rules -- if we're down here, then none of those matched and
  7206. // so we allow it only if we don't know what the parent is, as all other
  7207. // cases are invalid.
  7208. return parentTag == null;
  7209. }
  7210. return true;
  7211. };
  7212. /**
  7213. * Returns whether
  7214. */
  7215. var findInvalidAncestorForTag = function (tag, ancestorInfo) {
  7216. switch (tag) {
  7217. case 'address':
  7218. case 'article':
  7219. case 'aside':
  7220. case 'blockquote':
  7221. case 'center':
  7222. case 'details':
  7223. case 'dialog':
  7224. case 'dir':
  7225. case 'div':
  7226. case 'dl':
  7227. case 'fieldset':
  7228. case 'figcaption':
  7229. case 'figure':
  7230. case 'footer':
  7231. case 'header':
  7232. case 'hgroup':
  7233. case 'main':
  7234. case 'menu':
  7235. case 'nav':
  7236. case 'ol':
  7237. case 'p':
  7238. case 'section':
  7239. case 'summary':
  7240. case 'ul':
  7241. case 'pre':
  7242. case 'listing':
  7243. case 'table':
  7244. case 'hr':
  7245. case 'xmp':
  7246. case 'h1':
  7247. case 'h2':
  7248. case 'h3':
  7249. case 'h4':
  7250. case 'h5':
  7251. case 'h6':
  7252. return ancestorInfo.pTagInButtonScope;
  7253. case 'form':
  7254. return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
  7255. case 'li':
  7256. return ancestorInfo.listItemTagAutoclosing;
  7257. case 'dd':
  7258. case 'dt':
  7259. return ancestorInfo.dlItemTagAutoclosing;
  7260. case 'button':
  7261. return ancestorInfo.buttonTagInScope;
  7262. case 'a':
  7263. // Spec says something about storing a list of markers, but it sounds
  7264. // equivalent to this check.
  7265. return ancestorInfo.aTagInScope;
  7266. case 'nobr':
  7267. return ancestorInfo.nobrTagInScope;
  7268. }
  7269. return null;
  7270. };
  7271. /**
  7272. * Given a ReactCompositeComponent instance, return a list of its recursive
  7273. * owners, starting at the root and ending with the instance itself.
  7274. */
  7275. var findOwnerStack = function (instance) {
  7276. if (!instance) {
  7277. return [];
  7278. }
  7279. var stack = [];
  7280. /*eslint-disable space-after-keywords */
  7281. do {
  7282. /*eslint-enable space-after-keywords */
  7283. stack.push(instance);
  7284. } while (instance = instance._currentElement._owner);
  7285. stack.reverse();
  7286. return stack;
  7287. };
  7288. var didWarn = {};
  7289. validateDOMNesting = function (childTag, childInstance, ancestorInfo) {
  7290. ancestorInfo = ancestorInfo || emptyAncestorInfo;
  7291. var parentInfo = ancestorInfo.parentTag;
  7292. var parentTag = parentInfo && parentInfo.tag;
  7293. var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
  7294. var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
  7295. var problematic = invalidParent || invalidAncestor;
  7296. if (problematic) {
  7297. var ancestorTag = problematic.tag;
  7298. var ancestorInstance = problematic.instance;
  7299. var childOwner = childInstance && childInstance._currentElement._owner;
  7300. var ancestorOwner = ancestorInstance && ancestorInstance._currentElement._owner;
  7301. var childOwners = findOwnerStack(childOwner);
  7302. var ancestorOwners = findOwnerStack(ancestorOwner);
  7303. var minStackLen = Math.min(childOwners.length, ancestorOwners.length);
  7304. var i;
  7305. var deepestCommon = -1;
  7306. for (i = 0; i < minStackLen; i++) {
  7307. if (childOwners[i] === ancestorOwners[i]) {
  7308. deepestCommon = i;
  7309. } else {
  7310. break;
  7311. }
  7312. }
  7313. var UNKNOWN = '(unknown)';
  7314. var childOwnerNames = childOwners.slice(deepestCommon + 1).map(function (inst) {
  7315. return inst.getName() || UNKNOWN;
  7316. });
  7317. var ancestorOwnerNames = ancestorOwners.slice(deepestCommon + 1).map(function (inst) {
  7318. return inst.getName() || UNKNOWN;
  7319. });
  7320. var ownerInfo = [].concat(
  7321. // If the parent and child instances have a common owner ancestor, start
  7322. // with that -- otherwise we just start with the parent's owners.
  7323. deepestCommon !== -1 ? childOwners[deepestCommon].getName() || UNKNOWN : [], ancestorOwnerNames, ancestorTag,
  7324. // If we're warning about an invalid (non-parent) ancestry, add '...'
  7325. invalidAncestor ? ['...'] : [], childOwnerNames, childTag).join(' > ');
  7326. var warnKey = !!invalidParent + '|' + childTag + '|' + ancestorTag + '|' + ownerInfo;
  7327. if (didWarn[warnKey]) {
  7328. return;
  7329. }
  7330. didWarn[warnKey] = true;
  7331. if (invalidParent) {
  7332. var info = '';
  7333. if (ancestorTag === 'table' && childTag === 'tr') {
  7334. info += ' Add a <tbody> to your code to match the DOM tree generated by ' + 'the browser.';
  7335. }
  7336. process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a child of <%s>. ' + 'See %s.%s', childTag, ancestorTag, ownerInfo, info) : undefined;
  7337. } else {
  7338. process.env.NODE_ENV !== 'production' ? warning(false, 'validateDOMNesting(...): <%s> cannot appear as a descendant of ' + '<%s>. See %s.', childTag, ancestorTag, ownerInfo) : undefined;
  7339. }
  7340. }
  7341. };
  7342. validateDOMNesting.ancestorInfoContextKey = '__validateDOMNesting_ancestorInfo$' + Math.random().toString(36).slice(2);
  7343. validateDOMNesting.updatedAncestorInfo = updatedAncestorInfo;
  7344. // For testing
  7345. validateDOMNesting.isTagValidInContext = function (tag, ancestorInfo) {
  7346. ancestorInfo = ancestorInfo || emptyAncestorInfo;
  7347. var parentInfo = ancestorInfo.parentTag;
  7348. var parentTag = parentInfo && parentInfo.tag;
  7349. return isTagValidWithParent(tag, parentTag) && !findInvalidAncestorForTag(tag, ancestorInfo);
  7350. };
  7351. }
  7352. module.exports = validateDOMNesting;
  7353. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  7354. /***/ },
  7355. /* 71 */
  7356. /***/ function(module, exports, __webpack_require__) {
  7357. /* WEBPACK VAR INJECTION */(function(process) {/**
  7358. * Copyright 2013-2015, Facebook, Inc.
  7359. * All rights reserved.
  7360. *
  7361. * This source code is licensed under the BSD-style license found in the
  7362. * LICENSE file in the root directory of this source tree. An additional grant
  7363. * of patent rights can be found in the PATENTS file in the same directory.
  7364. *
  7365. * @providesModule ReactDefaultInjection
  7366. */
  7367. 'use strict';
  7368. var BeforeInputEventPlugin = __webpack_require__(72);
  7369. var ChangeEventPlugin = __webpack_require__(80);
  7370. var ClientReactRootIndex = __webpack_require__(83);
  7371. var DefaultEventPluginOrder = __webpack_require__(84);
  7372. var EnterLeaveEventPlugin = __webpack_require__(85);
  7373. var ExecutionEnvironment = __webpack_require__(9);
  7374. var HTMLDOMPropertyConfig = __webpack_require__(89);
  7375. var ReactBrowserComponentMixin = __webpack_require__(90);
  7376. var ReactComponentBrowserEnvironment = __webpack_require__(26);
  7377. var ReactDefaultBatchingStrategy = __webpack_require__(92);
  7378. var ReactDOMComponent = __webpack_require__(93);
  7379. var ReactDOMTextComponent = __webpack_require__(6);
  7380. var ReactEventListener = __webpack_require__(118);
  7381. var ReactInjection = __webpack_require__(121);
  7382. var ReactInstanceHandles = __webpack_require__(45);
  7383. var ReactMount = __webpack_require__(28);
  7384. var ReactReconcileTransaction = __webpack_require__(125);
  7385. var SelectEventPlugin = __webpack_require__(130);
  7386. var ServerReactRootIndex = __webpack_require__(131);
  7387. var SimpleEventPlugin = __webpack_require__(132);
  7388. var SVGDOMPropertyConfig = __webpack_require__(141);
  7389. var alreadyInjected = false;
  7390. function inject() {
  7391. if (alreadyInjected) {
  7392. // TODO: This is currently true because these injections are shared between
  7393. // the client and the server package. They should be built independently
  7394. // and not share any injection state. Then this problem will be solved.
  7395. return;
  7396. }
  7397. alreadyInjected = true;
  7398. ReactInjection.EventEmitter.injectReactEventListener(ReactEventListener);
  7399. /**
  7400. * Inject modules for resolving DOM hierarchy and plugin ordering.
  7401. */
  7402. ReactInjection.EventPluginHub.injectEventPluginOrder(DefaultEventPluginOrder);
  7403. ReactInjection.EventPluginHub.injectInstanceHandle(ReactInstanceHandles);
  7404. ReactInjection.EventPluginHub.injectMount(ReactMount);
  7405. /**
  7406. * Some important event plugins included by default (without having to require
  7407. * them).
  7408. */
  7409. ReactInjection.EventPluginHub.injectEventPluginsByName({
  7410. SimpleEventPlugin: SimpleEventPlugin,
  7411. EnterLeaveEventPlugin: EnterLeaveEventPlugin,
  7412. ChangeEventPlugin: ChangeEventPlugin,
  7413. SelectEventPlugin: SelectEventPlugin,
  7414. BeforeInputEventPlugin: BeforeInputEventPlugin
  7415. });
  7416. ReactInjection.NativeComponent.injectGenericComponentClass(ReactDOMComponent);
  7417. ReactInjection.NativeComponent.injectTextComponentClass(ReactDOMTextComponent);
  7418. ReactInjection.Class.injectMixin(ReactBrowserComponentMixin);
  7419. ReactInjection.DOMProperty.injectDOMPropertyConfig(HTMLDOMPropertyConfig);
  7420. ReactInjection.DOMProperty.injectDOMPropertyConfig(SVGDOMPropertyConfig);
  7421. ReactInjection.EmptyComponent.injectEmptyComponent('noscript');
  7422. ReactInjection.Updates.injectReconcileTransaction(ReactReconcileTransaction);
  7423. ReactInjection.Updates.injectBatchingStrategy(ReactDefaultBatchingStrategy);
  7424. ReactInjection.RootIndex.injectCreateReactRootIndex(ExecutionEnvironment.canUseDOM ? ClientReactRootIndex.createReactRootIndex : ServerReactRootIndex.createReactRootIndex);
  7425. ReactInjection.Component.injectEnvironment(ReactComponentBrowserEnvironment);
  7426. if (process.env.NODE_ENV !== 'production') {
  7427. var url = ExecutionEnvironment.canUseDOM && window.location.href || '';
  7428. if (/[?&]react_perf\b/.test(url)) {
  7429. var ReactDefaultPerf = __webpack_require__(142);
  7430. ReactDefaultPerf.start();
  7431. }
  7432. }
  7433. }
  7434. module.exports = {
  7435. inject: inject
  7436. };
  7437. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  7438. /***/ },
  7439. /* 72 */
  7440. /***/ function(module, exports, __webpack_require__) {
  7441. /**
  7442. * Copyright 2013-2015 Facebook, Inc.
  7443. * All rights reserved.
  7444. *
  7445. * This source code is licensed under the BSD-style license found in the
  7446. * LICENSE file in the root directory of this source tree. An additional grant
  7447. * of patent rights can be found in the PATENTS file in the same directory.
  7448. *
  7449. * @providesModule BeforeInputEventPlugin
  7450. * @typechecks static-only
  7451. */
  7452. 'use strict';
  7453. var EventConstants = __webpack_require__(30);
  7454. var EventPropagators = __webpack_require__(73);
  7455. var ExecutionEnvironment = __webpack_require__(9);
  7456. var FallbackCompositionState = __webpack_require__(74);
  7457. var SyntheticCompositionEvent = __webpack_require__(76);
  7458. var SyntheticInputEvent = __webpack_require__(78);
  7459. var keyOf = __webpack_require__(79);
  7460. var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space
  7461. var START_KEYCODE = 229;
  7462. var canUseCompositionEvent = ExecutionEnvironment.canUseDOM && 'CompositionEvent' in window;
  7463. var documentMode = null;
  7464. if (ExecutionEnvironment.canUseDOM && 'documentMode' in document) {
  7465. documentMode = document.documentMode;
  7466. }
  7467. // Webkit offers a very useful `textInput` event that can be used to
  7468. // directly represent `beforeInput`. The IE `textinput` event is not as
  7469. // useful, so we don't use it.
  7470. var canUseTextInputEvent = ExecutionEnvironment.canUseDOM && 'TextEvent' in window && !documentMode && !isPresto();
  7471. // In IE9+, we have access to composition events, but the data supplied
  7472. // by the native compositionend event may be incorrect. Japanese ideographic
  7473. // spaces, for instance (\u3000) are not recorded correctly.
  7474. var useFallbackCompositionData = ExecutionEnvironment.canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
  7475. /**
  7476. * Opera <= 12 includes TextEvent in window, but does not fire
  7477. * text input events. Rely on keypress instead.
  7478. */
  7479. function isPresto() {
  7480. var opera = window.opera;
  7481. return typeof opera === 'object' && typeof opera.version === 'function' && parseInt(opera.version(), 10) <= 12;
  7482. }
  7483. var SPACEBAR_CODE = 32;
  7484. var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
  7485. var topLevelTypes = EventConstants.topLevelTypes;
  7486. // Events and their corresponding property names.
  7487. var eventTypes = {
  7488. beforeInput: {
  7489. phasedRegistrationNames: {
  7490. bubbled: keyOf({ onBeforeInput: null }),
  7491. captured: keyOf({ onBeforeInputCapture: null })
  7492. },
  7493. dependencies: [topLevelTypes.topCompositionEnd, topLevelTypes.topKeyPress, topLevelTypes.topTextInput, topLevelTypes.topPaste]
  7494. },
  7495. compositionEnd: {
  7496. phasedRegistrationNames: {
  7497. bubbled: keyOf({ onCompositionEnd: null }),
  7498. captured: keyOf({ onCompositionEndCapture: null })
  7499. },
  7500. dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionEnd, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
  7501. },
  7502. compositionStart: {
  7503. phasedRegistrationNames: {
  7504. bubbled: keyOf({ onCompositionStart: null }),
  7505. captured: keyOf({ onCompositionStartCapture: null })
  7506. },
  7507. dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionStart, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
  7508. },
  7509. compositionUpdate: {
  7510. phasedRegistrationNames: {
  7511. bubbled: keyOf({ onCompositionUpdate: null }),
  7512. captured: keyOf({ onCompositionUpdateCapture: null })
  7513. },
  7514. dependencies: [topLevelTypes.topBlur, topLevelTypes.topCompositionUpdate, topLevelTypes.topKeyDown, topLevelTypes.topKeyPress, topLevelTypes.topKeyUp, topLevelTypes.topMouseDown]
  7515. }
  7516. };
  7517. // Track whether we've ever handled a keypress on the space key.
  7518. var hasSpaceKeypress = false;
  7519. /**
  7520. * Return whether a native keypress event is assumed to be a command.
  7521. * This is required because Firefox fires `keypress` events for key commands
  7522. * (cut, copy, select-all, etc.) even though no character is inserted.
  7523. */
  7524. function isKeypressCommand(nativeEvent) {
  7525. return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) &&
  7526. // ctrlKey && altKey is equivalent to AltGr, and is not a command.
  7527. !(nativeEvent.ctrlKey && nativeEvent.altKey);
  7528. }
  7529. /**
  7530. * Translate native top level events into event types.
  7531. *
  7532. * @param {string} topLevelType
  7533. * @return {object}
  7534. */
  7535. function getCompositionEventType(topLevelType) {
  7536. switch (topLevelType) {
  7537. case topLevelTypes.topCompositionStart:
  7538. return eventTypes.compositionStart;
  7539. case topLevelTypes.topCompositionEnd:
  7540. return eventTypes.compositionEnd;
  7541. case topLevelTypes.topCompositionUpdate:
  7542. return eventTypes.compositionUpdate;
  7543. }
  7544. }
  7545. /**
  7546. * Does our fallback best-guess model think this event signifies that
  7547. * composition has begun?
  7548. *
  7549. * @param {string} topLevelType
  7550. * @param {object} nativeEvent
  7551. * @return {boolean}
  7552. */
  7553. function isFallbackCompositionStart(topLevelType, nativeEvent) {
  7554. return topLevelType === topLevelTypes.topKeyDown && nativeEvent.keyCode === START_KEYCODE;
  7555. }
  7556. /**
  7557. * Does our fallback mode think that this event is the end of composition?
  7558. *
  7559. * @param {string} topLevelType
  7560. * @param {object} nativeEvent
  7561. * @return {boolean}
  7562. */
  7563. function isFallbackCompositionEnd(topLevelType, nativeEvent) {
  7564. switch (topLevelType) {
  7565. case topLevelTypes.topKeyUp:
  7566. // Command keys insert or clear IME input.
  7567. return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
  7568. case topLevelTypes.topKeyDown:
  7569. // Expect IME keyCode on each keydown. If we get any other
  7570. // code we must have exited earlier.
  7571. return nativeEvent.keyCode !== START_KEYCODE;
  7572. case topLevelTypes.topKeyPress:
  7573. case topLevelTypes.topMouseDown:
  7574. case topLevelTypes.topBlur:
  7575. // Events are not possible without cancelling IME.
  7576. return true;
  7577. default:
  7578. return false;
  7579. }
  7580. }
  7581. /**
  7582. * Google Input Tools provides composition data via a CustomEvent,
  7583. * with the `data` property populated in the `detail` object. If this
  7584. * is available on the event object, use it. If not, this is a plain
  7585. * composition event and we have nothing special to extract.
  7586. *
  7587. * @param {object} nativeEvent
  7588. * @return {?string}
  7589. */
  7590. function getDataFromCustomEvent(nativeEvent) {
  7591. var detail = nativeEvent.detail;
  7592. if (typeof detail === 'object' && 'data' in detail) {
  7593. return detail.data;
  7594. }
  7595. return null;
  7596. }
  7597. // Track the current IME composition fallback object, if any.
  7598. var currentComposition = null;
  7599. /**
  7600. * @param {string} topLevelType Record from `EventConstants`.
  7601. * @param {DOMEventTarget} topLevelTarget The listening component root node.
  7602. * @param {string} topLevelTargetID ID of `topLevelTarget`.
  7603. * @param {object} nativeEvent Native browser event.
  7604. * @return {?object} A SyntheticCompositionEvent.
  7605. */
  7606. function extractCompositionEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
  7607. var eventType;
  7608. var fallbackData;
  7609. if (canUseCompositionEvent) {
  7610. eventType = getCompositionEventType(topLevelType);
  7611. } else if (!currentComposition) {
  7612. if (isFallbackCompositionStart(topLevelType, nativeEvent)) {
  7613. eventType = eventTypes.compositionStart;
  7614. }
  7615. } else if (isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  7616. eventType = eventTypes.compositionEnd;
  7617. }
  7618. if (!eventType) {
  7619. return null;
  7620. }
  7621. if (useFallbackCompositionData) {
  7622. // The current composition is stored statically and must not be
  7623. // overwritten while composition continues.
  7624. if (!currentComposition && eventType === eventTypes.compositionStart) {
  7625. currentComposition = FallbackCompositionState.getPooled(topLevelTarget);
  7626. } else if (eventType === eventTypes.compositionEnd) {
  7627. if (currentComposition) {
  7628. fallbackData = currentComposition.getData();
  7629. }
  7630. }
  7631. }
  7632. var event = SyntheticCompositionEvent.getPooled(eventType, topLevelTargetID, nativeEvent, nativeEventTarget);
  7633. if (fallbackData) {
  7634. // Inject data generated from fallback path into the synthetic event.
  7635. // This matches the property of native CompositionEventInterface.
  7636. event.data = fallbackData;
  7637. } else {
  7638. var customData = getDataFromCustomEvent(nativeEvent);
  7639. if (customData !== null) {
  7640. event.data = customData;
  7641. }
  7642. }
  7643. EventPropagators.accumulateTwoPhaseDispatches(event);
  7644. return event;
  7645. }
  7646. /**
  7647. * @param {string} topLevelType Record from `EventConstants`.
  7648. * @param {object} nativeEvent Native browser event.
  7649. * @return {?string} The string corresponding to this `beforeInput` event.
  7650. */
  7651. function getNativeBeforeInputChars(topLevelType, nativeEvent) {
  7652. switch (topLevelType) {
  7653. case topLevelTypes.topCompositionEnd:
  7654. return getDataFromCustomEvent(nativeEvent);
  7655. case topLevelTypes.topKeyPress:
  7656. /**
  7657. * If native `textInput` events are available, our goal is to make
  7658. * use of them. However, there is a special case: the spacebar key.
  7659. * In Webkit, preventing default on a spacebar `textInput` event
  7660. * cancels character insertion, but it *also* causes the browser
  7661. * to fall back to its default spacebar behavior of scrolling the
  7662. * page.
  7663. *
  7664. * Tracking at:
  7665. * https://code.google.com/p/chromium/issues/detail?id=355103
  7666. *
  7667. * To avoid this issue, use the keypress event as if no `textInput`
  7668. * event is available.
  7669. */
  7670. var which = nativeEvent.which;
  7671. if (which !== SPACEBAR_CODE) {
  7672. return null;
  7673. }
  7674. hasSpaceKeypress = true;
  7675. return SPACEBAR_CHAR;
  7676. case topLevelTypes.topTextInput:
  7677. // Record the characters to be added to the DOM.
  7678. var chars = nativeEvent.data;
  7679. // If it's a spacebar character, assume that we have already handled
  7680. // it at the keypress level and bail immediately. Android Chrome
  7681. // doesn't give us keycodes, so we need to blacklist it.
  7682. if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
  7683. return null;
  7684. }
  7685. return chars;
  7686. default:
  7687. // For other native event types, do nothing.
  7688. return null;
  7689. }
  7690. }
  7691. /**
  7692. * For browsers that do not provide the `textInput` event, extract the
  7693. * appropriate string to use for SyntheticInputEvent.
  7694. *
  7695. * @param {string} topLevelType Record from `EventConstants`.
  7696. * @param {object} nativeEvent Native browser event.
  7697. * @return {?string} The fallback string for this `beforeInput` event.
  7698. */
  7699. function getFallbackBeforeInputChars(topLevelType, nativeEvent) {
  7700. // If we are currently composing (IME) and using a fallback to do so,
  7701. // try to extract the composed characters from the fallback object.
  7702. if (currentComposition) {
  7703. if (topLevelType === topLevelTypes.topCompositionEnd || isFallbackCompositionEnd(topLevelType, nativeEvent)) {
  7704. var chars = currentComposition.getData();
  7705. FallbackCompositionState.release(currentComposition);
  7706. currentComposition = null;
  7707. return chars;
  7708. }
  7709. return null;
  7710. }
  7711. switch (topLevelType) {
  7712. case topLevelTypes.topPaste:
  7713. // If a paste event occurs after a keypress, throw out the input
  7714. // chars. Paste events should not lead to BeforeInput events.
  7715. return null;
  7716. case topLevelTypes.topKeyPress:
  7717. /**
  7718. * As of v27, Firefox may fire keypress events even when no character
  7719. * will be inserted. A few possibilities:
  7720. *
  7721. * - `which` is `0`. Arrow keys, Esc key, etc.
  7722. *
  7723. * - `which` is the pressed key code, but no char is available.
  7724. * Ex: 'AltGr + d` in Polish. There is no modified character for
  7725. * this key combination and no character is inserted into the
  7726. * document, but FF fires the keypress for char code `100` anyway.
  7727. * No `input` event will occur.
  7728. *
  7729. * - `which` is the pressed key code, but a command combination is
  7730. * being used. Ex: `Cmd+C`. No character is inserted, and no
  7731. * `input` event will occur.
  7732. */
  7733. if (nativeEvent.which && !isKeypressCommand(nativeEvent)) {
  7734. return String.fromCharCode(nativeEvent.which);
  7735. }
  7736. return null;
  7737. case topLevelTypes.topCompositionEnd:
  7738. return useFallbackCompositionData ? null : nativeEvent.data;
  7739. default:
  7740. return null;
  7741. }
  7742. }
  7743. /**
  7744. * Extract a SyntheticInputEvent for `beforeInput`, based on either native
  7745. * `textInput` or fallback behavior.
  7746. *
  7747. * @param {string} topLevelType Record from `EventConstants`.
  7748. * @param {DOMEventTarget} topLevelTarget The listening component root node.
  7749. * @param {string} topLevelTargetID ID of `topLevelTarget`.
  7750. * @param {object} nativeEvent Native browser event.
  7751. * @return {?object} A SyntheticInputEvent.
  7752. */
  7753. function extractBeforeInputEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
  7754. var chars;
  7755. if (canUseTextInputEvent) {
  7756. chars = getNativeBeforeInputChars(topLevelType, nativeEvent);
  7757. } else {
  7758. chars = getFallbackBeforeInputChars(topLevelType, nativeEvent);
  7759. }
  7760. // If no characters are being inserted, no BeforeInput event should
  7761. // be fired.
  7762. if (!chars) {
  7763. return null;
  7764. }
  7765. var event = SyntheticInputEvent.getPooled(eventTypes.beforeInput, topLevelTargetID, nativeEvent, nativeEventTarget);
  7766. event.data = chars;
  7767. EventPropagators.accumulateTwoPhaseDispatches(event);
  7768. return event;
  7769. }
  7770. /**
  7771. * Create an `onBeforeInput` event to match
  7772. * http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105/#events-inputevents.
  7773. *
  7774. * This event plugin is based on the native `textInput` event
  7775. * available in Chrome, Safari, Opera, and IE. This event fires after
  7776. * `onKeyPress` and `onCompositionEnd`, but before `onInput`.
  7777. *
  7778. * `beforeInput` is spec'd but not implemented in any browsers, and
  7779. * the `input` event does not provide any useful information about what has
  7780. * actually been added, contrary to the spec. Thus, `textInput` is the best
  7781. * available event to identify the characters that have actually been inserted
  7782. * into the target node.
  7783. *
  7784. * This plugin is also responsible for emitting `composition` events, thus
  7785. * allowing us to share composition fallback code for both `beforeInput` and
  7786. * `composition` event types.
  7787. */
  7788. var BeforeInputEventPlugin = {
  7789. eventTypes: eventTypes,
  7790. /**
  7791. * @param {string} topLevelType Record from `EventConstants`.
  7792. * @param {DOMEventTarget} topLevelTarget The listening component root node.
  7793. * @param {string} topLevelTargetID ID of `topLevelTarget`.
  7794. * @param {object} nativeEvent Native browser event.
  7795. * @return {*} An accumulation of synthetic events.
  7796. * @see {EventPluginHub.extractEvents}
  7797. */
  7798. extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
  7799. return [extractCompositionEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget), extractBeforeInputEvent(topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget)];
  7800. }
  7801. };
  7802. module.exports = BeforeInputEventPlugin;
  7803. /***/ },
  7804. /* 73 */
  7805. /***/ function(module, exports, __webpack_require__) {
  7806. /* WEBPACK VAR INJECTION */(function(process) {/**
  7807. * Copyright 2013-2015, Facebook, Inc.
  7808. * All rights reserved.
  7809. *
  7810. * This source code is licensed under the BSD-style license found in the
  7811. * LICENSE file in the root directory of this source tree. An additional grant
  7812. * of patent rights can be found in the PATENTS file in the same directory.
  7813. *
  7814. * @providesModule EventPropagators
  7815. */
  7816. 'use strict';
  7817. var EventConstants = __webpack_require__(30);
  7818. var EventPluginHub = __webpack_require__(31);
  7819. var warning = __webpack_require__(25);
  7820. var accumulateInto = __webpack_require__(35);
  7821. var forEachAccumulated = __webpack_require__(36);
  7822. var PropagationPhases = EventConstants.PropagationPhases;
  7823. var getListener = EventPluginHub.getListener;
  7824. /**
  7825. * Some event types have a notion of different registration names for different
  7826. * "phases" of propagation. This finds listeners by a given phase.
  7827. */
  7828. function listenerAtPhase(id, event, propagationPhase) {
  7829. var registrationName = event.dispatchConfig.phasedRegistrationNames[propagationPhase];
  7830. return getListener(id, registrationName);
  7831. }
  7832. /**
  7833. * Tags a `SyntheticEvent` with dispatched listeners. Creating this function
  7834. * here, allows us to not have to bind or create functions for each event.
  7835. * Mutating the event's members allows us to not have to create a wrapping
  7836. * "dispatch" object that pairs the event with the listener.
  7837. */
  7838. function accumulateDirectionalDispatches(domID, upwards, event) {
  7839. if (process.env.NODE_ENV !== 'production') {
  7840. process.env.NODE_ENV !== 'production' ? warning(domID, 'Dispatching id must not be null') : undefined;
  7841. }
  7842. var phase = upwards ? PropagationPhases.bubbled : PropagationPhases.captured;
  7843. var listener = listenerAtPhase(domID, event, phase);
  7844. if (listener) {
  7845. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  7846. event._dispatchIDs = accumulateInto(event._dispatchIDs, domID);
  7847. }
  7848. }
  7849. /**
  7850. * Collect dispatches (must be entirely collected before dispatching - see unit
  7851. * tests). Lazily allocate the array to conserve memory. We must loop through
  7852. * each event and perform the traversal for each one. We cannot perform a
  7853. * single traversal for the entire collection of events because each event may
  7854. * have a different target.
  7855. */
  7856. function accumulateTwoPhaseDispatchesSingle(event) {
  7857. if (event && event.dispatchConfig.phasedRegistrationNames) {
  7858. EventPluginHub.injection.getInstanceHandle().traverseTwoPhase(event.dispatchMarker, accumulateDirectionalDispatches, event);
  7859. }
  7860. }
  7861. /**
  7862. * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID.
  7863. */
  7864. function accumulateTwoPhaseDispatchesSingleSkipTarget(event) {
  7865. if (event && event.dispatchConfig.phasedRegistrationNames) {
  7866. EventPluginHub.injection.getInstanceHandle().traverseTwoPhaseSkipTarget(event.dispatchMarker, accumulateDirectionalDispatches, event);
  7867. }
  7868. }
  7869. /**
  7870. * Accumulates without regard to direction, does not look for phased
  7871. * registration names. Same as `accumulateDirectDispatchesSingle` but without
  7872. * requiring that the `dispatchMarker` be the same as the dispatched ID.
  7873. */
  7874. function accumulateDispatches(id, ignoredDirection, event) {
  7875. if (event && event.dispatchConfig.registrationName) {
  7876. var registrationName = event.dispatchConfig.registrationName;
  7877. var listener = getListener(id, registrationName);
  7878. if (listener) {
  7879. event._dispatchListeners = accumulateInto(event._dispatchListeners, listener);
  7880. event._dispatchIDs = accumulateInto(event._dispatchIDs, id);
  7881. }
  7882. }
  7883. }
  7884. /**
  7885. * Accumulates dispatches on an `SyntheticEvent`, but only for the
  7886. * `dispatchMarker`.
  7887. * @param {SyntheticEvent} event
  7888. */
  7889. function accumulateDirectDispatchesSingle(event) {
  7890. if (event && event.dispatchConfig.registrationName) {
  7891. accumulateDispatches(event.dispatchMarker, null, event);
  7892. }
  7893. }
  7894. function accumulateTwoPhaseDispatches(events) {
  7895. forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle);
  7896. }
  7897. function accumulateTwoPhaseDispatchesSkipTarget(events) {
  7898. forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget);
  7899. }
  7900. function accumulateEnterLeaveDispatches(leave, enter, fromID, toID) {
  7901. EventPluginHub.injection.getInstanceHandle().traverseEnterLeave(fromID, toID, accumulateDispatches, leave, enter);
  7902. }
  7903. function accumulateDirectDispatches(events) {
  7904. forEachAccumulated(events, accumulateDirectDispatchesSingle);
  7905. }
  7906. /**
  7907. * A small set of propagation patterns, each of which will accept a small amount
  7908. * of information, and generate a set of "dispatch ready event objects" - which
  7909. * are sets of events that have already been annotated with a set of dispatched
  7910. * listener functions/ids. The API is designed this way to discourage these
  7911. * propagation strategies from actually executing the dispatches, since we
  7912. * always want to collect the entire set of dispatches before executing event a
  7913. * single one.
  7914. *
  7915. * @constructor EventPropagators
  7916. */
  7917. var EventPropagators = {
  7918. accumulateTwoPhaseDispatches: accumulateTwoPhaseDispatches,
  7919. accumulateTwoPhaseDispatchesSkipTarget: accumulateTwoPhaseDispatchesSkipTarget,
  7920. accumulateDirectDispatches: accumulateDirectDispatches,
  7921. accumulateEnterLeaveDispatches: accumulateEnterLeaveDispatches
  7922. };
  7923. module.exports = EventPropagators;
  7924. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  7925. /***/ },
  7926. /* 74 */
  7927. /***/ function(module, exports, __webpack_require__) {
  7928. /**
  7929. * Copyright 2013-2015, Facebook, Inc.
  7930. * All rights reserved.
  7931. *
  7932. * This source code is licensed under the BSD-style license found in the
  7933. * LICENSE file in the root directory of this source tree. An additional grant
  7934. * of patent rights can be found in the PATENTS file in the same directory.
  7935. *
  7936. * @providesModule FallbackCompositionState
  7937. * @typechecks static-only
  7938. */
  7939. 'use strict';
  7940. var PooledClass = __webpack_require__(56);
  7941. var assign = __webpack_require__(39);
  7942. var getTextContentAccessor = __webpack_require__(75);
  7943. /**
  7944. * This helper class stores information about text content of a target node,
  7945. * allowing comparison of content before and after a given event.
  7946. *
  7947. * Identify the node where selection currently begins, then observe
  7948. * both its text content and its current position in the DOM. Since the
  7949. * browser may natively replace the target node during composition, we can
  7950. * use its position to find its replacement.
  7951. *
  7952. * @param {DOMEventTarget} root
  7953. */
  7954. function FallbackCompositionState(root) {
  7955. this._root = root;
  7956. this._startText = this.getText();
  7957. this._fallbackText = null;
  7958. }
  7959. assign(FallbackCompositionState.prototype, {
  7960. destructor: function () {
  7961. this._root = null;
  7962. this._startText = null;
  7963. this._fallbackText = null;
  7964. },
  7965. /**
  7966. * Get current text of input.
  7967. *
  7968. * @return {string}
  7969. */
  7970. getText: function () {
  7971. if ('value' in this._root) {
  7972. return this._root.value;
  7973. }
  7974. return this._root[getTextContentAccessor()];
  7975. },
  7976. /**
  7977. * Determine the differing substring between the initially stored
  7978. * text content and the current content.
  7979. *
  7980. * @return {string}
  7981. */
  7982. getData: function () {
  7983. if (this._fallbackText) {
  7984. return this._fallbackText;
  7985. }
  7986. var start;
  7987. var startValue = this._startText;
  7988. var startLength = startValue.length;
  7989. var end;
  7990. var endValue = this.getText();
  7991. var endLength = endValue.length;
  7992. for (start = 0; start < startLength; start++) {
  7993. if (startValue[start] !== endValue[start]) {
  7994. break;
  7995. }
  7996. }
  7997. var minEnd = startLength - start;
  7998. for (end = 1; end <= minEnd; end++) {
  7999. if (startValue[startLength - end] !== endValue[endLength - end]) {
  8000. break;
  8001. }
  8002. }
  8003. var sliceTail = end > 1 ? 1 - end : undefined;
  8004. this._fallbackText = endValue.slice(start, sliceTail);
  8005. return this._fallbackText;
  8006. }
  8007. });
  8008. PooledClass.addPoolingTo(FallbackCompositionState);
  8009. module.exports = FallbackCompositionState;
  8010. /***/ },
  8011. /* 75 */
  8012. /***/ function(module, exports, __webpack_require__) {
  8013. /**
  8014. * Copyright 2013-2015, Facebook, Inc.
  8015. * All rights reserved.
  8016. *
  8017. * This source code is licensed under the BSD-style license found in the
  8018. * LICENSE file in the root directory of this source tree. An additional grant
  8019. * of patent rights can be found in the PATENTS file in the same directory.
  8020. *
  8021. * @providesModule getTextContentAccessor
  8022. */
  8023. 'use strict';
  8024. var ExecutionEnvironment = __webpack_require__(9);
  8025. var contentKey = null;
  8026. /**
  8027. * Gets the key used to access text content on a DOM node.
  8028. *
  8029. * @return {?string} Key used to access text content.
  8030. * @internal
  8031. */
  8032. function getTextContentAccessor() {
  8033. if (!contentKey && ExecutionEnvironment.canUseDOM) {
  8034. // Prefer textContent to innerText because many browsers support both but
  8035. // SVG <text> elements don't support innerText even when <div> does.
  8036. contentKey = 'textContent' in document.documentElement ? 'textContent' : 'innerText';
  8037. }
  8038. return contentKey;
  8039. }
  8040. module.exports = getTextContentAccessor;
  8041. /***/ },
  8042. /* 76 */
  8043. /***/ function(module, exports, __webpack_require__) {
  8044. /**
  8045. * Copyright 2013-2015, Facebook, Inc.
  8046. * All rights reserved.
  8047. *
  8048. * This source code is licensed under the BSD-style license found in the
  8049. * LICENSE file in the root directory of this source tree. An additional grant
  8050. * of patent rights can be found in the PATENTS file in the same directory.
  8051. *
  8052. * @providesModule SyntheticCompositionEvent
  8053. * @typechecks static-only
  8054. */
  8055. 'use strict';
  8056. var SyntheticEvent = __webpack_require__(77);
  8057. /**
  8058. * @interface Event
  8059. * @see http://www.w3.org/TR/DOM-Level-3-Events/#events-compositionevents
  8060. */
  8061. var CompositionEventInterface = {
  8062. data: null
  8063. };
  8064. /**
  8065. * @param {object} dispatchConfig Configuration used to dispatch this event.
  8066. * @param {string} dispatchMarker Marker identifying the event target.
  8067. * @param {object} nativeEvent Native browser event.
  8068. * @extends {SyntheticUIEvent}
  8069. */
  8070. function SyntheticCompositionEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  8071. SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
  8072. }
  8073. SyntheticEvent.augmentClass(SyntheticCompositionEvent, CompositionEventInterface);
  8074. module.exports = SyntheticCompositionEvent;
  8075. /***/ },
  8076. /* 77 */
  8077. /***/ function(module, exports, __webpack_require__) {
  8078. /* WEBPACK VAR INJECTION */(function(process) {/**
  8079. * Copyright 2013-2015, Facebook, Inc.
  8080. * All rights reserved.
  8081. *
  8082. * This source code is licensed under the BSD-style license found in the
  8083. * LICENSE file in the root directory of this source tree. An additional grant
  8084. * of patent rights can be found in the PATENTS file in the same directory.
  8085. *
  8086. * @providesModule SyntheticEvent
  8087. * @typechecks static-only
  8088. */
  8089. 'use strict';
  8090. var PooledClass = __webpack_require__(56);
  8091. var assign = __webpack_require__(39);
  8092. var emptyFunction = __webpack_require__(15);
  8093. var warning = __webpack_require__(25);
  8094. /**
  8095. * @interface Event
  8096. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  8097. */
  8098. var EventInterface = {
  8099. type: null,
  8100. target: null,
  8101. // currentTarget is set when dispatching; no use in copying it here
  8102. currentTarget: emptyFunction.thatReturnsNull,
  8103. eventPhase: null,
  8104. bubbles: null,
  8105. cancelable: null,
  8106. timeStamp: function (event) {
  8107. return event.timeStamp || Date.now();
  8108. },
  8109. defaultPrevented: null,
  8110. isTrusted: null
  8111. };
  8112. /**
  8113. * Synthetic events are dispatched by event plugins, typically in response to a
  8114. * top-level event delegation handler.
  8115. *
  8116. * These systems should generally use pooling to reduce the frequency of garbage
  8117. * collection. The system should check `isPersistent` to determine whether the
  8118. * event should be released into the pool after being dispatched. Users that
  8119. * need a persisted event should invoke `persist`.
  8120. *
  8121. * Synthetic events (and subclasses) implement the DOM Level 3 Events API by
  8122. * normalizing browser quirks. Subclasses do not necessarily have to implement a
  8123. * DOM interface; custom application-specific events can also subclass this.
  8124. *
  8125. * @param {object} dispatchConfig Configuration used to dispatch this event.
  8126. * @param {string} dispatchMarker Marker identifying the event target.
  8127. * @param {object} nativeEvent Native browser event.
  8128. */
  8129. function SyntheticEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  8130. this.dispatchConfig = dispatchConfig;
  8131. this.dispatchMarker = dispatchMarker;
  8132. this.nativeEvent = nativeEvent;
  8133. var Interface = this.constructor.Interface;
  8134. for (var propName in Interface) {
  8135. if (!Interface.hasOwnProperty(propName)) {
  8136. continue;
  8137. }
  8138. var normalize = Interface[propName];
  8139. if (normalize) {
  8140. this[propName] = normalize(nativeEvent);
  8141. } else {
  8142. if (propName === 'target') {
  8143. this.target = nativeEventTarget;
  8144. } else {
  8145. this[propName] = nativeEvent[propName];
  8146. }
  8147. }
  8148. }
  8149. var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
  8150. if (defaultPrevented) {
  8151. this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
  8152. } else {
  8153. this.isDefaultPrevented = emptyFunction.thatReturnsFalse;
  8154. }
  8155. this.isPropagationStopped = emptyFunction.thatReturnsFalse;
  8156. }
  8157. assign(SyntheticEvent.prototype, {
  8158. preventDefault: function () {
  8159. this.defaultPrevented = true;
  8160. var event = this.nativeEvent;
  8161. if (process.env.NODE_ENV !== 'production') {
  8162. process.env.NODE_ENV !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `preventDefault` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined;
  8163. }
  8164. if (!event) {
  8165. return;
  8166. }
  8167. if (event.preventDefault) {
  8168. event.preventDefault();
  8169. } else {
  8170. event.returnValue = false;
  8171. }
  8172. this.isDefaultPrevented = emptyFunction.thatReturnsTrue;
  8173. },
  8174. stopPropagation: function () {
  8175. var event = this.nativeEvent;
  8176. if (process.env.NODE_ENV !== 'production') {
  8177. process.env.NODE_ENV !== 'production' ? warning(event, 'This synthetic event is reused for performance reasons. If you\'re ' + 'seeing this, you\'re calling `stopPropagation` on a ' + 'released/nullified synthetic event. This is a no-op. See ' + 'https://fb.me/react-event-pooling for more information.') : undefined;
  8178. }
  8179. if (!event) {
  8180. return;
  8181. }
  8182. if (event.stopPropagation) {
  8183. event.stopPropagation();
  8184. } else {
  8185. event.cancelBubble = true;
  8186. }
  8187. this.isPropagationStopped = emptyFunction.thatReturnsTrue;
  8188. },
  8189. /**
  8190. * We release all dispatched `SyntheticEvent`s after each event loop, adding
  8191. * them back into the pool. This allows a way to hold onto a reference that
  8192. * won't be added back into the pool.
  8193. */
  8194. persist: function () {
  8195. this.isPersistent = emptyFunction.thatReturnsTrue;
  8196. },
  8197. /**
  8198. * Checks if this event should be released back into the pool.
  8199. *
  8200. * @return {boolean} True if this should not be released, false otherwise.
  8201. */
  8202. isPersistent: emptyFunction.thatReturnsFalse,
  8203. /**
  8204. * `PooledClass` looks for `destructor` on each instance it releases.
  8205. */
  8206. destructor: function () {
  8207. var Interface = this.constructor.Interface;
  8208. for (var propName in Interface) {
  8209. this[propName] = null;
  8210. }
  8211. this.dispatchConfig = null;
  8212. this.dispatchMarker = null;
  8213. this.nativeEvent = null;
  8214. }
  8215. });
  8216. SyntheticEvent.Interface = EventInterface;
  8217. /**
  8218. * Helper to reduce boilerplate when creating subclasses.
  8219. *
  8220. * @param {function} Class
  8221. * @param {?object} Interface
  8222. */
  8223. SyntheticEvent.augmentClass = function (Class, Interface) {
  8224. var Super = this;
  8225. var prototype = Object.create(Super.prototype);
  8226. assign(prototype, Class.prototype);
  8227. Class.prototype = prototype;
  8228. Class.prototype.constructor = Class;
  8229. Class.Interface = assign({}, Super.Interface, Interface);
  8230. Class.augmentClass = Super.augmentClass;
  8231. PooledClass.addPoolingTo(Class, PooledClass.fourArgumentPooler);
  8232. };
  8233. PooledClass.addPoolingTo(SyntheticEvent, PooledClass.fourArgumentPooler);
  8234. module.exports = SyntheticEvent;
  8235. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  8236. /***/ },
  8237. /* 78 */
  8238. /***/ function(module, exports, __webpack_require__) {
  8239. /**
  8240. * Copyright 2013-2015, Facebook, Inc.
  8241. * All rights reserved.
  8242. *
  8243. * This source code is licensed under the BSD-style license found in the
  8244. * LICENSE file in the root directory of this source tree. An additional grant
  8245. * of patent rights can be found in the PATENTS file in the same directory.
  8246. *
  8247. * @providesModule SyntheticInputEvent
  8248. * @typechecks static-only
  8249. */
  8250. 'use strict';
  8251. var SyntheticEvent = __webpack_require__(77);
  8252. /**
  8253. * @interface Event
  8254. * @see http://www.w3.org/TR/2013/WD-DOM-Level-3-Events-20131105
  8255. * /#events-inputevents
  8256. */
  8257. var InputEventInterface = {
  8258. data: null
  8259. };
  8260. /**
  8261. * @param {object} dispatchConfig Configuration used to dispatch this event.
  8262. * @param {string} dispatchMarker Marker identifying the event target.
  8263. * @param {object} nativeEvent Native browser event.
  8264. * @extends {SyntheticUIEvent}
  8265. */
  8266. function SyntheticInputEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  8267. SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
  8268. }
  8269. SyntheticEvent.augmentClass(SyntheticInputEvent, InputEventInterface);
  8270. module.exports = SyntheticInputEvent;
  8271. /***/ },
  8272. /* 79 */
  8273. /***/ function(module, exports) {
  8274. /**
  8275. * Copyright 2013-2015, Facebook, Inc.
  8276. * All rights reserved.
  8277. *
  8278. * This source code is licensed under the BSD-style license found in the
  8279. * LICENSE file in the root directory of this source tree. An additional grant
  8280. * of patent rights can be found in the PATENTS file in the same directory.
  8281. *
  8282. * @providesModule keyOf
  8283. */
  8284. /**
  8285. * Allows extraction of a minified key. Let's the build system minify keys
  8286. * without losing the ability to dynamically use key strings as values
  8287. * themselves. Pass in an object with a single key/val pair and it will return
  8288. * you the string key of that single record. Suppose you want to grab the
  8289. * value for a key 'className' inside of an object. Key/val minification may
  8290. * have aliased that key to be 'xa12'. keyOf({className: null}) will return
  8291. * 'xa12' in that case. Resolve keys you want to use once at startup time, then
  8292. * reuse those resolutions.
  8293. */
  8294. "use strict";
  8295. var keyOf = function (oneKeyObj) {
  8296. var key;
  8297. for (key in oneKeyObj) {
  8298. if (!oneKeyObj.hasOwnProperty(key)) {
  8299. continue;
  8300. }
  8301. return key;
  8302. }
  8303. return null;
  8304. };
  8305. module.exports = keyOf;
  8306. /***/ },
  8307. /* 80 */
  8308. /***/ function(module, exports, __webpack_require__) {
  8309. /**
  8310. * Copyright 2013-2015, Facebook, Inc.
  8311. * All rights reserved.
  8312. *
  8313. * This source code is licensed under the BSD-style license found in the
  8314. * LICENSE file in the root directory of this source tree. An additional grant
  8315. * of patent rights can be found in the PATENTS file in the same directory.
  8316. *
  8317. * @providesModule ChangeEventPlugin
  8318. */
  8319. 'use strict';
  8320. var EventConstants = __webpack_require__(30);
  8321. var EventPluginHub = __webpack_require__(31);
  8322. var EventPropagators = __webpack_require__(73);
  8323. var ExecutionEnvironment = __webpack_require__(9);
  8324. var ReactUpdates = __webpack_require__(54);
  8325. var SyntheticEvent = __webpack_require__(77);
  8326. var getEventTarget = __webpack_require__(81);
  8327. var isEventSupported = __webpack_require__(40);
  8328. var isTextInputElement = __webpack_require__(82);
  8329. var keyOf = __webpack_require__(79);
  8330. var topLevelTypes = EventConstants.topLevelTypes;
  8331. var eventTypes = {
  8332. change: {
  8333. phasedRegistrationNames: {
  8334. bubbled: keyOf({ onChange: null }),
  8335. captured: keyOf({ onChangeCapture: null })
  8336. },
  8337. dependencies: [topLevelTypes.topBlur, topLevelTypes.topChange, topLevelTypes.topClick, topLevelTypes.topFocus, topLevelTypes.topInput, topLevelTypes.topKeyDown, topLevelTypes.topKeyUp, topLevelTypes.topSelectionChange]
  8338. }
  8339. };
  8340. /**
  8341. * For IE shims
  8342. */
  8343. var activeElement = null;
  8344. var activeElementID = null;
  8345. var activeElementValue = null;
  8346. var activeElementValueProp = null;
  8347. /**
  8348. * SECTION: handle `change` event
  8349. */
  8350. function shouldUseChangeEvent(elem) {
  8351. var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
  8352. return nodeName === 'select' || nodeName === 'input' && elem.type === 'file';
  8353. }
  8354. var doesChangeEventBubble = false;
  8355. if (ExecutionEnvironment.canUseDOM) {
  8356. // See `handleChange` comment below
  8357. doesChangeEventBubble = isEventSupported('change') && (!('documentMode' in document) || document.documentMode > 8);
  8358. }
  8359. function manualDispatchChangeEvent(nativeEvent) {
  8360. var event = SyntheticEvent.getPooled(eventTypes.change, activeElementID, nativeEvent, getEventTarget(nativeEvent));
  8361. EventPropagators.accumulateTwoPhaseDispatches(event);
  8362. // If change and propertychange bubbled, we'd just bind to it like all the
  8363. // other events and have it go through ReactBrowserEventEmitter. Since it
  8364. // doesn't, we manually listen for the events and so we have to enqueue and
  8365. // process the abstract event manually.
  8366. //
  8367. // Batching is necessary here in order to ensure that all event handlers run
  8368. // before the next rerender (including event handlers attached to ancestor
  8369. // elements instead of directly on the input). Without this, controlled
  8370. // components don't work properly in conjunction with event bubbling because
  8371. // the component is rerendered and the value reverted before all the event
  8372. // handlers can run. See https://github.com/facebook/react/issues/708.
  8373. ReactUpdates.batchedUpdates(runEventInBatch, event);
  8374. }
  8375. function runEventInBatch(event) {
  8376. EventPluginHub.enqueueEvents(event);
  8377. EventPluginHub.processEventQueue(false);
  8378. }
  8379. function startWatchingForChangeEventIE8(target, targetID) {
  8380. activeElement = target;
  8381. activeElementID = targetID;
  8382. activeElement.attachEvent('onchange', manualDispatchChangeEvent);
  8383. }
  8384. function stopWatchingForChangeEventIE8() {
  8385. if (!activeElement) {
  8386. return;
  8387. }
  8388. activeElement.detachEvent('onchange', manualDispatchChangeEvent);
  8389. activeElement = null;
  8390. activeElementID = null;
  8391. }
  8392. function getTargetIDForChangeEvent(topLevelType, topLevelTarget, topLevelTargetID) {
  8393. if (topLevelType === topLevelTypes.topChange) {
  8394. return topLevelTargetID;
  8395. }
  8396. }
  8397. function handleEventsForChangeEventIE8(topLevelType, topLevelTarget, topLevelTargetID) {
  8398. if (topLevelType === topLevelTypes.topFocus) {
  8399. // stopWatching() should be a noop here but we call it just in case we
  8400. // missed a blur event somehow.
  8401. stopWatchingForChangeEventIE8();
  8402. startWatchingForChangeEventIE8(topLevelTarget, topLevelTargetID);
  8403. } else if (topLevelType === topLevelTypes.topBlur) {
  8404. stopWatchingForChangeEventIE8();
  8405. }
  8406. }
  8407. /**
  8408. * SECTION: handle `input` event
  8409. */
  8410. var isInputEventSupported = false;
  8411. if (ExecutionEnvironment.canUseDOM) {
  8412. // IE9 claims to support the input event but fails to trigger it when
  8413. // deleting text, so we ignore its input events
  8414. isInputEventSupported = isEventSupported('input') && (!('documentMode' in document) || document.documentMode > 9);
  8415. }
  8416. /**
  8417. * (For old IE.) Replacement getter/setter for the `value` property that gets
  8418. * set on the active element.
  8419. */
  8420. var newValueProp = {
  8421. get: function () {
  8422. return activeElementValueProp.get.call(this);
  8423. },
  8424. set: function (val) {
  8425. // Cast to a string so we can do equality checks.
  8426. activeElementValue = '' + val;
  8427. activeElementValueProp.set.call(this, val);
  8428. }
  8429. };
  8430. /**
  8431. * (For old IE.) Starts tracking propertychange events on the passed-in element
  8432. * and override the value property so that we can distinguish user events from
  8433. * value changes in JS.
  8434. */
  8435. function startWatchingForValueChange(target, targetID) {
  8436. activeElement = target;
  8437. activeElementID = targetID;
  8438. activeElementValue = target.value;
  8439. activeElementValueProp = Object.getOwnPropertyDescriptor(target.constructor.prototype, 'value');
  8440. // Not guarded in a canDefineProperty check: IE8 supports defineProperty only
  8441. // on DOM elements
  8442. Object.defineProperty(activeElement, 'value', newValueProp);
  8443. activeElement.attachEvent('onpropertychange', handlePropertyChange);
  8444. }
  8445. /**
  8446. * (For old IE.) Removes the event listeners from the currently-tracked element,
  8447. * if any exists.
  8448. */
  8449. function stopWatchingForValueChange() {
  8450. if (!activeElement) {
  8451. return;
  8452. }
  8453. // delete restores the original property definition
  8454. delete activeElement.value;
  8455. activeElement.detachEvent('onpropertychange', handlePropertyChange);
  8456. activeElement = null;
  8457. activeElementID = null;
  8458. activeElementValue = null;
  8459. activeElementValueProp = null;
  8460. }
  8461. /**
  8462. * (For old IE.) Handles a propertychange event, sending a `change` event if
  8463. * the value of the active element has changed.
  8464. */
  8465. function handlePropertyChange(nativeEvent) {
  8466. if (nativeEvent.propertyName !== 'value') {
  8467. return;
  8468. }
  8469. var value = nativeEvent.srcElement.value;
  8470. if (value === activeElementValue) {
  8471. return;
  8472. }
  8473. activeElementValue = value;
  8474. manualDispatchChangeEvent(nativeEvent);
  8475. }
  8476. /**
  8477. * If a `change` event should be fired, returns the target's ID.
  8478. */
  8479. function getTargetIDForInputEvent(topLevelType, topLevelTarget, topLevelTargetID) {
  8480. if (topLevelType === topLevelTypes.topInput) {
  8481. // In modern browsers (i.e., not IE8 or IE9), the input event is exactly
  8482. // what we want so fall through here and trigger an abstract event
  8483. return topLevelTargetID;
  8484. }
  8485. }
  8486. // For IE8 and IE9.
  8487. function handleEventsForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
  8488. if (topLevelType === topLevelTypes.topFocus) {
  8489. // In IE8, we can capture almost all .value changes by adding a
  8490. // propertychange handler and looking for events with propertyName
  8491. // equal to 'value'
  8492. // In IE9, propertychange fires for most input events but is buggy and
  8493. // doesn't fire when text is deleted, but conveniently, selectionchange
  8494. // appears to fire in all of the remaining cases so we catch those and
  8495. // forward the event if the value has changed
  8496. // In either case, we don't want to call the event handler if the value
  8497. // is changed from JS so we redefine a setter for `.value` that updates
  8498. // our activeElementValue variable, allowing us to ignore those changes
  8499. //
  8500. // stopWatching() should be a noop here but we call it just in case we
  8501. // missed a blur event somehow.
  8502. stopWatchingForValueChange();
  8503. startWatchingForValueChange(topLevelTarget, topLevelTargetID);
  8504. } else if (topLevelType === topLevelTypes.topBlur) {
  8505. stopWatchingForValueChange();
  8506. }
  8507. }
  8508. // For IE8 and IE9.
  8509. function getTargetIDForInputEventIE(topLevelType, topLevelTarget, topLevelTargetID) {
  8510. if (topLevelType === topLevelTypes.topSelectionChange || topLevelType === topLevelTypes.topKeyUp || topLevelType === topLevelTypes.topKeyDown) {
  8511. // On the selectionchange event, the target is just document which isn't
  8512. // helpful for us so just check activeElement instead.
  8513. //
  8514. // 99% of the time, keydown and keyup aren't necessary. IE8 fails to fire
  8515. // propertychange on the first input event after setting `value` from a
  8516. // script and fires only keydown, keypress, keyup. Catching keyup usually
  8517. // gets it and catching keydown lets us fire an event for the first
  8518. // keystroke if user does a key repeat (it'll be a little delayed: right
  8519. // before the second keystroke). Other input methods (e.g., paste) seem to
  8520. // fire selectionchange normally.
  8521. if (activeElement && activeElement.value !== activeElementValue) {
  8522. activeElementValue = activeElement.value;
  8523. return activeElementID;
  8524. }
  8525. }
  8526. }
  8527. /**
  8528. * SECTION: handle `click` event
  8529. */
  8530. function shouldUseClickEvent(elem) {
  8531. // Use the `click` event to detect changes to checkbox and radio inputs.
  8532. // This approach works across all browsers, whereas `change` does not fire
  8533. // until `blur` in IE8.
  8534. return elem.nodeName && elem.nodeName.toLowerCase() === 'input' && (elem.type === 'checkbox' || elem.type === 'radio');
  8535. }
  8536. function getTargetIDForClickEvent(topLevelType, topLevelTarget, topLevelTargetID) {
  8537. if (topLevelType === topLevelTypes.topClick) {
  8538. return topLevelTargetID;
  8539. }
  8540. }
  8541. /**
  8542. * This plugin creates an `onChange` event that normalizes change events
  8543. * across form elements. This event fires at a time when it's possible to
  8544. * change the element's value without seeing a flicker.
  8545. *
  8546. * Supported elements are:
  8547. * - input (see `isTextInputElement`)
  8548. * - textarea
  8549. * - select
  8550. */
  8551. var ChangeEventPlugin = {
  8552. eventTypes: eventTypes,
  8553. /**
  8554. * @param {string} topLevelType Record from `EventConstants`.
  8555. * @param {DOMEventTarget} topLevelTarget The listening component root node.
  8556. * @param {string} topLevelTargetID ID of `topLevelTarget`.
  8557. * @param {object} nativeEvent Native browser event.
  8558. * @return {*} An accumulation of synthetic events.
  8559. * @see {EventPluginHub.extractEvents}
  8560. */
  8561. extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
  8562. var getTargetIDFunc, handleEventFunc;
  8563. if (shouldUseChangeEvent(topLevelTarget)) {
  8564. if (doesChangeEventBubble) {
  8565. getTargetIDFunc = getTargetIDForChangeEvent;
  8566. } else {
  8567. handleEventFunc = handleEventsForChangeEventIE8;
  8568. }
  8569. } else if (isTextInputElement(topLevelTarget)) {
  8570. if (isInputEventSupported) {
  8571. getTargetIDFunc = getTargetIDForInputEvent;
  8572. } else {
  8573. getTargetIDFunc = getTargetIDForInputEventIE;
  8574. handleEventFunc = handleEventsForInputEventIE;
  8575. }
  8576. } else if (shouldUseClickEvent(topLevelTarget)) {
  8577. getTargetIDFunc = getTargetIDForClickEvent;
  8578. }
  8579. if (getTargetIDFunc) {
  8580. var targetID = getTargetIDFunc(topLevelType, topLevelTarget, topLevelTargetID);
  8581. if (targetID) {
  8582. var event = SyntheticEvent.getPooled(eventTypes.change, targetID, nativeEvent, nativeEventTarget);
  8583. event.type = 'change';
  8584. EventPropagators.accumulateTwoPhaseDispatches(event);
  8585. return event;
  8586. }
  8587. }
  8588. if (handleEventFunc) {
  8589. handleEventFunc(topLevelType, topLevelTarget, topLevelTargetID);
  8590. }
  8591. }
  8592. };
  8593. module.exports = ChangeEventPlugin;
  8594. /***/ },
  8595. /* 81 */
  8596. /***/ function(module, exports) {
  8597. /**
  8598. * Copyright 2013-2015, Facebook, Inc.
  8599. * All rights reserved.
  8600. *
  8601. * This source code is licensed under the BSD-style license found in the
  8602. * LICENSE file in the root directory of this source tree. An additional grant
  8603. * of patent rights can be found in the PATENTS file in the same directory.
  8604. *
  8605. * @providesModule getEventTarget
  8606. * @typechecks static-only
  8607. */
  8608. 'use strict';
  8609. /**
  8610. * Gets the target node from a native browser event by accounting for
  8611. * inconsistencies in browser DOM APIs.
  8612. *
  8613. * @param {object} nativeEvent Native browser event.
  8614. * @return {DOMEventTarget} Target node.
  8615. */
  8616. function getEventTarget(nativeEvent) {
  8617. var target = nativeEvent.target || nativeEvent.srcElement || window;
  8618. // Safari may fire events on text nodes (Node.TEXT_NODE is 3).
  8619. // @see http://www.quirksmode.org/js/events_properties.html
  8620. return target.nodeType === 3 ? target.parentNode : target;
  8621. }
  8622. module.exports = getEventTarget;
  8623. /***/ },
  8624. /* 82 */
  8625. /***/ function(module, exports) {
  8626. /**
  8627. * Copyright 2013-2015, Facebook, Inc.
  8628. * All rights reserved.
  8629. *
  8630. * This source code is licensed under the BSD-style license found in the
  8631. * LICENSE file in the root directory of this source tree. An additional grant
  8632. * of patent rights can be found in the PATENTS file in the same directory.
  8633. *
  8634. * @providesModule isTextInputElement
  8635. */
  8636. 'use strict';
  8637. /**
  8638. * @see http://www.whatwg.org/specs/web-apps/current-work/multipage/the-input-element.html#input-type-attr-summary
  8639. */
  8640. var supportedInputTypes = {
  8641. 'color': true,
  8642. 'date': true,
  8643. 'datetime': true,
  8644. 'datetime-local': true,
  8645. 'email': true,
  8646. 'month': true,
  8647. 'number': true,
  8648. 'password': true,
  8649. 'range': true,
  8650. 'search': true,
  8651. 'tel': true,
  8652. 'text': true,
  8653. 'time': true,
  8654. 'url': true,
  8655. 'week': true
  8656. };
  8657. function isTextInputElement(elem) {
  8658. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  8659. return nodeName && (nodeName === 'input' && supportedInputTypes[elem.type] || nodeName === 'textarea');
  8660. }
  8661. module.exports = isTextInputElement;
  8662. /***/ },
  8663. /* 83 */
  8664. /***/ function(module, exports) {
  8665. /**
  8666. * Copyright 2013-2015, Facebook, Inc.
  8667. * All rights reserved.
  8668. *
  8669. * This source code is licensed under the BSD-style license found in the
  8670. * LICENSE file in the root directory of this source tree. An additional grant
  8671. * of patent rights can be found in the PATENTS file in the same directory.
  8672. *
  8673. * @providesModule ClientReactRootIndex
  8674. * @typechecks
  8675. */
  8676. 'use strict';
  8677. var nextReactRootIndex = 0;
  8678. var ClientReactRootIndex = {
  8679. createReactRootIndex: function () {
  8680. return nextReactRootIndex++;
  8681. }
  8682. };
  8683. module.exports = ClientReactRootIndex;
  8684. /***/ },
  8685. /* 84 */
  8686. /***/ function(module, exports, __webpack_require__) {
  8687. /**
  8688. * Copyright 2013-2015, Facebook, Inc.
  8689. * All rights reserved.
  8690. *
  8691. * This source code is licensed under the BSD-style license found in the
  8692. * LICENSE file in the root directory of this source tree. An additional grant
  8693. * of patent rights can be found in the PATENTS file in the same directory.
  8694. *
  8695. * @providesModule DefaultEventPluginOrder
  8696. */
  8697. 'use strict';
  8698. var keyOf = __webpack_require__(79);
  8699. /**
  8700. * Module that is injectable into `EventPluginHub`, that specifies a
  8701. * deterministic ordering of `EventPlugin`s. A convenient way to reason about
  8702. * plugins, without having to package every one of them. This is better than
  8703. * having plugins be ordered in the same order that they are injected because
  8704. * that ordering would be influenced by the packaging order.
  8705. * `ResponderEventPlugin` must occur before `SimpleEventPlugin` so that
  8706. * preventing default on events is convenient in `SimpleEventPlugin` handlers.
  8707. */
  8708. var DefaultEventPluginOrder = [keyOf({ ResponderEventPlugin: null }), keyOf({ SimpleEventPlugin: null }), keyOf({ TapEventPlugin: null }), keyOf({ EnterLeaveEventPlugin: null }), keyOf({ ChangeEventPlugin: null }), keyOf({ SelectEventPlugin: null }), keyOf({ BeforeInputEventPlugin: null })];
  8709. module.exports = DefaultEventPluginOrder;
  8710. /***/ },
  8711. /* 85 */
  8712. /***/ function(module, exports, __webpack_require__) {
  8713. /**
  8714. * Copyright 2013-2015, Facebook, Inc.
  8715. * All rights reserved.
  8716. *
  8717. * This source code is licensed under the BSD-style license found in the
  8718. * LICENSE file in the root directory of this source tree. An additional grant
  8719. * of patent rights can be found in the PATENTS file in the same directory.
  8720. *
  8721. * @providesModule EnterLeaveEventPlugin
  8722. * @typechecks static-only
  8723. */
  8724. 'use strict';
  8725. var EventConstants = __webpack_require__(30);
  8726. var EventPropagators = __webpack_require__(73);
  8727. var SyntheticMouseEvent = __webpack_require__(86);
  8728. var ReactMount = __webpack_require__(28);
  8729. var keyOf = __webpack_require__(79);
  8730. var topLevelTypes = EventConstants.topLevelTypes;
  8731. var getFirstReactDOM = ReactMount.getFirstReactDOM;
  8732. var eventTypes = {
  8733. mouseEnter: {
  8734. registrationName: keyOf({ onMouseEnter: null }),
  8735. dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
  8736. },
  8737. mouseLeave: {
  8738. registrationName: keyOf({ onMouseLeave: null }),
  8739. dependencies: [topLevelTypes.topMouseOut, topLevelTypes.topMouseOver]
  8740. }
  8741. };
  8742. var extractedEvents = [null, null];
  8743. var EnterLeaveEventPlugin = {
  8744. eventTypes: eventTypes,
  8745. /**
  8746. * For almost every interaction we care about, there will be both a top-level
  8747. * `mouseover` and `mouseout` event that occurs. Only use `mouseout` so that
  8748. * we do not extract duplicate events. However, moving the mouse into the
  8749. * browser from outside will not fire a `mouseout` event. In this case, we use
  8750. * the `mouseover` top-level event.
  8751. *
  8752. * @param {string} topLevelType Record from `EventConstants`.
  8753. * @param {DOMEventTarget} topLevelTarget The listening component root node.
  8754. * @param {string} topLevelTargetID ID of `topLevelTarget`.
  8755. * @param {object} nativeEvent Native browser event.
  8756. * @return {*} An accumulation of synthetic events.
  8757. * @see {EventPluginHub.extractEvents}
  8758. */
  8759. extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
  8760. if (topLevelType === topLevelTypes.topMouseOver && (nativeEvent.relatedTarget || nativeEvent.fromElement)) {
  8761. return null;
  8762. }
  8763. if (topLevelType !== topLevelTypes.topMouseOut && topLevelType !== topLevelTypes.topMouseOver) {
  8764. // Must not be a mouse in or mouse out - ignoring.
  8765. return null;
  8766. }
  8767. var win;
  8768. if (topLevelTarget.window === topLevelTarget) {
  8769. // `topLevelTarget` is probably a window object.
  8770. win = topLevelTarget;
  8771. } else {
  8772. // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
  8773. var doc = topLevelTarget.ownerDocument;
  8774. if (doc) {
  8775. win = doc.defaultView || doc.parentWindow;
  8776. } else {
  8777. win = window;
  8778. }
  8779. }
  8780. var from;
  8781. var to;
  8782. var fromID = '';
  8783. var toID = '';
  8784. if (topLevelType === topLevelTypes.topMouseOut) {
  8785. from = topLevelTarget;
  8786. fromID = topLevelTargetID;
  8787. to = getFirstReactDOM(nativeEvent.relatedTarget || nativeEvent.toElement);
  8788. if (to) {
  8789. toID = ReactMount.getID(to);
  8790. } else {
  8791. to = win;
  8792. }
  8793. to = to || win;
  8794. } else {
  8795. from = win;
  8796. to = topLevelTarget;
  8797. toID = topLevelTargetID;
  8798. }
  8799. if (from === to) {
  8800. // Nothing pertains to our managed components.
  8801. return null;
  8802. }
  8803. var leave = SyntheticMouseEvent.getPooled(eventTypes.mouseLeave, fromID, nativeEvent, nativeEventTarget);
  8804. leave.type = 'mouseleave';
  8805. leave.target = from;
  8806. leave.relatedTarget = to;
  8807. var enter = SyntheticMouseEvent.getPooled(eventTypes.mouseEnter, toID, nativeEvent, nativeEventTarget);
  8808. enter.type = 'mouseenter';
  8809. enter.target = to;
  8810. enter.relatedTarget = from;
  8811. EventPropagators.accumulateEnterLeaveDispatches(leave, enter, fromID, toID);
  8812. extractedEvents[0] = leave;
  8813. extractedEvents[1] = enter;
  8814. return extractedEvents;
  8815. }
  8816. };
  8817. module.exports = EnterLeaveEventPlugin;
  8818. /***/ },
  8819. /* 86 */
  8820. /***/ function(module, exports, __webpack_require__) {
  8821. /**
  8822. * Copyright 2013-2015, Facebook, Inc.
  8823. * All rights reserved.
  8824. *
  8825. * This source code is licensed under the BSD-style license found in the
  8826. * LICENSE file in the root directory of this source tree. An additional grant
  8827. * of patent rights can be found in the PATENTS file in the same directory.
  8828. *
  8829. * @providesModule SyntheticMouseEvent
  8830. * @typechecks static-only
  8831. */
  8832. 'use strict';
  8833. var SyntheticUIEvent = __webpack_require__(87);
  8834. var ViewportMetrics = __webpack_require__(38);
  8835. var getEventModifierState = __webpack_require__(88);
  8836. /**
  8837. * @interface MouseEvent
  8838. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  8839. */
  8840. var MouseEventInterface = {
  8841. screenX: null,
  8842. screenY: null,
  8843. clientX: null,
  8844. clientY: null,
  8845. ctrlKey: null,
  8846. shiftKey: null,
  8847. altKey: null,
  8848. metaKey: null,
  8849. getModifierState: getEventModifierState,
  8850. button: function (event) {
  8851. // Webkit, Firefox, IE9+
  8852. // which: 1 2 3
  8853. // button: 0 1 2 (standard)
  8854. var button = event.button;
  8855. if ('which' in event) {
  8856. return button;
  8857. }
  8858. // IE<9
  8859. // which: undefined
  8860. // button: 0 0 0
  8861. // button: 1 4 2 (onmouseup)
  8862. return button === 2 ? 2 : button === 4 ? 1 : 0;
  8863. },
  8864. buttons: null,
  8865. relatedTarget: function (event) {
  8866. return event.relatedTarget || (event.fromElement === event.srcElement ? event.toElement : event.fromElement);
  8867. },
  8868. // "Proprietary" Interface.
  8869. pageX: function (event) {
  8870. return 'pageX' in event ? event.pageX : event.clientX + ViewportMetrics.currentScrollLeft;
  8871. },
  8872. pageY: function (event) {
  8873. return 'pageY' in event ? event.pageY : event.clientY + ViewportMetrics.currentScrollTop;
  8874. }
  8875. };
  8876. /**
  8877. * @param {object} dispatchConfig Configuration used to dispatch this event.
  8878. * @param {string} dispatchMarker Marker identifying the event target.
  8879. * @param {object} nativeEvent Native browser event.
  8880. * @extends {SyntheticUIEvent}
  8881. */
  8882. function SyntheticMouseEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  8883. SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
  8884. }
  8885. SyntheticUIEvent.augmentClass(SyntheticMouseEvent, MouseEventInterface);
  8886. module.exports = SyntheticMouseEvent;
  8887. /***/ },
  8888. /* 87 */
  8889. /***/ function(module, exports, __webpack_require__) {
  8890. /**
  8891. * Copyright 2013-2015, Facebook, Inc.
  8892. * All rights reserved.
  8893. *
  8894. * This source code is licensed under the BSD-style license found in the
  8895. * LICENSE file in the root directory of this source tree. An additional grant
  8896. * of patent rights can be found in the PATENTS file in the same directory.
  8897. *
  8898. * @providesModule SyntheticUIEvent
  8899. * @typechecks static-only
  8900. */
  8901. 'use strict';
  8902. var SyntheticEvent = __webpack_require__(77);
  8903. var getEventTarget = __webpack_require__(81);
  8904. /**
  8905. * @interface UIEvent
  8906. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  8907. */
  8908. var UIEventInterface = {
  8909. view: function (event) {
  8910. if (event.view) {
  8911. return event.view;
  8912. }
  8913. var target = getEventTarget(event);
  8914. if (target != null && target.window === target) {
  8915. // target is a window object
  8916. return target;
  8917. }
  8918. var doc = target.ownerDocument;
  8919. // TODO: Figure out why `ownerDocument` is sometimes undefined in IE8.
  8920. if (doc) {
  8921. return doc.defaultView || doc.parentWindow;
  8922. } else {
  8923. return window;
  8924. }
  8925. },
  8926. detail: function (event) {
  8927. return event.detail || 0;
  8928. }
  8929. };
  8930. /**
  8931. * @param {object} dispatchConfig Configuration used to dispatch this event.
  8932. * @param {string} dispatchMarker Marker identifying the event target.
  8933. * @param {object} nativeEvent Native browser event.
  8934. * @extends {SyntheticEvent}
  8935. */
  8936. function SyntheticUIEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  8937. SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
  8938. }
  8939. SyntheticEvent.augmentClass(SyntheticUIEvent, UIEventInterface);
  8940. module.exports = SyntheticUIEvent;
  8941. /***/ },
  8942. /* 88 */
  8943. /***/ function(module, exports) {
  8944. /**
  8945. * Copyright 2013-2015, Facebook, Inc.
  8946. * All rights reserved.
  8947. *
  8948. * This source code is licensed under the BSD-style license found in the
  8949. * LICENSE file in the root directory of this source tree. An additional grant
  8950. * of patent rights can be found in the PATENTS file in the same directory.
  8951. *
  8952. * @providesModule getEventModifierState
  8953. * @typechecks static-only
  8954. */
  8955. 'use strict';
  8956. /**
  8957. * Translation from modifier key to the associated property in the event.
  8958. * @see http://www.w3.org/TR/DOM-Level-3-Events/#keys-Modifiers
  8959. */
  8960. var modifierKeyToProp = {
  8961. 'Alt': 'altKey',
  8962. 'Control': 'ctrlKey',
  8963. 'Meta': 'metaKey',
  8964. 'Shift': 'shiftKey'
  8965. };
  8966. // IE8 does not implement getModifierState so we simply map it to the only
  8967. // modifier keys exposed by the event itself, does not support Lock-keys.
  8968. // Currently, all major browsers except Chrome seems to support Lock-keys.
  8969. function modifierStateGetter(keyArg) {
  8970. var syntheticEvent = this;
  8971. var nativeEvent = syntheticEvent.nativeEvent;
  8972. if (nativeEvent.getModifierState) {
  8973. return nativeEvent.getModifierState(keyArg);
  8974. }
  8975. var keyProp = modifierKeyToProp[keyArg];
  8976. return keyProp ? !!nativeEvent[keyProp] : false;
  8977. }
  8978. function getEventModifierState(nativeEvent) {
  8979. return modifierStateGetter;
  8980. }
  8981. module.exports = getEventModifierState;
  8982. /***/ },
  8983. /* 89 */
  8984. /***/ function(module, exports, __webpack_require__) {
  8985. /**
  8986. * Copyright 2013-2015, Facebook, Inc.
  8987. * All rights reserved.
  8988. *
  8989. * This source code is licensed under the BSD-style license found in the
  8990. * LICENSE file in the root directory of this source tree. An additional grant
  8991. * of patent rights can be found in the PATENTS file in the same directory.
  8992. *
  8993. * @providesModule HTMLDOMPropertyConfig
  8994. */
  8995. 'use strict';
  8996. var DOMProperty = __webpack_require__(23);
  8997. var ExecutionEnvironment = __webpack_require__(9);
  8998. var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
  8999. var MUST_USE_PROPERTY = DOMProperty.injection.MUST_USE_PROPERTY;
  9000. var HAS_BOOLEAN_VALUE = DOMProperty.injection.HAS_BOOLEAN_VALUE;
  9001. var HAS_SIDE_EFFECTS = DOMProperty.injection.HAS_SIDE_EFFECTS;
  9002. var HAS_NUMERIC_VALUE = DOMProperty.injection.HAS_NUMERIC_VALUE;
  9003. var HAS_POSITIVE_NUMERIC_VALUE = DOMProperty.injection.HAS_POSITIVE_NUMERIC_VALUE;
  9004. var HAS_OVERLOADED_BOOLEAN_VALUE = DOMProperty.injection.HAS_OVERLOADED_BOOLEAN_VALUE;
  9005. var hasSVG;
  9006. if (ExecutionEnvironment.canUseDOM) {
  9007. var implementation = document.implementation;
  9008. hasSVG = implementation && implementation.hasFeature && implementation.hasFeature('http://www.w3.org/TR/SVG11/feature#BasicStructure', '1.1');
  9009. }
  9010. var HTMLDOMPropertyConfig = {
  9011. isCustomAttribute: RegExp.prototype.test.bind(/^(data|aria)-[a-z_][a-z\d_.\-]*$/),
  9012. Properties: {
  9013. /**
  9014. * Standard Properties
  9015. */
  9016. accept: null,
  9017. acceptCharset: null,
  9018. accessKey: null,
  9019. action: null,
  9020. allowFullScreen: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
  9021. allowTransparency: MUST_USE_ATTRIBUTE,
  9022. alt: null,
  9023. async: HAS_BOOLEAN_VALUE,
  9024. autoComplete: null,
  9025. // autoFocus is polyfilled/normalized by AutoFocusUtils
  9026. // autoFocus: HAS_BOOLEAN_VALUE,
  9027. autoPlay: HAS_BOOLEAN_VALUE,
  9028. capture: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
  9029. cellPadding: null,
  9030. cellSpacing: null,
  9031. charSet: MUST_USE_ATTRIBUTE,
  9032. challenge: MUST_USE_ATTRIBUTE,
  9033. checked: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
  9034. classID: MUST_USE_ATTRIBUTE,
  9035. // To set className on SVG elements, it's necessary to use .setAttribute;
  9036. // this works on HTML elements too in all browsers except IE8. Conveniently,
  9037. // IE8 doesn't support SVG and so we can simply use the attribute in
  9038. // browsers that support SVG and the property in browsers that don't,
  9039. // regardless of whether the element is HTML or SVG.
  9040. className: hasSVG ? MUST_USE_ATTRIBUTE : MUST_USE_PROPERTY,
  9041. cols: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
  9042. colSpan: null,
  9043. content: null,
  9044. contentEditable: null,
  9045. contextMenu: MUST_USE_ATTRIBUTE,
  9046. controls: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
  9047. coords: null,
  9048. crossOrigin: null,
  9049. data: null, // For `<object />` acts as `src`.
  9050. dateTime: MUST_USE_ATTRIBUTE,
  9051. 'default': HAS_BOOLEAN_VALUE,
  9052. defer: HAS_BOOLEAN_VALUE,
  9053. dir: null,
  9054. disabled: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
  9055. download: HAS_OVERLOADED_BOOLEAN_VALUE,
  9056. draggable: null,
  9057. encType: null,
  9058. form: MUST_USE_ATTRIBUTE,
  9059. formAction: MUST_USE_ATTRIBUTE,
  9060. formEncType: MUST_USE_ATTRIBUTE,
  9061. formMethod: MUST_USE_ATTRIBUTE,
  9062. formNoValidate: HAS_BOOLEAN_VALUE,
  9063. formTarget: MUST_USE_ATTRIBUTE,
  9064. frameBorder: MUST_USE_ATTRIBUTE,
  9065. headers: null,
  9066. height: MUST_USE_ATTRIBUTE,
  9067. hidden: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
  9068. high: null,
  9069. href: null,
  9070. hrefLang: null,
  9071. htmlFor: null,
  9072. httpEquiv: null,
  9073. icon: null,
  9074. id: MUST_USE_PROPERTY,
  9075. inputMode: MUST_USE_ATTRIBUTE,
  9076. integrity: null,
  9077. is: MUST_USE_ATTRIBUTE,
  9078. keyParams: MUST_USE_ATTRIBUTE,
  9079. keyType: MUST_USE_ATTRIBUTE,
  9080. kind: null,
  9081. label: null,
  9082. lang: null,
  9083. list: MUST_USE_ATTRIBUTE,
  9084. loop: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
  9085. low: null,
  9086. manifest: MUST_USE_ATTRIBUTE,
  9087. marginHeight: null,
  9088. marginWidth: null,
  9089. max: null,
  9090. maxLength: MUST_USE_ATTRIBUTE,
  9091. media: MUST_USE_ATTRIBUTE,
  9092. mediaGroup: null,
  9093. method: null,
  9094. min: null,
  9095. minLength: MUST_USE_ATTRIBUTE,
  9096. multiple: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
  9097. muted: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
  9098. name: null,
  9099. nonce: MUST_USE_ATTRIBUTE,
  9100. noValidate: HAS_BOOLEAN_VALUE,
  9101. open: HAS_BOOLEAN_VALUE,
  9102. optimum: null,
  9103. pattern: null,
  9104. placeholder: null,
  9105. poster: null,
  9106. preload: null,
  9107. radioGroup: null,
  9108. readOnly: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
  9109. rel: null,
  9110. required: HAS_BOOLEAN_VALUE,
  9111. reversed: HAS_BOOLEAN_VALUE,
  9112. role: MUST_USE_ATTRIBUTE,
  9113. rows: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
  9114. rowSpan: null,
  9115. sandbox: null,
  9116. scope: null,
  9117. scoped: HAS_BOOLEAN_VALUE,
  9118. scrolling: null,
  9119. seamless: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
  9120. selected: MUST_USE_PROPERTY | HAS_BOOLEAN_VALUE,
  9121. shape: null,
  9122. size: MUST_USE_ATTRIBUTE | HAS_POSITIVE_NUMERIC_VALUE,
  9123. sizes: MUST_USE_ATTRIBUTE,
  9124. span: HAS_POSITIVE_NUMERIC_VALUE,
  9125. spellCheck: null,
  9126. src: null,
  9127. srcDoc: MUST_USE_PROPERTY,
  9128. srcLang: null,
  9129. srcSet: MUST_USE_ATTRIBUTE,
  9130. start: HAS_NUMERIC_VALUE,
  9131. step: null,
  9132. style: null,
  9133. summary: null,
  9134. tabIndex: null,
  9135. target: null,
  9136. title: null,
  9137. type: null,
  9138. useMap: null,
  9139. value: MUST_USE_PROPERTY | HAS_SIDE_EFFECTS,
  9140. width: MUST_USE_ATTRIBUTE,
  9141. wmode: MUST_USE_ATTRIBUTE,
  9142. wrap: null,
  9143. /**
  9144. * RDFa Properties
  9145. */
  9146. about: MUST_USE_ATTRIBUTE,
  9147. datatype: MUST_USE_ATTRIBUTE,
  9148. inlist: MUST_USE_ATTRIBUTE,
  9149. prefix: MUST_USE_ATTRIBUTE,
  9150. // property is also supported for OpenGraph in meta tags.
  9151. property: MUST_USE_ATTRIBUTE,
  9152. resource: MUST_USE_ATTRIBUTE,
  9153. 'typeof': MUST_USE_ATTRIBUTE,
  9154. vocab: MUST_USE_ATTRIBUTE,
  9155. /**
  9156. * Non-standard Properties
  9157. */
  9158. // autoCapitalize and autoCorrect are supported in Mobile Safari for
  9159. // keyboard hints.
  9160. autoCapitalize: MUST_USE_ATTRIBUTE,
  9161. autoCorrect: MUST_USE_ATTRIBUTE,
  9162. // autoSave allows WebKit/Blink to persist values of input fields on page reloads
  9163. autoSave: null,
  9164. // color is for Safari mask-icon link
  9165. color: null,
  9166. // itemProp, itemScope, itemType are for
  9167. // Microdata support. See http://schema.org/docs/gs.html
  9168. itemProp: MUST_USE_ATTRIBUTE,
  9169. itemScope: MUST_USE_ATTRIBUTE | HAS_BOOLEAN_VALUE,
  9170. itemType: MUST_USE_ATTRIBUTE,
  9171. // itemID and itemRef are for Microdata support as well but
  9172. // only specified in the the WHATWG spec document. See
  9173. // https://html.spec.whatwg.org/multipage/microdata.html#microdata-dom-api
  9174. itemID: MUST_USE_ATTRIBUTE,
  9175. itemRef: MUST_USE_ATTRIBUTE,
  9176. // results show looking glass icon and recent searches on input
  9177. // search fields in WebKit/Blink
  9178. results: null,
  9179. // IE-only attribute that specifies security restrictions on an iframe
  9180. // as an alternative to the sandbox attribute on IE<10
  9181. security: MUST_USE_ATTRIBUTE,
  9182. // IE-only attribute that controls focus behavior
  9183. unselectable: MUST_USE_ATTRIBUTE
  9184. },
  9185. DOMAttributeNames: {
  9186. acceptCharset: 'accept-charset',
  9187. className: 'class',
  9188. htmlFor: 'for',
  9189. httpEquiv: 'http-equiv'
  9190. },
  9191. DOMPropertyNames: {
  9192. autoComplete: 'autocomplete',
  9193. autoFocus: 'autofocus',
  9194. autoPlay: 'autoplay',
  9195. autoSave: 'autosave',
  9196. // `encoding` is equivalent to `enctype`, IE8 lacks an `enctype` setter.
  9197. // http://www.w3.org/TR/html5/forms.html#dom-fs-encoding
  9198. encType: 'encoding',
  9199. hrefLang: 'hreflang',
  9200. radioGroup: 'radiogroup',
  9201. spellCheck: 'spellcheck',
  9202. srcDoc: 'srcdoc',
  9203. srcSet: 'srcset'
  9204. }
  9205. };
  9206. module.exports = HTMLDOMPropertyConfig;
  9207. /***/ },
  9208. /* 90 */
  9209. /***/ function(module, exports, __webpack_require__) {
  9210. /* WEBPACK VAR INJECTION */(function(process) {/**
  9211. * Copyright 2013-2015, Facebook, Inc.
  9212. * All rights reserved.
  9213. *
  9214. * This source code is licensed under the BSD-style license found in the
  9215. * LICENSE file in the root directory of this source tree. An additional grant
  9216. * of patent rights can be found in the PATENTS file in the same directory.
  9217. *
  9218. * @providesModule ReactBrowserComponentMixin
  9219. */
  9220. 'use strict';
  9221. var ReactInstanceMap = __webpack_require__(47);
  9222. var findDOMNode = __webpack_require__(91);
  9223. var warning = __webpack_require__(25);
  9224. var didWarnKey = '_getDOMNodeDidWarn';
  9225. var ReactBrowserComponentMixin = {
  9226. /**
  9227. * Returns the DOM node rendered by this component.
  9228. *
  9229. * @return {DOMElement} The root node of this component.
  9230. * @final
  9231. * @protected
  9232. */
  9233. getDOMNode: function () {
  9234. process.env.NODE_ENV !== 'production' ? warning(this.constructor[didWarnKey], '%s.getDOMNode(...) is deprecated. Please use ' + 'ReactDOM.findDOMNode(instance) instead.', ReactInstanceMap.get(this).getName() || this.tagName || 'Unknown') : undefined;
  9235. this.constructor[didWarnKey] = true;
  9236. return findDOMNode(this);
  9237. }
  9238. };
  9239. module.exports = ReactBrowserComponentMixin;
  9240. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  9241. /***/ },
  9242. /* 91 */
  9243. /***/ function(module, exports, __webpack_require__) {
  9244. /* WEBPACK VAR INJECTION */(function(process) {/**
  9245. * Copyright 2013-2015, Facebook, Inc.
  9246. * All rights reserved.
  9247. *
  9248. * This source code is licensed under the BSD-style license found in the
  9249. * LICENSE file in the root directory of this source tree. An additional grant
  9250. * of patent rights can be found in the PATENTS file in the same directory.
  9251. *
  9252. * @providesModule findDOMNode
  9253. * @typechecks static-only
  9254. */
  9255. 'use strict';
  9256. var ReactCurrentOwner = __webpack_require__(5);
  9257. var ReactInstanceMap = __webpack_require__(47);
  9258. var ReactMount = __webpack_require__(28);
  9259. var invariant = __webpack_require__(13);
  9260. var warning = __webpack_require__(25);
  9261. /**
  9262. * Returns the DOM node rendered by this element.
  9263. *
  9264. * @param {ReactComponent|DOMElement} componentOrElement
  9265. * @return {?DOMElement} The root node of this element.
  9266. */
  9267. function findDOMNode(componentOrElement) {
  9268. if (process.env.NODE_ENV !== 'production') {
  9269. var owner = ReactCurrentOwner.current;
  9270. if (owner !== null) {
  9271. process.env.NODE_ENV !== 'production' ? warning(owner._warnedAboutRefsInRender, '%s is accessing getDOMNode or findDOMNode inside its render(). ' + 'render() should be a pure function of props and state. It should ' + 'never access something that requires stale data from the previous ' + 'render, such as refs. Move this logic to componentDidMount and ' + 'componentDidUpdate instead.', owner.getName() || 'A component') : undefined;
  9272. owner._warnedAboutRefsInRender = true;
  9273. }
  9274. }
  9275. if (componentOrElement == null) {
  9276. return null;
  9277. }
  9278. if (componentOrElement.nodeType === 1) {
  9279. return componentOrElement;
  9280. }
  9281. if (ReactInstanceMap.has(componentOrElement)) {
  9282. return ReactMount.getNodeFromInstance(componentOrElement);
  9283. }
  9284. !(componentOrElement.render == null || typeof componentOrElement.render !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'findDOMNode was called on an unmounted component.') : invariant(false) : undefined;
  9285. true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Element appears to be neither ReactComponent nor DOMNode (keys: %s)', Object.keys(componentOrElement)) : invariant(false) : undefined;
  9286. }
  9287. module.exports = findDOMNode;
  9288. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  9289. /***/ },
  9290. /* 92 */
  9291. /***/ function(module, exports, __webpack_require__) {
  9292. /**
  9293. * Copyright 2013-2015, Facebook, Inc.
  9294. * All rights reserved.
  9295. *
  9296. * This source code is licensed under the BSD-style license found in the
  9297. * LICENSE file in the root directory of this source tree. An additional grant
  9298. * of patent rights can be found in the PATENTS file in the same directory.
  9299. *
  9300. * @providesModule ReactDefaultBatchingStrategy
  9301. */
  9302. 'use strict';
  9303. var ReactUpdates = __webpack_require__(54);
  9304. var Transaction = __webpack_require__(57);
  9305. var assign = __webpack_require__(39);
  9306. var emptyFunction = __webpack_require__(15);
  9307. var RESET_BATCHED_UPDATES = {
  9308. initialize: emptyFunction,
  9309. close: function () {
  9310. ReactDefaultBatchingStrategy.isBatchingUpdates = false;
  9311. }
  9312. };
  9313. var FLUSH_BATCHED_UPDATES = {
  9314. initialize: emptyFunction,
  9315. close: ReactUpdates.flushBatchedUpdates.bind(ReactUpdates)
  9316. };
  9317. var TRANSACTION_WRAPPERS = [FLUSH_BATCHED_UPDATES, RESET_BATCHED_UPDATES];
  9318. function ReactDefaultBatchingStrategyTransaction() {
  9319. this.reinitializeTransaction();
  9320. }
  9321. assign(ReactDefaultBatchingStrategyTransaction.prototype, Transaction.Mixin, {
  9322. getTransactionWrappers: function () {
  9323. return TRANSACTION_WRAPPERS;
  9324. }
  9325. });
  9326. var transaction = new ReactDefaultBatchingStrategyTransaction();
  9327. var ReactDefaultBatchingStrategy = {
  9328. isBatchingUpdates: false,
  9329. /**
  9330. * Call the provided function in a context within which calls to `setState`
  9331. * and friends are batched such that components aren't updated unnecessarily.
  9332. */
  9333. batchedUpdates: function (callback, a, b, c, d, e) {
  9334. var alreadyBatchingUpdates = ReactDefaultBatchingStrategy.isBatchingUpdates;
  9335. ReactDefaultBatchingStrategy.isBatchingUpdates = true;
  9336. // The code is written this way to avoid extra allocations
  9337. if (alreadyBatchingUpdates) {
  9338. callback(a, b, c, d, e);
  9339. } else {
  9340. transaction.perform(callback, null, a, b, c, d, e);
  9341. }
  9342. }
  9343. };
  9344. module.exports = ReactDefaultBatchingStrategy;
  9345. /***/ },
  9346. /* 93 */
  9347. /***/ function(module, exports, __webpack_require__) {
  9348. /* WEBPACK VAR INJECTION */(function(process) {/**
  9349. * Copyright 2013-2015, Facebook, Inc.
  9350. * All rights reserved.
  9351. *
  9352. * This source code is licensed under the BSD-style license found in the
  9353. * LICENSE file in the root directory of this source tree. An additional grant
  9354. * of patent rights can be found in the PATENTS file in the same directory.
  9355. *
  9356. * @providesModule ReactDOMComponent
  9357. * @typechecks static-only
  9358. */
  9359. /* global hasOwnProperty:true */
  9360. 'use strict';
  9361. var AutoFocusUtils = __webpack_require__(94);
  9362. var CSSPropertyOperations = __webpack_require__(96);
  9363. var DOMProperty = __webpack_require__(23);
  9364. var DOMPropertyOperations = __webpack_require__(22);
  9365. var EventConstants = __webpack_require__(30);
  9366. var ReactBrowserEventEmitter = __webpack_require__(29);
  9367. var ReactComponentBrowserEnvironment = __webpack_require__(26);
  9368. var ReactDOMButton = __webpack_require__(104);
  9369. var ReactDOMInput = __webpack_require__(105);
  9370. var ReactDOMOption = __webpack_require__(109);
  9371. var ReactDOMSelect = __webpack_require__(112);
  9372. var ReactDOMTextarea = __webpack_require__(113);
  9373. var ReactMount = __webpack_require__(28);
  9374. var ReactMultiChild = __webpack_require__(114);
  9375. var ReactPerf = __webpack_require__(18);
  9376. var ReactUpdateQueue = __webpack_require__(53);
  9377. var assign = __webpack_require__(39);
  9378. var canDefineProperty = __webpack_require__(43);
  9379. var escapeTextContentForBrowser = __webpack_require__(21);
  9380. var invariant = __webpack_require__(13);
  9381. var isEventSupported = __webpack_require__(40);
  9382. var keyOf = __webpack_require__(79);
  9383. var setInnerHTML = __webpack_require__(19);
  9384. var setTextContent = __webpack_require__(20);
  9385. var shallowEqual = __webpack_require__(117);
  9386. var validateDOMNesting = __webpack_require__(70);
  9387. var warning = __webpack_require__(25);
  9388. var deleteListener = ReactBrowserEventEmitter.deleteListener;
  9389. var listenTo = ReactBrowserEventEmitter.listenTo;
  9390. var registrationNameModules = ReactBrowserEventEmitter.registrationNameModules;
  9391. // For quickly matching children type, to test if can be treated as content.
  9392. var CONTENT_TYPES = { 'string': true, 'number': true };
  9393. var CHILDREN = keyOf({ children: null });
  9394. var STYLE = keyOf({ style: null });
  9395. var HTML = keyOf({ __html: null });
  9396. var ELEMENT_NODE_TYPE = 1;
  9397. function getDeclarationErrorAddendum(internalInstance) {
  9398. if (internalInstance) {
  9399. var owner = internalInstance._currentElement._owner || null;
  9400. if (owner) {
  9401. var name = owner.getName();
  9402. if (name) {
  9403. return ' This DOM node was rendered by `' + name + '`.';
  9404. }
  9405. }
  9406. }
  9407. return '';
  9408. }
  9409. var legacyPropsDescriptor;
  9410. if (process.env.NODE_ENV !== 'production') {
  9411. legacyPropsDescriptor = {
  9412. props: {
  9413. enumerable: false,
  9414. get: function () {
  9415. var component = this._reactInternalComponent;
  9416. process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .props of a DOM node; instead, ' + 'recreate the props as `render` did originally or read the DOM ' + 'properties/attributes directly from this node (e.g., ' + 'this.refs.box.className).%s', getDeclarationErrorAddendum(component)) : undefined;
  9417. return component._currentElement.props;
  9418. }
  9419. }
  9420. };
  9421. }
  9422. function legacyGetDOMNode() {
  9423. if (process.env.NODE_ENV !== 'production') {
  9424. var component = this._reactInternalComponent;
  9425. process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .getDOMNode() of a DOM node; ' + 'instead, use the node directly.%s', getDeclarationErrorAddendum(component)) : undefined;
  9426. }
  9427. return this;
  9428. }
  9429. function legacyIsMounted() {
  9430. var component = this._reactInternalComponent;
  9431. if (process.env.NODE_ENV !== 'production') {
  9432. process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .isMounted() of a DOM node.%s', getDeclarationErrorAddendum(component)) : undefined;
  9433. }
  9434. return !!component;
  9435. }
  9436. function legacySetStateEtc() {
  9437. if (process.env.NODE_ENV !== 'production') {
  9438. var component = this._reactInternalComponent;
  9439. process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .setState(), .replaceState(), or ' + '.forceUpdate() of a DOM node. This is a no-op.%s', getDeclarationErrorAddendum(component)) : undefined;
  9440. }
  9441. }
  9442. function legacySetProps(partialProps, callback) {
  9443. var component = this._reactInternalComponent;
  9444. if (process.env.NODE_ENV !== 'production') {
  9445. process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .setProps() of a DOM node. ' + 'Instead, call ReactDOM.render again at the top level.%s', getDeclarationErrorAddendum(component)) : undefined;
  9446. }
  9447. if (!component) {
  9448. return;
  9449. }
  9450. ReactUpdateQueue.enqueueSetPropsInternal(component, partialProps);
  9451. if (callback) {
  9452. ReactUpdateQueue.enqueueCallbackInternal(component, callback);
  9453. }
  9454. }
  9455. function legacyReplaceProps(partialProps, callback) {
  9456. var component = this._reactInternalComponent;
  9457. if (process.env.NODE_ENV !== 'production') {
  9458. process.env.NODE_ENV !== 'production' ? warning(false, 'ReactDOMComponent: Do not access .replaceProps() of a DOM node. ' + 'Instead, call ReactDOM.render again at the top level.%s', getDeclarationErrorAddendum(component)) : undefined;
  9459. }
  9460. if (!component) {
  9461. return;
  9462. }
  9463. ReactUpdateQueue.enqueueReplacePropsInternal(component, partialProps);
  9464. if (callback) {
  9465. ReactUpdateQueue.enqueueCallbackInternal(component, callback);
  9466. }
  9467. }
  9468. function friendlyStringify(obj) {
  9469. if (typeof obj === 'object') {
  9470. if (Array.isArray(obj)) {
  9471. return '[' + obj.map(friendlyStringify).join(', ') + ']';
  9472. } else {
  9473. var pairs = [];
  9474. for (var key in obj) {
  9475. if (Object.prototype.hasOwnProperty.call(obj, key)) {
  9476. var keyEscaped = /^[a-z$_][\w$_]*$/i.test(key) ? key : JSON.stringify(key);
  9477. pairs.push(keyEscaped + ': ' + friendlyStringify(obj[key]));
  9478. }
  9479. }
  9480. return '{' + pairs.join(', ') + '}';
  9481. }
  9482. } else if (typeof obj === 'string') {
  9483. return JSON.stringify(obj);
  9484. } else if (typeof obj === 'function') {
  9485. return '[function object]';
  9486. }
  9487. // Differs from JSON.stringify in that undefined becauses undefined and that
  9488. // inf and nan don't become null
  9489. return String(obj);
  9490. }
  9491. var styleMutationWarning = {};
  9492. function checkAndWarnForMutatedStyle(style1, style2, component) {
  9493. if (style1 == null || style2 == null) {
  9494. return;
  9495. }
  9496. if (shallowEqual(style1, style2)) {
  9497. return;
  9498. }
  9499. var componentName = component._tag;
  9500. var owner = component._currentElement._owner;
  9501. var ownerName;
  9502. if (owner) {
  9503. ownerName = owner.getName();
  9504. }
  9505. var hash = ownerName + '|' + componentName;
  9506. if (styleMutationWarning.hasOwnProperty(hash)) {
  9507. return;
  9508. }
  9509. styleMutationWarning[hash] = true;
  9510. process.env.NODE_ENV !== 'production' ? warning(false, '`%s` was passed a style object that has previously been mutated. ' + 'Mutating `style` is deprecated. Consider cloning it beforehand. Check ' + 'the `render` %s. Previous style: %s. Mutated style: %s.', componentName, owner ? 'of `' + ownerName + '`' : 'using <' + componentName + '>', friendlyStringify(style1), friendlyStringify(style2)) : undefined;
  9511. }
  9512. /**
  9513. * @param {object} component
  9514. * @param {?object} props
  9515. */
  9516. function assertValidProps(component, props) {
  9517. if (!props) {
  9518. return;
  9519. }
  9520. // Note the use of `==` which checks for null or undefined.
  9521. if (process.env.NODE_ENV !== 'production') {
  9522. if (voidElementTags[component._tag]) {
  9523. process.env.NODE_ENV !== 'production' ? warning(props.children == null && props.dangerouslySetInnerHTML == null, '%s is a void element tag and must not have `children` or ' + 'use `props.dangerouslySetInnerHTML`.%s', component._tag, component._currentElement._owner ? ' Check the render method of ' + component._currentElement._owner.getName() + '.' : '') : undefined;
  9524. }
  9525. }
  9526. if (props.dangerouslySetInnerHTML != null) {
  9527. !(props.children == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Can only set one of `children` or `props.dangerouslySetInnerHTML`.') : invariant(false) : undefined;
  9528. !(typeof props.dangerouslySetInnerHTML === 'object' && HTML in props.dangerouslySetInnerHTML) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. ' + 'Please visit https://fb.me/react-invariant-dangerously-set-inner-html ' + 'for more information.') : invariant(false) : undefined;
  9529. }
  9530. if (process.env.NODE_ENV !== 'production') {
  9531. process.env.NODE_ENV !== 'production' ? warning(props.innerHTML == null, 'Directly setting property `innerHTML` is not permitted. ' + 'For more information, lookup documentation on `dangerouslySetInnerHTML`.') : undefined;
  9532. process.env.NODE_ENV !== 'production' ? warning(!props.contentEditable || props.children == null, 'A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.') : undefined;
  9533. }
  9534. !(props.style == null || typeof props.style === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'The `style` prop expects a mapping from style properties to values, ' + 'not a string. For example, style={{marginRight: spacing + \'em\'}} when ' + 'using JSX.%s', getDeclarationErrorAddendum(component)) : invariant(false) : undefined;
  9535. }
  9536. function enqueuePutListener(id, registrationName, listener, transaction) {
  9537. if (process.env.NODE_ENV !== 'production') {
  9538. // IE8 has no API for event capturing and the `onScroll` event doesn't
  9539. // bubble.
  9540. process.env.NODE_ENV !== 'production' ? warning(registrationName !== 'onScroll' || isEventSupported('scroll', true), 'This browser doesn\'t support the `onScroll` event') : undefined;
  9541. }
  9542. var container = ReactMount.findReactContainerForID(id);
  9543. if (container) {
  9544. var doc = container.nodeType === ELEMENT_NODE_TYPE ? container.ownerDocument : container;
  9545. listenTo(registrationName, doc);
  9546. }
  9547. transaction.getReactMountReady().enqueue(putListener, {
  9548. id: id,
  9549. registrationName: registrationName,
  9550. listener: listener
  9551. });
  9552. }
  9553. function putListener() {
  9554. var listenerToPut = this;
  9555. ReactBrowserEventEmitter.putListener(listenerToPut.id, listenerToPut.registrationName, listenerToPut.listener);
  9556. }
  9557. // There are so many media events, it makes sense to just
  9558. // maintain a list rather than create a `trapBubbledEvent` for each
  9559. var mediaEvents = {
  9560. topAbort: 'abort',
  9561. topCanPlay: 'canplay',
  9562. topCanPlayThrough: 'canplaythrough',
  9563. topDurationChange: 'durationchange',
  9564. topEmptied: 'emptied',
  9565. topEncrypted: 'encrypted',
  9566. topEnded: 'ended',
  9567. topError: 'error',
  9568. topLoadedData: 'loadeddata',
  9569. topLoadedMetadata: 'loadedmetadata',
  9570. topLoadStart: 'loadstart',
  9571. topPause: 'pause',
  9572. topPlay: 'play',
  9573. topPlaying: 'playing',
  9574. topProgress: 'progress',
  9575. topRateChange: 'ratechange',
  9576. topSeeked: 'seeked',
  9577. topSeeking: 'seeking',
  9578. topStalled: 'stalled',
  9579. topSuspend: 'suspend',
  9580. topTimeUpdate: 'timeupdate',
  9581. topVolumeChange: 'volumechange',
  9582. topWaiting: 'waiting'
  9583. };
  9584. function trapBubbledEventsLocal() {
  9585. var inst = this;
  9586. // If a component renders to null or if another component fatals and causes
  9587. // the state of the tree to be corrupted, `node` here can be null.
  9588. !inst._rootNodeID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Must be mounted to trap events') : invariant(false) : undefined;
  9589. var node = ReactMount.getNode(inst._rootNodeID);
  9590. !node ? process.env.NODE_ENV !== 'production' ? invariant(false, 'trapBubbledEvent(...): Requires node to be rendered.') : invariant(false) : undefined;
  9591. switch (inst._tag) {
  9592. case 'iframe':
  9593. inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)];
  9594. break;
  9595. case 'video':
  9596. case 'audio':
  9597. inst._wrapperState.listeners = [];
  9598. // create listener for each media event
  9599. for (var event in mediaEvents) {
  9600. if (mediaEvents.hasOwnProperty(event)) {
  9601. inst._wrapperState.listeners.push(ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes[event], mediaEvents[event], node));
  9602. }
  9603. }
  9604. break;
  9605. case 'img':
  9606. inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topError, 'error', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topLoad, 'load', node)];
  9607. break;
  9608. case 'form':
  9609. inst._wrapperState.listeners = [ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topReset, 'reset', node), ReactBrowserEventEmitter.trapBubbledEvent(EventConstants.topLevelTypes.topSubmit, 'submit', node)];
  9610. break;
  9611. }
  9612. }
  9613. function mountReadyInputWrapper() {
  9614. ReactDOMInput.mountReadyWrapper(this);
  9615. }
  9616. function postUpdateSelectWrapper() {
  9617. ReactDOMSelect.postUpdateWrapper(this);
  9618. }
  9619. // For HTML, certain tags should omit their close tag. We keep a whitelist for
  9620. // those special cased tags.
  9621. var omittedCloseTags = {
  9622. 'area': true,
  9623. 'base': true,
  9624. 'br': true,
  9625. 'col': true,
  9626. 'embed': true,
  9627. 'hr': true,
  9628. 'img': true,
  9629. 'input': true,
  9630. 'keygen': true,
  9631. 'link': true,
  9632. 'meta': true,
  9633. 'param': true,
  9634. 'source': true,
  9635. 'track': true,
  9636. 'wbr': true
  9637. };
  9638. // NOTE: menuitem's close tag should be omitted, but that causes problems.
  9639. var newlineEatingTags = {
  9640. 'listing': true,
  9641. 'pre': true,
  9642. 'textarea': true
  9643. };
  9644. // For HTML, certain tags cannot have children. This has the same purpose as
  9645. // `omittedCloseTags` except that `menuitem` should still have its closing tag.
  9646. var voidElementTags = assign({
  9647. 'menuitem': true
  9648. }, omittedCloseTags);
  9649. // We accept any tag to be rendered but since this gets injected into arbitrary
  9650. // HTML, we want to make sure that it's a safe tag.
  9651. // http://www.w3.org/TR/REC-xml/#NT-Name
  9652. var VALID_TAG_REGEX = /^[a-zA-Z][a-zA-Z:_\.\-\d]*$/; // Simplified subset
  9653. var validatedTagCache = {};
  9654. var hasOwnProperty = ({}).hasOwnProperty;
  9655. function validateDangerousTag(tag) {
  9656. if (!hasOwnProperty.call(validatedTagCache, tag)) {
  9657. !VALID_TAG_REGEX.test(tag) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Invalid tag: %s', tag) : invariant(false) : undefined;
  9658. validatedTagCache[tag] = true;
  9659. }
  9660. }
  9661. function processChildContextDev(context, inst) {
  9662. // Pass down our tag name to child components for validation purposes
  9663. context = assign({}, context);
  9664. var info = context[validateDOMNesting.ancestorInfoContextKey];
  9665. context[validateDOMNesting.ancestorInfoContextKey] = validateDOMNesting.updatedAncestorInfo(info, inst._tag, inst);
  9666. return context;
  9667. }
  9668. function isCustomComponent(tagName, props) {
  9669. return tagName.indexOf('-') >= 0 || props.is != null;
  9670. }
  9671. /**
  9672. * Creates a new React class that is idempotent and capable of containing other
  9673. * React components. It accepts event listeners and DOM properties that are
  9674. * valid according to `DOMProperty`.
  9675. *
  9676. * - Event listeners: `onClick`, `onMouseDown`, etc.
  9677. * - DOM properties: `className`, `name`, `title`, etc.
  9678. *
  9679. * The `style` property functions differently from the DOM API. It accepts an
  9680. * object mapping of style properties to values.
  9681. *
  9682. * @constructor ReactDOMComponent
  9683. * @extends ReactMultiChild
  9684. */
  9685. function ReactDOMComponent(tag) {
  9686. validateDangerousTag(tag);
  9687. this._tag = tag.toLowerCase();
  9688. this._renderedChildren = null;
  9689. this._previousStyle = null;
  9690. this._previousStyleCopy = null;
  9691. this._rootNodeID = null;
  9692. this._wrapperState = null;
  9693. this._topLevelWrapper = null;
  9694. this._nodeWithLegacyProperties = null;
  9695. if (process.env.NODE_ENV !== 'production') {
  9696. this._unprocessedContextDev = null;
  9697. this._processedContextDev = null;
  9698. }
  9699. }
  9700. ReactDOMComponent.displayName = 'ReactDOMComponent';
  9701. ReactDOMComponent.Mixin = {
  9702. construct: function (element) {
  9703. this._currentElement = element;
  9704. },
  9705. /**
  9706. * Generates root tag markup then recurses. This method has side effects and
  9707. * is not idempotent.
  9708. *
  9709. * @internal
  9710. * @param {string} rootID The root DOM ID for this node.
  9711. * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
  9712. * @param {object} context
  9713. * @return {string} The computed markup.
  9714. */
  9715. mountComponent: function (rootID, transaction, context) {
  9716. this._rootNodeID = rootID;
  9717. var props = this._currentElement.props;
  9718. switch (this._tag) {
  9719. case 'iframe':
  9720. case 'img':
  9721. case 'form':
  9722. case 'video':
  9723. case 'audio':
  9724. this._wrapperState = {
  9725. listeners: null
  9726. };
  9727. transaction.getReactMountReady().enqueue(trapBubbledEventsLocal, this);
  9728. break;
  9729. case 'button':
  9730. props = ReactDOMButton.getNativeProps(this, props, context);
  9731. break;
  9732. case 'input':
  9733. ReactDOMInput.mountWrapper(this, props, context);
  9734. props = ReactDOMInput.getNativeProps(this, props, context);
  9735. break;
  9736. case 'option':
  9737. ReactDOMOption.mountWrapper(this, props, context);
  9738. props = ReactDOMOption.getNativeProps(this, props, context);
  9739. break;
  9740. case 'select':
  9741. ReactDOMSelect.mountWrapper(this, props, context);
  9742. props = ReactDOMSelect.getNativeProps(this, props, context);
  9743. context = ReactDOMSelect.processChildContext(this, props, context);
  9744. break;
  9745. case 'textarea':
  9746. ReactDOMTextarea.mountWrapper(this, props, context);
  9747. props = ReactDOMTextarea.getNativeProps(this, props, context);
  9748. break;
  9749. }
  9750. assertValidProps(this, props);
  9751. if (process.env.NODE_ENV !== 'production') {
  9752. if (context[validateDOMNesting.ancestorInfoContextKey]) {
  9753. validateDOMNesting(this._tag, this, context[validateDOMNesting.ancestorInfoContextKey]);
  9754. }
  9755. }
  9756. if (process.env.NODE_ENV !== 'production') {
  9757. this._unprocessedContextDev = context;
  9758. this._processedContextDev = processChildContextDev(context, this);
  9759. context = this._processedContextDev;
  9760. }
  9761. var mountImage;
  9762. if (transaction.useCreateElement) {
  9763. var ownerDocument = context[ReactMount.ownerDocumentContextKey];
  9764. var el = ownerDocument.createElement(this._currentElement.type);
  9765. DOMPropertyOperations.setAttributeForID(el, this._rootNodeID);
  9766. // Populate node cache
  9767. ReactMount.getID(el);
  9768. this._updateDOMProperties({}, props, transaction, el);
  9769. this._createInitialChildren(transaction, props, context, el);
  9770. mountImage = el;
  9771. } else {
  9772. var tagOpen = this._createOpenTagMarkupAndPutListeners(transaction, props);
  9773. var tagContent = this._createContentMarkup(transaction, props, context);
  9774. if (!tagContent && omittedCloseTags[this._tag]) {
  9775. mountImage = tagOpen + '/>';
  9776. } else {
  9777. mountImage = tagOpen + '>' + tagContent + '</' + this._currentElement.type + '>';
  9778. }
  9779. }
  9780. switch (this._tag) {
  9781. case 'input':
  9782. transaction.getReactMountReady().enqueue(mountReadyInputWrapper, this);
  9783. // falls through
  9784. case 'button':
  9785. case 'select':
  9786. case 'textarea':
  9787. if (props.autoFocus) {
  9788. transaction.getReactMountReady().enqueue(AutoFocusUtils.focusDOMComponent, this);
  9789. }
  9790. break;
  9791. }
  9792. return mountImage;
  9793. },
  9794. /**
  9795. * Creates markup for the open tag and all attributes.
  9796. *
  9797. * This method has side effects because events get registered.
  9798. *
  9799. * Iterating over object properties is faster than iterating over arrays.
  9800. * @see http://jsperf.com/obj-vs-arr-iteration
  9801. *
  9802. * @private
  9803. * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
  9804. * @param {object} props
  9805. * @return {string} Markup of opening tag.
  9806. */
  9807. _createOpenTagMarkupAndPutListeners: function (transaction, props) {
  9808. var ret = '<' + this._currentElement.type;
  9809. for (var propKey in props) {
  9810. if (!props.hasOwnProperty(propKey)) {
  9811. continue;
  9812. }
  9813. var propValue = props[propKey];
  9814. if (propValue == null) {
  9815. continue;
  9816. }
  9817. if (registrationNameModules.hasOwnProperty(propKey)) {
  9818. if (propValue) {
  9819. enqueuePutListener(this._rootNodeID, propKey, propValue, transaction);
  9820. }
  9821. } else {
  9822. if (propKey === STYLE) {
  9823. if (propValue) {
  9824. if (process.env.NODE_ENV !== 'production') {
  9825. // See `_updateDOMProperties`. style block
  9826. this._previousStyle = propValue;
  9827. }
  9828. propValue = this._previousStyleCopy = assign({}, props.style);
  9829. }
  9830. propValue = CSSPropertyOperations.createMarkupForStyles(propValue);
  9831. }
  9832. var markup = null;
  9833. if (this._tag != null && isCustomComponent(this._tag, props)) {
  9834. if (propKey !== CHILDREN) {
  9835. markup = DOMPropertyOperations.createMarkupForCustomAttribute(propKey, propValue);
  9836. }
  9837. } else {
  9838. markup = DOMPropertyOperations.createMarkupForProperty(propKey, propValue);
  9839. }
  9840. if (markup) {
  9841. ret += ' ' + markup;
  9842. }
  9843. }
  9844. }
  9845. // For static pages, no need to put React ID and checksum. Saves lots of
  9846. // bytes.
  9847. if (transaction.renderToStaticMarkup) {
  9848. return ret;
  9849. }
  9850. var markupForID = DOMPropertyOperations.createMarkupForID(this._rootNodeID);
  9851. return ret + ' ' + markupForID;
  9852. },
  9853. /**
  9854. * Creates markup for the content between the tags.
  9855. *
  9856. * @private
  9857. * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
  9858. * @param {object} props
  9859. * @param {object} context
  9860. * @return {string} Content markup.
  9861. */
  9862. _createContentMarkup: function (transaction, props, context) {
  9863. var ret = '';
  9864. // Intentional use of != to avoid catching zero/false.
  9865. var innerHTML = props.dangerouslySetInnerHTML;
  9866. if (innerHTML != null) {
  9867. if (innerHTML.__html != null) {
  9868. ret = innerHTML.__html;
  9869. }
  9870. } else {
  9871. var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null;
  9872. var childrenToUse = contentToUse != null ? null : props.children;
  9873. if (contentToUse != null) {
  9874. // TODO: Validate that text is allowed as a child of this node
  9875. ret = escapeTextContentForBrowser(contentToUse);
  9876. } else if (childrenToUse != null) {
  9877. var mountImages = this.mountChildren(childrenToUse, transaction, context);
  9878. ret = mountImages.join('');
  9879. }
  9880. }
  9881. if (newlineEatingTags[this._tag] && ret.charAt(0) === '\n') {
  9882. // text/html ignores the first character in these tags if it's a newline
  9883. // Prefer to break application/xml over text/html (for now) by adding
  9884. // a newline specifically to get eaten by the parser. (Alternately for
  9885. // textareas, replacing "^\n" with "\r\n" doesn't get eaten, and the first
  9886. // \r is normalized out by HTMLTextAreaElement#value.)
  9887. // See: <http://www.w3.org/TR/html-polyglot/#newlines-in-textarea-and-pre>
  9888. // See: <http://www.w3.org/TR/html5/syntax.html#element-restrictions>
  9889. // See: <http://www.w3.org/TR/html5/syntax.html#newlines>
  9890. // See: Parsing of "textarea" "listing" and "pre" elements
  9891. // from <http://www.w3.org/TR/html5/syntax.html#parsing-main-inbody>
  9892. return '\n' + ret;
  9893. } else {
  9894. return ret;
  9895. }
  9896. },
  9897. _createInitialChildren: function (transaction, props, context, el) {
  9898. // Intentional use of != to avoid catching zero/false.
  9899. var innerHTML = props.dangerouslySetInnerHTML;
  9900. if (innerHTML != null) {
  9901. if (innerHTML.__html != null) {
  9902. setInnerHTML(el, innerHTML.__html);
  9903. }
  9904. } else {
  9905. var contentToUse = CONTENT_TYPES[typeof props.children] ? props.children : null;
  9906. var childrenToUse = contentToUse != null ? null : props.children;
  9907. if (contentToUse != null) {
  9908. // TODO: Validate that text is allowed as a child of this node
  9909. setTextContent(el, contentToUse);
  9910. } else if (childrenToUse != null) {
  9911. var mountImages = this.mountChildren(childrenToUse, transaction, context);
  9912. for (var i = 0; i < mountImages.length; i++) {
  9913. el.appendChild(mountImages[i]);
  9914. }
  9915. }
  9916. }
  9917. },
  9918. /**
  9919. * Receives a next element and updates the component.
  9920. *
  9921. * @internal
  9922. * @param {ReactElement} nextElement
  9923. * @param {ReactReconcileTransaction|ReactServerRenderingTransaction} transaction
  9924. * @param {object} context
  9925. */
  9926. receiveComponent: function (nextElement, transaction, context) {
  9927. var prevElement = this._currentElement;
  9928. this._currentElement = nextElement;
  9929. this.updateComponent(transaction, prevElement, nextElement, context);
  9930. },
  9931. /**
  9932. * Updates a native DOM component after it has already been allocated and
  9933. * attached to the DOM. Reconciles the root DOM node, then recurses.
  9934. *
  9935. * @param {ReactReconcileTransaction} transaction
  9936. * @param {ReactElement} prevElement
  9937. * @param {ReactElement} nextElement
  9938. * @internal
  9939. * @overridable
  9940. */
  9941. updateComponent: function (transaction, prevElement, nextElement, context) {
  9942. var lastProps = prevElement.props;
  9943. var nextProps = this._currentElement.props;
  9944. switch (this._tag) {
  9945. case 'button':
  9946. lastProps = ReactDOMButton.getNativeProps(this, lastProps);
  9947. nextProps = ReactDOMButton.getNativeProps(this, nextProps);
  9948. break;
  9949. case 'input':
  9950. ReactDOMInput.updateWrapper(this);
  9951. lastProps = ReactDOMInput.getNativeProps(this, lastProps);
  9952. nextProps = ReactDOMInput.getNativeProps(this, nextProps);
  9953. break;
  9954. case 'option':
  9955. lastProps = ReactDOMOption.getNativeProps(this, lastProps);
  9956. nextProps = ReactDOMOption.getNativeProps(this, nextProps);
  9957. break;
  9958. case 'select':
  9959. lastProps = ReactDOMSelect.getNativeProps(this, lastProps);
  9960. nextProps = ReactDOMSelect.getNativeProps(this, nextProps);
  9961. break;
  9962. case 'textarea':
  9963. ReactDOMTextarea.updateWrapper(this);
  9964. lastProps = ReactDOMTextarea.getNativeProps(this, lastProps);
  9965. nextProps = ReactDOMTextarea.getNativeProps(this, nextProps);
  9966. break;
  9967. }
  9968. if (process.env.NODE_ENV !== 'production') {
  9969. // If the context is reference-equal to the old one, pass down the same
  9970. // processed object so the update bailout in ReactReconciler behaves
  9971. // correctly (and identically in dev and prod). See #5005.
  9972. if (this._unprocessedContextDev !== context) {
  9973. this._unprocessedContextDev = context;
  9974. this._processedContextDev = processChildContextDev(context, this);
  9975. }
  9976. context = this._processedContextDev;
  9977. }
  9978. assertValidProps(this, nextProps);
  9979. this._updateDOMProperties(lastProps, nextProps, transaction, null);
  9980. this._updateDOMChildren(lastProps, nextProps, transaction, context);
  9981. if (!canDefineProperty && this._nodeWithLegacyProperties) {
  9982. this._nodeWithLegacyProperties.props = nextProps;
  9983. }
  9984. if (this._tag === 'select') {
  9985. // <select> value update needs to occur after <option> children
  9986. // reconciliation
  9987. transaction.getReactMountReady().enqueue(postUpdateSelectWrapper, this);
  9988. }
  9989. },
  9990. /**
  9991. * Reconciles the properties by detecting differences in property values and
  9992. * updating the DOM as necessary. This function is probably the single most
  9993. * critical path for performance optimization.
  9994. *
  9995. * TODO: Benchmark whether checking for changed values in memory actually
  9996. * improves performance (especially statically positioned elements).
  9997. * TODO: Benchmark the effects of putting this at the top since 99% of props
  9998. * do not change for a given reconciliation.
  9999. * TODO: Benchmark areas that can be improved with caching.
  10000. *
  10001. * @private
  10002. * @param {object} lastProps
  10003. * @param {object} nextProps
  10004. * @param {ReactReconcileTransaction} transaction
  10005. * @param {?DOMElement} node
  10006. */
  10007. _updateDOMProperties: function (lastProps, nextProps, transaction, node) {
  10008. var propKey;
  10009. var styleName;
  10010. var styleUpdates;
  10011. for (propKey in lastProps) {
  10012. if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey)) {
  10013. continue;
  10014. }
  10015. if (propKey === STYLE) {
  10016. var lastStyle = this._previousStyleCopy;
  10017. for (styleName in lastStyle) {
  10018. if (lastStyle.hasOwnProperty(styleName)) {
  10019. styleUpdates = styleUpdates || {};
  10020. styleUpdates[styleName] = '';
  10021. }
  10022. }
  10023. this._previousStyleCopy = null;
  10024. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  10025. if (lastProps[propKey]) {
  10026. // Only call deleteListener if there was a listener previously or
  10027. // else willDeleteListener gets called when there wasn't actually a
  10028. // listener (e.g., onClick={null})
  10029. deleteListener(this._rootNodeID, propKey);
  10030. }
  10031. } else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) {
  10032. if (!node) {
  10033. node = ReactMount.getNode(this._rootNodeID);
  10034. }
  10035. DOMPropertyOperations.deleteValueForProperty(node, propKey);
  10036. }
  10037. }
  10038. for (propKey in nextProps) {
  10039. var nextProp = nextProps[propKey];
  10040. var lastProp = propKey === STYLE ? this._previousStyleCopy : lastProps[propKey];
  10041. if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp) {
  10042. continue;
  10043. }
  10044. if (propKey === STYLE) {
  10045. if (nextProp) {
  10046. if (process.env.NODE_ENV !== 'production') {
  10047. checkAndWarnForMutatedStyle(this._previousStyleCopy, this._previousStyle, this);
  10048. this._previousStyle = nextProp;
  10049. }
  10050. nextProp = this._previousStyleCopy = assign({}, nextProp);
  10051. } else {
  10052. this._previousStyleCopy = null;
  10053. }
  10054. if (lastProp) {
  10055. // Unset styles on `lastProp` but not on `nextProp`.
  10056. for (styleName in lastProp) {
  10057. if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
  10058. styleUpdates = styleUpdates || {};
  10059. styleUpdates[styleName] = '';
  10060. }
  10061. }
  10062. // Update styles that changed since `lastProp`.
  10063. for (styleName in nextProp) {
  10064. if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
  10065. styleUpdates = styleUpdates || {};
  10066. styleUpdates[styleName] = nextProp[styleName];
  10067. }
  10068. }
  10069. } else {
  10070. // Relies on `updateStylesByID` not mutating `styleUpdates`.
  10071. styleUpdates = nextProp;
  10072. }
  10073. } else if (registrationNameModules.hasOwnProperty(propKey)) {
  10074. if (nextProp) {
  10075. enqueuePutListener(this._rootNodeID, propKey, nextProp, transaction);
  10076. } else if (lastProp) {
  10077. deleteListener(this._rootNodeID, propKey);
  10078. }
  10079. } else if (isCustomComponent(this._tag, nextProps)) {
  10080. if (!node) {
  10081. node = ReactMount.getNode(this._rootNodeID);
  10082. }
  10083. if (propKey === CHILDREN) {
  10084. nextProp = null;
  10085. }
  10086. DOMPropertyOperations.setValueForAttribute(node, propKey, nextProp);
  10087. } else if (DOMProperty.properties[propKey] || DOMProperty.isCustomAttribute(propKey)) {
  10088. if (!node) {
  10089. node = ReactMount.getNode(this._rootNodeID);
  10090. }
  10091. // If we're updating to null or undefined, we should remove the property
  10092. // from the DOM node instead of inadvertantly setting to a string. This
  10093. // brings us in line with the same behavior we have on initial render.
  10094. if (nextProp != null) {
  10095. DOMPropertyOperations.setValueForProperty(node, propKey, nextProp);
  10096. } else {
  10097. DOMPropertyOperations.deleteValueForProperty(node, propKey);
  10098. }
  10099. }
  10100. }
  10101. if (styleUpdates) {
  10102. if (!node) {
  10103. node = ReactMount.getNode(this._rootNodeID);
  10104. }
  10105. CSSPropertyOperations.setValueForStyles(node, styleUpdates);
  10106. }
  10107. },
  10108. /**
  10109. * Reconciles the children with the various properties that affect the
  10110. * children content.
  10111. *
  10112. * @param {object} lastProps
  10113. * @param {object} nextProps
  10114. * @param {ReactReconcileTransaction} transaction
  10115. * @param {object} context
  10116. */
  10117. _updateDOMChildren: function (lastProps, nextProps, transaction, context) {
  10118. var lastContent = CONTENT_TYPES[typeof lastProps.children] ? lastProps.children : null;
  10119. var nextContent = CONTENT_TYPES[typeof nextProps.children] ? nextProps.children : null;
  10120. var lastHtml = lastProps.dangerouslySetInnerHTML && lastProps.dangerouslySetInnerHTML.__html;
  10121. var nextHtml = nextProps.dangerouslySetInnerHTML && nextProps.dangerouslySetInnerHTML.__html;
  10122. // Note the use of `!=` which checks for null or undefined.
  10123. var lastChildren = lastContent != null ? null : lastProps.children;
  10124. var nextChildren = nextContent != null ? null : nextProps.children;
  10125. // If we're switching from children to content/html or vice versa, remove
  10126. // the old content
  10127. var lastHasContentOrHtml = lastContent != null || lastHtml != null;
  10128. var nextHasContentOrHtml = nextContent != null || nextHtml != null;
  10129. if (lastChildren != null && nextChildren == null) {
  10130. this.updateChildren(null, transaction, context);
  10131. } else if (lastHasContentOrHtml && !nextHasContentOrHtml) {
  10132. this.updateTextContent('');
  10133. }
  10134. if (nextContent != null) {
  10135. if (lastContent !== nextContent) {
  10136. this.updateTextContent('' + nextContent);
  10137. }
  10138. } else if (nextHtml != null) {
  10139. if (lastHtml !== nextHtml) {
  10140. this.updateMarkup('' + nextHtml);
  10141. }
  10142. } else if (nextChildren != null) {
  10143. this.updateChildren(nextChildren, transaction, context);
  10144. }
  10145. },
  10146. /**
  10147. * Destroys all event registrations for this instance. Does not remove from
  10148. * the DOM. That must be done by the parent.
  10149. *
  10150. * @internal
  10151. */
  10152. unmountComponent: function () {
  10153. switch (this._tag) {
  10154. case 'iframe':
  10155. case 'img':
  10156. case 'form':
  10157. case 'video':
  10158. case 'audio':
  10159. var listeners = this._wrapperState.listeners;
  10160. if (listeners) {
  10161. for (var i = 0; i < listeners.length; i++) {
  10162. listeners[i].remove();
  10163. }
  10164. }
  10165. break;
  10166. case 'input':
  10167. ReactDOMInput.unmountWrapper(this);
  10168. break;
  10169. case 'html':
  10170. case 'head':
  10171. case 'body':
  10172. /**
  10173. * Components like <html> <head> and <body> can't be removed or added
  10174. * easily in a cross-browser way, however it's valuable to be able to
  10175. * take advantage of React's reconciliation for styling and <title>
  10176. * management. So we just document it and throw in dangerous cases.
  10177. */
  10178. true ? process.env.NODE_ENV !== 'production' ? invariant(false, '<%s> tried to unmount. Because of cross-browser quirks it is ' + 'impossible to unmount some top-level components (eg <html>, ' + '<head>, and <body>) reliably and efficiently. To fix this, have a ' + 'single top-level component that never unmounts render these ' + 'elements.', this._tag) : invariant(false) : undefined;
  10179. break;
  10180. }
  10181. this.unmountChildren();
  10182. ReactBrowserEventEmitter.deleteAllListeners(this._rootNodeID);
  10183. ReactComponentBrowserEnvironment.unmountIDFromEnvironment(this._rootNodeID);
  10184. this._rootNodeID = null;
  10185. this._wrapperState = null;
  10186. if (this._nodeWithLegacyProperties) {
  10187. var node = this._nodeWithLegacyProperties;
  10188. node._reactInternalComponent = null;
  10189. this._nodeWithLegacyProperties = null;
  10190. }
  10191. },
  10192. getPublicInstance: function () {
  10193. if (!this._nodeWithLegacyProperties) {
  10194. var node = ReactMount.getNode(this._rootNodeID);
  10195. node._reactInternalComponent = this;
  10196. node.getDOMNode = legacyGetDOMNode;
  10197. node.isMounted = legacyIsMounted;
  10198. node.setState = legacySetStateEtc;
  10199. node.replaceState = legacySetStateEtc;
  10200. node.forceUpdate = legacySetStateEtc;
  10201. node.setProps = legacySetProps;
  10202. node.replaceProps = legacyReplaceProps;
  10203. if (process.env.NODE_ENV !== 'production') {
  10204. if (canDefineProperty) {
  10205. Object.defineProperties(node, legacyPropsDescriptor);
  10206. } else {
  10207. // updateComponent will update this property on subsequent renders
  10208. node.props = this._currentElement.props;
  10209. }
  10210. } else {
  10211. // updateComponent will update this property on subsequent renders
  10212. node.props = this._currentElement.props;
  10213. }
  10214. this._nodeWithLegacyProperties = node;
  10215. }
  10216. return this._nodeWithLegacyProperties;
  10217. }
  10218. };
  10219. ReactPerf.measureMethods(ReactDOMComponent, 'ReactDOMComponent', {
  10220. mountComponent: 'mountComponent',
  10221. updateComponent: 'updateComponent'
  10222. });
  10223. assign(ReactDOMComponent.prototype, ReactDOMComponent.Mixin, ReactMultiChild.Mixin);
  10224. module.exports = ReactDOMComponent;
  10225. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  10226. /***/ },
  10227. /* 94 */
  10228. /***/ function(module, exports, __webpack_require__) {
  10229. /**
  10230. * Copyright 2013-2015, Facebook, Inc.
  10231. * All rights reserved.
  10232. *
  10233. * This source code is licensed under the BSD-style license found in the
  10234. * LICENSE file in the root directory of this source tree. An additional grant
  10235. * of patent rights can be found in the PATENTS file in the same directory.
  10236. *
  10237. * @providesModule AutoFocusUtils
  10238. * @typechecks static-only
  10239. */
  10240. 'use strict';
  10241. var ReactMount = __webpack_require__(28);
  10242. var findDOMNode = __webpack_require__(91);
  10243. var focusNode = __webpack_require__(95);
  10244. var Mixin = {
  10245. componentDidMount: function () {
  10246. if (this.props.autoFocus) {
  10247. focusNode(findDOMNode(this));
  10248. }
  10249. }
  10250. };
  10251. var AutoFocusUtils = {
  10252. Mixin: Mixin,
  10253. focusDOMComponent: function () {
  10254. focusNode(ReactMount.getNode(this._rootNodeID));
  10255. }
  10256. };
  10257. module.exports = AutoFocusUtils;
  10258. /***/ },
  10259. /* 95 */
  10260. /***/ function(module, exports) {
  10261. /**
  10262. * Copyright 2013-2015, Facebook, Inc.
  10263. * All rights reserved.
  10264. *
  10265. * This source code is licensed under the BSD-style license found in the
  10266. * LICENSE file in the root directory of this source tree. An additional grant
  10267. * of patent rights can be found in the PATENTS file in the same directory.
  10268. *
  10269. * @providesModule focusNode
  10270. */
  10271. 'use strict';
  10272. /**
  10273. * @param {DOMElement} node input/textarea to focus
  10274. */
  10275. function focusNode(node) {
  10276. // IE8 can throw "Can't move focus to the control because it is invisible,
  10277. // not enabled, or of a type that does not accept the focus." for all kinds of
  10278. // reasons that are too expensive and fragile to test.
  10279. try {
  10280. node.focus();
  10281. } catch (e) {}
  10282. }
  10283. module.exports = focusNode;
  10284. /***/ },
  10285. /* 96 */
  10286. /***/ function(module, exports, __webpack_require__) {
  10287. /* WEBPACK VAR INJECTION */(function(process) {/**
  10288. * Copyright 2013-2015, Facebook, Inc.
  10289. * All rights reserved.
  10290. *
  10291. * This source code is licensed under the BSD-style license found in the
  10292. * LICENSE file in the root directory of this source tree. An additional grant
  10293. * of patent rights can be found in the PATENTS file in the same directory.
  10294. *
  10295. * @providesModule CSSPropertyOperations
  10296. * @typechecks static-only
  10297. */
  10298. 'use strict';
  10299. var CSSProperty = __webpack_require__(97);
  10300. var ExecutionEnvironment = __webpack_require__(9);
  10301. var ReactPerf = __webpack_require__(18);
  10302. var camelizeStyleName = __webpack_require__(98);
  10303. var dangerousStyleValue = __webpack_require__(100);
  10304. var hyphenateStyleName = __webpack_require__(101);
  10305. var memoizeStringOnly = __webpack_require__(103);
  10306. var warning = __webpack_require__(25);
  10307. var processStyleName = memoizeStringOnly(function (styleName) {
  10308. return hyphenateStyleName(styleName);
  10309. });
  10310. var hasShorthandPropertyBug = false;
  10311. var styleFloatAccessor = 'cssFloat';
  10312. if (ExecutionEnvironment.canUseDOM) {
  10313. var tempStyle = document.createElement('div').style;
  10314. try {
  10315. // IE8 throws "Invalid argument." if resetting shorthand style properties.
  10316. tempStyle.font = '';
  10317. } catch (e) {
  10318. hasShorthandPropertyBug = true;
  10319. }
  10320. // IE8 only supports accessing cssFloat (standard) as styleFloat
  10321. if (document.documentElement.style.cssFloat === undefined) {
  10322. styleFloatAccessor = 'styleFloat';
  10323. }
  10324. }
  10325. if (process.env.NODE_ENV !== 'production') {
  10326. // 'msTransform' is correct, but the other prefixes should be capitalized
  10327. var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
  10328. // style values shouldn't contain a semicolon
  10329. var badStyleValueWithSemicolonPattern = /;\s*$/;
  10330. var warnedStyleNames = {};
  10331. var warnedStyleValues = {};
  10332. var warnHyphenatedStyleName = function (name) {
  10333. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  10334. return;
  10335. }
  10336. warnedStyleNames[name] = true;
  10337. process.env.NODE_ENV !== 'production' ? warning(false, 'Unsupported style property %s. Did you mean %s?', name, camelizeStyleName(name)) : undefined;
  10338. };
  10339. var warnBadVendoredStyleName = function (name) {
  10340. if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
  10341. return;
  10342. }
  10343. warnedStyleNames[name] = true;
  10344. process.env.NODE_ENV !== 'production' ? warning(false, 'Unsupported vendor-prefixed style property %s. Did you mean %s?', name, name.charAt(0).toUpperCase() + name.slice(1)) : undefined;
  10345. };
  10346. var warnStyleValueWithSemicolon = function (name, value) {
  10347. if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
  10348. return;
  10349. }
  10350. warnedStyleValues[value] = true;
  10351. process.env.NODE_ENV !== 'production' ? warning(false, 'Style property values shouldn\'t contain a semicolon. ' + 'Try "%s: %s" instead.', name, value.replace(badStyleValueWithSemicolonPattern, '')) : undefined;
  10352. };
  10353. /**
  10354. * @param {string} name
  10355. * @param {*} value
  10356. */
  10357. var warnValidStyle = function (name, value) {
  10358. if (name.indexOf('-') > -1) {
  10359. warnHyphenatedStyleName(name);
  10360. } else if (badVendoredStyleNamePattern.test(name)) {
  10361. warnBadVendoredStyleName(name);
  10362. } else if (badStyleValueWithSemicolonPattern.test(value)) {
  10363. warnStyleValueWithSemicolon(name, value);
  10364. }
  10365. };
  10366. }
  10367. /**
  10368. * Operations for dealing with CSS properties.
  10369. */
  10370. var CSSPropertyOperations = {
  10371. /**
  10372. * Serializes a mapping of style properties for use as inline styles:
  10373. *
  10374. * > createMarkupForStyles({width: '200px', height: 0})
  10375. * "width:200px;height:0;"
  10376. *
  10377. * Undefined values are ignored so that declarative programming is easier.
  10378. * The result should be HTML-escaped before insertion into the DOM.
  10379. *
  10380. * @param {object} styles
  10381. * @return {?string}
  10382. */
  10383. createMarkupForStyles: function (styles) {
  10384. var serialized = '';
  10385. for (var styleName in styles) {
  10386. if (!styles.hasOwnProperty(styleName)) {
  10387. continue;
  10388. }
  10389. var styleValue = styles[styleName];
  10390. if (process.env.NODE_ENV !== 'production') {
  10391. warnValidStyle(styleName, styleValue);
  10392. }
  10393. if (styleValue != null) {
  10394. serialized += processStyleName(styleName) + ':';
  10395. serialized += dangerousStyleValue(styleName, styleValue) + ';';
  10396. }
  10397. }
  10398. return serialized || null;
  10399. },
  10400. /**
  10401. * Sets the value for multiple styles on a node. If a value is specified as
  10402. * '' (empty string), the corresponding style property will be unset.
  10403. *
  10404. * @param {DOMElement} node
  10405. * @param {object} styles
  10406. */
  10407. setValueForStyles: function (node, styles) {
  10408. var style = node.style;
  10409. for (var styleName in styles) {
  10410. if (!styles.hasOwnProperty(styleName)) {
  10411. continue;
  10412. }
  10413. if (process.env.NODE_ENV !== 'production') {
  10414. warnValidStyle(styleName, styles[styleName]);
  10415. }
  10416. var styleValue = dangerousStyleValue(styleName, styles[styleName]);
  10417. if (styleName === 'float') {
  10418. styleName = styleFloatAccessor;
  10419. }
  10420. if (styleValue) {
  10421. style[styleName] = styleValue;
  10422. } else {
  10423. var expansion = hasShorthandPropertyBug && CSSProperty.shorthandPropertyExpansions[styleName];
  10424. if (expansion) {
  10425. // Shorthand property that IE8 won't like unsetting, so unset each
  10426. // component to placate it
  10427. for (var individualStyleName in expansion) {
  10428. style[individualStyleName] = '';
  10429. }
  10430. } else {
  10431. style[styleName] = '';
  10432. }
  10433. }
  10434. }
  10435. }
  10436. };
  10437. ReactPerf.measureMethods(CSSPropertyOperations, 'CSSPropertyOperations', {
  10438. setValueForStyles: 'setValueForStyles'
  10439. });
  10440. module.exports = CSSPropertyOperations;
  10441. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  10442. /***/ },
  10443. /* 97 */
  10444. /***/ function(module, exports) {
  10445. /**
  10446. * Copyright 2013-2015, Facebook, Inc.
  10447. * All rights reserved.
  10448. *
  10449. * This source code is licensed under the BSD-style license found in the
  10450. * LICENSE file in the root directory of this source tree. An additional grant
  10451. * of patent rights can be found in the PATENTS file in the same directory.
  10452. *
  10453. * @providesModule CSSProperty
  10454. */
  10455. 'use strict';
  10456. /**
  10457. * CSS properties which accept numbers but are not in units of "px".
  10458. */
  10459. var isUnitlessNumber = {
  10460. animationIterationCount: true,
  10461. boxFlex: true,
  10462. boxFlexGroup: true,
  10463. boxOrdinalGroup: true,
  10464. columnCount: true,
  10465. flex: true,
  10466. flexGrow: true,
  10467. flexPositive: true,
  10468. flexShrink: true,
  10469. flexNegative: true,
  10470. flexOrder: true,
  10471. fontWeight: true,
  10472. lineClamp: true,
  10473. lineHeight: true,
  10474. opacity: true,
  10475. order: true,
  10476. orphans: true,
  10477. tabSize: true,
  10478. widows: true,
  10479. zIndex: true,
  10480. zoom: true,
  10481. // SVG-related properties
  10482. fillOpacity: true,
  10483. stopOpacity: true,
  10484. strokeDashoffset: true,
  10485. strokeOpacity: true,
  10486. strokeWidth: true
  10487. };
  10488. /**
  10489. * @param {string} prefix vendor-specific prefix, eg: Webkit
  10490. * @param {string} key style name, eg: transitionDuration
  10491. * @return {string} style name prefixed with `prefix`, properly camelCased, eg:
  10492. * WebkitTransitionDuration
  10493. */
  10494. function prefixKey(prefix, key) {
  10495. return prefix + key.charAt(0).toUpperCase() + key.substring(1);
  10496. }
  10497. /**
  10498. * Support style names that may come passed in prefixed by adding permutations
  10499. * of vendor prefixes.
  10500. */
  10501. var prefixes = ['Webkit', 'ms', 'Moz', 'O'];
  10502. // Using Object.keys here, or else the vanilla for-in loop makes IE8 go into an
  10503. // infinite loop, because it iterates over the newly added props too.
  10504. Object.keys(isUnitlessNumber).forEach(function (prop) {
  10505. prefixes.forEach(function (prefix) {
  10506. isUnitlessNumber[prefixKey(prefix, prop)] = isUnitlessNumber[prop];
  10507. });
  10508. });
  10509. /**
  10510. * Most style properties can be unset by doing .style[prop] = '' but IE8
  10511. * doesn't like doing that with shorthand properties so for the properties that
  10512. * IE8 breaks on, which are listed here, we instead unset each of the
  10513. * individual properties. See http://bugs.jquery.com/ticket/12385.
  10514. * The 4-value 'clock' properties like margin, padding, border-width seem to
  10515. * behave without any problems. Curiously, list-style works too without any
  10516. * special prodding.
  10517. */
  10518. var shorthandPropertyExpansions = {
  10519. background: {
  10520. backgroundAttachment: true,
  10521. backgroundColor: true,
  10522. backgroundImage: true,
  10523. backgroundPositionX: true,
  10524. backgroundPositionY: true,
  10525. backgroundRepeat: true
  10526. },
  10527. backgroundPosition: {
  10528. backgroundPositionX: true,
  10529. backgroundPositionY: true
  10530. },
  10531. border: {
  10532. borderWidth: true,
  10533. borderStyle: true,
  10534. borderColor: true
  10535. },
  10536. borderBottom: {
  10537. borderBottomWidth: true,
  10538. borderBottomStyle: true,
  10539. borderBottomColor: true
  10540. },
  10541. borderLeft: {
  10542. borderLeftWidth: true,
  10543. borderLeftStyle: true,
  10544. borderLeftColor: true
  10545. },
  10546. borderRight: {
  10547. borderRightWidth: true,
  10548. borderRightStyle: true,
  10549. borderRightColor: true
  10550. },
  10551. borderTop: {
  10552. borderTopWidth: true,
  10553. borderTopStyle: true,
  10554. borderTopColor: true
  10555. },
  10556. font: {
  10557. fontStyle: true,
  10558. fontVariant: true,
  10559. fontWeight: true,
  10560. fontSize: true,
  10561. lineHeight: true,
  10562. fontFamily: true
  10563. },
  10564. outline: {
  10565. outlineWidth: true,
  10566. outlineStyle: true,
  10567. outlineColor: true
  10568. }
  10569. };
  10570. var CSSProperty = {
  10571. isUnitlessNumber: isUnitlessNumber,
  10572. shorthandPropertyExpansions: shorthandPropertyExpansions
  10573. };
  10574. module.exports = CSSProperty;
  10575. /***/ },
  10576. /* 98 */
  10577. /***/ function(module, exports, __webpack_require__) {
  10578. /**
  10579. * Copyright 2013-2015, Facebook, Inc.
  10580. * All rights reserved.
  10581. *
  10582. * This source code is licensed under the BSD-style license found in the
  10583. * LICENSE file in the root directory of this source tree. An additional grant
  10584. * of patent rights can be found in the PATENTS file in the same directory.
  10585. *
  10586. * @providesModule camelizeStyleName
  10587. * @typechecks
  10588. */
  10589. 'use strict';
  10590. var camelize = __webpack_require__(99);
  10591. var msPattern = /^-ms-/;
  10592. /**
  10593. * Camelcases a hyphenated CSS property name, for example:
  10594. *
  10595. * > camelizeStyleName('background-color')
  10596. * < "backgroundColor"
  10597. * > camelizeStyleName('-moz-transition')
  10598. * < "MozTransition"
  10599. * > camelizeStyleName('-ms-transition')
  10600. * < "msTransition"
  10601. *
  10602. * As Andi Smith suggests
  10603. * (http://www.andismith.com/blog/2012/02/modernizr-prefixed/), an `-ms` prefix
  10604. * is converted to lowercase `ms`.
  10605. *
  10606. * @param {string} string
  10607. * @return {string}
  10608. */
  10609. function camelizeStyleName(string) {
  10610. return camelize(string.replace(msPattern, 'ms-'));
  10611. }
  10612. module.exports = camelizeStyleName;
  10613. /***/ },
  10614. /* 99 */
  10615. /***/ function(module, exports) {
  10616. /**
  10617. * Copyright 2013-2015, Facebook, Inc.
  10618. * All rights reserved.
  10619. *
  10620. * This source code is licensed under the BSD-style license found in the
  10621. * LICENSE file in the root directory of this source tree. An additional grant
  10622. * of patent rights can be found in the PATENTS file in the same directory.
  10623. *
  10624. * @providesModule camelize
  10625. * @typechecks
  10626. */
  10627. "use strict";
  10628. var _hyphenPattern = /-(.)/g;
  10629. /**
  10630. * Camelcases a hyphenated string, for example:
  10631. *
  10632. * > camelize('background-color')
  10633. * < "backgroundColor"
  10634. *
  10635. * @param {string} string
  10636. * @return {string}
  10637. */
  10638. function camelize(string) {
  10639. return string.replace(_hyphenPattern, function (_, character) {
  10640. return character.toUpperCase();
  10641. });
  10642. }
  10643. module.exports = camelize;
  10644. /***/ },
  10645. /* 100 */
  10646. /***/ function(module, exports, __webpack_require__) {
  10647. /**
  10648. * Copyright 2013-2015, Facebook, Inc.
  10649. * All rights reserved.
  10650. *
  10651. * This source code is licensed under the BSD-style license found in the
  10652. * LICENSE file in the root directory of this source tree. An additional grant
  10653. * of patent rights can be found in the PATENTS file in the same directory.
  10654. *
  10655. * @providesModule dangerousStyleValue
  10656. * @typechecks static-only
  10657. */
  10658. 'use strict';
  10659. var CSSProperty = __webpack_require__(97);
  10660. var isUnitlessNumber = CSSProperty.isUnitlessNumber;
  10661. /**
  10662. * Convert a value into the proper css writable value. The style name `name`
  10663. * should be logical (no hyphens), as specified
  10664. * in `CSSProperty.isUnitlessNumber`.
  10665. *
  10666. * @param {string} name CSS property name such as `topMargin`.
  10667. * @param {*} value CSS property value such as `10px`.
  10668. * @return {string} Normalized style value with dimensions applied.
  10669. */
  10670. function dangerousStyleValue(name, value) {
  10671. // Note that we've removed escapeTextForBrowser() calls here since the
  10672. // whole string will be escaped when the attribute is injected into
  10673. // the markup. If you provide unsafe user data here they can inject
  10674. // arbitrary CSS which may be problematic (I couldn't repro this):
  10675. // https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet
  10676. // http://www.thespanner.co.uk/2007/11/26/ultimate-xss-css-injection/
  10677. // This is not an XSS hole but instead a potential CSS injection issue
  10678. // which has lead to a greater discussion about how we're going to
  10679. // trust URLs moving forward. See #2115901
  10680. var isEmpty = value == null || typeof value === 'boolean' || value === '';
  10681. if (isEmpty) {
  10682. return '';
  10683. }
  10684. var isNonNumeric = isNaN(value);
  10685. if (isNonNumeric || value === 0 || isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name]) {
  10686. return '' + value; // cast to string
  10687. }
  10688. if (typeof value === 'string') {
  10689. value = value.trim();
  10690. }
  10691. return value + 'px';
  10692. }
  10693. module.exports = dangerousStyleValue;
  10694. /***/ },
  10695. /* 101 */
  10696. /***/ function(module, exports, __webpack_require__) {
  10697. /**
  10698. * Copyright 2013-2015, Facebook, Inc.
  10699. * All rights reserved.
  10700. *
  10701. * This source code is licensed under the BSD-style license found in the
  10702. * LICENSE file in the root directory of this source tree. An additional grant
  10703. * of patent rights can be found in the PATENTS file in the same directory.
  10704. *
  10705. * @providesModule hyphenateStyleName
  10706. * @typechecks
  10707. */
  10708. 'use strict';
  10709. var hyphenate = __webpack_require__(102);
  10710. var msPattern = /^ms-/;
  10711. /**
  10712. * Hyphenates a camelcased CSS property name, for example:
  10713. *
  10714. * > hyphenateStyleName('backgroundColor')
  10715. * < "background-color"
  10716. * > hyphenateStyleName('MozTransition')
  10717. * < "-moz-transition"
  10718. * > hyphenateStyleName('msTransition')
  10719. * < "-ms-transition"
  10720. *
  10721. * As Modernizr suggests (http://modernizr.com/docs/#prefixed), an `ms` prefix
  10722. * is converted to `-ms-`.
  10723. *
  10724. * @param {string} string
  10725. * @return {string}
  10726. */
  10727. function hyphenateStyleName(string) {
  10728. return hyphenate(string).replace(msPattern, '-ms-');
  10729. }
  10730. module.exports = hyphenateStyleName;
  10731. /***/ },
  10732. /* 102 */
  10733. /***/ function(module, exports) {
  10734. /**
  10735. * Copyright 2013-2015, Facebook, Inc.
  10736. * All rights reserved.
  10737. *
  10738. * This source code is licensed under the BSD-style license found in the
  10739. * LICENSE file in the root directory of this source tree. An additional grant
  10740. * of patent rights can be found in the PATENTS file in the same directory.
  10741. *
  10742. * @providesModule hyphenate
  10743. * @typechecks
  10744. */
  10745. 'use strict';
  10746. var _uppercasePattern = /([A-Z])/g;
  10747. /**
  10748. * Hyphenates a camelcased string, for example:
  10749. *
  10750. * > hyphenate('backgroundColor')
  10751. * < "background-color"
  10752. *
  10753. * For CSS style names, use `hyphenateStyleName` instead which works properly
  10754. * with all vendor prefixes, including `ms`.
  10755. *
  10756. * @param {string} string
  10757. * @return {string}
  10758. */
  10759. function hyphenate(string) {
  10760. return string.replace(_uppercasePattern, '-$1').toLowerCase();
  10761. }
  10762. module.exports = hyphenate;
  10763. /***/ },
  10764. /* 103 */
  10765. /***/ function(module, exports) {
  10766. /**
  10767. * Copyright 2013-2015, Facebook, Inc.
  10768. * All rights reserved.
  10769. *
  10770. * This source code is licensed under the BSD-style license found in the
  10771. * LICENSE file in the root directory of this source tree. An additional grant
  10772. * of patent rights can be found in the PATENTS file in the same directory.
  10773. *
  10774. * @providesModule memoizeStringOnly
  10775. * @typechecks static-only
  10776. */
  10777. 'use strict';
  10778. /**
  10779. * Memoizes the return value of a function that accepts one string argument.
  10780. *
  10781. * @param {function} callback
  10782. * @return {function}
  10783. */
  10784. function memoizeStringOnly(callback) {
  10785. var cache = {};
  10786. return function (string) {
  10787. if (!cache.hasOwnProperty(string)) {
  10788. cache[string] = callback.call(this, string);
  10789. }
  10790. return cache[string];
  10791. };
  10792. }
  10793. module.exports = memoizeStringOnly;
  10794. /***/ },
  10795. /* 104 */
  10796. /***/ function(module, exports) {
  10797. /**
  10798. * Copyright 2013-2015, Facebook, Inc.
  10799. * All rights reserved.
  10800. *
  10801. * This source code is licensed under the BSD-style license found in the
  10802. * LICENSE file in the root directory of this source tree. An additional grant
  10803. * of patent rights can be found in the PATENTS file in the same directory.
  10804. *
  10805. * @providesModule ReactDOMButton
  10806. */
  10807. 'use strict';
  10808. var mouseListenerNames = {
  10809. onClick: true,
  10810. onDoubleClick: true,
  10811. onMouseDown: true,
  10812. onMouseMove: true,
  10813. onMouseUp: true,
  10814. onClickCapture: true,
  10815. onDoubleClickCapture: true,
  10816. onMouseDownCapture: true,
  10817. onMouseMoveCapture: true,
  10818. onMouseUpCapture: true
  10819. };
  10820. /**
  10821. * Implements a <button> native component that does not receive mouse events
  10822. * when `disabled` is set.
  10823. */
  10824. var ReactDOMButton = {
  10825. getNativeProps: function (inst, props, context) {
  10826. if (!props.disabled) {
  10827. return props;
  10828. }
  10829. // Copy the props, except the mouse listeners
  10830. var nativeProps = {};
  10831. for (var key in props) {
  10832. if (props.hasOwnProperty(key) && !mouseListenerNames[key]) {
  10833. nativeProps[key] = props[key];
  10834. }
  10835. }
  10836. return nativeProps;
  10837. }
  10838. };
  10839. module.exports = ReactDOMButton;
  10840. /***/ },
  10841. /* 105 */
  10842. /***/ function(module, exports, __webpack_require__) {
  10843. /* WEBPACK VAR INJECTION */(function(process) {/**
  10844. * Copyright 2013-2015, Facebook, Inc.
  10845. * All rights reserved.
  10846. *
  10847. * This source code is licensed under the BSD-style license found in the
  10848. * LICENSE file in the root directory of this source tree. An additional grant
  10849. * of patent rights can be found in the PATENTS file in the same directory.
  10850. *
  10851. * @providesModule ReactDOMInput
  10852. */
  10853. 'use strict';
  10854. var ReactDOMIDOperations = __webpack_require__(27);
  10855. var LinkedValueUtils = __webpack_require__(106);
  10856. var ReactMount = __webpack_require__(28);
  10857. var ReactUpdates = __webpack_require__(54);
  10858. var assign = __webpack_require__(39);
  10859. var invariant = __webpack_require__(13);
  10860. var instancesByReactID = {};
  10861. function forceUpdateIfMounted() {
  10862. if (this._rootNodeID) {
  10863. // DOM component is still mounted; update
  10864. ReactDOMInput.updateWrapper(this);
  10865. }
  10866. }
  10867. /**
  10868. * Implements an <input> native component that allows setting these optional
  10869. * props: `checked`, `value`, `defaultChecked`, and `defaultValue`.
  10870. *
  10871. * If `checked` or `value` are not supplied (or null/undefined), user actions
  10872. * that affect the checked state or value will trigger updates to the element.
  10873. *
  10874. * If they are supplied (and not null/undefined), the rendered element will not
  10875. * trigger updates to the element. Instead, the props must change in order for
  10876. * the rendered element to be updated.
  10877. *
  10878. * The rendered element will be initialized as unchecked (or `defaultChecked`)
  10879. * with an empty value (or `defaultValue`).
  10880. *
  10881. * @see http://www.w3.org/TR/2012/WD-html5-20121025/the-input-element.html
  10882. */
  10883. var ReactDOMInput = {
  10884. getNativeProps: function (inst, props, context) {
  10885. var value = LinkedValueUtils.getValue(props);
  10886. var checked = LinkedValueUtils.getChecked(props);
  10887. var nativeProps = assign({}, props, {
  10888. defaultChecked: undefined,
  10889. defaultValue: undefined,
  10890. value: value != null ? value : inst._wrapperState.initialValue,
  10891. checked: checked != null ? checked : inst._wrapperState.initialChecked,
  10892. onChange: inst._wrapperState.onChange
  10893. });
  10894. return nativeProps;
  10895. },
  10896. mountWrapper: function (inst, props) {
  10897. if (process.env.NODE_ENV !== 'production') {
  10898. LinkedValueUtils.checkPropTypes('input', props, inst._currentElement._owner);
  10899. }
  10900. var defaultValue = props.defaultValue;
  10901. inst._wrapperState = {
  10902. initialChecked: props.defaultChecked || false,
  10903. initialValue: defaultValue != null ? defaultValue : null,
  10904. onChange: _handleChange.bind(inst)
  10905. };
  10906. },
  10907. mountReadyWrapper: function (inst) {
  10908. // Can't be in mountWrapper or else server rendering leaks.
  10909. instancesByReactID[inst._rootNodeID] = inst;
  10910. },
  10911. unmountWrapper: function (inst) {
  10912. delete instancesByReactID[inst._rootNodeID];
  10913. },
  10914. updateWrapper: function (inst) {
  10915. var props = inst._currentElement.props;
  10916. // TODO: Shouldn't this be getChecked(props)?
  10917. var checked = props.checked;
  10918. if (checked != null) {
  10919. ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'checked', checked || false);
  10920. }
  10921. var value = LinkedValueUtils.getValue(props);
  10922. if (value != null) {
  10923. // Cast `value` to a string to ensure the value is set correctly. While
  10924. // browsers typically do this as necessary, jsdom doesn't.
  10925. ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'value', '' + value);
  10926. }
  10927. }
  10928. };
  10929. function _handleChange(event) {
  10930. var props = this._currentElement.props;
  10931. var returnValue = LinkedValueUtils.executeOnChange(props, event);
  10932. // Here we use asap to wait until all updates have propagated, which
  10933. // is important when using controlled components within layers:
  10934. // https://github.com/facebook/react/issues/1698
  10935. ReactUpdates.asap(forceUpdateIfMounted, this);
  10936. var name = props.name;
  10937. if (props.type === 'radio' && name != null) {
  10938. var rootNode = ReactMount.getNode(this._rootNodeID);
  10939. var queryRoot = rootNode;
  10940. while (queryRoot.parentNode) {
  10941. queryRoot = queryRoot.parentNode;
  10942. }
  10943. // If `rootNode.form` was non-null, then we could try `form.elements`,
  10944. // but that sometimes behaves strangely in IE8. We could also try using
  10945. // `form.getElementsByName`, but that will only return direct children
  10946. // and won't include inputs that use the HTML5 `form=` attribute. Since
  10947. // the input might not even be in a form, let's just use the global
  10948. // `querySelectorAll` to ensure we don't miss anything.
  10949. var group = queryRoot.querySelectorAll('input[name=' + JSON.stringify('' + name) + '][type="radio"]');
  10950. for (var i = 0; i < group.length; i++) {
  10951. var otherNode = group[i];
  10952. if (otherNode === rootNode || otherNode.form !== rootNode.form) {
  10953. continue;
  10954. }
  10955. // This will throw if radio buttons rendered by different copies of React
  10956. // and the same name are rendered into the same form (same as #1939).
  10957. // That's probably okay; we don't support it just as we don't support
  10958. // mixing React with non-React.
  10959. var otherID = ReactMount.getID(otherNode);
  10960. !otherID ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOMInput: Mixing React and non-React radio inputs with the ' + 'same `name` is not supported.') : invariant(false) : undefined;
  10961. var otherInstance = instancesByReactID[otherID];
  10962. !otherInstance ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactDOMInput: Unknown radio button ID %s.', otherID) : invariant(false) : undefined;
  10963. // If this is a controlled radio button group, forcing the input that
  10964. // was previously checked to update will cause it to be come re-checked
  10965. // as appropriate.
  10966. ReactUpdates.asap(forceUpdateIfMounted, otherInstance);
  10967. }
  10968. }
  10969. return returnValue;
  10970. }
  10971. module.exports = ReactDOMInput;
  10972. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  10973. /***/ },
  10974. /* 106 */
  10975. /***/ function(module, exports, __webpack_require__) {
  10976. /* WEBPACK VAR INJECTION */(function(process) {/**
  10977. * Copyright 2013-2015, Facebook, Inc.
  10978. * All rights reserved.
  10979. *
  10980. * This source code is licensed under the BSD-style license found in the
  10981. * LICENSE file in the root directory of this source tree. An additional grant
  10982. * of patent rights can be found in the PATENTS file in the same directory.
  10983. *
  10984. * @providesModule LinkedValueUtils
  10985. * @typechecks static-only
  10986. */
  10987. 'use strict';
  10988. var ReactPropTypes = __webpack_require__(107);
  10989. var ReactPropTypeLocations = __webpack_require__(65);
  10990. var invariant = __webpack_require__(13);
  10991. var warning = __webpack_require__(25);
  10992. var hasReadOnlyValue = {
  10993. 'button': true,
  10994. 'checkbox': true,
  10995. 'image': true,
  10996. 'hidden': true,
  10997. 'radio': true,
  10998. 'reset': true,
  10999. 'submit': true
  11000. };
  11001. function _assertSingleLink(inputProps) {
  11002. !(inputProps.checkedLink == null || inputProps.valueLink == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a valueLink. If you want to use ' + 'checkedLink, you probably don\'t want to use valueLink and vice versa.') : invariant(false) : undefined;
  11003. }
  11004. function _assertValueLink(inputProps) {
  11005. _assertSingleLink(inputProps);
  11006. !(inputProps.value == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a valueLink and a value or onChange event. If you want ' + 'to use value or onChange, you probably don\'t want to use valueLink.') : invariant(false) : undefined;
  11007. }
  11008. function _assertCheckedLink(inputProps) {
  11009. _assertSingleLink(inputProps);
  11010. !(inputProps.checked == null && inputProps.onChange == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Cannot provide a checkedLink and a checked property or onChange event. ' + 'If you want to use checked or onChange, you probably don\'t want to ' + 'use checkedLink') : invariant(false) : undefined;
  11011. }
  11012. var propTypes = {
  11013. value: function (props, propName, componentName) {
  11014. if (!props[propName] || hasReadOnlyValue[props.type] || props.onChange || props.readOnly || props.disabled) {
  11015. return null;
  11016. }
  11017. return new Error('You provided a `value` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultValue`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
  11018. },
  11019. checked: function (props, propName, componentName) {
  11020. if (!props[propName] || props.onChange || props.readOnly || props.disabled) {
  11021. return null;
  11022. }
  11023. return new Error('You provided a `checked` prop to a form field without an ' + '`onChange` handler. This will render a read-only field. If ' + 'the field should be mutable use `defaultChecked`. Otherwise, ' + 'set either `onChange` or `readOnly`.');
  11024. },
  11025. onChange: ReactPropTypes.func
  11026. };
  11027. var loggedTypeFailures = {};
  11028. function getDeclarationErrorAddendum(owner) {
  11029. if (owner) {
  11030. var name = owner.getName();
  11031. if (name) {
  11032. return ' Check the render method of `' + name + '`.';
  11033. }
  11034. }
  11035. return '';
  11036. }
  11037. /**
  11038. * Provide a linked `value` attribute for controlled forms. You should not use
  11039. * this outside of the ReactDOM controlled form components.
  11040. */
  11041. var LinkedValueUtils = {
  11042. checkPropTypes: function (tagName, props, owner) {
  11043. for (var propName in propTypes) {
  11044. if (propTypes.hasOwnProperty(propName)) {
  11045. var error = propTypes[propName](props, propName, tagName, ReactPropTypeLocations.prop);
  11046. }
  11047. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  11048. // Only monitor this failure once because there tends to be a lot of the
  11049. // same error.
  11050. loggedTypeFailures[error.message] = true;
  11051. var addendum = getDeclarationErrorAddendum(owner);
  11052. process.env.NODE_ENV !== 'production' ? warning(false, 'Failed form propType: %s%s', error.message, addendum) : undefined;
  11053. }
  11054. }
  11055. },
  11056. /**
  11057. * @param {object} inputProps Props for form component
  11058. * @return {*} current value of the input either from value prop or link.
  11059. */
  11060. getValue: function (inputProps) {
  11061. if (inputProps.valueLink) {
  11062. _assertValueLink(inputProps);
  11063. return inputProps.valueLink.value;
  11064. }
  11065. return inputProps.value;
  11066. },
  11067. /**
  11068. * @param {object} inputProps Props for form component
  11069. * @return {*} current checked status of the input either from checked prop
  11070. * or link.
  11071. */
  11072. getChecked: function (inputProps) {
  11073. if (inputProps.checkedLink) {
  11074. _assertCheckedLink(inputProps);
  11075. return inputProps.checkedLink.value;
  11076. }
  11077. return inputProps.checked;
  11078. },
  11079. /**
  11080. * @param {object} inputProps Props for form component
  11081. * @param {SyntheticEvent} event change event to handle
  11082. */
  11083. executeOnChange: function (inputProps, event) {
  11084. if (inputProps.valueLink) {
  11085. _assertValueLink(inputProps);
  11086. return inputProps.valueLink.requestChange(event.target.value);
  11087. } else if (inputProps.checkedLink) {
  11088. _assertCheckedLink(inputProps);
  11089. return inputProps.checkedLink.requestChange(event.target.checked);
  11090. } else if (inputProps.onChange) {
  11091. return inputProps.onChange.call(undefined, event);
  11092. }
  11093. }
  11094. };
  11095. module.exports = LinkedValueUtils;
  11096. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  11097. /***/ },
  11098. /* 107 */
  11099. /***/ function(module, exports, __webpack_require__) {
  11100. /**
  11101. * Copyright 2013-2015, Facebook, Inc.
  11102. * All rights reserved.
  11103. *
  11104. * This source code is licensed under the BSD-style license found in the
  11105. * LICENSE file in the root directory of this source tree. An additional grant
  11106. * of patent rights can be found in the PATENTS file in the same directory.
  11107. *
  11108. * @providesModule ReactPropTypes
  11109. */
  11110. 'use strict';
  11111. var ReactElement = __webpack_require__(42);
  11112. var ReactPropTypeLocationNames = __webpack_require__(66);
  11113. var emptyFunction = __webpack_require__(15);
  11114. var getIteratorFn = __webpack_require__(108);
  11115. /**
  11116. * Collection of methods that allow declaration and validation of props that are
  11117. * supplied to React components. Example usage:
  11118. *
  11119. * var Props = require('ReactPropTypes');
  11120. * var MyArticle = React.createClass({
  11121. * propTypes: {
  11122. * // An optional string prop named "description".
  11123. * description: Props.string,
  11124. *
  11125. * // A required enum prop named "category".
  11126. * category: Props.oneOf(['News','Photos']).isRequired,
  11127. *
  11128. * // A prop named "dialog" that requires an instance of Dialog.
  11129. * dialog: Props.instanceOf(Dialog).isRequired
  11130. * },
  11131. * render: function() { ... }
  11132. * });
  11133. *
  11134. * A more formal specification of how these methods are used:
  11135. *
  11136. * type := array|bool|func|object|number|string|oneOf([...])|instanceOf(...)
  11137. * decl := ReactPropTypes.{type}(.isRequired)?
  11138. *
  11139. * Each and every declaration produces a function with the same signature. This
  11140. * allows the creation of custom validation functions. For example:
  11141. *
  11142. * var MyLink = React.createClass({
  11143. * propTypes: {
  11144. * // An optional string or URI prop named "href".
  11145. * href: function(props, propName, componentName) {
  11146. * var propValue = props[propName];
  11147. * if (propValue != null && typeof propValue !== 'string' &&
  11148. * !(propValue instanceof URI)) {
  11149. * return new Error(
  11150. * 'Expected a string or an URI for ' + propName + ' in ' +
  11151. * componentName
  11152. * );
  11153. * }
  11154. * }
  11155. * },
  11156. * render: function() {...}
  11157. * });
  11158. *
  11159. * @internal
  11160. */
  11161. var ANONYMOUS = '<<anonymous>>';
  11162. var ReactPropTypes = {
  11163. array: createPrimitiveTypeChecker('array'),
  11164. bool: createPrimitiveTypeChecker('boolean'),
  11165. func: createPrimitiveTypeChecker('function'),
  11166. number: createPrimitiveTypeChecker('number'),
  11167. object: createPrimitiveTypeChecker('object'),
  11168. string: createPrimitiveTypeChecker('string'),
  11169. any: createAnyTypeChecker(),
  11170. arrayOf: createArrayOfTypeChecker,
  11171. element: createElementTypeChecker(),
  11172. instanceOf: createInstanceTypeChecker,
  11173. node: createNodeChecker(),
  11174. objectOf: createObjectOfTypeChecker,
  11175. oneOf: createEnumTypeChecker,
  11176. oneOfType: createUnionTypeChecker,
  11177. shape: createShapeTypeChecker
  11178. };
  11179. function createChainableTypeChecker(validate) {
  11180. function checkType(isRequired, props, propName, componentName, location, propFullName) {
  11181. componentName = componentName || ANONYMOUS;
  11182. propFullName = propFullName || propName;
  11183. if (props[propName] == null) {
  11184. var locationName = ReactPropTypeLocationNames[location];
  11185. if (isRequired) {
  11186. return new Error('Required ' + locationName + ' `' + propFullName + '` was not specified in ' + ('`' + componentName + '`.'));
  11187. }
  11188. return null;
  11189. } else {
  11190. return validate(props, propName, componentName, location, propFullName);
  11191. }
  11192. }
  11193. var chainedCheckType = checkType.bind(null, false);
  11194. chainedCheckType.isRequired = checkType.bind(null, true);
  11195. return chainedCheckType;
  11196. }
  11197. function createPrimitiveTypeChecker(expectedType) {
  11198. function validate(props, propName, componentName, location, propFullName) {
  11199. var propValue = props[propName];
  11200. var propType = getPropType(propValue);
  11201. if (propType !== expectedType) {
  11202. var locationName = ReactPropTypeLocationNames[location];
  11203. // `propValue` being instance of, say, date/regexp, pass the 'object'
  11204. // check, but we can offer a more precise error message here rather than
  11205. // 'of type `object`'.
  11206. var preciseType = getPreciseType(propValue);
  11207. return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + preciseType + '` supplied to `' + componentName + '`, expected ') + ('`' + expectedType + '`.'));
  11208. }
  11209. return null;
  11210. }
  11211. return createChainableTypeChecker(validate);
  11212. }
  11213. function createAnyTypeChecker() {
  11214. return createChainableTypeChecker(emptyFunction.thatReturns(null));
  11215. }
  11216. function createArrayOfTypeChecker(typeChecker) {
  11217. function validate(props, propName, componentName, location, propFullName) {
  11218. var propValue = props[propName];
  11219. if (!Array.isArray(propValue)) {
  11220. var locationName = ReactPropTypeLocationNames[location];
  11221. var propType = getPropType(propValue);
  11222. return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an array.'));
  11223. }
  11224. for (var i = 0; i < propValue.length; i++) {
  11225. var error = typeChecker(propValue, i, componentName, location, propFullName + '[' + i + ']');
  11226. if (error instanceof Error) {
  11227. return error;
  11228. }
  11229. }
  11230. return null;
  11231. }
  11232. return createChainableTypeChecker(validate);
  11233. }
  11234. function createElementTypeChecker() {
  11235. function validate(props, propName, componentName, location, propFullName) {
  11236. if (!ReactElement.isValidElement(props[propName])) {
  11237. var locationName = ReactPropTypeLocationNames[location];
  11238. return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a single ReactElement.'));
  11239. }
  11240. return null;
  11241. }
  11242. return createChainableTypeChecker(validate);
  11243. }
  11244. function createInstanceTypeChecker(expectedClass) {
  11245. function validate(props, propName, componentName, location, propFullName) {
  11246. if (!(props[propName] instanceof expectedClass)) {
  11247. var locationName = ReactPropTypeLocationNames[location];
  11248. var expectedClassName = expectedClass.name || ANONYMOUS;
  11249. var actualClassName = getClassName(props[propName]);
  11250. return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + actualClassName + '` supplied to `' + componentName + '`, expected ') + ('instance of `' + expectedClassName + '`.'));
  11251. }
  11252. return null;
  11253. }
  11254. return createChainableTypeChecker(validate);
  11255. }
  11256. function createEnumTypeChecker(expectedValues) {
  11257. if (!Array.isArray(expectedValues)) {
  11258. return createChainableTypeChecker(function () {
  11259. return new Error('Invalid argument supplied to oneOf, expected an instance of array.');
  11260. });
  11261. }
  11262. function validate(props, propName, componentName, location, propFullName) {
  11263. var propValue = props[propName];
  11264. for (var i = 0; i < expectedValues.length; i++) {
  11265. if (propValue === expectedValues[i]) {
  11266. return null;
  11267. }
  11268. }
  11269. var locationName = ReactPropTypeLocationNames[location];
  11270. var valuesString = JSON.stringify(expectedValues);
  11271. return new Error('Invalid ' + locationName + ' `' + propFullName + '` of value `' + propValue + '` ' + ('supplied to `' + componentName + '`, expected one of ' + valuesString + '.'));
  11272. }
  11273. return createChainableTypeChecker(validate);
  11274. }
  11275. function createObjectOfTypeChecker(typeChecker) {
  11276. function validate(props, propName, componentName, location, propFullName) {
  11277. var propValue = props[propName];
  11278. var propType = getPropType(propValue);
  11279. if (propType !== 'object') {
  11280. var locationName = ReactPropTypeLocationNames[location];
  11281. return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type ' + ('`' + propType + '` supplied to `' + componentName + '`, expected an object.'));
  11282. }
  11283. for (var key in propValue) {
  11284. if (propValue.hasOwnProperty(key)) {
  11285. var error = typeChecker(propValue, key, componentName, location, propFullName + '.' + key);
  11286. if (error instanceof Error) {
  11287. return error;
  11288. }
  11289. }
  11290. }
  11291. return null;
  11292. }
  11293. return createChainableTypeChecker(validate);
  11294. }
  11295. function createUnionTypeChecker(arrayOfTypeCheckers) {
  11296. if (!Array.isArray(arrayOfTypeCheckers)) {
  11297. return createChainableTypeChecker(function () {
  11298. return new Error('Invalid argument supplied to oneOfType, expected an instance of array.');
  11299. });
  11300. }
  11301. function validate(props, propName, componentName, location, propFullName) {
  11302. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  11303. var checker = arrayOfTypeCheckers[i];
  11304. if (checker(props, propName, componentName, location, propFullName) == null) {
  11305. return null;
  11306. }
  11307. }
  11308. var locationName = ReactPropTypeLocationNames[location];
  11309. return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`.'));
  11310. }
  11311. return createChainableTypeChecker(validate);
  11312. }
  11313. function createNodeChecker() {
  11314. function validate(props, propName, componentName, location, propFullName) {
  11315. if (!isNode(props[propName])) {
  11316. var locationName = ReactPropTypeLocationNames[location];
  11317. return new Error('Invalid ' + locationName + ' `' + propFullName + '` supplied to ' + ('`' + componentName + '`, expected a ReactNode.'));
  11318. }
  11319. return null;
  11320. }
  11321. return createChainableTypeChecker(validate);
  11322. }
  11323. function createShapeTypeChecker(shapeTypes) {
  11324. function validate(props, propName, componentName, location, propFullName) {
  11325. var propValue = props[propName];
  11326. var propType = getPropType(propValue);
  11327. if (propType !== 'object') {
  11328. var locationName = ReactPropTypeLocationNames[location];
  11329. return new Error('Invalid ' + locationName + ' `' + propFullName + '` of type `' + propType + '` ' + ('supplied to `' + componentName + '`, expected `object`.'));
  11330. }
  11331. for (var key in shapeTypes) {
  11332. var checker = shapeTypes[key];
  11333. if (!checker) {
  11334. continue;
  11335. }
  11336. var error = checker(propValue, key, componentName, location, propFullName + '.' + key);
  11337. if (error) {
  11338. return error;
  11339. }
  11340. }
  11341. return null;
  11342. }
  11343. return createChainableTypeChecker(validate);
  11344. }
  11345. function isNode(propValue) {
  11346. switch (typeof propValue) {
  11347. case 'number':
  11348. case 'string':
  11349. case 'undefined':
  11350. return true;
  11351. case 'boolean':
  11352. return !propValue;
  11353. case 'object':
  11354. if (Array.isArray(propValue)) {
  11355. return propValue.every(isNode);
  11356. }
  11357. if (propValue === null || ReactElement.isValidElement(propValue)) {
  11358. return true;
  11359. }
  11360. var iteratorFn = getIteratorFn(propValue);
  11361. if (iteratorFn) {
  11362. var iterator = iteratorFn.call(propValue);
  11363. var step;
  11364. if (iteratorFn !== propValue.entries) {
  11365. while (!(step = iterator.next()).done) {
  11366. if (!isNode(step.value)) {
  11367. return false;
  11368. }
  11369. }
  11370. } else {
  11371. // Iterator will provide entry [k,v] tuples rather than values.
  11372. while (!(step = iterator.next()).done) {
  11373. var entry = step.value;
  11374. if (entry) {
  11375. if (!isNode(entry[1])) {
  11376. return false;
  11377. }
  11378. }
  11379. }
  11380. }
  11381. } else {
  11382. return false;
  11383. }
  11384. return true;
  11385. default:
  11386. return false;
  11387. }
  11388. }
  11389. // Equivalent of `typeof` but with special handling for array and regexp.
  11390. function getPropType(propValue) {
  11391. var propType = typeof propValue;
  11392. if (Array.isArray(propValue)) {
  11393. return 'array';
  11394. }
  11395. if (propValue instanceof RegExp) {
  11396. // Old webkits (at least until Android 4.0) return 'function' rather than
  11397. // 'object' for typeof a RegExp. We'll normalize this here so that /bla/
  11398. // passes PropTypes.object.
  11399. return 'object';
  11400. }
  11401. return propType;
  11402. }
  11403. // This handles more types than `getPropType`. Only used for error messages.
  11404. // See `createPrimitiveTypeChecker`.
  11405. function getPreciseType(propValue) {
  11406. var propType = getPropType(propValue);
  11407. if (propType === 'object') {
  11408. if (propValue instanceof Date) {
  11409. return 'date';
  11410. } else if (propValue instanceof RegExp) {
  11411. return 'regexp';
  11412. }
  11413. }
  11414. return propType;
  11415. }
  11416. // Returns class name of the object, if any.
  11417. function getClassName(propValue) {
  11418. if (!propValue.constructor || !propValue.constructor.name) {
  11419. return '<<anonymous>>';
  11420. }
  11421. return propValue.constructor.name;
  11422. }
  11423. module.exports = ReactPropTypes;
  11424. /***/ },
  11425. /* 108 */
  11426. /***/ function(module, exports) {
  11427. /**
  11428. * Copyright 2013-2015, Facebook, Inc.
  11429. * All rights reserved.
  11430. *
  11431. * This source code is licensed under the BSD-style license found in the
  11432. * LICENSE file in the root directory of this source tree. An additional grant
  11433. * of patent rights can be found in the PATENTS file in the same directory.
  11434. *
  11435. * @providesModule getIteratorFn
  11436. * @typechecks static-only
  11437. */
  11438. 'use strict';
  11439. /* global Symbol */
  11440. var ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  11441. var FAUX_ITERATOR_SYMBOL = '@@iterator'; // Before Symbol spec.
  11442. /**
  11443. * Returns the iterator method function contained on the iterable object.
  11444. *
  11445. * Be sure to invoke the function with the iterable as context:
  11446. *
  11447. * var iteratorFn = getIteratorFn(myIterable);
  11448. * if (iteratorFn) {
  11449. * var iterator = iteratorFn.call(myIterable);
  11450. * ...
  11451. * }
  11452. *
  11453. * @param {?object} maybeIterable
  11454. * @return {?function}
  11455. */
  11456. function getIteratorFn(maybeIterable) {
  11457. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  11458. if (typeof iteratorFn === 'function') {
  11459. return iteratorFn;
  11460. }
  11461. }
  11462. module.exports = getIteratorFn;
  11463. /***/ },
  11464. /* 109 */
  11465. /***/ function(module, exports, __webpack_require__) {
  11466. /* WEBPACK VAR INJECTION */(function(process) {/**
  11467. * Copyright 2013-2015, Facebook, Inc.
  11468. * All rights reserved.
  11469. *
  11470. * This source code is licensed under the BSD-style license found in the
  11471. * LICENSE file in the root directory of this source tree. An additional grant
  11472. * of patent rights can be found in the PATENTS file in the same directory.
  11473. *
  11474. * @providesModule ReactDOMOption
  11475. */
  11476. 'use strict';
  11477. var ReactChildren = __webpack_require__(110);
  11478. var ReactDOMSelect = __webpack_require__(112);
  11479. var assign = __webpack_require__(39);
  11480. var warning = __webpack_require__(25);
  11481. var valueContextKey = ReactDOMSelect.valueContextKey;
  11482. /**
  11483. * Implements an <option> native component that warns when `selected` is set.
  11484. */
  11485. var ReactDOMOption = {
  11486. mountWrapper: function (inst, props, context) {
  11487. // TODO (yungsters): Remove support for `selected` in <option>.
  11488. if (process.env.NODE_ENV !== 'production') {
  11489. process.env.NODE_ENV !== 'production' ? warning(props.selected == null, 'Use the `defaultValue` or `value` props on <select> instead of ' + 'setting `selected` on <option>.') : undefined;
  11490. }
  11491. // Look up whether this option is 'selected' via context
  11492. var selectValue = context[valueContextKey];
  11493. // If context key is null (e.g., no specified value or after initial mount)
  11494. // or missing (e.g., for <datalist>), we don't change props.selected
  11495. var selected = null;
  11496. if (selectValue != null) {
  11497. selected = false;
  11498. if (Array.isArray(selectValue)) {
  11499. // multiple
  11500. for (var i = 0; i < selectValue.length; i++) {
  11501. if ('' + selectValue[i] === '' + props.value) {
  11502. selected = true;
  11503. break;
  11504. }
  11505. }
  11506. } else {
  11507. selected = '' + selectValue === '' + props.value;
  11508. }
  11509. }
  11510. inst._wrapperState = { selected: selected };
  11511. },
  11512. getNativeProps: function (inst, props, context) {
  11513. var nativeProps = assign({ selected: undefined, children: undefined }, props);
  11514. // Read state only from initial mount because <select> updates value
  11515. // manually; we need the initial state only for server rendering
  11516. if (inst._wrapperState.selected != null) {
  11517. nativeProps.selected = inst._wrapperState.selected;
  11518. }
  11519. var content = '';
  11520. // Flatten children and warn if they aren't strings or numbers;
  11521. // invalid types are ignored.
  11522. ReactChildren.forEach(props.children, function (child) {
  11523. if (child == null) {
  11524. return;
  11525. }
  11526. if (typeof child === 'string' || typeof child === 'number') {
  11527. content += child;
  11528. } else {
  11529. process.env.NODE_ENV !== 'production' ? warning(false, 'Only strings and numbers are supported as <option> children.') : undefined;
  11530. }
  11531. });
  11532. if (content) {
  11533. nativeProps.children = content;
  11534. }
  11535. return nativeProps;
  11536. }
  11537. };
  11538. module.exports = ReactDOMOption;
  11539. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  11540. /***/ },
  11541. /* 110 */
  11542. /***/ function(module, exports, __webpack_require__) {
  11543. /**
  11544. * Copyright 2013-2015, Facebook, Inc.
  11545. * All rights reserved.
  11546. *
  11547. * This source code is licensed under the BSD-style license found in the
  11548. * LICENSE file in the root directory of this source tree. An additional grant
  11549. * of patent rights can be found in the PATENTS file in the same directory.
  11550. *
  11551. * @providesModule ReactChildren
  11552. */
  11553. 'use strict';
  11554. var PooledClass = __webpack_require__(56);
  11555. var ReactElement = __webpack_require__(42);
  11556. var emptyFunction = __webpack_require__(15);
  11557. var traverseAllChildren = __webpack_require__(111);
  11558. var twoArgumentPooler = PooledClass.twoArgumentPooler;
  11559. var fourArgumentPooler = PooledClass.fourArgumentPooler;
  11560. var userProvidedKeyEscapeRegex = /\/(?!\/)/g;
  11561. function escapeUserProvidedKey(text) {
  11562. return ('' + text).replace(userProvidedKeyEscapeRegex, '//');
  11563. }
  11564. /**
  11565. * PooledClass representing the bookkeeping associated with performing a child
  11566. * traversal. Allows avoiding binding callbacks.
  11567. *
  11568. * @constructor ForEachBookKeeping
  11569. * @param {!function} forEachFunction Function to perform traversal with.
  11570. * @param {?*} forEachContext Context to perform context with.
  11571. */
  11572. function ForEachBookKeeping(forEachFunction, forEachContext) {
  11573. this.func = forEachFunction;
  11574. this.context = forEachContext;
  11575. this.count = 0;
  11576. }
  11577. ForEachBookKeeping.prototype.destructor = function () {
  11578. this.func = null;
  11579. this.context = null;
  11580. this.count = 0;
  11581. };
  11582. PooledClass.addPoolingTo(ForEachBookKeeping, twoArgumentPooler);
  11583. function forEachSingleChild(bookKeeping, child, name) {
  11584. var func = bookKeeping.func;
  11585. var context = bookKeeping.context;
  11586. func.call(context, child, bookKeeping.count++);
  11587. }
  11588. /**
  11589. * Iterates through children that are typically specified as `props.children`.
  11590. *
  11591. * The provided forEachFunc(child, index) will be called for each
  11592. * leaf child.
  11593. *
  11594. * @param {?*} children Children tree container.
  11595. * @param {function(*, int)} forEachFunc
  11596. * @param {*} forEachContext Context for forEachContext.
  11597. */
  11598. function forEachChildren(children, forEachFunc, forEachContext) {
  11599. if (children == null) {
  11600. return children;
  11601. }
  11602. var traverseContext = ForEachBookKeeping.getPooled(forEachFunc, forEachContext);
  11603. traverseAllChildren(children, forEachSingleChild, traverseContext);
  11604. ForEachBookKeeping.release(traverseContext);
  11605. }
  11606. /**
  11607. * PooledClass representing the bookkeeping associated with performing a child
  11608. * mapping. Allows avoiding binding callbacks.
  11609. *
  11610. * @constructor MapBookKeeping
  11611. * @param {!*} mapResult Object containing the ordered map of results.
  11612. * @param {!function} mapFunction Function to perform mapping with.
  11613. * @param {?*} mapContext Context to perform mapping with.
  11614. */
  11615. function MapBookKeeping(mapResult, keyPrefix, mapFunction, mapContext) {
  11616. this.result = mapResult;
  11617. this.keyPrefix = keyPrefix;
  11618. this.func = mapFunction;
  11619. this.context = mapContext;
  11620. this.count = 0;
  11621. }
  11622. MapBookKeeping.prototype.destructor = function () {
  11623. this.result = null;
  11624. this.keyPrefix = null;
  11625. this.func = null;
  11626. this.context = null;
  11627. this.count = 0;
  11628. };
  11629. PooledClass.addPoolingTo(MapBookKeeping, fourArgumentPooler);
  11630. function mapSingleChildIntoContext(bookKeeping, child, childKey) {
  11631. var result = bookKeeping.result;
  11632. var keyPrefix = bookKeeping.keyPrefix;
  11633. var func = bookKeeping.func;
  11634. var context = bookKeeping.context;
  11635. var mappedChild = func.call(context, child, bookKeeping.count++);
  11636. if (Array.isArray(mappedChild)) {
  11637. mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, emptyFunction.thatReturnsArgument);
  11638. } else if (mappedChild != null) {
  11639. if (ReactElement.isValidElement(mappedChild)) {
  11640. mappedChild = ReactElement.cloneAndReplaceKey(mappedChild,
  11641. // Keep both the (mapped) and old keys if they differ, just as
  11642. // traverseAllChildren used to do for objects as children
  11643. keyPrefix + (mappedChild !== child ? escapeUserProvidedKey(mappedChild.key || '') + '/' : '') + childKey);
  11644. }
  11645. result.push(mappedChild);
  11646. }
  11647. }
  11648. function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
  11649. var escapedPrefix = '';
  11650. if (prefix != null) {
  11651. escapedPrefix = escapeUserProvidedKey(prefix) + '/';
  11652. }
  11653. var traverseContext = MapBookKeeping.getPooled(array, escapedPrefix, func, context);
  11654. traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
  11655. MapBookKeeping.release(traverseContext);
  11656. }
  11657. /**
  11658. * Maps children that are typically specified as `props.children`.
  11659. *
  11660. * The provided mapFunction(child, key, index) will be called for each
  11661. * leaf child.
  11662. *
  11663. * @param {?*} children Children tree container.
  11664. * @param {function(*, int)} func The map function.
  11665. * @param {*} context Context for mapFunction.
  11666. * @return {object} Object containing the ordered map of results.
  11667. */
  11668. function mapChildren(children, func, context) {
  11669. if (children == null) {
  11670. return children;
  11671. }
  11672. var result = [];
  11673. mapIntoWithKeyPrefixInternal(children, result, null, func, context);
  11674. return result;
  11675. }
  11676. function forEachSingleChildDummy(traverseContext, child, name) {
  11677. return null;
  11678. }
  11679. /**
  11680. * Count the number of children that are typically specified as
  11681. * `props.children`.
  11682. *
  11683. * @param {?*} children Children tree container.
  11684. * @return {number} The number of children.
  11685. */
  11686. function countChildren(children, context) {
  11687. return traverseAllChildren(children, forEachSingleChildDummy, null);
  11688. }
  11689. /**
  11690. * Flatten a children object (typically specified as `props.children`) and
  11691. * return an array with appropriately re-keyed children.
  11692. */
  11693. function toArray(children) {
  11694. var result = [];
  11695. mapIntoWithKeyPrefixInternal(children, result, null, emptyFunction.thatReturnsArgument);
  11696. return result;
  11697. }
  11698. var ReactChildren = {
  11699. forEach: forEachChildren,
  11700. map: mapChildren,
  11701. mapIntoWithKeyPrefixInternal: mapIntoWithKeyPrefixInternal,
  11702. count: countChildren,
  11703. toArray: toArray
  11704. };
  11705. module.exports = ReactChildren;
  11706. /***/ },
  11707. /* 111 */
  11708. /***/ function(module, exports, __webpack_require__) {
  11709. /* WEBPACK VAR INJECTION */(function(process) {/**
  11710. * Copyright 2013-2015, Facebook, Inc.
  11711. * All rights reserved.
  11712. *
  11713. * This source code is licensed under the BSD-style license found in the
  11714. * LICENSE file in the root directory of this source tree. An additional grant
  11715. * of patent rights can be found in the PATENTS file in the same directory.
  11716. *
  11717. * @providesModule traverseAllChildren
  11718. */
  11719. 'use strict';
  11720. var ReactCurrentOwner = __webpack_require__(5);
  11721. var ReactElement = __webpack_require__(42);
  11722. var ReactInstanceHandles = __webpack_require__(45);
  11723. var getIteratorFn = __webpack_require__(108);
  11724. var invariant = __webpack_require__(13);
  11725. var warning = __webpack_require__(25);
  11726. var SEPARATOR = ReactInstanceHandles.SEPARATOR;
  11727. var SUBSEPARATOR = ':';
  11728. /**
  11729. * TODO: Test that a single child and an array with one item have the same key
  11730. * pattern.
  11731. */
  11732. var userProvidedKeyEscaperLookup = {
  11733. '=': '=0',
  11734. '.': '=1',
  11735. ':': '=2'
  11736. };
  11737. var userProvidedKeyEscapeRegex = /[=.:]/g;
  11738. var didWarnAboutMaps = false;
  11739. function userProvidedKeyEscaper(match) {
  11740. return userProvidedKeyEscaperLookup[match];
  11741. }
  11742. /**
  11743. * Generate a key string that identifies a component within a set.
  11744. *
  11745. * @param {*} component A component that could contain a manual key.
  11746. * @param {number} index Index that is used if a manual key is not provided.
  11747. * @return {string}
  11748. */
  11749. function getComponentKey(component, index) {
  11750. if (component && component.key != null) {
  11751. // Explicit key
  11752. return wrapUserProvidedKey(component.key);
  11753. }
  11754. // Implicit key determined by the index in the set
  11755. return index.toString(36);
  11756. }
  11757. /**
  11758. * Escape a component key so that it is safe to use in a reactid.
  11759. *
  11760. * @param {*} text Component key to be escaped.
  11761. * @return {string} An escaped string.
  11762. */
  11763. function escapeUserProvidedKey(text) {
  11764. return ('' + text).replace(userProvidedKeyEscapeRegex, userProvidedKeyEscaper);
  11765. }
  11766. /**
  11767. * Wrap a `key` value explicitly provided by the user to distinguish it from
  11768. * implicitly-generated keys generated by a component's index in its parent.
  11769. *
  11770. * @param {string} key Value of a user-provided `key` attribute
  11771. * @return {string}
  11772. */
  11773. function wrapUserProvidedKey(key) {
  11774. return '$' + escapeUserProvidedKey(key);
  11775. }
  11776. /**
  11777. * @param {?*} children Children tree container.
  11778. * @param {!string} nameSoFar Name of the key path so far.
  11779. * @param {!function} callback Callback to invoke with each child found.
  11780. * @param {?*} traverseContext Used to pass information throughout the traversal
  11781. * process.
  11782. * @return {!number} The number of children in this subtree.
  11783. */
  11784. function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
  11785. var type = typeof children;
  11786. if (type === 'undefined' || type === 'boolean') {
  11787. // All of the above are perceived as null.
  11788. children = null;
  11789. }
  11790. if (children === null || type === 'string' || type === 'number' || ReactElement.isValidElement(children)) {
  11791. callback(traverseContext, children,
  11792. // If it's the only child, treat the name as if it was wrapped in an array
  11793. // so that it's consistent if the number of children grows.
  11794. nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
  11795. return 1;
  11796. }
  11797. var child;
  11798. var nextName;
  11799. var subtreeCount = 0; // Count of children found in the current subtree.
  11800. var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
  11801. if (Array.isArray(children)) {
  11802. for (var i = 0; i < children.length; i++) {
  11803. child = children[i];
  11804. nextName = nextNamePrefix + getComponentKey(child, i);
  11805. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  11806. }
  11807. } else {
  11808. var iteratorFn = getIteratorFn(children);
  11809. if (iteratorFn) {
  11810. var iterator = iteratorFn.call(children);
  11811. var step;
  11812. if (iteratorFn !== children.entries) {
  11813. var ii = 0;
  11814. while (!(step = iterator.next()).done) {
  11815. child = step.value;
  11816. nextName = nextNamePrefix + getComponentKey(child, ii++);
  11817. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  11818. }
  11819. } else {
  11820. if (process.env.NODE_ENV !== 'production') {
  11821. process.env.NODE_ENV !== 'production' ? warning(didWarnAboutMaps, 'Using Maps as children is not yet fully supported. It is an ' + 'experimental feature that might be removed. Convert it to a ' + 'sequence / iterable of keyed ReactElements instead.') : undefined;
  11822. didWarnAboutMaps = true;
  11823. }
  11824. // Iterator will provide entry [k,v] tuples rather than values.
  11825. while (!(step = iterator.next()).done) {
  11826. var entry = step.value;
  11827. if (entry) {
  11828. child = entry[1];
  11829. nextName = nextNamePrefix + wrapUserProvidedKey(entry[0]) + SUBSEPARATOR + getComponentKey(child, 0);
  11830. subtreeCount += traverseAllChildrenImpl(child, nextName, callback, traverseContext);
  11831. }
  11832. }
  11833. }
  11834. } else if (type === 'object') {
  11835. var addendum = '';
  11836. if (process.env.NODE_ENV !== 'production') {
  11837. addendum = ' If you meant to render a collection of children, use an array ' + 'instead or wrap the object using createFragment(object) from the ' + 'React add-ons.';
  11838. if (children._isReactElement) {
  11839. addendum = ' It looks like you\'re using an element created by a different ' + 'version of React. Make sure to use only one copy of React.';
  11840. }
  11841. if (ReactCurrentOwner.current) {
  11842. var name = ReactCurrentOwner.current.getName();
  11843. if (name) {
  11844. addendum += ' Check the render method of `' + name + '`.';
  11845. }
  11846. }
  11847. }
  11848. var childrenString = String(children);
  11849. true ? process.env.NODE_ENV !== 'production' ? invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum) : invariant(false) : undefined;
  11850. }
  11851. }
  11852. return subtreeCount;
  11853. }
  11854. /**
  11855. * Traverses children that are typically specified as `props.children`, but
  11856. * might also be specified through attributes:
  11857. *
  11858. * - `traverseAllChildren(this.props.children, ...)`
  11859. * - `traverseAllChildren(this.props.leftPanelChildren, ...)`
  11860. *
  11861. * The `traverseContext` is an optional argument that is passed through the
  11862. * entire traversal. It can be used to store accumulations or anything else that
  11863. * the callback might find relevant.
  11864. *
  11865. * @param {?*} children Children tree object.
  11866. * @param {!function} callback To invoke upon traversing each child.
  11867. * @param {?*} traverseContext Context for traversal.
  11868. * @return {!number} The number of children in this subtree.
  11869. */
  11870. function traverseAllChildren(children, callback, traverseContext) {
  11871. if (children == null) {
  11872. return 0;
  11873. }
  11874. return traverseAllChildrenImpl(children, '', callback, traverseContext);
  11875. }
  11876. module.exports = traverseAllChildren;
  11877. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  11878. /***/ },
  11879. /* 112 */
  11880. /***/ function(module, exports, __webpack_require__) {
  11881. /* WEBPACK VAR INJECTION */(function(process) {/**
  11882. * Copyright 2013-2015, Facebook, Inc.
  11883. * All rights reserved.
  11884. *
  11885. * This source code is licensed under the BSD-style license found in the
  11886. * LICENSE file in the root directory of this source tree. An additional grant
  11887. * of patent rights can be found in the PATENTS file in the same directory.
  11888. *
  11889. * @providesModule ReactDOMSelect
  11890. */
  11891. 'use strict';
  11892. var LinkedValueUtils = __webpack_require__(106);
  11893. var ReactMount = __webpack_require__(28);
  11894. var ReactUpdates = __webpack_require__(54);
  11895. var assign = __webpack_require__(39);
  11896. var warning = __webpack_require__(25);
  11897. var valueContextKey = '__ReactDOMSelect_value$' + Math.random().toString(36).slice(2);
  11898. function updateOptionsIfPendingUpdateAndMounted() {
  11899. if (this._rootNodeID && this._wrapperState.pendingUpdate) {
  11900. this._wrapperState.pendingUpdate = false;
  11901. var props = this._currentElement.props;
  11902. var value = LinkedValueUtils.getValue(props);
  11903. if (value != null) {
  11904. updateOptions(this, Boolean(props.multiple), value);
  11905. }
  11906. }
  11907. }
  11908. function getDeclarationErrorAddendum(owner) {
  11909. if (owner) {
  11910. var name = owner.getName();
  11911. if (name) {
  11912. return ' Check the render method of `' + name + '`.';
  11913. }
  11914. }
  11915. return '';
  11916. }
  11917. var valuePropNames = ['value', 'defaultValue'];
  11918. /**
  11919. * Validation function for `value` and `defaultValue`.
  11920. * @private
  11921. */
  11922. function checkSelectPropTypes(inst, props) {
  11923. var owner = inst._currentElement._owner;
  11924. LinkedValueUtils.checkPropTypes('select', props, owner);
  11925. for (var i = 0; i < valuePropNames.length; i++) {
  11926. var propName = valuePropNames[i];
  11927. if (props[propName] == null) {
  11928. continue;
  11929. }
  11930. if (props.multiple) {
  11931. process.env.NODE_ENV !== 'production' ? warning(Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be an array if ' + '`multiple` is true.%s', propName, getDeclarationErrorAddendum(owner)) : undefined;
  11932. } else {
  11933. process.env.NODE_ENV !== 'production' ? warning(!Array.isArray(props[propName]), 'The `%s` prop supplied to <select> must be a scalar ' + 'value if `multiple` is false.%s', propName, getDeclarationErrorAddendum(owner)) : undefined;
  11934. }
  11935. }
  11936. }
  11937. /**
  11938. * @param {ReactDOMComponent} inst
  11939. * @param {boolean} multiple
  11940. * @param {*} propValue A stringable (with `multiple`, a list of stringables).
  11941. * @private
  11942. */
  11943. function updateOptions(inst, multiple, propValue) {
  11944. var selectedValue, i;
  11945. var options = ReactMount.getNode(inst._rootNodeID).options;
  11946. if (multiple) {
  11947. selectedValue = {};
  11948. for (i = 0; i < propValue.length; i++) {
  11949. selectedValue['' + propValue[i]] = true;
  11950. }
  11951. for (i = 0; i < options.length; i++) {
  11952. var selected = selectedValue.hasOwnProperty(options[i].value);
  11953. if (options[i].selected !== selected) {
  11954. options[i].selected = selected;
  11955. }
  11956. }
  11957. } else {
  11958. // Do not set `select.value` as exact behavior isn't consistent across all
  11959. // browsers for all cases.
  11960. selectedValue = '' + propValue;
  11961. for (i = 0; i < options.length; i++) {
  11962. if (options[i].value === selectedValue) {
  11963. options[i].selected = true;
  11964. return;
  11965. }
  11966. }
  11967. if (options.length) {
  11968. options[0].selected = true;
  11969. }
  11970. }
  11971. }
  11972. /**
  11973. * Implements a <select> native component that allows optionally setting the
  11974. * props `value` and `defaultValue`. If `multiple` is false, the prop must be a
  11975. * stringable. If `multiple` is true, the prop must be an array of stringables.
  11976. *
  11977. * If `value` is not supplied (or null/undefined), user actions that change the
  11978. * selected option will trigger updates to the rendered options.
  11979. *
  11980. * If it is supplied (and not null/undefined), the rendered options will not
  11981. * update in response to user actions. Instead, the `value` prop must change in
  11982. * order for the rendered options to update.
  11983. *
  11984. * If `defaultValue` is provided, any options with the supplied values will be
  11985. * selected.
  11986. */
  11987. var ReactDOMSelect = {
  11988. valueContextKey: valueContextKey,
  11989. getNativeProps: function (inst, props, context) {
  11990. return assign({}, props, {
  11991. onChange: inst._wrapperState.onChange,
  11992. value: undefined
  11993. });
  11994. },
  11995. mountWrapper: function (inst, props) {
  11996. if (process.env.NODE_ENV !== 'production') {
  11997. checkSelectPropTypes(inst, props);
  11998. }
  11999. var value = LinkedValueUtils.getValue(props);
  12000. inst._wrapperState = {
  12001. pendingUpdate: false,
  12002. initialValue: value != null ? value : props.defaultValue,
  12003. onChange: _handleChange.bind(inst),
  12004. wasMultiple: Boolean(props.multiple)
  12005. };
  12006. },
  12007. processChildContext: function (inst, props, context) {
  12008. // Pass down initial value so initial generated markup has correct
  12009. // `selected` attributes
  12010. var childContext = assign({}, context);
  12011. childContext[valueContextKey] = inst._wrapperState.initialValue;
  12012. return childContext;
  12013. },
  12014. postUpdateWrapper: function (inst) {
  12015. var props = inst._currentElement.props;
  12016. // After the initial mount, we control selected-ness manually so don't pass
  12017. // the context value down
  12018. inst._wrapperState.initialValue = undefined;
  12019. var wasMultiple = inst._wrapperState.wasMultiple;
  12020. inst._wrapperState.wasMultiple = Boolean(props.multiple);
  12021. var value = LinkedValueUtils.getValue(props);
  12022. if (value != null) {
  12023. inst._wrapperState.pendingUpdate = false;
  12024. updateOptions(inst, Boolean(props.multiple), value);
  12025. } else if (wasMultiple !== Boolean(props.multiple)) {
  12026. // For simplicity, reapply `defaultValue` if `multiple` is toggled.
  12027. if (props.defaultValue != null) {
  12028. updateOptions(inst, Boolean(props.multiple), props.defaultValue);
  12029. } else {
  12030. // Revert the select back to its default unselected state.
  12031. updateOptions(inst, Boolean(props.multiple), props.multiple ? [] : '');
  12032. }
  12033. }
  12034. }
  12035. };
  12036. function _handleChange(event) {
  12037. var props = this._currentElement.props;
  12038. var returnValue = LinkedValueUtils.executeOnChange(props, event);
  12039. this._wrapperState.pendingUpdate = true;
  12040. ReactUpdates.asap(updateOptionsIfPendingUpdateAndMounted, this);
  12041. return returnValue;
  12042. }
  12043. module.exports = ReactDOMSelect;
  12044. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  12045. /***/ },
  12046. /* 113 */
  12047. /***/ function(module, exports, __webpack_require__) {
  12048. /* WEBPACK VAR INJECTION */(function(process) {/**
  12049. * Copyright 2013-2015, Facebook, Inc.
  12050. * All rights reserved.
  12051. *
  12052. * This source code is licensed under the BSD-style license found in the
  12053. * LICENSE file in the root directory of this source tree. An additional grant
  12054. * of patent rights can be found in the PATENTS file in the same directory.
  12055. *
  12056. * @providesModule ReactDOMTextarea
  12057. */
  12058. 'use strict';
  12059. var LinkedValueUtils = __webpack_require__(106);
  12060. var ReactDOMIDOperations = __webpack_require__(27);
  12061. var ReactUpdates = __webpack_require__(54);
  12062. var assign = __webpack_require__(39);
  12063. var invariant = __webpack_require__(13);
  12064. var warning = __webpack_require__(25);
  12065. function forceUpdateIfMounted() {
  12066. if (this._rootNodeID) {
  12067. // DOM component is still mounted; update
  12068. ReactDOMTextarea.updateWrapper(this);
  12069. }
  12070. }
  12071. /**
  12072. * Implements a <textarea> native component that allows setting `value`, and
  12073. * `defaultValue`. This differs from the traditional DOM API because value is
  12074. * usually set as PCDATA children.
  12075. *
  12076. * If `value` is not supplied (or null/undefined), user actions that affect the
  12077. * value will trigger updates to the element.
  12078. *
  12079. * If `value` is supplied (and not null/undefined), the rendered element will
  12080. * not trigger updates to the element. Instead, the `value` prop must change in
  12081. * order for the rendered element to be updated.
  12082. *
  12083. * The rendered element will be initialized with an empty value, the prop
  12084. * `defaultValue` if specified, or the children content (deprecated).
  12085. */
  12086. var ReactDOMTextarea = {
  12087. getNativeProps: function (inst, props, context) {
  12088. !(props.dangerouslySetInnerHTML == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, '`dangerouslySetInnerHTML` does not make sense on <textarea>.') : invariant(false) : undefined;
  12089. // Always set children to the same thing. In IE9, the selection range will
  12090. // get reset if `textContent` is mutated.
  12091. var nativeProps = assign({}, props, {
  12092. defaultValue: undefined,
  12093. value: undefined,
  12094. children: inst._wrapperState.initialValue,
  12095. onChange: inst._wrapperState.onChange
  12096. });
  12097. return nativeProps;
  12098. },
  12099. mountWrapper: function (inst, props) {
  12100. if (process.env.NODE_ENV !== 'production') {
  12101. LinkedValueUtils.checkPropTypes('textarea', props, inst._currentElement._owner);
  12102. }
  12103. var defaultValue = props.defaultValue;
  12104. // TODO (yungsters): Remove support for children content in <textarea>.
  12105. var children = props.children;
  12106. if (children != null) {
  12107. if (process.env.NODE_ENV !== 'production') {
  12108. process.env.NODE_ENV !== 'production' ? warning(false, 'Use the `defaultValue` or `value` props instead of setting ' + 'children on <textarea>.') : undefined;
  12109. }
  12110. !(defaultValue == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'If you supply `defaultValue` on a <textarea>, do not pass children.') : invariant(false) : undefined;
  12111. if (Array.isArray(children)) {
  12112. !(children.length <= 1) ? process.env.NODE_ENV !== 'production' ? invariant(false, '<textarea> can only have at most one child.') : invariant(false) : undefined;
  12113. children = children[0];
  12114. }
  12115. defaultValue = '' + children;
  12116. }
  12117. if (defaultValue == null) {
  12118. defaultValue = '';
  12119. }
  12120. var value = LinkedValueUtils.getValue(props);
  12121. inst._wrapperState = {
  12122. // We save the initial value so that `ReactDOMComponent` doesn't update
  12123. // `textContent` (unnecessary since we update value).
  12124. // The initial value can be a boolean or object so that's why it's
  12125. // forced to be a string.
  12126. initialValue: '' + (value != null ? value : defaultValue),
  12127. onChange: _handleChange.bind(inst)
  12128. };
  12129. },
  12130. updateWrapper: function (inst) {
  12131. var props = inst._currentElement.props;
  12132. var value = LinkedValueUtils.getValue(props);
  12133. if (value != null) {
  12134. // Cast `value` to a string to ensure the value is set correctly. While
  12135. // browsers typically do this as necessary, jsdom doesn't.
  12136. ReactDOMIDOperations.updatePropertyByID(inst._rootNodeID, 'value', '' + value);
  12137. }
  12138. }
  12139. };
  12140. function _handleChange(event) {
  12141. var props = this._currentElement.props;
  12142. var returnValue = LinkedValueUtils.executeOnChange(props, event);
  12143. ReactUpdates.asap(forceUpdateIfMounted, this);
  12144. return returnValue;
  12145. }
  12146. module.exports = ReactDOMTextarea;
  12147. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  12148. /***/ },
  12149. /* 114 */
  12150. /***/ function(module, exports, __webpack_require__) {
  12151. /* WEBPACK VAR INJECTION */(function(process) {/**
  12152. * Copyright 2013-2015, Facebook, Inc.
  12153. * All rights reserved.
  12154. *
  12155. * This source code is licensed under the BSD-style license found in the
  12156. * LICENSE file in the root directory of this source tree. An additional grant
  12157. * of patent rights can be found in the PATENTS file in the same directory.
  12158. *
  12159. * @providesModule ReactMultiChild
  12160. * @typechecks static-only
  12161. */
  12162. 'use strict';
  12163. var ReactComponentEnvironment = __webpack_require__(64);
  12164. var ReactMultiChildUpdateTypes = __webpack_require__(16);
  12165. var ReactCurrentOwner = __webpack_require__(5);
  12166. var ReactReconciler = __webpack_require__(50);
  12167. var ReactChildReconciler = __webpack_require__(115);
  12168. var flattenChildren = __webpack_require__(116);
  12169. /**
  12170. * Updating children of a component may trigger recursive updates. The depth is
  12171. * used to batch recursive updates to render markup more efficiently.
  12172. *
  12173. * @type {number}
  12174. * @private
  12175. */
  12176. var updateDepth = 0;
  12177. /**
  12178. * Queue of update configuration objects.
  12179. *
  12180. * Each object has a `type` property that is in `ReactMultiChildUpdateTypes`.
  12181. *
  12182. * @type {array<object>}
  12183. * @private
  12184. */
  12185. var updateQueue = [];
  12186. /**
  12187. * Queue of markup to be rendered.
  12188. *
  12189. * @type {array<string>}
  12190. * @private
  12191. */
  12192. var markupQueue = [];
  12193. /**
  12194. * Enqueues markup to be rendered and inserted at a supplied index.
  12195. *
  12196. * @param {string} parentID ID of the parent component.
  12197. * @param {string} markup Markup that renders into an element.
  12198. * @param {number} toIndex Destination index.
  12199. * @private
  12200. */
  12201. function enqueueInsertMarkup(parentID, markup, toIndex) {
  12202. // NOTE: Null values reduce hidden classes.
  12203. updateQueue.push({
  12204. parentID: parentID,
  12205. parentNode: null,
  12206. type: ReactMultiChildUpdateTypes.INSERT_MARKUP,
  12207. markupIndex: markupQueue.push(markup) - 1,
  12208. content: null,
  12209. fromIndex: null,
  12210. toIndex: toIndex
  12211. });
  12212. }
  12213. /**
  12214. * Enqueues moving an existing element to another index.
  12215. *
  12216. * @param {string} parentID ID of the parent component.
  12217. * @param {number} fromIndex Source index of the existing element.
  12218. * @param {number} toIndex Destination index of the element.
  12219. * @private
  12220. */
  12221. function enqueueMove(parentID, fromIndex, toIndex) {
  12222. // NOTE: Null values reduce hidden classes.
  12223. updateQueue.push({
  12224. parentID: parentID,
  12225. parentNode: null,
  12226. type: ReactMultiChildUpdateTypes.MOVE_EXISTING,
  12227. markupIndex: null,
  12228. content: null,
  12229. fromIndex: fromIndex,
  12230. toIndex: toIndex
  12231. });
  12232. }
  12233. /**
  12234. * Enqueues removing an element at an index.
  12235. *
  12236. * @param {string} parentID ID of the parent component.
  12237. * @param {number} fromIndex Index of the element to remove.
  12238. * @private
  12239. */
  12240. function enqueueRemove(parentID, fromIndex) {
  12241. // NOTE: Null values reduce hidden classes.
  12242. updateQueue.push({
  12243. parentID: parentID,
  12244. parentNode: null,
  12245. type: ReactMultiChildUpdateTypes.REMOVE_NODE,
  12246. markupIndex: null,
  12247. content: null,
  12248. fromIndex: fromIndex,
  12249. toIndex: null
  12250. });
  12251. }
  12252. /**
  12253. * Enqueues setting the markup of a node.
  12254. *
  12255. * @param {string} parentID ID of the parent component.
  12256. * @param {string} markup Markup that renders into an element.
  12257. * @private
  12258. */
  12259. function enqueueSetMarkup(parentID, markup) {
  12260. // NOTE: Null values reduce hidden classes.
  12261. updateQueue.push({
  12262. parentID: parentID,
  12263. parentNode: null,
  12264. type: ReactMultiChildUpdateTypes.SET_MARKUP,
  12265. markupIndex: null,
  12266. content: markup,
  12267. fromIndex: null,
  12268. toIndex: null
  12269. });
  12270. }
  12271. /**
  12272. * Enqueues setting the text content.
  12273. *
  12274. * @param {string} parentID ID of the parent component.
  12275. * @param {string} textContent Text content to set.
  12276. * @private
  12277. */
  12278. function enqueueTextContent(parentID, textContent) {
  12279. // NOTE: Null values reduce hidden classes.
  12280. updateQueue.push({
  12281. parentID: parentID,
  12282. parentNode: null,
  12283. type: ReactMultiChildUpdateTypes.TEXT_CONTENT,
  12284. markupIndex: null,
  12285. content: textContent,
  12286. fromIndex: null,
  12287. toIndex: null
  12288. });
  12289. }
  12290. /**
  12291. * Processes any enqueued updates.
  12292. *
  12293. * @private
  12294. */
  12295. function processQueue() {
  12296. if (updateQueue.length) {
  12297. ReactComponentEnvironment.processChildrenUpdates(updateQueue, markupQueue);
  12298. clearQueue();
  12299. }
  12300. }
  12301. /**
  12302. * Clears any enqueued updates.
  12303. *
  12304. * @private
  12305. */
  12306. function clearQueue() {
  12307. updateQueue.length = 0;
  12308. markupQueue.length = 0;
  12309. }
  12310. /**
  12311. * ReactMultiChild are capable of reconciling multiple children.
  12312. *
  12313. * @class ReactMultiChild
  12314. * @internal
  12315. */
  12316. var ReactMultiChild = {
  12317. /**
  12318. * Provides common functionality for components that must reconcile multiple
  12319. * children. This is used by `ReactDOMComponent` to mount, update, and
  12320. * unmount child components.
  12321. *
  12322. * @lends {ReactMultiChild.prototype}
  12323. */
  12324. Mixin: {
  12325. _reconcilerInstantiateChildren: function (nestedChildren, transaction, context) {
  12326. if (process.env.NODE_ENV !== 'production') {
  12327. if (this._currentElement) {
  12328. try {
  12329. ReactCurrentOwner.current = this._currentElement._owner;
  12330. return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
  12331. } finally {
  12332. ReactCurrentOwner.current = null;
  12333. }
  12334. }
  12335. }
  12336. return ReactChildReconciler.instantiateChildren(nestedChildren, transaction, context);
  12337. },
  12338. _reconcilerUpdateChildren: function (prevChildren, nextNestedChildrenElements, transaction, context) {
  12339. var nextChildren;
  12340. if (process.env.NODE_ENV !== 'production') {
  12341. if (this._currentElement) {
  12342. try {
  12343. ReactCurrentOwner.current = this._currentElement._owner;
  12344. nextChildren = flattenChildren(nextNestedChildrenElements);
  12345. } finally {
  12346. ReactCurrentOwner.current = null;
  12347. }
  12348. return ReactChildReconciler.updateChildren(prevChildren, nextChildren, transaction, context);
  12349. }
  12350. }
  12351. nextChildren = flattenChildren(nextNestedChildrenElements);
  12352. return ReactChildReconciler.updateChildren(prevChildren, nextChildren, transaction, context);
  12353. },
  12354. /**
  12355. * Generates a "mount image" for each of the supplied children. In the case
  12356. * of `ReactDOMComponent`, a mount image is a string of markup.
  12357. *
  12358. * @param {?object} nestedChildren Nested child maps.
  12359. * @return {array} An array of mounted representations.
  12360. * @internal
  12361. */
  12362. mountChildren: function (nestedChildren, transaction, context) {
  12363. var children = this._reconcilerInstantiateChildren(nestedChildren, transaction, context);
  12364. this._renderedChildren = children;
  12365. var mountImages = [];
  12366. var index = 0;
  12367. for (var name in children) {
  12368. if (children.hasOwnProperty(name)) {
  12369. var child = children[name];
  12370. // Inlined for performance, see `ReactInstanceHandles.createReactID`.
  12371. var rootID = this._rootNodeID + name;
  12372. var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
  12373. child._mountIndex = index++;
  12374. mountImages.push(mountImage);
  12375. }
  12376. }
  12377. return mountImages;
  12378. },
  12379. /**
  12380. * Replaces any rendered children with a text content string.
  12381. *
  12382. * @param {string} nextContent String of content.
  12383. * @internal
  12384. */
  12385. updateTextContent: function (nextContent) {
  12386. updateDepth++;
  12387. var errorThrown = true;
  12388. try {
  12389. var prevChildren = this._renderedChildren;
  12390. // Remove any rendered children.
  12391. ReactChildReconciler.unmountChildren(prevChildren);
  12392. // TODO: The setTextContent operation should be enough
  12393. for (var name in prevChildren) {
  12394. if (prevChildren.hasOwnProperty(name)) {
  12395. this._unmountChild(prevChildren[name]);
  12396. }
  12397. }
  12398. // Set new text content.
  12399. this.setTextContent(nextContent);
  12400. errorThrown = false;
  12401. } finally {
  12402. updateDepth--;
  12403. if (!updateDepth) {
  12404. if (errorThrown) {
  12405. clearQueue();
  12406. } else {
  12407. processQueue();
  12408. }
  12409. }
  12410. }
  12411. },
  12412. /**
  12413. * Replaces any rendered children with a markup string.
  12414. *
  12415. * @param {string} nextMarkup String of markup.
  12416. * @internal
  12417. */
  12418. updateMarkup: function (nextMarkup) {
  12419. updateDepth++;
  12420. var errorThrown = true;
  12421. try {
  12422. var prevChildren = this._renderedChildren;
  12423. // Remove any rendered children.
  12424. ReactChildReconciler.unmountChildren(prevChildren);
  12425. for (var name in prevChildren) {
  12426. if (prevChildren.hasOwnProperty(name)) {
  12427. this._unmountChildByName(prevChildren[name], name);
  12428. }
  12429. }
  12430. this.setMarkup(nextMarkup);
  12431. errorThrown = false;
  12432. } finally {
  12433. updateDepth--;
  12434. if (!updateDepth) {
  12435. if (errorThrown) {
  12436. clearQueue();
  12437. } else {
  12438. processQueue();
  12439. }
  12440. }
  12441. }
  12442. },
  12443. /**
  12444. * Updates the rendered children with new children.
  12445. *
  12446. * @param {?object} nextNestedChildrenElements Nested child element maps.
  12447. * @param {ReactReconcileTransaction} transaction
  12448. * @internal
  12449. */
  12450. updateChildren: function (nextNestedChildrenElements, transaction, context) {
  12451. updateDepth++;
  12452. var errorThrown = true;
  12453. try {
  12454. this._updateChildren(nextNestedChildrenElements, transaction, context);
  12455. errorThrown = false;
  12456. } finally {
  12457. updateDepth--;
  12458. if (!updateDepth) {
  12459. if (errorThrown) {
  12460. clearQueue();
  12461. } else {
  12462. processQueue();
  12463. }
  12464. }
  12465. }
  12466. },
  12467. /**
  12468. * Improve performance by isolating this hot code path from the try/catch
  12469. * block in `updateChildren`.
  12470. *
  12471. * @param {?object} nextNestedChildrenElements Nested child element maps.
  12472. * @param {ReactReconcileTransaction} transaction
  12473. * @final
  12474. * @protected
  12475. */
  12476. _updateChildren: function (nextNestedChildrenElements, transaction, context) {
  12477. var prevChildren = this._renderedChildren;
  12478. var nextChildren = this._reconcilerUpdateChildren(prevChildren, nextNestedChildrenElements, transaction, context);
  12479. this._renderedChildren = nextChildren;
  12480. if (!nextChildren && !prevChildren) {
  12481. return;
  12482. }
  12483. var name;
  12484. // `nextIndex` will increment for each child in `nextChildren`, but
  12485. // `lastIndex` will be the last index visited in `prevChildren`.
  12486. var lastIndex = 0;
  12487. var nextIndex = 0;
  12488. for (name in nextChildren) {
  12489. if (!nextChildren.hasOwnProperty(name)) {
  12490. continue;
  12491. }
  12492. var prevChild = prevChildren && prevChildren[name];
  12493. var nextChild = nextChildren[name];
  12494. if (prevChild === nextChild) {
  12495. this.moveChild(prevChild, nextIndex, lastIndex);
  12496. lastIndex = Math.max(prevChild._mountIndex, lastIndex);
  12497. prevChild._mountIndex = nextIndex;
  12498. } else {
  12499. if (prevChild) {
  12500. // Update `lastIndex` before `_mountIndex` gets unset by unmounting.
  12501. lastIndex = Math.max(prevChild._mountIndex, lastIndex);
  12502. this._unmountChild(prevChild);
  12503. }
  12504. // The child must be instantiated before it's mounted.
  12505. this._mountChildByNameAtIndex(nextChild, name, nextIndex, transaction, context);
  12506. }
  12507. nextIndex++;
  12508. }
  12509. // Remove children that are no longer present.
  12510. for (name in prevChildren) {
  12511. if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
  12512. this._unmountChild(prevChildren[name]);
  12513. }
  12514. }
  12515. },
  12516. /**
  12517. * Unmounts all rendered children. This should be used to clean up children
  12518. * when this component is unmounted.
  12519. *
  12520. * @internal
  12521. */
  12522. unmountChildren: function () {
  12523. var renderedChildren = this._renderedChildren;
  12524. ReactChildReconciler.unmountChildren(renderedChildren);
  12525. this._renderedChildren = null;
  12526. },
  12527. /**
  12528. * Moves a child component to the supplied index.
  12529. *
  12530. * @param {ReactComponent} child Component to move.
  12531. * @param {number} toIndex Destination index of the element.
  12532. * @param {number} lastIndex Last index visited of the siblings of `child`.
  12533. * @protected
  12534. */
  12535. moveChild: function (child, toIndex, lastIndex) {
  12536. // If the index of `child` is less than `lastIndex`, then it needs to
  12537. // be moved. Otherwise, we do not need to move it because a child will be
  12538. // inserted or moved before `child`.
  12539. if (child._mountIndex < lastIndex) {
  12540. enqueueMove(this._rootNodeID, child._mountIndex, toIndex);
  12541. }
  12542. },
  12543. /**
  12544. * Creates a child component.
  12545. *
  12546. * @param {ReactComponent} child Component to create.
  12547. * @param {string} mountImage Markup to insert.
  12548. * @protected
  12549. */
  12550. createChild: function (child, mountImage) {
  12551. enqueueInsertMarkup(this._rootNodeID, mountImage, child._mountIndex);
  12552. },
  12553. /**
  12554. * Removes a child component.
  12555. *
  12556. * @param {ReactComponent} child Child to remove.
  12557. * @protected
  12558. */
  12559. removeChild: function (child) {
  12560. enqueueRemove(this._rootNodeID, child._mountIndex);
  12561. },
  12562. /**
  12563. * Sets this text content string.
  12564. *
  12565. * @param {string} textContent Text content to set.
  12566. * @protected
  12567. */
  12568. setTextContent: function (textContent) {
  12569. enqueueTextContent(this._rootNodeID, textContent);
  12570. },
  12571. /**
  12572. * Sets this markup string.
  12573. *
  12574. * @param {string} markup Markup to set.
  12575. * @protected
  12576. */
  12577. setMarkup: function (markup) {
  12578. enqueueSetMarkup(this._rootNodeID, markup);
  12579. },
  12580. /**
  12581. * Mounts a child with the supplied name.
  12582. *
  12583. * NOTE: This is part of `updateChildren` and is here for readability.
  12584. *
  12585. * @param {ReactComponent} child Component to mount.
  12586. * @param {string} name Name of the child.
  12587. * @param {number} index Index at which to insert the child.
  12588. * @param {ReactReconcileTransaction} transaction
  12589. * @private
  12590. */
  12591. _mountChildByNameAtIndex: function (child, name, index, transaction, context) {
  12592. // Inlined for performance, see `ReactInstanceHandles.createReactID`.
  12593. var rootID = this._rootNodeID + name;
  12594. var mountImage = ReactReconciler.mountComponent(child, rootID, transaction, context);
  12595. child._mountIndex = index;
  12596. this.createChild(child, mountImage);
  12597. },
  12598. /**
  12599. * Unmounts a rendered child.
  12600. *
  12601. * NOTE: This is part of `updateChildren` and is here for readability.
  12602. *
  12603. * @param {ReactComponent} child Component to unmount.
  12604. * @private
  12605. */
  12606. _unmountChild: function (child) {
  12607. this.removeChild(child);
  12608. child._mountIndex = null;
  12609. }
  12610. }
  12611. };
  12612. module.exports = ReactMultiChild;
  12613. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  12614. /***/ },
  12615. /* 115 */
  12616. /***/ function(module, exports, __webpack_require__) {
  12617. /* WEBPACK VAR INJECTION */(function(process) {/**
  12618. * Copyright 2014-2015, Facebook, Inc.
  12619. * All rights reserved.
  12620. *
  12621. * This source code is licensed under the BSD-style license found in the
  12622. * LICENSE file in the root directory of this source tree. An additional grant
  12623. * of patent rights can be found in the PATENTS file in the same directory.
  12624. *
  12625. * @providesModule ReactChildReconciler
  12626. * @typechecks static-only
  12627. */
  12628. 'use strict';
  12629. var ReactReconciler = __webpack_require__(50);
  12630. var instantiateReactComponent = __webpack_require__(62);
  12631. var shouldUpdateReactComponent = __webpack_require__(67);
  12632. var traverseAllChildren = __webpack_require__(111);
  12633. var warning = __webpack_require__(25);
  12634. function instantiateChild(childInstances, child, name) {
  12635. // We found a component instance.
  12636. var keyUnique = childInstances[name] === undefined;
  12637. if (process.env.NODE_ENV !== 'production') {
  12638. process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) : undefined;
  12639. }
  12640. if (child != null && keyUnique) {
  12641. childInstances[name] = instantiateReactComponent(child, null);
  12642. }
  12643. }
  12644. /**
  12645. * ReactChildReconciler provides helpers for initializing or updating a set of
  12646. * children. Its output is suitable for passing it onto ReactMultiChild which
  12647. * does diffed reordering and insertion.
  12648. */
  12649. var ReactChildReconciler = {
  12650. /**
  12651. * Generates a "mount image" for each of the supplied children. In the case
  12652. * of `ReactDOMComponent`, a mount image is a string of markup.
  12653. *
  12654. * @param {?object} nestedChildNodes Nested child maps.
  12655. * @return {?object} A set of child instances.
  12656. * @internal
  12657. */
  12658. instantiateChildren: function (nestedChildNodes, transaction, context) {
  12659. if (nestedChildNodes == null) {
  12660. return null;
  12661. }
  12662. var childInstances = {};
  12663. traverseAllChildren(nestedChildNodes, instantiateChild, childInstances);
  12664. return childInstances;
  12665. },
  12666. /**
  12667. * Updates the rendered children and returns a new set of children.
  12668. *
  12669. * @param {?object} prevChildren Previously initialized set of children.
  12670. * @param {?object} nextChildren Flat child element maps.
  12671. * @param {ReactReconcileTransaction} transaction
  12672. * @param {object} context
  12673. * @return {?object} A new set of child instances.
  12674. * @internal
  12675. */
  12676. updateChildren: function (prevChildren, nextChildren, transaction, context) {
  12677. // We currently don't have a way to track moves here but if we use iterators
  12678. // instead of for..in we can zip the iterators and check if an item has
  12679. // moved.
  12680. // TODO: If nothing has changed, return the prevChildren object so that we
  12681. // can quickly bailout if nothing has changed.
  12682. if (!nextChildren && !prevChildren) {
  12683. return null;
  12684. }
  12685. var name;
  12686. for (name in nextChildren) {
  12687. if (!nextChildren.hasOwnProperty(name)) {
  12688. continue;
  12689. }
  12690. var prevChild = prevChildren && prevChildren[name];
  12691. var prevElement = prevChild && prevChild._currentElement;
  12692. var nextElement = nextChildren[name];
  12693. if (prevChild != null && shouldUpdateReactComponent(prevElement, nextElement)) {
  12694. ReactReconciler.receiveComponent(prevChild, nextElement, transaction, context);
  12695. nextChildren[name] = prevChild;
  12696. } else {
  12697. if (prevChild) {
  12698. ReactReconciler.unmountComponent(prevChild, name);
  12699. }
  12700. // The child must be instantiated before it's mounted.
  12701. var nextChildInstance = instantiateReactComponent(nextElement, null);
  12702. nextChildren[name] = nextChildInstance;
  12703. }
  12704. }
  12705. // Unmount children that are no longer present.
  12706. for (name in prevChildren) {
  12707. if (prevChildren.hasOwnProperty(name) && !(nextChildren && nextChildren.hasOwnProperty(name))) {
  12708. ReactReconciler.unmountComponent(prevChildren[name]);
  12709. }
  12710. }
  12711. return nextChildren;
  12712. },
  12713. /**
  12714. * Unmounts all rendered children. This should be used to clean up children
  12715. * when this component is unmounted.
  12716. *
  12717. * @param {?object} renderedChildren Previously initialized set of children.
  12718. * @internal
  12719. */
  12720. unmountChildren: function (renderedChildren) {
  12721. for (var name in renderedChildren) {
  12722. if (renderedChildren.hasOwnProperty(name)) {
  12723. var renderedChild = renderedChildren[name];
  12724. ReactReconciler.unmountComponent(renderedChild);
  12725. }
  12726. }
  12727. }
  12728. };
  12729. module.exports = ReactChildReconciler;
  12730. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  12731. /***/ },
  12732. /* 116 */
  12733. /***/ function(module, exports, __webpack_require__) {
  12734. /* WEBPACK VAR INJECTION */(function(process) {/**
  12735. * Copyright 2013-2015, Facebook, Inc.
  12736. * All rights reserved.
  12737. *
  12738. * This source code is licensed under the BSD-style license found in the
  12739. * LICENSE file in the root directory of this source tree. An additional grant
  12740. * of patent rights can be found in the PATENTS file in the same directory.
  12741. *
  12742. * @providesModule flattenChildren
  12743. */
  12744. 'use strict';
  12745. var traverseAllChildren = __webpack_require__(111);
  12746. var warning = __webpack_require__(25);
  12747. /**
  12748. * @param {function} traverseContext Context passed through traversal.
  12749. * @param {?ReactComponent} child React child component.
  12750. * @param {!string} name String name of key path to child.
  12751. */
  12752. function flattenSingleChildIntoContext(traverseContext, child, name) {
  12753. // We found a component instance.
  12754. var result = traverseContext;
  12755. var keyUnique = result[name] === undefined;
  12756. if (process.env.NODE_ENV !== 'production') {
  12757. process.env.NODE_ENV !== 'production' ? warning(keyUnique, 'flattenChildren(...): Encountered two children with the same key, ' + '`%s`. Child keys must be unique; when two children share a key, only ' + 'the first child will be used.', name) : undefined;
  12758. }
  12759. if (keyUnique && child != null) {
  12760. result[name] = child;
  12761. }
  12762. }
  12763. /**
  12764. * Flattens children that are typically specified as `props.children`. Any null
  12765. * children will not be included in the resulting object.
  12766. * @return {!object} flattened children keyed by name.
  12767. */
  12768. function flattenChildren(children) {
  12769. if (children == null) {
  12770. return children;
  12771. }
  12772. var result = {};
  12773. traverseAllChildren(children, flattenSingleChildIntoContext, result);
  12774. return result;
  12775. }
  12776. module.exports = flattenChildren;
  12777. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  12778. /***/ },
  12779. /* 117 */
  12780. /***/ function(module, exports) {
  12781. /**
  12782. * Copyright 2013-2015, Facebook, Inc.
  12783. * All rights reserved.
  12784. *
  12785. * This source code is licensed under the BSD-style license found in the
  12786. * LICENSE file in the root directory of this source tree. An additional grant
  12787. * of patent rights can be found in the PATENTS file in the same directory.
  12788. *
  12789. * @providesModule shallowEqual
  12790. * @typechecks
  12791. *
  12792. */
  12793. 'use strict';
  12794. var hasOwnProperty = Object.prototype.hasOwnProperty;
  12795. /**
  12796. * Performs equality by iterating through keys on an object and returning false
  12797. * when any key has values which are not strictly equal between the arguments.
  12798. * Returns true when the values of all keys are strictly equal.
  12799. */
  12800. function shallowEqual(objA, objB) {
  12801. if (objA === objB) {
  12802. return true;
  12803. }
  12804. if (typeof objA !== 'object' || objA === null || typeof objB !== 'object' || objB === null) {
  12805. return false;
  12806. }
  12807. var keysA = Object.keys(objA);
  12808. var keysB = Object.keys(objB);
  12809. if (keysA.length !== keysB.length) {
  12810. return false;
  12811. }
  12812. // Test for A's keys different from B.
  12813. var bHasOwnProperty = hasOwnProperty.bind(objB);
  12814. for (var i = 0; i < keysA.length; i++) {
  12815. if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
  12816. return false;
  12817. }
  12818. }
  12819. return true;
  12820. }
  12821. module.exports = shallowEqual;
  12822. /***/ },
  12823. /* 118 */
  12824. /***/ function(module, exports, __webpack_require__) {
  12825. /**
  12826. * Copyright 2013-2015, Facebook, Inc.
  12827. * All rights reserved.
  12828. *
  12829. * This source code is licensed under the BSD-style license found in the
  12830. * LICENSE file in the root directory of this source tree. An additional grant
  12831. * of patent rights can be found in the PATENTS file in the same directory.
  12832. *
  12833. * @providesModule ReactEventListener
  12834. * @typechecks static-only
  12835. */
  12836. 'use strict';
  12837. var EventListener = __webpack_require__(119);
  12838. var ExecutionEnvironment = __webpack_require__(9);
  12839. var PooledClass = __webpack_require__(56);
  12840. var ReactInstanceHandles = __webpack_require__(45);
  12841. var ReactMount = __webpack_require__(28);
  12842. var ReactUpdates = __webpack_require__(54);
  12843. var assign = __webpack_require__(39);
  12844. var getEventTarget = __webpack_require__(81);
  12845. var getUnboundedScrollPosition = __webpack_require__(120);
  12846. var DOCUMENT_FRAGMENT_NODE_TYPE = 11;
  12847. /**
  12848. * Finds the parent React component of `node`.
  12849. *
  12850. * @param {*} node
  12851. * @return {?DOMEventTarget} Parent container, or `null` if the specified node
  12852. * is not nested.
  12853. */
  12854. function findParent(node) {
  12855. // TODO: It may be a good idea to cache this to prevent unnecessary DOM
  12856. // traversal, but caching is difficult to do correctly without using a
  12857. // mutation observer to listen for all DOM changes.
  12858. var nodeID = ReactMount.getID(node);
  12859. var rootID = ReactInstanceHandles.getReactRootIDFromNodeID(nodeID);
  12860. var container = ReactMount.findReactContainerForID(rootID);
  12861. var parent = ReactMount.getFirstReactDOM(container);
  12862. return parent;
  12863. }
  12864. // Used to store ancestor hierarchy in top level callback
  12865. function TopLevelCallbackBookKeeping(topLevelType, nativeEvent) {
  12866. this.topLevelType = topLevelType;
  12867. this.nativeEvent = nativeEvent;
  12868. this.ancestors = [];
  12869. }
  12870. assign(TopLevelCallbackBookKeeping.prototype, {
  12871. destructor: function () {
  12872. this.topLevelType = null;
  12873. this.nativeEvent = null;
  12874. this.ancestors.length = 0;
  12875. }
  12876. });
  12877. PooledClass.addPoolingTo(TopLevelCallbackBookKeeping, PooledClass.twoArgumentPooler);
  12878. function handleTopLevelImpl(bookKeeping) {
  12879. // TODO: Re-enable event.path handling
  12880. //
  12881. // if (bookKeeping.nativeEvent.path && bookKeeping.nativeEvent.path.length > 1) {
  12882. // // New browsers have a path attribute on native events
  12883. // handleTopLevelWithPath(bookKeeping);
  12884. // } else {
  12885. // // Legacy browsers don't have a path attribute on native events
  12886. // handleTopLevelWithoutPath(bookKeeping);
  12887. // }
  12888. void handleTopLevelWithPath; // temporarily unused
  12889. handleTopLevelWithoutPath(bookKeeping);
  12890. }
  12891. // Legacy browsers don't have a path attribute on native events
  12892. function handleTopLevelWithoutPath(bookKeeping) {
  12893. var topLevelTarget = ReactMount.getFirstReactDOM(getEventTarget(bookKeeping.nativeEvent)) || window;
  12894. // Loop through the hierarchy, in case there's any nested components.
  12895. // It's important that we build the array of ancestors before calling any
  12896. // event handlers, because event handlers can modify the DOM, leading to
  12897. // inconsistencies with ReactMount's node cache. See #1105.
  12898. var ancestor = topLevelTarget;
  12899. while (ancestor) {
  12900. bookKeeping.ancestors.push(ancestor);
  12901. ancestor = findParent(ancestor);
  12902. }
  12903. for (var i = 0; i < bookKeeping.ancestors.length; i++) {
  12904. topLevelTarget = bookKeeping.ancestors[i];
  12905. var topLevelTargetID = ReactMount.getID(topLevelTarget) || '';
  12906. ReactEventListener._handleTopLevel(bookKeeping.topLevelType, topLevelTarget, topLevelTargetID, bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
  12907. }
  12908. }
  12909. // New browsers have a path attribute on native events
  12910. function handleTopLevelWithPath(bookKeeping) {
  12911. var path = bookKeeping.nativeEvent.path;
  12912. var currentNativeTarget = path[0];
  12913. var eventsFired = 0;
  12914. for (var i = 0; i < path.length; i++) {
  12915. var currentPathElement = path[i];
  12916. if (currentPathElement.nodeType === DOCUMENT_FRAGMENT_NODE_TYPE) {
  12917. currentNativeTarget = path[i + 1];
  12918. }
  12919. // TODO: slow
  12920. var reactParent = ReactMount.getFirstReactDOM(currentPathElement);
  12921. if (reactParent === currentPathElement) {
  12922. var currentPathElementID = ReactMount.getID(currentPathElement);
  12923. var newRootID = ReactInstanceHandles.getReactRootIDFromNodeID(currentPathElementID);
  12924. bookKeeping.ancestors.push(currentPathElement);
  12925. var topLevelTargetID = ReactMount.getID(currentPathElement) || '';
  12926. eventsFired++;
  12927. ReactEventListener._handleTopLevel(bookKeeping.topLevelType, currentPathElement, topLevelTargetID, bookKeeping.nativeEvent, currentNativeTarget);
  12928. // Jump to the root of this React render tree
  12929. while (currentPathElementID !== newRootID) {
  12930. i++;
  12931. currentPathElement = path[i];
  12932. currentPathElementID = ReactMount.getID(currentPathElement);
  12933. }
  12934. }
  12935. }
  12936. if (eventsFired === 0) {
  12937. ReactEventListener._handleTopLevel(bookKeeping.topLevelType, window, '', bookKeeping.nativeEvent, getEventTarget(bookKeeping.nativeEvent));
  12938. }
  12939. }
  12940. function scrollValueMonitor(cb) {
  12941. var scrollPosition = getUnboundedScrollPosition(window);
  12942. cb(scrollPosition);
  12943. }
  12944. var ReactEventListener = {
  12945. _enabled: true,
  12946. _handleTopLevel: null,
  12947. WINDOW_HANDLE: ExecutionEnvironment.canUseDOM ? window : null,
  12948. setHandleTopLevel: function (handleTopLevel) {
  12949. ReactEventListener._handleTopLevel = handleTopLevel;
  12950. },
  12951. setEnabled: function (enabled) {
  12952. ReactEventListener._enabled = !!enabled;
  12953. },
  12954. isEnabled: function () {
  12955. return ReactEventListener._enabled;
  12956. },
  12957. /**
  12958. * Traps top-level events by using event bubbling.
  12959. *
  12960. * @param {string} topLevelType Record from `EventConstants`.
  12961. * @param {string} handlerBaseName Event name (e.g. "click").
  12962. * @param {object} handle Element on which to attach listener.
  12963. * @return {?object} An object with a remove function which will forcefully
  12964. * remove the listener.
  12965. * @internal
  12966. */
  12967. trapBubbledEvent: function (topLevelType, handlerBaseName, handle) {
  12968. var element = handle;
  12969. if (!element) {
  12970. return null;
  12971. }
  12972. return EventListener.listen(element, handlerBaseName, ReactEventListener.dispatchEvent.bind(null, topLevelType));
  12973. },
  12974. /**
  12975. * Traps a top-level event by using event capturing.
  12976. *
  12977. * @param {string} topLevelType Record from `EventConstants`.
  12978. * @param {string} handlerBaseName Event name (e.g. "click").
  12979. * @param {object} handle Element on which to attach listener.
  12980. * @return {?object} An object with a remove function which will forcefully
  12981. * remove the listener.
  12982. * @internal
  12983. */
  12984. trapCapturedEvent: function (topLevelType, handlerBaseName, handle) {
  12985. var element = handle;
  12986. if (!element) {
  12987. return null;
  12988. }
  12989. return EventListener.capture(element, handlerBaseName, ReactEventListener.dispatchEvent.bind(null, topLevelType));
  12990. },
  12991. monitorScrollValue: function (refresh) {
  12992. var callback = scrollValueMonitor.bind(null, refresh);
  12993. EventListener.listen(window, 'scroll', callback);
  12994. },
  12995. dispatchEvent: function (topLevelType, nativeEvent) {
  12996. if (!ReactEventListener._enabled) {
  12997. return;
  12998. }
  12999. var bookKeeping = TopLevelCallbackBookKeeping.getPooled(topLevelType, nativeEvent);
  13000. try {
  13001. // Event queue being processed in the same cycle allows
  13002. // `preventDefault`.
  13003. ReactUpdates.batchedUpdates(handleTopLevelImpl, bookKeeping);
  13004. } finally {
  13005. TopLevelCallbackBookKeeping.release(bookKeeping);
  13006. }
  13007. }
  13008. };
  13009. module.exports = ReactEventListener;
  13010. /***/ },
  13011. /* 119 */
  13012. /***/ function(module, exports, __webpack_require__) {
  13013. /* WEBPACK VAR INJECTION */(function(process) {/**
  13014. * Copyright 2013-2015, Facebook, Inc.
  13015. *
  13016. * Licensed under the Apache License, Version 2.0 (the "License");
  13017. * you may not use this file except in compliance with the License.
  13018. * You may obtain a copy of the License at
  13019. *
  13020. * http://www.apache.org/licenses/LICENSE-2.0
  13021. *
  13022. * Unless required by applicable law or agreed to in writing, software
  13023. * distributed under the License is distributed on an "AS IS" BASIS,
  13024. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13025. * See the License for the specific language governing permissions and
  13026. * limitations under the License.
  13027. *
  13028. * @providesModule EventListener
  13029. * @typechecks
  13030. */
  13031. 'use strict';
  13032. var emptyFunction = __webpack_require__(15);
  13033. /**
  13034. * Upstream version of event listener. Does not take into account specific
  13035. * nature of platform.
  13036. */
  13037. var EventListener = {
  13038. /**
  13039. * Listen to DOM events during the bubble phase.
  13040. *
  13041. * @param {DOMEventTarget} target DOM element to register listener on.
  13042. * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
  13043. * @param {function} callback Callback function.
  13044. * @return {object} Object with a `remove` method.
  13045. */
  13046. listen: function (target, eventType, callback) {
  13047. if (target.addEventListener) {
  13048. target.addEventListener(eventType, callback, false);
  13049. return {
  13050. remove: function () {
  13051. target.removeEventListener(eventType, callback, false);
  13052. }
  13053. };
  13054. } else if (target.attachEvent) {
  13055. target.attachEvent('on' + eventType, callback);
  13056. return {
  13057. remove: function () {
  13058. target.detachEvent('on' + eventType, callback);
  13059. }
  13060. };
  13061. }
  13062. },
  13063. /**
  13064. * Listen to DOM events during the capture phase.
  13065. *
  13066. * @param {DOMEventTarget} target DOM element to register listener on.
  13067. * @param {string} eventType Event type, e.g. 'click' or 'mouseover'.
  13068. * @param {function} callback Callback function.
  13069. * @return {object} Object with a `remove` method.
  13070. */
  13071. capture: function (target, eventType, callback) {
  13072. if (target.addEventListener) {
  13073. target.addEventListener(eventType, callback, true);
  13074. return {
  13075. remove: function () {
  13076. target.removeEventListener(eventType, callback, true);
  13077. }
  13078. };
  13079. } else {
  13080. if (process.env.NODE_ENV !== 'production') {
  13081. console.error('Attempted to listen to events during the capture phase on a ' + 'browser that does not support the capture phase. Your application ' + 'will not receive some events.');
  13082. }
  13083. return {
  13084. remove: emptyFunction
  13085. };
  13086. }
  13087. },
  13088. registerDefault: function () {}
  13089. };
  13090. module.exports = EventListener;
  13091. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  13092. /***/ },
  13093. /* 120 */
  13094. /***/ function(module, exports) {
  13095. /**
  13096. * Copyright 2013-2015, Facebook, Inc.
  13097. * All rights reserved.
  13098. *
  13099. * This source code is licensed under the BSD-style license found in the
  13100. * LICENSE file in the root directory of this source tree. An additional grant
  13101. * of patent rights can be found in the PATENTS file in the same directory.
  13102. *
  13103. * @providesModule getUnboundedScrollPosition
  13104. * @typechecks
  13105. */
  13106. 'use strict';
  13107. /**
  13108. * Gets the scroll position of the supplied element or window.
  13109. *
  13110. * The return values are unbounded, unlike `getScrollPosition`. This means they
  13111. * may be negative or exceed the element boundaries (which is possible using
  13112. * inertial scrolling).
  13113. *
  13114. * @param {DOMWindow|DOMElement} scrollable
  13115. * @return {object} Map with `x` and `y` keys.
  13116. */
  13117. function getUnboundedScrollPosition(scrollable) {
  13118. if (scrollable === window) {
  13119. return {
  13120. x: window.pageXOffset || document.documentElement.scrollLeft,
  13121. y: window.pageYOffset || document.documentElement.scrollTop
  13122. };
  13123. }
  13124. return {
  13125. x: scrollable.scrollLeft,
  13126. y: scrollable.scrollTop
  13127. };
  13128. }
  13129. module.exports = getUnboundedScrollPosition;
  13130. /***/ },
  13131. /* 121 */
  13132. /***/ function(module, exports, __webpack_require__) {
  13133. /**
  13134. * Copyright 2013-2015, Facebook, Inc.
  13135. * All rights reserved.
  13136. *
  13137. * This source code is licensed under the BSD-style license found in the
  13138. * LICENSE file in the root directory of this source tree. An additional grant
  13139. * of patent rights can be found in the PATENTS file in the same directory.
  13140. *
  13141. * @providesModule ReactInjection
  13142. */
  13143. 'use strict';
  13144. var DOMProperty = __webpack_require__(23);
  13145. var EventPluginHub = __webpack_require__(31);
  13146. var ReactComponentEnvironment = __webpack_require__(64);
  13147. var ReactClass = __webpack_require__(122);
  13148. var ReactEmptyComponent = __webpack_require__(68);
  13149. var ReactBrowserEventEmitter = __webpack_require__(29);
  13150. var ReactNativeComponent = __webpack_require__(69);
  13151. var ReactPerf = __webpack_require__(18);
  13152. var ReactRootIndex = __webpack_require__(46);
  13153. var ReactUpdates = __webpack_require__(54);
  13154. var ReactInjection = {
  13155. Component: ReactComponentEnvironment.injection,
  13156. Class: ReactClass.injection,
  13157. DOMProperty: DOMProperty.injection,
  13158. EmptyComponent: ReactEmptyComponent.injection,
  13159. EventPluginHub: EventPluginHub.injection,
  13160. EventEmitter: ReactBrowserEventEmitter.injection,
  13161. NativeComponent: ReactNativeComponent.injection,
  13162. Perf: ReactPerf.injection,
  13163. RootIndex: ReactRootIndex.injection,
  13164. Updates: ReactUpdates.injection
  13165. };
  13166. module.exports = ReactInjection;
  13167. /***/ },
  13168. /* 122 */
  13169. /***/ function(module, exports, __webpack_require__) {
  13170. /* WEBPACK VAR INJECTION */(function(process) {/**
  13171. * Copyright 2013-2015, Facebook, Inc.
  13172. * All rights reserved.
  13173. *
  13174. * This source code is licensed under the BSD-style license found in the
  13175. * LICENSE file in the root directory of this source tree. An additional grant
  13176. * of patent rights can be found in the PATENTS file in the same directory.
  13177. *
  13178. * @providesModule ReactClass
  13179. */
  13180. 'use strict';
  13181. var ReactComponent = __webpack_require__(123);
  13182. var ReactElement = __webpack_require__(42);
  13183. var ReactPropTypeLocations = __webpack_require__(65);
  13184. var ReactPropTypeLocationNames = __webpack_require__(66);
  13185. var ReactNoopUpdateQueue = __webpack_require__(124);
  13186. var assign = __webpack_require__(39);
  13187. var emptyObject = __webpack_require__(58);
  13188. var invariant = __webpack_require__(13);
  13189. var keyMirror = __webpack_require__(17);
  13190. var keyOf = __webpack_require__(79);
  13191. var warning = __webpack_require__(25);
  13192. var MIXINS_KEY = keyOf({ mixins: null });
  13193. /**
  13194. * Policies that describe methods in `ReactClassInterface`.
  13195. */
  13196. var SpecPolicy = keyMirror({
  13197. /**
  13198. * These methods may be defined only once by the class specification or mixin.
  13199. */
  13200. DEFINE_ONCE: null,
  13201. /**
  13202. * These methods may be defined by both the class specification and mixins.
  13203. * Subsequent definitions will be chained. These methods must return void.
  13204. */
  13205. DEFINE_MANY: null,
  13206. /**
  13207. * These methods are overriding the base class.
  13208. */
  13209. OVERRIDE_BASE: null,
  13210. /**
  13211. * These methods are similar to DEFINE_MANY, except we assume they return
  13212. * objects. We try to merge the keys of the return values of all the mixed in
  13213. * functions. If there is a key conflict we throw.
  13214. */
  13215. DEFINE_MANY_MERGED: null
  13216. });
  13217. var injectedMixins = [];
  13218. var warnedSetProps = false;
  13219. function warnSetProps() {
  13220. if (!warnedSetProps) {
  13221. warnedSetProps = true;
  13222. process.env.NODE_ENV !== 'production' ? warning(false, 'setProps(...) and replaceProps(...) are deprecated. ' + 'Instead, call render again at the top level.') : undefined;
  13223. }
  13224. }
  13225. /**
  13226. * Composite components are higher-level components that compose other composite
  13227. * or native components.
  13228. *
  13229. * To create a new type of `ReactClass`, pass a specification of
  13230. * your new class to `React.createClass`. The only requirement of your class
  13231. * specification is that you implement a `render` method.
  13232. *
  13233. * var MyComponent = React.createClass({
  13234. * render: function() {
  13235. * return <div>Hello World</div>;
  13236. * }
  13237. * });
  13238. *
  13239. * The class specification supports a specific protocol of methods that have
  13240. * special meaning (e.g. `render`). See `ReactClassInterface` for
  13241. * more the comprehensive protocol. Any other properties and methods in the
  13242. * class specification will be available on the prototype.
  13243. *
  13244. * @interface ReactClassInterface
  13245. * @internal
  13246. */
  13247. var ReactClassInterface = {
  13248. /**
  13249. * An array of Mixin objects to include when defining your component.
  13250. *
  13251. * @type {array}
  13252. * @optional
  13253. */
  13254. mixins: SpecPolicy.DEFINE_MANY,
  13255. /**
  13256. * An object containing properties and methods that should be defined on
  13257. * the component's constructor instead of its prototype (static methods).
  13258. *
  13259. * @type {object}
  13260. * @optional
  13261. */
  13262. statics: SpecPolicy.DEFINE_MANY,
  13263. /**
  13264. * Definition of prop types for this component.
  13265. *
  13266. * @type {object}
  13267. * @optional
  13268. */
  13269. propTypes: SpecPolicy.DEFINE_MANY,
  13270. /**
  13271. * Definition of context types for this component.
  13272. *
  13273. * @type {object}
  13274. * @optional
  13275. */
  13276. contextTypes: SpecPolicy.DEFINE_MANY,
  13277. /**
  13278. * Definition of context types this component sets for its children.
  13279. *
  13280. * @type {object}
  13281. * @optional
  13282. */
  13283. childContextTypes: SpecPolicy.DEFINE_MANY,
  13284. // ==== Definition methods ====
  13285. /**
  13286. * Invoked when the component is mounted. Values in the mapping will be set on
  13287. * `this.props` if that prop is not specified (i.e. using an `in` check).
  13288. *
  13289. * This method is invoked before `getInitialState` and therefore cannot rely
  13290. * on `this.state` or use `this.setState`.
  13291. *
  13292. * @return {object}
  13293. * @optional
  13294. */
  13295. getDefaultProps: SpecPolicy.DEFINE_MANY_MERGED,
  13296. /**
  13297. * Invoked once before the component is mounted. The return value will be used
  13298. * as the initial value of `this.state`.
  13299. *
  13300. * getInitialState: function() {
  13301. * return {
  13302. * isOn: false,
  13303. * fooBaz: new BazFoo()
  13304. * }
  13305. * }
  13306. *
  13307. * @return {object}
  13308. * @optional
  13309. */
  13310. getInitialState: SpecPolicy.DEFINE_MANY_MERGED,
  13311. /**
  13312. * @return {object}
  13313. * @optional
  13314. */
  13315. getChildContext: SpecPolicy.DEFINE_MANY_MERGED,
  13316. /**
  13317. * Uses props from `this.props` and state from `this.state` to render the
  13318. * structure of the component.
  13319. *
  13320. * No guarantees are made about when or how often this method is invoked, so
  13321. * it must not have side effects.
  13322. *
  13323. * render: function() {
  13324. * var name = this.props.name;
  13325. * return <div>Hello, {name}!</div>;
  13326. * }
  13327. *
  13328. * @return {ReactComponent}
  13329. * @nosideeffects
  13330. * @required
  13331. */
  13332. render: SpecPolicy.DEFINE_ONCE,
  13333. // ==== Delegate methods ====
  13334. /**
  13335. * Invoked when the component is initially created and about to be mounted.
  13336. * This may have side effects, but any external subscriptions or data created
  13337. * by this method must be cleaned up in `componentWillUnmount`.
  13338. *
  13339. * @optional
  13340. */
  13341. componentWillMount: SpecPolicy.DEFINE_MANY,
  13342. /**
  13343. * Invoked when the component has been mounted and has a DOM representation.
  13344. * However, there is no guarantee that the DOM node is in the document.
  13345. *
  13346. * Use this as an opportunity to operate on the DOM when the component has
  13347. * been mounted (initialized and rendered) for the first time.
  13348. *
  13349. * @param {DOMElement} rootNode DOM element representing the component.
  13350. * @optional
  13351. */
  13352. componentDidMount: SpecPolicy.DEFINE_MANY,
  13353. /**
  13354. * Invoked before the component receives new props.
  13355. *
  13356. * Use this as an opportunity to react to a prop transition by updating the
  13357. * state using `this.setState`. Current props are accessed via `this.props`.
  13358. *
  13359. * componentWillReceiveProps: function(nextProps, nextContext) {
  13360. * this.setState({
  13361. * likesIncreasing: nextProps.likeCount > this.props.likeCount
  13362. * });
  13363. * }
  13364. *
  13365. * NOTE: There is no equivalent `componentWillReceiveState`. An incoming prop
  13366. * transition may cause a state change, but the opposite is not true. If you
  13367. * need it, you are probably looking for `componentWillUpdate`.
  13368. *
  13369. * @param {object} nextProps
  13370. * @optional
  13371. */
  13372. componentWillReceiveProps: SpecPolicy.DEFINE_MANY,
  13373. /**
  13374. * Invoked while deciding if the component should be updated as a result of
  13375. * receiving new props, state and/or context.
  13376. *
  13377. * Use this as an opportunity to `return false` when you're certain that the
  13378. * transition to the new props/state/context will not require a component
  13379. * update.
  13380. *
  13381. * shouldComponentUpdate: function(nextProps, nextState, nextContext) {
  13382. * return !equal(nextProps, this.props) ||
  13383. * !equal(nextState, this.state) ||
  13384. * !equal(nextContext, this.context);
  13385. * }
  13386. *
  13387. * @param {object} nextProps
  13388. * @param {?object} nextState
  13389. * @param {?object} nextContext
  13390. * @return {boolean} True if the component should update.
  13391. * @optional
  13392. */
  13393. shouldComponentUpdate: SpecPolicy.DEFINE_ONCE,
  13394. /**
  13395. * Invoked when the component is about to update due to a transition from
  13396. * `this.props`, `this.state` and `this.context` to `nextProps`, `nextState`
  13397. * and `nextContext`.
  13398. *
  13399. * Use this as an opportunity to perform preparation before an update occurs.
  13400. *
  13401. * NOTE: You **cannot** use `this.setState()` in this method.
  13402. *
  13403. * @param {object} nextProps
  13404. * @param {?object} nextState
  13405. * @param {?object} nextContext
  13406. * @param {ReactReconcileTransaction} transaction
  13407. * @optional
  13408. */
  13409. componentWillUpdate: SpecPolicy.DEFINE_MANY,
  13410. /**
  13411. * Invoked when the component's DOM representation has been updated.
  13412. *
  13413. * Use this as an opportunity to operate on the DOM when the component has
  13414. * been updated.
  13415. *
  13416. * @param {object} prevProps
  13417. * @param {?object} prevState
  13418. * @param {?object} prevContext
  13419. * @param {DOMElement} rootNode DOM element representing the component.
  13420. * @optional
  13421. */
  13422. componentDidUpdate: SpecPolicy.DEFINE_MANY,
  13423. /**
  13424. * Invoked when the component is about to be removed from its parent and have
  13425. * its DOM representation destroyed.
  13426. *
  13427. * Use this as an opportunity to deallocate any external resources.
  13428. *
  13429. * NOTE: There is no `componentDidUnmount` since your component will have been
  13430. * destroyed by that point.
  13431. *
  13432. * @optional
  13433. */
  13434. componentWillUnmount: SpecPolicy.DEFINE_MANY,
  13435. // ==== Advanced methods ====
  13436. /**
  13437. * Updates the component's currently mounted DOM representation.
  13438. *
  13439. * By default, this implements React's rendering and reconciliation algorithm.
  13440. * Sophisticated clients may wish to override this.
  13441. *
  13442. * @param {ReactReconcileTransaction} transaction
  13443. * @internal
  13444. * @overridable
  13445. */
  13446. updateComponent: SpecPolicy.OVERRIDE_BASE
  13447. };
  13448. /**
  13449. * Mapping from class specification keys to special processing functions.
  13450. *
  13451. * Although these are declared like instance properties in the specification
  13452. * when defining classes using `React.createClass`, they are actually static
  13453. * and are accessible on the constructor instead of the prototype. Despite
  13454. * being static, they must be defined outside of the "statics" key under
  13455. * which all other static methods are defined.
  13456. */
  13457. var RESERVED_SPEC_KEYS = {
  13458. displayName: function (Constructor, displayName) {
  13459. Constructor.displayName = displayName;
  13460. },
  13461. mixins: function (Constructor, mixins) {
  13462. if (mixins) {
  13463. for (var i = 0; i < mixins.length; i++) {
  13464. mixSpecIntoComponent(Constructor, mixins[i]);
  13465. }
  13466. }
  13467. },
  13468. childContextTypes: function (Constructor, childContextTypes) {
  13469. if (process.env.NODE_ENV !== 'production') {
  13470. validateTypeDef(Constructor, childContextTypes, ReactPropTypeLocations.childContext);
  13471. }
  13472. Constructor.childContextTypes = assign({}, Constructor.childContextTypes, childContextTypes);
  13473. },
  13474. contextTypes: function (Constructor, contextTypes) {
  13475. if (process.env.NODE_ENV !== 'production') {
  13476. validateTypeDef(Constructor, contextTypes, ReactPropTypeLocations.context);
  13477. }
  13478. Constructor.contextTypes = assign({}, Constructor.contextTypes, contextTypes);
  13479. },
  13480. /**
  13481. * Special case getDefaultProps which should move into statics but requires
  13482. * automatic merging.
  13483. */
  13484. getDefaultProps: function (Constructor, getDefaultProps) {
  13485. if (Constructor.getDefaultProps) {
  13486. Constructor.getDefaultProps = createMergedResultFunction(Constructor.getDefaultProps, getDefaultProps);
  13487. } else {
  13488. Constructor.getDefaultProps = getDefaultProps;
  13489. }
  13490. },
  13491. propTypes: function (Constructor, propTypes) {
  13492. if (process.env.NODE_ENV !== 'production') {
  13493. validateTypeDef(Constructor, propTypes, ReactPropTypeLocations.prop);
  13494. }
  13495. Constructor.propTypes = assign({}, Constructor.propTypes, propTypes);
  13496. },
  13497. statics: function (Constructor, statics) {
  13498. mixStaticSpecIntoComponent(Constructor, statics);
  13499. },
  13500. autobind: function () {} };
  13501. // noop
  13502. function validateTypeDef(Constructor, typeDef, location) {
  13503. for (var propName in typeDef) {
  13504. if (typeDef.hasOwnProperty(propName)) {
  13505. // use a warning instead of an invariant so components
  13506. // don't show up in prod but not in __DEV__
  13507. process.env.NODE_ENV !== 'production' ? warning(typeof typeDef[propName] === 'function', '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', Constructor.displayName || 'ReactClass', ReactPropTypeLocationNames[location], propName) : undefined;
  13508. }
  13509. }
  13510. }
  13511. function validateMethodOverride(proto, name) {
  13512. var specPolicy = ReactClassInterface.hasOwnProperty(name) ? ReactClassInterface[name] : null;
  13513. // Disallow overriding of base class methods unless explicitly allowed.
  13514. if (ReactClassMixin.hasOwnProperty(name)) {
  13515. !(specPolicy === SpecPolicy.OVERRIDE_BASE) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to override ' + '`%s` from your class specification. Ensure that your method names ' + 'do not overlap with React methods.', name) : invariant(false) : undefined;
  13516. }
  13517. // Disallow defining methods more than once unless explicitly allowed.
  13518. if (proto.hasOwnProperty(name)) {
  13519. !(specPolicy === SpecPolicy.DEFINE_MANY || specPolicy === SpecPolicy.DEFINE_MANY_MERGED) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClassInterface: You are attempting to define ' + '`%s` on your component more than once. This conflict may be due ' + 'to a mixin.', name) : invariant(false) : undefined;
  13520. }
  13521. }
  13522. /**
  13523. * Mixin helper which handles policy validation and reserved
  13524. * specification keys when building React classses.
  13525. */
  13526. function mixSpecIntoComponent(Constructor, spec) {
  13527. if (!spec) {
  13528. return;
  13529. }
  13530. !(typeof spec !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component class as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
  13531. !!ReactElement.isValidElement(spec) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You\'re attempting to ' + 'use a component as a mixin. Instead, just use a regular object.') : invariant(false) : undefined;
  13532. var proto = Constructor.prototype;
  13533. // By handling mixins before any other properties, we ensure the same
  13534. // chaining order is applied to methods with DEFINE_MANY policy, whether
  13535. // mixins are listed before or after these methods in the spec.
  13536. if (spec.hasOwnProperty(MIXINS_KEY)) {
  13537. RESERVED_SPEC_KEYS.mixins(Constructor, spec.mixins);
  13538. }
  13539. for (var name in spec) {
  13540. if (!spec.hasOwnProperty(name)) {
  13541. continue;
  13542. }
  13543. if (name === MIXINS_KEY) {
  13544. // We have already handled mixins in a special case above.
  13545. continue;
  13546. }
  13547. var property = spec[name];
  13548. validateMethodOverride(proto, name);
  13549. if (RESERVED_SPEC_KEYS.hasOwnProperty(name)) {
  13550. RESERVED_SPEC_KEYS[name](Constructor, property);
  13551. } else {
  13552. // Setup methods on prototype:
  13553. // The following member methods should not be automatically bound:
  13554. // 1. Expected ReactClass methods (in the "interface").
  13555. // 2. Overridden methods (that were mixed in).
  13556. var isReactClassMethod = ReactClassInterface.hasOwnProperty(name);
  13557. var isAlreadyDefined = proto.hasOwnProperty(name);
  13558. var isFunction = typeof property === 'function';
  13559. var shouldAutoBind = isFunction && !isReactClassMethod && !isAlreadyDefined && spec.autobind !== false;
  13560. if (shouldAutoBind) {
  13561. if (!proto.__reactAutoBindMap) {
  13562. proto.__reactAutoBindMap = {};
  13563. }
  13564. proto.__reactAutoBindMap[name] = property;
  13565. proto[name] = property;
  13566. } else {
  13567. if (isAlreadyDefined) {
  13568. var specPolicy = ReactClassInterface[name];
  13569. // These cases should already be caught by validateMethodOverride.
  13570. !(isReactClassMethod && (specPolicy === SpecPolicy.DEFINE_MANY_MERGED || specPolicy === SpecPolicy.DEFINE_MANY)) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: Unexpected spec policy %s for key %s ' + 'when mixing in component specs.', specPolicy, name) : invariant(false) : undefined;
  13571. // For methods which are defined more than once, call the existing
  13572. // methods before calling the new property, merging if appropriate.
  13573. if (specPolicy === SpecPolicy.DEFINE_MANY_MERGED) {
  13574. proto[name] = createMergedResultFunction(proto[name], property);
  13575. } else if (specPolicy === SpecPolicy.DEFINE_MANY) {
  13576. proto[name] = createChainedFunction(proto[name], property);
  13577. }
  13578. } else {
  13579. proto[name] = property;
  13580. if (process.env.NODE_ENV !== 'production') {
  13581. // Add verbose displayName to the function, which helps when looking
  13582. // at profiling tools.
  13583. if (typeof property === 'function' && spec.displayName) {
  13584. proto[name].displayName = spec.displayName + '_' + name;
  13585. }
  13586. }
  13587. }
  13588. }
  13589. }
  13590. }
  13591. }
  13592. function mixStaticSpecIntoComponent(Constructor, statics) {
  13593. if (!statics) {
  13594. return;
  13595. }
  13596. for (var name in statics) {
  13597. var property = statics[name];
  13598. if (!statics.hasOwnProperty(name)) {
  13599. continue;
  13600. }
  13601. var isReserved = (name in RESERVED_SPEC_KEYS);
  13602. !!isReserved ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define a reserved ' + 'property, `%s`, that shouldn\'t be on the "statics" key. Define it ' + 'as an instance property instead; it will still be accessible on the ' + 'constructor.', name) : invariant(false) : undefined;
  13603. var isInherited = (name in Constructor);
  13604. !!isInherited ? process.env.NODE_ENV !== 'production' ? invariant(false, 'ReactClass: You are attempting to define ' + '`%s` on your component more than once. This conflict may be ' + 'due to a mixin.', name) : invariant(false) : undefined;
  13605. Constructor[name] = property;
  13606. }
  13607. }
  13608. /**
  13609. * Merge two objects, but throw if both contain the same key.
  13610. *
  13611. * @param {object} one The first object, which is mutated.
  13612. * @param {object} two The second object
  13613. * @return {object} one after it has been mutated to contain everything in two.
  13614. */
  13615. function mergeIntoWithNoDuplicateKeys(one, two) {
  13616. !(one && two && typeof one === 'object' && typeof two === 'object') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): Cannot merge non-objects.') : invariant(false) : undefined;
  13617. for (var key in two) {
  13618. if (two.hasOwnProperty(key)) {
  13619. !(one[key] === undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'mergeIntoWithNoDuplicateKeys(): ' + 'Tried to merge two objects with the same key: `%s`. This conflict ' + 'may be due to a mixin; in particular, this may be caused by two ' + 'getInitialState() or getDefaultProps() methods returning objects ' + 'with clashing keys.', key) : invariant(false) : undefined;
  13620. one[key] = two[key];
  13621. }
  13622. }
  13623. return one;
  13624. }
  13625. /**
  13626. * Creates a function that invokes two functions and merges their return values.
  13627. *
  13628. * @param {function} one Function to invoke first.
  13629. * @param {function} two Function to invoke second.
  13630. * @return {function} Function that invokes the two argument functions.
  13631. * @private
  13632. */
  13633. function createMergedResultFunction(one, two) {
  13634. return function mergedResult() {
  13635. var a = one.apply(this, arguments);
  13636. var b = two.apply(this, arguments);
  13637. if (a == null) {
  13638. return b;
  13639. } else if (b == null) {
  13640. return a;
  13641. }
  13642. var c = {};
  13643. mergeIntoWithNoDuplicateKeys(c, a);
  13644. mergeIntoWithNoDuplicateKeys(c, b);
  13645. return c;
  13646. };
  13647. }
  13648. /**
  13649. * Creates a function that invokes two functions and ignores their return vales.
  13650. *
  13651. * @param {function} one Function to invoke first.
  13652. * @param {function} two Function to invoke second.
  13653. * @return {function} Function that invokes the two argument functions.
  13654. * @private
  13655. */
  13656. function createChainedFunction(one, two) {
  13657. return function chainedFunction() {
  13658. one.apply(this, arguments);
  13659. two.apply(this, arguments);
  13660. };
  13661. }
  13662. /**
  13663. * Binds a method to the component.
  13664. *
  13665. * @param {object} component Component whose method is going to be bound.
  13666. * @param {function} method Method to be bound.
  13667. * @return {function} The bound method.
  13668. */
  13669. function bindAutoBindMethod(component, method) {
  13670. var boundMethod = method.bind(component);
  13671. if (process.env.NODE_ENV !== 'production') {
  13672. boundMethod.__reactBoundContext = component;
  13673. boundMethod.__reactBoundMethod = method;
  13674. boundMethod.__reactBoundArguments = null;
  13675. var componentName = component.constructor.displayName;
  13676. var _bind = boundMethod.bind;
  13677. /* eslint-disable block-scoped-var, no-undef */
  13678. boundMethod.bind = function (newThis) {
  13679. for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  13680. args[_key - 1] = arguments[_key];
  13681. }
  13682. // User is trying to bind() an autobound method; we effectively will
  13683. // ignore the value of "this" that the user is trying to use, so
  13684. // let's warn.
  13685. if (newThis !== component && newThis !== null) {
  13686. process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): React component methods may only be bound to the ' + 'component instance. See %s', componentName) : undefined;
  13687. } else if (!args.length) {
  13688. process.env.NODE_ENV !== 'production' ? warning(false, 'bind(): You are binding a component method to the component. ' + 'React does this for you automatically in a high-performance ' + 'way, so you can safely remove this call. See %s', componentName) : undefined;
  13689. return boundMethod;
  13690. }
  13691. var reboundMethod = _bind.apply(boundMethod, arguments);
  13692. reboundMethod.__reactBoundContext = component;
  13693. reboundMethod.__reactBoundMethod = method;
  13694. reboundMethod.__reactBoundArguments = args;
  13695. return reboundMethod;
  13696. /* eslint-enable */
  13697. };
  13698. }
  13699. return boundMethod;
  13700. }
  13701. /**
  13702. * Binds all auto-bound methods in a component.
  13703. *
  13704. * @param {object} component Component whose method is going to be bound.
  13705. */
  13706. function bindAutoBindMethods(component) {
  13707. for (var autoBindKey in component.__reactAutoBindMap) {
  13708. if (component.__reactAutoBindMap.hasOwnProperty(autoBindKey)) {
  13709. var method = component.__reactAutoBindMap[autoBindKey];
  13710. component[autoBindKey] = bindAutoBindMethod(component, method);
  13711. }
  13712. }
  13713. }
  13714. /**
  13715. * Add more to the ReactClass base class. These are all legacy features and
  13716. * therefore not already part of the modern ReactComponent.
  13717. */
  13718. var ReactClassMixin = {
  13719. /**
  13720. * TODO: This will be deprecated because state should always keep a consistent
  13721. * type signature and the only use case for this, is to avoid that.
  13722. */
  13723. replaceState: function (newState, callback) {
  13724. this.updater.enqueueReplaceState(this, newState);
  13725. if (callback) {
  13726. this.updater.enqueueCallback(this, callback);
  13727. }
  13728. },
  13729. /**
  13730. * Checks whether or not this composite component is mounted.
  13731. * @return {boolean} True if mounted, false otherwise.
  13732. * @protected
  13733. * @final
  13734. */
  13735. isMounted: function () {
  13736. return this.updater.isMounted(this);
  13737. },
  13738. /**
  13739. * Sets a subset of the props.
  13740. *
  13741. * @param {object} partialProps Subset of the next props.
  13742. * @param {?function} callback Called after props are updated.
  13743. * @final
  13744. * @public
  13745. * @deprecated
  13746. */
  13747. setProps: function (partialProps, callback) {
  13748. if (process.env.NODE_ENV !== 'production') {
  13749. warnSetProps();
  13750. }
  13751. this.updater.enqueueSetProps(this, partialProps);
  13752. if (callback) {
  13753. this.updater.enqueueCallback(this, callback);
  13754. }
  13755. },
  13756. /**
  13757. * Replace all the props.
  13758. *
  13759. * @param {object} newProps Subset of the next props.
  13760. * @param {?function} callback Called after props are updated.
  13761. * @final
  13762. * @public
  13763. * @deprecated
  13764. */
  13765. replaceProps: function (newProps, callback) {
  13766. if (process.env.NODE_ENV !== 'production') {
  13767. warnSetProps();
  13768. }
  13769. this.updater.enqueueReplaceProps(this, newProps);
  13770. if (callback) {
  13771. this.updater.enqueueCallback(this, callback);
  13772. }
  13773. }
  13774. };
  13775. var ReactClassComponent = function () {};
  13776. assign(ReactClassComponent.prototype, ReactComponent.prototype, ReactClassMixin);
  13777. /**
  13778. * Module for creating composite components.
  13779. *
  13780. * @class ReactClass
  13781. */
  13782. var ReactClass = {
  13783. /**
  13784. * Creates a composite component class given a class specification.
  13785. *
  13786. * @param {object} spec Class specification (which must define `render`).
  13787. * @return {function} Component constructor function.
  13788. * @public
  13789. */
  13790. createClass: function (spec) {
  13791. var Constructor = function (props, context, updater) {
  13792. // This constructor is overridden by mocks. The argument is used
  13793. // by mocks to assert on what gets mounted.
  13794. if (process.env.NODE_ENV !== 'production') {
  13795. process.env.NODE_ENV !== 'production' ? warning(this instanceof Constructor, 'Something is calling a React component directly. Use a factory or ' + 'JSX instead. See: https://fb.me/react-legacyfactory') : undefined;
  13796. }
  13797. // Wire up auto-binding
  13798. if (this.__reactAutoBindMap) {
  13799. bindAutoBindMethods(this);
  13800. }
  13801. this.props = props;
  13802. this.context = context;
  13803. this.refs = emptyObject;
  13804. this.updater = updater || ReactNoopUpdateQueue;
  13805. this.state = null;
  13806. // ReactClasses doesn't have constructors. Instead, they use the
  13807. // getInitialState and componentWillMount methods for initialization.
  13808. var initialState = this.getInitialState ? this.getInitialState() : null;
  13809. if (process.env.NODE_ENV !== 'production') {
  13810. // We allow auto-mocks to proceed as if they're returning null.
  13811. if (typeof initialState === 'undefined' && this.getInitialState._isMockFunction) {
  13812. // This is probably bad practice. Consider warning here and
  13813. // deprecating this convenience.
  13814. initialState = null;
  13815. }
  13816. }
  13817. !(typeof initialState === 'object' && !Array.isArray(initialState)) ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s.getInitialState(): must return an object or null', Constructor.displayName || 'ReactCompositeComponent') : invariant(false) : undefined;
  13818. this.state = initialState;
  13819. };
  13820. Constructor.prototype = new ReactClassComponent();
  13821. Constructor.prototype.constructor = Constructor;
  13822. injectedMixins.forEach(mixSpecIntoComponent.bind(null, Constructor));
  13823. mixSpecIntoComponent(Constructor, spec);
  13824. // Initialize the defaultProps property after all mixins have been merged.
  13825. if (Constructor.getDefaultProps) {
  13826. Constructor.defaultProps = Constructor.getDefaultProps();
  13827. }
  13828. if (process.env.NODE_ENV !== 'production') {
  13829. // This is a tag to indicate that the use of these method names is ok,
  13830. // since it's used with createClass. If it's not, then it's likely a
  13831. // mistake so we'll warn you to use the static property, property
  13832. // initializer or constructor respectively.
  13833. if (Constructor.getDefaultProps) {
  13834. Constructor.getDefaultProps.isReactClassApproved = {};
  13835. }
  13836. if (Constructor.prototype.getInitialState) {
  13837. Constructor.prototype.getInitialState.isReactClassApproved = {};
  13838. }
  13839. }
  13840. !Constructor.prototype.render ? process.env.NODE_ENV !== 'production' ? invariant(false, 'createClass(...): Class specification must implement a `render` method.') : invariant(false) : undefined;
  13841. if (process.env.NODE_ENV !== 'production') {
  13842. process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentShouldUpdate, '%s has a method called ' + 'componentShouldUpdate(). Did you mean shouldComponentUpdate()? ' + 'The name is phrased as a question because the function is ' + 'expected to return a value.', spec.displayName || 'A component') : undefined;
  13843. process.env.NODE_ENV !== 'production' ? warning(!Constructor.prototype.componentWillRecieveProps, '%s has a method called ' + 'componentWillRecieveProps(). Did you mean componentWillReceiveProps()?', spec.displayName || 'A component') : undefined;
  13844. }
  13845. // Reduce time spent doing lookups by setting these on the prototype.
  13846. for (var methodName in ReactClassInterface) {
  13847. if (!Constructor.prototype[methodName]) {
  13848. Constructor.prototype[methodName] = null;
  13849. }
  13850. }
  13851. return Constructor;
  13852. },
  13853. injection: {
  13854. injectMixin: function (mixin) {
  13855. injectedMixins.push(mixin);
  13856. }
  13857. }
  13858. };
  13859. module.exports = ReactClass;
  13860. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  13861. /***/ },
  13862. /* 123 */
  13863. /***/ function(module, exports, __webpack_require__) {
  13864. /* WEBPACK VAR INJECTION */(function(process) {/**
  13865. * Copyright 2013-2015, Facebook, Inc.
  13866. * All rights reserved.
  13867. *
  13868. * This source code is licensed under the BSD-style license found in the
  13869. * LICENSE file in the root directory of this source tree. An additional grant
  13870. * of patent rights can be found in the PATENTS file in the same directory.
  13871. *
  13872. * @providesModule ReactComponent
  13873. */
  13874. 'use strict';
  13875. var ReactNoopUpdateQueue = __webpack_require__(124);
  13876. var canDefineProperty = __webpack_require__(43);
  13877. var emptyObject = __webpack_require__(58);
  13878. var invariant = __webpack_require__(13);
  13879. var warning = __webpack_require__(25);
  13880. /**
  13881. * Base class helpers for the updating state of a component.
  13882. */
  13883. function ReactComponent(props, context, updater) {
  13884. this.props = props;
  13885. this.context = context;
  13886. this.refs = emptyObject;
  13887. // We initialize the default updater but the real one gets injected by the
  13888. // renderer.
  13889. this.updater = updater || ReactNoopUpdateQueue;
  13890. }
  13891. ReactComponent.prototype.isReactComponent = {};
  13892. /**
  13893. * Sets a subset of the state. Always use this to mutate
  13894. * state. You should treat `this.state` as immutable.
  13895. *
  13896. * There is no guarantee that `this.state` will be immediately updated, so
  13897. * accessing `this.state` after calling this method may return the old value.
  13898. *
  13899. * There is no guarantee that calls to `setState` will run synchronously,
  13900. * as they may eventually be batched together. You can provide an optional
  13901. * callback that will be executed when the call to setState is actually
  13902. * completed.
  13903. *
  13904. * When a function is provided to setState, it will be called at some point in
  13905. * the future (not synchronously). It will be called with the up to date
  13906. * component arguments (state, props, context). These values can be different
  13907. * from this.* because your function may be called after receiveProps but before
  13908. * shouldComponentUpdate, and this new state, props, and context will not yet be
  13909. * assigned to this.
  13910. *
  13911. * @param {object|function} partialState Next partial state or function to
  13912. * produce next partial state to be merged with current state.
  13913. * @param {?function} callback Called after state is updated.
  13914. * @final
  13915. * @protected
  13916. */
  13917. ReactComponent.prototype.setState = function (partialState, callback) {
  13918. !(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'setState(...): takes an object of state variables to update or a ' + 'function which returns an object of state variables.') : invariant(false) : undefined;
  13919. if (process.env.NODE_ENV !== 'production') {
  13920. process.env.NODE_ENV !== 'production' ? warning(partialState != null, 'setState(...): You passed an undefined or null state object; ' + 'instead, use forceUpdate().') : undefined;
  13921. }
  13922. this.updater.enqueueSetState(this, partialState);
  13923. if (callback) {
  13924. this.updater.enqueueCallback(this, callback);
  13925. }
  13926. };
  13927. /**
  13928. * Forces an update. This should only be invoked when it is known with
  13929. * certainty that we are **not** in a DOM transaction.
  13930. *
  13931. * You may want to call this when you know that some deeper aspect of the
  13932. * component's state has changed but `setState` was not called.
  13933. *
  13934. * This will not invoke `shouldComponentUpdate`, but it will invoke
  13935. * `componentWillUpdate` and `componentDidUpdate`.
  13936. *
  13937. * @param {?function} callback Called after update is complete.
  13938. * @final
  13939. * @protected
  13940. */
  13941. ReactComponent.prototype.forceUpdate = function (callback) {
  13942. this.updater.enqueueForceUpdate(this);
  13943. if (callback) {
  13944. this.updater.enqueueCallback(this, callback);
  13945. }
  13946. };
  13947. /**
  13948. * Deprecated APIs. These APIs used to exist on classic React classes but since
  13949. * we would like to deprecate them, we're not going to move them over to this
  13950. * modern base class. Instead, we define a getter that warns if it's accessed.
  13951. */
  13952. if (process.env.NODE_ENV !== 'production') {
  13953. var deprecatedAPIs = {
  13954. getDOMNode: ['getDOMNode', 'Use ReactDOM.findDOMNode(component) instead.'],
  13955. isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
  13956. replaceProps: ['replaceProps', 'Instead, call render again at the top level.'],
  13957. replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).'],
  13958. setProps: ['setProps', 'Instead, call render again at the top level.']
  13959. };
  13960. var defineDeprecationWarning = function (methodName, info) {
  13961. if (canDefineProperty) {
  13962. Object.defineProperty(ReactComponent.prototype, methodName, {
  13963. get: function () {
  13964. process.env.NODE_ENV !== 'production' ? warning(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]) : undefined;
  13965. return undefined;
  13966. }
  13967. });
  13968. }
  13969. };
  13970. for (var fnName in deprecatedAPIs) {
  13971. if (deprecatedAPIs.hasOwnProperty(fnName)) {
  13972. defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
  13973. }
  13974. }
  13975. }
  13976. module.exports = ReactComponent;
  13977. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  13978. /***/ },
  13979. /* 124 */
  13980. /***/ function(module, exports, __webpack_require__) {
  13981. /* WEBPACK VAR INJECTION */(function(process) {/**
  13982. * Copyright 2015, Facebook, Inc.
  13983. * All rights reserved.
  13984. *
  13985. * This source code is licensed under the BSD-style license found in the
  13986. * LICENSE file in the root directory of this source tree. An additional grant
  13987. * of patent rights can be found in the PATENTS file in the same directory.
  13988. *
  13989. * @providesModule ReactNoopUpdateQueue
  13990. */
  13991. 'use strict';
  13992. var warning = __webpack_require__(25);
  13993. function warnTDZ(publicInstance, callerName) {
  13994. if (process.env.NODE_ENV !== 'production') {
  13995. process.env.NODE_ENV !== 'production' ? warning(false, '%s(...): Can only update a mounted or mounting component. ' + 'This usually means you called %s() on an unmounted component. ' + 'This is a no-op. Please check the code for the %s component.', callerName, callerName, publicInstance.constructor && publicInstance.constructor.displayName || '') : undefined;
  13996. }
  13997. }
  13998. /**
  13999. * This is the abstract API for an update queue.
  14000. */
  14001. var ReactNoopUpdateQueue = {
  14002. /**
  14003. * Checks whether or not this composite component is mounted.
  14004. * @param {ReactClass} publicInstance The instance we want to test.
  14005. * @return {boolean} True if mounted, false otherwise.
  14006. * @protected
  14007. * @final
  14008. */
  14009. isMounted: function (publicInstance) {
  14010. return false;
  14011. },
  14012. /**
  14013. * Enqueue a callback that will be executed after all the pending updates
  14014. * have processed.
  14015. *
  14016. * @param {ReactClass} publicInstance The instance to use as `this` context.
  14017. * @param {?function} callback Called after state is updated.
  14018. * @internal
  14019. */
  14020. enqueueCallback: function (publicInstance, callback) {},
  14021. /**
  14022. * Forces an update. This should only be invoked when it is known with
  14023. * certainty that we are **not** in a DOM transaction.
  14024. *
  14025. * You may want to call this when you know that some deeper aspect of the
  14026. * component's state has changed but `setState` was not called.
  14027. *
  14028. * This will not invoke `shouldComponentUpdate`, but it will invoke
  14029. * `componentWillUpdate` and `componentDidUpdate`.
  14030. *
  14031. * @param {ReactClass} publicInstance The instance that should rerender.
  14032. * @internal
  14033. */
  14034. enqueueForceUpdate: function (publicInstance) {
  14035. warnTDZ(publicInstance, 'forceUpdate');
  14036. },
  14037. /**
  14038. * Replaces all of the state. Always use this or `setState` to mutate state.
  14039. * You should treat `this.state` as immutable.
  14040. *
  14041. * There is no guarantee that `this.state` will be immediately updated, so
  14042. * accessing `this.state` after calling this method may return the old value.
  14043. *
  14044. * @param {ReactClass} publicInstance The instance that should rerender.
  14045. * @param {object} completeState Next state.
  14046. * @internal
  14047. */
  14048. enqueueReplaceState: function (publicInstance, completeState) {
  14049. warnTDZ(publicInstance, 'replaceState');
  14050. },
  14051. /**
  14052. * Sets a subset of the state. This only exists because _pendingState is
  14053. * internal. This provides a merging strategy that is not available to deep
  14054. * properties which is confusing. TODO: Expose pendingState or don't use it
  14055. * during the merge.
  14056. *
  14057. * @param {ReactClass} publicInstance The instance that should rerender.
  14058. * @param {object} partialState Next partial state to be merged with state.
  14059. * @internal
  14060. */
  14061. enqueueSetState: function (publicInstance, partialState) {
  14062. warnTDZ(publicInstance, 'setState');
  14063. },
  14064. /**
  14065. * Sets a subset of the props.
  14066. *
  14067. * @param {ReactClass} publicInstance The instance that should rerender.
  14068. * @param {object} partialProps Subset of the next props.
  14069. * @internal
  14070. */
  14071. enqueueSetProps: function (publicInstance, partialProps) {
  14072. warnTDZ(publicInstance, 'setProps');
  14073. },
  14074. /**
  14075. * Replaces all of the props.
  14076. *
  14077. * @param {ReactClass} publicInstance The instance that should rerender.
  14078. * @param {object} props New props.
  14079. * @internal
  14080. */
  14081. enqueueReplaceProps: function (publicInstance, props) {
  14082. warnTDZ(publicInstance, 'replaceProps');
  14083. }
  14084. };
  14085. module.exports = ReactNoopUpdateQueue;
  14086. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  14087. /***/ },
  14088. /* 125 */
  14089. /***/ function(module, exports, __webpack_require__) {
  14090. /**
  14091. * Copyright 2013-2015, Facebook, Inc.
  14092. * All rights reserved.
  14093. *
  14094. * This source code is licensed under the BSD-style license found in the
  14095. * LICENSE file in the root directory of this source tree. An additional grant
  14096. * of patent rights can be found in the PATENTS file in the same directory.
  14097. *
  14098. * @providesModule ReactReconcileTransaction
  14099. * @typechecks static-only
  14100. */
  14101. 'use strict';
  14102. var CallbackQueue = __webpack_require__(55);
  14103. var PooledClass = __webpack_require__(56);
  14104. var ReactBrowserEventEmitter = __webpack_require__(29);
  14105. var ReactDOMFeatureFlags = __webpack_require__(41);
  14106. var ReactInputSelection = __webpack_require__(126);
  14107. var Transaction = __webpack_require__(57);
  14108. var assign = __webpack_require__(39);
  14109. /**
  14110. * Ensures that, when possible, the selection range (currently selected text
  14111. * input) is not disturbed by performing the transaction.
  14112. */
  14113. var SELECTION_RESTORATION = {
  14114. /**
  14115. * @return {Selection} Selection information.
  14116. */
  14117. initialize: ReactInputSelection.getSelectionInformation,
  14118. /**
  14119. * @param {Selection} sel Selection information returned from `initialize`.
  14120. */
  14121. close: ReactInputSelection.restoreSelection
  14122. };
  14123. /**
  14124. * Suppresses events (blur/focus) that could be inadvertently dispatched due to
  14125. * high level DOM manipulations (like temporarily removing a text input from the
  14126. * DOM).
  14127. */
  14128. var EVENT_SUPPRESSION = {
  14129. /**
  14130. * @return {boolean} The enabled status of `ReactBrowserEventEmitter` before
  14131. * the reconciliation.
  14132. */
  14133. initialize: function () {
  14134. var currentlyEnabled = ReactBrowserEventEmitter.isEnabled();
  14135. ReactBrowserEventEmitter.setEnabled(false);
  14136. return currentlyEnabled;
  14137. },
  14138. /**
  14139. * @param {boolean} previouslyEnabled Enabled status of
  14140. * `ReactBrowserEventEmitter` before the reconciliation occurred. `close`
  14141. * restores the previous value.
  14142. */
  14143. close: function (previouslyEnabled) {
  14144. ReactBrowserEventEmitter.setEnabled(previouslyEnabled);
  14145. }
  14146. };
  14147. /**
  14148. * Provides a queue for collecting `componentDidMount` and
  14149. * `componentDidUpdate` callbacks during the the transaction.
  14150. */
  14151. var ON_DOM_READY_QUEUEING = {
  14152. /**
  14153. * Initializes the internal `onDOMReady` queue.
  14154. */
  14155. initialize: function () {
  14156. this.reactMountReady.reset();
  14157. },
  14158. /**
  14159. * After DOM is flushed, invoke all registered `onDOMReady` callbacks.
  14160. */
  14161. close: function () {
  14162. this.reactMountReady.notifyAll();
  14163. }
  14164. };
  14165. /**
  14166. * Executed within the scope of the `Transaction` instance. Consider these as
  14167. * being member methods, but with an implied ordering while being isolated from
  14168. * each other.
  14169. */
  14170. var TRANSACTION_WRAPPERS = [SELECTION_RESTORATION, EVENT_SUPPRESSION, ON_DOM_READY_QUEUEING];
  14171. /**
  14172. * Currently:
  14173. * - The order that these are listed in the transaction is critical:
  14174. * - Suppresses events.
  14175. * - Restores selection range.
  14176. *
  14177. * Future:
  14178. * - Restore document/overflow scroll positions that were unintentionally
  14179. * modified via DOM insertions above the top viewport boundary.
  14180. * - Implement/integrate with customized constraint based layout system and keep
  14181. * track of which dimensions must be remeasured.
  14182. *
  14183. * @class ReactReconcileTransaction
  14184. */
  14185. function ReactReconcileTransaction(forceHTML) {
  14186. this.reinitializeTransaction();
  14187. // Only server-side rendering really needs this option (see
  14188. // `ReactServerRendering`), but server-side uses
  14189. // `ReactServerRenderingTransaction` instead. This option is here so that it's
  14190. // accessible and defaults to false when `ReactDOMComponent` and
  14191. // `ReactTextComponent` checks it in `mountComponent`.`
  14192. this.renderToStaticMarkup = false;
  14193. this.reactMountReady = CallbackQueue.getPooled(null);
  14194. this.useCreateElement = !forceHTML && ReactDOMFeatureFlags.useCreateElement;
  14195. }
  14196. var Mixin = {
  14197. /**
  14198. * @see Transaction
  14199. * @abstract
  14200. * @final
  14201. * @return {array<object>} List of operation wrap procedures.
  14202. * TODO: convert to array<TransactionWrapper>
  14203. */
  14204. getTransactionWrappers: function () {
  14205. return TRANSACTION_WRAPPERS;
  14206. },
  14207. /**
  14208. * @return {object} The queue to collect `onDOMReady` callbacks with.
  14209. */
  14210. getReactMountReady: function () {
  14211. return this.reactMountReady;
  14212. },
  14213. /**
  14214. * `PooledClass` looks for this, and will invoke this before allowing this
  14215. * instance to be reused.
  14216. */
  14217. destructor: function () {
  14218. CallbackQueue.release(this.reactMountReady);
  14219. this.reactMountReady = null;
  14220. }
  14221. };
  14222. assign(ReactReconcileTransaction.prototype, Transaction.Mixin, Mixin);
  14223. PooledClass.addPoolingTo(ReactReconcileTransaction);
  14224. module.exports = ReactReconcileTransaction;
  14225. /***/ },
  14226. /* 126 */
  14227. /***/ function(module, exports, __webpack_require__) {
  14228. /**
  14229. * Copyright 2013-2015, Facebook, Inc.
  14230. * All rights reserved.
  14231. *
  14232. * This source code is licensed under the BSD-style license found in the
  14233. * LICENSE file in the root directory of this source tree. An additional grant
  14234. * of patent rights can be found in the PATENTS file in the same directory.
  14235. *
  14236. * @providesModule ReactInputSelection
  14237. */
  14238. 'use strict';
  14239. var ReactDOMSelection = __webpack_require__(127);
  14240. var containsNode = __webpack_require__(59);
  14241. var focusNode = __webpack_require__(95);
  14242. var getActiveElement = __webpack_require__(129);
  14243. function isInDocument(node) {
  14244. return containsNode(document.documentElement, node);
  14245. }
  14246. /**
  14247. * @ReactInputSelection: React input selection module. Based on Selection.js,
  14248. * but modified to be suitable for react and has a couple of bug fixes (doesn't
  14249. * assume buttons have range selections allowed).
  14250. * Input selection module for React.
  14251. */
  14252. var ReactInputSelection = {
  14253. hasSelectionCapabilities: function (elem) {
  14254. var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
  14255. return nodeName && (nodeName === 'input' && elem.type === 'text' || nodeName === 'textarea' || elem.contentEditable === 'true');
  14256. },
  14257. getSelectionInformation: function () {
  14258. var focusedElem = getActiveElement();
  14259. return {
  14260. focusedElem: focusedElem,
  14261. selectionRange: ReactInputSelection.hasSelectionCapabilities(focusedElem) ? ReactInputSelection.getSelection(focusedElem) : null
  14262. };
  14263. },
  14264. /**
  14265. * @restoreSelection: If any selection information was potentially lost,
  14266. * restore it. This is useful when performing operations that could remove dom
  14267. * nodes and place them back in, resulting in focus being lost.
  14268. */
  14269. restoreSelection: function (priorSelectionInformation) {
  14270. var curFocusedElem = getActiveElement();
  14271. var priorFocusedElem = priorSelectionInformation.focusedElem;
  14272. var priorSelectionRange = priorSelectionInformation.selectionRange;
  14273. if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
  14274. if (ReactInputSelection.hasSelectionCapabilities(priorFocusedElem)) {
  14275. ReactInputSelection.setSelection(priorFocusedElem, priorSelectionRange);
  14276. }
  14277. focusNode(priorFocusedElem);
  14278. }
  14279. },
  14280. /**
  14281. * @getSelection: Gets the selection bounds of a focused textarea, input or
  14282. * contentEditable node.
  14283. * -@input: Look up selection bounds of this input
  14284. * -@return {start: selectionStart, end: selectionEnd}
  14285. */
  14286. getSelection: function (input) {
  14287. var selection;
  14288. if ('selectionStart' in input) {
  14289. // Modern browser with input or textarea.
  14290. selection = {
  14291. start: input.selectionStart,
  14292. end: input.selectionEnd
  14293. };
  14294. } else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
  14295. // IE8 input.
  14296. var range = document.selection.createRange();
  14297. // There can only be one selection per document in IE, so it must
  14298. // be in our element.
  14299. if (range.parentElement() === input) {
  14300. selection = {
  14301. start: -range.moveStart('character', -input.value.length),
  14302. end: -range.moveEnd('character', -input.value.length)
  14303. };
  14304. }
  14305. } else {
  14306. // Content editable or old IE textarea.
  14307. selection = ReactDOMSelection.getOffsets(input);
  14308. }
  14309. return selection || { start: 0, end: 0 };
  14310. },
  14311. /**
  14312. * @setSelection: Sets the selection bounds of a textarea or input and focuses
  14313. * the input.
  14314. * -@input Set selection bounds of this input or textarea
  14315. * -@offsets Object of same form that is returned from get*
  14316. */
  14317. setSelection: function (input, offsets) {
  14318. var start = offsets.start;
  14319. var end = offsets.end;
  14320. if (typeof end === 'undefined') {
  14321. end = start;
  14322. }
  14323. if ('selectionStart' in input) {
  14324. input.selectionStart = start;
  14325. input.selectionEnd = Math.min(end, input.value.length);
  14326. } else if (document.selection && (input.nodeName && input.nodeName.toLowerCase() === 'input')) {
  14327. var range = input.createTextRange();
  14328. range.collapse(true);
  14329. range.moveStart('character', start);
  14330. range.moveEnd('character', end - start);
  14331. range.select();
  14332. } else {
  14333. ReactDOMSelection.setOffsets(input, offsets);
  14334. }
  14335. }
  14336. };
  14337. module.exports = ReactInputSelection;
  14338. /***/ },
  14339. /* 127 */
  14340. /***/ function(module, exports, __webpack_require__) {
  14341. /**
  14342. * Copyright 2013-2015, Facebook, Inc.
  14343. * All rights reserved.
  14344. *
  14345. * This source code is licensed under the BSD-style license found in the
  14346. * LICENSE file in the root directory of this source tree. An additional grant
  14347. * of patent rights can be found in the PATENTS file in the same directory.
  14348. *
  14349. * @providesModule ReactDOMSelection
  14350. */
  14351. 'use strict';
  14352. var ExecutionEnvironment = __webpack_require__(9);
  14353. var getNodeForCharacterOffset = __webpack_require__(128);
  14354. var getTextContentAccessor = __webpack_require__(75);
  14355. /**
  14356. * While `isCollapsed` is available on the Selection object and `collapsed`
  14357. * is available on the Range object, IE11 sometimes gets them wrong.
  14358. * If the anchor/focus nodes and offsets are the same, the range is collapsed.
  14359. */
  14360. function isCollapsed(anchorNode, anchorOffset, focusNode, focusOffset) {
  14361. return anchorNode === focusNode && anchorOffset === focusOffset;
  14362. }
  14363. /**
  14364. * Get the appropriate anchor and focus node/offset pairs for IE.
  14365. *
  14366. * The catch here is that IE's selection API doesn't provide information
  14367. * about whether the selection is forward or backward, so we have to
  14368. * behave as though it's always forward.
  14369. *
  14370. * IE text differs from modern selection in that it behaves as though
  14371. * block elements end with a new line. This means character offsets will
  14372. * differ between the two APIs.
  14373. *
  14374. * @param {DOMElement} node
  14375. * @return {object}
  14376. */
  14377. function getIEOffsets(node) {
  14378. var selection = document.selection;
  14379. var selectedRange = selection.createRange();
  14380. var selectedLength = selectedRange.text.length;
  14381. // Duplicate selection so we can move range without breaking user selection.
  14382. var fromStart = selectedRange.duplicate();
  14383. fromStart.moveToElementText(node);
  14384. fromStart.setEndPoint('EndToStart', selectedRange);
  14385. var startOffset = fromStart.text.length;
  14386. var endOffset = startOffset + selectedLength;
  14387. return {
  14388. start: startOffset,
  14389. end: endOffset
  14390. };
  14391. }
  14392. /**
  14393. * @param {DOMElement} node
  14394. * @return {?object}
  14395. */
  14396. function getModernOffsets(node) {
  14397. var selection = window.getSelection && window.getSelection();
  14398. if (!selection || selection.rangeCount === 0) {
  14399. return null;
  14400. }
  14401. var anchorNode = selection.anchorNode;
  14402. var anchorOffset = selection.anchorOffset;
  14403. var focusNode = selection.focusNode;
  14404. var focusOffset = selection.focusOffset;
  14405. var currentRange = selection.getRangeAt(0);
  14406. // In Firefox, range.startContainer and range.endContainer can be "anonymous
  14407. // divs", e.g. the up/down buttons on an <input type="number">. Anonymous
  14408. // divs do not seem to expose properties, triggering a "Permission denied
  14409. // error" if any of its properties are accessed. The only seemingly possible
  14410. // way to avoid erroring is to access a property that typically works for
  14411. // non-anonymous divs and catch any error that may otherwise arise. See
  14412. // https://bugzilla.mozilla.org/show_bug.cgi?id=208427
  14413. try {
  14414. /* eslint-disable no-unused-expressions */
  14415. currentRange.startContainer.nodeType;
  14416. currentRange.endContainer.nodeType;
  14417. /* eslint-enable no-unused-expressions */
  14418. } catch (e) {
  14419. return null;
  14420. }
  14421. // If the node and offset values are the same, the selection is collapsed.
  14422. // `Selection.isCollapsed` is available natively, but IE sometimes gets
  14423. // this value wrong.
  14424. var isSelectionCollapsed = isCollapsed(selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
  14425. var rangeLength = isSelectionCollapsed ? 0 : currentRange.toString().length;
  14426. var tempRange = currentRange.cloneRange();
  14427. tempRange.selectNodeContents(node);
  14428. tempRange.setEnd(currentRange.startContainer, currentRange.startOffset);
  14429. var isTempRangeCollapsed = isCollapsed(tempRange.startContainer, tempRange.startOffset, tempRange.endContainer, tempRange.endOffset);
  14430. var start = isTempRangeCollapsed ? 0 : tempRange.toString().length;
  14431. var end = start + rangeLength;
  14432. // Detect whether the selection is backward.
  14433. var detectionRange = document.createRange();
  14434. detectionRange.setStart(anchorNode, anchorOffset);
  14435. detectionRange.setEnd(focusNode, focusOffset);
  14436. var isBackward = detectionRange.collapsed;
  14437. return {
  14438. start: isBackward ? end : start,
  14439. end: isBackward ? start : end
  14440. };
  14441. }
  14442. /**
  14443. * @param {DOMElement|DOMTextNode} node
  14444. * @param {object} offsets
  14445. */
  14446. function setIEOffsets(node, offsets) {
  14447. var range = document.selection.createRange().duplicate();
  14448. var start, end;
  14449. if (typeof offsets.end === 'undefined') {
  14450. start = offsets.start;
  14451. end = start;
  14452. } else if (offsets.start > offsets.end) {
  14453. start = offsets.end;
  14454. end = offsets.start;
  14455. } else {
  14456. start = offsets.start;
  14457. end = offsets.end;
  14458. }
  14459. range.moveToElementText(node);
  14460. range.moveStart('character', start);
  14461. range.setEndPoint('EndToStart', range);
  14462. range.moveEnd('character', end - start);
  14463. range.select();
  14464. }
  14465. /**
  14466. * In modern non-IE browsers, we can support both forward and backward
  14467. * selections.
  14468. *
  14469. * Note: IE10+ supports the Selection object, but it does not support
  14470. * the `extend` method, which means that even in modern IE, it's not possible
  14471. * to programatically create a backward selection. Thus, for all IE
  14472. * versions, we use the old IE API to create our selections.
  14473. *
  14474. * @param {DOMElement|DOMTextNode} node
  14475. * @param {object} offsets
  14476. */
  14477. function setModernOffsets(node, offsets) {
  14478. if (!window.getSelection) {
  14479. return;
  14480. }
  14481. var selection = window.getSelection();
  14482. var length = node[getTextContentAccessor()].length;
  14483. var start = Math.min(offsets.start, length);
  14484. var end = typeof offsets.end === 'undefined' ? start : Math.min(offsets.end, length);
  14485. // IE 11 uses modern selection, but doesn't support the extend method.
  14486. // Flip backward selections, so we can set with a single range.
  14487. if (!selection.extend && start > end) {
  14488. var temp = end;
  14489. end = start;
  14490. start = temp;
  14491. }
  14492. var startMarker = getNodeForCharacterOffset(node, start);
  14493. var endMarker = getNodeForCharacterOffset(node, end);
  14494. if (startMarker && endMarker) {
  14495. var range = document.createRange();
  14496. range.setStart(startMarker.node, startMarker.offset);
  14497. selection.removeAllRanges();
  14498. if (start > end) {
  14499. selection.addRange(range);
  14500. selection.extend(endMarker.node, endMarker.offset);
  14501. } else {
  14502. range.setEnd(endMarker.node, endMarker.offset);
  14503. selection.addRange(range);
  14504. }
  14505. }
  14506. }
  14507. var useIEOffsets = ExecutionEnvironment.canUseDOM && 'selection' in document && !('getSelection' in window);
  14508. var ReactDOMSelection = {
  14509. /**
  14510. * @param {DOMElement} node
  14511. */
  14512. getOffsets: useIEOffsets ? getIEOffsets : getModernOffsets,
  14513. /**
  14514. * @param {DOMElement|DOMTextNode} node
  14515. * @param {object} offsets
  14516. */
  14517. setOffsets: useIEOffsets ? setIEOffsets : setModernOffsets
  14518. };
  14519. module.exports = ReactDOMSelection;
  14520. /***/ },
  14521. /* 128 */
  14522. /***/ function(module, exports) {
  14523. /**
  14524. * Copyright 2013-2015, Facebook, Inc.
  14525. * All rights reserved.
  14526. *
  14527. * This source code is licensed under the BSD-style license found in the
  14528. * LICENSE file in the root directory of this source tree. An additional grant
  14529. * of patent rights can be found in the PATENTS file in the same directory.
  14530. *
  14531. * @providesModule getNodeForCharacterOffset
  14532. */
  14533. 'use strict';
  14534. /**
  14535. * Given any node return the first leaf node without children.
  14536. *
  14537. * @param {DOMElement|DOMTextNode} node
  14538. * @return {DOMElement|DOMTextNode}
  14539. */
  14540. function getLeafNode(node) {
  14541. while (node && node.firstChild) {
  14542. node = node.firstChild;
  14543. }
  14544. return node;
  14545. }
  14546. /**
  14547. * Get the next sibling within a container. This will walk up the
  14548. * DOM if a node's siblings have been exhausted.
  14549. *
  14550. * @param {DOMElement|DOMTextNode} node
  14551. * @return {?DOMElement|DOMTextNode}
  14552. */
  14553. function getSiblingNode(node) {
  14554. while (node) {
  14555. if (node.nextSibling) {
  14556. return node.nextSibling;
  14557. }
  14558. node = node.parentNode;
  14559. }
  14560. }
  14561. /**
  14562. * Get object describing the nodes which contain characters at offset.
  14563. *
  14564. * @param {DOMElement|DOMTextNode} root
  14565. * @param {number} offset
  14566. * @return {?object}
  14567. */
  14568. function getNodeForCharacterOffset(root, offset) {
  14569. var node = getLeafNode(root);
  14570. var nodeStart = 0;
  14571. var nodeEnd = 0;
  14572. while (node) {
  14573. if (node.nodeType === 3) {
  14574. nodeEnd = nodeStart + node.textContent.length;
  14575. if (nodeStart <= offset && nodeEnd >= offset) {
  14576. return {
  14577. node: node,
  14578. offset: offset - nodeStart
  14579. };
  14580. }
  14581. nodeStart = nodeEnd;
  14582. }
  14583. node = getLeafNode(getSiblingNode(node));
  14584. }
  14585. }
  14586. module.exports = getNodeForCharacterOffset;
  14587. /***/ },
  14588. /* 129 */
  14589. /***/ function(module, exports) {
  14590. /**
  14591. * Copyright 2013-2015, Facebook, Inc.
  14592. * All rights reserved.
  14593. *
  14594. * This source code is licensed under the BSD-style license found in the
  14595. * LICENSE file in the root directory of this source tree. An additional grant
  14596. * of patent rights can be found in the PATENTS file in the same directory.
  14597. *
  14598. * @providesModule getActiveElement
  14599. * @typechecks
  14600. */
  14601. /* eslint-disable fb-www/typeof-undefined */
  14602. /**
  14603. * Same as document.activeElement but wraps in a try-catch block. In IE it is
  14604. * not safe to call document.activeElement if there is nothing focused.
  14605. *
  14606. * The activeElement will be null only if the document or document body is not
  14607. * yet defined.
  14608. */
  14609. 'use strict';
  14610. function getActiveElement() /*?DOMElement*/{
  14611. if (typeof document === 'undefined') {
  14612. return null;
  14613. }
  14614. try {
  14615. return document.activeElement || document.body;
  14616. } catch (e) {
  14617. return document.body;
  14618. }
  14619. }
  14620. module.exports = getActiveElement;
  14621. /***/ },
  14622. /* 130 */
  14623. /***/ function(module, exports, __webpack_require__) {
  14624. /**
  14625. * Copyright 2013-2015, Facebook, Inc.
  14626. * All rights reserved.
  14627. *
  14628. * This source code is licensed under the BSD-style license found in the
  14629. * LICENSE file in the root directory of this source tree. An additional grant
  14630. * of patent rights can be found in the PATENTS file in the same directory.
  14631. *
  14632. * @providesModule SelectEventPlugin
  14633. */
  14634. 'use strict';
  14635. var EventConstants = __webpack_require__(30);
  14636. var EventPropagators = __webpack_require__(73);
  14637. var ExecutionEnvironment = __webpack_require__(9);
  14638. var ReactInputSelection = __webpack_require__(126);
  14639. var SyntheticEvent = __webpack_require__(77);
  14640. var getActiveElement = __webpack_require__(129);
  14641. var isTextInputElement = __webpack_require__(82);
  14642. var keyOf = __webpack_require__(79);
  14643. var shallowEqual = __webpack_require__(117);
  14644. var topLevelTypes = EventConstants.topLevelTypes;
  14645. var skipSelectionChangeEvent = ExecutionEnvironment.canUseDOM && 'documentMode' in document && document.documentMode <= 11;
  14646. var eventTypes = {
  14647. select: {
  14648. phasedRegistrationNames: {
  14649. bubbled: keyOf({ onSelect: null }),
  14650. captured: keyOf({ onSelectCapture: null })
  14651. },
  14652. dependencies: [topLevelTypes.topBlur, topLevelTypes.topContextMenu, topLevelTypes.topFocus, topLevelTypes.topKeyDown, topLevelTypes.topMouseDown, topLevelTypes.topMouseUp, topLevelTypes.topSelectionChange]
  14653. }
  14654. };
  14655. var activeElement = null;
  14656. var activeElementID = null;
  14657. var lastSelection = null;
  14658. var mouseDown = false;
  14659. // Track whether a listener exists for this plugin. If none exist, we do
  14660. // not extract events.
  14661. var hasListener = false;
  14662. var ON_SELECT_KEY = keyOf({ onSelect: null });
  14663. /**
  14664. * Get an object which is a unique representation of the current selection.
  14665. *
  14666. * The return value will not be consistent across nodes or browsers, but
  14667. * two identical selections on the same node will return identical objects.
  14668. *
  14669. * @param {DOMElement} node
  14670. * @return {object}
  14671. */
  14672. function getSelection(node) {
  14673. if ('selectionStart' in node && ReactInputSelection.hasSelectionCapabilities(node)) {
  14674. return {
  14675. start: node.selectionStart,
  14676. end: node.selectionEnd
  14677. };
  14678. } else if (window.getSelection) {
  14679. var selection = window.getSelection();
  14680. return {
  14681. anchorNode: selection.anchorNode,
  14682. anchorOffset: selection.anchorOffset,
  14683. focusNode: selection.focusNode,
  14684. focusOffset: selection.focusOffset
  14685. };
  14686. } else if (document.selection) {
  14687. var range = document.selection.createRange();
  14688. return {
  14689. parentElement: range.parentElement(),
  14690. text: range.text,
  14691. top: range.boundingTop,
  14692. left: range.boundingLeft
  14693. };
  14694. }
  14695. }
  14696. /**
  14697. * Poll selection to see whether it's changed.
  14698. *
  14699. * @param {object} nativeEvent
  14700. * @return {?SyntheticEvent}
  14701. */
  14702. function constructSelectEvent(nativeEvent, nativeEventTarget) {
  14703. // Ensure we have the right element, and that the user is not dragging a
  14704. // selection (this matches native `select` event behavior). In HTML5, select
  14705. // fires only on input and textarea thus if there's no focused element we
  14706. // won't dispatch.
  14707. if (mouseDown || activeElement == null || activeElement !== getActiveElement()) {
  14708. return null;
  14709. }
  14710. // Only fire when selection has actually changed.
  14711. var currentSelection = getSelection(activeElement);
  14712. if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
  14713. lastSelection = currentSelection;
  14714. var syntheticEvent = SyntheticEvent.getPooled(eventTypes.select, activeElementID, nativeEvent, nativeEventTarget);
  14715. syntheticEvent.type = 'select';
  14716. syntheticEvent.target = activeElement;
  14717. EventPropagators.accumulateTwoPhaseDispatches(syntheticEvent);
  14718. return syntheticEvent;
  14719. }
  14720. return null;
  14721. }
  14722. /**
  14723. * This plugin creates an `onSelect` event that normalizes select events
  14724. * across form elements.
  14725. *
  14726. * Supported elements are:
  14727. * - input (see `isTextInputElement`)
  14728. * - textarea
  14729. * - contentEditable
  14730. *
  14731. * This differs from native browser implementations in the following ways:
  14732. * - Fires on contentEditable fields as well as inputs.
  14733. * - Fires for collapsed selection.
  14734. * - Fires after user input.
  14735. */
  14736. var SelectEventPlugin = {
  14737. eventTypes: eventTypes,
  14738. /**
  14739. * @param {string} topLevelType Record from `EventConstants`.
  14740. * @param {DOMEventTarget} topLevelTarget The listening component root node.
  14741. * @param {string} topLevelTargetID ID of `topLevelTarget`.
  14742. * @param {object} nativeEvent Native browser event.
  14743. * @return {*} An accumulation of synthetic events.
  14744. * @see {EventPluginHub.extractEvents}
  14745. */
  14746. extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
  14747. if (!hasListener) {
  14748. return null;
  14749. }
  14750. switch (topLevelType) {
  14751. // Track the input node that has focus.
  14752. case topLevelTypes.topFocus:
  14753. if (isTextInputElement(topLevelTarget) || topLevelTarget.contentEditable === 'true') {
  14754. activeElement = topLevelTarget;
  14755. activeElementID = topLevelTargetID;
  14756. lastSelection = null;
  14757. }
  14758. break;
  14759. case topLevelTypes.topBlur:
  14760. activeElement = null;
  14761. activeElementID = null;
  14762. lastSelection = null;
  14763. break;
  14764. // Don't fire the event while the user is dragging. This matches the
  14765. // semantics of the native select event.
  14766. case topLevelTypes.topMouseDown:
  14767. mouseDown = true;
  14768. break;
  14769. case topLevelTypes.topContextMenu:
  14770. case topLevelTypes.topMouseUp:
  14771. mouseDown = false;
  14772. return constructSelectEvent(nativeEvent, nativeEventTarget);
  14773. // Chrome and IE fire non-standard event when selection is changed (and
  14774. // sometimes when it hasn't). IE's event fires out of order with respect
  14775. // to key and input events on deletion, so we discard it.
  14776. //
  14777. // Firefox doesn't support selectionchange, so check selection status
  14778. // after each key entry. The selection changes after keydown and before
  14779. // keyup, but we check on keydown as well in the case of holding down a
  14780. // key, when multiple keydown events are fired but only one keyup is.
  14781. // This is also our approach for IE handling, for the reason above.
  14782. case topLevelTypes.topSelectionChange:
  14783. if (skipSelectionChangeEvent) {
  14784. break;
  14785. }
  14786. // falls through
  14787. case topLevelTypes.topKeyDown:
  14788. case topLevelTypes.topKeyUp:
  14789. return constructSelectEvent(nativeEvent, nativeEventTarget);
  14790. }
  14791. return null;
  14792. },
  14793. didPutListener: function (id, registrationName, listener) {
  14794. if (registrationName === ON_SELECT_KEY) {
  14795. hasListener = true;
  14796. }
  14797. }
  14798. };
  14799. module.exports = SelectEventPlugin;
  14800. /***/ },
  14801. /* 131 */
  14802. /***/ function(module, exports) {
  14803. /**
  14804. * Copyright 2013-2015, Facebook, Inc.
  14805. * All rights reserved.
  14806. *
  14807. * This source code is licensed under the BSD-style license found in the
  14808. * LICENSE file in the root directory of this source tree. An additional grant
  14809. * of patent rights can be found in the PATENTS file in the same directory.
  14810. *
  14811. * @providesModule ServerReactRootIndex
  14812. * @typechecks
  14813. */
  14814. 'use strict';
  14815. /**
  14816. * Size of the reactRoot ID space. We generate random numbers for React root
  14817. * IDs and if there's a collision the events and DOM update system will
  14818. * get confused. In the future we need a way to generate GUIDs but for
  14819. * now this will work on a smaller scale.
  14820. */
  14821. var GLOBAL_MOUNT_POINT_MAX = Math.pow(2, 53);
  14822. var ServerReactRootIndex = {
  14823. createReactRootIndex: function () {
  14824. return Math.ceil(Math.random() * GLOBAL_MOUNT_POINT_MAX);
  14825. }
  14826. };
  14827. module.exports = ServerReactRootIndex;
  14828. /***/ },
  14829. /* 132 */
  14830. /***/ function(module, exports, __webpack_require__) {
  14831. /* WEBPACK VAR INJECTION */(function(process) {/**
  14832. * Copyright 2013-2015, Facebook, Inc.
  14833. * All rights reserved.
  14834. *
  14835. * This source code is licensed under the BSD-style license found in the
  14836. * LICENSE file in the root directory of this source tree. An additional grant
  14837. * of patent rights can be found in the PATENTS file in the same directory.
  14838. *
  14839. * @providesModule SimpleEventPlugin
  14840. */
  14841. 'use strict';
  14842. var EventConstants = __webpack_require__(30);
  14843. var EventListener = __webpack_require__(119);
  14844. var EventPropagators = __webpack_require__(73);
  14845. var ReactMount = __webpack_require__(28);
  14846. var SyntheticClipboardEvent = __webpack_require__(133);
  14847. var SyntheticEvent = __webpack_require__(77);
  14848. var SyntheticFocusEvent = __webpack_require__(134);
  14849. var SyntheticKeyboardEvent = __webpack_require__(135);
  14850. var SyntheticMouseEvent = __webpack_require__(86);
  14851. var SyntheticDragEvent = __webpack_require__(138);
  14852. var SyntheticTouchEvent = __webpack_require__(139);
  14853. var SyntheticUIEvent = __webpack_require__(87);
  14854. var SyntheticWheelEvent = __webpack_require__(140);
  14855. var emptyFunction = __webpack_require__(15);
  14856. var getEventCharCode = __webpack_require__(136);
  14857. var invariant = __webpack_require__(13);
  14858. var keyOf = __webpack_require__(79);
  14859. var topLevelTypes = EventConstants.topLevelTypes;
  14860. var eventTypes = {
  14861. abort: {
  14862. phasedRegistrationNames: {
  14863. bubbled: keyOf({ onAbort: true }),
  14864. captured: keyOf({ onAbortCapture: true })
  14865. }
  14866. },
  14867. blur: {
  14868. phasedRegistrationNames: {
  14869. bubbled: keyOf({ onBlur: true }),
  14870. captured: keyOf({ onBlurCapture: true })
  14871. }
  14872. },
  14873. canPlay: {
  14874. phasedRegistrationNames: {
  14875. bubbled: keyOf({ onCanPlay: true }),
  14876. captured: keyOf({ onCanPlayCapture: true })
  14877. }
  14878. },
  14879. canPlayThrough: {
  14880. phasedRegistrationNames: {
  14881. bubbled: keyOf({ onCanPlayThrough: true }),
  14882. captured: keyOf({ onCanPlayThroughCapture: true })
  14883. }
  14884. },
  14885. click: {
  14886. phasedRegistrationNames: {
  14887. bubbled: keyOf({ onClick: true }),
  14888. captured: keyOf({ onClickCapture: true })
  14889. }
  14890. },
  14891. contextMenu: {
  14892. phasedRegistrationNames: {
  14893. bubbled: keyOf({ onContextMenu: true }),
  14894. captured: keyOf({ onContextMenuCapture: true })
  14895. }
  14896. },
  14897. copy: {
  14898. phasedRegistrationNames: {
  14899. bubbled: keyOf({ onCopy: true }),
  14900. captured: keyOf({ onCopyCapture: true })
  14901. }
  14902. },
  14903. cut: {
  14904. phasedRegistrationNames: {
  14905. bubbled: keyOf({ onCut: true }),
  14906. captured: keyOf({ onCutCapture: true })
  14907. }
  14908. },
  14909. doubleClick: {
  14910. phasedRegistrationNames: {
  14911. bubbled: keyOf({ onDoubleClick: true }),
  14912. captured: keyOf({ onDoubleClickCapture: true })
  14913. }
  14914. },
  14915. drag: {
  14916. phasedRegistrationNames: {
  14917. bubbled: keyOf({ onDrag: true }),
  14918. captured: keyOf({ onDragCapture: true })
  14919. }
  14920. },
  14921. dragEnd: {
  14922. phasedRegistrationNames: {
  14923. bubbled: keyOf({ onDragEnd: true }),
  14924. captured: keyOf({ onDragEndCapture: true })
  14925. }
  14926. },
  14927. dragEnter: {
  14928. phasedRegistrationNames: {
  14929. bubbled: keyOf({ onDragEnter: true }),
  14930. captured: keyOf({ onDragEnterCapture: true })
  14931. }
  14932. },
  14933. dragExit: {
  14934. phasedRegistrationNames: {
  14935. bubbled: keyOf({ onDragExit: true }),
  14936. captured: keyOf({ onDragExitCapture: true })
  14937. }
  14938. },
  14939. dragLeave: {
  14940. phasedRegistrationNames: {
  14941. bubbled: keyOf({ onDragLeave: true }),
  14942. captured: keyOf({ onDragLeaveCapture: true })
  14943. }
  14944. },
  14945. dragOver: {
  14946. phasedRegistrationNames: {
  14947. bubbled: keyOf({ onDragOver: true }),
  14948. captured: keyOf({ onDragOverCapture: true })
  14949. }
  14950. },
  14951. dragStart: {
  14952. phasedRegistrationNames: {
  14953. bubbled: keyOf({ onDragStart: true }),
  14954. captured: keyOf({ onDragStartCapture: true })
  14955. }
  14956. },
  14957. drop: {
  14958. phasedRegistrationNames: {
  14959. bubbled: keyOf({ onDrop: true }),
  14960. captured: keyOf({ onDropCapture: true })
  14961. }
  14962. },
  14963. durationChange: {
  14964. phasedRegistrationNames: {
  14965. bubbled: keyOf({ onDurationChange: true }),
  14966. captured: keyOf({ onDurationChangeCapture: true })
  14967. }
  14968. },
  14969. emptied: {
  14970. phasedRegistrationNames: {
  14971. bubbled: keyOf({ onEmptied: true }),
  14972. captured: keyOf({ onEmptiedCapture: true })
  14973. }
  14974. },
  14975. encrypted: {
  14976. phasedRegistrationNames: {
  14977. bubbled: keyOf({ onEncrypted: true }),
  14978. captured: keyOf({ onEncryptedCapture: true })
  14979. }
  14980. },
  14981. ended: {
  14982. phasedRegistrationNames: {
  14983. bubbled: keyOf({ onEnded: true }),
  14984. captured: keyOf({ onEndedCapture: true })
  14985. }
  14986. },
  14987. error: {
  14988. phasedRegistrationNames: {
  14989. bubbled: keyOf({ onError: true }),
  14990. captured: keyOf({ onErrorCapture: true })
  14991. }
  14992. },
  14993. focus: {
  14994. phasedRegistrationNames: {
  14995. bubbled: keyOf({ onFocus: true }),
  14996. captured: keyOf({ onFocusCapture: true })
  14997. }
  14998. },
  14999. input: {
  15000. phasedRegistrationNames: {
  15001. bubbled: keyOf({ onInput: true }),
  15002. captured: keyOf({ onInputCapture: true })
  15003. }
  15004. },
  15005. keyDown: {
  15006. phasedRegistrationNames: {
  15007. bubbled: keyOf({ onKeyDown: true }),
  15008. captured: keyOf({ onKeyDownCapture: true })
  15009. }
  15010. },
  15011. keyPress: {
  15012. phasedRegistrationNames: {
  15013. bubbled: keyOf({ onKeyPress: true }),
  15014. captured: keyOf({ onKeyPressCapture: true })
  15015. }
  15016. },
  15017. keyUp: {
  15018. phasedRegistrationNames: {
  15019. bubbled: keyOf({ onKeyUp: true }),
  15020. captured: keyOf({ onKeyUpCapture: true })
  15021. }
  15022. },
  15023. load: {
  15024. phasedRegistrationNames: {
  15025. bubbled: keyOf({ onLoad: true }),
  15026. captured: keyOf({ onLoadCapture: true })
  15027. }
  15028. },
  15029. loadedData: {
  15030. phasedRegistrationNames: {
  15031. bubbled: keyOf({ onLoadedData: true }),
  15032. captured: keyOf({ onLoadedDataCapture: true })
  15033. }
  15034. },
  15035. loadedMetadata: {
  15036. phasedRegistrationNames: {
  15037. bubbled: keyOf({ onLoadedMetadata: true }),
  15038. captured: keyOf({ onLoadedMetadataCapture: true })
  15039. }
  15040. },
  15041. loadStart: {
  15042. phasedRegistrationNames: {
  15043. bubbled: keyOf({ onLoadStart: true }),
  15044. captured: keyOf({ onLoadStartCapture: true })
  15045. }
  15046. },
  15047. // Note: We do not allow listening to mouseOver events. Instead, use the
  15048. // onMouseEnter/onMouseLeave created by `EnterLeaveEventPlugin`.
  15049. mouseDown: {
  15050. phasedRegistrationNames: {
  15051. bubbled: keyOf({ onMouseDown: true }),
  15052. captured: keyOf({ onMouseDownCapture: true })
  15053. }
  15054. },
  15055. mouseMove: {
  15056. phasedRegistrationNames: {
  15057. bubbled: keyOf({ onMouseMove: true }),
  15058. captured: keyOf({ onMouseMoveCapture: true })
  15059. }
  15060. },
  15061. mouseOut: {
  15062. phasedRegistrationNames: {
  15063. bubbled: keyOf({ onMouseOut: true }),
  15064. captured: keyOf({ onMouseOutCapture: true })
  15065. }
  15066. },
  15067. mouseOver: {
  15068. phasedRegistrationNames: {
  15069. bubbled: keyOf({ onMouseOver: true }),
  15070. captured: keyOf({ onMouseOverCapture: true })
  15071. }
  15072. },
  15073. mouseUp: {
  15074. phasedRegistrationNames: {
  15075. bubbled: keyOf({ onMouseUp: true }),
  15076. captured: keyOf({ onMouseUpCapture: true })
  15077. }
  15078. },
  15079. paste: {
  15080. phasedRegistrationNames: {
  15081. bubbled: keyOf({ onPaste: true }),
  15082. captured: keyOf({ onPasteCapture: true })
  15083. }
  15084. },
  15085. pause: {
  15086. phasedRegistrationNames: {
  15087. bubbled: keyOf({ onPause: true }),
  15088. captured: keyOf({ onPauseCapture: true })
  15089. }
  15090. },
  15091. play: {
  15092. phasedRegistrationNames: {
  15093. bubbled: keyOf({ onPlay: true }),
  15094. captured: keyOf({ onPlayCapture: true })
  15095. }
  15096. },
  15097. playing: {
  15098. phasedRegistrationNames: {
  15099. bubbled: keyOf({ onPlaying: true }),
  15100. captured: keyOf({ onPlayingCapture: true })
  15101. }
  15102. },
  15103. progress: {
  15104. phasedRegistrationNames: {
  15105. bubbled: keyOf({ onProgress: true }),
  15106. captured: keyOf({ onProgressCapture: true })
  15107. }
  15108. },
  15109. rateChange: {
  15110. phasedRegistrationNames: {
  15111. bubbled: keyOf({ onRateChange: true }),
  15112. captured: keyOf({ onRateChangeCapture: true })
  15113. }
  15114. },
  15115. reset: {
  15116. phasedRegistrationNames: {
  15117. bubbled: keyOf({ onReset: true }),
  15118. captured: keyOf({ onResetCapture: true })
  15119. }
  15120. },
  15121. scroll: {
  15122. phasedRegistrationNames: {
  15123. bubbled: keyOf({ onScroll: true }),
  15124. captured: keyOf({ onScrollCapture: true })
  15125. }
  15126. },
  15127. seeked: {
  15128. phasedRegistrationNames: {
  15129. bubbled: keyOf({ onSeeked: true }),
  15130. captured: keyOf({ onSeekedCapture: true })
  15131. }
  15132. },
  15133. seeking: {
  15134. phasedRegistrationNames: {
  15135. bubbled: keyOf({ onSeeking: true }),
  15136. captured: keyOf({ onSeekingCapture: true })
  15137. }
  15138. },
  15139. stalled: {
  15140. phasedRegistrationNames: {
  15141. bubbled: keyOf({ onStalled: true }),
  15142. captured: keyOf({ onStalledCapture: true })
  15143. }
  15144. },
  15145. submit: {
  15146. phasedRegistrationNames: {
  15147. bubbled: keyOf({ onSubmit: true }),
  15148. captured: keyOf({ onSubmitCapture: true })
  15149. }
  15150. },
  15151. suspend: {
  15152. phasedRegistrationNames: {
  15153. bubbled: keyOf({ onSuspend: true }),
  15154. captured: keyOf({ onSuspendCapture: true })
  15155. }
  15156. },
  15157. timeUpdate: {
  15158. phasedRegistrationNames: {
  15159. bubbled: keyOf({ onTimeUpdate: true }),
  15160. captured: keyOf({ onTimeUpdateCapture: true })
  15161. }
  15162. },
  15163. touchCancel: {
  15164. phasedRegistrationNames: {
  15165. bubbled: keyOf({ onTouchCancel: true }),
  15166. captured: keyOf({ onTouchCancelCapture: true })
  15167. }
  15168. },
  15169. touchEnd: {
  15170. phasedRegistrationNames: {
  15171. bubbled: keyOf({ onTouchEnd: true }),
  15172. captured: keyOf({ onTouchEndCapture: true })
  15173. }
  15174. },
  15175. touchMove: {
  15176. phasedRegistrationNames: {
  15177. bubbled: keyOf({ onTouchMove: true }),
  15178. captured: keyOf({ onTouchMoveCapture: true })
  15179. }
  15180. },
  15181. touchStart: {
  15182. phasedRegistrationNames: {
  15183. bubbled: keyOf({ onTouchStart: true }),
  15184. captured: keyOf({ onTouchStartCapture: true })
  15185. }
  15186. },
  15187. volumeChange: {
  15188. phasedRegistrationNames: {
  15189. bubbled: keyOf({ onVolumeChange: true }),
  15190. captured: keyOf({ onVolumeChangeCapture: true })
  15191. }
  15192. },
  15193. waiting: {
  15194. phasedRegistrationNames: {
  15195. bubbled: keyOf({ onWaiting: true }),
  15196. captured: keyOf({ onWaitingCapture: true })
  15197. }
  15198. },
  15199. wheel: {
  15200. phasedRegistrationNames: {
  15201. bubbled: keyOf({ onWheel: true }),
  15202. captured: keyOf({ onWheelCapture: true })
  15203. }
  15204. }
  15205. };
  15206. var topLevelEventsToDispatchConfig = {
  15207. topAbort: eventTypes.abort,
  15208. topBlur: eventTypes.blur,
  15209. topCanPlay: eventTypes.canPlay,
  15210. topCanPlayThrough: eventTypes.canPlayThrough,
  15211. topClick: eventTypes.click,
  15212. topContextMenu: eventTypes.contextMenu,
  15213. topCopy: eventTypes.copy,
  15214. topCut: eventTypes.cut,
  15215. topDoubleClick: eventTypes.doubleClick,
  15216. topDrag: eventTypes.drag,
  15217. topDragEnd: eventTypes.dragEnd,
  15218. topDragEnter: eventTypes.dragEnter,
  15219. topDragExit: eventTypes.dragExit,
  15220. topDragLeave: eventTypes.dragLeave,
  15221. topDragOver: eventTypes.dragOver,
  15222. topDragStart: eventTypes.dragStart,
  15223. topDrop: eventTypes.drop,
  15224. topDurationChange: eventTypes.durationChange,
  15225. topEmptied: eventTypes.emptied,
  15226. topEncrypted: eventTypes.encrypted,
  15227. topEnded: eventTypes.ended,
  15228. topError: eventTypes.error,
  15229. topFocus: eventTypes.focus,
  15230. topInput: eventTypes.input,
  15231. topKeyDown: eventTypes.keyDown,
  15232. topKeyPress: eventTypes.keyPress,
  15233. topKeyUp: eventTypes.keyUp,
  15234. topLoad: eventTypes.load,
  15235. topLoadedData: eventTypes.loadedData,
  15236. topLoadedMetadata: eventTypes.loadedMetadata,
  15237. topLoadStart: eventTypes.loadStart,
  15238. topMouseDown: eventTypes.mouseDown,
  15239. topMouseMove: eventTypes.mouseMove,
  15240. topMouseOut: eventTypes.mouseOut,
  15241. topMouseOver: eventTypes.mouseOver,
  15242. topMouseUp: eventTypes.mouseUp,
  15243. topPaste: eventTypes.paste,
  15244. topPause: eventTypes.pause,
  15245. topPlay: eventTypes.play,
  15246. topPlaying: eventTypes.playing,
  15247. topProgress: eventTypes.progress,
  15248. topRateChange: eventTypes.rateChange,
  15249. topReset: eventTypes.reset,
  15250. topScroll: eventTypes.scroll,
  15251. topSeeked: eventTypes.seeked,
  15252. topSeeking: eventTypes.seeking,
  15253. topStalled: eventTypes.stalled,
  15254. topSubmit: eventTypes.submit,
  15255. topSuspend: eventTypes.suspend,
  15256. topTimeUpdate: eventTypes.timeUpdate,
  15257. topTouchCancel: eventTypes.touchCancel,
  15258. topTouchEnd: eventTypes.touchEnd,
  15259. topTouchMove: eventTypes.touchMove,
  15260. topTouchStart: eventTypes.touchStart,
  15261. topVolumeChange: eventTypes.volumeChange,
  15262. topWaiting: eventTypes.waiting,
  15263. topWheel: eventTypes.wheel
  15264. };
  15265. for (var type in topLevelEventsToDispatchConfig) {
  15266. topLevelEventsToDispatchConfig[type].dependencies = [type];
  15267. }
  15268. var ON_CLICK_KEY = keyOf({ onClick: null });
  15269. var onClickListeners = {};
  15270. var SimpleEventPlugin = {
  15271. eventTypes: eventTypes,
  15272. /**
  15273. * @param {string} topLevelType Record from `EventConstants`.
  15274. * @param {DOMEventTarget} topLevelTarget The listening component root node.
  15275. * @param {string} topLevelTargetID ID of `topLevelTarget`.
  15276. * @param {object} nativeEvent Native browser event.
  15277. * @return {*} An accumulation of synthetic events.
  15278. * @see {EventPluginHub.extractEvents}
  15279. */
  15280. extractEvents: function (topLevelType, topLevelTarget, topLevelTargetID, nativeEvent, nativeEventTarget) {
  15281. var dispatchConfig = topLevelEventsToDispatchConfig[topLevelType];
  15282. if (!dispatchConfig) {
  15283. return null;
  15284. }
  15285. var EventConstructor;
  15286. switch (topLevelType) {
  15287. case topLevelTypes.topAbort:
  15288. case topLevelTypes.topCanPlay:
  15289. case topLevelTypes.topCanPlayThrough:
  15290. case topLevelTypes.topDurationChange:
  15291. case topLevelTypes.topEmptied:
  15292. case topLevelTypes.topEncrypted:
  15293. case topLevelTypes.topEnded:
  15294. case topLevelTypes.topError:
  15295. case topLevelTypes.topInput:
  15296. case topLevelTypes.topLoad:
  15297. case topLevelTypes.topLoadedData:
  15298. case topLevelTypes.topLoadedMetadata:
  15299. case topLevelTypes.topLoadStart:
  15300. case topLevelTypes.topPause:
  15301. case topLevelTypes.topPlay:
  15302. case topLevelTypes.topPlaying:
  15303. case topLevelTypes.topProgress:
  15304. case topLevelTypes.topRateChange:
  15305. case topLevelTypes.topReset:
  15306. case topLevelTypes.topSeeked:
  15307. case topLevelTypes.topSeeking:
  15308. case topLevelTypes.topStalled:
  15309. case topLevelTypes.topSubmit:
  15310. case topLevelTypes.topSuspend:
  15311. case topLevelTypes.topTimeUpdate:
  15312. case topLevelTypes.topVolumeChange:
  15313. case topLevelTypes.topWaiting:
  15314. // HTML Events
  15315. // @see http://www.w3.org/TR/html5/index.html#events-0
  15316. EventConstructor = SyntheticEvent;
  15317. break;
  15318. case topLevelTypes.topKeyPress:
  15319. // FireFox creates a keypress event for function keys too. This removes
  15320. // the unwanted keypress events. Enter is however both printable and
  15321. // non-printable. One would expect Tab to be as well (but it isn't).
  15322. if (getEventCharCode(nativeEvent) === 0) {
  15323. return null;
  15324. }
  15325. /* falls through */
  15326. case topLevelTypes.topKeyDown:
  15327. case topLevelTypes.topKeyUp:
  15328. EventConstructor = SyntheticKeyboardEvent;
  15329. break;
  15330. case topLevelTypes.topBlur:
  15331. case topLevelTypes.topFocus:
  15332. EventConstructor = SyntheticFocusEvent;
  15333. break;
  15334. case topLevelTypes.topClick:
  15335. // Firefox creates a click event on right mouse clicks. This removes the
  15336. // unwanted click events.
  15337. if (nativeEvent.button === 2) {
  15338. return null;
  15339. }
  15340. /* falls through */
  15341. case topLevelTypes.topContextMenu:
  15342. case topLevelTypes.topDoubleClick:
  15343. case topLevelTypes.topMouseDown:
  15344. case topLevelTypes.topMouseMove:
  15345. case topLevelTypes.topMouseOut:
  15346. case topLevelTypes.topMouseOver:
  15347. case topLevelTypes.topMouseUp:
  15348. EventConstructor = SyntheticMouseEvent;
  15349. break;
  15350. case topLevelTypes.topDrag:
  15351. case topLevelTypes.topDragEnd:
  15352. case topLevelTypes.topDragEnter:
  15353. case topLevelTypes.topDragExit:
  15354. case topLevelTypes.topDragLeave:
  15355. case topLevelTypes.topDragOver:
  15356. case topLevelTypes.topDragStart:
  15357. case topLevelTypes.topDrop:
  15358. EventConstructor = SyntheticDragEvent;
  15359. break;
  15360. case topLevelTypes.topTouchCancel:
  15361. case topLevelTypes.topTouchEnd:
  15362. case topLevelTypes.topTouchMove:
  15363. case topLevelTypes.topTouchStart:
  15364. EventConstructor = SyntheticTouchEvent;
  15365. break;
  15366. case topLevelTypes.topScroll:
  15367. EventConstructor = SyntheticUIEvent;
  15368. break;
  15369. case topLevelTypes.topWheel:
  15370. EventConstructor = SyntheticWheelEvent;
  15371. break;
  15372. case topLevelTypes.topCopy:
  15373. case topLevelTypes.topCut:
  15374. case topLevelTypes.topPaste:
  15375. EventConstructor = SyntheticClipboardEvent;
  15376. break;
  15377. }
  15378. !EventConstructor ? process.env.NODE_ENV !== 'production' ? invariant(false, 'SimpleEventPlugin: Unhandled event type, `%s`.', topLevelType) : invariant(false) : undefined;
  15379. var event = EventConstructor.getPooled(dispatchConfig, topLevelTargetID, nativeEvent, nativeEventTarget);
  15380. EventPropagators.accumulateTwoPhaseDispatches(event);
  15381. return event;
  15382. },
  15383. didPutListener: function (id, registrationName, listener) {
  15384. // Mobile Safari does not fire properly bubble click events on
  15385. // non-interactive elements, which means delegated click listeners do not
  15386. // fire. The workaround for this bug involves attaching an empty click
  15387. // listener on the target node.
  15388. if (registrationName === ON_CLICK_KEY) {
  15389. var node = ReactMount.getNode(id);
  15390. if (!onClickListeners[id]) {
  15391. onClickListeners[id] = EventListener.listen(node, 'click', emptyFunction);
  15392. }
  15393. }
  15394. },
  15395. willDeleteListener: function (id, registrationName) {
  15396. if (registrationName === ON_CLICK_KEY) {
  15397. onClickListeners[id].remove();
  15398. delete onClickListeners[id];
  15399. }
  15400. }
  15401. };
  15402. module.exports = SimpleEventPlugin;
  15403. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  15404. /***/ },
  15405. /* 133 */
  15406. /***/ function(module, exports, __webpack_require__) {
  15407. /**
  15408. * Copyright 2013-2015, Facebook, Inc.
  15409. * All rights reserved.
  15410. *
  15411. * This source code is licensed under the BSD-style license found in the
  15412. * LICENSE file in the root directory of this source tree. An additional grant
  15413. * of patent rights can be found in the PATENTS file in the same directory.
  15414. *
  15415. * @providesModule SyntheticClipboardEvent
  15416. * @typechecks static-only
  15417. */
  15418. 'use strict';
  15419. var SyntheticEvent = __webpack_require__(77);
  15420. /**
  15421. * @interface Event
  15422. * @see http://www.w3.org/TR/clipboard-apis/
  15423. */
  15424. var ClipboardEventInterface = {
  15425. clipboardData: function (event) {
  15426. return 'clipboardData' in event ? event.clipboardData : window.clipboardData;
  15427. }
  15428. };
  15429. /**
  15430. * @param {object} dispatchConfig Configuration used to dispatch this event.
  15431. * @param {string} dispatchMarker Marker identifying the event target.
  15432. * @param {object} nativeEvent Native browser event.
  15433. * @extends {SyntheticUIEvent}
  15434. */
  15435. function SyntheticClipboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  15436. SyntheticEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
  15437. }
  15438. SyntheticEvent.augmentClass(SyntheticClipboardEvent, ClipboardEventInterface);
  15439. module.exports = SyntheticClipboardEvent;
  15440. /***/ },
  15441. /* 134 */
  15442. /***/ function(module, exports, __webpack_require__) {
  15443. /**
  15444. * Copyright 2013-2015, Facebook, Inc.
  15445. * All rights reserved.
  15446. *
  15447. * This source code is licensed under the BSD-style license found in the
  15448. * LICENSE file in the root directory of this source tree. An additional grant
  15449. * of patent rights can be found in the PATENTS file in the same directory.
  15450. *
  15451. * @providesModule SyntheticFocusEvent
  15452. * @typechecks static-only
  15453. */
  15454. 'use strict';
  15455. var SyntheticUIEvent = __webpack_require__(87);
  15456. /**
  15457. * @interface FocusEvent
  15458. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  15459. */
  15460. var FocusEventInterface = {
  15461. relatedTarget: null
  15462. };
  15463. /**
  15464. * @param {object} dispatchConfig Configuration used to dispatch this event.
  15465. * @param {string} dispatchMarker Marker identifying the event target.
  15466. * @param {object} nativeEvent Native browser event.
  15467. * @extends {SyntheticUIEvent}
  15468. */
  15469. function SyntheticFocusEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  15470. SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
  15471. }
  15472. SyntheticUIEvent.augmentClass(SyntheticFocusEvent, FocusEventInterface);
  15473. module.exports = SyntheticFocusEvent;
  15474. /***/ },
  15475. /* 135 */
  15476. /***/ function(module, exports, __webpack_require__) {
  15477. /**
  15478. * Copyright 2013-2015, Facebook, Inc.
  15479. * All rights reserved.
  15480. *
  15481. * This source code is licensed under the BSD-style license found in the
  15482. * LICENSE file in the root directory of this source tree. An additional grant
  15483. * of patent rights can be found in the PATENTS file in the same directory.
  15484. *
  15485. * @providesModule SyntheticKeyboardEvent
  15486. * @typechecks static-only
  15487. */
  15488. 'use strict';
  15489. var SyntheticUIEvent = __webpack_require__(87);
  15490. var getEventCharCode = __webpack_require__(136);
  15491. var getEventKey = __webpack_require__(137);
  15492. var getEventModifierState = __webpack_require__(88);
  15493. /**
  15494. * @interface KeyboardEvent
  15495. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  15496. */
  15497. var KeyboardEventInterface = {
  15498. key: getEventKey,
  15499. location: null,
  15500. ctrlKey: null,
  15501. shiftKey: null,
  15502. altKey: null,
  15503. metaKey: null,
  15504. repeat: null,
  15505. locale: null,
  15506. getModifierState: getEventModifierState,
  15507. // Legacy Interface
  15508. charCode: function (event) {
  15509. // `charCode` is the result of a KeyPress event and represents the value of
  15510. // the actual printable character.
  15511. // KeyPress is deprecated, but its replacement is not yet final and not
  15512. // implemented in any major browser. Only KeyPress has charCode.
  15513. if (event.type === 'keypress') {
  15514. return getEventCharCode(event);
  15515. }
  15516. return 0;
  15517. },
  15518. keyCode: function (event) {
  15519. // `keyCode` is the result of a KeyDown/Up event and represents the value of
  15520. // physical keyboard key.
  15521. // The actual meaning of the value depends on the users' keyboard layout
  15522. // which cannot be detected. Assuming that it is a US keyboard layout
  15523. // provides a surprisingly accurate mapping for US and European users.
  15524. // Due to this, it is left to the user to implement at this time.
  15525. if (event.type === 'keydown' || event.type === 'keyup') {
  15526. return event.keyCode;
  15527. }
  15528. return 0;
  15529. },
  15530. which: function (event) {
  15531. // `which` is an alias for either `keyCode` or `charCode` depending on the
  15532. // type of the event.
  15533. if (event.type === 'keypress') {
  15534. return getEventCharCode(event);
  15535. }
  15536. if (event.type === 'keydown' || event.type === 'keyup') {
  15537. return event.keyCode;
  15538. }
  15539. return 0;
  15540. }
  15541. };
  15542. /**
  15543. * @param {object} dispatchConfig Configuration used to dispatch this event.
  15544. * @param {string} dispatchMarker Marker identifying the event target.
  15545. * @param {object} nativeEvent Native browser event.
  15546. * @extends {SyntheticUIEvent}
  15547. */
  15548. function SyntheticKeyboardEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  15549. SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
  15550. }
  15551. SyntheticUIEvent.augmentClass(SyntheticKeyboardEvent, KeyboardEventInterface);
  15552. module.exports = SyntheticKeyboardEvent;
  15553. /***/ },
  15554. /* 136 */
  15555. /***/ function(module, exports) {
  15556. /**
  15557. * Copyright 2013-2015, Facebook, Inc.
  15558. * All rights reserved.
  15559. *
  15560. * This source code is licensed under the BSD-style license found in the
  15561. * LICENSE file in the root directory of this source tree. An additional grant
  15562. * of patent rights can be found in the PATENTS file in the same directory.
  15563. *
  15564. * @providesModule getEventCharCode
  15565. * @typechecks static-only
  15566. */
  15567. 'use strict';
  15568. /**
  15569. * `charCode` represents the actual "character code" and is safe to use with
  15570. * `String.fromCharCode`. As such, only keys that correspond to printable
  15571. * characters produce a valid `charCode`, the only exception to this is Enter.
  15572. * The Tab-key is considered non-printable and does not have a `charCode`,
  15573. * presumably because it does not produce a tab-character in browsers.
  15574. *
  15575. * @param {object} nativeEvent Native browser event.
  15576. * @return {number} Normalized `charCode` property.
  15577. */
  15578. function getEventCharCode(nativeEvent) {
  15579. var charCode;
  15580. var keyCode = nativeEvent.keyCode;
  15581. if ('charCode' in nativeEvent) {
  15582. charCode = nativeEvent.charCode;
  15583. // FF does not set `charCode` for the Enter-key, check against `keyCode`.
  15584. if (charCode === 0 && keyCode === 13) {
  15585. charCode = 13;
  15586. }
  15587. } else {
  15588. // IE8 does not implement `charCode`, but `keyCode` has the correct value.
  15589. charCode = keyCode;
  15590. }
  15591. // Some non-printable keys are reported in `charCode`/`keyCode`, discard them.
  15592. // Must not discard the (non-)printable Enter-key.
  15593. if (charCode >= 32 || charCode === 13) {
  15594. return charCode;
  15595. }
  15596. return 0;
  15597. }
  15598. module.exports = getEventCharCode;
  15599. /***/ },
  15600. /* 137 */
  15601. /***/ function(module, exports, __webpack_require__) {
  15602. /**
  15603. * Copyright 2013-2015, Facebook, Inc.
  15604. * All rights reserved.
  15605. *
  15606. * This source code is licensed under the BSD-style license found in the
  15607. * LICENSE file in the root directory of this source tree. An additional grant
  15608. * of patent rights can be found in the PATENTS file in the same directory.
  15609. *
  15610. * @providesModule getEventKey
  15611. * @typechecks static-only
  15612. */
  15613. 'use strict';
  15614. var getEventCharCode = __webpack_require__(136);
  15615. /**
  15616. * Normalization of deprecated HTML5 `key` values
  15617. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  15618. */
  15619. var normalizeKey = {
  15620. 'Esc': 'Escape',
  15621. 'Spacebar': ' ',
  15622. 'Left': 'ArrowLeft',
  15623. 'Up': 'ArrowUp',
  15624. 'Right': 'ArrowRight',
  15625. 'Down': 'ArrowDown',
  15626. 'Del': 'Delete',
  15627. 'Win': 'OS',
  15628. 'Menu': 'ContextMenu',
  15629. 'Apps': 'ContextMenu',
  15630. 'Scroll': 'ScrollLock',
  15631. 'MozPrintableKey': 'Unidentified'
  15632. };
  15633. /**
  15634. * Translation from legacy `keyCode` to HTML5 `key`
  15635. * Only special keys supported, all others depend on keyboard layout or browser
  15636. * @see https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent#Key_names
  15637. */
  15638. var translateToKey = {
  15639. 8: 'Backspace',
  15640. 9: 'Tab',
  15641. 12: 'Clear',
  15642. 13: 'Enter',
  15643. 16: 'Shift',
  15644. 17: 'Control',
  15645. 18: 'Alt',
  15646. 19: 'Pause',
  15647. 20: 'CapsLock',
  15648. 27: 'Escape',
  15649. 32: ' ',
  15650. 33: 'PageUp',
  15651. 34: 'PageDown',
  15652. 35: 'End',
  15653. 36: 'Home',
  15654. 37: 'ArrowLeft',
  15655. 38: 'ArrowUp',
  15656. 39: 'ArrowRight',
  15657. 40: 'ArrowDown',
  15658. 45: 'Insert',
  15659. 46: 'Delete',
  15660. 112: 'F1', 113: 'F2', 114: 'F3', 115: 'F4', 116: 'F5', 117: 'F6',
  15661. 118: 'F7', 119: 'F8', 120: 'F9', 121: 'F10', 122: 'F11', 123: 'F12',
  15662. 144: 'NumLock',
  15663. 145: 'ScrollLock',
  15664. 224: 'Meta'
  15665. };
  15666. /**
  15667. * @param {object} nativeEvent Native browser event.
  15668. * @return {string} Normalized `key` property.
  15669. */
  15670. function getEventKey(nativeEvent) {
  15671. if (nativeEvent.key) {
  15672. // Normalize inconsistent values reported by browsers due to
  15673. // implementations of a working draft specification.
  15674. // FireFox implements `key` but returns `MozPrintableKey` for all
  15675. // printable characters (normalized to `Unidentified`), ignore it.
  15676. var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
  15677. if (key !== 'Unidentified') {
  15678. return key;
  15679. }
  15680. }
  15681. // Browser does not implement `key`, polyfill as much of it as we can.
  15682. if (nativeEvent.type === 'keypress') {
  15683. var charCode = getEventCharCode(nativeEvent);
  15684. // The enter-key is technically both printable and non-printable and can
  15685. // thus be captured by `keypress`, no other non-printable key should.
  15686. return charCode === 13 ? 'Enter' : String.fromCharCode(charCode);
  15687. }
  15688. if (nativeEvent.type === 'keydown' || nativeEvent.type === 'keyup') {
  15689. // While user keyboard layout determines the actual meaning of each
  15690. // `keyCode` value, almost all function keys have a universal value.
  15691. return translateToKey[nativeEvent.keyCode] || 'Unidentified';
  15692. }
  15693. return '';
  15694. }
  15695. module.exports = getEventKey;
  15696. /***/ },
  15697. /* 138 */
  15698. /***/ function(module, exports, __webpack_require__) {
  15699. /**
  15700. * Copyright 2013-2015, Facebook, Inc.
  15701. * All rights reserved.
  15702. *
  15703. * This source code is licensed under the BSD-style license found in the
  15704. * LICENSE file in the root directory of this source tree. An additional grant
  15705. * of patent rights can be found in the PATENTS file in the same directory.
  15706. *
  15707. * @providesModule SyntheticDragEvent
  15708. * @typechecks static-only
  15709. */
  15710. 'use strict';
  15711. var SyntheticMouseEvent = __webpack_require__(86);
  15712. /**
  15713. * @interface DragEvent
  15714. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  15715. */
  15716. var DragEventInterface = {
  15717. dataTransfer: null
  15718. };
  15719. /**
  15720. * @param {object} dispatchConfig Configuration used to dispatch this event.
  15721. * @param {string} dispatchMarker Marker identifying the event target.
  15722. * @param {object} nativeEvent Native browser event.
  15723. * @extends {SyntheticUIEvent}
  15724. */
  15725. function SyntheticDragEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  15726. SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
  15727. }
  15728. SyntheticMouseEvent.augmentClass(SyntheticDragEvent, DragEventInterface);
  15729. module.exports = SyntheticDragEvent;
  15730. /***/ },
  15731. /* 139 */
  15732. /***/ function(module, exports, __webpack_require__) {
  15733. /**
  15734. * Copyright 2013-2015, Facebook, Inc.
  15735. * All rights reserved.
  15736. *
  15737. * This source code is licensed under the BSD-style license found in the
  15738. * LICENSE file in the root directory of this source tree. An additional grant
  15739. * of patent rights can be found in the PATENTS file in the same directory.
  15740. *
  15741. * @providesModule SyntheticTouchEvent
  15742. * @typechecks static-only
  15743. */
  15744. 'use strict';
  15745. var SyntheticUIEvent = __webpack_require__(87);
  15746. var getEventModifierState = __webpack_require__(88);
  15747. /**
  15748. * @interface TouchEvent
  15749. * @see http://www.w3.org/TR/touch-events/
  15750. */
  15751. var TouchEventInterface = {
  15752. touches: null,
  15753. targetTouches: null,
  15754. changedTouches: null,
  15755. altKey: null,
  15756. metaKey: null,
  15757. ctrlKey: null,
  15758. shiftKey: null,
  15759. getModifierState: getEventModifierState
  15760. };
  15761. /**
  15762. * @param {object} dispatchConfig Configuration used to dispatch this event.
  15763. * @param {string} dispatchMarker Marker identifying the event target.
  15764. * @param {object} nativeEvent Native browser event.
  15765. * @extends {SyntheticUIEvent}
  15766. */
  15767. function SyntheticTouchEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  15768. SyntheticUIEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
  15769. }
  15770. SyntheticUIEvent.augmentClass(SyntheticTouchEvent, TouchEventInterface);
  15771. module.exports = SyntheticTouchEvent;
  15772. /***/ },
  15773. /* 140 */
  15774. /***/ function(module, exports, __webpack_require__) {
  15775. /**
  15776. * Copyright 2013-2015, Facebook, Inc.
  15777. * All rights reserved.
  15778. *
  15779. * This source code is licensed under the BSD-style license found in the
  15780. * LICENSE file in the root directory of this source tree. An additional grant
  15781. * of patent rights can be found in the PATENTS file in the same directory.
  15782. *
  15783. * @providesModule SyntheticWheelEvent
  15784. * @typechecks static-only
  15785. */
  15786. 'use strict';
  15787. var SyntheticMouseEvent = __webpack_require__(86);
  15788. /**
  15789. * @interface WheelEvent
  15790. * @see http://www.w3.org/TR/DOM-Level-3-Events/
  15791. */
  15792. var WheelEventInterface = {
  15793. deltaX: function (event) {
  15794. return 'deltaX' in event ? event.deltaX :
  15795. // Fallback to `wheelDeltaX` for Webkit and normalize (right is positive).
  15796. 'wheelDeltaX' in event ? -event.wheelDeltaX : 0;
  15797. },
  15798. deltaY: function (event) {
  15799. return 'deltaY' in event ? event.deltaY :
  15800. // Fallback to `wheelDeltaY` for Webkit and normalize (down is positive).
  15801. 'wheelDeltaY' in event ? -event.wheelDeltaY :
  15802. // Fallback to `wheelDelta` for IE<9 and normalize (down is positive).
  15803. 'wheelDelta' in event ? -event.wheelDelta : 0;
  15804. },
  15805. deltaZ: null,
  15806. // Browsers without "deltaMode" is reporting in raw wheel delta where one
  15807. // notch on the scroll is always +/- 120, roughly equivalent to pixels.
  15808. // A good approximation of DOM_DELTA_LINE (1) is 5% of viewport size or
  15809. // ~40 pixels, for DOM_DELTA_SCREEN (2) it is 87.5% of viewport size.
  15810. deltaMode: null
  15811. };
  15812. /**
  15813. * @param {object} dispatchConfig Configuration used to dispatch this event.
  15814. * @param {string} dispatchMarker Marker identifying the event target.
  15815. * @param {object} nativeEvent Native browser event.
  15816. * @extends {SyntheticMouseEvent}
  15817. */
  15818. function SyntheticWheelEvent(dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget) {
  15819. SyntheticMouseEvent.call(this, dispatchConfig, dispatchMarker, nativeEvent, nativeEventTarget);
  15820. }
  15821. SyntheticMouseEvent.augmentClass(SyntheticWheelEvent, WheelEventInterface);
  15822. module.exports = SyntheticWheelEvent;
  15823. /***/ },
  15824. /* 141 */
  15825. /***/ function(module, exports, __webpack_require__) {
  15826. /**
  15827. * Copyright 2013-2015, Facebook, Inc.
  15828. * All rights reserved.
  15829. *
  15830. * This source code is licensed under the BSD-style license found in the
  15831. * LICENSE file in the root directory of this source tree. An additional grant
  15832. * of patent rights can be found in the PATENTS file in the same directory.
  15833. *
  15834. * @providesModule SVGDOMPropertyConfig
  15835. */
  15836. 'use strict';
  15837. var DOMProperty = __webpack_require__(23);
  15838. var MUST_USE_ATTRIBUTE = DOMProperty.injection.MUST_USE_ATTRIBUTE;
  15839. var NS = {
  15840. xlink: 'http://www.w3.org/1999/xlink',
  15841. xml: 'http://www.w3.org/XML/1998/namespace'
  15842. };
  15843. var SVGDOMPropertyConfig = {
  15844. Properties: {
  15845. clipPath: MUST_USE_ATTRIBUTE,
  15846. cx: MUST_USE_ATTRIBUTE,
  15847. cy: MUST_USE_ATTRIBUTE,
  15848. d: MUST_USE_ATTRIBUTE,
  15849. dx: MUST_USE_ATTRIBUTE,
  15850. dy: MUST_USE_ATTRIBUTE,
  15851. fill: MUST_USE_ATTRIBUTE,
  15852. fillOpacity: MUST_USE_ATTRIBUTE,
  15853. fontFamily: MUST_USE_ATTRIBUTE,
  15854. fontSize: MUST_USE_ATTRIBUTE,
  15855. fx: MUST_USE_ATTRIBUTE,
  15856. fy: MUST_USE_ATTRIBUTE,
  15857. gradientTransform: MUST_USE_ATTRIBUTE,
  15858. gradientUnits: MUST_USE_ATTRIBUTE,
  15859. markerEnd: MUST_USE_ATTRIBUTE,
  15860. markerMid: MUST_USE_ATTRIBUTE,
  15861. markerStart: MUST_USE_ATTRIBUTE,
  15862. offset: MUST_USE_ATTRIBUTE,
  15863. opacity: MUST_USE_ATTRIBUTE,
  15864. patternContentUnits: MUST_USE_ATTRIBUTE,
  15865. patternUnits: MUST_USE_ATTRIBUTE,
  15866. points: MUST_USE_ATTRIBUTE,
  15867. preserveAspectRatio: MUST_USE_ATTRIBUTE,
  15868. r: MUST_USE_ATTRIBUTE,
  15869. rx: MUST_USE_ATTRIBUTE,
  15870. ry: MUST_USE_ATTRIBUTE,
  15871. spreadMethod: MUST_USE_ATTRIBUTE,
  15872. stopColor: MUST_USE_ATTRIBUTE,
  15873. stopOpacity: MUST_USE_ATTRIBUTE,
  15874. stroke: MUST_USE_ATTRIBUTE,
  15875. strokeDasharray: MUST_USE_ATTRIBUTE,
  15876. strokeLinecap: MUST_USE_ATTRIBUTE,
  15877. strokeOpacity: MUST_USE_ATTRIBUTE,
  15878. strokeWidth: MUST_USE_ATTRIBUTE,
  15879. textAnchor: MUST_USE_ATTRIBUTE,
  15880. transform: MUST_USE_ATTRIBUTE,
  15881. version: MUST_USE_ATTRIBUTE,
  15882. viewBox: MUST_USE_ATTRIBUTE,
  15883. x1: MUST_USE_ATTRIBUTE,
  15884. x2: MUST_USE_ATTRIBUTE,
  15885. x: MUST_USE_ATTRIBUTE,
  15886. xlinkActuate: MUST_USE_ATTRIBUTE,
  15887. xlinkArcrole: MUST_USE_ATTRIBUTE,
  15888. xlinkHref: MUST_USE_ATTRIBUTE,
  15889. xlinkRole: MUST_USE_ATTRIBUTE,
  15890. xlinkShow: MUST_USE_ATTRIBUTE,
  15891. xlinkTitle: MUST_USE_ATTRIBUTE,
  15892. xlinkType: MUST_USE_ATTRIBUTE,
  15893. xmlBase: MUST_USE_ATTRIBUTE,
  15894. xmlLang: MUST_USE_ATTRIBUTE,
  15895. xmlSpace: MUST_USE_ATTRIBUTE,
  15896. y1: MUST_USE_ATTRIBUTE,
  15897. y2: MUST_USE_ATTRIBUTE,
  15898. y: MUST_USE_ATTRIBUTE
  15899. },
  15900. DOMAttributeNamespaces: {
  15901. xlinkActuate: NS.xlink,
  15902. xlinkArcrole: NS.xlink,
  15903. xlinkHref: NS.xlink,
  15904. xlinkRole: NS.xlink,
  15905. xlinkShow: NS.xlink,
  15906. xlinkTitle: NS.xlink,
  15907. xlinkType: NS.xlink,
  15908. xmlBase: NS.xml,
  15909. xmlLang: NS.xml,
  15910. xmlSpace: NS.xml
  15911. },
  15912. DOMAttributeNames: {
  15913. clipPath: 'clip-path',
  15914. fillOpacity: 'fill-opacity',
  15915. fontFamily: 'font-family',
  15916. fontSize: 'font-size',
  15917. gradientTransform: 'gradientTransform',
  15918. gradientUnits: 'gradientUnits',
  15919. markerEnd: 'marker-end',
  15920. markerMid: 'marker-mid',
  15921. markerStart: 'marker-start',
  15922. patternContentUnits: 'patternContentUnits',
  15923. patternUnits: 'patternUnits',
  15924. preserveAspectRatio: 'preserveAspectRatio',
  15925. spreadMethod: 'spreadMethod',
  15926. stopColor: 'stop-color',
  15927. stopOpacity: 'stop-opacity',
  15928. strokeDasharray: 'stroke-dasharray',
  15929. strokeLinecap: 'stroke-linecap',
  15930. strokeOpacity: 'stroke-opacity',
  15931. strokeWidth: 'stroke-width',
  15932. textAnchor: 'text-anchor',
  15933. viewBox: 'viewBox',
  15934. xlinkActuate: 'xlink:actuate',
  15935. xlinkArcrole: 'xlink:arcrole',
  15936. xlinkHref: 'xlink:href',
  15937. xlinkRole: 'xlink:role',
  15938. xlinkShow: 'xlink:show',
  15939. xlinkTitle: 'xlink:title',
  15940. xlinkType: 'xlink:type',
  15941. xmlBase: 'xml:base',
  15942. xmlLang: 'xml:lang',
  15943. xmlSpace: 'xml:space'
  15944. }
  15945. };
  15946. module.exports = SVGDOMPropertyConfig;
  15947. /***/ },
  15948. /* 142 */
  15949. /***/ function(module, exports, __webpack_require__) {
  15950. /**
  15951. * Copyright 2013-2015, Facebook, Inc.
  15952. * All rights reserved.
  15953. *
  15954. * This source code is licensed under the BSD-style license found in the
  15955. * LICENSE file in the root directory of this source tree. An additional grant
  15956. * of patent rights can be found in the PATENTS file in the same directory.
  15957. *
  15958. * @providesModule ReactDefaultPerf
  15959. * @typechecks static-only
  15960. */
  15961. 'use strict';
  15962. var DOMProperty = __webpack_require__(23);
  15963. var ReactDefaultPerfAnalysis = __webpack_require__(143);
  15964. var ReactMount = __webpack_require__(28);
  15965. var ReactPerf = __webpack_require__(18);
  15966. var performanceNow = __webpack_require__(144);
  15967. function roundFloat(val) {
  15968. return Math.floor(val * 100) / 100;
  15969. }
  15970. function addValue(obj, key, val) {
  15971. obj[key] = (obj[key] || 0) + val;
  15972. }
  15973. var ReactDefaultPerf = {
  15974. _allMeasurements: [], // last item in the list is the current one
  15975. _mountStack: [0],
  15976. _injected: false,
  15977. start: function () {
  15978. if (!ReactDefaultPerf._injected) {
  15979. ReactPerf.injection.injectMeasure(ReactDefaultPerf.measure);
  15980. }
  15981. ReactDefaultPerf._allMeasurements.length = 0;
  15982. ReactPerf.enableMeasure = true;
  15983. },
  15984. stop: function () {
  15985. ReactPerf.enableMeasure = false;
  15986. },
  15987. getLastMeasurements: function () {
  15988. return ReactDefaultPerf._allMeasurements;
  15989. },
  15990. printExclusive: function (measurements) {
  15991. measurements = measurements || ReactDefaultPerf._allMeasurements;
  15992. var summary = ReactDefaultPerfAnalysis.getExclusiveSummary(measurements);
  15993. console.table(summary.map(function (item) {
  15994. return {
  15995. 'Component class name': item.componentName,
  15996. 'Total inclusive time (ms)': roundFloat(item.inclusive),
  15997. 'Exclusive mount time (ms)': roundFloat(item.exclusive),
  15998. 'Exclusive render time (ms)': roundFloat(item.render),
  15999. 'Mount time per instance (ms)': roundFloat(item.exclusive / item.count),
  16000. 'Render time per instance (ms)': roundFloat(item.render / item.count),
  16001. 'Instances': item.count
  16002. };
  16003. }));
  16004. // TODO: ReactDefaultPerfAnalysis.getTotalTime() does not return the correct
  16005. // number.
  16006. },
  16007. printInclusive: function (measurements) {
  16008. measurements = measurements || ReactDefaultPerf._allMeasurements;
  16009. var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements);
  16010. console.table(summary.map(function (item) {
  16011. return {
  16012. 'Owner > component': item.componentName,
  16013. 'Inclusive time (ms)': roundFloat(item.time),
  16014. 'Instances': item.count
  16015. };
  16016. }));
  16017. console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
  16018. },
  16019. getMeasurementsSummaryMap: function (measurements) {
  16020. var summary = ReactDefaultPerfAnalysis.getInclusiveSummary(measurements, true);
  16021. return summary.map(function (item) {
  16022. return {
  16023. 'Owner > component': item.componentName,
  16024. 'Wasted time (ms)': item.time,
  16025. 'Instances': item.count
  16026. };
  16027. });
  16028. },
  16029. printWasted: function (measurements) {
  16030. measurements = measurements || ReactDefaultPerf._allMeasurements;
  16031. console.table(ReactDefaultPerf.getMeasurementsSummaryMap(measurements));
  16032. console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
  16033. },
  16034. printDOM: function (measurements) {
  16035. measurements = measurements || ReactDefaultPerf._allMeasurements;
  16036. var summary = ReactDefaultPerfAnalysis.getDOMSummary(measurements);
  16037. console.table(summary.map(function (item) {
  16038. var result = {};
  16039. result[DOMProperty.ID_ATTRIBUTE_NAME] = item.id;
  16040. result.type = item.type;
  16041. result.args = JSON.stringify(item.args);
  16042. return result;
  16043. }));
  16044. console.log('Total time:', ReactDefaultPerfAnalysis.getTotalTime(measurements).toFixed(2) + ' ms');
  16045. },
  16046. _recordWrite: function (id, fnName, totalTime, args) {
  16047. // TODO: totalTime isn't that useful since it doesn't count paints/reflows
  16048. var writes = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1].writes;
  16049. writes[id] = writes[id] || [];
  16050. writes[id].push({
  16051. type: fnName,
  16052. time: totalTime,
  16053. args: args
  16054. });
  16055. },
  16056. measure: function (moduleName, fnName, func) {
  16057. return function () {
  16058. for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
  16059. args[_key] = arguments[_key];
  16060. }
  16061. var totalTime;
  16062. var rv;
  16063. var start;
  16064. if (fnName === '_renderNewRootComponent' || fnName === 'flushBatchedUpdates') {
  16065. // A "measurement" is a set of metrics recorded for each flush. We want
  16066. // to group the metrics for a given flush together so we can look at the
  16067. // components that rendered and the DOM operations that actually
  16068. // happened to determine the amount of "wasted work" performed.
  16069. ReactDefaultPerf._allMeasurements.push({
  16070. exclusive: {},
  16071. inclusive: {},
  16072. render: {},
  16073. counts: {},
  16074. writes: {},
  16075. displayNames: {},
  16076. totalTime: 0,
  16077. created: {}
  16078. });
  16079. start = performanceNow();
  16080. rv = func.apply(this, args);
  16081. ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1].totalTime = performanceNow() - start;
  16082. return rv;
  16083. } else if (fnName === '_mountImageIntoNode' || moduleName === 'ReactBrowserEventEmitter' || moduleName === 'ReactDOMIDOperations' || moduleName === 'CSSPropertyOperations' || moduleName === 'DOMChildrenOperations' || moduleName === 'DOMPropertyOperations') {
  16084. start = performanceNow();
  16085. rv = func.apply(this, args);
  16086. totalTime = performanceNow() - start;
  16087. if (fnName === '_mountImageIntoNode') {
  16088. var mountID = ReactMount.getID(args[1]);
  16089. ReactDefaultPerf._recordWrite(mountID, fnName, totalTime, args[0]);
  16090. } else if (fnName === 'dangerouslyProcessChildrenUpdates') {
  16091. // special format
  16092. args[0].forEach(function (update) {
  16093. var writeArgs = {};
  16094. if (update.fromIndex !== null) {
  16095. writeArgs.fromIndex = update.fromIndex;
  16096. }
  16097. if (update.toIndex !== null) {
  16098. writeArgs.toIndex = update.toIndex;
  16099. }
  16100. if (update.textContent !== null) {
  16101. writeArgs.textContent = update.textContent;
  16102. }
  16103. if (update.markupIndex !== null) {
  16104. writeArgs.markup = args[1][update.markupIndex];
  16105. }
  16106. ReactDefaultPerf._recordWrite(update.parentID, update.type, totalTime, writeArgs);
  16107. });
  16108. } else {
  16109. // basic format
  16110. var id = args[0];
  16111. if (typeof id === 'object') {
  16112. id = ReactMount.getID(args[0]);
  16113. }
  16114. ReactDefaultPerf._recordWrite(id, fnName, totalTime, Array.prototype.slice.call(args, 1));
  16115. }
  16116. return rv;
  16117. } else if (moduleName === 'ReactCompositeComponent' && (fnName === 'mountComponent' || fnName === 'updateComponent' || // TODO: receiveComponent()?
  16118. fnName === '_renderValidatedComponent')) {
  16119. if (this._currentElement.type === ReactMount.TopLevelWrapper) {
  16120. return func.apply(this, args);
  16121. }
  16122. var rootNodeID = fnName === 'mountComponent' ? args[0] : this._rootNodeID;
  16123. var isRender = fnName === '_renderValidatedComponent';
  16124. var isMount = fnName === 'mountComponent';
  16125. var mountStack = ReactDefaultPerf._mountStack;
  16126. var entry = ReactDefaultPerf._allMeasurements[ReactDefaultPerf._allMeasurements.length - 1];
  16127. if (isRender) {
  16128. addValue(entry.counts, rootNodeID, 1);
  16129. } else if (isMount) {
  16130. entry.created[rootNodeID] = true;
  16131. mountStack.push(0);
  16132. }
  16133. start = performanceNow();
  16134. rv = func.apply(this, args);
  16135. totalTime = performanceNow() - start;
  16136. if (isRender) {
  16137. addValue(entry.render, rootNodeID, totalTime);
  16138. } else if (isMount) {
  16139. var subMountTime = mountStack.pop();
  16140. mountStack[mountStack.length - 1] += totalTime;
  16141. addValue(entry.exclusive, rootNodeID, totalTime - subMountTime);
  16142. addValue(entry.inclusive, rootNodeID, totalTime);
  16143. } else {
  16144. addValue(entry.inclusive, rootNodeID, totalTime);
  16145. }
  16146. entry.displayNames[rootNodeID] = {
  16147. current: this.getName(),
  16148. owner: this._currentElement._owner ? this._currentElement._owner.getName() : '<root>'
  16149. };
  16150. return rv;
  16151. } else {
  16152. return func.apply(this, args);
  16153. }
  16154. };
  16155. }
  16156. };
  16157. module.exports = ReactDefaultPerf;
  16158. /***/ },
  16159. /* 143 */
  16160. /***/ function(module, exports, __webpack_require__) {
  16161. /**
  16162. * Copyright 2013-2015, Facebook, Inc.
  16163. * All rights reserved.
  16164. *
  16165. * This source code is licensed under the BSD-style license found in the
  16166. * LICENSE file in the root directory of this source tree. An additional grant
  16167. * of patent rights can be found in the PATENTS file in the same directory.
  16168. *
  16169. * @providesModule ReactDefaultPerfAnalysis
  16170. */
  16171. 'use strict';
  16172. var assign = __webpack_require__(39);
  16173. // Don't try to save users less than 1.2ms (a number I made up)
  16174. var DONT_CARE_THRESHOLD = 1.2;
  16175. var DOM_OPERATION_TYPES = {
  16176. '_mountImageIntoNode': 'set innerHTML',
  16177. INSERT_MARKUP: 'set innerHTML',
  16178. MOVE_EXISTING: 'move',
  16179. REMOVE_NODE: 'remove',
  16180. SET_MARKUP: 'set innerHTML',
  16181. TEXT_CONTENT: 'set textContent',
  16182. 'setValueForProperty': 'update attribute',
  16183. 'setValueForAttribute': 'update attribute',
  16184. 'deleteValueForProperty': 'remove attribute',
  16185. 'setValueForStyles': 'update styles',
  16186. 'replaceNodeWithMarkup': 'replace',
  16187. 'updateTextContent': 'set textContent'
  16188. };
  16189. function getTotalTime(measurements) {
  16190. // TODO: return number of DOM ops? could be misleading.
  16191. // TODO: measure dropped frames after reconcile?
  16192. // TODO: log total time of each reconcile and the top-level component
  16193. // class that triggered it.
  16194. var totalTime = 0;
  16195. for (var i = 0; i < measurements.length; i++) {
  16196. var measurement = measurements[i];
  16197. totalTime += measurement.totalTime;
  16198. }
  16199. return totalTime;
  16200. }
  16201. function getDOMSummary(measurements) {
  16202. var items = [];
  16203. measurements.forEach(function (measurement) {
  16204. Object.keys(measurement.writes).forEach(function (id) {
  16205. measurement.writes[id].forEach(function (write) {
  16206. items.push({
  16207. id: id,
  16208. type: DOM_OPERATION_TYPES[write.type] || write.type,
  16209. args: write.args
  16210. });
  16211. });
  16212. });
  16213. });
  16214. return items;
  16215. }
  16216. function getExclusiveSummary(measurements) {
  16217. var candidates = {};
  16218. var displayName;
  16219. for (var i = 0; i < measurements.length; i++) {
  16220. var measurement = measurements[i];
  16221. var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
  16222. for (var id in allIDs) {
  16223. displayName = measurement.displayNames[id].current;
  16224. candidates[displayName] = candidates[displayName] || {
  16225. componentName: displayName,
  16226. inclusive: 0,
  16227. exclusive: 0,
  16228. render: 0,
  16229. count: 0
  16230. };
  16231. if (measurement.render[id]) {
  16232. candidates[displayName].render += measurement.render[id];
  16233. }
  16234. if (measurement.exclusive[id]) {
  16235. candidates[displayName].exclusive += measurement.exclusive[id];
  16236. }
  16237. if (measurement.inclusive[id]) {
  16238. candidates[displayName].inclusive += measurement.inclusive[id];
  16239. }
  16240. if (measurement.counts[id]) {
  16241. candidates[displayName].count += measurement.counts[id];
  16242. }
  16243. }
  16244. }
  16245. // Now make a sorted array with the results.
  16246. var arr = [];
  16247. for (displayName in candidates) {
  16248. if (candidates[displayName].exclusive >= DONT_CARE_THRESHOLD) {
  16249. arr.push(candidates[displayName]);
  16250. }
  16251. }
  16252. arr.sort(function (a, b) {
  16253. return b.exclusive - a.exclusive;
  16254. });
  16255. return arr;
  16256. }
  16257. function getInclusiveSummary(measurements, onlyClean) {
  16258. var candidates = {};
  16259. var inclusiveKey;
  16260. for (var i = 0; i < measurements.length; i++) {
  16261. var measurement = measurements[i];
  16262. var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
  16263. var cleanComponents;
  16264. if (onlyClean) {
  16265. cleanComponents = getUnchangedComponents(measurement);
  16266. }
  16267. for (var id in allIDs) {
  16268. if (onlyClean && !cleanComponents[id]) {
  16269. continue;
  16270. }
  16271. var displayName = measurement.displayNames[id];
  16272. // Inclusive time is not useful for many components without knowing where
  16273. // they are instantiated. So we aggregate inclusive time with both the
  16274. // owner and current displayName as the key.
  16275. inclusiveKey = displayName.owner + ' > ' + displayName.current;
  16276. candidates[inclusiveKey] = candidates[inclusiveKey] || {
  16277. componentName: inclusiveKey,
  16278. time: 0,
  16279. count: 0
  16280. };
  16281. if (measurement.inclusive[id]) {
  16282. candidates[inclusiveKey].time += measurement.inclusive[id];
  16283. }
  16284. if (measurement.counts[id]) {
  16285. candidates[inclusiveKey].count += measurement.counts[id];
  16286. }
  16287. }
  16288. }
  16289. // Now make a sorted array with the results.
  16290. var arr = [];
  16291. for (inclusiveKey in candidates) {
  16292. if (candidates[inclusiveKey].time >= DONT_CARE_THRESHOLD) {
  16293. arr.push(candidates[inclusiveKey]);
  16294. }
  16295. }
  16296. arr.sort(function (a, b) {
  16297. return b.time - a.time;
  16298. });
  16299. return arr;
  16300. }
  16301. function getUnchangedComponents(measurement) {
  16302. // For a given reconcile, look at which components did not actually
  16303. // render anything to the DOM and return a mapping of their ID to
  16304. // the amount of time it took to render the entire subtree.
  16305. var cleanComponents = {};
  16306. var dirtyLeafIDs = Object.keys(measurement.writes);
  16307. var allIDs = assign({}, measurement.exclusive, measurement.inclusive);
  16308. for (var id in allIDs) {
  16309. var isDirty = false;
  16310. // For each component that rendered, see if a component that triggered
  16311. // a DOM op is in its subtree.
  16312. for (var i = 0; i < dirtyLeafIDs.length; i++) {
  16313. if (dirtyLeafIDs[i].indexOf(id) === 0) {
  16314. isDirty = true;
  16315. break;
  16316. }
  16317. }
  16318. // check if component newly created
  16319. if (measurement.created[id]) {
  16320. isDirty = true;
  16321. }
  16322. if (!isDirty && measurement.counts[id] > 0) {
  16323. cleanComponents[id] = true;
  16324. }
  16325. }
  16326. return cleanComponents;
  16327. }
  16328. var ReactDefaultPerfAnalysis = {
  16329. getExclusiveSummary: getExclusiveSummary,
  16330. getInclusiveSummary: getInclusiveSummary,
  16331. getDOMSummary: getDOMSummary,
  16332. getTotalTime: getTotalTime
  16333. };
  16334. module.exports = ReactDefaultPerfAnalysis;
  16335. /***/ },
  16336. /* 144 */
  16337. /***/ function(module, exports, __webpack_require__) {
  16338. /**
  16339. * Copyright 2013-2015, Facebook, Inc.
  16340. * All rights reserved.
  16341. *
  16342. * This source code is licensed under the BSD-style license found in the
  16343. * LICENSE file in the root directory of this source tree. An additional grant
  16344. * of patent rights can be found in the PATENTS file in the same directory.
  16345. *
  16346. * @providesModule performanceNow
  16347. * @typechecks
  16348. */
  16349. 'use strict';
  16350. var performance = __webpack_require__(145);
  16351. var performanceNow;
  16352. /**
  16353. * Detect if we can use `window.performance.now()` and gracefully fallback to
  16354. * `Date.now()` if it doesn't exist. We need to support Firefox < 15 for now
  16355. * because of Facebook's testing infrastructure.
  16356. */
  16357. if (performance.now) {
  16358. performanceNow = function () {
  16359. return performance.now();
  16360. };
  16361. } else {
  16362. performanceNow = function () {
  16363. return Date.now();
  16364. };
  16365. }
  16366. module.exports = performanceNow;
  16367. /***/ },
  16368. /* 145 */
  16369. /***/ function(module, exports, __webpack_require__) {
  16370. /**
  16371. * Copyright 2013-2015, Facebook, Inc.
  16372. * All rights reserved.
  16373. *
  16374. * This source code is licensed under the BSD-style license found in the
  16375. * LICENSE file in the root directory of this source tree. An additional grant
  16376. * of patent rights can be found in the PATENTS file in the same directory.
  16377. *
  16378. * @providesModule performance
  16379. * @typechecks
  16380. */
  16381. 'use strict';
  16382. var ExecutionEnvironment = __webpack_require__(9);
  16383. var performance;
  16384. if (ExecutionEnvironment.canUseDOM) {
  16385. performance = window.performance || window.msPerformance || window.webkitPerformance;
  16386. }
  16387. module.exports = performance || {};
  16388. /***/ },
  16389. /* 146 */
  16390. /***/ function(module, exports) {
  16391. /**
  16392. * Copyright 2013-2015, Facebook, Inc.
  16393. * All rights reserved.
  16394. *
  16395. * This source code is licensed under the BSD-style license found in the
  16396. * LICENSE file in the root directory of this source tree. An additional grant
  16397. * of patent rights can be found in the PATENTS file in the same directory.
  16398. *
  16399. * @providesModule ReactVersion
  16400. */
  16401. 'use strict';
  16402. module.exports = '0.14.8';
  16403. /***/ },
  16404. /* 147 */
  16405. /***/ function(module, exports, __webpack_require__) {
  16406. /**
  16407. * Copyright 2013-2015, Facebook, Inc.
  16408. * All rights reserved.
  16409. *
  16410. * This source code is licensed under the BSD-style license found in the
  16411. * LICENSE file in the root directory of this source tree. An additional grant
  16412. * of patent rights can be found in the PATENTS file in the same directory.
  16413. *
  16414. * @providesModule renderSubtreeIntoContainer
  16415. */
  16416. 'use strict';
  16417. var ReactMount = __webpack_require__(28);
  16418. module.exports = ReactMount.renderSubtreeIntoContainer;
  16419. /***/ },
  16420. /* 148 */
  16421. /***/ function(module, exports, __webpack_require__) {
  16422. /**
  16423. * Copyright 2013-2015, Facebook, Inc.
  16424. * All rights reserved.
  16425. *
  16426. * This source code is licensed under the BSD-style license found in the
  16427. * LICENSE file in the root directory of this source tree. An additional grant
  16428. * of patent rights can be found in the PATENTS file in the same directory.
  16429. *
  16430. * @providesModule ReactDOMServer
  16431. */
  16432. 'use strict';
  16433. var ReactDefaultInjection = __webpack_require__(71);
  16434. var ReactServerRendering = __webpack_require__(149);
  16435. var ReactVersion = __webpack_require__(146);
  16436. ReactDefaultInjection.inject();
  16437. var ReactDOMServer = {
  16438. renderToString: ReactServerRendering.renderToString,
  16439. renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup,
  16440. version: ReactVersion
  16441. };
  16442. module.exports = ReactDOMServer;
  16443. /***/ },
  16444. /* 149 */
  16445. /***/ function(module, exports, __webpack_require__) {
  16446. /* WEBPACK VAR INJECTION */(function(process) {/**
  16447. * Copyright 2013-2015, Facebook, Inc.
  16448. * All rights reserved.
  16449. *
  16450. * This source code is licensed under the BSD-style license found in the
  16451. * LICENSE file in the root directory of this source tree. An additional grant
  16452. * of patent rights can be found in the PATENTS file in the same directory.
  16453. *
  16454. * @typechecks static-only
  16455. * @providesModule ReactServerRendering
  16456. */
  16457. 'use strict';
  16458. var ReactDefaultBatchingStrategy = __webpack_require__(92);
  16459. var ReactElement = __webpack_require__(42);
  16460. var ReactInstanceHandles = __webpack_require__(45);
  16461. var ReactMarkupChecksum = __webpack_require__(48);
  16462. var ReactServerBatchingStrategy = __webpack_require__(150);
  16463. var ReactServerRenderingTransaction = __webpack_require__(151);
  16464. var ReactUpdates = __webpack_require__(54);
  16465. var emptyObject = __webpack_require__(58);
  16466. var instantiateReactComponent = __webpack_require__(62);
  16467. var invariant = __webpack_require__(13);
  16468. /**
  16469. * @param {ReactElement} element
  16470. * @return {string} the HTML markup
  16471. */
  16472. function renderToString(element) {
  16473. !ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToString(): You must pass a valid ReactElement.') : invariant(false) : undefined;
  16474. var transaction;
  16475. try {
  16476. ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
  16477. var id = ReactInstanceHandles.createReactRootID();
  16478. transaction = ReactServerRenderingTransaction.getPooled(false);
  16479. return transaction.perform(function () {
  16480. var componentInstance = instantiateReactComponent(element, null);
  16481. var markup = componentInstance.mountComponent(id, transaction, emptyObject);
  16482. return ReactMarkupChecksum.addChecksumToMarkup(markup);
  16483. }, null);
  16484. } finally {
  16485. ReactServerRenderingTransaction.release(transaction);
  16486. // Revert to the DOM batching strategy since these two renderers
  16487. // currently share these stateful modules.
  16488. ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
  16489. }
  16490. }
  16491. /**
  16492. * @param {ReactElement} element
  16493. * @return {string} the HTML markup, without the extra React ID and checksum
  16494. * (for generating static pages)
  16495. */
  16496. function renderToStaticMarkup(element) {
  16497. !ReactElement.isValidElement(element) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'renderToStaticMarkup(): You must pass a valid ReactElement.') : invariant(false) : undefined;
  16498. var transaction;
  16499. try {
  16500. ReactUpdates.injection.injectBatchingStrategy(ReactServerBatchingStrategy);
  16501. var id = ReactInstanceHandles.createReactRootID();
  16502. transaction = ReactServerRenderingTransaction.getPooled(true);
  16503. return transaction.perform(function () {
  16504. var componentInstance = instantiateReactComponent(element, null);
  16505. return componentInstance.mountComponent(id, transaction, emptyObject);
  16506. }, null);
  16507. } finally {
  16508. ReactServerRenderingTransaction.release(transaction);
  16509. // Revert to the DOM batching strategy since these two renderers
  16510. // currently share these stateful modules.
  16511. ReactUpdates.injection.injectBatchingStrategy(ReactDefaultBatchingStrategy);
  16512. }
  16513. }
  16514. module.exports = {
  16515. renderToString: renderToString,
  16516. renderToStaticMarkup: renderToStaticMarkup
  16517. };
  16518. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  16519. /***/ },
  16520. /* 150 */
  16521. /***/ function(module, exports) {
  16522. /**
  16523. * Copyright 2014-2015, Facebook, Inc.
  16524. * All rights reserved.
  16525. *
  16526. * This source code is licensed under the BSD-style license found in the
  16527. * LICENSE file in the root directory of this source tree. An additional grant
  16528. * of patent rights can be found in the PATENTS file in the same directory.
  16529. *
  16530. * @providesModule ReactServerBatchingStrategy
  16531. * @typechecks
  16532. */
  16533. 'use strict';
  16534. var ReactServerBatchingStrategy = {
  16535. isBatchingUpdates: false,
  16536. batchedUpdates: function (callback) {
  16537. // Don't do anything here. During the server rendering we don't want to
  16538. // schedule any updates. We will simply ignore them.
  16539. }
  16540. };
  16541. module.exports = ReactServerBatchingStrategy;
  16542. /***/ },
  16543. /* 151 */
  16544. /***/ function(module, exports, __webpack_require__) {
  16545. /**
  16546. * Copyright 2014-2015, Facebook, Inc.
  16547. * All rights reserved.
  16548. *
  16549. * This source code is licensed under the BSD-style license found in the
  16550. * LICENSE file in the root directory of this source tree. An additional grant
  16551. * of patent rights can be found in the PATENTS file in the same directory.
  16552. *
  16553. * @providesModule ReactServerRenderingTransaction
  16554. * @typechecks
  16555. */
  16556. 'use strict';
  16557. var PooledClass = __webpack_require__(56);
  16558. var CallbackQueue = __webpack_require__(55);
  16559. var Transaction = __webpack_require__(57);
  16560. var assign = __webpack_require__(39);
  16561. var emptyFunction = __webpack_require__(15);
  16562. /**
  16563. * Provides a `CallbackQueue` queue for collecting `onDOMReady` callbacks
  16564. * during the performing of the transaction.
  16565. */
  16566. var ON_DOM_READY_QUEUEING = {
  16567. /**
  16568. * Initializes the internal `onDOMReady` queue.
  16569. */
  16570. initialize: function () {
  16571. this.reactMountReady.reset();
  16572. },
  16573. close: emptyFunction
  16574. };
  16575. /**
  16576. * Executed within the scope of the `Transaction` instance. Consider these as
  16577. * being member methods, but with an implied ordering while being isolated from
  16578. * each other.
  16579. */
  16580. var TRANSACTION_WRAPPERS = [ON_DOM_READY_QUEUEING];
  16581. /**
  16582. * @class ReactServerRenderingTransaction
  16583. * @param {boolean} renderToStaticMarkup
  16584. */
  16585. function ReactServerRenderingTransaction(renderToStaticMarkup) {
  16586. this.reinitializeTransaction();
  16587. this.renderToStaticMarkup = renderToStaticMarkup;
  16588. this.reactMountReady = CallbackQueue.getPooled(null);
  16589. this.useCreateElement = false;
  16590. }
  16591. var Mixin = {
  16592. /**
  16593. * @see Transaction
  16594. * @abstract
  16595. * @final
  16596. * @return {array} Empty list of operation wrap procedures.
  16597. */
  16598. getTransactionWrappers: function () {
  16599. return TRANSACTION_WRAPPERS;
  16600. },
  16601. /**
  16602. * @return {object} The queue to collect `onDOMReady` callbacks with.
  16603. */
  16604. getReactMountReady: function () {
  16605. return this.reactMountReady;
  16606. },
  16607. /**
  16608. * `PooledClass` looks for this, and will invoke this before allowing this
  16609. * instance to be reused.
  16610. */
  16611. destructor: function () {
  16612. CallbackQueue.release(this.reactMountReady);
  16613. this.reactMountReady = null;
  16614. }
  16615. };
  16616. assign(ReactServerRenderingTransaction.prototype, Transaction.Mixin, Mixin);
  16617. PooledClass.addPoolingTo(ReactServerRenderingTransaction);
  16618. module.exports = ReactServerRenderingTransaction;
  16619. /***/ },
  16620. /* 152 */
  16621. /***/ function(module, exports, __webpack_require__) {
  16622. /* WEBPACK VAR INJECTION */(function(process) {/**
  16623. * Copyright 2013-2015, Facebook, Inc.
  16624. * All rights reserved.
  16625. *
  16626. * This source code is licensed under the BSD-style license found in the
  16627. * LICENSE file in the root directory of this source tree. An additional grant
  16628. * of patent rights can be found in the PATENTS file in the same directory.
  16629. *
  16630. * @providesModule ReactIsomorphic
  16631. */
  16632. 'use strict';
  16633. var ReactChildren = __webpack_require__(110);
  16634. var ReactComponent = __webpack_require__(123);
  16635. var ReactClass = __webpack_require__(122);
  16636. var ReactDOMFactories = __webpack_require__(153);
  16637. var ReactElement = __webpack_require__(42);
  16638. var ReactElementValidator = __webpack_require__(154);
  16639. var ReactPropTypes = __webpack_require__(107);
  16640. var ReactVersion = __webpack_require__(146);
  16641. var assign = __webpack_require__(39);
  16642. var onlyChild = __webpack_require__(156);
  16643. var createElement = ReactElement.createElement;
  16644. var createFactory = ReactElement.createFactory;
  16645. var cloneElement = ReactElement.cloneElement;
  16646. if (process.env.NODE_ENV !== 'production') {
  16647. createElement = ReactElementValidator.createElement;
  16648. createFactory = ReactElementValidator.createFactory;
  16649. cloneElement = ReactElementValidator.cloneElement;
  16650. }
  16651. var React = {
  16652. // Modern
  16653. Children: {
  16654. map: ReactChildren.map,
  16655. forEach: ReactChildren.forEach,
  16656. count: ReactChildren.count,
  16657. toArray: ReactChildren.toArray,
  16658. only: onlyChild
  16659. },
  16660. Component: ReactComponent,
  16661. createElement: createElement,
  16662. cloneElement: cloneElement,
  16663. isValidElement: ReactElement.isValidElement,
  16664. // Classic
  16665. PropTypes: ReactPropTypes,
  16666. createClass: ReactClass.createClass,
  16667. createFactory: createFactory,
  16668. createMixin: function (mixin) {
  16669. // Currently a noop. Will be used to validate and trace mixins.
  16670. return mixin;
  16671. },
  16672. // This looks DOM specific but these are actually isomorphic helpers
  16673. // since they are just generating DOM strings.
  16674. DOM: ReactDOMFactories,
  16675. version: ReactVersion,
  16676. // Hook for JSX spread, don't use this for anything else.
  16677. __spread: assign
  16678. };
  16679. module.exports = React;
  16680. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  16681. /***/ },
  16682. /* 153 */
  16683. /***/ function(module, exports, __webpack_require__) {
  16684. /* WEBPACK VAR INJECTION */(function(process) {/**
  16685. * Copyright 2013-2015, Facebook, Inc.
  16686. * All rights reserved.
  16687. *
  16688. * This source code is licensed under the BSD-style license found in the
  16689. * LICENSE file in the root directory of this source tree. An additional grant
  16690. * of patent rights can be found in the PATENTS file in the same directory.
  16691. *
  16692. * @providesModule ReactDOMFactories
  16693. * @typechecks static-only
  16694. */
  16695. 'use strict';
  16696. var ReactElement = __webpack_require__(42);
  16697. var ReactElementValidator = __webpack_require__(154);
  16698. var mapObject = __webpack_require__(155);
  16699. /**
  16700. * Create a factory that creates HTML tag elements.
  16701. *
  16702. * @param {string} tag Tag name (e.g. `div`).
  16703. * @private
  16704. */
  16705. function createDOMFactory(tag) {
  16706. if (process.env.NODE_ENV !== 'production') {
  16707. return ReactElementValidator.createFactory(tag);
  16708. }
  16709. return ReactElement.createFactory(tag);
  16710. }
  16711. /**
  16712. * Creates a mapping from supported HTML tags to `ReactDOMComponent` classes.
  16713. * This is also accessible via `React.DOM`.
  16714. *
  16715. * @public
  16716. */
  16717. var ReactDOMFactories = mapObject({
  16718. a: 'a',
  16719. abbr: 'abbr',
  16720. address: 'address',
  16721. area: 'area',
  16722. article: 'article',
  16723. aside: 'aside',
  16724. audio: 'audio',
  16725. b: 'b',
  16726. base: 'base',
  16727. bdi: 'bdi',
  16728. bdo: 'bdo',
  16729. big: 'big',
  16730. blockquote: 'blockquote',
  16731. body: 'body',
  16732. br: 'br',
  16733. button: 'button',
  16734. canvas: 'canvas',
  16735. caption: 'caption',
  16736. cite: 'cite',
  16737. code: 'code',
  16738. col: 'col',
  16739. colgroup: 'colgroup',
  16740. data: 'data',
  16741. datalist: 'datalist',
  16742. dd: 'dd',
  16743. del: 'del',
  16744. details: 'details',
  16745. dfn: 'dfn',
  16746. dialog: 'dialog',
  16747. div: 'div',
  16748. dl: 'dl',
  16749. dt: 'dt',
  16750. em: 'em',
  16751. embed: 'embed',
  16752. fieldset: 'fieldset',
  16753. figcaption: 'figcaption',
  16754. figure: 'figure',
  16755. footer: 'footer',
  16756. form: 'form',
  16757. h1: 'h1',
  16758. h2: 'h2',
  16759. h3: 'h3',
  16760. h4: 'h4',
  16761. h5: 'h5',
  16762. h6: 'h6',
  16763. head: 'head',
  16764. header: 'header',
  16765. hgroup: 'hgroup',
  16766. hr: 'hr',
  16767. html: 'html',
  16768. i: 'i',
  16769. iframe: 'iframe',
  16770. img: 'img',
  16771. input: 'input',
  16772. ins: 'ins',
  16773. kbd: 'kbd',
  16774. keygen: 'keygen',
  16775. label: 'label',
  16776. legend: 'legend',
  16777. li: 'li',
  16778. link: 'link',
  16779. main: 'main',
  16780. map: 'map',
  16781. mark: 'mark',
  16782. menu: 'menu',
  16783. menuitem: 'menuitem',
  16784. meta: 'meta',
  16785. meter: 'meter',
  16786. nav: 'nav',
  16787. noscript: 'noscript',
  16788. object: 'object',
  16789. ol: 'ol',
  16790. optgroup: 'optgroup',
  16791. option: 'option',
  16792. output: 'output',
  16793. p: 'p',
  16794. param: 'param',
  16795. picture: 'picture',
  16796. pre: 'pre',
  16797. progress: 'progress',
  16798. q: 'q',
  16799. rp: 'rp',
  16800. rt: 'rt',
  16801. ruby: 'ruby',
  16802. s: 's',
  16803. samp: 'samp',
  16804. script: 'script',
  16805. section: 'section',
  16806. select: 'select',
  16807. small: 'small',
  16808. source: 'source',
  16809. span: 'span',
  16810. strong: 'strong',
  16811. style: 'style',
  16812. sub: 'sub',
  16813. summary: 'summary',
  16814. sup: 'sup',
  16815. table: 'table',
  16816. tbody: 'tbody',
  16817. td: 'td',
  16818. textarea: 'textarea',
  16819. tfoot: 'tfoot',
  16820. th: 'th',
  16821. thead: 'thead',
  16822. time: 'time',
  16823. title: 'title',
  16824. tr: 'tr',
  16825. track: 'track',
  16826. u: 'u',
  16827. ul: 'ul',
  16828. 'var': 'var',
  16829. video: 'video',
  16830. wbr: 'wbr',
  16831. // SVG
  16832. circle: 'circle',
  16833. clipPath: 'clipPath',
  16834. defs: 'defs',
  16835. ellipse: 'ellipse',
  16836. g: 'g',
  16837. image: 'image',
  16838. line: 'line',
  16839. linearGradient: 'linearGradient',
  16840. mask: 'mask',
  16841. path: 'path',
  16842. pattern: 'pattern',
  16843. polygon: 'polygon',
  16844. polyline: 'polyline',
  16845. radialGradient: 'radialGradient',
  16846. rect: 'rect',
  16847. stop: 'stop',
  16848. svg: 'svg',
  16849. text: 'text',
  16850. tspan: 'tspan'
  16851. }, createDOMFactory);
  16852. module.exports = ReactDOMFactories;
  16853. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  16854. /***/ },
  16855. /* 154 */
  16856. /***/ function(module, exports, __webpack_require__) {
  16857. /* WEBPACK VAR INJECTION */(function(process) {/**
  16858. * Copyright 2014-2015, Facebook, Inc.
  16859. * All rights reserved.
  16860. *
  16861. * This source code is licensed under the BSD-style license found in the
  16862. * LICENSE file in the root directory of this source tree. An additional grant
  16863. * of patent rights can be found in the PATENTS file in the same directory.
  16864. *
  16865. * @providesModule ReactElementValidator
  16866. */
  16867. /**
  16868. * ReactElementValidator provides a wrapper around a element factory
  16869. * which validates the props passed to the element. This is intended to be
  16870. * used only in DEV and could be replaced by a static type checker for languages
  16871. * that support it.
  16872. */
  16873. 'use strict';
  16874. var ReactElement = __webpack_require__(42);
  16875. var ReactPropTypeLocations = __webpack_require__(65);
  16876. var ReactPropTypeLocationNames = __webpack_require__(66);
  16877. var ReactCurrentOwner = __webpack_require__(5);
  16878. var canDefineProperty = __webpack_require__(43);
  16879. var getIteratorFn = __webpack_require__(108);
  16880. var invariant = __webpack_require__(13);
  16881. var warning = __webpack_require__(25);
  16882. function getDeclarationErrorAddendum() {
  16883. if (ReactCurrentOwner.current) {
  16884. var name = ReactCurrentOwner.current.getName();
  16885. if (name) {
  16886. return ' Check the render method of `' + name + '`.';
  16887. }
  16888. }
  16889. return '';
  16890. }
  16891. /**
  16892. * Warn if there's no key explicitly set on dynamic arrays of children or
  16893. * object keys are not valid. This allows us to keep track of children between
  16894. * updates.
  16895. */
  16896. var ownerHasKeyUseWarning = {};
  16897. var loggedTypeFailures = {};
  16898. /**
  16899. * Warn if the element doesn't have an explicit key assigned to it.
  16900. * This element is in an array. The array could grow and shrink or be
  16901. * reordered. All children that haven't already been validated are required to
  16902. * have a "key" property assigned to it.
  16903. *
  16904. * @internal
  16905. * @param {ReactElement} element Element that requires a key.
  16906. * @param {*} parentType element's parent's type.
  16907. */
  16908. function validateExplicitKey(element, parentType) {
  16909. if (!element._store || element._store.validated || element.key != null) {
  16910. return;
  16911. }
  16912. element._store.validated = true;
  16913. var addenda = getAddendaForKeyUse('uniqueKey', element, parentType);
  16914. if (addenda === null) {
  16915. // we already showed the warning
  16916. return;
  16917. }
  16918. process.env.NODE_ENV !== 'production' ? warning(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s%s', addenda.parentOrOwner || '', addenda.childOwner || '', addenda.url || '') : undefined;
  16919. }
  16920. /**
  16921. * Shared warning and monitoring code for the key warnings.
  16922. *
  16923. * @internal
  16924. * @param {string} messageType A key used for de-duping warnings.
  16925. * @param {ReactElement} element Component that requires a key.
  16926. * @param {*} parentType element's parent's type.
  16927. * @returns {?object} A set of addenda to use in the warning message, or null
  16928. * if the warning has already been shown before (and shouldn't be shown again).
  16929. */
  16930. function getAddendaForKeyUse(messageType, element, parentType) {
  16931. var addendum = getDeclarationErrorAddendum();
  16932. if (!addendum) {
  16933. var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
  16934. if (parentName) {
  16935. addendum = ' Check the top-level render call using <' + parentName + '>.';
  16936. }
  16937. }
  16938. var memoizer = ownerHasKeyUseWarning[messageType] || (ownerHasKeyUseWarning[messageType] = {});
  16939. if (memoizer[addendum]) {
  16940. return null;
  16941. }
  16942. memoizer[addendum] = true;
  16943. var addenda = {
  16944. parentOrOwner: addendum,
  16945. url: ' See https://fb.me/react-warning-keys for more information.',
  16946. childOwner: null
  16947. };
  16948. // Usually the current owner is the offender, but if it accepts children as a
  16949. // property, it may be the creator of the child that's responsible for
  16950. // assigning it a key.
  16951. if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
  16952. // Give the component that originally created this child.
  16953. addenda.childOwner = ' It was passed a child from ' + element._owner.getName() + '.';
  16954. }
  16955. return addenda;
  16956. }
  16957. /**
  16958. * Ensure that every element either is passed in a static location, in an
  16959. * array with an explicit keys property defined, or in an object literal
  16960. * with valid key property.
  16961. *
  16962. * @internal
  16963. * @param {ReactNode} node Statically passed child of any type.
  16964. * @param {*} parentType node's parent's type.
  16965. */
  16966. function validateChildKeys(node, parentType) {
  16967. if (typeof node !== 'object') {
  16968. return;
  16969. }
  16970. if (Array.isArray(node)) {
  16971. for (var i = 0; i < node.length; i++) {
  16972. var child = node[i];
  16973. if (ReactElement.isValidElement(child)) {
  16974. validateExplicitKey(child, parentType);
  16975. }
  16976. }
  16977. } else if (ReactElement.isValidElement(node)) {
  16978. // This element was passed in a valid location.
  16979. if (node._store) {
  16980. node._store.validated = true;
  16981. }
  16982. } else if (node) {
  16983. var iteratorFn = getIteratorFn(node);
  16984. // Entry iterators provide implicit keys.
  16985. if (iteratorFn) {
  16986. if (iteratorFn !== node.entries) {
  16987. var iterator = iteratorFn.call(node);
  16988. var step;
  16989. while (!(step = iterator.next()).done) {
  16990. if (ReactElement.isValidElement(step.value)) {
  16991. validateExplicitKey(step.value, parentType);
  16992. }
  16993. }
  16994. }
  16995. }
  16996. }
  16997. }
  16998. /**
  16999. * Assert that the props are valid
  17000. *
  17001. * @param {string} componentName Name of the component for error messages.
  17002. * @param {object} propTypes Map of prop name to a ReactPropType
  17003. * @param {object} props
  17004. * @param {string} location e.g. "prop", "context", "child context"
  17005. * @private
  17006. */
  17007. function checkPropTypes(componentName, propTypes, props, location) {
  17008. for (var propName in propTypes) {
  17009. if (propTypes.hasOwnProperty(propName)) {
  17010. var error;
  17011. // Prop type validation may throw. In case they do, we don't want to
  17012. // fail the render phase where it didn't fail before. So we log it.
  17013. // After these have been cleaned up, we'll let them throw.
  17014. try {
  17015. // This is intentionally an invariant that gets caught. It's the same
  17016. // behavior as without this statement except with a better message.
  17017. !(typeof propTypes[propName] === 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, '%s: %s type `%s` is invalid; it must be a function, usually from ' + 'React.PropTypes.', componentName || 'React class', ReactPropTypeLocationNames[location], propName) : invariant(false) : undefined;
  17018. error = propTypes[propName](props, propName, componentName, location);
  17019. } catch (ex) {
  17020. error = ex;
  17021. }
  17022. process.env.NODE_ENV !== 'production' ? warning(!error || error instanceof Error, '%s: type specification of %s `%s` is invalid; the type checker ' + 'function must return `null` or an `Error` but returned a %s. ' + 'You may have forgotten to pass an argument to the type checker ' + 'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' + 'shape all require an argument).', componentName || 'React class', ReactPropTypeLocationNames[location], propName, typeof error) : undefined;
  17023. if (error instanceof Error && !(error.message in loggedTypeFailures)) {
  17024. // Only monitor this failure once because there tends to be a lot of the
  17025. // same error.
  17026. loggedTypeFailures[error.message] = true;
  17027. var addendum = getDeclarationErrorAddendum();
  17028. process.env.NODE_ENV !== 'production' ? warning(false, 'Failed propType: %s%s', error.message, addendum) : undefined;
  17029. }
  17030. }
  17031. }
  17032. }
  17033. /**
  17034. * Given an element, validate that its props follow the propTypes definition,
  17035. * provided by the type.
  17036. *
  17037. * @param {ReactElement} element
  17038. */
  17039. function validatePropTypes(element) {
  17040. var componentClass = element.type;
  17041. if (typeof componentClass !== 'function') {
  17042. return;
  17043. }
  17044. var name = componentClass.displayName || componentClass.name;
  17045. if (componentClass.propTypes) {
  17046. checkPropTypes(name, componentClass.propTypes, element.props, ReactPropTypeLocations.prop);
  17047. }
  17048. if (typeof componentClass.getDefaultProps === 'function') {
  17049. process.env.NODE_ENV !== 'production' ? warning(componentClass.getDefaultProps.isReactClassApproved, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : undefined;
  17050. }
  17051. }
  17052. var ReactElementValidator = {
  17053. createElement: function (type, props, children) {
  17054. var validType = typeof type === 'string' || typeof type === 'function';
  17055. // We warn in this case but don't throw. We expect the element creation to
  17056. // succeed and there will likely be errors in render.
  17057. process.env.NODE_ENV !== 'production' ? warning(validType, 'React.createElement: type should not be null, undefined, boolean, or ' + 'number. It should be a string (for DOM elements) or a ReactClass ' + '(for composite components).%s', getDeclarationErrorAddendum()) : undefined;
  17058. var element = ReactElement.createElement.apply(this, arguments);
  17059. // The result can be nullish if a mock or a custom function is used.
  17060. // TODO: Drop this when these are no longer allowed as the type argument.
  17061. if (element == null) {
  17062. return element;
  17063. }
  17064. // Skip key warning if the type isn't valid since our key validation logic
  17065. // doesn't expect a non-string/function type and can throw confusing errors.
  17066. // We don't want exception behavior to differ between dev and prod.
  17067. // (Rendering will throw with a helpful message and as soon as the type is
  17068. // fixed, the key warnings will appear.)
  17069. if (validType) {
  17070. for (var i = 2; i < arguments.length; i++) {
  17071. validateChildKeys(arguments[i], type);
  17072. }
  17073. }
  17074. validatePropTypes(element);
  17075. return element;
  17076. },
  17077. createFactory: function (type) {
  17078. var validatedFactory = ReactElementValidator.createElement.bind(null, type);
  17079. // Legacy hook TODO: Warn if this is accessed
  17080. validatedFactory.type = type;
  17081. if (process.env.NODE_ENV !== 'production') {
  17082. if (canDefineProperty) {
  17083. Object.defineProperty(validatedFactory, 'type', {
  17084. enumerable: false,
  17085. get: function () {
  17086. process.env.NODE_ENV !== 'production' ? warning(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.') : undefined;
  17087. Object.defineProperty(this, 'type', {
  17088. value: type
  17089. });
  17090. return type;
  17091. }
  17092. });
  17093. }
  17094. }
  17095. return validatedFactory;
  17096. },
  17097. cloneElement: function (element, props, children) {
  17098. var newElement = ReactElement.cloneElement.apply(this, arguments);
  17099. for (var i = 2; i < arguments.length; i++) {
  17100. validateChildKeys(arguments[i], newElement.type);
  17101. }
  17102. validatePropTypes(newElement);
  17103. return newElement;
  17104. }
  17105. };
  17106. module.exports = ReactElementValidator;
  17107. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  17108. /***/ },
  17109. /* 155 */
  17110. /***/ function(module, exports) {
  17111. /**
  17112. * Copyright 2013-2015, Facebook, Inc.
  17113. * All rights reserved.
  17114. *
  17115. * This source code is licensed under the BSD-style license found in the
  17116. * LICENSE file in the root directory of this source tree. An additional grant
  17117. * of patent rights can be found in the PATENTS file in the same directory.
  17118. *
  17119. * @providesModule mapObject
  17120. */
  17121. 'use strict';
  17122. var hasOwnProperty = Object.prototype.hasOwnProperty;
  17123. /**
  17124. * Executes the provided `callback` once for each enumerable own property in the
  17125. * object and constructs a new object from the results. The `callback` is
  17126. * invoked with three arguments:
  17127. *
  17128. * - the property value
  17129. * - the property name
  17130. * - the object being traversed
  17131. *
  17132. * Properties that are added after the call to `mapObject` will not be visited
  17133. * by `callback`. If the values of existing properties are changed, the value
  17134. * passed to `callback` will be the value at the time `mapObject` visits them.
  17135. * Properties that are deleted before being visited are not visited.
  17136. *
  17137. * @grep function objectMap()
  17138. * @grep function objMap()
  17139. *
  17140. * @param {?object} object
  17141. * @param {function} callback
  17142. * @param {*} context
  17143. * @return {?object}
  17144. */
  17145. function mapObject(object, callback, context) {
  17146. if (!object) {
  17147. return null;
  17148. }
  17149. var result = {};
  17150. for (var name in object) {
  17151. if (hasOwnProperty.call(object, name)) {
  17152. result[name] = callback.call(context, object[name], name, object);
  17153. }
  17154. }
  17155. return result;
  17156. }
  17157. module.exports = mapObject;
  17158. /***/ },
  17159. /* 156 */
  17160. /***/ function(module, exports, __webpack_require__) {
  17161. /* WEBPACK VAR INJECTION */(function(process) {/**
  17162. * Copyright 2013-2015, Facebook, Inc.
  17163. * All rights reserved.
  17164. *
  17165. * This source code is licensed under the BSD-style license found in the
  17166. * LICENSE file in the root directory of this source tree. An additional grant
  17167. * of patent rights can be found in the PATENTS file in the same directory.
  17168. *
  17169. * @providesModule onlyChild
  17170. */
  17171. 'use strict';
  17172. var ReactElement = __webpack_require__(42);
  17173. var invariant = __webpack_require__(13);
  17174. /**
  17175. * Returns the first child in a collection of children and verifies that there
  17176. * is only one child in the collection. The current implementation of this
  17177. * function assumes that a single child gets passed without a wrapper, but the
  17178. * purpose of this helper function is to abstract away the particular structure
  17179. * of children.
  17180. *
  17181. * @param {?object} children Child collection structure.
  17182. * @return {ReactComponent} The first and only `ReactComponent` contained in the
  17183. * structure.
  17184. */
  17185. function onlyChild(children) {
  17186. !ReactElement.isValidElement(children) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'onlyChild must be passed a children with exactly one child.') : invariant(false) : undefined;
  17187. return children;
  17188. }
  17189. module.exports = onlyChild;
  17190. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  17191. /***/ },
  17192. /* 157 */
  17193. /***/ function(module, exports, __webpack_require__) {
  17194. /* WEBPACK VAR INJECTION */(function(process) {/**
  17195. * Copyright 2013-2015, Facebook, Inc.
  17196. * All rights reserved.
  17197. *
  17198. * This source code is licensed under the BSD-style license found in the
  17199. * LICENSE file in the root directory of this source tree. An additional grant
  17200. * of patent rights can be found in the PATENTS file in the same directory.
  17201. *
  17202. * @providesModule deprecated
  17203. */
  17204. 'use strict';
  17205. var assign = __webpack_require__(39);
  17206. var warning = __webpack_require__(25);
  17207. /**
  17208. * This will log a single deprecation notice per function and forward the call
  17209. * on to the new API.
  17210. *
  17211. * @param {string} fnName The name of the function
  17212. * @param {string} newModule The module that fn will exist in
  17213. * @param {string} newPackage The module that fn will exist in
  17214. * @param {*} ctx The context this forwarded call should run in
  17215. * @param {function} fn The function to forward on to
  17216. * @return {function} The function that will warn once and then call fn
  17217. */
  17218. function deprecated(fnName, newModule, newPackage, ctx, fn) {
  17219. var warned = false;
  17220. if (process.env.NODE_ENV !== 'production') {
  17221. var newFn = function () {
  17222. process.env.NODE_ENV !== 'production' ? warning(warned,
  17223. // Require examples in this string must be split to prevent React's
  17224. // build tools from mistaking them for real requires.
  17225. // Otherwise the build tools will attempt to build a '%s' module.
  17226. 'React.%s is deprecated. Please use %s.%s from require' + '(\'%s\') ' + 'instead.', fnName, newModule, fnName, newPackage) : undefined;
  17227. warned = true;
  17228. return fn.apply(ctx, arguments);
  17229. };
  17230. // We need to make sure all properties of the original fn are copied over.
  17231. // In particular, this is needed to support PropTypes
  17232. return assign(newFn, fn);
  17233. }
  17234. return fn;
  17235. }
  17236. module.exports = deprecated;
  17237. /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(4)))
  17238. /***/ },
  17239. /* 158 */
  17240. /***/ function(module, exports, __webpack_require__) {
  17241. 'use strict';
  17242. module.exports = __webpack_require__(3);
  17243. /***/ },
  17244. /* 159 */
  17245. /***/ function(module, exports, __webpack_require__) {
  17246. var React = __webpack_require__(1);
  17247. var ReactDOM = __webpack_require__(158);
  17248. var SimpleMDEReact = __webpack_require__(160);
  17249. var Editor = __webpack_require__(183);
  17250. let counter = 1;
  17251. module.exports = React.createClass({
  17252. displayName: 'exports',
  17253. getInitialState() {
  17254. return {
  17255. textValue1: "I am the initial value. Erase me, or try the button above.",
  17256. textValue2: "Focus this text area and then use the Up and Down arrow keys to see the `extraKeys` prop in action"
  17257. };
  17258. },
  17259. extraKeys() {
  17260. return {
  17261. Up: function (cm) {
  17262. cm.replaceSelection(" surprise. ");
  17263. },
  17264. Down: function (cm) {
  17265. cm.replaceSelection(" surprise again! ");
  17266. }
  17267. };
  17268. },
  17269. handleChange1(value) {
  17270. this.setState({
  17271. textValue1: value
  17272. });
  17273. },
  17274. handleChange2(value) {
  17275. this.setState({
  17276. textValue2: value
  17277. });
  17278. },
  17279. handleTextChange() {
  17280. this.setState({
  17281. textValue1: `Changing text by setting new state. ${counter++}`
  17282. });
  17283. },
  17284. render() {
  17285. return React.createElement(
  17286. 'div',
  17287. { className: 'container container-narrow' },
  17288. React.createElement(
  17289. 'div',
  17290. { className: 'page-header' },
  17291. React.createElement(
  17292. 'h1',
  17293. null,
  17294. React.createElement(
  17295. 'a',
  17296. { href: 'https://github.com/benrlodge/react-simplemde-editor' },
  17297. 'react-simplemde-editor'
  17298. )
  17299. ),
  17300. React.createElement(
  17301. 'p',
  17302. { className: 'lead' },
  17303. 'A React.js wrapper for ',
  17304. React.createElement(
  17305. 'a',
  17306. { href: 'https://github.com/NextStepWebs/simplemde-markdown-editor' },
  17307. 'simplemde-markdown-editor'
  17308. ),
  17309. '.'
  17310. )
  17311. ),
  17312. React.createElement(
  17313. 'button',
  17314. { style: { display: "inline-block", margin: "10px 0" }, onClick: this.handleTextChange },
  17315. 'Click me to update the textValue outside of the editor'
  17316. ),
  17317. React.createElement(Editor, {
  17318. label: 'Markdown Editor',
  17319. value: this.state.textValue1,
  17320. handleEditorChange: this.handleChange1
  17321. }),
  17322. React.createElement('hr', null),
  17323. React.createElement(Editor, {
  17324. value: this.state.textValue2,
  17325. handleEditorChange: this.handleChange2,
  17326. extraKeys: this.extraKeys()
  17327. })
  17328. );
  17329. }
  17330. });
  17331. /***/ },
  17332. /* 160 */
  17333. /***/ function(module, exports, __webpack_require__) {
  17334. const React = __webpack_require__(1);
  17335. const generateId = __webpack_require__(161);
  17336. const NOOP = __webpack_require__(162);
  17337. module.exports = React.createClass({
  17338. displayName: 'exports',
  17339. getInitialState: function () {
  17340. return {
  17341. keyChange: false
  17342. };
  17343. },
  17344. getDefaultProps: function () {
  17345. return {
  17346. onChange: NOOP,
  17347. options: {}
  17348. };
  17349. },
  17350. componentWillMount: function () {
  17351. const id = this.props.id;
  17352. if (id) {
  17353. this.id = id;
  17354. } else {
  17355. this.id = generateId();
  17356. }
  17357. },
  17358. componentDidMount: function () {
  17359. this.createEditor();
  17360. this.addEvents();
  17361. this.addExtraKeys();
  17362. },
  17363. componentWillReceiveProps: function (nextProps) {
  17364. if (!this.state.keyChange) {
  17365. this.simplemde.value(nextProps.value);
  17366. }
  17367. this.setState({
  17368. keyChange: false
  17369. });
  17370. },
  17371. componentWillUnmount: function () {
  17372. this.removeEvents();
  17373. },
  17374. createEditor: function () {
  17375. const SimpleMDE = __webpack_require__(163);
  17376. const initialOptions = {
  17377. element: document.getElementById(this.id),
  17378. initialValue: this.props.value
  17379. };
  17380. const allOptions = Object.assign({}, initialOptions, this.props.options);
  17381. this.simplemde = new SimpleMDE(allOptions);
  17382. },
  17383. eventWrapper: function () {
  17384. this.setState({
  17385. keyChange: true
  17386. });
  17387. this.props.onChange(this.simplemde.value());
  17388. },
  17389. removeEvents: function () {
  17390. this.editorEl.removeEventListener('keyup', this.eventWrapper);
  17391. this.editorToolbarEl && this.editorToolbarEl.removeEventListener('click', this.eventWrapper);
  17392. },
  17393. addEvents: function () {
  17394. const wrapperId = `${this.id}-wrapper`;
  17395. const wrapperEl = document.getElementById(`${wrapperId}`);
  17396. this.editorEl = wrapperEl.getElementsByClassName('CodeMirror')[0];
  17397. this.editorToolbarEl = wrapperEl.getElementsByClassName('editor-toolbar')[0];
  17398. this.editorEl.addEventListener('keyup', this.eventWrapper);
  17399. this.editorToolbarEl && this.editorToolbarEl.addEventListener('click', this.eventWrapper);
  17400. },
  17401. addExtraKeys: function () {
  17402. // https://codemirror.net/doc/manual.html#option_extraKeys
  17403. if (this.props.extraKeys) {
  17404. this.simplemde.codemirror.setOption('extraKeys', this.props.extraKeys);
  17405. }
  17406. },
  17407. render: function () {
  17408. const textarea = React.createElement('textarea', { id: this.id });
  17409. const label = this.props.label ? React.createElement('label', { htmlFor: this.id }, [this.props.label]) : false;
  17410. return React.createElement('div', { id: `${this.id}-wrapper`, className: this.props.className }, [label, textarea]);
  17411. }
  17412. });
  17413. /***/ },
  17414. /* 161 */
  17415. /***/ function(module, exports) {
  17416. let _id = 0;
  17417. module.exports = function generateId() {
  17418. return `simplepostmd-editor-${++_id}`;
  17419. };
  17420. /***/ },
  17421. /* 162 */
  17422. /***/ function(module, exports) {
  17423. module.exports = function () {};
  17424. /***/ },
  17425. /* 163 */
  17426. /***/ function(module, exports, __webpack_require__) {
  17427. /*global require,module*/
  17428. "use strict";
  17429. var CodeMirror = __webpack_require__(164);
  17430. __webpack_require__(165);
  17431. __webpack_require__(166);
  17432. __webpack_require__(167);
  17433. __webpack_require__(168);
  17434. __webpack_require__(171);
  17435. __webpack_require__(172);
  17436. __webpack_require__(173);
  17437. __webpack_require__(174);
  17438. __webpack_require__(169);
  17439. var CodeMirrorSpellChecker = __webpack_require__(175);
  17440. var marked = __webpack_require__(182);
  17441. // Some variables
  17442. var isMac = /Mac/.test(navigator.platform);
  17443. // Mapping of actions that can be bound to keyboard shortcuts or toolbar buttons
  17444. var bindings = {
  17445. "toggleBold": toggleBold,
  17446. "toggleItalic": toggleItalic,
  17447. "drawLink": drawLink,
  17448. "toggleHeadingSmaller": toggleHeadingSmaller,
  17449. "toggleHeadingBigger": toggleHeadingBigger,
  17450. "drawImage": drawImage,
  17451. "toggleBlockquote": toggleBlockquote,
  17452. "toggleOrderedList": toggleOrderedList,
  17453. "toggleUnorderedList": toggleUnorderedList,
  17454. "toggleCodeBlock": toggleCodeBlock,
  17455. "togglePreview": togglePreview,
  17456. "toggleStrikethrough": toggleStrikethrough,
  17457. "toggleHeading1": toggleHeading1,
  17458. "toggleHeading2": toggleHeading2,
  17459. "toggleHeading3": toggleHeading3,
  17460. "cleanBlock": cleanBlock,
  17461. "drawTable": drawTable,
  17462. "drawHorizontalRule": drawHorizontalRule,
  17463. "undo": undo,
  17464. "redo": redo,
  17465. "toggleSideBySide": toggleSideBySide,
  17466. "toggleFullScreen": toggleFullScreen
  17467. };
  17468. var shortcuts = {
  17469. "toggleBold": "Cmd-B",
  17470. "toggleItalic": "Cmd-I",
  17471. "drawLink": "Cmd-K",
  17472. "toggleHeadingSmaller": "Cmd-H",
  17473. "toggleHeadingBigger": "Shift-Cmd-H",
  17474. "cleanBlock": "Cmd-E",
  17475. "drawImage": "Cmd-Alt-I",
  17476. "toggleBlockquote": "Cmd-'",
  17477. "toggleOrderedList": "Cmd-Alt-L",
  17478. "toggleUnorderedList": "Cmd-L",
  17479. "toggleCodeBlock": "Cmd-Alt-C",
  17480. "togglePreview": "Cmd-P",
  17481. "toggleSideBySide": "F9",
  17482. "toggleFullScreen": "F11"
  17483. };
  17484. var getBindingName = function(f) {
  17485. for(var key in bindings) {
  17486. if(bindings[key] === f) {
  17487. return key;
  17488. }
  17489. }
  17490. return null;
  17491. };
  17492. var isMobile = function() {
  17493. var check = false;
  17494. (function(a) {
  17495. if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(a) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0, 4))) check = true;
  17496. })(navigator.userAgent || navigator.vendor || window.opera);
  17497. return check;
  17498. };
  17499. /**
  17500. * Fix shortcut. Mac use Command, others use Ctrl.
  17501. */
  17502. function fixShortcut(name) {
  17503. if(isMac) {
  17504. name = name.replace("Ctrl", "Cmd");
  17505. } else {
  17506. name = name.replace("Cmd", "Ctrl");
  17507. }
  17508. return name;
  17509. }
  17510. /**
  17511. * Create icon element for toolbar.
  17512. */
  17513. function createIcon(options, enableTooltips, shortcuts) {
  17514. options = options || {};
  17515. var el = document.createElement("a");
  17516. enableTooltips = (enableTooltips == undefined) ? true : enableTooltips;
  17517. if(options.title && enableTooltips) {
  17518. el.title = createTootlip(options.title, options.action, shortcuts);
  17519. if(isMac) {
  17520. el.title = el.title.replace("Ctrl", "⌘");
  17521. el.title = el.title.replace("Alt", "⌥");
  17522. }
  17523. }
  17524. el.tabIndex = -1;
  17525. el.className = options.className;
  17526. return el;
  17527. }
  17528. function createSep() {
  17529. var el = document.createElement("i");
  17530. el.className = "separator";
  17531. el.innerHTML = "|";
  17532. return el;
  17533. }
  17534. function createTootlip(title, action, shortcuts) {
  17535. var actionName;
  17536. var tooltip = title;
  17537. if(action) {
  17538. actionName = getBindingName(action);
  17539. if(shortcuts[actionName]) {
  17540. tooltip += " (" + fixShortcut(shortcuts[actionName]) + ")";
  17541. }
  17542. }
  17543. return tooltip;
  17544. }
  17545. /**
  17546. * The state of CodeMirror at the given position.
  17547. */
  17548. function getState(cm, pos) {
  17549. pos = pos || cm.getCursor("start");
  17550. var stat = cm.getTokenAt(pos);
  17551. if(!stat.type) return {};
  17552. var types = stat.type.split(" ");
  17553. var ret = {},
  17554. data, text;
  17555. for(var i = 0; i < types.length; i++) {
  17556. data = types[i];
  17557. if(data === "strong") {
  17558. ret.bold = true;
  17559. } else if(data === "variable-2") {
  17560. text = cm.getLine(pos.line);
  17561. if(/^\s*\d+\.\s/.test(text)) {
  17562. ret["ordered-list"] = true;
  17563. } else {
  17564. ret["unordered-list"] = true;
  17565. }
  17566. } else if(data === "atom") {
  17567. ret.quote = true;
  17568. } else if(data === "em") {
  17569. ret.italic = true;
  17570. } else if(data === "quote") {
  17571. ret.quote = true;
  17572. } else if(data === "strikethrough") {
  17573. ret.strikethrough = true;
  17574. } else if(data === "comment") {
  17575. ret.code = true;
  17576. } else if(data === "link") {
  17577. ret.link = true;
  17578. } else if(data === "tag") {
  17579. ret.image = true;
  17580. } else if(data.match(/^header(\-[1-6])?$/)) {
  17581. ret[data.replace("header", "heading")] = true;
  17582. }
  17583. }
  17584. return ret;
  17585. }
  17586. // Saved overflow setting
  17587. var saved_overflow = "";
  17588. /**
  17589. * Toggle full screen of the editor.
  17590. */
  17591. function toggleFullScreen(editor) {
  17592. // Set fullscreen
  17593. var cm = editor.codemirror;
  17594. cm.setOption("fullScreen", !cm.getOption("fullScreen"));
  17595. // Prevent scrolling on body during fullscreen active
  17596. if(cm.getOption("fullScreen")) {
  17597. saved_overflow = document.body.style.overflow;
  17598. document.body.style.overflow = "hidden";
  17599. } else {
  17600. document.body.style.overflow = saved_overflow;
  17601. }
  17602. // Update toolbar class
  17603. var wrap = cm.getWrapperElement();
  17604. if(!/fullscreen/.test(wrap.previousSibling.className)) {
  17605. wrap.previousSibling.className += " fullscreen";
  17606. } else {
  17607. wrap.previousSibling.className = wrap.previousSibling.className.replace(/\s*fullscreen\b/, "");
  17608. }
  17609. // Update toolbar button
  17610. var toolbarButton = editor.toolbarElements.fullscreen;
  17611. if(!/active/.test(toolbarButton.className)) {
  17612. toolbarButton.className += " active";
  17613. } else {
  17614. toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, "");
  17615. }
  17616. // Hide side by side if needed
  17617. var sidebyside = cm.getWrapperElement().nextSibling;
  17618. if(/editor-preview-active-side/.test(sidebyside.className))
  17619. toggleSideBySide(editor);
  17620. }
  17621. /**
  17622. * Action for toggling bold.
  17623. */
  17624. function toggleBold(editor) {
  17625. _toggleBlock(editor, "bold", editor.options.blockStyles.bold);
  17626. }
  17627. /**
  17628. * Action for toggling italic.
  17629. */
  17630. function toggleItalic(editor) {
  17631. _toggleBlock(editor, "italic", editor.options.blockStyles.italic);
  17632. }
  17633. /**
  17634. * Action for toggling strikethrough.
  17635. */
  17636. function toggleStrikethrough(editor) {
  17637. _toggleBlock(editor, "strikethrough", "~~");
  17638. }
  17639. /**
  17640. * Action for toggling code block.
  17641. */
  17642. function toggleCodeBlock(editor) {
  17643. var fenceCharsToInsert = editor.options.blockStyles.code;
  17644. function fencing_line(line) {
  17645. /* return true, if this is a ``` or ~~~ line */
  17646. if(typeof line !== "object") {
  17647. throw "fencing_line() takes a 'line' object (not a line number, or line text). Got: " + typeof line + ": " + line;
  17648. }
  17649. return line.styles && line.styles[2] && line.styles[2].indexOf("formatting-code-block") !== -1;
  17650. }
  17651. function token_state(token) {
  17652. // base goes an extra level deep when mode backdrops are used, e.g. spellchecker on
  17653. return token.state.base.base || token.state.base;
  17654. }
  17655. function code_type(cm, line_num, line, firstTok, lastTok) {
  17656. /*
  17657. * Return "single", "indented", "fenced" or false
  17658. *
  17659. * cm and line_num are required. Others are optional for efficiency
  17660. * To check in the middle of a line, pass in firstTok yourself.
  17661. */
  17662. line = line || cm.getLineHandle(line_num);
  17663. firstTok = firstTok || cm.getTokenAt({
  17664. line: line_num,
  17665. ch: 1
  17666. });
  17667. lastTok = lastTok || (!!line.text && cm.getTokenAt({
  17668. line: line_num,
  17669. ch: line.text.length - 1
  17670. }));
  17671. var types = firstTok.type ? firstTok.type.split(" ") : [];
  17672. if(lastTok && token_state(lastTok).indentedCode) {
  17673. // have to check last char, since first chars of first line aren"t marked as indented
  17674. return "indented";
  17675. } else if(types.indexOf("comment") === -1) {
  17676. // has to be after "indented" check, since first chars of first indented line aren"t marked as such
  17677. return false;
  17678. } else if(token_state(firstTok).fencedChars || token_state(lastTok).fencedChars || fencing_line(line)) {
  17679. return "fenced";
  17680. } else {
  17681. return "single";
  17682. }
  17683. }
  17684. function insertFencingAtSelection(cm, cur_start, cur_end, fenceCharsToInsert) {
  17685. var start_line_sel = cur_start.line + 1,
  17686. end_line_sel = cur_end.line + 1,
  17687. sel_multi = cur_start.line !== cur_end.line,
  17688. repl_start = fenceCharsToInsert + "\n",
  17689. repl_end = "\n" + fenceCharsToInsert;
  17690. if(sel_multi) {
  17691. end_line_sel++;
  17692. }
  17693. // handle last char including \n or not
  17694. if(sel_multi && cur_end.ch === 0) {
  17695. repl_end = fenceCharsToInsert + "\n";
  17696. end_line_sel--;
  17697. }
  17698. _replaceSelection(cm, false, [repl_start, repl_end]);
  17699. cm.setSelection({
  17700. line: start_line_sel,
  17701. ch: 0
  17702. }, {
  17703. line: end_line_sel,
  17704. ch: 0
  17705. });
  17706. }
  17707. var cm = editor.codemirror,
  17708. cur_start = cm.getCursor("start"),
  17709. cur_end = cm.getCursor("end"),
  17710. tok = cm.getTokenAt({
  17711. line: cur_start.line,
  17712. ch: cur_start.ch || 1
  17713. }), // avoid ch 0 which is a cursor pos but not token
  17714. line = cm.getLineHandle(cur_start.line),
  17715. is_code = code_type(cm, cur_start.line, line, tok);
  17716. var block_start, block_end, lineCount;
  17717. if(is_code === "single") {
  17718. // similar to some SimpleMDE _toggleBlock logic
  17719. var start = line.text.slice(0, cur_start.ch).replace("`", ""),
  17720. end = line.text.slice(cur_start.ch).replace("`", "");
  17721. cm.replaceRange(start + end, {
  17722. line: cur_start.line,
  17723. ch: 0
  17724. }, {
  17725. line: cur_start.line,
  17726. ch: 99999999999999
  17727. });
  17728. cur_start.ch--;
  17729. if(cur_start !== cur_end) {
  17730. cur_end.ch--;
  17731. }
  17732. cm.setSelection(cur_start, cur_end);
  17733. cm.focus();
  17734. } else if(is_code === "fenced") {
  17735. if(cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch) {
  17736. // use selection
  17737. // find the fenced line so we know what type it is (tilde, backticks, number of them)
  17738. for(block_start = cur_start.line; block_start >= 0; block_start--) {
  17739. line = cm.getLineHandle(block_start);
  17740. if(fencing_line(line)) {
  17741. break;
  17742. }
  17743. }
  17744. var fencedTok = cm.getTokenAt({
  17745. line: block_start,
  17746. ch: 1
  17747. });
  17748. var fence_chars = token_state(fencedTok).fencedChars;
  17749. var start_text, start_line;
  17750. var end_text, end_line;
  17751. // check for selection going up against fenced lines, in which case we don't want to add more fencing
  17752. if(fencing_line(cm.getLineHandle(cur_start.line))) {
  17753. start_text = "";
  17754. start_line = cur_start.line;
  17755. } else if(fencing_line(cm.getLineHandle(cur_start.line - 1))) {
  17756. start_text = "";
  17757. start_line = cur_start.line - 1;
  17758. } else {
  17759. start_text = fence_chars + "\n";
  17760. start_line = cur_start.line;
  17761. }
  17762. if(fencing_line(cm.getLineHandle(cur_end.line))) {
  17763. end_text = "";
  17764. end_line = cur_end.line;
  17765. if(cur_end.ch === 0) {
  17766. end_line += 1;
  17767. }
  17768. } else if(cur_end.ch !== 0 && fencing_line(cm.getLineHandle(cur_end.line + 1))) {
  17769. end_text = "";
  17770. end_line = cur_end.line + 1;
  17771. } else {
  17772. end_text = fence_chars + "\n";
  17773. end_line = cur_end.line + 1;
  17774. }
  17775. if(cur_end.ch === 0) {
  17776. // full last line selected, putting cursor at beginning of next
  17777. end_line -= 1;
  17778. }
  17779. cm.operation(function() {
  17780. // end line first, so that line numbers don't change
  17781. cm.replaceRange(end_text, {
  17782. line: end_line,
  17783. ch: 0
  17784. }, {
  17785. line: end_line + (end_text ? 0 : 1),
  17786. ch: 0
  17787. });
  17788. cm.replaceRange(start_text, {
  17789. line: start_line,
  17790. ch: 0
  17791. }, {
  17792. line: start_line + (start_text ? 0 : 1),
  17793. ch: 0
  17794. });
  17795. });
  17796. cm.setSelection({
  17797. line: start_line + (start_text ? 1 : 0),
  17798. ch: 0
  17799. }, {
  17800. line: end_line + (start_text ? 1 : -1),
  17801. ch: 0
  17802. });
  17803. cm.focus();
  17804. } else {
  17805. // no selection, search for ends of this fenced block
  17806. var search_from = cur_start.line;
  17807. if(fencing_line(cm.getLineHandle(cur_start.line))) { // gets a little tricky if cursor is right on a fenced line
  17808. if(code_type(cm, cur_start.line + 1) === "fenced") {
  17809. block_start = cur_start.line;
  17810. search_from = cur_start.line + 1; // for searching for "end"
  17811. } else {
  17812. block_end = cur_start.line;
  17813. search_from = cur_start.line - 1; // for searching for "start"
  17814. }
  17815. }
  17816. if(block_start === undefined) {
  17817. for(block_start = search_from; block_start >= 0; block_start--) {
  17818. line = cm.getLineHandle(block_start);
  17819. if(fencing_line(line)) {
  17820. break;
  17821. }
  17822. }
  17823. }
  17824. if(block_end === undefined) {
  17825. lineCount = cm.lineCount();
  17826. for(block_end = search_from; block_end < lineCount; block_end++) {
  17827. line = cm.getLineHandle(block_end);
  17828. if(fencing_line(line)) {
  17829. break;
  17830. }
  17831. }
  17832. }
  17833. cm.operation(function() {
  17834. cm.replaceRange("", {
  17835. line: block_start,
  17836. ch: 0
  17837. }, {
  17838. line: block_start + 1,
  17839. ch: 0
  17840. });
  17841. cm.replaceRange("", {
  17842. line: block_end - 1,
  17843. ch: 0
  17844. }, {
  17845. line: block_end,
  17846. ch: 0
  17847. });
  17848. });
  17849. cm.focus();
  17850. }
  17851. } else if(is_code === "indented") {
  17852. if(cur_start.line !== cur_end.line || cur_start.ch !== cur_end.ch) {
  17853. // use selection
  17854. block_start = cur_start.line;
  17855. block_end = cur_end.line;
  17856. if(cur_end.ch === 0) {
  17857. block_end--;
  17858. }
  17859. } else {
  17860. // no selection, search for ends of this indented block
  17861. for(block_start = cur_start.line; block_start >= 0; block_start--) {
  17862. line = cm.getLineHandle(block_start);
  17863. if(line.text.match(/^\s*$/)) {
  17864. // empty or all whitespace - keep going
  17865. continue;
  17866. } else {
  17867. if(code_type(cm, block_start, line) !== "indented") {
  17868. block_start += 1;
  17869. break;
  17870. }
  17871. }
  17872. }
  17873. lineCount = cm.lineCount();
  17874. for(block_end = cur_start.line; block_end < lineCount; block_end++) {
  17875. line = cm.getLineHandle(block_end);
  17876. if(line.text.match(/^\s*$/)) {
  17877. // empty or all whitespace - keep going
  17878. continue;
  17879. } else {
  17880. if(code_type(cm, block_end, line) !== "indented") {
  17881. block_end -= 1;
  17882. break;
  17883. }
  17884. }
  17885. }
  17886. }
  17887. // if we are going to un-indent based on a selected set of lines, and the next line is indented too, we need to
  17888. // insert a blank line so that the next line(s) continue to be indented code
  17889. var next_line = cm.getLineHandle(block_end + 1),
  17890. next_line_last_tok = next_line && cm.getTokenAt({
  17891. line: block_end + 1,
  17892. ch: next_line.text.length - 1
  17893. }),
  17894. next_line_indented = next_line_last_tok && token_state(next_line_last_tok).indentedCode;
  17895. if(next_line_indented) {
  17896. cm.replaceRange("\n", {
  17897. line: block_end + 1,
  17898. ch: 0
  17899. });
  17900. }
  17901. for(var i = block_start; i <= block_end; i++) {
  17902. cm.indentLine(i, "subtract"); // TODO: this doesn't get tracked in the history, so can't be undone :(
  17903. }
  17904. cm.focus();
  17905. } else {
  17906. // insert code formatting
  17907. var no_sel_and_starting_of_line = (cur_start.line === cur_end.line && cur_start.ch === cur_end.ch && cur_start.ch === 0);
  17908. var sel_multi = cur_start.line !== cur_end.line;
  17909. if(no_sel_and_starting_of_line || sel_multi) {
  17910. insertFencingAtSelection(cm, cur_start, cur_end, fenceCharsToInsert);
  17911. } else {
  17912. _replaceSelection(cm, false, ["`", "`"]);
  17913. }
  17914. }
  17915. }
  17916. /**
  17917. * Action for toggling blockquote.
  17918. */
  17919. function toggleBlockquote(editor) {
  17920. var cm = editor.codemirror;
  17921. _toggleLine(cm, "quote");
  17922. }
  17923. /**
  17924. * Action for toggling heading size: normal -> h1 -> h2 -> h3 -> h4 -> h5 -> h6 -> normal
  17925. */
  17926. function toggleHeadingSmaller(editor) {
  17927. var cm = editor.codemirror;
  17928. _toggleHeading(cm, "smaller");
  17929. }
  17930. /**
  17931. * Action for toggling heading size: normal -> h6 -> h5 -> h4 -> h3 -> h2 -> h1 -> normal
  17932. */
  17933. function toggleHeadingBigger(editor) {
  17934. var cm = editor.codemirror;
  17935. _toggleHeading(cm, "bigger");
  17936. }
  17937. /**
  17938. * Action for toggling heading size 1
  17939. */
  17940. function toggleHeading1(editor) {
  17941. var cm = editor.codemirror;
  17942. _toggleHeading(cm, undefined, 1);
  17943. }
  17944. /**
  17945. * Action for toggling heading size 2
  17946. */
  17947. function toggleHeading2(editor) {
  17948. var cm = editor.codemirror;
  17949. _toggleHeading(cm, undefined, 2);
  17950. }
  17951. /**
  17952. * Action for toggling heading size 3
  17953. */
  17954. function toggleHeading3(editor) {
  17955. var cm = editor.codemirror;
  17956. _toggleHeading(cm, undefined, 3);
  17957. }
  17958. /**
  17959. * Action for toggling ul.
  17960. */
  17961. function toggleUnorderedList(editor) {
  17962. var cm = editor.codemirror;
  17963. _toggleLine(cm, "unordered-list");
  17964. }
  17965. /**
  17966. * Action for toggling ol.
  17967. */
  17968. function toggleOrderedList(editor) {
  17969. var cm = editor.codemirror;
  17970. _toggleLine(cm, "ordered-list");
  17971. }
  17972. /**
  17973. * Action for clean block (remove headline, list, blockquote code, markers)
  17974. */
  17975. function cleanBlock(editor) {
  17976. var cm = editor.codemirror;
  17977. _cleanBlock(cm);
  17978. }
  17979. /**
  17980. * Action for drawing a link.
  17981. */
  17982. function drawLink(editor) {
  17983. var cm = editor.codemirror;
  17984. var stat = getState(cm);
  17985. var options = editor.options;
  17986. var url = "http://";
  17987. if(options.promptURLs) {
  17988. url = prompt(options.promptTexts.link);
  17989. if(!url) {
  17990. return false;
  17991. }
  17992. }
  17993. _replaceSelection(cm, stat.link, options.insertTexts.link, url);
  17994. }
  17995. /**
  17996. * Action for drawing an img.
  17997. */
  17998. function drawImage(editor) {
  17999. var cm = editor.codemirror;
  18000. var stat = getState(cm);
  18001. var options = editor.options;
  18002. var url = "http://";
  18003. if(options.promptURLs) {
  18004. url = prompt(options.promptTexts.image);
  18005. if(!url) {
  18006. return false;
  18007. }
  18008. }
  18009. _replaceSelection(cm, stat.image, options.insertTexts.image, url);
  18010. }
  18011. /**
  18012. * Action for drawing a table.
  18013. */
  18014. function drawTable(editor) {
  18015. var cm = editor.codemirror;
  18016. var stat = getState(cm);
  18017. var options = editor.options;
  18018. _replaceSelection(cm, stat.table, options.insertTexts.table);
  18019. }
  18020. /**
  18021. * Action for drawing a horizontal rule.
  18022. */
  18023. function drawHorizontalRule(editor) {
  18024. var cm = editor.codemirror;
  18025. var stat = getState(cm);
  18026. var options = editor.options;
  18027. _replaceSelection(cm, stat.image, options.insertTexts.horizontalRule);
  18028. }
  18029. /**
  18030. * Undo action.
  18031. */
  18032. function undo(editor) {
  18033. var cm = editor.codemirror;
  18034. cm.undo();
  18035. cm.focus();
  18036. }
  18037. /**
  18038. * Redo action.
  18039. */
  18040. function redo(editor) {
  18041. var cm = editor.codemirror;
  18042. cm.redo();
  18043. cm.focus();
  18044. }
  18045. /**
  18046. * Toggle side by side preview
  18047. */
  18048. function toggleSideBySide(editor) {
  18049. var cm = editor.codemirror;
  18050. var wrapper = cm.getWrapperElement();
  18051. var preview = wrapper.nextSibling;
  18052. var toolbarButton = editor.toolbarElements["side-by-side"];
  18053. var useSideBySideListener = false;
  18054. if(/editor-preview-active-side/.test(preview.className)) {
  18055. preview.className = preview.className.replace(
  18056. /\s*editor-preview-active-side\s*/g, ""
  18057. );
  18058. toolbarButton.className = toolbarButton.className.replace(/\s*active\s*/g, "");
  18059. wrapper.className = wrapper.className.replace(/\s*CodeMirror-sided\s*/g, " ");
  18060. } else {
  18061. // When the preview button is clicked for the first time,
  18062. // give some time for the transition from editor.css to fire and the view to slide from right to left,
  18063. // instead of just appearing.
  18064. setTimeout(function() {
  18065. if(!cm.getOption("fullScreen"))
  18066. toggleFullScreen(editor);
  18067. preview.className += " editor-preview-active-side";
  18068. }, 1);
  18069. toolbarButton.className += " active";
  18070. wrapper.className += " CodeMirror-sided";
  18071. useSideBySideListener = true;
  18072. }
  18073. // Hide normal preview if active
  18074. var previewNormal = wrapper.lastChild;
  18075. if(/editor-preview-active/.test(previewNormal.className)) {
  18076. previewNormal.className = previewNormal.className.replace(
  18077. /\s*editor-preview-active\s*/g, ""
  18078. );
  18079. var toolbar = editor.toolbarElements.preview;
  18080. var toolbar_div = wrapper.previousSibling;
  18081. toolbar.className = toolbar.className.replace(/\s*active\s*/g, "");
  18082. toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
  18083. }
  18084. var sideBySideRenderingFunction = function() {
  18085. preview.innerHTML = editor.options.previewRender(editor.value(), preview);
  18086. };
  18087. if(!cm.sideBySideRenderingFunction) {
  18088. cm.sideBySideRenderingFunction = sideBySideRenderingFunction;
  18089. }
  18090. if(useSideBySideListener) {
  18091. preview.innerHTML = editor.options.previewRender(editor.value(), preview);
  18092. cm.on("update", cm.sideBySideRenderingFunction);
  18093. } else {
  18094. cm.off("update", cm.sideBySideRenderingFunction);
  18095. }
  18096. // Refresh to fix selection being off (#309)
  18097. cm.refresh();
  18098. }
  18099. /**
  18100. * Preview action.
  18101. */
  18102. function togglePreview(editor) {
  18103. var cm = editor.codemirror;
  18104. var wrapper = cm.getWrapperElement();
  18105. var toolbar_div = wrapper.previousSibling;
  18106. var toolbar = editor.options.toolbar ? editor.toolbarElements.preview : false;
  18107. var preview = wrapper.lastChild;
  18108. if(!preview || !/editor-preview/.test(preview.className)) {
  18109. preview = document.createElement("div");
  18110. preview.className = "editor-preview";
  18111. wrapper.appendChild(preview);
  18112. }
  18113. if(/editor-preview-active/.test(preview.className)) {
  18114. preview.className = preview.className.replace(
  18115. /\s*editor-preview-active\s*/g, ""
  18116. );
  18117. if(toolbar) {
  18118. toolbar.className = toolbar.className.replace(/\s*active\s*/g, "");
  18119. toolbar_div.className = toolbar_div.className.replace(/\s*disabled-for-preview*/g, "");
  18120. }
  18121. } else {
  18122. // When the preview button is clicked for the first time,
  18123. // give some time for the transition from editor.css to fire and the view to slide from right to left,
  18124. // instead of just appearing.
  18125. setTimeout(function() {
  18126. preview.className += " editor-preview-active";
  18127. }, 1);
  18128. if(toolbar) {
  18129. toolbar.className += " active";
  18130. toolbar_div.className += " disabled-for-preview";
  18131. }
  18132. }
  18133. preview.innerHTML = editor.options.previewRender(editor.value(), preview);
  18134. // Turn off side by side if needed
  18135. var sidebyside = cm.getWrapperElement().nextSibling;
  18136. if(/editor-preview-active-side/.test(sidebyside.className))
  18137. toggleSideBySide(editor);
  18138. }
  18139. function _replaceSelection(cm, active, startEnd, url) {
  18140. if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
  18141. return;
  18142. var text;
  18143. var start = startEnd[0];
  18144. var end = startEnd[1];
  18145. var startPoint = cm.getCursor("start");
  18146. var endPoint = cm.getCursor("end");
  18147. if(url) {
  18148. end = end.replace("#url#", url);
  18149. }
  18150. if(active) {
  18151. text = cm.getLine(startPoint.line);
  18152. start = text.slice(0, startPoint.ch);
  18153. end = text.slice(startPoint.ch);
  18154. cm.replaceRange(start + end, {
  18155. line: startPoint.line,
  18156. ch: 0
  18157. });
  18158. } else {
  18159. text = cm.getSelection();
  18160. cm.replaceSelection(start + text + end);
  18161. startPoint.ch += start.length;
  18162. if(startPoint !== endPoint) {
  18163. endPoint.ch += start.length;
  18164. }
  18165. }
  18166. cm.setSelection(startPoint, endPoint);
  18167. cm.focus();
  18168. }
  18169. function _toggleHeading(cm, direction, size) {
  18170. if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
  18171. return;
  18172. var startPoint = cm.getCursor("start");
  18173. var endPoint = cm.getCursor("end");
  18174. for(var i = startPoint.line; i <= endPoint.line; i++) {
  18175. (function(i) {
  18176. var text = cm.getLine(i);
  18177. var currHeadingLevel = text.search(/[^#]/);
  18178. if(direction !== undefined) {
  18179. if(currHeadingLevel <= 0) {
  18180. if(direction == "bigger") {
  18181. text = "###### " + text;
  18182. } else {
  18183. text = "# " + text;
  18184. }
  18185. } else if(currHeadingLevel == 6 && direction == "smaller") {
  18186. text = text.substr(7);
  18187. } else if(currHeadingLevel == 1 && direction == "bigger") {
  18188. text = text.substr(2);
  18189. } else {
  18190. if(direction == "bigger") {
  18191. text = text.substr(1);
  18192. } else {
  18193. text = "#" + text;
  18194. }
  18195. }
  18196. } else {
  18197. if(size == 1) {
  18198. if(currHeadingLevel <= 0) {
  18199. text = "# " + text;
  18200. } else if(currHeadingLevel == size) {
  18201. text = text.substr(currHeadingLevel + 1);
  18202. } else {
  18203. text = "# " + text.substr(currHeadingLevel + 1);
  18204. }
  18205. } else if(size == 2) {
  18206. if(currHeadingLevel <= 0) {
  18207. text = "## " + text;
  18208. } else if(currHeadingLevel == size) {
  18209. text = text.substr(currHeadingLevel + 1);
  18210. } else {
  18211. text = "## " + text.substr(currHeadingLevel + 1);
  18212. }
  18213. } else {
  18214. if(currHeadingLevel <= 0) {
  18215. text = "### " + text;
  18216. } else if(currHeadingLevel == size) {
  18217. text = text.substr(currHeadingLevel + 1);
  18218. } else {
  18219. text = "### " + text.substr(currHeadingLevel + 1);
  18220. }
  18221. }
  18222. }
  18223. cm.replaceRange(text, {
  18224. line: i,
  18225. ch: 0
  18226. }, {
  18227. line: i,
  18228. ch: 99999999999999
  18229. });
  18230. })(i);
  18231. }
  18232. cm.focus();
  18233. }
  18234. function _toggleLine(cm, name) {
  18235. if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
  18236. return;
  18237. var stat = getState(cm);
  18238. var startPoint = cm.getCursor("start");
  18239. var endPoint = cm.getCursor("end");
  18240. var repl = {
  18241. "quote": /^(\s*)\>\s+/,
  18242. "unordered-list": /^(\s*)(\*|\-|\+)\s+/,
  18243. "ordered-list": /^(\s*)\d+\.\s+/
  18244. };
  18245. var map = {
  18246. "quote": "> ",
  18247. "unordered-list": "* ",
  18248. "ordered-list": "1. "
  18249. };
  18250. for(var i = startPoint.line; i <= endPoint.line; i++) {
  18251. (function(i) {
  18252. var text = cm.getLine(i);
  18253. if(stat[name]) {
  18254. text = text.replace(repl[name], "$1");
  18255. } else {
  18256. text = map[name] + text;
  18257. }
  18258. cm.replaceRange(text, {
  18259. line: i,
  18260. ch: 0
  18261. }, {
  18262. line: i,
  18263. ch: 99999999999999
  18264. });
  18265. })(i);
  18266. }
  18267. cm.focus();
  18268. }
  18269. function _toggleBlock(editor, type, start_chars, end_chars) {
  18270. if(/editor-preview-active/.test(editor.codemirror.getWrapperElement().lastChild.className))
  18271. return;
  18272. end_chars = (typeof end_chars === "undefined") ? start_chars : end_chars;
  18273. var cm = editor.codemirror;
  18274. var stat = getState(cm);
  18275. var text;
  18276. var start = start_chars;
  18277. var end = end_chars;
  18278. var startPoint = cm.getCursor("start");
  18279. var endPoint = cm.getCursor("end");
  18280. if(stat[type]) {
  18281. text = cm.getLine(startPoint.line);
  18282. start = text.slice(0, startPoint.ch);
  18283. end = text.slice(startPoint.ch);
  18284. if(type == "bold") {
  18285. start = start.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/, "");
  18286. end = end.replace(/(\*\*|__)/, "");
  18287. } else if(type == "italic") {
  18288. start = start.replace(/(\*|_)(?![\s\S]*(\*|_))/, "");
  18289. end = end.replace(/(\*|_)/, "");
  18290. } else if(type == "strikethrough") {
  18291. start = start.replace(/(\*\*|~~)(?![\s\S]*(\*\*|~~))/, "");
  18292. end = end.replace(/(\*\*|~~)/, "");
  18293. }
  18294. cm.replaceRange(start + end, {
  18295. line: startPoint.line,
  18296. ch: 0
  18297. }, {
  18298. line: startPoint.line,
  18299. ch: 99999999999999
  18300. });
  18301. if(type == "bold" || type == "strikethrough") {
  18302. startPoint.ch -= 2;
  18303. if(startPoint !== endPoint) {
  18304. endPoint.ch -= 2;
  18305. }
  18306. } else if(type == "italic") {
  18307. startPoint.ch -= 1;
  18308. if(startPoint !== endPoint) {
  18309. endPoint.ch -= 1;
  18310. }
  18311. }
  18312. } else {
  18313. text = cm.getSelection();
  18314. if(type == "bold") {
  18315. text = text.split("**").join("");
  18316. text = text.split("__").join("");
  18317. } else if(type == "italic") {
  18318. text = text.split("*").join("");
  18319. text = text.split("_").join("");
  18320. } else if(type == "strikethrough") {
  18321. text = text.split("~~").join("");
  18322. }
  18323. cm.replaceSelection(start + text + end);
  18324. startPoint.ch += start_chars.length;
  18325. endPoint.ch = startPoint.ch + text.length;
  18326. }
  18327. cm.setSelection(startPoint, endPoint);
  18328. cm.focus();
  18329. }
  18330. function _cleanBlock(cm) {
  18331. if(/editor-preview-active/.test(cm.getWrapperElement().lastChild.className))
  18332. return;
  18333. var startPoint = cm.getCursor("start");
  18334. var endPoint = cm.getCursor("end");
  18335. var text;
  18336. for(var line = startPoint.line; line <= endPoint.line; line++) {
  18337. text = cm.getLine(line);
  18338. text = text.replace(/^[ ]*([# ]+|\*|\-|[> ]+|[0-9]+(.|\)))[ ]*/, "");
  18339. cm.replaceRange(text, {
  18340. line: line,
  18341. ch: 0
  18342. }, {
  18343. line: line,
  18344. ch: 99999999999999
  18345. });
  18346. }
  18347. }
  18348. // Merge the properties of one object into another.
  18349. function _mergeProperties(target, source) {
  18350. for(var property in source) {
  18351. if(source.hasOwnProperty(property)) {
  18352. if(source[property] instanceof Array) {
  18353. target[property] = source[property].concat(target[property] instanceof Array ? target[property] : []);
  18354. } else if(
  18355. source[property] !== null &&
  18356. typeof source[property] === "object" &&
  18357. source[property].constructor === Object
  18358. ) {
  18359. target[property] = _mergeProperties(target[property] || {}, source[property]);
  18360. } else {
  18361. target[property] = source[property];
  18362. }
  18363. }
  18364. }
  18365. return target;
  18366. }
  18367. // Merge an arbitrary number of objects into one.
  18368. function extend(target) {
  18369. for(var i = 1; i < arguments.length; i++) {
  18370. target = _mergeProperties(target, arguments[i]);
  18371. }
  18372. return target;
  18373. }
  18374. /* The right word count in respect for CJK. */
  18375. function wordCount(data) {
  18376. var pattern = /[a-zA-Z0-9_\u0392-\u03c9\u0410-\u04F9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
  18377. var m = data.match(pattern);
  18378. var count = 0;
  18379. if(m === null) return count;
  18380. for(var i = 0; i < m.length; i++) {
  18381. if(m[i].charCodeAt(0) >= 0x4E00) {
  18382. count += m[i].length;
  18383. } else {
  18384. count += 1;
  18385. }
  18386. }
  18387. return count;
  18388. }
  18389. var toolbarBuiltInButtons = {
  18390. "bold": {
  18391. name: "bold",
  18392. action: toggleBold,
  18393. className: "fa fa-bold",
  18394. title: "Bold",
  18395. default: true
  18396. },
  18397. "italic": {
  18398. name: "italic",
  18399. action: toggleItalic,
  18400. className: "fa fa-italic",
  18401. title: "Italic",
  18402. default: true
  18403. },
  18404. "strikethrough": {
  18405. name: "strikethrough",
  18406. action: toggleStrikethrough,
  18407. className: "fa fa-strikethrough",
  18408. title: "Strikethrough"
  18409. },
  18410. "heading": {
  18411. name: "heading",
  18412. action: toggleHeadingSmaller,
  18413. className: "fa fa-header",
  18414. title: "Heading",
  18415. default: true
  18416. },
  18417. "heading-smaller": {
  18418. name: "heading-smaller",
  18419. action: toggleHeadingSmaller,
  18420. className: "fa fa-header fa-header-x fa-header-smaller",
  18421. title: "Smaller Heading"
  18422. },
  18423. "heading-bigger": {
  18424. name: "heading-bigger",
  18425. action: toggleHeadingBigger,
  18426. className: "fa fa-header fa-header-x fa-header-bigger",
  18427. title: "Bigger Heading"
  18428. },
  18429. "heading-1": {
  18430. name: "heading-1",
  18431. action: toggleHeading1,
  18432. className: "fa fa-header fa-header-x fa-header-1",
  18433. title: "Big Heading"
  18434. },
  18435. "heading-2": {
  18436. name: "heading-2",
  18437. action: toggleHeading2,
  18438. className: "fa fa-header fa-header-x fa-header-2",
  18439. title: "Medium Heading"
  18440. },
  18441. "heading-3": {
  18442. name: "heading-3",
  18443. action: toggleHeading3,
  18444. className: "fa fa-header fa-header-x fa-header-3",
  18445. title: "Small Heading"
  18446. },
  18447. "separator-1": {
  18448. name: "separator-1"
  18449. },
  18450. "code": {
  18451. name: "code",
  18452. action: toggleCodeBlock,
  18453. className: "fa fa-code",
  18454. title: "Code"
  18455. },
  18456. "quote": {
  18457. name: "quote",
  18458. action: toggleBlockquote,
  18459. className: "fa fa-quote-left",
  18460. title: "Quote",
  18461. default: true
  18462. },
  18463. "unordered-list": {
  18464. name: "unordered-list",
  18465. action: toggleUnorderedList,
  18466. className: "fa fa-list-ul",
  18467. title: "Generic List",
  18468. default: true
  18469. },
  18470. "ordered-list": {
  18471. name: "ordered-list",
  18472. action: toggleOrderedList,
  18473. className: "fa fa-list-ol",
  18474. title: "Numbered List",
  18475. default: true
  18476. },
  18477. "clean-block": {
  18478. name: "clean-block",
  18479. action: cleanBlock,
  18480. className: "fa fa-eraser fa-clean-block",
  18481. title: "Clean block"
  18482. },
  18483. "separator-2": {
  18484. name: "separator-2"
  18485. },
  18486. "link": {
  18487. name: "link",
  18488. action: drawLink,
  18489. className: "fa fa-link",
  18490. title: "Create Link",
  18491. default: true
  18492. },
  18493. "image": {
  18494. name: "image",
  18495. action: drawImage,
  18496. className: "fa fa-picture-o",
  18497. title: "Insert Image",
  18498. default: true
  18499. },
  18500. "table": {
  18501. name: "table",
  18502. action: drawTable,
  18503. className: "fa fa-table",
  18504. title: "Insert Table"
  18505. },
  18506. "horizontal-rule": {
  18507. name: "horizontal-rule",
  18508. action: drawHorizontalRule,
  18509. className: "fa fa-minus",
  18510. title: "Insert Horizontal Line"
  18511. },
  18512. "separator-3": {
  18513. name: "separator-3"
  18514. },
  18515. "preview": {
  18516. name: "preview",
  18517. action: togglePreview,
  18518. className: "fa fa-eye no-disable",
  18519. title: "Toggle Preview",
  18520. default: true
  18521. },
  18522. "side-by-side": {
  18523. name: "side-by-side",
  18524. action: toggleSideBySide,
  18525. className: "fa fa-columns no-disable no-mobile",
  18526. title: "Toggle Side by Side",
  18527. default: true
  18528. },
  18529. "fullscreen": {
  18530. name: "fullscreen",
  18531. action: toggleFullScreen,
  18532. className: "fa fa-arrows-alt no-disable no-mobile",
  18533. title: "Toggle Fullscreen",
  18534. default: true
  18535. },
  18536. "separator-4": {
  18537. name: "separator-4"
  18538. },
  18539. "guide": {
  18540. name: "guide",
  18541. action: "https://simplemde.com/markdown-guide",
  18542. className: "fa fa-question-circle",
  18543. title: "Markdown Guide",
  18544. default: true
  18545. },
  18546. "separator-5": {
  18547. name: "separator-5"
  18548. },
  18549. "undo": {
  18550. name: "undo",
  18551. action: undo,
  18552. className: "fa fa-undo no-disable",
  18553. title: "Undo"
  18554. },
  18555. "redo": {
  18556. name: "redo",
  18557. action: redo,
  18558. className: "fa fa-repeat no-disable",
  18559. title: "Redo"
  18560. }
  18561. };
  18562. var insertTexts = {
  18563. link: ["[", "](#url#)"],
  18564. image: ["![](", "#url#)"],
  18565. table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
  18566. horizontalRule: ["", "\n\n-----\n\n"]
  18567. };
  18568. var promptTexts = {
  18569. link: "URL for the link:",
  18570. image: "URL of the image:"
  18571. };
  18572. var blockStyles = {
  18573. "bold": "**",
  18574. "code": "```",
  18575. "italic": "*"
  18576. };
  18577. /**
  18578. * Interface of SimpleMDE.
  18579. */
  18580. function SimpleMDE(options) {
  18581. // Handle options parameter
  18582. options = options || {};
  18583. // Used later to refer to it"s parent
  18584. options.parent = this;
  18585. // Check if Font Awesome needs to be auto downloaded
  18586. var autoDownloadFA = true;
  18587. if(options.autoDownloadFontAwesome === false) {
  18588. autoDownloadFA = false;
  18589. }
  18590. if(options.autoDownloadFontAwesome !== true) {
  18591. var styleSheets = document.styleSheets;
  18592. for(var i = 0; i < styleSheets.length; i++) {
  18593. if(!styleSheets[i].href)
  18594. continue;
  18595. if(styleSheets[i].href.indexOf("//maxcdn.bootstrapcdn.com/font-awesome/") > -1) {
  18596. autoDownloadFA = false;
  18597. }
  18598. }
  18599. }
  18600. if(autoDownloadFA) {
  18601. var link = document.createElement("link");
  18602. link.rel = "stylesheet";
  18603. link.href = "https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.min.css";
  18604. document.getElementsByTagName("head")[0].appendChild(link);
  18605. }
  18606. // Find the textarea to use
  18607. if(options.element) {
  18608. this.element = options.element;
  18609. } else if(options.element === null) {
  18610. // This means that the element option was specified, but no element was found
  18611. console.log("SimpleMDE: Error. No element was found.");
  18612. return;
  18613. }
  18614. // Handle toolbar
  18615. if(options.toolbar === undefined) {
  18616. // Initialize
  18617. options.toolbar = [];
  18618. // Loop over the built in buttons, to get the preferred order
  18619. for(var key in toolbarBuiltInButtons) {
  18620. if(toolbarBuiltInButtons.hasOwnProperty(key)) {
  18621. if(key.indexOf("separator-") != -1) {
  18622. options.toolbar.push("|");
  18623. }
  18624. if(toolbarBuiltInButtons[key].default === true || (options.showIcons && options.showIcons.constructor === Array && options.showIcons.indexOf(key) != -1)) {
  18625. options.toolbar.push(key);
  18626. }
  18627. }
  18628. }
  18629. }
  18630. // Handle status bar
  18631. if(!options.hasOwnProperty("status")) {
  18632. options.status = ["autosave", "lines", "words", "cursor"];
  18633. }
  18634. // Add default preview rendering function
  18635. if(!options.previewRender) {
  18636. options.previewRender = function(plainText) {
  18637. // Note: "this" refers to the options object
  18638. return this.parent.markdown(plainText);
  18639. };
  18640. }
  18641. // Set default options for parsing config
  18642. options.parsingConfig = extend({
  18643. highlightFormatting: true // needed for toggleCodeBlock to detect types of code
  18644. }, options.parsingConfig || {});
  18645. // Merging the insertTexts, with the given options
  18646. options.insertTexts = extend({}, insertTexts, options.insertTexts || {});
  18647. // Merging the promptTexts, with the given options
  18648. options.promptTexts = promptTexts;
  18649. // Merging the blockStyles, with the given options
  18650. options.blockStyles = extend({}, blockStyles, options.blockStyles || {});
  18651. // Merging the shortcuts, with the given options
  18652. options.shortcuts = extend({}, shortcuts, options.shortcuts || {});
  18653. // Change unique_id to uniqueId for backwards compatibility
  18654. if(options.autosave != undefined && options.autosave.unique_id != undefined && options.autosave.unique_id != "")
  18655. options.autosave.uniqueId = options.autosave.unique_id;
  18656. // Update this options
  18657. this.options = options;
  18658. // Auto render
  18659. this.render();
  18660. // The codemirror component is only available after rendering
  18661. // so, the setter for the initialValue can only run after
  18662. // the element has been rendered
  18663. if(options.initialValue && (!this.options.autosave || this.options.autosave.foundSavedValue !== true)) {
  18664. this.value(options.initialValue);
  18665. }
  18666. }
  18667. /**
  18668. * Default markdown render.
  18669. */
  18670. SimpleMDE.prototype.markdown = function(text) {
  18671. if(marked) {
  18672. // Initialize
  18673. var markedOptions = {};
  18674. // Update options
  18675. if(this.options && this.options.renderingConfig && this.options.renderingConfig.singleLineBreaks === false) {
  18676. markedOptions.breaks = false;
  18677. } else {
  18678. markedOptions.breaks = true;
  18679. }
  18680. if(this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true && window.hljs) {
  18681. markedOptions.highlight = function(code) {
  18682. return window.hljs.highlightAuto(code).value;
  18683. };
  18684. }
  18685. // Set options
  18686. marked.setOptions(markedOptions);
  18687. // Return
  18688. return marked(text);
  18689. }
  18690. };
  18691. /**
  18692. * Render editor to the given element.
  18693. */
  18694. SimpleMDE.prototype.render = function(el) {
  18695. if(!el) {
  18696. el = this.element || document.getElementsByTagName("textarea")[0];
  18697. }
  18698. if(this._rendered && this._rendered === el) {
  18699. // Already rendered.
  18700. return;
  18701. }
  18702. this.element = el;
  18703. var options = this.options;
  18704. var self = this;
  18705. var keyMaps = {};
  18706. for(var key in options.shortcuts) {
  18707. // null stands for "do not bind this command"
  18708. if(options.shortcuts[key] !== null && bindings[key] !== null) {
  18709. (function(key) {
  18710. keyMaps[fixShortcut(options.shortcuts[key])] = function() {
  18711. bindings[key](self);
  18712. };
  18713. })(key);
  18714. }
  18715. }
  18716. keyMaps["Enter"] = "newlineAndIndentContinueMarkdownList";
  18717. keyMaps["Tab"] = "tabAndIndentMarkdownList";
  18718. keyMaps["Shift-Tab"] = "shiftTabAndUnindentMarkdownList";
  18719. keyMaps["Esc"] = function(cm) {
  18720. if(cm.getOption("fullScreen")) toggleFullScreen(self);
  18721. };
  18722. document.addEventListener("keydown", function(e) {
  18723. e = e || window.event;
  18724. if(e.keyCode == 27) {
  18725. if(self.codemirror.getOption("fullScreen")) toggleFullScreen(self);
  18726. }
  18727. }, false);
  18728. var mode, backdrop;
  18729. if(options.spellChecker !== false) {
  18730. mode = "spell-checker";
  18731. backdrop = options.parsingConfig;
  18732. backdrop.name = "gfm";
  18733. backdrop.gitHubSpice = false;
  18734. CodeMirrorSpellChecker({
  18735. codeMirrorInstance: CodeMirror
  18736. });
  18737. } else {
  18738. mode = options.parsingConfig;
  18739. mode.name = "gfm";
  18740. mode.gitHubSpice = false;
  18741. }
  18742. this.codemirror = CodeMirror.fromTextArea(el, {
  18743. mode: mode,
  18744. backdrop: backdrop,
  18745. theme: "paper",
  18746. tabSize: (options.tabSize != undefined) ? options.tabSize : 2,
  18747. indentUnit: (options.tabSize != undefined) ? options.tabSize : 2,
  18748. indentWithTabs: (options.indentWithTabs === false) ? false : true,
  18749. lineNumbers: false,
  18750. autofocus: (options.autofocus === true) ? true : false,
  18751. extraKeys: keyMaps,
  18752. lineWrapping: (options.lineWrapping === false) ? false : true,
  18753. allowDropFileTypes: ["text/plain"],
  18754. placeholder: options.placeholder || el.getAttribute("placeholder") || "",
  18755. styleSelectedText: (options.styleSelectedText != undefined) ? options.styleSelectedText : true
  18756. });
  18757. if(options.forceSync === true) {
  18758. var cm = this.codemirror;
  18759. cm.on("change", function() {
  18760. cm.save();
  18761. });
  18762. }
  18763. this.gui = {};
  18764. if(options.toolbar !== false) {
  18765. this.gui.toolbar = this.createToolbar();
  18766. }
  18767. if(options.status !== false) {
  18768. this.gui.statusbar = this.createStatusbar();
  18769. }
  18770. if(options.autosave != undefined && options.autosave.enabled === true) {
  18771. this.autosave();
  18772. }
  18773. this.gui.sideBySide = this.createSideBySide();
  18774. this._rendered = this.element;
  18775. // Fixes CodeMirror bug (#344)
  18776. var temp_cm = this.codemirror;
  18777. setTimeout(function() {
  18778. temp_cm.refresh();
  18779. }.bind(temp_cm), 0);
  18780. };
  18781. // Safari, in Private Browsing Mode, looks like it supports localStorage but all calls to setItem throw QuotaExceededError. We're going to detect this and set a variable accordingly.
  18782. function isLocalStorageAvailable() {
  18783. if(typeof localStorage === "object") {
  18784. try {
  18785. localStorage.setItem("smde_localStorage", 1);
  18786. localStorage.removeItem("smde_localStorage");
  18787. } catch(e) {
  18788. return false;
  18789. }
  18790. } else {
  18791. return false;
  18792. }
  18793. return true;
  18794. }
  18795. SimpleMDE.prototype.autosave = function() {
  18796. if(isLocalStorageAvailable()) {
  18797. var simplemde = this;
  18798. if(this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == "") {
  18799. console.log("SimpleMDE: You must set a uniqueId to use the autosave feature");
  18800. return;
  18801. }
  18802. if(simplemde.element.form != null && simplemde.element.form != undefined) {
  18803. simplemde.element.form.addEventListener("submit", function() {
  18804. localStorage.removeItem("smde_" + simplemde.options.autosave.uniqueId);
  18805. });
  18806. }
  18807. if(this.options.autosave.loaded !== true) {
  18808. if(typeof localStorage.getItem("smde_" + this.options.autosave.uniqueId) == "string" && localStorage.getItem("smde_" + this.options.autosave.uniqueId) != "") {
  18809. this.codemirror.setValue(localStorage.getItem("smde_" + this.options.autosave.uniqueId));
  18810. this.options.autosave.foundSavedValue = true;
  18811. }
  18812. this.options.autosave.loaded = true;
  18813. }
  18814. localStorage.setItem("smde_" + this.options.autosave.uniqueId, simplemde.value());
  18815. var el = document.getElementById("autosaved");
  18816. if(el != null && el != undefined && el != "") {
  18817. var d = new Date();
  18818. var hh = d.getHours();
  18819. var m = d.getMinutes();
  18820. var dd = "am";
  18821. var h = hh;
  18822. if(h >= 12) {
  18823. h = hh - 12;
  18824. dd = "pm";
  18825. }
  18826. if(h == 0) {
  18827. h = 12;
  18828. }
  18829. m = m < 10 ? "0" + m : m;
  18830. el.innerHTML = "Autosaved: " + h + ":" + m + " " + dd;
  18831. }
  18832. this.autosaveTimeoutId = setTimeout(function() {
  18833. simplemde.autosave();
  18834. }, this.options.autosave.delay || 10000);
  18835. } else {
  18836. console.log("SimpleMDE: localStorage not available, cannot autosave");
  18837. }
  18838. };
  18839. SimpleMDE.prototype.clearAutosavedValue = function() {
  18840. if(isLocalStorageAvailable()) {
  18841. if(this.options.autosave == undefined || this.options.autosave.uniqueId == undefined || this.options.autosave.uniqueId == "") {
  18842. console.log("SimpleMDE: You must set a uniqueId to clear the autosave value");
  18843. return;
  18844. }
  18845. localStorage.removeItem("smde_" + this.options.autosave.uniqueId);
  18846. } else {
  18847. console.log("SimpleMDE: localStorage not available, cannot autosave");
  18848. }
  18849. };
  18850. SimpleMDE.prototype.createSideBySide = function() {
  18851. var cm = this.codemirror;
  18852. var wrapper = cm.getWrapperElement();
  18853. var preview = wrapper.nextSibling;
  18854. if(!preview || !/editor-preview-side/.test(preview.className)) {
  18855. preview = document.createElement("div");
  18856. preview.className = "editor-preview-side";
  18857. wrapper.parentNode.insertBefore(preview, wrapper.nextSibling);
  18858. }
  18859. // Syncs scroll editor -> preview
  18860. var cScroll = false;
  18861. var pScroll = false;
  18862. cm.on("scroll", function(v) {
  18863. if(cScroll) {
  18864. cScroll = false;
  18865. return;
  18866. }
  18867. pScroll = true;
  18868. var height = v.getScrollInfo().height - v.getScrollInfo().clientHeight;
  18869. var ratio = parseFloat(v.getScrollInfo().top) / height;
  18870. var move = (preview.scrollHeight - preview.clientHeight) * ratio;
  18871. preview.scrollTop = move;
  18872. });
  18873. // Syncs scroll preview -> editor
  18874. preview.onscroll = function() {
  18875. if(pScroll) {
  18876. pScroll = false;
  18877. return;
  18878. }
  18879. cScroll = true;
  18880. var height = preview.scrollHeight - preview.clientHeight;
  18881. var ratio = parseFloat(preview.scrollTop) / height;
  18882. var move = (cm.getScrollInfo().height - cm.getScrollInfo().clientHeight) * ratio;
  18883. cm.scrollTo(0, move);
  18884. };
  18885. return preview;
  18886. };
  18887. SimpleMDE.prototype.createToolbar = function(items) {
  18888. items = items || this.options.toolbar;
  18889. if(!items || items.length === 0) {
  18890. return;
  18891. }
  18892. var i;
  18893. for(i = 0; i < items.length; i++) {
  18894. if(toolbarBuiltInButtons[items[i]] != undefined) {
  18895. items[i] = toolbarBuiltInButtons[items[i]];
  18896. }
  18897. }
  18898. var bar = document.createElement("div");
  18899. bar.className = "editor-toolbar";
  18900. var self = this;
  18901. var toolbarData = {};
  18902. self.toolbar = items;
  18903. for(i = 0; i < items.length; i++) {
  18904. if(items[i].name == "guide" && self.options.toolbarGuideIcon === false)
  18905. continue;
  18906. if(self.options.hideIcons && self.options.hideIcons.indexOf(items[i].name) != -1)
  18907. continue;
  18908. // Fullscreen does not work well on mobile devices (even tablets)
  18909. // In the future, hopefully this can be resolved
  18910. if((items[i].name == "fullscreen" || items[i].name == "side-by-side") && isMobile())
  18911. continue;
  18912. // Don't include trailing separators
  18913. if(items[i] === "|") {
  18914. var nonSeparatorIconsFollow = false;
  18915. for(var x = (i + 1); x < items.length; x++) {
  18916. if(items[x] !== "|" && (!self.options.hideIcons || self.options.hideIcons.indexOf(items[x].name) == -1)) {
  18917. nonSeparatorIconsFollow = true;
  18918. }
  18919. }
  18920. if(!nonSeparatorIconsFollow)
  18921. continue;
  18922. }
  18923. // Create the icon and append to the toolbar
  18924. (function(item) {
  18925. var el;
  18926. if(item === "|") {
  18927. el = createSep();
  18928. } else {
  18929. el = createIcon(item, self.options.toolbarTips, self.options.shortcuts);
  18930. }
  18931. // bind events, special for info
  18932. if(item.action) {
  18933. if(typeof item.action === "function") {
  18934. el.onclick = function(e) {
  18935. e.preventDefault();
  18936. item.action(self);
  18937. };
  18938. } else if(typeof item.action === "string") {
  18939. el.href = item.action;
  18940. el.target = "_blank";
  18941. }
  18942. }
  18943. toolbarData[item.name || item] = el;
  18944. bar.appendChild(el);
  18945. })(items[i]);
  18946. }
  18947. self.toolbarElements = toolbarData;
  18948. var cm = this.codemirror;
  18949. cm.on("cursorActivity", function() {
  18950. var stat = getState(cm);
  18951. for(var key in toolbarData) {
  18952. (function(key) {
  18953. var el = toolbarData[key];
  18954. if(stat[key]) {
  18955. el.className += " active";
  18956. } else if(key != "fullscreen" && key != "side-by-side") {
  18957. el.className = el.className.replace(/\s*active\s*/g, "");
  18958. }
  18959. })(key);
  18960. }
  18961. });
  18962. var cmWrapper = cm.getWrapperElement();
  18963. cmWrapper.parentNode.insertBefore(bar, cmWrapper);
  18964. return bar;
  18965. };
  18966. SimpleMDE.prototype.createStatusbar = function(status) {
  18967. // Initialize
  18968. status = status || this.options.status;
  18969. var options = this.options;
  18970. var cm = this.codemirror;
  18971. // Make sure the status variable is valid
  18972. if(!status || status.length === 0)
  18973. return;
  18974. // Set up the built-in items
  18975. var items = [];
  18976. var i, onUpdate, defaultValue;
  18977. for(i = 0; i < status.length; i++) {
  18978. // Reset some values
  18979. onUpdate = undefined;
  18980. defaultValue = undefined;
  18981. // Handle if custom or not
  18982. if(typeof status[i] === "object") {
  18983. items.push({
  18984. className: status[i].className,
  18985. defaultValue: status[i].defaultValue,
  18986. onUpdate: status[i].onUpdate
  18987. });
  18988. } else {
  18989. var name = status[i];
  18990. if(name === "words") {
  18991. defaultValue = function(el) {
  18992. el.innerHTML = wordCount(cm.getValue());
  18993. };
  18994. onUpdate = function(el) {
  18995. el.innerHTML = wordCount(cm.getValue());
  18996. };
  18997. } else if(name === "lines") {
  18998. defaultValue = function(el) {
  18999. el.innerHTML = cm.lineCount();
  19000. };
  19001. onUpdate = function(el) {
  19002. el.innerHTML = cm.lineCount();
  19003. };
  19004. } else if(name === "cursor") {
  19005. defaultValue = function(el) {
  19006. el.innerHTML = "0:0";
  19007. };
  19008. onUpdate = function(el) {
  19009. var pos = cm.getCursor();
  19010. el.innerHTML = pos.line + ":" + pos.ch;
  19011. };
  19012. } else if(name === "autosave") {
  19013. defaultValue = function(el) {
  19014. if(options.autosave != undefined && options.autosave.enabled === true) {
  19015. el.setAttribute("id", "autosaved");
  19016. }
  19017. };
  19018. }
  19019. items.push({
  19020. className: name,
  19021. defaultValue: defaultValue,
  19022. onUpdate: onUpdate
  19023. });
  19024. }
  19025. }
  19026. // Create element for the status bar
  19027. var bar = document.createElement("div");
  19028. bar.className = "editor-statusbar";
  19029. // Create a new span for each item
  19030. for(i = 0; i < items.length; i++) {
  19031. // Store in temporary variable
  19032. var item = items[i];
  19033. // Create span element
  19034. var el = document.createElement("span");
  19035. el.className = item.className;
  19036. // Ensure the defaultValue is a function
  19037. if(typeof item.defaultValue === "function") {
  19038. item.defaultValue(el);
  19039. }
  19040. // Ensure the onUpdate is a function
  19041. if(typeof item.onUpdate === "function") {
  19042. // Create a closure around the span of the current action, then execute the onUpdate handler
  19043. this.codemirror.on("update", (function(el, item) {
  19044. return function() {
  19045. item.onUpdate(el);
  19046. };
  19047. }(el, item)));
  19048. }
  19049. // Append the item to the status bar
  19050. bar.appendChild(el);
  19051. }
  19052. // Insert the status bar into the DOM
  19053. var cmWrapper = this.codemirror.getWrapperElement();
  19054. cmWrapper.parentNode.insertBefore(bar, cmWrapper.nextSibling);
  19055. return bar;
  19056. };
  19057. /**
  19058. * Get or set the text content.
  19059. */
  19060. SimpleMDE.prototype.value = function(val) {
  19061. if(val === undefined) {
  19062. return this.codemirror.getValue();
  19063. } else {
  19064. this.codemirror.getDoc().setValue(val);
  19065. return this;
  19066. }
  19067. };
  19068. /**
  19069. * Bind static methods for exports.
  19070. */
  19071. SimpleMDE.toggleBold = toggleBold;
  19072. SimpleMDE.toggleItalic = toggleItalic;
  19073. SimpleMDE.toggleStrikethrough = toggleStrikethrough;
  19074. SimpleMDE.toggleBlockquote = toggleBlockquote;
  19075. SimpleMDE.toggleHeadingSmaller = toggleHeadingSmaller;
  19076. SimpleMDE.toggleHeadingBigger = toggleHeadingBigger;
  19077. SimpleMDE.toggleHeading1 = toggleHeading1;
  19078. SimpleMDE.toggleHeading2 = toggleHeading2;
  19079. SimpleMDE.toggleHeading3 = toggleHeading3;
  19080. SimpleMDE.toggleCodeBlock = toggleCodeBlock;
  19081. SimpleMDE.toggleUnorderedList = toggleUnorderedList;
  19082. SimpleMDE.toggleOrderedList = toggleOrderedList;
  19083. SimpleMDE.cleanBlock = cleanBlock;
  19084. SimpleMDE.drawLink = drawLink;
  19085. SimpleMDE.drawImage = drawImage;
  19086. SimpleMDE.drawTable = drawTable;
  19087. SimpleMDE.drawHorizontalRule = drawHorizontalRule;
  19088. SimpleMDE.undo = undo;
  19089. SimpleMDE.redo = redo;
  19090. SimpleMDE.togglePreview = togglePreview;
  19091. SimpleMDE.toggleSideBySide = toggleSideBySide;
  19092. SimpleMDE.toggleFullScreen = toggleFullScreen;
  19093. /**
  19094. * Bind instance methods for exports.
  19095. */
  19096. SimpleMDE.prototype.toggleBold = function() {
  19097. toggleBold(this);
  19098. };
  19099. SimpleMDE.prototype.toggleItalic = function() {
  19100. toggleItalic(this);
  19101. };
  19102. SimpleMDE.prototype.toggleStrikethrough = function() {
  19103. toggleStrikethrough(this);
  19104. };
  19105. SimpleMDE.prototype.toggleBlockquote = function() {
  19106. toggleBlockquote(this);
  19107. };
  19108. SimpleMDE.prototype.toggleHeadingSmaller = function() {
  19109. toggleHeadingSmaller(this);
  19110. };
  19111. SimpleMDE.prototype.toggleHeadingBigger = function() {
  19112. toggleHeadingBigger(this);
  19113. };
  19114. SimpleMDE.prototype.toggleHeading1 = function() {
  19115. toggleHeading1(this);
  19116. };
  19117. SimpleMDE.prototype.toggleHeading2 = function() {
  19118. toggleHeading2(this);
  19119. };
  19120. SimpleMDE.prototype.toggleHeading3 = function() {
  19121. toggleHeading3(this);
  19122. };
  19123. SimpleMDE.prototype.toggleCodeBlock = function() {
  19124. toggleCodeBlock(this);
  19125. };
  19126. SimpleMDE.prototype.toggleUnorderedList = function() {
  19127. toggleUnorderedList(this);
  19128. };
  19129. SimpleMDE.prototype.toggleOrderedList = function() {
  19130. toggleOrderedList(this);
  19131. };
  19132. SimpleMDE.prototype.cleanBlock = function() {
  19133. cleanBlock(this);
  19134. };
  19135. SimpleMDE.prototype.drawLink = function() {
  19136. drawLink(this);
  19137. };
  19138. SimpleMDE.prototype.drawImage = function() {
  19139. drawImage(this);
  19140. };
  19141. SimpleMDE.prototype.drawTable = function() {
  19142. drawTable(this);
  19143. };
  19144. SimpleMDE.prototype.drawHorizontalRule = function() {
  19145. drawHorizontalRule(this);
  19146. };
  19147. SimpleMDE.prototype.undo = function() {
  19148. undo(this);
  19149. };
  19150. SimpleMDE.prototype.redo = function() {
  19151. redo(this);
  19152. };
  19153. SimpleMDE.prototype.togglePreview = function() {
  19154. togglePreview(this);
  19155. };
  19156. SimpleMDE.prototype.toggleSideBySide = function() {
  19157. toggleSideBySide(this);
  19158. };
  19159. SimpleMDE.prototype.toggleFullScreen = function() {
  19160. toggleFullScreen(this);
  19161. };
  19162. SimpleMDE.prototype.isPreviewActive = function() {
  19163. var cm = this.codemirror;
  19164. var wrapper = cm.getWrapperElement();
  19165. var preview = wrapper.lastChild;
  19166. return /editor-preview-active/.test(preview.className);
  19167. };
  19168. SimpleMDE.prototype.isSideBySideActive = function() {
  19169. var cm = this.codemirror;
  19170. var wrapper = cm.getWrapperElement();
  19171. var preview = wrapper.nextSibling;
  19172. return /editor-preview-active-side/.test(preview.className);
  19173. };
  19174. SimpleMDE.prototype.isFullscreenActive = function() {
  19175. var cm = this.codemirror;
  19176. return cm.getOption("fullScreen");
  19177. };
  19178. SimpleMDE.prototype.getState = function() {
  19179. var cm = this.codemirror;
  19180. return getState(cm);
  19181. };
  19182. SimpleMDE.prototype.toTextArea = function() {
  19183. var cm = this.codemirror;
  19184. var wrapper = cm.getWrapperElement();
  19185. if(wrapper.parentNode) {
  19186. if(this.gui.toolbar) {
  19187. wrapper.parentNode.removeChild(this.gui.toolbar);
  19188. }
  19189. if(this.gui.statusbar) {
  19190. wrapper.parentNode.removeChild(this.gui.statusbar);
  19191. }
  19192. if(this.gui.sideBySide) {
  19193. wrapper.parentNode.removeChild(this.gui.sideBySide);
  19194. }
  19195. }
  19196. cm.toTextArea();
  19197. if(this.autosaveTimeoutId) {
  19198. clearTimeout(this.autosaveTimeoutId);
  19199. this.autosaveTimeoutId = undefined;
  19200. this.clearAutosavedValue();
  19201. }
  19202. };
  19203. module.exports = SimpleMDE;
  19204. /***/ },
  19205. /* 164 */
  19206. /***/ function(module, exports, __webpack_require__) {
  19207. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  19208. // Distributed under an MIT license: http://codemirror.net/LICENSE
  19209. // This is CodeMirror (http://codemirror.net), a code editor
  19210. // implemented in JavaScript on top of the browser's DOM.
  19211. //
  19212. // You can find some technical background for some of the code below
  19213. // at http://marijnhaverbeke.nl/blog/#cm-internals .
  19214. (function (global, factory) {
  19215. true ? module.exports = factory() :
  19216. typeof define === 'function' && define.amd ? define(factory) :
  19217. (global.CodeMirror = factory());
  19218. }(this, (function () { 'use strict';
  19219. // Kludges for bugs and behavior differences that can't be feature
  19220. // detected are enabled based on userAgent etc sniffing.
  19221. var userAgent = navigator.userAgent
  19222. var platform = navigator.platform
  19223. var gecko = /gecko\/\d/i.test(userAgent)
  19224. var ie_upto10 = /MSIE \d/.test(userAgent)
  19225. var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent)
  19226. var ie = ie_upto10 || ie_11up
  19227. var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : ie_11up[1])
  19228. var webkit = /WebKit\//.test(userAgent)
  19229. var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent)
  19230. var chrome = /Chrome\//.test(userAgent)
  19231. var presto = /Opera\//.test(userAgent)
  19232. var safari = /Apple Computer/.test(navigator.vendor)
  19233. var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent)
  19234. var phantom = /PhantomJS/.test(userAgent)
  19235. var ios = /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent)
  19236. // This is woefully incomplete. Suggestions for alternative methods welcome.
  19237. var mobile = ios || /Android|webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent)
  19238. var mac = ios || /Mac/.test(platform)
  19239. var chromeOS = /\bCrOS\b/.test(userAgent)
  19240. var windows = /win/i.test(platform)
  19241. var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/)
  19242. if (presto_version) { presto_version = Number(presto_version[1]) }
  19243. if (presto_version && presto_version >= 15) { presto = false; webkit = true }
  19244. // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
  19245. var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11))
  19246. var captureRightClick = gecko || (ie && ie_version >= 9)
  19247. function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") }
  19248. var rmClass = function(node, cls) {
  19249. var current = node.className
  19250. var match = classTest(cls).exec(current)
  19251. if (match) {
  19252. var after = current.slice(match.index + match[0].length)
  19253. node.className = current.slice(0, match.index) + (after ? match[1] + after : "")
  19254. }
  19255. }
  19256. function removeChildren(e) {
  19257. for (var count = e.childNodes.length; count > 0; --count)
  19258. { e.removeChild(e.firstChild) }
  19259. return e
  19260. }
  19261. function removeChildrenAndAdd(parent, e) {
  19262. return removeChildren(parent).appendChild(e)
  19263. }
  19264. function elt(tag, content, className, style) {
  19265. var e = document.createElement(tag)
  19266. if (className) { e.className = className }
  19267. if (style) { e.style.cssText = style }
  19268. if (typeof content == "string") { e.appendChild(document.createTextNode(content)) }
  19269. else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]) } }
  19270. return e
  19271. }
  19272. var range
  19273. if (document.createRange) { range = function(node, start, end, endNode) {
  19274. var r = document.createRange()
  19275. r.setEnd(endNode || node, end)
  19276. r.setStart(node, start)
  19277. return r
  19278. } }
  19279. else { range = function(node, start, end) {
  19280. var r = document.body.createTextRange()
  19281. try { r.moveToElementText(node.parentNode) }
  19282. catch(e) { return r }
  19283. r.collapse(true)
  19284. r.moveEnd("character", end)
  19285. r.moveStart("character", start)
  19286. return r
  19287. } }
  19288. function contains(parent, child) {
  19289. if (child.nodeType == 3) // Android browser always returns false when child is a textnode
  19290. { child = child.parentNode }
  19291. if (parent.contains)
  19292. { return parent.contains(child) }
  19293. do {
  19294. if (child.nodeType == 11) { child = child.host }
  19295. if (child == parent) { return true }
  19296. } while (child = child.parentNode)
  19297. }
  19298. function activeElt() {
  19299. // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
  19300. // IE < 10 will throw when accessed while the page is loading or in an iframe.
  19301. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
  19302. var activeElement
  19303. try {
  19304. activeElement = document.activeElement
  19305. } catch(e) {
  19306. activeElement = document.body || null
  19307. }
  19308. while (activeElement && activeElement.root && activeElement.root.activeElement)
  19309. { activeElement = activeElement.root.activeElement }
  19310. return activeElement
  19311. }
  19312. function addClass(node, cls) {
  19313. var current = node.className
  19314. if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls }
  19315. }
  19316. function joinClasses(a, b) {
  19317. var as = a.split(" ")
  19318. for (var i = 0; i < as.length; i++)
  19319. { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i] } }
  19320. return b
  19321. }
  19322. var selectInput = function(node) { node.select() }
  19323. if (ios) // Mobile Safari apparently has a bug where select() is broken.
  19324. { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length } }
  19325. else if (ie) // Suppress mysterious IE10 errors
  19326. { selectInput = function(node) { try { node.select() } catch(_e) {} } }
  19327. function bind(f) {
  19328. var args = Array.prototype.slice.call(arguments, 1)
  19329. return function(){return f.apply(null, args)}
  19330. }
  19331. function copyObj(obj, target, overwrite) {
  19332. if (!target) { target = {} }
  19333. for (var prop in obj)
  19334. { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
  19335. { target[prop] = obj[prop] } }
  19336. return target
  19337. }
  19338. // Counts the column offset in a string, taking tabs into account.
  19339. // Used mostly to find indentation.
  19340. function countColumn(string, end, tabSize, startIndex, startValue) {
  19341. if (end == null) {
  19342. end = string.search(/[^\s\u00a0]/)
  19343. if (end == -1) { end = string.length }
  19344. }
  19345. for (var i = startIndex || 0, n = startValue || 0;;) {
  19346. var nextTab = string.indexOf("\t", i)
  19347. if (nextTab < 0 || nextTab >= end)
  19348. { return n + (end - i) }
  19349. n += nextTab - i
  19350. n += tabSize - (n % tabSize)
  19351. i = nextTab + 1
  19352. }
  19353. }
  19354. function Delayed() {this.id = null}
  19355. Delayed.prototype.set = function(ms, f) {
  19356. clearTimeout(this.id)
  19357. this.id = setTimeout(f, ms)
  19358. }
  19359. function indexOf(array, elt) {
  19360. for (var i = 0; i < array.length; ++i)
  19361. { if (array[i] == elt) { return i } }
  19362. return -1
  19363. }
  19364. // Number of pixels added to scroller and sizer to hide scrollbar
  19365. var scrollerGap = 30
  19366. // Returned or thrown by various protocols to signal 'I'm not
  19367. // handling this'.
  19368. var Pass = {toString: function(){return "CodeMirror.Pass"}}
  19369. // Reused option objects for setSelection & friends
  19370. var sel_dontScroll = {scroll: false};
  19371. var sel_mouse = {origin: "*mouse"};
  19372. var sel_move = {origin: "+move"};
  19373. // The inverse of countColumn -- find the offset that corresponds to
  19374. // a particular column.
  19375. function findColumn(string, goal, tabSize) {
  19376. for (var pos = 0, col = 0;;) {
  19377. var nextTab = string.indexOf("\t", pos)
  19378. if (nextTab == -1) { nextTab = string.length }
  19379. var skipped = nextTab - pos
  19380. if (nextTab == string.length || col + skipped >= goal)
  19381. { return pos + Math.min(skipped, goal - col) }
  19382. col += nextTab - pos
  19383. col += tabSize - (col % tabSize)
  19384. pos = nextTab + 1
  19385. if (col >= goal) { return pos }
  19386. }
  19387. }
  19388. var spaceStrs = [""]
  19389. function spaceStr(n) {
  19390. while (spaceStrs.length <= n)
  19391. { spaceStrs.push(lst(spaceStrs) + " ") }
  19392. return spaceStrs[n]
  19393. }
  19394. function lst(arr) { return arr[arr.length-1] }
  19395. function map(array, f) {
  19396. var out = []
  19397. for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i) }
  19398. return out
  19399. }
  19400. function insertSorted(array, value, score) {
  19401. var pos = 0, priority = score(value)
  19402. while (pos < array.length && score(array[pos]) <= priority) { pos++ }
  19403. array.splice(pos, 0, value)
  19404. }
  19405. function nothing() {}
  19406. function createObj(base, props) {
  19407. var inst
  19408. if (Object.create) {
  19409. inst = Object.create(base)
  19410. } else {
  19411. nothing.prototype = base
  19412. inst = new nothing()
  19413. }
  19414. if (props) { copyObj(props, inst) }
  19415. return inst
  19416. }
  19417. var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/
  19418. function isWordCharBasic(ch) {
  19419. return /\w/.test(ch) || ch > "\x80" &&
  19420. (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))
  19421. }
  19422. function isWordChar(ch, helper) {
  19423. if (!helper) { return isWordCharBasic(ch) }
  19424. if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true }
  19425. return helper.test(ch)
  19426. }
  19427. function isEmpty(obj) {
  19428. for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } }
  19429. return true
  19430. }
  19431. // Extending unicode characters. A series of a non-extending char +
  19432. // any number of extending chars is treated as a single unit as far
  19433. // as editing and measuring is concerned. This is not fully correct,
  19434. // since some scripts/fonts/browsers also treat other configurations
  19435. // of code points as a group.
  19436. var extendingChars = /[\u0300-\u036f\u0483-\u0489\u0591-\u05bd\u05bf\u05c1\u05c2\u05c4\u05c5\u05c7\u0610-\u061a\u064b-\u065e\u0670\u06d6-\u06dc\u06de-\u06e4\u06e7\u06e8\u06ea-\u06ed\u0711\u0730-\u074a\u07a6-\u07b0\u07eb-\u07f3\u0816-\u0819\u081b-\u0823\u0825-\u0827\u0829-\u082d\u0900-\u0902\u093c\u0941-\u0948\u094d\u0951-\u0955\u0962\u0963\u0981\u09bc\u09be\u09c1-\u09c4\u09cd\u09d7\u09e2\u09e3\u0a01\u0a02\u0a3c\u0a41\u0a42\u0a47\u0a48\u0a4b-\u0a4d\u0a51\u0a70\u0a71\u0a75\u0a81\u0a82\u0abc\u0ac1-\u0ac5\u0ac7\u0ac8\u0acd\u0ae2\u0ae3\u0b01\u0b3c\u0b3e\u0b3f\u0b41-\u0b44\u0b4d\u0b56\u0b57\u0b62\u0b63\u0b82\u0bbe\u0bc0\u0bcd\u0bd7\u0c3e-\u0c40\u0c46-\u0c48\u0c4a-\u0c4d\u0c55\u0c56\u0c62\u0c63\u0cbc\u0cbf\u0cc2\u0cc6\u0ccc\u0ccd\u0cd5\u0cd6\u0ce2\u0ce3\u0d3e\u0d41-\u0d44\u0d4d\u0d57\u0d62\u0d63\u0dca\u0dcf\u0dd2-\u0dd4\u0dd6\u0ddf\u0e31\u0e34-\u0e3a\u0e47-\u0e4e\u0eb1\u0eb4-\u0eb9\u0ebb\u0ebc\u0ec8-\u0ecd\u0f18\u0f19\u0f35\u0f37\u0f39\u0f71-\u0f7e\u0f80-\u0f84\u0f86\u0f87\u0f90-\u0f97\u0f99-\u0fbc\u0fc6\u102d-\u1030\u1032-\u1037\u1039\u103a\u103d\u103e\u1058\u1059\u105e-\u1060\u1071-\u1074\u1082\u1085\u1086\u108d\u109d\u135f\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17b7-\u17bd\u17c6\u17c9-\u17d3\u17dd\u180b-\u180d\u18a9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193b\u1a17\u1a18\u1a56\u1a58-\u1a5e\u1a60\u1a62\u1a65-\u1a6c\u1a73-\u1a7c\u1a7f\u1b00-\u1b03\u1b34\u1b36-\u1b3a\u1b3c\u1b42\u1b6b-\u1b73\u1b80\u1b81\u1ba2-\u1ba5\u1ba8\u1ba9\u1c2c-\u1c33\u1c36\u1c37\u1cd0-\u1cd2\u1cd4-\u1ce0\u1ce2-\u1ce8\u1ced\u1dc0-\u1de6\u1dfd-\u1dff\u200c\u200d\u20d0-\u20f0\u2cef-\u2cf1\u2de0-\u2dff\u302a-\u302f\u3099\u309a\ua66f-\ua672\ua67c\ua67d\ua6f0\ua6f1\ua802\ua806\ua80b\ua825\ua826\ua8c4\ua8e0-\ua8f1\ua926-\ua92d\ua947-\ua951\ua980-\ua982\ua9b3\ua9b6-\ua9b9\ua9bc\uaa29-\uaa2e\uaa31\uaa32\uaa35\uaa36\uaa43\uaa4c\uaab0\uaab2-\uaab4\uaab7\uaab8\uaabe\uaabf\uaac1\uabe5\uabe8\uabed\udc00-\udfff\ufb1e\ufe00-\ufe0f\ufe20-\ufe26\uff9e\uff9f]/
  19437. function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
  19438. // The display handles the DOM integration, both for input reading
  19439. // and content drawing. It holds references to DOM nodes and
  19440. // display-related state.
  19441. function Display(place, doc, input) {
  19442. var d = this
  19443. this.input = input
  19444. // Covers bottom-right square when both scrollbars are present.
  19445. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler")
  19446. d.scrollbarFiller.setAttribute("cm-not-content", "true")
  19447. // Covers bottom of gutter when coverGutterNextToScrollbar is on
  19448. // and h scrollbar is present.
  19449. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler")
  19450. d.gutterFiller.setAttribute("cm-not-content", "true")
  19451. // Will contain the actual code, positioned to cover the viewport.
  19452. d.lineDiv = elt("div", null, "CodeMirror-code")
  19453. // Elements are added to these to represent selection and cursors.
  19454. d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1")
  19455. d.cursorDiv = elt("div", null, "CodeMirror-cursors")
  19456. // A visibility: hidden element used to find the size of things.
  19457. d.measure = elt("div", null, "CodeMirror-measure")
  19458. // When lines outside of the viewport are measured, they are drawn in this.
  19459. d.lineMeasure = elt("div", null, "CodeMirror-measure")
  19460. // Wraps everything that needs to exist inside the vertically-padded coordinate system
  19461. d.lineSpace = elt("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
  19462. null, "position: relative; outline: none")
  19463. // Moved around its parent to cover visible view.
  19464. d.mover = elt("div", [elt("div", [d.lineSpace], "CodeMirror-lines")], null, "position: relative")
  19465. // Set to the height of the document, allowing scrolling.
  19466. d.sizer = elt("div", [d.mover], "CodeMirror-sizer")
  19467. d.sizerWidth = null
  19468. // Behavior of elts with overflow: auto and padding is
  19469. // inconsistent across browsers. This is used to ensure the
  19470. // scrollable area is big enough.
  19471. d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;")
  19472. // Will contain the gutters, if any.
  19473. d.gutters = elt("div", null, "CodeMirror-gutters")
  19474. d.lineGutter = null
  19475. // Actual scrollable element.
  19476. d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll")
  19477. d.scroller.setAttribute("tabIndex", "-1")
  19478. // The element in which the editor lives.
  19479. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror")
  19480. // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
  19481. if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0 }
  19482. if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true }
  19483. if (place) {
  19484. if (place.appendChild) { place.appendChild(d.wrapper) }
  19485. else { place(d.wrapper) }
  19486. }
  19487. // Current rendered range (may be bigger than the view window).
  19488. d.viewFrom = d.viewTo = doc.first
  19489. d.reportedViewFrom = d.reportedViewTo = doc.first
  19490. // Information about the rendered lines.
  19491. d.view = []
  19492. d.renderedView = null
  19493. // Holds info about a single rendered line when it was rendered
  19494. // for measurement, while not in view.
  19495. d.externalMeasured = null
  19496. // Empty space (in pixels) above the view
  19497. d.viewOffset = 0
  19498. d.lastWrapHeight = d.lastWrapWidth = 0
  19499. d.updateLineNumbers = null
  19500. d.nativeBarWidth = d.barHeight = d.barWidth = 0
  19501. d.scrollbarsClipped = false
  19502. // Used to only resize the line number gutter when necessary (when
  19503. // the amount of lines crosses a boundary that makes its width change)
  19504. d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null
  19505. // Set to true when a non-horizontal-scrolling line widget is
  19506. // added. As an optimization, line widget aligning is skipped when
  19507. // this is false.
  19508. d.alignWidgets = false
  19509. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null
  19510. // Tracks the maximum line length so that the horizontal scrollbar
  19511. // can be kept static when scrolling.
  19512. d.maxLine = null
  19513. d.maxLineLength = 0
  19514. d.maxLineChanged = false
  19515. // Used for measuring wheel scrolling granularity
  19516. d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null
  19517. // True when shift is held down.
  19518. d.shift = false
  19519. // Used to track whether anything happened since the context menu
  19520. // was opened.
  19521. d.selForContextMenu = null
  19522. d.activeTouch = null
  19523. input.init(d)
  19524. }
  19525. // Find the line object corresponding to the given line number.
  19526. function getLine(doc, n) {
  19527. n -= doc.first
  19528. if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") }
  19529. var chunk = doc
  19530. while (!chunk.lines) {
  19531. for (var i = 0;; ++i) {
  19532. var child = chunk.children[i], sz = child.chunkSize()
  19533. if (n < sz) { chunk = child; break }
  19534. n -= sz
  19535. }
  19536. }
  19537. return chunk.lines[n]
  19538. }
  19539. // Get the part of a document between two positions, as an array of
  19540. // strings.
  19541. function getBetween(doc, start, end) {
  19542. var out = [], n = start.line
  19543. doc.iter(start.line, end.line + 1, function (line) {
  19544. var text = line.text
  19545. if (n == end.line) { text = text.slice(0, end.ch) }
  19546. if (n == start.line) { text = text.slice(start.ch) }
  19547. out.push(text)
  19548. ++n
  19549. })
  19550. return out
  19551. }
  19552. // Get the lines between from and to, as array of strings.
  19553. function getLines(doc, from, to) {
  19554. var out = []
  19555. doc.iter(from, to, function (line) { out.push(line.text) }) // iter aborts when callback returns truthy value
  19556. return out
  19557. }
  19558. // Update the height of a line, propagating the height change
  19559. // upwards to parent nodes.
  19560. function updateLineHeight(line, height) {
  19561. var diff = height - line.height
  19562. if (diff) { for (var n = line; n; n = n.parent) { n.height += diff } }
  19563. }
  19564. // Given a line object, find its line number by walking up through
  19565. // its parent links.
  19566. function lineNo(line) {
  19567. if (line.parent == null) { return null }
  19568. var cur = line.parent, no = indexOf(cur.lines, line)
  19569. for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
  19570. for (var i = 0;; ++i) {
  19571. if (chunk.children[i] == cur) { break }
  19572. no += chunk.children[i].chunkSize()
  19573. }
  19574. }
  19575. return no + cur.first
  19576. }
  19577. // Find the line at the given vertical position, using the height
  19578. // information in the document tree.
  19579. function lineAtHeight(chunk, h) {
  19580. var n = chunk.first
  19581. outer: do {
  19582. for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {
  19583. var child = chunk.children[i$1], ch = child.height
  19584. if (h < ch) { chunk = child; continue outer }
  19585. h -= ch
  19586. n += child.chunkSize()
  19587. }
  19588. return n
  19589. } while (!chunk.lines)
  19590. var i = 0
  19591. for (; i < chunk.lines.length; ++i) {
  19592. var line = chunk.lines[i], lh = line.height
  19593. if (h < lh) { break }
  19594. h -= lh
  19595. }
  19596. return n + i
  19597. }
  19598. function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size}
  19599. function lineNumberFor(options, i) {
  19600. return String(options.lineNumberFormatter(i + options.firstLineNumber))
  19601. }
  19602. // A Pos instance represents a position within the text.
  19603. function Pos (line, ch) {
  19604. if (!(this instanceof Pos)) { return new Pos(line, ch) }
  19605. this.line = line; this.ch = ch
  19606. }
  19607. // Compare two positions, return 0 if they are the same, a negative
  19608. // number when a is less, and a positive number otherwise.
  19609. function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
  19610. function copyPos(x) {return Pos(x.line, x.ch)}
  19611. function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
  19612. function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
  19613. // Most of the external API clips given positions to make sure they
  19614. // actually exist within the document.
  19615. function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}
  19616. function clipPos(doc, pos) {
  19617. if (pos.line < doc.first) { return Pos(doc.first, 0) }
  19618. var last = doc.first + doc.size - 1
  19619. if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) }
  19620. return clipToLen(pos, getLine(doc, pos.line).text.length)
  19621. }
  19622. function clipToLen(pos, linelen) {
  19623. var ch = pos.ch
  19624. if (ch == null || ch > linelen) { return Pos(pos.line, linelen) }
  19625. else if (ch < 0) { return Pos(pos.line, 0) }
  19626. else { return pos }
  19627. }
  19628. function clipPosArray(doc, array) {
  19629. var out = []
  19630. for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]) }
  19631. return out
  19632. }
  19633. // Optimize some code when these features are not used.
  19634. var sawReadOnlySpans = false;
  19635. var sawCollapsedSpans = false;
  19636. function seeReadOnlySpans() {
  19637. sawReadOnlySpans = true
  19638. }
  19639. function seeCollapsedSpans() {
  19640. sawCollapsedSpans = true
  19641. }
  19642. // TEXTMARKER SPANS
  19643. function MarkedSpan(marker, from, to) {
  19644. this.marker = marker
  19645. this.from = from; this.to = to
  19646. }
  19647. // Search an array of spans for a span matching the given marker.
  19648. function getMarkedSpanFor(spans, marker) {
  19649. if (spans) { for (var i = 0; i < spans.length; ++i) {
  19650. var span = spans[i]
  19651. if (span.marker == marker) { return span }
  19652. } }
  19653. }
  19654. // Remove a span from an array, returning undefined if no spans are
  19655. // left (we don't store arrays for lines without spans).
  19656. function removeMarkedSpan(spans, span) {
  19657. var r
  19658. for (var i = 0; i < spans.length; ++i)
  19659. { if (spans[i] != span) { (r || (r = [])).push(spans[i]) } }
  19660. return r
  19661. }
  19662. // Add a span to a line.
  19663. function addMarkedSpan(line, span) {
  19664. line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span]
  19665. span.marker.attachLine(line)
  19666. }
  19667. // Used for the algorithm that adjusts markers for a change in the
  19668. // document. These functions cut an array of spans at a given
  19669. // character position, returning an array of remaining chunks (or
  19670. // undefined if nothing remains).
  19671. function markedSpansBefore(old, startCh, isInsert) {
  19672. var nw
  19673. if (old) { for (var i = 0; i < old.length; ++i) {
  19674. var span = old[i], marker = span.marker
  19675. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh)
  19676. if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
  19677. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh)
  19678. ;(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to))
  19679. }
  19680. } }
  19681. return nw
  19682. }
  19683. function markedSpansAfter(old, endCh, isInsert) {
  19684. var nw
  19685. if (old) { for (var i = 0; i < old.length; ++i) {
  19686. var span = old[i], marker = span.marker
  19687. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh)
  19688. if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
  19689. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh)
  19690. ;(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
  19691. span.to == null ? null : span.to - endCh))
  19692. }
  19693. } }
  19694. return nw
  19695. }
  19696. // Given a change object, compute the new set of marker spans that
  19697. // cover the line in which the change took place. Removes spans
  19698. // entirely within the change, reconnects spans belonging to the
  19699. // same marker that appear on both sides of the change, and cuts off
  19700. // spans partially within the change. Returns an array of span
  19701. // arrays with one element for each line in (after) the change.
  19702. function stretchSpansOverChange(doc, change) {
  19703. if (change.full) { return null }
  19704. var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans
  19705. var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans
  19706. if (!oldFirst && !oldLast) { return null }
  19707. var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0
  19708. // Get the spans that 'stick out' on both sides
  19709. var first = markedSpansBefore(oldFirst, startCh, isInsert)
  19710. var last = markedSpansAfter(oldLast, endCh, isInsert)
  19711. // Next, merge those two ends
  19712. var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0)
  19713. if (first) {
  19714. // Fix up .to properties of first
  19715. for (var i = 0; i < first.length; ++i) {
  19716. var span = first[i]
  19717. if (span.to == null) {
  19718. var found = getMarkedSpanFor(last, span.marker)
  19719. if (!found) { span.to = startCh }
  19720. else if (sameLine) { span.to = found.to == null ? null : found.to + offset }
  19721. }
  19722. }
  19723. }
  19724. if (last) {
  19725. // Fix up .from in last (or move them into first in case of sameLine)
  19726. for (var i$1 = 0; i$1 < last.length; ++i$1) {
  19727. var span$1 = last[i$1]
  19728. if (span$1.to != null) { span$1.to += offset }
  19729. if (span$1.from == null) {
  19730. var found$1 = getMarkedSpanFor(first, span$1.marker)
  19731. if (!found$1) {
  19732. span$1.from = offset
  19733. if (sameLine) { (first || (first = [])).push(span$1) }
  19734. }
  19735. } else {
  19736. span$1.from += offset
  19737. if (sameLine) { (first || (first = [])).push(span$1) }
  19738. }
  19739. }
  19740. }
  19741. // Make sure we didn't create any zero-length spans
  19742. if (first) { first = clearEmptySpans(first) }
  19743. if (last && last != first) { last = clearEmptySpans(last) }
  19744. var newMarkers = [first]
  19745. if (!sameLine) {
  19746. // Fill gap with whole-line-spans
  19747. var gap = change.text.length - 2, gapMarkers
  19748. if (gap > 0 && first)
  19749. { for (var i$2 = 0; i$2 < first.length; ++i$2)
  19750. { if (first[i$2].to == null)
  19751. { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)) } } }
  19752. for (var i$3 = 0; i$3 < gap; ++i$3)
  19753. { newMarkers.push(gapMarkers) }
  19754. newMarkers.push(last)
  19755. }
  19756. return newMarkers
  19757. }
  19758. // Remove spans that are empty and don't have a clearWhenEmpty
  19759. // option of false.
  19760. function clearEmptySpans(spans) {
  19761. for (var i = 0; i < spans.length; ++i) {
  19762. var span = spans[i]
  19763. if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
  19764. { spans.splice(i--, 1) }
  19765. }
  19766. if (!spans.length) { return null }
  19767. return spans
  19768. }
  19769. // Used to 'clip' out readOnly ranges when making a change.
  19770. function removeReadOnlyRanges(doc, from, to) {
  19771. var markers = null
  19772. doc.iter(from.line, to.line + 1, function (line) {
  19773. if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
  19774. var mark = line.markedSpans[i].marker
  19775. if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
  19776. { (markers || (markers = [])).push(mark) }
  19777. } }
  19778. })
  19779. if (!markers) { return null }
  19780. var parts = [{from: from, to: to}]
  19781. for (var i = 0; i < markers.length; ++i) {
  19782. var mk = markers[i], m = mk.find(0)
  19783. for (var j = 0; j < parts.length; ++j) {
  19784. var p = parts[j]
  19785. if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue }
  19786. var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to)
  19787. if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
  19788. { newParts.push({from: p.from, to: m.from}) }
  19789. if (dto > 0 || !mk.inclusiveRight && !dto)
  19790. { newParts.push({from: m.to, to: p.to}) }
  19791. parts.splice.apply(parts, newParts)
  19792. j += newParts.length - 1
  19793. }
  19794. }
  19795. return parts
  19796. }
  19797. // Connect or disconnect spans from a line.
  19798. function detachMarkedSpans(line) {
  19799. var spans = line.markedSpans
  19800. if (!spans) { return }
  19801. for (var i = 0; i < spans.length; ++i)
  19802. { spans[i].marker.detachLine(line) }
  19803. line.markedSpans = null
  19804. }
  19805. function attachMarkedSpans(line, spans) {
  19806. if (!spans) { return }
  19807. for (var i = 0; i < spans.length; ++i)
  19808. { spans[i].marker.attachLine(line) }
  19809. line.markedSpans = spans
  19810. }
  19811. // Helpers used when computing which overlapping collapsed span
  19812. // counts as the larger one.
  19813. function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }
  19814. function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }
  19815. // Returns a number indicating which of two overlapping collapsed
  19816. // spans is larger (and thus includes the other). Falls back to
  19817. // comparing ids when the spans cover exactly the same range.
  19818. function compareCollapsedMarkers(a, b) {
  19819. var lenDiff = a.lines.length - b.lines.length
  19820. if (lenDiff != 0) { return lenDiff }
  19821. var aPos = a.find(), bPos = b.find()
  19822. var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b)
  19823. if (fromCmp) { return -fromCmp }
  19824. var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b)
  19825. if (toCmp) { return toCmp }
  19826. return b.id - a.id
  19827. }
  19828. // Find out whether a line ends or starts in a collapsed span. If
  19829. // so, return the marker for that span.
  19830. function collapsedSpanAtSide(line, start) {
  19831. var sps = sawCollapsedSpans && line.markedSpans, found
  19832. if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
  19833. sp = sps[i]
  19834. if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
  19835. (!found || compareCollapsedMarkers(found, sp.marker) < 0))
  19836. { found = sp.marker }
  19837. } }
  19838. return found
  19839. }
  19840. function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }
  19841. function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }
  19842. // Test whether there exists a collapsed span that partially
  19843. // overlaps (covers the start or end, but not both) of a new span.
  19844. // Such overlap is not allowed.
  19845. function conflictingCollapsedRange(doc, lineNo, from, to, marker) {
  19846. var line = getLine(doc, lineNo)
  19847. var sps = sawCollapsedSpans && line.markedSpans
  19848. if (sps) { for (var i = 0; i < sps.length; ++i) {
  19849. var sp = sps[i]
  19850. if (!sp.marker.collapsed) { continue }
  19851. var found = sp.marker.find(0)
  19852. var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker)
  19853. var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker)
  19854. if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue }
  19855. if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
  19856. fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
  19857. { return true }
  19858. } }
  19859. }
  19860. // A visual line is a line as drawn on the screen. Folding, for
  19861. // example, can cause multiple logical lines to appear on the same
  19862. // visual line. This finds the start of the visual line that the
  19863. // given line is part of (usually that is the line itself).
  19864. function visualLine(line) {
  19865. var merged
  19866. while (merged = collapsedSpanAtStart(line))
  19867. { line = merged.find(-1, true).line }
  19868. return line
  19869. }
  19870. // Returns an array of logical lines that continue the visual line
  19871. // started by the argument, or undefined if there are no such lines.
  19872. function visualLineContinued(line) {
  19873. var merged, lines
  19874. while (merged = collapsedSpanAtEnd(line)) {
  19875. line = merged.find(1, true).line
  19876. ;(lines || (lines = [])).push(line)
  19877. }
  19878. return lines
  19879. }
  19880. // Get the line number of the start of the visual line that the
  19881. // given line number is part of.
  19882. function visualLineNo(doc, lineN) {
  19883. var line = getLine(doc, lineN), vis = visualLine(line)
  19884. if (line == vis) { return lineN }
  19885. return lineNo(vis)
  19886. }
  19887. // Get the line number of the start of the next visual line after
  19888. // the given line.
  19889. function visualLineEndNo(doc, lineN) {
  19890. if (lineN > doc.lastLine()) { return lineN }
  19891. var line = getLine(doc, lineN), merged
  19892. if (!lineIsHidden(doc, line)) { return lineN }
  19893. while (merged = collapsedSpanAtEnd(line))
  19894. { line = merged.find(1, true).line }
  19895. return lineNo(line) + 1
  19896. }
  19897. // Compute whether a line is hidden. Lines count as hidden when they
  19898. // are part of a visual line that starts with another line, or when
  19899. // they are entirely covered by collapsed, non-widget span.
  19900. function lineIsHidden(doc, line) {
  19901. var sps = sawCollapsedSpans && line.markedSpans
  19902. if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
  19903. sp = sps[i]
  19904. if (!sp.marker.collapsed) { continue }
  19905. if (sp.from == null) { return true }
  19906. if (sp.marker.widgetNode) { continue }
  19907. if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
  19908. { return true }
  19909. } }
  19910. }
  19911. function lineIsHiddenInner(doc, line, span) {
  19912. if (span.to == null) {
  19913. var end = span.marker.find(1, true)
  19914. return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))
  19915. }
  19916. if (span.marker.inclusiveRight && span.to == line.text.length)
  19917. { return true }
  19918. for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) {
  19919. sp = line.markedSpans[i]
  19920. if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
  19921. (sp.to == null || sp.to != span.from) &&
  19922. (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
  19923. lineIsHiddenInner(doc, line, sp)) { return true }
  19924. }
  19925. }
  19926. // Find the height above the given line.
  19927. function heightAtLine(lineObj) {
  19928. lineObj = visualLine(lineObj)
  19929. var h = 0, chunk = lineObj.parent
  19930. for (var i = 0; i < chunk.lines.length; ++i) {
  19931. var line = chunk.lines[i]
  19932. if (line == lineObj) { break }
  19933. else { h += line.height }
  19934. }
  19935. for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
  19936. for (var i$1 = 0; i$1 < p.children.length; ++i$1) {
  19937. var cur = p.children[i$1]
  19938. if (cur == chunk) { break }
  19939. else { h += cur.height }
  19940. }
  19941. }
  19942. return h
  19943. }
  19944. // Compute the character length of a line, taking into account
  19945. // collapsed ranges (see markText) that might hide parts, and join
  19946. // other lines onto it.
  19947. function lineLength(line) {
  19948. if (line.height == 0) { return 0 }
  19949. var len = line.text.length, merged, cur = line
  19950. while (merged = collapsedSpanAtStart(cur)) {
  19951. var found = merged.find(0, true)
  19952. cur = found.from.line
  19953. len += found.from.ch - found.to.ch
  19954. }
  19955. cur = line
  19956. while (merged = collapsedSpanAtEnd(cur)) {
  19957. var found$1 = merged.find(0, true)
  19958. len -= cur.text.length - found$1.from.ch
  19959. cur = found$1.to.line
  19960. len += cur.text.length - found$1.to.ch
  19961. }
  19962. return len
  19963. }
  19964. // Find the longest line in the document.
  19965. function findMaxLine(cm) {
  19966. var d = cm.display, doc = cm.doc
  19967. d.maxLine = getLine(doc, doc.first)
  19968. d.maxLineLength = lineLength(d.maxLine)
  19969. d.maxLineChanged = true
  19970. doc.iter(function (line) {
  19971. var len = lineLength(line)
  19972. if (len > d.maxLineLength) {
  19973. d.maxLineLength = len
  19974. d.maxLine = line
  19975. }
  19976. })
  19977. }
  19978. // BIDI HELPERS
  19979. function iterateBidiSections(order, from, to, f) {
  19980. if (!order) { return f(from, to, "ltr") }
  19981. var found = false
  19982. for (var i = 0; i < order.length; ++i) {
  19983. var part = order[i]
  19984. if (part.from < to && part.to > from || from == to && part.to == from) {
  19985. f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr")
  19986. found = true
  19987. }
  19988. }
  19989. if (!found) { f(from, to, "ltr") }
  19990. }
  19991. function bidiLeft(part) { return part.level % 2 ? part.to : part.from }
  19992. function bidiRight(part) { return part.level % 2 ? part.from : part.to }
  19993. function lineLeft(line) { var order = getOrder(line); return order ? bidiLeft(order[0]) : 0 }
  19994. function lineRight(line) {
  19995. var order = getOrder(line)
  19996. if (!order) { return line.text.length }
  19997. return bidiRight(lst(order))
  19998. }
  19999. function compareBidiLevel(order, a, b) {
  20000. var linedir = order[0].level
  20001. if (a == linedir) { return true }
  20002. if (b == linedir) { return false }
  20003. return a < b
  20004. }
  20005. var bidiOther = null
  20006. function getBidiPartAt(order, pos) {
  20007. var found
  20008. bidiOther = null
  20009. for (var i = 0; i < order.length; ++i) {
  20010. var cur = order[i]
  20011. if (cur.from < pos && cur.to > pos) { return i }
  20012. if ((cur.from == pos || cur.to == pos)) {
  20013. if (found == null) {
  20014. found = i
  20015. } else if (compareBidiLevel(order, cur.level, order[found].level)) {
  20016. if (cur.from != cur.to) { bidiOther = found }
  20017. return i
  20018. } else {
  20019. if (cur.from != cur.to) { bidiOther = i }
  20020. return found
  20021. }
  20022. }
  20023. }
  20024. return found
  20025. }
  20026. function moveInLine(line, pos, dir, byUnit) {
  20027. if (!byUnit) { return pos + dir }
  20028. do { pos += dir }
  20029. while (pos > 0 && isExtendingChar(line.text.charAt(pos)))
  20030. return pos
  20031. }
  20032. // This is needed in order to move 'visually' through bi-directional
  20033. // text -- i.e., pressing left should make the cursor go left, even
  20034. // when in RTL text. The tricky part is the 'jumps', where RTL and
  20035. // LTR text touch each other. This often requires the cursor offset
  20036. // to move more than one unit, in order to visually move one unit.
  20037. function moveVisually(line, start, dir, byUnit) {
  20038. var bidi = getOrder(line)
  20039. if (!bidi) { return moveLogically(line, start, dir, byUnit) }
  20040. var pos = getBidiPartAt(bidi, start), part = bidi[pos]
  20041. var target = moveInLine(line, start, part.level % 2 ? -dir : dir, byUnit)
  20042. for (;;) {
  20043. if (target > part.from && target < part.to) { return target }
  20044. if (target == part.from || target == part.to) {
  20045. if (getBidiPartAt(bidi, target) == pos) { return target }
  20046. part = bidi[pos += dir]
  20047. return (dir > 0) == part.level % 2 ? part.to : part.from
  20048. } else {
  20049. part = bidi[pos += dir]
  20050. if (!part) { return null }
  20051. if ((dir > 0) == part.level % 2)
  20052. { target = moveInLine(line, part.to, -1, byUnit) }
  20053. else
  20054. { target = moveInLine(line, part.from, 1, byUnit) }
  20055. }
  20056. }
  20057. }
  20058. function moveLogically(line, start, dir, byUnit) {
  20059. var target = start + dir
  20060. if (byUnit) { while (target > 0 && isExtendingChar(line.text.charAt(target))) { target += dir } }
  20061. return target < 0 || target > line.text.length ? null : target
  20062. }
  20063. // Bidirectional ordering algorithm
  20064. // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
  20065. // that this (partially) implements.
  20066. // One-char codes used for character types:
  20067. // L (L): Left-to-Right
  20068. // R (R): Right-to-Left
  20069. // r (AL): Right-to-Left Arabic
  20070. // 1 (EN): European Number
  20071. // + (ES): European Number Separator
  20072. // % (ET): European Number Terminator
  20073. // n (AN): Arabic Number
  20074. // , (CS): Common Number Separator
  20075. // m (NSM): Non-Spacing Mark
  20076. // b (BN): Boundary Neutral
  20077. // s (B): Paragraph Separator
  20078. // t (S): Segment Separator
  20079. // w (WS): Whitespace
  20080. // N (ON): Other Neutrals
  20081. // Returns null if characters are ordered as they appear
  20082. // (left-to-right), or an array of sections ({from, to, level}
  20083. // objects) in the order in which they occur visually.
  20084. var bidiOrdering = (function() {
  20085. // Character types for codepoints 0 to 0xff
  20086. var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN"
  20087. // Character types for codepoints 0x600 to 0x6f9
  20088. var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111"
  20089. function charType(code) {
  20090. if (code <= 0xf7) { return lowTypes.charAt(code) }
  20091. else if (0x590 <= code && code <= 0x5f4) { return "R" }
  20092. else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) }
  20093. else if (0x6ee <= code && code <= 0x8ac) { return "r" }
  20094. else if (0x2000 <= code && code <= 0x200b) { return "w" }
  20095. else if (code == 0x200c) { return "b" }
  20096. else { return "L" }
  20097. }
  20098. var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/
  20099. var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/
  20100. // Browsers seem to always treat the boundaries of block elements as being L.
  20101. var outerType = "L"
  20102. function BidiSpan(level, from, to) {
  20103. this.level = level
  20104. this.from = from; this.to = to
  20105. }
  20106. return function(str) {
  20107. if (!bidiRE.test(str)) { return false }
  20108. var len = str.length, types = []
  20109. for (var i = 0; i < len; ++i)
  20110. { types.push(charType(str.charCodeAt(i))) }
  20111. // W1. Examine each non-spacing mark (NSM) in the level run, and
  20112. // change the type of the NSM to the type of the previous
  20113. // character. If the NSM is at the start of the level run, it will
  20114. // get the type of sor.
  20115. for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {
  20116. var type = types[i$1]
  20117. if (type == "m") { types[i$1] = prev }
  20118. else { prev = type }
  20119. }
  20120. // W2. Search backwards from each instance of a European number
  20121. // until the first strong type (R, L, AL, or sor) is found. If an
  20122. // AL is found, change the type of the European number to Arabic
  20123. // number.
  20124. // W3. Change all ALs to R.
  20125. for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {
  20126. var type$1 = types[i$2]
  20127. if (type$1 == "1" && cur == "r") { types[i$2] = "n" }
  20128. else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R" } }
  20129. }
  20130. // W4. A single European separator between two European numbers
  20131. // changes to a European number. A single common separator between
  20132. // two numbers of the same type changes to that type.
  20133. for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {
  20134. var type$2 = types[i$3]
  20135. if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1" }
  20136. else if (type$2 == "," && prev$1 == types[i$3+1] &&
  20137. (prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1 }
  20138. prev$1 = type$2
  20139. }
  20140. // W5. A sequence of European terminators adjacent to European
  20141. // numbers changes to all European numbers.
  20142. // W6. Otherwise, separators and terminators change to Other
  20143. // Neutral.
  20144. for (var i$4 = 0; i$4 < len; ++i$4) {
  20145. var type$3 = types[i$4]
  20146. if (type$3 == ",") { types[i$4] = "N" }
  20147. else if (type$3 == "%") {
  20148. var end = (void 0)
  20149. for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
  20150. var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N"
  20151. for (var j = i$4; j < end; ++j) { types[j] = replace }
  20152. i$4 = end - 1
  20153. }
  20154. }
  20155. // W7. Search backwards from each instance of a European number
  20156. // until the first strong type (R, L, or sor) is found. If an L is
  20157. // found, then change the type of the European number to L.
  20158. for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
  20159. var type$4 = types[i$5]
  20160. if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L" }
  20161. else if (isStrong.test(type$4)) { cur$1 = type$4 }
  20162. }
  20163. // N1. A sequence of neutrals takes the direction of the
  20164. // surrounding strong text if the text on both sides has the same
  20165. // direction. European and Arabic numbers act as if they were R in
  20166. // terms of their influence on neutrals. Start-of-level-run (sor)
  20167. // and end-of-level-run (eor) are used at level run boundaries.
  20168. // N2. Any remaining neutrals take the embedding direction.
  20169. for (var i$6 = 0; i$6 < len; ++i$6) {
  20170. if (isNeutral.test(types[i$6])) {
  20171. var end$1 = (void 0)
  20172. for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
  20173. var before = (i$6 ? types[i$6-1] : outerType) == "L"
  20174. var after = (end$1 < len ? types[end$1] : outerType) == "L"
  20175. var replace$1 = before || after ? "L" : "R"
  20176. for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1 }
  20177. i$6 = end$1 - 1
  20178. }
  20179. }
  20180. // Here we depart from the documented algorithm, in order to avoid
  20181. // building up an actual levels array. Since there are only three
  20182. // levels (0, 1, 2) in an implementation that doesn't take
  20183. // explicit embedding into account, we can build up the order on
  20184. // the fly, without following the level-based algorithm.
  20185. var order = [], m
  20186. for (var i$7 = 0; i$7 < len;) {
  20187. if (countsAsLeft.test(types[i$7])) {
  20188. var start = i$7
  20189. for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
  20190. order.push(new BidiSpan(0, start, i$7))
  20191. } else {
  20192. var pos = i$7, at = order.length
  20193. for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
  20194. for (var j$2 = pos; j$2 < i$7;) {
  20195. if (countsAsNum.test(types[j$2])) {
  20196. if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)) }
  20197. var nstart = j$2
  20198. for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
  20199. order.splice(at, 0, new BidiSpan(2, nstart, j$2))
  20200. pos = j$2
  20201. } else { ++j$2 }
  20202. }
  20203. if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)) }
  20204. }
  20205. }
  20206. if (order[0].level == 1 && (m = str.match(/^\s+/))) {
  20207. order[0].from = m[0].length
  20208. order.unshift(new BidiSpan(0, 0, m[0].length))
  20209. }
  20210. if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
  20211. lst(order).to -= m[0].length
  20212. order.push(new BidiSpan(0, len - m[0].length, len))
  20213. }
  20214. if (order[0].level == 2)
  20215. { order.unshift(new BidiSpan(1, order[0].to, order[0].to)) }
  20216. if (order[0].level != lst(order).level)
  20217. { order.push(new BidiSpan(order[0].level, len, len)) }
  20218. return order
  20219. }
  20220. })()
  20221. // Get the bidi ordering for the given line (and cache it). Returns
  20222. // false for lines that are fully left-to-right, and an array of
  20223. // BidiSpan objects otherwise.
  20224. function getOrder(line) {
  20225. var order = line.order
  20226. if (order == null) { order = line.order = bidiOrdering(line.text) }
  20227. return order
  20228. }
  20229. // EVENT HANDLING
  20230. // Lightweight event framework. on/off also work on DOM nodes,
  20231. // registering native DOM handlers.
  20232. var noHandlers = []
  20233. var on = function(emitter, type, f) {
  20234. if (emitter.addEventListener) {
  20235. emitter.addEventListener(type, f, false)
  20236. } else if (emitter.attachEvent) {
  20237. emitter.attachEvent("on" + type, f)
  20238. } else {
  20239. var map = emitter._handlers || (emitter._handlers = {})
  20240. map[type] = (map[type] || noHandlers).concat(f)
  20241. }
  20242. }
  20243. function getHandlers(emitter, type) {
  20244. return emitter._handlers && emitter._handlers[type] || noHandlers
  20245. }
  20246. function off(emitter, type, f) {
  20247. if (emitter.removeEventListener) {
  20248. emitter.removeEventListener(type, f, false)
  20249. } else if (emitter.detachEvent) {
  20250. emitter.detachEvent("on" + type, f)
  20251. } else {
  20252. var map = emitter._handlers, arr = map && map[type]
  20253. if (arr) {
  20254. var index = indexOf(arr, f)
  20255. if (index > -1)
  20256. { map[type] = arr.slice(0, index).concat(arr.slice(index + 1)) }
  20257. }
  20258. }
  20259. }
  20260. function signal(emitter, type /*, values...*/) {
  20261. var handlers = getHandlers(emitter, type)
  20262. if (!handlers.length) { return }
  20263. var args = Array.prototype.slice.call(arguments, 2)
  20264. for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args) }
  20265. }
  20266. // The DOM events that CodeMirror handles can be overridden by
  20267. // registering a (non-DOM) handler on the editor for the event name,
  20268. // and preventDefault-ing the event in that handler.
  20269. function signalDOMEvent(cm, e, override) {
  20270. if (typeof e == "string")
  20271. { e = {type: e, preventDefault: function() { this.defaultPrevented = true }} }
  20272. signal(cm, override || e.type, cm, e)
  20273. return e_defaultPrevented(e) || e.codemirrorIgnore
  20274. }
  20275. function signalCursorActivity(cm) {
  20276. var arr = cm._handlers && cm._handlers.cursorActivity
  20277. if (!arr) { return }
  20278. var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = [])
  20279. for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1)
  20280. { set.push(arr[i]) } }
  20281. }
  20282. function hasHandler(emitter, type) {
  20283. return getHandlers(emitter, type).length > 0
  20284. }
  20285. // Add on and off methods to a constructor's prototype, to make
  20286. // registering events on such objects more convenient.
  20287. function eventMixin(ctor) {
  20288. ctor.prototype.on = function(type, f) {on(this, type, f)}
  20289. ctor.prototype.off = function(type, f) {off(this, type, f)}
  20290. }
  20291. // Due to the fact that we still support jurassic IE versions, some
  20292. // compatibility wrappers are needed.
  20293. function e_preventDefault(e) {
  20294. if (e.preventDefault) { e.preventDefault() }
  20295. else { e.returnValue = false }
  20296. }
  20297. function e_stopPropagation(e) {
  20298. if (e.stopPropagation) { e.stopPropagation() }
  20299. else { e.cancelBubble = true }
  20300. }
  20301. function e_defaultPrevented(e) {
  20302. return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false
  20303. }
  20304. function e_stop(e) {e_preventDefault(e); e_stopPropagation(e)}
  20305. function e_target(e) {return e.target || e.srcElement}
  20306. function e_button(e) {
  20307. var b = e.which
  20308. if (b == null) {
  20309. if (e.button & 1) { b = 1 }
  20310. else if (e.button & 2) { b = 3 }
  20311. else if (e.button & 4) { b = 2 }
  20312. }
  20313. if (mac && e.ctrlKey && b == 1) { b = 3 }
  20314. return b
  20315. }
  20316. // Detect drag-and-drop
  20317. var dragAndDrop = function() {
  20318. // There is *some* kind of drag-and-drop support in IE6-8, but I
  20319. // couldn't get it to work yet.
  20320. if (ie && ie_version < 9) { return false }
  20321. var div = elt('div')
  20322. return "draggable" in div || "dragDrop" in div
  20323. }()
  20324. var zwspSupported
  20325. function zeroWidthElement(measure) {
  20326. if (zwspSupported == null) {
  20327. var test = elt("span", "\u200b")
  20328. removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]))
  20329. if (measure.firstChild.offsetHeight != 0)
  20330. { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8) }
  20331. }
  20332. var node = zwspSupported ? elt("span", "\u200b") :
  20333. elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px")
  20334. node.setAttribute("cm-text", "")
  20335. return node
  20336. }
  20337. // Feature-detect IE's crummy client rect reporting for bidi text
  20338. var badBidiRects
  20339. function hasBadBidiRects(measure) {
  20340. if (badBidiRects != null) { return badBidiRects }
  20341. var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"))
  20342. var r0 = range(txt, 0, 1).getBoundingClientRect()
  20343. var r1 = range(txt, 1, 2).getBoundingClientRect()
  20344. removeChildren(measure)
  20345. if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780)
  20346. return badBidiRects = (r1.right - r0.right < 3)
  20347. }
  20348. // See if "".split is the broken IE version, if so, provide an
  20349. // alternative way to split lines.
  20350. var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) {
  20351. var pos = 0, result = [], l = string.length
  20352. while (pos <= l) {
  20353. var nl = string.indexOf("\n", pos)
  20354. if (nl == -1) { nl = string.length }
  20355. var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl)
  20356. var rt = line.indexOf("\r")
  20357. if (rt != -1) {
  20358. result.push(line.slice(0, rt))
  20359. pos += rt + 1
  20360. } else {
  20361. result.push(line)
  20362. pos = nl + 1
  20363. }
  20364. }
  20365. return result
  20366. } : function (string) { return string.split(/\r\n?|\n/); }
  20367. var hasSelection = window.getSelection ? function (te) {
  20368. try { return te.selectionStart != te.selectionEnd }
  20369. catch(e) { return false }
  20370. } : function (te) {
  20371. var range
  20372. try {range = te.ownerDocument.selection.createRange()}
  20373. catch(e) {}
  20374. if (!range || range.parentElement() != te) { return false }
  20375. return range.compareEndPoints("StartToEnd", range) != 0
  20376. }
  20377. var hasCopyEvent = (function () {
  20378. var e = elt("div")
  20379. if ("oncopy" in e) { return true }
  20380. e.setAttribute("oncopy", "return;")
  20381. return typeof e.oncopy == "function"
  20382. })()
  20383. var badZoomedRects = null
  20384. function hasBadZoomedRects(measure) {
  20385. if (badZoomedRects != null) { return badZoomedRects }
  20386. var node = removeChildrenAndAdd(measure, elt("span", "x"))
  20387. var normal = node.getBoundingClientRect()
  20388. var fromRange = range(node, 0, 1).getBoundingClientRect()
  20389. return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1
  20390. }
  20391. var modes = {};
  20392. var mimeModes = {};
  20393. // Extra arguments are stored as the mode's dependencies, which is
  20394. // used by (legacy) mechanisms like loadmode.js to automatically
  20395. // load a mode. (Preferred mechanism is the require/define calls.)
  20396. function defineMode(name, mode) {
  20397. if (arguments.length > 2)
  20398. { mode.dependencies = Array.prototype.slice.call(arguments, 2) }
  20399. modes[name] = mode
  20400. }
  20401. function defineMIME(mime, spec) {
  20402. mimeModes[mime] = spec
  20403. }
  20404. // Given a MIME type, a {name, ...options} config object, or a name
  20405. // string, return a mode config object.
  20406. function resolveMode(spec) {
  20407. if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
  20408. spec = mimeModes[spec]
  20409. } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
  20410. var found = mimeModes[spec.name]
  20411. if (typeof found == "string") { found = {name: found} }
  20412. spec = createObj(found, spec)
  20413. spec.name = found.name
  20414. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
  20415. return resolveMode("application/xml")
  20416. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
  20417. return resolveMode("application/json")
  20418. }
  20419. if (typeof spec == "string") { return {name: spec} }
  20420. else { return spec || {name: "null"} }
  20421. }
  20422. // Given a mode spec (anything that resolveMode accepts), find and
  20423. // initialize an actual mode object.
  20424. function getMode(options, spec) {
  20425. spec = resolveMode(spec)
  20426. var mfactory = modes[spec.name]
  20427. if (!mfactory) { return getMode(options, "text/plain") }
  20428. var modeObj = mfactory(options, spec)
  20429. if (modeExtensions.hasOwnProperty(spec.name)) {
  20430. var exts = modeExtensions[spec.name]
  20431. for (var prop in exts) {
  20432. if (!exts.hasOwnProperty(prop)) { continue }
  20433. if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop] }
  20434. modeObj[prop] = exts[prop]
  20435. }
  20436. }
  20437. modeObj.name = spec.name
  20438. if (spec.helperType) { modeObj.helperType = spec.helperType }
  20439. if (spec.modeProps) { for (var prop$1 in spec.modeProps)
  20440. { modeObj[prop$1] = spec.modeProps[prop$1] } }
  20441. return modeObj
  20442. }
  20443. // This can be used to attach properties to mode objects from
  20444. // outside the actual mode definition.
  20445. var modeExtensions = {}
  20446. function extendMode(mode, properties) {
  20447. var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {})
  20448. copyObj(properties, exts)
  20449. }
  20450. function copyState(mode, state) {
  20451. if (state === true) { return state }
  20452. if (mode.copyState) { return mode.copyState(state) }
  20453. var nstate = {}
  20454. for (var n in state) {
  20455. var val = state[n]
  20456. if (val instanceof Array) { val = val.concat([]) }
  20457. nstate[n] = val
  20458. }
  20459. return nstate
  20460. }
  20461. // Given a mode and a state (for that mode), find the inner mode and
  20462. // state at the position that the state refers to.
  20463. function innerMode(mode, state) {
  20464. var info
  20465. while (mode.innerMode) {
  20466. info = mode.innerMode(state)
  20467. if (!info || info.mode == mode) { break }
  20468. state = info.state
  20469. mode = info.mode
  20470. }
  20471. return info || {mode: mode, state: state}
  20472. }
  20473. function startState(mode, a1, a2) {
  20474. return mode.startState ? mode.startState(a1, a2) : true
  20475. }
  20476. // STRING STREAM
  20477. // Fed to the mode parsers, provides helper functions to make
  20478. // parsers more succinct.
  20479. var StringStream = function(string, tabSize) {
  20480. this.pos = this.start = 0
  20481. this.string = string
  20482. this.tabSize = tabSize || 8
  20483. this.lastColumnPos = this.lastColumnValue = 0
  20484. this.lineStart = 0
  20485. }
  20486. StringStream.prototype = {
  20487. eol: function() {return this.pos >= this.string.length},
  20488. sol: function() {return this.pos == this.lineStart},
  20489. peek: function() {return this.string.charAt(this.pos) || undefined},
  20490. next: function() {
  20491. if (this.pos < this.string.length)
  20492. { return this.string.charAt(this.pos++) }
  20493. },
  20494. eat: function(match) {
  20495. var ch = this.string.charAt(this.pos)
  20496. var ok
  20497. if (typeof match == "string") { ok = ch == match }
  20498. else { ok = ch && (match.test ? match.test(ch) : match(ch)) }
  20499. if (ok) {++this.pos; return ch}
  20500. },
  20501. eatWhile: function(match) {
  20502. var start = this.pos
  20503. while (this.eat(match)){}
  20504. return this.pos > start
  20505. },
  20506. eatSpace: function() {
  20507. var this$1 = this;
  20508. var start = this.pos
  20509. while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos }
  20510. return this.pos > start
  20511. },
  20512. skipToEnd: function() {this.pos = this.string.length},
  20513. skipTo: function(ch) {
  20514. var found = this.string.indexOf(ch, this.pos)
  20515. if (found > -1) {this.pos = found; return true}
  20516. },
  20517. backUp: function(n) {this.pos -= n},
  20518. column: function() {
  20519. if (this.lastColumnPos < this.start) {
  20520. this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue)
  20521. this.lastColumnPos = this.start
  20522. }
  20523. return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
  20524. },
  20525. indentation: function() {
  20526. return countColumn(this.string, null, this.tabSize) -
  20527. (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
  20528. },
  20529. match: function(pattern, consume, caseInsensitive) {
  20530. if (typeof pattern == "string") {
  20531. var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; }
  20532. var substr = this.string.substr(this.pos, pattern.length)
  20533. if (cased(substr) == cased(pattern)) {
  20534. if (consume !== false) { this.pos += pattern.length }
  20535. return true
  20536. }
  20537. } else {
  20538. var match = this.string.slice(this.pos).match(pattern)
  20539. if (match && match.index > 0) { return null }
  20540. if (match && consume !== false) { this.pos += match[0].length }
  20541. return match
  20542. }
  20543. },
  20544. current: function(){return this.string.slice(this.start, this.pos)},
  20545. hideFirstChars: function(n, inner) {
  20546. this.lineStart += n
  20547. try { return inner() }
  20548. finally { this.lineStart -= n }
  20549. }
  20550. }
  20551. // Compute a style array (an array starting with a mode generation
  20552. // -- for invalidation -- followed by pairs of end positions and
  20553. // style strings), which is used to highlight the tokens on the
  20554. // line.
  20555. function highlightLine(cm, line, state, forceToEnd) {
  20556. // A styles array always starts with a number identifying the
  20557. // mode/overlays that it is based on (for easy invalidation).
  20558. var st = [cm.state.modeGen], lineClasses = {}
  20559. // Compute the base array of styles
  20560. runMode(cm, line.text, cm.doc.mode, state, function (end, style) { return st.push(end, style); },
  20561. lineClasses, forceToEnd)
  20562. // Run overlays, adjust style array.
  20563. var loop = function ( o ) {
  20564. var overlay = cm.state.overlays[o], i = 1, at = 0
  20565. runMode(cm, line.text, overlay.mode, true, function (end, style) {
  20566. var start = i
  20567. // Ensure there's a token end at the current position, and that i points at it
  20568. while (at < end) {
  20569. var i_end = st[i]
  20570. if (i_end > end)
  20571. { st.splice(i, 1, end, st[i+1], i_end) }
  20572. i += 2
  20573. at = Math.min(end, i_end)
  20574. }
  20575. if (!style) { return }
  20576. if (overlay.opaque) {
  20577. st.splice(start, i - start, end, "overlay " + style)
  20578. i = start + 2
  20579. } else {
  20580. for (; start < i; start += 2) {
  20581. var cur = st[start+1]
  20582. st[start+1] = (cur ? cur + " " : "") + "overlay " + style
  20583. }
  20584. }
  20585. }, lineClasses)
  20586. };
  20587. for (var o = 0; o < cm.state.overlays.length; ++o) loop( o );
  20588. return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}
  20589. }
  20590. function getLineStyles(cm, line, updateFrontier) {
  20591. if (!line.styles || line.styles[0] != cm.state.modeGen) {
  20592. var state = getStateBefore(cm, lineNo(line))
  20593. var result = highlightLine(cm, line, line.text.length > cm.options.maxHighlightLength ? copyState(cm.doc.mode, state) : state)
  20594. line.stateAfter = state
  20595. line.styles = result.styles
  20596. if (result.classes) { line.styleClasses = result.classes }
  20597. else if (line.styleClasses) { line.styleClasses = null }
  20598. if (updateFrontier === cm.doc.frontier) { cm.doc.frontier++ }
  20599. }
  20600. return line.styles
  20601. }
  20602. function getStateBefore(cm, n, precise) {
  20603. var doc = cm.doc, display = cm.display
  20604. if (!doc.mode.startState) { return true }
  20605. var pos = findStartLine(cm, n, precise), state = pos > doc.first && getLine(doc, pos-1).stateAfter
  20606. if (!state) { state = startState(doc.mode) }
  20607. else { state = copyState(doc.mode, state) }
  20608. doc.iter(pos, n, function (line) {
  20609. processLine(cm, line.text, state)
  20610. var save = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo
  20611. line.stateAfter = save ? copyState(doc.mode, state) : null
  20612. ++pos
  20613. })
  20614. if (precise) { doc.frontier = pos }
  20615. return state
  20616. }
  20617. // Lightweight form of highlight -- proceed over this line and
  20618. // update state, but don't save a style array. Used for lines that
  20619. // aren't currently visible.
  20620. function processLine(cm, text, state, startAt) {
  20621. var mode = cm.doc.mode
  20622. var stream = new StringStream(text, cm.options.tabSize)
  20623. stream.start = stream.pos = startAt || 0
  20624. if (text == "") { callBlankLine(mode, state) }
  20625. while (!stream.eol()) {
  20626. readToken(mode, stream, state)
  20627. stream.start = stream.pos
  20628. }
  20629. }
  20630. function callBlankLine(mode, state) {
  20631. if (mode.blankLine) { return mode.blankLine(state) }
  20632. if (!mode.innerMode) { return }
  20633. var inner = innerMode(mode, state)
  20634. if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) }
  20635. }
  20636. function readToken(mode, stream, state, inner) {
  20637. for (var i = 0; i < 10; i++) {
  20638. if (inner) { inner[0] = innerMode(mode, state).mode }
  20639. var style = mode.token(stream, state)
  20640. if (stream.pos > stream.start) { return style }
  20641. }
  20642. throw new Error("Mode " + mode.name + " failed to advance stream.")
  20643. }
  20644. // Utility for getTokenAt and getLineTokens
  20645. function takeToken(cm, pos, precise, asArray) {
  20646. var getObj = function (copy) { return ({
  20647. start: stream.start, end: stream.pos,
  20648. string: stream.current(),
  20649. type: style || null,
  20650. state: copy ? copyState(doc.mode, state) : state
  20651. }); }
  20652. var doc = cm.doc, mode = doc.mode, style
  20653. pos = clipPos(doc, pos)
  20654. var line = getLine(doc, pos.line), state = getStateBefore(cm, pos.line, precise)
  20655. var stream = new StringStream(line.text, cm.options.tabSize), tokens
  20656. if (asArray) { tokens = [] }
  20657. while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
  20658. stream.start = stream.pos
  20659. style = readToken(mode, stream, state)
  20660. if (asArray) { tokens.push(getObj(true)) }
  20661. }
  20662. return asArray ? tokens : getObj()
  20663. }
  20664. function extractLineClasses(type, output) {
  20665. if (type) { for (;;) {
  20666. var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/)
  20667. if (!lineClass) { break }
  20668. type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length)
  20669. var prop = lineClass[1] ? "bgClass" : "textClass"
  20670. if (output[prop] == null)
  20671. { output[prop] = lineClass[2] }
  20672. else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
  20673. { output[prop] += " " + lineClass[2] }
  20674. } }
  20675. return type
  20676. }
  20677. // Run the given mode's parser over a line, calling f for each token.
  20678. function runMode(cm, text, mode, state, f, lineClasses, forceToEnd) {
  20679. var flattenSpans = mode.flattenSpans
  20680. if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans }
  20681. var curStart = 0, curStyle = null
  20682. var stream = new StringStream(text, cm.options.tabSize), style
  20683. var inner = cm.options.addModeClass && [null]
  20684. if (text == "") { extractLineClasses(callBlankLine(mode, state), lineClasses) }
  20685. while (!stream.eol()) {
  20686. if (stream.pos > cm.options.maxHighlightLength) {
  20687. flattenSpans = false
  20688. if (forceToEnd) { processLine(cm, text, state, stream.pos) }
  20689. stream.pos = text.length
  20690. style = null
  20691. } else {
  20692. style = extractLineClasses(readToken(mode, stream, state, inner), lineClasses)
  20693. }
  20694. if (inner) {
  20695. var mName = inner[0].name
  20696. if (mName) { style = "m-" + (style ? mName + " " + style : mName) }
  20697. }
  20698. if (!flattenSpans || curStyle != style) {
  20699. while (curStart < stream.start) {
  20700. curStart = Math.min(stream.start, curStart + 5000)
  20701. f(curStart, curStyle)
  20702. }
  20703. curStyle = style
  20704. }
  20705. stream.start = stream.pos
  20706. }
  20707. while (curStart < stream.pos) {
  20708. // Webkit seems to refuse to render text nodes longer than 57444
  20709. // characters, and returns inaccurate measurements in nodes
  20710. // starting around 5000 chars.
  20711. var pos = Math.min(stream.pos, curStart + 5000)
  20712. f(pos, curStyle)
  20713. curStart = pos
  20714. }
  20715. }
  20716. // Finds the line to start with when starting a parse. Tries to
  20717. // find a line with a stateAfter, so that it can start with a
  20718. // valid state. If that fails, it returns the line with the
  20719. // smallest indentation, which tends to need the least context to
  20720. // parse correctly.
  20721. function findStartLine(cm, n, precise) {
  20722. var minindent, minline, doc = cm.doc
  20723. var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100)
  20724. for (var search = n; search > lim; --search) {
  20725. if (search <= doc.first) { return doc.first }
  20726. var line = getLine(doc, search - 1)
  20727. if (line.stateAfter && (!precise || search <= doc.frontier)) { return search }
  20728. var indented = countColumn(line.text, null, cm.options.tabSize)
  20729. if (minline == null || minindent > indented) {
  20730. minline = search - 1
  20731. minindent = indented
  20732. }
  20733. }
  20734. return minline
  20735. }
  20736. // LINE DATA STRUCTURE
  20737. // Line objects. These hold state related to a line, including
  20738. // highlighting info (the styles array).
  20739. function Line(text, markedSpans, estimateHeight) {
  20740. this.text = text
  20741. attachMarkedSpans(this, markedSpans)
  20742. this.height = estimateHeight ? estimateHeight(this) : 1
  20743. }
  20744. eventMixin(Line)
  20745. Line.prototype.lineNo = function() { return lineNo(this) }
  20746. // Change the content (text, markers) of a line. Automatically
  20747. // invalidates cached information and tries to re-estimate the
  20748. // line's height.
  20749. function updateLine(line, text, markedSpans, estimateHeight) {
  20750. line.text = text
  20751. if (line.stateAfter) { line.stateAfter = null }
  20752. if (line.styles) { line.styles = null }
  20753. if (line.order != null) { line.order = null }
  20754. detachMarkedSpans(line)
  20755. attachMarkedSpans(line, markedSpans)
  20756. var estHeight = estimateHeight ? estimateHeight(line) : 1
  20757. if (estHeight != line.height) { updateLineHeight(line, estHeight) }
  20758. }
  20759. // Detach a line from the document tree and its markers.
  20760. function cleanUpLine(line) {
  20761. line.parent = null
  20762. detachMarkedSpans(line)
  20763. }
  20764. // Convert a style as returned by a mode (either null, or a string
  20765. // containing one or more styles) to a CSS style. This is cached,
  20766. // and also looks for line-wide styles.
  20767. var styleToClassCache = {};
  20768. var styleToClassCacheWithMode = {};
  20769. function interpretTokenStyle(style, options) {
  20770. if (!style || /^\s*$/.test(style)) { return null }
  20771. var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache
  20772. return cache[style] ||
  20773. (cache[style] = style.replace(/\S+/g, "cm-$&"))
  20774. }
  20775. // Render the DOM representation of the text of a line. Also builds
  20776. // up a 'line map', which points at the DOM nodes that represent
  20777. // specific stretches of text, and is used by the measuring code.
  20778. // The returned object contains the DOM node, this map, and
  20779. // information about line-wide styles that were set by the mode.
  20780. function buildLineContent(cm, lineView) {
  20781. // The padding-right forces the element to have a 'border', which
  20782. // is needed on Webkit to be able to get line-level bounding
  20783. // rectangles for it (in measureChar).
  20784. var content = elt("span", null, null, webkit ? "padding-right: .1px" : null)
  20785. var builder = {pre: elt("pre", [content], "CodeMirror-line"), content: content,
  20786. col: 0, pos: 0, cm: cm,
  20787. trailingSpace: false,
  20788. splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")}
  20789. // hide from accessibility tree
  20790. content.setAttribute("role", "presentation")
  20791. builder.pre.setAttribute("role", "presentation")
  20792. lineView.measure = {}
  20793. // Iterate over the logical lines that make up this visual line.
  20794. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
  20795. var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0)
  20796. builder.pos = 0
  20797. builder.addToken = buildToken
  20798. // Optionally wire in some hacks into the token-rendering
  20799. // algorithm, to deal with browser quirks.
  20800. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line)))
  20801. { builder.addToken = buildTokenBadBidi(builder.addToken, order) }
  20802. builder.map = []
  20803. var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line)
  20804. insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate))
  20805. if (line.styleClasses) {
  20806. if (line.styleClasses.bgClass)
  20807. { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || "") }
  20808. if (line.styleClasses.textClass)
  20809. { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || "") }
  20810. }
  20811. // Ensure at least a single node is present, for measuring.
  20812. if (builder.map.length == 0)
  20813. { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))) }
  20814. // Store the map and a cache object for the current logical line
  20815. if (i == 0) {
  20816. lineView.measure.map = builder.map
  20817. lineView.measure.cache = {}
  20818. } else {
  20819. ;(lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)
  20820. ;(lineView.measure.caches || (lineView.measure.caches = [])).push({})
  20821. }
  20822. }
  20823. // See issue #2901
  20824. if (webkit) {
  20825. var last = builder.content.lastChild
  20826. if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
  20827. { builder.content.className = "cm-tab-wrap-hack" }
  20828. }
  20829. signal(cm, "renderLine", cm, lineView.line, builder.pre)
  20830. if (builder.pre.className)
  20831. { builder.textClass = joinClasses(builder.pre.className, builder.textClass || "") }
  20832. return builder
  20833. }
  20834. function defaultSpecialCharPlaceholder(ch) {
  20835. var token = elt("span", "\u2022", "cm-invalidchar")
  20836. token.title = "\\u" + ch.charCodeAt(0).toString(16)
  20837. token.setAttribute("aria-label", token.title)
  20838. return token
  20839. }
  20840. // Build up the DOM representation for a single token, and add it to
  20841. // the line map. Takes care to render special characters separately.
  20842. function buildToken(builder, text, style, startStyle, endStyle, title, css) {
  20843. if (!text) { return }
  20844. var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text
  20845. var special = builder.cm.state.specialChars, mustWrap = false
  20846. var content
  20847. if (!special.test(text)) {
  20848. builder.col += text.length
  20849. content = document.createTextNode(displayText)
  20850. builder.map.push(builder.pos, builder.pos + text.length, content)
  20851. if (ie && ie_version < 9) { mustWrap = true }
  20852. builder.pos += text.length
  20853. } else {
  20854. content = document.createDocumentFragment()
  20855. var pos = 0
  20856. while (true) {
  20857. special.lastIndex = pos
  20858. var m = special.exec(text)
  20859. var skipped = m ? m.index - pos : text.length - pos
  20860. if (skipped) {
  20861. var txt = document.createTextNode(displayText.slice(pos, pos + skipped))
  20862. if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])) }
  20863. else { content.appendChild(txt) }
  20864. builder.map.push(builder.pos, builder.pos + skipped, txt)
  20865. builder.col += skipped
  20866. builder.pos += skipped
  20867. }
  20868. if (!m) { break }
  20869. pos += skipped + 1
  20870. var txt$1 = (void 0)
  20871. if (m[0] == "\t") {
  20872. var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize
  20873. txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"))
  20874. txt$1.setAttribute("role", "presentation")
  20875. txt$1.setAttribute("cm-text", "\t")
  20876. builder.col += tabWidth
  20877. } else if (m[0] == "\r" || m[0] == "\n") {
  20878. txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"))
  20879. txt$1.setAttribute("cm-text", m[0])
  20880. builder.col += 1
  20881. } else {
  20882. txt$1 = builder.cm.options.specialCharPlaceholder(m[0])
  20883. txt$1.setAttribute("cm-text", m[0])
  20884. if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])) }
  20885. else { content.appendChild(txt$1) }
  20886. builder.col += 1
  20887. }
  20888. builder.map.push(builder.pos, builder.pos + 1, txt$1)
  20889. builder.pos++
  20890. }
  20891. }
  20892. builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32
  20893. if (style || startStyle || endStyle || mustWrap || css) {
  20894. var fullStyle = style || ""
  20895. if (startStyle) { fullStyle += startStyle }
  20896. if (endStyle) { fullStyle += endStyle }
  20897. var token = elt("span", [content], fullStyle, css)
  20898. if (title) { token.title = title }
  20899. return builder.content.appendChild(token)
  20900. }
  20901. builder.content.appendChild(content)
  20902. }
  20903. function splitSpaces(text, trailingBefore) {
  20904. if (text.length > 1 && !/ /.test(text)) { return text }
  20905. var spaceBefore = trailingBefore, result = ""
  20906. for (var i = 0; i < text.length; i++) {
  20907. var ch = text.charAt(i)
  20908. if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
  20909. { ch = "\u00a0" }
  20910. result += ch
  20911. spaceBefore = ch == " "
  20912. }
  20913. return result
  20914. }
  20915. // Work around nonsense dimensions being reported for stretches of
  20916. // right-to-left text.
  20917. function buildTokenBadBidi(inner, order) {
  20918. return function (builder, text, style, startStyle, endStyle, title, css) {
  20919. style = style ? style + " cm-force-border" : "cm-force-border"
  20920. var start = builder.pos, end = start + text.length
  20921. for (;;) {
  20922. // Find the part that overlaps with the start of this text
  20923. var part = (void 0)
  20924. for (var i = 0; i < order.length; i++) {
  20925. part = order[i]
  20926. if (part.to > start && part.from <= start) { break }
  20927. }
  20928. if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, title, css) }
  20929. inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css)
  20930. startStyle = null
  20931. text = text.slice(part.to - start)
  20932. start = part.to
  20933. }
  20934. }
  20935. }
  20936. function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
  20937. var widget = !ignoreWidget && marker.widgetNode
  20938. if (widget) { builder.map.push(builder.pos, builder.pos + size, widget) }
  20939. if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
  20940. if (!widget)
  20941. { widget = builder.content.appendChild(document.createElement("span")) }
  20942. widget.setAttribute("cm-marker", marker.id)
  20943. }
  20944. if (widget) {
  20945. builder.cm.display.input.setUneditable(widget)
  20946. builder.content.appendChild(widget)
  20947. }
  20948. builder.pos += size
  20949. builder.trailingSpace = false
  20950. }
  20951. // Outputs a number of spans to make up a line, taking highlighting
  20952. // and marked text into account.
  20953. function insertLineContent(line, builder, styles) {
  20954. var spans = line.markedSpans, allText = line.text, at = 0
  20955. if (!spans) {
  20956. for (var i$1 = 1; i$1 < styles.length; i$1+=2)
  20957. { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)) }
  20958. return
  20959. }
  20960. var len = allText.length, pos = 0, i = 1, text = "", style, css
  20961. var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed
  20962. for (;;) {
  20963. if (nextChange == pos) { // Update current marker set
  20964. spanStyle = spanEndStyle = spanStartStyle = title = css = ""
  20965. collapsed = null; nextChange = Infinity
  20966. var foundBookmarks = [], endStyles = (void 0)
  20967. for (var j = 0; j < spans.length; ++j) {
  20968. var sp = spans[j], m = sp.marker
  20969. if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
  20970. foundBookmarks.push(m)
  20971. } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
  20972. if (sp.to != null && sp.to != pos && nextChange > sp.to) {
  20973. nextChange = sp.to
  20974. spanEndStyle = ""
  20975. }
  20976. if (m.className) { spanStyle += " " + m.className }
  20977. if (m.css) { css = (css ? css + ";" : "") + m.css }
  20978. if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle }
  20979. if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to) }
  20980. if (m.title && !title) { title = m.title }
  20981. if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
  20982. { collapsed = sp }
  20983. } else if (sp.from > pos && nextChange > sp.from) {
  20984. nextChange = sp.from
  20985. }
  20986. }
  20987. if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2)
  20988. { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1] } } }
  20989. if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)
  20990. { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]) } }
  20991. if (collapsed && (collapsed.from || 0) == pos) {
  20992. buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
  20993. collapsed.marker, collapsed.from == null)
  20994. if (collapsed.to == null) { return }
  20995. if (collapsed.to == pos) { collapsed = false }
  20996. }
  20997. }
  20998. if (pos >= len) { break }
  20999. var upto = Math.min(len, nextChange)
  21000. while (true) {
  21001. if (text) {
  21002. var end = pos + text.length
  21003. if (!collapsed) {
  21004. var tokenText = end > upto ? text.slice(0, upto - pos) : text
  21005. builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
  21006. spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css)
  21007. }
  21008. if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}
  21009. pos = end
  21010. spanStartStyle = ""
  21011. }
  21012. text = allText.slice(at, at = styles[i++])
  21013. style = interpretTokenStyle(styles[i++], builder.cm.options)
  21014. }
  21015. }
  21016. }
  21017. // These objects are used to represent the visible (currently drawn)
  21018. // part of the document. A LineView may correspond to multiple
  21019. // logical lines, if those are connected by collapsed ranges.
  21020. function LineView(doc, line, lineN) {
  21021. // The starting line
  21022. this.line = line
  21023. // Continuing lines, if any
  21024. this.rest = visualLineContinued(line)
  21025. // Number of logical lines in this visual line
  21026. this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1
  21027. this.node = this.text = null
  21028. this.hidden = lineIsHidden(doc, line)
  21029. }
  21030. // Create a range of LineView objects for the given lines.
  21031. function buildViewArray(cm, from, to) {
  21032. var array = [], nextPos
  21033. for (var pos = from; pos < to; pos = nextPos) {
  21034. var view = new LineView(cm.doc, getLine(cm.doc, pos), pos)
  21035. nextPos = pos + view.size
  21036. array.push(view)
  21037. }
  21038. return array
  21039. }
  21040. var operationGroup = null
  21041. function pushOperation(op) {
  21042. if (operationGroup) {
  21043. operationGroup.ops.push(op)
  21044. } else {
  21045. op.ownsGroup = operationGroup = {
  21046. ops: [op],
  21047. delayedCallbacks: []
  21048. }
  21049. }
  21050. }
  21051. function fireCallbacksForOps(group) {
  21052. // Calls delayed callbacks and cursorActivity handlers until no
  21053. // new ones appear
  21054. var callbacks = group.delayedCallbacks, i = 0
  21055. do {
  21056. for (; i < callbacks.length; i++)
  21057. { callbacks[i].call(null) }
  21058. for (var j = 0; j < group.ops.length; j++) {
  21059. var op = group.ops[j]
  21060. if (op.cursorActivityHandlers)
  21061. { while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
  21062. { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm) } }
  21063. }
  21064. } while (i < callbacks.length)
  21065. }
  21066. function finishOperation(op, endCb) {
  21067. var group = op.ownsGroup
  21068. if (!group) { return }
  21069. try { fireCallbacksForOps(group) }
  21070. finally {
  21071. operationGroup = null
  21072. endCb(group)
  21073. }
  21074. }
  21075. var orphanDelayedCallbacks = null
  21076. // Often, we want to signal events at a point where we are in the
  21077. // middle of some work, but don't want the handler to start calling
  21078. // other methods on the editor, which might be in an inconsistent
  21079. // state or simply not expect any other events to happen.
  21080. // signalLater looks whether there are any handlers, and schedules
  21081. // them to be executed when the last operation ends, or, if no
  21082. // operation is active, when a timeout fires.
  21083. function signalLater(emitter, type /*, values...*/) {
  21084. var arr = getHandlers(emitter, type)
  21085. if (!arr.length) { return }
  21086. var args = Array.prototype.slice.call(arguments, 2), list
  21087. if (operationGroup) {
  21088. list = operationGroup.delayedCallbacks
  21089. } else if (orphanDelayedCallbacks) {
  21090. list = orphanDelayedCallbacks
  21091. } else {
  21092. list = orphanDelayedCallbacks = []
  21093. setTimeout(fireOrphanDelayed, 0)
  21094. }
  21095. var loop = function ( i ) {
  21096. list.push(function () { return arr[i].apply(null, args); })
  21097. };
  21098. for (var i = 0; i < arr.length; ++i)
  21099. loop( i );
  21100. }
  21101. function fireOrphanDelayed() {
  21102. var delayed = orphanDelayedCallbacks
  21103. orphanDelayedCallbacks = null
  21104. for (var i = 0; i < delayed.length; ++i) { delayed[i]() }
  21105. }
  21106. // When an aspect of a line changes, a string is added to
  21107. // lineView.changes. This updates the relevant part of the line's
  21108. // DOM structure.
  21109. function updateLineForChanges(cm, lineView, lineN, dims) {
  21110. for (var j = 0; j < lineView.changes.length; j++) {
  21111. var type = lineView.changes[j]
  21112. if (type == "text") { updateLineText(cm, lineView) }
  21113. else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims) }
  21114. else if (type == "class") { updateLineClasses(lineView) }
  21115. else if (type == "widget") { updateLineWidgets(cm, lineView, dims) }
  21116. }
  21117. lineView.changes = null
  21118. }
  21119. // Lines with gutter elements, widgets or a background class need to
  21120. // be wrapped, and have the extra elements added to the wrapper div
  21121. function ensureLineWrapped(lineView) {
  21122. if (lineView.node == lineView.text) {
  21123. lineView.node = elt("div", null, null, "position: relative")
  21124. if (lineView.text.parentNode)
  21125. { lineView.text.parentNode.replaceChild(lineView.node, lineView.text) }
  21126. lineView.node.appendChild(lineView.text)
  21127. if (ie && ie_version < 8) { lineView.node.style.zIndex = 2 }
  21128. }
  21129. return lineView.node
  21130. }
  21131. function updateLineBackground(lineView) {
  21132. var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass
  21133. if (cls) { cls += " CodeMirror-linebackground" }
  21134. if (lineView.background) {
  21135. if (cls) { lineView.background.className = cls }
  21136. else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null }
  21137. } else if (cls) {
  21138. var wrap = ensureLineWrapped(lineView)
  21139. lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild)
  21140. }
  21141. }
  21142. // Wrapper around buildLineContent which will reuse the structure
  21143. // in display.externalMeasured when possible.
  21144. function getLineContent(cm, lineView) {
  21145. var ext = cm.display.externalMeasured
  21146. if (ext && ext.line == lineView.line) {
  21147. cm.display.externalMeasured = null
  21148. lineView.measure = ext.measure
  21149. return ext.built
  21150. }
  21151. return buildLineContent(cm, lineView)
  21152. }
  21153. // Redraw the line's text. Interacts with the background and text
  21154. // classes because the mode may output tokens that influence these
  21155. // classes.
  21156. function updateLineText(cm, lineView) {
  21157. var cls = lineView.text.className
  21158. var built = getLineContent(cm, lineView)
  21159. if (lineView.text == lineView.node) { lineView.node = built.pre }
  21160. lineView.text.parentNode.replaceChild(built.pre, lineView.text)
  21161. lineView.text = built.pre
  21162. if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
  21163. lineView.bgClass = built.bgClass
  21164. lineView.textClass = built.textClass
  21165. updateLineClasses(lineView)
  21166. } else if (cls) {
  21167. lineView.text.className = cls
  21168. }
  21169. }
  21170. function updateLineClasses(lineView) {
  21171. updateLineBackground(lineView)
  21172. if (lineView.line.wrapClass)
  21173. { ensureLineWrapped(lineView).className = lineView.line.wrapClass }
  21174. else if (lineView.node != lineView.text)
  21175. { lineView.node.className = "" }
  21176. var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass
  21177. lineView.text.className = textClass || ""
  21178. }
  21179. function updateLineGutter(cm, lineView, lineN, dims) {
  21180. if (lineView.gutter) {
  21181. lineView.node.removeChild(lineView.gutter)
  21182. lineView.gutter = null
  21183. }
  21184. if (lineView.gutterBackground) {
  21185. lineView.node.removeChild(lineView.gutterBackground)
  21186. lineView.gutterBackground = null
  21187. }
  21188. if (lineView.line.gutterClass) {
  21189. var wrap = ensureLineWrapped(lineView)
  21190. lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
  21191. ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px"))
  21192. wrap.insertBefore(lineView.gutterBackground, lineView.text)
  21193. }
  21194. var markers = lineView.line.gutterMarkers
  21195. if (cm.options.lineNumbers || markers) {
  21196. var wrap$1 = ensureLineWrapped(lineView)
  21197. var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"))
  21198. cm.display.input.setUneditable(gutterWrap)
  21199. wrap$1.insertBefore(gutterWrap, lineView.text)
  21200. if (lineView.line.gutterClass)
  21201. { gutterWrap.className += " " + lineView.line.gutterClass }
  21202. if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
  21203. { lineView.lineNumber = gutterWrap.appendChild(
  21204. elt("div", lineNumberFor(cm.options, lineN),
  21205. "CodeMirror-linenumber CodeMirror-gutter-elt",
  21206. ("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))) }
  21207. if (markers) { for (var k = 0; k < cm.options.gutters.length; ++k) {
  21208. var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id]
  21209. if (found)
  21210. { gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt",
  21211. ("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))) }
  21212. } }
  21213. }
  21214. }
  21215. function updateLineWidgets(cm, lineView, dims) {
  21216. if (lineView.alignable) { lineView.alignable = null }
  21217. for (var node = lineView.node.firstChild, next = (void 0); node; node = next) {
  21218. next = node.nextSibling
  21219. if (node.className == "CodeMirror-linewidget")
  21220. { lineView.node.removeChild(node) }
  21221. }
  21222. insertLineWidgets(cm, lineView, dims)
  21223. }
  21224. // Build a line's DOM representation from scratch
  21225. function buildLineElement(cm, lineView, lineN, dims) {
  21226. var built = getLineContent(cm, lineView)
  21227. lineView.text = lineView.node = built.pre
  21228. if (built.bgClass) { lineView.bgClass = built.bgClass }
  21229. if (built.textClass) { lineView.textClass = built.textClass }
  21230. updateLineClasses(lineView)
  21231. updateLineGutter(cm, lineView, lineN, dims)
  21232. insertLineWidgets(cm, lineView, dims)
  21233. return lineView.node
  21234. }
  21235. // A lineView may contain multiple logical lines (when merged by
  21236. // collapsed spans). The widgets for all of them need to be drawn.
  21237. function insertLineWidgets(cm, lineView, dims) {
  21238. insertLineWidgetsFor(cm, lineView.line, lineView, dims, true)
  21239. if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
  21240. { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false) } }
  21241. }
  21242. function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
  21243. if (!line.widgets) { return }
  21244. var wrap = ensureLineWrapped(lineView)
  21245. for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
  21246. var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget")
  21247. if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true") }
  21248. positionLineWidget(widget, node, lineView, dims)
  21249. cm.display.input.setUneditable(node)
  21250. if (allowAbove && widget.above)
  21251. { wrap.insertBefore(node, lineView.gutter || lineView.text) }
  21252. else
  21253. { wrap.appendChild(node) }
  21254. signalLater(widget, "redraw")
  21255. }
  21256. }
  21257. function positionLineWidget(widget, node, lineView, dims) {
  21258. if (widget.noHScroll) {
  21259. ;(lineView.alignable || (lineView.alignable = [])).push(node)
  21260. var width = dims.wrapperWidth
  21261. node.style.left = dims.fixedPos + "px"
  21262. if (!widget.coverGutter) {
  21263. width -= dims.gutterTotalWidth
  21264. node.style.paddingLeft = dims.gutterTotalWidth + "px"
  21265. }
  21266. node.style.width = width + "px"
  21267. }
  21268. if (widget.coverGutter) {
  21269. node.style.zIndex = 5
  21270. node.style.position = "relative"
  21271. if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px" }
  21272. }
  21273. }
  21274. function widgetHeight(widget) {
  21275. if (widget.height != null) { return widget.height }
  21276. var cm = widget.doc.cm
  21277. if (!cm) { return 0 }
  21278. if (!contains(document.body, widget.node)) {
  21279. var parentStyle = "position: relative;"
  21280. if (widget.coverGutter)
  21281. { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;" }
  21282. if (widget.noHScroll)
  21283. { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;" }
  21284. removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle))
  21285. }
  21286. return widget.height = widget.node.parentNode.offsetHeight
  21287. }
  21288. // Return true when the given mouse event happened in a widget
  21289. function eventInWidget(display, e) {
  21290. for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
  21291. if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
  21292. (n.parentNode == display.sizer && n != display.mover))
  21293. { return true }
  21294. }
  21295. }
  21296. // POSITION MEASUREMENT
  21297. function paddingTop(display) {return display.lineSpace.offsetTop}
  21298. function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}
  21299. function paddingH(display) {
  21300. if (display.cachedPaddingH) { return display.cachedPaddingH }
  21301. var e = removeChildrenAndAdd(display.measure, elt("pre", "x"))
  21302. var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle
  21303. var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)}
  21304. if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data }
  21305. return data
  21306. }
  21307. function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth }
  21308. function displayWidth(cm) {
  21309. return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth
  21310. }
  21311. function displayHeight(cm) {
  21312. return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight
  21313. }
  21314. // Ensure the lineView.wrapping.heights array is populated. This is
  21315. // an array of bottom offsets for the lines that make up a drawn
  21316. // line. When lineWrapping is on, there might be more than one
  21317. // height.
  21318. function ensureLineHeights(cm, lineView, rect) {
  21319. var wrapping = cm.options.lineWrapping
  21320. var curWidth = wrapping && displayWidth(cm)
  21321. if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
  21322. var heights = lineView.measure.heights = []
  21323. if (wrapping) {
  21324. lineView.measure.width = curWidth
  21325. var rects = lineView.text.firstChild.getClientRects()
  21326. for (var i = 0; i < rects.length - 1; i++) {
  21327. var cur = rects[i], next = rects[i + 1]
  21328. if (Math.abs(cur.bottom - next.bottom) > 2)
  21329. { heights.push((cur.bottom + next.top) / 2 - rect.top) }
  21330. }
  21331. }
  21332. heights.push(rect.bottom - rect.top)
  21333. }
  21334. }
  21335. // Find a line map (mapping character offsets to text nodes) and a
  21336. // measurement cache for the given line number. (A line view might
  21337. // contain multiple lines when collapsed ranges are present.)
  21338. function mapFromLineView(lineView, line, lineN) {
  21339. if (lineView.line == line)
  21340. { return {map: lineView.measure.map, cache: lineView.measure.cache} }
  21341. for (var i = 0; i < lineView.rest.length; i++)
  21342. { if (lineView.rest[i] == line)
  21343. { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
  21344. for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
  21345. { if (lineNo(lineView.rest[i$1]) > lineN)
  21346. { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
  21347. }
  21348. // Render a line into the hidden node display.externalMeasured. Used
  21349. // when measurement is needed for a line that's not in the viewport.
  21350. function updateExternalMeasurement(cm, line) {
  21351. line = visualLine(line)
  21352. var lineN = lineNo(line)
  21353. var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN)
  21354. view.lineN = lineN
  21355. var built = view.built = buildLineContent(cm, view)
  21356. view.text = built.pre
  21357. removeChildrenAndAdd(cm.display.lineMeasure, built.pre)
  21358. return view
  21359. }
  21360. // Get a {top, bottom, left, right} box (in line-local coordinates)
  21361. // for a given character.
  21362. function measureChar(cm, line, ch, bias) {
  21363. return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)
  21364. }
  21365. // Find a line view that corresponds to the given line number.
  21366. function findViewForLine(cm, lineN) {
  21367. if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
  21368. { return cm.display.view[findViewIndex(cm, lineN)] }
  21369. var ext = cm.display.externalMeasured
  21370. if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
  21371. { return ext }
  21372. }
  21373. // Measurement can be split in two steps, the set-up work that
  21374. // applies to the whole line, and the measurement of the actual
  21375. // character. Functions like coordsChar, that need to do a lot of
  21376. // measurements in a row, can thus ensure that the set-up work is
  21377. // only done once.
  21378. function prepareMeasureForLine(cm, line) {
  21379. var lineN = lineNo(line)
  21380. var view = findViewForLine(cm, lineN)
  21381. if (view && !view.text) {
  21382. view = null
  21383. } else if (view && view.changes) {
  21384. updateLineForChanges(cm, view, lineN, getDimensions(cm))
  21385. cm.curOp.forceUpdate = true
  21386. }
  21387. if (!view)
  21388. { view = updateExternalMeasurement(cm, line) }
  21389. var info = mapFromLineView(view, line, lineN)
  21390. return {
  21391. line: line, view: view, rect: null,
  21392. map: info.map, cache: info.cache, before: info.before,
  21393. hasHeights: false
  21394. }
  21395. }
  21396. // Given a prepared measurement object, measures the position of an
  21397. // actual character (or fetches it from the cache).
  21398. function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
  21399. if (prepared.before) { ch = -1 }
  21400. var key = ch + (bias || ""), found
  21401. if (prepared.cache.hasOwnProperty(key)) {
  21402. found = prepared.cache[key]
  21403. } else {
  21404. if (!prepared.rect)
  21405. { prepared.rect = prepared.view.text.getBoundingClientRect() }
  21406. if (!prepared.hasHeights) {
  21407. ensureLineHeights(cm, prepared.view, prepared.rect)
  21408. prepared.hasHeights = true
  21409. }
  21410. found = measureCharInner(cm, prepared, ch, bias)
  21411. if (!found.bogus) { prepared.cache[key] = found }
  21412. }
  21413. return {left: found.left, right: found.right,
  21414. top: varHeight ? found.rtop : found.top,
  21415. bottom: varHeight ? found.rbottom : found.bottom}
  21416. }
  21417. var nullRect = {left: 0, right: 0, top: 0, bottom: 0}
  21418. function nodeAndOffsetInLineMap(map, ch, bias) {
  21419. var node, start, end, collapse, mStart, mEnd
  21420. // First, search the line map for the text node corresponding to,
  21421. // or closest to, the target character.
  21422. for (var i = 0; i < map.length; i += 3) {
  21423. mStart = map[i]
  21424. mEnd = map[i + 1]
  21425. if (ch < mStart) {
  21426. start = 0; end = 1
  21427. collapse = "left"
  21428. } else if (ch < mEnd) {
  21429. start = ch - mStart
  21430. end = start + 1
  21431. } else if (i == map.length - 3 || ch == mEnd && map[i + 3] > ch) {
  21432. end = mEnd - mStart
  21433. start = end - 1
  21434. if (ch >= mEnd) { collapse = "right" }
  21435. }
  21436. if (start != null) {
  21437. node = map[i + 2]
  21438. if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
  21439. { collapse = bias }
  21440. if (bias == "left" && start == 0)
  21441. { while (i && map[i - 2] == map[i - 3] && map[i - 1].insertLeft) {
  21442. node = map[(i -= 3) + 2]
  21443. collapse = "left"
  21444. } }
  21445. if (bias == "right" && start == mEnd - mStart)
  21446. { while (i < map.length - 3 && map[i + 3] == map[i + 4] && !map[i + 5].insertLeft) {
  21447. node = map[(i += 3) + 2]
  21448. collapse = "right"
  21449. } }
  21450. break
  21451. }
  21452. }
  21453. return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}
  21454. }
  21455. function getUsefulRect(rects, bias) {
  21456. var rect = nullRect
  21457. if (bias == "left") { for (var i = 0; i < rects.length; i++) {
  21458. if ((rect = rects[i]).left != rect.right) { break }
  21459. } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {
  21460. if ((rect = rects[i$1]).left != rect.right) { break }
  21461. } }
  21462. return rect
  21463. }
  21464. function measureCharInner(cm, prepared, ch, bias) {
  21465. var place = nodeAndOffsetInLineMap(prepared.map, ch, bias)
  21466. var node = place.node, start = place.start, end = place.end, collapse = place.collapse
  21467. var rect
  21468. if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
  21469. for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned
  21470. while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start }
  21471. while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end }
  21472. if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
  21473. { rect = node.parentNode.getBoundingClientRect() }
  21474. else
  21475. { rect = getUsefulRect(range(node, start, end).getClientRects(), bias) }
  21476. if (rect.left || rect.right || start == 0) { break }
  21477. end = start
  21478. start = start - 1
  21479. collapse = "right"
  21480. }
  21481. if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect) }
  21482. } else { // If it is a widget, simply get the box for the whole widget.
  21483. if (start > 0) { collapse = bias = "right" }
  21484. var rects
  21485. if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
  21486. { rect = rects[bias == "right" ? rects.length - 1 : 0] }
  21487. else
  21488. { rect = node.getBoundingClientRect() }
  21489. }
  21490. if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
  21491. var rSpan = node.parentNode.getClientRects()[0]
  21492. if (rSpan)
  21493. { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom} }
  21494. else
  21495. { rect = nullRect }
  21496. }
  21497. var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top
  21498. var mid = (rtop + rbot) / 2
  21499. var heights = prepared.view.measure.heights
  21500. var i = 0
  21501. for (; i < heights.length - 1; i++)
  21502. { if (mid < heights[i]) { break } }
  21503. var top = i ? heights[i - 1] : 0, bot = heights[i]
  21504. var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
  21505. right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
  21506. top: top, bottom: bot}
  21507. if (!rect.left && !rect.right) { result.bogus = true }
  21508. if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot }
  21509. return result
  21510. }
  21511. // Work around problem with bounding client rects on ranges being
  21512. // returned incorrectly when zoomed on IE10 and below.
  21513. function maybeUpdateRectForZooming(measure, rect) {
  21514. if (!window.screen || screen.logicalXDPI == null ||
  21515. screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
  21516. { return rect }
  21517. var scaleX = screen.logicalXDPI / screen.deviceXDPI
  21518. var scaleY = screen.logicalYDPI / screen.deviceYDPI
  21519. return {left: rect.left * scaleX, right: rect.right * scaleX,
  21520. top: rect.top * scaleY, bottom: rect.bottom * scaleY}
  21521. }
  21522. function clearLineMeasurementCacheFor(lineView) {
  21523. if (lineView.measure) {
  21524. lineView.measure.cache = {}
  21525. lineView.measure.heights = null
  21526. if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
  21527. { lineView.measure.caches[i] = {} } }
  21528. }
  21529. }
  21530. function clearLineMeasurementCache(cm) {
  21531. cm.display.externalMeasure = null
  21532. removeChildren(cm.display.lineMeasure)
  21533. for (var i = 0; i < cm.display.view.length; i++)
  21534. { clearLineMeasurementCacheFor(cm.display.view[i]) }
  21535. }
  21536. function clearCaches(cm) {
  21537. clearLineMeasurementCache(cm)
  21538. cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null
  21539. if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true }
  21540. cm.display.lineNumChars = null
  21541. }
  21542. function pageScrollX() { return window.pageXOffset || (document.documentElement || document.body).scrollLeft }
  21543. function pageScrollY() { return window.pageYOffset || (document.documentElement || document.body).scrollTop }
  21544. // Converts a {top, bottom, left, right} box from line-local
  21545. // coordinates into another coordinate system. Context may be one of
  21546. // "line", "div" (display.lineDiv), "local"./null (editor), "window",
  21547. // or "page".
  21548. function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
  21549. if (!includeWidgets && lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above) {
  21550. var size = widgetHeight(lineObj.widgets[i])
  21551. rect.top += size; rect.bottom += size
  21552. } } }
  21553. if (context == "line") { return rect }
  21554. if (!context) { context = "local" }
  21555. var yOff = heightAtLine(lineObj)
  21556. if (context == "local") { yOff += paddingTop(cm.display) }
  21557. else { yOff -= cm.display.viewOffset }
  21558. if (context == "page" || context == "window") {
  21559. var lOff = cm.display.lineSpace.getBoundingClientRect()
  21560. yOff += lOff.top + (context == "window" ? 0 : pageScrollY())
  21561. var xOff = lOff.left + (context == "window" ? 0 : pageScrollX())
  21562. rect.left += xOff; rect.right += xOff
  21563. }
  21564. rect.top += yOff; rect.bottom += yOff
  21565. return rect
  21566. }
  21567. // Coverts a box from "div" coords to another coordinate system.
  21568. // Context may be "window", "page", "div", or "local"./null.
  21569. function fromCoordSystem(cm, coords, context) {
  21570. if (context == "div") { return coords }
  21571. var left = coords.left, top = coords.top
  21572. // First move into "page" coordinate system
  21573. if (context == "page") {
  21574. left -= pageScrollX()
  21575. top -= pageScrollY()
  21576. } else if (context == "local" || !context) {
  21577. var localBox = cm.display.sizer.getBoundingClientRect()
  21578. left += localBox.left
  21579. top += localBox.top
  21580. }
  21581. var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect()
  21582. return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}
  21583. }
  21584. function charCoords(cm, pos, context, lineObj, bias) {
  21585. if (!lineObj) { lineObj = getLine(cm.doc, pos.line) }
  21586. return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context)
  21587. }
  21588. // Returns a box for a given cursor position, which may have an
  21589. // 'other' property containing the position of the secondary cursor
  21590. // on a bidi boundary.
  21591. function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
  21592. lineObj = lineObj || getLine(cm.doc, pos.line)
  21593. if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj) }
  21594. function get(ch, right) {
  21595. var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight)
  21596. if (right) { m.left = m.right; } else { m.right = m.left }
  21597. return intoCoordSystem(cm, lineObj, m, context)
  21598. }
  21599. function getBidi(ch, partPos) {
  21600. var part = order[partPos], right = part.level % 2
  21601. if (ch == bidiLeft(part) && partPos && part.level < order[partPos - 1].level) {
  21602. part = order[--partPos]
  21603. ch = bidiRight(part) - (part.level % 2 ? 0 : 1)
  21604. right = true
  21605. } else if (ch == bidiRight(part) && partPos < order.length - 1 && part.level < order[partPos + 1].level) {
  21606. part = order[++partPos]
  21607. ch = bidiLeft(part) - part.level % 2
  21608. right = false
  21609. }
  21610. if (right && ch == part.to && ch > part.from) { return get(ch - 1) }
  21611. return get(ch, right)
  21612. }
  21613. var order = getOrder(lineObj), ch = pos.ch
  21614. if (!order) { return get(ch) }
  21615. var partPos = getBidiPartAt(order, ch)
  21616. var val = getBidi(ch, partPos)
  21617. if (bidiOther != null) { val.other = getBidi(ch, bidiOther) }
  21618. return val
  21619. }
  21620. // Used to cheaply estimate the coordinates for a position. Used for
  21621. // intermediate scroll updates.
  21622. function estimateCoords(cm, pos) {
  21623. var left = 0
  21624. pos = clipPos(cm.doc, pos)
  21625. if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch }
  21626. var lineObj = getLine(cm.doc, pos.line)
  21627. var top = heightAtLine(lineObj) + paddingTop(cm.display)
  21628. return {left: left, right: left, top: top, bottom: top + lineObj.height}
  21629. }
  21630. // Positions returned by coordsChar contain some extra information.
  21631. // xRel is the relative x position of the input coordinates compared
  21632. // to the found position (so xRel > 0 means the coordinates are to
  21633. // the right of the character position, for example). When outside
  21634. // is true, that means the coordinates lie outside the line's
  21635. // vertical range.
  21636. function PosWithInfo(line, ch, outside, xRel) {
  21637. var pos = Pos(line, ch)
  21638. pos.xRel = xRel
  21639. if (outside) { pos.outside = true }
  21640. return pos
  21641. }
  21642. // Compute the character position closest to the given coordinates.
  21643. // Input must be lineSpace-local ("div" coordinate system).
  21644. function coordsChar(cm, x, y) {
  21645. var doc = cm.doc
  21646. y += cm.display.viewOffset
  21647. if (y < 0) { return PosWithInfo(doc.first, 0, true, -1) }
  21648. var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1
  21649. if (lineN > last)
  21650. { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, true, 1) }
  21651. if (x < 0) { x = 0 }
  21652. var lineObj = getLine(doc, lineN)
  21653. for (;;) {
  21654. var found = coordsCharInner(cm, lineObj, lineN, x, y)
  21655. var merged = collapsedSpanAtEnd(lineObj)
  21656. var mergedPos = merged && merged.find(0, true)
  21657. if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
  21658. { lineN = lineNo(lineObj = mergedPos.to.line) }
  21659. else
  21660. { return found }
  21661. }
  21662. }
  21663. function coordsCharInner(cm, lineObj, lineNo, x, y) {
  21664. var innerOff = y - heightAtLine(lineObj)
  21665. var wrongLine = false, adjust = 2 * cm.display.wrapper.clientWidth
  21666. var preparedMeasure = prepareMeasureForLine(cm, lineObj)
  21667. function getX(ch) {
  21668. var sp = cursorCoords(cm, Pos(lineNo, ch), "line", lineObj, preparedMeasure)
  21669. wrongLine = true
  21670. if (innerOff > sp.bottom) { return sp.left - adjust }
  21671. else if (innerOff < sp.top) { return sp.left + adjust }
  21672. else { wrongLine = false }
  21673. return sp.left
  21674. }
  21675. var bidi = getOrder(lineObj), dist = lineObj.text.length
  21676. var from = lineLeft(lineObj), to = lineRight(lineObj)
  21677. var fromX = getX(from), fromOutside = wrongLine, toX = getX(to), toOutside = wrongLine
  21678. if (x > toX) { return PosWithInfo(lineNo, to, toOutside, 1) }
  21679. // Do a binary search between these bounds.
  21680. for (;;) {
  21681. if (bidi ? to == from || to == moveVisually(lineObj, from, 1) : to - from <= 1) {
  21682. var ch = x < fromX || x - fromX <= toX - x ? from : to
  21683. var outside = ch == from ? fromOutside : toOutside
  21684. var xDiff = x - (ch == from ? fromX : toX)
  21685. // This is a kludge to handle the case where the coordinates
  21686. // are after a line-wrapped line. We should replace it with a
  21687. // more general handling of cursor positions around line
  21688. // breaks. (Issue #4078)
  21689. if (toOutside && !bidi && !/\s/.test(lineObj.text.charAt(ch)) && xDiff > 0 &&
  21690. ch < lineObj.text.length && preparedMeasure.view.measure.heights.length > 1) {
  21691. var charSize = measureCharPrepared(cm, preparedMeasure, ch, "right")
  21692. if (innerOff <= charSize.bottom && innerOff >= charSize.top && Math.abs(x - charSize.right) < xDiff) {
  21693. outside = false
  21694. ch++
  21695. xDiff = x - charSize.right
  21696. }
  21697. }
  21698. while (isExtendingChar(lineObj.text.charAt(ch))) { ++ch }
  21699. var pos = PosWithInfo(lineNo, ch, outside, xDiff < -1 ? -1 : xDiff > 1 ? 1 : 0)
  21700. return pos
  21701. }
  21702. var step = Math.ceil(dist / 2), middle = from + step
  21703. if (bidi) {
  21704. middle = from
  21705. for (var i = 0; i < step; ++i) { middle = moveVisually(lineObj, middle, 1) }
  21706. }
  21707. var middleX = getX(middle)
  21708. if (middleX > x) {to = middle; toX = middleX; if (toOutside = wrongLine) { toX += 1000; } dist = step}
  21709. else {from = middle; fromX = middleX; fromOutside = wrongLine; dist -= step}
  21710. }
  21711. }
  21712. var measureText
  21713. // Compute the default text height.
  21714. function textHeight(display) {
  21715. if (display.cachedTextHeight != null) { return display.cachedTextHeight }
  21716. if (measureText == null) {
  21717. measureText = elt("pre")
  21718. // Measure a bunch of lines, for browsers that compute
  21719. // fractional heights.
  21720. for (var i = 0; i < 49; ++i) {
  21721. measureText.appendChild(document.createTextNode("x"))
  21722. measureText.appendChild(elt("br"))
  21723. }
  21724. measureText.appendChild(document.createTextNode("x"))
  21725. }
  21726. removeChildrenAndAdd(display.measure, measureText)
  21727. var height = measureText.offsetHeight / 50
  21728. if (height > 3) { display.cachedTextHeight = height }
  21729. removeChildren(display.measure)
  21730. return height || 1
  21731. }
  21732. // Compute the default character width.
  21733. function charWidth(display) {
  21734. if (display.cachedCharWidth != null) { return display.cachedCharWidth }
  21735. var anchor = elt("span", "xxxxxxxxxx")
  21736. var pre = elt("pre", [anchor])
  21737. removeChildrenAndAdd(display.measure, pre)
  21738. var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10
  21739. if (width > 2) { display.cachedCharWidth = width }
  21740. return width || 10
  21741. }
  21742. // Do a bulk-read of the DOM positions and sizes needed to draw the
  21743. // view, so that we don't interleave reading and writing to the DOM.
  21744. function getDimensions(cm) {
  21745. var d = cm.display, left = {}, width = {}
  21746. var gutterLeft = d.gutters.clientLeft
  21747. for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
  21748. left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft
  21749. width[cm.options.gutters[i]] = n.clientWidth
  21750. }
  21751. return {fixedPos: compensateForHScroll(d),
  21752. gutterTotalWidth: d.gutters.offsetWidth,
  21753. gutterLeft: left,
  21754. gutterWidth: width,
  21755. wrapperWidth: d.wrapper.clientWidth}
  21756. }
  21757. // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
  21758. // but using getBoundingClientRect to get a sub-pixel-accurate
  21759. // result.
  21760. function compensateForHScroll(display) {
  21761. return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left
  21762. }
  21763. // Returns a function that estimates the height of a line, to use as
  21764. // first approximation until the line becomes visible (and is thus
  21765. // properly measurable).
  21766. function estimateHeight(cm) {
  21767. var th = textHeight(cm.display), wrapping = cm.options.lineWrapping
  21768. var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3)
  21769. return function (line) {
  21770. if (lineIsHidden(cm.doc, line)) { return 0 }
  21771. var widgetsHeight = 0
  21772. if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {
  21773. if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height }
  21774. } }
  21775. if (wrapping)
  21776. { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }
  21777. else
  21778. { return widgetsHeight + th }
  21779. }
  21780. }
  21781. function estimateLineHeights(cm) {
  21782. var doc = cm.doc, est = estimateHeight(cm)
  21783. doc.iter(function (line) {
  21784. var estHeight = est(line)
  21785. if (estHeight != line.height) { updateLineHeight(line, estHeight) }
  21786. })
  21787. }
  21788. // Given a mouse event, find the corresponding position. If liberal
  21789. // is false, it checks whether a gutter or scrollbar was clicked,
  21790. // and returns null if it was. forRect is used by rectangular
  21791. // selections, and tries to estimate a character position even for
  21792. // coordinates beyond the right of the text.
  21793. function posFromMouse(cm, e, liberal, forRect) {
  21794. var display = cm.display
  21795. if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null }
  21796. var x, y, space = display.lineSpace.getBoundingClientRect()
  21797. // Fails unpredictably on IE[67] when mouse is dragged around quickly.
  21798. try { x = e.clientX - space.left; y = e.clientY - space.top }
  21799. catch (e) { return null }
  21800. var coords = coordsChar(cm, x, y), line
  21801. if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
  21802. var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length
  21803. coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff))
  21804. }
  21805. return coords
  21806. }
  21807. // Find the view element corresponding to a given line. Return null
  21808. // when the line isn't visible.
  21809. function findViewIndex(cm, n) {
  21810. if (n >= cm.display.viewTo) { return null }
  21811. n -= cm.display.viewFrom
  21812. if (n < 0) { return null }
  21813. var view = cm.display.view
  21814. for (var i = 0; i < view.length; i++) {
  21815. n -= view[i].size
  21816. if (n < 0) { return i }
  21817. }
  21818. }
  21819. function updateSelection(cm) {
  21820. cm.display.input.showSelection(cm.display.input.prepareSelection())
  21821. }
  21822. function prepareSelection(cm, primary) {
  21823. var doc = cm.doc, result = {}
  21824. var curFragment = result.cursors = document.createDocumentFragment()
  21825. var selFragment = result.selection = document.createDocumentFragment()
  21826. for (var i = 0; i < doc.sel.ranges.length; i++) {
  21827. if (primary === false && i == doc.sel.primIndex) { continue }
  21828. var range = doc.sel.ranges[i]
  21829. if (range.from().line >= cm.display.viewTo || range.to().line < cm.display.viewFrom) { continue }
  21830. var collapsed = range.empty()
  21831. if (collapsed || cm.options.showCursorWhenSelecting)
  21832. { drawSelectionCursor(cm, range.head, curFragment) }
  21833. if (!collapsed)
  21834. { drawSelectionRange(cm, range, selFragment) }
  21835. }
  21836. return result
  21837. }
  21838. // Draws a cursor for the given range
  21839. function drawSelectionCursor(cm, head, output) {
  21840. var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine)
  21841. var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"))
  21842. cursor.style.left = pos.left + "px"
  21843. cursor.style.top = pos.top + "px"
  21844. cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px"
  21845. if (pos.other) {
  21846. // Secondary cursor, shown when on a 'jump' in bi-directional text
  21847. var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"))
  21848. otherCursor.style.display = ""
  21849. otherCursor.style.left = pos.other.left + "px"
  21850. otherCursor.style.top = pos.other.top + "px"
  21851. otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px"
  21852. }
  21853. }
  21854. // Draws the given range as a highlighted selection
  21855. function drawSelectionRange(cm, range, output) {
  21856. var display = cm.display, doc = cm.doc
  21857. var fragment = document.createDocumentFragment()
  21858. var padding = paddingH(cm.display), leftSide = padding.left
  21859. var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right
  21860. function add(left, top, width, bottom) {
  21861. if (top < 0) { top = 0 }
  21862. top = Math.round(top)
  21863. bottom = Math.round(bottom)
  21864. fragment.appendChild(elt("div", null, "CodeMirror-selected", ("position: absolute; left: " + left + "px;\n top: " + top + "px; width: " + (width == null ? rightSide - left : width) + "px;\n height: " + (bottom - top) + "px")))
  21865. }
  21866. function drawForLine(line, fromArg, toArg) {
  21867. var lineObj = getLine(doc, line)
  21868. var lineLen = lineObj.text.length
  21869. var start, end
  21870. function coords(ch, bias) {
  21871. return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
  21872. }
  21873. iterateBidiSections(getOrder(lineObj), fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir) {
  21874. var leftPos = coords(from, "left"), rightPos, left, right
  21875. if (from == to) {
  21876. rightPos = leftPos
  21877. left = right = leftPos.left
  21878. } else {
  21879. rightPos = coords(to - 1, "right")
  21880. if (dir == "rtl") { var tmp = leftPos; leftPos = rightPos; rightPos = tmp }
  21881. left = leftPos.left
  21882. right = rightPos.right
  21883. }
  21884. if (fromArg == null && from == 0) { left = leftSide }
  21885. if (rightPos.top - leftPos.top > 3) { // Different lines, draw top part
  21886. add(left, leftPos.top, null, leftPos.bottom)
  21887. left = leftSide
  21888. if (leftPos.bottom < rightPos.top) { add(left, leftPos.bottom, null, rightPos.top) }
  21889. }
  21890. if (toArg == null && to == lineLen) { right = rightSide }
  21891. if (!start || leftPos.top < start.top || leftPos.top == start.top && leftPos.left < start.left)
  21892. { start = leftPos }
  21893. if (!end || rightPos.bottom > end.bottom || rightPos.bottom == end.bottom && rightPos.right > end.right)
  21894. { end = rightPos }
  21895. if (left < leftSide + 1) { left = leftSide }
  21896. add(left, rightPos.top, right - left, rightPos.bottom)
  21897. })
  21898. return {start: start, end: end}
  21899. }
  21900. var sFrom = range.from(), sTo = range.to()
  21901. if (sFrom.line == sTo.line) {
  21902. drawForLine(sFrom.line, sFrom.ch, sTo.ch)
  21903. } else {
  21904. var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line)
  21905. var singleVLine = visualLine(fromLine) == visualLine(toLine)
  21906. var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end
  21907. var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start
  21908. if (singleVLine) {
  21909. if (leftEnd.top < rightStart.top - 2) {
  21910. add(leftEnd.right, leftEnd.top, null, leftEnd.bottom)
  21911. add(leftSide, rightStart.top, rightStart.left, rightStart.bottom)
  21912. } else {
  21913. add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom)
  21914. }
  21915. }
  21916. if (leftEnd.bottom < rightStart.top)
  21917. { add(leftSide, leftEnd.bottom, null, rightStart.top) }
  21918. }
  21919. output.appendChild(fragment)
  21920. }
  21921. // Cursor-blinking
  21922. function restartBlink(cm) {
  21923. if (!cm.state.focused) { return }
  21924. var display = cm.display
  21925. clearInterval(display.blinker)
  21926. var on = true
  21927. display.cursorDiv.style.visibility = ""
  21928. if (cm.options.cursorBlinkRate > 0)
  21929. { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; },
  21930. cm.options.cursorBlinkRate) }
  21931. else if (cm.options.cursorBlinkRate < 0)
  21932. { display.cursorDiv.style.visibility = "hidden" }
  21933. }
  21934. function ensureFocus(cm) {
  21935. if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm) }
  21936. }
  21937. function delayBlurEvent(cm) {
  21938. cm.state.delayingBlurEvent = true
  21939. setTimeout(function () { if (cm.state.delayingBlurEvent) {
  21940. cm.state.delayingBlurEvent = false
  21941. onBlur(cm)
  21942. } }, 100)
  21943. }
  21944. function onFocus(cm, e) {
  21945. if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false }
  21946. if (cm.options.readOnly == "nocursor") { return }
  21947. if (!cm.state.focused) {
  21948. signal(cm, "focus", cm, e)
  21949. cm.state.focused = true
  21950. addClass(cm.display.wrapper, "CodeMirror-focused")
  21951. // This test prevents this from firing when a context
  21952. // menu is closed (since the input reset would kill the
  21953. // select-all detection hack)
  21954. if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
  21955. cm.display.input.reset()
  21956. if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20) } // Issue #1730
  21957. }
  21958. cm.display.input.receivedFocus()
  21959. }
  21960. restartBlink(cm)
  21961. }
  21962. function onBlur(cm, e) {
  21963. if (cm.state.delayingBlurEvent) { return }
  21964. if (cm.state.focused) {
  21965. signal(cm, "blur", cm, e)
  21966. cm.state.focused = false
  21967. rmClass(cm.display.wrapper, "CodeMirror-focused")
  21968. }
  21969. clearInterval(cm.display.blinker)
  21970. setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false } }, 150)
  21971. }
  21972. // Re-align line numbers and gutter marks to compensate for
  21973. // horizontal scrolling.
  21974. function alignHorizontally(cm) {
  21975. var display = cm.display, view = display.view
  21976. if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return }
  21977. var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft
  21978. var gutterW = display.gutters.offsetWidth, left = comp + "px"
  21979. for (var i = 0; i < view.length; i++) { if (!view[i].hidden) {
  21980. if (cm.options.fixedGutter) {
  21981. if (view[i].gutter)
  21982. { view[i].gutter.style.left = left }
  21983. if (view[i].gutterBackground)
  21984. { view[i].gutterBackground.style.left = left }
  21985. }
  21986. var align = view[i].alignable
  21987. if (align) { for (var j = 0; j < align.length; j++)
  21988. { align[j].style.left = left } }
  21989. } }
  21990. if (cm.options.fixedGutter)
  21991. { display.gutters.style.left = (comp + gutterW) + "px" }
  21992. }
  21993. // Used to ensure that the line number gutter is still the right
  21994. // size for the current document size. Returns true when an update
  21995. // is needed.
  21996. function maybeUpdateLineNumberWidth(cm) {
  21997. if (!cm.options.lineNumbers) { return false }
  21998. var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display
  21999. if (last.length != display.lineNumChars) {
  22000. var test = display.measure.appendChild(elt("div", [elt("div", last)],
  22001. "CodeMirror-linenumber CodeMirror-gutter-elt"))
  22002. var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW
  22003. display.lineGutter.style.width = ""
  22004. display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1
  22005. display.lineNumWidth = display.lineNumInnerWidth + padding
  22006. display.lineNumChars = display.lineNumInnerWidth ? last.length : -1
  22007. display.lineGutter.style.width = display.lineNumWidth + "px"
  22008. updateGutterSpace(cm)
  22009. return true
  22010. }
  22011. return false
  22012. }
  22013. // Read the actual heights of the rendered lines, and update their
  22014. // stored heights to match.
  22015. function updateHeightsInViewport(cm) {
  22016. var display = cm.display
  22017. var prevBottom = display.lineDiv.offsetTop
  22018. for (var i = 0; i < display.view.length; i++) {
  22019. var cur = display.view[i], height = (void 0)
  22020. if (cur.hidden) { continue }
  22021. if (ie && ie_version < 8) {
  22022. var bot = cur.node.offsetTop + cur.node.offsetHeight
  22023. height = bot - prevBottom
  22024. prevBottom = bot
  22025. } else {
  22026. var box = cur.node.getBoundingClientRect()
  22027. height = box.bottom - box.top
  22028. }
  22029. var diff = cur.line.height - height
  22030. if (height < 2) { height = textHeight(display) }
  22031. if (diff > .001 || diff < -.001) {
  22032. updateLineHeight(cur.line, height)
  22033. updateWidgetHeight(cur.line)
  22034. if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
  22035. { updateWidgetHeight(cur.rest[j]) } }
  22036. }
  22037. }
  22038. }
  22039. // Read and store the height of line widgets associated with the
  22040. // given line.
  22041. function updateWidgetHeight(line) {
  22042. if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i)
  22043. { line.widgets[i].height = line.widgets[i].node.parentNode.offsetHeight } }
  22044. }
  22045. // Compute the lines that are visible in a given viewport (defaults
  22046. // the the current scroll position). viewport may contain top,
  22047. // height, and ensure (see op.scrollToPos) properties.
  22048. function visibleLines(display, doc, viewport) {
  22049. var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop
  22050. top = Math.floor(top - paddingTop(display))
  22051. var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight
  22052. var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom)
  22053. // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
  22054. // forces those lines into the viewport (if possible).
  22055. if (viewport && viewport.ensure) {
  22056. var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line
  22057. if (ensureFrom < from) {
  22058. from = ensureFrom
  22059. to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight)
  22060. } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
  22061. from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight)
  22062. to = ensureTo
  22063. }
  22064. }
  22065. return {from: from, to: Math.max(to, from + 1)}
  22066. }
  22067. // Sync the scrollable area and scrollbars, ensure the viewport
  22068. // covers the visible area.
  22069. function setScrollTop(cm, val) {
  22070. if (Math.abs(cm.doc.scrollTop - val) < 2) { return }
  22071. cm.doc.scrollTop = val
  22072. if (!gecko) { updateDisplaySimple(cm, {top: val}) }
  22073. if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val }
  22074. cm.display.scrollbars.setScrollTop(val)
  22075. if (gecko) { updateDisplaySimple(cm) }
  22076. startWorker(cm, 100)
  22077. }
  22078. // Sync scroller and scrollbar, ensure the gutter elements are
  22079. // aligned.
  22080. function setScrollLeft(cm, val, isScroller) {
  22081. if (isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) { return }
  22082. val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth)
  22083. cm.doc.scrollLeft = val
  22084. alignHorizontally(cm)
  22085. if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val }
  22086. cm.display.scrollbars.setScrollLeft(val)
  22087. }
  22088. // Since the delta values reported on mouse wheel events are
  22089. // unstandardized between browsers and even browser versions, and
  22090. // generally horribly unpredictable, this code starts by measuring
  22091. // the scroll effect that the first few mouse wheel events have,
  22092. // and, from that, detects the way it can convert deltas to pixel
  22093. // offsets afterwards.
  22094. //
  22095. // The reason we want to know the amount a wheel event will scroll
  22096. // is that it gives us a chance to update the display before the
  22097. // actual scrolling happens, reducing flickering.
  22098. var wheelSamples = 0;
  22099. var wheelPixelsPerUnit = null;
  22100. // Fill in a browser-detected starting value on browsers where we
  22101. // know one. These don't have to be accurate -- the result of them
  22102. // being wrong would just be a slight flicker on the first wheel
  22103. // scroll (if it is large enough).
  22104. if (ie) { wheelPixelsPerUnit = -.53 }
  22105. else if (gecko) { wheelPixelsPerUnit = 15 }
  22106. else if (chrome) { wheelPixelsPerUnit = -.7 }
  22107. else if (safari) { wheelPixelsPerUnit = -1/3 }
  22108. function wheelEventDelta(e) {
  22109. var dx = e.wheelDeltaX, dy = e.wheelDeltaY
  22110. if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail }
  22111. if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail }
  22112. else if (dy == null) { dy = e.wheelDelta }
  22113. return {x: dx, y: dy}
  22114. }
  22115. function wheelEventPixels(e) {
  22116. var delta = wheelEventDelta(e)
  22117. delta.x *= wheelPixelsPerUnit
  22118. delta.y *= wheelPixelsPerUnit
  22119. return delta
  22120. }
  22121. function onScrollWheel(cm, e) {
  22122. var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y
  22123. var display = cm.display, scroll = display.scroller
  22124. // Quit if there's nothing to scroll here
  22125. var canScrollX = scroll.scrollWidth > scroll.clientWidth
  22126. var canScrollY = scroll.scrollHeight > scroll.clientHeight
  22127. if (!(dx && canScrollX || dy && canScrollY)) { return }
  22128. // Webkit browsers on OS X abort momentum scrolls when the target
  22129. // of the scroll event is removed from the scrollable element.
  22130. // This hack (see related code in patchDisplay) makes sure the
  22131. // element is kept around.
  22132. if (dy && mac && webkit) {
  22133. outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
  22134. for (var i = 0; i < view.length; i++) {
  22135. if (view[i].node == cur) {
  22136. cm.display.currentWheelTarget = cur
  22137. break outer
  22138. }
  22139. }
  22140. }
  22141. }
  22142. // On some browsers, horizontal scrolling will cause redraws to
  22143. // happen before the gutter has been realigned, causing it to
  22144. // wriggle around in a most unseemly way. When we have an
  22145. // estimated pixels/delta value, we just handle horizontal
  22146. // scrolling entirely here. It'll be slightly off from native, but
  22147. // better than glitching out.
  22148. if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
  22149. if (dy && canScrollY)
  22150. { setScrollTop(cm, Math.max(0, Math.min(scroll.scrollTop + dy * wheelPixelsPerUnit, scroll.scrollHeight - scroll.clientHeight))) }
  22151. setScrollLeft(cm, Math.max(0, Math.min(scroll.scrollLeft + dx * wheelPixelsPerUnit, scroll.scrollWidth - scroll.clientWidth)))
  22152. // Only prevent default scrolling if vertical scrolling is
  22153. // actually possible. Otherwise, it causes vertical scroll
  22154. // jitter on OSX trackpads when deltaX is small and deltaY
  22155. // is large (issue #3579)
  22156. if (!dy || (dy && canScrollY))
  22157. { e_preventDefault(e) }
  22158. display.wheelStartX = null // Abort measurement, if in progress
  22159. return
  22160. }
  22161. // 'Project' the visible viewport to cover the area that is being
  22162. // scrolled into view (if we know enough to estimate it).
  22163. if (dy && wheelPixelsPerUnit != null) {
  22164. var pixels = dy * wheelPixelsPerUnit
  22165. var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight
  22166. if (pixels < 0) { top = Math.max(0, top + pixels - 50) }
  22167. else { bot = Math.min(cm.doc.height, bot + pixels + 50) }
  22168. updateDisplaySimple(cm, {top: top, bottom: bot})
  22169. }
  22170. if (wheelSamples < 20) {
  22171. if (display.wheelStartX == null) {
  22172. display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop
  22173. display.wheelDX = dx; display.wheelDY = dy
  22174. setTimeout(function () {
  22175. if (display.wheelStartX == null) { return }
  22176. var movedX = scroll.scrollLeft - display.wheelStartX
  22177. var movedY = scroll.scrollTop - display.wheelStartY
  22178. var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
  22179. (movedX && display.wheelDX && movedX / display.wheelDX)
  22180. display.wheelStartX = display.wheelStartY = null
  22181. if (!sample) { return }
  22182. wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1)
  22183. ++wheelSamples
  22184. }, 200)
  22185. } else {
  22186. display.wheelDX += dx; display.wheelDY += dy
  22187. }
  22188. }
  22189. }
  22190. // SCROLLBARS
  22191. // Prepare DOM reads needed to update the scrollbars. Done in one
  22192. // shot to minimize update/measure roundtrips.
  22193. function measureForScrollbars(cm) {
  22194. var d = cm.display, gutterW = d.gutters.offsetWidth
  22195. var docH = Math.round(cm.doc.height + paddingVert(cm.display))
  22196. return {
  22197. clientHeight: d.scroller.clientHeight,
  22198. viewHeight: d.wrapper.clientHeight,
  22199. scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
  22200. viewWidth: d.wrapper.clientWidth,
  22201. barLeft: cm.options.fixedGutter ? gutterW : 0,
  22202. docHeight: docH,
  22203. scrollHeight: docH + scrollGap(cm) + d.barHeight,
  22204. nativeBarWidth: d.nativeBarWidth,
  22205. gutterWidth: gutterW
  22206. }
  22207. }
  22208. var NativeScrollbars = function(place, scroll, cm) {
  22209. this.cm = cm
  22210. var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar")
  22211. var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar")
  22212. place(vert); place(horiz)
  22213. on(vert, "scroll", function () {
  22214. if (vert.clientHeight) { scroll(vert.scrollTop, "vertical") }
  22215. })
  22216. on(horiz, "scroll", function () {
  22217. if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal") }
  22218. })
  22219. this.checkedZeroWidth = false
  22220. // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
  22221. if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px" }
  22222. };
  22223. NativeScrollbars.prototype.update = function (measure) {
  22224. var needsH = measure.scrollWidth > measure.clientWidth + 1
  22225. var needsV = measure.scrollHeight > measure.clientHeight + 1
  22226. var sWidth = measure.nativeBarWidth
  22227. if (needsV) {
  22228. this.vert.style.display = "block"
  22229. this.vert.style.bottom = needsH ? sWidth + "px" : "0"
  22230. var totalHeight = measure.viewHeight - (needsH ? sWidth : 0)
  22231. // A bug in IE8 can cause this value to be negative, so guard it.
  22232. this.vert.firstChild.style.height =
  22233. Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px"
  22234. } else {
  22235. this.vert.style.display = ""
  22236. this.vert.firstChild.style.height = "0"
  22237. }
  22238. if (needsH) {
  22239. this.horiz.style.display = "block"
  22240. this.horiz.style.right = needsV ? sWidth + "px" : "0"
  22241. this.horiz.style.left = measure.barLeft + "px"
  22242. var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0)
  22243. this.horiz.firstChild.style.width =
  22244. (measure.scrollWidth - measure.clientWidth + totalWidth) + "px"
  22245. } else {
  22246. this.horiz.style.display = ""
  22247. this.horiz.firstChild.style.width = "0"
  22248. }
  22249. if (!this.checkedZeroWidth && measure.clientHeight > 0) {
  22250. if (sWidth == 0) { this.zeroWidthHack() }
  22251. this.checkedZeroWidth = true
  22252. }
  22253. return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
  22254. };
  22255. NativeScrollbars.prototype.setScrollLeft = function (pos) {
  22256. if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos }
  22257. if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz) }
  22258. };
  22259. NativeScrollbars.prototype.setScrollTop = function (pos) {
  22260. if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos }
  22261. if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert) }
  22262. };
  22263. NativeScrollbars.prototype.zeroWidthHack = function () {
  22264. var w = mac && !mac_geMountainLion ? "12px" : "18px"
  22265. this.horiz.style.height = this.vert.style.width = w
  22266. this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none"
  22267. this.disableHoriz = new Delayed
  22268. this.disableVert = new Delayed
  22269. };
  22270. NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay) {
  22271. bar.style.pointerEvents = "auto"
  22272. function maybeDisable() {
  22273. // To find out whether the scrollbar is still visible, we
  22274. // check whether the element under the pixel in the bottom
  22275. // left corner of the scrollbar box is the scrollbar box
  22276. // itself (when the bar is still visible) or its filler child
  22277. // (when the bar is hidden). If it is still visible, we keep
  22278. // it enabled, if it's hidden, we disable pointer events.
  22279. var box = bar.getBoundingClientRect()
  22280. var elt = document.elementFromPoint(box.left + 1, box.bottom - 1)
  22281. if (elt != bar) { bar.style.pointerEvents = "none" }
  22282. else { delay.set(1000, maybeDisable) }
  22283. }
  22284. delay.set(1000, maybeDisable)
  22285. };
  22286. NativeScrollbars.prototype.clear = function () {
  22287. var parent = this.horiz.parentNode
  22288. parent.removeChild(this.horiz)
  22289. parent.removeChild(this.vert)
  22290. };
  22291. var NullScrollbars = function () {};
  22292. NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} };
  22293. NullScrollbars.prototype.setScrollLeft = function () {};
  22294. NullScrollbars.prototype.setScrollTop = function () {};
  22295. NullScrollbars.prototype.clear = function () {};
  22296. function updateScrollbars(cm, measure) {
  22297. if (!measure) { measure = measureForScrollbars(cm) }
  22298. var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight
  22299. updateScrollbarsInner(cm, measure)
  22300. for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
  22301. if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
  22302. { updateHeightsInViewport(cm) }
  22303. updateScrollbarsInner(cm, measureForScrollbars(cm))
  22304. startWidth = cm.display.barWidth; startHeight = cm.display.barHeight
  22305. }
  22306. }
  22307. // Re-synchronize the fake scrollbars with the actual size of the
  22308. // content.
  22309. function updateScrollbarsInner(cm, measure) {
  22310. var d = cm.display
  22311. var sizes = d.scrollbars.update(measure)
  22312. d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px"
  22313. d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px"
  22314. d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent"
  22315. if (sizes.right && sizes.bottom) {
  22316. d.scrollbarFiller.style.display = "block"
  22317. d.scrollbarFiller.style.height = sizes.bottom + "px"
  22318. d.scrollbarFiller.style.width = sizes.right + "px"
  22319. } else { d.scrollbarFiller.style.display = "" }
  22320. if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
  22321. d.gutterFiller.style.display = "block"
  22322. d.gutterFiller.style.height = sizes.bottom + "px"
  22323. d.gutterFiller.style.width = measure.gutterWidth + "px"
  22324. } else { d.gutterFiller.style.display = "" }
  22325. }
  22326. var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars}
  22327. function initScrollbars(cm) {
  22328. if (cm.display.scrollbars) {
  22329. cm.display.scrollbars.clear()
  22330. if (cm.display.scrollbars.addClass)
  22331. { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass) }
  22332. }
  22333. cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {
  22334. cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller)
  22335. // Prevent clicks in the scrollbars from killing focus
  22336. on(node, "mousedown", function () {
  22337. if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0) }
  22338. })
  22339. node.setAttribute("cm-not-content", "true")
  22340. }, function (pos, axis) {
  22341. if (axis == "horizontal") { setScrollLeft(cm, pos) }
  22342. else { setScrollTop(cm, pos) }
  22343. }, cm)
  22344. if (cm.display.scrollbars.addClass)
  22345. { addClass(cm.display.wrapper, cm.display.scrollbars.addClass) }
  22346. }
  22347. // SCROLLING THINGS INTO VIEW
  22348. // If an editor sits on the top or bottom of the window, partially
  22349. // scrolled out of view, this ensures that the cursor is visible.
  22350. function maybeScrollWindow(cm, coords) {
  22351. if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
  22352. var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null
  22353. if (coords.top + box.top < 0) { doScroll = true }
  22354. else if (coords.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false }
  22355. if (doScroll != null && !phantom) {
  22356. var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (coords.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (coords.bottom - coords.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (coords.left) + "px; width: 2px;"))
  22357. cm.display.lineSpace.appendChild(scrollNode)
  22358. scrollNode.scrollIntoView(doScroll)
  22359. cm.display.lineSpace.removeChild(scrollNode)
  22360. }
  22361. }
  22362. // Scroll a given position into view (immediately), verifying that
  22363. // it actually became visible (as line heights are accurately
  22364. // measured, the position of something may 'drift' during drawing).
  22365. function scrollPosIntoView(cm, pos, end, margin) {
  22366. if (margin == null) { margin = 0 }
  22367. var coords
  22368. for (var limit = 0; limit < 5; limit++) {
  22369. var changed = false
  22370. coords = cursorCoords(cm, pos)
  22371. var endCoords = !end || end == pos ? coords : cursorCoords(cm, end)
  22372. var scrollPos = calculateScrollPos(cm, Math.min(coords.left, endCoords.left),
  22373. Math.min(coords.top, endCoords.top) - margin,
  22374. Math.max(coords.left, endCoords.left),
  22375. Math.max(coords.bottom, endCoords.bottom) + margin)
  22376. var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft
  22377. if (scrollPos.scrollTop != null) {
  22378. setScrollTop(cm, scrollPos.scrollTop)
  22379. if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true }
  22380. }
  22381. if (scrollPos.scrollLeft != null) {
  22382. setScrollLeft(cm, scrollPos.scrollLeft)
  22383. if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true }
  22384. }
  22385. if (!changed) { break }
  22386. }
  22387. return coords
  22388. }
  22389. // Scroll a given set of coordinates into view (immediately).
  22390. function scrollIntoView(cm, x1, y1, x2, y2) {
  22391. var scrollPos = calculateScrollPos(cm, x1, y1, x2, y2)
  22392. if (scrollPos.scrollTop != null) { setScrollTop(cm, scrollPos.scrollTop) }
  22393. if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft) }
  22394. }
  22395. // Calculate a new scroll position needed to scroll the given
  22396. // rectangle into view. Returns an object with scrollTop and
  22397. // scrollLeft properties. When these are undefined, the
  22398. // vertical/horizontal position does not need to be adjusted.
  22399. function calculateScrollPos(cm, x1, y1, x2, y2) {
  22400. var display = cm.display, snapMargin = textHeight(cm.display)
  22401. if (y1 < 0) { y1 = 0 }
  22402. var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop
  22403. var screen = displayHeight(cm), result = {}
  22404. if (y2 - y1 > screen) { y2 = y1 + screen }
  22405. var docBottom = cm.doc.height + paddingVert(display)
  22406. var atTop = y1 < snapMargin, atBottom = y2 > docBottom - snapMargin
  22407. if (y1 < screentop) {
  22408. result.scrollTop = atTop ? 0 : y1
  22409. } else if (y2 > screentop + screen) {
  22410. var newTop = Math.min(y1, (atBottom ? docBottom : y2) - screen)
  22411. if (newTop != screentop) { result.scrollTop = newTop }
  22412. }
  22413. var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft
  22414. var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0)
  22415. var tooWide = x2 - x1 > screenw
  22416. if (tooWide) { x2 = x1 + screenw }
  22417. if (x1 < 10)
  22418. { result.scrollLeft = 0 }
  22419. else if (x1 < screenleft)
  22420. { result.scrollLeft = Math.max(0, x1 - (tooWide ? 0 : 10)) }
  22421. else if (x2 > screenw + screenleft - 3)
  22422. { result.scrollLeft = x2 + (tooWide ? 0 : 10) - screenw }
  22423. return result
  22424. }
  22425. // Store a relative adjustment to the scroll position in the current
  22426. // operation (to be applied when the operation finishes).
  22427. function addToScrollPos(cm, left, top) {
  22428. if (left != null || top != null) { resolveScrollToPos(cm) }
  22429. if (left != null)
  22430. { cm.curOp.scrollLeft = (cm.curOp.scrollLeft == null ? cm.doc.scrollLeft : cm.curOp.scrollLeft) + left }
  22431. if (top != null)
  22432. { cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top }
  22433. }
  22434. // Make sure that at the end of the operation the current cursor is
  22435. // shown.
  22436. function ensureCursorVisible(cm) {
  22437. resolveScrollToPos(cm)
  22438. var cur = cm.getCursor(), from = cur, to = cur
  22439. if (!cm.options.lineWrapping) {
  22440. from = cur.ch ? Pos(cur.line, cur.ch - 1) : cur
  22441. to = Pos(cur.line, cur.ch + 1)
  22442. }
  22443. cm.curOp.scrollToPos = {from: from, to: to, margin: cm.options.cursorScrollMargin, isCursor: true}
  22444. }
  22445. // When an operation has its scrollToPos property set, and another
  22446. // scroll action is applied before the end of the operation, this
  22447. // 'simulates' scrolling that position into view in a cheap way, so
  22448. // that the effect of intermediate scroll commands is not ignored.
  22449. function resolveScrollToPos(cm) {
  22450. var range = cm.curOp.scrollToPos
  22451. if (range) {
  22452. cm.curOp.scrollToPos = null
  22453. var from = estimateCoords(cm, range.from), to = estimateCoords(cm, range.to)
  22454. var sPos = calculateScrollPos(cm, Math.min(from.left, to.left),
  22455. Math.min(from.top, to.top) - range.margin,
  22456. Math.max(from.right, to.right),
  22457. Math.max(from.bottom, to.bottom) + range.margin)
  22458. cm.scrollTo(sPos.scrollLeft, sPos.scrollTop)
  22459. }
  22460. }
  22461. // Operations are used to wrap a series of changes to the editor
  22462. // state in such a way that each change won't have to update the
  22463. // cursor and display (which would be awkward, slow, and
  22464. // error-prone). Instead, display updates are batched and then all
  22465. // combined and executed at once.
  22466. var nextOpId = 0
  22467. // Start a new operation.
  22468. function startOperation(cm) {
  22469. cm.curOp = {
  22470. cm: cm,
  22471. viewChanged: false, // Flag that indicates that lines might need to be redrawn
  22472. startHeight: cm.doc.height, // Used to detect need to update scrollbar
  22473. forceUpdate: false, // Used to force a redraw
  22474. updateInput: null, // Whether to reset the input textarea
  22475. typing: false, // Whether this reset should be careful to leave existing text (for compositing)
  22476. changeObjs: null, // Accumulated changes, for firing change events
  22477. cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
  22478. cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
  22479. selectionChanged: false, // Whether the selection needs to be redrawn
  22480. updateMaxLine: false, // Set when the widest line needs to be determined anew
  22481. scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
  22482. scrollToPos: null, // Used to scroll to a specific position
  22483. focus: false,
  22484. id: ++nextOpId // Unique ID
  22485. }
  22486. pushOperation(cm.curOp)
  22487. }
  22488. // Finish an operation, updating the display and signalling delayed events
  22489. function endOperation(cm) {
  22490. var op = cm.curOp
  22491. finishOperation(op, function (group) {
  22492. for (var i = 0; i < group.ops.length; i++)
  22493. { group.ops[i].cm.curOp = null }
  22494. endOperations(group)
  22495. })
  22496. }
  22497. // The DOM updates done when an operation finishes are batched so
  22498. // that the minimum number of relayouts are required.
  22499. function endOperations(group) {
  22500. var ops = group.ops
  22501. for (var i = 0; i < ops.length; i++) // Read DOM
  22502. { endOperation_R1(ops[i]) }
  22503. for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)
  22504. { endOperation_W1(ops[i$1]) }
  22505. for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM
  22506. { endOperation_R2(ops[i$2]) }
  22507. for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)
  22508. { endOperation_W2(ops[i$3]) }
  22509. for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM
  22510. { endOperation_finish(ops[i$4]) }
  22511. }
  22512. function endOperation_R1(op) {
  22513. var cm = op.cm, display = cm.display
  22514. maybeClipScrollbars(cm)
  22515. if (op.updateMaxLine) { findMaxLine(cm) }
  22516. op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
  22517. op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
  22518. op.scrollToPos.to.line >= display.viewTo) ||
  22519. display.maxLineChanged && cm.options.lineWrapping
  22520. op.update = op.mustUpdate &&
  22521. new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate)
  22522. }
  22523. function endOperation_W1(op) {
  22524. op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update)
  22525. }
  22526. function endOperation_R2(op) {
  22527. var cm = op.cm, display = cm.display
  22528. if (op.updatedDisplay) { updateHeightsInViewport(cm) }
  22529. op.barMeasure = measureForScrollbars(cm)
  22530. // If the max line changed since it was last measured, measure it,
  22531. // and ensure the document's width matches it.
  22532. // updateDisplay_W2 will use these properties to do the actual resizing
  22533. if (display.maxLineChanged && !cm.options.lineWrapping) {
  22534. op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3
  22535. cm.display.sizerWidth = op.adjustWidthTo
  22536. op.barMeasure.scrollWidth =
  22537. Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth)
  22538. op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm))
  22539. }
  22540. if (op.updatedDisplay || op.selectionChanged)
  22541. { op.preparedSelection = display.input.prepareSelection(op.focus) }
  22542. }
  22543. function endOperation_W2(op) {
  22544. var cm = op.cm
  22545. if (op.adjustWidthTo != null) {
  22546. cm.display.sizer.style.minWidth = op.adjustWidthTo + "px"
  22547. if (op.maxScrollLeft < cm.doc.scrollLeft)
  22548. { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true) }
  22549. cm.display.maxLineChanged = false
  22550. }
  22551. var takeFocus = op.focus && op.focus == activeElt() && (!document.hasFocus || document.hasFocus())
  22552. if (op.preparedSelection)
  22553. { cm.display.input.showSelection(op.preparedSelection, takeFocus) }
  22554. if (op.updatedDisplay || op.startHeight != cm.doc.height)
  22555. { updateScrollbars(cm, op.barMeasure) }
  22556. if (op.updatedDisplay)
  22557. { setDocumentHeight(cm, op.barMeasure) }
  22558. if (op.selectionChanged) { restartBlink(cm) }
  22559. if (cm.state.focused && op.updateInput)
  22560. { cm.display.input.reset(op.typing) }
  22561. if (takeFocus) { ensureFocus(op.cm) }
  22562. }
  22563. function endOperation_finish(op) {
  22564. var cm = op.cm, display = cm.display, doc = cm.doc
  22565. if (op.updatedDisplay) { postUpdateDisplay(cm, op.update) }
  22566. // Abort mouse wheel delta measurement, when scrolling explicitly
  22567. if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
  22568. { display.wheelStartX = display.wheelStartY = null }
  22569. // Propagate the scroll position to the actual DOM scroller
  22570. if (op.scrollTop != null && (display.scroller.scrollTop != op.scrollTop || op.forceScroll)) {
  22571. doc.scrollTop = Math.max(0, Math.min(display.scroller.scrollHeight - display.scroller.clientHeight, op.scrollTop))
  22572. display.scrollbars.setScrollTop(doc.scrollTop)
  22573. display.scroller.scrollTop = doc.scrollTop
  22574. }
  22575. if (op.scrollLeft != null && (display.scroller.scrollLeft != op.scrollLeft || op.forceScroll)) {
  22576. doc.scrollLeft = Math.max(0, Math.min(display.scroller.scrollWidth - display.scroller.clientWidth, op.scrollLeft))
  22577. display.scrollbars.setScrollLeft(doc.scrollLeft)
  22578. display.scroller.scrollLeft = doc.scrollLeft
  22579. alignHorizontally(cm)
  22580. }
  22581. // If we need to scroll a specific position into view, do so.
  22582. if (op.scrollToPos) {
  22583. var coords = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
  22584. clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin)
  22585. if (op.scrollToPos.isCursor && cm.state.focused) { maybeScrollWindow(cm, coords) }
  22586. }
  22587. // Fire events for markers that are hidden/unidden by editing or
  22588. // undoing
  22589. var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers
  22590. if (hidden) { for (var i = 0; i < hidden.length; ++i)
  22591. { if (!hidden[i].lines.length) { signal(hidden[i], "hide") } } }
  22592. if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1)
  22593. { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide") } } }
  22594. if (display.wrapper.offsetHeight)
  22595. { doc.scrollTop = cm.display.scroller.scrollTop }
  22596. // Fire change events, and delayed event handlers
  22597. if (op.changeObjs)
  22598. { signal(cm, "changes", cm, op.changeObjs) }
  22599. if (op.update)
  22600. { op.update.finish() }
  22601. }
  22602. // Run the given function in an operation
  22603. function runInOp(cm, f) {
  22604. if (cm.curOp) { return f() }
  22605. startOperation(cm)
  22606. try { return f() }
  22607. finally { endOperation(cm) }
  22608. }
  22609. // Wraps a function in an operation. Returns the wrapped function.
  22610. function operation(cm, f) {
  22611. return function() {
  22612. if (cm.curOp) { return f.apply(cm, arguments) }
  22613. startOperation(cm)
  22614. try { return f.apply(cm, arguments) }
  22615. finally { endOperation(cm) }
  22616. }
  22617. }
  22618. // Used to add methods to editor and doc instances, wrapping them in
  22619. // operations.
  22620. function methodOp(f) {
  22621. return function() {
  22622. if (this.curOp) { return f.apply(this, arguments) }
  22623. startOperation(this)
  22624. try { return f.apply(this, arguments) }
  22625. finally { endOperation(this) }
  22626. }
  22627. }
  22628. function docMethodOp(f) {
  22629. return function() {
  22630. var cm = this.cm
  22631. if (!cm || cm.curOp) { return f.apply(this, arguments) }
  22632. startOperation(cm)
  22633. try { return f.apply(this, arguments) }
  22634. finally { endOperation(cm) }
  22635. }
  22636. }
  22637. // Updates the display.view data structure for a given change to the
  22638. // document. From and to are in pre-change coordinates. Lendiff is
  22639. // the amount of lines added or subtracted by the change. This is
  22640. // used for changes that span multiple lines, or change the way
  22641. // lines are divided into visual lines. regLineChange (below)
  22642. // registers single-line changes.
  22643. function regChange(cm, from, to, lendiff) {
  22644. if (from == null) { from = cm.doc.first }
  22645. if (to == null) { to = cm.doc.first + cm.doc.size }
  22646. if (!lendiff) { lendiff = 0 }
  22647. var display = cm.display
  22648. if (lendiff && to < display.viewTo &&
  22649. (display.updateLineNumbers == null || display.updateLineNumbers > from))
  22650. { display.updateLineNumbers = from }
  22651. cm.curOp.viewChanged = true
  22652. if (from >= display.viewTo) { // Change after
  22653. if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
  22654. { resetView(cm) }
  22655. } else if (to <= display.viewFrom) { // Change before
  22656. if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
  22657. resetView(cm)
  22658. } else {
  22659. display.viewFrom += lendiff
  22660. display.viewTo += lendiff
  22661. }
  22662. } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
  22663. resetView(cm)
  22664. } else if (from <= display.viewFrom) { // Top overlap
  22665. var cut = viewCuttingPoint(cm, to, to + lendiff, 1)
  22666. if (cut) {
  22667. display.view = display.view.slice(cut.index)
  22668. display.viewFrom = cut.lineN
  22669. display.viewTo += lendiff
  22670. } else {
  22671. resetView(cm)
  22672. }
  22673. } else if (to >= display.viewTo) { // Bottom overlap
  22674. var cut$1 = viewCuttingPoint(cm, from, from, -1)
  22675. if (cut$1) {
  22676. display.view = display.view.slice(0, cut$1.index)
  22677. display.viewTo = cut$1.lineN
  22678. } else {
  22679. resetView(cm)
  22680. }
  22681. } else { // Gap in the middle
  22682. var cutTop = viewCuttingPoint(cm, from, from, -1)
  22683. var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1)
  22684. if (cutTop && cutBot) {
  22685. display.view = display.view.slice(0, cutTop.index)
  22686. .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
  22687. .concat(display.view.slice(cutBot.index))
  22688. display.viewTo += lendiff
  22689. } else {
  22690. resetView(cm)
  22691. }
  22692. }
  22693. var ext = display.externalMeasured
  22694. if (ext) {
  22695. if (to < ext.lineN)
  22696. { ext.lineN += lendiff }
  22697. else if (from < ext.lineN + ext.size)
  22698. { display.externalMeasured = null }
  22699. }
  22700. }
  22701. // Register a change to a single line. Type must be one of "text",
  22702. // "gutter", "class", "widget"
  22703. function regLineChange(cm, line, type) {
  22704. cm.curOp.viewChanged = true
  22705. var display = cm.display, ext = cm.display.externalMeasured
  22706. if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
  22707. { display.externalMeasured = null }
  22708. if (line < display.viewFrom || line >= display.viewTo) { return }
  22709. var lineView = display.view[findViewIndex(cm, line)]
  22710. if (lineView.node == null) { return }
  22711. var arr = lineView.changes || (lineView.changes = [])
  22712. if (indexOf(arr, type) == -1) { arr.push(type) }
  22713. }
  22714. // Clear the view.
  22715. function resetView(cm) {
  22716. cm.display.viewFrom = cm.display.viewTo = cm.doc.first
  22717. cm.display.view = []
  22718. cm.display.viewOffset = 0
  22719. }
  22720. function viewCuttingPoint(cm, oldN, newN, dir) {
  22721. var index = findViewIndex(cm, oldN), diff, view = cm.display.view
  22722. if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
  22723. { return {index: index, lineN: newN} }
  22724. var n = cm.display.viewFrom
  22725. for (var i = 0; i < index; i++)
  22726. { n += view[i].size }
  22727. if (n != oldN) {
  22728. if (dir > 0) {
  22729. if (index == view.length - 1) { return null }
  22730. diff = (n + view[index].size) - oldN
  22731. index++
  22732. } else {
  22733. diff = n - oldN
  22734. }
  22735. oldN += diff; newN += diff
  22736. }
  22737. while (visualLineNo(cm.doc, newN) != newN) {
  22738. if (index == (dir < 0 ? 0 : view.length - 1)) { return null }
  22739. newN += dir * view[index - (dir < 0 ? 1 : 0)].size
  22740. index += dir
  22741. }
  22742. return {index: index, lineN: newN}
  22743. }
  22744. // Force the view to cover a given range, adding empty view element
  22745. // or clipping off existing ones as needed.
  22746. function adjustView(cm, from, to) {
  22747. var display = cm.display, view = display.view
  22748. if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
  22749. display.view = buildViewArray(cm, from, to)
  22750. display.viewFrom = from
  22751. } else {
  22752. if (display.viewFrom > from)
  22753. { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view) }
  22754. else if (display.viewFrom < from)
  22755. { display.view = display.view.slice(findViewIndex(cm, from)) }
  22756. display.viewFrom = from
  22757. if (display.viewTo < to)
  22758. { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)) }
  22759. else if (display.viewTo > to)
  22760. { display.view = display.view.slice(0, findViewIndex(cm, to)) }
  22761. }
  22762. display.viewTo = to
  22763. }
  22764. // Count the number of lines in the view whose DOM representation is
  22765. // out of date (or nonexistent).
  22766. function countDirtyView(cm) {
  22767. var view = cm.display.view, dirty = 0
  22768. for (var i = 0; i < view.length; i++) {
  22769. var lineView = view[i]
  22770. if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty }
  22771. }
  22772. return dirty
  22773. }
  22774. // HIGHLIGHT WORKER
  22775. function startWorker(cm, time) {
  22776. if (cm.doc.mode.startState && cm.doc.frontier < cm.display.viewTo)
  22777. { cm.state.highlight.set(time, bind(highlightWorker, cm)) }
  22778. }
  22779. function highlightWorker(cm) {
  22780. var doc = cm.doc
  22781. if (doc.frontier < doc.first) { doc.frontier = doc.first }
  22782. if (doc.frontier >= cm.display.viewTo) { return }
  22783. var end = +new Date + cm.options.workTime
  22784. var state = copyState(doc.mode, getStateBefore(cm, doc.frontier))
  22785. var changedLines = []
  22786. doc.iter(doc.frontier, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {
  22787. if (doc.frontier >= cm.display.viewFrom) { // Visible
  22788. var oldStyles = line.styles, tooLong = line.text.length > cm.options.maxHighlightLength
  22789. var highlighted = highlightLine(cm, line, tooLong ? copyState(doc.mode, state) : state, true)
  22790. line.styles = highlighted.styles
  22791. var oldCls = line.styleClasses, newCls = highlighted.classes
  22792. if (newCls) { line.styleClasses = newCls }
  22793. else if (oldCls) { line.styleClasses = null }
  22794. var ischange = !oldStyles || oldStyles.length != line.styles.length ||
  22795. oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass)
  22796. for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i] }
  22797. if (ischange) { changedLines.push(doc.frontier) }
  22798. line.stateAfter = tooLong ? state : copyState(doc.mode, state)
  22799. } else {
  22800. if (line.text.length <= cm.options.maxHighlightLength)
  22801. { processLine(cm, line.text, state) }
  22802. line.stateAfter = doc.frontier % 5 == 0 ? copyState(doc.mode, state) : null
  22803. }
  22804. ++doc.frontier
  22805. if (+new Date > end) {
  22806. startWorker(cm, cm.options.workDelay)
  22807. return true
  22808. }
  22809. })
  22810. if (changedLines.length) { runInOp(cm, function () {
  22811. for (var i = 0; i < changedLines.length; i++)
  22812. { regLineChange(cm, changedLines[i], "text") }
  22813. }) }
  22814. }
  22815. // DISPLAY DRAWING
  22816. var DisplayUpdate = function(cm, viewport, force) {
  22817. var display = cm.display
  22818. this.viewport = viewport
  22819. // Store some values that we'll need later (but don't want to force a relayout for)
  22820. this.visible = visibleLines(display, cm.doc, viewport)
  22821. this.editorIsHidden = !display.wrapper.offsetWidth
  22822. this.wrapperHeight = display.wrapper.clientHeight
  22823. this.wrapperWidth = display.wrapper.clientWidth
  22824. this.oldDisplayWidth = displayWidth(cm)
  22825. this.force = force
  22826. this.dims = getDimensions(cm)
  22827. this.events = []
  22828. };
  22829. DisplayUpdate.prototype.signal = function (emitter, type) {
  22830. if (hasHandler(emitter, type))
  22831. { this.events.push(arguments) }
  22832. };
  22833. DisplayUpdate.prototype.finish = function () {
  22834. var this$1 = this;
  22835. for (var i = 0; i < this.events.length; i++)
  22836. { signal.apply(null, this$1.events[i]) }
  22837. };
  22838. function maybeClipScrollbars(cm) {
  22839. var display = cm.display
  22840. if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
  22841. display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth
  22842. display.heightForcer.style.height = scrollGap(cm) + "px"
  22843. display.sizer.style.marginBottom = -display.nativeBarWidth + "px"
  22844. display.sizer.style.borderRightWidth = scrollGap(cm) + "px"
  22845. display.scrollbarsClipped = true
  22846. }
  22847. }
  22848. // Does the actual updating of the line display. Bails out
  22849. // (returning false) when there is nothing to be done and forced is
  22850. // false.
  22851. function updateDisplayIfNeeded(cm, update) {
  22852. var display = cm.display, doc = cm.doc
  22853. if (update.editorIsHidden) {
  22854. resetView(cm)
  22855. return false
  22856. }
  22857. // Bail out if the visible area is already rendered and nothing changed.
  22858. if (!update.force &&
  22859. update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
  22860. (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
  22861. display.renderedView == display.view && countDirtyView(cm) == 0)
  22862. { return false }
  22863. if (maybeUpdateLineNumberWidth(cm)) {
  22864. resetView(cm)
  22865. update.dims = getDimensions(cm)
  22866. }
  22867. // Compute a suitable new viewport (from & to)
  22868. var end = doc.first + doc.size
  22869. var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first)
  22870. var to = Math.min(end, update.visible.to + cm.options.viewportMargin)
  22871. if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom) }
  22872. if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo) }
  22873. if (sawCollapsedSpans) {
  22874. from = visualLineNo(cm.doc, from)
  22875. to = visualLineEndNo(cm.doc, to)
  22876. }
  22877. var different = from != display.viewFrom || to != display.viewTo ||
  22878. display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth
  22879. adjustView(cm, from, to)
  22880. display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom))
  22881. // Position the mover div to align with the current scroll position
  22882. cm.display.mover.style.top = display.viewOffset + "px"
  22883. var toUpdate = countDirtyView(cm)
  22884. if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
  22885. (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
  22886. { return false }
  22887. // For big changes, we hide the enclosing element during the
  22888. // update, since that speeds up the operations on most browsers.
  22889. var focused = activeElt()
  22890. if (toUpdate > 4) { display.lineDiv.style.display = "none" }
  22891. patchDisplay(cm, display.updateLineNumbers, update.dims)
  22892. if (toUpdate > 4) { display.lineDiv.style.display = "" }
  22893. display.renderedView = display.view
  22894. // There might have been a widget with a focused element that got
  22895. // hidden or updated, if so re-focus it.
  22896. if (focused && activeElt() != focused && focused.offsetHeight) { focused.focus() }
  22897. // Prevent selection and cursors from interfering with the scroll
  22898. // width and height.
  22899. removeChildren(display.cursorDiv)
  22900. removeChildren(display.selectionDiv)
  22901. display.gutters.style.height = display.sizer.style.minHeight = 0
  22902. if (different) {
  22903. display.lastWrapHeight = update.wrapperHeight
  22904. display.lastWrapWidth = update.wrapperWidth
  22905. startWorker(cm, 400)
  22906. }
  22907. display.updateLineNumbers = null
  22908. return true
  22909. }
  22910. function postUpdateDisplay(cm, update) {
  22911. var viewport = update.viewport
  22912. for (var first = true;; first = false) {
  22913. if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
  22914. // Clip forced viewport to actual scrollable area.
  22915. if (viewport && viewport.top != null)
  22916. { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)} }
  22917. // Updated line heights might result in the drawn area not
  22918. // actually covering the viewport. Keep looping until it does.
  22919. update.visible = visibleLines(cm.display, cm.doc, viewport)
  22920. if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
  22921. { break }
  22922. }
  22923. if (!updateDisplayIfNeeded(cm, update)) { break }
  22924. updateHeightsInViewport(cm)
  22925. var barMeasure = measureForScrollbars(cm)
  22926. updateSelection(cm)
  22927. updateScrollbars(cm, barMeasure)
  22928. setDocumentHeight(cm, barMeasure)
  22929. }
  22930. update.signal(cm, "update", cm)
  22931. if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
  22932. update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo)
  22933. cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo
  22934. }
  22935. }
  22936. function updateDisplaySimple(cm, viewport) {
  22937. var update = new DisplayUpdate(cm, viewport)
  22938. if (updateDisplayIfNeeded(cm, update)) {
  22939. updateHeightsInViewport(cm)
  22940. postUpdateDisplay(cm, update)
  22941. var barMeasure = measureForScrollbars(cm)
  22942. updateSelection(cm)
  22943. updateScrollbars(cm, barMeasure)
  22944. setDocumentHeight(cm, barMeasure)
  22945. update.finish()
  22946. }
  22947. }
  22948. // Sync the actual display DOM structure with display.view, removing
  22949. // nodes for lines that are no longer in view, and creating the ones
  22950. // that are not there yet, and updating the ones that are out of
  22951. // date.
  22952. function patchDisplay(cm, updateNumbersFrom, dims) {
  22953. var display = cm.display, lineNumbers = cm.options.lineNumbers
  22954. var container = display.lineDiv, cur = container.firstChild
  22955. function rm(node) {
  22956. var next = node.nextSibling
  22957. // Works around a throw-scroll bug in OS X Webkit
  22958. if (webkit && mac && cm.display.currentWheelTarget == node)
  22959. { node.style.display = "none" }
  22960. else
  22961. { node.parentNode.removeChild(node) }
  22962. return next
  22963. }
  22964. var view = display.view, lineN = display.viewFrom
  22965. // Loop over the elements in the view, syncing cur (the DOM nodes
  22966. // in display.lineDiv) with the view as we go.
  22967. for (var i = 0; i < view.length; i++) {
  22968. var lineView = view[i]
  22969. if (lineView.hidden) {
  22970. } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
  22971. var node = buildLineElement(cm, lineView, lineN, dims)
  22972. container.insertBefore(node, cur)
  22973. } else { // Already drawn
  22974. while (cur != lineView.node) { cur = rm(cur) }
  22975. var updateNumber = lineNumbers && updateNumbersFrom != null &&
  22976. updateNumbersFrom <= lineN && lineView.lineNumber
  22977. if (lineView.changes) {
  22978. if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false }
  22979. updateLineForChanges(cm, lineView, lineN, dims)
  22980. }
  22981. if (updateNumber) {
  22982. removeChildren(lineView.lineNumber)
  22983. lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)))
  22984. }
  22985. cur = lineView.node.nextSibling
  22986. }
  22987. lineN += lineView.size
  22988. }
  22989. while (cur) { cur = rm(cur) }
  22990. }
  22991. function updateGutterSpace(cm) {
  22992. var width = cm.display.gutters.offsetWidth
  22993. cm.display.sizer.style.marginLeft = width + "px"
  22994. }
  22995. function setDocumentHeight(cm, measure) {
  22996. cm.display.sizer.style.minHeight = measure.docHeight + "px"
  22997. cm.display.heightForcer.style.top = measure.docHeight + "px"
  22998. cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px"
  22999. }
  23000. // Rebuild the gutter elements, ensure the margin to the left of the
  23001. // code matches their width.
  23002. function updateGutters(cm) {
  23003. var gutters = cm.display.gutters, specs = cm.options.gutters
  23004. removeChildren(gutters)
  23005. var i = 0
  23006. for (; i < specs.length; ++i) {
  23007. var gutterClass = specs[i]
  23008. var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass))
  23009. if (gutterClass == "CodeMirror-linenumbers") {
  23010. cm.display.lineGutter = gElt
  23011. gElt.style.width = (cm.display.lineNumWidth || 1) + "px"
  23012. }
  23013. }
  23014. gutters.style.display = i ? "" : "none"
  23015. updateGutterSpace(cm)
  23016. }
  23017. // Make sure the gutters options contains the element
  23018. // "CodeMirror-linenumbers" when the lineNumbers option is true.
  23019. function setGuttersForLineNumbers(options) {
  23020. var found = indexOf(options.gutters, "CodeMirror-linenumbers")
  23021. if (found == -1 && options.lineNumbers) {
  23022. options.gutters = options.gutters.concat(["CodeMirror-linenumbers"])
  23023. } else if (found > -1 && !options.lineNumbers) {
  23024. options.gutters = options.gutters.slice(0)
  23025. options.gutters.splice(found, 1)
  23026. }
  23027. }
  23028. // Selection objects are immutable. A new one is created every time
  23029. // the selection changes. A selection is one or more non-overlapping
  23030. // (and non-touching) ranges, sorted, and an integer that indicates
  23031. // which one is the primary selection (the one that's scrolled into
  23032. // view, that getCursor returns, etc).
  23033. function Selection(ranges, primIndex) {
  23034. this.ranges = ranges
  23035. this.primIndex = primIndex
  23036. }
  23037. Selection.prototype = {
  23038. primary: function() { return this.ranges[this.primIndex] },
  23039. equals: function(other) {
  23040. var this$1 = this;
  23041. if (other == this) { return true }
  23042. if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
  23043. for (var i = 0; i < this.ranges.length; i++) {
  23044. var here = this$1.ranges[i], there = other.ranges[i]
  23045. if (cmp(here.anchor, there.anchor) != 0 || cmp(here.head, there.head) != 0) { return false }
  23046. }
  23047. return true
  23048. },
  23049. deepCopy: function() {
  23050. var this$1 = this;
  23051. var out = []
  23052. for (var i = 0; i < this.ranges.length; i++)
  23053. { out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)) }
  23054. return new Selection(out, this.primIndex)
  23055. },
  23056. somethingSelected: function() {
  23057. var this$1 = this;
  23058. for (var i = 0; i < this.ranges.length; i++)
  23059. { if (!this$1.ranges[i].empty()) { return true } }
  23060. return false
  23061. },
  23062. contains: function(pos, end) {
  23063. var this$1 = this;
  23064. if (!end) { end = pos }
  23065. for (var i = 0; i < this.ranges.length; i++) {
  23066. var range = this$1.ranges[i]
  23067. if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
  23068. { return i }
  23069. }
  23070. return -1
  23071. }
  23072. }
  23073. function Range(anchor, head) {
  23074. this.anchor = anchor; this.head = head
  23075. }
  23076. Range.prototype = {
  23077. from: function() { return minPos(this.anchor, this.head) },
  23078. to: function() { return maxPos(this.anchor, this.head) },
  23079. empty: function() {
  23080. return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch
  23081. }
  23082. }
  23083. // Take an unsorted, potentially overlapping set of ranges, and
  23084. // build a selection out of it. 'Consumes' ranges array (modifying
  23085. // it).
  23086. function normalizeSelection(ranges, primIndex) {
  23087. var prim = ranges[primIndex]
  23088. ranges.sort(function (a, b) { return cmp(a.from(), b.from()); })
  23089. primIndex = indexOf(ranges, prim)
  23090. for (var i = 1; i < ranges.length; i++) {
  23091. var cur = ranges[i], prev = ranges[i - 1]
  23092. if (cmp(prev.to(), cur.from()) >= 0) {
  23093. var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to())
  23094. var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head
  23095. if (i <= primIndex) { --primIndex }
  23096. ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to))
  23097. }
  23098. }
  23099. return new Selection(ranges, primIndex)
  23100. }
  23101. function simpleSelection(anchor, head) {
  23102. return new Selection([new Range(anchor, head || anchor)], 0)
  23103. }
  23104. // Compute the position of the end of a change (its 'to' property
  23105. // refers to the pre-change end).
  23106. function changeEnd(change) {
  23107. if (!change.text) { return change.to }
  23108. return Pos(change.from.line + change.text.length - 1,
  23109. lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))
  23110. }
  23111. // Adjust a position to refer to the post-change position of the
  23112. // same text, or the end of the change if the change covers it.
  23113. function adjustForChange(pos, change) {
  23114. if (cmp(pos, change.from) < 0) { return pos }
  23115. if (cmp(pos, change.to) <= 0) { return changeEnd(change) }
  23116. var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch
  23117. if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch }
  23118. return Pos(line, ch)
  23119. }
  23120. function computeSelAfterChange(doc, change) {
  23121. var out = []
  23122. for (var i = 0; i < doc.sel.ranges.length; i++) {
  23123. var range = doc.sel.ranges[i]
  23124. out.push(new Range(adjustForChange(range.anchor, change),
  23125. adjustForChange(range.head, change)))
  23126. }
  23127. return normalizeSelection(out, doc.sel.primIndex)
  23128. }
  23129. function offsetPos(pos, old, nw) {
  23130. if (pos.line == old.line)
  23131. { return Pos(nw.line, pos.ch - old.ch + nw.ch) }
  23132. else
  23133. { return Pos(nw.line + (pos.line - old.line), pos.ch) }
  23134. }
  23135. // Used by replaceSelections to allow moving the selection to the
  23136. // start or around the replaced test. Hint may be "start" or "around".
  23137. function computeReplacedSel(doc, changes, hint) {
  23138. var out = []
  23139. var oldPrev = Pos(doc.first, 0), newPrev = oldPrev
  23140. for (var i = 0; i < changes.length; i++) {
  23141. var change = changes[i]
  23142. var from = offsetPos(change.from, oldPrev, newPrev)
  23143. var to = offsetPos(changeEnd(change), oldPrev, newPrev)
  23144. oldPrev = change.to
  23145. newPrev = to
  23146. if (hint == "around") {
  23147. var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0
  23148. out[i] = new Range(inv ? to : from, inv ? from : to)
  23149. } else {
  23150. out[i] = new Range(from, from)
  23151. }
  23152. }
  23153. return new Selection(out, doc.sel.primIndex)
  23154. }
  23155. // Used to get the editor into a consistent state again when options change.
  23156. function loadMode(cm) {
  23157. cm.doc.mode = getMode(cm.options, cm.doc.modeOption)
  23158. resetModeState(cm)
  23159. }
  23160. function resetModeState(cm) {
  23161. cm.doc.iter(function (line) {
  23162. if (line.stateAfter) { line.stateAfter = null }
  23163. if (line.styles) { line.styles = null }
  23164. })
  23165. cm.doc.frontier = cm.doc.first
  23166. startWorker(cm, 100)
  23167. cm.state.modeGen++
  23168. if (cm.curOp) { regChange(cm) }
  23169. }
  23170. // DOCUMENT DATA STRUCTURE
  23171. // By default, updates that start and end at the beginning of a line
  23172. // are treated specially, in order to make the association of line
  23173. // widgets and marker elements with the text behave more intuitive.
  23174. function isWholeLineUpdate(doc, change) {
  23175. return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
  23176. (!doc.cm || doc.cm.options.wholeLineUpdateBefore)
  23177. }
  23178. // Perform a change on the document data structure.
  23179. function updateDoc(doc, change, markedSpans, estimateHeight) {
  23180. function spansFor(n) {return markedSpans ? markedSpans[n] : null}
  23181. function update(line, text, spans) {
  23182. updateLine(line, text, spans, estimateHeight)
  23183. signalLater(line, "change", line, change)
  23184. }
  23185. function linesFor(start, end) {
  23186. var result = []
  23187. for (var i = start; i < end; ++i)
  23188. { result.push(new Line(text[i], spansFor(i), estimateHeight)) }
  23189. return result
  23190. }
  23191. var from = change.from, to = change.to, text = change.text
  23192. var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line)
  23193. var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line
  23194. // Adjust the line structure
  23195. if (change.full) {
  23196. doc.insert(0, linesFor(0, text.length))
  23197. doc.remove(text.length, doc.size - text.length)
  23198. } else if (isWholeLineUpdate(doc, change)) {
  23199. // This is a whole-line replace. Treated specially to make
  23200. // sure line objects move the way they are supposed to.
  23201. var added = linesFor(0, text.length - 1)
  23202. update(lastLine, lastLine.text, lastSpans)
  23203. if (nlines) { doc.remove(from.line, nlines) }
  23204. if (added.length) { doc.insert(from.line, added) }
  23205. } else if (firstLine == lastLine) {
  23206. if (text.length == 1) {
  23207. update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans)
  23208. } else {
  23209. var added$1 = linesFor(1, text.length - 1)
  23210. added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight))
  23211. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0))
  23212. doc.insert(from.line + 1, added$1)
  23213. }
  23214. } else if (text.length == 1) {
  23215. update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0))
  23216. doc.remove(from.line + 1, nlines)
  23217. } else {
  23218. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0))
  23219. update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans)
  23220. var added$2 = linesFor(1, text.length - 1)
  23221. if (nlines > 1) { doc.remove(from.line + 1, nlines - 1) }
  23222. doc.insert(from.line + 1, added$2)
  23223. }
  23224. signalLater(doc, "change", doc, change)
  23225. }
  23226. // Call f for all linked documents.
  23227. function linkedDocs(doc, f, sharedHistOnly) {
  23228. function propagate(doc, skip, sharedHist) {
  23229. if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) {
  23230. var rel = doc.linked[i]
  23231. if (rel.doc == skip) { continue }
  23232. var shared = sharedHist && rel.sharedHist
  23233. if (sharedHistOnly && !shared) { continue }
  23234. f(rel.doc, shared)
  23235. propagate(rel.doc, doc, shared)
  23236. } }
  23237. }
  23238. propagate(doc, null, true)
  23239. }
  23240. // Attach a document to an editor.
  23241. function attachDoc(cm, doc) {
  23242. if (doc.cm) { throw new Error("This document is already in use.") }
  23243. cm.doc = doc
  23244. doc.cm = cm
  23245. estimateLineHeights(cm)
  23246. loadMode(cm)
  23247. if (!cm.options.lineWrapping) { findMaxLine(cm) }
  23248. cm.options.mode = doc.modeOption
  23249. regChange(cm)
  23250. }
  23251. function History(startGen) {
  23252. // Arrays of change events and selections. Doing something adds an
  23253. // event to done and clears undo. Undoing moves events from done
  23254. // to undone, redoing moves them in the other direction.
  23255. this.done = []; this.undone = []
  23256. this.undoDepth = Infinity
  23257. // Used to track when changes can be merged into a single undo
  23258. // event
  23259. this.lastModTime = this.lastSelTime = 0
  23260. this.lastOp = this.lastSelOp = null
  23261. this.lastOrigin = this.lastSelOrigin = null
  23262. // Used by the isClean() method
  23263. this.generation = this.maxGeneration = startGen || 1
  23264. }
  23265. // Create a history change event from an updateDoc-style change
  23266. // object.
  23267. function historyChangeFromChange(doc, change) {
  23268. var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)}
  23269. attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1)
  23270. linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true)
  23271. return histChange
  23272. }
  23273. // Pop all selection events off the end of a history array. Stop at
  23274. // a change event.
  23275. function clearSelectionEvents(array) {
  23276. while (array.length) {
  23277. var last = lst(array)
  23278. if (last.ranges) { array.pop() }
  23279. else { break }
  23280. }
  23281. }
  23282. // Find the top change event in the history. Pop off selection
  23283. // events that are in the way.
  23284. function lastChangeEvent(hist, force) {
  23285. if (force) {
  23286. clearSelectionEvents(hist.done)
  23287. return lst(hist.done)
  23288. } else if (hist.done.length && !lst(hist.done).ranges) {
  23289. return lst(hist.done)
  23290. } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
  23291. hist.done.pop()
  23292. return lst(hist.done)
  23293. }
  23294. }
  23295. // Register a change in the history. Merges changes that are within
  23296. // a single operation, or are close together with an origin that
  23297. // allows merging (starting with "+") into a single event.
  23298. function addChangeToHistory(doc, change, selAfter, opId) {
  23299. var hist = doc.history
  23300. hist.undone.length = 0
  23301. var time = +new Date, cur
  23302. var last
  23303. if ((hist.lastOp == opId ||
  23304. hist.lastOrigin == change.origin && change.origin &&
  23305. ((change.origin.charAt(0) == "+" && doc.cm && hist.lastModTime > time - doc.cm.options.historyEventDelay) ||
  23306. change.origin.charAt(0) == "*")) &&
  23307. (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
  23308. // Merge this change into the last event
  23309. last = lst(cur.changes)
  23310. if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
  23311. // Optimized case for simple insertion -- don't want to add
  23312. // new changesets for every character typed
  23313. last.to = changeEnd(change)
  23314. } else {
  23315. // Add new sub-event
  23316. cur.changes.push(historyChangeFromChange(doc, change))
  23317. }
  23318. } else {
  23319. // Can not be merged, start a new event.
  23320. var before = lst(hist.done)
  23321. if (!before || !before.ranges)
  23322. { pushSelectionToHistory(doc.sel, hist.done) }
  23323. cur = {changes: [historyChangeFromChange(doc, change)],
  23324. generation: hist.generation}
  23325. hist.done.push(cur)
  23326. while (hist.done.length > hist.undoDepth) {
  23327. hist.done.shift()
  23328. if (!hist.done[0].ranges) { hist.done.shift() }
  23329. }
  23330. }
  23331. hist.done.push(selAfter)
  23332. hist.generation = ++hist.maxGeneration
  23333. hist.lastModTime = hist.lastSelTime = time
  23334. hist.lastOp = hist.lastSelOp = opId
  23335. hist.lastOrigin = hist.lastSelOrigin = change.origin
  23336. if (!last) { signal(doc, "historyAdded") }
  23337. }
  23338. function selectionEventCanBeMerged(doc, origin, prev, sel) {
  23339. var ch = origin.charAt(0)
  23340. return ch == "*" ||
  23341. ch == "+" &&
  23342. prev.ranges.length == sel.ranges.length &&
  23343. prev.somethingSelected() == sel.somethingSelected() &&
  23344. new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)
  23345. }
  23346. // Called whenever the selection changes, sets the new selection as
  23347. // the pending selection in the history, and pushes the old pending
  23348. // selection into the 'done' array when it was significantly
  23349. // different (in number of selected ranges, emptiness, or time).
  23350. function addSelectionToHistory(doc, sel, opId, options) {
  23351. var hist = doc.history, origin = options && options.origin
  23352. // A new event is started when the previous origin does not match
  23353. // the current, or the origins don't allow matching. Origins
  23354. // starting with * are always merged, those starting with + are
  23355. // merged when similar and close together in time.
  23356. if (opId == hist.lastSelOp ||
  23357. (origin && hist.lastSelOrigin == origin &&
  23358. (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
  23359. selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
  23360. { hist.done[hist.done.length - 1] = sel }
  23361. else
  23362. { pushSelectionToHistory(sel, hist.done) }
  23363. hist.lastSelTime = +new Date
  23364. hist.lastSelOrigin = origin
  23365. hist.lastSelOp = opId
  23366. if (options && options.clearRedo !== false)
  23367. { clearSelectionEvents(hist.undone) }
  23368. }
  23369. function pushSelectionToHistory(sel, dest) {
  23370. var top = lst(dest)
  23371. if (!(top && top.ranges && top.equals(sel)))
  23372. { dest.push(sel) }
  23373. }
  23374. // Used to store marked span information in the history.
  23375. function attachLocalSpans(doc, change, from, to) {
  23376. var existing = change["spans_" + doc.id], n = 0
  23377. doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {
  23378. if (line.markedSpans)
  23379. { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans }
  23380. ++n
  23381. })
  23382. }
  23383. // When un/re-doing restores text containing marked spans, those
  23384. // that have been explicitly cleared should not be restored.
  23385. function removeClearedSpans(spans) {
  23386. if (!spans) { return null }
  23387. var out
  23388. for (var i = 0; i < spans.length; ++i) {
  23389. if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i) } }
  23390. else if (out) { out.push(spans[i]) }
  23391. }
  23392. return !out ? spans : out.length ? out : null
  23393. }
  23394. // Retrieve and filter the old marked spans stored in a change event.
  23395. function getOldSpans(doc, change) {
  23396. var found = change["spans_" + doc.id]
  23397. if (!found) { return null }
  23398. var nw = []
  23399. for (var i = 0; i < change.text.length; ++i)
  23400. { nw.push(removeClearedSpans(found[i])) }
  23401. return nw
  23402. }
  23403. // Used for un/re-doing changes from the history. Combines the
  23404. // result of computing the existing spans with the set of spans that
  23405. // existed in the history (so that deleting around a span and then
  23406. // undoing brings back the span).
  23407. function mergeOldSpans(doc, change) {
  23408. var old = getOldSpans(doc, change)
  23409. var stretched = stretchSpansOverChange(doc, change)
  23410. if (!old) { return stretched }
  23411. if (!stretched) { return old }
  23412. for (var i = 0; i < old.length; ++i) {
  23413. var oldCur = old[i], stretchCur = stretched[i]
  23414. if (oldCur && stretchCur) {
  23415. spans: for (var j = 0; j < stretchCur.length; ++j) {
  23416. var span = stretchCur[j]
  23417. for (var k = 0; k < oldCur.length; ++k)
  23418. { if (oldCur[k].marker == span.marker) { continue spans } }
  23419. oldCur.push(span)
  23420. }
  23421. } else if (stretchCur) {
  23422. old[i] = stretchCur
  23423. }
  23424. }
  23425. return old
  23426. }
  23427. // Used both to provide a JSON-safe object in .getHistory, and, when
  23428. // detaching a document, to split the history in two
  23429. function copyHistoryArray(events, newGroup, instantiateSel) {
  23430. var copy = []
  23431. for (var i = 0; i < events.length; ++i) {
  23432. var event = events[i]
  23433. if (event.ranges) {
  23434. copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event)
  23435. continue
  23436. }
  23437. var changes = event.changes, newChanges = []
  23438. copy.push({changes: newChanges})
  23439. for (var j = 0; j < changes.length; ++j) {
  23440. var change = changes[j], m = (void 0)
  23441. newChanges.push({from: change.from, to: change.to, text: change.text})
  23442. if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
  23443. if (indexOf(newGroup, Number(m[1])) > -1) {
  23444. lst(newChanges)[prop] = change[prop]
  23445. delete change[prop]
  23446. }
  23447. } } }
  23448. }
  23449. }
  23450. return copy
  23451. }
  23452. // The 'scroll' parameter given to many of these indicated whether
  23453. // the new cursor position should be scrolled into view after
  23454. // modifying the selection.
  23455. // If shift is held or the extend flag is set, extends a range to
  23456. // include a given position (and optionally a second position).
  23457. // Otherwise, simply returns the range between the given positions.
  23458. // Used for cursor motion and such.
  23459. function extendRange(doc, range, head, other) {
  23460. if (doc.cm && doc.cm.display.shift || doc.extend) {
  23461. var anchor = range.anchor
  23462. if (other) {
  23463. var posBefore = cmp(head, anchor) < 0
  23464. if (posBefore != (cmp(other, anchor) < 0)) {
  23465. anchor = head
  23466. head = other
  23467. } else if (posBefore != (cmp(head, other) < 0)) {
  23468. head = other
  23469. }
  23470. }
  23471. return new Range(anchor, head)
  23472. } else {
  23473. return new Range(other || head, head)
  23474. }
  23475. }
  23476. // Extend the primary selection range, discard the rest.
  23477. function extendSelection(doc, head, other, options) {
  23478. setSelection(doc, new Selection([extendRange(doc, doc.sel.primary(), head, other)], 0), options)
  23479. }
  23480. // Extend all selections (pos is an array of selections with length
  23481. // equal the number of selections)
  23482. function extendSelections(doc, heads, options) {
  23483. var out = []
  23484. for (var i = 0; i < doc.sel.ranges.length; i++)
  23485. { out[i] = extendRange(doc, doc.sel.ranges[i], heads[i], null) }
  23486. var newSel = normalizeSelection(out, doc.sel.primIndex)
  23487. setSelection(doc, newSel, options)
  23488. }
  23489. // Updates a single range in the selection.
  23490. function replaceOneSelection(doc, i, range, options) {
  23491. var ranges = doc.sel.ranges.slice(0)
  23492. ranges[i] = range
  23493. setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options)
  23494. }
  23495. // Reset the selection to a single range.
  23496. function setSimpleSelection(doc, anchor, head, options) {
  23497. setSelection(doc, simpleSelection(anchor, head), options)
  23498. }
  23499. // Give beforeSelectionChange handlers a change to influence a
  23500. // selection update.
  23501. function filterSelectionChange(doc, sel, options) {
  23502. var obj = {
  23503. ranges: sel.ranges,
  23504. update: function(ranges) {
  23505. var this$1 = this;
  23506. this.ranges = []
  23507. for (var i = 0; i < ranges.length; i++)
  23508. { this$1.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
  23509. clipPos(doc, ranges[i].head)) }
  23510. },
  23511. origin: options && options.origin
  23512. }
  23513. signal(doc, "beforeSelectionChange", doc, obj)
  23514. if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj) }
  23515. if (obj.ranges != sel.ranges) { return normalizeSelection(obj.ranges, obj.ranges.length - 1) }
  23516. else { return sel }
  23517. }
  23518. function setSelectionReplaceHistory(doc, sel, options) {
  23519. var done = doc.history.done, last = lst(done)
  23520. if (last && last.ranges) {
  23521. done[done.length - 1] = sel
  23522. setSelectionNoUndo(doc, sel, options)
  23523. } else {
  23524. setSelection(doc, sel, options)
  23525. }
  23526. }
  23527. // Set a new selection.
  23528. function setSelection(doc, sel, options) {
  23529. setSelectionNoUndo(doc, sel, options)
  23530. addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options)
  23531. }
  23532. function setSelectionNoUndo(doc, sel, options) {
  23533. if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
  23534. { sel = filterSelectionChange(doc, sel, options) }
  23535. var bias = options && options.bias ||
  23536. (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1)
  23537. setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true))
  23538. if (!(options && options.scroll === false) && doc.cm)
  23539. { ensureCursorVisible(doc.cm) }
  23540. }
  23541. function setSelectionInner(doc, sel) {
  23542. if (sel.equals(doc.sel)) { return }
  23543. doc.sel = sel
  23544. if (doc.cm) {
  23545. doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true
  23546. signalCursorActivity(doc.cm)
  23547. }
  23548. signalLater(doc, "cursorActivity", doc)
  23549. }
  23550. // Verify that the selection does not partially select any atomic
  23551. // marked ranges.
  23552. function reCheckSelection(doc) {
  23553. setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false), sel_dontScroll)
  23554. }
  23555. // Return a selection that does not partially select any atomic
  23556. // ranges.
  23557. function skipAtomicInSelection(doc, sel, bias, mayClear) {
  23558. var out
  23559. for (var i = 0; i < sel.ranges.length; i++) {
  23560. var range = sel.ranges[i]
  23561. var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i]
  23562. var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear)
  23563. var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear)
  23564. if (out || newAnchor != range.anchor || newHead != range.head) {
  23565. if (!out) { out = sel.ranges.slice(0, i) }
  23566. out[i] = new Range(newAnchor, newHead)
  23567. }
  23568. }
  23569. return out ? normalizeSelection(out, sel.primIndex) : sel
  23570. }
  23571. function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
  23572. var line = getLine(doc, pos.line)
  23573. if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
  23574. var sp = line.markedSpans[i], m = sp.marker
  23575. if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
  23576. (sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
  23577. if (mayClear) {
  23578. signal(m, "beforeCursorEnter")
  23579. if (m.explicitlyCleared) {
  23580. if (!line.markedSpans) { break }
  23581. else {--i; continue}
  23582. }
  23583. }
  23584. if (!m.atomic) { continue }
  23585. if (oldPos) {
  23586. var near = m.find(dir < 0 ? 1 : -1), diff = (void 0)
  23587. if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
  23588. { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null) }
  23589. if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
  23590. { return skipAtomicInner(doc, near, pos, dir, mayClear) }
  23591. }
  23592. var far = m.find(dir < 0 ? -1 : 1)
  23593. if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
  23594. { far = movePos(doc, far, dir, far.line == pos.line ? line : null) }
  23595. return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
  23596. }
  23597. } }
  23598. return pos
  23599. }
  23600. // Ensure a given position is not inside an atomic range.
  23601. function skipAtomic(doc, pos, oldPos, bias, mayClear) {
  23602. var dir = bias || 1
  23603. var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
  23604. (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
  23605. skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
  23606. (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true))
  23607. if (!found) {
  23608. doc.cantEdit = true
  23609. return Pos(doc.first, 0)
  23610. }
  23611. return found
  23612. }
  23613. function movePos(doc, pos, dir, line) {
  23614. if (dir < 0 && pos.ch == 0) {
  23615. if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) }
  23616. else { return null }
  23617. } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
  23618. if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) }
  23619. else { return null }
  23620. } else {
  23621. return new Pos(pos.line, pos.ch + dir)
  23622. }
  23623. }
  23624. function selectAll(cm) {
  23625. cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll)
  23626. }
  23627. // UPDATING
  23628. // Allow "beforeChange" event handlers to influence a change
  23629. function filterChange(doc, change, update) {
  23630. var obj = {
  23631. canceled: false,
  23632. from: change.from,
  23633. to: change.to,
  23634. text: change.text,
  23635. origin: change.origin,
  23636. cancel: function () { return obj.canceled = true; }
  23637. }
  23638. if (update) { obj.update = function (from, to, text, origin) {
  23639. if (from) { obj.from = clipPos(doc, from) }
  23640. if (to) { obj.to = clipPos(doc, to) }
  23641. if (text) { obj.text = text }
  23642. if (origin !== undefined) { obj.origin = origin }
  23643. } }
  23644. signal(doc, "beforeChange", doc, obj)
  23645. if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj) }
  23646. if (obj.canceled) { return null }
  23647. return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}
  23648. }
  23649. // Apply a change to a document, and add it to the document's
  23650. // history, and propagating it to all linked documents.
  23651. function makeChange(doc, change, ignoreReadOnly) {
  23652. if (doc.cm) {
  23653. if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) }
  23654. if (doc.cm.state.suppressEdits) { return }
  23655. }
  23656. if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
  23657. change = filterChange(doc, change, true)
  23658. if (!change) { return }
  23659. }
  23660. // Possibly split or suppress the update based on the presence
  23661. // of read-only spans in its range.
  23662. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to)
  23663. if (split) {
  23664. for (var i = split.length - 1; i >= 0; --i)
  23665. { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text}) }
  23666. } else {
  23667. makeChangeInner(doc, change)
  23668. }
  23669. }
  23670. function makeChangeInner(doc, change) {
  23671. if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return }
  23672. var selAfter = computeSelAfterChange(doc, change)
  23673. addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN)
  23674. makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change))
  23675. var rebased = []
  23676. linkedDocs(doc, function (doc, sharedHist) {
  23677. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  23678. rebaseHist(doc.history, change)
  23679. rebased.push(doc.history)
  23680. }
  23681. makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change))
  23682. })
  23683. }
  23684. // Revert a change stored in a document's history.
  23685. function makeChangeFromHistory(doc, type, allowSelectionOnly) {
  23686. if (doc.cm && doc.cm.state.suppressEdits && !allowSelectionOnly) { return }
  23687. var hist = doc.history, event, selAfter = doc.sel
  23688. var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done
  23689. // Verify that there is a useable event (so that ctrl-z won't
  23690. // needlessly clear selection events)
  23691. var i = 0
  23692. for (; i < source.length; i++) {
  23693. event = source[i]
  23694. if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
  23695. { break }
  23696. }
  23697. if (i == source.length) { return }
  23698. hist.lastOrigin = hist.lastSelOrigin = null
  23699. for (;;) {
  23700. event = source.pop()
  23701. if (event.ranges) {
  23702. pushSelectionToHistory(event, dest)
  23703. if (allowSelectionOnly && !event.equals(doc.sel)) {
  23704. setSelection(doc, event, {clearRedo: false})
  23705. return
  23706. }
  23707. selAfter = event
  23708. }
  23709. else { break }
  23710. }
  23711. // Build up a reverse change object to add to the opposite history
  23712. // stack (redo when undoing, and vice versa).
  23713. var antiChanges = []
  23714. pushSelectionToHistory(selAfter, dest)
  23715. dest.push({changes: antiChanges, generation: hist.generation})
  23716. hist.generation = event.generation || ++hist.maxGeneration
  23717. var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")
  23718. var loop = function ( i ) {
  23719. var change = event.changes[i]
  23720. change.origin = type
  23721. if (filter && !filterChange(doc, change, false)) {
  23722. source.length = 0
  23723. return {}
  23724. }
  23725. antiChanges.push(historyChangeFromChange(doc, change))
  23726. var after = i ? computeSelAfterChange(doc, change) : lst(source)
  23727. makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change))
  23728. if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}) }
  23729. var rebased = []
  23730. // Propagate to the linked documents
  23731. linkedDocs(doc, function (doc, sharedHist) {
  23732. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  23733. rebaseHist(doc.history, change)
  23734. rebased.push(doc.history)
  23735. }
  23736. makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change))
  23737. })
  23738. };
  23739. for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {
  23740. var returned = loop( i$1 );
  23741. if ( returned ) return returned.v;
  23742. }
  23743. }
  23744. // Sub-views need their line numbers shifted when text is added
  23745. // above or below them in the parent document.
  23746. function shiftDoc(doc, distance) {
  23747. if (distance == 0) { return }
  23748. doc.first += distance
  23749. doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range(
  23750. Pos(range.anchor.line + distance, range.anchor.ch),
  23751. Pos(range.head.line + distance, range.head.ch)
  23752. ); }), doc.sel.primIndex)
  23753. if (doc.cm) {
  23754. regChange(doc.cm, doc.first, doc.first - distance, distance)
  23755. for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
  23756. { regLineChange(doc.cm, l, "gutter") }
  23757. }
  23758. }
  23759. // More lower-level change function, handling only a single document
  23760. // (not linked ones).
  23761. function makeChangeSingleDoc(doc, change, selAfter, spans) {
  23762. if (doc.cm && !doc.cm.curOp)
  23763. { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }
  23764. if (change.to.line < doc.first) {
  23765. shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line))
  23766. return
  23767. }
  23768. if (change.from.line > doc.lastLine()) { return }
  23769. // Clip the change to the size of this doc
  23770. if (change.from.line < doc.first) {
  23771. var shift = change.text.length - 1 - (doc.first - change.from.line)
  23772. shiftDoc(doc, shift)
  23773. change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
  23774. text: [lst(change.text)], origin: change.origin}
  23775. }
  23776. var last = doc.lastLine()
  23777. if (change.to.line > last) {
  23778. change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
  23779. text: [change.text[0]], origin: change.origin}
  23780. }
  23781. change.removed = getBetween(doc, change.from, change.to)
  23782. if (!selAfter) { selAfter = computeSelAfterChange(doc, change) }
  23783. if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans) }
  23784. else { updateDoc(doc, change, spans) }
  23785. setSelectionNoUndo(doc, selAfter, sel_dontScroll)
  23786. }
  23787. // Handle the interaction of a change to a document with the editor
  23788. // that this document is part of.
  23789. function makeChangeSingleDocInEditor(cm, change, spans) {
  23790. var doc = cm.doc, display = cm.display, from = change.from, to = change.to
  23791. var recomputeMaxLength = false, checkWidthStart = from.line
  23792. if (!cm.options.lineWrapping) {
  23793. checkWidthStart = lineNo(visualLine(getLine(doc, from.line)))
  23794. doc.iter(checkWidthStart, to.line + 1, function (line) {
  23795. if (line == display.maxLine) {
  23796. recomputeMaxLength = true
  23797. return true
  23798. }
  23799. })
  23800. }
  23801. if (doc.sel.contains(change.from, change.to) > -1)
  23802. { signalCursorActivity(cm) }
  23803. updateDoc(doc, change, spans, estimateHeight(cm))
  23804. if (!cm.options.lineWrapping) {
  23805. doc.iter(checkWidthStart, from.line + change.text.length, function (line) {
  23806. var len = lineLength(line)
  23807. if (len > display.maxLineLength) {
  23808. display.maxLine = line
  23809. display.maxLineLength = len
  23810. display.maxLineChanged = true
  23811. recomputeMaxLength = false
  23812. }
  23813. })
  23814. if (recomputeMaxLength) { cm.curOp.updateMaxLine = true }
  23815. }
  23816. // Adjust frontier, schedule worker
  23817. doc.frontier = Math.min(doc.frontier, from.line)
  23818. startWorker(cm, 400)
  23819. var lendiff = change.text.length - (to.line - from.line) - 1
  23820. // Remember that these lines changed, for updating the display
  23821. if (change.full)
  23822. { regChange(cm) }
  23823. else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
  23824. { regLineChange(cm, from.line, "text") }
  23825. else
  23826. { regChange(cm, from.line, to.line + 1, lendiff) }
  23827. var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change")
  23828. if (changeHandler || changesHandler) {
  23829. var obj = {
  23830. from: from, to: to,
  23831. text: change.text,
  23832. removed: change.removed,
  23833. origin: change.origin
  23834. }
  23835. if (changeHandler) { signalLater(cm, "change", cm, obj) }
  23836. if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj) }
  23837. }
  23838. cm.display.selForContextMenu = null
  23839. }
  23840. function replaceRange(doc, code, from, to, origin) {
  23841. if (!to) { to = from }
  23842. if (cmp(to, from) < 0) { var tmp = to; to = from; from = tmp }
  23843. if (typeof code == "string") { code = doc.splitLines(code) }
  23844. makeChange(doc, {from: from, to: to, text: code, origin: origin})
  23845. }
  23846. // Rebasing/resetting history to deal with externally-sourced changes
  23847. function rebaseHistSelSingle(pos, from, to, diff) {
  23848. if (to < pos.line) {
  23849. pos.line += diff
  23850. } else if (from < pos.line) {
  23851. pos.line = from
  23852. pos.ch = 0
  23853. }
  23854. }
  23855. // Tries to rebase an array of history events given a change in the
  23856. // document. If the change touches the same lines as the event, the
  23857. // event, and everything 'behind' it, is discarded. If the change is
  23858. // before the event, the event's positions are updated. Uses a
  23859. // copy-on-write scheme for the positions, to avoid having to
  23860. // reallocate them all on every rebase, but also avoid problems with
  23861. // shared position objects being unsafely updated.
  23862. function rebaseHistArray(array, from, to, diff) {
  23863. for (var i = 0; i < array.length; ++i) {
  23864. var sub = array[i], ok = true
  23865. if (sub.ranges) {
  23866. if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true }
  23867. for (var j = 0; j < sub.ranges.length; j++) {
  23868. rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff)
  23869. rebaseHistSelSingle(sub.ranges[j].head, from, to, diff)
  23870. }
  23871. continue
  23872. }
  23873. for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
  23874. var cur = sub.changes[j$1]
  23875. if (to < cur.from.line) {
  23876. cur.from = Pos(cur.from.line + diff, cur.from.ch)
  23877. cur.to = Pos(cur.to.line + diff, cur.to.ch)
  23878. } else if (from <= cur.to.line) {
  23879. ok = false
  23880. break
  23881. }
  23882. }
  23883. if (!ok) {
  23884. array.splice(0, i + 1)
  23885. i = 0
  23886. }
  23887. }
  23888. }
  23889. function rebaseHist(hist, change) {
  23890. var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1
  23891. rebaseHistArray(hist.done, from, to, diff)
  23892. rebaseHistArray(hist.undone, from, to, diff)
  23893. }
  23894. // Utility for applying a change to a line by handle or number,
  23895. // returning the number and optionally registering the line as
  23896. // changed.
  23897. function changeLine(doc, handle, changeType, op) {
  23898. var no = handle, line = handle
  23899. if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)) }
  23900. else { no = lineNo(handle) }
  23901. if (no == null) { return null }
  23902. if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType) }
  23903. return line
  23904. }
  23905. // The document is represented as a BTree consisting of leaves, with
  23906. // chunk of lines in them, and branches, with up to ten leaves or
  23907. // other branch nodes below them. The top node is always a branch
  23908. // node, and is the document object itself (meaning it has
  23909. // additional methods and properties).
  23910. //
  23911. // All nodes have parent links. The tree is used both to go from
  23912. // line numbers to line objects, and to go from objects to numbers.
  23913. // It also indexes by height, and is used to convert between height
  23914. // and line object, and to find the total height of the document.
  23915. //
  23916. // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
  23917. function LeafChunk(lines) {
  23918. var this$1 = this;
  23919. this.lines = lines
  23920. this.parent = null
  23921. var height = 0
  23922. for (var i = 0; i < lines.length; ++i) {
  23923. lines[i].parent = this$1
  23924. height += lines[i].height
  23925. }
  23926. this.height = height
  23927. }
  23928. LeafChunk.prototype = {
  23929. chunkSize: function() { return this.lines.length },
  23930. // Remove the n lines at offset 'at'.
  23931. removeInner: function(at, n) {
  23932. var this$1 = this;
  23933. for (var i = at, e = at + n; i < e; ++i) {
  23934. var line = this$1.lines[i]
  23935. this$1.height -= line.height
  23936. cleanUpLine(line)
  23937. signalLater(line, "delete")
  23938. }
  23939. this.lines.splice(at, n)
  23940. },
  23941. // Helper used to collapse a small branch into a single leaf.
  23942. collapse: function(lines) {
  23943. lines.push.apply(lines, this.lines)
  23944. },
  23945. // Insert the given array of lines at offset 'at', count them as
  23946. // having the given height.
  23947. insertInner: function(at, lines, height) {
  23948. var this$1 = this;
  23949. this.height += height
  23950. this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at))
  23951. for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1 }
  23952. },
  23953. // Used to iterate over a part of the tree.
  23954. iterN: function(at, n, op) {
  23955. var this$1 = this;
  23956. for (var e = at + n; at < e; ++at)
  23957. { if (op(this$1.lines[at])) { return true } }
  23958. }
  23959. }
  23960. function BranchChunk(children) {
  23961. var this$1 = this;
  23962. this.children = children
  23963. var size = 0, height = 0
  23964. for (var i = 0; i < children.length; ++i) {
  23965. var ch = children[i]
  23966. size += ch.chunkSize(); height += ch.height
  23967. ch.parent = this$1
  23968. }
  23969. this.size = size
  23970. this.height = height
  23971. this.parent = null
  23972. }
  23973. BranchChunk.prototype = {
  23974. chunkSize: function() { return this.size },
  23975. removeInner: function(at, n) {
  23976. var this$1 = this;
  23977. this.size -= n
  23978. for (var i = 0; i < this.children.length; ++i) {
  23979. var child = this$1.children[i], sz = child.chunkSize()
  23980. if (at < sz) {
  23981. var rm = Math.min(n, sz - at), oldHeight = child.height
  23982. child.removeInner(at, rm)
  23983. this$1.height -= oldHeight - child.height
  23984. if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null }
  23985. if ((n -= rm) == 0) { break }
  23986. at = 0
  23987. } else { at -= sz }
  23988. }
  23989. // If the result is smaller than 25 lines, ensure that it is a
  23990. // single leaf node.
  23991. if (this.size - n < 25 &&
  23992. (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
  23993. var lines = []
  23994. this.collapse(lines)
  23995. this.children = [new LeafChunk(lines)]
  23996. this.children[0].parent = this
  23997. }
  23998. },
  23999. collapse: function(lines) {
  24000. var this$1 = this;
  24001. for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines) }
  24002. },
  24003. insertInner: function(at, lines, height) {
  24004. var this$1 = this;
  24005. this.size += lines.length
  24006. this.height += height
  24007. for (var i = 0; i < this.children.length; ++i) {
  24008. var child = this$1.children[i], sz = child.chunkSize()
  24009. if (at <= sz) {
  24010. child.insertInner(at, lines, height)
  24011. if (child.lines && child.lines.length > 50) {
  24012. // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
  24013. // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
  24014. var remaining = child.lines.length % 25 + 25
  24015. for (var pos = remaining; pos < child.lines.length;) {
  24016. var leaf = new LeafChunk(child.lines.slice(pos, pos += 25))
  24017. child.height -= leaf.height
  24018. this$1.children.splice(++i, 0, leaf)
  24019. leaf.parent = this$1
  24020. }
  24021. child.lines = child.lines.slice(0, remaining)
  24022. this$1.maybeSpill()
  24023. }
  24024. break
  24025. }
  24026. at -= sz
  24027. }
  24028. },
  24029. // When a node has grown, check whether it should be split.
  24030. maybeSpill: function() {
  24031. if (this.children.length <= 10) { return }
  24032. var me = this
  24033. do {
  24034. var spilled = me.children.splice(me.children.length - 5, 5)
  24035. var sibling = new BranchChunk(spilled)
  24036. if (!me.parent) { // Become the parent node
  24037. var copy = new BranchChunk(me.children)
  24038. copy.parent = me
  24039. me.children = [copy, sibling]
  24040. me = copy
  24041. } else {
  24042. me.size -= sibling.size
  24043. me.height -= sibling.height
  24044. var myIndex = indexOf(me.parent.children, me)
  24045. me.parent.children.splice(myIndex + 1, 0, sibling)
  24046. }
  24047. sibling.parent = me.parent
  24048. } while (me.children.length > 10)
  24049. me.parent.maybeSpill()
  24050. },
  24051. iterN: function(at, n, op) {
  24052. var this$1 = this;
  24053. for (var i = 0; i < this.children.length; ++i) {
  24054. var child = this$1.children[i], sz = child.chunkSize()
  24055. if (at < sz) {
  24056. var used = Math.min(n, sz - at)
  24057. if (child.iterN(at, used, op)) { return true }
  24058. if ((n -= used) == 0) { break }
  24059. at = 0
  24060. } else { at -= sz }
  24061. }
  24062. }
  24063. }
  24064. // Line widgets are block elements displayed above or below a line.
  24065. function LineWidget(doc, node, options) {
  24066. var this$1 = this;
  24067. if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
  24068. { this$1[opt] = options[opt] } } }
  24069. this.doc = doc
  24070. this.node = node
  24071. }
  24072. eventMixin(LineWidget)
  24073. function adjustScrollWhenAboveVisible(cm, line, diff) {
  24074. if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
  24075. { addToScrollPos(cm, null, diff) }
  24076. }
  24077. LineWidget.prototype.clear = function() {
  24078. var this$1 = this;
  24079. var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line)
  24080. if (no == null || !ws) { return }
  24081. for (var i = 0; i < ws.length; ++i) { if (ws[i] == this$1) { ws.splice(i--, 1) } }
  24082. if (!ws.length) { line.widgets = null }
  24083. var height = widgetHeight(this)
  24084. updateLineHeight(line, Math.max(0, line.height - height))
  24085. if (cm) { runInOp(cm, function () {
  24086. adjustScrollWhenAboveVisible(cm, line, -height)
  24087. regLineChange(cm, no, "widget")
  24088. }) }
  24089. }
  24090. LineWidget.prototype.changed = function() {
  24091. var oldH = this.height, cm = this.doc.cm, line = this.line
  24092. this.height = null
  24093. var diff = widgetHeight(this) - oldH
  24094. if (!diff) { return }
  24095. updateLineHeight(line, line.height + diff)
  24096. if (cm) { runInOp(cm, function () {
  24097. cm.curOp.forceUpdate = true
  24098. adjustScrollWhenAboveVisible(cm, line, diff)
  24099. }) }
  24100. }
  24101. function addLineWidget(doc, handle, node, options) {
  24102. var widget = new LineWidget(doc, node, options)
  24103. var cm = doc.cm
  24104. if (cm && widget.noHScroll) { cm.display.alignWidgets = true }
  24105. changeLine(doc, handle, "widget", function (line) {
  24106. var widgets = line.widgets || (line.widgets = [])
  24107. if (widget.insertAt == null) { widgets.push(widget) }
  24108. else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget) }
  24109. widget.line = line
  24110. if (cm && !lineIsHidden(doc, line)) {
  24111. var aboveVisible = heightAtLine(line) < doc.scrollTop
  24112. updateLineHeight(line, line.height + widgetHeight(widget))
  24113. if (aboveVisible) { addToScrollPos(cm, null, widget.height) }
  24114. cm.curOp.forceUpdate = true
  24115. }
  24116. return true
  24117. })
  24118. return widget
  24119. }
  24120. // TEXTMARKERS
  24121. // Created with markText and setBookmark methods. A TextMarker is a
  24122. // handle that can be used to clear or find a marked position in the
  24123. // document. Line objects hold arrays (markedSpans) containing
  24124. // {from, to, marker} object pointing to such marker objects, and
  24125. // indicating that such a marker is present on that line. Multiple
  24126. // lines may point to the same marker when it spans across lines.
  24127. // The spans will have null for their from/to properties when the
  24128. // marker continues beyond the start/end of the line. Markers have
  24129. // links back to the lines they currently touch.
  24130. // Collapsed markers have unique ids, in order to be able to order
  24131. // them, which is needed for uniquely determining an outer marker
  24132. // when they overlap (they may nest, but not partially overlap).
  24133. var nextMarkerId = 0
  24134. function TextMarker(doc, type) {
  24135. this.lines = []
  24136. this.type = type
  24137. this.doc = doc
  24138. this.id = ++nextMarkerId
  24139. }
  24140. eventMixin(TextMarker)
  24141. // Clear the marker.
  24142. TextMarker.prototype.clear = function() {
  24143. var this$1 = this;
  24144. if (this.explicitlyCleared) { return }
  24145. var cm = this.doc.cm, withOp = cm && !cm.curOp
  24146. if (withOp) { startOperation(cm) }
  24147. if (hasHandler(this, "clear")) {
  24148. var found = this.find()
  24149. if (found) { signalLater(this, "clear", found.from, found.to) }
  24150. }
  24151. var min = null, max = null
  24152. for (var i = 0; i < this.lines.length; ++i) {
  24153. var line = this$1.lines[i]
  24154. var span = getMarkedSpanFor(line.markedSpans, this$1)
  24155. if (cm && !this$1.collapsed) { regLineChange(cm, lineNo(line), "text") }
  24156. else if (cm) {
  24157. if (span.to != null) { max = lineNo(line) }
  24158. if (span.from != null) { min = lineNo(line) }
  24159. }
  24160. line.markedSpans = removeMarkedSpan(line.markedSpans, span)
  24161. if (span.from == null && this$1.collapsed && !lineIsHidden(this$1.doc, line) && cm)
  24162. { updateLineHeight(line, textHeight(cm.display)) }
  24163. }
  24164. if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {
  24165. var visual = visualLine(this$1.lines[i$1]), len = lineLength(visual)
  24166. if (len > cm.display.maxLineLength) {
  24167. cm.display.maxLine = visual
  24168. cm.display.maxLineLength = len
  24169. cm.display.maxLineChanged = true
  24170. }
  24171. } }
  24172. if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1) }
  24173. this.lines.length = 0
  24174. this.explicitlyCleared = true
  24175. if (this.atomic && this.doc.cantEdit) {
  24176. this.doc.cantEdit = false
  24177. if (cm) { reCheckSelection(cm.doc) }
  24178. }
  24179. if (cm) { signalLater(cm, "markerCleared", cm, this) }
  24180. if (withOp) { endOperation(cm) }
  24181. if (this.parent) { this.parent.clear() }
  24182. }
  24183. // Find the position of the marker in the document. Returns a {from,
  24184. // to} object by default. Side can be passed to get a specific side
  24185. // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
  24186. // Pos objects returned contain a line object, rather than a line
  24187. // number (used to prevent looking up the same line twice).
  24188. TextMarker.prototype.find = function(side, lineObj) {
  24189. var this$1 = this;
  24190. if (side == null && this.type == "bookmark") { side = 1 }
  24191. var from, to
  24192. for (var i = 0; i < this.lines.length; ++i) {
  24193. var line = this$1.lines[i]
  24194. var span = getMarkedSpanFor(line.markedSpans, this$1)
  24195. if (span.from != null) {
  24196. from = Pos(lineObj ? line : lineNo(line), span.from)
  24197. if (side == -1) { return from }
  24198. }
  24199. if (span.to != null) {
  24200. to = Pos(lineObj ? line : lineNo(line), span.to)
  24201. if (side == 1) { return to }
  24202. }
  24203. }
  24204. return from && {from: from, to: to}
  24205. }
  24206. // Signals that the marker's widget changed, and surrounding layout
  24207. // should be recomputed.
  24208. TextMarker.prototype.changed = function() {
  24209. var pos = this.find(-1, true), widget = this, cm = this.doc.cm
  24210. if (!pos || !cm) { return }
  24211. runInOp(cm, function () {
  24212. var line = pos.line, lineN = lineNo(pos.line)
  24213. var view = findViewForLine(cm, lineN)
  24214. if (view) {
  24215. clearLineMeasurementCacheFor(view)
  24216. cm.curOp.selectionChanged = cm.curOp.forceUpdate = true
  24217. }
  24218. cm.curOp.updateMaxLine = true
  24219. if (!lineIsHidden(widget.doc, line) && widget.height != null) {
  24220. var oldHeight = widget.height
  24221. widget.height = null
  24222. var dHeight = widgetHeight(widget) - oldHeight
  24223. if (dHeight)
  24224. { updateLineHeight(line, line.height + dHeight) }
  24225. }
  24226. })
  24227. }
  24228. TextMarker.prototype.attachLine = function(line) {
  24229. if (!this.lines.length && this.doc.cm) {
  24230. var op = this.doc.cm.curOp
  24231. if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
  24232. { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this) }
  24233. }
  24234. this.lines.push(line)
  24235. }
  24236. TextMarker.prototype.detachLine = function(line) {
  24237. this.lines.splice(indexOf(this.lines, line), 1)
  24238. if (!this.lines.length && this.doc.cm) {
  24239. var op = this.doc.cm.curOp
  24240. ;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this)
  24241. }
  24242. }
  24243. // Create a marker, wire it up to the right lines, and
  24244. function markText(doc, from, to, options, type) {
  24245. // Shared markers (across linked documents) are handled separately
  24246. // (markTextShared will call out to this again, once per
  24247. // document).
  24248. if (options && options.shared) { return markTextShared(doc, from, to, options, type) }
  24249. // Ensure we are in an operation.
  24250. if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) }
  24251. var marker = new TextMarker(doc, type), diff = cmp(from, to)
  24252. if (options) { copyObj(options, marker, false) }
  24253. // Don't connect empty markers unless clearWhenEmpty is false
  24254. if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
  24255. { return marker }
  24256. if (marker.replacedWith) {
  24257. // Showing up as a widget implies collapsed (widget replaces text)
  24258. marker.collapsed = true
  24259. marker.widgetNode = elt("span", [marker.replacedWith], "CodeMirror-widget")
  24260. marker.widgetNode.setAttribute("role", "presentation") // hide from accessibility tree
  24261. if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true") }
  24262. if (options.insertLeft) { marker.widgetNode.insertLeft = true }
  24263. }
  24264. if (marker.collapsed) {
  24265. if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
  24266. from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
  24267. { throw new Error("Inserting collapsed marker partially overlapping an existing one") }
  24268. seeCollapsedSpans()
  24269. }
  24270. if (marker.addToHistory)
  24271. { addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN) }
  24272. var curLine = from.line, cm = doc.cm, updateMaxLine
  24273. doc.iter(curLine, to.line + 1, function (line) {
  24274. if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
  24275. { updateMaxLine = true }
  24276. if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0) }
  24277. addMarkedSpan(line, new MarkedSpan(marker,
  24278. curLine == from.line ? from.ch : null,
  24279. curLine == to.line ? to.ch : null))
  24280. ++curLine
  24281. })
  24282. // lineIsHidden depends on the presence of the spans, so needs a second pass
  24283. if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) {
  24284. if (lineIsHidden(doc, line)) { updateLineHeight(line, 0) }
  24285. }) }
  24286. if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }) }
  24287. if (marker.readOnly) {
  24288. seeReadOnlySpans()
  24289. if (doc.history.done.length || doc.history.undone.length)
  24290. { doc.clearHistory() }
  24291. }
  24292. if (marker.collapsed) {
  24293. marker.id = ++nextMarkerId
  24294. marker.atomic = true
  24295. }
  24296. if (cm) {
  24297. // Sync editor state
  24298. if (updateMaxLine) { cm.curOp.updateMaxLine = true }
  24299. if (marker.collapsed)
  24300. { regChange(cm, from.line, to.line + 1) }
  24301. else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
  24302. { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text") } }
  24303. if (marker.atomic) { reCheckSelection(cm.doc) }
  24304. signalLater(cm, "markerAdded", cm, marker)
  24305. }
  24306. return marker
  24307. }
  24308. // SHARED TEXTMARKERS
  24309. // A shared marker spans multiple linked documents. It is
  24310. // implemented as a meta-marker-object controlling multiple normal
  24311. // markers.
  24312. function SharedTextMarker(markers, primary) {
  24313. var this$1 = this;
  24314. this.markers = markers
  24315. this.primary = primary
  24316. for (var i = 0; i < markers.length; ++i)
  24317. { markers[i].parent = this$1 }
  24318. }
  24319. eventMixin(SharedTextMarker)
  24320. SharedTextMarker.prototype.clear = function() {
  24321. var this$1 = this;
  24322. if (this.explicitlyCleared) { return }
  24323. this.explicitlyCleared = true
  24324. for (var i = 0; i < this.markers.length; ++i)
  24325. { this$1.markers[i].clear() }
  24326. signalLater(this, "clear")
  24327. }
  24328. SharedTextMarker.prototype.find = function(side, lineObj) {
  24329. return this.primary.find(side, lineObj)
  24330. }
  24331. function markTextShared(doc, from, to, options, type) {
  24332. options = copyObj(options)
  24333. options.shared = false
  24334. var markers = [markText(doc, from, to, options, type)], primary = markers[0]
  24335. var widget = options.widgetNode
  24336. linkedDocs(doc, function (doc) {
  24337. if (widget) { options.widgetNode = widget.cloneNode(true) }
  24338. markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type))
  24339. for (var i = 0; i < doc.linked.length; ++i)
  24340. { if (doc.linked[i].isParent) { return } }
  24341. primary = lst(markers)
  24342. })
  24343. return new SharedTextMarker(markers, primary)
  24344. }
  24345. function findSharedMarkers(doc) {
  24346. return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; })
  24347. }
  24348. function copySharedMarkers(doc, markers) {
  24349. for (var i = 0; i < markers.length; i++) {
  24350. var marker = markers[i], pos = marker.find()
  24351. var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to)
  24352. if (cmp(mFrom, mTo)) {
  24353. var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type)
  24354. marker.markers.push(subMark)
  24355. subMark.parent = marker
  24356. }
  24357. }
  24358. }
  24359. function detachSharedMarkers(markers) {
  24360. var loop = function ( i ) {
  24361. var marker = markers[i], linked = [marker.primary.doc]
  24362. linkedDocs(marker.primary.doc, function (d) { return linked.push(d); })
  24363. for (var j = 0; j < marker.markers.length; j++) {
  24364. var subMarker = marker.markers[j]
  24365. if (indexOf(linked, subMarker.doc) == -1) {
  24366. subMarker.parent = null
  24367. marker.markers.splice(j--, 1)
  24368. }
  24369. }
  24370. };
  24371. for (var i = 0; i < markers.length; i++) loop( i );
  24372. }
  24373. var nextDocId = 0
  24374. var Doc = function(text, mode, firstLine, lineSep) {
  24375. if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep) }
  24376. if (firstLine == null) { firstLine = 0 }
  24377. BranchChunk.call(this, [new LeafChunk([new Line("", null)])])
  24378. this.first = firstLine
  24379. this.scrollTop = this.scrollLeft = 0
  24380. this.cantEdit = false
  24381. this.cleanGeneration = 1
  24382. this.frontier = firstLine
  24383. var start = Pos(firstLine, 0)
  24384. this.sel = simpleSelection(start)
  24385. this.history = new History(null)
  24386. this.id = ++nextDocId
  24387. this.modeOption = mode
  24388. this.lineSep = lineSep
  24389. this.extend = false
  24390. if (typeof text == "string") { text = this.splitLines(text) }
  24391. updateDoc(this, {from: start, to: start, text: text})
  24392. setSelection(this, simpleSelection(start), sel_dontScroll)
  24393. }
  24394. Doc.prototype = createObj(BranchChunk.prototype, {
  24395. constructor: Doc,
  24396. // Iterate over the document. Supports two forms -- with only one
  24397. // argument, it calls that for each line in the document. With
  24398. // three, it iterates over the range given by the first two (with
  24399. // the second being non-inclusive).
  24400. iter: function(from, to, op) {
  24401. if (op) { this.iterN(from - this.first, to - from, op) }
  24402. else { this.iterN(this.first, this.first + this.size, from) }
  24403. },
  24404. // Non-public interface for adding and removing lines.
  24405. insert: function(at, lines) {
  24406. var height = 0
  24407. for (var i = 0; i < lines.length; ++i) { height += lines[i].height }
  24408. this.insertInner(at - this.first, lines, height)
  24409. },
  24410. remove: function(at, n) { this.removeInner(at - this.first, n) },
  24411. // From here, the methods are part of the public interface. Most
  24412. // are also available from CodeMirror (editor) instances.
  24413. getValue: function(lineSep) {
  24414. var lines = getLines(this, this.first, this.first + this.size)
  24415. if (lineSep === false) { return lines }
  24416. return lines.join(lineSep || this.lineSeparator())
  24417. },
  24418. setValue: docMethodOp(function(code) {
  24419. var top = Pos(this.first, 0), last = this.first + this.size - 1
  24420. makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
  24421. text: this.splitLines(code), origin: "setValue", full: true}, true)
  24422. setSelection(this, simpleSelection(top))
  24423. }),
  24424. replaceRange: function(code, from, to, origin) {
  24425. from = clipPos(this, from)
  24426. to = to ? clipPos(this, to) : from
  24427. replaceRange(this, code, from, to, origin)
  24428. },
  24429. getRange: function(from, to, lineSep) {
  24430. var lines = getBetween(this, clipPos(this, from), clipPos(this, to))
  24431. if (lineSep === false) { return lines }
  24432. return lines.join(lineSep || this.lineSeparator())
  24433. },
  24434. getLine: function(line) {var l = this.getLineHandle(line); return l && l.text},
  24435. getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }},
  24436. getLineNumber: function(line) {return lineNo(line)},
  24437. getLineHandleVisualStart: function(line) {
  24438. if (typeof line == "number") { line = getLine(this, line) }
  24439. return visualLine(line)
  24440. },
  24441. lineCount: function() {return this.size},
  24442. firstLine: function() {return this.first},
  24443. lastLine: function() {return this.first + this.size - 1},
  24444. clipPos: function(pos) {return clipPos(this, pos)},
  24445. getCursor: function(start) {
  24446. var range = this.sel.primary(), pos
  24447. if (start == null || start == "head") { pos = range.head }
  24448. else if (start == "anchor") { pos = range.anchor }
  24449. else if (start == "end" || start == "to" || start === false) { pos = range.to() }
  24450. else { pos = range.from() }
  24451. return pos
  24452. },
  24453. listSelections: function() { return this.sel.ranges },
  24454. somethingSelected: function() {return this.sel.somethingSelected()},
  24455. setCursor: docMethodOp(function(line, ch, options) {
  24456. setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options)
  24457. }),
  24458. setSelection: docMethodOp(function(anchor, head, options) {
  24459. setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options)
  24460. }),
  24461. extendSelection: docMethodOp(function(head, other, options) {
  24462. extendSelection(this, clipPos(this, head), other && clipPos(this, other), options)
  24463. }),
  24464. extendSelections: docMethodOp(function(heads, options) {
  24465. extendSelections(this, clipPosArray(this, heads), options)
  24466. }),
  24467. extendSelectionsBy: docMethodOp(function(f, options) {
  24468. var heads = map(this.sel.ranges, f)
  24469. extendSelections(this, clipPosArray(this, heads), options)
  24470. }),
  24471. setSelections: docMethodOp(function(ranges, primary, options) {
  24472. var this$1 = this;
  24473. if (!ranges.length) { return }
  24474. var out = []
  24475. for (var i = 0; i < ranges.length; i++)
  24476. { out[i] = new Range(clipPos(this$1, ranges[i].anchor),
  24477. clipPos(this$1, ranges[i].head)) }
  24478. if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex) }
  24479. setSelection(this, normalizeSelection(out, primary), options)
  24480. }),
  24481. addSelection: docMethodOp(function(anchor, head, options) {
  24482. var ranges = this.sel.ranges.slice(0)
  24483. ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)))
  24484. setSelection(this, normalizeSelection(ranges, ranges.length - 1), options)
  24485. }),
  24486. getSelection: function(lineSep) {
  24487. var this$1 = this;
  24488. var ranges = this.sel.ranges, lines
  24489. for (var i = 0; i < ranges.length; i++) {
  24490. var sel = getBetween(this$1, ranges[i].from(), ranges[i].to())
  24491. lines = lines ? lines.concat(sel) : sel
  24492. }
  24493. if (lineSep === false) { return lines }
  24494. else { return lines.join(lineSep || this.lineSeparator()) }
  24495. },
  24496. getSelections: function(lineSep) {
  24497. var this$1 = this;
  24498. var parts = [], ranges = this.sel.ranges
  24499. for (var i = 0; i < ranges.length; i++) {
  24500. var sel = getBetween(this$1, ranges[i].from(), ranges[i].to())
  24501. if (lineSep !== false) { sel = sel.join(lineSep || this$1.lineSeparator()) }
  24502. parts[i] = sel
  24503. }
  24504. return parts
  24505. },
  24506. replaceSelection: function(code, collapse, origin) {
  24507. var dup = []
  24508. for (var i = 0; i < this.sel.ranges.length; i++)
  24509. { dup[i] = code }
  24510. this.replaceSelections(dup, collapse, origin || "+input")
  24511. },
  24512. replaceSelections: docMethodOp(function(code, collapse, origin) {
  24513. var this$1 = this;
  24514. var changes = [], sel = this.sel
  24515. for (var i = 0; i < sel.ranges.length; i++) {
  24516. var range = sel.ranges[i]
  24517. changes[i] = {from: range.from(), to: range.to(), text: this$1.splitLines(code[i]), origin: origin}
  24518. }
  24519. var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse)
  24520. for (var i$1 = changes.length - 1; i$1 >= 0; i$1--)
  24521. { makeChange(this$1, changes[i$1]) }
  24522. if (newSel) { setSelectionReplaceHistory(this, newSel) }
  24523. else if (this.cm) { ensureCursorVisible(this.cm) }
  24524. }),
  24525. undo: docMethodOp(function() {makeChangeFromHistory(this, "undo")}),
  24526. redo: docMethodOp(function() {makeChangeFromHistory(this, "redo")}),
  24527. undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true)}),
  24528. redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true)}),
  24529. setExtending: function(val) {this.extend = val},
  24530. getExtending: function() {return this.extend},
  24531. historySize: function() {
  24532. var hist = this.history, done = 0, undone = 0
  24533. for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done } }
  24534. for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone } }
  24535. return {undo: done, redo: undone}
  24536. },
  24537. clearHistory: function() {this.history = new History(this.history.maxGeneration)},
  24538. markClean: function() {
  24539. this.cleanGeneration = this.changeGeneration(true)
  24540. },
  24541. changeGeneration: function(forceSplit) {
  24542. if (forceSplit)
  24543. { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null }
  24544. return this.history.generation
  24545. },
  24546. isClean: function (gen) {
  24547. return this.history.generation == (gen || this.cleanGeneration)
  24548. },
  24549. getHistory: function() {
  24550. return {done: copyHistoryArray(this.history.done),
  24551. undone: copyHistoryArray(this.history.undone)}
  24552. },
  24553. setHistory: function(histData) {
  24554. var hist = this.history = new History(this.history.maxGeneration)
  24555. hist.done = copyHistoryArray(histData.done.slice(0), null, true)
  24556. hist.undone = copyHistoryArray(histData.undone.slice(0), null, true)
  24557. },
  24558. setGutterMarker: docMethodOp(function(line, gutterID, value) {
  24559. return changeLine(this, line, "gutter", function (line) {
  24560. var markers = line.gutterMarkers || (line.gutterMarkers = {})
  24561. markers[gutterID] = value
  24562. if (!value && isEmpty(markers)) { line.gutterMarkers = null }
  24563. return true
  24564. })
  24565. }),
  24566. clearGutter: docMethodOp(function(gutterID) {
  24567. var this$1 = this;
  24568. this.iter(function (line) {
  24569. if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
  24570. changeLine(this$1, line, "gutter", function () {
  24571. line.gutterMarkers[gutterID] = null
  24572. if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null }
  24573. return true
  24574. })
  24575. }
  24576. })
  24577. }),
  24578. lineInfo: function(line) {
  24579. var n
  24580. if (typeof line == "number") {
  24581. if (!isLine(this, line)) { return null }
  24582. n = line
  24583. line = getLine(this, line)
  24584. if (!line) { return null }
  24585. } else {
  24586. n = lineNo(line)
  24587. if (n == null) { return null }
  24588. }
  24589. return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
  24590. textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
  24591. widgets: line.widgets}
  24592. },
  24593. addLineClass: docMethodOp(function(handle, where, cls) {
  24594. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  24595. var prop = where == "text" ? "textClass"
  24596. : where == "background" ? "bgClass"
  24597. : where == "gutter" ? "gutterClass" : "wrapClass"
  24598. if (!line[prop]) { line[prop] = cls }
  24599. else if (classTest(cls).test(line[prop])) { return false }
  24600. else { line[prop] += " " + cls }
  24601. return true
  24602. })
  24603. }),
  24604. removeLineClass: docMethodOp(function(handle, where, cls) {
  24605. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  24606. var prop = where == "text" ? "textClass"
  24607. : where == "background" ? "bgClass"
  24608. : where == "gutter" ? "gutterClass" : "wrapClass"
  24609. var cur = line[prop]
  24610. if (!cur) { return false }
  24611. else if (cls == null) { line[prop] = null }
  24612. else {
  24613. var found = cur.match(classTest(cls))
  24614. if (!found) { return false }
  24615. var end = found.index + found[0].length
  24616. line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null
  24617. }
  24618. return true
  24619. })
  24620. }),
  24621. addLineWidget: docMethodOp(function(handle, node, options) {
  24622. return addLineWidget(this, handle, node, options)
  24623. }),
  24624. removeLineWidget: function(widget) { widget.clear() },
  24625. markText: function(from, to, options) {
  24626. return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range")
  24627. },
  24628. setBookmark: function(pos, options) {
  24629. var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
  24630. insertLeft: options && options.insertLeft,
  24631. clearWhenEmpty: false, shared: options && options.shared,
  24632. handleMouseEvents: options && options.handleMouseEvents}
  24633. pos = clipPos(this, pos)
  24634. return markText(this, pos, pos, realOpts, "bookmark")
  24635. },
  24636. findMarksAt: function(pos) {
  24637. pos = clipPos(this, pos)
  24638. var markers = [], spans = getLine(this, pos.line).markedSpans
  24639. if (spans) { for (var i = 0; i < spans.length; ++i) {
  24640. var span = spans[i]
  24641. if ((span.from == null || span.from <= pos.ch) &&
  24642. (span.to == null || span.to >= pos.ch))
  24643. { markers.push(span.marker.parent || span.marker) }
  24644. } }
  24645. return markers
  24646. },
  24647. findMarks: function(from, to, filter) {
  24648. from = clipPos(this, from); to = clipPos(this, to)
  24649. var found = [], lineNo = from.line
  24650. this.iter(from.line, to.line + 1, function (line) {
  24651. var spans = line.markedSpans
  24652. if (spans) { for (var i = 0; i < spans.length; i++) {
  24653. var span = spans[i]
  24654. if (!(span.to != null && lineNo == from.line && from.ch >= span.to ||
  24655. span.from == null && lineNo != from.line ||
  24656. span.from != null && lineNo == to.line && span.from >= to.ch) &&
  24657. (!filter || filter(span.marker)))
  24658. { found.push(span.marker.parent || span.marker) }
  24659. } }
  24660. ++lineNo
  24661. })
  24662. return found
  24663. },
  24664. getAllMarks: function() {
  24665. var markers = []
  24666. this.iter(function (line) {
  24667. var sps = line.markedSpans
  24668. if (sps) { for (var i = 0; i < sps.length; ++i)
  24669. { if (sps[i].from != null) { markers.push(sps[i].marker) } } }
  24670. })
  24671. return markers
  24672. },
  24673. posFromIndex: function(off) {
  24674. var ch, lineNo = this.first, sepSize = this.lineSeparator().length
  24675. this.iter(function (line) {
  24676. var sz = line.text.length + sepSize
  24677. if (sz > off) { ch = off; return true }
  24678. off -= sz
  24679. ++lineNo
  24680. })
  24681. return clipPos(this, Pos(lineNo, ch))
  24682. },
  24683. indexFromPos: function (coords) {
  24684. coords = clipPos(this, coords)
  24685. var index = coords.ch
  24686. if (coords.line < this.first || coords.ch < 0) { return 0 }
  24687. var sepSize = this.lineSeparator().length
  24688. this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value
  24689. index += line.text.length + sepSize
  24690. })
  24691. return index
  24692. },
  24693. copy: function(copyHistory) {
  24694. var doc = new Doc(getLines(this, this.first, this.first + this.size),
  24695. this.modeOption, this.first, this.lineSep)
  24696. doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft
  24697. doc.sel = this.sel
  24698. doc.extend = false
  24699. if (copyHistory) {
  24700. doc.history.undoDepth = this.history.undoDepth
  24701. doc.setHistory(this.getHistory())
  24702. }
  24703. return doc
  24704. },
  24705. linkedDoc: function(options) {
  24706. if (!options) { options = {} }
  24707. var from = this.first, to = this.first + this.size
  24708. if (options.from != null && options.from > from) { from = options.from }
  24709. if (options.to != null && options.to < to) { to = options.to }
  24710. var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep)
  24711. if (options.sharedHist) { copy.history = this.history
  24712. ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist})
  24713. copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}]
  24714. copySharedMarkers(copy, findSharedMarkers(this))
  24715. return copy
  24716. },
  24717. unlinkDoc: function(other) {
  24718. var this$1 = this;
  24719. if (other instanceof CodeMirror) { other = other.doc }
  24720. if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {
  24721. var link = this$1.linked[i]
  24722. if (link.doc != other) { continue }
  24723. this$1.linked.splice(i, 1)
  24724. other.unlinkDoc(this$1)
  24725. detachSharedMarkers(findSharedMarkers(this$1))
  24726. break
  24727. } }
  24728. // If the histories were shared, split them again
  24729. if (other.history == this.history) {
  24730. var splitIds = [other.id]
  24731. linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true)
  24732. other.history = new History(null)
  24733. other.history.done = copyHistoryArray(this.history.done, splitIds)
  24734. other.history.undone = copyHistoryArray(this.history.undone, splitIds)
  24735. }
  24736. },
  24737. iterLinkedDocs: function(f) {linkedDocs(this, f)},
  24738. getMode: function() {return this.mode},
  24739. getEditor: function() {return this.cm},
  24740. splitLines: function(str) {
  24741. if (this.lineSep) { return str.split(this.lineSep) }
  24742. return splitLinesAuto(str)
  24743. },
  24744. lineSeparator: function() { return this.lineSep || "\n" }
  24745. })
  24746. // Public alias.
  24747. Doc.prototype.eachLine = Doc.prototype.iter
  24748. // Kludge to work around strange IE behavior where it'll sometimes
  24749. // re-fire a series of drag-related events right after the drop (#1551)
  24750. var lastDrop = 0
  24751. function onDrop(e) {
  24752. var cm = this
  24753. clearDragCursor(cm)
  24754. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
  24755. { return }
  24756. e_preventDefault(e)
  24757. if (ie) { lastDrop = +new Date }
  24758. var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files
  24759. if (!pos || cm.isReadOnly()) { return }
  24760. // Might be a file drop, in which case we simply extract the text
  24761. // and insert it.
  24762. if (files && files.length && window.FileReader && window.File) {
  24763. var n = files.length, text = Array(n), read = 0
  24764. var loadFile = function (file, i) {
  24765. if (cm.options.allowDropFileTypes &&
  24766. indexOf(cm.options.allowDropFileTypes, file.type) == -1)
  24767. { return }
  24768. var reader = new FileReader
  24769. reader.onload = operation(cm, function () {
  24770. var content = reader.result
  24771. if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { content = "" }
  24772. text[i] = content
  24773. if (++read == n) {
  24774. pos = clipPos(cm.doc, pos)
  24775. var change = {from: pos, to: pos,
  24776. text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
  24777. origin: "paste"}
  24778. makeChange(cm.doc, change)
  24779. setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)))
  24780. }
  24781. })
  24782. reader.readAsText(file)
  24783. }
  24784. for (var i = 0; i < n; ++i) { loadFile(files[i], i) }
  24785. } else { // Normal drop
  24786. // Don't do a replace if the drop happened inside of the selected text.
  24787. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
  24788. cm.state.draggingText(e)
  24789. // Ensure the editor is re-focused
  24790. setTimeout(function () { return cm.display.input.focus(); }, 20)
  24791. return
  24792. }
  24793. try {
  24794. var text$1 = e.dataTransfer.getData("Text")
  24795. if (text$1) {
  24796. var selected
  24797. if (cm.state.draggingText && !cm.state.draggingText.copy)
  24798. { selected = cm.listSelections() }
  24799. setSelectionNoUndo(cm.doc, simpleSelection(pos, pos))
  24800. if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1)
  24801. { replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag") } }
  24802. cm.replaceSelection(text$1, "around", "paste")
  24803. cm.display.input.focus()
  24804. }
  24805. }
  24806. catch(e){}
  24807. }
  24808. }
  24809. function onDragStart(cm, e) {
  24810. if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }
  24811. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return }
  24812. e.dataTransfer.setData("Text", cm.getSelection())
  24813. e.dataTransfer.effectAllowed = "copyMove"
  24814. // Use dummy image instead of default browsers image.
  24815. // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
  24816. if (e.dataTransfer.setDragImage && !safari) {
  24817. var img = elt("img", null, null, "position: fixed; left: 0; top: 0;")
  24818. img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="
  24819. if (presto) {
  24820. img.width = img.height = 1
  24821. cm.display.wrapper.appendChild(img)
  24822. // Force a relayout, or Opera won't use our image for some obscure reason
  24823. img._top = img.offsetTop
  24824. }
  24825. e.dataTransfer.setDragImage(img, 0, 0)
  24826. if (presto) { img.parentNode.removeChild(img) }
  24827. }
  24828. }
  24829. function onDragOver(cm, e) {
  24830. var pos = posFromMouse(cm, e)
  24831. if (!pos) { return }
  24832. var frag = document.createDocumentFragment()
  24833. drawSelectionCursor(cm, pos, frag)
  24834. if (!cm.display.dragCursor) {
  24835. cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors")
  24836. cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv)
  24837. }
  24838. removeChildrenAndAdd(cm.display.dragCursor, frag)
  24839. }
  24840. function clearDragCursor(cm) {
  24841. if (cm.display.dragCursor) {
  24842. cm.display.lineSpace.removeChild(cm.display.dragCursor)
  24843. cm.display.dragCursor = null
  24844. }
  24845. }
  24846. // These must be handled carefully, because naively registering a
  24847. // handler for each editor will cause the editors to never be
  24848. // garbage collected.
  24849. function forEachCodeMirror(f) {
  24850. if (!document.body.getElementsByClassName) { return }
  24851. var byClass = document.body.getElementsByClassName("CodeMirror")
  24852. for (var i = 0; i < byClass.length; i++) {
  24853. var cm = byClass[i].CodeMirror
  24854. if (cm) { f(cm) }
  24855. }
  24856. }
  24857. var globalsRegistered = false
  24858. function ensureGlobalHandlers() {
  24859. if (globalsRegistered) { return }
  24860. registerGlobalHandlers()
  24861. globalsRegistered = true
  24862. }
  24863. function registerGlobalHandlers() {
  24864. // When the window resizes, we need to refresh active editors.
  24865. var resizeTimer
  24866. on(window, "resize", function () {
  24867. if (resizeTimer == null) { resizeTimer = setTimeout(function () {
  24868. resizeTimer = null
  24869. forEachCodeMirror(onResize)
  24870. }, 100) }
  24871. })
  24872. // When the window loses focus, we want to show the editor as blurred
  24873. on(window, "blur", function () { return forEachCodeMirror(onBlur); })
  24874. }
  24875. // Called when the window resizes
  24876. function onResize(cm) {
  24877. var d = cm.display
  24878. if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
  24879. { return }
  24880. // Might be a text scaling operation, clear size caches.
  24881. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null
  24882. d.scrollbarsClipped = false
  24883. cm.setSize()
  24884. }
  24885. var keyNames = {
  24886. 3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
  24887. 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
  24888. 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
  24889. 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
  24890. 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete",
  24891. 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
  24892. 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
  24893. 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
  24894. }
  24895. // Number keys
  24896. for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i) }
  24897. // Alphabetic keys
  24898. for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1) }
  24899. // Function keys
  24900. for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2 }
  24901. var keyMap = {}
  24902. keyMap.basic = {
  24903. "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
  24904. "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
  24905. "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
  24906. "Tab": "defaultTab", "Shift-Tab": "indentAuto",
  24907. "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
  24908. "Esc": "singleSelection"
  24909. }
  24910. // Note that the save and find-related commands aren't defined by
  24911. // default. User code or addons can define them. Unknown commands
  24912. // are simply ignored.
  24913. keyMap.pcDefault = {
  24914. "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
  24915. "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
  24916. "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
  24917. "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
  24918. "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
  24919. "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
  24920. "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
  24921. fallthrough: "basic"
  24922. }
  24923. // Very basic readline/emacs-style bindings, which are standard on Mac.
  24924. keyMap.emacsy = {
  24925. "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
  24926. "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
  24927. "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
  24928. "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
  24929. "Ctrl-O": "openLine"
  24930. }
  24931. keyMap.macDefault = {
  24932. "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
  24933. "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
  24934. "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
  24935. "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
  24936. "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
  24937. "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
  24938. "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
  24939. fallthrough: ["basic", "emacsy"]
  24940. }
  24941. keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault
  24942. // KEYMAP DISPATCH
  24943. function normalizeKeyName(name) {
  24944. var parts = name.split(/-(?!$)/)
  24945. name = parts[parts.length - 1]
  24946. var alt, ctrl, shift, cmd
  24947. for (var i = 0; i < parts.length - 1; i++) {
  24948. var mod = parts[i]
  24949. if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true }
  24950. else if (/^a(lt)?$/i.test(mod)) { alt = true }
  24951. else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true }
  24952. else if (/^s(hift)?$/i.test(mod)) { shift = true }
  24953. else { throw new Error("Unrecognized modifier name: " + mod) }
  24954. }
  24955. if (alt) { name = "Alt-" + name }
  24956. if (ctrl) { name = "Ctrl-" + name }
  24957. if (cmd) { name = "Cmd-" + name }
  24958. if (shift) { name = "Shift-" + name }
  24959. return name
  24960. }
  24961. // This is a kludge to keep keymaps mostly working as raw objects
  24962. // (backwards compatibility) while at the same time support features
  24963. // like normalization and multi-stroke key bindings. It compiles a
  24964. // new normalized keymap, and then updates the old object to reflect
  24965. // this.
  24966. function normalizeKeyMap(keymap) {
  24967. var copy = {}
  24968. for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {
  24969. var value = keymap[keyname]
  24970. if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }
  24971. if (value == "...") { delete keymap[keyname]; continue }
  24972. var keys = map(keyname.split(" "), normalizeKeyName)
  24973. for (var i = 0; i < keys.length; i++) {
  24974. var val = (void 0), name = (void 0)
  24975. if (i == keys.length - 1) {
  24976. name = keys.join(" ")
  24977. val = value
  24978. } else {
  24979. name = keys.slice(0, i + 1).join(" ")
  24980. val = "..."
  24981. }
  24982. var prev = copy[name]
  24983. if (!prev) { copy[name] = val }
  24984. else if (prev != val) { throw new Error("Inconsistent bindings for " + name) }
  24985. }
  24986. delete keymap[keyname]
  24987. } }
  24988. for (var prop in copy) { keymap[prop] = copy[prop] }
  24989. return keymap
  24990. }
  24991. function lookupKey(key, map, handle, context) {
  24992. map = getKeyMap(map)
  24993. var found = map.call ? map.call(key, context) : map[key]
  24994. if (found === false) { return "nothing" }
  24995. if (found === "...") { return "multi" }
  24996. if (found != null && handle(found)) { return "handled" }
  24997. if (map.fallthrough) {
  24998. if (Object.prototype.toString.call(map.fallthrough) != "[object Array]")
  24999. { return lookupKey(key, map.fallthrough, handle, context) }
  25000. for (var i = 0; i < map.fallthrough.length; i++) {
  25001. var result = lookupKey(key, map.fallthrough[i], handle, context)
  25002. if (result) { return result }
  25003. }
  25004. }
  25005. }
  25006. // Modifier key presses don't count as 'real' key presses for the
  25007. // purpose of keymap fallthrough.
  25008. function isModifierKey(value) {
  25009. var name = typeof value == "string" ? value : keyNames[value.keyCode]
  25010. return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"
  25011. }
  25012. // Look up the name of a key as indicated by an event object.
  25013. function keyName(event, noShift) {
  25014. if (presto && event.keyCode == 34 && event["char"]) { return false }
  25015. var base = keyNames[event.keyCode], name = base
  25016. if (name == null || event.altGraphKey) { return false }
  25017. if (event.altKey && base != "Alt") { name = "Alt-" + name }
  25018. if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name }
  25019. if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name }
  25020. if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name }
  25021. return name
  25022. }
  25023. function getKeyMap(val) {
  25024. return typeof val == "string" ? keyMap[val] : val
  25025. }
  25026. // Helper for deleting text near the selection(s), used to implement
  25027. // backspace, delete, and similar functionality.
  25028. function deleteNearSelection(cm, compute) {
  25029. var ranges = cm.doc.sel.ranges, kill = []
  25030. // Build up a set of ranges to kill first, merging overlapping
  25031. // ranges.
  25032. for (var i = 0; i < ranges.length; i++) {
  25033. var toKill = compute(ranges[i])
  25034. while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
  25035. var replaced = kill.pop()
  25036. if (cmp(replaced.from, toKill.from) < 0) {
  25037. toKill.from = replaced.from
  25038. break
  25039. }
  25040. }
  25041. kill.push(toKill)
  25042. }
  25043. // Next, remove those actual ranges.
  25044. runInOp(cm, function () {
  25045. for (var i = kill.length - 1; i >= 0; i--)
  25046. { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete") }
  25047. ensureCursorVisible(cm)
  25048. })
  25049. }
  25050. // Commands are parameter-less actions that can be performed on an
  25051. // editor, mostly used for keybindings.
  25052. var commands = {
  25053. selectAll: selectAll,
  25054. singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); },
  25055. killLine: function (cm) { return deleteNearSelection(cm, function (range) {
  25056. if (range.empty()) {
  25057. var len = getLine(cm.doc, range.head.line).text.length
  25058. if (range.head.ch == len && range.head.line < cm.lastLine())
  25059. { return {from: range.head, to: Pos(range.head.line + 1, 0)} }
  25060. else
  25061. { return {from: range.head, to: Pos(range.head.line, len)} }
  25062. } else {
  25063. return {from: range.from(), to: range.to()}
  25064. }
  25065. }); },
  25066. deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({
  25067. from: Pos(range.from().line, 0),
  25068. to: clipPos(cm.doc, Pos(range.to().line + 1, 0))
  25069. }); }); },
  25070. delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({
  25071. from: Pos(range.from().line, 0), to: range.from()
  25072. }); }); },
  25073. delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) {
  25074. var top = cm.charCoords(range.head, "div").top + 5
  25075. var leftPos = cm.coordsChar({left: 0, top: top}, "div")
  25076. return {from: leftPos, to: range.from()}
  25077. }); },
  25078. delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) {
  25079. var top = cm.charCoords(range.head, "div").top + 5
  25080. var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
  25081. return {from: range.from(), to: rightPos }
  25082. }); },
  25083. undo: function (cm) { return cm.undo(); },
  25084. redo: function (cm) { return cm.redo(); },
  25085. undoSelection: function (cm) { return cm.undoSelection(); },
  25086. redoSelection: function (cm) { return cm.redoSelection(); },
  25087. goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); },
  25088. goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); },
  25089. goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); },
  25090. {origin: "+move", bias: 1}
  25091. ); },
  25092. goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); },
  25093. {origin: "+move", bias: 1}
  25094. ); },
  25095. goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); },
  25096. {origin: "+move", bias: -1}
  25097. ); },
  25098. goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) {
  25099. var top = cm.charCoords(range.head, "div").top + 5
  25100. return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
  25101. }, sel_move); },
  25102. goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) {
  25103. var top = cm.charCoords(range.head, "div").top + 5
  25104. return cm.coordsChar({left: 0, top: top}, "div")
  25105. }, sel_move); },
  25106. goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) {
  25107. var top = cm.charCoords(range.head, "div").top + 5
  25108. var pos = cm.coordsChar({left: 0, top: top}, "div")
  25109. if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) }
  25110. return pos
  25111. }, sel_move); },
  25112. goLineUp: function (cm) { return cm.moveV(-1, "line"); },
  25113. goLineDown: function (cm) { return cm.moveV(1, "line"); },
  25114. goPageUp: function (cm) { return cm.moveV(-1, "page"); },
  25115. goPageDown: function (cm) { return cm.moveV(1, "page"); },
  25116. goCharLeft: function (cm) { return cm.moveH(-1, "char"); },
  25117. goCharRight: function (cm) { return cm.moveH(1, "char"); },
  25118. goColumnLeft: function (cm) { return cm.moveH(-1, "column"); },
  25119. goColumnRight: function (cm) { return cm.moveH(1, "column"); },
  25120. goWordLeft: function (cm) { return cm.moveH(-1, "word"); },
  25121. goGroupRight: function (cm) { return cm.moveH(1, "group"); },
  25122. goGroupLeft: function (cm) { return cm.moveH(-1, "group"); },
  25123. goWordRight: function (cm) { return cm.moveH(1, "word"); },
  25124. delCharBefore: function (cm) { return cm.deleteH(-1, "char"); },
  25125. delCharAfter: function (cm) { return cm.deleteH(1, "char"); },
  25126. delWordBefore: function (cm) { return cm.deleteH(-1, "word"); },
  25127. delWordAfter: function (cm) { return cm.deleteH(1, "word"); },
  25128. delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); },
  25129. delGroupAfter: function (cm) { return cm.deleteH(1, "group"); },
  25130. indentAuto: function (cm) { return cm.indentSelection("smart"); },
  25131. indentMore: function (cm) { return cm.indentSelection("add"); },
  25132. indentLess: function (cm) { return cm.indentSelection("subtract"); },
  25133. insertTab: function (cm) { return cm.replaceSelection("\t"); },
  25134. insertSoftTab: function (cm) {
  25135. var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize
  25136. for (var i = 0; i < ranges.length; i++) {
  25137. var pos = ranges[i].from()
  25138. var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize)
  25139. spaces.push(spaceStr(tabSize - col % tabSize))
  25140. }
  25141. cm.replaceSelections(spaces)
  25142. },
  25143. defaultTab: function (cm) {
  25144. if (cm.somethingSelected()) { cm.indentSelection("add") }
  25145. else { cm.execCommand("insertTab") }
  25146. },
  25147. // Swap the two chars left and right of each selection's head.
  25148. // Move cursor behind the two swapped characters afterwards.
  25149. //
  25150. // Doesn't consider line feeds a character.
  25151. // Doesn't scan more than one line above to find a character.
  25152. // Doesn't do anything on an empty line.
  25153. // Doesn't do anything with non-empty selections.
  25154. transposeChars: function (cm) { return runInOp(cm, function () {
  25155. var ranges = cm.listSelections(), newSel = []
  25156. for (var i = 0; i < ranges.length; i++) {
  25157. if (!ranges[i].empty()) { continue }
  25158. var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text
  25159. if (line) {
  25160. if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1) }
  25161. if (cur.ch > 0) {
  25162. cur = new Pos(cur.line, cur.ch + 1)
  25163. cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
  25164. Pos(cur.line, cur.ch - 2), cur, "+transpose")
  25165. } else if (cur.line > cm.doc.first) {
  25166. var prev = getLine(cm.doc, cur.line - 1).text
  25167. if (prev) {
  25168. cur = new Pos(cur.line, 1)
  25169. cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
  25170. prev.charAt(prev.length - 1),
  25171. Pos(cur.line - 1, prev.length - 1), cur, "+transpose")
  25172. }
  25173. }
  25174. }
  25175. newSel.push(new Range(cur, cur))
  25176. }
  25177. cm.setSelections(newSel)
  25178. }); },
  25179. newlineAndIndent: function (cm) { return runInOp(cm, function () {
  25180. var sels = cm.listSelections()
  25181. for (var i = sels.length - 1; i >= 0; i--)
  25182. { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input") }
  25183. sels = cm.listSelections()
  25184. for (var i$1 = 0; i$1 < sels.length; i$1++)
  25185. { cm.indentLine(sels[i$1].from().line, null, true) }
  25186. ensureCursorVisible(cm)
  25187. }); },
  25188. openLine: function (cm) { return cm.replaceSelection("\n", "start"); },
  25189. toggleOverwrite: function (cm) { return cm.toggleOverwrite(); }
  25190. }
  25191. function lineStart(cm, lineN) {
  25192. var line = getLine(cm.doc, lineN)
  25193. var visual = visualLine(line)
  25194. if (visual != line) { lineN = lineNo(visual) }
  25195. var order = getOrder(visual)
  25196. var ch = !order ? 0 : order[0].level % 2 ? lineRight(visual) : lineLeft(visual)
  25197. return Pos(lineN, ch)
  25198. }
  25199. function lineEnd(cm, lineN) {
  25200. var merged, line = getLine(cm.doc, lineN)
  25201. while (merged = collapsedSpanAtEnd(line)) {
  25202. line = merged.find(1, true).line
  25203. lineN = null
  25204. }
  25205. var order = getOrder(line)
  25206. var ch = !order ? line.text.length : order[0].level % 2 ? lineLeft(line) : lineRight(line)
  25207. return Pos(lineN == null ? lineNo(line) : lineN, ch)
  25208. }
  25209. function lineStartSmart(cm, pos) {
  25210. var start = lineStart(cm, pos.line)
  25211. var line = getLine(cm.doc, start.line)
  25212. var order = getOrder(line)
  25213. if (!order || order[0].level == 0) {
  25214. var firstNonWS = Math.max(0, line.text.search(/\S/))
  25215. var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch
  25216. return Pos(start.line, inWS ? 0 : firstNonWS)
  25217. }
  25218. return start
  25219. }
  25220. // Run a handler that was bound to a key.
  25221. function doHandleBinding(cm, bound, dropShift) {
  25222. if (typeof bound == "string") {
  25223. bound = commands[bound]
  25224. if (!bound) { return false }
  25225. }
  25226. // Ensure previous input has been read, so that the handler sees a
  25227. // consistent view of the document
  25228. cm.display.input.ensurePolled()
  25229. var prevShift = cm.display.shift, done = false
  25230. try {
  25231. if (cm.isReadOnly()) { cm.state.suppressEdits = true }
  25232. if (dropShift) { cm.display.shift = false }
  25233. done = bound(cm) != Pass
  25234. } finally {
  25235. cm.display.shift = prevShift
  25236. cm.state.suppressEdits = false
  25237. }
  25238. return done
  25239. }
  25240. function lookupKeyForEditor(cm, name, handle) {
  25241. for (var i = 0; i < cm.state.keyMaps.length; i++) {
  25242. var result = lookupKey(name, cm.state.keyMaps[i], handle, cm)
  25243. if (result) { return result }
  25244. }
  25245. return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
  25246. || lookupKey(name, cm.options.keyMap, handle, cm)
  25247. }
  25248. var stopSeq = new Delayed
  25249. function dispatchKey(cm, name, e, handle) {
  25250. var seq = cm.state.keySeq
  25251. if (seq) {
  25252. if (isModifierKey(name)) { return "handled" }
  25253. stopSeq.set(50, function () {
  25254. if (cm.state.keySeq == seq) {
  25255. cm.state.keySeq = null
  25256. cm.display.input.reset()
  25257. }
  25258. })
  25259. name = seq + " " + name
  25260. }
  25261. var result = lookupKeyForEditor(cm, name, handle)
  25262. if (result == "multi")
  25263. { cm.state.keySeq = name }
  25264. if (result == "handled")
  25265. { signalLater(cm, "keyHandled", cm, name, e) }
  25266. if (result == "handled" || result == "multi") {
  25267. e_preventDefault(e)
  25268. restartBlink(cm)
  25269. }
  25270. if (seq && !result && /\'$/.test(name)) {
  25271. e_preventDefault(e)
  25272. return true
  25273. }
  25274. return !!result
  25275. }
  25276. // Handle a key from the keydown event.
  25277. function handleKeyBinding(cm, e) {
  25278. var name = keyName(e, true)
  25279. if (!name) { return false }
  25280. if (e.shiftKey && !cm.state.keySeq) {
  25281. // First try to resolve full name (including 'Shift-'). Failing
  25282. // that, see if there is a cursor-motion command (starting with
  25283. // 'go') bound to the keyname without 'Shift-'.
  25284. return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); })
  25285. || dispatchKey(cm, name, e, function (b) {
  25286. if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
  25287. { return doHandleBinding(cm, b) }
  25288. })
  25289. } else {
  25290. return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); })
  25291. }
  25292. }
  25293. // Handle a key from the keypress event
  25294. function handleCharBinding(cm, e, ch) {
  25295. return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); })
  25296. }
  25297. var lastStoppedKey = null
  25298. function onKeyDown(e) {
  25299. var cm = this
  25300. cm.curOp.focus = activeElt()
  25301. if (signalDOMEvent(cm, e)) { return }
  25302. // IE does strange things with escape.
  25303. if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false }
  25304. var code = e.keyCode
  25305. cm.display.shift = code == 16 || e.shiftKey
  25306. var handled = handleKeyBinding(cm, e)
  25307. if (presto) {
  25308. lastStoppedKey = handled ? code : null
  25309. // Opera has no cut event... we try to at least catch the key combo
  25310. if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
  25311. { cm.replaceSelection("", null, "cut") }
  25312. }
  25313. // Turn mouse into crosshair when Alt is held on Mac.
  25314. if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
  25315. { showCrossHair(cm) }
  25316. }
  25317. function showCrossHair(cm) {
  25318. var lineDiv = cm.display.lineDiv
  25319. addClass(lineDiv, "CodeMirror-crosshair")
  25320. function up(e) {
  25321. if (e.keyCode == 18 || !e.altKey) {
  25322. rmClass(lineDiv, "CodeMirror-crosshair")
  25323. off(document, "keyup", up)
  25324. off(document, "mouseover", up)
  25325. }
  25326. }
  25327. on(document, "keyup", up)
  25328. on(document, "mouseover", up)
  25329. }
  25330. function onKeyUp(e) {
  25331. if (e.keyCode == 16) { this.doc.sel.shift = false }
  25332. signalDOMEvent(this, e)
  25333. }
  25334. function onKeyPress(e) {
  25335. var cm = this
  25336. if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }
  25337. var keyCode = e.keyCode, charCode = e.charCode
  25338. if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}
  25339. if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return }
  25340. var ch = String.fromCharCode(charCode == null ? keyCode : charCode)
  25341. // Some browsers fire keypress events for backspace
  25342. if (ch == "\x08") { return }
  25343. if (handleCharBinding(cm, e, ch)) { return }
  25344. cm.display.input.onKeyPress(e)
  25345. }
  25346. // A mouse down can be a single click, double click, triple click,
  25347. // start of selection drag, start of text drag, new cursor
  25348. // (ctrl-click), rectangle drag (alt-drag), or xwin
  25349. // middle-click-paste. Or it might be a click on something we should
  25350. // not interfere with, such as a scrollbar or widget.
  25351. function onMouseDown(e) {
  25352. var cm = this, display = cm.display
  25353. if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }
  25354. display.input.ensurePolled()
  25355. display.shift = e.shiftKey
  25356. if (eventInWidget(display, e)) {
  25357. if (!webkit) {
  25358. // Briefly turn off draggability, to allow widgets to do
  25359. // normal dragging things.
  25360. display.scroller.draggable = false
  25361. setTimeout(function () { return display.scroller.draggable = true; }, 100)
  25362. }
  25363. return
  25364. }
  25365. if (clickInGutter(cm, e)) { return }
  25366. var start = posFromMouse(cm, e)
  25367. window.focus()
  25368. switch (e_button(e)) {
  25369. case 1:
  25370. // #3261: make sure, that we're not starting a second selection
  25371. if (cm.state.selectingText)
  25372. { cm.state.selectingText(e) }
  25373. else if (start)
  25374. { leftButtonDown(cm, e, start) }
  25375. else if (e_target(e) == display.scroller)
  25376. { e_preventDefault(e) }
  25377. break
  25378. case 2:
  25379. if (webkit) { cm.state.lastMiddleDown = +new Date }
  25380. if (start) { extendSelection(cm.doc, start) }
  25381. setTimeout(function () { return display.input.focus(); }, 20)
  25382. e_preventDefault(e)
  25383. break
  25384. case 3:
  25385. if (captureRightClick) { onContextMenu(cm, e) }
  25386. else { delayBlurEvent(cm) }
  25387. break
  25388. }
  25389. }
  25390. var lastClick;
  25391. var lastDoubleClick;
  25392. function leftButtonDown(cm, e, start) {
  25393. if (ie) { setTimeout(bind(ensureFocus, cm), 0) }
  25394. else { cm.curOp.focus = activeElt() }
  25395. var now = +new Date, type
  25396. if (lastDoubleClick && lastDoubleClick.time > now - 400 && cmp(lastDoubleClick.pos, start) == 0) {
  25397. type = "triple"
  25398. } else if (lastClick && lastClick.time > now - 400 && cmp(lastClick.pos, start) == 0) {
  25399. type = "double"
  25400. lastDoubleClick = {time: now, pos: start}
  25401. } else {
  25402. type = "single"
  25403. lastClick = {time: now, pos: start}
  25404. }
  25405. var sel = cm.doc.sel, modifier = mac ? e.metaKey : e.ctrlKey, contained
  25406. if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
  25407. type == "single" && (contained = sel.contains(start)) > -1 &&
  25408. (cmp((contained = sel.ranges[contained]).from(), start) < 0 || start.xRel > 0) &&
  25409. (cmp(contained.to(), start) > 0 || start.xRel < 0))
  25410. { leftButtonStartDrag(cm, e, start, modifier) }
  25411. else
  25412. { leftButtonSelect(cm, e, start, type, modifier) }
  25413. }
  25414. // Start a text drag. When it ends, see if any dragging actually
  25415. // happen, and treat as a click if it didn't.
  25416. function leftButtonStartDrag(cm, e, start, modifier) {
  25417. var display = cm.display, startTime = +new Date
  25418. var dragEnd = operation(cm, function (e2) {
  25419. if (webkit) { display.scroller.draggable = false }
  25420. cm.state.draggingText = false
  25421. off(document, "mouseup", dragEnd)
  25422. off(display.scroller, "drop", dragEnd)
  25423. if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
  25424. e_preventDefault(e2)
  25425. if (!modifier && +new Date - 200 < startTime)
  25426. { extendSelection(cm.doc, start) }
  25427. // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
  25428. if (webkit || ie && ie_version == 9)
  25429. { setTimeout(function () {document.body.focus(); display.input.focus()}, 20) }
  25430. else
  25431. { display.input.focus() }
  25432. }
  25433. })
  25434. // Let the drag handler handle this.
  25435. if (webkit) { display.scroller.draggable = true }
  25436. cm.state.draggingText = dragEnd
  25437. dragEnd.copy = mac ? e.altKey : e.ctrlKey
  25438. // IE's approach to draggable
  25439. if (display.scroller.dragDrop) { display.scroller.dragDrop() }
  25440. on(document, "mouseup", dragEnd)
  25441. on(display.scroller, "drop", dragEnd)
  25442. }
  25443. // Normal selection, as opposed to text dragging.
  25444. function leftButtonSelect(cm, e, start, type, addNew) {
  25445. var display = cm.display, doc = cm.doc
  25446. e_preventDefault(e)
  25447. var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges
  25448. if (addNew && !e.shiftKey) {
  25449. ourIndex = doc.sel.contains(start)
  25450. if (ourIndex > -1)
  25451. { ourRange = ranges[ourIndex] }
  25452. else
  25453. { ourRange = new Range(start, start) }
  25454. } else {
  25455. ourRange = doc.sel.primary()
  25456. ourIndex = doc.sel.primIndex
  25457. }
  25458. if (chromeOS ? e.shiftKey && e.metaKey : e.altKey) {
  25459. type = "rect"
  25460. if (!addNew) { ourRange = new Range(start, start) }
  25461. start = posFromMouse(cm, e, true, true)
  25462. ourIndex = -1
  25463. } else if (type == "double") {
  25464. var word = cm.findWordAt(start)
  25465. if (cm.display.shift || doc.extend)
  25466. { ourRange = extendRange(doc, ourRange, word.anchor, word.head) }
  25467. else
  25468. { ourRange = word }
  25469. } else if (type == "triple") {
  25470. var line = new Range(Pos(start.line, 0), clipPos(doc, Pos(start.line + 1, 0)))
  25471. if (cm.display.shift || doc.extend)
  25472. { ourRange = extendRange(doc, ourRange, line.anchor, line.head) }
  25473. else
  25474. { ourRange = line }
  25475. } else {
  25476. ourRange = extendRange(doc, ourRange, start)
  25477. }
  25478. if (!addNew) {
  25479. ourIndex = 0
  25480. setSelection(doc, new Selection([ourRange], 0), sel_mouse)
  25481. startSel = doc.sel
  25482. } else if (ourIndex == -1) {
  25483. ourIndex = ranges.length
  25484. setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
  25485. {scroll: false, origin: "*mouse"})
  25486. } else if (ranges.length > 1 && ranges[ourIndex].empty() && type == "single" && !e.shiftKey) {
  25487. setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
  25488. {scroll: false, origin: "*mouse"})
  25489. startSel = doc.sel
  25490. } else {
  25491. replaceOneSelection(doc, ourIndex, ourRange, sel_mouse)
  25492. }
  25493. var lastPos = start
  25494. function extendTo(pos) {
  25495. if (cmp(lastPos, pos) == 0) { return }
  25496. lastPos = pos
  25497. if (type == "rect") {
  25498. var ranges = [], tabSize = cm.options.tabSize
  25499. var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize)
  25500. var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize)
  25501. var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol)
  25502. for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
  25503. line <= end; line++) {
  25504. var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize)
  25505. if (left == right)
  25506. { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))) }
  25507. else if (text.length > leftPos)
  25508. { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))) }
  25509. }
  25510. if (!ranges.length) { ranges.push(new Range(start, start)) }
  25511. setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
  25512. {origin: "*mouse", scroll: false})
  25513. cm.scrollIntoView(pos)
  25514. } else {
  25515. var oldRange = ourRange
  25516. var anchor = oldRange.anchor, head = pos
  25517. if (type != "single") {
  25518. var range
  25519. if (type == "double")
  25520. { range = cm.findWordAt(pos) }
  25521. else
  25522. { range = new Range(Pos(pos.line, 0), clipPos(doc, Pos(pos.line + 1, 0))) }
  25523. if (cmp(range.anchor, anchor) > 0) {
  25524. head = range.head
  25525. anchor = minPos(oldRange.from(), range.anchor)
  25526. } else {
  25527. head = range.anchor
  25528. anchor = maxPos(oldRange.to(), range.head)
  25529. }
  25530. }
  25531. var ranges$1 = startSel.ranges.slice(0)
  25532. ranges$1[ourIndex] = new Range(clipPos(doc, anchor), head)
  25533. setSelection(doc, normalizeSelection(ranges$1, ourIndex), sel_mouse)
  25534. }
  25535. }
  25536. var editorSize = display.wrapper.getBoundingClientRect()
  25537. // Used to ensure timeout re-tries don't fire when another extend
  25538. // happened in the meantime (clearTimeout isn't reliable -- at
  25539. // least on Chrome, the timeouts still happen even when cleared,
  25540. // if the clear happens after their scheduled firing time).
  25541. var counter = 0
  25542. function extend(e) {
  25543. var curCount = ++counter
  25544. var cur = posFromMouse(cm, e, true, type == "rect")
  25545. if (!cur) { return }
  25546. if (cmp(cur, lastPos) != 0) {
  25547. cm.curOp.focus = activeElt()
  25548. extendTo(cur)
  25549. var visible = visibleLines(display, doc)
  25550. if (cur.line >= visible.to || cur.line < visible.from)
  25551. { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e) }}), 150) }
  25552. } else {
  25553. var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0
  25554. if (outside) { setTimeout(operation(cm, function () {
  25555. if (counter != curCount) { return }
  25556. display.scroller.scrollTop += outside
  25557. extend(e)
  25558. }), 50) }
  25559. }
  25560. }
  25561. function done(e) {
  25562. cm.state.selectingText = false
  25563. counter = Infinity
  25564. e_preventDefault(e)
  25565. display.input.focus()
  25566. off(document, "mousemove", move)
  25567. off(document, "mouseup", up)
  25568. doc.history.lastSelOrigin = null
  25569. }
  25570. var move = operation(cm, function (e) {
  25571. if (!e_button(e)) { done(e) }
  25572. else { extend(e) }
  25573. })
  25574. var up = operation(cm, done)
  25575. cm.state.selectingText = up
  25576. on(document, "mousemove", move)
  25577. on(document, "mouseup", up)
  25578. }
  25579. // Determines whether an event happened in the gutter, and fires the
  25580. // handlers for the corresponding event.
  25581. function gutterEvent(cm, e, type, prevent) {
  25582. var mX, mY
  25583. try { mX = e.clientX; mY = e.clientY }
  25584. catch(e) { return false }
  25585. if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
  25586. if (prevent) { e_preventDefault(e) }
  25587. var display = cm.display
  25588. var lineBox = display.lineDiv.getBoundingClientRect()
  25589. if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }
  25590. mY -= lineBox.top - display.viewOffset
  25591. for (var i = 0; i < cm.options.gutters.length; ++i) {
  25592. var g = display.gutters.childNodes[i]
  25593. if (g && g.getBoundingClientRect().right >= mX) {
  25594. var line = lineAtHeight(cm.doc, mY)
  25595. var gutter = cm.options.gutters[i]
  25596. signal(cm, type, cm, line, gutter, e)
  25597. return e_defaultPrevented(e)
  25598. }
  25599. }
  25600. }
  25601. function clickInGutter(cm, e) {
  25602. return gutterEvent(cm, e, "gutterClick", true)
  25603. }
  25604. // CONTEXT MENU HANDLING
  25605. // To make the context menu work, we need to briefly unhide the
  25606. // textarea (making it as unobtrusive as possible) to let the
  25607. // right-click take effect on it.
  25608. function onContextMenu(cm, e) {
  25609. if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return }
  25610. if (signalDOMEvent(cm, e, "contextmenu")) { return }
  25611. cm.display.input.onContextMenu(e)
  25612. }
  25613. function contextMenuInGutter(cm, e) {
  25614. if (!hasHandler(cm, "gutterContextMenu")) { return false }
  25615. return gutterEvent(cm, e, "gutterContextMenu", false)
  25616. }
  25617. function themeChanged(cm) {
  25618. cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
  25619. cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-")
  25620. clearCaches(cm)
  25621. }
  25622. var Init = {toString: function(){return "CodeMirror.Init"}}
  25623. var defaults = {}
  25624. var optionHandlers = {}
  25625. function defineOptions(CodeMirror) {
  25626. var optionHandlers = CodeMirror.optionHandlers
  25627. function option(name, deflt, handle, notOnInit) {
  25628. CodeMirror.defaults[name] = deflt
  25629. if (handle) { optionHandlers[name] =
  25630. notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old) }} : handle }
  25631. }
  25632. CodeMirror.defineOption = option
  25633. // Passed to option handlers when there is no old value.
  25634. CodeMirror.Init = Init
  25635. // These two are, on init, called from the constructor because they
  25636. // have to be initialized before the editor can start at all.
  25637. option("value", "", function (cm, val) { return cm.setValue(val); }, true)
  25638. option("mode", null, function (cm, val) {
  25639. cm.doc.modeOption = val
  25640. loadMode(cm)
  25641. }, true)
  25642. option("indentUnit", 2, loadMode, true)
  25643. option("indentWithTabs", false)
  25644. option("smartIndent", true)
  25645. option("tabSize", 4, function (cm) {
  25646. resetModeState(cm)
  25647. clearCaches(cm)
  25648. regChange(cm)
  25649. }, true)
  25650. option("lineSeparator", null, function (cm, val) {
  25651. cm.doc.lineSep = val
  25652. if (!val) { return }
  25653. var newBreaks = [], lineNo = cm.doc.first
  25654. cm.doc.iter(function (line) {
  25655. for (var pos = 0;;) {
  25656. var found = line.text.indexOf(val, pos)
  25657. if (found == -1) { break }
  25658. pos = found + val.length
  25659. newBreaks.push(Pos(lineNo, found))
  25660. }
  25661. lineNo++
  25662. })
  25663. for (var i = newBreaks.length - 1; i >= 0; i--)
  25664. { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)) }
  25665. })
  25666. option("specialChars", /[\u0000-\u001f\u007f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
  25667. cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g")
  25668. if (old != Init) { cm.refresh() }
  25669. })
  25670. option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true)
  25671. option("electricChars", true)
  25672. option("inputStyle", mobile ? "contenteditable" : "textarea", function () {
  25673. throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME
  25674. }, true)
  25675. option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true)
  25676. option("rtlMoveVisually", !windows)
  25677. option("wholeLineUpdateBefore", true)
  25678. option("theme", "default", function (cm) {
  25679. themeChanged(cm)
  25680. guttersChanged(cm)
  25681. }, true)
  25682. option("keyMap", "default", function (cm, val, old) {
  25683. var next = getKeyMap(val)
  25684. var prev = old != Init && getKeyMap(old)
  25685. if (prev && prev.detach) { prev.detach(cm, next) }
  25686. if (next.attach) { next.attach(cm, prev || null) }
  25687. })
  25688. option("extraKeys", null)
  25689. option("lineWrapping", false, wrappingChanged, true)
  25690. option("gutters", [], function (cm) {
  25691. setGuttersForLineNumbers(cm.options)
  25692. guttersChanged(cm)
  25693. }, true)
  25694. option("fixedGutter", true, function (cm, val) {
  25695. cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0"
  25696. cm.refresh()
  25697. }, true)
  25698. option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true)
  25699. option("scrollbarStyle", "native", function (cm) {
  25700. initScrollbars(cm)
  25701. updateScrollbars(cm)
  25702. cm.display.scrollbars.setScrollTop(cm.doc.scrollTop)
  25703. cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft)
  25704. }, true)
  25705. option("lineNumbers", false, function (cm) {
  25706. setGuttersForLineNumbers(cm.options)
  25707. guttersChanged(cm)
  25708. }, true)
  25709. option("firstLineNumber", 1, guttersChanged, true)
  25710. option("lineNumberFormatter", function (integer) { return integer; }, guttersChanged, true)
  25711. option("showCursorWhenSelecting", false, updateSelection, true)
  25712. option("resetSelectionOnContextMenu", true)
  25713. option("lineWiseCopyCut", true)
  25714. option("readOnly", false, function (cm, val) {
  25715. if (val == "nocursor") {
  25716. onBlur(cm)
  25717. cm.display.input.blur()
  25718. cm.display.disabled = true
  25719. } else {
  25720. cm.display.disabled = false
  25721. }
  25722. cm.display.input.readOnlyChanged(val)
  25723. })
  25724. option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset() }}, true)
  25725. option("dragDrop", true, dragDropChanged)
  25726. option("allowDropFileTypes", null)
  25727. option("cursorBlinkRate", 530)
  25728. option("cursorScrollMargin", 0)
  25729. option("cursorHeight", 1, updateSelection, true)
  25730. option("singleCursorHeightPerLine", true, updateSelection, true)
  25731. option("workTime", 100)
  25732. option("workDelay", 100)
  25733. option("flattenSpans", true, resetModeState, true)
  25734. option("addModeClass", false, resetModeState, true)
  25735. option("pollInterval", 100)
  25736. option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; })
  25737. option("historyEventDelay", 1250)
  25738. option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true)
  25739. option("maxHighlightLength", 10000, resetModeState, true)
  25740. option("moveInputWithCursor", true, function (cm, val) {
  25741. if (!val) { cm.display.input.resetPosition() }
  25742. })
  25743. option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; })
  25744. option("autofocus", null)
  25745. }
  25746. function guttersChanged(cm) {
  25747. updateGutters(cm)
  25748. regChange(cm)
  25749. alignHorizontally(cm)
  25750. }
  25751. function dragDropChanged(cm, value, old) {
  25752. var wasOn = old && old != Init
  25753. if (!value != !wasOn) {
  25754. var funcs = cm.display.dragFunctions
  25755. var toggle = value ? on : off
  25756. toggle(cm.display.scroller, "dragstart", funcs.start)
  25757. toggle(cm.display.scroller, "dragenter", funcs.enter)
  25758. toggle(cm.display.scroller, "dragover", funcs.over)
  25759. toggle(cm.display.scroller, "dragleave", funcs.leave)
  25760. toggle(cm.display.scroller, "drop", funcs.drop)
  25761. }
  25762. }
  25763. function wrappingChanged(cm) {
  25764. if (cm.options.lineWrapping) {
  25765. addClass(cm.display.wrapper, "CodeMirror-wrap")
  25766. cm.display.sizer.style.minWidth = ""
  25767. cm.display.sizerWidth = null
  25768. } else {
  25769. rmClass(cm.display.wrapper, "CodeMirror-wrap")
  25770. findMaxLine(cm)
  25771. }
  25772. estimateLineHeights(cm)
  25773. regChange(cm)
  25774. clearCaches(cm)
  25775. setTimeout(function () { return updateScrollbars(cm); }, 100)
  25776. }
  25777. // A CodeMirror instance represents an editor. This is the object
  25778. // that user code is usually dealing with.
  25779. function CodeMirror(place, options) {
  25780. var this$1 = this;
  25781. if (!(this instanceof CodeMirror)) { return new CodeMirror(place, options) }
  25782. this.options = options = options ? copyObj(options) : {}
  25783. // Determine effective options based on given values and defaults.
  25784. copyObj(defaults, options, false)
  25785. setGuttersForLineNumbers(options)
  25786. var doc = options.value
  25787. if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator) }
  25788. this.doc = doc
  25789. var input = new CodeMirror.inputStyles[options.inputStyle](this)
  25790. var display = this.display = new Display(place, doc, input)
  25791. display.wrapper.CodeMirror = this
  25792. updateGutters(this)
  25793. themeChanged(this)
  25794. if (options.lineWrapping)
  25795. { this.display.wrapper.className += " CodeMirror-wrap" }
  25796. initScrollbars(this)
  25797. this.state = {
  25798. keyMaps: [], // stores maps added by addKeyMap
  25799. overlays: [], // highlighting overlays, as added by addOverlay
  25800. modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
  25801. overwrite: false,
  25802. delayingBlurEvent: false,
  25803. focused: false,
  25804. suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
  25805. pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
  25806. selectingText: false,
  25807. draggingText: false,
  25808. highlight: new Delayed(), // stores highlight worker timeout
  25809. keySeq: null, // Unfinished key sequence
  25810. specialChars: null
  25811. }
  25812. if (options.autofocus && !mobile) { display.input.focus() }
  25813. // Override magic textarea content restore that IE sometimes does
  25814. // on our hidden textarea on reload
  25815. if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20) }
  25816. registerEventHandlers(this)
  25817. ensureGlobalHandlers()
  25818. startOperation(this)
  25819. this.curOp.forceUpdate = true
  25820. attachDoc(this, doc)
  25821. if ((options.autofocus && !mobile) || this.hasFocus())
  25822. { setTimeout(bind(onFocus, this), 20) }
  25823. else
  25824. { onBlur(this) }
  25825. for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt))
  25826. { optionHandlers[opt](this$1, options[opt], Init) } }
  25827. maybeUpdateLineNumberWidth(this)
  25828. if (options.finishInit) { options.finishInit(this) }
  25829. for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this$1) }
  25830. endOperation(this)
  25831. // Suppress optimizelegibility in Webkit, since it breaks text
  25832. // measuring on line wrapping boundaries.
  25833. if (webkit && options.lineWrapping &&
  25834. getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
  25835. { display.lineDiv.style.textRendering = "auto" }
  25836. }
  25837. // The default configuration options.
  25838. CodeMirror.defaults = defaults
  25839. // Functions to run when options are changed.
  25840. CodeMirror.optionHandlers = optionHandlers
  25841. // Attach the necessary event handlers when initializing the editor
  25842. function registerEventHandlers(cm) {
  25843. var d = cm.display
  25844. on(d.scroller, "mousedown", operation(cm, onMouseDown))
  25845. // Older IE's will not fire a second mousedown for a double click
  25846. if (ie && ie_version < 11)
  25847. { on(d.scroller, "dblclick", operation(cm, function (e) {
  25848. if (signalDOMEvent(cm, e)) { return }
  25849. var pos = posFromMouse(cm, e)
  25850. if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return }
  25851. e_preventDefault(e)
  25852. var word = cm.findWordAt(pos)
  25853. extendSelection(cm.doc, word.anchor, word.head)
  25854. })) }
  25855. else
  25856. { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }) }
  25857. // Some browsers fire contextmenu *after* opening the menu, at
  25858. // which point we can't mess with it anymore. Context menu is
  25859. // handled in onMouseDown for these browsers.
  25860. if (!captureRightClick) { on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); }) }
  25861. // Used to suppress mouse event handling when a touch happens
  25862. var touchFinished, prevTouch = {end: 0}
  25863. function finishTouch() {
  25864. if (d.activeTouch) {
  25865. touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000)
  25866. prevTouch = d.activeTouch
  25867. prevTouch.end = +new Date
  25868. }
  25869. }
  25870. function isMouseLikeTouchEvent(e) {
  25871. if (e.touches.length != 1) { return false }
  25872. var touch = e.touches[0]
  25873. return touch.radiusX <= 1 && touch.radiusY <= 1
  25874. }
  25875. function farAway(touch, other) {
  25876. if (other.left == null) { return true }
  25877. var dx = other.left - touch.left, dy = other.top - touch.top
  25878. return dx * dx + dy * dy > 20 * 20
  25879. }
  25880. on(d.scroller, "touchstart", function (e) {
  25881. if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e)) {
  25882. d.input.ensurePolled()
  25883. clearTimeout(touchFinished)
  25884. var now = +new Date
  25885. d.activeTouch = {start: now, moved: false,
  25886. prev: now - prevTouch.end <= 300 ? prevTouch : null}
  25887. if (e.touches.length == 1) {
  25888. d.activeTouch.left = e.touches[0].pageX
  25889. d.activeTouch.top = e.touches[0].pageY
  25890. }
  25891. }
  25892. })
  25893. on(d.scroller, "touchmove", function () {
  25894. if (d.activeTouch) { d.activeTouch.moved = true }
  25895. })
  25896. on(d.scroller, "touchend", function (e) {
  25897. var touch = d.activeTouch
  25898. if (touch && !eventInWidget(d, e) && touch.left != null &&
  25899. !touch.moved && new Date - touch.start < 300) {
  25900. var pos = cm.coordsChar(d.activeTouch, "page"), range
  25901. if (!touch.prev || farAway(touch, touch.prev)) // Single tap
  25902. { range = new Range(pos, pos) }
  25903. else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
  25904. { range = cm.findWordAt(pos) }
  25905. else // Triple tap
  25906. { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }
  25907. cm.setSelection(range.anchor, range.head)
  25908. cm.focus()
  25909. e_preventDefault(e)
  25910. }
  25911. finishTouch()
  25912. })
  25913. on(d.scroller, "touchcancel", finishTouch)
  25914. // Sync scrolling between fake scrollbars and real scrollable
  25915. // area, ensure viewport is updated when scrolling.
  25916. on(d.scroller, "scroll", function () {
  25917. if (d.scroller.clientHeight) {
  25918. setScrollTop(cm, d.scroller.scrollTop)
  25919. setScrollLeft(cm, d.scroller.scrollLeft, true)
  25920. signal(cm, "scroll", cm)
  25921. }
  25922. })
  25923. // Listen to wheel events in order to try and update the viewport on time.
  25924. on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); })
  25925. on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); })
  25926. // Prevent wrapper from ever scrolling
  25927. on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; })
  25928. d.dragFunctions = {
  25929. enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e) }},
  25930. over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e) }},
  25931. start: function (e) { return onDragStart(cm, e); },
  25932. drop: operation(cm, onDrop),
  25933. leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm) }}
  25934. }
  25935. var inp = d.input.getField()
  25936. on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); })
  25937. on(inp, "keydown", operation(cm, onKeyDown))
  25938. on(inp, "keypress", operation(cm, onKeyPress))
  25939. on(inp, "focus", function (e) { return onFocus(cm, e); })
  25940. on(inp, "blur", function (e) { return onBlur(cm, e); })
  25941. }
  25942. var initHooks = []
  25943. CodeMirror.defineInitHook = function (f) { return initHooks.push(f); }
  25944. // Indent the given line. The how parameter can be "smart",
  25945. // "add"/null, "subtract", or "prev". When aggressive is false
  25946. // (typically set to true for forced single-line indents), empty
  25947. // lines are not indented, and places where the mode returns Pass
  25948. // are left alone.
  25949. function indentLine(cm, n, how, aggressive) {
  25950. var doc = cm.doc, state
  25951. if (how == null) { how = "add" }
  25952. if (how == "smart") {
  25953. // Fall back to "prev" when the mode doesn't have an indentation
  25954. // method.
  25955. if (!doc.mode.indent) { how = "prev" }
  25956. else { state = getStateBefore(cm, n) }
  25957. }
  25958. var tabSize = cm.options.tabSize
  25959. var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize)
  25960. if (line.stateAfter) { line.stateAfter = null }
  25961. var curSpaceString = line.text.match(/^\s*/)[0], indentation
  25962. if (!aggressive && !/\S/.test(line.text)) {
  25963. indentation = 0
  25964. how = "not"
  25965. } else if (how == "smart") {
  25966. indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text)
  25967. if (indentation == Pass || indentation > 150) {
  25968. if (!aggressive) { return }
  25969. how = "prev"
  25970. }
  25971. }
  25972. if (how == "prev") {
  25973. if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize) }
  25974. else { indentation = 0 }
  25975. } else if (how == "add") {
  25976. indentation = curSpace + cm.options.indentUnit
  25977. } else if (how == "subtract") {
  25978. indentation = curSpace - cm.options.indentUnit
  25979. } else if (typeof how == "number") {
  25980. indentation = curSpace + how
  25981. }
  25982. indentation = Math.max(0, indentation)
  25983. var indentString = "", pos = 0
  25984. if (cm.options.indentWithTabs)
  25985. { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t"} }
  25986. if (pos < indentation) { indentString += spaceStr(indentation - pos) }
  25987. if (indentString != curSpaceString) {
  25988. replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input")
  25989. line.stateAfter = null
  25990. return true
  25991. } else {
  25992. // Ensure that, if the cursor was in the whitespace at the start
  25993. // of the line, it is moved to the end of that space.
  25994. for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {
  25995. var range = doc.sel.ranges[i$1]
  25996. if (range.head.line == n && range.head.ch < curSpaceString.length) {
  25997. var pos$1 = Pos(n, curSpaceString.length)
  25998. replaceOneSelection(doc, i$1, new Range(pos$1, pos$1))
  25999. break
  26000. }
  26001. }
  26002. }
  26003. }
  26004. // This will be set to a {lineWise: bool, text: [string]} object, so
  26005. // that, when pasting, we know what kind of selections the copied
  26006. // text was made out of.
  26007. var lastCopied = null
  26008. function setLastCopied(newLastCopied) {
  26009. lastCopied = newLastCopied
  26010. }
  26011. function applyTextInput(cm, inserted, deleted, sel, origin) {
  26012. var doc = cm.doc
  26013. cm.display.shift = false
  26014. if (!sel) { sel = doc.sel }
  26015. var paste = cm.state.pasteIncoming || origin == "paste"
  26016. var textLines = splitLinesAuto(inserted), multiPaste = null
  26017. // When pasing N lines into N selections, insert one line per selection
  26018. if (paste && sel.ranges.length > 1) {
  26019. if (lastCopied && lastCopied.text.join("\n") == inserted) {
  26020. if (sel.ranges.length % lastCopied.text.length == 0) {
  26021. multiPaste = []
  26022. for (var i = 0; i < lastCopied.text.length; i++)
  26023. { multiPaste.push(doc.splitLines(lastCopied.text[i])) }
  26024. }
  26025. } else if (textLines.length == sel.ranges.length) {
  26026. multiPaste = map(textLines, function (l) { return [l]; })
  26027. }
  26028. }
  26029. var updateInput
  26030. // Normal behavior is to insert the new text into every selection
  26031. for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {
  26032. var range = sel.ranges[i$1]
  26033. var from = range.from(), to = range.to()
  26034. if (range.empty()) {
  26035. if (deleted && deleted > 0) // Handle deletion
  26036. { from = Pos(from.line, from.ch - deleted) }
  26037. else if (cm.state.overwrite && !paste) // Handle overwrite
  26038. { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)) }
  26039. else if (lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
  26040. { from = to = Pos(from.line, 0) }
  26041. }
  26042. updateInput = cm.curOp.updateInput
  26043. var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
  26044. origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")}
  26045. makeChange(cm.doc, changeEvent)
  26046. signalLater(cm, "inputRead", cm, changeEvent)
  26047. }
  26048. if (inserted && !paste)
  26049. { triggerElectric(cm, inserted) }
  26050. ensureCursorVisible(cm)
  26051. cm.curOp.updateInput = updateInput
  26052. cm.curOp.typing = true
  26053. cm.state.pasteIncoming = cm.state.cutIncoming = false
  26054. }
  26055. function handlePaste(e, cm) {
  26056. var pasted = e.clipboardData && e.clipboardData.getData("Text")
  26057. if (pasted) {
  26058. e.preventDefault()
  26059. if (!cm.isReadOnly() && !cm.options.disableInput)
  26060. { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }) }
  26061. return true
  26062. }
  26063. }
  26064. function triggerElectric(cm, inserted) {
  26065. // When an 'electric' character is inserted, immediately trigger a reindent
  26066. if (!cm.options.electricChars || !cm.options.smartIndent) { return }
  26067. var sel = cm.doc.sel
  26068. for (var i = sel.ranges.length - 1; i >= 0; i--) {
  26069. var range = sel.ranges[i]
  26070. if (range.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range.head.line)) { continue }
  26071. var mode = cm.getModeAt(range.head)
  26072. var indented = false
  26073. if (mode.electricChars) {
  26074. for (var j = 0; j < mode.electricChars.length; j++)
  26075. { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
  26076. indented = indentLine(cm, range.head.line, "smart")
  26077. break
  26078. } }
  26079. } else if (mode.electricInput) {
  26080. if (mode.electricInput.test(getLine(cm.doc, range.head.line).text.slice(0, range.head.ch)))
  26081. { indented = indentLine(cm, range.head.line, "smart") }
  26082. }
  26083. if (indented) { signalLater(cm, "electricInput", cm, range.head.line) }
  26084. }
  26085. }
  26086. function copyableRanges(cm) {
  26087. var text = [], ranges = []
  26088. for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
  26089. var line = cm.doc.sel.ranges[i].head.line
  26090. var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)}
  26091. ranges.push(lineRange)
  26092. text.push(cm.getRange(lineRange.anchor, lineRange.head))
  26093. }
  26094. return {text: text, ranges: ranges}
  26095. }
  26096. function disableBrowserMagic(field, spellcheck) {
  26097. field.setAttribute("autocorrect", "off")
  26098. field.setAttribute("autocapitalize", "off")
  26099. field.setAttribute("spellcheck", !!spellcheck)
  26100. }
  26101. function hiddenTextarea() {
  26102. var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none")
  26103. var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;")
  26104. // The textarea is kept positioned near the cursor to prevent the
  26105. // fact that it'll be scrolled into view on input from scrolling
  26106. // our fake cursor out of view. On webkit, when wrap=off, paste is
  26107. // very slow. So make the area wide instead.
  26108. if (webkit) { te.style.width = "1000px" }
  26109. else { te.setAttribute("wrap", "off") }
  26110. // If border: 0; -- iOS fails to open keyboard (issue #1287)
  26111. if (ios) { te.style.border = "1px solid black" }
  26112. disableBrowserMagic(te)
  26113. return div
  26114. }
  26115. // The publicly visible API. Note that methodOp(f) means
  26116. // 'wrap f in an operation, performed on its `this` parameter'.
  26117. // This is not the complete set of editor methods. Most of the
  26118. // methods defined on the Doc type are also injected into
  26119. // CodeMirror.prototype, for backwards compatibility and
  26120. // convenience.
  26121. function addEditorMethods(CodeMirror) {
  26122. var optionHandlers = CodeMirror.optionHandlers
  26123. var helpers = CodeMirror.helpers = {}
  26124. CodeMirror.prototype = {
  26125. constructor: CodeMirror,
  26126. focus: function(){window.focus(); this.display.input.focus()},
  26127. setOption: function(option, value) {
  26128. var options = this.options, old = options[option]
  26129. if (options[option] == value && option != "mode") { return }
  26130. options[option] = value
  26131. if (optionHandlers.hasOwnProperty(option))
  26132. { operation(this, optionHandlers[option])(this, value, old) }
  26133. signal(this, "optionChange", this, option)
  26134. },
  26135. getOption: function(option) {return this.options[option]},
  26136. getDoc: function() {return this.doc},
  26137. addKeyMap: function(map, bottom) {
  26138. this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map))
  26139. },
  26140. removeKeyMap: function(map) {
  26141. var maps = this.state.keyMaps
  26142. for (var i = 0; i < maps.length; ++i)
  26143. { if (maps[i] == map || maps[i].name == map) {
  26144. maps.splice(i, 1)
  26145. return true
  26146. } }
  26147. },
  26148. addOverlay: methodOp(function(spec, options) {
  26149. var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec)
  26150. if (mode.startState) { throw new Error("Overlays may not be stateful.") }
  26151. insertSorted(this.state.overlays,
  26152. {mode: mode, modeSpec: spec, opaque: options && options.opaque,
  26153. priority: (options && options.priority) || 0},
  26154. function (overlay) { return overlay.priority; })
  26155. this.state.modeGen++
  26156. regChange(this)
  26157. }),
  26158. removeOverlay: methodOp(function(spec) {
  26159. var this$1 = this;
  26160. var overlays = this.state.overlays
  26161. for (var i = 0; i < overlays.length; ++i) {
  26162. var cur = overlays[i].modeSpec
  26163. if (cur == spec || typeof spec == "string" && cur.name == spec) {
  26164. overlays.splice(i, 1)
  26165. this$1.state.modeGen++
  26166. regChange(this$1)
  26167. return
  26168. }
  26169. }
  26170. }),
  26171. indentLine: methodOp(function(n, dir, aggressive) {
  26172. if (typeof dir != "string" && typeof dir != "number") {
  26173. if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev" }
  26174. else { dir = dir ? "add" : "subtract" }
  26175. }
  26176. if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive) }
  26177. }),
  26178. indentSelection: methodOp(function(how) {
  26179. var this$1 = this;
  26180. var ranges = this.doc.sel.ranges, end = -1
  26181. for (var i = 0; i < ranges.length; i++) {
  26182. var range = ranges[i]
  26183. if (!range.empty()) {
  26184. var from = range.from(), to = range.to()
  26185. var start = Math.max(end, from.line)
  26186. end = Math.min(this$1.lastLine(), to.line - (to.ch ? 0 : 1)) + 1
  26187. for (var j = start; j < end; ++j)
  26188. { indentLine(this$1, j, how) }
  26189. var newRanges = this$1.doc.sel.ranges
  26190. if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
  26191. { replaceOneSelection(this$1.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll) }
  26192. } else if (range.head.line > end) {
  26193. indentLine(this$1, range.head.line, how, true)
  26194. end = range.head.line
  26195. if (i == this$1.doc.sel.primIndex) { ensureCursorVisible(this$1) }
  26196. }
  26197. }
  26198. }),
  26199. // Fetch the parser token for a given character. Useful for hacks
  26200. // that want to inspect the mode state (say, for completion).
  26201. getTokenAt: function(pos, precise) {
  26202. return takeToken(this, pos, precise)
  26203. },
  26204. getLineTokens: function(line, precise) {
  26205. return takeToken(this, Pos(line), precise, true)
  26206. },
  26207. getTokenTypeAt: function(pos) {
  26208. pos = clipPos(this.doc, pos)
  26209. var styles = getLineStyles(this, getLine(this.doc, pos.line))
  26210. var before = 0, after = (styles.length - 1) / 2, ch = pos.ch
  26211. var type
  26212. if (ch == 0) { type = styles[2] }
  26213. else { for (;;) {
  26214. var mid = (before + after) >> 1
  26215. if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid }
  26216. else if (styles[mid * 2 + 1] < ch) { before = mid + 1 }
  26217. else { type = styles[mid * 2 + 2]; break }
  26218. } }
  26219. var cut = type ? type.indexOf("overlay ") : -1
  26220. return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1)
  26221. },
  26222. getModeAt: function(pos) {
  26223. var mode = this.doc.mode
  26224. if (!mode.innerMode) { return mode }
  26225. return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode
  26226. },
  26227. getHelper: function(pos, type) {
  26228. return this.getHelpers(pos, type)[0]
  26229. },
  26230. getHelpers: function(pos, type) {
  26231. var this$1 = this;
  26232. var found = []
  26233. if (!helpers.hasOwnProperty(type)) { return found }
  26234. var help = helpers[type], mode = this.getModeAt(pos)
  26235. if (typeof mode[type] == "string") {
  26236. if (help[mode[type]]) { found.push(help[mode[type]]) }
  26237. } else if (mode[type]) {
  26238. for (var i = 0; i < mode[type].length; i++) {
  26239. var val = help[mode[type][i]]
  26240. if (val) { found.push(val) }
  26241. }
  26242. } else if (mode.helperType && help[mode.helperType]) {
  26243. found.push(help[mode.helperType])
  26244. } else if (help[mode.name]) {
  26245. found.push(help[mode.name])
  26246. }
  26247. for (var i$1 = 0; i$1 < help._global.length; i$1++) {
  26248. var cur = help._global[i$1]
  26249. if (cur.pred(mode, this$1) && indexOf(found, cur.val) == -1)
  26250. { found.push(cur.val) }
  26251. }
  26252. return found
  26253. },
  26254. getStateAfter: function(line, precise) {
  26255. var doc = this.doc
  26256. line = clipLine(doc, line == null ? doc.first + doc.size - 1: line)
  26257. return getStateBefore(this, line + 1, precise)
  26258. },
  26259. cursorCoords: function(start, mode) {
  26260. var pos, range = this.doc.sel.primary()
  26261. if (start == null) { pos = range.head }
  26262. else if (typeof start == "object") { pos = clipPos(this.doc, start) }
  26263. else { pos = start ? range.from() : range.to() }
  26264. return cursorCoords(this, pos, mode || "page")
  26265. },
  26266. charCoords: function(pos, mode) {
  26267. return charCoords(this, clipPos(this.doc, pos), mode || "page")
  26268. },
  26269. coordsChar: function(coords, mode) {
  26270. coords = fromCoordSystem(this, coords, mode || "page")
  26271. return coordsChar(this, coords.left, coords.top)
  26272. },
  26273. lineAtHeight: function(height, mode) {
  26274. height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top
  26275. return lineAtHeight(this.doc, height + this.display.viewOffset)
  26276. },
  26277. heightAtLine: function(line, mode, includeWidgets) {
  26278. var end = false, lineObj
  26279. if (typeof line == "number") {
  26280. var last = this.doc.first + this.doc.size - 1
  26281. if (line < this.doc.first) { line = this.doc.first }
  26282. else if (line > last) { line = last; end = true }
  26283. lineObj = getLine(this.doc, line)
  26284. } else {
  26285. lineObj = line
  26286. }
  26287. return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets).top +
  26288. (end ? this.doc.height - heightAtLine(lineObj) : 0)
  26289. },
  26290. defaultTextHeight: function() { return textHeight(this.display) },
  26291. defaultCharWidth: function() { return charWidth(this.display) },
  26292. getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},
  26293. addWidget: function(pos, node, scroll, vert, horiz) {
  26294. var display = this.display
  26295. pos = cursorCoords(this, clipPos(this.doc, pos))
  26296. var top = pos.bottom, left = pos.left
  26297. node.style.position = "absolute"
  26298. node.setAttribute("cm-ignore-events", "true")
  26299. this.display.input.setUneditable(node)
  26300. display.sizer.appendChild(node)
  26301. if (vert == "over") {
  26302. top = pos.top
  26303. } else if (vert == "above" || vert == "near") {
  26304. var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
  26305. hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth)
  26306. // Default to positioning above (if specified and possible); otherwise default to positioning below
  26307. if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
  26308. { top = pos.top - node.offsetHeight }
  26309. else if (pos.bottom + node.offsetHeight <= vspace)
  26310. { top = pos.bottom }
  26311. if (left + node.offsetWidth > hspace)
  26312. { left = hspace - node.offsetWidth }
  26313. }
  26314. node.style.top = top + "px"
  26315. node.style.left = node.style.right = ""
  26316. if (horiz == "right") {
  26317. left = display.sizer.clientWidth - node.offsetWidth
  26318. node.style.right = "0px"
  26319. } else {
  26320. if (horiz == "left") { left = 0 }
  26321. else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2 }
  26322. node.style.left = left + "px"
  26323. }
  26324. if (scroll)
  26325. { scrollIntoView(this, left, top, left + node.offsetWidth, top + node.offsetHeight) }
  26326. },
  26327. triggerOnKeyDown: methodOp(onKeyDown),
  26328. triggerOnKeyPress: methodOp(onKeyPress),
  26329. triggerOnKeyUp: onKeyUp,
  26330. execCommand: function(cmd) {
  26331. if (commands.hasOwnProperty(cmd))
  26332. { return commands[cmd].call(null, this) }
  26333. },
  26334. triggerElectric: methodOp(function(text) { triggerElectric(this, text) }),
  26335. findPosH: function(from, amount, unit, visually) {
  26336. var this$1 = this;
  26337. var dir = 1
  26338. if (amount < 0) { dir = -1; amount = -amount }
  26339. var cur = clipPos(this.doc, from)
  26340. for (var i = 0; i < amount; ++i) {
  26341. cur = findPosH(this$1.doc, cur, dir, unit, visually)
  26342. if (cur.hitSide) { break }
  26343. }
  26344. return cur
  26345. },
  26346. moveH: methodOp(function(dir, unit) {
  26347. var this$1 = this;
  26348. this.extendSelectionsBy(function (range) {
  26349. if (this$1.display.shift || this$1.doc.extend || range.empty())
  26350. { return findPosH(this$1.doc, range.head, dir, unit, this$1.options.rtlMoveVisually) }
  26351. else
  26352. { return dir < 0 ? range.from() : range.to() }
  26353. }, sel_move)
  26354. }),
  26355. deleteH: methodOp(function(dir, unit) {
  26356. var sel = this.doc.sel, doc = this.doc
  26357. if (sel.somethingSelected())
  26358. { doc.replaceSelection("", null, "+delete") }
  26359. else
  26360. { deleteNearSelection(this, function (range) {
  26361. var other = findPosH(doc, range.head, dir, unit, false)
  26362. return dir < 0 ? {from: other, to: range.head} : {from: range.head, to: other}
  26363. }) }
  26364. }),
  26365. findPosV: function(from, amount, unit, goalColumn) {
  26366. var this$1 = this;
  26367. var dir = 1, x = goalColumn
  26368. if (amount < 0) { dir = -1; amount = -amount }
  26369. var cur = clipPos(this.doc, from)
  26370. for (var i = 0; i < amount; ++i) {
  26371. var coords = cursorCoords(this$1, cur, "div")
  26372. if (x == null) { x = coords.left }
  26373. else { coords.left = x }
  26374. cur = findPosV(this$1, coords, dir, unit)
  26375. if (cur.hitSide) { break }
  26376. }
  26377. return cur
  26378. },
  26379. moveV: methodOp(function(dir, unit) {
  26380. var this$1 = this;
  26381. var doc = this.doc, goals = []
  26382. var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected()
  26383. doc.extendSelectionsBy(function (range) {
  26384. if (collapse)
  26385. { return dir < 0 ? range.from() : range.to() }
  26386. var headPos = cursorCoords(this$1, range.head, "div")
  26387. if (range.goalColumn != null) { headPos.left = range.goalColumn }
  26388. goals.push(headPos.left)
  26389. var pos = findPosV(this$1, headPos, dir, unit)
  26390. if (unit == "page" && range == doc.sel.primary())
  26391. { addToScrollPos(this$1, null, charCoords(this$1, pos, "div").top - headPos.top) }
  26392. return pos
  26393. }, sel_move)
  26394. if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++)
  26395. { doc.sel.ranges[i].goalColumn = goals[i] } }
  26396. }),
  26397. // Find the word at the given position (as returned by coordsChar).
  26398. findWordAt: function(pos) {
  26399. var doc = this.doc, line = getLine(doc, pos.line).text
  26400. var start = pos.ch, end = pos.ch
  26401. if (line) {
  26402. var helper = this.getHelper(pos, "wordChars")
  26403. if ((pos.xRel < 0 || end == line.length) && start) { --start; } else { ++end }
  26404. var startChar = line.charAt(start)
  26405. var check = isWordChar(startChar, helper)
  26406. ? function (ch) { return isWordChar(ch, helper); }
  26407. : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); }
  26408. : function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); }
  26409. while (start > 0 && check(line.charAt(start - 1))) { --start }
  26410. while (end < line.length && check(line.charAt(end))) { ++end }
  26411. }
  26412. return new Range(Pos(pos.line, start), Pos(pos.line, end))
  26413. },
  26414. toggleOverwrite: function(value) {
  26415. if (value != null && value == this.state.overwrite) { return }
  26416. if (this.state.overwrite = !this.state.overwrite)
  26417. { addClass(this.display.cursorDiv, "CodeMirror-overwrite") }
  26418. else
  26419. { rmClass(this.display.cursorDiv, "CodeMirror-overwrite") }
  26420. signal(this, "overwriteToggle", this, this.state.overwrite)
  26421. },
  26422. hasFocus: function() { return this.display.input.getField() == activeElt() },
  26423. isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
  26424. scrollTo: methodOp(function(x, y) {
  26425. if (x != null || y != null) { resolveScrollToPos(this) }
  26426. if (x != null) { this.curOp.scrollLeft = x }
  26427. if (y != null) { this.curOp.scrollTop = y }
  26428. }),
  26429. getScrollInfo: function() {
  26430. var scroller = this.display.scroller
  26431. return {left: scroller.scrollLeft, top: scroller.scrollTop,
  26432. height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
  26433. width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
  26434. clientHeight: displayHeight(this), clientWidth: displayWidth(this)}
  26435. },
  26436. scrollIntoView: methodOp(function(range, margin) {
  26437. if (range == null) {
  26438. range = {from: this.doc.sel.primary().head, to: null}
  26439. if (margin == null) { margin = this.options.cursorScrollMargin }
  26440. } else if (typeof range == "number") {
  26441. range = {from: Pos(range, 0), to: null}
  26442. } else if (range.from == null) {
  26443. range = {from: range, to: null}
  26444. }
  26445. if (!range.to) { range.to = range.from }
  26446. range.margin = margin || 0
  26447. if (range.from.line != null) {
  26448. resolveScrollToPos(this)
  26449. this.curOp.scrollToPos = range
  26450. } else {
  26451. var sPos = calculateScrollPos(this, Math.min(range.from.left, range.to.left),
  26452. Math.min(range.from.top, range.to.top) - range.margin,
  26453. Math.max(range.from.right, range.to.right),
  26454. Math.max(range.from.bottom, range.to.bottom) + range.margin)
  26455. this.scrollTo(sPos.scrollLeft, sPos.scrollTop)
  26456. }
  26457. }),
  26458. setSize: methodOp(function(width, height) {
  26459. var this$1 = this;
  26460. var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; }
  26461. if (width != null) { this.display.wrapper.style.width = interpret(width) }
  26462. if (height != null) { this.display.wrapper.style.height = interpret(height) }
  26463. if (this.options.lineWrapping) { clearLineMeasurementCache(this) }
  26464. var lineNo = this.display.viewFrom
  26465. this.doc.iter(lineNo, this.display.viewTo, function (line) {
  26466. if (line.widgets) { for (var i = 0; i < line.widgets.length; i++)
  26467. { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo, "widget"); break } } }
  26468. ++lineNo
  26469. })
  26470. this.curOp.forceUpdate = true
  26471. signal(this, "refresh", this)
  26472. }),
  26473. operation: function(f){return runInOp(this, f)},
  26474. refresh: methodOp(function() {
  26475. var oldHeight = this.display.cachedTextHeight
  26476. regChange(this)
  26477. this.curOp.forceUpdate = true
  26478. clearCaches(this)
  26479. this.scrollTo(this.doc.scrollLeft, this.doc.scrollTop)
  26480. updateGutterSpace(this)
  26481. if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
  26482. { estimateLineHeights(this) }
  26483. signal(this, "refresh", this)
  26484. }),
  26485. swapDoc: methodOp(function(doc) {
  26486. var old = this.doc
  26487. old.cm = null
  26488. attachDoc(this, doc)
  26489. clearCaches(this)
  26490. this.display.input.reset()
  26491. this.scrollTo(doc.scrollLeft, doc.scrollTop)
  26492. this.curOp.forceScroll = true
  26493. signalLater(this, "swapDoc", this, old)
  26494. return old
  26495. }),
  26496. getInputField: function(){return this.display.input.getField()},
  26497. getWrapperElement: function(){return this.display.wrapper},
  26498. getScrollerElement: function(){return this.display.scroller},
  26499. getGutterElement: function(){return this.display.gutters}
  26500. }
  26501. eventMixin(CodeMirror)
  26502. CodeMirror.registerHelper = function(type, name, value) {
  26503. if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []} }
  26504. helpers[type][name] = value
  26505. }
  26506. CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
  26507. CodeMirror.registerHelper(type, name, value)
  26508. helpers[type]._global.push({pred: predicate, val: value})
  26509. }
  26510. }
  26511. // Used for horizontal relative motion. Dir is -1 or 1 (left or
  26512. // right), unit can be "char", "column" (like char, but doesn't
  26513. // cross line boundaries), "word" (across next word), or "group" (to
  26514. // the start of next group of word or non-word-non-whitespace
  26515. // chars). The visually param controls whether, in right-to-left
  26516. // text, direction 1 means to move towards the next index in the
  26517. // string, or towards the character to the right of the current
  26518. // position. The resulting position will have a hitSide=true
  26519. // property if it reached the end of the document.
  26520. function findPosH(doc, pos, dir, unit, visually) {
  26521. var line = pos.line, ch = pos.ch, origDir = dir
  26522. var lineObj = getLine(doc, line)
  26523. function findNextLine() {
  26524. var l = line + dir
  26525. if (l < doc.first || l >= doc.first + doc.size) { return false }
  26526. line = l
  26527. return lineObj = getLine(doc, l)
  26528. }
  26529. function moveOnce(boundToLine) {
  26530. var next = (visually ? moveVisually : moveLogically)(lineObj, ch, dir, true)
  26531. if (next == null) {
  26532. if (!boundToLine && findNextLine()) {
  26533. if (visually) { ch = (dir < 0 ? lineRight : lineLeft)(lineObj) }
  26534. else { ch = dir < 0 ? lineObj.text.length : 0 }
  26535. } else { return false }
  26536. } else { ch = next }
  26537. return true
  26538. }
  26539. if (unit == "char") {
  26540. moveOnce()
  26541. } else if (unit == "column") {
  26542. moveOnce(true)
  26543. } else if (unit == "word" || unit == "group") {
  26544. var sawType = null, group = unit == "group"
  26545. var helper = doc.cm && doc.cm.getHelper(pos, "wordChars")
  26546. for (var first = true;; first = false) {
  26547. if (dir < 0 && !moveOnce(!first)) { break }
  26548. var cur = lineObj.text.charAt(ch) || "\n"
  26549. var type = isWordChar(cur, helper) ? "w"
  26550. : group && cur == "\n" ? "n"
  26551. : !group || /\s/.test(cur) ? null
  26552. : "p"
  26553. if (group && !first && !type) { type = "s" }
  26554. if (sawType && sawType != type) {
  26555. if (dir < 0) {dir = 1; moveOnce()}
  26556. break
  26557. }
  26558. if (type) { sawType = type }
  26559. if (dir > 0 && !moveOnce(!first)) { break }
  26560. }
  26561. }
  26562. var result = skipAtomic(doc, Pos(line, ch), pos, origDir, true)
  26563. if (!cmp(pos, result)) { result.hitSide = true }
  26564. return result
  26565. }
  26566. // For relative vertical movement. Dir may be -1 or 1. Unit can be
  26567. // "page" or "line". The resulting position will have a hitSide=true
  26568. // property if it reached the end of the document.
  26569. function findPosV(cm, pos, dir, unit) {
  26570. var doc = cm.doc, x = pos.left, y
  26571. if (unit == "page") {
  26572. var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight)
  26573. var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3)
  26574. y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount
  26575. } else if (unit == "line") {
  26576. y = dir > 0 ? pos.bottom + 3 : pos.top - 3
  26577. }
  26578. var target
  26579. for (;;) {
  26580. target = coordsChar(cm, x, y)
  26581. if (!target.outside) { break }
  26582. if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break }
  26583. y += dir * 5
  26584. }
  26585. return target
  26586. }
  26587. // CONTENTEDITABLE INPUT STYLE
  26588. var ContentEditableInput = function(cm) {
  26589. this.cm = cm
  26590. this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null
  26591. this.polling = new Delayed()
  26592. this.composing = null
  26593. this.gracePeriod = false
  26594. this.readDOMTimeout = null
  26595. };
  26596. ContentEditableInput.prototype.init = function (display) {
  26597. var this$1 = this;
  26598. var input = this, cm = input.cm
  26599. var div = input.div = display.lineDiv
  26600. disableBrowserMagic(div, cm.options.spellcheck)
  26601. on(div, "paste", function (e) {
  26602. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
  26603. // IE doesn't fire input events, so we schedule a read for the pasted content in this way
  26604. if (ie_version <= 11) { setTimeout(operation(cm, function () {
  26605. if (!input.pollContent()) { regChange(cm) }
  26606. }), 20) }
  26607. })
  26608. on(div, "compositionstart", function (e) {
  26609. this$1.composing = {data: e.data, done: false}
  26610. })
  26611. on(div, "compositionupdate", function (e) {
  26612. if (!this$1.composing) { this$1.composing = {data: e.data, done: false} }
  26613. })
  26614. on(div, "compositionend", function (e) {
  26615. if (this$1.composing) {
  26616. if (e.data != this$1.composing.data) { this$1.readFromDOMSoon() }
  26617. this$1.composing.done = true
  26618. }
  26619. })
  26620. on(div, "touchstart", function () { return input.forceCompositionEnd(); })
  26621. on(div, "input", function () {
  26622. if (!this$1.composing) { this$1.readFromDOMSoon() }
  26623. })
  26624. function onCopyCut(e) {
  26625. if (signalDOMEvent(cm, e)) { return }
  26626. if (cm.somethingSelected()) {
  26627. setLastCopied({lineWise: false, text: cm.getSelections()})
  26628. if (e.type == "cut") { cm.replaceSelection("", null, "cut") }
  26629. } else if (!cm.options.lineWiseCopyCut) {
  26630. return
  26631. } else {
  26632. var ranges = copyableRanges(cm)
  26633. setLastCopied({lineWise: true, text: ranges.text})
  26634. if (e.type == "cut") {
  26635. cm.operation(function () {
  26636. cm.setSelections(ranges.ranges, 0, sel_dontScroll)
  26637. cm.replaceSelection("", null, "cut")
  26638. })
  26639. }
  26640. }
  26641. if (e.clipboardData) {
  26642. e.clipboardData.clearData()
  26643. var content = lastCopied.text.join("\n")
  26644. // iOS exposes the clipboard API, but seems to discard content inserted into it
  26645. e.clipboardData.setData("Text", content)
  26646. if (e.clipboardData.getData("Text") == content) {
  26647. e.preventDefault()
  26648. return
  26649. }
  26650. }
  26651. // Old-fashioned briefly-focus-a-textarea hack
  26652. var kludge = hiddenTextarea(), te = kludge.firstChild
  26653. cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild)
  26654. te.value = lastCopied.text.join("\n")
  26655. var hadFocus = document.activeElement
  26656. selectInput(te)
  26657. setTimeout(function () {
  26658. cm.display.lineSpace.removeChild(kludge)
  26659. hadFocus.focus()
  26660. if (hadFocus == div) { input.showPrimarySelection() }
  26661. }, 50)
  26662. }
  26663. on(div, "copy", onCopyCut)
  26664. on(div, "cut", onCopyCut)
  26665. };
  26666. ContentEditableInput.prototype.prepareSelection = function () {
  26667. var result = prepareSelection(this.cm, false)
  26668. result.focus = this.cm.state.focused
  26669. return result
  26670. };
  26671. ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
  26672. if (!info || !this.cm.display.view.length) { return }
  26673. if (info.focus || takeFocus) { this.showPrimarySelection() }
  26674. this.showMultipleSelections(info)
  26675. };
  26676. ContentEditableInput.prototype.showPrimarySelection = function () {
  26677. var sel = window.getSelection(), prim = this.cm.doc.sel.primary()
  26678. var curAnchor = domToPos(this.cm, sel.anchorNode, sel.anchorOffset)
  26679. var curFocus = domToPos(this.cm, sel.focusNode, sel.focusOffset)
  26680. if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
  26681. cmp(minPos(curAnchor, curFocus), prim.from()) == 0 &&
  26682. cmp(maxPos(curAnchor, curFocus), prim.to()) == 0)
  26683. { return }
  26684. var start = posToDOM(this.cm, prim.from())
  26685. var end = posToDOM(this.cm, prim.to())
  26686. if (!start && !end) { return }
  26687. var view = this.cm.display.view
  26688. var old = sel.rangeCount && sel.getRangeAt(0)
  26689. if (!start) {
  26690. start = {node: view[0].measure.map[2], offset: 0}
  26691. } else if (!end) { // FIXME dangerously hacky
  26692. var measure = view[view.length - 1].measure
  26693. var map = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map
  26694. end = {node: map[map.length - 1], offset: map[map.length - 2] - map[map.length - 3]}
  26695. }
  26696. var rng
  26697. try { rng = range(start.node, start.offset, end.offset, end.node) }
  26698. catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
  26699. if (rng) {
  26700. if (!gecko && this.cm.state.focused) {
  26701. sel.collapse(start.node, start.offset)
  26702. if (!rng.collapsed) {
  26703. sel.removeAllRanges()
  26704. sel.addRange(rng)
  26705. }
  26706. } else {
  26707. sel.removeAllRanges()
  26708. sel.addRange(rng)
  26709. }
  26710. if (old && sel.anchorNode == null) { sel.addRange(old) }
  26711. else if (gecko) { this.startGracePeriod() }
  26712. }
  26713. this.rememberSelection()
  26714. };
  26715. ContentEditableInput.prototype.startGracePeriod = function () {
  26716. var this$1 = this;
  26717. clearTimeout(this.gracePeriod)
  26718. this.gracePeriod = setTimeout(function () {
  26719. this$1.gracePeriod = false
  26720. if (this$1.selectionChanged())
  26721. { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }) }
  26722. }, 20)
  26723. };
  26724. ContentEditableInput.prototype.showMultipleSelections = function (info) {
  26725. removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors)
  26726. removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection)
  26727. };
  26728. ContentEditableInput.prototype.rememberSelection = function () {
  26729. var sel = window.getSelection()
  26730. this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset
  26731. this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset
  26732. };
  26733. ContentEditableInput.prototype.selectionInEditor = function () {
  26734. var sel = window.getSelection()
  26735. if (!sel.rangeCount) { return false }
  26736. var node = sel.getRangeAt(0).commonAncestorContainer
  26737. return contains(this.div, node)
  26738. };
  26739. ContentEditableInput.prototype.focus = function () {
  26740. if (this.cm.options.readOnly != "nocursor") {
  26741. if (!this.selectionInEditor())
  26742. { this.showSelection(this.prepareSelection(), true) }
  26743. this.div.focus()
  26744. }
  26745. };
  26746. ContentEditableInput.prototype.blur = function () { this.div.blur() };
  26747. ContentEditableInput.prototype.getField = function () { return this.div };
  26748. ContentEditableInput.prototype.supportsTouch = function () { return true };
  26749. ContentEditableInput.prototype.receivedFocus = function () {
  26750. var input = this
  26751. if (this.selectionInEditor())
  26752. { this.pollSelection() }
  26753. else
  26754. { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }) }
  26755. function poll() {
  26756. if (input.cm.state.focused) {
  26757. input.pollSelection()
  26758. input.polling.set(input.cm.options.pollInterval, poll)
  26759. }
  26760. }
  26761. this.polling.set(this.cm.options.pollInterval, poll)
  26762. };
  26763. ContentEditableInput.prototype.selectionChanged = function () {
  26764. var sel = window.getSelection()
  26765. return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
  26766. sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset
  26767. };
  26768. ContentEditableInput.prototype.pollSelection = function () {
  26769. if (!this.composing && this.readDOMTimeout == null && !this.gracePeriod && this.selectionChanged()) {
  26770. var sel = window.getSelection(), cm = this.cm
  26771. this.rememberSelection()
  26772. var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset)
  26773. var head = domToPos(cm, sel.focusNode, sel.focusOffset)
  26774. if (anchor && head) { runInOp(cm, function () {
  26775. setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll)
  26776. if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true }
  26777. }) }
  26778. }
  26779. };
  26780. ContentEditableInput.prototype.pollContent = function () {
  26781. if (this.readDOMTimeout != null) {
  26782. clearTimeout(this.readDOMTimeout)
  26783. this.readDOMTimeout = null
  26784. }
  26785. var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary()
  26786. var from = sel.from(), to = sel.to()
  26787. if (from.ch == 0 && from.line > cm.firstLine())
  26788. { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length) }
  26789. if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())
  26790. { to = Pos(to.line + 1, 0) }
  26791. if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
  26792. var fromIndex, fromLine, fromNode
  26793. if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
  26794. fromLine = lineNo(display.view[0].line)
  26795. fromNode = display.view[0].node
  26796. } else {
  26797. fromLine = lineNo(display.view[fromIndex].line)
  26798. fromNode = display.view[fromIndex - 1].node.nextSibling
  26799. }
  26800. var toIndex = findViewIndex(cm, to.line)
  26801. var toLine, toNode
  26802. if (toIndex == display.view.length - 1) {
  26803. toLine = display.viewTo - 1
  26804. toNode = display.lineDiv.lastChild
  26805. } else {
  26806. toLine = lineNo(display.view[toIndex + 1].line) - 1
  26807. toNode = display.view[toIndex + 1].node.previousSibling
  26808. }
  26809. if (!fromNode) { return false }
  26810. var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine))
  26811. var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length))
  26812. while (newText.length > 1 && oldText.length > 1) {
  26813. if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine-- }
  26814. else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++ }
  26815. else { break }
  26816. }
  26817. var cutFront = 0, cutEnd = 0
  26818. var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length)
  26819. while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
  26820. { ++cutFront }
  26821. var newBot = lst(newText), oldBot = lst(oldText)
  26822. var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
  26823. oldBot.length - (oldText.length == 1 ? cutFront : 0))
  26824. while (cutEnd < maxCutEnd &&
  26825. newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
  26826. { ++cutEnd }
  26827. newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "")
  26828. newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "")
  26829. var chFrom = Pos(fromLine, cutFront)
  26830. var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0)
  26831. if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
  26832. replaceRange(cm.doc, newText, chFrom, chTo, "+input")
  26833. return true
  26834. }
  26835. };
  26836. ContentEditableInput.prototype.ensurePolled = function () {
  26837. this.forceCompositionEnd()
  26838. };
  26839. ContentEditableInput.prototype.reset = function () {
  26840. this.forceCompositionEnd()
  26841. };
  26842. ContentEditableInput.prototype.forceCompositionEnd = function () {
  26843. if (!this.composing) { return }
  26844. clearTimeout(this.readDOMTimeout)
  26845. this.composing = null
  26846. if (!this.pollContent()) { regChange(this.cm) }
  26847. this.div.blur()
  26848. this.div.focus()
  26849. };
  26850. ContentEditableInput.prototype.readFromDOMSoon = function () {
  26851. var this$1 = this;
  26852. if (this.readDOMTimeout != null) { return }
  26853. this.readDOMTimeout = setTimeout(function () {
  26854. this$1.readDOMTimeout = null
  26855. if (this$1.composing) {
  26856. if (this$1.composing.done) { this$1.composing = null }
  26857. else { return }
  26858. }
  26859. if (this$1.cm.isReadOnly() || !this$1.pollContent())
  26860. { runInOp(this$1.cm, function () { return regChange(this$1.cm); }) }
  26861. }, 80)
  26862. };
  26863. ContentEditableInput.prototype.setUneditable = function (node) {
  26864. node.contentEditable = "false"
  26865. };
  26866. ContentEditableInput.prototype.onKeyPress = function (e) {
  26867. e.preventDefault()
  26868. if (!this.cm.isReadOnly())
  26869. { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0) }
  26870. };
  26871. ContentEditableInput.prototype.readOnlyChanged = function (val) {
  26872. this.div.contentEditable = String(val != "nocursor")
  26873. };
  26874. ContentEditableInput.prototype.onContextMenu = function () {};
  26875. ContentEditableInput.prototype.resetPosition = function () {};
  26876. ContentEditableInput.prototype.needsContentAttribute = true
  26877. function posToDOM(cm, pos) {
  26878. var view = findViewForLine(cm, pos.line)
  26879. if (!view || view.hidden) { return null }
  26880. var line = getLine(cm.doc, pos.line)
  26881. var info = mapFromLineView(view, line, pos.line)
  26882. var order = getOrder(line), side = "left"
  26883. if (order) {
  26884. var partPos = getBidiPartAt(order, pos.ch)
  26885. side = partPos % 2 ? "right" : "left"
  26886. }
  26887. var result = nodeAndOffsetInLineMap(info.map, pos.ch, side)
  26888. result.offset = result.collapse == "right" ? result.end : result.start
  26889. return result
  26890. }
  26891. function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }
  26892. function domTextBetween(cm, from, to, fromLine, toLine) {
  26893. var text = "", closing = false, lineSep = cm.doc.lineSeparator()
  26894. function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
  26895. function walk(node) {
  26896. if (node.nodeType == 1) {
  26897. var cmText = node.getAttribute("cm-text")
  26898. if (cmText != null) {
  26899. if (cmText == "") { text += node.textContent.replace(/\u200b/g, "") }
  26900. else { text += cmText }
  26901. return
  26902. }
  26903. var markerID = node.getAttribute("cm-marker"), range
  26904. if (markerID) {
  26905. var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID))
  26906. if (found.length && (range = found[0].find()))
  26907. { text += getBetween(cm.doc, range.from, range.to).join(lineSep) }
  26908. return
  26909. }
  26910. if (node.getAttribute("contenteditable") == "false") { return }
  26911. for (var i = 0; i < node.childNodes.length; i++)
  26912. { walk(node.childNodes[i]) }
  26913. if (/^(pre|div|p)$/i.test(node.nodeName))
  26914. { closing = true }
  26915. } else if (node.nodeType == 3) {
  26916. var val = node.nodeValue
  26917. if (!val) { return }
  26918. if (closing) {
  26919. text += lineSep
  26920. closing = false
  26921. }
  26922. text += val
  26923. }
  26924. }
  26925. for (;;) {
  26926. walk(from)
  26927. if (from == to) { break }
  26928. from = from.nextSibling
  26929. }
  26930. return text
  26931. }
  26932. function domToPos(cm, node, offset) {
  26933. var lineNode
  26934. if (node == cm.display.lineDiv) {
  26935. lineNode = cm.display.lineDiv.childNodes[offset]
  26936. if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) }
  26937. node = null; offset = 0
  26938. } else {
  26939. for (lineNode = node;; lineNode = lineNode.parentNode) {
  26940. if (!lineNode || lineNode == cm.display.lineDiv) { return null }
  26941. if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break }
  26942. }
  26943. }
  26944. for (var i = 0; i < cm.display.view.length; i++) {
  26945. var lineView = cm.display.view[i]
  26946. if (lineView.node == lineNode)
  26947. { return locateNodeInLineView(lineView, node, offset) }
  26948. }
  26949. }
  26950. function locateNodeInLineView(lineView, node, offset) {
  26951. var wrapper = lineView.text.firstChild, bad = false
  26952. if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }
  26953. if (node == wrapper) {
  26954. bad = true
  26955. node = wrapper.childNodes[offset]
  26956. offset = 0
  26957. if (!node) {
  26958. var line = lineView.rest ? lst(lineView.rest) : lineView.line
  26959. return badPos(Pos(lineNo(line), line.text.length), bad)
  26960. }
  26961. }
  26962. var textNode = node.nodeType == 3 ? node : null, topNode = node
  26963. if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
  26964. textNode = node.firstChild
  26965. if (offset) { offset = textNode.nodeValue.length }
  26966. }
  26967. while (topNode.parentNode != wrapper) { topNode = topNode.parentNode }
  26968. var measure = lineView.measure, maps = measure.maps
  26969. function find(textNode, topNode, offset) {
  26970. for (var i = -1; i < (maps ? maps.length : 0); i++) {
  26971. var map = i < 0 ? measure.map : maps[i]
  26972. for (var j = 0; j < map.length; j += 3) {
  26973. var curNode = map[j + 2]
  26974. if (curNode == textNode || curNode == topNode) {
  26975. var line = lineNo(i < 0 ? lineView.line : lineView.rest[i])
  26976. var ch = map[j] + offset
  26977. if (offset < 0 || curNode != textNode) { ch = map[j + (offset ? 1 : 0)] }
  26978. return Pos(line, ch)
  26979. }
  26980. }
  26981. }
  26982. }
  26983. var found = find(textNode, topNode, offset)
  26984. if (found) { return badPos(found, bad) }
  26985. // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
  26986. for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
  26987. found = find(after, after.firstChild, 0)
  26988. if (found)
  26989. { return badPos(Pos(found.line, found.ch - dist), bad) }
  26990. else
  26991. { dist += after.textContent.length }
  26992. }
  26993. for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {
  26994. found = find(before, before.firstChild, -1)
  26995. if (found)
  26996. { return badPos(Pos(found.line, found.ch + dist$1), bad) }
  26997. else
  26998. { dist$1 += before.textContent.length }
  26999. }
  27000. }
  27001. // TEXTAREA INPUT STYLE
  27002. var TextareaInput = function(cm) {
  27003. this.cm = cm
  27004. // See input.poll and input.reset
  27005. this.prevInput = ""
  27006. // Flag that indicates whether we expect input to appear real soon
  27007. // now (after some event like 'keypress' or 'input') and are
  27008. // polling intensively.
  27009. this.pollingFast = false
  27010. // Self-resetting timeout for the poller
  27011. this.polling = new Delayed()
  27012. // Tracks when input.reset has punted to just putting a short
  27013. // string into the textarea instead of the full selection.
  27014. this.inaccurateSelection = false
  27015. // Used to work around IE issue with selection being forgotten when focus moves away from textarea
  27016. this.hasSelection = false
  27017. this.composing = null
  27018. };
  27019. TextareaInput.prototype.init = function (display) {
  27020. var this$1 = this;
  27021. var input = this, cm = this.cm
  27022. // Wraps and hides input textarea
  27023. var div = this.wrapper = hiddenTextarea()
  27024. // The semihidden textarea that is focused when the editor is
  27025. // focused, and receives input.
  27026. var te = this.textarea = div.firstChild
  27027. display.wrapper.insertBefore(div, display.wrapper.firstChild)
  27028. // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
  27029. if (ios) { te.style.width = "0px" }
  27030. on(te, "input", function () {
  27031. if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null }
  27032. input.poll()
  27033. })
  27034. on(te, "paste", function (e) {
  27035. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
  27036. cm.state.pasteIncoming = true
  27037. input.fastPoll()
  27038. })
  27039. function prepareCopyCut(e) {
  27040. if (signalDOMEvent(cm, e)) { return }
  27041. if (cm.somethingSelected()) {
  27042. setLastCopied({lineWise: false, text: cm.getSelections()})
  27043. if (input.inaccurateSelection) {
  27044. input.prevInput = ""
  27045. input.inaccurateSelection = false
  27046. te.value = lastCopied.text.join("\n")
  27047. selectInput(te)
  27048. }
  27049. } else if (!cm.options.lineWiseCopyCut) {
  27050. return
  27051. } else {
  27052. var ranges = copyableRanges(cm)
  27053. setLastCopied({lineWise: true, text: ranges.text})
  27054. if (e.type == "cut") {
  27055. cm.setSelections(ranges.ranges, null, sel_dontScroll)
  27056. } else {
  27057. input.prevInput = ""
  27058. te.value = ranges.text.join("\n")
  27059. selectInput(te)
  27060. }
  27061. }
  27062. if (e.type == "cut") { cm.state.cutIncoming = true }
  27063. }
  27064. on(te, "cut", prepareCopyCut)
  27065. on(te, "copy", prepareCopyCut)
  27066. on(display.scroller, "paste", function (e) {
  27067. if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }
  27068. cm.state.pasteIncoming = true
  27069. input.focus()
  27070. })
  27071. // Prevent normal selection in the editor (we handle our own)
  27072. on(display.lineSpace, "selectstart", function (e) {
  27073. if (!eventInWidget(display, e)) { e_preventDefault(e) }
  27074. })
  27075. on(te, "compositionstart", function () {
  27076. var start = cm.getCursor("from")
  27077. if (input.composing) { input.composing.range.clear() }
  27078. input.composing = {
  27079. start: start,
  27080. range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
  27081. }
  27082. })
  27083. on(te, "compositionend", function () {
  27084. if (input.composing) {
  27085. input.poll()
  27086. input.composing.range.clear()
  27087. input.composing = null
  27088. }
  27089. })
  27090. };
  27091. TextareaInput.prototype.prepareSelection = function () {
  27092. // Redraw the selection and/or cursor
  27093. var cm = this.cm, display = cm.display, doc = cm.doc
  27094. var result = prepareSelection(cm)
  27095. // Move the hidden textarea near the cursor to prevent scrolling artifacts
  27096. if (cm.options.moveInputWithCursor) {
  27097. var headPos = cursorCoords(cm, doc.sel.primary().head, "div")
  27098. var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect()
  27099. result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
  27100. headPos.top + lineOff.top - wrapOff.top))
  27101. result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
  27102. headPos.left + lineOff.left - wrapOff.left))
  27103. }
  27104. return result
  27105. };
  27106. TextareaInput.prototype.showSelection = function (drawn) {
  27107. var cm = this.cm, display = cm.display
  27108. removeChildrenAndAdd(display.cursorDiv, drawn.cursors)
  27109. removeChildrenAndAdd(display.selectionDiv, drawn.selection)
  27110. if (drawn.teTop != null) {
  27111. this.wrapper.style.top = drawn.teTop + "px"
  27112. this.wrapper.style.left = drawn.teLeft + "px"
  27113. }
  27114. };
  27115. // Reset the input to correspond to the selection (or to be empty,
  27116. // when not typing and nothing is selected)
  27117. TextareaInput.prototype.reset = function (typing) {
  27118. if (this.contextMenuPending) { return }
  27119. var minimal, selected, cm = this.cm, doc = cm.doc
  27120. if (cm.somethingSelected()) {
  27121. this.prevInput = ""
  27122. var range = doc.sel.primary()
  27123. minimal = hasCopyEvent &&
  27124. (range.to().line - range.from().line > 100 || (selected = cm.getSelection()).length > 1000)
  27125. var content = minimal ? "-" : selected || cm.getSelection()
  27126. this.textarea.value = content
  27127. if (cm.state.focused) { selectInput(this.textarea) }
  27128. if (ie && ie_version >= 9) { this.hasSelection = content }
  27129. } else if (!typing) {
  27130. this.prevInput = this.textarea.value = ""
  27131. if (ie && ie_version >= 9) { this.hasSelection = null }
  27132. }
  27133. this.inaccurateSelection = minimal
  27134. };
  27135. TextareaInput.prototype.getField = function () { return this.textarea };
  27136. TextareaInput.prototype.supportsTouch = function () { return false };
  27137. TextareaInput.prototype.focus = function () {
  27138. if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
  27139. try { this.textarea.focus() }
  27140. catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
  27141. }
  27142. };
  27143. TextareaInput.prototype.blur = function () { this.textarea.blur() };
  27144. TextareaInput.prototype.resetPosition = function () {
  27145. this.wrapper.style.top = this.wrapper.style.left = 0
  27146. };
  27147. TextareaInput.prototype.receivedFocus = function () { this.slowPoll() };
  27148. // Poll for input changes, using the normal rate of polling. This
  27149. // runs as long as the editor is focused.
  27150. TextareaInput.prototype.slowPoll = function () {
  27151. var this$1 = this;
  27152. if (this.pollingFast) { return }
  27153. this.polling.set(this.cm.options.pollInterval, function () {
  27154. this$1.poll()
  27155. if (this$1.cm.state.focused) { this$1.slowPoll() }
  27156. })
  27157. };
  27158. // When an event has just come in that is likely to add or change
  27159. // something in the input textarea, we poll faster, to ensure that
  27160. // the change appears on the screen quickly.
  27161. TextareaInput.prototype.fastPoll = function () {
  27162. var missed = false, input = this
  27163. input.pollingFast = true
  27164. function p() {
  27165. var changed = input.poll()
  27166. if (!changed && !missed) {missed = true; input.polling.set(60, p)}
  27167. else {input.pollingFast = false; input.slowPoll()}
  27168. }
  27169. input.polling.set(20, p)
  27170. };
  27171. // Read input from the textarea, and update the document to match.
  27172. // When something is selected, it is present in the textarea, and
  27173. // selected (unless it is huge, in which case a placeholder is
  27174. // used). When nothing is selected, the cursor sits after previously
  27175. // seen text (can be empty), which is stored in prevInput (we must
  27176. // not reset the textarea when typing, because that breaks IME).
  27177. TextareaInput.prototype.poll = function () {
  27178. var this$1 = this;
  27179. var cm = this.cm, input = this.textarea, prevInput = this.prevInput
  27180. // Since this is called a *lot*, try to bail out as cheaply as
  27181. // possible when it is clear that nothing happened. hasSelection
  27182. // will be the case when there is a lot of text in the textarea,
  27183. // in which case reading its value would be expensive.
  27184. if (this.contextMenuPending || !cm.state.focused ||
  27185. (hasSelection(input) && !prevInput && !this.composing) ||
  27186. cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
  27187. { return false }
  27188. var text = input.value
  27189. // If nothing changed, bail.
  27190. if (text == prevInput && !cm.somethingSelected()) { return false }
  27191. // Work around nonsensical selection resetting in IE9/10, and
  27192. // inexplicable appearance of private area unicode characters on
  27193. // some key combos in Mac (#2689).
  27194. if (ie && ie_version >= 9 && this.hasSelection === text ||
  27195. mac && /[\uf700-\uf7ff]/.test(text)) {
  27196. cm.display.input.reset()
  27197. return false
  27198. }
  27199. if (cm.doc.sel == cm.display.selForContextMenu) {
  27200. var first = text.charCodeAt(0)
  27201. if (first == 0x200b && !prevInput) { prevInput = "\u200b" }
  27202. if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
  27203. }
  27204. // Find the part of the input that is actually new
  27205. var same = 0, l = Math.min(prevInput.length, text.length)
  27206. while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same }
  27207. runInOp(cm, function () {
  27208. applyTextInput(cm, text.slice(same), prevInput.length - same,
  27209. null, this$1.composing ? "*compose" : null)
  27210. // Don't leave long text in the textarea, since it makes further polling slow
  27211. if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = "" }
  27212. else { this$1.prevInput = text }
  27213. if (this$1.composing) {
  27214. this$1.composing.range.clear()
  27215. this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"),
  27216. {className: "CodeMirror-composing"})
  27217. }
  27218. })
  27219. return true
  27220. };
  27221. TextareaInput.prototype.ensurePolled = function () {
  27222. if (this.pollingFast && this.poll()) { this.pollingFast = false }
  27223. };
  27224. TextareaInput.prototype.onKeyPress = function () {
  27225. if (ie && ie_version >= 9) { this.hasSelection = null }
  27226. this.fastPoll()
  27227. };
  27228. TextareaInput.prototype.onContextMenu = function (e) {
  27229. var input = this, cm = input.cm, display = cm.display, te = input.textarea
  27230. var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop
  27231. if (!pos || presto) { return } // Opera is difficult.
  27232. // Reset the current text selection only if the click is done outside of the selection
  27233. // and 'resetSelectionOnContextMenu' option is true.
  27234. var reset = cm.options.resetSelectionOnContextMenu
  27235. if (reset && cm.doc.sel.contains(pos) == -1)
  27236. { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll) }
  27237. var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText
  27238. input.wrapper.style.cssText = "position: absolute"
  27239. var wrapperBox = input.wrapper.getBoundingClientRect()
  27240. te.style.cssText = "position: absolute; width: 30px; height: 30px;\n top: " + (e.clientY - wrapperBox.top - 5) + "px; left: " + (e.clientX - wrapperBox.left - 5) + "px;\n z-index: 1000; background: " + (ie ? "rgba(255, 255, 255, .05)" : "transparent") + ";\n outline: none; border-width: 0; outline: none; overflow: hidden; opacity: .05; filter: alpha(opacity=5);"
  27241. var oldScrollY
  27242. if (webkit) { oldScrollY = window.scrollY } // Work around Chrome issue (#2712)
  27243. display.input.focus()
  27244. if (webkit) { window.scrollTo(null, oldScrollY) }
  27245. display.input.reset()
  27246. // Adds "Select all" to context menu in FF
  27247. if (!cm.somethingSelected()) { te.value = input.prevInput = " " }
  27248. input.contextMenuPending = true
  27249. display.selForContextMenu = cm.doc.sel
  27250. clearTimeout(display.detectingSelectAll)
  27251. // Select-all will be greyed out if there's nothing to select, so
  27252. // this adds a zero-width space so that we can later check whether
  27253. // it got selected.
  27254. function prepareSelectAllHack() {
  27255. if (te.selectionStart != null) {
  27256. var selected = cm.somethingSelected()
  27257. var extval = "\u200b" + (selected ? te.value : "")
  27258. te.value = "\u21da" // Used to catch context-menu undo
  27259. te.value = extval
  27260. input.prevInput = selected ? "" : "\u200b"
  27261. te.selectionStart = 1; te.selectionEnd = extval.length
  27262. // Re-set this, in case some other handler touched the
  27263. // selection in the meantime.
  27264. display.selForContextMenu = cm.doc.sel
  27265. }
  27266. }
  27267. function rehide() {
  27268. input.contextMenuPending = false
  27269. input.wrapper.style.cssText = oldWrapperCSS
  27270. te.style.cssText = oldCSS
  27271. if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos) }
  27272. // Try to detect the user choosing select-all
  27273. if (te.selectionStart != null) {
  27274. if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack() }
  27275. var i = 0, poll = function () {
  27276. if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
  27277. te.selectionEnd > 0 && input.prevInput == "\u200b")
  27278. { operation(cm, selectAll)(cm) }
  27279. else if (i++ < 10) { display.detectingSelectAll = setTimeout(poll, 500) }
  27280. else { display.input.reset() }
  27281. }
  27282. display.detectingSelectAll = setTimeout(poll, 200)
  27283. }
  27284. }
  27285. if (ie && ie_version >= 9) { prepareSelectAllHack() }
  27286. if (captureRightClick) {
  27287. e_stop(e)
  27288. var mouseup = function () {
  27289. off(window, "mouseup", mouseup)
  27290. setTimeout(rehide, 20)
  27291. }
  27292. on(window, "mouseup", mouseup)
  27293. } else {
  27294. setTimeout(rehide, 50)
  27295. }
  27296. };
  27297. TextareaInput.prototype.readOnlyChanged = function (val) {
  27298. if (!val) { this.reset() }
  27299. };
  27300. TextareaInput.prototype.setUneditable = function () {};
  27301. TextareaInput.prototype.needsContentAttribute = false
  27302. function fromTextArea(textarea, options) {
  27303. options = options ? copyObj(options) : {}
  27304. options.value = textarea.value
  27305. if (!options.tabindex && textarea.tabIndex)
  27306. { options.tabindex = textarea.tabIndex }
  27307. if (!options.placeholder && textarea.placeholder)
  27308. { options.placeholder = textarea.placeholder }
  27309. // Set autofocus to true if this textarea is focused, or if it has
  27310. // autofocus and no other element is focused.
  27311. if (options.autofocus == null) {
  27312. var hasFocus = activeElt()
  27313. options.autofocus = hasFocus == textarea ||
  27314. textarea.getAttribute("autofocus") != null && hasFocus == document.body
  27315. }
  27316. function save() {textarea.value = cm.getValue()}
  27317. var realSubmit
  27318. if (textarea.form) {
  27319. on(textarea.form, "submit", save)
  27320. // Deplorable hack to make the submit method do the right thing.
  27321. if (!options.leaveSubmitMethodAlone) {
  27322. var form = textarea.form
  27323. realSubmit = form.submit
  27324. try {
  27325. var wrappedSubmit = form.submit = function () {
  27326. save()
  27327. form.submit = realSubmit
  27328. form.submit()
  27329. form.submit = wrappedSubmit
  27330. }
  27331. } catch(e) {}
  27332. }
  27333. }
  27334. options.finishInit = function (cm) {
  27335. cm.save = save
  27336. cm.getTextArea = function () { return textarea; }
  27337. cm.toTextArea = function () {
  27338. cm.toTextArea = isNaN // Prevent this from being ran twice
  27339. save()
  27340. textarea.parentNode.removeChild(cm.getWrapperElement())
  27341. textarea.style.display = ""
  27342. if (textarea.form) {
  27343. off(textarea.form, "submit", save)
  27344. if (typeof textarea.form.submit == "function")
  27345. { textarea.form.submit = realSubmit }
  27346. }
  27347. }
  27348. }
  27349. textarea.style.display = "none"
  27350. var cm = CodeMirror(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
  27351. options)
  27352. return cm
  27353. }
  27354. function addLegacyProps(CodeMirror) {
  27355. CodeMirror.off = off
  27356. CodeMirror.on = on
  27357. CodeMirror.wheelEventPixels = wheelEventPixels
  27358. CodeMirror.Doc = Doc
  27359. CodeMirror.splitLines = splitLinesAuto
  27360. CodeMirror.countColumn = countColumn
  27361. CodeMirror.findColumn = findColumn
  27362. CodeMirror.isWordChar = isWordCharBasic
  27363. CodeMirror.Pass = Pass
  27364. CodeMirror.signal = signal
  27365. CodeMirror.Line = Line
  27366. CodeMirror.changeEnd = changeEnd
  27367. CodeMirror.scrollbarModel = scrollbarModel
  27368. CodeMirror.Pos = Pos
  27369. CodeMirror.cmpPos = cmp
  27370. CodeMirror.modes = modes
  27371. CodeMirror.mimeModes = mimeModes
  27372. CodeMirror.resolveMode = resolveMode
  27373. CodeMirror.getMode = getMode
  27374. CodeMirror.modeExtensions = modeExtensions
  27375. CodeMirror.extendMode = extendMode
  27376. CodeMirror.copyState = copyState
  27377. CodeMirror.startState = startState
  27378. CodeMirror.innerMode = innerMode
  27379. CodeMirror.commands = commands
  27380. CodeMirror.keyMap = keyMap
  27381. CodeMirror.keyName = keyName
  27382. CodeMirror.isModifierKey = isModifierKey
  27383. CodeMirror.lookupKey = lookupKey
  27384. CodeMirror.normalizeKeyMap = normalizeKeyMap
  27385. CodeMirror.StringStream = StringStream
  27386. CodeMirror.SharedTextMarker = SharedTextMarker
  27387. CodeMirror.TextMarker = TextMarker
  27388. CodeMirror.LineWidget = LineWidget
  27389. CodeMirror.e_preventDefault = e_preventDefault
  27390. CodeMirror.e_stopPropagation = e_stopPropagation
  27391. CodeMirror.e_stop = e_stop
  27392. CodeMirror.addClass = addClass
  27393. CodeMirror.contains = contains
  27394. CodeMirror.rmClass = rmClass
  27395. CodeMirror.keyNames = keyNames
  27396. }
  27397. // EDITOR CONSTRUCTOR
  27398. defineOptions(CodeMirror)
  27399. addEditorMethods(CodeMirror)
  27400. // Set up methods on CodeMirror's prototype to redirect to the editor's document.
  27401. var dontDelegate = "iter insert remove copy getEditor constructor".split(" ")
  27402. for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
  27403. { CodeMirror.prototype[prop] = (function(method) {
  27404. return function() {return method.apply(this.doc, arguments)}
  27405. })(Doc.prototype[prop]) } }
  27406. eventMixin(Doc)
  27407. // INPUT HANDLING
  27408. CodeMirror.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput}
  27409. // MODE DEFINITION AND QUERYING
  27410. // Extra arguments are stored as the mode's dependencies, which is
  27411. // used by (legacy) mechanisms like loadmode.js to automatically
  27412. // load a mode. (Preferred mechanism is the require/define calls.)
  27413. CodeMirror.defineMode = function(name/*, mode, …*/) {
  27414. if (!CodeMirror.defaults.mode && name != "null") { CodeMirror.defaults.mode = name }
  27415. defineMode.apply(this, arguments)
  27416. }
  27417. CodeMirror.defineMIME = defineMIME
  27418. // Minimal default mode.
  27419. CodeMirror.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); })
  27420. CodeMirror.defineMIME("text/plain", "null")
  27421. // EXTENSIONS
  27422. CodeMirror.defineExtension = function (name, func) {
  27423. CodeMirror.prototype[name] = func
  27424. }
  27425. CodeMirror.defineDocExtension = function (name, func) {
  27426. Doc.prototype[name] = func
  27427. }
  27428. CodeMirror.fromTextArea = fromTextArea
  27429. addLegacyProps(CodeMirror)
  27430. CodeMirror.version = "5.23.0"
  27431. return CodeMirror;
  27432. })));
  27433. /***/ },
  27434. /* 165 */
  27435. /***/ function(module, exports, __webpack_require__) {
  27436. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  27437. // Distributed under an MIT license: http://codemirror.net/LICENSE
  27438. (function(mod) {
  27439. if (true) // CommonJS
  27440. mod(__webpack_require__(164));
  27441. else if (typeof define == "function" && define.amd) // AMD
  27442. define(["../../lib/codemirror"], mod);
  27443. else // Plain browser env
  27444. mod(CodeMirror);
  27445. })(function(CodeMirror) {
  27446. "use strict";
  27447. var listRE = /^(\s*)(>[> ]*|- \[[x ]\]\s|[*+-]\s|(\d+)([.)]))(\s*)/,
  27448. emptyListRE = /^(\s*)(>[> ]*|- \[[x ]\]|[*+-]|(\d+)[.)])(\s*)$/,
  27449. unorderedListRE = /[*+-]\s/;
  27450. CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
  27451. if (cm.getOption("disableInput")) return CodeMirror.Pass;
  27452. var ranges = cm.listSelections(), replacements = [];
  27453. for (var i = 0; i < ranges.length; i++) {
  27454. var pos = ranges[i].head;
  27455. var eolState = cm.getStateAfter(pos.line);
  27456. var inList = eolState.list !== false;
  27457. var inQuote = eolState.quote !== 0;
  27458. var line = cm.getLine(pos.line), match = listRE.exec(line);
  27459. if (!ranges[i].empty() || (!inList && !inQuote) || !match) {
  27460. cm.execCommand("newlineAndIndent");
  27461. return;
  27462. }
  27463. if (emptyListRE.test(line)) {
  27464. cm.replaceRange("", {
  27465. line: pos.line, ch: 0
  27466. }, {
  27467. line: pos.line, ch: pos.ch + 1
  27468. });
  27469. replacements[i] = "\n";
  27470. } else {
  27471. var indent = match[1], after = match[5];
  27472. var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0
  27473. ? match[2].replace("x", " ")
  27474. : (parseInt(match[3], 10) + 1) + match[4];
  27475. replacements[i] = "\n" + indent + bullet + after;
  27476. }
  27477. }
  27478. cm.replaceSelections(replacements);
  27479. };
  27480. });
  27481. /***/ },
  27482. /* 166 */
  27483. /***/ function(module, exports, __webpack_require__) {
  27484. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  27485. // Distributed under an MIT license: http://codemirror.net/LICENSE
  27486. var CodeMirror = __webpack_require__(164);
  27487. CodeMirror.commands.tabAndIndentMarkdownList = function (cm) {
  27488. var ranges = cm.listSelections();
  27489. var pos = ranges[0].head;
  27490. var eolState = cm.getStateAfter(pos.line);
  27491. var inList = eolState.list !== false;
  27492. if (inList) {
  27493. cm.execCommand("indentMore");
  27494. return;
  27495. }
  27496. if (cm.options.indentWithTabs) {
  27497. cm.execCommand("insertTab");
  27498. }
  27499. else {
  27500. var spaces = Array(cm.options.tabSize + 1).join(" ");
  27501. cm.replaceSelection(spaces);
  27502. }
  27503. };
  27504. CodeMirror.commands.shiftTabAndUnindentMarkdownList = function (cm) {
  27505. var ranges = cm.listSelections();
  27506. var pos = ranges[0].head;
  27507. var eolState = cm.getStateAfter(pos.line);
  27508. var inList = eolState.list !== false;
  27509. if (inList) {
  27510. cm.execCommand("indentLess");
  27511. return;
  27512. }
  27513. if (cm.options.indentWithTabs) {
  27514. cm.execCommand("insertTab");
  27515. }
  27516. else {
  27517. var spaces = Array(cm.options.tabSize + 1).join(" ");
  27518. cm.replaceSelection(spaces);
  27519. }
  27520. };
  27521. /***/ },
  27522. /* 167 */
  27523. /***/ function(module, exports, __webpack_require__) {
  27524. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  27525. // Distributed under an MIT license: http://codemirror.net/LICENSE
  27526. (function(mod) {
  27527. if (true) // CommonJS
  27528. mod(__webpack_require__(164));
  27529. else if (typeof define == "function" && define.amd) // AMD
  27530. define(["../../lib/codemirror"], mod);
  27531. else // Plain browser env
  27532. mod(CodeMirror);
  27533. })(function(CodeMirror) {
  27534. "use strict";
  27535. CodeMirror.defineOption("fullScreen", false, function(cm, val, old) {
  27536. if (old == CodeMirror.Init) old = false;
  27537. if (!old == !val) return;
  27538. if (val) setFullscreen(cm);
  27539. else setNormal(cm);
  27540. });
  27541. function setFullscreen(cm) {
  27542. var wrap = cm.getWrapperElement();
  27543. cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
  27544. width: wrap.style.width, height: wrap.style.height};
  27545. wrap.style.width = "";
  27546. wrap.style.height = "auto";
  27547. wrap.className += " CodeMirror-fullscreen";
  27548. document.documentElement.style.overflow = "hidden";
  27549. cm.refresh();
  27550. }
  27551. function setNormal(cm) {
  27552. var wrap = cm.getWrapperElement();
  27553. wrap.className = wrap.className.replace(/\s*CodeMirror-fullscreen\b/, "");
  27554. document.documentElement.style.overflow = "";
  27555. var info = cm.state.fullScreenRestore;
  27556. wrap.style.width = info.width; wrap.style.height = info.height;
  27557. window.scrollTo(info.scrollLeft, info.scrollTop);
  27558. cm.refresh();
  27559. }
  27560. });
  27561. /***/ },
  27562. /* 168 */
  27563. /***/ function(module, exports, __webpack_require__) {
  27564. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  27565. // Distributed under an MIT license: http://codemirror.net/LICENSE
  27566. (function(mod) {
  27567. if (true) // CommonJS
  27568. mod(__webpack_require__(164), __webpack_require__(169), __webpack_require__(170));
  27569. else if (typeof define == "function" && define.amd) // AMD
  27570. define(["../../lib/codemirror", "../xml/xml", "../meta"], mod);
  27571. else // Plain browser env
  27572. mod(CodeMirror);
  27573. })(function(CodeMirror) {
  27574. "use strict";
  27575. CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
  27576. var htmlMode = CodeMirror.getMode(cmCfg, "text/html");
  27577. var htmlModeMissing = htmlMode.name == "null"
  27578. function getMode(name) {
  27579. if (CodeMirror.findModeByName) {
  27580. var found = CodeMirror.findModeByName(name);
  27581. if (found) name = found.mime || found.mimes[0];
  27582. }
  27583. var mode = CodeMirror.getMode(cmCfg, name);
  27584. return mode.name == "null" ? null : mode;
  27585. }
  27586. // Should characters that affect highlighting be highlighted separate?
  27587. // Does not include characters that will be output (such as `1.` and `-` for lists)
  27588. if (modeCfg.highlightFormatting === undefined)
  27589. modeCfg.highlightFormatting = false;
  27590. // Maximum number of nested blockquotes. Set to 0 for infinite nesting.
  27591. // Excess `>` will emit `error` token.
  27592. if (modeCfg.maxBlockquoteDepth === undefined)
  27593. modeCfg.maxBlockquoteDepth = 0;
  27594. // Should underscores in words open/close em/strong?
  27595. if (modeCfg.underscoresBreakWords === undefined)
  27596. modeCfg.underscoresBreakWords = true;
  27597. // Use `fencedCodeBlocks` to configure fenced code blocks. false to
  27598. // disable, string to specify a precise regexp that the fence should
  27599. // match, and true to allow three or more backticks or tildes (as
  27600. // per CommonMark).
  27601. // Turn on task lists? ("- [ ] " and "- [x] ")
  27602. if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
  27603. // Turn on strikethrough syntax
  27604. if (modeCfg.strikethrough === undefined)
  27605. modeCfg.strikethrough = false;
  27606. // Allow token types to be overridden by user-provided token types.
  27607. if (modeCfg.tokenTypeOverrides === undefined)
  27608. modeCfg.tokenTypeOverrides = {};
  27609. var tokenTypes = {
  27610. header: "header",
  27611. code: "comment",
  27612. quote: "quote",
  27613. list1: "variable-2",
  27614. list2: "variable-3",
  27615. list3: "keyword",
  27616. hr: "hr",
  27617. image: "image",
  27618. imageAltText: "image-alt-text",
  27619. imageMarker: "image-marker",
  27620. formatting: "formatting",
  27621. linkInline: "link",
  27622. linkEmail: "link",
  27623. linkText: "link",
  27624. linkHref: "string",
  27625. em: "em",
  27626. strong: "strong",
  27627. strikethrough: "strikethrough"
  27628. };
  27629. for (var tokenType in tokenTypes) {
  27630. if (tokenTypes.hasOwnProperty(tokenType) && modeCfg.tokenTypeOverrides[tokenType]) {
  27631. tokenTypes[tokenType] = modeCfg.tokenTypeOverrides[tokenType];
  27632. }
  27633. }
  27634. var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
  27635. , listRE = /^(?:[*\-+]|^[0-9]+([.)]))\s+/
  27636. , taskListRE = /^\[(x| )\](?=\s)/ // Must follow listRE
  27637. , atxHeaderRE = modeCfg.allowAtxHeaderWithoutSpace ? /^(#+)/ : /^(#+)(?: |$)/
  27638. , setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
  27639. , textRE = /^[^#!\[\]*_\\<>` "'(~]+/
  27640. , fencedCodeRE = new RegExp("^(" + (modeCfg.fencedCodeBlocks === true ? "~~~+|```+" : modeCfg.fencedCodeBlocks) +
  27641. ")[ \\t]*([\\w+#\-]*)");
  27642. function switchInline(stream, state, f) {
  27643. state.f = state.inline = f;
  27644. return f(stream, state);
  27645. }
  27646. function switchBlock(stream, state, f) {
  27647. state.f = state.block = f;
  27648. return f(stream, state);
  27649. }
  27650. function lineIsEmpty(line) {
  27651. return !line || !/\S/.test(line.string)
  27652. }
  27653. // Blocks
  27654. function blankLine(state) {
  27655. // Reset linkTitle state
  27656. state.linkTitle = false;
  27657. // Reset EM state
  27658. state.em = false;
  27659. // Reset STRONG state
  27660. state.strong = false;
  27661. // Reset strikethrough state
  27662. state.strikethrough = false;
  27663. // Reset state.quote
  27664. state.quote = 0;
  27665. // Reset state.indentedCode
  27666. state.indentedCode = false;
  27667. if (htmlModeMissing && state.f == htmlBlock) {
  27668. state.f = inlineNormal;
  27669. state.block = blockNormal;
  27670. }
  27671. // Reset state.trailingSpace
  27672. state.trailingSpace = 0;
  27673. state.trailingSpaceNewLine = false;
  27674. // Mark this line as blank
  27675. state.prevLine = state.thisLine
  27676. state.thisLine = null
  27677. return null;
  27678. }
  27679. function blockNormal(stream, state) {
  27680. var sol = stream.sol();
  27681. var prevLineIsList = state.list !== false,
  27682. prevLineIsIndentedCode = state.indentedCode;
  27683. state.indentedCode = false;
  27684. if (prevLineIsList) {
  27685. if (state.indentationDiff >= 0) { // Continued list
  27686. if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
  27687. state.indentation -= state.indentationDiff;
  27688. }
  27689. state.list = null;
  27690. } else if (state.indentation > 0) {
  27691. state.list = null;
  27692. } else { // No longer a list
  27693. state.list = false;
  27694. }
  27695. }
  27696. var match = null;
  27697. if (state.indentationDiff >= 4) {
  27698. stream.skipToEnd();
  27699. if (prevLineIsIndentedCode || lineIsEmpty(state.prevLine)) {
  27700. state.indentation -= 4;
  27701. state.indentedCode = true;
  27702. return tokenTypes.code;
  27703. } else {
  27704. return null;
  27705. }
  27706. } else if (stream.eatSpace()) {
  27707. return null;
  27708. } else if ((match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
  27709. state.header = match[1].length;
  27710. if (modeCfg.highlightFormatting) state.formatting = "header";
  27711. state.f = state.inline;
  27712. return getType(state);
  27713. } else if (!lineIsEmpty(state.prevLine) && !state.quote && !prevLineIsList &&
  27714. !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
  27715. state.header = match[0].charAt(0) == '=' ? 1 : 2;
  27716. if (modeCfg.highlightFormatting) state.formatting = "header";
  27717. state.f = state.inline;
  27718. return getType(state);
  27719. } else if (stream.eat('>')) {
  27720. state.quote = sol ? 1 : state.quote + 1;
  27721. if (modeCfg.highlightFormatting) state.formatting = "quote";
  27722. stream.eatSpace();
  27723. return getType(state);
  27724. } else if (stream.peek() === '[') {
  27725. return switchInline(stream, state, footnoteLink);
  27726. } else if (stream.match(hrRE, true)) {
  27727. state.hr = true;
  27728. return tokenTypes.hr;
  27729. } else if (match = stream.match(listRE)) {
  27730. var listType = match[1] ? "ol" : "ul";
  27731. state.indentation = stream.column() + stream.current().length;
  27732. state.list = true;
  27733. // While this list item's marker's indentation
  27734. // is less than the deepest list item's content's indentation,
  27735. // pop the deepest list item indentation off the stack.
  27736. while (state.listStack && stream.column() < state.listStack[state.listStack.length - 1]) {
  27737. state.listStack.pop();
  27738. }
  27739. // Add this list item's content's indentation to the stack
  27740. state.listStack.push(state.indentation);
  27741. if (modeCfg.taskLists && stream.match(taskListRE, false)) {
  27742. state.taskList = true;
  27743. }
  27744. state.f = state.inline;
  27745. if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
  27746. return getType(state);
  27747. } else if (modeCfg.fencedCodeBlocks && (match = stream.match(fencedCodeRE, true))) {
  27748. state.fencedChars = match[1]
  27749. // try switching mode
  27750. state.localMode = getMode(match[2]);
  27751. if (state.localMode) state.localState = CodeMirror.startState(state.localMode);
  27752. state.f = state.block = local;
  27753. if (modeCfg.highlightFormatting) state.formatting = "code-block";
  27754. state.code = -1
  27755. return getType(state);
  27756. }
  27757. return switchInline(stream, state, state.inline);
  27758. }
  27759. function htmlBlock(stream, state) {
  27760. var style = htmlMode.token(stream, state.htmlState);
  27761. if (!htmlModeMissing) {
  27762. var inner = CodeMirror.innerMode(htmlMode, state.htmlState)
  27763. if ((inner.mode.name == "xml" && inner.state.tagStart === null &&
  27764. (!inner.state.context && inner.state.tokenize.isInText)) ||
  27765. (state.md_inside && stream.current().indexOf(">") > -1)) {
  27766. state.f = inlineNormal;
  27767. state.block = blockNormal;
  27768. state.htmlState = null;
  27769. }
  27770. }
  27771. return style;
  27772. }
  27773. function local(stream, state) {
  27774. if (state.fencedChars && stream.match(state.fencedChars, false)) {
  27775. state.localMode = state.localState = null;
  27776. state.f = state.block = leavingLocal;
  27777. return null;
  27778. } else if (state.localMode) {
  27779. return state.localMode.token(stream, state.localState);
  27780. } else {
  27781. stream.skipToEnd();
  27782. return tokenTypes.code;
  27783. }
  27784. }
  27785. function leavingLocal(stream, state) {
  27786. stream.match(state.fencedChars);
  27787. state.block = blockNormal;
  27788. state.f = inlineNormal;
  27789. state.fencedChars = null;
  27790. if (modeCfg.highlightFormatting) state.formatting = "code-block";
  27791. state.code = 1
  27792. var returnType = getType(state);
  27793. state.code = 0
  27794. return returnType;
  27795. }
  27796. // Inline
  27797. function getType(state) {
  27798. var styles = [];
  27799. if (state.formatting) {
  27800. styles.push(tokenTypes.formatting);
  27801. if (typeof state.formatting === "string") state.formatting = [state.formatting];
  27802. for (var i = 0; i < state.formatting.length; i++) {
  27803. styles.push(tokenTypes.formatting + "-" + state.formatting[i]);
  27804. if (state.formatting[i] === "header") {
  27805. styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.header);
  27806. }
  27807. // Add `formatting-quote` and `formatting-quote-#` for blockquotes
  27808. // Add `error` instead if the maximum blockquote nesting depth is passed
  27809. if (state.formatting[i] === "quote") {
  27810. if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
  27811. styles.push(tokenTypes.formatting + "-" + state.formatting[i] + "-" + state.quote);
  27812. } else {
  27813. styles.push("error");
  27814. }
  27815. }
  27816. }
  27817. }
  27818. if (state.taskOpen) {
  27819. styles.push("meta");
  27820. return styles.length ? styles.join(' ') : null;
  27821. }
  27822. if (state.taskClosed) {
  27823. styles.push("property");
  27824. return styles.length ? styles.join(' ') : null;
  27825. }
  27826. if (state.linkHref) {
  27827. styles.push(tokenTypes.linkHref, "url");
  27828. } else { // Only apply inline styles to non-url text
  27829. if (state.strong) { styles.push(tokenTypes.strong); }
  27830. if (state.em) { styles.push(tokenTypes.em); }
  27831. if (state.strikethrough) { styles.push(tokenTypes.strikethrough); }
  27832. if (state.linkText) { styles.push(tokenTypes.linkText); }
  27833. if (state.code) { styles.push(tokenTypes.code); }
  27834. if (state.image) { styles.push(tokenTypes.image); }
  27835. if (state.imageAltText) { styles.push(tokenTypes.imageAltText, "link"); }
  27836. if (state.imageMarker) { styles.push(tokenTypes.imageMarker); }
  27837. }
  27838. if (state.header) { styles.push(tokenTypes.header, tokenTypes.header + "-" + state.header); }
  27839. if (state.quote) {
  27840. styles.push(tokenTypes.quote);
  27841. // Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
  27842. if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
  27843. styles.push(tokenTypes.quote + "-" + state.quote);
  27844. } else {
  27845. styles.push(tokenTypes.quote + "-" + modeCfg.maxBlockquoteDepth);
  27846. }
  27847. }
  27848. if (state.list !== false) {
  27849. var listMod = (state.listStack.length - 1) % 3;
  27850. if (!listMod) {
  27851. styles.push(tokenTypes.list1);
  27852. } else if (listMod === 1) {
  27853. styles.push(tokenTypes.list2);
  27854. } else {
  27855. styles.push(tokenTypes.list3);
  27856. }
  27857. }
  27858. if (state.trailingSpaceNewLine) {
  27859. styles.push("trailing-space-new-line");
  27860. } else if (state.trailingSpace) {
  27861. styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
  27862. }
  27863. return styles.length ? styles.join(' ') : null;
  27864. }
  27865. function handleText(stream, state) {
  27866. if (stream.match(textRE, true)) {
  27867. return getType(state);
  27868. }
  27869. return undefined;
  27870. }
  27871. function inlineNormal(stream, state) {
  27872. var style = state.text(stream, state);
  27873. if (typeof style !== 'undefined')
  27874. return style;
  27875. if (state.list) { // List marker (*, +, -, 1., etc)
  27876. state.list = null;
  27877. return getType(state);
  27878. }
  27879. if (state.taskList) {
  27880. var taskOpen = stream.match(taskListRE, true)[1] !== "x";
  27881. if (taskOpen) state.taskOpen = true;
  27882. else state.taskClosed = true;
  27883. if (modeCfg.highlightFormatting) state.formatting = "task";
  27884. state.taskList = false;
  27885. return getType(state);
  27886. }
  27887. state.taskOpen = false;
  27888. state.taskClosed = false;
  27889. if (state.header && stream.match(/^#+$/, true)) {
  27890. if (modeCfg.highlightFormatting) state.formatting = "header";
  27891. return getType(state);
  27892. }
  27893. // Get sol() value now, before character is consumed
  27894. var sol = stream.sol();
  27895. var ch = stream.next();
  27896. // Matches link titles present on next line
  27897. if (state.linkTitle) {
  27898. state.linkTitle = false;
  27899. var matchCh = ch;
  27900. if (ch === '(') {
  27901. matchCh = ')';
  27902. }
  27903. matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
  27904. var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
  27905. if (stream.match(new RegExp(regex), true)) {
  27906. return tokenTypes.linkHref;
  27907. }
  27908. }
  27909. // If this block is changed, it may need to be updated in GFM mode
  27910. if (ch === '`') {
  27911. var previousFormatting = state.formatting;
  27912. if (modeCfg.highlightFormatting) state.formatting = "code";
  27913. stream.eatWhile('`');
  27914. var count = stream.current().length
  27915. if (state.code == 0) {
  27916. state.code = count
  27917. return getType(state)
  27918. } else if (count == state.code) { // Must be exact
  27919. var t = getType(state)
  27920. state.code = 0
  27921. return t
  27922. } else {
  27923. state.formatting = previousFormatting
  27924. return getType(state)
  27925. }
  27926. } else if (state.code) {
  27927. return getType(state);
  27928. }
  27929. if (ch === '\\') {
  27930. stream.next();
  27931. if (modeCfg.highlightFormatting) {
  27932. var type = getType(state);
  27933. var formattingEscape = tokenTypes.formatting + "-escape";
  27934. return type ? type + " " + formattingEscape : formattingEscape;
  27935. }
  27936. }
  27937. if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
  27938. state.imageMarker = true;
  27939. state.image = true;
  27940. if (modeCfg.highlightFormatting) state.formatting = "image";
  27941. return getType(state);
  27942. }
  27943. if (ch === '[' && state.imageMarker && stream.match(/[^\]]*\](\(.*?\)| ?\[.*?\])/, false)) {
  27944. state.imageMarker = false;
  27945. state.imageAltText = true
  27946. if (modeCfg.highlightFormatting) state.formatting = "image";
  27947. return getType(state);
  27948. }
  27949. if (ch === ']' && state.imageAltText) {
  27950. if (modeCfg.highlightFormatting) state.formatting = "image";
  27951. var type = getType(state);
  27952. state.imageAltText = false;
  27953. state.image = false;
  27954. state.inline = state.f = linkHref;
  27955. return type;
  27956. }
  27957. if (ch === '[' && stream.match(/[^\]]*\](\(.*\)| ?\[.*?\])/, false) && !state.image) {
  27958. state.linkText = true;
  27959. if (modeCfg.highlightFormatting) state.formatting = "link";
  27960. return getType(state);
  27961. }
  27962. if (ch === ']' && state.linkText && stream.match(/\(.*?\)| ?\[.*?\]/, false)) {
  27963. if (modeCfg.highlightFormatting) state.formatting = "link";
  27964. var type = getType(state);
  27965. state.linkText = false;
  27966. state.inline = state.f = linkHref;
  27967. return type;
  27968. }
  27969. if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
  27970. state.f = state.inline = linkInline;
  27971. if (modeCfg.highlightFormatting) state.formatting = "link";
  27972. var type = getType(state);
  27973. if (type){
  27974. type += " ";
  27975. } else {
  27976. type = "";
  27977. }
  27978. return type + tokenTypes.linkInline;
  27979. }
  27980. if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
  27981. state.f = state.inline = linkInline;
  27982. if (modeCfg.highlightFormatting) state.formatting = "link";
  27983. var type = getType(state);
  27984. if (type){
  27985. type += " ";
  27986. } else {
  27987. type = "";
  27988. }
  27989. return type + tokenTypes.linkEmail;
  27990. }
  27991. if (ch === '<' && stream.match(/^(!--|[a-z]+(?:\s+[a-z_:.\-]+(?:\s*=\s*[^ >]+)?)*\s*>)/i, false)) {
  27992. var end = stream.string.indexOf(">", stream.pos);
  27993. if (end != -1) {
  27994. var atts = stream.string.substring(stream.start, end);
  27995. if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) state.md_inside = true;
  27996. }
  27997. stream.backUp(1);
  27998. state.htmlState = CodeMirror.startState(htmlMode);
  27999. return switchBlock(stream, state, htmlBlock);
  28000. }
  28001. if (ch === '<' && stream.match(/^\/\w*?>/)) {
  28002. state.md_inside = false;
  28003. return "tag";
  28004. }
  28005. var ignoreUnderscore = false;
  28006. if (!modeCfg.underscoresBreakWords) {
  28007. if (ch === '_' && stream.peek() !== '_' && stream.match(/(\w)/, false)) {
  28008. var prevPos = stream.pos - 2;
  28009. if (prevPos >= 0) {
  28010. var prevCh = stream.string.charAt(prevPos);
  28011. if (prevCh !== '_' && prevCh.match(/(\w)/, false)) {
  28012. ignoreUnderscore = true;
  28013. }
  28014. }
  28015. }
  28016. }
  28017. if (ch === '*' || (ch === '_' && !ignoreUnderscore)) {
  28018. if (sol && stream.peek() === ' ') {
  28019. // Do nothing, surrounded by newline and space
  28020. } else if (state.strong === ch && stream.eat(ch)) { // Remove STRONG
  28021. if (modeCfg.highlightFormatting) state.formatting = "strong";
  28022. var t = getType(state);
  28023. state.strong = false;
  28024. return t;
  28025. } else if (!state.strong && stream.eat(ch)) { // Add STRONG
  28026. state.strong = ch;
  28027. if (modeCfg.highlightFormatting) state.formatting = "strong";
  28028. return getType(state);
  28029. } else if (state.em === ch) { // Remove EM
  28030. if (modeCfg.highlightFormatting) state.formatting = "em";
  28031. var t = getType(state);
  28032. state.em = false;
  28033. return t;
  28034. } else if (!state.em) { // Add EM
  28035. state.em = ch;
  28036. if (modeCfg.highlightFormatting) state.formatting = "em";
  28037. return getType(state);
  28038. }
  28039. } else if (ch === ' ') {
  28040. if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces
  28041. if (stream.peek() === ' ') { // Surrounded by spaces, ignore
  28042. return getType(state);
  28043. } else { // Not surrounded by spaces, back up pointer
  28044. stream.backUp(1);
  28045. }
  28046. }
  28047. }
  28048. if (modeCfg.strikethrough) {
  28049. if (ch === '~' && stream.eatWhile(ch)) {
  28050. if (state.strikethrough) {// Remove strikethrough
  28051. if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
  28052. var t = getType(state);
  28053. state.strikethrough = false;
  28054. return t;
  28055. } else if (stream.match(/^[^\s]/, false)) {// Add strikethrough
  28056. state.strikethrough = true;
  28057. if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
  28058. return getType(state);
  28059. }
  28060. } else if (ch === ' ') {
  28061. if (stream.match(/^~~/, true)) { // Probably surrounded by space
  28062. if (stream.peek() === ' ') { // Surrounded by spaces, ignore
  28063. return getType(state);
  28064. } else { // Not surrounded by spaces, back up pointer
  28065. stream.backUp(2);
  28066. }
  28067. }
  28068. }
  28069. }
  28070. if (ch === ' ') {
  28071. if (stream.match(/ +$/, false)) {
  28072. state.trailingSpace++;
  28073. } else if (state.trailingSpace) {
  28074. state.trailingSpaceNewLine = true;
  28075. }
  28076. }
  28077. return getType(state);
  28078. }
  28079. function linkInline(stream, state) {
  28080. var ch = stream.next();
  28081. if (ch === ">") {
  28082. state.f = state.inline = inlineNormal;
  28083. if (modeCfg.highlightFormatting) state.formatting = "link";
  28084. var type = getType(state);
  28085. if (type){
  28086. type += " ";
  28087. } else {
  28088. type = "";
  28089. }
  28090. return type + tokenTypes.linkInline;
  28091. }
  28092. stream.match(/^[^>]+/, true);
  28093. return tokenTypes.linkInline;
  28094. }
  28095. function linkHref(stream, state) {
  28096. // Check if space, and return NULL if so (to avoid marking the space)
  28097. if(stream.eatSpace()){
  28098. return null;
  28099. }
  28100. var ch = stream.next();
  28101. if (ch === '(' || ch === '[') {
  28102. state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]", 0);
  28103. if (modeCfg.highlightFormatting) state.formatting = "link-string";
  28104. state.linkHref = true;
  28105. return getType(state);
  28106. }
  28107. return 'error';
  28108. }
  28109. var linkRE = {
  28110. ")": /^(?:[^\\\(\)]|\\.|\((?:[^\\\(\)]|\\.)*\))*?(?=\))/,
  28111. "]": /^(?:[^\\\[\]]|\\.|\[(?:[^\\\[\\]]|\\.)*\])*?(?=\])/
  28112. }
  28113. function getLinkHrefInside(endChar) {
  28114. return function(stream, state) {
  28115. var ch = stream.next();
  28116. if (ch === endChar) {
  28117. state.f = state.inline = inlineNormal;
  28118. if (modeCfg.highlightFormatting) state.formatting = "link-string";
  28119. var returnState = getType(state);
  28120. state.linkHref = false;
  28121. return returnState;
  28122. }
  28123. stream.match(linkRE[endChar])
  28124. state.linkHref = true;
  28125. return getType(state);
  28126. };
  28127. }
  28128. function footnoteLink(stream, state) {
  28129. if (stream.match(/^([^\]\\]|\\.)*\]:/, false)) {
  28130. state.f = footnoteLinkInside;
  28131. stream.next(); // Consume [
  28132. if (modeCfg.highlightFormatting) state.formatting = "link";
  28133. state.linkText = true;
  28134. return getType(state);
  28135. }
  28136. return switchInline(stream, state, inlineNormal);
  28137. }
  28138. function footnoteLinkInside(stream, state) {
  28139. if (stream.match(/^\]:/, true)) {
  28140. state.f = state.inline = footnoteUrl;
  28141. if (modeCfg.highlightFormatting) state.formatting = "link";
  28142. var returnType = getType(state);
  28143. state.linkText = false;
  28144. return returnType;
  28145. }
  28146. stream.match(/^([^\]\\]|\\.)+/, true);
  28147. return tokenTypes.linkText;
  28148. }
  28149. function footnoteUrl(stream, state) {
  28150. // Check if space, and return NULL if so (to avoid marking the space)
  28151. if(stream.eatSpace()){
  28152. return null;
  28153. }
  28154. // Match URL
  28155. stream.match(/^[^\s]+/, true);
  28156. // Check for link title
  28157. if (stream.peek() === undefined) { // End of line, set flag to check next line
  28158. state.linkTitle = true;
  28159. } else { // More content on line, check if link title
  28160. stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
  28161. }
  28162. state.f = state.inline = inlineNormal;
  28163. return tokenTypes.linkHref + " url";
  28164. }
  28165. var mode = {
  28166. startState: function() {
  28167. return {
  28168. f: blockNormal,
  28169. prevLine: null,
  28170. thisLine: null,
  28171. block: blockNormal,
  28172. htmlState: null,
  28173. indentation: 0,
  28174. inline: inlineNormal,
  28175. text: handleText,
  28176. formatting: false,
  28177. linkText: false,
  28178. linkHref: false,
  28179. linkTitle: false,
  28180. code: 0,
  28181. em: false,
  28182. strong: false,
  28183. header: 0,
  28184. hr: false,
  28185. taskList: false,
  28186. list: false,
  28187. listStack: [],
  28188. quote: 0,
  28189. trailingSpace: 0,
  28190. trailingSpaceNewLine: false,
  28191. strikethrough: false,
  28192. fencedChars: null
  28193. };
  28194. },
  28195. copyState: function(s) {
  28196. return {
  28197. f: s.f,
  28198. prevLine: s.prevLine,
  28199. thisLine: s.thisLine,
  28200. block: s.block,
  28201. htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
  28202. indentation: s.indentation,
  28203. localMode: s.localMode,
  28204. localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null,
  28205. inline: s.inline,
  28206. text: s.text,
  28207. formatting: false,
  28208. linkTitle: s.linkTitle,
  28209. code: s.code,
  28210. em: s.em,
  28211. strong: s.strong,
  28212. strikethrough: s.strikethrough,
  28213. header: s.header,
  28214. hr: s.hr,
  28215. taskList: s.taskList,
  28216. list: s.list,
  28217. listStack: s.listStack.slice(0),
  28218. quote: s.quote,
  28219. indentedCode: s.indentedCode,
  28220. trailingSpace: s.trailingSpace,
  28221. trailingSpaceNewLine: s.trailingSpaceNewLine,
  28222. md_inside: s.md_inside,
  28223. fencedChars: s.fencedChars
  28224. };
  28225. },
  28226. token: function(stream, state) {
  28227. // Reset state.formatting
  28228. state.formatting = false;
  28229. if (stream != state.thisLine) {
  28230. var forceBlankLine = state.header || state.hr;
  28231. // Reset state.header and state.hr
  28232. state.header = 0;
  28233. state.hr = false;
  28234. if (stream.match(/^\s*$/, true) || forceBlankLine) {
  28235. blankLine(state);
  28236. if (!forceBlankLine) return null
  28237. state.prevLine = null
  28238. }
  28239. state.prevLine = state.thisLine
  28240. state.thisLine = stream
  28241. // Reset state.taskList
  28242. state.taskList = false;
  28243. // Reset state.trailingSpace
  28244. state.trailingSpace = 0;
  28245. state.trailingSpaceNewLine = false;
  28246. state.f = state.block;
  28247. var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
  28248. state.indentationDiff = Math.min(indentation - state.indentation, 4);
  28249. state.indentation = state.indentation + state.indentationDiff;
  28250. if (indentation > 0) return null;
  28251. }
  28252. return state.f(stream, state);
  28253. },
  28254. innerMode: function(state) {
  28255. if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode};
  28256. if (state.localState) return {state: state.localState, mode: state.localMode};
  28257. return {state: state, mode: mode};
  28258. },
  28259. blankLine: blankLine,
  28260. getType: getType,
  28261. closeBrackets: "()[]{}''\"\"``",
  28262. fold: "markdown"
  28263. };
  28264. return mode;
  28265. }, "xml");
  28266. CodeMirror.defineMIME("text/x-markdown", "markdown");
  28267. });
  28268. /***/ },
  28269. /* 169 */
  28270. /***/ function(module, exports, __webpack_require__) {
  28271. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  28272. // Distributed under an MIT license: http://codemirror.net/LICENSE
  28273. (function(mod) {
  28274. if (true) // CommonJS
  28275. mod(__webpack_require__(164));
  28276. else if (typeof define == "function" && define.amd) // AMD
  28277. define(["../../lib/codemirror"], mod);
  28278. else // Plain browser env
  28279. mod(CodeMirror);
  28280. })(function(CodeMirror) {
  28281. "use strict";
  28282. var htmlConfig = {
  28283. autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
  28284. 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
  28285. 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
  28286. 'track': true, 'wbr': true, 'menuitem': true},
  28287. implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
  28288. 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
  28289. 'th': true, 'tr': true},
  28290. contextGrabbers: {
  28291. 'dd': {'dd': true, 'dt': true},
  28292. 'dt': {'dd': true, 'dt': true},
  28293. 'li': {'li': true},
  28294. 'option': {'option': true, 'optgroup': true},
  28295. 'optgroup': {'optgroup': true},
  28296. 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
  28297. 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
  28298. 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
  28299. 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
  28300. 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
  28301. 'rp': {'rp': true, 'rt': true},
  28302. 'rt': {'rp': true, 'rt': true},
  28303. 'tbody': {'tbody': true, 'tfoot': true},
  28304. 'td': {'td': true, 'th': true},
  28305. 'tfoot': {'tbody': true},
  28306. 'th': {'td': true, 'th': true},
  28307. 'thead': {'tbody': true, 'tfoot': true},
  28308. 'tr': {'tr': true}
  28309. },
  28310. doNotIndent: {"pre": true},
  28311. allowUnquoted: true,
  28312. allowMissing: true,
  28313. caseFold: true
  28314. }
  28315. var xmlConfig = {
  28316. autoSelfClosers: {},
  28317. implicitlyClosed: {},
  28318. contextGrabbers: {},
  28319. doNotIndent: {},
  28320. allowUnquoted: false,
  28321. allowMissing: false,
  28322. caseFold: false
  28323. }
  28324. CodeMirror.defineMode("xml", function(editorConf, config_) {
  28325. var indentUnit = editorConf.indentUnit
  28326. var config = {}
  28327. var defaults = config_.htmlMode ? htmlConfig : xmlConfig
  28328. for (var prop in defaults) config[prop] = defaults[prop]
  28329. for (var prop in config_) config[prop] = config_[prop]
  28330. // Return variables for tokenizers
  28331. var type, setStyle;
  28332. function inText(stream, state) {
  28333. function chain(parser) {
  28334. state.tokenize = parser;
  28335. return parser(stream, state);
  28336. }
  28337. var ch = stream.next();
  28338. if (ch == "<") {
  28339. if (stream.eat("!")) {
  28340. if (stream.eat("[")) {
  28341. if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
  28342. else return null;
  28343. } else if (stream.match("--")) {
  28344. return chain(inBlock("comment", "-->"));
  28345. } else if (stream.match("DOCTYPE", true, true)) {
  28346. stream.eatWhile(/[\w\._\-]/);
  28347. return chain(doctype(1));
  28348. } else {
  28349. return null;
  28350. }
  28351. } else if (stream.eat("?")) {
  28352. stream.eatWhile(/[\w\._\-]/);
  28353. state.tokenize = inBlock("meta", "?>");
  28354. return "meta";
  28355. } else {
  28356. type = stream.eat("/") ? "closeTag" : "openTag";
  28357. state.tokenize = inTag;
  28358. return "tag bracket";
  28359. }
  28360. } else if (ch == "&") {
  28361. var ok;
  28362. if (stream.eat("#")) {
  28363. if (stream.eat("x")) {
  28364. ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
  28365. } else {
  28366. ok = stream.eatWhile(/[\d]/) && stream.eat(";");
  28367. }
  28368. } else {
  28369. ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
  28370. }
  28371. return ok ? "atom" : "error";
  28372. } else {
  28373. stream.eatWhile(/[^&<]/);
  28374. return null;
  28375. }
  28376. }
  28377. inText.isInText = true;
  28378. function inTag(stream, state) {
  28379. var ch = stream.next();
  28380. if (ch == ">" || (ch == "/" && stream.eat(">"))) {
  28381. state.tokenize = inText;
  28382. type = ch == ">" ? "endTag" : "selfcloseTag";
  28383. return "tag bracket";
  28384. } else if (ch == "=") {
  28385. type = "equals";
  28386. return null;
  28387. } else if (ch == "<") {
  28388. state.tokenize = inText;
  28389. state.state = baseState;
  28390. state.tagName = state.tagStart = null;
  28391. var next = state.tokenize(stream, state);
  28392. return next ? next + " tag error" : "tag error";
  28393. } else if (/[\'\"]/.test(ch)) {
  28394. state.tokenize = inAttribute(ch);
  28395. state.stringStartCol = stream.column();
  28396. return state.tokenize(stream, state);
  28397. } else {
  28398. stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
  28399. return "word";
  28400. }
  28401. }
  28402. function inAttribute(quote) {
  28403. var closure = function(stream, state) {
  28404. while (!stream.eol()) {
  28405. if (stream.next() == quote) {
  28406. state.tokenize = inTag;
  28407. break;
  28408. }
  28409. }
  28410. return "string";
  28411. };
  28412. closure.isInAttribute = true;
  28413. return closure;
  28414. }
  28415. function inBlock(style, terminator) {
  28416. return function(stream, state) {
  28417. while (!stream.eol()) {
  28418. if (stream.match(terminator)) {
  28419. state.tokenize = inText;
  28420. break;
  28421. }
  28422. stream.next();
  28423. }
  28424. return style;
  28425. };
  28426. }
  28427. function doctype(depth) {
  28428. return function(stream, state) {
  28429. var ch;
  28430. while ((ch = stream.next()) != null) {
  28431. if (ch == "<") {
  28432. state.tokenize = doctype(depth + 1);
  28433. return state.tokenize(stream, state);
  28434. } else if (ch == ">") {
  28435. if (depth == 1) {
  28436. state.tokenize = inText;
  28437. break;
  28438. } else {
  28439. state.tokenize = doctype(depth - 1);
  28440. return state.tokenize(stream, state);
  28441. }
  28442. }
  28443. }
  28444. return "meta";
  28445. };
  28446. }
  28447. function Context(state, tagName, startOfLine) {
  28448. this.prev = state.context;
  28449. this.tagName = tagName;
  28450. this.indent = state.indented;
  28451. this.startOfLine = startOfLine;
  28452. if (config.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
  28453. this.noIndent = true;
  28454. }
  28455. function popContext(state) {
  28456. if (state.context) state.context = state.context.prev;
  28457. }
  28458. function maybePopContext(state, nextTagName) {
  28459. var parentTagName;
  28460. while (true) {
  28461. if (!state.context) {
  28462. return;
  28463. }
  28464. parentTagName = state.context.tagName;
  28465. if (!config.contextGrabbers.hasOwnProperty(parentTagName) ||
  28466. !config.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
  28467. return;
  28468. }
  28469. popContext(state);
  28470. }
  28471. }
  28472. function baseState(type, stream, state) {
  28473. if (type == "openTag") {
  28474. state.tagStart = stream.column();
  28475. return tagNameState;
  28476. } else if (type == "closeTag") {
  28477. return closeTagNameState;
  28478. } else {
  28479. return baseState;
  28480. }
  28481. }
  28482. function tagNameState(type, stream, state) {
  28483. if (type == "word") {
  28484. state.tagName = stream.current();
  28485. setStyle = "tag";
  28486. return attrState;
  28487. } else {
  28488. setStyle = "error";
  28489. return tagNameState;
  28490. }
  28491. }
  28492. function closeTagNameState(type, stream, state) {
  28493. if (type == "word") {
  28494. var tagName = stream.current();
  28495. if (state.context && state.context.tagName != tagName &&
  28496. config.implicitlyClosed.hasOwnProperty(state.context.tagName))
  28497. popContext(state);
  28498. if ((state.context && state.context.tagName == tagName) || config.matchClosing === false) {
  28499. setStyle = "tag";
  28500. return closeState;
  28501. } else {
  28502. setStyle = "tag error";
  28503. return closeStateErr;
  28504. }
  28505. } else {
  28506. setStyle = "error";
  28507. return closeStateErr;
  28508. }
  28509. }
  28510. function closeState(type, _stream, state) {
  28511. if (type != "endTag") {
  28512. setStyle = "error";
  28513. return closeState;
  28514. }
  28515. popContext(state);
  28516. return baseState;
  28517. }
  28518. function closeStateErr(type, stream, state) {
  28519. setStyle = "error";
  28520. return closeState(type, stream, state);
  28521. }
  28522. function attrState(type, _stream, state) {
  28523. if (type == "word") {
  28524. setStyle = "attribute";
  28525. return attrEqState;
  28526. } else if (type == "endTag" || type == "selfcloseTag") {
  28527. var tagName = state.tagName, tagStart = state.tagStart;
  28528. state.tagName = state.tagStart = null;
  28529. if (type == "selfcloseTag" ||
  28530. config.autoSelfClosers.hasOwnProperty(tagName)) {
  28531. maybePopContext(state, tagName);
  28532. } else {
  28533. maybePopContext(state, tagName);
  28534. state.context = new Context(state, tagName, tagStart == state.indented);
  28535. }
  28536. return baseState;
  28537. }
  28538. setStyle = "error";
  28539. return attrState;
  28540. }
  28541. function attrEqState(type, stream, state) {
  28542. if (type == "equals") return attrValueState;
  28543. if (!config.allowMissing) setStyle = "error";
  28544. return attrState(type, stream, state);
  28545. }
  28546. function attrValueState(type, stream, state) {
  28547. if (type == "string") return attrContinuedState;
  28548. if (type == "word" && config.allowUnquoted) {setStyle = "string"; return attrState;}
  28549. setStyle = "error";
  28550. return attrState(type, stream, state);
  28551. }
  28552. function attrContinuedState(type, stream, state) {
  28553. if (type == "string") return attrContinuedState;
  28554. return attrState(type, stream, state);
  28555. }
  28556. return {
  28557. startState: function(baseIndent) {
  28558. var state = {tokenize: inText,
  28559. state: baseState,
  28560. indented: baseIndent || 0,
  28561. tagName: null, tagStart: null,
  28562. context: null}
  28563. if (baseIndent != null) state.baseIndent = baseIndent
  28564. return state
  28565. },
  28566. token: function(stream, state) {
  28567. if (!state.tagName && stream.sol())
  28568. state.indented = stream.indentation();
  28569. if (stream.eatSpace()) return null;
  28570. type = null;
  28571. var style = state.tokenize(stream, state);
  28572. if ((style || type) && style != "comment") {
  28573. setStyle = null;
  28574. state.state = state.state(type || style, stream, state);
  28575. if (setStyle)
  28576. style = setStyle == "error" ? style + " error" : setStyle;
  28577. }
  28578. return style;
  28579. },
  28580. indent: function(state, textAfter, fullLine) {
  28581. var context = state.context;
  28582. // Indent multi-line strings (e.g. css).
  28583. if (state.tokenize.isInAttribute) {
  28584. if (state.tagStart == state.indented)
  28585. return state.stringStartCol + 1;
  28586. else
  28587. return state.indented + indentUnit;
  28588. }
  28589. if (context && context.noIndent) return CodeMirror.Pass;
  28590. if (state.tokenize != inTag && state.tokenize != inText)
  28591. return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
  28592. // Indent the starts of attribute names.
  28593. if (state.tagName) {
  28594. if (config.multilineTagIndentPastTag !== false)
  28595. return state.tagStart + state.tagName.length + 2;
  28596. else
  28597. return state.tagStart + indentUnit * (config.multilineTagIndentFactor || 1);
  28598. }
  28599. if (config.alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
  28600. var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
  28601. if (tagAfter && tagAfter[1]) { // Closing tag spotted
  28602. while (context) {
  28603. if (context.tagName == tagAfter[2]) {
  28604. context = context.prev;
  28605. break;
  28606. } else if (config.implicitlyClosed.hasOwnProperty(context.tagName)) {
  28607. context = context.prev;
  28608. } else {
  28609. break;
  28610. }
  28611. }
  28612. } else if (tagAfter) { // Opening tag spotted
  28613. while (context) {
  28614. var grabbers = config.contextGrabbers[context.tagName];
  28615. if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
  28616. context = context.prev;
  28617. else
  28618. break;
  28619. }
  28620. }
  28621. while (context && context.prev && !context.startOfLine)
  28622. context = context.prev;
  28623. if (context) return context.indent + indentUnit;
  28624. else return state.baseIndent || 0;
  28625. },
  28626. electricInput: /<\/[\s\w:]+>$/,
  28627. blockCommentStart: "<!--",
  28628. blockCommentEnd: "-->",
  28629. configuration: config.htmlMode ? "html" : "xml",
  28630. helperType: config.htmlMode ? "html" : "xml",
  28631. skipAttribute: function(state) {
  28632. if (state.state == attrValueState)
  28633. state.state = attrState
  28634. }
  28635. };
  28636. });
  28637. CodeMirror.defineMIME("text/xml", "xml");
  28638. CodeMirror.defineMIME("application/xml", "xml");
  28639. if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
  28640. CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
  28641. });
  28642. /***/ },
  28643. /* 170 */
  28644. /***/ function(module, exports, __webpack_require__) {
  28645. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  28646. // Distributed under an MIT license: http://codemirror.net/LICENSE
  28647. (function(mod) {
  28648. if (true) // CommonJS
  28649. mod(__webpack_require__(164));
  28650. else if (typeof define == "function" && define.amd) // AMD
  28651. define(["../lib/codemirror"], mod);
  28652. else // Plain browser env
  28653. mod(CodeMirror);
  28654. })(function(CodeMirror) {
  28655. "use strict";
  28656. CodeMirror.modeInfo = [
  28657. {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
  28658. {name: "PGP", mimes: ["application/pgp", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["pgp"]},
  28659. {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]},
  28660. {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i},
  28661. {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]},
  28662. {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h"]},
  28663. {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
  28664. {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
  28665. {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]},
  28666. {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
  28667. {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
  28668. {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
  28669. {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/},
  28670. {name: "CoffeeScript", mime: "text/x-coffeescript", mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
  28671. {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
  28672. {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
  28673. {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
  28674. {name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]},
  28675. {name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
  28676. {name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
  28677. {name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
  28678. {name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"]},
  28679. {name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
  28680. {name: "Django", mime: "text/x-django", mode: "django"},
  28681. {name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile", file: /^Dockerfile$/},
  28682. {name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
  28683. {name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
  28684. {name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"},
  28685. {name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
  28686. {name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]},
  28687. {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
  28688. {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]},
  28689. {name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
  28690. {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
  28691. {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
  28692. {name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]},
  28693. {name: "FCL", mime: "text/x-fcl", mode: "fcl"},
  28694. {name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
  28695. {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
  28696. {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
  28697. {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
  28698. {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
  28699. {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
  28700. {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
  28701. {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
  28702. {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
  28703. {name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
  28704. {name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
  28705. {name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
  28706. {name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
  28707. {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
  28708. {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm"], alias: ["xhtml"]},
  28709. {name: "HTTP", mime: "message/http", mode: "http"},
  28710. {name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
  28711. {name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
  28712. {name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
  28713. {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
  28714. {name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
  28715. mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
  28716. {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
  28717. {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
  28718. {name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
  28719. {name: "Jinja2", mime: "null", mode: "jinja2"},
  28720. {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
  28721. {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
  28722. {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
  28723. {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
  28724. {name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
  28725. {name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]},
  28726. {name: "mIRC", mime: "text/mirc", mode: "mirc"},
  28727. {name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
  28728. {name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb"]},
  28729. {name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
  28730. {name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]},
  28731. {name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
  28732. {name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"]},
  28733. {name: "MySQL", mime: "text/x-mysql", mode: "sql"},
  28734. {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i},
  28735. {name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]},
  28736. {name: "NTriples", mime: "text/n-triples", mode: "ntriples", ext: ["nt"]},
  28737. {name: "Objective C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"], alias: ["objective-c", "objc"]},
  28738. {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
  28739. {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
  28740. {name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]},
  28741. {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
  28742. {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]},
  28743. {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
  28744. {name: "PHP", mime: "application/x-httpd-php", mode: "php", ext: ["php", "php3", "php4", "php5", "phtml"]},
  28745. {name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]},
  28746. {name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
  28747. {name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]},
  28748. {name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]},
  28749. {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
  28750. {name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]},
  28751. {name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/},
  28752. {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
  28753. {name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
  28754. {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r", "R"], alias: ["rscript"]},
  28755. {name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]},
  28756. {name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"},
  28757. {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]},
  28758. {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]},
  28759. {name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
  28760. {name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"]},
  28761. {name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
  28762. {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
  28763. {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
  28764. {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
  28765. {name: "Shell", mime: "text/x-sh", mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/},
  28766. {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]},
  28767. {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]},
  28768. {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
  28769. {name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
  28770. {name: "Solr", mime: "text/x-solr", mode: "solr"},
  28771. {name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]},
  28772. {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]},
  28773. {name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]},
  28774. {name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
  28775. {name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]},
  28776. {name: "Stylus", mime: "text/x-styl", mode: "stylus", ext: ["styl"]},
  28777. {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]},
  28778. {name: "sTeX", mime: "text/x-stex", mode: "stex"},
  28779. {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx"], alias: ["tex"]},
  28780. {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v"]},
  28781. {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
  28782. {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]},
  28783. {name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
  28784. {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
  28785. {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]},
  28786. {name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
  28787. {name: "troff", mime: "text/troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]},
  28788. {name: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"]},
  28789. {name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"]},
  28790. {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
  28791. {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]},
  28792. {name: "Twig", mime: "text/x-twig", mode: "twig"},
  28793. {name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"]},
  28794. {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
  28795. {name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]},
  28796. {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
  28797. {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
  28798. {name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]},
  28799. {name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"]},
  28800. {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd", "svg"], alias: ["rss", "wsdl", "xsd"]},
  28801. {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
  28802. {name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]},
  28803. {name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]},
  28804. {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
  28805. {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
  28806. {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
  28807. {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}
  28808. ];
  28809. // Ensure all modes have a mime property for backwards compatibility
  28810. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  28811. var info = CodeMirror.modeInfo[i];
  28812. if (info.mimes) info.mime = info.mimes[0];
  28813. }
  28814. CodeMirror.findModeByMIME = function(mime) {
  28815. mime = mime.toLowerCase();
  28816. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  28817. var info = CodeMirror.modeInfo[i];
  28818. if (info.mime == mime) return info;
  28819. if (info.mimes) for (var j = 0; j < info.mimes.length; j++)
  28820. if (info.mimes[j] == mime) return info;
  28821. }
  28822. if (/\+xml$/.test(mime)) return CodeMirror.findModeByMIME("application/xml")
  28823. if (/\+json$/.test(mime)) return CodeMirror.findModeByMIME("application/json")
  28824. };
  28825. CodeMirror.findModeByExtension = function(ext) {
  28826. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  28827. var info = CodeMirror.modeInfo[i];
  28828. if (info.ext) for (var j = 0; j < info.ext.length; j++)
  28829. if (info.ext[j] == ext) return info;
  28830. }
  28831. };
  28832. CodeMirror.findModeByFileName = function(filename) {
  28833. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  28834. var info = CodeMirror.modeInfo[i];
  28835. if (info.file && info.file.test(filename)) return info;
  28836. }
  28837. var dot = filename.lastIndexOf(".");
  28838. var ext = dot > -1 && filename.substring(dot + 1, filename.length);
  28839. if (ext) return CodeMirror.findModeByExtension(ext);
  28840. };
  28841. CodeMirror.findModeByName = function(name) {
  28842. name = name.toLowerCase();
  28843. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  28844. var info = CodeMirror.modeInfo[i];
  28845. if (info.name.toLowerCase() == name) return info;
  28846. if (info.alias) for (var j = 0; j < info.alias.length; j++)
  28847. if (info.alias[j].toLowerCase() == name) return info;
  28848. }
  28849. };
  28850. });
  28851. /***/ },
  28852. /* 171 */
  28853. /***/ function(module, exports, __webpack_require__) {
  28854. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  28855. // Distributed under an MIT license: http://codemirror.net/LICENSE
  28856. // Utility function that allows modes to be combined. The mode given
  28857. // as the base argument takes care of most of the normal mode
  28858. // functionality, but a second (typically simple) mode is used, which
  28859. // can override the style of text. Both modes get to parse all of the
  28860. // text, but when both assign a non-null style to a piece of code, the
  28861. // overlay wins, unless the combine argument was true and not overridden,
  28862. // or state.overlay.combineTokens was true, in which case the styles are
  28863. // combined.
  28864. (function(mod) {
  28865. if (true) // CommonJS
  28866. mod(__webpack_require__(164));
  28867. else if (typeof define == "function" && define.amd) // AMD
  28868. define(["../../lib/codemirror"], mod);
  28869. else // Plain browser env
  28870. mod(CodeMirror);
  28871. })(function(CodeMirror) {
  28872. "use strict";
  28873. CodeMirror.overlayMode = function(base, overlay, combine) {
  28874. return {
  28875. startState: function() {
  28876. return {
  28877. base: CodeMirror.startState(base),
  28878. overlay: CodeMirror.startState(overlay),
  28879. basePos: 0, baseCur: null,
  28880. overlayPos: 0, overlayCur: null,
  28881. streamSeen: null
  28882. };
  28883. },
  28884. copyState: function(state) {
  28885. return {
  28886. base: CodeMirror.copyState(base, state.base),
  28887. overlay: CodeMirror.copyState(overlay, state.overlay),
  28888. basePos: state.basePos, baseCur: null,
  28889. overlayPos: state.overlayPos, overlayCur: null
  28890. };
  28891. },
  28892. token: function(stream, state) {
  28893. if (stream != state.streamSeen ||
  28894. Math.min(state.basePos, state.overlayPos) < stream.start) {
  28895. state.streamSeen = stream;
  28896. state.basePos = state.overlayPos = stream.start;
  28897. }
  28898. if (stream.start == state.basePos) {
  28899. state.baseCur = base.token(stream, state.base);
  28900. state.basePos = stream.pos;
  28901. }
  28902. if (stream.start == state.overlayPos) {
  28903. stream.pos = stream.start;
  28904. state.overlayCur = overlay.token(stream, state.overlay);
  28905. state.overlayPos = stream.pos;
  28906. }
  28907. stream.pos = Math.min(state.basePos, state.overlayPos);
  28908. // state.overlay.combineTokens always takes precedence over combine,
  28909. // unless set to null
  28910. if (state.overlayCur == null) return state.baseCur;
  28911. else if (state.baseCur != null &&
  28912. state.overlay.combineTokens ||
  28913. combine && state.overlay.combineTokens == null)
  28914. return state.baseCur + " " + state.overlayCur;
  28915. else return state.overlayCur;
  28916. },
  28917. indent: base.indent && function(state, textAfter) {
  28918. return base.indent(state.base, textAfter);
  28919. },
  28920. electricChars: base.electricChars,
  28921. innerMode: function(state) { return {state: state.base, mode: base}; },
  28922. blankLine: function(state) {
  28923. var baseToken, overlayToken;
  28924. if (base.blankLine) baseToken = base.blankLine(state.base);
  28925. if (overlay.blankLine) overlayToken = overlay.blankLine(state.overlay);
  28926. return overlayToken == null ?
  28927. baseToken :
  28928. (combine && baseToken != null ? baseToken + " " + overlayToken : overlayToken);
  28929. }
  28930. };
  28931. };
  28932. });
  28933. /***/ },
  28934. /* 172 */
  28935. /***/ function(module, exports, __webpack_require__) {
  28936. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  28937. // Distributed under an MIT license: http://codemirror.net/LICENSE
  28938. (function(mod) {
  28939. if (true) // CommonJS
  28940. mod(__webpack_require__(164));
  28941. else if (typeof define == "function" && define.amd) // AMD
  28942. define(["../../lib/codemirror"], mod);
  28943. else // Plain browser env
  28944. mod(CodeMirror);
  28945. })(function(CodeMirror) {
  28946. CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
  28947. var prev = old && old != CodeMirror.Init;
  28948. if (val && !prev) {
  28949. cm.on("blur", onBlur);
  28950. cm.on("change", onChange);
  28951. cm.on("swapDoc", onChange);
  28952. onChange(cm);
  28953. } else if (!val && prev) {
  28954. cm.off("blur", onBlur);
  28955. cm.off("change", onChange);
  28956. cm.off("swapDoc", onChange);
  28957. clearPlaceholder(cm);
  28958. var wrapper = cm.getWrapperElement();
  28959. wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
  28960. }
  28961. if (val && !cm.hasFocus()) onBlur(cm);
  28962. });
  28963. function clearPlaceholder(cm) {
  28964. if (cm.state.placeholder) {
  28965. cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
  28966. cm.state.placeholder = null;
  28967. }
  28968. }
  28969. function setPlaceholder(cm) {
  28970. clearPlaceholder(cm);
  28971. var elt = cm.state.placeholder = document.createElement("pre");
  28972. elt.style.cssText = "height: 0; overflow: visible";
  28973. elt.className = "CodeMirror-placeholder";
  28974. var placeHolder = cm.getOption("placeholder")
  28975. if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
  28976. elt.appendChild(placeHolder)
  28977. cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
  28978. }
  28979. function onBlur(cm) {
  28980. if (isEmpty(cm)) setPlaceholder(cm);
  28981. }
  28982. function onChange(cm) {
  28983. var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
  28984. wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
  28985. if (empty) setPlaceholder(cm);
  28986. else clearPlaceholder(cm);
  28987. }
  28988. function isEmpty(cm) {
  28989. return (cm.lineCount() === 1) && (cm.getLine(0) === "");
  28990. }
  28991. });
  28992. /***/ },
  28993. /* 173 */
  28994. /***/ function(module, exports, __webpack_require__) {
  28995. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  28996. // Distributed under an MIT license: http://codemirror.net/LICENSE
  28997. // Because sometimes you need to mark the selected *text*.
  28998. //
  28999. // Adds an option 'styleSelectedText' which, when enabled, gives
  29000. // selected text the CSS class given as option value, or
  29001. // "CodeMirror-selectedtext" when the value is not a string.
  29002. (function(mod) {
  29003. if (true) // CommonJS
  29004. mod(__webpack_require__(164));
  29005. else if (typeof define == "function" && define.amd) // AMD
  29006. define(["../../lib/codemirror"], mod);
  29007. else // Plain browser env
  29008. mod(CodeMirror);
  29009. })(function(CodeMirror) {
  29010. "use strict";
  29011. CodeMirror.defineOption("styleSelectedText", false, function(cm, val, old) {
  29012. var prev = old && old != CodeMirror.Init;
  29013. if (val && !prev) {
  29014. cm.state.markedSelection = [];
  29015. cm.state.markedSelectionStyle = typeof val == "string" ? val : "CodeMirror-selectedtext";
  29016. reset(cm);
  29017. cm.on("cursorActivity", onCursorActivity);
  29018. cm.on("change", onChange);
  29019. } else if (!val && prev) {
  29020. cm.off("cursorActivity", onCursorActivity);
  29021. cm.off("change", onChange);
  29022. clear(cm);
  29023. cm.state.markedSelection = cm.state.markedSelectionStyle = null;
  29024. }
  29025. });
  29026. function onCursorActivity(cm) {
  29027. cm.operation(function() { update(cm); });
  29028. }
  29029. function onChange(cm) {
  29030. if (cm.state.markedSelection.length)
  29031. cm.operation(function() { clear(cm); });
  29032. }
  29033. var CHUNK_SIZE = 8;
  29034. var Pos = CodeMirror.Pos;
  29035. var cmp = CodeMirror.cmpPos;
  29036. function coverRange(cm, from, to, addAt) {
  29037. if (cmp(from, to) == 0) return;
  29038. var array = cm.state.markedSelection;
  29039. var cls = cm.state.markedSelectionStyle;
  29040. for (var line = from.line;;) {
  29041. var start = line == from.line ? from : Pos(line, 0);
  29042. var endLine = line + CHUNK_SIZE, atEnd = endLine >= to.line;
  29043. var end = atEnd ? to : Pos(endLine, 0);
  29044. var mark = cm.markText(start, end, {className: cls});
  29045. if (addAt == null) array.push(mark);
  29046. else array.splice(addAt++, 0, mark);
  29047. if (atEnd) break;
  29048. line = endLine;
  29049. }
  29050. }
  29051. function clear(cm) {
  29052. var array = cm.state.markedSelection;
  29053. for (var i = 0; i < array.length; ++i) array[i].clear();
  29054. array.length = 0;
  29055. }
  29056. function reset(cm) {
  29057. clear(cm);
  29058. var ranges = cm.listSelections();
  29059. for (var i = 0; i < ranges.length; i++)
  29060. coverRange(cm, ranges[i].from(), ranges[i].to());
  29061. }
  29062. function update(cm) {
  29063. if (!cm.somethingSelected()) return clear(cm);
  29064. if (cm.listSelections().length > 1) return reset(cm);
  29065. var from = cm.getCursor("start"), to = cm.getCursor("end");
  29066. var array = cm.state.markedSelection;
  29067. if (!array.length) return coverRange(cm, from, to);
  29068. var coverStart = array[0].find(), coverEnd = array[array.length - 1].find();
  29069. if (!coverStart || !coverEnd || to.line - from.line < CHUNK_SIZE ||
  29070. cmp(from, coverEnd.to) >= 0 || cmp(to, coverStart.from) <= 0)
  29071. return reset(cm);
  29072. while (cmp(from, coverStart.from) > 0) {
  29073. array.shift().clear();
  29074. coverStart = array[0].find();
  29075. }
  29076. if (cmp(from, coverStart.from) < 0) {
  29077. if (coverStart.to.line - from.line < CHUNK_SIZE) {
  29078. array.shift().clear();
  29079. coverRange(cm, from, coverStart.to, 0);
  29080. } else {
  29081. coverRange(cm, from, coverStart.from, 0);
  29082. }
  29083. }
  29084. while (cmp(to, coverEnd.to) < 0) {
  29085. array.pop().clear();
  29086. coverEnd = array[array.length - 1].find();
  29087. }
  29088. if (cmp(to, coverEnd.to) > 0) {
  29089. if (to.line - coverEnd.from.line < CHUNK_SIZE) {
  29090. array.pop().clear();
  29091. coverRange(cm, coverEnd.from, to);
  29092. } else {
  29093. coverRange(cm, coverEnd.to, to);
  29094. }
  29095. }
  29096. }
  29097. });
  29098. /***/ },
  29099. /* 174 */
  29100. /***/ function(module, exports, __webpack_require__) {
  29101. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  29102. // Distributed under an MIT license: http://codemirror.net/LICENSE
  29103. (function(mod) {
  29104. if (true) // CommonJS
  29105. mod(__webpack_require__(164), __webpack_require__(168), __webpack_require__(171));
  29106. else if (typeof define == "function" && define.amd) // AMD
  29107. define(["../../lib/codemirror", "../markdown/markdown", "../../addon/mode/overlay"], mod);
  29108. else // Plain browser env
  29109. mod(CodeMirror);
  29110. })(function(CodeMirror) {
  29111. "use strict";
  29112. var urlRE = /^((?:(?:aaas?|about|acap|adiumxtra|af[ps]|aim|apt|attachment|aw|beshare|bitcoin|bolo|callto|cap|chrome(?:-extension)?|cid|coap|com-eventbrite-attendee|content|crid|cvs|data|dav|dict|dlna-(?:playcontainer|playsingle)|dns|doi|dtn|dvb|ed2k|facetime|feed|file|finger|fish|ftp|geo|gg|git|gizmoproject|go|gopher|gtalk|h323|hcp|https?|iax|icap|icon|im|imap|info|ipn|ipp|irc[6s]?|iris(?:\.beep|\.lwz|\.xpc|\.xpcs)?|itms|jar|javascript|jms|keyparc|lastfm|ldaps?|magnet|mailto|maps|market|message|mid|mms|ms-help|msnim|msrps?|mtqp|mumble|mupdate|mvn|news|nfs|nih?|nntp|notes|oid|opaquelocktoken|palm|paparazzi|platform|pop|pres|proxy|psyc|query|res(?:ource)?|rmi|rsync|rtmp|rtsp|secondlife|service|session|sftp|sgn|shttp|sieve|sips?|skype|sm[bs]|snmp|soap\.beeps?|soldat|spotify|ssh|steam|svn|tag|teamspeak|tel(?:net)?|tftp|things|thismessage|tip|tn3270|tv|udp|unreal|urn|ut2004|vemmi|ventrilo|view-source|webcal|wss?|wtai|wyciwyg|xcon(?:-userid)?|xfire|xmlrpc\.beeps?|xmpp|xri|ymsgr|z39\.50[rs]?):(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`*!()\[\]{};:'".,<>?«»“”‘’]))/i
  29113. CodeMirror.defineMode("gfm", function(config, modeConfig) {
  29114. var codeDepth = 0;
  29115. function blankLine(state) {
  29116. state.code = false;
  29117. return null;
  29118. }
  29119. var gfmOverlay = {
  29120. startState: function() {
  29121. return {
  29122. code: false,
  29123. codeBlock: false,
  29124. ateSpace: false
  29125. };
  29126. },
  29127. copyState: function(s) {
  29128. return {
  29129. code: s.code,
  29130. codeBlock: s.codeBlock,
  29131. ateSpace: s.ateSpace
  29132. };
  29133. },
  29134. token: function(stream, state) {
  29135. state.combineTokens = null;
  29136. // Hack to prevent formatting override inside code blocks (block and inline)
  29137. if (state.codeBlock) {
  29138. if (stream.match(/^```+/)) {
  29139. state.codeBlock = false;
  29140. return null;
  29141. }
  29142. stream.skipToEnd();
  29143. return null;
  29144. }
  29145. if (stream.sol()) {
  29146. state.code = false;
  29147. }
  29148. if (stream.sol() && stream.match(/^```+/)) {
  29149. stream.skipToEnd();
  29150. state.codeBlock = true;
  29151. return null;
  29152. }
  29153. // If this block is changed, it may need to be updated in Markdown mode
  29154. if (stream.peek() === '`') {
  29155. stream.next();
  29156. var before = stream.pos;
  29157. stream.eatWhile('`');
  29158. var difference = 1 + stream.pos - before;
  29159. if (!state.code) {
  29160. codeDepth = difference;
  29161. state.code = true;
  29162. } else {
  29163. if (difference === codeDepth) { // Must be exact
  29164. state.code = false;
  29165. }
  29166. }
  29167. return null;
  29168. } else if (state.code) {
  29169. stream.next();
  29170. return null;
  29171. }
  29172. // Check if space. If so, links can be formatted later on
  29173. if (stream.eatSpace()) {
  29174. state.ateSpace = true;
  29175. return null;
  29176. }
  29177. if (stream.sol() || state.ateSpace) {
  29178. state.ateSpace = false;
  29179. if (modeConfig.gitHubSpice !== false) {
  29180. if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
  29181. // User/Project@SHA
  29182. // User@SHA
  29183. // SHA
  29184. state.combineTokens = true;
  29185. return "link";
  29186. } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
  29187. // User/Project#Num
  29188. // User#Num
  29189. // #Num
  29190. state.combineTokens = true;
  29191. return "link";
  29192. }
  29193. }
  29194. }
  29195. if (stream.match(urlRE) &&
  29196. stream.string.slice(stream.start - 2, stream.start) != "](" &&
  29197. (stream.start == 0 || /\W/.test(stream.string.charAt(stream.start - 1)))) {
  29198. // URLs
  29199. // Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
  29200. // And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
  29201. // And then limited url schemes to the CommonMark list, so foo:bar isn't matched as a URL
  29202. state.combineTokens = true;
  29203. return "link";
  29204. }
  29205. stream.next();
  29206. return null;
  29207. },
  29208. blankLine: blankLine
  29209. };
  29210. var markdownConfig = {
  29211. underscoresBreakWords: false,
  29212. taskLists: true,
  29213. fencedCodeBlocks: '```',
  29214. strikethrough: true
  29215. };
  29216. for (var attr in modeConfig) {
  29217. markdownConfig[attr] = modeConfig[attr];
  29218. }
  29219. markdownConfig.name = "markdown";
  29220. return CodeMirror.overlayMode(CodeMirror.getMode(config, markdownConfig), gfmOverlay);
  29221. }, "markdown");
  29222. CodeMirror.defineMIME("text/x-gfm", "gfm");
  29223. });
  29224. /***/ },
  29225. /* 175 */
  29226. /***/ function(module, exports, __webpack_require__) {
  29227. // Use strict mode (https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode)
  29228. "use strict";
  29229. // Requires
  29230. var Typo = __webpack_require__(176);
  29231. // Create function
  29232. function CodeMirrorSpellChecker(options) {
  29233. // Initialize
  29234. options = options || {};
  29235. // Verify
  29236. if(typeof options.codeMirrorInstance !== "function" || typeof options.codeMirrorInstance.defineMode !== "function") {
  29237. console.log("CodeMirror Spell Checker: You must provide an instance of CodeMirror via the option `codeMirrorInstance`");
  29238. return;
  29239. }
  29240. // Because some browsers don't support this functionality yet
  29241. if(!String.prototype.includes) {
  29242. String.prototype.includes = function() {
  29243. "use strict";
  29244. return String.prototype.indexOf.apply(this, arguments) !== -1;
  29245. };
  29246. }
  29247. // Define the new mode
  29248. options.codeMirrorInstance.defineMode("spell-checker", function(config) {
  29249. // Load AFF/DIC data
  29250. if(!CodeMirrorSpellChecker.aff_loading) {
  29251. CodeMirrorSpellChecker.aff_loading = true;
  29252. var xhr_aff = new XMLHttpRequest();
  29253. xhr_aff.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff", true);
  29254. xhr_aff.onload = function() {
  29255. if(xhr_aff.readyState === 4 && xhr_aff.status === 200) {
  29256. CodeMirrorSpellChecker.aff_data = xhr_aff.responseText;
  29257. CodeMirrorSpellChecker.num_loaded++;
  29258. if(CodeMirrorSpellChecker.num_loaded == 2) {
  29259. CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
  29260. platform: "any"
  29261. });
  29262. }
  29263. }
  29264. };
  29265. xhr_aff.send(null);
  29266. }
  29267. if(!CodeMirrorSpellChecker.dic_loading) {
  29268. CodeMirrorSpellChecker.dic_loading = true;
  29269. var xhr_dic = new XMLHttpRequest();
  29270. xhr_dic.open("GET", "https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic", true);
  29271. xhr_dic.onload = function() {
  29272. if(xhr_dic.readyState === 4 && xhr_dic.status === 200) {
  29273. CodeMirrorSpellChecker.dic_data = xhr_dic.responseText;
  29274. CodeMirrorSpellChecker.num_loaded++;
  29275. if(CodeMirrorSpellChecker.num_loaded == 2) {
  29276. CodeMirrorSpellChecker.typo = new Typo("en_US", CodeMirrorSpellChecker.aff_data, CodeMirrorSpellChecker.dic_data, {
  29277. platform: "any"
  29278. });
  29279. }
  29280. }
  29281. };
  29282. xhr_dic.send(null);
  29283. }
  29284. // Define what separates a word
  29285. var rx_word = "!\"#$%&()*+,-./:;<=>?@[\\]^_`{|}~ ";
  29286. // Create the overlay and such
  29287. var overlay = {
  29288. token: function(stream) {
  29289. var ch = stream.peek();
  29290. var word = "";
  29291. if(rx_word.includes(ch)) {
  29292. stream.next();
  29293. return null;
  29294. }
  29295. while((ch = stream.peek()) != null && !rx_word.includes(ch)) {
  29296. word += ch;
  29297. stream.next();
  29298. }
  29299. if(CodeMirrorSpellChecker.typo && !CodeMirrorSpellChecker.typo.check(word))
  29300. return "spell-error"; // CSS class: cm-spell-error
  29301. return null;
  29302. }
  29303. };
  29304. var mode = options.codeMirrorInstance.getMode(
  29305. config, config.backdrop || "text/plain"
  29306. );
  29307. return options.codeMirrorInstance.overlayMode(mode, overlay, true);
  29308. });
  29309. }
  29310. // Initialize data globally to reduce memory consumption
  29311. CodeMirrorSpellChecker.num_loaded = 0;
  29312. CodeMirrorSpellChecker.aff_loading = false;
  29313. CodeMirrorSpellChecker.dic_loading = false;
  29314. CodeMirrorSpellChecker.aff_data = "";
  29315. CodeMirrorSpellChecker.dic_data = "";
  29316. CodeMirrorSpellChecker.typo;
  29317. // Export
  29318. module.exports = CodeMirrorSpellChecker;
  29319. /***/ },
  29320. /* 176 */
  29321. /***/ function(module, exports, __webpack_require__) {
  29322. /* WEBPACK VAR INJECTION */(function(__dirname, Buffer) {/* globals chrome: false */
  29323. /* globals __dirname: false */
  29324. /* globals require: false */
  29325. /* globals Buffer: false */
  29326. /* globals module: false */
  29327. /**
  29328. * Typo is a JavaScript implementation of a spellchecker using hunspell-style
  29329. * dictionaries.
  29330. */
  29331. var Typo;
  29332. (function () {
  29333. "use strict";
  29334. /**
  29335. * Typo constructor.
  29336. *
  29337. * @param {String} [dictionary] The locale code of the dictionary being used. e.g.,
  29338. * "en_US". This is only used to auto-load dictionaries.
  29339. * @param {String} [affData] The data from the dictionary's .aff file. If omitted
  29340. * and Typo.js is being used in a Chrome extension, the .aff
  29341. * file will be loaded automatically from
  29342. * lib/typo/dictionaries/[dictionary]/[dictionary].aff
  29343. * In other environments, it will be loaded from
  29344. * [settings.dictionaryPath]/dictionaries/[dictionary]/[dictionary].aff
  29345. * @param {String} [wordsData] The data from the dictionary's .dic file. If omitted
  29346. * and Typo.js is being used in a Chrome extension, the .dic
  29347. * file will be loaded automatically from
  29348. * lib/typo/dictionaries/[dictionary]/[dictionary].dic
  29349. * In other environments, it will be loaded from
  29350. * [settings.dictionaryPath]/dictionaries/[dictionary]/[dictionary].dic
  29351. * @param {Object} [settings] Constructor settings. Available properties are:
  29352. * {String} [dictionaryPath]: path to load dictionary from in non-chrome
  29353. * environment.
  29354. * {Object} [flags]: flag information.
  29355. * {Boolean} [asyncLoad]: If true, affData and wordsData will be loaded
  29356. * asynchronously.
  29357. * {Function} [loadedCallback]: Called when both affData and wordsData
  29358. * have been loaded. Only used if asyncLoad is set to true. The parameter
  29359. * is the instantiated Typo object.
  29360. *
  29361. * @returns {Typo} A Typo object.
  29362. */
  29363. Typo = function (dictionary, affData, wordsData, settings) {
  29364. settings = settings || {};
  29365. this.dictionary = null;
  29366. this.rules = {};
  29367. this.dictionaryTable = {};
  29368. this.compoundRules = [];
  29369. this.compoundRuleCodes = {};
  29370. this.replacementTable = [];
  29371. this.flags = settings.flags || {};
  29372. this.memoized = {};
  29373. this.loaded = false;
  29374. var self = this;
  29375. var path;
  29376. // Loop-control variables.
  29377. var i, j, _len, _jlen;
  29378. if (dictionary) {
  29379. self.dictionary = dictionary;
  29380. // If the data is preloaded, just setup the Typo object.
  29381. if (affData && wordsData) {
  29382. setup();
  29383. }
  29384. // Loading data for Chrome extentions.
  29385. else if (typeof window !== 'undefined' && 'chrome' in window && 'extension' in window.chrome && 'getURL' in window.chrome.extension) {
  29386. if (settings.dictionaryPath) {
  29387. path = settings.dictionaryPath;
  29388. }
  29389. else {
  29390. path = "typo/dictionaries";
  29391. }
  29392. if (!affData) readDataFile(chrome.extension.getURL(path + "/" + dictionary + "/" + dictionary + ".aff"), setAffData);
  29393. if (!wordsData) readDataFile(chrome.extension.getURL(path + "/" + dictionary + "/" + dictionary + ".dic"), setWordsData);
  29394. }
  29395. else {
  29396. if (settings.dictionaryPath) {
  29397. path = settings.dictionaryPath;
  29398. }
  29399. else if (true) {
  29400. path = __dirname + '/dictionaries';
  29401. }
  29402. else {
  29403. path = './dictionaries';
  29404. }
  29405. if (!affData) readDataFile(path + "/" + dictionary + "/" + dictionary + ".aff", setAffData);
  29406. if (!wordsData) readDataFile(path + "/" + dictionary + "/" + dictionary + ".dic", setWordsData);
  29407. }
  29408. }
  29409. function readDataFile(url, setFunc) {
  29410. var response = self._readFile(url, null, settings.asyncLoad);
  29411. if (settings.asyncLoad) {
  29412. response.then(function(data) {
  29413. setFunc(data);
  29414. });
  29415. }
  29416. else {
  29417. setFunc(response);
  29418. }
  29419. }
  29420. function setAffData(data) {
  29421. affData = data;
  29422. if (wordsData) {
  29423. setup();
  29424. }
  29425. }
  29426. function setWordsData(data) {
  29427. wordsData = data;
  29428. if (affData) {
  29429. setup();
  29430. }
  29431. }
  29432. function setup() {
  29433. self.rules = self._parseAFF(affData);
  29434. // Save the rule codes that are used in compound rules.
  29435. self.compoundRuleCodes = {};
  29436. for (i = 0, _len = self.compoundRules.length; i < _len; i++) {
  29437. var rule = self.compoundRules[i];
  29438. for (j = 0, _jlen = rule.length; j < _jlen; j++) {
  29439. self.compoundRuleCodes[rule[j]] = [];
  29440. }
  29441. }
  29442. // If we add this ONLYINCOMPOUND flag to self.compoundRuleCodes, then _parseDIC
  29443. // will do the work of saving the list of words that are compound-only.
  29444. if ("ONLYINCOMPOUND" in self.flags) {
  29445. self.compoundRuleCodes[self.flags.ONLYINCOMPOUND] = [];
  29446. }
  29447. self.dictionaryTable = self._parseDIC(wordsData);
  29448. // Get rid of any codes from the compound rule codes that are never used
  29449. // (or that were special regex characters). Not especially necessary...
  29450. for (i in self.compoundRuleCodes) {
  29451. if (self.compoundRuleCodes[i].length === 0) {
  29452. delete self.compoundRuleCodes[i];
  29453. }
  29454. }
  29455. // Build the full regular expressions for each compound rule.
  29456. // I have a feeling (but no confirmation yet) that this method of
  29457. // testing for compound words is probably slow.
  29458. for (i = 0, _len = self.compoundRules.length; i < _len; i++) {
  29459. var ruleText = self.compoundRules[i];
  29460. var expressionText = "";
  29461. for (j = 0, _jlen = ruleText.length; j < _jlen; j++) {
  29462. var character = ruleText[j];
  29463. if (character in self.compoundRuleCodes) {
  29464. expressionText += "(" + self.compoundRuleCodes[character].join("|") + ")";
  29465. }
  29466. else {
  29467. expressionText += character;
  29468. }
  29469. }
  29470. self.compoundRules[i] = new RegExp(expressionText, "i");
  29471. }
  29472. self.loaded = true;
  29473. if (settings.asyncLoad && settings.loadedCallback) {
  29474. settings.loadedCallback(self);
  29475. }
  29476. }
  29477. return this;
  29478. };
  29479. Typo.prototype = {
  29480. /**
  29481. * Loads a Typo instance from a hash of all of the Typo properties.
  29482. *
  29483. * @param object obj A hash of Typo properties, probably gotten from a JSON.parse(JSON.stringify(typo_instance)).
  29484. */
  29485. load : function (obj) {
  29486. for (var i in obj) {
  29487. if (obj.hasOwnProperty(i)) {
  29488. this[i] = obj[i];
  29489. }
  29490. }
  29491. return this;
  29492. },
  29493. /**
  29494. * Read the contents of a file.
  29495. *
  29496. * @param {String} path The path (relative) to the file.
  29497. * @param {String} [charset="ISO8859-1"] The expected charset of the file
  29498. * @param {Boolean} async If true, the file will be read asynchronously. For node.js this does nothing, all
  29499. * files are read synchronously.
  29500. * @returns {String} The file data if async is false, otherwise a promise object. If running node.js, the data is
  29501. * always returned.
  29502. */
  29503. _readFile : function (path, charset, async) {
  29504. charset = charset || "utf8";
  29505. if (typeof XMLHttpRequest !== 'undefined') {
  29506. var promise;
  29507. var req = new XMLHttpRequest();
  29508. req.open("GET", path, async);
  29509. if (async) {
  29510. promise = new Promise(function(resolve, reject) {
  29511. req.onload = function() {
  29512. if (req.status === 200) {
  29513. resolve(req.responseText);
  29514. }
  29515. else {
  29516. reject(req.statusText);
  29517. }
  29518. };
  29519. req.onerror = function() {
  29520. reject(req.statusText);
  29521. }
  29522. });
  29523. }
  29524. if (req.overrideMimeType)
  29525. req.overrideMimeType("text/plain; charset=" + charset);
  29526. req.send(null);
  29527. return async ? promise : req.responseText;
  29528. }
  29529. else if (true) {
  29530. // Node.js
  29531. var fs = __webpack_require__(181);
  29532. try {
  29533. if (fs.existsSync(path)) {
  29534. var stats = fs.statSync(path);
  29535. var fileDescriptor = fs.openSync(path, 'r');
  29536. var buffer = new Buffer(stats.size);
  29537. fs.readSync(fileDescriptor, buffer, 0, buffer.length, null);
  29538. return buffer.toString(charset, 0, buffer.length);
  29539. }
  29540. else {
  29541. console.log("Path " + path + " does not exist.");
  29542. }
  29543. } catch (e) {
  29544. console.log(e);
  29545. return '';
  29546. }
  29547. }
  29548. },
  29549. /**
  29550. * Parse the rules out from a .aff file.
  29551. *
  29552. * @param {String} data The contents of the affix file.
  29553. * @returns object The rules from the file.
  29554. */
  29555. _parseAFF : function (data) {
  29556. var rules = {};
  29557. var line, subline, numEntries, lineParts;
  29558. var i, j, _len, _jlen;
  29559. // Remove comment lines
  29560. data = this._removeAffixComments(data);
  29561. var lines = data.split("\n");
  29562. for (i = 0, _len = lines.length; i < _len; i++) {
  29563. line = lines[i];
  29564. var definitionParts = line.split(/\s+/);
  29565. var ruleType = definitionParts[0];
  29566. if (ruleType == "PFX" || ruleType == "SFX") {
  29567. var ruleCode = definitionParts[1];
  29568. var combineable = definitionParts[2];
  29569. numEntries = parseInt(definitionParts[3], 10);
  29570. var entries = [];
  29571. for (j = i + 1, _jlen = i + 1 + numEntries; j < _jlen; j++) {
  29572. subline = lines[j];
  29573. lineParts = subline.split(/\s+/);
  29574. var charactersToRemove = lineParts[2];
  29575. var additionParts = lineParts[3].split("/");
  29576. var charactersToAdd = additionParts[0];
  29577. if (charactersToAdd === "0") charactersToAdd = "";
  29578. var continuationClasses = this.parseRuleCodes(additionParts[1]);
  29579. var regexToMatch = lineParts[4];
  29580. var entry = {};
  29581. entry.add = charactersToAdd;
  29582. if (continuationClasses.length > 0) entry.continuationClasses = continuationClasses;
  29583. if (regexToMatch !== ".") {
  29584. if (ruleType === "SFX") {
  29585. entry.match = new RegExp(regexToMatch + "$");
  29586. }
  29587. else {
  29588. entry.match = new RegExp("^" + regexToMatch);
  29589. }
  29590. }
  29591. if (charactersToRemove != "0") {
  29592. if (ruleType === "SFX") {
  29593. entry.remove = new RegExp(charactersToRemove + "$");
  29594. }
  29595. else {
  29596. entry.remove = charactersToRemove;
  29597. }
  29598. }
  29599. entries.push(entry);
  29600. }
  29601. rules[ruleCode] = { "type" : ruleType, "combineable" : (combineable == "Y"), "entries" : entries };
  29602. i += numEntries;
  29603. }
  29604. else if (ruleType === "COMPOUNDRULE") {
  29605. numEntries = parseInt(definitionParts[1], 10);
  29606. for (j = i + 1, _jlen = i + 1 + numEntries; j < _jlen; j++) {
  29607. line = lines[j];
  29608. lineParts = line.split(/\s+/);
  29609. this.compoundRules.push(lineParts[1]);
  29610. }
  29611. i += numEntries;
  29612. }
  29613. else if (ruleType === "REP") {
  29614. lineParts = line.split(/\s+/);
  29615. if (lineParts.length === 3) {
  29616. this.replacementTable.push([ lineParts[1], lineParts[2] ]);
  29617. }
  29618. }
  29619. else {
  29620. // ONLYINCOMPOUND
  29621. // COMPOUNDMIN
  29622. // FLAG
  29623. // KEEPCASE
  29624. // NEEDAFFIX
  29625. this.flags[ruleType] = definitionParts[1];
  29626. }
  29627. }
  29628. return rules;
  29629. },
  29630. /**
  29631. * Removes comment lines and then cleans up blank lines and trailing whitespace.
  29632. *
  29633. * @param {String} data The data from an affix file.
  29634. * @return {String} The cleaned-up data.
  29635. */
  29636. _removeAffixComments : function (data) {
  29637. // Remove comments
  29638. // This used to remove any string starting with '#' up to the end of the line,
  29639. // but some COMPOUNDRULE definitions include '#' as part of the rule.
  29640. // I haven't seen any affix files that use comments on the same line as real data,
  29641. // so I don't think this will break anything.
  29642. data = data.replace(/^\s*#.*$/mg, "");
  29643. // Trim each line
  29644. data = data.replace(/^\s\s*/m, '').replace(/\s\s*$/m, '');
  29645. // Remove blank lines.
  29646. data = data.replace(/\n{2,}/g, "\n");
  29647. // Trim the entire string
  29648. data = data.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  29649. return data;
  29650. },
  29651. /**
  29652. * Parses the words out from the .dic file.
  29653. *
  29654. * @param {String} data The data from the dictionary file.
  29655. * @returns object The lookup table containing all of the words and
  29656. * word forms from the dictionary.
  29657. */
  29658. _parseDIC : function (data) {
  29659. data = this._removeDicComments(data);
  29660. var lines = data.split("\n");
  29661. var dictionaryTable = {};
  29662. function addWord(word, rules) {
  29663. // Some dictionaries will list the same word multiple times with different rule sets.
  29664. if (!dictionaryTable.hasOwnProperty(word)) {
  29665. dictionaryTable[word] = null;
  29666. }
  29667. if (rules.length > 0) {
  29668. if (dictionaryTable[word] === null) {
  29669. dictionaryTable[word] = [];
  29670. }
  29671. dictionaryTable[word].push(rules);
  29672. }
  29673. }
  29674. // The first line is the number of words in the dictionary.
  29675. for (var i = 1, _len = lines.length; i < _len; i++) {
  29676. var line = lines[i];
  29677. var parts = line.split("/", 2);
  29678. var word = parts[0];
  29679. // Now for each affix rule, generate that form of the word.
  29680. if (parts.length > 1) {
  29681. var ruleCodesArray = this.parseRuleCodes(parts[1]);
  29682. // Save the ruleCodes for compound word situations.
  29683. if (!("NEEDAFFIX" in this.flags) || ruleCodesArray.indexOf(this.flags.NEEDAFFIX) == -1) {
  29684. addWord(word, ruleCodesArray);
  29685. }
  29686. for (var j = 0, _jlen = ruleCodesArray.length; j < _jlen; j++) {
  29687. var code = ruleCodesArray[j];
  29688. var rule = this.rules[code];
  29689. if (rule) {
  29690. var newWords = this._applyRule(word, rule);
  29691. for (var ii = 0, _iilen = newWords.length; ii < _iilen; ii++) {
  29692. var newWord = newWords[ii];
  29693. addWord(newWord, []);
  29694. if (rule.combineable) {
  29695. for (var k = j + 1; k < _jlen; k++) {
  29696. var combineCode = ruleCodesArray[k];
  29697. var combineRule = this.rules[combineCode];
  29698. if (combineRule) {
  29699. if (combineRule.combineable && (rule.type != combineRule.type)) {
  29700. var otherNewWords = this._applyRule(newWord, combineRule);
  29701. for (var iii = 0, _iiilen = otherNewWords.length; iii < _iiilen; iii++) {
  29702. var otherNewWord = otherNewWords[iii];
  29703. addWord(otherNewWord, []);
  29704. }
  29705. }
  29706. }
  29707. }
  29708. }
  29709. }
  29710. }
  29711. if (code in this.compoundRuleCodes) {
  29712. this.compoundRuleCodes[code].push(word);
  29713. }
  29714. }
  29715. }
  29716. else {
  29717. addWord(word.trim(), []);
  29718. }
  29719. }
  29720. return dictionaryTable;
  29721. },
  29722. /**
  29723. * Removes comment lines and then cleans up blank lines and trailing whitespace.
  29724. *
  29725. * @param {String} data The data from a .dic file.
  29726. * @return {String} The cleaned-up data.
  29727. */
  29728. _removeDicComments : function (data) {
  29729. // I can't find any official documentation on it, but at least the de_DE
  29730. // dictionary uses tab-indented lines as comments.
  29731. // Remove comments
  29732. data = data.replace(/^\t.*$/mg, "");
  29733. return data;
  29734. },
  29735. parseRuleCodes : function (textCodes) {
  29736. if (!textCodes) {
  29737. return [];
  29738. }
  29739. else if (!("FLAG" in this.flags)) {
  29740. return textCodes.split("");
  29741. }
  29742. else if (this.flags.FLAG === "long") {
  29743. var flags = [];
  29744. for (var i = 0, _len = textCodes.length; i < _len; i += 2) {
  29745. flags.push(textCodes.substr(i, 2));
  29746. }
  29747. return flags;
  29748. }
  29749. else if (this.flags.FLAG === "num") {
  29750. return textCodes.split(",");
  29751. }
  29752. },
  29753. /**
  29754. * Applies an affix rule to a word.
  29755. *
  29756. * @param {String} word The base word.
  29757. * @param {Object} rule The affix rule.
  29758. * @returns {String[]} The new words generated by the rule.
  29759. */
  29760. _applyRule : function (word, rule) {
  29761. var entries = rule.entries;
  29762. var newWords = [];
  29763. for (var i = 0, _len = entries.length; i < _len; i++) {
  29764. var entry = entries[i];
  29765. if (!entry.match || word.match(entry.match)) {
  29766. var newWord = word;
  29767. if (entry.remove) {
  29768. newWord = newWord.replace(entry.remove, "");
  29769. }
  29770. if (rule.type === "SFX") {
  29771. newWord = newWord + entry.add;
  29772. }
  29773. else {
  29774. newWord = entry.add + newWord;
  29775. }
  29776. newWords.push(newWord);
  29777. if ("continuationClasses" in entry) {
  29778. for (var j = 0, _jlen = entry.continuationClasses.length; j < _jlen; j++) {
  29779. var continuationRule = this.rules[entry.continuationClasses[j]];
  29780. if (continuationRule) {
  29781. newWords = newWords.concat(this._applyRule(newWord, continuationRule));
  29782. }
  29783. /*
  29784. else {
  29785. // This shouldn't happen, but it does, at least in the de_DE dictionary.
  29786. // I think the author mistakenly supplied lower-case rule codes instead
  29787. // of upper-case.
  29788. }
  29789. */
  29790. }
  29791. }
  29792. }
  29793. }
  29794. return newWords;
  29795. },
  29796. /**
  29797. * Checks whether a word or a capitalization variant exists in the current dictionary.
  29798. * The word is trimmed and several variations of capitalizations are checked.
  29799. * If you want to check a word without any changes made to it, call checkExact()
  29800. *
  29801. * @see http://blog.stevenlevithan.com/archives/faster-trim-javascript re:trimming function
  29802. *
  29803. * @param {String} aWord The word to check.
  29804. * @returns {Boolean}
  29805. */
  29806. check : function (aWord) {
  29807. if (!this.loaded) {
  29808. throw "Dictionary not loaded.";
  29809. }
  29810. // Remove leading and trailing whitespace
  29811. var trimmedWord = aWord.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  29812. if (this.checkExact(trimmedWord)) {
  29813. return true;
  29814. }
  29815. // The exact word is not in the dictionary.
  29816. if (trimmedWord.toUpperCase() === trimmedWord) {
  29817. // The word was supplied in all uppercase.
  29818. // Check for a capitalized form of the word.
  29819. var capitalizedWord = trimmedWord[0] + trimmedWord.substring(1).toLowerCase();
  29820. if (this.hasFlag(capitalizedWord, "KEEPCASE")) {
  29821. // Capitalization variants are not allowed for this word.
  29822. return false;
  29823. }
  29824. if (this.checkExact(capitalizedWord)) {
  29825. return true;
  29826. }
  29827. }
  29828. var lowercaseWord = trimmedWord.toLowerCase();
  29829. if (lowercaseWord !== trimmedWord) {
  29830. if (this.hasFlag(lowercaseWord, "KEEPCASE")) {
  29831. // Capitalization variants are not allowed for this word.
  29832. return false;
  29833. }
  29834. // Check for a lowercase form
  29835. if (this.checkExact(lowercaseWord)) {
  29836. return true;
  29837. }
  29838. }
  29839. return false;
  29840. },
  29841. /**
  29842. * Checks whether a word exists in the current dictionary.
  29843. *
  29844. * @param {String} word The word to check.
  29845. * @returns {Boolean}
  29846. */
  29847. checkExact : function (word) {
  29848. if (!this.loaded) {
  29849. throw "Dictionary not loaded.";
  29850. }
  29851. var ruleCodes = this.dictionaryTable[word];
  29852. var i, _len;
  29853. if (typeof ruleCodes === 'undefined') {
  29854. // Check if this might be a compound word.
  29855. if ("COMPOUNDMIN" in this.flags && word.length >= this.flags.COMPOUNDMIN) {
  29856. for (i = 0, _len = this.compoundRules.length; i < _len; i++) {
  29857. if (word.match(this.compoundRules[i])) {
  29858. return true;
  29859. }
  29860. }
  29861. }
  29862. }
  29863. else if (ruleCodes === null) {
  29864. // a null (but not undefined) value for an entry in the dictionary table
  29865. // means that the word is in the dictionary but has no flags.
  29866. return true;
  29867. }
  29868. else if (typeof ruleCodes === 'object') { // this.dictionary['hasOwnProperty'] will be a function.
  29869. for (i = 0, _len = ruleCodes.length; i < _len; i++) {
  29870. if (!this.hasFlag(word, "ONLYINCOMPOUND", ruleCodes[i])) {
  29871. return true;
  29872. }
  29873. }
  29874. }
  29875. return false;
  29876. },
  29877. /**
  29878. * Looks up whether a given word is flagged with a given flag.
  29879. *
  29880. * @param {String} word The word in question.
  29881. * @param {String} flag The flag in question.
  29882. * @return {Boolean}
  29883. */
  29884. hasFlag : function (word, flag, wordFlags) {
  29885. if (!this.loaded) {
  29886. throw "Dictionary not loaded.";
  29887. }
  29888. if (flag in this.flags) {
  29889. if (typeof wordFlags === 'undefined') {
  29890. wordFlags = Array.prototype.concat.apply([], this.dictionaryTable[word]);
  29891. }
  29892. if (wordFlags && wordFlags.indexOf(this.flags[flag]) !== -1) {
  29893. return true;
  29894. }
  29895. }
  29896. return false;
  29897. },
  29898. /**
  29899. * Returns a list of suggestions for a misspelled word.
  29900. *
  29901. * @see http://www.norvig.com/spell-correct.html for the basis of this suggestor.
  29902. * This suggestor is primitive, but it works.
  29903. *
  29904. * @param {String} word The misspelling.
  29905. * @param {Number} [limit=5] The maximum number of suggestions to return.
  29906. * @returns {String[]} The array of suggestions.
  29907. */
  29908. alphabet : "",
  29909. suggest : function (word, limit) {
  29910. if (!this.loaded) {
  29911. throw "Dictionary not loaded.";
  29912. }
  29913. limit = limit || 5;
  29914. if (this.memoized.hasOwnProperty(word)) {
  29915. var memoizedLimit = this.memoized[word]['limit'];
  29916. // Only return the cached list if it's big enough or if there weren't enough suggestions
  29917. // to fill a smaller limit.
  29918. if (limit <= memoizedLimit || this.memoized[word]['suggestions'].length < memoizedLimit) {
  29919. return this.memoized[word]['suggestions'].slice(0, limit);
  29920. }
  29921. }
  29922. if (this.check(word)) return [];
  29923. // Check the replacement table.
  29924. for (var i = 0, _len = this.replacementTable.length; i < _len; i++) {
  29925. var replacementEntry = this.replacementTable[i];
  29926. if (word.indexOf(replacementEntry[0]) !== -1) {
  29927. var correctedWord = word.replace(replacementEntry[0], replacementEntry[1]);
  29928. if (this.check(correctedWord)) {
  29929. return [ correctedWord ];
  29930. }
  29931. }
  29932. }
  29933. var self = this;
  29934. self.alphabet = "abcdefghijklmnopqrstuvwxyz";
  29935. /*
  29936. if (!self.alphabet) {
  29937. // Use the alphabet as implicitly defined by the words in the dictionary.
  29938. var alphaHash = {};
  29939. for (var i in self.dictionaryTable) {
  29940. for (var j = 0, _len = i.length; j < _len; j++) {
  29941. alphaHash[i[j]] = true;
  29942. }
  29943. }
  29944. for (var i in alphaHash) {
  29945. self.alphabet += i;
  29946. }
  29947. var alphaArray = self.alphabet.split("");
  29948. alphaArray.sort();
  29949. self.alphabet = alphaArray.join("");
  29950. }
  29951. */
  29952. function edits1(words) {
  29953. var rv = [];
  29954. var ii, i, j, _iilen, _len, _jlen;
  29955. for (ii = 0, _iilen = words.length; ii < _iilen; ii++) {
  29956. var word = words[ii];
  29957. for (i = 0, _len = word.length + 1; i < _len; i++) {
  29958. var s = [ word.substring(0, i), word.substring(i) ];
  29959. if (s[1]) {
  29960. rv.push(s[0] + s[1].substring(1));
  29961. }
  29962. // Eliminate transpositions of identical letters
  29963. if (s[1].length > 1 && s[1][1] !== s[1][0]) {
  29964. rv.push(s[0] + s[1][1] + s[1][0] + s[1].substring(2));
  29965. }
  29966. if (s[1]) {
  29967. for (j = 0, _jlen = self.alphabet.length; j < _jlen; j++) {
  29968. // Eliminate replacement of a letter by itself
  29969. if (self.alphabet[j] != s[1].substring(0,1)){
  29970. rv.push(s[0] + self.alphabet[j] + s[1].substring(1));
  29971. }
  29972. }
  29973. }
  29974. if (s[1]) {
  29975. for (j = 0, _jlen = self.alphabet.length; j < _jlen; j++) {
  29976. rv.push(s[0] + self.alphabet[j] + s[1]);
  29977. }
  29978. }
  29979. }
  29980. }
  29981. return rv;
  29982. }
  29983. function known(words) {
  29984. var rv = [];
  29985. for (var i = 0, _len = words.length; i < _len; i++) {
  29986. if (self.check(words[i])) {
  29987. rv.push(words[i]);
  29988. }
  29989. }
  29990. return rv;
  29991. }
  29992. function correct(word) {
  29993. // Get the edit-distance-1 and edit-distance-2 forms of this word.
  29994. var ed1 = edits1([word]);
  29995. var ed2 = edits1(ed1);
  29996. var corrections = known(ed1.concat(ed2));
  29997. var i, _len;
  29998. // Sort the edits based on how many different ways they were created.
  29999. var weighted_corrections = {};
  30000. for (i = 0, _len = corrections.length; i < _len; i++) {
  30001. if (!(corrections[i] in weighted_corrections)) {
  30002. weighted_corrections[corrections[i]] = 1;
  30003. }
  30004. else {
  30005. weighted_corrections[corrections[i]] += 1;
  30006. }
  30007. }
  30008. var sorted_corrections = [];
  30009. for (i in weighted_corrections) {
  30010. if (weighted_corrections.hasOwnProperty(i)) {
  30011. sorted_corrections.push([ i, weighted_corrections[i] ]);
  30012. }
  30013. }
  30014. function sorter(a, b) {
  30015. if (a[1] < b[1]) {
  30016. return -1;
  30017. }
  30018. return 1;
  30019. }
  30020. sorted_corrections.sort(sorter).reverse();
  30021. var rv = [];
  30022. var capitalization_scheme = "lowercase";
  30023. if (word.toUpperCase() === word) {
  30024. capitalization_scheme = "uppercase";
  30025. }
  30026. else if (word.substr(0, 1).toUpperCase() + word.substr(1).toLowerCase() === word) {
  30027. capitalization_scheme = "capitalized";
  30028. }
  30029. for (i = 0, _len = Math.min(limit, sorted_corrections.length); i < _len; i++) {
  30030. if ("uppercase" === capitalization_scheme) {
  30031. sorted_corrections[i][0] = sorted_corrections[i][0].toUpperCase();
  30032. }
  30033. else if ("capitalized" === capitalization_scheme) {
  30034. sorted_corrections[i][0] = sorted_corrections[i][0].substr(0, 1).toUpperCase() + sorted_corrections[i][0].substr(1);
  30035. }
  30036. if (!self.hasFlag(sorted_corrections[i][0], "NOSUGGEST")) {
  30037. rv.push(sorted_corrections[i][0]);
  30038. }
  30039. }
  30040. return rv;
  30041. }
  30042. this.memoized[word] = {
  30043. 'suggestions': correct(word),
  30044. 'limit': limit
  30045. };
  30046. return this.memoized[word]['suggestions'];
  30047. }
  30048. };
  30049. })();
  30050. // Support for use as a node.js module.
  30051. if (true) {
  30052. module.exports = Typo;
  30053. }
  30054. /* WEBPACK VAR INJECTION */}.call(exports, "/", __webpack_require__(177).Buffer))
  30055. /***/ },
  30056. /* 177 */
  30057. /***/ function(module, exports, __webpack_require__) {
  30058. /* WEBPACK VAR INJECTION */(function(global) {/*!
  30059. * The buffer module from node.js, for the browser.
  30060. *
  30061. * @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
  30062. * @license MIT
  30063. */
  30064. /* eslint-disable no-proto */
  30065. 'use strict'
  30066. var base64 = __webpack_require__(178)
  30067. var ieee754 = __webpack_require__(179)
  30068. var isArray = __webpack_require__(180)
  30069. exports.Buffer = Buffer
  30070. exports.SlowBuffer = SlowBuffer
  30071. exports.INSPECT_MAX_BYTES = 50
  30072. /**
  30073. * If `Buffer.TYPED_ARRAY_SUPPORT`:
  30074. * === true Use Uint8Array implementation (fastest)
  30075. * === false Use Object implementation (most compatible, even IE6)
  30076. *
  30077. * Browsers that support typed arrays are IE 10+, Firefox 4+, Chrome 7+, Safari 5.1+,
  30078. * Opera 11.6+, iOS 4.2+.
  30079. *
  30080. * Due to various browser bugs, sometimes the Object implementation will be used even
  30081. * when the browser supports typed arrays.
  30082. *
  30083. * Note:
  30084. *
  30085. * - Firefox 4-29 lacks support for adding new properties to `Uint8Array` instances,
  30086. * See: https://bugzilla.mozilla.org/show_bug.cgi?id=695438.
  30087. *
  30088. * - Chrome 9-10 is missing the `TypedArray.prototype.subarray` function.
  30089. *
  30090. * - IE10 has a broken `TypedArray.prototype.subarray` function which returns arrays of
  30091. * incorrect length in some situations.
  30092. * We detect these buggy browsers and set `Buffer.TYPED_ARRAY_SUPPORT` to `false` so they
  30093. * get the Object implementation, which is slower but behaves correctly.
  30094. */
  30095. Buffer.TYPED_ARRAY_SUPPORT = global.TYPED_ARRAY_SUPPORT !== undefined
  30096. ? global.TYPED_ARRAY_SUPPORT
  30097. : typedArraySupport()
  30098. /*
  30099. * Export kMaxLength after typed array support is determined.
  30100. */
  30101. exports.kMaxLength = kMaxLength()
  30102. function typedArraySupport () {
  30103. try {
  30104. var arr = new Uint8Array(1)
  30105. arr.__proto__ = {__proto__: Uint8Array.prototype, foo: function () { return 42 }}
  30106. return arr.foo() === 42 && // typed array instances can be augmented
  30107. typeof arr.subarray === 'function' && // chrome 9-10 lack `subarray`
  30108. arr.subarray(1, 1).byteLength === 0 // ie10 has broken `subarray`
  30109. } catch (e) {
  30110. return false
  30111. }
  30112. }
  30113. function kMaxLength () {
  30114. return Buffer.TYPED_ARRAY_SUPPORT
  30115. ? 0x7fffffff
  30116. : 0x3fffffff
  30117. }
  30118. function createBuffer (that, length) {
  30119. if (kMaxLength() < length) {
  30120. throw new RangeError('Invalid typed array length')
  30121. }
  30122. if (Buffer.TYPED_ARRAY_SUPPORT) {
  30123. // Return an augmented `Uint8Array` instance, for best performance
  30124. that = new Uint8Array(length)
  30125. that.__proto__ = Buffer.prototype
  30126. } else {
  30127. // Fallback: Return an object instance of the Buffer class
  30128. if (that === null) {
  30129. that = new Buffer(length)
  30130. }
  30131. that.length = length
  30132. }
  30133. return that
  30134. }
  30135. /**
  30136. * The Buffer constructor returns instances of `Uint8Array` that have their
  30137. * prototype changed to `Buffer.prototype`. Furthermore, `Buffer` is a subclass of
  30138. * `Uint8Array`, so the returned instances will have all the node `Buffer` methods
  30139. * and the `Uint8Array` methods. Square bracket notation works as expected -- it
  30140. * returns a single octet.
  30141. *
  30142. * The `Uint8Array` prototype remains unmodified.
  30143. */
  30144. function Buffer (arg, encodingOrOffset, length) {
  30145. if (!Buffer.TYPED_ARRAY_SUPPORT && !(this instanceof Buffer)) {
  30146. return new Buffer(arg, encodingOrOffset, length)
  30147. }
  30148. // Common case.
  30149. if (typeof arg === 'number') {
  30150. if (typeof encodingOrOffset === 'string') {
  30151. throw new Error(
  30152. 'If encoding is specified then the first argument must be a string'
  30153. )
  30154. }
  30155. return allocUnsafe(this, arg)
  30156. }
  30157. return from(this, arg, encodingOrOffset, length)
  30158. }
  30159. Buffer.poolSize = 8192 // not used by this implementation
  30160. // TODO: Legacy, not needed anymore. Remove in next major version.
  30161. Buffer._augment = function (arr) {
  30162. arr.__proto__ = Buffer.prototype
  30163. return arr
  30164. }
  30165. function from (that, value, encodingOrOffset, length) {
  30166. if (typeof value === 'number') {
  30167. throw new TypeError('"value" argument must not be a number')
  30168. }
  30169. if (typeof ArrayBuffer !== 'undefined' && value instanceof ArrayBuffer) {
  30170. return fromArrayBuffer(that, value, encodingOrOffset, length)
  30171. }
  30172. if (typeof value === 'string') {
  30173. return fromString(that, value, encodingOrOffset)
  30174. }
  30175. return fromObject(that, value)
  30176. }
  30177. /**
  30178. * Functionally equivalent to Buffer(arg, encoding) but throws a TypeError
  30179. * if value is a number.
  30180. * Buffer.from(str[, encoding])
  30181. * Buffer.from(array)
  30182. * Buffer.from(buffer)
  30183. * Buffer.from(arrayBuffer[, byteOffset[, length]])
  30184. **/
  30185. Buffer.from = function (value, encodingOrOffset, length) {
  30186. return from(null, value, encodingOrOffset, length)
  30187. }
  30188. if (Buffer.TYPED_ARRAY_SUPPORT) {
  30189. Buffer.prototype.__proto__ = Uint8Array.prototype
  30190. Buffer.__proto__ = Uint8Array
  30191. if (typeof Symbol !== 'undefined' && Symbol.species &&
  30192. Buffer[Symbol.species] === Buffer) {
  30193. // Fix subarray() in ES2016. See: https://github.com/feross/buffer/pull/97
  30194. Object.defineProperty(Buffer, Symbol.species, {
  30195. value: null,
  30196. configurable: true
  30197. })
  30198. }
  30199. }
  30200. function assertSize (size) {
  30201. if (typeof size !== 'number') {
  30202. throw new TypeError('"size" argument must be a number')
  30203. } else if (size < 0) {
  30204. throw new RangeError('"size" argument must not be negative')
  30205. }
  30206. }
  30207. function alloc (that, size, fill, encoding) {
  30208. assertSize(size)
  30209. if (size <= 0) {
  30210. return createBuffer(that, size)
  30211. }
  30212. if (fill !== undefined) {
  30213. // Only pay attention to encoding if it's a string. This
  30214. // prevents accidentally sending in a number that would
  30215. // be interpretted as a start offset.
  30216. return typeof encoding === 'string'
  30217. ? createBuffer(that, size).fill(fill, encoding)
  30218. : createBuffer(that, size).fill(fill)
  30219. }
  30220. return createBuffer(that, size)
  30221. }
  30222. /**
  30223. * Creates a new filled Buffer instance.
  30224. * alloc(size[, fill[, encoding]])
  30225. **/
  30226. Buffer.alloc = function (size, fill, encoding) {
  30227. return alloc(null, size, fill, encoding)
  30228. }
  30229. function allocUnsafe (that, size) {
  30230. assertSize(size)
  30231. that = createBuffer(that, size < 0 ? 0 : checked(size) | 0)
  30232. if (!Buffer.TYPED_ARRAY_SUPPORT) {
  30233. for (var i = 0; i < size; ++i) {
  30234. that[i] = 0
  30235. }
  30236. }
  30237. return that
  30238. }
  30239. /**
  30240. * Equivalent to Buffer(num), by default creates a non-zero-filled Buffer instance.
  30241. * */
  30242. Buffer.allocUnsafe = function (size) {
  30243. return allocUnsafe(null, size)
  30244. }
  30245. /**
  30246. * Equivalent to SlowBuffer(num), by default creates a non-zero-filled Buffer instance.
  30247. */
  30248. Buffer.allocUnsafeSlow = function (size) {
  30249. return allocUnsafe(null, size)
  30250. }
  30251. function fromString (that, string, encoding) {
  30252. if (typeof encoding !== 'string' || encoding === '') {
  30253. encoding = 'utf8'
  30254. }
  30255. if (!Buffer.isEncoding(encoding)) {
  30256. throw new TypeError('"encoding" must be a valid string encoding')
  30257. }
  30258. var length = byteLength(string, encoding) | 0
  30259. that = createBuffer(that, length)
  30260. var actual = that.write(string, encoding)
  30261. if (actual !== length) {
  30262. // Writing a hex string, for example, that contains invalid characters will
  30263. // cause everything after the first invalid character to be ignored. (e.g.
  30264. // 'abxxcd' will be treated as 'ab')
  30265. that = that.slice(0, actual)
  30266. }
  30267. return that
  30268. }
  30269. function fromArrayLike (that, array) {
  30270. var length = array.length < 0 ? 0 : checked(array.length) | 0
  30271. that = createBuffer(that, length)
  30272. for (var i = 0; i < length; i += 1) {
  30273. that[i] = array[i] & 255
  30274. }
  30275. return that
  30276. }
  30277. function fromArrayBuffer (that, array, byteOffset, length) {
  30278. array.byteLength // this throws if `array` is not a valid ArrayBuffer
  30279. if (byteOffset < 0 || array.byteLength < byteOffset) {
  30280. throw new RangeError('\'offset\' is out of bounds')
  30281. }
  30282. if (array.byteLength < byteOffset + (length || 0)) {
  30283. throw new RangeError('\'length\' is out of bounds')
  30284. }
  30285. if (byteOffset === undefined && length === undefined) {
  30286. array = new Uint8Array(array)
  30287. } else if (length === undefined) {
  30288. array = new Uint8Array(array, byteOffset)
  30289. } else {
  30290. array = new Uint8Array(array, byteOffset, length)
  30291. }
  30292. if (Buffer.TYPED_ARRAY_SUPPORT) {
  30293. // Return an augmented `Uint8Array` instance, for best performance
  30294. that = array
  30295. that.__proto__ = Buffer.prototype
  30296. } else {
  30297. // Fallback: Return an object instance of the Buffer class
  30298. that = fromArrayLike(that, array)
  30299. }
  30300. return that
  30301. }
  30302. function fromObject (that, obj) {
  30303. if (Buffer.isBuffer(obj)) {
  30304. var len = checked(obj.length) | 0
  30305. that = createBuffer(that, len)
  30306. if (that.length === 0) {
  30307. return that
  30308. }
  30309. obj.copy(that, 0, 0, len)
  30310. return that
  30311. }
  30312. if (obj) {
  30313. if ((typeof ArrayBuffer !== 'undefined' &&
  30314. obj.buffer instanceof ArrayBuffer) || 'length' in obj) {
  30315. if (typeof obj.length !== 'number' || isnan(obj.length)) {
  30316. return createBuffer(that, 0)
  30317. }
  30318. return fromArrayLike(that, obj)
  30319. }
  30320. if (obj.type === 'Buffer' && isArray(obj.data)) {
  30321. return fromArrayLike(that, obj.data)
  30322. }
  30323. }
  30324. throw new TypeError('First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.')
  30325. }
  30326. function checked (length) {
  30327. // Note: cannot use `length < kMaxLength()` here because that fails when
  30328. // length is NaN (which is otherwise coerced to zero.)
  30329. if (length >= kMaxLength()) {
  30330. throw new RangeError('Attempt to allocate Buffer larger than maximum ' +
  30331. 'size: 0x' + kMaxLength().toString(16) + ' bytes')
  30332. }
  30333. return length | 0
  30334. }
  30335. function SlowBuffer (length) {
  30336. if (+length != length) { // eslint-disable-line eqeqeq
  30337. length = 0
  30338. }
  30339. return Buffer.alloc(+length)
  30340. }
  30341. Buffer.isBuffer = function isBuffer (b) {
  30342. return !!(b != null && b._isBuffer)
  30343. }
  30344. Buffer.compare = function compare (a, b) {
  30345. if (!Buffer.isBuffer(a) || !Buffer.isBuffer(b)) {
  30346. throw new TypeError('Arguments must be Buffers')
  30347. }
  30348. if (a === b) return 0
  30349. var x = a.length
  30350. var y = b.length
  30351. for (var i = 0, len = Math.min(x, y); i < len; ++i) {
  30352. if (a[i] !== b[i]) {
  30353. x = a[i]
  30354. y = b[i]
  30355. break
  30356. }
  30357. }
  30358. if (x < y) return -1
  30359. if (y < x) return 1
  30360. return 0
  30361. }
  30362. Buffer.isEncoding = function isEncoding (encoding) {
  30363. switch (String(encoding).toLowerCase()) {
  30364. case 'hex':
  30365. case 'utf8':
  30366. case 'utf-8':
  30367. case 'ascii':
  30368. case 'latin1':
  30369. case 'binary':
  30370. case 'base64':
  30371. case 'ucs2':
  30372. case 'ucs-2':
  30373. case 'utf16le':
  30374. case 'utf-16le':
  30375. return true
  30376. default:
  30377. return false
  30378. }
  30379. }
  30380. Buffer.concat = function concat (list, length) {
  30381. if (!isArray(list)) {
  30382. throw new TypeError('"list" argument must be an Array of Buffers')
  30383. }
  30384. if (list.length === 0) {
  30385. return Buffer.alloc(0)
  30386. }
  30387. var i
  30388. if (length === undefined) {
  30389. length = 0
  30390. for (i = 0; i < list.length; ++i) {
  30391. length += list[i].length
  30392. }
  30393. }
  30394. var buffer = Buffer.allocUnsafe(length)
  30395. var pos = 0
  30396. for (i = 0; i < list.length; ++i) {
  30397. var buf = list[i]
  30398. if (!Buffer.isBuffer(buf)) {
  30399. throw new TypeError('"list" argument must be an Array of Buffers')
  30400. }
  30401. buf.copy(buffer, pos)
  30402. pos += buf.length
  30403. }
  30404. return buffer
  30405. }
  30406. function byteLength (string, encoding) {
  30407. if (Buffer.isBuffer(string)) {
  30408. return string.length
  30409. }
  30410. if (typeof ArrayBuffer !== 'undefined' && typeof ArrayBuffer.isView === 'function' &&
  30411. (ArrayBuffer.isView(string) || string instanceof ArrayBuffer)) {
  30412. return string.byteLength
  30413. }
  30414. if (typeof string !== 'string') {
  30415. string = '' + string
  30416. }
  30417. var len = string.length
  30418. if (len === 0) return 0
  30419. // Use a for loop to avoid recursion
  30420. var loweredCase = false
  30421. for (;;) {
  30422. switch (encoding) {
  30423. case 'ascii':
  30424. case 'latin1':
  30425. case 'binary':
  30426. return len
  30427. case 'utf8':
  30428. case 'utf-8':
  30429. case undefined:
  30430. return utf8ToBytes(string).length
  30431. case 'ucs2':
  30432. case 'ucs-2':
  30433. case 'utf16le':
  30434. case 'utf-16le':
  30435. return len * 2
  30436. case 'hex':
  30437. return len >>> 1
  30438. case 'base64':
  30439. return base64ToBytes(string).length
  30440. default:
  30441. if (loweredCase) return utf8ToBytes(string).length // assume utf8
  30442. encoding = ('' + encoding).toLowerCase()
  30443. loweredCase = true
  30444. }
  30445. }
  30446. }
  30447. Buffer.byteLength = byteLength
  30448. function slowToString (encoding, start, end) {
  30449. var loweredCase = false
  30450. // No need to verify that "this.length <= MAX_UINT32" since it's a read-only
  30451. // property of a typed array.
  30452. // This behaves neither like String nor Uint8Array in that we set start/end
  30453. // to their upper/lower bounds if the value passed is out of range.
  30454. // undefined is handled specially as per ECMA-262 6th Edition,
  30455. // Section 13.3.3.7 Runtime Semantics: KeyedBindingInitialization.
  30456. if (start === undefined || start < 0) {
  30457. start = 0
  30458. }
  30459. // Return early if start > this.length. Done here to prevent potential uint32
  30460. // coercion fail below.
  30461. if (start > this.length) {
  30462. return ''
  30463. }
  30464. if (end === undefined || end > this.length) {
  30465. end = this.length
  30466. }
  30467. if (end <= 0) {
  30468. return ''
  30469. }
  30470. // Force coersion to uint32. This will also coerce falsey/NaN values to 0.
  30471. end >>>= 0
  30472. start >>>= 0
  30473. if (end <= start) {
  30474. return ''
  30475. }
  30476. if (!encoding) encoding = 'utf8'
  30477. while (true) {
  30478. switch (encoding) {
  30479. case 'hex':
  30480. return hexSlice(this, start, end)
  30481. case 'utf8':
  30482. case 'utf-8':
  30483. return utf8Slice(this, start, end)
  30484. case 'ascii':
  30485. return asciiSlice(this, start, end)
  30486. case 'latin1':
  30487. case 'binary':
  30488. return latin1Slice(this, start, end)
  30489. case 'base64':
  30490. return base64Slice(this, start, end)
  30491. case 'ucs2':
  30492. case 'ucs-2':
  30493. case 'utf16le':
  30494. case 'utf-16le':
  30495. return utf16leSlice(this, start, end)
  30496. default:
  30497. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  30498. encoding = (encoding + '').toLowerCase()
  30499. loweredCase = true
  30500. }
  30501. }
  30502. }
  30503. // The property is used by `Buffer.isBuffer` and `is-buffer` (in Safari 5-7) to detect
  30504. // Buffer instances.
  30505. Buffer.prototype._isBuffer = true
  30506. function swap (b, n, m) {
  30507. var i = b[n]
  30508. b[n] = b[m]
  30509. b[m] = i
  30510. }
  30511. Buffer.prototype.swap16 = function swap16 () {
  30512. var len = this.length
  30513. if (len % 2 !== 0) {
  30514. throw new RangeError('Buffer size must be a multiple of 16-bits')
  30515. }
  30516. for (var i = 0; i < len; i += 2) {
  30517. swap(this, i, i + 1)
  30518. }
  30519. return this
  30520. }
  30521. Buffer.prototype.swap32 = function swap32 () {
  30522. var len = this.length
  30523. if (len % 4 !== 0) {
  30524. throw new RangeError('Buffer size must be a multiple of 32-bits')
  30525. }
  30526. for (var i = 0; i < len; i += 4) {
  30527. swap(this, i, i + 3)
  30528. swap(this, i + 1, i + 2)
  30529. }
  30530. return this
  30531. }
  30532. Buffer.prototype.swap64 = function swap64 () {
  30533. var len = this.length
  30534. if (len % 8 !== 0) {
  30535. throw new RangeError('Buffer size must be a multiple of 64-bits')
  30536. }
  30537. for (var i = 0; i < len; i += 8) {
  30538. swap(this, i, i + 7)
  30539. swap(this, i + 1, i + 6)
  30540. swap(this, i + 2, i + 5)
  30541. swap(this, i + 3, i + 4)
  30542. }
  30543. return this
  30544. }
  30545. Buffer.prototype.toString = function toString () {
  30546. var length = this.length | 0
  30547. if (length === 0) return ''
  30548. if (arguments.length === 0) return utf8Slice(this, 0, length)
  30549. return slowToString.apply(this, arguments)
  30550. }
  30551. Buffer.prototype.equals = function equals (b) {
  30552. if (!Buffer.isBuffer(b)) throw new TypeError('Argument must be a Buffer')
  30553. if (this === b) return true
  30554. return Buffer.compare(this, b) === 0
  30555. }
  30556. Buffer.prototype.inspect = function inspect () {
  30557. var str = ''
  30558. var max = exports.INSPECT_MAX_BYTES
  30559. if (this.length > 0) {
  30560. str = this.toString('hex', 0, max).match(/.{2}/g).join(' ')
  30561. if (this.length > max) str += ' ... '
  30562. }
  30563. return '<Buffer ' + str + '>'
  30564. }
  30565. Buffer.prototype.compare = function compare (target, start, end, thisStart, thisEnd) {
  30566. if (!Buffer.isBuffer(target)) {
  30567. throw new TypeError('Argument must be a Buffer')
  30568. }
  30569. if (start === undefined) {
  30570. start = 0
  30571. }
  30572. if (end === undefined) {
  30573. end = target ? target.length : 0
  30574. }
  30575. if (thisStart === undefined) {
  30576. thisStart = 0
  30577. }
  30578. if (thisEnd === undefined) {
  30579. thisEnd = this.length
  30580. }
  30581. if (start < 0 || end > target.length || thisStart < 0 || thisEnd > this.length) {
  30582. throw new RangeError('out of range index')
  30583. }
  30584. if (thisStart >= thisEnd && start >= end) {
  30585. return 0
  30586. }
  30587. if (thisStart >= thisEnd) {
  30588. return -1
  30589. }
  30590. if (start >= end) {
  30591. return 1
  30592. }
  30593. start >>>= 0
  30594. end >>>= 0
  30595. thisStart >>>= 0
  30596. thisEnd >>>= 0
  30597. if (this === target) return 0
  30598. var x = thisEnd - thisStart
  30599. var y = end - start
  30600. var len = Math.min(x, y)
  30601. var thisCopy = this.slice(thisStart, thisEnd)
  30602. var targetCopy = target.slice(start, end)
  30603. for (var i = 0; i < len; ++i) {
  30604. if (thisCopy[i] !== targetCopy[i]) {
  30605. x = thisCopy[i]
  30606. y = targetCopy[i]
  30607. break
  30608. }
  30609. }
  30610. if (x < y) return -1
  30611. if (y < x) return 1
  30612. return 0
  30613. }
  30614. // Finds either the first index of `val` in `buffer` at offset >= `byteOffset`,
  30615. // OR the last index of `val` in `buffer` at offset <= `byteOffset`.
  30616. //
  30617. // Arguments:
  30618. // - buffer - a Buffer to search
  30619. // - val - a string, Buffer, or number
  30620. // - byteOffset - an index into `buffer`; will be clamped to an int32
  30621. // - encoding - an optional encoding, relevant is val is a string
  30622. // - dir - true for indexOf, false for lastIndexOf
  30623. function bidirectionalIndexOf (buffer, val, byteOffset, encoding, dir) {
  30624. // Empty buffer means no match
  30625. if (buffer.length === 0) return -1
  30626. // Normalize byteOffset
  30627. if (typeof byteOffset === 'string') {
  30628. encoding = byteOffset
  30629. byteOffset = 0
  30630. } else if (byteOffset > 0x7fffffff) {
  30631. byteOffset = 0x7fffffff
  30632. } else if (byteOffset < -0x80000000) {
  30633. byteOffset = -0x80000000
  30634. }
  30635. byteOffset = +byteOffset // Coerce to Number.
  30636. if (isNaN(byteOffset)) {
  30637. // byteOffset: it it's undefined, null, NaN, "foo", etc, search whole buffer
  30638. byteOffset = dir ? 0 : (buffer.length - 1)
  30639. }
  30640. // Normalize byteOffset: negative offsets start from the end of the buffer
  30641. if (byteOffset < 0) byteOffset = buffer.length + byteOffset
  30642. if (byteOffset >= buffer.length) {
  30643. if (dir) return -1
  30644. else byteOffset = buffer.length - 1
  30645. } else if (byteOffset < 0) {
  30646. if (dir) byteOffset = 0
  30647. else return -1
  30648. }
  30649. // Normalize val
  30650. if (typeof val === 'string') {
  30651. val = Buffer.from(val, encoding)
  30652. }
  30653. // Finally, search either indexOf (if dir is true) or lastIndexOf
  30654. if (Buffer.isBuffer(val)) {
  30655. // Special case: looking for empty string/buffer always fails
  30656. if (val.length === 0) {
  30657. return -1
  30658. }
  30659. return arrayIndexOf(buffer, val, byteOffset, encoding, dir)
  30660. } else if (typeof val === 'number') {
  30661. val = val & 0xFF // Search for a byte value [0-255]
  30662. if (Buffer.TYPED_ARRAY_SUPPORT &&
  30663. typeof Uint8Array.prototype.indexOf === 'function') {
  30664. if (dir) {
  30665. return Uint8Array.prototype.indexOf.call(buffer, val, byteOffset)
  30666. } else {
  30667. return Uint8Array.prototype.lastIndexOf.call(buffer, val, byteOffset)
  30668. }
  30669. }
  30670. return arrayIndexOf(buffer, [ val ], byteOffset, encoding, dir)
  30671. }
  30672. throw new TypeError('val must be string, number or Buffer')
  30673. }
  30674. function arrayIndexOf (arr, val, byteOffset, encoding, dir) {
  30675. var indexSize = 1
  30676. var arrLength = arr.length
  30677. var valLength = val.length
  30678. if (encoding !== undefined) {
  30679. encoding = String(encoding).toLowerCase()
  30680. if (encoding === 'ucs2' || encoding === 'ucs-2' ||
  30681. encoding === 'utf16le' || encoding === 'utf-16le') {
  30682. if (arr.length < 2 || val.length < 2) {
  30683. return -1
  30684. }
  30685. indexSize = 2
  30686. arrLength /= 2
  30687. valLength /= 2
  30688. byteOffset /= 2
  30689. }
  30690. }
  30691. function read (buf, i) {
  30692. if (indexSize === 1) {
  30693. return buf[i]
  30694. } else {
  30695. return buf.readUInt16BE(i * indexSize)
  30696. }
  30697. }
  30698. var i
  30699. if (dir) {
  30700. var foundIndex = -1
  30701. for (i = byteOffset; i < arrLength; i++) {
  30702. if (read(arr, i) === read(val, foundIndex === -1 ? 0 : i - foundIndex)) {
  30703. if (foundIndex === -1) foundIndex = i
  30704. if (i - foundIndex + 1 === valLength) return foundIndex * indexSize
  30705. } else {
  30706. if (foundIndex !== -1) i -= i - foundIndex
  30707. foundIndex = -1
  30708. }
  30709. }
  30710. } else {
  30711. if (byteOffset + valLength > arrLength) byteOffset = arrLength - valLength
  30712. for (i = byteOffset; i >= 0; i--) {
  30713. var found = true
  30714. for (var j = 0; j < valLength; j++) {
  30715. if (read(arr, i + j) !== read(val, j)) {
  30716. found = false
  30717. break
  30718. }
  30719. }
  30720. if (found) return i
  30721. }
  30722. }
  30723. return -1
  30724. }
  30725. Buffer.prototype.includes = function includes (val, byteOffset, encoding) {
  30726. return this.indexOf(val, byteOffset, encoding) !== -1
  30727. }
  30728. Buffer.prototype.indexOf = function indexOf (val, byteOffset, encoding) {
  30729. return bidirectionalIndexOf(this, val, byteOffset, encoding, true)
  30730. }
  30731. Buffer.prototype.lastIndexOf = function lastIndexOf (val, byteOffset, encoding) {
  30732. return bidirectionalIndexOf(this, val, byteOffset, encoding, false)
  30733. }
  30734. function hexWrite (buf, string, offset, length) {
  30735. offset = Number(offset) || 0
  30736. var remaining = buf.length - offset
  30737. if (!length) {
  30738. length = remaining
  30739. } else {
  30740. length = Number(length)
  30741. if (length > remaining) {
  30742. length = remaining
  30743. }
  30744. }
  30745. // must be an even number of digits
  30746. var strLen = string.length
  30747. if (strLen % 2 !== 0) throw new TypeError('Invalid hex string')
  30748. if (length > strLen / 2) {
  30749. length = strLen / 2
  30750. }
  30751. for (var i = 0; i < length; ++i) {
  30752. var parsed = parseInt(string.substr(i * 2, 2), 16)
  30753. if (isNaN(parsed)) return i
  30754. buf[offset + i] = parsed
  30755. }
  30756. return i
  30757. }
  30758. function utf8Write (buf, string, offset, length) {
  30759. return blitBuffer(utf8ToBytes(string, buf.length - offset), buf, offset, length)
  30760. }
  30761. function asciiWrite (buf, string, offset, length) {
  30762. return blitBuffer(asciiToBytes(string), buf, offset, length)
  30763. }
  30764. function latin1Write (buf, string, offset, length) {
  30765. return asciiWrite(buf, string, offset, length)
  30766. }
  30767. function base64Write (buf, string, offset, length) {
  30768. return blitBuffer(base64ToBytes(string), buf, offset, length)
  30769. }
  30770. function ucs2Write (buf, string, offset, length) {
  30771. return blitBuffer(utf16leToBytes(string, buf.length - offset), buf, offset, length)
  30772. }
  30773. Buffer.prototype.write = function write (string, offset, length, encoding) {
  30774. // Buffer#write(string)
  30775. if (offset === undefined) {
  30776. encoding = 'utf8'
  30777. length = this.length
  30778. offset = 0
  30779. // Buffer#write(string, encoding)
  30780. } else if (length === undefined && typeof offset === 'string') {
  30781. encoding = offset
  30782. length = this.length
  30783. offset = 0
  30784. // Buffer#write(string, offset[, length][, encoding])
  30785. } else if (isFinite(offset)) {
  30786. offset = offset | 0
  30787. if (isFinite(length)) {
  30788. length = length | 0
  30789. if (encoding === undefined) encoding = 'utf8'
  30790. } else {
  30791. encoding = length
  30792. length = undefined
  30793. }
  30794. // legacy write(string, encoding, offset, length) - remove in v0.13
  30795. } else {
  30796. throw new Error(
  30797. 'Buffer.write(string, encoding, offset[, length]) is no longer supported'
  30798. )
  30799. }
  30800. var remaining = this.length - offset
  30801. if (length === undefined || length > remaining) length = remaining
  30802. if ((string.length > 0 && (length < 0 || offset < 0)) || offset > this.length) {
  30803. throw new RangeError('Attempt to write outside buffer bounds')
  30804. }
  30805. if (!encoding) encoding = 'utf8'
  30806. var loweredCase = false
  30807. for (;;) {
  30808. switch (encoding) {
  30809. case 'hex':
  30810. return hexWrite(this, string, offset, length)
  30811. case 'utf8':
  30812. case 'utf-8':
  30813. return utf8Write(this, string, offset, length)
  30814. case 'ascii':
  30815. return asciiWrite(this, string, offset, length)
  30816. case 'latin1':
  30817. case 'binary':
  30818. return latin1Write(this, string, offset, length)
  30819. case 'base64':
  30820. // Warning: maxLength not taken into account in base64Write
  30821. return base64Write(this, string, offset, length)
  30822. case 'ucs2':
  30823. case 'ucs-2':
  30824. case 'utf16le':
  30825. case 'utf-16le':
  30826. return ucs2Write(this, string, offset, length)
  30827. default:
  30828. if (loweredCase) throw new TypeError('Unknown encoding: ' + encoding)
  30829. encoding = ('' + encoding).toLowerCase()
  30830. loweredCase = true
  30831. }
  30832. }
  30833. }
  30834. Buffer.prototype.toJSON = function toJSON () {
  30835. return {
  30836. type: 'Buffer',
  30837. data: Array.prototype.slice.call(this._arr || this, 0)
  30838. }
  30839. }
  30840. function base64Slice (buf, start, end) {
  30841. if (start === 0 && end === buf.length) {
  30842. return base64.fromByteArray(buf)
  30843. } else {
  30844. return base64.fromByteArray(buf.slice(start, end))
  30845. }
  30846. }
  30847. function utf8Slice (buf, start, end) {
  30848. end = Math.min(buf.length, end)
  30849. var res = []
  30850. var i = start
  30851. while (i < end) {
  30852. var firstByte = buf[i]
  30853. var codePoint = null
  30854. var bytesPerSequence = (firstByte > 0xEF) ? 4
  30855. : (firstByte > 0xDF) ? 3
  30856. : (firstByte > 0xBF) ? 2
  30857. : 1
  30858. if (i + bytesPerSequence <= end) {
  30859. var secondByte, thirdByte, fourthByte, tempCodePoint
  30860. switch (bytesPerSequence) {
  30861. case 1:
  30862. if (firstByte < 0x80) {
  30863. codePoint = firstByte
  30864. }
  30865. break
  30866. case 2:
  30867. secondByte = buf[i + 1]
  30868. if ((secondByte & 0xC0) === 0x80) {
  30869. tempCodePoint = (firstByte & 0x1F) << 0x6 | (secondByte & 0x3F)
  30870. if (tempCodePoint > 0x7F) {
  30871. codePoint = tempCodePoint
  30872. }
  30873. }
  30874. break
  30875. case 3:
  30876. secondByte = buf[i + 1]
  30877. thirdByte = buf[i + 2]
  30878. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80) {
  30879. tempCodePoint = (firstByte & 0xF) << 0xC | (secondByte & 0x3F) << 0x6 | (thirdByte & 0x3F)
  30880. if (tempCodePoint > 0x7FF && (tempCodePoint < 0xD800 || tempCodePoint > 0xDFFF)) {
  30881. codePoint = tempCodePoint
  30882. }
  30883. }
  30884. break
  30885. case 4:
  30886. secondByte = buf[i + 1]
  30887. thirdByte = buf[i + 2]
  30888. fourthByte = buf[i + 3]
  30889. if ((secondByte & 0xC0) === 0x80 && (thirdByte & 0xC0) === 0x80 && (fourthByte & 0xC0) === 0x80) {
  30890. tempCodePoint = (firstByte & 0xF) << 0x12 | (secondByte & 0x3F) << 0xC | (thirdByte & 0x3F) << 0x6 | (fourthByte & 0x3F)
  30891. if (tempCodePoint > 0xFFFF && tempCodePoint < 0x110000) {
  30892. codePoint = tempCodePoint
  30893. }
  30894. }
  30895. }
  30896. }
  30897. if (codePoint === null) {
  30898. // we did not generate a valid codePoint so insert a
  30899. // replacement char (U+FFFD) and advance only 1 byte
  30900. codePoint = 0xFFFD
  30901. bytesPerSequence = 1
  30902. } else if (codePoint > 0xFFFF) {
  30903. // encode to utf16 (surrogate pair dance)
  30904. codePoint -= 0x10000
  30905. res.push(codePoint >>> 10 & 0x3FF | 0xD800)
  30906. codePoint = 0xDC00 | codePoint & 0x3FF
  30907. }
  30908. res.push(codePoint)
  30909. i += bytesPerSequence
  30910. }
  30911. return decodeCodePointsArray(res)
  30912. }
  30913. // Based on http://stackoverflow.com/a/22747272/680742, the browser with
  30914. // the lowest limit is Chrome, with 0x10000 args.
  30915. // We go 1 magnitude less, for safety
  30916. var MAX_ARGUMENTS_LENGTH = 0x1000
  30917. function decodeCodePointsArray (codePoints) {
  30918. var len = codePoints.length
  30919. if (len <= MAX_ARGUMENTS_LENGTH) {
  30920. return String.fromCharCode.apply(String, codePoints) // avoid extra slice()
  30921. }
  30922. // Decode in chunks to avoid "call stack size exceeded".
  30923. var res = ''
  30924. var i = 0
  30925. while (i < len) {
  30926. res += String.fromCharCode.apply(
  30927. String,
  30928. codePoints.slice(i, i += MAX_ARGUMENTS_LENGTH)
  30929. )
  30930. }
  30931. return res
  30932. }
  30933. function asciiSlice (buf, start, end) {
  30934. var ret = ''
  30935. end = Math.min(buf.length, end)
  30936. for (var i = start; i < end; ++i) {
  30937. ret += String.fromCharCode(buf[i] & 0x7F)
  30938. }
  30939. return ret
  30940. }
  30941. function latin1Slice (buf, start, end) {
  30942. var ret = ''
  30943. end = Math.min(buf.length, end)
  30944. for (var i = start; i < end; ++i) {
  30945. ret += String.fromCharCode(buf[i])
  30946. }
  30947. return ret
  30948. }
  30949. function hexSlice (buf, start, end) {
  30950. var len = buf.length
  30951. if (!start || start < 0) start = 0
  30952. if (!end || end < 0 || end > len) end = len
  30953. var out = ''
  30954. for (var i = start; i < end; ++i) {
  30955. out += toHex(buf[i])
  30956. }
  30957. return out
  30958. }
  30959. function utf16leSlice (buf, start, end) {
  30960. var bytes = buf.slice(start, end)
  30961. var res = ''
  30962. for (var i = 0; i < bytes.length; i += 2) {
  30963. res += String.fromCharCode(bytes[i] + bytes[i + 1] * 256)
  30964. }
  30965. return res
  30966. }
  30967. Buffer.prototype.slice = function slice (start, end) {
  30968. var len = this.length
  30969. start = ~~start
  30970. end = end === undefined ? len : ~~end
  30971. if (start < 0) {
  30972. start += len
  30973. if (start < 0) start = 0
  30974. } else if (start > len) {
  30975. start = len
  30976. }
  30977. if (end < 0) {
  30978. end += len
  30979. if (end < 0) end = 0
  30980. } else if (end > len) {
  30981. end = len
  30982. }
  30983. if (end < start) end = start
  30984. var newBuf
  30985. if (Buffer.TYPED_ARRAY_SUPPORT) {
  30986. newBuf = this.subarray(start, end)
  30987. newBuf.__proto__ = Buffer.prototype
  30988. } else {
  30989. var sliceLen = end - start
  30990. newBuf = new Buffer(sliceLen, undefined)
  30991. for (var i = 0; i < sliceLen; ++i) {
  30992. newBuf[i] = this[i + start]
  30993. }
  30994. }
  30995. return newBuf
  30996. }
  30997. /*
  30998. * Need to make sure that buffer isn't trying to write out of bounds.
  30999. */
  31000. function checkOffset (offset, ext, length) {
  31001. if ((offset % 1) !== 0 || offset < 0) throw new RangeError('offset is not uint')
  31002. if (offset + ext > length) throw new RangeError('Trying to access beyond buffer length')
  31003. }
  31004. Buffer.prototype.readUIntLE = function readUIntLE (offset, byteLength, noAssert) {
  31005. offset = offset | 0
  31006. byteLength = byteLength | 0
  31007. if (!noAssert) checkOffset(offset, byteLength, this.length)
  31008. var val = this[offset]
  31009. var mul = 1
  31010. var i = 0
  31011. while (++i < byteLength && (mul *= 0x100)) {
  31012. val += this[offset + i] * mul
  31013. }
  31014. return val
  31015. }
  31016. Buffer.prototype.readUIntBE = function readUIntBE (offset, byteLength, noAssert) {
  31017. offset = offset | 0
  31018. byteLength = byteLength | 0
  31019. if (!noAssert) {
  31020. checkOffset(offset, byteLength, this.length)
  31021. }
  31022. var val = this[offset + --byteLength]
  31023. var mul = 1
  31024. while (byteLength > 0 && (mul *= 0x100)) {
  31025. val += this[offset + --byteLength] * mul
  31026. }
  31027. return val
  31028. }
  31029. Buffer.prototype.readUInt8 = function readUInt8 (offset, noAssert) {
  31030. if (!noAssert) checkOffset(offset, 1, this.length)
  31031. return this[offset]
  31032. }
  31033. Buffer.prototype.readUInt16LE = function readUInt16LE (offset, noAssert) {
  31034. if (!noAssert) checkOffset(offset, 2, this.length)
  31035. return this[offset] | (this[offset + 1] << 8)
  31036. }
  31037. Buffer.prototype.readUInt16BE = function readUInt16BE (offset, noAssert) {
  31038. if (!noAssert) checkOffset(offset, 2, this.length)
  31039. return (this[offset] << 8) | this[offset + 1]
  31040. }
  31041. Buffer.prototype.readUInt32LE = function readUInt32LE (offset, noAssert) {
  31042. if (!noAssert) checkOffset(offset, 4, this.length)
  31043. return ((this[offset]) |
  31044. (this[offset + 1] << 8) |
  31045. (this[offset + 2] << 16)) +
  31046. (this[offset + 3] * 0x1000000)
  31047. }
  31048. Buffer.prototype.readUInt32BE = function readUInt32BE (offset, noAssert) {
  31049. if (!noAssert) checkOffset(offset, 4, this.length)
  31050. return (this[offset] * 0x1000000) +
  31051. ((this[offset + 1] << 16) |
  31052. (this[offset + 2] << 8) |
  31053. this[offset + 3])
  31054. }
  31055. Buffer.prototype.readIntLE = function readIntLE (offset, byteLength, noAssert) {
  31056. offset = offset | 0
  31057. byteLength = byteLength | 0
  31058. if (!noAssert) checkOffset(offset, byteLength, this.length)
  31059. var val = this[offset]
  31060. var mul = 1
  31061. var i = 0
  31062. while (++i < byteLength && (mul *= 0x100)) {
  31063. val += this[offset + i] * mul
  31064. }
  31065. mul *= 0x80
  31066. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  31067. return val
  31068. }
  31069. Buffer.prototype.readIntBE = function readIntBE (offset, byteLength, noAssert) {
  31070. offset = offset | 0
  31071. byteLength = byteLength | 0
  31072. if (!noAssert) checkOffset(offset, byteLength, this.length)
  31073. var i = byteLength
  31074. var mul = 1
  31075. var val = this[offset + --i]
  31076. while (i > 0 && (mul *= 0x100)) {
  31077. val += this[offset + --i] * mul
  31078. }
  31079. mul *= 0x80
  31080. if (val >= mul) val -= Math.pow(2, 8 * byteLength)
  31081. return val
  31082. }
  31083. Buffer.prototype.readInt8 = function readInt8 (offset, noAssert) {
  31084. if (!noAssert) checkOffset(offset, 1, this.length)
  31085. if (!(this[offset] & 0x80)) return (this[offset])
  31086. return ((0xff - this[offset] + 1) * -1)
  31087. }
  31088. Buffer.prototype.readInt16LE = function readInt16LE (offset, noAssert) {
  31089. if (!noAssert) checkOffset(offset, 2, this.length)
  31090. var val = this[offset] | (this[offset + 1] << 8)
  31091. return (val & 0x8000) ? val | 0xFFFF0000 : val
  31092. }
  31093. Buffer.prototype.readInt16BE = function readInt16BE (offset, noAssert) {
  31094. if (!noAssert) checkOffset(offset, 2, this.length)
  31095. var val = this[offset + 1] | (this[offset] << 8)
  31096. return (val & 0x8000) ? val | 0xFFFF0000 : val
  31097. }
  31098. Buffer.prototype.readInt32LE = function readInt32LE (offset, noAssert) {
  31099. if (!noAssert) checkOffset(offset, 4, this.length)
  31100. return (this[offset]) |
  31101. (this[offset + 1] << 8) |
  31102. (this[offset + 2] << 16) |
  31103. (this[offset + 3] << 24)
  31104. }
  31105. Buffer.prototype.readInt32BE = function readInt32BE (offset, noAssert) {
  31106. if (!noAssert) checkOffset(offset, 4, this.length)
  31107. return (this[offset] << 24) |
  31108. (this[offset + 1] << 16) |
  31109. (this[offset + 2] << 8) |
  31110. (this[offset + 3])
  31111. }
  31112. Buffer.prototype.readFloatLE = function readFloatLE (offset, noAssert) {
  31113. if (!noAssert) checkOffset(offset, 4, this.length)
  31114. return ieee754.read(this, offset, true, 23, 4)
  31115. }
  31116. Buffer.prototype.readFloatBE = function readFloatBE (offset, noAssert) {
  31117. if (!noAssert) checkOffset(offset, 4, this.length)
  31118. return ieee754.read(this, offset, false, 23, 4)
  31119. }
  31120. Buffer.prototype.readDoubleLE = function readDoubleLE (offset, noAssert) {
  31121. if (!noAssert) checkOffset(offset, 8, this.length)
  31122. return ieee754.read(this, offset, true, 52, 8)
  31123. }
  31124. Buffer.prototype.readDoubleBE = function readDoubleBE (offset, noAssert) {
  31125. if (!noAssert) checkOffset(offset, 8, this.length)
  31126. return ieee754.read(this, offset, false, 52, 8)
  31127. }
  31128. function checkInt (buf, value, offset, ext, max, min) {
  31129. if (!Buffer.isBuffer(buf)) throw new TypeError('"buffer" argument must be a Buffer instance')
  31130. if (value > max || value < min) throw new RangeError('"value" argument is out of bounds')
  31131. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  31132. }
  31133. Buffer.prototype.writeUIntLE = function writeUIntLE (value, offset, byteLength, noAssert) {
  31134. value = +value
  31135. offset = offset | 0
  31136. byteLength = byteLength | 0
  31137. if (!noAssert) {
  31138. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  31139. checkInt(this, value, offset, byteLength, maxBytes, 0)
  31140. }
  31141. var mul = 1
  31142. var i = 0
  31143. this[offset] = value & 0xFF
  31144. while (++i < byteLength && (mul *= 0x100)) {
  31145. this[offset + i] = (value / mul) & 0xFF
  31146. }
  31147. return offset + byteLength
  31148. }
  31149. Buffer.prototype.writeUIntBE = function writeUIntBE (value, offset, byteLength, noAssert) {
  31150. value = +value
  31151. offset = offset | 0
  31152. byteLength = byteLength | 0
  31153. if (!noAssert) {
  31154. var maxBytes = Math.pow(2, 8 * byteLength) - 1
  31155. checkInt(this, value, offset, byteLength, maxBytes, 0)
  31156. }
  31157. var i = byteLength - 1
  31158. var mul = 1
  31159. this[offset + i] = value & 0xFF
  31160. while (--i >= 0 && (mul *= 0x100)) {
  31161. this[offset + i] = (value / mul) & 0xFF
  31162. }
  31163. return offset + byteLength
  31164. }
  31165. Buffer.prototype.writeUInt8 = function writeUInt8 (value, offset, noAssert) {
  31166. value = +value
  31167. offset = offset | 0
  31168. if (!noAssert) checkInt(this, value, offset, 1, 0xff, 0)
  31169. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  31170. this[offset] = (value & 0xff)
  31171. return offset + 1
  31172. }
  31173. function objectWriteUInt16 (buf, value, offset, littleEndian) {
  31174. if (value < 0) value = 0xffff + value + 1
  31175. for (var i = 0, j = Math.min(buf.length - offset, 2); i < j; ++i) {
  31176. buf[offset + i] = (value & (0xff << (8 * (littleEndian ? i : 1 - i)))) >>>
  31177. (littleEndian ? i : 1 - i) * 8
  31178. }
  31179. }
  31180. Buffer.prototype.writeUInt16LE = function writeUInt16LE (value, offset, noAssert) {
  31181. value = +value
  31182. offset = offset | 0
  31183. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  31184. if (Buffer.TYPED_ARRAY_SUPPORT) {
  31185. this[offset] = (value & 0xff)
  31186. this[offset + 1] = (value >>> 8)
  31187. } else {
  31188. objectWriteUInt16(this, value, offset, true)
  31189. }
  31190. return offset + 2
  31191. }
  31192. Buffer.prototype.writeUInt16BE = function writeUInt16BE (value, offset, noAssert) {
  31193. value = +value
  31194. offset = offset | 0
  31195. if (!noAssert) checkInt(this, value, offset, 2, 0xffff, 0)
  31196. if (Buffer.TYPED_ARRAY_SUPPORT) {
  31197. this[offset] = (value >>> 8)
  31198. this[offset + 1] = (value & 0xff)
  31199. } else {
  31200. objectWriteUInt16(this, value, offset, false)
  31201. }
  31202. return offset + 2
  31203. }
  31204. function objectWriteUInt32 (buf, value, offset, littleEndian) {
  31205. if (value < 0) value = 0xffffffff + value + 1
  31206. for (var i = 0, j = Math.min(buf.length - offset, 4); i < j; ++i) {
  31207. buf[offset + i] = (value >>> (littleEndian ? i : 3 - i) * 8) & 0xff
  31208. }
  31209. }
  31210. Buffer.prototype.writeUInt32LE = function writeUInt32LE (value, offset, noAssert) {
  31211. value = +value
  31212. offset = offset | 0
  31213. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  31214. if (Buffer.TYPED_ARRAY_SUPPORT) {
  31215. this[offset + 3] = (value >>> 24)
  31216. this[offset + 2] = (value >>> 16)
  31217. this[offset + 1] = (value >>> 8)
  31218. this[offset] = (value & 0xff)
  31219. } else {
  31220. objectWriteUInt32(this, value, offset, true)
  31221. }
  31222. return offset + 4
  31223. }
  31224. Buffer.prototype.writeUInt32BE = function writeUInt32BE (value, offset, noAssert) {
  31225. value = +value
  31226. offset = offset | 0
  31227. if (!noAssert) checkInt(this, value, offset, 4, 0xffffffff, 0)
  31228. if (Buffer.TYPED_ARRAY_SUPPORT) {
  31229. this[offset] = (value >>> 24)
  31230. this[offset + 1] = (value >>> 16)
  31231. this[offset + 2] = (value >>> 8)
  31232. this[offset + 3] = (value & 0xff)
  31233. } else {
  31234. objectWriteUInt32(this, value, offset, false)
  31235. }
  31236. return offset + 4
  31237. }
  31238. Buffer.prototype.writeIntLE = function writeIntLE (value, offset, byteLength, noAssert) {
  31239. value = +value
  31240. offset = offset | 0
  31241. if (!noAssert) {
  31242. var limit = Math.pow(2, 8 * byteLength - 1)
  31243. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  31244. }
  31245. var i = 0
  31246. var mul = 1
  31247. var sub = 0
  31248. this[offset] = value & 0xFF
  31249. while (++i < byteLength && (mul *= 0x100)) {
  31250. if (value < 0 && sub === 0 && this[offset + i - 1] !== 0) {
  31251. sub = 1
  31252. }
  31253. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  31254. }
  31255. return offset + byteLength
  31256. }
  31257. Buffer.prototype.writeIntBE = function writeIntBE (value, offset, byteLength, noAssert) {
  31258. value = +value
  31259. offset = offset | 0
  31260. if (!noAssert) {
  31261. var limit = Math.pow(2, 8 * byteLength - 1)
  31262. checkInt(this, value, offset, byteLength, limit - 1, -limit)
  31263. }
  31264. var i = byteLength - 1
  31265. var mul = 1
  31266. var sub = 0
  31267. this[offset + i] = value & 0xFF
  31268. while (--i >= 0 && (mul *= 0x100)) {
  31269. if (value < 0 && sub === 0 && this[offset + i + 1] !== 0) {
  31270. sub = 1
  31271. }
  31272. this[offset + i] = ((value / mul) >> 0) - sub & 0xFF
  31273. }
  31274. return offset + byteLength
  31275. }
  31276. Buffer.prototype.writeInt8 = function writeInt8 (value, offset, noAssert) {
  31277. value = +value
  31278. offset = offset | 0
  31279. if (!noAssert) checkInt(this, value, offset, 1, 0x7f, -0x80)
  31280. if (!Buffer.TYPED_ARRAY_SUPPORT) value = Math.floor(value)
  31281. if (value < 0) value = 0xff + value + 1
  31282. this[offset] = (value & 0xff)
  31283. return offset + 1
  31284. }
  31285. Buffer.prototype.writeInt16LE = function writeInt16LE (value, offset, noAssert) {
  31286. value = +value
  31287. offset = offset | 0
  31288. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  31289. if (Buffer.TYPED_ARRAY_SUPPORT) {
  31290. this[offset] = (value & 0xff)
  31291. this[offset + 1] = (value >>> 8)
  31292. } else {
  31293. objectWriteUInt16(this, value, offset, true)
  31294. }
  31295. return offset + 2
  31296. }
  31297. Buffer.prototype.writeInt16BE = function writeInt16BE (value, offset, noAssert) {
  31298. value = +value
  31299. offset = offset | 0
  31300. if (!noAssert) checkInt(this, value, offset, 2, 0x7fff, -0x8000)
  31301. if (Buffer.TYPED_ARRAY_SUPPORT) {
  31302. this[offset] = (value >>> 8)
  31303. this[offset + 1] = (value & 0xff)
  31304. } else {
  31305. objectWriteUInt16(this, value, offset, false)
  31306. }
  31307. return offset + 2
  31308. }
  31309. Buffer.prototype.writeInt32LE = function writeInt32LE (value, offset, noAssert) {
  31310. value = +value
  31311. offset = offset | 0
  31312. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  31313. if (Buffer.TYPED_ARRAY_SUPPORT) {
  31314. this[offset] = (value & 0xff)
  31315. this[offset + 1] = (value >>> 8)
  31316. this[offset + 2] = (value >>> 16)
  31317. this[offset + 3] = (value >>> 24)
  31318. } else {
  31319. objectWriteUInt32(this, value, offset, true)
  31320. }
  31321. return offset + 4
  31322. }
  31323. Buffer.prototype.writeInt32BE = function writeInt32BE (value, offset, noAssert) {
  31324. value = +value
  31325. offset = offset | 0
  31326. if (!noAssert) checkInt(this, value, offset, 4, 0x7fffffff, -0x80000000)
  31327. if (value < 0) value = 0xffffffff + value + 1
  31328. if (Buffer.TYPED_ARRAY_SUPPORT) {
  31329. this[offset] = (value >>> 24)
  31330. this[offset + 1] = (value >>> 16)
  31331. this[offset + 2] = (value >>> 8)
  31332. this[offset + 3] = (value & 0xff)
  31333. } else {
  31334. objectWriteUInt32(this, value, offset, false)
  31335. }
  31336. return offset + 4
  31337. }
  31338. function checkIEEE754 (buf, value, offset, ext, max, min) {
  31339. if (offset + ext > buf.length) throw new RangeError('Index out of range')
  31340. if (offset < 0) throw new RangeError('Index out of range')
  31341. }
  31342. function writeFloat (buf, value, offset, littleEndian, noAssert) {
  31343. if (!noAssert) {
  31344. checkIEEE754(buf, value, offset, 4, 3.4028234663852886e+38, -3.4028234663852886e+38)
  31345. }
  31346. ieee754.write(buf, value, offset, littleEndian, 23, 4)
  31347. return offset + 4
  31348. }
  31349. Buffer.prototype.writeFloatLE = function writeFloatLE (value, offset, noAssert) {
  31350. return writeFloat(this, value, offset, true, noAssert)
  31351. }
  31352. Buffer.prototype.writeFloatBE = function writeFloatBE (value, offset, noAssert) {
  31353. return writeFloat(this, value, offset, false, noAssert)
  31354. }
  31355. function writeDouble (buf, value, offset, littleEndian, noAssert) {
  31356. if (!noAssert) {
  31357. checkIEEE754(buf, value, offset, 8, 1.7976931348623157E+308, -1.7976931348623157E+308)
  31358. }
  31359. ieee754.write(buf, value, offset, littleEndian, 52, 8)
  31360. return offset + 8
  31361. }
  31362. Buffer.prototype.writeDoubleLE = function writeDoubleLE (value, offset, noAssert) {
  31363. return writeDouble(this, value, offset, true, noAssert)
  31364. }
  31365. Buffer.prototype.writeDoubleBE = function writeDoubleBE (value, offset, noAssert) {
  31366. return writeDouble(this, value, offset, false, noAssert)
  31367. }
  31368. // copy(targetBuffer, targetStart=0, sourceStart=0, sourceEnd=buffer.length)
  31369. Buffer.prototype.copy = function copy (target, targetStart, start, end) {
  31370. if (!start) start = 0
  31371. if (!end && end !== 0) end = this.length
  31372. if (targetStart >= target.length) targetStart = target.length
  31373. if (!targetStart) targetStart = 0
  31374. if (end > 0 && end < start) end = start
  31375. // Copy 0 bytes; we're done
  31376. if (end === start) return 0
  31377. if (target.length === 0 || this.length === 0) return 0
  31378. // Fatal error conditions
  31379. if (targetStart < 0) {
  31380. throw new RangeError('targetStart out of bounds')
  31381. }
  31382. if (start < 0 || start >= this.length) throw new RangeError('sourceStart out of bounds')
  31383. if (end < 0) throw new RangeError('sourceEnd out of bounds')
  31384. // Are we oob?
  31385. if (end > this.length) end = this.length
  31386. if (target.length - targetStart < end - start) {
  31387. end = target.length - targetStart + start
  31388. }
  31389. var len = end - start
  31390. var i
  31391. if (this === target && start < targetStart && targetStart < end) {
  31392. // descending copy from end
  31393. for (i = len - 1; i >= 0; --i) {
  31394. target[i + targetStart] = this[i + start]
  31395. }
  31396. } else if (len < 1000 || !Buffer.TYPED_ARRAY_SUPPORT) {
  31397. // ascending copy from start
  31398. for (i = 0; i < len; ++i) {
  31399. target[i + targetStart] = this[i + start]
  31400. }
  31401. } else {
  31402. Uint8Array.prototype.set.call(
  31403. target,
  31404. this.subarray(start, start + len),
  31405. targetStart
  31406. )
  31407. }
  31408. return len
  31409. }
  31410. // Usage:
  31411. // buffer.fill(number[, offset[, end]])
  31412. // buffer.fill(buffer[, offset[, end]])
  31413. // buffer.fill(string[, offset[, end]][, encoding])
  31414. Buffer.prototype.fill = function fill (val, start, end, encoding) {
  31415. // Handle string cases:
  31416. if (typeof val === 'string') {
  31417. if (typeof start === 'string') {
  31418. encoding = start
  31419. start = 0
  31420. end = this.length
  31421. } else if (typeof end === 'string') {
  31422. encoding = end
  31423. end = this.length
  31424. }
  31425. if (val.length === 1) {
  31426. var code = val.charCodeAt(0)
  31427. if (code < 256) {
  31428. val = code
  31429. }
  31430. }
  31431. if (encoding !== undefined && typeof encoding !== 'string') {
  31432. throw new TypeError('encoding must be a string')
  31433. }
  31434. if (typeof encoding === 'string' && !Buffer.isEncoding(encoding)) {
  31435. throw new TypeError('Unknown encoding: ' + encoding)
  31436. }
  31437. } else if (typeof val === 'number') {
  31438. val = val & 255
  31439. }
  31440. // Invalid ranges are not set to a default, so can range check early.
  31441. if (start < 0 || this.length < start || this.length < end) {
  31442. throw new RangeError('Out of range index')
  31443. }
  31444. if (end <= start) {
  31445. return this
  31446. }
  31447. start = start >>> 0
  31448. end = end === undefined ? this.length : end >>> 0
  31449. if (!val) val = 0
  31450. var i
  31451. if (typeof val === 'number') {
  31452. for (i = start; i < end; ++i) {
  31453. this[i] = val
  31454. }
  31455. } else {
  31456. var bytes = Buffer.isBuffer(val)
  31457. ? val
  31458. : utf8ToBytes(new Buffer(val, encoding).toString())
  31459. var len = bytes.length
  31460. for (i = 0; i < end - start; ++i) {
  31461. this[i + start] = bytes[i % len]
  31462. }
  31463. }
  31464. return this
  31465. }
  31466. // HELPER FUNCTIONS
  31467. // ================
  31468. var INVALID_BASE64_RE = /[^+\/0-9A-Za-z-_]/g
  31469. function base64clean (str) {
  31470. // Node strips out invalid characters like \n and \t from the string, base64-js does not
  31471. str = stringtrim(str).replace(INVALID_BASE64_RE, '')
  31472. // Node converts strings with length < 2 to ''
  31473. if (str.length < 2) return ''
  31474. // Node allows for non-padded base64 strings (missing trailing ===), base64-js does not
  31475. while (str.length % 4 !== 0) {
  31476. str = str + '='
  31477. }
  31478. return str
  31479. }
  31480. function stringtrim (str) {
  31481. if (str.trim) return str.trim()
  31482. return str.replace(/^\s+|\s+$/g, '')
  31483. }
  31484. function toHex (n) {
  31485. if (n < 16) return '0' + n.toString(16)
  31486. return n.toString(16)
  31487. }
  31488. function utf8ToBytes (string, units) {
  31489. units = units || Infinity
  31490. var codePoint
  31491. var length = string.length
  31492. var leadSurrogate = null
  31493. var bytes = []
  31494. for (var i = 0; i < length; ++i) {
  31495. codePoint = string.charCodeAt(i)
  31496. // is surrogate component
  31497. if (codePoint > 0xD7FF && codePoint < 0xE000) {
  31498. // last char was a lead
  31499. if (!leadSurrogate) {
  31500. // no lead yet
  31501. if (codePoint > 0xDBFF) {
  31502. // unexpected trail
  31503. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  31504. continue
  31505. } else if (i + 1 === length) {
  31506. // unpaired lead
  31507. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  31508. continue
  31509. }
  31510. // valid lead
  31511. leadSurrogate = codePoint
  31512. continue
  31513. }
  31514. // 2 leads in a row
  31515. if (codePoint < 0xDC00) {
  31516. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  31517. leadSurrogate = codePoint
  31518. continue
  31519. }
  31520. // valid surrogate pair
  31521. codePoint = (leadSurrogate - 0xD800 << 10 | codePoint - 0xDC00) + 0x10000
  31522. } else if (leadSurrogate) {
  31523. // valid bmp char, but last char was a lead
  31524. if ((units -= 3) > -1) bytes.push(0xEF, 0xBF, 0xBD)
  31525. }
  31526. leadSurrogate = null
  31527. // encode utf8
  31528. if (codePoint < 0x80) {
  31529. if ((units -= 1) < 0) break
  31530. bytes.push(codePoint)
  31531. } else if (codePoint < 0x800) {
  31532. if ((units -= 2) < 0) break
  31533. bytes.push(
  31534. codePoint >> 0x6 | 0xC0,
  31535. codePoint & 0x3F | 0x80
  31536. )
  31537. } else if (codePoint < 0x10000) {
  31538. if ((units -= 3) < 0) break
  31539. bytes.push(
  31540. codePoint >> 0xC | 0xE0,
  31541. codePoint >> 0x6 & 0x3F | 0x80,
  31542. codePoint & 0x3F | 0x80
  31543. )
  31544. } else if (codePoint < 0x110000) {
  31545. if ((units -= 4) < 0) break
  31546. bytes.push(
  31547. codePoint >> 0x12 | 0xF0,
  31548. codePoint >> 0xC & 0x3F | 0x80,
  31549. codePoint >> 0x6 & 0x3F | 0x80,
  31550. codePoint & 0x3F | 0x80
  31551. )
  31552. } else {
  31553. throw new Error('Invalid code point')
  31554. }
  31555. }
  31556. return bytes
  31557. }
  31558. function asciiToBytes (str) {
  31559. var byteArray = []
  31560. for (var i = 0; i < str.length; ++i) {
  31561. // Node's code seems to be doing this and not & 0x7F..
  31562. byteArray.push(str.charCodeAt(i) & 0xFF)
  31563. }
  31564. return byteArray
  31565. }
  31566. function utf16leToBytes (str, units) {
  31567. var c, hi, lo
  31568. var byteArray = []
  31569. for (var i = 0; i < str.length; ++i) {
  31570. if ((units -= 2) < 0) break
  31571. c = str.charCodeAt(i)
  31572. hi = c >> 8
  31573. lo = c % 256
  31574. byteArray.push(lo)
  31575. byteArray.push(hi)
  31576. }
  31577. return byteArray
  31578. }
  31579. function base64ToBytes (str) {
  31580. return base64.toByteArray(base64clean(str))
  31581. }
  31582. function blitBuffer (src, dst, offset, length) {
  31583. for (var i = 0; i < length; ++i) {
  31584. if ((i + offset >= dst.length) || (i >= src.length)) break
  31585. dst[i + offset] = src[i]
  31586. }
  31587. return i
  31588. }
  31589. function isnan (val) {
  31590. return val !== val // eslint-disable-line no-self-compare
  31591. }
  31592. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  31593. /***/ },
  31594. /* 178 */
  31595. /***/ function(module, exports) {
  31596. 'use strict'
  31597. exports.byteLength = byteLength
  31598. exports.toByteArray = toByteArray
  31599. exports.fromByteArray = fromByteArray
  31600. var lookup = []
  31601. var revLookup = []
  31602. var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
  31603. var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
  31604. for (var i = 0, len = code.length; i < len; ++i) {
  31605. lookup[i] = code[i]
  31606. revLookup[code.charCodeAt(i)] = i
  31607. }
  31608. revLookup['-'.charCodeAt(0)] = 62
  31609. revLookup['_'.charCodeAt(0)] = 63
  31610. function placeHoldersCount (b64) {
  31611. var len = b64.length
  31612. if (len % 4 > 0) {
  31613. throw new Error('Invalid string. Length must be a multiple of 4')
  31614. }
  31615. // the number of equal signs (place holders)
  31616. // if there are two placeholders, than the two characters before it
  31617. // represent one byte
  31618. // if there is only one, then the three characters before it represent 2 bytes
  31619. // this is just a cheap hack to not do indexOf twice
  31620. return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
  31621. }
  31622. function byteLength (b64) {
  31623. // base64 is 4/3 + up to two characters of the original data
  31624. return b64.length * 3 / 4 - placeHoldersCount(b64)
  31625. }
  31626. function toByteArray (b64) {
  31627. var i, j, l, tmp, placeHolders, arr
  31628. var len = b64.length
  31629. placeHolders = placeHoldersCount(b64)
  31630. arr = new Arr(len * 3 / 4 - placeHolders)
  31631. // if there are placeholders, only get up to the last complete 4 chars
  31632. l = placeHolders > 0 ? len - 4 : len
  31633. var L = 0
  31634. for (i = 0, j = 0; i < l; i += 4, j += 3) {
  31635. tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
  31636. arr[L++] = (tmp >> 16) & 0xFF
  31637. arr[L++] = (tmp >> 8) & 0xFF
  31638. arr[L++] = tmp & 0xFF
  31639. }
  31640. if (placeHolders === 2) {
  31641. tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
  31642. arr[L++] = tmp & 0xFF
  31643. } else if (placeHolders === 1) {
  31644. tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
  31645. arr[L++] = (tmp >> 8) & 0xFF
  31646. arr[L++] = tmp & 0xFF
  31647. }
  31648. return arr
  31649. }
  31650. function tripletToBase64 (num) {
  31651. return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
  31652. }
  31653. function encodeChunk (uint8, start, end) {
  31654. var tmp
  31655. var output = []
  31656. for (var i = start; i < end; i += 3) {
  31657. tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
  31658. output.push(tripletToBase64(tmp))
  31659. }
  31660. return output.join('')
  31661. }
  31662. function fromByteArray (uint8) {
  31663. var tmp
  31664. var len = uint8.length
  31665. var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
  31666. var output = ''
  31667. var parts = []
  31668. var maxChunkLength = 16383 // must be multiple of 3
  31669. // go through the array every three bytes, we'll deal with trailing stuff later
  31670. for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
  31671. parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
  31672. }
  31673. // pad the end with zeros, but make sure to not forget the extra bytes
  31674. if (extraBytes === 1) {
  31675. tmp = uint8[len - 1]
  31676. output += lookup[tmp >> 2]
  31677. output += lookup[(tmp << 4) & 0x3F]
  31678. output += '=='
  31679. } else if (extraBytes === 2) {
  31680. tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
  31681. output += lookup[tmp >> 10]
  31682. output += lookup[(tmp >> 4) & 0x3F]
  31683. output += lookup[(tmp << 2) & 0x3F]
  31684. output += '='
  31685. }
  31686. parts.push(output)
  31687. return parts.join('')
  31688. }
  31689. /***/ },
  31690. /* 179 */
  31691. /***/ function(module, exports) {
  31692. exports.read = function (buffer, offset, isLE, mLen, nBytes) {
  31693. var e, m
  31694. var eLen = nBytes * 8 - mLen - 1
  31695. var eMax = (1 << eLen) - 1
  31696. var eBias = eMax >> 1
  31697. var nBits = -7
  31698. var i = isLE ? (nBytes - 1) : 0
  31699. var d = isLE ? -1 : 1
  31700. var s = buffer[offset + i]
  31701. i += d
  31702. e = s & ((1 << (-nBits)) - 1)
  31703. s >>= (-nBits)
  31704. nBits += eLen
  31705. for (; nBits > 0; e = e * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  31706. m = e & ((1 << (-nBits)) - 1)
  31707. e >>= (-nBits)
  31708. nBits += mLen
  31709. for (; nBits > 0; m = m * 256 + buffer[offset + i], i += d, nBits -= 8) {}
  31710. if (e === 0) {
  31711. e = 1 - eBias
  31712. } else if (e === eMax) {
  31713. return m ? NaN : ((s ? -1 : 1) * Infinity)
  31714. } else {
  31715. m = m + Math.pow(2, mLen)
  31716. e = e - eBias
  31717. }
  31718. return (s ? -1 : 1) * m * Math.pow(2, e - mLen)
  31719. }
  31720. exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
  31721. var e, m, c
  31722. var eLen = nBytes * 8 - mLen - 1
  31723. var eMax = (1 << eLen) - 1
  31724. var eBias = eMax >> 1
  31725. var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)
  31726. var i = isLE ? 0 : (nBytes - 1)
  31727. var d = isLE ? 1 : -1
  31728. var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0
  31729. value = Math.abs(value)
  31730. if (isNaN(value) || value === Infinity) {
  31731. m = isNaN(value) ? 1 : 0
  31732. e = eMax
  31733. } else {
  31734. e = Math.floor(Math.log(value) / Math.LN2)
  31735. if (value * (c = Math.pow(2, -e)) < 1) {
  31736. e--
  31737. c *= 2
  31738. }
  31739. if (e + eBias >= 1) {
  31740. value += rt / c
  31741. } else {
  31742. value += rt * Math.pow(2, 1 - eBias)
  31743. }
  31744. if (value * c >= 2) {
  31745. e++
  31746. c /= 2
  31747. }
  31748. if (e + eBias >= eMax) {
  31749. m = 0
  31750. e = eMax
  31751. } else if (e + eBias >= 1) {
  31752. m = (value * c - 1) * Math.pow(2, mLen)
  31753. e = e + eBias
  31754. } else {
  31755. m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)
  31756. e = 0
  31757. }
  31758. }
  31759. for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}
  31760. e = (e << mLen) | m
  31761. eLen += mLen
  31762. for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}
  31763. buffer[offset + i - d] |= s * 128
  31764. }
  31765. /***/ },
  31766. /* 180 */
  31767. /***/ function(module, exports) {
  31768. var toString = {}.toString;
  31769. module.exports = Array.isArray || function (arr) {
  31770. return toString.call(arr) == '[object Array]';
  31771. };
  31772. /***/ },
  31773. /* 181 */
  31774. /***/ function(module, exports) {
  31775. /* (ignored) */
  31776. /***/ },
  31777. /* 182 */
  31778. /***/ function(module, exports, __webpack_require__) {
  31779. /* WEBPACK VAR INJECTION */(function(global) {/**
  31780. * marked - a markdown parser
  31781. * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
  31782. * https://github.com/chjj/marked
  31783. */
  31784. ;(function() {
  31785. /**
  31786. * Block-Level Grammar
  31787. */
  31788. var block = {
  31789. newline: /^\n+/,
  31790. code: /^( {4}[^\n]+\n*)+/,
  31791. fences: noop,
  31792. hr: /^( *[-*_]){3,} *(?:\n+|$)/,
  31793. heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
  31794. nptable: noop,
  31795. lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
  31796. blockquote: /^( *>[^\n]+(\n(?!def)[^\n]+)*\n*)+/,
  31797. list: /^( *)(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
  31798. html: /^ *(?:comment *(?:\n|\s*$)|closed *(?:\n{2,}|\s*$)|closing *(?:\n{2,}|\s*$))/,
  31799. def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
  31800. table: noop,
  31801. paragraph: /^((?:[^\n]+\n?(?!hr|heading|lheading|blockquote|tag|def))+)\n*/,
  31802. text: /^[^\n]+/
  31803. };
  31804. block.bullet = /(?:[*+-]|\d+\.)/;
  31805. block.item = /^( *)(bull) [^\n]*(?:\n(?!\1bull )[^\n]*)*/;
  31806. block.item = replace(block.item, 'gm')
  31807. (/bull/g, block.bullet)
  31808. ();
  31809. block.list = replace(block.list)
  31810. (/bull/g, block.bullet)
  31811. ('hr', '\\n+(?=\\1?(?:[-*_] *){3,}(?:\\n+|$))')
  31812. ('def', '\\n+(?=' + block.def.source + ')')
  31813. ();
  31814. block.blockquote = replace(block.blockquote)
  31815. ('def', block.def)
  31816. ();
  31817. block._tag = '(?!(?:'
  31818. + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code'
  31819. + '|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo'
  31820. + '|span|br|wbr|ins|del|img)\\b)\\w+(?!:/|[^\\w\\s@]*@)\\b';
  31821. block.html = replace(block.html)
  31822. ('comment', /<!--[\s\S]*?-->/)
  31823. ('closed', /<(tag)[\s\S]+?<\/\1>/)
  31824. ('closing', /<tag(?:"[^"]*"|'[^']*'|[^'">])*?>/)
  31825. (/tag/g, block._tag)
  31826. ();
  31827. block.paragraph = replace(block.paragraph)
  31828. ('hr', block.hr)
  31829. ('heading', block.heading)
  31830. ('lheading', block.lheading)
  31831. ('blockquote', block.blockquote)
  31832. ('tag', '<' + block._tag)
  31833. ('def', block.def)
  31834. ();
  31835. /**
  31836. * Normal Block Grammar
  31837. */
  31838. block.normal = merge({}, block);
  31839. /**
  31840. * GFM Block Grammar
  31841. */
  31842. block.gfm = merge({}, block.normal, {
  31843. fences: /^ *(`{3,}|~{3,})[ \.]*(\S+)? *\n([\s\S]*?)\s*\1 *(?:\n+|$)/,
  31844. paragraph: /^/,
  31845. heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
  31846. });
  31847. block.gfm.paragraph = replace(block.paragraph)
  31848. ('(?!', '(?!'
  31849. + block.gfm.fences.source.replace('\\1', '\\2') + '|'
  31850. + block.list.source.replace('\\1', '\\3') + '|')
  31851. ();
  31852. /**
  31853. * GFM + Tables Block Grammar
  31854. */
  31855. block.tables = merge({}, block.gfm, {
  31856. nptable: /^ *(\S.*\|.*)\n *([-:]+ *\|[-| :]*)\n((?:.*\|.*(?:\n|$))*)\n*/,
  31857. table: /^ *\|(.+)\n *\|( *[-:]+[-| :]*)\n((?: *\|.*(?:\n|$))*)\n*/
  31858. });
  31859. /**
  31860. * Block Lexer
  31861. */
  31862. function Lexer(options) {
  31863. this.tokens = [];
  31864. this.tokens.links = {};
  31865. this.options = options || marked.defaults;
  31866. this.rules = block.normal;
  31867. if (this.options.gfm) {
  31868. if (this.options.tables) {
  31869. this.rules = block.tables;
  31870. } else {
  31871. this.rules = block.gfm;
  31872. }
  31873. }
  31874. }
  31875. /**
  31876. * Expose Block Rules
  31877. */
  31878. Lexer.rules = block;
  31879. /**
  31880. * Static Lex Method
  31881. */
  31882. Lexer.lex = function(src, options) {
  31883. var lexer = new Lexer(options);
  31884. return lexer.lex(src);
  31885. };
  31886. /**
  31887. * Preprocessing
  31888. */
  31889. Lexer.prototype.lex = function(src) {
  31890. src = src
  31891. .replace(/\r\n|\r/g, '\n')
  31892. .replace(/\t/g, ' ')
  31893. .replace(/\u00a0/g, ' ')
  31894. .replace(/\u2424/g, '\n');
  31895. return this.token(src, true);
  31896. };
  31897. /**
  31898. * Lexing
  31899. */
  31900. Lexer.prototype.token = function(src, top, bq) {
  31901. var src = src.replace(/^ +$/gm, '')
  31902. , next
  31903. , loose
  31904. , cap
  31905. , bull
  31906. , b
  31907. , item
  31908. , space
  31909. , i
  31910. , l;
  31911. while (src) {
  31912. // newline
  31913. if (cap = this.rules.newline.exec(src)) {
  31914. src = src.substring(cap[0].length);
  31915. if (cap[0].length > 1) {
  31916. this.tokens.push({
  31917. type: 'space'
  31918. });
  31919. }
  31920. }
  31921. // code
  31922. if (cap = this.rules.code.exec(src)) {
  31923. src = src.substring(cap[0].length);
  31924. cap = cap[0].replace(/^ {4}/gm, '');
  31925. this.tokens.push({
  31926. type: 'code',
  31927. text: !this.options.pedantic
  31928. ? cap.replace(/\n+$/, '')
  31929. : cap
  31930. });
  31931. continue;
  31932. }
  31933. // fences (gfm)
  31934. if (cap = this.rules.fences.exec(src)) {
  31935. src = src.substring(cap[0].length);
  31936. this.tokens.push({
  31937. type: 'code',
  31938. lang: cap[2],
  31939. text: cap[3] || ''
  31940. });
  31941. continue;
  31942. }
  31943. // heading
  31944. if (cap = this.rules.heading.exec(src)) {
  31945. src = src.substring(cap[0].length);
  31946. this.tokens.push({
  31947. type: 'heading',
  31948. depth: cap[1].length,
  31949. text: cap[2]
  31950. });
  31951. continue;
  31952. }
  31953. // table no leading pipe (gfm)
  31954. if (top && (cap = this.rules.nptable.exec(src))) {
  31955. src = src.substring(cap[0].length);
  31956. item = {
  31957. type: 'table',
  31958. header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
  31959. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  31960. cells: cap[3].replace(/\n$/, '').split('\n')
  31961. };
  31962. for (i = 0; i < item.align.length; i++) {
  31963. if (/^ *-+: *$/.test(item.align[i])) {
  31964. item.align[i] = 'right';
  31965. } else if (/^ *:-+: *$/.test(item.align[i])) {
  31966. item.align[i] = 'center';
  31967. } else if (/^ *:-+ *$/.test(item.align[i])) {
  31968. item.align[i] = 'left';
  31969. } else {
  31970. item.align[i] = null;
  31971. }
  31972. }
  31973. for (i = 0; i < item.cells.length; i++) {
  31974. item.cells[i] = item.cells[i].split(/ *\| */);
  31975. }
  31976. this.tokens.push(item);
  31977. continue;
  31978. }
  31979. // lheading
  31980. if (cap = this.rules.lheading.exec(src)) {
  31981. src = src.substring(cap[0].length);
  31982. this.tokens.push({
  31983. type: 'heading',
  31984. depth: cap[2] === '=' ? 1 : 2,
  31985. text: cap[1]
  31986. });
  31987. continue;
  31988. }
  31989. // hr
  31990. if (cap = this.rules.hr.exec(src)) {
  31991. src = src.substring(cap[0].length);
  31992. this.tokens.push({
  31993. type: 'hr'
  31994. });
  31995. continue;
  31996. }
  31997. // blockquote
  31998. if (cap = this.rules.blockquote.exec(src)) {
  31999. src = src.substring(cap[0].length);
  32000. this.tokens.push({
  32001. type: 'blockquote_start'
  32002. });
  32003. cap = cap[0].replace(/^ *> ?/gm, '');
  32004. // Pass `top` to keep the current
  32005. // "toplevel" state. This is exactly
  32006. // how markdown.pl works.
  32007. this.token(cap, top, true);
  32008. this.tokens.push({
  32009. type: 'blockquote_end'
  32010. });
  32011. continue;
  32012. }
  32013. // list
  32014. if (cap = this.rules.list.exec(src)) {
  32015. src = src.substring(cap[0].length);
  32016. bull = cap[2];
  32017. this.tokens.push({
  32018. type: 'list_start',
  32019. ordered: bull.length > 1
  32020. });
  32021. // Get each top-level item.
  32022. cap = cap[0].match(this.rules.item);
  32023. next = false;
  32024. l = cap.length;
  32025. i = 0;
  32026. for (; i < l; i++) {
  32027. item = cap[i];
  32028. // Remove the list item's bullet
  32029. // so it is seen as the next token.
  32030. space = item.length;
  32031. item = item.replace(/^ *([*+-]|\d+\.) +/, '');
  32032. // Outdent whatever the
  32033. // list item contains. Hacky.
  32034. if (~item.indexOf('\n ')) {
  32035. space -= item.length;
  32036. item = !this.options.pedantic
  32037. ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
  32038. : item.replace(/^ {1,4}/gm, '');
  32039. }
  32040. // Determine whether the next list item belongs here.
  32041. // Backpedal if it does not belong in this list.
  32042. if (this.options.smartLists && i !== l - 1) {
  32043. b = block.bullet.exec(cap[i + 1])[0];
  32044. if (bull !== b && !(bull.length > 1 && b.length > 1)) {
  32045. src = cap.slice(i + 1).join('\n') + src;
  32046. i = l - 1;
  32047. }
  32048. }
  32049. // Determine whether item is loose or not.
  32050. // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
  32051. // for discount behavior.
  32052. loose = next || /\n\n(?!\s*$)/.test(item);
  32053. if (i !== l - 1) {
  32054. next = item.charAt(item.length - 1) === '\n';
  32055. if (!loose) loose = next;
  32056. }
  32057. this.tokens.push({
  32058. type: loose
  32059. ? 'loose_item_start'
  32060. : 'list_item_start'
  32061. });
  32062. // Recurse.
  32063. this.token(item, false, bq);
  32064. this.tokens.push({
  32065. type: 'list_item_end'
  32066. });
  32067. }
  32068. this.tokens.push({
  32069. type: 'list_end'
  32070. });
  32071. continue;
  32072. }
  32073. // html
  32074. if (cap = this.rules.html.exec(src)) {
  32075. src = src.substring(cap[0].length);
  32076. this.tokens.push({
  32077. type: this.options.sanitize
  32078. ? 'paragraph'
  32079. : 'html',
  32080. pre: !this.options.sanitizer
  32081. && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
  32082. text: cap[0]
  32083. });
  32084. continue;
  32085. }
  32086. // def
  32087. if ((!bq && top) && (cap = this.rules.def.exec(src))) {
  32088. src = src.substring(cap[0].length);
  32089. this.tokens.links[cap[1].toLowerCase()] = {
  32090. href: cap[2],
  32091. title: cap[3]
  32092. };
  32093. continue;
  32094. }
  32095. // table (gfm)
  32096. if (top && (cap = this.rules.table.exec(src))) {
  32097. src = src.substring(cap[0].length);
  32098. item = {
  32099. type: 'table',
  32100. header: cap[1].replace(/^ *| *\| *$/g, '').split(/ *\| */),
  32101. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  32102. cells: cap[3].replace(/(?: *\| *)?\n$/, '').split('\n')
  32103. };
  32104. for (i = 0; i < item.align.length; i++) {
  32105. if (/^ *-+: *$/.test(item.align[i])) {
  32106. item.align[i] = 'right';
  32107. } else if (/^ *:-+: *$/.test(item.align[i])) {
  32108. item.align[i] = 'center';
  32109. } else if (/^ *:-+ *$/.test(item.align[i])) {
  32110. item.align[i] = 'left';
  32111. } else {
  32112. item.align[i] = null;
  32113. }
  32114. }
  32115. for (i = 0; i < item.cells.length; i++) {
  32116. item.cells[i] = item.cells[i]
  32117. .replace(/^ *\| *| *\| *$/g, '')
  32118. .split(/ *\| */);
  32119. }
  32120. this.tokens.push(item);
  32121. continue;
  32122. }
  32123. // top-level paragraph
  32124. if (top && (cap = this.rules.paragraph.exec(src))) {
  32125. src = src.substring(cap[0].length);
  32126. this.tokens.push({
  32127. type: 'paragraph',
  32128. text: cap[1].charAt(cap[1].length - 1) === '\n'
  32129. ? cap[1].slice(0, -1)
  32130. : cap[1]
  32131. });
  32132. continue;
  32133. }
  32134. // text
  32135. if (cap = this.rules.text.exec(src)) {
  32136. // Top-level should never reach here.
  32137. src = src.substring(cap[0].length);
  32138. this.tokens.push({
  32139. type: 'text',
  32140. text: cap[0]
  32141. });
  32142. continue;
  32143. }
  32144. if (src) {
  32145. throw new
  32146. Error('Infinite loop on byte: ' + src.charCodeAt(0));
  32147. }
  32148. }
  32149. return this.tokens;
  32150. };
  32151. /**
  32152. * Inline-Level Grammar
  32153. */
  32154. var inline = {
  32155. escape: /^\\([\\`*{}\[\]()#+\-.!_>])/,
  32156. autolink: /^<([^ >]+(@|:\/)[^ >]+)>/,
  32157. url: noop,
  32158. tag: /^<!--[\s\S]*?-->|^<\/?\w+(?:"[^"]*"|'[^']*'|[^'">])*?>/,
  32159. link: /^!?\[(inside)\]\(href\)/,
  32160. reflink: /^!?\[(inside)\]\s*\[([^\]]*)\]/,
  32161. nolink: /^!?\[((?:\[[^\]]*\]|[^\[\]])*)\]/,
  32162. strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/,
  32163. em: /^\b_((?:[^_]|__)+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/,
  32164. code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/,
  32165. br: /^ {2,}\n(?!\s*$)/,
  32166. del: noop,
  32167. text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
  32168. };
  32169. inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
  32170. inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
  32171. inline.link = replace(inline.link)
  32172. ('inside', inline._inside)
  32173. ('href', inline._href)
  32174. ();
  32175. inline.reflink = replace(inline.reflink)
  32176. ('inside', inline._inside)
  32177. ();
  32178. /**
  32179. * Normal Inline Grammar
  32180. */
  32181. inline.normal = merge({}, inline);
  32182. /**
  32183. * Pedantic Inline Grammar
  32184. */
  32185. inline.pedantic = merge({}, inline.normal, {
  32186. strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
  32187. em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/
  32188. });
  32189. /**
  32190. * GFM Inline Grammar
  32191. */
  32192. inline.gfm = merge({}, inline.normal, {
  32193. escape: replace(inline.escape)('])', '~|])')(),
  32194. url: /^(https?:\/\/[^\s<]+[^<.,:;"')\]\s])/,
  32195. del: /^~~(?=\S)([\s\S]*?\S)~~/,
  32196. text: replace(inline.text)
  32197. (']|', '~]|')
  32198. ('|', '|https?://|')
  32199. ()
  32200. });
  32201. /**
  32202. * GFM + Line Breaks Inline Grammar
  32203. */
  32204. inline.breaks = merge({}, inline.gfm, {
  32205. br: replace(inline.br)('{2,}', '*')(),
  32206. text: replace(inline.gfm.text)('{2,}', '*')()
  32207. });
  32208. /**
  32209. * Inline Lexer & Compiler
  32210. */
  32211. function InlineLexer(links, options) {
  32212. this.options = options || marked.defaults;
  32213. this.links = links;
  32214. this.rules = inline.normal;
  32215. this.renderer = this.options.renderer || new Renderer;
  32216. this.renderer.options = this.options;
  32217. if (!this.links) {
  32218. throw new
  32219. Error('Tokens array requires a `links` property.');
  32220. }
  32221. if (this.options.gfm) {
  32222. if (this.options.breaks) {
  32223. this.rules = inline.breaks;
  32224. } else {
  32225. this.rules = inline.gfm;
  32226. }
  32227. } else if (this.options.pedantic) {
  32228. this.rules = inline.pedantic;
  32229. }
  32230. }
  32231. /**
  32232. * Expose Inline Rules
  32233. */
  32234. InlineLexer.rules = inline;
  32235. /**
  32236. * Static Lexing/Compiling Method
  32237. */
  32238. InlineLexer.output = function(src, links, options) {
  32239. var inline = new InlineLexer(links, options);
  32240. return inline.output(src);
  32241. };
  32242. /**
  32243. * Lexing/Compiling
  32244. */
  32245. InlineLexer.prototype.output = function(src) {
  32246. var out = ''
  32247. , link
  32248. , text
  32249. , href
  32250. , cap;
  32251. while (src) {
  32252. // escape
  32253. if (cap = this.rules.escape.exec(src)) {
  32254. src = src.substring(cap[0].length);
  32255. out += cap[1];
  32256. continue;
  32257. }
  32258. // autolink
  32259. if (cap = this.rules.autolink.exec(src)) {
  32260. src = src.substring(cap[0].length);
  32261. if (cap[2] === '@') {
  32262. text = cap[1].charAt(6) === ':'
  32263. ? this.mangle(cap[1].substring(7))
  32264. : this.mangle(cap[1]);
  32265. href = this.mangle('mailto:') + text;
  32266. } else {
  32267. text = escape(cap[1]);
  32268. href = text;
  32269. }
  32270. out += this.renderer.link(href, null, text);
  32271. continue;
  32272. }
  32273. // url (gfm)
  32274. if (!this.inLink && (cap = this.rules.url.exec(src))) {
  32275. src = src.substring(cap[0].length);
  32276. text = escape(cap[1]);
  32277. href = text;
  32278. out += this.renderer.link(href, null, text);
  32279. continue;
  32280. }
  32281. // tag
  32282. if (cap = this.rules.tag.exec(src)) {
  32283. if (!this.inLink && /^<a /i.test(cap[0])) {
  32284. this.inLink = true;
  32285. } else if (this.inLink && /^<\/a>/i.test(cap[0])) {
  32286. this.inLink = false;
  32287. }
  32288. src = src.substring(cap[0].length);
  32289. out += this.options.sanitize
  32290. ? this.options.sanitizer
  32291. ? this.options.sanitizer(cap[0])
  32292. : escape(cap[0])
  32293. : cap[0]
  32294. continue;
  32295. }
  32296. // link
  32297. if (cap = this.rules.link.exec(src)) {
  32298. src = src.substring(cap[0].length);
  32299. this.inLink = true;
  32300. out += this.outputLink(cap, {
  32301. href: cap[2],
  32302. title: cap[3]
  32303. });
  32304. this.inLink = false;
  32305. continue;
  32306. }
  32307. // reflink, nolink
  32308. if ((cap = this.rules.reflink.exec(src))
  32309. || (cap = this.rules.nolink.exec(src))) {
  32310. src = src.substring(cap[0].length);
  32311. link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
  32312. link = this.links[link.toLowerCase()];
  32313. if (!link || !link.href) {
  32314. out += cap[0].charAt(0);
  32315. src = cap[0].substring(1) + src;
  32316. continue;
  32317. }
  32318. this.inLink = true;
  32319. out += this.outputLink(cap, link);
  32320. this.inLink = false;
  32321. continue;
  32322. }
  32323. // strong
  32324. if (cap = this.rules.strong.exec(src)) {
  32325. src = src.substring(cap[0].length);
  32326. out += this.renderer.strong(this.output(cap[2] || cap[1]));
  32327. continue;
  32328. }
  32329. // em
  32330. if (cap = this.rules.em.exec(src)) {
  32331. src = src.substring(cap[0].length);
  32332. out += this.renderer.em(this.output(cap[2] || cap[1]));
  32333. continue;
  32334. }
  32335. // code
  32336. if (cap = this.rules.code.exec(src)) {
  32337. src = src.substring(cap[0].length);
  32338. out += this.renderer.codespan(escape(cap[2], true));
  32339. continue;
  32340. }
  32341. // br
  32342. if (cap = this.rules.br.exec(src)) {
  32343. src = src.substring(cap[0].length);
  32344. out += this.renderer.br();
  32345. continue;
  32346. }
  32347. // del (gfm)
  32348. if (cap = this.rules.del.exec(src)) {
  32349. src = src.substring(cap[0].length);
  32350. out += this.renderer.del(this.output(cap[1]));
  32351. continue;
  32352. }
  32353. // text
  32354. if (cap = this.rules.text.exec(src)) {
  32355. src = src.substring(cap[0].length);
  32356. out += this.renderer.text(escape(this.smartypants(cap[0])));
  32357. continue;
  32358. }
  32359. if (src) {
  32360. throw new
  32361. Error('Infinite loop on byte: ' + src.charCodeAt(0));
  32362. }
  32363. }
  32364. return out;
  32365. };
  32366. /**
  32367. * Compile Link
  32368. */
  32369. InlineLexer.prototype.outputLink = function(cap, link) {
  32370. var href = escape(link.href)
  32371. , title = link.title ? escape(link.title) : null;
  32372. return cap[0].charAt(0) !== '!'
  32373. ? this.renderer.link(href, title, this.output(cap[1]))
  32374. : this.renderer.image(href, title, escape(cap[1]));
  32375. };
  32376. /**
  32377. * Smartypants Transformations
  32378. */
  32379. InlineLexer.prototype.smartypants = function(text) {
  32380. if (!this.options.smartypants) return text;
  32381. return text
  32382. // em-dashes
  32383. .replace(/---/g, '\u2014')
  32384. // en-dashes
  32385. .replace(/--/g, '\u2013')
  32386. // opening singles
  32387. .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
  32388. // closing singles & apostrophes
  32389. .replace(/'/g, '\u2019')
  32390. // opening doubles
  32391. .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
  32392. // closing doubles
  32393. .replace(/"/g, '\u201d')
  32394. // ellipses
  32395. .replace(/\.{3}/g, '\u2026');
  32396. };
  32397. /**
  32398. * Mangle Links
  32399. */
  32400. InlineLexer.prototype.mangle = function(text) {
  32401. if (!this.options.mangle) return text;
  32402. var out = ''
  32403. , l = text.length
  32404. , i = 0
  32405. , ch;
  32406. for (; i < l; i++) {
  32407. ch = text.charCodeAt(i);
  32408. if (Math.random() > 0.5) {
  32409. ch = 'x' + ch.toString(16);
  32410. }
  32411. out += '&#' + ch + ';';
  32412. }
  32413. return out;
  32414. };
  32415. /**
  32416. * Renderer
  32417. */
  32418. function Renderer(options) {
  32419. this.options = options || {};
  32420. }
  32421. Renderer.prototype.code = function(code, lang, escaped) {
  32422. if (this.options.highlight) {
  32423. var out = this.options.highlight(code, lang);
  32424. if (out != null && out !== code) {
  32425. escaped = true;
  32426. code = out;
  32427. }
  32428. }
  32429. if (!lang) {
  32430. return '<pre><code>'
  32431. + (escaped ? code : escape(code, true))
  32432. + '\n</code></pre>';
  32433. }
  32434. return '<pre><code class="'
  32435. + this.options.langPrefix
  32436. + escape(lang, true)
  32437. + '">'
  32438. + (escaped ? code : escape(code, true))
  32439. + '\n</code></pre>\n';
  32440. };
  32441. Renderer.prototype.blockquote = function(quote) {
  32442. return '<blockquote>\n' + quote + '</blockquote>\n';
  32443. };
  32444. Renderer.prototype.html = function(html) {
  32445. return html;
  32446. };
  32447. Renderer.prototype.heading = function(text, level, raw) {
  32448. return '<h'
  32449. + level
  32450. + ' id="'
  32451. + this.options.headerPrefix
  32452. + raw.toLowerCase().replace(/[^\w]+/g, '-')
  32453. + '">'
  32454. + text
  32455. + '</h'
  32456. + level
  32457. + '>\n';
  32458. };
  32459. Renderer.prototype.hr = function() {
  32460. return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
  32461. };
  32462. Renderer.prototype.list = function(body, ordered) {
  32463. var type = ordered ? 'ol' : 'ul';
  32464. return '<' + type + '>\n' + body + '</' + type + '>\n';
  32465. };
  32466. Renderer.prototype.listitem = function(text) {
  32467. return '<li>' + text + '</li>\n';
  32468. };
  32469. Renderer.prototype.paragraph = function(text) {
  32470. return '<p>' + text + '</p>\n';
  32471. };
  32472. Renderer.prototype.table = function(header, body) {
  32473. return '<table>\n'
  32474. + '<thead>\n'
  32475. + header
  32476. + '</thead>\n'
  32477. + '<tbody>\n'
  32478. + body
  32479. + '</tbody>\n'
  32480. + '</table>\n';
  32481. };
  32482. Renderer.prototype.tablerow = function(content) {
  32483. return '<tr>\n' + content + '</tr>\n';
  32484. };
  32485. Renderer.prototype.tablecell = function(content, flags) {
  32486. var type = flags.header ? 'th' : 'td';
  32487. var tag = flags.align
  32488. ? '<' + type + ' style="text-align:' + flags.align + '">'
  32489. : '<' + type + '>';
  32490. return tag + content + '</' + type + '>\n';
  32491. };
  32492. // span level renderer
  32493. Renderer.prototype.strong = function(text) {
  32494. return '<strong>' + text + '</strong>';
  32495. };
  32496. Renderer.prototype.em = function(text) {
  32497. return '<em>' + text + '</em>';
  32498. };
  32499. Renderer.prototype.codespan = function(text) {
  32500. return '<code>' + text + '</code>';
  32501. };
  32502. Renderer.prototype.br = function() {
  32503. return this.options.xhtml ? '<br/>' : '<br>';
  32504. };
  32505. Renderer.prototype.del = function(text) {
  32506. return '<del>' + text + '</del>';
  32507. };
  32508. Renderer.prototype.link = function(href, title, text) {
  32509. if (this.options.sanitize) {
  32510. try {
  32511. var prot = decodeURIComponent(unescape(href))
  32512. .replace(/[^\w:]/g, '')
  32513. .toLowerCase();
  32514. } catch (e) {
  32515. return '';
  32516. }
  32517. if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0) {
  32518. return '';
  32519. }
  32520. }
  32521. var out = '<a href="' + href + '"';
  32522. if (title) {
  32523. out += ' title="' + title + '"';
  32524. }
  32525. out += '>' + text + '</a>';
  32526. return out;
  32527. };
  32528. Renderer.prototype.image = function(href, title, text) {
  32529. var out = '<img src="' + href + '" alt="' + text + '"';
  32530. if (title) {
  32531. out += ' title="' + title + '"';
  32532. }
  32533. out += this.options.xhtml ? '/>' : '>';
  32534. return out;
  32535. };
  32536. Renderer.prototype.text = function(text) {
  32537. return text;
  32538. };
  32539. /**
  32540. * Parsing & Compiling
  32541. */
  32542. function Parser(options) {
  32543. this.tokens = [];
  32544. this.token = null;
  32545. this.options = options || marked.defaults;
  32546. this.options.renderer = this.options.renderer || new Renderer;
  32547. this.renderer = this.options.renderer;
  32548. this.renderer.options = this.options;
  32549. }
  32550. /**
  32551. * Static Parse Method
  32552. */
  32553. Parser.parse = function(src, options, renderer) {
  32554. var parser = new Parser(options, renderer);
  32555. return parser.parse(src);
  32556. };
  32557. /**
  32558. * Parse Loop
  32559. */
  32560. Parser.prototype.parse = function(src) {
  32561. this.inline = new InlineLexer(src.links, this.options, this.renderer);
  32562. this.tokens = src.reverse();
  32563. var out = '';
  32564. while (this.next()) {
  32565. out += this.tok();
  32566. }
  32567. return out;
  32568. };
  32569. /**
  32570. * Next Token
  32571. */
  32572. Parser.prototype.next = function() {
  32573. return this.token = this.tokens.pop();
  32574. };
  32575. /**
  32576. * Preview Next Token
  32577. */
  32578. Parser.prototype.peek = function() {
  32579. return this.tokens[this.tokens.length - 1] || 0;
  32580. };
  32581. /**
  32582. * Parse Text Tokens
  32583. */
  32584. Parser.prototype.parseText = function() {
  32585. var body = this.token.text;
  32586. while (this.peek().type === 'text') {
  32587. body += '\n' + this.next().text;
  32588. }
  32589. return this.inline.output(body);
  32590. };
  32591. /**
  32592. * Parse Current Token
  32593. */
  32594. Parser.prototype.tok = function() {
  32595. switch (this.token.type) {
  32596. case 'space': {
  32597. return '';
  32598. }
  32599. case 'hr': {
  32600. return this.renderer.hr();
  32601. }
  32602. case 'heading': {
  32603. return this.renderer.heading(
  32604. this.inline.output(this.token.text),
  32605. this.token.depth,
  32606. this.token.text);
  32607. }
  32608. case 'code': {
  32609. return this.renderer.code(this.token.text,
  32610. this.token.lang,
  32611. this.token.escaped);
  32612. }
  32613. case 'table': {
  32614. var header = ''
  32615. , body = ''
  32616. , i
  32617. , row
  32618. , cell
  32619. , flags
  32620. , j;
  32621. // header
  32622. cell = '';
  32623. for (i = 0; i < this.token.header.length; i++) {
  32624. flags = { header: true, align: this.token.align[i] };
  32625. cell += this.renderer.tablecell(
  32626. this.inline.output(this.token.header[i]),
  32627. { header: true, align: this.token.align[i] }
  32628. );
  32629. }
  32630. header += this.renderer.tablerow(cell);
  32631. for (i = 0; i < this.token.cells.length; i++) {
  32632. row = this.token.cells[i];
  32633. cell = '';
  32634. for (j = 0; j < row.length; j++) {
  32635. cell += this.renderer.tablecell(
  32636. this.inline.output(row[j]),
  32637. { header: false, align: this.token.align[j] }
  32638. );
  32639. }
  32640. body += this.renderer.tablerow(cell);
  32641. }
  32642. return this.renderer.table(header, body);
  32643. }
  32644. case 'blockquote_start': {
  32645. var body = '';
  32646. while (this.next().type !== 'blockquote_end') {
  32647. body += this.tok();
  32648. }
  32649. return this.renderer.blockquote(body);
  32650. }
  32651. case 'list_start': {
  32652. var body = ''
  32653. , ordered = this.token.ordered;
  32654. while (this.next().type !== 'list_end') {
  32655. body += this.tok();
  32656. }
  32657. return this.renderer.list(body, ordered);
  32658. }
  32659. case 'list_item_start': {
  32660. var body = '';
  32661. while (this.next().type !== 'list_item_end') {
  32662. body += this.token.type === 'text'
  32663. ? this.parseText()
  32664. : this.tok();
  32665. }
  32666. return this.renderer.listitem(body);
  32667. }
  32668. case 'loose_item_start': {
  32669. var body = '';
  32670. while (this.next().type !== 'list_item_end') {
  32671. body += this.tok();
  32672. }
  32673. return this.renderer.listitem(body);
  32674. }
  32675. case 'html': {
  32676. var html = !this.token.pre && !this.options.pedantic
  32677. ? this.inline.output(this.token.text)
  32678. : this.token.text;
  32679. return this.renderer.html(html);
  32680. }
  32681. case 'paragraph': {
  32682. return this.renderer.paragraph(this.inline.output(this.token.text));
  32683. }
  32684. case 'text': {
  32685. return this.renderer.paragraph(this.parseText());
  32686. }
  32687. }
  32688. };
  32689. /**
  32690. * Helpers
  32691. */
  32692. function escape(html, encode) {
  32693. return html
  32694. .replace(!encode ? /&(?!#?\w+;)/g : /&/g, '&amp;')
  32695. .replace(/</g, '&lt;')
  32696. .replace(/>/g, '&gt;')
  32697. .replace(/"/g, '&quot;')
  32698. .replace(/'/g, '&#39;');
  32699. }
  32700. function unescape(html) {
  32701. // explicitly match decimal, hex, and named HTML entities
  32702. return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/g, function(_, n) {
  32703. n = n.toLowerCase();
  32704. if (n === 'colon') return ':';
  32705. if (n.charAt(0) === '#') {
  32706. return n.charAt(1) === 'x'
  32707. ? String.fromCharCode(parseInt(n.substring(2), 16))
  32708. : String.fromCharCode(+n.substring(1));
  32709. }
  32710. return '';
  32711. });
  32712. }
  32713. function replace(regex, opt) {
  32714. regex = regex.source;
  32715. opt = opt || '';
  32716. return function self(name, val) {
  32717. if (!name) return new RegExp(regex, opt);
  32718. val = val.source || val;
  32719. val = val.replace(/(^|[^\[])\^/g, '$1');
  32720. regex = regex.replace(name, val);
  32721. return self;
  32722. };
  32723. }
  32724. function noop() {}
  32725. noop.exec = noop;
  32726. function merge(obj) {
  32727. var i = 1
  32728. , target
  32729. , key;
  32730. for (; i < arguments.length; i++) {
  32731. target = arguments[i];
  32732. for (key in target) {
  32733. if (Object.prototype.hasOwnProperty.call(target, key)) {
  32734. obj[key] = target[key];
  32735. }
  32736. }
  32737. }
  32738. return obj;
  32739. }
  32740. /**
  32741. * Marked
  32742. */
  32743. function marked(src, opt, callback) {
  32744. if (callback || typeof opt === 'function') {
  32745. if (!callback) {
  32746. callback = opt;
  32747. opt = null;
  32748. }
  32749. opt = merge({}, marked.defaults, opt || {});
  32750. var highlight = opt.highlight
  32751. , tokens
  32752. , pending
  32753. , i = 0;
  32754. try {
  32755. tokens = Lexer.lex(src, opt)
  32756. } catch (e) {
  32757. return callback(e);
  32758. }
  32759. pending = tokens.length;
  32760. var done = function(err) {
  32761. if (err) {
  32762. opt.highlight = highlight;
  32763. return callback(err);
  32764. }
  32765. var out;
  32766. try {
  32767. out = Parser.parse(tokens, opt);
  32768. } catch (e) {
  32769. err = e;
  32770. }
  32771. opt.highlight = highlight;
  32772. return err
  32773. ? callback(err)
  32774. : callback(null, out);
  32775. };
  32776. if (!highlight || highlight.length < 3) {
  32777. return done();
  32778. }
  32779. delete opt.highlight;
  32780. if (!pending) return done();
  32781. for (; i < tokens.length; i++) {
  32782. (function(token) {
  32783. if (token.type !== 'code') {
  32784. return --pending || done();
  32785. }
  32786. return highlight(token.text, token.lang, function(err, code) {
  32787. if (err) return done(err);
  32788. if (code == null || code === token.text) {
  32789. return --pending || done();
  32790. }
  32791. token.text = code;
  32792. token.escaped = true;
  32793. --pending || done();
  32794. });
  32795. })(tokens[i]);
  32796. }
  32797. return;
  32798. }
  32799. try {
  32800. if (opt) opt = merge({}, marked.defaults, opt);
  32801. return Parser.parse(Lexer.lex(src, opt), opt);
  32802. } catch (e) {
  32803. e.message += '\nPlease report this to https://github.com/chjj/marked.';
  32804. if ((opt || marked.defaults).silent) {
  32805. return '<p>An error occured:</p><pre>'
  32806. + escape(e.message + '', true)
  32807. + '</pre>';
  32808. }
  32809. throw e;
  32810. }
  32811. }
  32812. /**
  32813. * Options
  32814. */
  32815. marked.options =
  32816. marked.setOptions = function(opt) {
  32817. merge(marked.defaults, opt);
  32818. return marked;
  32819. };
  32820. marked.defaults = {
  32821. gfm: true,
  32822. tables: true,
  32823. breaks: false,
  32824. pedantic: false,
  32825. sanitize: false,
  32826. sanitizer: null,
  32827. mangle: true,
  32828. smartLists: false,
  32829. silent: false,
  32830. highlight: null,
  32831. langPrefix: 'lang-',
  32832. smartypants: false,
  32833. headerPrefix: '',
  32834. renderer: new Renderer,
  32835. xhtml: false
  32836. };
  32837. /**
  32838. * Expose
  32839. */
  32840. marked.Parser = Parser;
  32841. marked.parser = Parser.parse;
  32842. marked.Renderer = Renderer;
  32843. marked.Lexer = Lexer;
  32844. marked.lexer = Lexer.lex;
  32845. marked.InlineLexer = InlineLexer;
  32846. marked.inlineLexer = InlineLexer.output;
  32847. marked.parse = marked;
  32848. if (true) {
  32849. module.exports = marked;
  32850. } else if (typeof define === 'function' && define.amd) {
  32851. define(function() { return marked; });
  32852. } else {
  32853. this.marked = marked;
  32854. }
  32855. }).call(function() {
  32856. return this || (typeof window !== 'undefined' ? window : global);
  32857. }());
  32858. /* WEBPACK VAR INJECTION */}.call(exports, (function() { return this; }())))
  32859. /***/ },
  32860. /* 183 */
  32861. /***/ function(module, exports, __webpack_require__) {
  32862. var React = __webpack_require__(1);
  32863. var ReactDOM = __webpack_require__(158);
  32864. var SimpleMDEReact = __webpack_require__(160);
  32865. module.exports = React.createClass({
  32866. displayName: 'exports',
  32867. getMarkdownOptions() {
  32868. return {
  32869. autofocus: false,
  32870. spellChecker: true,
  32871. initialValue: this.props.value
  32872. };
  32873. },
  32874. render() {
  32875. return React.createElement(SimpleMDEReact, {
  32876. onChange: this.props.handleEditorChange,
  32877. options: this.getMarkdownOptions(),
  32878. label: this.props.label,
  32879. value: this.props.value,
  32880. extraKeys: this.props.extraKeys
  32881. });
  32882. }
  32883. });
  32884. /***/ }
  32885. /******/ ]);