main.min.js 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613
  1. /*!
  2. * jQuery JavaScript Library v3.4.1
  3. * https://jquery.com/
  4. *
  5. * Includes Sizzle.js
  6. * https://sizzlejs.com/
  7. *
  8. * Copyright JS Foundation and other contributors
  9. * Released under the MIT license
  10. * https://jquery.org/license
  11. *
  12. * Date: 2019-05-01T21:04Z
  13. */
  14. ( function( global, factory ) {
  15. "use strict";
  16. if ( typeof module === "object" && typeof module.exports === "object" ) {
  17. // For CommonJS and CommonJS-like environments where a proper `window`
  18. // is present, execute the factory and get jQuery.
  19. // For environments that do not have a `window` with a `document`
  20. // (such as Node.js), expose a factory as module.exports.
  21. // This accentuates the need for the creation of a real `window`.
  22. // e.g. var jQuery = require("jquery")(window);
  23. // See ticket #14549 for more info.
  24. module.exports = global.document ?
  25. factory( global, true ) :
  26. function( w ) {
  27. if ( !w.document ) {
  28. throw new Error( "jQuery requires a window with a document" );
  29. }
  30. return factory( w );
  31. };
  32. } else {
  33. factory( global );
  34. }
  35. // Pass this if window is not defined yet
  36. } )( typeof window !== "undefined" ? window : this, function( window, noGlobal ) {
  37. // Edge <= 12 - 13+, Firefox <=18 - 45+, IE 10 - 11, Safari 5.1 - 9+, iOS 6 - 9.1
  38. // throw exceptions when non-strict code (e.g., ASP.NET 4.5) accesses strict mode
  39. // arguments.callee.caller (trac-13335). But as of jQuery 3.0 (2016), strict mode should be common
  40. // enough that all such attempts are guarded in a try block.
  41. var arr = [];
  42. var document = window.document;
  43. var getProto = Object.getPrototypeOf;
  44. var slice = arr.slice;
  45. var concat = arr.concat;
  46. var push = arr.push;
  47. var indexOf = arr.indexOf;
  48. var class2type = {};
  49. var toString = class2type.toString;
  50. var hasOwn = class2type.hasOwnProperty;
  51. var fnToString = hasOwn.toString;
  52. var ObjectFunctionString = fnToString.call( Object );
  53. var support = {};
  54. var isFunction = function isFunction( obj ) {
  55. // Support: Chrome <=57, Firefox <=52
  56. // In some browsers, typeof returns "function" for HTML <object> elements
  57. // (i.e., `typeof document.createElement( "object" ) === "function"`).
  58. // We don't want to classify *any* DOM node as a function.
  59. return typeof obj === "function" && typeof obj.nodeType !== "number";
  60. };
  61. var isWindow = function isWindow( obj ) {
  62. return obj != null && obj === obj.window;
  63. };
  64. var preservedScriptAttributes = {
  65. type: true,
  66. src: true,
  67. nonce: true,
  68. noModule: true
  69. };
  70. function DOMEval( code, node, doc ) {
  71. doc = doc || document;
  72. var i, val,
  73. script = doc.createElement( "script" );
  74. script.text = code;
  75. if ( node ) {
  76. for ( i in preservedScriptAttributes ) {
  77. // Support: Firefox 64+, Edge 18+
  78. // Some browsers don't support the "nonce" property on scripts.
  79. // On the other hand, just using `getAttribute` is not enough as
  80. // the `nonce` attribute is reset to an empty string whenever it
  81. // becomes browsing-context connected.
  82. // See https://github.com/whatwg/html/issues/2369
  83. // See https://html.spec.whatwg.org/#nonce-attributes
  84. // The `node.getAttribute` check was added for the sake of
  85. // `jQuery.globalEval` so that it can fake a nonce-containing node
  86. // via an object.
  87. val = node[ i ] || node.getAttribute && node.getAttribute( i );
  88. if ( val ) {
  89. script.setAttribute( i, val );
  90. }
  91. }
  92. }
  93. doc.head.appendChild( script ).parentNode.removeChild( script );
  94. }
  95. function toType( obj ) {
  96. if ( obj == null ) {
  97. return obj + "";
  98. }
  99. // Support: Android <=2.3 only (functionish RegExp)
  100. return typeof obj === "object" || typeof obj === "function" ?
  101. class2type[ toString.call( obj ) ] || "object" :
  102. typeof obj;
  103. }
  104. /* global Symbol */
  105. // Defining this global in .eslintrc.json would create a danger of using the global
  106. // unguarded in another place, it seems safer to define global only for this module
  107. var
  108. version = "3.4.1",
  109. // Define a local copy of jQuery
  110. jQuery = function( selector, context ) {
  111. // The jQuery object is actually just the init constructor 'enhanced'
  112. // Need init if jQuery is called (just allow error to be thrown if not included)
  113. return new jQuery.fn.init( selector, context );
  114. },
  115. // Support: Android <=4.0 only
  116. // Make sure we trim BOM and NBSP
  117. rtrim = /^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;
  118. jQuery.fn = jQuery.prototype = {
  119. // The current version of jQuery being used
  120. jquery: version,
  121. constructor: jQuery,
  122. // The default length of a jQuery object is 0
  123. length: 0,
  124. toArray: function() {
  125. return slice.call( this );
  126. },
  127. // Get the Nth element in the matched element set OR
  128. // Get the whole matched element set as a clean array
  129. get: function( num ) {
  130. // Return all the elements in a clean array
  131. if ( num == null ) {
  132. return slice.call( this );
  133. }
  134. // Return just the one element from the set
  135. return num < 0 ? this[ num + this.length ] : this[ num ];
  136. },
  137. // Take an array of elements and push it onto the stack
  138. // (returning the new matched element set)
  139. pushStack: function( elems ) {
  140. // Build a new jQuery matched element set
  141. var ret = jQuery.merge( this.constructor(), elems );
  142. // Add the old object onto the stack (as a reference)
  143. ret.prevObject = this;
  144. // Return the newly-formed element set
  145. return ret;
  146. },
  147. // Execute a callback for every element in the matched set.
  148. each: function( callback ) {
  149. return jQuery.each( this, callback );
  150. },
  151. map: function( callback ) {
  152. return this.pushStack( jQuery.map( this, function( elem, i ) {
  153. return callback.call( elem, i, elem );
  154. } ) );
  155. },
  156. slice: function() {
  157. return this.pushStack( slice.apply( this, arguments ) );
  158. },
  159. first: function() {
  160. return this.eq( 0 );
  161. },
  162. last: function() {
  163. return this.eq( -1 );
  164. },
  165. eq: function( i ) {
  166. var len = this.length,
  167. j = +i + ( i < 0 ? len : 0 );
  168. return this.pushStack( j >= 0 && j < len ? [ this[ j ] ] : [] );
  169. },
  170. end: function() {
  171. return this.prevObject || this.constructor();
  172. },
  173. // For internal use only.
  174. // Behaves like an Array's method, not like a jQuery method.
  175. push: push,
  176. sort: arr.sort,
  177. splice: arr.splice
  178. };
  179. jQuery.extend = jQuery.fn.extend = function() {
  180. var options, name, src, copy, copyIsArray, clone,
  181. target = arguments[ 0 ] || {},
  182. i = 1,
  183. length = arguments.length,
  184. deep = false;
  185. // Handle a deep copy situation
  186. if ( typeof target === "boolean" ) {
  187. deep = target;
  188. // Skip the boolean and the target
  189. target = arguments[ i ] || {};
  190. i++;
  191. }
  192. // Handle case when target is a string or something (possible in deep copy)
  193. if ( typeof target !== "object" && !isFunction( target ) ) {
  194. target = {};
  195. }
  196. // Extend jQuery itself if only one argument is passed
  197. if ( i === length ) {
  198. target = this;
  199. i--;
  200. }
  201. for ( ; i < length; i++ ) {
  202. // Only deal with non-null/undefined values
  203. if ( ( options = arguments[ i ] ) != null ) {
  204. // Extend the base object
  205. for ( name in options ) {
  206. copy = options[ name ];
  207. // Prevent Object.prototype pollution
  208. // Prevent never-ending loop
  209. if ( name === "__proto__" || target === copy ) {
  210. continue;
  211. }
  212. // Recurse if we're merging plain objects or arrays
  213. if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
  214. ( copyIsArray = Array.isArray( copy ) ) ) ) {
  215. src = target[ name ];
  216. // Ensure proper type for the source value
  217. if ( copyIsArray && !Array.isArray( src ) ) {
  218. clone = [];
  219. } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
  220. clone = {};
  221. } else {
  222. clone = src;
  223. }
  224. copyIsArray = false;
  225. // Never move original objects, clone them
  226. target[ name ] = jQuery.extend( deep, clone, copy );
  227. // Don't bring in undefined values
  228. } else if ( copy !== undefined ) {
  229. target[ name ] = copy;
  230. }
  231. }
  232. }
  233. }
  234. // Return the modified object
  235. return target;
  236. };
  237. jQuery.extend( {
  238. // Unique for each copy of jQuery on the page
  239. expando: "jQuery" + ( version + Math.random() ).replace( /\D/g, "" ),
  240. // Assume jQuery is ready without the ready module
  241. isReady: true,
  242. error: function( msg ) {
  243. throw new Error( msg );
  244. },
  245. noop: function() {},
  246. isPlainObject: function( obj ) {
  247. var proto, Ctor;
  248. // Detect obvious negatives
  249. // Use toString instead of jQuery.type to catch host objects
  250. if ( !obj || toString.call( obj ) !== "[object Object]" ) {
  251. return false;
  252. }
  253. proto = getProto( obj );
  254. // Objects with no prototype (e.g., `Object.create( null )`) are plain
  255. if ( !proto ) {
  256. return true;
  257. }
  258. // Objects with prototype are plain iff they were constructed by a global Object function
  259. Ctor = hasOwn.call( proto, "constructor" ) && proto.constructor;
  260. return typeof Ctor === "function" && fnToString.call( Ctor ) === ObjectFunctionString;
  261. },
  262. isEmptyObject: function( obj ) {
  263. var name;
  264. for ( name in obj ) {
  265. return false;
  266. }
  267. return true;
  268. },
  269. // Evaluates a script in a global context
  270. globalEval: function( code, options ) {
  271. DOMEval( code, { nonce: options && options.nonce } );
  272. },
  273. each: function( obj, callback ) {
  274. var length, i = 0;
  275. if ( isArrayLike( obj ) ) {
  276. length = obj.length;
  277. for ( ; i < length; i++ ) {
  278. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  279. break;
  280. }
  281. }
  282. } else {
  283. for ( i in obj ) {
  284. if ( callback.call( obj[ i ], i, obj[ i ] ) === false ) {
  285. break;
  286. }
  287. }
  288. }
  289. return obj;
  290. },
  291. // Support: Android <=4.0 only
  292. trim: function( text ) {
  293. return text == null ?
  294. "" :
  295. ( text + "" ).replace( rtrim, "" );
  296. },
  297. // results is for internal usage only
  298. makeArray: function( arr, results ) {
  299. var ret = results || [];
  300. if ( arr != null ) {
  301. if ( isArrayLike( Object( arr ) ) ) {
  302. jQuery.merge( ret,
  303. typeof arr === "string" ?
  304. [ arr ] : arr
  305. );
  306. } else {
  307. push.call( ret, arr );
  308. }
  309. }
  310. return ret;
  311. },
  312. inArray: function( elem, arr, i ) {
  313. return arr == null ? -1 : indexOf.call( arr, elem, i );
  314. },
  315. // Support: Android <=4.0 only, PhantomJS 1 only
  316. // push.apply(_, arraylike) throws on ancient WebKit
  317. merge: function( first, second ) {
  318. var len = +second.length,
  319. j = 0,
  320. i = first.length;
  321. for ( ; j < len; j++ ) {
  322. first[ i++ ] = second[ j ];
  323. }
  324. first.length = i;
  325. return first;
  326. },
  327. grep: function( elems, callback, invert ) {
  328. var callbackInverse,
  329. matches = [],
  330. i = 0,
  331. length = elems.length,
  332. callbackExpect = !invert;
  333. // Go through the array, only saving the items
  334. // that pass the validator function
  335. for ( ; i < length; i++ ) {
  336. callbackInverse = !callback( elems[ i ], i );
  337. if ( callbackInverse !== callbackExpect ) {
  338. matches.push( elems[ i ] );
  339. }
  340. }
  341. return matches;
  342. },
  343. // arg is for internal usage only
  344. map: function( elems, callback, arg ) {
  345. var length, value,
  346. i = 0,
  347. ret = [];
  348. // Go through the array, translating each of the items to their new values
  349. if ( isArrayLike( elems ) ) {
  350. length = elems.length;
  351. for ( ; i < length; i++ ) {
  352. value = callback( elems[ i ], i, arg );
  353. if ( value != null ) {
  354. ret.push( value );
  355. }
  356. }
  357. // Go through every key on the object,
  358. } else {
  359. for ( i in elems ) {
  360. value = callback( elems[ i ], i, arg );
  361. if ( value != null ) {
  362. ret.push( value );
  363. }
  364. }
  365. }
  366. // Flatten any nested arrays
  367. return concat.apply( [], ret );
  368. },
  369. // A global GUID counter for objects
  370. guid: 1,
  371. // jQuery.support is not used in Core but other projects attach their
  372. // properties to it so it needs to exist.
  373. support: support
  374. } );
  375. if ( typeof Symbol === "function" ) {
  376. jQuery.fn[ Symbol.iterator ] = arr[ Symbol.iterator ];
  377. }
  378. // Populate the class2type map
  379. jQuery.each( "Boolean Number String Function Array Date RegExp Object Error Symbol".split( " " ),
  380. function( i, name ) {
  381. class2type[ "[object " + name + "]" ] = name.toLowerCase();
  382. } );
  383. function isArrayLike( obj ) {
  384. // Support: real iOS 8.2 only (not reproducible in simulator)
  385. // `in` check used to prevent JIT error (gh-2145)
  386. // hasOwn isn't used here due to false negatives
  387. // regarding Nodelist length in IE
  388. var length = !!obj && "length" in obj && obj.length,
  389. type = toType( obj );
  390. if ( isFunction( obj ) || isWindow( obj ) ) {
  391. return false;
  392. }
  393. return type === "array" || length === 0 ||
  394. typeof length === "number" && length > 0 && ( length - 1 ) in obj;
  395. }
  396. var Sizzle =
  397. /*!
  398. * Sizzle CSS Selector Engine v2.3.4
  399. * https://sizzlejs.com/
  400. *
  401. * Copyright JS Foundation and other contributors
  402. * Released under the MIT license
  403. * https://js.foundation/
  404. *
  405. * Date: 2019-04-08
  406. */
  407. (function( window ) {
  408. var i,
  409. support,
  410. Expr,
  411. getText,
  412. isXML,
  413. tokenize,
  414. compile,
  415. select,
  416. outermostContext,
  417. sortInput,
  418. hasDuplicate,
  419. // Local document vars
  420. setDocument,
  421. document,
  422. docElem,
  423. documentIsHTML,
  424. rbuggyQSA,
  425. rbuggyMatches,
  426. matches,
  427. contains,
  428. // Instance-specific data
  429. expando = "sizzle" + 1 * new Date(),
  430. preferredDoc = window.document,
  431. dirruns = 0,
  432. done = 0,
  433. classCache = createCache(),
  434. tokenCache = createCache(),
  435. compilerCache = createCache(),
  436. nonnativeSelectorCache = createCache(),
  437. sortOrder = function( a, b ) {
  438. if ( a === b ) {
  439. hasDuplicate = true;
  440. }
  441. return 0;
  442. },
  443. // Instance methods
  444. hasOwn = ({}).hasOwnProperty,
  445. arr = [],
  446. pop = arr.pop,
  447. push_native = arr.push,
  448. push = arr.push,
  449. slice = arr.slice,
  450. // Use a stripped-down indexOf as it's faster than native
  451. // https://jsperf.com/thor-indexof-vs-for/5
  452. indexOf = function( list, elem ) {
  453. var i = 0,
  454. len = list.length;
  455. for ( ; i < len; i++ ) {
  456. if ( list[i] === elem ) {
  457. return i;
  458. }
  459. }
  460. return -1;
  461. },
  462. booleans = "checked|selected|async|autofocus|autoplay|controls|defer|disabled|hidden|ismap|loop|multiple|open|readonly|required|scoped",
  463. // Regular expressions
  464. // http://www.w3.org/TR/css3-selectors/#whitespace
  465. whitespace = "[\\x20\\t\\r\\n\\f]",
  466. // http://www.w3.org/TR/CSS21/syndata.html#value-def-identifier
  467. identifier = "(?:\\\\.|[\\w-]|[^\0-\\xa0])+",
  468. // Attribute selectors: http://www.w3.org/TR/selectors/#attribute-selectors
  469. attributes = "\\[" + whitespace + "*(" + identifier + ")(?:" + whitespace +
  470. // Operator (capture 2)
  471. "*([*^$|!~]?=)" + whitespace +
  472. // "Attribute values must be CSS identifiers [capture 5] or strings [capture 3 or capture 4]"
  473. "*(?:'((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\"|(" + identifier + "))|)" + whitespace +
  474. "*\\]",
  475. pseudos = ":(" + identifier + ")(?:\\((" +
  476. // To reduce the number of selectors needing tokenize in the preFilter, prefer arguments:
  477. // 1. quoted (capture 3; capture 4 or capture 5)
  478. "('((?:\\\\.|[^\\\\'])*)'|\"((?:\\\\.|[^\\\\\"])*)\")|" +
  479. // 2. simple (capture 6)
  480. "((?:\\\\.|[^\\\\()[\\]]|" + attributes + ")*)|" +
  481. // 3. anything else (capture 2)
  482. ".*" +
  483. ")\\)|)",
  484. // Leading and non-escaped trailing whitespace, capturing some non-whitespace characters preceding the latter
  485. rwhitespace = new RegExp( whitespace + "+", "g" ),
  486. rtrim = new RegExp( "^" + whitespace + "+|((?:^|[^\\\\])(?:\\\\.)*)" + whitespace + "+$", "g" ),
  487. rcomma = new RegExp( "^" + whitespace + "*," + whitespace + "*" ),
  488. rcombinators = new RegExp( "^" + whitespace + "*([>+~]|" + whitespace + ")" + whitespace + "*" ),
  489. rdescend = new RegExp( whitespace + "|>" ),
  490. rpseudo = new RegExp( pseudos ),
  491. ridentifier = new RegExp( "^" + identifier + "$" ),
  492. matchExpr = {
  493. "ID": new RegExp( "^#(" + identifier + ")" ),
  494. "CLASS": new RegExp( "^\\.(" + identifier + ")" ),
  495. "TAG": new RegExp( "^(" + identifier + "|[*])" ),
  496. "ATTR": new RegExp( "^" + attributes ),
  497. "PSEUDO": new RegExp( "^" + pseudos ),
  498. "CHILD": new RegExp( "^:(only|first|last|nth|nth-last)-(child|of-type)(?:\\(" + whitespace +
  499. "*(even|odd|(([+-]|)(\\d*)n|)" + whitespace + "*(?:([+-]|)" + whitespace +
  500. "*(\\d+)|))" + whitespace + "*\\)|)", "i" ),
  501. "bool": new RegExp( "^(?:" + booleans + ")$", "i" ),
  502. // For use in libraries implementing .is()
  503. // We use this for POS matching in `select`
  504. "needsContext": new RegExp( "^" + whitespace + "*[>+~]|:(even|odd|eq|gt|lt|nth|first|last)(?:\\(" +
  505. whitespace + "*((?:-\\d)?\\d*)" + whitespace + "*\\)|)(?=[^-]|$)", "i" )
  506. },
  507. rhtml = /HTML$/i,
  508. rinputs = /^(?:input|select|textarea|button)$/i,
  509. rheader = /^h\d$/i,
  510. rnative = /^[^{]+\{\s*\[native \w/,
  511. // Easily-parseable/retrievable ID or TAG or CLASS selectors
  512. rquickExpr = /^(?:#([\w-]+)|(\w+)|\.([\w-]+))$/,
  513. rsibling = /[+~]/,
  514. // CSS escapes
  515. // http://www.w3.org/TR/CSS21/syndata.html#escaped-characters
  516. runescape = new RegExp( "\\\\([\\da-f]{1,6}" + whitespace + "?|(" + whitespace + ")|.)", "ig" ),
  517. funescape = function( _, escaped, escapedWhitespace ) {
  518. var high = "0x" + escaped - 0x10000;
  519. // NaN means non-codepoint
  520. // Support: Firefox<24
  521. // Workaround erroneous numeric interpretation of +"0x"
  522. return high !== high || escapedWhitespace ?
  523. escaped :
  524. high < 0 ?
  525. // BMP codepoint
  526. String.fromCharCode( high + 0x10000 ) :
  527. // Supplemental Plane codepoint (surrogate pair)
  528. String.fromCharCode( high >> 10 | 0xD800, high & 0x3FF | 0xDC00 );
  529. },
  530. // CSS string/identifier serialization
  531. // https://drafts.csswg.org/cssom/#common-serializing-idioms
  532. rcssescape = /([\0-\x1f\x7f]|^-?\d)|^-$|[^\0-\x1f\x7f-\uFFFF\w-]/g,
  533. fcssescape = function( ch, asCodePoint ) {
  534. if ( asCodePoint ) {
  535. // U+0000 NULL becomes U+FFFD REPLACEMENT CHARACTER
  536. if ( ch === "\0" ) {
  537. return "\uFFFD";
  538. }
  539. // Control characters and (dependent upon position) numbers get escaped as code points
  540. return ch.slice( 0, -1 ) + "\\" + ch.charCodeAt( ch.length - 1 ).toString( 16 ) + " ";
  541. }
  542. // Other potentially-special ASCII characters get backslash-escaped
  543. return "\\" + ch;
  544. },
  545. // Used for iframes
  546. // See setDocument()
  547. // Removing the function wrapper causes a "Permission Denied"
  548. // error in IE
  549. unloadHandler = function() {
  550. setDocument();
  551. },
  552. inDisabledFieldset = addCombinator(
  553. function( elem ) {
  554. return elem.disabled === true && elem.nodeName.toLowerCase() === "fieldset";
  555. },
  556. { dir: "parentNode", next: "legend" }
  557. );
  558. // Optimize for push.apply( _, NodeList )
  559. try {
  560. push.apply(
  561. (arr = slice.call( preferredDoc.childNodes )),
  562. preferredDoc.childNodes
  563. );
  564. // Support: Android<4.0
  565. // Detect silently failing push.apply
  566. arr[ preferredDoc.childNodes.length ].nodeType;
  567. } catch ( e ) {
  568. push = { apply: arr.length ?
  569. // Leverage slice if possible
  570. function( target, els ) {
  571. push_native.apply( target, slice.call(els) );
  572. } :
  573. // Support: IE<9
  574. // Otherwise append directly
  575. function( target, els ) {
  576. var j = target.length,
  577. i = 0;
  578. // Can't trust NodeList.length
  579. while ( (target[j++] = els[i++]) ) {}
  580. target.length = j - 1;
  581. }
  582. };
  583. }
  584. function Sizzle( selector, context, results, seed ) {
  585. var m, i, elem, nid, match, groups, newSelector,
  586. newContext = context && context.ownerDocument,
  587. // nodeType defaults to 9, since context defaults to document
  588. nodeType = context ? context.nodeType : 9;
  589. results = results || [];
  590. // Return early from calls with invalid selector or context
  591. if ( typeof selector !== "string" || !selector ||
  592. nodeType !== 1 && nodeType !== 9 && nodeType !== 11 ) {
  593. return results;
  594. }
  595. // Try to shortcut find operations (as opposed to filters) in HTML documents
  596. if ( !seed ) {
  597. if ( ( context ? context.ownerDocument || context : preferredDoc ) !== document ) {
  598. setDocument( context );
  599. }
  600. context = context || document;
  601. if ( documentIsHTML ) {
  602. // If the selector is sufficiently simple, try using a "get*By*" DOM method
  603. // (excepting DocumentFragment context, where the methods don't exist)
  604. if ( nodeType !== 11 && (match = rquickExpr.exec( selector )) ) {
  605. // ID selector
  606. if ( (m = match[1]) ) {
  607. // Document context
  608. if ( nodeType === 9 ) {
  609. if ( (elem = context.getElementById( m )) ) {
  610. // Support: IE, Opera, Webkit
  611. // TODO: identify versions
  612. // getElementById can match elements by name instead of ID
  613. if ( elem.id === m ) {
  614. results.push( elem );
  615. return results;
  616. }
  617. } else {
  618. return results;
  619. }
  620. // Element context
  621. } else {
  622. // Support: IE, Opera, Webkit
  623. // TODO: identify versions
  624. // getElementById can match elements by name instead of ID
  625. if ( newContext && (elem = newContext.getElementById( m )) &&
  626. contains( context, elem ) &&
  627. elem.id === m ) {
  628. results.push( elem );
  629. return results;
  630. }
  631. }
  632. // Type selector
  633. } else if ( match[2] ) {
  634. push.apply( results, context.getElementsByTagName( selector ) );
  635. return results;
  636. // Class selector
  637. } else if ( (m = match[3]) && support.getElementsByClassName &&
  638. context.getElementsByClassName ) {
  639. push.apply( results, context.getElementsByClassName( m ) );
  640. return results;
  641. }
  642. }
  643. // Take advantage of querySelectorAll
  644. if ( support.qsa &&
  645. !nonnativeSelectorCache[ selector + " " ] &&
  646. (!rbuggyQSA || !rbuggyQSA.test( selector )) &&
  647. // Support: IE 8 only
  648. // Exclude object elements
  649. (nodeType !== 1 || context.nodeName.toLowerCase() !== "object") ) {
  650. newSelector = selector;
  651. newContext = context;
  652. // qSA considers elements outside a scoping root when evaluating child or
  653. // descendant combinators, which is not what we want.
  654. // In such cases, we work around the behavior by prefixing every selector in the
  655. // list with an ID selector referencing the scope context.
  656. // Thanks to Andrew Dupont for this technique.
  657. if ( nodeType === 1 && rdescend.test( selector ) ) {
  658. // Capture the context ID, setting it first if necessary
  659. if ( (nid = context.getAttribute( "id" )) ) {
  660. nid = nid.replace( rcssescape, fcssescape );
  661. } else {
  662. context.setAttribute( "id", (nid = expando) );
  663. }
  664. // Prefix every selector in the list
  665. groups = tokenize( selector );
  666. i = groups.length;
  667. while ( i-- ) {
  668. groups[i] = "#" + nid + " " + toSelector( groups[i] );
  669. }
  670. newSelector = groups.join( "," );
  671. // Expand context for sibling selectors
  672. newContext = rsibling.test( selector ) && testContext( context.parentNode ) ||
  673. context;
  674. }
  675. try {
  676. push.apply( results,
  677. newContext.querySelectorAll( newSelector )
  678. );
  679. return results;
  680. } catch ( qsaError ) {
  681. nonnativeSelectorCache( selector, true );
  682. } finally {
  683. if ( nid === expando ) {
  684. context.removeAttribute( "id" );
  685. }
  686. }
  687. }
  688. }
  689. }
  690. // All others
  691. return select( selector.replace( rtrim, "$1" ), context, results, seed );
  692. }
  693. /**
  694. * Create key-value caches of limited size
  695. * @returns {function(string, object)} Returns the Object data after storing it on itself with
  696. * property name the (space-suffixed) string and (if the cache is larger than Expr.cacheLength)
  697. * deleting the oldest entry
  698. */
  699. function createCache() {
  700. var keys = [];
  701. function cache( key, value ) {
  702. // Use (key + " ") to avoid collision with native prototype properties (see Issue #157)
  703. if ( keys.push( key + " " ) > Expr.cacheLength ) {
  704. // Only keep the most recent entries
  705. delete cache[ keys.shift() ];
  706. }
  707. return (cache[ key + " " ] = value);
  708. }
  709. return cache;
  710. }
  711. /**
  712. * Mark a function for special use by Sizzle
  713. * @param {Function} fn The function to mark
  714. */
  715. function markFunction( fn ) {
  716. fn[ expando ] = true;
  717. return fn;
  718. }
  719. /**
  720. * Support testing using an element
  721. * @param {Function} fn Passed the created element and returns a boolean result
  722. */
  723. function assert( fn ) {
  724. var el = document.createElement("fieldset");
  725. try {
  726. return !!fn( el );
  727. } catch (e) {
  728. return false;
  729. } finally {
  730. // Remove from its parent by default
  731. if ( el.parentNode ) {
  732. el.parentNode.removeChild( el );
  733. }
  734. // release memory in IE
  735. el = null;
  736. }
  737. }
  738. /**
  739. * Adds the same handler for all of the specified attrs
  740. * @param {String} attrs Pipe-separated list of attributes
  741. * @param {Function} handler The method that will be applied
  742. */
  743. function addHandle( attrs, handler ) {
  744. var arr = attrs.split("|"),
  745. i = arr.length;
  746. while ( i-- ) {
  747. Expr.attrHandle[ arr[i] ] = handler;
  748. }
  749. }
  750. /**
  751. * Checks document order of two siblings
  752. * @param {Element} a
  753. * @param {Element} b
  754. * @returns {Number} Returns less than 0 if a precedes b, greater than 0 if a follows b
  755. */
  756. function siblingCheck( a, b ) {
  757. var cur = b && a,
  758. diff = cur && a.nodeType === 1 && b.nodeType === 1 &&
  759. a.sourceIndex - b.sourceIndex;
  760. // Use IE sourceIndex if available on both nodes
  761. if ( diff ) {
  762. return diff;
  763. }
  764. // Check if b follows a
  765. if ( cur ) {
  766. while ( (cur = cur.nextSibling) ) {
  767. if ( cur === b ) {
  768. return -1;
  769. }
  770. }
  771. }
  772. return a ? 1 : -1;
  773. }
  774. /**
  775. * Returns a function to use in pseudos for input types
  776. * @param {String} type
  777. */
  778. function createInputPseudo( type ) {
  779. return function( elem ) {
  780. var name = elem.nodeName.toLowerCase();
  781. return name === "input" && elem.type === type;
  782. };
  783. }
  784. /**
  785. * Returns a function to use in pseudos for buttons
  786. * @param {String} type
  787. */
  788. function createButtonPseudo( type ) {
  789. return function( elem ) {
  790. var name = elem.nodeName.toLowerCase();
  791. return (name === "input" || name === "button") && elem.type === type;
  792. };
  793. }
  794. /**
  795. * Returns a function to use in pseudos for :enabled/:disabled
  796. * @param {Boolean} disabled true for :disabled; false for :enabled
  797. */
  798. function createDisabledPseudo( disabled ) {
  799. // Known :disabled false positives: fieldset[disabled] > legend:nth-of-type(n+2) :can-disable
  800. return function( elem ) {
  801. // Only certain elements can match :enabled or :disabled
  802. // https://html.spec.whatwg.org/multipage/scripting.html#selector-enabled
  803. // https://html.spec.whatwg.org/multipage/scripting.html#selector-disabled
  804. if ( "form" in elem ) {
  805. // Check for inherited disabledness on relevant non-disabled elements:
  806. // * listed form-associated elements in a disabled fieldset
  807. // https://html.spec.whatwg.org/multipage/forms.html#category-listed
  808. // https://html.spec.whatwg.org/multipage/forms.html#concept-fe-disabled
  809. // * option elements in a disabled optgroup
  810. // https://html.spec.whatwg.org/multipage/forms.html#concept-option-disabled
  811. // All such elements have a "form" property.
  812. if ( elem.parentNode && elem.disabled === false ) {
  813. // Option elements defer to a parent optgroup if present
  814. if ( "label" in elem ) {
  815. if ( "label" in elem.parentNode ) {
  816. return elem.parentNode.disabled === disabled;
  817. } else {
  818. return elem.disabled === disabled;
  819. }
  820. }
  821. // Support: IE 6 - 11
  822. // Use the isDisabled shortcut property to check for disabled fieldset ancestors
  823. return elem.isDisabled === disabled ||
  824. // Where there is no isDisabled, check manually
  825. /* jshint -W018 */
  826. elem.isDisabled !== !disabled &&
  827. inDisabledFieldset( elem ) === disabled;
  828. }
  829. return elem.disabled === disabled;
  830. // Try to winnow out elements that can't be disabled before trusting the disabled property.
  831. // Some victims get caught in our net (label, legend, menu, track), but it shouldn't
  832. // even exist on them, let alone have a boolean value.
  833. } else if ( "label" in elem ) {
  834. return elem.disabled === disabled;
  835. }
  836. // Remaining elements are neither :enabled nor :disabled
  837. return false;
  838. };
  839. }
  840. /**
  841. * Returns a function to use in pseudos for positionals
  842. * @param {Function} fn
  843. */
  844. function createPositionalPseudo( fn ) {
  845. return markFunction(function( argument ) {
  846. argument = +argument;
  847. return markFunction(function( seed, matches ) {
  848. var j,
  849. matchIndexes = fn( [], seed.length, argument ),
  850. i = matchIndexes.length;
  851. // Match elements found at the specified indexes
  852. while ( i-- ) {
  853. if ( seed[ (j = matchIndexes[i]) ] ) {
  854. seed[j] = !(matches[j] = seed[j]);
  855. }
  856. }
  857. });
  858. });
  859. }
  860. /**
  861. * Checks a node for validity as a Sizzle context
  862. * @param {Element|Object=} context
  863. * @returns {Element|Object|Boolean} The input node if acceptable, otherwise a falsy value
  864. */
  865. function testContext( context ) {
  866. return context && typeof context.getElementsByTagName !== "undefined" && context;
  867. }
  868. // Expose support vars for convenience
  869. support = Sizzle.support = {};
  870. /**
  871. * Detects XML nodes
  872. * @param {Element|Object} elem An element or a document
  873. * @returns {Boolean} True iff elem is a non-HTML XML node
  874. */
  875. isXML = Sizzle.isXML = function( elem ) {
  876. var namespace = elem.namespaceURI,
  877. docElem = (elem.ownerDocument || elem).documentElement;
  878. // Support: IE <=8
  879. // Assume HTML when documentElement doesn't yet exist, such as inside loading iframes
  880. // https://bugs.jquery.com/ticket/4833
  881. return !rhtml.test( namespace || docElem && docElem.nodeName || "HTML" );
  882. };
  883. /**
  884. * Sets document-related variables once based on the current document
  885. * @param {Element|Object} [doc] An element or document object to use to set the document
  886. * @returns {Object} Returns the current document
  887. */
  888. setDocument = Sizzle.setDocument = function( node ) {
  889. var hasCompare, subWindow,
  890. doc = node ? node.ownerDocument || node : preferredDoc;
  891. // Return early if doc is invalid or already selected
  892. if ( doc === document || doc.nodeType !== 9 || !doc.documentElement ) {
  893. return document;
  894. }
  895. // Update global variables
  896. document = doc;
  897. docElem = document.documentElement;
  898. documentIsHTML = !isXML( document );
  899. // Support: IE 9-11, Edge
  900. // Accessing iframe documents after unload throws "permission denied" errors (jQuery #13936)
  901. if ( preferredDoc !== document &&
  902. (subWindow = document.defaultView) && subWindow.top !== subWindow ) {
  903. // Support: IE 11, Edge
  904. if ( subWindow.addEventListener ) {
  905. subWindow.addEventListener( "unload", unloadHandler, false );
  906. // Support: IE 9 - 10 only
  907. } else if ( subWindow.attachEvent ) {
  908. subWindow.attachEvent( "onunload", unloadHandler );
  909. }
  910. }
  911. /* Attributes
  912. ---------------------------------------------------------------------- */
  913. // Support: IE<8
  914. // Verify that getAttribute really returns attributes and not properties
  915. // (excepting IE8 booleans)
  916. support.attributes = assert(function( el ) {
  917. el.className = "i";
  918. return !el.getAttribute("className");
  919. });
  920. /* getElement(s)By*
  921. ---------------------------------------------------------------------- */
  922. // Check if getElementsByTagName("*") returns only elements
  923. support.getElementsByTagName = assert(function( el ) {
  924. el.appendChild( document.createComment("") );
  925. return !el.getElementsByTagName("*").length;
  926. });
  927. // Support: IE<9
  928. support.getElementsByClassName = rnative.test( document.getElementsByClassName );
  929. // Support: IE<10
  930. // Check if getElementById returns elements by name
  931. // The broken getElementById methods don't pick up programmatically-set names,
  932. // so use a roundabout getElementsByName test
  933. support.getById = assert(function( el ) {
  934. docElem.appendChild( el ).id = expando;
  935. return !document.getElementsByName || !document.getElementsByName( expando ).length;
  936. });
  937. // ID filter and find
  938. if ( support.getById ) {
  939. Expr.filter["ID"] = function( id ) {
  940. var attrId = id.replace( runescape, funescape );
  941. return function( elem ) {
  942. return elem.getAttribute("id") === attrId;
  943. };
  944. };
  945. Expr.find["ID"] = function( id, context ) {
  946. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  947. var elem = context.getElementById( id );
  948. return elem ? [ elem ] : [];
  949. }
  950. };
  951. } else {
  952. Expr.filter["ID"] = function( id ) {
  953. var attrId = id.replace( runescape, funescape );
  954. return function( elem ) {
  955. var node = typeof elem.getAttributeNode !== "undefined" &&
  956. elem.getAttributeNode("id");
  957. return node && node.value === attrId;
  958. };
  959. };
  960. // Support: IE 6 - 7 only
  961. // getElementById is not reliable as a find shortcut
  962. Expr.find["ID"] = function( id, context ) {
  963. if ( typeof context.getElementById !== "undefined" && documentIsHTML ) {
  964. var node, i, elems,
  965. elem = context.getElementById( id );
  966. if ( elem ) {
  967. // Verify the id attribute
  968. node = elem.getAttributeNode("id");
  969. if ( node && node.value === id ) {
  970. return [ elem ];
  971. }
  972. // Fall back on getElementsByName
  973. elems = context.getElementsByName( id );
  974. i = 0;
  975. while ( (elem = elems[i++]) ) {
  976. node = elem.getAttributeNode("id");
  977. if ( node && node.value === id ) {
  978. return [ elem ];
  979. }
  980. }
  981. }
  982. return [];
  983. }
  984. };
  985. }
  986. // Tag
  987. Expr.find["TAG"] = support.getElementsByTagName ?
  988. function( tag, context ) {
  989. if ( typeof context.getElementsByTagName !== "undefined" ) {
  990. return context.getElementsByTagName( tag );
  991. // DocumentFragment nodes don't have gEBTN
  992. } else if ( support.qsa ) {
  993. return context.querySelectorAll( tag );
  994. }
  995. } :
  996. function( tag, context ) {
  997. var elem,
  998. tmp = [],
  999. i = 0,
  1000. // By happy coincidence, a (broken) gEBTN appears on DocumentFragment nodes too
  1001. results = context.getElementsByTagName( tag );
  1002. // Filter out possible comments
  1003. if ( tag === "*" ) {
  1004. while ( (elem = results[i++]) ) {
  1005. if ( elem.nodeType === 1 ) {
  1006. tmp.push( elem );
  1007. }
  1008. }
  1009. return tmp;
  1010. }
  1011. return results;
  1012. };
  1013. // Class
  1014. Expr.find["CLASS"] = support.getElementsByClassName && function( className, context ) {
  1015. if ( typeof context.getElementsByClassName !== "undefined" && documentIsHTML ) {
  1016. return context.getElementsByClassName( className );
  1017. }
  1018. };
  1019. /* QSA/matchesSelector
  1020. ---------------------------------------------------------------------- */
  1021. // QSA and matchesSelector support
  1022. // matchesSelector(:active) reports false when true (IE9/Opera 11.5)
  1023. rbuggyMatches = [];
  1024. // qSa(:focus) reports false when true (Chrome 21)
  1025. // We allow this because of a bug in IE8/9 that throws an error
  1026. // whenever `document.activeElement` is accessed on an iframe
  1027. // So, we allow :focus to pass through QSA all the time to avoid the IE error
  1028. // See https://bugs.jquery.com/ticket/13378
  1029. rbuggyQSA = [];
  1030. if ( (support.qsa = rnative.test( document.querySelectorAll )) ) {
  1031. // Build QSA regex
  1032. // Regex strategy adopted from Diego Perini
  1033. assert(function( el ) {
  1034. // Select is set to empty string on purpose
  1035. // This is to test IE's treatment of not explicitly
  1036. // setting a boolean content attribute,
  1037. // since its presence should be enough
  1038. // https://bugs.jquery.com/ticket/12359
  1039. docElem.appendChild( el ).innerHTML = "<a id='" + expando + "'></a>" +
  1040. "<select id='" + expando + "-\r\\' msallowcapture=''>" +
  1041. "<option selected=''></option></select>";
  1042. // Support: IE8, Opera 11-12.16
  1043. // Nothing should be selected when empty strings follow ^= or $= or *=
  1044. // The test attribute must be unknown in Opera but "safe" for WinRT
  1045. // https://msdn.microsoft.com/en-us/library/ie/hh465388.aspx#attribute_section
  1046. if ( el.querySelectorAll("[msallowcapture^='']").length ) {
  1047. rbuggyQSA.push( "[*^$]=" + whitespace + "*(?:''|\"\")" );
  1048. }
  1049. // Support: IE8
  1050. // Boolean attributes and "value" are not treated correctly
  1051. if ( !el.querySelectorAll("[selected]").length ) {
  1052. rbuggyQSA.push( "\\[" + whitespace + "*(?:value|" + booleans + ")" );
  1053. }
  1054. // Support: Chrome<29, Android<4.4, Safari<7.0+, iOS<7.0+, PhantomJS<1.9.8+
  1055. if ( !el.querySelectorAll( "[id~=" + expando + "-]" ).length ) {
  1056. rbuggyQSA.push("~=");
  1057. }
  1058. // Webkit/Opera - :checked should return selected option elements
  1059. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1060. // IE8 throws error here and will not see later tests
  1061. if ( !el.querySelectorAll(":checked").length ) {
  1062. rbuggyQSA.push(":checked");
  1063. }
  1064. // Support: Safari 8+, iOS 8+
  1065. // https://bugs.webkit.org/show_bug.cgi?id=136851
  1066. // In-page `selector#id sibling-combinator selector` fails
  1067. if ( !el.querySelectorAll( "a#" + expando + "+*" ).length ) {
  1068. rbuggyQSA.push(".#.+[+~]");
  1069. }
  1070. });
  1071. assert(function( el ) {
  1072. el.innerHTML = "<a href='' disabled='disabled'></a>" +
  1073. "<select disabled='disabled'><option/></select>";
  1074. // Support: Windows 8 Native Apps
  1075. // The type and name attributes are restricted during .innerHTML assignment
  1076. var input = document.createElement("input");
  1077. input.setAttribute( "type", "hidden" );
  1078. el.appendChild( input ).setAttribute( "name", "D" );
  1079. // Support: IE8
  1080. // Enforce case-sensitivity of name attribute
  1081. if ( el.querySelectorAll("[name=d]").length ) {
  1082. rbuggyQSA.push( "name" + whitespace + "*[*^$|!~]?=" );
  1083. }
  1084. // FF 3.5 - :enabled/:disabled and hidden elements (hidden elements are still enabled)
  1085. // IE8 throws error here and will not see later tests
  1086. if ( el.querySelectorAll(":enabled").length !== 2 ) {
  1087. rbuggyQSA.push( ":enabled", ":disabled" );
  1088. }
  1089. // Support: IE9-11+
  1090. // IE's :disabled selector does not pick up the children of disabled fieldsets
  1091. docElem.appendChild( el ).disabled = true;
  1092. if ( el.querySelectorAll(":disabled").length !== 2 ) {
  1093. rbuggyQSA.push( ":enabled", ":disabled" );
  1094. }
  1095. // Opera 10-11 does not throw on post-comma invalid pseudos
  1096. el.querySelectorAll("*,:x");
  1097. rbuggyQSA.push(",.*:");
  1098. });
  1099. }
  1100. if ( (support.matchesSelector = rnative.test( (matches = docElem.matches ||
  1101. docElem.webkitMatchesSelector ||
  1102. docElem.mozMatchesSelector ||
  1103. docElem.oMatchesSelector ||
  1104. docElem.msMatchesSelector) )) ) {
  1105. assert(function( el ) {
  1106. // Check to see if it's possible to do matchesSelector
  1107. // on a disconnected node (IE 9)
  1108. support.disconnectedMatch = matches.call( el, "*" );
  1109. // This should fail with an exception
  1110. // Gecko does not error, returns false instead
  1111. matches.call( el, "[s!='']:x" );
  1112. rbuggyMatches.push( "!=", pseudos );
  1113. });
  1114. }
  1115. rbuggyQSA = rbuggyQSA.length && new RegExp( rbuggyQSA.join("|") );
  1116. rbuggyMatches = rbuggyMatches.length && new RegExp( rbuggyMatches.join("|") );
  1117. /* Contains
  1118. ---------------------------------------------------------------------- */
  1119. hasCompare = rnative.test( docElem.compareDocumentPosition );
  1120. // Element contains another
  1121. // Purposefully self-exclusive
  1122. // As in, an element does not contain itself
  1123. contains = hasCompare || rnative.test( docElem.contains ) ?
  1124. function( a, b ) {
  1125. var adown = a.nodeType === 9 ? a.documentElement : a,
  1126. bup = b && b.parentNode;
  1127. return a === bup || !!( bup && bup.nodeType === 1 && (
  1128. adown.contains ?
  1129. adown.contains( bup ) :
  1130. a.compareDocumentPosition && a.compareDocumentPosition( bup ) & 16
  1131. ));
  1132. } :
  1133. function( a, b ) {
  1134. if ( b ) {
  1135. while ( (b = b.parentNode) ) {
  1136. if ( b === a ) {
  1137. return true;
  1138. }
  1139. }
  1140. }
  1141. return false;
  1142. };
  1143. /* Sorting
  1144. ---------------------------------------------------------------------- */
  1145. // Document order sorting
  1146. sortOrder = hasCompare ?
  1147. function( a, b ) {
  1148. // Flag for duplicate removal
  1149. if ( a === b ) {
  1150. hasDuplicate = true;
  1151. return 0;
  1152. }
  1153. // Sort on method existence if only one input has compareDocumentPosition
  1154. var compare = !a.compareDocumentPosition - !b.compareDocumentPosition;
  1155. if ( compare ) {
  1156. return compare;
  1157. }
  1158. // Calculate position if both inputs belong to the same document
  1159. compare = ( a.ownerDocument || a ) === ( b.ownerDocument || b ) ?
  1160. a.compareDocumentPosition( b ) :
  1161. // Otherwise we know they are disconnected
  1162. 1;
  1163. // Disconnected nodes
  1164. if ( compare & 1 ||
  1165. (!support.sortDetached && b.compareDocumentPosition( a ) === compare) ) {
  1166. // Choose the first element that is related to our preferred document
  1167. if ( a === document || a.ownerDocument === preferredDoc && contains(preferredDoc, a) ) {
  1168. return -1;
  1169. }
  1170. if ( b === document || b.ownerDocument === preferredDoc && contains(preferredDoc, b) ) {
  1171. return 1;
  1172. }
  1173. // Maintain original order
  1174. return sortInput ?
  1175. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  1176. 0;
  1177. }
  1178. return compare & 4 ? -1 : 1;
  1179. } :
  1180. function( a, b ) {
  1181. // Exit early if the nodes are identical
  1182. if ( a === b ) {
  1183. hasDuplicate = true;
  1184. return 0;
  1185. }
  1186. var cur,
  1187. i = 0,
  1188. aup = a.parentNode,
  1189. bup = b.parentNode,
  1190. ap = [ a ],
  1191. bp = [ b ];
  1192. // Parentless nodes are either documents or disconnected
  1193. if ( !aup || !bup ) {
  1194. return a === document ? -1 :
  1195. b === document ? 1 :
  1196. aup ? -1 :
  1197. bup ? 1 :
  1198. sortInput ?
  1199. ( indexOf( sortInput, a ) - indexOf( sortInput, b ) ) :
  1200. 0;
  1201. // If the nodes are siblings, we can do a quick check
  1202. } else if ( aup === bup ) {
  1203. return siblingCheck( a, b );
  1204. }
  1205. // Otherwise we need full lists of their ancestors for comparison
  1206. cur = a;
  1207. while ( (cur = cur.parentNode) ) {
  1208. ap.unshift( cur );
  1209. }
  1210. cur = b;
  1211. while ( (cur = cur.parentNode) ) {
  1212. bp.unshift( cur );
  1213. }
  1214. // Walk down the tree looking for a discrepancy
  1215. while ( ap[i] === bp[i] ) {
  1216. i++;
  1217. }
  1218. return i ?
  1219. // Do a sibling check if the nodes have a common ancestor
  1220. siblingCheck( ap[i], bp[i] ) :
  1221. // Otherwise nodes in our document sort first
  1222. ap[i] === preferredDoc ? -1 :
  1223. bp[i] === preferredDoc ? 1 :
  1224. 0;
  1225. };
  1226. return document;
  1227. };
  1228. Sizzle.matches = function( expr, elements ) {
  1229. return Sizzle( expr, null, null, elements );
  1230. };
  1231. Sizzle.matchesSelector = function( elem, expr ) {
  1232. // Set document vars if needed
  1233. if ( ( elem.ownerDocument || elem ) !== document ) {
  1234. setDocument( elem );
  1235. }
  1236. if ( support.matchesSelector && documentIsHTML &&
  1237. !nonnativeSelectorCache[ expr + " " ] &&
  1238. ( !rbuggyMatches || !rbuggyMatches.test( expr ) ) &&
  1239. ( !rbuggyQSA || !rbuggyQSA.test( expr ) ) ) {
  1240. try {
  1241. var ret = matches.call( elem, expr );
  1242. // IE 9's matchesSelector returns false on disconnected nodes
  1243. if ( ret || support.disconnectedMatch ||
  1244. // As well, disconnected nodes are said to be in a document
  1245. // fragment in IE 9
  1246. elem.document && elem.document.nodeType !== 11 ) {
  1247. return ret;
  1248. }
  1249. } catch (e) {
  1250. nonnativeSelectorCache( expr, true );
  1251. }
  1252. }
  1253. return Sizzle( expr, document, null, [ elem ] ).length > 0;
  1254. };
  1255. Sizzle.contains = function( context, elem ) {
  1256. // Set document vars if needed
  1257. if ( ( context.ownerDocument || context ) !== document ) {
  1258. setDocument( context );
  1259. }
  1260. return contains( context, elem );
  1261. };
  1262. Sizzle.attr = function( elem, name ) {
  1263. // Set document vars if needed
  1264. if ( ( elem.ownerDocument || elem ) !== document ) {
  1265. setDocument( elem );
  1266. }
  1267. var fn = Expr.attrHandle[ name.toLowerCase() ],
  1268. // Don't get fooled by Object.prototype properties (jQuery #13807)
  1269. val = fn && hasOwn.call( Expr.attrHandle, name.toLowerCase() ) ?
  1270. fn( elem, name, !documentIsHTML ) :
  1271. undefined;
  1272. return val !== undefined ?
  1273. val :
  1274. support.attributes || !documentIsHTML ?
  1275. elem.getAttribute( name ) :
  1276. (val = elem.getAttributeNode(name)) && val.specified ?
  1277. val.value :
  1278. null;
  1279. };
  1280. Sizzle.escape = function( sel ) {
  1281. return (sel + "").replace( rcssescape, fcssescape );
  1282. };
  1283. Sizzle.error = function( msg ) {
  1284. throw new Error( "Syntax error, unrecognized expression: " + msg );
  1285. };
  1286. /**
  1287. * Document sorting and removing duplicates
  1288. * @param {ArrayLike} results
  1289. */
  1290. Sizzle.uniqueSort = function( results ) {
  1291. var elem,
  1292. duplicates = [],
  1293. j = 0,
  1294. i = 0;
  1295. // Unless we *know* we can detect duplicates, assume their presence
  1296. hasDuplicate = !support.detectDuplicates;
  1297. sortInput = !support.sortStable && results.slice( 0 );
  1298. results.sort( sortOrder );
  1299. if ( hasDuplicate ) {
  1300. while ( (elem = results[i++]) ) {
  1301. if ( elem === results[ i ] ) {
  1302. j = duplicates.push( i );
  1303. }
  1304. }
  1305. while ( j-- ) {
  1306. results.splice( duplicates[ j ], 1 );
  1307. }
  1308. }
  1309. // Clear input after sorting to release objects
  1310. // See https://github.com/jquery/sizzle/pull/225
  1311. sortInput = null;
  1312. return results;
  1313. };
  1314. /**
  1315. * Utility function for retrieving the text value of an array of DOM nodes
  1316. * @param {Array|Element} elem
  1317. */
  1318. getText = Sizzle.getText = function( elem ) {
  1319. var node,
  1320. ret = "",
  1321. i = 0,
  1322. nodeType = elem.nodeType;
  1323. if ( !nodeType ) {
  1324. // If no nodeType, this is expected to be an array
  1325. while ( (node = elem[i++]) ) {
  1326. // Do not traverse comment nodes
  1327. ret += getText( node );
  1328. }
  1329. } else if ( nodeType === 1 || nodeType === 9 || nodeType === 11 ) {
  1330. // Use textContent for elements
  1331. // innerText usage removed for consistency of new lines (jQuery #11153)
  1332. if ( typeof elem.textContent === "string" ) {
  1333. return elem.textContent;
  1334. } else {
  1335. // Traverse its children
  1336. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1337. ret += getText( elem );
  1338. }
  1339. }
  1340. } else if ( nodeType === 3 || nodeType === 4 ) {
  1341. return elem.nodeValue;
  1342. }
  1343. // Do not include comment or processing instruction nodes
  1344. return ret;
  1345. };
  1346. Expr = Sizzle.selectors = {
  1347. // Can be adjusted by the user
  1348. cacheLength: 50,
  1349. createPseudo: markFunction,
  1350. match: matchExpr,
  1351. attrHandle: {},
  1352. find: {},
  1353. relative: {
  1354. ">": { dir: "parentNode", first: true },
  1355. " ": { dir: "parentNode" },
  1356. "+": { dir: "previousSibling", first: true },
  1357. "~": { dir: "previousSibling" }
  1358. },
  1359. preFilter: {
  1360. "ATTR": function( match ) {
  1361. match[1] = match[1].replace( runescape, funescape );
  1362. // Move the given value to match[3] whether quoted or unquoted
  1363. match[3] = ( match[3] || match[4] || match[5] || "" ).replace( runescape, funescape );
  1364. if ( match[2] === "~=" ) {
  1365. match[3] = " " + match[3] + " ";
  1366. }
  1367. return match.slice( 0, 4 );
  1368. },
  1369. "CHILD": function( match ) {
  1370. /* matches from matchExpr["CHILD"]
  1371. 1 type (only|nth|...)
  1372. 2 what (child|of-type)
  1373. 3 argument (even|odd|\d*|\d*n([+-]\d+)?|...)
  1374. 4 xn-component of xn+y argument ([+-]?\d*n|)
  1375. 5 sign of xn-component
  1376. 6 x of xn-component
  1377. 7 sign of y-component
  1378. 8 y of y-component
  1379. */
  1380. match[1] = match[1].toLowerCase();
  1381. if ( match[1].slice( 0, 3 ) === "nth" ) {
  1382. // nth-* requires argument
  1383. if ( !match[3] ) {
  1384. Sizzle.error( match[0] );
  1385. }
  1386. // numeric x and y parameters for Expr.filter.CHILD
  1387. // remember that false/true cast respectively to 0/1
  1388. match[4] = +( match[4] ? match[5] + (match[6] || 1) : 2 * ( match[3] === "even" || match[3] === "odd" ) );
  1389. match[5] = +( ( match[7] + match[8] ) || match[3] === "odd" );
  1390. // other types prohibit arguments
  1391. } else if ( match[3] ) {
  1392. Sizzle.error( match[0] );
  1393. }
  1394. return match;
  1395. },
  1396. "PSEUDO": function( match ) {
  1397. var excess,
  1398. unquoted = !match[6] && match[2];
  1399. if ( matchExpr["CHILD"].test( match[0] ) ) {
  1400. return null;
  1401. }
  1402. // Accept quoted arguments as-is
  1403. if ( match[3] ) {
  1404. match[2] = match[4] || match[5] || "";
  1405. // Strip excess characters from unquoted arguments
  1406. } else if ( unquoted && rpseudo.test( unquoted ) &&
  1407. // Get excess from tokenize (recursively)
  1408. (excess = tokenize( unquoted, true )) &&
  1409. // advance to the next closing parenthesis
  1410. (excess = unquoted.indexOf( ")", unquoted.length - excess ) - unquoted.length) ) {
  1411. // excess is a negative index
  1412. match[0] = match[0].slice( 0, excess );
  1413. match[2] = unquoted.slice( 0, excess );
  1414. }
  1415. // Return only captures needed by the pseudo filter method (type and argument)
  1416. return match.slice( 0, 3 );
  1417. }
  1418. },
  1419. filter: {
  1420. "TAG": function( nodeNameSelector ) {
  1421. var nodeName = nodeNameSelector.replace( runescape, funescape ).toLowerCase();
  1422. return nodeNameSelector === "*" ?
  1423. function() { return true; } :
  1424. function( elem ) {
  1425. return elem.nodeName && elem.nodeName.toLowerCase() === nodeName;
  1426. };
  1427. },
  1428. "CLASS": function( className ) {
  1429. var pattern = classCache[ className + " " ];
  1430. return pattern ||
  1431. (pattern = new RegExp( "(^|" + whitespace + ")" + className + "(" + whitespace + "|$)" )) &&
  1432. classCache( className, function( elem ) {
  1433. return pattern.test( typeof elem.className === "string" && elem.className || typeof elem.getAttribute !== "undefined" && elem.getAttribute("class") || "" );
  1434. });
  1435. },
  1436. "ATTR": function( name, operator, check ) {
  1437. return function( elem ) {
  1438. var result = Sizzle.attr( elem, name );
  1439. if ( result == null ) {
  1440. return operator === "!=";
  1441. }
  1442. if ( !operator ) {
  1443. return true;
  1444. }
  1445. result += "";
  1446. return operator === "=" ? result === check :
  1447. operator === "!=" ? result !== check :
  1448. operator === "^=" ? check && result.indexOf( check ) === 0 :
  1449. operator === "*=" ? check && result.indexOf( check ) > -1 :
  1450. operator === "$=" ? check && result.slice( -check.length ) === check :
  1451. operator === "~=" ? ( " " + result.replace( rwhitespace, " " ) + " " ).indexOf( check ) > -1 :
  1452. operator === "|=" ? result === check || result.slice( 0, check.length + 1 ) === check + "-" :
  1453. false;
  1454. };
  1455. },
  1456. "CHILD": function( type, what, argument, first, last ) {
  1457. var simple = type.slice( 0, 3 ) !== "nth",
  1458. forward = type.slice( -4 ) !== "last",
  1459. ofType = what === "of-type";
  1460. return first === 1 && last === 0 ?
  1461. // Shortcut for :nth-*(n)
  1462. function( elem ) {
  1463. return !!elem.parentNode;
  1464. } :
  1465. function( elem, context, xml ) {
  1466. var cache, uniqueCache, outerCache, node, nodeIndex, start,
  1467. dir = simple !== forward ? "nextSibling" : "previousSibling",
  1468. parent = elem.parentNode,
  1469. name = ofType && elem.nodeName.toLowerCase(),
  1470. useCache = !xml && !ofType,
  1471. diff = false;
  1472. if ( parent ) {
  1473. // :(first|last|only)-(child|of-type)
  1474. if ( simple ) {
  1475. while ( dir ) {
  1476. node = elem;
  1477. while ( (node = node[ dir ]) ) {
  1478. if ( ofType ?
  1479. node.nodeName.toLowerCase() === name :
  1480. node.nodeType === 1 ) {
  1481. return false;
  1482. }
  1483. }
  1484. // Reverse direction for :only-* (if we haven't yet done so)
  1485. start = dir = type === "only" && !start && "nextSibling";
  1486. }
  1487. return true;
  1488. }
  1489. start = [ forward ? parent.firstChild : parent.lastChild ];
  1490. // non-xml :nth-child(...) stores cache data on `parent`
  1491. if ( forward && useCache ) {
  1492. // Seek `elem` from a previously-cached index
  1493. // ...in a gzip-friendly way
  1494. node = parent;
  1495. outerCache = node[ expando ] || (node[ expando ] = {});
  1496. // Support: IE <9 only
  1497. // Defend against cloned attroperties (jQuery gh-1709)
  1498. uniqueCache = outerCache[ node.uniqueID ] ||
  1499. (outerCache[ node.uniqueID ] = {});
  1500. cache = uniqueCache[ type ] || [];
  1501. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  1502. diff = nodeIndex && cache[ 2 ];
  1503. node = nodeIndex && parent.childNodes[ nodeIndex ];
  1504. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1505. // Fallback to seeking `elem` from the start
  1506. (diff = nodeIndex = 0) || start.pop()) ) {
  1507. // When found, cache indexes on `parent` and break
  1508. if ( node.nodeType === 1 && ++diff && node === elem ) {
  1509. uniqueCache[ type ] = [ dirruns, nodeIndex, diff ];
  1510. break;
  1511. }
  1512. }
  1513. } else {
  1514. // Use previously-cached element index if available
  1515. if ( useCache ) {
  1516. // ...in a gzip-friendly way
  1517. node = elem;
  1518. outerCache = node[ expando ] || (node[ expando ] = {});
  1519. // Support: IE <9 only
  1520. // Defend against cloned attroperties (jQuery gh-1709)
  1521. uniqueCache = outerCache[ node.uniqueID ] ||
  1522. (outerCache[ node.uniqueID ] = {});
  1523. cache = uniqueCache[ type ] || [];
  1524. nodeIndex = cache[ 0 ] === dirruns && cache[ 1 ];
  1525. diff = nodeIndex;
  1526. }
  1527. // xml :nth-child(...)
  1528. // or :nth-last-child(...) or :nth(-last)?-of-type(...)
  1529. if ( diff === false ) {
  1530. // Use the same loop as above to seek `elem` from the start
  1531. while ( (node = ++nodeIndex && node && node[ dir ] ||
  1532. (diff = nodeIndex = 0) || start.pop()) ) {
  1533. if ( ( ofType ?
  1534. node.nodeName.toLowerCase() === name :
  1535. node.nodeType === 1 ) &&
  1536. ++diff ) {
  1537. // Cache the index of each encountered element
  1538. if ( useCache ) {
  1539. outerCache = node[ expando ] || (node[ expando ] = {});
  1540. // Support: IE <9 only
  1541. // Defend against cloned attroperties (jQuery gh-1709)
  1542. uniqueCache = outerCache[ node.uniqueID ] ||
  1543. (outerCache[ node.uniqueID ] = {});
  1544. uniqueCache[ type ] = [ dirruns, diff ];
  1545. }
  1546. if ( node === elem ) {
  1547. break;
  1548. }
  1549. }
  1550. }
  1551. }
  1552. }
  1553. // Incorporate the offset, then check against cycle size
  1554. diff -= last;
  1555. return diff === first || ( diff % first === 0 && diff / first >= 0 );
  1556. }
  1557. };
  1558. },
  1559. "PSEUDO": function( pseudo, argument ) {
  1560. // pseudo-class names are case-insensitive
  1561. // http://www.w3.org/TR/selectors/#pseudo-classes
  1562. // Prioritize by case sensitivity in case custom pseudos are added with uppercase letters
  1563. // Remember that setFilters inherits from pseudos
  1564. var args,
  1565. fn = Expr.pseudos[ pseudo ] || Expr.setFilters[ pseudo.toLowerCase() ] ||
  1566. Sizzle.error( "unsupported pseudo: " + pseudo );
  1567. // The user may use createPseudo to indicate that
  1568. // arguments are needed to create the filter function
  1569. // just as Sizzle does
  1570. if ( fn[ expando ] ) {
  1571. return fn( argument );
  1572. }
  1573. // But maintain support for old signatures
  1574. if ( fn.length > 1 ) {
  1575. args = [ pseudo, pseudo, "", argument ];
  1576. return Expr.setFilters.hasOwnProperty( pseudo.toLowerCase() ) ?
  1577. markFunction(function( seed, matches ) {
  1578. var idx,
  1579. matched = fn( seed, argument ),
  1580. i = matched.length;
  1581. while ( i-- ) {
  1582. idx = indexOf( seed, matched[i] );
  1583. seed[ idx ] = !( matches[ idx ] = matched[i] );
  1584. }
  1585. }) :
  1586. function( elem ) {
  1587. return fn( elem, 0, args );
  1588. };
  1589. }
  1590. return fn;
  1591. }
  1592. },
  1593. pseudos: {
  1594. // Potentially complex pseudos
  1595. "not": markFunction(function( selector ) {
  1596. // Trim the selector passed to compile
  1597. // to avoid treating leading and trailing
  1598. // spaces as combinators
  1599. var input = [],
  1600. results = [],
  1601. matcher = compile( selector.replace( rtrim, "$1" ) );
  1602. return matcher[ expando ] ?
  1603. markFunction(function( seed, matches, context, xml ) {
  1604. var elem,
  1605. unmatched = matcher( seed, null, xml, [] ),
  1606. i = seed.length;
  1607. // Match elements unmatched by `matcher`
  1608. while ( i-- ) {
  1609. if ( (elem = unmatched[i]) ) {
  1610. seed[i] = !(matches[i] = elem);
  1611. }
  1612. }
  1613. }) :
  1614. function( elem, context, xml ) {
  1615. input[0] = elem;
  1616. matcher( input, null, xml, results );
  1617. // Don't keep the element (issue #299)
  1618. input[0] = null;
  1619. return !results.pop();
  1620. };
  1621. }),
  1622. "has": markFunction(function( selector ) {
  1623. return function( elem ) {
  1624. return Sizzle( selector, elem ).length > 0;
  1625. };
  1626. }),
  1627. "contains": markFunction(function( text ) {
  1628. text = text.replace( runescape, funescape );
  1629. return function( elem ) {
  1630. return ( elem.textContent || getText( elem ) ).indexOf( text ) > -1;
  1631. };
  1632. }),
  1633. // "Whether an element is represented by a :lang() selector
  1634. // is based solely on the element's language value
  1635. // being equal to the identifier C,
  1636. // or beginning with the identifier C immediately followed by "-".
  1637. // The matching of C against the element's language value is performed case-insensitively.
  1638. // The identifier C does not have to be a valid language name."
  1639. // http://www.w3.org/TR/selectors/#lang-pseudo
  1640. "lang": markFunction( function( lang ) {
  1641. // lang value must be a valid identifier
  1642. if ( !ridentifier.test(lang || "") ) {
  1643. Sizzle.error( "unsupported lang: " + lang );
  1644. }
  1645. lang = lang.replace( runescape, funescape ).toLowerCase();
  1646. return function( elem ) {
  1647. var elemLang;
  1648. do {
  1649. if ( (elemLang = documentIsHTML ?
  1650. elem.lang :
  1651. elem.getAttribute("xml:lang") || elem.getAttribute("lang")) ) {
  1652. elemLang = elemLang.toLowerCase();
  1653. return elemLang === lang || elemLang.indexOf( lang + "-" ) === 0;
  1654. }
  1655. } while ( (elem = elem.parentNode) && elem.nodeType === 1 );
  1656. return false;
  1657. };
  1658. }),
  1659. // Miscellaneous
  1660. "target": function( elem ) {
  1661. var hash = window.location && window.location.hash;
  1662. return hash && hash.slice( 1 ) === elem.id;
  1663. },
  1664. "root": function( elem ) {
  1665. return elem === docElem;
  1666. },
  1667. "focus": function( elem ) {
  1668. return elem === document.activeElement && (!document.hasFocus || document.hasFocus()) && !!(elem.type || elem.href || ~elem.tabIndex);
  1669. },
  1670. // Boolean properties
  1671. "enabled": createDisabledPseudo( false ),
  1672. "disabled": createDisabledPseudo( true ),
  1673. "checked": function( elem ) {
  1674. // In CSS3, :checked should return both checked and selected elements
  1675. // http://www.w3.org/TR/2011/REC-css3-selectors-20110929/#checked
  1676. var nodeName = elem.nodeName.toLowerCase();
  1677. return (nodeName === "input" && !!elem.checked) || (nodeName === "option" && !!elem.selected);
  1678. },
  1679. "selected": function( elem ) {
  1680. // Accessing this property makes selected-by-default
  1681. // options in Safari work properly
  1682. if ( elem.parentNode ) {
  1683. elem.parentNode.selectedIndex;
  1684. }
  1685. return elem.selected === true;
  1686. },
  1687. // Contents
  1688. "empty": function( elem ) {
  1689. // http://www.w3.org/TR/selectors/#empty-pseudo
  1690. // :empty is negated by element (1) or content nodes (text: 3; cdata: 4; entity ref: 5),
  1691. // but not by others (comment: 8; processing instruction: 7; etc.)
  1692. // nodeType < 6 works because attributes (2) do not appear as children
  1693. for ( elem = elem.firstChild; elem; elem = elem.nextSibling ) {
  1694. if ( elem.nodeType < 6 ) {
  1695. return false;
  1696. }
  1697. }
  1698. return true;
  1699. },
  1700. "parent": function( elem ) {
  1701. return !Expr.pseudos["empty"]( elem );
  1702. },
  1703. // Element/input types
  1704. "header": function( elem ) {
  1705. return rheader.test( elem.nodeName );
  1706. },
  1707. "input": function( elem ) {
  1708. return rinputs.test( elem.nodeName );
  1709. },
  1710. "button": function( elem ) {
  1711. var name = elem.nodeName.toLowerCase();
  1712. return name === "input" && elem.type === "button" || name === "button";
  1713. },
  1714. "text": function( elem ) {
  1715. var attr;
  1716. return elem.nodeName.toLowerCase() === "input" &&
  1717. elem.type === "text" &&
  1718. // Support: IE<8
  1719. // New HTML5 attribute values (e.g., "search") appear with elem.type === "text"
  1720. ( (attr = elem.getAttribute("type")) == null || attr.toLowerCase() === "text" );
  1721. },
  1722. // Position-in-collection
  1723. "first": createPositionalPseudo(function() {
  1724. return [ 0 ];
  1725. }),
  1726. "last": createPositionalPseudo(function( matchIndexes, length ) {
  1727. return [ length - 1 ];
  1728. }),
  1729. "eq": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1730. return [ argument < 0 ? argument + length : argument ];
  1731. }),
  1732. "even": createPositionalPseudo(function( matchIndexes, length ) {
  1733. var i = 0;
  1734. for ( ; i < length; i += 2 ) {
  1735. matchIndexes.push( i );
  1736. }
  1737. return matchIndexes;
  1738. }),
  1739. "odd": createPositionalPseudo(function( matchIndexes, length ) {
  1740. var i = 1;
  1741. for ( ; i < length; i += 2 ) {
  1742. matchIndexes.push( i );
  1743. }
  1744. return matchIndexes;
  1745. }),
  1746. "lt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1747. var i = argument < 0 ?
  1748. argument + length :
  1749. argument > length ?
  1750. length :
  1751. argument;
  1752. for ( ; --i >= 0; ) {
  1753. matchIndexes.push( i );
  1754. }
  1755. return matchIndexes;
  1756. }),
  1757. "gt": createPositionalPseudo(function( matchIndexes, length, argument ) {
  1758. var i = argument < 0 ? argument + length : argument;
  1759. for ( ; ++i < length; ) {
  1760. matchIndexes.push( i );
  1761. }
  1762. return matchIndexes;
  1763. })
  1764. }
  1765. };
  1766. Expr.pseudos["nth"] = Expr.pseudos["eq"];
  1767. // Add button/input type pseudos
  1768. for ( i in { radio: true, checkbox: true, file: true, password: true, image: true } ) {
  1769. Expr.pseudos[ i ] = createInputPseudo( i );
  1770. }
  1771. for ( i in { submit: true, reset: true } ) {
  1772. Expr.pseudos[ i ] = createButtonPseudo( i );
  1773. }
  1774. // Easy API for creating new setFilters
  1775. function setFilters() {}
  1776. setFilters.prototype = Expr.filters = Expr.pseudos;
  1777. Expr.setFilters = new setFilters();
  1778. tokenize = Sizzle.tokenize = function( selector, parseOnly ) {
  1779. var matched, match, tokens, type,
  1780. soFar, groups, preFilters,
  1781. cached = tokenCache[ selector + " " ];
  1782. if ( cached ) {
  1783. return parseOnly ? 0 : cached.slice( 0 );
  1784. }
  1785. soFar = selector;
  1786. groups = [];
  1787. preFilters = Expr.preFilter;
  1788. while ( soFar ) {
  1789. // Comma and first run
  1790. if ( !matched || (match = rcomma.exec( soFar )) ) {
  1791. if ( match ) {
  1792. // Don't consume trailing commas as valid
  1793. soFar = soFar.slice( match[0].length ) || soFar;
  1794. }
  1795. groups.push( (tokens = []) );
  1796. }
  1797. matched = false;
  1798. // Combinators
  1799. if ( (match = rcombinators.exec( soFar )) ) {
  1800. matched = match.shift();
  1801. tokens.push({
  1802. value: matched,
  1803. // Cast descendant combinators to space
  1804. type: match[0].replace( rtrim, " " )
  1805. });
  1806. soFar = soFar.slice( matched.length );
  1807. }
  1808. // Filters
  1809. for ( type in Expr.filter ) {
  1810. if ( (match = matchExpr[ type ].exec( soFar )) && (!preFilters[ type ] ||
  1811. (match = preFilters[ type ]( match ))) ) {
  1812. matched = match.shift();
  1813. tokens.push({
  1814. value: matched,
  1815. type: type,
  1816. matches: match
  1817. });
  1818. soFar = soFar.slice( matched.length );
  1819. }
  1820. }
  1821. if ( !matched ) {
  1822. break;
  1823. }
  1824. }
  1825. // Return the length of the invalid excess
  1826. // if we're just parsing
  1827. // Otherwise, throw an error or return tokens
  1828. return parseOnly ?
  1829. soFar.length :
  1830. soFar ?
  1831. Sizzle.error( selector ) :
  1832. // Cache the tokens
  1833. tokenCache( selector, groups ).slice( 0 );
  1834. };
  1835. function toSelector( tokens ) {
  1836. var i = 0,
  1837. len = tokens.length,
  1838. selector = "";
  1839. for ( ; i < len; i++ ) {
  1840. selector += tokens[i].value;
  1841. }
  1842. return selector;
  1843. }
  1844. function addCombinator( matcher, combinator, base ) {
  1845. var dir = combinator.dir,
  1846. skip = combinator.next,
  1847. key = skip || dir,
  1848. checkNonElements = base && key === "parentNode",
  1849. doneName = done++;
  1850. return combinator.first ?
  1851. // Check against closest ancestor/preceding element
  1852. function( elem, context, xml ) {
  1853. while ( (elem = elem[ dir ]) ) {
  1854. if ( elem.nodeType === 1 || checkNonElements ) {
  1855. return matcher( elem, context, xml );
  1856. }
  1857. }
  1858. return false;
  1859. } :
  1860. // Check against all ancestor/preceding elements
  1861. function( elem, context, xml ) {
  1862. var oldCache, uniqueCache, outerCache,
  1863. newCache = [ dirruns, doneName ];
  1864. // We can't set arbitrary data on XML nodes, so they don't benefit from combinator caching
  1865. if ( xml ) {
  1866. while ( (elem = elem[ dir ]) ) {
  1867. if ( elem.nodeType === 1 || checkNonElements ) {
  1868. if ( matcher( elem, context, xml ) ) {
  1869. return true;
  1870. }
  1871. }
  1872. }
  1873. } else {
  1874. while ( (elem = elem[ dir ]) ) {
  1875. if ( elem.nodeType === 1 || checkNonElements ) {
  1876. outerCache = elem[ expando ] || (elem[ expando ] = {});
  1877. // Support: IE <9 only
  1878. // Defend against cloned attroperties (jQuery gh-1709)
  1879. uniqueCache = outerCache[ elem.uniqueID ] || (outerCache[ elem.uniqueID ] = {});
  1880. if ( skip && skip === elem.nodeName.toLowerCase() ) {
  1881. elem = elem[ dir ] || elem;
  1882. } else if ( (oldCache = uniqueCache[ key ]) &&
  1883. oldCache[ 0 ] === dirruns && oldCache[ 1 ] === doneName ) {
  1884. // Assign to newCache so results back-propagate to previous elements
  1885. return (newCache[ 2 ] = oldCache[ 2 ]);
  1886. } else {
  1887. // Reuse newcache so results back-propagate to previous elements
  1888. uniqueCache[ key ] = newCache;
  1889. // A match means we're done; a fail means we have to keep checking
  1890. if ( (newCache[ 2 ] = matcher( elem, context, xml )) ) {
  1891. return true;
  1892. }
  1893. }
  1894. }
  1895. }
  1896. }
  1897. return false;
  1898. };
  1899. }
  1900. function elementMatcher( matchers ) {
  1901. return matchers.length > 1 ?
  1902. function( elem, context, xml ) {
  1903. var i = matchers.length;
  1904. while ( i-- ) {
  1905. if ( !matchers[i]( elem, context, xml ) ) {
  1906. return false;
  1907. }
  1908. }
  1909. return true;
  1910. } :
  1911. matchers[0];
  1912. }
  1913. function multipleContexts( selector, contexts, results ) {
  1914. var i = 0,
  1915. len = contexts.length;
  1916. for ( ; i < len; i++ ) {
  1917. Sizzle( selector, contexts[i], results );
  1918. }
  1919. return results;
  1920. }
  1921. function condense( unmatched, map, filter, context, xml ) {
  1922. var elem,
  1923. newUnmatched = [],
  1924. i = 0,
  1925. len = unmatched.length,
  1926. mapped = map != null;
  1927. for ( ; i < len; i++ ) {
  1928. if ( (elem = unmatched[i]) ) {
  1929. if ( !filter || filter( elem, context, xml ) ) {
  1930. newUnmatched.push( elem );
  1931. if ( mapped ) {
  1932. map.push( i );
  1933. }
  1934. }
  1935. }
  1936. }
  1937. return newUnmatched;
  1938. }
  1939. function setMatcher( preFilter, selector, matcher, postFilter, postFinder, postSelector ) {
  1940. if ( postFilter && !postFilter[ expando ] ) {
  1941. postFilter = setMatcher( postFilter );
  1942. }
  1943. if ( postFinder && !postFinder[ expando ] ) {
  1944. postFinder = setMatcher( postFinder, postSelector );
  1945. }
  1946. return markFunction(function( seed, results, context, xml ) {
  1947. var temp, i, elem,
  1948. preMap = [],
  1949. postMap = [],
  1950. preexisting = results.length,
  1951. // Get initial elements from seed or context
  1952. elems = seed || multipleContexts( selector || "*", context.nodeType ? [ context ] : context, [] ),
  1953. // Prefilter to get matcher input, preserving a map for seed-results synchronization
  1954. matcherIn = preFilter && ( seed || !selector ) ?
  1955. condense( elems, preMap, preFilter, context, xml ) :
  1956. elems,
  1957. matcherOut = matcher ?
  1958. // If we have a postFinder, or filtered seed, or non-seed postFilter or preexisting results,
  1959. postFinder || ( seed ? preFilter : preexisting || postFilter ) ?
  1960. // ...intermediate processing is necessary
  1961. [] :
  1962. // ...otherwise use results directly
  1963. results :
  1964. matcherIn;
  1965. // Find primary matches
  1966. if ( matcher ) {
  1967. matcher( matcherIn, matcherOut, context, xml );
  1968. }
  1969. // Apply postFilter
  1970. if ( postFilter ) {
  1971. temp = condense( matcherOut, postMap );
  1972. postFilter( temp, [], context, xml );
  1973. // Un-match failing elements by moving them back to matcherIn
  1974. i = temp.length;
  1975. while ( i-- ) {
  1976. if ( (elem = temp[i]) ) {
  1977. matcherOut[ postMap[i] ] = !(matcherIn[ postMap[i] ] = elem);
  1978. }
  1979. }
  1980. }
  1981. if ( seed ) {
  1982. if ( postFinder || preFilter ) {
  1983. if ( postFinder ) {
  1984. // Get the final matcherOut by condensing this intermediate into postFinder contexts
  1985. temp = [];
  1986. i = matcherOut.length;
  1987. while ( i-- ) {
  1988. if ( (elem = matcherOut[i]) ) {
  1989. // Restore matcherIn since elem is not yet a final match
  1990. temp.push( (matcherIn[i] = elem) );
  1991. }
  1992. }
  1993. postFinder( null, (matcherOut = []), temp, xml );
  1994. }
  1995. // Move matched elements from seed to results to keep them synchronized
  1996. i = matcherOut.length;
  1997. while ( i-- ) {
  1998. if ( (elem = matcherOut[i]) &&
  1999. (temp = postFinder ? indexOf( seed, elem ) : preMap[i]) > -1 ) {
  2000. seed[temp] = !(results[temp] = elem);
  2001. }
  2002. }
  2003. }
  2004. // Add elements to results, through postFinder if defined
  2005. } else {
  2006. matcherOut = condense(
  2007. matcherOut === results ?
  2008. matcherOut.splice( preexisting, matcherOut.length ) :
  2009. matcherOut
  2010. );
  2011. if ( postFinder ) {
  2012. postFinder( null, results, matcherOut, xml );
  2013. } else {
  2014. push.apply( results, matcherOut );
  2015. }
  2016. }
  2017. });
  2018. }
  2019. function matcherFromTokens( tokens ) {
  2020. var checkContext, matcher, j,
  2021. len = tokens.length,
  2022. leadingRelative = Expr.relative[ tokens[0].type ],
  2023. implicitRelative = leadingRelative || Expr.relative[" "],
  2024. i = leadingRelative ? 1 : 0,
  2025. // The foundational matcher ensures that elements are reachable from top-level context(s)
  2026. matchContext = addCombinator( function( elem ) {
  2027. return elem === checkContext;
  2028. }, implicitRelative, true ),
  2029. matchAnyContext = addCombinator( function( elem ) {
  2030. return indexOf( checkContext, elem ) > -1;
  2031. }, implicitRelative, true ),
  2032. matchers = [ function( elem, context, xml ) {
  2033. var ret = ( !leadingRelative && ( xml || context !== outermostContext ) ) || (
  2034. (checkContext = context).nodeType ?
  2035. matchContext( elem, context, xml ) :
  2036. matchAnyContext( elem, context, xml ) );
  2037. // Avoid hanging onto element (issue #299)
  2038. checkContext = null;
  2039. return ret;
  2040. } ];
  2041. for ( ; i < len; i++ ) {
  2042. if ( (matcher = Expr.relative[ tokens[i].type ]) ) {
  2043. matchers = [ addCombinator(elementMatcher( matchers ), matcher) ];
  2044. } else {
  2045. matcher = Expr.filter[ tokens[i].type ].apply( null, tokens[i].matches );
  2046. // Return special upon seeing a positional matcher
  2047. if ( matcher[ expando ] ) {
  2048. // Find the next relative operator (if any) for proper handling
  2049. j = ++i;
  2050. for ( ; j < len; j++ ) {
  2051. if ( Expr.relative[ tokens[j].type ] ) {
  2052. break;
  2053. }
  2054. }
  2055. return setMatcher(
  2056. i > 1 && elementMatcher( matchers ),
  2057. i > 1 && toSelector(
  2058. // If the preceding token was a descendant combinator, insert an implicit any-element `*`
  2059. tokens.slice( 0, i - 1 ).concat({ value: tokens[ i - 2 ].type === " " ? "*" : "" })
  2060. ).replace( rtrim, "$1" ),
  2061. matcher,
  2062. i < j && matcherFromTokens( tokens.slice( i, j ) ),
  2063. j < len && matcherFromTokens( (tokens = tokens.slice( j )) ),
  2064. j < len && toSelector( tokens )
  2065. );
  2066. }
  2067. matchers.push( matcher );
  2068. }
  2069. }
  2070. return elementMatcher( matchers );
  2071. }
  2072. function matcherFromGroupMatchers( elementMatchers, setMatchers ) {
  2073. var bySet = setMatchers.length > 0,
  2074. byElement = elementMatchers.length > 0,
  2075. superMatcher = function( seed, context, xml, results, outermost ) {
  2076. var elem, j, matcher,
  2077. matchedCount = 0,
  2078. i = "0",
  2079. unmatched = seed && [],
  2080. setMatched = [],
  2081. contextBackup = outermostContext,
  2082. // We must always have either seed elements or outermost context
  2083. elems = seed || byElement && Expr.find["TAG"]( "*", outermost ),
  2084. // Use integer dirruns iff this is the outermost matcher
  2085. dirrunsUnique = (dirruns += contextBackup == null ? 1 : Math.random() || 0.1),
  2086. len = elems.length;
  2087. if ( outermost ) {
  2088. outermostContext = context === document || context || outermost;
  2089. }
  2090. // Add elements passing elementMatchers directly to results
  2091. // Support: IE<9, Safari
  2092. // Tolerate NodeList properties (IE: "length"; Safari: <number>) matching elements by id
  2093. for ( ; i !== len && (elem = elems[i]) != null; i++ ) {
  2094. if ( byElement && elem ) {
  2095. j = 0;
  2096. if ( !context && elem.ownerDocument !== document ) {
  2097. setDocument( elem );
  2098. xml = !documentIsHTML;
  2099. }
  2100. while ( (matcher = elementMatchers[j++]) ) {
  2101. if ( matcher( elem, context || document, xml) ) {
  2102. results.push( elem );
  2103. break;
  2104. }
  2105. }
  2106. if ( outermost ) {
  2107. dirruns = dirrunsUnique;
  2108. }
  2109. }
  2110. // Track unmatched elements for set filters
  2111. if ( bySet ) {
  2112. // They will have gone through all possible matchers
  2113. if ( (elem = !matcher && elem) ) {
  2114. matchedCount--;
  2115. }
  2116. // Lengthen the array for every element, matched or not
  2117. if ( seed ) {
  2118. unmatched.push( elem );
  2119. }
  2120. }
  2121. }
  2122. // `i` is now the count of elements visited above, and adding it to `matchedCount`
  2123. // makes the latter nonnegative.
  2124. matchedCount += i;
  2125. // Apply set filters to unmatched elements
  2126. // NOTE: This can be skipped if there are no unmatched elements (i.e., `matchedCount`
  2127. // equals `i`), unless we didn't visit _any_ elements in the above loop because we have
  2128. // no element matchers and no seed.
  2129. // Incrementing an initially-string "0" `i` allows `i` to remain a string only in that
  2130. // case, which will result in a "00" `matchedCount` that differs from `i` but is also
  2131. // numerically zero.
  2132. if ( bySet && i !== matchedCount ) {
  2133. j = 0;
  2134. while ( (matcher = setMatchers[j++]) ) {
  2135. matcher( unmatched, setMatched, context, xml );
  2136. }
  2137. if ( seed ) {
  2138. // Reintegrate element matches to eliminate the need for sorting
  2139. if ( matchedCount > 0 ) {
  2140. while ( i-- ) {
  2141. if ( !(unmatched[i] || setMatched[i]) ) {
  2142. setMatched[i] = pop.call( results );
  2143. }
  2144. }
  2145. }
  2146. // Discard index placeholder values to get only actual matches
  2147. setMatched = condense( setMatched );
  2148. }
  2149. // Add matches to results
  2150. push.apply( results, setMatched );
  2151. // Seedless set matches succeeding multiple successful matchers stipulate sorting
  2152. if ( outermost && !seed && setMatched.length > 0 &&
  2153. ( matchedCount + setMatchers.length ) > 1 ) {
  2154. Sizzle.uniqueSort( results );
  2155. }
  2156. }
  2157. // Override manipulation of globals by nested matchers
  2158. if ( outermost ) {
  2159. dirruns = dirrunsUnique;
  2160. outermostContext = contextBackup;
  2161. }
  2162. return unmatched;
  2163. };
  2164. return bySet ?
  2165. markFunction( superMatcher ) :
  2166. superMatcher;
  2167. }
  2168. compile = Sizzle.compile = function( selector, match /* Internal Use Only */ ) {
  2169. var i,
  2170. setMatchers = [],
  2171. elementMatchers = [],
  2172. cached = compilerCache[ selector + " " ];
  2173. if ( !cached ) {
  2174. // Generate a function of recursive functions that can be used to check each element
  2175. if ( !match ) {
  2176. match = tokenize( selector );
  2177. }
  2178. i = match.length;
  2179. while ( i-- ) {
  2180. cached = matcherFromTokens( match[i] );
  2181. if ( cached[ expando ] ) {
  2182. setMatchers.push( cached );
  2183. } else {
  2184. elementMatchers.push( cached );
  2185. }
  2186. }
  2187. // Cache the compiled function
  2188. cached = compilerCache( selector, matcherFromGroupMatchers( elementMatchers, setMatchers ) );
  2189. // Save selector and tokenization
  2190. cached.selector = selector;
  2191. }
  2192. return cached;
  2193. };
  2194. /**
  2195. * A low-level selection function that works with Sizzle's compiled
  2196. * selector functions
  2197. * @param {String|Function} selector A selector or a pre-compiled
  2198. * selector function built with Sizzle.compile
  2199. * @param {Element} context
  2200. * @param {Array} [results]
  2201. * @param {Array} [seed] A set of elements to match against
  2202. */
  2203. select = Sizzle.select = function( selector, context, results, seed ) {
  2204. var i, tokens, token, type, find,
  2205. compiled = typeof selector === "function" && selector,
  2206. match = !seed && tokenize( (selector = compiled.selector || selector) );
  2207. results = results || [];
  2208. // Try to minimize operations if there is only one selector in the list and no seed
  2209. // (the latter of which guarantees us context)
  2210. if ( match.length === 1 ) {
  2211. // Reduce context if the leading compound selector is an ID
  2212. tokens = match[0] = match[0].slice( 0 );
  2213. if ( tokens.length > 2 && (token = tokens[0]).type === "ID" &&
  2214. context.nodeType === 9 && documentIsHTML && Expr.relative[ tokens[1].type ] ) {
  2215. context = ( Expr.find["ID"]( token.matches[0].replace(runescape, funescape), context ) || [] )[0];
  2216. if ( !context ) {
  2217. return results;
  2218. // Precompiled matchers will still verify ancestry, so step up a level
  2219. } else if ( compiled ) {
  2220. context = context.parentNode;
  2221. }
  2222. selector = selector.slice( tokens.shift().value.length );
  2223. }
  2224. // Fetch a seed set for right-to-left matching
  2225. i = matchExpr["needsContext"].test( selector ) ? 0 : tokens.length;
  2226. while ( i-- ) {
  2227. token = tokens[i];
  2228. // Abort if we hit a combinator
  2229. if ( Expr.relative[ (type = token.type) ] ) {
  2230. break;
  2231. }
  2232. if ( (find = Expr.find[ type ]) ) {
  2233. // Search, expanding context for leading sibling combinators
  2234. if ( (seed = find(
  2235. token.matches[0].replace( runescape, funescape ),
  2236. rsibling.test( tokens[0].type ) && testContext( context.parentNode ) || context
  2237. )) ) {
  2238. // If seed is empty or no tokens remain, we can return early
  2239. tokens.splice( i, 1 );
  2240. selector = seed.length && toSelector( tokens );
  2241. if ( !selector ) {
  2242. push.apply( results, seed );
  2243. return results;
  2244. }
  2245. break;
  2246. }
  2247. }
  2248. }
  2249. }
  2250. // Compile and execute a filtering function if one is not provided
  2251. // Provide `match` to avoid retokenization if we modified the selector above
  2252. ( compiled || compile( selector, match ) )(
  2253. seed,
  2254. context,
  2255. !documentIsHTML,
  2256. results,
  2257. !context || rsibling.test( selector ) && testContext( context.parentNode ) || context
  2258. );
  2259. return results;
  2260. };
  2261. // One-time assignments
  2262. // Sort stability
  2263. support.sortStable = expando.split("").sort( sortOrder ).join("") === expando;
  2264. // Support: Chrome 14-35+
  2265. // Always assume duplicates if they aren't passed to the comparison function
  2266. support.detectDuplicates = !!hasDuplicate;
  2267. // Initialize against the default document
  2268. setDocument();
  2269. // Support: Webkit<537.32 - Safari 6.0.3/Chrome 25 (fixed in Chrome 27)
  2270. // Detached nodes confoundingly follow *each other*
  2271. support.sortDetached = assert(function( el ) {
  2272. // Should return 1, but returns 4 (following)
  2273. return el.compareDocumentPosition( document.createElement("fieldset") ) & 1;
  2274. });
  2275. // Support: IE<8
  2276. // Prevent attribute/property "interpolation"
  2277. // https://msdn.microsoft.com/en-us/library/ms536429%28VS.85%29.aspx
  2278. if ( !assert(function( el ) {
  2279. el.innerHTML = "<a href='#'></a>";
  2280. return el.firstChild.getAttribute("href") === "#" ;
  2281. }) ) {
  2282. addHandle( "type|href|height|width", function( elem, name, isXML ) {
  2283. if ( !isXML ) {
  2284. return elem.getAttribute( name, name.toLowerCase() === "type" ? 1 : 2 );
  2285. }
  2286. });
  2287. }
  2288. // Support: IE<9
  2289. // Use defaultValue in place of getAttribute("value")
  2290. if ( !support.attributes || !assert(function( el ) {
  2291. el.innerHTML = "<input/>";
  2292. el.firstChild.setAttribute( "value", "" );
  2293. return el.firstChild.getAttribute( "value" ) === "";
  2294. }) ) {
  2295. addHandle( "value", function( elem, name, isXML ) {
  2296. if ( !isXML && elem.nodeName.toLowerCase() === "input" ) {
  2297. return elem.defaultValue;
  2298. }
  2299. });
  2300. }
  2301. // Support: IE<9
  2302. // Use getAttributeNode to fetch booleans when getAttribute lies
  2303. if ( !assert(function( el ) {
  2304. return el.getAttribute("disabled") == null;
  2305. }) ) {
  2306. addHandle( booleans, function( elem, name, isXML ) {
  2307. var val;
  2308. if ( !isXML ) {
  2309. return elem[ name ] === true ? name.toLowerCase() :
  2310. (val = elem.getAttributeNode( name )) && val.specified ?
  2311. val.value :
  2312. null;
  2313. }
  2314. });
  2315. }
  2316. return Sizzle;
  2317. })( window );
  2318. jQuery.find = Sizzle;
  2319. jQuery.expr = Sizzle.selectors;
  2320. // Deprecated
  2321. jQuery.expr[ ":" ] = jQuery.expr.pseudos;
  2322. jQuery.uniqueSort = jQuery.unique = Sizzle.uniqueSort;
  2323. jQuery.text = Sizzle.getText;
  2324. jQuery.isXMLDoc = Sizzle.isXML;
  2325. jQuery.contains = Sizzle.contains;
  2326. jQuery.escapeSelector = Sizzle.escape;
  2327. var dir = function( elem, dir, until ) {
  2328. var matched = [],
  2329. truncate = until !== undefined;
  2330. while ( ( elem = elem[ dir ] ) && elem.nodeType !== 9 ) {
  2331. if ( elem.nodeType === 1 ) {
  2332. if ( truncate && jQuery( elem ).is( until ) ) {
  2333. break;
  2334. }
  2335. matched.push( elem );
  2336. }
  2337. }
  2338. return matched;
  2339. };
  2340. var siblings = function( n, elem ) {
  2341. var matched = [];
  2342. for ( ; n; n = n.nextSibling ) {
  2343. if ( n.nodeType === 1 && n !== elem ) {
  2344. matched.push( n );
  2345. }
  2346. }
  2347. return matched;
  2348. };
  2349. var rneedsContext = jQuery.expr.match.needsContext;
  2350. function nodeName( elem, name ) {
  2351. return elem.nodeName && elem.nodeName.toLowerCase() === name.toLowerCase();
  2352. };
  2353. var rsingleTag = ( /^<([a-z][^\/\0>:\x20\t\r\n\f]*)[\x20\t\r\n\f]*\/?>(?:<\/\1>|)$/i );
  2354. // Implement the identical functionality for filter and not
  2355. function winnow( elements, qualifier, not ) {
  2356. if ( isFunction( qualifier ) ) {
  2357. return jQuery.grep( elements, function( elem, i ) {
  2358. return !!qualifier.call( elem, i, elem ) !== not;
  2359. } );
  2360. }
  2361. // Single element
  2362. if ( qualifier.nodeType ) {
  2363. return jQuery.grep( elements, function( elem ) {
  2364. return ( elem === qualifier ) !== not;
  2365. } );
  2366. }
  2367. // Arraylike of elements (jQuery, arguments, Array)
  2368. if ( typeof qualifier !== "string" ) {
  2369. return jQuery.grep( elements, function( elem ) {
  2370. return ( indexOf.call( qualifier, elem ) > -1 ) !== not;
  2371. } );
  2372. }
  2373. // Filtered directly for both simple and complex selectors
  2374. return jQuery.filter( qualifier, elements, not );
  2375. }
  2376. jQuery.filter = function( expr, elems, not ) {
  2377. var elem = elems[ 0 ];
  2378. if ( not ) {
  2379. expr = ":not(" + expr + ")";
  2380. }
  2381. if ( elems.length === 1 && elem.nodeType === 1 ) {
  2382. return jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [];
  2383. }
  2384. return jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
  2385. return elem.nodeType === 1;
  2386. } ) );
  2387. };
  2388. jQuery.fn.extend( {
  2389. find: function( selector ) {
  2390. var i, ret,
  2391. len = this.length,
  2392. self = this;
  2393. if ( typeof selector !== "string" ) {
  2394. return this.pushStack( jQuery( selector ).filter( function() {
  2395. for ( i = 0; i < len; i++ ) {
  2396. if ( jQuery.contains( self[ i ], this ) ) {
  2397. return true;
  2398. }
  2399. }
  2400. } ) );
  2401. }
  2402. ret = this.pushStack( [] );
  2403. for ( i = 0; i < len; i++ ) {
  2404. jQuery.find( selector, self[ i ], ret );
  2405. }
  2406. return len > 1 ? jQuery.uniqueSort( ret ) : ret;
  2407. },
  2408. filter: function( selector ) {
  2409. return this.pushStack( winnow( this, selector || [], false ) );
  2410. },
  2411. not: function( selector ) {
  2412. return this.pushStack( winnow( this, selector || [], true ) );
  2413. },
  2414. is: function( selector ) {
  2415. return !!winnow(
  2416. this,
  2417. // If this is a positional/relative selector, check membership in the returned set
  2418. // so $("p:first").is("p:last") won't return true for a doc with two "p".
  2419. typeof selector === "string" && rneedsContext.test( selector ) ?
  2420. jQuery( selector ) :
  2421. selector || [],
  2422. false
  2423. ).length;
  2424. }
  2425. } );
  2426. // Initialize a jQuery object
  2427. // A central reference to the root jQuery(document)
  2428. var rootjQuery,
  2429. // A simple way to check for HTML strings
  2430. // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
  2431. // Strict HTML recognition (#11290: must start with <)
  2432. // Shortcut simple #id case for speed
  2433. rquickExpr = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]+))$/,
  2434. init = jQuery.fn.init = function( selector, context, root ) {
  2435. var match, elem;
  2436. // HANDLE: $(""), $(null), $(undefined), $(false)
  2437. if ( !selector ) {
  2438. return this;
  2439. }
  2440. // Method init() accepts an alternate rootjQuery
  2441. // so migrate can support jQuery.sub (gh-2101)
  2442. root = root || rootjQuery;
  2443. // Handle HTML strings
  2444. if ( typeof selector === "string" ) {
  2445. if ( selector[ 0 ] === "<" &&
  2446. selector[ selector.length - 1 ] === ">" &&
  2447. selector.length >= 3 ) {
  2448. // Assume that strings that start and end with <> are HTML and skip the regex check
  2449. match = [ null, selector, null ];
  2450. } else {
  2451. match = rquickExpr.exec( selector );
  2452. }
  2453. // Match html or make sure no context is specified for #id
  2454. if ( match && ( match[ 1 ] || !context ) ) {
  2455. // HANDLE: $(html) -> $(array)
  2456. if ( match[ 1 ] ) {
  2457. context = context instanceof jQuery ? context[ 0 ] : context;
  2458. // Option to run scripts is true for back-compat
  2459. // Intentionally let the error be thrown if parseHTML is not present
  2460. jQuery.merge( this, jQuery.parseHTML(
  2461. match[ 1 ],
  2462. context && context.nodeType ? context.ownerDocument || context : document,
  2463. true
  2464. ) );
  2465. // HANDLE: $(html, props)
  2466. if ( rsingleTag.test( match[ 1 ] ) && jQuery.isPlainObject( context ) ) {
  2467. for ( match in context ) {
  2468. // Properties of context are called as methods if possible
  2469. if ( isFunction( this[ match ] ) ) {
  2470. this[ match ]( context[ match ] );
  2471. // ...and otherwise set as attributes
  2472. } else {
  2473. this.attr( match, context[ match ] );
  2474. }
  2475. }
  2476. }
  2477. return this;
  2478. // HANDLE: $(#id)
  2479. } else {
  2480. elem = document.getElementById( match[ 2 ] );
  2481. if ( elem ) {
  2482. // Inject the element directly into the jQuery object
  2483. this[ 0 ] = elem;
  2484. this.length = 1;
  2485. }
  2486. return this;
  2487. }
  2488. // HANDLE: $(expr, $(...))
  2489. } else if ( !context || context.jquery ) {
  2490. return ( context || root ).find( selector );
  2491. // HANDLE: $(expr, context)
  2492. // (which is just equivalent to: $(context).find(expr)
  2493. } else {
  2494. return this.constructor( context ).find( selector );
  2495. }
  2496. // HANDLE: $(DOMElement)
  2497. } else if ( selector.nodeType ) {
  2498. this[ 0 ] = selector;
  2499. this.length = 1;
  2500. return this;
  2501. // HANDLE: $(function)
  2502. // Shortcut for document ready
  2503. } else if ( isFunction( selector ) ) {
  2504. return root.ready !== undefined ?
  2505. root.ready( selector ) :
  2506. // Execute immediately if ready is not present
  2507. selector( jQuery );
  2508. }
  2509. return jQuery.makeArray( selector, this );
  2510. };
  2511. // Give the init function the jQuery prototype for later instantiation
  2512. init.prototype = jQuery.fn;
  2513. // Initialize central reference
  2514. rootjQuery = jQuery( document );
  2515. var rparentsprev = /^(?:parents|prev(?:Until|All))/,
  2516. // Methods guaranteed to produce a unique set when starting from a unique set
  2517. guaranteedUnique = {
  2518. children: true,
  2519. contents: true,
  2520. next: true,
  2521. prev: true
  2522. };
  2523. jQuery.fn.extend( {
  2524. has: function( target ) {
  2525. var targets = jQuery( target, this ),
  2526. l = targets.length;
  2527. return this.filter( function() {
  2528. var i = 0;
  2529. for ( ; i < l; i++ ) {
  2530. if ( jQuery.contains( this, targets[ i ] ) ) {
  2531. return true;
  2532. }
  2533. }
  2534. } );
  2535. },
  2536. closest: function( selectors, context ) {
  2537. var cur,
  2538. i = 0,
  2539. l = this.length,
  2540. matched = [],
  2541. targets = typeof selectors !== "string" && jQuery( selectors );
  2542. // Positional selectors never match, since there's no _selection_ context
  2543. if ( !rneedsContext.test( selectors ) ) {
  2544. for ( ; i < l; i++ ) {
  2545. for ( cur = this[ i ]; cur && cur !== context; cur = cur.parentNode ) {
  2546. // Always skip document fragments
  2547. if ( cur.nodeType < 11 && ( targets ?
  2548. targets.index( cur ) > -1 :
  2549. // Don't pass non-elements to Sizzle
  2550. cur.nodeType === 1 &&
  2551. jQuery.find.matchesSelector( cur, selectors ) ) ) {
  2552. matched.push( cur );
  2553. break;
  2554. }
  2555. }
  2556. }
  2557. }
  2558. return this.pushStack( matched.length > 1 ? jQuery.uniqueSort( matched ) : matched );
  2559. },
  2560. // Determine the position of an element within the set
  2561. index: function( elem ) {
  2562. // No argument, return index in parent
  2563. if ( !elem ) {
  2564. return ( this[ 0 ] && this[ 0 ].parentNode ) ? this.first().prevAll().length : -1;
  2565. }
  2566. // Index in selector
  2567. if ( typeof elem === "string" ) {
  2568. return indexOf.call( jQuery( elem ), this[ 0 ] );
  2569. }
  2570. // Locate the position of the desired element
  2571. return indexOf.call( this,
  2572. // If it receives a jQuery object, the first element is used
  2573. elem.jquery ? elem[ 0 ] : elem
  2574. );
  2575. },
  2576. add: function( selector, context ) {
  2577. return this.pushStack(
  2578. jQuery.uniqueSort(
  2579. jQuery.merge( this.get(), jQuery( selector, context ) )
  2580. )
  2581. );
  2582. },
  2583. addBack: function( selector ) {
  2584. return this.add( selector == null ?
  2585. this.prevObject : this.prevObject.filter( selector )
  2586. );
  2587. }
  2588. } );
  2589. function sibling( cur, dir ) {
  2590. while ( ( cur = cur[ dir ] ) && cur.nodeType !== 1 ) {}
  2591. return cur;
  2592. }
  2593. jQuery.each( {
  2594. parent: function( elem ) {
  2595. var parent = elem.parentNode;
  2596. return parent && parent.nodeType !== 11 ? parent : null;
  2597. },
  2598. parents: function( elem ) {
  2599. return dir( elem, "parentNode" );
  2600. },
  2601. parentsUntil: function( elem, i, until ) {
  2602. return dir( elem, "parentNode", until );
  2603. },
  2604. next: function( elem ) {
  2605. return sibling( elem, "nextSibling" );
  2606. },
  2607. prev: function( elem ) {
  2608. return sibling( elem, "previousSibling" );
  2609. },
  2610. nextAll: function( elem ) {
  2611. return dir( elem, "nextSibling" );
  2612. },
  2613. prevAll: function( elem ) {
  2614. return dir( elem, "previousSibling" );
  2615. },
  2616. nextUntil: function( elem, i, until ) {
  2617. return dir( elem, "nextSibling", until );
  2618. },
  2619. prevUntil: function( elem, i, until ) {
  2620. return dir( elem, "previousSibling", until );
  2621. },
  2622. siblings: function( elem ) {
  2623. return siblings( ( elem.parentNode || {} ).firstChild, elem );
  2624. },
  2625. children: function( elem ) {
  2626. return siblings( elem.firstChild );
  2627. },
  2628. contents: function( elem ) {
  2629. if ( typeof elem.contentDocument !== "undefined" ) {
  2630. return elem.contentDocument;
  2631. }
  2632. // Support: IE 9 - 11 only, iOS 7 only, Android Browser <=4.3 only
  2633. // Treat the template element as a regular one in browsers that
  2634. // don't support it.
  2635. if ( nodeName( elem, "template" ) ) {
  2636. elem = elem.content || elem;
  2637. }
  2638. return jQuery.merge( [], elem.childNodes );
  2639. }
  2640. }, function( name, fn ) {
  2641. jQuery.fn[ name ] = function( until, selector ) {
  2642. var matched = jQuery.map( this, fn, until );
  2643. if ( name.slice( -5 ) !== "Until" ) {
  2644. selector = until;
  2645. }
  2646. if ( selector && typeof selector === "string" ) {
  2647. matched = jQuery.filter( selector, matched );
  2648. }
  2649. if ( this.length > 1 ) {
  2650. // Remove duplicates
  2651. if ( !guaranteedUnique[ name ] ) {
  2652. jQuery.uniqueSort( matched );
  2653. }
  2654. // Reverse order for parents* and prev-derivatives
  2655. if ( rparentsprev.test( name ) ) {
  2656. matched.reverse();
  2657. }
  2658. }
  2659. return this.pushStack( matched );
  2660. };
  2661. } );
  2662. var rnothtmlwhite = ( /[^\x20\t\r\n\f]+/g );
  2663. // Convert String-formatted options into Object-formatted ones
  2664. function createOptions( options ) {
  2665. var object = {};
  2666. jQuery.each( options.match( rnothtmlwhite ) || [], function( _, flag ) {
  2667. object[ flag ] = true;
  2668. } );
  2669. return object;
  2670. }
  2671. /*
  2672. * Create a callback list using the following parameters:
  2673. *
  2674. * options: an optional list of space-separated options that will change how
  2675. * the callback list behaves or a more traditional option object
  2676. *
  2677. * By default a callback list will act like an event callback list and can be
  2678. * "fired" multiple times.
  2679. *
  2680. * Possible options:
  2681. *
  2682. * once: will ensure the callback list can only be fired once (like a Deferred)
  2683. *
  2684. * memory: will keep track of previous values and will call any callback added
  2685. * after the list has been fired right away with the latest "memorized"
  2686. * values (like a Deferred)
  2687. *
  2688. * unique: will ensure a callback can only be added once (no duplicate in the list)
  2689. *
  2690. * stopOnFalse: interrupt callings when a callback returns false
  2691. *
  2692. */
  2693. jQuery.Callbacks = function( options ) {
  2694. // Convert options from String-formatted to Object-formatted if needed
  2695. // (we check in cache first)
  2696. options = typeof options === "string" ?
  2697. createOptions( options ) :
  2698. jQuery.extend( {}, options );
  2699. var // Flag to know if list is currently firing
  2700. firing,
  2701. // Last fire value for non-forgettable lists
  2702. memory,
  2703. // Flag to know if list was already fired
  2704. fired,
  2705. // Flag to prevent firing
  2706. locked,
  2707. // Actual callback list
  2708. list = [],
  2709. // Queue of execution data for repeatable lists
  2710. queue = [],
  2711. // Index of currently firing callback (modified by add/remove as needed)
  2712. firingIndex = -1,
  2713. // Fire callbacks
  2714. fire = function() {
  2715. // Enforce single-firing
  2716. locked = locked || options.once;
  2717. // Execute callbacks for all pending executions,
  2718. // respecting firingIndex overrides and runtime changes
  2719. fired = firing = true;
  2720. for ( ; queue.length; firingIndex = -1 ) {
  2721. memory = queue.shift();
  2722. while ( ++firingIndex < list.length ) {
  2723. // Run callback and check for early termination
  2724. if ( list[ firingIndex ].apply( memory[ 0 ], memory[ 1 ] ) === false &&
  2725. options.stopOnFalse ) {
  2726. // Jump to end and forget the data so .add doesn't re-fire
  2727. firingIndex = list.length;
  2728. memory = false;
  2729. }
  2730. }
  2731. }
  2732. // Forget the data if we're done with it
  2733. if ( !options.memory ) {
  2734. memory = false;
  2735. }
  2736. firing = false;
  2737. // Clean up if we're done firing for good
  2738. if ( locked ) {
  2739. // Keep an empty list if we have data for future add calls
  2740. if ( memory ) {
  2741. list = [];
  2742. // Otherwise, this object is spent
  2743. } else {
  2744. list = "";
  2745. }
  2746. }
  2747. },
  2748. // Actual Callbacks object
  2749. self = {
  2750. // Add a callback or a collection of callbacks to the list
  2751. add: function() {
  2752. if ( list ) {
  2753. // If we have memory from a past run, we should fire after adding
  2754. if ( memory && !firing ) {
  2755. firingIndex = list.length - 1;
  2756. queue.push( memory );
  2757. }
  2758. ( function add( args ) {
  2759. jQuery.each( args, function( _, arg ) {
  2760. if ( isFunction( arg ) ) {
  2761. if ( !options.unique || !self.has( arg ) ) {
  2762. list.push( arg );
  2763. }
  2764. } else if ( arg && arg.length && toType( arg ) !== "string" ) {
  2765. // Inspect recursively
  2766. add( arg );
  2767. }
  2768. } );
  2769. } )( arguments );
  2770. if ( memory && !firing ) {
  2771. fire();
  2772. }
  2773. }
  2774. return this;
  2775. },
  2776. // Remove a callback from the list
  2777. remove: function() {
  2778. jQuery.each( arguments, function( _, arg ) {
  2779. var index;
  2780. while ( ( index = jQuery.inArray( arg, list, index ) ) > -1 ) {
  2781. list.splice( index, 1 );
  2782. // Handle firing indexes
  2783. if ( index <= firingIndex ) {
  2784. firingIndex--;
  2785. }
  2786. }
  2787. } );
  2788. return this;
  2789. },
  2790. // Check if a given callback is in the list.
  2791. // If no argument is given, return whether or not list has callbacks attached.
  2792. has: function( fn ) {
  2793. return fn ?
  2794. jQuery.inArray( fn, list ) > -1 :
  2795. list.length > 0;
  2796. },
  2797. // Remove all callbacks from the list
  2798. empty: function() {
  2799. if ( list ) {
  2800. list = [];
  2801. }
  2802. return this;
  2803. },
  2804. // Disable .fire and .add
  2805. // Abort any current/pending executions
  2806. // Clear all callbacks and values
  2807. disable: function() {
  2808. locked = queue = [];
  2809. list = memory = "";
  2810. return this;
  2811. },
  2812. disabled: function() {
  2813. return !list;
  2814. },
  2815. // Disable .fire
  2816. // Also disable .add unless we have memory (since it would have no effect)
  2817. // Abort any pending executions
  2818. lock: function() {
  2819. locked = queue = [];
  2820. if ( !memory && !firing ) {
  2821. list = memory = "";
  2822. }
  2823. return this;
  2824. },
  2825. locked: function() {
  2826. return !!locked;
  2827. },
  2828. // Call all callbacks with the given context and arguments
  2829. fireWith: function( context, args ) {
  2830. if ( !locked ) {
  2831. args = args || [];
  2832. args = [ context, args.slice ? args.slice() : args ];
  2833. queue.push( args );
  2834. if ( !firing ) {
  2835. fire();
  2836. }
  2837. }
  2838. return this;
  2839. },
  2840. // Call all the callbacks with the given arguments
  2841. fire: function() {
  2842. self.fireWith( this, arguments );
  2843. return this;
  2844. },
  2845. // To know if the callbacks have already been called at least once
  2846. fired: function() {
  2847. return !!fired;
  2848. }
  2849. };
  2850. return self;
  2851. };
  2852. function Identity( v ) {
  2853. return v;
  2854. }
  2855. function Thrower( ex ) {
  2856. throw ex;
  2857. }
  2858. function adoptValue( value, resolve, reject, noValue ) {
  2859. var method;
  2860. try {
  2861. // Check for promise aspect first to privilege synchronous behavior
  2862. if ( value && isFunction( ( method = value.promise ) ) ) {
  2863. method.call( value ).done( resolve ).fail( reject );
  2864. // Other thenables
  2865. } else if ( value && isFunction( ( method = value.then ) ) ) {
  2866. method.call( value, resolve, reject );
  2867. // Other non-thenables
  2868. } else {
  2869. // Control `resolve` arguments by letting Array#slice cast boolean `noValue` to integer:
  2870. // * false: [ value ].slice( 0 ) => resolve( value )
  2871. // * true: [ value ].slice( 1 ) => resolve()
  2872. resolve.apply( undefined, [ value ].slice( noValue ) );
  2873. }
  2874. // For Promises/A+, convert exceptions into rejections
  2875. // Since jQuery.when doesn't unwrap thenables, we can skip the extra checks appearing in
  2876. // Deferred#then to conditionally suppress rejection.
  2877. } catch ( value ) {
  2878. // Support: Android 4.0 only
  2879. // Strict mode functions invoked without .call/.apply get global-object context
  2880. reject.apply( undefined, [ value ] );
  2881. }
  2882. }
  2883. jQuery.extend( {
  2884. Deferred: function( func ) {
  2885. var tuples = [
  2886. // action, add listener, callbacks,
  2887. // ... .then handlers, argument index, [final state]
  2888. [ "notify", "progress", jQuery.Callbacks( "memory" ),
  2889. jQuery.Callbacks( "memory" ), 2 ],
  2890. [ "resolve", "done", jQuery.Callbacks( "once memory" ),
  2891. jQuery.Callbacks( "once memory" ), 0, "resolved" ],
  2892. [ "reject", "fail", jQuery.Callbacks( "once memory" ),
  2893. jQuery.Callbacks( "once memory" ), 1, "rejected" ]
  2894. ],
  2895. state = "pending",
  2896. promise = {
  2897. state: function() {
  2898. return state;
  2899. },
  2900. always: function() {
  2901. deferred.done( arguments ).fail( arguments );
  2902. return this;
  2903. },
  2904. "catch": function( fn ) {
  2905. return promise.then( null, fn );
  2906. },
  2907. // Keep pipe for back-compat
  2908. pipe: function( /* fnDone, fnFail, fnProgress */ ) {
  2909. var fns = arguments;
  2910. return jQuery.Deferred( function( newDefer ) {
  2911. jQuery.each( tuples, function( i, tuple ) {
  2912. // Map tuples (progress, done, fail) to arguments (done, fail, progress)
  2913. var fn = isFunction( fns[ tuple[ 4 ] ] ) && fns[ tuple[ 4 ] ];
  2914. // deferred.progress(function() { bind to newDefer or newDefer.notify })
  2915. // deferred.done(function() { bind to newDefer or newDefer.resolve })
  2916. // deferred.fail(function() { bind to newDefer or newDefer.reject })
  2917. deferred[ tuple[ 1 ] ]( function() {
  2918. var returned = fn && fn.apply( this, arguments );
  2919. if ( returned && isFunction( returned.promise ) ) {
  2920. returned.promise()
  2921. .progress( newDefer.notify )
  2922. .done( newDefer.resolve )
  2923. .fail( newDefer.reject );
  2924. } else {
  2925. newDefer[ tuple[ 0 ] + "With" ](
  2926. this,
  2927. fn ? [ returned ] : arguments
  2928. );
  2929. }
  2930. } );
  2931. } );
  2932. fns = null;
  2933. } ).promise();
  2934. },
  2935. then: function( onFulfilled, onRejected, onProgress ) {
  2936. var maxDepth = 0;
  2937. function resolve( depth, deferred, handler, special ) {
  2938. return function() {
  2939. var that = this,
  2940. args = arguments,
  2941. mightThrow = function() {
  2942. var returned, then;
  2943. // Support: Promises/A+ section 2.3.3.3.3
  2944. // https://promisesaplus.com/#point-59
  2945. // Ignore double-resolution attempts
  2946. if ( depth < maxDepth ) {
  2947. return;
  2948. }
  2949. returned = handler.apply( that, args );
  2950. // Support: Promises/A+ section 2.3.1
  2951. // https://promisesaplus.com/#point-48
  2952. if ( returned === deferred.promise() ) {
  2953. throw new TypeError( "Thenable self-resolution" );
  2954. }
  2955. // Support: Promises/A+ sections 2.3.3.1, 3.5
  2956. // https://promisesaplus.com/#point-54
  2957. // https://promisesaplus.com/#point-75
  2958. // Retrieve `then` only once
  2959. then = returned &&
  2960. // Support: Promises/A+ section 2.3.4
  2961. // https://promisesaplus.com/#point-64
  2962. // Only check objects and functions for thenability
  2963. ( typeof returned === "object" ||
  2964. typeof returned === "function" ) &&
  2965. returned.then;
  2966. // Handle a returned thenable
  2967. if ( isFunction( then ) ) {
  2968. // Special processors (notify) just wait for resolution
  2969. if ( special ) {
  2970. then.call(
  2971. returned,
  2972. resolve( maxDepth, deferred, Identity, special ),
  2973. resolve( maxDepth, deferred, Thrower, special )
  2974. );
  2975. // Normal processors (resolve) also hook into progress
  2976. } else {
  2977. // ...and disregard older resolution values
  2978. maxDepth++;
  2979. then.call(
  2980. returned,
  2981. resolve( maxDepth, deferred, Identity, special ),
  2982. resolve( maxDepth, deferred, Thrower, special ),
  2983. resolve( maxDepth, deferred, Identity,
  2984. deferred.notifyWith )
  2985. );
  2986. }
  2987. // Handle all other returned values
  2988. } else {
  2989. // Only substitute handlers pass on context
  2990. // and multiple values (non-spec behavior)
  2991. if ( handler !== Identity ) {
  2992. that = undefined;
  2993. args = [ returned ];
  2994. }
  2995. // Process the value(s)
  2996. // Default process is resolve
  2997. ( special || deferred.resolveWith )( that, args );
  2998. }
  2999. },
  3000. // Only normal processors (resolve) catch and reject exceptions
  3001. process = special ?
  3002. mightThrow :
  3003. function() {
  3004. try {
  3005. mightThrow();
  3006. } catch ( e ) {
  3007. if ( jQuery.Deferred.exceptionHook ) {
  3008. jQuery.Deferred.exceptionHook( e,
  3009. process.stackTrace );
  3010. }
  3011. // Support: Promises/A+ section 2.3.3.3.4.1
  3012. // https://promisesaplus.com/#point-61
  3013. // Ignore post-resolution exceptions
  3014. if ( depth + 1 >= maxDepth ) {
  3015. // Only substitute handlers pass on context
  3016. // and multiple values (non-spec behavior)
  3017. if ( handler !== Thrower ) {
  3018. that = undefined;
  3019. args = [ e ];
  3020. }
  3021. deferred.rejectWith( that, args );
  3022. }
  3023. }
  3024. };
  3025. // Support: Promises/A+ section 2.3.3.3.1
  3026. // https://promisesaplus.com/#point-57
  3027. // Re-resolve promises immediately to dodge false rejection from
  3028. // subsequent errors
  3029. if ( depth ) {
  3030. process();
  3031. } else {
  3032. // Call an optional hook to record the stack, in case of exception
  3033. // since it's otherwise lost when execution goes async
  3034. if ( jQuery.Deferred.getStackHook ) {
  3035. process.stackTrace = jQuery.Deferred.getStackHook();
  3036. }
  3037. window.setTimeout( process );
  3038. }
  3039. };
  3040. }
  3041. return jQuery.Deferred( function( newDefer ) {
  3042. // progress_handlers.add( ... )
  3043. tuples[ 0 ][ 3 ].add(
  3044. resolve(
  3045. 0,
  3046. newDefer,
  3047. isFunction( onProgress ) ?
  3048. onProgress :
  3049. Identity,
  3050. newDefer.notifyWith
  3051. )
  3052. );
  3053. // fulfilled_handlers.add( ... )
  3054. tuples[ 1 ][ 3 ].add(
  3055. resolve(
  3056. 0,
  3057. newDefer,
  3058. isFunction( onFulfilled ) ?
  3059. onFulfilled :
  3060. Identity
  3061. )
  3062. );
  3063. // rejected_handlers.add( ... )
  3064. tuples[ 2 ][ 3 ].add(
  3065. resolve(
  3066. 0,
  3067. newDefer,
  3068. isFunction( onRejected ) ?
  3069. onRejected :
  3070. Thrower
  3071. )
  3072. );
  3073. } ).promise();
  3074. },
  3075. // Get a promise for this deferred
  3076. // If obj is provided, the promise aspect is added to the object
  3077. promise: function( obj ) {
  3078. return obj != null ? jQuery.extend( obj, promise ) : promise;
  3079. }
  3080. },
  3081. deferred = {};
  3082. // Add list-specific methods
  3083. jQuery.each( tuples, function( i, tuple ) {
  3084. var list = tuple[ 2 ],
  3085. stateString = tuple[ 5 ];
  3086. // promise.progress = list.add
  3087. // promise.done = list.add
  3088. // promise.fail = list.add
  3089. promise[ tuple[ 1 ] ] = list.add;
  3090. // Handle state
  3091. if ( stateString ) {
  3092. list.add(
  3093. function() {
  3094. // state = "resolved" (i.e., fulfilled)
  3095. // state = "rejected"
  3096. state = stateString;
  3097. },
  3098. // rejected_callbacks.disable
  3099. // fulfilled_callbacks.disable
  3100. tuples[ 3 - i ][ 2 ].disable,
  3101. // rejected_handlers.disable
  3102. // fulfilled_handlers.disable
  3103. tuples[ 3 - i ][ 3 ].disable,
  3104. // progress_callbacks.lock
  3105. tuples[ 0 ][ 2 ].lock,
  3106. // progress_handlers.lock
  3107. tuples[ 0 ][ 3 ].lock
  3108. );
  3109. }
  3110. // progress_handlers.fire
  3111. // fulfilled_handlers.fire
  3112. // rejected_handlers.fire
  3113. list.add( tuple[ 3 ].fire );
  3114. // deferred.notify = function() { deferred.notifyWith(...) }
  3115. // deferred.resolve = function() { deferred.resolveWith(...) }
  3116. // deferred.reject = function() { deferred.rejectWith(...) }
  3117. deferred[ tuple[ 0 ] ] = function() {
  3118. deferred[ tuple[ 0 ] + "With" ]( this === deferred ? undefined : this, arguments );
  3119. return this;
  3120. };
  3121. // deferred.notifyWith = list.fireWith
  3122. // deferred.resolveWith = list.fireWith
  3123. // deferred.rejectWith = list.fireWith
  3124. deferred[ tuple[ 0 ] + "With" ] = list.fireWith;
  3125. } );
  3126. // Make the deferred a promise
  3127. promise.promise( deferred );
  3128. // Call given func if any
  3129. if ( func ) {
  3130. func.call( deferred, deferred );
  3131. }
  3132. // All done!
  3133. return deferred;
  3134. },
  3135. // Deferred helper
  3136. when: function( singleValue ) {
  3137. var
  3138. // count of uncompleted subordinates
  3139. remaining = arguments.length,
  3140. // count of unprocessed arguments
  3141. i = remaining,
  3142. // subordinate fulfillment data
  3143. resolveContexts = Array( i ),
  3144. resolveValues = slice.call( arguments ),
  3145. // the master Deferred
  3146. master = jQuery.Deferred(),
  3147. // subordinate callback factory
  3148. updateFunc = function( i ) {
  3149. return function( value ) {
  3150. resolveContexts[ i ] = this;
  3151. resolveValues[ i ] = arguments.length > 1 ? slice.call( arguments ) : value;
  3152. if ( !( --remaining ) ) {
  3153. master.resolveWith( resolveContexts, resolveValues );
  3154. }
  3155. };
  3156. };
  3157. // Single- and empty arguments are adopted like Promise.resolve
  3158. if ( remaining <= 1 ) {
  3159. adoptValue( singleValue, master.done( updateFunc( i ) ).resolve, master.reject,
  3160. !remaining );
  3161. // Use .then() to unwrap secondary thenables (cf. gh-3000)
  3162. if ( master.state() === "pending" ||
  3163. isFunction( resolveValues[ i ] && resolveValues[ i ].then ) ) {
  3164. return master.then();
  3165. }
  3166. }
  3167. // Multiple arguments are aggregated like Promise.all array elements
  3168. while ( i-- ) {
  3169. adoptValue( resolveValues[ i ], updateFunc( i ), master.reject );
  3170. }
  3171. return master.promise();
  3172. }
  3173. } );
  3174. // These usually indicate a programmer mistake during development,
  3175. // warn about them ASAP rather than swallowing them by default.
  3176. var rerrorNames = /^(Eval|Internal|Range|Reference|Syntax|Type|URI)Error$/;
  3177. jQuery.Deferred.exceptionHook = function( error, stack ) {
  3178. // Support: IE 8 - 9 only
  3179. // Console exists when dev tools are open, which can happen at any time
  3180. if ( window.console && window.console.warn && error && rerrorNames.test( error.name ) ) {
  3181. window.console.warn( "jQuery.Deferred exception: " + error.message, error.stack, stack );
  3182. }
  3183. };
  3184. jQuery.readyException = function( error ) {
  3185. window.setTimeout( function() {
  3186. throw error;
  3187. } );
  3188. };
  3189. // The deferred used on DOM ready
  3190. var readyList = jQuery.Deferred();
  3191. jQuery.fn.ready = function( fn ) {
  3192. readyList
  3193. .then( fn )
  3194. // Wrap jQuery.readyException in a function so that the lookup
  3195. // happens at the time of error handling instead of callback
  3196. // registration.
  3197. .catch( function( error ) {
  3198. jQuery.readyException( error );
  3199. } );
  3200. return this;
  3201. };
  3202. jQuery.extend( {
  3203. // Is the DOM ready to be used? Set to true once it occurs.
  3204. isReady: false,
  3205. // A counter to track how many items to wait for before
  3206. // the ready event fires. See #6781
  3207. readyWait: 1,
  3208. // Handle when the DOM is ready
  3209. ready: function( wait ) {
  3210. // Abort if there are pending holds or we're already ready
  3211. if ( wait === true ? --jQuery.readyWait : jQuery.isReady ) {
  3212. return;
  3213. }
  3214. // Remember that the DOM is ready
  3215. jQuery.isReady = true;
  3216. // If a normal DOM Ready event fired, decrement, and wait if need be
  3217. if ( wait !== true && --jQuery.readyWait > 0 ) {
  3218. return;
  3219. }
  3220. // If there are functions bound, to execute
  3221. readyList.resolveWith( document, [ jQuery ] );
  3222. }
  3223. } );
  3224. jQuery.ready.then = readyList.then;
  3225. // The ready event handler and self cleanup method
  3226. function completed() {
  3227. document.removeEventListener( "DOMContentLoaded", completed );
  3228. window.removeEventListener( "load", completed );
  3229. jQuery.ready();
  3230. }
  3231. // Catch cases where $(document).ready() is called
  3232. // after the browser event has already occurred.
  3233. // Support: IE <=9 - 10 only
  3234. // Older IE sometimes signals "interactive" too soon
  3235. if ( document.readyState === "complete" ||
  3236. ( document.readyState !== "loading" && !document.documentElement.doScroll ) ) {
  3237. // Handle it asynchronously to allow scripts the opportunity to delay ready
  3238. window.setTimeout( jQuery.ready );
  3239. } else {
  3240. // Use the handy event callback
  3241. document.addEventListener( "DOMContentLoaded", completed );
  3242. // A fallback to window.onload, that will always work
  3243. window.addEventListener( "load", completed );
  3244. }
  3245. // Multifunctional method to get and set values of a collection
  3246. // The value/s can optionally be executed if it's a function
  3247. var access = function( elems, fn, key, value, chainable, emptyGet, raw ) {
  3248. var i = 0,
  3249. len = elems.length,
  3250. bulk = key == null;
  3251. // Sets many values
  3252. if ( toType( key ) === "object" ) {
  3253. chainable = true;
  3254. for ( i in key ) {
  3255. access( elems, fn, i, key[ i ], true, emptyGet, raw );
  3256. }
  3257. // Sets one value
  3258. } else if ( value !== undefined ) {
  3259. chainable = true;
  3260. if ( !isFunction( value ) ) {
  3261. raw = true;
  3262. }
  3263. if ( bulk ) {
  3264. // Bulk operations run against the entire set
  3265. if ( raw ) {
  3266. fn.call( elems, value );
  3267. fn = null;
  3268. // ...except when executing function values
  3269. } else {
  3270. bulk = fn;
  3271. fn = function( elem, key, value ) {
  3272. return bulk.call( jQuery( elem ), value );
  3273. };
  3274. }
  3275. }
  3276. if ( fn ) {
  3277. for ( ; i < len; i++ ) {
  3278. fn(
  3279. elems[ i ], key, raw ?
  3280. value :
  3281. value.call( elems[ i ], i, fn( elems[ i ], key ) )
  3282. );
  3283. }
  3284. }
  3285. }
  3286. if ( chainable ) {
  3287. return elems;
  3288. }
  3289. // Gets
  3290. if ( bulk ) {
  3291. return fn.call( elems );
  3292. }
  3293. return len ? fn( elems[ 0 ], key ) : emptyGet;
  3294. };
  3295. // Matches dashed string for camelizing
  3296. var rmsPrefix = /^-ms-/,
  3297. rdashAlpha = /-([a-z])/g;
  3298. // Used by camelCase as callback to replace()
  3299. function fcamelCase( all, letter ) {
  3300. return letter.toUpperCase();
  3301. }
  3302. // Convert dashed to camelCase; used by the css and data modules
  3303. // Support: IE <=9 - 11, Edge 12 - 15
  3304. // Microsoft forgot to hump their vendor prefix (#9572)
  3305. function camelCase( string ) {
  3306. return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
  3307. }
  3308. var acceptData = function( owner ) {
  3309. // Accepts only:
  3310. // - Node
  3311. // - Node.ELEMENT_NODE
  3312. // - Node.DOCUMENT_NODE
  3313. // - Object
  3314. // - Any
  3315. return owner.nodeType === 1 || owner.nodeType === 9 || !( +owner.nodeType );
  3316. };
  3317. function Data() {
  3318. this.expando = jQuery.expando + Data.uid++;
  3319. }
  3320. Data.uid = 1;
  3321. Data.prototype = {
  3322. cache: function( owner ) {
  3323. // Check if the owner object already has a cache
  3324. var value = owner[ this.expando ];
  3325. // If not, create one
  3326. if ( !value ) {
  3327. value = {};
  3328. // We can accept data for non-element nodes in modern browsers,
  3329. // but we should not, see #8335.
  3330. // Always return an empty object.
  3331. if ( acceptData( owner ) ) {
  3332. // If it is a node unlikely to be stringify-ed or looped over
  3333. // use plain assignment
  3334. if ( owner.nodeType ) {
  3335. owner[ this.expando ] = value;
  3336. // Otherwise secure it in a non-enumerable property
  3337. // configurable must be true to allow the property to be
  3338. // deleted when data is removed
  3339. } else {
  3340. Object.defineProperty( owner, this.expando, {
  3341. value: value,
  3342. configurable: true
  3343. } );
  3344. }
  3345. }
  3346. }
  3347. return value;
  3348. },
  3349. set: function( owner, data, value ) {
  3350. var prop,
  3351. cache = this.cache( owner );
  3352. // Handle: [ owner, key, value ] args
  3353. // Always use camelCase key (gh-2257)
  3354. if ( typeof data === "string" ) {
  3355. cache[ camelCase( data ) ] = value;
  3356. // Handle: [ owner, { properties } ] args
  3357. } else {
  3358. // Copy the properties one-by-one to the cache object
  3359. for ( prop in data ) {
  3360. cache[ camelCase( prop ) ] = data[ prop ];
  3361. }
  3362. }
  3363. return cache;
  3364. },
  3365. get: function( owner, key ) {
  3366. return key === undefined ?
  3367. this.cache( owner ) :
  3368. // Always use camelCase key (gh-2257)
  3369. owner[ this.expando ] && owner[ this.expando ][ camelCase( key ) ];
  3370. },
  3371. access: function( owner, key, value ) {
  3372. // In cases where either:
  3373. //
  3374. // 1. No key was specified
  3375. // 2. A string key was specified, but no value provided
  3376. //
  3377. // Take the "read" path and allow the get method to determine
  3378. // which value to return, respectively either:
  3379. //
  3380. // 1. The entire cache object
  3381. // 2. The data stored at the key
  3382. //
  3383. if ( key === undefined ||
  3384. ( ( key && typeof key === "string" ) && value === undefined ) ) {
  3385. return this.get( owner, key );
  3386. }
  3387. // When the key is not a string, or both a key and value
  3388. // are specified, set or extend (existing objects) with either:
  3389. //
  3390. // 1. An object of properties
  3391. // 2. A key and value
  3392. //
  3393. this.set( owner, key, value );
  3394. // Since the "set" path can have two possible entry points
  3395. // return the expected data based on which path was taken[*]
  3396. return value !== undefined ? value : key;
  3397. },
  3398. remove: function( owner, key ) {
  3399. var i,
  3400. cache = owner[ this.expando ];
  3401. if ( cache === undefined ) {
  3402. return;
  3403. }
  3404. if ( key !== undefined ) {
  3405. // Support array or space separated string of keys
  3406. if ( Array.isArray( key ) ) {
  3407. // If key is an array of keys...
  3408. // We always set camelCase keys, so remove that.
  3409. key = key.map( camelCase );
  3410. } else {
  3411. key = camelCase( key );
  3412. // If a key with the spaces exists, use it.
  3413. // Otherwise, create an array by matching non-whitespace
  3414. key = key in cache ?
  3415. [ key ] :
  3416. ( key.match( rnothtmlwhite ) || [] );
  3417. }
  3418. i = key.length;
  3419. while ( i-- ) {
  3420. delete cache[ key[ i ] ];
  3421. }
  3422. }
  3423. // Remove the expando if there's no more data
  3424. if ( key === undefined || jQuery.isEmptyObject( cache ) ) {
  3425. // Support: Chrome <=35 - 45
  3426. // Webkit & Blink performance suffers when deleting properties
  3427. // from DOM nodes, so set to undefined instead
  3428. // https://bugs.chromium.org/p/chromium/issues/detail?id=378607 (bug restricted)
  3429. if ( owner.nodeType ) {
  3430. owner[ this.expando ] = undefined;
  3431. } else {
  3432. delete owner[ this.expando ];
  3433. }
  3434. }
  3435. },
  3436. hasData: function( owner ) {
  3437. var cache = owner[ this.expando ];
  3438. return cache !== undefined && !jQuery.isEmptyObject( cache );
  3439. }
  3440. };
  3441. var dataPriv = new Data();
  3442. var dataUser = new Data();
  3443. // Implementation Summary
  3444. //
  3445. // 1. Enforce API surface and semantic compatibility with 1.9.x branch
  3446. // 2. Improve the module's maintainability by reducing the storage
  3447. // paths to a single mechanism.
  3448. // 3. Use the same single mechanism to support "private" and "user" data.
  3449. // 4. _Never_ expose "private" data to user code (TODO: Drop _data, _removeData)
  3450. // 5. Avoid exposing implementation details on user objects (eg. expando properties)
  3451. // 6. Provide a clear path for implementation upgrade to WeakMap in 2014
  3452. var rbrace = /^(?:\{[\w\W]*\}|\[[\w\W]*\])$/,
  3453. rmultiDash = /[A-Z]/g;
  3454. function getData( data ) {
  3455. if ( data === "true" ) {
  3456. return true;
  3457. }
  3458. if ( data === "false" ) {
  3459. return false;
  3460. }
  3461. if ( data === "null" ) {
  3462. return null;
  3463. }
  3464. // Only convert to a number if it doesn't change the string
  3465. if ( data === +data + "" ) {
  3466. return +data;
  3467. }
  3468. if ( rbrace.test( data ) ) {
  3469. return JSON.parse( data );
  3470. }
  3471. return data;
  3472. }
  3473. function dataAttr( elem, key, data ) {
  3474. var name;
  3475. // If nothing was found internally, try to fetch any
  3476. // data from the HTML5 data-* attribute
  3477. if ( data === undefined && elem.nodeType === 1 ) {
  3478. name = "data-" + key.replace( rmultiDash, "-$&" ).toLowerCase();
  3479. data = elem.getAttribute( name );
  3480. if ( typeof data === "string" ) {
  3481. try {
  3482. data = getData( data );
  3483. } catch ( e ) {}
  3484. // Make sure we set the data so it isn't changed later
  3485. dataUser.set( elem, key, data );
  3486. } else {
  3487. data = undefined;
  3488. }
  3489. }
  3490. return data;
  3491. }
  3492. jQuery.extend( {
  3493. hasData: function( elem ) {
  3494. return dataUser.hasData( elem ) || dataPriv.hasData( elem );
  3495. },
  3496. data: function( elem, name, data ) {
  3497. return dataUser.access( elem, name, data );
  3498. },
  3499. removeData: function( elem, name ) {
  3500. dataUser.remove( elem, name );
  3501. },
  3502. // TODO: Now that all calls to _data and _removeData have been replaced
  3503. // with direct calls to dataPriv methods, these can be deprecated.
  3504. _data: function( elem, name, data ) {
  3505. return dataPriv.access( elem, name, data );
  3506. },
  3507. _removeData: function( elem, name ) {
  3508. dataPriv.remove( elem, name );
  3509. }
  3510. } );
  3511. jQuery.fn.extend( {
  3512. data: function( key, value ) {
  3513. var i, name, data,
  3514. elem = this[ 0 ],
  3515. attrs = elem && elem.attributes;
  3516. // Gets all values
  3517. if ( key === undefined ) {
  3518. if ( this.length ) {
  3519. data = dataUser.get( elem );
  3520. if ( elem.nodeType === 1 && !dataPriv.get( elem, "hasDataAttrs" ) ) {
  3521. i = attrs.length;
  3522. while ( i-- ) {
  3523. // Support: IE 11 only
  3524. // The attrs elements can be null (#14894)
  3525. if ( attrs[ i ] ) {
  3526. name = attrs[ i ].name;
  3527. if ( name.indexOf( "data-" ) === 0 ) {
  3528. name = camelCase( name.slice( 5 ) );
  3529. dataAttr( elem, name, data[ name ] );
  3530. }
  3531. }
  3532. }
  3533. dataPriv.set( elem, "hasDataAttrs", true );
  3534. }
  3535. }
  3536. return data;
  3537. }
  3538. // Sets multiple values
  3539. if ( typeof key === "object" ) {
  3540. return this.each( function() {
  3541. dataUser.set( this, key );
  3542. } );
  3543. }
  3544. return access( this, function( value ) {
  3545. var data;
  3546. // The calling jQuery object (element matches) is not empty
  3547. // (and therefore has an element appears at this[ 0 ]) and the
  3548. // `value` parameter was not undefined. An empty jQuery object
  3549. // will result in `undefined` for elem = this[ 0 ] which will
  3550. // throw an exception if an attempt to read a data cache is made.
  3551. if ( elem && value === undefined ) {
  3552. // Attempt to get data from the cache
  3553. // The key will always be camelCased in Data
  3554. data = dataUser.get( elem, key );
  3555. if ( data !== undefined ) {
  3556. return data;
  3557. }
  3558. // Attempt to "discover" the data in
  3559. // HTML5 custom data-* attrs
  3560. data = dataAttr( elem, key );
  3561. if ( data !== undefined ) {
  3562. return data;
  3563. }
  3564. // We tried really hard, but the data doesn't exist.
  3565. return;
  3566. }
  3567. // Set the data...
  3568. this.each( function() {
  3569. // We always store the camelCased key
  3570. dataUser.set( this, key, value );
  3571. } );
  3572. }, null, value, arguments.length > 1, null, true );
  3573. },
  3574. removeData: function( key ) {
  3575. return this.each( function() {
  3576. dataUser.remove( this, key );
  3577. } );
  3578. }
  3579. } );
  3580. jQuery.extend( {
  3581. queue: function( elem, type, data ) {
  3582. var queue;
  3583. if ( elem ) {
  3584. type = ( type || "fx" ) + "queue";
  3585. queue = dataPriv.get( elem, type );
  3586. // Speed up dequeue by getting out quickly if this is just a lookup
  3587. if ( data ) {
  3588. if ( !queue || Array.isArray( data ) ) {
  3589. queue = dataPriv.access( elem, type, jQuery.makeArray( data ) );
  3590. } else {
  3591. queue.push( data );
  3592. }
  3593. }
  3594. return queue || [];
  3595. }
  3596. },
  3597. dequeue: function( elem, type ) {
  3598. type = type || "fx";
  3599. var queue = jQuery.queue( elem, type ),
  3600. startLength = queue.length,
  3601. fn = queue.shift(),
  3602. hooks = jQuery._queueHooks( elem, type ),
  3603. next = function() {
  3604. jQuery.dequeue( elem, type );
  3605. };
  3606. // If the fx queue is dequeued, always remove the progress sentinel
  3607. if ( fn === "inprogress" ) {
  3608. fn = queue.shift();
  3609. startLength--;
  3610. }
  3611. if ( fn ) {
  3612. // Add a progress sentinel to prevent the fx queue from being
  3613. // automatically dequeued
  3614. if ( type === "fx" ) {
  3615. queue.unshift( "inprogress" );
  3616. }
  3617. // Clear up the last queue stop function
  3618. delete hooks.stop;
  3619. fn.call( elem, next, hooks );
  3620. }
  3621. if ( !startLength && hooks ) {
  3622. hooks.empty.fire();
  3623. }
  3624. },
  3625. // Not public - generate a queueHooks object, or return the current one
  3626. _queueHooks: function( elem, type ) {
  3627. var key = type + "queueHooks";
  3628. return dataPriv.get( elem, key ) || dataPriv.access( elem, key, {
  3629. empty: jQuery.Callbacks( "once memory" ).add( function() {
  3630. dataPriv.remove( elem, [ type + "queue", key ] );
  3631. } )
  3632. } );
  3633. }
  3634. } );
  3635. jQuery.fn.extend( {
  3636. queue: function( type, data ) {
  3637. var setter = 2;
  3638. if ( typeof type !== "string" ) {
  3639. data = type;
  3640. type = "fx";
  3641. setter--;
  3642. }
  3643. if ( arguments.length < setter ) {
  3644. return jQuery.queue( this[ 0 ], type );
  3645. }
  3646. return data === undefined ?
  3647. this :
  3648. this.each( function() {
  3649. var queue = jQuery.queue( this, type, data );
  3650. // Ensure a hooks for this queue
  3651. jQuery._queueHooks( this, type );
  3652. if ( type === "fx" && queue[ 0 ] !== "inprogress" ) {
  3653. jQuery.dequeue( this, type );
  3654. }
  3655. } );
  3656. },
  3657. dequeue: function( type ) {
  3658. return this.each( function() {
  3659. jQuery.dequeue( this, type );
  3660. } );
  3661. },
  3662. clearQueue: function( type ) {
  3663. return this.queue( type || "fx", [] );
  3664. },
  3665. // Get a promise resolved when queues of a certain type
  3666. // are emptied (fx is the type by default)
  3667. promise: function( type, obj ) {
  3668. var tmp,
  3669. count = 1,
  3670. defer = jQuery.Deferred(),
  3671. elements = this,
  3672. i = this.length,
  3673. resolve = function() {
  3674. if ( !( --count ) ) {
  3675. defer.resolveWith( elements, [ elements ] );
  3676. }
  3677. };
  3678. if ( typeof type !== "string" ) {
  3679. obj = type;
  3680. type = undefined;
  3681. }
  3682. type = type || "fx";
  3683. while ( i-- ) {
  3684. tmp = dataPriv.get( elements[ i ], type + "queueHooks" );
  3685. if ( tmp && tmp.empty ) {
  3686. count++;
  3687. tmp.empty.add( resolve );
  3688. }
  3689. }
  3690. resolve();
  3691. return defer.promise( obj );
  3692. }
  3693. } );
  3694. var pnum = ( /[+-]?(?:\d*\.|)\d+(?:[eE][+-]?\d+|)/ ).source;
  3695. var rcssNum = new RegExp( "^(?:([+-])=|)(" + pnum + ")([a-z%]*)$", "i" );
  3696. var cssExpand = [ "Top", "Right", "Bottom", "Left" ];
  3697. var documentElement = document.documentElement;
  3698. var isAttached = function( elem ) {
  3699. return jQuery.contains( elem.ownerDocument, elem );
  3700. },
  3701. composed = { composed: true };
  3702. // Support: IE 9 - 11+, Edge 12 - 18+, iOS 10.0 - 10.2 only
  3703. // Check attachment across shadow DOM boundaries when possible (gh-3504)
  3704. // Support: iOS 10.0-10.2 only
  3705. // Early iOS 10 versions support `attachShadow` but not `getRootNode`,
  3706. // leading to errors. We need to check for `getRootNode`.
  3707. if ( documentElement.getRootNode ) {
  3708. isAttached = function( elem ) {
  3709. return jQuery.contains( elem.ownerDocument, elem ) ||
  3710. elem.getRootNode( composed ) === elem.ownerDocument;
  3711. };
  3712. }
  3713. var isHiddenWithinTree = function( elem, el ) {
  3714. // isHiddenWithinTree might be called from jQuery#filter function;
  3715. // in that case, element will be second argument
  3716. elem = el || elem;
  3717. // Inline style trumps all
  3718. return elem.style.display === "none" ||
  3719. elem.style.display === "" &&
  3720. // Otherwise, check computed style
  3721. // Support: Firefox <=43 - 45
  3722. // Disconnected elements can have computed display: none, so first confirm that elem is
  3723. // in the document.
  3724. isAttached( elem ) &&
  3725. jQuery.css( elem, "display" ) === "none";
  3726. };
  3727. var swap = function( elem, options, callback, args ) {
  3728. var ret, name,
  3729. old = {};
  3730. // Remember the old values, and insert the new ones
  3731. for ( name in options ) {
  3732. old[ name ] = elem.style[ name ];
  3733. elem.style[ name ] = options[ name ];
  3734. }
  3735. ret = callback.apply( elem, args || [] );
  3736. // Revert the old values
  3737. for ( name in options ) {
  3738. elem.style[ name ] = old[ name ];
  3739. }
  3740. return ret;
  3741. };
  3742. function adjustCSS( elem, prop, valueParts, tween ) {
  3743. var adjusted, scale,
  3744. maxIterations = 20,
  3745. currentValue = tween ?
  3746. function() {
  3747. return tween.cur();
  3748. } :
  3749. function() {
  3750. return jQuery.css( elem, prop, "" );
  3751. },
  3752. initial = currentValue(),
  3753. unit = valueParts && valueParts[ 3 ] || ( jQuery.cssNumber[ prop ] ? "" : "px" ),
  3754. // Starting value computation is required for potential unit mismatches
  3755. initialInUnit = elem.nodeType &&
  3756. ( jQuery.cssNumber[ prop ] || unit !== "px" && +initial ) &&
  3757. rcssNum.exec( jQuery.css( elem, prop ) );
  3758. if ( initialInUnit && initialInUnit[ 3 ] !== unit ) {
  3759. // Support: Firefox <=54
  3760. // Halve the iteration target value to prevent interference from CSS upper bounds (gh-2144)
  3761. initial = initial / 2;
  3762. // Trust units reported by jQuery.css
  3763. unit = unit || initialInUnit[ 3 ];
  3764. // Iteratively approximate from a nonzero starting point
  3765. initialInUnit = +initial || 1;
  3766. while ( maxIterations-- ) {
  3767. // Evaluate and update our best guess (doubling guesses that zero out).
  3768. // Finish if the scale equals or crosses 1 (making the old*new product non-positive).
  3769. jQuery.style( elem, prop, initialInUnit + unit );
  3770. if ( ( 1 - scale ) * ( 1 - ( scale = currentValue() / initial || 0.5 ) ) <= 0 ) {
  3771. maxIterations = 0;
  3772. }
  3773. initialInUnit = initialInUnit / scale;
  3774. }
  3775. initialInUnit = initialInUnit * 2;
  3776. jQuery.style( elem, prop, initialInUnit + unit );
  3777. // Make sure we update the tween properties later on
  3778. valueParts = valueParts || [];
  3779. }
  3780. if ( valueParts ) {
  3781. initialInUnit = +initialInUnit || +initial || 0;
  3782. // Apply relative offset (+=/-=) if specified
  3783. adjusted = valueParts[ 1 ] ?
  3784. initialInUnit + ( valueParts[ 1 ] + 1 ) * valueParts[ 2 ] :
  3785. +valueParts[ 2 ];
  3786. if ( tween ) {
  3787. tween.unit = unit;
  3788. tween.start = initialInUnit;
  3789. tween.end = adjusted;
  3790. }
  3791. }
  3792. return adjusted;
  3793. }
  3794. var defaultDisplayMap = {};
  3795. function getDefaultDisplay( elem ) {
  3796. var temp,
  3797. doc = elem.ownerDocument,
  3798. nodeName = elem.nodeName,
  3799. display = defaultDisplayMap[ nodeName ];
  3800. if ( display ) {
  3801. return display;
  3802. }
  3803. temp = doc.body.appendChild( doc.createElement( nodeName ) );
  3804. display = jQuery.css( temp, "display" );
  3805. temp.parentNode.removeChild( temp );
  3806. if ( display === "none" ) {
  3807. display = "block";
  3808. }
  3809. defaultDisplayMap[ nodeName ] = display;
  3810. return display;
  3811. }
  3812. function showHide( elements, show ) {
  3813. var display, elem,
  3814. values = [],
  3815. index = 0,
  3816. length = elements.length;
  3817. // Determine new display value for elements that need to change
  3818. for ( ; index < length; index++ ) {
  3819. elem = elements[ index ];
  3820. if ( !elem.style ) {
  3821. continue;
  3822. }
  3823. display = elem.style.display;
  3824. if ( show ) {
  3825. // Since we force visibility upon cascade-hidden elements, an immediate (and slow)
  3826. // check is required in this first loop unless we have a nonempty display value (either
  3827. // inline or about-to-be-restored)
  3828. if ( display === "none" ) {
  3829. values[ index ] = dataPriv.get( elem, "display" ) || null;
  3830. if ( !values[ index ] ) {
  3831. elem.style.display = "";
  3832. }
  3833. }
  3834. if ( elem.style.display === "" && isHiddenWithinTree( elem ) ) {
  3835. values[ index ] = getDefaultDisplay( elem );
  3836. }
  3837. } else {
  3838. if ( display !== "none" ) {
  3839. values[ index ] = "none";
  3840. // Remember what we're overwriting
  3841. dataPriv.set( elem, "display", display );
  3842. }
  3843. }
  3844. }
  3845. // Set the display of the elements in a second loop to avoid constant reflow
  3846. for ( index = 0; index < length; index++ ) {
  3847. if ( values[ index ] != null ) {
  3848. elements[ index ].style.display = values[ index ];
  3849. }
  3850. }
  3851. return elements;
  3852. }
  3853. jQuery.fn.extend( {
  3854. show: function() {
  3855. return showHide( this, true );
  3856. },
  3857. hide: function() {
  3858. return showHide( this );
  3859. },
  3860. toggle: function( state ) {
  3861. if ( typeof state === "boolean" ) {
  3862. return state ? this.show() : this.hide();
  3863. }
  3864. return this.each( function() {
  3865. if ( isHiddenWithinTree( this ) ) {
  3866. jQuery( this ).show();
  3867. } else {
  3868. jQuery( this ).hide();
  3869. }
  3870. } );
  3871. }
  3872. } );
  3873. var rcheckableType = ( /^(?:checkbox|radio)$/i );
  3874. var rtagName = ( /<([a-z][^\/\0>\x20\t\r\n\f]*)/i );
  3875. var rscriptType = ( /^$|^module$|\/(?:java|ecma)script/i );
  3876. // We have to close these tags to support XHTML (#13200)
  3877. var wrapMap = {
  3878. // Support: IE <=9 only
  3879. option: [ 1, "<select multiple='multiple'>", "</select>" ],
  3880. // XHTML parsers do not magically insert elements in the
  3881. // same way that tag soup parsers do. So we cannot shorten
  3882. // this by omitting <tbody> or other required elements.
  3883. thead: [ 1, "<table>", "</table>" ],
  3884. col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
  3885. tr: [ 2, "<table><tbody>", "</tbody></table>" ],
  3886. td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
  3887. _default: [ 0, "", "" ]
  3888. };
  3889. // Support: IE <=9 only
  3890. wrapMap.optgroup = wrapMap.option;
  3891. wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
  3892. wrapMap.th = wrapMap.td;
  3893. function getAll( context, tag ) {
  3894. // Support: IE <=9 - 11 only
  3895. // Use typeof to avoid zero-argument method invocation on host objects (#15151)
  3896. var ret;
  3897. if ( typeof context.getElementsByTagName !== "undefined" ) {
  3898. ret = context.getElementsByTagName( tag || "*" );
  3899. } else if ( typeof context.querySelectorAll !== "undefined" ) {
  3900. ret = context.querySelectorAll( tag || "*" );
  3901. } else {
  3902. ret = [];
  3903. }
  3904. if ( tag === undefined || tag && nodeName( context, tag ) ) {
  3905. return jQuery.merge( [ context ], ret );
  3906. }
  3907. return ret;
  3908. }
  3909. // Mark scripts as having already been evaluated
  3910. function setGlobalEval( elems, refElements ) {
  3911. var i = 0,
  3912. l = elems.length;
  3913. for ( ; i < l; i++ ) {
  3914. dataPriv.set(
  3915. elems[ i ],
  3916. "globalEval",
  3917. !refElements || dataPriv.get( refElements[ i ], "globalEval" )
  3918. );
  3919. }
  3920. }
  3921. var rhtml = /<|&#?\w+;/;
  3922. function buildFragment( elems, context, scripts, selection, ignored ) {
  3923. var elem, tmp, tag, wrap, attached, j,
  3924. fragment = context.createDocumentFragment(),
  3925. nodes = [],
  3926. i = 0,
  3927. l = elems.length;
  3928. for ( ; i < l; i++ ) {
  3929. elem = elems[ i ];
  3930. if ( elem || elem === 0 ) {
  3931. // Add nodes directly
  3932. if ( toType( elem ) === "object" ) {
  3933. // Support: Android <=4.0 only, PhantomJS 1 only
  3934. // push.apply(_, arraylike) throws on ancient WebKit
  3935. jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
  3936. // Convert non-html into a text node
  3937. } else if ( !rhtml.test( elem ) ) {
  3938. nodes.push( context.createTextNode( elem ) );
  3939. // Convert html into DOM nodes
  3940. } else {
  3941. tmp = tmp || fragment.appendChild( context.createElement( "div" ) );
  3942. // Deserialize a standard representation
  3943. tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
  3944. wrap = wrapMap[ tag ] || wrapMap._default;
  3945. tmp.innerHTML = wrap[ 1 ] + jQuery.htmlPrefilter( elem ) + wrap[ 2 ];
  3946. // Descend through wrappers to the right content
  3947. j = wrap[ 0 ];
  3948. while ( j-- ) {
  3949. tmp = tmp.lastChild;
  3950. }
  3951. // Support: Android <=4.0 only, PhantomJS 1 only
  3952. // push.apply(_, arraylike) throws on ancient WebKit
  3953. jQuery.merge( nodes, tmp.childNodes );
  3954. // Remember the top-level container
  3955. tmp = fragment.firstChild;
  3956. // Ensure the created nodes are orphaned (#12392)
  3957. tmp.textContent = "";
  3958. }
  3959. }
  3960. }
  3961. // Remove wrapper from fragment
  3962. fragment.textContent = "";
  3963. i = 0;
  3964. while ( ( elem = nodes[ i++ ] ) ) {
  3965. // Skip elements already in the context collection (trac-4087)
  3966. if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
  3967. if ( ignored ) {
  3968. ignored.push( elem );
  3969. }
  3970. continue;
  3971. }
  3972. attached = isAttached( elem );
  3973. // Append to fragment
  3974. tmp = getAll( fragment.appendChild( elem ), "script" );
  3975. // Preserve script evaluation history
  3976. if ( attached ) {
  3977. setGlobalEval( tmp );
  3978. }
  3979. // Capture executables
  3980. if ( scripts ) {
  3981. j = 0;
  3982. while ( ( elem = tmp[ j++ ] ) ) {
  3983. if ( rscriptType.test( elem.type || "" ) ) {
  3984. scripts.push( elem );
  3985. }
  3986. }
  3987. }
  3988. }
  3989. return fragment;
  3990. }
  3991. ( function() {
  3992. var fragment = document.createDocumentFragment(),
  3993. div = fragment.appendChild( document.createElement( "div" ) ),
  3994. input = document.createElement( "input" );
  3995. // Support: Android 4.0 - 4.3 only
  3996. // Check state lost if the name is set (#11217)
  3997. // Support: Windows Web Apps (WWA)
  3998. // `name` and `type` must use .setAttribute for WWA (#14901)
  3999. input.setAttribute( "type", "radio" );
  4000. input.setAttribute( "checked", "checked" );
  4001. input.setAttribute( "name", "t" );
  4002. div.appendChild( input );
  4003. // Support: Android <=4.1 only
  4004. // Older WebKit doesn't clone checked state correctly in fragments
  4005. support.checkClone = div.cloneNode( true ).cloneNode( true ).lastChild.checked;
  4006. // Support: IE <=11 only
  4007. // Make sure textarea (and checkbox) defaultValue is properly cloned
  4008. div.innerHTML = "<textarea>x</textarea>";
  4009. support.noCloneChecked = !!div.cloneNode( true ).lastChild.defaultValue;
  4010. } )();
  4011. var
  4012. rkeyEvent = /^key/,
  4013. rmouseEvent = /^(?:mouse|pointer|contextmenu|drag|drop)|click/,
  4014. rtypenamespace = /^([^.]*)(?:\.(.+)|)/;
  4015. function returnTrue() {
  4016. return true;
  4017. }
  4018. function returnFalse() {
  4019. return false;
  4020. }
  4021. // Support: IE <=9 - 11+
  4022. // focus() and blur() are asynchronous, except when they are no-op.
  4023. // So expect focus to be synchronous when the element is already active,
  4024. // and blur to be synchronous when the element is not already active.
  4025. // (focus and blur are always synchronous in other supported browsers,
  4026. // this just defines when we can count on it).
  4027. function expectSync( elem, type ) {
  4028. return ( elem === safeActiveElement() ) === ( type === "focus" );
  4029. }
  4030. // Support: IE <=9 only
  4031. // Accessing document.activeElement can throw unexpectedly
  4032. // https://bugs.jquery.com/ticket/13393
  4033. function safeActiveElement() {
  4034. try {
  4035. return document.activeElement;
  4036. } catch ( err ) { }
  4037. }
  4038. function on( elem, types, selector, data, fn, one ) {
  4039. var origFn, type;
  4040. // Types can be a map of types/handlers
  4041. if ( typeof types === "object" ) {
  4042. // ( types-Object, selector, data )
  4043. if ( typeof selector !== "string" ) {
  4044. // ( types-Object, data )
  4045. data = data || selector;
  4046. selector = undefined;
  4047. }
  4048. for ( type in types ) {
  4049. on( elem, type, selector, data, types[ type ], one );
  4050. }
  4051. return elem;
  4052. }
  4053. if ( data == null && fn == null ) {
  4054. // ( types, fn )
  4055. fn = selector;
  4056. data = selector = undefined;
  4057. } else if ( fn == null ) {
  4058. if ( typeof selector === "string" ) {
  4059. // ( types, selector, fn )
  4060. fn = data;
  4061. data = undefined;
  4062. } else {
  4063. // ( types, data, fn )
  4064. fn = data;
  4065. data = selector;
  4066. selector = undefined;
  4067. }
  4068. }
  4069. if ( fn === false ) {
  4070. fn = returnFalse;
  4071. } else if ( !fn ) {
  4072. return elem;
  4073. }
  4074. if ( one === 1 ) {
  4075. origFn = fn;
  4076. fn = function( event ) {
  4077. // Can use an empty set, since event contains the info
  4078. jQuery().off( event );
  4079. return origFn.apply( this, arguments );
  4080. };
  4081. // Use same guid so caller can remove using origFn
  4082. fn.guid = origFn.guid || ( origFn.guid = jQuery.guid++ );
  4083. }
  4084. return elem.each( function() {
  4085. jQuery.event.add( this, types, fn, data, selector );
  4086. } );
  4087. }
  4088. /*
  4089. * Helper functions for managing events -- not part of the public interface.
  4090. * Props to Dean Edwards' addEvent library for many of the ideas.
  4091. */
  4092. jQuery.event = {
  4093. global: {},
  4094. add: function( elem, types, handler, data, selector ) {
  4095. var handleObjIn, eventHandle, tmp,
  4096. events, t, handleObj,
  4097. special, handlers, type, namespaces, origType,
  4098. elemData = dataPriv.get( elem );
  4099. // Don't attach events to noData or text/comment nodes (but allow plain objects)
  4100. if ( !elemData ) {
  4101. return;
  4102. }
  4103. // Caller can pass in an object of custom data in lieu of the handler
  4104. if ( handler.handler ) {
  4105. handleObjIn = handler;
  4106. handler = handleObjIn.handler;
  4107. selector = handleObjIn.selector;
  4108. }
  4109. // Ensure that invalid selectors throw exceptions at attach time
  4110. // Evaluate against documentElement in case elem is a non-element node (e.g., document)
  4111. if ( selector ) {
  4112. jQuery.find.matchesSelector( documentElement, selector );
  4113. }
  4114. // Make sure that the handler has a unique ID, used to find/remove it later
  4115. if ( !handler.guid ) {
  4116. handler.guid = jQuery.guid++;
  4117. }
  4118. // Init the element's event structure and main handler, if this is the first
  4119. if ( !( events = elemData.events ) ) {
  4120. events = elemData.events = {};
  4121. }
  4122. if ( !( eventHandle = elemData.handle ) ) {
  4123. eventHandle = elemData.handle = function( e ) {
  4124. // Discard the second event of a jQuery.event.trigger() and
  4125. // when an event is called after a page has unloaded
  4126. return typeof jQuery !== "undefined" && jQuery.event.triggered !== e.type ?
  4127. jQuery.event.dispatch.apply( elem, arguments ) : undefined;
  4128. };
  4129. }
  4130. // Handle multiple events separated by a space
  4131. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  4132. t = types.length;
  4133. while ( t-- ) {
  4134. tmp = rtypenamespace.exec( types[ t ] ) || [];
  4135. type = origType = tmp[ 1 ];
  4136. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  4137. // There *must* be a type, no attaching namespace-only handlers
  4138. if ( !type ) {
  4139. continue;
  4140. }
  4141. // If event changes its type, use the special event handlers for the changed type
  4142. special = jQuery.event.special[ type ] || {};
  4143. // If selector defined, determine special event api type, otherwise given type
  4144. type = ( selector ? special.delegateType : special.bindType ) || type;
  4145. // Update special based on newly reset type
  4146. special = jQuery.event.special[ type ] || {};
  4147. // handleObj is passed to all event handlers
  4148. handleObj = jQuery.extend( {
  4149. type: type,
  4150. origType: origType,
  4151. data: data,
  4152. handler: handler,
  4153. guid: handler.guid,
  4154. selector: selector,
  4155. needsContext: selector && jQuery.expr.match.needsContext.test( selector ),
  4156. namespace: namespaces.join( "." )
  4157. }, handleObjIn );
  4158. // Init the event handler queue if we're the first
  4159. if ( !( handlers = events[ type ] ) ) {
  4160. handlers = events[ type ] = [];
  4161. handlers.delegateCount = 0;
  4162. // Only use addEventListener if the special events handler returns false
  4163. if ( !special.setup ||
  4164. special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
  4165. if ( elem.addEventListener ) {
  4166. elem.addEventListener( type, eventHandle );
  4167. }
  4168. }
  4169. }
  4170. if ( special.add ) {
  4171. special.add.call( elem, handleObj );
  4172. if ( !handleObj.handler.guid ) {
  4173. handleObj.handler.guid = handler.guid;
  4174. }
  4175. }
  4176. // Add to the element's handler list, delegates in front
  4177. if ( selector ) {
  4178. handlers.splice( handlers.delegateCount++, 0, handleObj );
  4179. } else {
  4180. handlers.push( handleObj );
  4181. }
  4182. // Keep track of which events have ever been used, for event optimization
  4183. jQuery.event.global[ type ] = true;
  4184. }
  4185. },
  4186. // Detach an event or set of events from an element
  4187. remove: function( elem, types, handler, selector, mappedTypes ) {
  4188. var j, origCount, tmp,
  4189. events, t, handleObj,
  4190. special, handlers, type, namespaces, origType,
  4191. elemData = dataPriv.hasData( elem ) && dataPriv.get( elem );
  4192. if ( !elemData || !( events = elemData.events ) ) {
  4193. return;
  4194. }
  4195. // Once for each type.namespace in types; type may be omitted
  4196. types = ( types || "" ).match( rnothtmlwhite ) || [ "" ];
  4197. t = types.length;
  4198. while ( t-- ) {
  4199. tmp = rtypenamespace.exec( types[ t ] ) || [];
  4200. type = origType = tmp[ 1 ];
  4201. namespaces = ( tmp[ 2 ] || "" ).split( "." ).sort();
  4202. // Unbind all events (on this namespace, if provided) for the element
  4203. if ( !type ) {
  4204. for ( type in events ) {
  4205. jQuery.event.remove( elem, type + types[ t ], handler, selector, true );
  4206. }
  4207. continue;
  4208. }
  4209. special = jQuery.event.special[ type ] || {};
  4210. type = ( selector ? special.delegateType : special.bindType ) || type;
  4211. handlers = events[ type ] || [];
  4212. tmp = tmp[ 2 ] &&
  4213. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" );
  4214. // Remove matching events
  4215. origCount = j = handlers.length;
  4216. while ( j-- ) {
  4217. handleObj = handlers[ j ];
  4218. if ( ( mappedTypes || origType === handleObj.origType ) &&
  4219. ( !handler || handler.guid === handleObj.guid ) &&
  4220. ( !tmp || tmp.test( handleObj.namespace ) ) &&
  4221. ( !selector || selector === handleObj.selector ||
  4222. selector === "**" && handleObj.selector ) ) {
  4223. handlers.splice( j, 1 );
  4224. if ( handleObj.selector ) {
  4225. handlers.delegateCount--;
  4226. }
  4227. if ( special.remove ) {
  4228. special.remove.call( elem, handleObj );
  4229. }
  4230. }
  4231. }
  4232. // Remove generic event handler if we removed something and no more handlers exist
  4233. // (avoids potential for endless recursion during removal of special event handlers)
  4234. if ( origCount && !handlers.length ) {
  4235. if ( !special.teardown ||
  4236. special.teardown.call( elem, namespaces, elemData.handle ) === false ) {
  4237. jQuery.removeEvent( elem, type, elemData.handle );
  4238. }
  4239. delete events[ type ];
  4240. }
  4241. }
  4242. // Remove data and the expando if it's no longer used
  4243. if ( jQuery.isEmptyObject( events ) ) {
  4244. dataPriv.remove( elem, "handle events" );
  4245. }
  4246. },
  4247. dispatch: function( nativeEvent ) {
  4248. // Make a writable jQuery.Event from the native event object
  4249. var event = jQuery.event.fix( nativeEvent );
  4250. var i, j, ret, matched, handleObj, handlerQueue,
  4251. args = new Array( arguments.length ),
  4252. handlers = ( dataPriv.get( this, "events" ) || {} )[ event.type ] || [],
  4253. special = jQuery.event.special[ event.type ] || {};
  4254. // Use the fix-ed jQuery.Event rather than the (read-only) native event
  4255. args[ 0 ] = event;
  4256. for ( i = 1; i < arguments.length; i++ ) {
  4257. args[ i ] = arguments[ i ];
  4258. }
  4259. event.delegateTarget = this;
  4260. // Call the preDispatch hook for the mapped type, and let it bail if desired
  4261. if ( special.preDispatch && special.preDispatch.call( this, event ) === false ) {
  4262. return;
  4263. }
  4264. // Determine handlers
  4265. handlerQueue = jQuery.event.handlers.call( this, event, handlers );
  4266. // Run delegates first; they may want to stop propagation beneath us
  4267. i = 0;
  4268. while ( ( matched = handlerQueue[ i++ ] ) && !event.isPropagationStopped() ) {
  4269. event.currentTarget = matched.elem;
  4270. j = 0;
  4271. while ( ( handleObj = matched.handlers[ j++ ] ) &&
  4272. !event.isImmediatePropagationStopped() ) {
  4273. // If the event is namespaced, then each handler is only invoked if it is
  4274. // specially universal or its namespaces are a superset of the event's.
  4275. if ( !event.rnamespace || handleObj.namespace === false ||
  4276. event.rnamespace.test( handleObj.namespace ) ) {
  4277. event.handleObj = handleObj;
  4278. event.data = handleObj.data;
  4279. ret = ( ( jQuery.event.special[ handleObj.origType ] || {} ).handle ||
  4280. handleObj.handler ).apply( matched.elem, args );
  4281. if ( ret !== undefined ) {
  4282. if ( ( event.result = ret ) === false ) {
  4283. event.preventDefault();
  4284. event.stopPropagation();
  4285. }
  4286. }
  4287. }
  4288. }
  4289. }
  4290. // Call the postDispatch hook for the mapped type
  4291. if ( special.postDispatch ) {
  4292. special.postDispatch.call( this, event );
  4293. }
  4294. return event.result;
  4295. },
  4296. handlers: function( event, handlers ) {
  4297. var i, handleObj, sel, matchedHandlers, matchedSelectors,
  4298. handlerQueue = [],
  4299. delegateCount = handlers.delegateCount,
  4300. cur = event.target;
  4301. // Find delegate handlers
  4302. if ( delegateCount &&
  4303. // Support: IE <=9
  4304. // Black-hole SVG <use> instance trees (trac-13180)
  4305. cur.nodeType &&
  4306. // Support: Firefox <=42
  4307. // Suppress spec-violating clicks indicating a non-primary pointer button (trac-3861)
  4308. // https://www.w3.org/TR/DOM-Level-3-Events/#event-type-click
  4309. // Support: IE 11 only
  4310. // ...but not arrow key "clicks" of radio inputs, which can have `button` -1 (gh-2343)
  4311. !( event.type === "click" && event.button >= 1 ) ) {
  4312. for ( ; cur !== this; cur = cur.parentNode || this ) {
  4313. // Don't check non-elements (#13208)
  4314. // Don't process clicks on disabled elements (#6911, #8165, #11382, #11764)
  4315. if ( cur.nodeType === 1 && !( event.type === "click" && cur.disabled === true ) ) {
  4316. matchedHandlers = [];
  4317. matchedSelectors = {};
  4318. for ( i = 0; i < delegateCount; i++ ) {
  4319. handleObj = handlers[ i ];
  4320. // Don't conflict with Object.prototype properties (#13203)
  4321. sel = handleObj.selector + " ";
  4322. if ( matchedSelectors[ sel ] === undefined ) {
  4323. matchedSelectors[ sel ] = handleObj.needsContext ?
  4324. jQuery( sel, this ).index( cur ) > -1 :
  4325. jQuery.find( sel, this, null, [ cur ] ).length;
  4326. }
  4327. if ( matchedSelectors[ sel ] ) {
  4328. matchedHandlers.push( handleObj );
  4329. }
  4330. }
  4331. if ( matchedHandlers.length ) {
  4332. handlerQueue.push( { elem: cur, handlers: matchedHandlers } );
  4333. }
  4334. }
  4335. }
  4336. }
  4337. // Add the remaining (directly-bound) handlers
  4338. cur = this;
  4339. if ( delegateCount < handlers.length ) {
  4340. handlerQueue.push( { elem: cur, handlers: handlers.slice( delegateCount ) } );
  4341. }
  4342. return handlerQueue;
  4343. },
  4344. addProp: function( name, hook ) {
  4345. Object.defineProperty( jQuery.Event.prototype, name, {
  4346. enumerable: true,
  4347. configurable: true,
  4348. get: isFunction( hook ) ?
  4349. function() {
  4350. if ( this.originalEvent ) {
  4351. return hook( this.originalEvent );
  4352. }
  4353. } :
  4354. function() {
  4355. if ( this.originalEvent ) {
  4356. return this.originalEvent[ name ];
  4357. }
  4358. },
  4359. set: function( value ) {
  4360. Object.defineProperty( this, name, {
  4361. enumerable: true,
  4362. configurable: true,
  4363. writable: true,
  4364. value: value
  4365. } );
  4366. }
  4367. } );
  4368. },
  4369. fix: function( originalEvent ) {
  4370. return originalEvent[ jQuery.expando ] ?
  4371. originalEvent :
  4372. new jQuery.Event( originalEvent );
  4373. },
  4374. special: {
  4375. load: {
  4376. // Prevent triggered image.load events from bubbling to window.load
  4377. noBubble: true
  4378. },
  4379. click: {
  4380. // Utilize native event to ensure correct state for checkable inputs
  4381. setup: function( data ) {
  4382. // For mutual compressibility with _default, replace `this` access with a local var.
  4383. // `|| data` is dead code meant only to preserve the variable through minification.
  4384. var el = this || data;
  4385. // Claim the first handler
  4386. if ( rcheckableType.test( el.type ) &&
  4387. el.click && nodeName( el, "input" ) ) {
  4388. // dataPriv.set( el, "click", ... )
  4389. leverageNative( el, "click", returnTrue );
  4390. }
  4391. // Return false to allow normal processing in the caller
  4392. return false;
  4393. },
  4394. trigger: function( data ) {
  4395. // For mutual compressibility with _default, replace `this` access with a local var.
  4396. // `|| data` is dead code meant only to preserve the variable through minification.
  4397. var el = this || data;
  4398. // Force setup before triggering a click
  4399. if ( rcheckableType.test( el.type ) &&
  4400. el.click && nodeName( el, "input" ) ) {
  4401. leverageNative( el, "click" );
  4402. }
  4403. // Return non-false to allow normal event-path propagation
  4404. return true;
  4405. },
  4406. // For cross-browser consistency, suppress native .click() on links
  4407. // Also prevent it if we're currently inside a leveraged native-event stack
  4408. _default: function( event ) {
  4409. var target = event.target;
  4410. return rcheckableType.test( target.type ) &&
  4411. target.click && nodeName( target, "input" ) &&
  4412. dataPriv.get( target, "click" ) ||
  4413. nodeName( target, "a" );
  4414. }
  4415. },
  4416. beforeunload: {
  4417. postDispatch: function( event ) {
  4418. // Support: Firefox 20+
  4419. // Firefox doesn't alert if the returnValue field is not set.
  4420. if ( event.result !== undefined && event.originalEvent ) {
  4421. event.originalEvent.returnValue = event.result;
  4422. }
  4423. }
  4424. }
  4425. }
  4426. };
  4427. // Ensure the presence of an event listener that handles manually-triggered
  4428. // synthetic events by interrupting progress until reinvoked in response to
  4429. // *native* events that it fires directly, ensuring that state changes have
  4430. // already occurred before other listeners are invoked.
  4431. function leverageNative( el, type, expectSync ) {
  4432. // Missing expectSync indicates a trigger call, which must force setup through jQuery.event.add
  4433. if ( !expectSync ) {
  4434. if ( dataPriv.get( el, type ) === undefined ) {
  4435. jQuery.event.add( el, type, returnTrue );
  4436. }
  4437. return;
  4438. }
  4439. // Register the controller as a special universal handler for all event namespaces
  4440. dataPriv.set( el, type, false );
  4441. jQuery.event.add( el, type, {
  4442. namespace: false,
  4443. handler: function( event ) {
  4444. var notAsync, result,
  4445. saved = dataPriv.get( this, type );
  4446. if ( ( event.isTrigger & 1 ) && this[ type ] ) {
  4447. // Interrupt processing of the outer synthetic .trigger()ed event
  4448. // Saved data should be false in such cases, but might be a leftover capture object
  4449. // from an async native handler (gh-4350)
  4450. if ( !saved.length ) {
  4451. // Store arguments for use when handling the inner native event
  4452. // There will always be at least one argument (an event object), so this array
  4453. // will not be confused with a leftover capture object.
  4454. saved = slice.call( arguments );
  4455. dataPriv.set( this, type, saved );
  4456. // Trigger the native event and capture its result
  4457. // Support: IE <=9 - 11+
  4458. // focus() and blur() are asynchronous
  4459. notAsync = expectSync( this, type );
  4460. this[ type ]();
  4461. result = dataPriv.get( this, type );
  4462. if ( saved !== result || notAsync ) {
  4463. dataPriv.set( this, type, false );
  4464. } else {
  4465. result = {};
  4466. }
  4467. if ( saved !== result ) {
  4468. // Cancel the outer synthetic event
  4469. event.stopImmediatePropagation();
  4470. event.preventDefault();
  4471. return result.value;
  4472. }
  4473. // If this is an inner synthetic event for an event with a bubbling surrogate
  4474. // (focus or blur), assume that the surrogate already propagated from triggering the
  4475. // native event and prevent that from happening again here.
  4476. // This technically gets the ordering wrong w.r.t. to `.trigger()` (in which the
  4477. // bubbling surrogate propagates *after* the non-bubbling base), but that seems
  4478. // less bad than duplication.
  4479. } else if ( ( jQuery.event.special[ type ] || {} ).delegateType ) {
  4480. event.stopPropagation();
  4481. }
  4482. // If this is a native event triggered above, everything is now in order
  4483. // Fire an inner synthetic event with the original arguments
  4484. } else if ( saved.length ) {
  4485. // ...and capture the result
  4486. dataPriv.set( this, type, {
  4487. value: jQuery.event.trigger(
  4488. // Support: IE <=9 - 11+
  4489. // Extend with the prototype to reset the above stopImmediatePropagation()
  4490. jQuery.extend( saved[ 0 ], jQuery.Event.prototype ),
  4491. saved.slice( 1 ),
  4492. this
  4493. )
  4494. } );
  4495. // Abort handling of the native event
  4496. event.stopImmediatePropagation();
  4497. }
  4498. }
  4499. } );
  4500. }
  4501. jQuery.removeEvent = function( elem, type, handle ) {
  4502. // This "if" is needed for plain objects
  4503. if ( elem.removeEventListener ) {
  4504. elem.removeEventListener( type, handle );
  4505. }
  4506. };
  4507. jQuery.Event = function( src, props ) {
  4508. // Allow instantiation without the 'new' keyword
  4509. if ( !( this instanceof jQuery.Event ) ) {
  4510. return new jQuery.Event( src, props );
  4511. }
  4512. // Event object
  4513. if ( src && src.type ) {
  4514. this.originalEvent = src;
  4515. this.type = src.type;
  4516. // Events bubbling up the document may have been marked as prevented
  4517. // by a handler lower down the tree; reflect the correct value.
  4518. this.isDefaultPrevented = src.defaultPrevented ||
  4519. src.defaultPrevented === undefined &&
  4520. // Support: Android <=2.3 only
  4521. src.returnValue === false ?
  4522. returnTrue :
  4523. returnFalse;
  4524. // Create target properties
  4525. // Support: Safari <=6 - 7 only
  4526. // Target should not be a text node (#504, #13143)
  4527. this.target = ( src.target && src.target.nodeType === 3 ) ?
  4528. src.target.parentNode :
  4529. src.target;
  4530. this.currentTarget = src.currentTarget;
  4531. this.relatedTarget = src.relatedTarget;
  4532. // Event type
  4533. } else {
  4534. this.type = src;
  4535. }
  4536. // Put explicitly provided properties onto the event object
  4537. if ( props ) {
  4538. jQuery.extend( this, props );
  4539. }
  4540. // Create a timestamp if incoming event doesn't have one
  4541. this.timeStamp = src && src.timeStamp || Date.now();
  4542. // Mark it as fixed
  4543. this[ jQuery.expando ] = true;
  4544. };
  4545. // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
  4546. // https://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
  4547. jQuery.Event.prototype = {
  4548. constructor: jQuery.Event,
  4549. isDefaultPrevented: returnFalse,
  4550. isPropagationStopped: returnFalse,
  4551. isImmediatePropagationStopped: returnFalse,
  4552. isSimulated: false,
  4553. preventDefault: function() {
  4554. var e = this.originalEvent;
  4555. this.isDefaultPrevented = returnTrue;
  4556. if ( e && !this.isSimulated ) {
  4557. e.preventDefault();
  4558. }
  4559. },
  4560. stopPropagation: function() {
  4561. var e = this.originalEvent;
  4562. this.isPropagationStopped = returnTrue;
  4563. if ( e && !this.isSimulated ) {
  4564. e.stopPropagation();
  4565. }
  4566. },
  4567. stopImmediatePropagation: function() {
  4568. var e = this.originalEvent;
  4569. this.isImmediatePropagationStopped = returnTrue;
  4570. if ( e && !this.isSimulated ) {
  4571. e.stopImmediatePropagation();
  4572. }
  4573. this.stopPropagation();
  4574. }
  4575. };
  4576. // Includes all common event props including KeyEvent and MouseEvent specific props
  4577. jQuery.each( {
  4578. altKey: true,
  4579. bubbles: true,
  4580. cancelable: true,
  4581. changedTouches: true,
  4582. ctrlKey: true,
  4583. detail: true,
  4584. eventPhase: true,
  4585. metaKey: true,
  4586. pageX: true,
  4587. pageY: true,
  4588. shiftKey: true,
  4589. view: true,
  4590. "char": true,
  4591. code: true,
  4592. charCode: true,
  4593. key: true,
  4594. keyCode: true,
  4595. button: true,
  4596. buttons: true,
  4597. clientX: true,
  4598. clientY: true,
  4599. offsetX: true,
  4600. offsetY: true,
  4601. pointerId: true,
  4602. pointerType: true,
  4603. screenX: true,
  4604. screenY: true,
  4605. targetTouches: true,
  4606. toElement: true,
  4607. touches: true,
  4608. which: function( event ) {
  4609. var button = event.button;
  4610. // Add which for key events
  4611. if ( event.which == null && rkeyEvent.test( event.type ) ) {
  4612. return event.charCode != null ? event.charCode : event.keyCode;
  4613. }
  4614. // Add which for click: 1 === left; 2 === middle; 3 === right
  4615. if ( !event.which && button !== undefined && rmouseEvent.test( event.type ) ) {
  4616. if ( button & 1 ) {
  4617. return 1;
  4618. }
  4619. if ( button & 2 ) {
  4620. return 3;
  4621. }
  4622. if ( button & 4 ) {
  4623. return 2;
  4624. }
  4625. return 0;
  4626. }
  4627. return event.which;
  4628. }
  4629. }, jQuery.event.addProp );
  4630. jQuery.each( { focus: "focusin", blur: "focusout" }, function( type, delegateType ) {
  4631. jQuery.event.special[ type ] = {
  4632. // Utilize native event if possible so blur/focus sequence is correct
  4633. setup: function() {
  4634. // Claim the first handler
  4635. // dataPriv.set( this, "focus", ... )
  4636. // dataPriv.set( this, "blur", ... )
  4637. leverageNative( this, type, expectSync );
  4638. // Return false to allow normal processing in the caller
  4639. return false;
  4640. },
  4641. trigger: function() {
  4642. // Force setup before trigger
  4643. leverageNative( this, type );
  4644. // Return non-false to allow normal event-path propagation
  4645. return true;
  4646. },
  4647. delegateType: delegateType
  4648. };
  4649. } );
  4650. // Create mouseenter/leave events using mouseover/out and event-time checks
  4651. // so that event delegation works in jQuery.
  4652. // Do the same for pointerenter/pointerleave and pointerover/pointerout
  4653. //
  4654. // Support: Safari 7 only
  4655. // Safari sends mouseenter too often; see:
  4656. // https://bugs.chromium.org/p/chromium/issues/detail?id=470258
  4657. // for the description of the bug (it existed in older Chrome versions as well).
  4658. jQuery.each( {
  4659. mouseenter: "mouseover",
  4660. mouseleave: "mouseout",
  4661. pointerenter: "pointerover",
  4662. pointerleave: "pointerout"
  4663. }, function( orig, fix ) {
  4664. jQuery.event.special[ orig ] = {
  4665. delegateType: fix,
  4666. bindType: fix,
  4667. handle: function( event ) {
  4668. var ret,
  4669. target = this,
  4670. related = event.relatedTarget,
  4671. handleObj = event.handleObj;
  4672. // For mouseenter/leave call the handler if related is outside the target.
  4673. // NB: No relatedTarget if the mouse left/entered the browser window
  4674. if ( !related || ( related !== target && !jQuery.contains( target, related ) ) ) {
  4675. event.type = handleObj.origType;
  4676. ret = handleObj.handler.apply( this, arguments );
  4677. event.type = fix;
  4678. }
  4679. return ret;
  4680. }
  4681. };
  4682. } );
  4683. jQuery.fn.extend( {
  4684. on: function( types, selector, data, fn ) {
  4685. return on( this, types, selector, data, fn );
  4686. },
  4687. one: function( types, selector, data, fn ) {
  4688. return on( this, types, selector, data, fn, 1 );
  4689. },
  4690. off: function( types, selector, fn ) {
  4691. var handleObj, type;
  4692. if ( types && types.preventDefault && types.handleObj ) {
  4693. // ( event ) dispatched jQuery.Event
  4694. handleObj = types.handleObj;
  4695. jQuery( types.delegateTarget ).off(
  4696. handleObj.namespace ?
  4697. handleObj.origType + "." + handleObj.namespace :
  4698. handleObj.origType,
  4699. handleObj.selector,
  4700. handleObj.handler
  4701. );
  4702. return this;
  4703. }
  4704. if ( typeof types === "object" ) {
  4705. // ( types-object [, selector] )
  4706. for ( type in types ) {
  4707. this.off( type, selector, types[ type ] );
  4708. }
  4709. return this;
  4710. }
  4711. if ( selector === false || typeof selector === "function" ) {
  4712. // ( types [, fn] )
  4713. fn = selector;
  4714. selector = undefined;
  4715. }
  4716. if ( fn === false ) {
  4717. fn = returnFalse;
  4718. }
  4719. return this.each( function() {
  4720. jQuery.event.remove( this, types, fn, selector );
  4721. } );
  4722. }
  4723. } );
  4724. var
  4725. /* eslint-disable max-len */
  4726. // See https://github.com/eslint/eslint/issues/3229
  4727. rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi,
  4728. /* eslint-enable */
  4729. // Support: IE <=10 - 11, Edge 12 - 13 only
  4730. // In IE/Edge using regex groups here causes severe slowdowns.
  4731. // See https://connect.microsoft.com/IE/feedback/details/1736512/
  4732. rnoInnerhtml = /<script|<style|<link/i,
  4733. // checked="checked" or checked
  4734. rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
  4735. rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g;
  4736. // Prefer a tbody over its parent table for containing new rows
  4737. function manipulationTarget( elem, content ) {
  4738. if ( nodeName( elem, "table" ) &&
  4739. nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
  4740. return jQuery( elem ).children( "tbody" )[ 0 ] || elem;
  4741. }
  4742. return elem;
  4743. }
  4744. // Replace/restore the type attribute of script elements for safe DOM manipulation
  4745. function disableScript( elem ) {
  4746. elem.type = ( elem.getAttribute( "type" ) !== null ) + "/" + elem.type;
  4747. return elem;
  4748. }
  4749. function restoreScript( elem ) {
  4750. if ( ( elem.type || "" ).slice( 0, 5 ) === "true/" ) {
  4751. elem.type = elem.type.slice( 5 );
  4752. } else {
  4753. elem.removeAttribute( "type" );
  4754. }
  4755. return elem;
  4756. }
  4757. function cloneCopyEvent( src, dest ) {
  4758. var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
  4759. if ( dest.nodeType !== 1 ) {
  4760. return;
  4761. }
  4762. // 1. Copy private data: events, handlers, etc.
  4763. if ( dataPriv.hasData( src ) ) {
  4764. pdataOld = dataPriv.access( src );
  4765. pdataCur = dataPriv.set( dest, pdataOld );
  4766. events = pdataOld.events;
  4767. if ( events ) {
  4768. delete pdataCur.handle;
  4769. pdataCur.events = {};
  4770. for ( type in events ) {
  4771. for ( i = 0, l = events[ type ].length; i < l; i++ ) {
  4772. jQuery.event.add( dest, type, events[ type ][ i ] );
  4773. }
  4774. }
  4775. }
  4776. }
  4777. // 2. Copy user data
  4778. if ( dataUser.hasData( src ) ) {
  4779. udataOld = dataUser.access( src );
  4780. udataCur = jQuery.extend( {}, udataOld );
  4781. dataUser.set( dest, udataCur );
  4782. }
  4783. }
  4784. // Fix IE bugs, see support tests
  4785. function fixInput( src, dest ) {
  4786. var nodeName = dest.nodeName.toLowerCase();
  4787. // Fails to persist the checked state of a cloned checkbox or radio button.
  4788. if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
  4789. dest.checked = src.checked;
  4790. // Fails to return the selected option to the default selected state when cloning options
  4791. } else if ( nodeName === "input" || nodeName === "textarea" ) {
  4792. dest.defaultValue = src.defaultValue;
  4793. }
  4794. }
  4795. function domManip( collection, args, callback, ignored ) {
  4796. // Flatten any nested arrays
  4797. args = concat.apply( [], args );
  4798. var fragment, first, scripts, hasScripts, node, doc,
  4799. i = 0,
  4800. l = collection.length,
  4801. iNoClone = l - 1,
  4802. value = args[ 0 ],
  4803. valueIsFunction = isFunction( value );
  4804. // We can't cloneNode fragments that contain checked, in WebKit
  4805. if ( valueIsFunction ||
  4806. ( l > 1 && typeof value === "string" &&
  4807. !support.checkClone && rchecked.test( value ) ) ) {
  4808. return collection.each( function( index ) {
  4809. var self = collection.eq( index );
  4810. if ( valueIsFunction ) {
  4811. args[ 0 ] = value.call( this, index, self.html() );
  4812. }
  4813. domManip( self, args, callback, ignored );
  4814. } );
  4815. }
  4816. if ( l ) {
  4817. fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored );
  4818. first = fragment.firstChild;
  4819. if ( fragment.childNodes.length === 1 ) {
  4820. fragment = first;
  4821. }
  4822. // Require either new content or an interest in ignored elements to invoke the callback
  4823. if ( first || ignored ) {
  4824. scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
  4825. hasScripts = scripts.length;
  4826. // Use the original fragment for the last item
  4827. // instead of the first because it can end up
  4828. // being emptied incorrectly in certain situations (#8070).
  4829. for ( ; i < l; i++ ) {
  4830. node = fragment;
  4831. if ( i !== iNoClone ) {
  4832. node = jQuery.clone( node, true, true );
  4833. // Keep references to cloned scripts for later restoration
  4834. if ( hasScripts ) {
  4835. // Support: Android <=4.0 only, PhantomJS 1 only
  4836. // push.apply(_, arraylike) throws on ancient WebKit
  4837. jQuery.merge( scripts, getAll( node, "script" ) );
  4838. }
  4839. }
  4840. callback.call( collection[ i ], node, i );
  4841. }
  4842. if ( hasScripts ) {
  4843. doc = scripts[ scripts.length - 1 ].ownerDocument;
  4844. // Reenable scripts
  4845. jQuery.map( scripts, restoreScript );
  4846. // Evaluate executable scripts on first document insertion
  4847. for ( i = 0; i < hasScripts; i++ ) {
  4848. node = scripts[ i ];
  4849. if ( rscriptType.test( node.type || "" ) &&
  4850. !dataPriv.access( node, "globalEval" ) &&
  4851. jQuery.contains( doc, node ) ) {
  4852. if ( node.src && ( node.type || "" ).toLowerCase() !== "module" ) {
  4853. // Optional AJAX dependency, but won't run scripts if not present
  4854. if ( jQuery._evalUrl && !node.noModule ) {
  4855. jQuery._evalUrl( node.src, {
  4856. nonce: node.nonce || node.getAttribute( "nonce" )
  4857. } );
  4858. }
  4859. } else {
  4860. DOMEval( node.textContent.replace( rcleanScript, "" ), node, doc );
  4861. }
  4862. }
  4863. }
  4864. }
  4865. }
  4866. }
  4867. return collection;
  4868. }
  4869. function remove( elem, selector, keepData ) {
  4870. var node,
  4871. nodes = selector ? jQuery.filter( selector, elem ) : elem,
  4872. i = 0;
  4873. for ( ; ( node = nodes[ i ] ) != null; i++ ) {
  4874. if ( !keepData && node.nodeType === 1 ) {
  4875. jQuery.cleanData( getAll( node ) );
  4876. }
  4877. if ( node.parentNode ) {
  4878. if ( keepData && isAttached( node ) ) {
  4879. setGlobalEval( getAll( node, "script" ) );
  4880. }
  4881. node.parentNode.removeChild( node );
  4882. }
  4883. }
  4884. return elem;
  4885. }
  4886. jQuery.extend( {
  4887. htmlPrefilter: function( html ) {
  4888. return html.replace( rxhtmlTag, "<$1></$2>" );
  4889. },
  4890. clone: function( elem, dataAndEvents, deepDataAndEvents ) {
  4891. var i, l, srcElements, destElements,
  4892. clone = elem.cloneNode( true ),
  4893. inPage = isAttached( elem );
  4894. // Fix IE cloning issues
  4895. if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
  4896. !jQuery.isXMLDoc( elem ) ) {
  4897. // We eschew Sizzle here for performance reasons: https://jsperf.com/getall-vs-sizzle/2
  4898. destElements = getAll( clone );
  4899. srcElements = getAll( elem );
  4900. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  4901. fixInput( srcElements[ i ], destElements[ i ] );
  4902. }
  4903. }
  4904. // Copy the events from the original to the clone
  4905. if ( dataAndEvents ) {
  4906. if ( deepDataAndEvents ) {
  4907. srcElements = srcElements || getAll( elem );
  4908. destElements = destElements || getAll( clone );
  4909. for ( i = 0, l = srcElements.length; i < l; i++ ) {
  4910. cloneCopyEvent( srcElements[ i ], destElements[ i ] );
  4911. }
  4912. } else {
  4913. cloneCopyEvent( elem, clone );
  4914. }
  4915. }
  4916. // Preserve script evaluation history
  4917. destElements = getAll( clone, "script" );
  4918. if ( destElements.length > 0 ) {
  4919. setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
  4920. }
  4921. // Return the cloned set
  4922. return clone;
  4923. },
  4924. cleanData: function( elems ) {
  4925. var data, elem, type,
  4926. special = jQuery.event.special,
  4927. i = 0;
  4928. for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) {
  4929. if ( acceptData( elem ) ) {
  4930. if ( ( data = elem[ dataPriv.expando ] ) ) {
  4931. if ( data.events ) {
  4932. for ( type in data.events ) {
  4933. if ( special[ type ] ) {
  4934. jQuery.event.remove( elem, type );
  4935. // This is a shortcut to avoid jQuery.event.remove's overhead
  4936. } else {
  4937. jQuery.removeEvent( elem, type, data.handle );
  4938. }
  4939. }
  4940. }
  4941. // Support: Chrome <=35 - 45+
  4942. // Assign undefined instead of using delete, see Data#remove
  4943. elem[ dataPriv.expando ] = undefined;
  4944. }
  4945. if ( elem[ dataUser.expando ] ) {
  4946. // Support: Chrome <=35 - 45+
  4947. // Assign undefined instead of using delete, see Data#remove
  4948. elem[ dataUser.expando ] = undefined;
  4949. }
  4950. }
  4951. }
  4952. }
  4953. } );
  4954. jQuery.fn.extend( {
  4955. detach: function( selector ) {
  4956. return remove( this, selector, true );
  4957. },
  4958. remove: function( selector ) {
  4959. return remove( this, selector );
  4960. },
  4961. text: function( value ) {
  4962. return access( this, function( value ) {
  4963. return value === undefined ?
  4964. jQuery.text( this ) :
  4965. this.empty().each( function() {
  4966. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4967. this.textContent = value;
  4968. }
  4969. } );
  4970. }, null, value, arguments.length );
  4971. },
  4972. append: function() {
  4973. return domManip( this, arguments, function( elem ) {
  4974. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4975. var target = manipulationTarget( this, elem );
  4976. target.appendChild( elem );
  4977. }
  4978. } );
  4979. },
  4980. prepend: function() {
  4981. return domManip( this, arguments, function( elem ) {
  4982. if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
  4983. var target = manipulationTarget( this, elem );
  4984. target.insertBefore( elem, target.firstChild );
  4985. }
  4986. } );
  4987. },
  4988. before: function() {
  4989. return domManip( this, arguments, function( elem ) {
  4990. if ( this.parentNode ) {
  4991. this.parentNode.insertBefore( elem, this );
  4992. }
  4993. } );
  4994. },
  4995. after: function() {
  4996. return domManip( this, arguments, function( elem ) {
  4997. if ( this.parentNode ) {
  4998. this.parentNode.insertBefore( elem, this.nextSibling );
  4999. }
  5000. } );
  5001. },
  5002. empty: function() {
  5003. var elem,
  5004. i = 0;
  5005. for ( ; ( elem = this[ i ] ) != null; i++ ) {
  5006. if ( elem.nodeType === 1 ) {
  5007. // Prevent memory leaks
  5008. jQuery.cleanData( getAll( elem, false ) );
  5009. // Remove any remaining nodes
  5010. elem.textContent = "";
  5011. }
  5012. }
  5013. return this;
  5014. },
  5015. clone: function( dataAndEvents, deepDataAndEvents ) {
  5016. dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
  5017. deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
  5018. return this.map( function() {
  5019. return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
  5020. } );
  5021. },
  5022. html: function( value ) {
  5023. return access( this, function( value ) {
  5024. var elem = this[ 0 ] || {},
  5025. i = 0,
  5026. l = this.length;
  5027. if ( value === undefined && elem.nodeType === 1 ) {
  5028. return elem.innerHTML;
  5029. }
  5030. // See if we can take a shortcut and just use innerHTML
  5031. if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
  5032. !wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
  5033. value = jQuery.htmlPrefilter( value );
  5034. try {
  5035. for ( ; i < l; i++ ) {
  5036. elem = this[ i ] || {};
  5037. // Remove element nodes and prevent memory leaks
  5038. if ( elem.nodeType === 1 ) {
  5039. jQuery.cleanData( getAll( elem, false ) );
  5040. elem.innerHTML = value;
  5041. }
  5042. }
  5043. elem = 0;
  5044. // If using innerHTML throws an exception, use the fallback method
  5045. } catch ( e ) {}
  5046. }
  5047. if ( elem ) {
  5048. this.empty().append( value );
  5049. }
  5050. }, null, value, arguments.length );
  5051. },
  5052. replaceWith: function() {
  5053. var ignored = [];
  5054. // Make the changes, replacing each non-ignored context element with the new content
  5055. return domManip( this, arguments, function( elem ) {
  5056. var parent = this.parentNode;
  5057. if ( jQuery.inArray( this, ignored ) < 0 ) {
  5058. jQuery.cleanData( getAll( this ) );
  5059. if ( parent ) {
  5060. parent.replaceChild( elem, this );
  5061. }
  5062. }
  5063. // Force callback invocation
  5064. }, ignored );
  5065. }
  5066. } );
  5067. jQuery.each( {
  5068. appendTo: "append",
  5069. prependTo: "prepend",
  5070. insertBefore: "before",
  5071. insertAfter: "after",
  5072. replaceAll: "replaceWith"
  5073. }, function( name, original ) {
  5074. jQuery.fn[ name ] = function( selector ) {
  5075. var elems,
  5076. ret = [],
  5077. insert = jQuery( selector ),
  5078. last = insert.length - 1,
  5079. i = 0;
  5080. for ( ; i <= last; i++ ) {
  5081. elems = i === last ? this : this.clone( true );
  5082. jQuery( insert[ i ] )[ original ]( elems );
  5083. // Support: Android <=4.0 only, PhantomJS 1 only
  5084. // .get() because push.apply(_, arraylike) throws on ancient WebKit
  5085. push.apply( ret, elems.get() );
  5086. }
  5087. return this.pushStack( ret );
  5088. };
  5089. } );
  5090. var rnumnonpx = new RegExp( "^(" + pnum + ")(?!px)[a-z%]+$", "i" );
  5091. var getStyles = function( elem ) {
  5092. // Support: IE <=11 only, Firefox <=30 (#15098, #14150)
  5093. // IE throws on elements created in popups
  5094. // FF meanwhile throws on frame elements through "defaultView.getComputedStyle"
  5095. var view = elem.ownerDocument.defaultView;
  5096. if ( !view || !view.opener ) {
  5097. view = window;
  5098. }
  5099. return view.getComputedStyle( elem );
  5100. };
  5101. var rboxStyle = new RegExp( cssExpand.join( "|" ), "i" );
  5102. ( function() {
  5103. // Executing both pixelPosition & boxSizingReliable tests require only one layout
  5104. // so they're executed at the same time to save the second computation.
  5105. function computeStyleTests() {
  5106. // This is a singleton, we need to execute it only once
  5107. if ( !div ) {
  5108. return;
  5109. }
  5110. container.style.cssText = "position:absolute;left:-11111px;width:60px;" +
  5111. "margin-top:1px;padding:0;border:0";
  5112. div.style.cssText =
  5113. "position:relative;display:block;box-sizing:border-box;overflow:scroll;" +
  5114. "margin:auto;border:1px;padding:1px;" +
  5115. "width:60%;top:1%";
  5116. documentElement.appendChild( container ).appendChild( div );
  5117. var divStyle = window.getComputedStyle( div );
  5118. pixelPositionVal = divStyle.top !== "1%";
  5119. // Support: Android 4.0 - 4.3 only, Firefox <=3 - 44
  5120. reliableMarginLeftVal = roundPixelMeasures( divStyle.marginLeft ) === 12;
  5121. // Support: Android 4.0 - 4.3 only, Safari <=9.1 - 10.1, iOS <=7.0 - 9.3
  5122. // Some styles come back with percentage values, even though they shouldn't
  5123. div.style.right = "60%";
  5124. pixelBoxStylesVal = roundPixelMeasures( divStyle.right ) === 36;
  5125. // Support: IE 9 - 11 only
  5126. // Detect misreporting of content dimensions for box-sizing:border-box elements
  5127. boxSizingReliableVal = roundPixelMeasures( divStyle.width ) === 36;
  5128. // Support: IE 9 only
  5129. // Detect overflow:scroll screwiness (gh-3699)
  5130. // Support: Chrome <=64
  5131. // Don't get tricked when zoom affects offsetWidth (gh-4029)
  5132. div.style.position = "absolute";
  5133. scrollboxSizeVal = roundPixelMeasures( div.offsetWidth / 3 ) === 12;
  5134. documentElement.removeChild( container );
  5135. // Nullify the div so it wouldn't be stored in the memory and
  5136. // it will also be a sign that checks already performed
  5137. div = null;
  5138. }
  5139. function roundPixelMeasures( measure ) {
  5140. return Math.round( parseFloat( measure ) );
  5141. }
  5142. var pixelPositionVal, boxSizingReliableVal, scrollboxSizeVal, pixelBoxStylesVal,
  5143. reliableMarginLeftVal,
  5144. container = document.createElement( "div" ),
  5145. div = document.createElement( "div" );
  5146. // Finish early in limited (non-browser) environments
  5147. if ( !div.style ) {
  5148. return;
  5149. }
  5150. // Support: IE <=9 - 11 only
  5151. // Style of cloned element affects source element cloned (#8908)
  5152. div.style.backgroundClip = "content-box";
  5153. div.cloneNode( true ).style.backgroundClip = "";
  5154. support.clearCloneStyle = div.style.backgroundClip === "content-box";
  5155. jQuery.extend( support, {
  5156. boxSizingReliable: function() {
  5157. computeStyleTests();
  5158. return boxSizingReliableVal;
  5159. },
  5160. pixelBoxStyles: function() {
  5161. computeStyleTests();
  5162. return pixelBoxStylesVal;
  5163. },
  5164. pixelPosition: function() {
  5165. computeStyleTests();
  5166. return pixelPositionVal;
  5167. },
  5168. reliableMarginLeft: function() {
  5169. computeStyleTests();
  5170. return reliableMarginLeftVal;
  5171. },
  5172. scrollboxSize: function() {
  5173. computeStyleTests();
  5174. return scrollboxSizeVal;
  5175. }
  5176. } );
  5177. } )();
  5178. function curCSS( elem, name, computed ) {
  5179. var width, minWidth, maxWidth, ret,
  5180. // Support: Firefox 51+
  5181. // Retrieving style before computed somehow
  5182. // fixes an issue with getting wrong values
  5183. // on detached elements
  5184. style = elem.style;
  5185. computed = computed || getStyles( elem );
  5186. // getPropertyValue is needed for:
  5187. // .css('filter') (IE 9 only, #12537)
  5188. // .css('--customProperty) (#3144)
  5189. if ( computed ) {
  5190. ret = computed.getPropertyValue( name ) || computed[ name ];
  5191. if ( ret === "" && !isAttached( elem ) ) {
  5192. ret = jQuery.style( elem, name );
  5193. }
  5194. // A tribute to the "awesome hack by Dean Edwards"
  5195. // Android Browser returns percentage for some values,
  5196. // but width seems to be reliably pixels.
  5197. // This is against the CSSOM draft spec:
  5198. // https://drafts.csswg.org/cssom/#resolved-values
  5199. if ( !support.pixelBoxStyles() && rnumnonpx.test( ret ) && rboxStyle.test( name ) ) {
  5200. // Remember the original values
  5201. width = style.width;
  5202. minWidth = style.minWidth;
  5203. maxWidth = style.maxWidth;
  5204. // Put in the new values to get a computed value out
  5205. style.minWidth = style.maxWidth = style.width = ret;
  5206. ret = computed.width;
  5207. // Revert the changed values
  5208. style.width = width;
  5209. style.minWidth = minWidth;
  5210. style.maxWidth = maxWidth;
  5211. }
  5212. }
  5213. return ret !== undefined ?
  5214. // Support: IE <=9 - 11 only
  5215. // IE returns zIndex value as an integer.
  5216. ret + "" :
  5217. ret;
  5218. }
  5219. function addGetHookIf( conditionFn, hookFn ) {
  5220. // Define the hook, we'll check on the first run if it's really needed.
  5221. return {
  5222. get: function() {
  5223. if ( conditionFn() ) {
  5224. // Hook not needed (or it's not possible to use it due
  5225. // to missing dependency), remove it.
  5226. delete this.get;
  5227. return;
  5228. }
  5229. // Hook needed; redefine it so that the support test is not executed again.
  5230. return ( this.get = hookFn ).apply( this, arguments );
  5231. }
  5232. };
  5233. }
  5234. var cssPrefixes = [ "Webkit", "Moz", "ms" ],
  5235. emptyStyle = document.createElement( "div" ).style,
  5236. vendorProps = {};
  5237. // Return a vendor-prefixed property or undefined
  5238. function vendorPropName( name ) {
  5239. // Check for vendor prefixed names
  5240. var capName = name[ 0 ].toUpperCase() + name.slice( 1 ),
  5241. i = cssPrefixes.length;
  5242. while ( i-- ) {
  5243. name = cssPrefixes[ i ] + capName;
  5244. if ( name in emptyStyle ) {
  5245. return name;
  5246. }
  5247. }
  5248. }
  5249. // Return a potentially-mapped jQuery.cssProps or vendor prefixed property
  5250. function finalPropName( name ) {
  5251. var final = jQuery.cssProps[ name ] || vendorProps[ name ];
  5252. if ( final ) {
  5253. return final;
  5254. }
  5255. if ( name in emptyStyle ) {
  5256. return name;
  5257. }
  5258. return vendorProps[ name ] = vendorPropName( name ) || name;
  5259. }
  5260. var
  5261. // Swappable if display is none or starts with table
  5262. // except "table", "table-cell", or "table-caption"
  5263. // See here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
  5264. rdisplayswap = /^(none|table(?!-c[ea]).+)/,
  5265. rcustomProp = /^--/,
  5266. cssShow = { position: "absolute", visibility: "hidden", display: "block" },
  5267. cssNormalTransform = {
  5268. letterSpacing: "0",
  5269. fontWeight: "400"
  5270. };
  5271. function setPositiveNumber( elem, value, subtract ) {
  5272. // Any relative (+/-) values have already been
  5273. // normalized at this point
  5274. var matches = rcssNum.exec( value );
  5275. return matches ?
  5276. // Guard against undefined "subtract", e.g., when used as in cssHooks
  5277. Math.max( 0, matches[ 2 ] - ( subtract || 0 ) ) + ( matches[ 3 ] || "px" ) :
  5278. value;
  5279. }
  5280. function boxModelAdjustment( elem, dimension, box, isBorderBox, styles, computedVal ) {
  5281. var i = dimension === "width" ? 1 : 0,
  5282. extra = 0,
  5283. delta = 0;
  5284. // Adjustment may not be necessary
  5285. if ( box === ( isBorderBox ? "border" : "content" ) ) {
  5286. return 0;
  5287. }
  5288. for ( ; i < 4; i += 2 ) {
  5289. // Both box models exclude margin
  5290. if ( box === "margin" ) {
  5291. delta += jQuery.css( elem, box + cssExpand[ i ], true, styles );
  5292. }
  5293. // If we get here with a content-box, we're seeking "padding" or "border" or "margin"
  5294. if ( !isBorderBox ) {
  5295. // Add padding
  5296. delta += jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5297. // For "border" or "margin", add border
  5298. if ( box !== "padding" ) {
  5299. delta += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5300. // But still keep track of it otherwise
  5301. } else {
  5302. extra += jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5303. }
  5304. // If we get here with a border-box (content + padding + border), we're seeking "content" or
  5305. // "padding" or "margin"
  5306. } else {
  5307. // For "content", subtract padding
  5308. if ( box === "content" ) {
  5309. delta -= jQuery.css( elem, "padding" + cssExpand[ i ], true, styles );
  5310. }
  5311. // For "content" or "padding", subtract border
  5312. if ( box !== "margin" ) {
  5313. delta -= jQuery.css( elem, "border" + cssExpand[ i ] + "Width", true, styles );
  5314. }
  5315. }
  5316. }
  5317. // Account for positive content-box scroll gutter when requested by providing computedVal
  5318. if ( !isBorderBox && computedVal >= 0 ) {
  5319. // offsetWidth/offsetHeight is a rounded sum of content, padding, scroll gutter, and border
  5320. // Assuming integer scroll gutter, subtract the rest and round down
  5321. delta += Math.max( 0, Math.ceil(
  5322. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  5323. computedVal -
  5324. delta -
  5325. extra -
  5326. 0.5
  5327. // If offsetWidth/offsetHeight is unknown, then we can't determine content-box scroll gutter
  5328. // Use an explicit zero to avoid NaN (gh-3964)
  5329. ) ) || 0;
  5330. }
  5331. return delta;
  5332. }
  5333. function getWidthOrHeight( elem, dimension, extra ) {
  5334. // Start with computed style
  5335. var styles = getStyles( elem ),
  5336. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-4322).
  5337. // Fake content-box until we know it's needed to know the true value.
  5338. boxSizingNeeded = !support.boxSizingReliable() || extra,
  5339. isBorderBox = boxSizingNeeded &&
  5340. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  5341. valueIsBorderBox = isBorderBox,
  5342. val = curCSS( elem, dimension, styles ),
  5343. offsetProp = "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 );
  5344. // Support: Firefox <=54
  5345. // Return a confounding non-pixel value or feign ignorance, as appropriate.
  5346. if ( rnumnonpx.test( val ) ) {
  5347. if ( !extra ) {
  5348. return val;
  5349. }
  5350. val = "auto";
  5351. }
  5352. // Fall back to offsetWidth/offsetHeight when value is "auto"
  5353. // This happens for inline elements with no explicit setting (gh-3571)
  5354. // Support: Android <=4.1 - 4.3 only
  5355. // Also use offsetWidth/offsetHeight for misreported inline dimensions (gh-3602)
  5356. // Support: IE 9-11 only
  5357. // Also use offsetWidth/offsetHeight for when box sizing is unreliable
  5358. // We use getClientRects() to check for hidden/disconnected.
  5359. // In those cases, the computed value can be trusted to be border-box
  5360. if ( ( !support.boxSizingReliable() && isBorderBox ||
  5361. val === "auto" ||
  5362. !parseFloat( val ) && jQuery.css( elem, "display", false, styles ) === "inline" ) &&
  5363. elem.getClientRects().length ) {
  5364. isBorderBox = jQuery.css( elem, "boxSizing", false, styles ) === "border-box";
  5365. // Where available, offsetWidth/offsetHeight approximate border box dimensions.
  5366. // Where not available (e.g., SVG), assume unreliable box-sizing and interpret the
  5367. // retrieved value as a content box dimension.
  5368. valueIsBorderBox = offsetProp in elem;
  5369. if ( valueIsBorderBox ) {
  5370. val = elem[ offsetProp ];
  5371. }
  5372. }
  5373. // Normalize "" and auto
  5374. val = parseFloat( val ) || 0;
  5375. // Adjust for the element's box model
  5376. return ( val +
  5377. boxModelAdjustment(
  5378. elem,
  5379. dimension,
  5380. extra || ( isBorderBox ? "border" : "content" ),
  5381. valueIsBorderBox,
  5382. styles,
  5383. // Provide the current computed size to request scroll gutter calculation (gh-3589)
  5384. val
  5385. )
  5386. ) + "px";
  5387. }
  5388. jQuery.extend( {
  5389. // Add in style property hooks for overriding the default
  5390. // behavior of getting and setting a style property
  5391. cssHooks: {
  5392. opacity: {
  5393. get: function( elem, computed ) {
  5394. if ( computed ) {
  5395. // We should always get a number back from opacity
  5396. var ret = curCSS( elem, "opacity" );
  5397. return ret === "" ? "1" : ret;
  5398. }
  5399. }
  5400. }
  5401. },
  5402. // Don't automatically add "px" to these possibly-unitless properties
  5403. cssNumber: {
  5404. "animationIterationCount": true,
  5405. "columnCount": true,
  5406. "fillOpacity": true,
  5407. "flexGrow": true,
  5408. "flexShrink": true,
  5409. "fontWeight": true,
  5410. "gridArea": true,
  5411. "gridColumn": true,
  5412. "gridColumnEnd": true,
  5413. "gridColumnStart": true,
  5414. "gridRow": true,
  5415. "gridRowEnd": true,
  5416. "gridRowStart": true,
  5417. "lineHeight": true,
  5418. "opacity": true,
  5419. "order": true,
  5420. "orphans": true,
  5421. "widows": true,
  5422. "zIndex": true,
  5423. "zoom": true
  5424. },
  5425. // Add in properties whose names you wish to fix before
  5426. // setting or getting the value
  5427. cssProps: {},
  5428. // Get and set the style property on a DOM Node
  5429. style: function( elem, name, value, extra ) {
  5430. // Don't set styles on text and comment nodes
  5431. if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
  5432. return;
  5433. }
  5434. // Make sure that we're working with the right name
  5435. var ret, type, hooks,
  5436. origName = camelCase( name ),
  5437. isCustomProp = rcustomProp.test( name ),
  5438. style = elem.style;
  5439. // Make sure that we're working with the right name. We don't
  5440. // want to query the value if it is a CSS custom property
  5441. // since they are user-defined.
  5442. if ( !isCustomProp ) {
  5443. name = finalPropName( origName );
  5444. }
  5445. // Gets hook for the prefixed version, then unprefixed version
  5446. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5447. // Check if we're setting a value
  5448. if ( value !== undefined ) {
  5449. type = typeof value;
  5450. // Convert "+=" or "-=" to relative numbers (#7345)
  5451. if ( type === "string" && ( ret = rcssNum.exec( value ) ) && ret[ 1 ] ) {
  5452. value = adjustCSS( elem, name, ret );
  5453. // Fixes bug #9237
  5454. type = "number";
  5455. }
  5456. // Make sure that null and NaN values aren't set (#7116)
  5457. if ( value == null || value !== value ) {
  5458. return;
  5459. }
  5460. // If a number was passed in, add the unit (except for certain CSS properties)
  5461. // The isCustomProp check can be removed in jQuery 4.0 when we only auto-append
  5462. // "px" to a few hardcoded values.
  5463. if ( type === "number" && !isCustomProp ) {
  5464. value += ret && ret[ 3 ] || ( jQuery.cssNumber[ origName ] ? "" : "px" );
  5465. }
  5466. // background-* props affect original clone's values
  5467. if ( !support.clearCloneStyle && value === "" && name.indexOf( "background" ) === 0 ) {
  5468. style[ name ] = "inherit";
  5469. }
  5470. // If a hook was provided, use that value, otherwise just set the specified value
  5471. if ( !hooks || !( "set" in hooks ) ||
  5472. ( value = hooks.set( elem, value, extra ) ) !== undefined ) {
  5473. if ( isCustomProp ) {
  5474. style.setProperty( name, value );
  5475. } else {
  5476. style[ name ] = value;
  5477. }
  5478. }
  5479. } else {
  5480. // If a hook was provided get the non-computed value from there
  5481. if ( hooks && "get" in hooks &&
  5482. ( ret = hooks.get( elem, false, extra ) ) !== undefined ) {
  5483. return ret;
  5484. }
  5485. // Otherwise just get the value from the style object
  5486. return style[ name ];
  5487. }
  5488. },
  5489. css: function( elem, name, extra, styles ) {
  5490. var val, num, hooks,
  5491. origName = camelCase( name ),
  5492. isCustomProp = rcustomProp.test( name );
  5493. // Make sure that we're working with the right name. We don't
  5494. // want to modify the value if it is a CSS custom property
  5495. // since they are user-defined.
  5496. if ( !isCustomProp ) {
  5497. name = finalPropName( origName );
  5498. }
  5499. // Try prefixed name followed by the unprefixed name
  5500. hooks = jQuery.cssHooks[ name ] || jQuery.cssHooks[ origName ];
  5501. // If a hook was provided get the computed value from there
  5502. if ( hooks && "get" in hooks ) {
  5503. val = hooks.get( elem, true, extra );
  5504. }
  5505. // Otherwise, if a way to get the computed value exists, use that
  5506. if ( val === undefined ) {
  5507. val = curCSS( elem, name, styles );
  5508. }
  5509. // Convert "normal" to computed value
  5510. if ( val === "normal" && name in cssNormalTransform ) {
  5511. val = cssNormalTransform[ name ];
  5512. }
  5513. // Make numeric if forced or a qualifier was provided and val looks numeric
  5514. if ( extra === "" || extra ) {
  5515. num = parseFloat( val );
  5516. return extra === true || isFinite( num ) ? num || 0 : val;
  5517. }
  5518. return val;
  5519. }
  5520. } );
  5521. jQuery.each( [ "height", "width" ], function( i, dimension ) {
  5522. jQuery.cssHooks[ dimension ] = {
  5523. get: function( elem, computed, extra ) {
  5524. if ( computed ) {
  5525. // Certain elements can have dimension info if we invisibly show them
  5526. // but it must have a current display style that would benefit
  5527. return rdisplayswap.test( jQuery.css( elem, "display" ) ) &&
  5528. // Support: Safari 8+
  5529. // Table columns in Safari have non-zero offsetWidth & zero
  5530. // getBoundingClientRect().width unless display is changed.
  5531. // Support: IE <=11 only
  5532. // Running getBoundingClientRect on a disconnected node
  5533. // in IE throws an error.
  5534. ( !elem.getClientRects().length || !elem.getBoundingClientRect().width ) ?
  5535. swap( elem, cssShow, function() {
  5536. return getWidthOrHeight( elem, dimension, extra );
  5537. } ) :
  5538. getWidthOrHeight( elem, dimension, extra );
  5539. }
  5540. },
  5541. set: function( elem, value, extra ) {
  5542. var matches,
  5543. styles = getStyles( elem ),
  5544. // Only read styles.position if the test has a chance to fail
  5545. // to avoid forcing a reflow.
  5546. scrollboxSizeBuggy = !support.scrollboxSize() &&
  5547. styles.position === "absolute",
  5548. // To avoid forcing a reflow, only fetch boxSizing if we need it (gh-3991)
  5549. boxSizingNeeded = scrollboxSizeBuggy || extra,
  5550. isBorderBox = boxSizingNeeded &&
  5551. jQuery.css( elem, "boxSizing", false, styles ) === "border-box",
  5552. subtract = extra ?
  5553. boxModelAdjustment(
  5554. elem,
  5555. dimension,
  5556. extra,
  5557. isBorderBox,
  5558. styles
  5559. ) :
  5560. 0;
  5561. // Account for unreliable border-box dimensions by comparing offset* to computed and
  5562. // faking a content-box to get border and padding (gh-3699)
  5563. if ( isBorderBox && scrollboxSizeBuggy ) {
  5564. subtract -= Math.ceil(
  5565. elem[ "offset" + dimension[ 0 ].toUpperCase() + dimension.slice( 1 ) ] -
  5566. parseFloat( styles[ dimension ] ) -
  5567. boxModelAdjustment( elem, dimension, "border", false, styles ) -
  5568. 0.5
  5569. );
  5570. }
  5571. // Convert to pixels if value adjustment is needed
  5572. if ( subtract && ( matches = rcssNum.exec( value ) ) &&
  5573. ( matches[ 3 ] || "px" ) !== "px" ) {
  5574. elem.style[ dimension ] = value;
  5575. value = jQuery.css( elem, dimension );
  5576. }
  5577. return setPositiveNumber( elem, value, subtract );
  5578. }
  5579. };
  5580. } );
  5581. jQuery.cssHooks.marginLeft = addGetHookIf( support.reliableMarginLeft,
  5582. function( elem, computed ) {
  5583. if ( computed ) {
  5584. return ( parseFloat( curCSS( elem, "marginLeft" ) ) ||
  5585. elem.getBoundingClientRect().left -
  5586. swap( elem, { marginLeft: 0 }, function() {
  5587. return elem.getBoundingClientRect().left;
  5588. } )
  5589. ) + "px";
  5590. }
  5591. }
  5592. );
  5593. // These hooks are used by animate to expand properties
  5594. jQuery.each( {
  5595. margin: "",
  5596. padding: "",
  5597. border: "Width"
  5598. }, function( prefix, suffix ) {
  5599. jQuery.cssHooks[ prefix + suffix ] = {
  5600. expand: function( value ) {
  5601. var i = 0,
  5602. expanded = {},
  5603. // Assumes a single number if not a string
  5604. parts = typeof value === "string" ? value.split( " " ) : [ value ];
  5605. for ( ; i < 4; i++ ) {
  5606. expanded[ prefix + cssExpand[ i ] + suffix ] =
  5607. parts[ i ] || parts[ i - 2 ] || parts[ 0 ];
  5608. }
  5609. return expanded;
  5610. }
  5611. };
  5612. if ( prefix !== "margin" ) {
  5613. jQuery.cssHooks[ prefix + suffix ].set = setPositiveNumber;
  5614. }
  5615. } );
  5616. jQuery.fn.extend( {
  5617. css: function( name, value ) {
  5618. return access( this, function( elem, name, value ) {
  5619. var styles, len,
  5620. map = {},
  5621. i = 0;
  5622. if ( Array.isArray( name ) ) {
  5623. styles = getStyles( elem );
  5624. len = name.length;
  5625. for ( ; i < len; i++ ) {
  5626. map[ name[ i ] ] = jQuery.css( elem, name[ i ], false, styles );
  5627. }
  5628. return map;
  5629. }
  5630. return value !== undefined ?
  5631. jQuery.style( elem, name, value ) :
  5632. jQuery.css( elem, name );
  5633. }, name, value, arguments.length > 1 );
  5634. }
  5635. } );
  5636. function Tween( elem, options, prop, end, easing ) {
  5637. return new Tween.prototype.init( elem, options, prop, end, easing );
  5638. }
  5639. jQuery.Tween = Tween;
  5640. Tween.prototype = {
  5641. constructor: Tween,
  5642. init: function( elem, options, prop, end, easing, unit ) {
  5643. this.elem = elem;
  5644. this.prop = prop;
  5645. this.easing = easing || jQuery.easing._default;
  5646. this.options = options;
  5647. this.start = this.now = this.cur();
  5648. this.end = end;
  5649. this.unit = unit || ( jQuery.cssNumber[ prop ] ? "" : "px" );
  5650. },
  5651. cur: function() {
  5652. var hooks = Tween.propHooks[ this.prop ];
  5653. return hooks && hooks.get ?
  5654. hooks.get( this ) :
  5655. Tween.propHooks._default.get( this );
  5656. },
  5657. run: function( percent ) {
  5658. var eased,
  5659. hooks = Tween.propHooks[ this.prop ];
  5660. if ( this.options.duration ) {
  5661. this.pos = eased = jQuery.easing[ this.easing ](
  5662. percent, this.options.duration * percent, 0, 1, this.options.duration
  5663. );
  5664. } else {
  5665. this.pos = eased = percent;
  5666. }
  5667. this.now = ( this.end - this.start ) * eased + this.start;
  5668. if ( this.options.step ) {
  5669. this.options.step.call( this.elem, this.now, this );
  5670. }
  5671. if ( hooks && hooks.set ) {
  5672. hooks.set( this );
  5673. } else {
  5674. Tween.propHooks._default.set( this );
  5675. }
  5676. return this;
  5677. }
  5678. };
  5679. Tween.prototype.init.prototype = Tween.prototype;
  5680. Tween.propHooks = {
  5681. _default: {
  5682. get: function( tween ) {
  5683. var result;
  5684. // Use a property on the element directly when it is not a DOM element,
  5685. // or when there is no matching style property that exists.
  5686. if ( tween.elem.nodeType !== 1 ||
  5687. tween.elem[ tween.prop ] != null && tween.elem.style[ tween.prop ] == null ) {
  5688. return tween.elem[ tween.prop ];
  5689. }
  5690. // Passing an empty string as a 3rd parameter to .css will automatically
  5691. // attempt a parseFloat and fallback to a string if the parse fails.
  5692. // Simple values such as "10px" are parsed to Float;
  5693. // complex values such as "rotate(1rad)" are returned as-is.
  5694. result = jQuery.css( tween.elem, tween.prop, "" );
  5695. // Empty strings, null, undefined and "auto" are converted to 0.
  5696. return !result || result === "auto" ? 0 : result;
  5697. },
  5698. set: function( tween ) {
  5699. // Use step hook for back compat.
  5700. // Use cssHook if its there.
  5701. // Use .style if available and use plain properties where available.
  5702. if ( jQuery.fx.step[ tween.prop ] ) {
  5703. jQuery.fx.step[ tween.prop ]( tween );
  5704. } else if ( tween.elem.nodeType === 1 && (
  5705. jQuery.cssHooks[ tween.prop ] ||
  5706. tween.elem.style[ finalPropName( tween.prop ) ] != null ) ) {
  5707. jQuery.style( tween.elem, tween.prop, tween.now + tween.unit );
  5708. } else {
  5709. tween.elem[ tween.prop ] = tween.now;
  5710. }
  5711. }
  5712. }
  5713. };
  5714. // Support: IE <=9 only
  5715. // Panic based approach to setting things on disconnected nodes
  5716. Tween.propHooks.scrollTop = Tween.propHooks.scrollLeft = {
  5717. set: function( tween ) {
  5718. if ( tween.elem.nodeType && tween.elem.parentNode ) {
  5719. tween.elem[ tween.prop ] = tween.now;
  5720. }
  5721. }
  5722. };
  5723. jQuery.easing = {
  5724. linear: function( p ) {
  5725. return p;
  5726. },
  5727. swing: function( p ) {
  5728. return 0.5 - Math.cos( p * Math.PI ) / 2;
  5729. },
  5730. _default: "swing"
  5731. };
  5732. jQuery.fx = Tween.prototype.init;
  5733. // Back compat <1.8 extension point
  5734. jQuery.fx.step = {};
  5735. var
  5736. fxNow, inProgress,
  5737. rfxtypes = /^(?:toggle|show|hide)$/,
  5738. rrun = /queueHooks$/;
  5739. function schedule() {
  5740. if ( inProgress ) {
  5741. if ( document.hidden === false && window.requestAnimationFrame ) {
  5742. window.requestAnimationFrame( schedule );
  5743. } else {
  5744. window.setTimeout( schedule, jQuery.fx.interval );
  5745. }
  5746. jQuery.fx.tick();
  5747. }
  5748. }
  5749. // Animations created synchronously will run synchronously
  5750. function createFxNow() {
  5751. window.setTimeout( function() {
  5752. fxNow = undefined;
  5753. } );
  5754. return ( fxNow = Date.now() );
  5755. }
  5756. // Generate parameters to create a standard animation
  5757. function genFx( type, includeWidth ) {
  5758. var which,
  5759. i = 0,
  5760. attrs = { height: type };
  5761. // If we include width, step value is 1 to do all cssExpand values,
  5762. // otherwise step value is 2 to skip over Left and Right
  5763. includeWidth = includeWidth ? 1 : 0;
  5764. for ( ; i < 4; i += 2 - includeWidth ) {
  5765. which = cssExpand[ i ];
  5766. attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
  5767. }
  5768. if ( includeWidth ) {
  5769. attrs.opacity = attrs.width = type;
  5770. }
  5771. return attrs;
  5772. }
  5773. function createTween( value, prop, animation ) {
  5774. var tween,
  5775. collection = ( Animation.tweeners[ prop ] || [] ).concat( Animation.tweeners[ "*" ] ),
  5776. index = 0,
  5777. length = collection.length;
  5778. for ( ; index < length; index++ ) {
  5779. if ( ( tween = collection[ index ].call( animation, prop, value ) ) ) {
  5780. // We're done with this property
  5781. return tween;
  5782. }
  5783. }
  5784. }
  5785. function defaultPrefilter( elem, props, opts ) {
  5786. var prop, value, toggle, hooks, oldfire, propTween, restoreDisplay, display,
  5787. isBox = "width" in props || "height" in props,
  5788. anim = this,
  5789. orig = {},
  5790. style = elem.style,
  5791. hidden = elem.nodeType && isHiddenWithinTree( elem ),
  5792. dataShow = dataPriv.get( elem, "fxshow" );
  5793. // Queue-skipping animations hijack the fx hooks
  5794. if ( !opts.queue ) {
  5795. hooks = jQuery._queueHooks( elem, "fx" );
  5796. if ( hooks.unqueued == null ) {
  5797. hooks.unqueued = 0;
  5798. oldfire = hooks.empty.fire;
  5799. hooks.empty.fire = function() {
  5800. if ( !hooks.unqueued ) {
  5801. oldfire();
  5802. }
  5803. };
  5804. }
  5805. hooks.unqueued++;
  5806. anim.always( function() {
  5807. // Ensure the complete handler is called before this completes
  5808. anim.always( function() {
  5809. hooks.unqueued--;
  5810. if ( !jQuery.queue( elem, "fx" ).length ) {
  5811. hooks.empty.fire();
  5812. }
  5813. } );
  5814. } );
  5815. }
  5816. // Detect show/hide animations
  5817. for ( prop in props ) {
  5818. value = props[ prop ];
  5819. if ( rfxtypes.test( value ) ) {
  5820. delete props[ prop ];
  5821. toggle = toggle || value === "toggle";
  5822. if ( value === ( hidden ? "hide" : "show" ) ) {
  5823. // Pretend to be hidden if this is a "show" and
  5824. // there is still data from a stopped show/hide
  5825. if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
  5826. hidden = true;
  5827. // Ignore all other no-op show/hide data
  5828. } else {
  5829. continue;
  5830. }
  5831. }
  5832. orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
  5833. }
  5834. }
  5835. // Bail out if this is a no-op like .hide().hide()
  5836. propTween = !jQuery.isEmptyObject( props );
  5837. if ( !propTween && jQuery.isEmptyObject( orig ) ) {
  5838. return;
  5839. }
  5840. // Restrict "overflow" and "display" styles during box animations
  5841. if ( isBox && elem.nodeType === 1 ) {
  5842. // Support: IE <=9 - 11, Edge 12 - 15
  5843. // Record all 3 overflow attributes because IE does not infer the shorthand
  5844. // from identically-valued overflowX and overflowY and Edge just mirrors
  5845. // the overflowX value there.
  5846. opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
  5847. // Identify a display type, preferring old show/hide data over the CSS cascade
  5848. restoreDisplay = dataShow && dataShow.display;
  5849. if ( restoreDisplay == null ) {
  5850. restoreDisplay = dataPriv.get( elem, "display" );
  5851. }
  5852. display = jQuery.css( elem, "display" );
  5853. if ( display === "none" ) {
  5854. if ( restoreDisplay ) {
  5855. display = restoreDisplay;
  5856. } else {
  5857. // Get nonempty value(s) by temporarily forcing visibility
  5858. showHide( [ elem ], true );
  5859. restoreDisplay = elem.style.display || restoreDisplay;
  5860. display = jQuery.css( elem, "display" );
  5861. showHide( [ elem ] );
  5862. }
  5863. }
  5864. // Animate inline elements as inline-block
  5865. if ( display === "inline" || display === "inline-block" && restoreDisplay != null ) {
  5866. if ( jQuery.css( elem, "float" ) === "none" ) {
  5867. // Restore the original display value at the end of pure show/hide animations
  5868. if ( !propTween ) {
  5869. anim.done( function() {
  5870. style.display = restoreDisplay;
  5871. } );
  5872. if ( restoreDisplay == null ) {
  5873. display = style.display;
  5874. restoreDisplay = display === "none" ? "" : display;
  5875. }
  5876. }
  5877. style.display = "inline-block";
  5878. }
  5879. }
  5880. }
  5881. if ( opts.overflow ) {
  5882. style.overflow = "hidden";
  5883. anim.always( function() {
  5884. style.overflow = opts.overflow[ 0 ];
  5885. style.overflowX = opts.overflow[ 1 ];
  5886. style.overflowY = opts.overflow[ 2 ];
  5887. } );
  5888. }
  5889. // Implement show/hide animations
  5890. propTween = false;
  5891. for ( prop in orig ) {
  5892. // General show/hide setup for this element animation
  5893. if ( !propTween ) {
  5894. if ( dataShow ) {
  5895. if ( "hidden" in dataShow ) {
  5896. hidden = dataShow.hidden;
  5897. }
  5898. } else {
  5899. dataShow = dataPriv.access( elem, "fxshow", { display: restoreDisplay } );
  5900. }
  5901. // Store hidden/visible for toggle so `.stop().toggle()` "reverses"
  5902. if ( toggle ) {
  5903. dataShow.hidden = !hidden;
  5904. }
  5905. // Show elements before animating them
  5906. if ( hidden ) {
  5907. showHide( [ elem ], true );
  5908. }
  5909. /* eslint-disable no-loop-func */
  5910. anim.done( function() {
  5911. /* eslint-enable no-loop-func */
  5912. // The final step of a "hide" animation is actually hiding the element
  5913. if ( !hidden ) {
  5914. showHide( [ elem ] );
  5915. }
  5916. dataPriv.remove( elem, "fxshow" );
  5917. for ( prop in orig ) {
  5918. jQuery.style( elem, prop, orig[ prop ] );
  5919. }
  5920. } );
  5921. }
  5922. // Per-property setup
  5923. propTween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
  5924. if ( !( prop in dataShow ) ) {
  5925. dataShow[ prop ] = propTween.start;
  5926. if ( hidden ) {
  5927. propTween.end = propTween.start;
  5928. propTween.start = 0;
  5929. }
  5930. }
  5931. }
  5932. }
  5933. function propFilter( props, specialEasing ) {
  5934. var index, name, easing, value, hooks;
  5935. // camelCase, specialEasing and expand cssHook pass
  5936. for ( index in props ) {
  5937. name = camelCase( index );
  5938. easing = specialEasing[ name ];
  5939. value = props[ index ];
  5940. if ( Array.isArray( value ) ) {
  5941. easing = value[ 1 ];
  5942. value = props[ index ] = value[ 0 ];
  5943. }
  5944. if ( index !== name ) {
  5945. props[ name ] = value;
  5946. delete props[ index ];
  5947. }
  5948. hooks = jQuery.cssHooks[ name ];
  5949. if ( hooks && "expand" in hooks ) {
  5950. value = hooks.expand( value );
  5951. delete props[ name ];
  5952. // Not quite $.extend, this won't overwrite existing keys.
  5953. // Reusing 'index' because we have the correct "name"
  5954. for ( index in value ) {
  5955. if ( !( index in props ) ) {
  5956. props[ index ] = value[ index ];
  5957. specialEasing[ index ] = easing;
  5958. }
  5959. }
  5960. } else {
  5961. specialEasing[ name ] = easing;
  5962. }
  5963. }
  5964. }
  5965. function Animation( elem, properties, options ) {
  5966. var result,
  5967. stopped,
  5968. index = 0,
  5969. length = Animation.prefilters.length,
  5970. deferred = jQuery.Deferred().always( function() {
  5971. // Don't match elem in the :animated selector
  5972. delete tick.elem;
  5973. } ),
  5974. tick = function() {
  5975. if ( stopped ) {
  5976. return false;
  5977. }
  5978. var currentTime = fxNow || createFxNow(),
  5979. remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
  5980. // Support: Android 2.3 only
  5981. // Archaic crash bug won't allow us to use `1 - ( 0.5 || 0 )` (#12497)
  5982. temp = remaining / animation.duration || 0,
  5983. percent = 1 - temp,
  5984. index = 0,
  5985. length = animation.tweens.length;
  5986. for ( ; index < length; index++ ) {
  5987. animation.tweens[ index ].run( percent );
  5988. }
  5989. deferred.notifyWith( elem, [ animation, percent, remaining ] );
  5990. // If there's more to do, yield
  5991. if ( percent < 1 && length ) {
  5992. return remaining;
  5993. }
  5994. // If this was an empty animation, synthesize a final progress notification
  5995. if ( !length ) {
  5996. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  5997. }
  5998. // Resolve the animation and report its conclusion
  5999. deferred.resolveWith( elem, [ animation ] );
  6000. return false;
  6001. },
  6002. animation = deferred.promise( {
  6003. elem: elem,
  6004. props: jQuery.extend( {}, properties ),
  6005. opts: jQuery.extend( true, {
  6006. specialEasing: {},
  6007. easing: jQuery.easing._default
  6008. }, options ),
  6009. originalProperties: properties,
  6010. originalOptions: options,
  6011. startTime: fxNow || createFxNow(),
  6012. duration: options.duration,
  6013. tweens: [],
  6014. createTween: function( prop, end ) {
  6015. var tween = jQuery.Tween( elem, animation.opts, prop, end,
  6016. animation.opts.specialEasing[ prop ] || animation.opts.easing );
  6017. animation.tweens.push( tween );
  6018. return tween;
  6019. },
  6020. stop: function( gotoEnd ) {
  6021. var index = 0,
  6022. // If we are going to the end, we want to run all the tweens
  6023. // otherwise we skip this part
  6024. length = gotoEnd ? animation.tweens.length : 0;
  6025. if ( stopped ) {
  6026. return this;
  6027. }
  6028. stopped = true;
  6029. for ( ; index < length; index++ ) {
  6030. animation.tweens[ index ].run( 1 );
  6031. }
  6032. // Resolve when we played the last frame; otherwise, reject
  6033. if ( gotoEnd ) {
  6034. deferred.notifyWith( elem, [ animation, 1, 0 ] );
  6035. deferred.resolveWith( elem, [ animation, gotoEnd ] );
  6036. } else {
  6037. deferred.rejectWith( elem, [ animation, gotoEnd ] );
  6038. }
  6039. return this;
  6040. }
  6041. } ),
  6042. props = animation.props;
  6043. propFilter( props, animation.opts.specialEasing );
  6044. for ( ; index < length; index++ ) {
  6045. result = Animation.prefilters[ index ].call( animation, elem, props, animation.opts );
  6046. if ( result ) {
  6047. if ( isFunction( result.stop ) ) {
  6048. jQuery._queueHooks( animation.elem, animation.opts.queue ).stop =
  6049. result.stop.bind( result );
  6050. }
  6051. return result;
  6052. }
  6053. }
  6054. jQuery.map( props, createTween, animation );
  6055. if ( isFunction( animation.opts.start ) ) {
  6056. animation.opts.start.call( elem, animation );
  6057. }
  6058. // Attach callbacks from options
  6059. animation
  6060. .progress( animation.opts.progress )
  6061. .done( animation.opts.done, animation.opts.complete )
  6062. .fail( animation.opts.fail )
  6063. .always( animation.opts.always );
  6064. jQuery.fx.timer(
  6065. jQuery.extend( tick, {
  6066. elem: elem,
  6067. anim: animation,
  6068. queue: animation.opts.queue
  6069. } )
  6070. );
  6071. return animation;
  6072. }
  6073. jQuery.Animation = jQuery.extend( Animation, {
  6074. tweeners: {
  6075. "*": [ function( prop, value ) {
  6076. var tween = this.createTween( prop, value );
  6077. adjustCSS( tween.elem, prop, rcssNum.exec( value ), tween );
  6078. return tween;
  6079. } ]
  6080. },
  6081. tweener: function( props, callback ) {
  6082. if ( isFunction( props ) ) {
  6083. callback = props;
  6084. props = [ "*" ];
  6085. } else {
  6086. props = props.match( rnothtmlwhite );
  6087. }
  6088. var prop,
  6089. index = 0,
  6090. length = props.length;
  6091. for ( ; index < length; index++ ) {
  6092. prop = props[ index ];
  6093. Animation.tweeners[ prop ] = Animation.tweeners[ prop ] || [];
  6094. Animation.tweeners[ prop ].unshift( callback );
  6095. }
  6096. },
  6097. prefilters: [ defaultPrefilter ],
  6098. prefilter: function( callback, prepend ) {
  6099. if ( prepend ) {
  6100. Animation.prefilters.unshift( callback );
  6101. } else {
  6102. Animation.prefilters.push( callback );
  6103. }
  6104. }
  6105. } );
  6106. jQuery.speed = function( speed, easing, fn ) {
  6107. var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
  6108. complete: fn || !fn && easing ||
  6109. isFunction( speed ) && speed,
  6110. duration: speed,
  6111. easing: fn && easing || easing && !isFunction( easing ) && easing
  6112. };
  6113. // Go to the end state if fx are off
  6114. if ( jQuery.fx.off ) {
  6115. opt.duration = 0;
  6116. } else {
  6117. if ( typeof opt.duration !== "number" ) {
  6118. if ( opt.duration in jQuery.fx.speeds ) {
  6119. opt.duration = jQuery.fx.speeds[ opt.duration ];
  6120. } else {
  6121. opt.duration = jQuery.fx.speeds._default;
  6122. }
  6123. }
  6124. }
  6125. // Normalize opt.queue - true/undefined/null -> "fx"
  6126. if ( opt.queue == null || opt.queue === true ) {
  6127. opt.queue = "fx";
  6128. }
  6129. // Queueing
  6130. opt.old = opt.complete;
  6131. opt.complete = function() {
  6132. if ( isFunction( opt.old ) ) {
  6133. opt.old.call( this );
  6134. }
  6135. if ( opt.queue ) {
  6136. jQuery.dequeue( this, opt.queue );
  6137. }
  6138. };
  6139. return opt;
  6140. };
  6141. jQuery.fn.extend( {
  6142. fadeTo: function( speed, to, easing, callback ) {
  6143. // Show any hidden elements after setting opacity to 0
  6144. return this.filter( isHiddenWithinTree ).css( "opacity", 0 ).show()
  6145. // Animate to the value specified
  6146. .end().animate( { opacity: to }, speed, easing, callback );
  6147. },
  6148. animate: function( prop, speed, easing, callback ) {
  6149. var empty = jQuery.isEmptyObject( prop ),
  6150. optall = jQuery.speed( speed, easing, callback ),
  6151. doAnimation = function() {
  6152. // Operate on a copy of prop so per-property easing won't be lost
  6153. var anim = Animation( this, jQuery.extend( {}, prop ), optall );
  6154. // Empty animations, or finishing resolves immediately
  6155. if ( empty || dataPriv.get( this, "finish" ) ) {
  6156. anim.stop( true );
  6157. }
  6158. };
  6159. doAnimation.finish = doAnimation;
  6160. return empty || optall.queue === false ?
  6161. this.each( doAnimation ) :
  6162. this.queue( optall.queue, doAnimation );
  6163. },
  6164. stop: function( type, clearQueue, gotoEnd ) {
  6165. var stopQueue = function( hooks ) {
  6166. var stop = hooks.stop;
  6167. delete hooks.stop;
  6168. stop( gotoEnd );
  6169. };
  6170. if ( typeof type !== "string" ) {
  6171. gotoEnd = clearQueue;
  6172. clearQueue = type;
  6173. type = undefined;
  6174. }
  6175. if ( clearQueue && type !== false ) {
  6176. this.queue( type || "fx", [] );
  6177. }
  6178. return this.each( function() {
  6179. var dequeue = true,
  6180. index = type != null && type + "queueHooks",
  6181. timers = jQuery.timers,
  6182. data = dataPriv.get( this );
  6183. if ( index ) {
  6184. if ( data[ index ] && data[ index ].stop ) {
  6185. stopQueue( data[ index ] );
  6186. }
  6187. } else {
  6188. for ( index in data ) {
  6189. if ( data[ index ] && data[ index ].stop && rrun.test( index ) ) {
  6190. stopQueue( data[ index ] );
  6191. }
  6192. }
  6193. }
  6194. for ( index = timers.length; index--; ) {
  6195. if ( timers[ index ].elem === this &&
  6196. ( type == null || timers[ index ].queue === type ) ) {
  6197. timers[ index ].anim.stop( gotoEnd );
  6198. dequeue = false;
  6199. timers.splice( index, 1 );
  6200. }
  6201. }
  6202. // Start the next in the queue if the last step wasn't forced.
  6203. // Timers currently will call their complete callbacks, which
  6204. // will dequeue but only if they were gotoEnd.
  6205. if ( dequeue || !gotoEnd ) {
  6206. jQuery.dequeue( this, type );
  6207. }
  6208. } );
  6209. },
  6210. finish: function( type ) {
  6211. if ( type !== false ) {
  6212. type = type || "fx";
  6213. }
  6214. return this.each( function() {
  6215. var index,
  6216. data = dataPriv.get( this ),
  6217. queue = data[ type + "queue" ],
  6218. hooks = data[ type + "queueHooks" ],
  6219. timers = jQuery.timers,
  6220. length = queue ? queue.length : 0;
  6221. // Enable finishing flag on private data
  6222. data.finish = true;
  6223. // Empty the queue first
  6224. jQuery.queue( this, type, [] );
  6225. if ( hooks && hooks.stop ) {
  6226. hooks.stop.call( this, true );
  6227. }
  6228. // Look for any active animations, and finish them
  6229. for ( index = timers.length; index--; ) {
  6230. if ( timers[ index ].elem === this && timers[ index ].queue === type ) {
  6231. timers[ index ].anim.stop( true );
  6232. timers.splice( index, 1 );
  6233. }
  6234. }
  6235. // Look for any animations in the old queue and finish them
  6236. for ( index = 0; index < length; index++ ) {
  6237. if ( queue[ index ] && queue[ index ].finish ) {
  6238. queue[ index ].finish.call( this );
  6239. }
  6240. }
  6241. // Turn off finishing flag
  6242. delete data.finish;
  6243. } );
  6244. }
  6245. } );
  6246. jQuery.each( [ "toggle", "show", "hide" ], function( i, name ) {
  6247. var cssFn = jQuery.fn[ name ];
  6248. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6249. return speed == null || typeof speed === "boolean" ?
  6250. cssFn.apply( this, arguments ) :
  6251. this.animate( genFx( name, true ), speed, easing, callback );
  6252. };
  6253. } );
  6254. // Generate shortcuts for custom animations
  6255. jQuery.each( {
  6256. slideDown: genFx( "show" ),
  6257. slideUp: genFx( "hide" ),
  6258. slideToggle: genFx( "toggle" ),
  6259. fadeIn: { opacity: "show" },
  6260. fadeOut: { opacity: "hide" },
  6261. fadeToggle: { opacity: "toggle" }
  6262. }, function( name, props ) {
  6263. jQuery.fn[ name ] = function( speed, easing, callback ) {
  6264. return this.animate( props, speed, easing, callback );
  6265. };
  6266. } );
  6267. jQuery.timers = [];
  6268. jQuery.fx.tick = function() {
  6269. var timer,
  6270. i = 0,
  6271. timers = jQuery.timers;
  6272. fxNow = Date.now();
  6273. for ( ; i < timers.length; i++ ) {
  6274. timer = timers[ i ];
  6275. // Run the timer and safely remove it when done (allowing for external removal)
  6276. if ( !timer() && timers[ i ] === timer ) {
  6277. timers.splice( i--, 1 );
  6278. }
  6279. }
  6280. if ( !timers.length ) {
  6281. jQuery.fx.stop();
  6282. }
  6283. fxNow = undefined;
  6284. };
  6285. jQuery.fx.timer = function( timer ) {
  6286. jQuery.timers.push( timer );
  6287. jQuery.fx.start();
  6288. };
  6289. jQuery.fx.interval = 13;
  6290. jQuery.fx.start = function() {
  6291. if ( inProgress ) {
  6292. return;
  6293. }
  6294. inProgress = true;
  6295. schedule();
  6296. };
  6297. jQuery.fx.stop = function() {
  6298. inProgress = null;
  6299. };
  6300. jQuery.fx.speeds = {
  6301. slow: 600,
  6302. fast: 200,
  6303. // Default speed
  6304. _default: 400
  6305. };
  6306. // Based off of the plugin by Clint Helfers, with permission.
  6307. // https://web.archive.org/web/20100324014747/http://blindsignals.com/index.php/2009/07/jquery-delay/
  6308. jQuery.fn.delay = function( time, type ) {
  6309. time = jQuery.fx ? jQuery.fx.speeds[ time ] || time : time;
  6310. type = type || "fx";
  6311. return this.queue( type, function( next, hooks ) {
  6312. var timeout = window.setTimeout( next, time );
  6313. hooks.stop = function() {
  6314. window.clearTimeout( timeout );
  6315. };
  6316. } );
  6317. };
  6318. ( function() {
  6319. var input = document.createElement( "input" ),
  6320. select = document.createElement( "select" ),
  6321. opt = select.appendChild( document.createElement( "option" ) );
  6322. input.type = "checkbox";
  6323. // Support: Android <=4.3 only
  6324. // Default value for a checkbox should be "on"
  6325. support.checkOn = input.value !== "";
  6326. // Support: IE <=11 only
  6327. // Must access selectedIndex to make default options select
  6328. support.optSelected = opt.selected;
  6329. // Support: IE <=11 only
  6330. // An input loses its value after becoming a radio
  6331. input = document.createElement( "input" );
  6332. input.value = "t";
  6333. input.type = "radio";
  6334. support.radioValue = input.value === "t";
  6335. } )();
  6336. var boolHook,
  6337. attrHandle = jQuery.expr.attrHandle;
  6338. jQuery.fn.extend( {
  6339. attr: function( name, value ) {
  6340. return access( this, jQuery.attr, name, value, arguments.length > 1 );
  6341. },
  6342. removeAttr: function( name ) {
  6343. return this.each( function() {
  6344. jQuery.removeAttr( this, name );
  6345. } );
  6346. }
  6347. } );
  6348. jQuery.extend( {
  6349. attr: function( elem, name, value ) {
  6350. var ret, hooks,
  6351. nType = elem.nodeType;
  6352. // Don't get/set attributes on text, comment and attribute nodes
  6353. if ( nType === 3 || nType === 8 || nType === 2 ) {
  6354. return;
  6355. }
  6356. // Fallback to prop when attributes are not supported
  6357. if ( typeof elem.getAttribute === "undefined" ) {
  6358. return jQuery.prop( elem, name, value );
  6359. }
  6360. // Attribute hooks are determined by the lowercase version
  6361. // Grab necessary hook if one is defined
  6362. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  6363. hooks = jQuery.attrHooks[ name.toLowerCase() ] ||
  6364. ( jQuery.expr.match.bool.test( name ) ? boolHook : undefined );
  6365. }
  6366. if ( value !== undefined ) {
  6367. if ( value === null ) {
  6368. jQuery.removeAttr( elem, name );
  6369. return;
  6370. }
  6371. if ( hooks && "set" in hooks &&
  6372. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  6373. return ret;
  6374. }
  6375. elem.setAttribute( name, value + "" );
  6376. return value;
  6377. }
  6378. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  6379. return ret;
  6380. }
  6381. ret = jQuery.find.attr( elem, name );
  6382. // Non-existent attributes return null, we normalize to undefined
  6383. return ret == null ? undefined : ret;
  6384. },
  6385. attrHooks: {
  6386. type: {
  6387. set: function( elem, value ) {
  6388. if ( !support.radioValue && value === "radio" &&
  6389. nodeName( elem, "input" ) ) {
  6390. var val = elem.value;
  6391. elem.setAttribute( "type", value );
  6392. if ( val ) {
  6393. elem.value = val;
  6394. }
  6395. return value;
  6396. }
  6397. }
  6398. }
  6399. },
  6400. removeAttr: function( elem, value ) {
  6401. var name,
  6402. i = 0,
  6403. // Attribute names can contain non-HTML whitespace characters
  6404. // https://html.spec.whatwg.org/multipage/syntax.html#attributes-2
  6405. attrNames = value && value.match( rnothtmlwhite );
  6406. if ( attrNames && elem.nodeType === 1 ) {
  6407. while ( ( name = attrNames[ i++ ] ) ) {
  6408. elem.removeAttribute( name );
  6409. }
  6410. }
  6411. }
  6412. } );
  6413. // Hooks for boolean attributes
  6414. boolHook = {
  6415. set: function( elem, value, name ) {
  6416. if ( value === false ) {
  6417. // Remove boolean attributes when set to false
  6418. jQuery.removeAttr( elem, name );
  6419. } else {
  6420. elem.setAttribute( name, name );
  6421. }
  6422. return name;
  6423. }
  6424. };
  6425. jQuery.each( jQuery.expr.match.bool.source.match( /\w+/g ), function( i, name ) {
  6426. var getter = attrHandle[ name ] || jQuery.find.attr;
  6427. attrHandle[ name ] = function( elem, name, isXML ) {
  6428. var ret, handle,
  6429. lowercaseName = name.toLowerCase();
  6430. if ( !isXML ) {
  6431. // Avoid an infinite loop by temporarily removing this function from the getter
  6432. handle = attrHandle[ lowercaseName ];
  6433. attrHandle[ lowercaseName ] = ret;
  6434. ret = getter( elem, name, isXML ) != null ?
  6435. lowercaseName :
  6436. null;
  6437. attrHandle[ lowercaseName ] = handle;
  6438. }
  6439. return ret;
  6440. };
  6441. } );
  6442. var rfocusable = /^(?:input|select|textarea|button)$/i,
  6443. rclickable = /^(?:a|area)$/i;
  6444. jQuery.fn.extend( {
  6445. prop: function( name, value ) {
  6446. return access( this, jQuery.prop, name, value, arguments.length > 1 );
  6447. },
  6448. removeProp: function( name ) {
  6449. return this.each( function() {
  6450. delete this[ jQuery.propFix[ name ] || name ];
  6451. } );
  6452. }
  6453. } );
  6454. jQuery.extend( {
  6455. prop: function( elem, name, value ) {
  6456. var ret, hooks,
  6457. nType = elem.nodeType;
  6458. // Don't get/set properties on text, comment and attribute nodes
  6459. if ( nType === 3 || nType === 8 || nType === 2 ) {
  6460. return;
  6461. }
  6462. if ( nType !== 1 || !jQuery.isXMLDoc( elem ) ) {
  6463. // Fix name and attach hooks
  6464. name = jQuery.propFix[ name ] || name;
  6465. hooks = jQuery.propHooks[ name ];
  6466. }
  6467. if ( value !== undefined ) {
  6468. if ( hooks && "set" in hooks &&
  6469. ( ret = hooks.set( elem, value, name ) ) !== undefined ) {
  6470. return ret;
  6471. }
  6472. return ( elem[ name ] = value );
  6473. }
  6474. if ( hooks && "get" in hooks && ( ret = hooks.get( elem, name ) ) !== null ) {
  6475. return ret;
  6476. }
  6477. return elem[ name ];
  6478. },
  6479. propHooks: {
  6480. tabIndex: {
  6481. get: function( elem ) {
  6482. // Support: IE <=9 - 11 only
  6483. // elem.tabIndex doesn't always return the
  6484. // correct value when it hasn't been explicitly set
  6485. // https://web.archive.org/web/20141116233347/http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
  6486. // Use proper attribute retrieval(#12072)
  6487. var tabindex = jQuery.find.attr( elem, "tabindex" );
  6488. if ( tabindex ) {
  6489. return parseInt( tabindex, 10 );
  6490. }
  6491. if (
  6492. rfocusable.test( elem.nodeName ) ||
  6493. rclickable.test( elem.nodeName ) &&
  6494. elem.href
  6495. ) {
  6496. return 0;
  6497. }
  6498. return -1;
  6499. }
  6500. }
  6501. },
  6502. propFix: {
  6503. "for": "htmlFor",
  6504. "class": "className"
  6505. }
  6506. } );
  6507. // Support: IE <=11 only
  6508. // Accessing the selectedIndex property
  6509. // forces the browser to respect setting selected
  6510. // on the option
  6511. // The getter ensures a default option is selected
  6512. // when in an optgroup
  6513. // eslint rule "no-unused-expressions" is disabled for this code
  6514. // since it considers such accessions noop
  6515. if ( !support.optSelected ) {
  6516. jQuery.propHooks.selected = {
  6517. get: function( elem ) {
  6518. /* eslint no-unused-expressions: "off" */
  6519. var parent = elem.parentNode;
  6520. if ( parent && parent.parentNode ) {
  6521. parent.parentNode.selectedIndex;
  6522. }
  6523. return null;
  6524. },
  6525. set: function( elem ) {
  6526. /* eslint no-unused-expressions: "off" */
  6527. var parent = elem.parentNode;
  6528. if ( parent ) {
  6529. parent.selectedIndex;
  6530. if ( parent.parentNode ) {
  6531. parent.parentNode.selectedIndex;
  6532. }
  6533. }
  6534. }
  6535. };
  6536. }
  6537. jQuery.each( [
  6538. "tabIndex",
  6539. "readOnly",
  6540. "maxLength",
  6541. "cellSpacing",
  6542. "cellPadding",
  6543. "rowSpan",
  6544. "colSpan",
  6545. "useMap",
  6546. "frameBorder",
  6547. "contentEditable"
  6548. ], function() {
  6549. jQuery.propFix[ this.toLowerCase() ] = this;
  6550. } );
  6551. // Strip and collapse whitespace according to HTML spec
  6552. // https://infra.spec.whatwg.org/#strip-and-collapse-ascii-whitespace
  6553. function stripAndCollapse( value ) {
  6554. var tokens = value.match( rnothtmlwhite ) || [];
  6555. return tokens.join( " " );
  6556. }
  6557. function getClass( elem ) {
  6558. return elem.getAttribute && elem.getAttribute( "class" ) || "";
  6559. }
  6560. function classesToArray( value ) {
  6561. if ( Array.isArray( value ) ) {
  6562. return value;
  6563. }
  6564. if ( typeof value === "string" ) {
  6565. return value.match( rnothtmlwhite ) || [];
  6566. }
  6567. return [];
  6568. }
  6569. jQuery.fn.extend( {
  6570. addClass: function( value ) {
  6571. var classes, elem, cur, curValue, clazz, j, finalValue,
  6572. i = 0;
  6573. if ( isFunction( value ) ) {
  6574. return this.each( function( j ) {
  6575. jQuery( this ).addClass( value.call( this, j, getClass( this ) ) );
  6576. } );
  6577. }
  6578. classes = classesToArray( value );
  6579. if ( classes.length ) {
  6580. while ( ( elem = this[ i++ ] ) ) {
  6581. curValue = getClass( elem );
  6582. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  6583. if ( cur ) {
  6584. j = 0;
  6585. while ( ( clazz = classes[ j++ ] ) ) {
  6586. if ( cur.indexOf( " " + clazz + " " ) < 0 ) {
  6587. cur += clazz + " ";
  6588. }
  6589. }
  6590. // Only assign if different to avoid unneeded rendering.
  6591. finalValue = stripAndCollapse( cur );
  6592. if ( curValue !== finalValue ) {
  6593. elem.setAttribute( "class", finalValue );
  6594. }
  6595. }
  6596. }
  6597. }
  6598. return this;
  6599. },
  6600. removeClass: function( value ) {
  6601. var classes, elem, cur, curValue, clazz, j, finalValue,
  6602. i = 0;
  6603. if ( isFunction( value ) ) {
  6604. return this.each( function( j ) {
  6605. jQuery( this ).removeClass( value.call( this, j, getClass( this ) ) );
  6606. } );
  6607. }
  6608. if ( !arguments.length ) {
  6609. return this.attr( "class", "" );
  6610. }
  6611. classes = classesToArray( value );
  6612. if ( classes.length ) {
  6613. while ( ( elem = this[ i++ ] ) ) {
  6614. curValue = getClass( elem );
  6615. // This expression is here for better compressibility (see addClass)
  6616. cur = elem.nodeType === 1 && ( " " + stripAndCollapse( curValue ) + " " );
  6617. if ( cur ) {
  6618. j = 0;
  6619. while ( ( clazz = classes[ j++ ] ) ) {
  6620. // Remove *all* instances
  6621. while ( cur.indexOf( " " + clazz + " " ) > -1 ) {
  6622. cur = cur.replace( " " + clazz + " ", " " );
  6623. }
  6624. }
  6625. // Only assign if different to avoid unneeded rendering.
  6626. finalValue = stripAndCollapse( cur );
  6627. if ( curValue !== finalValue ) {
  6628. elem.setAttribute( "class", finalValue );
  6629. }
  6630. }
  6631. }
  6632. }
  6633. return this;
  6634. },
  6635. toggleClass: function( value, stateVal ) {
  6636. var type = typeof value,
  6637. isValidValue = type === "string" || Array.isArray( value );
  6638. if ( typeof stateVal === "boolean" && isValidValue ) {
  6639. return stateVal ? this.addClass( value ) : this.removeClass( value );
  6640. }
  6641. if ( isFunction( value ) ) {
  6642. return this.each( function( i ) {
  6643. jQuery( this ).toggleClass(
  6644. value.call( this, i, getClass( this ), stateVal ),
  6645. stateVal
  6646. );
  6647. } );
  6648. }
  6649. return this.each( function() {
  6650. var className, i, self, classNames;
  6651. if ( isValidValue ) {
  6652. // Toggle individual class names
  6653. i = 0;
  6654. self = jQuery( this );
  6655. classNames = classesToArray( value );
  6656. while ( ( className = classNames[ i++ ] ) ) {
  6657. // Check each className given, space separated list
  6658. if ( self.hasClass( className ) ) {
  6659. self.removeClass( className );
  6660. } else {
  6661. self.addClass( className );
  6662. }
  6663. }
  6664. // Toggle whole class name
  6665. } else if ( value === undefined || type === "boolean" ) {
  6666. className = getClass( this );
  6667. if ( className ) {
  6668. // Store className if set
  6669. dataPriv.set( this, "__className__", className );
  6670. }
  6671. // If the element has a class name or if we're passed `false`,
  6672. // then remove the whole classname (if there was one, the above saved it).
  6673. // Otherwise bring back whatever was previously saved (if anything),
  6674. // falling back to the empty string if nothing was stored.
  6675. if ( this.setAttribute ) {
  6676. this.setAttribute( "class",
  6677. className || value === false ?
  6678. "" :
  6679. dataPriv.get( this, "__className__" ) || ""
  6680. );
  6681. }
  6682. }
  6683. } );
  6684. },
  6685. hasClass: function( selector ) {
  6686. var className, elem,
  6687. i = 0;
  6688. className = " " + selector + " ";
  6689. while ( ( elem = this[ i++ ] ) ) {
  6690. if ( elem.nodeType === 1 &&
  6691. ( " " + stripAndCollapse( getClass( elem ) ) + " " ).indexOf( className ) > -1 ) {
  6692. return true;
  6693. }
  6694. }
  6695. return false;
  6696. }
  6697. } );
  6698. var rreturn = /\r/g;
  6699. jQuery.fn.extend( {
  6700. val: function( value ) {
  6701. var hooks, ret, valueIsFunction,
  6702. elem = this[ 0 ];
  6703. if ( !arguments.length ) {
  6704. if ( elem ) {
  6705. hooks = jQuery.valHooks[ elem.type ] ||
  6706. jQuery.valHooks[ elem.nodeName.toLowerCase() ];
  6707. if ( hooks &&
  6708. "get" in hooks &&
  6709. ( ret = hooks.get( elem, "value" ) ) !== undefined
  6710. ) {
  6711. return ret;
  6712. }
  6713. ret = elem.value;
  6714. // Handle most common string cases
  6715. if ( typeof ret === "string" ) {
  6716. return ret.replace( rreturn, "" );
  6717. }
  6718. // Handle cases where value is null/undef or number
  6719. return ret == null ? "" : ret;
  6720. }
  6721. return;
  6722. }
  6723. valueIsFunction = isFunction( value );
  6724. return this.each( function( i ) {
  6725. var val;
  6726. if ( this.nodeType !== 1 ) {
  6727. return;
  6728. }
  6729. if ( valueIsFunction ) {
  6730. val = value.call( this, i, jQuery( this ).val() );
  6731. } else {
  6732. val = value;
  6733. }
  6734. // Treat null/undefined as ""; convert numbers to string
  6735. if ( val == null ) {
  6736. val = "";
  6737. } else if ( typeof val === "number" ) {
  6738. val += "";
  6739. } else if ( Array.isArray( val ) ) {
  6740. val = jQuery.map( val, function( value ) {
  6741. return value == null ? "" : value + "";
  6742. } );
  6743. }
  6744. hooks = jQuery.valHooks[ this.type ] || jQuery.valHooks[ this.nodeName.toLowerCase() ];
  6745. // If set returns undefined, fall back to normal setting
  6746. if ( !hooks || !( "set" in hooks ) || hooks.set( this, val, "value" ) === undefined ) {
  6747. this.value = val;
  6748. }
  6749. } );
  6750. }
  6751. } );
  6752. jQuery.extend( {
  6753. valHooks: {
  6754. option: {
  6755. get: function( elem ) {
  6756. var val = jQuery.find.attr( elem, "value" );
  6757. return val != null ?
  6758. val :
  6759. // Support: IE <=10 - 11 only
  6760. // option.text throws exceptions (#14686, #14858)
  6761. // Strip and collapse whitespace
  6762. // https://html.spec.whatwg.org/#strip-and-collapse-whitespace
  6763. stripAndCollapse( jQuery.text( elem ) );
  6764. }
  6765. },
  6766. select: {
  6767. get: function( elem ) {
  6768. var value, option, i,
  6769. options = elem.options,
  6770. index = elem.selectedIndex,
  6771. one = elem.type === "select-one",
  6772. values = one ? null : [],
  6773. max = one ? index + 1 : options.length;
  6774. if ( index < 0 ) {
  6775. i = max;
  6776. } else {
  6777. i = one ? index : 0;
  6778. }
  6779. // Loop through all the selected options
  6780. for ( ; i < max; i++ ) {
  6781. option = options[ i ];
  6782. // Support: IE <=9 only
  6783. // IE8-9 doesn't update selected after form reset (#2551)
  6784. if ( ( option.selected || i === index ) &&
  6785. // Don't return options that are disabled or in a disabled optgroup
  6786. !option.disabled &&
  6787. ( !option.parentNode.disabled ||
  6788. !nodeName( option.parentNode, "optgroup" ) ) ) {
  6789. // Get the specific value for the option
  6790. value = jQuery( option ).val();
  6791. // We don't need an array for one selects
  6792. if ( one ) {
  6793. return value;
  6794. }
  6795. // Multi-Selects return an array
  6796. values.push( value );
  6797. }
  6798. }
  6799. return values;
  6800. },
  6801. set: function( elem, value ) {
  6802. var optionSet, option,
  6803. options = elem.options,
  6804. values = jQuery.makeArray( value ),
  6805. i = options.length;
  6806. while ( i-- ) {
  6807. option = options[ i ];
  6808. /* eslint-disable no-cond-assign */
  6809. if ( option.selected =
  6810. jQuery.inArray( jQuery.valHooks.option.get( option ), values ) > -1
  6811. ) {
  6812. optionSet = true;
  6813. }
  6814. /* eslint-enable no-cond-assign */
  6815. }
  6816. // Force browsers to behave consistently when non-matching value is set
  6817. if ( !optionSet ) {
  6818. elem.selectedIndex = -1;
  6819. }
  6820. return values;
  6821. }
  6822. }
  6823. }
  6824. } );
  6825. // Radios and checkboxes getter/setter
  6826. jQuery.each( [ "radio", "checkbox" ], function() {
  6827. jQuery.valHooks[ this ] = {
  6828. set: function( elem, value ) {
  6829. if ( Array.isArray( value ) ) {
  6830. return ( elem.checked = jQuery.inArray( jQuery( elem ).val(), value ) > -1 );
  6831. }
  6832. }
  6833. };
  6834. if ( !support.checkOn ) {
  6835. jQuery.valHooks[ this ].get = function( elem ) {
  6836. return elem.getAttribute( "value" ) === null ? "on" : elem.value;
  6837. };
  6838. }
  6839. } );
  6840. // Return jQuery for attributes-only inclusion
  6841. support.focusin = "onfocusin" in window;
  6842. var rfocusMorph = /^(?:focusinfocus|focusoutblur)$/,
  6843. stopPropagationCallback = function( e ) {
  6844. e.stopPropagation();
  6845. };
  6846. jQuery.extend( jQuery.event, {
  6847. trigger: function( event, data, elem, onlyHandlers ) {
  6848. var i, cur, tmp, bubbleType, ontype, handle, special, lastElement,
  6849. eventPath = [ elem || document ],
  6850. type = hasOwn.call( event, "type" ) ? event.type : event,
  6851. namespaces = hasOwn.call( event, "namespace" ) ? event.namespace.split( "." ) : [];
  6852. cur = lastElement = tmp = elem = elem || document;
  6853. // Don't do events on text and comment nodes
  6854. if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
  6855. return;
  6856. }
  6857. // focus/blur morphs to focusin/out; ensure we're not firing them right now
  6858. if ( rfocusMorph.test( type + jQuery.event.triggered ) ) {
  6859. return;
  6860. }
  6861. if ( type.indexOf( "." ) > -1 ) {
  6862. // Namespaced trigger; create a regexp to match event type in handle()
  6863. namespaces = type.split( "." );
  6864. type = namespaces.shift();
  6865. namespaces.sort();
  6866. }
  6867. ontype = type.indexOf( ":" ) < 0 && "on" + type;
  6868. // Caller can pass in a jQuery.Event object, Object, or just an event type string
  6869. event = event[ jQuery.expando ] ?
  6870. event :
  6871. new jQuery.Event( type, typeof event === "object" && event );
  6872. // Trigger bitmask: & 1 for native handlers; & 2 for jQuery (always true)
  6873. event.isTrigger = onlyHandlers ? 2 : 3;
  6874. event.namespace = namespaces.join( "." );
  6875. event.rnamespace = event.namespace ?
  6876. new RegExp( "(^|\\.)" + namespaces.join( "\\.(?:.*\\.|)" ) + "(\\.|$)" ) :
  6877. null;
  6878. // Clean up the event in case it is being reused
  6879. event.result = undefined;
  6880. if ( !event.target ) {
  6881. event.target = elem;
  6882. }
  6883. // Clone any incoming data and prepend the event, creating the handler arg list
  6884. data = data == null ?
  6885. [ event ] :
  6886. jQuery.makeArray( data, [ event ] );
  6887. // Allow special events to draw outside the lines
  6888. special = jQuery.event.special[ type ] || {};
  6889. if ( !onlyHandlers && special.trigger && special.trigger.apply( elem, data ) === false ) {
  6890. return;
  6891. }
  6892. // Determine event propagation path in advance, per W3C events spec (#9951)
  6893. // Bubble up to document, then to window; watch for a global ownerDocument var (#9724)
  6894. if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) {
  6895. bubbleType = special.delegateType || type;
  6896. if ( !rfocusMorph.test( bubbleType + type ) ) {
  6897. cur = cur.parentNode;
  6898. }
  6899. for ( ; cur; cur = cur.parentNode ) {
  6900. eventPath.push( cur );
  6901. tmp = cur;
  6902. }
  6903. // Only add window if we got to document (e.g., not plain obj or detached DOM)
  6904. if ( tmp === ( elem.ownerDocument || document ) ) {
  6905. eventPath.push( tmp.defaultView || tmp.parentWindow || window );
  6906. }
  6907. }
  6908. // Fire handlers on the event path
  6909. i = 0;
  6910. while ( ( cur = eventPath[ i++ ] ) && !event.isPropagationStopped() ) {
  6911. lastElement = cur;
  6912. event.type = i > 1 ?
  6913. bubbleType :
  6914. special.bindType || type;
  6915. // jQuery handler
  6916. handle = ( dataPriv.get( cur, "events" ) || {} )[ event.type ] &&
  6917. dataPriv.get( cur, "handle" );
  6918. if ( handle ) {
  6919. handle.apply( cur, data );
  6920. }
  6921. // Native handler
  6922. handle = ontype && cur[ ontype ];
  6923. if ( handle && handle.apply && acceptData( cur ) ) {
  6924. event.result = handle.apply( cur, data );
  6925. if ( event.result === false ) {
  6926. event.preventDefault();
  6927. }
  6928. }
  6929. }
  6930. event.type = type;
  6931. // If nobody prevented the default action, do it now
  6932. if ( !onlyHandlers && !event.isDefaultPrevented() ) {
  6933. if ( ( !special._default ||
  6934. special._default.apply( eventPath.pop(), data ) === false ) &&
  6935. acceptData( elem ) ) {
  6936. // Call a native DOM method on the target with the same name as the event.
  6937. // Don't do default actions on window, that's where global variables be (#6170)
  6938. if ( ontype && isFunction( elem[ type ] ) && !isWindow( elem ) ) {
  6939. // Don't re-trigger an onFOO event when we call its FOO() method
  6940. tmp = elem[ ontype ];
  6941. if ( tmp ) {
  6942. elem[ ontype ] = null;
  6943. }
  6944. // Prevent re-triggering of the same event, since we already bubbled it above
  6945. jQuery.event.triggered = type;
  6946. if ( event.isPropagationStopped() ) {
  6947. lastElement.addEventListener( type, stopPropagationCallback );
  6948. }
  6949. elem[ type ]();
  6950. if ( event.isPropagationStopped() ) {
  6951. lastElement.removeEventListener( type, stopPropagationCallback );
  6952. }
  6953. jQuery.event.triggered = undefined;
  6954. if ( tmp ) {
  6955. elem[ ontype ] = tmp;
  6956. }
  6957. }
  6958. }
  6959. }
  6960. return event.result;
  6961. },
  6962. // Piggyback on a donor event to simulate a different one
  6963. // Used only for `focus(in | out)` events
  6964. simulate: function( type, elem, event ) {
  6965. var e = jQuery.extend(
  6966. new jQuery.Event(),
  6967. event,
  6968. {
  6969. type: type,
  6970. isSimulated: true
  6971. }
  6972. );
  6973. jQuery.event.trigger( e, null, elem );
  6974. }
  6975. } );
  6976. jQuery.fn.extend( {
  6977. trigger: function( type, data ) {
  6978. return this.each( function() {
  6979. jQuery.event.trigger( type, data, this );
  6980. } );
  6981. },
  6982. triggerHandler: function( type, data ) {
  6983. var elem = this[ 0 ];
  6984. if ( elem ) {
  6985. return jQuery.event.trigger( type, data, elem, true );
  6986. }
  6987. }
  6988. } );
  6989. // Support: Firefox <=44
  6990. // Firefox doesn't have focus(in | out) events
  6991. // Related ticket - https://bugzilla.mozilla.org/show_bug.cgi?id=687787
  6992. //
  6993. // Support: Chrome <=48 - 49, Safari <=9.0 - 9.1
  6994. // focus(in | out) events fire after focus & blur events,
  6995. // which is spec violation - http://www.w3.org/TR/DOM-Level-3-Events/#events-focusevent-event-order
  6996. // Related ticket - https://bugs.chromium.org/p/chromium/issues/detail?id=449857
  6997. if ( !support.focusin ) {
  6998. jQuery.each( { focus: "focusin", blur: "focusout" }, function( orig, fix ) {
  6999. // Attach a single capturing handler on the document while someone wants focusin/focusout
  7000. var handler = function( event ) {
  7001. jQuery.event.simulate( fix, event.target, jQuery.event.fix( event ) );
  7002. };
  7003. jQuery.event.special[ fix ] = {
  7004. setup: function() {
  7005. var doc = this.ownerDocument || this,
  7006. attaches = dataPriv.access( doc, fix );
  7007. if ( !attaches ) {
  7008. doc.addEventListener( orig, handler, true );
  7009. }
  7010. dataPriv.access( doc, fix, ( attaches || 0 ) + 1 );
  7011. },
  7012. teardown: function() {
  7013. var doc = this.ownerDocument || this,
  7014. attaches = dataPriv.access( doc, fix ) - 1;
  7015. if ( !attaches ) {
  7016. doc.removeEventListener( orig, handler, true );
  7017. dataPriv.remove( doc, fix );
  7018. } else {
  7019. dataPriv.access( doc, fix, attaches );
  7020. }
  7021. }
  7022. };
  7023. } );
  7024. }
  7025. var location = window.location;
  7026. var nonce = Date.now();
  7027. var rquery = ( /\?/ );
  7028. // Cross-browser xml parsing
  7029. jQuery.parseXML = function( data ) {
  7030. var xml;
  7031. if ( !data || typeof data !== "string" ) {
  7032. return null;
  7033. }
  7034. // Support: IE 9 - 11 only
  7035. // IE throws on parseFromString with invalid input.
  7036. try {
  7037. xml = ( new window.DOMParser() ).parseFromString( data, "text/xml" );
  7038. } catch ( e ) {
  7039. xml = undefined;
  7040. }
  7041. if ( !xml || xml.getElementsByTagName( "parsererror" ).length ) {
  7042. jQuery.error( "Invalid XML: " + data );
  7043. }
  7044. return xml;
  7045. };
  7046. var
  7047. rbracket = /\[\]$/,
  7048. rCRLF = /\r?\n/g,
  7049. rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
  7050. rsubmittable = /^(?:input|select|textarea|keygen)/i;
  7051. function buildParams( prefix, obj, traditional, add ) {
  7052. var name;
  7053. if ( Array.isArray( obj ) ) {
  7054. // Serialize array item.
  7055. jQuery.each( obj, function( i, v ) {
  7056. if ( traditional || rbracket.test( prefix ) ) {
  7057. // Treat each array item as a scalar.
  7058. add( prefix, v );
  7059. } else {
  7060. // Item is non-scalar (array or object), encode its numeric index.
  7061. buildParams(
  7062. prefix + "[" + ( typeof v === "object" && v != null ? i : "" ) + "]",
  7063. v,
  7064. traditional,
  7065. add
  7066. );
  7067. }
  7068. } );
  7069. } else if ( !traditional && toType( obj ) === "object" ) {
  7070. // Serialize object item.
  7071. for ( name in obj ) {
  7072. buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
  7073. }
  7074. } else {
  7075. // Serialize scalar item.
  7076. add( prefix, obj );
  7077. }
  7078. }
  7079. // Serialize an array of form elements or a set of
  7080. // key/values into a query string
  7081. jQuery.param = function( a, traditional ) {
  7082. var prefix,
  7083. s = [],
  7084. add = function( key, valueOrFunction ) {
  7085. // If value is a function, invoke it and use its return value
  7086. var value = isFunction( valueOrFunction ) ?
  7087. valueOrFunction() :
  7088. valueOrFunction;
  7089. s[ s.length ] = encodeURIComponent( key ) + "=" +
  7090. encodeURIComponent( value == null ? "" : value );
  7091. };
  7092. if ( a == null ) {
  7093. return "";
  7094. }
  7095. // If an array was passed in, assume that it is an array of form elements.
  7096. if ( Array.isArray( a ) || ( a.jquery && !jQuery.isPlainObject( a ) ) ) {
  7097. // Serialize the form elements
  7098. jQuery.each( a, function() {
  7099. add( this.name, this.value );
  7100. } );
  7101. } else {
  7102. // If traditional, encode the "old" way (the way 1.3.2 or older
  7103. // did it), otherwise encode params recursively.
  7104. for ( prefix in a ) {
  7105. buildParams( prefix, a[ prefix ], traditional, add );
  7106. }
  7107. }
  7108. // Return the resulting serialization
  7109. return s.join( "&" );
  7110. };
  7111. jQuery.fn.extend( {
  7112. serialize: function() {
  7113. return jQuery.param( this.serializeArray() );
  7114. },
  7115. serializeArray: function() {
  7116. return this.map( function() {
  7117. // Can add propHook for "elements" to filter or add form elements
  7118. var elements = jQuery.prop( this, "elements" );
  7119. return elements ? jQuery.makeArray( elements ) : this;
  7120. } )
  7121. .filter( function() {
  7122. var type = this.type;
  7123. // Use .is( ":disabled" ) so that fieldset[disabled] works
  7124. return this.name && !jQuery( this ).is( ":disabled" ) &&
  7125. rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
  7126. ( this.checked || !rcheckableType.test( type ) );
  7127. } )
  7128. .map( function( i, elem ) {
  7129. var val = jQuery( this ).val();
  7130. if ( val == null ) {
  7131. return null;
  7132. }
  7133. if ( Array.isArray( val ) ) {
  7134. return jQuery.map( val, function( val ) {
  7135. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7136. } );
  7137. }
  7138. return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
  7139. } ).get();
  7140. }
  7141. } );
  7142. var
  7143. r20 = /%20/g,
  7144. rhash = /#.*$/,
  7145. rantiCache = /([?&])_=[^&]*/,
  7146. rheaders = /^(.*?):[ \t]*([^\r\n]*)$/mg,
  7147. // #7653, #8125, #8152: local protocol detection
  7148. rlocalProtocol = /^(?:about|app|app-storage|.+-extension|file|res|widget):$/,
  7149. rnoContent = /^(?:GET|HEAD)$/,
  7150. rprotocol = /^\/\//,
  7151. /* Prefilters
  7152. * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
  7153. * 2) These are called:
  7154. * - BEFORE asking for a transport
  7155. * - AFTER param serialization (s.data is a string if s.processData is true)
  7156. * 3) key is the dataType
  7157. * 4) the catchall symbol "*" can be used
  7158. * 5) execution will start with transport dataType and THEN continue down to "*" if needed
  7159. */
  7160. prefilters = {},
  7161. /* Transports bindings
  7162. * 1) key is the dataType
  7163. * 2) the catchall symbol "*" can be used
  7164. * 3) selection will start with transport dataType and THEN go to "*" if needed
  7165. */
  7166. transports = {},
  7167. // Avoid comment-prolog char sequence (#10098); must appease lint and evade compression
  7168. allTypes = "*/".concat( "*" ),
  7169. // Anchor tag for parsing the document origin
  7170. originAnchor = document.createElement( "a" );
  7171. originAnchor.href = location.href;
  7172. // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
  7173. function addToPrefiltersOrTransports( structure ) {
  7174. // dataTypeExpression is optional and defaults to "*"
  7175. return function( dataTypeExpression, func ) {
  7176. if ( typeof dataTypeExpression !== "string" ) {
  7177. func = dataTypeExpression;
  7178. dataTypeExpression = "*";
  7179. }
  7180. var dataType,
  7181. i = 0,
  7182. dataTypes = dataTypeExpression.toLowerCase().match( rnothtmlwhite ) || [];
  7183. if ( isFunction( func ) ) {
  7184. // For each dataType in the dataTypeExpression
  7185. while ( ( dataType = dataTypes[ i++ ] ) ) {
  7186. // Prepend if requested
  7187. if ( dataType[ 0 ] === "+" ) {
  7188. dataType = dataType.slice( 1 ) || "*";
  7189. ( structure[ dataType ] = structure[ dataType ] || [] ).unshift( func );
  7190. // Otherwise append
  7191. } else {
  7192. ( structure[ dataType ] = structure[ dataType ] || [] ).push( func );
  7193. }
  7194. }
  7195. }
  7196. };
  7197. }
  7198. // Base inspection function for prefilters and transports
  7199. function inspectPrefiltersOrTransports( structure, options, originalOptions, jqXHR ) {
  7200. var inspected = {},
  7201. seekingTransport = ( structure === transports );
  7202. function inspect( dataType ) {
  7203. var selected;
  7204. inspected[ dataType ] = true;
  7205. jQuery.each( structure[ dataType ] || [], function( _, prefilterOrFactory ) {
  7206. var dataTypeOrTransport = prefilterOrFactory( options, originalOptions, jqXHR );
  7207. if ( typeof dataTypeOrTransport === "string" &&
  7208. !seekingTransport && !inspected[ dataTypeOrTransport ] ) {
  7209. options.dataTypes.unshift( dataTypeOrTransport );
  7210. inspect( dataTypeOrTransport );
  7211. return false;
  7212. } else if ( seekingTransport ) {
  7213. return !( selected = dataTypeOrTransport );
  7214. }
  7215. } );
  7216. return selected;
  7217. }
  7218. return inspect( options.dataTypes[ 0 ] ) || !inspected[ "*" ] && inspect( "*" );
  7219. }
  7220. // A special extend for ajax options
  7221. // that takes "flat" options (not to be deep extended)
  7222. // Fixes #9887
  7223. function ajaxExtend( target, src ) {
  7224. var key, deep,
  7225. flatOptions = jQuery.ajaxSettings.flatOptions || {};
  7226. for ( key in src ) {
  7227. if ( src[ key ] !== undefined ) {
  7228. ( flatOptions[ key ] ? target : ( deep || ( deep = {} ) ) )[ key ] = src[ key ];
  7229. }
  7230. }
  7231. if ( deep ) {
  7232. jQuery.extend( true, target, deep );
  7233. }
  7234. return target;
  7235. }
  7236. /* Handles responses to an ajax request:
  7237. * - finds the right dataType (mediates between content-type and expected dataType)
  7238. * - returns the corresponding response
  7239. */
  7240. function ajaxHandleResponses( s, jqXHR, responses ) {
  7241. var ct, type, finalDataType, firstDataType,
  7242. contents = s.contents,
  7243. dataTypes = s.dataTypes;
  7244. // Remove auto dataType and get content-type in the process
  7245. while ( dataTypes[ 0 ] === "*" ) {
  7246. dataTypes.shift();
  7247. if ( ct === undefined ) {
  7248. ct = s.mimeType || jqXHR.getResponseHeader( "Content-Type" );
  7249. }
  7250. }
  7251. // Check if we're dealing with a known content-type
  7252. if ( ct ) {
  7253. for ( type in contents ) {
  7254. if ( contents[ type ] && contents[ type ].test( ct ) ) {
  7255. dataTypes.unshift( type );
  7256. break;
  7257. }
  7258. }
  7259. }
  7260. // Check to see if we have a response for the expected dataType
  7261. if ( dataTypes[ 0 ] in responses ) {
  7262. finalDataType = dataTypes[ 0 ];
  7263. } else {
  7264. // Try convertible dataTypes
  7265. for ( type in responses ) {
  7266. if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[ 0 ] ] ) {
  7267. finalDataType = type;
  7268. break;
  7269. }
  7270. if ( !firstDataType ) {
  7271. firstDataType = type;
  7272. }
  7273. }
  7274. // Or just use first one
  7275. finalDataType = finalDataType || firstDataType;
  7276. }
  7277. // If we found a dataType
  7278. // We add the dataType to the list if needed
  7279. // and return the corresponding response
  7280. if ( finalDataType ) {
  7281. if ( finalDataType !== dataTypes[ 0 ] ) {
  7282. dataTypes.unshift( finalDataType );
  7283. }
  7284. return responses[ finalDataType ];
  7285. }
  7286. }
  7287. /* Chain conversions given the request and the original response
  7288. * Also sets the responseXXX fields on the jqXHR instance
  7289. */
  7290. function ajaxConvert( s, response, jqXHR, isSuccess ) {
  7291. var conv2, current, conv, tmp, prev,
  7292. converters = {},
  7293. // Work with a copy of dataTypes in case we need to modify it for conversion
  7294. dataTypes = s.dataTypes.slice();
  7295. // Create converters map with lowercased keys
  7296. if ( dataTypes[ 1 ] ) {
  7297. for ( conv in s.converters ) {
  7298. converters[ conv.toLowerCase() ] = s.converters[ conv ];
  7299. }
  7300. }
  7301. current = dataTypes.shift();
  7302. // Convert to each sequential dataType
  7303. while ( current ) {
  7304. if ( s.responseFields[ current ] ) {
  7305. jqXHR[ s.responseFields[ current ] ] = response;
  7306. }
  7307. // Apply the dataFilter if provided
  7308. if ( !prev && isSuccess && s.dataFilter ) {
  7309. response = s.dataFilter( response, s.dataType );
  7310. }
  7311. prev = current;
  7312. current = dataTypes.shift();
  7313. if ( current ) {
  7314. // There's only work to do if current dataType is non-auto
  7315. if ( current === "*" ) {
  7316. current = prev;
  7317. // Convert response if prev dataType is non-auto and differs from current
  7318. } else if ( prev !== "*" && prev !== current ) {
  7319. // Seek a direct converter
  7320. conv = converters[ prev + " " + current ] || converters[ "* " + current ];
  7321. // If none found, seek a pair
  7322. if ( !conv ) {
  7323. for ( conv2 in converters ) {
  7324. // If conv2 outputs current
  7325. tmp = conv2.split( " " );
  7326. if ( tmp[ 1 ] === current ) {
  7327. // If prev can be converted to accepted input
  7328. conv = converters[ prev + " " + tmp[ 0 ] ] ||
  7329. converters[ "* " + tmp[ 0 ] ];
  7330. if ( conv ) {
  7331. // Condense equivalence converters
  7332. if ( conv === true ) {
  7333. conv = converters[ conv2 ];
  7334. // Otherwise, insert the intermediate dataType
  7335. } else if ( converters[ conv2 ] !== true ) {
  7336. current = tmp[ 0 ];
  7337. dataTypes.unshift( tmp[ 1 ] );
  7338. }
  7339. break;
  7340. }
  7341. }
  7342. }
  7343. }
  7344. // Apply converter (if not an equivalence)
  7345. if ( conv !== true ) {
  7346. // Unless errors are allowed to bubble, catch and return them
  7347. if ( conv && s.throws ) {
  7348. response = conv( response );
  7349. } else {
  7350. try {
  7351. response = conv( response );
  7352. } catch ( e ) {
  7353. return {
  7354. state: "parsererror",
  7355. error: conv ? e : "No conversion from " + prev + " to " + current
  7356. };
  7357. }
  7358. }
  7359. }
  7360. }
  7361. }
  7362. }
  7363. return { state: "success", data: response };
  7364. }
  7365. jQuery.extend( {
  7366. // Counter for holding the number of active queries
  7367. active: 0,
  7368. // Last-Modified header cache for next request
  7369. lastModified: {},
  7370. etag: {},
  7371. ajaxSettings: {
  7372. url: location.href,
  7373. type: "GET",
  7374. isLocal: rlocalProtocol.test( location.protocol ),
  7375. global: true,
  7376. processData: true,
  7377. async: true,
  7378. contentType: "application/x-www-form-urlencoded; charset=UTF-8",
  7379. /*
  7380. timeout: 0,
  7381. data: null,
  7382. dataType: null,
  7383. username: null,
  7384. password: null,
  7385. cache: null,
  7386. throws: false,
  7387. traditional: false,
  7388. headers: {},
  7389. */
  7390. accepts: {
  7391. "*": allTypes,
  7392. text: "text/plain",
  7393. html: "text/html",
  7394. xml: "application/xml, text/xml",
  7395. json: "application/json, text/javascript"
  7396. },
  7397. contents: {
  7398. xml: /\bxml\b/,
  7399. html: /\bhtml/,
  7400. json: /\bjson\b/
  7401. },
  7402. responseFields: {
  7403. xml: "responseXML",
  7404. text: "responseText",
  7405. json: "responseJSON"
  7406. },
  7407. // Data converters
  7408. // Keys separate source (or catchall "*") and destination types with a single space
  7409. converters: {
  7410. // Convert anything to text
  7411. "* text": String,
  7412. // Text to html (true = no transformation)
  7413. "text html": true,
  7414. // Evaluate text as a json expression
  7415. "text json": JSON.parse,
  7416. // Parse text as xml
  7417. "text xml": jQuery.parseXML
  7418. },
  7419. // For options that shouldn't be deep extended:
  7420. // you can add your own custom options here if
  7421. // and when you create one that shouldn't be
  7422. // deep extended (see ajaxExtend)
  7423. flatOptions: {
  7424. url: true,
  7425. context: true
  7426. }
  7427. },
  7428. // Creates a full fledged settings object into target
  7429. // with both ajaxSettings and settings fields.
  7430. // If target is omitted, writes into ajaxSettings.
  7431. ajaxSetup: function( target, settings ) {
  7432. return settings ?
  7433. // Building a settings object
  7434. ajaxExtend( ajaxExtend( target, jQuery.ajaxSettings ), settings ) :
  7435. // Extending ajaxSettings
  7436. ajaxExtend( jQuery.ajaxSettings, target );
  7437. },
  7438. ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
  7439. ajaxTransport: addToPrefiltersOrTransports( transports ),
  7440. // Main method
  7441. ajax: function( url, options ) {
  7442. // If url is an object, simulate pre-1.5 signature
  7443. if ( typeof url === "object" ) {
  7444. options = url;
  7445. url = undefined;
  7446. }
  7447. // Force options to be an object
  7448. options = options || {};
  7449. var transport,
  7450. // URL without anti-cache param
  7451. cacheURL,
  7452. // Response headers
  7453. responseHeadersString,
  7454. responseHeaders,
  7455. // timeout handle
  7456. timeoutTimer,
  7457. // Url cleanup var
  7458. urlAnchor,
  7459. // Request state (becomes false upon send and true upon completion)
  7460. completed,
  7461. // To know if global events are to be dispatched
  7462. fireGlobals,
  7463. // Loop variable
  7464. i,
  7465. // uncached part of the url
  7466. uncached,
  7467. // Create the final options object
  7468. s = jQuery.ajaxSetup( {}, options ),
  7469. // Callbacks context
  7470. callbackContext = s.context || s,
  7471. // Context for global events is callbackContext if it is a DOM node or jQuery collection
  7472. globalEventContext = s.context &&
  7473. ( callbackContext.nodeType || callbackContext.jquery ) ?
  7474. jQuery( callbackContext ) :
  7475. jQuery.event,
  7476. // Deferreds
  7477. deferred = jQuery.Deferred(),
  7478. completeDeferred = jQuery.Callbacks( "once memory" ),
  7479. // Status-dependent callbacks
  7480. statusCode = s.statusCode || {},
  7481. // Headers (they are sent all at once)
  7482. requestHeaders = {},
  7483. requestHeadersNames = {},
  7484. // Default abort message
  7485. strAbort = "canceled",
  7486. // Fake xhr
  7487. jqXHR = {
  7488. readyState: 0,
  7489. // Builds headers hashtable if needed
  7490. getResponseHeader: function( key ) {
  7491. var match;
  7492. if ( completed ) {
  7493. if ( !responseHeaders ) {
  7494. responseHeaders = {};
  7495. while ( ( match = rheaders.exec( responseHeadersString ) ) ) {
  7496. responseHeaders[ match[ 1 ].toLowerCase() + " " ] =
  7497. ( responseHeaders[ match[ 1 ].toLowerCase() + " " ] || [] )
  7498. .concat( match[ 2 ] );
  7499. }
  7500. }
  7501. match = responseHeaders[ key.toLowerCase() + " " ];
  7502. }
  7503. return match == null ? null : match.join( ", " );
  7504. },
  7505. // Raw string
  7506. getAllResponseHeaders: function() {
  7507. return completed ? responseHeadersString : null;
  7508. },
  7509. // Caches the header
  7510. setRequestHeader: function( name, value ) {
  7511. if ( completed == null ) {
  7512. name = requestHeadersNames[ name.toLowerCase() ] =
  7513. requestHeadersNames[ name.toLowerCase() ] || name;
  7514. requestHeaders[ name ] = value;
  7515. }
  7516. return this;
  7517. },
  7518. // Overrides response content-type header
  7519. overrideMimeType: function( type ) {
  7520. if ( completed == null ) {
  7521. s.mimeType = type;
  7522. }
  7523. return this;
  7524. },
  7525. // Status-dependent callbacks
  7526. statusCode: function( map ) {
  7527. var code;
  7528. if ( map ) {
  7529. if ( completed ) {
  7530. // Execute the appropriate callbacks
  7531. jqXHR.always( map[ jqXHR.status ] );
  7532. } else {
  7533. // Lazy-add the new callbacks in a way that preserves old ones
  7534. for ( code in map ) {
  7535. statusCode[ code ] = [ statusCode[ code ], map[ code ] ];
  7536. }
  7537. }
  7538. }
  7539. return this;
  7540. },
  7541. // Cancel the request
  7542. abort: function( statusText ) {
  7543. var finalText = statusText || strAbort;
  7544. if ( transport ) {
  7545. transport.abort( finalText );
  7546. }
  7547. done( 0, finalText );
  7548. return this;
  7549. }
  7550. };
  7551. // Attach deferreds
  7552. deferred.promise( jqXHR );
  7553. // Add protocol if not provided (prefilters might expect it)
  7554. // Handle falsy url in the settings object (#10093: consistency with old signature)
  7555. // We also use the url parameter if available
  7556. s.url = ( ( url || s.url || location.href ) + "" )
  7557. .replace( rprotocol, location.protocol + "//" );
  7558. // Alias method option to type as per ticket #12004
  7559. s.type = options.method || options.type || s.method || s.type;
  7560. // Extract dataTypes list
  7561. s.dataTypes = ( s.dataType || "*" ).toLowerCase().match( rnothtmlwhite ) || [ "" ];
  7562. // A cross-domain request is in order when the origin doesn't match the current origin.
  7563. if ( s.crossDomain == null ) {
  7564. urlAnchor = document.createElement( "a" );
  7565. // Support: IE <=8 - 11, Edge 12 - 15
  7566. // IE throws exception on accessing the href property if url is malformed,
  7567. // e.g. http://example.com:80x/
  7568. try {
  7569. urlAnchor.href = s.url;
  7570. // Support: IE <=8 - 11 only
  7571. // Anchor's host property isn't correctly set when s.url is relative
  7572. urlAnchor.href = urlAnchor.href;
  7573. s.crossDomain = originAnchor.protocol + "//" + originAnchor.host !==
  7574. urlAnchor.protocol + "//" + urlAnchor.host;
  7575. } catch ( e ) {
  7576. // If there is an error parsing the URL, assume it is crossDomain,
  7577. // it can be rejected by the transport if it is invalid
  7578. s.crossDomain = true;
  7579. }
  7580. }
  7581. // Convert data if not already a string
  7582. if ( s.data && s.processData && typeof s.data !== "string" ) {
  7583. s.data = jQuery.param( s.data, s.traditional );
  7584. }
  7585. // Apply prefilters
  7586. inspectPrefiltersOrTransports( prefilters, s, options, jqXHR );
  7587. // If request was aborted inside a prefilter, stop there
  7588. if ( completed ) {
  7589. return jqXHR;
  7590. }
  7591. // We can fire global events as of now if asked to
  7592. // Don't fire events if jQuery.event is undefined in an AMD-usage scenario (#15118)
  7593. fireGlobals = jQuery.event && s.global;
  7594. // Watch for a new set of requests
  7595. if ( fireGlobals && jQuery.active++ === 0 ) {
  7596. jQuery.event.trigger( "ajaxStart" );
  7597. }
  7598. // Uppercase the type
  7599. s.type = s.type.toUpperCase();
  7600. // Determine if request has content
  7601. s.hasContent = !rnoContent.test( s.type );
  7602. // Save the URL in case we're toying with the If-Modified-Since
  7603. // and/or If-None-Match header later on
  7604. // Remove hash to simplify url manipulation
  7605. cacheURL = s.url.replace( rhash, "" );
  7606. // More options handling for requests with no content
  7607. if ( !s.hasContent ) {
  7608. // Remember the hash so we can put it back
  7609. uncached = s.url.slice( cacheURL.length );
  7610. // If data is available and should be processed, append data to url
  7611. if ( s.data && ( s.processData || typeof s.data === "string" ) ) {
  7612. cacheURL += ( rquery.test( cacheURL ) ? "&" : "?" ) + s.data;
  7613. // #9682: remove data so that it's not used in an eventual retry
  7614. delete s.data;
  7615. }
  7616. // Add or update anti-cache param if needed
  7617. if ( s.cache === false ) {
  7618. cacheURL = cacheURL.replace( rantiCache, "$1" );
  7619. uncached = ( rquery.test( cacheURL ) ? "&" : "?" ) + "_=" + ( nonce++ ) + uncached;
  7620. }
  7621. // Put hash and anti-cache on the URL that will be requested (gh-1732)
  7622. s.url = cacheURL + uncached;
  7623. // Change '%20' to '+' if this is encoded form body content (gh-2658)
  7624. } else if ( s.data && s.processData &&
  7625. ( s.contentType || "" ).indexOf( "application/x-www-form-urlencoded" ) === 0 ) {
  7626. s.data = s.data.replace( r20, "+" );
  7627. }
  7628. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7629. if ( s.ifModified ) {
  7630. if ( jQuery.lastModified[ cacheURL ] ) {
  7631. jqXHR.setRequestHeader( "If-Modified-Since", jQuery.lastModified[ cacheURL ] );
  7632. }
  7633. if ( jQuery.etag[ cacheURL ] ) {
  7634. jqXHR.setRequestHeader( "If-None-Match", jQuery.etag[ cacheURL ] );
  7635. }
  7636. }
  7637. // Set the correct header, if data is being sent
  7638. if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
  7639. jqXHR.setRequestHeader( "Content-Type", s.contentType );
  7640. }
  7641. // Set the Accepts header for the server, depending on the dataType
  7642. jqXHR.setRequestHeader(
  7643. "Accept",
  7644. s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[ 0 ] ] ?
  7645. s.accepts[ s.dataTypes[ 0 ] ] +
  7646. ( s.dataTypes[ 0 ] !== "*" ? ", " + allTypes + "; q=0.01" : "" ) :
  7647. s.accepts[ "*" ]
  7648. );
  7649. // Check for headers option
  7650. for ( i in s.headers ) {
  7651. jqXHR.setRequestHeader( i, s.headers[ i ] );
  7652. }
  7653. // Allow custom headers/mimetypes and early abort
  7654. if ( s.beforeSend &&
  7655. ( s.beforeSend.call( callbackContext, jqXHR, s ) === false || completed ) ) {
  7656. // Abort if not done already and return
  7657. return jqXHR.abort();
  7658. }
  7659. // Aborting is no longer a cancellation
  7660. strAbort = "abort";
  7661. // Install callbacks on deferreds
  7662. completeDeferred.add( s.complete );
  7663. jqXHR.done( s.success );
  7664. jqXHR.fail( s.error );
  7665. // Get transport
  7666. transport = inspectPrefiltersOrTransports( transports, s, options, jqXHR );
  7667. // If no transport, we auto-abort
  7668. if ( !transport ) {
  7669. done( -1, "No Transport" );
  7670. } else {
  7671. jqXHR.readyState = 1;
  7672. // Send global event
  7673. if ( fireGlobals ) {
  7674. globalEventContext.trigger( "ajaxSend", [ jqXHR, s ] );
  7675. }
  7676. // If request was aborted inside ajaxSend, stop there
  7677. if ( completed ) {
  7678. return jqXHR;
  7679. }
  7680. // Timeout
  7681. if ( s.async && s.timeout > 0 ) {
  7682. timeoutTimer = window.setTimeout( function() {
  7683. jqXHR.abort( "timeout" );
  7684. }, s.timeout );
  7685. }
  7686. try {
  7687. completed = false;
  7688. transport.send( requestHeaders, done );
  7689. } catch ( e ) {
  7690. // Rethrow post-completion exceptions
  7691. if ( completed ) {
  7692. throw e;
  7693. }
  7694. // Propagate others as results
  7695. done( -1, e );
  7696. }
  7697. }
  7698. // Callback for when everything is done
  7699. function done( status, nativeStatusText, responses, headers ) {
  7700. var isSuccess, success, error, response, modified,
  7701. statusText = nativeStatusText;
  7702. // Ignore repeat invocations
  7703. if ( completed ) {
  7704. return;
  7705. }
  7706. completed = true;
  7707. // Clear timeout if it exists
  7708. if ( timeoutTimer ) {
  7709. window.clearTimeout( timeoutTimer );
  7710. }
  7711. // Dereference transport for early garbage collection
  7712. // (no matter how long the jqXHR object will be used)
  7713. transport = undefined;
  7714. // Cache response headers
  7715. responseHeadersString = headers || "";
  7716. // Set readyState
  7717. jqXHR.readyState = status > 0 ? 4 : 0;
  7718. // Determine if successful
  7719. isSuccess = status >= 200 && status < 300 || status === 304;
  7720. // Get response data
  7721. if ( responses ) {
  7722. response = ajaxHandleResponses( s, jqXHR, responses );
  7723. }
  7724. // Convert no matter what (that way responseXXX fields are always set)
  7725. response = ajaxConvert( s, response, jqXHR, isSuccess );
  7726. // If successful, handle type chaining
  7727. if ( isSuccess ) {
  7728. // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
  7729. if ( s.ifModified ) {
  7730. modified = jqXHR.getResponseHeader( "Last-Modified" );
  7731. if ( modified ) {
  7732. jQuery.lastModified[ cacheURL ] = modified;
  7733. }
  7734. modified = jqXHR.getResponseHeader( "etag" );
  7735. if ( modified ) {
  7736. jQuery.etag[ cacheURL ] = modified;
  7737. }
  7738. }
  7739. // if no content
  7740. if ( status === 204 || s.type === "HEAD" ) {
  7741. statusText = "nocontent";
  7742. // if not modified
  7743. } else if ( status === 304 ) {
  7744. statusText = "notmodified";
  7745. // If we have data, let's convert it
  7746. } else {
  7747. statusText = response.state;
  7748. success = response.data;
  7749. error = response.error;
  7750. isSuccess = !error;
  7751. }
  7752. } else {
  7753. // Extract error from statusText and normalize for non-aborts
  7754. error = statusText;
  7755. if ( status || !statusText ) {
  7756. statusText = "error";
  7757. if ( status < 0 ) {
  7758. status = 0;
  7759. }
  7760. }
  7761. }
  7762. // Set data for the fake xhr object
  7763. jqXHR.status = status;
  7764. jqXHR.statusText = ( nativeStatusText || statusText ) + "";
  7765. // Success/Error
  7766. if ( isSuccess ) {
  7767. deferred.resolveWith( callbackContext, [ success, statusText, jqXHR ] );
  7768. } else {
  7769. deferred.rejectWith( callbackContext, [ jqXHR, statusText, error ] );
  7770. }
  7771. // Status-dependent callbacks
  7772. jqXHR.statusCode( statusCode );
  7773. statusCode = undefined;
  7774. if ( fireGlobals ) {
  7775. globalEventContext.trigger( isSuccess ? "ajaxSuccess" : "ajaxError",
  7776. [ jqXHR, s, isSuccess ? success : error ] );
  7777. }
  7778. // Complete
  7779. completeDeferred.fireWith( callbackContext, [ jqXHR, statusText ] );
  7780. if ( fireGlobals ) {
  7781. globalEventContext.trigger( "ajaxComplete", [ jqXHR, s ] );
  7782. // Handle the global AJAX counter
  7783. if ( !( --jQuery.active ) ) {
  7784. jQuery.event.trigger( "ajaxStop" );
  7785. }
  7786. }
  7787. }
  7788. return jqXHR;
  7789. },
  7790. getJSON: function( url, data, callback ) {
  7791. return jQuery.get( url, data, callback, "json" );
  7792. },
  7793. getScript: function( url, callback ) {
  7794. return jQuery.get( url, undefined, callback, "script" );
  7795. }
  7796. } );
  7797. jQuery.each( [ "get", "post" ], function( i, method ) {
  7798. jQuery[ method ] = function( url, data, callback, type ) {
  7799. // Shift arguments if data argument was omitted
  7800. if ( isFunction( data ) ) {
  7801. type = type || callback;
  7802. callback = data;
  7803. data = undefined;
  7804. }
  7805. // The url can be an options object (which then must have .url)
  7806. return jQuery.ajax( jQuery.extend( {
  7807. url: url,
  7808. type: method,
  7809. dataType: type,
  7810. data: data,
  7811. success: callback
  7812. }, jQuery.isPlainObject( url ) && url ) );
  7813. };
  7814. } );
  7815. jQuery._evalUrl = function( url, options ) {
  7816. return jQuery.ajax( {
  7817. url: url,
  7818. // Make this explicit, since user can override this through ajaxSetup (#11264)
  7819. type: "GET",
  7820. dataType: "script",
  7821. cache: true,
  7822. async: false,
  7823. global: false,
  7824. // Only evaluate the response if it is successful (gh-4126)
  7825. // dataFilter is not invoked for failure responses, so using it instead
  7826. // of the default converter is kludgy but it works.
  7827. converters: {
  7828. "text script": function() {}
  7829. },
  7830. dataFilter: function( response ) {
  7831. jQuery.globalEval( response, options );
  7832. }
  7833. } );
  7834. };
  7835. jQuery.fn.extend( {
  7836. wrapAll: function( html ) {
  7837. var wrap;
  7838. if ( this[ 0 ] ) {
  7839. if ( isFunction( html ) ) {
  7840. html = html.call( this[ 0 ] );
  7841. }
  7842. // The elements to wrap the target around
  7843. wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
  7844. if ( this[ 0 ].parentNode ) {
  7845. wrap.insertBefore( this[ 0 ] );
  7846. }
  7847. wrap.map( function() {
  7848. var elem = this;
  7849. while ( elem.firstElementChild ) {
  7850. elem = elem.firstElementChild;
  7851. }
  7852. return elem;
  7853. } ).append( this );
  7854. }
  7855. return this;
  7856. },
  7857. wrapInner: function( html ) {
  7858. if ( isFunction( html ) ) {
  7859. return this.each( function( i ) {
  7860. jQuery( this ).wrapInner( html.call( this, i ) );
  7861. } );
  7862. }
  7863. return this.each( function() {
  7864. var self = jQuery( this ),
  7865. contents = self.contents();
  7866. if ( contents.length ) {
  7867. contents.wrapAll( html );
  7868. } else {
  7869. self.append( html );
  7870. }
  7871. } );
  7872. },
  7873. wrap: function( html ) {
  7874. var htmlIsFunction = isFunction( html );
  7875. return this.each( function( i ) {
  7876. jQuery( this ).wrapAll( htmlIsFunction ? html.call( this, i ) : html );
  7877. } );
  7878. },
  7879. unwrap: function( selector ) {
  7880. this.parent( selector ).not( "body" ).each( function() {
  7881. jQuery( this ).replaceWith( this.childNodes );
  7882. } );
  7883. return this;
  7884. }
  7885. } );
  7886. jQuery.expr.pseudos.hidden = function( elem ) {
  7887. return !jQuery.expr.pseudos.visible( elem );
  7888. };
  7889. jQuery.expr.pseudos.visible = function( elem ) {
  7890. return !!( elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length );
  7891. };
  7892. jQuery.ajaxSettings.xhr = function() {
  7893. try {
  7894. return new window.XMLHttpRequest();
  7895. } catch ( e ) {}
  7896. };
  7897. var xhrSuccessStatus = {
  7898. // File protocol always yields status code 0, assume 200
  7899. 0: 200,
  7900. // Support: IE <=9 only
  7901. // #1450: sometimes IE returns 1223 when it should be 204
  7902. 1223: 204
  7903. },
  7904. xhrSupported = jQuery.ajaxSettings.xhr();
  7905. support.cors = !!xhrSupported && ( "withCredentials" in xhrSupported );
  7906. support.ajax = xhrSupported = !!xhrSupported;
  7907. jQuery.ajaxTransport( function( options ) {
  7908. var callback, errorCallback;
  7909. // Cross domain only allowed if supported through XMLHttpRequest
  7910. if ( support.cors || xhrSupported && !options.crossDomain ) {
  7911. return {
  7912. send: function( headers, complete ) {
  7913. var i,
  7914. xhr = options.xhr();
  7915. xhr.open(
  7916. options.type,
  7917. options.url,
  7918. options.async,
  7919. options.username,
  7920. options.password
  7921. );
  7922. // Apply custom fields if provided
  7923. if ( options.xhrFields ) {
  7924. for ( i in options.xhrFields ) {
  7925. xhr[ i ] = options.xhrFields[ i ];
  7926. }
  7927. }
  7928. // Override mime type if needed
  7929. if ( options.mimeType && xhr.overrideMimeType ) {
  7930. xhr.overrideMimeType( options.mimeType );
  7931. }
  7932. // X-Requested-With header
  7933. // For cross-domain requests, seeing as conditions for a preflight are
  7934. // akin to a jigsaw puzzle, we simply never set it to be sure.
  7935. // (it can always be set on a per-request basis or even using ajaxSetup)
  7936. // For same-domain requests, won't change header if already provided.
  7937. if ( !options.crossDomain && !headers[ "X-Requested-With" ] ) {
  7938. headers[ "X-Requested-With" ] = "XMLHttpRequest";
  7939. }
  7940. // Set headers
  7941. for ( i in headers ) {
  7942. xhr.setRequestHeader( i, headers[ i ] );
  7943. }
  7944. // Callback
  7945. callback = function( type ) {
  7946. return function() {
  7947. if ( callback ) {
  7948. callback = errorCallback = xhr.onload =
  7949. xhr.onerror = xhr.onabort = xhr.ontimeout =
  7950. xhr.onreadystatechange = null;
  7951. if ( type === "abort" ) {
  7952. xhr.abort();
  7953. } else if ( type === "error" ) {
  7954. // Support: IE <=9 only
  7955. // On a manual native abort, IE9 throws
  7956. // errors on any property access that is not readyState
  7957. if ( typeof xhr.status !== "number" ) {
  7958. complete( 0, "error" );
  7959. } else {
  7960. complete(
  7961. // File: protocol always yields status 0; see #8605, #14207
  7962. xhr.status,
  7963. xhr.statusText
  7964. );
  7965. }
  7966. } else {
  7967. complete(
  7968. xhrSuccessStatus[ xhr.status ] || xhr.status,
  7969. xhr.statusText,
  7970. // Support: IE <=9 only
  7971. // IE9 has no XHR2 but throws on binary (trac-11426)
  7972. // For XHR2 non-text, let the caller handle it (gh-2498)
  7973. ( xhr.responseType || "text" ) !== "text" ||
  7974. typeof xhr.responseText !== "string" ?
  7975. { binary: xhr.response } :
  7976. { text: xhr.responseText },
  7977. xhr.getAllResponseHeaders()
  7978. );
  7979. }
  7980. }
  7981. };
  7982. };
  7983. // Listen to events
  7984. xhr.onload = callback();
  7985. errorCallback = xhr.onerror = xhr.ontimeout = callback( "error" );
  7986. // Support: IE 9 only
  7987. // Use onreadystatechange to replace onabort
  7988. // to handle uncaught aborts
  7989. if ( xhr.onabort !== undefined ) {
  7990. xhr.onabort = errorCallback;
  7991. } else {
  7992. xhr.onreadystatechange = function() {
  7993. // Check readyState before timeout as it changes
  7994. if ( xhr.readyState === 4 ) {
  7995. // Allow onerror to be called first,
  7996. // but that will not handle a native abort
  7997. // Also, save errorCallback to a variable
  7998. // as xhr.onerror cannot be accessed
  7999. window.setTimeout( function() {
  8000. if ( callback ) {
  8001. errorCallback();
  8002. }
  8003. } );
  8004. }
  8005. };
  8006. }
  8007. // Create the abort callback
  8008. callback = callback( "abort" );
  8009. try {
  8010. // Do send the request (this may raise an exception)
  8011. xhr.send( options.hasContent && options.data || null );
  8012. } catch ( e ) {
  8013. // #14683: Only rethrow if this hasn't been notified as an error yet
  8014. if ( callback ) {
  8015. throw e;
  8016. }
  8017. }
  8018. },
  8019. abort: function() {
  8020. if ( callback ) {
  8021. callback();
  8022. }
  8023. }
  8024. };
  8025. }
  8026. } );
  8027. // Prevent auto-execution of scripts when no explicit dataType was provided (See gh-2432)
  8028. jQuery.ajaxPrefilter( function( s ) {
  8029. if ( s.crossDomain ) {
  8030. s.contents.script = false;
  8031. }
  8032. } );
  8033. // Install script dataType
  8034. jQuery.ajaxSetup( {
  8035. accepts: {
  8036. script: "text/javascript, application/javascript, " +
  8037. "application/ecmascript, application/x-ecmascript"
  8038. },
  8039. contents: {
  8040. script: /\b(?:java|ecma)script\b/
  8041. },
  8042. converters: {
  8043. "text script": function( text ) {
  8044. jQuery.globalEval( text );
  8045. return text;
  8046. }
  8047. }
  8048. } );
  8049. // Handle cache's special case and crossDomain
  8050. jQuery.ajaxPrefilter( "script", function( s ) {
  8051. if ( s.cache === undefined ) {
  8052. s.cache = false;
  8053. }
  8054. if ( s.crossDomain ) {
  8055. s.type = "GET";
  8056. }
  8057. } );
  8058. // Bind script tag hack transport
  8059. jQuery.ajaxTransport( "script", function( s ) {
  8060. // This transport only deals with cross domain or forced-by-attrs requests
  8061. if ( s.crossDomain || s.scriptAttrs ) {
  8062. var script, callback;
  8063. return {
  8064. send: function( _, complete ) {
  8065. script = jQuery( "<script>" )
  8066. .attr( s.scriptAttrs || {} )
  8067. .prop( { charset: s.scriptCharset, src: s.url } )
  8068. .on( "load error", callback = function( evt ) {
  8069. script.remove();
  8070. callback = null;
  8071. if ( evt ) {
  8072. complete( evt.type === "error" ? 404 : 200, evt.type );
  8073. }
  8074. } );
  8075. // Use native DOM manipulation to avoid our domManip AJAX trickery
  8076. document.head.appendChild( script[ 0 ] );
  8077. },
  8078. abort: function() {
  8079. if ( callback ) {
  8080. callback();
  8081. }
  8082. }
  8083. };
  8084. }
  8085. } );
  8086. var oldCallbacks = [],
  8087. rjsonp = /(=)\?(?=&|$)|\?\?/;
  8088. // Default jsonp settings
  8089. jQuery.ajaxSetup( {
  8090. jsonp: "callback",
  8091. jsonpCallback: function() {
  8092. var callback = oldCallbacks.pop() || ( jQuery.expando + "_" + ( nonce++ ) );
  8093. this[ callback ] = true;
  8094. return callback;
  8095. }
  8096. } );
  8097. // Detect, normalize options and install callbacks for jsonp requests
  8098. jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, jqXHR ) {
  8099. var callbackName, overwritten, responseContainer,
  8100. jsonProp = s.jsonp !== false && ( rjsonp.test( s.url ) ?
  8101. "url" :
  8102. typeof s.data === "string" &&
  8103. ( s.contentType || "" )
  8104. .indexOf( "application/x-www-form-urlencoded" ) === 0 &&
  8105. rjsonp.test( s.data ) && "data"
  8106. );
  8107. // Handle iff the expected data type is "jsonp" or we have a parameter to set
  8108. if ( jsonProp || s.dataTypes[ 0 ] === "jsonp" ) {
  8109. // Get callback name, remembering preexisting value associated with it
  8110. callbackName = s.jsonpCallback = isFunction( s.jsonpCallback ) ?
  8111. s.jsonpCallback() :
  8112. s.jsonpCallback;
  8113. // Insert callback into url or form data
  8114. if ( jsonProp ) {
  8115. s[ jsonProp ] = s[ jsonProp ].replace( rjsonp, "$1" + callbackName );
  8116. } else if ( s.jsonp !== false ) {
  8117. s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.jsonp + "=" + callbackName;
  8118. }
  8119. // Use data converter to retrieve json after script execution
  8120. s.converters[ "script json" ] = function() {
  8121. if ( !responseContainer ) {
  8122. jQuery.error( callbackName + " was not called" );
  8123. }
  8124. return responseContainer[ 0 ];
  8125. };
  8126. // Force json dataType
  8127. s.dataTypes[ 0 ] = "json";
  8128. // Install callback
  8129. overwritten = window[ callbackName ];
  8130. window[ callbackName ] = function() {
  8131. responseContainer = arguments;
  8132. };
  8133. // Clean-up function (fires after converters)
  8134. jqXHR.always( function() {
  8135. // If previous value didn't exist - remove it
  8136. if ( overwritten === undefined ) {
  8137. jQuery( window ).removeProp( callbackName );
  8138. // Otherwise restore preexisting value
  8139. } else {
  8140. window[ callbackName ] = overwritten;
  8141. }
  8142. // Save back as free
  8143. if ( s[ callbackName ] ) {
  8144. // Make sure that re-using the options doesn't screw things around
  8145. s.jsonpCallback = originalSettings.jsonpCallback;
  8146. // Save the callback name for future use
  8147. oldCallbacks.push( callbackName );
  8148. }
  8149. // Call if it was a function and we have a response
  8150. if ( responseContainer && isFunction( overwritten ) ) {
  8151. overwritten( responseContainer[ 0 ] );
  8152. }
  8153. responseContainer = overwritten = undefined;
  8154. } );
  8155. // Delegate to script
  8156. return "script";
  8157. }
  8158. } );
  8159. // Support: Safari 8 only
  8160. // In Safari 8 documents created via document.implementation.createHTMLDocument
  8161. // collapse sibling forms: the second one becomes a child of the first one.
  8162. // Because of that, this security measure has to be disabled in Safari 8.
  8163. // https://bugs.webkit.org/show_bug.cgi?id=137337
  8164. support.createHTMLDocument = ( function() {
  8165. var body = document.implementation.createHTMLDocument( "" ).body;
  8166. body.innerHTML = "<form></form><form></form>";
  8167. return body.childNodes.length === 2;
  8168. } )();
  8169. // Argument "data" should be string of html
  8170. // context (optional): If specified, the fragment will be created in this context,
  8171. // defaults to document
  8172. // keepScripts (optional): If true, will include scripts passed in the html string
  8173. jQuery.parseHTML = function( data, context, keepScripts ) {
  8174. if ( typeof data !== "string" ) {
  8175. return [];
  8176. }
  8177. if ( typeof context === "boolean" ) {
  8178. keepScripts = context;
  8179. context = false;
  8180. }
  8181. var base, parsed, scripts;
  8182. if ( !context ) {
  8183. // Stop scripts or inline event handlers from being executed immediately
  8184. // by using document.implementation
  8185. if ( support.createHTMLDocument ) {
  8186. context = document.implementation.createHTMLDocument( "" );
  8187. // Set the base href for the created document
  8188. // so any parsed elements with URLs
  8189. // are based on the document's URL (gh-2965)
  8190. base = context.createElement( "base" );
  8191. base.href = document.location.href;
  8192. context.head.appendChild( base );
  8193. } else {
  8194. context = document;
  8195. }
  8196. }
  8197. parsed = rsingleTag.exec( data );
  8198. scripts = !keepScripts && [];
  8199. // Single tag
  8200. if ( parsed ) {
  8201. return [ context.createElement( parsed[ 1 ] ) ];
  8202. }
  8203. parsed = buildFragment( [ data ], context, scripts );
  8204. if ( scripts && scripts.length ) {
  8205. jQuery( scripts ).remove();
  8206. }
  8207. return jQuery.merge( [], parsed.childNodes );
  8208. };
  8209. /**
  8210. * Load a url into a page
  8211. */
  8212. jQuery.fn.load = function( url, params, callback ) {
  8213. var selector, type, response,
  8214. self = this,
  8215. off = url.indexOf( " " );
  8216. if ( off > -1 ) {
  8217. selector = stripAndCollapse( url.slice( off ) );
  8218. url = url.slice( 0, off );
  8219. }
  8220. // If it's a function
  8221. if ( isFunction( params ) ) {
  8222. // We assume that it's the callback
  8223. callback = params;
  8224. params = undefined;
  8225. // Otherwise, build a param string
  8226. } else if ( params && typeof params === "object" ) {
  8227. type = "POST";
  8228. }
  8229. // If we have elements to modify, make the request
  8230. if ( self.length > 0 ) {
  8231. jQuery.ajax( {
  8232. url: url,
  8233. // If "type" variable is undefined, then "GET" method will be used.
  8234. // Make value of this field explicit since
  8235. // user can override it through ajaxSetup method
  8236. type: type || "GET",
  8237. dataType: "html",
  8238. data: params
  8239. } ).done( function( responseText ) {
  8240. // Save response for use in complete callback
  8241. response = arguments;
  8242. self.html( selector ?
  8243. // If a selector was specified, locate the right elements in a dummy div
  8244. // Exclude scripts to avoid IE 'Permission Denied' errors
  8245. jQuery( "<div>" ).append( jQuery.parseHTML( responseText ) ).find( selector ) :
  8246. // Otherwise use the full result
  8247. responseText );
  8248. // If the request succeeds, this function gets "data", "status", "jqXHR"
  8249. // but they are ignored because response was set above.
  8250. // If it fails, this function gets "jqXHR", "status", "error"
  8251. } ).always( callback && function( jqXHR, status ) {
  8252. self.each( function() {
  8253. callback.apply( this, response || [ jqXHR.responseText, status, jqXHR ] );
  8254. } );
  8255. } );
  8256. }
  8257. return this;
  8258. };
  8259. // Attach a bunch of functions for handling common AJAX events
  8260. jQuery.each( [
  8261. "ajaxStart",
  8262. "ajaxStop",
  8263. "ajaxComplete",
  8264. "ajaxError",
  8265. "ajaxSuccess",
  8266. "ajaxSend"
  8267. ], function( i, type ) {
  8268. jQuery.fn[ type ] = function( fn ) {
  8269. return this.on( type, fn );
  8270. };
  8271. } );
  8272. jQuery.expr.pseudos.animated = function( elem ) {
  8273. return jQuery.grep( jQuery.timers, function( fn ) {
  8274. return elem === fn.elem;
  8275. } ).length;
  8276. };
  8277. jQuery.offset = {
  8278. setOffset: function( elem, options, i ) {
  8279. var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
  8280. position = jQuery.css( elem, "position" ),
  8281. curElem = jQuery( elem ),
  8282. props = {};
  8283. // Set position first, in-case top/left are set even on static elem
  8284. if ( position === "static" ) {
  8285. elem.style.position = "relative";
  8286. }
  8287. curOffset = curElem.offset();
  8288. curCSSTop = jQuery.css( elem, "top" );
  8289. curCSSLeft = jQuery.css( elem, "left" );
  8290. calculatePosition = ( position === "absolute" || position === "fixed" ) &&
  8291. ( curCSSTop + curCSSLeft ).indexOf( "auto" ) > -1;
  8292. // Need to be able to calculate position if either
  8293. // top or left is auto and position is either absolute or fixed
  8294. if ( calculatePosition ) {
  8295. curPosition = curElem.position();
  8296. curTop = curPosition.top;
  8297. curLeft = curPosition.left;
  8298. } else {
  8299. curTop = parseFloat( curCSSTop ) || 0;
  8300. curLeft = parseFloat( curCSSLeft ) || 0;
  8301. }
  8302. if ( isFunction( options ) ) {
  8303. // Use jQuery.extend here to allow modification of coordinates argument (gh-1848)
  8304. options = options.call( elem, i, jQuery.extend( {}, curOffset ) );
  8305. }
  8306. if ( options.top != null ) {
  8307. props.top = ( options.top - curOffset.top ) + curTop;
  8308. }
  8309. if ( options.left != null ) {
  8310. props.left = ( options.left - curOffset.left ) + curLeft;
  8311. }
  8312. if ( "using" in options ) {
  8313. options.using.call( elem, props );
  8314. } else {
  8315. curElem.css( props );
  8316. }
  8317. }
  8318. };
  8319. jQuery.fn.extend( {
  8320. // offset() relates an element's border box to the document origin
  8321. offset: function( options ) {
  8322. // Preserve chaining for setter
  8323. if ( arguments.length ) {
  8324. return options === undefined ?
  8325. this :
  8326. this.each( function( i ) {
  8327. jQuery.offset.setOffset( this, options, i );
  8328. } );
  8329. }
  8330. var rect, win,
  8331. elem = this[ 0 ];
  8332. if ( !elem ) {
  8333. return;
  8334. }
  8335. // Return zeros for disconnected and hidden (display: none) elements (gh-2310)
  8336. // Support: IE <=11 only
  8337. // Running getBoundingClientRect on a
  8338. // disconnected node in IE throws an error
  8339. if ( !elem.getClientRects().length ) {
  8340. return { top: 0, left: 0 };
  8341. }
  8342. // Get document-relative position by adding viewport scroll to viewport-relative gBCR
  8343. rect = elem.getBoundingClientRect();
  8344. win = elem.ownerDocument.defaultView;
  8345. return {
  8346. top: rect.top + win.pageYOffset,
  8347. left: rect.left + win.pageXOffset
  8348. };
  8349. },
  8350. // position() relates an element's margin box to its offset parent's padding box
  8351. // This corresponds to the behavior of CSS absolute positioning
  8352. position: function() {
  8353. if ( !this[ 0 ] ) {
  8354. return;
  8355. }
  8356. var offsetParent, offset, doc,
  8357. elem = this[ 0 ],
  8358. parentOffset = { top: 0, left: 0 };
  8359. // position:fixed elements are offset from the viewport, which itself always has zero offset
  8360. if ( jQuery.css( elem, "position" ) === "fixed" ) {
  8361. // Assume position:fixed implies availability of getBoundingClientRect
  8362. offset = elem.getBoundingClientRect();
  8363. } else {
  8364. offset = this.offset();
  8365. // Account for the *real* offset parent, which can be the document or its root element
  8366. // when a statically positioned element is identified
  8367. doc = elem.ownerDocument;
  8368. offsetParent = elem.offsetParent || doc.documentElement;
  8369. while ( offsetParent &&
  8370. ( offsetParent === doc.body || offsetParent === doc.documentElement ) &&
  8371. jQuery.css( offsetParent, "position" ) === "static" ) {
  8372. offsetParent = offsetParent.parentNode;
  8373. }
  8374. if ( offsetParent && offsetParent !== elem && offsetParent.nodeType === 1 ) {
  8375. // Incorporate borders into its offset, since they are outside its content origin
  8376. parentOffset = jQuery( offsetParent ).offset();
  8377. parentOffset.top += jQuery.css( offsetParent, "borderTopWidth", true );
  8378. parentOffset.left += jQuery.css( offsetParent, "borderLeftWidth", true );
  8379. }
  8380. }
  8381. // Subtract parent offsets and element margins
  8382. return {
  8383. top: offset.top - parentOffset.top - jQuery.css( elem, "marginTop", true ),
  8384. left: offset.left - parentOffset.left - jQuery.css( elem, "marginLeft", true )
  8385. };
  8386. },
  8387. // This method will return documentElement in the following cases:
  8388. // 1) For the element inside the iframe without offsetParent, this method will return
  8389. // documentElement of the parent window
  8390. // 2) For the hidden or detached element
  8391. // 3) For body or html element, i.e. in case of the html node - it will return itself
  8392. //
  8393. // but those exceptions were never presented as a real life use-cases
  8394. // and might be considered as more preferable results.
  8395. //
  8396. // This logic, however, is not guaranteed and can change at any point in the future
  8397. offsetParent: function() {
  8398. return this.map( function() {
  8399. var offsetParent = this.offsetParent;
  8400. while ( offsetParent && jQuery.css( offsetParent, "position" ) === "static" ) {
  8401. offsetParent = offsetParent.offsetParent;
  8402. }
  8403. return offsetParent || documentElement;
  8404. } );
  8405. }
  8406. } );
  8407. // Create scrollLeft and scrollTop methods
  8408. jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( method, prop ) {
  8409. var top = "pageYOffset" === prop;
  8410. jQuery.fn[ method ] = function( val ) {
  8411. return access( this, function( elem, method, val ) {
  8412. // Coalesce documents and windows
  8413. var win;
  8414. if ( isWindow( elem ) ) {
  8415. win = elem;
  8416. } else if ( elem.nodeType === 9 ) {
  8417. win = elem.defaultView;
  8418. }
  8419. if ( val === undefined ) {
  8420. return win ? win[ prop ] : elem[ method ];
  8421. }
  8422. if ( win ) {
  8423. win.scrollTo(
  8424. !top ? val : win.pageXOffset,
  8425. top ? val : win.pageYOffset
  8426. );
  8427. } else {
  8428. elem[ method ] = val;
  8429. }
  8430. }, method, val, arguments.length );
  8431. };
  8432. } );
  8433. // Support: Safari <=7 - 9.1, Chrome <=37 - 49
  8434. // Add the top/left cssHooks using jQuery.fn.position
  8435. // Webkit bug: https://bugs.webkit.org/show_bug.cgi?id=29084
  8436. // Blink bug: https://bugs.chromium.org/p/chromium/issues/detail?id=589347
  8437. // getComputedStyle returns percent when specified for top/left/bottom/right;
  8438. // rather than make the css module depend on the offset module, just check for it here
  8439. jQuery.each( [ "top", "left" ], function( i, prop ) {
  8440. jQuery.cssHooks[ prop ] = addGetHookIf( support.pixelPosition,
  8441. function( elem, computed ) {
  8442. if ( computed ) {
  8443. computed = curCSS( elem, prop );
  8444. // If curCSS returns percentage, fallback to offset
  8445. return rnumnonpx.test( computed ) ?
  8446. jQuery( elem ).position()[ prop ] + "px" :
  8447. computed;
  8448. }
  8449. }
  8450. );
  8451. } );
  8452. // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
  8453. jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
  8454. jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name },
  8455. function( defaultExtra, funcName ) {
  8456. // Margin is only for outerHeight, outerWidth
  8457. jQuery.fn[ funcName ] = function( margin, value ) {
  8458. var chainable = arguments.length && ( defaultExtra || typeof margin !== "boolean" ),
  8459. extra = defaultExtra || ( margin === true || value === true ? "margin" : "border" );
  8460. return access( this, function( elem, type, value ) {
  8461. var doc;
  8462. if ( isWindow( elem ) ) {
  8463. // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729)
  8464. return funcName.indexOf( "outer" ) === 0 ?
  8465. elem[ "inner" + name ] :
  8466. elem.document.documentElement[ "client" + name ];
  8467. }
  8468. // Get document width or height
  8469. if ( elem.nodeType === 9 ) {
  8470. doc = elem.documentElement;
  8471. // Either scroll[Width/Height] or offset[Width/Height] or client[Width/Height],
  8472. // whichever is greatest
  8473. return Math.max(
  8474. elem.body[ "scroll" + name ], doc[ "scroll" + name ],
  8475. elem.body[ "offset" + name ], doc[ "offset" + name ],
  8476. doc[ "client" + name ]
  8477. );
  8478. }
  8479. return value === undefined ?
  8480. // Get width or height on the element, requesting but not forcing parseFloat
  8481. jQuery.css( elem, type, extra ) :
  8482. // Set width or height on the element
  8483. jQuery.style( elem, type, value, extra );
  8484. }, type, chainable ? margin : undefined, chainable );
  8485. };
  8486. } );
  8487. } );
  8488. jQuery.each( ( "blur focus focusin focusout resize scroll click dblclick " +
  8489. "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
  8490. "change select submit keydown keypress keyup contextmenu" ).split( " " ),
  8491. function( i, name ) {
  8492. // Handle event binding
  8493. jQuery.fn[ name ] = function( data, fn ) {
  8494. return arguments.length > 0 ?
  8495. this.on( name, null, data, fn ) :
  8496. this.trigger( name );
  8497. };
  8498. } );
  8499. jQuery.fn.extend( {
  8500. hover: function( fnOver, fnOut ) {
  8501. return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
  8502. }
  8503. } );
  8504. jQuery.fn.extend( {
  8505. bind: function( types, data, fn ) {
  8506. return this.on( types, null, data, fn );
  8507. },
  8508. unbind: function( types, fn ) {
  8509. return this.off( types, null, fn );
  8510. },
  8511. delegate: function( selector, types, data, fn ) {
  8512. return this.on( types, selector, data, fn );
  8513. },
  8514. undelegate: function( selector, types, fn ) {
  8515. // ( namespace ) or ( selector, types [, fn] )
  8516. return arguments.length === 1 ?
  8517. this.off( selector, "**" ) :
  8518. this.off( types, selector || "**", fn );
  8519. }
  8520. } );
  8521. // Bind a function to a context, optionally partially applying any
  8522. // arguments.
  8523. // jQuery.proxy is deprecated to promote standards (specifically Function#bind)
  8524. // However, it is not slated for removal any time soon
  8525. jQuery.proxy = function( fn, context ) {
  8526. var tmp, args, proxy;
  8527. if ( typeof context === "string" ) {
  8528. tmp = fn[ context ];
  8529. context = fn;
  8530. fn = tmp;
  8531. }
  8532. // Quick check to determine if target is callable, in the spec
  8533. // this throws a TypeError, but we will just return undefined.
  8534. if ( !isFunction( fn ) ) {
  8535. return undefined;
  8536. }
  8537. // Simulated bind
  8538. args = slice.call( arguments, 2 );
  8539. proxy = function() {
  8540. return fn.apply( context || this, args.concat( slice.call( arguments ) ) );
  8541. };
  8542. // Set the guid of unique handler to the same of original handler, so it can be removed
  8543. proxy.guid = fn.guid = fn.guid || jQuery.guid++;
  8544. return proxy;
  8545. };
  8546. jQuery.holdReady = function( hold ) {
  8547. if ( hold ) {
  8548. jQuery.readyWait++;
  8549. } else {
  8550. jQuery.ready( true );
  8551. }
  8552. };
  8553. jQuery.isArray = Array.isArray;
  8554. jQuery.parseJSON = JSON.parse;
  8555. jQuery.nodeName = nodeName;
  8556. jQuery.isFunction = isFunction;
  8557. jQuery.isWindow = isWindow;
  8558. jQuery.camelCase = camelCase;
  8559. jQuery.type = toType;
  8560. jQuery.now = Date.now;
  8561. jQuery.isNumeric = function( obj ) {
  8562. // As of jQuery 3.0, isNumeric is limited to
  8563. // strings and numbers (primitives or objects)
  8564. // that can be coerced to finite numbers (gh-2662)
  8565. var type = jQuery.type( obj );
  8566. return ( type === "number" || type === "string" ) &&
  8567. // parseFloat NaNs numeric-cast false positives ("")
  8568. // ...but misinterprets leading-number strings, particularly hex literals ("0x...")
  8569. // subtraction forces infinities to NaN
  8570. !isNaN( obj - parseFloat( obj ) );
  8571. };
  8572. // Register as a named AMD module, since jQuery can be concatenated with other
  8573. // files that may use define, but not via a proper concatenation script that
  8574. // understands anonymous AMD modules. A named AMD is safest and most robust
  8575. // way to register. Lowercase jquery is used because AMD module names are
  8576. // derived from file names, and jQuery is normally delivered in a lowercase
  8577. // file name. Do this after creating the global so that if an AMD module wants
  8578. // to call noConflict to hide this version of jQuery, it will work.
  8579. // Note that for maximum portability, libraries that are not jQuery should
  8580. // declare themselves as anonymous modules, and avoid setting a global if an
  8581. // AMD loader is present. jQuery is a special case. For more information, see
  8582. // https://github.com/jrburke/requirejs/wiki/Updating-existing-libraries#wiki-anon
  8583. if ( typeof define === "function" && define.amd ) {
  8584. define( "jquery", [], function() {
  8585. return jQuery;
  8586. } );
  8587. }
  8588. var
  8589. // Map over jQuery in case of overwrite
  8590. _jQuery = window.jQuery,
  8591. // Map over the $ in case of overwrite
  8592. _$ = window.$;
  8593. jQuery.noConflict = function( deep ) {
  8594. if ( window.$ === jQuery ) {
  8595. window.$ = _$;
  8596. }
  8597. if ( deep && window.jQuery === jQuery ) {
  8598. window.jQuery = _jQuery;
  8599. }
  8600. return jQuery;
  8601. };
  8602. // Expose jQuery and $ identifiers, even in AMD
  8603. // (#7102#comment:10, https://github.com/jquery/jquery/pull/557)
  8604. // and CommonJS for browser emulators (#13566)
  8605. if ( !noGlobal ) {
  8606. window.jQuery = window.$ = jQuery;
  8607. }
  8608. return jQuery;
  8609. } );
  8610. // Copyright (c) Jupyter Development Team.
  8611. // Distributed under the terms of the Modified BSD License.
  8612. var Jupyter = Jupyter || {};
  8613. var jprop = function(name, module_path){
  8614. Object.defineProperty(Jupyter, name, {
  8615. get: function() {
  8616. console.warn('accessing `'+name+'` is deprecated. Use `requirejs("'+module_path+'")`');
  8617. return requirejs(module_path);
  8618. },
  8619. enumerable: true,
  8620. configurable: false
  8621. });
  8622. }
  8623. var jglobal = function(name, module_path){
  8624. Object.defineProperty(Jupyter, name, {
  8625. get: function() {
  8626. console.warn('accessing `'+name+'` is deprecated. Use `requirejs("'+module_path+'").'+name+'`');
  8627. return requirejs(module_path)[name];
  8628. },
  8629. enumerable: true,
  8630. configurable: false
  8631. });
  8632. }
  8633. define('base/js/namespace',[],function(){
  8634. "use strict";
  8635. // expose modules
  8636. jprop('utils','base/js/utils')
  8637. //Jupyter.load_extensions = Jupyter.utils.load_extensions;
  8638. //
  8639. jprop('security','base/js/security');
  8640. jprop('keyboard','base/js/keyboard');
  8641. jprop('dialog','base/js/dialog');
  8642. jprop('mathjaxutils','notebook/js/mathjaxutils');
  8643. //// exposed constructors
  8644. jglobal('CommManager','services/kernels/comm')
  8645. jglobal('Comm','services/kernels/comm')
  8646. jglobal('NotificationWidget','base/js/notificationwidget');
  8647. jglobal('Kernel','services/kernels/kernel');
  8648. jglobal('Session','services/sessions/session');
  8649. jglobal('LoginWidget','auth/js/loginwidget');
  8650. jglobal('Page','base/js/page');
  8651. // notebook
  8652. jglobal('TextCell','notebook/js/textcell');
  8653. jglobal('OutputArea','notebook/js/outputarea');
  8654. jglobal('KeyboardManager','notebook/js/keyboardmanager');
  8655. jglobal('Completer','notebook/js/completer');
  8656. jglobal('Notebook','notebook/js/notebook');
  8657. jglobal('Tooltip','notebook/js/tooltip');
  8658. jglobal('Toolbar','notebook/js/toolbar');
  8659. jglobal('SaveWidget','notebook/js/savewidget');
  8660. jglobal('Pager','notebook/js/pager');
  8661. jglobal('QuickHelp','notebook/js/quickhelp');
  8662. jglobal('MarkdownCell','notebook/js/textcell');
  8663. jglobal('RawCell','notebook/js/textcell');
  8664. jglobal('Cell','notebook/js/cell');
  8665. jglobal('MainToolBar','notebook/js/maintoolbar');
  8666. jglobal('NotebookNotificationArea','notebook/js/notificationarea');
  8667. jglobal('NotebookTour', 'notebook/js/tour');
  8668. jglobal('MenuBar', 'notebook/js/menubar');
  8669. // tree
  8670. jglobal('SessionList','tree/js/sessionlist');
  8671. Jupyter.version = "5.7.10";
  8672. Jupyter._target = '_blank';
  8673. return Jupyter;
  8674. });
  8675. // deprecated since 4.0, remove in 5+
  8676. var IPython = Jupyter;
  8677. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  8678. // Distributed under an MIT license: http://codemirror.net/LICENSE
  8679. // This is CodeMirror (http://codemirror.net), a code editor
  8680. // implemented in JavaScript on top of the browser's DOM.
  8681. //
  8682. // You can find some technical background for some of the code below
  8683. // at http://marijnhaverbeke.nl/blog/#cm-internals .
  8684. (function (global, factory) {
  8685. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8686. typeof define === 'function' && define.amd ? define('codemirror/lib/codemirror',factory) :
  8687. (global.CodeMirror = factory());
  8688. }(this, (function () { 'use strict';
  8689. // Kludges for bugs and behavior differences that can't be feature
  8690. // detected are enabled based on userAgent etc sniffing.
  8691. var userAgent = navigator.userAgent;
  8692. var platform = navigator.platform;
  8693. var gecko = /gecko\/\d/i.test(userAgent);
  8694. var ie_upto10 = /MSIE \d/.test(userAgent);
  8695. var ie_11up = /Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(userAgent);
  8696. var edge = /Edge\/(\d+)/.exec(userAgent);
  8697. var ie = ie_upto10 || ie_11up || edge;
  8698. var ie_version = ie && (ie_upto10 ? document.documentMode || 6 : +(edge || ie_11up)[1]);
  8699. var webkit = !edge && /WebKit\//.test(userAgent);
  8700. var qtwebkit = webkit && /Qt\/\d+\.\d+/.test(userAgent);
  8701. var chrome = !edge && /Chrome\//.test(userAgent);
  8702. var presto = /Opera\//.test(userAgent);
  8703. var safari = /Apple Computer/.test(navigator.vendor);
  8704. var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
  8705. var phantom = /PhantomJS/.test(userAgent);
  8706. var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
  8707. var android = /Android/.test(userAgent);
  8708. // This is woefully incomplete. Suggestions for alternative methods welcome.
  8709. var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
  8710. var mac = ios || /Mac/.test(platform);
  8711. var chromeOS = /\bCrOS\b/.test(userAgent);
  8712. var windows = /win/i.test(platform);
  8713. var presto_version = presto && userAgent.match(/Version\/(\d*\.\d*)/);
  8714. if (presto_version) { presto_version = Number(presto_version[1]); }
  8715. if (presto_version && presto_version >= 15) { presto = false; webkit = true; }
  8716. // Some browsers use the wrong event properties to signal cmd/ctrl on OS X
  8717. var flipCtrlCmd = mac && (qtwebkit || presto && (presto_version == null || presto_version < 12.11));
  8718. var captureRightClick = gecko || (ie && ie_version >= 9);
  8719. function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") }
  8720. var rmClass = function(node, cls) {
  8721. var current = node.className;
  8722. var match = classTest(cls).exec(current);
  8723. if (match) {
  8724. var after = current.slice(match.index + match[0].length);
  8725. node.className = current.slice(0, match.index) + (after ? match[1] + after : "");
  8726. }
  8727. };
  8728. function removeChildren(e) {
  8729. for (var count = e.childNodes.length; count > 0; --count)
  8730. { e.removeChild(e.firstChild); }
  8731. return e
  8732. }
  8733. function removeChildrenAndAdd(parent, e) {
  8734. return removeChildren(parent).appendChild(e)
  8735. }
  8736. function elt(tag, content, className, style) {
  8737. var e = document.createElement(tag);
  8738. if (className) { e.className = className; }
  8739. if (style) { e.style.cssText = style; }
  8740. if (typeof content == "string") { e.appendChild(document.createTextNode(content)); }
  8741. else if (content) { for (var i = 0; i < content.length; ++i) { e.appendChild(content[i]); } }
  8742. return e
  8743. }
  8744. // wrapper for elt, which removes the elt from the accessibility tree
  8745. function eltP(tag, content, className, style) {
  8746. var e = elt(tag, content, className, style);
  8747. e.setAttribute("role", "presentation");
  8748. return e
  8749. }
  8750. var range;
  8751. if (document.createRange) { range = function(node, start, end, endNode) {
  8752. var r = document.createRange();
  8753. r.setEnd(endNode || node, end);
  8754. r.setStart(node, start);
  8755. return r
  8756. }; }
  8757. else { range = function(node, start, end) {
  8758. var r = document.body.createTextRange();
  8759. try { r.moveToElementText(node.parentNode); }
  8760. catch(e) { return r }
  8761. r.collapse(true);
  8762. r.moveEnd("character", end);
  8763. r.moveStart("character", start);
  8764. return r
  8765. }; }
  8766. function contains(parent, child) {
  8767. if (child.nodeType == 3) // Android browser always returns false when child is a textnode
  8768. { child = child.parentNode; }
  8769. if (parent.contains)
  8770. { return parent.contains(child) }
  8771. do {
  8772. if (child.nodeType == 11) { child = child.host; }
  8773. if (child == parent) { return true }
  8774. } while (child = child.parentNode)
  8775. }
  8776. function activeElt() {
  8777. // IE and Edge may throw an "Unspecified Error" when accessing document.activeElement.
  8778. // IE < 10 will throw when accessed while the page is loading or in an iframe.
  8779. // IE > 9 and Edge will throw when accessed in an iframe if document.body is unavailable.
  8780. var activeElement;
  8781. try {
  8782. activeElement = document.activeElement;
  8783. } catch(e) {
  8784. activeElement = document.body || null;
  8785. }
  8786. while (activeElement && activeElement.shadowRoot && activeElement.shadowRoot.activeElement)
  8787. { activeElement = activeElement.shadowRoot.activeElement; }
  8788. return activeElement
  8789. }
  8790. function addClass(node, cls) {
  8791. var current = node.className;
  8792. if (!classTest(cls).test(current)) { node.className += (current ? " " : "") + cls; }
  8793. }
  8794. function joinClasses(a, b) {
  8795. var as = a.split(" ");
  8796. for (var i = 0; i < as.length; i++)
  8797. { if (as[i] && !classTest(as[i]).test(b)) { b += " " + as[i]; } }
  8798. return b
  8799. }
  8800. var selectInput = function(node) { node.select(); };
  8801. if (ios) // Mobile Safari apparently has a bug where select() is broken.
  8802. { selectInput = function(node) { node.selectionStart = 0; node.selectionEnd = node.value.length; }; }
  8803. else if (ie) // Suppress mysterious IE10 errors
  8804. { selectInput = function(node) { try { node.select(); } catch(_e) {} }; }
  8805. function bind(f) {
  8806. var args = Array.prototype.slice.call(arguments, 1);
  8807. return function(){return f.apply(null, args)}
  8808. }
  8809. function copyObj(obj, target, overwrite) {
  8810. if (!target) { target = {}; }
  8811. for (var prop in obj)
  8812. { if (obj.hasOwnProperty(prop) && (overwrite !== false || !target.hasOwnProperty(prop)))
  8813. { target[prop] = obj[prop]; } }
  8814. return target
  8815. }
  8816. // Counts the column offset in a string, taking tabs into account.
  8817. // Used mostly to find indentation.
  8818. function countColumn(string, end, tabSize, startIndex, startValue) {
  8819. if (end == null) {
  8820. end = string.search(/[^\s\u00a0]/);
  8821. if (end == -1) { end = string.length; }
  8822. }
  8823. for (var i = startIndex || 0, n = startValue || 0;;) {
  8824. var nextTab = string.indexOf("\t", i);
  8825. if (nextTab < 0 || nextTab >= end)
  8826. { return n + (end - i) }
  8827. n += nextTab - i;
  8828. n += tabSize - (n % tabSize);
  8829. i = nextTab + 1;
  8830. }
  8831. }
  8832. var Delayed = function() {this.id = null;};
  8833. Delayed.prototype.set = function (ms, f) {
  8834. clearTimeout(this.id);
  8835. this.id = setTimeout(f, ms);
  8836. };
  8837. function indexOf(array, elt) {
  8838. for (var i = 0; i < array.length; ++i)
  8839. { if (array[i] == elt) { return i } }
  8840. return -1
  8841. }
  8842. // Number of pixels added to scroller and sizer to hide scrollbar
  8843. var scrollerGap = 30;
  8844. // Returned or thrown by various protocols to signal 'I'm not
  8845. // handling this'.
  8846. var Pass = {toString: function(){return "CodeMirror.Pass"}};
  8847. // Reused option objects for setSelection & friends
  8848. var sel_dontScroll = {scroll: false};
  8849. var sel_mouse = {origin: "*mouse"};
  8850. var sel_move = {origin: "+move"};
  8851. // The inverse of countColumn -- find the offset that corresponds to
  8852. // a particular column.
  8853. function findColumn(string, goal, tabSize) {
  8854. for (var pos = 0, col = 0;;) {
  8855. var nextTab = string.indexOf("\t", pos);
  8856. if (nextTab == -1) { nextTab = string.length; }
  8857. var skipped = nextTab - pos;
  8858. if (nextTab == string.length || col + skipped >= goal)
  8859. { return pos + Math.min(skipped, goal - col) }
  8860. col += nextTab - pos;
  8861. col += tabSize - (col % tabSize);
  8862. pos = nextTab + 1;
  8863. if (col >= goal) { return pos }
  8864. }
  8865. }
  8866. var spaceStrs = [""];
  8867. function spaceStr(n) {
  8868. while (spaceStrs.length <= n)
  8869. { spaceStrs.push(lst(spaceStrs) + " "); }
  8870. return spaceStrs[n]
  8871. }
  8872. function lst(arr) { return arr[arr.length-1] }
  8873. function map(array, f) {
  8874. var out = [];
  8875. for (var i = 0; i < array.length; i++) { out[i] = f(array[i], i); }
  8876. return out
  8877. }
  8878. function insertSorted(array, value, score) {
  8879. var pos = 0, priority = score(value);
  8880. while (pos < array.length && score(array[pos]) <= priority) { pos++; }
  8881. array.splice(pos, 0, value);
  8882. }
  8883. function nothing() {}
  8884. function createObj(base, props) {
  8885. var inst;
  8886. if (Object.create) {
  8887. inst = Object.create(base);
  8888. } else {
  8889. nothing.prototype = base;
  8890. inst = new nothing();
  8891. }
  8892. if (props) { copyObj(props, inst); }
  8893. return inst
  8894. }
  8895. var nonASCIISingleCaseWordChar = /[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;
  8896. function isWordCharBasic(ch) {
  8897. return /\w/.test(ch) || ch > "\x80" &&
  8898. (ch.toUpperCase() != ch.toLowerCase() || nonASCIISingleCaseWordChar.test(ch))
  8899. }
  8900. function isWordChar(ch, helper) {
  8901. if (!helper) { return isWordCharBasic(ch) }
  8902. if (helper.source.indexOf("\\w") > -1 && isWordCharBasic(ch)) { return true }
  8903. return helper.test(ch)
  8904. }
  8905. function isEmpty(obj) {
  8906. for (var n in obj) { if (obj.hasOwnProperty(n) && obj[n]) { return false } }
  8907. return true
  8908. }
  8909. // Extending unicode characters. A series of a non-extending char +
  8910. // any number of extending chars is treated as a single unit as far
  8911. // as editing and measuring is concerned. This is not fully correct,
  8912. // since some scripts/fonts/browsers also treat other configurations
  8913. // of code points as a group.
  8914. 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]/;
  8915. function isExtendingChar(ch) { return ch.charCodeAt(0) >= 768 && extendingChars.test(ch) }
  8916. // Returns a number from the range [`0`; `str.length`] unless `pos` is outside that range.
  8917. function skipExtendingChars(str, pos, dir) {
  8918. while ((dir < 0 ? pos > 0 : pos < str.length) && isExtendingChar(str.charAt(pos))) { pos += dir; }
  8919. return pos
  8920. }
  8921. // Returns the value from the range [`from`; `to`] that satisfies
  8922. // `pred` and is closest to `from`. Assumes that at least `to`
  8923. // satisfies `pred`. Supports `from` being greater than `to`.
  8924. function findFirst(pred, from, to) {
  8925. // At any point we are certain `to` satisfies `pred`, don't know
  8926. // whether `from` does.
  8927. var dir = from > to ? -1 : 1;
  8928. for (;;) {
  8929. if (from == to) { return from }
  8930. var midF = (from + to) / 2, mid = dir < 0 ? Math.ceil(midF) : Math.floor(midF);
  8931. if (mid == from) { return pred(mid) ? from : to }
  8932. if (pred(mid)) { to = mid; }
  8933. else { from = mid + dir; }
  8934. }
  8935. }
  8936. // The display handles the DOM integration, both for input reading
  8937. // and content drawing. It holds references to DOM nodes and
  8938. // display-related state.
  8939. function Display(place, doc, input) {
  8940. var d = this;
  8941. this.input = input;
  8942. // Covers bottom-right square when both scrollbars are present.
  8943. d.scrollbarFiller = elt("div", null, "CodeMirror-scrollbar-filler");
  8944. d.scrollbarFiller.setAttribute("cm-not-content", "true");
  8945. // Covers bottom of gutter when coverGutterNextToScrollbar is on
  8946. // and h scrollbar is present.
  8947. d.gutterFiller = elt("div", null, "CodeMirror-gutter-filler");
  8948. d.gutterFiller.setAttribute("cm-not-content", "true");
  8949. // Will contain the actual code, positioned to cover the viewport.
  8950. d.lineDiv = eltP("div", null, "CodeMirror-code");
  8951. // Elements are added to these to represent selection and cursors.
  8952. d.selectionDiv = elt("div", null, null, "position: relative; z-index: 1");
  8953. d.cursorDiv = elt("div", null, "CodeMirror-cursors");
  8954. // A visibility: hidden element used to find the size of things.
  8955. d.measure = elt("div", null, "CodeMirror-measure");
  8956. // When lines outside of the viewport are measured, they are drawn in this.
  8957. d.lineMeasure = elt("div", null, "CodeMirror-measure");
  8958. // Wraps everything that needs to exist inside the vertically-padded coordinate system
  8959. d.lineSpace = eltP("div", [d.measure, d.lineMeasure, d.selectionDiv, d.cursorDiv, d.lineDiv],
  8960. null, "position: relative; outline: none");
  8961. var lines = eltP("div", [d.lineSpace], "CodeMirror-lines");
  8962. // Moved around its parent to cover visible view.
  8963. d.mover = elt("div", [lines], null, "position: relative");
  8964. // Set to the height of the document, allowing scrolling.
  8965. d.sizer = elt("div", [d.mover], "CodeMirror-sizer");
  8966. d.sizerWidth = null;
  8967. // Behavior of elts with overflow: auto and padding is
  8968. // inconsistent across browsers. This is used to ensure the
  8969. // scrollable area is big enough.
  8970. d.heightForcer = elt("div", null, null, "position: absolute; height: " + scrollerGap + "px; width: 1px;");
  8971. // Will contain the gutters, if any.
  8972. d.gutters = elt("div", null, "CodeMirror-gutters");
  8973. d.lineGutter = null;
  8974. // Actual scrollable element.
  8975. d.scroller = elt("div", [d.sizer, d.heightForcer, d.gutters], "CodeMirror-scroll");
  8976. d.scroller.setAttribute("tabIndex", "-1");
  8977. // The element in which the editor lives.
  8978. d.wrapper = elt("div", [d.scrollbarFiller, d.gutterFiller, d.scroller], "CodeMirror");
  8979. // Work around IE7 z-index bug (not perfect, hence IE7 not really being supported)
  8980. if (ie && ie_version < 8) { d.gutters.style.zIndex = -1; d.scroller.style.paddingRight = 0; }
  8981. if (!webkit && !(gecko && mobile)) { d.scroller.draggable = true; }
  8982. if (place) {
  8983. if (place.appendChild) { place.appendChild(d.wrapper); }
  8984. else { place(d.wrapper); }
  8985. }
  8986. // Current rendered range (may be bigger than the view window).
  8987. d.viewFrom = d.viewTo = doc.first;
  8988. d.reportedViewFrom = d.reportedViewTo = doc.first;
  8989. // Information about the rendered lines.
  8990. d.view = [];
  8991. d.renderedView = null;
  8992. // Holds info about a single rendered line when it was rendered
  8993. // for measurement, while not in view.
  8994. d.externalMeasured = null;
  8995. // Empty space (in pixels) above the view
  8996. d.viewOffset = 0;
  8997. d.lastWrapHeight = d.lastWrapWidth = 0;
  8998. d.updateLineNumbers = null;
  8999. d.nativeBarWidth = d.barHeight = d.barWidth = 0;
  9000. d.scrollbarsClipped = false;
  9001. // Used to only resize the line number gutter when necessary (when
  9002. // the amount of lines crosses a boundary that makes its width change)
  9003. d.lineNumWidth = d.lineNumInnerWidth = d.lineNumChars = null;
  9004. // Set to true when a non-horizontal-scrolling line widget is
  9005. // added. As an optimization, line widget aligning is skipped when
  9006. // this is false.
  9007. d.alignWidgets = false;
  9008. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  9009. // Tracks the maximum line length so that the horizontal scrollbar
  9010. // can be kept static when scrolling.
  9011. d.maxLine = null;
  9012. d.maxLineLength = 0;
  9013. d.maxLineChanged = false;
  9014. // Used for measuring wheel scrolling granularity
  9015. d.wheelDX = d.wheelDY = d.wheelStartX = d.wheelStartY = null;
  9016. // True when shift is held down.
  9017. d.shift = false;
  9018. // Used to track whether anything happened since the context menu
  9019. // was opened.
  9020. d.selForContextMenu = null;
  9021. d.activeTouch = null;
  9022. input.init(d);
  9023. }
  9024. // Find the line object corresponding to the given line number.
  9025. function getLine(doc, n) {
  9026. n -= doc.first;
  9027. if (n < 0 || n >= doc.size) { throw new Error("There is no line " + (n + doc.first) + " in the document.") }
  9028. var chunk = doc;
  9029. while (!chunk.lines) {
  9030. for (var i = 0;; ++i) {
  9031. var child = chunk.children[i], sz = child.chunkSize();
  9032. if (n < sz) { chunk = child; break }
  9033. n -= sz;
  9034. }
  9035. }
  9036. return chunk.lines[n]
  9037. }
  9038. // Get the part of a document between two positions, as an array of
  9039. // strings.
  9040. function getBetween(doc, start, end) {
  9041. var out = [], n = start.line;
  9042. doc.iter(start.line, end.line + 1, function (line) {
  9043. var text = line.text;
  9044. if (n == end.line) { text = text.slice(0, end.ch); }
  9045. if (n == start.line) { text = text.slice(start.ch); }
  9046. out.push(text);
  9047. ++n;
  9048. });
  9049. return out
  9050. }
  9051. // Get the lines between from and to, as array of strings.
  9052. function getLines(doc, from, to) {
  9053. var out = [];
  9054. doc.iter(from, to, function (line) { out.push(line.text); }); // iter aborts when callback returns truthy value
  9055. return out
  9056. }
  9057. // Update the height of a line, propagating the height change
  9058. // upwards to parent nodes.
  9059. function updateLineHeight(line, height) {
  9060. var diff = height - line.height;
  9061. if (diff) { for (var n = line; n; n = n.parent) { n.height += diff; } }
  9062. }
  9063. // Given a line object, find its line number by walking up through
  9064. // its parent links.
  9065. function lineNo(line) {
  9066. if (line.parent == null) { return null }
  9067. var cur = line.parent, no = indexOf(cur.lines, line);
  9068. for (var chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent) {
  9069. for (var i = 0;; ++i) {
  9070. if (chunk.children[i] == cur) { break }
  9071. no += chunk.children[i].chunkSize();
  9072. }
  9073. }
  9074. return no + cur.first
  9075. }
  9076. // Find the line at the given vertical position, using the height
  9077. // information in the document tree.
  9078. function lineAtHeight(chunk, h) {
  9079. var n = chunk.first;
  9080. outer: do {
  9081. for (var i$1 = 0; i$1 < chunk.children.length; ++i$1) {
  9082. var child = chunk.children[i$1], ch = child.height;
  9083. if (h < ch) { chunk = child; continue outer }
  9084. h -= ch;
  9085. n += child.chunkSize();
  9086. }
  9087. return n
  9088. } while (!chunk.lines)
  9089. var i = 0;
  9090. for (; i < chunk.lines.length; ++i) {
  9091. var line = chunk.lines[i], lh = line.height;
  9092. if (h < lh) { break }
  9093. h -= lh;
  9094. }
  9095. return n + i
  9096. }
  9097. function isLine(doc, l) {return l >= doc.first && l < doc.first + doc.size}
  9098. function lineNumberFor(options, i) {
  9099. return String(options.lineNumberFormatter(i + options.firstLineNumber))
  9100. }
  9101. // A Pos instance represents a position within the text.
  9102. function Pos(line, ch, sticky) {
  9103. if ( sticky === void 0 ) sticky = null;
  9104. if (!(this instanceof Pos)) { return new Pos(line, ch, sticky) }
  9105. this.line = line;
  9106. this.ch = ch;
  9107. this.sticky = sticky;
  9108. }
  9109. // Compare two positions, return 0 if they are the same, a negative
  9110. // number when a is less, and a positive number otherwise.
  9111. function cmp(a, b) { return a.line - b.line || a.ch - b.ch }
  9112. function equalCursorPos(a, b) { return a.sticky == b.sticky && cmp(a, b) == 0 }
  9113. function copyPos(x) {return Pos(x.line, x.ch)}
  9114. function maxPos(a, b) { return cmp(a, b) < 0 ? b : a }
  9115. function minPos(a, b) { return cmp(a, b) < 0 ? a : b }
  9116. // Most of the external API clips given positions to make sure they
  9117. // actually exist within the document.
  9118. function clipLine(doc, n) {return Math.max(doc.first, Math.min(n, doc.first + doc.size - 1))}
  9119. function clipPos(doc, pos) {
  9120. if (pos.line < doc.first) { return Pos(doc.first, 0) }
  9121. var last = doc.first + doc.size - 1;
  9122. if (pos.line > last) { return Pos(last, getLine(doc, last).text.length) }
  9123. return clipToLen(pos, getLine(doc, pos.line).text.length)
  9124. }
  9125. function clipToLen(pos, linelen) {
  9126. var ch = pos.ch;
  9127. if (ch == null || ch > linelen) { return Pos(pos.line, linelen) }
  9128. else if (ch < 0) { return Pos(pos.line, 0) }
  9129. else { return pos }
  9130. }
  9131. function clipPosArray(doc, array) {
  9132. var out = [];
  9133. for (var i = 0; i < array.length; i++) { out[i] = clipPos(doc, array[i]); }
  9134. return out
  9135. }
  9136. // Optimize some code when these features are not used.
  9137. var sawReadOnlySpans = false;
  9138. var sawCollapsedSpans = false;
  9139. function seeReadOnlySpans() {
  9140. sawReadOnlySpans = true;
  9141. }
  9142. function seeCollapsedSpans() {
  9143. sawCollapsedSpans = true;
  9144. }
  9145. // TEXTMARKER SPANS
  9146. function MarkedSpan(marker, from, to) {
  9147. this.marker = marker;
  9148. this.from = from; this.to = to;
  9149. }
  9150. // Search an array of spans for a span matching the given marker.
  9151. function getMarkedSpanFor(spans, marker) {
  9152. if (spans) { for (var i = 0; i < spans.length; ++i) {
  9153. var span = spans[i];
  9154. if (span.marker == marker) { return span }
  9155. } }
  9156. }
  9157. // Remove a span from an array, returning undefined if no spans are
  9158. // left (we don't store arrays for lines without spans).
  9159. function removeMarkedSpan(spans, span) {
  9160. var r;
  9161. for (var i = 0; i < spans.length; ++i)
  9162. { if (spans[i] != span) { (r || (r = [])).push(spans[i]); } }
  9163. return r
  9164. }
  9165. // Add a span to a line.
  9166. function addMarkedSpan(line, span) {
  9167. line.markedSpans = line.markedSpans ? line.markedSpans.concat([span]) : [span];
  9168. span.marker.attachLine(line);
  9169. }
  9170. // Used for the algorithm that adjusts markers for a change in the
  9171. // document. These functions cut an array of spans at a given
  9172. // character position, returning an array of remaining chunks (or
  9173. // undefined if nothing remains).
  9174. function markedSpansBefore(old, startCh, isInsert) {
  9175. var nw;
  9176. if (old) { for (var i = 0; i < old.length; ++i) {
  9177. var span = old[i], marker = span.marker;
  9178. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= startCh : span.from < startCh);
  9179. if (startsBefore || span.from == startCh && marker.type == "bookmark" && (!isInsert || !span.marker.insertLeft)) {
  9180. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= startCh : span.to > startCh);(nw || (nw = [])).push(new MarkedSpan(marker, span.from, endsAfter ? null : span.to));
  9181. }
  9182. } }
  9183. return nw
  9184. }
  9185. function markedSpansAfter(old, endCh, isInsert) {
  9186. var nw;
  9187. if (old) { for (var i = 0; i < old.length; ++i) {
  9188. var span = old[i], marker = span.marker;
  9189. var endsAfter = span.to == null || (marker.inclusiveRight ? span.to >= endCh : span.to > endCh);
  9190. if (endsAfter || span.from == endCh && marker.type == "bookmark" && (!isInsert || span.marker.insertLeft)) {
  9191. var startsBefore = span.from == null || (marker.inclusiveLeft ? span.from <= endCh : span.from < endCh);(nw || (nw = [])).push(new MarkedSpan(marker, startsBefore ? null : span.from - endCh,
  9192. span.to == null ? null : span.to - endCh));
  9193. }
  9194. } }
  9195. return nw
  9196. }
  9197. // Given a change object, compute the new set of marker spans that
  9198. // cover the line in which the change took place. Removes spans
  9199. // entirely within the change, reconnects spans belonging to the
  9200. // same marker that appear on both sides of the change, and cuts off
  9201. // spans partially within the change. Returns an array of span
  9202. // arrays with one element for each line in (after) the change.
  9203. function stretchSpansOverChange(doc, change) {
  9204. if (change.full) { return null }
  9205. var oldFirst = isLine(doc, change.from.line) && getLine(doc, change.from.line).markedSpans;
  9206. var oldLast = isLine(doc, change.to.line) && getLine(doc, change.to.line).markedSpans;
  9207. if (!oldFirst && !oldLast) { return null }
  9208. var startCh = change.from.ch, endCh = change.to.ch, isInsert = cmp(change.from, change.to) == 0;
  9209. // Get the spans that 'stick out' on both sides
  9210. var first = markedSpansBefore(oldFirst, startCh, isInsert);
  9211. var last = markedSpansAfter(oldLast, endCh, isInsert);
  9212. // Next, merge those two ends
  9213. var sameLine = change.text.length == 1, offset = lst(change.text).length + (sameLine ? startCh : 0);
  9214. if (first) {
  9215. // Fix up .to properties of first
  9216. for (var i = 0; i < first.length; ++i) {
  9217. var span = first[i];
  9218. if (span.to == null) {
  9219. var found = getMarkedSpanFor(last, span.marker);
  9220. if (!found) { span.to = startCh; }
  9221. else if (sameLine) { span.to = found.to == null ? null : found.to + offset; }
  9222. }
  9223. }
  9224. }
  9225. if (last) {
  9226. // Fix up .from in last (or move them into first in case of sameLine)
  9227. for (var i$1 = 0; i$1 < last.length; ++i$1) {
  9228. var span$1 = last[i$1];
  9229. if (span$1.to != null) { span$1.to += offset; }
  9230. if (span$1.from == null) {
  9231. var found$1 = getMarkedSpanFor(first, span$1.marker);
  9232. if (!found$1) {
  9233. span$1.from = offset;
  9234. if (sameLine) { (first || (first = [])).push(span$1); }
  9235. }
  9236. } else {
  9237. span$1.from += offset;
  9238. if (sameLine) { (first || (first = [])).push(span$1); }
  9239. }
  9240. }
  9241. }
  9242. // Make sure we didn't create any zero-length spans
  9243. if (first) { first = clearEmptySpans(first); }
  9244. if (last && last != first) { last = clearEmptySpans(last); }
  9245. var newMarkers = [first];
  9246. if (!sameLine) {
  9247. // Fill gap with whole-line-spans
  9248. var gap = change.text.length - 2, gapMarkers;
  9249. if (gap > 0 && first)
  9250. { for (var i$2 = 0; i$2 < first.length; ++i$2)
  9251. { if (first[i$2].to == null)
  9252. { (gapMarkers || (gapMarkers = [])).push(new MarkedSpan(first[i$2].marker, null, null)); } } }
  9253. for (var i$3 = 0; i$3 < gap; ++i$3)
  9254. { newMarkers.push(gapMarkers); }
  9255. newMarkers.push(last);
  9256. }
  9257. return newMarkers
  9258. }
  9259. // Remove spans that are empty and don't have a clearWhenEmpty
  9260. // option of false.
  9261. function clearEmptySpans(spans) {
  9262. for (var i = 0; i < spans.length; ++i) {
  9263. var span = spans[i];
  9264. if (span.from != null && span.from == span.to && span.marker.clearWhenEmpty !== false)
  9265. { spans.splice(i--, 1); }
  9266. }
  9267. if (!spans.length) { return null }
  9268. return spans
  9269. }
  9270. // Used to 'clip' out readOnly ranges when making a change.
  9271. function removeReadOnlyRanges(doc, from, to) {
  9272. var markers = null;
  9273. doc.iter(from.line, to.line + 1, function (line) {
  9274. if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
  9275. var mark = line.markedSpans[i].marker;
  9276. if (mark.readOnly && (!markers || indexOf(markers, mark) == -1))
  9277. { (markers || (markers = [])).push(mark); }
  9278. } }
  9279. });
  9280. if (!markers) { return null }
  9281. var parts = [{from: from, to: to}];
  9282. for (var i = 0; i < markers.length; ++i) {
  9283. var mk = markers[i], m = mk.find(0);
  9284. for (var j = 0; j < parts.length; ++j) {
  9285. var p = parts[j];
  9286. if (cmp(p.to, m.from) < 0 || cmp(p.from, m.to) > 0) { continue }
  9287. var newParts = [j, 1], dfrom = cmp(p.from, m.from), dto = cmp(p.to, m.to);
  9288. if (dfrom < 0 || !mk.inclusiveLeft && !dfrom)
  9289. { newParts.push({from: p.from, to: m.from}); }
  9290. if (dto > 0 || !mk.inclusiveRight && !dto)
  9291. { newParts.push({from: m.to, to: p.to}); }
  9292. parts.splice.apply(parts, newParts);
  9293. j += newParts.length - 3;
  9294. }
  9295. }
  9296. return parts
  9297. }
  9298. // Connect or disconnect spans from a line.
  9299. function detachMarkedSpans(line) {
  9300. var spans = line.markedSpans;
  9301. if (!spans) { return }
  9302. for (var i = 0; i < spans.length; ++i)
  9303. { spans[i].marker.detachLine(line); }
  9304. line.markedSpans = null;
  9305. }
  9306. function attachMarkedSpans(line, spans) {
  9307. if (!spans) { return }
  9308. for (var i = 0; i < spans.length; ++i)
  9309. { spans[i].marker.attachLine(line); }
  9310. line.markedSpans = spans;
  9311. }
  9312. // Helpers used when computing which overlapping collapsed span
  9313. // counts as the larger one.
  9314. function extraLeft(marker) { return marker.inclusiveLeft ? -1 : 0 }
  9315. function extraRight(marker) { return marker.inclusiveRight ? 1 : 0 }
  9316. // Returns a number indicating which of two overlapping collapsed
  9317. // spans is larger (and thus includes the other). Falls back to
  9318. // comparing ids when the spans cover exactly the same range.
  9319. function compareCollapsedMarkers(a, b) {
  9320. var lenDiff = a.lines.length - b.lines.length;
  9321. if (lenDiff != 0) { return lenDiff }
  9322. var aPos = a.find(), bPos = b.find();
  9323. var fromCmp = cmp(aPos.from, bPos.from) || extraLeft(a) - extraLeft(b);
  9324. if (fromCmp) { return -fromCmp }
  9325. var toCmp = cmp(aPos.to, bPos.to) || extraRight(a) - extraRight(b);
  9326. if (toCmp) { return toCmp }
  9327. return b.id - a.id
  9328. }
  9329. // Find out whether a line ends or starts in a collapsed span. If
  9330. // so, return the marker for that span.
  9331. function collapsedSpanAtSide(line, start) {
  9332. var sps = sawCollapsedSpans && line.markedSpans, found;
  9333. if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
  9334. sp = sps[i];
  9335. if (sp.marker.collapsed && (start ? sp.from : sp.to) == null &&
  9336. (!found || compareCollapsedMarkers(found, sp.marker) < 0))
  9337. { found = sp.marker; }
  9338. } }
  9339. return found
  9340. }
  9341. function collapsedSpanAtStart(line) { return collapsedSpanAtSide(line, true) }
  9342. function collapsedSpanAtEnd(line) { return collapsedSpanAtSide(line, false) }
  9343. // Test whether there exists a collapsed span that partially
  9344. // overlaps (covers the start or end, but not both) of a new span.
  9345. // Such overlap is not allowed.
  9346. function conflictingCollapsedRange(doc, lineNo$$1, from, to, marker) {
  9347. var line = getLine(doc, lineNo$$1);
  9348. var sps = sawCollapsedSpans && line.markedSpans;
  9349. if (sps) { for (var i = 0; i < sps.length; ++i) {
  9350. var sp = sps[i];
  9351. if (!sp.marker.collapsed) { continue }
  9352. var found = sp.marker.find(0);
  9353. var fromCmp = cmp(found.from, from) || extraLeft(sp.marker) - extraLeft(marker);
  9354. var toCmp = cmp(found.to, to) || extraRight(sp.marker) - extraRight(marker);
  9355. if (fromCmp >= 0 && toCmp <= 0 || fromCmp <= 0 && toCmp >= 0) { continue }
  9356. if (fromCmp <= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.to, from) >= 0 : cmp(found.to, from) > 0) ||
  9357. fromCmp >= 0 && (sp.marker.inclusiveRight && marker.inclusiveLeft ? cmp(found.from, to) <= 0 : cmp(found.from, to) < 0))
  9358. { return true }
  9359. } }
  9360. }
  9361. // A visual line is a line as drawn on the screen. Folding, for
  9362. // example, can cause multiple logical lines to appear on the same
  9363. // visual line. This finds the start of the visual line that the
  9364. // given line is part of (usually that is the line itself).
  9365. function visualLine(line) {
  9366. var merged;
  9367. while (merged = collapsedSpanAtStart(line))
  9368. { line = merged.find(-1, true).line; }
  9369. return line
  9370. }
  9371. function visualLineEnd(line) {
  9372. var merged;
  9373. while (merged = collapsedSpanAtEnd(line))
  9374. { line = merged.find(1, true).line; }
  9375. return line
  9376. }
  9377. // Returns an array of logical lines that continue the visual line
  9378. // started by the argument, or undefined if there are no such lines.
  9379. function visualLineContinued(line) {
  9380. var merged, lines;
  9381. while (merged = collapsedSpanAtEnd(line)) {
  9382. line = merged.find(1, true).line
  9383. ;(lines || (lines = [])).push(line);
  9384. }
  9385. return lines
  9386. }
  9387. // Get the line number of the start of the visual line that the
  9388. // given line number is part of.
  9389. function visualLineNo(doc, lineN) {
  9390. var line = getLine(doc, lineN), vis = visualLine(line);
  9391. if (line == vis) { return lineN }
  9392. return lineNo(vis)
  9393. }
  9394. // Get the line number of the start of the next visual line after
  9395. // the given line.
  9396. function visualLineEndNo(doc, lineN) {
  9397. if (lineN > doc.lastLine()) { return lineN }
  9398. var line = getLine(doc, lineN), merged;
  9399. if (!lineIsHidden(doc, line)) { return lineN }
  9400. while (merged = collapsedSpanAtEnd(line))
  9401. { line = merged.find(1, true).line; }
  9402. return lineNo(line) + 1
  9403. }
  9404. // Compute whether a line is hidden. Lines count as hidden when they
  9405. // are part of a visual line that starts with another line, or when
  9406. // they are entirely covered by collapsed, non-widget span.
  9407. function lineIsHidden(doc, line) {
  9408. var sps = sawCollapsedSpans && line.markedSpans;
  9409. if (sps) { for (var sp = (void 0), i = 0; i < sps.length; ++i) {
  9410. sp = sps[i];
  9411. if (!sp.marker.collapsed) { continue }
  9412. if (sp.from == null) { return true }
  9413. if (sp.marker.widgetNode) { continue }
  9414. if (sp.from == 0 && sp.marker.inclusiveLeft && lineIsHiddenInner(doc, line, sp))
  9415. { return true }
  9416. } }
  9417. }
  9418. function lineIsHiddenInner(doc, line, span) {
  9419. if (span.to == null) {
  9420. var end = span.marker.find(1, true);
  9421. return lineIsHiddenInner(doc, end.line, getMarkedSpanFor(end.line.markedSpans, span.marker))
  9422. }
  9423. if (span.marker.inclusiveRight && span.to == line.text.length)
  9424. { return true }
  9425. for (var sp = (void 0), i = 0; i < line.markedSpans.length; ++i) {
  9426. sp = line.markedSpans[i];
  9427. if (sp.marker.collapsed && !sp.marker.widgetNode && sp.from == span.to &&
  9428. (sp.to == null || sp.to != span.from) &&
  9429. (sp.marker.inclusiveLeft || span.marker.inclusiveRight) &&
  9430. lineIsHiddenInner(doc, line, sp)) { return true }
  9431. }
  9432. }
  9433. // Find the height above the given line.
  9434. function heightAtLine(lineObj) {
  9435. lineObj = visualLine(lineObj);
  9436. var h = 0, chunk = lineObj.parent;
  9437. for (var i = 0; i < chunk.lines.length; ++i) {
  9438. var line = chunk.lines[i];
  9439. if (line == lineObj) { break }
  9440. else { h += line.height; }
  9441. }
  9442. for (var p = chunk.parent; p; chunk = p, p = chunk.parent) {
  9443. for (var i$1 = 0; i$1 < p.children.length; ++i$1) {
  9444. var cur = p.children[i$1];
  9445. if (cur == chunk) { break }
  9446. else { h += cur.height; }
  9447. }
  9448. }
  9449. return h
  9450. }
  9451. // Compute the character length of a line, taking into account
  9452. // collapsed ranges (see markText) that might hide parts, and join
  9453. // other lines onto it.
  9454. function lineLength(line) {
  9455. if (line.height == 0) { return 0 }
  9456. var len = line.text.length, merged, cur = line;
  9457. while (merged = collapsedSpanAtStart(cur)) {
  9458. var found = merged.find(0, true);
  9459. cur = found.from.line;
  9460. len += found.from.ch - found.to.ch;
  9461. }
  9462. cur = line;
  9463. while (merged = collapsedSpanAtEnd(cur)) {
  9464. var found$1 = merged.find(0, true);
  9465. len -= cur.text.length - found$1.from.ch;
  9466. cur = found$1.to.line;
  9467. len += cur.text.length - found$1.to.ch;
  9468. }
  9469. return len
  9470. }
  9471. // Find the longest line in the document.
  9472. function findMaxLine(cm) {
  9473. var d = cm.display, doc = cm.doc;
  9474. d.maxLine = getLine(doc, doc.first);
  9475. d.maxLineLength = lineLength(d.maxLine);
  9476. d.maxLineChanged = true;
  9477. doc.iter(function (line) {
  9478. var len = lineLength(line);
  9479. if (len > d.maxLineLength) {
  9480. d.maxLineLength = len;
  9481. d.maxLine = line;
  9482. }
  9483. });
  9484. }
  9485. // BIDI HELPERS
  9486. function iterateBidiSections(order, from, to, f) {
  9487. if (!order) { return f(from, to, "ltr", 0) }
  9488. var found = false;
  9489. for (var i = 0; i < order.length; ++i) {
  9490. var part = order[i];
  9491. if (part.from < to && part.to > from || from == to && part.to == from) {
  9492. f(Math.max(part.from, from), Math.min(part.to, to), part.level == 1 ? "rtl" : "ltr", i);
  9493. found = true;
  9494. }
  9495. }
  9496. if (!found) { f(from, to, "ltr"); }
  9497. }
  9498. var bidiOther = null;
  9499. function getBidiPartAt(order, ch, sticky) {
  9500. var found;
  9501. bidiOther = null;
  9502. for (var i = 0; i < order.length; ++i) {
  9503. var cur = order[i];
  9504. if (cur.from < ch && cur.to > ch) { return i }
  9505. if (cur.to == ch) {
  9506. if (cur.from != cur.to && sticky == "before") { found = i; }
  9507. else { bidiOther = i; }
  9508. }
  9509. if (cur.from == ch) {
  9510. if (cur.from != cur.to && sticky != "before") { found = i; }
  9511. else { bidiOther = i; }
  9512. }
  9513. }
  9514. return found != null ? found : bidiOther
  9515. }
  9516. // Bidirectional ordering algorithm
  9517. // See http://unicode.org/reports/tr9/tr9-13.html for the algorithm
  9518. // that this (partially) implements.
  9519. // One-char codes used for character types:
  9520. // L (L): Left-to-Right
  9521. // R (R): Right-to-Left
  9522. // r (AL): Right-to-Left Arabic
  9523. // 1 (EN): European Number
  9524. // + (ES): European Number Separator
  9525. // % (ET): European Number Terminator
  9526. // n (AN): Arabic Number
  9527. // , (CS): Common Number Separator
  9528. // m (NSM): Non-Spacing Mark
  9529. // b (BN): Boundary Neutral
  9530. // s (B): Paragraph Separator
  9531. // t (S): Segment Separator
  9532. // w (WS): Whitespace
  9533. // N (ON): Other Neutrals
  9534. // Returns null if characters are ordered as they appear
  9535. // (left-to-right), or an array of sections ({from, to, level}
  9536. // objects) in the order in which they occur visually.
  9537. var bidiOrdering = (function() {
  9538. // Character types for codepoints 0 to 0xff
  9539. var lowTypes = "bbbbbbbbbtstwsbbbbbbbbbbbbbbssstwNN%%%NNNNNN,N,N1111111111NNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNNNLLLLLLLLLLLLLLLLLLLLLLLLLLNNNNbbbbbbsbbbbbbbbbbbbbbbbbbbbbbbbbb,N%%%%NNNNLNNNNN%%11NLNNN1LNNNNNLLLLLLLLLLLLLLLLLLLLLLLNLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLLN";
  9540. // Character types for codepoints 0x600 to 0x6f9
  9541. var arabicTypes = "nnnnnnNNr%%r,rNNmmmmmmmmmmmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmmmmmmmmmmmmmmmnnnnnnnnnn%nnrrrmrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrmmmmmmmnNmmmmmmrrmmNmmmmrr1111111111";
  9542. function charType(code) {
  9543. if (code <= 0xf7) { return lowTypes.charAt(code) }
  9544. else if (0x590 <= code && code <= 0x5f4) { return "R" }
  9545. else if (0x600 <= code && code <= 0x6f9) { return arabicTypes.charAt(code - 0x600) }
  9546. else if (0x6ee <= code && code <= 0x8ac) { return "r" }
  9547. else if (0x2000 <= code && code <= 0x200b) { return "w" }
  9548. else if (code == 0x200c) { return "b" }
  9549. else { return "L" }
  9550. }
  9551. var bidiRE = /[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;
  9552. var isNeutral = /[stwN]/, isStrong = /[LRr]/, countsAsLeft = /[Lb1n]/, countsAsNum = /[1n]/;
  9553. function BidiSpan(level, from, to) {
  9554. this.level = level;
  9555. this.from = from; this.to = to;
  9556. }
  9557. return function(str, direction) {
  9558. var outerType = direction == "ltr" ? "L" : "R";
  9559. if (str.length == 0 || direction == "ltr" && !bidiRE.test(str)) { return false }
  9560. var len = str.length, types = [];
  9561. for (var i = 0; i < len; ++i)
  9562. { types.push(charType(str.charCodeAt(i))); }
  9563. // W1. Examine each non-spacing mark (NSM) in the level run, and
  9564. // change the type of the NSM to the type of the previous
  9565. // character. If the NSM is at the start of the level run, it will
  9566. // get the type of sor.
  9567. for (var i$1 = 0, prev = outerType; i$1 < len; ++i$1) {
  9568. var type = types[i$1];
  9569. if (type == "m") { types[i$1] = prev; }
  9570. else { prev = type; }
  9571. }
  9572. // W2. Search backwards from each instance of a European number
  9573. // until the first strong type (R, L, AL, or sor) is found. If an
  9574. // AL is found, change the type of the European number to Arabic
  9575. // number.
  9576. // W3. Change all ALs to R.
  9577. for (var i$2 = 0, cur = outerType; i$2 < len; ++i$2) {
  9578. var type$1 = types[i$2];
  9579. if (type$1 == "1" && cur == "r") { types[i$2] = "n"; }
  9580. else if (isStrong.test(type$1)) { cur = type$1; if (type$1 == "r") { types[i$2] = "R"; } }
  9581. }
  9582. // W4. A single European separator between two European numbers
  9583. // changes to a European number. A single common separator between
  9584. // two numbers of the same type changes to that type.
  9585. for (var i$3 = 1, prev$1 = types[0]; i$3 < len - 1; ++i$3) {
  9586. var type$2 = types[i$3];
  9587. if (type$2 == "+" && prev$1 == "1" && types[i$3+1] == "1") { types[i$3] = "1"; }
  9588. else if (type$2 == "," && prev$1 == types[i$3+1] &&
  9589. (prev$1 == "1" || prev$1 == "n")) { types[i$3] = prev$1; }
  9590. prev$1 = type$2;
  9591. }
  9592. // W5. A sequence of European terminators adjacent to European
  9593. // numbers changes to all European numbers.
  9594. // W6. Otherwise, separators and terminators change to Other
  9595. // Neutral.
  9596. for (var i$4 = 0; i$4 < len; ++i$4) {
  9597. var type$3 = types[i$4];
  9598. if (type$3 == ",") { types[i$4] = "N"; }
  9599. else if (type$3 == "%") {
  9600. var end = (void 0);
  9601. for (end = i$4 + 1; end < len && types[end] == "%"; ++end) {}
  9602. var replace = (i$4 && types[i$4-1] == "!") || (end < len && types[end] == "1") ? "1" : "N";
  9603. for (var j = i$4; j < end; ++j) { types[j] = replace; }
  9604. i$4 = end - 1;
  9605. }
  9606. }
  9607. // W7. Search backwards from each instance of a European number
  9608. // until the first strong type (R, L, or sor) is found. If an L is
  9609. // found, then change the type of the European number to L.
  9610. for (var i$5 = 0, cur$1 = outerType; i$5 < len; ++i$5) {
  9611. var type$4 = types[i$5];
  9612. if (cur$1 == "L" && type$4 == "1") { types[i$5] = "L"; }
  9613. else if (isStrong.test(type$4)) { cur$1 = type$4; }
  9614. }
  9615. // N1. A sequence of neutrals takes the direction of the
  9616. // surrounding strong text if the text on both sides has the same
  9617. // direction. European and Arabic numbers act as if they were R in
  9618. // terms of their influence on neutrals. Start-of-level-run (sor)
  9619. // and end-of-level-run (eor) are used at level run boundaries.
  9620. // N2. Any remaining neutrals take the embedding direction.
  9621. for (var i$6 = 0; i$6 < len; ++i$6) {
  9622. if (isNeutral.test(types[i$6])) {
  9623. var end$1 = (void 0);
  9624. for (end$1 = i$6 + 1; end$1 < len && isNeutral.test(types[end$1]); ++end$1) {}
  9625. var before = (i$6 ? types[i$6-1] : outerType) == "L";
  9626. var after = (end$1 < len ? types[end$1] : outerType) == "L";
  9627. var replace$1 = before == after ? (before ? "L" : "R") : outerType;
  9628. for (var j$1 = i$6; j$1 < end$1; ++j$1) { types[j$1] = replace$1; }
  9629. i$6 = end$1 - 1;
  9630. }
  9631. }
  9632. // Here we depart from the documented algorithm, in order to avoid
  9633. // building up an actual levels array. Since there are only three
  9634. // levels (0, 1, 2) in an implementation that doesn't take
  9635. // explicit embedding into account, we can build up the order on
  9636. // the fly, without following the level-based algorithm.
  9637. var order = [], m;
  9638. for (var i$7 = 0; i$7 < len;) {
  9639. if (countsAsLeft.test(types[i$7])) {
  9640. var start = i$7;
  9641. for (++i$7; i$7 < len && countsAsLeft.test(types[i$7]); ++i$7) {}
  9642. order.push(new BidiSpan(0, start, i$7));
  9643. } else {
  9644. var pos = i$7, at = order.length;
  9645. for (++i$7; i$7 < len && types[i$7] != "L"; ++i$7) {}
  9646. for (var j$2 = pos; j$2 < i$7;) {
  9647. if (countsAsNum.test(types[j$2])) {
  9648. if (pos < j$2) { order.splice(at, 0, new BidiSpan(1, pos, j$2)); }
  9649. var nstart = j$2;
  9650. for (++j$2; j$2 < i$7 && countsAsNum.test(types[j$2]); ++j$2) {}
  9651. order.splice(at, 0, new BidiSpan(2, nstart, j$2));
  9652. pos = j$2;
  9653. } else { ++j$2; }
  9654. }
  9655. if (pos < i$7) { order.splice(at, 0, new BidiSpan(1, pos, i$7)); }
  9656. }
  9657. }
  9658. if (direction == "ltr") {
  9659. if (order[0].level == 1 && (m = str.match(/^\s+/))) {
  9660. order[0].from = m[0].length;
  9661. order.unshift(new BidiSpan(0, 0, m[0].length));
  9662. }
  9663. if (lst(order).level == 1 && (m = str.match(/\s+$/))) {
  9664. lst(order).to -= m[0].length;
  9665. order.push(new BidiSpan(0, len - m[0].length, len));
  9666. }
  9667. }
  9668. return direction == "rtl" ? order.reverse() : order
  9669. }
  9670. })();
  9671. // Get the bidi ordering for the given line (and cache it). Returns
  9672. // false for lines that are fully left-to-right, and an array of
  9673. // BidiSpan objects otherwise.
  9674. function getOrder(line, direction) {
  9675. var order = line.order;
  9676. if (order == null) { order = line.order = bidiOrdering(line.text, direction); }
  9677. return order
  9678. }
  9679. // EVENT HANDLING
  9680. // Lightweight event framework. on/off also work on DOM nodes,
  9681. // registering native DOM handlers.
  9682. var noHandlers = [];
  9683. var on = function(emitter, type, f) {
  9684. if (emitter.addEventListener) {
  9685. emitter.addEventListener(type, f, false);
  9686. } else if (emitter.attachEvent) {
  9687. emitter.attachEvent("on" + type, f);
  9688. } else {
  9689. var map$$1 = emitter._handlers || (emitter._handlers = {});
  9690. map$$1[type] = (map$$1[type] || noHandlers).concat(f);
  9691. }
  9692. };
  9693. function getHandlers(emitter, type) {
  9694. return emitter._handlers && emitter._handlers[type] || noHandlers
  9695. }
  9696. function off(emitter, type, f) {
  9697. if (emitter.removeEventListener) {
  9698. emitter.removeEventListener(type, f, false);
  9699. } else if (emitter.detachEvent) {
  9700. emitter.detachEvent("on" + type, f);
  9701. } else {
  9702. var map$$1 = emitter._handlers, arr = map$$1 && map$$1[type];
  9703. if (arr) {
  9704. var index = indexOf(arr, f);
  9705. if (index > -1)
  9706. { map$$1[type] = arr.slice(0, index).concat(arr.slice(index + 1)); }
  9707. }
  9708. }
  9709. }
  9710. function signal(emitter, type /*, values...*/) {
  9711. var handlers = getHandlers(emitter, type);
  9712. if (!handlers.length) { return }
  9713. var args = Array.prototype.slice.call(arguments, 2);
  9714. for (var i = 0; i < handlers.length; ++i) { handlers[i].apply(null, args); }
  9715. }
  9716. // The DOM events that CodeMirror handles can be overridden by
  9717. // registering a (non-DOM) handler on the editor for the event name,
  9718. // and preventDefault-ing the event in that handler.
  9719. function signalDOMEvent(cm, e, override) {
  9720. if (typeof e == "string")
  9721. { e = {type: e, preventDefault: function() { this.defaultPrevented = true; }}; }
  9722. signal(cm, override || e.type, cm, e);
  9723. return e_defaultPrevented(e) || e.codemirrorIgnore
  9724. }
  9725. function signalCursorActivity(cm) {
  9726. var arr = cm._handlers && cm._handlers.cursorActivity;
  9727. if (!arr) { return }
  9728. var set = cm.curOp.cursorActivityHandlers || (cm.curOp.cursorActivityHandlers = []);
  9729. for (var i = 0; i < arr.length; ++i) { if (indexOf(set, arr[i]) == -1)
  9730. { set.push(arr[i]); } }
  9731. }
  9732. function hasHandler(emitter, type) {
  9733. return getHandlers(emitter, type).length > 0
  9734. }
  9735. // Add on and off methods to a constructor's prototype, to make
  9736. // registering events on such objects more convenient.
  9737. function eventMixin(ctor) {
  9738. ctor.prototype.on = function(type, f) {on(this, type, f);};
  9739. ctor.prototype.off = function(type, f) {off(this, type, f);};
  9740. }
  9741. // Due to the fact that we still support jurassic IE versions, some
  9742. // compatibility wrappers are needed.
  9743. function e_preventDefault(e) {
  9744. if (e.preventDefault) { e.preventDefault(); }
  9745. else { e.returnValue = false; }
  9746. }
  9747. function e_stopPropagation(e) {
  9748. if (e.stopPropagation) { e.stopPropagation(); }
  9749. else { e.cancelBubble = true; }
  9750. }
  9751. function e_defaultPrevented(e) {
  9752. return e.defaultPrevented != null ? e.defaultPrevented : e.returnValue == false
  9753. }
  9754. function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}
  9755. function e_target(e) {return e.target || e.srcElement}
  9756. function e_button(e) {
  9757. var b = e.which;
  9758. if (b == null) {
  9759. if (e.button & 1) { b = 1; }
  9760. else if (e.button & 2) { b = 3; }
  9761. else if (e.button & 4) { b = 2; }
  9762. }
  9763. if (mac && e.ctrlKey && b == 1) { b = 3; }
  9764. return b
  9765. }
  9766. // Detect drag-and-drop
  9767. var dragAndDrop = function() {
  9768. // There is *some* kind of drag-and-drop support in IE6-8, but I
  9769. // couldn't get it to work yet.
  9770. if (ie && ie_version < 9) { return false }
  9771. var div = elt('div');
  9772. return "draggable" in div || "dragDrop" in div
  9773. }();
  9774. var zwspSupported;
  9775. function zeroWidthElement(measure) {
  9776. if (zwspSupported == null) {
  9777. var test = elt("span", "\u200b");
  9778. removeChildrenAndAdd(measure, elt("span", [test, document.createTextNode("x")]));
  9779. if (measure.firstChild.offsetHeight != 0)
  9780. { zwspSupported = test.offsetWidth <= 1 && test.offsetHeight > 2 && !(ie && ie_version < 8); }
  9781. }
  9782. var node = zwspSupported ? elt("span", "\u200b") :
  9783. elt("span", "\u00a0", null, "display: inline-block; width: 1px; margin-right: -1px");
  9784. node.setAttribute("cm-text", "");
  9785. return node
  9786. }
  9787. // Feature-detect IE's crummy client rect reporting for bidi text
  9788. var badBidiRects;
  9789. function hasBadBidiRects(measure) {
  9790. if (badBidiRects != null) { return badBidiRects }
  9791. var txt = removeChildrenAndAdd(measure, document.createTextNode("A\u062eA"));
  9792. var r0 = range(txt, 0, 1).getBoundingClientRect();
  9793. var r1 = range(txt, 1, 2).getBoundingClientRect();
  9794. removeChildren(measure);
  9795. if (!r0 || r0.left == r0.right) { return false } // Safari returns null in some cases (#2780)
  9796. return badBidiRects = (r1.right - r0.right < 3)
  9797. }
  9798. // See if "".split is the broken IE version, if so, provide an
  9799. // alternative way to split lines.
  9800. var splitLinesAuto = "\n\nb".split(/\n/).length != 3 ? function (string) {
  9801. var pos = 0, result = [], l = string.length;
  9802. while (pos <= l) {
  9803. var nl = string.indexOf("\n", pos);
  9804. if (nl == -1) { nl = string.length; }
  9805. var line = string.slice(pos, string.charAt(nl - 1) == "\r" ? nl - 1 : nl);
  9806. var rt = line.indexOf("\r");
  9807. if (rt != -1) {
  9808. result.push(line.slice(0, rt));
  9809. pos += rt + 1;
  9810. } else {
  9811. result.push(line);
  9812. pos = nl + 1;
  9813. }
  9814. }
  9815. return result
  9816. } : function (string) { return string.split(/\r\n?|\n/); };
  9817. var hasSelection = window.getSelection ? function (te) {
  9818. try { return te.selectionStart != te.selectionEnd }
  9819. catch(e) { return false }
  9820. } : function (te) {
  9821. var range$$1;
  9822. try {range$$1 = te.ownerDocument.selection.createRange();}
  9823. catch(e) {}
  9824. if (!range$$1 || range$$1.parentElement() != te) { return false }
  9825. return range$$1.compareEndPoints("StartToEnd", range$$1) != 0
  9826. };
  9827. var hasCopyEvent = (function () {
  9828. var e = elt("div");
  9829. if ("oncopy" in e) { return true }
  9830. e.setAttribute("oncopy", "return;");
  9831. return typeof e.oncopy == "function"
  9832. })();
  9833. var badZoomedRects = null;
  9834. function hasBadZoomedRects(measure) {
  9835. if (badZoomedRects != null) { return badZoomedRects }
  9836. var node = removeChildrenAndAdd(measure, elt("span", "x"));
  9837. var normal = node.getBoundingClientRect();
  9838. var fromRange = range(node, 0, 1).getBoundingClientRect();
  9839. return badZoomedRects = Math.abs(normal.left - fromRange.left) > 1
  9840. }
  9841. // Known modes, by name and by MIME
  9842. var modes = {};
  9843. var mimeModes = {};
  9844. // Extra arguments are stored as the mode's dependencies, which is
  9845. // used by (legacy) mechanisms like loadmode.js to automatically
  9846. // load a mode. (Preferred mechanism is the require/define calls.)
  9847. function defineMode(name, mode) {
  9848. if (arguments.length > 2)
  9849. { mode.dependencies = Array.prototype.slice.call(arguments, 2); }
  9850. modes[name] = mode;
  9851. }
  9852. function defineMIME(mime, spec) {
  9853. mimeModes[mime] = spec;
  9854. }
  9855. // Given a MIME type, a {name, ...options} config object, or a name
  9856. // string, return a mode config object.
  9857. function resolveMode(spec) {
  9858. if (typeof spec == "string" && mimeModes.hasOwnProperty(spec)) {
  9859. spec = mimeModes[spec];
  9860. } else if (spec && typeof spec.name == "string" && mimeModes.hasOwnProperty(spec.name)) {
  9861. var found = mimeModes[spec.name];
  9862. if (typeof found == "string") { found = {name: found}; }
  9863. spec = createObj(found, spec);
  9864. spec.name = found.name;
  9865. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec)) {
  9866. return resolveMode("application/xml")
  9867. } else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+json$/.test(spec)) {
  9868. return resolveMode("application/json")
  9869. }
  9870. if (typeof spec == "string") { return {name: spec} }
  9871. else { return spec || {name: "null"} }
  9872. }
  9873. // Given a mode spec (anything that resolveMode accepts), find and
  9874. // initialize an actual mode object.
  9875. function getMode(options, spec) {
  9876. spec = resolveMode(spec);
  9877. var mfactory = modes[spec.name];
  9878. if (!mfactory) { return getMode(options, "text/plain") }
  9879. var modeObj = mfactory(options, spec);
  9880. if (modeExtensions.hasOwnProperty(spec.name)) {
  9881. var exts = modeExtensions[spec.name];
  9882. for (var prop in exts) {
  9883. if (!exts.hasOwnProperty(prop)) { continue }
  9884. if (modeObj.hasOwnProperty(prop)) { modeObj["_" + prop] = modeObj[prop]; }
  9885. modeObj[prop] = exts[prop];
  9886. }
  9887. }
  9888. modeObj.name = spec.name;
  9889. if (spec.helperType) { modeObj.helperType = spec.helperType; }
  9890. if (spec.modeProps) { for (var prop$1 in spec.modeProps)
  9891. { modeObj[prop$1] = spec.modeProps[prop$1]; } }
  9892. return modeObj
  9893. }
  9894. // This can be used to attach properties to mode objects from
  9895. // outside the actual mode definition.
  9896. var modeExtensions = {};
  9897. function extendMode(mode, properties) {
  9898. var exts = modeExtensions.hasOwnProperty(mode) ? modeExtensions[mode] : (modeExtensions[mode] = {});
  9899. copyObj(properties, exts);
  9900. }
  9901. function copyState(mode, state) {
  9902. if (state === true) { return state }
  9903. if (mode.copyState) { return mode.copyState(state) }
  9904. var nstate = {};
  9905. for (var n in state) {
  9906. var val = state[n];
  9907. if (val instanceof Array) { val = val.concat([]); }
  9908. nstate[n] = val;
  9909. }
  9910. return nstate
  9911. }
  9912. // Given a mode and a state (for that mode), find the inner mode and
  9913. // state at the position that the state refers to.
  9914. function innerMode(mode, state) {
  9915. var info;
  9916. while (mode.innerMode) {
  9917. info = mode.innerMode(state);
  9918. if (!info || info.mode == mode) { break }
  9919. state = info.state;
  9920. mode = info.mode;
  9921. }
  9922. return info || {mode: mode, state: state}
  9923. }
  9924. function startState(mode, a1, a2) {
  9925. return mode.startState ? mode.startState(a1, a2) : true
  9926. }
  9927. // STRING STREAM
  9928. // Fed to the mode parsers, provides helper functions to make
  9929. // parsers more succinct.
  9930. var StringStream = function(string, tabSize, lineOracle) {
  9931. this.pos = this.start = 0;
  9932. this.string = string;
  9933. this.tabSize = tabSize || 8;
  9934. this.lastColumnPos = this.lastColumnValue = 0;
  9935. this.lineStart = 0;
  9936. this.lineOracle = lineOracle;
  9937. };
  9938. StringStream.prototype.eol = function () {return this.pos >= this.string.length};
  9939. StringStream.prototype.sol = function () {return this.pos == this.lineStart};
  9940. StringStream.prototype.peek = function () {return this.string.charAt(this.pos) || undefined};
  9941. StringStream.prototype.next = function () {
  9942. if (this.pos < this.string.length)
  9943. { return this.string.charAt(this.pos++) }
  9944. };
  9945. StringStream.prototype.eat = function (match) {
  9946. var ch = this.string.charAt(this.pos);
  9947. var ok;
  9948. if (typeof match == "string") { ok = ch == match; }
  9949. else { ok = ch && (match.test ? match.test(ch) : match(ch)); }
  9950. if (ok) {++this.pos; return ch}
  9951. };
  9952. StringStream.prototype.eatWhile = function (match) {
  9953. var start = this.pos;
  9954. while (this.eat(match)){}
  9955. return this.pos > start
  9956. };
  9957. StringStream.prototype.eatSpace = function () {
  9958. var this$1 = this;
  9959. var start = this.pos;
  9960. while (/[\s\u00a0]/.test(this.string.charAt(this.pos))) { ++this$1.pos; }
  9961. return this.pos > start
  9962. };
  9963. StringStream.prototype.skipToEnd = function () {this.pos = this.string.length;};
  9964. StringStream.prototype.skipTo = function (ch) {
  9965. var found = this.string.indexOf(ch, this.pos);
  9966. if (found > -1) {this.pos = found; return true}
  9967. };
  9968. StringStream.prototype.backUp = function (n) {this.pos -= n;};
  9969. StringStream.prototype.column = function () {
  9970. if (this.lastColumnPos < this.start) {
  9971. this.lastColumnValue = countColumn(this.string, this.start, this.tabSize, this.lastColumnPos, this.lastColumnValue);
  9972. this.lastColumnPos = this.start;
  9973. }
  9974. return this.lastColumnValue - (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
  9975. };
  9976. StringStream.prototype.indentation = function () {
  9977. return countColumn(this.string, null, this.tabSize) -
  9978. (this.lineStart ? countColumn(this.string, this.lineStart, this.tabSize) : 0)
  9979. };
  9980. StringStream.prototype.match = function (pattern, consume, caseInsensitive) {
  9981. if (typeof pattern == "string") {
  9982. var cased = function (str) { return caseInsensitive ? str.toLowerCase() : str; };
  9983. var substr = this.string.substr(this.pos, pattern.length);
  9984. if (cased(substr) == cased(pattern)) {
  9985. if (consume !== false) { this.pos += pattern.length; }
  9986. return true
  9987. }
  9988. } else {
  9989. var match = this.string.slice(this.pos).match(pattern);
  9990. if (match && match.index > 0) { return null }
  9991. if (match && consume !== false) { this.pos += match[0].length; }
  9992. return match
  9993. }
  9994. };
  9995. StringStream.prototype.current = function (){return this.string.slice(this.start, this.pos)};
  9996. StringStream.prototype.hideFirstChars = function (n, inner) {
  9997. this.lineStart += n;
  9998. try { return inner() }
  9999. finally { this.lineStart -= n; }
  10000. };
  10001. StringStream.prototype.lookAhead = function (n) {
  10002. var oracle = this.lineOracle;
  10003. return oracle && oracle.lookAhead(n)
  10004. };
  10005. StringStream.prototype.baseToken = function () {
  10006. var oracle = this.lineOracle;
  10007. return oracle && oracle.baseToken(this.pos)
  10008. };
  10009. var SavedContext = function(state, lookAhead) {
  10010. this.state = state;
  10011. this.lookAhead = lookAhead;
  10012. };
  10013. var Context = function(doc, state, line, lookAhead) {
  10014. this.state = state;
  10015. this.doc = doc;
  10016. this.line = line;
  10017. this.maxLookAhead = lookAhead || 0;
  10018. this.baseTokens = null;
  10019. this.baseTokenPos = 1;
  10020. };
  10021. Context.prototype.lookAhead = function (n) {
  10022. var line = this.doc.getLine(this.line + n);
  10023. if (line != null && n > this.maxLookAhead) { this.maxLookAhead = n; }
  10024. return line
  10025. };
  10026. Context.prototype.baseToken = function (n) {
  10027. var this$1 = this;
  10028. if (!this.baseTokens) { return null }
  10029. while (this.baseTokens[this.baseTokenPos] <= n)
  10030. { this$1.baseTokenPos += 2; }
  10031. var type = this.baseTokens[this.baseTokenPos + 1];
  10032. return {type: type && type.replace(/( |^)overlay .*/, ""),
  10033. size: this.baseTokens[this.baseTokenPos] - n}
  10034. };
  10035. Context.prototype.nextLine = function () {
  10036. this.line++;
  10037. if (this.maxLookAhead > 0) { this.maxLookAhead--; }
  10038. };
  10039. Context.fromSaved = function (doc, saved, line) {
  10040. if (saved instanceof SavedContext)
  10041. { return new Context(doc, copyState(doc.mode, saved.state), line, saved.lookAhead) }
  10042. else
  10043. { return new Context(doc, copyState(doc.mode, saved), line) }
  10044. };
  10045. Context.prototype.save = function (copy) {
  10046. var state = copy !== false ? copyState(this.doc.mode, this.state) : this.state;
  10047. return this.maxLookAhead > 0 ? new SavedContext(state, this.maxLookAhead) : state
  10048. };
  10049. // Compute a style array (an array starting with a mode generation
  10050. // -- for invalidation -- followed by pairs of end positions and
  10051. // style strings), which is used to highlight the tokens on the
  10052. // line.
  10053. function highlightLine(cm, line, context, forceToEnd) {
  10054. // A styles array always starts with a number identifying the
  10055. // mode/overlays that it is based on (for easy invalidation).
  10056. var st = [cm.state.modeGen], lineClasses = {};
  10057. // Compute the base array of styles
  10058. runMode(cm, line.text, cm.doc.mode, context, function (end, style) { return st.push(end, style); },
  10059. lineClasses, forceToEnd);
  10060. var state = context.state;
  10061. // Run overlays, adjust style array.
  10062. var loop = function ( o ) {
  10063. context.baseTokens = st;
  10064. var overlay = cm.state.overlays[o], i = 1, at = 0;
  10065. context.state = true;
  10066. runMode(cm, line.text, overlay.mode, context, function (end, style) {
  10067. var start = i;
  10068. // Ensure there's a token end at the current position, and that i points at it
  10069. while (at < end) {
  10070. var i_end = st[i];
  10071. if (i_end > end)
  10072. { st.splice(i, 1, end, st[i+1], i_end); }
  10073. i += 2;
  10074. at = Math.min(end, i_end);
  10075. }
  10076. if (!style) { return }
  10077. if (overlay.opaque) {
  10078. st.splice(start, i - start, end, "overlay " + style);
  10079. i = start + 2;
  10080. } else {
  10081. for (; start < i; start += 2) {
  10082. var cur = st[start+1];
  10083. st[start+1] = (cur ? cur + " " : "") + "overlay " + style;
  10084. }
  10085. }
  10086. }, lineClasses);
  10087. context.state = state;
  10088. context.baseTokens = null;
  10089. context.baseTokenPos = 1;
  10090. };
  10091. for (var o = 0; o < cm.state.overlays.length; ++o) loop( o );
  10092. return {styles: st, classes: lineClasses.bgClass || lineClasses.textClass ? lineClasses : null}
  10093. }
  10094. function getLineStyles(cm, line, updateFrontier) {
  10095. if (!line.styles || line.styles[0] != cm.state.modeGen) {
  10096. var context = getContextBefore(cm, lineNo(line));
  10097. var resetState = line.text.length > cm.options.maxHighlightLength && copyState(cm.doc.mode, context.state);
  10098. var result = highlightLine(cm, line, context);
  10099. if (resetState) { context.state = resetState; }
  10100. line.stateAfter = context.save(!resetState);
  10101. line.styles = result.styles;
  10102. if (result.classes) { line.styleClasses = result.classes; }
  10103. else if (line.styleClasses) { line.styleClasses = null; }
  10104. if (updateFrontier === cm.doc.highlightFrontier)
  10105. { cm.doc.modeFrontier = Math.max(cm.doc.modeFrontier, ++cm.doc.highlightFrontier); }
  10106. }
  10107. return line.styles
  10108. }
  10109. function getContextBefore(cm, n, precise) {
  10110. var doc = cm.doc, display = cm.display;
  10111. if (!doc.mode.startState) { return new Context(doc, true, n) }
  10112. var start = findStartLine(cm, n, precise);
  10113. var saved = start > doc.first && getLine(doc, start - 1).stateAfter;
  10114. var context = saved ? Context.fromSaved(doc, saved, start) : new Context(doc, startState(doc.mode), start);
  10115. doc.iter(start, n, function (line) {
  10116. processLine(cm, line.text, context);
  10117. var pos = context.line;
  10118. line.stateAfter = pos == n - 1 || pos % 5 == 0 || pos >= display.viewFrom && pos < display.viewTo ? context.save() : null;
  10119. context.nextLine();
  10120. });
  10121. if (precise) { doc.modeFrontier = context.line; }
  10122. return context
  10123. }
  10124. // Lightweight form of highlight -- proceed over this line and
  10125. // update state, but don't save a style array. Used for lines that
  10126. // aren't currently visible.
  10127. function processLine(cm, text, context, startAt) {
  10128. var mode = cm.doc.mode;
  10129. var stream = new StringStream(text, cm.options.tabSize, context);
  10130. stream.start = stream.pos = startAt || 0;
  10131. if (text == "") { callBlankLine(mode, context.state); }
  10132. while (!stream.eol()) {
  10133. readToken(mode, stream, context.state);
  10134. stream.start = stream.pos;
  10135. }
  10136. }
  10137. function callBlankLine(mode, state) {
  10138. if (mode.blankLine) { return mode.blankLine(state) }
  10139. if (!mode.innerMode) { return }
  10140. var inner = innerMode(mode, state);
  10141. if (inner.mode.blankLine) { return inner.mode.blankLine(inner.state) }
  10142. }
  10143. function readToken(mode, stream, state, inner) {
  10144. for (var i = 0; i < 10; i++) {
  10145. if (inner) { inner[0] = innerMode(mode, state).mode; }
  10146. var style = mode.token(stream, state);
  10147. if (stream.pos > stream.start) { return style }
  10148. }
  10149. throw new Error("Mode " + mode.name + " failed to advance stream.")
  10150. }
  10151. var Token = function(stream, type, state) {
  10152. this.start = stream.start; this.end = stream.pos;
  10153. this.string = stream.current();
  10154. this.type = type || null;
  10155. this.state = state;
  10156. };
  10157. // Utility for getTokenAt and getLineTokens
  10158. function takeToken(cm, pos, precise, asArray) {
  10159. var doc = cm.doc, mode = doc.mode, style;
  10160. pos = clipPos(doc, pos);
  10161. var line = getLine(doc, pos.line), context = getContextBefore(cm, pos.line, precise);
  10162. var stream = new StringStream(line.text, cm.options.tabSize, context), tokens;
  10163. if (asArray) { tokens = []; }
  10164. while ((asArray || stream.pos < pos.ch) && !stream.eol()) {
  10165. stream.start = stream.pos;
  10166. style = readToken(mode, stream, context.state);
  10167. if (asArray) { tokens.push(new Token(stream, style, copyState(doc.mode, context.state))); }
  10168. }
  10169. return asArray ? tokens : new Token(stream, style, context.state)
  10170. }
  10171. function extractLineClasses(type, output) {
  10172. if (type) { for (;;) {
  10173. var lineClass = type.match(/(?:^|\s+)line-(background-)?(\S+)/);
  10174. if (!lineClass) { break }
  10175. type = type.slice(0, lineClass.index) + type.slice(lineClass.index + lineClass[0].length);
  10176. var prop = lineClass[1] ? "bgClass" : "textClass";
  10177. if (output[prop] == null)
  10178. { output[prop] = lineClass[2]; }
  10179. else if (!(new RegExp("(?:^|\s)" + lineClass[2] + "(?:$|\s)")).test(output[prop]))
  10180. { output[prop] += " " + lineClass[2]; }
  10181. } }
  10182. return type
  10183. }
  10184. // Run the given mode's parser over a line, calling f for each token.
  10185. function runMode(cm, text, mode, context, f, lineClasses, forceToEnd) {
  10186. var flattenSpans = mode.flattenSpans;
  10187. if (flattenSpans == null) { flattenSpans = cm.options.flattenSpans; }
  10188. var curStart = 0, curStyle = null;
  10189. var stream = new StringStream(text, cm.options.tabSize, context), style;
  10190. var inner = cm.options.addModeClass && [null];
  10191. if (text == "") { extractLineClasses(callBlankLine(mode, context.state), lineClasses); }
  10192. while (!stream.eol()) {
  10193. if (stream.pos > cm.options.maxHighlightLength) {
  10194. flattenSpans = false;
  10195. if (forceToEnd) { processLine(cm, text, context, stream.pos); }
  10196. stream.pos = text.length;
  10197. style = null;
  10198. } else {
  10199. style = extractLineClasses(readToken(mode, stream, context.state, inner), lineClasses);
  10200. }
  10201. if (inner) {
  10202. var mName = inner[0].name;
  10203. if (mName) { style = "m-" + (style ? mName + " " + style : mName); }
  10204. }
  10205. if (!flattenSpans || curStyle != style) {
  10206. while (curStart < stream.start) {
  10207. curStart = Math.min(stream.start, curStart + 5000);
  10208. f(curStart, curStyle);
  10209. }
  10210. curStyle = style;
  10211. }
  10212. stream.start = stream.pos;
  10213. }
  10214. while (curStart < stream.pos) {
  10215. // Webkit seems to refuse to render text nodes longer than 57444
  10216. // characters, and returns inaccurate measurements in nodes
  10217. // starting around 5000 chars.
  10218. var pos = Math.min(stream.pos, curStart + 5000);
  10219. f(pos, curStyle);
  10220. curStart = pos;
  10221. }
  10222. }
  10223. // Finds the line to start with when starting a parse. Tries to
  10224. // find a line with a stateAfter, so that it can start with a
  10225. // valid state. If that fails, it returns the line with the
  10226. // smallest indentation, which tends to need the least context to
  10227. // parse correctly.
  10228. function findStartLine(cm, n, precise) {
  10229. var minindent, minline, doc = cm.doc;
  10230. var lim = precise ? -1 : n - (cm.doc.mode.innerMode ? 1000 : 100);
  10231. for (var search = n; search > lim; --search) {
  10232. if (search <= doc.first) { return doc.first }
  10233. var line = getLine(doc, search - 1), after = line.stateAfter;
  10234. if (after && (!precise || search + (after instanceof SavedContext ? after.lookAhead : 0) <= doc.modeFrontier))
  10235. { return search }
  10236. var indented = countColumn(line.text, null, cm.options.tabSize);
  10237. if (minline == null || minindent > indented) {
  10238. minline = search - 1;
  10239. minindent = indented;
  10240. }
  10241. }
  10242. return minline
  10243. }
  10244. function retreatFrontier(doc, n) {
  10245. doc.modeFrontier = Math.min(doc.modeFrontier, n);
  10246. if (doc.highlightFrontier < n - 10) { return }
  10247. var start = doc.first;
  10248. for (var line = n - 1; line > start; line--) {
  10249. var saved = getLine(doc, line).stateAfter;
  10250. // change is on 3
  10251. // state on line 1 looked ahead 2 -- so saw 3
  10252. // test 1 + 2 < 3 should cover this
  10253. if (saved && (!(saved instanceof SavedContext) || line + saved.lookAhead < n)) {
  10254. start = line + 1;
  10255. break
  10256. }
  10257. }
  10258. doc.highlightFrontier = Math.min(doc.highlightFrontier, start);
  10259. }
  10260. // LINE DATA STRUCTURE
  10261. // Line objects. These hold state related to a line, including
  10262. // highlighting info (the styles array).
  10263. var Line = function(text, markedSpans, estimateHeight) {
  10264. this.text = text;
  10265. attachMarkedSpans(this, markedSpans);
  10266. this.height = estimateHeight ? estimateHeight(this) : 1;
  10267. };
  10268. Line.prototype.lineNo = function () { return lineNo(this) };
  10269. eventMixin(Line);
  10270. // Change the content (text, markers) of a line. Automatically
  10271. // invalidates cached information and tries to re-estimate the
  10272. // line's height.
  10273. function updateLine(line, text, markedSpans, estimateHeight) {
  10274. line.text = text;
  10275. if (line.stateAfter) { line.stateAfter = null; }
  10276. if (line.styles) { line.styles = null; }
  10277. if (line.order != null) { line.order = null; }
  10278. detachMarkedSpans(line);
  10279. attachMarkedSpans(line, markedSpans);
  10280. var estHeight = estimateHeight ? estimateHeight(line) : 1;
  10281. if (estHeight != line.height) { updateLineHeight(line, estHeight); }
  10282. }
  10283. // Detach a line from the document tree and its markers.
  10284. function cleanUpLine(line) {
  10285. line.parent = null;
  10286. detachMarkedSpans(line);
  10287. }
  10288. // Convert a style as returned by a mode (either null, or a string
  10289. // containing one or more styles) to a CSS style. This is cached,
  10290. // and also looks for line-wide styles.
  10291. var styleToClassCache = {};
  10292. var styleToClassCacheWithMode = {};
  10293. function interpretTokenStyle(style, options) {
  10294. if (!style || /^\s*$/.test(style)) { return null }
  10295. var cache = options.addModeClass ? styleToClassCacheWithMode : styleToClassCache;
  10296. return cache[style] ||
  10297. (cache[style] = style.replace(/\S+/g, "cm-$&"))
  10298. }
  10299. // Render the DOM representation of the text of a line. Also builds
  10300. // up a 'line map', which points at the DOM nodes that represent
  10301. // specific stretches of text, and is used by the measuring code.
  10302. // The returned object contains the DOM node, this map, and
  10303. // information about line-wide styles that were set by the mode.
  10304. function buildLineContent(cm, lineView) {
  10305. // The padding-right forces the element to have a 'border', which
  10306. // is needed on Webkit to be able to get line-level bounding
  10307. // rectangles for it (in measureChar).
  10308. var content = eltP("span", null, null, webkit ? "padding-right: .1px" : null);
  10309. var builder = {pre: eltP("pre", [content], "CodeMirror-line"), content: content,
  10310. col: 0, pos: 0, cm: cm,
  10311. trailingSpace: false,
  10312. splitSpaces: (ie || webkit) && cm.getOption("lineWrapping")};
  10313. lineView.measure = {};
  10314. // Iterate over the logical lines that make up this visual line.
  10315. for (var i = 0; i <= (lineView.rest ? lineView.rest.length : 0); i++) {
  10316. var line = i ? lineView.rest[i - 1] : lineView.line, order = (void 0);
  10317. builder.pos = 0;
  10318. builder.addToken = buildToken;
  10319. // Optionally wire in some hacks into the token-rendering
  10320. // algorithm, to deal with browser quirks.
  10321. if (hasBadBidiRects(cm.display.measure) && (order = getOrder(line, cm.doc.direction)))
  10322. { builder.addToken = buildTokenBadBidi(builder.addToken, order); }
  10323. builder.map = [];
  10324. var allowFrontierUpdate = lineView != cm.display.externalMeasured && lineNo(line);
  10325. insertLineContent(line, builder, getLineStyles(cm, line, allowFrontierUpdate));
  10326. if (line.styleClasses) {
  10327. if (line.styleClasses.bgClass)
  10328. { builder.bgClass = joinClasses(line.styleClasses.bgClass, builder.bgClass || ""); }
  10329. if (line.styleClasses.textClass)
  10330. { builder.textClass = joinClasses(line.styleClasses.textClass, builder.textClass || ""); }
  10331. }
  10332. // Ensure at least a single node is present, for measuring.
  10333. if (builder.map.length == 0)
  10334. { builder.map.push(0, 0, builder.content.appendChild(zeroWidthElement(cm.display.measure))); }
  10335. // Store the map and a cache object for the current logical line
  10336. if (i == 0) {
  10337. lineView.measure.map = builder.map;
  10338. lineView.measure.cache = {};
  10339. } else {
  10340. (lineView.measure.maps || (lineView.measure.maps = [])).push(builder.map)
  10341. ;(lineView.measure.caches || (lineView.measure.caches = [])).push({});
  10342. }
  10343. }
  10344. // See issue #2901
  10345. if (webkit) {
  10346. var last = builder.content.lastChild;
  10347. if (/\bcm-tab\b/.test(last.className) || (last.querySelector && last.querySelector(".cm-tab")))
  10348. { builder.content.className = "cm-tab-wrap-hack"; }
  10349. }
  10350. signal(cm, "renderLine", cm, lineView.line, builder.pre);
  10351. if (builder.pre.className)
  10352. { builder.textClass = joinClasses(builder.pre.className, builder.textClass || ""); }
  10353. return builder
  10354. }
  10355. function defaultSpecialCharPlaceholder(ch) {
  10356. var token = elt("span", "\u2022", "cm-invalidchar");
  10357. token.title = "\\u" + ch.charCodeAt(0).toString(16);
  10358. token.setAttribute("aria-label", token.title);
  10359. return token
  10360. }
  10361. // Build up the DOM representation for a single token, and add it to
  10362. // the line map. Takes care to render special characters separately.
  10363. function buildToken(builder, text, style, startStyle, endStyle, title, css) {
  10364. if (!text) { return }
  10365. var displayText = builder.splitSpaces ? splitSpaces(text, builder.trailingSpace) : text;
  10366. var special = builder.cm.state.specialChars, mustWrap = false;
  10367. var content;
  10368. if (!special.test(text)) {
  10369. builder.col += text.length;
  10370. content = document.createTextNode(displayText);
  10371. builder.map.push(builder.pos, builder.pos + text.length, content);
  10372. if (ie && ie_version < 9) { mustWrap = true; }
  10373. builder.pos += text.length;
  10374. } else {
  10375. content = document.createDocumentFragment();
  10376. var pos = 0;
  10377. while (true) {
  10378. special.lastIndex = pos;
  10379. var m = special.exec(text);
  10380. var skipped = m ? m.index - pos : text.length - pos;
  10381. if (skipped) {
  10382. var txt = document.createTextNode(displayText.slice(pos, pos + skipped));
  10383. if (ie && ie_version < 9) { content.appendChild(elt("span", [txt])); }
  10384. else { content.appendChild(txt); }
  10385. builder.map.push(builder.pos, builder.pos + skipped, txt);
  10386. builder.col += skipped;
  10387. builder.pos += skipped;
  10388. }
  10389. if (!m) { break }
  10390. pos += skipped + 1;
  10391. var txt$1 = (void 0);
  10392. if (m[0] == "\t") {
  10393. var tabSize = builder.cm.options.tabSize, tabWidth = tabSize - builder.col % tabSize;
  10394. txt$1 = content.appendChild(elt("span", spaceStr(tabWidth), "cm-tab"));
  10395. txt$1.setAttribute("role", "presentation");
  10396. txt$1.setAttribute("cm-text", "\t");
  10397. builder.col += tabWidth;
  10398. } else if (m[0] == "\r" || m[0] == "\n") {
  10399. txt$1 = content.appendChild(elt("span", m[0] == "\r" ? "\u240d" : "\u2424", "cm-invalidchar"));
  10400. txt$1.setAttribute("cm-text", m[0]);
  10401. builder.col += 1;
  10402. } else {
  10403. txt$1 = builder.cm.options.specialCharPlaceholder(m[0]);
  10404. txt$1.setAttribute("cm-text", m[0]);
  10405. if (ie && ie_version < 9) { content.appendChild(elt("span", [txt$1])); }
  10406. else { content.appendChild(txt$1); }
  10407. builder.col += 1;
  10408. }
  10409. builder.map.push(builder.pos, builder.pos + 1, txt$1);
  10410. builder.pos++;
  10411. }
  10412. }
  10413. builder.trailingSpace = displayText.charCodeAt(text.length - 1) == 32;
  10414. if (style || startStyle || endStyle || mustWrap || css) {
  10415. var fullStyle = style || "";
  10416. if (startStyle) { fullStyle += startStyle; }
  10417. if (endStyle) { fullStyle += endStyle; }
  10418. var token = elt("span", [content], fullStyle, css);
  10419. if (title) { token.title = title; }
  10420. return builder.content.appendChild(token)
  10421. }
  10422. builder.content.appendChild(content);
  10423. }
  10424. function splitSpaces(text, trailingBefore) {
  10425. if (text.length > 1 && !/ /.test(text)) { return text }
  10426. var spaceBefore = trailingBefore, result = "";
  10427. for (var i = 0; i < text.length; i++) {
  10428. var ch = text.charAt(i);
  10429. if (ch == " " && spaceBefore && (i == text.length - 1 || text.charCodeAt(i + 1) == 32))
  10430. { ch = "\u00a0"; }
  10431. result += ch;
  10432. spaceBefore = ch == " ";
  10433. }
  10434. return result
  10435. }
  10436. // Work around nonsense dimensions being reported for stretches of
  10437. // right-to-left text.
  10438. function buildTokenBadBidi(inner, order) {
  10439. return function (builder, text, style, startStyle, endStyle, title, css) {
  10440. style = style ? style + " cm-force-border" : "cm-force-border";
  10441. var start = builder.pos, end = start + text.length;
  10442. for (;;) {
  10443. // Find the part that overlaps with the start of this text
  10444. var part = (void 0);
  10445. for (var i = 0; i < order.length; i++) {
  10446. part = order[i];
  10447. if (part.to > start && part.from <= start) { break }
  10448. }
  10449. if (part.to >= end) { return inner(builder, text, style, startStyle, endStyle, title, css) }
  10450. inner(builder, text.slice(0, part.to - start), style, startStyle, null, title, css);
  10451. startStyle = null;
  10452. text = text.slice(part.to - start);
  10453. start = part.to;
  10454. }
  10455. }
  10456. }
  10457. function buildCollapsedSpan(builder, size, marker, ignoreWidget) {
  10458. var widget = !ignoreWidget && marker.widgetNode;
  10459. if (widget) { builder.map.push(builder.pos, builder.pos + size, widget); }
  10460. if (!ignoreWidget && builder.cm.display.input.needsContentAttribute) {
  10461. if (!widget)
  10462. { widget = builder.content.appendChild(document.createElement("span")); }
  10463. widget.setAttribute("cm-marker", marker.id);
  10464. }
  10465. if (widget) {
  10466. builder.cm.display.input.setUneditable(widget);
  10467. builder.content.appendChild(widget);
  10468. }
  10469. builder.pos += size;
  10470. builder.trailingSpace = false;
  10471. }
  10472. // Outputs a number of spans to make up a line, taking highlighting
  10473. // and marked text into account.
  10474. function insertLineContent(line, builder, styles) {
  10475. var spans = line.markedSpans, allText = line.text, at = 0;
  10476. if (!spans) {
  10477. for (var i$1 = 1; i$1 < styles.length; i$1+=2)
  10478. { builder.addToken(builder, allText.slice(at, at = styles[i$1]), interpretTokenStyle(styles[i$1+1], builder.cm.options)); }
  10479. return
  10480. }
  10481. var len = allText.length, pos = 0, i = 1, text = "", style, css;
  10482. var nextChange = 0, spanStyle, spanEndStyle, spanStartStyle, title, collapsed;
  10483. for (;;) {
  10484. if (nextChange == pos) { // Update current marker set
  10485. spanStyle = spanEndStyle = spanStartStyle = title = css = "";
  10486. collapsed = null; nextChange = Infinity;
  10487. var foundBookmarks = [], endStyles = (void 0);
  10488. for (var j = 0; j < spans.length; ++j) {
  10489. var sp = spans[j], m = sp.marker;
  10490. if (m.type == "bookmark" && sp.from == pos && m.widgetNode) {
  10491. foundBookmarks.push(m);
  10492. } else if (sp.from <= pos && (sp.to == null || sp.to > pos || m.collapsed && sp.to == pos && sp.from == pos)) {
  10493. if (sp.to != null && sp.to != pos && nextChange > sp.to) {
  10494. nextChange = sp.to;
  10495. spanEndStyle = "";
  10496. }
  10497. if (m.className) { spanStyle += " " + m.className; }
  10498. if (m.css) { css = (css ? css + ";" : "") + m.css; }
  10499. if (m.startStyle && sp.from == pos) { spanStartStyle += " " + m.startStyle; }
  10500. if (m.endStyle && sp.to == nextChange) { (endStyles || (endStyles = [])).push(m.endStyle, sp.to); }
  10501. if (m.title && !title) { title = m.title; }
  10502. if (m.collapsed && (!collapsed || compareCollapsedMarkers(collapsed.marker, m) < 0))
  10503. { collapsed = sp; }
  10504. } else if (sp.from > pos && nextChange > sp.from) {
  10505. nextChange = sp.from;
  10506. }
  10507. }
  10508. if (endStyles) { for (var j$1 = 0; j$1 < endStyles.length; j$1 += 2)
  10509. { if (endStyles[j$1 + 1] == nextChange) { spanEndStyle += " " + endStyles[j$1]; } } }
  10510. if (!collapsed || collapsed.from == pos) { for (var j$2 = 0; j$2 < foundBookmarks.length; ++j$2)
  10511. { buildCollapsedSpan(builder, 0, foundBookmarks[j$2]); } }
  10512. if (collapsed && (collapsed.from || 0) == pos) {
  10513. buildCollapsedSpan(builder, (collapsed.to == null ? len + 1 : collapsed.to) - pos,
  10514. collapsed.marker, collapsed.from == null);
  10515. if (collapsed.to == null) { return }
  10516. if (collapsed.to == pos) { collapsed = false; }
  10517. }
  10518. }
  10519. if (pos >= len) { break }
  10520. var upto = Math.min(len, nextChange);
  10521. while (true) {
  10522. if (text) {
  10523. var end = pos + text.length;
  10524. if (!collapsed) {
  10525. var tokenText = end > upto ? text.slice(0, upto - pos) : text;
  10526. builder.addToken(builder, tokenText, style ? style + spanStyle : spanStyle,
  10527. spanStartStyle, pos + tokenText.length == nextChange ? spanEndStyle : "", title, css);
  10528. }
  10529. if (end >= upto) {text = text.slice(upto - pos); pos = upto; break}
  10530. pos = end;
  10531. spanStartStyle = "";
  10532. }
  10533. text = allText.slice(at, at = styles[i++]);
  10534. style = interpretTokenStyle(styles[i++], builder.cm.options);
  10535. }
  10536. }
  10537. }
  10538. // These objects are used to represent the visible (currently drawn)
  10539. // part of the document. A LineView may correspond to multiple
  10540. // logical lines, if those are connected by collapsed ranges.
  10541. function LineView(doc, line, lineN) {
  10542. // The starting line
  10543. this.line = line;
  10544. // Continuing lines, if any
  10545. this.rest = visualLineContinued(line);
  10546. // Number of logical lines in this visual line
  10547. this.size = this.rest ? lineNo(lst(this.rest)) - lineN + 1 : 1;
  10548. this.node = this.text = null;
  10549. this.hidden = lineIsHidden(doc, line);
  10550. }
  10551. // Create a range of LineView objects for the given lines.
  10552. function buildViewArray(cm, from, to) {
  10553. var array = [], nextPos;
  10554. for (var pos = from; pos < to; pos = nextPos) {
  10555. var view = new LineView(cm.doc, getLine(cm.doc, pos), pos);
  10556. nextPos = pos + view.size;
  10557. array.push(view);
  10558. }
  10559. return array
  10560. }
  10561. var operationGroup = null;
  10562. function pushOperation(op) {
  10563. if (operationGroup) {
  10564. operationGroup.ops.push(op);
  10565. } else {
  10566. op.ownsGroup = operationGroup = {
  10567. ops: [op],
  10568. delayedCallbacks: []
  10569. };
  10570. }
  10571. }
  10572. function fireCallbacksForOps(group) {
  10573. // Calls delayed callbacks and cursorActivity handlers until no
  10574. // new ones appear
  10575. var callbacks = group.delayedCallbacks, i = 0;
  10576. do {
  10577. for (; i < callbacks.length; i++)
  10578. { callbacks[i].call(null); }
  10579. for (var j = 0; j < group.ops.length; j++) {
  10580. var op = group.ops[j];
  10581. if (op.cursorActivityHandlers)
  10582. { while (op.cursorActivityCalled < op.cursorActivityHandlers.length)
  10583. { op.cursorActivityHandlers[op.cursorActivityCalled++].call(null, op.cm); } }
  10584. }
  10585. } while (i < callbacks.length)
  10586. }
  10587. function finishOperation(op, endCb) {
  10588. var group = op.ownsGroup;
  10589. if (!group) { return }
  10590. try { fireCallbacksForOps(group); }
  10591. finally {
  10592. operationGroup = null;
  10593. endCb(group);
  10594. }
  10595. }
  10596. var orphanDelayedCallbacks = null;
  10597. // Often, we want to signal events at a point where we are in the
  10598. // middle of some work, but don't want the handler to start calling
  10599. // other methods on the editor, which might be in an inconsistent
  10600. // state or simply not expect any other events to happen.
  10601. // signalLater looks whether there are any handlers, and schedules
  10602. // them to be executed when the last operation ends, or, if no
  10603. // operation is active, when a timeout fires.
  10604. function signalLater(emitter, type /*, values...*/) {
  10605. var arr = getHandlers(emitter, type);
  10606. if (!arr.length) { return }
  10607. var args = Array.prototype.slice.call(arguments, 2), list;
  10608. if (operationGroup) {
  10609. list = operationGroup.delayedCallbacks;
  10610. } else if (orphanDelayedCallbacks) {
  10611. list = orphanDelayedCallbacks;
  10612. } else {
  10613. list = orphanDelayedCallbacks = [];
  10614. setTimeout(fireOrphanDelayed, 0);
  10615. }
  10616. var loop = function ( i ) {
  10617. list.push(function () { return arr[i].apply(null, args); });
  10618. };
  10619. for (var i = 0; i < arr.length; ++i)
  10620. loop( i );
  10621. }
  10622. function fireOrphanDelayed() {
  10623. var delayed = orphanDelayedCallbacks;
  10624. orphanDelayedCallbacks = null;
  10625. for (var i = 0; i < delayed.length; ++i) { delayed[i](); }
  10626. }
  10627. // When an aspect of a line changes, a string is added to
  10628. // lineView.changes. This updates the relevant part of the line's
  10629. // DOM structure.
  10630. function updateLineForChanges(cm, lineView, lineN, dims) {
  10631. for (var j = 0; j < lineView.changes.length; j++) {
  10632. var type = lineView.changes[j];
  10633. if (type == "text") { updateLineText(cm, lineView); }
  10634. else if (type == "gutter") { updateLineGutter(cm, lineView, lineN, dims); }
  10635. else if (type == "class") { updateLineClasses(cm, lineView); }
  10636. else if (type == "widget") { updateLineWidgets(cm, lineView, dims); }
  10637. }
  10638. lineView.changes = null;
  10639. }
  10640. // Lines with gutter elements, widgets or a background class need to
  10641. // be wrapped, and have the extra elements added to the wrapper div
  10642. function ensureLineWrapped(lineView) {
  10643. if (lineView.node == lineView.text) {
  10644. lineView.node = elt("div", null, null, "position: relative");
  10645. if (lineView.text.parentNode)
  10646. { lineView.text.parentNode.replaceChild(lineView.node, lineView.text); }
  10647. lineView.node.appendChild(lineView.text);
  10648. if (ie && ie_version < 8) { lineView.node.style.zIndex = 2; }
  10649. }
  10650. return lineView.node
  10651. }
  10652. function updateLineBackground(cm, lineView) {
  10653. var cls = lineView.bgClass ? lineView.bgClass + " " + (lineView.line.bgClass || "") : lineView.line.bgClass;
  10654. if (cls) { cls += " CodeMirror-linebackground"; }
  10655. if (lineView.background) {
  10656. if (cls) { lineView.background.className = cls; }
  10657. else { lineView.background.parentNode.removeChild(lineView.background); lineView.background = null; }
  10658. } else if (cls) {
  10659. var wrap = ensureLineWrapped(lineView);
  10660. lineView.background = wrap.insertBefore(elt("div", null, cls), wrap.firstChild);
  10661. cm.display.input.setUneditable(lineView.background);
  10662. }
  10663. }
  10664. // Wrapper around buildLineContent which will reuse the structure
  10665. // in display.externalMeasured when possible.
  10666. function getLineContent(cm, lineView) {
  10667. var ext = cm.display.externalMeasured;
  10668. if (ext && ext.line == lineView.line) {
  10669. cm.display.externalMeasured = null;
  10670. lineView.measure = ext.measure;
  10671. return ext.built
  10672. }
  10673. return buildLineContent(cm, lineView)
  10674. }
  10675. // Redraw the line's text. Interacts with the background and text
  10676. // classes because the mode may output tokens that influence these
  10677. // classes.
  10678. function updateLineText(cm, lineView) {
  10679. var cls = lineView.text.className;
  10680. var built = getLineContent(cm, lineView);
  10681. if (lineView.text == lineView.node) { lineView.node = built.pre; }
  10682. lineView.text.parentNode.replaceChild(built.pre, lineView.text);
  10683. lineView.text = built.pre;
  10684. if (built.bgClass != lineView.bgClass || built.textClass != lineView.textClass) {
  10685. lineView.bgClass = built.bgClass;
  10686. lineView.textClass = built.textClass;
  10687. updateLineClasses(cm, lineView);
  10688. } else if (cls) {
  10689. lineView.text.className = cls;
  10690. }
  10691. }
  10692. function updateLineClasses(cm, lineView) {
  10693. updateLineBackground(cm, lineView);
  10694. if (lineView.line.wrapClass)
  10695. { ensureLineWrapped(lineView).className = lineView.line.wrapClass; }
  10696. else if (lineView.node != lineView.text)
  10697. { lineView.node.className = ""; }
  10698. var textClass = lineView.textClass ? lineView.textClass + " " + (lineView.line.textClass || "") : lineView.line.textClass;
  10699. lineView.text.className = textClass || "";
  10700. }
  10701. function updateLineGutter(cm, lineView, lineN, dims) {
  10702. if (lineView.gutter) {
  10703. lineView.node.removeChild(lineView.gutter);
  10704. lineView.gutter = null;
  10705. }
  10706. if (lineView.gutterBackground) {
  10707. lineView.node.removeChild(lineView.gutterBackground);
  10708. lineView.gutterBackground = null;
  10709. }
  10710. if (lineView.line.gutterClass) {
  10711. var wrap = ensureLineWrapped(lineView);
  10712. lineView.gutterBackground = elt("div", null, "CodeMirror-gutter-background " + lineView.line.gutterClass,
  10713. ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px; width: " + (dims.gutterTotalWidth) + "px"));
  10714. cm.display.input.setUneditable(lineView.gutterBackground);
  10715. wrap.insertBefore(lineView.gutterBackground, lineView.text);
  10716. }
  10717. var markers = lineView.line.gutterMarkers;
  10718. if (cm.options.lineNumbers || markers) {
  10719. var wrap$1 = ensureLineWrapped(lineView);
  10720. var gutterWrap = lineView.gutter = elt("div", null, "CodeMirror-gutter-wrapper", ("left: " + (cm.options.fixedGutter ? dims.fixedPos : -dims.gutterTotalWidth) + "px"));
  10721. cm.display.input.setUneditable(gutterWrap);
  10722. wrap$1.insertBefore(gutterWrap, lineView.text);
  10723. if (lineView.line.gutterClass)
  10724. { gutterWrap.className += " " + lineView.line.gutterClass; }
  10725. if (cm.options.lineNumbers && (!markers || !markers["CodeMirror-linenumbers"]))
  10726. { lineView.lineNumber = gutterWrap.appendChild(
  10727. elt("div", lineNumberFor(cm.options, lineN),
  10728. "CodeMirror-linenumber CodeMirror-gutter-elt",
  10729. ("left: " + (dims.gutterLeft["CodeMirror-linenumbers"]) + "px; width: " + (cm.display.lineNumInnerWidth) + "px"))); }
  10730. if (markers) { for (var k = 0; k < cm.options.gutters.length; ++k) {
  10731. var id = cm.options.gutters[k], found = markers.hasOwnProperty(id) && markers[id];
  10732. if (found)
  10733. { gutterWrap.appendChild(elt("div", [found], "CodeMirror-gutter-elt",
  10734. ("left: " + (dims.gutterLeft[id]) + "px; width: " + (dims.gutterWidth[id]) + "px"))); }
  10735. } }
  10736. }
  10737. }
  10738. function updateLineWidgets(cm, lineView, dims) {
  10739. if (lineView.alignable) { lineView.alignable = null; }
  10740. for (var node = lineView.node.firstChild, next = (void 0); node; node = next) {
  10741. next = node.nextSibling;
  10742. if (node.className == "CodeMirror-linewidget")
  10743. { lineView.node.removeChild(node); }
  10744. }
  10745. insertLineWidgets(cm, lineView, dims);
  10746. }
  10747. // Build a line's DOM representation from scratch
  10748. function buildLineElement(cm, lineView, lineN, dims) {
  10749. var built = getLineContent(cm, lineView);
  10750. lineView.text = lineView.node = built.pre;
  10751. if (built.bgClass) { lineView.bgClass = built.bgClass; }
  10752. if (built.textClass) { lineView.textClass = built.textClass; }
  10753. updateLineClasses(cm, lineView);
  10754. updateLineGutter(cm, lineView, lineN, dims);
  10755. insertLineWidgets(cm, lineView, dims);
  10756. return lineView.node
  10757. }
  10758. // A lineView may contain multiple logical lines (when merged by
  10759. // collapsed spans). The widgets for all of them need to be drawn.
  10760. function insertLineWidgets(cm, lineView, dims) {
  10761. insertLineWidgetsFor(cm, lineView.line, lineView, dims, true);
  10762. if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
  10763. { insertLineWidgetsFor(cm, lineView.rest[i], lineView, dims, false); } }
  10764. }
  10765. function insertLineWidgetsFor(cm, line, lineView, dims, allowAbove) {
  10766. if (!line.widgets) { return }
  10767. var wrap = ensureLineWrapped(lineView);
  10768. for (var i = 0, ws = line.widgets; i < ws.length; ++i) {
  10769. var widget = ws[i], node = elt("div", [widget.node], "CodeMirror-linewidget");
  10770. if (!widget.handleMouseEvents) { node.setAttribute("cm-ignore-events", "true"); }
  10771. positionLineWidget(widget, node, lineView, dims);
  10772. cm.display.input.setUneditable(node);
  10773. if (allowAbove && widget.above)
  10774. { wrap.insertBefore(node, lineView.gutter || lineView.text); }
  10775. else
  10776. { wrap.appendChild(node); }
  10777. signalLater(widget, "redraw");
  10778. }
  10779. }
  10780. function positionLineWidget(widget, node, lineView, dims) {
  10781. if (widget.noHScroll) {
  10782. (lineView.alignable || (lineView.alignable = [])).push(node);
  10783. var width = dims.wrapperWidth;
  10784. node.style.left = dims.fixedPos + "px";
  10785. if (!widget.coverGutter) {
  10786. width -= dims.gutterTotalWidth;
  10787. node.style.paddingLeft = dims.gutterTotalWidth + "px";
  10788. }
  10789. node.style.width = width + "px";
  10790. }
  10791. if (widget.coverGutter) {
  10792. node.style.zIndex = 5;
  10793. node.style.position = "relative";
  10794. if (!widget.noHScroll) { node.style.marginLeft = -dims.gutterTotalWidth + "px"; }
  10795. }
  10796. }
  10797. function widgetHeight(widget) {
  10798. if (widget.height != null) { return widget.height }
  10799. var cm = widget.doc.cm;
  10800. if (!cm) { return 0 }
  10801. if (!contains(document.body, widget.node)) {
  10802. var parentStyle = "position: relative;";
  10803. if (widget.coverGutter)
  10804. { parentStyle += "margin-left: -" + cm.display.gutters.offsetWidth + "px;"; }
  10805. if (widget.noHScroll)
  10806. { parentStyle += "width: " + cm.display.wrapper.clientWidth + "px;"; }
  10807. removeChildrenAndAdd(cm.display.measure, elt("div", [widget.node], null, parentStyle));
  10808. }
  10809. return widget.height = widget.node.parentNode.offsetHeight
  10810. }
  10811. // Return true when the given mouse event happened in a widget
  10812. function eventInWidget(display, e) {
  10813. for (var n = e_target(e); n != display.wrapper; n = n.parentNode) {
  10814. if (!n || (n.nodeType == 1 && n.getAttribute("cm-ignore-events") == "true") ||
  10815. (n.parentNode == display.sizer && n != display.mover))
  10816. { return true }
  10817. }
  10818. }
  10819. // POSITION MEASUREMENT
  10820. function paddingTop(display) {return display.lineSpace.offsetTop}
  10821. function paddingVert(display) {return display.mover.offsetHeight - display.lineSpace.offsetHeight}
  10822. function paddingH(display) {
  10823. if (display.cachedPaddingH) { return display.cachedPaddingH }
  10824. var e = removeChildrenAndAdd(display.measure, elt("pre", "x"));
  10825. var style = window.getComputedStyle ? window.getComputedStyle(e) : e.currentStyle;
  10826. var data = {left: parseInt(style.paddingLeft), right: parseInt(style.paddingRight)};
  10827. if (!isNaN(data.left) && !isNaN(data.right)) { display.cachedPaddingH = data; }
  10828. return data
  10829. }
  10830. function scrollGap(cm) { return scrollerGap - cm.display.nativeBarWidth }
  10831. function displayWidth(cm) {
  10832. return cm.display.scroller.clientWidth - scrollGap(cm) - cm.display.barWidth
  10833. }
  10834. function displayHeight(cm) {
  10835. return cm.display.scroller.clientHeight - scrollGap(cm) - cm.display.barHeight
  10836. }
  10837. // Ensure the lineView.wrapping.heights array is populated. This is
  10838. // an array of bottom offsets for the lines that make up a drawn
  10839. // line. When lineWrapping is on, there might be more than one
  10840. // height.
  10841. function ensureLineHeights(cm, lineView, rect) {
  10842. var wrapping = cm.options.lineWrapping;
  10843. var curWidth = wrapping && displayWidth(cm);
  10844. if (!lineView.measure.heights || wrapping && lineView.measure.width != curWidth) {
  10845. var heights = lineView.measure.heights = [];
  10846. if (wrapping) {
  10847. lineView.measure.width = curWidth;
  10848. var rects = lineView.text.firstChild.getClientRects();
  10849. for (var i = 0; i < rects.length - 1; i++) {
  10850. var cur = rects[i], next = rects[i + 1];
  10851. if (Math.abs(cur.bottom - next.bottom) > 2)
  10852. { heights.push((cur.bottom + next.top) / 2 - rect.top); }
  10853. }
  10854. }
  10855. heights.push(rect.bottom - rect.top);
  10856. }
  10857. }
  10858. // Find a line map (mapping character offsets to text nodes) and a
  10859. // measurement cache for the given line number. (A line view might
  10860. // contain multiple lines when collapsed ranges are present.)
  10861. function mapFromLineView(lineView, line, lineN) {
  10862. if (lineView.line == line)
  10863. { return {map: lineView.measure.map, cache: lineView.measure.cache} }
  10864. for (var i = 0; i < lineView.rest.length; i++)
  10865. { if (lineView.rest[i] == line)
  10866. { return {map: lineView.measure.maps[i], cache: lineView.measure.caches[i]} } }
  10867. for (var i$1 = 0; i$1 < lineView.rest.length; i$1++)
  10868. { if (lineNo(lineView.rest[i$1]) > lineN)
  10869. { return {map: lineView.measure.maps[i$1], cache: lineView.measure.caches[i$1], before: true} } }
  10870. }
  10871. // Render a line into the hidden node display.externalMeasured. Used
  10872. // when measurement is needed for a line that's not in the viewport.
  10873. function updateExternalMeasurement(cm, line) {
  10874. line = visualLine(line);
  10875. var lineN = lineNo(line);
  10876. var view = cm.display.externalMeasured = new LineView(cm.doc, line, lineN);
  10877. view.lineN = lineN;
  10878. var built = view.built = buildLineContent(cm, view);
  10879. view.text = built.pre;
  10880. removeChildrenAndAdd(cm.display.lineMeasure, built.pre);
  10881. return view
  10882. }
  10883. // Get a {top, bottom, left, right} box (in line-local coordinates)
  10884. // for a given character.
  10885. function measureChar(cm, line, ch, bias) {
  10886. return measureCharPrepared(cm, prepareMeasureForLine(cm, line), ch, bias)
  10887. }
  10888. // Find a line view that corresponds to the given line number.
  10889. function findViewForLine(cm, lineN) {
  10890. if (lineN >= cm.display.viewFrom && lineN < cm.display.viewTo)
  10891. { return cm.display.view[findViewIndex(cm, lineN)] }
  10892. var ext = cm.display.externalMeasured;
  10893. if (ext && lineN >= ext.lineN && lineN < ext.lineN + ext.size)
  10894. { return ext }
  10895. }
  10896. // Measurement can be split in two steps, the set-up work that
  10897. // applies to the whole line, and the measurement of the actual
  10898. // character. Functions like coordsChar, that need to do a lot of
  10899. // measurements in a row, can thus ensure that the set-up work is
  10900. // only done once.
  10901. function prepareMeasureForLine(cm, line) {
  10902. var lineN = lineNo(line);
  10903. var view = findViewForLine(cm, lineN);
  10904. if (view && !view.text) {
  10905. view = null;
  10906. } else if (view && view.changes) {
  10907. updateLineForChanges(cm, view, lineN, getDimensions(cm));
  10908. cm.curOp.forceUpdate = true;
  10909. }
  10910. if (!view)
  10911. { view = updateExternalMeasurement(cm, line); }
  10912. var info = mapFromLineView(view, line, lineN);
  10913. return {
  10914. line: line, view: view, rect: null,
  10915. map: info.map, cache: info.cache, before: info.before,
  10916. hasHeights: false
  10917. }
  10918. }
  10919. // Given a prepared measurement object, measures the position of an
  10920. // actual character (or fetches it from the cache).
  10921. function measureCharPrepared(cm, prepared, ch, bias, varHeight) {
  10922. if (prepared.before) { ch = -1; }
  10923. var key = ch + (bias || ""), found;
  10924. if (prepared.cache.hasOwnProperty(key)) {
  10925. found = prepared.cache[key];
  10926. } else {
  10927. if (!prepared.rect)
  10928. { prepared.rect = prepared.view.text.getBoundingClientRect(); }
  10929. if (!prepared.hasHeights) {
  10930. ensureLineHeights(cm, prepared.view, prepared.rect);
  10931. prepared.hasHeights = true;
  10932. }
  10933. found = measureCharInner(cm, prepared, ch, bias);
  10934. if (!found.bogus) { prepared.cache[key] = found; }
  10935. }
  10936. return {left: found.left, right: found.right,
  10937. top: varHeight ? found.rtop : found.top,
  10938. bottom: varHeight ? found.rbottom : found.bottom}
  10939. }
  10940. var nullRect = {left: 0, right: 0, top: 0, bottom: 0};
  10941. function nodeAndOffsetInLineMap(map$$1, ch, bias) {
  10942. var node, start, end, collapse, mStart, mEnd;
  10943. // First, search the line map for the text node corresponding to,
  10944. // or closest to, the target character.
  10945. for (var i = 0; i < map$$1.length; i += 3) {
  10946. mStart = map$$1[i];
  10947. mEnd = map$$1[i + 1];
  10948. if (ch < mStart) {
  10949. start = 0; end = 1;
  10950. collapse = "left";
  10951. } else if (ch < mEnd) {
  10952. start = ch - mStart;
  10953. end = start + 1;
  10954. } else if (i == map$$1.length - 3 || ch == mEnd && map$$1[i + 3] > ch) {
  10955. end = mEnd - mStart;
  10956. start = end - 1;
  10957. if (ch >= mEnd) { collapse = "right"; }
  10958. }
  10959. if (start != null) {
  10960. node = map$$1[i + 2];
  10961. if (mStart == mEnd && bias == (node.insertLeft ? "left" : "right"))
  10962. { collapse = bias; }
  10963. if (bias == "left" && start == 0)
  10964. { while (i && map$$1[i - 2] == map$$1[i - 3] && map$$1[i - 1].insertLeft) {
  10965. node = map$$1[(i -= 3) + 2];
  10966. collapse = "left";
  10967. } }
  10968. if (bias == "right" && start == mEnd - mStart)
  10969. { while (i < map$$1.length - 3 && map$$1[i + 3] == map$$1[i + 4] && !map$$1[i + 5].insertLeft) {
  10970. node = map$$1[(i += 3) + 2];
  10971. collapse = "right";
  10972. } }
  10973. break
  10974. }
  10975. }
  10976. return {node: node, start: start, end: end, collapse: collapse, coverStart: mStart, coverEnd: mEnd}
  10977. }
  10978. function getUsefulRect(rects, bias) {
  10979. var rect = nullRect;
  10980. if (bias == "left") { for (var i = 0; i < rects.length; i++) {
  10981. if ((rect = rects[i]).left != rect.right) { break }
  10982. } } else { for (var i$1 = rects.length - 1; i$1 >= 0; i$1--) {
  10983. if ((rect = rects[i$1]).left != rect.right) { break }
  10984. } }
  10985. return rect
  10986. }
  10987. function measureCharInner(cm, prepared, ch, bias) {
  10988. var place = nodeAndOffsetInLineMap(prepared.map, ch, bias);
  10989. var node = place.node, start = place.start, end = place.end, collapse = place.collapse;
  10990. var rect;
  10991. if (node.nodeType == 3) { // If it is a text node, use a range to retrieve the coordinates.
  10992. for (var i$1 = 0; i$1 < 4; i$1++) { // Retry a maximum of 4 times when nonsense rectangles are returned
  10993. while (start && isExtendingChar(prepared.line.text.charAt(place.coverStart + start))) { --start; }
  10994. while (place.coverStart + end < place.coverEnd && isExtendingChar(prepared.line.text.charAt(place.coverStart + end))) { ++end; }
  10995. if (ie && ie_version < 9 && start == 0 && end == place.coverEnd - place.coverStart)
  10996. { rect = node.parentNode.getBoundingClientRect(); }
  10997. else
  10998. { rect = getUsefulRect(range(node, start, end).getClientRects(), bias); }
  10999. if (rect.left || rect.right || start == 0) { break }
  11000. end = start;
  11001. start = start - 1;
  11002. collapse = "right";
  11003. }
  11004. if (ie && ie_version < 11) { rect = maybeUpdateRectForZooming(cm.display.measure, rect); }
  11005. } else { // If it is a widget, simply get the box for the whole widget.
  11006. if (start > 0) { collapse = bias = "right"; }
  11007. var rects;
  11008. if (cm.options.lineWrapping && (rects = node.getClientRects()).length > 1)
  11009. { rect = rects[bias == "right" ? rects.length - 1 : 0]; }
  11010. else
  11011. { rect = node.getBoundingClientRect(); }
  11012. }
  11013. if (ie && ie_version < 9 && !start && (!rect || !rect.left && !rect.right)) {
  11014. var rSpan = node.parentNode.getClientRects()[0];
  11015. if (rSpan)
  11016. { rect = {left: rSpan.left, right: rSpan.left + charWidth(cm.display), top: rSpan.top, bottom: rSpan.bottom}; }
  11017. else
  11018. { rect = nullRect; }
  11019. }
  11020. var rtop = rect.top - prepared.rect.top, rbot = rect.bottom - prepared.rect.top;
  11021. var mid = (rtop + rbot) / 2;
  11022. var heights = prepared.view.measure.heights;
  11023. var i = 0;
  11024. for (; i < heights.length - 1; i++)
  11025. { if (mid < heights[i]) { break } }
  11026. var top = i ? heights[i - 1] : 0, bot = heights[i];
  11027. var result = {left: (collapse == "right" ? rect.right : rect.left) - prepared.rect.left,
  11028. right: (collapse == "left" ? rect.left : rect.right) - prepared.rect.left,
  11029. top: top, bottom: bot};
  11030. if (!rect.left && !rect.right) { result.bogus = true; }
  11031. if (!cm.options.singleCursorHeightPerLine) { result.rtop = rtop; result.rbottom = rbot; }
  11032. return result
  11033. }
  11034. // Work around problem with bounding client rects on ranges being
  11035. // returned incorrectly when zoomed on IE10 and below.
  11036. function maybeUpdateRectForZooming(measure, rect) {
  11037. if (!window.screen || screen.logicalXDPI == null ||
  11038. screen.logicalXDPI == screen.deviceXDPI || !hasBadZoomedRects(measure))
  11039. { return rect }
  11040. var scaleX = screen.logicalXDPI / screen.deviceXDPI;
  11041. var scaleY = screen.logicalYDPI / screen.deviceYDPI;
  11042. return {left: rect.left * scaleX, right: rect.right * scaleX,
  11043. top: rect.top * scaleY, bottom: rect.bottom * scaleY}
  11044. }
  11045. function clearLineMeasurementCacheFor(lineView) {
  11046. if (lineView.measure) {
  11047. lineView.measure.cache = {};
  11048. lineView.measure.heights = null;
  11049. if (lineView.rest) { for (var i = 0; i < lineView.rest.length; i++)
  11050. { lineView.measure.caches[i] = {}; } }
  11051. }
  11052. }
  11053. function clearLineMeasurementCache(cm) {
  11054. cm.display.externalMeasure = null;
  11055. removeChildren(cm.display.lineMeasure);
  11056. for (var i = 0; i < cm.display.view.length; i++)
  11057. { clearLineMeasurementCacheFor(cm.display.view[i]); }
  11058. }
  11059. function clearCaches(cm) {
  11060. clearLineMeasurementCache(cm);
  11061. cm.display.cachedCharWidth = cm.display.cachedTextHeight = cm.display.cachedPaddingH = null;
  11062. if (!cm.options.lineWrapping) { cm.display.maxLineChanged = true; }
  11063. cm.display.lineNumChars = null;
  11064. }
  11065. function pageScrollX() {
  11066. // Work around https://bugs.chromium.org/p/chromium/issues/detail?id=489206
  11067. // which causes page_Offset and bounding client rects to use
  11068. // different reference viewports and invalidate our calculations.
  11069. if (chrome && android) { return -(document.body.getBoundingClientRect().left - parseInt(getComputedStyle(document.body).marginLeft)) }
  11070. return window.pageXOffset || (document.documentElement || document.body).scrollLeft
  11071. }
  11072. function pageScrollY() {
  11073. if (chrome && android) { return -(document.body.getBoundingClientRect().top - parseInt(getComputedStyle(document.body).marginTop)) }
  11074. return window.pageYOffset || (document.documentElement || document.body).scrollTop
  11075. }
  11076. function widgetTopHeight(lineObj) {
  11077. var height = 0;
  11078. if (lineObj.widgets) { for (var i = 0; i < lineObj.widgets.length; ++i) { if (lineObj.widgets[i].above)
  11079. { height += widgetHeight(lineObj.widgets[i]); } } }
  11080. return height
  11081. }
  11082. // Converts a {top, bottom, left, right} box from line-local
  11083. // coordinates into another coordinate system. Context may be one of
  11084. // "line", "div" (display.lineDiv), "local"./null (editor), "window",
  11085. // or "page".
  11086. function intoCoordSystem(cm, lineObj, rect, context, includeWidgets) {
  11087. if (!includeWidgets) {
  11088. var height = widgetTopHeight(lineObj);
  11089. rect.top += height; rect.bottom += height;
  11090. }
  11091. if (context == "line") { return rect }
  11092. if (!context) { context = "local"; }
  11093. var yOff = heightAtLine(lineObj);
  11094. if (context == "local") { yOff += paddingTop(cm.display); }
  11095. else { yOff -= cm.display.viewOffset; }
  11096. if (context == "page" || context == "window") {
  11097. var lOff = cm.display.lineSpace.getBoundingClientRect();
  11098. yOff += lOff.top + (context == "window" ? 0 : pageScrollY());
  11099. var xOff = lOff.left + (context == "window" ? 0 : pageScrollX());
  11100. rect.left += xOff; rect.right += xOff;
  11101. }
  11102. rect.top += yOff; rect.bottom += yOff;
  11103. return rect
  11104. }
  11105. // Coverts a box from "div" coords to another coordinate system.
  11106. // Context may be "window", "page", "div", or "local"./null.
  11107. function fromCoordSystem(cm, coords, context) {
  11108. if (context == "div") { return coords }
  11109. var left = coords.left, top = coords.top;
  11110. // First move into "page" coordinate system
  11111. if (context == "page") {
  11112. left -= pageScrollX();
  11113. top -= pageScrollY();
  11114. } else if (context == "local" || !context) {
  11115. var localBox = cm.display.sizer.getBoundingClientRect();
  11116. left += localBox.left;
  11117. top += localBox.top;
  11118. }
  11119. var lineSpaceBox = cm.display.lineSpace.getBoundingClientRect();
  11120. return {left: left - lineSpaceBox.left, top: top - lineSpaceBox.top}
  11121. }
  11122. function charCoords(cm, pos, context, lineObj, bias) {
  11123. if (!lineObj) { lineObj = getLine(cm.doc, pos.line); }
  11124. return intoCoordSystem(cm, lineObj, measureChar(cm, lineObj, pos.ch, bias), context)
  11125. }
  11126. // Returns a box for a given cursor position, which may have an
  11127. // 'other' property containing the position of the secondary cursor
  11128. // on a bidi boundary.
  11129. // A cursor Pos(line, char, "before") is on the same visual line as `char - 1`
  11130. // and after `char - 1` in writing order of `char - 1`
  11131. // A cursor Pos(line, char, "after") is on the same visual line as `char`
  11132. // and before `char` in writing order of `char`
  11133. // Examples (upper-case letters are RTL, lower-case are LTR):
  11134. // Pos(0, 1, ...)
  11135. // before after
  11136. // ab a|b a|b
  11137. // aB a|B aB|
  11138. // Ab |Ab A|b
  11139. // AB B|A B|A
  11140. // Every position after the last character on a line is considered to stick
  11141. // to the last character on the line.
  11142. function cursorCoords(cm, pos, context, lineObj, preparedMeasure, varHeight) {
  11143. lineObj = lineObj || getLine(cm.doc, pos.line);
  11144. if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
  11145. function get(ch, right) {
  11146. var m = measureCharPrepared(cm, preparedMeasure, ch, right ? "right" : "left", varHeight);
  11147. if (right) { m.left = m.right; } else { m.right = m.left; }
  11148. return intoCoordSystem(cm, lineObj, m, context)
  11149. }
  11150. var order = getOrder(lineObj, cm.doc.direction), ch = pos.ch, sticky = pos.sticky;
  11151. if (ch >= lineObj.text.length) {
  11152. ch = lineObj.text.length;
  11153. sticky = "before";
  11154. } else if (ch <= 0) {
  11155. ch = 0;
  11156. sticky = "after";
  11157. }
  11158. if (!order) { return get(sticky == "before" ? ch - 1 : ch, sticky == "before") }
  11159. function getBidi(ch, partPos, invert) {
  11160. var part = order[partPos], right = part.level == 1;
  11161. return get(invert ? ch - 1 : ch, right != invert)
  11162. }
  11163. var partPos = getBidiPartAt(order, ch, sticky);
  11164. var other = bidiOther;
  11165. var val = getBidi(ch, partPos, sticky == "before");
  11166. if (other != null) { val.other = getBidi(ch, other, sticky != "before"); }
  11167. return val
  11168. }
  11169. // Used to cheaply estimate the coordinates for a position. Used for
  11170. // intermediate scroll updates.
  11171. function estimateCoords(cm, pos) {
  11172. var left = 0;
  11173. pos = clipPos(cm.doc, pos);
  11174. if (!cm.options.lineWrapping) { left = charWidth(cm.display) * pos.ch; }
  11175. var lineObj = getLine(cm.doc, pos.line);
  11176. var top = heightAtLine(lineObj) + paddingTop(cm.display);
  11177. return {left: left, right: left, top: top, bottom: top + lineObj.height}
  11178. }
  11179. // Positions returned by coordsChar contain some extra information.
  11180. // xRel is the relative x position of the input coordinates compared
  11181. // to the found position (so xRel > 0 means the coordinates are to
  11182. // the right of the character position, for example). When outside
  11183. // is true, that means the coordinates lie outside the line's
  11184. // vertical range.
  11185. function PosWithInfo(line, ch, sticky, outside, xRel) {
  11186. var pos = Pos(line, ch, sticky);
  11187. pos.xRel = xRel;
  11188. if (outside) { pos.outside = true; }
  11189. return pos
  11190. }
  11191. // Compute the character position closest to the given coordinates.
  11192. // Input must be lineSpace-local ("div" coordinate system).
  11193. function coordsChar(cm, x, y) {
  11194. var doc = cm.doc;
  11195. y += cm.display.viewOffset;
  11196. if (y < 0) { return PosWithInfo(doc.first, 0, null, true, -1) }
  11197. var lineN = lineAtHeight(doc, y), last = doc.first + doc.size - 1;
  11198. if (lineN > last)
  11199. { return PosWithInfo(doc.first + doc.size - 1, getLine(doc, last).text.length, null, true, 1) }
  11200. if (x < 0) { x = 0; }
  11201. var lineObj = getLine(doc, lineN);
  11202. for (;;) {
  11203. var found = coordsCharInner(cm, lineObj, lineN, x, y);
  11204. var merged = collapsedSpanAtEnd(lineObj);
  11205. var mergedPos = merged && merged.find(0, true);
  11206. if (merged && (found.ch > mergedPos.from.ch || found.ch == mergedPos.from.ch && found.xRel > 0))
  11207. { lineN = lineNo(lineObj = mergedPos.to.line); }
  11208. else
  11209. { return found }
  11210. }
  11211. }
  11212. function wrappedLineExtent(cm, lineObj, preparedMeasure, y) {
  11213. y -= widgetTopHeight(lineObj);
  11214. var end = lineObj.text.length;
  11215. var begin = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch - 1).bottom <= y; }, end, 0);
  11216. end = findFirst(function (ch) { return measureCharPrepared(cm, preparedMeasure, ch).top > y; }, begin, end);
  11217. return {begin: begin, end: end}
  11218. }
  11219. function wrappedLineExtentChar(cm, lineObj, preparedMeasure, target) {
  11220. if (!preparedMeasure) { preparedMeasure = prepareMeasureForLine(cm, lineObj); }
  11221. var targetTop = intoCoordSystem(cm, lineObj, measureCharPrepared(cm, preparedMeasure, target), "line").top;
  11222. return wrappedLineExtent(cm, lineObj, preparedMeasure, targetTop)
  11223. }
  11224. // Returns true if the given side of a box is after the given
  11225. // coordinates, in top-to-bottom, left-to-right order.
  11226. function boxIsAfter(box, x, y, left) {
  11227. return box.bottom <= y ? false : box.top > y ? true : (left ? box.left : box.right) > x
  11228. }
  11229. function coordsCharInner(cm, lineObj, lineNo$$1, x, y) {
  11230. // Move y into line-local coordinate space
  11231. y -= heightAtLine(lineObj);
  11232. var preparedMeasure = prepareMeasureForLine(cm, lineObj);
  11233. // When directly calling `measureCharPrepared`, we have to adjust
  11234. // for the widgets at this line.
  11235. var widgetHeight$$1 = widgetTopHeight(lineObj);
  11236. var begin = 0, end = lineObj.text.length, ltr = true;
  11237. var order = getOrder(lineObj, cm.doc.direction);
  11238. // If the line isn't plain left-to-right text, first figure out
  11239. // which bidi section the coordinates fall into.
  11240. if (order) {
  11241. var part = (cm.options.lineWrapping ? coordsBidiPartWrapped : coordsBidiPart)
  11242. (cm, lineObj, lineNo$$1, preparedMeasure, order, x, y);
  11243. ltr = part.level != 1;
  11244. // The awkward -1 offsets are needed because findFirst (called
  11245. // on these below) will treat its first bound as inclusive,
  11246. // second as exclusive, but we want to actually address the
  11247. // characters in the part's range
  11248. begin = ltr ? part.from : part.to - 1;
  11249. end = ltr ? part.to : part.from - 1;
  11250. }
  11251. // A binary search to find the first character whose bounding box
  11252. // starts after the coordinates. If we run across any whose box wrap
  11253. // the coordinates, store that.
  11254. var chAround = null, boxAround = null;
  11255. var ch = findFirst(function (ch) {
  11256. var box = measureCharPrepared(cm, preparedMeasure, ch);
  11257. box.top += widgetHeight$$1; box.bottom += widgetHeight$$1;
  11258. if (!boxIsAfter(box, x, y, false)) { return false }
  11259. if (box.top <= y && box.left <= x) {
  11260. chAround = ch;
  11261. boxAround = box;
  11262. }
  11263. return true
  11264. }, begin, end);
  11265. var baseX, sticky, outside = false;
  11266. // If a box around the coordinates was found, use that
  11267. if (boxAround) {
  11268. // Distinguish coordinates nearer to the left or right side of the box
  11269. var atLeft = x - boxAround.left < boxAround.right - x, atStart = atLeft == ltr;
  11270. ch = chAround + (atStart ? 0 : 1);
  11271. sticky = atStart ? "after" : "before";
  11272. baseX = atLeft ? boxAround.left : boxAround.right;
  11273. } else {
  11274. // (Adjust for extended bound, if necessary.)
  11275. if (!ltr && (ch == end || ch == begin)) { ch++; }
  11276. // To determine which side to associate with, get the box to the
  11277. // left of the character and compare it's vertical position to the
  11278. // coordinates
  11279. sticky = ch == 0 ? "after" : ch == lineObj.text.length ? "before" :
  11280. (measureCharPrepared(cm, preparedMeasure, ch - (ltr ? 1 : 0)).bottom + widgetHeight$$1 <= y) == ltr ?
  11281. "after" : "before";
  11282. // Now get accurate coordinates for this place, in order to get a
  11283. // base X position
  11284. var coords = cursorCoords(cm, Pos(lineNo$$1, ch, sticky), "line", lineObj, preparedMeasure);
  11285. baseX = coords.left;
  11286. outside = y < coords.top || y >= coords.bottom;
  11287. }
  11288. ch = skipExtendingChars(lineObj.text, ch, 1);
  11289. return PosWithInfo(lineNo$$1, ch, sticky, outside, x - baseX)
  11290. }
  11291. function coordsBidiPart(cm, lineObj, lineNo$$1, preparedMeasure, order, x, y) {
  11292. // Bidi parts are sorted left-to-right, and in a non-line-wrapping
  11293. // situation, we can take this ordering to correspond to the visual
  11294. // ordering. This finds the first part whose end is after the given
  11295. // coordinates.
  11296. var index = findFirst(function (i) {
  11297. var part = order[i], ltr = part.level != 1;
  11298. return boxIsAfter(cursorCoords(cm, Pos(lineNo$$1, ltr ? part.to : part.from, ltr ? "before" : "after"),
  11299. "line", lineObj, preparedMeasure), x, y, true)
  11300. }, 0, order.length - 1);
  11301. var part = order[index];
  11302. // If this isn't the first part, the part's start is also after
  11303. // the coordinates, and the coordinates aren't on the same line as
  11304. // that start, move one part back.
  11305. if (index > 0) {
  11306. var ltr = part.level != 1;
  11307. var start = cursorCoords(cm, Pos(lineNo$$1, ltr ? part.from : part.to, ltr ? "after" : "before"),
  11308. "line", lineObj, preparedMeasure);
  11309. if (boxIsAfter(start, x, y, true) && start.top > y)
  11310. { part = order[index - 1]; }
  11311. }
  11312. return part
  11313. }
  11314. function coordsBidiPartWrapped(cm, lineObj, _lineNo, preparedMeasure, order, x, y) {
  11315. // In a wrapped line, rtl text on wrapping boundaries can do things
  11316. // that don't correspond to the ordering in our `order` array at
  11317. // all, so a binary search doesn't work, and we want to return a
  11318. // part that only spans one line so that the binary search in
  11319. // coordsCharInner is safe. As such, we first find the extent of the
  11320. // wrapped line, and then do a flat search in which we discard any
  11321. // spans that aren't on the line.
  11322. var ref = wrappedLineExtent(cm, lineObj, preparedMeasure, y);
  11323. var begin = ref.begin;
  11324. var end = ref.end;
  11325. if (/\s/.test(lineObj.text.charAt(end - 1))) { end--; }
  11326. var part = null, closestDist = null;
  11327. for (var i = 0; i < order.length; i++) {
  11328. var p = order[i];
  11329. if (p.from >= end || p.to <= begin) { continue }
  11330. var ltr = p.level != 1;
  11331. var endX = measureCharPrepared(cm, preparedMeasure, ltr ? Math.min(end, p.to) - 1 : Math.max(begin, p.from)).right;
  11332. // Weigh against spans ending before this, so that they are only
  11333. // picked if nothing ends after
  11334. var dist = endX < x ? x - endX + 1e9 : endX - x;
  11335. if (!part || closestDist > dist) {
  11336. part = p;
  11337. closestDist = dist;
  11338. }
  11339. }
  11340. if (!part) { part = order[order.length - 1]; }
  11341. // Clip the part to the wrapped line.
  11342. if (part.from < begin) { part = {from: begin, to: part.to, level: part.level}; }
  11343. if (part.to > end) { part = {from: part.from, to: end, level: part.level}; }
  11344. return part
  11345. }
  11346. var measureText;
  11347. // Compute the default text height.
  11348. function textHeight(display) {
  11349. if (display.cachedTextHeight != null) { return display.cachedTextHeight }
  11350. if (measureText == null) {
  11351. measureText = elt("pre");
  11352. // Measure a bunch of lines, for browsers that compute
  11353. // fractional heights.
  11354. for (var i = 0; i < 49; ++i) {
  11355. measureText.appendChild(document.createTextNode("x"));
  11356. measureText.appendChild(elt("br"));
  11357. }
  11358. measureText.appendChild(document.createTextNode("x"));
  11359. }
  11360. removeChildrenAndAdd(display.measure, measureText);
  11361. var height = measureText.offsetHeight / 50;
  11362. if (height > 3) { display.cachedTextHeight = height; }
  11363. removeChildren(display.measure);
  11364. return height || 1
  11365. }
  11366. // Compute the default character width.
  11367. function charWidth(display) {
  11368. if (display.cachedCharWidth != null) { return display.cachedCharWidth }
  11369. var anchor = elt("span", "xxxxxxxxxx");
  11370. var pre = elt("pre", [anchor]);
  11371. removeChildrenAndAdd(display.measure, pre);
  11372. var rect = anchor.getBoundingClientRect(), width = (rect.right - rect.left) / 10;
  11373. if (width > 2) { display.cachedCharWidth = width; }
  11374. return width || 10
  11375. }
  11376. // Do a bulk-read of the DOM positions and sizes needed to draw the
  11377. // view, so that we don't interleave reading and writing to the DOM.
  11378. function getDimensions(cm) {
  11379. var d = cm.display, left = {}, width = {};
  11380. var gutterLeft = d.gutters.clientLeft;
  11381. for (var n = d.gutters.firstChild, i = 0; n; n = n.nextSibling, ++i) {
  11382. left[cm.options.gutters[i]] = n.offsetLeft + n.clientLeft + gutterLeft;
  11383. width[cm.options.gutters[i]] = n.clientWidth;
  11384. }
  11385. return {fixedPos: compensateForHScroll(d),
  11386. gutterTotalWidth: d.gutters.offsetWidth,
  11387. gutterLeft: left,
  11388. gutterWidth: width,
  11389. wrapperWidth: d.wrapper.clientWidth}
  11390. }
  11391. // Computes display.scroller.scrollLeft + display.gutters.offsetWidth,
  11392. // but using getBoundingClientRect to get a sub-pixel-accurate
  11393. // result.
  11394. function compensateForHScroll(display) {
  11395. return display.scroller.getBoundingClientRect().left - display.sizer.getBoundingClientRect().left
  11396. }
  11397. // Returns a function that estimates the height of a line, to use as
  11398. // first approximation until the line becomes visible (and is thus
  11399. // properly measurable).
  11400. function estimateHeight(cm) {
  11401. var th = textHeight(cm.display), wrapping = cm.options.lineWrapping;
  11402. var perLine = wrapping && Math.max(5, cm.display.scroller.clientWidth / charWidth(cm.display) - 3);
  11403. return function (line) {
  11404. if (lineIsHidden(cm.doc, line)) { return 0 }
  11405. var widgetsHeight = 0;
  11406. if (line.widgets) { for (var i = 0; i < line.widgets.length; i++) {
  11407. if (line.widgets[i].height) { widgetsHeight += line.widgets[i].height; }
  11408. } }
  11409. if (wrapping)
  11410. { return widgetsHeight + (Math.ceil(line.text.length / perLine) || 1) * th }
  11411. else
  11412. { return widgetsHeight + th }
  11413. }
  11414. }
  11415. function estimateLineHeights(cm) {
  11416. var doc = cm.doc, est = estimateHeight(cm);
  11417. doc.iter(function (line) {
  11418. var estHeight = est(line);
  11419. if (estHeight != line.height) { updateLineHeight(line, estHeight); }
  11420. });
  11421. }
  11422. // Given a mouse event, find the corresponding position. If liberal
  11423. // is false, it checks whether a gutter or scrollbar was clicked,
  11424. // and returns null if it was. forRect is used by rectangular
  11425. // selections, and tries to estimate a character position even for
  11426. // coordinates beyond the right of the text.
  11427. function posFromMouse(cm, e, liberal, forRect) {
  11428. var display = cm.display;
  11429. if (!liberal && e_target(e).getAttribute("cm-not-content") == "true") { return null }
  11430. var x, y, space = display.lineSpace.getBoundingClientRect();
  11431. // Fails unpredictably on IE[67] when mouse is dragged around quickly.
  11432. try { x = e.clientX - space.left; y = e.clientY - space.top; }
  11433. catch (e) { return null }
  11434. var coords = coordsChar(cm, x, y), line;
  11435. if (forRect && coords.xRel == 1 && (line = getLine(cm.doc, coords.line).text).length == coords.ch) {
  11436. var colDiff = countColumn(line, line.length, cm.options.tabSize) - line.length;
  11437. coords = Pos(coords.line, Math.max(0, Math.round((x - paddingH(cm.display).left) / charWidth(cm.display)) - colDiff));
  11438. }
  11439. return coords
  11440. }
  11441. // Find the view element corresponding to a given line. Return null
  11442. // when the line isn't visible.
  11443. function findViewIndex(cm, n) {
  11444. if (n >= cm.display.viewTo) { return null }
  11445. n -= cm.display.viewFrom;
  11446. if (n < 0) { return null }
  11447. var view = cm.display.view;
  11448. for (var i = 0; i < view.length; i++) {
  11449. n -= view[i].size;
  11450. if (n < 0) { return i }
  11451. }
  11452. }
  11453. function updateSelection(cm) {
  11454. cm.display.input.showSelection(cm.display.input.prepareSelection());
  11455. }
  11456. function prepareSelection(cm, primary) {
  11457. if ( primary === void 0 ) primary = true;
  11458. var doc = cm.doc, result = {};
  11459. var curFragment = result.cursors = document.createDocumentFragment();
  11460. var selFragment = result.selection = document.createDocumentFragment();
  11461. for (var i = 0; i < doc.sel.ranges.length; i++) {
  11462. if (!primary && i == doc.sel.primIndex) { continue }
  11463. var range$$1 = doc.sel.ranges[i];
  11464. if (range$$1.from().line >= cm.display.viewTo || range$$1.to().line < cm.display.viewFrom) { continue }
  11465. var collapsed = range$$1.empty();
  11466. if (collapsed || cm.options.showCursorWhenSelecting)
  11467. { drawSelectionCursor(cm, range$$1.head, curFragment); }
  11468. if (!collapsed)
  11469. { drawSelectionRange(cm, range$$1, selFragment); }
  11470. }
  11471. return result
  11472. }
  11473. // Draws a cursor for the given range
  11474. function drawSelectionCursor(cm, head, output) {
  11475. var pos = cursorCoords(cm, head, "div", null, null, !cm.options.singleCursorHeightPerLine);
  11476. var cursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor"));
  11477. cursor.style.left = pos.left + "px";
  11478. cursor.style.top = pos.top + "px";
  11479. cursor.style.height = Math.max(0, pos.bottom - pos.top) * cm.options.cursorHeight + "px";
  11480. if (pos.other) {
  11481. // Secondary cursor, shown when on a 'jump' in bi-directional text
  11482. var otherCursor = output.appendChild(elt("div", "\u00a0", "CodeMirror-cursor CodeMirror-secondarycursor"));
  11483. otherCursor.style.display = "";
  11484. otherCursor.style.left = pos.other.left + "px";
  11485. otherCursor.style.top = pos.other.top + "px";
  11486. otherCursor.style.height = (pos.other.bottom - pos.other.top) * .85 + "px";
  11487. }
  11488. }
  11489. function cmpCoords(a, b) { return a.top - b.top || a.left - b.left }
  11490. // Draws the given range as a highlighted selection
  11491. function drawSelectionRange(cm, range$$1, output) {
  11492. var display = cm.display, doc = cm.doc;
  11493. var fragment = document.createDocumentFragment();
  11494. var padding = paddingH(cm.display), leftSide = padding.left;
  11495. var rightSide = Math.max(display.sizerWidth, displayWidth(cm) - display.sizer.offsetLeft) - padding.right;
  11496. var docLTR = doc.direction == "ltr";
  11497. function add(left, top, width, bottom) {
  11498. if (top < 0) { top = 0; }
  11499. top = Math.round(top);
  11500. bottom = Math.round(bottom);
  11501. 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")));
  11502. }
  11503. function drawForLine(line, fromArg, toArg) {
  11504. var lineObj = getLine(doc, line);
  11505. var lineLen = lineObj.text.length;
  11506. var start, end;
  11507. function coords(ch, bias) {
  11508. return charCoords(cm, Pos(line, ch), "div", lineObj, bias)
  11509. }
  11510. function wrapX(pos, dir, side) {
  11511. var extent = wrappedLineExtentChar(cm, lineObj, null, pos);
  11512. var prop = (dir == "ltr") == (side == "after") ? "left" : "right";
  11513. var ch = side == "after" ? extent.begin : extent.end - (/\s/.test(lineObj.text.charAt(extent.end - 1)) ? 2 : 1);
  11514. return coords(ch, prop)[prop]
  11515. }
  11516. var order = getOrder(lineObj, doc.direction);
  11517. iterateBidiSections(order, fromArg || 0, toArg == null ? lineLen : toArg, function (from, to, dir, i) {
  11518. var ltr = dir == "ltr";
  11519. var fromPos = coords(from, ltr ? "left" : "right");
  11520. var toPos = coords(to - 1, ltr ? "right" : "left");
  11521. var openStart = fromArg == null && from == 0, openEnd = toArg == null && to == lineLen;
  11522. var first = i == 0, last = !order || i == order.length - 1;
  11523. if (toPos.top - fromPos.top <= 3) { // Single line
  11524. var openLeft = (docLTR ? openStart : openEnd) && first;
  11525. var openRight = (docLTR ? openEnd : openStart) && last;
  11526. var left = openLeft ? leftSide : (ltr ? fromPos : toPos).left;
  11527. var right = openRight ? rightSide : (ltr ? toPos : fromPos).right;
  11528. add(left, fromPos.top, right - left, fromPos.bottom);
  11529. } else { // Multiple lines
  11530. var topLeft, topRight, botLeft, botRight;
  11531. if (ltr) {
  11532. topLeft = docLTR && openStart && first ? leftSide : fromPos.left;
  11533. topRight = docLTR ? rightSide : wrapX(from, dir, "before");
  11534. botLeft = docLTR ? leftSide : wrapX(to, dir, "after");
  11535. botRight = docLTR && openEnd && last ? rightSide : toPos.right;
  11536. } else {
  11537. topLeft = !docLTR ? leftSide : wrapX(from, dir, "before");
  11538. topRight = !docLTR && openStart && first ? rightSide : fromPos.right;
  11539. botLeft = !docLTR && openEnd && last ? leftSide : toPos.left;
  11540. botRight = !docLTR ? rightSide : wrapX(to, dir, "after");
  11541. }
  11542. add(topLeft, fromPos.top, topRight - topLeft, fromPos.bottom);
  11543. if (fromPos.bottom < toPos.top) { add(leftSide, fromPos.bottom, null, toPos.top); }
  11544. add(botLeft, toPos.top, botRight - botLeft, toPos.bottom);
  11545. }
  11546. if (!start || cmpCoords(fromPos, start) < 0) { start = fromPos; }
  11547. if (cmpCoords(toPos, start) < 0) { start = toPos; }
  11548. if (!end || cmpCoords(fromPos, end) < 0) { end = fromPos; }
  11549. if (cmpCoords(toPos, end) < 0) { end = toPos; }
  11550. });
  11551. return {start: start, end: end}
  11552. }
  11553. var sFrom = range$$1.from(), sTo = range$$1.to();
  11554. if (sFrom.line == sTo.line) {
  11555. drawForLine(sFrom.line, sFrom.ch, sTo.ch);
  11556. } else {
  11557. var fromLine = getLine(doc, sFrom.line), toLine = getLine(doc, sTo.line);
  11558. var singleVLine = visualLine(fromLine) == visualLine(toLine);
  11559. var leftEnd = drawForLine(sFrom.line, sFrom.ch, singleVLine ? fromLine.text.length + 1 : null).end;
  11560. var rightStart = drawForLine(sTo.line, singleVLine ? 0 : null, sTo.ch).start;
  11561. if (singleVLine) {
  11562. if (leftEnd.top < rightStart.top - 2) {
  11563. add(leftEnd.right, leftEnd.top, null, leftEnd.bottom);
  11564. add(leftSide, rightStart.top, rightStart.left, rightStart.bottom);
  11565. } else {
  11566. add(leftEnd.right, leftEnd.top, rightStart.left - leftEnd.right, leftEnd.bottom);
  11567. }
  11568. }
  11569. if (leftEnd.bottom < rightStart.top)
  11570. { add(leftSide, leftEnd.bottom, null, rightStart.top); }
  11571. }
  11572. output.appendChild(fragment);
  11573. }
  11574. // Cursor-blinking
  11575. function restartBlink(cm) {
  11576. if (!cm.state.focused) { return }
  11577. var display = cm.display;
  11578. clearInterval(display.blinker);
  11579. var on = true;
  11580. display.cursorDiv.style.visibility = "";
  11581. if (cm.options.cursorBlinkRate > 0)
  11582. { display.blinker = setInterval(function () { return display.cursorDiv.style.visibility = (on = !on) ? "" : "hidden"; },
  11583. cm.options.cursorBlinkRate); }
  11584. else if (cm.options.cursorBlinkRate < 0)
  11585. { display.cursorDiv.style.visibility = "hidden"; }
  11586. }
  11587. function ensureFocus(cm) {
  11588. if (!cm.state.focused) { cm.display.input.focus(); onFocus(cm); }
  11589. }
  11590. function delayBlurEvent(cm) {
  11591. cm.state.delayingBlurEvent = true;
  11592. setTimeout(function () { if (cm.state.delayingBlurEvent) {
  11593. cm.state.delayingBlurEvent = false;
  11594. onBlur(cm);
  11595. } }, 100);
  11596. }
  11597. function onFocus(cm, e) {
  11598. if (cm.state.delayingBlurEvent) { cm.state.delayingBlurEvent = false; }
  11599. if (cm.options.readOnly == "nocursor") { return }
  11600. if (!cm.state.focused) {
  11601. signal(cm, "focus", cm, e);
  11602. cm.state.focused = true;
  11603. addClass(cm.display.wrapper, "CodeMirror-focused");
  11604. // This test prevents this from firing when a context
  11605. // menu is closed (since the input reset would kill the
  11606. // select-all detection hack)
  11607. if (!cm.curOp && cm.display.selForContextMenu != cm.doc.sel) {
  11608. cm.display.input.reset();
  11609. if (webkit) { setTimeout(function () { return cm.display.input.reset(true); }, 20); } // Issue #1730
  11610. }
  11611. cm.display.input.receivedFocus();
  11612. }
  11613. restartBlink(cm);
  11614. }
  11615. function onBlur(cm, e) {
  11616. if (cm.state.delayingBlurEvent) { return }
  11617. if (cm.state.focused) {
  11618. signal(cm, "blur", cm, e);
  11619. cm.state.focused = false;
  11620. rmClass(cm.display.wrapper, "CodeMirror-focused");
  11621. }
  11622. clearInterval(cm.display.blinker);
  11623. setTimeout(function () { if (!cm.state.focused) { cm.display.shift = false; } }, 150);
  11624. }
  11625. // Read the actual heights of the rendered lines, and update their
  11626. // stored heights to match.
  11627. function updateHeightsInViewport(cm) {
  11628. var display = cm.display;
  11629. var prevBottom = display.lineDiv.offsetTop;
  11630. for (var i = 0; i < display.view.length; i++) {
  11631. var cur = display.view[i], height = (void 0);
  11632. if (cur.hidden) { continue }
  11633. if (ie && ie_version < 8) {
  11634. var bot = cur.node.offsetTop + cur.node.offsetHeight;
  11635. height = bot - prevBottom;
  11636. prevBottom = bot;
  11637. } else {
  11638. var box = cur.node.getBoundingClientRect();
  11639. height = box.bottom - box.top;
  11640. }
  11641. var diff = cur.line.height - height;
  11642. if (height < 2) { height = textHeight(display); }
  11643. if (diff > .005 || diff < -.005) {
  11644. updateLineHeight(cur.line, height);
  11645. updateWidgetHeight(cur.line);
  11646. if (cur.rest) { for (var j = 0; j < cur.rest.length; j++)
  11647. { updateWidgetHeight(cur.rest[j]); } }
  11648. }
  11649. }
  11650. }
  11651. // Read and store the height of line widgets associated with the
  11652. // given line.
  11653. function updateWidgetHeight(line) {
  11654. if (line.widgets) { for (var i = 0; i < line.widgets.length; ++i) {
  11655. var w = line.widgets[i], parent = w.node.parentNode;
  11656. if (parent) { w.height = parent.offsetHeight; }
  11657. } }
  11658. }
  11659. // Compute the lines that are visible in a given viewport (defaults
  11660. // the the current scroll position). viewport may contain top,
  11661. // height, and ensure (see op.scrollToPos) properties.
  11662. function visibleLines(display, doc, viewport) {
  11663. var top = viewport && viewport.top != null ? Math.max(0, viewport.top) : display.scroller.scrollTop;
  11664. top = Math.floor(top - paddingTop(display));
  11665. var bottom = viewport && viewport.bottom != null ? viewport.bottom : top + display.wrapper.clientHeight;
  11666. var from = lineAtHeight(doc, top), to = lineAtHeight(doc, bottom);
  11667. // Ensure is a {from: {line, ch}, to: {line, ch}} object, and
  11668. // forces those lines into the viewport (if possible).
  11669. if (viewport && viewport.ensure) {
  11670. var ensureFrom = viewport.ensure.from.line, ensureTo = viewport.ensure.to.line;
  11671. if (ensureFrom < from) {
  11672. from = ensureFrom;
  11673. to = lineAtHeight(doc, heightAtLine(getLine(doc, ensureFrom)) + display.wrapper.clientHeight);
  11674. } else if (Math.min(ensureTo, doc.lastLine()) >= to) {
  11675. from = lineAtHeight(doc, heightAtLine(getLine(doc, ensureTo)) - display.wrapper.clientHeight);
  11676. to = ensureTo;
  11677. }
  11678. }
  11679. return {from: from, to: Math.max(to, from + 1)}
  11680. }
  11681. // Re-align line numbers and gutter marks to compensate for
  11682. // horizontal scrolling.
  11683. function alignHorizontally(cm) {
  11684. var display = cm.display, view = display.view;
  11685. if (!display.alignWidgets && (!display.gutters.firstChild || !cm.options.fixedGutter)) { return }
  11686. var comp = compensateForHScroll(display) - display.scroller.scrollLeft + cm.doc.scrollLeft;
  11687. var gutterW = display.gutters.offsetWidth, left = comp + "px";
  11688. for (var i = 0; i < view.length; i++) { if (!view[i].hidden) {
  11689. if (cm.options.fixedGutter) {
  11690. if (view[i].gutter)
  11691. { view[i].gutter.style.left = left; }
  11692. if (view[i].gutterBackground)
  11693. { view[i].gutterBackground.style.left = left; }
  11694. }
  11695. var align = view[i].alignable;
  11696. if (align) { for (var j = 0; j < align.length; j++)
  11697. { align[j].style.left = left; } }
  11698. } }
  11699. if (cm.options.fixedGutter)
  11700. { display.gutters.style.left = (comp + gutterW) + "px"; }
  11701. }
  11702. // Used to ensure that the line number gutter is still the right
  11703. // size for the current document size. Returns true when an update
  11704. // is needed.
  11705. function maybeUpdateLineNumberWidth(cm) {
  11706. if (!cm.options.lineNumbers) { return false }
  11707. var doc = cm.doc, last = lineNumberFor(cm.options, doc.first + doc.size - 1), display = cm.display;
  11708. if (last.length != display.lineNumChars) {
  11709. var test = display.measure.appendChild(elt("div", [elt("div", last)],
  11710. "CodeMirror-linenumber CodeMirror-gutter-elt"));
  11711. var innerW = test.firstChild.offsetWidth, padding = test.offsetWidth - innerW;
  11712. display.lineGutter.style.width = "";
  11713. display.lineNumInnerWidth = Math.max(innerW, display.lineGutter.offsetWidth - padding) + 1;
  11714. display.lineNumWidth = display.lineNumInnerWidth + padding;
  11715. display.lineNumChars = display.lineNumInnerWidth ? last.length : -1;
  11716. display.lineGutter.style.width = display.lineNumWidth + "px";
  11717. updateGutterSpace(cm);
  11718. return true
  11719. }
  11720. return false
  11721. }
  11722. // SCROLLING THINGS INTO VIEW
  11723. // If an editor sits on the top or bottom of the window, partially
  11724. // scrolled out of view, this ensures that the cursor is visible.
  11725. function maybeScrollWindow(cm, rect) {
  11726. if (signalDOMEvent(cm, "scrollCursorIntoView")) { return }
  11727. var display = cm.display, box = display.sizer.getBoundingClientRect(), doScroll = null;
  11728. if (rect.top + box.top < 0) { doScroll = true; }
  11729. else if (rect.bottom + box.top > (window.innerHeight || document.documentElement.clientHeight)) { doScroll = false; }
  11730. if (doScroll != null && !phantom) {
  11731. var scrollNode = elt("div", "\u200b", null, ("position: absolute;\n top: " + (rect.top - display.viewOffset - paddingTop(cm.display)) + "px;\n height: " + (rect.bottom - rect.top + scrollGap(cm) + display.barHeight) + "px;\n left: " + (rect.left) + "px; width: " + (Math.max(2, rect.right - rect.left)) + "px;"));
  11732. cm.display.lineSpace.appendChild(scrollNode);
  11733. scrollNode.scrollIntoView(doScroll);
  11734. cm.display.lineSpace.removeChild(scrollNode);
  11735. }
  11736. }
  11737. // Scroll a given position into view (immediately), verifying that
  11738. // it actually became visible (as line heights are accurately
  11739. // measured, the position of something may 'drift' during drawing).
  11740. function scrollPosIntoView(cm, pos, end, margin) {
  11741. if (margin == null) { margin = 0; }
  11742. var rect;
  11743. if (!cm.options.lineWrapping && pos == end) {
  11744. // Set pos and end to the cursor positions around the character pos sticks to
  11745. // If pos.sticky == "before", that is around pos.ch - 1, otherwise around pos.ch
  11746. // If pos == Pos(_, 0, "before"), pos and end are unchanged
  11747. pos = pos.ch ? Pos(pos.line, pos.sticky == "before" ? pos.ch - 1 : pos.ch, "after") : pos;
  11748. end = pos.sticky == "before" ? Pos(pos.line, pos.ch + 1, "before") : pos;
  11749. }
  11750. for (var limit = 0; limit < 5; limit++) {
  11751. var changed = false;
  11752. var coords = cursorCoords(cm, pos);
  11753. var endCoords = !end || end == pos ? coords : cursorCoords(cm, end);
  11754. rect = {left: Math.min(coords.left, endCoords.left),
  11755. top: Math.min(coords.top, endCoords.top) - margin,
  11756. right: Math.max(coords.left, endCoords.left),
  11757. bottom: Math.max(coords.bottom, endCoords.bottom) + margin};
  11758. var scrollPos = calculateScrollPos(cm, rect);
  11759. var startTop = cm.doc.scrollTop, startLeft = cm.doc.scrollLeft;
  11760. if (scrollPos.scrollTop != null) {
  11761. updateScrollTop(cm, scrollPos.scrollTop);
  11762. if (Math.abs(cm.doc.scrollTop - startTop) > 1) { changed = true; }
  11763. }
  11764. if (scrollPos.scrollLeft != null) {
  11765. setScrollLeft(cm, scrollPos.scrollLeft);
  11766. if (Math.abs(cm.doc.scrollLeft - startLeft) > 1) { changed = true; }
  11767. }
  11768. if (!changed) { break }
  11769. }
  11770. return rect
  11771. }
  11772. // Scroll a given set of coordinates into view (immediately).
  11773. function scrollIntoView(cm, rect) {
  11774. var scrollPos = calculateScrollPos(cm, rect);
  11775. if (scrollPos.scrollTop != null) { updateScrollTop(cm, scrollPos.scrollTop); }
  11776. if (scrollPos.scrollLeft != null) { setScrollLeft(cm, scrollPos.scrollLeft); }
  11777. }
  11778. // Calculate a new scroll position needed to scroll the given
  11779. // rectangle into view. Returns an object with scrollTop and
  11780. // scrollLeft properties. When these are undefined, the
  11781. // vertical/horizontal position does not need to be adjusted.
  11782. function calculateScrollPos(cm, rect) {
  11783. var display = cm.display, snapMargin = textHeight(cm.display);
  11784. if (rect.top < 0) { rect.top = 0; }
  11785. var screentop = cm.curOp && cm.curOp.scrollTop != null ? cm.curOp.scrollTop : display.scroller.scrollTop;
  11786. var screen = displayHeight(cm), result = {};
  11787. if (rect.bottom - rect.top > screen) { rect.bottom = rect.top + screen; }
  11788. var docBottom = cm.doc.height + paddingVert(display);
  11789. var atTop = rect.top < snapMargin, atBottom = rect.bottom > docBottom - snapMargin;
  11790. if (rect.top < screentop) {
  11791. result.scrollTop = atTop ? 0 : rect.top;
  11792. } else if (rect.bottom > screentop + screen) {
  11793. var newTop = Math.min(rect.top, (atBottom ? docBottom : rect.bottom) - screen);
  11794. if (newTop != screentop) { result.scrollTop = newTop; }
  11795. }
  11796. var screenleft = cm.curOp && cm.curOp.scrollLeft != null ? cm.curOp.scrollLeft : display.scroller.scrollLeft;
  11797. var screenw = displayWidth(cm) - (cm.options.fixedGutter ? display.gutters.offsetWidth : 0);
  11798. var tooWide = rect.right - rect.left > screenw;
  11799. if (tooWide) { rect.right = rect.left + screenw; }
  11800. if (rect.left < 10)
  11801. { result.scrollLeft = 0; }
  11802. else if (rect.left < screenleft)
  11803. { result.scrollLeft = Math.max(0, rect.left - (tooWide ? 0 : 10)); }
  11804. else if (rect.right > screenw + screenleft - 3)
  11805. { result.scrollLeft = rect.right + (tooWide ? 0 : 10) - screenw; }
  11806. return result
  11807. }
  11808. // Store a relative adjustment to the scroll position in the current
  11809. // operation (to be applied when the operation finishes).
  11810. function addToScrollTop(cm, top) {
  11811. if (top == null) { return }
  11812. resolveScrollToPos(cm);
  11813. cm.curOp.scrollTop = (cm.curOp.scrollTop == null ? cm.doc.scrollTop : cm.curOp.scrollTop) + top;
  11814. }
  11815. // Make sure that at the end of the operation the current cursor is
  11816. // shown.
  11817. function ensureCursorVisible(cm) {
  11818. resolveScrollToPos(cm);
  11819. var cur = cm.getCursor();
  11820. cm.curOp.scrollToPos = {from: cur, to: cur, margin: cm.options.cursorScrollMargin};
  11821. }
  11822. function scrollToCoords(cm, x, y) {
  11823. if (x != null || y != null) { resolveScrollToPos(cm); }
  11824. if (x != null) { cm.curOp.scrollLeft = x; }
  11825. if (y != null) { cm.curOp.scrollTop = y; }
  11826. }
  11827. function scrollToRange(cm, range$$1) {
  11828. resolveScrollToPos(cm);
  11829. cm.curOp.scrollToPos = range$$1;
  11830. }
  11831. // When an operation has its scrollToPos property set, and another
  11832. // scroll action is applied before the end of the operation, this
  11833. // 'simulates' scrolling that position into view in a cheap way, so
  11834. // that the effect of intermediate scroll commands is not ignored.
  11835. function resolveScrollToPos(cm) {
  11836. var range$$1 = cm.curOp.scrollToPos;
  11837. if (range$$1) {
  11838. cm.curOp.scrollToPos = null;
  11839. var from = estimateCoords(cm, range$$1.from), to = estimateCoords(cm, range$$1.to);
  11840. scrollToCoordsRange(cm, from, to, range$$1.margin);
  11841. }
  11842. }
  11843. function scrollToCoordsRange(cm, from, to, margin) {
  11844. var sPos = calculateScrollPos(cm, {
  11845. left: Math.min(from.left, to.left),
  11846. top: Math.min(from.top, to.top) - margin,
  11847. right: Math.max(from.right, to.right),
  11848. bottom: Math.max(from.bottom, to.bottom) + margin
  11849. });
  11850. scrollToCoords(cm, sPos.scrollLeft, sPos.scrollTop);
  11851. }
  11852. // Sync the scrollable area and scrollbars, ensure the viewport
  11853. // covers the visible area.
  11854. function updateScrollTop(cm, val) {
  11855. if (Math.abs(cm.doc.scrollTop - val) < 2) { return }
  11856. if (!gecko) { updateDisplaySimple(cm, {top: val}); }
  11857. setScrollTop(cm, val, true);
  11858. if (gecko) { updateDisplaySimple(cm); }
  11859. startWorker(cm, 100);
  11860. }
  11861. function setScrollTop(cm, val, forceScroll) {
  11862. val = Math.min(cm.display.scroller.scrollHeight - cm.display.scroller.clientHeight, val);
  11863. if (cm.display.scroller.scrollTop == val && !forceScroll) { return }
  11864. cm.doc.scrollTop = val;
  11865. cm.display.scrollbars.setScrollTop(val);
  11866. if (cm.display.scroller.scrollTop != val) { cm.display.scroller.scrollTop = val; }
  11867. }
  11868. // Sync scroller and scrollbar, ensure the gutter elements are
  11869. // aligned.
  11870. function setScrollLeft(cm, val, isScroller, forceScroll) {
  11871. val = Math.min(val, cm.display.scroller.scrollWidth - cm.display.scroller.clientWidth);
  11872. if ((isScroller ? val == cm.doc.scrollLeft : Math.abs(cm.doc.scrollLeft - val) < 2) && !forceScroll) { return }
  11873. cm.doc.scrollLeft = val;
  11874. alignHorizontally(cm);
  11875. if (cm.display.scroller.scrollLeft != val) { cm.display.scroller.scrollLeft = val; }
  11876. cm.display.scrollbars.setScrollLeft(val);
  11877. }
  11878. // SCROLLBARS
  11879. // Prepare DOM reads needed to update the scrollbars. Done in one
  11880. // shot to minimize update/measure roundtrips.
  11881. function measureForScrollbars(cm) {
  11882. var d = cm.display, gutterW = d.gutters.offsetWidth;
  11883. var docH = Math.round(cm.doc.height + paddingVert(cm.display));
  11884. return {
  11885. clientHeight: d.scroller.clientHeight,
  11886. viewHeight: d.wrapper.clientHeight,
  11887. scrollWidth: d.scroller.scrollWidth, clientWidth: d.scroller.clientWidth,
  11888. viewWidth: d.wrapper.clientWidth,
  11889. barLeft: cm.options.fixedGutter ? gutterW : 0,
  11890. docHeight: docH,
  11891. scrollHeight: docH + scrollGap(cm) + d.barHeight,
  11892. nativeBarWidth: d.nativeBarWidth,
  11893. gutterWidth: gutterW
  11894. }
  11895. }
  11896. var NativeScrollbars = function(place, scroll, cm) {
  11897. this.cm = cm;
  11898. var vert = this.vert = elt("div", [elt("div", null, null, "min-width: 1px")], "CodeMirror-vscrollbar");
  11899. var horiz = this.horiz = elt("div", [elt("div", null, null, "height: 100%; min-height: 1px")], "CodeMirror-hscrollbar");
  11900. place(vert); place(horiz);
  11901. on(vert, "scroll", function () {
  11902. if (vert.clientHeight) { scroll(vert.scrollTop, "vertical"); }
  11903. });
  11904. on(horiz, "scroll", function () {
  11905. if (horiz.clientWidth) { scroll(horiz.scrollLeft, "horizontal"); }
  11906. });
  11907. this.checkedZeroWidth = false;
  11908. // Need to set a minimum width to see the scrollbar on IE7 (but must not set it on IE8).
  11909. if (ie && ie_version < 8) { this.horiz.style.minHeight = this.vert.style.minWidth = "18px"; }
  11910. };
  11911. NativeScrollbars.prototype.update = function (measure) {
  11912. var needsH = measure.scrollWidth > measure.clientWidth + 1;
  11913. var needsV = measure.scrollHeight > measure.clientHeight + 1;
  11914. var sWidth = measure.nativeBarWidth;
  11915. if (needsV) {
  11916. this.vert.style.display = "block";
  11917. this.vert.style.bottom = needsH ? sWidth + "px" : "0";
  11918. var totalHeight = measure.viewHeight - (needsH ? sWidth : 0);
  11919. // A bug in IE8 can cause this value to be negative, so guard it.
  11920. this.vert.firstChild.style.height =
  11921. Math.max(0, measure.scrollHeight - measure.clientHeight + totalHeight) + "px";
  11922. } else {
  11923. this.vert.style.display = "";
  11924. this.vert.firstChild.style.height = "0";
  11925. }
  11926. if (needsH) {
  11927. this.horiz.style.display = "block";
  11928. this.horiz.style.right = needsV ? sWidth + "px" : "0";
  11929. this.horiz.style.left = measure.barLeft + "px";
  11930. var totalWidth = measure.viewWidth - measure.barLeft - (needsV ? sWidth : 0);
  11931. this.horiz.firstChild.style.width =
  11932. Math.max(0, measure.scrollWidth - measure.clientWidth + totalWidth) + "px";
  11933. } else {
  11934. this.horiz.style.display = "";
  11935. this.horiz.firstChild.style.width = "0";
  11936. }
  11937. if (!this.checkedZeroWidth && measure.clientHeight > 0) {
  11938. if (sWidth == 0) { this.zeroWidthHack(); }
  11939. this.checkedZeroWidth = true;
  11940. }
  11941. return {right: needsV ? sWidth : 0, bottom: needsH ? sWidth : 0}
  11942. };
  11943. NativeScrollbars.prototype.setScrollLeft = function (pos) {
  11944. if (this.horiz.scrollLeft != pos) { this.horiz.scrollLeft = pos; }
  11945. if (this.disableHoriz) { this.enableZeroWidthBar(this.horiz, this.disableHoriz, "horiz"); }
  11946. };
  11947. NativeScrollbars.prototype.setScrollTop = function (pos) {
  11948. if (this.vert.scrollTop != pos) { this.vert.scrollTop = pos; }
  11949. if (this.disableVert) { this.enableZeroWidthBar(this.vert, this.disableVert, "vert"); }
  11950. };
  11951. NativeScrollbars.prototype.zeroWidthHack = function () {
  11952. var w = mac && !mac_geMountainLion ? "12px" : "18px";
  11953. this.horiz.style.height = this.vert.style.width = w;
  11954. this.horiz.style.pointerEvents = this.vert.style.pointerEvents = "none";
  11955. this.disableHoriz = new Delayed;
  11956. this.disableVert = new Delayed;
  11957. };
  11958. NativeScrollbars.prototype.enableZeroWidthBar = function (bar, delay, type) {
  11959. bar.style.pointerEvents = "auto";
  11960. function maybeDisable() {
  11961. // To find out whether the scrollbar is still visible, we
  11962. // check whether the element under the pixel in the bottom
  11963. // right corner of the scrollbar box is the scrollbar box
  11964. // itself (when the bar is still visible) or its filler child
  11965. // (when the bar is hidden). If it is still visible, we keep
  11966. // it enabled, if it's hidden, we disable pointer events.
  11967. var box = bar.getBoundingClientRect();
  11968. var elt$$1 = type == "vert" ? document.elementFromPoint(box.right - 1, (box.top + box.bottom) / 2)
  11969. : document.elementFromPoint((box.right + box.left) / 2, box.bottom - 1);
  11970. if (elt$$1 != bar) { bar.style.pointerEvents = "none"; }
  11971. else { delay.set(1000, maybeDisable); }
  11972. }
  11973. delay.set(1000, maybeDisable);
  11974. };
  11975. NativeScrollbars.prototype.clear = function () {
  11976. var parent = this.horiz.parentNode;
  11977. parent.removeChild(this.horiz);
  11978. parent.removeChild(this.vert);
  11979. };
  11980. var NullScrollbars = function () {};
  11981. NullScrollbars.prototype.update = function () { return {bottom: 0, right: 0} };
  11982. NullScrollbars.prototype.setScrollLeft = function () {};
  11983. NullScrollbars.prototype.setScrollTop = function () {};
  11984. NullScrollbars.prototype.clear = function () {};
  11985. function updateScrollbars(cm, measure) {
  11986. if (!measure) { measure = measureForScrollbars(cm); }
  11987. var startWidth = cm.display.barWidth, startHeight = cm.display.barHeight;
  11988. updateScrollbarsInner(cm, measure);
  11989. for (var i = 0; i < 4 && startWidth != cm.display.barWidth || startHeight != cm.display.barHeight; i++) {
  11990. if (startWidth != cm.display.barWidth && cm.options.lineWrapping)
  11991. { updateHeightsInViewport(cm); }
  11992. updateScrollbarsInner(cm, measureForScrollbars(cm));
  11993. startWidth = cm.display.barWidth; startHeight = cm.display.barHeight;
  11994. }
  11995. }
  11996. // Re-synchronize the fake scrollbars with the actual size of the
  11997. // content.
  11998. function updateScrollbarsInner(cm, measure) {
  11999. var d = cm.display;
  12000. var sizes = d.scrollbars.update(measure);
  12001. d.sizer.style.paddingRight = (d.barWidth = sizes.right) + "px";
  12002. d.sizer.style.paddingBottom = (d.barHeight = sizes.bottom) + "px";
  12003. d.heightForcer.style.borderBottom = sizes.bottom + "px solid transparent";
  12004. if (sizes.right && sizes.bottom) {
  12005. d.scrollbarFiller.style.display = "block";
  12006. d.scrollbarFiller.style.height = sizes.bottom + "px";
  12007. d.scrollbarFiller.style.width = sizes.right + "px";
  12008. } else { d.scrollbarFiller.style.display = ""; }
  12009. if (sizes.bottom && cm.options.coverGutterNextToScrollbar && cm.options.fixedGutter) {
  12010. d.gutterFiller.style.display = "block";
  12011. d.gutterFiller.style.height = sizes.bottom + "px";
  12012. d.gutterFiller.style.width = measure.gutterWidth + "px";
  12013. } else { d.gutterFiller.style.display = ""; }
  12014. }
  12015. var scrollbarModel = {"native": NativeScrollbars, "null": NullScrollbars};
  12016. function initScrollbars(cm) {
  12017. if (cm.display.scrollbars) {
  12018. cm.display.scrollbars.clear();
  12019. if (cm.display.scrollbars.addClass)
  12020. { rmClass(cm.display.wrapper, cm.display.scrollbars.addClass); }
  12021. }
  12022. cm.display.scrollbars = new scrollbarModel[cm.options.scrollbarStyle](function (node) {
  12023. cm.display.wrapper.insertBefore(node, cm.display.scrollbarFiller);
  12024. // Prevent clicks in the scrollbars from killing focus
  12025. on(node, "mousedown", function () {
  12026. if (cm.state.focused) { setTimeout(function () { return cm.display.input.focus(); }, 0); }
  12027. });
  12028. node.setAttribute("cm-not-content", "true");
  12029. }, function (pos, axis) {
  12030. if (axis == "horizontal") { setScrollLeft(cm, pos); }
  12031. else { updateScrollTop(cm, pos); }
  12032. }, cm);
  12033. if (cm.display.scrollbars.addClass)
  12034. { addClass(cm.display.wrapper, cm.display.scrollbars.addClass); }
  12035. }
  12036. // Operations are used to wrap a series of changes to the editor
  12037. // state in such a way that each change won't have to update the
  12038. // cursor and display (which would be awkward, slow, and
  12039. // error-prone). Instead, display updates are batched and then all
  12040. // combined and executed at once.
  12041. var nextOpId = 0;
  12042. // Start a new operation.
  12043. function startOperation(cm) {
  12044. cm.curOp = {
  12045. cm: cm,
  12046. viewChanged: false, // Flag that indicates that lines might need to be redrawn
  12047. startHeight: cm.doc.height, // Used to detect need to update scrollbar
  12048. forceUpdate: false, // Used to force a redraw
  12049. updateInput: null, // Whether to reset the input textarea
  12050. typing: false, // Whether this reset should be careful to leave existing text (for compositing)
  12051. changeObjs: null, // Accumulated changes, for firing change events
  12052. cursorActivityHandlers: null, // Set of handlers to fire cursorActivity on
  12053. cursorActivityCalled: 0, // Tracks which cursorActivity handlers have been called already
  12054. selectionChanged: false, // Whether the selection needs to be redrawn
  12055. updateMaxLine: false, // Set when the widest line needs to be determined anew
  12056. scrollLeft: null, scrollTop: null, // Intermediate scroll position, not pushed to DOM yet
  12057. scrollToPos: null, // Used to scroll to a specific position
  12058. focus: false,
  12059. id: ++nextOpId // Unique ID
  12060. };
  12061. pushOperation(cm.curOp);
  12062. }
  12063. // Finish an operation, updating the display and signalling delayed events
  12064. function endOperation(cm) {
  12065. var op = cm.curOp;
  12066. finishOperation(op, function (group) {
  12067. for (var i = 0; i < group.ops.length; i++)
  12068. { group.ops[i].cm.curOp = null; }
  12069. endOperations(group);
  12070. });
  12071. }
  12072. // The DOM updates done when an operation finishes are batched so
  12073. // that the minimum number of relayouts are required.
  12074. function endOperations(group) {
  12075. var ops = group.ops;
  12076. for (var i = 0; i < ops.length; i++) // Read DOM
  12077. { endOperation_R1(ops[i]); }
  12078. for (var i$1 = 0; i$1 < ops.length; i$1++) // Write DOM (maybe)
  12079. { endOperation_W1(ops[i$1]); }
  12080. for (var i$2 = 0; i$2 < ops.length; i$2++) // Read DOM
  12081. { endOperation_R2(ops[i$2]); }
  12082. for (var i$3 = 0; i$3 < ops.length; i$3++) // Write DOM (maybe)
  12083. { endOperation_W2(ops[i$3]); }
  12084. for (var i$4 = 0; i$4 < ops.length; i$4++) // Read DOM
  12085. { endOperation_finish(ops[i$4]); }
  12086. }
  12087. function endOperation_R1(op) {
  12088. var cm = op.cm, display = cm.display;
  12089. maybeClipScrollbars(cm);
  12090. if (op.updateMaxLine) { findMaxLine(cm); }
  12091. op.mustUpdate = op.viewChanged || op.forceUpdate || op.scrollTop != null ||
  12092. op.scrollToPos && (op.scrollToPos.from.line < display.viewFrom ||
  12093. op.scrollToPos.to.line >= display.viewTo) ||
  12094. display.maxLineChanged && cm.options.lineWrapping;
  12095. op.update = op.mustUpdate &&
  12096. new DisplayUpdate(cm, op.mustUpdate && {top: op.scrollTop, ensure: op.scrollToPos}, op.forceUpdate);
  12097. }
  12098. function endOperation_W1(op) {
  12099. op.updatedDisplay = op.mustUpdate && updateDisplayIfNeeded(op.cm, op.update);
  12100. }
  12101. function endOperation_R2(op) {
  12102. var cm = op.cm, display = cm.display;
  12103. if (op.updatedDisplay) { updateHeightsInViewport(cm); }
  12104. op.barMeasure = measureForScrollbars(cm);
  12105. // If the max line changed since it was last measured, measure it,
  12106. // and ensure the document's width matches it.
  12107. // updateDisplay_W2 will use these properties to do the actual resizing
  12108. if (display.maxLineChanged && !cm.options.lineWrapping) {
  12109. op.adjustWidthTo = measureChar(cm, display.maxLine, display.maxLine.text.length).left + 3;
  12110. cm.display.sizerWidth = op.adjustWidthTo;
  12111. op.barMeasure.scrollWidth =
  12112. Math.max(display.scroller.clientWidth, display.sizer.offsetLeft + op.adjustWidthTo + scrollGap(cm) + cm.display.barWidth);
  12113. op.maxScrollLeft = Math.max(0, display.sizer.offsetLeft + op.adjustWidthTo - displayWidth(cm));
  12114. }
  12115. if (op.updatedDisplay || op.selectionChanged)
  12116. { op.preparedSelection = display.input.prepareSelection(); }
  12117. }
  12118. function endOperation_W2(op) {
  12119. var cm = op.cm;
  12120. if (op.adjustWidthTo != null) {
  12121. cm.display.sizer.style.minWidth = op.adjustWidthTo + "px";
  12122. if (op.maxScrollLeft < cm.doc.scrollLeft)
  12123. { setScrollLeft(cm, Math.min(cm.display.scroller.scrollLeft, op.maxScrollLeft), true); }
  12124. cm.display.maxLineChanged = false;
  12125. }
  12126. var takeFocus = op.focus && op.focus == activeElt();
  12127. if (op.preparedSelection)
  12128. { cm.display.input.showSelection(op.preparedSelection, takeFocus); }
  12129. if (op.updatedDisplay || op.startHeight != cm.doc.height)
  12130. { updateScrollbars(cm, op.barMeasure); }
  12131. if (op.updatedDisplay)
  12132. { setDocumentHeight(cm, op.barMeasure); }
  12133. if (op.selectionChanged) { restartBlink(cm); }
  12134. if (cm.state.focused && op.updateInput)
  12135. { cm.display.input.reset(op.typing); }
  12136. if (takeFocus) { ensureFocus(op.cm); }
  12137. }
  12138. function endOperation_finish(op) {
  12139. var cm = op.cm, display = cm.display, doc = cm.doc;
  12140. if (op.updatedDisplay) { postUpdateDisplay(cm, op.update); }
  12141. // Abort mouse wheel delta measurement, when scrolling explicitly
  12142. if (display.wheelStartX != null && (op.scrollTop != null || op.scrollLeft != null || op.scrollToPos))
  12143. { display.wheelStartX = display.wheelStartY = null; }
  12144. // Propagate the scroll position to the actual DOM scroller
  12145. if (op.scrollTop != null) { setScrollTop(cm, op.scrollTop, op.forceScroll); }
  12146. if (op.scrollLeft != null) { setScrollLeft(cm, op.scrollLeft, true, true); }
  12147. // If we need to scroll a specific position into view, do so.
  12148. if (op.scrollToPos) {
  12149. var rect = scrollPosIntoView(cm, clipPos(doc, op.scrollToPos.from),
  12150. clipPos(doc, op.scrollToPos.to), op.scrollToPos.margin);
  12151. maybeScrollWindow(cm, rect);
  12152. }
  12153. // Fire events for markers that are hidden/unidden by editing or
  12154. // undoing
  12155. var hidden = op.maybeHiddenMarkers, unhidden = op.maybeUnhiddenMarkers;
  12156. if (hidden) { for (var i = 0; i < hidden.length; ++i)
  12157. { if (!hidden[i].lines.length) { signal(hidden[i], "hide"); } } }
  12158. if (unhidden) { for (var i$1 = 0; i$1 < unhidden.length; ++i$1)
  12159. { if (unhidden[i$1].lines.length) { signal(unhidden[i$1], "unhide"); } } }
  12160. if (display.wrapper.offsetHeight)
  12161. { doc.scrollTop = cm.display.scroller.scrollTop; }
  12162. // Fire change events, and delayed event handlers
  12163. if (op.changeObjs)
  12164. { signal(cm, "changes", cm, op.changeObjs); }
  12165. if (op.update)
  12166. { op.update.finish(); }
  12167. }
  12168. // Run the given function in an operation
  12169. function runInOp(cm, f) {
  12170. if (cm.curOp) { return f() }
  12171. startOperation(cm);
  12172. try { return f() }
  12173. finally { endOperation(cm); }
  12174. }
  12175. // Wraps a function in an operation. Returns the wrapped function.
  12176. function operation(cm, f) {
  12177. return function() {
  12178. if (cm.curOp) { return f.apply(cm, arguments) }
  12179. startOperation(cm);
  12180. try { return f.apply(cm, arguments) }
  12181. finally { endOperation(cm); }
  12182. }
  12183. }
  12184. // Used to add methods to editor and doc instances, wrapping them in
  12185. // operations.
  12186. function methodOp(f) {
  12187. return function() {
  12188. if (this.curOp) { return f.apply(this, arguments) }
  12189. startOperation(this);
  12190. try { return f.apply(this, arguments) }
  12191. finally { endOperation(this); }
  12192. }
  12193. }
  12194. function docMethodOp(f) {
  12195. return function() {
  12196. var cm = this.cm;
  12197. if (!cm || cm.curOp) { return f.apply(this, arguments) }
  12198. startOperation(cm);
  12199. try { return f.apply(this, arguments) }
  12200. finally { endOperation(cm); }
  12201. }
  12202. }
  12203. // Updates the display.view data structure for a given change to the
  12204. // document. From and to are in pre-change coordinates. Lendiff is
  12205. // the amount of lines added or subtracted by the change. This is
  12206. // used for changes that span multiple lines, or change the way
  12207. // lines are divided into visual lines. regLineChange (below)
  12208. // registers single-line changes.
  12209. function regChange(cm, from, to, lendiff) {
  12210. if (from == null) { from = cm.doc.first; }
  12211. if (to == null) { to = cm.doc.first + cm.doc.size; }
  12212. if (!lendiff) { lendiff = 0; }
  12213. var display = cm.display;
  12214. if (lendiff && to < display.viewTo &&
  12215. (display.updateLineNumbers == null || display.updateLineNumbers > from))
  12216. { display.updateLineNumbers = from; }
  12217. cm.curOp.viewChanged = true;
  12218. if (from >= display.viewTo) { // Change after
  12219. if (sawCollapsedSpans && visualLineNo(cm.doc, from) < display.viewTo)
  12220. { resetView(cm); }
  12221. } else if (to <= display.viewFrom) { // Change before
  12222. if (sawCollapsedSpans && visualLineEndNo(cm.doc, to + lendiff) > display.viewFrom) {
  12223. resetView(cm);
  12224. } else {
  12225. display.viewFrom += lendiff;
  12226. display.viewTo += lendiff;
  12227. }
  12228. } else if (from <= display.viewFrom && to >= display.viewTo) { // Full overlap
  12229. resetView(cm);
  12230. } else if (from <= display.viewFrom) { // Top overlap
  12231. var cut = viewCuttingPoint(cm, to, to + lendiff, 1);
  12232. if (cut) {
  12233. display.view = display.view.slice(cut.index);
  12234. display.viewFrom = cut.lineN;
  12235. display.viewTo += lendiff;
  12236. } else {
  12237. resetView(cm);
  12238. }
  12239. } else if (to >= display.viewTo) { // Bottom overlap
  12240. var cut$1 = viewCuttingPoint(cm, from, from, -1);
  12241. if (cut$1) {
  12242. display.view = display.view.slice(0, cut$1.index);
  12243. display.viewTo = cut$1.lineN;
  12244. } else {
  12245. resetView(cm);
  12246. }
  12247. } else { // Gap in the middle
  12248. var cutTop = viewCuttingPoint(cm, from, from, -1);
  12249. var cutBot = viewCuttingPoint(cm, to, to + lendiff, 1);
  12250. if (cutTop && cutBot) {
  12251. display.view = display.view.slice(0, cutTop.index)
  12252. .concat(buildViewArray(cm, cutTop.lineN, cutBot.lineN))
  12253. .concat(display.view.slice(cutBot.index));
  12254. display.viewTo += lendiff;
  12255. } else {
  12256. resetView(cm);
  12257. }
  12258. }
  12259. var ext = display.externalMeasured;
  12260. if (ext) {
  12261. if (to < ext.lineN)
  12262. { ext.lineN += lendiff; }
  12263. else if (from < ext.lineN + ext.size)
  12264. { display.externalMeasured = null; }
  12265. }
  12266. }
  12267. // Register a change to a single line. Type must be one of "text",
  12268. // "gutter", "class", "widget"
  12269. function regLineChange(cm, line, type) {
  12270. cm.curOp.viewChanged = true;
  12271. var display = cm.display, ext = cm.display.externalMeasured;
  12272. if (ext && line >= ext.lineN && line < ext.lineN + ext.size)
  12273. { display.externalMeasured = null; }
  12274. if (line < display.viewFrom || line >= display.viewTo) { return }
  12275. var lineView = display.view[findViewIndex(cm, line)];
  12276. if (lineView.node == null) { return }
  12277. var arr = lineView.changes || (lineView.changes = []);
  12278. if (indexOf(arr, type) == -1) { arr.push(type); }
  12279. }
  12280. // Clear the view.
  12281. function resetView(cm) {
  12282. cm.display.viewFrom = cm.display.viewTo = cm.doc.first;
  12283. cm.display.view = [];
  12284. cm.display.viewOffset = 0;
  12285. }
  12286. function viewCuttingPoint(cm, oldN, newN, dir) {
  12287. var index = findViewIndex(cm, oldN), diff, view = cm.display.view;
  12288. if (!sawCollapsedSpans || newN == cm.doc.first + cm.doc.size)
  12289. { return {index: index, lineN: newN} }
  12290. var n = cm.display.viewFrom;
  12291. for (var i = 0; i < index; i++)
  12292. { n += view[i].size; }
  12293. if (n != oldN) {
  12294. if (dir > 0) {
  12295. if (index == view.length - 1) { return null }
  12296. diff = (n + view[index].size) - oldN;
  12297. index++;
  12298. } else {
  12299. diff = n - oldN;
  12300. }
  12301. oldN += diff; newN += diff;
  12302. }
  12303. while (visualLineNo(cm.doc, newN) != newN) {
  12304. if (index == (dir < 0 ? 0 : view.length - 1)) { return null }
  12305. newN += dir * view[index - (dir < 0 ? 1 : 0)].size;
  12306. index += dir;
  12307. }
  12308. return {index: index, lineN: newN}
  12309. }
  12310. // Force the view to cover a given range, adding empty view element
  12311. // or clipping off existing ones as needed.
  12312. function adjustView(cm, from, to) {
  12313. var display = cm.display, view = display.view;
  12314. if (view.length == 0 || from >= display.viewTo || to <= display.viewFrom) {
  12315. display.view = buildViewArray(cm, from, to);
  12316. display.viewFrom = from;
  12317. } else {
  12318. if (display.viewFrom > from)
  12319. { display.view = buildViewArray(cm, from, display.viewFrom).concat(display.view); }
  12320. else if (display.viewFrom < from)
  12321. { display.view = display.view.slice(findViewIndex(cm, from)); }
  12322. display.viewFrom = from;
  12323. if (display.viewTo < to)
  12324. { display.view = display.view.concat(buildViewArray(cm, display.viewTo, to)); }
  12325. else if (display.viewTo > to)
  12326. { display.view = display.view.slice(0, findViewIndex(cm, to)); }
  12327. }
  12328. display.viewTo = to;
  12329. }
  12330. // Count the number of lines in the view whose DOM representation is
  12331. // out of date (or nonexistent).
  12332. function countDirtyView(cm) {
  12333. var view = cm.display.view, dirty = 0;
  12334. for (var i = 0; i < view.length; i++) {
  12335. var lineView = view[i];
  12336. if (!lineView.hidden && (!lineView.node || lineView.changes)) { ++dirty; }
  12337. }
  12338. return dirty
  12339. }
  12340. // HIGHLIGHT WORKER
  12341. function startWorker(cm, time) {
  12342. if (cm.doc.highlightFrontier < cm.display.viewTo)
  12343. { cm.state.highlight.set(time, bind(highlightWorker, cm)); }
  12344. }
  12345. function highlightWorker(cm) {
  12346. var doc = cm.doc;
  12347. if (doc.highlightFrontier >= cm.display.viewTo) { return }
  12348. var end = +new Date + cm.options.workTime;
  12349. var context = getContextBefore(cm, doc.highlightFrontier);
  12350. var changedLines = [];
  12351. doc.iter(context.line, Math.min(doc.first + doc.size, cm.display.viewTo + 500), function (line) {
  12352. if (context.line >= cm.display.viewFrom) { // Visible
  12353. var oldStyles = line.styles;
  12354. var resetState = line.text.length > cm.options.maxHighlightLength ? copyState(doc.mode, context.state) : null;
  12355. var highlighted = highlightLine(cm, line, context, true);
  12356. if (resetState) { context.state = resetState; }
  12357. line.styles = highlighted.styles;
  12358. var oldCls = line.styleClasses, newCls = highlighted.classes;
  12359. if (newCls) { line.styleClasses = newCls; }
  12360. else if (oldCls) { line.styleClasses = null; }
  12361. var ischange = !oldStyles || oldStyles.length != line.styles.length ||
  12362. oldCls != newCls && (!oldCls || !newCls || oldCls.bgClass != newCls.bgClass || oldCls.textClass != newCls.textClass);
  12363. for (var i = 0; !ischange && i < oldStyles.length; ++i) { ischange = oldStyles[i] != line.styles[i]; }
  12364. if (ischange) { changedLines.push(context.line); }
  12365. line.stateAfter = context.save();
  12366. context.nextLine();
  12367. } else {
  12368. if (line.text.length <= cm.options.maxHighlightLength)
  12369. { processLine(cm, line.text, context); }
  12370. line.stateAfter = context.line % 5 == 0 ? context.save() : null;
  12371. context.nextLine();
  12372. }
  12373. if (+new Date > end) {
  12374. startWorker(cm, cm.options.workDelay);
  12375. return true
  12376. }
  12377. });
  12378. doc.highlightFrontier = context.line;
  12379. doc.modeFrontier = Math.max(doc.modeFrontier, context.line);
  12380. if (changedLines.length) { runInOp(cm, function () {
  12381. for (var i = 0; i < changedLines.length; i++)
  12382. { regLineChange(cm, changedLines[i], "text"); }
  12383. }); }
  12384. }
  12385. // DISPLAY DRAWING
  12386. var DisplayUpdate = function(cm, viewport, force) {
  12387. var display = cm.display;
  12388. this.viewport = viewport;
  12389. // Store some values that we'll need later (but don't want to force a relayout for)
  12390. this.visible = visibleLines(display, cm.doc, viewport);
  12391. this.editorIsHidden = !display.wrapper.offsetWidth;
  12392. this.wrapperHeight = display.wrapper.clientHeight;
  12393. this.wrapperWidth = display.wrapper.clientWidth;
  12394. this.oldDisplayWidth = displayWidth(cm);
  12395. this.force = force;
  12396. this.dims = getDimensions(cm);
  12397. this.events = [];
  12398. };
  12399. DisplayUpdate.prototype.signal = function (emitter, type) {
  12400. if (hasHandler(emitter, type))
  12401. { this.events.push(arguments); }
  12402. };
  12403. DisplayUpdate.prototype.finish = function () {
  12404. var this$1 = this;
  12405. for (var i = 0; i < this.events.length; i++)
  12406. { signal.apply(null, this$1.events[i]); }
  12407. };
  12408. function maybeClipScrollbars(cm) {
  12409. var display = cm.display;
  12410. if (!display.scrollbarsClipped && display.scroller.offsetWidth) {
  12411. display.nativeBarWidth = display.scroller.offsetWidth - display.scroller.clientWidth;
  12412. display.heightForcer.style.height = scrollGap(cm) + "px";
  12413. display.sizer.style.marginBottom = -display.nativeBarWidth + "px";
  12414. display.sizer.style.borderRightWidth = scrollGap(cm) + "px";
  12415. display.scrollbarsClipped = true;
  12416. }
  12417. }
  12418. function selectionSnapshot(cm) {
  12419. if (cm.hasFocus()) { return null }
  12420. var active = activeElt();
  12421. if (!active || !contains(cm.display.lineDiv, active)) { return null }
  12422. var result = {activeElt: active};
  12423. if (window.getSelection) {
  12424. var sel = window.getSelection();
  12425. if (sel.anchorNode && sel.extend && contains(cm.display.lineDiv, sel.anchorNode)) {
  12426. result.anchorNode = sel.anchorNode;
  12427. result.anchorOffset = sel.anchorOffset;
  12428. result.focusNode = sel.focusNode;
  12429. result.focusOffset = sel.focusOffset;
  12430. }
  12431. }
  12432. return result
  12433. }
  12434. function restoreSelection(snapshot) {
  12435. if (!snapshot || !snapshot.activeElt || snapshot.activeElt == activeElt()) { return }
  12436. snapshot.activeElt.focus();
  12437. if (snapshot.anchorNode && contains(document.body, snapshot.anchorNode) && contains(document.body, snapshot.focusNode)) {
  12438. var sel = window.getSelection(), range$$1 = document.createRange();
  12439. range$$1.setEnd(snapshot.anchorNode, snapshot.anchorOffset);
  12440. range$$1.collapse(false);
  12441. sel.removeAllRanges();
  12442. sel.addRange(range$$1);
  12443. sel.extend(snapshot.focusNode, snapshot.focusOffset);
  12444. }
  12445. }
  12446. // Does the actual updating of the line display. Bails out
  12447. // (returning false) when there is nothing to be done and forced is
  12448. // false.
  12449. function updateDisplayIfNeeded(cm, update) {
  12450. var display = cm.display, doc = cm.doc;
  12451. if (update.editorIsHidden) {
  12452. resetView(cm);
  12453. return false
  12454. }
  12455. // Bail out if the visible area is already rendered and nothing changed.
  12456. if (!update.force &&
  12457. update.visible.from >= display.viewFrom && update.visible.to <= display.viewTo &&
  12458. (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo) &&
  12459. display.renderedView == display.view && countDirtyView(cm) == 0)
  12460. { return false }
  12461. if (maybeUpdateLineNumberWidth(cm)) {
  12462. resetView(cm);
  12463. update.dims = getDimensions(cm);
  12464. }
  12465. // Compute a suitable new viewport (from & to)
  12466. var end = doc.first + doc.size;
  12467. var from = Math.max(update.visible.from - cm.options.viewportMargin, doc.first);
  12468. var to = Math.min(end, update.visible.to + cm.options.viewportMargin);
  12469. if (display.viewFrom < from && from - display.viewFrom < 20) { from = Math.max(doc.first, display.viewFrom); }
  12470. if (display.viewTo > to && display.viewTo - to < 20) { to = Math.min(end, display.viewTo); }
  12471. if (sawCollapsedSpans) {
  12472. from = visualLineNo(cm.doc, from);
  12473. to = visualLineEndNo(cm.doc, to);
  12474. }
  12475. var different = from != display.viewFrom || to != display.viewTo ||
  12476. display.lastWrapHeight != update.wrapperHeight || display.lastWrapWidth != update.wrapperWidth;
  12477. adjustView(cm, from, to);
  12478. display.viewOffset = heightAtLine(getLine(cm.doc, display.viewFrom));
  12479. // Position the mover div to align with the current scroll position
  12480. cm.display.mover.style.top = display.viewOffset + "px";
  12481. var toUpdate = countDirtyView(cm);
  12482. if (!different && toUpdate == 0 && !update.force && display.renderedView == display.view &&
  12483. (display.updateLineNumbers == null || display.updateLineNumbers >= display.viewTo))
  12484. { return false }
  12485. // For big changes, we hide the enclosing element during the
  12486. // update, since that speeds up the operations on most browsers.
  12487. var selSnapshot = selectionSnapshot(cm);
  12488. if (toUpdate > 4) { display.lineDiv.style.display = "none"; }
  12489. patchDisplay(cm, display.updateLineNumbers, update.dims);
  12490. if (toUpdate > 4) { display.lineDiv.style.display = ""; }
  12491. display.renderedView = display.view;
  12492. // There might have been a widget with a focused element that got
  12493. // hidden or updated, if so re-focus it.
  12494. restoreSelection(selSnapshot);
  12495. // Prevent selection and cursors from interfering with the scroll
  12496. // width and height.
  12497. removeChildren(display.cursorDiv);
  12498. removeChildren(display.selectionDiv);
  12499. display.gutters.style.height = display.sizer.style.minHeight = 0;
  12500. if (different) {
  12501. display.lastWrapHeight = update.wrapperHeight;
  12502. display.lastWrapWidth = update.wrapperWidth;
  12503. startWorker(cm, 400);
  12504. }
  12505. display.updateLineNumbers = null;
  12506. return true
  12507. }
  12508. function postUpdateDisplay(cm, update) {
  12509. var viewport = update.viewport;
  12510. for (var first = true;; first = false) {
  12511. if (!first || !cm.options.lineWrapping || update.oldDisplayWidth == displayWidth(cm)) {
  12512. // Clip forced viewport to actual scrollable area.
  12513. if (viewport && viewport.top != null)
  12514. { viewport = {top: Math.min(cm.doc.height + paddingVert(cm.display) - displayHeight(cm), viewport.top)}; }
  12515. // Updated line heights might result in the drawn area not
  12516. // actually covering the viewport. Keep looping until it does.
  12517. update.visible = visibleLines(cm.display, cm.doc, viewport);
  12518. if (update.visible.from >= cm.display.viewFrom && update.visible.to <= cm.display.viewTo)
  12519. { break }
  12520. }
  12521. if (!updateDisplayIfNeeded(cm, update)) { break }
  12522. updateHeightsInViewport(cm);
  12523. var barMeasure = measureForScrollbars(cm);
  12524. updateSelection(cm);
  12525. updateScrollbars(cm, barMeasure);
  12526. setDocumentHeight(cm, barMeasure);
  12527. update.force = false;
  12528. }
  12529. update.signal(cm, "update", cm);
  12530. if (cm.display.viewFrom != cm.display.reportedViewFrom || cm.display.viewTo != cm.display.reportedViewTo) {
  12531. update.signal(cm, "viewportChange", cm, cm.display.viewFrom, cm.display.viewTo);
  12532. cm.display.reportedViewFrom = cm.display.viewFrom; cm.display.reportedViewTo = cm.display.viewTo;
  12533. }
  12534. }
  12535. function updateDisplaySimple(cm, viewport) {
  12536. var update = new DisplayUpdate(cm, viewport);
  12537. if (updateDisplayIfNeeded(cm, update)) {
  12538. updateHeightsInViewport(cm);
  12539. postUpdateDisplay(cm, update);
  12540. var barMeasure = measureForScrollbars(cm);
  12541. updateSelection(cm);
  12542. updateScrollbars(cm, barMeasure);
  12543. setDocumentHeight(cm, barMeasure);
  12544. update.finish();
  12545. }
  12546. }
  12547. // Sync the actual display DOM structure with display.view, removing
  12548. // nodes for lines that are no longer in view, and creating the ones
  12549. // that are not there yet, and updating the ones that are out of
  12550. // date.
  12551. function patchDisplay(cm, updateNumbersFrom, dims) {
  12552. var display = cm.display, lineNumbers = cm.options.lineNumbers;
  12553. var container = display.lineDiv, cur = container.firstChild;
  12554. function rm(node) {
  12555. var next = node.nextSibling;
  12556. // Works around a throw-scroll bug in OS X Webkit
  12557. if (webkit && mac && cm.display.currentWheelTarget == node)
  12558. { node.style.display = "none"; }
  12559. else
  12560. { node.parentNode.removeChild(node); }
  12561. return next
  12562. }
  12563. var view = display.view, lineN = display.viewFrom;
  12564. // Loop over the elements in the view, syncing cur (the DOM nodes
  12565. // in display.lineDiv) with the view as we go.
  12566. for (var i = 0; i < view.length; i++) {
  12567. var lineView = view[i];
  12568. if (lineView.hidden) {
  12569. } else if (!lineView.node || lineView.node.parentNode != container) { // Not drawn yet
  12570. var node = buildLineElement(cm, lineView, lineN, dims);
  12571. container.insertBefore(node, cur);
  12572. } else { // Already drawn
  12573. while (cur != lineView.node) { cur = rm(cur); }
  12574. var updateNumber = lineNumbers && updateNumbersFrom != null &&
  12575. updateNumbersFrom <= lineN && lineView.lineNumber;
  12576. if (lineView.changes) {
  12577. if (indexOf(lineView.changes, "gutter") > -1) { updateNumber = false; }
  12578. updateLineForChanges(cm, lineView, lineN, dims);
  12579. }
  12580. if (updateNumber) {
  12581. removeChildren(lineView.lineNumber);
  12582. lineView.lineNumber.appendChild(document.createTextNode(lineNumberFor(cm.options, lineN)));
  12583. }
  12584. cur = lineView.node.nextSibling;
  12585. }
  12586. lineN += lineView.size;
  12587. }
  12588. while (cur) { cur = rm(cur); }
  12589. }
  12590. function updateGutterSpace(cm) {
  12591. var width = cm.display.gutters.offsetWidth;
  12592. cm.display.sizer.style.marginLeft = width + "px";
  12593. }
  12594. function setDocumentHeight(cm, measure) {
  12595. cm.display.sizer.style.minHeight = measure.docHeight + "px";
  12596. cm.display.heightForcer.style.top = measure.docHeight + "px";
  12597. cm.display.gutters.style.height = (measure.docHeight + cm.display.barHeight + scrollGap(cm)) + "px";
  12598. }
  12599. // Rebuild the gutter elements, ensure the margin to the left of the
  12600. // code matches their width.
  12601. function updateGutters(cm) {
  12602. var gutters = cm.display.gutters, specs = cm.options.gutters;
  12603. removeChildren(gutters);
  12604. var i = 0;
  12605. for (; i < specs.length; ++i) {
  12606. var gutterClass = specs[i];
  12607. var gElt = gutters.appendChild(elt("div", null, "CodeMirror-gutter " + gutterClass));
  12608. if (gutterClass == "CodeMirror-linenumbers") {
  12609. cm.display.lineGutter = gElt;
  12610. gElt.style.width = (cm.display.lineNumWidth || 1) + "px";
  12611. }
  12612. }
  12613. gutters.style.display = i ? "" : "none";
  12614. updateGutterSpace(cm);
  12615. }
  12616. // Make sure the gutters options contains the element
  12617. // "CodeMirror-linenumbers" when the lineNumbers option is true.
  12618. function setGuttersForLineNumbers(options) {
  12619. var found = indexOf(options.gutters, "CodeMirror-linenumbers");
  12620. if (found == -1 && options.lineNumbers) {
  12621. options.gutters = options.gutters.concat(["CodeMirror-linenumbers"]);
  12622. } else if (found > -1 && !options.lineNumbers) {
  12623. options.gutters = options.gutters.slice(0);
  12624. options.gutters.splice(found, 1);
  12625. }
  12626. }
  12627. // Since the delta values reported on mouse wheel events are
  12628. // unstandardized between browsers and even browser versions, and
  12629. // generally horribly unpredictable, this code starts by measuring
  12630. // the scroll effect that the first few mouse wheel events have,
  12631. // and, from that, detects the way it can convert deltas to pixel
  12632. // offsets afterwards.
  12633. //
  12634. // The reason we want to know the amount a wheel event will scroll
  12635. // is that it gives us a chance to update the display before the
  12636. // actual scrolling happens, reducing flickering.
  12637. var wheelSamples = 0;
  12638. var wheelPixelsPerUnit = null;
  12639. // Fill in a browser-detected starting value on browsers where we
  12640. // know one. These don't have to be accurate -- the result of them
  12641. // being wrong would just be a slight flicker on the first wheel
  12642. // scroll (if it is large enough).
  12643. if (ie) { wheelPixelsPerUnit = -.53; }
  12644. else if (gecko) { wheelPixelsPerUnit = 15; }
  12645. else if (chrome) { wheelPixelsPerUnit = -.7; }
  12646. else if (safari) { wheelPixelsPerUnit = -1/3; }
  12647. function wheelEventDelta(e) {
  12648. var dx = e.wheelDeltaX, dy = e.wheelDeltaY;
  12649. if (dx == null && e.detail && e.axis == e.HORIZONTAL_AXIS) { dx = e.detail; }
  12650. if (dy == null && e.detail && e.axis == e.VERTICAL_AXIS) { dy = e.detail; }
  12651. else if (dy == null) { dy = e.wheelDelta; }
  12652. return {x: dx, y: dy}
  12653. }
  12654. function wheelEventPixels(e) {
  12655. var delta = wheelEventDelta(e);
  12656. delta.x *= wheelPixelsPerUnit;
  12657. delta.y *= wheelPixelsPerUnit;
  12658. return delta
  12659. }
  12660. function onScrollWheel(cm, e) {
  12661. var delta = wheelEventDelta(e), dx = delta.x, dy = delta.y;
  12662. var display = cm.display, scroll = display.scroller;
  12663. // Quit if there's nothing to scroll here
  12664. var canScrollX = scroll.scrollWidth > scroll.clientWidth;
  12665. var canScrollY = scroll.scrollHeight > scroll.clientHeight;
  12666. if (!(dx && canScrollX || dy && canScrollY)) { return }
  12667. // Webkit browsers on OS X abort momentum scrolls when the target
  12668. // of the scroll event is removed from the scrollable element.
  12669. // This hack (see related code in patchDisplay) makes sure the
  12670. // element is kept around.
  12671. if (dy && mac && webkit) {
  12672. outer: for (var cur = e.target, view = display.view; cur != scroll; cur = cur.parentNode) {
  12673. for (var i = 0; i < view.length; i++) {
  12674. if (view[i].node == cur) {
  12675. cm.display.currentWheelTarget = cur;
  12676. break outer
  12677. }
  12678. }
  12679. }
  12680. }
  12681. // On some browsers, horizontal scrolling will cause redraws to
  12682. // happen before the gutter has been realigned, causing it to
  12683. // wriggle around in a most unseemly way. When we have an
  12684. // estimated pixels/delta value, we just handle horizontal
  12685. // scrolling entirely here. It'll be slightly off from native, but
  12686. // better than glitching out.
  12687. if (dx && !gecko && !presto && wheelPixelsPerUnit != null) {
  12688. if (dy && canScrollY)
  12689. { updateScrollTop(cm, Math.max(0, scroll.scrollTop + dy * wheelPixelsPerUnit)); }
  12690. setScrollLeft(cm, Math.max(0, scroll.scrollLeft + dx * wheelPixelsPerUnit));
  12691. // Only prevent default scrolling if vertical scrolling is
  12692. // actually possible. Otherwise, it causes vertical scroll
  12693. // jitter on OSX trackpads when deltaX is small and deltaY
  12694. // is large (issue #3579)
  12695. if (!dy || (dy && canScrollY))
  12696. { e_preventDefault(e); }
  12697. display.wheelStartX = null; // Abort measurement, if in progress
  12698. return
  12699. }
  12700. // 'Project' the visible viewport to cover the area that is being
  12701. // scrolled into view (if we know enough to estimate it).
  12702. if (dy && wheelPixelsPerUnit != null) {
  12703. var pixels = dy * wheelPixelsPerUnit;
  12704. var top = cm.doc.scrollTop, bot = top + display.wrapper.clientHeight;
  12705. if (pixels < 0) { top = Math.max(0, top + pixels - 50); }
  12706. else { bot = Math.min(cm.doc.height, bot + pixels + 50); }
  12707. updateDisplaySimple(cm, {top: top, bottom: bot});
  12708. }
  12709. if (wheelSamples < 20) {
  12710. if (display.wheelStartX == null) {
  12711. display.wheelStartX = scroll.scrollLeft; display.wheelStartY = scroll.scrollTop;
  12712. display.wheelDX = dx; display.wheelDY = dy;
  12713. setTimeout(function () {
  12714. if (display.wheelStartX == null) { return }
  12715. var movedX = scroll.scrollLeft - display.wheelStartX;
  12716. var movedY = scroll.scrollTop - display.wheelStartY;
  12717. var sample = (movedY && display.wheelDY && movedY / display.wheelDY) ||
  12718. (movedX && display.wheelDX && movedX / display.wheelDX);
  12719. display.wheelStartX = display.wheelStartY = null;
  12720. if (!sample) { return }
  12721. wheelPixelsPerUnit = (wheelPixelsPerUnit * wheelSamples + sample) / (wheelSamples + 1);
  12722. ++wheelSamples;
  12723. }, 200);
  12724. } else {
  12725. display.wheelDX += dx; display.wheelDY += dy;
  12726. }
  12727. }
  12728. }
  12729. // Selection objects are immutable. A new one is created every time
  12730. // the selection changes. A selection is one or more non-overlapping
  12731. // (and non-touching) ranges, sorted, and an integer that indicates
  12732. // which one is the primary selection (the one that's scrolled into
  12733. // view, that getCursor returns, etc).
  12734. var Selection = function(ranges, primIndex) {
  12735. this.ranges = ranges;
  12736. this.primIndex = primIndex;
  12737. };
  12738. Selection.prototype.primary = function () { return this.ranges[this.primIndex] };
  12739. Selection.prototype.equals = function (other) {
  12740. var this$1 = this;
  12741. if (other == this) { return true }
  12742. if (other.primIndex != this.primIndex || other.ranges.length != this.ranges.length) { return false }
  12743. for (var i = 0; i < this.ranges.length; i++) {
  12744. var here = this$1.ranges[i], there = other.ranges[i];
  12745. if (!equalCursorPos(here.anchor, there.anchor) || !equalCursorPos(here.head, there.head)) { return false }
  12746. }
  12747. return true
  12748. };
  12749. Selection.prototype.deepCopy = function () {
  12750. var this$1 = this;
  12751. var out = [];
  12752. for (var i = 0; i < this.ranges.length; i++)
  12753. { out[i] = new Range(copyPos(this$1.ranges[i].anchor), copyPos(this$1.ranges[i].head)); }
  12754. return new Selection(out, this.primIndex)
  12755. };
  12756. Selection.prototype.somethingSelected = function () {
  12757. var this$1 = this;
  12758. for (var i = 0; i < this.ranges.length; i++)
  12759. { if (!this$1.ranges[i].empty()) { return true } }
  12760. return false
  12761. };
  12762. Selection.prototype.contains = function (pos, end) {
  12763. var this$1 = this;
  12764. if (!end) { end = pos; }
  12765. for (var i = 0; i < this.ranges.length; i++) {
  12766. var range = this$1.ranges[i];
  12767. if (cmp(end, range.from()) >= 0 && cmp(pos, range.to()) <= 0)
  12768. { return i }
  12769. }
  12770. return -1
  12771. };
  12772. var Range = function(anchor, head) {
  12773. this.anchor = anchor; this.head = head;
  12774. };
  12775. Range.prototype.from = function () { return minPos(this.anchor, this.head) };
  12776. Range.prototype.to = function () { return maxPos(this.anchor, this.head) };
  12777. Range.prototype.empty = function () { return this.head.line == this.anchor.line && this.head.ch == this.anchor.ch };
  12778. // Take an unsorted, potentially overlapping set of ranges, and
  12779. // build a selection out of it. 'Consumes' ranges array (modifying
  12780. // it).
  12781. function normalizeSelection(ranges, primIndex) {
  12782. var prim = ranges[primIndex];
  12783. ranges.sort(function (a, b) { return cmp(a.from(), b.from()); });
  12784. primIndex = indexOf(ranges, prim);
  12785. for (var i = 1; i < ranges.length; i++) {
  12786. var cur = ranges[i], prev = ranges[i - 1];
  12787. if (cmp(prev.to(), cur.from()) >= 0) {
  12788. var from = minPos(prev.from(), cur.from()), to = maxPos(prev.to(), cur.to());
  12789. var inv = prev.empty() ? cur.from() == cur.head : prev.from() == prev.head;
  12790. if (i <= primIndex) { --primIndex; }
  12791. ranges.splice(--i, 2, new Range(inv ? to : from, inv ? from : to));
  12792. }
  12793. }
  12794. return new Selection(ranges, primIndex)
  12795. }
  12796. function simpleSelection(anchor, head) {
  12797. return new Selection([new Range(anchor, head || anchor)], 0)
  12798. }
  12799. // Compute the position of the end of a change (its 'to' property
  12800. // refers to the pre-change end).
  12801. function changeEnd(change) {
  12802. if (!change.text) { return change.to }
  12803. return Pos(change.from.line + change.text.length - 1,
  12804. lst(change.text).length + (change.text.length == 1 ? change.from.ch : 0))
  12805. }
  12806. // Adjust a position to refer to the post-change position of the
  12807. // same text, or the end of the change if the change covers it.
  12808. function adjustForChange(pos, change) {
  12809. if (cmp(pos, change.from) < 0) { return pos }
  12810. if (cmp(pos, change.to) <= 0) { return changeEnd(change) }
  12811. var line = pos.line + change.text.length - (change.to.line - change.from.line) - 1, ch = pos.ch;
  12812. if (pos.line == change.to.line) { ch += changeEnd(change).ch - change.to.ch; }
  12813. return Pos(line, ch)
  12814. }
  12815. function computeSelAfterChange(doc, change) {
  12816. var out = [];
  12817. for (var i = 0; i < doc.sel.ranges.length; i++) {
  12818. var range = doc.sel.ranges[i];
  12819. out.push(new Range(adjustForChange(range.anchor, change),
  12820. adjustForChange(range.head, change)));
  12821. }
  12822. return normalizeSelection(out, doc.sel.primIndex)
  12823. }
  12824. function offsetPos(pos, old, nw) {
  12825. if (pos.line == old.line)
  12826. { return Pos(nw.line, pos.ch - old.ch + nw.ch) }
  12827. else
  12828. { return Pos(nw.line + (pos.line - old.line), pos.ch) }
  12829. }
  12830. // Used by replaceSelections to allow moving the selection to the
  12831. // start or around the replaced test. Hint may be "start" or "around".
  12832. function computeReplacedSel(doc, changes, hint) {
  12833. var out = [];
  12834. var oldPrev = Pos(doc.first, 0), newPrev = oldPrev;
  12835. for (var i = 0; i < changes.length; i++) {
  12836. var change = changes[i];
  12837. var from = offsetPos(change.from, oldPrev, newPrev);
  12838. var to = offsetPos(changeEnd(change), oldPrev, newPrev);
  12839. oldPrev = change.to;
  12840. newPrev = to;
  12841. if (hint == "around") {
  12842. var range = doc.sel.ranges[i], inv = cmp(range.head, range.anchor) < 0;
  12843. out[i] = new Range(inv ? to : from, inv ? from : to);
  12844. } else {
  12845. out[i] = new Range(from, from);
  12846. }
  12847. }
  12848. return new Selection(out, doc.sel.primIndex)
  12849. }
  12850. // Used to get the editor into a consistent state again when options change.
  12851. function loadMode(cm) {
  12852. cm.doc.mode = getMode(cm.options, cm.doc.modeOption);
  12853. resetModeState(cm);
  12854. }
  12855. function resetModeState(cm) {
  12856. cm.doc.iter(function (line) {
  12857. if (line.stateAfter) { line.stateAfter = null; }
  12858. if (line.styles) { line.styles = null; }
  12859. });
  12860. cm.doc.modeFrontier = cm.doc.highlightFrontier = cm.doc.first;
  12861. startWorker(cm, 100);
  12862. cm.state.modeGen++;
  12863. if (cm.curOp) { regChange(cm); }
  12864. }
  12865. // DOCUMENT DATA STRUCTURE
  12866. // By default, updates that start and end at the beginning of a line
  12867. // are treated specially, in order to make the association of line
  12868. // widgets and marker elements with the text behave more intuitive.
  12869. function isWholeLineUpdate(doc, change) {
  12870. return change.from.ch == 0 && change.to.ch == 0 && lst(change.text) == "" &&
  12871. (!doc.cm || doc.cm.options.wholeLineUpdateBefore)
  12872. }
  12873. // Perform a change on the document data structure.
  12874. function updateDoc(doc, change, markedSpans, estimateHeight$$1) {
  12875. function spansFor(n) {return markedSpans ? markedSpans[n] : null}
  12876. function update(line, text, spans) {
  12877. updateLine(line, text, spans, estimateHeight$$1);
  12878. signalLater(line, "change", line, change);
  12879. }
  12880. function linesFor(start, end) {
  12881. var result = [];
  12882. for (var i = start; i < end; ++i)
  12883. { result.push(new Line(text[i], spansFor(i), estimateHeight$$1)); }
  12884. return result
  12885. }
  12886. var from = change.from, to = change.to, text = change.text;
  12887. var firstLine = getLine(doc, from.line), lastLine = getLine(doc, to.line);
  12888. var lastText = lst(text), lastSpans = spansFor(text.length - 1), nlines = to.line - from.line;
  12889. // Adjust the line structure
  12890. if (change.full) {
  12891. doc.insert(0, linesFor(0, text.length));
  12892. doc.remove(text.length, doc.size - text.length);
  12893. } else if (isWholeLineUpdate(doc, change)) {
  12894. // This is a whole-line replace. Treated specially to make
  12895. // sure line objects move the way they are supposed to.
  12896. var added = linesFor(0, text.length - 1);
  12897. update(lastLine, lastLine.text, lastSpans);
  12898. if (nlines) { doc.remove(from.line, nlines); }
  12899. if (added.length) { doc.insert(from.line, added); }
  12900. } else if (firstLine == lastLine) {
  12901. if (text.length == 1) {
  12902. update(firstLine, firstLine.text.slice(0, from.ch) + lastText + firstLine.text.slice(to.ch), lastSpans);
  12903. } else {
  12904. var added$1 = linesFor(1, text.length - 1);
  12905. added$1.push(new Line(lastText + firstLine.text.slice(to.ch), lastSpans, estimateHeight$$1));
  12906. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  12907. doc.insert(from.line + 1, added$1);
  12908. }
  12909. } else if (text.length == 1) {
  12910. update(firstLine, firstLine.text.slice(0, from.ch) + text[0] + lastLine.text.slice(to.ch), spansFor(0));
  12911. doc.remove(from.line + 1, nlines);
  12912. } else {
  12913. update(firstLine, firstLine.text.slice(0, from.ch) + text[0], spansFor(0));
  12914. update(lastLine, lastText + lastLine.text.slice(to.ch), lastSpans);
  12915. var added$2 = linesFor(1, text.length - 1);
  12916. if (nlines > 1) { doc.remove(from.line + 1, nlines - 1); }
  12917. doc.insert(from.line + 1, added$2);
  12918. }
  12919. signalLater(doc, "change", doc, change);
  12920. }
  12921. // Call f for all linked documents.
  12922. function linkedDocs(doc, f, sharedHistOnly) {
  12923. function propagate(doc, skip, sharedHist) {
  12924. if (doc.linked) { for (var i = 0; i < doc.linked.length; ++i) {
  12925. var rel = doc.linked[i];
  12926. if (rel.doc == skip) { continue }
  12927. var shared = sharedHist && rel.sharedHist;
  12928. if (sharedHistOnly && !shared) { continue }
  12929. f(rel.doc, shared);
  12930. propagate(rel.doc, doc, shared);
  12931. } }
  12932. }
  12933. propagate(doc, null, true);
  12934. }
  12935. // Attach a document to an editor.
  12936. function attachDoc(cm, doc) {
  12937. if (doc.cm) { throw new Error("This document is already in use.") }
  12938. cm.doc = doc;
  12939. doc.cm = cm;
  12940. estimateLineHeights(cm);
  12941. loadMode(cm);
  12942. setDirectionClass(cm);
  12943. if (!cm.options.lineWrapping) { findMaxLine(cm); }
  12944. cm.options.mode = doc.modeOption;
  12945. regChange(cm);
  12946. }
  12947. function setDirectionClass(cm) {
  12948. (cm.doc.direction == "rtl" ? addClass : rmClass)(cm.display.lineDiv, "CodeMirror-rtl");
  12949. }
  12950. function directionChanged(cm) {
  12951. runInOp(cm, function () {
  12952. setDirectionClass(cm);
  12953. regChange(cm);
  12954. });
  12955. }
  12956. function History(startGen) {
  12957. // Arrays of change events and selections. Doing something adds an
  12958. // event to done and clears undo. Undoing moves events from done
  12959. // to undone, redoing moves them in the other direction.
  12960. this.done = []; this.undone = [];
  12961. this.undoDepth = Infinity;
  12962. // Used to track when changes can be merged into a single undo
  12963. // event
  12964. this.lastModTime = this.lastSelTime = 0;
  12965. this.lastOp = this.lastSelOp = null;
  12966. this.lastOrigin = this.lastSelOrigin = null;
  12967. // Used by the isClean() method
  12968. this.generation = this.maxGeneration = startGen || 1;
  12969. }
  12970. // Create a history change event from an updateDoc-style change
  12971. // object.
  12972. function historyChangeFromChange(doc, change) {
  12973. var histChange = {from: copyPos(change.from), to: changeEnd(change), text: getBetween(doc, change.from, change.to)};
  12974. attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1);
  12975. linkedDocs(doc, function (doc) { return attachLocalSpans(doc, histChange, change.from.line, change.to.line + 1); }, true);
  12976. return histChange
  12977. }
  12978. // Pop all selection events off the end of a history array. Stop at
  12979. // a change event.
  12980. function clearSelectionEvents(array) {
  12981. while (array.length) {
  12982. var last = lst(array);
  12983. if (last.ranges) { array.pop(); }
  12984. else { break }
  12985. }
  12986. }
  12987. // Find the top change event in the history. Pop off selection
  12988. // events that are in the way.
  12989. function lastChangeEvent(hist, force) {
  12990. if (force) {
  12991. clearSelectionEvents(hist.done);
  12992. return lst(hist.done)
  12993. } else if (hist.done.length && !lst(hist.done).ranges) {
  12994. return lst(hist.done)
  12995. } else if (hist.done.length > 1 && !hist.done[hist.done.length - 2].ranges) {
  12996. hist.done.pop();
  12997. return lst(hist.done)
  12998. }
  12999. }
  13000. // Register a change in the history. Merges changes that are within
  13001. // a single operation, or are close together with an origin that
  13002. // allows merging (starting with "+") into a single event.
  13003. function addChangeToHistory(doc, change, selAfter, opId) {
  13004. var hist = doc.history;
  13005. hist.undone.length = 0;
  13006. var time = +new Date, cur;
  13007. var last;
  13008. if ((hist.lastOp == opId ||
  13009. hist.lastOrigin == change.origin && change.origin &&
  13010. ((change.origin.charAt(0) == "+" && hist.lastModTime > time - (doc.cm ? doc.cm.options.historyEventDelay : 500)) ||
  13011. change.origin.charAt(0) == "*")) &&
  13012. (cur = lastChangeEvent(hist, hist.lastOp == opId))) {
  13013. // Merge this change into the last event
  13014. last = lst(cur.changes);
  13015. if (cmp(change.from, change.to) == 0 && cmp(change.from, last.to) == 0) {
  13016. // Optimized case for simple insertion -- don't want to add
  13017. // new changesets for every character typed
  13018. last.to = changeEnd(change);
  13019. } else {
  13020. // Add new sub-event
  13021. cur.changes.push(historyChangeFromChange(doc, change));
  13022. }
  13023. } else {
  13024. // Can not be merged, start a new event.
  13025. var before = lst(hist.done);
  13026. if (!before || !before.ranges)
  13027. { pushSelectionToHistory(doc.sel, hist.done); }
  13028. cur = {changes: [historyChangeFromChange(doc, change)],
  13029. generation: hist.generation};
  13030. hist.done.push(cur);
  13031. while (hist.done.length > hist.undoDepth) {
  13032. hist.done.shift();
  13033. if (!hist.done[0].ranges) { hist.done.shift(); }
  13034. }
  13035. }
  13036. hist.done.push(selAfter);
  13037. hist.generation = ++hist.maxGeneration;
  13038. hist.lastModTime = hist.lastSelTime = time;
  13039. hist.lastOp = hist.lastSelOp = opId;
  13040. hist.lastOrigin = hist.lastSelOrigin = change.origin;
  13041. if (!last) { signal(doc, "historyAdded"); }
  13042. }
  13043. function selectionEventCanBeMerged(doc, origin, prev, sel) {
  13044. var ch = origin.charAt(0);
  13045. return ch == "*" ||
  13046. ch == "+" &&
  13047. prev.ranges.length == sel.ranges.length &&
  13048. prev.somethingSelected() == sel.somethingSelected() &&
  13049. new Date - doc.history.lastSelTime <= (doc.cm ? doc.cm.options.historyEventDelay : 500)
  13050. }
  13051. // Called whenever the selection changes, sets the new selection as
  13052. // the pending selection in the history, and pushes the old pending
  13053. // selection into the 'done' array when it was significantly
  13054. // different (in number of selected ranges, emptiness, or time).
  13055. function addSelectionToHistory(doc, sel, opId, options) {
  13056. var hist = doc.history, origin = options && options.origin;
  13057. // A new event is started when the previous origin does not match
  13058. // the current, or the origins don't allow matching. Origins
  13059. // starting with * are always merged, those starting with + are
  13060. // merged when similar and close together in time.
  13061. if (opId == hist.lastSelOp ||
  13062. (origin && hist.lastSelOrigin == origin &&
  13063. (hist.lastModTime == hist.lastSelTime && hist.lastOrigin == origin ||
  13064. selectionEventCanBeMerged(doc, origin, lst(hist.done), sel))))
  13065. { hist.done[hist.done.length - 1] = sel; }
  13066. else
  13067. { pushSelectionToHistory(sel, hist.done); }
  13068. hist.lastSelTime = +new Date;
  13069. hist.lastSelOrigin = origin;
  13070. hist.lastSelOp = opId;
  13071. if (options && options.clearRedo !== false)
  13072. { clearSelectionEvents(hist.undone); }
  13073. }
  13074. function pushSelectionToHistory(sel, dest) {
  13075. var top = lst(dest);
  13076. if (!(top && top.ranges && top.equals(sel)))
  13077. { dest.push(sel); }
  13078. }
  13079. // Used to store marked span information in the history.
  13080. function attachLocalSpans(doc, change, from, to) {
  13081. var existing = change["spans_" + doc.id], n = 0;
  13082. doc.iter(Math.max(doc.first, from), Math.min(doc.first + doc.size, to), function (line) {
  13083. if (line.markedSpans)
  13084. { (existing || (existing = change["spans_" + doc.id] = {}))[n] = line.markedSpans; }
  13085. ++n;
  13086. });
  13087. }
  13088. // When un/re-doing restores text containing marked spans, those
  13089. // that have been explicitly cleared should not be restored.
  13090. function removeClearedSpans(spans) {
  13091. if (!spans) { return null }
  13092. var out;
  13093. for (var i = 0; i < spans.length; ++i) {
  13094. if (spans[i].marker.explicitlyCleared) { if (!out) { out = spans.slice(0, i); } }
  13095. else if (out) { out.push(spans[i]); }
  13096. }
  13097. return !out ? spans : out.length ? out : null
  13098. }
  13099. // Retrieve and filter the old marked spans stored in a change event.
  13100. function getOldSpans(doc, change) {
  13101. var found = change["spans_" + doc.id];
  13102. if (!found) { return null }
  13103. var nw = [];
  13104. for (var i = 0; i < change.text.length; ++i)
  13105. { nw.push(removeClearedSpans(found[i])); }
  13106. return nw
  13107. }
  13108. // Used for un/re-doing changes from the history. Combines the
  13109. // result of computing the existing spans with the set of spans that
  13110. // existed in the history (so that deleting around a span and then
  13111. // undoing brings back the span).
  13112. function mergeOldSpans(doc, change) {
  13113. var old = getOldSpans(doc, change);
  13114. var stretched = stretchSpansOverChange(doc, change);
  13115. if (!old) { return stretched }
  13116. if (!stretched) { return old }
  13117. for (var i = 0; i < old.length; ++i) {
  13118. var oldCur = old[i], stretchCur = stretched[i];
  13119. if (oldCur && stretchCur) {
  13120. spans: for (var j = 0; j < stretchCur.length; ++j) {
  13121. var span = stretchCur[j];
  13122. for (var k = 0; k < oldCur.length; ++k)
  13123. { if (oldCur[k].marker == span.marker) { continue spans } }
  13124. oldCur.push(span);
  13125. }
  13126. } else if (stretchCur) {
  13127. old[i] = stretchCur;
  13128. }
  13129. }
  13130. return old
  13131. }
  13132. // Used both to provide a JSON-safe object in .getHistory, and, when
  13133. // detaching a document, to split the history in two
  13134. function copyHistoryArray(events, newGroup, instantiateSel) {
  13135. var copy = [];
  13136. for (var i = 0; i < events.length; ++i) {
  13137. var event = events[i];
  13138. if (event.ranges) {
  13139. copy.push(instantiateSel ? Selection.prototype.deepCopy.call(event) : event);
  13140. continue
  13141. }
  13142. var changes = event.changes, newChanges = [];
  13143. copy.push({changes: newChanges});
  13144. for (var j = 0; j < changes.length; ++j) {
  13145. var change = changes[j], m = (void 0);
  13146. newChanges.push({from: change.from, to: change.to, text: change.text});
  13147. if (newGroup) { for (var prop in change) { if (m = prop.match(/^spans_(\d+)$/)) {
  13148. if (indexOf(newGroup, Number(m[1])) > -1) {
  13149. lst(newChanges)[prop] = change[prop];
  13150. delete change[prop];
  13151. }
  13152. } } }
  13153. }
  13154. }
  13155. return copy
  13156. }
  13157. // The 'scroll' parameter given to many of these indicated whether
  13158. // the new cursor position should be scrolled into view after
  13159. // modifying the selection.
  13160. // If shift is held or the extend flag is set, extends a range to
  13161. // include a given position (and optionally a second position).
  13162. // Otherwise, simply returns the range between the given positions.
  13163. // Used for cursor motion and such.
  13164. function extendRange(range, head, other, extend) {
  13165. if (extend) {
  13166. var anchor = range.anchor;
  13167. if (other) {
  13168. var posBefore = cmp(head, anchor) < 0;
  13169. if (posBefore != (cmp(other, anchor) < 0)) {
  13170. anchor = head;
  13171. head = other;
  13172. } else if (posBefore != (cmp(head, other) < 0)) {
  13173. head = other;
  13174. }
  13175. }
  13176. return new Range(anchor, head)
  13177. } else {
  13178. return new Range(other || head, head)
  13179. }
  13180. }
  13181. // Extend the primary selection range, discard the rest.
  13182. function extendSelection(doc, head, other, options, extend) {
  13183. if (extend == null) { extend = doc.cm && (doc.cm.display.shift || doc.extend); }
  13184. setSelection(doc, new Selection([extendRange(doc.sel.primary(), head, other, extend)], 0), options);
  13185. }
  13186. // Extend all selections (pos is an array of selections with length
  13187. // equal the number of selections)
  13188. function extendSelections(doc, heads, options) {
  13189. var out = [];
  13190. var extend = doc.cm && (doc.cm.display.shift || doc.extend);
  13191. for (var i = 0; i < doc.sel.ranges.length; i++)
  13192. { out[i] = extendRange(doc.sel.ranges[i], heads[i], null, extend); }
  13193. var newSel = normalizeSelection(out, doc.sel.primIndex);
  13194. setSelection(doc, newSel, options);
  13195. }
  13196. // Updates a single range in the selection.
  13197. function replaceOneSelection(doc, i, range, options) {
  13198. var ranges = doc.sel.ranges.slice(0);
  13199. ranges[i] = range;
  13200. setSelection(doc, normalizeSelection(ranges, doc.sel.primIndex), options);
  13201. }
  13202. // Reset the selection to a single range.
  13203. function setSimpleSelection(doc, anchor, head, options) {
  13204. setSelection(doc, simpleSelection(anchor, head), options);
  13205. }
  13206. // Give beforeSelectionChange handlers a change to influence a
  13207. // selection update.
  13208. function filterSelectionChange(doc, sel, options) {
  13209. var obj = {
  13210. ranges: sel.ranges,
  13211. update: function(ranges) {
  13212. var this$1 = this;
  13213. this.ranges = [];
  13214. for (var i = 0; i < ranges.length; i++)
  13215. { this$1.ranges[i] = new Range(clipPos(doc, ranges[i].anchor),
  13216. clipPos(doc, ranges[i].head)); }
  13217. },
  13218. origin: options && options.origin
  13219. };
  13220. signal(doc, "beforeSelectionChange", doc, obj);
  13221. if (doc.cm) { signal(doc.cm, "beforeSelectionChange", doc.cm, obj); }
  13222. if (obj.ranges != sel.ranges) { return normalizeSelection(obj.ranges, obj.ranges.length - 1) }
  13223. else { return sel }
  13224. }
  13225. function setSelectionReplaceHistory(doc, sel, options) {
  13226. var done = doc.history.done, last = lst(done);
  13227. if (last && last.ranges) {
  13228. done[done.length - 1] = sel;
  13229. setSelectionNoUndo(doc, sel, options);
  13230. } else {
  13231. setSelection(doc, sel, options);
  13232. }
  13233. }
  13234. // Set a new selection.
  13235. function setSelection(doc, sel, options) {
  13236. setSelectionNoUndo(doc, sel, options);
  13237. addSelectionToHistory(doc, doc.sel, doc.cm ? doc.cm.curOp.id : NaN, options);
  13238. }
  13239. function setSelectionNoUndo(doc, sel, options) {
  13240. if (hasHandler(doc, "beforeSelectionChange") || doc.cm && hasHandler(doc.cm, "beforeSelectionChange"))
  13241. { sel = filterSelectionChange(doc, sel, options); }
  13242. var bias = options && options.bias ||
  13243. (cmp(sel.primary().head, doc.sel.primary().head) < 0 ? -1 : 1);
  13244. setSelectionInner(doc, skipAtomicInSelection(doc, sel, bias, true));
  13245. if (!(options && options.scroll === false) && doc.cm)
  13246. { ensureCursorVisible(doc.cm); }
  13247. }
  13248. function setSelectionInner(doc, sel) {
  13249. if (sel.equals(doc.sel)) { return }
  13250. doc.sel = sel;
  13251. if (doc.cm) {
  13252. doc.cm.curOp.updateInput = doc.cm.curOp.selectionChanged = true;
  13253. signalCursorActivity(doc.cm);
  13254. }
  13255. signalLater(doc, "cursorActivity", doc);
  13256. }
  13257. // Verify that the selection does not partially select any atomic
  13258. // marked ranges.
  13259. function reCheckSelection(doc) {
  13260. setSelectionInner(doc, skipAtomicInSelection(doc, doc.sel, null, false));
  13261. }
  13262. // Return a selection that does not partially select any atomic
  13263. // ranges.
  13264. function skipAtomicInSelection(doc, sel, bias, mayClear) {
  13265. var out;
  13266. for (var i = 0; i < sel.ranges.length; i++) {
  13267. var range = sel.ranges[i];
  13268. var old = sel.ranges.length == doc.sel.ranges.length && doc.sel.ranges[i];
  13269. var newAnchor = skipAtomic(doc, range.anchor, old && old.anchor, bias, mayClear);
  13270. var newHead = skipAtomic(doc, range.head, old && old.head, bias, mayClear);
  13271. if (out || newAnchor != range.anchor || newHead != range.head) {
  13272. if (!out) { out = sel.ranges.slice(0, i); }
  13273. out[i] = new Range(newAnchor, newHead);
  13274. }
  13275. }
  13276. return out ? normalizeSelection(out, sel.primIndex) : sel
  13277. }
  13278. function skipAtomicInner(doc, pos, oldPos, dir, mayClear) {
  13279. var line = getLine(doc, pos.line);
  13280. if (line.markedSpans) { for (var i = 0; i < line.markedSpans.length; ++i) {
  13281. var sp = line.markedSpans[i], m = sp.marker;
  13282. if ((sp.from == null || (m.inclusiveLeft ? sp.from <= pos.ch : sp.from < pos.ch)) &&
  13283. (sp.to == null || (m.inclusiveRight ? sp.to >= pos.ch : sp.to > pos.ch))) {
  13284. if (mayClear) {
  13285. signal(m, "beforeCursorEnter");
  13286. if (m.explicitlyCleared) {
  13287. if (!line.markedSpans) { break }
  13288. else {--i; continue}
  13289. }
  13290. }
  13291. if (!m.atomic) { continue }
  13292. if (oldPos) {
  13293. var near = m.find(dir < 0 ? 1 : -1), diff = (void 0);
  13294. if (dir < 0 ? m.inclusiveRight : m.inclusiveLeft)
  13295. { near = movePos(doc, near, -dir, near && near.line == pos.line ? line : null); }
  13296. if (near && near.line == pos.line && (diff = cmp(near, oldPos)) && (dir < 0 ? diff < 0 : diff > 0))
  13297. { return skipAtomicInner(doc, near, pos, dir, mayClear) }
  13298. }
  13299. var far = m.find(dir < 0 ? -1 : 1);
  13300. if (dir < 0 ? m.inclusiveLeft : m.inclusiveRight)
  13301. { far = movePos(doc, far, dir, far.line == pos.line ? line : null); }
  13302. return far ? skipAtomicInner(doc, far, pos, dir, mayClear) : null
  13303. }
  13304. } }
  13305. return pos
  13306. }
  13307. // Ensure a given position is not inside an atomic range.
  13308. function skipAtomic(doc, pos, oldPos, bias, mayClear) {
  13309. var dir = bias || 1;
  13310. var found = skipAtomicInner(doc, pos, oldPos, dir, mayClear) ||
  13311. (!mayClear && skipAtomicInner(doc, pos, oldPos, dir, true)) ||
  13312. skipAtomicInner(doc, pos, oldPos, -dir, mayClear) ||
  13313. (!mayClear && skipAtomicInner(doc, pos, oldPos, -dir, true));
  13314. if (!found) {
  13315. doc.cantEdit = true;
  13316. return Pos(doc.first, 0)
  13317. }
  13318. return found
  13319. }
  13320. function movePos(doc, pos, dir, line) {
  13321. if (dir < 0 && pos.ch == 0) {
  13322. if (pos.line > doc.first) { return clipPos(doc, Pos(pos.line - 1)) }
  13323. else { return null }
  13324. } else if (dir > 0 && pos.ch == (line || getLine(doc, pos.line)).text.length) {
  13325. if (pos.line < doc.first + doc.size - 1) { return Pos(pos.line + 1, 0) }
  13326. else { return null }
  13327. } else {
  13328. return new Pos(pos.line, pos.ch + dir)
  13329. }
  13330. }
  13331. function selectAll(cm) {
  13332. cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()), sel_dontScroll);
  13333. }
  13334. // UPDATING
  13335. // Allow "beforeChange" event handlers to influence a change
  13336. function filterChange(doc, change, update) {
  13337. var obj = {
  13338. canceled: false,
  13339. from: change.from,
  13340. to: change.to,
  13341. text: change.text,
  13342. origin: change.origin,
  13343. cancel: function () { return obj.canceled = true; }
  13344. };
  13345. if (update) { obj.update = function (from, to, text, origin) {
  13346. if (from) { obj.from = clipPos(doc, from); }
  13347. if (to) { obj.to = clipPos(doc, to); }
  13348. if (text) { obj.text = text; }
  13349. if (origin !== undefined) { obj.origin = origin; }
  13350. }; }
  13351. signal(doc, "beforeChange", doc, obj);
  13352. if (doc.cm) { signal(doc.cm, "beforeChange", doc.cm, obj); }
  13353. if (obj.canceled) { return null }
  13354. return {from: obj.from, to: obj.to, text: obj.text, origin: obj.origin}
  13355. }
  13356. // Apply a change to a document, and add it to the document's
  13357. // history, and propagating it to all linked documents.
  13358. function makeChange(doc, change, ignoreReadOnly) {
  13359. if (doc.cm) {
  13360. if (!doc.cm.curOp) { return operation(doc.cm, makeChange)(doc, change, ignoreReadOnly) }
  13361. if (doc.cm.state.suppressEdits) { return }
  13362. }
  13363. if (hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange")) {
  13364. change = filterChange(doc, change, true);
  13365. if (!change) { return }
  13366. }
  13367. // Possibly split or suppress the update based on the presence
  13368. // of read-only spans in its range.
  13369. var split = sawReadOnlySpans && !ignoreReadOnly && removeReadOnlyRanges(doc, change.from, change.to);
  13370. if (split) {
  13371. for (var i = split.length - 1; i >= 0; --i)
  13372. { makeChangeInner(doc, {from: split[i].from, to: split[i].to, text: i ? [""] : change.text, origin: change.origin}); }
  13373. } else {
  13374. makeChangeInner(doc, change);
  13375. }
  13376. }
  13377. function makeChangeInner(doc, change) {
  13378. if (change.text.length == 1 && change.text[0] == "" && cmp(change.from, change.to) == 0) { return }
  13379. var selAfter = computeSelAfterChange(doc, change);
  13380. addChangeToHistory(doc, change, selAfter, doc.cm ? doc.cm.curOp.id : NaN);
  13381. makeChangeSingleDoc(doc, change, selAfter, stretchSpansOverChange(doc, change));
  13382. var rebased = [];
  13383. linkedDocs(doc, function (doc, sharedHist) {
  13384. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  13385. rebaseHist(doc.history, change);
  13386. rebased.push(doc.history);
  13387. }
  13388. makeChangeSingleDoc(doc, change, null, stretchSpansOverChange(doc, change));
  13389. });
  13390. }
  13391. // Revert a change stored in a document's history.
  13392. function makeChangeFromHistory(doc, type, allowSelectionOnly) {
  13393. var suppress = doc.cm && doc.cm.state.suppressEdits;
  13394. if (suppress && !allowSelectionOnly) { return }
  13395. var hist = doc.history, event, selAfter = doc.sel;
  13396. var source = type == "undo" ? hist.done : hist.undone, dest = type == "undo" ? hist.undone : hist.done;
  13397. // Verify that there is a useable event (so that ctrl-z won't
  13398. // needlessly clear selection events)
  13399. var i = 0;
  13400. for (; i < source.length; i++) {
  13401. event = source[i];
  13402. if (allowSelectionOnly ? event.ranges && !event.equals(doc.sel) : !event.ranges)
  13403. { break }
  13404. }
  13405. if (i == source.length) { return }
  13406. hist.lastOrigin = hist.lastSelOrigin = null;
  13407. for (;;) {
  13408. event = source.pop();
  13409. if (event.ranges) {
  13410. pushSelectionToHistory(event, dest);
  13411. if (allowSelectionOnly && !event.equals(doc.sel)) {
  13412. setSelection(doc, event, {clearRedo: false});
  13413. return
  13414. }
  13415. selAfter = event;
  13416. } else if (suppress) {
  13417. source.push(event);
  13418. return
  13419. } else { break }
  13420. }
  13421. // Build up a reverse change object to add to the opposite history
  13422. // stack (redo when undoing, and vice versa).
  13423. var antiChanges = [];
  13424. pushSelectionToHistory(selAfter, dest);
  13425. dest.push({changes: antiChanges, generation: hist.generation});
  13426. hist.generation = event.generation || ++hist.maxGeneration;
  13427. var filter = hasHandler(doc, "beforeChange") || doc.cm && hasHandler(doc.cm, "beforeChange");
  13428. var loop = function ( i ) {
  13429. var change = event.changes[i];
  13430. change.origin = type;
  13431. if (filter && !filterChange(doc, change, false)) {
  13432. source.length = 0;
  13433. return {}
  13434. }
  13435. antiChanges.push(historyChangeFromChange(doc, change));
  13436. var after = i ? computeSelAfterChange(doc, change) : lst(source);
  13437. makeChangeSingleDoc(doc, change, after, mergeOldSpans(doc, change));
  13438. if (!i && doc.cm) { doc.cm.scrollIntoView({from: change.from, to: changeEnd(change)}); }
  13439. var rebased = [];
  13440. // Propagate to the linked documents
  13441. linkedDocs(doc, function (doc, sharedHist) {
  13442. if (!sharedHist && indexOf(rebased, doc.history) == -1) {
  13443. rebaseHist(doc.history, change);
  13444. rebased.push(doc.history);
  13445. }
  13446. makeChangeSingleDoc(doc, change, null, mergeOldSpans(doc, change));
  13447. });
  13448. };
  13449. for (var i$1 = event.changes.length - 1; i$1 >= 0; --i$1) {
  13450. var returned = loop( i$1 );
  13451. if ( returned ) return returned.v;
  13452. }
  13453. }
  13454. // Sub-views need their line numbers shifted when text is added
  13455. // above or below them in the parent document.
  13456. function shiftDoc(doc, distance) {
  13457. if (distance == 0) { return }
  13458. doc.first += distance;
  13459. doc.sel = new Selection(map(doc.sel.ranges, function (range) { return new Range(
  13460. Pos(range.anchor.line + distance, range.anchor.ch),
  13461. Pos(range.head.line + distance, range.head.ch)
  13462. ); }), doc.sel.primIndex);
  13463. if (doc.cm) {
  13464. regChange(doc.cm, doc.first, doc.first - distance, distance);
  13465. for (var d = doc.cm.display, l = d.viewFrom; l < d.viewTo; l++)
  13466. { regLineChange(doc.cm, l, "gutter"); }
  13467. }
  13468. }
  13469. // More lower-level change function, handling only a single document
  13470. // (not linked ones).
  13471. function makeChangeSingleDoc(doc, change, selAfter, spans) {
  13472. if (doc.cm && !doc.cm.curOp)
  13473. { return operation(doc.cm, makeChangeSingleDoc)(doc, change, selAfter, spans) }
  13474. if (change.to.line < doc.first) {
  13475. shiftDoc(doc, change.text.length - 1 - (change.to.line - change.from.line));
  13476. return
  13477. }
  13478. if (change.from.line > doc.lastLine()) { return }
  13479. // Clip the change to the size of this doc
  13480. if (change.from.line < doc.first) {
  13481. var shift = change.text.length - 1 - (doc.first - change.from.line);
  13482. shiftDoc(doc, shift);
  13483. change = {from: Pos(doc.first, 0), to: Pos(change.to.line + shift, change.to.ch),
  13484. text: [lst(change.text)], origin: change.origin};
  13485. }
  13486. var last = doc.lastLine();
  13487. if (change.to.line > last) {
  13488. change = {from: change.from, to: Pos(last, getLine(doc, last).text.length),
  13489. text: [change.text[0]], origin: change.origin};
  13490. }
  13491. change.removed = getBetween(doc, change.from, change.to);
  13492. if (!selAfter) { selAfter = computeSelAfterChange(doc, change); }
  13493. if (doc.cm) { makeChangeSingleDocInEditor(doc.cm, change, spans); }
  13494. else { updateDoc(doc, change, spans); }
  13495. setSelectionNoUndo(doc, selAfter, sel_dontScroll);
  13496. }
  13497. // Handle the interaction of a change to a document with the editor
  13498. // that this document is part of.
  13499. function makeChangeSingleDocInEditor(cm, change, spans) {
  13500. var doc = cm.doc, display = cm.display, from = change.from, to = change.to;
  13501. var recomputeMaxLength = false, checkWidthStart = from.line;
  13502. if (!cm.options.lineWrapping) {
  13503. checkWidthStart = lineNo(visualLine(getLine(doc, from.line)));
  13504. doc.iter(checkWidthStart, to.line + 1, function (line) {
  13505. if (line == display.maxLine) {
  13506. recomputeMaxLength = true;
  13507. return true
  13508. }
  13509. });
  13510. }
  13511. if (doc.sel.contains(change.from, change.to) > -1)
  13512. { signalCursorActivity(cm); }
  13513. updateDoc(doc, change, spans, estimateHeight(cm));
  13514. if (!cm.options.lineWrapping) {
  13515. doc.iter(checkWidthStart, from.line + change.text.length, function (line) {
  13516. var len = lineLength(line);
  13517. if (len > display.maxLineLength) {
  13518. display.maxLine = line;
  13519. display.maxLineLength = len;
  13520. display.maxLineChanged = true;
  13521. recomputeMaxLength = false;
  13522. }
  13523. });
  13524. if (recomputeMaxLength) { cm.curOp.updateMaxLine = true; }
  13525. }
  13526. retreatFrontier(doc, from.line);
  13527. startWorker(cm, 400);
  13528. var lendiff = change.text.length - (to.line - from.line) - 1;
  13529. // Remember that these lines changed, for updating the display
  13530. if (change.full)
  13531. { regChange(cm); }
  13532. else if (from.line == to.line && change.text.length == 1 && !isWholeLineUpdate(cm.doc, change))
  13533. { regLineChange(cm, from.line, "text"); }
  13534. else
  13535. { regChange(cm, from.line, to.line + 1, lendiff); }
  13536. var changesHandler = hasHandler(cm, "changes"), changeHandler = hasHandler(cm, "change");
  13537. if (changeHandler || changesHandler) {
  13538. var obj = {
  13539. from: from, to: to,
  13540. text: change.text,
  13541. removed: change.removed,
  13542. origin: change.origin
  13543. };
  13544. if (changeHandler) { signalLater(cm, "change", cm, obj); }
  13545. if (changesHandler) { (cm.curOp.changeObjs || (cm.curOp.changeObjs = [])).push(obj); }
  13546. }
  13547. cm.display.selForContextMenu = null;
  13548. }
  13549. function replaceRange(doc, code, from, to, origin) {
  13550. if (!to) { to = from; }
  13551. if (cmp(to, from) < 0) { var assign;
  13552. (assign = [to, from], from = assign[0], to = assign[1]); }
  13553. if (typeof code == "string") { code = doc.splitLines(code); }
  13554. makeChange(doc, {from: from, to: to, text: code, origin: origin});
  13555. }
  13556. // Rebasing/resetting history to deal with externally-sourced changes
  13557. function rebaseHistSelSingle(pos, from, to, diff) {
  13558. if (to < pos.line) {
  13559. pos.line += diff;
  13560. } else if (from < pos.line) {
  13561. pos.line = from;
  13562. pos.ch = 0;
  13563. }
  13564. }
  13565. // Tries to rebase an array of history events given a change in the
  13566. // document. If the change touches the same lines as the event, the
  13567. // event, and everything 'behind' it, is discarded. If the change is
  13568. // before the event, the event's positions are updated. Uses a
  13569. // copy-on-write scheme for the positions, to avoid having to
  13570. // reallocate them all on every rebase, but also avoid problems with
  13571. // shared position objects being unsafely updated.
  13572. function rebaseHistArray(array, from, to, diff) {
  13573. for (var i = 0; i < array.length; ++i) {
  13574. var sub = array[i], ok = true;
  13575. if (sub.ranges) {
  13576. if (!sub.copied) { sub = array[i] = sub.deepCopy(); sub.copied = true; }
  13577. for (var j = 0; j < sub.ranges.length; j++) {
  13578. rebaseHistSelSingle(sub.ranges[j].anchor, from, to, diff);
  13579. rebaseHistSelSingle(sub.ranges[j].head, from, to, diff);
  13580. }
  13581. continue
  13582. }
  13583. for (var j$1 = 0; j$1 < sub.changes.length; ++j$1) {
  13584. var cur = sub.changes[j$1];
  13585. if (to < cur.from.line) {
  13586. cur.from = Pos(cur.from.line + diff, cur.from.ch);
  13587. cur.to = Pos(cur.to.line + diff, cur.to.ch);
  13588. } else if (from <= cur.to.line) {
  13589. ok = false;
  13590. break
  13591. }
  13592. }
  13593. if (!ok) {
  13594. array.splice(0, i + 1);
  13595. i = 0;
  13596. }
  13597. }
  13598. }
  13599. function rebaseHist(hist, change) {
  13600. var from = change.from.line, to = change.to.line, diff = change.text.length - (to - from) - 1;
  13601. rebaseHistArray(hist.done, from, to, diff);
  13602. rebaseHistArray(hist.undone, from, to, diff);
  13603. }
  13604. // Utility for applying a change to a line by handle or number,
  13605. // returning the number and optionally registering the line as
  13606. // changed.
  13607. function changeLine(doc, handle, changeType, op) {
  13608. var no = handle, line = handle;
  13609. if (typeof handle == "number") { line = getLine(doc, clipLine(doc, handle)); }
  13610. else { no = lineNo(handle); }
  13611. if (no == null) { return null }
  13612. if (op(line, no) && doc.cm) { regLineChange(doc.cm, no, changeType); }
  13613. return line
  13614. }
  13615. // The document is represented as a BTree consisting of leaves, with
  13616. // chunk of lines in them, and branches, with up to ten leaves or
  13617. // other branch nodes below them. The top node is always a branch
  13618. // node, and is the document object itself (meaning it has
  13619. // additional methods and properties).
  13620. //
  13621. // All nodes have parent links. The tree is used both to go from
  13622. // line numbers to line objects, and to go from objects to numbers.
  13623. // It also indexes by height, and is used to convert between height
  13624. // and line object, and to find the total height of the document.
  13625. //
  13626. // See also http://marijnhaverbeke.nl/blog/codemirror-line-tree.html
  13627. function LeafChunk(lines) {
  13628. var this$1 = this;
  13629. this.lines = lines;
  13630. this.parent = null;
  13631. var height = 0;
  13632. for (var i = 0; i < lines.length; ++i) {
  13633. lines[i].parent = this$1;
  13634. height += lines[i].height;
  13635. }
  13636. this.height = height;
  13637. }
  13638. LeafChunk.prototype = {
  13639. chunkSize: function() { return this.lines.length },
  13640. // Remove the n lines at offset 'at'.
  13641. removeInner: function(at, n) {
  13642. var this$1 = this;
  13643. for (var i = at, e = at + n; i < e; ++i) {
  13644. var line = this$1.lines[i];
  13645. this$1.height -= line.height;
  13646. cleanUpLine(line);
  13647. signalLater(line, "delete");
  13648. }
  13649. this.lines.splice(at, n);
  13650. },
  13651. // Helper used to collapse a small branch into a single leaf.
  13652. collapse: function(lines) {
  13653. lines.push.apply(lines, this.lines);
  13654. },
  13655. // Insert the given array of lines at offset 'at', count them as
  13656. // having the given height.
  13657. insertInner: function(at, lines, height) {
  13658. var this$1 = this;
  13659. this.height += height;
  13660. this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
  13661. for (var i = 0; i < lines.length; ++i) { lines[i].parent = this$1; }
  13662. },
  13663. // Used to iterate over a part of the tree.
  13664. iterN: function(at, n, op) {
  13665. var this$1 = this;
  13666. for (var e = at + n; at < e; ++at)
  13667. { if (op(this$1.lines[at])) { return true } }
  13668. }
  13669. };
  13670. function BranchChunk(children) {
  13671. var this$1 = this;
  13672. this.children = children;
  13673. var size = 0, height = 0;
  13674. for (var i = 0; i < children.length; ++i) {
  13675. var ch = children[i];
  13676. size += ch.chunkSize(); height += ch.height;
  13677. ch.parent = this$1;
  13678. }
  13679. this.size = size;
  13680. this.height = height;
  13681. this.parent = null;
  13682. }
  13683. BranchChunk.prototype = {
  13684. chunkSize: function() { return this.size },
  13685. removeInner: function(at, n) {
  13686. var this$1 = this;
  13687. this.size -= n;
  13688. for (var i = 0; i < this.children.length; ++i) {
  13689. var child = this$1.children[i], sz = child.chunkSize();
  13690. if (at < sz) {
  13691. var rm = Math.min(n, sz - at), oldHeight = child.height;
  13692. child.removeInner(at, rm);
  13693. this$1.height -= oldHeight - child.height;
  13694. if (sz == rm) { this$1.children.splice(i--, 1); child.parent = null; }
  13695. if ((n -= rm) == 0) { break }
  13696. at = 0;
  13697. } else { at -= sz; }
  13698. }
  13699. // If the result is smaller than 25 lines, ensure that it is a
  13700. // single leaf node.
  13701. if (this.size - n < 25 &&
  13702. (this.children.length > 1 || !(this.children[0] instanceof LeafChunk))) {
  13703. var lines = [];
  13704. this.collapse(lines);
  13705. this.children = [new LeafChunk(lines)];
  13706. this.children[0].parent = this;
  13707. }
  13708. },
  13709. collapse: function(lines) {
  13710. var this$1 = this;
  13711. for (var i = 0; i < this.children.length; ++i) { this$1.children[i].collapse(lines); }
  13712. },
  13713. insertInner: function(at, lines, height) {
  13714. var this$1 = this;
  13715. this.size += lines.length;
  13716. this.height += height;
  13717. for (var i = 0; i < this.children.length; ++i) {
  13718. var child = this$1.children[i], sz = child.chunkSize();
  13719. if (at <= sz) {
  13720. child.insertInner(at, lines, height);
  13721. if (child.lines && child.lines.length > 50) {
  13722. // To avoid memory thrashing when child.lines is huge (e.g. first view of a large file), it's never spliced.
  13723. // Instead, small slices are taken. They're taken in order because sequential memory accesses are fastest.
  13724. var remaining = child.lines.length % 25 + 25;
  13725. for (var pos = remaining; pos < child.lines.length;) {
  13726. var leaf = new LeafChunk(child.lines.slice(pos, pos += 25));
  13727. child.height -= leaf.height;
  13728. this$1.children.splice(++i, 0, leaf);
  13729. leaf.parent = this$1;
  13730. }
  13731. child.lines = child.lines.slice(0, remaining);
  13732. this$1.maybeSpill();
  13733. }
  13734. break
  13735. }
  13736. at -= sz;
  13737. }
  13738. },
  13739. // When a node has grown, check whether it should be split.
  13740. maybeSpill: function() {
  13741. if (this.children.length <= 10) { return }
  13742. var me = this;
  13743. do {
  13744. var spilled = me.children.splice(me.children.length - 5, 5);
  13745. var sibling = new BranchChunk(spilled);
  13746. if (!me.parent) { // Become the parent node
  13747. var copy = new BranchChunk(me.children);
  13748. copy.parent = me;
  13749. me.children = [copy, sibling];
  13750. me = copy;
  13751. } else {
  13752. me.size -= sibling.size;
  13753. me.height -= sibling.height;
  13754. var myIndex = indexOf(me.parent.children, me);
  13755. me.parent.children.splice(myIndex + 1, 0, sibling);
  13756. }
  13757. sibling.parent = me.parent;
  13758. } while (me.children.length > 10)
  13759. me.parent.maybeSpill();
  13760. },
  13761. iterN: function(at, n, op) {
  13762. var this$1 = this;
  13763. for (var i = 0; i < this.children.length; ++i) {
  13764. var child = this$1.children[i], sz = child.chunkSize();
  13765. if (at < sz) {
  13766. var used = Math.min(n, sz - at);
  13767. if (child.iterN(at, used, op)) { return true }
  13768. if ((n -= used) == 0) { break }
  13769. at = 0;
  13770. } else { at -= sz; }
  13771. }
  13772. }
  13773. };
  13774. // Line widgets are block elements displayed above or below a line.
  13775. var LineWidget = function(doc, node, options) {
  13776. var this$1 = this;
  13777. if (options) { for (var opt in options) { if (options.hasOwnProperty(opt))
  13778. { this$1[opt] = options[opt]; } } }
  13779. this.doc = doc;
  13780. this.node = node;
  13781. };
  13782. LineWidget.prototype.clear = function () {
  13783. var this$1 = this;
  13784. var cm = this.doc.cm, ws = this.line.widgets, line = this.line, no = lineNo(line);
  13785. if (no == null || !ws) { return }
  13786. for (var i = 0; i < ws.length; ++i) { if (ws[i] == this$1) { ws.splice(i--, 1); } }
  13787. if (!ws.length) { line.widgets = null; }
  13788. var height = widgetHeight(this);
  13789. updateLineHeight(line, Math.max(0, line.height - height));
  13790. if (cm) {
  13791. runInOp(cm, function () {
  13792. adjustScrollWhenAboveVisible(cm, line, -height);
  13793. regLineChange(cm, no, "widget");
  13794. });
  13795. signalLater(cm, "lineWidgetCleared", cm, this, no);
  13796. }
  13797. };
  13798. LineWidget.prototype.changed = function () {
  13799. var this$1 = this;
  13800. var oldH = this.height, cm = this.doc.cm, line = this.line;
  13801. this.height = null;
  13802. var diff = widgetHeight(this) - oldH;
  13803. if (!diff) { return }
  13804. updateLineHeight(line, line.height + diff);
  13805. if (cm) {
  13806. runInOp(cm, function () {
  13807. cm.curOp.forceUpdate = true;
  13808. adjustScrollWhenAboveVisible(cm, line, diff);
  13809. signalLater(cm, "lineWidgetChanged", cm, this$1, lineNo(line));
  13810. });
  13811. }
  13812. };
  13813. eventMixin(LineWidget);
  13814. function adjustScrollWhenAboveVisible(cm, line, diff) {
  13815. if (heightAtLine(line) < ((cm.curOp && cm.curOp.scrollTop) || cm.doc.scrollTop))
  13816. { addToScrollTop(cm, diff); }
  13817. }
  13818. function addLineWidget(doc, handle, node, options) {
  13819. var widget = new LineWidget(doc, node, options);
  13820. var cm = doc.cm;
  13821. if (cm && widget.noHScroll) { cm.display.alignWidgets = true; }
  13822. changeLine(doc, handle, "widget", function (line) {
  13823. var widgets = line.widgets || (line.widgets = []);
  13824. if (widget.insertAt == null) { widgets.push(widget); }
  13825. else { widgets.splice(Math.min(widgets.length - 1, Math.max(0, widget.insertAt)), 0, widget); }
  13826. widget.line = line;
  13827. if (cm && !lineIsHidden(doc, line)) {
  13828. var aboveVisible = heightAtLine(line) < doc.scrollTop;
  13829. updateLineHeight(line, line.height + widgetHeight(widget));
  13830. if (aboveVisible) { addToScrollTop(cm, widget.height); }
  13831. cm.curOp.forceUpdate = true;
  13832. }
  13833. return true
  13834. });
  13835. if (cm) { signalLater(cm, "lineWidgetAdded", cm, widget, typeof handle == "number" ? handle : lineNo(handle)); }
  13836. return widget
  13837. }
  13838. // TEXTMARKERS
  13839. // Created with markText and setBookmark methods. A TextMarker is a
  13840. // handle that can be used to clear or find a marked position in the
  13841. // document. Line objects hold arrays (markedSpans) containing
  13842. // {from, to, marker} object pointing to such marker objects, and
  13843. // indicating that such a marker is present on that line. Multiple
  13844. // lines may point to the same marker when it spans across lines.
  13845. // The spans will have null for their from/to properties when the
  13846. // marker continues beyond the start/end of the line. Markers have
  13847. // links back to the lines they currently touch.
  13848. // Collapsed markers have unique ids, in order to be able to order
  13849. // them, which is needed for uniquely determining an outer marker
  13850. // when they overlap (they may nest, but not partially overlap).
  13851. var nextMarkerId = 0;
  13852. var TextMarker = function(doc, type) {
  13853. this.lines = [];
  13854. this.type = type;
  13855. this.doc = doc;
  13856. this.id = ++nextMarkerId;
  13857. };
  13858. // Clear the marker.
  13859. TextMarker.prototype.clear = function () {
  13860. var this$1 = this;
  13861. if (this.explicitlyCleared) { return }
  13862. var cm = this.doc.cm, withOp = cm && !cm.curOp;
  13863. if (withOp) { startOperation(cm); }
  13864. if (hasHandler(this, "clear")) {
  13865. var found = this.find();
  13866. if (found) { signalLater(this, "clear", found.from, found.to); }
  13867. }
  13868. var min = null, max = null;
  13869. for (var i = 0; i < this.lines.length; ++i) {
  13870. var line = this$1.lines[i];
  13871. var span = getMarkedSpanFor(line.markedSpans, this$1);
  13872. if (cm && !this$1.collapsed) { regLineChange(cm, lineNo(line), "text"); }
  13873. else if (cm) {
  13874. if (span.to != null) { max = lineNo(line); }
  13875. if (span.from != null) { min = lineNo(line); }
  13876. }
  13877. line.markedSpans = removeMarkedSpan(line.markedSpans, span);
  13878. if (span.from == null && this$1.collapsed && !lineIsHidden(this$1.doc, line) && cm)
  13879. { updateLineHeight(line, textHeight(cm.display)); }
  13880. }
  13881. if (cm && this.collapsed && !cm.options.lineWrapping) { for (var i$1 = 0; i$1 < this.lines.length; ++i$1) {
  13882. var visual = visualLine(this$1.lines[i$1]), len = lineLength(visual);
  13883. if (len > cm.display.maxLineLength) {
  13884. cm.display.maxLine = visual;
  13885. cm.display.maxLineLength = len;
  13886. cm.display.maxLineChanged = true;
  13887. }
  13888. } }
  13889. if (min != null && cm && this.collapsed) { regChange(cm, min, max + 1); }
  13890. this.lines.length = 0;
  13891. this.explicitlyCleared = true;
  13892. if (this.atomic && this.doc.cantEdit) {
  13893. this.doc.cantEdit = false;
  13894. if (cm) { reCheckSelection(cm.doc); }
  13895. }
  13896. if (cm) { signalLater(cm, "markerCleared", cm, this, min, max); }
  13897. if (withOp) { endOperation(cm); }
  13898. if (this.parent) { this.parent.clear(); }
  13899. };
  13900. // Find the position of the marker in the document. Returns a {from,
  13901. // to} object by default. Side can be passed to get a specific side
  13902. // -- 0 (both), -1 (left), or 1 (right). When lineObj is true, the
  13903. // Pos objects returned contain a line object, rather than a line
  13904. // number (used to prevent looking up the same line twice).
  13905. TextMarker.prototype.find = function (side, lineObj) {
  13906. var this$1 = this;
  13907. if (side == null && this.type == "bookmark") { side = 1; }
  13908. var from, to;
  13909. for (var i = 0; i < this.lines.length; ++i) {
  13910. var line = this$1.lines[i];
  13911. var span = getMarkedSpanFor(line.markedSpans, this$1);
  13912. if (span.from != null) {
  13913. from = Pos(lineObj ? line : lineNo(line), span.from);
  13914. if (side == -1) { return from }
  13915. }
  13916. if (span.to != null) {
  13917. to = Pos(lineObj ? line : lineNo(line), span.to);
  13918. if (side == 1) { return to }
  13919. }
  13920. }
  13921. return from && {from: from, to: to}
  13922. };
  13923. // Signals that the marker's widget changed, and surrounding layout
  13924. // should be recomputed.
  13925. TextMarker.prototype.changed = function () {
  13926. var this$1 = this;
  13927. var pos = this.find(-1, true), widget = this, cm = this.doc.cm;
  13928. if (!pos || !cm) { return }
  13929. runInOp(cm, function () {
  13930. var line = pos.line, lineN = lineNo(pos.line);
  13931. var view = findViewForLine(cm, lineN);
  13932. if (view) {
  13933. clearLineMeasurementCacheFor(view);
  13934. cm.curOp.selectionChanged = cm.curOp.forceUpdate = true;
  13935. }
  13936. cm.curOp.updateMaxLine = true;
  13937. if (!lineIsHidden(widget.doc, line) && widget.height != null) {
  13938. var oldHeight = widget.height;
  13939. widget.height = null;
  13940. var dHeight = widgetHeight(widget) - oldHeight;
  13941. if (dHeight)
  13942. { updateLineHeight(line, line.height + dHeight); }
  13943. }
  13944. signalLater(cm, "markerChanged", cm, this$1);
  13945. });
  13946. };
  13947. TextMarker.prototype.attachLine = function (line) {
  13948. if (!this.lines.length && this.doc.cm) {
  13949. var op = this.doc.cm.curOp;
  13950. if (!op.maybeHiddenMarkers || indexOf(op.maybeHiddenMarkers, this) == -1)
  13951. { (op.maybeUnhiddenMarkers || (op.maybeUnhiddenMarkers = [])).push(this); }
  13952. }
  13953. this.lines.push(line);
  13954. };
  13955. TextMarker.prototype.detachLine = function (line) {
  13956. this.lines.splice(indexOf(this.lines, line), 1);
  13957. if (!this.lines.length && this.doc.cm) {
  13958. var op = this.doc.cm.curOp;(op.maybeHiddenMarkers || (op.maybeHiddenMarkers = [])).push(this);
  13959. }
  13960. };
  13961. eventMixin(TextMarker);
  13962. // Create a marker, wire it up to the right lines, and
  13963. function markText(doc, from, to, options, type) {
  13964. // Shared markers (across linked documents) are handled separately
  13965. // (markTextShared will call out to this again, once per
  13966. // document).
  13967. if (options && options.shared) { return markTextShared(doc, from, to, options, type) }
  13968. // Ensure we are in an operation.
  13969. if (doc.cm && !doc.cm.curOp) { return operation(doc.cm, markText)(doc, from, to, options, type) }
  13970. var marker = new TextMarker(doc, type), diff = cmp(from, to);
  13971. if (options) { copyObj(options, marker, false); }
  13972. // Don't connect empty markers unless clearWhenEmpty is false
  13973. if (diff > 0 || diff == 0 && marker.clearWhenEmpty !== false)
  13974. { return marker }
  13975. if (marker.replacedWith) {
  13976. // Showing up as a widget implies collapsed (widget replaces text)
  13977. marker.collapsed = true;
  13978. marker.widgetNode = eltP("span", [marker.replacedWith], "CodeMirror-widget");
  13979. if (!options.handleMouseEvents) { marker.widgetNode.setAttribute("cm-ignore-events", "true"); }
  13980. if (options.insertLeft) { marker.widgetNode.insertLeft = true; }
  13981. }
  13982. if (marker.collapsed) {
  13983. if (conflictingCollapsedRange(doc, from.line, from, to, marker) ||
  13984. from.line != to.line && conflictingCollapsedRange(doc, to.line, from, to, marker))
  13985. { throw new Error("Inserting collapsed marker partially overlapping an existing one") }
  13986. seeCollapsedSpans();
  13987. }
  13988. if (marker.addToHistory)
  13989. { addChangeToHistory(doc, {from: from, to: to, origin: "markText"}, doc.sel, NaN); }
  13990. var curLine = from.line, cm = doc.cm, updateMaxLine;
  13991. doc.iter(curLine, to.line + 1, function (line) {
  13992. if (cm && marker.collapsed && !cm.options.lineWrapping && visualLine(line) == cm.display.maxLine)
  13993. { updateMaxLine = true; }
  13994. if (marker.collapsed && curLine != from.line) { updateLineHeight(line, 0); }
  13995. addMarkedSpan(line, new MarkedSpan(marker,
  13996. curLine == from.line ? from.ch : null,
  13997. curLine == to.line ? to.ch : null));
  13998. ++curLine;
  13999. });
  14000. // lineIsHidden depends on the presence of the spans, so needs a second pass
  14001. if (marker.collapsed) { doc.iter(from.line, to.line + 1, function (line) {
  14002. if (lineIsHidden(doc, line)) { updateLineHeight(line, 0); }
  14003. }); }
  14004. if (marker.clearOnEnter) { on(marker, "beforeCursorEnter", function () { return marker.clear(); }); }
  14005. if (marker.readOnly) {
  14006. seeReadOnlySpans();
  14007. if (doc.history.done.length || doc.history.undone.length)
  14008. { doc.clearHistory(); }
  14009. }
  14010. if (marker.collapsed) {
  14011. marker.id = ++nextMarkerId;
  14012. marker.atomic = true;
  14013. }
  14014. if (cm) {
  14015. // Sync editor state
  14016. if (updateMaxLine) { cm.curOp.updateMaxLine = true; }
  14017. if (marker.collapsed)
  14018. { regChange(cm, from.line, to.line + 1); }
  14019. else if (marker.className || marker.title || marker.startStyle || marker.endStyle || marker.css)
  14020. { for (var i = from.line; i <= to.line; i++) { regLineChange(cm, i, "text"); } }
  14021. if (marker.atomic) { reCheckSelection(cm.doc); }
  14022. signalLater(cm, "markerAdded", cm, marker);
  14023. }
  14024. return marker
  14025. }
  14026. // SHARED TEXTMARKERS
  14027. // A shared marker spans multiple linked documents. It is
  14028. // implemented as a meta-marker-object controlling multiple normal
  14029. // markers.
  14030. var SharedTextMarker = function(markers, primary) {
  14031. var this$1 = this;
  14032. this.markers = markers;
  14033. this.primary = primary;
  14034. for (var i = 0; i < markers.length; ++i)
  14035. { markers[i].parent = this$1; }
  14036. };
  14037. SharedTextMarker.prototype.clear = function () {
  14038. var this$1 = this;
  14039. if (this.explicitlyCleared) { return }
  14040. this.explicitlyCleared = true;
  14041. for (var i = 0; i < this.markers.length; ++i)
  14042. { this$1.markers[i].clear(); }
  14043. signalLater(this, "clear");
  14044. };
  14045. SharedTextMarker.prototype.find = function (side, lineObj) {
  14046. return this.primary.find(side, lineObj)
  14047. };
  14048. eventMixin(SharedTextMarker);
  14049. function markTextShared(doc, from, to, options, type) {
  14050. options = copyObj(options);
  14051. options.shared = false;
  14052. var markers = [markText(doc, from, to, options, type)], primary = markers[0];
  14053. var widget = options.widgetNode;
  14054. linkedDocs(doc, function (doc) {
  14055. if (widget) { options.widgetNode = widget.cloneNode(true); }
  14056. markers.push(markText(doc, clipPos(doc, from), clipPos(doc, to), options, type));
  14057. for (var i = 0; i < doc.linked.length; ++i)
  14058. { if (doc.linked[i].isParent) { return } }
  14059. primary = lst(markers);
  14060. });
  14061. return new SharedTextMarker(markers, primary)
  14062. }
  14063. function findSharedMarkers(doc) {
  14064. return doc.findMarks(Pos(doc.first, 0), doc.clipPos(Pos(doc.lastLine())), function (m) { return m.parent; })
  14065. }
  14066. function copySharedMarkers(doc, markers) {
  14067. for (var i = 0; i < markers.length; i++) {
  14068. var marker = markers[i], pos = marker.find();
  14069. var mFrom = doc.clipPos(pos.from), mTo = doc.clipPos(pos.to);
  14070. if (cmp(mFrom, mTo)) {
  14071. var subMark = markText(doc, mFrom, mTo, marker.primary, marker.primary.type);
  14072. marker.markers.push(subMark);
  14073. subMark.parent = marker;
  14074. }
  14075. }
  14076. }
  14077. function detachSharedMarkers(markers) {
  14078. var loop = function ( i ) {
  14079. var marker = markers[i], linked = [marker.primary.doc];
  14080. linkedDocs(marker.primary.doc, function (d) { return linked.push(d); });
  14081. for (var j = 0; j < marker.markers.length; j++) {
  14082. var subMarker = marker.markers[j];
  14083. if (indexOf(linked, subMarker.doc) == -1) {
  14084. subMarker.parent = null;
  14085. marker.markers.splice(j--, 1);
  14086. }
  14087. }
  14088. };
  14089. for (var i = 0; i < markers.length; i++) loop( i );
  14090. }
  14091. var nextDocId = 0;
  14092. var Doc = function(text, mode, firstLine, lineSep, direction) {
  14093. if (!(this instanceof Doc)) { return new Doc(text, mode, firstLine, lineSep, direction) }
  14094. if (firstLine == null) { firstLine = 0; }
  14095. BranchChunk.call(this, [new LeafChunk([new Line("", null)])]);
  14096. this.first = firstLine;
  14097. this.scrollTop = this.scrollLeft = 0;
  14098. this.cantEdit = false;
  14099. this.cleanGeneration = 1;
  14100. this.modeFrontier = this.highlightFrontier = firstLine;
  14101. var start = Pos(firstLine, 0);
  14102. this.sel = simpleSelection(start);
  14103. this.history = new History(null);
  14104. this.id = ++nextDocId;
  14105. this.modeOption = mode;
  14106. this.lineSep = lineSep;
  14107. this.direction = (direction == "rtl") ? "rtl" : "ltr";
  14108. this.extend = false;
  14109. if (typeof text == "string") { text = this.splitLines(text); }
  14110. updateDoc(this, {from: start, to: start, text: text});
  14111. setSelection(this, simpleSelection(start), sel_dontScroll);
  14112. };
  14113. Doc.prototype = createObj(BranchChunk.prototype, {
  14114. constructor: Doc,
  14115. // Iterate over the document. Supports two forms -- with only one
  14116. // argument, it calls that for each line in the document. With
  14117. // three, it iterates over the range given by the first two (with
  14118. // the second being non-inclusive).
  14119. iter: function(from, to, op) {
  14120. if (op) { this.iterN(from - this.first, to - from, op); }
  14121. else { this.iterN(this.first, this.first + this.size, from); }
  14122. },
  14123. // Non-public interface for adding and removing lines.
  14124. insert: function(at, lines) {
  14125. var height = 0;
  14126. for (var i = 0; i < lines.length; ++i) { height += lines[i].height; }
  14127. this.insertInner(at - this.first, lines, height);
  14128. },
  14129. remove: function(at, n) { this.removeInner(at - this.first, n); },
  14130. // From here, the methods are part of the public interface. Most
  14131. // are also available from CodeMirror (editor) instances.
  14132. getValue: function(lineSep) {
  14133. var lines = getLines(this, this.first, this.first + this.size);
  14134. if (lineSep === false) { return lines }
  14135. return lines.join(lineSep || this.lineSeparator())
  14136. },
  14137. setValue: docMethodOp(function(code) {
  14138. var top = Pos(this.first, 0), last = this.first + this.size - 1;
  14139. makeChange(this, {from: top, to: Pos(last, getLine(this, last).text.length),
  14140. text: this.splitLines(code), origin: "setValue", full: true}, true);
  14141. if (this.cm) { scrollToCoords(this.cm, 0, 0); }
  14142. setSelection(this, simpleSelection(top), sel_dontScroll);
  14143. }),
  14144. replaceRange: function(code, from, to, origin) {
  14145. from = clipPos(this, from);
  14146. to = to ? clipPos(this, to) : from;
  14147. replaceRange(this, code, from, to, origin);
  14148. },
  14149. getRange: function(from, to, lineSep) {
  14150. var lines = getBetween(this, clipPos(this, from), clipPos(this, to));
  14151. if (lineSep === false) { return lines }
  14152. return lines.join(lineSep || this.lineSeparator())
  14153. },
  14154. getLine: function(line) {var l = this.getLineHandle(line); return l && l.text},
  14155. getLineHandle: function(line) {if (isLine(this, line)) { return getLine(this, line) }},
  14156. getLineNumber: function(line) {return lineNo(line)},
  14157. getLineHandleVisualStart: function(line) {
  14158. if (typeof line == "number") { line = getLine(this, line); }
  14159. return visualLine(line)
  14160. },
  14161. lineCount: function() {return this.size},
  14162. firstLine: function() {return this.first},
  14163. lastLine: function() {return this.first + this.size - 1},
  14164. clipPos: function(pos) {return clipPos(this, pos)},
  14165. getCursor: function(start) {
  14166. var range$$1 = this.sel.primary(), pos;
  14167. if (start == null || start == "head") { pos = range$$1.head; }
  14168. else if (start == "anchor") { pos = range$$1.anchor; }
  14169. else if (start == "end" || start == "to" || start === false) { pos = range$$1.to(); }
  14170. else { pos = range$$1.from(); }
  14171. return pos
  14172. },
  14173. listSelections: function() { return this.sel.ranges },
  14174. somethingSelected: function() {return this.sel.somethingSelected()},
  14175. setCursor: docMethodOp(function(line, ch, options) {
  14176. setSimpleSelection(this, clipPos(this, typeof line == "number" ? Pos(line, ch || 0) : line), null, options);
  14177. }),
  14178. setSelection: docMethodOp(function(anchor, head, options) {
  14179. setSimpleSelection(this, clipPos(this, anchor), clipPos(this, head || anchor), options);
  14180. }),
  14181. extendSelection: docMethodOp(function(head, other, options) {
  14182. extendSelection(this, clipPos(this, head), other && clipPos(this, other), options);
  14183. }),
  14184. extendSelections: docMethodOp(function(heads, options) {
  14185. extendSelections(this, clipPosArray(this, heads), options);
  14186. }),
  14187. extendSelectionsBy: docMethodOp(function(f, options) {
  14188. var heads = map(this.sel.ranges, f);
  14189. extendSelections(this, clipPosArray(this, heads), options);
  14190. }),
  14191. setSelections: docMethodOp(function(ranges, primary, options) {
  14192. var this$1 = this;
  14193. if (!ranges.length) { return }
  14194. var out = [];
  14195. for (var i = 0; i < ranges.length; i++)
  14196. { out[i] = new Range(clipPos(this$1, ranges[i].anchor),
  14197. clipPos(this$1, ranges[i].head)); }
  14198. if (primary == null) { primary = Math.min(ranges.length - 1, this.sel.primIndex); }
  14199. setSelection(this, normalizeSelection(out, primary), options);
  14200. }),
  14201. addSelection: docMethodOp(function(anchor, head, options) {
  14202. var ranges = this.sel.ranges.slice(0);
  14203. ranges.push(new Range(clipPos(this, anchor), clipPos(this, head || anchor)));
  14204. setSelection(this, normalizeSelection(ranges, ranges.length - 1), options);
  14205. }),
  14206. getSelection: function(lineSep) {
  14207. var this$1 = this;
  14208. var ranges = this.sel.ranges, lines;
  14209. for (var i = 0; i < ranges.length; i++) {
  14210. var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());
  14211. lines = lines ? lines.concat(sel) : sel;
  14212. }
  14213. if (lineSep === false) { return lines }
  14214. else { return lines.join(lineSep || this.lineSeparator()) }
  14215. },
  14216. getSelections: function(lineSep) {
  14217. var this$1 = this;
  14218. var parts = [], ranges = this.sel.ranges;
  14219. for (var i = 0; i < ranges.length; i++) {
  14220. var sel = getBetween(this$1, ranges[i].from(), ranges[i].to());
  14221. if (lineSep !== false) { sel = sel.join(lineSep || this$1.lineSeparator()); }
  14222. parts[i] = sel;
  14223. }
  14224. return parts
  14225. },
  14226. replaceSelection: function(code, collapse, origin) {
  14227. var dup = [];
  14228. for (var i = 0; i < this.sel.ranges.length; i++)
  14229. { dup[i] = code; }
  14230. this.replaceSelections(dup, collapse, origin || "+input");
  14231. },
  14232. replaceSelections: docMethodOp(function(code, collapse, origin) {
  14233. var this$1 = this;
  14234. var changes = [], sel = this.sel;
  14235. for (var i = 0; i < sel.ranges.length; i++) {
  14236. var range$$1 = sel.ranges[i];
  14237. changes[i] = {from: range$$1.from(), to: range$$1.to(), text: this$1.splitLines(code[i]), origin: origin};
  14238. }
  14239. var newSel = collapse && collapse != "end" && computeReplacedSel(this, changes, collapse);
  14240. for (var i$1 = changes.length - 1; i$1 >= 0; i$1--)
  14241. { makeChange(this$1, changes[i$1]); }
  14242. if (newSel) { setSelectionReplaceHistory(this, newSel); }
  14243. else if (this.cm) { ensureCursorVisible(this.cm); }
  14244. }),
  14245. undo: docMethodOp(function() {makeChangeFromHistory(this, "undo");}),
  14246. redo: docMethodOp(function() {makeChangeFromHistory(this, "redo");}),
  14247. undoSelection: docMethodOp(function() {makeChangeFromHistory(this, "undo", true);}),
  14248. redoSelection: docMethodOp(function() {makeChangeFromHistory(this, "redo", true);}),
  14249. setExtending: function(val) {this.extend = val;},
  14250. getExtending: function() {return this.extend},
  14251. historySize: function() {
  14252. var hist = this.history, done = 0, undone = 0;
  14253. for (var i = 0; i < hist.done.length; i++) { if (!hist.done[i].ranges) { ++done; } }
  14254. for (var i$1 = 0; i$1 < hist.undone.length; i$1++) { if (!hist.undone[i$1].ranges) { ++undone; } }
  14255. return {undo: done, redo: undone}
  14256. },
  14257. clearHistory: function() {this.history = new History(this.history.maxGeneration);},
  14258. markClean: function() {
  14259. this.cleanGeneration = this.changeGeneration(true);
  14260. },
  14261. changeGeneration: function(forceSplit) {
  14262. if (forceSplit)
  14263. { this.history.lastOp = this.history.lastSelOp = this.history.lastOrigin = null; }
  14264. return this.history.generation
  14265. },
  14266. isClean: function (gen) {
  14267. return this.history.generation == (gen || this.cleanGeneration)
  14268. },
  14269. getHistory: function() {
  14270. return {done: copyHistoryArray(this.history.done),
  14271. undone: copyHistoryArray(this.history.undone)}
  14272. },
  14273. setHistory: function(histData) {
  14274. var hist = this.history = new History(this.history.maxGeneration);
  14275. hist.done = copyHistoryArray(histData.done.slice(0), null, true);
  14276. hist.undone = copyHistoryArray(histData.undone.slice(0), null, true);
  14277. },
  14278. setGutterMarker: docMethodOp(function(line, gutterID, value) {
  14279. return changeLine(this, line, "gutter", function (line) {
  14280. var markers = line.gutterMarkers || (line.gutterMarkers = {});
  14281. markers[gutterID] = value;
  14282. if (!value && isEmpty(markers)) { line.gutterMarkers = null; }
  14283. return true
  14284. })
  14285. }),
  14286. clearGutter: docMethodOp(function(gutterID) {
  14287. var this$1 = this;
  14288. this.iter(function (line) {
  14289. if (line.gutterMarkers && line.gutterMarkers[gutterID]) {
  14290. changeLine(this$1, line, "gutter", function () {
  14291. line.gutterMarkers[gutterID] = null;
  14292. if (isEmpty(line.gutterMarkers)) { line.gutterMarkers = null; }
  14293. return true
  14294. });
  14295. }
  14296. });
  14297. }),
  14298. lineInfo: function(line) {
  14299. var n;
  14300. if (typeof line == "number") {
  14301. if (!isLine(this, line)) { return null }
  14302. n = line;
  14303. line = getLine(this, line);
  14304. if (!line) { return null }
  14305. } else {
  14306. n = lineNo(line);
  14307. if (n == null) { return null }
  14308. }
  14309. return {line: n, handle: line, text: line.text, gutterMarkers: line.gutterMarkers,
  14310. textClass: line.textClass, bgClass: line.bgClass, wrapClass: line.wrapClass,
  14311. widgets: line.widgets}
  14312. },
  14313. addLineClass: docMethodOp(function(handle, where, cls) {
  14314. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  14315. var prop = where == "text" ? "textClass"
  14316. : where == "background" ? "bgClass"
  14317. : where == "gutter" ? "gutterClass" : "wrapClass";
  14318. if (!line[prop]) { line[prop] = cls; }
  14319. else if (classTest(cls).test(line[prop])) { return false }
  14320. else { line[prop] += " " + cls; }
  14321. return true
  14322. })
  14323. }),
  14324. removeLineClass: docMethodOp(function(handle, where, cls) {
  14325. return changeLine(this, handle, where == "gutter" ? "gutter" : "class", function (line) {
  14326. var prop = where == "text" ? "textClass"
  14327. : where == "background" ? "bgClass"
  14328. : where == "gutter" ? "gutterClass" : "wrapClass";
  14329. var cur = line[prop];
  14330. if (!cur) { return false }
  14331. else if (cls == null) { line[prop] = null; }
  14332. else {
  14333. var found = cur.match(classTest(cls));
  14334. if (!found) { return false }
  14335. var end = found.index + found[0].length;
  14336. line[prop] = cur.slice(0, found.index) + (!found.index || end == cur.length ? "" : " ") + cur.slice(end) || null;
  14337. }
  14338. return true
  14339. })
  14340. }),
  14341. addLineWidget: docMethodOp(function(handle, node, options) {
  14342. return addLineWidget(this, handle, node, options)
  14343. }),
  14344. removeLineWidget: function(widget) { widget.clear(); },
  14345. markText: function(from, to, options) {
  14346. return markText(this, clipPos(this, from), clipPos(this, to), options, options && options.type || "range")
  14347. },
  14348. setBookmark: function(pos, options) {
  14349. var realOpts = {replacedWith: options && (options.nodeType == null ? options.widget : options),
  14350. insertLeft: options && options.insertLeft,
  14351. clearWhenEmpty: false, shared: options && options.shared,
  14352. handleMouseEvents: options && options.handleMouseEvents};
  14353. pos = clipPos(this, pos);
  14354. return markText(this, pos, pos, realOpts, "bookmark")
  14355. },
  14356. findMarksAt: function(pos) {
  14357. pos = clipPos(this, pos);
  14358. var markers = [], spans = getLine(this, pos.line).markedSpans;
  14359. if (spans) { for (var i = 0; i < spans.length; ++i) {
  14360. var span = spans[i];
  14361. if ((span.from == null || span.from <= pos.ch) &&
  14362. (span.to == null || span.to >= pos.ch))
  14363. { markers.push(span.marker.parent || span.marker); }
  14364. } }
  14365. return markers
  14366. },
  14367. findMarks: function(from, to, filter) {
  14368. from = clipPos(this, from); to = clipPos(this, to);
  14369. var found = [], lineNo$$1 = from.line;
  14370. this.iter(from.line, to.line + 1, function (line) {
  14371. var spans = line.markedSpans;
  14372. if (spans) { for (var i = 0; i < spans.length; i++) {
  14373. var span = spans[i];
  14374. if (!(span.to != null && lineNo$$1 == from.line && from.ch >= span.to ||
  14375. span.from == null && lineNo$$1 != from.line ||
  14376. span.from != null && lineNo$$1 == to.line && span.from >= to.ch) &&
  14377. (!filter || filter(span.marker)))
  14378. { found.push(span.marker.parent || span.marker); }
  14379. } }
  14380. ++lineNo$$1;
  14381. });
  14382. return found
  14383. },
  14384. getAllMarks: function() {
  14385. var markers = [];
  14386. this.iter(function (line) {
  14387. var sps = line.markedSpans;
  14388. if (sps) { for (var i = 0; i < sps.length; ++i)
  14389. { if (sps[i].from != null) { markers.push(sps[i].marker); } } }
  14390. });
  14391. return markers
  14392. },
  14393. posFromIndex: function(off) {
  14394. var ch, lineNo$$1 = this.first, sepSize = this.lineSeparator().length;
  14395. this.iter(function (line) {
  14396. var sz = line.text.length + sepSize;
  14397. if (sz > off) { ch = off; return true }
  14398. off -= sz;
  14399. ++lineNo$$1;
  14400. });
  14401. return clipPos(this, Pos(lineNo$$1, ch))
  14402. },
  14403. indexFromPos: function (coords) {
  14404. coords = clipPos(this, coords);
  14405. var index = coords.ch;
  14406. if (coords.line < this.first || coords.ch < 0) { return 0 }
  14407. var sepSize = this.lineSeparator().length;
  14408. this.iter(this.first, coords.line, function (line) { // iter aborts when callback returns a truthy value
  14409. index += line.text.length + sepSize;
  14410. });
  14411. return index
  14412. },
  14413. copy: function(copyHistory) {
  14414. var doc = new Doc(getLines(this, this.first, this.first + this.size),
  14415. this.modeOption, this.first, this.lineSep, this.direction);
  14416. doc.scrollTop = this.scrollTop; doc.scrollLeft = this.scrollLeft;
  14417. doc.sel = this.sel;
  14418. doc.extend = false;
  14419. if (copyHistory) {
  14420. doc.history.undoDepth = this.history.undoDepth;
  14421. doc.setHistory(this.getHistory());
  14422. }
  14423. return doc
  14424. },
  14425. linkedDoc: function(options) {
  14426. if (!options) { options = {}; }
  14427. var from = this.first, to = this.first + this.size;
  14428. if (options.from != null && options.from > from) { from = options.from; }
  14429. if (options.to != null && options.to < to) { to = options.to; }
  14430. var copy = new Doc(getLines(this, from, to), options.mode || this.modeOption, from, this.lineSep, this.direction);
  14431. if (options.sharedHist) { copy.history = this.history
  14432. ; }(this.linked || (this.linked = [])).push({doc: copy, sharedHist: options.sharedHist});
  14433. copy.linked = [{doc: this, isParent: true, sharedHist: options.sharedHist}];
  14434. copySharedMarkers(copy, findSharedMarkers(this));
  14435. return copy
  14436. },
  14437. unlinkDoc: function(other) {
  14438. var this$1 = this;
  14439. if (other instanceof CodeMirror$1) { other = other.doc; }
  14440. if (this.linked) { for (var i = 0; i < this.linked.length; ++i) {
  14441. var link = this$1.linked[i];
  14442. if (link.doc != other) { continue }
  14443. this$1.linked.splice(i, 1);
  14444. other.unlinkDoc(this$1);
  14445. detachSharedMarkers(findSharedMarkers(this$1));
  14446. break
  14447. } }
  14448. // If the histories were shared, split them again
  14449. if (other.history == this.history) {
  14450. var splitIds = [other.id];
  14451. linkedDocs(other, function (doc) { return splitIds.push(doc.id); }, true);
  14452. other.history = new History(null);
  14453. other.history.done = copyHistoryArray(this.history.done, splitIds);
  14454. other.history.undone = copyHistoryArray(this.history.undone, splitIds);
  14455. }
  14456. },
  14457. iterLinkedDocs: function(f) {linkedDocs(this, f);},
  14458. getMode: function() {return this.mode},
  14459. getEditor: function() {return this.cm},
  14460. splitLines: function(str) {
  14461. if (this.lineSep) { return str.split(this.lineSep) }
  14462. return splitLinesAuto(str)
  14463. },
  14464. lineSeparator: function() { return this.lineSep || "\n" },
  14465. setDirection: docMethodOp(function (dir) {
  14466. if (dir != "rtl") { dir = "ltr"; }
  14467. if (dir == this.direction) { return }
  14468. this.direction = dir;
  14469. this.iter(function (line) { return line.order = null; });
  14470. if (this.cm) { directionChanged(this.cm); }
  14471. })
  14472. });
  14473. // Public alias.
  14474. Doc.prototype.eachLine = Doc.prototype.iter;
  14475. // Kludge to work around strange IE behavior where it'll sometimes
  14476. // re-fire a series of drag-related events right after the drop (#1551)
  14477. var lastDrop = 0;
  14478. function onDrop(e) {
  14479. var cm = this;
  14480. clearDragCursor(cm);
  14481. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e))
  14482. { return }
  14483. e_preventDefault(e);
  14484. if (ie) { lastDrop = +new Date; }
  14485. var pos = posFromMouse(cm, e, true), files = e.dataTransfer.files;
  14486. if (!pos || cm.isReadOnly()) { return }
  14487. // Might be a file drop, in which case we simply extract the text
  14488. // and insert it.
  14489. if (files && files.length && window.FileReader && window.File) {
  14490. var n = files.length, text = Array(n), read = 0;
  14491. var loadFile = function (file, i) {
  14492. if (cm.options.allowDropFileTypes &&
  14493. indexOf(cm.options.allowDropFileTypes, file.type) == -1)
  14494. { return }
  14495. var reader = new FileReader;
  14496. reader.onload = operation(cm, function () {
  14497. var content = reader.result;
  14498. if (/[\x00-\x08\x0e-\x1f]{2}/.test(content)) { content = ""; }
  14499. text[i] = content;
  14500. if (++read == n) {
  14501. pos = clipPos(cm.doc, pos);
  14502. var change = {from: pos, to: pos,
  14503. text: cm.doc.splitLines(text.join(cm.doc.lineSeparator())),
  14504. origin: "paste"};
  14505. makeChange(cm.doc, change);
  14506. setSelectionReplaceHistory(cm.doc, simpleSelection(pos, changeEnd(change)));
  14507. }
  14508. });
  14509. reader.readAsText(file);
  14510. };
  14511. for (var i = 0; i < n; ++i) { loadFile(files[i], i); }
  14512. } else { // Normal drop
  14513. // Don't do a replace if the drop happened inside of the selected text.
  14514. if (cm.state.draggingText && cm.doc.sel.contains(pos) > -1) {
  14515. cm.state.draggingText(e);
  14516. // Ensure the editor is re-focused
  14517. setTimeout(function () { return cm.display.input.focus(); }, 20);
  14518. return
  14519. }
  14520. try {
  14521. var text$1 = e.dataTransfer.getData("Text");
  14522. if (text$1) {
  14523. var selected;
  14524. if (cm.state.draggingText && !cm.state.draggingText.copy)
  14525. { selected = cm.listSelections(); }
  14526. setSelectionNoUndo(cm.doc, simpleSelection(pos, pos));
  14527. if (selected) { for (var i$1 = 0; i$1 < selected.length; ++i$1)
  14528. { replaceRange(cm.doc, "", selected[i$1].anchor, selected[i$1].head, "drag"); } }
  14529. cm.replaceSelection(text$1, "around", "paste");
  14530. cm.display.input.focus();
  14531. }
  14532. }
  14533. catch(e){}
  14534. }
  14535. }
  14536. function onDragStart(cm, e) {
  14537. if (ie && (!cm.state.draggingText || +new Date - lastDrop < 100)) { e_stop(e); return }
  14538. if (signalDOMEvent(cm, e) || eventInWidget(cm.display, e)) { return }
  14539. e.dataTransfer.setData("Text", cm.getSelection());
  14540. e.dataTransfer.effectAllowed = "copyMove";
  14541. // Use dummy image instead of default browsers image.
  14542. // Recent Safari (~6.0.2) have a tendency to segfault when this happens, so we don't do it there.
  14543. if (e.dataTransfer.setDragImage && !safari) {
  14544. var img = elt("img", null, null, "position: fixed; left: 0; top: 0;");
  14545. img.src = "data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==";
  14546. if (presto) {
  14547. img.width = img.height = 1;
  14548. cm.display.wrapper.appendChild(img);
  14549. // Force a relayout, or Opera won't use our image for some obscure reason
  14550. img._top = img.offsetTop;
  14551. }
  14552. e.dataTransfer.setDragImage(img, 0, 0);
  14553. if (presto) { img.parentNode.removeChild(img); }
  14554. }
  14555. }
  14556. function onDragOver(cm, e) {
  14557. var pos = posFromMouse(cm, e);
  14558. if (!pos) { return }
  14559. var frag = document.createDocumentFragment();
  14560. drawSelectionCursor(cm, pos, frag);
  14561. if (!cm.display.dragCursor) {
  14562. cm.display.dragCursor = elt("div", null, "CodeMirror-cursors CodeMirror-dragcursors");
  14563. cm.display.lineSpace.insertBefore(cm.display.dragCursor, cm.display.cursorDiv);
  14564. }
  14565. removeChildrenAndAdd(cm.display.dragCursor, frag);
  14566. }
  14567. function clearDragCursor(cm) {
  14568. if (cm.display.dragCursor) {
  14569. cm.display.lineSpace.removeChild(cm.display.dragCursor);
  14570. cm.display.dragCursor = null;
  14571. }
  14572. }
  14573. // These must be handled carefully, because naively registering a
  14574. // handler for each editor will cause the editors to never be
  14575. // garbage collected.
  14576. function forEachCodeMirror(f) {
  14577. if (!document.getElementsByClassName) { return }
  14578. var byClass = document.getElementsByClassName("CodeMirror");
  14579. for (var i = 0; i < byClass.length; i++) {
  14580. var cm = byClass[i].CodeMirror;
  14581. if (cm) { f(cm); }
  14582. }
  14583. }
  14584. var globalsRegistered = false;
  14585. function ensureGlobalHandlers() {
  14586. if (globalsRegistered) { return }
  14587. registerGlobalHandlers();
  14588. globalsRegistered = true;
  14589. }
  14590. function registerGlobalHandlers() {
  14591. // When the window resizes, we need to refresh active editors.
  14592. var resizeTimer;
  14593. on(window, "resize", function () {
  14594. if (resizeTimer == null) { resizeTimer = setTimeout(function () {
  14595. resizeTimer = null;
  14596. forEachCodeMirror(onResize);
  14597. }, 100); }
  14598. });
  14599. // When the window loses focus, we want to show the editor as blurred
  14600. on(window, "blur", function () { return forEachCodeMirror(onBlur); });
  14601. }
  14602. // Called when the window resizes
  14603. function onResize(cm) {
  14604. var d = cm.display;
  14605. if (d.lastWrapHeight == d.wrapper.clientHeight && d.lastWrapWidth == d.wrapper.clientWidth)
  14606. { return }
  14607. // Might be a text scaling operation, clear size caches.
  14608. d.cachedCharWidth = d.cachedTextHeight = d.cachedPaddingH = null;
  14609. d.scrollbarsClipped = false;
  14610. cm.setSize();
  14611. }
  14612. var keyNames = {
  14613. 3: "Pause", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
  14614. 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
  14615. 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
  14616. 46: "Delete", 59: ";", 61: "=", 91: "Mod", 92: "Mod", 93: "Mod",
  14617. 106: "*", 107: "=", 109: "-", 110: ".", 111: "/", 127: "Delete", 145: "ScrollLock",
  14618. 173: "-", 186: ";", 187: "=", 188: ",", 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\",
  14619. 221: "]", 222: "'", 63232: "Up", 63233: "Down", 63234: "Left", 63235: "Right", 63272: "Delete",
  14620. 63273: "Home", 63275: "End", 63276: "PageUp", 63277: "PageDown", 63302: "Insert"
  14621. };
  14622. // Number keys
  14623. for (var i = 0; i < 10; i++) { keyNames[i + 48] = keyNames[i + 96] = String(i); }
  14624. // Alphabetic keys
  14625. for (var i$1 = 65; i$1 <= 90; i$1++) { keyNames[i$1] = String.fromCharCode(i$1); }
  14626. // Function keys
  14627. for (var i$2 = 1; i$2 <= 12; i$2++) { keyNames[i$2 + 111] = keyNames[i$2 + 63235] = "F" + i$2; }
  14628. var keyMap = {};
  14629. keyMap.basic = {
  14630. "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
  14631. "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
  14632. "Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
  14633. "Tab": "defaultTab", "Shift-Tab": "indentAuto",
  14634. "Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
  14635. "Esc": "singleSelection"
  14636. };
  14637. // Note that the save and find-related commands aren't defined by
  14638. // default. User code or addons can define them. Unknown commands
  14639. // are simply ignored.
  14640. keyMap.pcDefault = {
  14641. "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
  14642. "Ctrl-Home": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Up": "goLineUp", "Ctrl-Down": "goLineDown",
  14643. "Ctrl-Left": "goGroupLeft", "Ctrl-Right": "goGroupRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
  14644. "Ctrl-Backspace": "delGroupBefore", "Ctrl-Delete": "delGroupAfter", "Ctrl-S": "save", "Ctrl-F": "find",
  14645. "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
  14646. "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
  14647. "Ctrl-U": "undoSelection", "Shift-Ctrl-U": "redoSelection", "Alt-U": "redoSelection",
  14648. fallthrough: "basic"
  14649. };
  14650. // Very basic readline/emacs-style bindings, which are standard on Mac.
  14651. keyMap.emacsy = {
  14652. "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
  14653. "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
  14654. "Ctrl-V": "goPageDown", "Shift-Ctrl-V": "goPageUp", "Ctrl-D": "delCharAfter", "Ctrl-H": "delCharBefore",
  14655. "Alt-D": "delWordAfter", "Alt-Backspace": "delWordBefore", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars",
  14656. "Ctrl-O": "openLine"
  14657. };
  14658. keyMap.macDefault = {
  14659. "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
  14660. "Cmd-Home": "goDocStart", "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goGroupLeft",
  14661. "Alt-Right": "goGroupRight", "Cmd-Left": "goLineLeft", "Cmd-Right": "goLineRight", "Alt-Backspace": "delGroupBefore",
  14662. "Ctrl-Alt-Backspace": "delGroupAfter", "Alt-Delete": "delGroupAfter", "Cmd-S": "save", "Cmd-F": "find",
  14663. "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
  14664. "Cmd-[": "indentLess", "Cmd-]": "indentMore", "Cmd-Backspace": "delWrappedLineLeft", "Cmd-Delete": "delWrappedLineRight",
  14665. "Cmd-U": "undoSelection", "Shift-Cmd-U": "redoSelection", "Ctrl-Up": "goDocStart", "Ctrl-Down": "goDocEnd",
  14666. fallthrough: ["basic", "emacsy"]
  14667. };
  14668. keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
  14669. // KEYMAP DISPATCH
  14670. function normalizeKeyName(name) {
  14671. var parts = name.split(/-(?!$)/);
  14672. name = parts[parts.length - 1];
  14673. var alt, ctrl, shift, cmd;
  14674. for (var i = 0; i < parts.length - 1; i++) {
  14675. var mod = parts[i];
  14676. if (/^(cmd|meta|m)$/i.test(mod)) { cmd = true; }
  14677. else if (/^a(lt)?$/i.test(mod)) { alt = true; }
  14678. else if (/^(c|ctrl|control)$/i.test(mod)) { ctrl = true; }
  14679. else if (/^s(hift)?$/i.test(mod)) { shift = true; }
  14680. else { throw new Error("Unrecognized modifier name: " + mod) }
  14681. }
  14682. if (alt) { name = "Alt-" + name; }
  14683. if (ctrl) { name = "Ctrl-" + name; }
  14684. if (cmd) { name = "Cmd-" + name; }
  14685. if (shift) { name = "Shift-" + name; }
  14686. return name
  14687. }
  14688. // This is a kludge to keep keymaps mostly working as raw objects
  14689. // (backwards compatibility) while at the same time support features
  14690. // like normalization and multi-stroke key bindings. It compiles a
  14691. // new normalized keymap, and then updates the old object to reflect
  14692. // this.
  14693. function normalizeKeyMap(keymap) {
  14694. var copy = {};
  14695. for (var keyname in keymap) { if (keymap.hasOwnProperty(keyname)) {
  14696. var value = keymap[keyname];
  14697. if (/^(name|fallthrough|(de|at)tach)$/.test(keyname)) { continue }
  14698. if (value == "...") { delete keymap[keyname]; continue }
  14699. var keys = map(keyname.split(" "), normalizeKeyName);
  14700. for (var i = 0; i < keys.length; i++) {
  14701. var val = (void 0), name = (void 0);
  14702. if (i == keys.length - 1) {
  14703. name = keys.join(" ");
  14704. val = value;
  14705. } else {
  14706. name = keys.slice(0, i + 1).join(" ");
  14707. val = "...";
  14708. }
  14709. var prev = copy[name];
  14710. if (!prev) { copy[name] = val; }
  14711. else if (prev != val) { throw new Error("Inconsistent bindings for " + name) }
  14712. }
  14713. delete keymap[keyname];
  14714. } }
  14715. for (var prop in copy) { keymap[prop] = copy[prop]; }
  14716. return keymap
  14717. }
  14718. function lookupKey(key, map$$1, handle, context) {
  14719. map$$1 = getKeyMap(map$$1);
  14720. var found = map$$1.call ? map$$1.call(key, context) : map$$1[key];
  14721. if (found === false) { return "nothing" }
  14722. if (found === "...") { return "multi" }
  14723. if (found != null && handle(found)) { return "handled" }
  14724. if (map$$1.fallthrough) {
  14725. if (Object.prototype.toString.call(map$$1.fallthrough) != "[object Array]")
  14726. { return lookupKey(key, map$$1.fallthrough, handle, context) }
  14727. for (var i = 0; i < map$$1.fallthrough.length; i++) {
  14728. var result = lookupKey(key, map$$1.fallthrough[i], handle, context);
  14729. if (result) { return result }
  14730. }
  14731. }
  14732. }
  14733. // Modifier key presses don't count as 'real' key presses for the
  14734. // purpose of keymap fallthrough.
  14735. function isModifierKey(value) {
  14736. var name = typeof value == "string" ? value : keyNames[value.keyCode];
  14737. return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod"
  14738. }
  14739. function addModifierNames(name, event, noShift) {
  14740. var base = name;
  14741. if (event.altKey && base != "Alt") { name = "Alt-" + name; }
  14742. if ((flipCtrlCmd ? event.metaKey : event.ctrlKey) && base != "Ctrl") { name = "Ctrl-" + name; }
  14743. if ((flipCtrlCmd ? event.ctrlKey : event.metaKey) && base != "Cmd") { name = "Cmd-" + name; }
  14744. if (!noShift && event.shiftKey && base != "Shift") { name = "Shift-" + name; }
  14745. return name
  14746. }
  14747. // Look up the name of a key as indicated by an event object.
  14748. function keyName(event, noShift) {
  14749. if (presto && event.keyCode == 34 && event["char"]) { return false }
  14750. var name = keyNames[event.keyCode];
  14751. if (name == null || event.altGraphKey) { return false }
  14752. // Ctrl-ScrollLock has keyCode 3, same as Ctrl-Pause,
  14753. // so we'll use event.code when available (Chrome 48+, FF 38+, Safari 10.1+)
  14754. if (event.keyCode == 3 && event.code) { name = event.code; }
  14755. return addModifierNames(name, event, noShift)
  14756. }
  14757. function getKeyMap(val) {
  14758. return typeof val == "string" ? keyMap[val] : val
  14759. }
  14760. // Helper for deleting text near the selection(s), used to implement
  14761. // backspace, delete, and similar functionality.
  14762. function deleteNearSelection(cm, compute) {
  14763. var ranges = cm.doc.sel.ranges, kill = [];
  14764. // Build up a set of ranges to kill first, merging overlapping
  14765. // ranges.
  14766. for (var i = 0; i < ranges.length; i++) {
  14767. var toKill = compute(ranges[i]);
  14768. while (kill.length && cmp(toKill.from, lst(kill).to) <= 0) {
  14769. var replaced = kill.pop();
  14770. if (cmp(replaced.from, toKill.from) < 0) {
  14771. toKill.from = replaced.from;
  14772. break
  14773. }
  14774. }
  14775. kill.push(toKill);
  14776. }
  14777. // Next, remove those actual ranges.
  14778. runInOp(cm, function () {
  14779. for (var i = kill.length - 1; i >= 0; i--)
  14780. { replaceRange(cm.doc, "", kill[i].from, kill[i].to, "+delete"); }
  14781. ensureCursorVisible(cm);
  14782. });
  14783. }
  14784. function moveCharLogically(line, ch, dir) {
  14785. var target = skipExtendingChars(line.text, ch + dir, dir);
  14786. return target < 0 || target > line.text.length ? null : target
  14787. }
  14788. function moveLogically(line, start, dir) {
  14789. var ch = moveCharLogically(line, start.ch, dir);
  14790. return ch == null ? null : new Pos(start.line, ch, dir < 0 ? "after" : "before")
  14791. }
  14792. function endOfLine(visually, cm, lineObj, lineNo, dir) {
  14793. if (visually) {
  14794. var order = getOrder(lineObj, cm.doc.direction);
  14795. if (order) {
  14796. var part = dir < 0 ? lst(order) : order[0];
  14797. var moveInStorageOrder = (dir < 0) == (part.level == 1);
  14798. var sticky = moveInStorageOrder ? "after" : "before";
  14799. var ch;
  14800. // With a wrapped rtl chunk (possibly spanning multiple bidi parts),
  14801. // it could be that the last bidi part is not on the last visual line,
  14802. // since visual lines contain content order-consecutive chunks.
  14803. // Thus, in rtl, we are looking for the first (content-order) character
  14804. // in the rtl chunk that is on the last line (that is, the same line
  14805. // as the last (content-order) character).
  14806. if (part.level > 0 || cm.doc.direction == "rtl") {
  14807. var prep = prepareMeasureForLine(cm, lineObj);
  14808. ch = dir < 0 ? lineObj.text.length - 1 : 0;
  14809. var targetTop = measureCharPrepared(cm, prep, ch).top;
  14810. ch = findFirst(function (ch) { return measureCharPrepared(cm, prep, ch).top == targetTop; }, (dir < 0) == (part.level == 1) ? part.from : part.to - 1, ch);
  14811. if (sticky == "before") { ch = moveCharLogically(lineObj, ch, 1); }
  14812. } else { ch = dir < 0 ? part.to : part.from; }
  14813. return new Pos(lineNo, ch, sticky)
  14814. }
  14815. }
  14816. return new Pos(lineNo, dir < 0 ? lineObj.text.length : 0, dir < 0 ? "before" : "after")
  14817. }
  14818. function moveVisually(cm, line, start, dir) {
  14819. var bidi = getOrder(line, cm.doc.direction);
  14820. if (!bidi) { return moveLogically(line, start, dir) }
  14821. if (start.ch >= line.text.length) {
  14822. start.ch = line.text.length;
  14823. start.sticky = "before";
  14824. } else if (start.ch <= 0) {
  14825. start.ch = 0;
  14826. start.sticky = "after";
  14827. }
  14828. var partPos = getBidiPartAt(bidi, start.ch, start.sticky), part = bidi[partPos];
  14829. if (cm.doc.direction == "ltr" && part.level % 2 == 0 && (dir > 0 ? part.to > start.ch : part.from < start.ch)) {
  14830. // Case 1: We move within an ltr part in an ltr editor. Even with wrapped lines,
  14831. // nothing interesting happens.
  14832. return moveLogically(line, start, dir)
  14833. }
  14834. var mv = function (pos, dir) { return moveCharLogically(line, pos instanceof Pos ? pos.ch : pos, dir); };
  14835. var prep;
  14836. var getWrappedLineExtent = function (ch) {
  14837. if (!cm.options.lineWrapping) { return {begin: 0, end: line.text.length} }
  14838. prep = prep || prepareMeasureForLine(cm, line);
  14839. return wrappedLineExtentChar(cm, line, prep, ch)
  14840. };
  14841. var wrappedLineExtent = getWrappedLineExtent(start.sticky == "before" ? mv(start, -1) : start.ch);
  14842. if (cm.doc.direction == "rtl" || part.level == 1) {
  14843. var moveInStorageOrder = (part.level == 1) == (dir < 0);
  14844. var ch = mv(start, moveInStorageOrder ? 1 : -1);
  14845. if (ch != null && (!moveInStorageOrder ? ch >= part.from && ch >= wrappedLineExtent.begin : ch <= part.to && ch <= wrappedLineExtent.end)) {
  14846. // Case 2: We move within an rtl part or in an rtl editor on the same visual line
  14847. var sticky = moveInStorageOrder ? "before" : "after";
  14848. return new Pos(start.line, ch, sticky)
  14849. }
  14850. }
  14851. // Case 3: Could not move within this bidi part in this visual line, so leave
  14852. // the current bidi part
  14853. var searchInVisualLine = function (partPos, dir, wrappedLineExtent) {
  14854. var getRes = function (ch, moveInStorageOrder) { return moveInStorageOrder
  14855. ? new Pos(start.line, mv(ch, 1), "before")
  14856. : new Pos(start.line, ch, "after"); };
  14857. for (; partPos >= 0 && partPos < bidi.length; partPos += dir) {
  14858. var part = bidi[partPos];
  14859. var moveInStorageOrder = (dir > 0) == (part.level != 1);
  14860. var ch = moveInStorageOrder ? wrappedLineExtent.begin : mv(wrappedLineExtent.end, -1);
  14861. if (part.from <= ch && ch < part.to) { return getRes(ch, moveInStorageOrder) }
  14862. ch = moveInStorageOrder ? part.from : mv(part.to, -1);
  14863. if (wrappedLineExtent.begin <= ch && ch < wrappedLineExtent.end) { return getRes(ch, moveInStorageOrder) }
  14864. }
  14865. };
  14866. // Case 3a: Look for other bidi parts on the same visual line
  14867. var res = searchInVisualLine(partPos + dir, dir, wrappedLineExtent);
  14868. if (res) { return res }
  14869. // Case 3b: Look for other bidi parts on the next visual line
  14870. var nextCh = dir > 0 ? wrappedLineExtent.end : mv(wrappedLineExtent.begin, -1);
  14871. if (nextCh != null && !(dir > 0 && nextCh == line.text.length)) {
  14872. res = searchInVisualLine(dir > 0 ? 0 : bidi.length - 1, dir, getWrappedLineExtent(nextCh));
  14873. if (res) { return res }
  14874. }
  14875. // Case 4: Nowhere to move
  14876. return null
  14877. }
  14878. // Commands are parameter-less actions that can be performed on an
  14879. // editor, mostly used for keybindings.
  14880. var commands = {
  14881. selectAll: selectAll,
  14882. singleSelection: function (cm) { return cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"), sel_dontScroll); },
  14883. killLine: function (cm) { return deleteNearSelection(cm, function (range) {
  14884. if (range.empty()) {
  14885. var len = getLine(cm.doc, range.head.line).text.length;
  14886. if (range.head.ch == len && range.head.line < cm.lastLine())
  14887. { return {from: range.head, to: Pos(range.head.line + 1, 0)} }
  14888. else
  14889. { return {from: range.head, to: Pos(range.head.line, len)} }
  14890. } else {
  14891. return {from: range.from(), to: range.to()}
  14892. }
  14893. }); },
  14894. deleteLine: function (cm) { return deleteNearSelection(cm, function (range) { return ({
  14895. from: Pos(range.from().line, 0),
  14896. to: clipPos(cm.doc, Pos(range.to().line + 1, 0))
  14897. }); }); },
  14898. delLineLeft: function (cm) { return deleteNearSelection(cm, function (range) { return ({
  14899. from: Pos(range.from().line, 0), to: range.from()
  14900. }); }); },
  14901. delWrappedLineLeft: function (cm) { return deleteNearSelection(cm, function (range) {
  14902. var top = cm.charCoords(range.head, "div").top + 5;
  14903. var leftPos = cm.coordsChar({left: 0, top: top}, "div");
  14904. return {from: leftPos, to: range.from()}
  14905. }); },
  14906. delWrappedLineRight: function (cm) { return deleteNearSelection(cm, function (range) {
  14907. var top = cm.charCoords(range.head, "div").top + 5;
  14908. var rightPos = cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div");
  14909. return {from: range.from(), to: rightPos }
  14910. }); },
  14911. undo: function (cm) { return cm.undo(); },
  14912. redo: function (cm) { return cm.redo(); },
  14913. undoSelection: function (cm) { return cm.undoSelection(); },
  14914. redoSelection: function (cm) { return cm.redoSelection(); },
  14915. goDocStart: function (cm) { return cm.extendSelection(Pos(cm.firstLine(), 0)); },
  14916. goDocEnd: function (cm) { return cm.extendSelection(Pos(cm.lastLine())); },
  14917. goLineStart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStart(cm, range.head.line); },
  14918. {origin: "+move", bias: 1}
  14919. ); },
  14920. goLineStartSmart: function (cm) { return cm.extendSelectionsBy(function (range) { return lineStartSmart(cm, range.head); },
  14921. {origin: "+move", bias: 1}
  14922. ); },
  14923. goLineEnd: function (cm) { return cm.extendSelectionsBy(function (range) { return lineEnd(cm, range.head.line); },
  14924. {origin: "+move", bias: -1}
  14925. ); },
  14926. goLineRight: function (cm) { return cm.extendSelectionsBy(function (range) {
  14927. var top = cm.cursorCoords(range.head, "div").top + 5;
  14928. return cm.coordsChar({left: cm.display.lineDiv.offsetWidth + 100, top: top}, "div")
  14929. }, sel_move); },
  14930. goLineLeft: function (cm) { return cm.extendSelectionsBy(function (range) {
  14931. var top = cm.cursorCoords(range.head, "div").top + 5;
  14932. return cm.coordsChar({left: 0, top: top}, "div")
  14933. }, sel_move); },
  14934. goLineLeftSmart: function (cm) { return cm.extendSelectionsBy(function (range) {
  14935. var top = cm.cursorCoords(range.head, "div").top + 5;
  14936. var pos = cm.coordsChar({left: 0, top: top}, "div");
  14937. if (pos.ch < cm.getLine(pos.line).search(/\S/)) { return lineStartSmart(cm, range.head) }
  14938. return pos
  14939. }, sel_move); },
  14940. goLineUp: function (cm) { return cm.moveV(-1, "line"); },
  14941. goLineDown: function (cm) { return cm.moveV(1, "line"); },
  14942. goPageUp: function (cm) { return cm.moveV(-1, "page"); },
  14943. goPageDown: function (cm) { return cm.moveV(1, "page"); },
  14944. goCharLeft: function (cm) { return cm.moveH(-1, "char"); },
  14945. goCharRight: function (cm) { return cm.moveH(1, "char"); },
  14946. goColumnLeft: function (cm) { return cm.moveH(-1, "column"); },
  14947. goColumnRight: function (cm) { return cm.moveH(1, "column"); },
  14948. goWordLeft: function (cm) { return cm.moveH(-1, "word"); },
  14949. goGroupRight: function (cm) { return cm.moveH(1, "group"); },
  14950. goGroupLeft: function (cm) { return cm.moveH(-1, "group"); },
  14951. goWordRight: function (cm) { return cm.moveH(1, "word"); },
  14952. delCharBefore: function (cm) { return cm.deleteH(-1, "char"); },
  14953. delCharAfter: function (cm) { return cm.deleteH(1, "char"); },
  14954. delWordBefore: function (cm) { return cm.deleteH(-1, "word"); },
  14955. delWordAfter: function (cm) { return cm.deleteH(1, "word"); },
  14956. delGroupBefore: function (cm) { return cm.deleteH(-1, "group"); },
  14957. delGroupAfter: function (cm) { return cm.deleteH(1, "group"); },
  14958. indentAuto: function (cm) { return cm.indentSelection("smart"); },
  14959. indentMore: function (cm) { return cm.indentSelection("add"); },
  14960. indentLess: function (cm) { return cm.indentSelection("subtract"); },
  14961. insertTab: function (cm) { return cm.replaceSelection("\t"); },
  14962. insertSoftTab: function (cm) {
  14963. var spaces = [], ranges = cm.listSelections(), tabSize = cm.options.tabSize;
  14964. for (var i = 0; i < ranges.length; i++) {
  14965. var pos = ranges[i].from();
  14966. var col = countColumn(cm.getLine(pos.line), pos.ch, tabSize);
  14967. spaces.push(spaceStr(tabSize - col % tabSize));
  14968. }
  14969. cm.replaceSelections(spaces);
  14970. },
  14971. defaultTab: function (cm) {
  14972. if (cm.somethingSelected()) { cm.indentSelection("add"); }
  14973. else { cm.execCommand("insertTab"); }
  14974. },
  14975. // Swap the two chars left and right of each selection's head.
  14976. // Move cursor behind the two swapped characters afterwards.
  14977. //
  14978. // Doesn't consider line feeds a character.
  14979. // Doesn't scan more than one line above to find a character.
  14980. // Doesn't do anything on an empty line.
  14981. // Doesn't do anything with non-empty selections.
  14982. transposeChars: function (cm) { return runInOp(cm, function () {
  14983. var ranges = cm.listSelections(), newSel = [];
  14984. for (var i = 0; i < ranges.length; i++) {
  14985. if (!ranges[i].empty()) { continue }
  14986. var cur = ranges[i].head, line = getLine(cm.doc, cur.line).text;
  14987. if (line) {
  14988. if (cur.ch == line.length) { cur = new Pos(cur.line, cur.ch - 1); }
  14989. if (cur.ch > 0) {
  14990. cur = new Pos(cur.line, cur.ch + 1);
  14991. cm.replaceRange(line.charAt(cur.ch - 1) + line.charAt(cur.ch - 2),
  14992. Pos(cur.line, cur.ch - 2), cur, "+transpose");
  14993. } else if (cur.line > cm.doc.first) {
  14994. var prev = getLine(cm.doc, cur.line - 1).text;
  14995. if (prev) {
  14996. cur = new Pos(cur.line, 1);
  14997. cm.replaceRange(line.charAt(0) + cm.doc.lineSeparator() +
  14998. prev.charAt(prev.length - 1),
  14999. Pos(cur.line - 1, prev.length - 1), cur, "+transpose");
  15000. }
  15001. }
  15002. }
  15003. newSel.push(new Range(cur, cur));
  15004. }
  15005. cm.setSelections(newSel);
  15006. }); },
  15007. newlineAndIndent: function (cm) { return runInOp(cm, function () {
  15008. var sels = cm.listSelections();
  15009. for (var i = sels.length - 1; i >= 0; i--)
  15010. { cm.replaceRange(cm.doc.lineSeparator(), sels[i].anchor, sels[i].head, "+input"); }
  15011. sels = cm.listSelections();
  15012. for (var i$1 = 0; i$1 < sels.length; i$1++)
  15013. { cm.indentLine(sels[i$1].from().line, null, true); }
  15014. ensureCursorVisible(cm);
  15015. }); },
  15016. openLine: function (cm) { return cm.replaceSelection("\n", "start"); },
  15017. toggleOverwrite: function (cm) { return cm.toggleOverwrite(); }
  15018. };
  15019. function lineStart(cm, lineN) {
  15020. var line = getLine(cm.doc, lineN);
  15021. var visual = visualLine(line);
  15022. if (visual != line) { lineN = lineNo(visual); }
  15023. return endOfLine(true, cm, visual, lineN, 1)
  15024. }
  15025. function lineEnd(cm, lineN) {
  15026. var line = getLine(cm.doc, lineN);
  15027. var visual = visualLineEnd(line);
  15028. if (visual != line) { lineN = lineNo(visual); }
  15029. return endOfLine(true, cm, line, lineN, -1)
  15030. }
  15031. function lineStartSmart(cm, pos) {
  15032. var start = lineStart(cm, pos.line);
  15033. var line = getLine(cm.doc, start.line);
  15034. var order = getOrder(line, cm.doc.direction);
  15035. if (!order || order[0].level == 0) {
  15036. var firstNonWS = Math.max(0, line.text.search(/\S/));
  15037. var inWS = pos.line == start.line && pos.ch <= firstNonWS && pos.ch;
  15038. return Pos(start.line, inWS ? 0 : firstNonWS, start.sticky)
  15039. }
  15040. return start
  15041. }
  15042. // Run a handler that was bound to a key.
  15043. function doHandleBinding(cm, bound, dropShift) {
  15044. if (typeof bound == "string") {
  15045. bound = commands[bound];
  15046. if (!bound) { return false }
  15047. }
  15048. // Ensure previous input has been read, so that the handler sees a
  15049. // consistent view of the document
  15050. cm.display.input.ensurePolled();
  15051. var prevShift = cm.display.shift, done = false;
  15052. try {
  15053. if (cm.isReadOnly()) { cm.state.suppressEdits = true; }
  15054. if (dropShift) { cm.display.shift = false; }
  15055. done = bound(cm) != Pass;
  15056. } finally {
  15057. cm.display.shift = prevShift;
  15058. cm.state.suppressEdits = false;
  15059. }
  15060. return done
  15061. }
  15062. function lookupKeyForEditor(cm, name, handle) {
  15063. for (var i = 0; i < cm.state.keyMaps.length; i++) {
  15064. var result = lookupKey(name, cm.state.keyMaps[i], handle, cm);
  15065. if (result) { return result }
  15066. }
  15067. return (cm.options.extraKeys && lookupKey(name, cm.options.extraKeys, handle, cm))
  15068. || lookupKey(name, cm.options.keyMap, handle, cm)
  15069. }
  15070. // Note that, despite the name, this function is also used to check
  15071. // for bound mouse clicks.
  15072. var stopSeq = new Delayed;
  15073. function dispatchKey(cm, name, e, handle) {
  15074. var seq = cm.state.keySeq;
  15075. if (seq) {
  15076. if (isModifierKey(name)) { return "handled" }
  15077. if (/\'$/.test(name))
  15078. { cm.state.keySeq = null; }
  15079. else
  15080. { stopSeq.set(50, function () {
  15081. if (cm.state.keySeq == seq) {
  15082. cm.state.keySeq = null;
  15083. cm.display.input.reset();
  15084. }
  15085. }); }
  15086. if (dispatchKeyInner(cm, seq + " " + name, e, handle)) { return true }
  15087. }
  15088. return dispatchKeyInner(cm, name, e, handle)
  15089. }
  15090. function dispatchKeyInner(cm, name, e, handle) {
  15091. var result = lookupKeyForEditor(cm, name, handle);
  15092. if (result == "multi")
  15093. { cm.state.keySeq = name; }
  15094. if (result == "handled")
  15095. { signalLater(cm, "keyHandled", cm, name, e); }
  15096. if (result == "handled" || result == "multi") {
  15097. e_preventDefault(e);
  15098. restartBlink(cm);
  15099. }
  15100. return !!result
  15101. }
  15102. // Handle a key from the keydown event.
  15103. function handleKeyBinding(cm, e) {
  15104. var name = keyName(e, true);
  15105. if (!name) { return false }
  15106. if (e.shiftKey && !cm.state.keySeq) {
  15107. // First try to resolve full name (including 'Shift-'). Failing
  15108. // that, see if there is a cursor-motion command (starting with
  15109. // 'go') bound to the keyname without 'Shift-'.
  15110. return dispatchKey(cm, "Shift-" + name, e, function (b) { return doHandleBinding(cm, b, true); })
  15111. || dispatchKey(cm, name, e, function (b) {
  15112. if (typeof b == "string" ? /^go[A-Z]/.test(b) : b.motion)
  15113. { return doHandleBinding(cm, b) }
  15114. })
  15115. } else {
  15116. return dispatchKey(cm, name, e, function (b) { return doHandleBinding(cm, b); })
  15117. }
  15118. }
  15119. // Handle a key from the keypress event
  15120. function handleCharBinding(cm, e, ch) {
  15121. return dispatchKey(cm, "'" + ch + "'", e, function (b) { return doHandleBinding(cm, b, true); })
  15122. }
  15123. var lastStoppedKey = null;
  15124. function onKeyDown(e) {
  15125. var cm = this;
  15126. cm.curOp.focus = activeElt();
  15127. if (signalDOMEvent(cm, e)) { return }
  15128. // IE does strange things with escape.
  15129. if (ie && ie_version < 11 && e.keyCode == 27) { e.returnValue = false; }
  15130. var code = e.keyCode;
  15131. cm.display.shift = code == 16 || e.shiftKey;
  15132. var handled = handleKeyBinding(cm, e);
  15133. if (presto) {
  15134. lastStoppedKey = handled ? code : null;
  15135. // Opera has no cut event... we try to at least catch the key combo
  15136. if (!handled && code == 88 && !hasCopyEvent && (mac ? e.metaKey : e.ctrlKey))
  15137. { cm.replaceSelection("", null, "cut"); }
  15138. }
  15139. // Turn mouse into crosshair when Alt is held on Mac.
  15140. if (code == 18 && !/\bCodeMirror-crosshair\b/.test(cm.display.lineDiv.className))
  15141. { showCrossHair(cm); }
  15142. }
  15143. function showCrossHair(cm) {
  15144. var lineDiv = cm.display.lineDiv;
  15145. addClass(lineDiv, "CodeMirror-crosshair");
  15146. function up(e) {
  15147. if (e.keyCode == 18 || !e.altKey) {
  15148. rmClass(lineDiv, "CodeMirror-crosshair");
  15149. off(document, "keyup", up);
  15150. off(document, "mouseover", up);
  15151. }
  15152. }
  15153. on(document, "keyup", up);
  15154. on(document, "mouseover", up);
  15155. }
  15156. function onKeyUp(e) {
  15157. if (e.keyCode == 16) { this.doc.sel.shift = false; }
  15158. signalDOMEvent(this, e);
  15159. }
  15160. function onKeyPress(e) {
  15161. var cm = this;
  15162. if (eventInWidget(cm.display, e) || signalDOMEvent(cm, e) || e.ctrlKey && !e.altKey || mac && e.metaKey) { return }
  15163. var keyCode = e.keyCode, charCode = e.charCode;
  15164. if (presto && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return}
  15165. if ((presto && (!e.which || e.which < 10)) && handleKeyBinding(cm, e)) { return }
  15166. var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
  15167. // Some browsers fire keypress events for backspace
  15168. if (ch == "\x08") { return }
  15169. if (handleCharBinding(cm, e, ch)) { return }
  15170. cm.display.input.onKeyPress(e);
  15171. }
  15172. var DOUBLECLICK_DELAY = 400;
  15173. var PastClick = function(time, pos, button) {
  15174. this.time = time;
  15175. this.pos = pos;
  15176. this.button = button;
  15177. };
  15178. PastClick.prototype.compare = function (time, pos, button) {
  15179. return this.time + DOUBLECLICK_DELAY > time &&
  15180. cmp(pos, this.pos) == 0 && button == this.button
  15181. };
  15182. var lastClick;
  15183. var lastDoubleClick;
  15184. function clickRepeat(pos, button) {
  15185. var now = +new Date;
  15186. if (lastDoubleClick && lastDoubleClick.compare(now, pos, button)) {
  15187. lastClick = lastDoubleClick = null;
  15188. return "triple"
  15189. } else if (lastClick && lastClick.compare(now, pos, button)) {
  15190. lastDoubleClick = new PastClick(now, pos, button);
  15191. lastClick = null;
  15192. return "double"
  15193. } else {
  15194. lastClick = new PastClick(now, pos, button);
  15195. lastDoubleClick = null;
  15196. return "single"
  15197. }
  15198. }
  15199. // A mouse down can be a single click, double click, triple click,
  15200. // start of selection drag, start of text drag, new cursor
  15201. // (ctrl-click), rectangle drag (alt-drag), or xwin
  15202. // middle-click-paste. Or it might be a click on something we should
  15203. // not interfere with, such as a scrollbar or widget.
  15204. function onMouseDown(e) {
  15205. var cm = this, display = cm.display;
  15206. if (signalDOMEvent(cm, e) || display.activeTouch && display.input.supportsTouch()) { return }
  15207. display.input.ensurePolled();
  15208. display.shift = e.shiftKey;
  15209. if (eventInWidget(display, e)) {
  15210. if (!webkit) {
  15211. // Briefly turn off draggability, to allow widgets to do
  15212. // normal dragging things.
  15213. display.scroller.draggable = false;
  15214. setTimeout(function () { return display.scroller.draggable = true; }, 100);
  15215. }
  15216. return
  15217. }
  15218. if (clickInGutter(cm, e)) { return }
  15219. var pos = posFromMouse(cm, e), button = e_button(e), repeat = pos ? clickRepeat(pos, button) : "single";
  15220. window.focus();
  15221. // #3261: make sure, that we're not starting a second selection
  15222. if (button == 1 && cm.state.selectingText)
  15223. { cm.state.selectingText(e); }
  15224. if (pos && handleMappedButton(cm, button, pos, repeat, e)) { return }
  15225. if (button == 1) {
  15226. if (pos) { leftButtonDown(cm, pos, repeat, e); }
  15227. else if (e_target(e) == display.scroller) { e_preventDefault(e); }
  15228. } else if (button == 2) {
  15229. if (pos) { extendSelection(cm.doc, pos); }
  15230. setTimeout(function () { return display.input.focus(); }, 20);
  15231. } else if (button == 3) {
  15232. if (captureRightClick) { onContextMenu(cm, e); }
  15233. else { delayBlurEvent(cm); }
  15234. }
  15235. }
  15236. function handleMappedButton(cm, button, pos, repeat, event) {
  15237. var name = "Click";
  15238. if (repeat == "double") { name = "Double" + name; }
  15239. else if (repeat == "triple") { name = "Triple" + name; }
  15240. name = (button == 1 ? "Left" : button == 2 ? "Middle" : "Right") + name;
  15241. return dispatchKey(cm, addModifierNames(name, event), event, function (bound) {
  15242. if (typeof bound == "string") { bound = commands[bound]; }
  15243. if (!bound) { return false }
  15244. var done = false;
  15245. try {
  15246. if (cm.isReadOnly()) { cm.state.suppressEdits = true; }
  15247. done = bound(cm, pos) != Pass;
  15248. } finally {
  15249. cm.state.suppressEdits = false;
  15250. }
  15251. return done
  15252. })
  15253. }
  15254. function configureMouse(cm, repeat, event) {
  15255. var option = cm.getOption("configureMouse");
  15256. var value = option ? option(cm, repeat, event) : {};
  15257. if (value.unit == null) {
  15258. var rect = chromeOS ? event.shiftKey && event.metaKey : event.altKey;
  15259. value.unit = rect ? "rectangle" : repeat == "single" ? "char" : repeat == "double" ? "word" : "line";
  15260. }
  15261. if (value.extend == null || cm.doc.extend) { value.extend = cm.doc.extend || event.shiftKey; }
  15262. if (value.addNew == null) { value.addNew = mac ? event.metaKey : event.ctrlKey; }
  15263. if (value.moveOnDrag == null) { value.moveOnDrag = !(mac ? event.altKey : event.ctrlKey); }
  15264. return value
  15265. }
  15266. function leftButtonDown(cm, pos, repeat, event) {
  15267. if (ie) { setTimeout(bind(ensureFocus, cm), 0); }
  15268. else { cm.curOp.focus = activeElt(); }
  15269. var behavior = configureMouse(cm, repeat, event);
  15270. var sel = cm.doc.sel, contained;
  15271. if (cm.options.dragDrop && dragAndDrop && !cm.isReadOnly() &&
  15272. repeat == "single" && (contained = sel.contains(pos)) > -1 &&
  15273. (cmp((contained = sel.ranges[contained]).from(), pos) < 0 || pos.xRel > 0) &&
  15274. (cmp(contained.to(), pos) > 0 || pos.xRel < 0))
  15275. { leftButtonStartDrag(cm, event, pos, behavior); }
  15276. else
  15277. { leftButtonSelect(cm, event, pos, behavior); }
  15278. }
  15279. // Start a text drag. When it ends, see if any dragging actually
  15280. // happen, and treat as a click if it didn't.
  15281. function leftButtonStartDrag(cm, event, pos, behavior) {
  15282. var display = cm.display, moved = false;
  15283. var dragEnd = operation(cm, function (e) {
  15284. if (webkit) { display.scroller.draggable = false; }
  15285. cm.state.draggingText = false;
  15286. off(display.wrapper.ownerDocument, "mouseup", dragEnd);
  15287. off(display.wrapper.ownerDocument, "mousemove", mouseMove);
  15288. off(display.scroller, "dragstart", dragStart);
  15289. off(display.scroller, "drop", dragEnd);
  15290. if (!moved) {
  15291. e_preventDefault(e);
  15292. if (!behavior.addNew)
  15293. { extendSelection(cm.doc, pos, null, null, behavior.extend); }
  15294. // Work around unexplainable focus problem in IE9 (#2127) and Chrome (#3081)
  15295. if (webkit || ie && ie_version == 9)
  15296. { setTimeout(function () {display.wrapper.ownerDocument.body.focus(); display.input.focus();}, 20); }
  15297. else
  15298. { display.input.focus(); }
  15299. }
  15300. });
  15301. var mouseMove = function(e2) {
  15302. moved = moved || Math.abs(event.clientX - e2.clientX) + Math.abs(event.clientY - e2.clientY) >= 10;
  15303. };
  15304. var dragStart = function () { return moved = true; };
  15305. // Let the drag handler handle this.
  15306. if (webkit) { display.scroller.draggable = true; }
  15307. cm.state.draggingText = dragEnd;
  15308. dragEnd.copy = !behavior.moveOnDrag;
  15309. // IE's approach to draggable
  15310. if (display.scroller.dragDrop) { display.scroller.dragDrop(); }
  15311. on(display.wrapper.ownerDocument, "mouseup", dragEnd);
  15312. on(display.wrapper.ownerDocument, "mousemove", mouseMove);
  15313. on(display.scroller, "dragstart", dragStart);
  15314. on(display.scroller, "drop", dragEnd);
  15315. delayBlurEvent(cm);
  15316. setTimeout(function () { return display.input.focus(); }, 20);
  15317. }
  15318. function rangeForUnit(cm, pos, unit) {
  15319. if (unit == "char") { return new Range(pos, pos) }
  15320. if (unit == "word") { return cm.findWordAt(pos) }
  15321. if (unit == "line") { return new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))) }
  15322. var result = unit(cm, pos);
  15323. return new Range(result.from, result.to)
  15324. }
  15325. // Normal selection, as opposed to text dragging.
  15326. function leftButtonSelect(cm, event, start, behavior) {
  15327. var display = cm.display, doc = cm.doc;
  15328. e_preventDefault(event);
  15329. var ourRange, ourIndex, startSel = doc.sel, ranges = startSel.ranges;
  15330. if (behavior.addNew && !behavior.extend) {
  15331. ourIndex = doc.sel.contains(start);
  15332. if (ourIndex > -1)
  15333. { ourRange = ranges[ourIndex]; }
  15334. else
  15335. { ourRange = new Range(start, start); }
  15336. } else {
  15337. ourRange = doc.sel.primary();
  15338. ourIndex = doc.sel.primIndex;
  15339. }
  15340. if (behavior.unit == "rectangle") {
  15341. if (!behavior.addNew) { ourRange = new Range(start, start); }
  15342. start = posFromMouse(cm, event, true, true);
  15343. ourIndex = -1;
  15344. } else {
  15345. var range$$1 = rangeForUnit(cm, start, behavior.unit);
  15346. if (behavior.extend)
  15347. { ourRange = extendRange(ourRange, range$$1.anchor, range$$1.head, behavior.extend); }
  15348. else
  15349. { ourRange = range$$1; }
  15350. }
  15351. if (!behavior.addNew) {
  15352. ourIndex = 0;
  15353. setSelection(doc, new Selection([ourRange], 0), sel_mouse);
  15354. startSel = doc.sel;
  15355. } else if (ourIndex == -1) {
  15356. ourIndex = ranges.length;
  15357. setSelection(doc, normalizeSelection(ranges.concat([ourRange]), ourIndex),
  15358. {scroll: false, origin: "*mouse"});
  15359. } else if (ranges.length > 1 && ranges[ourIndex].empty() && behavior.unit == "char" && !behavior.extend) {
  15360. setSelection(doc, normalizeSelection(ranges.slice(0, ourIndex).concat(ranges.slice(ourIndex + 1)), 0),
  15361. {scroll: false, origin: "*mouse"});
  15362. startSel = doc.sel;
  15363. } else {
  15364. replaceOneSelection(doc, ourIndex, ourRange, sel_mouse);
  15365. }
  15366. var lastPos = start;
  15367. function extendTo(pos) {
  15368. if (cmp(lastPos, pos) == 0) { return }
  15369. lastPos = pos;
  15370. if (behavior.unit == "rectangle") {
  15371. var ranges = [], tabSize = cm.options.tabSize;
  15372. var startCol = countColumn(getLine(doc, start.line).text, start.ch, tabSize);
  15373. var posCol = countColumn(getLine(doc, pos.line).text, pos.ch, tabSize);
  15374. var left = Math.min(startCol, posCol), right = Math.max(startCol, posCol);
  15375. for (var line = Math.min(start.line, pos.line), end = Math.min(cm.lastLine(), Math.max(start.line, pos.line));
  15376. line <= end; line++) {
  15377. var text = getLine(doc, line).text, leftPos = findColumn(text, left, tabSize);
  15378. if (left == right)
  15379. { ranges.push(new Range(Pos(line, leftPos), Pos(line, leftPos))); }
  15380. else if (text.length > leftPos)
  15381. { ranges.push(new Range(Pos(line, leftPos), Pos(line, findColumn(text, right, tabSize)))); }
  15382. }
  15383. if (!ranges.length) { ranges.push(new Range(start, start)); }
  15384. setSelection(doc, normalizeSelection(startSel.ranges.slice(0, ourIndex).concat(ranges), ourIndex),
  15385. {origin: "*mouse", scroll: false});
  15386. cm.scrollIntoView(pos);
  15387. } else {
  15388. var oldRange = ourRange;
  15389. var range$$1 = rangeForUnit(cm, pos, behavior.unit);
  15390. var anchor = oldRange.anchor, head;
  15391. if (cmp(range$$1.anchor, anchor) > 0) {
  15392. head = range$$1.head;
  15393. anchor = minPos(oldRange.from(), range$$1.anchor);
  15394. } else {
  15395. head = range$$1.anchor;
  15396. anchor = maxPos(oldRange.to(), range$$1.head);
  15397. }
  15398. var ranges$1 = startSel.ranges.slice(0);
  15399. ranges$1[ourIndex] = bidiSimplify(cm, new Range(clipPos(doc, anchor), head));
  15400. setSelection(doc, normalizeSelection(ranges$1, ourIndex), sel_mouse);
  15401. }
  15402. }
  15403. var editorSize = display.wrapper.getBoundingClientRect();
  15404. // Used to ensure timeout re-tries don't fire when another extend
  15405. // happened in the meantime (clearTimeout isn't reliable -- at
  15406. // least on Chrome, the timeouts still happen even when cleared,
  15407. // if the clear happens after their scheduled firing time).
  15408. var counter = 0;
  15409. function extend(e) {
  15410. var curCount = ++counter;
  15411. var cur = posFromMouse(cm, e, true, behavior.unit == "rectangle");
  15412. if (!cur) { return }
  15413. if (cmp(cur, lastPos) != 0) {
  15414. cm.curOp.focus = activeElt();
  15415. extendTo(cur);
  15416. var visible = visibleLines(display, doc);
  15417. if (cur.line >= visible.to || cur.line < visible.from)
  15418. { setTimeout(operation(cm, function () {if (counter == curCount) { extend(e); }}), 150); }
  15419. } else {
  15420. var outside = e.clientY < editorSize.top ? -20 : e.clientY > editorSize.bottom ? 20 : 0;
  15421. if (outside) { setTimeout(operation(cm, function () {
  15422. if (counter != curCount) { return }
  15423. display.scroller.scrollTop += outside;
  15424. extend(e);
  15425. }), 50); }
  15426. }
  15427. }
  15428. function done(e) {
  15429. cm.state.selectingText = false;
  15430. counter = Infinity;
  15431. e_preventDefault(e);
  15432. display.input.focus();
  15433. off(display.wrapper.ownerDocument, "mousemove", move);
  15434. off(display.wrapper.ownerDocument, "mouseup", up);
  15435. doc.history.lastSelOrigin = null;
  15436. }
  15437. var move = operation(cm, function (e) {
  15438. if (!e_button(e)) { done(e); }
  15439. else { extend(e); }
  15440. });
  15441. var up = operation(cm, done);
  15442. cm.state.selectingText = up;
  15443. on(display.wrapper.ownerDocument, "mousemove", move);
  15444. on(display.wrapper.ownerDocument, "mouseup", up);
  15445. }
  15446. // Used when mouse-selecting to adjust the anchor to the proper side
  15447. // of a bidi jump depending on the visual position of the head.
  15448. function bidiSimplify(cm, range$$1) {
  15449. var anchor = range$$1.anchor;
  15450. var head = range$$1.head;
  15451. var anchorLine = getLine(cm.doc, anchor.line);
  15452. if (cmp(anchor, head) == 0 && anchor.sticky == head.sticky) { return range$$1 }
  15453. var order = getOrder(anchorLine);
  15454. if (!order) { return range$$1 }
  15455. var index = getBidiPartAt(order, anchor.ch, anchor.sticky), part = order[index];
  15456. if (part.from != anchor.ch && part.to != anchor.ch) { return range$$1 }
  15457. var boundary = index + ((part.from == anchor.ch) == (part.level != 1) ? 0 : 1);
  15458. if (boundary == 0 || boundary == order.length) { return range$$1 }
  15459. // Compute the relative visual position of the head compared to the
  15460. // anchor (<0 is to the left, >0 to the right)
  15461. var leftSide;
  15462. if (head.line != anchor.line) {
  15463. leftSide = (head.line - anchor.line) * (cm.doc.direction == "ltr" ? 1 : -1) > 0;
  15464. } else {
  15465. var headIndex = getBidiPartAt(order, head.ch, head.sticky);
  15466. var dir = headIndex - index || (head.ch - anchor.ch) * (part.level == 1 ? -1 : 1);
  15467. if (headIndex == boundary - 1 || headIndex == boundary)
  15468. { leftSide = dir < 0; }
  15469. else
  15470. { leftSide = dir > 0; }
  15471. }
  15472. var usePart = order[boundary + (leftSide ? -1 : 0)];
  15473. var from = leftSide == (usePart.level == 1);
  15474. var ch = from ? usePart.from : usePart.to, sticky = from ? "after" : "before";
  15475. return anchor.ch == ch && anchor.sticky == sticky ? range$$1 : new Range(new Pos(anchor.line, ch, sticky), head)
  15476. }
  15477. // Determines whether an event happened in the gutter, and fires the
  15478. // handlers for the corresponding event.
  15479. function gutterEvent(cm, e, type, prevent) {
  15480. var mX, mY;
  15481. if (e.touches) {
  15482. mX = e.touches[0].clientX;
  15483. mY = e.touches[0].clientY;
  15484. } else {
  15485. try { mX = e.clientX; mY = e.clientY; }
  15486. catch(e) { return false }
  15487. }
  15488. if (mX >= Math.floor(cm.display.gutters.getBoundingClientRect().right)) { return false }
  15489. if (prevent) { e_preventDefault(e); }
  15490. var display = cm.display;
  15491. var lineBox = display.lineDiv.getBoundingClientRect();
  15492. if (mY > lineBox.bottom || !hasHandler(cm, type)) { return e_defaultPrevented(e) }
  15493. mY -= lineBox.top - display.viewOffset;
  15494. for (var i = 0; i < cm.options.gutters.length; ++i) {
  15495. var g = display.gutters.childNodes[i];
  15496. if (g && g.getBoundingClientRect().right >= mX) {
  15497. var line = lineAtHeight(cm.doc, mY);
  15498. var gutter = cm.options.gutters[i];
  15499. signal(cm, type, cm, line, gutter, e);
  15500. return e_defaultPrevented(e)
  15501. }
  15502. }
  15503. }
  15504. function clickInGutter(cm, e) {
  15505. return gutterEvent(cm, e, "gutterClick", true)
  15506. }
  15507. // CONTEXT MENU HANDLING
  15508. // To make the context menu work, we need to briefly unhide the
  15509. // textarea (making it as unobtrusive as possible) to let the
  15510. // right-click take effect on it.
  15511. function onContextMenu(cm, e) {
  15512. if (eventInWidget(cm.display, e) || contextMenuInGutter(cm, e)) { return }
  15513. if (signalDOMEvent(cm, e, "contextmenu")) { return }
  15514. cm.display.input.onContextMenu(e);
  15515. }
  15516. function contextMenuInGutter(cm, e) {
  15517. if (!hasHandler(cm, "gutterContextMenu")) { return false }
  15518. return gutterEvent(cm, e, "gutterContextMenu", false)
  15519. }
  15520. function themeChanged(cm) {
  15521. cm.display.wrapper.className = cm.display.wrapper.className.replace(/\s*cm-s-\S+/g, "") +
  15522. cm.options.theme.replace(/(^|\s)\s*/g, " cm-s-");
  15523. clearCaches(cm);
  15524. }
  15525. var Init = {toString: function(){return "CodeMirror.Init"}};
  15526. var defaults = {};
  15527. var optionHandlers = {};
  15528. function defineOptions(CodeMirror) {
  15529. var optionHandlers = CodeMirror.optionHandlers;
  15530. function option(name, deflt, handle, notOnInit) {
  15531. CodeMirror.defaults[name] = deflt;
  15532. if (handle) { optionHandlers[name] =
  15533. notOnInit ? function (cm, val, old) {if (old != Init) { handle(cm, val, old); }} : handle; }
  15534. }
  15535. CodeMirror.defineOption = option;
  15536. // Passed to option handlers when there is no old value.
  15537. CodeMirror.Init = Init;
  15538. // These two are, on init, called from the constructor because they
  15539. // have to be initialized before the editor can start at all.
  15540. option("value", "", function (cm, val) { return cm.setValue(val); }, true);
  15541. option("mode", null, function (cm, val) {
  15542. cm.doc.modeOption = val;
  15543. loadMode(cm);
  15544. }, true);
  15545. option("indentUnit", 2, loadMode, true);
  15546. option("indentWithTabs", false);
  15547. option("smartIndent", true);
  15548. option("tabSize", 4, function (cm) {
  15549. resetModeState(cm);
  15550. clearCaches(cm);
  15551. regChange(cm);
  15552. }, true);
  15553. option("lineSeparator", null, function (cm, val) {
  15554. cm.doc.lineSep = val;
  15555. if (!val) { return }
  15556. var newBreaks = [], lineNo = cm.doc.first;
  15557. cm.doc.iter(function (line) {
  15558. for (var pos = 0;;) {
  15559. var found = line.text.indexOf(val, pos);
  15560. if (found == -1) { break }
  15561. pos = found + val.length;
  15562. newBreaks.push(Pos(lineNo, found));
  15563. }
  15564. lineNo++;
  15565. });
  15566. for (var i = newBreaks.length - 1; i >= 0; i--)
  15567. { replaceRange(cm.doc, val, newBreaks[i], Pos(newBreaks[i].line, newBreaks[i].ch + val.length)); }
  15568. });
  15569. option("specialChars", /[\u0000-\u001f\u007f-\u009f\u00ad\u061c\u200b-\u200f\u2028\u2029\ufeff]/g, function (cm, val, old) {
  15570. cm.state.specialChars = new RegExp(val.source + (val.test("\t") ? "" : "|\t"), "g");
  15571. if (old != Init) { cm.refresh(); }
  15572. });
  15573. option("specialCharPlaceholder", defaultSpecialCharPlaceholder, function (cm) { return cm.refresh(); }, true);
  15574. option("electricChars", true);
  15575. option("inputStyle", mobile ? "contenteditable" : "textarea", function () {
  15576. throw new Error("inputStyle can not (yet) be changed in a running editor") // FIXME
  15577. }, true);
  15578. option("spellcheck", false, function (cm, val) { return cm.getInputField().spellcheck = val; }, true);
  15579. option("rtlMoveVisually", !windows);
  15580. option("wholeLineUpdateBefore", true);
  15581. option("theme", "default", function (cm) {
  15582. themeChanged(cm);
  15583. guttersChanged(cm);
  15584. }, true);
  15585. option("keyMap", "default", function (cm, val, old) {
  15586. var next = getKeyMap(val);
  15587. var prev = old != Init && getKeyMap(old);
  15588. if (prev && prev.detach) { prev.detach(cm, next); }
  15589. if (next.attach) { next.attach(cm, prev || null); }
  15590. });
  15591. option("extraKeys", null);
  15592. option("configureMouse", null);
  15593. option("lineWrapping", false, wrappingChanged, true);
  15594. option("gutters", [], function (cm) {
  15595. setGuttersForLineNumbers(cm.options);
  15596. guttersChanged(cm);
  15597. }, true);
  15598. option("fixedGutter", true, function (cm, val) {
  15599. cm.display.gutters.style.left = val ? compensateForHScroll(cm.display) + "px" : "0";
  15600. cm.refresh();
  15601. }, true);
  15602. option("coverGutterNextToScrollbar", false, function (cm) { return updateScrollbars(cm); }, true);
  15603. option("scrollbarStyle", "native", function (cm) {
  15604. initScrollbars(cm);
  15605. updateScrollbars(cm);
  15606. cm.display.scrollbars.setScrollTop(cm.doc.scrollTop);
  15607. cm.display.scrollbars.setScrollLeft(cm.doc.scrollLeft);
  15608. }, true);
  15609. option("lineNumbers", false, function (cm) {
  15610. setGuttersForLineNumbers(cm.options);
  15611. guttersChanged(cm);
  15612. }, true);
  15613. option("firstLineNumber", 1, guttersChanged, true);
  15614. option("lineNumberFormatter", function (integer) { return integer; }, guttersChanged, true);
  15615. option("showCursorWhenSelecting", false, updateSelection, true);
  15616. option("resetSelectionOnContextMenu", true);
  15617. option("lineWiseCopyCut", true);
  15618. option("pasteLinesPerSelection", true);
  15619. option("readOnly", false, function (cm, val) {
  15620. if (val == "nocursor") {
  15621. onBlur(cm);
  15622. cm.display.input.blur();
  15623. }
  15624. cm.display.input.readOnlyChanged(val);
  15625. });
  15626. option("disableInput", false, function (cm, val) {if (!val) { cm.display.input.reset(); }}, true);
  15627. option("dragDrop", true, dragDropChanged);
  15628. option("allowDropFileTypes", null);
  15629. option("cursorBlinkRate", 530);
  15630. option("cursorScrollMargin", 0);
  15631. option("cursorHeight", 1, updateSelection, true);
  15632. option("singleCursorHeightPerLine", true, updateSelection, true);
  15633. option("workTime", 100);
  15634. option("workDelay", 100);
  15635. option("flattenSpans", true, resetModeState, true);
  15636. option("addModeClass", false, resetModeState, true);
  15637. option("pollInterval", 100);
  15638. option("undoDepth", 200, function (cm, val) { return cm.doc.history.undoDepth = val; });
  15639. option("historyEventDelay", 1250);
  15640. option("viewportMargin", 10, function (cm) { return cm.refresh(); }, true);
  15641. option("maxHighlightLength", 10000, resetModeState, true);
  15642. option("moveInputWithCursor", true, function (cm, val) {
  15643. if (!val) { cm.display.input.resetPosition(); }
  15644. });
  15645. option("tabindex", null, function (cm, val) { return cm.display.input.getField().tabIndex = val || ""; });
  15646. option("autofocus", null);
  15647. option("direction", "ltr", function (cm, val) { return cm.doc.setDirection(val); }, true);
  15648. }
  15649. function guttersChanged(cm) {
  15650. updateGutters(cm);
  15651. regChange(cm);
  15652. alignHorizontally(cm);
  15653. }
  15654. function dragDropChanged(cm, value, old) {
  15655. var wasOn = old && old != Init;
  15656. if (!value != !wasOn) {
  15657. var funcs = cm.display.dragFunctions;
  15658. var toggle = value ? on : off;
  15659. toggle(cm.display.scroller, "dragstart", funcs.start);
  15660. toggle(cm.display.scroller, "dragenter", funcs.enter);
  15661. toggle(cm.display.scroller, "dragover", funcs.over);
  15662. toggle(cm.display.scroller, "dragleave", funcs.leave);
  15663. toggle(cm.display.scroller, "drop", funcs.drop);
  15664. }
  15665. }
  15666. function wrappingChanged(cm) {
  15667. if (cm.options.lineWrapping) {
  15668. addClass(cm.display.wrapper, "CodeMirror-wrap");
  15669. cm.display.sizer.style.minWidth = "";
  15670. cm.display.sizerWidth = null;
  15671. } else {
  15672. rmClass(cm.display.wrapper, "CodeMirror-wrap");
  15673. findMaxLine(cm);
  15674. }
  15675. estimateLineHeights(cm);
  15676. regChange(cm);
  15677. clearCaches(cm);
  15678. setTimeout(function () { return updateScrollbars(cm); }, 100);
  15679. }
  15680. // A CodeMirror instance represents an editor. This is the object
  15681. // that user code is usually dealing with.
  15682. function CodeMirror$1(place, options) {
  15683. var this$1 = this;
  15684. if (!(this instanceof CodeMirror$1)) { return new CodeMirror$1(place, options) }
  15685. this.options = options = options ? copyObj(options) : {};
  15686. // Determine effective options based on given values and defaults.
  15687. copyObj(defaults, options, false);
  15688. setGuttersForLineNumbers(options);
  15689. var doc = options.value;
  15690. if (typeof doc == "string") { doc = new Doc(doc, options.mode, null, options.lineSeparator, options.direction); }
  15691. this.doc = doc;
  15692. var input = new CodeMirror$1.inputStyles[options.inputStyle](this);
  15693. var display = this.display = new Display(place, doc, input);
  15694. display.wrapper.CodeMirror = this;
  15695. updateGutters(this);
  15696. themeChanged(this);
  15697. if (options.lineWrapping)
  15698. { this.display.wrapper.className += " CodeMirror-wrap"; }
  15699. initScrollbars(this);
  15700. this.state = {
  15701. keyMaps: [], // stores maps added by addKeyMap
  15702. overlays: [], // highlighting overlays, as added by addOverlay
  15703. modeGen: 0, // bumped when mode/overlay changes, used to invalidate highlighting info
  15704. overwrite: false,
  15705. delayingBlurEvent: false,
  15706. focused: false,
  15707. suppressEdits: false, // used to disable editing during key handlers when in readOnly mode
  15708. pasteIncoming: false, cutIncoming: false, // help recognize paste/cut edits in input.poll
  15709. selectingText: false,
  15710. draggingText: false,
  15711. highlight: new Delayed(), // stores highlight worker timeout
  15712. keySeq: null, // Unfinished key sequence
  15713. specialChars: null
  15714. };
  15715. if (options.autofocus && !mobile) { display.input.focus(); }
  15716. // Override magic textarea content restore that IE sometimes does
  15717. // on our hidden textarea on reload
  15718. if (ie && ie_version < 11) { setTimeout(function () { return this$1.display.input.reset(true); }, 20); }
  15719. registerEventHandlers(this);
  15720. ensureGlobalHandlers();
  15721. startOperation(this);
  15722. this.curOp.forceUpdate = true;
  15723. attachDoc(this, doc);
  15724. if ((options.autofocus && !mobile) || this.hasFocus())
  15725. { setTimeout(bind(onFocus, this), 20); }
  15726. else
  15727. { onBlur(this); }
  15728. for (var opt in optionHandlers) { if (optionHandlers.hasOwnProperty(opt))
  15729. { optionHandlers[opt](this$1, options[opt], Init); } }
  15730. maybeUpdateLineNumberWidth(this);
  15731. if (options.finishInit) { options.finishInit(this); }
  15732. for (var i = 0; i < initHooks.length; ++i) { initHooks[i](this$1); }
  15733. endOperation(this);
  15734. // Suppress optimizelegibility in Webkit, since it breaks text
  15735. // measuring on line wrapping boundaries.
  15736. if (webkit && options.lineWrapping &&
  15737. getComputedStyle(display.lineDiv).textRendering == "optimizelegibility")
  15738. { display.lineDiv.style.textRendering = "auto"; }
  15739. }
  15740. // The default configuration options.
  15741. CodeMirror$1.defaults = defaults;
  15742. // Functions to run when options are changed.
  15743. CodeMirror$1.optionHandlers = optionHandlers;
  15744. // Attach the necessary event handlers when initializing the editor
  15745. function registerEventHandlers(cm) {
  15746. var d = cm.display;
  15747. on(d.scroller, "mousedown", operation(cm, onMouseDown));
  15748. // Older IE's will not fire a second mousedown for a double click
  15749. if (ie && ie_version < 11)
  15750. { on(d.scroller, "dblclick", operation(cm, function (e) {
  15751. if (signalDOMEvent(cm, e)) { return }
  15752. var pos = posFromMouse(cm, e);
  15753. if (!pos || clickInGutter(cm, e) || eventInWidget(cm.display, e)) { return }
  15754. e_preventDefault(e);
  15755. var word = cm.findWordAt(pos);
  15756. extendSelection(cm.doc, word.anchor, word.head);
  15757. })); }
  15758. else
  15759. { on(d.scroller, "dblclick", function (e) { return signalDOMEvent(cm, e) || e_preventDefault(e); }); }
  15760. // Some browsers fire contextmenu *after* opening the menu, at
  15761. // which point we can't mess with it anymore. Context menu is
  15762. // handled in onMouseDown for these browsers.
  15763. if (!captureRightClick) { on(d.scroller, "contextmenu", function (e) { return onContextMenu(cm, e); }); }
  15764. // Used to suppress mouse event handling when a touch happens
  15765. var touchFinished, prevTouch = {end: 0};
  15766. function finishTouch() {
  15767. if (d.activeTouch) {
  15768. touchFinished = setTimeout(function () { return d.activeTouch = null; }, 1000);
  15769. prevTouch = d.activeTouch;
  15770. prevTouch.end = +new Date;
  15771. }
  15772. }
  15773. function isMouseLikeTouchEvent(e) {
  15774. if (e.touches.length != 1) { return false }
  15775. var touch = e.touches[0];
  15776. return touch.radiusX <= 1 && touch.radiusY <= 1
  15777. }
  15778. function farAway(touch, other) {
  15779. if (other.left == null) { return true }
  15780. var dx = other.left - touch.left, dy = other.top - touch.top;
  15781. return dx * dx + dy * dy > 20 * 20
  15782. }
  15783. on(d.scroller, "touchstart", function (e) {
  15784. if (!signalDOMEvent(cm, e) && !isMouseLikeTouchEvent(e) && !clickInGutter(cm, e)) {
  15785. d.input.ensurePolled();
  15786. clearTimeout(touchFinished);
  15787. var now = +new Date;
  15788. d.activeTouch = {start: now, moved: false,
  15789. prev: now - prevTouch.end <= 300 ? prevTouch : null};
  15790. if (e.touches.length == 1) {
  15791. d.activeTouch.left = e.touches[0].pageX;
  15792. d.activeTouch.top = e.touches[0].pageY;
  15793. }
  15794. }
  15795. });
  15796. on(d.scroller, "touchmove", function () {
  15797. if (d.activeTouch) { d.activeTouch.moved = true; }
  15798. });
  15799. on(d.scroller, "touchend", function (e) {
  15800. var touch = d.activeTouch;
  15801. if (touch && !eventInWidget(d, e) && touch.left != null &&
  15802. !touch.moved && new Date - touch.start < 300) {
  15803. var pos = cm.coordsChar(d.activeTouch, "page"), range;
  15804. if (!touch.prev || farAway(touch, touch.prev)) // Single tap
  15805. { range = new Range(pos, pos); }
  15806. else if (!touch.prev.prev || farAway(touch, touch.prev.prev)) // Double tap
  15807. { range = cm.findWordAt(pos); }
  15808. else // Triple tap
  15809. { range = new Range(Pos(pos.line, 0), clipPos(cm.doc, Pos(pos.line + 1, 0))); }
  15810. cm.setSelection(range.anchor, range.head);
  15811. cm.focus();
  15812. e_preventDefault(e);
  15813. }
  15814. finishTouch();
  15815. });
  15816. on(d.scroller, "touchcancel", finishTouch);
  15817. // Sync scrolling between fake scrollbars and real scrollable
  15818. // area, ensure viewport is updated when scrolling.
  15819. on(d.scroller, "scroll", function () {
  15820. if (d.scroller.clientHeight) {
  15821. updateScrollTop(cm, d.scroller.scrollTop);
  15822. setScrollLeft(cm, d.scroller.scrollLeft, true);
  15823. signal(cm, "scroll", cm);
  15824. }
  15825. });
  15826. // Listen to wheel events in order to try and update the viewport on time.
  15827. on(d.scroller, "mousewheel", function (e) { return onScrollWheel(cm, e); });
  15828. on(d.scroller, "DOMMouseScroll", function (e) { return onScrollWheel(cm, e); });
  15829. // Prevent wrapper from ever scrolling
  15830. on(d.wrapper, "scroll", function () { return d.wrapper.scrollTop = d.wrapper.scrollLeft = 0; });
  15831. d.dragFunctions = {
  15832. enter: function (e) {if (!signalDOMEvent(cm, e)) { e_stop(e); }},
  15833. over: function (e) {if (!signalDOMEvent(cm, e)) { onDragOver(cm, e); e_stop(e); }},
  15834. start: function (e) { return onDragStart(cm, e); },
  15835. drop: operation(cm, onDrop),
  15836. leave: function (e) {if (!signalDOMEvent(cm, e)) { clearDragCursor(cm); }}
  15837. };
  15838. var inp = d.input.getField();
  15839. on(inp, "keyup", function (e) { return onKeyUp.call(cm, e); });
  15840. on(inp, "keydown", operation(cm, onKeyDown));
  15841. on(inp, "keypress", operation(cm, onKeyPress));
  15842. on(inp, "focus", function (e) { return onFocus(cm, e); });
  15843. on(inp, "blur", function (e) { return onBlur(cm, e); });
  15844. }
  15845. var initHooks = [];
  15846. CodeMirror$1.defineInitHook = function (f) { return initHooks.push(f); };
  15847. // Indent the given line. The how parameter can be "smart",
  15848. // "add"/null, "subtract", or "prev". When aggressive is false
  15849. // (typically set to true for forced single-line indents), empty
  15850. // lines are not indented, and places where the mode returns Pass
  15851. // are left alone.
  15852. function indentLine(cm, n, how, aggressive) {
  15853. var doc = cm.doc, state;
  15854. if (how == null) { how = "add"; }
  15855. if (how == "smart") {
  15856. // Fall back to "prev" when the mode doesn't have an indentation
  15857. // method.
  15858. if (!doc.mode.indent) { how = "prev"; }
  15859. else { state = getContextBefore(cm, n).state; }
  15860. }
  15861. var tabSize = cm.options.tabSize;
  15862. var line = getLine(doc, n), curSpace = countColumn(line.text, null, tabSize);
  15863. if (line.stateAfter) { line.stateAfter = null; }
  15864. var curSpaceString = line.text.match(/^\s*/)[0], indentation;
  15865. if (!aggressive && !/\S/.test(line.text)) {
  15866. indentation = 0;
  15867. how = "not";
  15868. } else if (how == "smart") {
  15869. indentation = doc.mode.indent(state, line.text.slice(curSpaceString.length), line.text);
  15870. if (indentation == Pass || indentation > 150) {
  15871. if (!aggressive) { return }
  15872. how = "prev";
  15873. }
  15874. }
  15875. if (how == "prev") {
  15876. if (n > doc.first) { indentation = countColumn(getLine(doc, n-1).text, null, tabSize); }
  15877. else { indentation = 0; }
  15878. } else if (how == "add") {
  15879. indentation = curSpace + cm.options.indentUnit;
  15880. } else if (how == "subtract") {
  15881. indentation = curSpace - cm.options.indentUnit;
  15882. } else if (typeof how == "number") {
  15883. indentation = curSpace + how;
  15884. }
  15885. indentation = Math.max(0, indentation);
  15886. var indentString = "", pos = 0;
  15887. if (cm.options.indentWithTabs)
  15888. { for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";} }
  15889. if (pos < indentation) { indentString += spaceStr(indentation - pos); }
  15890. if (indentString != curSpaceString) {
  15891. replaceRange(doc, indentString, Pos(n, 0), Pos(n, curSpaceString.length), "+input");
  15892. line.stateAfter = null;
  15893. return true
  15894. } else {
  15895. // Ensure that, if the cursor was in the whitespace at the start
  15896. // of the line, it is moved to the end of that space.
  15897. for (var i$1 = 0; i$1 < doc.sel.ranges.length; i$1++) {
  15898. var range = doc.sel.ranges[i$1];
  15899. if (range.head.line == n && range.head.ch < curSpaceString.length) {
  15900. var pos$1 = Pos(n, curSpaceString.length);
  15901. replaceOneSelection(doc, i$1, new Range(pos$1, pos$1));
  15902. break
  15903. }
  15904. }
  15905. }
  15906. }
  15907. // This will be set to a {lineWise: bool, text: [string]} object, so
  15908. // that, when pasting, we know what kind of selections the copied
  15909. // text was made out of.
  15910. var lastCopied = null;
  15911. function setLastCopied(newLastCopied) {
  15912. lastCopied = newLastCopied;
  15913. }
  15914. function applyTextInput(cm, inserted, deleted, sel, origin) {
  15915. var doc = cm.doc;
  15916. cm.display.shift = false;
  15917. if (!sel) { sel = doc.sel; }
  15918. var paste = cm.state.pasteIncoming || origin == "paste";
  15919. var textLines = splitLinesAuto(inserted), multiPaste = null;
  15920. // When pasting N lines into N selections, insert one line per selection
  15921. if (paste && sel.ranges.length > 1) {
  15922. if (lastCopied && lastCopied.text.join("\n") == inserted) {
  15923. if (sel.ranges.length % lastCopied.text.length == 0) {
  15924. multiPaste = [];
  15925. for (var i = 0; i < lastCopied.text.length; i++)
  15926. { multiPaste.push(doc.splitLines(lastCopied.text[i])); }
  15927. }
  15928. } else if (textLines.length == sel.ranges.length && cm.options.pasteLinesPerSelection) {
  15929. multiPaste = map(textLines, function (l) { return [l]; });
  15930. }
  15931. }
  15932. var updateInput;
  15933. // Normal behavior is to insert the new text into every selection
  15934. for (var i$1 = sel.ranges.length - 1; i$1 >= 0; i$1--) {
  15935. var range$$1 = sel.ranges[i$1];
  15936. var from = range$$1.from(), to = range$$1.to();
  15937. if (range$$1.empty()) {
  15938. if (deleted && deleted > 0) // Handle deletion
  15939. { from = Pos(from.line, from.ch - deleted); }
  15940. else if (cm.state.overwrite && !paste) // Handle overwrite
  15941. { to = Pos(to.line, Math.min(getLine(doc, to.line).text.length, to.ch + lst(textLines).length)); }
  15942. else if (lastCopied && lastCopied.lineWise && lastCopied.text.join("\n") == inserted)
  15943. { from = to = Pos(from.line, 0); }
  15944. }
  15945. updateInput = cm.curOp.updateInput;
  15946. var changeEvent = {from: from, to: to, text: multiPaste ? multiPaste[i$1 % multiPaste.length] : textLines,
  15947. origin: origin || (paste ? "paste" : cm.state.cutIncoming ? "cut" : "+input")};
  15948. makeChange(cm.doc, changeEvent);
  15949. signalLater(cm, "inputRead", cm, changeEvent);
  15950. }
  15951. if (inserted && !paste)
  15952. { triggerElectric(cm, inserted); }
  15953. ensureCursorVisible(cm);
  15954. cm.curOp.updateInput = updateInput;
  15955. cm.curOp.typing = true;
  15956. cm.state.pasteIncoming = cm.state.cutIncoming = false;
  15957. }
  15958. function handlePaste(e, cm) {
  15959. var pasted = e.clipboardData && e.clipboardData.getData("Text");
  15960. if (pasted) {
  15961. e.preventDefault();
  15962. if (!cm.isReadOnly() && !cm.options.disableInput)
  15963. { runInOp(cm, function () { return applyTextInput(cm, pasted, 0, null, "paste"); }); }
  15964. return true
  15965. }
  15966. }
  15967. function triggerElectric(cm, inserted) {
  15968. // When an 'electric' character is inserted, immediately trigger a reindent
  15969. if (!cm.options.electricChars || !cm.options.smartIndent) { return }
  15970. var sel = cm.doc.sel;
  15971. for (var i = sel.ranges.length - 1; i >= 0; i--) {
  15972. var range$$1 = sel.ranges[i];
  15973. if (range$$1.head.ch > 100 || (i && sel.ranges[i - 1].head.line == range$$1.head.line)) { continue }
  15974. var mode = cm.getModeAt(range$$1.head);
  15975. var indented = false;
  15976. if (mode.electricChars) {
  15977. for (var j = 0; j < mode.electricChars.length; j++)
  15978. { if (inserted.indexOf(mode.electricChars.charAt(j)) > -1) {
  15979. indented = indentLine(cm, range$$1.head.line, "smart");
  15980. break
  15981. } }
  15982. } else if (mode.electricInput) {
  15983. if (mode.electricInput.test(getLine(cm.doc, range$$1.head.line).text.slice(0, range$$1.head.ch)))
  15984. { indented = indentLine(cm, range$$1.head.line, "smart"); }
  15985. }
  15986. if (indented) { signalLater(cm, "electricInput", cm, range$$1.head.line); }
  15987. }
  15988. }
  15989. function copyableRanges(cm) {
  15990. var text = [], ranges = [];
  15991. for (var i = 0; i < cm.doc.sel.ranges.length; i++) {
  15992. var line = cm.doc.sel.ranges[i].head.line;
  15993. var lineRange = {anchor: Pos(line, 0), head: Pos(line + 1, 0)};
  15994. ranges.push(lineRange);
  15995. text.push(cm.getRange(lineRange.anchor, lineRange.head));
  15996. }
  15997. return {text: text, ranges: ranges}
  15998. }
  15999. function disableBrowserMagic(field, spellcheck) {
  16000. field.setAttribute("autocorrect", "off");
  16001. field.setAttribute("autocapitalize", "off");
  16002. field.setAttribute("spellcheck", !!spellcheck);
  16003. }
  16004. function hiddenTextarea() {
  16005. var te = elt("textarea", null, null, "position: absolute; bottom: -1em; padding: 0; width: 1px; height: 1em; outline: none");
  16006. var div = elt("div", [te], null, "overflow: hidden; position: relative; width: 3px; height: 0px;");
  16007. // The textarea is kept positioned near the cursor to prevent the
  16008. // fact that it'll be scrolled into view on input from scrolling
  16009. // our fake cursor out of view. On webkit, when wrap=off, paste is
  16010. // very slow. So make the area wide instead.
  16011. if (webkit) { te.style.width = "1000px"; }
  16012. else { te.setAttribute("wrap", "off"); }
  16013. // If border: 0; -- iOS fails to open keyboard (issue #1287)
  16014. if (ios) { te.style.border = "1px solid black"; }
  16015. disableBrowserMagic(te);
  16016. return div
  16017. }
  16018. // The publicly visible API. Note that methodOp(f) means
  16019. // 'wrap f in an operation, performed on its `this` parameter'.
  16020. // This is not the complete set of editor methods. Most of the
  16021. // methods defined on the Doc type are also injected into
  16022. // CodeMirror.prototype, for backwards compatibility and
  16023. // convenience.
  16024. var addEditorMethods = function(CodeMirror) {
  16025. var optionHandlers = CodeMirror.optionHandlers;
  16026. var helpers = CodeMirror.helpers = {};
  16027. CodeMirror.prototype = {
  16028. constructor: CodeMirror,
  16029. focus: function(){window.focus(); this.display.input.focus();},
  16030. setOption: function(option, value) {
  16031. var options = this.options, old = options[option];
  16032. if (options[option] == value && option != "mode") { return }
  16033. options[option] = value;
  16034. if (optionHandlers.hasOwnProperty(option))
  16035. { operation(this, optionHandlers[option])(this, value, old); }
  16036. signal(this, "optionChange", this, option);
  16037. },
  16038. getOption: function(option) {return this.options[option]},
  16039. getDoc: function() {return this.doc},
  16040. addKeyMap: function(map$$1, bottom) {
  16041. this.state.keyMaps[bottom ? "push" : "unshift"](getKeyMap(map$$1));
  16042. },
  16043. removeKeyMap: function(map$$1) {
  16044. var maps = this.state.keyMaps;
  16045. for (var i = 0; i < maps.length; ++i)
  16046. { if (maps[i] == map$$1 || maps[i].name == map$$1) {
  16047. maps.splice(i, 1);
  16048. return true
  16049. } }
  16050. },
  16051. addOverlay: methodOp(function(spec, options) {
  16052. var mode = spec.token ? spec : CodeMirror.getMode(this.options, spec);
  16053. if (mode.startState) { throw new Error("Overlays may not be stateful.") }
  16054. insertSorted(this.state.overlays,
  16055. {mode: mode, modeSpec: spec, opaque: options && options.opaque,
  16056. priority: (options && options.priority) || 0},
  16057. function (overlay) { return overlay.priority; });
  16058. this.state.modeGen++;
  16059. regChange(this);
  16060. }),
  16061. removeOverlay: methodOp(function(spec) {
  16062. var this$1 = this;
  16063. var overlays = this.state.overlays;
  16064. for (var i = 0; i < overlays.length; ++i) {
  16065. var cur = overlays[i].modeSpec;
  16066. if (cur == spec || typeof spec == "string" && cur.name == spec) {
  16067. overlays.splice(i, 1);
  16068. this$1.state.modeGen++;
  16069. regChange(this$1);
  16070. return
  16071. }
  16072. }
  16073. }),
  16074. indentLine: methodOp(function(n, dir, aggressive) {
  16075. if (typeof dir != "string" && typeof dir != "number") {
  16076. if (dir == null) { dir = this.options.smartIndent ? "smart" : "prev"; }
  16077. else { dir = dir ? "add" : "subtract"; }
  16078. }
  16079. if (isLine(this.doc, n)) { indentLine(this, n, dir, aggressive); }
  16080. }),
  16081. indentSelection: methodOp(function(how) {
  16082. var this$1 = this;
  16083. var ranges = this.doc.sel.ranges, end = -1;
  16084. for (var i = 0; i < ranges.length; i++) {
  16085. var range$$1 = ranges[i];
  16086. if (!range$$1.empty()) {
  16087. var from = range$$1.from(), to = range$$1.to();
  16088. var start = Math.max(end, from.line);
  16089. end = Math.min(this$1.lastLine(), to.line - (to.ch ? 0 : 1)) + 1;
  16090. for (var j = start; j < end; ++j)
  16091. { indentLine(this$1, j, how); }
  16092. var newRanges = this$1.doc.sel.ranges;
  16093. if (from.ch == 0 && ranges.length == newRanges.length && newRanges[i].from().ch > 0)
  16094. { replaceOneSelection(this$1.doc, i, new Range(from, newRanges[i].to()), sel_dontScroll); }
  16095. } else if (range$$1.head.line > end) {
  16096. indentLine(this$1, range$$1.head.line, how, true);
  16097. end = range$$1.head.line;
  16098. if (i == this$1.doc.sel.primIndex) { ensureCursorVisible(this$1); }
  16099. }
  16100. }
  16101. }),
  16102. // Fetch the parser token for a given character. Useful for hacks
  16103. // that want to inspect the mode state (say, for completion).
  16104. getTokenAt: function(pos, precise) {
  16105. return takeToken(this, pos, precise)
  16106. },
  16107. getLineTokens: function(line, precise) {
  16108. return takeToken(this, Pos(line), precise, true)
  16109. },
  16110. getTokenTypeAt: function(pos) {
  16111. pos = clipPos(this.doc, pos);
  16112. var styles = getLineStyles(this, getLine(this.doc, pos.line));
  16113. var before = 0, after = (styles.length - 1) / 2, ch = pos.ch;
  16114. var type;
  16115. if (ch == 0) { type = styles[2]; }
  16116. else { for (;;) {
  16117. var mid = (before + after) >> 1;
  16118. if ((mid ? styles[mid * 2 - 1] : 0) >= ch) { after = mid; }
  16119. else if (styles[mid * 2 + 1] < ch) { before = mid + 1; }
  16120. else { type = styles[mid * 2 + 2]; break }
  16121. } }
  16122. var cut = type ? type.indexOf("overlay ") : -1;
  16123. return cut < 0 ? type : cut == 0 ? null : type.slice(0, cut - 1)
  16124. },
  16125. getModeAt: function(pos) {
  16126. var mode = this.doc.mode;
  16127. if (!mode.innerMode) { return mode }
  16128. return CodeMirror.innerMode(mode, this.getTokenAt(pos).state).mode
  16129. },
  16130. getHelper: function(pos, type) {
  16131. return this.getHelpers(pos, type)[0]
  16132. },
  16133. getHelpers: function(pos, type) {
  16134. var this$1 = this;
  16135. var found = [];
  16136. if (!helpers.hasOwnProperty(type)) { return found }
  16137. var help = helpers[type], mode = this.getModeAt(pos);
  16138. if (typeof mode[type] == "string") {
  16139. if (help[mode[type]]) { found.push(help[mode[type]]); }
  16140. } else if (mode[type]) {
  16141. for (var i = 0; i < mode[type].length; i++) {
  16142. var val = help[mode[type][i]];
  16143. if (val) { found.push(val); }
  16144. }
  16145. } else if (mode.helperType && help[mode.helperType]) {
  16146. found.push(help[mode.helperType]);
  16147. } else if (help[mode.name]) {
  16148. found.push(help[mode.name]);
  16149. }
  16150. for (var i$1 = 0; i$1 < help._global.length; i$1++) {
  16151. var cur = help._global[i$1];
  16152. if (cur.pred(mode, this$1) && indexOf(found, cur.val) == -1)
  16153. { found.push(cur.val); }
  16154. }
  16155. return found
  16156. },
  16157. getStateAfter: function(line, precise) {
  16158. var doc = this.doc;
  16159. line = clipLine(doc, line == null ? doc.first + doc.size - 1: line);
  16160. return getContextBefore(this, line + 1, precise).state
  16161. },
  16162. cursorCoords: function(start, mode) {
  16163. var pos, range$$1 = this.doc.sel.primary();
  16164. if (start == null) { pos = range$$1.head; }
  16165. else if (typeof start == "object") { pos = clipPos(this.doc, start); }
  16166. else { pos = start ? range$$1.from() : range$$1.to(); }
  16167. return cursorCoords(this, pos, mode || "page")
  16168. },
  16169. charCoords: function(pos, mode) {
  16170. return charCoords(this, clipPos(this.doc, pos), mode || "page")
  16171. },
  16172. coordsChar: function(coords, mode) {
  16173. coords = fromCoordSystem(this, coords, mode || "page");
  16174. return coordsChar(this, coords.left, coords.top)
  16175. },
  16176. lineAtHeight: function(height, mode) {
  16177. height = fromCoordSystem(this, {top: height, left: 0}, mode || "page").top;
  16178. return lineAtHeight(this.doc, height + this.display.viewOffset)
  16179. },
  16180. heightAtLine: function(line, mode, includeWidgets) {
  16181. var end = false, lineObj;
  16182. if (typeof line == "number") {
  16183. var last = this.doc.first + this.doc.size - 1;
  16184. if (line < this.doc.first) { line = this.doc.first; }
  16185. else if (line > last) { line = last; end = true; }
  16186. lineObj = getLine(this.doc, line);
  16187. } else {
  16188. lineObj = line;
  16189. }
  16190. return intoCoordSystem(this, lineObj, {top: 0, left: 0}, mode || "page", includeWidgets || end).top +
  16191. (end ? this.doc.height - heightAtLine(lineObj) : 0)
  16192. },
  16193. defaultTextHeight: function() { return textHeight(this.display) },
  16194. defaultCharWidth: function() { return charWidth(this.display) },
  16195. getViewport: function() { return {from: this.display.viewFrom, to: this.display.viewTo}},
  16196. addWidget: function(pos, node, scroll, vert, horiz) {
  16197. var display = this.display;
  16198. pos = cursorCoords(this, clipPos(this.doc, pos));
  16199. var top = pos.bottom, left = pos.left;
  16200. node.style.position = "absolute";
  16201. node.setAttribute("cm-ignore-events", "true");
  16202. this.display.input.setUneditable(node);
  16203. display.sizer.appendChild(node);
  16204. if (vert == "over") {
  16205. top = pos.top;
  16206. } else if (vert == "above" || vert == "near") {
  16207. var vspace = Math.max(display.wrapper.clientHeight, this.doc.height),
  16208. hspace = Math.max(display.sizer.clientWidth, display.lineSpace.clientWidth);
  16209. // Default to positioning above (if specified and possible); otherwise default to positioning below
  16210. if ((vert == 'above' || pos.bottom + node.offsetHeight > vspace) && pos.top > node.offsetHeight)
  16211. { top = pos.top - node.offsetHeight; }
  16212. else if (pos.bottom + node.offsetHeight <= vspace)
  16213. { top = pos.bottom; }
  16214. if (left + node.offsetWidth > hspace)
  16215. { left = hspace - node.offsetWidth; }
  16216. }
  16217. node.style.top = top + "px";
  16218. node.style.left = node.style.right = "";
  16219. if (horiz == "right") {
  16220. left = display.sizer.clientWidth - node.offsetWidth;
  16221. node.style.right = "0px";
  16222. } else {
  16223. if (horiz == "left") { left = 0; }
  16224. else if (horiz == "middle") { left = (display.sizer.clientWidth - node.offsetWidth) / 2; }
  16225. node.style.left = left + "px";
  16226. }
  16227. if (scroll)
  16228. { scrollIntoView(this, {left: left, top: top, right: left + node.offsetWidth, bottom: top + node.offsetHeight}); }
  16229. },
  16230. triggerOnKeyDown: methodOp(onKeyDown),
  16231. triggerOnKeyPress: methodOp(onKeyPress),
  16232. triggerOnKeyUp: onKeyUp,
  16233. triggerOnMouseDown: methodOp(onMouseDown),
  16234. execCommand: function(cmd) {
  16235. if (commands.hasOwnProperty(cmd))
  16236. { return commands[cmd].call(null, this) }
  16237. },
  16238. triggerElectric: methodOp(function(text) { triggerElectric(this, text); }),
  16239. findPosH: function(from, amount, unit, visually) {
  16240. var this$1 = this;
  16241. var dir = 1;
  16242. if (amount < 0) { dir = -1; amount = -amount; }
  16243. var cur = clipPos(this.doc, from);
  16244. for (var i = 0; i < amount; ++i) {
  16245. cur = findPosH(this$1.doc, cur, dir, unit, visually);
  16246. if (cur.hitSide) { break }
  16247. }
  16248. return cur
  16249. },
  16250. moveH: methodOp(function(dir, unit) {
  16251. var this$1 = this;
  16252. this.extendSelectionsBy(function (range$$1) {
  16253. if (this$1.display.shift || this$1.doc.extend || range$$1.empty())
  16254. { return findPosH(this$1.doc, range$$1.head, dir, unit, this$1.options.rtlMoveVisually) }
  16255. else
  16256. { return dir < 0 ? range$$1.from() : range$$1.to() }
  16257. }, sel_move);
  16258. }),
  16259. deleteH: methodOp(function(dir, unit) {
  16260. var sel = this.doc.sel, doc = this.doc;
  16261. if (sel.somethingSelected())
  16262. { doc.replaceSelection("", null, "+delete"); }
  16263. else
  16264. { deleteNearSelection(this, function (range$$1) {
  16265. var other = findPosH(doc, range$$1.head, dir, unit, false);
  16266. return dir < 0 ? {from: other, to: range$$1.head} : {from: range$$1.head, to: other}
  16267. }); }
  16268. }),
  16269. findPosV: function(from, amount, unit, goalColumn) {
  16270. var this$1 = this;
  16271. var dir = 1, x = goalColumn;
  16272. if (amount < 0) { dir = -1; amount = -amount; }
  16273. var cur = clipPos(this.doc, from);
  16274. for (var i = 0; i < amount; ++i) {
  16275. var coords = cursorCoords(this$1, cur, "div");
  16276. if (x == null) { x = coords.left; }
  16277. else { coords.left = x; }
  16278. cur = findPosV(this$1, coords, dir, unit);
  16279. if (cur.hitSide) { break }
  16280. }
  16281. return cur
  16282. },
  16283. moveV: methodOp(function(dir, unit) {
  16284. var this$1 = this;
  16285. var doc = this.doc, goals = [];
  16286. var collapse = !this.display.shift && !doc.extend && doc.sel.somethingSelected();
  16287. doc.extendSelectionsBy(function (range$$1) {
  16288. if (collapse)
  16289. { return dir < 0 ? range$$1.from() : range$$1.to() }
  16290. var headPos = cursorCoords(this$1, range$$1.head, "div");
  16291. if (range$$1.goalColumn != null) { headPos.left = range$$1.goalColumn; }
  16292. goals.push(headPos.left);
  16293. var pos = findPosV(this$1, headPos, dir, unit);
  16294. if (unit == "page" && range$$1 == doc.sel.primary())
  16295. { addToScrollTop(this$1, charCoords(this$1, pos, "div").top - headPos.top); }
  16296. return pos
  16297. }, sel_move);
  16298. if (goals.length) { for (var i = 0; i < doc.sel.ranges.length; i++)
  16299. { doc.sel.ranges[i].goalColumn = goals[i]; } }
  16300. }),
  16301. // Find the word at the given position (as returned by coordsChar).
  16302. findWordAt: function(pos) {
  16303. var doc = this.doc, line = getLine(doc, pos.line).text;
  16304. var start = pos.ch, end = pos.ch;
  16305. if (line) {
  16306. var helper = this.getHelper(pos, "wordChars");
  16307. if ((pos.sticky == "before" || end == line.length) && start) { --start; } else { ++end; }
  16308. var startChar = line.charAt(start);
  16309. var check = isWordChar(startChar, helper)
  16310. ? function (ch) { return isWordChar(ch, helper); }
  16311. : /\s/.test(startChar) ? function (ch) { return /\s/.test(ch); }
  16312. : function (ch) { return (!/\s/.test(ch) && !isWordChar(ch)); };
  16313. while (start > 0 && check(line.charAt(start - 1))) { --start; }
  16314. while (end < line.length && check(line.charAt(end))) { ++end; }
  16315. }
  16316. return new Range(Pos(pos.line, start), Pos(pos.line, end))
  16317. },
  16318. toggleOverwrite: function(value) {
  16319. if (value != null && value == this.state.overwrite) { return }
  16320. if (this.state.overwrite = !this.state.overwrite)
  16321. { addClass(this.display.cursorDiv, "CodeMirror-overwrite"); }
  16322. else
  16323. { rmClass(this.display.cursorDiv, "CodeMirror-overwrite"); }
  16324. signal(this, "overwriteToggle", this, this.state.overwrite);
  16325. },
  16326. hasFocus: function() { return this.display.input.getField() == activeElt() },
  16327. isReadOnly: function() { return !!(this.options.readOnly || this.doc.cantEdit) },
  16328. scrollTo: methodOp(function (x, y) { scrollToCoords(this, x, y); }),
  16329. getScrollInfo: function() {
  16330. var scroller = this.display.scroller;
  16331. return {left: scroller.scrollLeft, top: scroller.scrollTop,
  16332. height: scroller.scrollHeight - scrollGap(this) - this.display.barHeight,
  16333. width: scroller.scrollWidth - scrollGap(this) - this.display.barWidth,
  16334. clientHeight: displayHeight(this), clientWidth: displayWidth(this)}
  16335. },
  16336. scrollIntoView: methodOp(function(range$$1, margin) {
  16337. if (range$$1 == null) {
  16338. range$$1 = {from: this.doc.sel.primary().head, to: null};
  16339. if (margin == null) { margin = this.options.cursorScrollMargin; }
  16340. } else if (typeof range$$1 == "number") {
  16341. range$$1 = {from: Pos(range$$1, 0), to: null};
  16342. } else if (range$$1.from == null) {
  16343. range$$1 = {from: range$$1, to: null};
  16344. }
  16345. if (!range$$1.to) { range$$1.to = range$$1.from; }
  16346. range$$1.margin = margin || 0;
  16347. if (range$$1.from.line != null) {
  16348. scrollToRange(this, range$$1);
  16349. } else {
  16350. scrollToCoordsRange(this, range$$1.from, range$$1.to, range$$1.margin);
  16351. }
  16352. }),
  16353. setSize: methodOp(function(width, height) {
  16354. var this$1 = this;
  16355. var interpret = function (val) { return typeof val == "number" || /^\d+$/.test(String(val)) ? val + "px" : val; };
  16356. if (width != null) { this.display.wrapper.style.width = interpret(width); }
  16357. if (height != null) { this.display.wrapper.style.height = interpret(height); }
  16358. if (this.options.lineWrapping) { clearLineMeasurementCache(this); }
  16359. var lineNo$$1 = this.display.viewFrom;
  16360. this.doc.iter(lineNo$$1, this.display.viewTo, function (line) {
  16361. if (line.widgets) { for (var i = 0; i < line.widgets.length; i++)
  16362. { if (line.widgets[i].noHScroll) { regLineChange(this$1, lineNo$$1, "widget"); break } } }
  16363. ++lineNo$$1;
  16364. });
  16365. this.curOp.forceUpdate = true;
  16366. signal(this, "refresh", this);
  16367. }),
  16368. operation: function(f){return runInOp(this, f)},
  16369. startOperation: function(){return startOperation(this)},
  16370. endOperation: function(){return endOperation(this)},
  16371. refresh: methodOp(function() {
  16372. var oldHeight = this.display.cachedTextHeight;
  16373. regChange(this);
  16374. this.curOp.forceUpdate = true;
  16375. clearCaches(this);
  16376. scrollToCoords(this, this.doc.scrollLeft, this.doc.scrollTop);
  16377. updateGutterSpace(this);
  16378. if (oldHeight == null || Math.abs(oldHeight - textHeight(this.display)) > .5)
  16379. { estimateLineHeights(this); }
  16380. signal(this, "refresh", this);
  16381. }),
  16382. swapDoc: methodOp(function(doc) {
  16383. var old = this.doc;
  16384. old.cm = null;
  16385. attachDoc(this, doc);
  16386. clearCaches(this);
  16387. this.display.input.reset();
  16388. scrollToCoords(this, doc.scrollLeft, doc.scrollTop);
  16389. this.curOp.forceScroll = true;
  16390. signalLater(this, "swapDoc", this, old);
  16391. return old
  16392. }),
  16393. getInputField: function(){return this.display.input.getField()},
  16394. getWrapperElement: function(){return this.display.wrapper},
  16395. getScrollerElement: function(){return this.display.scroller},
  16396. getGutterElement: function(){return this.display.gutters}
  16397. };
  16398. eventMixin(CodeMirror);
  16399. CodeMirror.registerHelper = function(type, name, value) {
  16400. if (!helpers.hasOwnProperty(type)) { helpers[type] = CodeMirror[type] = {_global: []}; }
  16401. helpers[type][name] = value;
  16402. };
  16403. CodeMirror.registerGlobalHelper = function(type, name, predicate, value) {
  16404. CodeMirror.registerHelper(type, name, value);
  16405. helpers[type]._global.push({pred: predicate, val: value});
  16406. };
  16407. };
  16408. // Used for horizontal relative motion. Dir is -1 or 1 (left or
  16409. // right), unit can be "char", "column" (like char, but doesn't
  16410. // cross line boundaries), "word" (across next word), or "group" (to
  16411. // the start of next group of word or non-word-non-whitespace
  16412. // chars). The visually param controls whether, in right-to-left
  16413. // text, direction 1 means to move towards the next index in the
  16414. // string, or towards the character to the right of the current
  16415. // position. The resulting position will have a hitSide=true
  16416. // property if it reached the end of the document.
  16417. function findPosH(doc, pos, dir, unit, visually) {
  16418. var oldPos = pos;
  16419. var origDir = dir;
  16420. var lineObj = getLine(doc, pos.line);
  16421. function findNextLine() {
  16422. var l = pos.line + dir;
  16423. if (l < doc.first || l >= doc.first + doc.size) { return false }
  16424. pos = new Pos(l, pos.ch, pos.sticky);
  16425. return lineObj = getLine(doc, l)
  16426. }
  16427. function moveOnce(boundToLine) {
  16428. var next;
  16429. if (visually) {
  16430. next = moveVisually(doc.cm, lineObj, pos, dir);
  16431. } else {
  16432. next = moveLogically(lineObj, pos, dir);
  16433. }
  16434. if (next == null) {
  16435. if (!boundToLine && findNextLine())
  16436. { pos = endOfLine(visually, doc.cm, lineObj, pos.line, dir); }
  16437. else
  16438. { return false }
  16439. } else {
  16440. pos = next;
  16441. }
  16442. return true
  16443. }
  16444. if (unit == "char") {
  16445. moveOnce();
  16446. } else if (unit == "column") {
  16447. moveOnce(true);
  16448. } else if (unit == "word" || unit == "group") {
  16449. var sawType = null, group = unit == "group";
  16450. var helper = doc.cm && doc.cm.getHelper(pos, "wordChars");
  16451. for (var first = true;; first = false) {
  16452. if (dir < 0 && !moveOnce(!first)) { break }
  16453. var cur = lineObj.text.charAt(pos.ch) || "\n";
  16454. var type = isWordChar(cur, helper) ? "w"
  16455. : group && cur == "\n" ? "n"
  16456. : !group || /\s/.test(cur) ? null
  16457. : "p";
  16458. if (group && !first && !type) { type = "s"; }
  16459. if (sawType && sawType != type) {
  16460. if (dir < 0) {dir = 1; moveOnce(); pos.sticky = "after";}
  16461. break
  16462. }
  16463. if (type) { sawType = type; }
  16464. if (dir > 0 && !moveOnce(!first)) { break }
  16465. }
  16466. }
  16467. var result = skipAtomic(doc, pos, oldPos, origDir, true);
  16468. if (equalCursorPos(oldPos, result)) { result.hitSide = true; }
  16469. return result
  16470. }
  16471. // For relative vertical movement. Dir may be -1 or 1. Unit can be
  16472. // "page" or "line". The resulting position will have a hitSide=true
  16473. // property if it reached the end of the document.
  16474. function findPosV(cm, pos, dir, unit) {
  16475. var doc = cm.doc, x = pos.left, y;
  16476. if (unit == "page") {
  16477. var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight);
  16478. var moveAmount = Math.max(pageSize - .5 * textHeight(cm.display), 3);
  16479. y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
  16480. } else if (unit == "line") {
  16481. y = dir > 0 ? pos.bottom + 3 : pos.top - 3;
  16482. }
  16483. var target;
  16484. for (;;) {
  16485. target = coordsChar(cm, x, y);
  16486. if (!target.outside) { break }
  16487. if (dir < 0 ? y <= 0 : y >= doc.height) { target.hitSide = true; break }
  16488. y += dir * 5;
  16489. }
  16490. return target
  16491. }
  16492. // CONTENTEDITABLE INPUT STYLE
  16493. var ContentEditableInput = function(cm) {
  16494. this.cm = cm;
  16495. this.lastAnchorNode = this.lastAnchorOffset = this.lastFocusNode = this.lastFocusOffset = null;
  16496. this.polling = new Delayed();
  16497. this.composing = null;
  16498. this.gracePeriod = false;
  16499. this.readDOMTimeout = null;
  16500. };
  16501. ContentEditableInput.prototype.init = function (display) {
  16502. var this$1 = this;
  16503. var input = this, cm = input.cm;
  16504. var div = input.div = display.lineDiv;
  16505. disableBrowserMagic(div, cm.options.spellcheck);
  16506. on(div, "paste", function (e) {
  16507. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
  16508. // IE doesn't fire input events, so we schedule a read for the pasted content in this way
  16509. if (ie_version <= 11) { setTimeout(operation(cm, function () { return this$1.updateFromDOM(); }), 20); }
  16510. });
  16511. on(div, "compositionstart", function (e) {
  16512. this$1.composing = {data: e.data, done: false};
  16513. });
  16514. on(div, "compositionupdate", function (e) {
  16515. if (!this$1.composing) { this$1.composing = {data: e.data, done: false}; }
  16516. });
  16517. on(div, "compositionend", function (e) {
  16518. if (this$1.composing) {
  16519. if (e.data != this$1.composing.data) { this$1.readFromDOMSoon(); }
  16520. this$1.composing.done = true;
  16521. }
  16522. });
  16523. on(div, "touchstart", function () { return input.forceCompositionEnd(); });
  16524. on(div, "input", function () {
  16525. if (!this$1.composing) { this$1.readFromDOMSoon(); }
  16526. });
  16527. function onCopyCut(e) {
  16528. if (signalDOMEvent(cm, e)) { return }
  16529. if (cm.somethingSelected()) {
  16530. setLastCopied({lineWise: false, text: cm.getSelections()});
  16531. if (e.type == "cut") { cm.replaceSelection("", null, "cut"); }
  16532. } else if (!cm.options.lineWiseCopyCut) {
  16533. return
  16534. } else {
  16535. var ranges = copyableRanges(cm);
  16536. setLastCopied({lineWise: true, text: ranges.text});
  16537. if (e.type == "cut") {
  16538. cm.operation(function () {
  16539. cm.setSelections(ranges.ranges, 0, sel_dontScroll);
  16540. cm.replaceSelection("", null, "cut");
  16541. });
  16542. }
  16543. }
  16544. if (e.clipboardData) {
  16545. e.clipboardData.clearData();
  16546. var content = lastCopied.text.join("\n");
  16547. // iOS exposes the clipboard API, but seems to discard content inserted into it
  16548. e.clipboardData.setData("Text", content);
  16549. if (e.clipboardData.getData("Text") == content) {
  16550. e.preventDefault();
  16551. return
  16552. }
  16553. }
  16554. // Old-fashioned briefly-focus-a-textarea hack
  16555. var kludge = hiddenTextarea(), te = kludge.firstChild;
  16556. cm.display.lineSpace.insertBefore(kludge, cm.display.lineSpace.firstChild);
  16557. te.value = lastCopied.text.join("\n");
  16558. var hadFocus = document.activeElement;
  16559. selectInput(te);
  16560. setTimeout(function () {
  16561. cm.display.lineSpace.removeChild(kludge);
  16562. hadFocus.focus();
  16563. if (hadFocus == div) { input.showPrimarySelection(); }
  16564. }, 50);
  16565. }
  16566. on(div, "copy", onCopyCut);
  16567. on(div, "cut", onCopyCut);
  16568. };
  16569. ContentEditableInput.prototype.prepareSelection = function () {
  16570. var result = prepareSelection(this.cm, false);
  16571. result.focus = this.cm.state.focused;
  16572. return result
  16573. };
  16574. ContentEditableInput.prototype.showSelection = function (info, takeFocus) {
  16575. if (!info || !this.cm.display.view.length) { return }
  16576. if (info.focus || takeFocus) { this.showPrimarySelection(); }
  16577. this.showMultipleSelections(info);
  16578. };
  16579. ContentEditableInput.prototype.showPrimarySelection = function () {
  16580. var sel = window.getSelection(), cm = this.cm, prim = cm.doc.sel.primary();
  16581. var from = prim.from(), to = prim.to();
  16582. if (cm.display.viewTo == cm.display.viewFrom || from.line >= cm.display.viewTo || to.line < cm.display.viewFrom) {
  16583. sel.removeAllRanges();
  16584. return
  16585. }
  16586. var curAnchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  16587. var curFocus = domToPos(cm, sel.focusNode, sel.focusOffset);
  16588. if (curAnchor && !curAnchor.bad && curFocus && !curFocus.bad &&
  16589. cmp(minPos(curAnchor, curFocus), from) == 0 &&
  16590. cmp(maxPos(curAnchor, curFocus), to) == 0)
  16591. { return }
  16592. var view = cm.display.view;
  16593. var start = (from.line >= cm.display.viewFrom && posToDOM(cm, from)) ||
  16594. {node: view[0].measure.map[2], offset: 0};
  16595. var end = to.line < cm.display.viewTo && posToDOM(cm, to);
  16596. if (!end) {
  16597. var measure = view[view.length - 1].measure;
  16598. var map$$1 = measure.maps ? measure.maps[measure.maps.length - 1] : measure.map;
  16599. end = {node: map$$1[map$$1.length - 1], offset: map$$1[map$$1.length - 2] - map$$1[map$$1.length - 3]};
  16600. }
  16601. if (!start || !end) {
  16602. sel.removeAllRanges();
  16603. return
  16604. }
  16605. var old = sel.rangeCount && sel.getRangeAt(0), rng;
  16606. try { rng = range(start.node, start.offset, end.offset, end.node); }
  16607. catch(e) {} // Our model of the DOM might be outdated, in which case the range we try to set can be impossible
  16608. if (rng) {
  16609. if (!gecko && cm.state.focused) {
  16610. sel.collapse(start.node, start.offset);
  16611. if (!rng.collapsed) {
  16612. sel.removeAllRanges();
  16613. sel.addRange(rng);
  16614. }
  16615. } else {
  16616. sel.removeAllRanges();
  16617. sel.addRange(rng);
  16618. }
  16619. if (old && sel.anchorNode == null) { sel.addRange(old); }
  16620. else if (gecko) { this.startGracePeriod(); }
  16621. }
  16622. this.rememberSelection();
  16623. };
  16624. ContentEditableInput.prototype.startGracePeriod = function () {
  16625. var this$1 = this;
  16626. clearTimeout(this.gracePeriod);
  16627. this.gracePeriod = setTimeout(function () {
  16628. this$1.gracePeriod = false;
  16629. if (this$1.selectionChanged())
  16630. { this$1.cm.operation(function () { return this$1.cm.curOp.selectionChanged = true; }); }
  16631. }, 20);
  16632. };
  16633. ContentEditableInput.prototype.showMultipleSelections = function (info) {
  16634. removeChildrenAndAdd(this.cm.display.cursorDiv, info.cursors);
  16635. removeChildrenAndAdd(this.cm.display.selectionDiv, info.selection);
  16636. };
  16637. ContentEditableInput.prototype.rememberSelection = function () {
  16638. var sel = window.getSelection();
  16639. this.lastAnchorNode = sel.anchorNode; this.lastAnchorOffset = sel.anchorOffset;
  16640. this.lastFocusNode = sel.focusNode; this.lastFocusOffset = sel.focusOffset;
  16641. };
  16642. ContentEditableInput.prototype.selectionInEditor = function () {
  16643. var sel = window.getSelection();
  16644. if (!sel.rangeCount) { return false }
  16645. var node = sel.getRangeAt(0).commonAncestorContainer;
  16646. return contains(this.div, node)
  16647. };
  16648. ContentEditableInput.prototype.focus = function () {
  16649. if (this.cm.options.readOnly != "nocursor") {
  16650. if (!this.selectionInEditor())
  16651. { this.showSelection(this.prepareSelection(), true); }
  16652. this.div.focus();
  16653. }
  16654. };
  16655. ContentEditableInput.prototype.blur = function () { this.div.blur(); };
  16656. ContentEditableInput.prototype.getField = function () { return this.div };
  16657. ContentEditableInput.prototype.supportsTouch = function () { return true };
  16658. ContentEditableInput.prototype.receivedFocus = function () {
  16659. var input = this;
  16660. if (this.selectionInEditor())
  16661. { this.pollSelection(); }
  16662. else
  16663. { runInOp(this.cm, function () { return input.cm.curOp.selectionChanged = true; }); }
  16664. function poll() {
  16665. if (input.cm.state.focused) {
  16666. input.pollSelection();
  16667. input.polling.set(input.cm.options.pollInterval, poll);
  16668. }
  16669. }
  16670. this.polling.set(this.cm.options.pollInterval, poll);
  16671. };
  16672. ContentEditableInput.prototype.selectionChanged = function () {
  16673. var sel = window.getSelection();
  16674. return sel.anchorNode != this.lastAnchorNode || sel.anchorOffset != this.lastAnchorOffset ||
  16675. sel.focusNode != this.lastFocusNode || sel.focusOffset != this.lastFocusOffset
  16676. };
  16677. ContentEditableInput.prototype.pollSelection = function () {
  16678. if (this.readDOMTimeout != null || this.gracePeriod || !this.selectionChanged()) { return }
  16679. var sel = window.getSelection(), cm = this.cm;
  16680. // On Android Chrome (version 56, at least), backspacing into an
  16681. // uneditable block element will put the cursor in that element,
  16682. // and then, because it's not editable, hide the virtual keyboard.
  16683. // Because Android doesn't allow us to actually detect backspace
  16684. // presses in a sane way, this code checks for when that happens
  16685. // and simulates a backspace press in this case.
  16686. if (android && chrome && this.cm.options.gutters.length && isInGutter(sel.anchorNode)) {
  16687. this.cm.triggerOnKeyDown({type: "keydown", keyCode: 8, preventDefault: Math.abs});
  16688. this.blur();
  16689. this.focus();
  16690. return
  16691. }
  16692. if (this.composing) { return }
  16693. this.rememberSelection();
  16694. var anchor = domToPos(cm, sel.anchorNode, sel.anchorOffset);
  16695. var head = domToPos(cm, sel.focusNode, sel.focusOffset);
  16696. if (anchor && head) { runInOp(cm, function () {
  16697. setSelection(cm.doc, simpleSelection(anchor, head), sel_dontScroll);
  16698. if (anchor.bad || head.bad) { cm.curOp.selectionChanged = true; }
  16699. }); }
  16700. };
  16701. ContentEditableInput.prototype.pollContent = function () {
  16702. if (this.readDOMTimeout != null) {
  16703. clearTimeout(this.readDOMTimeout);
  16704. this.readDOMTimeout = null;
  16705. }
  16706. var cm = this.cm, display = cm.display, sel = cm.doc.sel.primary();
  16707. var from = sel.from(), to = sel.to();
  16708. if (from.ch == 0 && from.line > cm.firstLine())
  16709. { from = Pos(from.line - 1, getLine(cm.doc, from.line - 1).length); }
  16710. if (to.ch == getLine(cm.doc, to.line).text.length && to.line < cm.lastLine())
  16711. { to = Pos(to.line + 1, 0); }
  16712. if (from.line < display.viewFrom || to.line > display.viewTo - 1) { return false }
  16713. var fromIndex, fromLine, fromNode;
  16714. if (from.line == display.viewFrom || (fromIndex = findViewIndex(cm, from.line)) == 0) {
  16715. fromLine = lineNo(display.view[0].line);
  16716. fromNode = display.view[0].node;
  16717. } else {
  16718. fromLine = lineNo(display.view[fromIndex].line);
  16719. fromNode = display.view[fromIndex - 1].node.nextSibling;
  16720. }
  16721. var toIndex = findViewIndex(cm, to.line);
  16722. var toLine, toNode;
  16723. if (toIndex == display.view.length - 1) {
  16724. toLine = display.viewTo - 1;
  16725. toNode = display.lineDiv.lastChild;
  16726. } else {
  16727. toLine = lineNo(display.view[toIndex + 1].line) - 1;
  16728. toNode = display.view[toIndex + 1].node.previousSibling;
  16729. }
  16730. if (!fromNode) { return false }
  16731. var newText = cm.doc.splitLines(domTextBetween(cm, fromNode, toNode, fromLine, toLine));
  16732. var oldText = getBetween(cm.doc, Pos(fromLine, 0), Pos(toLine, getLine(cm.doc, toLine).text.length));
  16733. while (newText.length > 1 && oldText.length > 1) {
  16734. if (lst(newText) == lst(oldText)) { newText.pop(); oldText.pop(); toLine--; }
  16735. else if (newText[0] == oldText[0]) { newText.shift(); oldText.shift(); fromLine++; }
  16736. else { break }
  16737. }
  16738. var cutFront = 0, cutEnd = 0;
  16739. var newTop = newText[0], oldTop = oldText[0], maxCutFront = Math.min(newTop.length, oldTop.length);
  16740. while (cutFront < maxCutFront && newTop.charCodeAt(cutFront) == oldTop.charCodeAt(cutFront))
  16741. { ++cutFront; }
  16742. var newBot = lst(newText), oldBot = lst(oldText);
  16743. var maxCutEnd = Math.min(newBot.length - (newText.length == 1 ? cutFront : 0),
  16744. oldBot.length - (oldText.length == 1 ? cutFront : 0));
  16745. while (cutEnd < maxCutEnd &&
  16746. newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1))
  16747. { ++cutEnd; }
  16748. // Try to move start of change to start of selection if ambiguous
  16749. if (newText.length == 1 && oldText.length == 1 && fromLine == from.line) {
  16750. while (cutFront && cutFront > from.ch &&
  16751. newBot.charCodeAt(newBot.length - cutEnd - 1) == oldBot.charCodeAt(oldBot.length - cutEnd - 1)) {
  16752. cutFront--;
  16753. cutEnd++;
  16754. }
  16755. }
  16756. newText[newText.length - 1] = newBot.slice(0, newBot.length - cutEnd).replace(/^\u200b+/, "");
  16757. newText[0] = newText[0].slice(cutFront).replace(/\u200b+$/, "");
  16758. var chFrom = Pos(fromLine, cutFront);
  16759. var chTo = Pos(toLine, oldText.length ? lst(oldText).length - cutEnd : 0);
  16760. if (newText.length > 1 || newText[0] || cmp(chFrom, chTo)) {
  16761. replaceRange(cm.doc, newText, chFrom, chTo, "+input");
  16762. return true
  16763. }
  16764. };
  16765. ContentEditableInput.prototype.ensurePolled = function () {
  16766. this.forceCompositionEnd();
  16767. };
  16768. ContentEditableInput.prototype.reset = function () {
  16769. this.forceCompositionEnd();
  16770. };
  16771. ContentEditableInput.prototype.forceCompositionEnd = function () {
  16772. if (!this.composing) { return }
  16773. clearTimeout(this.readDOMTimeout);
  16774. this.composing = null;
  16775. this.updateFromDOM();
  16776. this.div.blur();
  16777. this.div.focus();
  16778. };
  16779. ContentEditableInput.prototype.readFromDOMSoon = function () {
  16780. var this$1 = this;
  16781. if (this.readDOMTimeout != null) { return }
  16782. this.readDOMTimeout = setTimeout(function () {
  16783. this$1.readDOMTimeout = null;
  16784. if (this$1.composing) {
  16785. if (this$1.composing.done) { this$1.composing = null; }
  16786. else { return }
  16787. }
  16788. this$1.updateFromDOM();
  16789. }, 80);
  16790. };
  16791. ContentEditableInput.prototype.updateFromDOM = function () {
  16792. var this$1 = this;
  16793. if (this.cm.isReadOnly() || !this.pollContent())
  16794. { runInOp(this.cm, function () { return regChange(this$1.cm); }); }
  16795. };
  16796. ContentEditableInput.prototype.setUneditable = function (node) {
  16797. node.contentEditable = "false";
  16798. };
  16799. ContentEditableInput.prototype.onKeyPress = function (e) {
  16800. if (e.charCode == 0 || this.composing) { return }
  16801. e.preventDefault();
  16802. if (!this.cm.isReadOnly())
  16803. { operation(this.cm, applyTextInput)(this.cm, String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode), 0); }
  16804. };
  16805. ContentEditableInput.prototype.readOnlyChanged = function (val) {
  16806. this.div.contentEditable = String(val != "nocursor");
  16807. };
  16808. ContentEditableInput.prototype.onContextMenu = function () {};
  16809. ContentEditableInput.prototype.resetPosition = function () {};
  16810. ContentEditableInput.prototype.needsContentAttribute = true;
  16811. function posToDOM(cm, pos) {
  16812. var view = findViewForLine(cm, pos.line);
  16813. if (!view || view.hidden) { return null }
  16814. var line = getLine(cm.doc, pos.line);
  16815. var info = mapFromLineView(view, line, pos.line);
  16816. var order = getOrder(line, cm.doc.direction), side = "left";
  16817. if (order) {
  16818. var partPos = getBidiPartAt(order, pos.ch);
  16819. side = partPos % 2 ? "right" : "left";
  16820. }
  16821. var result = nodeAndOffsetInLineMap(info.map, pos.ch, side);
  16822. result.offset = result.collapse == "right" ? result.end : result.start;
  16823. return result
  16824. }
  16825. function isInGutter(node) {
  16826. for (var scan = node; scan; scan = scan.parentNode)
  16827. { if (/CodeMirror-gutter-wrapper/.test(scan.className)) { return true } }
  16828. return false
  16829. }
  16830. function badPos(pos, bad) { if (bad) { pos.bad = true; } return pos }
  16831. function domTextBetween(cm, from, to, fromLine, toLine) {
  16832. var text = "", closing = false, lineSep = cm.doc.lineSeparator();
  16833. function recognizeMarker(id) { return function (marker) { return marker.id == id; } }
  16834. function close() {
  16835. if (closing) {
  16836. text += lineSep;
  16837. closing = false;
  16838. }
  16839. }
  16840. function addText(str) {
  16841. if (str) {
  16842. close();
  16843. text += str;
  16844. }
  16845. }
  16846. function walk(node) {
  16847. if (node.nodeType == 1) {
  16848. var cmText = node.getAttribute("cm-text");
  16849. if (cmText != null) {
  16850. addText(cmText || node.textContent.replace(/\u200b/g, ""));
  16851. return
  16852. }
  16853. var markerID = node.getAttribute("cm-marker"), range$$1;
  16854. if (markerID) {
  16855. var found = cm.findMarks(Pos(fromLine, 0), Pos(toLine + 1, 0), recognizeMarker(+markerID));
  16856. if (found.length && (range$$1 = found[0].find(0)))
  16857. { addText(getBetween(cm.doc, range$$1.from, range$$1.to).join(lineSep)); }
  16858. return
  16859. }
  16860. if (node.getAttribute("contenteditable") == "false") { return }
  16861. var isBlock = /^(pre|div|p)$/i.test(node.nodeName);
  16862. if (isBlock) { close(); }
  16863. for (var i = 0; i < node.childNodes.length; i++)
  16864. { walk(node.childNodes[i]); }
  16865. if (isBlock) { closing = true; }
  16866. } else if (node.nodeType == 3) {
  16867. addText(node.nodeValue);
  16868. }
  16869. }
  16870. for (;;) {
  16871. walk(from);
  16872. if (from == to) { break }
  16873. from = from.nextSibling;
  16874. }
  16875. return text
  16876. }
  16877. function domToPos(cm, node, offset) {
  16878. var lineNode;
  16879. if (node == cm.display.lineDiv) {
  16880. lineNode = cm.display.lineDiv.childNodes[offset];
  16881. if (!lineNode) { return badPos(cm.clipPos(Pos(cm.display.viewTo - 1)), true) }
  16882. node = null; offset = 0;
  16883. } else {
  16884. for (lineNode = node;; lineNode = lineNode.parentNode) {
  16885. if (!lineNode || lineNode == cm.display.lineDiv) { return null }
  16886. if (lineNode.parentNode && lineNode.parentNode == cm.display.lineDiv) { break }
  16887. }
  16888. }
  16889. for (var i = 0; i < cm.display.view.length; i++) {
  16890. var lineView = cm.display.view[i];
  16891. if (lineView.node == lineNode)
  16892. { return locateNodeInLineView(lineView, node, offset) }
  16893. }
  16894. }
  16895. function locateNodeInLineView(lineView, node, offset) {
  16896. var wrapper = lineView.text.firstChild, bad = false;
  16897. if (!node || !contains(wrapper, node)) { return badPos(Pos(lineNo(lineView.line), 0), true) }
  16898. if (node == wrapper) {
  16899. bad = true;
  16900. node = wrapper.childNodes[offset];
  16901. offset = 0;
  16902. if (!node) {
  16903. var line = lineView.rest ? lst(lineView.rest) : lineView.line;
  16904. return badPos(Pos(lineNo(line), line.text.length), bad)
  16905. }
  16906. }
  16907. var textNode = node.nodeType == 3 ? node : null, topNode = node;
  16908. if (!textNode && node.childNodes.length == 1 && node.firstChild.nodeType == 3) {
  16909. textNode = node.firstChild;
  16910. if (offset) { offset = textNode.nodeValue.length; }
  16911. }
  16912. while (topNode.parentNode != wrapper) { topNode = topNode.parentNode; }
  16913. var measure = lineView.measure, maps = measure.maps;
  16914. function find(textNode, topNode, offset) {
  16915. for (var i = -1; i < (maps ? maps.length : 0); i++) {
  16916. var map$$1 = i < 0 ? measure.map : maps[i];
  16917. for (var j = 0; j < map$$1.length; j += 3) {
  16918. var curNode = map$$1[j + 2];
  16919. if (curNode == textNode || curNode == topNode) {
  16920. var line = lineNo(i < 0 ? lineView.line : lineView.rest[i]);
  16921. var ch = map$$1[j] + offset;
  16922. if (offset < 0 || curNode != textNode) { ch = map$$1[j + (offset ? 1 : 0)]; }
  16923. return Pos(line, ch)
  16924. }
  16925. }
  16926. }
  16927. }
  16928. var found = find(textNode, topNode, offset);
  16929. if (found) { return badPos(found, bad) }
  16930. // FIXME this is all really shaky. might handle the few cases it needs to handle, but likely to cause problems
  16931. for (var after = topNode.nextSibling, dist = textNode ? textNode.nodeValue.length - offset : 0; after; after = after.nextSibling) {
  16932. found = find(after, after.firstChild, 0);
  16933. if (found)
  16934. { return badPos(Pos(found.line, found.ch - dist), bad) }
  16935. else
  16936. { dist += after.textContent.length; }
  16937. }
  16938. for (var before = topNode.previousSibling, dist$1 = offset; before; before = before.previousSibling) {
  16939. found = find(before, before.firstChild, -1);
  16940. if (found)
  16941. { return badPos(Pos(found.line, found.ch + dist$1), bad) }
  16942. else
  16943. { dist$1 += before.textContent.length; }
  16944. }
  16945. }
  16946. // TEXTAREA INPUT STYLE
  16947. var TextareaInput = function(cm) {
  16948. this.cm = cm;
  16949. // See input.poll and input.reset
  16950. this.prevInput = "";
  16951. // Flag that indicates whether we expect input to appear real soon
  16952. // now (after some event like 'keypress' or 'input') and are
  16953. // polling intensively.
  16954. this.pollingFast = false;
  16955. // Self-resetting timeout for the poller
  16956. this.polling = new Delayed();
  16957. // Used to work around IE issue with selection being forgotten when focus moves away from textarea
  16958. this.hasSelection = false;
  16959. this.composing = null;
  16960. };
  16961. TextareaInput.prototype.init = function (display) {
  16962. var this$1 = this;
  16963. var input = this, cm = this.cm;
  16964. this.createField(display);
  16965. var te = this.textarea;
  16966. display.wrapper.insertBefore(this.wrapper, display.wrapper.firstChild);
  16967. // Needed to hide big blue blinking cursor on Mobile Safari (doesn't seem to work in iOS 8 anymore)
  16968. if (ios) { te.style.width = "0px"; }
  16969. on(te, "input", function () {
  16970. if (ie && ie_version >= 9 && this$1.hasSelection) { this$1.hasSelection = null; }
  16971. input.poll();
  16972. });
  16973. on(te, "paste", function (e) {
  16974. if (signalDOMEvent(cm, e) || handlePaste(e, cm)) { return }
  16975. cm.state.pasteIncoming = true;
  16976. input.fastPoll();
  16977. });
  16978. function prepareCopyCut(e) {
  16979. if (signalDOMEvent(cm, e)) { return }
  16980. if (cm.somethingSelected()) {
  16981. setLastCopied({lineWise: false, text: cm.getSelections()});
  16982. } else if (!cm.options.lineWiseCopyCut) {
  16983. return
  16984. } else {
  16985. var ranges = copyableRanges(cm);
  16986. setLastCopied({lineWise: true, text: ranges.text});
  16987. if (e.type == "cut") {
  16988. cm.setSelections(ranges.ranges, null, sel_dontScroll);
  16989. } else {
  16990. input.prevInput = "";
  16991. te.value = ranges.text.join("\n");
  16992. selectInput(te);
  16993. }
  16994. }
  16995. if (e.type == "cut") { cm.state.cutIncoming = true; }
  16996. }
  16997. on(te, "cut", prepareCopyCut);
  16998. on(te, "copy", prepareCopyCut);
  16999. on(display.scroller, "paste", function (e) {
  17000. if (eventInWidget(display, e) || signalDOMEvent(cm, e)) { return }
  17001. cm.state.pasteIncoming = true;
  17002. input.focus();
  17003. });
  17004. // Prevent normal selection in the editor (we handle our own)
  17005. on(display.lineSpace, "selectstart", function (e) {
  17006. if (!eventInWidget(display, e)) { e_preventDefault(e); }
  17007. });
  17008. on(te, "compositionstart", function () {
  17009. var start = cm.getCursor("from");
  17010. if (input.composing) { input.composing.range.clear(); }
  17011. input.composing = {
  17012. start: start,
  17013. range: cm.markText(start, cm.getCursor("to"), {className: "CodeMirror-composing"})
  17014. };
  17015. });
  17016. on(te, "compositionend", function () {
  17017. if (input.composing) {
  17018. input.poll();
  17019. input.composing.range.clear();
  17020. input.composing = null;
  17021. }
  17022. });
  17023. };
  17024. TextareaInput.prototype.createField = function (_display) {
  17025. // Wraps and hides input textarea
  17026. this.wrapper = hiddenTextarea();
  17027. // The semihidden textarea that is focused when the editor is
  17028. // focused, and receives input.
  17029. this.textarea = this.wrapper.firstChild;
  17030. };
  17031. TextareaInput.prototype.prepareSelection = function () {
  17032. // Redraw the selection and/or cursor
  17033. var cm = this.cm, display = cm.display, doc = cm.doc;
  17034. var result = prepareSelection(cm);
  17035. // Move the hidden textarea near the cursor to prevent scrolling artifacts
  17036. if (cm.options.moveInputWithCursor) {
  17037. var headPos = cursorCoords(cm, doc.sel.primary().head, "div");
  17038. var wrapOff = display.wrapper.getBoundingClientRect(), lineOff = display.lineDiv.getBoundingClientRect();
  17039. result.teTop = Math.max(0, Math.min(display.wrapper.clientHeight - 10,
  17040. headPos.top + lineOff.top - wrapOff.top));
  17041. result.teLeft = Math.max(0, Math.min(display.wrapper.clientWidth - 10,
  17042. headPos.left + lineOff.left - wrapOff.left));
  17043. }
  17044. return result
  17045. };
  17046. TextareaInput.prototype.showSelection = function (drawn) {
  17047. var cm = this.cm, display = cm.display;
  17048. removeChildrenAndAdd(display.cursorDiv, drawn.cursors);
  17049. removeChildrenAndAdd(display.selectionDiv, drawn.selection);
  17050. if (drawn.teTop != null) {
  17051. this.wrapper.style.top = drawn.teTop + "px";
  17052. this.wrapper.style.left = drawn.teLeft + "px";
  17053. }
  17054. };
  17055. // Reset the input to correspond to the selection (or to be empty,
  17056. // when not typing and nothing is selected)
  17057. TextareaInput.prototype.reset = function (typing) {
  17058. if (this.contextMenuPending || this.composing) { return }
  17059. var cm = this.cm;
  17060. if (cm.somethingSelected()) {
  17061. this.prevInput = "";
  17062. var content = cm.getSelection();
  17063. this.textarea.value = content;
  17064. if (cm.state.focused) { selectInput(this.textarea); }
  17065. if (ie && ie_version >= 9) { this.hasSelection = content; }
  17066. } else if (!typing) {
  17067. this.prevInput = this.textarea.value = "";
  17068. if (ie && ie_version >= 9) { this.hasSelection = null; }
  17069. }
  17070. };
  17071. TextareaInput.prototype.getField = function () { return this.textarea };
  17072. TextareaInput.prototype.supportsTouch = function () { return false };
  17073. TextareaInput.prototype.focus = function () {
  17074. if (this.cm.options.readOnly != "nocursor" && (!mobile || activeElt() != this.textarea)) {
  17075. try { this.textarea.focus(); }
  17076. catch (e) {} // IE8 will throw if the textarea is display: none or not in DOM
  17077. }
  17078. };
  17079. TextareaInput.prototype.blur = function () { this.textarea.blur(); };
  17080. TextareaInput.prototype.resetPosition = function () {
  17081. this.wrapper.style.top = this.wrapper.style.left = 0;
  17082. };
  17083. TextareaInput.prototype.receivedFocus = function () { this.slowPoll(); };
  17084. // Poll for input changes, using the normal rate of polling. This
  17085. // runs as long as the editor is focused.
  17086. TextareaInput.prototype.slowPoll = function () {
  17087. var this$1 = this;
  17088. if (this.pollingFast) { return }
  17089. this.polling.set(this.cm.options.pollInterval, function () {
  17090. this$1.poll();
  17091. if (this$1.cm.state.focused) { this$1.slowPoll(); }
  17092. });
  17093. };
  17094. // When an event has just come in that is likely to add or change
  17095. // something in the input textarea, we poll faster, to ensure that
  17096. // the change appears on the screen quickly.
  17097. TextareaInput.prototype.fastPoll = function () {
  17098. var missed = false, input = this;
  17099. input.pollingFast = true;
  17100. function p() {
  17101. var changed = input.poll();
  17102. if (!changed && !missed) {missed = true; input.polling.set(60, p);}
  17103. else {input.pollingFast = false; input.slowPoll();}
  17104. }
  17105. input.polling.set(20, p);
  17106. };
  17107. // Read input from the textarea, and update the document to match.
  17108. // When something is selected, it is present in the textarea, and
  17109. // selected (unless it is huge, in which case a placeholder is
  17110. // used). When nothing is selected, the cursor sits after previously
  17111. // seen text (can be empty), which is stored in prevInput (we must
  17112. // not reset the textarea when typing, because that breaks IME).
  17113. TextareaInput.prototype.poll = function () {
  17114. var this$1 = this;
  17115. var cm = this.cm, input = this.textarea, prevInput = this.prevInput;
  17116. // Since this is called a *lot*, try to bail out as cheaply as
  17117. // possible when it is clear that nothing happened. hasSelection
  17118. // will be the case when there is a lot of text in the textarea,
  17119. // in which case reading its value would be expensive.
  17120. if (this.contextMenuPending || !cm.state.focused ||
  17121. (hasSelection(input) && !prevInput && !this.composing) ||
  17122. cm.isReadOnly() || cm.options.disableInput || cm.state.keySeq)
  17123. { return false }
  17124. var text = input.value;
  17125. // If nothing changed, bail.
  17126. if (text == prevInput && !cm.somethingSelected()) { return false }
  17127. // Work around nonsensical selection resetting in IE9/10, and
  17128. // inexplicable appearance of private area unicode characters on
  17129. // some key combos in Mac (#2689).
  17130. if (ie && ie_version >= 9 && this.hasSelection === text ||
  17131. mac && /[\uf700-\uf7ff]/.test(text)) {
  17132. cm.display.input.reset();
  17133. return false
  17134. }
  17135. if (cm.doc.sel == cm.display.selForContextMenu) {
  17136. var first = text.charCodeAt(0);
  17137. if (first == 0x200b && !prevInput) { prevInput = "\u200b"; }
  17138. if (first == 0x21da) { this.reset(); return this.cm.execCommand("undo") }
  17139. }
  17140. // Find the part of the input that is actually new
  17141. var same = 0, l = Math.min(prevInput.length, text.length);
  17142. while (same < l && prevInput.charCodeAt(same) == text.charCodeAt(same)) { ++same; }
  17143. runInOp(cm, function () {
  17144. applyTextInput(cm, text.slice(same), prevInput.length - same,
  17145. null, this$1.composing ? "*compose" : null);
  17146. // Don't leave long text in the textarea, since it makes further polling slow
  17147. if (text.length > 1000 || text.indexOf("\n") > -1) { input.value = this$1.prevInput = ""; }
  17148. else { this$1.prevInput = text; }
  17149. if (this$1.composing) {
  17150. this$1.composing.range.clear();
  17151. this$1.composing.range = cm.markText(this$1.composing.start, cm.getCursor("to"),
  17152. {className: "CodeMirror-composing"});
  17153. }
  17154. });
  17155. return true
  17156. };
  17157. TextareaInput.prototype.ensurePolled = function () {
  17158. if (this.pollingFast && this.poll()) { this.pollingFast = false; }
  17159. };
  17160. TextareaInput.prototype.onKeyPress = function () {
  17161. if (ie && ie_version >= 9) { this.hasSelection = null; }
  17162. this.fastPoll();
  17163. };
  17164. TextareaInput.prototype.onContextMenu = function (e) {
  17165. var input = this, cm = input.cm, display = cm.display, te = input.textarea;
  17166. var pos = posFromMouse(cm, e), scrollPos = display.scroller.scrollTop;
  17167. if (!pos || presto) { return } // Opera is difficult.
  17168. // Reset the current text selection only if the click is done outside of the selection
  17169. // and 'resetSelectionOnContextMenu' option is true.
  17170. var reset = cm.options.resetSelectionOnContextMenu;
  17171. if (reset && cm.doc.sel.contains(pos) == -1)
  17172. { operation(cm, setSelection)(cm.doc, simpleSelection(pos), sel_dontScroll); }
  17173. var oldCSS = te.style.cssText, oldWrapperCSS = input.wrapper.style.cssText;
  17174. input.wrapper.style.cssText = "position: absolute";
  17175. var wrapperBox = input.wrapper.getBoundingClientRect();
  17176. 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);";
  17177. var oldScrollY;
  17178. if (webkit) { oldScrollY = window.scrollY; } // Work around Chrome issue (#2712)
  17179. display.input.focus();
  17180. if (webkit) { window.scrollTo(null, oldScrollY); }
  17181. display.input.reset();
  17182. // Adds "Select all" to context menu in FF
  17183. if (!cm.somethingSelected()) { te.value = input.prevInput = " "; }
  17184. input.contextMenuPending = true;
  17185. display.selForContextMenu = cm.doc.sel;
  17186. clearTimeout(display.detectingSelectAll);
  17187. // Select-all will be greyed out if there's nothing to select, so
  17188. // this adds a zero-width space so that we can later check whether
  17189. // it got selected.
  17190. function prepareSelectAllHack() {
  17191. if (te.selectionStart != null) {
  17192. var selected = cm.somethingSelected();
  17193. var extval = "\u200b" + (selected ? te.value : "");
  17194. te.value = "\u21da"; // Used to catch context-menu undo
  17195. te.value = extval;
  17196. input.prevInput = selected ? "" : "\u200b";
  17197. te.selectionStart = 1; te.selectionEnd = extval.length;
  17198. // Re-set this, in case some other handler touched the
  17199. // selection in the meantime.
  17200. display.selForContextMenu = cm.doc.sel;
  17201. }
  17202. }
  17203. function rehide() {
  17204. input.contextMenuPending = false;
  17205. input.wrapper.style.cssText = oldWrapperCSS;
  17206. te.style.cssText = oldCSS;
  17207. if (ie && ie_version < 9) { display.scrollbars.setScrollTop(display.scroller.scrollTop = scrollPos); }
  17208. // Try to detect the user choosing select-all
  17209. if (te.selectionStart != null) {
  17210. if (!ie || (ie && ie_version < 9)) { prepareSelectAllHack(); }
  17211. var i = 0, poll = function () {
  17212. if (display.selForContextMenu == cm.doc.sel && te.selectionStart == 0 &&
  17213. te.selectionEnd > 0 && input.prevInput == "\u200b") {
  17214. operation(cm, selectAll)(cm);
  17215. } else if (i++ < 10) {
  17216. display.detectingSelectAll = setTimeout(poll, 500);
  17217. } else {
  17218. display.selForContextMenu = null;
  17219. display.input.reset();
  17220. }
  17221. };
  17222. display.detectingSelectAll = setTimeout(poll, 200);
  17223. }
  17224. }
  17225. if (ie && ie_version >= 9) { prepareSelectAllHack(); }
  17226. if (captureRightClick) {
  17227. e_stop(e);
  17228. var mouseup = function () {
  17229. off(window, "mouseup", mouseup);
  17230. setTimeout(rehide, 20);
  17231. };
  17232. on(window, "mouseup", mouseup);
  17233. } else {
  17234. setTimeout(rehide, 50);
  17235. }
  17236. };
  17237. TextareaInput.prototype.readOnlyChanged = function (val) {
  17238. if (!val) { this.reset(); }
  17239. this.textarea.disabled = val == "nocursor";
  17240. };
  17241. TextareaInput.prototype.setUneditable = function () {};
  17242. TextareaInput.prototype.needsContentAttribute = false;
  17243. function fromTextArea(textarea, options) {
  17244. options = options ? copyObj(options) : {};
  17245. options.value = textarea.value;
  17246. if (!options.tabindex && textarea.tabIndex)
  17247. { options.tabindex = textarea.tabIndex; }
  17248. if (!options.placeholder && textarea.placeholder)
  17249. { options.placeholder = textarea.placeholder; }
  17250. // Set autofocus to true if this textarea is focused, or if it has
  17251. // autofocus and no other element is focused.
  17252. if (options.autofocus == null) {
  17253. var hasFocus = activeElt();
  17254. options.autofocus = hasFocus == textarea ||
  17255. textarea.getAttribute("autofocus") != null && hasFocus == document.body;
  17256. }
  17257. function save() {textarea.value = cm.getValue();}
  17258. var realSubmit;
  17259. if (textarea.form) {
  17260. on(textarea.form, "submit", save);
  17261. // Deplorable hack to make the submit method do the right thing.
  17262. if (!options.leaveSubmitMethodAlone) {
  17263. var form = textarea.form;
  17264. realSubmit = form.submit;
  17265. try {
  17266. var wrappedSubmit = form.submit = function () {
  17267. save();
  17268. form.submit = realSubmit;
  17269. form.submit();
  17270. form.submit = wrappedSubmit;
  17271. };
  17272. } catch(e) {}
  17273. }
  17274. }
  17275. options.finishInit = function (cm) {
  17276. cm.save = save;
  17277. cm.getTextArea = function () { return textarea; };
  17278. cm.toTextArea = function () {
  17279. cm.toTextArea = isNaN; // Prevent this from being ran twice
  17280. save();
  17281. textarea.parentNode.removeChild(cm.getWrapperElement());
  17282. textarea.style.display = "";
  17283. if (textarea.form) {
  17284. off(textarea.form, "submit", save);
  17285. if (typeof textarea.form.submit == "function")
  17286. { textarea.form.submit = realSubmit; }
  17287. }
  17288. };
  17289. };
  17290. textarea.style.display = "none";
  17291. var cm = CodeMirror$1(function (node) { return textarea.parentNode.insertBefore(node, textarea.nextSibling); },
  17292. options);
  17293. return cm
  17294. }
  17295. function addLegacyProps(CodeMirror) {
  17296. CodeMirror.off = off;
  17297. CodeMirror.on = on;
  17298. CodeMirror.wheelEventPixels = wheelEventPixels;
  17299. CodeMirror.Doc = Doc;
  17300. CodeMirror.splitLines = splitLinesAuto;
  17301. CodeMirror.countColumn = countColumn;
  17302. CodeMirror.findColumn = findColumn;
  17303. CodeMirror.isWordChar = isWordCharBasic;
  17304. CodeMirror.Pass = Pass;
  17305. CodeMirror.signal = signal;
  17306. CodeMirror.Line = Line;
  17307. CodeMirror.changeEnd = changeEnd;
  17308. CodeMirror.scrollbarModel = scrollbarModel;
  17309. CodeMirror.Pos = Pos;
  17310. CodeMirror.cmpPos = cmp;
  17311. CodeMirror.modes = modes;
  17312. CodeMirror.mimeModes = mimeModes;
  17313. CodeMirror.resolveMode = resolveMode;
  17314. CodeMirror.getMode = getMode;
  17315. CodeMirror.modeExtensions = modeExtensions;
  17316. CodeMirror.extendMode = extendMode;
  17317. CodeMirror.copyState = copyState;
  17318. CodeMirror.startState = startState;
  17319. CodeMirror.innerMode = innerMode;
  17320. CodeMirror.commands = commands;
  17321. CodeMirror.keyMap = keyMap;
  17322. CodeMirror.keyName = keyName;
  17323. CodeMirror.isModifierKey = isModifierKey;
  17324. CodeMirror.lookupKey = lookupKey;
  17325. CodeMirror.normalizeKeyMap = normalizeKeyMap;
  17326. CodeMirror.StringStream = StringStream;
  17327. CodeMirror.SharedTextMarker = SharedTextMarker;
  17328. CodeMirror.TextMarker = TextMarker;
  17329. CodeMirror.LineWidget = LineWidget;
  17330. CodeMirror.e_preventDefault = e_preventDefault;
  17331. CodeMirror.e_stopPropagation = e_stopPropagation;
  17332. CodeMirror.e_stop = e_stop;
  17333. CodeMirror.addClass = addClass;
  17334. CodeMirror.contains = contains;
  17335. CodeMirror.rmClass = rmClass;
  17336. CodeMirror.keyNames = keyNames;
  17337. }
  17338. // EDITOR CONSTRUCTOR
  17339. defineOptions(CodeMirror$1);
  17340. addEditorMethods(CodeMirror$1);
  17341. // Set up methods on CodeMirror's prototype to redirect to the editor's document.
  17342. var dontDelegate = "iter insert remove copy getEditor constructor".split(" ");
  17343. for (var prop in Doc.prototype) { if (Doc.prototype.hasOwnProperty(prop) && indexOf(dontDelegate, prop) < 0)
  17344. { CodeMirror$1.prototype[prop] = (function(method) {
  17345. return function() {return method.apply(this.doc, arguments)}
  17346. })(Doc.prototype[prop]); } }
  17347. eventMixin(Doc);
  17348. // INPUT HANDLING
  17349. CodeMirror$1.inputStyles = {"textarea": TextareaInput, "contenteditable": ContentEditableInput};
  17350. // MODE DEFINITION AND QUERYING
  17351. // Extra arguments are stored as the mode's dependencies, which is
  17352. // used by (legacy) mechanisms like loadmode.js to automatically
  17353. // load a mode. (Preferred mechanism is the require/define calls.)
  17354. CodeMirror$1.defineMode = function(name/*, mode, …*/) {
  17355. if (!CodeMirror$1.defaults.mode && name != "null") { CodeMirror$1.defaults.mode = name; }
  17356. defineMode.apply(this, arguments);
  17357. };
  17358. CodeMirror$1.defineMIME = defineMIME;
  17359. // Minimal default mode.
  17360. CodeMirror$1.defineMode("null", function () { return ({token: function (stream) { return stream.skipToEnd(); }}); });
  17361. CodeMirror$1.defineMIME("text/plain", "null");
  17362. // EXTENSIONS
  17363. CodeMirror$1.defineExtension = function (name, func) {
  17364. CodeMirror$1.prototype[name] = func;
  17365. };
  17366. CodeMirror$1.defineDocExtension = function (name, func) {
  17367. Doc.prototype[name] = func;
  17368. };
  17369. CodeMirror$1.fromTextArea = fromTextArea;
  17370. addLegacyProps(CodeMirror$1);
  17371. CodeMirror$1.version = "5.37.0";
  17372. return CodeMirror$1;
  17373. })));
  17374. /*!
  17375. * Bootstrap v3.4.1 (https://getbootstrap.com/)
  17376. * Copyright 2011-2019 Twitter, Inc.
  17377. * Licensed under the MIT license
  17378. */
  17379. if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");!function(t){"use strict";var e=jQuery.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1==e[0]&&9==e[1]&&e[2]<1||3<e[0])throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(),function(n){"use strict";n.fn.emulateTransitionEnd=function(t){var e=!1,i=this;n(this).one("bsTransitionEnd",function(){e=!0});return setTimeout(function(){e||n(i).trigger(n.support.transition.end)},t),this},n(function(){n.support.transition=function o(){var t=document.createElement("bootstrap"),e={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var i in e)if(t.style[i]!==undefined)return{end:e[i]};return!1}(),n.support.transition&&(n.event.special.bsTransitionEnd={bindType:n.support.transition.end,delegateType:n.support.transition.end,handle:function(t){if(n(t.target).is(this))return t.handleObj.handler.apply(this,arguments)}})})}(jQuery),function(s){"use strict";var e='[data-dismiss="alert"]',a=function(t){s(t).on("click",e,this.close)};a.VERSION="3.4.1",a.TRANSITION_DURATION=150,a.prototype.close=function(t){var e=s(this),i=e.attr("data-target");i||(i=(i=e.attr("href"))&&i.replace(/.*(?=#[^\s]*$)/,"")),i="#"===i?[]:i;var o=s(document).find(i);function n(){o.detach().trigger("closed.bs.alert").remove()}t&&t.preventDefault(),o.length||(o=e.closest(".alert")),o.trigger(t=s.Event("close.bs.alert")),t.isDefaultPrevented()||(o.removeClass("in"),s.support.transition&&o.hasClass("fade")?o.one("bsTransitionEnd",n).emulateTransitionEnd(a.TRANSITION_DURATION):n())};var t=s.fn.alert;s.fn.alert=function o(i){return this.each(function(){var t=s(this),e=t.data("bs.alert");e||t.data("bs.alert",e=new a(this)),"string"==typeof i&&e[i].call(t)})},s.fn.alert.Constructor=a,s.fn.alert.noConflict=function(){return s.fn.alert=t,this},s(document).on("click.bs.alert.data-api",e,a.prototype.close)}(jQuery),function(s){"use strict";var n=function(t,e){this.$element=s(t),this.options=s.extend({},n.DEFAULTS,e),this.isLoading=!1};function i(o){return this.each(function(){var t=s(this),e=t.data("bs.button"),i="object"==typeof o&&o;e||t.data("bs.button",e=new n(this,i)),"toggle"==o?e.toggle():o&&e.setState(o)})}n.VERSION="3.4.1",n.DEFAULTS={loadingText:"loading..."},n.prototype.setState=function(t){var e="disabled",i=this.$element,o=i.is("input")?"val":"html",n=i.data();t+="Text",null==n.resetText&&i.data("resetText",i[o]()),setTimeout(s.proxy(function(){i[o](null==n[t]?this.options[t]:n[t]),"loadingText"==t?(this.isLoading=!0,i.addClass(e).attr(e,e).prop(e,!0)):this.isLoading&&(this.isLoading=!1,i.removeClass(e).removeAttr(e).prop(e,!1))},this),0)},n.prototype.toggle=function(){var t=!0,e=this.$element.closest('[data-toggle="buttons"]');if(e.length){var i=this.$element.find("input");"radio"==i.prop("type")?(i.prop("checked")&&(t=!1),e.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==i.prop("type")&&(i.prop("checked")!==this.$element.hasClass("active")&&(t=!1),this.$element.toggleClass("active")),i.prop("checked",this.$element.hasClass("active")),t&&i.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var t=s.fn.button;s.fn.button=i,s.fn.button.Constructor=n,s.fn.button.noConflict=function(){return s.fn.button=t,this},s(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(t){var e=s(t.target).closest(".btn");i.call(e,"toggle"),s(t.target).is('input[type="radio"], input[type="checkbox"]')||(t.preventDefault(),e.is("input,button")?e.trigger("focus"):e.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(t){s(t.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(t.type))})}(jQuery),function(p){"use strict";var c=function(t,e){this.$element=p(t),this.$indicators=this.$element.find(".carousel-indicators"),this.options=e,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",p.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",p.proxy(this.pause,this)).on("mouseleave.bs.carousel",p.proxy(this.cycle,this))};function r(n){return this.each(function(){var t=p(this),e=t.data("bs.carousel"),i=p.extend({},c.DEFAULTS,t.data(),"object"==typeof n&&n),o="string"==typeof n?n:i.slide;e||t.data("bs.carousel",e=new c(this,i)),"number"==typeof n?e.to(n):o?e[o]():i.interval&&e.pause().cycle()})}c.VERSION="3.4.1",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(t){if(!/input|textarea/i.test(t.target.tagName)){switch(t.which){case 37:this.prev();break;case 39:this.next();break;default:return}t.preventDefault()}},c.prototype.cycle=function(t){return t||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(p.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(t){return this.$items=t.parent().children(".item"),this.$items.index(t||this.$active)},c.prototype.getItemForDirection=function(t,e){var i=this.getItemIndex(e);if(("prev"==t&&0===i||"next"==t&&i==this.$items.length-1)&&!this.options.wrap)return e;var o=(i+("prev"==t?-1:1))%this.$items.length;return this.$items.eq(o)},c.prototype.to=function(t){var e=this,i=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(t>this.$items.length-1||t<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){e.to(t)}):i==t?this.pause().cycle():this.slide(i<t?"next":"prev",this.$items.eq(t))},c.prototype.pause=function(t){return t||(this.paused=!0),this.$element.find(".next, .prev").length&&p.support.transition&&(this.$element.trigger(p.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){if(!this.sliding)return this.slide("next")},c.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},c.prototype.slide=function(t,e){var i=this.$element.find(".item.active"),o=e||this.getItemForDirection(t,i),n=this.interval,s="next"==t?"left":"right",a=this;if(o.hasClass("active"))return this.sliding=!1;var r=o[0],l=p.Event("slide.bs.carousel",{relatedTarget:r,direction:s});if(this.$element.trigger(l),!l.isDefaultPrevented()){if(this.sliding=!0,n&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var h=p(this.$indicators.children()[this.getItemIndex(o)]);h&&h.addClass("active")}var d=p.Event("slid.bs.carousel",{relatedTarget:r,direction:s});return p.support.transition&&this.$element.hasClass("slide")?(o.addClass(t),"object"==typeof o&&o.length&&o[0].offsetWidth,i.addClass(s),o.addClass(s),i.one("bsTransitionEnd",function(){o.removeClass([t,s].join(" ")).addClass("active"),i.removeClass(["active",s].join(" ")),a.sliding=!1,setTimeout(function(){a.$element.trigger(d)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(i.removeClass("active"),o.addClass("active"),this.sliding=!1,this.$element.trigger(d)),n&&this.cycle(),this}};var t=p.fn.carousel;p.fn.carousel=r,p.fn.carousel.Constructor=c,p.fn.carousel.noConflict=function(){return p.fn.carousel=t,this};var e=function(t){var e=p(this),i=e.attr("href");i&&(i=i.replace(/.*(?=#[^\s]+$)/,""));var o=e.attr("data-target")||i,n=p(document).find(o);if(n.hasClass("carousel")){var s=p.extend({},n.data(),e.data()),a=e.attr("data-slide-to");a&&(s.interval=!1),r.call(n,s),a&&n.data("bs.carousel").to(a),t.preventDefault()}};p(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),p(window).on("load",function(){p('[data-ride="carousel"]').each(function(){var t=p(this);r.call(t,t.data())})})}(jQuery),function(a){"use strict";var r=function(t,e){this.$element=a(t),this.options=a.extend({},r.DEFAULTS,e),this.$trigger=a('[data-toggle="collapse"][href="#'+t.id+'"],[data-toggle="collapse"][data-target="#'+t.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};function n(t){var e,i=t.attr("data-target")||(e=t.attr("href"))&&e.replace(/.*(?=#[^\s]+$)/,"");return a(document).find(i)}function l(o){return this.each(function(){var t=a(this),e=t.data("bs.collapse"),i=a.extend({},r.DEFAULTS,t.data(),"object"==typeof o&&o);!e&&i.toggle&&/show|hide/.test(o)&&(i.toggle=!1),e||t.data("bs.collapse",e=new r(this,i)),"string"==typeof o&&e[o]()})}r.VERSION="3.4.1",r.TRANSITION_DURATION=350,r.DEFAULTS={toggle:!0},r.prototype.dimension=function(){return this.$element.hasClass("width")?"width":"height"},r.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var t,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(t=e.data("bs.collapse"))&&t.transitioning)){var i=a.Event("show.bs.collapse");if(this.$element.trigger(i),!i.isDefaultPrevented()){e&&e.length&&(l.call(e,"hide"),t||e.data("bs.collapse",null));var o=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[o](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var n=function(){this.$element.removeClass("collapsing").addClass("collapse in")[o](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return n.call(this);var s=a.camelCase(["scroll",o].join("-"));this.$element.one("bsTransitionEnd",a.proxy(n,this)).emulateTransitionEnd(r.TRANSITION_DURATION)[o](this.$element[0][s])}}}},r.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var t=a.Event("hide.bs.collapse");if(this.$element.trigger(t),!t.isDefaultPrevented()){var e=this.dimension();this.$element[e](this.$element[e]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var i=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};if(!a.support.transition)return i.call(this);this.$element[e](0).one("bsTransitionEnd",a.proxy(i,this)).emulateTransitionEnd(r.TRANSITION_DURATION)}}},r.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},r.prototype.getParent=function(){return a(document).find(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(t,e){var i=a(e);this.addAriaAndCollapsedClass(n(i),i)},this)).end()},r.prototype.addAriaAndCollapsedClass=function(t,e){var i=t.hasClass("in");t.attr("aria-expanded",i),e.toggleClass("collapsed",!i).attr("aria-expanded",i)};var t=a.fn.collapse;a.fn.collapse=l,a.fn.collapse.Constructor=r,a.fn.collapse.noConflict=function(){return a.fn.collapse=t,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(t){var e=a(this);e.attr("data-target")||t.preventDefault();var i=n(e),o=i.data("bs.collapse")?"toggle":e.data();l.call(i,o)})}(jQuery),function(a){"use strict";var r='[data-toggle="dropdown"]',o=function(t){a(t).on("click.bs.dropdown",this.toggle)};function l(t){var e=t.attr("data-target");e||(e=(e=t.attr("href"))&&/#[A-Za-z]/.test(e)&&e.replace(/.*(?=#[^\s]*$)/,""));var i="#"!==e?a(document).find(e):null;return i&&i.length?i:t.parent()}function s(o){o&&3===o.which||(a(".dropdown-backdrop").remove(),a(r).each(function(){var t=a(this),e=l(t),i={relatedTarget:this};e.hasClass("open")&&(o&&"click"==o.type&&/input|textarea/i.test(o.target.tagName)&&a.contains(e[0],o.target)||(e.trigger(o=a.Event("hide.bs.dropdown",i)),o.isDefaultPrevented()||(t.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",i)))))}))}o.VERSION="3.4.1",o.prototype.toggle=function(t){var e=a(this);if(!e.is(".disabled, :disabled")){var i=l(e),o=i.hasClass("open");if(s(),!o){"ontouchstart"in document.documentElement&&!i.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",s);var n={relatedTarget:this};if(i.trigger(t=a.Event("show.bs.dropdown",n)),t.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),i.toggleClass("open").trigger(a.Event("shown.bs.dropdown",n))}return!1}},o.prototype.keydown=function(t){if(/(38|40|27|32)/.test(t.which)&&!/input|textarea/i.test(t.target.tagName)){var e=a(this);if(t.preventDefault(),t.stopPropagation(),!e.is(".disabled, :disabled")){var i=l(e),o=i.hasClass("open");if(!o&&27!=t.which||o&&27==t.which)return 27==t.which&&i.find(r).trigger("focus"),e.trigger("click");var n=i.find(".dropdown-menu li:not(.disabled):visible a");if(n.length){var s=n.index(t.target);38==t.which&&0<s&&s--,40==t.which&&s<n.length-1&&s++,~s||(s=0),n.eq(s).trigger("focus")}}}};var t=a.fn.dropdown;a.fn.dropdown=function e(i){return this.each(function(){var t=a(this),e=t.data("bs.dropdown");e||t.data("bs.dropdown",e=new o(this)),"string"==typeof i&&e[i].call(t)})},a.fn.dropdown.Constructor=o,a.fn.dropdown.noConflict=function(){return a.fn.dropdown=t,this},a(document).on("click.bs.dropdown.data-api",s).on("click.bs.dropdown.data-api",".dropdown form",function(t){t.stopPropagation()}).on("click.bs.dropdown.data-api",r,o.prototype.toggle).on("keydown.bs.dropdown.data-api",r,o.prototype.keydown).on("keydown.bs.dropdown.data-api",".dropdown-menu",o.prototype.keydown)}(jQuery),function(a){"use strict";var s=function(t,e){this.options=e,this.$body=a(document.body),this.$element=a(t),this.$dialog=this.$element.find(".modal-dialog"),this.$backdrop=null,this.isShown=null,this.originalBodyPad=null,this.scrollbarWidth=0,this.ignoreBackdropClick=!1,this.fixedContent=".navbar-fixed-top, .navbar-fixed-bottom",this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,a.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};function r(o,n){return this.each(function(){var t=a(this),e=t.data("bs.modal"),i=a.extend({},s.DEFAULTS,t.data(),"object"==typeof o&&o);e||t.data("bs.modal",e=new s(this,i)),"string"==typeof o?e[o](n):i.show&&e.show(n)})}s.VERSION="3.4.1",s.TRANSITION_DURATION=300,s.BACKDROP_TRANSITION_DURATION=150,s.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},s.prototype.toggle=function(t){return this.isShown?this.hide():this.show(t)},s.prototype.show=function(i){var o=this,t=a.Event("show.bs.modal",{relatedTarget:i});this.$element.trigger(t),this.isShown||t.isDefaultPrevented()||(this.isShown=!0,this.checkScrollbar(),this.setScrollbar(),this.$body.addClass("modal-open"),this.escape(),this.resize(),this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',a.proxy(this.hide,this)),this.$dialog.on("mousedown.dismiss.bs.modal",function(){o.$element.one("mouseup.dismiss.bs.modal",function(t){a(t.target).is(o.$element)&&(o.ignoreBackdropClick=!0)})}),this.backdrop(function(){var t=a.support.transition&&o.$element.hasClass("fade");o.$element.parent().length||o.$element.appendTo(o.$body),o.$element.show().scrollTop(0),o.adjustDialog(),t&&o.$element[0].offsetWidth,o.$element.addClass("in"),o.enforceFocus();var e=a.Event("shown.bs.modal",{relatedTarget:i});t?o.$dialog.one("bsTransitionEnd",function(){o.$element.trigger("focus").trigger(e)}).emulateTransitionEnd(s.TRANSITION_DURATION):o.$element.trigger("focus").trigger(e)}))},s.prototype.hide=function(t){t&&t.preventDefault(),t=a.Event("hide.bs.modal"),this.$element.trigger(t),this.isShown&&!t.isDefaultPrevented()&&(this.isShown=!1,this.escape(),this.resize(),a(document).off("focusin.bs.modal"),this.$element.removeClass("in").off("click.dismiss.bs.modal").off("mouseup.dismiss.bs.modal"),this.$dialog.off("mousedown.dismiss.bs.modal"),a.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",a.proxy(this.hideModal,this)).emulateTransitionEnd(s.TRANSITION_DURATION):this.hideModal())},s.prototype.enforceFocus=function(){a(document).off("focusin.bs.modal").on("focusin.bs.modal",a.proxy(function(t){document===t.target||this.$element[0]===t.target||this.$element.has(t.target).length||this.$element.trigger("focus")},this))},s.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keydown.dismiss.bs.modal",a.proxy(function(t){27==t.which&&this.hide()},this)):this.isShown||this.$element.off("keydown.dismiss.bs.modal")},s.prototype.resize=function(){this.isShown?a(window).on("resize.bs.modal",a.proxy(this.handleUpdate,this)):a(window).off("resize.bs.modal")},s.prototype.hideModal=function(){var t=this;this.$element.hide(),this.backdrop(function(){t.$body.removeClass("modal-open"),t.resetAdjustments(),t.resetScrollbar(),t.$element.trigger("hidden.bs.modal")})},s.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},s.prototype.backdrop=function(t){var e=this,i=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var o=a.support.transition&&i;if(this.$backdrop=a(document.createElement("div")).addClass("modal-backdrop "+i).appendTo(this.$body),this.$element.on("click.dismiss.bs.modal",a.proxy(function(t){this.ignoreBackdropClick?this.ignoreBackdropClick=!1:t.target===t.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus():this.hide())},this)),o&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!t)return;o?this.$backdrop.one("bsTransitionEnd",t).emulateTransitionEnd(s.BACKDROP_TRANSITION_DURATION):t()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var n=function(){e.removeBackdrop(),t&&t()};a.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",n).emulateTransitionEnd(s.BACKDROP_TRANSITION_DURATION):n()}else t&&t()},s.prototype.handleUpdate=function(){this.adjustDialog()},s.prototype.adjustDialog=function(){var t=this.$element[0].scrollHeight>document.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&t?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!t?this.scrollbarWidth:""})},s.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},s.prototype.checkScrollbar=function(){var t=window.innerWidth;if(!t){var e=document.documentElement.getBoundingClientRect();t=e.right-Math.abs(e.left)}this.bodyIsOverflowing=document.body.clientWidth<t,this.scrollbarWidth=this.measureScrollbar()},s.prototype.setScrollbar=function(){var t=parseInt(this.$body.css("padding-right")||0,10);this.originalBodyPad=document.body.style.paddingRight||"";var n=this.scrollbarWidth;this.bodyIsOverflowing&&(this.$body.css("padding-right",t+n),a(this.fixedContent).each(function(t,e){var i=e.style.paddingRight,o=a(e).css("padding-right");a(e).data("padding-right",i).css("padding-right",parseFloat(o)+n+"px")}))},s.prototype.resetScrollbar=function(){this.$body.css("padding-right",this.originalBodyPad),a(this.fixedContent).each(function(t,e){var i=a(e).data("padding-right");a(e).removeData("padding-right"),e.style.paddingRight=i||""})},s.prototype.measureScrollbar=function(){var t=document.createElement("div");t.className="modal-scrollbar-measure",this.$body.append(t);var e=t.offsetWidth-t.clientWidth;return this.$body[0].removeChild(t),e};var t=a.fn.modal;a.fn.modal=r,a.fn.modal.Constructor=s,a.fn.modal.noConflict=function(){return a.fn.modal=t,this},a(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(t){var e=a(this),i=e.attr("href"),o=e.attr("data-target")||i&&i.replace(/.*(?=#[^\s]+$)/,""),n=a(document).find(o),s=n.data("bs.modal")?"toggle":a.extend({remote:!/#/.test(i)&&i},n.data(),e.data());e.is("a")&&t.preventDefault(),n.one("show.bs.modal",function(t){t.isDefaultPrevented()||n.one("hidden.bs.modal",function(){e.is(":visible")&&e.trigger("focus")})}),r.call(n,s,this)})}(jQuery),function(g){"use strict";var o=["sanitize","whiteList","sanitizeFn"],a=["background","cite","href","itemtype","longdesc","poster","src","xlink:href"],t={"*":["class","dir","id","lang","role",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},r=/^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi,l=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+/]+=*$/i;function u(t,e){var i=t.nodeName.toLowerCase();if(-1!==g.inArray(i,e))return-1===g.inArray(i,a)||Boolean(t.nodeValue.match(r)||t.nodeValue.match(l));for(var o=g(e).filter(function(t,e){return e instanceof RegExp}),n=0,s=o.length;n<s;n++)if(i.match(o[n]))return!0;return!1}function n(t,e,i){if(0===t.length)return t;if(i&&"function"==typeof i)return i(t);if(!document.implementation||!document.implementation.createHTMLDocument)return t;var o=document.implementation.createHTMLDocument("sanitization");o.body.innerHTML=t;for(var n=g.map(e,function(t,e){return e}),s=g(o.body).find("*"),a=0,r=s.length;a<r;a++){var l=s[a],h=l.nodeName.toLowerCase();if(-1!==g.inArray(h,n))for(var d=g.map(l.attributes,function(t){return t}),p=[].concat(e["*"]||[],e[h]||[]),c=0,f=d.length;c<f;c++)u(d[c],p)||l.removeAttribute(d[c].nodeName);else l.parentNode.removeChild(l)}return o.body.innerHTML}var m=function(t,e){this.type=null,this.options=null,this.enabled=null,this.timeout=null,this.hoverState=null,this.$element=null,this.inState=null,this.init("tooltip",t,e)};m.VERSION="3.4.1",m.TRANSITION_DURATION=150,m.DEFAULTS={animation:!0,placement:"top",selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0},sanitize:!0,sanitizeFn:null,whiteList:t},m.prototype.init=function(t,e,i){if(this.enabled=!0,this.type=t,this.$element=g(e),this.options=this.getOptions(i),this.$viewport=this.options.viewport&&g(document).find(g.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var o=this.options.trigger.split(" "),n=o.length;n--;){var s=o[n];if("click"==s)this.$element.on("click."+this.type,this.options.selector,g.proxy(this.toggle,this));else if("manual"!=s){var a="hover"==s?"mouseenter":"focusin",r="hover"==s?"mouseleave":"focusout";this.$element.on(a+"."+this.type,this.options.selector,g.proxy(this.enter,this)),this.$element.on(r+"."+this.type,this.options.selector,g.proxy(this.leave,this))}}this.options.selector?this._options=g.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},m.prototype.getDefaults=function(){return m.DEFAULTS},m.prototype.getOptions=function(t){var e=this.$element.data();for(var i in e)e.hasOwnProperty(i)&&-1!==g.inArray(i,o)&&delete e[i];return(t=g.extend({},this.getDefaults(),e,t)).delay&&"number"==typeof t.delay&&(t.delay={show:t.delay,hide:t.delay}),t.sanitize&&(t.template=n(t.template,t.whiteList,t.sanitizeFn)),t},m.prototype.getDelegateOptions=function(){var i={},o=this.getDefaults();return this._options&&g.each(this._options,function(t,e){o[t]!=e&&(i[t]=e)}),i},m.prototype.enter=function(t){var e=t instanceof this.constructor?t:g(t.currentTarget).data("bs."+this.type);if(e||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),g(t.currentTarget).data("bs."+this.type,e)),t instanceof g.Event&&(e.inState["focusin"==t.type?"focus":"hover"]=!0),e.tip().hasClass("in")||"in"==e.hoverState)e.hoverState="in";else{if(clearTimeout(e.timeout),e.hoverState="in",!e.options.delay||!e.options.delay.show)return e.show();e.timeout=setTimeout(function(){"in"==e.hoverState&&e.show()},e.options.delay.show)}},m.prototype.isInStateTrue=function(){for(var t in this.inState)if(this.inState[t])return!0;return!1},m.prototype.leave=function(t){var e=t instanceof this.constructor?t:g(t.currentTarget).data("bs."+this.type);if(e||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),g(t.currentTarget).data("bs."+this.type,e)),t instanceof g.Event&&(e.inState["focusout"==t.type?"focus":"hover"]=!1),!e.isInStateTrue()){if(clearTimeout(e.timeout),e.hoverState="out",!e.options.delay||!e.options.delay.hide)return e.hide();e.timeout=setTimeout(function(){"out"==e.hoverState&&e.hide()},e.options.delay.hide)}},m.prototype.show=function(){var t=g.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(t);var e=g.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(t.isDefaultPrevented()||!e)return;var i=this,o=this.tip(),n=this.getUID(this.type);this.setContent(),o.attr("id",n),this.$element.attr("aria-describedby",n),this.options.animation&&o.addClass("fade");var s="function"==typeof this.options.placement?this.options.placement.call(this,o[0],this.$element[0]):this.options.placement,a=/\s?auto?\s?/i,r=a.test(s);r&&(s=s.replace(a,"")||"top"),o.detach().css({top:0,left:0,display:"block"}).addClass(s).data("bs."+this.type,this),this.options.container?o.appendTo(g(document).find(this.options.container)):o.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var l=this.getPosition(),h=o[0].offsetWidth,d=o[0].offsetHeight;if(r){var p=s,c=this.getPosition(this.$viewport);s="bottom"==s&&l.bottom+d>c.bottom?"top":"top"==s&&l.top-d<c.top?"bottom":"right"==s&&l.right+h>c.width?"left":"left"==s&&l.left-h<c.left?"right":s,o.removeClass(p).addClass(s)}var f=this.getCalculatedOffset(s,l,h,d);this.applyPlacement(f,s);var u=function(){var t=i.hoverState;i.$element.trigger("shown.bs."+i.type),i.hoverState=null,"out"==t&&i.leave(i)};g.support.transition&&this.$tip.hasClass("fade")?o.one("bsTransitionEnd",u).emulateTransitionEnd(m.TRANSITION_DURATION):u()}},m.prototype.applyPlacement=function(t,e){var i=this.tip(),o=i[0].offsetWidth,n=i[0].offsetHeight,s=parseInt(i.css("margin-top"),10),a=parseInt(i.css("margin-left"),10);isNaN(s)&&(s=0),isNaN(a)&&(a=0),t.top+=s,t.left+=a,g.offset.setOffset(i[0],g.extend({using:function(t){i.css({top:Math.round(t.top),left:Math.round(t.left)})}},t),0),i.addClass("in");var r=i[0].offsetWidth,l=i[0].offsetHeight;"top"==e&&l!=n&&(t.top=t.top+n-l);var h=this.getViewportAdjustedDelta(e,t,r,l);h.left?t.left+=h.left:t.top+=h.top;var d=/top|bottom/.test(e),p=d?2*h.left-o+r:2*h.top-n+l,c=d?"offsetWidth":"offsetHeight";i.offset(t),this.replaceArrow(p,i[0][c],d)},m.prototype.replaceArrow=function(t,e,i){this.arrow().css(i?"left":"top",50*(1-t/e)+"%").css(i?"top":"left","")},m.prototype.setContent=function(){var t=this.tip(),e=this.getTitle();this.options.html?(this.options.sanitize&&(e=n(e,this.options.whiteList,this.options.sanitizeFn)),t.find(".tooltip-inner").html(e)):t.find(".tooltip-inner").text(e),t.removeClass("fade in top bottom left right")},m.prototype.hide=function(t){var e=this,i=g(this.$tip),o=g.Event("hide.bs."+this.type);function n(){"in"!=e.hoverState&&i.detach(),e.$element&&e.$element.removeAttr("aria-describedby").trigger("hidden.bs."+e.type),t&&t()}if(this.$element.trigger(o),!o.isDefaultPrevented())return i.removeClass("in"),g.support.transition&&i.hasClass("fade")?i.one("bsTransitionEnd",n).emulateTransitionEnd(m.TRANSITION_DURATION):n(),this.hoverState=null,this},m.prototype.fixTitle=function(){var t=this.$element;(t.attr("title")||"string"!=typeof t.attr("data-original-title"))&&t.attr("data-original-title",t.attr("title")||"").attr("title","")},m.prototype.hasContent=function(){return this.getTitle()},m.prototype.getPosition=function(t){var e=(t=t||this.$element)[0],i="BODY"==e.tagName,o=e.getBoundingClientRect();null==o.width&&(o=g.extend({},o,{width:o.right-o.left,height:o.bottom-o.top}));var n=window.SVGElement&&e instanceof window.SVGElement,s=i?{top:0,left:0}:n?null:t.offset(),a={scroll:i?document.documentElement.scrollTop||document.body.scrollTop:t.scrollTop()},r=i?{width:g(window).width(),height:g(window).height()}:null;return g.extend({},o,a,r,s)},m.prototype.getCalculatedOffset=function(t,e,i,o){return"bottom"==t?{top:e.top+e.height,left:e.left+e.width/2-i/2}:"top"==t?{top:e.top-o,left:e.left+e.width/2-i/2}:"left"==t?{top:e.top+e.height/2-o/2,left:e.left-i}:{top:e.top+e.height/2-o/2,left:e.left+e.width}},m.prototype.getViewportAdjustedDelta=function(t,e,i,o){var n={top:0,left:0};if(!this.$viewport)return n;var s=this.options.viewport&&this.options.viewport.padding||0,a=this.getPosition(this.$viewport);if(/right|left/.test(t)){var r=e.top-s-a.scroll,l=e.top+s-a.scroll+o;r<a.top?n.top=a.top-r:l>a.top+a.height&&(n.top=a.top+a.height-l)}else{var h=e.left-s,d=e.left+s+i;h<a.left?n.left=a.left-h:d>a.right&&(n.left=a.left+a.width-d)}return n},m.prototype.getTitle=function(){var t=this.$element,e=this.options;return t.attr("data-original-title")||("function"==typeof e.title?e.title.call(t[0]):e.title)},m.prototype.getUID=function(t){for(;t+=~~(1e6*Math.random()),document.getElementById(t););return t},m.prototype.tip=function(){if(!this.$tip&&(this.$tip=g(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},m.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},m.prototype.enable=function(){this.enabled=!0},m.prototype.disable=function(){this.enabled=!1},m.prototype.toggleEnabled=function(){this.enabled=!this.enabled},m.prototype.toggle=function(t){var e=this;t&&((e=g(t.currentTarget).data("bs."+this.type))||(e=new this.constructor(t.currentTarget,this.getDelegateOptions()),g(t.currentTarget).data("bs."+this.type,e))),t?(e.inState.click=!e.inState.click,e.isInStateTrue()?e.enter(e):e.leave(e)):e.tip().hasClass("in")?e.leave(e):e.enter(e)},m.prototype.destroy=function(){var t=this;clearTimeout(this.timeout),this.hide(function(){t.$element.off("."+t.type).removeData("bs."+t.type),t.$tip&&t.$tip.detach(),t.$tip=null,t.$arrow=null,t.$viewport=null,t.$element=null})},m.prototype.sanitizeHtml=function(t){return n(t,this.options.whiteList,this.options.sanitizeFn)};var e=g.fn.tooltip;g.fn.tooltip=function i(o){return this.each(function(){var t=g(this),e=t.data("bs.tooltip"),i="object"==typeof o&&o;!e&&/destroy|hide/.test(o)||(e||t.data("bs.tooltip",e=new m(this,i)),"string"==typeof o&&e[o]())})},g.fn.tooltip.Constructor=m,g.fn.tooltip.noConflict=function(){return g.fn.tooltip=e,this}}(jQuery),function(n){"use strict";var s=function(t,e){this.init("popover",t,e)};if(!n.fn.tooltip)throw new Error("Popover requires tooltip.js");s.VERSION="3.4.1",s.DEFAULTS=n.extend({},n.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'}),((s.prototype=n.extend({},n.fn.tooltip.Constructor.prototype)).constructor=s).prototype.getDefaults=function(){return s.DEFAULTS},s.prototype.setContent=function(){var t=this.tip(),e=this.getTitle(),i=this.getContent();if(this.options.html){var o=typeof i;this.options.sanitize&&(e=this.sanitizeHtml(e),"string"===o&&(i=this.sanitizeHtml(i))),t.find(".popover-title").html(e),t.find(".popover-content").children().detach().end()["string"===o?"html":"append"](i)}else t.find(".popover-title").text(e),t.find(".popover-content").children().detach().end().text(i);t.removeClass("fade top bottom left right in"),t.find(".popover-title").html()||t.find(".popover-title").hide()},s.prototype.hasContent=function(){return this.getTitle()||this.getContent()},s.prototype.getContent=function(){var t=this.$element,e=this.options;return t.attr("data-content")||("function"==typeof e.content?e.content.call(t[0]):e.content)},s.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var t=n.fn.popover;n.fn.popover=function e(o){return this.each(function(){var t=n(this),e=t.data("bs.popover"),i="object"==typeof o&&o;!e&&/destroy|hide/.test(o)||(e||t.data("bs.popover",e=new s(this,i)),"string"==typeof o&&e[o]())})},n.fn.popover.Constructor=s,n.fn.popover.noConflict=function(){return n.fn.popover=t,this}}(jQuery),function(s){"use strict";function n(t,e){this.$body=s(document.body),this.$scrollElement=s(t).is(document.body)?s(window):s(t),this.options=s.extend({},n.DEFAULTS,e),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",s.proxy(this.process,this)),this.refresh(),this.process()}function e(o){return this.each(function(){var t=s(this),e=t.data("bs.scrollspy"),i="object"==typeof o&&o;e||t.data("bs.scrollspy",e=new n(this,i)),"string"==typeof o&&e[o]()})}n.VERSION="3.4.1",n.DEFAULTS={offset:10},n.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},n.prototype.refresh=function(){var t=this,o="offset",n=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),s.isWindow(this.$scrollElement[0])||(o="position",n=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var t=s(this),e=t.data("target")||t.attr("href"),i=/^#./.test(e)&&s(e);return i&&i.length&&i.is(":visible")&&[[i[o]().top+n,e]]||null}).sort(function(t,e){return t[0]-e[0]}).each(function(){t.offsets.push(this[0]),t.targets.push(this[1])})},n.prototype.process=function(){var t,e=this.$scrollElement.scrollTop()+this.options.offset,i=this.getScrollHeight(),o=this.options.offset+i-this.$scrollElement.height(),n=this.offsets,s=this.targets,a=this.activeTarget;if(this.scrollHeight!=i&&this.refresh(),o<=e)return a!=(t=s[s.length-1])&&this.activate(t);if(a&&e<n[0])return this.activeTarget=null,this.clear();for(t=n.length;t--;)a!=s[t]&&e>=n[t]&&(n[t+1]===undefined||e<n[t+1])&&this.activate(s[t])},n.prototype.activate=function(t){this.activeTarget=t,this.clear();var e=this.selector+'[data-target="'+t+'"],'+this.selector+'[href="'+t+'"]',i=s(e).parents("li").addClass("active");i.parent(".dropdown-menu").length&&(i=i.closest("li.dropdown").addClass("active")),i.trigger("activate.bs.scrollspy")},n.prototype.clear=function(){s(this.selector).parentsUntil(this.options.target,".active").removeClass("active")};var t=s.fn.scrollspy;s.fn.scrollspy=e,s.fn.scrollspy.Constructor=n,s.fn.scrollspy.noConflict=function(){return s.fn.scrollspy=t,this},s(window).on("load.bs.scrollspy.data-api",function(){s('[data-spy="scroll"]').each(function(){var t=s(this);e.call(t,t.data())})})}(jQuery),function(r){"use strict";var a=function(t){this.element=r(t)};function e(i){return this.each(function(){var t=r(this),e=t.data("bs.tab");e||t.data("bs.tab",e=new a(this)),"string"==typeof i&&e[i]()})}a.VERSION="3.4.1",a.TRANSITION_DURATION=150,a.prototype.show=function(){var t=this.element,e=t.closest("ul:not(.dropdown-menu)"),i=t.data("target");if(i||(i=(i=t.attr("href"))&&i.replace(/.*(?=#[^\s]*$)/,"")),!t.parent("li").hasClass("active")){var o=e.find(".active:last a"),n=r.Event("hide.bs.tab",{relatedTarget:t[0]}),s=r.Event("show.bs.tab",{relatedTarget:o[0]});if(o.trigger(n),t.trigger(s),!s.isDefaultPrevented()&&!n.isDefaultPrevented()){var a=r(document).find(i);this.activate(t.closest("li"),e),this.activate(a,a.parent(),function(){o.trigger({type:"hidden.bs.tab",relatedTarget:t[0]}),t.trigger({type:"shown.bs.tab",relatedTarget:o[0]})})}}},a.prototype.activate=function(t,e,i){var o=e.find("> .active"),n=i&&r.support.transition&&(o.length&&o.hasClass("fade")||!!e.find("> .fade").length);function s(){o.removeClass("active").find("> .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),t.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),n?(t[0].offsetWidth,t.addClass("in")):t.removeClass("fade"),t.parent(".dropdown-menu").length&&t.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),i&&i()}o.length&&n?o.one("bsTransitionEnd",s).emulateTransitionEnd(a.TRANSITION_DURATION):s(),o.removeClass("in")};var t=r.fn.tab;r.fn.tab=e,r.fn.tab.Constructor=a,r.fn.tab.noConflict=function(){return r.fn.tab=t,this};var i=function(t){t.preventDefault(),e.call(r(this),"show")};r(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',i).on("click.bs.tab.data-api",'[data-toggle="pill"]',i)}(jQuery),function(l){"use strict";var h=function(t,e){this.options=l.extend({},h.DEFAULTS,e);var i=this.options.target===h.DEFAULTS.target?l(this.options.target):l(document).find(this.options.target);this.$target=i.on("scroll.bs.affix.data-api",l.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",l.proxy(this.checkPositionWithEventLoop,this)),this.$element=l(t),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};function i(o){return this.each(function(){var t=l(this),e=t.data("bs.affix"),i="object"==typeof o&&o;e||t.data("bs.affix",e=new h(this,i)),"string"==typeof o&&e[o]()})}h.VERSION="3.4.1",h.RESET="affix affix-top affix-bottom",h.DEFAULTS={offset:0,target:window},h.prototype.getState=function(t,e,i,o){var n=this.$target.scrollTop(),s=this.$element.offset(),a=this.$target.height();if(null!=i&&"top"==this.affixed)return n<i&&"top";if("bottom"==this.affixed)return null!=i?!(n+this.unpin<=s.top)&&"bottom":!(n+a<=t-o)&&"bottom";var r=null==this.affixed,l=r?n:s.top;return null!=i&&n<=i?"top":null!=o&&t-o<=l+(r?a:e)&&"bottom"},h.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(h.RESET).addClass("affix");var t=this.$target.scrollTop(),e=this.$element.offset();return this.pinnedOffset=e.top-t},h.prototype.checkPositionWithEventLoop=function(){setTimeout(l.proxy(this.checkPosition,this),1)},h.prototype.checkPosition=function(){if(this.$element.is(":visible")){var t=this.$element.height(),e=this.options.offset,i=e.top,o=e.bottom,n=Math.max(l(document).height(),l(document.body).height());"object"!=typeof e&&(o=i=e),"function"==typeof i&&(i=e.top(this.$element)),"function"==typeof o&&(o=e.bottom(this.$element));var s=this.getState(n,t,i,o);if(this.affixed!=s){null!=this.unpin&&this.$element.css("top","");var a="affix"+(s?"-"+s:""),r=l.Event(a+".bs.affix");if(this.$element.trigger(r),r.isDefaultPrevented())return;this.affixed=s,this.unpin="bottom"==s?this.getPinnedOffset():null,this.$element.removeClass(h.RESET).addClass(a).trigger(a.replace("affix","affixed")+".bs.affix")}"bottom"==s&&this.$element.offset({top:n-t-o})}};var t=l.fn.affix;l.fn.affix=i,l.fn.affix.Constructor=h,l.fn.affix.noConflict=function(){return l.fn.affix=t,this},l(window).on("load",function(){l('[data-spy="affix"]').each(function(){var t=l(this),e=t.data();e.offset=e.offset||{},null!=e.offsetBottom&&(e.offset.bottom=e.offsetBottom),null!=e.offsetTop&&(e.offset.top=e.offsetTop),i.call(t,e)})})}(jQuery);
  17380. define("bootstrap", ["jquery"], (function (global) {
  17381. return function () {
  17382. var ret, fn;
  17383. return ret || global.bootstrap;
  17384. };
  17385. }(this)));
  17386. /**
  17387. * @preserve jed.js https://github.com/SlexAxton/Jed
  17388. */
  17389. /*
  17390. -----------
  17391. A gettext compatible i18n library for modern JavaScript Applications
  17392. by Alex Sexton - AlexSexton [at] gmail - @SlexAxton
  17393. MIT License
  17394. A jQuery Foundation project - requires CLA to contribute -
  17395. https://contribute.jquery.org/CLA/
  17396. Jed offers the entire applicable GNU gettext spec'd set of
  17397. functions, but also offers some nicer wrappers around them.
  17398. The api for gettext was written for a language with no function
  17399. overloading, so Jed allows a little more of that.
  17400. Many thanks to Joshua I. Miller - unrtst@cpan.org - who wrote
  17401. gettext.js back in 2008. I was able to vet a lot of my ideas
  17402. against his. I also made sure Jed passed against his tests
  17403. in order to offer easy upgrades -- jsgettext.berlios.de
  17404. */
  17405. (function (root, undef) {
  17406. // Set up some underscore-style functions, if you already have
  17407. // underscore, feel free to delete this section, and use it
  17408. // directly, however, the amount of functions used doesn't
  17409. // warrant having underscore as a full dependency.
  17410. // Underscore 1.3.0 was used to port and is licensed
  17411. // under the MIT License by Jeremy Ashkenas.
  17412. var ArrayProto = Array.prototype,
  17413. ObjProto = Object.prototype,
  17414. slice = ArrayProto.slice,
  17415. hasOwnProp = ObjProto.hasOwnProperty,
  17416. nativeForEach = ArrayProto.forEach,
  17417. breaker = {};
  17418. // We're not using the OOP style _ so we don't need the
  17419. // extra level of indirection. This still means that you
  17420. // sub out for real `_` though.
  17421. var _ = {
  17422. forEach : function( obj, iterator, context ) {
  17423. var i, l, key;
  17424. if ( obj === null ) {
  17425. return;
  17426. }
  17427. if ( nativeForEach && obj.forEach === nativeForEach ) {
  17428. obj.forEach( iterator, context );
  17429. }
  17430. else if ( obj.length === +obj.length ) {
  17431. for ( i = 0, l = obj.length; i < l; i++ ) {
  17432. if ( i in obj && iterator.call( context, obj[i], i, obj ) === breaker ) {
  17433. return;
  17434. }
  17435. }
  17436. }
  17437. else {
  17438. for ( key in obj) {
  17439. if ( hasOwnProp.call( obj, key ) ) {
  17440. if ( iterator.call (context, obj[key], key, obj ) === breaker ) {
  17441. return;
  17442. }
  17443. }
  17444. }
  17445. }
  17446. },
  17447. extend : function( obj ) {
  17448. this.forEach( slice.call( arguments, 1 ), function ( source ) {
  17449. for ( var prop in source ) {
  17450. obj[prop] = source[prop];
  17451. }
  17452. });
  17453. return obj;
  17454. }
  17455. };
  17456. // END Miniature underscore impl
  17457. // Jed is a constructor function
  17458. var Jed = function ( options ) {
  17459. // Some minimal defaults
  17460. this.defaults = {
  17461. "locale_data" : {
  17462. "messages" : {
  17463. "" : {
  17464. "domain" : "messages",
  17465. "lang" : "en",
  17466. "plural_forms" : "nplurals=2; plural=(n != 1);"
  17467. }
  17468. // There are no default keys, though
  17469. }
  17470. },
  17471. // The default domain if one is missing
  17472. "domain" : "messages",
  17473. // enable debug mode to log untranslated strings to the console
  17474. "debug" : false
  17475. };
  17476. // Mix in the sent options with the default options
  17477. this.options = _.extend( {}, this.defaults, options );
  17478. this.textdomain( this.options.domain );
  17479. if ( options.domain && ! this.options.locale_data[ this.options.domain ] ) {
  17480. throw new Error('Text domain set to non-existent domain: `' + options.domain + '`');
  17481. }
  17482. };
  17483. // The gettext spec sets this character as the default
  17484. // delimiter for context lookups.
  17485. // e.g.: context\u0004key
  17486. // If your translation company uses something different,
  17487. // just change this at any time and it will use that instead.
  17488. Jed.context_delimiter = String.fromCharCode( 4 );
  17489. function getPluralFormFunc ( plural_form_string ) {
  17490. return Jed.PF.compile( plural_form_string || "nplurals=2; plural=(n != 1);");
  17491. }
  17492. function Chain( key, i18n ){
  17493. this._key = key;
  17494. this._i18n = i18n;
  17495. }
  17496. // Create a chainable api for adding args prettily
  17497. _.extend( Chain.prototype, {
  17498. onDomain : function ( domain ) {
  17499. this._domain = domain;
  17500. return this;
  17501. },
  17502. withContext : function ( context ) {
  17503. this._context = context;
  17504. return this;
  17505. },
  17506. ifPlural : function ( num, pkey ) {
  17507. this._val = num;
  17508. this._pkey = pkey;
  17509. return this;
  17510. },
  17511. fetch : function ( sArr ) {
  17512. if ( {}.toString.call( sArr ) != '[object Array]' ) {
  17513. sArr = [].slice.call(arguments, 0);
  17514. }
  17515. return ( sArr && sArr.length ? Jed.sprintf : function(x){ return x; } )(
  17516. this._i18n.dcnpgettext(this._domain, this._context, this._key, this._pkey, this._val),
  17517. sArr
  17518. );
  17519. }
  17520. });
  17521. // Add functions to the Jed prototype.
  17522. // These will be the functions on the object that's returned
  17523. // from creating a `new Jed()`
  17524. // These seem redundant, but they gzip pretty well.
  17525. _.extend( Jed.prototype, {
  17526. // The sexier api start point
  17527. translate : function ( key ) {
  17528. return new Chain( key, this );
  17529. },
  17530. textdomain : function ( domain ) {
  17531. if ( ! domain ) {
  17532. return this._textdomain;
  17533. }
  17534. this._textdomain = domain;
  17535. },
  17536. gettext : function ( key ) {
  17537. return this.dcnpgettext.call( this, undef, undef, key );
  17538. },
  17539. dgettext : function ( domain, key ) {
  17540. return this.dcnpgettext.call( this, domain, undef, key );
  17541. },
  17542. dcgettext : function ( domain , key /*, category */ ) {
  17543. // Ignores the category anyways
  17544. return this.dcnpgettext.call( this, domain, undef, key );
  17545. },
  17546. ngettext : function ( skey, pkey, val ) {
  17547. return this.dcnpgettext.call( this, undef, undef, skey, pkey, val );
  17548. },
  17549. dngettext : function ( domain, skey, pkey, val ) {
  17550. return this.dcnpgettext.call( this, domain, undef, skey, pkey, val );
  17551. },
  17552. dcngettext : function ( domain, skey, pkey, val/*, category */) {
  17553. return this.dcnpgettext.call( this, domain, undef, skey, pkey, val );
  17554. },
  17555. pgettext : function ( context, key ) {
  17556. return this.dcnpgettext.call( this, undef, context, key );
  17557. },
  17558. dpgettext : function ( domain, context, key ) {
  17559. return this.dcnpgettext.call( this, domain, context, key );
  17560. },
  17561. dcpgettext : function ( domain, context, key/*, category */) {
  17562. return this.dcnpgettext.call( this, domain, context, key );
  17563. },
  17564. npgettext : function ( context, skey, pkey, val ) {
  17565. return this.dcnpgettext.call( this, undef, context, skey, pkey, val );
  17566. },
  17567. dnpgettext : function ( domain, context, skey, pkey, val ) {
  17568. return this.dcnpgettext.call( this, domain, context, skey, pkey, val );
  17569. },
  17570. // The most fully qualified gettext function. It has every option.
  17571. // Since it has every option, we can use it from every other method.
  17572. // This is the bread and butter.
  17573. // Technically there should be one more argument in this function for 'Category',
  17574. // but since we never use it, we might as well not waste the bytes to define it.
  17575. dcnpgettext : function ( domain, context, singular_key, plural_key, val ) {
  17576. // Set some defaults
  17577. plural_key = plural_key || singular_key;
  17578. // Use the global domain default if one
  17579. // isn't explicitly passed in
  17580. domain = domain || this._textdomain;
  17581. var fallback;
  17582. // Handle special cases
  17583. // No options found
  17584. if ( ! this.options ) {
  17585. // There's likely something wrong, but we'll return the correct key for english
  17586. // We do this by instantiating a brand new Jed instance with the default set
  17587. // for everything that could be broken.
  17588. fallback = new Jed();
  17589. return fallback.dcnpgettext.call( fallback, undefined, undefined, singular_key, plural_key, val );
  17590. }
  17591. // No translation data provided
  17592. if ( ! this.options.locale_data ) {
  17593. throw new Error('No locale data provided.');
  17594. }
  17595. if ( ! this.options.locale_data[ domain ] ) {
  17596. throw new Error('Domain `' + domain + '` was not found.');
  17597. }
  17598. if ( ! this.options.locale_data[ domain ][ "" ] ) {
  17599. throw new Error('No locale meta information provided.');
  17600. }
  17601. // Make sure we have a truthy key. Otherwise we might start looking
  17602. // into the empty string key, which is the options for the locale
  17603. // data.
  17604. if ( ! singular_key ) {
  17605. throw new Error('No translation key found.');
  17606. }
  17607. var key = context ? context + Jed.context_delimiter + singular_key : singular_key,
  17608. locale_data = this.options.locale_data,
  17609. dict = locale_data[ domain ],
  17610. defaultConf = (locale_data.messages || this.defaults.locale_data.messages)[""],
  17611. pluralForms = dict[""].plural_forms || dict[""]["Plural-Forms"] || dict[""]["plural-forms"] || defaultConf.plural_forms || defaultConf["Plural-Forms"] || defaultConf["plural-forms"],
  17612. val_list,
  17613. res;
  17614. var val_idx;
  17615. if (val === undefined) {
  17616. // No value passed in; assume singular key lookup.
  17617. val_idx = 0;
  17618. } else {
  17619. // Value has been passed in; use plural-forms calculations.
  17620. // Handle invalid numbers, but try casting strings for good measure
  17621. if ( typeof val != 'number' ) {
  17622. val = parseInt( val, 10 );
  17623. if ( isNaN( val ) ) {
  17624. throw new Error('The number that was passed in is not a number.');
  17625. }
  17626. }
  17627. val_idx = getPluralFormFunc(pluralForms)(val);
  17628. }
  17629. // Throw an error if a domain isn't found
  17630. if ( ! dict ) {
  17631. throw new Error('No domain named `' + domain + '` could be found.');
  17632. }
  17633. val_list = dict[ key ];
  17634. // If there is no match, then revert back to
  17635. // english style singular/plural with the keys passed in.
  17636. if ( ! val_list || val_idx > val_list.length ) {
  17637. if (this.options.missing_key_callback) {
  17638. this.options.missing_key_callback(key, domain);
  17639. }
  17640. res = [ singular_key, plural_key ];
  17641. // collect untranslated strings
  17642. if (this.options.debug===true) {
  17643. console.log(res[ getPluralFormFunc(pluralForms)( val ) ]);
  17644. }
  17645. return res[ getPluralFormFunc()( val ) ];
  17646. }
  17647. res = val_list[ val_idx ];
  17648. // This includes empty strings on purpose
  17649. if ( ! res ) {
  17650. res = [ singular_key, plural_key ];
  17651. return res[ getPluralFormFunc()( val ) ];
  17652. }
  17653. return res;
  17654. }
  17655. });
  17656. // We add in sprintf capabilities for post translation value interolation
  17657. // This is not internally used, so you can remove it if you have this
  17658. // available somewhere else, or want to use a different system.
  17659. // We _slightly_ modify the normal sprintf behavior to more gracefully handle
  17660. // undefined values.
  17661. /**
  17662. sprintf() for JavaScript 0.7-beta1
  17663. http://www.diveintojavascript.com/projects/javascript-sprintf
  17664. Copyright (c) Alexandru Marasteanu <alexaholic [at) gmail (dot] com>
  17665. All rights reserved.
  17666. Redistribution and use in source and binary forms, with or without
  17667. modification, are permitted provided that the following conditions are met:
  17668. * Redistributions of source code must retain the above copyright
  17669. notice, this list of conditions and the following disclaimer.
  17670. * Redistributions in binary form must reproduce the above copyright
  17671. notice, this list of conditions and the following disclaimer in the
  17672. documentation and/or other materials provided with the distribution.
  17673. * Neither the name of sprintf() for JavaScript nor the
  17674. names of its contributors may be used to endorse or promote products
  17675. derived from this software without specific prior written permission.
  17676. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  17677. ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  17678. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  17679. DISCLAIMED. IN NO EVENT SHALL Alexandru Marasteanu BE LIABLE FOR ANY
  17680. DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  17681. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  17682. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  17683. ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  17684. (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  17685. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  17686. */
  17687. var sprintf = (function() {
  17688. function get_type(variable) {
  17689. return Object.prototype.toString.call(variable).slice(8, -1).toLowerCase();
  17690. }
  17691. function str_repeat(input, multiplier) {
  17692. for (var output = []; multiplier > 0; output[--multiplier] = input) {/* do nothing */}
  17693. return output.join('');
  17694. }
  17695. var str_format = function() {
  17696. if (!str_format.cache.hasOwnProperty(arguments[0])) {
  17697. str_format.cache[arguments[0]] = str_format.parse(arguments[0]);
  17698. }
  17699. return str_format.format.call(null, str_format.cache[arguments[0]], arguments);
  17700. };
  17701. str_format.format = function(parse_tree, argv) {
  17702. var cursor = 1, tree_length = parse_tree.length, node_type = '', arg, output = [], i, k, match, pad, pad_character, pad_length;
  17703. for (i = 0; i < tree_length; i++) {
  17704. node_type = get_type(parse_tree[i]);
  17705. if (node_type === 'string') {
  17706. output.push(parse_tree[i]);
  17707. }
  17708. else if (node_type === 'array') {
  17709. match = parse_tree[i]; // convenience purposes only
  17710. if (match[2]) { // keyword argument
  17711. arg = argv[cursor];
  17712. for (k = 0; k < match[2].length; k++) {
  17713. if (!arg.hasOwnProperty(match[2][k])) {
  17714. throw(sprintf('[sprintf] property "%s" does not exist', match[2][k]));
  17715. }
  17716. arg = arg[match[2][k]];
  17717. }
  17718. }
  17719. else if (match[1]) { // positional argument (explicit)
  17720. arg = argv[match[1]];
  17721. }
  17722. else { // positional argument (implicit)
  17723. arg = argv[cursor++];
  17724. }
  17725. if (/[^s]/.test(match[8]) && (get_type(arg) != 'number')) {
  17726. throw(sprintf('[sprintf] expecting number but found %s', get_type(arg)));
  17727. }
  17728. // Jed EDIT
  17729. if ( typeof arg == 'undefined' || arg === null ) {
  17730. arg = '';
  17731. }
  17732. // Jed EDIT
  17733. switch (match[8]) {
  17734. case 'b': arg = arg.toString(2); break;
  17735. case 'c': arg = String.fromCharCode(arg); break;
  17736. case 'd': arg = parseInt(arg, 10); break;
  17737. case 'e': arg = match[7] ? arg.toExponential(match[7]) : arg.toExponential(); break;
  17738. case 'f': arg = match[7] ? parseFloat(arg).toFixed(match[7]) : parseFloat(arg); break;
  17739. case 'o': arg = arg.toString(8); break;
  17740. case 's': arg = ((arg = String(arg)) && match[7] ? arg.substring(0, match[7]) : arg); break;
  17741. case 'u': arg = Math.abs(arg); break;
  17742. case 'x': arg = arg.toString(16); break;
  17743. case 'X': arg = arg.toString(16).toUpperCase(); break;
  17744. }
  17745. arg = (/[def]/.test(match[8]) && match[3] && arg >= 0 ? '+'+ arg : arg);
  17746. pad_character = match[4] ? match[4] == '0' ? '0' : match[4].charAt(1) : ' ';
  17747. pad_length = match[6] - String(arg).length;
  17748. pad = match[6] ? str_repeat(pad_character, pad_length) : '';
  17749. output.push(match[5] ? arg + pad : pad + arg);
  17750. }
  17751. }
  17752. return output.join('');
  17753. };
  17754. str_format.cache = {};
  17755. str_format.parse = function(fmt) {
  17756. var _fmt = fmt, match = [], parse_tree = [], arg_names = 0;
  17757. while (_fmt) {
  17758. if ((match = /^[^\x25]+/.exec(_fmt)) !== null) {
  17759. parse_tree.push(match[0]);
  17760. }
  17761. else if ((match = /^\x25{2}/.exec(_fmt)) !== null) {
  17762. parse_tree.push('%');
  17763. }
  17764. else if ((match = /^\x25(?:([1-9]\d*)\$|\(([^\)]+)\))?(\+)?(0|'[^$])?(-)?(\d+)?(?:\.(\d+))?([b-fosuxX])/.exec(_fmt)) !== null) {
  17765. if (match[2]) {
  17766. arg_names |= 1;
  17767. var field_list = [], replacement_field = match[2], field_match = [];
  17768. if ((field_match = /^([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
  17769. field_list.push(field_match[1]);
  17770. while ((replacement_field = replacement_field.substring(field_match[0].length)) !== '') {
  17771. if ((field_match = /^\.([a-z_][a-z_\d]*)/i.exec(replacement_field)) !== null) {
  17772. field_list.push(field_match[1]);
  17773. }
  17774. else if ((field_match = /^\[(\d+)\]/.exec(replacement_field)) !== null) {
  17775. field_list.push(field_match[1]);
  17776. }
  17777. else {
  17778. throw('[sprintf] huh?');
  17779. }
  17780. }
  17781. }
  17782. else {
  17783. throw('[sprintf] huh?');
  17784. }
  17785. match[2] = field_list;
  17786. }
  17787. else {
  17788. arg_names |= 2;
  17789. }
  17790. if (arg_names === 3) {
  17791. throw('[sprintf] mixing positional and named placeholders is not (yet) supported');
  17792. }
  17793. parse_tree.push(match);
  17794. }
  17795. else {
  17796. throw('[sprintf] huh?');
  17797. }
  17798. _fmt = _fmt.substring(match[0].length);
  17799. }
  17800. return parse_tree;
  17801. };
  17802. return str_format;
  17803. })();
  17804. var vsprintf = function(fmt, argv) {
  17805. argv.unshift(fmt);
  17806. return sprintf.apply(null, argv);
  17807. };
  17808. Jed.parse_plural = function ( plural_forms, n ) {
  17809. plural_forms = plural_forms.replace(/n/g, n);
  17810. return Jed.parse_expression(plural_forms);
  17811. };
  17812. Jed.sprintf = function ( fmt, args ) {
  17813. if ( {}.toString.call( args ) == '[object Array]' ) {
  17814. return vsprintf( fmt, [].slice.call(args) );
  17815. }
  17816. return sprintf.apply(this, [].slice.call(arguments) );
  17817. };
  17818. Jed.prototype.sprintf = function () {
  17819. return Jed.sprintf.apply(this, arguments);
  17820. };
  17821. // END sprintf Implementation
  17822. // Start the Plural forms section
  17823. // This is a full plural form expression parser. It is used to avoid
  17824. // running 'eval' or 'new Function' directly against the plural
  17825. // forms.
  17826. //
  17827. // This can be important if you get translations done through a 3rd
  17828. // party vendor. I encourage you to use this instead, however, I
  17829. // also will provide a 'precompiler' that you can use at build time
  17830. // to output valid/safe function representations of the plural form
  17831. // expressions. This means you can build this code out for the most
  17832. // part.
  17833. Jed.PF = {};
  17834. Jed.PF.parse = function ( p ) {
  17835. var plural_str = Jed.PF.extractPluralExpr( p );
  17836. return Jed.PF.parser.parse.call(Jed.PF.parser, plural_str);
  17837. };
  17838. Jed.PF.compile = function ( p ) {
  17839. // Handle trues and falses as 0 and 1
  17840. function imply( val ) {
  17841. return (val === true ? 1 : val ? val : 0);
  17842. }
  17843. var ast = Jed.PF.parse( p );
  17844. return function ( n ) {
  17845. return imply( Jed.PF.interpreter( ast )( n ) );
  17846. };
  17847. };
  17848. Jed.PF.interpreter = function ( ast ) {
  17849. return function ( n ) {
  17850. var res;
  17851. switch ( ast.type ) {
  17852. case 'GROUP':
  17853. return Jed.PF.interpreter( ast.expr )( n );
  17854. case 'TERNARY':
  17855. if ( Jed.PF.interpreter( ast.expr )( n ) ) {
  17856. return Jed.PF.interpreter( ast.truthy )( n );
  17857. }
  17858. return Jed.PF.interpreter( ast.falsey )( n );
  17859. case 'OR':
  17860. return Jed.PF.interpreter( ast.left )( n ) || Jed.PF.interpreter( ast.right )( n );
  17861. case 'AND':
  17862. return Jed.PF.interpreter( ast.left )( n ) && Jed.PF.interpreter( ast.right )( n );
  17863. case 'LT':
  17864. return Jed.PF.interpreter( ast.left )( n ) < Jed.PF.interpreter( ast.right )( n );
  17865. case 'GT':
  17866. return Jed.PF.interpreter( ast.left )( n ) > Jed.PF.interpreter( ast.right )( n );
  17867. case 'LTE':
  17868. return Jed.PF.interpreter( ast.left )( n ) <= Jed.PF.interpreter( ast.right )( n );
  17869. case 'GTE':
  17870. return Jed.PF.interpreter( ast.left )( n ) >= Jed.PF.interpreter( ast.right )( n );
  17871. case 'EQ':
  17872. return Jed.PF.interpreter( ast.left )( n ) == Jed.PF.interpreter( ast.right )( n );
  17873. case 'NEQ':
  17874. return Jed.PF.interpreter( ast.left )( n ) != Jed.PF.interpreter( ast.right )( n );
  17875. case 'MOD':
  17876. return Jed.PF.interpreter( ast.left )( n ) % Jed.PF.interpreter( ast.right )( n );
  17877. case 'VAR':
  17878. return n;
  17879. case 'NUM':
  17880. return ast.val;
  17881. default:
  17882. throw new Error("Invalid Token found.");
  17883. }
  17884. };
  17885. };
  17886. Jed.PF.extractPluralExpr = function ( p ) {
  17887. // trim first
  17888. p = p.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
  17889. if (! /;\s*$/.test(p)) {
  17890. p = p.concat(';');
  17891. }
  17892. var nplurals_re = /nplurals\=(\d+);/,
  17893. plural_re = /plural\=(.*);/,
  17894. nplurals_matches = p.match( nplurals_re ),
  17895. res = {},
  17896. plural_matches;
  17897. // Find the nplurals number
  17898. if ( nplurals_matches.length > 1 ) {
  17899. res.nplurals = nplurals_matches[1];
  17900. }
  17901. else {
  17902. throw new Error('nplurals not found in plural_forms string: ' + p );
  17903. }
  17904. // remove that data to get to the formula
  17905. p = p.replace( nplurals_re, "" );
  17906. plural_matches = p.match( plural_re );
  17907. if (!( plural_matches && plural_matches.length > 1 ) ) {
  17908. throw new Error('`plural` expression not found: ' + p);
  17909. }
  17910. return plural_matches[ 1 ];
  17911. };
  17912. /* Jison generated parser */
  17913. Jed.PF.parser = (function(){
  17914. var parser = {trace: function trace() { },
  17915. yy: {},
  17916. symbols_: {"error":2,"expressions":3,"e":4,"EOF":5,"?":6,":":7,"||":8,"&&":9,"<":10,"<=":11,">":12,">=":13,"!=":14,"==":15,"%":16,"(":17,")":18,"n":19,"NUMBER":20,"$accept":0,"$end":1},
  17917. terminals_: {2:"error",5:"EOF",6:"?",7:":",8:"||",9:"&&",10:"<",11:"<=",12:">",13:">=",14:"!=",15:"==",16:"%",17:"(",18:")",19:"n",20:"NUMBER"},
  17918. productions_: [0,[3,2],[4,5],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,3],[4,1],[4,1]],
  17919. performAction: function anonymous(yytext,yyleng,yylineno,yy,yystate,$$,_$) {
  17920. var $0 = $$.length - 1;
  17921. switch (yystate) {
  17922. case 1: return { type : 'GROUP', expr: $$[$0-1] };
  17923. break;
  17924. case 2:this.$ = { type: 'TERNARY', expr: $$[$0-4], truthy : $$[$0-2], falsey: $$[$0] };
  17925. break;
  17926. case 3:this.$ = { type: "OR", left: $$[$0-2], right: $$[$0] };
  17927. break;
  17928. case 4:this.$ = { type: "AND", left: $$[$0-2], right: $$[$0] };
  17929. break;
  17930. case 5:this.$ = { type: 'LT', left: $$[$0-2], right: $$[$0] };
  17931. break;
  17932. case 6:this.$ = { type: 'LTE', left: $$[$0-2], right: $$[$0] };
  17933. break;
  17934. case 7:this.$ = { type: 'GT', left: $$[$0-2], right: $$[$0] };
  17935. break;
  17936. case 8:this.$ = { type: 'GTE', left: $$[$0-2], right: $$[$0] };
  17937. break;
  17938. case 9:this.$ = { type: 'NEQ', left: $$[$0-2], right: $$[$0] };
  17939. break;
  17940. case 10:this.$ = { type: 'EQ', left: $$[$0-2], right: $$[$0] };
  17941. break;
  17942. case 11:this.$ = { type: 'MOD', left: $$[$0-2], right: $$[$0] };
  17943. break;
  17944. case 12:this.$ = { type: 'GROUP', expr: $$[$0-1] };
  17945. break;
  17946. case 13:this.$ = { type: 'VAR' };
  17947. break;
  17948. case 14:this.$ = { type: 'NUM', val: Number(yytext) };
  17949. break;
  17950. }
  17951. },
  17952. table: [{3:1,4:2,17:[1,3],19:[1,4],20:[1,5]},{1:[3]},{5:[1,6],6:[1,7],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16]},{4:17,17:[1,3],19:[1,4],20:[1,5]},{5:[2,13],6:[2,13],7:[2,13],8:[2,13],9:[2,13],10:[2,13],11:[2,13],12:[2,13],13:[2,13],14:[2,13],15:[2,13],16:[2,13],18:[2,13]},{5:[2,14],6:[2,14],7:[2,14],8:[2,14],9:[2,14],10:[2,14],11:[2,14],12:[2,14],13:[2,14],14:[2,14],15:[2,14],16:[2,14],18:[2,14]},{1:[2,1]},{4:18,17:[1,3],19:[1,4],20:[1,5]},{4:19,17:[1,3],19:[1,4],20:[1,5]},{4:20,17:[1,3],19:[1,4],20:[1,5]},{4:21,17:[1,3],19:[1,4],20:[1,5]},{4:22,17:[1,3],19:[1,4],20:[1,5]},{4:23,17:[1,3],19:[1,4],20:[1,5]},{4:24,17:[1,3],19:[1,4],20:[1,5]},{4:25,17:[1,3],19:[1,4],20:[1,5]},{4:26,17:[1,3],19:[1,4],20:[1,5]},{4:27,17:[1,3],19:[1,4],20:[1,5]},{6:[1,7],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[1,28]},{6:[1,7],7:[1,29],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16]},{5:[2,3],6:[2,3],7:[2,3],8:[2,3],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,3]},{5:[2,4],6:[2,4],7:[2,4],8:[2,4],9:[2,4],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,4]},{5:[2,5],6:[2,5],7:[2,5],8:[2,5],9:[2,5],10:[2,5],11:[2,5],12:[2,5],13:[2,5],14:[2,5],15:[2,5],16:[1,16],18:[2,5]},{5:[2,6],6:[2,6],7:[2,6],8:[2,6],9:[2,6],10:[2,6],11:[2,6],12:[2,6],13:[2,6],14:[2,6],15:[2,6],16:[1,16],18:[2,6]},{5:[2,7],6:[2,7],7:[2,7],8:[2,7],9:[2,7],10:[2,7],11:[2,7],12:[2,7],13:[2,7],14:[2,7],15:[2,7],16:[1,16],18:[2,7]},{5:[2,8],6:[2,8],7:[2,8],8:[2,8],9:[2,8],10:[2,8],11:[2,8],12:[2,8],13:[2,8],14:[2,8],15:[2,8],16:[1,16],18:[2,8]},{5:[2,9],6:[2,9],7:[2,9],8:[2,9],9:[2,9],10:[2,9],11:[2,9],12:[2,9],13:[2,9],14:[2,9],15:[2,9],16:[1,16],18:[2,9]},{5:[2,10],6:[2,10],7:[2,10],8:[2,10],9:[2,10],10:[2,10],11:[2,10],12:[2,10],13:[2,10],14:[2,10],15:[2,10],16:[1,16],18:[2,10]},{5:[2,11],6:[2,11],7:[2,11],8:[2,11],9:[2,11],10:[2,11],11:[2,11],12:[2,11],13:[2,11],14:[2,11],15:[2,11],16:[2,11],18:[2,11]},{5:[2,12],6:[2,12],7:[2,12],8:[2,12],9:[2,12],10:[2,12],11:[2,12],12:[2,12],13:[2,12],14:[2,12],15:[2,12],16:[2,12],18:[2,12]},{4:30,17:[1,3],19:[1,4],20:[1,5]},{5:[2,2],6:[1,7],7:[2,2],8:[1,8],9:[1,9],10:[1,10],11:[1,11],12:[1,12],13:[1,13],14:[1,14],15:[1,15],16:[1,16],18:[2,2]}],
  17953. defaultActions: {6:[2,1]},
  17954. parseError: function parseError(str, hash) {
  17955. throw new Error(str);
  17956. },
  17957. parse: function parse(input) {
  17958. var self = this,
  17959. stack = [0],
  17960. vstack = [null], // semantic value stack
  17961. lstack = [], // location stack
  17962. table = this.table,
  17963. yytext = '',
  17964. yylineno = 0,
  17965. yyleng = 0,
  17966. recovering = 0,
  17967. TERROR = 2,
  17968. EOF = 1;
  17969. //this.reductionCount = this.shiftCount = 0;
  17970. this.lexer.setInput(input);
  17971. this.lexer.yy = this.yy;
  17972. this.yy.lexer = this.lexer;
  17973. if (typeof this.lexer.yylloc == 'undefined')
  17974. this.lexer.yylloc = {};
  17975. var yyloc = this.lexer.yylloc;
  17976. lstack.push(yyloc);
  17977. if (typeof this.yy.parseError === 'function')
  17978. this.parseError = this.yy.parseError;
  17979. function popStack (n) {
  17980. stack.length = stack.length - 2*n;
  17981. vstack.length = vstack.length - n;
  17982. lstack.length = lstack.length - n;
  17983. }
  17984. function lex() {
  17985. var token;
  17986. token = self.lexer.lex() || 1; // $end = 1
  17987. // if token isn't its numeric value, convert
  17988. if (typeof token !== 'number') {
  17989. token = self.symbols_[token] || token;
  17990. }
  17991. return token;
  17992. }
  17993. var symbol, preErrorSymbol, state, action, a, r, yyval={},p,len,newState, expected;
  17994. while (true) {
  17995. // retreive state number from top of stack
  17996. state = stack[stack.length-1];
  17997. // use default actions if available
  17998. if (this.defaultActions[state]) {
  17999. action = this.defaultActions[state];
  18000. } else {
  18001. if (symbol == null)
  18002. symbol = lex();
  18003. // read action for current state and first input
  18004. action = table[state] && table[state][symbol];
  18005. }
  18006. // handle parse error
  18007. _handle_error:
  18008. if (typeof action === 'undefined' || !action.length || !action[0]) {
  18009. if (!recovering) {
  18010. // Report error
  18011. expected = [];
  18012. for (p in table[state]) if (this.terminals_[p] && p > 2) {
  18013. expected.push("'"+this.terminals_[p]+"'");
  18014. }
  18015. var errStr = '';
  18016. if (this.lexer.showPosition) {
  18017. errStr = 'Parse error on line '+(yylineno+1)+":\n"+this.lexer.showPosition()+"\nExpecting "+expected.join(', ') + ", got '" + this.terminals_[symbol]+ "'";
  18018. } else {
  18019. errStr = 'Parse error on line '+(yylineno+1)+": Unexpected " +
  18020. (symbol == 1 /*EOF*/ ? "end of input" :
  18021. ("'"+(this.terminals_[symbol] || symbol)+"'"));
  18022. }
  18023. this.parseError(errStr,
  18024. {text: this.lexer.match, token: this.terminals_[symbol] || symbol, line: this.lexer.yylineno, loc: yyloc, expected: expected});
  18025. }
  18026. // just recovered from another error
  18027. if (recovering == 3) {
  18028. if (symbol == EOF) {
  18029. throw new Error(errStr || 'Parsing halted.');
  18030. }
  18031. // discard current lookahead and grab another
  18032. yyleng = this.lexer.yyleng;
  18033. yytext = this.lexer.yytext;
  18034. yylineno = this.lexer.yylineno;
  18035. yyloc = this.lexer.yylloc;
  18036. symbol = lex();
  18037. }
  18038. // try to recover from error
  18039. while (1) {
  18040. // check for error recovery rule in this state
  18041. if ((TERROR.toString()) in table[state]) {
  18042. break;
  18043. }
  18044. if (state == 0) {
  18045. throw new Error(errStr || 'Parsing halted.');
  18046. }
  18047. popStack(1);
  18048. state = stack[stack.length-1];
  18049. }
  18050. preErrorSymbol = symbol; // save the lookahead token
  18051. symbol = TERROR; // insert generic error symbol as new lookahead
  18052. state = stack[stack.length-1];
  18053. action = table[state] && table[state][TERROR];
  18054. recovering = 3; // allow 3 real symbols to be shifted before reporting a new error
  18055. }
  18056. // this shouldn't happen, unless resolve defaults are off
  18057. if (action[0] instanceof Array && action.length > 1) {
  18058. throw new Error('Parse Error: multiple actions possible at state: '+state+', token: '+symbol);
  18059. }
  18060. switch (action[0]) {
  18061. case 1: // shift
  18062. //this.shiftCount++;
  18063. stack.push(symbol);
  18064. vstack.push(this.lexer.yytext);
  18065. lstack.push(this.lexer.yylloc);
  18066. stack.push(action[1]); // push state
  18067. symbol = null;
  18068. if (!preErrorSymbol) { // normal execution/no error
  18069. yyleng = this.lexer.yyleng;
  18070. yytext = this.lexer.yytext;
  18071. yylineno = this.lexer.yylineno;
  18072. yyloc = this.lexer.yylloc;
  18073. if (recovering > 0)
  18074. recovering--;
  18075. } else { // error just occurred, resume old lookahead f/ before error
  18076. symbol = preErrorSymbol;
  18077. preErrorSymbol = null;
  18078. }
  18079. break;
  18080. case 2: // reduce
  18081. //this.reductionCount++;
  18082. len = this.productions_[action[1]][1];
  18083. // perform semantic action
  18084. yyval.$ = vstack[vstack.length-len]; // default to $$ = $1
  18085. // default location, uses first token for firsts, last for lasts
  18086. yyval._$ = {
  18087. first_line: lstack[lstack.length-(len||1)].first_line,
  18088. last_line: lstack[lstack.length-1].last_line,
  18089. first_column: lstack[lstack.length-(len||1)].first_column,
  18090. last_column: lstack[lstack.length-1].last_column
  18091. };
  18092. r = this.performAction.call(yyval, yytext, yyleng, yylineno, this.yy, action[1], vstack, lstack);
  18093. if (typeof r !== 'undefined') {
  18094. return r;
  18095. }
  18096. // pop off stack
  18097. if (len) {
  18098. stack = stack.slice(0,-1*len*2);
  18099. vstack = vstack.slice(0, -1*len);
  18100. lstack = lstack.slice(0, -1*len);
  18101. }
  18102. stack.push(this.productions_[action[1]][0]); // push nonterminal (reduce)
  18103. vstack.push(yyval.$);
  18104. lstack.push(yyval._$);
  18105. // goto new state = table[STATE][NONTERMINAL]
  18106. newState = table[stack[stack.length-2]][stack[stack.length-1]];
  18107. stack.push(newState);
  18108. break;
  18109. case 3: // accept
  18110. return true;
  18111. }
  18112. }
  18113. return true;
  18114. }};/* Jison generated lexer */
  18115. var lexer = (function(){
  18116. var lexer = ({EOF:1,
  18117. parseError:function parseError(str, hash) {
  18118. if (this.yy.parseError) {
  18119. this.yy.parseError(str, hash);
  18120. } else {
  18121. throw new Error(str);
  18122. }
  18123. },
  18124. setInput:function (input) {
  18125. this._input = input;
  18126. this._more = this._less = this.done = false;
  18127. this.yylineno = this.yyleng = 0;
  18128. this.yytext = this.matched = this.match = '';
  18129. this.conditionStack = ['INITIAL'];
  18130. this.yylloc = {first_line:1,first_column:0,last_line:1,last_column:0};
  18131. return this;
  18132. },
  18133. input:function () {
  18134. var ch = this._input[0];
  18135. this.yytext+=ch;
  18136. this.yyleng++;
  18137. this.match+=ch;
  18138. this.matched+=ch;
  18139. var lines = ch.match(/\n/);
  18140. if (lines) this.yylineno++;
  18141. this._input = this._input.slice(1);
  18142. return ch;
  18143. },
  18144. unput:function (ch) {
  18145. this._input = ch + this._input;
  18146. return this;
  18147. },
  18148. more:function () {
  18149. this._more = true;
  18150. return this;
  18151. },
  18152. pastInput:function () {
  18153. var past = this.matched.substr(0, this.matched.length - this.match.length);
  18154. return (past.length > 20 ? '...':'') + past.substr(-20).replace(/\n/g, "");
  18155. },
  18156. upcomingInput:function () {
  18157. var next = this.match;
  18158. if (next.length < 20) {
  18159. next += this._input.substr(0, 20-next.length);
  18160. }
  18161. return (next.substr(0,20)+(next.length > 20 ? '...':'')).replace(/\n/g, "");
  18162. },
  18163. showPosition:function () {
  18164. var pre = this.pastInput();
  18165. var c = new Array(pre.length + 1).join("-");
  18166. return pre + this.upcomingInput() + "\n" + c+"^";
  18167. },
  18168. next:function () {
  18169. if (this.done) {
  18170. return this.EOF;
  18171. }
  18172. if (!this._input) this.done = true;
  18173. var token,
  18174. match,
  18175. col,
  18176. lines;
  18177. if (!this._more) {
  18178. this.yytext = '';
  18179. this.match = '';
  18180. }
  18181. var rules = this._currentRules();
  18182. for (var i=0;i < rules.length; i++) {
  18183. match = this._input.match(this.rules[rules[i]]);
  18184. if (match) {
  18185. lines = match[0].match(/\n.*/g);
  18186. if (lines) this.yylineno += lines.length;
  18187. this.yylloc = {first_line: this.yylloc.last_line,
  18188. last_line: this.yylineno+1,
  18189. first_column: this.yylloc.last_column,
  18190. last_column: lines ? lines[lines.length-1].length-1 : this.yylloc.last_column + match[0].length}
  18191. this.yytext += match[0];
  18192. this.match += match[0];
  18193. this.matches = match;
  18194. this.yyleng = this.yytext.length;
  18195. this._more = false;
  18196. this._input = this._input.slice(match[0].length);
  18197. this.matched += match[0];
  18198. token = this.performAction.call(this, this.yy, this, rules[i],this.conditionStack[this.conditionStack.length-1]);
  18199. if (token) return token;
  18200. else return;
  18201. }
  18202. }
  18203. if (this._input === "") {
  18204. return this.EOF;
  18205. } else {
  18206. this.parseError('Lexical error on line '+(this.yylineno+1)+'. Unrecognized text.\n'+this.showPosition(),
  18207. {text: "", token: null, line: this.yylineno});
  18208. }
  18209. },
  18210. lex:function lex() {
  18211. var r = this.next();
  18212. if (typeof r !== 'undefined') {
  18213. return r;
  18214. } else {
  18215. return this.lex();
  18216. }
  18217. },
  18218. begin:function begin(condition) {
  18219. this.conditionStack.push(condition);
  18220. },
  18221. popState:function popState() {
  18222. return this.conditionStack.pop();
  18223. },
  18224. _currentRules:function _currentRules() {
  18225. return this.conditions[this.conditionStack[this.conditionStack.length-1]].rules;
  18226. },
  18227. topState:function () {
  18228. return this.conditionStack[this.conditionStack.length-2];
  18229. },
  18230. pushState:function begin(condition) {
  18231. this.begin(condition);
  18232. }});
  18233. lexer.performAction = function anonymous(yy,yy_,$avoiding_name_collisions,YY_START) {
  18234. var YYSTATE=YY_START;
  18235. switch($avoiding_name_collisions) {
  18236. case 0:/* skip whitespace */
  18237. break;
  18238. case 1:return 20
  18239. break;
  18240. case 2:return 19
  18241. break;
  18242. case 3:return 8
  18243. break;
  18244. case 4:return 9
  18245. break;
  18246. case 5:return 6
  18247. break;
  18248. case 6:return 7
  18249. break;
  18250. case 7:return 11
  18251. break;
  18252. case 8:return 13
  18253. break;
  18254. case 9:return 10
  18255. break;
  18256. case 10:return 12
  18257. break;
  18258. case 11:return 14
  18259. break;
  18260. case 12:return 15
  18261. break;
  18262. case 13:return 16
  18263. break;
  18264. case 14:return 17
  18265. break;
  18266. case 15:return 18
  18267. break;
  18268. case 16:return 5
  18269. break;
  18270. case 17:return 'INVALID'
  18271. break;
  18272. }
  18273. };
  18274. lexer.rules = [/^\s+/,/^[0-9]+(\.[0-9]+)?\b/,/^n\b/,/^\|\|/,/^&&/,/^\?/,/^:/,/^<=/,/^>=/,/^</,/^>/,/^!=/,/^==/,/^%/,/^\(/,/^\)/,/^$/,/^./];
  18275. lexer.conditions = {"INITIAL":{"rules":[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17],"inclusive":true}};return lexer;})()
  18276. parser.lexer = lexer;
  18277. return parser;
  18278. })();
  18279. // End parser
  18280. // Handle node, amd, and global systems
  18281. if (typeof exports !== 'undefined') {
  18282. if (typeof module !== 'undefined' && module.exports) {
  18283. exports = module.exports = Jed;
  18284. }
  18285. exports.Jed = Jed;
  18286. }
  18287. else {
  18288. if (typeof define === 'function' && define.amd) {
  18289. define('jed',[],function() {
  18290. return Jed;
  18291. });
  18292. }
  18293. // Leak a global regardless of module system
  18294. root['Jed'] = Jed;
  18295. }
  18296. })(this);
  18297. // Copyright (c) Jupyter Development Team.
  18298. // Distributed under the terms of the Modified BSD License.
  18299. // Module to handle i18n ( Internationalization ) and translated UI
  18300. define('base/js/i18n',[
  18301. 'jed'
  18302. ], function(Jed) {
  18303. "use strict";
  18304. var i18n = new Jed(document.nbjs_translations);
  18305. i18n._ = i18n.gettext;
  18306. i18n.msg = i18n; // Just a place holder until the init promise resolves.
  18307. return i18n;
  18308. });
  18309. // Copyright (c) Jupyter Development Team.
  18310. // Distributed under the terms of the Modified BSD License.
  18311. define('base/js/dialog',['jquery',
  18312. 'codemirror/lib/codemirror',
  18313. 'bootstrap',
  18314. 'base/js/i18n'],
  18315. function($, CodeMirror, bs, i18n) {
  18316. "use strict";
  18317. /**
  18318. * A wrapper around bootstrap modal for easier use
  18319. * Pass it an option dictionary with the following properties:
  18320. *
  18321. * - body : <string> or <DOM node>, main content of the dialog
  18322. * if pass a <string> it will be wrapped in a p tag and
  18323. * html element escaped, unless you specify sanitize=false
  18324. * option.
  18325. * - title : Dialog title, default to empty string.
  18326. * - buttons : dict of btn_options who keys are button label.
  18327. * see btn_options below for description
  18328. * - open : callback to trigger on dialog open.
  18329. * - destroy:
  18330. * - notebook : notebook instance
  18331. * - keyboard_manager: keyboard manager instance.
  18332. *
  18333. * Unlike bootstrap modals, the backdrop options is set by default
  18334. * to 'static'.
  18335. *
  18336. * The rest of the options are passed as is to bootstrap modals.
  18337. *
  18338. * btn_options: dict with the following property:
  18339. *
  18340. * - click : callback to trigger on click
  18341. * - class : css classes to add to button.
  18342. *
  18343. *
  18344. *
  18345. **/
  18346. var modal = function (options) {
  18347. var modal = $("<div/>")
  18348. .addClass("modal")
  18349. .addClass("fade")
  18350. .attr("role", "dialog");
  18351. var dialog = $("<div/>")
  18352. .addClass("modal-dialog")
  18353. .appendTo(modal);
  18354. var dialog_content = $("<div/>")
  18355. .addClass("modal-content")
  18356. .appendTo(dialog);
  18357. if(typeof(options.body) === 'string' && options.sanitize !== false){
  18358. options.body = $("<p/>").text(options.body);
  18359. }
  18360. dialog_content.append(
  18361. $("<div/>")
  18362. .addClass("modal-header")
  18363. .mousedown(function() {
  18364. $(".modal").draggable({handle: '.modal-header'});
  18365. })
  18366. .append($("<button>")
  18367. .attr("type", "button")
  18368. .addClass("close")
  18369. .attr("data-dismiss", "modal")
  18370. .attr("aria-hidden", "true")
  18371. .html("&times;")
  18372. ).append(
  18373. $("<h4/>")
  18374. .addClass('modal-title')
  18375. .text(options.title || "")
  18376. )
  18377. ).append(
  18378. $("<div/>")
  18379. .addClass("modal-body")
  18380. .append(
  18381. options.body || $("<p/>")
  18382. )
  18383. );
  18384. var footer = $("<div/>").addClass("modal-footer");
  18385. var default_button;
  18386. for (var label in options.buttons) {
  18387. var btn_opts = options.buttons[label];
  18388. var button = $("<button/>")
  18389. .addClass("btn btn-default btn-sm")
  18390. .attr("data-dismiss", "modal")
  18391. .text(i18n.msg.translate(label).fetch());
  18392. if (btn_opts.id) {
  18393. button.attr('id', btn_opts.id);
  18394. }
  18395. if (btn_opts.click) {
  18396. button.click($.proxy(btn_opts.click, dialog_content));
  18397. }
  18398. if (btn_opts.class) {
  18399. button.addClass(btn_opts.class);
  18400. }
  18401. footer.append(button);
  18402. if (options.default_button && label === options.default_button) {
  18403. default_button = button;
  18404. }
  18405. }
  18406. if (!options.default_button) {
  18407. default_button = footer.find("button").last();
  18408. }
  18409. dialog_content.append(footer);
  18410. // hook up on-open event
  18411. modal.on("shown.bs.modal", function () {
  18412. setTimeout(function () {
  18413. default_button.focus();
  18414. if (options.open) {
  18415. $.proxy(options.open, modal)();
  18416. }
  18417. }, 0);
  18418. });
  18419. // destroy modal on hide, unless explicitly asked not to
  18420. if (options.destroy === undefined || options.destroy) {
  18421. modal.on("hidden.bs.modal", function () {
  18422. modal.remove();
  18423. });
  18424. }
  18425. modal.on("hidden.bs.modal", function () {
  18426. if (options.notebook) {
  18427. var cell = options.notebook.get_selected_cell();
  18428. if (cell) cell.select();
  18429. }
  18430. if (options.keyboard_manager) {
  18431. options.keyboard_manager.enable();
  18432. options.keyboard_manager.command_mode();
  18433. }
  18434. });
  18435. if (options.keyboard_manager) {
  18436. options.keyboard_manager.disable();
  18437. }
  18438. if(options.backdrop === undefined){
  18439. options.backdrop = 'static';
  18440. }
  18441. return modal.modal(options);
  18442. };
  18443. var kernel_modal = function (options) {
  18444. /**
  18445. * only one kernel dialog should be open at a time -- but
  18446. * other modal dialogs can still be open
  18447. */
  18448. $('.kernel-modal').modal('hide');
  18449. var dialog = modal(options);
  18450. dialog.addClass('kernel-modal');
  18451. return dialog;
  18452. };
  18453. var edit_metadata = function (options) {
  18454. options.name = options.name || "Cell";
  18455. var error_div = $('<div/>').css('color', 'red');
  18456. var message_cell =
  18457. i18n.msg._("Manually edit the JSON below to manipulate the metadata for this cell.");
  18458. var message_notebook =
  18459. i18n.msg._("Manually edit the JSON below to manipulate the metadata for this notebook.");
  18460. var message_end =
  18461. i18n.msg._(" We recommend putting custom metadata attributes in an appropriately named substructure," +
  18462. " so they don't conflict with those of others.");
  18463. var message;
  18464. if (options.name === 'Notebook') {
  18465. message = message_notebook + message_end;
  18466. } else {
  18467. message = message_cell + message_end;
  18468. }
  18469. var textarea = $('<textarea/>')
  18470. .attr('rows', '13')
  18471. .attr('cols', '80')
  18472. .attr('name', 'metadata')
  18473. .text(JSON.stringify(options.md || {}, null, 2));
  18474. var dialogform = $('<div/>').attr('title', i18n.msg._('Edit the metadata'))
  18475. .append(
  18476. $('<form/>').append(
  18477. $('<fieldset/>').append(
  18478. $('<label/>')
  18479. .attr('for','metadata')
  18480. .text(message)
  18481. )
  18482. .append(error_div)
  18483. .append($('<br/>'))
  18484. .append(textarea)
  18485. )
  18486. );
  18487. var editor = CodeMirror.fromTextArea(textarea[0], {
  18488. lineNumbers: true,
  18489. matchBrackets: true,
  18490. indentUnit: 2,
  18491. autoIndent: true,
  18492. mode: 'application/json',
  18493. });
  18494. var title_msg;
  18495. if (options.name === "Notebook") {
  18496. title_msg = i18n.msg._("Edit Notebook Metadata");
  18497. } else {
  18498. title_msg = i18n.msg._("Edit Cell Metadata");
  18499. }
  18500. // This statement is used simply so that message extraction
  18501. // will pick up the strings.
  18502. var button_labels = [ i18n.msg._("Cancel"), i18n.msg._("Edit"), i18n.msg._("OK"), i18n.msg._("Apply")];
  18503. var modal_obj = modal({
  18504. title: title_msg,
  18505. body: dialogform,
  18506. default_button: "Cancel",
  18507. buttons: {
  18508. Cancel: {},
  18509. Edit: { class : "btn-primary",
  18510. click: function() {
  18511. /**
  18512. * validate json and set it
  18513. */
  18514. var new_md;
  18515. try {
  18516. new_md = JSON.parse(editor.getValue());
  18517. } catch(e) {
  18518. console.log(e);
  18519. error_div.text(i18n.msg._('WARNING: Could not save invalid JSON.'));
  18520. return false;
  18521. }
  18522. options.callback(new_md);
  18523. }
  18524. }
  18525. },
  18526. notebook: options.notebook,
  18527. keyboard_manager: options.keyboard_manager,
  18528. });
  18529. modal_obj.on('shown.bs.modal', function(){ editor.refresh(); });
  18530. };
  18531. var edit_attachments = function (options) {
  18532. // This shows the Edit Attachments dialog. This dialog allows the
  18533. // user to delete attachments. We show a list of attachments to
  18534. // the user and he can mark some of them for deletion. The deletion
  18535. // is applied when the 'Apply' button of this dialog is pressed.
  18536. var message;
  18537. var attachments_list;
  18538. if (Object.keys(options.attachments).length == 0) {
  18539. message = i18n.msg._("There are no attachments for this cell.");
  18540. attachments_list = $('<div>');
  18541. } else {
  18542. message = i18n.msg._("Current cell attachments");
  18543. attachments_list = $('<div>')
  18544. .addClass('list_container')
  18545. .append(
  18546. $('<div>')
  18547. .addClass('row list_header')
  18548. .append(
  18549. $('<div>')
  18550. .text(i18n.msg._('Attachments'))
  18551. )
  18552. );
  18553. // This is a set containing keys of attachments to be deleted when
  18554. // the Apply button is clicked
  18555. var to_delete = {};
  18556. var refresh_attachments_list = function() {
  18557. $(attachments_list).find('.row').remove();
  18558. for (var key in options.attachments) {
  18559. var mime = Object.keys(options.attachments[key])[0];
  18560. var deleted = key in to_delete;
  18561. // This ensures the current value of key is captured since
  18562. // javascript only has function scope
  18563. var btn;
  18564. // Trash/restore button
  18565. (function(){
  18566. var _key = key;
  18567. btn = $('<button>')
  18568. .addClass('btn btn-default btn-xs')
  18569. .css('display', 'inline-block');
  18570. if (deleted) {
  18571. btn.attr('title', i18n.msg._('Restore'))
  18572. .append(
  18573. $('<i>')
  18574. .addClass('fa fa-plus')
  18575. );
  18576. btn.click(function() {
  18577. delete to_delete[_key];
  18578. refresh_attachments_list();
  18579. });
  18580. } else {
  18581. btn.attr('title', i18n.msg._('Delete'))
  18582. .addClass('btn-danger')
  18583. .append(
  18584. $('<i>')
  18585. .addClass('fa fa-trash')
  18586. );
  18587. btn.click(function() {
  18588. to_delete[_key] = true;
  18589. refresh_attachments_list();
  18590. });
  18591. }
  18592. return btn;
  18593. })();
  18594. var row = $('<div>')
  18595. .addClass('col-md-12 att_row')
  18596. .append(
  18597. $('<div>')
  18598. .addClass('row')
  18599. .append(
  18600. $('<div>')
  18601. .addClass('att-name col-xs-4')
  18602. .text(key)
  18603. )
  18604. .append(
  18605. $('<div>')
  18606. .addClass('col-xs-4 text-muted')
  18607. .text(mime)
  18608. )
  18609. .append(
  18610. $('<div>')
  18611. .addClass('item-buttons pull-right')
  18612. .append(btn)
  18613. )
  18614. );
  18615. if (deleted) {
  18616. row.find('.att-name')
  18617. .css('text-decoration', 'line-through');
  18618. }
  18619. attachments_list.append($('<div>')
  18620. .addClass('list_item row')
  18621. .append(row)
  18622. );
  18623. }
  18624. };
  18625. refresh_attachments_list();
  18626. }
  18627. var dialogform = $('<div/>')
  18628. .attr('title', i18n.msg._('Edit attachments'))
  18629. .append(message)
  18630. .append('<br />')
  18631. .append(attachments_list);
  18632. var title_msg;
  18633. if ( options.name === "Notebook" ) {
  18634. title_msg = i18n.msg._("Edit Notebook Attachments");
  18635. } else {
  18636. title_msg = i18n.msg._("Edit Cell Attachments");
  18637. }
  18638. var modal_obj = modal({
  18639. title: title_msg,
  18640. body: dialogform,
  18641. buttons: {
  18642. Apply: { class : "btn-primary",
  18643. click: function() {
  18644. for (var key in to_delete) {
  18645. delete options.attachments[key];
  18646. }
  18647. options.callback(options.attachments);
  18648. }
  18649. },
  18650. Cancel: {}
  18651. },
  18652. notebook: options.notebook,
  18653. keyboard_manager: options.keyboard_manager,
  18654. });
  18655. };
  18656. var insert_image = function (options) {
  18657. var message =
  18658. i18n.msg._("Select a file to insert.");
  18659. var file_input = $('<input/>')
  18660. .attr('type', 'file')
  18661. .attr('accept', 'image/*')
  18662. .attr('name', 'file')
  18663. .on('change', function(file) {
  18664. var $btn = $(modal_obj).find('#btn_ok');
  18665. if (this.files.length > 0) {
  18666. $btn.removeClass('disabled');
  18667. } else {
  18668. $btn.addClass('disabled');
  18669. }
  18670. });
  18671. var dialogform = $('<div/>').attr('title', i18n.msg._('Edit attachments'))
  18672. .append(
  18673. $('<form id="insert-image-form" />').append(
  18674. $('<fieldset/>').append(
  18675. $('<label/>')
  18676. .attr('for','file')
  18677. .text(message)
  18678. )
  18679. .append($('<br/>'))
  18680. .append(file_input)
  18681. )
  18682. );
  18683. var modal_obj = modal({
  18684. title: i18n.msg._("Select a file"),
  18685. body: dialogform,
  18686. buttons: {
  18687. OK: {
  18688. id : 'btn_ok',
  18689. class : "btn-primary disabled",
  18690. click: function() {
  18691. options.callback(file_input[0].files[0]);
  18692. }
  18693. },
  18694. Cancel: {}
  18695. },
  18696. notebook: options.notebook,
  18697. keyboard_manager: options.keyboard_manager,
  18698. });
  18699. };
  18700. var dialog = {
  18701. modal : modal,
  18702. kernel_modal : kernel_modal,
  18703. edit_metadata : edit_metadata,
  18704. edit_attachments : edit_attachments,
  18705. insert_image : insert_image
  18706. };
  18707. return dialog;
  18708. });
  18709. // Copyright (c) Jupyter Development Team.
  18710. // Distributed under the terms of the Modified BSD License.
  18711. // Give us an object to bind all events to. This object should be created
  18712. // before all other objects so it exists when others register event handlers.
  18713. // To register an event handler:
  18714. //
  18715. // requirejs(['base/js/events'], function (events) {
  18716. // events.on("event.Namespace", function () { do_stuff(); });
  18717. // });
  18718. define('base/js/events',['jquery', 'base/js/namespace'], function($, Jupyter) {
  18719. "use strict";
  18720. // Events singleton
  18721. if (!window._Events) {
  18722. window._Events = function () {};
  18723. window._events = new window._Events();
  18724. }
  18725. // Backwards compatability.
  18726. Jupyter.Events = window._Events;
  18727. Jupyter.events = window._events;
  18728. var events = $([window._events]);
  18729. // catch and log errors in triggered events
  18730. events._original_trigger = events.trigger;
  18731. events.trigger = function (name, data) {
  18732. try {
  18733. this._original_trigger.apply(this, arguments);
  18734. } catch (e) {
  18735. console.error("Exception in event handler for " + name, e, arguments);
  18736. }
  18737. }
  18738. return events;
  18739. });
  18740. // Copyright (c) Jupyter Development Team.
  18741. // Distributed under the terms of the Modified BSD License.
  18742. // Define an object to attach promises to for one-time events.
  18743. define('base/js/promises',['base/js/events', 'base/js/namespace'], function(events, Jupyter) {
  18744. "use strict";
  18745. // Promise to be resolved when the application is initialized.
  18746. // The value is the name of the app on the current page.
  18747. var app_initialized = new Promise(function(resolve, reject) {
  18748. events.on('app_initialized.NotebookApp', function() {
  18749. resolve('NotebookApp');
  18750. });
  18751. events.on('app_initialized.DashboardApp', function() {
  18752. resolve('DashboardApp');
  18753. });
  18754. });
  18755. var promises = {
  18756. app_initialized: app_initialized
  18757. };
  18758. Jupyter.promises = promises;
  18759. return promises;
  18760. });
  18761. // Copyright (c) Jupyter Development Team.
  18762. // Distributed under the terms of the Modified BSD License.
  18763. define('base/js/page',[
  18764. 'jquery',
  18765. 'base/js/events',
  18766. ], function($, events){
  18767. "use strict";
  18768. var Page = function (header_div_selector, site_div_selector) {
  18769. /**
  18770. * Constructor
  18771. *
  18772. * Parameters
  18773. * header_div_selector: string
  18774. * site_div_selector: string
  18775. */
  18776. this.header_div_element = $(header_div_selector || 'div#header');
  18777. this.site_div_element = $(site_div_selector || 'div#site');
  18778. this.bind_events();
  18779. };
  18780. Page.prototype.bind_events = function () {
  18781. // resize site on:
  18782. // - window resize
  18783. // - header change
  18784. // - page load
  18785. var _handle_resize = $.proxy(this._resize_site, this);
  18786. $(window).resize(_handle_resize);
  18787. // On document ready, resize codemirror.
  18788. $(document).ready(_handle_resize);
  18789. events.on('resize-header.Page', _handle_resize);
  18790. };
  18791. Page.prototype.show = function () {
  18792. /**
  18793. * The header and site divs start out hidden to prevent FLOUC.
  18794. * Main scripts should call this method after styling everything.
  18795. */
  18796. this.show_header();
  18797. this.show_site();
  18798. };
  18799. Page.prototype.show_header = function () {
  18800. /**
  18801. * The header and site divs start out hidden to prevent FLOUC.
  18802. * Main scripts should call this method after styling everything.
  18803. */
  18804. this.header_div_element.css('display','block');
  18805. };
  18806. Page.prototype.show_site = function () {
  18807. /**
  18808. * The header and site divs start out hidden to prevent FLOUC.
  18809. * Main scripts should call this method after styling everything.
  18810. */
  18811. this.site_div_element.css('display', 'block');
  18812. this._resize_site();
  18813. };
  18814. Page.prototype._resize_site = function(e) {
  18815. /**
  18816. * Update the site's size.
  18817. */
  18818. // In the case an event is passed in, only trigger if the event does
  18819. // *not* have a target DOM node (i.e., it is not bubbling up). See
  18820. // https://bugs.jquery.com/ticket/9841#comment:8
  18821. if (!(e && e.target && e.target.tagName)) {
  18822. $('div#site').height($(window).height() - $('#header').height());
  18823. }
  18824. };
  18825. return {'Page': Page};
  18826. });
  18827. ;(function (global, factory) {
  18828. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  18829. typeof define === 'function' && define.amd ? define('moment',factory) :
  18830. global.moment = factory()
  18831. }(this, (function () { 'use strict';
  18832. var hookCallback;
  18833. function hooks () {
  18834. return hookCallback.apply(null, arguments);
  18835. }
  18836. // This is done to register the method called with moment()
  18837. // without creating circular dependencies.
  18838. function setHookCallback (callback) {
  18839. hookCallback = callback;
  18840. }
  18841. function isArray(input) {
  18842. return input instanceof Array || Object.prototype.toString.call(input) === '[object Array]';
  18843. }
  18844. function isObject(input) {
  18845. // IE8 will treat undefined and null as object if it wasn't for
  18846. // input != null
  18847. return input != null && Object.prototype.toString.call(input) === '[object Object]';
  18848. }
  18849. function isObjectEmpty(obj) {
  18850. if (Object.getOwnPropertyNames) {
  18851. return (Object.getOwnPropertyNames(obj).length === 0);
  18852. } else {
  18853. var k;
  18854. for (k in obj) {
  18855. if (obj.hasOwnProperty(k)) {
  18856. return false;
  18857. }
  18858. }
  18859. return true;
  18860. }
  18861. }
  18862. function isUndefined(input) {
  18863. return input === void 0;
  18864. }
  18865. function isNumber(input) {
  18866. return typeof input === 'number' || Object.prototype.toString.call(input) === '[object Number]';
  18867. }
  18868. function isDate(input) {
  18869. return input instanceof Date || Object.prototype.toString.call(input) === '[object Date]';
  18870. }
  18871. function map(arr, fn) {
  18872. var res = [], i;
  18873. for (i = 0; i < arr.length; ++i) {
  18874. res.push(fn(arr[i], i));
  18875. }
  18876. return res;
  18877. }
  18878. function hasOwnProp(a, b) {
  18879. return Object.prototype.hasOwnProperty.call(a, b);
  18880. }
  18881. function extend(a, b) {
  18882. for (var i in b) {
  18883. if (hasOwnProp(b, i)) {
  18884. a[i] = b[i];
  18885. }
  18886. }
  18887. if (hasOwnProp(b, 'toString')) {
  18888. a.toString = b.toString;
  18889. }
  18890. if (hasOwnProp(b, 'valueOf')) {
  18891. a.valueOf = b.valueOf;
  18892. }
  18893. return a;
  18894. }
  18895. function createUTC (input, format, locale, strict) {
  18896. return createLocalOrUTC(input, format, locale, strict, true).utc();
  18897. }
  18898. function defaultParsingFlags() {
  18899. // We need to deep clone this object.
  18900. return {
  18901. empty : false,
  18902. unusedTokens : [],
  18903. unusedInput : [],
  18904. overflow : -2,
  18905. charsLeftOver : 0,
  18906. nullInput : false,
  18907. invalidMonth : null,
  18908. invalidFormat : false,
  18909. userInvalidated : false,
  18910. iso : false,
  18911. parsedDateParts : [],
  18912. meridiem : null,
  18913. rfc2822 : false,
  18914. weekdayMismatch : false
  18915. };
  18916. }
  18917. function getParsingFlags(m) {
  18918. if (m._pf == null) {
  18919. m._pf = defaultParsingFlags();
  18920. }
  18921. return m._pf;
  18922. }
  18923. var some;
  18924. if (Array.prototype.some) {
  18925. some = Array.prototype.some;
  18926. } else {
  18927. some = function (fun) {
  18928. var t = Object(this);
  18929. var len = t.length >>> 0;
  18930. for (var i = 0; i < len; i++) {
  18931. if (i in t && fun.call(this, t[i], i, t)) {
  18932. return true;
  18933. }
  18934. }
  18935. return false;
  18936. };
  18937. }
  18938. function isValid(m) {
  18939. if (m._isValid == null) {
  18940. var flags = getParsingFlags(m);
  18941. var parsedParts = some.call(flags.parsedDateParts, function (i) {
  18942. return i != null;
  18943. });
  18944. var isNowValid = !isNaN(m._d.getTime()) &&
  18945. flags.overflow < 0 &&
  18946. !flags.empty &&
  18947. !flags.invalidMonth &&
  18948. !flags.invalidWeekday &&
  18949. !flags.weekdayMismatch &&
  18950. !flags.nullInput &&
  18951. !flags.invalidFormat &&
  18952. !flags.userInvalidated &&
  18953. (!flags.meridiem || (flags.meridiem && parsedParts));
  18954. if (m._strict) {
  18955. isNowValid = isNowValid &&
  18956. flags.charsLeftOver === 0 &&
  18957. flags.unusedTokens.length === 0 &&
  18958. flags.bigHour === undefined;
  18959. }
  18960. if (Object.isFrozen == null || !Object.isFrozen(m)) {
  18961. m._isValid = isNowValid;
  18962. }
  18963. else {
  18964. return isNowValid;
  18965. }
  18966. }
  18967. return m._isValid;
  18968. }
  18969. function createInvalid (flags) {
  18970. var m = createUTC(NaN);
  18971. if (flags != null) {
  18972. extend(getParsingFlags(m), flags);
  18973. }
  18974. else {
  18975. getParsingFlags(m).userInvalidated = true;
  18976. }
  18977. return m;
  18978. }
  18979. // Plugins that add properties should also add the key here (null value),
  18980. // so we can properly clone ourselves.
  18981. var momentProperties = hooks.momentProperties = [];
  18982. function copyConfig(to, from) {
  18983. var i, prop, val;
  18984. if (!isUndefined(from._isAMomentObject)) {
  18985. to._isAMomentObject = from._isAMomentObject;
  18986. }
  18987. if (!isUndefined(from._i)) {
  18988. to._i = from._i;
  18989. }
  18990. if (!isUndefined(from._f)) {
  18991. to._f = from._f;
  18992. }
  18993. if (!isUndefined(from._l)) {
  18994. to._l = from._l;
  18995. }
  18996. if (!isUndefined(from._strict)) {
  18997. to._strict = from._strict;
  18998. }
  18999. if (!isUndefined(from._tzm)) {
  19000. to._tzm = from._tzm;
  19001. }
  19002. if (!isUndefined(from._isUTC)) {
  19003. to._isUTC = from._isUTC;
  19004. }
  19005. if (!isUndefined(from._offset)) {
  19006. to._offset = from._offset;
  19007. }
  19008. if (!isUndefined(from._pf)) {
  19009. to._pf = getParsingFlags(from);
  19010. }
  19011. if (!isUndefined(from._locale)) {
  19012. to._locale = from._locale;
  19013. }
  19014. if (momentProperties.length > 0) {
  19015. for (i = 0; i < momentProperties.length; i++) {
  19016. prop = momentProperties[i];
  19017. val = from[prop];
  19018. if (!isUndefined(val)) {
  19019. to[prop] = val;
  19020. }
  19021. }
  19022. }
  19023. return to;
  19024. }
  19025. var updateInProgress = false;
  19026. // Moment prototype object
  19027. function Moment(config) {
  19028. copyConfig(this, config);
  19029. this._d = new Date(config._d != null ? config._d.getTime() : NaN);
  19030. if (!this.isValid()) {
  19031. this._d = new Date(NaN);
  19032. }
  19033. // Prevent infinite loop in case updateOffset creates new moment
  19034. // objects.
  19035. if (updateInProgress === false) {
  19036. updateInProgress = true;
  19037. hooks.updateOffset(this);
  19038. updateInProgress = false;
  19039. }
  19040. }
  19041. function isMoment (obj) {
  19042. return obj instanceof Moment || (obj != null && obj._isAMomentObject != null);
  19043. }
  19044. function absFloor (number) {
  19045. if (number < 0) {
  19046. // -0 -> 0
  19047. return Math.ceil(number) || 0;
  19048. } else {
  19049. return Math.floor(number);
  19050. }
  19051. }
  19052. function toInt(argumentForCoercion) {
  19053. var coercedNumber = +argumentForCoercion,
  19054. value = 0;
  19055. if (coercedNumber !== 0 && isFinite(coercedNumber)) {
  19056. value = absFloor(coercedNumber);
  19057. }
  19058. return value;
  19059. }
  19060. // compare two arrays, return the number of differences
  19061. function compareArrays(array1, array2, dontConvert) {
  19062. var len = Math.min(array1.length, array2.length),
  19063. lengthDiff = Math.abs(array1.length - array2.length),
  19064. diffs = 0,
  19065. i;
  19066. for (i = 0; i < len; i++) {
  19067. if ((dontConvert && array1[i] !== array2[i]) ||
  19068. (!dontConvert && toInt(array1[i]) !== toInt(array2[i]))) {
  19069. diffs++;
  19070. }
  19071. }
  19072. return diffs + lengthDiff;
  19073. }
  19074. function warn(msg) {
  19075. if (hooks.suppressDeprecationWarnings === false &&
  19076. (typeof console !== 'undefined') && console.warn) {
  19077. console.warn('Deprecation warning: ' + msg);
  19078. }
  19079. }
  19080. function deprecate(msg, fn) {
  19081. var firstTime = true;
  19082. return extend(function () {
  19083. if (hooks.deprecationHandler != null) {
  19084. hooks.deprecationHandler(null, msg);
  19085. }
  19086. if (firstTime) {
  19087. var args = [];
  19088. var arg;
  19089. for (var i = 0; i < arguments.length; i++) {
  19090. arg = '';
  19091. if (typeof arguments[i] === 'object') {
  19092. arg += '\n[' + i + '] ';
  19093. for (var key in arguments[0]) {
  19094. arg += key + ': ' + arguments[0][key] + ', ';
  19095. }
  19096. arg = arg.slice(0, -2); // Remove trailing comma and space
  19097. } else {
  19098. arg = arguments[i];
  19099. }
  19100. args.push(arg);
  19101. }
  19102. warn(msg + '\nArguments: ' + Array.prototype.slice.call(args).join('') + '\n' + (new Error()).stack);
  19103. firstTime = false;
  19104. }
  19105. return fn.apply(this, arguments);
  19106. }, fn);
  19107. }
  19108. var deprecations = {};
  19109. function deprecateSimple(name, msg) {
  19110. if (hooks.deprecationHandler != null) {
  19111. hooks.deprecationHandler(name, msg);
  19112. }
  19113. if (!deprecations[name]) {
  19114. warn(msg);
  19115. deprecations[name] = true;
  19116. }
  19117. }
  19118. hooks.suppressDeprecationWarnings = false;
  19119. hooks.deprecationHandler = null;
  19120. function isFunction(input) {
  19121. return input instanceof Function || Object.prototype.toString.call(input) === '[object Function]';
  19122. }
  19123. function set (config) {
  19124. var prop, i;
  19125. for (i in config) {
  19126. prop = config[i];
  19127. if (isFunction(prop)) {
  19128. this[i] = prop;
  19129. } else {
  19130. this['_' + i] = prop;
  19131. }
  19132. }
  19133. this._config = config;
  19134. // Lenient ordinal parsing accepts just a number in addition to
  19135. // number + (possibly) stuff coming from _dayOfMonthOrdinalParse.
  19136. // TODO: Remove "ordinalParse" fallback in next major release.
  19137. this._dayOfMonthOrdinalParseLenient = new RegExp(
  19138. (this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) +
  19139. '|' + (/\d{1,2}/).source);
  19140. }
  19141. function mergeConfigs(parentConfig, childConfig) {
  19142. var res = extend({}, parentConfig), prop;
  19143. for (prop in childConfig) {
  19144. if (hasOwnProp(childConfig, prop)) {
  19145. if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
  19146. res[prop] = {};
  19147. extend(res[prop], parentConfig[prop]);
  19148. extend(res[prop], childConfig[prop]);
  19149. } else if (childConfig[prop] != null) {
  19150. res[prop] = childConfig[prop];
  19151. } else {
  19152. delete res[prop];
  19153. }
  19154. }
  19155. }
  19156. for (prop in parentConfig) {
  19157. if (hasOwnProp(parentConfig, prop) &&
  19158. !hasOwnProp(childConfig, prop) &&
  19159. isObject(parentConfig[prop])) {
  19160. // make sure changes to properties don't modify parent config
  19161. res[prop] = extend({}, res[prop]);
  19162. }
  19163. }
  19164. return res;
  19165. }
  19166. function Locale(config) {
  19167. if (config != null) {
  19168. this.set(config);
  19169. }
  19170. }
  19171. var keys;
  19172. if (Object.keys) {
  19173. keys = Object.keys;
  19174. } else {
  19175. keys = function (obj) {
  19176. var i, res = [];
  19177. for (i in obj) {
  19178. if (hasOwnProp(obj, i)) {
  19179. res.push(i);
  19180. }
  19181. }
  19182. return res;
  19183. };
  19184. }
  19185. var defaultCalendar = {
  19186. sameDay : '[Today at] LT',
  19187. nextDay : '[Tomorrow at] LT',
  19188. nextWeek : 'dddd [at] LT',
  19189. lastDay : '[Yesterday at] LT',
  19190. lastWeek : '[Last] dddd [at] LT',
  19191. sameElse : 'L'
  19192. };
  19193. function calendar (key, mom, now) {
  19194. var output = this._calendar[key] || this._calendar['sameElse'];
  19195. return isFunction(output) ? output.call(mom, now) : output;
  19196. }
  19197. var defaultLongDateFormat = {
  19198. LTS : 'h:mm:ss A',
  19199. LT : 'h:mm A',
  19200. L : 'MM/DD/YYYY',
  19201. LL : 'MMMM D, YYYY',
  19202. LLL : 'MMMM D, YYYY h:mm A',
  19203. LLLL : 'dddd, MMMM D, YYYY h:mm A'
  19204. };
  19205. function longDateFormat (key) {
  19206. var format = this._longDateFormat[key],
  19207. formatUpper = this._longDateFormat[key.toUpperCase()];
  19208. if (format || !formatUpper) {
  19209. return format;
  19210. }
  19211. this._longDateFormat[key] = formatUpper.replace(/MMMM|MM|DD|dddd/g, function (val) {
  19212. return val.slice(1);
  19213. });
  19214. return this._longDateFormat[key];
  19215. }
  19216. var defaultInvalidDate = 'Invalid date';
  19217. function invalidDate () {
  19218. return this._invalidDate;
  19219. }
  19220. var defaultOrdinal = '%d';
  19221. var defaultDayOfMonthOrdinalParse = /\d{1,2}/;
  19222. function ordinal (number) {
  19223. return this._ordinal.replace('%d', number);
  19224. }
  19225. var defaultRelativeTime = {
  19226. future : 'in %s',
  19227. past : '%s ago',
  19228. s : 'a few seconds',
  19229. ss : '%d seconds',
  19230. m : 'a minute',
  19231. mm : '%d minutes',
  19232. h : 'an hour',
  19233. hh : '%d hours',
  19234. d : 'a day',
  19235. dd : '%d days',
  19236. M : 'a month',
  19237. MM : '%d months',
  19238. y : 'a year',
  19239. yy : '%d years'
  19240. };
  19241. function relativeTime (number, withoutSuffix, string, isFuture) {
  19242. var output = this._relativeTime[string];
  19243. return (isFunction(output)) ?
  19244. output(number, withoutSuffix, string, isFuture) :
  19245. output.replace(/%d/i, number);
  19246. }
  19247. function pastFuture (diff, output) {
  19248. var format = this._relativeTime[diff > 0 ? 'future' : 'past'];
  19249. return isFunction(format) ? format(output) : format.replace(/%s/i, output);
  19250. }
  19251. var aliases = {};
  19252. function addUnitAlias (unit, shorthand) {
  19253. var lowerCase = unit.toLowerCase();
  19254. aliases[lowerCase] = aliases[lowerCase + 's'] = aliases[shorthand] = unit;
  19255. }
  19256. function normalizeUnits(units) {
  19257. return typeof units === 'string' ? aliases[units] || aliases[units.toLowerCase()] : undefined;
  19258. }
  19259. function normalizeObjectUnits(inputObject) {
  19260. var normalizedInput = {},
  19261. normalizedProp,
  19262. prop;
  19263. for (prop in inputObject) {
  19264. if (hasOwnProp(inputObject, prop)) {
  19265. normalizedProp = normalizeUnits(prop);
  19266. if (normalizedProp) {
  19267. normalizedInput[normalizedProp] = inputObject[prop];
  19268. }
  19269. }
  19270. }
  19271. return normalizedInput;
  19272. }
  19273. var priorities = {};
  19274. function addUnitPriority(unit, priority) {
  19275. priorities[unit] = priority;
  19276. }
  19277. function getPrioritizedUnits(unitsObj) {
  19278. var units = [];
  19279. for (var u in unitsObj) {
  19280. units.push({unit: u, priority: priorities[u]});
  19281. }
  19282. units.sort(function (a, b) {
  19283. return a.priority - b.priority;
  19284. });
  19285. return units;
  19286. }
  19287. function zeroFill(number, targetLength, forceSign) {
  19288. var absNumber = '' + Math.abs(number),
  19289. zerosToFill = targetLength - absNumber.length,
  19290. sign = number >= 0;
  19291. return (sign ? (forceSign ? '+' : '') : '-') +
  19292. Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
  19293. }
  19294. var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g;
  19295. var localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g;
  19296. var formatFunctions = {};
  19297. var formatTokenFunctions = {};
  19298. // token: 'M'
  19299. // padded: ['MM', 2]
  19300. // ordinal: 'Mo'
  19301. // callback: function () { this.month() + 1 }
  19302. function addFormatToken (token, padded, ordinal, callback) {
  19303. var func = callback;
  19304. if (typeof callback === 'string') {
  19305. func = function () {
  19306. return this[callback]();
  19307. };
  19308. }
  19309. if (token) {
  19310. formatTokenFunctions[token] = func;
  19311. }
  19312. if (padded) {
  19313. formatTokenFunctions[padded[0]] = function () {
  19314. return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
  19315. };
  19316. }
  19317. if (ordinal) {
  19318. formatTokenFunctions[ordinal] = function () {
  19319. return this.localeData().ordinal(func.apply(this, arguments), token);
  19320. };
  19321. }
  19322. }
  19323. function removeFormattingTokens(input) {
  19324. if (input.match(/\[[\s\S]/)) {
  19325. return input.replace(/^\[|\]$/g, '');
  19326. }
  19327. return input.replace(/\\/g, '');
  19328. }
  19329. function makeFormatFunction(format) {
  19330. var array = format.match(formattingTokens), i, length;
  19331. for (i = 0, length = array.length; i < length; i++) {
  19332. if (formatTokenFunctions[array[i]]) {
  19333. array[i] = formatTokenFunctions[array[i]];
  19334. } else {
  19335. array[i] = removeFormattingTokens(array[i]);
  19336. }
  19337. }
  19338. return function (mom) {
  19339. var output = '', i;
  19340. for (i = 0; i < length; i++) {
  19341. output += isFunction(array[i]) ? array[i].call(mom, format) : array[i];
  19342. }
  19343. return output;
  19344. };
  19345. }
  19346. // format date using native date object
  19347. function formatMoment(m, format) {
  19348. if (!m.isValid()) {
  19349. return m.localeData().invalidDate();
  19350. }
  19351. format = expandFormat(format, m.localeData());
  19352. formatFunctions[format] = formatFunctions[format] || makeFormatFunction(format);
  19353. return formatFunctions[format](m);
  19354. }
  19355. function expandFormat(format, locale) {
  19356. var i = 5;
  19357. function replaceLongDateFormatTokens(input) {
  19358. return locale.longDateFormat(input) || input;
  19359. }
  19360. localFormattingTokens.lastIndex = 0;
  19361. while (i >= 0 && localFormattingTokens.test(format)) {
  19362. format = format.replace(localFormattingTokens, replaceLongDateFormatTokens);
  19363. localFormattingTokens.lastIndex = 0;
  19364. i -= 1;
  19365. }
  19366. return format;
  19367. }
  19368. var match1 = /\d/; // 0 - 9
  19369. var match2 = /\d\d/; // 00 - 99
  19370. var match3 = /\d{3}/; // 000 - 999
  19371. var match4 = /\d{4}/; // 0000 - 9999
  19372. var match6 = /[+-]?\d{6}/; // -999999 - 999999
  19373. var match1to2 = /\d\d?/; // 0 - 99
  19374. var match3to4 = /\d\d\d\d?/; // 999 - 9999
  19375. var match5to6 = /\d\d\d\d\d\d?/; // 99999 - 999999
  19376. var match1to3 = /\d{1,3}/; // 0 - 999
  19377. var match1to4 = /\d{1,4}/; // 0 - 9999
  19378. var match1to6 = /[+-]?\d{1,6}/; // -999999 - 999999
  19379. var matchUnsigned = /\d+/; // 0 - inf
  19380. var matchSigned = /[+-]?\d+/; // -inf - inf
  19381. var matchOffset = /Z|[+-]\d\d:?\d\d/gi; // +00:00 -00:00 +0000 -0000 or Z
  19382. var matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi; // +00 -00 +00:00 -00:00 +0000 -0000 or Z
  19383. var matchTimestamp = /[+-]?\d+(\.\d{1,3})?/; // 123456789 123456789.123
  19384. // any word (or two) characters or numbers including two/three word month in arabic.
  19385. // includes scottish gaelic two word and hyphenated months
  19386. var matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i;
  19387. var regexes = {};
  19388. function addRegexToken (token, regex, strictRegex) {
  19389. regexes[token] = isFunction(regex) ? regex : function (isStrict, localeData) {
  19390. return (isStrict && strictRegex) ? strictRegex : regex;
  19391. };
  19392. }
  19393. function getParseRegexForToken (token, config) {
  19394. if (!hasOwnProp(regexes, token)) {
  19395. return new RegExp(unescapeFormat(token));
  19396. }
  19397. return regexes[token](config._strict, config._locale);
  19398. }
  19399. // Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
  19400. function unescapeFormat(s) {
  19401. return regexEscape(s.replace('\\', '').replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g, function (matched, p1, p2, p3, p4) {
  19402. return p1 || p2 || p3 || p4;
  19403. }));
  19404. }
  19405. function regexEscape(s) {
  19406. return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
  19407. }
  19408. var tokens = {};
  19409. function addParseToken (token, callback) {
  19410. var i, func = callback;
  19411. if (typeof token === 'string') {
  19412. token = [token];
  19413. }
  19414. if (isNumber(callback)) {
  19415. func = function (input, array) {
  19416. array[callback] = toInt(input);
  19417. };
  19418. }
  19419. for (i = 0; i < token.length; i++) {
  19420. tokens[token[i]] = func;
  19421. }
  19422. }
  19423. function addWeekParseToken (token, callback) {
  19424. addParseToken(token, function (input, array, config, token) {
  19425. config._w = config._w || {};
  19426. callback(input, config._w, config, token);
  19427. });
  19428. }
  19429. function addTimeToArrayFromToken(token, input, config) {
  19430. if (input != null && hasOwnProp(tokens, token)) {
  19431. tokens[token](input, config._a, config, token);
  19432. }
  19433. }
  19434. var YEAR = 0;
  19435. var MONTH = 1;
  19436. var DATE = 2;
  19437. var HOUR = 3;
  19438. var MINUTE = 4;
  19439. var SECOND = 5;
  19440. var MILLISECOND = 6;
  19441. var WEEK = 7;
  19442. var WEEKDAY = 8;
  19443. // FORMATTING
  19444. addFormatToken('Y', 0, 0, function () {
  19445. var y = this.year();
  19446. return y <= 9999 ? '' + y : '+' + y;
  19447. });
  19448. addFormatToken(0, ['YY', 2], 0, function () {
  19449. return this.year() % 100;
  19450. });
  19451. addFormatToken(0, ['YYYY', 4], 0, 'year');
  19452. addFormatToken(0, ['YYYYY', 5], 0, 'year');
  19453. addFormatToken(0, ['YYYYYY', 6, true], 0, 'year');
  19454. // ALIASES
  19455. addUnitAlias('year', 'y');
  19456. // PRIORITIES
  19457. addUnitPriority('year', 1);
  19458. // PARSING
  19459. addRegexToken('Y', matchSigned);
  19460. addRegexToken('YY', match1to2, match2);
  19461. addRegexToken('YYYY', match1to4, match4);
  19462. addRegexToken('YYYYY', match1to6, match6);
  19463. addRegexToken('YYYYYY', match1to6, match6);
  19464. addParseToken(['YYYYY', 'YYYYYY'], YEAR);
  19465. addParseToken('YYYY', function (input, array) {
  19466. array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
  19467. });
  19468. addParseToken('YY', function (input, array) {
  19469. array[YEAR] = hooks.parseTwoDigitYear(input);
  19470. });
  19471. addParseToken('Y', function (input, array) {
  19472. array[YEAR] = parseInt(input, 10);
  19473. });
  19474. // HELPERS
  19475. function daysInYear(year) {
  19476. return isLeapYear(year) ? 366 : 365;
  19477. }
  19478. function isLeapYear(year) {
  19479. return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
  19480. }
  19481. // HOOKS
  19482. hooks.parseTwoDigitYear = function (input) {
  19483. return toInt(input) + (toInt(input) > 68 ? 1900 : 2000);
  19484. };
  19485. // MOMENTS
  19486. var getSetYear = makeGetSet('FullYear', true);
  19487. function getIsLeapYear () {
  19488. return isLeapYear(this.year());
  19489. }
  19490. function makeGetSet (unit, keepTime) {
  19491. return function (value) {
  19492. if (value != null) {
  19493. set$1(this, unit, value);
  19494. hooks.updateOffset(this, keepTime);
  19495. return this;
  19496. } else {
  19497. return get(this, unit);
  19498. }
  19499. };
  19500. }
  19501. function get (mom, unit) {
  19502. return mom.isValid() ?
  19503. mom._d['get' + (mom._isUTC ? 'UTC' : '') + unit]() : NaN;
  19504. }
  19505. function set$1 (mom, unit, value) {
  19506. if (mom.isValid() && !isNaN(value)) {
  19507. if (unit === 'FullYear' && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
  19508. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value, mom.month(), daysInMonth(value, mom.month()));
  19509. }
  19510. else {
  19511. mom._d['set' + (mom._isUTC ? 'UTC' : '') + unit](value);
  19512. }
  19513. }
  19514. }
  19515. // MOMENTS
  19516. function stringGet (units) {
  19517. units = normalizeUnits(units);
  19518. if (isFunction(this[units])) {
  19519. return this[units]();
  19520. }
  19521. return this;
  19522. }
  19523. function stringSet (units, value) {
  19524. if (typeof units === 'object') {
  19525. units = normalizeObjectUnits(units);
  19526. var prioritized = getPrioritizedUnits(units);
  19527. for (var i = 0; i < prioritized.length; i++) {
  19528. this[prioritized[i].unit](units[prioritized[i].unit]);
  19529. }
  19530. } else {
  19531. units = normalizeUnits(units);
  19532. if (isFunction(this[units])) {
  19533. return this[units](value);
  19534. }
  19535. }
  19536. return this;
  19537. }
  19538. function mod(n, x) {
  19539. return ((n % x) + x) % x;
  19540. }
  19541. var indexOf;
  19542. if (Array.prototype.indexOf) {
  19543. indexOf = Array.prototype.indexOf;
  19544. } else {
  19545. indexOf = function (o) {
  19546. // I know
  19547. var i;
  19548. for (i = 0; i < this.length; ++i) {
  19549. if (this[i] === o) {
  19550. return i;
  19551. }
  19552. }
  19553. return -1;
  19554. };
  19555. }
  19556. function daysInMonth(year, month) {
  19557. if (isNaN(year) || isNaN(month)) {
  19558. return NaN;
  19559. }
  19560. var modMonth = mod(month, 12);
  19561. year += (month - modMonth) / 12;
  19562. return modMonth === 1 ? (isLeapYear(year) ? 29 : 28) : (31 - modMonth % 7 % 2);
  19563. }
  19564. // FORMATTING
  19565. addFormatToken('M', ['MM', 2], 'Mo', function () {
  19566. return this.month() + 1;
  19567. });
  19568. addFormatToken('MMM', 0, 0, function (format) {
  19569. return this.localeData().monthsShort(this, format);
  19570. });
  19571. addFormatToken('MMMM', 0, 0, function (format) {
  19572. return this.localeData().months(this, format);
  19573. });
  19574. // ALIASES
  19575. addUnitAlias('month', 'M');
  19576. // PRIORITY
  19577. addUnitPriority('month', 8);
  19578. // PARSING
  19579. addRegexToken('M', match1to2);
  19580. addRegexToken('MM', match1to2, match2);
  19581. addRegexToken('MMM', function (isStrict, locale) {
  19582. return locale.monthsShortRegex(isStrict);
  19583. });
  19584. addRegexToken('MMMM', function (isStrict, locale) {
  19585. return locale.monthsRegex(isStrict);
  19586. });
  19587. addParseToken(['M', 'MM'], function (input, array) {
  19588. array[MONTH] = toInt(input) - 1;
  19589. });
  19590. addParseToken(['MMM', 'MMMM'], function (input, array, config, token) {
  19591. var month = config._locale.monthsParse(input, token, config._strict);
  19592. // if we didn't find a month name, mark the date as invalid.
  19593. if (month != null) {
  19594. array[MONTH] = month;
  19595. } else {
  19596. getParsingFlags(config).invalidMonth = input;
  19597. }
  19598. });
  19599. // LOCALES
  19600. var MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/;
  19601. var defaultLocaleMonths = 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_');
  19602. function localeMonths (m, format) {
  19603. if (!m) {
  19604. return isArray(this._months) ? this._months :
  19605. this._months['standalone'];
  19606. }
  19607. return isArray(this._months) ? this._months[m.month()] :
  19608. this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format) ? 'format' : 'standalone'][m.month()];
  19609. }
  19610. var defaultLocaleMonthsShort = 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_');
  19611. function localeMonthsShort (m, format) {
  19612. if (!m) {
  19613. return isArray(this._monthsShort) ? this._monthsShort :
  19614. this._monthsShort['standalone'];
  19615. }
  19616. return isArray(this._monthsShort) ? this._monthsShort[m.month()] :
  19617. this._monthsShort[MONTHS_IN_FORMAT.test(format) ? 'format' : 'standalone'][m.month()];
  19618. }
  19619. function handleStrictParse(monthName, format, strict) {
  19620. var i, ii, mom, llc = monthName.toLocaleLowerCase();
  19621. if (!this._monthsParse) {
  19622. // this is not used
  19623. this._monthsParse = [];
  19624. this._longMonthsParse = [];
  19625. this._shortMonthsParse = [];
  19626. for (i = 0; i < 12; ++i) {
  19627. mom = createUTC([2000, i]);
  19628. this._shortMonthsParse[i] = this.monthsShort(mom, '').toLocaleLowerCase();
  19629. this._longMonthsParse[i] = this.months(mom, '').toLocaleLowerCase();
  19630. }
  19631. }
  19632. if (strict) {
  19633. if (format === 'MMM') {
  19634. ii = indexOf.call(this._shortMonthsParse, llc);
  19635. return ii !== -1 ? ii : null;
  19636. } else {
  19637. ii = indexOf.call(this._longMonthsParse, llc);
  19638. return ii !== -1 ? ii : null;
  19639. }
  19640. } else {
  19641. if (format === 'MMM') {
  19642. ii = indexOf.call(this._shortMonthsParse, llc);
  19643. if (ii !== -1) {
  19644. return ii;
  19645. }
  19646. ii = indexOf.call(this._longMonthsParse, llc);
  19647. return ii !== -1 ? ii : null;
  19648. } else {
  19649. ii = indexOf.call(this._longMonthsParse, llc);
  19650. if (ii !== -1) {
  19651. return ii;
  19652. }
  19653. ii = indexOf.call(this._shortMonthsParse, llc);
  19654. return ii !== -1 ? ii : null;
  19655. }
  19656. }
  19657. }
  19658. function localeMonthsParse (monthName, format, strict) {
  19659. var i, mom, regex;
  19660. if (this._monthsParseExact) {
  19661. return handleStrictParse.call(this, monthName, format, strict);
  19662. }
  19663. if (!this._monthsParse) {
  19664. this._monthsParse = [];
  19665. this._longMonthsParse = [];
  19666. this._shortMonthsParse = [];
  19667. }
  19668. // TODO: add sorting
  19669. // Sorting makes sure if one month (or abbr) is a prefix of another
  19670. // see sorting in computeMonthsParse
  19671. for (i = 0; i < 12; i++) {
  19672. // make the regex if we don't have it already
  19673. mom = createUTC([2000, i]);
  19674. if (strict && !this._longMonthsParse[i]) {
  19675. this._longMonthsParse[i] = new RegExp('^' + this.months(mom, '').replace('.', '') + '$', 'i');
  19676. this._shortMonthsParse[i] = new RegExp('^' + this.monthsShort(mom, '').replace('.', '') + '$', 'i');
  19677. }
  19678. if (!strict && !this._monthsParse[i]) {
  19679. regex = '^' + this.months(mom, '') + '|^' + this.monthsShort(mom, '');
  19680. this._monthsParse[i] = new RegExp(regex.replace('.', ''), 'i');
  19681. }
  19682. // test the regex
  19683. if (strict && format === 'MMMM' && this._longMonthsParse[i].test(monthName)) {
  19684. return i;
  19685. } else if (strict && format === 'MMM' && this._shortMonthsParse[i].test(monthName)) {
  19686. return i;
  19687. } else if (!strict && this._monthsParse[i].test(monthName)) {
  19688. return i;
  19689. }
  19690. }
  19691. }
  19692. // MOMENTS
  19693. function setMonth (mom, value) {
  19694. var dayOfMonth;
  19695. if (!mom.isValid()) {
  19696. // No op
  19697. return mom;
  19698. }
  19699. if (typeof value === 'string') {
  19700. if (/^\d+$/.test(value)) {
  19701. value = toInt(value);
  19702. } else {
  19703. value = mom.localeData().monthsParse(value);
  19704. // TODO: Another silent failure?
  19705. if (!isNumber(value)) {
  19706. return mom;
  19707. }
  19708. }
  19709. }
  19710. dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
  19711. mom._d['set' + (mom._isUTC ? 'UTC' : '') + 'Month'](value, dayOfMonth);
  19712. return mom;
  19713. }
  19714. function getSetMonth (value) {
  19715. if (value != null) {
  19716. setMonth(this, value);
  19717. hooks.updateOffset(this, true);
  19718. return this;
  19719. } else {
  19720. return get(this, 'Month');
  19721. }
  19722. }
  19723. function getDaysInMonth () {
  19724. return daysInMonth(this.year(), this.month());
  19725. }
  19726. var defaultMonthsShortRegex = matchWord;
  19727. function monthsShortRegex (isStrict) {
  19728. if (this._monthsParseExact) {
  19729. if (!hasOwnProp(this, '_monthsRegex')) {
  19730. computeMonthsParse.call(this);
  19731. }
  19732. if (isStrict) {
  19733. return this._monthsShortStrictRegex;
  19734. } else {
  19735. return this._monthsShortRegex;
  19736. }
  19737. } else {
  19738. if (!hasOwnProp(this, '_monthsShortRegex')) {
  19739. this._monthsShortRegex = defaultMonthsShortRegex;
  19740. }
  19741. return this._monthsShortStrictRegex && isStrict ?
  19742. this._monthsShortStrictRegex : this._monthsShortRegex;
  19743. }
  19744. }
  19745. var defaultMonthsRegex = matchWord;
  19746. function monthsRegex (isStrict) {
  19747. if (this._monthsParseExact) {
  19748. if (!hasOwnProp(this, '_monthsRegex')) {
  19749. computeMonthsParse.call(this);
  19750. }
  19751. if (isStrict) {
  19752. return this._monthsStrictRegex;
  19753. } else {
  19754. return this._monthsRegex;
  19755. }
  19756. } else {
  19757. if (!hasOwnProp(this, '_monthsRegex')) {
  19758. this._monthsRegex = defaultMonthsRegex;
  19759. }
  19760. return this._monthsStrictRegex && isStrict ?
  19761. this._monthsStrictRegex : this._monthsRegex;
  19762. }
  19763. }
  19764. function computeMonthsParse () {
  19765. function cmpLenRev(a, b) {
  19766. return b.length - a.length;
  19767. }
  19768. var shortPieces = [], longPieces = [], mixedPieces = [],
  19769. i, mom;
  19770. for (i = 0; i < 12; i++) {
  19771. // make the regex if we don't have it already
  19772. mom = createUTC([2000, i]);
  19773. shortPieces.push(this.monthsShort(mom, ''));
  19774. longPieces.push(this.months(mom, ''));
  19775. mixedPieces.push(this.months(mom, ''));
  19776. mixedPieces.push(this.monthsShort(mom, ''));
  19777. }
  19778. // Sorting makes sure if one month (or abbr) is a prefix of another it
  19779. // will match the longer piece.
  19780. shortPieces.sort(cmpLenRev);
  19781. longPieces.sort(cmpLenRev);
  19782. mixedPieces.sort(cmpLenRev);
  19783. for (i = 0; i < 12; i++) {
  19784. shortPieces[i] = regexEscape(shortPieces[i]);
  19785. longPieces[i] = regexEscape(longPieces[i]);
  19786. }
  19787. for (i = 0; i < 24; i++) {
  19788. mixedPieces[i] = regexEscape(mixedPieces[i]);
  19789. }
  19790. this._monthsRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  19791. this._monthsShortRegex = this._monthsRegex;
  19792. this._monthsStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  19793. this._monthsShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  19794. }
  19795. function createDate (y, m, d, h, M, s, ms) {
  19796. // can't just apply() to create a date:
  19797. // https://stackoverflow.com/q/181348
  19798. var date = new Date(y, m, d, h, M, s, ms);
  19799. // the date constructor remaps years 0-99 to 1900-1999
  19800. if (y < 100 && y >= 0 && isFinite(date.getFullYear())) {
  19801. date.setFullYear(y);
  19802. }
  19803. return date;
  19804. }
  19805. function createUTCDate (y) {
  19806. var date = new Date(Date.UTC.apply(null, arguments));
  19807. // the Date.UTC function remaps years 0-99 to 1900-1999
  19808. if (y < 100 && y >= 0 && isFinite(date.getUTCFullYear())) {
  19809. date.setUTCFullYear(y);
  19810. }
  19811. return date;
  19812. }
  19813. // start-of-first-week - start-of-year
  19814. function firstWeekOffset(year, dow, doy) {
  19815. var // first-week day -- which january is always in the first week (4 for iso, 1 for other)
  19816. fwd = 7 + dow - doy,
  19817. // first-week day local weekday -- which local weekday is fwd
  19818. fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
  19819. return -fwdlw + fwd - 1;
  19820. }
  19821. // https://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
  19822. function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
  19823. var localWeekday = (7 + weekday - dow) % 7,
  19824. weekOffset = firstWeekOffset(year, dow, doy),
  19825. dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset,
  19826. resYear, resDayOfYear;
  19827. if (dayOfYear <= 0) {
  19828. resYear = year - 1;
  19829. resDayOfYear = daysInYear(resYear) + dayOfYear;
  19830. } else if (dayOfYear > daysInYear(year)) {
  19831. resYear = year + 1;
  19832. resDayOfYear = dayOfYear - daysInYear(year);
  19833. } else {
  19834. resYear = year;
  19835. resDayOfYear = dayOfYear;
  19836. }
  19837. return {
  19838. year: resYear,
  19839. dayOfYear: resDayOfYear
  19840. };
  19841. }
  19842. function weekOfYear(mom, dow, doy) {
  19843. var weekOffset = firstWeekOffset(mom.year(), dow, doy),
  19844. week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1,
  19845. resWeek, resYear;
  19846. if (week < 1) {
  19847. resYear = mom.year() - 1;
  19848. resWeek = week + weeksInYear(resYear, dow, doy);
  19849. } else if (week > weeksInYear(mom.year(), dow, doy)) {
  19850. resWeek = week - weeksInYear(mom.year(), dow, doy);
  19851. resYear = mom.year() + 1;
  19852. } else {
  19853. resYear = mom.year();
  19854. resWeek = week;
  19855. }
  19856. return {
  19857. week: resWeek,
  19858. year: resYear
  19859. };
  19860. }
  19861. function weeksInYear(year, dow, doy) {
  19862. var weekOffset = firstWeekOffset(year, dow, doy),
  19863. weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
  19864. return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
  19865. }
  19866. // FORMATTING
  19867. addFormatToken('w', ['ww', 2], 'wo', 'week');
  19868. addFormatToken('W', ['WW', 2], 'Wo', 'isoWeek');
  19869. // ALIASES
  19870. addUnitAlias('week', 'w');
  19871. addUnitAlias('isoWeek', 'W');
  19872. // PRIORITIES
  19873. addUnitPriority('week', 5);
  19874. addUnitPriority('isoWeek', 5);
  19875. // PARSING
  19876. addRegexToken('w', match1to2);
  19877. addRegexToken('ww', match1to2, match2);
  19878. addRegexToken('W', match1to2);
  19879. addRegexToken('WW', match1to2, match2);
  19880. addWeekParseToken(['w', 'ww', 'W', 'WW'], function (input, week, config, token) {
  19881. week[token.substr(0, 1)] = toInt(input);
  19882. });
  19883. // HELPERS
  19884. // LOCALES
  19885. function localeWeek (mom) {
  19886. return weekOfYear(mom, this._week.dow, this._week.doy).week;
  19887. }
  19888. var defaultLocaleWeek = {
  19889. dow : 0, // Sunday is the first day of the week.
  19890. doy : 6 // The week that contains Jan 1st is the first week of the year.
  19891. };
  19892. function localeFirstDayOfWeek () {
  19893. return this._week.dow;
  19894. }
  19895. function localeFirstDayOfYear () {
  19896. return this._week.doy;
  19897. }
  19898. // MOMENTS
  19899. function getSetWeek (input) {
  19900. var week = this.localeData().week(this);
  19901. return input == null ? week : this.add((input - week) * 7, 'd');
  19902. }
  19903. function getSetISOWeek (input) {
  19904. var week = weekOfYear(this, 1, 4).week;
  19905. return input == null ? week : this.add((input - week) * 7, 'd');
  19906. }
  19907. // FORMATTING
  19908. addFormatToken('d', 0, 'do', 'day');
  19909. addFormatToken('dd', 0, 0, function (format) {
  19910. return this.localeData().weekdaysMin(this, format);
  19911. });
  19912. addFormatToken('ddd', 0, 0, function (format) {
  19913. return this.localeData().weekdaysShort(this, format);
  19914. });
  19915. addFormatToken('dddd', 0, 0, function (format) {
  19916. return this.localeData().weekdays(this, format);
  19917. });
  19918. addFormatToken('e', 0, 0, 'weekday');
  19919. addFormatToken('E', 0, 0, 'isoWeekday');
  19920. // ALIASES
  19921. addUnitAlias('day', 'd');
  19922. addUnitAlias('weekday', 'e');
  19923. addUnitAlias('isoWeekday', 'E');
  19924. // PRIORITY
  19925. addUnitPriority('day', 11);
  19926. addUnitPriority('weekday', 11);
  19927. addUnitPriority('isoWeekday', 11);
  19928. // PARSING
  19929. addRegexToken('d', match1to2);
  19930. addRegexToken('e', match1to2);
  19931. addRegexToken('E', match1to2);
  19932. addRegexToken('dd', function (isStrict, locale) {
  19933. return locale.weekdaysMinRegex(isStrict);
  19934. });
  19935. addRegexToken('ddd', function (isStrict, locale) {
  19936. return locale.weekdaysShortRegex(isStrict);
  19937. });
  19938. addRegexToken('dddd', function (isStrict, locale) {
  19939. return locale.weekdaysRegex(isStrict);
  19940. });
  19941. addWeekParseToken(['dd', 'ddd', 'dddd'], function (input, week, config, token) {
  19942. var weekday = config._locale.weekdaysParse(input, token, config._strict);
  19943. // if we didn't get a weekday name, mark the date as invalid
  19944. if (weekday != null) {
  19945. week.d = weekday;
  19946. } else {
  19947. getParsingFlags(config).invalidWeekday = input;
  19948. }
  19949. });
  19950. addWeekParseToken(['d', 'e', 'E'], function (input, week, config, token) {
  19951. week[token] = toInt(input);
  19952. });
  19953. // HELPERS
  19954. function parseWeekday(input, locale) {
  19955. if (typeof input !== 'string') {
  19956. return input;
  19957. }
  19958. if (!isNaN(input)) {
  19959. return parseInt(input, 10);
  19960. }
  19961. input = locale.weekdaysParse(input);
  19962. if (typeof input === 'number') {
  19963. return input;
  19964. }
  19965. return null;
  19966. }
  19967. function parseIsoWeekday(input, locale) {
  19968. if (typeof input === 'string') {
  19969. return locale.weekdaysParse(input) % 7 || 7;
  19970. }
  19971. return isNaN(input) ? null : input;
  19972. }
  19973. // LOCALES
  19974. var defaultLocaleWeekdays = 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_');
  19975. function localeWeekdays (m, format) {
  19976. if (!m) {
  19977. return isArray(this._weekdays) ? this._weekdays :
  19978. this._weekdays['standalone'];
  19979. }
  19980. return isArray(this._weekdays) ? this._weekdays[m.day()] :
  19981. this._weekdays[this._weekdays.isFormat.test(format) ? 'format' : 'standalone'][m.day()];
  19982. }
  19983. var defaultLocaleWeekdaysShort = 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_');
  19984. function localeWeekdaysShort (m) {
  19985. return (m) ? this._weekdaysShort[m.day()] : this._weekdaysShort;
  19986. }
  19987. var defaultLocaleWeekdaysMin = 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_');
  19988. function localeWeekdaysMin (m) {
  19989. return (m) ? this._weekdaysMin[m.day()] : this._weekdaysMin;
  19990. }
  19991. function handleStrictParse$1(weekdayName, format, strict) {
  19992. var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
  19993. if (!this._weekdaysParse) {
  19994. this._weekdaysParse = [];
  19995. this._shortWeekdaysParse = [];
  19996. this._minWeekdaysParse = [];
  19997. for (i = 0; i < 7; ++i) {
  19998. mom = createUTC([2000, 1]).day(i);
  19999. this._minWeekdaysParse[i] = this.weekdaysMin(mom, '').toLocaleLowerCase();
  20000. this._shortWeekdaysParse[i] = this.weekdaysShort(mom, '').toLocaleLowerCase();
  20001. this._weekdaysParse[i] = this.weekdays(mom, '').toLocaleLowerCase();
  20002. }
  20003. }
  20004. if (strict) {
  20005. if (format === 'dddd') {
  20006. ii = indexOf.call(this._weekdaysParse, llc);
  20007. return ii !== -1 ? ii : null;
  20008. } else if (format === 'ddd') {
  20009. ii = indexOf.call(this._shortWeekdaysParse, llc);
  20010. return ii !== -1 ? ii : null;
  20011. } else {
  20012. ii = indexOf.call(this._minWeekdaysParse, llc);
  20013. return ii !== -1 ? ii : null;
  20014. }
  20015. } else {
  20016. if (format === 'dddd') {
  20017. ii = indexOf.call(this._weekdaysParse, llc);
  20018. if (ii !== -1) {
  20019. return ii;
  20020. }
  20021. ii = indexOf.call(this._shortWeekdaysParse, llc);
  20022. if (ii !== -1) {
  20023. return ii;
  20024. }
  20025. ii = indexOf.call(this._minWeekdaysParse, llc);
  20026. return ii !== -1 ? ii : null;
  20027. } else if (format === 'ddd') {
  20028. ii = indexOf.call(this._shortWeekdaysParse, llc);
  20029. if (ii !== -1) {
  20030. return ii;
  20031. }
  20032. ii = indexOf.call(this._weekdaysParse, llc);
  20033. if (ii !== -1) {
  20034. return ii;
  20035. }
  20036. ii = indexOf.call(this._minWeekdaysParse, llc);
  20037. return ii !== -1 ? ii : null;
  20038. } else {
  20039. ii = indexOf.call(this._minWeekdaysParse, llc);
  20040. if (ii !== -1) {
  20041. return ii;
  20042. }
  20043. ii = indexOf.call(this._weekdaysParse, llc);
  20044. if (ii !== -1) {
  20045. return ii;
  20046. }
  20047. ii = indexOf.call(this._shortWeekdaysParse, llc);
  20048. return ii !== -1 ? ii : null;
  20049. }
  20050. }
  20051. }
  20052. function localeWeekdaysParse (weekdayName, format, strict) {
  20053. var i, mom, regex;
  20054. if (this._weekdaysParseExact) {
  20055. return handleStrictParse$1.call(this, weekdayName, format, strict);
  20056. }
  20057. if (!this._weekdaysParse) {
  20058. this._weekdaysParse = [];
  20059. this._minWeekdaysParse = [];
  20060. this._shortWeekdaysParse = [];
  20061. this._fullWeekdaysParse = [];
  20062. }
  20063. for (i = 0; i < 7; i++) {
  20064. // make the regex if we don't have it already
  20065. mom = createUTC([2000, 1]).day(i);
  20066. if (strict && !this._fullWeekdaysParse[i]) {
  20067. this._fullWeekdaysParse[i] = new RegExp('^' + this.weekdays(mom, '').replace('.', '\.?') + '$', 'i');
  20068. this._shortWeekdaysParse[i] = new RegExp('^' + this.weekdaysShort(mom, '').replace('.', '\.?') + '$', 'i');
  20069. this._minWeekdaysParse[i] = new RegExp('^' + this.weekdaysMin(mom, '').replace('.', '\.?') + '$', 'i');
  20070. }
  20071. if (!this._weekdaysParse[i]) {
  20072. regex = '^' + this.weekdays(mom, '') + '|^' + this.weekdaysShort(mom, '') + '|^' + this.weekdaysMin(mom, '');
  20073. this._weekdaysParse[i] = new RegExp(regex.replace('.', ''), 'i');
  20074. }
  20075. // test the regex
  20076. if (strict && format === 'dddd' && this._fullWeekdaysParse[i].test(weekdayName)) {
  20077. return i;
  20078. } else if (strict && format === 'ddd' && this._shortWeekdaysParse[i].test(weekdayName)) {
  20079. return i;
  20080. } else if (strict && format === 'dd' && this._minWeekdaysParse[i].test(weekdayName)) {
  20081. return i;
  20082. } else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
  20083. return i;
  20084. }
  20085. }
  20086. }
  20087. // MOMENTS
  20088. function getSetDayOfWeek (input) {
  20089. if (!this.isValid()) {
  20090. return input != null ? this : NaN;
  20091. }
  20092. var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
  20093. if (input != null) {
  20094. input = parseWeekday(input, this.localeData());
  20095. return this.add(input - day, 'd');
  20096. } else {
  20097. return day;
  20098. }
  20099. }
  20100. function getSetLocaleDayOfWeek (input) {
  20101. if (!this.isValid()) {
  20102. return input != null ? this : NaN;
  20103. }
  20104. var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
  20105. return input == null ? weekday : this.add(input - weekday, 'd');
  20106. }
  20107. function getSetISODayOfWeek (input) {
  20108. if (!this.isValid()) {
  20109. return input != null ? this : NaN;
  20110. }
  20111. // behaves the same as moment#day except
  20112. // as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
  20113. // as a setter, sunday should belong to the previous week.
  20114. if (input != null) {
  20115. var weekday = parseIsoWeekday(input, this.localeData());
  20116. return this.day(this.day() % 7 ? weekday : weekday - 7);
  20117. } else {
  20118. return this.day() || 7;
  20119. }
  20120. }
  20121. var defaultWeekdaysRegex = matchWord;
  20122. function weekdaysRegex (isStrict) {
  20123. if (this._weekdaysParseExact) {
  20124. if (!hasOwnProp(this, '_weekdaysRegex')) {
  20125. computeWeekdaysParse.call(this);
  20126. }
  20127. if (isStrict) {
  20128. return this._weekdaysStrictRegex;
  20129. } else {
  20130. return this._weekdaysRegex;
  20131. }
  20132. } else {
  20133. if (!hasOwnProp(this, '_weekdaysRegex')) {
  20134. this._weekdaysRegex = defaultWeekdaysRegex;
  20135. }
  20136. return this._weekdaysStrictRegex && isStrict ?
  20137. this._weekdaysStrictRegex : this._weekdaysRegex;
  20138. }
  20139. }
  20140. var defaultWeekdaysShortRegex = matchWord;
  20141. function weekdaysShortRegex (isStrict) {
  20142. if (this._weekdaysParseExact) {
  20143. if (!hasOwnProp(this, '_weekdaysRegex')) {
  20144. computeWeekdaysParse.call(this);
  20145. }
  20146. if (isStrict) {
  20147. return this._weekdaysShortStrictRegex;
  20148. } else {
  20149. return this._weekdaysShortRegex;
  20150. }
  20151. } else {
  20152. if (!hasOwnProp(this, '_weekdaysShortRegex')) {
  20153. this._weekdaysShortRegex = defaultWeekdaysShortRegex;
  20154. }
  20155. return this._weekdaysShortStrictRegex && isStrict ?
  20156. this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
  20157. }
  20158. }
  20159. var defaultWeekdaysMinRegex = matchWord;
  20160. function weekdaysMinRegex (isStrict) {
  20161. if (this._weekdaysParseExact) {
  20162. if (!hasOwnProp(this, '_weekdaysRegex')) {
  20163. computeWeekdaysParse.call(this);
  20164. }
  20165. if (isStrict) {
  20166. return this._weekdaysMinStrictRegex;
  20167. } else {
  20168. return this._weekdaysMinRegex;
  20169. }
  20170. } else {
  20171. if (!hasOwnProp(this, '_weekdaysMinRegex')) {
  20172. this._weekdaysMinRegex = defaultWeekdaysMinRegex;
  20173. }
  20174. return this._weekdaysMinStrictRegex && isStrict ?
  20175. this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
  20176. }
  20177. }
  20178. function computeWeekdaysParse () {
  20179. function cmpLenRev(a, b) {
  20180. return b.length - a.length;
  20181. }
  20182. var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [],
  20183. i, mom, minp, shortp, longp;
  20184. for (i = 0; i < 7; i++) {
  20185. // make the regex if we don't have it already
  20186. mom = createUTC([2000, 1]).day(i);
  20187. minp = this.weekdaysMin(mom, '');
  20188. shortp = this.weekdaysShort(mom, '');
  20189. longp = this.weekdays(mom, '');
  20190. minPieces.push(minp);
  20191. shortPieces.push(shortp);
  20192. longPieces.push(longp);
  20193. mixedPieces.push(minp);
  20194. mixedPieces.push(shortp);
  20195. mixedPieces.push(longp);
  20196. }
  20197. // Sorting makes sure if one weekday (or abbr) is a prefix of another it
  20198. // will match the longer piece.
  20199. minPieces.sort(cmpLenRev);
  20200. shortPieces.sort(cmpLenRev);
  20201. longPieces.sort(cmpLenRev);
  20202. mixedPieces.sort(cmpLenRev);
  20203. for (i = 0; i < 7; i++) {
  20204. shortPieces[i] = regexEscape(shortPieces[i]);
  20205. longPieces[i] = regexEscape(longPieces[i]);
  20206. mixedPieces[i] = regexEscape(mixedPieces[i]);
  20207. }
  20208. this._weekdaysRegex = new RegExp('^(' + mixedPieces.join('|') + ')', 'i');
  20209. this._weekdaysShortRegex = this._weekdaysRegex;
  20210. this._weekdaysMinRegex = this._weekdaysRegex;
  20211. this._weekdaysStrictRegex = new RegExp('^(' + longPieces.join('|') + ')', 'i');
  20212. this._weekdaysShortStrictRegex = new RegExp('^(' + shortPieces.join('|') + ')', 'i');
  20213. this._weekdaysMinStrictRegex = new RegExp('^(' + minPieces.join('|') + ')', 'i');
  20214. }
  20215. // FORMATTING
  20216. function hFormat() {
  20217. return this.hours() % 12 || 12;
  20218. }
  20219. function kFormat() {
  20220. return this.hours() || 24;
  20221. }
  20222. addFormatToken('H', ['HH', 2], 0, 'hour');
  20223. addFormatToken('h', ['hh', 2], 0, hFormat);
  20224. addFormatToken('k', ['kk', 2], 0, kFormat);
  20225. addFormatToken('hmm', 0, 0, function () {
  20226. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2);
  20227. });
  20228. addFormatToken('hmmss', 0, 0, function () {
  20229. return '' + hFormat.apply(this) + zeroFill(this.minutes(), 2) +
  20230. zeroFill(this.seconds(), 2);
  20231. });
  20232. addFormatToken('Hmm', 0, 0, function () {
  20233. return '' + this.hours() + zeroFill(this.minutes(), 2);
  20234. });
  20235. addFormatToken('Hmmss', 0, 0, function () {
  20236. return '' + this.hours() + zeroFill(this.minutes(), 2) +
  20237. zeroFill(this.seconds(), 2);
  20238. });
  20239. function meridiem (token, lowercase) {
  20240. addFormatToken(token, 0, 0, function () {
  20241. return this.localeData().meridiem(this.hours(), this.minutes(), lowercase);
  20242. });
  20243. }
  20244. meridiem('a', true);
  20245. meridiem('A', false);
  20246. // ALIASES
  20247. addUnitAlias('hour', 'h');
  20248. // PRIORITY
  20249. addUnitPriority('hour', 13);
  20250. // PARSING
  20251. function matchMeridiem (isStrict, locale) {
  20252. return locale._meridiemParse;
  20253. }
  20254. addRegexToken('a', matchMeridiem);
  20255. addRegexToken('A', matchMeridiem);
  20256. addRegexToken('H', match1to2);
  20257. addRegexToken('h', match1to2);
  20258. addRegexToken('k', match1to2);
  20259. addRegexToken('HH', match1to2, match2);
  20260. addRegexToken('hh', match1to2, match2);
  20261. addRegexToken('kk', match1to2, match2);
  20262. addRegexToken('hmm', match3to4);
  20263. addRegexToken('hmmss', match5to6);
  20264. addRegexToken('Hmm', match3to4);
  20265. addRegexToken('Hmmss', match5to6);
  20266. addParseToken(['H', 'HH'], HOUR);
  20267. addParseToken(['k', 'kk'], function (input, array, config) {
  20268. var kInput = toInt(input);
  20269. array[HOUR] = kInput === 24 ? 0 : kInput;
  20270. });
  20271. addParseToken(['a', 'A'], function (input, array, config) {
  20272. config._isPm = config._locale.isPM(input);
  20273. config._meridiem = input;
  20274. });
  20275. addParseToken(['h', 'hh'], function (input, array, config) {
  20276. array[HOUR] = toInt(input);
  20277. getParsingFlags(config).bigHour = true;
  20278. });
  20279. addParseToken('hmm', function (input, array, config) {
  20280. var pos = input.length - 2;
  20281. array[HOUR] = toInt(input.substr(0, pos));
  20282. array[MINUTE] = toInt(input.substr(pos));
  20283. getParsingFlags(config).bigHour = true;
  20284. });
  20285. addParseToken('hmmss', function (input, array, config) {
  20286. var pos1 = input.length - 4;
  20287. var pos2 = input.length - 2;
  20288. array[HOUR] = toInt(input.substr(0, pos1));
  20289. array[MINUTE] = toInt(input.substr(pos1, 2));
  20290. array[SECOND] = toInt(input.substr(pos2));
  20291. getParsingFlags(config).bigHour = true;
  20292. });
  20293. addParseToken('Hmm', function (input, array, config) {
  20294. var pos = input.length - 2;
  20295. array[HOUR] = toInt(input.substr(0, pos));
  20296. array[MINUTE] = toInt(input.substr(pos));
  20297. });
  20298. addParseToken('Hmmss', function (input, array, config) {
  20299. var pos1 = input.length - 4;
  20300. var pos2 = input.length - 2;
  20301. array[HOUR] = toInt(input.substr(0, pos1));
  20302. array[MINUTE] = toInt(input.substr(pos1, 2));
  20303. array[SECOND] = toInt(input.substr(pos2));
  20304. });
  20305. // LOCALES
  20306. function localeIsPM (input) {
  20307. // IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
  20308. // Using charAt should be more compatible.
  20309. return ((input + '').toLowerCase().charAt(0) === 'p');
  20310. }
  20311. var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i;
  20312. function localeMeridiem (hours, minutes, isLower) {
  20313. if (hours > 11) {
  20314. return isLower ? 'pm' : 'PM';
  20315. } else {
  20316. return isLower ? 'am' : 'AM';
  20317. }
  20318. }
  20319. // MOMENTS
  20320. // Setting the hour should keep the time, because the user explicitly
  20321. // specified which hour he wants. So trying to maintain the same hour (in
  20322. // a new timezone) makes sense. Adding/subtracting hours does not follow
  20323. // this rule.
  20324. var getSetHour = makeGetSet('Hours', true);
  20325. // months
  20326. // week
  20327. // weekdays
  20328. // meridiem
  20329. var baseConfig = {
  20330. calendar: defaultCalendar,
  20331. longDateFormat: defaultLongDateFormat,
  20332. invalidDate: defaultInvalidDate,
  20333. ordinal: defaultOrdinal,
  20334. dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
  20335. relativeTime: defaultRelativeTime,
  20336. months: defaultLocaleMonths,
  20337. monthsShort: defaultLocaleMonthsShort,
  20338. week: defaultLocaleWeek,
  20339. weekdays: defaultLocaleWeekdays,
  20340. weekdaysMin: defaultLocaleWeekdaysMin,
  20341. weekdaysShort: defaultLocaleWeekdaysShort,
  20342. meridiemParse: defaultLocaleMeridiemParse
  20343. };
  20344. // internal storage for locale config files
  20345. var locales = {};
  20346. var localeFamilies = {};
  20347. var globalLocale;
  20348. function normalizeLocale(key) {
  20349. return key ? key.toLowerCase().replace('_', '-') : key;
  20350. }
  20351. // pick the locale from the array
  20352. // try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
  20353. // substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
  20354. function chooseLocale(names) {
  20355. var i = 0, j, next, locale, split;
  20356. while (i < names.length) {
  20357. split = normalizeLocale(names[i]).split('-');
  20358. j = split.length;
  20359. next = normalizeLocale(names[i + 1]);
  20360. next = next ? next.split('-') : null;
  20361. while (j > 0) {
  20362. locale = loadLocale(split.slice(0, j).join('-'));
  20363. if (locale) {
  20364. return locale;
  20365. }
  20366. if (next && next.length >= j && compareArrays(split, next, true) >= j - 1) {
  20367. //the next array item is better than a shallower substring of this one
  20368. break;
  20369. }
  20370. j--;
  20371. }
  20372. i++;
  20373. }
  20374. return null;
  20375. }
  20376. function loadLocale(name) {
  20377. var oldLocale = null;
  20378. // TODO: Find a better way to register and load all the locales in Node
  20379. if (!locales[name] && (typeof module !== 'undefined') &&
  20380. module && module.exports) {
  20381. try {
  20382. oldLocale = globalLocale._abbr;
  20383. var aliasedRequire = require;
  20384. aliasedRequire('./locale/' + name);
  20385. getSetGlobalLocale(oldLocale);
  20386. } catch (e) {}
  20387. }
  20388. return locales[name];
  20389. }
  20390. // This function will load locale and then set the global locale. If
  20391. // no arguments are passed in, it will simply return the current global
  20392. // locale key.
  20393. function getSetGlobalLocale (key, values) {
  20394. var data;
  20395. if (key) {
  20396. if (isUndefined(values)) {
  20397. data = getLocale(key);
  20398. }
  20399. else {
  20400. data = defineLocale(key, values);
  20401. }
  20402. if (data) {
  20403. // moment.duration._locale = moment._locale = data;
  20404. globalLocale = data;
  20405. }
  20406. }
  20407. return globalLocale._abbr;
  20408. }
  20409. function defineLocale (name, config) {
  20410. if (config !== null) {
  20411. var parentConfig = baseConfig;
  20412. config.abbr = name;
  20413. if (locales[name] != null) {
  20414. deprecateSimple('defineLocaleOverride',
  20415. 'use moment.updateLocale(localeName, config) to change ' +
  20416. 'an existing locale. moment.defineLocale(localeName, ' +
  20417. 'config) should only be used for creating a new locale ' +
  20418. 'See http://momentjs.com/guides/#/warnings/define-locale/ for more info.');
  20419. parentConfig = locales[name]._config;
  20420. } else if (config.parentLocale != null) {
  20421. if (locales[config.parentLocale] != null) {
  20422. parentConfig = locales[config.parentLocale]._config;
  20423. } else {
  20424. if (!localeFamilies[config.parentLocale]) {
  20425. localeFamilies[config.parentLocale] = [];
  20426. }
  20427. localeFamilies[config.parentLocale].push({
  20428. name: name,
  20429. config: config
  20430. });
  20431. return null;
  20432. }
  20433. }
  20434. locales[name] = new Locale(mergeConfigs(parentConfig, config));
  20435. if (localeFamilies[name]) {
  20436. localeFamilies[name].forEach(function (x) {
  20437. defineLocale(x.name, x.config);
  20438. });
  20439. }
  20440. // backwards compat for now: also set the locale
  20441. // make sure we set the locale AFTER all child locales have been
  20442. // created, so we won't end up with the child locale set.
  20443. getSetGlobalLocale(name);
  20444. return locales[name];
  20445. } else {
  20446. // useful for testing
  20447. delete locales[name];
  20448. return null;
  20449. }
  20450. }
  20451. function updateLocale(name, config) {
  20452. if (config != null) {
  20453. var locale, tmpLocale, parentConfig = baseConfig;
  20454. // MERGE
  20455. tmpLocale = loadLocale(name);
  20456. if (tmpLocale != null) {
  20457. parentConfig = tmpLocale._config;
  20458. }
  20459. config = mergeConfigs(parentConfig, config);
  20460. locale = new Locale(config);
  20461. locale.parentLocale = locales[name];
  20462. locales[name] = locale;
  20463. // backwards compat for now: also set the locale
  20464. getSetGlobalLocale(name);
  20465. } else {
  20466. // pass null for config to unupdate, useful for tests
  20467. if (locales[name] != null) {
  20468. if (locales[name].parentLocale != null) {
  20469. locales[name] = locales[name].parentLocale;
  20470. } else if (locales[name] != null) {
  20471. delete locales[name];
  20472. }
  20473. }
  20474. }
  20475. return locales[name];
  20476. }
  20477. // returns locale data
  20478. function getLocale (key) {
  20479. var locale;
  20480. if (key && key._locale && key._locale._abbr) {
  20481. key = key._locale._abbr;
  20482. }
  20483. if (!key) {
  20484. return globalLocale;
  20485. }
  20486. if (!isArray(key)) {
  20487. //short-circuit everything else
  20488. locale = loadLocale(key);
  20489. if (locale) {
  20490. return locale;
  20491. }
  20492. key = [key];
  20493. }
  20494. return chooseLocale(key);
  20495. }
  20496. function listLocales() {
  20497. return keys(locales);
  20498. }
  20499. function checkOverflow (m) {
  20500. var overflow;
  20501. var a = m._a;
  20502. if (a && getParsingFlags(m).overflow === -2) {
  20503. overflow =
  20504. a[MONTH] < 0 || a[MONTH] > 11 ? MONTH :
  20505. a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE :
  20506. a[HOUR] < 0 || a[HOUR] > 24 || (a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0)) ? HOUR :
  20507. a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE :
  20508. a[SECOND] < 0 || a[SECOND] > 59 ? SECOND :
  20509. a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND :
  20510. -1;
  20511. if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
  20512. overflow = DATE;
  20513. }
  20514. if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
  20515. overflow = WEEK;
  20516. }
  20517. if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
  20518. overflow = WEEKDAY;
  20519. }
  20520. getParsingFlags(m).overflow = overflow;
  20521. }
  20522. return m;
  20523. }
  20524. // Pick the first defined of two or three arguments.
  20525. function defaults(a, b, c) {
  20526. if (a != null) {
  20527. return a;
  20528. }
  20529. if (b != null) {
  20530. return b;
  20531. }
  20532. return c;
  20533. }
  20534. function currentDateArray(config) {
  20535. // hooks is actually the exported moment object
  20536. var nowValue = new Date(hooks.now());
  20537. if (config._useUTC) {
  20538. return [nowValue.getUTCFullYear(), nowValue.getUTCMonth(), nowValue.getUTCDate()];
  20539. }
  20540. return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
  20541. }
  20542. // convert an array to a date.
  20543. // the array should mirror the parameters below
  20544. // note: all values past the year are optional and will default to the lowest possible value.
  20545. // [year, month, day , hour, minute, second, millisecond]
  20546. function configFromArray (config) {
  20547. var i, date, input = [], currentDate, expectedWeekday, yearToUse;
  20548. if (config._d) {
  20549. return;
  20550. }
  20551. currentDate = currentDateArray(config);
  20552. //compute day of the year from weeks and weekdays
  20553. if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
  20554. dayOfYearFromWeekInfo(config);
  20555. }
  20556. //if the day of the year is set, figure out what it is
  20557. if (config._dayOfYear != null) {
  20558. yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
  20559. if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
  20560. getParsingFlags(config)._overflowDayOfYear = true;
  20561. }
  20562. date = createUTCDate(yearToUse, 0, config._dayOfYear);
  20563. config._a[MONTH] = date.getUTCMonth();
  20564. config._a[DATE] = date.getUTCDate();
  20565. }
  20566. // Default to current date.
  20567. // * if no year, month, day of month are given, default to today
  20568. // * if day of month is given, default month and year
  20569. // * if month is given, default only year
  20570. // * if year is given, don't default anything
  20571. for (i = 0; i < 3 && config._a[i] == null; ++i) {
  20572. config._a[i] = input[i] = currentDate[i];
  20573. }
  20574. // Zero out whatever was not defaulted, including time
  20575. for (; i < 7; i++) {
  20576. config._a[i] = input[i] = (config._a[i] == null) ? (i === 2 ? 1 : 0) : config._a[i];
  20577. }
  20578. // Check for 24:00:00.000
  20579. if (config._a[HOUR] === 24 &&
  20580. config._a[MINUTE] === 0 &&
  20581. config._a[SECOND] === 0 &&
  20582. config._a[MILLISECOND] === 0) {
  20583. config._nextDay = true;
  20584. config._a[HOUR] = 0;
  20585. }
  20586. config._d = (config._useUTC ? createUTCDate : createDate).apply(null, input);
  20587. expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
  20588. // Apply timezone offset from input. The actual utcOffset can be changed
  20589. // with parseZone.
  20590. if (config._tzm != null) {
  20591. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  20592. }
  20593. if (config._nextDay) {
  20594. config._a[HOUR] = 24;
  20595. }
  20596. // check for mismatching day of week
  20597. if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== expectedWeekday) {
  20598. getParsingFlags(config).weekdayMismatch = true;
  20599. }
  20600. }
  20601. function dayOfYearFromWeekInfo(config) {
  20602. var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow;
  20603. w = config._w;
  20604. if (w.GG != null || w.W != null || w.E != null) {
  20605. dow = 1;
  20606. doy = 4;
  20607. // TODO: We need to take the current isoWeekYear, but that depends on
  20608. // how we interpret now (local, utc, fixed offset). So create
  20609. // a now version of current config (take local/utc/offset flags, and
  20610. // create now).
  20611. weekYear = defaults(w.GG, config._a[YEAR], weekOfYear(createLocal(), 1, 4).year);
  20612. week = defaults(w.W, 1);
  20613. weekday = defaults(w.E, 1);
  20614. if (weekday < 1 || weekday > 7) {
  20615. weekdayOverflow = true;
  20616. }
  20617. } else {
  20618. dow = config._locale._week.dow;
  20619. doy = config._locale._week.doy;
  20620. var curWeek = weekOfYear(createLocal(), dow, doy);
  20621. weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
  20622. // Default to current week.
  20623. week = defaults(w.w, curWeek.week);
  20624. if (w.d != null) {
  20625. // weekday -- low day numbers are considered next week
  20626. weekday = w.d;
  20627. if (weekday < 0 || weekday > 6) {
  20628. weekdayOverflow = true;
  20629. }
  20630. } else if (w.e != null) {
  20631. // local weekday -- counting starts from begining of week
  20632. weekday = w.e + dow;
  20633. if (w.e < 0 || w.e > 6) {
  20634. weekdayOverflow = true;
  20635. }
  20636. } else {
  20637. // default to begining of week
  20638. weekday = dow;
  20639. }
  20640. }
  20641. if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
  20642. getParsingFlags(config)._overflowWeeks = true;
  20643. } else if (weekdayOverflow != null) {
  20644. getParsingFlags(config)._overflowWeekday = true;
  20645. } else {
  20646. temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
  20647. config._a[YEAR] = temp.year;
  20648. config._dayOfYear = temp.dayOfYear;
  20649. }
  20650. }
  20651. // iso 8601 regex
  20652. // 0000-00-00 0000-W00 or 0000-W00-0 + T + 00 or 00:00 or 00:00:00 or 00:00:00.000 + +00:00 or +0000 or +00)
  20653. var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
  20654. var basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/;
  20655. var tzRegex = /Z|[+-]\d\d(?::?\d\d)?/;
  20656. var isoDates = [
  20657. ['YYYYYY-MM-DD', /[+-]\d{6}-\d\d-\d\d/],
  20658. ['YYYY-MM-DD', /\d{4}-\d\d-\d\d/],
  20659. ['GGGG-[W]WW-E', /\d{4}-W\d\d-\d/],
  20660. ['GGGG-[W]WW', /\d{4}-W\d\d/, false],
  20661. ['YYYY-DDD', /\d{4}-\d{3}/],
  20662. ['YYYY-MM', /\d{4}-\d\d/, false],
  20663. ['YYYYYYMMDD', /[+-]\d{10}/],
  20664. ['YYYYMMDD', /\d{8}/],
  20665. // YYYYMM is NOT allowed by the standard
  20666. ['GGGG[W]WWE', /\d{4}W\d{3}/],
  20667. ['GGGG[W]WW', /\d{4}W\d{2}/, false],
  20668. ['YYYYDDD', /\d{7}/]
  20669. ];
  20670. // iso time formats and regexes
  20671. var isoTimes = [
  20672. ['HH:mm:ss.SSSS', /\d\d:\d\d:\d\d\.\d+/],
  20673. ['HH:mm:ss,SSSS', /\d\d:\d\d:\d\d,\d+/],
  20674. ['HH:mm:ss', /\d\d:\d\d:\d\d/],
  20675. ['HH:mm', /\d\d:\d\d/],
  20676. ['HHmmss.SSSS', /\d\d\d\d\d\d\.\d+/],
  20677. ['HHmmss,SSSS', /\d\d\d\d\d\d,\d+/],
  20678. ['HHmmss', /\d\d\d\d\d\d/],
  20679. ['HHmm', /\d\d\d\d/],
  20680. ['HH', /\d\d/]
  20681. ];
  20682. var aspNetJsonRegex = /^\/?Date\((\-?\d+)/i;
  20683. // date from iso format
  20684. function configFromISO(config) {
  20685. var i, l,
  20686. string = config._i,
  20687. match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string),
  20688. allowTime, dateFormat, timeFormat, tzFormat;
  20689. if (match) {
  20690. getParsingFlags(config).iso = true;
  20691. for (i = 0, l = isoDates.length; i < l; i++) {
  20692. if (isoDates[i][1].exec(match[1])) {
  20693. dateFormat = isoDates[i][0];
  20694. allowTime = isoDates[i][2] !== false;
  20695. break;
  20696. }
  20697. }
  20698. if (dateFormat == null) {
  20699. config._isValid = false;
  20700. return;
  20701. }
  20702. if (match[3]) {
  20703. for (i = 0, l = isoTimes.length; i < l; i++) {
  20704. if (isoTimes[i][1].exec(match[3])) {
  20705. // match[2] should be 'T' or space
  20706. timeFormat = (match[2] || ' ') + isoTimes[i][0];
  20707. break;
  20708. }
  20709. }
  20710. if (timeFormat == null) {
  20711. config._isValid = false;
  20712. return;
  20713. }
  20714. }
  20715. if (!allowTime && timeFormat != null) {
  20716. config._isValid = false;
  20717. return;
  20718. }
  20719. if (match[4]) {
  20720. if (tzRegex.exec(match[4])) {
  20721. tzFormat = 'Z';
  20722. } else {
  20723. config._isValid = false;
  20724. return;
  20725. }
  20726. }
  20727. config._f = dateFormat + (timeFormat || '') + (tzFormat || '');
  20728. configFromStringAndFormat(config);
  20729. } else {
  20730. config._isValid = false;
  20731. }
  20732. }
  20733. // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
  20734. var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/;
  20735. function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
  20736. var result = [
  20737. untruncateYear(yearStr),
  20738. defaultLocaleMonthsShort.indexOf(monthStr),
  20739. parseInt(dayStr, 10),
  20740. parseInt(hourStr, 10),
  20741. parseInt(minuteStr, 10)
  20742. ];
  20743. if (secondStr) {
  20744. result.push(parseInt(secondStr, 10));
  20745. }
  20746. return result;
  20747. }
  20748. function untruncateYear(yearStr) {
  20749. var year = parseInt(yearStr, 10);
  20750. if (year <= 49) {
  20751. return 2000 + year;
  20752. } else if (year <= 999) {
  20753. return 1900 + year;
  20754. }
  20755. return year;
  20756. }
  20757. function preprocessRFC2822(s) {
  20758. // Remove comments and folding whitespace and replace multiple-spaces with a single space
  20759. return s.replace(/\([^)]*\)|[\n\t]/g, ' ').replace(/(\s\s+)/g, ' ').trim();
  20760. }
  20761. function checkWeekday(weekdayStr, parsedInput, config) {
  20762. if (weekdayStr) {
  20763. // TODO: Replace the vanilla JS Date object with an indepentent day-of-week check.
  20764. var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr),
  20765. weekdayActual = new Date(parsedInput[0], parsedInput[1], parsedInput[2]).getDay();
  20766. if (weekdayProvided !== weekdayActual) {
  20767. getParsingFlags(config).weekdayMismatch = true;
  20768. config._isValid = false;
  20769. return false;
  20770. }
  20771. }
  20772. return true;
  20773. }
  20774. var obsOffsets = {
  20775. UT: 0,
  20776. GMT: 0,
  20777. EDT: -4 * 60,
  20778. EST: -5 * 60,
  20779. CDT: -5 * 60,
  20780. CST: -6 * 60,
  20781. MDT: -6 * 60,
  20782. MST: -7 * 60,
  20783. PDT: -7 * 60,
  20784. PST: -8 * 60
  20785. };
  20786. function calculateOffset(obsOffset, militaryOffset, numOffset) {
  20787. if (obsOffset) {
  20788. return obsOffsets[obsOffset];
  20789. } else if (militaryOffset) {
  20790. // the only allowed military tz is Z
  20791. return 0;
  20792. } else {
  20793. var hm = parseInt(numOffset, 10);
  20794. var m = hm % 100, h = (hm - m) / 100;
  20795. return h * 60 + m;
  20796. }
  20797. }
  20798. // date and time from ref 2822 format
  20799. function configFromRFC2822(config) {
  20800. var match = rfc2822.exec(preprocessRFC2822(config._i));
  20801. if (match) {
  20802. var parsedArray = extractFromRFC2822Strings(match[4], match[3], match[2], match[5], match[6], match[7]);
  20803. if (!checkWeekday(match[1], parsedArray, config)) {
  20804. return;
  20805. }
  20806. config._a = parsedArray;
  20807. config._tzm = calculateOffset(match[8], match[9], match[10]);
  20808. config._d = createUTCDate.apply(null, config._a);
  20809. config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
  20810. getParsingFlags(config).rfc2822 = true;
  20811. } else {
  20812. config._isValid = false;
  20813. }
  20814. }
  20815. // date from iso format or fallback
  20816. function configFromString(config) {
  20817. var matched = aspNetJsonRegex.exec(config._i);
  20818. if (matched !== null) {
  20819. config._d = new Date(+matched[1]);
  20820. return;
  20821. }
  20822. configFromISO(config);
  20823. if (config._isValid === false) {
  20824. delete config._isValid;
  20825. } else {
  20826. return;
  20827. }
  20828. configFromRFC2822(config);
  20829. if (config._isValid === false) {
  20830. delete config._isValid;
  20831. } else {
  20832. return;
  20833. }
  20834. // Final attempt, use Input Fallback
  20835. hooks.createFromInputFallback(config);
  20836. }
  20837. hooks.createFromInputFallback = deprecate(
  20838. 'value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), ' +
  20839. 'which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are ' +
  20840. 'discouraged and will be removed in an upcoming major release. Please refer to ' +
  20841. 'http://momentjs.com/guides/#/warnings/js-date/ for more info.',
  20842. function (config) {
  20843. config._d = new Date(config._i + (config._useUTC ? ' UTC' : ''));
  20844. }
  20845. );
  20846. // constant that refers to the ISO standard
  20847. hooks.ISO_8601 = function () {};
  20848. // constant that refers to the RFC 2822 form
  20849. hooks.RFC_2822 = function () {};
  20850. // date from string and format string
  20851. function configFromStringAndFormat(config) {
  20852. // TODO: Move this to another part of the creation flow to prevent circular deps
  20853. if (config._f === hooks.ISO_8601) {
  20854. configFromISO(config);
  20855. return;
  20856. }
  20857. if (config._f === hooks.RFC_2822) {
  20858. configFromRFC2822(config);
  20859. return;
  20860. }
  20861. config._a = [];
  20862. getParsingFlags(config).empty = true;
  20863. // This array is used to make a Date, either with `new Date` or `Date.UTC`
  20864. var string = '' + config._i,
  20865. i, parsedInput, tokens, token, skipped,
  20866. stringLength = string.length,
  20867. totalParsedInputLength = 0;
  20868. tokens = expandFormat(config._f, config._locale).match(formattingTokens) || [];
  20869. for (i = 0; i < tokens.length; i++) {
  20870. token = tokens[i];
  20871. parsedInput = (string.match(getParseRegexForToken(token, config)) || [])[0];
  20872. // console.log('token', token, 'parsedInput', parsedInput,
  20873. // 'regex', getParseRegexForToken(token, config));
  20874. if (parsedInput) {
  20875. skipped = string.substr(0, string.indexOf(parsedInput));
  20876. if (skipped.length > 0) {
  20877. getParsingFlags(config).unusedInput.push(skipped);
  20878. }
  20879. string = string.slice(string.indexOf(parsedInput) + parsedInput.length);
  20880. totalParsedInputLength += parsedInput.length;
  20881. }
  20882. // don't parse if it's not a known token
  20883. if (formatTokenFunctions[token]) {
  20884. if (parsedInput) {
  20885. getParsingFlags(config).empty = false;
  20886. }
  20887. else {
  20888. getParsingFlags(config).unusedTokens.push(token);
  20889. }
  20890. addTimeToArrayFromToken(token, parsedInput, config);
  20891. }
  20892. else if (config._strict && !parsedInput) {
  20893. getParsingFlags(config).unusedTokens.push(token);
  20894. }
  20895. }
  20896. // add remaining unparsed input length to the string
  20897. getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
  20898. if (string.length > 0) {
  20899. getParsingFlags(config).unusedInput.push(string);
  20900. }
  20901. // clear _12h flag if hour is <= 12
  20902. if (config._a[HOUR] <= 12 &&
  20903. getParsingFlags(config).bigHour === true &&
  20904. config._a[HOUR] > 0) {
  20905. getParsingFlags(config).bigHour = undefined;
  20906. }
  20907. getParsingFlags(config).parsedDateParts = config._a.slice(0);
  20908. getParsingFlags(config).meridiem = config._meridiem;
  20909. // handle meridiem
  20910. config._a[HOUR] = meridiemFixWrap(config._locale, config._a[HOUR], config._meridiem);
  20911. configFromArray(config);
  20912. checkOverflow(config);
  20913. }
  20914. function meridiemFixWrap (locale, hour, meridiem) {
  20915. var isPm;
  20916. if (meridiem == null) {
  20917. // nothing to do
  20918. return hour;
  20919. }
  20920. if (locale.meridiemHour != null) {
  20921. return locale.meridiemHour(hour, meridiem);
  20922. } else if (locale.isPM != null) {
  20923. // Fallback
  20924. isPm = locale.isPM(meridiem);
  20925. if (isPm && hour < 12) {
  20926. hour += 12;
  20927. }
  20928. if (!isPm && hour === 12) {
  20929. hour = 0;
  20930. }
  20931. return hour;
  20932. } else {
  20933. // this is not supposed to happen
  20934. return hour;
  20935. }
  20936. }
  20937. // date from string and array of format strings
  20938. function configFromStringAndArray(config) {
  20939. var tempConfig,
  20940. bestMoment,
  20941. scoreToBeat,
  20942. i,
  20943. currentScore;
  20944. if (config._f.length === 0) {
  20945. getParsingFlags(config).invalidFormat = true;
  20946. config._d = new Date(NaN);
  20947. return;
  20948. }
  20949. for (i = 0; i < config._f.length; i++) {
  20950. currentScore = 0;
  20951. tempConfig = copyConfig({}, config);
  20952. if (config._useUTC != null) {
  20953. tempConfig._useUTC = config._useUTC;
  20954. }
  20955. tempConfig._f = config._f[i];
  20956. configFromStringAndFormat(tempConfig);
  20957. if (!isValid(tempConfig)) {
  20958. continue;
  20959. }
  20960. // if there is any input that was not parsed add a penalty for that format
  20961. currentScore += getParsingFlags(tempConfig).charsLeftOver;
  20962. //or tokens
  20963. currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
  20964. getParsingFlags(tempConfig).score = currentScore;
  20965. if (scoreToBeat == null || currentScore < scoreToBeat) {
  20966. scoreToBeat = currentScore;
  20967. bestMoment = tempConfig;
  20968. }
  20969. }
  20970. extend(config, bestMoment || tempConfig);
  20971. }
  20972. function configFromObject(config) {
  20973. if (config._d) {
  20974. return;
  20975. }
  20976. var i = normalizeObjectUnits(config._i);
  20977. config._a = map([i.year, i.month, i.day || i.date, i.hour, i.minute, i.second, i.millisecond], function (obj) {
  20978. return obj && parseInt(obj, 10);
  20979. });
  20980. configFromArray(config);
  20981. }
  20982. function createFromConfig (config) {
  20983. var res = new Moment(checkOverflow(prepareConfig(config)));
  20984. if (res._nextDay) {
  20985. // Adding is smart enough around DST
  20986. res.add(1, 'd');
  20987. res._nextDay = undefined;
  20988. }
  20989. return res;
  20990. }
  20991. function prepareConfig (config) {
  20992. var input = config._i,
  20993. format = config._f;
  20994. config._locale = config._locale || getLocale(config._l);
  20995. if (input === null || (format === undefined && input === '')) {
  20996. return createInvalid({nullInput: true});
  20997. }
  20998. if (typeof input === 'string') {
  20999. config._i = input = config._locale.preparse(input);
  21000. }
  21001. if (isMoment(input)) {
  21002. return new Moment(checkOverflow(input));
  21003. } else if (isDate(input)) {
  21004. config._d = input;
  21005. } else if (isArray(format)) {
  21006. configFromStringAndArray(config);
  21007. } else if (format) {
  21008. configFromStringAndFormat(config);
  21009. } else {
  21010. configFromInput(config);
  21011. }
  21012. if (!isValid(config)) {
  21013. config._d = null;
  21014. }
  21015. return config;
  21016. }
  21017. function configFromInput(config) {
  21018. var input = config._i;
  21019. if (isUndefined(input)) {
  21020. config._d = new Date(hooks.now());
  21021. } else if (isDate(input)) {
  21022. config._d = new Date(input.valueOf());
  21023. } else if (typeof input === 'string') {
  21024. configFromString(config);
  21025. } else if (isArray(input)) {
  21026. config._a = map(input.slice(0), function (obj) {
  21027. return parseInt(obj, 10);
  21028. });
  21029. configFromArray(config);
  21030. } else if (isObject(input)) {
  21031. configFromObject(config);
  21032. } else if (isNumber(input)) {
  21033. // from milliseconds
  21034. config._d = new Date(input);
  21035. } else {
  21036. hooks.createFromInputFallback(config);
  21037. }
  21038. }
  21039. function createLocalOrUTC (input, format, locale, strict, isUTC) {
  21040. var c = {};
  21041. if (locale === true || locale === false) {
  21042. strict = locale;
  21043. locale = undefined;
  21044. }
  21045. if ((isObject(input) && isObjectEmpty(input)) ||
  21046. (isArray(input) && input.length === 0)) {
  21047. input = undefined;
  21048. }
  21049. // object construction must be done this way.
  21050. // https://github.com/moment/moment/issues/1423
  21051. c._isAMomentObject = true;
  21052. c._useUTC = c._isUTC = isUTC;
  21053. c._l = locale;
  21054. c._i = input;
  21055. c._f = format;
  21056. c._strict = strict;
  21057. return createFromConfig(c);
  21058. }
  21059. function createLocal (input, format, locale, strict) {
  21060. return createLocalOrUTC(input, format, locale, strict, false);
  21061. }
  21062. var prototypeMin = deprecate(
  21063. 'moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/',
  21064. function () {
  21065. var other = createLocal.apply(null, arguments);
  21066. if (this.isValid() && other.isValid()) {
  21067. return other < this ? this : other;
  21068. } else {
  21069. return createInvalid();
  21070. }
  21071. }
  21072. );
  21073. var prototypeMax = deprecate(
  21074. 'moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/',
  21075. function () {
  21076. var other = createLocal.apply(null, arguments);
  21077. if (this.isValid() && other.isValid()) {
  21078. return other > this ? this : other;
  21079. } else {
  21080. return createInvalid();
  21081. }
  21082. }
  21083. );
  21084. // Pick a moment m from moments so that m[fn](other) is true for all
  21085. // other. This relies on the function fn to be transitive.
  21086. //
  21087. // moments should either be an array of moment objects or an array, whose
  21088. // first element is an array of moment objects.
  21089. function pickBy(fn, moments) {
  21090. var res, i;
  21091. if (moments.length === 1 && isArray(moments[0])) {
  21092. moments = moments[0];
  21093. }
  21094. if (!moments.length) {
  21095. return createLocal();
  21096. }
  21097. res = moments[0];
  21098. for (i = 1; i < moments.length; ++i) {
  21099. if (!moments[i].isValid() || moments[i][fn](res)) {
  21100. res = moments[i];
  21101. }
  21102. }
  21103. return res;
  21104. }
  21105. // TODO: Use [].sort instead?
  21106. function min () {
  21107. var args = [].slice.call(arguments, 0);
  21108. return pickBy('isBefore', args);
  21109. }
  21110. function max () {
  21111. var args = [].slice.call(arguments, 0);
  21112. return pickBy('isAfter', args);
  21113. }
  21114. var now = function () {
  21115. return Date.now ? Date.now() : +(new Date());
  21116. };
  21117. var ordering = ['year', 'quarter', 'month', 'week', 'day', 'hour', 'minute', 'second', 'millisecond'];
  21118. function isDurationValid(m) {
  21119. for (var key in m) {
  21120. if (!(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
  21121. return false;
  21122. }
  21123. }
  21124. var unitHasDecimal = false;
  21125. for (var i = 0; i < ordering.length; ++i) {
  21126. if (m[ordering[i]]) {
  21127. if (unitHasDecimal) {
  21128. return false; // only allow non-integers for smallest unit
  21129. }
  21130. if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
  21131. unitHasDecimal = true;
  21132. }
  21133. }
  21134. }
  21135. return true;
  21136. }
  21137. function isValid$1() {
  21138. return this._isValid;
  21139. }
  21140. function createInvalid$1() {
  21141. return createDuration(NaN);
  21142. }
  21143. function Duration (duration) {
  21144. var normalizedInput = normalizeObjectUnits(duration),
  21145. years = normalizedInput.year || 0,
  21146. quarters = normalizedInput.quarter || 0,
  21147. months = normalizedInput.month || 0,
  21148. weeks = normalizedInput.week || 0,
  21149. days = normalizedInput.day || 0,
  21150. hours = normalizedInput.hour || 0,
  21151. minutes = normalizedInput.minute || 0,
  21152. seconds = normalizedInput.second || 0,
  21153. milliseconds = normalizedInput.millisecond || 0;
  21154. this._isValid = isDurationValid(normalizedInput);
  21155. // representation for dateAddRemove
  21156. this._milliseconds = +milliseconds +
  21157. seconds * 1e3 + // 1000
  21158. minutes * 6e4 + // 1000 * 60
  21159. hours * 1000 * 60 * 60; //using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
  21160. // Because of dateAddRemove treats 24 hours as different from a
  21161. // day when working around DST, we need to store them separately
  21162. this._days = +days +
  21163. weeks * 7;
  21164. // It is impossible to translate months into days without knowing
  21165. // which months you are are talking about, so we have to store
  21166. // it separately.
  21167. this._months = +months +
  21168. quarters * 3 +
  21169. years * 12;
  21170. this._data = {};
  21171. this._locale = getLocale();
  21172. this._bubble();
  21173. }
  21174. function isDuration (obj) {
  21175. return obj instanceof Duration;
  21176. }
  21177. function absRound (number) {
  21178. if (number < 0) {
  21179. return Math.round(-1 * number) * -1;
  21180. } else {
  21181. return Math.round(number);
  21182. }
  21183. }
  21184. // FORMATTING
  21185. function offset (token, separator) {
  21186. addFormatToken(token, 0, 0, function () {
  21187. var offset = this.utcOffset();
  21188. var sign = '+';
  21189. if (offset < 0) {
  21190. offset = -offset;
  21191. sign = '-';
  21192. }
  21193. return sign + zeroFill(~~(offset / 60), 2) + separator + zeroFill(~~(offset) % 60, 2);
  21194. });
  21195. }
  21196. offset('Z', ':');
  21197. offset('ZZ', '');
  21198. // PARSING
  21199. addRegexToken('Z', matchShortOffset);
  21200. addRegexToken('ZZ', matchShortOffset);
  21201. addParseToken(['Z', 'ZZ'], function (input, array, config) {
  21202. config._useUTC = true;
  21203. config._tzm = offsetFromString(matchShortOffset, input);
  21204. });
  21205. // HELPERS
  21206. // timezone chunker
  21207. // '+10:00' > ['10', '00']
  21208. // '-1530' > ['-15', '30']
  21209. var chunkOffset = /([\+\-]|\d\d)/gi;
  21210. function offsetFromString(matcher, string) {
  21211. var matches = (string || '').match(matcher);
  21212. if (matches === null) {
  21213. return null;
  21214. }
  21215. var chunk = matches[matches.length - 1] || [];
  21216. var parts = (chunk + '').match(chunkOffset) || ['-', 0, 0];
  21217. var minutes = +(parts[1] * 60) + toInt(parts[2]);
  21218. return minutes === 0 ?
  21219. 0 :
  21220. parts[0] === '+' ? minutes : -minutes;
  21221. }
  21222. // Return a moment from input, that is local/utc/zone equivalent to model.
  21223. function cloneWithOffset(input, model) {
  21224. var res, diff;
  21225. if (model._isUTC) {
  21226. res = model.clone();
  21227. diff = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
  21228. // Use low-level api, because this fn is low-level api.
  21229. res._d.setTime(res._d.valueOf() + diff);
  21230. hooks.updateOffset(res, false);
  21231. return res;
  21232. } else {
  21233. return createLocal(input).local();
  21234. }
  21235. }
  21236. function getDateOffset (m) {
  21237. // On Firefox.24 Date#getTimezoneOffset returns a floating point.
  21238. // https://github.com/moment/moment/pull/1871
  21239. return -Math.round(m._d.getTimezoneOffset() / 15) * 15;
  21240. }
  21241. // HOOKS
  21242. // This function will be called whenever a moment is mutated.
  21243. // It is intended to keep the offset in sync with the timezone.
  21244. hooks.updateOffset = function () {};
  21245. // MOMENTS
  21246. // keepLocalTime = true means only change the timezone, without
  21247. // affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
  21248. // 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
  21249. // +0200, so we adjust the time as needed, to be valid.
  21250. //
  21251. // Keeping the time actually adds/subtracts (one hour)
  21252. // from the actual represented time. That is why we call updateOffset
  21253. // a second time. In case it wants us to change the offset again
  21254. // _changeInProgress == true case, then we have to adjust, because
  21255. // there is no such time in the given timezone.
  21256. function getSetOffset (input, keepLocalTime, keepMinutes) {
  21257. var offset = this._offset || 0,
  21258. localAdjust;
  21259. if (!this.isValid()) {
  21260. return input != null ? this : NaN;
  21261. }
  21262. if (input != null) {
  21263. if (typeof input === 'string') {
  21264. input = offsetFromString(matchShortOffset, input);
  21265. if (input === null) {
  21266. return this;
  21267. }
  21268. } else if (Math.abs(input) < 16 && !keepMinutes) {
  21269. input = input * 60;
  21270. }
  21271. if (!this._isUTC && keepLocalTime) {
  21272. localAdjust = getDateOffset(this);
  21273. }
  21274. this._offset = input;
  21275. this._isUTC = true;
  21276. if (localAdjust != null) {
  21277. this.add(localAdjust, 'm');
  21278. }
  21279. if (offset !== input) {
  21280. if (!keepLocalTime || this._changeInProgress) {
  21281. addSubtract(this, createDuration(input - offset, 'm'), 1, false);
  21282. } else if (!this._changeInProgress) {
  21283. this._changeInProgress = true;
  21284. hooks.updateOffset(this, true);
  21285. this._changeInProgress = null;
  21286. }
  21287. }
  21288. return this;
  21289. } else {
  21290. return this._isUTC ? offset : getDateOffset(this);
  21291. }
  21292. }
  21293. function getSetZone (input, keepLocalTime) {
  21294. if (input != null) {
  21295. if (typeof input !== 'string') {
  21296. input = -input;
  21297. }
  21298. this.utcOffset(input, keepLocalTime);
  21299. return this;
  21300. } else {
  21301. return -this.utcOffset();
  21302. }
  21303. }
  21304. function setOffsetToUTC (keepLocalTime) {
  21305. return this.utcOffset(0, keepLocalTime);
  21306. }
  21307. function setOffsetToLocal (keepLocalTime) {
  21308. if (this._isUTC) {
  21309. this.utcOffset(0, keepLocalTime);
  21310. this._isUTC = false;
  21311. if (keepLocalTime) {
  21312. this.subtract(getDateOffset(this), 'm');
  21313. }
  21314. }
  21315. return this;
  21316. }
  21317. function setOffsetToParsedOffset () {
  21318. if (this._tzm != null) {
  21319. this.utcOffset(this._tzm, false, true);
  21320. } else if (typeof this._i === 'string') {
  21321. var tZone = offsetFromString(matchOffset, this._i);
  21322. if (tZone != null) {
  21323. this.utcOffset(tZone);
  21324. }
  21325. else {
  21326. this.utcOffset(0, true);
  21327. }
  21328. }
  21329. return this;
  21330. }
  21331. function hasAlignedHourOffset (input) {
  21332. if (!this.isValid()) {
  21333. return false;
  21334. }
  21335. input = input ? createLocal(input).utcOffset() : 0;
  21336. return (this.utcOffset() - input) % 60 === 0;
  21337. }
  21338. function isDaylightSavingTime () {
  21339. return (
  21340. this.utcOffset() > this.clone().month(0).utcOffset() ||
  21341. this.utcOffset() > this.clone().month(5).utcOffset()
  21342. );
  21343. }
  21344. function isDaylightSavingTimeShifted () {
  21345. if (!isUndefined(this._isDSTShifted)) {
  21346. return this._isDSTShifted;
  21347. }
  21348. var c = {};
  21349. copyConfig(c, this);
  21350. c = prepareConfig(c);
  21351. if (c._a) {
  21352. var other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
  21353. this._isDSTShifted = this.isValid() &&
  21354. compareArrays(c._a, other.toArray()) > 0;
  21355. } else {
  21356. this._isDSTShifted = false;
  21357. }
  21358. return this._isDSTShifted;
  21359. }
  21360. function isLocal () {
  21361. return this.isValid() ? !this._isUTC : false;
  21362. }
  21363. function isUtcOffset () {
  21364. return this.isValid() ? this._isUTC : false;
  21365. }
  21366. function isUtc () {
  21367. return this.isValid() ? this._isUTC && this._offset === 0 : false;
  21368. }
  21369. // ASP.NET json date format regex
  21370. var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/;
  21371. // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html
  21372. // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere
  21373. // and further modified to allow for strings containing both week and day
  21374. var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
  21375. function createDuration (input, key) {
  21376. var duration = input,
  21377. // matching against regexp is expensive, do it on demand
  21378. match = null,
  21379. sign,
  21380. ret,
  21381. diffRes;
  21382. if (isDuration(input)) {
  21383. duration = {
  21384. ms : input._milliseconds,
  21385. d : input._days,
  21386. M : input._months
  21387. };
  21388. } else if (isNumber(input)) {
  21389. duration = {};
  21390. if (key) {
  21391. duration[key] = input;
  21392. } else {
  21393. duration.milliseconds = input;
  21394. }
  21395. } else if (!!(match = aspNetRegex.exec(input))) {
  21396. sign = (match[1] === '-') ? -1 : 1;
  21397. duration = {
  21398. y : 0,
  21399. d : toInt(match[DATE]) * sign,
  21400. h : toInt(match[HOUR]) * sign,
  21401. m : toInt(match[MINUTE]) * sign,
  21402. s : toInt(match[SECOND]) * sign,
  21403. ms : toInt(absRound(match[MILLISECOND] * 1000)) * sign // the millisecond decimal point is included in the match
  21404. };
  21405. } else if (!!(match = isoRegex.exec(input))) {
  21406. sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1;
  21407. duration = {
  21408. y : parseIso(match[2], sign),
  21409. M : parseIso(match[3], sign),
  21410. w : parseIso(match[4], sign),
  21411. d : parseIso(match[5], sign),
  21412. h : parseIso(match[6], sign),
  21413. m : parseIso(match[7], sign),
  21414. s : parseIso(match[8], sign)
  21415. };
  21416. } else if (duration == null) {// checks for null or undefined
  21417. duration = {};
  21418. } else if (typeof duration === 'object' && ('from' in duration || 'to' in duration)) {
  21419. diffRes = momentsDifference(createLocal(duration.from), createLocal(duration.to));
  21420. duration = {};
  21421. duration.ms = diffRes.milliseconds;
  21422. duration.M = diffRes.months;
  21423. }
  21424. ret = new Duration(duration);
  21425. if (isDuration(input) && hasOwnProp(input, '_locale')) {
  21426. ret._locale = input._locale;
  21427. }
  21428. return ret;
  21429. }
  21430. createDuration.fn = Duration.prototype;
  21431. createDuration.invalid = createInvalid$1;
  21432. function parseIso (inp, sign) {
  21433. // We'd normally use ~~inp for this, but unfortunately it also
  21434. // converts floats to ints.
  21435. // inp may be undefined, so careful calling replace on it.
  21436. var res = inp && parseFloat(inp.replace(',', '.'));
  21437. // apply sign while we're at it
  21438. return (isNaN(res) ? 0 : res) * sign;
  21439. }
  21440. function positiveMomentsDifference(base, other) {
  21441. var res = {milliseconds: 0, months: 0};
  21442. res.months = other.month() - base.month() +
  21443. (other.year() - base.year()) * 12;
  21444. if (base.clone().add(res.months, 'M').isAfter(other)) {
  21445. --res.months;
  21446. }
  21447. res.milliseconds = +other - +(base.clone().add(res.months, 'M'));
  21448. return res;
  21449. }
  21450. function momentsDifference(base, other) {
  21451. var res;
  21452. if (!(base.isValid() && other.isValid())) {
  21453. return {milliseconds: 0, months: 0};
  21454. }
  21455. other = cloneWithOffset(other, base);
  21456. if (base.isBefore(other)) {
  21457. res = positiveMomentsDifference(base, other);
  21458. } else {
  21459. res = positiveMomentsDifference(other, base);
  21460. res.milliseconds = -res.milliseconds;
  21461. res.months = -res.months;
  21462. }
  21463. return res;
  21464. }
  21465. // TODO: remove 'name' arg after deprecation is removed
  21466. function createAdder(direction, name) {
  21467. return function (val, period) {
  21468. var dur, tmp;
  21469. //invert the arguments, but complain about it
  21470. if (period !== null && !isNaN(+period)) {
  21471. deprecateSimple(name, 'moment().' + name + '(period, number) is deprecated. Please use moment().' + name + '(number, period). ' +
  21472. 'See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info.');
  21473. tmp = val; val = period; period = tmp;
  21474. }
  21475. val = typeof val === 'string' ? +val : val;
  21476. dur = createDuration(val, period);
  21477. addSubtract(this, dur, direction);
  21478. return this;
  21479. };
  21480. }
  21481. function addSubtract (mom, duration, isAdding, updateOffset) {
  21482. var milliseconds = duration._milliseconds,
  21483. days = absRound(duration._days),
  21484. months = absRound(duration._months);
  21485. if (!mom.isValid()) {
  21486. // No op
  21487. return;
  21488. }
  21489. updateOffset = updateOffset == null ? true : updateOffset;
  21490. if (months) {
  21491. setMonth(mom, get(mom, 'Month') + months * isAdding);
  21492. }
  21493. if (days) {
  21494. set$1(mom, 'Date', get(mom, 'Date') + days * isAdding);
  21495. }
  21496. if (milliseconds) {
  21497. mom._d.setTime(mom._d.valueOf() + milliseconds * isAdding);
  21498. }
  21499. if (updateOffset) {
  21500. hooks.updateOffset(mom, days || months);
  21501. }
  21502. }
  21503. var add = createAdder(1, 'add');
  21504. var subtract = createAdder(-1, 'subtract');
  21505. function getCalendarFormat(myMoment, now) {
  21506. var diff = myMoment.diff(now, 'days', true);
  21507. return diff < -6 ? 'sameElse' :
  21508. diff < -1 ? 'lastWeek' :
  21509. diff < 0 ? 'lastDay' :
  21510. diff < 1 ? 'sameDay' :
  21511. diff < 2 ? 'nextDay' :
  21512. diff < 7 ? 'nextWeek' : 'sameElse';
  21513. }
  21514. function calendar$1 (time, formats) {
  21515. // We want to compare the start of today, vs this.
  21516. // Getting start-of-today depends on whether we're local/utc/offset or not.
  21517. var now = time || createLocal(),
  21518. sod = cloneWithOffset(now, this).startOf('day'),
  21519. format = hooks.calendarFormat(this, sod) || 'sameElse';
  21520. var output = formats && (isFunction(formats[format]) ? formats[format].call(this, now) : formats[format]);
  21521. return this.format(output || this.localeData().calendar(format, this, createLocal(now)));
  21522. }
  21523. function clone () {
  21524. return new Moment(this);
  21525. }
  21526. function isAfter (input, units) {
  21527. var localInput = isMoment(input) ? input : createLocal(input);
  21528. if (!(this.isValid() && localInput.isValid())) {
  21529. return false;
  21530. }
  21531. units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
  21532. if (units === 'millisecond') {
  21533. return this.valueOf() > localInput.valueOf();
  21534. } else {
  21535. return localInput.valueOf() < this.clone().startOf(units).valueOf();
  21536. }
  21537. }
  21538. function isBefore (input, units) {
  21539. var localInput = isMoment(input) ? input : createLocal(input);
  21540. if (!(this.isValid() && localInput.isValid())) {
  21541. return false;
  21542. }
  21543. units = normalizeUnits(!isUndefined(units) ? units : 'millisecond');
  21544. if (units === 'millisecond') {
  21545. return this.valueOf() < localInput.valueOf();
  21546. } else {
  21547. return this.clone().endOf(units).valueOf() < localInput.valueOf();
  21548. }
  21549. }
  21550. function isBetween (from, to, units, inclusivity) {
  21551. inclusivity = inclusivity || '()';
  21552. return (inclusivity[0] === '(' ? this.isAfter(from, units) : !this.isBefore(from, units)) &&
  21553. (inclusivity[1] === ')' ? this.isBefore(to, units) : !this.isAfter(to, units));
  21554. }
  21555. function isSame (input, units) {
  21556. var localInput = isMoment(input) ? input : createLocal(input),
  21557. inputMs;
  21558. if (!(this.isValid() && localInput.isValid())) {
  21559. return false;
  21560. }
  21561. units = normalizeUnits(units || 'millisecond');
  21562. if (units === 'millisecond') {
  21563. return this.valueOf() === localInput.valueOf();
  21564. } else {
  21565. inputMs = localInput.valueOf();
  21566. return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
  21567. }
  21568. }
  21569. function isSameOrAfter (input, units) {
  21570. return this.isSame(input, units) || this.isAfter(input,units);
  21571. }
  21572. function isSameOrBefore (input, units) {
  21573. return this.isSame(input, units) || this.isBefore(input,units);
  21574. }
  21575. function diff (input, units, asFloat) {
  21576. var that,
  21577. zoneDelta,
  21578. delta, output;
  21579. if (!this.isValid()) {
  21580. return NaN;
  21581. }
  21582. that = cloneWithOffset(input, this);
  21583. if (!that.isValid()) {
  21584. return NaN;
  21585. }
  21586. zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
  21587. units = normalizeUnits(units);
  21588. switch (units) {
  21589. case 'year': output = monthDiff(this, that) / 12; break;
  21590. case 'month': output = monthDiff(this, that); break;
  21591. case 'quarter': output = monthDiff(this, that) / 3; break;
  21592. case 'second': output = (this - that) / 1e3; break; // 1000
  21593. case 'minute': output = (this - that) / 6e4; break; // 1000 * 60
  21594. case 'hour': output = (this - that) / 36e5; break; // 1000 * 60 * 60
  21595. case 'day': output = (this - that - zoneDelta) / 864e5; break; // 1000 * 60 * 60 * 24, negate dst
  21596. case 'week': output = (this - that - zoneDelta) / 6048e5; break; // 1000 * 60 * 60 * 24 * 7, negate dst
  21597. default: output = this - that;
  21598. }
  21599. return asFloat ? output : absFloor(output);
  21600. }
  21601. function monthDiff (a, b) {
  21602. // difference in months
  21603. var wholeMonthDiff = ((b.year() - a.year()) * 12) + (b.month() - a.month()),
  21604. // b is in (anchor - 1 month, anchor + 1 month)
  21605. anchor = a.clone().add(wholeMonthDiff, 'months'),
  21606. anchor2, adjust;
  21607. if (b - anchor < 0) {
  21608. anchor2 = a.clone().add(wholeMonthDiff - 1, 'months');
  21609. // linear across the month
  21610. adjust = (b - anchor) / (anchor - anchor2);
  21611. } else {
  21612. anchor2 = a.clone().add(wholeMonthDiff + 1, 'months');
  21613. // linear across the month
  21614. adjust = (b - anchor) / (anchor2 - anchor);
  21615. }
  21616. //check for negative zero, return zero if negative zero
  21617. return -(wholeMonthDiff + adjust) || 0;
  21618. }
  21619. hooks.defaultFormat = 'YYYY-MM-DDTHH:mm:ssZ';
  21620. hooks.defaultFormatUtc = 'YYYY-MM-DDTHH:mm:ss[Z]';
  21621. function toString () {
  21622. return this.clone().locale('en').format('ddd MMM DD YYYY HH:mm:ss [GMT]ZZ');
  21623. }
  21624. function toISOString() {
  21625. if (!this.isValid()) {
  21626. return null;
  21627. }
  21628. var m = this.clone().utc();
  21629. if (m.year() < 0 || m.year() > 9999) {
  21630. return formatMoment(m, 'YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  21631. }
  21632. if (isFunction(Date.prototype.toISOString)) {
  21633. // native implementation is ~50x faster, use it when we can
  21634. return this.toDate().toISOString();
  21635. }
  21636. return formatMoment(m, 'YYYY-MM-DD[T]HH:mm:ss.SSS[Z]');
  21637. }
  21638. /**
  21639. * Return a human readable representation of a moment that can
  21640. * also be evaluated to get a new moment which is the same
  21641. *
  21642. * @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
  21643. */
  21644. function inspect () {
  21645. if (!this.isValid()) {
  21646. return 'moment.invalid(/* ' + this._i + ' */)';
  21647. }
  21648. var func = 'moment';
  21649. var zone = '';
  21650. if (!this.isLocal()) {
  21651. func = this.utcOffset() === 0 ? 'moment.utc' : 'moment.parseZone';
  21652. zone = 'Z';
  21653. }
  21654. var prefix = '[' + func + '("]';
  21655. var year = (0 <= this.year() && this.year() <= 9999) ? 'YYYY' : 'YYYYYY';
  21656. var datetime = '-MM-DD[T]HH:mm:ss.SSS';
  21657. var suffix = zone + '[")]';
  21658. return this.format(prefix + year + datetime + suffix);
  21659. }
  21660. function format (inputString) {
  21661. if (!inputString) {
  21662. inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
  21663. }
  21664. var output = formatMoment(this, inputString);
  21665. return this.localeData().postformat(output);
  21666. }
  21667. function from (time, withoutSuffix) {
  21668. if (this.isValid() &&
  21669. ((isMoment(time) && time.isValid()) ||
  21670. createLocal(time).isValid())) {
  21671. return createDuration({to: this, from: time}).locale(this.locale()).humanize(!withoutSuffix);
  21672. } else {
  21673. return this.localeData().invalidDate();
  21674. }
  21675. }
  21676. function fromNow (withoutSuffix) {
  21677. return this.from(createLocal(), withoutSuffix);
  21678. }
  21679. function to (time, withoutSuffix) {
  21680. if (this.isValid() &&
  21681. ((isMoment(time) && time.isValid()) ||
  21682. createLocal(time).isValid())) {
  21683. return createDuration({from: this, to: time}).locale(this.locale()).humanize(!withoutSuffix);
  21684. } else {
  21685. return this.localeData().invalidDate();
  21686. }
  21687. }
  21688. function toNow (withoutSuffix) {
  21689. return this.to(createLocal(), withoutSuffix);
  21690. }
  21691. // If passed a locale key, it will set the locale for this
  21692. // instance. Otherwise, it will return the locale configuration
  21693. // variables for this instance.
  21694. function locale (key) {
  21695. var newLocaleData;
  21696. if (key === undefined) {
  21697. return this._locale._abbr;
  21698. } else {
  21699. newLocaleData = getLocale(key);
  21700. if (newLocaleData != null) {
  21701. this._locale = newLocaleData;
  21702. }
  21703. return this;
  21704. }
  21705. }
  21706. var lang = deprecate(
  21707. 'moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.',
  21708. function (key) {
  21709. if (key === undefined) {
  21710. return this.localeData();
  21711. } else {
  21712. return this.locale(key);
  21713. }
  21714. }
  21715. );
  21716. function localeData () {
  21717. return this._locale;
  21718. }
  21719. function startOf (units) {
  21720. units = normalizeUnits(units);
  21721. // the following switch intentionally omits break keywords
  21722. // to utilize falling through the cases.
  21723. switch (units) {
  21724. case 'year':
  21725. this.month(0);
  21726. /* falls through */
  21727. case 'quarter':
  21728. case 'month':
  21729. this.date(1);
  21730. /* falls through */
  21731. case 'week':
  21732. case 'isoWeek':
  21733. case 'day':
  21734. case 'date':
  21735. this.hours(0);
  21736. /* falls through */
  21737. case 'hour':
  21738. this.minutes(0);
  21739. /* falls through */
  21740. case 'minute':
  21741. this.seconds(0);
  21742. /* falls through */
  21743. case 'second':
  21744. this.milliseconds(0);
  21745. }
  21746. // weeks are a special case
  21747. if (units === 'week') {
  21748. this.weekday(0);
  21749. }
  21750. if (units === 'isoWeek') {
  21751. this.isoWeekday(1);
  21752. }
  21753. // quarters are also special
  21754. if (units === 'quarter') {
  21755. this.month(Math.floor(this.month() / 3) * 3);
  21756. }
  21757. return this;
  21758. }
  21759. function endOf (units) {
  21760. units = normalizeUnits(units);
  21761. if (units === undefined || units === 'millisecond') {
  21762. return this;
  21763. }
  21764. // 'date' is an alias for 'day', so it should be considered as such.
  21765. if (units === 'date') {
  21766. units = 'day';
  21767. }
  21768. return this.startOf(units).add(1, (units === 'isoWeek' ? 'week' : units)).subtract(1, 'ms');
  21769. }
  21770. function valueOf () {
  21771. return this._d.valueOf() - ((this._offset || 0) * 60000);
  21772. }
  21773. function unix () {
  21774. return Math.floor(this.valueOf() / 1000);
  21775. }
  21776. function toDate () {
  21777. return new Date(this.valueOf());
  21778. }
  21779. function toArray () {
  21780. var m = this;
  21781. return [m.year(), m.month(), m.date(), m.hour(), m.minute(), m.second(), m.millisecond()];
  21782. }
  21783. function toObject () {
  21784. var m = this;
  21785. return {
  21786. years: m.year(),
  21787. months: m.month(),
  21788. date: m.date(),
  21789. hours: m.hours(),
  21790. minutes: m.minutes(),
  21791. seconds: m.seconds(),
  21792. milliseconds: m.milliseconds()
  21793. };
  21794. }
  21795. function toJSON () {
  21796. // new Date(NaN).toJSON() === null
  21797. return this.isValid() ? this.toISOString() : null;
  21798. }
  21799. function isValid$2 () {
  21800. return isValid(this);
  21801. }
  21802. function parsingFlags () {
  21803. return extend({}, getParsingFlags(this));
  21804. }
  21805. function invalidAt () {
  21806. return getParsingFlags(this).overflow;
  21807. }
  21808. function creationData() {
  21809. return {
  21810. input: this._i,
  21811. format: this._f,
  21812. locale: this._locale,
  21813. isUTC: this._isUTC,
  21814. strict: this._strict
  21815. };
  21816. }
  21817. // FORMATTING
  21818. addFormatToken(0, ['gg', 2], 0, function () {
  21819. return this.weekYear() % 100;
  21820. });
  21821. addFormatToken(0, ['GG', 2], 0, function () {
  21822. return this.isoWeekYear() % 100;
  21823. });
  21824. function addWeekYearFormatToken (token, getter) {
  21825. addFormatToken(0, [token, token.length], 0, getter);
  21826. }
  21827. addWeekYearFormatToken('gggg', 'weekYear');
  21828. addWeekYearFormatToken('ggggg', 'weekYear');
  21829. addWeekYearFormatToken('GGGG', 'isoWeekYear');
  21830. addWeekYearFormatToken('GGGGG', 'isoWeekYear');
  21831. // ALIASES
  21832. addUnitAlias('weekYear', 'gg');
  21833. addUnitAlias('isoWeekYear', 'GG');
  21834. // PRIORITY
  21835. addUnitPriority('weekYear', 1);
  21836. addUnitPriority('isoWeekYear', 1);
  21837. // PARSING
  21838. addRegexToken('G', matchSigned);
  21839. addRegexToken('g', matchSigned);
  21840. addRegexToken('GG', match1to2, match2);
  21841. addRegexToken('gg', match1to2, match2);
  21842. addRegexToken('GGGG', match1to4, match4);
  21843. addRegexToken('gggg', match1to4, match4);
  21844. addRegexToken('GGGGG', match1to6, match6);
  21845. addRegexToken('ggggg', match1to6, match6);
  21846. addWeekParseToken(['gggg', 'ggggg', 'GGGG', 'GGGGG'], function (input, week, config, token) {
  21847. week[token.substr(0, 2)] = toInt(input);
  21848. });
  21849. addWeekParseToken(['gg', 'GG'], function (input, week, config, token) {
  21850. week[token] = hooks.parseTwoDigitYear(input);
  21851. });
  21852. // MOMENTS
  21853. function getSetWeekYear (input) {
  21854. return getSetWeekYearHelper.call(this,
  21855. input,
  21856. this.week(),
  21857. this.weekday(),
  21858. this.localeData()._week.dow,
  21859. this.localeData()._week.doy);
  21860. }
  21861. function getSetISOWeekYear (input) {
  21862. return getSetWeekYearHelper.call(this,
  21863. input, this.isoWeek(), this.isoWeekday(), 1, 4);
  21864. }
  21865. function getISOWeeksInYear () {
  21866. return weeksInYear(this.year(), 1, 4);
  21867. }
  21868. function getWeeksInYear () {
  21869. var weekInfo = this.localeData()._week;
  21870. return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
  21871. }
  21872. function getSetWeekYearHelper(input, week, weekday, dow, doy) {
  21873. var weeksTarget;
  21874. if (input == null) {
  21875. return weekOfYear(this, dow, doy).year;
  21876. } else {
  21877. weeksTarget = weeksInYear(input, dow, doy);
  21878. if (week > weeksTarget) {
  21879. week = weeksTarget;
  21880. }
  21881. return setWeekAll.call(this, input, week, weekday, dow, doy);
  21882. }
  21883. }
  21884. function setWeekAll(weekYear, week, weekday, dow, doy) {
  21885. var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy),
  21886. date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
  21887. this.year(date.getUTCFullYear());
  21888. this.month(date.getUTCMonth());
  21889. this.date(date.getUTCDate());
  21890. return this;
  21891. }
  21892. // FORMATTING
  21893. addFormatToken('Q', 0, 'Qo', 'quarter');
  21894. // ALIASES
  21895. addUnitAlias('quarter', 'Q');
  21896. // PRIORITY
  21897. addUnitPriority('quarter', 7);
  21898. // PARSING
  21899. addRegexToken('Q', match1);
  21900. addParseToken('Q', function (input, array) {
  21901. array[MONTH] = (toInt(input) - 1) * 3;
  21902. });
  21903. // MOMENTS
  21904. function getSetQuarter (input) {
  21905. return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
  21906. }
  21907. // FORMATTING
  21908. addFormatToken('D', ['DD', 2], 'Do', 'date');
  21909. // ALIASES
  21910. addUnitAlias('date', 'D');
  21911. // PRIOROITY
  21912. addUnitPriority('date', 9);
  21913. // PARSING
  21914. addRegexToken('D', match1to2);
  21915. addRegexToken('DD', match1to2, match2);
  21916. addRegexToken('Do', function (isStrict, locale) {
  21917. // TODO: Remove "ordinalParse" fallback in next major release.
  21918. return isStrict ?
  21919. (locale._dayOfMonthOrdinalParse || locale._ordinalParse) :
  21920. locale._dayOfMonthOrdinalParseLenient;
  21921. });
  21922. addParseToken(['D', 'DD'], DATE);
  21923. addParseToken('Do', function (input, array) {
  21924. array[DATE] = toInt(input.match(match1to2)[0]);
  21925. });
  21926. // MOMENTS
  21927. var getSetDayOfMonth = makeGetSet('Date', true);
  21928. // FORMATTING
  21929. addFormatToken('DDD', ['DDDD', 3], 'DDDo', 'dayOfYear');
  21930. // ALIASES
  21931. addUnitAlias('dayOfYear', 'DDD');
  21932. // PRIORITY
  21933. addUnitPriority('dayOfYear', 4);
  21934. // PARSING
  21935. addRegexToken('DDD', match1to3);
  21936. addRegexToken('DDDD', match3);
  21937. addParseToken(['DDD', 'DDDD'], function (input, array, config) {
  21938. config._dayOfYear = toInt(input);
  21939. });
  21940. // HELPERS
  21941. // MOMENTS
  21942. function getSetDayOfYear (input) {
  21943. var dayOfYear = Math.round((this.clone().startOf('day') - this.clone().startOf('year')) / 864e5) + 1;
  21944. return input == null ? dayOfYear : this.add((input - dayOfYear), 'd');
  21945. }
  21946. // FORMATTING
  21947. addFormatToken('m', ['mm', 2], 0, 'minute');
  21948. // ALIASES
  21949. addUnitAlias('minute', 'm');
  21950. // PRIORITY
  21951. addUnitPriority('minute', 14);
  21952. // PARSING
  21953. addRegexToken('m', match1to2);
  21954. addRegexToken('mm', match1to2, match2);
  21955. addParseToken(['m', 'mm'], MINUTE);
  21956. // MOMENTS
  21957. var getSetMinute = makeGetSet('Minutes', false);
  21958. // FORMATTING
  21959. addFormatToken('s', ['ss', 2], 0, 'second');
  21960. // ALIASES
  21961. addUnitAlias('second', 's');
  21962. // PRIORITY
  21963. addUnitPriority('second', 15);
  21964. // PARSING
  21965. addRegexToken('s', match1to2);
  21966. addRegexToken('ss', match1to2, match2);
  21967. addParseToken(['s', 'ss'], SECOND);
  21968. // MOMENTS
  21969. var getSetSecond = makeGetSet('Seconds', false);
  21970. // FORMATTING
  21971. addFormatToken('S', 0, 0, function () {
  21972. return ~~(this.millisecond() / 100);
  21973. });
  21974. addFormatToken(0, ['SS', 2], 0, function () {
  21975. return ~~(this.millisecond() / 10);
  21976. });
  21977. addFormatToken(0, ['SSS', 3], 0, 'millisecond');
  21978. addFormatToken(0, ['SSSS', 4], 0, function () {
  21979. return this.millisecond() * 10;
  21980. });
  21981. addFormatToken(0, ['SSSSS', 5], 0, function () {
  21982. return this.millisecond() * 100;
  21983. });
  21984. addFormatToken(0, ['SSSSSS', 6], 0, function () {
  21985. return this.millisecond() * 1000;
  21986. });
  21987. addFormatToken(0, ['SSSSSSS', 7], 0, function () {
  21988. return this.millisecond() * 10000;
  21989. });
  21990. addFormatToken(0, ['SSSSSSSS', 8], 0, function () {
  21991. return this.millisecond() * 100000;
  21992. });
  21993. addFormatToken(0, ['SSSSSSSSS', 9], 0, function () {
  21994. return this.millisecond() * 1000000;
  21995. });
  21996. // ALIASES
  21997. addUnitAlias('millisecond', 'ms');
  21998. // PRIORITY
  21999. addUnitPriority('millisecond', 16);
  22000. // PARSING
  22001. addRegexToken('S', match1to3, match1);
  22002. addRegexToken('SS', match1to3, match2);
  22003. addRegexToken('SSS', match1to3, match3);
  22004. var token;
  22005. for (token = 'SSSS'; token.length <= 9; token += 'S') {
  22006. addRegexToken(token, matchUnsigned);
  22007. }
  22008. function parseMs(input, array) {
  22009. array[MILLISECOND] = toInt(('0.' + input) * 1000);
  22010. }
  22011. for (token = 'S'; token.length <= 9; token += 'S') {
  22012. addParseToken(token, parseMs);
  22013. }
  22014. // MOMENTS
  22015. var getSetMillisecond = makeGetSet('Milliseconds', false);
  22016. // FORMATTING
  22017. addFormatToken('z', 0, 0, 'zoneAbbr');
  22018. addFormatToken('zz', 0, 0, 'zoneName');
  22019. // MOMENTS
  22020. function getZoneAbbr () {
  22021. return this._isUTC ? 'UTC' : '';
  22022. }
  22023. function getZoneName () {
  22024. return this._isUTC ? 'Coordinated Universal Time' : '';
  22025. }
  22026. var proto = Moment.prototype;
  22027. proto.add = add;
  22028. proto.calendar = calendar$1;
  22029. proto.clone = clone;
  22030. proto.diff = diff;
  22031. proto.endOf = endOf;
  22032. proto.format = format;
  22033. proto.from = from;
  22034. proto.fromNow = fromNow;
  22035. proto.to = to;
  22036. proto.toNow = toNow;
  22037. proto.get = stringGet;
  22038. proto.invalidAt = invalidAt;
  22039. proto.isAfter = isAfter;
  22040. proto.isBefore = isBefore;
  22041. proto.isBetween = isBetween;
  22042. proto.isSame = isSame;
  22043. proto.isSameOrAfter = isSameOrAfter;
  22044. proto.isSameOrBefore = isSameOrBefore;
  22045. proto.isValid = isValid$2;
  22046. proto.lang = lang;
  22047. proto.locale = locale;
  22048. proto.localeData = localeData;
  22049. proto.max = prototypeMax;
  22050. proto.min = prototypeMin;
  22051. proto.parsingFlags = parsingFlags;
  22052. proto.set = stringSet;
  22053. proto.startOf = startOf;
  22054. proto.subtract = subtract;
  22055. proto.toArray = toArray;
  22056. proto.toObject = toObject;
  22057. proto.toDate = toDate;
  22058. proto.toISOString = toISOString;
  22059. proto.inspect = inspect;
  22060. proto.toJSON = toJSON;
  22061. proto.toString = toString;
  22062. proto.unix = unix;
  22063. proto.valueOf = valueOf;
  22064. proto.creationData = creationData;
  22065. // Year
  22066. proto.year = getSetYear;
  22067. proto.isLeapYear = getIsLeapYear;
  22068. // Week Year
  22069. proto.weekYear = getSetWeekYear;
  22070. proto.isoWeekYear = getSetISOWeekYear;
  22071. // Quarter
  22072. proto.quarter = proto.quarters = getSetQuarter;
  22073. // Month
  22074. proto.month = getSetMonth;
  22075. proto.daysInMonth = getDaysInMonth;
  22076. // Week
  22077. proto.week = proto.weeks = getSetWeek;
  22078. proto.isoWeek = proto.isoWeeks = getSetISOWeek;
  22079. proto.weeksInYear = getWeeksInYear;
  22080. proto.isoWeeksInYear = getISOWeeksInYear;
  22081. // Day
  22082. proto.date = getSetDayOfMonth;
  22083. proto.day = proto.days = getSetDayOfWeek;
  22084. proto.weekday = getSetLocaleDayOfWeek;
  22085. proto.isoWeekday = getSetISODayOfWeek;
  22086. proto.dayOfYear = getSetDayOfYear;
  22087. // Hour
  22088. proto.hour = proto.hours = getSetHour;
  22089. // Minute
  22090. proto.minute = proto.minutes = getSetMinute;
  22091. // Second
  22092. proto.second = proto.seconds = getSetSecond;
  22093. // Millisecond
  22094. proto.millisecond = proto.milliseconds = getSetMillisecond;
  22095. // Offset
  22096. proto.utcOffset = getSetOffset;
  22097. proto.utc = setOffsetToUTC;
  22098. proto.local = setOffsetToLocal;
  22099. proto.parseZone = setOffsetToParsedOffset;
  22100. proto.hasAlignedHourOffset = hasAlignedHourOffset;
  22101. proto.isDST = isDaylightSavingTime;
  22102. proto.isLocal = isLocal;
  22103. proto.isUtcOffset = isUtcOffset;
  22104. proto.isUtc = isUtc;
  22105. proto.isUTC = isUtc;
  22106. // Timezone
  22107. proto.zoneAbbr = getZoneAbbr;
  22108. proto.zoneName = getZoneName;
  22109. // Deprecations
  22110. proto.dates = deprecate('dates accessor is deprecated. Use date instead.', getSetDayOfMonth);
  22111. proto.months = deprecate('months accessor is deprecated. Use month instead', getSetMonth);
  22112. proto.years = deprecate('years accessor is deprecated. Use year instead', getSetYear);
  22113. proto.zone = deprecate('moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/', getSetZone);
  22114. proto.isDSTShifted = deprecate('isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information', isDaylightSavingTimeShifted);
  22115. function createUnix (input) {
  22116. return createLocal(input * 1000);
  22117. }
  22118. function createInZone () {
  22119. return createLocal.apply(null, arguments).parseZone();
  22120. }
  22121. function preParsePostFormat (string) {
  22122. return string;
  22123. }
  22124. var proto$1 = Locale.prototype;
  22125. proto$1.calendar = calendar;
  22126. proto$1.longDateFormat = longDateFormat;
  22127. proto$1.invalidDate = invalidDate;
  22128. proto$1.ordinal = ordinal;
  22129. proto$1.preparse = preParsePostFormat;
  22130. proto$1.postformat = preParsePostFormat;
  22131. proto$1.relativeTime = relativeTime;
  22132. proto$1.pastFuture = pastFuture;
  22133. proto$1.set = set;
  22134. // Month
  22135. proto$1.months = localeMonths;
  22136. proto$1.monthsShort = localeMonthsShort;
  22137. proto$1.monthsParse = localeMonthsParse;
  22138. proto$1.monthsRegex = monthsRegex;
  22139. proto$1.monthsShortRegex = monthsShortRegex;
  22140. // Week
  22141. proto$1.week = localeWeek;
  22142. proto$1.firstDayOfYear = localeFirstDayOfYear;
  22143. proto$1.firstDayOfWeek = localeFirstDayOfWeek;
  22144. // Day of Week
  22145. proto$1.weekdays = localeWeekdays;
  22146. proto$1.weekdaysMin = localeWeekdaysMin;
  22147. proto$1.weekdaysShort = localeWeekdaysShort;
  22148. proto$1.weekdaysParse = localeWeekdaysParse;
  22149. proto$1.weekdaysRegex = weekdaysRegex;
  22150. proto$1.weekdaysShortRegex = weekdaysShortRegex;
  22151. proto$1.weekdaysMinRegex = weekdaysMinRegex;
  22152. // Hours
  22153. proto$1.isPM = localeIsPM;
  22154. proto$1.meridiem = localeMeridiem;
  22155. function get$1 (format, index, field, setter) {
  22156. var locale = getLocale();
  22157. var utc = createUTC().set(setter, index);
  22158. return locale[field](utc, format);
  22159. }
  22160. function listMonthsImpl (format, index, field) {
  22161. if (isNumber(format)) {
  22162. index = format;
  22163. format = undefined;
  22164. }
  22165. format = format || '';
  22166. if (index != null) {
  22167. return get$1(format, index, field, 'month');
  22168. }
  22169. var i;
  22170. var out = [];
  22171. for (i = 0; i < 12; i++) {
  22172. out[i] = get$1(format, i, field, 'month');
  22173. }
  22174. return out;
  22175. }
  22176. // ()
  22177. // (5)
  22178. // (fmt, 5)
  22179. // (fmt)
  22180. // (true)
  22181. // (true, 5)
  22182. // (true, fmt, 5)
  22183. // (true, fmt)
  22184. function listWeekdaysImpl (localeSorted, format, index, field) {
  22185. if (typeof localeSorted === 'boolean') {
  22186. if (isNumber(format)) {
  22187. index = format;
  22188. format = undefined;
  22189. }
  22190. format = format || '';
  22191. } else {
  22192. format = localeSorted;
  22193. index = format;
  22194. localeSorted = false;
  22195. if (isNumber(format)) {
  22196. index = format;
  22197. format = undefined;
  22198. }
  22199. format = format || '';
  22200. }
  22201. var locale = getLocale(),
  22202. shift = localeSorted ? locale._week.dow : 0;
  22203. if (index != null) {
  22204. return get$1(format, (index + shift) % 7, field, 'day');
  22205. }
  22206. var i;
  22207. var out = [];
  22208. for (i = 0; i < 7; i++) {
  22209. out[i] = get$1(format, (i + shift) % 7, field, 'day');
  22210. }
  22211. return out;
  22212. }
  22213. function listMonths (format, index) {
  22214. return listMonthsImpl(format, index, 'months');
  22215. }
  22216. function listMonthsShort (format, index) {
  22217. return listMonthsImpl(format, index, 'monthsShort');
  22218. }
  22219. function listWeekdays (localeSorted, format, index) {
  22220. return listWeekdaysImpl(localeSorted, format, index, 'weekdays');
  22221. }
  22222. function listWeekdaysShort (localeSorted, format, index) {
  22223. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysShort');
  22224. }
  22225. function listWeekdaysMin (localeSorted, format, index) {
  22226. return listWeekdaysImpl(localeSorted, format, index, 'weekdaysMin');
  22227. }
  22228. getSetGlobalLocale('en', {
  22229. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  22230. ordinal : function (number) {
  22231. var b = number % 10,
  22232. output = (toInt(number % 100 / 10) === 1) ? 'th' :
  22233. (b === 1) ? 'st' :
  22234. (b === 2) ? 'nd' :
  22235. (b === 3) ? 'rd' : 'th';
  22236. return number + output;
  22237. }
  22238. });
  22239. // Side effect imports
  22240. hooks.lang = deprecate('moment.lang is deprecated. Use moment.locale instead.', getSetGlobalLocale);
  22241. hooks.langData = deprecate('moment.langData is deprecated. Use moment.localeData instead.', getLocale);
  22242. var mathAbs = Math.abs;
  22243. function abs () {
  22244. var data = this._data;
  22245. this._milliseconds = mathAbs(this._milliseconds);
  22246. this._days = mathAbs(this._days);
  22247. this._months = mathAbs(this._months);
  22248. data.milliseconds = mathAbs(data.milliseconds);
  22249. data.seconds = mathAbs(data.seconds);
  22250. data.minutes = mathAbs(data.minutes);
  22251. data.hours = mathAbs(data.hours);
  22252. data.months = mathAbs(data.months);
  22253. data.years = mathAbs(data.years);
  22254. return this;
  22255. }
  22256. function addSubtract$1 (duration, input, value, direction) {
  22257. var other = createDuration(input, value);
  22258. duration._milliseconds += direction * other._milliseconds;
  22259. duration._days += direction * other._days;
  22260. duration._months += direction * other._months;
  22261. return duration._bubble();
  22262. }
  22263. // supports only 2.0-style add(1, 's') or add(duration)
  22264. function add$1 (input, value) {
  22265. return addSubtract$1(this, input, value, 1);
  22266. }
  22267. // supports only 2.0-style subtract(1, 's') or subtract(duration)
  22268. function subtract$1 (input, value) {
  22269. return addSubtract$1(this, input, value, -1);
  22270. }
  22271. function absCeil (number) {
  22272. if (number < 0) {
  22273. return Math.floor(number);
  22274. } else {
  22275. return Math.ceil(number);
  22276. }
  22277. }
  22278. function bubble () {
  22279. var milliseconds = this._milliseconds;
  22280. var days = this._days;
  22281. var months = this._months;
  22282. var data = this._data;
  22283. var seconds, minutes, hours, years, monthsFromDays;
  22284. // if we have a mix of positive and negative values, bubble down first
  22285. // check: https://github.com/moment/moment/issues/2166
  22286. if (!((milliseconds >= 0 && days >= 0 && months >= 0) ||
  22287. (milliseconds <= 0 && days <= 0 && months <= 0))) {
  22288. milliseconds += absCeil(monthsToDays(months) + days) * 864e5;
  22289. days = 0;
  22290. months = 0;
  22291. }
  22292. // The following code bubbles up values, see the tests for
  22293. // examples of what that means.
  22294. data.milliseconds = milliseconds % 1000;
  22295. seconds = absFloor(milliseconds / 1000);
  22296. data.seconds = seconds % 60;
  22297. minutes = absFloor(seconds / 60);
  22298. data.minutes = minutes % 60;
  22299. hours = absFloor(minutes / 60);
  22300. data.hours = hours % 24;
  22301. days += absFloor(hours / 24);
  22302. // convert days to months
  22303. monthsFromDays = absFloor(daysToMonths(days));
  22304. months += monthsFromDays;
  22305. days -= absCeil(monthsToDays(monthsFromDays));
  22306. // 12 months -> 1 year
  22307. years = absFloor(months / 12);
  22308. months %= 12;
  22309. data.days = days;
  22310. data.months = months;
  22311. data.years = years;
  22312. return this;
  22313. }
  22314. function daysToMonths (days) {
  22315. // 400 years have 146097 days (taking into account leap year rules)
  22316. // 400 years have 12 months === 4800
  22317. return days * 4800 / 146097;
  22318. }
  22319. function monthsToDays (months) {
  22320. // the reverse of daysToMonths
  22321. return months * 146097 / 4800;
  22322. }
  22323. function as (units) {
  22324. if (!this.isValid()) {
  22325. return NaN;
  22326. }
  22327. var days;
  22328. var months;
  22329. var milliseconds = this._milliseconds;
  22330. units = normalizeUnits(units);
  22331. if (units === 'month' || units === 'year') {
  22332. days = this._days + milliseconds / 864e5;
  22333. months = this._months + daysToMonths(days);
  22334. return units === 'month' ? months : months / 12;
  22335. } else {
  22336. // handle milliseconds separately because of floating point math errors (issue #1867)
  22337. days = this._days + Math.round(monthsToDays(this._months));
  22338. switch (units) {
  22339. case 'week' : return days / 7 + milliseconds / 6048e5;
  22340. case 'day' : return days + milliseconds / 864e5;
  22341. case 'hour' : return days * 24 + milliseconds / 36e5;
  22342. case 'minute' : return days * 1440 + milliseconds / 6e4;
  22343. case 'second' : return days * 86400 + milliseconds / 1000;
  22344. // Math.floor prevents floating point math errors here
  22345. case 'millisecond': return Math.floor(days * 864e5) + milliseconds;
  22346. default: throw new Error('Unknown unit ' + units);
  22347. }
  22348. }
  22349. }
  22350. // TODO: Use this.as('ms')?
  22351. function valueOf$1 () {
  22352. if (!this.isValid()) {
  22353. return NaN;
  22354. }
  22355. return (
  22356. this._milliseconds +
  22357. this._days * 864e5 +
  22358. (this._months % 12) * 2592e6 +
  22359. toInt(this._months / 12) * 31536e6
  22360. );
  22361. }
  22362. function makeAs (alias) {
  22363. return function () {
  22364. return this.as(alias);
  22365. };
  22366. }
  22367. var asMilliseconds = makeAs('ms');
  22368. var asSeconds = makeAs('s');
  22369. var asMinutes = makeAs('m');
  22370. var asHours = makeAs('h');
  22371. var asDays = makeAs('d');
  22372. var asWeeks = makeAs('w');
  22373. var asMonths = makeAs('M');
  22374. var asYears = makeAs('y');
  22375. function clone$1 () {
  22376. return createDuration(this);
  22377. }
  22378. function get$2 (units) {
  22379. units = normalizeUnits(units);
  22380. return this.isValid() ? this[units + 's']() : NaN;
  22381. }
  22382. function makeGetter(name) {
  22383. return function () {
  22384. return this.isValid() ? this._data[name] : NaN;
  22385. };
  22386. }
  22387. var milliseconds = makeGetter('milliseconds');
  22388. var seconds = makeGetter('seconds');
  22389. var minutes = makeGetter('minutes');
  22390. var hours = makeGetter('hours');
  22391. var days = makeGetter('days');
  22392. var months = makeGetter('months');
  22393. var years = makeGetter('years');
  22394. function weeks () {
  22395. return absFloor(this.days() / 7);
  22396. }
  22397. var round = Math.round;
  22398. var thresholds = {
  22399. ss: 44, // a few seconds to seconds
  22400. s : 45, // seconds to minute
  22401. m : 45, // minutes to hour
  22402. h : 22, // hours to day
  22403. d : 26, // days to month
  22404. M : 11 // months to year
  22405. };
  22406. // helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
  22407. function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale) {
  22408. return locale.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
  22409. }
  22410. function relativeTime$1 (posNegDuration, withoutSuffix, locale) {
  22411. var duration = createDuration(posNegDuration).abs();
  22412. var seconds = round(duration.as('s'));
  22413. var minutes = round(duration.as('m'));
  22414. var hours = round(duration.as('h'));
  22415. var days = round(duration.as('d'));
  22416. var months = round(duration.as('M'));
  22417. var years = round(duration.as('y'));
  22418. var a = seconds <= thresholds.ss && ['s', seconds] ||
  22419. seconds < thresholds.s && ['ss', seconds] ||
  22420. minutes <= 1 && ['m'] ||
  22421. minutes < thresholds.m && ['mm', minutes] ||
  22422. hours <= 1 && ['h'] ||
  22423. hours < thresholds.h && ['hh', hours] ||
  22424. days <= 1 && ['d'] ||
  22425. days < thresholds.d && ['dd', days] ||
  22426. months <= 1 && ['M'] ||
  22427. months < thresholds.M && ['MM', months] ||
  22428. years <= 1 && ['y'] || ['yy', years];
  22429. a[2] = withoutSuffix;
  22430. a[3] = +posNegDuration > 0;
  22431. a[4] = locale;
  22432. return substituteTimeAgo.apply(null, a);
  22433. }
  22434. // This function allows you to set the rounding function for relative time strings
  22435. function getSetRelativeTimeRounding (roundingFunction) {
  22436. if (roundingFunction === undefined) {
  22437. return round;
  22438. }
  22439. if (typeof(roundingFunction) === 'function') {
  22440. round = roundingFunction;
  22441. return true;
  22442. }
  22443. return false;
  22444. }
  22445. // This function allows you to set a threshold for relative time strings
  22446. function getSetRelativeTimeThreshold (threshold, limit) {
  22447. if (thresholds[threshold] === undefined) {
  22448. return false;
  22449. }
  22450. if (limit === undefined) {
  22451. return thresholds[threshold];
  22452. }
  22453. thresholds[threshold] = limit;
  22454. if (threshold === 's') {
  22455. thresholds.ss = limit - 1;
  22456. }
  22457. return true;
  22458. }
  22459. function humanize (withSuffix) {
  22460. if (!this.isValid()) {
  22461. return this.localeData().invalidDate();
  22462. }
  22463. var locale = this.localeData();
  22464. var output = relativeTime$1(this, !withSuffix, locale);
  22465. if (withSuffix) {
  22466. output = locale.pastFuture(+this, output);
  22467. }
  22468. return locale.postformat(output);
  22469. }
  22470. var abs$1 = Math.abs;
  22471. function sign(x) {
  22472. return ((x > 0) - (x < 0)) || +x;
  22473. }
  22474. function toISOString$1() {
  22475. // for ISO strings we do not use the normal bubbling rules:
  22476. // * milliseconds bubble up until they become hours
  22477. // * days do not bubble at all
  22478. // * months bubble up until they become years
  22479. // This is because there is no context-free conversion between hours and days
  22480. // (think of clock changes)
  22481. // and also not between days and months (28-31 days per month)
  22482. if (!this.isValid()) {
  22483. return this.localeData().invalidDate();
  22484. }
  22485. var seconds = abs$1(this._milliseconds) / 1000;
  22486. var days = abs$1(this._days);
  22487. var months = abs$1(this._months);
  22488. var minutes, hours, years;
  22489. // 3600 seconds -> 60 minutes -> 1 hour
  22490. minutes = absFloor(seconds / 60);
  22491. hours = absFloor(minutes / 60);
  22492. seconds %= 60;
  22493. minutes %= 60;
  22494. // 12 months -> 1 year
  22495. years = absFloor(months / 12);
  22496. months %= 12;
  22497. // inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
  22498. var Y = years;
  22499. var M = months;
  22500. var D = days;
  22501. var h = hours;
  22502. var m = minutes;
  22503. var s = seconds ? seconds.toFixed(3).replace(/\.?0+$/, '') : '';
  22504. var total = this.asSeconds();
  22505. if (!total) {
  22506. // this is the same as C#'s (Noda) and python (isodate)...
  22507. // but not other JS (goog.date)
  22508. return 'P0D';
  22509. }
  22510. var totalSign = total < 0 ? '-' : '';
  22511. var ymSign = sign(this._months) !== sign(total) ? '-' : '';
  22512. var daysSign = sign(this._days) !== sign(total) ? '-' : '';
  22513. var hmsSign = sign(this._milliseconds) !== sign(total) ? '-' : '';
  22514. return totalSign + 'P' +
  22515. (Y ? ymSign + Y + 'Y' : '') +
  22516. (M ? ymSign + M + 'M' : '') +
  22517. (D ? daysSign + D + 'D' : '') +
  22518. ((h || m || s) ? 'T' : '') +
  22519. (h ? hmsSign + h + 'H' : '') +
  22520. (m ? hmsSign + m + 'M' : '') +
  22521. (s ? hmsSign + s + 'S' : '');
  22522. }
  22523. var proto$2 = Duration.prototype;
  22524. proto$2.isValid = isValid$1;
  22525. proto$2.abs = abs;
  22526. proto$2.add = add$1;
  22527. proto$2.subtract = subtract$1;
  22528. proto$2.as = as;
  22529. proto$2.asMilliseconds = asMilliseconds;
  22530. proto$2.asSeconds = asSeconds;
  22531. proto$2.asMinutes = asMinutes;
  22532. proto$2.asHours = asHours;
  22533. proto$2.asDays = asDays;
  22534. proto$2.asWeeks = asWeeks;
  22535. proto$2.asMonths = asMonths;
  22536. proto$2.asYears = asYears;
  22537. proto$2.valueOf = valueOf$1;
  22538. proto$2._bubble = bubble;
  22539. proto$2.clone = clone$1;
  22540. proto$2.get = get$2;
  22541. proto$2.milliseconds = milliseconds;
  22542. proto$2.seconds = seconds;
  22543. proto$2.minutes = minutes;
  22544. proto$2.hours = hours;
  22545. proto$2.days = days;
  22546. proto$2.weeks = weeks;
  22547. proto$2.months = months;
  22548. proto$2.years = years;
  22549. proto$2.humanize = humanize;
  22550. proto$2.toISOString = toISOString$1;
  22551. proto$2.toString = toISOString$1;
  22552. proto$2.toJSON = toISOString$1;
  22553. proto$2.locale = locale;
  22554. proto$2.localeData = localeData;
  22555. // Deprecations
  22556. proto$2.toIsoString = deprecate('toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)', toISOString$1);
  22557. proto$2.lang = lang;
  22558. // Side effect imports
  22559. // FORMATTING
  22560. addFormatToken('X', 0, 0, 'unix');
  22561. addFormatToken('x', 0, 0, 'valueOf');
  22562. // PARSING
  22563. addRegexToken('x', matchSigned);
  22564. addRegexToken('X', matchTimestamp);
  22565. addParseToken('X', function (input, array, config) {
  22566. config._d = new Date(parseFloat(input, 10) * 1000);
  22567. });
  22568. addParseToken('x', function (input, array, config) {
  22569. config._d = new Date(toInt(input));
  22570. });
  22571. // Side effect imports
  22572. //! moment.js
  22573. //! version : 2.19.4
  22574. //! authors : Tim Wood, Iskren Chernev, Moment.js contributors
  22575. //! license : MIT
  22576. //! momentjs.com
  22577. hooks.version = '2.19.4';
  22578. setHookCallback(createLocal);
  22579. hooks.fn = proto;
  22580. hooks.min = min;
  22581. hooks.max = max;
  22582. hooks.now = now;
  22583. hooks.utc = createUTC;
  22584. hooks.unix = createUnix;
  22585. hooks.months = listMonths;
  22586. hooks.isDate = isDate;
  22587. hooks.locale = getSetGlobalLocale;
  22588. hooks.invalid = createInvalid;
  22589. hooks.duration = createDuration;
  22590. hooks.isMoment = isMoment;
  22591. hooks.weekdays = listWeekdays;
  22592. hooks.parseZone = createInZone;
  22593. hooks.localeData = getLocale;
  22594. hooks.isDuration = isDuration;
  22595. hooks.monthsShort = listMonthsShort;
  22596. hooks.weekdaysMin = listWeekdaysMin;
  22597. hooks.defineLocale = defineLocale;
  22598. hooks.updateLocale = updateLocale;
  22599. hooks.locales = listLocales;
  22600. hooks.weekdaysShort = listWeekdaysShort;
  22601. hooks.normalizeUnits = normalizeUnits;
  22602. hooks.relativeTimeRounding = getSetRelativeTimeRounding;
  22603. hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
  22604. hooks.calendarFormat = getCalendarFormat;
  22605. hooks.prototype = proto;
  22606. //! moment.js locale configuration
  22607. //! locale : Afrikaans [af]
  22608. //! author : Werner Mollentze : https://github.com/wernerm
  22609. hooks.defineLocale('af', {
  22610. months : 'Januarie_Februarie_Maart_April_Mei_Junie_Julie_Augustus_September_Oktober_November_Desember'.split('_'),
  22611. monthsShort : 'Jan_Feb_Mrt_Apr_Mei_Jun_Jul_Aug_Sep_Okt_Nov_Des'.split('_'),
  22612. weekdays : 'Sondag_Maandag_Dinsdag_Woensdag_Donderdag_Vrydag_Saterdag'.split('_'),
  22613. weekdaysShort : 'Son_Maa_Din_Woe_Don_Vry_Sat'.split('_'),
  22614. weekdaysMin : 'So_Ma_Di_Wo_Do_Vr_Sa'.split('_'),
  22615. meridiemParse: /vm|nm/i,
  22616. isPM : function (input) {
  22617. return /^nm$/i.test(input);
  22618. },
  22619. meridiem : function (hours, minutes, isLower) {
  22620. if (hours < 12) {
  22621. return isLower ? 'vm' : 'VM';
  22622. } else {
  22623. return isLower ? 'nm' : 'NM';
  22624. }
  22625. },
  22626. longDateFormat : {
  22627. LT : 'HH:mm',
  22628. LTS : 'HH:mm:ss',
  22629. L : 'DD/MM/YYYY',
  22630. LL : 'D MMMM YYYY',
  22631. LLL : 'D MMMM YYYY HH:mm',
  22632. LLLL : 'dddd, D MMMM YYYY HH:mm'
  22633. },
  22634. calendar : {
  22635. sameDay : '[Vandag om] LT',
  22636. nextDay : '[Môre om] LT',
  22637. nextWeek : 'dddd [om] LT',
  22638. lastDay : '[Gister om] LT',
  22639. lastWeek : '[Laas] dddd [om] LT',
  22640. sameElse : 'L'
  22641. },
  22642. relativeTime : {
  22643. future : 'oor %s',
  22644. past : '%s gelede',
  22645. s : '\'n paar sekondes',
  22646. m : '\'n minuut',
  22647. mm : '%d minute',
  22648. h : '\'n uur',
  22649. hh : '%d ure',
  22650. d : '\'n dag',
  22651. dd : '%d dae',
  22652. M : '\'n maand',
  22653. MM : '%d maande',
  22654. y : '\'n jaar',
  22655. yy : '%d jaar'
  22656. },
  22657. dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
  22658. ordinal : function (number) {
  22659. return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de'); // Thanks to Joris Röling : https://github.com/jjupiter
  22660. },
  22661. week : {
  22662. dow : 1, // Maandag is die eerste dag van die week.
  22663. doy : 4 // Die week wat die 4de Januarie bevat is die eerste week van die jaar.
  22664. }
  22665. });
  22666. //! moment.js locale configuration
  22667. //! locale : Arabic (Algeria) [ar-dz]
  22668. //! author : Noureddine LOUAHEDJ : https://github.com/noureddineme
  22669. hooks.defineLocale('ar-dz', {
  22670. months : 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  22671. monthsShort : 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  22672. weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  22673. weekdaysShort : 'احد_اثنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
  22674. weekdaysMin : 'أح_إث_ثلا_أر_خم_جم_سب'.split('_'),
  22675. weekdaysParseExact : true,
  22676. longDateFormat : {
  22677. LT : 'HH:mm',
  22678. LTS : 'HH:mm:ss',
  22679. L : 'DD/MM/YYYY',
  22680. LL : 'D MMMM YYYY',
  22681. LLL : 'D MMMM YYYY HH:mm',
  22682. LLLL : 'dddd D MMMM YYYY HH:mm'
  22683. },
  22684. calendar : {
  22685. sameDay: '[اليوم على الساعة] LT',
  22686. nextDay: '[غدا على الساعة] LT',
  22687. nextWeek: 'dddd [على الساعة] LT',
  22688. lastDay: '[أمس على الساعة] LT',
  22689. lastWeek: 'dddd [على الساعة] LT',
  22690. sameElse: 'L'
  22691. },
  22692. relativeTime : {
  22693. future : 'في %s',
  22694. past : 'منذ %s',
  22695. s : 'ثوان',
  22696. m : 'دقيقة',
  22697. mm : '%d دقائق',
  22698. h : 'ساعة',
  22699. hh : '%d ساعات',
  22700. d : 'يوم',
  22701. dd : '%d أيام',
  22702. M : 'شهر',
  22703. MM : '%d أشهر',
  22704. y : 'سنة',
  22705. yy : '%d سنوات'
  22706. },
  22707. week : {
  22708. dow : 0, // Sunday is the first day of the week.
  22709. doy : 4 // The week that contains Jan 1st is the first week of the year.
  22710. }
  22711. });
  22712. //! moment.js locale configuration
  22713. //! locale : Arabic (Kuwait) [ar-kw]
  22714. //! author : Nusret Parlak: https://github.com/nusretparlak
  22715. hooks.defineLocale('ar-kw', {
  22716. months : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
  22717. monthsShort : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
  22718. weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  22719. weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
  22720. weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  22721. weekdaysParseExact : true,
  22722. longDateFormat : {
  22723. LT : 'HH:mm',
  22724. LTS : 'HH:mm:ss',
  22725. L : 'DD/MM/YYYY',
  22726. LL : 'D MMMM YYYY',
  22727. LLL : 'D MMMM YYYY HH:mm',
  22728. LLLL : 'dddd D MMMM YYYY HH:mm'
  22729. },
  22730. calendar : {
  22731. sameDay: '[اليوم على الساعة] LT',
  22732. nextDay: '[غدا على الساعة] LT',
  22733. nextWeek: 'dddd [على الساعة] LT',
  22734. lastDay: '[أمس على الساعة] LT',
  22735. lastWeek: 'dddd [على الساعة] LT',
  22736. sameElse: 'L'
  22737. },
  22738. relativeTime : {
  22739. future : 'في %s',
  22740. past : 'منذ %s',
  22741. s : 'ثوان',
  22742. m : 'دقيقة',
  22743. mm : '%d دقائق',
  22744. h : 'ساعة',
  22745. hh : '%d ساعات',
  22746. d : 'يوم',
  22747. dd : '%d أيام',
  22748. M : 'شهر',
  22749. MM : '%d أشهر',
  22750. y : 'سنة',
  22751. yy : '%d سنوات'
  22752. },
  22753. week : {
  22754. dow : 0, // Sunday is the first day of the week.
  22755. doy : 12 // The week that contains Jan 1st is the first week of the year.
  22756. }
  22757. });
  22758. //! moment.js locale configuration
  22759. //! locale : Arabic (Lybia) [ar-ly]
  22760. //! author : Ali Hmer: https://github.com/kikoanis
  22761. var symbolMap = {
  22762. '1': '1',
  22763. '2': '2',
  22764. '3': '3',
  22765. '4': '4',
  22766. '5': '5',
  22767. '6': '6',
  22768. '7': '7',
  22769. '8': '8',
  22770. '9': '9',
  22771. '0': '0'
  22772. };
  22773. var pluralForm = function (n) {
  22774. return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
  22775. };
  22776. var plurals = {
  22777. s : ['أقل من ثانية', 'ثانية واحدة', ['ثانيتان', 'ثانيتين'], '%d ثوان', '%d ثانية', '%d ثانية'],
  22778. m : ['أقل من دقيقة', 'دقيقة واحدة', ['دقيقتان', 'دقيقتين'], '%d دقائق', '%d دقيقة', '%d دقيقة'],
  22779. h : ['أقل من ساعة', 'ساعة واحدة', ['ساعتان', 'ساعتين'], '%d ساعات', '%d ساعة', '%d ساعة'],
  22780. d : ['أقل من يوم', 'يوم واحد', ['يومان', 'يومين'], '%d أيام', '%d يومًا', '%d يوم'],
  22781. M : ['أقل من شهر', 'شهر واحد', ['شهران', 'شهرين'], '%d أشهر', '%d شهرا', '%d شهر'],
  22782. y : ['أقل من عام', 'عام واحد', ['عامان', 'عامين'], '%d أعوام', '%d عامًا', '%d عام']
  22783. };
  22784. var pluralize = function (u) {
  22785. return function (number, withoutSuffix, string, isFuture) {
  22786. var f = pluralForm(number),
  22787. str = plurals[u][pluralForm(number)];
  22788. if (f === 2) {
  22789. str = str[withoutSuffix ? 0 : 1];
  22790. }
  22791. return str.replace(/%d/i, number);
  22792. };
  22793. };
  22794. var months$1 = [
  22795. 'يناير',
  22796. 'فبراير',
  22797. 'مارس',
  22798. 'أبريل',
  22799. 'مايو',
  22800. 'يونيو',
  22801. 'يوليو',
  22802. 'أغسطس',
  22803. 'سبتمبر',
  22804. 'أكتوبر',
  22805. 'نوفمبر',
  22806. 'ديسمبر'
  22807. ];
  22808. hooks.defineLocale('ar-ly', {
  22809. months : months$1,
  22810. monthsShort : months$1,
  22811. weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  22812. weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
  22813. weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  22814. weekdaysParseExact : true,
  22815. longDateFormat : {
  22816. LT : 'HH:mm',
  22817. LTS : 'HH:mm:ss',
  22818. L : 'D/\u200FM/\u200FYYYY',
  22819. LL : 'D MMMM YYYY',
  22820. LLL : 'D MMMM YYYY HH:mm',
  22821. LLLL : 'dddd D MMMM YYYY HH:mm'
  22822. },
  22823. meridiemParse: /ص|م/,
  22824. isPM : function (input) {
  22825. return 'م' === input;
  22826. },
  22827. meridiem : function (hour, minute, isLower) {
  22828. if (hour < 12) {
  22829. return 'ص';
  22830. } else {
  22831. return 'م';
  22832. }
  22833. },
  22834. calendar : {
  22835. sameDay: '[اليوم عند الساعة] LT',
  22836. nextDay: '[غدًا عند الساعة] LT',
  22837. nextWeek: 'dddd [عند الساعة] LT',
  22838. lastDay: '[أمس عند الساعة] LT',
  22839. lastWeek: 'dddd [عند الساعة] LT',
  22840. sameElse: 'L'
  22841. },
  22842. relativeTime : {
  22843. future : 'بعد %s',
  22844. past : 'منذ %s',
  22845. s : pluralize('s'),
  22846. m : pluralize('m'),
  22847. mm : pluralize('m'),
  22848. h : pluralize('h'),
  22849. hh : pluralize('h'),
  22850. d : pluralize('d'),
  22851. dd : pluralize('d'),
  22852. M : pluralize('M'),
  22853. MM : pluralize('M'),
  22854. y : pluralize('y'),
  22855. yy : pluralize('y')
  22856. },
  22857. preparse: function (string) {
  22858. return string.replace(/،/g, ',');
  22859. },
  22860. postformat: function (string) {
  22861. return string.replace(/\d/g, function (match) {
  22862. return symbolMap[match];
  22863. }).replace(/,/g, '،');
  22864. },
  22865. week : {
  22866. dow : 6, // Saturday is the first day of the week.
  22867. doy : 12 // The week that contains Jan 1st is the first week of the year.
  22868. }
  22869. });
  22870. //! moment.js locale configuration
  22871. //! locale : Arabic (Morocco) [ar-ma]
  22872. //! author : ElFadili Yassine : https://github.com/ElFadiliY
  22873. //! author : Abdel Said : https://github.com/abdelsaid
  22874. hooks.defineLocale('ar-ma', {
  22875. months : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
  22876. monthsShort : 'يناير_فبراير_مارس_أبريل_ماي_يونيو_يوليوز_غشت_شتنبر_أكتوبر_نونبر_دجنبر'.split('_'),
  22877. weekdays : 'الأحد_الإتنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  22878. weekdaysShort : 'احد_اتنين_ثلاثاء_اربعاء_خميس_جمعة_سبت'.split('_'),
  22879. weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  22880. weekdaysParseExact : true,
  22881. longDateFormat : {
  22882. LT : 'HH:mm',
  22883. LTS : 'HH:mm:ss',
  22884. L : 'DD/MM/YYYY',
  22885. LL : 'D MMMM YYYY',
  22886. LLL : 'D MMMM YYYY HH:mm',
  22887. LLLL : 'dddd D MMMM YYYY HH:mm'
  22888. },
  22889. calendar : {
  22890. sameDay: '[اليوم على الساعة] LT',
  22891. nextDay: '[غدا على الساعة] LT',
  22892. nextWeek: 'dddd [على الساعة] LT',
  22893. lastDay: '[أمس على الساعة] LT',
  22894. lastWeek: 'dddd [على الساعة] LT',
  22895. sameElse: 'L'
  22896. },
  22897. relativeTime : {
  22898. future : 'في %s',
  22899. past : 'منذ %s',
  22900. s : 'ثوان',
  22901. m : 'دقيقة',
  22902. mm : '%d دقائق',
  22903. h : 'ساعة',
  22904. hh : '%d ساعات',
  22905. d : 'يوم',
  22906. dd : '%d أيام',
  22907. M : 'شهر',
  22908. MM : '%d أشهر',
  22909. y : 'سنة',
  22910. yy : '%d سنوات'
  22911. },
  22912. week : {
  22913. dow : 6, // Saturday is the first day of the week.
  22914. doy : 12 // The week that contains Jan 1st is the first week of the year.
  22915. }
  22916. });
  22917. //! moment.js locale configuration
  22918. //! locale : Arabic (Saudi Arabia) [ar-sa]
  22919. //! author : Suhail Alkowaileet : https://github.com/xsoh
  22920. var symbolMap$1 = {
  22921. '1': '١',
  22922. '2': '٢',
  22923. '3': '٣',
  22924. '4': '٤',
  22925. '5': '٥',
  22926. '6': '٦',
  22927. '7': '٧',
  22928. '8': '٨',
  22929. '9': '٩',
  22930. '0': '٠'
  22931. };
  22932. var numberMap = {
  22933. '١': '1',
  22934. '٢': '2',
  22935. '٣': '3',
  22936. '٤': '4',
  22937. '٥': '5',
  22938. '٦': '6',
  22939. '٧': '7',
  22940. '٨': '8',
  22941. '٩': '9',
  22942. '٠': '0'
  22943. };
  22944. hooks.defineLocale('ar-sa', {
  22945. months : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  22946. monthsShort : 'يناير_فبراير_مارس_أبريل_مايو_يونيو_يوليو_أغسطس_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  22947. weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  22948. weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
  22949. weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  22950. weekdaysParseExact : true,
  22951. longDateFormat : {
  22952. LT : 'HH:mm',
  22953. LTS : 'HH:mm:ss',
  22954. L : 'DD/MM/YYYY',
  22955. LL : 'D MMMM YYYY',
  22956. LLL : 'D MMMM YYYY HH:mm',
  22957. LLLL : 'dddd D MMMM YYYY HH:mm'
  22958. },
  22959. meridiemParse: /ص|م/,
  22960. isPM : function (input) {
  22961. return 'م' === input;
  22962. },
  22963. meridiem : function (hour, minute, isLower) {
  22964. if (hour < 12) {
  22965. return 'ص';
  22966. } else {
  22967. return 'م';
  22968. }
  22969. },
  22970. calendar : {
  22971. sameDay: '[اليوم على الساعة] LT',
  22972. nextDay: '[غدا على الساعة] LT',
  22973. nextWeek: 'dddd [على الساعة] LT',
  22974. lastDay: '[أمس على الساعة] LT',
  22975. lastWeek: 'dddd [على الساعة] LT',
  22976. sameElse: 'L'
  22977. },
  22978. relativeTime : {
  22979. future : 'في %s',
  22980. past : 'منذ %s',
  22981. s : 'ثوان',
  22982. m : 'دقيقة',
  22983. mm : '%d دقائق',
  22984. h : 'ساعة',
  22985. hh : '%d ساعات',
  22986. d : 'يوم',
  22987. dd : '%d أيام',
  22988. M : 'شهر',
  22989. MM : '%d أشهر',
  22990. y : 'سنة',
  22991. yy : '%d سنوات'
  22992. },
  22993. preparse: function (string) {
  22994. return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
  22995. return numberMap[match];
  22996. }).replace(/،/g, ',');
  22997. },
  22998. postformat: function (string) {
  22999. return string.replace(/\d/g, function (match) {
  23000. return symbolMap$1[match];
  23001. }).replace(/,/g, '،');
  23002. },
  23003. week : {
  23004. dow : 0, // Sunday is the first day of the week.
  23005. doy : 6 // The week that contains Jan 1st is the first week of the year.
  23006. }
  23007. });
  23008. //! moment.js locale configuration
  23009. //! locale : Arabic (Tunisia) [ar-tn]
  23010. //! author : Nader Toukabri : https://github.com/naderio
  23011. hooks.defineLocale('ar-tn', {
  23012. months: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  23013. monthsShort: 'جانفي_فيفري_مارس_أفريل_ماي_جوان_جويلية_أوت_سبتمبر_أكتوبر_نوفمبر_ديسمبر'.split('_'),
  23014. weekdays: 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  23015. weekdaysShort: 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
  23016. weekdaysMin: 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  23017. weekdaysParseExact : true,
  23018. longDateFormat: {
  23019. LT: 'HH:mm',
  23020. LTS: 'HH:mm:ss',
  23021. L: 'DD/MM/YYYY',
  23022. LL: 'D MMMM YYYY',
  23023. LLL: 'D MMMM YYYY HH:mm',
  23024. LLLL: 'dddd D MMMM YYYY HH:mm'
  23025. },
  23026. calendar: {
  23027. sameDay: '[اليوم على الساعة] LT',
  23028. nextDay: '[غدا على الساعة] LT',
  23029. nextWeek: 'dddd [على الساعة] LT',
  23030. lastDay: '[أمس على الساعة] LT',
  23031. lastWeek: 'dddd [على الساعة] LT',
  23032. sameElse: 'L'
  23033. },
  23034. relativeTime: {
  23035. future: 'في %s',
  23036. past: 'منذ %s',
  23037. s: 'ثوان',
  23038. m: 'دقيقة',
  23039. mm: '%d دقائق',
  23040. h: 'ساعة',
  23041. hh: '%d ساعات',
  23042. d: 'يوم',
  23043. dd: '%d أيام',
  23044. M: 'شهر',
  23045. MM: '%d أشهر',
  23046. y: 'سنة',
  23047. yy: '%d سنوات'
  23048. },
  23049. week: {
  23050. dow: 1, // Monday is the first day of the week.
  23051. doy: 4 // The week that contains Jan 4th is the first week of the year.
  23052. }
  23053. });
  23054. //! moment.js locale configuration
  23055. //! locale : Arabic [ar]
  23056. //! author : Abdel Said: https://github.com/abdelsaid
  23057. //! author : Ahmed Elkhatib
  23058. //! author : forabi https://github.com/forabi
  23059. var symbolMap$2 = {
  23060. '1': '١',
  23061. '2': '٢',
  23062. '3': '٣',
  23063. '4': '٤',
  23064. '5': '٥',
  23065. '6': '٦',
  23066. '7': '٧',
  23067. '8': '٨',
  23068. '9': '٩',
  23069. '0': '٠'
  23070. };
  23071. var numberMap$1 = {
  23072. '١': '1',
  23073. '٢': '2',
  23074. '٣': '3',
  23075. '٤': '4',
  23076. '٥': '5',
  23077. '٦': '6',
  23078. '٧': '7',
  23079. '٨': '8',
  23080. '٩': '9',
  23081. '٠': '0'
  23082. };
  23083. var pluralForm$1 = function (n) {
  23084. return n === 0 ? 0 : n === 1 ? 1 : n === 2 ? 2 : n % 100 >= 3 && n % 100 <= 10 ? 3 : n % 100 >= 11 ? 4 : 5;
  23085. };
  23086. var plurals$1 = {
  23087. s : ['أقل من ثانية', 'ثانية واحدة', ['ثانيتان', 'ثانيتين'], '%d ثوان', '%d ثانية', '%d ثانية'],
  23088. m : ['أقل من دقيقة', 'دقيقة واحدة', ['دقيقتان', 'دقيقتين'], '%d دقائق', '%d دقيقة', '%d دقيقة'],
  23089. h : ['أقل من ساعة', 'ساعة واحدة', ['ساعتان', 'ساعتين'], '%d ساعات', '%d ساعة', '%d ساعة'],
  23090. d : ['أقل من يوم', 'يوم واحد', ['يومان', 'يومين'], '%d أيام', '%d يومًا', '%d يوم'],
  23091. M : ['أقل من شهر', 'شهر واحد', ['شهران', 'شهرين'], '%d أشهر', '%d شهرا', '%d شهر'],
  23092. y : ['أقل من عام', 'عام واحد', ['عامان', 'عامين'], '%d أعوام', '%d عامًا', '%d عام']
  23093. };
  23094. var pluralize$1 = function (u) {
  23095. return function (number, withoutSuffix, string, isFuture) {
  23096. var f = pluralForm$1(number),
  23097. str = plurals$1[u][pluralForm$1(number)];
  23098. if (f === 2) {
  23099. str = str[withoutSuffix ? 0 : 1];
  23100. }
  23101. return str.replace(/%d/i, number);
  23102. };
  23103. };
  23104. var months$2 = [
  23105. 'كانون الثاني يناير',
  23106. 'شباط فبراير',
  23107. 'آذار مارس',
  23108. 'نيسان أبريل',
  23109. 'أيار مايو',
  23110. 'حزيران يونيو',
  23111. 'تموز يوليو',
  23112. 'آب أغسطس',
  23113. 'أيلول سبتمبر',
  23114. 'تشرين الأول أكتوبر',
  23115. 'تشرين الثاني نوفمبر',
  23116. 'كانون الأول ديسمبر'
  23117. ];
  23118. hooks.defineLocale('ar', {
  23119. months : months$2,
  23120. monthsShort : months$2,
  23121. weekdays : 'الأحد_الإثنين_الثلاثاء_الأربعاء_الخميس_الجمعة_السبت'.split('_'),
  23122. weekdaysShort : 'أحد_إثنين_ثلاثاء_أربعاء_خميس_جمعة_سبت'.split('_'),
  23123. weekdaysMin : 'ح_ن_ث_ر_خ_ج_س'.split('_'),
  23124. weekdaysParseExact : true,
  23125. longDateFormat : {
  23126. LT : 'HH:mm',
  23127. LTS : 'HH:mm:ss',
  23128. L : 'D/\u200FM/\u200FYYYY',
  23129. LL : 'D MMMM YYYY',
  23130. LLL : 'D MMMM YYYY HH:mm',
  23131. LLLL : 'dddd D MMMM YYYY HH:mm'
  23132. },
  23133. meridiemParse: /ص|م/,
  23134. isPM : function (input) {
  23135. return 'م' === input;
  23136. },
  23137. meridiem : function (hour, minute, isLower) {
  23138. if (hour < 12) {
  23139. return 'ص';
  23140. } else {
  23141. return 'م';
  23142. }
  23143. },
  23144. calendar : {
  23145. sameDay: '[اليوم عند الساعة] LT',
  23146. nextDay: '[غدًا عند الساعة] LT',
  23147. nextWeek: 'dddd [عند الساعة] LT',
  23148. lastDay: '[أمس عند الساعة] LT',
  23149. lastWeek: 'dddd [عند الساعة] LT',
  23150. sameElse: 'L'
  23151. },
  23152. relativeTime : {
  23153. future : 'بعد %s',
  23154. past : 'منذ %s',
  23155. s : pluralize$1('s'),
  23156. m : pluralize$1('m'),
  23157. mm : pluralize$1('m'),
  23158. h : pluralize$1('h'),
  23159. hh : pluralize$1('h'),
  23160. d : pluralize$1('d'),
  23161. dd : pluralize$1('d'),
  23162. M : pluralize$1('M'),
  23163. MM : pluralize$1('M'),
  23164. y : pluralize$1('y'),
  23165. yy : pluralize$1('y')
  23166. },
  23167. preparse: function (string) {
  23168. return string.replace(/[١٢٣٤٥٦٧٨٩٠]/g, function (match) {
  23169. return numberMap$1[match];
  23170. }).replace(/،/g, ',');
  23171. },
  23172. postformat: function (string) {
  23173. return string.replace(/\d/g, function (match) {
  23174. return symbolMap$2[match];
  23175. }).replace(/,/g, '،');
  23176. },
  23177. week : {
  23178. dow : 6, // Saturday is the first day of the week.
  23179. doy : 12 // The week that contains Jan 1st is the first week of the year.
  23180. }
  23181. });
  23182. //! moment.js locale configuration
  23183. //! locale : Azerbaijani [az]
  23184. //! author : topchiyev : https://github.com/topchiyev
  23185. var suffixes = {
  23186. 1: '-inci',
  23187. 5: '-inci',
  23188. 8: '-inci',
  23189. 70: '-inci',
  23190. 80: '-inci',
  23191. 2: '-nci',
  23192. 7: '-nci',
  23193. 20: '-nci',
  23194. 50: '-nci',
  23195. 3: '-üncü',
  23196. 4: '-üncü',
  23197. 100: '-üncü',
  23198. 6: '-ncı',
  23199. 9: '-uncu',
  23200. 10: '-uncu',
  23201. 30: '-uncu',
  23202. 60: '-ıncı',
  23203. 90: '-ıncı'
  23204. };
  23205. hooks.defineLocale('az', {
  23206. months : 'yanvar_fevral_mart_aprel_may_iyun_iyul_avqust_sentyabr_oktyabr_noyabr_dekabr'.split('_'),
  23207. monthsShort : 'yan_fev_mar_apr_may_iyn_iyl_avq_sen_okt_noy_dek'.split('_'),
  23208. weekdays : 'Bazar_Bazar ertəsi_Çərşənbə axşamı_Çərşənbə_Cümə axşamı_Cümə_Şənbə'.split('_'),
  23209. weekdaysShort : 'Baz_BzE_ÇAx_Çər_CAx_Cüm_Şən'.split('_'),
  23210. weekdaysMin : 'Bz_BE_ÇA_Çə_CA_Cü_Şə'.split('_'),
  23211. weekdaysParseExact : true,
  23212. longDateFormat : {
  23213. LT : 'HH:mm',
  23214. LTS : 'HH:mm:ss',
  23215. L : 'DD.MM.YYYY',
  23216. LL : 'D MMMM YYYY',
  23217. LLL : 'D MMMM YYYY HH:mm',
  23218. LLLL : 'dddd, D MMMM YYYY HH:mm'
  23219. },
  23220. calendar : {
  23221. sameDay : '[bugün saat] LT',
  23222. nextDay : '[sabah saat] LT',
  23223. nextWeek : '[gələn həftə] dddd [saat] LT',
  23224. lastDay : '[dünən] LT',
  23225. lastWeek : '[keçən həftə] dddd [saat] LT',
  23226. sameElse : 'L'
  23227. },
  23228. relativeTime : {
  23229. future : '%s sonra',
  23230. past : '%s əvvəl',
  23231. s : 'birneçə saniyyə',
  23232. m : 'bir dəqiqə',
  23233. mm : '%d dəqiqə',
  23234. h : 'bir saat',
  23235. hh : '%d saat',
  23236. d : 'bir gün',
  23237. dd : '%d gün',
  23238. M : 'bir ay',
  23239. MM : '%d ay',
  23240. y : 'bir il',
  23241. yy : '%d il'
  23242. },
  23243. meridiemParse: /gecə|səhər|gündüz|axşam/,
  23244. isPM : function (input) {
  23245. return /^(gündüz|axşam)$/.test(input);
  23246. },
  23247. meridiem : function (hour, minute, isLower) {
  23248. if (hour < 4) {
  23249. return 'gecə';
  23250. } else if (hour < 12) {
  23251. return 'səhər';
  23252. } else if (hour < 17) {
  23253. return 'gündüz';
  23254. } else {
  23255. return 'axşam';
  23256. }
  23257. },
  23258. dayOfMonthOrdinalParse: /\d{1,2}-(ıncı|inci|nci|üncü|ncı|uncu)/,
  23259. ordinal : function (number) {
  23260. if (number === 0) { // special case for zero
  23261. return number + '-ıncı';
  23262. }
  23263. var a = number % 10,
  23264. b = number % 100 - a,
  23265. c = number >= 100 ? 100 : null;
  23266. return number + (suffixes[a] || suffixes[b] || suffixes[c]);
  23267. },
  23268. week : {
  23269. dow : 1, // Monday is the first day of the week.
  23270. doy : 7 // The week that contains Jan 1st is the first week of the year.
  23271. }
  23272. });
  23273. //! moment.js locale configuration
  23274. //! locale : Belarusian [be]
  23275. //! author : Dmitry Demidov : https://github.com/demidov91
  23276. //! author: Praleska: http://praleska.pro/
  23277. //! Author : Menelion Elensúle : https://github.com/Oire
  23278. function plural(word, num) {
  23279. var forms = word.split('_');
  23280. return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
  23281. }
  23282. function relativeTimeWithPlural(number, withoutSuffix, key) {
  23283. var format = {
  23284. 'mm': withoutSuffix ? 'хвіліна_хвіліны_хвілін' : 'хвіліну_хвіліны_хвілін',
  23285. 'hh': withoutSuffix ? 'гадзіна_гадзіны_гадзін' : 'гадзіну_гадзіны_гадзін',
  23286. 'dd': 'дзень_дні_дзён',
  23287. 'MM': 'месяц_месяцы_месяцаў',
  23288. 'yy': 'год_гады_гадоў'
  23289. };
  23290. if (key === 'm') {
  23291. return withoutSuffix ? 'хвіліна' : 'хвіліну';
  23292. }
  23293. else if (key === 'h') {
  23294. return withoutSuffix ? 'гадзіна' : 'гадзіну';
  23295. }
  23296. else {
  23297. return number + ' ' + plural(format[key], +number);
  23298. }
  23299. }
  23300. hooks.defineLocale('be', {
  23301. months : {
  23302. format: 'студзеня_лютага_сакавіка_красавіка_траўня_чэрвеня_ліпеня_жніўня_верасня_кастрычніка_лістапада_снежня'.split('_'),
  23303. standalone: 'студзень_люты_сакавік_красавік_травень_чэрвень_ліпень_жнівень_верасень_кастрычнік_лістапад_снежань'.split('_')
  23304. },
  23305. monthsShort : 'студ_лют_сак_крас_трав_чэрв_ліп_жнів_вер_каст_ліст_снеж'.split('_'),
  23306. weekdays : {
  23307. format: 'нядзелю_панядзелак_аўторак_сераду_чацвер_пятніцу_суботу'.split('_'),
  23308. standalone: 'нядзеля_панядзелак_аўторак_серада_чацвер_пятніца_субота'.split('_'),
  23309. isFormat: /\[ ?[Вв] ?(?:мінулую|наступную)? ?\] ?dddd/
  23310. },
  23311. weekdaysShort : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
  23312. weekdaysMin : 'нд_пн_ат_ср_чц_пт_сб'.split('_'),
  23313. longDateFormat : {
  23314. LT : 'HH:mm',
  23315. LTS : 'HH:mm:ss',
  23316. L : 'DD.MM.YYYY',
  23317. LL : 'D MMMM YYYY г.',
  23318. LLL : 'D MMMM YYYY г., HH:mm',
  23319. LLLL : 'dddd, D MMMM YYYY г., HH:mm'
  23320. },
  23321. calendar : {
  23322. sameDay: '[Сёння ў] LT',
  23323. nextDay: '[Заўтра ў] LT',
  23324. lastDay: '[Учора ў] LT',
  23325. nextWeek: function () {
  23326. return '[У] dddd [ў] LT';
  23327. },
  23328. lastWeek: function () {
  23329. switch (this.day()) {
  23330. case 0:
  23331. case 3:
  23332. case 5:
  23333. case 6:
  23334. return '[У мінулую] dddd [ў] LT';
  23335. case 1:
  23336. case 2:
  23337. case 4:
  23338. return '[У мінулы] dddd [ў] LT';
  23339. }
  23340. },
  23341. sameElse: 'L'
  23342. },
  23343. relativeTime : {
  23344. future : 'праз %s',
  23345. past : '%s таму',
  23346. s : 'некалькі секунд',
  23347. m : relativeTimeWithPlural,
  23348. mm : relativeTimeWithPlural,
  23349. h : relativeTimeWithPlural,
  23350. hh : relativeTimeWithPlural,
  23351. d : 'дзень',
  23352. dd : relativeTimeWithPlural,
  23353. M : 'месяц',
  23354. MM : relativeTimeWithPlural,
  23355. y : 'год',
  23356. yy : relativeTimeWithPlural
  23357. },
  23358. meridiemParse: /ночы|раніцы|дня|вечара/,
  23359. isPM : function (input) {
  23360. return /^(дня|вечара)$/.test(input);
  23361. },
  23362. meridiem : function (hour, minute, isLower) {
  23363. if (hour < 4) {
  23364. return 'ночы';
  23365. } else if (hour < 12) {
  23366. return 'раніцы';
  23367. } else if (hour < 17) {
  23368. return 'дня';
  23369. } else {
  23370. return 'вечара';
  23371. }
  23372. },
  23373. dayOfMonthOrdinalParse: /\d{1,2}-(і|ы|га)/,
  23374. ordinal: function (number, period) {
  23375. switch (period) {
  23376. case 'M':
  23377. case 'd':
  23378. case 'DDD':
  23379. case 'w':
  23380. case 'W':
  23381. return (number % 10 === 2 || number % 10 === 3) && (number % 100 !== 12 && number % 100 !== 13) ? number + '-і' : number + '-ы';
  23382. case 'D':
  23383. return number + '-га';
  23384. default:
  23385. return number;
  23386. }
  23387. },
  23388. week : {
  23389. dow : 1, // Monday is the first day of the week.
  23390. doy : 7 // The week that contains Jan 1st is the first week of the year.
  23391. }
  23392. });
  23393. //! moment.js locale configuration
  23394. //! locale : Bulgarian [bg]
  23395. //! author : Krasen Borisov : https://github.com/kraz
  23396. hooks.defineLocale('bg', {
  23397. months : 'януари_февруари_март_април_май_юни_юли_август_септември_октомври_ноември_декември'.split('_'),
  23398. monthsShort : 'янр_фев_мар_апр_май_юни_юли_авг_сеп_окт_ное_дек'.split('_'),
  23399. weekdays : 'неделя_понеделник_вторник_сряда_четвъртък_петък_събота'.split('_'),
  23400. weekdaysShort : 'нед_пон_вто_сря_чет_пет_съб'.split('_'),
  23401. weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
  23402. longDateFormat : {
  23403. LT : 'H:mm',
  23404. LTS : 'H:mm:ss',
  23405. L : 'D.MM.YYYY',
  23406. LL : 'D MMMM YYYY',
  23407. LLL : 'D MMMM YYYY H:mm',
  23408. LLLL : 'dddd, D MMMM YYYY H:mm'
  23409. },
  23410. calendar : {
  23411. sameDay : '[Днес в] LT',
  23412. nextDay : '[Утре в] LT',
  23413. nextWeek : 'dddd [в] LT',
  23414. lastDay : '[Вчера в] LT',
  23415. lastWeek : function () {
  23416. switch (this.day()) {
  23417. case 0:
  23418. case 3:
  23419. case 6:
  23420. return '[В изминалата] dddd [в] LT';
  23421. case 1:
  23422. case 2:
  23423. case 4:
  23424. case 5:
  23425. return '[В изминалия] dddd [в] LT';
  23426. }
  23427. },
  23428. sameElse : 'L'
  23429. },
  23430. relativeTime : {
  23431. future : 'след %s',
  23432. past : 'преди %s',
  23433. s : 'няколко секунди',
  23434. m : 'минута',
  23435. mm : '%d минути',
  23436. h : 'час',
  23437. hh : '%d часа',
  23438. d : 'ден',
  23439. dd : '%d дни',
  23440. M : 'месец',
  23441. MM : '%d месеца',
  23442. y : 'година',
  23443. yy : '%d години'
  23444. },
  23445. dayOfMonthOrdinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
  23446. ordinal : function (number) {
  23447. var lastDigit = number % 10,
  23448. last2Digits = number % 100;
  23449. if (number === 0) {
  23450. return number + '-ев';
  23451. } else if (last2Digits === 0) {
  23452. return number + '-ен';
  23453. } else if (last2Digits > 10 && last2Digits < 20) {
  23454. return number + '-ти';
  23455. } else if (lastDigit === 1) {
  23456. return number + '-ви';
  23457. } else if (lastDigit === 2) {
  23458. return number + '-ри';
  23459. } else if (lastDigit === 7 || lastDigit === 8) {
  23460. return number + '-ми';
  23461. } else {
  23462. return number + '-ти';
  23463. }
  23464. },
  23465. week : {
  23466. dow : 1, // Monday is the first day of the week.
  23467. doy : 7 // The week that contains Jan 1st is the first week of the year.
  23468. }
  23469. });
  23470. //! moment.js locale configuration
  23471. //! locale : Bambara [bm]
  23472. //! author : Estelle Comment : https://github.com/estellecomment
  23473. // Language contact person : Abdoufata Kane : https://github.com/abdoufata
  23474. hooks.defineLocale('bm', {
  23475. months : 'Zanwuyekalo_Fewuruyekalo_Marisikalo_Awirilikalo_Mɛkalo_Zuwɛnkalo_Zuluyekalo_Utikalo_Sɛtanburukalo_ɔkutɔburukalo_Nowanburukalo_Desanburukalo'.split('_'),
  23476. monthsShort : 'Zan_Few_Mar_Awi_Mɛ_Zuw_Zul_Uti_Sɛt_ɔku_Now_Des'.split('_'),
  23477. weekdays : 'Kari_Ntɛnɛn_Tarata_Araba_Alamisa_Juma_Sibiri'.split('_'),
  23478. weekdaysShort : 'Kar_Ntɛ_Tar_Ara_Ala_Jum_Sib'.split('_'),
  23479. weekdaysMin : 'Ka_Nt_Ta_Ar_Al_Ju_Si'.split('_'),
  23480. longDateFormat : {
  23481. LT : 'HH:mm',
  23482. LTS : 'HH:mm:ss',
  23483. L : 'DD/MM/YYYY',
  23484. LL : 'MMMM [tile] D [san] YYYY',
  23485. LLL : 'MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm',
  23486. LLLL : 'dddd MMMM [tile] D [san] YYYY [lɛrɛ] HH:mm'
  23487. },
  23488. calendar : {
  23489. sameDay : '[Bi lɛrɛ] LT',
  23490. nextDay : '[Sini lɛrɛ] LT',
  23491. nextWeek : 'dddd [don lɛrɛ] LT',
  23492. lastDay : '[Kunu lɛrɛ] LT',
  23493. lastWeek : 'dddd [tɛmɛnen lɛrɛ] LT',
  23494. sameElse : 'L'
  23495. },
  23496. relativeTime : {
  23497. future : '%s kɔnɔ',
  23498. past : 'a bɛ %s bɔ',
  23499. s : 'sanga dama dama',
  23500. m : 'miniti kelen',
  23501. mm : 'miniti %d',
  23502. h : 'lɛrɛ kelen',
  23503. hh : 'lɛrɛ %d',
  23504. d : 'tile kelen',
  23505. dd : 'tile %d',
  23506. M : 'kalo kelen',
  23507. MM : 'kalo %d',
  23508. y : 'san kelen',
  23509. yy : 'san %d'
  23510. },
  23511. week : {
  23512. dow : 1, // Monday is the first day of the week.
  23513. doy : 4 // The week that contains Jan 4th is the first week of the year.
  23514. }
  23515. });
  23516. //! moment.js locale configuration
  23517. //! locale : Bengali [bn]
  23518. //! author : Kaushik Gandhi : https://github.com/kaushikgandhi
  23519. var symbolMap$3 = {
  23520. '1': '১',
  23521. '2': '২',
  23522. '3': '৩',
  23523. '4': '৪',
  23524. '5': '৫',
  23525. '6': '৬',
  23526. '7': '৭',
  23527. '8': '৮',
  23528. '9': '৯',
  23529. '0': '০'
  23530. };
  23531. var numberMap$2 = {
  23532. '১': '1',
  23533. '২': '2',
  23534. '৩': '3',
  23535. '৪': '4',
  23536. '৫': '5',
  23537. '৬': '6',
  23538. '৭': '7',
  23539. '৮': '8',
  23540. '৯': '9',
  23541. '০': '0'
  23542. };
  23543. hooks.defineLocale('bn', {
  23544. months : 'জানুয়ারী_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'),
  23545. monthsShort : 'জানু_ফেব_মার্চ_এপ্র_মে_জুন_জুল_আগ_সেপ্ট_অক্টো_নভে_ডিসে'.split('_'),
  23546. weekdays : 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার'.split('_'),
  23547. weekdaysShort : 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি'.split('_'),
  23548. weekdaysMin : 'রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি'.split('_'),
  23549. longDateFormat : {
  23550. LT : 'A h:mm সময়',
  23551. LTS : 'A h:mm:ss সময়',
  23552. L : 'DD/MM/YYYY',
  23553. LL : 'D MMMM YYYY',
  23554. LLL : 'D MMMM YYYY, A h:mm সময়',
  23555. LLLL : 'dddd, D MMMM YYYY, A h:mm সময়'
  23556. },
  23557. calendar : {
  23558. sameDay : '[আজ] LT',
  23559. nextDay : '[আগামীকাল] LT',
  23560. nextWeek : 'dddd, LT',
  23561. lastDay : '[গতকাল] LT',
  23562. lastWeek : '[গত] dddd, LT',
  23563. sameElse : 'L'
  23564. },
  23565. relativeTime : {
  23566. future : '%s পরে',
  23567. past : '%s আগে',
  23568. s : 'কয়েক সেকেন্ড',
  23569. m : 'এক মিনিট',
  23570. mm : '%d মিনিট',
  23571. h : 'এক ঘন্টা',
  23572. hh : '%d ঘন্টা',
  23573. d : 'এক দিন',
  23574. dd : '%d দিন',
  23575. M : 'এক মাস',
  23576. MM : '%d মাস',
  23577. y : 'এক বছর',
  23578. yy : '%d বছর'
  23579. },
  23580. preparse: function (string) {
  23581. return string.replace(/[১২৩৪৫৬৭৮৯০]/g, function (match) {
  23582. return numberMap$2[match];
  23583. });
  23584. },
  23585. postformat: function (string) {
  23586. return string.replace(/\d/g, function (match) {
  23587. return symbolMap$3[match];
  23588. });
  23589. },
  23590. meridiemParse: /রাত|সকাল|দুপুর|বিকাল|রাত/,
  23591. meridiemHour : function (hour, meridiem) {
  23592. if (hour === 12) {
  23593. hour = 0;
  23594. }
  23595. if ((meridiem === 'রাত' && hour >= 4) ||
  23596. (meridiem === 'দুপুর' && hour < 5) ||
  23597. meridiem === 'বিকাল') {
  23598. return hour + 12;
  23599. } else {
  23600. return hour;
  23601. }
  23602. },
  23603. meridiem : function (hour, minute, isLower) {
  23604. if (hour < 4) {
  23605. return 'রাত';
  23606. } else if (hour < 10) {
  23607. return 'সকাল';
  23608. } else if (hour < 17) {
  23609. return 'দুপুর';
  23610. } else if (hour < 20) {
  23611. return 'বিকাল';
  23612. } else {
  23613. return 'রাত';
  23614. }
  23615. },
  23616. week : {
  23617. dow : 0, // Sunday is the first day of the week.
  23618. doy : 6 // The week that contains Jan 1st is the first week of the year.
  23619. }
  23620. });
  23621. //! moment.js locale configuration
  23622. //! locale : Tibetan [bo]
  23623. //! author : Thupten N. Chakrishar : https://github.com/vajradog
  23624. var symbolMap$4 = {
  23625. '1': '༡',
  23626. '2': '༢',
  23627. '3': '༣',
  23628. '4': '༤',
  23629. '5': '༥',
  23630. '6': '༦',
  23631. '7': '༧',
  23632. '8': '༨',
  23633. '9': '༩',
  23634. '0': '༠'
  23635. };
  23636. var numberMap$3 = {
  23637. '༡': '1',
  23638. '༢': '2',
  23639. '༣': '3',
  23640. '༤': '4',
  23641. '༥': '5',
  23642. '༦': '6',
  23643. '༧': '7',
  23644. '༨': '8',
  23645. '༩': '9',
  23646. '༠': '0'
  23647. };
  23648. hooks.defineLocale('bo', {
  23649. months : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
  23650. monthsShort : 'ཟླ་བ་དང་པོ_ཟླ་བ་གཉིས་པ_ཟླ་བ་གསུམ་པ_ཟླ་བ་བཞི་པ_ཟླ་བ་ལྔ་པ_ཟླ་བ་དྲུག་པ_ཟླ་བ་བདུན་པ_ཟླ་བ་བརྒྱད་པ_ཟླ་བ་དགུ་པ_ཟླ་བ་བཅུ་པ_ཟླ་བ་བཅུ་གཅིག་པ_ཟླ་བ་བཅུ་གཉིས་པ'.split('_'),
  23651. weekdays : 'གཟའ་ཉི་མ་_གཟའ་ཟླ་བ་_གཟའ་མིག་དམར་_གཟའ་ལྷག་པ་_གཟའ་ཕུར་བུ_གཟའ་པ་སངས་_གཟའ་སྤེན་པ་'.split('_'),
  23652. weekdaysShort : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
  23653. weekdaysMin : 'ཉི་མ་_ཟླ་བ་_མིག་དམར་_ལྷག་པ་_ཕུར་བུ_པ་སངས་_སྤེན་པ་'.split('_'),
  23654. longDateFormat : {
  23655. LT : 'A h:mm',
  23656. LTS : 'A h:mm:ss',
  23657. L : 'DD/MM/YYYY',
  23658. LL : 'D MMMM YYYY',
  23659. LLL : 'D MMMM YYYY, A h:mm',
  23660. LLLL : 'dddd, D MMMM YYYY, A h:mm'
  23661. },
  23662. calendar : {
  23663. sameDay : '[དི་རིང] LT',
  23664. nextDay : '[སང་ཉིན] LT',
  23665. nextWeek : '[བདུན་ཕྲག་རྗེས་མ], LT',
  23666. lastDay : '[ཁ་སང] LT',
  23667. lastWeek : '[བདུན་ཕྲག་མཐའ་མ] dddd, LT',
  23668. sameElse : 'L'
  23669. },
  23670. relativeTime : {
  23671. future : '%s ལ་',
  23672. past : '%s སྔན་ལ',
  23673. s : 'ལམ་སང',
  23674. m : 'སྐར་མ་གཅིག',
  23675. mm : '%d སྐར་མ',
  23676. h : 'ཆུ་ཚོད་གཅིག',
  23677. hh : '%d ཆུ་ཚོད',
  23678. d : 'ཉིན་གཅིག',
  23679. dd : '%d ཉིན་',
  23680. M : 'ཟླ་བ་གཅིག',
  23681. MM : '%d ཟླ་བ',
  23682. y : 'ལོ་གཅིག',
  23683. yy : '%d ལོ'
  23684. },
  23685. preparse: function (string) {
  23686. return string.replace(/[༡༢༣༤༥༦༧༨༩༠]/g, function (match) {
  23687. return numberMap$3[match];
  23688. });
  23689. },
  23690. postformat: function (string) {
  23691. return string.replace(/\d/g, function (match) {
  23692. return symbolMap$4[match];
  23693. });
  23694. },
  23695. meridiemParse: /མཚན་མོ|ཞོགས་ཀས|ཉིན་གུང|དགོང་དག|མཚན་མོ/,
  23696. meridiemHour : function (hour, meridiem) {
  23697. if (hour === 12) {
  23698. hour = 0;
  23699. }
  23700. if ((meridiem === 'མཚན་མོ' && hour >= 4) ||
  23701. (meridiem === 'ཉིན་གུང' && hour < 5) ||
  23702. meridiem === 'དགོང་དག') {
  23703. return hour + 12;
  23704. } else {
  23705. return hour;
  23706. }
  23707. },
  23708. meridiem : function (hour, minute, isLower) {
  23709. if (hour < 4) {
  23710. return 'མཚན་མོ';
  23711. } else if (hour < 10) {
  23712. return 'ཞོགས་ཀས';
  23713. } else if (hour < 17) {
  23714. return 'ཉིན་གུང';
  23715. } else if (hour < 20) {
  23716. return 'དགོང་དག';
  23717. } else {
  23718. return 'མཚན་མོ';
  23719. }
  23720. },
  23721. week : {
  23722. dow : 0, // Sunday is the first day of the week.
  23723. doy : 6 // The week that contains Jan 1st is the first week of the year.
  23724. }
  23725. });
  23726. //! moment.js locale configuration
  23727. //! locale : Breton [br]
  23728. //! author : Jean-Baptiste Le Duigou : https://github.com/jbleduigou
  23729. function relativeTimeWithMutation(number, withoutSuffix, key) {
  23730. var format = {
  23731. 'mm': 'munutenn',
  23732. 'MM': 'miz',
  23733. 'dd': 'devezh'
  23734. };
  23735. return number + ' ' + mutation(format[key], number);
  23736. }
  23737. function specialMutationForYears(number) {
  23738. switch (lastNumber(number)) {
  23739. case 1:
  23740. case 3:
  23741. case 4:
  23742. case 5:
  23743. case 9:
  23744. return number + ' bloaz';
  23745. default:
  23746. return number + ' vloaz';
  23747. }
  23748. }
  23749. function lastNumber(number) {
  23750. if (number > 9) {
  23751. return lastNumber(number % 10);
  23752. }
  23753. return number;
  23754. }
  23755. function mutation(text, number) {
  23756. if (number === 2) {
  23757. return softMutation(text);
  23758. }
  23759. return text;
  23760. }
  23761. function softMutation(text) {
  23762. var mutationTable = {
  23763. 'm': 'v',
  23764. 'b': 'v',
  23765. 'd': 'z'
  23766. };
  23767. if (mutationTable[text.charAt(0)] === undefined) {
  23768. return text;
  23769. }
  23770. return mutationTable[text.charAt(0)] + text.substring(1);
  23771. }
  23772. hooks.defineLocale('br', {
  23773. months : 'Genver_C\'hwevrer_Meurzh_Ebrel_Mae_Mezheven_Gouere_Eost_Gwengolo_Here_Du_Kerzu'.split('_'),
  23774. monthsShort : 'Gen_C\'hwe_Meu_Ebr_Mae_Eve_Gou_Eos_Gwe_Her_Du_Ker'.split('_'),
  23775. weekdays : 'Sul_Lun_Meurzh_Merc\'her_Yaou_Gwener_Sadorn'.split('_'),
  23776. weekdaysShort : 'Sul_Lun_Meu_Mer_Yao_Gwe_Sad'.split('_'),
  23777. weekdaysMin : 'Su_Lu_Me_Mer_Ya_Gw_Sa'.split('_'),
  23778. weekdaysParseExact : true,
  23779. longDateFormat : {
  23780. LT : 'h[e]mm A',
  23781. LTS : 'h[e]mm:ss A',
  23782. L : 'DD/MM/YYYY',
  23783. LL : 'D [a viz] MMMM YYYY',
  23784. LLL : 'D [a viz] MMMM YYYY h[e]mm A',
  23785. LLLL : 'dddd, D [a viz] MMMM YYYY h[e]mm A'
  23786. },
  23787. calendar : {
  23788. sameDay : '[Hiziv da] LT',
  23789. nextDay : '[Warc\'hoazh da] LT',
  23790. nextWeek : 'dddd [da] LT',
  23791. lastDay : '[Dec\'h da] LT',
  23792. lastWeek : 'dddd [paset da] LT',
  23793. sameElse : 'L'
  23794. },
  23795. relativeTime : {
  23796. future : 'a-benn %s',
  23797. past : '%s \'zo',
  23798. s : 'un nebeud segondennoù',
  23799. m : 'ur vunutenn',
  23800. mm : relativeTimeWithMutation,
  23801. h : 'un eur',
  23802. hh : '%d eur',
  23803. d : 'un devezh',
  23804. dd : relativeTimeWithMutation,
  23805. M : 'ur miz',
  23806. MM : relativeTimeWithMutation,
  23807. y : 'ur bloaz',
  23808. yy : specialMutationForYears
  23809. },
  23810. dayOfMonthOrdinalParse: /\d{1,2}(añ|vet)/,
  23811. ordinal : function (number) {
  23812. var output = (number === 1) ? 'añ' : 'vet';
  23813. return number + output;
  23814. },
  23815. week : {
  23816. dow : 1, // Monday is the first day of the week.
  23817. doy : 4 // The week that contains Jan 4th is the first week of the year.
  23818. }
  23819. });
  23820. //! moment.js locale configuration
  23821. //! locale : Bosnian [bs]
  23822. //! author : Nedim Cholich : https://github.com/frontyard
  23823. //! based on (hr) translation by Bojan Marković
  23824. function translate(number, withoutSuffix, key) {
  23825. var result = number + ' ';
  23826. switch (key) {
  23827. case 'm':
  23828. return withoutSuffix ? 'jedna minuta' : 'jedne minute';
  23829. case 'mm':
  23830. if (number === 1) {
  23831. result += 'minuta';
  23832. } else if (number === 2 || number === 3 || number === 4) {
  23833. result += 'minute';
  23834. } else {
  23835. result += 'minuta';
  23836. }
  23837. return result;
  23838. case 'h':
  23839. return withoutSuffix ? 'jedan sat' : 'jednog sata';
  23840. case 'hh':
  23841. if (number === 1) {
  23842. result += 'sat';
  23843. } else if (number === 2 || number === 3 || number === 4) {
  23844. result += 'sata';
  23845. } else {
  23846. result += 'sati';
  23847. }
  23848. return result;
  23849. case 'dd':
  23850. if (number === 1) {
  23851. result += 'dan';
  23852. } else {
  23853. result += 'dana';
  23854. }
  23855. return result;
  23856. case 'MM':
  23857. if (number === 1) {
  23858. result += 'mjesec';
  23859. } else if (number === 2 || number === 3 || number === 4) {
  23860. result += 'mjeseca';
  23861. } else {
  23862. result += 'mjeseci';
  23863. }
  23864. return result;
  23865. case 'yy':
  23866. if (number === 1) {
  23867. result += 'godina';
  23868. } else if (number === 2 || number === 3 || number === 4) {
  23869. result += 'godine';
  23870. } else {
  23871. result += 'godina';
  23872. }
  23873. return result;
  23874. }
  23875. }
  23876. hooks.defineLocale('bs', {
  23877. months : 'januar_februar_mart_april_maj_juni_juli_august_septembar_oktobar_novembar_decembar'.split('_'),
  23878. monthsShort : 'jan._feb._mar._apr._maj._jun._jul._aug._sep._okt._nov._dec.'.split('_'),
  23879. monthsParseExact: true,
  23880. weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
  23881. weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
  23882. weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
  23883. weekdaysParseExact : true,
  23884. longDateFormat : {
  23885. LT : 'H:mm',
  23886. LTS : 'H:mm:ss',
  23887. L : 'DD.MM.YYYY',
  23888. LL : 'D. MMMM YYYY',
  23889. LLL : 'D. MMMM YYYY H:mm',
  23890. LLLL : 'dddd, D. MMMM YYYY H:mm'
  23891. },
  23892. calendar : {
  23893. sameDay : '[danas u] LT',
  23894. nextDay : '[sutra u] LT',
  23895. nextWeek : function () {
  23896. switch (this.day()) {
  23897. case 0:
  23898. return '[u] [nedjelju] [u] LT';
  23899. case 3:
  23900. return '[u] [srijedu] [u] LT';
  23901. case 6:
  23902. return '[u] [subotu] [u] LT';
  23903. case 1:
  23904. case 2:
  23905. case 4:
  23906. case 5:
  23907. return '[u] dddd [u] LT';
  23908. }
  23909. },
  23910. lastDay : '[jučer u] LT',
  23911. lastWeek : function () {
  23912. switch (this.day()) {
  23913. case 0:
  23914. case 3:
  23915. return '[prošlu] dddd [u] LT';
  23916. case 6:
  23917. return '[prošle] [subote] [u] LT';
  23918. case 1:
  23919. case 2:
  23920. case 4:
  23921. case 5:
  23922. return '[prošli] dddd [u] LT';
  23923. }
  23924. },
  23925. sameElse : 'L'
  23926. },
  23927. relativeTime : {
  23928. future : 'za %s',
  23929. past : 'prije %s',
  23930. s : 'par sekundi',
  23931. m : translate,
  23932. mm : translate,
  23933. h : translate,
  23934. hh : translate,
  23935. d : 'dan',
  23936. dd : translate,
  23937. M : 'mjesec',
  23938. MM : translate,
  23939. y : 'godinu',
  23940. yy : translate
  23941. },
  23942. dayOfMonthOrdinalParse: /\d{1,2}\./,
  23943. ordinal : '%d.',
  23944. week : {
  23945. dow : 1, // Monday is the first day of the week.
  23946. doy : 7 // The week that contains Jan 1st is the first week of the year.
  23947. }
  23948. });
  23949. //! moment.js locale configuration
  23950. //! locale : Catalan [ca]
  23951. //! author : Juan G. Hurtado : https://github.com/juanghurtado
  23952. hooks.defineLocale('ca', {
  23953. months : {
  23954. standalone: 'gener_febrer_març_abril_maig_juny_juliol_agost_setembre_octubre_novembre_desembre'.split('_'),
  23955. format: 'de gener_de febrer_de març_d\'abril_de maig_de juny_de juliol_d\'agost_de setembre_d\'octubre_de novembre_de desembre'.split('_'),
  23956. isFormat: /D[oD]?(\s)+MMMM/
  23957. },
  23958. monthsShort : 'gen._febr._març_abr._maig_juny_jul._ag._set._oct._nov._des.'.split('_'),
  23959. monthsParseExact : true,
  23960. weekdays : 'diumenge_dilluns_dimarts_dimecres_dijous_divendres_dissabte'.split('_'),
  23961. weekdaysShort : 'dg._dl._dt._dc._dj._dv._ds.'.split('_'),
  23962. weekdaysMin : 'dg_dl_dt_dc_dj_dv_ds'.split('_'),
  23963. weekdaysParseExact : true,
  23964. longDateFormat : {
  23965. LT : 'H:mm',
  23966. LTS : 'H:mm:ss',
  23967. L : 'DD/MM/YYYY',
  23968. LL : 'D MMMM [de] YYYY',
  23969. ll : 'D MMM YYYY',
  23970. LLL : 'D MMMM [de] YYYY [a les] H:mm',
  23971. lll : 'D MMM YYYY, H:mm',
  23972. LLLL : 'dddd D MMMM [de] YYYY [a les] H:mm',
  23973. llll : 'ddd D MMM YYYY, H:mm'
  23974. },
  23975. calendar : {
  23976. sameDay : function () {
  23977. return '[avui a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
  23978. },
  23979. nextDay : function () {
  23980. return '[demà a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
  23981. },
  23982. nextWeek : function () {
  23983. return 'dddd [a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
  23984. },
  23985. lastDay : function () {
  23986. return '[ahir a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
  23987. },
  23988. lastWeek : function () {
  23989. return '[el] dddd [passat a ' + ((this.hours() !== 1) ? 'les' : 'la') + '] LT';
  23990. },
  23991. sameElse : 'L'
  23992. },
  23993. relativeTime : {
  23994. future : 'd\'aquí %s',
  23995. past : 'fa %s',
  23996. s : 'uns segons',
  23997. m : 'un minut',
  23998. mm : '%d minuts',
  23999. h : 'una hora',
  24000. hh : '%d hores',
  24001. d : 'un dia',
  24002. dd : '%d dies',
  24003. M : 'un mes',
  24004. MM : '%d mesos',
  24005. y : 'un any',
  24006. yy : '%d anys'
  24007. },
  24008. dayOfMonthOrdinalParse: /\d{1,2}(r|n|t|è|a)/,
  24009. ordinal : function (number, period) {
  24010. var output = (number === 1) ? 'r' :
  24011. (number === 2) ? 'n' :
  24012. (number === 3) ? 'r' :
  24013. (number === 4) ? 't' : 'è';
  24014. if (period === 'w' || period === 'W') {
  24015. output = 'a';
  24016. }
  24017. return number + output;
  24018. },
  24019. week : {
  24020. dow : 1, // Monday is the first day of the week.
  24021. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24022. }
  24023. });
  24024. //! moment.js locale configuration
  24025. //! locale : Czech [cs]
  24026. //! author : petrbela : https://github.com/petrbela
  24027. var months$3 = 'leden_únor_březen_duben_květen_červen_červenec_srpen_září_říjen_listopad_prosinec'.split('_');
  24028. var monthsShort = 'led_úno_bře_dub_kvě_čvn_čvc_srp_zář_říj_lis_pro'.split('_');
  24029. function plural$1(n) {
  24030. return (n > 1) && (n < 5) && (~~(n / 10) !== 1);
  24031. }
  24032. function translate$1(number, withoutSuffix, key, isFuture) {
  24033. var result = number + ' ';
  24034. switch (key) {
  24035. case 's': // a few seconds / in a few seconds / a few seconds ago
  24036. return (withoutSuffix || isFuture) ? 'pár sekund' : 'pár sekundami';
  24037. case 'm': // a minute / in a minute / a minute ago
  24038. return withoutSuffix ? 'minuta' : (isFuture ? 'minutu' : 'minutou');
  24039. case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
  24040. if (withoutSuffix || isFuture) {
  24041. return result + (plural$1(number) ? 'minuty' : 'minut');
  24042. } else {
  24043. return result + 'minutami';
  24044. }
  24045. break;
  24046. case 'h': // an hour / in an hour / an hour ago
  24047. return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
  24048. case 'hh': // 9 hours / in 9 hours / 9 hours ago
  24049. if (withoutSuffix || isFuture) {
  24050. return result + (plural$1(number) ? 'hodiny' : 'hodin');
  24051. } else {
  24052. return result + 'hodinami';
  24053. }
  24054. break;
  24055. case 'd': // a day / in a day / a day ago
  24056. return (withoutSuffix || isFuture) ? 'den' : 'dnem';
  24057. case 'dd': // 9 days / in 9 days / 9 days ago
  24058. if (withoutSuffix || isFuture) {
  24059. return result + (plural$1(number) ? 'dny' : 'dní');
  24060. } else {
  24061. return result + 'dny';
  24062. }
  24063. break;
  24064. case 'M': // a month / in a month / a month ago
  24065. return (withoutSuffix || isFuture) ? 'měsíc' : 'měsícem';
  24066. case 'MM': // 9 months / in 9 months / 9 months ago
  24067. if (withoutSuffix || isFuture) {
  24068. return result + (plural$1(number) ? 'měsíce' : 'měsíců');
  24069. } else {
  24070. return result + 'měsíci';
  24071. }
  24072. break;
  24073. case 'y': // a year / in a year / a year ago
  24074. return (withoutSuffix || isFuture) ? 'rok' : 'rokem';
  24075. case 'yy': // 9 years / in 9 years / 9 years ago
  24076. if (withoutSuffix || isFuture) {
  24077. return result + (plural$1(number) ? 'roky' : 'let');
  24078. } else {
  24079. return result + 'lety';
  24080. }
  24081. break;
  24082. }
  24083. }
  24084. hooks.defineLocale('cs', {
  24085. months : months$3,
  24086. monthsShort : monthsShort,
  24087. monthsParse : (function (months, monthsShort) {
  24088. var i, _monthsParse = [];
  24089. for (i = 0; i < 12; i++) {
  24090. // use custom parser to solve problem with July (červenec)
  24091. _monthsParse[i] = new RegExp('^' + months[i] + '$|^' + monthsShort[i] + '$', 'i');
  24092. }
  24093. return _monthsParse;
  24094. }(months$3, monthsShort)),
  24095. shortMonthsParse : (function (monthsShort) {
  24096. var i, _shortMonthsParse = [];
  24097. for (i = 0; i < 12; i++) {
  24098. _shortMonthsParse[i] = new RegExp('^' + monthsShort[i] + '$', 'i');
  24099. }
  24100. return _shortMonthsParse;
  24101. }(monthsShort)),
  24102. longMonthsParse : (function (months) {
  24103. var i, _longMonthsParse = [];
  24104. for (i = 0; i < 12; i++) {
  24105. _longMonthsParse[i] = new RegExp('^' + months[i] + '$', 'i');
  24106. }
  24107. return _longMonthsParse;
  24108. }(months$3)),
  24109. weekdays : 'neděle_pondělí_úterý_středa_čtvrtek_pátek_sobota'.split('_'),
  24110. weekdaysShort : 'ne_po_út_st_čt_pá_so'.split('_'),
  24111. weekdaysMin : 'ne_po_út_st_čt_pá_so'.split('_'),
  24112. longDateFormat : {
  24113. LT: 'H:mm',
  24114. LTS : 'H:mm:ss',
  24115. L : 'DD.MM.YYYY',
  24116. LL : 'D. MMMM YYYY',
  24117. LLL : 'D. MMMM YYYY H:mm',
  24118. LLLL : 'dddd D. MMMM YYYY H:mm',
  24119. l : 'D. M. YYYY'
  24120. },
  24121. calendar : {
  24122. sameDay: '[dnes v] LT',
  24123. nextDay: '[zítra v] LT',
  24124. nextWeek: function () {
  24125. switch (this.day()) {
  24126. case 0:
  24127. return '[v neděli v] LT';
  24128. case 1:
  24129. case 2:
  24130. return '[v] dddd [v] LT';
  24131. case 3:
  24132. return '[ve středu v] LT';
  24133. case 4:
  24134. return '[ve čtvrtek v] LT';
  24135. case 5:
  24136. return '[v pátek v] LT';
  24137. case 6:
  24138. return '[v sobotu v] LT';
  24139. }
  24140. },
  24141. lastDay: '[včera v] LT',
  24142. lastWeek: function () {
  24143. switch (this.day()) {
  24144. case 0:
  24145. return '[minulou neděli v] LT';
  24146. case 1:
  24147. case 2:
  24148. return '[minulé] dddd [v] LT';
  24149. case 3:
  24150. return '[minulou středu v] LT';
  24151. case 4:
  24152. case 5:
  24153. return '[minulý] dddd [v] LT';
  24154. case 6:
  24155. return '[minulou sobotu v] LT';
  24156. }
  24157. },
  24158. sameElse: 'L'
  24159. },
  24160. relativeTime : {
  24161. future : 'za %s',
  24162. past : 'před %s',
  24163. s : translate$1,
  24164. m : translate$1,
  24165. mm : translate$1,
  24166. h : translate$1,
  24167. hh : translate$1,
  24168. d : translate$1,
  24169. dd : translate$1,
  24170. M : translate$1,
  24171. MM : translate$1,
  24172. y : translate$1,
  24173. yy : translate$1
  24174. },
  24175. dayOfMonthOrdinalParse : /\d{1,2}\./,
  24176. ordinal : '%d.',
  24177. week : {
  24178. dow : 1, // Monday is the first day of the week.
  24179. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24180. }
  24181. });
  24182. //! moment.js locale configuration
  24183. //! locale : Chuvash [cv]
  24184. //! author : Anatoly Mironov : https://github.com/mirontoli
  24185. hooks.defineLocale('cv', {
  24186. months : 'кӑрлач_нарӑс_пуш_ака_май_ҫӗртме_утӑ_ҫурла_авӑн_юпа_чӳк_раштав'.split('_'),
  24187. monthsShort : 'кӑр_нар_пуш_ака_май_ҫӗр_утӑ_ҫур_авн_юпа_чӳк_раш'.split('_'),
  24188. weekdays : 'вырсарникун_тунтикун_ытларикун_юнкун_кӗҫнерникун_эрнекун_шӑматкун'.split('_'),
  24189. weekdaysShort : 'выр_тун_ытл_юн_кӗҫ_эрн_шӑм'.split('_'),
  24190. weekdaysMin : 'вр_тн_ыт_юн_кҫ_эр_шм'.split('_'),
  24191. longDateFormat : {
  24192. LT : 'HH:mm',
  24193. LTS : 'HH:mm:ss',
  24194. L : 'DD-MM-YYYY',
  24195. LL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ]',
  24196. LLL : 'YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm',
  24197. LLLL : 'dddd, YYYY [ҫулхи] MMMM [уйӑхӗн] D[-мӗшӗ], HH:mm'
  24198. },
  24199. calendar : {
  24200. sameDay: '[Паян] LT [сехетре]',
  24201. nextDay: '[Ыран] LT [сехетре]',
  24202. lastDay: '[Ӗнер] LT [сехетре]',
  24203. nextWeek: '[Ҫитес] dddd LT [сехетре]',
  24204. lastWeek: '[Иртнӗ] dddd LT [сехетре]',
  24205. sameElse: 'L'
  24206. },
  24207. relativeTime : {
  24208. future : function (output) {
  24209. var affix = /сехет$/i.exec(output) ? 'рен' : /ҫул$/i.exec(output) ? 'тан' : 'ран';
  24210. return output + affix;
  24211. },
  24212. past : '%s каялла',
  24213. s : 'пӗр-ик ҫеккунт',
  24214. m : 'пӗр минут',
  24215. mm : '%d минут',
  24216. h : 'пӗр сехет',
  24217. hh : '%d сехет',
  24218. d : 'пӗр кун',
  24219. dd : '%d кун',
  24220. M : 'пӗр уйӑх',
  24221. MM : '%d уйӑх',
  24222. y : 'пӗр ҫул',
  24223. yy : '%d ҫул'
  24224. },
  24225. dayOfMonthOrdinalParse: /\d{1,2}-мӗш/,
  24226. ordinal : '%d-мӗш',
  24227. week : {
  24228. dow : 1, // Monday is the first day of the week.
  24229. doy : 7 // The week that contains Jan 1st is the first week of the year.
  24230. }
  24231. });
  24232. //! moment.js locale configuration
  24233. //! locale : Welsh [cy]
  24234. //! author : Robert Allen : https://github.com/robgallen
  24235. //! author : https://github.com/ryangreaves
  24236. hooks.defineLocale('cy', {
  24237. months: 'Ionawr_Chwefror_Mawrth_Ebrill_Mai_Mehefin_Gorffennaf_Awst_Medi_Hydref_Tachwedd_Rhagfyr'.split('_'),
  24238. monthsShort: 'Ion_Chwe_Maw_Ebr_Mai_Meh_Gor_Aws_Med_Hyd_Tach_Rhag'.split('_'),
  24239. weekdays: 'Dydd Sul_Dydd Llun_Dydd Mawrth_Dydd Mercher_Dydd Iau_Dydd Gwener_Dydd Sadwrn'.split('_'),
  24240. weekdaysShort: 'Sul_Llun_Maw_Mer_Iau_Gwe_Sad'.split('_'),
  24241. weekdaysMin: 'Su_Ll_Ma_Me_Ia_Gw_Sa'.split('_'),
  24242. weekdaysParseExact : true,
  24243. // time formats are the same as en-gb
  24244. longDateFormat: {
  24245. LT: 'HH:mm',
  24246. LTS : 'HH:mm:ss',
  24247. L: 'DD/MM/YYYY',
  24248. LL: 'D MMMM YYYY',
  24249. LLL: 'D MMMM YYYY HH:mm',
  24250. LLLL: 'dddd, D MMMM YYYY HH:mm'
  24251. },
  24252. calendar: {
  24253. sameDay: '[Heddiw am] LT',
  24254. nextDay: '[Yfory am] LT',
  24255. nextWeek: 'dddd [am] LT',
  24256. lastDay: '[Ddoe am] LT',
  24257. lastWeek: 'dddd [diwethaf am] LT',
  24258. sameElse: 'L'
  24259. },
  24260. relativeTime: {
  24261. future: 'mewn %s',
  24262. past: '%s yn ôl',
  24263. s: 'ychydig eiliadau',
  24264. m: 'munud',
  24265. mm: '%d munud',
  24266. h: 'awr',
  24267. hh: '%d awr',
  24268. d: 'diwrnod',
  24269. dd: '%d diwrnod',
  24270. M: 'mis',
  24271. MM: '%d mis',
  24272. y: 'blwyddyn',
  24273. yy: '%d flynedd'
  24274. },
  24275. dayOfMonthOrdinalParse: /\d{1,2}(fed|ain|af|il|ydd|ed|eg)/,
  24276. // traditional ordinal numbers above 31 are not commonly used in colloquial Welsh
  24277. ordinal: function (number) {
  24278. var b = number,
  24279. output = '',
  24280. lookup = [
  24281. '', 'af', 'il', 'ydd', 'ydd', 'ed', 'ed', 'ed', 'fed', 'fed', 'fed', // 1af to 10fed
  24282. 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'eg', 'fed', 'eg', 'fed' // 11eg to 20fed
  24283. ];
  24284. if (b > 20) {
  24285. if (b === 40 || b === 50 || b === 60 || b === 80 || b === 100) {
  24286. output = 'fed'; // not 30ain, 70ain or 90ain
  24287. } else {
  24288. output = 'ain';
  24289. }
  24290. } else if (b > 0) {
  24291. output = lookup[b];
  24292. }
  24293. return number + output;
  24294. },
  24295. week : {
  24296. dow : 1, // Monday is the first day of the week.
  24297. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24298. }
  24299. });
  24300. //! moment.js locale configuration
  24301. //! locale : Danish [da]
  24302. //! author : Ulrik Nielsen : https://github.com/mrbase
  24303. hooks.defineLocale('da', {
  24304. months : 'januar_februar_marts_april_maj_juni_juli_august_september_oktober_november_december'.split('_'),
  24305. monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
  24306. weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
  24307. weekdaysShort : 'søn_man_tir_ons_tor_fre_lør'.split('_'),
  24308. weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
  24309. longDateFormat : {
  24310. LT : 'HH:mm',
  24311. LTS : 'HH:mm:ss',
  24312. L : 'DD.MM.YYYY',
  24313. LL : 'D. MMMM YYYY',
  24314. LLL : 'D. MMMM YYYY HH:mm',
  24315. LLLL : 'dddd [d.] D. MMMM YYYY [kl.] HH:mm'
  24316. },
  24317. calendar : {
  24318. sameDay : '[i dag kl.] LT',
  24319. nextDay : '[i morgen kl.] LT',
  24320. nextWeek : 'på dddd [kl.] LT',
  24321. lastDay : '[i går kl.] LT',
  24322. lastWeek : '[i] dddd[s kl.] LT',
  24323. sameElse : 'L'
  24324. },
  24325. relativeTime : {
  24326. future : 'om %s',
  24327. past : '%s siden',
  24328. s : 'få sekunder',
  24329. m : 'et minut',
  24330. mm : '%d minutter',
  24331. h : 'en time',
  24332. hh : '%d timer',
  24333. d : 'en dag',
  24334. dd : '%d dage',
  24335. M : 'en måned',
  24336. MM : '%d måneder',
  24337. y : 'et år',
  24338. yy : '%d år'
  24339. },
  24340. dayOfMonthOrdinalParse: /\d{1,2}\./,
  24341. ordinal : '%d.',
  24342. week : {
  24343. dow : 1, // Monday is the first day of the week.
  24344. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24345. }
  24346. });
  24347. //! moment.js locale configuration
  24348. //! locale : German (Austria) [de-at]
  24349. //! author : lluchs : https://github.com/lluchs
  24350. //! author: Menelion Elensúle: https://github.com/Oire
  24351. //! author : Martin Groller : https://github.com/MadMG
  24352. //! author : Mikolaj Dadela : https://github.com/mik01aj
  24353. function processRelativeTime(number, withoutSuffix, key, isFuture) {
  24354. var format = {
  24355. 'm': ['eine Minute', 'einer Minute'],
  24356. 'h': ['eine Stunde', 'einer Stunde'],
  24357. 'd': ['ein Tag', 'einem Tag'],
  24358. 'dd': [number + ' Tage', number + ' Tagen'],
  24359. 'M': ['ein Monat', 'einem Monat'],
  24360. 'MM': [number + ' Monate', number + ' Monaten'],
  24361. 'y': ['ein Jahr', 'einem Jahr'],
  24362. 'yy': [number + ' Jahre', number + ' Jahren']
  24363. };
  24364. return withoutSuffix ? format[key][0] : format[key][1];
  24365. }
  24366. hooks.defineLocale('de-at', {
  24367. months : 'Jänner_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
  24368. monthsShort : 'Jän._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'),
  24369. monthsParseExact : true,
  24370. weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
  24371. weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
  24372. weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
  24373. weekdaysParseExact : true,
  24374. longDateFormat : {
  24375. LT: 'HH:mm',
  24376. LTS: 'HH:mm:ss',
  24377. L : 'DD.MM.YYYY',
  24378. LL : 'D. MMMM YYYY',
  24379. LLL : 'D. MMMM YYYY HH:mm',
  24380. LLLL : 'dddd, D. MMMM YYYY HH:mm'
  24381. },
  24382. calendar : {
  24383. sameDay: '[heute um] LT [Uhr]',
  24384. sameElse: 'L',
  24385. nextDay: '[morgen um] LT [Uhr]',
  24386. nextWeek: 'dddd [um] LT [Uhr]',
  24387. lastDay: '[gestern um] LT [Uhr]',
  24388. lastWeek: '[letzten] dddd [um] LT [Uhr]'
  24389. },
  24390. relativeTime : {
  24391. future : 'in %s',
  24392. past : 'vor %s',
  24393. s : 'ein paar Sekunden',
  24394. m : processRelativeTime,
  24395. mm : '%d Minuten',
  24396. h : processRelativeTime,
  24397. hh : '%d Stunden',
  24398. d : processRelativeTime,
  24399. dd : processRelativeTime,
  24400. M : processRelativeTime,
  24401. MM : processRelativeTime,
  24402. y : processRelativeTime,
  24403. yy : processRelativeTime
  24404. },
  24405. dayOfMonthOrdinalParse: /\d{1,2}\./,
  24406. ordinal : '%d.',
  24407. week : {
  24408. dow : 1, // Monday is the first day of the week.
  24409. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24410. }
  24411. });
  24412. //! moment.js locale configuration
  24413. //! locale : German (Switzerland) [de-ch]
  24414. //! author : sschueller : https://github.com/sschueller
  24415. // based on: https://www.bk.admin.ch/dokumentation/sprachen/04915/05016/index.html?lang=de#
  24416. function processRelativeTime$1(number, withoutSuffix, key, isFuture) {
  24417. var format = {
  24418. 'm': ['eine Minute', 'einer Minute'],
  24419. 'h': ['eine Stunde', 'einer Stunde'],
  24420. 'd': ['ein Tag', 'einem Tag'],
  24421. 'dd': [number + ' Tage', number + ' Tagen'],
  24422. 'M': ['ein Monat', 'einem Monat'],
  24423. 'MM': [number + ' Monate', number + ' Monaten'],
  24424. 'y': ['ein Jahr', 'einem Jahr'],
  24425. 'yy': [number + ' Jahre', number + ' Jahren']
  24426. };
  24427. return withoutSuffix ? format[key][0] : format[key][1];
  24428. }
  24429. hooks.defineLocale('de-ch', {
  24430. months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
  24431. monthsShort : 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'),
  24432. monthsParseExact : true,
  24433. weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
  24434. weekdaysShort : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
  24435. weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
  24436. weekdaysParseExact : true,
  24437. longDateFormat : {
  24438. LT: 'HH.mm',
  24439. LTS: 'HH.mm.ss',
  24440. L : 'DD.MM.YYYY',
  24441. LL : 'D. MMMM YYYY',
  24442. LLL : 'D. MMMM YYYY HH.mm',
  24443. LLLL : 'dddd, D. MMMM YYYY HH.mm'
  24444. },
  24445. calendar : {
  24446. sameDay: '[heute um] LT [Uhr]',
  24447. sameElse: 'L',
  24448. nextDay: '[morgen um] LT [Uhr]',
  24449. nextWeek: 'dddd [um] LT [Uhr]',
  24450. lastDay: '[gestern um] LT [Uhr]',
  24451. lastWeek: '[letzten] dddd [um] LT [Uhr]'
  24452. },
  24453. relativeTime : {
  24454. future : 'in %s',
  24455. past : 'vor %s',
  24456. s : 'ein paar Sekunden',
  24457. m : processRelativeTime$1,
  24458. mm : '%d Minuten',
  24459. h : processRelativeTime$1,
  24460. hh : '%d Stunden',
  24461. d : processRelativeTime$1,
  24462. dd : processRelativeTime$1,
  24463. M : processRelativeTime$1,
  24464. MM : processRelativeTime$1,
  24465. y : processRelativeTime$1,
  24466. yy : processRelativeTime$1
  24467. },
  24468. dayOfMonthOrdinalParse: /\d{1,2}\./,
  24469. ordinal : '%d.',
  24470. week : {
  24471. dow : 1, // Monday is the first day of the week.
  24472. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24473. }
  24474. });
  24475. //! moment.js locale configuration
  24476. //! locale : German [de]
  24477. //! author : lluchs : https://github.com/lluchs
  24478. //! author: Menelion Elensúle: https://github.com/Oire
  24479. //! author : Mikolaj Dadela : https://github.com/mik01aj
  24480. function processRelativeTime$2(number, withoutSuffix, key, isFuture) {
  24481. var format = {
  24482. 'm': ['eine Minute', 'einer Minute'],
  24483. 'h': ['eine Stunde', 'einer Stunde'],
  24484. 'd': ['ein Tag', 'einem Tag'],
  24485. 'dd': [number + ' Tage', number + ' Tagen'],
  24486. 'M': ['ein Monat', 'einem Monat'],
  24487. 'MM': [number + ' Monate', number + ' Monaten'],
  24488. 'y': ['ein Jahr', 'einem Jahr'],
  24489. 'yy': [number + ' Jahre', number + ' Jahren']
  24490. };
  24491. return withoutSuffix ? format[key][0] : format[key][1];
  24492. }
  24493. hooks.defineLocale('de', {
  24494. months : 'Januar_Februar_März_April_Mai_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
  24495. monthsShort : 'Jan._Feb._März_Apr._Mai_Juni_Juli_Aug._Sep._Okt._Nov._Dez.'.split('_'),
  24496. monthsParseExact : true,
  24497. weekdays : 'Sonntag_Montag_Dienstag_Mittwoch_Donnerstag_Freitag_Samstag'.split('_'),
  24498. weekdaysShort : 'So._Mo._Di._Mi._Do._Fr._Sa.'.split('_'),
  24499. weekdaysMin : 'So_Mo_Di_Mi_Do_Fr_Sa'.split('_'),
  24500. weekdaysParseExact : true,
  24501. longDateFormat : {
  24502. LT: 'HH:mm',
  24503. LTS: 'HH:mm:ss',
  24504. L : 'DD.MM.YYYY',
  24505. LL : 'D. MMMM YYYY',
  24506. LLL : 'D. MMMM YYYY HH:mm',
  24507. LLLL : 'dddd, D. MMMM YYYY HH:mm'
  24508. },
  24509. calendar : {
  24510. sameDay: '[heute um] LT [Uhr]',
  24511. sameElse: 'L',
  24512. nextDay: '[morgen um] LT [Uhr]',
  24513. nextWeek: 'dddd [um] LT [Uhr]',
  24514. lastDay: '[gestern um] LT [Uhr]',
  24515. lastWeek: '[letzten] dddd [um] LT [Uhr]'
  24516. },
  24517. relativeTime : {
  24518. future : 'in %s',
  24519. past : 'vor %s',
  24520. s : 'ein paar Sekunden',
  24521. m : processRelativeTime$2,
  24522. mm : '%d Minuten',
  24523. h : processRelativeTime$2,
  24524. hh : '%d Stunden',
  24525. d : processRelativeTime$2,
  24526. dd : processRelativeTime$2,
  24527. M : processRelativeTime$2,
  24528. MM : processRelativeTime$2,
  24529. y : processRelativeTime$2,
  24530. yy : processRelativeTime$2
  24531. },
  24532. dayOfMonthOrdinalParse: /\d{1,2}\./,
  24533. ordinal : '%d.',
  24534. week : {
  24535. dow : 1, // Monday is the first day of the week.
  24536. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24537. }
  24538. });
  24539. //! moment.js locale configuration
  24540. //! locale : Maldivian [dv]
  24541. //! author : Jawish Hameed : https://github.com/jawish
  24542. var months$4 = [
  24543. 'ޖެނުއަރީ',
  24544. 'ފެބްރުއަރީ',
  24545. 'މާރިޗު',
  24546. 'އޭޕްރީލު',
  24547. 'މޭ',
  24548. 'ޖޫން',
  24549. 'ޖުލައި',
  24550. 'އޯގަސްޓު',
  24551. 'ސެޕްޓެމްބަރު',
  24552. 'އޮކްޓޯބަރު',
  24553. 'ނޮވެމްބަރު',
  24554. 'ޑިސެމްބަރު'
  24555. ];
  24556. var weekdays = [
  24557. 'އާދިއްތަ',
  24558. 'ހޯމަ',
  24559. 'އަންގާރަ',
  24560. 'ބުދަ',
  24561. 'ބުރާސްފަތި',
  24562. 'ހުކުރު',
  24563. 'ހޮނިހިރު'
  24564. ];
  24565. hooks.defineLocale('dv', {
  24566. months : months$4,
  24567. monthsShort : months$4,
  24568. weekdays : weekdays,
  24569. weekdaysShort : weekdays,
  24570. weekdaysMin : 'އާދި_ހޯމަ_އަން_ބުދަ_ބުރާ_ހުކު_ހޮނި'.split('_'),
  24571. longDateFormat : {
  24572. LT : 'HH:mm',
  24573. LTS : 'HH:mm:ss',
  24574. L : 'D/M/YYYY',
  24575. LL : 'D MMMM YYYY',
  24576. LLL : 'D MMMM YYYY HH:mm',
  24577. LLLL : 'dddd D MMMM YYYY HH:mm'
  24578. },
  24579. meridiemParse: /މކ|މފ/,
  24580. isPM : function (input) {
  24581. return 'މފ' === input;
  24582. },
  24583. meridiem : function (hour, minute, isLower) {
  24584. if (hour < 12) {
  24585. return 'މކ';
  24586. } else {
  24587. return 'މފ';
  24588. }
  24589. },
  24590. calendar : {
  24591. sameDay : '[މިއަދު] LT',
  24592. nextDay : '[މާދަމާ] LT',
  24593. nextWeek : 'dddd LT',
  24594. lastDay : '[އިއްޔެ] LT',
  24595. lastWeek : '[ފާއިތުވި] dddd LT',
  24596. sameElse : 'L'
  24597. },
  24598. relativeTime : {
  24599. future : 'ތެރޭގައި %s',
  24600. past : 'ކުރިން %s',
  24601. s : 'ސިކުންތުކޮޅެއް',
  24602. m : 'މިނިޓެއް',
  24603. mm : 'މިނިޓު %d',
  24604. h : 'ގަޑިއިރެއް',
  24605. hh : 'ގަޑިއިރު %d',
  24606. d : 'ދުވަހެއް',
  24607. dd : 'ދުވަސް %d',
  24608. M : 'މަހެއް',
  24609. MM : 'މަސް %d',
  24610. y : 'އަހަރެއް',
  24611. yy : 'އަހަރު %d'
  24612. },
  24613. preparse: function (string) {
  24614. return string.replace(/،/g, ',');
  24615. },
  24616. postformat: function (string) {
  24617. return string.replace(/,/g, '،');
  24618. },
  24619. week : {
  24620. dow : 7, // Sunday is the first day of the week.
  24621. doy : 12 // The week that contains Jan 1st is the first week of the year.
  24622. }
  24623. });
  24624. //! moment.js locale configuration
  24625. //! locale : Greek [el]
  24626. //! author : Aggelos Karalias : https://github.com/mehiel
  24627. hooks.defineLocale('el', {
  24628. monthsNominativeEl : 'Ιανουάριος_Φεβρουάριος_Μάρτιος_Απρίλιος_Μάιος_Ιούνιος_Ιούλιος_Αύγουστος_Σεπτέμβριος_Οκτώβριος_Νοέμβριος_Δεκέμβριος'.split('_'),
  24629. monthsGenitiveEl : 'Ιανουαρίου_Φεβρουαρίου_Μαρτίου_Απριλίου_Μαΐου_Ιουνίου_Ιουλίου_Αυγούστου_Σεπτεμβρίου_Οκτωβρίου_Νοεμβρίου_Δεκεμβρίου'.split('_'),
  24630. months : function (momentToFormat, format) {
  24631. if (!momentToFormat) {
  24632. return this._monthsNominativeEl;
  24633. } else if (typeof format === 'string' && /D/.test(format.substring(0, format.indexOf('MMMM')))) { // if there is a day number before 'MMMM'
  24634. return this._monthsGenitiveEl[momentToFormat.month()];
  24635. } else {
  24636. return this._monthsNominativeEl[momentToFormat.month()];
  24637. }
  24638. },
  24639. monthsShort : 'Ιαν_Φεβ_Μαρ_Απρ_Μαϊ_Ιουν_Ιουλ_Αυγ_Σεπ_Οκτ_Νοε_Δεκ'.split('_'),
  24640. weekdays : 'Κυριακή_Δευτέρα_Τρίτη_Τετάρτη_Πέμπτη_Παρασκευή_Σάββατο'.split('_'),
  24641. weekdaysShort : 'Κυρ_Δευ_Τρι_Τετ_Πεμ_Παρ_Σαβ'.split('_'),
  24642. weekdaysMin : 'Κυ_Δε_Τρ_Τε_Πε_Πα_Σα'.split('_'),
  24643. meridiem : function (hours, minutes, isLower) {
  24644. if (hours > 11) {
  24645. return isLower ? 'μμ' : 'ΜΜ';
  24646. } else {
  24647. return isLower ? 'πμ' : 'ΠΜ';
  24648. }
  24649. },
  24650. isPM : function (input) {
  24651. return ((input + '').toLowerCase()[0] === 'μ');
  24652. },
  24653. meridiemParse : /[ΠΜ]\.?Μ?\.?/i,
  24654. longDateFormat : {
  24655. LT : 'h:mm A',
  24656. LTS : 'h:mm:ss A',
  24657. L : 'DD/MM/YYYY',
  24658. LL : 'D MMMM YYYY',
  24659. LLL : 'D MMMM YYYY h:mm A',
  24660. LLLL : 'dddd, D MMMM YYYY h:mm A'
  24661. },
  24662. calendarEl : {
  24663. sameDay : '[Σήμερα {}] LT',
  24664. nextDay : '[Αύριο {}] LT',
  24665. nextWeek : 'dddd [{}] LT',
  24666. lastDay : '[Χθες {}] LT',
  24667. lastWeek : function () {
  24668. switch (this.day()) {
  24669. case 6:
  24670. return '[το προηγούμενο] dddd [{}] LT';
  24671. default:
  24672. return '[την προηγούμενη] dddd [{}] LT';
  24673. }
  24674. },
  24675. sameElse : 'L'
  24676. },
  24677. calendar : function (key, mom) {
  24678. var output = this._calendarEl[key],
  24679. hours = mom && mom.hours();
  24680. if (isFunction(output)) {
  24681. output = output.apply(mom);
  24682. }
  24683. return output.replace('{}', (hours % 12 === 1 ? 'στη' : 'στις'));
  24684. },
  24685. relativeTime : {
  24686. future : 'σε %s',
  24687. past : '%s πριν',
  24688. s : 'λίγα δευτερόλεπτα',
  24689. m : 'ένα λεπτό',
  24690. mm : '%d λεπτά',
  24691. h : 'μία ώρα',
  24692. hh : '%d ώρες',
  24693. d : 'μία μέρα',
  24694. dd : '%d μέρες',
  24695. M : 'ένας μήνας',
  24696. MM : '%d μήνες',
  24697. y : 'ένας χρόνος',
  24698. yy : '%d χρόνια'
  24699. },
  24700. dayOfMonthOrdinalParse: /\d{1,2}η/,
  24701. ordinal: '%dη',
  24702. week : {
  24703. dow : 1, // Monday is the first day of the week.
  24704. doy : 4 // The week that contains Jan 4st is the first week of the year.
  24705. }
  24706. });
  24707. //! moment.js locale configuration
  24708. //! locale : English (Australia) [en-au]
  24709. //! author : Jared Morse : https://github.com/jarcoal
  24710. hooks.defineLocale('en-au', {
  24711. months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
  24712. monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  24713. weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  24714. weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  24715. weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  24716. longDateFormat : {
  24717. LT : 'h:mm A',
  24718. LTS : 'h:mm:ss A',
  24719. L : 'DD/MM/YYYY',
  24720. LL : 'D MMMM YYYY',
  24721. LLL : 'D MMMM YYYY h:mm A',
  24722. LLLL : 'dddd, D MMMM YYYY h:mm A'
  24723. },
  24724. calendar : {
  24725. sameDay : '[Today at] LT',
  24726. nextDay : '[Tomorrow at] LT',
  24727. nextWeek : 'dddd [at] LT',
  24728. lastDay : '[Yesterday at] LT',
  24729. lastWeek : '[Last] dddd [at] LT',
  24730. sameElse : 'L'
  24731. },
  24732. relativeTime : {
  24733. future : 'in %s',
  24734. past : '%s ago',
  24735. s : 'a few seconds',
  24736. m : 'a minute',
  24737. mm : '%d minutes',
  24738. h : 'an hour',
  24739. hh : '%d hours',
  24740. d : 'a day',
  24741. dd : '%d days',
  24742. M : 'a month',
  24743. MM : '%d months',
  24744. y : 'a year',
  24745. yy : '%d years'
  24746. },
  24747. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  24748. ordinal : function (number) {
  24749. var b = number % 10,
  24750. output = (~~(number % 100 / 10) === 1) ? 'th' :
  24751. (b === 1) ? 'st' :
  24752. (b === 2) ? 'nd' :
  24753. (b === 3) ? 'rd' : 'th';
  24754. return number + output;
  24755. },
  24756. week : {
  24757. dow : 1, // Monday is the first day of the week.
  24758. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24759. }
  24760. });
  24761. //! moment.js locale configuration
  24762. //! locale : English (Canada) [en-ca]
  24763. //! author : Jonathan Abourbih : https://github.com/jonbca
  24764. hooks.defineLocale('en-ca', {
  24765. months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
  24766. monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  24767. weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  24768. weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  24769. weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  24770. longDateFormat : {
  24771. LT : 'h:mm A',
  24772. LTS : 'h:mm:ss A',
  24773. L : 'YYYY-MM-DD',
  24774. LL : 'MMMM D, YYYY',
  24775. LLL : 'MMMM D, YYYY h:mm A',
  24776. LLLL : 'dddd, MMMM D, YYYY h:mm A'
  24777. },
  24778. calendar : {
  24779. sameDay : '[Today at] LT',
  24780. nextDay : '[Tomorrow at] LT',
  24781. nextWeek : 'dddd [at] LT',
  24782. lastDay : '[Yesterday at] LT',
  24783. lastWeek : '[Last] dddd [at] LT',
  24784. sameElse : 'L'
  24785. },
  24786. relativeTime : {
  24787. future : 'in %s',
  24788. past : '%s ago',
  24789. s : 'a few seconds',
  24790. m : 'a minute',
  24791. mm : '%d minutes',
  24792. h : 'an hour',
  24793. hh : '%d hours',
  24794. d : 'a day',
  24795. dd : '%d days',
  24796. M : 'a month',
  24797. MM : '%d months',
  24798. y : 'a year',
  24799. yy : '%d years'
  24800. },
  24801. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  24802. ordinal : function (number) {
  24803. var b = number % 10,
  24804. output = (~~(number % 100 / 10) === 1) ? 'th' :
  24805. (b === 1) ? 'st' :
  24806. (b === 2) ? 'nd' :
  24807. (b === 3) ? 'rd' : 'th';
  24808. return number + output;
  24809. }
  24810. });
  24811. //! moment.js locale configuration
  24812. //! locale : English (United Kingdom) [en-gb]
  24813. //! author : Chris Gedrim : https://github.com/chrisgedrim
  24814. hooks.defineLocale('en-gb', {
  24815. months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
  24816. monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  24817. weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  24818. weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  24819. weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  24820. longDateFormat : {
  24821. LT : 'HH:mm',
  24822. LTS : 'HH:mm:ss',
  24823. L : 'DD/MM/YYYY',
  24824. LL : 'D MMMM YYYY',
  24825. LLL : 'D MMMM YYYY HH:mm',
  24826. LLLL : 'dddd, D MMMM YYYY HH:mm'
  24827. },
  24828. calendar : {
  24829. sameDay : '[Today at] LT',
  24830. nextDay : '[Tomorrow at] LT',
  24831. nextWeek : 'dddd [at] LT',
  24832. lastDay : '[Yesterday at] LT',
  24833. lastWeek : '[Last] dddd [at] LT',
  24834. sameElse : 'L'
  24835. },
  24836. relativeTime : {
  24837. future : 'in %s',
  24838. past : '%s ago',
  24839. s : 'a few seconds',
  24840. m : 'a minute',
  24841. mm : '%d minutes',
  24842. h : 'an hour',
  24843. hh : '%d hours',
  24844. d : 'a day',
  24845. dd : '%d days',
  24846. M : 'a month',
  24847. MM : '%d months',
  24848. y : 'a year',
  24849. yy : '%d years'
  24850. },
  24851. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  24852. ordinal : function (number) {
  24853. var b = number % 10,
  24854. output = (~~(number % 100 / 10) === 1) ? 'th' :
  24855. (b === 1) ? 'st' :
  24856. (b === 2) ? 'nd' :
  24857. (b === 3) ? 'rd' : 'th';
  24858. return number + output;
  24859. },
  24860. week : {
  24861. dow : 1, // Monday is the first day of the week.
  24862. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24863. }
  24864. });
  24865. //! moment.js locale configuration
  24866. //! locale : English (Ireland) [en-ie]
  24867. //! author : Chris Cartlidge : https://github.com/chriscartlidge
  24868. hooks.defineLocale('en-ie', {
  24869. months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
  24870. monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  24871. weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  24872. weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  24873. weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  24874. longDateFormat : {
  24875. LT : 'HH:mm',
  24876. LTS : 'HH:mm:ss',
  24877. L : 'DD-MM-YYYY',
  24878. LL : 'D MMMM YYYY',
  24879. LLL : 'D MMMM YYYY HH:mm',
  24880. LLLL : 'dddd D MMMM YYYY HH:mm'
  24881. },
  24882. calendar : {
  24883. sameDay : '[Today at] LT',
  24884. nextDay : '[Tomorrow at] LT',
  24885. nextWeek : 'dddd [at] LT',
  24886. lastDay : '[Yesterday at] LT',
  24887. lastWeek : '[Last] dddd [at] LT',
  24888. sameElse : 'L'
  24889. },
  24890. relativeTime : {
  24891. future : 'in %s',
  24892. past : '%s ago',
  24893. s : 'a few seconds',
  24894. m : 'a minute',
  24895. mm : '%d minutes',
  24896. h : 'an hour',
  24897. hh : '%d hours',
  24898. d : 'a day',
  24899. dd : '%d days',
  24900. M : 'a month',
  24901. MM : '%d months',
  24902. y : 'a year',
  24903. yy : '%d years'
  24904. },
  24905. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  24906. ordinal : function (number) {
  24907. var b = number % 10,
  24908. output = (~~(number % 100 / 10) === 1) ? 'th' :
  24909. (b === 1) ? 'st' :
  24910. (b === 2) ? 'nd' :
  24911. (b === 3) ? 'rd' : 'th';
  24912. return number + output;
  24913. },
  24914. week : {
  24915. dow : 1, // Monday is the first day of the week.
  24916. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24917. }
  24918. });
  24919. //! moment.js locale configuration
  24920. //! locale : English (New Zealand) [en-nz]
  24921. //! author : Luke McGregor : https://github.com/lukemcgregor
  24922. hooks.defineLocale('en-nz', {
  24923. months : 'January_February_March_April_May_June_July_August_September_October_November_December'.split('_'),
  24924. monthsShort : 'Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec'.split('_'),
  24925. weekdays : 'Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday'.split('_'),
  24926. weekdaysShort : 'Sun_Mon_Tue_Wed_Thu_Fri_Sat'.split('_'),
  24927. weekdaysMin : 'Su_Mo_Tu_We_Th_Fr_Sa'.split('_'),
  24928. longDateFormat : {
  24929. LT : 'h:mm A',
  24930. LTS : 'h:mm:ss A',
  24931. L : 'DD/MM/YYYY',
  24932. LL : 'D MMMM YYYY',
  24933. LLL : 'D MMMM YYYY h:mm A',
  24934. LLLL : 'dddd, D MMMM YYYY h:mm A'
  24935. },
  24936. calendar : {
  24937. sameDay : '[Today at] LT',
  24938. nextDay : '[Tomorrow at] LT',
  24939. nextWeek : 'dddd [at] LT',
  24940. lastDay : '[Yesterday at] LT',
  24941. lastWeek : '[Last] dddd [at] LT',
  24942. sameElse : 'L'
  24943. },
  24944. relativeTime : {
  24945. future : 'in %s',
  24946. past : '%s ago',
  24947. s : 'a few seconds',
  24948. m : 'a minute',
  24949. mm : '%d minutes',
  24950. h : 'an hour',
  24951. hh : '%d hours',
  24952. d : 'a day',
  24953. dd : '%d days',
  24954. M : 'a month',
  24955. MM : '%d months',
  24956. y : 'a year',
  24957. yy : '%d years'
  24958. },
  24959. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  24960. ordinal : function (number) {
  24961. var b = number % 10,
  24962. output = (~~(number % 100 / 10) === 1) ? 'th' :
  24963. (b === 1) ? 'st' :
  24964. (b === 2) ? 'nd' :
  24965. (b === 3) ? 'rd' : 'th';
  24966. return number + output;
  24967. },
  24968. week : {
  24969. dow : 1, // Monday is the first day of the week.
  24970. doy : 4 // The week that contains Jan 4th is the first week of the year.
  24971. }
  24972. });
  24973. //! moment.js locale configuration
  24974. //! locale : Esperanto [eo]
  24975. //! author : Colin Dean : https://github.com/colindean
  24976. //! author : Mia Nordentoft Imperatori : https://github.com/miestasmia
  24977. //! comment : miestasmia corrected the translation by colindean
  24978. hooks.defineLocale('eo', {
  24979. months : 'januaro_februaro_marto_aprilo_majo_junio_julio_aŭgusto_septembro_oktobro_novembro_decembro'.split('_'),
  24980. monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aŭg_sep_okt_nov_dec'.split('_'),
  24981. weekdays : 'dimanĉo_lundo_mardo_merkredo_ĵaŭdo_vendredo_sabato'.split('_'),
  24982. weekdaysShort : 'dim_lun_mard_merk_ĵaŭ_ven_sab'.split('_'),
  24983. weekdaysMin : 'di_lu_ma_me_ĵa_ve_sa'.split('_'),
  24984. longDateFormat : {
  24985. LT : 'HH:mm',
  24986. LTS : 'HH:mm:ss',
  24987. L : 'YYYY-MM-DD',
  24988. LL : 'D[-a de] MMMM, YYYY',
  24989. LLL : 'D[-a de] MMMM, YYYY HH:mm',
  24990. LLLL : 'dddd, [la] D[-a de] MMMM, YYYY HH:mm'
  24991. },
  24992. meridiemParse: /[ap]\.t\.m/i,
  24993. isPM: function (input) {
  24994. return input.charAt(0).toLowerCase() === 'p';
  24995. },
  24996. meridiem : function (hours, minutes, isLower) {
  24997. if (hours > 11) {
  24998. return isLower ? 'p.t.m.' : 'P.T.M.';
  24999. } else {
  25000. return isLower ? 'a.t.m.' : 'A.T.M.';
  25001. }
  25002. },
  25003. calendar : {
  25004. sameDay : '[Hodiaŭ je] LT',
  25005. nextDay : '[Morgaŭ je] LT',
  25006. nextWeek : 'dddd [je] LT',
  25007. lastDay : '[Hieraŭ je] LT',
  25008. lastWeek : '[pasinta] dddd [je] LT',
  25009. sameElse : 'L'
  25010. },
  25011. relativeTime : {
  25012. future : 'post %s',
  25013. past : 'antaŭ %s',
  25014. s : 'sekundoj',
  25015. m : 'minuto',
  25016. mm : '%d minutoj',
  25017. h : 'horo',
  25018. hh : '%d horoj',
  25019. d : 'tago',//ne 'diurno', ĉar estas uzita por proksimumo
  25020. dd : '%d tagoj',
  25021. M : 'monato',
  25022. MM : '%d monatoj',
  25023. y : 'jaro',
  25024. yy : '%d jaroj'
  25025. },
  25026. dayOfMonthOrdinalParse: /\d{1,2}a/,
  25027. ordinal : '%da',
  25028. week : {
  25029. dow : 1, // Monday is the first day of the week.
  25030. doy : 7 // The week that contains Jan 1st is the first week of the year.
  25031. }
  25032. });
  25033. //! moment.js locale configuration
  25034. //! locale : Spanish (Dominican Republic) [es-do]
  25035. var monthsShortDot = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_');
  25036. var monthsShort$1 = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
  25037. var monthsParse = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i];
  25038. var monthsRegex$1 = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i;
  25039. hooks.defineLocale('es-do', {
  25040. months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
  25041. monthsShort : function (m, format) {
  25042. if (!m) {
  25043. return monthsShortDot;
  25044. } else if (/-MMM-/.test(format)) {
  25045. return monthsShort$1[m.month()];
  25046. } else {
  25047. return monthsShortDot[m.month()];
  25048. }
  25049. },
  25050. monthsRegex: monthsRegex$1,
  25051. monthsShortRegex: monthsRegex$1,
  25052. monthsStrictRegex: /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i,
  25053. monthsShortStrictRegex: /^(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i,
  25054. monthsParse: monthsParse,
  25055. longMonthsParse: monthsParse,
  25056. shortMonthsParse: monthsParse,
  25057. weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
  25058. weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
  25059. weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'),
  25060. weekdaysParseExact : true,
  25061. longDateFormat : {
  25062. LT : 'h:mm A',
  25063. LTS : 'h:mm:ss A',
  25064. L : 'DD/MM/YYYY',
  25065. LL : 'D [de] MMMM [de] YYYY',
  25066. LLL : 'D [de] MMMM [de] YYYY h:mm A',
  25067. LLLL : 'dddd, D [de] MMMM [de] YYYY h:mm A'
  25068. },
  25069. calendar : {
  25070. sameDay : function () {
  25071. return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25072. },
  25073. nextDay : function () {
  25074. return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25075. },
  25076. nextWeek : function () {
  25077. return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25078. },
  25079. lastDay : function () {
  25080. return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25081. },
  25082. lastWeek : function () {
  25083. return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25084. },
  25085. sameElse : 'L'
  25086. },
  25087. relativeTime : {
  25088. future : 'en %s',
  25089. past : 'hace %s',
  25090. s : 'unos segundos',
  25091. m : 'un minuto',
  25092. mm : '%d minutos',
  25093. h : 'una hora',
  25094. hh : '%d horas',
  25095. d : 'un día',
  25096. dd : '%d días',
  25097. M : 'un mes',
  25098. MM : '%d meses',
  25099. y : 'un año',
  25100. yy : '%d años'
  25101. },
  25102. dayOfMonthOrdinalParse : /\d{1,2}º/,
  25103. ordinal : '%dº',
  25104. week : {
  25105. dow : 1, // Monday is the first day of the week.
  25106. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25107. }
  25108. });
  25109. //! moment.js locale configuration
  25110. //! locale : Spanish (United States) [es-us]
  25111. //! author : bustta : https://github.com/bustta
  25112. var monthsShortDot$1 = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_');
  25113. var monthsShort$2 = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
  25114. hooks.defineLocale('es-us', {
  25115. months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
  25116. monthsShort : function (m, format) {
  25117. if (!m) {
  25118. return monthsShortDot$1;
  25119. } else if (/-MMM-/.test(format)) {
  25120. return monthsShort$2[m.month()];
  25121. } else {
  25122. return monthsShortDot$1[m.month()];
  25123. }
  25124. },
  25125. monthsParseExact : true,
  25126. weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
  25127. weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
  25128. weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'),
  25129. weekdaysParseExact : true,
  25130. longDateFormat : {
  25131. LT : 'H:mm',
  25132. LTS : 'H:mm:ss',
  25133. L : 'MM/DD/YYYY',
  25134. LL : 'MMMM [de] D [de] YYYY',
  25135. LLL : 'MMMM [de] D [de] YYYY H:mm',
  25136. LLLL : 'dddd, MMMM [de] D [de] YYYY H:mm'
  25137. },
  25138. calendar : {
  25139. sameDay : function () {
  25140. return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25141. },
  25142. nextDay : function () {
  25143. return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25144. },
  25145. nextWeek : function () {
  25146. return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25147. },
  25148. lastDay : function () {
  25149. return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25150. },
  25151. lastWeek : function () {
  25152. return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25153. },
  25154. sameElse : 'L'
  25155. },
  25156. relativeTime : {
  25157. future : 'en %s',
  25158. past : 'hace %s',
  25159. s : 'unos segundos',
  25160. m : 'un minuto',
  25161. mm : '%d minutos',
  25162. h : 'una hora',
  25163. hh : '%d horas',
  25164. d : 'un día',
  25165. dd : '%d días',
  25166. M : 'un mes',
  25167. MM : '%d meses',
  25168. y : 'un año',
  25169. yy : '%d años'
  25170. },
  25171. dayOfMonthOrdinalParse : /\d{1,2}º/,
  25172. ordinal : '%dº',
  25173. week : {
  25174. dow : 0, // Sunday is the first day of the week.
  25175. doy : 6 // The week that contains Jan 1st is the first week of the year.
  25176. }
  25177. });
  25178. //! moment.js locale configuration
  25179. //! locale : Spanish [es]
  25180. //! author : Julio Napurí : https://github.com/julionc
  25181. var monthsShortDot$2 = 'ene._feb._mar._abr._may._jun._jul._ago._sep._oct._nov._dic.'.split('_');
  25182. var monthsShort$3 = 'ene_feb_mar_abr_may_jun_jul_ago_sep_oct_nov_dic'.split('_');
  25183. var monthsParse$1 = [/^ene/i, /^feb/i, /^mar/i, /^abr/i, /^may/i, /^jun/i, /^jul/i, /^ago/i, /^sep/i, /^oct/i, /^nov/i, /^dic/i];
  25184. var monthsRegex$2 = /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre|ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i;
  25185. hooks.defineLocale('es', {
  25186. months : 'enero_febrero_marzo_abril_mayo_junio_julio_agosto_septiembre_octubre_noviembre_diciembre'.split('_'),
  25187. monthsShort : function (m, format) {
  25188. if (!m) {
  25189. return monthsShortDot$2;
  25190. } else if (/-MMM-/.test(format)) {
  25191. return monthsShort$3[m.month()];
  25192. } else {
  25193. return monthsShortDot$2[m.month()];
  25194. }
  25195. },
  25196. monthsRegex : monthsRegex$2,
  25197. monthsShortRegex : monthsRegex$2,
  25198. monthsStrictRegex : /^(enero|febrero|marzo|abril|mayo|junio|julio|agosto|septiembre|octubre|noviembre|diciembre)/i,
  25199. monthsShortStrictRegex : /^(ene\.?|feb\.?|mar\.?|abr\.?|may\.?|jun\.?|jul\.?|ago\.?|sep\.?|oct\.?|nov\.?|dic\.?)/i,
  25200. monthsParse : monthsParse$1,
  25201. longMonthsParse : monthsParse$1,
  25202. shortMonthsParse : monthsParse$1,
  25203. weekdays : 'domingo_lunes_martes_miércoles_jueves_viernes_sábado'.split('_'),
  25204. weekdaysShort : 'dom._lun._mar._mié._jue._vie._sáb.'.split('_'),
  25205. weekdaysMin : 'do_lu_ma_mi_ju_vi_sá'.split('_'),
  25206. weekdaysParseExact : true,
  25207. longDateFormat : {
  25208. LT : 'H:mm',
  25209. LTS : 'H:mm:ss',
  25210. L : 'DD/MM/YYYY',
  25211. LL : 'D [de] MMMM [de] YYYY',
  25212. LLL : 'D [de] MMMM [de] YYYY H:mm',
  25213. LLLL : 'dddd, D [de] MMMM [de] YYYY H:mm'
  25214. },
  25215. calendar : {
  25216. sameDay : function () {
  25217. return '[hoy a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25218. },
  25219. nextDay : function () {
  25220. return '[mañana a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25221. },
  25222. nextWeek : function () {
  25223. return 'dddd [a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25224. },
  25225. lastDay : function () {
  25226. return '[ayer a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25227. },
  25228. lastWeek : function () {
  25229. return '[el] dddd [pasado a la' + ((this.hours() !== 1) ? 's' : '') + '] LT';
  25230. },
  25231. sameElse : 'L'
  25232. },
  25233. relativeTime : {
  25234. future : 'en %s',
  25235. past : 'hace %s',
  25236. s : 'unos segundos',
  25237. m : 'un minuto',
  25238. mm : '%d minutos',
  25239. h : 'una hora',
  25240. hh : '%d horas',
  25241. d : 'un día',
  25242. dd : '%d días',
  25243. M : 'un mes',
  25244. MM : '%d meses',
  25245. y : 'un año',
  25246. yy : '%d años'
  25247. },
  25248. dayOfMonthOrdinalParse : /\d{1,2}º/,
  25249. ordinal : '%dº',
  25250. week : {
  25251. dow : 1, // Monday is the first day of the week.
  25252. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25253. }
  25254. });
  25255. //! moment.js locale configuration
  25256. //! locale : Estonian [et]
  25257. //! author : Henry Kehlmann : https://github.com/madhenry
  25258. //! improvements : Illimar Tambek : https://github.com/ragulka
  25259. function processRelativeTime$3(number, withoutSuffix, key, isFuture) {
  25260. var format = {
  25261. 's' : ['mõne sekundi', 'mõni sekund', 'paar sekundit'],
  25262. 'm' : ['ühe minuti', 'üks minut'],
  25263. 'mm': [number + ' minuti', number + ' minutit'],
  25264. 'h' : ['ühe tunni', 'tund aega', 'üks tund'],
  25265. 'hh': [number + ' tunni', number + ' tundi'],
  25266. 'd' : ['ühe päeva', 'üks päev'],
  25267. 'M' : ['kuu aja', 'kuu aega', 'üks kuu'],
  25268. 'MM': [number + ' kuu', number + ' kuud'],
  25269. 'y' : ['ühe aasta', 'aasta', 'üks aasta'],
  25270. 'yy': [number + ' aasta', number + ' aastat']
  25271. };
  25272. if (withoutSuffix) {
  25273. return format[key][2] ? format[key][2] : format[key][1];
  25274. }
  25275. return isFuture ? format[key][0] : format[key][1];
  25276. }
  25277. hooks.defineLocale('et', {
  25278. months : 'jaanuar_veebruar_märts_aprill_mai_juuni_juuli_august_september_oktoober_november_detsember'.split('_'),
  25279. monthsShort : 'jaan_veebr_märts_apr_mai_juuni_juuli_aug_sept_okt_nov_dets'.split('_'),
  25280. weekdays : 'pühapäev_esmaspäev_teisipäev_kolmapäev_neljapäev_reede_laupäev'.split('_'),
  25281. weekdaysShort : 'P_E_T_K_N_R_L'.split('_'),
  25282. weekdaysMin : 'P_E_T_K_N_R_L'.split('_'),
  25283. longDateFormat : {
  25284. LT : 'H:mm',
  25285. LTS : 'H:mm:ss',
  25286. L : 'DD.MM.YYYY',
  25287. LL : 'D. MMMM YYYY',
  25288. LLL : 'D. MMMM YYYY H:mm',
  25289. LLLL : 'dddd, D. MMMM YYYY H:mm'
  25290. },
  25291. calendar : {
  25292. sameDay : '[Täna,] LT',
  25293. nextDay : '[Homme,] LT',
  25294. nextWeek : '[Järgmine] dddd LT',
  25295. lastDay : '[Eile,] LT',
  25296. lastWeek : '[Eelmine] dddd LT',
  25297. sameElse : 'L'
  25298. },
  25299. relativeTime : {
  25300. future : '%s pärast',
  25301. past : '%s tagasi',
  25302. s : processRelativeTime$3,
  25303. m : processRelativeTime$3,
  25304. mm : processRelativeTime$3,
  25305. h : processRelativeTime$3,
  25306. hh : processRelativeTime$3,
  25307. d : processRelativeTime$3,
  25308. dd : '%d päeva',
  25309. M : processRelativeTime$3,
  25310. MM : processRelativeTime$3,
  25311. y : processRelativeTime$3,
  25312. yy : processRelativeTime$3
  25313. },
  25314. dayOfMonthOrdinalParse: /\d{1,2}\./,
  25315. ordinal : '%d.',
  25316. week : {
  25317. dow : 1, // Monday is the first day of the week.
  25318. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25319. }
  25320. });
  25321. //! moment.js locale configuration
  25322. //! locale : Basque [eu]
  25323. //! author : Eneko Illarramendi : https://github.com/eillarra
  25324. hooks.defineLocale('eu', {
  25325. months : 'urtarrila_otsaila_martxoa_apirila_maiatza_ekaina_uztaila_abuztua_iraila_urria_azaroa_abendua'.split('_'),
  25326. monthsShort : 'urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.'.split('_'),
  25327. monthsParseExact : true,
  25328. weekdays : 'igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata'.split('_'),
  25329. weekdaysShort : 'ig._al._ar._az._og._ol._lr.'.split('_'),
  25330. weekdaysMin : 'ig_al_ar_az_og_ol_lr'.split('_'),
  25331. weekdaysParseExact : true,
  25332. longDateFormat : {
  25333. LT : 'HH:mm',
  25334. LTS : 'HH:mm:ss',
  25335. L : 'YYYY-MM-DD',
  25336. LL : 'YYYY[ko] MMMM[ren] D[a]',
  25337. LLL : 'YYYY[ko] MMMM[ren] D[a] HH:mm',
  25338. LLLL : 'dddd, YYYY[ko] MMMM[ren] D[a] HH:mm',
  25339. l : 'YYYY-M-D',
  25340. ll : 'YYYY[ko] MMM D[a]',
  25341. lll : 'YYYY[ko] MMM D[a] HH:mm',
  25342. llll : 'ddd, YYYY[ko] MMM D[a] HH:mm'
  25343. },
  25344. calendar : {
  25345. sameDay : '[gaur] LT[etan]',
  25346. nextDay : '[bihar] LT[etan]',
  25347. nextWeek : 'dddd LT[etan]',
  25348. lastDay : '[atzo] LT[etan]',
  25349. lastWeek : '[aurreko] dddd LT[etan]',
  25350. sameElse : 'L'
  25351. },
  25352. relativeTime : {
  25353. future : '%s barru',
  25354. past : 'duela %s',
  25355. s : 'segundo batzuk',
  25356. m : 'minutu bat',
  25357. mm : '%d minutu',
  25358. h : 'ordu bat',
  25359. hh : '%d ordu',
  25360. d : 'egun bat',
  25361. dd : '%d egun',
  25362. M : 'hilabete bat',
  25363. MM : '%d hilabete',
  25364. y : 'urte bat',
  25365. yy : '%d urte'
  25366. },
  25367. dayOfMonthOrdinalParse: /\d{1,2}\./,
  25368. ordinal : '%d.',
  25369. week : {
  25370. dow : 1, // Monday is the first day of the week.
  25371. doy : 7 // The week that contains Jan 1st is the first week of the year.
  25372. }
  25373. });
  25374. //! moment.js locale configuration
  25375. //! locale : Persian [fa]
  25376. //! author : Ebrahim Byagowi : https://github.com/ebraminio
  25377. var symbolMap$5 = {
  25378. '1': '۱',
  25379. '2': '۲',
  25380. '3': '۳',
  25381. '4': '۴',
  25382. '5': '۵',
  25383. '6': '۶',
  25384. '7': '۷',
  25385. '8': '۸',
  25386. '9': '۹',
  25387. '0': '۰'
  25388. };
  25389. var numberMap$4 = {
  25390. '۱': '1',
  25391. '۲': '2',
  25392. '۳': '3',
  25393. '۴': '4',
  25394. '۵': '5',
  25395. '۶': '6',
  25396. '۷': '7',
  25397. '۸': '8',
  25398. '۹': '9',
  25399. '۰': '0'
  25400. };
  25401. hooks.defineLocale('fa', {
  25402. months : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
  25403. monthsShort : 'ژانویه_فوریه_مارس_آوریل_مه_ژوئن_ژوئیه_اوت_سپتامبر_اکتبر_نوامبر_دسامبر'.split('_'),
  25404. weekdays : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
  25405. weekdaysShort : 'یک\u200cشنبه_دوشنبه_سه\u200cشنبه_چهارشنبه_پنج\u200cشنبه_جمعه_شنبه'.split('_'),
  25406. weekdaysMin : 'ی_د_س_چ_پ_ج_ش'.split('_'),
  25407. weekdaysParseExact : true,
  25408. longDateFormat : {
  25409. LT : 'HH:mm',
  25410. LTS : 'HH:mm:ss',
  25411. L : 'DD/MM/YYYY',
  25412. LL : 'D MMMM YYYY',
  25413. LLL : 'D MMMM YYYY HH:mm',
  25414. LLLL : 'dddd, D MMMM YYYY HH:mm'
  25415. },
  25416. meridiemParse: /قبل از ظهر|بعد از ظهر/,
  25417. isPM: function (input) {
  25418. return /بعد از ظهر/.test(input);
  25419. },
  25420. meridiem : function (hour, minute, isLower) {
  25421. if (hour < 12) {
  25422. return 'قبل از ظهر';
  25423. } else {
  25424. return 'بعد از ظهر';
  25425. }
  25426. },
  25427. calendar : {
  25428. sameDay : '[امروز ساعت] LT',
  25429. nextDay : '[فردا ساعت] LT',
  25430. nextWeek : 'dddd [ساعت] LT',
  25431. lastDay : '[دیروز ساعت] LT',
  25432. lastWeek : 'dddd [پیش] [ساعت] LT',
  25433. sameElse : 'L'
  25434. },
  25435. relativeTime : {
  25436. future : 'در %s',
  25437. past : '%s پیش',
  25438. s : 'چند ثانیه',
  25439. m : 'یک دقیقه',
  25440. mm : '%d دقیقه',
  25441. h : 'یک ساعت',
  25442. hh : '%d ساعت',
  25443. d : 'یک روز',
  25444. dd : '%d روز',
  25445. M : 'یک ماه',
  25446. MM : '%d ماه',
  25447. y : 'یک سال',
  25448. yy : '%d سال'
  25449. },
  25450. preparse: function (string) {
  25451. return string.replace(/[۰-۹]/g, function (match) {
  25452. return numberMap$4[match];
  25453. }).replace(/،/g, ',');
  25454. },
  25455. postformat: function (string) {
  25456. return string.replace(/\d/g, function (match) {
  25457. return symbolMap$5[match];
  25458. }).replace(/,/g, '،');
  25459. },
  25460. dayOfMonthOrdinalParse: /\d{1,2}م/,
  25461. ordinal : '%dم',
  25462. week : {
  25463. dow : 6, // Saturday is the first day of the week.
  25464. doy : 12 // The week that contains Jan 1st is the first week of the year.
  25465. }
  25466. });
  25467. //! moment.js locale configuration
  25468. //! locale : Finnish [fi]
  25469. //! author : Tarmo Aidantausta : https://github.com/bleadof
  25470. var numbersPast = 'nolla yksi kaksi kolme neljä viisi kuusi seitsemän kahdeksan yhdeksän'.split(' ');
  25471. var numbersFuture = [
  25472. 'nolla', 'yhden', 'kahden', 'kolmen', 'neljän', 'viiden', 'kuuden',
  25473. numbersPast[7], numbersPast[8], numbersPast[9]
  25474. ];
  25475. function translate$2(number, withoutSuffix, key, isFuture) {
  25476. var result = '';
  25477. switch (key) {
  25478. case 's':
  25479. return isFuture ? 'muutaman sekunnin' : 'muutama sekunti';
  25480. case 'm':
  25481. return isFuture ? 'minuutin' : 'minuutti';
  25482. case 'mm':
  25483. result = isFuture ? 'minuutin' : 'minuuttia';
  25484. break;
  25485. case 'h':
  25486. return isFuture ? 'tunnin' : 'tunti';
  25487. case 'hh':
  25488. result = isFuture ? 'tunnin' : 'tuntia';
  25489. break;
  25490. case 'd':
  25491. return isFuture ? 'päivän' : 'päivä';
  25492. case 'dd':
  25493. result = isFuture ? 'päivän' : 'päivää';
  25494. break;
  25495. case 'M':
  25496. return isFuture ? 'kuukauden' : 'kuukausi';
  25497. case 'MM':
  25498. result = isFuture ? 'kuukauden' : 'kuukautta';
  25499. break;
  25500. case 'y':
  25501. return isFuture ? 'vuoden' : 'vuosi';
  25502. case 'yy':
  25503. result = isFuture ? 'vuoden' : 'vuotta';
  25504. break;
  25505. }
  25506. result = verbalNumber(number, isFuture) + ' ' + result;
  25507. return result;
  25508. }
  25509. function verbalNumber(number, isFuture) {
  25510. return number < 10 ? (isFuture ? numbersFuture[number] : numbersPast[number]) : number;
  25511. }
  25512. hooks.defineLocale('fi', {
  25513. months : 'tammikuu_helmikuu_maaliskuu_huhtikuu_toukokuu_kesäkuu_heinäkuu_elokuu_syyskuu_lokakuu_marraskuu_joulukuu'.split('_'),
  25514. monthsShort : 'tammi_helmi_maalis_huhti_touko_kesä_heinä_elo_syys_loka_marras_joulu'.split('_'),
  25515. weekdays : 'sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai'.split('_'),
  25516. weekdaysShort : 'su_ma_ti_ke_to_pe_la'.split('_'),
  25517. weekdaysMin : 'su_ma_ti_ke_to_pe_la'.split('_'),
  25518. longDateFormat : {
  25519. LT : 'HH.mm',
  25520. LTS : 'HH.mm.ss',
  25521. L : 'DD.MM.YYYY',
  25522. LL : 'Do MMMM[ta] YYYY',
  25523. LLL : 'Do MMMM[ta] YYYY, [klo] HH.mm',
  25524. LLLL : 'dddd, Do MMMM[ta] YYYY, [klo] HH.mm',
  25525. l : 'D.M.YYYY',
  25526. ll : 'Do MMM YYYY',
  25527. lll : 'Do MMM YYYY, [klo] HH.mm',
  25528. llll : 'ddd, Do MMM YYYY, [klo] HH.mm'
  25529. },
  25530. calendar : {
  25531. sameDay : '[tänään] [klo] LT',
  25532. nextDay : '[huomenna] [klo] LT',
  25533. nextWeek : 'dddd [klo] LT',
  25534. lastDay : '[eilen] [klo] LT',
  25535. lastWeek : '[viime] dddd[na] [klo] LT',
  25536. sameElse : 'L'
  25537. },
  25538. relativeTime : {
  25539. future : '%s päästä',
  25540. past : '%s sitten',
  25541. s : translate$2,
  25542. m : translate$2,
  25543. mm : translate$2,
  25544. h : translate$2,
  25545. hh : translate$2,
  25546. d : translate$2,
  25547. dd : translate$2,
  25548. M : translate$2,
  25549. MM : translate$2,
  25550. y : translate$2,
  25551. yy : translate$2
  25552. },
  25553. dayOfMonthOrdinalParse: /\d{1,2}\./,
  25554. ordinal : '%d.',
  25555. week : {
  25556. dow : 1, // Monday is the first day of the week.
  25557. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25558. }
  25559. });
  25560. //! moment.js locale configuration
  25561. //! locale : Faroese [fo]
  25562. //! author : Ragnar Johannesen : https://github.com/ragnar123
  25563. hooks.defineLocale('fo', {
  25564. months : 'januar_februar_mars_apríl_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
  25565. monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
  25566. weekdays : 'sunnudagur_mánadagur_týsdagur_mikudagur_hósdagur_fríggjadagur_leygardagur'.split('_'),
  25567. weekdaysShort : 'sun_mán_týs_mik_hós_frí_ley'.split('_'),
  25568. weekdaysMin : 'su_má_tý_mi_hó_fr_le'.split('_'),
  25569. longDateFormat : {
  25570. LT : 'HH:mm',
  25571. LTS : 'HH:mm:ss',
  25572. L : 'DD/MM/YYYY',
  25573. LL : 'D MMMM YYYY',
  25574. LLL : 'D MMMM YYYY HH:mm',
  25575. LLLL : 'dddd D. MMMM, YYYY HH:mm'
  25576. },
  25577. calendar : {
  25578. sameDay : '[Í dag kl.] LT',
  25579. nextDay : '[Í morgin kl.] LT',
  25580. nextWeek : 'dddd [kl.] LT',
  25581. lastDay : '[Í gjár kl.] LT',
  25582. lastWeek : '[síðstu] dddd [kl] LT',
  25583. sameElse : 'L'
  25584. },
  25585. relativeTime : {
  25586. future : 'um %s',
  25587. past : '%s síðani',
  25588. s : 'fá sekund',
  25589. m : 'ein minutt',
  25590. mm : '%d minuttir',
  25591. h : 'ein tími',
  25592. hh : '%d tímar',
  25593. d : 'ein dagur',
  25594. dd : '%d dagar',
  25595. M : 'ein mánaði',
  25596. MM : '%d mánaðir',
  25597. y : 'eitt ár',
  25598. yy : '%d ár'
  25599. },
  25600. dayOfMonthOrdinalParse: /\d{1,2}\./,
  25601. ordinal : '%d.',
  25602. week : {
  25603. dow : 1, // Monday is the first day of the week.
  25604. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25605. }
  25606. });
  25607. //! moment.js locale configuration
  25608. //! locale : French (Canada) [fr-ca]
  25609. //! author : Jonathan Abourbih : https://github.com/jonbca
  25610. hooks.defineLocale('fr-ca', {
  25611. months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
  25612. monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
  25613. monthsParseExact : true,
  25614. weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
  25615. weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
  25616. weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
  25617. weekdaysParseExact : true,
  25618. longDateFormat : {
  25619. LT : 'HH:mm',
  25620. LTS : 'HH:mm:ss',
  25621. L : 'YYYY-MM-DD',
  25622. LL : 'D MMMM YYYY',
  25623. LLL : 'D MMMM YYYY HH:mm',
  25624. LLLL : 'dddd D MMMM YYYY HH:mm'
  25625. },
  25626. calendar : {
  25627. sameDay : '[Aujourd’hui à] LT',
  25628. nextDay : '[Demain à] LT',
  25629. nextWeek : 'dddd [à] LT',
  25630. lastDay : '[Hier à] LT',
  25631. lastWeek : 'dddd [dernier à] LT',
  25632. sameElse : 'L'
  25633. },
  25634. relativeTime : {
  25635. future : 'dans %s',
  25636. past : 'il y a %s',
  25637. s : 'quelques secondes',
  25638. m : 'une minute',
  25639. mm : '%d minutes',
  25640. h : 'une heure',
  25641. hh : '%d heures',
  25642. d : 'un jour',
  25643. dd : '%d jours',
  25644. M : 'un mois',
  25645. MM : '%d mois',
  25646. y : 'un an',
  25647. yy : '%d ans'
  25648. },
  25649. dayOfMonthOrdinalParse: /\d{1,2}(er|e)/,
  25650. ordinal : function (number, period) {
  25651. switch (period) {
  25652. // Words with masculine grammatical gender: mois, trimestre, jour
  25653. default:
  25654. case 'M':
  25655. case 'Q':
  25656. case 'D':
  25657. case 'DDD':
  25658. case 'd':
  25659. return number + (number === 1 ? 'er' : 'e');
  25660. // Words with feminine grammatical gender: semaine
  25661. case 'w':
  25662. case 'W':
  25663. return number + (number === 1 ? 're' : 'e');
  25664. }
  25665. }
  25666. });
  25667. //! moment.js locale configuration
  25668. //! locale : French (Switzerland) [fr-ch]
  25669. //! author : Gaspard Bucher : https://github.com/gaspard
  25670. hooks.defineLocale('fr-ch', {
  25671. months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
  25672. monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
  25673. monthsParseExact : true,
  25674. weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
  25675. weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
  25676. weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
  25677. weekdaysParseExact : true,
  25678. longDateFormat : {
  25679. LT : 'HH:mm',
  25680. LTS : 'HH:mm:ss',
  25681. L : 'DD.MM.YYYY',
  25682. LL : 'D MMMM YYYY',
  25683. LLL : 'D MMMM YYYY HH:mm',
  25684. LLLL : 'dddd D MMMM YYYY HH:mm'
  25685. },
  25686. calendar : {
  25687. sameDay : '[Aujourd’hui à] LT',
  25688. nextDay : '[Demain à] LT',
  25689. nextWeek : 'dddd [à] LT',
  25690. lastDay : '[Hier à] LT',
  25691. lastWeek : 'dddd [dernier à] LT',
  25692. sameElse : 'L'
  25693. },
  25694. relativeTime : {
  25695. future : 'dans %s',
  25696. past : 'il y a %s',
  25697. s : 'quelques secondes',
  25698. m : 'une minute',
  25699. mm : '%d minutes',
  25700. h : 'une heure',
  25701. hh : '%d heures',
  25702. d : 'un jour',
  25703. dd : '%d jours',
  25704. M : 'un mois',
  25705. MM : '%d mois',
  25706. y : 'un an',
  25707. yy : '%d ans'
  25708. },
  25709. dayOfMonthOrdinalParse: /\d{1,2}(er|e)/,
  25710. ordinal : function (number, period) {
  25711. switch (period) {
  25712. // Words with masculine grammatical gender: mois, trimestre, jour
  25713. default:
  25714. case 'M':
  25715. case 'Q':
  25716. case 'D':
  25717. case 'DDD':
  25718. case 'd':
  25719. return number + (number === 1 ? 'er' : 'e');
  25720. // Words with feminine grammatical gender: semaine
  25721. case 'w':
  25722. case 'W':
  25723. return number + (number === 1 ? 're' : 'e');
  25724. }
  25725. },
  25726. week : {
  25727. dow : 1, // Monday is the first day of the week.
  25728. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25729. }
  25730. });
  25731. //! moment.js locale configuration
  25732. //! locale : French [fr]
  25733. //! author : John Fischer : https://github.com/jfroffice
  25734. hooks.defineLocale('fr', {
  25735. months : 'janvier_février_mars_avril_mai_juin_juillet_août_septembre_octobre_novembre_décembre'.split('_'),
  25736. monthsShort : 'janv._févr._mars_avr._mai_juin_juil._août_sept._oct._nov._déc.'.split('_'),
  25737. monthsParseExact : true,
  25738. weekdays : 'dimanche_lundi_mardi_mercredi_jeudi_vendredi_samedi'.split('_'),
  25739. weekdaysShort : 'dim._lun._mar._mer._jeu._ven._sam.'.split('_'),
  25740. weekdaysMin : 'Di_Lu_Ma_Me_Je_Ve_Sa'.split('_'),
  25741. weekdaysParseExact : true,
  25742. longDateFormat : {
  25743. LT : 'HH:mm',
  25744. LTS : 'HH:mm:ss',
  25745. L : 'DD/MM/YYYY',
  25746. LL : 'D MMMM YYYY',
  25747. LLL : 'D MMMM YYYY HH:mm',
  25748. LLLL : 'dddd D MMMM YYYY HH:mm'
  25749. },
  25750. calendar : {
  25751. sameDay : '[Aujourd’hui à] LT',
  25752. nextDay : '[Demain à] LT',
  25753. nextWeek : 'dddd [à] LT',
  25754. lastDay : '[Hier à] LT',
  25755. lastWeek : 'dddd [dernier à] LT',
  25756. sameElse : 'L'
  25757. },
  25758. relativeTime : {
  25759. future : 'dans %s',
  25760. past : 'il y a %s',
  25761. s : 'quelques secondes',
  25762. m : 'une minute',
  25763. mm : '%d minutes',
  25764. h : 'une heure',
  25765. hh : '%d heures',
  25766. d : 'un jour',
  25767. dd : '%d jours',
  25768. M : 'un mois',
  25769. MM : '%d mois',
  25770. y : 'un an',
  25771. yy : '%d ans'
  25772. },
  25773. dayOfMonthOrdinalParse: /\d{1,2}(er|)/,
  25774. ordinal : function (number, period) {
  25775. switch (period) {
  25776. // TODO: Return 'e' when day of month > 1. Move this case inside
  25777. // block for masculine words below.
  25778. // See https://github.com/moment/moment/issues/3375
  25779. case 'D':
  25780. return number + (number === 1 ? 'er' : '');
  25781. // Words with masculine grammatical gender: mois, trimestre, jour
  25782. default:
  25783. case 'M':
  25784. case 'Q':
  25785. case 'DDD':
  25786. case 'd':
  25787. return number + (number === 1 ? 'er' : 'e');
  25788. // Words with feminine grammatical gender: semaine
  25789. case 'w':
  25790. case 'W':
  25791. return number + (number === 1 ? 're' : 'e');
  25792. }
  25793. },
  25794. week : {
  25795. dow : 1, // Monday is the first day of the week.
  25796. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25797. }
  25798. });
  25799. //! moment.js locale configuration
  25800. //! locale : Frisian [fy]
  25801. //! author : Robin van der Vliet : https://github.com/robin0van0der0v
  25802. var monthsShortWithDots = 'jan._feb._mrt._apr._mai_jun._jul._aug._sep._okt._nov._des.'.split('_');
  25803. var monthsShortWithoutDots = 'jan_feb_mrt_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_');
  25804. hooks.defineLocale('fy', {
  25805. months : 'jannewaris_febrewaris_maart_april_maaie_juny_july_augustus_septimber_oktober_novimber_desimber'.split('_'),
  25806. monthsShort : function (m, format) {
  25807. if (!m) {
  25808. return monthsShortWithDots;
  25809. } else if (/-MMM-/.test(format)) {
  25810. return monthsShortWithoutDots[m.month()];
  25811. } else {
  25812. return monthsShortWithDots[m.month()];
  25813. }
  25814. },
  25815. monthsParseExact : true,
  25816. weekdays : 'snein_moandei_tiisdei_woansdei_tongersdei_freed_sneon'.split('_'),
  25817. weekdaysShort : 'si._mo._ti._wo._to._fr._so.'.split('_'),
  25818. weekdaysMin : 'Si_Mo_Ti_Wo_To_Fr_So'.split('_'),
  25819. weekdaysParseExact : true,
  25820. longDateFormat : {
  25821. LT : 'HH:mm',
  25822. LTS : 'HH:mm:ss',
  25823. L : 'DD-MM-YYYY',
  25824. LL : 'D MMMM YYYY',
  25825. LLL : 'D MMMM YYYY HH:mm',
  25826. LLLL : 'dddd D MMMM YYYY HH:mm'
  25827. },
  25828. calendar : {
  25829. sameDay: '[hjoed om] LT',
  25830. nextDay: '[moarn om] LT',
  25831. nextWeek: 'dddd [om] LT',
  25832. lastDay: '[juster om] LT',
  25833. lastWeek: '[ôfrûne] dddd [om] LT',
  25834. sameElse: 'L'
  25835. },
  25836. relativeTime : {
  25837. future : 'oer %s',
  25838. past : '%s lyn',
  25839. s : 'in pear sekonden',
  25840. m : 'ien minút',
  25841. mm : '%d minuten',
  25842. h : 'ien oere',
  25843. hh : '%d oeren',
  25844. d : 'ien dei',
  25845. dd : '%d dagen',
  25846. M : 'ien moanne',
  25847. MM : '%d moannen',
  25848. y : 'ien jier',
  25849. yy : '%d jierren'
  25850. },
  25851. dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
  25852. ordinal : function (number) {
  25853. return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
  25854. },
  25855. week : {
  25856. dow : 1, // Monday is the first day of the week.
  25857. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25858. }
  25859. });
  25860. //! moment.js locale configuration
  25861. //! locale : Scottish Gaelic [gd]
  25862. //! author : Jon Ashdown : https://github.com/jonashdown
  25863. var months$5 = [
  25864. 'Am Faoilleach', 'An Gearran', 'Am Màrt', 'An Giblean', 'An Cèitean', 'An t-Ògmhios', 'An t-Iuchar', 'An Lùnastal', 'An t-Sultain', 'An Dàmhair', 'An t-Samhain', 'An Dùbhlachd'
  25865. ];
  25866. var monthsShort$4 = ['Faoi', 'Gear', 'Màrt', 'Gibl', 'Cèit', 'Ògmh', 'Iuch', 'Lùn', 'Sult', 'Dàmh', 'Samh', 'Dùbh'];
  25867. var weekdays$1 = ['Didòmhnaich', 'Diluain', 'Dimàirt', 'Diciadain', 'Diardaoin', 'Dihaoine', 'Disathairne'];
  25868. var weekdaysShort = ['Did', 'Dil', 'Dim', 'Dic', 'Dia', 'Dih', 'Dis'];
  25869. var weekdaysMin = ['Dò', 'Lu', 'Mà', 'Ci', 'Ar', 'Ha', 'Sa'];
  25870. hooks.defineLocale('gd', {
  25871. months : months$5,
  25872. monthsShort : monthsShort$4,
  25873. monthsParseExact : true,
  25874. weekdays : weekdays$1,
  25875. weekdaysShort : weekdaysShort,
  25876. weekdaysMin : weekdaysMin,
  25877. longDateFormat : {
  25878. LT : 'HH:mm',
  25879. LTS : 'HH:mm:ss',
  25880. L : 'DD/MM/YYYY',
  25881. LL : 'D MMMM YYYY',
  25882. LLL : 'D MMMM YYYY HH:mm',
  25883. LLLL : 'dddd, D MMMM YYYY HH:mm'
  25884. },
  25885. calendar : {
  25886. sameDay : '[An-diugh aig] LT',
  25887. nextDay : '[A-màireach aig] LT',
  25888. nextWeek : 'dddd [aig] LT',
  25889. lastDay : '[An-dè aig] LT',
  25890. lastWeek : 'dddd [seo chaidh] [aig] LT',
  25891. sameElse : 'L'
  25892. },
  25893. relativeTime : {
  25894. future : 'ann an %s',
  25895. past : 'bho chionn %s',
  25896. s : 'beagan diogan',
  25897. m : 'mionaid',
  25898. mm : '%d mionaidean',
  25899. h : 'uair',
  25900. hh : '%d uairean',
  25901. d : 'latha',
  25902. dd : '%d latha',
  25903. M : 'mìos',
  25904. MM : '%d mìosan',
  25905. y : 'bliadhna',
  25906. yy : '%d bliadhna'
  25907. },
  25908. dayOfMonthOrdinalParse : /\d{1,2}(d|na|mh)/,
  25909. ordinal : function (number) {
  25910. var output = number === 1 ? 'd' : number % 10 === 2 ? 'na' : 'mh';
  25911. return number + output;
  25912. },
  25913. week : {
  25914. dow : 1, // Monday is the first day of the week.
  25915. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25916. }
  25917. });
  25918. //! moment.js locale configuration
  25919. //! locale : Galician [gl]
  25920. //! author : Juan G. Hurtado : https://github.com/juanghurtado
  25921. hooks.defineLocale('gl', {
  25922. months : 'xaneiro_febreiro_marzo_abril_maio_xuño_xullo_agosto_setembro_outubro_novembro_decembro'.split('_'),
  25923. monthsShort : 'xan._feb._mar._abr._mai._xuñ._xul._ago._set._out._nov._dec.'.split('_'),
  25924. monthsParseExact: true,
  25925. weekdays : 'domingo_luns_martes_mércores_xoves_venres_sábado'.split('_'),
  25926. weekdaysShort : 'dom._lun._mar._mér._xov._ven._sáb.'.split('_'),
  25927. weekdaysMin : 'do_lu_ma_mé_xo_ve_sá'.split('_'),
  25928. weekdaysParseExact : true,
  25929. longDateFormat : {
  25930. LT : 'H:mm',
  25931. LTS : 'H:mm:ss',
  25932. L : 'DD/MM/YYYY',
  25933. LL : 'D [de] MMMM [de] YYYY',
  25934. LLL : 'D [de] MMMM [de] YYYY H:mm',
  25935. LLLL : 'dddd, D [de] MMMM [de] YYYY H:mm'
  25936. },
  25937. calendar : {
  25938. sameDay : function () {
  25939. return '[hoxe ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
  25940. },
  25941. nextDay : function () {
  25942. return '[mañá ' + ((this.hours() !== 1) ? 'ás' : 'á') + '] LT';
  25943. },
  25944. nextWeek : function () {
  25945. return 'dddd [' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
  25946. },
  25947. lastDay : function () {
  25948. return '[onte ' + ((this.hours() !== 1) ? 'á' : 'a') + '] LT';
  25949. },
  25950. lastWeek : function () {
  25951. return '[o] dddd [pasado ' + ((this.hours() !== 1) ? 'ás' : 'a') + '] LT';
  25952. },
  25953. sameElse : 'L'
  25954. },
  25955. relativeTime : {
  25956. future : function (str) {
  25957. if (str.indexOf('un') === 0) {
  25958. return 'n' + str;
  25959. }
  25960. return 'en ' + str;
  25961. },
  25962. past : 'hai %s',
  25963. s : 'uns segundos',
  25964. m : 'un minuto',
  25965. mm : '%d minutos',
  25966. h : 'unha hora',
  25967. hh : '%d horas',
  25968. d : 'un día',
  25969. dd : '%d días',
  25970. M : 'un mes',
  25971. MM : '%d meses',
  25972. y : 'un ano',
  25973. yy : '%d anos'
  25974. },
  25975. dayOfMonthOrdinalParse : /\d{1,2}º/,
  25976. ordinal : '%dº',
  25977. week : {
  25978. dow : 1, // Monday is the first day of the week.
  25979. doy : 4 // The week that contains Jan 4th is the first week of the year.
  25980. }
  25981. });
  25982. //! moment.js locale configuration
  25983. //! locale : Konkani Latin script [gom-latn]
  25984. //! author : The Discoverer : https://github.com/WikiDiscoverer
  25985. function processRelativeTime$4(number, withoutSuffix, key, isFuture) {
  25986. var format = {
  25987. 's': ['thodde secondanim', 'thodde second'],
  25988. 'm': ['eka mintan', 'ek minute'],
  25989. 'mm': [number + ' mintanim', number + ' mintam'],
  25990. 'h': ['eka horan', 'ek hor'],
  25991. 'hh': [number + ' horanim', number + ' hor'],
  25992. 'd': ['eka disan', 'ek dis'],
  25993. 'dd': [number + ' disanim', number + ' dis'],
  25994. 'M': ['eka mhoinean', 'ek mhoino'],
  25995. 'MM': [number + ' mhoineanim', number + ' mhoine'],
  25996. 'y': ['eka vorsan', 'ek voros'],
  25997. 'yy': [number + ' vorsanim', number + ' vorsam']
  25998. };
  25999. return withoutSuffix ? format[key][0] : format[key][1];
  26000. }
  26001. hooks.defineLocale('gom-latn', {
  26002. months : 'Janer_Febrer_Mars_Abril_Mai_Jun_Julai_Agost_Setembr_Otubr_Novembr_Dezembr'.split('_'),
  26003. monthsShort : 'Jan._Feb._Mars_Abr._Mai_Jun_Jul._Ago._Set._Otu._Nov._Dez.'.split('_'),
  26004. monthsParseExact : true,
  26005. weekdays : 'Aitar_Somar_Mongllar_Budvar_Brestar_Sukrar_Son\'var'.split('_'),
  26006. weekdaysShort : 'Ait._Som._Mon._Bud._Bre._Suk._Son.'.split('_'),
  26007. weekdaysMin : 'Ai_Sm_Mo_Bu_Br_Su_Sn'.split('_'),
  26008. weekdaysParseExact : true,
  26009. longDateFormat : {
  26010. LT : 'A h:mm [vazta]',
  26011. LTS : 'A h:mm:ss [vazta]',
  26012. L : 'DD-MM-YYYY',
  26013. LL : 'D MMMM YYYY',
  26014. LLL : 'D MMMM YYYY A h:mm [vazta]',
  26015. LLLL : 'dddd, MMMM[achea] Do, YYYY, A h:mm [vazta]',
  26016. llll: 'ddd, D MMM YYYY, A h:mm [vazta]'
  26017. },
  26018. calendar : {
  26019. sameDay: '[Aiz] LT',
  26020. nextDay: '[Faleam] LT',
  26021. nextWeek: '[Ieta to] dddd[,] LT',
  26022. lastDay: '[Kal] LT',
  26023. lastWeek: '[Fatlo] dddd[,] LT',
  26024. sameElse: 'L'
  26025. },
  26026. relativeTime : {
  26027. future : '%s',
  26028. past : '%s adim',
  26029. s : processRelativeTime$4,
  26030. m : processRelativeTime$4,
  26031. mm : processRelativeTime$4,
  26032. h : processRelativeTime$4,
  26033. hh : processRelativeTime$4,
  26034. d : processRelativeTime$4,
  26035. dd : processRelativeTime$4,
  26036. M : processRelativeTime$4,
  26037. MM : processRelativeTime$4,
  26038. y : processRelativeTime$4,
  26039. yy : processRelativeTime$4
  26040. },
  26041. dayOfMonthOrdinalParse : /\d{1,2}(er)/,
  26042. ordinal : function (number, period) {
  26043. switch (period) {
  26044. // the ordinal 'er' only applies to day of the month
  26045. case 'D':
  26046. return number + 'er';
  26047. default:
  26048. case 'M':
  26049. case 'Q':
  26050. case 'DDD':
  26051. case 'd':
  26052. case 'w':
  26053. case 'W':
  26054. return number;
  26055. }
  26056. },
  26057. week : {
  26058. dow : 1, // Monday is the first day of the week.
  26059. doy : 4 // The week that contains Jan 4th is the first week of the year.
  26060. },
  26061. meridiemParse: /rati|sokalli|donparam|sanje/,
  26062. meridiemHour : function (hour, meridiem) {
  26063. if (hour === 12) {
  26064. hour = 0;
  26065. }
  26066. if (meridiem === 'rati') {
  26067. return hour < 4 ? hour : hour + 12;
  26068. } else if (meridiem === 'sokalli') {
  26069. return hour;
  26070. } else if (meridiem === 'donparam') {
  26071. return hour > 12 ? hour : hour + 12;
  26072. } else if (meridiem === 'sanje') {
  26073. return hour + 12;
  26074. }
  26075. },
  26076. meridiem : function (hour, minute, isLower) {
  26077. if (hour < 4) {
  26078. return 'rati';
  26079. } else if (hour < 12) {
  26080. return 'sokalli';
  26081. } else if (hour < 16) {
  26082. return 'donparam';
  26083. } else if (hour < 20) {
  26084. return 'sanje';
  26085. } else {
  26086. return 'rati';
  26087. }
  26088. }
  26089. });
  26090. //! moment.js locale configuration
  26091. //! locale : Gujarati [gu]
  26092. //! author : Kaushik Thanki : https://github.com/Kaushik1987
  26093. var symbolMap$6 = {
  26094. '1': '૧',
  26095. '2': '૨',
  26096. '3': '૩',
  26097. '4': '૪',
  26098. '5': '૫',
  26099. '6': '૬',
  26100. '7': '૭',
  26101. '8': '૮',
  26102. '9': '૯',
  26103. '0': '૦'
  26104. };
  26105. var numberMap$5 = {
  26106. '૧': '1',
  26107. '૨': '2',
  26108. '૩': '3',
  26109. '૪': '4',
  26110. '૫': '5',
  26111. '૬': '6',
  26112. '૭': '7',
  26113. '૮': '8',
  26114. '૯': '9',
  26115. '૦': '0'
  26116. };
  26117. hooks.defineLocale('gu', {
  26118. months: 'જાન્યુઆરી_ફેબ્રુઆરી_માર્ચ_એપ્રિલ_મે_જૂન_જુલાઈ_ઑગસ્ટ_સપ્ટેમ્બર_ઑક્ટ્બર_નવેમ્બર_ડિસેમ્બર'.split('_'),
  26119. monthsShort: 'જાન્યુ._ફેબ્રુ._માર્ચ_એપ્રિ._મે_જૂન_જુલા._ઑગ._સપ્ટે._ઑક્ટ્._નવે._ડિસે.'.split('_'),
  26120. monthsParseExact: true,
  26121. weekdays: 'રવિવાર_સોમવાર_મંગળવાર_બુધ્વાર_ગુરુવાર_શુક્રવાર_શનિવાર'.split('_'),
  26122. weekdaysShort: 'રવિ_સોમ_મંગળ_બુધ્_ગુરુ_શુક્ર_શનિ'.split('_'),
  26123. weekdaysMin: 'ર_સો_મં_બુ_ગુ_શુ_શ'.split('_'),
  26124. longDateFormat: {
  26125. LT: 'A h:mm વાગ્યે',
  26126. LTS: 'A h:mm:ss વાગ્યે',
  26127. L: 'DD/MM/YYYY',
  26128. LL: 'D MMMM YYYY',
  26129. LLL: 'D MMMM YYYY, A h:mm વાગ્યે',
  26130. LLLL: 'dddd, D MMMM YYYY, A h:mm વાગ્યે'
  26131. },
  26132. calendar: {
  26133. sameDay: '[આજ] LT',
  26134. nextDay: '[કાલે] LT',
  26135. nextWeek: 'dddd, LT',
  26136. lastDay: '[ગઇકાલે] LT',
  26137. lastWeek: '[પાછલા] dddd, LT',
  26138. sameElse: 'L'
  26139. },
  26140. relativeTime: {
  26141. future: '%s મા',
  26142. past: '%s પેહલા',
  26143. s: 'અમુક પળો',
  26144. m: 'એક મિનિટ',
  26145. mm: '%d મિનિટ',
  26146. h: 'એક કલાક',
  26147. hh: '%d કલાક',
  26148. d: 'એક દિવસ',
  26149. dd: '%d દિવસ',
  26150. M: 'એક મહિનો',
  26151. MM: '%d મહિનો',
  26152. y: 'એક વર્ષ',
  26153. yy: '%d વર્ષ'
  26154. },
  26155. preparse: function (string) {
  26156. return string.replace(/[૧૨૩૪૫૬૭૮૯૦]/g, function (match) {
  26157. return numberMap$5[match];
  26158. });
  26159. },
  26160. postformat: function (string) {
  26161. return string.replace(/\d/g, function (match) {
  26162. return symbolMap$6[match];
  26163. });
  26164. },
  26165. // Gujarati notation for meridiems are quite fuzzy in practice. While there exists
  26166. // a rigid notion of a 'Pahar' it is not used as rigidly in modern Gujarati.
  26167. meridiemParse: /રાત|બપોર|સવાર|સાંજ/,
  26168. meridiemHour: function (hour, meridiem) {
  26169. if (hour === 12) {
  26170. hour = 0;
  26171. }
  26172. if (meridiem === 'રાત') {
  26173. return hour < 4 ? hour : hour + 12;
  26174. } else if (meridiem === 'સવાર') {
  26175. return hour;
  26176. } else if (meridiem === 'બપોર') {
  26177. return hour >= 10 ? hour : hour + 12;
  26178. } else if (meridiem === 'સાંજ') {
  26179. return hour + 12;
  26180. }
  26181. },
  26182. meridiem: function (hour, minute, isLower) {
  26183. if (hour < 4) {
  26184. return 'રાત';
  26185. } else if (hour < 10) {
  26186. return 'સવાર';
  26187. } else if (hour < 17) {
  26188. return 'બપોર';
  26189. } else if (hour < 20) {
  26190. return 'સાંજ';
  26191. } else {
  26192. return 'રાત';
  26193. }
  26194. },
  26195. week: {
  26196. dow: 0, // Sunday is the first day of the week.
  26197. doy: 6 // The week that contains Jan 1st is the first week of the year.
  26198. }
  26199. });
  26200. //! moment.js locale configuration
  26201. //! locale : Hebrew [he]
  26202. //! author : Tomer Cohen : https://github.com/tomer
  26203. //! author : Moshe Simantov : https://github.com/DevelopmentIL
  26204. //! author : Tal Ater : https://github.com/TalAter
  26205. hooks.defineLocale('he', {
  26206. months : 'ינואר_פברואר_מרץ_אפריל_מאי_יוני_יולי_אוגוסט_ספטמבר_אוקטובר_נובמבר_דצמבר'.split('_'),
  26207. monthsShort : 'ינו׳_פבר׳_מרץ_אפר׳_מאי_יוני_יולי_אוג׳_ספט׳_אוק׳_נוב׳_דצמ׳'.split('_'),
  26208. weekdays : 'ראשון_שני_שלישי_רביעי_חמישי_שישי_שבת'.split('_'),
  26209. weekdaysShort : 'א׳_ב׳_ג׳_ד׳_ה׳_ו׳_ש׳'.split('_'),
  26210. weekdaysMin : 'א_ב_ג_ד_ה_ו_ש'.split('_'),
  26211. longDateFormat : {
  26212. LT : 'HH:mm',
  26213. LTS : 'HH:mm:ss',
  26214. L : 'DD/MM/YYYY',
  26215. LL : 'D [ב]MMMM YYYY',
  26216. LLL : 'D [ב]MMMM YYYY HH:mm',
  26217. LLLL : 'dddd, D [ב]MMMM YYYY HH:mm',
  26218. l : 'D/M/YYYY',
  26219. ll : 'D MMM YYYY',
  26220. lll : 'D MMM YYYY HH:mm',
  26221. llll : 'ddd, D MMM YYYY HH:mm'
  26222. },
  26223. calendar : {
  26224. sameDay : '[היום ב־]LT',
  26225. nextDay : '[מחר ב־]LT',
  26226. nextWeek : 'dddd [בשעה] LT',
  26227. lastDay : '[אתמול ב־]LT',
  26228. lastWeek : '[ביום] dddd [האחרון בשעה] LT',
  26229. sameElse : 'L'
  26230. },
  26231. relativeTime : {
  26232. future : 'בעוד %s',
  26233. past : 'לפני %s',
  26234. s : 'מספר שניות',
  26235. m : 'דקה',
  26236. mm : '%d דקות',
  26237. h : 'שעה',
  26238. hh : function (number) {
  26239. if (number === 2) {
  26240. return 'שעתיים';
  26241. }
  26242. return number + ' שעות';
  26243. },
  26244. d : 'יום',
  26245. dd : function (number) {
  26246. if (number === 2) {
  26247. return 'יומיים';
  26248. }
  26249. return number + ' ימים';
  26250. },
  26251. M : 'חודש',
  26252. MM : function (number) {
  26253. if (number === 2) {
  26254. return 'חודשיים';
  26255. }
  26256. return number + ' חודשים';
  26257. },
  26258. y : 'שנה',
  26259. yy : function (number) {
  26260. if (number === 2) {
  26261. return 'שנתיים';
  26262. } else if (number % 10 === 0 && number !== 10) {
  26263. return number + ' שנה';
  26264. }
  26265. return number + ' שנים';
  26266. }
  26267. },
  26268. meridiemParse: /אחה"צ|לפנה"צ|אחרי הצהריים|לפני הצהריים|לפנות בוקר|בבוקר|בערב/i,
  26269. isPM : function (input) {
  26270. return /^(אחה"צ|אחרי הצהריים|בערב)$/.test(input);
  26271. },
  26272. meridiem : function (hour, minute, isLower) {
  26273. if (hour < 5) {
  26274. return 'לפנות בוקר';
  26275. } else if (hour < 10) {
  26276. return 'בבוקר';
  26277. } else if (hour < 12) {
  26278. return isLower ? 'לפנה"צ' : 'לפני הצהריים';
  26279. } else if (hour < 18) {
  26280. return isLower ? 'אחה"צ' : 'אחרי הצהריים';
  26281. } else {
  26282. return 'בערב';
  26283. }
  26284. }
  26285. });
  26286. //! moment.js locale configuration
  26287. //! locale : Hindi [hi]
  26288. //! author : Mayank Singhal : https://github.com/mayanksinghal
  26289. var symbolMap$7 = {
  26290. '1': '१',
  26291. '2': '२',
  26292. '3': '३',
  26293. '4': '४',
  26294. '5': '५',
  26295. '6': '६',
  26296. '7': '७',
  26297. '8': '८',
  26298. '9': '९',
  26299. '0': '०'
  26300. };
  26301. var numberMap$6 = {
  26302. '१': '1',
  26303. '२': '2',
  26304. '३': '3',
  26305. '४': '4',
  26306. '५': '5',
  26307. '६': '6',
  26308. '७': '7',
  26309. '८': '8',
  26310. '९': '9',
  26311. '०': '0'
  26312. };
  26313. hooks.defineLocale('hi', {
  26314. months : 'जनवरी_फ़रवरी_मार्च_अप्रैल_मई_जून_जुलाई_अगस्त_सितम्बर_अक्टूबर_नवम्बर_दिसम्बर'.split('_'),
  26315. monthsShort : 'जन._फ़र._मार्च_अप्रै._मई_जून_जुल._अग._सित._अक्टू._नव._दिस.'.split('_'),
  26316. monthsParseExact: true,
  26317. weekdays : 'रविवार_सोमवार_मंगलवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
  26318. weekdaysShort : 'रवि_सोम_मंगल_बुध_गुरू_शुक्र_शनि'.split('_'),
  26319. weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
  26320. longDateFormat : {
  26321. LT : 'A h:mm बजे',
  26322. LTS : 'A h:mm:ss बजे',
  26323. L : 'DD/MM/YYYY',
  26324. LL : 'D MMMM YYYY',
  26325. LLL : 'D MMMM YYYY, A h:mm बजे',
  26326. LLLL : 'dddd, D MMMM YYYY, A h:mm बजे'
  26327. },
  26328. calendar : {
  26329. sameDay : '[आज] LT',
  26330. nextDay : '[कल] LT',
  26331. nextWeek : 'dddd, LT',
  26332. lastDay : '[कल] LT',
  26333. lastWeek : '[पिछले] dddd, LT',
  26334. sameElse : 'L'
  26335. },
  26336. relativeTime : {
  26337. future : '%s में',
  26338. past : '%s पहले',
  26339. s : 'कुछ ही क्षण',
  26340. m : 'एक मिनट',
  26341. mm : '%d मिनट',
  26342. h : 'एक घंटा',
  26343. hh : '%d घंटे',
  26344. d : 'एक दिन',
  26345. dd : '%d दिन',
  26346. M : 'एक महीने',
  26347. MM : '%d महीने',
  26348. y : 'एक वर्ष',
  26349. yy : '%d वर्ष'
  26350. },
  26351. preparse: function (string) {
  26352. return string.replace(/[१२३४५६७८९०]/g, function (match) {
  26353. return numberMap$6[match];
  26354. });
  26355. },
  26356. postformat: function (string) {
  26357. return string.replace(/\d/g, function (match) {
  26358. return symbolMap$7[match];
  26359. });
  26360. },
  26361. // Hindi notation for meridiems are quite fuzzy in practice. While there exists
  26362. // a rigid notion of a 'Pahar' it is not used as rigidly in modern Hindi.
  26363. meridiemParse: /रात|सुबह|दोपहर|शाम/,
  26364. meridiemHour : function (hour, meridiem) {
  26365. if (hour === 12) {
  26366. hour = 0;
  26367. }
  26368. if (meridiem === 'रात') {
  26369. return hour < 4 ? hour : hour + 12;
  26370. } else if (meridiem === 'सुबह') {
  26371. return hour;
  26372. } else if (meridiem === 'दोपहर') {
  26373. return hour >= 10 ? hour : hour + 12;
  26374. } else if (meridiem === 'शाम') {
  26375. return hour + 12;
  26376. }
  26377. },
  26378. meridiem : function (hour, minute, isLower) {
  26379. if (hour < 4) {
  26380. return 'रात';
  26381. } else if (hour < 10) {
  26382. return 'सुबह';
  26383. } else if (hour < 17) {
  26384. return 'दोपहर';
  26385. } else if (hour < 20) {
  26386. return 'शाम';
  26387. } else {
  26388. return 'रात';
  26389. }
  26390. },
  26391. week : {
  26392. dow : 0, // Sunday is the first day of the week.
  26393. doy : 6 // The week that contains Jan 1st is the first week of the year.
  26394. }
  26395. });
  26396. //! moment.js locale configuration
  26397. //! locale : Croatian [hr]
  26398. //! author : Bojan Marković : https://github.com/bmarkovic
  26399. function translate$3(number, withoutSuffix, key) {
  26400. var result = number + ' ';
  26401. switch (key) {
  26402. case 'm':
  26403. return withoutSuffix ? 'jedna minuta' : 'jedne minute';
  26404. case 'mm':
  26405. if (number === 1) {
  26406. result += 'minuta';
  26407. } else if (number === 2 || number === 3 || number === 4) {
  26408. result += 'minute';
  26409. } else {
  26410. result += 'minuta';
  26411. }
  26412. return result;
  26413. case 'h':
  26414. return withoutSuffix ? 'jedan sat' : 'jednog sata';
  26415. case 'hh':
  26416. if (number === 1) {
  26417. result += 'sat';
  26418. } else if (number === 2 || number === 3 || number === 4) {
  26419. result += 'sata';
  26420. } else {
  26421. result += 'sati';
  26422. }
  26423. return result;
  26424. case 'dd':
  26425. if (number === 1) {
  26426. result += 'dan';
  26427. } else {
  26428. result += 'dana';
  26429. }
  26430. return result;
  26431. case 'MM':
  26432. if (number === 1) {
  26433. result += 'mjesec';
  26434. } else if (number === 2 || number === 3 || number === 4) {
  26435. result += 'mjeseca';
  26436. } else {
  26437. result += 'mjeseci';
  26438. }
  26439. return result;
  26440. case 'yy':
  26441. if (number === 1) {
  26442. result += 'godina';
  26443. } else if (number === 2 || number === 3 || number === 4) {
  26444. result += 'godine';
  26445. } else {
  26446. result += 'godina';
  26447. }
  26448. return result;
  26449. }
  26450. }
  26451. hooks.defineLocale('hr', {
  26452. months : {
  26453. format: 'siječnja_veljače_ožujka_travnja_svibnja_lipnja_srpnja_kolovoza_rujna_listopada_studenoga_prosinca'.split('_'),
  26454. standalone: 'siječanj_veljača_ožujak_travanj_svibanj_lipanj_srpanj_kolovoz_rujan_listopad_studeni_prosinac'.split('_')
  26455. },
  26456. monthsShort : 'sij._velj._ožu._tra._svi._lip._srp._kol._ruj._lis._stu._pro.'.split('_'),
  26457. monthsParseExact: true,
  26458. weekdays : 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
  26459. weekdaysShort : 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
  26460. weekdaysMin : 'ne_po_ut_sr_če_pe_su'.split('_'),
  26461. weekdaysParseExact : true,
  26462. longDateFormat : {
  26463. LT : 'H:mm',
  26464. LTS : 'H:mm:ss',
  26465. L : 'DD.MM.YYYY',
  26466. LL : 'D. MMMM YYYY',
  26467. LLL : 'D. MMMM YYYY H:mm',
  26468. LLLL : 'dddd, D. MMMM YYYY H:mm'
  26469. },
  26470. calendar : {
  26471. sameDay : '[danas u] LT',
  26472. nextDay : '[sutra u] LT',
  26473. nextWeek : function () {
  26474. switch (this.day()) {
  26475. case 0:
  26476. return '[u] [nedjelju] [u] LT';
  26477. case 3:
  26478. return '[u] [srijedu] [u] LT';
  26479. case 6:
  26480. return '[u] [subotu] [u] LT';
  26481. case 1:
  26482. case 2:
  26483. case 4:
  26484. case 5:
  26485. return '[u] dddd [u] LT';
  26486. }
  26487. },
  26488. lastDay : '[jučer u] LT',
  26489. lastWeek : function () {
  26490. switch (this.day()) {
  26491. case 0:
  26492. case 3:
  26493. return '[prošlu] dddd [u] LT';
  26494. case 6:
  26495. return '[prošle] [subote] [u] LT';
  26496. case 1:
  26497. case 2:
  26498. case 4:
  26499. case 5:
  26500. return '[prošli] dddd [u] LT';
  26501. }
  26502. },
  26503. sameElse : 'L'
  26504. },
  26505. relativeTime : {
  26506. future : 'za %s',
  26507. past : 'prije %s',
  26508. s : 'par sekundi',
  26509. m : translate$3,
  26510. mm : translate$3,
  26511. h : translate$3,
  26512. hh : translate$3,
  26513. d : 'dan',
  26514. dd : translate$3,
  26515. M : 'mjesec',
  26516. MM : translate$3,
  26517. y : 'godinu',
  26518. yy : translate$3
  26519. },
  26520. dayOfMonthOrdinalParse: /\d{1,2}\./,
  26521. ordinal : '%d.',
  26522. week : {
  26523. dow : 1, // Monday is the first day of the week.
  26524. doy : 7 // The week that contains Jan 1st is the first week of the year.
  26525. }
  26526. });
  26527. //! moment.js locale configuration
  26528. //! locale : Hungarian [hu]
  26529. //! author : Adam Brunner : https://github.com/adambrunner
  26530. var weekEndings = 'vasárnap hétfőn kedden szerdán csütörtökön pénteken szombaton'.split(' ');
  26531. function translate$4(number, withoutSuffix, key, isFuture) {
  26532. var num = number;
  26533. switch (key) {
  26534. case 's':
  26535. return (isFuture || withoutSuffix) ? 'néhány másodperc' : 'néhány másodperce';
  26536. case 'm':
  26537. return 'egy' + (isFuture || withoutSuffix ? ' perc' : ' perce');
  26538. case 'mm':
  26539. return num + (isFuture || withoutSuffix ? ' perc' : ' perce');
  26540. case 'h':
  26541. return 'egy' + (isFuture || withoutSuffix ? ' óra' : ' órája');
  26542. case 'hh':
  26543. return num + (isFuture || withoutSuffix ? ' óra' : ' órája');
  26544. case 'd':
  26545. return 'egy' + (isFuture || withoutSuffix ? ' nap' : ' napja');
  26546. case 'dd':
  26547. return num + (isFuture || withoutSuffix ? ' nap' : ' napja');
  26548. case 'M':
  26549. return 'egy' + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
  26550. case 'MM':
  26551. return num + (isFuture || withoutSuffix ? ' hónap' : ' hónapja');
  26552. case 'y':
  26553. return 'egy' + (isFuture || withoutSuffix ? ' év' : ' éve');
  26554. case 'yy':
  26555. return num + (isFuture || withoutSuffix ? ' év' : ' éve');
  26556. }
  26557. return '';
  26558. }
  26559. function week(isFuture) {
  26560. return (isFuture ? '' : '[múlt] ') + '[' + weekEndings[this.day()] + '] LT[-kor]';
  26561. }
  26562. hooks.defineLocale('hu', {
  26563. months : 'január_február_március_április_május_június_július_augusztus_szeptember_október_november_december'.split('_'),
  26564. monthsShort : 'jan_feb_márc_ápr_máj_jún_júl_aug_szept_okt_nov_dec'.split('_'),
  26565. weekdays : 'vasárnap_hétfő_kedd_szerda_csütörtök_péntek_szombat'.split('_'),
  26566. weekdaysShort : 'vas_hét_kedd_sze_csüt_pén_szo'.split('_'),
  26567. weekdaysMin : 'v_h_k_sze_cs_p_szo'.split('_'),
  26568. longDateFormat : {
  26569. LT : 'H:mm',
  26570. LTS : 'H:mm:ss',
  26571. L : 'YYYY.MM.DD.',
  26572. LL : 'YYYY. MMMM D.',
  26573. LLL : 'YYYY. MMMM D. H:mm',
  26574. LLLL : 'YYYY. MMMM D., dddd H:mm'
  26575. },
  26576. meridiemParse: /de|du/i,
  26577. isPM: function (input) {
  26578. return input.charAt(1).toLowerCase() === 'u';
  26579. },
  26580. meridiem : function (hours, minutes, isLower) {
  26581. if (hours < 12) {
  26582. return isLower === true ? 'de' : 'DE';
  26583. } else {
  26584. return isLower === true ? 'du' : 'DU';
  26585. }
  26586. },
  26587. calendar : {
  26588. sameDay : '[ma] LT[-kor]',
  26589. nextDay : '[holnap] LT[-kor]',
  26590. nextWeek : function () {
  26591. return week.call(this, true);
  26592. },
  26593. lastDay : '[tegnap] LT[-kor]',
  26594. lastWeek : function () {
  26595. return week.call(this, false);
  26596. },
  26597. sameElse : 'L'
  26598. },
  26599. relativeTime : {
  26600. future : '%s múlva',
  26601. past : '%s',
  26602. s : translate$4,
  26603. m : translate$4,
  26604. mm : translate$4,
  26605. h : translate$4,
  26606. hh : translate$4,
  26607. d : translate$4,
  26608. dd : translate$4,
  26609. M : translate$4,
  26610. MM : translate$4,
  26611. y : translate$4,
  26612. yy : translate$4
  26613. },
  26614. dayOfMonthOrdinalParse: /\d{1,2}\./,
  26615. ordinal : '%d.',
  26616. week : {
  26617. dow : 1, // Monday is the first day of the week.
  26618. doy : 4 // The week that contains Jan 4th is the first week of the year.
  26619. }
  26620. });
  26621. //! moment.js locale configuration
  26622. //! locale : Armenian [hy-am]
  26623. //! author : Armendarabyan : https://github.com/armendarabyan
  26624. hooks.defineLocale('hy-am', {
  26625. months : {
  26626. format: 'հունվարի_փետրվարի_մարտի_ապրիլի_մայիսի_հունիսի_հուլիսի_օգոստոսի_սեպտեմբերի_հոկտեմբերի_նոյեմբերի_դեկտեմբերի'.split('_'),
  26627. standalone: 'հունվար_փետրվար_մարտ_ապրիլ_մայիս_հունիս_հուլիս_օգոստոս_սեպտեմբեր_հոկտեմբեր_նոյեմբեր_դեկտեմբեր'.split('_')
  26628. },
  26629. monthsShort : 'հնվ_փտր_մրտ_ապր_մյս_հնս_հլս_օգս_սպտ_հկտ_նմբ_դկտ'.split('_'),
  26630. weekdays : 'կիրակի_երկուշաբթի_երեքշաբթի_չորեքշաբթի_հինգշաբթի_ուրբաթ_շաբաթ'.split('_'),
  26631. weekdaysShort : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
  26632. weekdaysMin : 'կրկ_երկ_երք_չրք_հնգ_ուրբ_շբթ'.split('_'),
  26633. longDateFormat : {
  26634. LT : 'HH:mm',
  26635. LTS : 'HH:mm:ss',
  26636. L : 'DD.MM.YYYY',
  26637. LL : 'D MMMM YYYY թ.',
  26638. LLL : 'D MMMM YYYY թ., HH:mm',
  26639. LLLL : 'dddd, D MMMM YYYY թ., HH:mm'
  26640. },
  26641. calendar : {
  26642. sameDay: '[այսօր] LT',
  26643. nextDay: '[վաղը] LT',
  26644. lastDay: '[երեկ] LT',
  26645. nextWeek: function () {
  26646. return 'dddd [օրը ժամը] LT';
  26647. },
  26648. lastWeek: function () {
  26649. return '[անցած] dddd [օրը ժամը] LT';
  26650. },
  26651. sameElse: 'L'
  26652. },
  26653. relativeTime : {
  26654. future : '%s հետո',
  26655. past : '%s առաջ',
  26656. s : 'մի քանի վայրկյան',
  26657. m : 'րոպե',
  26658. mm : '%d րոպե',
  26659. h : 'ժամ',
  26660. hh : '%d ժամ',
  26661. d : 'օր',
  26662. dd : '%d օր',
  26663. M : 'ամիս',
  26664. MM : '%d ամիս',
  26665. y : 'տարի',
  26666. yy : '%d տարի'
  26667. },
  26668. meridiemParse: /գիշերվա|առավոտվա|ցերեկվա|երեկոյան/,
  26669. isPM: function (input) {
  26670. return /^(ցերեկվա|երեկոյան)$/.test(input);
  26671. },
  26672. meridiem : function (hour) {
  26673. if (hour < 4) {
  26674. return 'գիշերվա';
  26675. } else if (hour < 12) {
  26676. return 'առավոտվա';
  26677. } else if (hour < 17) {
  26678. return 'ցերեկվա';
  26679. } else {
  26680. return 'երեկոյան';
  26681. }
  26682. },
  26683. dayOfMonthOrdinalParse: /\d{1,2}|\d{1,2}-(ին|րդ)/,
  26684. ordinal: function (number, period) {
  26685. switch (period) {
  26686. case 'DDD':
  26687. case 'w':
  26688. case 'W':
  26689. case 'DDDo':
  26690. if (number === 1) {
  26691. return number + '-ին';
  26692. }
  26693. return number + '-րդ';
  26694. default:
  26695. return number;
  26696. }
  26697. },
  26698. week : {
  26699. dow : 1, // Monday is the first day of the week.
  26700. doy : 7 // The week that contains Jan 1st is the first week of the year.
  26701. }
  26702. });
  26703. //! moment.js locale configuration
  26704. //! locale : Indonesian [id]
  26705. //! author : Mohammad Satrio Utomo : https://github.com/tyok
  26706. //! reference: http://id.wikisource.org/wiki/Pedoman_Umum_Ejaan_Bahasa_Indonesia_yang_Disempurnakan
  26707. hooks.defineLocale('id', {
  26708. months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_November_Desember'.split('_'),
  26709. monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nov_Des'.split('_'),
  26710. weekdays : 'Minggu_Senin_Selasa_Rabu_Kamis_Jumat_Sabtu'.split('_'),
  26711. weekdaysShort : 'Min_Sen_Sel_Rab_Kam_Jum_Sab'.split('_'),
  26712. weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sb'.split('_'),
  26713. longDateFormat : {
  26714. LT : 'HH.mm',
  26715. LTS : 'HH.mm.ss',
  26716. L : 'DD/MM/YYYY',
  26717. LL : 'D MMMM YYYY',
  26718. LLL : 'D MMMM YYYY [pukul] HH.mm',
  26719. LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
  26720. },
  26721. meridiemParse: /pagi|siang|sore|malam/,
  26722. meridiemHour : function (hour, meridiem) {
  26723. if (hour === 12) {
  26724. hour = 0;
  26725. }
  26726. if (meridiem === 'pagi') {
  26727. return hour;
  26728. } else if (meridiem === 'siang') {
  26729. return hour >= 11 ? hour : hour + 12;
  26730. } else if (meridiem === 'sore' || meridiem === 'malam') {
  26731. return hour + 12;
  26732. }
  26733. },
  26734. meridiem : function (hours, minutes, isLower) {
  26735. if (hours < 11) {
  26736. return 'pagi';
  26737. } else if (hours < 15) {
  26738. return 'siang';
  26739. } else if (hours < 19) {
  26740. return 'sore';
  26741. } else {
  26742. return 'malam';
  26743. }
  26744. },
  26745. calendar : {
  26746. sameDay : '[Hari ini pukul] LT',
  26747. nextDay : '[Besok pukul] LT',
  26748. nextWeek : 'dddd [pukul] LT',
  26749. lastDay : '[Kemarin pukul] LT',
  26750. lastWeek : 'dddd [lalu pukul] LT',
  26751. sameElse : 'L'
  26752. },
  26753. relativeTime : {
  26754. future : 'dalam %s',
  26755. past : '%s yang lalu',
  26756. s : 'beberapa detik',
  26757. m : 'semenit',
  26758. mm : '%d menit',
  26759. h : 'sejam',
  26760. hh : '%d jam',
  26761. d : 'sehari',
  26762. dd : '%d hari',
  26763. M : 'sebulan',
  26764. MM : '%d bulan',
  26765. y : 'setahun',
  26766. yy : '%d tahun'
  26767. },
  26768. week : {
  26769. dow : 1, // Monday is the first day of the week.
  26770. doy : 7 // The week that contains Jan 1st is the first week of the year.
  26771. }
  26772. });
  26773. //! moment.js locale configuration
  26774. //! locale : Icelandic [is]
  26775. //! author : Hinrik Örn Sigurðsson : https://github.com/hinrik
  26776. function plural$2(n) {
  26777. if (n % 100 === 11) {
  26778. return true;
  26779. } else if (n % 10 === 1) {
  26780. return false;
  26781. }
  26782. return true;
  26783. }
  26784. function translate$5(number, withoutSuffix, key, isFuture) {
  26785. var result = number + ' ';
  26786. switch (key) {
  26787. case 's':
  26788. return withoutSuffix || isFuture ? 'nokkrar sekúndur' : 'nokkrum sekúndum';
  26789. case 'm':
  26790. return withoutSuffix ? 'mínúta' : 'mínútu';
  26791. case 'mm':
  26792. if (plural$2(number)) {
  26793. return result + (withoutSuffix || isFuture ? 'mínútur' : 'mínútum');
  26794. } else if (withoutSuffix) {
  26795. return result + 'mínúta';
  26796. }
  26797. return result + 'mínútu';
  26798. case 'hh':
  26799. if (plural$2(number)) {
  26800. return result + (withoutSuffix || isFuture ? 'klukkustundir' : 'klukkustundum');
  26801. }
  26802. return result + 'klukkustund';
  26803. case 'd':
  26804. if (withoutSuffix) {
  26805. return 'dagur';
  26806. }
  26807. return isFuture ? 'dag' : 'degi';
  26808. case 'dd':
  26809. if (plural$2(number)) {
  26810. if (withoutSuffix) {
  26811. return result + 'dagar';
  26812. }
  26813. return result + (isFuture ? 'daga' : 'dögum');
  26814. } else if (withoutSuffix) {
  26815. return result + 'dagur';
  26816. }
  26817. return result + (isFuture ? 'dag' : 'degi');
  26818. case 'M':
  26819. if (withoutSuffix) {
  26820. return 'mánuður';
  26821. }
  26822. return isFuture ? 'mánuð' : 'mánuði';
  26823. case 'MM':
  26824. if (plural$2(number)) {
  26825. if (withoutSuffix) {
  26826. return result + 'mánuðir';
  26827. }
  26828. return result + (isFuture ? 'mánuði' : 'mánuðum');
  26829. } else if (withoutSuffix) {
  26830. return result + 'mánuður';
  26831. }
  26832. return result + (isFuture ? 'mánuð' : 'mánuði');
  26833. case 'y':
  26834. return withoutSuffix || isFuture ? 'ár' : 'ári';
  26835. case 'yy':
  26836. if (plural$2(number)) {
  26837. return result + (withoutSuffix || isFuture ? 'ár' : 'árum');
  26838. }
  26839. return result + (withoutSuffix || isFuture ? 'ár' : 'ári');
  26840. }
  26841. }
  26842. hooks.defineLocale('is', {
  26843. months : 'janúar_febrúar_mars_apríl_maí_júní_júlí_ágúst_september_október_nóvember_desember'.split('_'),
  26844. monthsShort : 'jan_feb_mar_apr_maí_jún_júl_ágú_sep_okt_nóv_des'.split('_'),
  26845. weekdays : 'sunnudagur_mánudagur_þriðjudagur_miðvikudagur_fimmtudagur_föstudagur_laugardagur'.split('_'),
  26846. weekdaysShort : 'sun_mán_þri_mið_fim_fös_lau'.split('_'),
  26847. weekdaysMin : 'Su_Má_Þr_Mi_Fi_Fö_La'.split('_'),
  26848. longDateFormat : {
  26849. LT : 'H:mm',
  26850. LTS : 'H:mm:ss',
  26851. L : 'DD.MM.YYYY',
  26852. LL : 'D. MMMM YYYY',
  26853. LLL : 'D. MMMM YYYY [kl.] H:mm',
  26854. LLLL : 'dddd, D. MMMM YYYY [kl.] H:mm'
  26855. },
  26856. calendar : {
  26857. sameDay : '[í dag kl.] LT',
  26858. nextDay : '[á morgun kl.] LT',
  26859. nextWeek : 'dddd [kl.] LT',
  26860. lastDay : '[í gær kl.] LT',
  26861. lastWeek : '[síðasta] dddd [kl.] LT',
  26862. sameElse : 'L'
  26863. },
  26864. relativeTime : {
  26865. future : 'eftir %s',
  26866. past : 'fyrir %s síðan',
  26867. s : translate$5,
  26868. m : translate$5,
  26869. mm : translate$5,
  26870. h : 'klukkustund',
  26871. hh : translate$5,
  26872. d : translate$5,
  26873. dd : translate$5,
  26874. M : translate$5,
  26875. MM : translate$5,
  26876. y : translate$5,
  26877. yy : translate$5
  26878. },
  26879. dayOfMonthOrdinalParse: /\d{1,2}\./,
  26880. ordinal : '%d.',
  26881. week : {
  26882. dow : 1, // Monday is the first day of the week.
  26883. doy : 4 // The week that contains Jan 4th is the first week of the year.
  26884. }
  26885. });
  26886. //! moment.js locale configuration
  26887. //! locale : Italian [it]
  26888. //! author : Lorenzo : https://github.com/aliem
  26889. //! author: Mattia Larentis: https://github.com/nostalgiaz
  26890. hooks.defineLocale('it', {
  26891. months : 'gennaio_febbraio_marzo_aprile_maggio_giugno_luglio_agosto_settembre_ottobre_novembre_dicembre'.split('_'),
  26892. monthsShort : 'gen_feb_mar_apr_mag_giu_lug_ago_set_ott_nov_dic'.split('_'),
  26893. weekdays : 'domenica_lunedì_martedì_mercoledì_giovedì_venerdì_sabato'.split('_'),
  26894. weekdaysShort : 'dom_lun_mar_mer_gio_ven_sab'.split('_'),
  26895. weekdaysMin : 'do_lu_ma_me_gi_ve_sa'.split('_'),
  26896. longDateFormat : {
  26897. LT : 'HH:mm',
  26898. LTS : 'HH:mm:ss',
  26899. L : 'DD/MM/YYYY',
  26900. LL : 'D MMMM YYYY',
  26901. LLL : 'D MMMM YYYY HH:mm',
  26902. LLLL : 'dddd, D MMMM YYYY HH:mm'
  26903. },
  26904. calendar : {
  26905. sameDay: '[Oggi alle] LT',
  26906. nextDay: '[Domani alle] LT',
  26907. nextWeek: 'dddd [alle] LT',
  26908. lastDay: '[Ieri alle] LT',
  26909. lastWeek: function () {
  26910. switch (this.day()) {
  26911. case 0:
  26912. return '[la scorsa] dddd [alle] LT';
  26913. default:
  26914. return '[lo scorso] dddd [alle] LT';
  26915. }
  26916. },
  26917. sameElse: 'L'
  26918. },
  26919. relativeTime : {
  26920. future : function (s) {
  26921. return ((/^[0-9].+$/).test(s) ? 'tra' : 'in') + ' ' + s;
  26922. },
  26923. past : '%s fa',
  26924. s : 'alcuni secondi',
  26925. m : 'un minuto',
  26926. mm : '%d minuti',
  26927. h : 'un\'ora',
  26928. hh : '%d ore',
  26929. d : 'un giorno',
  26930. dd : '%d giorni',
  26931. M : 'un mese',
  26932. MM : '%d mesi',
  26933. y : 'un anno',
  26934. yy : '%d anni'
  26935. },
  26936. dayOfMonthOrdinalParse : /\d{1,2}º/,
  26937. ordinal: '%dº',
  26938. week : {
  26939. dow : 1, // Monday is the first day of the week.
  26940. doy : 4 // The week that contains Jan 4th is the first week of the year.
  26941. }
  26942. });
  26943. //! moment.js locale configuration
  26944. //! locale : Japanese [ja]
  26945. //! author : LI Long : https://github.com/baryon
  26946. hooks.defineLocale('ja', {
  26947. months : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  26948. monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  26949. weekdays : '日曜日_月曜日_火曜日_水曜日_木曜日_金曜日_土曜日'.split('_'),
  26950. weekdaysShort : '日_月_火_水_木_金_土'.split('_'),
  26951. weekdaysMin : '日_月_火_水_木_金_土'.split('_'),
  26952. longDateFormat : {
  26953. LT : 'HH:mm',
  26954. LTS : 'HH:mm:ss',
  26955. L : 'YYYY/MM/DD',
  26956. LL : 'YYYY年M月D日',
  26957. LLL : 'YYYY年M月D日 HH:mm',
  26958. LLLL : 'YYYY年M月D日 HH:mm dddd',
  26959. l : 'YYYY/MM/DD',
  26960. ll : 'YYYY年M月D日',
  26961. lll : 'YYYY年M月D日 HH:mm',
  26962. llll : 'YYYY年M月D日 HH:mm dddd'
  26963. },
  26964. meridiemParse: /午前|午後/i,
  26965. isPM : function (input) {
  26966. return input === '午後';
  26967. },
  26968. meridiem : function (hour, minute, isLower) {
  26969. if (hour < 12) {
  26970. return '午前';
  26971. } else {
  26972. return '午後';
  26973. }
  26974. },
  26975. calendar : {
  26976. sameDay : '[今日] LT',
  26977. nextDay : '[明日] LT',
  26978. nextWeek : '[来週]dddd LT',
  26979. lastDay : '[昨日] LT',
  26980. lastWeek : '[前週]dddd LT',
  26981. sameElse : 'L'
  26982. },
  26983. dayOfMonthOrdinalParse : /\d{1,2}日/,
  26984. ordinal : function (number, period) {
  26985. switch (period) {
  26986. case 'd':
  26987. case 'D':
  26988. case 'DDD':
  26989. return number + '日';
  26990. default:
  26991. return number;
  26992. }
  26993. },
  26994. relativeTime : {
  26995. future : '%s後',
  26996. past : '%s前',
  26997. s : '数秒',
  26998. m : '1分',
  26999. mm : '%d分',
  27000. h : '1時間',
  27001. hh : '%d時間',
  27002. d : '1日',
  27003. dd : '%d日',
  27004. M : '1ヶ月',
  27005. MM : '%dヶ月',
  27006. y : '1年',
  27007. yy : '%d年'
  27008. }
  27009. });
  27010. //! moment.js locale configuration
  27011. //! locale : Javanese [jv]
  27012. //! author : Rony Lantip : https://github.com/lantip
  27013. //! reference: http://jv.wikipedia.org/wiki/Basa_Jawa
  27014. hooks.defineLocale('jv', {
  27015. months : 'Januari_Februari_Maret_April_Mei_Juni_Juli_Agustus_September_Oktober_Nopember_Desember'.split('_'),
  27016. monthsShort : 'Jan_Feb_Mar_Apr_Mei_Jun_Jul_Ags_Sep_Okt_Nop_Des'.split('_'),
  27017. weekdays : 'Minggu_Senen_Seloso_Rebu_Kemis_Jemuwah_Septu'.split('_'),
  27018. weekdaysShort : 'Min_Sen_Sel_Reb_Kem_Jem_Sep'.split('_'),
  27019. weekdaysMin : 'Mg_Sn_Sl_Rb_Km_Jm_Sp'.split('_'),
  27020. longDateFormat : {
  27021. LT : 'HH.mm',
  27022. LTS : 'HH.mm.ss',
  27023. L : 'DD/MM/YYYY',
  27024. LL : 'D MMMM YYYY',
  27025. LLL : 'D MMMM YYYY [pukul] HH.mm',
  27026. LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
  27027. },
  27028. meridiemParse: /enjing|siyang|sonten|ndalu/,
  27029. meridiemHour : function (hour, meridiem) {
  27030. if (hour === 12) {
  27031. hour = 0;
  27032. }
  27033. if (meridiem === 'enjing') {
  27034. return hour;
  27035. } else if (meridiem === 'siyang') {
  27036. return hour >= 11 ? hour : hour + 12;
  27037. } else if (meridiem === 'sonten' || meridiem === 'ndalu') {
  27038. return hour + 12;
  27039. }
  27040. },
  27041. meridiem : function (hours, minutes, isLower) {
  27042. if (hours < 11) {
  27043. return 'enjing';
  27044. } else if (hours < 15) {
  27045. return 'siyang';
  27046. } else if (hours < 19) {
  27047. return 'sonten';
  27048. } else {
  27049. return 'ndalu';
  27050. }
  27051. },
  27052. calendar : {
  27053. sameDay : '[Dinten puniko pukul] LT',
  27054. nextDay : '[Mbenjang pukul] LT',
  27055. nextWeek : 'dddd [pukul] LT',
  27056. lastDay : '[Kala wingi pukul] LT',
  27057. lastWeek : 'dddd [kepengker pukul] LT',
  27058. sameElse : 'L'
  27059. },
  27060. relativeTime : {
  27061. future : 'wonten ing %s',
  27062. past : '%s ingkang kepengker',
  27063. s : 'sawetawis detik',
  27064. m : 'setunggal menit',
  27065. mm : '%d menit',
  27066. h : 'setunggal jam',
  27067. hh : '%d jam',
  27068. d : 'sedinten',
  27069. dd : '%d dinten',
  27070. M : 'sewulan',
  27071. MM : '%d wulan',
  27072. y : 'setaun',
  27073. yy : '%d taun'
  27074. },
  27075. week : {
  27076. dow : 1, // Monday is the first day of the week.
  27077. doy : 7 // The week that contains Jan 1st is the first week of the year.
  27078. }
  27079. });
  27080. //! moment.js locale configuration
  27081. //! locale : Georgian [ka]
  27082. //! author : Irakli Janiashvili : https://github.com/irakli-janiashvili
  27083. hooks.defineLocale('ka', {
  27084. months : {
  27085. standalone: 'იანვარი_თებერვალი_მარტი_აპრილი_მაისი_ივნისი_ივლისი_აგვისტო_სექტემბერი_ოქტომბერი_ნოემბერი_დეკემბერი'.split('_'),
  27086. format: 'იანვარს_თებერვალს_მარტს_აპრილის_მაისს_ივნისს_ივლისს_აგვისტს_სექტემბერს_ოქტომბერს_ნოემბერს_დეკემბერს'.split('_')
  27087. },
  27088. monthsShort : 'იან_თებ_მარ_აპრ_მაი_ივნ_ივლ_აგვ_სექ_ოქტ_ნოე_დეკ'.split('_'),
  27089. weekdays : {
  27090. standalone: 'კვირა_ორშაბათი_სამშაბათი_ოთხშაბათი_ხუთშაბათი_პარასკევი_შაბათი'.split('_'),
  27091. format: 'კვირას_ორშაბათს_სამშაბათს_ოთხშაბათს_ხუთშაბათს_პარასკევს_შაბათს'.split('_'),
  27092. isFormat: /(წინა|შემდეგ)/
  27093. },
  27094. weekdaysShort : 'კვი_ორშ_სამ_ოთხ_ხუთ_პარ_შაბ'.split('_'),
  27095. weekdaysMin : 'კვ_ორ_სა_ოთ_ხუ_პა_შა'.split('_'),
  27096. longDateFormat : {
  27097. LT : 'h:mm A',
  27098. LTS : 'h:mm:ss A',
  27099. L : 'DD/MM/YYYY',
  27100. LL : 'D MMMM YYYY',
  27101. LLL : 'D MMMM YYYY h:mm A',
  27102. LLLL : 'dddd, D MMMM YYYY h:mm A'
  27103. },
  27104. calendar : {
  27105. sameDay : '[დღეს] LT[-ზე]',
  27106. nextDay : '[ხვალ] LT[-ზე]',
  27107. lastDay : '[გუშინ] LT[-ზე]',
  27108. nextWeek : '[შემდეგ] dddd LT[-ზე]',
  27109. lastWeek : '[წინა] dddd LT-ზე',
  27110. sameElse : 'L'
  27111. },
  27112. relativeTime : {
  27113. future : function (s) {
  27114. return (/(წამი|წუთი|საათი|წელი)/).test(s) ?
  27115. s.replace(/ი$/, 'ში') :
  27116. s + 'ში';
  27117. },
  27118. past : function (s) {
  27119. if ((/(წამი|წუთი|საათი|დღე|თვე)/).test(s)) {
  27120. return s.replace(/(ი|ე)$/, 'ის უკან');
  27121. }
  27122. if ((/წელი/).test(s)) {
  27123. return s.replace(/წელი$/, 'წლის უკან');
  27124. }
  27125. },
  27126. s : 'რამდენიმე წამი',
  27127. m : 'წუთი',
  27128. mm : '%d წუთი',
  27129. h : 'საათი',
  27130. hh : '%d საათი',
  27131. d : 'დღე',
  27132. dd : '%d დღე',
  27133. M : 'თვე',
  27134. MM : '%d თვე',
  27135. y : 'წელი',
  27136. yy : '%d წელი'
  27137. },
  27138. dayOfMonthOrdinalParse: /0|1-ლი|მე-\d{1,2}|\d{1,2}-ე/,
  27139. ordinal : function (number) {
  27140. if (number === 0) {
  27141. return number;
  27142. }
  27143. if (number === 1) {
  27144. return number + '-ლი';
  27145. }
  27146. if ((number < 20) || (number <= 100 && (number % 20 === 0)) || (number % 100 === 0)) {
  27147. return 'მე-' + number;
  27148. }
  27149. return number + '-ე';
  27150. },
  27151. week : {
  27152. dow : 1,
  27153. doy : 7
  27154. }
  27155. });
  27156. //! moment.js locale configuration
  27157. //! locale : Kazakh [kk]
  27158. //! authors : Nurlan Rakhimzhanov : https://github.com/nurlan
  27159. var suffixes$1 = {
  27160. 0: '-ші',
  27161. 1: '-ші',
  27162. 2: '-ші',
  27163. 3: '-ші',
  27164. 4: '-ші',
  27165. 5: '-ші',
  27166. 6: '-шы',
  27167. 7: '-ші',
  27168. 8: '-ші',
  27169. 9: '-шы',
  27170. 10: '-шы',
  27171. 20: '-шы',
  27172. 30: '-шы',
  27173. 40: '-шы',
  27174. 50: '-ші',
  27175. 60: '-шы',
  27176. 70: '-ші',
  27177. 80: '-ші',
  27178. 90: '-шы',
  27179. 100: '-ші'
  27180. };
  27181. hooks.defineLocale('kk', {
  27182. months : 'қаңтар_ақпан_наурыз_сәуір_мамыр_маусым_шілде_тамыз_қыркүйек_қазан_қараша_желтоқсан'.split('_'),
  27183. monthsShort : 'қаң_ақп_нау_сәу_мам_мау_шіл_там_қыр_қаз_қар_жел'.split('_'),
  27184. weekdays : 'жексенбі_дүйсенбі_сейсенбі_сәрсенбі_бейсенбі_жұма_сенбі'.split('_'),
  27185. weekdaysShort : 'жек_дүй_сей_сәр_бей_жұм_сен'.split('_'),
  27186. weekdaysMin : 'жк_дй_сй_ср_бй_жм_сн'.split('_'),
  27187. longDateFormat : {
  27188. LT : 'HH:mm',
  27189. LTS : 'HH:mm:ss',
  27190. L : 'DD.MM.YYYY',
  27191. LL : 'D MMMM YYYY',
  27192. LLL : 'D MMMM YYYY HH:mm',
  27193. LLLL : 'dddd, D MMMM YYYY HH:mm'
  27194. },
  27195. calendar : {
  27196. sameDay : '[Бүгін сағат] LT',
  27197. nextDay : '[Ертең сағат] LT',
  27198. nextWeek : 'dddd [сағат] LT',
  27199. lastDay : '[Кеше сағат] LT',
  27200. lastWeek : '[Өткен аптаның] dddd [сағат] LT',
  27201. sameElse : 'L'
  27202. },
  27203. relativeTime : {
  27204. future : '%s ішінде',
  27205. past : '%s бұрын',
  27206. s : 'бірнеше секунд',
  27207. m : 'бір минут',
  27208. mm : '%d минут',
  27209. h : 'бір сағат',
  27210. hh : '%d сағат',
  27211. d : 'бір күн',
  27212. dd : '%d күн',
  27213. M : 'бір ай',
  27214. MM : '%d ай',
  27215. y : 'бір жыл',
  27216. yy : '%d жыл'
  27217. },
  27218. dayOfMonthOrdinalParse: /\d{1,2}-(ші|шы)/,
  27219. ordinal : function (number) {
  27220. var a = number % 10,
  27221. b = number >= 100 ? 100 : null;
  27222. return number + (suffixes$1[number] || suffixes$1[a] || suffixes$1[b]);
  27223. },
  27224. week : {
  27225. dow : 1, // Monday is the first day of the week.
  27226. doy : 7 // The week that contains Jan 1st is the first week of the year.
  27227. }
  27228. });
  27229. //! moment.js locale configuration
  27230. //! locale : Cambodian [km]
  27231. //! author : Kruy Vanna : https://github.com/kruyvanna
  27232. hooks.defineLocale('km', {
  27233. months: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
  27234. monthsShort: 'មករា_កុម្ភៈ_មីនា_មេសា_ឧសភា_មិថុនា_កក្កដា_សីហា_កញ្ញា_តុលា_វិច្ឆិកា_ធ្នូ'.split('_'),
  27235. weekdays: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
  27236. weekdaysShort: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
  27237. weekdaysMin: 'អាទិត្យ_ច័ន្ទ_អង្គារ_ពុធ_ព្រហស្បតិ៍_សុក្រ_សៅរ៍'.split('_'),
  27238. longDateFormat: {
  27239. LT: 'HH:mm',
  27240. LTS : 'HH:mm:ss',
  27241. L: 'DD/MM/YYYY',
  27242. LL: 'D MMMM YYYY',
  27243. LLL: 'D MMMM YYYY HH:mm',
  27244. LLLL: 'dddd, D MMMM YYYY HH:mm'
  27245. },
  27246. calendar: {
  27247. sameDay: '[ថ្ងៃនេះ ម៉ោង] LT',
  27248. nextDay: '[ស្អែក ម៉ោង] LT',
  27249. nextWeek: 'dddd [ម៉ោង] LT',
  27250. lastDay: '[ម្សិលមិញ ម៉ោង] LT',
  27251. lastWeek: 'dddd [សប្តាហ៍មុន] [ម៉ោង] LT',
  27252. sameElse: 'L'
  27253. },
  27254. relativeTime: {
  27255. future: '%sទៀត',
  27256. past: '%sមុន',
  27257. s: 'ប៉ុន្មានវិនាទី',
  27258. m: 'មួយនាទី',
  27259. mm: '%d នាទី',
  27260. h: 'មួយម៉ោង',
  27261. hh: '%d ម៉ោង',
  27262. d: 'មួយថ្ងៃ',
  27263. dd: '%d ថ្ងៃ',
  27264. M: 'មួយខែ',
  27265. MM: '%d ខែ',
  27266. y: 'មួយឆ្នាំ',
  27267. yy: '%d ឆ្នាំ'
  27268. },
  27269. week: {
  27270. dow: 1, // Monday is the first day of the week.
  27271. doy: 4 // The week that contains Jan 4th is the first week of the year.
  27272. }
  27273. });
  27274. //! moment.js locale configuration
  27275. //! locale : Kannada [kn]
  27276. //! author : Rajeev Naik : https://github.com/rajeevnaikte
  27277. var symbolMap$8 = {
  27278. '1': '೧',
  27279. '2': '೨',
  27280. '3': '೩',
  27281. '4': '೪',
  27282. '5': '೫',
  27283. '6': '೬',
  27284. '7': '೭',
  27285. '8': '೮',
  27286. '9': '೯',
  27287. '0': '೦'
  27288. };
  27289. var numberMap$7 = {
  27290. '೧': '1',
  27291. '೨': '2',
  27292. '೩': '3',
  27293. '೪': '4',
  27294. '೫': '5',
  27295. '೬': '6',
  27296. '೭': '7',
  27297. '೮': '8',
  27298. '೯': '9',
  27299. '೦': '0'
  27300. };
  27301. hooks.defineLocale('kn', {
  27302. months : 'ಜನವರಿ_ಫೆಬ್ರವರಿ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂಬರ್_ಅಕ್ಟೋಬರ್_ನವೆಂಬರ್_ಡಿಸೆಂಬರ್'.split('_'),
  27303. monthsShort : 'ಜನ_ಫೆಬ್ರ_ಮಾರ್ಚ್_ಏಪ್ರಿಲ್_ಮೇ_ಜೂನ್_ಜುಲೈ_ಆಗಸ್ಟ್_ಸೆಪ್ಟೆಂಬ_ಅಕ್ಟೋಬ_ನವೆಂಬ_ಡಿಸೆಂಬ'.split('_'),
  27304. monthsParseExact: true,
  27305. weekdays : 'ಭಾನುವಾರ_ಸೋಮವಾರ_ಮಂಗಳವಾರ_ಬುಧವಾರ_ಗುರುವಾರ_ಶುಕ್ರವಾರ_ಶನಿವಾರ'.split('_'),
  27306. weekdaysShort : 'ಭಾನು_ಸೋಮ_ಮಂಗಳ_ಬುಧ_ಗುರು_ಶುಕ್ರ_ಶನಿ'.split('_'),
  27307. weekdaysMin : 'ಭಾ_ಸೋ_ಮಂ_ಬು_ಗು_ಶು_ಶ'.split('_'),
  27308. longDateFormat : {
  27309. LT : 'A h:mm',
  27310. LTS : 'A h:mm:ss',
  27311. L : 'DD/MM/YYYY',
  27312. LL : 'D MMMM YYYY',
  27313. LLL : 'D MMMM YYYY, A h:mm',
  27314. LLLL : 'dddd, D MMMM YYYY, A h:mm'
  27315. },
  27316. calendar : {
  27317. sameDay : '[ಇಂದು] LT',
  27318. nextDay : '[ನಾಳೆ] LT',
  27319. nextWeek : 'dddd, LT',
  27320. lastDay : '[ನಿನ್ನೆ] LT',
  27321. lastWeek : '[ಕೊನೆಯ] dddd, LT',
  27322. sameElse : 'L'
  27323. },
  27324. relativeTime : {
  27325. future : '%s ನಂತರ',
  27326. past : '%s ಹಿಂದೆ',
  27327. s : 'ಕೆಲವು ಕ್ಷಣಗಳು',
  27328. m : 'ಒಂದು ನಿಮಿಷ',
  27329. mm : '%d ನಿಮಿಷ',
  27330. h : 'ಒಂದು ಗಂಟೆ',
  27331. hh : '%d ಗಂಟೆ',
  27332. d : 'ಒಂದು ದಿನ',
  27333. dd : '%d ದಿನ',
  27334. M : 'ಒಂದು ತಿಂಗಳು',
  27335. MM : '%d ತಿಂಗಳು',
  27336. y : 'ಒಂದು ವರ್ಷ',
  27337. yy : '%d ವರ್ಷ'
  27338. },
  27339. preparse: function (string) {
  27340. return string.replace(/[೧೨೩೪೫೬೭೮೯೦]/g, function (match) {
  27341. return numberMap$7[match];
  27342. });
  27343. },
  27344. postformat: function (string) {
  27345. return string.replace(/\d/g, function (match) {
  27346. return symbolMap$8[match];
  27347. });
  27348. },
  27349. meridiemParse: /ರಾತ್ರಿ|ಬೆಳಿಗ್ಗೆ|ಮಧ್ಯಾಹ್ನ|ಸಂಜೆ/,
  27350. meridiemHour : function (hour, meridiem) {
  27351. if (hour === 12) {
  27352. hour = 0;
  27353. }
  27354. if (meridiem === 'ರಾತ್ರಿ') {
  27355. return hour < 4 ? hour : hour + 12;
  27356. } else if (meridiem === 'ಬೆಳಿಗ್ಗೆ') {
  27357. return hour;
  27358. } else if (meridiem === 'ಮಧ್ಯಾಹ್ನ') {
  27359. return hour >= 10 ? hour : hour + 12;
  27360. } else if (meridiem === 'ಸಂಜೆ') {
  27361. return hour + 12;
  27362. }
  27363. },
  27364. meridiem : function (hour, minute, isLower) {
  27365. if (hour < 4) {
  27366. return 'ರಾತ್ರಿ';
  27367. } else if (hour < 10) {
  27368. return 'ಬೆಳಿಗ್ಗೆ';
  27369. } else if (hour < 17) {
  27370. return 'ಮಧ್ಯಾಹ್ನ';
  27371. } else if (hour < 20) {
  27372. return 'ಸಂಜೆ';
  27373. } else {
  27374. return 'ರಾತ್ರಿ';
  27375. }
  27376. },
  27377. dayOfMonthOrdinalParse: /\d{1,2}(ನೇ)/,
  27378. ordinal : function (number) {
  27379. return number + 'ನೇ';
  27380. },
  27381. week : {
  27382. dow : 0, // Sunday is the first day of the week.
  27383. doy : 6 // The week that contains Jan 1st is the first week of the year.
  27384. }
  27385. });
  27386. //! moment.js locale configuration
  27387. //! locale : Korean [ko]
  27388. //! author : Kyungwook, Park : https://github.com/kyungw00k
  27389. //! author : Jeeeyul Lee <jeeeyul@gmail.com>
  27390. hooks.defineLocale('ko', {
  27391. months : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
  27392. monthsShort : '1월_2월_3월_4월_5월_6월_7월_8월_9월_10월_11월_12월'.split('_'),
  27393. weekdays : '일요일_월요일_화요일_수요일_목요일_금요일_토요일'.split('_'),
  27394. weekdaysShort : '일_월_화_수_목_금_토'.split('_'),
  27395. weekdaysMin : '일_월_화_수_목_금_토'.split('_'),
  27396. longDateFormat : {
  27397. LT : 'A h:mm',
  27398. LTS : 'A h:mm:ss',
  27399. L : 'YYYY.MM.DD',
  27400. LL : 'YYYY년 MMMM D일',
  27401. LLL : 'YYYY년 MMMM D일 A h:mm',
  27402. LLLL : 'YYYY년 MMMM D일 dddd A h:mm',
  27403. l : 'YYYY.MM.DD',
  27404. ll : 'YYYY년 MMMM D일',
  27405. lll : 'YYYY년 MMMM D일 A h:mm',
  27406. llll : 'YYYY년 MMMM D일 dddd A h:mm'
  27407. },
  27408. calendar : {
  27409. sameDay : '오늘 LT',
  27410. nextDay : '내일 LT',
  27411. nextWeek : 'dddd LT',
  27412. lastDay : '어제 LT',
  27413. lastWeek : '지난주 dddd LT',
  27414. sameElse : 'L'
  27415. },
  27416. relativeTime : {
  27417. future : '%s 후',
  27418. past : '%s 전',
  27419. s : '몇 초',
  27420. ss : '%d초',
  27421. m : '1분',
  27422. mm : '%d분',
  27423. h : '한 시간',
  27424. hh : '%d시간',
  27425. d : '하루',
  27426. dd : '%d일',
  27427. M : '한 달',
  27428. MM : '%d달',
  27429. y : '일 년',
  27430. yy : '%d년'
  27431. },
  27432. dayOfMonthOrdinalParse : /\d{1,2}(일|월|주)/,
  27433. ordinal : function (number, period) {
  27434. switch (period) {
  27435. case 'd':
  27436. case 'D':
  27437. case 'DDD':
  27438. return number + '일';
  27439. case 'M':
  27440. return number + '월';
  27441. case 'w':
  27442. case 'W':
  27443. return number + '주';
  27444. default:
  27445. return number;
  27446. }
  27447. },
  27448. meridiemParse : /오전|오후/,
  27449. isPM : function (token) {
  27450. return token === '오후';
  27451. },
  27452. meridiem : function (hour, minute, isUpper) {
  27453. return hour < 12 ? '오전' : '오후';
  27454. }
  27455. });
  27456. //! moment.js locale configuration
  27457. //! locale : Kyrgyz [ky]
  27458. //! author : Chyngyz Arystan uulu : https://github.com/chyngyz
  27459. var suffixes$2 = {
  27460. 0: '-чү',
  27461. 1: '-чи',
  27462. 2: '-чи',
  27463. 3: '-чү',
  27464. 4: '-чү',
  27465. 5: '-чи',
  27466. 6: '-чы',
  27467. 7: '-чи',
  27468. 8: '-чи',
  27469. 9: '-чу',
  27470. 10: '-чу',
  27471. 20: '-чы',
  27472. 30: '-чу',
  27473. 40: '-чы',
  27474. 50: '-чү',
  27475. 60: '-чы',
  27476. 70: '-чи',
  27477. 80: '-чи',
  27478. 90: '-чу',
  27479. 100: '-чү'
  27480. };
  27481. hooks.defineLocale('ky', {
  27482. months : 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_'),
  27483. monthsShort : 'янв_фев_март_апр_май_июнь_июль_авг_сен_окт_ноя_дек'.split('_'),
  27484. weekdays : 'Жекшемби_Дүйшөмбү_Шейшемби_Шаршемби_Бейшемби_Жума_Ишемби'.split('_'),
  27485. weekdaysShort : 'Жек_Дүй_Шей_Шар_Бей_Жум_Ише'.split('_'),
  27486. weekdaysMin : 'Жк_Дй_Шй_Шр_Бй_Жм_Иш'.split('_'),
  27487. longDateFormat : {
  27488. LT : 'HH:mm',
  27489. LTS : 'HH:mm:ss',
  27490. L : 'DD.MM.YYYY',
  27491. LL : 'D MMMM YYYY',
  27492. LLL : 'D MMMM YYYY HH:mm',
  27493. LLLL : 'dddd, D MMMM YYYY HH:mm'
  27494. },
  27495. calendar : {
  27496. sameDay : '[Бүгүн саат] LT',
  27497. nextDay : '[Эртең саат] LT',
  27498. nextWeek : 'dddd [саат] LT',
  27499. lastDay : '[Кече саат] LT',
  27500. lastWeek : '[Өткен аптанын] dddd [күнү] [саат] LT',
  27501. sameElse : 'L'
  27502. },
  27503. relativeTime : {
  27504. future : '%s ичинде',
  27505. past : '%s мурун',
  27506. s : 'бирнече секунд',
  27507. m : 'бир мүнөт',
  27508. mm : '%d мүнөт',
  27509. h : 'бир саат',
  27510. hh : '%d саат',
  27511. d : 'бир күн',
  27512. dd : '%d күн',
  27513. M : 'бир ай',
  27514. MM : '%d ай',
  27515. y : 'бир жыл',
  27516. yy : '%d жыл'
  27517. },
  27518. dayOfMonthOrdinalParse: /\d{1,2}-(чи|чы|чү|чу)/,
  27519. ordinal : function (number) {
  27520. var a = number % 10,
  27521. b = number >= 100 ? 100 : null;
  27522. return number + (suffixes$2[number] || suffixes$2[a] || suffixes$2[b]);
  27523. },
  27524. week : {
  27525. dow : 1, // Monday is the first day of the week.
  27526. doy : 7 // The week that contains Jan 1st is the first week of the year.
  27527. }
  27528. });
  27529. //! moment.js locale configuration
  27530. //! locale : Luxembourgish [lb]
  27531. //! author : mweimerskirch : https://github.com/mweimerskirch
  27532. //! author : David Raison : https://github.com/kwisatz
  27533. function processRelativeTime$5(number, withoutSuffix, key, isFuture) {
  27534. var format = {
  27535. 'm': ['eng Minutt', 'enger Minutt'],
  27536. 'h': ['eng Stonn', 'enger Stonn'],
  27537. 'd': ['een Dag', 'engem Dag'],
  27538. 'M': ['ee Mount', 'engem Mount'],
  27539. 'y': ['ee Joer', 'engem Joer']
  27540. };
  27541. return withoutSuffix ? format[key][0] : format[key][1];
  27542. }
  27543. function processFutureTime(string) {
  27544. var number = string.substr(0, string.indexOf(' '));
  27545. if (eifelerRegelAppliesToNumber(number)) {
  27546. return 'a ' + string;
  27547. }
  27548. return 'an ' + string;
  27549. }
  27550. function processPastTime(string) {
  27551. var number = string.substr(0, string.indexOf(' '));
  27552. if (eifelerRegelAppliesToNumber(number)) {
  27553. return 'viru ' + string;
  27554. }
  27555. return 'virun ' + string;
  27556. }
  27557. /**
  27558. * Returns true if the word before the given number loses the '-n' ending.
  27559. * e.g. 'an 10 Deeg' but 'a 5 Deeg'
  27560. *
  27561. * @param number {integer}
  27562. * @returns {boolean}
  27563. */
  27564. function eifelerRegelAppliesToNumber(number) {
  27565. number = parseInt(number, 10);
  27566. if (isNaN(number)) {
  27567. return false;
  27568. }
  27569. if (number < 0) {
  27570. // Negative Number --> always true
  27571. return true;
  27572. } else if (number < 10) {
  27573. // Only 1 digit
  27574. if (4 <= number && number <= 7) {
  27575. return true;
  27576. }
  27577. return false;
  27578. } else if (number < 100) {
  27579. // 2 digits
  27580. var lastDigit = number % 10, firstDigit = number / 10;
  27581. if (lastDigit === 0) {
  27582. return eifelerRegelAppliesToNumber(firstDigit);
  27583. }
  27584. return eifelerRegelAppliesToNumber(lastDigit);
  27585. } else if (number < 10000) {
  27586. // 3 or 4 digits --> recursively check first digit
  27587. while (number >= 10) {
  27588. number = number / 10;
  27589. }
  27590. return eifelerRegelAppliesToNumber(number);
  27591. } else {
  27592. // Anything larger than 4 digits: recursively check first n-3 digits
  27593. number = number / 1000;
  27594. return eifelerRegelAppliesToNumber(number);
  27595. }
  27596. }
  27597. hooks.defineLocale('lb', {
  27598. months: 'Januar_Februar_Mäerz_Abrëll_Mee_Juni_Juli_August_September_Oktober_November_Dezember'.split('_'),
  27599. monthsShort: 'Jan._Febr._Mrz._Abr._Mee_Jun._Jul._Aug._Sept._Okt._Nov._Dez.'.split('_'),
  27600. monthsParseExact : true,
  27601. weekdays: 'Sonndeg_Méindeg_Dënschdeg_Mëttwoch_Donneschdeg_Freideg_Samschdeg'.split('_'),
  27602. weekdaysShort: 'So._Mé._Dë._Më._Do._Fr._Sa.'.split('_'),
  27603. weekdaysMin: 'So_Mé_Dë_Më_Do_Fr_Sa'.split('_'),
  27604. weekdaysParseExact : true,
  27605. longDateFormat: {
  27606. LT: 'H:mm [Auer]',
  27607. LTS: 'H:mm:ss [Auer]',
  27608. L: 'DD.MM.YYYY',
  27609. LL: 'D. MMMM YYYY',
  27610. LLL: 'D. MMMM YYYY H:mm [Auer]',
  27611. LLLL: 'dddd, D. MMMM YYYY H:mm [Auer]'
  27612. },
  27613. calendar: {
  27614. sameDay: '[Haut um] LT',
  27615. sameElse: 'L',
  27616. nextDay: '[Muer um] LT',
  27617. nextWeek: 'dddd [um] LT',
  27618. lastDay: '[Gëschter um] LT',
  27619. lastWeek: function () {
  27620. // Different date string for 'Dënschdeg' (Tuesday) and 'Donneschdeg' (Thursday) due to phonological rule
  27621. switch (this.day()) {
  27622. case 2:
  27623. case 4:
  27624. return '[Leschten] dddd [um] LT';
  27625. default:
  27626. return '[Leschte] dddd [um] LT';
  27627. }
  27628. }
  27629. },
  27630. relativeTime : {
  27631. future : processFutureTime,
  27632. past : processPastTime,
  27633. s : 'e puer Sekonnen',
  27634. m : processRelativeTime$5,
  27635. mm : '%d Minutten',
  27636. h : processRelativeTime$5,
  27637. hh : '%d Stonnen',
  27638. d : processRelativeTime$5,
  27639. dd : '%d Deeg',
  27640. M : processRelativeTime$5,
  27641. MM : '%d Méint',
  27642. y : processRelativeTime$5,
  27643. yy : '%d Joer'
  27644. },
  27645. dayOfMonthOrdinalParse: /\d{1,2}\./,
  27646. ordinal: '%d.',
  27647. week: {
  27648. dow: 1, // Monday is the first day of the week.
  27649. doy: 4 // The week that contains Jan 4th is the first week of the year.
  27650. }
  27651. });
  27652. //! moment.js locale configuration
  27653. //! locale : Lao [lo]
  27654. //! author : Ryan Hart : https://github.com/ryanhart2
  27655. hooks.defineLocale('lo', {
  27656. months : 'ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ'.split('_'),
  27657. monthsShort : 'ມັງກອນ_ກຸມພາ_ມີນາ_ເມສາ_ພຶດສະພາ_ມິຖຸນາ_ກໍລະກົດ_ສິງຫາ_ກັນຍາ_ຕຸລາ_ພະຈິກ_ທັນວາ'.split('_'),
  27658. weekdays : 'ອາທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
  27659. weekdaysShort : 'ທິດ_ຈັນ_ອັງຄານ_ພຸດ_ພະຫັດ_ສຸກ_ເສົາ'.split('_'),
  27660. weekdaysMin : 'ທ_ຈ_ອຄ_ພ_ພຫ_ສກ_ສ'.split('_'),
  27661. weekdaysParseExact : true,
  27662. longDateFormat : {
  27663. LT : 'HH:mm',
  27664. LTS : 'HH:mm:ss',
  27665. L : 'DD/MM/YYYY',
  27666. LL : 'D MMMM YYYY',
  27667. LLL : 'D MMMM YYYY HH:mm',
  27668. LLLL : 'ວັນdddd D MMMM YYYY HH:mm'
  27669. },
  27670. meridiemParse: /ຕອນເຊົ້າ|ຕອນແລງ/,
  27671. isPM: function (input) {
  27672. return input === 'ຕອນແລງ';
  27673. },
  27674. meridiem : function (hour, minute, isLower) {
  27675. if (hour < 12) {
  27676. return 'ຕອນເຊົ້າ';
  27677. } else {
  27678. return 'ຕອນແລງ';
  27679. }
  27680. },
  27681. calendar : {
  27682. sameDay : '[ມື້ນີ້ເວລາ] LT',
  27683. nextDay : '[ມື້ອື່ນເວລາ] LT',
  27684. nextWeek : '[ວັນ]dddd[ໜ້າເວລາ] LT',
  27685. lastDay : '[ມື້ວານນີ້ເວລາ] LT',
  27686. lastWeek : '[ວັນ]dddd[ແລ້ວນີ້ເວລາ] LT',
  27687. sameElse : 'L'
  27688. },
  27689. relativeTime : {
  27690. future : 'ອີກ %s',
  27691. past : '%sຜ່ານມາ',
  27692. s : 'ບໍ່ເທົ່າໃດວິນາທີ',
  27693. m : '1 ນາທີ',
  27694. mm : '%d ນາທີ',
  27695. h : '1 ຊົ່ວໂມງ',
  27696. hh : '%d ຊົ່ວໂມງ',
  27697. d : '1 ມື້',
  27698. dd : '%d ມື້',
  27699. M : '1 ເດືອນ',
  27700. MM : '%d ເດືອນ',
  27701. y : '1 ປີ',
  27702. yy : '%d ປີ'
  27703. },
  27704. dayOfMonthOrdinalParse: /(ທີ່)\d{1,2}/,
  27705. ordinal : function (number) {
  27706. return 'ທີ່' + number;
  27707. }
  27708. });
  27709. //! moment.js locale configuration
  27710. //! locale : Lithuanian [lt]
  27711. //! author : Mindaugas Mozūras : https://github.com/mmozuras
  27712. var units = {
  27713. 'm' : 'minutė_minutės_minutę',
  27714. 'mm': 'minutės_minučių_minutes',
  27715. 'h' : 'valanda_valandos_valandą',
  27716. 'hh': 'valandos_valandų_valandas',
  27717. 'd' : 'diena_dienos_dieną',
  27718. 'dd': 'dienos_dienų_dienas',
  27719. 'M' : 'mėnuo_mėnesio_mėnesį',
  27720. 'MM': 'mėnesiai_mėnesių_mėnesius',
  27721. 'y' : 'metai_metų_metus',
  27722. 'yy': 'metai_metų_metus'
  27723. };
  27724. function translateSeconds(number, withoutSuffix, key, isFuture) {
  27725. if (withoutSuffix) {
  27726. return 'kelios sekundės';
  27727. } else {
  27728. return isFuture ? 'kelių sekundžių' : 'kelias sekundes';
  27729. }
  27730. }
  27731. function translateSingular(number, withoutSuffix, key, isFuture) {
  27732. return withoutSuffix ? forms(key)[0] : (isFuture ? forms(key)[1] : forms(key)[2]);
  27733. }
  27734. function special(number) {
  27735. return number % 10 === 0 || (number > 10 && number < 20);
  27736. }
  27737. function forms(key) {
  27738. return units[key].split('_');
  27739. }
  27740. function translate$6(number, withoutSuffix, key, isFuture) {
  27741. var result = number + ' ';
  27742. if (number === 1) {
  27743. return result + translateSingular(number, withoutSuffix, key[0], isFuture);
  27744. } else if (withoutSuffix) {
  27745. return result + (special(number) ? forms(key)[1] : forms(key)[0]);
  27746. } else {
  27747. if (isFuture) {
  27748. return result + forms(key)[1];
  27749. } else {
  27750. return result + (special(number) ? forms(key)[1] : forms(key)[2]);
  27751. }
  27752. }
  27753. }
  27754. hooks.defineLocale('lt', {
  27755. months : {
  27756. format: 'sausio_vasario_kovo_balandžio_gegužės_birželio_liepos_rugpjūčio_rugsėjo_spalio_lapkričio_gruodžio'.split('_'),
  27757. standalone: 'sausis_vasaris_kovas_balandis_gegužė_birželis_liepa_rugpjūtis_rugsėjis_spalis_lapkritis_gruodis'.split('_'),
  27758. isFormat: /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?|MMMM?(\[[^\[\]]*\]|\s)+D[oD]?/
  27759. },
  27760. monthsShort : 'sau_vas_kov_bal_geg_bir_lie_rgp_rgs_spa_lap_grd'.split('_'),
  27761. weekdays : {
  27762. format: 'sekmadienį_pirmadienį_antradienį_trečiadienį_ketvirtadienį_penktadienį_šeštadienį'.split('_'),
  27763. standalone: 'sekmadienis_pirmadienis_antradienis_trečiadienis_ketvirtadienis_penktadienis_šeštadienis'.split('_'),
  27764. isFormat: /dddd HH:mm/
  27765. },
  27766. weekdaysShort : 'Sek_Pir_Ant_Tre_Ket_Pen_Šeš'.split('_'),
  27767. weekdaysMin : 'S_P_A_T_K_Pn_Š'.split('_'),
  27768. weekdaysParseExact : true,
  27769. longDateFormat : {
  27770. LT : 'HH:mm',
  27771. LTS : 'HH:mm:ss',
  27772. L : 'YYYY-MM-DD',
  27773. LL : 'YYYY [m.] MMMM D [d.]',
  27774. LLL : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
  27775. LLLL : 'YYYY [m.] MMMM D [d.], dddd, HH:mm [val.]',
  27776. l : 'YYYY-MM-DD',
  27777. ll : 'YYYY [m.] MMMM D [d.]',
  27778. lll : 'YYYY [m.] MMMM D [d.], HH:mm [val.]',
  27779. llll : 'YYYY [m.] MMMM D [d.], ddd, HH:mm [val.]'
  27780. },
  27781. calendar : {
  27782. sameDay : '[Šiandien] LT',
  27783. nextDay : '[Rytoj] LT',
  27784. nextWeek : 'dddd LT',
  27785. lastDay : '[Vakar] LT',
  27786. lastWeek : '[Praėjusį] dddd LT',
  27787. sameElse : 'L'
  27788. },
  27789. relativeTime : {
  27790. future : 'po %s',
  27791. past : 'prieš %s',
  27792. s : translateSeconds,
  27793. m : translateSingular,
  27794. mm : translate$6,
  27795. h : translateSingular,
  27796. hh : translate$6,
  27797. d : translateSingular,
  27798. dd : translate$6,
  27799. M : translateSingular,
  27800. MM : translate$6,
  27801. y : translateSingular,
  27802. yy : translate$6
  27803. },
  27804. dayOfMonthOrdinalParse: /\d{1,2}-oji/,
  27805. ordinal : function (number) {
  27806. return number + '-oji';
  27807. },
  27808. week : {
  27809. dow : 1, // Monday is the first day of the week.
  27810. doy : 4 // The week that contains Jan 4th is the first week of the year.
  27811. }
  27812. });
  27813. //! moment.js locale configuration
  27814. //! locale : Latvian [lv]
  27815. //! author : Kristaps Karlsons : https://github.com/skakri
  27816. //! author : Jānis Elmeris : https://github.com/JanisE
  27817. var units$1 = {
  27818. 'm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
  27819. 'mm': 'minūtes_minūtēm_minūte_minūtes'.split('_'),
  27820. 'h': 'stundas_stundām_stunda_stundas'.split('_'),
  27821. 'hh': 'stundas_stundām_stunda_stundas'.split('_'),
  27822. 'd': 'dienas_dienām_diena_dienas'.split('_'),
  27823. 'dd': 'dienas_dienām_diena_dienas'.split('_'),
  27824. 'M': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
  27825. 'MM': 'mēneša_mēnešiem_mēnesis_mēneši'.split('_'),
  27826. 'y': 'gada_gadiem_gads_gadi'.split('_'),
  27827. 'yy': 'gada_gadiem_gads_gadi'.split('_')
  27828. };
  27829. /**
  27830. * @param withoutSuffix boolean true = a length of time; false = before/after a period of time.
  27831. */
  27832. function format$1(forms, number, withoutSuffix) {
  27833. if (withoutSuffix) {
  27834. // E.g. "21 minūte", "3 minūtes".
  27835. return number % 10 === 1 && number % 100 !== 11 ? forms[2] : forms[3];
  27836. } else {
  27837. // E.g. "21 minūtes" as in "pēc 21 minūtes".
  27838. // E.g. "3 minūtēm" as in "pēc 3 minūtēm".
  27839. return number % 10 === 1 && number % 100 !== 11 ? forms[0] : forms[1];
  27840. }
  27841. }
  27842. function relativeTimeWithPlural$1(number, withoutSuffix, key) {
  27843. return number + ' ' + format$1(units$1[key], number, withoutSuffix);
  27844. }
  27845. function relativeTimeWithSingular(number, withoutSuffix, key) {
  27846. return format$1(units$1[key], number, withoutSuffix);
  27847. }
  27848. function relativeSeconds(number, withoutSuffix) {
  27849. return withoutSuffix ? 'dažas sekundes' : 'dažām sekundēm';
  27850. }
  27851. hooks.defineLocale('lv', {
  27852. months : 'janvāris_februāris_marts_aprīlis_maijs_jūnijs_jūlijs_augusts_septembris_oktobris_novembris_decembris'.split('_'),
  27853. monthsShort : 'jan_feb_mar_apr_mai_jūn_jūl_aug_sep_okt_nov_dec'.split('_'),
  27854. weekdays : 'svētdiena_pirmdiena_otrdiena_trešdiena_ceturtdiena_piektdiena_sestdiena'.split('_'),
  27855. weekdaysShort : 'Sv_P_O_T_C_Pk_S'.split('_'),
  27856. weekdaysMin : 'Sv_P_O_T_C_Pk_S'.split('_'),
  27857. weekdaysParseExact : true,
  27858. longDateFormat : {
  27859. LT : 'HH:mm',
  27860. LTS : 'HH:mm:ss',
  27861. L : 'DD.MM.YYYY.',
  27862. LL : 'YYYY. [gada] D. MMMM',
  27863. LLL : 'YYYY. [gada] D. MMMM, HH:mm',
  27864. LLLL : 'YYYY. [gada] D. MMMM, dddd, HH:mm'
  27865. },
  27866. calendar : {
  27867. sameDay : '[Šodien pulksten] LT',
  27868. nextDay : '[Rīt pulksten] LT',
  27869. nextWeek : 'dddd [pulksten] LT',
  27870. lastDay : '[Vakar pulksten] LT',
  27871. lastWeek : '[Pagājušā] dddd [pulksten] LT',
  27872. sameElse : 'L'
  27873. },
  27874. relativeTime : {
  27875. future : 'pēc %s',
  27876. past : 'pirms %s',
  27877. s : relativeSeconds,
  27878. m : relativeTimeWithSingular,
  27879. mm : relativeTimeWithPlural$1,
  27880. h : relativeTimeWithSingular,
  27881. hh : relativeTimeWithPlural$1,
  27882. d : relativeTimeWithSingular,
  27883. dd : relativeTimeWithPlural$1,
  27884. M : relativeTimeWithSingular,
  27885. MM : relativeTimeWithPlural$1,
  27886. y : relativeTimeWithSingular,
  27887. yy : relativeTimeWithPlural$1
  27888. },
  27889. dayOfMonthOrdinalParse: /\d{1,2}\./,
  27890. ordinal : '%d.',
  27891. week : {
  27892. dow : 1, // Monday is the first day of the week.
  27893. doy : 4 // The week that contains Jan 4th is the first week of the year.
  27894. }
  27895. });
  27896. //! moment.js locale configuration
  27897. //! locale : Montenegrin [me]
  27898. //! author : Miodrag Nikač <miodrag@restartit.me> : https://github.com/miodragnikac
  27899. var translator = {
  27900. words: { //Different grammatical cases
  27901. m: ['jedan minut', 'jednog minuta'],
  27902. mm: ['minut', 'minuta', 'minuta'],
  27903. h: ['jedan sat', 'jednog sata'],
  27904. hh: ['sat', 'sata', 'sati'],
  27905. dd: ['dan', 'dana', 'dana'],
  27906. MM: ['mjesec', 'mjeseca', 'mjeseci'],
  27907. yy: ['godina', 'godine', 'godina']
  27908. },
  27909. correctGrammaticalCase: function (number, wordKey) {
  27910. return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
  27911. },
  27912. translate: function (number, withoutSuffix, key) {
  27913. var wordKey = translator.words[key];
  27914. if (key.length === 1) {
  27915. return withoutSuffix ? wordKey[0] : wordKey[1];
  27916. } else {
  27917. return number + ' ' + translator.correctGrammaticalCase(number, wordKey);
  27918. }
  27919. }
  27920. };
  27921. hooks.defineLocale('me', {
  27922. months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
  27923. monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
  27924. monthsParseExact : true,
  27925. weekdays: 'nedjelja_ponedjeljak_utorak_srijeda_četvrtak_petak_subota'.split('_'),
  27926. weekdaysShort: 'ned._pon._uto._sri._čet._pet._sub.'.split('_'),
  27927. weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
  27928. weekdaysParseExact : true,
  27929. longDateFormat: {
  27930. LT: 'H:mm',
  27931. LTS : 'H:mm:ss',
  27932. L: 'DD.MM.YYYY',
  27933. LL: 'D. MMMM YYYY',
  27934. LLL: 'D. MMMM YYYY H:mm',
  27935. LLLL: 'dddd, D. MMMM YYYY H:mm'
  27936. },
  27937. calendar: {
  27938. sameDay: '[danas u] LT',
  27939. nextDay: '[sjutra u] LT',
  27940. nextWeek: function () {
  27941. switch (this.day()) {
  27942. case 0:
  27943. return '[u] [nedjelju] [u] LT';
  27944. case 3:
  27945. return '[u] [srijedu] [u] LT';
  27946. case 6:
  27947. return '[u] [subotu] [u] LT';
  27948. case 1:
  27949. case 2:
  27950. case 4:
  27951. case 5:
  27952. return '[u] dddd [u] LT';
  27953. }
  27954. },
  27955. lastDay : '[juče u] LT',
  27956. lastWeek : function () {
  27957. var lastWeekDays = [
  27958. '[prošle] [nedjelje] [u] LT',
  27959. '[prošlog] [ponedjeljka] [u] LT',
  27960. '[prošlog] [utorka] [u] LT',
  27961. '[prošle] [srijede] [u] LT',
  27962. '[prošlog] [četvrtka] [u] LT',
  27963. '[prošlog] [petka] [u] LT',
  27964. '[prošle] [subote] [u] LT'
  27965. ];
  27966. return lastWeekDays[this.day()];
  27967. },
  27968. sameElse : 'L'
  27969. },
  27970. relativeTime : {
  27971. future : 'za %s',
  27972. past : 'prije %s',
  27973. s : 'nekoliko sekundi',
  27974. m : translator.translate,
  27975. mm : translator.translate,
  27976. h : translator.translate,
  27977. hh : translator.translate,
  27978. d : 'dan',
  27979. dd : translator.translate,
  27980. M : 'mjesec',
  27981. MM : translator.translate,
  27982. y : 'godinu',
  27983. yy : translator.translate
  27984. },
  27985. dayOfMonthOrdinalParse: /\d{1,2}\./,
  27986. ordinal : '%d.',
  27987. week : {
  27988. dow : 1, // Monday is the first day of the week.
  27989. doy : 7 // The week that contains Jan 1st is the first week of the year.
  27990. }
  27991. });
  27992. //! moment.js locale configuration
  27993. //! locale : Maori [mi]
  27994. //! author : John Corrigan <robbiecloset@gmail.com> : https://github.com/johnideal
  27995. hooks.defineLocale('mi', {
  27996. months: 'Kohi-tāte_Hui-tanguru_Poutū-te-rangi_Paenga-whāwhā_Haratua_Pipiri_Hōngoingoi_Here-turi-kōkā_Mahuru_Whiringa-ā-nuku_Whiringa-ā-rangi_Hakihea'.split('_'),
  27997. monthsShort: 'Kohi_Hui_Pou_Pae_Hara_Pipi_Hōngoi_Here_Mahu_Whi-nu_Whi-ra_Haki'.split('_'),
  27998. monthsRegex: /(?:['a-z\u0101\u014D\u016B]+\-?){1,3}/i,
  27999. monthsStrictRegex: /(?:['a-z\u0101\u014D\u016B]+\-?){1,3}/i,
  28000. monthsShortRegex: /(?:['a-z\u0101\u014D\u016B]+\-?){1,3}/i,
  28001. monthsShortStrictRegex: /(?:['a-z\u0101\u014D\u016B]+\-?){1,2}/i,
  28002. weekdays: 'Rātapu_Mane_Tūrei_Wenerei_Tāite_Paraire_Hātarei'.split('_'),
  28003. weekdaysShort: 'Ta_Ma_Tū_We_Tāi_Pa_Hā'.split('_'),
  28004. weekdaysMin: 'Ta_Ma_Tū_We_Tāi_Pa_Hā'.split('_'),
  28005. longDateFormat: {
  28006. LT: 'HH:mm',
  28007. LTS: 'HH:mm:ss',
  28008. L: 'DD/MM/YYYY',
  28009. LL: 'D MMMM YYYY',
  28010. LLL: 'D MMMM YYYY [i] HH:mm',
  28011. LLLL: 'dddd, D MMMM YYYY [i] HH:mm'
  28012. },
  28013. calendar: {
  28014. sameDay: '[i teie mahana, i] LT',
  28015. nextDay: '[apopo i] LT',
  28016. nextWeek: 'dddd [i] LT',
  28017. lastDay: '[inanahi i] LT',
  28018. lastWeek: 'dddd [whakamutunga i] LT',
  28019. sameElse: 'L'
  28020. },
  28021. relativeTime: {
  28022. future: 'i roto i %s',
  28023. past: '%s i mua',
  28024. s: 'te hēkona ruarua',
  28025. m: 'he meneti',
  28026. mm: '%d meneti',
  28027. h: 'te haora',
  28028. hh: '%d haora',
  28029. d: 'he ra',
  28030. dd: '%d ra',
  28031. M: 'he marama',
  28032. MM: '%d marama',
  28033. y: 'he tau',
  28034. yy: '%d tau'
  28035. },
  28036. dayOfMonthOrdinalParse: /\d{1,2}º/,
  28037. ordinal: '%dº',
  28038. week : {
  28039. dow : 1, // Monday is the first day of the week.
  28040. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28041. }
  28042. });
  28043. //! moment.js locale configuration
  28044. //! locale : Macedonian [mk]
  28045. //! author : Borislav Mickov : https://github.com/B0k0
  28046. hooks.defineLocale('mk', {
  28047. months : 'јануари_февруари_март_април_мај_јуни_јули_август_септември_октомври_ноември_декември'.split('_'),
  28048. monthsShort : 'јан_фев_мар_апр_мај_јун_јул_авг_сеп_окт_ное_дек'.split('_'),
  28049. weekdays : 'недела_понеделник_вторник_среда_четврток_петок_сабота'.split('_'),
  28050. weekdaysShort : 'нед_пон_вто_сре_чет_пет_саб'.split('_'),
  28051. weekdaysMin : 'нe_пo_вт_ср_че_пе_сa'.split('_'),
  28052. longDateFormat : {
  28053. LT : 'H:mm',
  28054. LTS : 'H:mm:ss',
  28055. L : 'D.MM.YYYY',
  28056. LL : 'D MMMM YYYY',
  28057. LLL : 'D MMMM YYYY H:mm',
  28058. LLLL : 'dddd, D MMMM YYYY H:mm'
  28059. },
  28060. calendar : {
  28061. sameDay : '[Денес во] LT',
  28062. nextDay : '[Утре во] LT',
  28063. nextWeek : '[Во] dddd [во] LT',
  28064. lastDay : '[Вчера во] LT',
  28065. lastWeek : function () {
  28066. switch (this.day()) {
  28067. case 0:
  28068. case 3:
  28069. case 6:
  28070. return '[Изминатата] dddd [во] LT';
  28071. case 1:
  28072. case 2:
  28073. case 4:
  28074. case 5:
  28075. return '[Изминатиот] dddd [во] LT';
  28076. }
  28077. },
  28078. sameElse : 'L'
  28079. },
  28080. relativeTime : {
  28081. future : 'после %s',
  28082. past : 'пред %s',
  28083. s : 'неколку секунди',
  28084. m : 'минута',
  28085. mm : '%d минути',
  28086. h : 'час',
  28087. hh : '%d часа',
  28088. d : 'ден',
  28089. dd : '%d дена',
  28090. M : 'месец',
  28091. MM : '%d месеци',
  28092. y : 'година',
  28093. yy : '%d години'
  28094. },
  28095. dayOfMonthOrdinalParse: /\d{1,2}-(ев|ен|ти|ви|ри|ми)/,
  28096. ordinal : function (number) {
  28097. var lastDigit = number % 10,
  28098. last2Digits = number % 100;
  28099. if (number === 0) {
  28100. return number + '-ев';
  28101. } else if (last2Digits === 0) {
  28102. return number + '-ен';
  28103. } else if (last2Digits > 10 && last2Digits < 20) {
  28104. return number + '-ти';
  28105. } else if (lastDigit === 1) {
  28106. return number + '-ви';
  28107. } else if (lastDigit === 2) {
  28108. return number + '-ри';
  28109. } else if (lastDigit === 7 || lastDigit === 8) {
  28110. return number + '-ми';
  28111. } else {
  28112. return number + '-ти';
  28113. }
  28114. },
  28115. week : {
  28116. dow : 1, // Monday is the first day of the week.
  28117. doy : 7 // The week that contains Jan 1st is the first week of the year.
  28118. }
  28119. });
  28120. //! moment.js locale configuration
  28121. //! locale : Malayalam [ml]
  28122. //! author : Floyd Pink : https://github.com/floydpink
  28123. hooks.defineLocale('ml', {
  28124. months : 'ജനുവരി_ഫെബ്രുവരി_മാർച്ച്_ഏപ്രിൽ_മേയ്_ജൂൺ_ജൂലൈ_ഓഗസ്റ്റ്_സെപ്റ്റംബർ_ഒക്ടോബർ_നവംബർ_ഡിസംബർ'.split('_'),
  28125. monthsShort : 'ജനു._ഫെബ്രു._മാർ._ഏപ്രി._മേയ്_ജൂൺ_ജൂലൈ._ഓഗ._സെപ്റ്റ._ഒക്ടോ._നവം._ഡിസം.'.split('_'),
  28126. monthsParseExact : true,
  28127. weekdays : 'ഞായറാഴ്ച_തിങ്കളാഴ്ച_ചൊവ്വാഴ്ച_ബുധനാഴ്ച_വ്യാഴാഴ്ച_വെള്ളിയാഴ്ച_ശനിയാഴ്ച'.split('_'),
  28128. weekdaysShort : 'ഞായർ_തിങ്കൾ_ചൊവ്വ_ബുധൻ_വ്യാഴം_വെള്ളി_ശനി'.split('_'),
  28129. weekdaysMin : 'ഞാ_തി_ചൊ_ബു_വ്യാ_വെ_ശ'.split('_'),
  28130. longDateFormat : {
  28131. LT : 'A h:mm -നു',
  28132. LTS : 'A h:mm:ss -നു',
  28133. L : 'DD/MM/YYYY',
  28134. LL : 'D MMMM YYYY',
  28135. LLL : 'D MMMM YYYY, A h:mm -നു',
  28136. LLLL : 'dddd, D MMMM YYYY, A h:mm -നു'
  28137. },
  28138. calendar : {
  28139. sameDay : '[ഇന്ന്] LT',
  28140. nextDay : '[നാളെ] LT',
  28141. nextWeek : 'dddd, LT',
  28142. lastDay : '[ഇന്നലെ] LT',
  28143. lastWeek : '[കഴിഞ്ഞ] dddd, LT',
  28144. sameElse : 'L'
  28145. },
  28146. relativeTime : {
  28147. future : '%s കഴിഞ്ഞ്',
  28148. past : '%s മുൻപ്',
  28149. s : 'അൽപ നിമിഷങ്ങൾ',
  28150. m : 'ഒരു മിനിറ്റ്',
  28151. mm : '%d മിനിറ്റ്',
  28152. h : 'ഒരു മണിക്കൂർ',
  28153. hh : '%d മണിക്കൂർ',
  28154. d : 'ഒരു ദിവസം',
  28155. dd : '%d ദിവസം',
  28156. M : 'ഒരു മാസം',
  28157. MM : '%d മാസം',
  28158. y : 'ഒരു വർഷം',
  28159. yy : '%d വർഷം'
  28160. },
  28161. meridiemParse: /രാത്രി|രാവിലെ|ഉച്ച കഴിഞ്ഞ്|വൈകുന്നേരം|രാത്രി/i,
  28162. meridiemHour : function (hour, meridiem) {
  28163. if (hour === 12) {
  28164. hour = 0;
  28165. }
  28166. if ((meridiem === 'രാത്രി' && hour >= 4) ||
  28167. meridiem === 'ഉച്ച കഴിഞ്ഞ്' ||
  28168. meridiem === 'വൈകുന്നേരം') {
  28169. return hour + 12;
  28170. } else {
  28171. return hour;
  28172. }
  28173. },
  28174. meridiem : function (hour, minute, isLower) {
  28175. if (hour < 4) {
  28176. return 'രാത്രി';
  28177. } else if (hour < 12) {
  28178. return 'രാവിലെ';
  28179. } else if (hour < 17) {
  28180. return 'ഉച്ച കഴിഞ്ഞ്';
  28181. } else if (hour < 20) {
  28182. return 'വൈകുന്നേരം';
  28183. } else {
  28184. return 'രാത്രി';
  28185. }
  28186. }
  28187. });
  28188. //! moment.js locale configuration
  28189. //! locale : Marathi [mr]
  28190. //! author : Harshad Kale : https://github.com/kalehv
  28191. //! author : Vivek Athalye : https://github.com/vnathalye
  28192. var symbolMap$9 = {
  28193. '1': '१',
  28194. '2': '२',
  28195. '3': '३',
  28196. '4': '४',
  28197. '5': '५',
  28198. '6': '६',
  28199. '7': '७',
  28200. '8': '८',
  28201. '9': '९',
  28202. '0': '०'
  28203. };
  28204. var numberMap$8 = {
  28205. '१': '1',
  28206. '२': '2',
  28207. '३': '3',
  28208. '४': '4',
  28209. '५': '5',
  28210. '६': '6',
  28211. '७': '7',
  28212. '८': '8',
  28213. '९': '9',
  28214. '०': '0'
  28215. };
  28216. function relativeTimeMr(number, withoutSuffix, string, isFuture)
  28217. {
  28218. var output = '';
  28219. if (withoutSuffix) {
  28220. switch (string) {
  28221. case 's': output = 'काही सेकंद'; break;
  28222. case 'm': output = 'एक मिनिट'; break;
  28223. case 'mm': output = '%d मिनिटे'; break;
  28224. case 'h': output = 'एक तास'; break;
  28225. case 'hh': output = '%d तास'; break;
  28226. case 'd': output = 'एक दिवस'; break;
  28227. case 'dd': output = '%d दिवस'; break;
  28228. case 'M': output = 'एक महिना'; break;
  28229. case 'MM': output = '%d महिने'; break;
  28230. case 'y': output = 'एक वर्ष'; break;
  28231. case 'yy': output = '%d वर्षे'; break;
  28232. }
  28233. }
  28234. else {
  28235. switch (string) {
  28236. case 's': output = 'काही सेकंदां'; break;
  28237. case 'm': output = 'एका मिनिटा'; break;
  28238. case 'mm': output = '%d मिनिटां'; break;
  28239. case 'h': output = 'एका तासा'; break;
  28240. case 'hh': output = '%d तासां'; break;
  28241. case 'd': output = 'एका दिवसा'; break;
  28242. case 'dd': output = '%d दिवसां'; break;
  28243. case 'M': output = 'एका महिन्या'; break;
  28244. case 'MM': output = '%d महिन्यां'; break;
  28245. case 'y': output = 'एका वर्षा'; break;
  28246. case 'yy': output = '%d वर्षां'; break;
  28247. }
  28248. }
  28249. return output.replace(/%d/i, number);
  28250. }
  28251. hooks.defineLocale('mr', {
  28252. months : 'जानेवारी_फेब्रुवारी_मार्च_एप्रिल_मे_जून_जुलै_ऑगस्ट_सप्टेंबर_ऑक्टोबर_नोव्हेंबर_डिसेंबर'.split('_'),
  28253. monthsShort: 'जाने._फेब्रु._मार्च._एप्रि._मे._जून._जुलै._ऑग._सप्टें._ऑक्टो._नोव्हें._डिसें.'.split('_'),
  28254. monthsParseExact : true,
  28255. weekdays : 'रविवार_सोमवार_मंगळवार_बुधवार_गुरूवार_शुक्रवार_शनिवार'.split('_'),
  28256. weekdaysShort : 'रवि_सोम_मंगळ_बुध_गुरू_शुक्र_शनि'.split('_'),
  28257. weekdaysMin : 'र_सो_मं_बु_गु_शु_श'.split('_'),
  28258. longDateFormat : {
  28259. LT : 'A h:mm वाजता',
  28260. LTS : 'A h:mm:ss वाजता',
  28261. L : 'DD/MM/YYYY',
  28262. LL : 'D MMMM YYYY',
  28263. LLL : 'D MMMM YYYY, A h:mm वाजता',
  28264. LLLL : 'dddd, D MMMM YYYY, A h:mm वाजता'
  28265. },
  28266. calendar : {
  28267. sameDay : '[आज] LT',
  28268. nextDay : '[उद्या] LT',
  28269. nextWeek : 'dddd, LT',
  28270. lastDay : '[काल] LT',
  28271. lastWeek: '[मागील] dddd, LT',
  28272. sameElse : 'L'
  28273. },
  28274. relativeTime : {
  28275. future: '%sमध्ये',
  28276. past: '%sपूर्वी',
  28277. s: relativeTimeMr,
  28278. m: relativeTimeMr,
  28279. mm: relativeTimeMr,
  28280. h: relativeTimeMr,
  28281. hh: relativeTimeMr,
  28282. d: relativeTimeMr,
  28283. dd: relativeTimeMr,
  28284. M: relativeTimeMr,
  28285. MM: relativeTimeMr,
  28286. y: relativeTimeMr,
  28287. yy: relativeTimeMr
  28288. },
  28289. preparse: function (string) {
  28290. return string.replace(/[१२३४५६७८९०]/g, function (match) {
  28291. return numberMap$8[match];
  28292. });
  28293. },
  28294. postformat: function (string) {
  28295. return string.replace(/\d/g, function (match) {
  28296. return symbolMap$9[match];
  28297. });
  28298. },
  28299. meridiemParse: /रात्री|सकाळी|दुपारी|सायंकाळी/,
  28300. meridiemHour : function (hour, meridiem) {
  28301. if (hour === 12) {
  28302. hour = 0;
  28303. }
  28304. if (meridiem === 'रात्री') {
  28305. return hour < 4 ? hour : hour + 12;
  28306. } else if (meridiem === 'सकाळी') {
  28307. return hour;
  28308. } else if (meridiem === 'दुपारी') {
  28309. return hour >= 10 ? hour : hour + 12;
  28310. } else if (meridiem === 'सायंकाळी') {
  28311. return hour + 12;
  28312. }
  28313. },
  28314. meridiem: function (hour, minute, isLower) {
  28315. if (hour < 4) {
  28316. return 'रात्री';
  28317. } else if (hour < 10) {
  28318. return 'सकाळी';
  28319. } else if (hour < 17) {
  28320. return 'दुपारी';
  28321. } else if (hour < 20) {
  28322. return 'सायंकाळी';
  28323. } else {
  28324. return 'रात्री';
  28325. }
  28326. },
  28327. week : {
  28328. dow : 0, // Sunday is the first day of the week.
  28329. doy : 6 // The week that contains Jan 1st is the first week of the year.
  28330. }
  28331. });
  28332. //! moment.js locale configuration
  28333. //! locale : Malay [ms-my]
  28334. //! note : DEPRECATED, the correct one is [ms]
  28335. //! author : Weldan Jamili : https://github.com/weldan
  28336. hooks.defineLocale('ms-my', {
  28337. months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
  28338. monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
  28339. weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
  28340. weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
  28341. weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
  28342. longDateFormat : {
  28343. LT : 'HH.mm',
  28344. LTS : 'HH.mm.ss',
  28345. L : 'DD/MM/YYYY',
  28346. LL : 'D MMMM YYYY',
  28347. LLL : 'D MMMM YYYY [pukul] HH.mm',
  28348. LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
  28349. },
  28350. meridiemParse: /pagi|tengahari|petang|malam/,
  28351. meridiemHour: function (hour, meridiem) {
  28352. if (hour === 12) {
  28353. hour = 0;
  28354. }
  28355. if (meridiem === 'pagi') {
  28356. return hour;
  28357. } else if (meridiem === 'tengahari') {
  28358. return hour >= 11 ? hour : hour + 12;
  28359. } else if (meridiem === 'petang' || meridiem === 'malam') {
  28360. return hour + 12;
  28361. }
  28362. },
  28363. meridiem : function (hours, minutes, isLower) {
  28364. if (hours < 11) {
  28365. return 'pagi';
  28366. } else if (hours < 15) {
  28367. return 'tengahari';
  28368. } else if (hours < 19) {
  28369. return 'petang';
  28370. } else {
  28371. return 'malam';
  28372. }
  28373. },
  28374. calendar : {
  28375. sameDay : '[Hari ini pukul] LT',
  28376. nextDay : '[Esok pukul] LT',
  28377. nextWeek : 'dddd [pukul] LT',
  28378. lastDay : '[Kelmarin pukul] LT',
  28379. lastWeek : 'dddd [lepas pukul] LT',
  28380. sameElse : 'L'
  28381. },
  28382. relativeTime : {
  28383. future : 'dalam %s',
  28384. past : '%s yang lepas',
  28385. s : 'beberapa saat',
  28386. m : 'seminit',
  28387. mm : '%d minit',
  28388. h : 'sejam',
  28389. hh : '%d jam',
  28390. d : 'sehari',
  28391. dd : '%d hari',
  28392. M : 'sebulan',
  28393. MM : '%d bulan',
  28394. y : 'setahun',
  28395. yy : '%d tahun'
  28396. },
  28397. week : {
  28398. dow : 1, // Monday is the first day of the week.
  28399. doy : 7 // The week that contains Jan 1st is the first week of the year.
  28400. }
  28401. });
  28402. //! moment.js locale configuration
  28403. //! locale : Malay [ms]
  28404. //! author : Weldan Jamili : https://github.com/weldan
  28405. hooks.defineLocale('ms', {
  28406. months : 'Januari_Februari_Mac_April_Mei_Jun_Julai_Ogos_September_Oktober_November_Disember'.split('_'),
  28407. monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ogs_Sep_Okt_Nov_Dis'.split('_'),
  28408. weekdays : 'Ahad_Isnin_Selasa_Rabu_Khamis_Jumaat_Sabtu'.split('_'),
  28409. weekdaysShort : 'Ahd_Isn_Sel_Rab_Kha_Jum_Sab'.split('_'),
  28410. weekdaysMin : 'Ah_Is_Sl_Rb_Km_Jm_Sb'.split('_'),
  28411. longDateFormat : {
  28412. LT : 'HH.mm',
  28413. LTS : 'HH.mm.ss',
  28414. L : 'DD/MM/YYYY',
  28415. LL : 'D MMMM YYYY',
  28416. LLL : 'D MMMM YYYY [pukul] HH.mm',
  28417. LLLL : 'dddd, D MMMM YYYY [pukul] HH.mm'
  28418. },
  28419. meridiemParse: /pagi|tengahari|petang|malam/,
  28420. meridiemHour: function (hour, meridiem) {
  28421. if (hour === 12) {
  28422. hour = 0;
  28423. }
  28424. if (meridiem === 'pagi') {
  28425. return hour;
  28426. } else if (meridiem === 'tengahari') {
  28427. return hour >= 11 ? hour : hour + 12;
  28428. } else if (meridiem === 'petang' || meridiem === 'malam') {
  28429. return hour + 12;
  28430. }
  28431. },
  28432. meridiem : function (hours, minutes, isLower) {
  28433. if (hours < 11) {
  28434. return 'pagi';
  28435. } else if (hours < 15) {
  28436. return 'tengahari';
  28437. } else if (hours < 19) {
  28438. return 'petang';
  28439. } else {
  28440. return 'malam';
  28441. }
  28442. },
  28443. calendar : {
  28444. sameDay : '[Hari ini pukul] LT',
  28445. nextDay : '[Esok pukul] LT',
  28446. nextWeek : 'dddd [pukul] LT',
  28447. lastDay : '[Kelmarin pukul] LT',
  28448. lastWeek : 'dddd [lepas pukul] LT',
  28449. sameElse : 'L'
  28450. },
  28451. relativeTime : {
  28452. future : 'dalam %s',
  28453. past : '%s yang lepas',
  28454. s : 'beberapa saat',
  28455. m : 'seminit',
  28456. mm : '%d minit',
  28457. h : 'sejam',
  28458. hh : '%d jam',
  28459. d : 'sehari',
  28460. dd : '%d hari',
  28461. M : 'sebulan',
  28462. MM : '%d bulan',
  28463. y : 'setahun',
  28464. yy : '%d tahun'
  28465. },
  28466. week : {
  28467. dow : 1, // Monday is the first day of the week.
  28468. doy : 7 // The week that contains Jan 1st is the first week of the year.
  28469. }
  28470. });
  28471. //! moment.js locale configuration
  28472. //! locale : Burmese [my]
  28473. //! author : Squar team, mysquar.com
  28474. //! author : David Rossellat : https://github.com/gholadr
  28475. //! author : Tin Aung Lin : https://github.com/thanyawzinmin
  28476. var symbolMap$10 = {
  28477. '1': '၁',
  28478. '2': '၂',
  28479. '3': '၃',
  28480. '4': '၄',
  28481. '5': '၅',
  28482. '6': '၆',
  28483. '7': '၇',
  28484. '8': '၈',
  28485. '9': '၉',
  28486. '0': '၀'
  28487. };
  28488. var numberMap$9 = {
  28489. '၁': '1',
  28490. '၂': '2',
  28491. '၃': '3',
  28492. '၄': '4',
  28493. '၅': '5',
  28494. '၆': '6',
  28495. '၇': '7',
  28496. '၈': '8',
  28497. '၉': '9',
  28498. '၀': '0'
  28499. };
  28500. hooks.defineLocale('my', {
  28501. months: 'ဇန်နဝါရီ_ဖေဖော်ဝါရီ_မတ်_ဧပြီ_မေ_ဇွန်_ဇူလိုင်_သြဂုတ်_စက်တင်ဘာ_အောက်တိုဘာ_နိုဝင်ဘာ_ဒီဇင်ဘာ'.split('_'),
  28502. monthsShort: 'ဇန်_ဖေ_မတ်_ပြီ_မေ_ဇွန်_လိုင်_သြ_စက်_အောက်_နို_ဒီ'.split('_'),
  28503. weekdays: 'တနင်္ဂနွေ_တနင်္လာ_အင်္ဂါ_ဗုဒ္ဓဟူး_ကြာသပတေး_သောကြာ_စနေ'.split('_'),
  28504. weekdaysShort: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
  28505. weekdaysMin: 'နွေ_လာ_ဂါ_ဟူး_ကြာ_သော_နေ'.split('_'),
  28506. longDateFormat: {
  28507. LT: 'HH:mm',
  28508. LTS: 'HH:mm:ss',
  28509. L: 'DD/MM/YYYY',
  28510. LL: 'D MMMM YYYY',
  28511. LLL: 'D MMMM YYYY HH:mm',
  28512. LLLL: 'dddd D MMMM YYYY HH:mm'
  28513. },
  28514. calendar: {
  28515. sameDay: '[ယနေ.] LT [မှာ]',
  28516. nextDay: '[မနက်ဖြန်] LT [မှာ]',
  28517. nextWeek: 'dddd LT [မှာ]',
  28518. lastDay: '[မနေ.က] LT [မှာ]',
  28519. lastWeek: '[ပြီးခဲ့သော] dddd LT [မှာ]',
  28520. sameElse: 'L'
  28521. },
  28522. relativeTime: {
  28523. future: 'လာမည့် %s မှာ',
  28524. past: 'လွန်ခဲ့သော %s က',
  28525. s: 'စက္ကန်.အနည်းငယ်',
  28526. m: 'တစ်မိနစ်',
  28527. mm: '%d မိနစ်',
  28528. h: 'တစ်နာရီ',
  28529. hh: '%d နာရီ',
  28530. d: 'တစ်ရက်',
  28531. dd: '%d ရက်',
  28532. M: 'တစ်လ',
  28533. MM: '%d လ',
  28534. y: 'တစ်နှစ်',
  28535. yy: '%d နှစ်'
  28536. },
  28537. preparse: function (string) {
  28538. return string.replace(/[၁၂၃၄၅၆၇၈၉၀]/g, function (match) {
  28539. return numberMap$9[match];
  28540. });
  28541. },
  28542. postformat: function (string) {
  28543. return string.replace(/\d/g, function (match) {
  28544. return symbolMap$10[match];
  28545. });
  28546. },
  28547. week: {
  28548. dow: 1, // Monday is the first day of the week.
  28549. doy: 4 // The week that contains Jan 1st is the first week of the year.
  28550. }
  28551. });
  28552. //! moment.js locale configuration
  28553. //! locale : Norwegian Bokmål [nb]
  28554. //! authors : Espen Hovlandsdal : https://github.com/rexxars
  28555. //! Sigurd Gartmann : https://github.com/sigurdga
  28556. hooks.defineLocale('nb', {
  28557. months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
  28558. monthsShort : 'jan._feb._mars_april_mai_juni_juli_aug._sep._okt._nov._des.'.split('_'),
  28559. monthsParseExact : true,
  28560. weekdays : 'søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag'.split('_'),
  28561. weekdaysShort : 'sø._ma._ti._on._to._fr._lø.'.split('_'),
  28562. weekdaysMin : 'sø_ma_ti_on_to_fr_lø'.split('_'),
  28563. weekdaysParseExact : true,
  28564. longDateFormat : {
  28565. LT : 'HH:mm',
  28566. LTS : 'HH:mm:ss',
  28567. L : 'DD.MM.YYYY',
  28568. LL : 'D. MMMM YYYY',
  28569. LLL : 'D. MMMM YYYY [kl.] HH:mm',
  28570. LLLL : 'dddd D. MMMM YYYY [kl.] HH:mm'
  28571. },
  28572. calendar : {
  28573. sameDay: '[i dag kl.] LT',
  28574. nextDay: '[i morgen kl.] LT',
  28575. nextWeek: 'dddd [kl.] LT',
  28576. lastDay: '[i går kl.] LT',
  28577. lastWeek: '[forrige] dddd [kl.] LT',
  28578. sameElse: 'L'
  28579. },
  28580. relativeTime : {
  28581. future : 'om %s',
  28582. past : '%s siden',
  28583. s : 'noen sekunder',
  28584. m : 'ett minutt',
  28585. mm : '%d minutter',
  28586. h : 'en time',
  28587. hh : '%d timer',
  28588. d : 'en dag',
  28589. dd : '%d dager',
  28590. M : 'en måned',
  28591. MM : '%d måneder',
  28592. y : 'ett år',
  28593. yy : '%d år'
  28594. },
  28595. dayOfMonthOrdinalParse: /\d{1,2}\./,
  28596. ordinal : '%d.',
  28597. week : {
  28598. dow : 1, // Monday is the first day of the week.
  28599. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28600. }
  28601. });
  28602. //! moment.js locale configuration
  28603. //! locale : Nepalese [ne]
  28604. //! author : suvash : https://github.com/suvash
  28605. var symbolMap$11 = {
  28606. '1': '१',
  28607. '2': '२',
  28608. '3': '३',
  28609. '4': '४',
  28610. '5': '५',
  28611. '6': '६',
  28612. '7': '७',
  28613. '8': '८',
  28614. '9': '९',
  28615. '0': '०'
  28616. };
  28617. var numberMap$10 = {
  28618. '१': '1',
  28619. '२': '2',
  28620. '३': '3',
  28621. '४': '4',
  28622. '५': '5',
  28623. '६': '6',
  28624. '७': '7',
  28625. '८': '8',
  28626. '९': '9',
  28627. '०': '0'
  28628. };
  28629. hooks.defineLocale('ne', {
  28630. months : 'जनवरी_फेब्रुवरी_मार्च_अप्रिल_मई_जुन_जुलाई_अगष्ट_सेप्टेम्बर_अक्टोबर_नोभेम्बर_डिसेम्बर'.split('_'),
  28631. monthsShort : 'जन._फेब्रु._मार्च_अप्रि._मई_जुन_जुलाई._अग._सेप्ट._अक्टो._नोभे._डिसे.'.split('_'),
  28632. monthsParseExact : true,
  28633. weekdays : 'आइतबार_सोमबार_मङ्गलबार_बुधबार_बिहिबार_शुक्रबार_शनिबार'.split('_'),
  28634. weekdaysShort : 'आइत._सोम._मङ्गल._बुध._बिहि._शुक्र._शनि.'.split('_'),
  28635. weekdaysMin : 'आ._सो._मं._बु._बि._शु._श.'.split('_'),
  28636. weekdaysParseExact : true,
  28637. longDateFormat : {
  28638. LT : 'Aको h:mm बजे',
  28639. LTS : 'Aको h:mm:ss बजे',
  28640. L : 'DD/MM/YYYY',
  28641. LL : 'D MMMM YYYY',
  28642. LLL : 'D MMMM YYYY, Aको h:mm बजे',
  28643. LLLL : 'dddd, D MMMM YYYY, Aको h:mm बजे'
  28644. },
  28645. preparse: function (string) {
  28646. return string.replace(/[१२३४५६७८९०]/g, function (match) {
  28647. return numberMap$10[match];
  28648. });
  28649. },
  28650. postformat: function (string) {
  28651. return string.replace(/\d/g, function (match) {
  28652. return symbolMap$11[match];
  28653. });
  28654. },
  28655. meridiemParse: /राति|बिहान|दिउँसो|साँझ/,
  28656. meridiemHour : function (hour, meridiem) {
  28657. if (hour === 12) {
  28658. hour = 0;
  28659. }
  28660. if (meridiem === 'राति') {
  28661. return hour < 4 ? hour : hour + 12;
  28662. } else if (meridiem === 'बिहान') {
  28663. return hour;
  28664. } else if (meridiem === 'दिउँसो') {
  28665. return hour >= 10 ? hour : hour + 12;
  28666. } else if (meridiem === 'साँझ') {
  28667. return hour + 12;
  28668. }
  28669. },
  28670. meridiem : function (hour, minute, isLower) {
  28671. if (hour < 3) {
  28672. return 'राति';
  28673. } else if (hour < 12) {
  28674. return 'बिहान';
  28675. } else if (hour < 16) {
  28676. return 'दिउँसो';
  28677. } else if (hour < 20) {
  28678. return 'साँझ';
  28679. } else {
  28680. return 'राति';
  28681. }
  28682. },
  28683. calendar : {
  28684. sameDay : '[आज] LT',
  28685. nextDay : '[भोलि] LT',
  28686. nextWeek : '[आउँदो] dddd[,] LT',
  28687. lastDay : '[हिजो] LT',
  28688. lastWeek : '[गएको] dddd[,] LT',
  28689. sameElse : 'L'
  28690. },
  28691. relativeTime : {
  28692. future : '%sमा',
  28693. past : '%s अगाडि',
  28694. s : 'केही क्षण',
  28695. m : 'एक मिनेट',
  28696. mm : '%d मिनेट',
  28697. h : 'एक घण्टा',
  28698. hh : '%d घण्टा',
  28699. d : 'एक दिन',
  28700. dd : '%d दिन',
  28701. M : 'एक महिना',
  28702. MM : '%d महिना',
  28703. y : 'एक बर्ष',
  28704. yy : '%d बर्ष'
  28705. },
  28706. week : {
  28707. dow : 0, // Sunday is the first day of the week.
  28708. doy : 6 // The week that contains Jan 1st is the first week of the year.
  28709. }
  28710. });
  28711. //! moment.js locale configuration
  28712. //! locale : Dutch (Belgium) [nl-be]
  28713. //! author : Joris Röling : https://github.com/jorisroling
  28714. //! author : Jacob Middag : https://github.com/middagj
  28715. var monthsShortWithDots$1 = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_');
  28716. var monthsShortWithoutDots$1 = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
  28717. var monthsParse$2 = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i];
  28718. var monthsRegex$3 = /^(januari|februari|maart|april|mei|april|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i;
  28719. hooks.defineLocale('nl-be', {
  28720. months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
  28721. monthsShort : function (m, format) {
  28722. if (!m) {
  28723. return monthsShortWithDots$1;
  28724. } else if (/-MMM-/.test(format)) {
  28725. return monthsShortWithoutDots$1[m.month()];
  28726. } else {
  28727. return monthsShortWithDots$1[m.month()];
  28728. }
  28729. },
  28730. monthsRegex: monthsRegex$3,
  28731. monthsShortRegex: monthsRegex$3,
  28732. monthsStrictRegex: /^(januari|februari|maart|mei|ju[nl]i|april|augustus|september|oktober|november|december)/i,
  28733. monthsShortStrictRegex: /^(jan\.?|feb\.?|mrt\.?|apr\.?|mei|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i,
  28734. monthsParse : monthsParse$2,
  28735. longMonthsParse : monthsParse$2,
  28736. shortMonthsParse : monthsParse$2,
  28737. weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
  28738. weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
  28739. weekdaysMin : 'zo_ma_di_wo_do_vr_za'.split('_'),
  28740. weekdaysParseExact : true,
  28741. longDateFormat : {
  28742. LT : 'HH:mm',
  28743. LTS : 'HH:mm:ss',
  28744. L : 'DD/MM/YYYY',
  28745. LL : 'D MMMM YYYY',
  28746. LLL : 'D MMMM YYYY HH:mm',
  28747. LLLL : 'dddd D MMMM YYYY HH:mm'
  28748. },
  28749. calendar : {
  28750. sameDay: '[vandaag om] LT',
  28751. nextDay: '[morgen om] LT',
  28752. nextWeek: 'dddd [om] LT',
  28753. lastDay: '[gisteren om] LT',
  28754. lastWeek: '[afgelopen] dddd [om] LT',
  28755. sameElse: 'L'
  28756. },
  28757. relativeTime : {
  28758. future : 'over %s',
  28759. past : '%s geleden',
  28760. s : 'een paar seconden',
  28761. m : 'één minuut',
  28762. mm : '%d minuten',
  28763. h : 'één uur',
  28764. hh : '%d uur',
  28765. d : 'één dag',
  28766. dd : '%d dagen',
  28767. M : 'één maand',
  28768. MM : '%d maanden',
  28769. y : 'één jaar',
  28770. yy : '%d jaar'
  28771. },
  28772. dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
  28773. ordinal : function (number) {
  28774. return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
  28775. },
  28776. week : {
  28777. dow : 1, // Monday is the first day of the week.
  28778. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28779. }
  28780. });
  28781. //! moment.js locale configuration
  28782. //! locale : Dutch [nl]
  28783. //! author : Joris Röling : https://github.com/jorisroling
  28784. //! author : Jacob Middag : https://github.com/middagj
  28785. var monthsShortWithDots$2 = 'jan._feb._mrt._apr._mei_jun._jul._aug._sep._okt._nov._dec.'.split('_');
  28786. var monthsShortWithoutDots$2 = 'jan_feb_mrt_apr_mei_jun_jul_aug_sep_okt_nov_dec'.split('_');
  28787. var monthsParse$3 = [/^jan/i, /^feb/i, /^maart|mrt.?$/i, /^apr/i, /^mei$/i, /^jun[i.]?$/i, /^jul[i.]?$/i, /^aug/i, /^sep/i, /^okt/i, /^nov/i, /^dec/i];
  28788. var monthsRegex$4 = /^(januari|februari|maart|april|mei|april|ju[nl]i|augustus|september|oktober|november|december|jan\.?|feb\.?|mrt\.?|apr\.?|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i;
  28789. hooks.defineLocale('nl', {
  28790. months : 'januari_februari_maart_april_mei_juni_juli_augustus_september_oktober_november_december'.split('_'),
  28791. monthsShort : function (m, format) {
  28792. if (!m) {
  28793. return monthsShortWithDots$2;
  28794. } else if (/-MMM-/.test(format)) {
  28795. return monthsShortWithoutDots$2[m.month()];
  28796. } else {
  28797. return monthsShortWithDots$2[m.month()];
  28798. }
  28799. },
  28800. monthsRegex: monthsRegex$4,
  28801. monthsShortRegex: monthsRegex$4,
  28802. monthsStrictRegex: /^(januari|februari|maart|mei|ju[nl]i|april|augustus|september|oktober|november|december)/i,
  28803. monthsShortStrictRegex: /^(jan\.?|feb\.?|mrt\.?|apr\.?|mei|ju[nl]\.?|aug\.?|sep\.?|okt\.?|nov\.?|dec\.?)/i,
  28804. monthsParse : monthsParse$3,
  28805. longMonthsParse : monthsParse$3,
  28806. shortMonthsParse : monthsParse$3,
  28807. weekdays : 'zondag_maandag_dinsdag_woensdag_donderdag_vrijdag_zaterdag'.split('_'),
  28808. weekdaysShort : 'zo._ma._di._wo._do._vr._za.'.split('_'),
  28809. weekdaysMin : 'zo_ma_di_wo_do_vr_za'.split('_'),
  28810. weekdaysParseExact : true,
  28811. longDateFormat : {
  28812. LT : 'HH:mm',
  28813. LTS : 'HH:mm:ss',
  28814. L : 'DD-MM-YYYY',
  28815. LL : 'D MMMM YYYY',
  28816. LLL : 'D MMMM YYYY HH:mm',
  28817. LLLL : 'dddd D MMMM YYYY HH:mm'
  28818. },
  28819. calendar : {
  28820. sameDay: '[vandaag om] LT',
  28821. nextDay: '[morgen om] LT',
  28822. nextWeek: 'dddd [om] LT',
  28823. lastDay: '[gisteren om] LT',
  28824. lastWeek: '[afgelopen] dddd [om] LT',
  28825. sameElse: 'L'
  28826. },
  28827. relativeTime : {
  28828. future : 'over %s',
  28829. past : '%s geleden',
  28830. s : 'een paar seconden',
  28831. m : 'één minuut',
  28832. mm : '%d minuten',
  28833. h : 'één uur',
  28834. hh : '%d uur',
  28835. d : 'één dag',
  28836. dd : '%d dagen',
  28837. M : 'één maand',
  28838. MM : '%d maanden',
  28839. y : 'één jaar',
  28840. yy : '%d jaar'
  28841. },
  28842. dayOfMonthOrdinalParse: /\d{1,2}(ste|de)/,
  28843. ordinal : function (number) {
  28844. return number + ((number === 1 || number === 8 || number >= 20) ? 'ste' : 'de');
  28845. },
  28846. week : {
  28847. dow : 1, // Monday is the first day of the week.
  28848. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28849. }
  28850. });
  28851. //! moment.js locale configuration
  28852. //! locale : Nynorsk [nn]
  28853. //! author : https://github.com/mechuwind
  28854. hooks.defineLocale('nn', {
  28855. months : 'januar_februar_mars_april_mai_juni_juli_august_september_oktober_november_desember'.split('_'),
  28856. monthsShort : 'jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des'.split('_'),
  28857. weekdays : 'sundag_måndag_tysdag_onsdag_torsdag_fredag_laurdag'.split('_'),
  28858. weekdaysShort : 'sun_mån_tys_ons_tor_fre_lau'.split('_'),
  28859. weekdaysMin : 'su_må_ty_on_to_fr_lø'.split('_'),
  28860. longDateFormat : {
  28861. LT : 'HH:mm',
  28862. LTS : 'HH:mm:ss',
  28863. L : 'DD.MM.YYYY',
  28864. LL : 'D. MMMM YYYY',
  28865. LLL : 'D. MMMM YYYY [kl.] H:mm',
  28866. LLLL : 'dddd D. MMMM YYYY [kl.] HH:mm'
  28867. },
  28868. calendar : {
  28869. sameDay: '[I dag klokka] LT',
  28870. nextDay: '[I morgon klokka] LT',
  28871. nextWeek: 'dddd [klokka] LT',
  28872. lastDay: '[I går klokka] LT',
  28873. lastWeek: '[Føregåande] dddd [klokka] LT',
  28874. sameElse: 'L'
  28875. },
  28876. relativeTime : {
  28877. future : 'om %s',
  28878. past : '%s sidan',
  28879. s : 'nokre sekund',
  28880. m : 'eit minutt',
  28881. mm : '%d minutt',
  28882. h : 'ein time',
  28883. hh : '%d timar',
  28884. d : 'ein dag',
  28885. dd : '%d dagar',
  28886. M : 'ein månad',
  28887. MM : '%d månader',
  28888. y : 'eit år',
  28889. yy : '%d år'
  28890. },
  28891. dayOfMonthOrdinalParse: /\d{1,2}\./,
  28892. ordinal : '%d.',
  28893. week : {
  28894. dow : 1, // Monday is the first day of the week.
  28895. doy : 4 // The week that contains Jan 4th is the first week of the year.
  28896. }
  28897. });
  28898. //! moment.js locale configuration
  28899. //! locale : Punjabi (India) [pa-in]
  28900. //! author : Harpreet Singh : https://github.com/harpreetkhalsagtbit
  28901. var symbolMap$12 = {
  28902. '1': '੧',
  28903. '2': '੨',
  28904. '3': '੩',
  28905. '4': '੪',
  28906. '5': '੫',
  28907. '6': '੬',
  28908. '7': '੭',
  28909. '8': '੮',
  28910. '9': '੯',
  28911. '0': '੦'
  28912. };
  28913. var numberMap$11 = {
  28914. '੧': '1',
  28915. '੨': '2',
  28916. '੩': '3',
  28917. '੪': '4',
  28918. '੫': '5',
  28919. '੬': '6',
  28920. '੭': '7',
  28921. '੮': '8',
  28922. '੯': '9',
  28923. '੦': '0'
  28924. };
  28925. hooks.defineLocale('pa-in', {
  28926. // There are months name as per Nanakshahi Calender but they are not used as rigidly in modern Punjabi.
  28927. months : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
  28928. monthsShort : 'ਜਨਵਰੀ_ਫ਼ਰਵਰੀ_ਮਾਰਚ_ਅਪ੍ਰੈਲ_ਮਈ_ਜੂਨ_ਜੁਲਾਈ_ਅਗਸਤ_ਸਤੰਬਰ_ਅਕਤੂਬਰ_ਨਵੰਬਰ_ਦਸੰਬਰ'.split('_'),
  28929. weekdays : 'ਐਤਵਾਰ_ਸੋਮਵਾਰ_ਮੰਗਲਵਾਰ_ਬੁਧਵਾਰ_ਵੀਰਵਾਰ_ਸ਼ੁੱਕਰਵਾਰ_ਸ਼ਨੀਚਰਵਾਰ'.split('_'),
  28930. weekdaysShort : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
  28931. weekdaysMin : 'ਐਤ_ਸੋਮ_ਮੰਗਲ_ਬੁਧ_ਵੀਰ_ਸ਼ੁਕਰ_ਸ਼ਨੀ'.split('_'),
  28932. longDateFormat : {
  28933. LT : 'A h:mm ਵਜੇ',
  28934. LTS : 'A h:mm:ss ਵਜੇ',
  28935. L : 'DD/MM/YYYY',
  28936. LL : 'D MMMM YYYY',
  28937. LLL : 'D MMMM YYYY, A h:mm ਵਜੇ',
  28938. LLLL : 'dddd, D MMMM YYYY, A h:mm ਵਜੇ'
  28939. },
  28940. calendar : {
  28941. sameDay : '[ਅਜ] LT',
  28942. nextDay : '[ਕਲ] LT',
  28943. nextWeek : 'dddd, LT',
  28944. lastDay : '[ਕਲ] LT',
  28945. lastWeek : '[ਪਿਛਲੇ] dddd, LT',
  28946. sameElse : 'L'
  28947. },
  28948. relativeTime : {
  28949. future : '%s ਵਿੱਚ',
  28950. past : '%s ਪਿਛਲੇ',
  28951. s : 'ਕੁਝ ਸਕਿੰਟ',
  28952. m : 'ਇਕ ਮਿੰਟ',
  28953. mm : '%d ਮਿੰਟ',
  28954. h : 'ਇੱਕ ਘੰਟਾ',
  28955. hh : '%d ਘੰਟੇ',
  28956. d : 'ਇੱਕ ਦਿਨ',
  28957. dd : '%d ਦਿਨ',
  28958. M : 'ਇੱਕ ਮਹੀਨਾ',
  28959. MM : '%d ਮਹੀਨੇ',
  28960. y : 'ਇੱਕ ਸਾਲ',
  28961. yy : '%d ਸਾਲ'
  28962. },
  28963. preparse: function (string) {
  28964. return string.replace(/[੧੨੩੪੫੬੭੮੯੦]/g, function (match) {
  28965. return numberMap$11[match];
  28966. });
  28967. },
  28968. postformat: function (string) {
  28969. return string.replace(/\d/g, function (match) {
  28970. return symbolMap$12[match];
  28971. });
  28972. },
  28973. // Punjabi notation for meridiems are quite fuzzy in practice. While there exists
  28974. // a rigid notion of a 'Pahar' it is not used as rigidly in modern Punjabi.
  28975. meridiemParse: /ਰਾਤ|ਸਵੇਰ|ਦੁਪਹਿਰ|ਸ਼ਾਮ/,
  28976. meridiemHour : function (hour, meridiem) {
  28977. if (hour === 12) {
  28978. hour = 0;
  28979. }
  28980. if (meridiem === 'ਰਾਤ') {
  28981. return hour < 4 ? hour : hour + 12;
  28982. } else if (meridiem === 'ਸਵੇਰ') {
  28983. return hour;
  28984. } else if (meridiem === 'ਦੁਪਹਿਰ') {
  28985. return hour >= 10 ? hour : hour + 12;
  28986. } else if (meridiem === 'ਸ਼ਾਮ') {
  28987. return hour + 12;
  28988. }
  28989. },
  28990. meridiem : function (hour, minute, isLower) {
  28991. if (hour < 4) {
  28992. return 'ਰਾਤ';
  28993. } else if (hour < 10) {
  28994. return 'ਸਵੇਰ';
  28995. } else if (hour < 17) {
  28996. return 'ਦੁਪਹਿਰ';
  28997. } else if (hour < 20) {
  28998. return 'ਸ਼ਾਮ';
  28999. } else {
  29000. return 'ਰਾਤ';
  29001. }
  29002. },
  29003. week : {
  29004. dow : 0, // Sunday is the first day of the week.
  29005. doy : 6 // The week that contains Jan 1st is the first week of the year.
  29006. }
  29007. });
  29008. //! moment.js locale configuration
  29009. //! locale : Polish [pl]
  29010. //! author : Rafal Hirsz : https://github.com/evoL
  29011. var monthsNominative = 'styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień'.split('_');
  29012. var monthsSubjective = 'stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia'.split('_');
  29013. function plural$3(n) {
  29014. return (n % 10 < 5) && (n % 10 > 1) && ((~~(n / 10) % 10) !== 1);
  29015. }
  29016. function translate$7(number, withoutSuffix, key) {
  29017. var result = number + ' ';
  29018. switch (key) {
  29019. case 'm':
  29020. return withoutSuffix ? 'minuta' : 'minutę';
  29021. case 'mm':
  29022. return result + (plural$3(number) ? 'minuty' : 'minut');
  29023. case 'h':
  29024. return withoutSuffix ? 'godzina' : 'godzinę';
  29025. case 'hh':
  29026. return result + (plural$3(number) ? 'godziny' : 'godzin');
  29027. case 'MM':
  29028. return result + (plural$3(number) ? 'miesiące' : 'miesięcy');
  29029. case 'yy':
  29030. return result + (plural$3(number) ? 'lata' : 'lat');
  29031. }
  29032. }
  29033. hooks.defineLocale('pl', {
  29034. months : function (momentToFormat, format) {
  29035. if (!momentToFormat) {
  29036. return monthsNominative;
  29037. } else if (format === '') {
  29038. // Hack: if format empty we know this is used to generate
  29039. // RegExp by moment. Give then back both valid forms of months
  29040. // in RegExp ready format.
  29041. return '(' + monthsSubjective[momentToFormat.month()] + '|' + monthsNominative[momentToFormat.month()] + ')';
  29042. } else if (/D MMMM/.test(format)) {
  29043. return monthsSubjective[momentToFormat.month()];
  29044. } else {
  29045. return monthsNominative[momentToFormat.month()];
  29046. }
  29047. },
  29048. monthsShort : 'sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru'.split('_'),
  29049. weekdays : 'niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota'.split('_'),
  29050. weekdaysShort : 'ndz_pon_wt_śr_czw_pt_sob'.split('_'),
  29051. weekdaysMin : 'Nd_Pn_Wt_Śr_Cz_Pt_So'.split('_'),
  29052. longDateFormat : {
  29053. LT : 'HH:mm',
  29054. LTS : 'HH:mm:ss',
  29055. L : 'DD.MM.YYYY',
  29056. LL : 'D MMMM YYYY',
  29057. LLL : 'D MMMM YYYY HH:mm',
  29058. LLLL : 'dddd, D MMMM YYYY HH:mm'
  29059. },
  29060. calendar : {
  29061. sameDay: '[Dziś o] LT',
  29062. nextDay: '[Jutro o] LT',
  29063. nextWeek: function () {
  29064. switch (this.day()) {
  29065. case 0:
  29066. return '[W niedzielę o] LT';
  29067. case 2:
  29068. return '[We wtorek o] LT';
  29069. case 3:
  29070. return '[W środę o] LT';
  29071. case 6:
  29072. return '[W sobotę o] LT';
  29073. default:
  29074. return '[W] dddd [o] LT';
  29075. }
  29076. },
  29077. lastDay: '[Wczoraj o] LT',
  29078. lastWeek: function () {
  29079. switch (this.day()) {
  29080. case 0:
  29081. return '[W zeszłą niedzielę o] LT';
  29082. case 3:
  29083. return '[W zeszłą środę o] LT';
  29084. case 6:
  29085. return '[W zeszłą sobotę o] LT';
  29086. default:
  29087. return '[W zeszły] dddd [o] LT';
  29088. }
  29089. },
  29090. sameElse: 'L'
  29091. },
  29092. relativeTime : {
  29093. future : 'za %s',
  29094. past : '%s temu',
  29095. s : 'kilka sekund',
  29096. m : translate$7,
  29097. mm : translate$7,
  29098. h : translate$7,
  29099. hh : translate$7,
  29100. d : '1 dzień',
  29101. dd : '%d dni',
  29102. M : 'miesiąc',
  29103. MM : translate$7,
  29104. y : 'rok',
  29105. yy : translate$7
  29106. },
  29107. dayOfMonthOrdinalParse: /\d{1,2}\./,
  29108. ordinal : '%d.',
  29109. week : {
  29110. dow : 1, // Monday is the first day of the week.
  29111. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29112. }
  29113. });
  29114. //! moment.js locale configuration
  29115. //! locale : Portuguese (Brazil) [pt-br]
  29116. //! author : Caio Ribeiro Pereira : https://github.com/caio-ribeiro-pereira
  29117. hooks.defineLocale('pt-br', {
  29118. months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'),
  29119. monthsShort : 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'),
  29120. weekdays : 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'),
  29121. weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
  29122. weekdaysMin : 'Do_2ª_3ª_4ª_5ª_6ª_Sá'.split('_'),
  29123. weekdaysParseExact : true,
  29124. longDateFormat : {
  29125. LT : 'HH:mm',
  29126. LTS : 'HH:mm:ss',
  29127. L : 'DD/MM/YYYY',
  29128. LL : 'D [de] MMMM [de] YYYY',
  29129. LLL : 'D [de] MMMM [de] YYYY [às] HH:mm',
  29130. LLLL : 'dddd, D [de] MMMM [de] YYYY [às] HH:mm'
  29131. },
  29132. calendar : {
  29133. sameDay: '[Hoje às] LT',
  29134. nextDay: '[Amanhã às] LT',
  29135. nextWeek: 'dddd [às] LT',
  29136. lastDay: '[Ontem às] LT',
  29137. lastWeek: function () {
  29138. return (this.day() === 0 || this.day() === 6) ?
  29139. '[Último] dddd [às] LT' : // Saturday + Sunday
  29140. '[Última] dddd [às] LT'; // Monday - Friday
  29141. },
  29142. sameElse: 'L'
  29143. },
  29144. relativeTime : {
  29145. future : 'em %s',
  29146. past : '%s atrás',
  29147. s : 'poucos segundos',
  29148. ss : '%d segundos',
  29149. m : 'um minuto',
  29150. mm : '%d minutos',
  29151. h : 'uma hora',
  29152. hh : '%d horas',
  29153. d : 'um dia',
  29154. dd : '%d dias',
  29155. M : 'um mês',
  29156. MM : '%d meses',
  29157. y : 'um ano',
  29158. yy : '%d anos'
  29159. },
  29160. dayOfMonthOrdinalParse: /\d{1,2}º/,
  29161. ordinal : '%dº'
  29162. });
  29163. //! moment.js locale configuration
  29164. //! locale : Portuguese [pt]
  29165. //! author : Jefferson : https://github.com/jalex79
  29166. hooks.defineLocale('pt', {
  29167. months : 'janeiro_fevereiro_março_abril_maio_junho_julho_agosto_setembro_outubro_novembro_dezembro'.split('_'),
  29168. monthsShort : 'jan_fev_mar_abr_mai_jun_jul_ago_set_out_nov_dez'.split('_'),
  29169. weekdays : 'Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado'.split('_'),
  29170. weekdaysShort : 'Dom_Seg_Ter_Qua_Qui_Sex_Sáb'.split('_'),
  29171. weekdaysMin : 'Do_2ª_3ª_4ª_5ª_6ª_Sá'.split('_'),
  29172. weekdaysParseExact : true,
  29173. longDateFormat : {
  29174. LT : 'HH:mm',
  29175. LTS : 'HH:mm:ss',
  29176. L : 'DD/MM/YYYY',
  29177. LL : 'D [de] MMMM [de] YYYY',
  29178. LLL : 'D [de] MMMM [de] YYYY HH:mm',
  29179. LLLL : 'dddd, D [de] MMMM [de] YYYY HH:mm'
  29180. },
  29181. calendar : {
  29182. sameDay: '[Hoje às] LT',
  29183. nextDay: '[Amanhã às] LT',
  29184. nextWeek: 'dddd [às] LT',
  29185. lastDay: '[Ontem às] LT',
  29186. lastWeek: function () {
  29187. return (this.day() === 0 || this.day() === 6) ?
  29188. '[Último] dddd [às] LT' : // Saturday + Sunday
  29189. '[Última] dddd [às] LT'; // Monday - Friday
  29190. },
  29191. sameElse: 'L'
  29192. },
  29193. relativeTime : {
  29194. future : 'em %s',
  29195. past : 'há %s',
  29196. s : 'segundos',
  29197. m : 'um minuto',
  29198. mm : '%d minutos',
  29199. h : 'uma hora',
  29200. hh : '%d horas',
  29201. d : 'um dia',
  29202. dd : '%d dias',
  29203. M : 'um mês',
  29204. MM : '%d meses',
  29205. y : 'um ano',
  29206. yy : '%d anos'
  29207. },
  29208. dayOfMonthOrdinalParse: /\d{1,2}º/,
  29209. ordinal : '%dº',
  29210. week : {
  29211. dow : 1, // Monday is the first day of the week.
  29212. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29213. }
  29214. });
  29215. //! moment.js locale configuration
  29216. //! locale : Romanian [ro]
  29217. //! author : Vlad Gurdiga : https://github.com/gurdiga
  29218. //! author : Valentin Agachi : https://github.com/avaly
  29219. function relativeTimeWithPlural$2(number, withoutSuffix, key) {
  29220. var format = {
  29221. 'mm': 'minute',
  29222. 'hh': 'ore',
  29223. 'dd': 'zile',
  29224. 'MM': 'luni',
  29225. 'yy': 'ani'
  29226. },
  29227. separator = ' ';
  29228. if (number % 100 >= 20 || (number >= 100 && number % 100 === 0)) {
  29229. separator = ' de ';
  29230. }
  29231. return number + separator + format[key];
  29232. }
  29233. hooks.defineLocale('ro', {
  29234. months : 'ianuarie_februarie_martie_aprilie_mai_iunie_iulie_august_septembrie_octombrie_noiembrie_decembrie'.split('_'),
  29235. monthsShort : 'ian._febr._mart._apr._mai_iun._iul._aug._sept._oct._nov._dec.'.split('_'),
  29236. monthsParseExact: true,
  29237. weekdays : 'duminică_luni_marți_miercuri_joi_vineri_sâmbătă'.split('_'),
  29238. weekdaysShort : 'Dum_Lun_Mar_Mie_Joi_Vin_Sâm'.split('_'),
  29239. weekdaysMin : 'Du_Lu_Ma_Mi_Jo_Vi_Sâ'.split('_'),
  29240. longDateFormat : {
  29241. LT : 'H:mm',
  29242. LTS : 'H:mm:ss',
  29243. L : 'DD.MM.YYYY',
  29244. LL : 'D MMMM YYYY',
  29245. LLL : 'D MMMM YYYY H:mm',
  29246. LLLL : 'dddd, D MMMM YYYY H:mm'
  29247. },
  29248. calendar : {
  29249. sameDay: '[azi la] LT',
  29250. nextDay: '[mâine la] LT',
  29251. nextWeek: 'dddd [la] LT',
  29252. lastDay: '[ieri la] LT',
  29253. lastWeek: '[fosta] dddd [la] LT',
  29254. sameElse: 'L'
  29255. },
  29256. relativeTime : {
  29257. future : 'peste %s',
  29258. past : '%s în urmă',
  29259. s : 'câteva secunde',
  29260. m : 'un minut',
  29261. mm : relativeTimeWithPlural$2,
  29262. h : 'o oră',
  29263. hh : relativeTimeWithPlural$2,
  29264. d : 'o zi',
  29265. dd : relativeTimeWithPlural$2,
  29266. M : 'o lună',
  29267. MM : relativeTimeWithPlural$2,
  29268. y : 'un an',
  29269. yy : relativeTimeWithPlural$2
  29270. },
  29271. week : {
  29272. dow : 1, // Monday is the first day of the week.
  29273. doy : 7 // The week that contains Jan 1st is the first week of the year.
  29274. }
  29275. });
  29276. //! moment.js locale configuration
  29277. //! locale : Russian [ru]
  29278. //! author : Viktorminator : https://github.com/Viktorminator
  29279. //! Author : Menelion Elensúle : https://github.com/Oire
  29280. //! author : Коренберг Марк : https://github.com/socketpair
  29281. function plural$4(word, num) {
  29282. var forms = word.split('_');
  29283. return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
  29284. }
  29285. function relativeTimeWithPlural$3(number, withoutSuffix, key) {
  29286. var format = {
  29287. 'mm': withoutSuffix ? 'минута_минуты_минут' : 'минуту_минуты_минут',
  29288. 'hh': 'час_часа_часов',
  29289. 'dd': 'день_дня_дней',
  29290. 'MM': 'месяц_месяца_месяцев',
  29291. 'yy': 'год_года_лет'
  29292. };
  29293. if (key === 'm') {
  29294. return withoutSuffix ? 'минута' : 'минуту';
  29295. }
  29296. else {
  29297. return number + ' ' + plural$4(format[key], +number);
  29298. }
  29299. }
  29300. var monthsParse$4 = [/^янв/i, /^фев/i, /^мар/i, /^апр/i, /^ма[йя]/i, /^июн/i, /^июл/i, /^авг/i, /^сен/i, /^окт/i, /^ноя/i, /^дек/i];
  29301. // http://new.gramota.ru/spravka/rules/139-prop : § 103
  29302. // Сокращения месяцев: http://new.gramota.ru/spravka/buro/search-answer?s=242637
  29303. // CLDR data: http://www.unicode.org/cldr/charts/28/summary/ru.html#1753
  29304. hooks.defineLocale('ru', {
  29305. months : {
  29306. format: 'января_февраля_марта_апреля_мая_июня_июля_августа_сентября_октября_ноября_декабря'.split('_'),
  29307. standalone: 'январь_февраль_март_апрель_май_июнь_июль_август_сентябрь_октябрь_ноябрь_декабрь'.split('_')
  29308. },
  29309. monthsShort : {
  29310. // по CLDR именно "июл." и "июн.", но какой смысл менять букву на точку ?
  29311. format: 'янв._февр._мар._апр._мая_июня_июля_авг._сент._окт._нояб._дек.'.split('_'),
  29312. standalone: 'янв._февр._март_апр._май_июнь_июль_авг._сент._окт._нояб._дек.'.split('_')
  29313. },
  29314. weekdays : {
  29315. standalone: 'воскресенье_понедельник_вторник_среда_четверг_пятница_суббота'.split('_'),
  29316. format: 'воскресенье_понедельник_вторник_среду_четверг_пятницу_субботу'.split('_'),
  29317. isFormat: /\[ ?[Вв] ?(?:прошлую|следующую|эту)? ?\] ?dddd/
  29318. },
  29319. weekdaysShort : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
  29320. weekdaysMin : 'вс_пн_вт_ср_чт_пт_сб'.split('_'),
  29321. monthsParse : monthsParse$4,
  29322. longMonthsParse : monthsParse$4,
  29323. shortMonthsParse : monthsParse$4,
  29324. // полные названия с падежами, по три буквы, для некоторых, по 4 буквы, сокращения с точкой и без точки
  29325. monthsRegex: /^(январ[ья]|янв\.?|феврал[ья]|февр?\.?|марта?|мар\.?|апрел[ья]|апр\.?|ма[йя]|июн[ья]|июн\.?|июл[ья]|июл\.?|августа?|авг\.?|сентябр[ья]|сент?\.?|октябр[ья]|окт\.?|ноябр[ья]|нояб?\.?|декабр[ья]|дек\.?)/i,
  29326. // копия предыдущего
  29327. monthsShortRegex: /^(январ[ья]|янв\.?|феврал[ья]|февр?\.?|марта?|мар\.?|апрел[ья]|апр\.?|ма[йя]|июн[ья]|июн\.?|июл[ья]|июл\.?|августа?|авг\.?|сентябр[ья]|сент?\.?|октябр[ья]|окт\.?|ноябр[ья]|нояб?\.?|декабр[ья]|дек\.?)/i,
  29328. // полные названия с падежами
  29329. monthsStrictRegex: /^(январ[яь]|феврал[яь]|марта?|апрел[яь]|ма[яй]|июн[яь]|июл[яь]|августа?|сентябр[яь]|октябр[яь]|ноябр[яь]|декабр[яь])/i,
  29330. // Выражение, которое соотвествует только сокращённым формам
  29331. monthsShortStrictRegex: /^(янв\.|февр?\.|мар[т.]|апр\.|ма[яй]|июн[ья.]|июл[ья.]|авг\.|сент?\.|окт\.|нояб?\.|дек\.)/i,
  29332. longDateFormat : {
  29333. LT : 'HH:mm',
  29334. LTS : 'HH:mm:ss',
  29335. L : 'DD.MM.YYYY',
  29336. LL : 'D MMMM YYYY г.',
  29337. LLL : 'D MMMM YYYY г., HH:mm',
  29338. LLLL : 'dddd, D MMMM YYYY г., HH:mm'
  29339. },
  29340. calendar : {
  29341. sameDay: '[Сегодня в] LT',
  29342. nextDay: '[Завтра в] LT',
  29343. lastDay: '[Вчера в] LT',
  29344. nextWeek: function (now) {
  29345. if (now.week() !== this.week()) {
  29346. switch (this.day()) {
  29347. case 0:
  29348. return '[В следующее] dddd [в] LT';
  29349. case 1:
  29350. case 2:
  29351. case 4:
  29352. return '[В следующий] dddd [в] LT';
  29353. case 3:
  29354. case 5:
  29355. case 6:
  29356. return '[В следующую] dddd [в] LT';
  29357. }
  29358. } else {
  29359. if (this.day() === 2) {
  29360. return '[Во] dddd [в] LT';
  29361. } else {
  29362. return '[В] dddd [в] LT';
  29363. }
  29364. }
  29365. },
  29366. lastWeek: function (now) {
  29367. if (now.week() !== this.week()) {
  29368. switch (this.day()) {
  29369. case 0:
  29370. return '[В прошлое] dddd [в] LT';
  29371. case 1:
  29372. case 2:
  29373. case 4:
  29374. return '[В прошлый] dddd [в] LT';
  29375. case 3:
  29376. case 5:
  29377. case 6:
  29378. return '[В прошлую] dddd [в] LT';
  29379. }
  29380. } else {
  29381. if (this.day() === 2) {
  29382. return '[Во] dddd [в] LT';
  29383. } else {
  29384. return '[В] dddd [в] LT';
  29385. }
  29386. }
  29387. },
  29388. sameElse: 'L'
  29389. },
  29390. relativeTime : {
  29391. future : 'через %s',
  29392. past : '%s назад',
  29393. s : 'несколько секунд',
  29394. m : relativeTimeWithPlural$3,
  29395. mm : relativeTimeWithPlural$3,
  29396. h : 'час',
  29397. hh : relativeTimeWithPlural$3,
  29398. d : 'день',
  29399. dd : relativeTimeWithPlural$3,
  29400. M : 'месяц',
  29401. MM : relativeTimeWithPlural$3,
  29402. y : 'год',
  29403. yy : relativeTimeWithPlural$3
  29404. },
  29405. meridiemParse: /ночи|утра|дня|вечера/i,
  29406. isPM : function (input) {
  29407. return /^(дня|вечера)$/.test(input);
  29408. },
  29409. meridiem : function (hour, minute, isLower) {
  29410. if (hour < 4) {
  29411. return 'ночи';
  29412. } else if (hour < 12) {
  29413. return 'утра';
  29414. } else if (hour < 17) {
  29415. return 'дня';
  29416. } else {
  29417. return 'вечера';
  29418. }
  29419. },
  29420. dayOfMonthOrdinalParse: /\d{1,2}-(й|го|я)/,
  29421. ordinal: function (number, period) {
  29422. switch (period) {
  29423. case 'M':
  29424. case 'd':
  29425. case 'DDD':
  29426. return number + '-й';
  29427. case 'D':
  29428. return number + '-го';
  29429. case 'w':
  29430. case 'W':
  29431. return number + '-я';
  29432. default:
  29433. return number;
  29434. }
  29435. },
  29436. week : {
  29437. dow : 1, // Monday is the first day of the week.
  29438. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29439. }
  29440. });
  29441. //! moment.js locale configuration
  29442. //! locale : Sindhi [sd]
  29443. //! author : Narain Sagar : https://github.com/narainsagar
  29444. var months$6 = [
  29445. 'جنوري',
  29446. 'فيبروري',
  29447. 'مارچ',
  29448. 'اپريل',
  29449. 'مئي',
  29450. 'جون',
  29451. 'جولاءِ',
  29452. 'آگسٽ',
  29453. 'سيپٽمبر',
  29454. 'آڪٽوبر',
  29455. 'نومبر',
  29456. 'ڊسمبر'
  29457. ];
  29458. var days$1 = [
  29459. 'آچر',
  29460. 'سومر',
  29461. 'اڱارو',
  29462. 'اربع',
  29463. 'خميس',
  29464. 'جمع',
  29465. 'ڇنڇر'
  29466. ];
  29467. hooks.defineLocale('sd', {
  29468. months : months$6,
  29469. monthsShort : months$6,
  29470. weekdays : days$1,
  29471. weekdaysShort : days$1,
  29472. weekdaysMin : days$1,
  29473. longDateFormat : {
  29474. LT : 'HH:mm',
  29475. LTS : 'HH:mm:ss',
  29476. L : 'DD/MM/YYYY',
  29477. LL : 'D MMMM YYYY',
  29478. LLL : 'D MMMM YYYY HH:mm',
  29479. LLLL : 'dddd، D MMMM YYYY HH:mm'
  29480. },
  29481. meridiemParse: /صبح|شام/,
  29482. isPM : function (input) {
  29483. return 'شام' === input;
  29484. },
  29485. meridiem : function (hour, minute, isLower) {
  29486. if (hour < 12) {
  29487. return 'صبح';
  29488. }
  29489. return 'شام';
  29490. },
  29491. calendar : {
  29492. sameDay : '[اڄ] LT',
  29493. nextDay : '[سڀاڻي] LT',
  29494. nextWeek : 'dddd [اڳين هفتي تي] LT',
  29495. lastDay : '[ڪالهه] LT',
  29496. lastWeek : '[گزريل هفتي] dddd [تي] LT',
  29497. sameElse : 'L'
  29498. },
  29499. relativeTime : {
  29500. future : '%s پوء',
  29501. past : '%s اڳ',
  29502. s : 'چند سيڪنڊ',
  29503. m : 'هڪ منٽ',
  29504. mm : '%d منٽ',
  29505. h : 'هڪ ڪلاڪ',
  29506. hh : '%d ڪلاڪ',
  29507. d : 'هڪ ڏينهن',
  29508. dd : '%d ڏينهن',
  29509. M : 'هڪ مهينو',
  29510. MM : '%d مهينا',
  29511. y : 'هڪ سال',
  29512. yy : '%d سال'
  29513. },
  29514. preparse: function (string) {
  29515. return string.replace(/،/g, ',');
  29516. },
  29517. postformat: function (string) {
  29518. return string.replace(/,/g, '،');
  29519. },
  29520. week : {
  29521. dow : 1, // Monday is the first day of the week.
  29522. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29523. }
  29524. });
  29525. //! moment.js locale configuration
  29526. //! locale : Northern Sami [se]
  29527. //! authors : Bård Rolstad Henriksen : https://github.com/karamell
  29528. hooks.defineLocale('se', {
  29529. months : 'ođđajagemánnu_guovvamánnu_njukčamánnu_cuoŋománnu_miessemánnu_geassemánnu_suoidnemánnu_borgemánnu_čakčamánnu_golggotmánnu_skábmamánnu_juovlamánnu'.split('_'),
  29530. monthsShort : 'ođđj_guov_njuk_cuo_mies_geas_suoi_borg_čakč_golg_skáb_juov'.split('_'),
  29531. weekdays : 'sotnabeaivi_vuossárga_maŋŋebárga_gaskavahkku_duorastat_bearjadat_lávvardat'.split('_'),
  29532. weekdaysShort : 'sotn_vuos_maŋ_gask_duor_bear_láv'.split('_'),
  29533. weekdaysMin : 's_v_m_g_d_b_L'.split('_'),
  29534. longDateFormat : {
  29535. LT : 'HH:mm',
  29536. LTS : 'HH:mm:ss',
  29537. L : 'DD.MM.YYYY',
  29538. LL : 'MMMM D. [b.] YYYY',
  29539. LLL : 'MMMM D. [b.] YYYY [ti.] HH:mm',
  29540. LLLL : 'dddd, MMMM D. [b.] YYYY [ti.] HH:mm'
  29541. },
  29542. calendar : {
  29543. sameDay: '[otne ti] LT',
  29544. nextDay: '[ihttin ti] LT',
  29545. nextWeek: 'dddd [ti] LT',
  29546. lastDay: '[ikte ti] LT',
  29547. lastWeek: '[ovddit] dddd [ti] LT',
  29548. sameElse: 'L'
  29549. },
  29550. relativeTime : {
  29551. future : '%s geažes',
  29552. past : 'maŋit %s',
  29553. s : 'moadde sekunddat',
  29554. m : 'okta minuhta',
  29555. mm : '%d minuhtat',
  29556. h : 'okta diimmu',
  29557. hh : '%d diimmut',
  29558. d : 'okta beaivi',
  29559. dd : '%d beaivvit',
  29560. M : 'okta mánnu',
  29561. MM : '%d mánut',
  29562. y : 'okta jahki',
  29563. yy : '%d jagit'
  29564. },
  29565. dayOfMonthOrdinalParse: /\d{1,2}\./,
  29566. ordinal : '%d.',
  29567. week : {
  29568. dow : 1, // Monday is the first day of the week.
  29569. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29570. }
  29571. });
  29572. //! moment.js locale configuration
  29573. //! locale : Sinhalese [si]
  29574. //! author : Sampath Sitinamaluwa : https://github.com/sampathsris
  29575. /*jshint -W100*/
  29576. hooks.defineLocale('si', {
  29577. months : 'ජනවාරි_පෙබරවාරි_මාර්තු_අප්‍රේල්_මැයි_ජූනි_ජූලි_අගෝස්තු_සැප්තැම්බර්_ඔක්තෝබර්_නොවැම්බර්_දෙසැම්බර්'.split('_'),
  29578. monthsShort : 'ජන_පෙබ_මාර්_අප්_මැයි_ජූනි_ජූලි_අගෝ_සැප්_ඔක්_නොවැ_දෙසැ'.split('_'),
  29579. weekdays : 'ඉරිදා_සඳුදා_අඟහරුවාදා_බදාදා_බ්‍රහස්පතින්දා_සිකුරාදා_සෙනසුරාදා'.split('_'),
  29580. weekdaysShort : 'ඉරි_සඳු_අඟ_බදා_බ්‍රහ_සිකු_සෙන'.split('_'),
  29581. weekdaysMin : 'ඉ_ස_අ_බ_බ්‍ර_සි_සෙ'.split('_'),
  29582. weekdaysParseExact : true,
  29583. longDateFormat : {
  29584. LT : 'a h:mm',
  29585. LTS : 'a h:mm:ss',
  29586. L : 'YYYY/MM/DD',
  29587. LL : 'YYYY MMMM D',
  29588. LLL : 'YYYY MMMM D, a h:mm',
  29589. LLLL : 'YYYY MMMM D [වැනි] dddd, a h:mm:ss'
  29590. },
  29591. calendar : {
  29592. sameDay : '[අද] LT[ට]',
  29593. nextDay : '[හෙට] LT[ට]',
  29594. nextWeek : 'dddd LT[ට]',
  29595. lastDay : '[ඊයේ] LT[ට]',
  29596. lastWeek : '[පසුගිය] dddd LT[ට]',
  29597. sameElse : 'L'
  29598. },
  29599. relativeTime : {
  29600. future : '%sකින්',
  29601. past : '%sකට පෙර',
  29602. s : 'තත්පර කිහිපය',
  29603. m : 'මිනිත්තුව',
  29604. mm : 'මිනිත්තු %d',
  29605. h : 'පැය',
  29606. hh : 'පැය %d',
  29607. d : 'දිනය',
  29608. dd : 'දින %d',
  29609. M : 'මාසය',
  29610. MM : 'මාස %d',
  29611. y : 'වසර',
  29612. yy : 'වසර %d'
  29613. },
  29614. dayOfMonthOrdinalParse: /\d{1,2} වැනි/,
  29615. ordinal : function (number) {
  29616. return number + ' වැනි';
  29617. },
  29618. meridiemParse : /පෙර වරු|පස් වරු|පෙ.ව|ප.ව./,
  29619. isPM : function (input) {
  29620. return input === 'ප.ව.' || input === 'පස් වරු';
  29621. },
  29622. meridiem : function (hours, minutes, isLower) {
  29623. if (hours > 11) {
  29624. return isLower ? 'ප.ව.' : 'පස් වරු';
  29625. } else {
  29626. return isLower ? 'පෙ.ව.' : 'පෙර වරු';
  29627. }
  29628. }
  29629. });
  29630. //! moment.js locale configuration
  29631. //! locale : Slovak [sk]
  29632. //! author : Martin Minka : https://github.com/k2s
  29633. //! based on work of petrbela : https://github.com/petrbela
  29634. var months$7 = 'január_február_marec_apríl_máj_jún_júl_august_september_október_november_december'.split('_');
  29635. var monthsShort$5 = 'jan_feb_mar_apr_máj_jún_júl_aug_sep_okt_nov_dec'.split('_');
  29636. function plural$5(n) {
  29637. return (n > 1) && (n < 5);
  29638. }
  29639. function translate$8(number, withoutSuffix, key, isFuture) {
  29640. var result = number + ' ';
  29641. switch (key) {
  29642. case 's': // a few seconds / in a few seconds / a few seconds ago
  29643. return (withoutSuffix || isFuture) ? 'pár sekúnd' : 'pár sekundami';
  29644. case 'm': // a minute / in a minute / a minute ago
  29645. return withoutSuffix ? 'minúta' : (isFuture ? 'minútu' : 'minútou');
  29646. case 'mm': // 9 minutes / in 9 minutes / 9 minutes ago
  29647. if (withoutSuffix || isFuture) {
  29648. return result + (plural$5(number) ? 'minúty' : 'minút');
  29649. } else {
  29650. return result + 'minútami';
  29651. }
  29652. break;
  29653. case 'h': // an hour / in an hour / an hour ago
  29654. return withoutSuffix ? 'hodina' : (isFuture ? 'hodinu' : 'hodinou');
  29655. case 'hh': // 9 hours / in 9 hours / 9 hours ago
  29656. if (withoutSuffix || isFuture) {
  29657. return result + (plural$5(number) ? 'hodiny' : 'hodín');
  29658. } else {
  29659. return result + 'hodinami';
  29660. }
  29661. break;
  29662. case 'd': // a day / in a day / a day ago
  29663. return (withoutSuffix || isFuture) ? 'deň' : 'dňom';
  29664. case 'dd': // 9 days / in 9 days / 9 days ago
  29665. if (withoutSuffix || isFuture) {
  29666. return result + (plural$5(number) ? 'dni' : 'dní');
  29667. } else {
  29668. return result + 'dňami';
  29669. }
  29670. break;
  29671. case 'M': // a month / in a month / a month ago
  29672. return (withoutSuffix || isFuture) ? 'mesiac' : 'mesiacom';
  29673. case 'MM': // 9 months / in 9 months / 9 months ago
  29674. if (withoutSuffix || isFuture) {
  29675. return result + (plural$5(number) ? 'mesiace' : 'mesiacov');
  29676. } else {
  29677. return result + 'mesiacmi';
  29678. }
  29679. break;
  29680. case 'y': // a year / in a year / a year ago
  29681. return (withoutSuffix || isFuture) ? 'rok' : 'rokom';
  29682. case 'yy': // 9 years / in 9 years / 9 years ago
  29683. if (withoutSuffix || isFuture) {
  29684. return result + (plural$5(number) ? 'roky' : 'rokov');
  29685. } else {
  29686. return result + 'rokmi';
  29687. }
  29688. break;
  29689. }
  29690. }
  29691. hooks.defineLocale('sk', {
  29692. months : months$7,
  29693. monthsShort : monthsShort$5,
  29694. weekdays : 'nedeľa_pondelok_utorok_streda_štvrtok_piatok_sobota'.split('_'),
  29695. weekdaysShort : 'ne_po_ut_st_št_pi_so'.split('_'),
  29696. weekdaysMin : 'ne_po_ut_st_št_pi_so'.split('_'),
  29697. longDateFormat : {
  29698. LT: 'H:mm',
  29699. LTS : 'H:mm:ss',
  29700. L : 'DD.MM.YYYY',
  29701. LL : 'D. MMMM YYYY',
  29702. LLL : 'D. MMMM YYYY H:mm',
  29703. LLLL : 'dddd D. MMMM YYYY H:mm'
  29704. },
  29705. calendar : {
  29706. sameDay: '[dnes o] LT',
  29707. nextDay: '[zajtra o] LT',
  29708. nextWeek: function () {
  29709. switch (this.day()) {
  29710. case 0:
  29711. return '[v nedeľu o] LT';
  29712. case 1:
  29713. case 2:
  29714. return '[v] dddd [o] LT';
  29715. case 3:
  29716. return '[v stredu o] LT';
  29717. case 4:
  29718. return '[vo štvrtok o] LT';
  29719. case 5:
  29720. return '[v piatok o] LT';
  29721. case 6:
  29722. return '[v sobotu o] LT';
  29723. }
  29724. },
  29725. lastDay: '[včera o] LT',
  29726. lastWeek: function () {
  29727. switch (this.day()) {
  29728. case 0:
  29729. return '[minulú nedeľu o] LT';
  29730. case 1:
  29731. case 2:
  29732. return '[minulý] dddd [o] LT';
  29733. case 3:
  29734. return '[minulú stredu o] LT';
  29735. case 4:
  29736. case 5:
  29737. return '[minulý] dddd [o] LT';
  29738. case 6:
  29739. return '[minulú sobotu o] LT';
  29740. }
  29741. },
  29742. sameElse: 'L'
  29743. },
  29744. relativeTime : {
  29745. future : 'za %s',
  29746. past : 'pred %s',
  29747. s : translate$8,
  29748. m : translate$8,
  29749. mm : translate$8,
  29750. h : translate$8,
  29751. hh : translate$8,
  29752. d : translate$8,
  29753. dd : translate$8,
  29754. M : translate$8,
  29755. MM : translate$8,
  29756. y : translate$8,
  29757. yy : translate$8
  29758. },
  29759. dayOfMonthOrdinalParse: /\d{1,2}\./,
  29760. ordinal : '%d.',
  29761. week : {
  29762. dow : 1, // Monday is the first day of the week.
  29763. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29764. }
  29765. });
  29766. //! moment.js locale configuration
  29767. //! locale : Slovenian [sl]
  29768. //! author : Robert Sedovšek : https://github.com/sedovsek
  29769. function processRelativeTime$6(number, withoutSuffix, key, isFuture) {
  29770. var result = number + ' ';
  29771. switch (key) {
  29772. case 's':
  29773. return withoutSuffix || isFuture ? 'nekaj sekund' : 'nekaj sekundami';
  29774. case 'm':
  29775. return withoutSuffix ? 'ena minuta' : 'eno minuto';
  29776. case 'mm':
  29777. if (number === 1) {
  29778. result += withoutSuffix ? 'minuta' : 'minuto';
  29779. } else if (number === 2) {
  29780. result += withoutSuffix || isFuture ? 'minuti' : 'minutama';
  29781. } else if (number < 5) {
  29782. result += withoutSuffix || isFuture ? 'minute' : 'minutami';
  29783. } else {
  29784. result += withoutSuffix || isFuture ? 'minut' : 'minutami';
  29785. }
  29786. return result;
  29787. case 'h':
  29788. return withoutSuffix ? 'ena ura' : 'eno uro';
  29789. case 'hh':
  29790. if (number === 1) {
  29791. result += withoutSuffix ? 'ura' : 'uro';
  29792. } else if (number === 2) {
  29793. result += withoutSuffix || isFuture ? 'uri' : 'urama';
  29794. } else if (number < 5) {
  29795. result += withoutSuffix || isFuture ? 'ure' : 'urami';
  29796. } else {
  29797. result += withoutSuffix || isFuture ? 'ur' : 'urami';
  29798. }
  29799. return result;
  29800. case 'd':
  29801. return withoutSuffix || isFuture ? 'en dan' : 'enim dnem';
  29802. case 'dd':
  29803. if (number === 1) {
  29804. result += withoutSuffix || isFuture ? 'dan' : 'dnem';
  29805. } else if (number === 2) {
  29806. result += withoutSuffix || isFuture ? 'dni' : 'dnevoma';
  29807. } else {
  29808. result += withoutSuffix || isFuture ? 'dni' : 'dnevi';
  29809. }
  29810. return result;
  29811. case 'M':
  29812. return withoutSuffix || isFuture ? 'en mesec' : 'enim mesecem';
  29813. case 'MM':
  29814. if (number === 1) {
  29815. result += withoutSuffix || isFuture ? 'mesec' : 'mesecem';
  29816. } else if (number === 2) {
  29817. result += withoutSuffix || isFuture ? 'meseca' : 'mesecema';
  29818. } else if (number < 5) {
  29819. result += withoutSuffix || isFuture ? 'mesece' : 'meseci';
  29820. } else {
  29821. result += withoutSuffix || isFuture ? 'mesecev' : 'meseci';
  29822. }
  29823. return result;
  29824. case 'y':
  29825. return withoutSuffix || isFuture ? 'eno leto' : 'enim letom';
  29826. case 'yy':
  29827. if (number === 1) {
  29828. result += withoutSuffix || isFuture ? 'leto' : 'letom';
  29829. } else if (number === 2) {
  29830. result += withoutSuffix || isFuture ? 'leti' : 'letoma';
  29831. } else if (number < 5) {
  29832. result += withoutSuffix || isFuture ? 'leta' : 'leti';
  29833. } else {
  29834. result += withoutSuffix || isFuture ? 'let' : 'leti';
  29835. }
  29836. return result;
  29837. }
  29838. }
  29839. hooks.defineLocale('sl', {
  29840. months : 'januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december'.split('_'),
  29841. monthsShort : 'jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.'.split('_'),
  29842. monthsParseExact: true,
  29843. weekdays : 'nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota'.split('_'),
  29844. weekdaysShort : 'ned._pon._tor._sre._čet._pet._sob.'.split('_'),
  29845. weekdaysMin : 'ne_po_to_sr_če_pe_so'.split('_'),
  29846. weekdaysParseExact : true,
  29847. longDateFormat : {
  29848. LT : 'H:mm',
  29849. LTS : 'H:mm:ss',
  29850. L : 'DD.MM.YYYY',
  29851. LL : 'D. MMMM YYYY',
  29852. LLL : 'D. MMMM YYYY H:mm',
  29853. LLLL : 'dddd, D. MMMM YYYY H:mm'
  29854. },
  29855. calendar : {
  29856. sameDay : '[danes ob] LT',
  29857. nextDay : '[jutri ob] LT',
  29858. nextWeek : function () {
  29859. switch (this.day()) {
  29860. case 0:
  29861. return '[v] [nedeljo] [ob] LT';
  29862. case 3:
  29863. return '[v] [sredo] [ob] LT';
  29864. case 6:
  29865. return '[v] [soboto] [ob] LT';
  29866. case 1:
  29867. case 2:
  29868. case 4:
  29869. case 5:
  29870. return '[v] dddd [ob] LT';
  29871. }
  29872. },
  29873. lastDay : '[včeraj ob] LT',
  29874. lastWeek : function () {
  29875. switch (this.day()) {
  29876. case 0:
  29877. return '[prejšnjo] [nedeljo] [ob] LT';
  29878. case 3:
  29879. return '[prejšnjo] [sredo] [ob] LT';
  29880. case 6:
  29881. return '[prejšnjo] [soboto] [ob] LT';
  29882. case 1:
  29883. case 2:
  29884. case 4:
  29885. case 5:
  29886. return '[prejšnji] dddd [ob] LT';
  29887. }
  29888. },
  29889. sameElse : 'L'
  29890. },
  29891. relativeTime : {
  29892. future : 'čez %s',
  29893. past : 'pred %s',
  29894. s : processRelativeTime$6,
  29895. m : processRelativeTime$6,
  29896. mm : processRelativeTime$6,
  29897. h : processRelativeTime$6,
  29898. hh : processRelativeTime$6,
  29899. d : processRelativeTime$6,
  29900. dd : processRelativeTime$6,
  29901. M : processRelativeTime$6,
  29902. MM : processRelativeTime$6,
  29903. y : processRelativeTime$6,
  29904. yy : processRelativeTime$6
  29905. },
  29906. dayOfMonthOrdinalParse: /\d{1,2}\./,
  29907. ordinal : '%d.',
  29908. week : {
  29909. dow : 1, // Monday is the first day of the week.
  29910. doy : 7 // The week that contains Jan 1st is the first week of the year.
  29911. }
  29912. });
  29913. //! moment.js locale configuration
  29914. //! locale : Albanian [sq]
  29915. //! author : Flakërim Ismani : https://github.com/flakerimi
  29916. //! author : Menelion Elensúle : https://github.com/Oire
  29917. //! author : Oerd Cukalla : https://github.com/oerd
  29918. hooks.defineLocale('sq', {
  29919. months : 'Janar_Shkurt_Mars_Prill_Maj_Qershor_Korrik_Gusht_Shtator_Tetor_Nëntor_Dhjetor'.split('_'),
  29920. monthsShort : 'Jan_Shk_Mar_Pri_Maj_Qer_Kor_Gus_Sht_Tet_Nën_Dhj'.split('_'),
  29921. weekdays : 'E Diel_E Hënë_E Martë_E Mërkurë_E Enjte_E Premte_E Shtunë'.split('_'),
  29922. weekdaysShort : 'Die_Hën_Mar_Mër_Enj_Pre_Sht'.split('_'),
  29923. weekdaysMin : 'D_H_Ma_Më_E_P_Sh'.split('_'),
  29924. weekdaysParseExact : true,
  29925. meridiemParse: /PD|MD/,
  29926. isPM: function (input) {
  29927. return input.charAt(0) === 'M';
  29928. },
  29929. meridiem : function (hours, minutes, isLower) {
  29930. return hours < 12 ? 'PD' : 'MD';
  29931. },
  29932. longDateFormat : {
  29933. LT : 'HH:mm',
  29934. LTS : 'HH:mm:ss',
  29935. L : 'DD/MM/YYYY',
  29936. LL : 'D MMMM YYYY',
  29937. LLL : 'D MMMM YYYY HH:mm',
  29938. LLLL : 'dddd, D MMMM YYYY HH:mm'
  29939. },
  29940. calendar : {
  29941. sameDay : '[Sot në] LT',
  29942. nextDay : '[Nesër në] LT',
  29943. nextWeek : 'dddd [në] LT',
  29944. lastDay : '[Dje në] LT',
  29945. lastWeek : 'dddd [e kaluar në] LT',
  29946. sameElse : 'L'
  29947. },
  29948. relativeTime : {
  29949. future : 'në %s',
  29950. past : '%s më parë',
  29951. s : 'disa sekonda',
  29952. m : 'një minutë',
  29953. mm : '%d minuta',
  29954. h : 'një orë',
  29955. hh : '%d orë',
  29956. d : 'një ditë',
  29957. dd : '%d ditë',
  29958. M : 'një muaj',
  29959. MM : '%d muaj',
  29960. y : 'një vit',
  29961. yy : '%d vite'
  29962. },
  29963. dayOfMonthOrdinalParse: /\d{1,2}\./,
  29964. ordinal : '%d.',
  29965. week : {
  29966. dow : 1, // Monday is the first day of the week.
  29967. doy : 4 // The week that contains Jan 4th is the first week of the year.
  29968. }
  29969. });
  29970. //! moment.js locale configuration
  29971. //! locale : Serbian Cyrillic [sr-cyrl]
  29972. //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
  29973. var translator$1 = {
  29974. words: { //Different grammatical cases
  29975. m: ['један минут', 'једне минуте'],
  29976. mm: ['минут', 'минуте', 'минута'],
  29977. h: ['један сат', 'једног сата'],
  29978. hh: ['сат', 'сата', 'сати'],
  29979. dd: ['дан', 'дана', 'дана'],
  29980. MM: ['месец', 'месеца', 'месеци'],
  29981. yy: ['година', 'године', 'година']
  29982. },
  29983. correctGrammaticalCase: function (number, wordKey) {
  29984. return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
  29985. },
  29986. translate: function (number, withoutSuffix, key) {
  29987. var wordKey = translator$1.words[key];
  29988. if (key.length === 1) {
  29989. return withoutSuffix ? wordKey[0] : wordKey[1];
  29990. } else {
  29991. return number + ' ' + translator$1.correctGrammaticalCase(number, wordKey);
  29992. }
  29993. }
  29994. };
  29995. hooks.defineLocale('sr-cyrl', {
  29996. months: 'јануар_фебруар_март_април_мај_јун_јул_август_септембар_октобар_новембар_децембар'.split('_'),
  29997. monthsShort: 'јан._феб._мар._апр._мај_јун_јул_авг._сеп._окт._нов._дец.'.split('_'),
  29998. monthsParseExact: true,
  29999. weekdays: 'недеља_понедељак_уторак_среда_четвртак_петак_субота'.split('_'),
  30000. weekdaysShort: 'нед._пон._уто._сре._чет._пет._суб.'.split('_'),
  30001. weekdaysMin: 'не_по_ут_ср_че_пе_су'.split('_'),
  30002. weekdaysParseExact : true,
  30003. longDateFormat: {
  30004. LT: 'H:mm',
  30005. LTS : 'H:mm:ss',
  30006. L: 'DD.MM.YYYY',
  30007. LL: 'D. MMMM YYYY',
  30008. LLL: 'D. MMMM YYYY H:mm',
  30009. LLLL: 'dddd, D. MMMM YYYY H:mm'
  30010. },
  30011. calendar: {
  30012. sameDay: '[данас у] LT',
  30013. nextDay: '[сутра у] LT',
  30014. nextWeek: function () {
  30015. switch (this.day()) {
  30016. case 0:
  30017. return '[у] [недељу] [у] LT';
  30018. case 3:
  30019. return '[у] [среду] [у] LT';
  30020. case 6:
  30021. return '[у] [суботу] [у] LT';
  30022. case 1:
  30023. case 2:
  30024. case 4:
  30025. case 5:
  30026. return '[у] dddd [у] LT';
  30027. }
  30028. },
  30029. lastDay : '[јуче у] LT',
  30030. lastWeek : function () {
  30031. var lastWeekDays = [
  30032. '[прошле] [недеље] [у] LT',
  30033. '[прошлог] [понедељка] [у] LT',
  30034. '[прошлог] [уторка] [у] LT',
  30035. '[прошле] [среде] [у] LT',
  30036. '[прошлог] [четвртка] [у] LT',
  30037. '[прошлог] [петка] [у] LT',
  30038. '[прошле] [суботе] [у] LT'
  30039. ];
  30040. return lastWeekDays[this.day()];
  30041. },
  30042. sameElse : 'L'
  30043. },
  30044. relativeTime : {
  30045. future : 'за %s',
  30046. past : 'пре %s',
  30047. s : 'неколико секунди',
  30048. m : translator$1.translate,
  30049. mm : translator$1.translate,
  30050. h : translator$1.translate,
  30051. hh : translator$1.translate,
  30052. d : 'дан',
  30053. dd : translator$1.translate,
  30054. M : 'месец',
  30055. MM : translator$1.translate,
  30056. y : 'годину',
  30057. yy : translator$1.translate
  30058. },
  30059. dayOfMonthOrdinalParse: /\d{1,2}\./,
  30060. ordinal : '%d.',
  30061. week : {
  30062. dow : 1, // Monday is the first day of the week.
  30063. doy : 7 // The week that contains Jan 1st is the first week of the year.
  30064. }
  30065. });
  30066. //! moment.js locale configuration
  30067. //! locale : Serbian [sr]
  30068. //! author : Milan Janačković<milanjanackovic@gmail.com> : https://github.com/milan-j
  30069. var translator$2 = {
  30070. words: { //Different grammatical cases
  30071. m: ['jedan minut', 'jedne minute'],
  30072. mm: ['minut', 'minute', 'minuta'],
  30073. h: ['jedan sat', 'jednog sata'],
  30074. hh: ['sat', 'sata', 'sati'],
  30075. dd: ['dan', 'dana', 'dana'],
  30076. MM: ['mesec', 'meseca', 'meseci'],
  30077. yy: ['godina', 'godine', 'godina']
  30078. },
  30079. correctGrammaticalCase: function (number, wordKey) {
  30080. return number === 1 ? wordKey[0] : (number >= 2 && number <= 4 ? wordKey[1] : wordKey[2]);
  30081. },
  30082. translate: function (number, withoutSuffix, key) {
  30083. var wordKey = translator$2.words[key];
  30084. if (key.length === 1) {
  30085. return withoutSuffix ? wordKey[0] : wordKey[1];
  30086. } else {
  30087. return number + ' ' + translator$2.correctGrammaticalCase(number, wordKey);
  30088. }
  30089. }
  30090. };
  30091. hooks.defineLocale('sr', {
  30092. months: 'januar_februar_mart_april_maj_jun_jul_avgust_septembar_oktobar_novembar_decembar'.split('_'),
  30093. monthsShort: 'jan._feb._mar._apr._maj_jun_jul_avg._sep._okt._nov._dec.'.split('_'),
  30094. monthsParseExact: true,
  30095. weekdays: 'nedelja_ponedeljak_utorak_sreda_četvrtak_petak_subota'.split('_'),
  30096. weekdaysShort: 'ned._pon._uto._sre._čet._pet._sub.'.split('_'),
  30097. weekdaysMin: 'ne_po_ut_sr_če_pe_su'.split('_'),
  30098. weekdaysParseExact : true,
  30099. longDateFormat: {
  30100. LT: 'H:mm',
  30101. LTS : 'H:mm:ss',
  30102. L: 'DD.MM.YYYY',
  30103. LL: 'D. MMMM YYYY',
  30104. LLL: 'D. MMMM YYYY H:mm',
  30105. LLLL: 'dddd, D. MMMM YYYY H:mm'
  30106. },
  30107. calendar: {
  30108. sameDay: '[danas u] LT',
  30109. nextDay: '[sutra u] LT',
  30110. nextWeek: function () {
  30111. switch (this.day()) {
  30112. case 0:
  30113. return '[u] [nedelju] [u] LT';
  30114. case 3:
  30115. return '[u] [sredu] [u] LT';
  30116. case 6:
  30117. return '[u] [subotu] [u] LT';
  30118. case 1:
  30119. case 2:
  30120. case 4:
  30121. case 5:
  30122. return '[u] dddd [u] LT';
  30123. }
  30124. },
  30125. lastDay : '[juče u] LT',
  30126. lastWeek : function () {
  30127. var lastWeekDays = [
  30128. '[prošle] [nedelje] [u] LT',
  30129. '[prošlog] [ponedeljka] [u] LT',
  30130. '[prošlog] [utorka] [u] LT',
  30131. '[prošle] [srede] [u] LT',
  30132. '[prošlog] [četvrtka] [u] LT',
  30133. '[prošlog] [petka] [u] LT',
  30134. '[prošle] [subote] [u] LT'
  30135. ];
  30136. return lastWeekDays[this.day()];
  30137. },
  30138. sameElse : 'L'
  30139. },
  30140. relativeTime : {
  30141. future : 'za %s',
  30142. past : 'pre %s',
  30143. s : 'nekoliko sekundi',
  30144. m : translator$2.translate,
  30145. mm : translator$2.translate,
  30146. h : translator$2.translate,
  30147. hh : translator$2.translate,
  30148. d : 'dan',
  30149. dd : translator$2.translate,
  30150. M : 'mesec',
  30151. MM : translator$2.translate,
  30152. y : 'godinu',
  30153. yy : translator$2.translate
  30154. },
  30155. dayOfMonthOrdinalParse: /\d{1,2}\./,
  30156. ordinal : '%d.',
  30157. week : {
  30158. dow : 1, // Monday is the first day of the week.
  30159. doy : 7 // The week that contains Jan 1st is the first week of the year.
  30160. }
  30161. });
  30162. //! moment.js locale configuration
  30163. //! locale : siSwati [ss]
  30164. //! author : Nicolai Davies<mail@nicolai.io> : https://github.com/nicolaidavies
  30165. hooks.defineLocale('ss', {
  30166. months : "Bhimbidvwane_Indlovana_Indlov'lenkhulu_Mabasa_Inkhwekhweti_Inhlaba_Kholwane_Ingci_Inyoni_Imphala_Lweti_Ingongoni".split('_'),
  30167. monthsShort : 'Bhi_Ina_Inu_Mab_Ink_Inh_Kho_Igc_Iny_Imp_Lwe_Igo'.split('_'),
  30168. weekdays : 'Lisontfo_Umsombuluko_Lesibili_Lesitsatfu_Lesine_Lesihlanu_Umgcibelo'.split('_'),
  30169. weekdaysShort : 'Lis_Umb_Lsb_Les_Lsi_Lsh_Umg'.split('_'),
  30170. weekdaysMin : 'Li_Us_Lb_Lt_Ls_Lh_Ug'.split('_'),
  30171. weekdaysParseExact : true,
  30172. longDateFormat : {
  30173. LT : 'h:mm A',
  30174. LTS : 'h:mm:ss A',
  30175. L : 'DD/MM/YYYY',
  30176. LL : 'D MMMM YYYY',
  30177. LLL : 'D MMMM YYYY h:mm A',
  30178. LLLL : 'dddd, D MMMM YYYY h:mm A'
  30179. },
  30180. calendar : {
  30181. sameDay : '[Namuhla nga] LT',
  30182. nextDay : '[Kusasa nga] LT',
  30183. nextWeek : 'dddd [nga] LT',
  30184. lastDay : '[Itolo nga] LT',
  30185. lastWeek : 'dddd [leliphelile] [nga] LT',
  30186. sameElse : 'L'
  30187. },
  30188. relativeTime : {
  30189. future : 'nga %s',
  30190. past : 'wenteka nga %s',
  30191. s : 'emizuzwana lomcane',
  30192. m : 'umzuzu',
  30193. mm : '%d emizuzu',
  30194. h : 'lihora',
  30195. hh : '%d emahora',
  30196. d : 'lilanga',
  30197. dd : '%d emalanga',
  30198. M : 'inyanga',
  30199. MM : '%d tinyanga',
  30200. y : 'umnyaka',
  30201. yy : '%d iminyaka'
  30202. },
  30203. meridiemParse: /ekuseni|emini|entsambama|ebusuku/,
  30204. meridiem : function (hours, minutes, isLower) {
  30205. if (hours < 11) {
  30206. return 'ekuseni';
  30207. } else if (hours < 15) {
  30208. return 'emini';
  30209. } else if (hours < 19) {
  30210. return 'entsambama';
  30211. } else {
  30212. return 'ebusuku';
  30213. }
  30214. },
  30215. meridiemHour : function (hour, meridiem) {
  30216. if (hour === 12) {
  30217. hour = 0;
  30218. }
  30219. if (meridiem === 'ekuseni') {
  30220. return hour;
  30221. } else if (meridiem === 'emini') {
  30222. return hour >= 11 ? hour : hour + 12;
  30223. } else if (meridiem === 'entsambama' || meridiem === 'ebusuku') {
  30224. if (hour === 0) {
  30225. return 0;
  30226. }
  30227. return hour + 12;
  30228. }
  30229. },
  30230. dayOfMonthOrdinalParse: /\d{1,2}/,
  30231. ordinal : '%d',
  30232. week : {
  30233. dow : 1, // Monday is the first day of the week.
  30234. doy : 4 // The week that contains Jan 4th is the first week of the year.
  30235. }
  30236. });
  30237. //! moment.js locale configuration
  30238. //! locale : Swedish [sv]
  30239. //! author : Jens Alm : https://github.com/ulmus
  30240. hooks.defineLocale('sv', {
  30241. months : 'januari_februari_mars_april_maj_juni_juli_augusti_september_oktober_november_december'.split('_'),
  30242. monthsShort : 'jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec'.split('_'),
  30243. weekdays : 'söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag'.split('_'),
  30244. weekdaysShort : 'sön_mån_tis_ons_tor_fre_lör'.split('_'),
  30245. weekdaysMin : 'sö_må_ti_on_to_fr_lö'.split('_'),
  30246. longDateFormat : {
  30247. LT : 'HH:mm',
  30248. LTS : 'HH:mm:ss',
  30249. L : 'YYYY-MM-DD',
  30250. LL : 'D MMMM YYYY',
  30251. LLL : 'D MMMM YYYY [kl.] HH:mm',
  30252. LLLL : 'dddd D MMMM YYYY [kl.] HH:mm',
  30253. lll : 'D MMM YYYY HH:mm',
  30254. llll : 'ddd D MMM YYYY HH:mm'
  30255. },
  30256. calendar : {
  30257. sameDay: '[Idag] LT',
  30258. nextDay: '[Imorgon] LT',
  30259. lastDay: '[Igår] LT',
  30260. nextWeek: '[På] dddd LT',
  30261. lastWeek: '[I] dddd[s] LT',
  30262. sameElse: 'L'
  30263. },
  30264. relativeTime : {
  30265. future : 'om %s',
  30266. past : 'för %s sedan',
  30267. s : 'några sekunder',
  30268. m : 'en minut',
  30269. mm : '%d minuter',
  30270. h : 'en timme',
  30271. hh : '%d timmar',
  30272. d : 'en dag',
  30273. dd : '%d dagar',
  30274. M : 'en månad',
  30275. MM : '%d månader',
  30276. y : 'ett år',
  30277. yy : '%d år'
  30278. },
  30279. dayOfMonthOrdinalParse: /\d{1,2}(e|a)/,
  30280. ordinal : function (number) {
  30281. var b = number % 10,
  30282. output = (~~(number % 100 / 10) === 1) ? 'e' :
  30283. (b === 1) ? 'a' :
  30284. (b === 2) ? 'a' :
  30285. (b === 3) ? 'e' : 'e';
  30286. return number + output;
  30287. },
  30288. week : {
  30289. dow : 1, // Monday is the first day of the week.
  30290. doy : 4 // The week that contains Jan 4th is the first week of the year.
  30291. }
  30292. });
  30293. //! moment.js locale configuration
  30294. //! locale : Swahili [sw]
  30295. //! author : Fahad Kassim : https://github.com/fadsel
  30296. hooks.defineLocale('sw', {
  30297. months : 'Januari_Februari_Machi_Aprili_Mei_Juni_Julai_Agosti_Septemba_Oktoba_Novemba_Desemba'.split('_'),
  30298. monthsShort : 'Jan_Feb_Mac_Apr_Mei_Jun_Jul_Ago_Sep_Okt_Nov_Des'.split('_'),
  30299. weekdays : 'Jumapili_Jumatatu_Jumanne_Jumatano_Alhamisi_Ijumaa_Jumamosi'.split('_'),
  30300. weekdaysShort : 'Jpl_Jtat_Jnne_Jtan_Alh_Ijm_Jmos'.split('_'),
  30301. weekdaysMin : 'J2_J3_J4_J5_Al_Ij_J1'.split('_'),
  30302. weekdaysParseExact : true,
  30303. longDateFormat : {
  30304. LT : 'HH:mm',
  30305. LTS : 'HH:mm:ss',
  30306. L : 'DD.MM.YYYY',
  30307. LL : 'D MMMM YYYY',
  30308. LLL : 'D MMMM YYYY HH:mm',
  30309. LLLL : 'dddd, D MMMM YYYY HH:mm'
  30310. },
  30311. calendar : {
  30312. sameDay : '[leo saa] LT',
  30313. nextDay : '[kesho saa] LT',
  30314. nextWeek : '[wiki ijayo] dddd [saat] LT',
  30315. lastDay : '[jana] LT',
  30316. lastWeek : '[wiki iliyopita] dddd [saat] LT',
  30317. sameElse : 'L'
  30318. },
  30319. relativeTime : {
  30320. future : '%s baadaye',
  30321. past : 'tokea %s',
  30322. s : 'hivi punde',
  30323. m : 'dakika moja',
  30324. mm : 'dakika %d',
  30325. h : 'saa limoja',
  30326. hh : 'masaa %d',
  30327. d : 'siku moja',
  30328. dd : 'masiku %d',
  30329. M : 'mwezi mmoja',
  30330. MM : 'miezi %d',
  30331. y : 'mwaka mmoja',
  30332. yy : 'miaka %d'
  30333. },
  30334. week : {
  30335. dow : 1, // Monday is the first day of the week.
  30336. doy : 7 // The week that contains Jan 1st is the first week of the year.
  30337. }
  30338. });
  30339. //! moment.js locale configuration
  30340. //! locale : Tamil [ta]
  30341. //! author : Arjunkumar Krishnamoorthy : https://github.com/tk120404
  30342. var symbolMap$13 = {
  30343. '1': '௧',
  30344. '2': '௨',
  30345. '3': '௩',
  30346. '4': '௪',
  30347. '5': '௫',
  30348. '6': '௬',
  30349. '7': '௭',
  30350. '8': '௮',
  30351. '9': '௯',
  30352. '0': '௦'
  30353. };
  30354. var numberMap$12 = {
  30355. '௧': '1',
  30356. '௨': '2',
  30357. '௩': '3',
  30358. '௪': '4',
  30359. '௫': '5',
  30360. '௬': '6',
  30361. '௭': '7',
  30362. '௮': '8',
  30363. '௯': '9',
  30364. '௦': '0'
  30365. };
  30366. hooks.defineLocale('ta', {
  30367. months : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
  30368. monthsShort : 'ஜனவரி_பிப்ரவரி_மார்ச்_ஏப்ரல்_மே_ஜூன்_ஜூலை_ஆகஸ்ட்_செப்டெம்பர்_அக்டோபர்_நவம்பர்_டிசம்பர்'.split('_'),
  30369. weekdays : 'ஞாயிற்றுக்கிழமை_திங்கட்கிழமை_செவ்வாய்கிழமை_புதன்கிழமை_வியாழக்கிழமை_வெள்ளிக்கிழமை_சனிக்கிழமை'.split('_'),
  30370. weekdaysShort : 'ஞாயிறு_திங்கள்_செவ்வாய்_புதன்_வியாழன்_வெள்ளி_சனி'.split('_'),
  30371. weekdaysMin : 'ஞா_தி_செ_பு_வி_வெ_ச'.split('_'),
  30372. longDateFormat : {
  30373. LT : 'HH:mm',
  30374. LTS : 'HH:mm:ss',
  30375. L : 'DD/MM/YYYY',
  30376. LL : 'D MMMM YYYY',
  30377. LLL : 'D MMMM YYYY, HH:mm',
  30378. LLLL : 'dddd, D MMMM YYYY, HH:mm'
  30379. },
  30380. calendar : {
  30381. sameDay : '[இன்று] LT',
  30382. nextDay : '[நாளை] LT',
  30383. nextWeek : 'dddd, LT',
  30384. lastDay : '[நேற்று] LT',
  30385. lastWeek : '[கடந்த வாரம்] dddd, LT',
  30386. sameElse : 'L'
  30387. },
  30388. relativeTime : {
  30389. future : '%s இல்',
  30390. past : '%s முன்',
  30391. s : 'ஒரு சில விநாடிகள்',
  30392. m : 'ஒரு நிமிடம்',
  30393. mm : '%d நிமிடங்கள்',
  30394. h : 'ஒரு மணி நேரம்',
  30395. hh : '%d மணி நேரம்',
  30396. d : 'ஒரு நாள்',
  30397. dd : '%d நாட்கள்',
  30398. M : 'ஒரு மாதம்',
  30399. MM : '%d மாதங்கள்',
  30400. y : 'ஒரு வருடம்',
  30401. yy : '%d ஆண்டுகள்'
  30402. },
  30403. dayOfMonthOrdinalParse: /\d{1,2}வது/,
  30404. ordinal : function (number) {
  30405. return number + 'வது';
  30406. },
  30407. preparse: function (string) {
  30408. return string.replace(/[௧௨௩௪௫௬௭௮௯௦]/g, function (match) {
  30409. return numberMap$12[match];
  30410. });
  30411. },
  30412. postformat: function (string) {
  30413. return string.replace(/\d/g, function (match) {
  30414. return symbolMap$13[match];
  30415. });
  30416. },
  30417. // refer http://ta.wikipedia.org/s/1er1
  30418. meridiemParse: /யாமம்|வைகறை|காலை|நண்பகல்|எற்பாடு|மாலை/,
  30419. meridiem : function (hour, minute, isLower) {
  30420. if (hour < 2) {
  30421. return ' யாமம்';
  30422. } else if (hour < 6) {
  30423. return ' வைகறை'; // வைகறை
  30424. } else if (hour < 10) {
  30425. return ' காலை'; // காலை
  30426. } else if (hour < 14) {
  30427. return ' நண்பகல்'; // நண்பகல்
  30428. } else if (hour < 18) {
  30429. return ' எற்பாடு'; // எற்பாடு
  30430. } else if (hour < 22) {
  30431. return ' மாலை'; // மாலை
  30432. } else {
  30433. return ' யாமம்';
  30434. }
  30435. },
  30436. meridiemHour : function (hour, meridiem) {
  30437. if (hour === 12) {
  30438. hour = 0;
  30439. }
  30440. if (meridiem === 'யாமம்') {
  30441. return hour < 2 ? hour : hour + 12;
  30442. } else if (meridiem === 'வைகறை' || meridiem === 'காலை') {
  30443. return hour;
  30444. } else if (meridiem === 'நண்பகல்') {
  30445. return hour >= 10 ? hour : hour + 12;
  30446. } else {
  30447. return hour + 12;
  30448. }
  30449. },
  30450. week : {
  30451. dow : 0, // Sunday is the first day of the week.
  30452. doy : 6 // The week that contains Jan 1st is the first week of the year.
  30453. }
  30454. });
  30455. //! moment.js locale configuration
  30456. //! locale : Telugu [te]
  30457. //! author : Krishna Chaitanya Thota : https://github.com/kcthota
  30458. hooks.defineLocale('te', {
  30459. months : 'జనవరి_ఫిబ్రవరి_మార్చి_ఏప్రిల్_మే_జూన్_జూలై_ఆగస్టు_సెప్టెంబర్_అక్టోబర్_నవంబర్_డిసెంబర్'.split('_'),
  30460. monthsShort : 'జన._ఫిబ్ర._మార్చి_ఏప్రి._మే_జూన్_జూలై_ఆగ._సెప్._అక్టో._నవ._డిసె.'.split('_'),
  30461. monthsParseExact : true,
  30462. weekdays : 'ఆదివారం_సోమవారం_మంగళవారం_బుధవారం_గురువారం_శుక్రవారం_శనివారం'.split('_'),
  30463. weekdaysShort : 'ఆది_సోమ_మంగళ_బుధ_గురు_శుక్ర_శని'.split('_'),
  30464. weekdaysMin : 'ఆ_సో_మం_బు_గు_శు_శ'.split('_'),
  30465. longDateFormat : {
  30466. LT : 'A h:mm',
  30467. LTS : 'A h:mm:ss',
  30468. L : 'DD/MM/YYYY',
  30469. LL : 'D MMMM YYYY',
  30470. LLL : 'D MMMM YYYY, A h:mm',
  30471. LLLL : 'dddd, D MMMM YYYY, A h:mm'
  30472. },
  30473. calendar : {
  30474. sameDay : '[నేడు] LT',
  30475. nextDay : '[రేపు] LT',
  30476. nextWeek : 'dddd, LT',
  30477. lastDay : '[నిన్న] LT',
  30478. lastWeek : '[గత] dddd, LT',
  30479. sameElse : 'L'
  30480. },
  30481. relativeTime : {
  30482. future : '%s లో',
  30483. past : '%s క్రితం',
  30484. s : 'కొన్ని క్షణాలు',
  30485. m : 'ఒక నిమిషం',
  30486. mm : '%d నిమిషాలు',
  30487. h : 'ఒక గంట',
  30488. hh : '%d గంటలు',
  30489. d : 'ఒక రోజు',
  30490. dd : '%d రోజులు',
  30491. M : 'ఒక నెల',
  30492. MM : '%d నెలలు',
  30493. y : 'ఒక సంవత్సరం',
  30494. yy : '%d సంవత్సరాలు'
  30495. },
  30496. dayOfMonthOrdinalParse : /\d{1,2}వ/,
  30497. ordinal : '%dవ',
  30498. meridiemParse: /రాత్రి|ఉదయం|మధ్యాహ్నం|సాయంత్రం/,
  30499. meridiemHour : function (hour, meridiem) {
  30500. if (hour === 12) {
  30501. hour = 0;
  30502. }
  30503. if (meridiem === 'రాత్రి') {
  30504. return hour < 4 ? hour : hour + 12;
  30505. } else if (meridiem === 'ఉదయం') {
  30506. return hour;
  30507. } else if (meridiem === 'మధ్యాహ్నం') {
  30508. return hour >= 10 ? hour : hour + 12;
  30509. } else if (meridiem === 'సాయంత్రం') {
  30510. return hour + 12;
  30511. }
  30512. },
  30513. meridiem : function (hour, minute, isLower) {
  30514. if (hour < 4) {
  30515. return 'రాత్రి';
  30516. } else if (hour < 10) {
  30517. return 'ఉదయం';
  30518. } else if (hour < 17) {
  30519. return 'మధ్యాహ్నం';
  30520. } else if (hour < 20) {
  30521. return 'సాయంత్రం';
  30522. } else {
  30523. return 'రాత్రి';
  30524. }
  30525. },
  30526. week : {
  30527. dow : 0, // Sunday is the first day of the week.
  30528. doy : 6 // The week that contains Jan 1st is the first week of the year.
  30529. }
  30530. });
  30531. //! moment.js locale configuration
  30532. //! locale : Tetun Dili (East Timor) [tet]
  30533. //! author : Joshua Brooks : https://github.com/joshbrooks
  30534. //! author : Onorio De J. Afonso : https://github.com/marobo
  30535. hooks.defineLocale('tet', {
  30536. months : 'Janeiru_Fevereiru_Marsu_Abril_Maiu_Juniu_Juliu_Augustu_Setembru_Outubru_Novembru_Dezembru'.split('_'),
  30537. monthsShort : 'Jan_Fev_Mar_Abr_Mai_Jun_Jul_Aug_Set_Out_Nov_Dez'.split('_'),
  30538. weekdays : 'Domingu_Segunda_Tersa_Kuarta_Kinta_Sexta_Sabadu'.split('_'),
  30539. weekdaysShort : 'Dom_Seg_Ters_Kua_Kint_Sext_Sab'.split('_'),
  30540. weekdaysMin : 'Do_Seg_Te_Ku_Ki_Sex_Sa'.split('_'),
  30541. longDateFormat : {
  30542. LT : 'HH:mm',
  30543. LTS : 'HH:mm:ss',
  30544. L : 'DD/MM/YYYY',
  30545. LL : 'D MMMM YYYY',
  30546. LLL : 'D MMMM YYYY HH:mm',
  30547. LLLL : 'dddd, D MMMM YYYY HH:mm'
  30548. },
  30549. calendar : {
  30550. sameDay: '[Ohin iha] LT',
  30551. nextDay: '[Aban iha] LT',
  30552. nextWeek: 'dddd [iha] LT',
  30553. lastDay: '[Horiseik iha] LT',
  30554. lastWeek: 'dddd [semana kotuk] [iha] LT',
  30555. sameElse: 'L'
  30556. },
  30557. relativeTime : {
  30558. future : 'iha %s',
  30559. past : '%s liuba',
  30560. s : 'minutu balun',
  30561. m : 'minutu ida',
  30562. mm : 'minutus %d',
  30563. h : 'horas ida',
  30564. hh : 'horas %d',
  30565. d : 'loron ida',
  30566. dd : 'loron %d',
  30567. M : 'fulan ida',
  30568. MM : 'fulan %d',
  30569. y : 'tinan ida',
  30570. yy : 'tinan %d'
  30571. },
  30572. dayOfMonthOrdinalParse: /\d{1,2}(st|nd|rd|th)/,
  30573. ordinal : function (number) {
  30574. var b = number % 10,
  30575. output = (~~(number % 100 / 10) === 1) ? 'th' :
  30576. (b === 1) ? 'st' :
  30577. (b === 2) ? 'nd' :
  30578. (b === 3) ? 'rd' : 'th';
  30579. return number + output;
  30580. },
  30581. week : {
  30582. dow : 1, // Monday is the first day of the week.
  30583. doy : 4 // The week that contains Jan 4th is the first week of the year.
  30584. }
  30585. });
  30586. //! moment.js locale configuration
  30587. //! locale : Thai [th]
  30588. //! author : Kridsada Thanabulpong : https://github.com/sirn
  30589. hooks.defineLocale('th', {
  30590. months : 'มกราคม_กุมภาพันธ์_มีนาคม_เมษายน_พฤษภาคม_มิถุนายน_กรกฎาคม_สิงหาคม_กันยายน_ตุลาคม_พฤศจิกายน_ธันวาคม'.split('_'),
  30591. monthsShort : 'ม.ค._ก.พ._มี.ค._เม.ย._พ.ค._มิ.ย._ก.ค._ส.ค._ก.ย._ต.ค._พ.ย._ธ.ค.'.split('_'),
  30592. monthsParseExact: true,
  30593. weekdays : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัสบดี_ศุกร์_เสาร์'.split('_'),
  30594. weekdaysShort : 'อาทิตย์_จันทร์_อังคาร_พุธ_พฤหัส_ศุกร์_เสาร์'.split('_'), // yes, three characters difference
  30595. weekdaysMin : 'อา._จ._อ._พ._พฤ._ศ._ส.'.split('_'),
  30596. weekdaysParseExact : true,
  30597. longDateFormat : {
  30598. LT : 'H:mm',
  30599. LTS : 'H:mm:ss',
  30600. L : 'DD/MM/YYYY',
  30601. LL : 'D MMMM YYYY',
  30602. LLL : 'D MMMM YYYY เวลา H:mm',
  30603. LLLL : 'วันddddที่ D MMMM YYYY เวลา H:mm'
  30604. },
  30605. meridiemParse: /ก่อนเที่ยง|หลังเที่ยง/,
  30606. isPM: function (input) {
  30607. return input === 'หลังเที่ยง';
  30608. },
  30609. meridiem : function (hour, minute, isLower) {
  30610. if (hour < 12) {
  30611. return 'ก่อนเที่ยง';
  30612. } else {
  30613. return 'หลังเที่ยง';
  30614. }
  30615. },
  30616. calendar : {
  30617. sameDay : '[วันนี้ เวลา] LT',
  30618. nextDay : '[พรุ่งนี้ เวลา] LT',
  30619. nextWeek : 'dddd[หน้า เวลา] LT',
  30620. lastDay : '[เมื่อวานนี้ เวลา] LT',
  30621. lastWeek : '[วัน]dddd[ที่แล้ว เวลา] LT',
  30622. sameElse : 'L'
  30623. },
  30624. relativeTime : {
  30625. future : 'อีก %s',
  30626. past : '%sที่แล้ว',
  30627. s : 'ไม่กี่วินาที',
  30628. m : '1 นาที',
  30629. mm : '%d นาที',
  30630. h : '1 ชั่วโมง',
  30631. hh : '%d ชั่วโมง',
  30632. d : '1 วัน',
  30633. dd : '%d วัน',
  30634. M : '1 เดือน',
  30635. MM : '%d เดือน',
  30636. y : '1 ปี',
  30637. yy : '%d ปี'
  30638. }
  30639. });
  30640. //! moment.js locale configuration
  30641. //! locale : Tagalog (Philippines) [tl-ph]
  30642. //! author : Dan Hagman : https://github.com/hagmandan
  30643. hooks.defineLocale('tl-ph', {
  30644. months : 'Enero_Pebrero_Marso_Abril_Mayo_Hunyo_Hulyo_Agosto_Setyembre_Oktubre_Nobyembre_Disyembre'.split('_'),
  30645. monthsShort : 'Ene_Peb_Mar_Abr_May_Hun_Hul_Ago_Set_Okt_Nob_Dis'.split('_'),
  30646. weekdays : 'Linggo_Lunes_Martes_Miyerkules_Huwebes_Biyernes_Sabado'.split('_'),
  30647. weekdaysShort : 'Lin_Lun_Mar_Miy_Huw_Biy_Sab'.split('_'),
  30648. weekdaysMin : 'Li_Lu_Ma_Mi_Hu_Bi_Sab'.split('_'),
  30649. longDateFormat : {
  30650. LT : 'HH:mm',
  30651. LTS : 'HH:mm:ss',
  30652. L : 'MM/D/YYYY',
  30653. LL : 'MMMM D, YYYY',
  30654. LLL : 'MMMM D, YYYY HH:mm',
  30655. LLLL : 'dddd, MMMM DD, YYYY HH:mm'
  30656. },
  30657. calendar : {
  30658. sameDay: 'LT [ngayong araw]',
  30659. nextDay: '[Bukas ng] LT',
  30660. nextWeek: 'LT [sa susunod na] dddd',
  30661. lastDay: 'LT [kahapon]',
  30662. lastWeek: 'LT [noong nakaraang] dddd',
  30663. sameElse: 'L'
  30664. },
  30665. relativeTime : {
  30666. future : 'sa loob ng %s',
  30667. past : '%s ang nakalipas',
  30668. s : 'ilang segundo',
  30669. m : 'isang minuto',
  30670. mm : '%d minuto',
  30671. h : 'isang oras',
  30672. hh : '%d oras',
  30673. d : 'isang araw',
  30674. dd : '%d araw',
  30675. M : 'isang buwan',
  30676. MM : '%d buwan',
  30677. y : 'isang taon',
  30678. yy : '%d taon'
  30679. },
  30680. dayOfMonthOrdinalParse: /\d{1,2}/,
  30681. ordinal : function (number) {
  30682. return number;
  30683. },
  30684. week : {
  30685. dow : 1, // Monday is the first day of the week.
  30686. doy : 4 // The week that contains Jan 4th is the first week of the year.
  30687. }
  30688. });
  30689. //! moment.js locale configuration
  30690. //! locale : Klingon [tlh]
  30691. //! author : Dominika Kruk : https://github.com/amaranthrose
  30692. var numbersNouns = 'pagh_wa’_cha’_wej_loS_vagh_jav_Soch_chorgh_Hut'.split('_');
  30693. function translateFuture(output) {
  30694. var time = output;
  30695. time = (output.indexOf('jaj') !== -1) ?
  30696. time.slice(0, -3) + 'leS' :
  30697. (output.indexOf('jar') !== -1) ?
  30698. time.slice(0, -3) + 'waQ' :
  30699. (output.indexOf('DIS') !== -1) ?
  30700. time.slice(0, -3) + 'nem' :
  30701. time + ' pIq';
  30702. return time;
  30703. }
  30704. function translatePast(output) {
  30705. var time = output;
  30706. time = (output.indexOf('jaj') !== -1) ?
  30707. time.slice(0, -3) + 'Hu’' :
  30708. (output.indexOf('jar') !== -1) ?
  30709. time.slice(0, -3) + 'wen' :
  30710. (output.indexOf('DIS') !== -1) ?
  30711. time.slice(0, -3) + 'ben' :
  30712. time + ' ret';
  30713. return time;
  30714. }
  30715. function translate$9(number, withoutSuffix, string, isFuture) {
  30716. var numberNoun = numberAsNoun(number);
  30717. switch (string) {
  30718. case 'mm':
  30719. return numberNoun + ' tup';
  30720. case 'hh':
  30721. return numberNoun + ' rep';
  30722. case 'dd':
  30723. return numberNoun + ' jaj';
  30724. case 'MM':
  30725. return numberNoun + ' jar';
  30726. case 'yy':
  30727. return numberNoun + ' DIS';
  30728. }
  30729. }
  30730. function numberAsNoun(number) {
  30731. var hundred = Math.floor((number % 1000) / 100),
  30732. ten = Math.floor((number % 100) / 10),
  30733. one = number % 10,
  30734. word = '';
  30735. if (hundred > 0) {
  30736. word += numbersNouns[hundred] + 'vatlh';
  30737. }
  30738. if (ten > 0) {
  30739. word += ((word !== '') ? ' ' : '') + numbersNouns[ten] + 'maH';
  30740. }
  30741. if (one > 0) {
  30742. word += ((word !== '') ? ' ' : '') + numbersNouns[one];
  30743. }
  30744. return (word === '') ? 'pagh' : word;
  30745. }
  30746. hooks.defineLocale('tlh', {
  30747. months : 'tera’ jar wa’_tera’ jar cha’_tera’ jar wej_tera’ jar loS_tera’ jar vagh_tera’ jar jav_tera’ jar Soch_tera’ jar chorgh_tera’ jar Hut_tera’ jar wa’maH_tera’ jar wa’maH wa’_tera’ jar wa’maH cha’'.split('_'),
  30748. monthsShort : 'jar wa’_jar cha’_jar wej_jar loS_jar vagh_jar jav_jar Soch_jar chorgh_jar Hut_jar wa’maH_jar wa’maH wa’_jar wa’maH cha’'.split('_'),
  30749. monthsParseExact : true,
  30750. weekdays : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  30751. weekdaysShort : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  30752. weekdaysMin : 'lojmItjaj_DaSjaj_povjaj_ghItlhjaj_loghjaj_buqjaj_ghInjaj'.split('_'),
  30753. longDateFormat : {
  30754. LT : 'HH:mm',
  30755. LTS : 'HH:mm:ss',
  30756. L : 'DD.MM.YYYY',
  30757. LL : 'D MMMM YYYY',
  30758. LLL : 'D MMMM YYYY HH:mm',
  30759. LLLL : 'dddd, D MMMM YYYY HH:mm'
  30760. },
  30761. calendar : {
  30762. sameDay: '[DaHjaj] LT',
  30763. nextDay: '[wa’leS] LT',
  30764. nextWeek: 'LLL',
  30765. lastDay: '[wa’Hu’] LT',
  30766. lastWeek: 'LLL',
  30767. sameElse: 'L'
  30768. },
  30769. relativeTime : {
  30770. future : translateFuture,
  30771. past : translatePast,
  30772. s : 'puS lup',
  30773. m : 'wa’ tup',
  30774. mm : translate$9,
  30775. h : 'wa’ rep',
  30776. hh : translate$9,
  30777. d : 'wa’ jaj',
  30778. dd : translate$9,
  30779. M : 'wa’ jar',
  30780. MM : translate$9,
  30781. y : 'wa’ DIS',
  30782. yy : translate$9
  30783. },
  30784. dayOfMonthOrdinalParse: /\d{1,2}\./,
  30785. ordinal : '%d.',
  30786. week : {
  30787. dow : 1, // Monday is the first day of the week.
  30788. doy : 4 // The week that contains Jan 4th is the first week of the year.
  30789. }
  30790. });
  30791. //! moment.js locale configuration
  30792. //! locale : Turkish [tr]
  30793. //! authors : Erhan Gundogan : https://github.com/erhangundogan,
  30794. //! Burak Yiğit Kaya: https://github.com/BYK
  30795. var suffixes$3 = {
  30796. 1: '\'inci',
  30797. 5: '\'inci',
  30798. 8: '\'inci',
  30799. 70: '\'inci',
  30800. 80: '\'inci',
  30801. 2: '\'nci',
  30802. 7: '\'nci',
  30803. 20: '\'nci',
  30804. 50: '\'nci',
  30805. 3: '\'üncü',
  30806. 4: '\'üncü',
  30807. 100: '\'üncü',
  30808. 6: '\'ncı',
  30809. 9: '\'uncu',
  30810. 10: '\'uncu',
  30811. 30: '\'uncu',
  30812. 60: '\'ıncı',
  30813. 90: '\'ıncı'
  30814. };
  30815. hooks.defineLocale('tr', {
  30816. months : 'Ocak_Şubat_Mart_Nisan_Mayıs_Haziran_Temmuz_Ağustos_Eylül_Ekim_Kasım_Aralık'.split('_'),
  30817. monthsShort : 'Oca_Şub_Mar_Nis_May_Haz_Tem_Ağu_Eyl_Eki_Kas_Ara'.split('_'),
  30818. weekdays : 'Pazar_Pazartesi_Salı_Çarşamba_Perşembe_Cuma_Cumartesi'.split('_'),
  30819. weekdaysShort : 'Paz_Pts_Sal_Çar_Per_Cum_Cts'.split('_'),
  30820. weekdaysMin : 'Pz_Pt_Sa_Ça_Pe_Cu_Ct'.split('_'),
  30821. longDateFormat : {
  30822. LT : 'HH:mm',
  30823. LTS : 'HH:mm:ss',
  30824. L : 'DD.MM.YYYY',
  30825. LL : 'D MMMM YYYY',
  30826. LLL : 'D MMMM YYYY HH:mm',
  30827. LLLL : 'dddd, D MMMM YYYY HH:mm'
  30828. },
  30829. calendar : {
  30830. sameDay : '[bugün saat] LT',
  30831. nextDay : '[yarın saat] LT',
  30832. nextWeek : '[gelecek] dddd [saat] LT',
  30833. lastDay : '[dün] LT',
  30834. lastWeek : '[geçen] dddd [saat] LT',
  30835. sameElse : 'L'
  30836. },
  30837. relativeTime : {
  30838. future : '%s sonra',
  30839. past : '%s önce',
  30840. s : 'birkaç saniye',
  30841. m : 'bir dakika',
  30842. mm : '%d dakika',
  30843. h : 'bir saat',
  30844. hh : '%d saat',
  30845. d : 'bir gün',
  30846. dd : '%d gün',
  30847. M : 'bir ay',
  30848. MM : '%d ay',
  30849. y : 'bir yıl',
  30850. yy : '%d yıl'
  30851. },
  30852. dayOfMonthOrdinalParse: /\d{1,2}'(inci|nci|üncü|ncı|uncu|ıncı)/,
  30853. ordinal : function (number) {
  30854. if (number === 0) { // special case for zero
  30855. return number + '\'ıncı';
  30856. }
  30857. var a = number % 10,
  30858. b = number % 100 - a,
  30859. c = number >= 100 ? 100 : null;
  30860. return number + (suffixes$3[a] || suffixes$3[b] || suffixes$3[c]);
  30861. },
  30862. week : {
  30863. dow : 1, // Monday is the first day of the week.
  30864. doy : 7 // The week that contains Jan 1st is the first week of the year.
  30865. }
  30866. });
  30867. //! moment.js locale configuration
  30868. //! locale : Talossan [tzl]
  30869. //! author : Robin van der Vliet : https://github.com/robin0van0der0v
  30870. //! author : Iustì Canun
  30871. // After the year there should be a slash and the amount of years since December 26, 1979 in Roman numerals.
  30872. // This is currently too difficult (maybe even impossible) to add.
  30873. hooks.defineLocale('tzl', {
  30874. months : 'Januar_Fevraglh_Març_Avrïu_Mai_Gün_Julia_Guscht_Setemvar_Listopäts_Noemvar_Zecemvar'.split('_'),
  30875. monthsShort : 'Jan_Fev_Mar_Avr_Mai_Gün_Jul_Gus_Set_Lis_Noe_Zec'.split('_'),
  30876. weekdays : 'Súladi_Lúneçi_Maitzi_Márcuri_Xhúadi_Viénerçi_Sáturi'.split('_'),
  30877. weekdaysShort : 'Súl_Lún_Mai_Már_Xhú_Vié_Sát'.split('_'),
  30878. weekdaysMin : 'Sú_Lú_Ma_Má_Xh_Vi_Sá'.split('_'),
  30879. longDateFormat : {
  30880. LT : 'HH.mm',
  30881. LTS : 'HH.mm.ss',
  30882. L : 'DD.MM.YYYY',
  30883. LL : 'D. MMMM [dallas] YYYY',
  30884. LLL : 'D. MMMM [dallas] YYYY HH.mm',
  30885. LLLL : 'dddd, [li] D. MMMM [dallas] YYYY HH.mm'
  30886. },
  30887. meridiemParse: /d\'o|d\'a/i,
  30888. isPM : function (input) {
  30889. return 'd\'o' === input.toLowerCase();
  30890. },
  30891. meridiem : function (hours, minutes, isLower) {
  30892. if (hours > 11) {
  30893. return isLower ? 'd\'o' : 'D\'O';
  30894. } else {
  30895. return isLower ? 'd\'a' : 'D\'A';
  30896. }
  30897. },
  30898. calendar : {
  30899. sameDay : '[oxhi à] LT',
  30900. nextDay : '[demà à] LT',
  30901. nextWeek : 'dddd [à] LT',
  30902. lastDay : '[ieiri à] LT',
  30903. lastWeek : '[sür el] dddd [lasteu à] LT',
  30904. sameElse : 'L'
  30905. },
  30906. relativeTime : {
  30907. future : 'osprei %s',
  30908. past : 'ja%s',
  30909. s : processRelativeTime$7,
  30910. m : processRelativeTime$7,
  30911. mm : processRelativeTime$7,
  30912. h : processRelativeTime$7,
  30913. hh : processRelativeTime$7,
  30914. d : processRelativeTime$7,
  30915. dd : processRelativeTime$7,
  30916. M : processRelativeTime$7,
  30917. MM : processRelativeTime$7,
  30918. y : processRelativeTime$7,
  30919. yy : processRelativeTime$7
  30920. },
  30921. dayOfMonthOrdinalParse: /\d{1,2}\./,
  30922. ordinal : '%d.',
  30923. week : {
  30924. dow : 1, // Monday is the first day of the week.
  30925. doy : 4 // The week that contains Jan 4th is the first week of the year.
  30926. }
  30927. });
  30928. function processRelativeTime$7(number, withoutSuffix, key, isFuture) {
  30929. var format = {
  30930. 's': ['viensas secunds', '\'iensas secunds'],
  30931. 'm': ['\'n míut', '\'iens míut'],
  30932. 'mm': [number + ' míuts', '' + number + ' míuts'],
  30933. 'h': ['\'n þora', '\'iensa þora'],
  30934. 'hh': [number + ' þoras', '' + number + ' þoras'],
  30935. 'd': ['\'n ziua', '\'iensa ziua'],
  30936. 'dd': [number + ' ziuas', '' + number + ' ziuas'],
  30937. 'M': ['\'n mes', '\'iens mes'],
  30938. 'MM': [number + ' mesen', '' + number + ' mesen'],
  30939. 'y': ['\'n ar', '\'iens ar'],
  30940. 'yy': [number + ' ars', '' + number + ' ars']
  30941. };
  30942. return isFuture ? format[key][0] : (withoutSuffix ? format[key][0] : format[key][1]);
  30943. }
  30944. //! moment.js locale configuration
  30945. //! locale : Central Atlas Tamazight Latin [tzm-latn]
  30946. //! author : Abdel Said : https://github.com/abdelsaid
  30947. hooks.defineLocale('tzm-latn', {
  30948. months : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
  30949. monthsShort : 'innayr_brˤayrˤ_marˤsˤ_ibrir_mayyw_ywnyw_ywlywz_ɣwšt_šwtanbir_ktˤwbrˤ_nwwanbir_dwjnbir'.split('_'),
  30950. weekdays : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
  30951. weekdaysShort : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
  30952. weekdaysMin : 'asamas_aynas_asinas_akras_akwas_asimwas_asiḍyas'.split('_'),
  30953. longDateFormat : {
  30954. LT : 'HH:mm',
  30955. LTS : 'HH:mm:ss',
  30956. L : 'DD/MM/YYYY',
  30957. LL : 'D MMMM YYYY',
  30958. LLL : 'D MMMM YYYY HH:mm',
  30959. LLLL : 'dddd D MMMM YYYY HH:mm'
  30960. },
  30961. calendar : {
  30962. sameDay: '[asdkh g] LT',
  30963. nextDay: '[aska g] LT',
  30964. nextWeek: 'dddd [g] LT',
  30965. lastDay: '[assant g] LT',
  30966. lastWeek: 'dddd [g] LT',
  30967. sameElse: 'L'
  30968. },
  30969. relativeTime : {
  30970. future : 'dadkh s yan %s',
  30971. past : 'yan %s',
  30972. s : 'imik',
  30973. m : 'minuḍ',
  30974. mm : '%d minuḍ',
  30975. h : 'saɛa',
  30976. hh : '%d tassaɛin',
  30977. d : 'ass',
  30978. dd : '%d ossan',
  30979. M : 'ayowr',
  30980. MM : '%d iyyirn',
  30981. y : 'asgas',
  30982. yy : '%d isgasn'
  30983. },
  30984. week : {
  30985. dow : 6, // Saturday is the first day of the week.
  30986. doy : 12 // The week that contains Jan 1st is the first week of the year.
  30987. }
  30988. });
  30989. //! moment.js locale configuration
  30990. //! locale : Central Atlas Tamazight [tzm]
  30991. //! author : Abdel Said : https://github.com/abdelsaid
  30992. hooks.defineLocale('tzm', {
  30993. months : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
  30994. monthsShort : 'ⵉⵏⵏⴰⵢⵔ_ⴱⵕⴰⵢⵕ_ⵎⴰⵕⵚ_ⵉⴱⵔⵉⵔ_ⵎⴰⵢⵢⵓ_ⵢⵓⵏⵢⵓ_ⵢⵓⵍⵢⵓⵣ_ⵖⵓⵛⵜ_ⵛⵓⵜⴰⵏⴱⵉⵔ_ⴽⵟⵓⴱⵕ_ⵏⵓⵡⴰⵏⴱⵉⵔ_ⴷⵓⵊⵏⴱⵉⵔ'.split('_'),
  30995. weekdays : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
  30996. weekdaysShort : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
  30997. weekdaysMin : 'ⴰⵙⴰⵎⴰⵙ_ⴰⵢⵏⴰⵙ_ⴰⵙⵉⵏⴰⵙ_ⴰⴽⵔⴰⵙ_ⴰⴽⵡⴰⵙ_ⴰⵙⵉⵎⵡⴰⵙ_ⴰⵙⵉⴹⵢⴰⵙ'.split('_'),
  30998. longDateFormat : {
  30999. LT : 'HH:mm',
  31000. LTS: 'HH:mm:ss',
  31001. L : 'DD/MM/YYYY',
  31002. LL : 'D MMMM YYYY',
  31003. LLL : 'D MMMM YYYY HH:mm',
  31004. LLLL : 'dddd D MMMM YYYY HH:mm'
  31005. },
  31006. calendar : {
  31007. sameDay: '[ⴰⵙⴷⵅ ⴴ] LT',
  31008. nextDay: '[ⴰⵙⴽⴰ ⴴ] LT',
  31009. nextWeek: 'dddd [ⴴ] LT',
  31010. lastDay: '[ⴰⵚⴰⵏⵜ ⴴ] LT',
  31011. lastWeek: 'dddd [ⴴ] LT',
  31012. sameElse: 'L'
  31013. },
  31014. relativeTime : {
  31015. future : 'ⴷⴰⴷⵅ ⵙ ⵢⴰⵏ %s',
  31016. past : 'ⵢⴰⵏ %s',
  31017. s : 'ⵉⵎⵉⴽ',
  31018. m : 'ⵎⵉⵏⵓⴺ',
  31019. mm : '%d ⵎⵉⵏⵓⴺ',
  31020. h : 'ⵙⴰⵄⴰ',
  31021. hh : '%d ⵜⴰⵙⵙⴰⵄⵉⵏ',
  31022. d : 'ⴰⵙⵙ',
  31023. dd : '%d oⵙⵙⴰⵏ',
  31024. M : 'ⴰⵢoⵓⵔ',
  31025. MM : '%d ⵉⵢⵢⵉⵔⵏ',
  31026. y : 'ⴰⵙⴳⴰⵙ',
  31027. yy : '%d ⵉⵙⴳⴰⵙⵏ'
  31028. },
  31029. week : {
  31030. dow : 6, // Saturday is the first day of the week.
  31031. doy : 12 // The week that contains Jan 1st is the first week of the year.
  31032. }
  31033. });
  31034. //! moment.js locale configuration
  31035. //! locale : Ukrainian [uk]
  31036. //! author : zemlanin : https://github.com/zemlanin
  31037. //! Author : Menelion Elensúle : https://github.com/Oire
  31038. function plural$6(word, num) {
  31039. var forms = word.split('_');
  31040. return num % 10 === 1 && num % 100 !== 11 ? forms[0] : (num % 10 >= 2 && num % 10 <= 4 && (num % 100 < 10 || num % 100 >= 20) ? forms[1] : forms[2]);
  31041. }
  31042. function relativeTimeWithPlural$4(number, withoutSuffix, key) {
  31043. var format = {
  31044. 'mm': withoutSuffix ? 'хвилина_хвилини_хвилин' : 'хвилину_хвилини_хвилин',
  31045. 'hh': withoutSuffix ? 'година_години_годин' : 'годину_години_годин',
  31046. 'dd': 'день_дні_днів',
  31047. 'MM': 'місяць_місяці_місяців',
  31048. 'yy': 'рік_роки_років'
  31049. };
  31050. if (key === 'm') {
  31051. return withoutSuffix ? 'хвилина' : 'хвилину';
  31052. }
  31053. else if (key === 'h') {
  31054. return withoutSuffix ? 'година' : 'годину';
  31055. }
  31056. else {
  31057. return number + ' ' + plural$6(format[key], +number);
  31058. }
  31059. }
  31060. function weekdaysCaseReplace(m, format) {
  31061. var weekdays = {
  31062. 'nominative': 'неділя_понеділок_вівторок_середа_четвер_п’ятниця_субота'.split('_'),
  31063. 'accusative': 'неділю_понеділок_вівторок_середу_четвер_п’ятницю_суботу'.split('_'),
  31064. 'genitive': 'неділі_понеділка_вівторка_середи_четверга_п’ятниці_суботи'.split('_')
  31065. };
  31066. if (!m) {
  31067. return weekdays['nominative'];
  31068. }
  31069. var nounCase = (/(\[[ВвУу]\]) ?dddd/).test(format) ?
  31070. 'accusative' :
  31071. ((/\[?(?:минулої|наступної)? ?\] ?dddd/).test(format) ?
  31072. 'genitive' :
  31073. 'nominative');
  31074. return weekdays[nounCase][m.day()];
  31075. }
  31076. function processHoursFunction(str) {
  31077. return function () {
  31078. return str + 'о' + (this.hours() === 11 ? 'б' : '') + '] LT';
  31079. };
  31080. }
  31081. hooks.defineLocale('uk', {
  31082. months : {
  31083. 'format': 'січня_лютого_березня_квітня_травня_червня_липня_серпня_вересня_жовтня_листопада_грудня'.split('_'),
  31084. 'standalone': 'січень_лютий_березень_квітень_травень_червень_липень_серпень_вересень_жовтень_листопад_грудень'.split('_')
  31085. },
  31086. monthsShort : 'січ_лют_бер_квіт_трав_черв_лип_серп_вер_жовт_лист_груд'.split('_'),
  31087. weekdays : weekdaysCaseReplace,
  31088. weekdaysShort : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
  31089. weekdaysMin : 'нд_пн_вт_ср_чт_пт_сб'.split('_'),
  31090. longDateFormat : {
  31091. LT : 'HH:mm',
  31092. LTS : 'HH:mm:ss',
  31093. L : 'DD.MM.YYYY',
  31094. LL : 'D MMMM YYYY р.',
  31095. LLL : 'D MMMM YYYY р., HH:mm',
  31096. LLLL : 'dddd, D MMMM YYYY р., HH:mm'
  31097. },
  31098. calendar : {
  31099. sameDay: processHoursFunction('[Сьогодні '),
  31100. nextDay: processHoursFunction('[Завтра '),
  31101. lastDay: processHoursFunction('[Вчора '),
  31102. nextWeek: processHoursFunction('[У] dddd ['),
  31103. lastWeek: function () {
  31104. switch (this.day()) {
  31105. case 0:
  31106. case 3:
  31107. case 5:
  31108. case 6:
  31109. return processHoursFunction('[Минулої] dddd [').call(this);
  31110. case 1:
  31111. case 2:
  31112. case 4:
  31113. return processHoursFunction('[Минулого] dddd [').call(this);
  31114. }
  31115. },
  31116. sameElse: 'L'
  31117. },
  31118. relativeTime : {
  31119. future : 'за %s',
  31120. past : '%s тому',
  31121. s : 'декілька секунд',
  31122. m : relativeTimeWithPlural$4,
  31123. mm : relativeTimeWithPlural$4,
  31124. h : 'годину',
  31125. hh : relativeTimeWithPlural$4,
  31126. d : 'день',
  31127. dd : relativeTimeWithPlural$4,
  31128. M : 'місяць',
  31129. MM : relativeTimeWithPlural$4,
  31130. y : 'рік',
  31131. yy : relativeTimeWithPlural$4
  31132. },
  31133. // M. E.: those two are virtually unused but a user might want to implement them for his/her website for some reason
  31134. meridiemParse: /ночі|ранку|дня|вечора/,
  31135. isPM: function (input) {
  31136. return /^(дня|вечора)$/.test(input);
  31137. },
  31138. meridiem : function (hour, minute, isLower) {
  31139. if (hour < 4) {
  31140. return 'ночі';
  31141. } else if (hour < 12) {
  31142. return 'ранку';
  31143. } else if (hour < 17) {
  31144. return 'дня';
  31145. } else {
  31146. return 'вечора';
  31147. }
  31148. },
  31149. dayOfMonthOrdinalParse: /\d{1,2}-(й|го)/,
  31150. ordinal: function (number, period) {
  31151. switch (period) {
  31152. case 'M':
  31153. case 'd':
  31154. case 'DDD':
  31155. case 'w':
  31156. case 'W':
  31157. return number + '-й';
  31158. case 'D':
  31159. return number + '-го';
  31160. default:
  31161. return number;
  31162. }
  31163. },
  31164. week : {
  31165. dow : 1, // Monday is the first day of the week.
  31166. doy : 7 // The week that contains Jan 1st is the first week of the year.
  31167. }
  31168. });
  31169. //! moment.js locale configuration
  31170. //! locale : Urdu [ur]
  31171. //! author : Sawood Alam : https://github.com/ibnesayeed
  31172. //! author : Zack : https://github.com/ZackVision
  31173. var months$8 = [
  31174. 'جنوری',
  31175. 'فروری',
  31176. 'مارچ',
  31177. 'اپریل',
  31178. 'مئی',
  31179. 'جون',
  31180. 'جولائی',
  31181. 'اگست',
  31182. 'ستمبر',
  31183. 'اکتوبر',
  31184. 'نومبر',
  31185. 'دسمبر'
  31186. ];
  31187. var days$2 = [
  31188. 'اتوار',
  31189. 'پیر',
  31190. 'منگل',
  31191. 'بدھ',
  31192. 'جمعرات',
  31193. 'جمعہ',
  31194. 'ہفتہ'
  31195. ];
  31196. hooks.defineLocale('ur', {
  31197. months : months$8,
  31198. monthsShort : months$8,
  31199. weekdays : days$2,
  31200. weekdaysShort : days$2,
  31201. weekdaysMin : days$2,
  31202. longDateFormat : {
  31203. LT : 'HH:mm',
  31204. LTS : 'HH:mm:ss',
  31205. L : 'DD/MM/YYYY',
  31206. LL : 'D MMMM YYYY',
  31207. LLL : 'D MMMM YYYY HH:mm',
  31208. LLLL : 'dddd، D MMMM YYYY HH:mm'
  31209. },
  31210. meridiemParse: /صبح|شام/,
  31211. isPM : function (input) {
  31212. return 'شام' === input;
  31213. },
  31214. meridiem : function (hour, minute, isLower) {
  31215. if (hour < 12) {
  31216. return 'صبح';
  31217. }
  31218. return 'شام';
  31219. },
  31220. calendar : {
  31221. sameDay : '[آج بوقت] LT',
  31222. nextDay : '[کل بوقت] LT',
  31223. nextWeek : 'dddd [بوقت] LT',
  31224. lastDay : '[گذشتہ روز بوقت] LT',
  31225. lastWeek : '[گذشتہ] dddd [بوقت] LT',
  31226. sameElse : 'L'
  31227. },
  31228. relativeTime : {
  31229. future : '%s بعد',
  31230. past : '%s قبل',
  31231. s : 'چند سیکنڈ',
  31232. m : 'ایک منٹ',
  31233. mm : '%d منٹ',
  31234. h : 'ایک گھنٹہ',
  31235. hh : '%d گھنٹے',
  31236. d : 'ایک دن',
  31237. dd : '%d دن',
  31238. M : 'ایک ماہ',
  31239. MM : '%d ماہ',
  31240. y : 'ایک سال',
  31241. yy : '%d سال'
  31242. },
  31243. preparse: function (string) {
  31244. return string.replace(/،/g, ',');
  31245. },
  31246. postformat: function (string) {
  31247. return string.replace(/,/g, '،');
  31248. },
  31249. week : {
  31250. dow : 1, // Monday is the first day of the week.
  31251. doy : 4 // The week that contains Jan 4th is the first week of the year.
  31252. }
  31253. });
  31254. //! moment.js locale configuration
  31255. //! locale : Uzbek Latin [uz-latn]
  31256. //! author : Rasulbek Mirzayev : github.com/Rasulbeeek
  31257. hooks.defineLocale('uz-latn', {
  31258. months : 'Yanvar_Fevral_Mart_Aprel_May_Iyun_Iyul_Avgust_Sentabr_Oktabr_Noyabr_Dekabr'.split('_'),
  31259. monthsShort : 'Yan_Fev_Mar_Apr_May_Iyun_Iyul_Avg_Sen_Okt_Noy_Dek'.split('_'),
  31260. weekdays : 'Yakshanba_Dushanba_Seshanba_Chorshanba_Payshanba_Juma_Shanba'.split('_'),
  31261. weekdaysShort : 'Yak_Dush_Sesh_Chor_Pay_Jum_Shan'.split('_'),
  31262. weekdaysMin : 'Ya_Du_Se_Cho_Pa_Ju_Sha'.split('_'),
  31263. longDateFormat : {
  31264. LT : 'HH:mm',
  31265. LTS : 'HH:mm:ss',
  31266. L : 'DD/MM/YYYY',
  31267. LL : 'D MMMM YYYY',
  31268. LLL : 'D MMMM YYYY HH:mm',
  31269. LLLL : 'D MMMM YYYY, dddd HH:mm'
  31270. },
  31271. calendar : {
  31272. sameDay : '[Bugun soat] LT [da]',
  31273. nextDay : '[Ertaga] LT [da]',
  31274. nextWeek : 'dddd [kuni soat] LT [da]',
  31275. lastDay : '[Kecha soat] LT [da]',
  31276. lastWeek : '[O\'tgan] dddd [kuni soat] LT [da]',
  31277. sameElse : 'L'
  31278. },
  31279. relativeTime : {
  31280. future : 'Yaqin %s ichida',
  31281. past : 'Bir necha %s oldin',
  31282. s : 'soniya',
  31283. m : 'bir daqiqa',
  31284. mm : '%d daqiqa',
  31285. h : 'bir soat',
  31286. hh : '%d soat',
  31287. d : 'bir kun',
  31288. dd : '%d kun',
  31289. M : 'bir oy',
  31290. MM : '%d oy',
  31291. y : 'bir yil',
  31292. yy : '%d yil'
  31293. },
  31294. week : {
  31295. dow : 1, // Monday is the first day of the week.
  31296. doy : 7 // The week that contains Jan 1st is the first week of the year.
  31297. }
  31298. });
  31299. //! moment.js locale configuration
  31300. //! locale : Uzbek [uz]
  31301. //! author : Sardor Muminov : https://github.com/muminoff
  31302. hooks.defineLocale('uz', {
  31303. months : 'январ_феврал_март_апрел_май_июн_июл_август_сентябр_октябр_ноябр_декабр'.split('_'),
  31304. monthsShort : 'янв_фев_мар_апр_май_июн_июл_авг_сен_окт_ноя_дек'.split('_'),
  31305. weekdays : 'Якшанба_Душанба_Сешанба_Чоршанба_Пайшанба_Жума_Шанба'.split('_'),
  31306. weekdaysShort : 'Якш_Душ_Сеш_Чор_Пай_Жум_Шан'.split('_'),
  31307. weekdaysMin : 'Як_Ду_Се_Чо_Па_Жу_Ша'.split('_'),
  31308. longDateFormat : {
  31309. LT : 'HH:mm',
  31310. LTS : 'HH:mm:ss',
  31311. L : 'DD/MM/YYYY',
  31312. LL : 'D MMMM YYYY',
  31313. LLL : 'D MMMM YYYY HH:mm',
  31314. LLLL : 'D MMMM YYYY, dddd HH:mm'
  31315. },
  31316. calendar : {
  31317. sameDay : '[Бугун соат] LT [да]',
  31318. nextDay : '[Эртага] LT [да]',
  31319. nextWeek : 'dddd [куни соат] LT [да]',
  31320. lastDay : '[Кеча соат] LT [да]',
  31321. lastWeek : '[Утган] dddd [куни соат] LT [да]',
  31322. sameElse : 'L'
  31323. },
  31324. relativeTime : {
  31325. future : 'Якин %s ичида',
  31326. past : 'Бир неча %s олдин',
  31327. s : 'фурсат',
  31328. m : 'бир дакика',
  31329. mm : '%d дакика',
  31330. h : 'бир соат',
  31331. hh : '%d соат',
  31332. d : 'бир кун',
  31333. dd : '%d кун',
  31334. M : 'бир ой',
  31335. MM : '%d ой',
  31336. y : 'бир йил',
  31337. yy : '%d йил'
  31338. },
  31339. week : {
  31340. dow : 1, // Monday is the first day of the week.
  31341. doy : 7 // The week that contains Jan 4th is the first week of the year.
  31342. }
  31343. });
  31344. //! moment.js locale configuration
  31345. //! locale : Vietnamese [vi]
  31346. //! author : Bang Nguyen : https://github.com/bangnk
  31347. hooks.defineLocale('vi', {
  31348. months : 'tháng 1_tháng 2_tháng 3_tháng 4_tháng 5_tháng 6_tháng 7_tháng 8_tháng 9_tháng 10_tháng 11_tháng 12'.split('_'),
  31349. monthsShort : 'Th01_Th02_Th03_Th04_Th05_Th06_Th07_Th08_Th09_Th10_Th11_Th12'.split('_'),
  31350. monthsParseExact : true,
  31351. weekdays : 'chủ nhật_thứ hai_thứ ba_thứ tư_thứ năm_thứ sáu_thứ bảy'.split('_'),
  31352. weekdaysShort : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
  31353. weekdaysMin : 'CN_T2_T3_T4_T5_T6_T7'.split('_'),
  31354. weekdaysParseExact : true,
  31355. meridiemParse: /sa|ch/i,
  31356. isPM : function (input) {
  31357. return /^ch$/i.test(input);
  31358. },
  31359. meridiem : function (hours, minutes, isLower) {
  31360. if (hours < 12) {
  31361. return isLower ? 'sa' : 'SA';
  31362. } else {
  31363. return isLower ? 'ch' : 'CH';
  31364. }
  31365. },
  31366. longDateFormat : {
  31367. LT : 'HH:mm',
  31368. LTS : 'HH:mm:ss',
  31369. L : 'DD/MM/YYYY',
  31370. LL : 'D MMMM [năm] YYYY',
  31371. LLL : 'D MMMM [năm] YYYY HH:mm',
  31372. LLLL : 'dddd, D MMMM [năm] YYYY HH:mm',
  31373. l : 'DD/M/YYYY',
  31374. ll : 'D MMM YYYY',
  31375. lll : 'D MMM YYYY HH:mm',
  31376. llll : 'ddd, D MMM YYYY HH:mm'
  31377. },
  31378. calendar : {
  31379. sameDay: '[Hôm nay lúc] LT',
  31380. nextDay: '[Ngày mai lúc] LT',
  31381. nextWeek: 'dddd [tuần tới lúc] LT',
  31382. lastDay: '[Hôm qua lúc] LT',
  31383. lastWeek: 'dddd [tuần rồi lúc] LT',
  31384. sameElse: 'L'
  31385. },
  31386. relativeTime : {
  31387. future : '%s tới',
  31388. past : '%s trước',
  31389. s : 'vài giây',
  31390. m : 'một phút',
  31391. mm : '%d phút',
  31392. h : 'một giờ',
  31393. hh : '%d giờ',
  31394. d : 'một ngày',
  31395. dd : '%d ngày',
  31396. M : 'một tháng',
  31397. MM : '%d tháng',
  31398. y : 'một năm',
  31399. yy : '%d năm'
  31400. },
  31401. dayOfMonthOrdinalParse: /\d{1,2}/,
  31402. ordinal : function (number) {
  31403. return number;
  31404. },
  31405. week : {
  31406. dow : 1, // Monday is the first day of the week.
  31407. doy : 4 // The week that contains Jan 4th is the first week of the year.
  31408. }
  31409. });
  31410. //! moment.js locale configuration
  31411. //! locale : Pseudo [x-pseudo]
  31412. //! author : Andrew Hood : https://github.com/andrewhood125
  31413. hooks.defineLocale('x-pseudo', {
  31414. months : 'J~áñúá~rý_F~ébrú~árý_~Márc~h_Áp~ríl_~Máý_~Júñé~_Júl~ý_Áú~gúst~_Sép~témb~ér_Ó~ctób~ér_Ñ~óvém~bér_~Décé~mbér'.split('_'),
  31415. monthsShort : 'J~áñ_~Féb_~Már_~Ápr_~Máý_~Júñ_~Júl_~Áúg_~Sép_~Óct_~Ñóv_~Déc'.split('_'),
  31416. monthsParseExact : true,
  31417. weekdays : 'S~úñdá~ý_Mó~ñdáý~_Túé~sdáý~_Wéd~ñésd~áý_T~húrs~dáý_~Fríd~áý_S~átúr~dáý'.split('_'),
  31418. weekdaysShort : 'S~úñ_~Móñ_~Túé_~Wéd_~Thú_~Frí_~Sát'.split('_'),
  31419. weekdaysMin : 'S~ú_Mó~_Tú_~Wé_T~h_Fr~_Sá'.split('_'),
  31420. weekdaysParseExact : true,
  31421. longDateFormat : {
  31422. LT : 'HH:mm',
  31423. L : 'DD/MM/YYYY',
  31424. LL : 'D MMMM YYYY',
  31425. LLL : 'D MMMM YYYY HH:mm',
  31426. LLLL : 'dddd, D MMMM YYYY HH:mm'
  31427. },
  31428. calendar : {
  31429. sameDay : '[T~ódá~ý át] LT',
  31430. nextDay : '[T~ómó~rró~w át] LT',
  31431. nextWeek : 'dddd [át] LT',
  31432. lastDay : '[Ý~ést~érdá~ý át] LT',
  31433. lastWeek : '[L~ást] dddd [át] LT',
  31434. sameElse : 'L'
  31435. },
  31436. relativeTime : {
  31437. future : 'í~ñ %s',
  31438. past : '%s á~gó',
  31439. s : 'á ~féw ~sécó~ñds',
  31440. m : 'á ~míñ~úté',
  31441. mm : '%d m~íñú~tés',
  31442. h : 'á~ñ hó~úr',
  31443. hh : '%d h~óúrs',
  31444. d : 'á ~dáý',
  31445. dd : '%d d~áýs',
  31446. M : 'á ~móñ~th',
  31447. MM : '%d m~óñt~hs',
  31448. y : 'á ~ýéár',
  31449. yy : '%d ý~éárs'
  31450. },
  31451. dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
  31452. ordinal : function (number) {
  31453. var b = number % 10,
  31454. output = (~~(number % 100 / 10) === 1) ? 'th' :
  31455. (b === 1) ? 'st' :
  31456. (b === 2) ? 'nd' :
  31457. (b === 3) ? 'rd' : 'th';
  31458. return number + output;
  31459. },
  31460. week : {
  31461. dow : 1, // Monday is the first day of the week.
  31462. doy : 4 // The week that contains Jan 4th is the first week of the year.
  31463. }
  31464. });
  31465. //! moment.js locale configuration
  31466. //! locale : Yoruba Nigeria [yo]
  31467. //! author : Atolagbe Abisoye : https://github.com/andela-batolagbe
  31468. hooks.defineLocale('yo', {
  31469. months : 'Sẹ́rẹ́_Èrèlè_Ẹrẹ̀nà_Ìgbé_Èbibi_Òkùdu_Agẹmo_Ògún_Owewe_Ọ̀wàrà_Bélú_Ọ̀pẹ̀̀'.split('_'),
  31470. monthsShort : 'Sẹ́r_Èrl_Ẹrn_Ìgb_Èbi_Òkù_Agẹ_Ògú_Owe_Ọ̀wà_Bél_Ọ̀pẹ̀̀'.split('_'),
  31471. weekdays : 'Àìkú_Ajé_Ìsẹ́gun_Ọjọ́rú_Ọjọ́bọ_Ẹtì_Àbámẹ́ta'.split('_'),
  31472. weekdaysShort : 'Àìk_Ajé_Ìsẹ́_Ọjr_Ọjb_Ẹtì_Àbá'.split('_'),
  31473. weekdaysMin : 'Àì_Aj_Ìs_Ọr_Ọb_Ẹt_Àb'.split('_'),
  31474. longDateFormat : {
  31475. LT : 'h:mm A',
  31476. LTS : 'h:mm:ss A',
  31477. L : 'DD/MM/YYYY',
  31478. LL : 'D MMMM YYYY',
  31479. LLL : 'D MMMM YYYY h:mm A',
  31480. LLLL : 'dddd, D MMMM YYYY h:mm A'
  31481. },
  31482. calendar : {
  31483. sameDay : '[Ònì ni] LT',
  31484. nextDay : '[Ọ̀la ni] LT',
  31485. nextWeek : 'dddd [Ọsẹ̀ tón\'bọ] [ni] LT',
  31486. lastDay : '[Àna ni] LT',
  31487. lastWeek : 'dddd [Ọsẹ̀ tólọ́] [ni] LT',
  31488. sameElse : 'L'
  31489. },
  31490. relativeTime : {
  31491. future : 'ní %s',
  31492. past : '%s kọjá',
  31493. s : 'ìsẹjú aayá die',
  31494. m : 'ìsẹjú kan',
  31495. mm : 'ìsẹjú %d',
  31496. h : 'wákati kan',
  31497. hh : 'wákati %d',
  31498. d : 'ọjọ́ kan',
  31499. dd : 'ọjọ́ %d',
  31500. M : 'osù kan',
  31501. MM : 'osù %d',
  31502. y : 'ọdún kan',
  31503. yy : 'ọdún %d'
  31504. },
  31505. dayOfMonthOrdinalParse : /ọjọ́\s\d{1,2}/,
  31506. ordinal : 'ọjọ́ %d',
  31507. week : {
  31508. dow : 1, // Monday is the first day of the week.
  31509. doy : 4 // The week that contains Jan 4th is the first week of the year.
  31510. }
  31511. });
  31512. //! moment.js locale configuration
  31513. //! locale : Chinese (China) [zh-cn]
  31514. //! author : suupic : https://github.com/suupic
  31515. //! author : Zeno Zeng : https://github.com/zenozeng
  31516. hooks.defineLocale('zh-cn', {
  31517. months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  31518. monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  31519. weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  31520. weekdaysShort : '周日_周一_周二_周三_周四_周五_周六'.split('_'),
  31521. weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
  31522. longDateFormat : {
  31523. LT : 'HH:mm',
  31524. LTS : 'HH:mm:ss',
  31525. L : 'YYYY年MMMD日',
  31526. LL : 'YYYY年MMMD日',
  31527. LLL : 'YYYY年MMMD日Ah点mm分',
  31528. LLLL : 'YYYY年MMMD日ddddAh点mm分',
  31529. l : 'YYYY年MMMD日',
  31530. ll : 'YYYY年MMMD日',
  31531. lll : 'YYYY年MMMD日 HH:mm',
  31532. llll : 'YYYY年MMMD日dddd HH:mm'
  31533. },
  31534. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  31535. meridiemHour: function (hour, meridiem) {
  31536. if (hour === 12) {
  31537. hour = 0;
  31538. }
  31539. if (meridiem === '凌晨' || meridiem === '早上' ||
  31540. meridiem === '上午') {
  31541. return hour;
  31542. } else if (meridiem === '下午' || meridiem === '晚上') {
  31543. return hour + 12;
  31544. } else {
  31545. // '中午'
  31546. return hour >= 11 ? hour : hour + 12;
  31547. }
  31548. },
  31549. meridiem : function (hour, minute, isLower) {
  31550. var hm = hour * 100 + minute;
  31551. if (hm < 600) {
  31552. return '凌晨';
  31553. } else if (hm < 900) {
  31554. return '早上';
  31555. } else if (hm < 1130) {
  31556. return '上午';
  31557. } else if (hm < 1230) {
  31558. return '中午';
  31559. } else if (hm < 1800) {
  31560. return '下午';
  31561. } else {
  31562. return '晚上';
  31563. }
  31564. },
  31565. calendar : {
  31566. sameDay : '[今天]LT',
  31567. nextDay : '[明天]LT',
  31568. nextWeek : '[下]ddddLT',
  31569. lastDay : '[昨天]LT',
  31570. lastWeek : '[上]ddddLT',
  31571. sameElse : 'L'
  31572. },
  31573. dayOfMonthOrdinalParse: /\d{1,2}(日|月|周)/,
  31574. ordinal : function (number, period) {
  31575. switch (period) {
  31576. case 'd':
  31577. case 'D':
  31578. case 'DDD':
  31579. return number + '日';
  31580. case 'M':
  31581. return number + '月';
  31582. case 'w':
  31583. case 'W':
  31584. return number + '周';
  31585. default:
  31586. return number;
  31587. }
  31588. },
  31589. relativeTime : {
  31590. future : '%s内',
  31591. past : '%s前',
  31592. s : '几秒',
  31593. m : '1 分钟',
  31594. mm : '%d 分钟',
  31595. h : '1 小时',
  31596. hh : '%d 小时',
  31597. d : '1 天',
  31598. dd : '%d 天',
  31599. M : '1 个月',
  31600. MM : '%d 个月',
  31601. y : '1 年',
  31602. yy : '%d 年'
  31603. },
  31604. week : {
  31605. // GB/T 7408-1994《数据元和交换格式·信息交换·日期和时间表示法》与ISO 8601:1988等效
  31606. dow : 1, // Monday is the first day of the week.
  31607. doy : 4 // The week that contains Jan 4th is the first week of the year.
  31608. }
  31609. });
  31610. //! moment.js locale configuration
  31611. //! locale : Chinese (Hong Kong) [zh-hk]
  31612. //! author : Ben : https://github.com/ben-lin
  31613. //! author : Chris Lam : https://github.com/hehachris
  31614. //! author : Konstantin : https://github.com/skfd
  31615. hooks.defineLocale('zh-hk', {
  31616. months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  31617. monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  31618. weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  31619. weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
  31620. weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
  31621. longDateFormat : {
  31622. LT : 'HH:mm',
  31623. LTS : 'HH:mm:ss',
  31624. L : 'YYYY年MMMD日',
  31625. LL : 'YYYY年MMMD日',
  31626. LLL : 'YYYY年MMMD日 HH:mm',
  31627. LLLL : 'YYYY年MMMD日dddd HH:mm',
  31628. l : 'YYYY年MMMD日',
  31629. ll : 'YYYY年MMMD日',
  31630. lll : 'YYYY年MMMD日 HH:mm',
  31631. llll : 'YYYY年MMMD日dddd HH:mm'
  31632. },
  31633. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  31634. meridiemHour : function (hour, meridiem) {
  31635. if (hour === 12) {
  31636. hour = 0;
  31637. }
  31638. if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') {
  31639. return hour;
  31640. } else if (meridiem === '中午') {
  31641. return hour >= 11 ? hour : hour + 12;
  31642. } else if (meridiem === '下午' || meridiem === '晚上') {
  31643. return hour + 12;
  31644. }
  31645. },
  31646. meridiem : function (hour, minute, isLower) {
  31647. var hm = hour * 100 + minute;
  31648. if (hm < 600) {
  31649. return '凌晨';
  31650. } else if (hm < 900) {
  31651. return '早上';
  31652. } else if (hm < 1130) {
  31653. return '上午';
  31654. } else if (hm < 1230) {
  31655. return '中午';
  31656. } else if (hm < 1800) {
  31657. return '下午';
  31658. } else {
  31659. return '晚上';
  31660. }
  31661. },
  31662. calendar : {
  31663. sameDay : '[今天]LT',
  31664. nextDay : '[明天]LT',
  31665. nextWeek : '[下]ddddLT',
  31666. lastDay : '[昨天]LT',
  31667. lastWeek : '[上]ddddLT',
  31668. sameElse : 'L'
  31669. },
  31670. dayOfMonthOrdinalParse: /\d{1,2}(日|月|週)/,
  31671. ordinal : function (number, period) {
  31672. switch (period) {
  31673. case 'd' :
  31674. case 'D' :
  31675. case 'DDD' :
  31676. return number + '日';
  31677. case 'M' :
  31678. return number + '月';
  31679. case 'w' :
  31680. case 'W' :
  31681. return number + '週';
  31682. default :
  31683. return number;
  31684. }
  31685. },
  31686. relativeTime : {
  31687. future : '%s內',
  31688. past : '%s前',
  31689. s : '幾秒',
  31690. m : '1 分鐘',
  31691. mm : '%d 分鐘',
  31692. h : '1 小時',
  31693. hh : '%d 小時',
  31694. d : '1 天',
  31695. dd : '%d 天',
  31696. M : '1 個月',
  31697. MM : '%d 個月',
  31698. y : '1 年',
  31699. yy : '%d 年'
  31700. }
  31701. });
  31702. //! moment.js locale configuration
  31703. //! locale : Chinese (Taiwan) [zh-tw]
  31704. //! author : Ben : https://github.com/ben-lin
  31705. //! author : Chris Lam : https://github.com/hehachris
  31706. hooks.defineLocale('zh-tw', {
  31707. months : '一月_二月_三月_四月_五月_六月_七月_八月_九月_十月_十一月_十二月'.split('_'),
  31708. monthsShort : '1月_2月_3月_4月_5月_6月_7月_8月_9月_10月_11月_12月'.split('_'),
  31709. weekdays : '星期日_星期一_星期二_星期三_星期四_星期五_星期六'.split('_'),
  31710. weekdaysShort : '週日_週一_週二_週三_週四_週五_週六'.split('_'),
  31711. weekdaysMin : '日_一_二_三_四_五_六'.split('_'),
  31712. longDateFormat : {
  31713. LT : 'HH:mm',
  31714. LTS : 'HH:mm:ss',
  31715. L : 'YYYY年MMMD日',
  31716. LL : 'YYYY年MMMD日',
  31717. LLL : 'YYYY年MMMD日 HH:mm',
  31718. LLLL : 'YYYY年MMMD日dddd HH:mm',
  31719. l : 'YYYY年MMMD日',
  31720. ll : 'YYYY年MMMD日',
  31721. lll : 'YYYY年MMMD日 HH:mm',
  31722. llll : 'YYYY年MMMD日dddd HH:mm'
  31723. },
  31724. meridiemParse: /凌晨|早上|上午|中午|下午|晚上/,
  31725. meridiemHour : function (hour, meridiem) {
  31726. if (hour === 12) {
  31727. hour = 0;
  31728. }
  31729. if (meridiem === '凌晨' || meridiem === '早上' || meridiem === '上午') {
  31730. return hour;
  31731. } else if (meridiem === '中午') {
  31732. return hour >= 11 ? hour : hour + 12;
  31733. } else if (meridiem === '下午' || meridiem === '晚上') {
  31734. return hour + 12;
  31735. }
  31736. },
  31737. meridiem : function (hour, minute, isLower) {
  31738. var hm = hour * 100 + minute;
  31739. if (hm < 600) {
  31740. return '凌晨';
  31741. } else if (hm < 900) {
  31742. return '早上';
  31743. } else if (hm < 1130) {
  31744. return '上午';
  31745. } else if (hm < 1230) {
  31746. return '中午';
  31747. } else if (hm < 1800) {
  31748. return '下午';
  31749. } else {
  31750. return '晚上';
  31751. }
  31752. },
  31753. calendar : {
  31754. sameDay : '[今天]LT',
  31755. nextDay : '[明天]LT',
  31756. nextWeek : '[下]ddddLT',
  31757. lastDay : '[昨天]LT',
  31758. lastWeek : '[上]ddddLT',
  31759. sameElse : 'L'
  31760. },
  31761. dayOfMonthOrdinalParse: /\d{1,2}(日|月|週)/,
  31762. ordinal : function (number, period) {
  31763. switch (period) {
  31764. case 'd' :
  31765. case 'D' :
  31766. case 'DDD' :
  31767. return number + '日';
  31768. case 'M' :
  31769. return number + '月';
  31770. case 'w' :
  31771. case 'W' :
  31772. return number + '週';
  31773. default :
  31774. return number;
  31775. }
  31776. },
  31777. relativeTime : {
  31778. future : '%s內',
  31779. past : '%s前',
  31780. s : '幾秒',
  31781. m : '1 分鐘',
  31782. mm : '%d 分鐘',
  31783. h : '1 小時',
  31784. hh : '%d 小時',
  31785. d : '1 天',
  31786. dd : '%d 天',
  31787. M : '1 個月',
  31788. MM : '%d 個月',
  31789. y : '1 年',
  31790. yy : '%d 年'
  31791. }
  31792. });
  31793. hooks.locale('en');
  31794. return hooks;
  31795. })));
  31796. // Underscore.js 1.8.3
  31797. // http://underscorejs.org
  31798. // (c) 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  31799. // Underscore may be freely distributed under the MIT license.
  31800. (function(){function n(n){function t(t,r,e,u,i,o){for(;i>=0&&o>i;i+=n){var a=u?u[i]:i;e=r(e,t[a],a,t)}return e}return function(r,e,u,i){e=b(e,i,4);var o=!k(r)&&m.keys(r),a=(o||r).length,c=n>0?0:a-1;return arguments.length<3&&(u=r[o?o[c]:c],c+=n),t(r,e,u,o,c,a)}}function t(n){return function(t,r,e){r=x(r,e);for(var u=O(t),i=n>0?0:u-1;i>=0&&u>i;i+=n)if(r(t[i],i,t))return i;return-1}}function r(n,t,r){return function(e,u,i){var o=0,a=O(e);if("number"==typeof i)n>0?o=i>=0?i:Math.max(i+a,o):a=i>=0?Math.min(i+1,a):i+a+1;else if(r&&i&&a)return i=r(e,u),e[i]===u?i:-1;if(u!==u)return i=t(l.call(e,o,a),m.isNaN),i>=0?i+o:-1;for(i=n>0?o:a-1;i>=0&&a>i;i+=n)if(e[i]===u)return i;return-1}}function e(n,t){var r=I.length,e=n.constructor,u=m.isFunction(e)&&e.prototype||a,i="constructor";for(m.has(n,i)&&!m.contains(t,i)&&t.push(i);r--;)i=I[r],i in n&&n[i]!==u[i]&&!m.contains(t,i)&&t.push(i)}var u=this,i=u._,o=Array.prototype,a=Object.prototype,c=Function.prototype,f=o.push,l=o.slice,s=a.toString,p=a.hasOwnProperty,h=Array.isArray,v=Object.keys,g=c.bind,y=Object.create,d=function(){},m=function(n){return n instanceof m?n:this instanceof m?void(this._wrapped=n):new m(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=m),exports._=m):u._=m,m.VERSION="1.8.3";var b=function(n,t,r){if(t===void 0)return n;switch(null==r?3:r){case 1:return function(r){return n.call(t,r)};case 2:return function(r,e){return n.call(t,r,e)};case 3:return function(r,e,u){return n.call(t,r,e,u)};case 4:return function(r,e,u,i){return n.call(t,r,e,u,i)}}return function(){return n.apply(t,arguments)}},x=function(n,t,r){return null==n?m.identity:m.isFunction(n)?b(n,t,r):m.isObject(n)?m.matcher(n):m.property(n)};m.iteratee=function(n,t){return x(n,t,1/0)};var _=function(n,t){return function(r){var e=arguments.length;if(2>e||null==r)return r;for(var u=1;e>u;u++)for(var i=arguments[u],o=n(i),a=o.length,c=0;a>c;c++){var f=o[c];t&&r[f]!==void 0||(r[f]=i[f])}return r}},j=function(n){if(!m.isObject(n))return{};if(y)return y(n);d.prototype=n;var t=new d;return d.prototype=null,t},w=function(n){return function(t){return null==t?void 0:t[n]}},A=Math.pow(2,53)-1,O=w("length"),k=function(n){var t=O(n);return"number"==typeof t&&t>=0&&A>=t};m.each=m.forEach=function(n,t,r){t=b(t,r);var e,u;if(k(n))for(e=0,u=n.length;u>e;e++)t(n[e],e,n);else{var i=m.keys(n);for(e=0,u=i.length;u>e;e++)t(n[i[e]],i[e],n)}return n},m.map=m.collect=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=Array(u),o=0;u>o;o++){var a=e?e[o]:o;i[o]=t(n[a],a,n)}return i},m.reduce=m.foldl=m.inject=n(1),m.reduceRight=m.foldr=n(-1),m.find=m.detect=function(n,t,r){var e;return e=k(n)?m.findIndex(n,t,r):m.findKey(n,t,r),e!==void 0&&e!==-1?n[e]:void 0},m.filter=m.select=function(n,t,r){var e=[];return t=x(t,r),m.each(n,function(n,r,u){t(n,r,u)&&e.push(n)}),e},m.reject=function(n,t,r){return m.filter(n,m.negate(x(t)),r)},m.every=m.all=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(!t(n[o],o,n))return!1}return!0},m.some=m.any=function(n,t,r){t=x(t,r);for(var e=!k(n)&&m.keys(n),u=(e||n).length,i=0;u>i;i++){var o=e?e[i]:i;if(t(n[o],o,n))return!0}return!1},m.contains=m.includes=m.include=function(n,t,r,e){return k(n)||(n=m.values(n)),("number"!=typeof r||e)&&(r=0),m.indexOf(n,t,r)>=0},m.invoke=function(n,t){var r=l.call(arguments,2),e=m.isFunction(t);return m.map(n,function(n){var u=e?t:n[t];return null==u?u:u.apply(n,r)})},m.pluck=function(n,t){return m.map(n,m.property(t))},m.where=function(n,t){return m.filter(n,m.matcher(t))},m.findWhere=function(n,t){return m.find(n,m.matcher(t))},m.max=function(n,t,r){var e,u,i=-1/0,o=-1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],e>i&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(u>o||u===-1/0&&i===-1/0)&&(i=n,o=u)});return i},m.min=function(n,t,r){var e,u,i=1/0,o=1/0;if(null==t&&null!=n){n=k(n)?n:m.values(n);for(var a=0,c=n.length;c>a;a++)e=n[a],i>e&&(i=e)}else t=x(t,r),m.each(n,function(n,r,e){u=t(n,r,e),(o>u||1/0===u&&1/0===i)&&(i=n,o=u)});return i},m.shuffle=function(n){for(var t,r=k(n)?n:m.values(n),e=r.length,u=Array(e),i=0;e>i;i++)t=m.random(0,i),t!==i&&(u[i]=u[t]),u[t]=r[i];return u},m.sample=function(n,t,r){return null==t||r?(k(n)||(n=m.values(n)),n[m.random(n.length-1)]):m.shuffle(n).slice(0,Math.max(0,t))},m.sortBy=function(n,t,r){return t=x(t,r),m.pluck(m.map(n,function(n,r,e){return{value:n,index:r,criteria:t(n,r,e)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={};return r=x(r,e),m.each(t,function(e,i){var o=r(e,i,t);n(u,e,o)}),u}};m.groupBy=F(function(n,t,r){m.has(n,r)?n[r].push(t):n[r]=[t]}),m.indexBy=F(function(n,t,r){n[r]=t}),m.countBy=F(function(n,t,r){m.has(n,r)?n[r]++:n[r]=1}),m.toArray=function(n){return n?m.isArray(n)?l.call(n):k(n)?m.map(n,m.identity):m.values(n):[]},m.size=function(n){return null==n?0:k(n)?n.length:m.keys(n).length},m.partition=function(n,t,r){t=x(t,r);var e=[],u=[];return m.each(n,function(n,r,i){(t(n,r,i)?e:u).push(n)}),[e,u]},m.first=m.head=m.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:m.initial(n,n.length-t)},m.initial=function(n,t,r){return l.call(n,0,Math.max(0,n.length-(null==t||r?1:t)))},m.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:m.rest(n,Math.max(0,n.length-t))},m.rest=m.tail=m.drop=function(n,t,r){return l.call(n,null==t||r?1:t)},m.compact=function(n){return m.filter(n,m.identity)};var S=function(n,t,r,e){for(var u=[],i=0,o=e||0,a=O(n);a>o;o++){var c=n[o];if(k(c)&&(m.isArray(c)||m.isArguments(c))){t||(c=S(c,t,r));var f=0,l=c.length;for(u.length+=l;l>f;)u[i++]=c[f++]}else r||(u[i++]=c)}return u};m.flatten=function(n,t){return S(n,t,!1)},m.without=function(n){return m.difference(n,l.call(arguments,1))},m.uniq=m.unique=function(n,t,r,e){m.isBoolean(t)||(e=r,r=t,t=!1),null!=r&&(r=x(r,e));for(var u=[],i=[],o=0,a=O(n);a>o;o++){var c=n[o],f=r?r(c,o,n):c;t?(o&&i===f||u.push(c),i=f):r?m.contains(i,f)||(i.push(f),u.push(c)):m.contains(u,c)||u.push(c)}return u},m.union=function(){return m.uniq(S(arguments,!0,!0))},m.intersection=function(n){for(var t=[],r=arguments.length,e=0,u=O(n);u>e;e++){var i=n[e];if(!m.contains(t,i)){for(var o=1;r>o&&m.contains(arguments[o],i);o++);o===r&&t.push(i)}}return t},m.difference=function(n){var t=S(arguments,!0,!0,1);return m.filter(n,function(n){return!m.contains(t,n)})},m.zip=function(){return m.unzip(arguments)},m.unzip=function(n){for(var t=n&&m.max(n,O).length||0,r=Array(t),e=0;t>e;e++)r[e]=m.pluck(n,e);return r},m.object=function(n,t){for(var r={},e=0,u=O(n);u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},m.findIndex=t(1),m.findLastIndex=t(-1),m.sortedIndex=function(n,t,r,e){r=x(r,e,1);for(var u=r(t),i=0,o=O(n);o>i;){var a=Math.floor((i+o)/2);r(n[a])<u?i=a+1:o=a}return i},m.indexOf=r(1,m.findIndex,m.sortedIndex),m.lastIndexOf=r(-1,m.findLastIndex),m.range=function(n,t,r){null==t&&(t=n||0,n=0),r=r||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=Array(e),i=0;e>i;i++,n+=r)u[i]=n;return u};var E=function(n,t,r,e,u){if(!(e instanceof t))return n.apply(r,u);var i=j(n.prototype),o=n.apply(i,u);return m.isObject(o)?o:i};m.bind=function(n,t){if(g&&n.bind===g)return g.apply(n,l.call(arguments,1));if(!m.isFunction(n))throw new TypeError("Bind must be called on a function");var r=l.call(arguments,2),e=function(){return E(n,e,t,this,r.concat(l.call(arguments)))};return e},m.partial=function(n){var t=l.call(arguments,1),r=function(){for(var e=0,u=t.length,i=Array(u),o=0;u>o;o++)i[o]=t[o]===m?arguments[e++]:t[o];for(;e<arguments.length;)i.push(arguments[e++]);return E(n,r,this,this,i)};return r},m.bindAll=function(n){var t,r,e=arguments.length;if(1>=e)throw new Error("bindAll must be passed function names");for(t=1;e>t;t++)r=arguments[t],n[r]=m.bind(n[r],n);return n},m.memoize=function(n,t){var r=function(e){var u=r.cache,i=""+(t?t.apply(this,arguments):e);return m.has(u,i)||(u[i]=n.apply(this,arguments)),u[i]};return r.cache={},r},m.delay=function(n,t){var r=l.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},m.defer=m.partial(m.delay,m,1),m.throttle=function(n,t,r){var e,u,i,o=null,a=0;r||(r={});var c=function(){a=r.leading===!1?0:m.now(),o=null,i=n.apply(e,u),o||(e=u=null)};return function(){var f=m.now();a||r.leading!==!1||(a=f);var l=t-(f-a);return e=this,u=arguments,0>=l||l>t?(o&&(clearTimeout(o),o=null),a=f,i=n.apply(e,u),o||(e=u=null)):o||r.trailing===!1||(o=setTimeout(c,l)),i}},m.debounce=function(n,t,r){var e,u,i,o,a,c=function(){var f=m.now()-o;t>f&&f>=0?e=setTimeout(c,t-f):(e=null,r||(a=n.apply(i,u),e||(i=u=null)))};return function(){i=this,u=arguments,o=m.now();var f=r&&!e;return e||(e=setTimeout(c,t)),f&&(a=n.apply(i,u),i=u=null),a}},m.wrap=function(n,t){return m.partial(t,n)},m.negate=function(n){return function(){return!n.apply(this,arguments)}},m.compose=function(){var n=arguments,t=n.length-1;return function(){for(var r=t,e=n[t].apply(this,arguments);r--;)e=n[r].call(this,e);return e}},m.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},m.before=function(n,t){var r;return function(){return--n>0&&(r=t.apply(this,arguments)),1>=n&&(t=null),r}},m.once=m.partial(m.before,2);var M=!{toString:null}.propertyIsEnumerable("toString"),I=["valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"];m.keys=function(n){if(!m.isObject(n))return[];if(v)return v(n);var t=[];for(var r in n)m.has(n,r)&&t.push(r);return M&&e(n,t),t},m.allKeys=function(n){if(!m.isObject(n))return[];var t=[];for(var r in n)t.push(r);return M&&e(n,t),t},m.values=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},m.mapObject=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=u.length,o={},a=0;i>a;a++)e=u[a],o[e]=t(n[e],e,n);return o},m.pairs=function(n){for(var t=m.keys(n),r=t.length,e=Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},m.invert=function(n){for(var t={},r=m.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},m.functions=m.methods=function(n){var t=[];for(var r in n)m.isFunction(n[r])&&t.push(r);return t.sort()},m.extend=_(m.allKeys),m.extendOwn=m.assign=_(m.keys),m.findKey=function(n,t,r){t=x(t,r);for(var e,u=m.keys(n),i=0,o=u.length;o>i;i++)if(e=u[i],t(n[e],e,n))return e},m.pick=function(n,t,r){var e,u,i={},o=n;if(null==o)return i;m.isFunction(t)?(u=m.allKeys(o),e=b(t,r)):(u=S(arguments,!1,!1,1),e=function(n,t,r){return t in r},o=Object(o));for(var a=0,c=u.length;c>a;a++){var f=u[a],l=o[f];e(l,f,o)&&(i[f]=l)}return i},m.omit=function(n,t,r){if(m.isFunction(t))t=m.negate(t);else{var e=m.map(S(arguments,!1,!1,1),String);t=function(n,t){return!m.contains(e,t)}}return m.pick(n,t,r)},m.defaults=_(m.allKeys,!0),m.create=function(n,t){var r=j(n);return t&&m.extendOwn(r,t),r},m.clone=function(n){return m.isObject(n)?m.isArray(n)?n.slice():m.extend({},n):n},m.tap=function(n,t){return t(n),n},m.isMatch=function(n,t){var r=m.keys(t),e=r.length;if(null==n)return!e;for(var u=Object(n),i=0;e>i;i++){var o=r[i];if(t[o]!==u[o]||!(o in u))return!1}return!0};var N=function(n,t,r,e){if(n===t)return 0!==n||1/n===1/t;if(null==n||null==t)return n===t;n instanceof m&&(n=n._wrapped),t instanceof m&&(t=t._wrapped);var u=s.call(n);if(u!==s.call(t))return!1;switch(u){case"[object RegExp]":case"[object String]":return""+n==""+t;case"[object Number]":return+n!==+n?+t!==+t:0===+n?1/+n===1/t:+n===+t;case"[object Date]":case"[object Boolean]":return+n===+t}var i="[object Array]"===u;if(!i){if("object"!=typeof n||"object"!=typeof t)return!1;var o=n.constructor,a=t.constructor;if(o!==a&&!(m.isFunction(o)&&o instanceof o&&m.isFunction(a)&&a instanceof a)&&"constructor"in n&&"constructor"in t)return!1}r=r||[],e=e||[];for(var c=r.length;c--;)if(r[c]===n)return e[c]===t;if(r.push(n),e.push(t),i){if(c=n.length,c!==t.length)return!1;for(;c--;)if(!N(n[c],t[c],r,e))return!1}else{var f,l=m.keys(n);if(c=l.length,m.keys(t).length!==c)return!1;for(;c--;)if(f=l[c],!m.has(t,f)||!N(n[f],t[f],r,e))return!1}return r.pop(),e.pop(),!0};m.isEqual=function(n,t){return N(n,t)},m.isEmpty=function(n){return null==n?!0:k(n)&&(m.isArray(n)||m.isString(n)||m.isArguments(n))?0===n.length:0===m.keys(n).length},m.isElement=function(n){return!(!n||1!==n.nodeType)},m.isArray=h||function(n){return"[object Array]"===s.call(n)},m.isObject=function(n){var t=typeof n;return"function"===t||"object"===t&&!!n},m.each(["Arguments","Function","String","Number","Date","RegExp","Error"],function(n){m["is"+n]=function(t){return s.call(t)==="[object "+n+"]"}}),m.isArguments(arguments)||(m.isArguments=function(n){return m.has(n,"callee")}),"function"!=typeof/./&&"object"!=typeof Int8Array&&(m.isFunction=function(n){return"function"==typeof n||!1}),m.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},m.isNaN=function(n){return m.isNumber(n)&&n!==+n},m.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"===s.call(n)},m.isNull=function(n){return null===n},m.isUndefined=function(n){return n===void 0},m.has=function(n,t){return null!=n&&p.call(n,t)},m.noConflict=function(){return u._=i,this},m.identity=function(n){return n},m.constant=function(n){return function(){return n}},m.noop=function(){},m.property=w,m.propertyOf=function(n){return null==n?function(){}:function(t){return n[t]}},m.matcher=m.matches=function(n){return n=m.extendOwn({},n),function(t){return m.isMatch(t,n)}},m.times=function(n,t,r){var e=Array(Math.max(0,n));t=b(t,r,1);for(var u=0;n>u;u++)e[u]=t(u);return e},m.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))},m.now=Date.now||function(){return(new Date).getTime()};var B={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},T=m.invert(B),R=function(n){var t=function(t){return n[t]},r="(?:"+m.keys(n).join("|")+")",e=RegExp(r),u=RegExp(r,"g");return function(n){return n=null==n?"":""+n,e.test(n)?n.replace(u,t):n}};m.escape=R(B),m.unescape=R(T),m.result=function(n,t,r){var e=null==n?void 0:n[t];return e===void 0&&(e=r),m.isFunction(e)?e.call(n):e};var q=0;m.uniqueId=function(n){var t=++q+"";return n?n+t:t},m.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var K=/(.)^/,z={"'":"'","\\":"\\","\r":"r","\n":"n","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\u2028|\u2029/g,L=function(n){return"\\"+z[n]};m.template=function(n,t,r){!t&&r&&(t=r),t=m.defaults({},t,m.templateSettings);var e=RegExp([(t.escape||K).source,(t.interpolate||K).source,(t.evaluate||K).source].join("|")+"|$","g"),u=0,i="__p+='";n.replace(e,function(t,r,e,o,a){return i+=n.slice(u,a).replace(D,L),u=a+t.length,r?i+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'":e?i+="'+\n((__t=("+e+"))==null?'':__t)+\n'":o&&(i+="';\n"+o+"\n__p+='"),t}),i+="';\n",t.variable||(i="with(obj||{}){\n"+i+"}\n"),i="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+i+"return __p;\n";try{var o=new Function(t.variable||"obj","_",i)}catch(a){throw a.source=i,a}var c=function(n){return o.call(this,n,m)},f=t.variable||"obj";return c.source="function("+f+"){\n"+i+"}",c},m.chain=function(n){var t=m(n);return t._chain=!0,t};var P=function(n,t){return n._chain?m(t).chain():t};m.mixin=function(n){m.each(m.functions(n),function(t){var r=m[t]=n[t];m.prototype[t]=function(){var n=[this._wrapped];return f.apply(n,arguments),P(this,r.apply(m,n))}})},m.mixin(m),m.each(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=o[n];m.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!==n&&"splice"!==n||0!==r.length||delete r[0],P(this,r)}}),m.each(["concat","join","slice"],function(n){var t=o[n];m.prototype[n]=function(){return P(this,t.apply(this._wrapped,arguments))}}),m.prototype.value=function(){return this._wrapped},m.prototype.valueOf=m.prototype.toJSON=m.prototype.value,m.prototype.toString=function(){return""+this._wrapped},"function"==typeof define&&define.amd&&define("underscore",[],function(){return m})}).call(this);
  31801. //# sourceMappingURL=underscore-min.map;
  31802. // CodeMirror, copyright (c) by Marijn Haverbeke and others
  31803. // Distributed under an MIT license: http://codemirror.net/LICENSE
  31804. (function(mod) {
  31805. if (typeof exports == "object" && typeof module == "object") // CommonJS
  31806. mod(require("../lib/codemirror"));
  31807. else if (typeof define == "function" && define.amd) // AMD
  31808. define('codemirror/mode/meta',["../lib/codemirror"], mod);
  31809. else // Plain browser env
  31810. mod(CodeMirror);
  31811. })(function(CodeMirror) {
  31812. "use strict";
  31813. CodeMirror.modeInfo = [
  31814. {name: "APL", mime: "text/apl", mode: "apl", ext: ["dyalog", "apl"]},
  31815. {name: "PGP", mimes: ["application/pgp", "application/pgp-encrypted", "application/pgp-keys", "application/pgp-signature"], mode: "asciiarmor", ext: ["asc", "pgp", "sig"]},
  31816. {name: "ASN.1", mime: "text/x-ttcn-asn", mode: "asn.1", ext: ["asn", "asn1"]},
  31817. {name: "Asterisk", mime: "text/x-asterisk", mode: "asterisk", file: /^extensions\.conf$/i},
  31818. {name: "Brainfuck", mime: "text/x-brainfuck", mode: "brainfuck", ext: ["b", "bf"]},
  31819. {name: "C", mime: "text/x-csrc", mode: "clike", ext: ["c", "h", "ino"]},
  31820. {name: "C++", mime: "text/x-c++src", mode: "clike", ext: ["cpp", "c++", "cc", "cxx", "hpp", "h++", "hh", "hxx"], alias: ["cpp"]},
  31821. {name: "Cobol", mime: "text/x-cobol", mode: "cobol", ext: ["cob", "cpy"]},
  31822. {name: "C#", mime: "text/x-csharp", mode: "clike", ext: ["cs"], alias: ["csharp"]},
  31823. {name: "Clojure", mime: "text/x-clojure", mode: "clojure", ext: ["clj", "cljc", "cljx"]},
  31824. {name: "ClojureScript", mime: "text/x-clojurescript", mode: "clojure", ext: ["cljs"]},
  31825. {name: "Closure Stylesheets (GSS)", mime: "text/x-gss", mode: "css", ext: ["gss"]},
  31826. {name: "CMake", mime: "text/x-cmake", mode: "cmake", ext: ["cmake", "cmake.in"], file: /^CMakeLists.txt$/},
  31827. {name: "CoffeeScript", mimes: ["application/vnd.coffeescript", "text/coffeescript", "text/x-coffeescript"], mode: "coffeescript", ext: ["coffee"], alias: ["coffee", "coffee-script"]},
  31828. {name: "Common Lisp", mime: "text/x-common-lisp", mode: "commonlisp", ext: ["cl", "lisp", "el"], alias: ["lisp"]},
  31829. {name: "Cypher", mime: "application/x-cypher-query", mode: "cypher", ext: ["cyp", "cypher"]},
  31830. {name: "Cython", mime: "text/x-cython", mode: "python", ext: ["pyx", "pxd", "pxi"]},
  31831. {name: "Crystal", mime: "text/x-crystal", mode: "crystal", ext: ["cr"]},
  31832. {name: "CSS", mime: "text/css", mode: "css", ext: ["css"]},
  31833. {name: "CQL", mime: "text/x-cassandra", mode: "sql", ext: ["cql"]},
  31834. {name: "D", mime: "text/x-d", mode: "d", ext: ["d"]},
  31835. {name: "Dart", mimes: ["application/dart", "text/x-dart"], mode: "dart", ext: ["dart"]},
  31836. {name: "diff", mime: "text/x-diff", mode: "diff", ext: ["diff", "patch"]},
  31837. {name: "Django", mime: "text/x-django", mode: "django"},
  31838. {name: "Dockerfile", mime: "text/x-dockerfile", mode: "dockerfile", file: /^Dockerfile$/},
  31839. {name: "DTD", mime: "application/xml-dtd", mode: "dtd", ext: ["dtd"]},
  31840. {name: "Dylan", mime: "text/x-dylan", mode: "dylan", ext: ["dylan", "dyl", "intr"]},
  31841. {name: "EBNF", mime: "text/x-ebnf", mode: "ebnf"},
  31842. {name: "ECL", mime: "text/x-ecl", mode: "ecl", ext: ["ecl"]},
  31843. {name: "edn", mime: "application/edn", mode: "clojure", ext: ["edn"]},
  31844. {name: "Eiffel", mime: "text/x-eiffel", mode: "eiffel", ext: ["e"]},
  31845. {name: "Elm", mime: "text/x-elm", mode: "elm", ext: ["elm"]},
  31846. {name: "Embedded Javascript", mime: "application/x-ejs", mode: "htmlembedded", ext: ["ejs"]},
  31847. {name: "Embedded Ruby", mime: "application/x-erb", mode: "htmlembedded", ext: ["erb"]},
  31848. {name: "Erlang", mime: "text/x-erlang", mode: "erlang", ext: ["erl"]},
  31849. {name: "Esper", mime: "text/x-esper", mode: "sql"},
  31850. {name: "Factor", mime: "text/x-factor", mode: "factor", ext: ["factor"]},
  31851. {name: "FCL", mime: "text/x-fcl", mode: "fcl"},
  31852. {name: "Forth", mime: "text/x-forth", mode: "forth", ext: ["forth", "fth", "4th"]},
  31853. {name: "Fortran", mime: "text/x-fortran", mode: "fortran", ext: ["f", "for", "f77", "f90"]},
  31854. {name: "F#", mime: "text/x-fsharp", mode: "mllike", ext: ["fs"], alias: ["fsharp"]},
  31855. {name: "Gas", mime: "text/x-gas", mode: "gas", ext: ["s"]},
  31856. {name: "Gherkin", mime: "text/x-feature", mode: "gherkin", ext: ["feature"]},
  31857. {name: "GitHub Flavored Markdown", mime: "text/x-gfm", mode: "gfm", file: /^(readme|contributing|history).md$/i},
  31858. {name: "Go", mime: "text/x-go", mode: "go", ext: ["go"]},
  31859. {name: "Groovy", mime: "text/x-groovy", mode: "groovy", ext: ["groovy", "gradle"], file: /^Jenkinsfile$/},
  31860. {name: "HAML", mime: "text/x-haml", mode: "haml", ext: ["haml"]},
  31861. {name: "Haskell", mime: "text/x-haskell", mode: "haskell", ext: ["hs"]},
  31862. {name: "Haskell (Literate)", mime: "text/x-literate-haskell", mode: "haskell-literate", ext: ["lhs"]},
  31863. {name: "Haxe", mime: "text/x-haxe", mode: "haxe", ext: ["hx"]},
  31864. {name: "HXML", mime: "text/x-hxml", mode: "haxe", ext: ["hxml"]},
  31865. {name: "ASP.NET", mime: "application/x-aspx", mode: "htmlembedded", ext: ["aspx"], alias: ["asp", "aspx"]},
  31866. {name: "HTML", mime: "text/html", mode: "htmlmixed", ext: ["html", "htm", "handlebars", "hbs"], alias: ["xhtml"]},
  31867. {name: "HTTP", mime: "message/http", mode: "http"},
  31868. {name: "IDL", mime: "text/x-idl", mode: "idl", ext: ["pro"]},
  31869. {name: "Pug", mime: "text/x-pug", mode: "pug", ext: ["jade", "pug"], alias: ["jade"]},
  31870. {name: "Java", mime: "text/x-java", mode: "clike", ext: ["java"]},
  31871. {name: "Java Server Pages", mime: "application/x-jsp", mode: "htmlembedded", ext: ["jsp"], alias: ["jsp"]},
  31872. {name: "JavaScript", mimes: ["text/javascript", "text/ecmascript", "application/javascript", "application/x-javascript", "application/ecmascript"],
  31873. mode: "javascript", ext: ["js"], alias: ["ecmascript", "js", "node"]},
  31874. {name: "JSON", mimes: ["application/json", "application/x-json"], mode: "javascript", ext: ["json", "map"], alias: ["json5"]},
  31875. {name: "JSON-LD", mime: "application/ld+json", mode: "javascript", ext: ["jsonld"], alias: ["jsonld"]},
  31876. {name: "JSX", mime: "text/jsx", mode: "jsx", ext: ["jsx"]},
  31877. {name: "Jinja2", mime: "null", mode: "jinja2"},
  31878. {name: "Julia", mime: "text/x-julia", mode: "julia", ext: ["jl"]},
  31879. {name: "Kotlin", mime: "text/x-kotlin", mode: "clike", ext: ["kt"]},
  31880. {name: "LESS", mime: "text/x-less", mode: "css", ext: ["less"]},
  31881. {name: "LiveScript", mime: "text/x-livescript", mode: "livescript", ext: ["ls"], alias: ["ls"]},
  31882. {name: "Lua", mime: "text/x-lua", mode: "lua", ext: ["lua"]},
  31883. {name: "Markdown", mime: "text/x-markdown", mode: "markdown", ext: ["markdown", "md", "mkd"]},
  31884. {name: "mIRC", mime: "text/mirc", mode: "mirc"},
  31885. {name: "MariaDB SQL", mime: "text/x-mariadb", mode: "sql"},
  31886. {name: "Mathematica", mime: "text/x-mathematica", mode: "mathematica", ext: ["m", "nb"]},
  31887. {name: "Modelica", mime: "text/x-modelica", mode: "modelica", ext: ["mo"]},
  31888. {name: "MUMPS", mime: "text/x-mumps", mode: "mumps", ext: ["mps"]},
  31889. {name: "MS SQL", mime: "text/x-mssql", mode: "sql"},
  31890. {name: "mbox", mime: "application/mbox", mode: "mbox", ext: ["mbox"]},
  31891. {name: "MySQL", mime: "text/x-mysql", mode: "sql"},
  31892. {name: "Nginx", mime: "text/x-nginx-conf", mode: "nginx", file: /nginx.*\.conf$/i},
  31893. {name: "NSIS", mime: "text/x-nsis", mode: "nsis", ext: ["nsh", "nsi"]},
  31894. {name: "NTriples", mimes: ["application/n-triples", "application/n-quads", "text/n-triples"],
  31895. mode: "ntriples", ext: ["nt", "nq"]},
  31896. {name: "Objective-C", mime: "text/x-objectivec", mode: "clike", ext: ["m", "mm"], alias: ["objective-c", "objc"]},
  31897. {name: "OCaml", mime: "text/x-ocaml", mode: "mllike", ext: ["ml", "mli", "mll", "mly"]},
  31898. {name: "Octave", mime: "text/x-octave", mode: "octave", ext: ["m"]},
  31899. {name: "Oz", mime: "text/x-oz", mode: "oz", ext: ["oz"]},
  31900. {name: "Pascal", mime: "text/x-pascal", mode: "pascal", ext: ["p", "pas"]},
  31901. {name: "PEG.js", mime: "null", mode: "pegjs", ext: ["jsonld"]},
  31902. {name: "Perl", mime: "text/x-perl", mode: "perl", ext: ["pl", "pm"]},
  31903. {name: "PHP", mimes: ["text/x-php", "application/x-httpd-php", "application/x-httpd-php-open"], mode: "php", ext: ["php", "php3", "php4", "php5", "php7", "phtml"]},
  31904. {name: "Pig", mime: "text/x-pig", mode: "pig", ext: ["pig"]},
  31905. {name: "Plain Text", mime: "text/plain", mode: "null", ext: ["txt", "text", "conf", "def", "list", "log"]},
  31906. {name: "PLSQL", mime: "text/x-plsql", mode: "sql", ext: ["pls"]},
  31907. {name: "PowerShell", mime: "application/x-powershell", mode: "powershell", ext: ["ps1", "psd1", "psm1"]},
  31908. {name: "Properties files", mime: "text/x-properties", mode: "properties", ext: ["properties", "ini", "in"], alias: ["ini", "properties"]},
  31909. {name: "ProtoBuf", mime: "text/x-protobuf", mode: "protobuf", ext: ["proto"]},
  31910. {name: "Python", mime: "text/x-python", mode: "python", ext: ["BUILD", "bzl", "py", "pyw"], file: /^(BUCK|BUILD)$/},
  31911. {name: "Puppet", mime: "text/x-puppet", mode: "puppet", ext: ["pp"]},
  31912. {name: "Q", mime: "text/x-q", mode: "q", ext: ["q"]},
  31913. {name: "R", mime: "text/x-rsrc", mode: "r", ext: ["r", "R"], alias: ["rscript"]},
  31914. {name: "reStructuredText", mime: "text/x-rst", mode: "rst", ext: ["rst"], alias: ["rst"]},
  31915. {name: "RPM Changes", mime: "text/x-rpm-changes", mode: "rpm"},
  31916. {name: "RPM Spec", mime: "text/x-rpm-spec", mode: "rpm", ext: ["spec"]},
  31917. {name: "Ruby", mime: "text/x-ruby", mode: "ruby", ext: ["rb"], alias: ["jruby", "macruby", "rake", "rb", "rbx"]},
  31918. {name: "Rust", mime: "text/x-rustsrc", mode: "rust", ext: ["rs"]},
  31919. {name: "SAS", mime: "text/x-sas", mode: "sas", ext: ["sas"]},
  31920. {name: "Sass", mime: "text/x-sass", mode: "sass", ext: ["sass"]},
  31921. {name: "Scala", mime: "text/x-scala", mode: "clike", ext: ["scala"]},
  31922. {name: "Scheme", mime: "text/x-scheme", mode: "scheme", ext: ["scm", "ss"]},
  31923. {name: "SCSS", mime: "text/x-scss", mode: "css", ext: ["scss"]},
  31924. {name: "Shell", mimes: ["text/x-sh", "application/x-sh"], mode: "shell", ext: ["sh", "ksh", "bash"], alias: ["bash", "sh", "zsh"], file: /^PKGBUILD$/},
  31925. {name: "Sieve", mime: "application/sieve", mode: "sieve", ext: ["siv", "sieve"]},
  31926. {name: "Slim", mimes: ["text/x-slim", "application/x-slim"], mode: "slim", ext: ["slim"]},
  31927. {name: "Smalltalk", mime: "text/x-stsrc", mode: "smalltalk", ext: ["st"]},
  31928. {name: "Smarty", mime: "text/x-smarty", mode: "smarty", ext: ["tpl"]},
  31929. {name: "Solr", mime: "text/x-solr", mode: "solr"},
  31930. {name: "SML", mime: "text/x-sml", mode: "mllike", ext: ["sml", "sig", "fun", "smackspec"]},
  31931. {name: "Soy", mime: "text/x-soy", mode: "soy", ext: ["soy"], alias: ["closure template"]},
  31932. {name: "SPARQL", mime: "application/sparql-query", mode: "sparql", ext: ["rq", "sparql"], alias: ["sparul"]},
  31933. {name: "Spreadsheet", mime: "text/x-spreadsheet", mode: "spreadsheet", alias: ["excel", "formula"]},
  31934. {name: "SQL", mime: "text/x-sql", mode: "sql", ext: ["sql"]},
  31935. {name: "SQLite", mime: "text/x-sqlite", mode: "sql"},
  31936. {name: "Squirrel", mime: "text/x-squirrel", mode: "clike", ext: ["nut"]},
  31937. {name: "Stylus", mime: "text/x-styl", mode: "stylus", ext: ["styl"]},
  31938. {name: "Swift", mime: "text/x-swift", mode: "swift", ext: ["swift"]},
  31939. {name: "sTeX", mime: "text/x-stex", mode: "stex"},
  31940. {name: "LaTeX", mime: "text/x-latex", mode: "stex", ext: ["text", "ltx", "tex"], alias: ["tex"]},
  31941. {name: "SystemVerilog", mime: "text/x-systemverilog", mode: "verilog", ext: ["v", "sv", "svh"]},
  31942. {name: "Tcl", mime: "text/x-tcl", mode: "tcl", ext: ["tcl"]},
  31943. {name: "Textile", mime: "text/x-textile", mode: "textile", ext: ["textile"]},
  31944. {name: "TiddlyWiki ", mime: "text/x-tiddlywiki", mode: "tiddlywiki"},
  31945. {name: "Tiki wiki", mime: "text/tiki", mode: "tiki"},
  31946. {name: "TOML", mime: "text/x-toml", mode: "toml", ext: ["toml"]},
  31947. {name: "Tornado", mime: "text/x-tornado", mode: "tornado"},
  31948. {name: "troff", mime: "text/troff", mode: "troff", ext: ["1", "2", "3", "4", "5", "6", "7", "8", "9"]},
  31949. {name: "TTCN", mime: "text/x-ttcn", mode: "ttcn", ext: ["ttcn", "ttcn3", "ttcnpp"]},
  31950. {name: "TTCN_CFG", mime: "text/x-ttcn-cfg", mode: "ttcn-cfg", ext: ["cfg"]},
  31951. {name: "Turtle", mime: "text/turtle", mode: "turtle", ext: ["ttl"]},
  31952. {name: "TypeScript", mime: "application/typescript", mode: "javascript", ext: ["ts"], alias: ["ts"]},
  31953. {name: "TypeScript-JSX", mime: "text/typescript-jsx", mode: "jsx", ext: ["tsx"], alias: ["tsx"]},
  31954. {name: "Twig", mime: "text/x-twig", mode: "twig"},
  31955. {name: "Web IDL", mime: "text/x-webidl", mode: "webidl", ext: ["webidl"]},
  31956. {name: "VB.NET", mime: "text/x-vb", mode: "vb", ext: ["vb"]},
  31957. {name: "VBScript", mime: "text/vbscript", mode: "vbscript", ext: ["vbs"]},
  31958. {name: "Velocity", mime: "text/velocity", mode: "velocity", ext: ["vtl"]},
  31959. {name: "Verilog", mime: "text/x-verilog", mode: "verilog", ext: ["v"]},
  31960. {name: "VHDL", mime: "text/x-vhdl", mode: "vhdl", ext: ["vhd", "vhdl"]},
  31961. {name: "Vue.js Component", mimes: ["script/x-vue", "text/x-vue"], mode: "vue", ext: ["vue"]},
  31962. {name: "XML", mimes: ["application/xml", "text/xml"], mode: "xml", ext: ["xml", "xsl", "xsd", "svg"], alias: ["rss", "wsdl", "xsd"]},
  31963. {name: "XQuery", mime: "application/xquery", mode: "xquery", ext: ["xy", "xquery"]},
  31964. {name: "Yacas", mime: "text/x-yacas", mode: "yacas", ext: ["ys"]},
  31965. {name: "YAML", mimes: ["text/x-yaml", "text/yaml"], mode: "yaml", ext: ["yaml", "yml"], alias: ["yml"]},
  31966. {name: "Z80", mime: "text/x-z80", mode: "z80", ext: ["z80"]},
  31967. {name: "mscgen", mime: "text/x-mscgen", mode: "mscgen", ext: ["mscgen", "mscin", "msc"]},
  31968. {name: "xu", mime: "text/x-xu", mode: "mscgen", ext: ["xu"]},
  31969. {name: "msgenny", mime: "text/x-msgenny", mode: "mscgen", ext: ["msgenny"]}
  31970. ];
  31971. // Ensure all modes have a mime property for backwards compatibility
  31972. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  31973. var info = CodeMirror.modeInfo[i];
  31974. if (info.mimes) info.mime = info.mimes[0];
  31975. }
  31976. CodeMirror.findModeByMIME = function(mime) {
  31977. mime = mime.toLowerCase();
  31978. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  31979. var info = CodeMirror.modeInfo[i];
  31980. if (info.mime == mime) return info;
  31981. if (info.mimes) for (var j = 0; j < info.mimes.length; j++)
  31982. if (info.mimes[j] == mime) return info;
  31983. }
  31984. if (/\+xml$/.test(mime)) return CodeMirror.findModeByMIME("application/xml")
  31985. if (/\+json$/.test(mime)) return CodeMirror.findModeByMIME("application/json")
  31986. };
  31987. CodeMirror.findModeByExtension = function(ext) {
  31988. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  31989. var info = CodeMirror.modeInfo[i];
  31990. if (info.ext) for (var j = 0; j < info.ext.length; j++)
  31991. if (info.ext[j] == ext) return info;
  31992. }
  31993. };
  31994. CodeMirror.findModeByFileName = function(filename) {
  31995. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  31996. var info = CodeMirror.modeInfo[i];
  31997. if (info.file && info.file.test(filename)) return info;
  31998. }
  31999. var dot = filename.lastIndexOf(".");
  32000. var ext = dot > -1 && filename.substring(dot + 1, filename.length);
  32001. if (ext) return CodeMirror.findModeByExtension(ext);
  32002. };
  32003. CodeMirror.findModeByName = function(name) {
  32004. name = name.toLowerCase();
  32005. for (var i = 0; i < CodeMirror.modeInfo.length; i++) {
  32006. var info = CodeMirror.modeInfo[i];
  32007. if (info.name.toLowerCase() == name) return info;
  32008. if (info.alias) for (var j = 0; j < info.alias.length; j++)
  32009. if (info.alias[j].toLowerCase() == name) return info;
  32010. }
  32011. };
  32012. });
  32013. // Copyright (c) Jupyter Development Team.
  32014. // Distributed under the terms of the Modified BSD License.
  32015. define('base/js/utils',[
  32016. 'jquery',
  32017. 'codemirror/lib/codemirror',
  32018. 'moment',
  32019. 'underscore',
  32020. // silently upgrades CodeMirror
  32021. 'codemirror/mode/meta',
  32022. ], function($, CodeMirror, moment, _){
  32023. "use strict";
  32024. // keep track of which extensions have been loaded already
  32025. var extensions_loaded = [];
  32026. /**
  32027. * Whether or not an extension has been loaded
  32028. * @param {string} extension - name of the extension
  32029. * @return {boolean} true if loaded already
  32030. */
  32031. var is_loaded = function(extension) {
  32032. var ext_path = "nbextensions/" + extension;
  32033. return extensions_loaded.indexOf(ext_path) >= 0;
  32034. };
  32035. /**
  32036. * Load a single extension.
  32037. * @param {string} extension - extension path.
  32038. * @return {Promise} that resolves to an extension module handle
  32039. */
  32040. var load_extension = function (extension) {
  32041. return new Promise(function(resolve, reject) {
  32042. var ext_path = "nbextensions/" + extension;
  32043. requirejs([ext_path], function(module) {
  32044. if (!is_loaded(extension)) {
  32045. console.log("Loading extension: " + extension);
  32046. if (module && module.load_ipython_extension) {
  32047. Promise.resolve(module.load_ipython_extension()).then(function() {
  32048. resolve(module);
  32049. }).catch(reject);
  32050. }
  32051. extensions_loaded.push(ext_path);
  32052. } else {
  32053. console.log("Loaded extension already: " + extension);
  32054. resolve(module);
  32055. }
  32056. }, function(err) {
  32057. reject(err);
  32058. });
  32059. });
  32060. };
  32061. /**
  32062. * Load multiple extensions.
  32063. * Takes n-args, where each arg is a string path to the extension.
  32064. * @return {Promise} that resolves to a list of loaded module handles.
  32065. */
  32066. var load_extensions = function () {
  32067. console.log('load_extensions', arguments);
  32068. return Promise.all(Array.prototype.map.call(arguments, load_extension)).catch(function(err) {
  32069. console.error("Failed to load extension" + (err.requireModules.length>1?'s':'') + ":", err.requireModules, err);
  32070. });
  32071. };
  32072. /**
  32073. * Return a list of extensions that should be active
  32074. * The config for nbextensions comes in as a dict where keys are
  32075. * nbextensions paths and the values are a bool indicating if it
  32076. * should be active. This returns a list of nbextension paths
  32077. * where the value is true
  32078. */
  32079. function filter_extensions(nbext_config) {
  32080. var active = [];
  32081. Object.keys(nbext_config).forEach(function (nbext) {
  32082. if (nbext_config[nbext]) {active.push(nbext);}
  32083. });
  32084. return active;
  32085. }
  32086. /**
  32087. * Wait for a config section to load, and then load the extensions specified
  32088. * in a 'load_extensions' key inside it.
  32089. */
  32090. function load_extensions_from_config(section) {
  32091. return section.loaded.then(function() {
  32092. if (section.data.load_extensions) {
  32093. var active = filter_extensions(section.data.load_extensions);
  32094. return load_extensions.apply(this, active);
  32095. }
  32096. }).catch(utils.reject('Could not load nbextensions from ' + section.section_name + ' config file'));
  32097. }
  32098. //============================================================================
  32099. // Cross-browser RegEx Split
  32100. //============================================================================
  32101. // This code has been MODIFIED from the code licensed below to not replace the
  32102. // default browser split. The license is reproduced here.
  32103. // see http://blog.stevenlevithan.com/archives/cross-browser-split for more info:
  32104. /*!
  32105. * Cross-Browser Split 1.1.1
  32106. * Copyright 2007-2012 Steven Levithan <stevenlevithan.com>
  32107. * Available under the MIT License
  32108. * ECMAScript compliant, uniform cross-browser split method
  32109. */
  32110. /**
  32111. * Splits a string into an array of strings using a regex or string
  32112. * separator. Matches of the separator are not included in the result array.
  32113. * However, if `separator` is a regex that contains capturing groups,
  32114. * backreferences are spliced into the result each time `separator` is
  32115. * matched. Fixes browser bugs compared to the native
  32116. * `String.prototype.split` and can be used reliably cross-browser.
  32117. * @param {String} str String to split.
  32118. * @param {RegExp} separator Regex to use for separating
  32119. * the string.
  32120. * @param {Number} [limit] Maximum number of items to include in the result
  32121. * array.
  32122. * @returns {Array} Array of substrings.
  32123. * @example
  32124. *
  32125. * // Basic use
  32126. * regex_split('a b c d', ' ');
  32127. * // -> ['a', 'b', 'c', 'd']
  32128. *
  32129. * // With limit
  32130. * regex_split('a b c d', ' ', 2);
  32131. * // -> ['a', 'b']
  32132. *
  32133. * // Backreferences in result array
  32134. * regex_split('..word1 word2..', /([a-z]+)(\d+)/i);
  32135. * // -> ['..', 'word', '1', ' ', 'word', '2', '..']
  32136. */
  32137. var regex_split = function (str, separator, limit) {
  32138. var output = [],
  32139. flags = (separator.ignoreCase ? "i" : "") +
  32140. (separator.multiline ? "m" : "") +
  32141. (separator.extended ? "x" : "") + // Proposed for ES6
  32142. (separator.sticky ? "y" : ""), // Firefox 3+
  32143. lastLastIndex = 0,
  32144. separator2, match, lastIndex, lastLength;
  32145. // Make `global` and avoid `lastIndex` issues by working with a copy
  32146. separator = new RegExp(separator.source, flags + "g");
  32147. var compliantExecNpcg = typeof(/()??/.exec("")[1]) === "undefined";
  32148. if (!compliantExecNpcg) {
  32149. // Doesn't need flags gy, but they don't hurt
  32150. separator2 = new RegExp("^" + separator.source + "$(?!\\s)", flags);
  32151. }
  32152. /* Values for `limit`, per the spec:
  32153. * If undefined: 4294967295 // Math.pow(2, 32) - 1
  32154. * If 0, Infinity, or NaN: 0
  32155. * If positive number: limit = Math.floor(limit); if (limit > 4294967295) limit -= 4294967296;
  32156. * If negative number: 4294967296 - Math.floor(Math.abs(limit))
  32157. * If other: Type-convert, then use the above rules
  32158. */
  32159. limit = typeof(limit) === "undefined" ?
  32160. -1 >>> 0 : // Math.pow(2, 32) - 1
  32161. limit >>> 0; // ToUint32(limit)
  32162. for (match = separator.exec(str); match; match = separator.exec(str)) {
  32163. // `separator.lastIndex` is not reliable cross-browser
  32164. lastIndex = match.index + match[0].length;
  32165. if (lastIndex > lastLastIndex) {
  32166. output.push(str.slice(lastLastIndex, match.index));
  32167. // Fix browsers whose `exec` methods don't consistently return `undefined` for
  32168. // nonparticipating capturing groups
  32169. if (!compliantExecNpcg && match.length > 1) {
  32170. match[0].replace(separator2, function () {
  32171. for (var i = 1; i < arguments.length - 2; i++) {
  32172. if (typeof(arguments[i]) === "undefined") {
  32173. match[i] = undefined;
  32174. }
  32175. }
  32176. });
  32177. }
  32178. if (match.length > 1 && match.index < str.length) {
  32179. Array.prototype.push.apply(output, match.slice(1));
  32180. }
  32181. lastLength = match[0].length;
  32182. lastLastIndex = lastIndex;
  32183. if (output.length >= limit) {
  32184. break;
  32185. }
  32186. }
  32187. if (separator.lastIndex === match.index) {
  32188. separator.lastIndex++; // Avoid an infinite loop
  32189. }
  32190. }
  32191. if (lastLastIndex === str.length) {
  32192. if (lastLength || !separator.test("")) {
  32193. output.push("");
  32194. }
  32195. } else {
  32196. output.push(str.slice(lastLastIndex));
  32197. }
  32198. return output.length > limit ? output.slice(0, limit) : output;
  32199. };
  32200. //============================================================================
  32201. // End contributed Cross-browser RegEx Split
  32202. //============================================================================
  32203. var uuid = function () {
  32204. /**
  32205. * http://www.ietf.org/rfc/rfc4122.txt
  32206. */
  32207. var s = [];
  32208. var hexDigits = "0123456789abcdef";
  32209. for (var i = 0; i < 32; i++) {
  32210. s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
  32211. }
  32212. s[12] = "4"; // bits 12-15 of the time_hi_and_version field to 0010
  32213. s[16] = hexDigits.substr((s[16] & 0x3) | 0x8, 1); // bits 6-7 of the clock_seq_hi_and_reserved to 01
  32214. var uuid = s.join("");
  32215. return uuid;
  32216. };
  32217. var _ANSI_COLORS = [
  32218. "ansi-black",
  32219. "ansi-red",
  32220. "ansi-green",
  32221. "ansi-yellow",
  32222. "ansi-blue",
  32223. "ansi-magenta",
  32224. "ansi-cyan",
  32225. "ansi-white",
  32226. "ansi-black-intense",
  32227. "ansi-red-intense",
  32228. "ansi-green-intense",
  32229. "ansi-yellow-intense",
  32230. "ansi-blue-intense",
  32231. "ansi-magenta-intense",
  32232. "ansi-cyan-intense",
  32233. "ansi-white-intense",
  32234. ];
  32235. function _pushColoredChunk(chunk, fg, bg, bold, underline, inverse, out) {
  32236. if (chunk) {
  32237. var classes = [];
  32238. var styles = [];
  32239. if (bold && typeof fg === "number" && 0 <= fg && fg < 8) {
  32240. fg += 8; // Bold text uses "intense" colors
  32241. }
  32242. if (inverse) {
  32243. [fg, bg] = [bg, fg];
  32244. }
  32245. if (typeof fg === "number") {
  32246. classes.push(_ANSI_COLORS[fg] + "-fg");
  32247. } else if (fg.length) {
  32248. styles.push("color: rgb(" + fg + ")");
  32249. } else if (inverse) {
  32250. classes.push("ansi-default-inverse-fg");
  32251. }
  32252. if (typeof bg === "number") {
  32253. classes.push(_ANSI_COLORS[bg] + "-bg");
  32254. } else if (bg.length) {
  32255. styles.push("background-color: rgb(" + bg + ")");
  32256. } else if (inverse) {
  32257. classes.push("ansi-default-inverse-bg");
  32258. }
  32259. if (bold) {
  32260. classes.push("ansi-bold");
  32261. }
  32262. if (underline) {
  32263. classes.push("ansi-underline");
  32264. }
  32265. if (classes.length || styles.length) {
  32266. out.push("<span");
  32267. if (classes.length) {
  32268. out.push(' class="' + classes.join(" ") + '"');
  32269. }
  32270. if (styles.length) {
  32271. out.push(' style="' + styles.join("; ") + '"');
  32272. }
  32273. out.push(">");
  32274. out.push(chunk);
  32275. out.push("</span>");
  32276. } else {
  32277. out.push(chunk);
  32278. }
  32279. }
  32280. }
  32281. function _getExtendedColors(numbers) {
  32282. var r, g, b;
  32283. var n = numbers.shift();
  32284. if (n === 2 && numbers.length >= 3) {
  32285. // 24-bit RGB
  32286. r = numbers.shift();
  32287. g = numbers.shift();
  32288. b = numbers.shift();
  32289. if ([r, g, b].some(function (c) { return c < 0 || 255 < c; })) {
  32290. throw new RangeError("Invalid range for RGB colors");
  32291. }
  32292. } else if (n === 5 && numbers.length >= 1) {
  32293. // 256 colors
  32294. var idx = numbers.shift();
  32295. if (idx < 0) {
  32296. throw new RangeError("Color index must be >= 0");
  32297. } else if (idx < 16) {
  32298. // 16 default terminal colors
  32299. return idx;
  32300. } else if (idx < 232) {
  32301. // 6x6x6 color cube, see https://stackoverflow.com/a/27165165/500098
  32302. r = Math.floor((idx - 16) / 36);
  32303. r = r > 0 ? 55 + r * 40 : 0;
  32304. g = Math.floor(((idx - 16) % 36) / 6);
  32305. g = g > 0 ? 55 + g * 40 : 0;
  32306. b = (idx - 16) % 6;
  32307. b = b > 0 ? 55 + b * 40 : 0;
  32308. } else if (idx < 256) {
  32309. // grayscale, see https://stackoverflow.com/a/27165165/500098
  32310. r = g = b = (idx - 232) * 10 + 8;
  32311. } else {
  32312. throw new RangeError("Color index must be < 256");
  32313. }
  32314. } else {
  32315. throw new RangeError("Invalid extended color specification");
  32316. }
  32317. return [r, g, b];
  32318. }
  32319. function _ansispan(str) {
  32320. var ansi_re = /\x1b\[(.*?)([@-~])/g;
  32321. var fg = [];
  32322. var bg = [];
  32323. var bold = false;
  32324. var underline = false;
  32325. var inverse = false;
  32326. var match;
  32327. var out = [];
  32328. var numbers = [];
  32329. var start = 0;
  32330. str += "\x1b[m"; // Ensure markup for trailing text
  32331. while ((match = ansi_re.exec(str))) {
  32332. if (match[2] === "m") {
  32333. var items = match[1].split(";");
  32334. for (var i = 0; i < items.length; i++) {
  32335. var item = items[i];
  32336. if (item === "") {
  32337. numbers.push(0);
  32338. } else if (item.search(/^\d+$/) !== -1) {
  32339. numbers.push(parseInt(item));
  32340. } else {
  32341. // Ignored: Invalid color specification
  32342. numbers.length = 0;
  32343. break;
  32344. }
  32345. }
  32346. } else {
  32347. // Ignored: Not a color code
  32348. }
  32349. var chunk = str.substring(start, match.index);
  32350. _pushColoredChunk(chunk, fg, bg, bold, underline, inverse, out);
  32351. start = ansi_re.lastIndex;
  32352. while (numbers.length) {
  32353. var n = numbers.shift();
  32354. switch (n) {
  32355. case 0:
  32356. fg = bg = [];
  32357. bold = false;
  32358. underline = false;
  32359. inverse = false;
  32360. break;
  32361. case 1:
  32362. case 5:
  32363. bold = true;
  32364. break;
  32365. case 4:
  32366. underline = true;
  32367. break;
  32368. case 7:
  32369. inverse = true;
  32370. break;
  32371. case 21:
  32372. case 22:
  32373. bold = false;
  32374. break;
  32375. case 24:
  32376. underline = false;
  32377. break;
  32378. case 27:
  32379. inverse = false;
  32380. break;
  32381. case 30:
  32382. case 31:
  32383. case 32:
  32384. case 33:
  32385. case 34:
  32386. case 35:
  32387. case 36:
  32388. case 37:
  32389. fg = n - 30;
  32390. break;
  32391. case 38:
  32392. try {
  32393. fg = _getExtendedColors(numbers);
  32394. } catch(e) {
  32395. numbers.length = 0;
  32396. }
  32397. break;
  32398. case 39:
  32399. fg = [];
  32400. break;
  32401. case 40:
  32402. case 41:
  32403. case 42:
  32404. case 43:
  32405. case 44:
  32406. case 45:
  32407. case 46:
  32408. case 47:
  32409. bg = n - 40;
  32410. break;
  32411. case 48:
  32412. try {
  32413. bg = _getExtendedColors(numbers);
  32414. } catch(e) {
  32415. numbers.length = 0;
  32416. }
  32417. break;
  32418. case 49:
  32419. bg = [];
  32420. break;
  32421. case 90:
  32422. case 91:
  32423. case 92:
  32424. case 93:
  32425. case 94:
  32426. case 95:
  32427. case 96:
  32428. case 97:
  32429. fg = n - 90 + 8;
  32430. break;
  32431. case 100:
  32432. case 101:
  32433. case 102:
  32434. case 103:
  32435. case 104:
  32436. case 105:
  32437. case 106:
  32438. case 107:
  32439. bg = n - 100 + 8;
  32440. break;
  32441. default:
  32442. // Unknown codes are ignored
  32443. }
  32444. }
  32445. }
  32446. return out.join("");
  32447. }
  32448. // Transform ANSI color escape codes into HTML <span> tags with CSS
  32449. // classes such as "ansi-green-intense-fg".
  32450. // The actual colors used are set in the CSS file.
  32451. // This is supposed to have the same behavior as nbconvert.filters.ansi2html()
  32452. function fixConsole(txt) {
  32453. txt = _.escape(txt);
  32454. // color ansi codes (and remove non-color escape sequences)
  32455. txt = _ansispan(txt);
  32456. return txt;
  32457. }
  32458. // Remove chunks that should be overridden by the effect of
  32459. // carriage return characters
  32460. function fixCarriageReturn(txt) {
  32461. txt = txt.replace(/\r+\n/gm, '\n'); // \r followed by \n --> newline
  32462. while (txt.search(/\r[^$]/g) > -1) {
  32463. var base = txt.match(/^(.*)\r+/m)[1];
  32464. var insert = txt.match(/\r+(.*)$/m)[1];
  32465. insert = insert + base.slice(insert.length, base.length);
  32466. txt = txt.replace(/\r+.*$/m, '\r').replace(/^.*\r/m, insert);
  32467. }
  32468. return txt;
  32469. }
  32470. // Remove characters that are overridden by backspace characters
  32471. function fixBackspace(txt) {
  32472. var tmp = txt;
  32473. do {
  32474. txt = tmp;
  32475. // Cancel out anything-but-newline followed by backspace
  32476. tmp = txt.replace(/[^\n]\x08/gm, '');
  32477. } while (tmp.length < txt.length);
  32478. return txt;
  32479. }
  32480. // Remove characters overridden by backspace and carriage return
  32481. function fixOverwrittenChars(txt) {
  32482. return fixCarriageReturn(fixBackspace(txt));
  32483. }
  32484. // Locate any URLs and convert them to an anchor tag
  32485. function autoLinkUrls(txt) {
  32486. return txt.replace(/(^|\s)(https?|ftp)(:[^'"<>\s]+)/gi,
  32487. "$1<a target=\"_blank\" href=\"$2$3\">$2$3</a>");
  32488. }
  32489. var points_to_pixels = function (points) {
  32490. /**
  32491. * A reasonably good way of converting between points and pixels.
  32492. */
  32493. var test = $('<div style="display: none; width: 10000pt; padding:0; border:0;"></div>');
  32494. $('body').append(test);
  32495. var pixel_per_point = test.width()/10000;
  32496. test.remove();
  32497. return Math.floor(points*pixel_per_point);
  32498. };
  32499. var always_new = function (constructor) {
  32500. /**
  32501. * wrapper around contructor to avoid requiring `var a = new constructor()`
  32502. * useful for passing constructors as callbacks,
  32503. * not for programmer laziness.
  32504. * from https://programmers.stackexchange.com/questions/118798
  32505. */
  32506. return function () {
  32507. var obj = Object.create(constructor.prototype);
  32508. constructor.apply(obj, arguments);
  32509. return obj;
  32510. };
  32511. };
  32512. var url_path_join = function () {
  32513. /**
  32514. * join a sequence of url components with '/'
  32515. */
  32516. var url = '';
  32517. for (var i = 0; i < arguments.length; i++) {
  32518. if (arguments[i] === '') {
  32519. continue;
  32520. }
  32521. if (url.length > 0 && url[url.length-1] != '/') {
  32522. url = url + '/' + arguments[i];
  32523. } else {
  32524. url = url + arguments[i];
  32525. }
  32526. }
  32527. url = url.replace(/\/\/+/, '/');
  32528. return url;
  32529. };
  32530. var url_path_split = function (path) {
  32531. /**
  32532. * Like os.path.split for URLs.
  32533. * Always returns two strings, the directory path and the base filename
  32534. */
  32535. var idx = path.lastIndexOf('/');
  32536. if (idx === -1) {
  32537. return ['', path];
  32538. } else {
  32539. return [ path.slice(0, idx), path.slice(idx + 1) ];
  32540. }
  32541. };
  32542. var parse_url = function (url) {
  32543. /**
  32544. * an `a` element with an href allows attr-access to the parsed segments of a URL
  32545. * a = parse_url("http://localhost:8888/path/name#hash")
  32546. * a.protocol = "http:"
  32547. * a.host = "localhost:8888"
  32548. * a.hostname = "localhost"
  32549. * a.port = 8888
  32550. * a.pathname = "/path/name"
  32551. * a.hash = "#hash"
  32552. */
  32553. var a = document.createElement("a");
  32554. a.href = url;
  32555. return a;
  32556. };
  32557. var encode_uri_components = function (uri) {
  32558. /**
  32559. * encode just the components of a multi-segment uri,
  32560. * leaving '/' separators
  32561. */
  32562. return uri.split('/').map(encodeURIComponent).join('/');
  32563. };
  32564. var url_join_encode = function () {
  32565. /**
  32566. * join a sequence of url components with '/',
  32567. * encoding each component with encodeURIComponent
  32568. */
  32569. return encode_uri_components(url_path_join.apply(null, arguments));
  32570. };
  32571. var splitext = function (filename) {
  32572. /**
  32573. * mimic Python os.path.splitext
  32574. * Returns ['base', '.ext']
  32575. */
  32576. var idx = filename.lastIndexOf('.');
  32577. if (idx > 0) {
  32578. return [filename.slice(0, idx), filename.slice(idx)];
  32579. } else {
  32580. return [filename, ''];
  32581. }
  32582. };
  32583. var escape_html = function (text) {
  32584. /**
  32585. * escape text to HTML
  32586. */
  32587. return $("<div/>").text(text).html();
  32588. };
  32589. var get_body_data = function(key) {
  32590. /**
  32591. * get a url-encoded item from body.data and decode it
  32592. * we should never have any encoded URLs anywhere else in code
  32593. * until we are building an actual request
  32594. */
  32595. var val = $('body').data(key);
  32596. if (typeof val === 'undefined')
  32597. return val;
  32598. return decodeURIComponent(val);
  32599. };
  32600. var to_absolute_cursor_pos = function (cm, cursor) {
  32601. console.warn('`utils.to_absolute_cursor_pos(cm, pos)` is deprecated. Use `cm.indexFromPos(cursor)`');
  32602. return cm.indexFromPos(cursor);
  32603. };
  32604. var from_absolute_cursor_pos = function (cm, cursor_pos) {
  32605. console.warn('`utils.from_absolute_cursor_pos(cm, pos)` is deprecated. Use `cm.posFromIndex(index)`');
  32606. return cm.posFromIndex(cursor_pos);
  32607. };
  32608. // https://stackoverflow.com/questions/2400935/browser-detection-in-javascript
  32609. var browser = (function() {
  32610. if (typeof navigator === 'undefined') {
  32611. // navigator undefined in node
  32612. return 'None';
  32613. }
  32614. var N= navigator.appName, ua= navigator.userAgent, tem;
  32615. var M= ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
  32616. if (M && (tem= ua.match(/version\/([\.\d]+)/i)) !== null) M[2]= tem[1];
  32617. M= M? [M[1], M[2]]: [N, navigator.appVersion,'-?'];
  32618. return M;
  32619. })();
  32620. // https://stackoverflow.com/questions/11219582/how-to-detect-my-browser-version-and-operating-system-using-javascript
  32621. var platform = (function () {
  32622. if (typeof navigator === 'undefined') {
  32623. // navigator undefined in node
  32624. return 'None';
  32625. }
  32626. var OSName="None";
  32627. if (navigator.appVersion.indexOf("Win")!=-1) OSName="Windows";
  32628. if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";
  32629. if (navigator.appVersion.indexOf("X11")!=-1) OSName="UNIX";
  32630. if (navigator.appVersion.indexOf("Linux")!=-1) OSName="Linux";
  32631. return OSName;
  32632. })();
  32633. var get_url_param = function (name) {
  32634. // get a URL parameter. I cannot believe we actually need this.
  32635. // Based on https://stackoverflow.com/a/25359264/938949
  32636. var match = new RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
  32637. if (match){
  32638. return decodeURIComponent(match[1] || '');
  32639. }
  32640. };
  32641. var is_or_has = function (a, b) {
  32642. /**
  32643. * Is b a child of a or a itself?
  32644. */
  32645. return a.has(b).length !==0 || a.is(b);
  32646. };
  32647. var is_focused = function (e) {
  32648. /**
  32649. * Is element e, or one of its children focused?
  32650. */
  32651. e = $(e);
  32652. var target = $(document.activeElement);
  32653. if (target.length > 0) {
  32654. if (is_or_has(e, target)) {
  32655. return true;
  32656. } else {
  32657. return false;
  32658. }
  32659. } else {
  32660. return false;
  32661. }
  32662. };
  32663. var mergeopt = function(_class, options, overwrite){
  32664. options = options || {};
  32665. overwrite = overwrite || {};
  32666. return $.extend(true, {}, _class.options_default, options, overwrite);
  32667. };
  32668. var ajax_error_msg = function (jqXHR) {
  32669. /**
  32670. * Return a JSON error message if there is one,
  32671. * otherwise the basic HTTP status text.
  32672. */
  32673. if (jqXHR.responseJSON && jqXHR.responseJSON.traceback) {
  32674. return jqXHR.responseJSON.traceback;
  32675. } else if (jqXHR.responseJSON && jqXHR.responseJSON.message) {
  32676. return jqXHR.responseJSON.message;
  32677. } else {
  32678. return jqXHR.statusText;
  32679. }
  32680. };
  32681. var log_ajax_error = function (jqXHR, status, error) {
  32682. /**
  32683. * log ajax failures with informative messages
  32684. */
  32685. var msg = "API request failed (" + jqXHR.status + "): ";
  32686. console.log(jqXHR);
  32687. msg += ajax_error_msg(jqXHR);
  32688. console.log(msg);
  32689. };
  32690. var requireCodeMirrorMode = function (mode, callback, errback) {
  32691. /**
  32692. * find a predefined mode or detect from CM metadata then
  32693. * require and callback with the resolveable mode string: mime or
  32694. * custom name
  32695. */
  32696. var modename = (typeof mode == "string") ? mode :
  32697. mode.mode || mode.name;
  32698. // simplest, cheapest check by mode name: mode may also have config
  32699. if (CodeMirror.modes.hasOwnProperty(modename)) {
  32700. // return the full mode object, if it has a name
  32701. callback(mode.name ? mode : modename);
  32702. return;
  32703. }
  32704. // *somehow* get back a CM.modeInfo-like object that has .mode and
  32705. // .mime
  32706. var info = (mode && mode.mode && mode.mime && mode) ||
  32707. CodeMirror.findModeByName(modename) ||
  32708. CodeMirror.findModeByExtension(modename.split(".").slice(-1)) ||
  32709. CodeMirror.findModeByMIME(modename) ||
  32710. {mode: modename, mime: modename};
  32711. requirejs([
  32712. // might want to use CodeMirror.modeURL here
  32713. ['codemirror/mode', info.mode, info.mode].join('/'),
  32714. ], function() {
  32715. // return the original mode, as from a kernelspec on first load
  32716. // or the mimetype, as for most highlighting
  32717. callback(mode.name ? mode : info.mime);
  32718. }, errback
  32719. );
  32720. };
  32721. /** Error type for wrapped XHR errors. */
  32722. var XHR_ERROR = 'XhrError';
  32723. /**
  32724. * Wraps an AJAX error as an Error object.
  32725. */
  32726. var wrap_ajax_error = function (jqXHR, status, error) {
  32727. var wrapped_error = new Error(ajax_error_msg(jqXHR));
  32728. wrapped_error.name = XHR_ERROR;
  32729. // provide xhr response
  32730. wrapped_error.xhr = jqXHR;
  32731. wrapped_error.xhr_status = status;
  32732. wrapped_error.xhr_error = error;
  32733. return wrapped_error;
  32734. };
  32735. var ajax = function (url, settings) {
  32736. // like $.ajax, but ensure XSRF or Authorization header is set
  32737. if (typeof url === "object") {
  32738. // called with single argument: $.ajax({url: '...'})
  32739. settings = url;
  32740. url = settings.url;
  32741. delete settings.url;
  32742. }
  32743. settings = _add_auth_header(settings);
  32744. return $.ajax(url, settings);
  32745. };
  32746. var _get_cookie = function (name) {
  32747. // from tornado docs: http://www.tornadoweb.org/en/stable/guide/security.html
  32748. var r = document.cookie.match("\\b" + name + "=([^;]*)\\b");
  32749. return r ? r[1] : undefined;
  32750. }
  32751. var _add_auth_header = function (settings) {
  32752. /**
  32753. * Adds auth header to jquery ajax settings
  32754. */
  32755. settings = settings || {};
  32756. if (!settings.headers) {
  32757. settings.headers = {};
  32758. }
  32759. if (!settings.headers.Authorization) {
  32760. var xsrf_token = _get_cookie('_xsrf');
  32761. if (xsrf_token) {
  32762. settings.headers['X-XSRFToken'] = xsrf_token;
  32763. }
  32764. }
  32765. return settings;
  32766. };
  32767. var promising_ajax = function(url, settings) {
  32768. /**
  32769. * Like $.ajax, but returning an ES6 promise. success and error settings
  32770. * will be ignored.
  32771. */
  32772. settings = settings || {};
  32773. return new Promise(function(resolve, reject) {
  32774. settings.success = function(data, status, jqXHR) {
  32775. resolve(data);
  32776. };
  32777. settings.error = function(jqXHR, status, error) {
  32778. log_ajax_error(jqXHR, status, error);
  32779. reject(wrap_ajax_error(jqXHR, status, error));
  32780. };
  32781. ajax(url, settings);
  32782. });
  32783. };
  32784. var WrappedError = function(message, error){
  32785. /**
  32786. * Wrappable Error class
  32787. *
  32788. * The Error class doesn't actually act on `this`. Instead it always
  32789. * returns a new instance of Error. Here we capture that instance so we
  32790. * can apply it's properties to `this`.
  32791. */
  32792. var tmp = Error.apply(this, [message]);
  32793. // Copy the properties of the error over to this.
  32794. var properties = Object.getOwnPropertyNames(tmp);
  32795. for (var i = 0; i < properties.length; i++) {
  32796. this[properties[i]] = tmp[properties[i]];
  32797. }
  32798. // Keep a stack of the original error messages.
  32799. if (error instanceof WrappedError) {
  32800. this.error_stack = error.error_stack;
  32801. } else {
  32802. this.error_stack = [error];
  32803. }
  32804. this.error_stack.push(tmp);
  32805. return this;
  32806. };
  32807. WrappedError.prototype = Object.create(Error.prototype, {});
  32808. var load_class = function(class_name, module_name, registry) {
  32809. /**
  32810. * Tries to load a class
  32811. *
  32812. * Tries to load a class from a module using require.js, if a module
  32813. * is specified, otherwise tries to load a class from the global
  32814. * registry, if the global registry is provided.
  32815. */
  32816. return new Promise(function(resolve, reject) {
  32817. // Try loading the view module using require.js
  32818. if (module_name) {
  32819. requirejs([module_name], function(module) {
  32820. if (module[class_name] === undefined) {
  32821. reject(new Error('Class '+class_name+' not found in module '+module_name));
  32822. } else {
  32823. resolve(module[class_name]);
  32824. }
  32825. }, reject);
  32826. } else {
  32827. if (registry && registry[class_name]) {
  32828. resolve(registry[class_name]);
  32829. } else {
  32830. reject(new Error('Class '+class_name+' not found in registry '));
  32831. }
  32832. }
  32833. });
  32834. };
  32835. var resolve_promises_dict = function(d) {
  32836. /**
  32837. * Resolve a promiseful dictionary.
  32838. * Returns a single Promise.
  32839. */
  32840. var keys = Object.keys(d);
  32841. var values = [];
  32842. keys.forEach(function(key) {
  32843. values.push(d[key]);
  32844. });
  32845. return Promise.all(values).then(function(v) {
  32846. d = {};
  32847. for(var i=0; i<keys.length; i++) {
  32848. d[keys[i]] = v[i];
  32849. }
  32850. return d;
  32851. });
  32852. };
  32853. var reject = function(message, log) {
  32854. /**
  32855. * Creates a wrappable Promise rejection function.
  32856. *
  32857. * Creates a function that returns a Promise.reject with a new WrappedError
  32858. * that has the provided message and wraps the original error that
  32859. * caused the promise to reject.
  32860. */
  32861. return function(error) {
  32862. var wrapped_error = new WrappedError(message, error);
  32863. if (log) {
  32864. console.error(message, " -- ", error);
  32865. }
  32866. return Promise.reject(wrapped_error);
  32867. };
  32868. };
  32869. var typeset = function(element, text) {
  32870. /**
  32871. * Apply MathJax rendering to an element, and optionally set its text
  32872. *
  32873. * If MathJax is not available, make no changes.
  32874. *
  32875. * Returns the output any number of typeset elements, or undefined if
  32876. * MathJax was not available.
  32877. *
  32878. * Parameters
  32879. * ----------
  32880. * element: Node, NodeList, or jQuery selection
  32881. * text: option string
  32882. */
  32883. var $el = element.jquery ? element : $(element);
  32884. if(arguments.length > 1){
  32885. $el.text(text);
  32886. }
  32887. if(!window.MathJax){
  32888. return;
  32889. }
  32890. $el.map(function(){
  32891. // MathJax takes a DOM node: $.map makes `this` the context
  32892. MathJax.Hub.Queue(["Typeset", MathJax.Hub, this]);
  32893. try {
  32894. MathJax.Hub.Queue(
  32895. ["Require", MathJax.Ajax, "[MathJax]/extensions/TeX/AMSmath.js"],
  32896. function() { MathJax.InputJax.TeX.resetEquationNumbers(); }
  32897. );
  32898. } catch (e) {
  32899. console.error("Error queueing resetEquationNumbers:", e);
  32900. }
  32901. });
  32902. };
  32903. var parse_b64_data_uri = function(uri) {
  32904. /**
  32905. * Parses a base64 encoded data-uri to extract mimetype and the
  32906. * base64 string.
  32907. *
  32908. * For example, given 'data:image/png;base64,iVBORw', it will return
  32909. * ["image/png", "iVBORw"]
  32910. *
  32911. * Parameters
  32912. */
  32913. // For performance reasons, the non-greedy ? qualifiers are crucial so
  32914. // that the matcher stops early on big blobs. Without them, it will try
  32915. // to match the whole blob which can take ages
  32916. var regex = /^data:(.+?\/.+?);base64,/;
  32917. var matches = uri.match(regex);
  32918. var mime = matches[1];
  32919. // matches[0] contains the whole data-uri prefix
  32920. var b64_data = uri.slice(matches[0].length);
  32921. return [mime, b64_data];
  32922. };
  32923. var time = {};
  32924. time.milliseconds = {};
  32925. time.milliseconds.s = 1000;
  32926. time.milliseconds.m = 60 * time.milliseconds.s;
  32927. time.milliseconds.h = 60 * time.milliseconds.m;
  32928. time.milliseconds.d = 24 * time.milliseconds.h;
  32929. time.thresholds = {
  32930. // moment.js thresholds in milliseconds
  32931. s: moment.relativeTimeThreshold('s') * time.milliseconds.s,
  32932. m: moment.relativeTimeThreshold('m') * time.milliseconds.m,
  32933. h: moment.relativeTimeThreshold('h') * time.milliseconds.h,
  32934. d: moment.relativeTimeThreshold('d') * time.milliseconds.d,
  32935. };
  32936. time.timeout_from_dt = function (dt) {
  32937. /** compute a timeout based on dt
  32938. input and output both in milliseconds
  32939. use moment's relative time thresholds:
  32940. - 10 seconds if in 'seconds ago' territory
  32941. - 1 minute if in 'minutes ago'
  32942. - 1 hour otherwise
  32943. */
  32944. if (dt < time.thresholds.s) {
  32945. return 10 * time.milliseconds.s;
  32946. } else if (dt < time.thresholds.m) {
  32947. return time.milliseconds.m;
  32948. } else {
  32949. return time.milliseconds.h;
  32950. }
  32951. };
  32952. var format_datetime = function(date) {
  32953. var text = moment(date).fromNow();
  32954. return text === 'a few seconds ago' ? 'seconds ago' : text;
  32955. };
  32956. var datetime_sort_helper = function(a, b, order) {
  32957. if (moment(a).isBefore(moment(b))) {
  32958. return (order == 1) ? -1 : 1;
  32959. } else if (moment(a).isSame(moment(b))) {
  32960. return 0;
  32961. } else {
  32962. return (order == 1) ? 1 : -1;
  32963. }
  32964. };
  32965. /**
  32966. source: https://github.com/sindresorhus/pretty-bytes
  32967. The MIT License (MIT)
  32968. Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
  32969. Permission is hereby granted, free of charge, to any person obtaining a copy
  32970. of this software and associated documentation files (the "Software"), to deal
  32971. in the Software without restriction, including without limitation the rights
  32972. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  32973. copies of the Software, and to permit persons to whom the Software is
  32974. furnished to do so, subject to the following conditions:
  32975. The above copyright notice and this permission notice shall be included in
  32976. all copies or substantial portions of the Software.
  32977. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  32978. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  32979. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  32980. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  32981. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  32982. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  32983. THE SOFTWARE.
  32984. **/
  32985. var format_filesize = function(num) {
  32986. if (num === undefined || num === null)
  32987. return;
  32988. var UNITS = ['B', 'kB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
  32989. if (!Number.isFinite(num)) {
  32990. console.error("Expected finite number, got ", typeof(num) + ": " + num);
  32991. }
  32992. var neg = num < 0;
  32993. if (neg) {
  32994. num = -num;
  32995. }
  32996. if (num < 1) {
  32997. return (neg ? '-' : '') + num + ' B';
  32998. }
  32999. var exponent = Math.min(Math.floor(Math.log10(num) / 3), UNITS.length - 1);
  33000. var numStr = Number((num / Math.pow(1000, exponent)).toPrecision(3));
  33001. var unit = UNITS[exponent];
  33002. return (neg ? '-' : '') + numStr + ' ' + unit;
  33003. }
  33004. // javascript stores text as utf16 and string indices use "code units",
  33005. // which stores high-codepoint characters as "surrogate pairs",
  33006. // which occupy two indices in the javascript string.
  33007. // We need to translate cursor_pos in the protocol (in characters)
  33008. // to js offset (with surrogate pairs taking two spots).
  33009. function js_idx_to_char_idx (js_idx, text) {
  33010. var char_idx = js_idx;
  33011. for (var i = 0; i + 1 < text.length && i < js_idx; i++) {
  33012. var char_code = text.charCodeAt(i);
  33013. // check for surrogate pair
  33014. if (char_code >= 0xD800 && char_code <= 0xDBFF) {
  33015. var next_char_code = text.charCodeAt(i+1);
  33016. if (next_char_code >= 0xDC00 && next_char_code <= 0xDFFF) {
  33017. char_idx--;
  33018. i++;
  33019. }
  33020. }
  33021. }
  33022. return char_idx;
  33023. }
  33024. function char_idx_to_js_idx (char_idx, text) {
  33025. var js_idx = char_idx;
  33026. for (var i = 0; i + 1 < text.length && i < js_idx; i++) {
  33027. var char_code = text.charCodeAt(i);
  33028. // check for surrogate pair
  33029. if (char_code >= 0xD800 && char_code <= 0xDBFF) {
  33030. var next_char_code = text.charCodeAt(i+1);
  33031. if (next_char_code >= 0xDC00 && next_char_code <= 0xDFFF) {
  33032. js_idx++;
  33033. i++;
  33034. }
  33035. }
  33036. }
  33037. return js_idx;
  33038. }
  33039. if ('𝐚'.length === 1) {
  33040. // If javascript fixes string indices of non-BMP characters,
  33041. // don't keep shifting offsets to compensate for surrogate pairs
  33042. char_idx_to_js_idx = js_idx_to_char_idx = function (idx, text) { return idx; };
  33043. }
  33044. // Test if a drag'n'drop event contains a file (as opposed to an HTML
  33045. // element/text from the document)
  33046. var dnd_contain_file = function(event) {
  33047. // As per the HTML5 drag'n'drop spec, the dataTransfer.types should
  33048. // contain one "Files" type if a file is being dragged
  33049. // https://www.w3.org/TR/2011/WD-html5-20110113/dnd.html#dom-datatransfer-types
  33050. if (event.dataTransfer.types) {
  33051. for (var i = 0; i < event.dataTransfer.types.length; i++) {
  33052. if (event.dataTransfer.types[i] == "Files") {
  33053. return true;
  33054. }
  33055. }
  33056. }
  33057. return false;
  33058. };
  33059. var throttle = function(fn, time) {
  33060. var pending = null;
  33061. return function () {
  33062. if (pending) return;
  33063. pending = setTimeout(run, time);
  33064. return function () {
  33065. clearTimeout(pending);
  33066. pending = null;
  33067. }
  33068. }
  33069. function run () {
  33070. pending = null;
  33071. fn();
  33072. }
  33073. }
  33074. var change_favicon = function (src) {
  33075. var link = document.createElement('link'),
  33076. oldLink = document.getElementById('favicon');
  33077. link.id = 'favicon';
  33078. link.type = 'image/x-icon';
  33079. link.rel = 'shortcut icon';
  33080. link.href = utils.url_path_join(utils.get_body_data('baseUrl'), src);
  33081. if (oldLink && (link.href === oldLink.href)) {
  33082. // This favicon is already set, don't modify the DOM.
  33083. return;
  33084. }
  33085. if (oldLink) document.head.removeChild(oldLink);
  33086. document.head.appendChild(link);
  33087. };
  33088. var utils = {
  33089. throttle: throttle,
  33090. is_loaded: is_loaded,
  33091. load_extension: load_extension,
  33092. load_extensions: load_extensions,
  33093. filter_extensions: filter_extensions,
  33094. load_extensions_from_config: load_extensions_from_config,
  33095. regex_split : regex_split,
  33096. uuid : uuid,
  33097. fixConsole : fixConsole,
  33098. fixCarriageReturn : fixCarriageReturn,
  33099. fixBackspace : fixBackspace,
  33100. fixOverwrittenChars: fixOverwrittenChars,
  33101. autoLinkUrls : autoLinkUrls,
  33102. points_to_pixels : points_to_pixels,
  33103. get_body_data : get_body_data,
  33104. parse_url : parse_url,
  33105. url_path_split : url_path_split,
  33106. url_path_join : url_path_join,
  33107. url_join_encode : url_join_encode,
  33108. encode_uri_components : encode_uri_components,
  33109. splitext : splitext,
  33110. escape_html : escape_html,
  33111. always_new : always_new,
  33112. to_absolute_cursor_pos : to_absolute_cursor_pos,
  33113. from_absolute_cursor_pos : from_absolute_cursor_pos,
  33114. browser : browser,
  33115. platform: platform,
  33116. get_url_param: get_url_param,
  33117. is_or_has : is_or_has,
  33118. is_focused : is_focused,
  33119. mergeopt: mergeopt,
  33120. requireCodeMirrorMode : requireCodeMirrorMode,
  33121. XHR_ERROR : XHR_ERROR,
  33122. ajax : ajax,
  33123. ajax_error_msg : ajax_error_msg,
  33124. log_ajax_error : log_ajax_error,
  33125. wrap_ajax_error : wrap_ajax_error,
  33126. promising_ajax : promising_ajax,
  33127. WrappedError: WrappedError,
  33128. load_class: load_class,
  33129. resolve_promises_dict: resolve_promises_dict,
  33130. reject: reject,
  33131. typeset: typeset,
  33132. parse_b64_data_uri: parse_b64_data_uri,
  33133. time: time,
  33134. format_datetime: format_datetime,
  33135. format_filesize: format_filesize,
  33136. datetime_sort_helper: datetime_sort_helper,
  33137. dnd_contain_file: dnd_contain_file,
  33138. js_idx_to_char_idx: js_idx_to_char_idx,
  33139. char_idx_to_js_idx: char_idx_to_js_idx,
  33140. _ansispan:_ansispan,
  33141. change_favicon: change_favicon
  33142. };
  33143. return utils;
  33144. });
  33145. // Copyright (c) Jupyter Development Team.
  33146. // Distributed under the terms of the Modified BSD License.
  33147. define('services/config',[
  33148. 'base/js/utils',
  33149. ],
  33150. function(utils) {
  33151. "use strict";
  33152. var ConfigSection = function(section_name, options) {
  33153. this.section_name = section_name;
  33154. this.base_url = options.base_url;
  33155. this.data = {};
  33156. var that = this;
  33157. /* .loaded is a promise, fulfilled the first time the config is loaded
  33158. * from the server. Code can do:
  33159. * conf.loaded.then(function() { ... using conf.data ... });
  33160. */
  33161. this._one_load_finished = false;
  33162. this.loaded = new Promise(function(resolve, reject) {
  33163. that._finish_firstload = resolve;
  33164. });
  33165. };
  33166. ConfigSection.prototype.api_url = function() {
  33167. return utils.url_path_join(this.base_url, 'api/config',
  33168. utils.encode_uri_components(this.section_name));
  33169. };
  33170. ConfigSection.prototype._load_done = function() {
  33171. if (!this._one_load_finished) {
  33172. this._one_load_finished = true;
  33173. this._finish_firstload();
  33174. }
  33175. };
  33176. ConfigSection.prototype.load = function() {
  33177. var that = this;
  33178. return utils.promising_ajax(this.api_url(), {
  33179. cache: false,
  33180. type: "GET",
  33181. dataType: "json",
  33182. }).then(function(data) {
  33183. that.data = data;
  33184. that._load_done();
  33185. return data;
  33186. });
  33187. };
  33188. /**
  33189. * Modify the config values stored. Update the local data immediately,
  33190. * send the change to the server, and use the updated data from the server
  33191. * when the reply comes.
  33192. */
  33193. ConfigSection.prototype.update = function(newdata) {
  33194. $.extend(true, this.data, newdata); // true -> recursive update
  33195. var that = this;
  33196. return utils.promising_ajax(this.api_url(), {
  33197. processData: false,
  33198. type : "PATCH",
  33199. data: JSON.stringify(newdata),
  33200. dataType : "json",
  33201. contentType: 'application/json',
  33202. }).then(function(data) {
  33203. that.data = data;
  33204. that._load_done();
  33205. return data;
  33206. });
  33207. };
  33208. var ConfigWithDefaults = function(section, defaults, classname) {
  33209. this.section = section;
  33210. this.defaults = defaults;
  33211. this.classname = classname;
  33212. };
  33213. ConfigWithDefaults.prototype._class_data = function() {
  33214. if (this.classname) {
  33215. return this.section.data[this.classname] || {};
  33216. } else {
  33217. return this.section.data;
  33218. }
  33219. };
  33220. /**
  33221. * Wait for config to have loaded, then get a value or the default.
  33222. * Returns a promise.
  33223. */
  33224. ConfigWithDefaults.prototype.get = function(key) {
  33225. var that = this;
  33226. return this.section.loaded.then(function() {
  33227. return that.get_sync(key);
  33228. });
  33229. };
  33230. /**
  33231. * Return a config value. If config is not yet loaded, return the default
  33232. * instead of waiting for it to load.
  33233. */
  33234. ConfigWithDefaults.prototype.get_sync = function(key) {
  33235. var data = this._class_data();
  33236. if (key === undefined) {
  33237. // no key specified, return full config data
  33238. return $.extend(true, {}, this.defaults, data);
  33239. }
  33240. var value = data[key];
  33241. if (value !== undefined) {
  33242. if (typeof value == 'object') {
  33243. // merge with defaults if it's an object
  33244. return $.extend(true, {}, this.defaults[key], value);
  33245. } else {
  33246. return value;
  33247. }
  33248. }
  33249. return this.defaults[key];
  33250. };
  33251. /**
  33252. * Set a config value. Send the update to the server, and change our
  33253. * local copy of the data immediately.
  33254. * Returns a promise which is fulfilled when the server replies to the
  33255. * change.
  33256. */
  33257. ConfigWithDefaults.prototype.set = function(key, value) {
  33258. var d = {};
  33259. d[key] = value;
  33260. if (this.classname) {
  33261. var d2 = {};
  33262. d2[this.classname] = d;
  33263. return this.section.update(d2);
  33264. } else {
  33265. return this.section.update(d);
  33266. }
  33267. };
  33268. return {ConfigSection: ConfigSection,
  33269. ConfigWithDefaults: ConfigWithDefaults,
  33270. };
  33271. });
  33272. // Copyright (c) Jupyter Development Team.
  33273. // Distributed under the terms of the Modified BSD License.
  33274. /**
  33275. *
  33276. *
  33277. * @module keyboard
  33278. * @namespace keyboard
  33279. * @class ShortcutManager
  33280. */
  33281. define('base/js/keyboard',[
  33282. 'jquery',
  33283. 'base/js/utils',
  33284. 'underscore',
  33285. ], function($, utils, _) {
  33286. "use strict";
  33287. /**
  33288. * Setup global keycodes and inverse keycodes.
  33289. *
  33290. * See http://unixpapa.com/js/key.html for a complete description. The short of
  33291. * it is that there are different keycode sets. Firefox uses the "Mozilla keycodes"
  33292. * and Webkit/IE use the "IE keycodes". These keycode sets are mostly the same
  33293. * but have minor differences.
  33294. **/
  33295. // These apply to Firefox, (Webkit and IE)
  33296. // This does work **only** on US keyboard.
  33297. var _keycodes = {
  33298. 'a': 65, 'b': 66, 'c': 67, 'd': 68, 'e': 69, 'f': 70, 'g': 71, 'h': 72, 'i': 73,
  33299. 'j': 74, 'k': 75, 'l': 76, 'm': 77, 'n': 78, 'o': 79, 'p': 80, 'q': 81, 'r': 82,
  33300. 's': 83, 't': 84, 'u': 85, 'v': 86, 'w': 87, 'x': 88, 'y': 89, 'z': 90,
  33301. '1 !': 49, '2 @': 50, '3 #': 51, '4 $': 52, '5 %': 53, '6 ^': 54,
  33302. '7 &': 55, '8 *': 56, '9 (': 57, '0 )': 48,
  33303. '[ {': 219, '] }': 221, '` ~': 192, ', <': 188, '. >': 190, '/ ?': 191,
  33304. '\\ |': 220, '\' "': 222,
  33305. 'numpad0': 96, 'numpad1': 97, 'numpad2': 98, 'numpad3': 99, 'numpad4': 100,
  33306. 'numpad5': 101, 'numpad6': 102, 'numpad7': 103, 'numpad8': 104, 'numpad9': 105,
  33307. 'multiply': 106, 'add': 107, 'subtract': 109, 'decimal': 110, 'divide': 111,
  33308. 'f1': 112, 'f2': 113, 'f3': 114, 'f4': 115, 'f5': 116, 'f6': 117, 'f7': 118,
  33309. 'f8': 119, 'f9': 120, 'f10': 121, 'f11': 122, 'f12': 123, 'f13': 124, 'f14': 125, 'f15': 126,
  33310. 'backspace': 8, 'tab': 9, 'enter': 13, 'shift': 16, 'ctrl': 17, 'alt': 18,
  33311. 'meta': 91, 'capslock': 20, 'esc': 27, 'space': 32, 'pageup': 33, 'pagedown': 34,
  33312. 'end': 35, 'home': 36, 'left': 37, 'up': 38, 'right': 39, 'down': 40,
  33313. 'insert': 45, 'delete': 46, 'numlock': 144,
  33314. };
  33315. // These apply to Firefox and Opera
  33316. var _mozilla_keycodes = {
  33317. '; :': 59, '= +': 61, '- _': 173, 'meta': 224, 'minus':173
  33318. };
  33319. // This apply to Webkit and IE
  33320. var _ie_keycodes = {
  33321. '; :': 186, '= +': 187, '- _': 189, 'minus':189
  33322. };
  33323. var browser = utils.browser[0];
  33324. var platform = utils.platform;
  33325. if (browser === 'Firefox' || browser === 'Opera' || browser === 'Netscape') {
  33326. $.extend(_keycodes, _mozilla_keycodes);
  33327. } else if (browser === 'Safari' || browser === 'Chrome' || browser === 'MSIE') {
  33328. $.extend(_keycodes, _ie_keycodes);
  33329. }
  33330. var keycodes = {};
  33331. var inv_keycodes = {};
  33332. for (var name in _keycodes) {
  33333. var names = name.split(' ');
  33334. if (names.length === 1) {
  33335. var n = names[0];
  33336. keycodes[n] = _keycodes[n];
  33337. inv_keycodes[_keycodes[n]] = n;
  33338. } else {
  33339. var primary = names[0];
  33340. var secondary = names[1];
  33341. keycodes[primary] = _keycodes[name];
  33342. keycodes[secondary] = _keycodes[name];
  33343. inv_keycodes[_keycodes[name]] = primary;
  33344. }
  33345. }
  33346. var normalize_key = function (key) {
  33347. return inv_keycodes[keycodes[key]];
  33348. };
  33349. var normalize_shortcut = function (shortcut) {
  33350. /**
  33351. * @function _normalize_shortcut
  33352. * @private
  33353. * return a dict containing the normalized shortcut and the number of time it should be pressed:
  33354. *
  33355. * Put a shortcut into normalized form:
  33356. * 1. Make lowercase
  33357. * 2. Replace cmd by meta
  33358. * 3. Sort '-' separated modifiers into the order alt-ctrl-meta-shift
  33359. * 4. Normalize keys
  33360. **/
  33361. if (platform === 'MacOS') {
  33362. shortcut = shortcut.toLowerCase().replace('cmdtrl-', 'cmd-');
  33363. } else {
  33364. shortcut = shortcut.toLowerCase().replace('cmdtrl-', 'ctrl-');
  33365. }
  33366. shortcut = shortcut.toLowerCase().replace('cmd', 'meta');
  33367. shortcut = shortcut.replace(/-$/, 'minus'); // catch shortcuts using '-' key
  33368. shortcut = shortcut.replace(/,$/, 'comma'); // catch shortcuts using '-' key
  33369. if(shortcut.indexOf(',') !== -1){
  33370. var sht = shortcut.split(',');
  33371. sht = _.map(sht, normalize_shortcut);
  33372. return shortcut;
  33373. }
  33374. shortcut = shortcut.replace(/comma/g, ','); // catch shortcuts using '-' key
  33375. var values = shortcut.split("-");
  33376. if (values.length === 1) {
  33377. return normalize_key(values[0]);
  33378. } else {
  33379. var modifiers = values.slice(0,-1);
  33380. var key = normalize_key(values[values.length-1]);
  33381. modifiers.sort();
  33382. return modifiers.join('-') + '-' + key;
  33383. }
  33384. };
  33385. var shortcut_to_event = function (shortcut, type) {
  33386. /**
  33387. * Convert a shortcut (shift-r) to a jQuery Event object
  33388. **/
  33389. type = type || 'keydown';
  33390. shortcut = normalize_shortcut(shortcut);
  33391. shortcut = shortcut.replace(/-$/, 'minus'); // catch shortcuts using '-' key
  33392. var values = shortcut.split("-");
  33393. var modifiers = values.slice(0,-1);
  33394. var key = values[values.length-1];
  33395. var opts = {which: keycodes[key]};
  33396. if (modifiers.indexOf('alt') !== -1) {opts.altKey = true;}
  33397. if (modifiers.indexOf('ctrl') !== -1) {opts.ctrlKey = true;}
  33398. if (modifiers.indexOf('meta') !== -1) {opts.metaKey = true;}
  33399. if (modifiers.indexOf('shift') !== -1) {opts.shiftKey = true;}
  33400. return $.Event(type, opts);
  33401. };
  33402. var only_modifier_event = function(event){
  33403. /**
  33404. * Return `true` if the event only contains modifiers keys.
  33405. * false otherwise
  33406. **/
  33407. var key = inv_keycodes[event.which];
  33408. return ((event.altKey || event.ctrlKey || event.metaKey || event.shiftKey) &&
  33409. (key === 'alt'|| key === 'ctrl'|| key === 'meta'|| key === 'shift'));
  33410. };
  33411. var event_to_shortcut = function (event) {
  33412. /**
  33413. * Convert a jQuery Event object to a normalized shortcut string (shift-r)
  33414. **/
  33415. var shortcut = '';
  33416. var key = inv_keycodes[event.which];
  33417. if (event.altKey && key !== 'alt') {shortcut += 'alt-';}
  33418. if (event.ctrlKey && key !== 'ctrl') {shortcut += 'ctrl-';}
  33419. if (event.metaKey && key !== 'meta') {shortcut += 'meta-';}
  33420. if (event.shiftKey && key !== 'shift') {shortcut += 'shift-';}
  33421. shortcut += key;
  33422. return shortcut;
  33423. };
  33424. // Shortcut manager class
  33425. var ShortcutManager = function (delay, events, actions, env, config, mode) {
  33426. /**
  33427. * A class to deal with keyboard event and shortcut
  33428. *
  33429. * @class ShortcutManager
  33430. * @constructor
  33431. *
  33432. * :config: configobjet on which to call `update(....)` to persist the config.
  33433. * :mode: mode of this shortcut manager where to persist config.
  33434. */
  33435. mode = mode || 'command';
  33436. this._shortcuts = {};
  33437. this._defaults_bindings = [];
  33438. this.delay = delay || 800; // delay in milliseconds
  33439. this.events = events;
  33440. this.actions = actions;
  33441. this.actions.extend_env(env);
  33442. this._queue = [];
  33443. this._cleartimeout = null;
  33444. this._config = config;
  33445. this._mode = mode;
  33446. Object.seal(this);
  33447. };
  33448. ShortcutManager.prototype.clearsoon = function(){
  33449. /**
  33450. * Clear the pending shortcut soon, and cancel previous clearing
  33451. * that might be registered.
  33452. **/
  33453. var that = this;
  33454. clearTimeout(this._cleartimeout);
  33455. this._cleartimeout = setTimeout(function(){that.clearqueue();}, this.delay);
  33456. };
  33457. ShortcutManager.prototype.clearqueue = function(){
  33458. /**
  33459. * clear the pending shortcut sequence now.
  33460. **/
  33461. this._queue = [];
  33462. clearTimeout(this._cleartimeout);
  33463. };
  33464. var flatten_shorttree = function(tree){
  33465. /**
  33466. * Flatten a tree of shortcut sequences.
  33467. * use full to iterate over all the key/values of available shortcuts.
  33468. **/
  33469. var dct = {};
  33470. _.forEach(tree, function(value, key) {
  33471. if(typeof(value) === 'string'){
  33472. dct[key] = value;
  33473. } else {
  33474. var ftree=flatten_shorttree(value);
  33475. _.forEach(ftree, function(v2, subkey) {
  33476. dct[key+','+subkey] = ftree[subkey];
  33477. });
  33478. }
  33479. });
  33480. return dct;
  33481. };
  33482. ShortcutManager.prototype.get_action_shortcuts = function(name){
  33483. var ftree = flatten_shorttree(this._shortcuts);
  33484. var res = [];
  33485. _.forEach(ftree, function(value, key) {
  33486. if(value === name){
  33487. res.push(key);
  33488. }
  33489. });
  33490. return res;
  33491. };
  33492. ShortcutManager.prototype.get_action_shortcut = function(name){
  33493. var matches = this.get_action_shortcuts(name);
  33494. if (matches.length > 0) {
  33495. return matches[0];
  33496. }
  33497. return undefined;
  33498. };
  33499. ShortcutManager.prototype.help = function () {
  33500. var that = this;
  33501. var help = [];
  33502. var ftree = flatten_shorttree(this._shortcuts);
  33503. _.forEach(ftree, function(value, key) {
  33504. var action = that.actions.get(value);
  33505. var help_string = action.help||'== no help ==';
  33506. var help_index = action.help_index;
  33507. if (help_string) {
  33508. var shortstring = (action.shortstring||key);
  33509. help.push({
  33510. shortcut: shortstring,
  33511. help: help_string,
  33512. help_index: help_index}
  33513. );
  33514. }
  33515. });
  33516. help.sort(function (a, b) {
  33517. if (a.help_index === b.help_index) {
  33518. if (a.shortcut === b.shortcut) {
  33519. return 0;
  33520. }
  33521. if (a.shortcut > b.shortcut) {
  33522. return 1;
  33523. }
  33524. return -1;
  33525. }
  33526. if (a.help_index === undefined || a.help_index > b.help_index){
  33527. return 1;
  33528. }
  33529. return -1;
  33530. });
  33531. return help;
  33532. };
  33533. ShortcutManager.prototype.clear_shortcuts = function () {
  33534. this._shortcuts = {};
  33535. };
  33536. ShortcutManager.prototype.get_shortcut = function (shortcut){
  33537. /**
  33538. * return a node of the shortcut tree which an action name (string) if leaf,
  33539. * and an object with `object.subtree===true`
  33540. **/
  33541. if(typeof(shortcut) === 'string'){
  33542. shortcut = shortcut.split(',');
  33543. }
  33544. return this._get_leaf(shortcut, this._shortcuts);
  33545. };
  33546. ShortcutManager.prototype._get_leaf = function(shortcut_array, tree){
  33547. /**
  33548. * @private
  33549. * find a leaf/node in a subtree of the keyboard shortcut
  33550. *
  33551. **/
  33552. if(shortcut_array.length === 1){
  33553. return tree[shortcut_array[0]];
  33554. } else if( typeof(tree[shortcut_array[0]]) !== 'string'){
  33555. return this._get_leaf(shortcut_array.slice(1), tree[shortcut_array[0]]);
  33556. }
  33557. return null;
  33558. };
  33559. ShortcutManager.prototype.set_shortcut = function( shortcut, action_name){
  33560. if( typeof(action_name) !== 'string'){throw new Error('action is not a string', action_name);}
  33561. if( typeof(shortcut) === 'string'){
  33562. shortcut = shortcut.split(',');
  33563. }
  33564. return this._set_leaf(shortcut, action_name, this._shortcuts);
  33565. };
  33566. ShortcutManager.prototype._is_leaf = function(shortcut_array, tree){
  33567. if(shortcut_array.length === 1){
  33568. return(typeof(tree[shortcut_array[0]]) === 'string');
  33569. } else {
  33570. var subtree = tree[shortcut_array[0]];
  33571. return this._is_leaf(shortcut_array.slice(1), subtree );
  33572. }
  33573. };
  33574. ShortcutManager.prototype._remove_leaf = function(shortcut_array, tree, allow_node){
  33575. if(shortcut_array.length === 1){
  33576. var current_node = tree[shortcut_array[0]];
  33577. if(typeof(current_node) === 'string'){
  33578. delete tree[shortcut_array[0]];
  33579. } else {
  33580. throw new Error('try to delete non-leaf');
  33581. }
  33582. } else {
  33583. this._remove_leaf(shortcut_array.slice(1), tree[shortcut_array[0]], allow_node);
  33584. if(_.keys(tree[shortcut_array[0]]).length === 0){
  33585. delete tree[shortcut_array[0]];
  33586. }
  33587. }
  33588. };
  33589. ShortcutManager.prototype.is_available_shortcut = function(shortcut){
  33590. var shortcut_array = shortcut.split(',');
  33591. return this._is_available_shortcut(shortcut_array, this._shortcuts);
  33592. };
  33593. ShortcutManager.prototype._is_available_shortcut = function(shortcut_array, tree){
  33594. var current_node = tree[shortcut_array[0]];
  33595. if(!shortcut_array[0]){
  33596. return false;
  33597. }
  33598. if(current_node === undefined){
  33599. return true;
  33600. } else {
  33601. if (typeof(current_node) === 'string'){
  33602. return false;
  33603. } else { // assume is a sub-shortcut tree
  33604. return this._is_available_shortcut(shortcut_array.slice(1), current_node);
  33605. }
  33606. }
  33607. };
  33608. ShortcutManager.prototype._set_leaf = function(shortcut_array, action_name, tree){
  33609. var current_node = tree[shortcut_array[0]];
  33610. if(shortcut_array.length === 1){
  33611. if(current_node !== undefined && typeof(current_node) !== 'string'){
  33612. console.warn('[warning], you are overriting a long shortcut with a shorter one');
  33613. }
  33614. tree[shortcut_array[0]] = action_name;
  33615. return true;
  33616. } else {
  33617. if(typeof(current_node) === 'string'){
  33618. console.warn('you are trying to set a shortcut that will be shadowed'+
  33619. 'by a more specific one. Aborting for :', action_name, 'the follwing '+
  33620. 'will take precedence', current_node);
  33621. return false;
  33622. } else {
  33623. tree[shortcut_array[0]] = tree[shortcut_array[0]]||{};
  33624. }
  33625. this._set_leaf(shortcut_array.slice(1), action_name, tree[shortcut_array[0]]);
  33626. return true;
  33627. }
  33628. };
  33629. ShortcutManager.prototype._persist_shortcut = function(shortcut, data) {
  33630. /**
  33631. * add a shortcut to this manager and persist it to the config file.
  33632. **/
  33633. shortcut = shortcut.toLowerCase();
  33634. this.add_shortcut(shortcut, data);
  33635. var patch = {keys:{}};
  33636. patch.keys[this._mode] = {bind:{}};
  33637. patch.keys[this._mode].bind[shortcut] = data;
  33638. this._config.update(patch);
  33639. };
  33640. ShortcutManager.prototype._persist_remove_shortcut = function(shortcut){
  33641. /**
  33642. * Remove a shortcut from this manager and persist its removal.
  33643. */
  33644. shortcut = shortcut.toLowerCase();
  33645. this.remove_shortcut(shortcut);
  33646. var patch = {keys: {}};
  33647. patch.keys[this._mode] = {bind:{}};
  33648. patch.keys[this._mode].bind[shortcut] = null;
  33649. this._config.update(patch);
  33650. // if the shortcut we unbind is a default one, we add it to the list of
  33651. // things to unbind at startup
  33652. if( this._defaults_bindings.indexOf(shortcut) !== -1 ){
  33653. var cnf = (this._config.data.keys || {})[this._mode];
  33654. var unbind_array = cnf.unbind || [];
  33655. // unless it's already there (like if we have remapped a default
  33656. // shortcut to another command): unbind it)
  33657. if(unbind_array.indexOf(shortcut) === -1){
  33658. var _parray = unbind_array.concat(shortcut);
  33659. var unbind_patch = {keys:{}};
  33660. unbind_patch.keys[this._mode] = {unbind:_parray};
  33661. console.warn('up:', unbind_patch);
  33662. this._config.update(unbind_patch);
  33663. }
  33664. }
  33665. };
  33666. ShortcutManager.prototype.add_shortcut = function (shortcut, data, suppress_help_update) {
  33667. /**
  33668. * Add an action to be handled by shortcut manager.
  33669. *
  33670. * - `shortcut` should be a `Shortcut Sequence` of the for `Ctrl-Alt-C,Meta-X`...
  33671. * - `data` could be an `action name`, an `action` or a `function`.
  33672. * if a `function` is passed it will be converted to an anonymous `action`.
  33673. *
  33674. **/
  33675. var action_name = this.actions.get_name(data);
  33676. if (! action_name){
  33677. if (typeof data === 'string') {
  33678. // If we have an action name, allow it to be bound anyway.
  33679. console.log("Unknown action '" + data + "' for shortcut " + shortcut
  33680. + "; it may be defined by an extension which is not yet loaded.");
  33681. action_name = data;
  33682. } else {
  33683. throw new Error('does not know how to deal with : ' + data);
  33684. }
  33685. }
  33686. var _shortcut = normalize_shortcut(shortcut);
  33687. this.set_shortcut(_shortcut, action_name);
  33688. if (!suppress_help_update) {
  33689. // update the keyboard shortcuts notebook help
  33690. this.events.trigger('rebuild.QuickHelp');
  33691. }
  33692. };
  33693. ShortcutManager.prototype.add_shortcuts = function (data) {
  33694. /**
  33695. * Convenient methods to call `add_shortcut(key, value)` on several items
  33696. *
  33697. * data : Dict of the form {key:value, ...}
  33698. **/
  33699. var that = this;
  33700. _.forEach(data, function(value, key) {
  33701. that.add_shortcut(key, value, true);
  33702. });
  33703. // update the keyboard shortcuts notebook help
  33704. this.events.trigger('rebuild.QuickHelp');
  33705. };
  33706. ShortcutManager.prototype._add_default_shortcuts = function (data) {
  33707. /**
  33708. * same as add_shortcuts, but register them as "default" that if persistently unbound, with
  33709. * persist_remove_shortcut, need to be on the "unbind" list.
  33710. **/
  33711. this._defaults_bindings = this._defaults_bindings.concat(Object.keys(data));
  33712. this.add_shortcuts(data);
  33713. };
  33714. ShortcutManager.prototype.remove_shortcut = function (shortcut, suppress_help_update) {
  33715. /**
  33716. * Remove the binding of shortcut `sortcut` with its action.
  33717. * throw an error if trying to remove a non-exiting shortcut
  33718. **/
  33719. if(!shortcut){
  33720. console.warn('trying to remove empty shortcut');
  33721. return;
  33722. }
  33723. shortcut = normalize_shortcut(shortcut);
  33724. if( typeof(shortcut) === 'string'){
  33725. shortcut = shortcut.split(',');
  33726. }
  33727. /*
  33728. * The shortcut error should be explicit here, because it will be
  33729. * seen by users.
  33730. */
  33731. try {
  33732. this._remove_leaf(shortcut, this._shortcuts);
  33733. if (!suppress_help_update) {
  33734. // update the keyboard shortcuts notebook help
  33735. this.events.trigger('rebuild.QuickHelp');
  33736. }
  33737. } catch (ex) {
  33738. throw new Error('trying to remove a non-existent shortcut', shortcut, typeof shortcut);
  33739. }
  33740. };
  33741. ShortcutManager.prototype.call_handler = function (event) {
  33742. /**
  33743. * Call the corresponding shortcut handler for a keyboard event
  33744. * @method call_handler
  33745. * @return {Boolean} `true|false`, `false` if no handler was found, otherwise the value return by the handler.
  33746. * @param event {event}
  33747. *
  33748. * given an event, call the corresponding shortcut.
  33749. * return false is event wan handled, true otherwise
  33750. * in any case returning false stop event propagation
  33751. **/
  33752. this.clearsoon();
  33753. if(only_modifier_event(event)){
  33754. return true;
  33755. }
  33756. var shortcut = event_to_shortcut(event);
  33757. this._queue.push(shortcut);
  33758. var action_name = this.get_shortcut(this._queue);
  33759. if (typeof(action_name) === 'undefined'|| action_name === null){
  33760. this.clearqueue();
  33761. return true;
  33762. }
  33763. if (this.actions.exists(action_name)) {
  33764. event.preventDefault();
  33765. this.clearqueue();
  33766. return this.actions.call(action_name, event);
  33767. }
  33768. return false;
  33769. };
  33770. ShortcutManager.prototype.handles = function (event) {
  33771. var shortcut = event_to_shortcut(event);
  33772. var action_name = this.get_shortcut(this._queue.concat(shortcut));
  33773. return (typeof(action_name) !== 'undefined');
  33774. };
  33775. return {
  33776. keycodes : keycodes,
  33777. inv_keycodes : inv_keycodes,
  33778. ShortcutManager : ShortcutManager,
  33779. normalize_key : normalize_key,
  33780. normalize_shortcut : normalize_shortcut,
  33781. shortcut_to_event : shortcut_to_event,
  33782. event_to_shortcut : event_to_shortcut,
  33783. };
  33784. });
  33785. // Copyright (c) Jupyter Development Team.
  33786. // Distributed under the terms of the Modified BSD License.
  33787. define('bidi/numericshaping',[],
  33788. function(bidi) {
  33789. "use strict";
  33790. var regex = /([0-9])|([\u0660-\u0669])|([\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FF\u0750-\u077F\u08A0-\u08E3\u200F\u202B\u202E\u2067\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFC\uFDFE-\uFDFF\uFE70-\uFEFE]+)|([^0-9\u0660-\u0669\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5-\u06E6\u06EE-\u06EF\u06FA-\u06FF\u0750-\u077F\u08A0-\u08E3\u200F\u202B\u202E\u2067\uFB50-\uFD3D\uFD40-\uFDCF\uFDF0-\uFDFC\uFDFE-\uFDFF\uFE70-\uFEFE\u0600-\u0607\u0609-\u060A\u060C\u060E-\u061A\u064B-\u066C\u0670\u06D6-\u06E4\u06E7-\u06ED\u06F0-\u06F9\u08E4-\u08FF\uFD3E-\uFD3F\uFDD0-\uFDEF\uFDFD\uFEFF\u0000-\u0040\u005B-\u0060\u007B-\u007F\u0080-\u00A9\u00AB-\u00B4\u00B6-\u00B9\u00BB-\u00BF\u00D7\u00F7\u02B9-\u02BA\u02C2-\u02CF\u02D2-\u02DF\u02E5-\u02ED\u02EF-\u02FF\u2070\u2074-\u207E\u2080-\u208E\u2100-\u2101\u2103-\u2106\u2108-\u2109\u2114\u2116-\u2118\u211E-\u2123\u2125\u2127\u2129\u212E\u213A-\u213B\u2140-\u2144\u214A-\u214D\u2150-\u215F\u2189\uA720-\uA721\uA788\uFF01-\uFF20\uFF3B-\uFF40\uFF5B-\uFF65\uFFE0-\uFFE6\uFFE8-\uFFEE]+)/g;
  33791. var shape = function(text, shaperType) {
  33792. text = text.toString();
  33793. if (!text) {
  33794. return text;
  33795. }
  33796. switch (shaperType) {
  33797. case "defaultNumeral":
  33798. return _shapeEuropean(text);
  33799. case "national":
  33800. return _shapeArabic(text);
  33801. default:
  33802. return text;
  33803. }
  33804. };
  33805. var _shapeEuropean = function(text) {
  33806. return text.replace(/[\u0660-\u0669]/g, function(c) {
  33807. return c.charCodeAt(0) - 1632;
  33808. });
  33809. };
  33810. var _shapeArabic = function(text) {
  33811. return text.replace(/[0-9]/g, function(c) {
  33812. return String.fromCharCode(parseInt(c) + 1632);
  33813. });
  33814. };
  33815. var numericshaping = {
  33816. shapeNumerals : shape
  33817. };
  33818. return numericshaping;
  33819. });
  33820. // Copyright (c) Jupyter Development Team.
  33821. // Distributed under the terms of the Modified BSD License.
  33822. define('bidi/bidi',['bidi/numericshaping'], function(numericshaping) {
  33823. 'use strict';
  33824. var shaperType = '';
  33825. var _uiLang = function() {
  33826. return navigator.language.toLowerCase();
  33827. };
  33828. var _loadLocale = function() {
  33829. if (_isMirroringEnabled()) {
  33830. document.body.dir = 'rtl';
  33831. }
  33832. requirejs(['moment'], function (moment) {
  33833. console.log('Loaded moment locale', moment.locale(_uiLang()));
  33834. });
  33835. shaperType = _uiLang().split('-')[0] == 'ar' ? 'national' : 'defaultNumeral';
  33836. };
  33837. var _isMirroringEnabled = function() {
  33838. return new RegExp('^(ar|he)').test(_uiLang());
  33839. };
  33840. /**
  33841. * @param value : the string to apply the bidi-support on it.
  33842. * @param flag :indicates the type of bidi-support (Numeric-shaping ,Base-text-dir ).
  33843. */
  33844. var _applyBidi = function(value /*, flag*/) {
  33845. value = numericshaping.shapeNumerals(value, shaperType);
  33846. return value;
  33847. };
  33848. var bidi = {
  33849. applyBidi: _applyBidi,
  33850. isMirroringEnabled: _isMirroringEnabled,
  33851. loadLocale: _loadLocale,
  33852. };
  33853. return bidi;
  33854. });
  33855. // Copyright (c) Jupyter Development Team.
  33856. // Distributed under the terms of the Modified BSD License.
  33857. define('tree/js/notebooklist',[
  33858. 'jquery',
  33859. 'base/js/namespace',
  33860. 'base/js/utils',
  33861. 'base/js/i18n',
  33862. 'base/js/dialog',
  33863. 'base/js/events',
  33864. 'base/js/keyboard',
  33865. 'moment',
  33866. 'bidi/bidi'
  33867. ], function($, IPython, utils, i18n, dialog, events, keyboard, moment, bidi) {
  33868. "use strict";
  33869. var extension = function(path){
  33870. /**
  33871. * return the last pat after the dot in a filepath
  33872. * or the filepath itself if no dots present.
  33873. * Empty string if the filepath ends with a dot.
  33874. **/
  33875. var parts = path.split('.');
  33876. return parts[parts.length-1];
  33877. };
  33878. var item_in = function(item, list) {
  33879. // Normalize list and item to lowercase
  33880. var normalized_list = list.map(function(_item) {
  33881. return _item.toLowerCase();
  33882. });
  33883. return normalized_list.indexOf(item.toLowerCase()) !== -1;
  33884. };
  33885. var includes_extension = function(filepath, extensionslist) {
  33886. return item_in(extension(filepath), extensionslist);
  33887. };
  33888. function name_sorter(ascending) {
  33889. return (function(a, b) {
  33890. if (type_order[a['type']] < type_order[b['type']]) {
  33891. return -1;
  33892. }
  33893. if (type_order[a['type']] > type_order[b['type']]) {
  33894. return 1;
  33895. }
  33896. if (a['name'].toLowerCase() < b['name'].toLowerCase()) {
  33897. return (ascending) ? -1 : 1;
  33898. }
  33899. if (a['name'].toLowerCase() > b['name'].toLowerCase()) {
  33900. return (ascending) ? 1 : -1;
  33901. }
  33902. return 0;
  33903. });
  33904. }
  33905. function modified_sorter(ascending) {
  33906. var order = ascending ? 1 : 0;
  33907. return (function(a, b) {
  33908. return utils.datetime_sort_helper(a.last_modified, b.last_modified,
  33909. order)
  33910. });
  33911. }
  33912. function size_sorter(ascending) {
  33913. var order = ascending ? 1 : 0;
  33914. // directories have file size of undefined
  33915. return (function(a, b) {
  33916. if (a.size === undefined) {
  33917. return (ascending) ? -1 : 1;
  33918. }
  33919. if (b.size === undefined) {
  33920. return (ascending) ? 1 : -1;
  33921. }
  33922. if (a.size > b.size) {
  33923. return (ascending) ? -1 : 1;
  33924. }
  33925. if (b.size > a.size) {
  33926. return (ascending) ? 1 : -1;
  33927. }
  33928. return 0;
  33929. });
  33930. }
  33931. var sort_functions = {
  33932. 'sort-name': name_sorter,
  33933. 'last-modified': modified_sorter,
  33934. 'file-size': size_sorter
  33935. };
  33936. var NotebookList = function (selector, options) {
  33937. /**
  33938. * Constructor
  33939. *
  33940. * Parameters:
  33941. * selector: string
  33942. * options: dictionary
  33943. * Dictionary of keyword arguments.
  33944. * session_list: SessionList instance
  33945. * element_name: string
  33946. * base_url: string
  33947. * notebook_path: string
  33948. * contents: Contents instance
  33949. */
  33950. var that = this;
  33951. this.session_list = options.session_list;
  33952. this.events = this.session_list.events;
  33953. // allow code re-use by just changing element_name in kernellist.js
  33954. this.element_name = options.element_name || 'notebook';
  33955. this.selector = selector;
  33956. if (this.selector !== undefined) {
  33957. this.element = $(selector);
  33958. this.style();
  33959. this.bind_events();
  33960. }
  33961. this.notebooks_list = [];
  33962. this.sessions = {};
  33963. this.base_url = options.base_url || utils.get_body_data("baseUrl");
  33964. this.notebook_path = options.notebook_path || utils.get_body_data("notebookPath");
  33965. this.initial_notebook_path = this.notebook_path;
  33966. this.contents = options.contents;
  33967. if (this.session_list && this.session_list.events) {
  33968. this.session_list.events.on('sessions_loaded.Dashboard',
  33969. function(e, d) { that.sessions_loaded(d); });
  33970. }
  33971. this.selected = [];
  33972. this.sort_function = name_sorter(1);
  33973. // 0 => descending, 1 => ascending
  33974. this.sort_id = 'sort-name';
  33975. this.sort_direction = 1;
  33976. this._max_upload_size_mb = 25;
  33977. this.EDIT_MIMETYPES = [
  33978. 'application/javascript',
  33979. 'application/x-sh',
  33980. 'application/vnd.groove-tool-template'
  33981. ];
  33982. };
  33983. NotebookList.prototype.style = function () {
  33984. var prefix = '#' + this.element_name;
  33985. $(prefix + '_toolbar').addClass('list_toolbar');
  33986. $(prefix + '_list_info').addClass('toolbar_info');
  33987. $(prefix + '_buttons').addClass('toolbar_buttons');
  33988. $(prefix + '_list_header').addClass('list_header');
  33989. this.element.addClass("list_container");
  33990. };
  33991. NotebookList.prototype.bind_events = function () {
  33992. var that = this;
  33993. $('#refresh_' + this.element_name + '_list').click(function () {
  33994. that.load_sessions();
  33995. });
  33996. this.element.bind('dragover', function () {
  33997. return false;
  33998. });
  33999. this.element.bind('drop', function(event){
  34000. that.handleFilesUpload(event,'drop');
  34001. return false;
  34002. });
  34003. // Bind events for singleton controls.
  34004. if (!NotebookList._bound_singletons) {
  34005. NotebookList._bound_singletons = true;
  34006. $('#new-file').click(function(e) {
  34007. var w = window.open('', IPython._target);
  34008. that.contents.new_untitled(that.notebook_path || '', {type: 'file', ext: '.txt'}).then(function(data) {
  34009. w.location = utils.url_path_join(
  34010. that.base_url, 'edit',
  34011. utils.encode_uri_components(data.path)
  34012. );
  34013. }).catch(function (e) {
  34014. w.close();
  34015. dialog.modal({
  34016. title: i18n.msg._('Creating File Failed'),
  34017. body: $('<div/>')
  34018. .text(i18n.msg._("An error occurred while creating a new file."))
  34019. .append($('<div/>')
  34020. .addClass('alert alert-danger')
  34021. .text(e.message || e)),
  34022. buttons: {
  34023. OK: {'class': 'btn-primary'}
  34024. }
  34025. });
  34026. console.warn('Error during New file creation', e);
  34027. });
  34028. that.load_sessions();
  34029. e.preventDefault();
  34030. });
  34031. $('#new-folder').click(function(e) {
  34032. that.contents.new_untitled(that.notebook_path || '', {type: 'directory'})
  34033. .then(function(){
  34034. that.load_list();
  34035. }).catch(function (e) {
  34036. dialog.modal({
  34037. title: i18n.msg._('Creating Folder Failed'),
  34038. body: $('<div/>')
  34039. .text(i18n.msg._("An error occurred while creating a new folder."))
  34040. .append($('<div/>')
  34041. .addClass('alert alert-danger')
  34042. .text(e.message || e)),
  34043. buttons: {
  34044. OK: {'class': 'btn-primary'}
  34045. }
  34046. });
  34047. console.warn('Error during New directory creation', e);
  34048. });
  34049. that.load_sessions();
  34050. e.preventDefault();
  34051. });
  34052. // Bind events for action buttons.
  34053. $('.rename-button').click($.proxy(this.rename_selected, this));
  34054. $('.move-button').click($.proxy(this.move_selected, this));
  34055. $('.download-button').click($.proxy(this.download_selected, this));
  34056. $('.shutdown-button').click($.proxy(this.shutdown_selected, this));
  34057. $('.duplicate-button').click($.proxy(this.duplicate_selected, this));
  34058. $('.view-button').click($.proxy(this.view_selected, this));
  34059. $('.edit-button').click($.proxy(this.edit_selected, this));
  34060. $('.delete-button').click($.proxy(this.delete_selected, this));
  34061. // Bind events for selection menu buttons.
  34062. $('#selector-menu').click(function (event) {
  34063. that.select($(event.target).attr('id'));
  34064. });
  34065. var select_all = $('#select-all');
  34066. select_all.change(function () {
  34067. if (!select_all.prop('checked') || select_all.data('indeterminate')) {
  34068. that.select('select-none');
  34069. } else {
  34070. that.select('select-all');
  34071. }
  34072. });
  34073. $('#button-select-all').click(function (e) {
  34074. // toggle checkbox if the click doesn't come from the checkbox already
  34075. if (!$(e.target).is('input[type=checkbox]')) {
  34076. if (select_all.prop('checked') || select_all.data('indeterminate')) {
  34077. that.select('select-none');
  34078. } else {
  34079. that.select('select-all');
  34080. }
  34081. }
  34082. });
  34083. $('.sort-action').click(function(e) {
  34084. var sort_on = e.target.id;
  34085. // Clear sort indications in UI
  34086. $(".sort-action i").removeClass("fa-arrow-up").removeClass("fa-arrow-down");
  34087. if ((that.sort_id === sort_on) && (that.sort_direction === 1)) {
  34088. that.sort_list(sort_on, 0);
  34089. $("#" + sort_on + " i").addClass("fa-arrow-up");
  34090. that.sort_direction = 0;
  34091. } else {
  34092. that.sort_list(sort_on, 1);
  34093. $("#" + sort_on + " i").addClass("fa-arrow-down");
  34094. that.sort_direction = 1;
  34095. }
  34096. that.sort_id = sort_on;
  34097. });
  34098. }
  34099. };
  34100. NotebookList.prototype.sort_list = function(id, order) {
  34101. if (sort_functions.hasOwnProperty(id)) {
  34102. this.sort_function = sort_functions[id](order);
  34103. this.draw_notebook_list(this.model_list, this.error_msg);
  34104. } else {
  34105. console.error("No such sort id: '" + id + "'")
  34106. }
  34107. };
  34108. NotebookList.prototype.handleFilesUpload = function(event, dropOrForm) {
  34109. var that = this;
  34110. var files;
  34111. if(dropOrForm === 'drop'){
  34112. files = event.originalEvent.dataTransfer.files;
  34113. } else {
  34114. files = event.originalEvent.target.files;
  34115. }
  34116. var reader_onload = function (event) {
  34117. var item = $(event.target).data('item');
  34118. that.add_file_data(event.target.result, item);
  34119. that.add_upload_button(item);
  34120. };
  34121. var reader_onerror = function (event) {
  34122. var item = $(event.target).data('item');
  34123. var name = item.data('name');
  34124. item.remove();
  34125. dialog.modal({
  34126. title : i18n.msg._('Failed to read file'),
  34127. body : i18n.msg.sprintf(i18n.msg._("Failed to read file %s"),name),
  34128. buttons : {'OK' : { 'class' : 'btn-primary' }}
  34129. });
  34130. };
  34131. Array.from(files).forEach(function(f) {
  34132. var name_and_ext = utils.splitext(f.name);
  34133. var file_ext = name_and_ext[1];
  34134. if (f.size > that._max_upload_size_mb * 1024 * 1024) {
  34135. var body_msg = i18n.msg.sprintf(i18n.msg._("The file size is %d MB. Do you still want to upload it?"),
  34136. Math.round(f.size / (1024 * 1024)));
  34137. dialog.modal({
  34138. title : i18n.msg._('Large file size warning'),
  34139. body : body_msg,
  34140. buttons : {
  34141. Cancel: {},
  34142. Ok: {
  34143. class: "btn-primary",
  34144. click: function() {
  34145. that.add_large_file_upload_button(f);
  34146. }
  34147. }
  34148. }
  34149. });
  34150. }
  34151. else{
  34152. var reader = new FileReader();
  34153. if (file_ext === '.ipynb') {
  34154. reader.readAsText(f);
  34155. } else {
  34156. // read non-notebook files as binary
  34157. reader.readAsArrayBuffer(f);
  34158. }
  34159. var item = that.new_item(0, true);
  34160. item.addClass('new-file');
  34161. that.add_name_input(f.name, item, file_ext === '.ipynb' ? 'notebook' : 'file');
  34162. // Store the list item in the reader so we can use it later
  34163. // to know which item it belongs to.
  34164. $(reader).data('item', item);
  34165. reader.onload = reader_onload;
  34166. reader.onerror = reader_onerror;
  34167. }
  34168. });
  34169. // Clear fileinput value. This is required to
  34170. // reset the form. Otherwise, if you upload a file, delete it and try to
  34171. // upload it again, the changed event won't fire.
  34172. var form = $('input.fileinput');
  34173. form.val('');
  34174. return false;
  34175. };
  34176. NotebookList.prototype.clear_list = function (remove_uploads) {
  34177. /**
  34178. * Clears the navigation tree.
  34179. *
  34180. * Parameters
  34181. * remove_uploads: bool=False
  34182. * Should upload prompts also be removed from the tree.
  34183. */
  34184. if (remove_uploads) {
  34185. this.element.children('.list_item').remove();
  34186. } else {
  34187. this.element.children('.list_item:not(.new-file)').remove();
  34188. }
  34189. };
  34190. NotebookList.prototype.load_sessions = function(){
  34191. this.session_list.load_sessions();
  34192. };
  34193. NotebookList.prototype.sessions_loaded = function(data){
  34194. this.sessions = data;
  34195. this.load_list();
  34196. };
  34197. NotebookList.prototype.load_list = function () {
  34198. var that = this;
  34199. // Add an event handler browser back and forward events
  34200. window.onpopstate = function(e) {
  34201. var path = (window.history.state && window.history.state.path) ?
  34202. window.history.state.path : that.initial_notebook_path;
  34203. that.update_location(path);
  34204. };
  34205. var breadcrumb = $('.breadcrumb');
  34206. breadcrumb.empty();
  34207. var list_item = $('<li/>');
  34208. var root_url = utils.url_path_join(that.base_url, '/tree');
  34209. var root = $('<li/>').append(
  34210. $("<a/>")
  34211. .attr('href', root_url)
  34212. .append(
  34213. $("<i/>")
  34214. .addClass('fa fa-folder')
  34215. )
  34216. .click(function(e) {
  34217. // Allow the default browser action when the user holds a modifier (e.g., Ctrl-Click)
  34218. if(e.altKey || e.metaKey || e.shiftKey) {
  34219. return true;
  34220. }
  34221. var path = '';
  34222. window.history.pushState(
  34223. {path: path},
  34224. 'Home',
  34225. utils.url_path_join(that.base_url, 'tree')
  34226. );
  34227. that.update_location(path);
  34228. return false;
  34229. })
  34230. );
  34231. breadcrumb.append(root);
  34232. var path_parts = [];
  34233. this.notebook_path.split('/').forEach(function(path_part) {
  34234. path_parts.push(path_part);
  34235. var path = path_parts.join('/');
  34236. var url = utils.url_path_join(
  34237. that.base_url,
  34238. '/tree',
  34239. utils.encode_uri_components(path)
  34240. );
  34241. var crumb = $('<li/>').append(
  34242. $('<a/>')
  34243. .attr('href', url)
  34244. .text(path_part)
  34245. .click(function(e) {
  34246. // Allow the default browser action when the user holds a modifier (e.g., Ctrl-Click)
  34247. if(e.altKey || e.metaKey || e.shiftKey) {
  34248. return true;
  34249. }
  34250. window.history.pushState(
  34251. {path: path},
  34252. path,
  34253. url
  34254. );
  34255. that.update_location(path);
  34256. return false;
  34257. })
  34258. );
  34259. breadcrumb.append(crumb);
  34260. });
  34261. this.contents.list_contents(that.notebook_path).then(
  34262. $.proxy(this.draw_notebook_list, this),
  34263. function(error) {
  34264. that.draw_notebook_list({content: []}, i18n.msg._("Server error: ") + error.message);
  34265. }
  34266. );
  34267. };
  34268. NotebookList.prototype.update_location = function (path) {
  34269. this.notebook_path = path;
  34270. $('body').attr('data-notebook-path', path);
  34271. // Update the file tree list without reloading the page
  34272. this.load_list();
  34273. // Update the page title so the browser tab reflects it
  34274. // Match how the title appears with a trailing slash or
  34275. // "Home" if the page loads from the server.
  34276. $('title').text(path ? path+'/' : i18n.msg._("Home"));
  34277. };
  34278. /**
  34279. * Draw the list of notebooks
  34280. * @method draw_notebook_list
  34281. * @param {Array} list An array of dictionaries representing files or
  34282. * directories.
  34283. * @param {String} error_msg An error message
  34284. */
  34285. var type_order = {'directory':0,'notebook':1,'file':2};
  34286. NotebookList.prototype.draw_notebook_list = function (list, error_msg) {
  34287. // Remember what was selected before the refresh.
  34288. var selected_before = this.selected;
  34289. // Store the data to be redrawn by sorting
  34290. this.model_list = list;
  34291. this.error_msg = error_msg;
  34292. list.content.sort(this.sort_function);
  34293. var message = error_msg || i18n.msg._('The notebook list is empty.');
  34294. var item = null;
  34295. var model = null;
  34296. var len = list.content.length;
  34297. this.clear_list();
  34298. var n_uploads = this.element.children('.list_item').length;
  34299. if (len === 0) {
  34300. item = this.new_item(0);
  34301. var span12 = item.children().first();
  34302. span12.empty();
  34303. span12.append($('<div style="margin:auto;text-align:center;color:grey"/>').text(message));
  34304. }
  34305. var path = this.notebook_path;
  34306. var offset = n_uploads;
  34307. if (path !== '') {
  34308. item = this.new_item(offset, false);
  34309. model = {
  34310. type: 'directory',
  34311. name: '..',
  34312. path: utils.url_path_split(path)[0]
  34313. };
  34314. this.add_link(model, item);
  34315. offset += 1;
  34316. }
  34317. for (var i=0; i<len; i++) {
  34318. model = list.content[i];
  34319. item = this.new_item(i+offset, true);
  34320. try {
  34321. this.add_link(model, item);
  34322. } catch(err) {
  34323. console.log('Error adding link: ' + err);
  34324. }
  34325. }
  34326. // Trigger an event when we've finished drawing the notebook list.
  34327. events.trigger('draw_notebook_list.NotebookList');
  34328. // Reselect the items that were selected before. Notify listeners
  34329. // that the selected items may have changed. O(n^2) operation.
  34330. selected_before.forEach(function(item) {
  34331. var list_items = $('.list_item');
  34332. for (var i=0; i<list_items.length; i++) {
  34333. var $list_item = $(list_items[i]);
  34334. if ($list_item.data('path') === item.path) {
  34335. $list_item.find('input[type=checkbox]').prop('checked', true);
  34336. break;
  34337. }
  34338. }
  34339. });
  34340. this._selection_changed();
  34341. };
  34342. /**
  34343. * Creates a new item.
  34344. * @param {integer} index
  34345. * @param {boolean} [selectable] - tristate, undefined: don't draw checkbox,
  34346. * false: don't draw checkbox but pad
  34347. * where it should be, true: draw checkbox.
  34348. * @return {JQuery} row
  34349. */
  34350. NotebookList.prototype.new_item = function (index, selectable) {
  34351. var row = $('<div/>')
  34352. .addClass("list_item")
  34353. .addClass("row");
  34354. var item = $("<div/>")
  34355. .addClass("col-md-12")
  34356. .appendTo(row);
  34357. var checkbox;
  34358. if (selectable !== undefined) {
  34359. checkbox = $('<input/>')
  34360. .attr('type', 'checkbox')
  34361. .attr('title', i18n.msg._('Click here to rename, delete, etc.'))
  34362. .appendTo(item);
  34363. }
  34364. $('<i/>')
  34365. .addClass('item_icon')
  34366. .appendTo(item);
  34367. var link = $("<a/>")
  34368. .addClass("item_link")
  34369. .appendTo(item);
  34370. $("<span/>")
  34371. .addClass("item_name")
  34372. .appendTo(link);
  34373. $("<span/>")
  34374. .addClass("file_size")
  34375. .addClass("pull-right")
  34376. .appendTo(item);
  34377. $("<span/>")
  34378. .addClass("item_modified")
  34379. .addClass("pull-right")
  34380. .appendTo(item);
  34381. if (selectable === false) {
  34382. checkbox.css('visibility', 'hidden');
  34383. } else if (selectable === true) {
  34384. var that = this;
  34385. row.click(function(e) {
  34386. // toggle checkbox only if the click doesn't come from the checkbox or the link
  34387. if (!$(e.target).is('span[class=item_name]') && !$(e.target).is('input[type=checkbox]')) {
  34388. checkbox.prop('checked', !checkbox.prop('checked'));
  34389. }
  34390. that._selection_changed();
  34391. });
  34392. }
  34393. var buttons = $('<div/>')
  34394. .addClass("item_buttons pull-right")
  34395. .appendTo(item);
  34396. $('<div/>')
  34397. .addClass('running-indicator')
  34398. .text(i18n.msg._('Running'))
  34399. .css('visibility', 'hidden')
  34400. .appendTo(buttons);
  34401. if (index === -1) {
  34402. this.element.append(row);
  34403. } else {
  34404. this.element.children().eq(index).after(row);
  34405. }
  34406. return row;
  34407. };
  34408. NotebookList.icons = {
  34409. directory: 'folder_icon',
  34410. notebook: 'notebook_icon',
  34411. file: 'file_icon'
  34412. };
  34413. NotebookList.uri_prefixes = {
  34414. directory: 'tree',
  34415. notebook: 'notebooks',
  34416. file: 'edit'
  34417. };
  34418. /**
  34419. * Select all items in the tree of specified type.
  34420. * selection_type : string among "select-all", "select-folders", "select-notebooks", "select-running-notebooks", "select-files"
  34421. * any other string (like "select-none") deselects all items
  34422. */
  34423. NotebookList.prototype.select = function(selection_type) {
  34424. var that = this;
  34425. $('.list_item').each(function(index, item) {
  34426. var item_type = $(item).data('type');
  34427. var state = false;
  34428. state = state || (selection_type === "select-all");
  34429. state = state || (selection_type === "select-folders" && item_type === 'directory');
  34430. state = state || (selection_type === "select-notebooks" && item_type === 'notebook');
  34431. state = state || (selection_type === "select-running-notebooks" && item_type === 'notebook' && that.sessions[$(item).data('path')] !== undefined);
  34432. state = state || (selection_type === "select-files" && item_type === 'file');
  34433. $(item).find('input[type=checkbox]').prop('checked', state);
  34434. });
  34435. this._selection_changed();
  34436. };
  34437. NotebookList.prototype._is_notebook = function(model) {
  34438. var ipynb_extensions = ['ipynb'];
  34439. return includes_extension(model.path, ipynb_extensions);
  34440. };
  34441. NotebookList.prototype._is_editable = function(model) {
  34442. // Allow any file to be "edited"
  34443. // Non-text files will display the following error:
  34444. // Error: [FILE] is not UTF-8 encoded
  34445. // Saving is disabled.
  34446. // See Console for more details.
  34447. return true;
  34448. };
  34449. NotebookList.prototype._is_viewable = function(model) {
  34450. var html_types = ['htm', 'html', 'xhtml', 'xml', 'mht', 'mhtml'];
  34451. var media_extension = ['3gp', 'avi', 'mov', 'mp4', 'm4v', 'm4a', 'mp3', 'mkv', 'ogv', 'ogm', 'ogg', 'oga', 'webm', 'wav'];
  34452. var image_type = ['bmp', 'gif', 'jpg', 'jpeg', 'png', 'webp'];
  34453. var other_type = ['ico'];
  34454. var viewable_extensions = [].concat(html_types, media_extension, image_type, other_type);
  34455. return model.mimetype === 'text/html'
  34456. || includes_extension(model.path, viewable_extensions);
  34457. };
  34458. // Files like PDF that should be opened using `/files` prefix
  34459. NotebookList.prototype._is_pdflike = function(model) {
  34460. var pdflike_extensions = ['pdf'];
  34461. return includes_extension(model.path, pdflike_extensions);
  34462. };
  34463. /**
  34464. * Handles when any row selector checkbox is toggled.
  34465. */
  34466. NotebookList.prototype._selection_changed = function() {
  34467. // Use a JQuery selector to find each row with a checked checkbox. If
  34468. // we decide to add more checkboxes in the future, this code will need
  34469. // to be changed to distinguish which checkbox is the row selector.
  34470. var that = this;
  34471. var selected = [];
  34472. var has_running_notebook = false;
  34473. var has_directory = false;
  34474. var has_file = false;
  34475. var checked = 0;
  34476. $('.list_item :checked').each(function(index, item) {
  34477. var parent = $(item).parent().parent();
  34478. // If the item doesn't have an upload button, isn't the
  34479. // breadcrumbs and isn't the parent folder '..', then it can be selected.
  34480. // Breadcrumbs path == ''.
  34481. if (parent.find('.upload_button').length === 0 && parent.data('path') !== '' && parent.data('path') !== utils.url_path_split(that.notebook_path)[0]) {
  34482. checked++;
  34483. selected.push({
  34484. name: parent.data('name'),
  34485. path: parent.data('path'),
  34486. type: parent.data('type')
  34487. });
  34488. // Set flags according to what is selected. Flags are later
  34489. // used to decide which action buttons are visible.
  34490. has_running_notebook = has_running_notebook ||
  34491. (parent.data('type') === 'notebook' && that.sessions[parent.data('path')] !== undefined);
  34492. has_file = has_file || (parent.data('type') === 'file');
  34493. has_directory = has_directory || (parent.data('type') === 'directory');
  34494. }
  34495. });
  34496. this.selected = selected;
  34497. // Rename is only visible when one item is selected, and it is not a running notebook
  34498. if (selected.length === 1 && !has_running_notebook) {
  34499. $('.rename-button').css('display', 'inline-block');
  34500. } else {
  34501. $('.rename-button').css('display', 'none');
  34502. }
  34503. // Move is visible if at least one item is selected, and none of them
  34504. // are a running notebook.
  34505. if (selected.length > 0 && !has_running_notebook) {
  34506. $('.move-button').css('display', 'inline-block');
  34507. } else {
  34508. $('.move-button').css('display', 'none');
  34509. }
  34510. // Download is only visible when one item is selected, and it is not a
  34511. // running notebook or a directory
  34512. // TODO(nhdaly): Add support for download multiple items at once.
  34513. if (selected.length === 1 && !has_running_notebook && !has_directory) {
  34514. $('.download-button').css('display', 'inline-block');
  34515. } else {
  34516. $('.download-button').css('display', 'none');
  34517. }
  34518. // Shutdown is only visible when one or more notebooks running notebooks
  34519. // are selected and no non-notebook items are selected.
  34520. if (has_running_notebook && !(has_file || has_directory)) {
  34521. $('.shutdown-button').css('display', 'inline-block');
  34522. } else {
  34523. $('.shutdown-button').css('display', 'none');
  34524. }
  34525. // Duplicate isn't visible when a directory is selected.
  34526. if (selected.length > 0 && !has_directory) {
  34527. $('.duplicate-button').css('display', 'inline-block');
  34528. } else {
  34529. $('.duplicate-button').css('display', 'none');
  34530. }
  34531. // Delete is visible if one or more items are selected.
  34532. if (selected.length > 0) {
  34533. $('.delete-button').css('display', 'inline-block');
  34534. } else {
  34535. $('.delete-button').css('display', 'none');
  34536. }
  34537. // View is visible in the following case:
  34538. //
  34539. // - the item is editable
  34540. // - it is not a notebook
  34541. //
  34542. // If it's not editable or unknown, the default action should be view
  34543. // already so no need to show the button.
  34544. // That should include things like, html, py, txt, json....
  34545. if (selected.length >= 1 && !has_directory) {
  34546. $('.view-button').css('display', 'inline-block');
  34547. } else {
  34548. $('.view-button').css('display', 'none');
  34549. }
  34550. // Edit is visible when an item is unknown, that is to say:
  34551. // - not in the editable list
  34552. // - not in the known non-editable list.
  34553. // - not a notebook.
  34554. // Indeed if it's editable the default action is already to edit.
  34555. // And non editable files should not show edit button.
  34556. // for unknown we'll assume users know what they are doing.
  34557. if (selected.length >= 1 && !has_directory && selected.every(function(el) {
  34558. return that._is_editable(el);
  34559. })) {
  34560. $('.edit-button').css('display', 'inline-block');
  34561. } else {
  34562. $('.edit-button').css('display', 'none');
  34563. }
  34564. // If all of the items are selected, show the selector as checked. If
  34565. // some of the items are selected, show it as checked. Otherwise,
  34566. // uncheck it.
  34567. var total = 0;
  34568. $('.list_item input[type=checkbox]').each(function(index, item) {
  34569. var parent = $(item).parent().parent();
  34570. // If the item doesn't have an upload button and it's not the
  34571. // breadcrumbs, it can be selected. Breadcrumbs path == ''.
  34572. if (parent.find('.upload_button').length === 0 && parent.data('path') !== '' && parent.data('path') !== utils.url_path_split(that.notebook_path)[0]) {
  34573. total++;
  34574. }
  34575. });
  34576. var select_all = $("#select-all");
  34577. if (checked === 0) {
  34578. select_all.prop('checked', false);
  34579. select_all.prop('indeterminate', false);
  34580. select_all.data('indeterminate', false);
  34581. } else if (checked === total) {
  34582. select_all.prop('checked', true);
  34583. select_all.prop('indeterminate', false);
  34584. select_all.data('indeterminate', false);
  34585. } else {
  34586. select_all.prop('checked', false);
  34587. select_all.prop('indeterminate', true);
  34588. select_all.data('indeterminate', true);
  34589. }
  34590. // Update total counter
  34591. checked = bidi.applyBidi(checked);
  34592. $('#counter-select-all').html(checked===0 ? '&nbsp;' : checked);
  34593. // If at aleast on item is selected, hide the selection instructions.
  34594. if (checked > 0) {
  34595. $('.dynamic-instructions').hide();
  34596. } else {
  34597. $('.dynamic-instructions').show();
  34598. }
  34599. };
  34600. NotebookList.prototype.add_link = function (model, item) {
  34601. var that = this;
  34602. var running = (model.type === 'notebook' && this.sessions[model.path] !== undefined);
  34603. item.data('name',model.name);
  34604. item.data('path', model.path);
  34605. item.data('modified', model.last_modified);
  34606. item.data('type', model.type);
  34607. item.find(".item_name").text(bidi.applyBidi(model.name));
  34608. var icon = NotebookList.icons[model.type];
  34609. if (running) {
  34610. icon = 'running_' + icon;
  34611. }
  34612. var uri_prefix = NotebookList.uri_prefixes[model.type];
  34613. if (model.type === 'file' && this._is_viewable(model))
  34614. {
  34615. uri_prefix = 'view';
  34616. }
  34617. if (model.type === 'file' && this._is_pdflike(model))
  34618. {
  34619. uri_prefix = 'files';
  34620. }
  34621. if (model.type === 'file' && this._is_notebook(model))
  34622. {
  34623. uri_prefix = 'notebooks';
  34624. }
  34625. item.find(".item_icon").addClass(icon).addClass('icon-fixed-width');
  34626. var link = item.find("a.item_link")
  34627. .attr('href',
  34628. utils.url_path_join(
  34629. this.base_url,
  34630. uri_prefix,
  34631. utils.encode_uri_components(model.path)
  34632. )
  34633. );
  34634. item.find(".item_buttons .running-indicator").css('visibility', running ? '' : 'hidden');
  34635. // directory nav doesn't open new tabs
  34636. // files, notebooks do
  34637. if (model.type !== "directory") {
  34638. link.attr('target', IPython._target);
  34639. } else {
  34640. // Replace with a click handler that will use the History API to
  34641. // push a new route without reloading the page if the click is
  34642. // not modified (e.g., Ctrl-Click)
  34643. link.click(function (e) {
  34644. if(e.altKey || e.metaKey || e.shiftKey) {
  34645. return true;
  34646. }
  34647. window.history.pushState({
  34648. path: model.path
  34649. }, model.path, utils.url_path_join(
  34650. that.base_url,
  34651. 'tree',
  34652. utils.encode_uri_components(model.path)
  34653. ));
  34654. that.update_location(model.path);
  34655. return false;
  34656. });
  34657. }
  34658. // Add in the date that the file was last modified
  34659. item.find(".item_modified").text(utils.format_datetime(model.last_modified));
  34660. item.find(".item_modified").attr("title", moment(model.last_modified).format("YYYY-MM-DD HH:mm"));
  34661. var filesize = utils.format_filesize(model.size);
  34662. item.find(".file_size").text(filesize || '\xA0');
  34663. };
  34664. NotebookList.prototype.add_name_input = function (name, item, icon_type) {
  34665. item.data('name', name);
  34666. item.find(".item_icon").addClass(NotebookList.icons[icon_type]).addClass('icon-fixed-width');
  34667. item.find(".item_name").empty().append(
  34668. $('<input/>')
  34669. .addClass("filename_input")
  34670. .attr('value', name)
  34671. .attr('size', '30')
  34672. .attr('type', 'text')
  34673. .keyup(function(event){
  34674. if(event.keyCode === 13){item.find('.upload_button').click();}
  34675. else if(event.keyCode === 27){item.remove();}
  34676. })
  34677. );
  34678. };
  34679. NotebookList.prototype.add_file_data = function (data, item) {
  34680. item.data('filedata', data);
  34681. };
  34682. NotebookList.prototype.shutdown_selected = function() {
  34683. var that = this;
  34684. this.selected.forEach(function(item) {
  34685. if (item.type === 'notebook') {
  34686. that.shutdown_notebook(item.path);
  34687. }
  34688. });
  34689. // Deselect items after successful shutdown.
  34690. that.select('select-none');
  34691. };
  34692. NotebookList.prototype.shutdown_notebook = function(path) {
  34693. var that = this;
  34694. var settings = {
  34695. processData : false,
  34696. cache : false,
  34697. type : "DELETE",
  34698. dataType : "json",
  34699. success : function () {
  34700. that.load_sessions();
  34701. },
  34702. error : utils.log_ajax_error
  34703. };
  34704. var session = this.sessions[path];
  34705. if (session) {
  34706. var url = utils.url_path_join(
  34707. this.base_url,
  34708. 'api/sessions',
  34709. encodeURIComponent(session.id)
  34710. );
  34711. utils.ajax(url, settings);
  34712. }
  34713. };
  34714. NotebookList.prototype.rename_selected = function() {
  34715. if (this.selected.length !== 1){
  34716. return;
  34717. }
  34718. var that = this;
  34719. var item_path = this.selected[0].path;
  34720. var item_name = this.selected[0].name;
  34721. var item_type = this.selected[0].type;
  34722. var input = $('<input/>').attr('type','text').attr('size','25').addClass('form-control')
  34723. .val(item_name);
  34724. var rename_msg = function (type) {
  34725. switch(type) {
  34726. case 'file': return i18n.msg._("Enter a new file name:");
  34727. case 'directory': return i18n.msg._("Enter a new directory name:");
  34728. case 'notebook': return i18n.msg._("Enter a new notebook name:");
  34729. default: return i18n.msg._("Enter a new name:");
  34730. }
  34731. };
  34732. var rename_title = function (type) {
  34733. switch(type) {
  34734. case 'file': return i18n.msg._("Rename file");
  34735. case 'directory': return i18n.msg._("Rename directory");
  34736. case 'notebook': return i18n.msg._("Rename notebook");
  34737. default: return i18n.msg._("Rename");
  34738. }
  34739. };
  34740. var dialog_body = $('<div/>').append(
  34741. $("<p/>").addClass("rename-message")
  34742. .text(rename_msg(item_type))
  34743. ).append(
  34744. $("<br/>")
  34745. ).append(input);
  34746. // This statement is used simply so that message extraction
  34747. // will pick up the strings. The actual setting of the text
  34748. // for the button is in dialog.js.
  34749. var button_labels = [ i18n.msg._("Cancel"), i18n.msg._("Rename"), i18n.msg._("OK"), i18n.msg._("Move")];
  34750. var d = dialog.modal({
  34751. title : rename_title(item_type),
  34752. body : dialog_body,
  34753. default_button: "Cancel",
  34754. buttons : {
  34755. Cancel: {},
  34756. Rename : {
  34757. class: "btn-primary",
  34758. click: function() {
  34759. that.contents.rename(item_path, utils.url_path_join(that.notebook_path, input.val())).then(function() {
  34760. that.load_list();
  34761. // Deselect items after successful rename.
  34762. that.select('select-none');
  34763. }).catch(function(e) {
  34764. var template = i18n.msg._("An error occurred while renaming \"%1$s\" to \"%2$s\".");
  34765. var failmsg = i18n.msg.sprintf(template,item_name,input.val());
  34766. dialog.modal({
  34767. title: i18n.msg._("Rename Failed"),
  34768. body: $('<div/>')
  34769. .text(failmsg)
  34770. .append($('<div/>')
  34771. .addClass('alert alert-danger')
  34772. .text(e.message || e)),
  34773. buttons: {
  34774. OK: {'class': 'btn-primary'}
  34775. }
  34776. });
  34777. console.warn('Error during renaming :', e);
  34778. });
  34779. }
  34780. }
  34781. },
  34782. open : function () {
  34783. // Upon ENTER, click the OK button.
  34784. input.keydown(function (event) {
  34785. if (event.which === keyboard.keycodes.enter) {
  34786. d.find('.btn-primary').first().click();
  34787. return false;
  34788. }
  34789. });
  34790. input.focus();
  34791. // Highlight the filename (up to the filetype suffix) in the input field.
  34792. if (input.val().indexOf(".") > 0) {
  34793. input[0].setSelectionRange(0,input.val().indexOf("."));
  34794. } else {
  34795. input.select();
  34796. }
  34797. }
  34798. });
  34799. };
  34800. NotebookList.prototype.move_selected = function() {
  34801. var that = this;
  34802. var selected = that.selected.slice(); // Don't let that.selected change out from under us
  34803. var num_items = selected.length;
  34804. // Can move one or more selected items.
  34805. if (!(num_items >= 1)) {
  34806. return;
  34807. }
  34808. // Open a dialog to enter the new path, with current path as default.
  34809. var input = $('<input/>').attr('type','text').attr('size','25').addClass('form-control')
  34810. .val(utils.url_path_join('/', that.notebook_path));
  34811. var dialog_body = $('<div/>').append(
  34812. $("<p/>").addClass("rename-message")
  34813. .text(i18n.msg.sprintf(i18n.msg.ngettext("Enter a new destination directory path for this item:",
  34814. "Enter a new destination directory path for these %d items:", num_items),num_items))
  34815. ).append(
  34816. $("<br/>")
  34817. ).append(
  34818. $("<div/>").append(
  34819. // $("<i/>").addClass("fa fa-folder").addClass("server-root")
  34820. $("<span/>").text(utils.get_body_data("serverRoot")).addClass("server-root")
  34821. ).append(
  34822. input.addClass("path-input")
  34823. ).addClass("move-path")
  34824. );
  34825. var d = dialog.modal({
  34826. title : i18n.msg.sprintf(i18n.msg.ngettext("Move an Item","Move %d Items",num_items),num_items),
  34827. body : dialog_body,
  34828. default_button: "Cancel",
  34829. buttons : {
  34830. Cancel : {},
  34831. Move : {
  34832. class: "btn-primary",
  34833. click: function() {
  34834. // Move all the items.
  34835. selected.forEach(function(item) {
  34836. var item_path = item.path;
  34837. var item_name = item.name;
  34838. // Construct the new path using the user input and the item's name.
  34839. var new_path = utils.url_path_join(input.val(), item_name);
  34840. that.contents.rename(item_path, new_path).then(function() {
  34841. // After each move finishes, reload the list.
  34842. that.load_list();
  34843. }).catch(function(e) {
  34844. // If any of the moves fails, show this dialog for that move.
  34845. var failmsg = i18n.msg._("An error occurred while moving \"%1$s\" from \"%2$s\" to \"%3$s\".");
  34846. dialog.modal({
  34847. title: i18n.msg._("Move Failed"),
  34848. body: $('<div/>')
  34849. .text(i18n.msg.sprintf(failmsg,item_name,item_path,new_path))
  34850. .append($('<div/>')
  34851. .addClass('alert alert-danger')
  34852. .text(e.message || e)),
  34853. buttons: {
  34854. OK: {'class': 'btn-primary'}
  34855. }
  34856. });
  34857. console.warn('Error during moving :', e);
  34858. });
  34859. }); // End of forEach.
  34860. }
  34861. }
  34862. },
  34863. // TODO: Consider adding fancier UI per Issue #941.
  34864. open : function () {
  34865. // Upon ENTER, click the OK button.
  34866. input.keydown(function (event) {
  34867. if (event.which === keyboard.keycodes.enter) {
  34868. d.find('.btn-primary').first().click();
  34869. return false;
  34870. }
  34871. });
  34872. // Put the cursor at the end of the input.
  34873. input.focus();
  34874. }
  34875. });
  34876. };
  34877. NotebookList.prototype.download_selected = function() {
  34878. var that = this;
  34879. // TODO(nhdaly): Support download multiple items at once.
  34880. if (that.selected.length !== 1){
  34881. return;
  34882. }
  34883. var item_path = that.selected[0].path;
  34884. window.open(utils.url_path_join(that.base_url, 'files', utils.encode_uri_components(item_path)) + '?download=1', IPython._target);
  34885. };
  34886. NotebookList.prototype.delete_selected = function() {
  34887. var selected = this.selected.slice(); // Don't let that.selected change out from under us
  34888. var template = i18n.msg.ngettext("Are you sure you want to permanently delete: \"%s\"?",
  34889. "Are you sure you want to permanently delete the %d files or folders selected?",
  34890. selected.length);
  34891. var delete_msg;
  34892. if (selected.length === 1) {
  34893. delete_msg = i18n.msg.sprintf(template, selected[0].name);
  34894. } else {
  34895. delete_msg = i18n.msg.sprintf(template, selected.length);
  34896. }
  34897. var that = this;
  34898. dialog.modal({
  34899. title : i18n.msg._("Delete"),
  34900. body : delete_msg,
  34901. default_button: "Cancel",
  34902. buttons : {
  34903. Cancel: {},
  34904. Delete : {
  34905. class: "btn-danger",
  34906. click: function() {
  34907. // Shutdown any/all selected notebooks before deleting
  34908. // the files.
  34909. that.shutdown_selected();
  34910. // Delete selected.
  34911. selected.forEach(function(item) {
  34912. that.contents.delete(item.path).then(function() {
  34913. that.notebook_deleted(item.path);
  34914. }).catch(function(e) {
  34915. var failmsg = i18n.msg._("An error occurred while deleting \"%s\".");
  34916. dialog.modal({
  34917. title: i18n.msg._("Delete Failed"),
  34918. body: $('<div/>')
  34919. .text(i18n.msg.sprintf(failmsg, item.path))
  34920. .append($('<div/>')
  34921. .addClass('alert alert-danger')
  34922. .text(e.message || e)),
  34923. buttons: {
  34924. OK: {'class': 'btn-primary'}
  34925. }
  34926. });
  34927. console.warn('Error during content deletion:', e);
  34928. });
  34929. });
  34930. }
  34931. }
  34932. }
  34933. });
  34934. };
  34935. NotebookList.prototype.view_selected = function() {
  34936. var that = this;
  34937. that.selected.forEach(function(item) {
  34938. var item_path = utils.encode_uri_components(item.path);
  34939. var item_type = that._is_notebook(item) ? 'notebooks' : that._is_viewable(item) ? 'view' : 'files';
  34940. window.open(utils.url_path_join(that.base_url, item_type, item_path), IPython._target);
  34941. });
  34942. };
  34943. NotebookList.prototype.edit_selected = function() {
  34944. var that = this;
  34945. that.selected.forEach(function(item) {
  34946. var item_path = utils.encode_uri_components(item.path);
  34947. window.open(utils.url_path_join(that.base_url, 'edit', item_path), IPython._target);
  34948. });
  34949. };
  34950. NotebookList.prototype.duplicate_selected = function() {
  34951. var selected = this.selected.slice(); // Don't let that.selected change out from under us
  34952. var template = i18n.msg.ngettext("Are you sure you want to duplicate: \"%s\"?",
  34953. "Are you sure you want to duplicate the %d files selected?",selected.length);
  34954. var dup_msg;
  34955. if (selected.length === 1) {
  34956. dup_msg = i18n.msg.sprintf(template,selected[0].name);
  34957. } else {
  34958. dup_msg = i18n.msg.sprintf(template,selected.length);
  34959. }
  34960. var that = this;
  34961. dialog.modal({
  34962. title : i18n.msg._("Duplicate"),
  34963. body : dup_msg,
  34964. default_button: "Cancel",
  34965. buttons : {
  34966. Cancel: {},
  34967. Duplicate : {
  34968. class: "btn-primary",
  34969. click: function() {
  34970. selected.forEach(function(item) {
  34971. that.contents.copy(item.path, that.notebook_path).then(function () {
  34972. that.load_list();
  34973. // Deselect items after successful duplication.
  34974. that.select('select-none');
  34975. }).catch(function(e) {
  34976. var failmsg = i18n.msg._("An error occurred while duplicating \"%s\".");
  34977. dialog.modal({
  34978. title: i18n.msg._("Duplicate Failed"),
  34979. body: $('<div/>')
  34980. .text(i18n.msg.sprintf(failmsg,item.path))
  34981. .append($('<div/>')
  34982. .addClass('alert alert-danger')
  34983. .text(e.message || e)),
  34984. buttons: {
  34985. OK: {'class': 'btn-primary'}
  34986. }
  34987. });
  34988. console.warn('Error during content duplication', e);
  34989. });
  34990. });
  34991. }
  34992. }
  34993. }
  34994. });
  34995. };
  34996. NotebookList.prototype.notebook_deleted = function(path) {
  34997. /**
  34998. * Remove the deleted notebook.
  34999. */
  35000. var that = this;
  35001. $(".list_item").each(function() {
  35002. var element = $(this);
  35003. if (element.data("path") === path) {
  35004. element.remove();
  35005. events.trigger('notebook_deleted.NotebookList');
  35006. that._selection_changed();
  35007. }
  35008. });
  35009. };
  35010. // Add a new class for large file upload
  35011. NotebookList.prototype.add_large_file_upload_button = function (file) {
  35012. var that = this;
  35013. var item = that.new_item(0, true);
  35014. var stop_signal = false;
  35015. item.addClass('new-file');
  35016. that.add_name_input(file.name, item, 'file');
  35017. var cancel_button = $('<button/>').text("Cancel")
  35018. .addClass("btn btn-default btn-xs")
  35019. .click(function (e) {
  35020. item.remove();
  35021. stop_signal = true;
  35022. return false;
  35023. });
  35024. var upload_button = $('<button/>').text("Upload")
  35025. .addClass('btn btn-primary btn-xs upload_button')
  35026. .click(function (e) {
  35027. var filename = item.find('.item_name > input').val();
  35028. var path = utils.url_path_join(that.notebook_path, filename);
  35029. var format = 'text';
  35030. if (filename.length === 0 || filename[0] === '.') {
  35031. dialog.modal({
  35032. title : 'Invalid file name',
  35033. body : "File names must be at least one character and not start with a dot",
  35034. buttons : {'OK' : { 'class' : 'btn-primary' }}
  35035. });
  35036. return false;
  35037. }
  35038. var check_exist = function () {
  35039. var exists = false;
  35040. $.each(that.element.find('.list_item:not(.new-file)'), function(k,v){
  35041. if ($(v).data('name') === filename) { exists = true; return false; }
  35042. });
  35043. return exists
  35044. };
  35045. var exists = check_exist();
  35046. var add_uploading_button = function (f, item) {
  35047. // change buttons, add a progress bar
  35048. var uploading_button = item.find('.upload_button').text("Uploading");
  35049. uploading_button.off('click'); // Prevent double upload
  35050. var progress_bar = $('<span/>')
  35051. .addClass('progress-bar')
  35052. .css('top', '0')
  35053. .css('left', '0')
  35054. .css('width', '0')
  35055. .css('height', '3px')
  35056. .css('border-radius', '0 0 0 0')
  35057. .css('display', 'inline-block')
  35058. .css('position', 'absolute');
  35059. var parse_large_file = function (f, item) {
  35060. // codes inspired by https://stackoverflow.com/a/28318964
  35061. var chunk_size = 1024 * 1024;
  35062. var offset = 0;
  35063. var chunk = 0;
  35064. var chunk_reader = null;
  35065. var large_reader_onload = function (event) {
  35066. if (stop_signal === true) {
  35067. return;
  35068. }
  35069. if (event.target.error == null) {
  35070. offset += chunk_size;
  35071. if (offset >= f.size) {
  35072. chunk = -1;
  35073. } else {
  35074. chunk += 1;
  35075. }
  35076. // callback for handling reading: reader_onload in add_upload_button
  35077. var item = $(event.target).data('item');
  35078. that.add_file_data(event.target.result, item);
  35079. upload_file(item, chunk); // Do the upload
  35080. } else {
  35081. console.log("Read error: " + event.target.error);
  35082. }
  35083. };
  35084. var on_error = function (event) {
  35085. var item = $(event.target).data('item');
  35086. var name = item.data('name');
  35087. item.remove();
  35088. var _exists = check_exist();
  35089. if (_exists) {
  35090. that.contents.delete(path);
  35091. }
  35092. dialog.modal({
  35093. title : 'Failed to read file',
  35094. body : "Failed to read file '" + name + "'",
  35095. buttons : {'OK' : { 'class' : 'btn-primary' }}
  35096. });
  35097. };
  35098. chunk_reader = function (_offset, _f) {
  35099. var reader = new FileReader();
  35100. var blob = _f.slice(_offset, chunk_size + _offset);
  35101. // Load everything as ArrayBuffer
  35102. reader.readAsArrayBuffer(blob);
  35103. // Store the list item in the reader so we can use it later
  35104. // to know which item it belongs to.
  35105. $(reader).data('item', item);
  35106. reader.onload = large_reader_onload;
  35107. reader.onerror = on_error;
  35108. };
  35109. // These codes to upload file in original class
  35110. var upload_file = function(item, chunk) {
  35111. var filedata = item.data('filedata');
  35112. if (filedata instanceof ArrayBuffer) {
  35113. // base64-encode binary file data
  35114. var bytes = '';
  35115. var buf = new Uint8Array(filedata);
  35116. var nbytes = buf.byteLength;
  35117. for (var i=0; i<nbytes; i++) {
  35118. bytes += String.fromCharCode(buf[i]);
  35119. }
  35120. filedata = btoa(bytes);
  35121. format = 'base64';
  35122. }
  35123. var model = { name: filename, path: path };
  35124. var name_and_ext = utils.splitext(filename);
  35125. var file_ext = name_and_ext[1];
  35126. var content_type;
  35127. // Treat everything as generic file
  35128. model.type = 'file';
  35129. model.format = format;
  35130. content_type = 'application/octet-stream';
  35131. model.chunk = chunk;
  35132. model.content = filedata;
  35133. var on_success = function () {
  35134. if (offset < f.size) {
  35135. // of to the next chunk
  35136. chunk_reader(offset, f);
  35137. // change progress bar and progress button
  35138. var progress = offset / f.size * 100;
  35139. progress = progress > 100 ? 100 : progress;
  35140. uploading_button.text(progress.toFixed(0)+'%');
  35141. progress_bar.css('width', progress+'%')
  35142. .attr('aria-valuenow', progress.toString());
  35143. } else {
  35144. item.removeClass('new-file');
  35145. that.add_link(model, item);
  35146. that.session_list.load_sessions();
  35147. }
  35148. };
  35149. that.contents.save(path, model).then(on_success, on_error);
  35150. };
  35151. // now let's start the read with the first block
  35152. chunk_reader(offset, f);
  35153. };
  35154. item.find('.item_buttons')
  35155. .append(progress_bar);
  35156. parse_large_file(f, item);
  35157. };
  35158. if (exists) {
  35159. dialog.modal({
  35160. title : "Replace file",
  35161. body : 'There is already a file named ' + filename + ', do you want to replace it?',
  35162. default_button: "Cancel",
  35163. buttons : {
  35164. Overwrite : {
  35165. class: "btn-danger",
  35166. click: function () {
  35167. add_uploading_button(file, item);
  35168. }
  35169. },
  35170. Cancel : {
  35171. click: function() { item.remove(); }
  35172. }
  35173. }
  35174. });
  35175. } else {
  35176. add_uploading_button(file, item);
  35177. }
  35178. return false;
  35179. });
  35180. item.find(".item_buttons").empty()
  35181. .append(upload_button)
  35182. .append(cancel_button);
  35183. };
  35184. NotebookList.prototype.add_upload_button = function (item) {
  35185. var that = this;
  35186. var upload_button = $('<button/>').text(i18n.msg._("Upload"))
  35187. .addClass('btn btn-primary btn-xs upload_button')
  35188. .click(function (e) {
  35189. var filename = item.find('.item_name > input').val();
  35190. var path = utils.url_path_join(that.notebook_path, filename);
  35191. var filedata = item.data('filedata');
  35192. var format = 'text';
  35193. if (filename.length === 0 || filename[0] === '.') {
  35194. dialog.modal({
  35195. title : i18n.msg._('Invalid file name'),
  35196. body : i18n.msg._("File names must be at least one character and not start with a period"),
  35197. buttons : {'OK' : { 'class' : 'btn-primary' }}
  35198. });
  35199. return false;
  35200. }
  35201. if (filedata instanceof ArrayBuffer) {
  35202. // base64-encode binary file data
  35203. var bytes = '';
  35204. var buf = new Uint8Array(filedata);
  35205. var nbytes = buf.byteLength;
  35206. for (var i=0; i<nbytes; i++) {
  35207. bytes += String.fromCharCode(buf[i]);
  35208. }
  35209. filedata = btoa(bytes);
  35210. format = 'base64';
  35211. }
  35212. var model = { name: filename, path: path };
  35213. var name_and_ext = utils.splitext(filename);
  35214. var file_ext = name_and_ext[1];
  35215. var content_type;
  35216. if (file_ext === '.ipynb') {
  35217. model.type = 'notebook';
  35218. model.format = 'json';
  35219. try {
  35220. model.content = JSON.parse(filedata);
  35221. } catch (e) {
  35222. var failbody = i18n.msg._("The error was: %s");
  35223. dialog.modal({
  35224. title : i18n.msg._('Cannot upload invalid Notebook'),
  35225. body : i18n.msg.sprintf(failbody,e),
  35226. buttons : {'OK' : {
  35227. 'class' : 'btn-primary',
  35228. click: function () {
  35229. item.remove();
  35230. }
  35231. }}
  35232. });
  35233. console.warn('Error during notebook uploading', e);
  35234. return false;
  35235. }
  35236. content_type = 'application/json';
  35237. } else {
  35238. model.type = 'file';
  35239. model.format = format;
  35240. model.content = filedata;
  35241. content_type = 'application/octet-stream';
  35242. }
  35243. var on_success = function () {
  35244. item.removeClass('new-file');
  35245. that.add_link(model, item);
  35246. that.session_list.load_sessions();
  35247. };
  35248. var exists = false;
  35249. $.each(that.element.find('.list_item:not(.new-file)'), function(k,v){
  35250. if ($(v).data('name') === filename) { exists = true; return false; }
  35251. });
  35252. if (exists) {
  35253. var body = i18n.msg._("There is already a file named \"%s\". Do you want to replace it?");
  35254. dialog.modal({
  35255. title : i18n.msg._("Replace file"),
  35256. body : i18n.msg.sprintf(body,filename),
  35257. default_button: "Cancel",
  35258. buttons : {
  35259. Cancel : {
  35260. click: function() { item.remove(); }
  35261. },
  35262. Overwrite : {
  35263. class: "btn-danger",
  35264. click: function () {
  35265. that.contents.save(path, model).then(on_success);
  35266. }
  35267. }
  35268. }
  35269. });
  35270. } else {
  35271. that.contents.save(path, model).then(on_success);
  35272. }
  35273. return false;
  35274. });
  35275. var cancel_button = $('<button/>').text(i18n.msg._("Cancel"))
  35276. .addClass("btn btn-default btn-xs")
  35277. .click(function (e) {
  35278. item.remove();
  35279. return false;
  35280. });
  35281. item.find(".item_buttons").empty()
  35282. .append(upload_button)
  35283. .append(cancel_button);
  35284. };
  35285. return {'NotebookList': NotebookList};
  35286. });
  35287. // Copyright (c) Jupyter Development Team.
  35288. // Distributed under the terms of the Modified BSD License.
  35289. define('tree/js/sessionlist',[
  35290. 'jquery',
  35291. 'base/js/utils',
  35292. 'bidi/bidi',
  35293. ], function($, utils, bidi) {
  35294. "use strict";
  35295. var isRTL = bidi.isMirroringEnabled();
  35296. var SesssionList = function (options) {
  35297. /**
  35298. * Constructor
  35299. *
  35300. * Parameters:
  35301. * options: dictionary
  35302. * Dictionary of keyword arguments.
  35303. * events: $(Events) instance
  35304. * base_url : string
  35305. */
  35306. this.events = options.events;
  35307. this.sessions = {};
  35308. this.base_url = options.base_url || utils.get_body_data("baseUrl");
  35309. // Add collapse arrows.
  35310. $('#running .panel-group .panel .panel-heading a').each(function(index, el) {
  35311. var $link = $(el);
  35312. var $icon = $('<i />')
  35313. .addClass('fa fa-caret-down');
  35314. $link.append($icon);
  35315. $link.down = true;
  35316. $link.click(function () {
  35317. if ($link.down) {
  35318. $link.down = false;
  35319. // jQeury doesn't know how to animate rotations. Abuse
  35320. // jQueries animate function by using an unused css attribute
  35321. // to do the animation (borderSpacing).
  35322. $icon.animate({ borderSpacing: 90 }, {
  35323. step: function(now,fx) {
  35324. isRTL ? $icon.css('transform','rotate(' + now + 'deg)') : $icon.css('transform','rotate(-' + now + 'deg)');
  35325. }
  35326. }, 250);
  35327. } else {
  35328. $link.down = true;
  35329. // See comment above.
  35330. $icon.animate({ borderSpacing: 0 }, {
  35331. step: function(now,fx) {
  35332. isRTL ? $icon.css('transform','rotate(' + now + 'deg)') : $icon.css('transform','rotate(-' + now + 'deg)');
  35333. }
  35334. }, 250);
  35335. }
  35336. });
  35337. });
  35338. };
  35339. SesssionList.prototype.load_sessions = function(){
  35340. var that = this;
  35341. var settings = {
  35342. processData : false,
  35343. cache : false,
  35344. type : "GET",
  35345. dataType : "json",
  35346. success : $.proxy(that.sessions_loaded, this),
  35347. error : utils.log_ajax_error,
  35348. };
  35349. var url = utils.url_path_join(this.base_url, 'api/sessions');
  35350. utils.ajax(url, settings);
  35351. };
  35352. SesssionList.prototype.sessions_loaded = function(data){
  35353. this.sessions = {};
  35354. var len = data.length;
  35355. var nb_path;
  35356. for (var i=0; i<len; i++) {
  35357. // The classic notebook only knows about sessions for notebooks,
  35358. // but the server now knows about more general sessions for
  35359. // things like consoles.
  35360. if (data[i].type === 'notebook') {
  35361. nb_path = data[i].notebook.path;
  35362. this.sessions[nb_path] = {
  35363. id: data[i].id,
  35364. kernel: {
  35365. name: data[i].kernel.name
  35366. }
  35367. };
  35368. }
  35369. }
  35370. this.events.trigger('sessions_loaded.Dashboard', this.sessions);
  35371. };
  35372. return {'SesssionList': SesssionList};
  35373. });
  35374. // Copyright (c) Jupyter Development Team.
  35375. // Distributed under the terms of the Modified BSD License.
  35376. define('tree/js/kernellist',[
  35377. 'jquery',
  35378. 'base/js/namespace',
  35379. 'tree/js/notebooklist',
  35380. 'base/js/i18n'
  35381. ], function($, IPython, notebooklist, i18n) {
  35382. "use strict";
  35383. var KernelList = function (selector, options) {
  35384. /**
  35385. * Constructor
  35386. *
  35387. * Parameters:
  35388. * selector: string
  35389. * options: dictionary
  35390. * Dictionary of keyword arguments.
  35391. * session_list: SessionList instance
  35392. * base_url: string
  35393. * notebook_path: string
  35394. */
  35395. notebooklist.NotebookList.call(this, selector, $.extend({
  35396. element_name: 'running'},
  35397. options));
  35398. this.kernelspecs = this.sessions = null;
  35399. this.events.on('kernelspecs_loaded.KernelSpec', $.proxy(this._kernelspecs_loaded, this));
  35400. };
  35401. KernelList.prototype = Object.create(notebooklist.NotebookList.prototype);
  35402. KernelList.prototype.add_duplicate_button = function () {
  35403. /**
  35404. * do nothing
  35405. */
  35406. };
  35407. KernelList.prototype._kernelspecs_loaded = function (event, kernelspecs) {
  35408. this.kernelspecs = kernelspecs;
  35409. if (this.sessions) {
  35410. // trigger delayed session load, since kernelspecs arrived later
  35411. this.sessions_loaded(this.sessions);
  35412. }
  35413. };
  35414. KernelList.prototype.sessions_loaded = function (d) {
  35415. this.sessions = d;
  35416. if (!this.kernelspecs) {
  35417. return; // wait for kernelspecs before first load
  35418. }
  35419. this.clear_list();
  35420. var item, path, session, info;
  35421. for (path in d) {
  35422. if (!d.hasOwnProperty(path)) {
  35423. // nothing is safe in javascript
  35424. continue;
  35425. }
  35426. session = d[path];
  35427. item = this.new_item(-1);
  35428. info = this.kernelspecs[session.kernel.name];
  35429. this.add_link({
  35430. name: path,
  35431. path: path,
  35432. type: 'notebook',
  35433. kernel_display_name: (info && info.spec) ? info.spec.display_name : session.kernel.name
  35434. }, item);
  35435. }
  35436. $('#running_list_placeholder').toggle($.isEmptyObject(d));
  35437. };
  35438. KernelList.prototype.add_link = function (model, item) {
  35439. notebooklist.NotebookList.prototype.add_link.apply(this, [model, item]);
  35440. var running_indicator = item.find(".item_buttons")
  35441. .text('');
  35442. var that = this;
  35443. var kernel_name = $('<div/>')
  35444. .addClass('kernel-name')
  35445. .text(model.kernel_display_name)
  35446. .appendTo(running_indicator);
  35447. var shutdown_button = $('<button/>')
  35448. .addClass('btn btn-warning btn-xs')
  35449. .text(i18n._('Shutdown'))
  35450. .click(function() {
  35451. var path = $(this).parent().parent().parent().data('path');
  35452. that.shutdown_notebook(path);
  35453. })
  35454. .appendTo(running_indicator);
  35455. };
  35456. // Backwards compatability.
  35457. IPython.KernelList = KernelList;
  35458. return {'KernelList': KernelList};
  35459. });
  35460. // Copyright (c) Jupyter Development Team.
  35461. // Distributed under the terms of the Modified BSD License.
  35462. define('tree/js/terminallist',[
  35463. 'jquery',
  35464. 'base/js/namespace',
  35465. 'base/js/utils',
  35466. 'base/js/i18n',
  35467. 'tree/js/notebooklist',
  35468. ], function($, IPython, utils, i18n, notebooklist) {
  35469. "use strict";
  35470. var TerminalList = function (selector, options) {
  35471. /**
  35472. * Constructor
  35473. *
  35474. * Parameters:
  35475. * selector: string
  35476. * options: dictionary
  35477. * Dictionary of keyword arguments.
  35478. * base_url: string
  35479. */
  35480. this.base_url = options.base_url || utils.get_body_data("baseUrl");
  35481. this.element_name = options.element_name || 'running';
  35482. this.selector = selector;
  35483. this.terminals = [];
  35484. if (this.selector !== undefined) {
  35485. this.element = $(selector);
  35486. this.style();
  35487. this.bind_events();
  35488. this.load_terminals();
  35489. }
  35490. };
  35491. TerminalList.prototype = Object.create(notebooklist.NotebookList.prototype);
  35492. TerminalList.prototype.bind_events = function () {
  35493. var that = this;
  35494. $('#refresh_' + this.element_name + '_list').click(function () {
  35495. that.load_terminals();
  35496. });
  35497. $('#new-terminal').click($.proxy(this.new_terminal, this));
  35498. };
  35499. TerminalList.prototype.new_terminal = function (event) {
  35500. if (event) {
  35501. event.preventDefault();
  35502. }
  35503. var w = window.open('#', IPython._target);
  35504. var base_url = this.base_url;
  35505. var settings = {
  35506. type : "POST",
  35507. dataType: "json",
  35508. success : function (data, status, xhr) {
  35509. var name = data.name;
  35510. w.location = utils.url_path_join(base_url, 'terminals',
  35511. utils.encode_uri_components(name));
  35512. },
  35513. error : function(jqXHR, status, error){
  35514. w.close();
  35515. utils.log_ajax_error(jqXHR, status, error);
  35516. },
  35517. };
  35518. var url = utils.url_path_join(
  35519. this.base_url,
  35520. 'api/terminals'
  35521. );
  35522. utils.ajax(url, settings);
  35523. };
  35524. TerminalList.prototype.load_terminals = function() {
  35525. var url = utils.url_path_join(this.base_url, 'api/terminals');
  35526. utils.ajax(url, {
  35527. type: "GET",
  35528. cache: false,
  35529. dataType: "json",
  35530. success: $.proxy(this.terminals_loaded, this),
  35531. error : utils.log_ajax_error
  35532. });
  35533. };
  35534. TerminalList.prototype.terminals_loaded = function (data) {
  35535. this.terminals = data;
  35536. this.clear_list();
  35537. var item, term;
  35538. for (var i=0; i < this.terminals.length; i++) {
  35539. term = this.terminals[i];
  35540. item = this.new_item(-1);
  35541. this.add_link(term.name, item);
  35542. this.add_shutdown_button(term.name, item);
  35543. }
  35544. $('#terminal_list_header').toggle(data.length === 0);
  35545. };
  35546. TerminalList.prototype.add_link = function(name, item) {
  35547. item.data('term-name', name);
  35548. item.find(".item_name").text("terminals/" + name);
  35549. item.find(".item_icon").addClass("fa fa-terminal");
  35550. var link = item.find("a.item_link")
  35551. .attr('href', utils.url_path_join(this.base_url, "terminals",
  35552. utils.encode_uri_components(name)));
  35553. link.attr('target', IPython._target||'_blank');
  35554. this.add_shutdown_button(name, item);
  35555. };
  35556. TerminalList.prototype.add_shutdown_button = function(name, item) {
  35557. var that = this;
  35558. var shutdown_button = $("<button/>").text(i18n._("Shutdown")).addClass("btn btn-xs btn-warning").
  35559. click(function (e) {
  35560. var settings = {
  35561. processData : false,
  35562. type : "DELETE",
  35563. dataType : "json",
  35564. success : function () {
  35565. that.load_terminals();
  35566. },
  35567. error : utils.log_ajax_error,
  35568. };
  35569. var url = utils.url_path_join(that.base_url, 'api/terminals',
  35570. utils.encode_uri_components(name));
  35571. utils.ajax(url, settings);
  35572. return false;
  35573. });
  35574. item.find(".item_buttons").text("").append(shutdown_button);
  35575. };
  35576. return {TerminalList: TerminalList};
  35577. });
  35578. // Copyright (c) Jupyter Development Team.
  35579. // Distributed under the terms of the Modified BSD License.
  35580. define('tree/js/newnotebook',[
  35581. 'jquery',
  35582. 'base/js/namespace',
  35583. 'base/js/utils',
  35584. 'base/js/i18n',
  35585. 'base/js/dialog',
  35586. ], function ($, IPython, utils, i18n, dialog) {
  35587. "use strict";
  35588. var NewNotebookWidget = function (selector, options) {
  35589. this.selector = selector;
  35590. this.base_url = options.base_url;
  35591. this.contents = options.contents;
  35592. this.events = options.events;
  35593. this.default_kernel = null;
  35594. this.kernelspecs = {};
  35595. if (this.selector !== undefined) {
  35596. this.element = $(selector);
  35597. this.request_kernelspecs();
  35598. }
  35599. this.bind_events();
  35600. };
  35601. NewNotebookWidget.prototype.bind_events = function () {
  35602. var that = this;
  35603. this.element.find('#new_notebook').click(function () {
  35604. that.new_notebook();
  35605. });
  35606. };
  35607. NewNotebookWidget.prototype.request_kernelspecs = function () {
  35608. /** request and then load kernel specs */
  35609. var url = utils.url_path_join(this.base_url, 'api/kernelspecs');
  35610. utils.promising_ajax(url).then($.proxy(this._load_kernelspecs, this));
  35611. };
  35612. NewNotebookWidget.prototype._load_kernelspecs = function (data) {
  35613. /** load kernelspec list */
  35614. var that = this;
  35615. this.kernelspecs = data.kernelspecs;
  35616. var menu = this.element.find("#notebook-kernels");
  35617. var keys = Object.keys(data.kernelspecs).sort(function (a, b) {
  35618. var da = data.kernelspecs[a].spec.display_name;
  35619. var db = data.kernelspecs[b].spec.display_name;
  35620. if (da === db) {
  35621. return 0;
  35622. } else if (da > db) {
  35623. return 1;
  35624. } else {
  35625. return -1;
  35626. }
  35627. });
  35628. // Create the kernel list in reverse order because
  35629. // the .after insertion causes each item to be added
  35630. // to the top of the list.
  35631. for (var i = keys.length - 1; i >= 0; i--) {
  35632. var ks = this.kernelspecs[keys[i]];
  35633. var li = $("<li>")
  35634. .attr("id", "kernel-" +ks.name)
  35635. .data('kernelspec', ks).append(
  35636. $('<a>')
  35637. .attr('href', '#')
  35638. .click($.proxy(this.new_notebook, this, ks.name))
  35639. .text(ks.spec.display_name)
  35640. .attr('title', i18n.sprintf(i18n._('Create a new notebook with %s'), ks.spec.display_name))
  35641. );
  35642. menu.after(li);
  35643. }
  35644. this.events.trigger('kernelspecs_loaded.KernelSpec', data.kernelspecs);
  35645. };
  35646. NewNotebookWidget.prototype.new_notebook = function (kernel_name, evt) {
  35647. /** create and open a new notebook */
  35648. var that = this;
  35649. kernel_name = kernel_name || this.default_kernel;
  35650. var w = window.open(undefined, IPython._target);
  35651. var dir_path = $('body').attr('data-notebook-path');
  35652. this.contents.new_untitled(dir_path, {type: "notebook"}).then(
  35653. function (data) {
  35654. var url = utils.url_path_join(
  35655. that.base_url, 'notebooks',
  35656. utils.encode_uri_components(data.path)
  35657. );
  35658. if (kernel_name) {
  35659. url += "?kernel_name=" + kernel_name;
  35660. }
  35661. w.location = url;
  35662. }).catch(function (e) {
  35663. w.close();
  35664. // This statement is used simply so that message extraction
  35665. // will pick up the strings. The actual setting of the text
  35666. // for the button is in dialog.js.
  35667. var button_labels = [ i18n._("OK")];
  35668. dialog.modal({
  35669. title : i18n._('Creating Notebook Failed'),
  35670. body : $('<div/>')
  35671. .text(i18n._("An error occurred while creating a new notebook."))
  35672. .append($('<div/>')
  35673. .addClass('alert alert-danger')
  35674. .text(e.message || e)),
  35675. buttons: {
  35676. OK: {'class' : 'btn-primary'}
  35677. }
  35678. });
  35679. });
  35680. if (evt !== undefined) {
  35681. evt.preventDefault();
  35682. }
  35683. };
  35684. return {'NewNotebookWidget': NewNotebookWidget};
  35685. });
  35686. // Copyright (c) Jupyter Development Team.
  35687. // Distributed under the terms of the Modified BSD License.
  35688. define('tree/js/shutdownbutton',[
  35689. 'jquery',
  35690. 'base/js/dialog',
  35691. 'base/js/i18n',
  35692. 'base/js/utils'
  35693. ], function(
  35694. $,
  35695. dialog,
  35696. i18n,
  35697. utils
  35698. ){
  35699. "use strict";
  35700. function display_shutdown_dialog() {
  35701. var body = $('<div/>').append(
  35702. $('<p/>').text(i18n.msg._("You have shut down Jupyter. You can now close this tab."))
  35703. ).append(
  35704. $('<p/>').text(i18n.msg._("To use Jupyter again, you will need to relaunch it."))
  35705. );
  35706. dialog.modal({
  35707. title: i18n.msg._("Server stopped"),
  35708. body: body
  35709. })
  35710. }
  35711. function activate() {
  35712. // Add shutdown button
  35713. $("button#shutdown").click(function () {
  35714. utils.ajax(utils.url_path_join(
  35715. utils.get_body_data("baseUrl"),
  35716. "api",
  35717. "shutdown"
  35718. ), {
  35719. type: "POST",
  35720. success: display_shutdown_dialog,
  35721. error: function (error) {
  35722. console.log(error);
  35723. }
  35724. });
  35725. });
  35726. }
  35727. return {activate: activate}
  35728. });
  35729. // Copyright (c) Jupyter Development Team.
  35730. // Distributed under the terms of the Modified BSD License.
  35731. define('auth/js/loginwidget',[
  35732. 'jquery',
  35733. 'base/js/utils',
  35734. ], function($, utils){
  35735. "use strict";
  35736. var LoginWidget = function (selector, options) {
  35737. options = options || {};
  35738. this.base_url = options.base_url || utils.get_body_data("baseUrl");
  35739. this.selector = selector;
  35740. if (this.selector !== undefined) {
  35741. this.element = $(selector);
  35742. this.bind_events();
  35743. }
  35744. };
  35745. LoginWidget.prototype.bind_events = function () {
  35746. var that = this;
  35747. this.element.find("button#logout").click(function () {
  35748. window.location = utils.url_path_join(
  35749. that.base_url,
  35750. "logout"
  35751. );
  35752. });
  35753. this.element.find("button#login").click(function () {
  35754. window.location = utils.url_path_join(
  35755. that.base_url,
  35756. "login"
  35757. );
  35758. });
  35759. };
  35760. return {'LoginWidget': LoginWidget};
  35761. });
  35762. // Copyright (c) Jupyter Development Team.
  35763. // Distributed under the terms of the Modified BSD License.
  35764. // adapted from Mozilla Developer Network example at
  35765. // https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Function/bind
  35766. // shim `bind` for testing under casper.js
  35767. var bind = function bind(obj) {
  35768. var slice = [].slice;
  35769. var args = slice.call(arguments, 1),
  35770. self = this,
  35771. nop = function() {
  35772. },
  35773. bound = function() {
  35774. return self.apply(this instanceof nop ? this : (obj || {}), args.concat(slice.call(arguments)));
  35775. };
  35776. nop.prototype = this.prototype || {}; // Firefox cries sometimes if prototype is undefined
  35777. bound.prototype = new nop();
  35778. return bound;
  35779. };
  35780. Function.prototype.bind = Function.prototype.bind || bind ;
  35781. requirejs([
  35782. 'jquery',
  35783. 'contents',
  35784. 'base/js/namespace',
  35785. 'base/js/dialog',
  35786. 'base/js/events',
  35787. 'base/js/promises',
  35788. 'base/js/page',
  35789. 'base/js/utils',
  35790. 'services/config',
  35791. 'tree/js/notebooklist',
  35792. 'tree/js/sessionlist',
  35793. 'tree/js/kernellist',
  35794. 'tree/js/terminallist',
  35795. 'tree/js/newnotebook',
  35796. 'tree/js/shutdownbutton',
  35797. 'auth/js/loginwidget',
  35798. 'bidi/bidi',
  35799. ], function(
  35800. $,
  35801. contents_service,
  35802. IPython,
  35803. dialog,
  35804. events,
  35805. promises,
  35806. page,
  35807. utils,
  35808. config,
  35809. notebooklist,
  35810. sesssionlist,
  35811. kernellist,
  35812. terminallist,
  35813. newnotebook,
  35814. shutdownbutton,
  35815. loginwidget,
  35816. bidi){
  35817. "use strict";
  35818. try{
  35819. requirejs(['custom/custom'], function() {});
  35820. bidi.loadLocale();
  35821. } catch(err) {
  35822. console.log("Error loading custom.js from tree service. Continuing and logging");
  35823. console.warn(err);
  35824. }
  35825. console.log('Welcome to Project Jupyter! Explore the various tools available and their corresponding documentation. If you are interested in contributing to the platform, please visit the community resources section at http://jupyter.org/community.html.');
  35826. // Setup all of the config related things
  35827. var common_options = {
  35828. base_url: utils.get_body_data("baseUrl"),
  35829. notebook_path: utils.get_body_data("notebookPath"),
  35830. };
  35831. var cfg = new config.ConfigSection('tree', common_options);
  35832. cfg.load();
  35833. common_options.config = cfg;
  35834. var common_config = new config.ConfigSection('common', common_options);
  35835. common_config.load();
  35836. // Instantiate the main objects
  35837. page = new page.Page('div#header', 'div#site');
  35838. var session_list = new sesssionlist.SesssionList($.extend({
  35839. events: events},
  35840. common_options));
  35841. var contents = new contents_service.Contents({
  35842. base_url: common_options.base_url,
  35843. common_config: common_config
  35844. });
  35845. IPython.NotebookList = notebooklist.NotebookList;
  35846. var notebook_list = new notebooklist.NotebookList('#notebook_list', $.extend({
  35847. contents: contents,
  35848. session_list: session_list},
  35849. common_options));
  35850. var kernel_list = new kernellist.KernelList('#running_list', $.extend({
  35851. session_list: session_list},
  35852. common_options));
  35853. var terminal_list;
  35854. if (utils.get_body_data("terminalsAvailable") === "True") {
  35855. terminal_list = new terminallist.TerminalList('#terminal_list', common_options);
  35856. }
  35857. var login_widget = new loginwidget.LoginWidget('#login_widget', common_options);
  35858. var new_buttons = new newnotebook.NewNotebookWidget("#new-buttons",
  35859. $.extend(
  35860. {contents: contents, events: events},
  35861. common_options
  35862. )
  35863. );
  35864. var interval_id=0;
  35865. // auto refresh every xx secondes, no need to be fast,
  35866. // update is done most of the time when page get focus
  35867. IPython.tree_time_refresh = 60; // in sec
  35868. // limit refresh on focus at 1/10sec, otherwise this
  35869. // can cause too frequent refresh on switching through windows or tabs.
  35870. IPython.min_delta_refresh = 10; // in sec
  35871. var _last_refresh = null;
  35872. var _refresh_list = function(){
  35873. _last_refresh = new Date();
  35874. session_list.load_sessions();
  35875. if (terminal_list) {
  35876. terminal_list.load_terminals();
  35877. }
  35878. };
  35879. var enable_autorefresh = function(){
  35880. /**
  35881. *refresh immediately , then start interval
  35882. */
  35883. var now = new Date();
  35884. if (now - _last_refresh < IPython.min_delta_refresh*1000){
  35885. console.log("Reenabling autorefresh too close to last tree refresh, not refreshing immediately again.");
  35886. } else {
  35887. _refresh_list();
  35888. }
  35889. if (!interval_id){
  35890. interval_id = setInterval(_refresh_list,
  35891. IPython.tree_time_refresh*1000
  35892. );
  35893. }
  35894. };
  35895. var disable_autorefresh = function(){
  35896. clearInterval(interval_id);
  35897. interval_id = 0;
  35898. };
  35899. // stop autorefresh when page lose focus
  35900. $(window).blur(function() {
  35901. disable_autorefresh();
  35902. });
  35903. //re-enable when page get focus back
  35904. $(window).focus(function() {
  35905. enable_autorefresh();
  35906. });
  35907. // finally start it, it will refresh immediately
  35908. enable_autorefresh();
  35909. page.show();
  35910. // For backwards compatability.
  35911. IPython.page = page;
  35912. IPython.notebook_list = notebook_list;
  35913. IPython.session_list = session_list;
  35914. IPython.kernel_list = kernel_list;
  35915. IPython.login_widget = login_widget;
  35916. IPython.new_notebook_widget = new_buttons;
  35917. events.trigger('app_initialized.DashboardApp');
  35918. // Now actually load nbextensions
  35919. utils.load_extensions_from_config(cfg);
  35920. utils.load_extensions_from_config(common_config);
  35921. // bound the upload method to the on change of the file select list
  35922. $("#alternate_upload").change(function (event){
  35923. notebook_list.handleFilesUpload(event,'form');
  35924. });
  35925. // set hash on tab click
  35926. $("#tabs").find("a").click(function(e) {
  35927. // Prevent the document from jumping when the active tab is changed to a
  35928. // tab that has a lot of content.
  35929. e.preventDefault();
  35930. // Set the hash without causing the page to jump.
  35931. // https://stackoverflow.com/a/14690177/2824256
  35932. var hash = $(this).attr("href");
  35933. if(window.history.pushState) {
  35934. window.history.pushState(null, null, hash);
  35935. } else {
  35936. window.location.hash = hash;
  35937. }
  35938. });
  35939. // load tab if url hash
  35940. if (window.location.hash) {
  35941. $("#tabs").find("a[href='" + window.location.hash + "']").click();
  35942. }
  35943. shutdownbutton.activate();
  35944. });
  35945. define("tree/js/main", function(){});
  35946. //# sourceMappingURL=main.min.js.map