No Description

index.js 1.5MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763
  1. 'use strict';
  2. Object.defineProperty(exports, '__esModule', { value: true });
  3. function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
  4. var React = require('react');
  5. var React__default = _interopDefault(React);
  6. var ReactDOM = require('react-dom');
  7. var ReactDOM__default = _interopDefault(ReactDOM);
  8. var styleInject_es = require('../style-inject.es-dcee06b6.js');
  9. var defineProperty = require('../defineProperty-ba7cd53d.js');
  10. var index = require('../index-1143667e.js');
  11. var slicedToArray = require('../slicedToArray-172f4624.js');
  12. var server = _interopDefault(require('react-dom/server'));
  13. /*
  14. object-assign
  15. (c) Sindre Sorhus
  16. @license MIT
  17. */
  18. /* eslint-disable no-unused-vars */
  19. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  20. var hasOwnProperty = Object.prototype.hasOwnProperty;
  21. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  22. function toObject(val) {
  23. if (val === null || val === undefined) {
  24. throw new TypeError('Object.assign cannot be called with null or undefined');
  25. }
  26. return Object(val);
  27. }
  28. function shouldUseNative() {
  29. try {
  30. if (!Object.assign) {
  31. return false;
  32. }
  33. // Detect buggy property enumeration order in older V8 versions.
  34. // https://bugs.chromium.org/p/v8/issues/detail?id=4118
  35. var test1 = new String('abc'); // eslint-disable-line no-new-wrappers
  36. test1[5] = 'de';
  37. if (Object.getOwnPropertyNames(test1)[0] === '5') {
  38. return false;
  39. }
  40. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  41. var test2 = {};
  42. for (var i = 0; i < 10; i++) {
  43. test2['_' + String.fromCharCode(i)] = i;
  44. }
  45. var order2 = Object.getOwnPropertyNames(test2).map(function (n) {
  46. return test2[n];
  47. });
  48. if (order2.join('') !== '0123456789') {
  49. return false;
  50. }
  51. // https://bugs.chromium.org/p/v8/issues/detail?id=3056
  52. var test3 = {};
  53. 'abcdefghijklmnopqrst'.split('').forEach(function (letter) {
  54. test3[letter] = letter;
  55. });
  56. if (Object.keys(Object.assign({}, test3)).join('') !==
  57. 'abcdefghijklmnopqrst') {
  58. return false;
  59. }
  60. return true;
  61. } catch (err) {
  62. // We don't expect any of the above to throw, but better to be safe.
  63. return false;
  64. }
  65. }
  66. var objectAssign = shouldUseNative() ? Object.assign : function (target, source) {
  67. var from;
  68. var to = toObject(target);
  69. var symbols;
  70. for (var s = 1; s < arguments.length; s++) {
  71. from = Object(arguments[s]);
  72. for (var key in from) {
  73. if (hasOwnProperty.call(from, key)) {
  74. to[key] = from[key];
  75. }
  76. }
  77. if (getOwnPropertySymbols) {
  78. symbols = getOwnPropertySymbols(from);
  79. for (var i = 0; i < symbols.length; i++) {
  80. if (propIsEnumerable.call(from, symbols[i])) {
  81. to[symbols[i]] = from[symbols[i]];
  82. }
  83. }
  84. }
  85. }
  86. return to;
  87. };
  88. var immutable = index.createCommonjsModule(function (module, exports) {
  89. /**
  90. * Copyright (c) 2014-2015, Facebook, Inc.
  91. * All rights reserved.
  92. *
  93. * This source code is licensed under the BSD-style license found in the
  94. * LICENSE file in the root directory of this source tree. An additional grant
  95. * of patent rights can be found in the PATENTS file in the same directory.
  96. */
  97. (function (global, factory) {
  98. module.exports = factory() ;
  99. }(index.commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
  100. function createClass(ctor, superClass) {
  101. if (superClass) {
  102. ctor.prototype = Object.create(superClass.prototype);
  103. }
  104. ctor.prototype.constructor = ctor;
  105. }
  106. function Iterable(value) {
  107. return isIterable(value) ? value : Seq(value);
  108. }
  109. createClass(KeyedIterable, Iterable);
  110. function KeyedIterable(value) {
  111. return isKeyed(value) ? value : KeyedSeq(value);
  112. }
  113. createClass(IndexedIterable, Iterable);
  114. function IndexedIterable(value) {
  115. return isIndexed(value) ? value : IndexedSeq(value);
  116. }
  117. createClass(SetIterable, Iterable);
  118. function SetIterable(value) {
  119. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  120. }
  121. function isIterable(maybeIterable) {
  122. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  123. }
  124. function isKeyed(maybeKeyed) {
  125. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  126. }
  127. function isIndexed(maybeIndexed) {
  128. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  129. }
  130. function isAssociative(maybeAssociative) {
  131. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  132. }
  133. function isOrdered(maybeOrdered) {
  134. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  135. }
  136. Iterable.isIterable = isIterable;
  137. Iterable.isKeyed = isKeyed;
  138. Iterable.isIndexed = isIndexed;
  139. Iterable.isAssociative = isAssociative;
  140. Iterable.isOrdered = isOrdered;
  141. Iterable.Keyed = KeyedIterable;
  142. Iterable.Indexed = IndexedIterable;
  143. Iterable.Set = SetIterable;
  144. var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  145. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  146. var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  147. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  148. // Used for setting prototype methods that IE8 chokes on.
  149. var DELETE = 'delete';
  150. // Constants describing the size of trie nodes.
  151. var SHIFT = 5; // Resulted in best performance after ______?
  152. var SIZE = 1 << SHIFT;
  153. var MASK = SIZE - 1;
  154. // A consistent shared value representing "not set" which equals nothing other
  155. // than itself, and nothing that could be provided externally.
  156. var NOT_SET = {};
  157. // Boolean references, Rough equivalent of `bool &`.
  158. var CHANGE_LENGTH = { value: false };
  159. var DID_ALTER = { value: false };
  160. function MakeRef(ref) {
  161. ref.value = false;
  162. return ref;
  163. }
  164. function SetRef(ref) {
  165. ref && (ref.value = true);
  166. }
  167. // A function which returns a value representing an "owner" for transient writes
  168. // to tries. The return value will only ever equal itself, and will not equal
  169. // the return of any subsequent call of this function.
  170. function OwnerID() {}
  171. // http://jsperf.com/copy-array-inline
  172. function arrCopy(arr, offset) {
  173. offset = offset || 0;
  174. var len = Math.max(0, arr.length - offset);
  175. var newArr = new Array(len);
  176. for (var ii = 0; ii < len; ii++) {
  177. newArr[ii] = arr[ii + offset];
  178. }
  179. return newArr;
  180. }
  181. function ensureSize(iter) {
  182. if (iter.size === undefined) {
  183. iter.size = iter.__iterate(returnTrue);
  184. }
  185. return iter.size;
  186. }
  187. function wrapIndex(iter, index) {
  188. // This implements "is array index" which the ECMAString spec defines as:
  189. //
  190. // A String property name P is an array index if and only if
  191. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  192. // to 2^32−1.
  193. //
  194. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  195. if (typeof index !== 'number') {
  196. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  197. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  198. return NaN;
  199. }
  200. index = uint32Index;
  201. }
  202. return index < 0 ? ensureSize(iter) + index : index;
  203. }
  204. function returnTrue() {
  205. return true;
  206. }
  207. function wholeSlice(begin, end, size) {
  208. return (begin === 0 || (size !== undefined && begin <= -size)) &&
  209. (end === undefined || (size !== undefined && end >= size));
  210. }
  211. function resolveBegin(begin, size) {
  212. return resolveIndex(begin, size, 0);
  213. }
  214. function resolveEnd(end, size) {
  215. return resolveIndex(end, size, size);
  216. }
  217. function resolveIndex(index, size, defaultIndex) {
  218. return index === undefined ?
  219. defaultIndex :
  220. index < 0 ?
  221. Math.max(0, size + index) :
  222. size === undefined ?
  223. index :
  224. Math.min(size, index);
  225. }
  226. /* global Symbol */
  227. var ITERATE_KEYS = 0;
  228. var ITERATE_VALUES = 1;
  229. var ITERATE_ENTRIES = 2;
  230. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  231. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  232. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  233. function Iterator(next) {
  234. this.next = next;
  235. }
  236. Iterator.prototype.toString = function() {
  237. return '[Iterator]';
  238. };
  239. Iterator.KEYS = ITERATE_KEYS;
  240. Iterator.VALUES = ITERATE_VALUES;
  241. Iterator.ENTRIES = ITERATE_ENTRIES;
  242. Iterator.prototype.inspect =
  243. Iterator.prototype.toSource = function () { return this.toString(); };
  244. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  245. return this;
  246. };
  247. function iteratorValue(type, k, v, iteratorResult) {
  248. var value = type === 0 ? k : type === 1 ? v : [k, v];
  249. iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
  250. value: value, done: false
  251. });
  252. return iteratorResult;
  253. }
  254. function iteratorDone() {
  255. return { value: undefined, done: true };
  256. }
  257. function hasIterator(maybeIterable) {
  258. return !!getIteratorFn(maybeIterable);
  259. }
  260. function isIterator(maybeIterator) {
  261. return maybeIterator && typeof maybeIterator.next === 'function';
  262. }
  263. function getIterator(iterable) {
  264. var iteratorFn = getIteratorFn(iterable);
  265. return iteratorFn && iteratorFn.call(iterable);
  266. }
  267. function getIteratorFn(iterable) {
  268. var iteratorFn = iterable && (
  269. (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  270. iterable[FAUX_ITERATOR_SYMBOL]
  271. );
  272. if (typeof iteratorFn === 'function') {
  273. return iteratorFn;
  274. }
  275. }
  276. function isArrayLike(value) {
  277. return value && typeof value.length === 'number';
  278. }
  279. createClass(Seq, Iterable);
  280. function Seq(value) {
  281. return value === null || value === undefined ? emptySequence() :
  282. isIterable(value) ? value.toSeq() : seqFromValue(value);
  283. }
  284. Seq.of = function(/*...values*/) {
  285. return Seq(arguments);
  286. };
  287. Seq.prototype.toSeq = function() {
  288. return this;
  289. };
  290. Seq.prototype.toString = function() {
  291. return this.__toString('Seq {', '}');
  292. };
  293. Seq.prototype.cacheResult = function() {
  294. if (!this._cache && this.__iterateUncached) {
  295. this._cache = this.entrySeq().toArray();
  296. this.size = this._cache.length;
  297. }
  298. return this;
  299. };
  300. // abstract __iterateUncached(fn, reverse)
  301. Seq.prototype.__iterate = function(fn, reverse) {
  302. return seqIterate(this, fn, reverse, true);
  303. };
  304. // abstract __iteratorUncached(type, reverse)
  305. Seq.prototype.__iterator = function(type, reverse) {
  306. return seqIterator(this, type, reverse, true);
  307. };
  308. createClass(KeyedSeq, Seq);
  309. function KeyedSeq(value) {
  310. return value === null || value === undefined ?
  311. emptySequence().toKeyedSeq() :
  312. isIterable(value) ?
  313. (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
  314. keyedSeqFromValue(value);
  315. }
  316. KeyedSeq.prototype.toKeyedSeq = function() {
  317. return this;
  318. };
  319. createClass(IndexedSeq, Seq);
  320. function IndexedSeq(value) {
  321. return value === null || value === undefined ? emptySequence() :
  322. !isIterable(value) ? indexedSeqFromValue(value) :
  323. isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
  324. }
  325. IndexedSeq.of = function(/*...values*/) {
  326. return IndexedSeq(arguments);
  327. };
  328. IndexedSeq.prototype.toIndexedSeq = function() {
  329. return this;
  330. };
  331. IndexedSeq.prototype.toString = function() {
  332. return this.__toString('Seq [', ']');
  333. };
  334. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  335. return seqIterate(this, fn, reverse, false);
  336. };
  337. IndexedSeq.prototype.__iterator = function(type, reverse) {
  338. return seqIterator(this, type, reverse, false);
  339. };
  340. createClass(SetSeq, Seq);
  341. function SetSeq(value) {
  342. return (
  343. value === null || value === undefined ? emptySequence() :
  344. !isIterable(value) ? indexedSeqFromValue(value) :
  345. isKeyed(value) ? value.entrySeq() : value
  346. ).toSetSeq();
  347. }
  348. SetSeq.of = function(/*...values*/) {
  349. return SetSeq(arguments);
  350. };
  351. SetSeq.prototype.toSetSeq = function() {
  352. return this;
  353. };
  354. Seq.isSeq = isSeq;
  355. Seq.Keyed = KeyedSeq;
  356. Seq.Set = SetSeq;
  357. Seq.Indexed = IndexedSeq;
  358. var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  359. Seq.prototype[IS_SEQ_SENTINEL] = true;
  360. createClass(ArraySeq, IndexedSeq);
  361. function ArraySeq(array) {
  362. this._array = array;
  363. this.size = array.length;
  364. }
  365. ArraySeq.prototype.get = function(index, notSetValue) {
  366. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  367. };
  368. ArraySeq.prototype.__iterate = function(fn, reverse) {
  369. var array = this._array;
  370. var maxIndex = array.length - 1;
  371. for (var ii = 0; ii <= maxIndex; ii++) {
  372. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  373. return ii + 1;
  374. }
  375. }
  376. return ii;
  377. };
  378. ArraySeq.prototype.__iterator = function(type, reverse) {
  379. var array = this._array;
  380. var maxIndex = array.length - 1;
  381. var ii = 0;
  382. return new Iterator(function()
  383. {return ii > maxIndex ?
  384. iteratorDone() :
  385. iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
  386. );
  387. };
  388. createClass(ObjectSeq, KeyedSeq);
  389. function ObjectSeq(object) {
  390. var keys = Object.keys(object);
  391. this._object = object;
  392. this._keys = keys;
  393. this.size = keys.length;
  394. }
  395. ObjectSeq.prototype.get = function(key, notSetValue) {
  396. if (notSetValue !== undefined && !this.has(key)) {
  397. return notSetValue;
  398. }
  399. return this._object[key];
  400. };
  401. ObjectSeq.prototype.has = function(key) {
  402. return this._object.hasOwnProperty(key);
  403. };
  404. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  405. var object = this._object;
  406. var keys = this._keys;
  407. var maxIndex = keys.length - 1;
  408. for (var ii = 0; ii <= maxIndex; ii++) {
  409. var key = keys[reverse ? maxIndex - ii : ii];
  410. if (fn(object[key], key, this) === false) {
  411. return ii + 1;
  412. }
  413. }
  414. return ii;
  415. };
  416. ObjectSeq.prototype.__iterator = function(type, reverse) {
  417. var object = this._object;
  418. var keys = this._keys;
  419. var maxIndex = keys.length - 1;
  420. var ii = 0;
  421. return new Iterator(function() {
  422. var key = keys[reverse ? maxIndex - ii : ii];
  423. return ii++ > maxIndex ?
  424. iteratorDone() :
  425. iteratorValue(type, key, object[key]);
  426. });
  427. };
  428. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  429. createClass(IterableSeq, IndexedSeq);
  430. function IterableSeq(iterable) {
  431. this._iterable = iterable;
  432. this.size = iterable.length || iterable.size;
  433. }
  434. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  435. if (reverse) {
  436. return this.cacheResult().__iterate(fn, reverse);
  437. }
  438. var iterable = this._iterable;
  439. var iterator = getIterator(iterable);
  440. var iterations = 0;
  441. if (isIterator(iterator)) {
  442. var step;
  443. while (!(step = iterator.next()).done) {
  444. if (fn(step.value, iterations++, this) === false) {
  445. break;
  446. }
  447. }
  448. }
  449. return iterations;
  450. };
  451. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  452. if (reverse) {
  453. return this.cacheResult().__iterator(type, reverse);
  454. }
  455. var iterable = this._iterable;
  456. var iterator = getIterator(iterable);
  457. if (!isIterator(iterator)) {
  458. return new Iterator(iteratorDone);
  459. }
  460. var iterations = 0;
  461. return new Iterator(function() {
  462. var step = iterator.next();
  463. return step.done ? step : iteratorValue(type, iterations++, step.value);
  464. });
  465. };
  466. createClass(IteratorSeq, IndexedSeq);
  467. function IteratorSeq(iterator) {
  468. this._iterator = iterator;
  469. this._iteratorCache = [];
  470. }
  471. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  472. if (reverse) {
  473. return this.cacheResult().__iterate(fn, reverse);
  474. }
  475. var iterator = this._iterator;
  476. var cache = this._iteratorCache;
  477. var iterations = 0;
  478. while (iterations < cache.length) {
  479. if (fn(cache[iterations], iterations++, this) === false) {
  480. return iterations;
  481. }
  482. }
  483. var step;
  484. while (!(step = iterator.next()).done) {
  485. var val = step.value;
  486. cache[iterations] = val;
  487. if (fn(val, iterations++, this) === false) {
  488. break;
  489. }
  490. }
  491. return iterations;
  492. };
  493. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  494. if (reverse) {
  495. return this.cacheResult().__iterator(type, reverse);
  496. }
  497. var iterator = this._iterator;
  498. var cache = this._iteratorCache;
  499. var iterations = 0;
  500. return new Iterator(function() {
  501. if (iterations >= cache.length) {
  502. var step = iterator.next();
  503. if (step.done) {
  504. return step;
  505. }
  506. cache[iterations] = step.value;
  507. }
  508. return iteratorValue(type, iterations, cache[iterations++]);
  509. });
  510. };
  511. // # pragma Helper functions
  512. function isSeq(maybeSeq) {
  513. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  514. }
  515. var EMPTY_SEQ;
  516. function emptySequence() {
  517. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  518. }
  519. function keyedSeqFromValue(value) {
  520. var seq =
  521. Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
  522. isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
  523. hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
  524. typeof value === 'object' ? new ObjectSeq(value) :
  525. undefined;
  526. if (!seq) {
  527. throw new TypeError(
  528. 'Expected Array or iterable object of [k, v] entries, '+
  529. 'or keyed object: ' + value
  530. );
  531. }
  532. return seq;
  533. }
  534. function indexedSeqFromValue(value) {
  535. var seq = maybeIndexedSeqFromValue(value);
  536. if (!seq) {
  537. throw new TypeError(
  538. 'Expected Array or iterable object of values: ' + value
  539. );
  540. }
  541. return seq;
  542. }
  543. function seqFromValue(value) {
  544. var seq = maybeIndexedSeqFromValue(value) ||
  545. (typeof value === 'object' && new ObjectSeq(value));
  546. if (!seq) {
  547. throw new TypeError(
  548. 'Expected Array or iterable object of values, or keyed object: ' + value
  549. );
  550. }
  551. return seq;
  552. }
  553. function maybeIndexedSeqFromValue(value) {
  554. return (
  555. isArrayLike(value) ? new ArraySeq(value) :
  556. isIterator(value) ? new IteratorSeq(value) :
  557. hasIterator(value) ? new IterableSeq(value) :
  558. undefined
  559. );
  560. }
  561. function seqIterate(seq, fn, reverse, useKeys) {
  562. var cache = seq._cache;
  563. if (cache) {
  564. var maxIndex = cache.length - 1;
  565. for (var ii = 0; ii <= maxIndex; ii++) {
  566. var entry = cache[reverse ? maxIndex - ii : ii];
  567. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  568. return ii + 1;
  569. }
  570. }
  571. return ii;
  572. }
  573. return seq.__iterateUncached(fn, reverse);
  574. }
  575. function seqIterator(seq, type, reverse, useKeys) {
  576. var cache = seq._cache;
  577. if (cache) {
  578. var maxIndex = cache.length - 1;
  579. var ii = 0;
  580. return new Iterator(function() {
  581. var entry = cache[reverse ? maxIndex - ii : ii];
  582. return ii++ > maxIndex ?
  583. iteratorDone() :
  584. iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  585. });
  586. }
  587. return seq.__iteratorUncached(type, reverse);
  588. }
  589. function fromJS(json, converter) {
  590. return converter ?
  591. fromJSWith(converter, json, '', {'': json}) :
  592. fromJSDefault(json);
  593. }
  594. function fromJSWith(converter, json, key, parentJSON) {
  595. if (Array.isArray(json)) {
  596. return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  597. }
  598. if (isPlainObj(json)) {
  599. return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  600. }
  601. return json;
  602. }
  603. function fromJSDefault(json) {
  604. if (Array.isArray(json)) {
  605. return IndexedSeq(json).map(fromJSDefault).toList();
  606. }
  607. if (isPlainObj(json)) {
  608. return KeyedSeq(json).map(fromJSDefault).toMap();
  609. }
  610. return json;
  611. }
  612. function isPlainObj(value) {
  613. return value && (value.constructor === Object || value.constructor === undefined);
  614. }
  615. /**
  616. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  617. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  618. *
  619. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  620. * value, which is different from the algorithm described by
  621. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  622. *
  623. * This is extended further to allow Objects to describe the values they
  624. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  625. *
  626. * Note: because of this extension, the key equality of Immutable.Map and the
  627. * value equality of Immutable.Set will differ from ES6 Map and Set.
  628. *
  629. * ### Defining custom values
  630. *
  631. * The easiest way to describe the value an object represents is by implementing
  632. * `valueOf`. For example, `Date` represents a value by returning a unix
  633. * timestamp for `valueOf`:
  634. *
  635. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  636. * var date2 = new Date(1234567890000);
  637. * date1.valueOf(); // 1234567890000
  638. * assert( date1 !== date2 );
  639. * assert( Immutable.is( date1, date2 ) );
  640. *
  641. * Note: overriding `valueOf` may have other implications if you use this object
  642. * where JavaScript expects a primitive, such as implicit string coercion.
  643. *
  644. * For more complex types, especially collections, implementing `valueOf` may
  645. * not be performant. An alternative is to implement `equals` and `hashCode`.
  646. *
  647. * `equals` takes another object, presumably of similar type, and returns true
  648. * if the it is equal. Equality is symmetrical, so the same result should be
  649. * returned if this and the argument are flipped.
  650. *
  651. * assert( a.equals(b) === b.equals(a) );
  652. *
  653. * `hashCode` returns a 32bit integer number representing the object which will
  654. * be used to determine how to store the value object in a Map or Set. You must
  655. * provide both or neither methods, one must not exist without the other.
  656. *
  657. * Also, an important relationship between these methods must be upheld: if two
  658. * values are equal, they *must* return the same hashCode. If the values are not
  659. * equal, they might have the same hashCode; this is called a hash collision,
  660. * and while undesirable for performance reasons, it is acceptable.
  661. *
  662. * if (a.equals(b)) {
  663. * assert( a.hashCode() === b.hashCode() );
  664. * }
  665. *
  666. * All Immutable collections implement `equals` and `hashCode`.
  667. *
  668. */
  669. function is(valueA, valueB) {
  670. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  671. return true;
  672. }
  673. if (!valueA || !valueB) {
  674. return false;
  675. }
  676. if (typeof valueA.valueOf === 'function' &&
  677. typeof valueB.valueOf === 'function') {
  678. valueA = valueA.valueOf();
  679. valueB = valueB.valueOf();
  680. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  681. return true;
  682. }
  683. if (!valueA || !valueB) {
  684. return false;
  685. }
  686. }
  687. if (typeof valueA.equals === 'function' &&
  688. typeof valueB.equals === 'function' &&
  689. valueA.equals(valueB)) {
  690. return true;
  691. }
  692. return false;
  693. }
  694. function deepEqual(a, b) {
  695. if (a === b) {
  696. return true;
  697. }
  698. if (
  699. !isIterable(b) ||
  700. a.size !== undefined && b.size !== undefined && a.size !== b.size ||
  701. a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
  702. isKeyed(a) !== isKeyed(b) ||
  703. isIndexed(a) !== isIndexed(b) ||
  704. isOrdered(a) !== isOrdered(b)
  705. ) {
  706. return false;
  707. }
  708. if (a.size === 0 && b.size === 0) {
  709. return true;
  710. }
  711. var notAssociative = !isAssociative(a);
  712. if (isOrdered(a)) {
  713. var entries = a.entries();
  714. return b.every(function(v, k) {
  715. var entry = entries.next().value;
  716. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  717. }) && entries.next().done;
  718. }
  719. var flipped = false;
  720. if (a.size === undefined) {
  721. if (b.size === undefined) {
  722. if (typeof a.cacheResult === 'function') {
  723. a.cacheResult();
  724. }
  725. } else {
  726. flipped = true;
  727. var _ = a;
  728. a = b;
  729. b = _;
  730. }
  731. }
  732. var allEqual = true;
  733. var bSize = b.__iterate(function(v, k) {
  734. if (notAssociative ? !a.has(v) :
  735. flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
  736. allEqual = false;
  737. return false;
  738. }
  739. });
  740. return allEqual && a.size === bSize;
  741. }
  742. createClass(Repeat, IndexedSeq);
  743. function Repeat(value, times) {
  744. if (!(this instanceof Repeat)) {
  745. return new Repeat(value, times);
  746. }
  747. this._value = value;
  748. this.size = times === undefined ? Infinity : Math.max(0, times);
  749. if (this.size === 0) {
  750. if (EMPTY_REPEAT) {
  751. return EMPTY_REPEAT;
  752. }
  753. EMPTY_REPEAT = this;
  754. }
  755. }
  756. Repeat.prototype.toString = function() {
  757. if (this.size === 0) {
  758. return 'Repeat []';
  759. }
  760. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  761. };
  762. Repeat.prototype.get = function(index, notSetValue) {
  763. return this.has(index) ? this._value : notSetValue;
  764. };
  765. Repeat.prototype.includes = function(searchValue) {
  766. return is(this._value, searchValue);
  767. };
  768. Repeat.prototype.slice = function(begin, end) {
  769. var size = this.size;
  770. return wholeSlice(begin, end, size) ? this :
  771. new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
  772. };
  773. Repeat.prototype.reverse = function() {
  774. return this;
  775. };
  776. Repeat.prototype.indexOf = function(searchValue) {
  777. if (is(this._value, searchValue)) {
  778. return 0;
  779. }
  780. return -1;
  781. };
  782. Repeat.prototype.lastIndexOf = function(searchValue) {
  783. if (is(this._value, searchValue)) {
  784. return this.size;
  785. }
  786. return -1;
  787. };
  788. Repeat.prototype.__iterate = function(fn, reverse) {
  789. for (var ii = 0; ii < this.size; ii++) {
  790. if (fn(this._value, ii, this) === false) {
  791. return ii + 1;
  792. }
  793. }
  794. return ii;
  795. };
  796. Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
  797. var ii = 0;
  798. return new Iterator(function()
  799. {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
  800. );
  801. };
  802. Repeat.prototype.equals = function(other) {
  803. return other instanceof Repeat ?
  804. is(this._value, other._value) :
  805. deepEqual(other);
  806. };
  807. var EMPTY_REPEAT;
  808. function invariant(condition, error) {
  809. if (!condition) throw new Error(error);
  810. }
  811. createClass(Range, IndexedSeq);
  812. function Range(start, end, step) {
  813. if (!(this instanceof Range)) {
  814. return new Range(start, end, step);
  815. }
  816. invariant(step !== 0, 'Cannot step a Range by 0');
  817. start = start || 0;
  818. if (end === undefined) {
  819. end = Infinity;
  820. }
  821. step = step === undefined ? 1 : Math.abs(step);
  822. if (end < start) {
  823. step = -step;
  824. }
  825. this._start = start;
  826. this._end = end;
  827. this._step = step;
  828. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  829. if (this.size === 0) {
  830. if (EMPTY_RANGE) {
  831. return EMPTY_RANGE;
  832. }
  833. EMPTY_RANGE = this;
  834. }
  835. }
  836. Range.prototype.toString = function() {
  837. if (this.size === 0) {
  838. return 'Range []';
  839. }
  840. return 'Range [ ' +
  841. this._start + '...' + this._end +
  842. (this._step > 1 ? ' by ' + this._step : '') +
  843. ' ]';
  844. };
  845. Range.prototype.get = function(index, notSetValue) {
  846. return this.has(index) ?
  847. this._start + wrapIndex(this, index) * this._step :
  848. notSetValue;
  849. };
  850. Range.prototype.includes = function(searchValue) {
  851. var possibleIndex = (searchValue - this._start) / this._step;
  852. return possibleIndex >= 0 &&
  853. possibleIndex < this.size &&
  854. possibleIndex === Math.floor(possibleIndex);
  855. };
  856. Range.prototype.slice = function(begin, end) {
  857. if (wholeSlice(begin, end, this.size)) {
  858. return this;
  859. }
  860. begin = resolveBegin(begin, this.size);
  861. end = resolveEnd(end, this.size);
  862. if (end <= begin) {
  863. return new Range(0, 0);
  864. }
  865. return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
  866. };
  867. Range.prototype.indexOf = function(searchValue) {
  868. var offsetValue = searchValue - this._start;
  869. if (offsetValue % this._step === 0) {
  870. var index = offsetValue / this._step;
  871. if (index >= 0 && index < this.size) {
  872. return index
  873. }
  874. }
  875. return -1;
  876. };
  877. Range.prototype.lastIndexOf = function(searchValue) {
  878. return this.indexOf(searchValue);
  879. };
  880. Range.prototype.__iterate = function(fn, reverse) {
  881. var maxIndex = this.size - 1;
  882. var step = this._step;
  883. var value = reverse ? this._start + maxIndex * step : this._start;
  884. for (var ii = 0; ii <= maxIndex; ii++) {
  885. if (fn(value, ii, this) === false) {
  886. return ii + 1;
  887. }
  888. value += reverse ? -step : step;
  889. }
  890. return ii;
  891. };
  892. Range.prototype.__iterator = function(type, reverse) {
  893. var maxIndex = this.size - 1;
  894. var step = this._step;
  895. var value = reverse ? this._start + maxIndex * step : this._start;
  896. var ii = 0;
  897. return new Iterator(function() {
  898. var v = value;
  899. value += reverse ? -step : step;
  900. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  901. });
  902. };
  903. Range.prototype.equals = function(other) {
  904. return other instanceof Range ?
  905. this._start === other._start &&
  906. this._end === other._end &&
  907. this._step === other._step :
  908. deepEqual(this, other);
  909. };
  910. var EMPTY_RANGE;
  911. createClass(Collection, Iterable);
  912. function Collection() {
  913. throw TypeError('Abstract');
  914. }
  915. createClass(KeyedCollection, Collection);function KeyedCollection() {}
  916. createClass(IndexedCollection, Collection);function IndexedCollection() {}
  917. createClass(SetCollection, Collection);function SetCollection() {}
  918. Collection.Keyed = KeyedCollection;
  919. Collection.Indexed = IndexedCollection;
  920. Collection.Set = SetCollection;
  921. var imul =
  922. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
  923. Math.imul :
  924. function imul(a, b) {
  925. a = a | 0; // int
  926. b = b | 0; // int
  927. var c = a & 0xffff;
  928. var d = b & 0xffff;
  929. // Shift by 0 fixes the sign on the high part.
  930. return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
  931. };
  932. // v8 has an optimization for storing 31-bit signed numbers.
  933. // Values which have either 00 or 11 as the high order bits qualify.
  934. // This function drops the highest order bit in a signed number, maintaining
  935. // the sign bit.
  936. function smi(i32) {
  937. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
  938. }
  939. function hash(o) {
  940. if (o === false || o === null || o === undefined) {
  941. return 0;
  942. }
  943. if (typeof o.valueOf === 'function') {
  944. o = o.valueOf();
  945. if (o === false || o === null || o === undefined) {
  946. return 0;
  947. }
  948. }
  949. if (o === true) {
  950. return 1;
  951. }
  952. var type = typeof o;
  953. if (type === 'number') {
  954. var h = o | 0;
  955. if (h !== o) {
  956. h ^= o * 0xFFFFFFFF;
  957. }
  958. while (o > 0xFFFFFFFF) {
  959. o /= 0xFFFFFFFF;
  960. h ^= o;
  961. }
  962. return smi(h);
  963. }
  964. if (type === 'string') {
  965. return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
  966. }
  967. if (typeof o.hashCode === 'function') {
  968. return o.hashCode();
  969. }
  970. if (type === 'object') {
  971. return hashJSObj(o);
  972. }
  973. if (typeof o.toString === 'function') {
  974. return hashString(o.toString());
  975. }
  976. throw new Error('Value type ' + type + ' cannot be hashed.');
  977. }
  978. function cachedHashString(string) {
  979. var hash = stringHashCache[string];
  980. if (hash === undefined) {
  981. hash = hashString(string);
  982. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  983. STRING_HASH_CACHE_SIZE = 0;
  984. stringHashCache = {};
  985. }
  986. STRING_HASH_CACHE_SIZE++;
  987. stringHashCache[string] = hash;
  988. }
  989. return hash;
  990. }
  991. // http://jsperf.com/hashing-strings
  992. function hashString(string) {
  993. // This is the hash from JVM
  994. // The hash code for a string is computed as
  995. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  996. // where s[i] is the ith character of the string and n is the length of
  997. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  998. // (exclusive) by dropping high bits.
  999. var hash = 0;
  1000. for (var ii = 0; ii < string.length; ii++) {
  1001. hash = 31 * hash + string.charCodeAt(ii) | 0;
  1002. }
  1003. return smi(hash);
  1004. }
  1005. function hashJSObj(obj) {
  1006. var hash;
  1007. if (usingWeakMap) {
  1008. hash = weakMap.get(obj);
  1009. if (hash !== undefined) {
  1010. return hash;
  1011. }
  1012. }
  1013. hash = obj[UID_HASH_KEY];
  1014. if (hash !== undefined) {
  1015. return hash;
  1016. }
  1017. if (!canDefineProperty) {
  1018. hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  1019. if (hash !== undefined) {
  1020. return hash;
  1021. }
  1022. hash = getIENodeHash(obj);
  1023. if (hash !== undefined) {
  1024. return hash;
  1025. }
  1026. }
  1027. hash = ++objHashUID;
  1028. if (objHashUID & 0x40000000) {
  1029. objHashUID = 0;
  1030. }
  1031. if (usingWeakMap) {
  1032. weakMap.set(obj, hash);
  1033. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  1034. throw new Error('Non-extensible objects are not allowed as keys.');
  1035. } else if (canDefineProperty) {
  1036. Object.defineProperty(obj, UID_HASH_KEY, {
  1037. 'enumerable': false,
  1038. 'configurable': false,
  1039. 'writable': false,
  1040. 'value': hash
  1041. });
  1042. } else if (obj.propertyIsEnumerable !== undefined &&
  1043. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
  1044. // Since we can't define a non-enumerable property on the object
  1045. // we'll hijack one of the less-used non-enumerable properties to
  1046. // save our hash on it. Since this is a function it will not show up in
  1047. // `JSON.stringify` which is what we want.
  1048. obj.propertyIsEnumerable = function() {
  1049. return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
  1050. };
  1051. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  1052. } else if (obj.nodeType !== undefined) {
  1053. // At this point we couldn't get the IE `uniqueID` to use as a hash
  1054. // and we couldn't use a non-enumerable property to exploit the
  1055. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  1056. // itself.
  1057. obj[UID_HASH_KEY] = hash;
  1058. } else {
  1059. throw new Error('Unable to set a non-enumerable property on object.');
  1060. }
  1061. return hash;
  1062. }
  1063. // Get references to ES5 object methods.
  1064. var isExtensible = Object.isExtensible;
  1065. // True if Object.defineProperty works as expected. IE8 fails this test.
  1066. var canDefineProperty = (function() {
  1067. try {
  1068. Object.defineProperty({}, '@', {});
  1069. return true;
  1070. } catch (e) {
  1071. return false;
  1072. }
  1073. }());
  1074. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  1075. // and avoid memory leaks from the IE cloneNode bug.
  1076. function getIENodeHash(node) {
  1077. if (node && node.nodeType > 0) {
  1078. switch (node.nodeType) {
  1079. case 1: // Element
  1080. return node.uniqueID;
  1081. case 9: // Document
  1082. return node.documentElement && node.documentElement.uniqueID;
  1083. }
  1084. }
  1085. }
  1086. // If possible, use a WeakMap.
  1087. var usingWeakMap = typeof WeakMap === 'function';
  1088. var weakMap;
  1089. if (usingWeakMap) {
  1090. weakMap = new WeakMap();
  1091. }
  1092. var objHashUID = 0;
  1093. var UID_HASH_KEY = '__immutablehash__';
  1094. if (typeof Symbol === 'function') {
  1095. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  1096. }
  1097. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  1098. var STRING_HASH_CACHE_MAX_SIZE = 255;
  1099. var STRING_HASH_CACHE_SIZE = 0;
  1100. var stringHashCache = {};
  1101. function assertNotInfinite(size) {
  1102. invariant(
  1103. size !== Infinity,
  1104. 'Cannot perform this action with an infinite size.'
  1105. );
  1106. }
  1107. createClass(Map, KeyedCollection);
  1108. // @pragma Construction
  1109. function Map(value) {
  1110. return value === null || value === undefined ? emptyMap() :
  1111. isMap(value) && !isOrdered(value) ? value :
  1112. emptyMap().withMutations(function(map ) {
  1113. var iter = KeyedIterable(value);
  1114. assertNotInfinite(iter.size);
  1115. iter.forEach(function(v, k) {return map.set(k, v)});
  1116. });
  1117. }
  1118. Map.prototype.toString = function() {
  1119. return this.__toString('Map {', '}');
  1120. };
  1121. // @pragma Access
  1122. Map.prototype.get = function(k, notSetValue) {
  1123. return this._root ?
  1124. this._root.get(0, undefined, k, notSetValue) :
  1125. notSetValue;
  1126. };
  1127. // @pragma Modification
  1128. Map.prototype.set = function(k, v) {
  1129. return updateMap(this, k, v);
  1130. };
  1131. Map.prototype.setIn = function(keyPath, v) {
  1132. return this.updateIn(keyPath, NOT_SET, function() {return v});
  1133. };
  1134. Map.prototype.remove = function(k) {
  1135. return updateMap(this, k, NOT_SET);
  1136. };
  1137. Map.prototype.deleteIn = function(keyPath) {
  1138. return this.updateIn(keyPath, function() {return NOT_SET});
  1139. };
  1140. Map.prototype.update = function(k, notSetValue, updater) {
  1141. return arguments.length === 1 ?
  1142. k(this) :
  1143. this.updateIn([k], notSetValue, updater);
  1144. };
  1145. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  1146. if (!updater) {
  1147. updater = notSetValue;
  1148. notSetValue = undefined;
  1149. }
  1150. var updatedValue = updateInDeepMap(
  1151. this,
  1152. forceIterator(keyPath),
  1153. notSetValue,
  1154. updater
  1155. );
  1156. return updatedValue === NOT_SET ? undefined : updatedValue;
  1157. };
  1158. Map.prototype.clear = function() {
  1159. if (this.size === 0) {
  1160. return this;
  1161. }
  1162. if (this.__ownerID) {
  1163. this.size = 0;
  1164. this._root = null;
  1165. this.__hash = undefined;
  1166. this.__altered = true;
  1167. return this;
  1168. }
  1169. return emptyMap();
  1170. };
  1171. // @pragma Composition
  1172. Map.prototype.merge = function(/*...iters*/) {
  1173. return mergeIntoMapWith(this, undefined, arguments);
  1174. };
  1175. Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  1176. return mergeIntoMapWith(this, merger, iters);
  1177. };
  1178. Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  1179. return this.updateIn(
  1180. keyPath,
  1181. emptyMap(),
  1182. function(m ) {return typeof m.merge === 'function' ?
  1183. m.merge.apply(m, iters) :
  1184. iters[iters.length - 1]}
  1185. );
  1186. };
  1187. Map.prototype.mergeDeep = function(/*...iters*/) {
  1188. return mergeIntoMapWith(this, deepMerger, arguments);
  1189. };
  1190. Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  1191. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  1192. };
  1193. Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  1194. return this.updateIn(
  1195. keyPath,
  1196. emptyMap(),
  1197. function(m ) {return typeof m.mergeDeep === 'function' ?
  1198. m.mergeDeep.apply(m, iters) :
  1199. iters[iters.length - 1]}
  1200. );
  1201. };
  1202. Map.prototype.sort = function(comparator) {
  1203. // Late binding
  1204. return OrderedMap(sortFactory(this, comparator));
  1205. };
  1206. Map.prototype.sortBy = function(mapper, comparator) {
  1207. // Late binding
  1208. return OrderedMap(sortFactory(this, comparator, mapper));
  1209. };
  1210. // @pragma Mutability
  1211. Map.prototype.withMutations = function(fn) {
  1212. var mutable = this.asMutable();
  1213. fn(mutable);
  1214. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  1215. };
  1216. Map.prototype.asMutable = function() {
  1217. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  1218. };
  1219. Map.prototype.asImmutable = function() {
  1220. return this.__ensureOwner();
  1221. };
  1222. Map.prototype.wasAltered = function() {
  1223. return this.__altered;
  1224. };
  1225. Map.prototype.__iterator = function(type, reverse) {
  1226. return new MapIterator(this, type, reverse);
  1227. };
  1228. Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  1229. var iterations = 0;
  1230. this._root && this._root.iterate(function(entry ) {
  1231. iterations++;
  1232. return fn(entry[1], entry[0], this$0);
  1233. }, reverse);
  1234. return iterations;
  1235. };
  1236. Map.prototype.__ensureOwner = function(ownerID) {
  1237. if (ownerID === this.__ownerID) {
  1238. return this;
  1239. }
  1240. if (!ownerID) {
  1241. this.__ownerID = ownerID;
  1242. this.__altered = false;
  1243. return this;
  1244. }
  1245. return makeMap(this.size, this._root, ownerID, this.__hash);
  1246. };
  1247. function isMap(maybeMap) {
  1248. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  1249. }
  1250. Map.isMap = isMap;
  1251. var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  1252. var MapPrototype = Map.prototype;
  1253. MapPrototype[IS_MAP_SENTINEL] = true;
  1254. MapPrototype[DELETE] = MapPrototype.remove;
  1255. MapPrototype.removeIn = MapPrototype.deleteIn;
  1256. // #pragma Trie Nodes
  1257. function ArrayMapNode(ownerID, entries) {
  1258. this.ownerID = ownerID;
  1259. this.entries = entries;
  1260. }
  1261. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1262. var entries = this.entries;
  1263. for (var ii = 0, len = entries.length; ii < len; ii++) {
  1264. if (is(key, entries[ii][0])) {
  1265. return entries[ii][1];
  1266. }
  1267. }
  1268. return notSetValue;
  1269. };
  1270. ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1271. var removed = value === NOT_SET;
  1272. var entries = this.entries;
  1273. var idx = 0;
  1274. for (var len = entries.length; idx < len; idx++) {
  1275. if (is(key, entries[idx][0])) {
  1276. break;
  1277. }
  1278. }
  1279. var exists = idx < len;
  1280. if (exists ? entries[idx][1] === value : removed) {
  1281. return this;
  1282. }
  1283. SetRef(didAlter);
  1284. (removed || !exists) && SetRef(didChangeSize);
  1285. if (removed && entries.length === 1) {
  1286. return; // undefined
  1287. }
  1288. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  1289. return createNodes(ownerID, entries, key, value);
  1290. }
  1291. var isEditable = ownerID && ownerID === this.ownerID;
  1292. var newEntries = isEditable ? entries : arrCopy(entries);
  1293. if (exists) {
  1294. if (removed) {
  1295. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  1296. } else {
  1297. newEntries[idx] = [key, value];
  1298. }
  1299. } else {
  1300. newEntries.push([key, value]);
  1301. }
  1302. if (isEditable) {
  1303. this.entries = newEntries;
  1304. return this;
  1305. }
  1306. return new ArrayMapNode(ownerID, newEntries);
  1307. };
  1308. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  1309. this.ownerID = ownerID;
  1310. this.bitmap = bitmap;
  1311. this.nodes = nodes;
  1312. }
  1313. BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1314. if (keyHash === undefined) {
  1315. keyHash = hash(key);
  1316. }
  1317. var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
  1318. var bitmap = this.bitmap;
  1319. return (bitmap & bit) === 0 ? notSetValue :
  1320. this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
  1321. };
  1322. BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1323. if (keyHash === undefined) {
  1324. keyHash = hash(key);
  1325. }
  1326. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1327. var bit = 1 << keyHashFrag;
  1328. var bitmap = this.bitmap;
  1329. var exists = (bitmap & bit) !== 0;
  1330. if (!exists && value === NOT_SET) {
  1331. return this;
  1332. }
  1333. var idx = popCount(bitmap & (bit - 1));
  1334. var nodes = this.nodes;
  1335. var node = exists ? nodes[idx] : undefined;
  1336. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  1337. if (newNode === node) {
  1338. return this;
  1339. }
  1340. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  1341. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  1342. }
  1343. if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
  1344. return nodes[idx ^ 1];
  1345. }
  1346. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  1347. return newNode;
  1348. }
  1349. var isEditable = ownerID && ownerID === this.ownerID;
  1350. var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
  1351. var newNodes = exists ? newNode ?
  1352. setIn(nodes, idx, newNode, isEditable) :
  1353. spliceOut(nodes, idx, isEditable) :
  1354. spliceIn(nodes, idx, newNode, isEditable);
  1355. if (isEditable) {
  1356. this.bitmap = newBitmap;
  1357. this.nodes = newNodes;
  1358. return this;
  1359. }
  1360. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  1361. };
  1362. function HashArrayMapNode(ownerID, count, nodes) {
  1363. this.ownerID = ownerID;
  1364. this.count = count;
  1365. this.nodes = nodes;
  1366. }
  1367. HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1368. if (keyHash === undefined) {
  1369. keyHash = hash(key);
  1370. }
  1371. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1372. var node = this.nodes[idx];
  1373. return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
  1374. };
  1375. HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1376. if (keyHash === undefined) {
  1377. keyHash = hash(key);
  1378. }
  1379. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1380. var removed = value === NOT_SET;
  1381. var nodes = this.nodes;
  1382. var node = nodes[idx];
  1383. if (removed && !node) {
  1384. return this;
  1385. }
  1386. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  1387. if (newNode === node) {
  1388. return this;
  1389. }
  1390. var newCount = this.count;
  1391. if (!node) {
  1392. newCount++;
  1393. } else if (!newNode) {
  1394. newCount--;
  1395. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  1396. return packNodes(ownerID, nodes, newCount, idx);
  1397. }
  1398. }
  1399. var isEditable = ownerID && ownerID === this.ownerID;
  1400. var newNodes = setIn(nodes, idx, newNode, isEditable);
  1401. if (isEditable) {
  1402. this.count = newCount;
  1403. this.nodes = newNodes;
  1404. return this;
  1405. }
  1406. return new HashArrayMapNode(ownerID, newCount, newNodes);
  1407. };
  1408. function HashCollisionNode(ownerID, keyHash, entries) {
  1409. this.ownerID = ownerID;
  1410. this.keyHash = keyHash;
  1411. this.entries = entries;
  1412. }
  1413. HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1414. var entries = this.entries;
  1415. for (var ii = 0, len = entries.length; ii < len; ii++) {
  1416. if (is(key, entries[ii][0])) {
  1417. return entries[ii][1];
  1418. }
  1419. }
  1420. return notSetValue;
  1421. };
  1422. HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1423. if (keyHash === undefined) {
  1424. keyHash = hash(key);
  1425. }
  1426. var removed = value === NOT_SET;
  1427. if (keyHash !== this.keyHash) {
  1428. if (removed) {
  1429. return this;
  1430. }
  1431. SetRef(didAlter);
  1432. SetRef(didChangeSize);
  1433. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  1434. }
  1435. var entries = this.entries;
  1436. var idx = 0;
  1437. for (var len = entries.length; idx < len; idx++) {
  1438. if (is(key, entries[idx][0])) {
  1439. break;
  1440. }
  1441. }
  1442. var exists = idx < len;
  1443. if (exists ? entries[idx][1] === value : removed) {
  1444. return this;
  1445. }
  1446. SetRef(didAlter);
  1447. (removed || !exists) && SetRef(didChangeSize);
  1448. if (removed && len === 2) {
  1449. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  1450. }
  1451. var isEditable = ownerID && ownerID === this.ownerID;
  1452. var newEntries = isEditable ? entries : arrCopy(entries);
  1453. if (exists) {
  1454. if (removed) {
  1455. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  1456. } else {
  1457. newEntries[idx] = [key, value];
  1458. }
  1459. } else {
  1460. newEntries.push([key, value]);
  1461. }
  1462. if (isEditable) {
  1463. this.entries = newEntries;
  1464. return this;
  1465. }
  1466. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  1467. };
  1468. function ValueNode(ownerID, keyHash, entry) {
  1469. this.ownerID = ownerID;
  1470. this.keyHash = keyHash;
  1471. this.entry = entry;
  1472. }
  1473. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  1474. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  1475. };
  1476. ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1477. var removed = value === NOT_SET;
  1478. var keyMatch = is(key, this.entry[0]);
  1479. if (keyMatch ? value === this.entry[1] : removed) {
  1480. return this;
  1481. }
  1482. SetRef(didAlter);
  1483. if (removed) {
  1484. SetRef(didChangeSize);
  1485. return; // undefined
  1486. }
  1487. if (keyMatch) {
  1488. if (ownerID && ownerID === this.ownerID) {
  1489. this.entry[1] = value;
  1490. return this;
  1491. }
  1492. return new ValueNode(ownerID, this.keyHash, [key, value]);
  1493. }
  1494. SetRef(didChangeSize);
  1495. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  1496. };
  1497. // #pragma Iterators
  1498. ArrayMapNode.prototype.iterate =
  1499. HashCollisionNode.prototype.iterate = function (fn, reverse) {
  1500. var entries = this.entries;
  1501. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  1502. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  1503. return false;
  1504. }
  1505. }
  1506. };
  1507. BitmapIndexedNode.prototype.iterate =
  1508. HashArrayMapNode.prototype.iterate = function (fn, reverse) {
  1509. var nodes = this.nodes;
  1510. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  1511. var node = nodes[reverse ? maxIndex - ii : ii];
  1512. if (node && node.iterate(fn, reverse) === false) {
  1513. return false;
  1514. }
  1515. }
  1516. };
  1517. ValueNode.prototype.iterate = function (fn, reverse) {
  1518. return fn(this.entry);
  1519. };
  1520. createClass(MapIterator, Iterator);
  1521. function MapIterator(map, type, reverse) {
  1522. this._type = type;
  1523. this._reverse = reverse;
  1524. this._stack = map._root && mapIteratorFrame(map._root);
  1525. }
  1526. MapIterator.prototype.next = function() {
  1527. var type = this._type;
  1528. var stack = this._stack;
  1529. while (stack) {
  1530. var node = stack.node;
  1531. var index = stack.index++;
  1532. var maxIndex;
  1533. if (node.entry) {
  1534. if (index === 0) {
  1535. return mapIteratorValue(type, node.entry);
  1536. }
  1537. } else if (node.entries) {
  1538. maxIndex = node.entries.length - 1;
  1539. if (index <= maxIndex) {
  1540. return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
  1541. }
  1542. } else {
  1543. maxIndex = node.nodes.length - 1;
  1544. if (index <= maxIndex) {
  1545. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  1546. if (subNode) {
  1547. if (subNode.entry) {
  1548. return mapIteratorValue(type, subNode.entry);
  1549. }
  1550. stack = this._stack = mapIteratorFrame(subNode, stack);
  1551. }
  1552. continue;
  1553. }
  1554. }
  1555. stack = this._stack = this._stack.__prev;
  1556. }
  1557. return iteratorDone();
  1558. };
  1559. function mapIteratorValue(type, entry) {
  1560. return iteratorValue(type, entry[0], entry[1]);
  1561. }
  1562. function mapIteratorFrame(node, prev) {
  1563. return {
  1564. node: node,
  1565. index: 0,
  1566. __prev: prev
  1567. };
  1568. }
  1569. function makeMap(size, root, ownerID, hash) {
  1570. var map = Object.create(MapPrototype);
  1571. map.size = size;
  1572. map._root = root;
  1573. map.__ownerID = ownerID;
  1574. map.__hash = hash;
  1575. map.__altered = false;
  1576. return map;
  1577. }
  1578. var EMPTY_MAP;
  1579. function emptyMap() {
  1580. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  1581. }
  1582. function updateMap(map, k, v) {
  1583. var newRoot;
  1584. var newSize;
  1585. if (!map._root) {
  1586. if (v === NOT_SET) {
  1587. return map;
  1588. }
  1589. newSize = 1;
  1590. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  1591. } else {
  1592. var didChangeSize = MakeRef(CHANGE_LENGTH);
  1593. var didAlter = MakeRef(DID_ALTER);
  1594. newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
  1595. if (!didAlter.value) {
  1596. return map;
  1597. }
  1598. newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
  1599. }
  1600. if (map.__ownerID) {
  1601. map.size = newSize;
  1602. map._root = newRoot;
  1603. map.__hash = undefined;
  1604. map.__altered = true;
  1605. return map;
  1606. }
  1607. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  1608. }
  1609. function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  1610. if (!node) {
  1611. if (value === NOT_SET) {
  1612. return node;
  1613. }
  1614. SetRef(didAlter);
  1615. SetRef(didChangeSize);
  1616. return new ValueNode(ownerID, keyHash, [key, value]);
  1617. }
  1618. return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
  1619. }
  1620. function isLeafNode(node) {
  1621. return node.constructor === ValueNode || node.constructor === HashCollisionNode;
  1622. }
  1623. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  1624. if (node.keyHash === keyHash) {
  1625. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  1626. }
  1627. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  1628. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  1629. var newNode;
  1630. var nodes = idx1 === idx2 ?
  1631. [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
  1632. ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
  1633. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  1634. }
  1635. function createNodes(ownerID, entries, key, value) {
  1636. if (!ownerID) {
  1637. ownerID = new OwnerID();
  1638. }
  1639. var node = new ValueNode(ownerID, hash(key), [key, value]);
  1640. for (var ii = 0; ii < entries.length; ii++) {
  1641. var entry = entries[ii];
  1642. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  1643. }
  1644. return node;
  1645. }
  1646. function packNodes(ownerID, nodes, count, excluding) {
  1647. var bitmap = 0;
  1648. var packedII = 0;
  1649. var packedNodes = new Array(count);
  1650. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  1651. var node = nodes[ii];
  1652. if (node !== undefined && ii !== excluding) {
  1653. bitmap |= bit;
  1654. packedNodes[packedII++] = node;
  1655. }
  1656. }
  1657. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  1658. }
  1659. function expandNodes(ownerID, nodes, bitmap, including, node) {
  1660. var count = 0;
  1661. var expandedNodes = new Array(SIZE);
  1662. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  1663. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  1664. }
  1665. expandedNodes[including] = node;
  1666. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  1667. }
  1668. function mergeIntoMapWith(map, merger, iterables) {
  1669. var iters = [];
  1670. for (var ii = 0; ii < iterables.length; ii++) {
  1671. var value = iterables[ii];
  1672. var iter = KeyedIterable(value);
  1673. if (!isIterable(value)) {
  1674. iter = iter.map(function(v ) {return fromJS(v)});
  1675. }
  1676. iters.push(iter);
  1677. }
  1678. return mergeIntoCollectionWith(map, merger, iters);
  1679. }
  1680. function deepMerger(existing, value, key) {
  1681. return existing && existing.mergeDeep && isIterable(value) ?
  1682. existing.mergeDeep(value) :
  1683. is(existing, value) ? existing : value;
  1684. }
  1685. function deepMergerWith(merger) {
  1686. return function(existing, value, key) {
  1687. if (existing && existing.mergeDeepWith && isIterable(value)) {
  1688. return existing.mergeDeepWith(merger, value);
  1689. }
  1690. var nextValue = merger(existing, value, key);
  1691. return is(existing, nextValue) ? existing : nextValue;
  1692. };
  1693. }
  1694. function mergeIntoCollectionWith(collection, merger, iters) {
  1695. iters = iters.filter(function(x ) {return x.size !== 0});
  1696. if (iters.length === 0) {
  1697. return collection;
  1698. }
  1699. if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
  1700. return collection.constructor(iters[0]);
  1701. }
  1702. return collection.withMutations(function(collection ) {
  1703. var mergeIntoMap = merger ?
  1704. function(value, key) {
  1705. collection.update(key, NOT_SET, function(existing )
  1706. {return existing === NOT_SET ? value : merger(existing, value, key)}
  1707. );
  1708. } :
  1709. function(value, key) {
  1710. collection.set(key, value);
  1711. };
  1712. for (var ii = 0; ii < iters.length; ii++) {
  1713. iters[ii].forEach(mergeIntoMap);
  1714. }
  1715. });
  1716. }
  1717. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  1718. var isNotSet = existing === NOT_SET;
  1719. var step = keyPathIter.next();
  1720. if (step.done) {
  1721. var existingValue = isNotSet ? notSetValue : existing;
  1722. var newValue = updater(existingValue);
  1723. return newValue === existingValue ? existing : newValue;
  1724. }
  1725. invariant(
  1726. isNotSet || (existing && existing.set),
  1727. 'invalid keyPath'
  1728. );
  1729. var key = step.value;
  1730. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  1731. var nextUpdated = updateInDeepMap(
  1732. nextExisting,
  1733. keyPathIter,
  1734. notSetValue,
  1735. updater
  1736. );
  1737. return nextUpdated === nextExisting ? existing :
  1738. nextUpdated === NOT_SET ? existing.remove(key) :
  1739. (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  1740. }
  1741. function popCount(x) {
  1742. x = x - ((x >> 1) & 0x55555555);
  1743. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  1744. x = (x + (x >> 4)) & 0x0f0f0f0f;
  1745. x = x + (x >> 8);
  1746. x = x + (x >> 16);
  1747. return x & 0x7f;
  1748. }
  1749. function setIn(array, idx, val, canEdit) {
  1750. var newArray = canEdit ? array : arrCopy(array);
  1751. newArray[idx] = val;
  1752. return newArray;
  1753. }
  1754. function spliceIn(array, idx, val, canEdit) {
  1755. var newLen = array.length + 1;
  1756. if (canEdit && idx + 1 === newLen) {
  1757. array[idx] = val;
  1758. return array;
  1759. }
  1760. var newArray = new Array(newLen);
  1761. var after = 0;
  1762. for (var ii = 0; ii < newLen; ii++) {
  1763. if (ii === idx) {
  1764. newArray[ii] = val;
  1765. after = -1;
  1766. } else {
  1767. newArray[ii] = array[ii + after];
  1768. }
  1769. }
  1770. return newArray;
  1771. }
  1772. function spliceOut(array, idx, canEdit) {
  1773. var newLen = array.length - 1;
  1774. if (canEdit && idx === newLen) {
  1775. array.pop();
  1776. return array;
  1777. }
  1778. var newArray = new Array(newLen);
  1779. var after = 0;
  1780. for (var ii = 0; ii < newLen; ii++) {
  1781. if (ii === idx) {
  1782. after = 1;
  1783. }
  1784. newArray[ii] = array[ii + after];
  1785. }
  1786. return newArray;
  1787. }
  1788. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  1789. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  1790. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  1791. createClass(List, IndexedCollection);
  1792. // @pragma Construction
  1793. function List(value) {
  1794. var empty = emptyList();
  1795. if (value === null || value === undefined) {
  1796. return empty;
  1797. }
  1798. if (isList(value)) {
  1799. return value;
  1800. }
  1801. var iter = IndexedIterable(value);
  1802. var size = iter.size;
  1803. if (size === 0) {
  1804. return empty;
  1805. }
  1806. assertNotInfinite(size);
  1807. if (size > 0 && size < SIZE) {
  1808. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  1809. }
  1810. return empty.withMutations(function(list ) {
  1811. list.setSize(size);
  1812. iter.forEach(function(v, i) {return list.set(i, v)});
  1813. });
  1814. }
  1815. List.of = function(/*...values*/) {
  1816. return this(arguments);
  1817. };
  1818. List.prototype.toString = function() {
  1819. return this.__toString('List [', ']');
  1820. };
  1821. // @pragma Access
  1822. List.prototype.get = function(index, notSetValue) {
  1823. index = wrapIndex(this, index);
  1824. if (index >= 0 && index < this.size) {
  1825. index += this._origin;
  1826. var node = listNodeFor(this, index);
  1827. return node && node.array[index & MASK];
  1828. }
  1829. return notSetValue;
  1830. };
  1831. // @pragma Modification
  1832. List.prototype.set = function(index, value) {
  1833. return updateList(this, index, value);
  1834. };
  1835. List.prototype.remove = function(index) {
  1836. return !this.has(index) ? this :
  1837. index === 0 ? this.shift() :
  1838. index === this.size - 1 ? this.pop() :
  1839. this.splice(index, 1);
  1840. };
  1841. List.prototype.insert = function(index, value) {
  1842. return this.splice(index, 0, value);
  1843. };
  1844. List.prototype.clear = function() {
  1845. if (this.size === 0) {
  1846. return this;
  1847. }
  1848. if (this.__ownerID) {
  1849. this.size = this._origin = this._capacity = 0;
  1850. this._level = SHIFT;
  1851. this._root = this._tail = null;
  1852. this.__hash = undefined;
  1853. this.__altered = true;
  1854. return this;
  1855. }
  1856. return emptyList();
  1857. };
  1858. List.prototype.push = function(/*...values*/) {
  1859. var values = arguments;
  1860. var oldSize = this.size;
  1861. return this.withMutations(function(list ) {
  1862. setListBounds(list, 0, oldSize + values.length);
  1863. for (var ii = 0; ii < values.length; ii++) {
  1864. list.set(oldSize + ii, values[ii]);
  1865. }
  1866. });
  1867. };
  1868. List.prototype.pop = function() {
  1869. return setListBounds(this, 0, -1);
  1870. };
  1871. List.prototype.unshift = function(/*...values*/) {
  1872. var values = arguments;
  1873. return this.withMutations(function(list ) {
  1874. setListBounds(list, -values.length);
  1875. for (var ii = 0; ii < values.length; ii++) {
  1876. list.set(ii, values[ii]);
  1877. }
  1878. });
  1879. };
  1880. List.prototype.shift = function() {
  1881. return setListBounds(this, 1);
  1882. };
  1883. // @pragma Composition
  1884. List.prototype.merge = function(/*...iters*/) {
  1885. return mergeIntoListWith(this, undefined, arguments);
  1886. };
  1887. List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  1888. return mergeIntoListWith(this, merger, iters);
  1889. };
  1890. List.prototype.mergeDeep = function(/*...iters*/) {
  1891. return mergeIntoListWith(this, deepMerger, arguments);
  1892. };
  1893. List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  1894. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  1895. };
  1896. List.prototype.setSize = function(size) {
  1897. return setListBounds(this, 0, size);
  1898. };
  1899. // @pragma Iteration
  1900. List.prototype.slice = function(begin, end) {
  1901. var size = this.size;
  1902. if (wholeSlice(begin, end, size)) {
  1903. return this;
  1904. }
  1905. return setListBounds(
  1906. this,
  1907. resolveBegin(begin, size),
  1908. resolveEnd(end, size)
  1909. );
  1910. };
  1911. List.prototype.__iterator = function(type, reverse) {
  1912. var index = 0;
  1913. var values = iterateList(this, reverse);
  1914. return new Iterator(function() {
  1915. var value = values();
  1916. return value === DONE ?
  1917. iteratorDone() :
  1918. iteratorValue(type, index++, value);
  1919. });
  1920. };
  1921. List.prototype.__iterate = function(fn, reverse) {
  1922. var index = 0;
  1923. var values = iterateList(this, reverse);
  1924. var value;
  1925. while ((value = values()) !== DONE) {
  1926. if (fn(value, index++, this) === false) {
  1927. break;
  1928. }
  1929. }
  1930. return index;
  1931. };
  1932. List.prototype.__ensureOwner = function(ownerID) {
  1933. if (ownerID === this.__ownerID) {
  1934. return this;
  1935. }
  1936. if (!ownerID) {
  1937. this.__ownerID = ownerID;
  1938. return this;
  1939. }
  1940. return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
  1941. };
  1942. function isList(maybeList) {
  1943. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  1944. }
  1945. List.isList = isList;
  1946. var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  1947. var ListPrototype = List.prototype;
  1948. ListPrototype[IS_LIST_SENTINEL] = true;
  1949. ListPrototype[DELETE] = ListPrototype.remove;
  1950. ListPrototype.setIn = MapPrototype.setIn;
  1951. ListPrototype.deleteIn =
  1952. ListPrototype.removeIn = MapPrototype.removeIn;
  1953. ListPrototype.update = MapPrototype.update;
  1954. ListPrototype.updateIn = MapPrototype.updateIn;
  1955. ListPrototype.mergeIn = MapPrototype.mergeIn;
  1956. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  1957. ListPrototype.withMutations = MapPrototype.withMutations;
  1958. ListPrototype.asMutable = MapPrototype.asMutable;
  1959. ListPrototype.asImmutable = MapPrototype.asImmutable;
  1960. ListPrototype.wasAltered = MapPrototype.wasAltered;
  1961. function VNode(array, ownerID) {
  1962. this.array = array;
  1963. this.ownerID = ownerID;
  1964. }
  1965. // TODO: seems like these methods are very similar
  1966. VNode.prototype.removeBefore = function(ownerID, level, index) {
  1967. if (index === level ? 1 << level : this.array.length === 0) {
  1968. return this;
  1969. }
  1970. var originIndex = (index >>> level) & MASK;
  1971. if (originIndex >= this.array.length) {
  1972. return new VNode([], ownerID);
  1973. }
  1974. var removingFirst = originIndex === 0;
  1975. var newChild;
  1976. if (level > 0) {
  1977. var oldChild = this.array[originIndex];
  1978. newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  1979. if (newChild === oldChild && removingFirst) {
  1980. return this;
  1981. }
  1982. }
  1983. if (removingFirst && !newChild) {
  1984. return this;
  1985. }
  1986. var editable = editableVNode(this, ownerID);
  1987. if (!removingFirst) {
  1988. for (var ii = 0; ii < originIndex; ii++) {
  1989. editable.array[ii] = undefined;
  1990. }
  1991. }
  1992. if (newChild) {
  1993. editable.array[originIndex] = newChild;
  1994. }
  1995. return editable;
  1996. };
  1997. VNode.prototype.removeAfter = function(ownerID, level, index) {
  1998. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  1999. return this;
  2000. }
  2001. var sizeIndex = ((index - 1) >>> level) & MASK;
  2002. if (sizeIndex >= this.array.length) {
  2003. return this;
  2004. }
  2005. var newChild;
  2006. if (level > 0) {
  2007. var oldChild = this.array[sizeIndex];
  2008. newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  2009. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  2010. return this;
  2011. }
  2012. }
  2013. var editable = editableVNode(this, ownerID);
  2014. editable.array.splice(sizeIndex + 1);
  2015. if (newChild) {
  2016. editable.array[sizeIndex] = newChild;
  2017. }
  2018. return editable;
  2019. };
  2020. var DONE = {};
  2021. function iterateList(list, reverse) {
  2022. var left = list._origin;
  2023. var right = list._capacity;
  2024. var tailPos = getTailOffset(right);
  2025. var tail = list._tail;
  2026. return iterateNodeOrLeaf(list._root, list._level, 0);
  2027. function iterateNodeOrLeaf(node, level, offset) {
  2028. return level === 0 ?
  2029. iterateLeaf(node, offset) :
  2030. iterateNode(node, level, offset);
  2031. }
  2032. function iterateLeaf(node, offset) {
  2033. var array = offset === tailPos ? tail && tail.array : node && node.array;
  2034. var from = offset > left ? 0 : left - offset;
  2035. var to = right - offset;
  2036. if (to > SIZE) {
  2037. to = SIZE;
  2038. }
  2039. return function() {
  2040. if (from === to) {
  2041. return DONE;
  2042. }
  2043. var idx = reverse ? --to : from++;
  2044. return array && array[idx];
  2045. };
  2046. }
  2047. function iterateNode(node, level, offset) {
  2048. var values;
  2049. var array = node && node.array;
  2050. var from = offset > left ? 0 : (left - offset) >> level;
  2051. var to = ((right - offset) >> level) + 1;
  2052. if (to > SIZE) {
  2053. to = SIZE;
  2054. }
  2055. return function() {
  2056. do {
  2057. if (values) {
  2058. var value = values();
  2059. if (value !== DONE) {
  2060. return value;
  2061. }
  2062. values = null;
  2063. }
  2064. if (from === to) {
  2065. return DONE;
  2066. }
  2067. var idx = reverse ? --to : from++;
  2068. values = iterateNodeOrLeaf(
  2069. array && array[idx], level - SHIFT, offset + (idx << level)
  2070. );
  2071. } while (true);
  2072. };
  2073. }
  2074. }
  2075. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  2076. var list = Object.create(ListPrototype);
  2077. list.size = capacity - origin;
  2078. list._origin = origin;
  2079. list._capacity = capacity;
  2080. list._level = level;
  2081. list._root = root;
  2082. list._tail = tail;
  2083. list.__ownerID = ownerID;
  2084. list.__hash = hash;
  2085. list.__altered = false;
  2086. return list;
  2087. }
  2088. var EMPTY_LIST;
  2089. function emptyList() {
  2090. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  2091. }
  2092. function updateList(list, index, value) {
  2093. index = wrapIndex(list, index);
  2094. if (index !== index) {
  2095. return list;
  2096. }
  2097. if (index >= list.size || index < 0) {
  2098. return list.withMutations(function(list ) {
  2099. index < 0 ?
  2100. setListBounds(list, index).set(0, value) :
  2101. setListBounds(list, 0, index + 1).set(index, value);
  2102. });
  2103. }
  2104. index += list._origin;
  2105. var newTail = list._tail;
  2106. var newRoot = list._root;
  2107. var didAlter = MakeRef(DID_ALTER);
  2108. if (index >= getTailOffset(list._capacity)) {
  2109. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  2110. } else {
  2111. newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
  2112. }
  2113. if (!didAlter.value) {
  2114. return list;
  2115. }
  2116. if (list.__ownerID) {
  2117. list._root = newRoot;
  2118. list._tail = newTail;
  2119. list.__hash = undefined;
  2120. list.__altered = true;
  2121. return list;
  2122. }
  2123. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  2124. }
  2125. function updateVNode(node, ownerID, level, index, value, didAlter) {
  2126. var idx = (index >>> level) & MASK;
  2127. var nodeHas = node && idx < node.array.length;
  2128. if (!nodeHas && value === undefined) {
  2129. return node;
  2130. }
  2131. var newNode;
  2132. if (level > 0) {
  2133. var lowerNode = node && node.array[idx];
  2134. var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
  2135. if (newLowerNode === lowerNode) {
  2136. return node;
  2137. }
  2138. newNode = editableVNode(node, ownerID);
  2139. newNode.array[idx] = newLowerNode;
  2140. return newNode;
  2141. }
  2142. if (nodeHas && node.array[idx] === value) {
  2143. return node;
  2144. }
  2145. SetRef(didAlter);
  2146. newNode = editableVNode(node, ownerID);
  2147. if (value === undefined && idx === newNode.array.length - 1) {
  2148. newNode.array.pop();
  2149. } else {
  2150. newNode.array[idx] = value;
  2151. }
  2152. return newNode;
  2153. }
  2154. function editableVNode(node, ownerID) {
  2155. if (ownerID && node && ownerID === node.ownerID) {
  2156. return node;
  2157. }
  2158. return new VNode(node ? node.array.slice() : [], ownerID);
  2159. }
  2160. function listNodeFor(list, rawIndex) {
  2161. if (rawIndex >= getTailOffset(list._capacity)) {
  2162. return list._tail;
  2163. }
  2164. if (rawIndex < 1 << (list._level + SHIFT)) {
  2165. var node = list._root;
  2166. var level = list._level;
  2167. while (node && level > 0) {
  2168. node = node.array[(rawIndex >>> level) & MASK];
  2169. level -= SHIFT;
  2170. }
  2171. return node;
  2172. }
  2173. }
  2174. function setListBounds(list, begin, end) {
  2175. // Sanitize begin & end using this shorthand for ToInt32(argument)
  2176. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  2177. if (begin !== undefined) {
  2178. begin = begin | 0;
  2179. }
  2180. if (end !== undefined) {
  2181. end = end | 0;
  2182. }
  2183. var owner = list.__ownerID || new OwnerID();
  2184. var oldOrigin = list._origin;
  2185. var oldCapacity = list._capacity;
  2186. var newOrigin = oldOrigin + begin;
  2187. var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
  2188. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  2189. return list;
  2190. }
  2191. // If it's going to end after it starts, it's empty.
  2192. if (newOrigin >= newCapacity) {
  2193. return list.clear();
  2194. }
  2195. var newLevel = list._level;
  2196. var newRoot = list._root;
  2197. // New origin might need creating a higher root.
  2198. var offsetShift = 0;
  2199. while (newOrigin + offsetShift < 0) {
  2200. newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
  2201. newLevel += SHIFT;
  2202. offsetShift += 1 << newLevel;
  2203. }
  2204. if (offsetShift) {
  2205. newOrigin += offsetShift;
  2206. oldOrigin += offsetShift;
  2207. newCapacity += offsetShift;
  2208. oldCapacity += offsetShift;
  2209. }
  2210. var oldTailOffset = getTailOffset(oldCapacity);
  2211. var newTailOffset = getTailOffset(newCapacity);
  2212. // New size might need creating a higher root.
  2213. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  2214. newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
  2215. newLevel += SHIFT;
  2216. }
  2217. // Locate or create the new tail.
  2218. var oldTail = list._tail;
  2219. var newTail = newTailOffset < oldTailOffset ?
  2220. listNodeFor(list, newCapacity - 1) :
  2221. newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
  2222. // Merge Tail into tree.
  2223. if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
  2224. newRoot = editableVNode(newRoot, owner);
  2225. var node = newRoot;
  2226. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  2227. var idx = (oldTailOffset >>> level) & MASK;
  2228. node = node.array[idx] = editableVNode(node.array[idx], owner);
  2229. }
  2230. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  2231. }
  2232. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  2233. if (newCapacity < oldCapacity) {
  2234. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  2235. }
  2236. // If the new origin is within the tail, then we do not need a root.
  2237. if (newOrigin >= newTailOffset) {
  2238. newOrigin -= newTailOffset;
  2239. newCapacity -= newTailOffset;
  2240. newLevel = SHIFT;
  2241. newRoot = null;
  2242. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  2243. // Otherwise, if the root has been trimmed, garbage collect.
  2244. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  2245. offsetShift = 0;
  2246. // Identify the new top root node of the subtree of the old root.
  2247. while (newRoot) {
  2248. var beginIndex = (newOrigin >>> newLevel) & MASK;
  2249. if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
  2250. break;
  2251. }
  2252. if (beginIndex) {
  2253. offsetShift += (1 << newLevel) * beginIndex;
  2254. }
  2255. newLevel -= SHIFT;
  2256. newRoot = newRoot.array[beginIndex];
  2257. }
  2258. // Trim the new sides of the new root.
  2259. if (newRoot && newOrigin > oldOrigin) {
  2260. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  2261. }
  2262. if (newRoot && newTailOffset < oldTailOffset) {
  2263. newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
  2264. }
  2265. if (offsetShift) {
  2266. newOrigin -= offsetShift;
  2267. newCapacity -= offsetShift;
  2268. }
  2269. }
  2270. if (list.__ownerID) {
  2271. list.size = newCapacity - newOrigin;
  2272. list._origin = newOrigin;
  2273. list._capacity = newCapacity;
  2274. list._level = newLevel;
  2275. list._root = newRoot;
  2276. list._tail = newTail;
  2277. list.__hash = undefined;
  2278. list.__altered = true;
  2279. return list;
  2280. }
  2281. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  2282. }
  2283. function mergeIntoListWith(list, merger, iterables) {
  2284. var iters = [];
  2285. var maxSize = 0;
  2286. for (var ii = 0; ii < iterables.length; ii++) {
  2287. var value = iterables[ii];
  2288. var iter = IndexedIterable(value);
  2289. if (iter.size > maxSize) {
  2290. maxSize = iter.size;
  2291. }
  2292. if (!isIterable(value)) {
  2293. iter = iter.map(function(v ) {return fromJS(v)});
  2294. }
  2295. iters.push(iter);
  2296. }
  2297. if (maxSize > list.size) {
  2298. list = list.setSize(maxSize);
  2299. }
  2300. return mergeIntoCollectionWith(list, merger, iters);
  2301. }
  2302. function getTailOffset(size) {
  2303. return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
  2304. }
  2305. createClass(OrderedMap, Map);
  2306. // @pragma Construction
  2307. function OrderedMap(value) {
  2308. return value === null || value === undefined ? emptyOrderedMap() :
  2309. isOrderedMap(value) ? value :
  2310. emptyOrderedMap().withMutations(function(map ) {
  2311. var iter = KeyedIterable(value);
  2312. assertNotInfinite(iter.size);
  2313. iter.forEach(function(v, k) {return map.set(k, v)});
  2314. });
  2315. }
  2316. OrderedMap.of = function(/*...values*/) {
  2317. return this(arguments);
  2318. };
  2319. OrderedMap.prototype.toString = function() {
  2320. return this.__toString('OrderedMap {', '}');
  2321. };
  2322. // @pragma Access
  2323. OrderedMap.prototype.get = function(k, notSetValue) {
  2324. var index = this._map.get(k);
  2325. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  2326. };
  2327. // @pragma Modification
  2328. OrderedMap.prototype.clear = function() {
  2329. if (this.size === 0) {
  2330. return this;
  2331. }
  2332. if (this.__ownerID) {
  2333. this.size = 0;
  2334. this._map.clear();
  2335. this._list.clear();
  2336. return this;
  2337. }
  2338. return emptyOrderedMap();
  2339. };
  2340. OrderedMap.prototype.set = function(k, v) {
  2341. return updateOrderedMap(this, k, v);
  2342. };
  2343. OrderedMap.prototype.remove = function(k) {
  2344. return updateOrderedMap(this, k, NOT_SET);
  2345. };
  2346. OrderedMap.prototype.wasAltered = function() {
  2347. return this._map.wasAltered() || this._list.wasAltered();
  2348. };
  2349. OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  2350. return this._list.__iterate(
  2351. function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
  2352. reverse
  2353. );
  2354. };
  2355. OrderedMap.prototype.__iterator = function(type, reverse) {
  2356. return this._list.fromEntrySeq().__iterator(type, reverse);
  2357. };
  2358. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  2359. if (ownerID === this.__ownerID) {
  2360. return this;
  2361. }
  2362. var newMap = this._map.__ensureOwner(ownerID);
  2363. var newList = this._list.__ensureOwner(ownerID);
  2364. if (!ownerID) {
  2365. this.__ownerID = ownerID;
  2366. this._map = newMap;
  2367. this._list = newList;
  2368. return this;
  2369. }
  2370. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  2371. };
  2372. function isOrderedMap(maybeOrderedMap) {
  2373. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  2374. }
  2375. OrderedMap.isOrderedMap = isOrderedMap;
  2376. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  2377. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  2378. function makeOrderedMap(map, list, ownerID, hash) {
  2379. var omap = Object.create(OrderedMap.prototype);
  2380. omap.size = map ? map.size : 0;
  2381. omap._map = map;
  2382. omap._list = list;
  2383. omap.__ownerID = ownerID;
  2384. omap.__hash = hash;
  2385. return omap;
  2386. }
  2387. var EMPTY_ORDERED_MAP;
  2388. function emptyOrderedMap() {
  2389. return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
  2390. }
  2391. function updateOrderedMap(omap, k, v) {
  2392. var map = omap._map;
  2393. var list = omap._list;
  2394. var i = map.get(k);
  2395. var has = i !== undefined;
  2396. var newMap;
  2397. var newList;
  2398. if (v === NOT_SET) { // removed
  2399. if (!has) {
  2400. return omap;
  2401. }
  2402. if (list.size >= SIZE && list.size >= map.size * 2) {
  2403. newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
  2404. newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
  2405. if (omap.__ownerID) {
  2406. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  2407. }
  2408. } else {
  2409. newMap = map.remove(k);
  2410. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  2411. }
  2412. } else {
  2413. if (has) {
  2414. if (v === list.get(i)[1]) {
  2415. return omap;
  2416. }
  2417. newMap = map;
  2418. newList = list.set(i, [k, v]);
  2419. } else {
  2420. newMap = map.set(k, list.size);
  2421. newList = list.set(list.size, [k, v]);
  2422. }
  2423. }
  2424. if (omap.__ownerID) {
  2425. omap.size = newMap.size;
  2426. omap._map = newMap;
  2427. omap._list = newList;
  2428. omap.__hash = undefined;
  2429. return omap;
  2430. }
  2431. return makeOrderedMap(newMap, newList);
  2432. }
  2433. createClass(ToKeyedSequence, KeyedSeq);
  2434. function ToKeyedSequence(indexed, useKeys) {
  2435. this._iter = indexed;
  2436. this._useKeys = useKeys;
  2437. this.size = indexed.size;
  2438. }
  2439. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  2440. return this._iter.get(key, notSetValue);
  2441. };
  2442. ToKeyedSequence.prototype.has = function(key) {
  2443. return this._iter.has(key);
  2444. };
  2445. ToKeyedSequence.prototype.valueSeq = function() {
  2446. return this._iter.valueSeq();
  2447. };
  2448. ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
  2449. var reversedSequence = reverseFactory(this, true);
  2450. if (!this._useKeys) {
  2451. reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
  2452. }
  2453. return reversedSequence;
  2454. };
  2455. ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
  2456. var mappedSequence = mapFactory(this, mapper, context);
  2457. if (!this._useKeys) {
  2458. mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
  2459. }
  2460. return mappedSequence;
  2461. };
  2462. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  2463. var ii;
  2464. return this._iter.__iterate(
  2465. this._useKeys ?
  2466. function(v, k) {return fn(v, k, this$0)} :
  2467. ((ii = reverse ? resolveSize(this) : 0),
  2468. function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
  2469. reverse
  2470. );
  2471. };
  2472. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  2473. if (this._useKeys) {
  2474. return this._iter.__iterator(type, reverse);
  2475. }
  2476. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2477. var ii = reverse ? resolveSize(this) : 0;
  2478. return new Iterator(function() {
  2479. var step = iterator.next();
  2480. return step.done ? step :
  2481. iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  2482. });
  2483. };
  2484. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  2485. createClass(ToIndexedSequence, IndexedSeq);
  2486. function ToIndexedSequence(iter) {
  2487. this._iter = iter;
  2488. this.size = iter.size;
  2489. }
  2490. ToIndexedSequence.prototype.includes = function(value) {
  2491. return this._iter.includes(value);
  2492. };
  2493. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  2494. var iterations = 0;
  2495. return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
  2496. };
  2497. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  2498. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2499. var iterations = 0;
  2500. return new Iterator(function() {
  2501. var step = iterator.next();
  2502. return step.done ? step :
  2503. iteratorValue(type, iterations++, step.value, step)
  2504. });
  2505. };
  2506. createClass(ToSetSequence, SetSeq);
  2507. function ToSetSequence(iter) {
  2508. this._iter = iter;
  2509. this.size = iter.size;
  2510. }
  2511. ToSetSequence.prototype.has = function(key) {
  2512. return this._iter.includes(key);
  2513. };
  2514. ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  2515. return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
  2516. };
  2517. ToSetSequence.prototype.__iterator = function(type, reverse) {
  2518. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2519. return new Iterator(function() {
  2520. var step = iterator.next();
  2521. return step.done ? step :
  2522. iteratorValue(type, step.value, step.value, step);
  2523. });
  2524. };
  2525. createClass(FromEntriesSequence, KeyedSeq);
  2526. function FromEntriesSequence(entries) {
  2527. this._iter = entries;
  2528. this.size = entries.size;
  2529. }
  2530. FromEntriesSequence.prototype.entrySeq = function() {
  2531. return this._iter.toSeq();
  2532. };
  2533. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  2534. return this._iter.__iterate(function(entry ) {
  2535. // Check if entry exists first so array access doesn't throw for holes
  2536. // in the parent iteration.
  2537. if (entry) {
  2538. validateEntry(entry);
  2539. var indexedIterable = isIterable(entry);
  2540. return fn(
  2541. indexedIterable ? entry.get(1) : entry[1],
  2542. indexedIterable ? entry.get(0) : entry[0],
  2543. this$0
  2544. );
  2545. }
  2546. }, reverse);
  2547. };
  2548. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  2549. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  2550. return new Iterator(function() {
  2551. while (true) {
  2552. var step = iterator.next();
  2553. if (step.done) {
  2554. return step;
  2555. }
  2556. var entry = step.value;
  2557. // Check if entry exists first so array access doesn't throw for holes
  2558. // in the parent iteration.
  2559. if (entry) {
  2560. validateEntry(entry);
  2561. var indexedIterable = isIterable(entry);
  2562. return iteratorValue(
  2563. type,
  2564. indexedIterable ? entry.get(0) : entry[0],
  2565. indexedIterable ? entry.get(1) : entry[1],
  2566. step
  2567. );
  2568. }
  2569. }
  2570. });
  2571. };
  2572. ToIndexedSequence.prototype.cacheResult =
  2573. ToKeyedSequence.prototype.cacheResult =
  2574. ToSetSequence.prototype.cacheResult =
  2575. FromEntriesSequence.prototype.cacheResult =
  2576. cacheResultThrough;
  2577. function flipFactory(iterable) {
  2578. var flipSequence = makeSequence(iterable);
  2579. flipSequence._iter = iterable;
  2580. flipSequence.size = iterable.size;
  2581. flipSequence.flip = function() {return iterable};
  2582. flipSequence.reverse = function () {
  2583. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  2584. reversedSequence.flip = function() {return iterable.reverse()};
  2585. return reversedSequence;
  2586. };
  2587. flipSequence.has = function(key ) {return iterable.includes(key)};
  2588. flipSequence.includes = function(key ) {return iterable.has(key)};
  2589. flipSequence.cacheResult = cacheResultThrough;
  2590. flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  2591. return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
  2592. };
  2593. flipSequence.__iteratorUncached = function(type, reverse) {
  2594. if (type === ITERATE_ENTRIES) {
  2595. var iterator = iterable.__iterator(type, reverse);
  2596. return new Iterator(function() {
  2597. var step = iterator.next();
  2598. if (!step.done) {
  2599. var k = step.value[0];
  2600. step.value[0] = step.value[1];
  2601. step.value[1] = k;
  2602. }
  2603. return step;
  2604. });
  2605. }
  2606. return iterable.__iterator(
  2607. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  2608. reverse
  2609. );
  2610. };
  2611. return flipSequence;
  2612. }
  2613. function mapFactory(iterable, mapper, context) {
  2614. var mappedSequence = makeSequence(iterable);
  2615. mappedSequence.size = iterable.size;
  2616. mappedSequence.has = function(key ) {return iterable.has(key)};
  2617. mappedSequence.get = function(key, notSetValue) {
  2618. var v = iterable.get(key, NOT_SET);
  2619. return v === NOT_SET ?
  2620. notSetValue :
  2621. mapper.call(context, v, key, iterable);
  2622. };
  2623. mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  2624. return iterable.__iterate(
  2625. function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
  2626. reverse
  2627. );
  2628. };
  2629. mappedSequence.__iteratorUncached = function (type, reverse) {
  2630. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  2631. return new Iterator(function() {
  2632. var step = iterator.next();
  2633. if (step.done) {
  2634. return step;
  2635. }
  2636. var entry = step.value;
  2637. var key = entry[0];
  2638. return iteratorValue(
  2639. type,
  2640. key,
  2641. mapper.call(context, entry[1], key, iterable),
  2642. step
  2643. );
  2644. });
  2645. };
  2646. return mappedSequence;
  2647. }
  2648. function reverseFactory(iterable, useKeys) {
  2649. var reversedSequence = makeSequence(iterable);
  2650. reversedSequence._iter = iterable;
  2651. reversedSequence.size = iterable.size;
  2652. reversedSequence.reverse = function() {return iterable};
  2653. if (iterable.flip) {
  2654. reversedSequence.flip = function () {
  2655. var flipSequence = flipFactory(iterable);
  2656. flipSequence.reverse = function() {return iterable.flip()};
  2657. return flipSequence;
  2658. };
  2659. }
  2660. reversedSequence.get = function(key, notSetValue)
  2661. {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
  2662. reversedSequence.has = function(key )
  2663. {return iterable.has(useKeys ? key : -1 - key)};
  2664. reversedSequence.includes = function(value ) {return iterable.includes(value)};
  2665. reversedSequence.cacheResult = cacheResultThrough;
  2666. reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
  2667. return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
  2668. };
  2669. reversedSequence.__iterator =
  2670. function(type, reverse) {return iterable.__iterator(type, !reverse)};
  2671. return reversedSequence;
  2672. }
  2673. function filterFactory(iterable, predicate, context, useKeys) {
  2674. var filterSequence = makeSequence(iterable);
  2675. if (useKeys) {
  2676. filterSequence.has = function(key ) {
  2677. var v = iterable.get(key, NOT_SET);
  2678. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  2679. };
  2680. filterSequence.get = function(key, notSetValue) {
  2681. var v = iterable.get(key, NOT_SET);
  2682. return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
  2683. v : notSetValue;
  2684. };
  2685. }
  2686. filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  2687. var iterations = 0;
  2688. iterable.__iterate(function(v, k, c) {
  2689. if (predicate.call(context, v, k, c)) {
  2690. iterations++;
  2691. return fn(v, useKeys ? k : iterations - 1, this$0);
  2692. }
  2693. }, reverse);
  2694. return iterations;
  2695. };
  2696. filterSequence.__iteratorUncached = function (type, reverse) {
  2697. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  2698. var iterations = 0;
  2699. return new Iterator(function() {
  2700. while (true) {
  2701. var step = iterator.next();
  2702. if (step.done) {
  2703. return step;
  2704. }
  2705. var entry = step.value;
  2706. var key = entry[0];
  2707. var value = entry[1];
  2708. if (predicate.call(context, value, key, iterable)) {
  2709. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  2710. }
  2711. }
  2712. });
  2713. };
  2714. return filterSequence;
  2715. }
  2716. function countByFactory(iterable, grouper, context) {
  2717. var groups = Map().asMutable();
  2718. iterable.__iterate(function(v, k) {
  2719. groups.update(
  2720. grouper.call(context, v, k, iterable),
  2721. 0,
  2722. function(a ) {return a + 1}
  2723. );
  2724. });
  2725. return groups.asImmutable();
  2726. }
  2727. function groupByFactory(iterable, grouper, context) {
  2728. var isKeyedIter = isKeyed(iterable);
  2729. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  2730. iterable.__iterate(function(v, k) {
  2731. groups.update(
  2732. grouper.call(context, v, k, iterable),
  2733. function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
  2734. );
  2735. });
  2736. var coerce = iterableClass(iterable);
  2737. return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
  2738. }
  2739. function sliceFactory(iterable, begin, end, useKeys) {
  2740. var originalSize = iterable.size;
  2741. // Sanitize begin & end using this shorthand for ToInt32(argument)
  2742. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  2743. if (begin !== undefined) {
  2744. begin = begin | 0;
  2745. }
  2746. if (end !== undefined) {
  2747. end = end | 0;
  2748. }
  2749. if (wholeSlice(begin, end, originalSize)) {
  2750. return iterable;
  2751. }
  2752. var resolvedBegin = resolveBegin(begin, originalSize);
  2753. var resolvedEnd = resolveEnd(end, originalSize);
  2754. // begin or end will be NaN if they were provided as negative numbers and
  2755. // this iterable's size is unknown. In that case, cache first so there is
  2756. // a known size and these do not resolve to NaN.
  2757. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  2758. return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
  2759. }
  2760. // Note: resolvedEnd is undefined when the original sequence's length is
  2761. // unknown and this slice did not supply an end and should contain all
  2762. // elements after resolvedBegin.
  2763. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  2764. var resolvedSize = resolvedEnd - resolvedBegin;
  2765. var sliceSize;
  2766. if (resolvedSize === resolvedSize) {
  2767. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  2768. }
  2769. var sliceSeq = makeSequence(iterable);
  2770. // If iterable.size is undefined, the size of the realized sliceSeq is
  2771. // unknown at this point unless the number of items to slice is 0
  2772. sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
  2773. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  2774. sliceSeq.get = function (index, notSetValue) {
  2775. index = wrapIndex(this, index);
  2776. return index >= 0 && index < sliceSize ?
  2777. iterable.get(index + resolvedBegin, notSetValue) :
  2778. notSetValue;
  2779. };
  2780. }
  2781. sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
  2782. if (sliceSize === 0) {
  2783. return 0;
  2784. }
  2785. if (reverse) {
  2786. return this.cacheResult().__iterate(fn, reverse);
  2787. }
  2788. var skipped = 0;
  2789. var isSkipping = true;
  2790. var iterations = 0;
  2791. iterable.__iterate(function(v, k) {
  2792. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  2793. iterations++;
  2794. return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  2795. iterations !== sliceSize;
  2796. }
  2797. });
  2798. return iterations;
  2799. };
  2800. sliceSeq.__iteratorUncached = function(type, reverse) {
  2801. if (sliceSize !== 0 && reverse) {
  2802. return this.cacheResult().__iterator(type, reverse);
  2803. }
  2804. // Don't bother instantiating parent iterator if taking 0.
  2805. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  2806. var skipped = 0;
  2807. var iterations = 0;
  2808. return new Iterator(function() {
  2809. while (skipped++ < resolvedBegin) {
  2810. iterator.next();
  2811. }
  2812. if (++iterations > sliceSize) {
  2813. return iteratorDone();
  2814. }
  2815. var step = iterator.next();
  2816. if (useKeys || type === ITERATE_VALUES) {
  2817. return step;
  2818. } else if (type === ITERATE_KEYS) {
  2819. return iteratorValue(type, iterations - 1, undefined, step);
  2820. } else {
  2821. return iteratorValue(type, iterations - 1, step.value[1], step);
  2822. }
  2823. });
  2824. };
  2825. return sliceSeq;
  2826. }
  2827. function takeWhileFactory(iterable, predicate, context) {
  2828. var takeSequence = makeSequence(iterable);
  2829. takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  2830. if (reverse) {
  2831. return this.cacheResult().__iterate(fn, reverse);
  2832. }
  2833. var iterations = 0;
  2834. iterable.__iterate(function(v, k, c)
  2835. {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
  2836. );
  2837. return iterations;
  2838. };
  2839. takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  2840. if (reverse) {
  2841. return this.cacheResult().__iterator(type, reverse);
  2842. }
  2843. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  2844. var iterating = true;
  2845. return new Iterator(function() {
  2846. if (!iterating) {
  2847. return iteratorDone();
  2848. }
  2849. var step = iterator.next();
  2850. if (step.done) {
  2851. return step;
  2852. }
  2853. var entry = step.value;
  2854. var k = entry[0];
  2855. var v = entry[1];
  2856. if (!predicate.call(context, v, k, this$0)) {
  2857. iterating = false;
  2858. return iteratorDone();
  2859. }
  2860. return type === ITERATE_ENTRIES ? step :
  2861. iteratorValue(type, k, v, step);
  2862. });
  2863. };
  2864. return takeSequence;
  2865. }
  2866. function skipWhileFactory(iterable, predicate, context, useKeys) {
  2867. var skipSequence = makeSequence(iterable);
  2868. skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  2869. if (reverse) {
  2870. return this.cacheResult().__iterate(fn, reverse);
  2871. }
  2872. var isSkipping = true;
  2873. var iterations = 0;
  2874. iterable.__iterate(function(v, k, c) {
  2875. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  2876. iterations++;
  2877. return fn(v, useKeys ? k : iterations - 1, this$0);
  2878. }
  2879. });
  2880. return iterations;
  2881. };
  2882. skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  2883. if (reverse) {
  2884. return this.cacheResult().__iterator(type, reverse);
  2885. }
  2886. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  2887. var skipping = true;
  2888. var iterations = 0;
  2889. return new Iterator(function() {
  2890. var step, k, v;
  2891. do {
  2892. step = iterator.next();
  2893. if (step.done) {
  2894. if (useKeys || type === ITERATE_VALUES) {
  2895. return step;
  2896. } else if (type === ITERATE_KEYS) {
  2897. return iteratorValue(type, iterations++, undefined, step);
  2898. } else {
  2899. return iteratorValue(type, iterations++, step.value[1], step);
  2900. }
  2901. }
  2902. var entry = step.value;
  2903. k = entry[0];
  2904. v = entry[1];
  2905. skipping && (skipping = predicate.call(context, v, k, this$0));
  2906. } while (skipping);
  2907. return type === ITERATE_ENTRIES ? step :
  2908. iteratorValue(type, k, v, step);
  2909. });
  2910. };
  2911. return skipSequence;
  2912. }
  2913. function concatFactory(iterable, values) {
  2914. var isKeyedIterable = isKeyed(iterable);
  2915. var iters = [iterable].concat(values).map(function(v ) {
  2916. if (!isIterable(v)) {
  2917. v = isKeyedIterable ?
  2918. keyedSeqFromValue(v) :
  2919. indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  2920. } else if (isKeyedIterable) {
  2921. v = KeyedIterable(v);
  2922. }
  2923. return v;
  2924. }).filter(function(v ) {return v.size !== 0});
  2925. if (iters.length === 0) {
  2926. return iterable;
  2927. }
  2928. if (iters.length === 1) {
  2929. var singleton = iters[0];
  2930. if (singleton === iterable ||
  2931. isKeyedIterable && isKeyed(singleton) ||
  2932. isIndexed(iterable) && isIndexed(singleton)) {
  2933. return singleton;
  2934. }
  2935. }
  2936. var concatSeq = new ArraySeq(iters);
  2937. if (isKeyedIterable) {
  2938. concatSeq = concatSeq.toKeyedSeq();
  2939. } else if (!isIndexed(iterable)) {
  2940. concatSeq = concatSeq.toSetSeq();
  2941. }
  2942. concatSeq = concatSeq.flatten(true);
  2943. concatSeq.size = iters.reduce(
  2944. function(sum, seq) {
  2945. if (sum !== undefined) {
  2946. var size = seq.size;
  2947. if (size !== undefined) {
  2948. return sum + size;
  2949. }
  2950. }
  2951. },
  2952. 0
  2953. );
  2954. return concatSeq;
  2955. }
  2956. function flattenFactory(iterable, depth, useKeys) {
  2957. var flatSequence = makeSequence(iterable);
  2958. flatSequence.__iterateUncached = function(fn, reverse) {
  2959. var iterations = 0;
  2960. var stopped = false;
  2961. function flatDeep(iter, currentDepth) {var this$0 = this;
  2962. iter.__iterate(function(v, k) {
  2963. if ((!depth || currentDepth < depth) && isIterable(v)) {
  2964. flatDeep(v, currentDepth + 1);
  2965. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  2966. stopped = true;
  2967. }
  2968. return !stopped;
  2969. }, reverse);
  2970. }
  2971. flatDeep(iterable, 0);
  2972. return iterations;
  2973. };
  2974. flatSequence.__iteratorUncached = function(type, reverse) {
  2975. var iterator = iterable.__iterator(type, reverse);
  2976. var stack = [];
  2977. var iterations = 0;
  2978. return new Iterator(function() {
  2979. while (iterator) {
  2980. var step = iterator.next();
  2981. if (step.done !== false) {
  2982. iterator = stack.pop();
  2983. continue;
  2984. }
  2985. var v = step.value;
  2986. if (type === ITERATE_ENTRIES) {
  2987. v = v[1];
  2988. }
  2989. if ((!depth || stack.length < depth) && isIterable(v)) {
  2990. stack.push(iterator);
  2991. iterator = v.__iterator(type, reverse);
  2992. } else {
  2993. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  2994. }
  2995. }
  2996. return iteratorDone();
  2997. });
  2998. };
  2999. return flatSequence;
  3000. }
  3001. function flatMapFactory(iterable, mapper, context) {
  3002. var coerce = iterableClass(iterable);
  3003. return iterable.toSeq().map(
  3004. function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
  3005. ).flatten(true);
  3006. }
  3007. function interposeFactory(iterable, separator) {
  3008. var interposedSequence = makeSequence(iterable);
  3009. interposedSequence.size = iterable.size && iterable.size * 2 -1;
  3010. interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  3011. var iterations = 0;
  3012. iterable.__iterate(function(v, k)
  3013. {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
  3014. fn(v, iterations++, this$0) !== false},
  3015. reverse
  3016. );
  3017. return iterations;
  3018. };
  3019. interposedSequence.__iteratorUncached = function(type, reverse) {
  3020. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  3021. var iterations = 0;
  3022. var step;
  3023. return new Iterator(function() {
  3024. if (!step || iterations % 2) {
  3025. step = iterator.next();
  3026. if (step.done) {
  3027. return step;
  3028. }
  3029. }
  3030. return iterations % 2 ?
  3031. iteratorValue(type, iterations++, separator) :
  3032. iteratorValue(type, iterations++, step.value, step);
  3033. });
  3034. };
  3035. return interposedSequence;
  3036. }
  3037. function sortFactory(iterable, comparator, mapper) {
  3038. if (!comparator) {
  3039. comparator = defaultComparator;
  3040. }
  3041. var isKeyedIterable = isKeyed(iterable);
  3042. var index = 0;
  3043. var entries = iterable.toSeq().map(
  3044. function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
  3045. ).toArray();
  3046. entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
  3047. isKeyedIterable ?
  3048. function(v, i) { entries[i].length = 2; } :
  3049. function(v, i) { entries[i] = v[1]; }
  3050. );
  3051. return isKeyedIterable ? KeyedSeq(entries) :
  3052. isIndexed(iterable) ? IndexedSeq(entries) :
  3053. SetSeq(entries);
  3054. }
  3055. function maxFactory(iterable, comparator, mapper) {
  3056. if (!comparator) {
  3057. comparator = defaultComparator;
  3058. }
  3059. if (mapper) {
  3060. var entry = iterable.toSeq()
  3061. .map(function(v, k) {return [v, mapper(v, k, iterable)]})
  3062. .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
  3063. return entry && entry[0];
  3064. } else {
  3065. return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
  3066. }
  3067. }
  3068. function maxCompare(comparator, a, b) {
  3069. var comp = comparator(b, a);
  3070. // b is considered the new max if the comparator declares them equal, but
  3071. // they are not equal and b is in fact a nullish value.
  3072. return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
  3073. }
  3074. function zipWithFactory(keyIter, zipper, iters) {
  3075. var zipSequence = makeSequence(keyIter);
  3076. zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
  3077. // Note: this a generic base implementation of __iterate in terms of
  3078. // __iterator which may be more generically useful in the future.
  3079. zipSequence.__iterate = function(fn, reverse) {
  3080. /* generic:
  3081. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  3082. var step;
  3083. var iterations = 0;
  3084. while (!(step = iterator.next()).done) {
  3085. iterations++;
  3086. if (fn(step.value[1], step.value[0], this) === false) {
  3087. break;
  3088. }
  3089. }
  3090. return iterations;
  3091. */
  3092. // indexed:
  3093. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  3094. var step;
  3095. var iterations = 0;
  3096. while (!(step = iterator.next()).done) {
  3097. if (fn(step.value, iterations++, this) === false) {
  3098. break;
  3099. }
  3100. }
  3101. return iterations;
  3102. };
  3103. zipSequence.__iteratorUncached = function(type, reverse) {
  3104. var iterators = iters.map(function(i )
  3105. {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
  3106. );
  3107. var iterations = 0;
  3108. var isDone = false;
  3109. return new Iterator(function() {
  3110. var steps;
  3111. if (!isDone) {
  3112. steps = iterators.map(function(i ) {return i.next()});
  3113. isDone = steps.some(function(s ) {return s.done});
  3114. }
  3115. if (isDone) {
  3116. return iteratorDone();
  3117. }
  3118. return iteratorValue(
  3119. type,
  3120. iterations++,
  3121. zipper.apply(null, steps.map(function(s ) {return s.value}))
  3122. );
  3123. });
  3124. };
  3125. return zipSequence
  3126. }
  3127. // #pragma Helper Functions
  3128. function reify(iter, seq) {
  3129. return isSeq(iter) ? seq : iter.constructor(seq);
  3130. }
  3131. function validateEntry(entry) {
  3132. if (entry !== Object(entry)) {
  3133. throw new TypeError('Expected [K, V] tuple: ' + entry);
  3134. }
  3135. }
  3136. function resolveSize(iter) {
  3137. assertNotInfinite(iter.size);
  3138. return ensureSize(iter);
  3139. }
  3140. function iterableClass(iterable) {
  3141. return isKeyed(iterable) ? KeyedIterable :
  3142. isIndexed(iterable) ? IndexedIterable :
  3143. SetIterable;
  3144. }
  3145. function makeSequence(iterable) {
  3146. return Object.create(
  3147. (
  3148. isKeyed(iterable) ? KeyedSeq :
  3149. isIndexed(iterable) ? IndexedSeq :
  3150. SetSeq
  3151. ).prototype
  3152. );
  3153. }
  3154. function cacheResultThrough() {
  3155. if (this._iter.cacheResult) {
  3156. this._iter.cacheResult();
  3157. this.size = this._iter.size;
  3158. return this;
  3159. } else {
  3160. return Seq.prototype.cacheResult.call(this);
  3161. }
  3162. }
  3163. function defaultComparator(a, b) {
  3164. return a > b ? 1 : a < b ? -1 : 0;
  3165. }
  3166. function forceIterator(keyPath) {
  3167. var iter = getIterator(keyPath);
  3168. if (!iter) {
  3169. // Array might not be iterable in this environment, so we need a fallback
  3170. // to our wrapped type.
  3171. if (!isArrayLike(keyPath)) {
  3172. throw new TypeError('Expected iterable or array-like: ' + keyPath);
  3173. }
  3174. iter = getIterator(Iterable(keyPath));
  3175. }
  3176. return iter;
  3177. }
  3178. createClass(Record, KeyedCollection);
  3179. function Record(defaultValues, name) {
  3180. var hasInitialized;
  3181. var RecordType = function Record(values) {
  3182. if (values instanceof RecordType) {
  3183. return values;
  3184. }
  3185. if (!(this instanceof RecordType)) {
  3186. return new RecordType(values);
  3187. }
  3188. if (!hasInitialized) {
  3189. hasInitialized = true;
  3190. var keys = Object.keys(defaultValues);
  3191. setProps(RecordTypePrototype, keys);
  3192. RecordTypePrototype.size = keys.length;
  3193. RecordTypePrototype._name = name;
  3194. RecordTypePrototype._keys = keys;
  3195. RecordTypePrototype._defaultValues = defaultValues;
  3196. }
  3197. this._map = Map(values);
  3198. };
  3199. var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
  3200. RecordTypePrototype.constructor = RecordType;
  3201. return RecordType;
  3202. }
  3203. Record.prototype.toString = function() {
  3204. return this.__toString(recordName(this) + ' {', '}');
  3205. };
  3206. // @pragma Access
  3207. Record.prototype.has = function(k) {
  3208. return this._defaultValues.hasOwnProperty(k);
  3209. };
  3210. Record.prototype.get = function(k, notSetValue) {
  3211. if (!this.has(k)) {
  3212. return notSetValue;
  3213. }
  3214. var defaultVal = this._defaultValues[k];
  3215. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  3216. };
  3217. // @pragma Modification
  3218. Record.prototype.clear = function() {
  3219. if (this.__ownerID) {
  3220. this._map && this._map.clear();
  3221. return this;
  3222. }
  3223. var RecordType = this.constructor;
  3224. return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
  3225. };
  3226. Record.prototype.set = function(k, v) {
  3227. if (!this.has(k)) {
  3228. throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
  3229. }
  3230. var newMap = this._map && this._map.set(k, v);
  3231. if (this.__ownerID || newMap === this._map) {
  3232. return this;
  3233. }
  3234. return makeRecord(this, newMap);
  3235. };
  3236. Record.prototype.remove = function(k) {
  3237. if (!this.has(k)) {
  3238. return this;
  3239. }
  3240. var newMap = this._map && this._map.remove(k);
  3241. if (this.__ownerID || newMap === this._map) {
  3242. return this;
  3243. }
  3244. return makeRecord(this, newMap);
  3245. };
  3246. Record.prototype.wasAltered = function() {
  3247. return this._map.wasAltered();
  3248. };
  3249. Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
  3250. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
  3251. };
  3252. Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  3253. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
  3254. };
  3255. Record.prototype.__ensureOwner = function(ownerID) {
  3256. if (ownerID === this.__ownerID) {
  3257. return this;
  3258. }
  3259. var newMap = this._map && this._map.__ensureOwner(ownerID);
  3260. if (!ownerID) {
  3261. this.__ownerID = ownerID;
  3262. this._map = newMap;
  3263. return this;
  3264. }
  3265. return makeRecord(this, newMap, ownerID);
  3266. };
  3267. var RecordPrototype = Record.prototype;
  3268. RecordPrototype[DELETE] = RecordPrototype.remove;
  3269. RecordPrototype.deleteIn =
  3270. RecordPrototype.removeIn = MapPrototype.removeIn;
  3271. RecordPrototype.merge = MapPrototype.merge;
  3272. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  3273. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  3274. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  3275. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  3276. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  3277. RecordPrototype.setIn = MapPrototype.setIn;
  3278. RecordPrototype.update = MapPrototype.update;
  3279. RecordPrototype.updateIn = MapPrototype.updateIn;
  3280. RecordPrototype.withMutations = MapPrototype.withMutations;
  3281. RecordPrototype.asMutable = MapPrototype.asMutable;
  3282. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  3283. function makeRecord(likeRecord, map, ownerID) {
  3284. var record = Object.create(Object.getPrototypeOf(likeRecord));
  3285. record._map = map;
  3286. record.__ownerID = ownerID;
  3287. return record;
  3288. }
  3289. function recordName(record) {
  3290. return record._name || record.constructor.name || 'Record';
  3291. }
  3292. function setProps(prototype, names) {
  3293. try {
  3294. names.forEach(setProp.bind(undefined, prototype));
  3295. } catch (error) {
  3296. // Object.defineProperty failed. Probably IE8.
  3297. }
  3298. }
  3299. function setProp(prototype, name) {
  3300. Object.defineProperty(prototype, name, {
  3301. get: function() {
  3302. return this.get(name);
  3303. },
  3304. set: function(value) {
  3305. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  3306. this.set(name, value);
  3307. }
  3308. });
  3309. }
  3310. createClass(Set, SetCollection);
  3311. // @pragma Construction
  3312. function Set(value) {
  3313. return value === null || value === undefined ? emptySet() :
  3314. isSet(value) && !isOrdered(value) ? value :
  3315. emptySet().withMutations(function(set ) {
  3316. var iter = SetIterable(value);
  3317. assertNotInfinite(iter.size);
  3318. iter.forEach(function(v ) {return set.add(v)});
  3319. });
  3320. }
  3321. Set.of = function(/*...values*/) {
  3322. return this(arguments);
  3323. };
  3324. Set.fromKeys = function(value) {
  3325. return this(KeyedIterable(value).keySeq());
  3326. };
  3327. Set.prototype.toString = function() {
  3328. return this.__toString('Set {', '}');
  3329. };
  3330. // @pragma Access
  3331. Set.prototype.has = function(value) {
  3332. return this._map.has(value);
  3333. };
  3334. // @pragma Modification
  3335. Set.prototype.add = function(value) {
  3336. return updateSet(this, this._map.set(value, true));
  3337. };
  3338. Set.prototype.remove = function(value) {
  3339. return updateSet(this, this._map.remove(value));
  3340. };
  3341. Set.prototype.clear = function() {
  3342. return updateSet(this, this._map.clear());
  3343. };
  3344. // @pragma Composition
  3345. Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
  3346. iters = iters.filter(function(x ) {return x.size !== 0});
  3347. if (iters.length === 0) {
  3348. return this;
  3349. }
  3350. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  3351. return this.constructor(iters[0]);
  3352. }
  3353. return this.withMutations(function(set ) {
  3354. for (var ii = 0; ii < iters.length; ii++) {
  3355. SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
  3356. }
  3357. });
  3358. };
  3359. Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
  3360. if (iters.length === 0) {
  3361. return this;
  3362. }
  3363. iters = iters.map(function(iter ) {return SetIterable(iter)});
  3364. var originalSet = this;
  3365. return this.withMutations(function(set ) {
  3366. originalSet.forEach(function(value ) {
  3367. if (!iters.every(function(iter ) {return iter.includes(value)})) {
  3368. set.remove(value);
  3369. }
  3370. });
  3371. });
  3372. };
  3373. Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
  3374. if (iters.length === 0) {
  3375. return this;
  3376. }
  3377. iters = iters.map(function(iter ) {return SetIterable(iter)});
  3378. var originalSet = this;
  3379. return this.withMutations(function(set ) {
  3380. originalSet.forEach(function(value ) {
  3381. if (iters.some(function(iter ) {return iter.includes(value)})) {
  3382. set.remove(value);
  3383. }
  3384. });
  3385. });
  3386. };
  3387. Set.prototype.merge = function() {
  3388. return this.union.apply(this, arguments);
  3389. };
  3390. Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  3391. return this.union.apply(this, iters);
  3392. };
  3393. Set.prototype.sort = function(comparator) {
  3394. // Late binding
  3395. return OrderedSet(sortFactory(this, comparator));
  3396. };
  3397. Set.prototype.sortBy = function(mapper, comparator) {
  3398. // Late binding
  3399. return OrderedSet(sortFactory(this, comparator, mapper));
  3400. };
  3401. Set.prototype.wasAltered = function() {
  3402. return this._map.wasAltered();
  3403. };
  3404. Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  3405. return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
  3406. };
  3407. Set.prototype.__iterator = function(type, reverse) {
  3408. return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
  3409. };
  3410. Set.prototype.__ensureOwner = function(ownerID) {
  3411. if (ownerID === this.__ownerID) {
  3412. return this;
  3413. }
  3414. var newMap = this._map.__ensureOwner(ownerID);
  3415. if (!ownerID) {
  3416. this.__ownerID = ownerID;
  3417. this._map = newMap;
  3418. return this;
  3419. }
  3420. return this.__make(newMap, ownerID);
  3421. };
  3422. function isSet(maybeSet) {
  3423. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  3424. }
  3425. Set.isSet = isSet;
  3426. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  3427. var SetPrototype = Set.prototype;
  3428. SetPrototype[IS_SET_SENTINEL] = true;
  3429. SetPrototype[DELETE] = SetPrototype.remove;
  3430. SetPrototype.mergeDeep = SetPrototype.merge;
  3431. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  3432. SetPrototype.withMutations = MapPrototype.withMutations;
  3433. SetPrototype.asMutable = MapPrototype.asMutable;
  3434. SetPrototype.asImmutable = MapPrototype.asImmutable;
  3435. SetPrototype.__empty = emptySet;
  3436. SetPrototype.__make = makeSet;
  3437. function updateSet(set, newMap) {
  3438. if (set.__ownerID) {
  3439. set.size = newMap.size;
  3440. set._map = newMap;
  3441. return set;
  3442. }
  3443. return newMap === set._map ? set :
  3444. newMap.size === 0 ? set.__empty() :
  3445. set.__make(newMap);
  3446. }
  3447. function makeSet(map, ownerID) {
  3448. var set = Object.create(SetPrototype);
  3449. set.size = map ? map.size : 0;
  3450. set._map = map;
  3451. set.__ownerID = ownerID;
  3452. return set;
  3453. }
  3454. var EMPTY_SET;
  3455. function emptySet() {
  3456. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  3457. }
  3458. createClass(OrderedSet, Set);
  3459. // @pragma Construction
  3460. function OrderedSet(value) {
  3461. return value === null || value === undefined ? emptyOrderedSet() :
  3462. isOrderedSet(value) ? value :
  3463. emptyOrderedSet().withMutations(function(set ) {
  3464. var iter = SetIterable(value);
  3465. assertNotInfinite(iter.size);
  3466. iter.forEach(function(v ) {return set.add(v)});
  3467. });
  3468. }
  3469. OrderedSet.of = function(/*...values*/) {
  3470. return this(arguments);
  3471. };
  3472. OrderedSet.fromKeys = function(value) {
  3473. return this(KeyedIterable(value).keySeq());
  3474. };
  3475. OrderedSet.prototype.toString = function() {
  3476. return this.__toString('OrderedSet {', '}');
  3477. };
  3478. function isOrderedSet(maybeOrderedSet) {
  3479. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  3480. }
  3481. OrderedSet.isOrderedSet = isOrderedSet;
  3482. var OrderedSetPrototype = OrderedSet.prototype;
  3483. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  3484. OrderedSetPrototype.__empty = emptyOrderedSet;
  3485. OrderedSetPrototype.__make = makeOrderedSet;
  3486. function makeOrderedSet(map, ownerID) {
  3487. var set = Object.create(OrderedSetPrototype);
  3488. set.size = map ? map.size : 0;
  3489. set._map = map;
  3490. set.__ownerID = ownerID;
  3491. return set;
  3492. }
  3493. var EMPTY_ORDERED_SET;
  3494. function emptyOrderedSet() {
  3495. return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
  3496. }
  3497. createClass(Stack, IndexedCollection);
  3498. // @pragma Construction
  3499. function Stack(value) {
  3500. return value === null || value === undefined ? emptyStack() :
  3501. isStack(value) ? value :
  3502. emptyStack().unshiftAll(value);
  3503. }
  3504. Stack.of = function(/*...values*/) {
  3505. return this(arguments);
  3506. };
  3507. Stack.prototype.toString = function() {
  3508. return this.__toString('Stack [', ']');
  3509. };
  3510. // @pragma Access
  3511. Stack.prototype.get = function(index, notSetValue) {
  3512. var head = this._head;
  3513. index = wrapIndex(this, index);
  3514. while (head && index--) {
  3515. head = head.next;
  3516. }
  3517. return head ? head.value : notSetValue;
  3518. };
  3519. Stack.prototype.peek = function() {
  3520. return this._head && this._head.value;
  3521. };
  3522. // @pragma Modification
  3523. Stack.prototype.push = function(/*...values*/) {
  3524. if (arguments.length === 0) {
  3525. return this;
  3526. }
  3527. var newSize = this.size + arguments.length;
  3528. var head = this._head;
  3529. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  3530. head = {
  3531. value: arguments[ii],
  3532. next: head
  3533. };
  3534. }
  3535. if (this.__ownerID) {
  3536. this.size = newSize;
  3537. this._head = head;
  3538. this.__hash = undefined;
  3539. this.__altered = true;
  3540. return this;
  3541. }
  3542. return makeStack(newSize, head);
  3543. };
  3544. Stack.prototype.pushAll = function(iter) {
  3545. iter = IndexedIterable(iter);
  3546. if (iter.size === 0) {
  3547. return this;
  3548. }
  3549. assertNotInfinite(iter.size);
  3550. var newSize = this.size;
  3551. var head = this._head;
  3552. iter.reverse().forEach(function(value ) {
  3553. newSize++;
  3554. head = {
  3555. value: value,
  3556. next: head
  3557. };
  3558. });
  3559. if (this.__ownerID) {
  3560. this.size = newSize;
  3561. this._head = head;
  3562. this.__hash = undefined;
  3563. this.__altered = true;
  3564. return this;
  3565. }
  3566. return makeStack(newSize, head);
  3567. };
  3568. Stack.prototype.pop = function() {
  3569. return this.slice(1);
  3570. };
  3571. Stack.prototype.unshift = function(/*...values*/) {
  3572. return this.push.apply(this, arguments);
  3573. };
  3574. Stack.prototype.unshiftAll = function(iter) {
  3575. return this.pushAll(iter);
  3576. };
  3577. Stack.prototype.shift = function() {
  3578. return this.pop.apply(this, arguments);
  3579. };
  3580. Stack.prototype.clear = function() {
  3581. if (this.size === 0) {
  3582. return this;
  3583. }
  3584. if (this.__ownerID) {
  3585. this.size = 0;
  3586. this._head = undefined;
  3587. this.__hash = undefined;
  3588. this.__altered = true;
  3589. return this;
  3590. }
  3591. return emptyStack();
  3592. };
  3593. Stack.prototype.slice = function(begin, end) {
  3594. if (wholeSlice(begin, end, this.size)) {
  3595. return this;
  3596. }
  3597. var resolvedBegin = resolveBegin(begin, this.size);
  3598. var resolvedEnd = resolveEnd(end, this.size);
  3599. if (resolvedEnd !== this.size) {
  3600. // super.slice(begin, end);
  3601. return IndexedCollection.prototype.slice.call(this, begin, end);
  3602. }
  3603. var newSize = this.size - resolvedBegin;
  3604. var head = this._head;
  3605. while (resolvedBegin--) {
  3606. head = head.next;
  3607. }
  3608. if (this.__ownerID) {
  3609. this.size = newSize;
  3610. this._head = head;
  3611. this.__hash = undefined;
  3612. this.__altered = true;
  3613. return this;
  3614. }
  3615. return makeStack(newSize, head);
  3616. };
  3617. // @pragma Mutability
  3618. Stack.prototype.__ensureOwner = function(ownerID) {
  3619. if (ownerID === this.__ownerID) {
  3620. return this;
  3621. }
  3622. if (!ownerID) {
  3623. this.__ownerID = ownerID;
  3624. this.__altered = false;
  3625. return this;
  3626. }
  3627. return makeStack(this.size, this._head, ownerID, this.__hash);
  3628. };
  3629. // @pragma Iteration
  3630. Stack.prototype.__iterate = function(fn, reverse) {
  3631. if (reverse) {
  3632. return this.reverse().__iterate(fn);
  3633. }
  3634. var iterations = 0;
  3635. var node = this._head;
  3636. while (node) {
  3637. if (fn(node.value, iterations++, this) === false) {
  3638. break;
  3639. }
  3640. node = node.next;
  3641. }
  3642. return iterations;
  3643. };
  3644. Stack.prototype.__iterator = function(type, reverse) {
  3645. if (reverse) {
  3646. return this.reverse().__iterator(type);
  3647. }
  3648. var iterations = 0;
  3649. var node = this._head;
  3650. return new Iterator(function() {
  3651. if (node) {
  3652. var value = node.value;
  3653. node = node.next;
  3654. return iteratorValue(type, iterations++, value);
  3655. }
  3656. return iteratorDone();
  3657. });
  3658. };
  3659. function isStack(maybeStack) {
  3660. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  3661. }
  3662. Stack.isStack = isStack;
  3663. var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  3664. var StackPrototype = Stack.prototype;
  3665. StackPrototype[IS_STACK_SENTINEL] = true;
  3666. StackPrototype.withMutations = MapPrototype.withMutations;
  3667. StackPrototype.asMutable = MapPrototype.asMutable;
  3668. StackPrototype.asImmutable = MapPrototype.asImmutable;
  3669. StackPrototype.wasAltered = MapPrototype.wasAltered;
  3670. function makeStack(size, head, ownerID, hash) {
  3671. var map = Object.create(StackPrototype);
  3672. map.size = size;
  3673. map._head = head;
  3674. map.__ownerID = ownerID;
  3675. map.__hash = hash;
  3676. map.__altered = false;
  3677. return map;
  3678. }
  3679. var EMPTY_STACK;
  3680. function emptyStack() {
  3681. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  3682. }
  3683. /**
  3684. * Contributes additional methods to a constructor
  3685. */
  3686. function mixin(ctor, methods) {
  3687. var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
  3688. Object.keys(methods).forEach(keyCopier);
  3689. Object.getOwnPropertySymbols &&
  3690. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  3691. return ctor;
  3692. }
  3693. Iterable.Iterator = Iterator;
  3694. mixin(Iterable, {
  3695. // ### Conversion to other types
  3696. toArray: function() {
  3697. assertNotInfinite(this.size);
  3698. var array = new Array(this.size || 0);
  3699. this.valueSeq().__iterate(function(v, i) { array[i] = v; });
  3700. return array;
  3701. },
  3702. toIndexedSeq: function() {
  3703. return new ToIndexedSequence(this);
  3704. },
  3705. toJS: function() {
  3706. return this.toSeq().map(
  3707. function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
  3708. ).__toJS();
  3709. },
  3710. toJSON: function() {
  3711. return this.toSeq().map(
  3712. function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
  3713. ).__toJS();
  3714. },
  3715. toKeyedSeq: function() {
  3716. return new ToKeyedSequence(this, true);
  3717. },
  3718. toMap: function() {
  3719. // Use Late Binding here to solve the circular dependency.
  3720. return Map(this.toKeyedSeq());
  3721. },
  3722. toObject: function() {
  3723. assertNotInfinite(this.size);
  3724. var object = {};
  3725. this.__iterate(function(v, k) { object[k] = v; });
  3726. return object;
  3727. },
  3728. toOrderedMap: function() {
  3729. // Use Late Binding here to solve the circular dependency.
  3730. return OrderedMap(this.toKeyedSeq());
  3731. },
  3732. toOrderedSet: function() {
  3733. // Use Late Binding here to solve the circular dependency.
  3734. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  3735. },
  3736. toSet: function() {
  3737. // Use Late Binding here to solve the circular dependency.
  3738. return Set(isKeyed(this) ? this.valueSeq() : this);
  3739. },
  3740. toSetSeq: function() {
  3741. return new ToSetSequence(this);
  3742. },
  3743. toSeq: function() {
  3744. return isIndexed(this) ? this.toIndexedSeq() :
  3745. isKeyed(this) ? this.toKeyedSeq() :
  3746. this.toSetSeq();
  3747. },
  3748. toStack: function() {
  3749. // Use Late Binding here to solve the circular dependency.
  3750. return Stack(isKeyed(this) ? this.valueSeq() : this);
  3751. },
  3752. toList: function() {
  3753. // Use Late Binding here to solve the circular dependency.
  3754. return List(isKeyed(this) ? this.valueSeq() : this);
  3755. },
  3756. // ### Common JavaScript methods and properties
  3757. toString: function() {
  3758. return '[Iterable]';
  3759. },
  3760. __toString: function(head, tail) {
  3761. if (this.size === 0) {
  3762. return head + tail;
  3763. }
  3764. return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
  3765. },
  3766. // ### ES6 Collection methods (ES6 Array and Map)
  3767. concat: function() {var values = SLICE$0.call(arguments, 0);
  3768. return reify(this, concatFactory(this, values));
  3769. },
  3770. includes: function(searchValue) {
  3771. return this.some(function(value ) {return is(value, searchValue)});
  3772. },
  3773. entries: function() {
  3774. return this.__iterator(ITERATE_ENTRIES);
  3775. },
  3776. every: function(predicate, context) {
  3777. assertNotInfinite(this.size);
  3778. var returnValue = true;
  3779. this.__iterate(function(v, k, c) {
  3780. if (!predicate.call(context, v, k, c)) {
  3781. returnValue = false;
  3782. return false;
  3783. }
  3784. });
  3785. return returnValue;
  3786. },
  3787. filter: function(predicate, context) {
  3788. return reify(this, filterFactory(this, predicate, context, true));
  3789. },
  3790. find: function(predicate, context, notSetValue) {
  3791. var entry = this.findEntry(predicate, context);
  3792. return entry ? entry[1] : notSetValue;
  3793. },
  3794. findEntry: function(predicate, context) {
  3795. var found;
  3796. this.__iterate(function(v, k, c) {
  3797. if (predicate.call(context, v, k, c)) {
  3798. found = [k, v];
  3799. return false;
  3800. }
  3801. });
  3802. return found;
  3803. },
  3804. findLastEntry: function(predicate, context) {
  3805. return this.toSeq().reverse().findEntry(predicate, context);
  3806. },
  3807. forEach: function(sideEffect, context) {
  3808. assertNotInfinite(this.size);
  3809. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  3810. },
  3811. join: function(separator) {
  3812. assertNotInfinite(this.size);
  3813. separator = separator !== undefined ? '' + separator : ',';
  3814. var joined = '';
  3815. var isFirst = true;
  3816. this.__iterate(function(v ) {
  3817. isFirst ? (isFirst = false) : (joined += separator);
  3818. joined += v !== null && v !== undefined ? v.toString() : '';
  3819. });
  3820. return joined;
  3821. },
  3822. keys: function() {
  3823. return this.__iterator(ITERATE_KEYS);
  3824. },
  3825. map: function(mapper, context) {
  3826. return reify(this, mapFactory(this, mapper, context));
  3827. },
  3828. reduce: function(reducer, initialReduction, context) {
  3829. assertNotInfinite(this.size);
  3830. var reduction;
  3831. var useFirst;
  3832. if (arguments.length < 2) {
  3833. useFirst = true;
  3834. } else {
  3835. reduction = initialReduction;
  3836. }
  3837. this.__iterate(function(v, k, c) {
  3838. if (useFirst) {
  3839. useFirst = false;
  3840. reduction = v;
  3841. } else {
  3842. reduction = reducer.call(context, reduction, v, k, c);
  3843. }
  3844. });
  3845. return reduction;
  3846. },
  3847. reduceRight: function(reducer, initialReduction, context) {
  3848. var reversed = this.toKeyedSeq().reverse();
  3849. return reversed.reduce.apply(reversed, arguments);
  3850. },
  3851. reverse: function() {
  3852. return reify(this, reverseFactory(this, true));
  3853. },
  3854. slice: function(begin, end) {
  3855. return reify(this, sliceFactory(this, begin, end, true));
  3856. },
  3857. some: function(predicate, context) {
  3858. return !this.every(not(predicate), context);
  3859. },
  3860. sort: function(comparator) {
  3861. return reify(this, sortFactory(this, comparator));
  3862. },
  3863. values: function() {
  3864. return this.__iterator(ITERATE_VALUES);
  3865. },
  3866. // ### More sequential methods
  3867. butLast: function() {
  3868. return this.slice(0, -1);
  3869. },
  3870. isEmpty: function() {
  3871. return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
  3872. },
  3873. count: function(predicate, context) {
  3874. return ensureSize(
  3875. predicate ? this.toSeq().filter(predicate, context) : this
  3876. );
  3877. },
  3878. countBy: function(grouper, context) {
  3879. return countByFactory(this, grouper, context);
  3880. },
  3881. equals: function(other) {
  3882. return deepEqual(this, other);
  3883. },
  3884. entrySeq: function() {
  3885. var iterable = this;
  3886. if (iterable._cache) {
  3887. // We cache as an entries array, so we can just return the cache!
  3888. return new ArraySeq(iterable._cache);
  3889. }
  3890. var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
  3891. entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
  3892. return entriesSequence;
  3893. },
  3894. filterNot: function(predicate, context) {
  3895. return this.filter(not(predicate), context);
  3896. },
  3897. findLast: function(predicate, context, notSetValue) {
  3898. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  3899. },
  3900. first: function() {
  3901. return this.find(returnTrue);
  3902. },
  3903. flatMap: function(mapper, context) {
  3904. return reify(this, flatMapFactory(this, mapper, context));
  3905. },
  3906. flatten: function(depth) {
  3907. return reify(this, flattenFactory(this, depth, true));
  3908. },
  3909. fromEntrySeq: function() {
  3910. return new FromEntriesSequence(this);
  3911. },
  3912. get: function(searchKey, notSetValue) {
  3913. return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
  3914. },
  3915. getIn: function(searchKeyPath, notSetValue) {
  3916. var nested = this;
  3917. // Note: in an ES6 environment, we would prefer:
  3918. // for (var key of searchKeyPath) {
  3919. var iter = forceIterator(searchKeyPath);
  3920. var step;
  3921. while (!(step = iter.next()).done) {
  3922. var key = step.value;
  3923. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  3924. if (nested === NOT_SET) {
  3925. return notSetValue;
  3926. }
  3927. }
  3928. return nested;
  3929. },
  3930. groupBy: function(grouper, context) {
  3931. return groupByFactory(this, grouper, context);
  3932. },
  3933. has: function(searchKey) {
  3934. return this.get(searchKey, NOT_SET) !== NOT_SET;
  3935. },
  3936. hasIn: function(searchKeyPath) {
  3937. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  3938. },
  3939. isSubset: function(iter) {
  3940. iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
  3941. return this.every(function(value ) {return iter.includes(value)});
  3942. },
  3943. isSuperset: function(iter) {
  3944. iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
  3945. return iter.isSubset(this);
  3946. },
  3947. keySeq: function() {
  3948. return this.toSeq().map(keyMapper).toIndexedSeq();
  3949. },
  3950. last: function() {
  3951. return this.toSeq().reverse().first();
  3952. },
  3953. max: function(comparator) {
  3954. return maxFactory(this, comparator);
  3955. },
  3956. maxBy: function(mapper, comparator) {
  3957. return maxFactory(this, comparator, mapper);
  3958. },
  3959. min: function(comparator) {
  3960. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
  3961. },
  3962. minBy: function(mapper, comparator) {
  3963. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
  3964. },
  3965. rest: function() {
  3966. return this.slice(1);
  3967. },
  3968. skip: function(amount) {
  3969. return this.slice(Math.max(0, amount));
  3970. },
  3971. skipLast: function(amount) {
  3972. return reify(this, this.toSeq().reverse().skip(amount).reverse());
  3973. },
  3974. skipWhile: function(predicate, context) {
  3975. return reify(this, skipWhileFactory(this, predicate, context, true));
  3976. },
  3977. skipUntil: function(predicate, context) {
  3978. return this.skipWhile(not(predicate), context);
  3979. },
  3980. sortBy: function(mapper, comparator) {
  3981. return reify(this, sortFactory(this, comparator, mapper));
  3982. },
  3983. take: function(amount) {
  3984. return this.slice(0, Math.max(0, amount));
  3985. },
  3986. takeLast: function(amount) {
  3987. return reify(this, this.toSeq().reverse().take(amount).reverse());
  3988. },
  3989. takeWhile: function(predicate, context) {
  3990. return reify(this, takeWhileFactory(this, predicate, context));
  3991. },
  3992. takeUntil: function(predicate, context) {
  3993. return this.takeWhile(not(predicate), context);
  3994. },
  3995. valueSeq: function() {
  3996. return this.toIndexedSeq();
  3997. },
  3998. // ### Hashable Object
  3999. hashCode: function() {
  4000. return this.__hash || (this.__hash = hashIterable(this));
  4001. }
  4002. // ### Internal
  4003. // abstract __iterate(fn, reverse)
  4004. // abstract __iterator(type, reverse)
  4005. });
  4006. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  4007. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  4008. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  4009. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  4010. var IterablePrototype = Iterable.prototype;
  4011. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  4012. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  4013. IterablePrototype.__toJS = IterablePrototype.toArray;
  4014. IterablePrototype.__toStringMapper = quoteString;
  4015. IterablePrototype.inspect =
  4016. IterablePrototype.toSource = function() { return this.toString(); };
  4017. IterablePrototype.chain = IterablePrototype.flatMap;
  4018. IterablePrototype.contains = IterablePrototype.includes;
  4019. // Temporary warning about using length
  4020. (function () {
  4021. try {
  4022. Object.defineProperty(IterablePrototype, 'length', {
  4023. get: function () {
  4024. if (!Iterable.noLengthWarning) {
  4025. var stack;
  4026. try {
  4027. throw new Error();
  4028. } catch (error) {
  4029. stack = error.stack;
  4030. }
  4031. if (stack.indexOf('_wrapObject') === -1) {
  4032. console && console.warn && console.warn(
  4033. 'iterable.length has been deprecated, '+
  4034. 'use iterable.size or iterable.count(). '+
  4035. 'This warning will become a silent error in a future version. ' +
  4036. stack
  4037. );
  4038. return this.size;
  4039. }
  4040. }
  4041. }
  4042. });
  4043. } catch (e) {}
  4044. })();
  4045. mixin(KeyedIterable, {
  4046. // ### More sequential methods
  4047. flip: function() {
  4048. return reify(this, flipFactory(this));
  4049. },
  4050. findKey: function(predicate, context) {
  4051. var entry = this.findEntry(predicate, context);
  4052. return entry && entry[0];
  4053. },
  4054. findLastKey: function(predicate, context) {
  4055. return this.toSeq().reverse().findKey(predicate, context);
  4056. },
  4057. keyOf: function(searchValue) {
  4058. return this.findKey(function(value ) {return is(value, searchValue)});
  4059. },
  4060. lastKeyOf: function(searchValue) {
  4061. return this.findLastKey(function(value ) {return is(value, searchValue)});
  4062. },
  4063. mapEntries: function(mapper, context) {var this$0 = this;
  4064. var iterations = 0;
  4065. return reify(this,
  4066. this.toSeq().map(
  4067. function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
  4068. ).fromEntrySeq()
  4069. );
  4070. },
  4071. mapKeys: function(mapper, context) {var this$0 = this;
  4072. return reify(this,
  4073. this.toSeq().flip().map(
  4074. function(k, v) {return mapper.call(context, k, v, this$0)}
  4075. ).flip()
  4076. );
  4077. }
  4078. });
  4079. var KeyedIterablePrototype = KeyedIterable.prototype;
  4080. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  4081. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  4082. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  4083. KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
  4084. mixin(IndexedIterable, {
  4085. // ### Conversion to other types
  4086. toKeyedSeq: function() {
  4087. return new ToKeyedSequence(this, false);
  4088. },
  4089. // ### ES6 Collection methods (ES6 Array and Map)
  4090. filter: function(predicate, context) {
  4091. return reify(this, filterFactory(this, predicate, context, false));
  4092. },
  4093. findIndex: function(predicate, context) {
  4094. var entry = this.findEntry(predicate, context);
  4095. return entry ? entry[0] : -1;
  4096. },
  4097. indexOf: function(searchValue) {
  4098. var key = this.toKeyedSeq().keyOf(searchValue);
  4099. return key === undefined ? -1 : key;
  4100. },
  4101. lastIndexOf: function(searchValue) {
  4102. var key = this.toKeyedSeq().reverse().keyOf(searchValue);
  4103. return key === undefined ? -1 : key;
  4104. // var index =
  4105. // return this.toSeq().reverse().indexOf(searchValue);
  4106. },
  4107. reverse: function() {
  4108. return reify(this, reverseFactory(this, false));
  4109. },
  4110. slice: function(begin, end) {
  4111. return reify(this, sliceFactory(this, begin, end, false));
  4112. },
  4113. splice: function(index, removeNum /*, ...values*/) {
  4114. var numArgs = arguments.length;
  4115. removeNum = Math.max(removeNum | 0, 0);
  4116. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  4117. return this;
  4118. }
  4119. // If index is negative, it should resolve relative to the size of the
  4120. // collection. However size may be expensive to compute if not cached, so
  4121. // only call count() if the number is in fact negative.
  4122. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  4123. var spliced = this.slice(0, index);
  4124. return reify(
  4125. this,
  4126. numArgs === 1 ?
  4127. spliced :
  4128. spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  4129. );
  4130. },
  4131. // ### More collection methods
  4132. findLastIndex: function(predicate, context) {
  4133. var key = this.toKeyedSeq().findLastKey(predicate, context);
  4134. return key === undefined ? -1 : key;
  4135. },
  4136. first: function() {
  4137. return this.get(0);
  4138. },
  4139. flatten: function(depth) {
  4140. return reify(this, flattenFactory(this, depth, false));
  4141. },
  4142. get: function(index, notSetValue) {
  4143. index = wrapIndex(this, index);
  4144. return (index < 0 || (this.size === Infinity ||
  4145. (this.size !== undefined && index > this.size))) ?
  4146. notSetValue :
  4147. this.find(function(_, key) {return key === index}, undefined, notSetValue);
  4148. },
  4149. has: function(index) {
  4150. index = wrapIndex(this, index);
  4151. return index >= 0 && (this.size !== undefined ?
  4152. this.size === Infinity || index < this.size :
  4153. this.indexOf(index) !== -1
  4154. );
  4155. },
  4156. interpose: function(separator) {
  4157. return reify(this, interposeFactory(this, separator));
  4158. },
  4159. interleave: function(/*...iterables*/) {
  4160. var iterables = [this].concat(arrCopy(arguments));
  4161. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  4162. var interleaved = zipped.flatten(true);
  4163. if (zipped.size) {
  4164. interleaved.size = zipped.size * iterables.length;
  4165. }
  4166. return reify(this, interleaved);
  4167. },
  4168. last: function() {
  4169. return this.get(-1);
  4170. },
  4171. skipWhile: function(predicate, context) {
  4172. return reify(this, skipWhileFactory(this, predicate, context, false));
  4173. },
  4174. zip: function(/*, ...iterables */) {
  4175. var iterables = [this].concat(arrCopy(arguments));
  4176. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  4177. },
  4178. zipWith: function(zipper/*, ...iterables */) {
  4179. var iterables = arrCopy(arguments);
  4180. iterables[0] = this;
  4181. return reify(this, zipWithFactory(this, zipper, iterables));
  4182. }
  4183. });
  4184. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  4185. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  4186. mixin(SetIterable, {
  4187. // ### ES6 Collection methods (ES6 Array and Map)
  4188. get: function(value, notSetValue) {
  4189. return this.has(value) ? value : notSetValue;
  4190. },
  4191. includes: function(value) {
  4192. return this.has(value);
  4193. },
  4194. // ### More sequential methods
  4195. keySeq: function() {
  4196. return this.valueSeq();
  4197. }
  4198. });
  4199. SetIterable.prototype.has = IterablePrototype.includes;
  4200. // Mixin subclasses
  4201. mixin(KeyedSeq, KeyedIterable.prototype);
  4202. mixin(IndexedSeq, IndexedIterable.prototype);
  4203. mixin(SetSeq, SetIterable.prototype);
  4204. mixin(KeyedCollection, KeyedIterable.prototype);
  4205. mixin(IndexedCollection, IndexedIterable.prototype);
  4206. mixin(SetCollection, SetIterable.prototype);
  4207. // #pragma Helper functions
  4208. function keyMapper(v, k) {
  4209. return k;
  4210. }
  4211. function entryMapper(v, k) {
  4212. return [k, v];
  4213. }
  4214. function not(predicate) {
  4215. return function() {
  4216. return !predicate.apply(this, arguments);
  4217. }
  4218. }
  4219. function neg(predicate) {
  4220. return function() {
  4221. return -predicate.apply(this, arguments);
  4222. }
  4223. }
  4224. function quoteString(value) {
  4225. return typeof value === 'string' ? JSON.stringify(value) : value;
  4226. }
  4227. function defaultZipper() {
  4228. return arrCopy(arguments);
  4229. }
  4230. function defaultNegComparator(a, b) {
  4231. return a < b ? 1 : a > b ? -1 : 0;
  4232. }
  4233. function hashIterable(iterable) {
  4234. if (iterable.size === Infinity) {
  4235. return 0;
  4236. }
  4237. var ordered = isOrdered(iterable);
  4238. var keyed = isKeyed(iterable);
  4239. var h = ordered ? 1 : 0;
  4240. var size = iterable.__iterate(
  4241. keyed ?
  4242. ordered ?
  4243. function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
  4244. function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
  4245. ordered ?
  4246. function(v ) { h = 31 * h + hash(v) | 0; } :
  4247. function(v ) { h = h + hash(v) | 0; }
  4248. );
  4249. return murmurHashOfSize(size, h);
  4250. }
  4251. function murmurHashOfSize(size, h) {
  4252. h = imul(h, 0xCC9E2D51);
  4253. h = imul(h << 15 | h >>> -15, 0x1B873593);
  4254. h = imul(h << 13 | h >>> -13, 5);
  4255. h = (h + 0xE6546B64 | 0) ^ size;
  4256. h = imul(h ^ h >>> 16, 0x85EBCA6B);
  4257. h = imul(h ^ h >>> 13, 0xC2B2AE35);
  4258. h = smi(h ^ h >>> 16);
  4259. return h;
  4260. }
  4261. function hashMerge(a, b) {
  4262. return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
  4263. }
  4264. var Immutable = {
  4265. Iterable: Iterable,
  4266. Seq: Seq,
  4267. Collection: Collection,
  4268. Map: Map,
  4269. OrderedMap: OrderedMap,
  4270. List: List,
  4271. Stack: Stack,
  4272. Set: Set,
  4273. OrderedSet: OrderedSet,
  4274. Record: Record,
  4275. Range: Range,
  4276. Repeat: Repeat,
  4277. is: is,
  4278. fromJS: fromJS
  4279. };
  4280. return Immutable;
  4281. }));
  4282. });
  4283. var OrderedMap = immutable.OrderedMap;
  4284. var BlockMapBuilder = {
  4285. createFromArray: function createFromArray(blocks) {
  4286. return OrderedMap(blocks.map(function (block) {
  4287. return [block.getKey(), block];
  4288. }));
  4289. }
  4290. };
  4291. var BlockMapBuilder_1 = BlockMapBuilder;
  4292. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4293. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4294. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4295. var Map = immutable.Map,
  4296. OrderedSet = immutable.OrderedSet,
  4297. Record = immutable.Record;
  4298. // Immutable.map is typed such that the value for every key in the map
  4299. // must be the same type
  4300. var EMPTY_SET = OrderedSet();
  4301. var defaultRecord = {
  4302. style: EMPTY_SET,
  4303. entity: null
  4304. };
  4305. var CharacterMetadataRecord = Record(defaultRecord);
  4306. var CharacterMetadata = function (_CharacterMetadataRec) {
  4307. _inherits(CharacterMetadata, _CharacterMetadataRec);
  4308. function CharacterMetadata() {
  4309. _classCallCheck(this, CharacterMetadata);
  4310. return _possibleConstructorReturn(this, _CharacterMetadataRec.apply(this, arguments));
  4311. }
  4312. CharacterMetadata.prototype.getStyle = function getStyle() {
  4313. return this.get('style');
  4314. };
  4315. CharacterMetadata.prototype.getEntity = function getEntity() {
  4316. return this.get('entity');
  4317. };
  4318. CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
  4319. return this.getStyle().includes(style);
  4320. };
  4321. CharacterMetadata.applyStyle = function applyStyle(record, style) {
  4322. var withStyle = record.set('style', record.getStyle().add(style));
  4323. return CharacterMetadata.create(withStyle);
  4324. };
  4325. CharacterMetadata.removeStyle = function removeStyle(record, style) {
  4326. var withoutStyle = record.set('style', record.getStyle().remove(style));
  4327. return CharacterMetadata.create(withoutStyle);
  4328. };
  4329. CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
  4330. var withEntity = record.getEntity() === entityKey ? record : record.set('entity', entityKey);
  4331. return CharacterMetadata.create(withEntity);
  4332. };
  4333. /**
  4334. * Use this function instead of the `CharacterMetadata` constructor.
  4335. * Since most content generally uses only a very small number of
  4336. * style/entity permutations, we can reuse these objects as often as
  4337. * possible.
  4338. */
  4339. CharacterMetadata.create = function create(config) {
  4340. if (!config) {
  4341. return EMPTY;
  4342. }
  4343. var defaultConfig = {
  4344. style: EMPTY_SET,
  4345. entity: null
  4346. };
  4347. // Fill in unspecified properties, if necessary.
  4348. var configMap = Map(defaultConfig).merge(config);
  4349. var existing = pool.get(configMap);
  4350. if (existing) {
  4351. return existing;
  4352. }
  4353. var newCharacter = new CharacterMetadata(configMap);
  4354. pool = pool.set(configMap, newCharacter);
  4355. return newCharacter;
  4356. };
  4357. return CharacterMetadata;
  4358. }(CharacterMetadataRecord);
  4359. var EMPTY = new CharacterMetadata();
  4360. var pool = Map([[Map(defaultRecord), EMPTY]]);
  4361. CharacterMetadata.EMPTY = EMPTY;
  4362. var CharacterMetadata_1 = CharacterMetadata;
  4363. /**
  4364. * Copyright (c) 2013-present, Facebook, Inc.
  4365. * All rights reserved.
  4366. *
  4367. * This source code is licensed under the BSD-style license found in the
  4368. * LICENSE file in the root directory of this source tree. An additional grant
  4369. * of patent rights can be found in the PATENTS file in the same directory.
  4370. *
  4371. * @providesModule findRangesImmutable
  4372. * @format
  4373. *
  4374. */
  4375. /**
  4376. * Search through an array to find contiguous stretches of elements that
  4377. * match a specified filter function.
  4378. *
  4379. * When ranges are found, execute a specified `found` function to supply
  4380. * the values to the caller.
  4381. */
  4382. function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
  4383. if (!haystack.size) {
  4384. return;
  4385. }
  4386. var cursor = 0;
  4387. haystack.reduce(function (value, nextValue, nextIndex) {
  4388. if (!areEqualFn(value, nextValue)) {
  4389. if (filterFn(value)) {
  4390. foundFn(cursor, nextIndex);
  4391. }
  4392. cursor = nextIndex;
  4393. }
  4394. return nextValue;
  4395. });
  4396. filterFn(haystack.last()) && foundFn(cursor, haystack.count());
  4397. }
  4398. var findRangesImmutable_1 = findRangesImmutable;
  4399. function _classCallCheck$1(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4400. function _possibleConstructorReturn$1(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4401. function _inherits$1(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4402. var List = immutable.List,
  4403. Map$1 = immutable.Map,
  4404. OrderedSet$1 = immutable.OrderedSet,
  4405. Record$1 = immutable.Record,
  4406. Repeat = immutable.Repeat;
  4407. var EMPTY_SET$1 = OrderedSet$1();
  4408. var defaultRecord$1 = {
  4409. key: '',
  4410. type: 'unstyled',
  4411. text: '',
  4412. characterList: List(),
  4413. depth: 0,
  4414. data: Map$1()
  4415. };
  4416. var ContentBlockRecord = Record$1(defaultRecord$1);
  4417. var decorateCharacterList = function decorateCharacterList(config) {
  4418. if (!config) {
  4419. return config;
  4420. }
  4421. var characterList = config.characterList,
  4422. text = config.text;
  4423. if (text && !characterList) {
  4424. config.characterList = List(Repeat(CharacterMetadata_1.EMPTY, text.length));
  4425. }
  4426. return config;
  4427. };
  4428. var ContentBlock = function (_ContentBlockRecord) {
  4429. _inherits$1(ContentBlock, _ContentBlockRecord);
  4430. function ContentBlock(config) {
  4431. _classCallCheck$1(this, ContentBlock);
  4432. return _possibleConstructorReturn$1(this, _ContentBlockRecord.call(this, decorateCharacterList(config)));
  4433. }
  4434. ContentBlock.prototype.getKey = function getKey() {
  4435. return this.get('key');
  4436. };
  4437. ContentBlock.prototype.getType = function getType() {
  4438. return this.get('type');
  4439. };
  4440. ContentBlock.prototype.getText = function getText() {
  4441. return this.get('text');
  4442. };
  4443. ContentBlock.prototype.getCharacterList = function getCharacterList() {
  4444. return this.get('characterList');
  4445. };
  4446. ContentBlock.prototype.getLength = function getLength() {
  4447. return this.getText().length;
  4448. };
  4449. ContentBlock.prototype.getDepth = function getDepth() {
  4450. return this.get('depth');
  4451. };
  4452. ContentBlock.prototype.getData = function getData() {
  4453. return this.get('data');
  4454. };
  4455. ContentBlock.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
  4456. var character = this.getCharacterList().get(offset);
  4457. return character ? character.getStyle() : EMPTY_SET$1;
  4458. };
  4459. ContentBlock.prototype.getEntityAt = function getEntityAt(offset) {
  4460. var character = this.getCharacterList().get(offset);
  4461. return character ? character.getEntity() : null;
  4462. };
  4463. /**
  4464. * Execute a callback for every contiguous range of styles within the block.
  4465. */
  4466. ContentBlock.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
  4467. findRangesImmutable_1(this.getCharacterList(), haveEqualStyle, filterFn, callback);
  4468. };
  4469. /**
  4470. * Execute a callback for every contiguous range of entities within the block.
  4471. */
  4472. ContentBlock.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
  4473. findRangesImmutable_1(this.getCharacterList(), haveEqualEntity, filterFn, callback);
  4474. };
  4475. return ContentBlock;
  4476. }(ContentBlockRecord);
  4477. function haveEqualStyle(charA, charB) {
  4478. return charA.getStyle() === charB.getStyle();
  4479. }
  4480. function haveEqualEntity(charA, charB) {
  4481. return charA.getEntity() === charB.getEntity();
  4482. }
  4483. var ContentBlock_1 = ContentBlock;
  4484. function _classCallCheck$2(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  4485. function _possibleConstructorReturn$2(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  4486. function _inherits$2(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  4487. var List$1 = immutable.List,
  4488. Map$2 = immutable.Map,
  4489. OrderedSet$2 = immutable.OrderedSet,
  4490. Record$2 = immutable.Record,
  4491. Repeat$1 = immutable.Repeat;
  4492. var EMPTY_SET$2 = OrderedSet$2();
  4493. var defaultRecord$2 = {
  4494. parent: null,
  4495. characterList: List$1(),
  4496. data: Map$2(),
  4497. depth: 0,
  4498. key: '',
  4499. text: '',
  4500. type: 'unstyled',
  4501. children: List$1(),
  4502. prevSibling: null,
  4503. nextSibling: null
  4504. };
  4505. var haveEqualStyle$1 = function haveEqualStyle(charA, charB) {
  4506. return charA.getStyle() === charB.getStyle();
  4507. };
  4508. var haveEqualEntity$1 = function haveEqualEntity(charA, charB) {
  4509. return charA.getEntity() === charB.getEntity();
  4510. };
  4511. var decorateCharacterList$1 = function decorateCharacterList(config) {
  4512. if (!config) {
  4513. return config;
  4514. }
  4515. var characterList = config.characterList,
  4516. text = config.text;
  4517. if (text && !characterList) {
  4518. config.characterList = List$1(Repeat$1(CharacterMetadata_1.EMPTY, text.length));
  4519. }
  4520. return config;
  4521. };
  4522. var ContentBlockNode = function (_Record) {
  4523. _inherits$2(ContentBlockNode, _Record);
  4524. function ContentBlockNode() {
  4525. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultRecord$2;
  4526. _classCallCheck$2(this, ContentBlockNode);
  4527. return _possibleConstructorReturn$2(this, _Record.call(this, decorateCharacterList$1(props)));
  4528. }
  4529. ContentBlockNode.prototype.getKey = function getKey() {
  4530. return this.get('key');
  4531. };
  4532. ContentBlockNode.prototype.getType = function getType() {
  4533. return this.get('type');
  4534. };
  4535. ContentBlockNode.prototype.getText = function getText() {
  4536. return this.get('text');
  4537. };
  4538. ContentBlockNode.prototype.getCharacterList = function getCharacterList() {
  4539. return this.get('characterList');
  4540. };
  4541. ContentBlockNode.prototype.getLength = function getLength() {
  4542. return this.getText().length;
  4543. };
  4544. ContentBlockNode.prototype.getDepth = function getDepth() {
  4545. return this.get('depth');
  4546. };
  4547. ContentBlockNode.prototype.getData = function getData() {
  4548. return this.get('data');
  4549. };
  4550. ContentBlockNode.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
  4551. var character = this.getCharacterList().get(offset);
  4552. return character ? character.getStyle() : EMPTY_SET$2;
  4553. };
  4554. ContentBlockNode.prototype.getEntityAt = function getEntityAt(offset) {
  4555. var character = this.getCharacterList().get(offset);
  4556. return character ? character.getEntity() : null;
  4557. };
  4558. ContentBlockNode.prototype.getChildKeys = function getChildKeys() {
  4559. return this.get('children');
  4560. };
  4561. ContentBlockNode.prototype.getParentKey = function getParentKey() {
  4562. return this.get('parent');
  4563. };
  4564. ContentBlockNode.prototype.getPrevSiblingKey = function getPrevSiblingKey() {
  4565. return this.get('prevSibling');
  4566. };
  4567. ContentBlockNode.prototype.getNextSiblingKey = function getNextSiblingKey() {
  4568. return this.get('nextSibling');
  4569. };
  4570. ContentBlockNode.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
  4571. findRangesImmutable_1(this.getCharacterList(), haveEqualStyle$1, filterFn, callback);
  4572. };
  4573. ContentBlockNode.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
  4574. findRangesImmutable_1(this.getCharacterList(), haveEqualEntity$1, filterFn, callback);
  4575. };
  4576. return ContentBlockNode;
  4577. }(Record$2(defaultRecord$2));
  4578. var ContentBlockNode_1 = ContentBlockNode;
  4579. /**
  4580. * Copyright 2013-present, Facebook, Inc.
  4581. * All rights reserved.
  4582. *
  4583. * This source code is licensed under the BSD-style license found in the
  4584. * LICENSE file in the root directory of this source tree. An additional grant
  4585. * of patent rights can be found in the PATENTS file in the same directory.
  4586. *
  4587. * @providesModule DraftFeatureFlags-core
  4588. * @format
  4589. *
  4590. */
  4591. var DraftFeatureFlags = {
  4592. draft_killswitch_allow_nontextnodes: false,
  4593. draft_segmented_entities_behavior: false,
  4594. draft_handlebeforeinput_composed_text: false,
  4595. draft_tree_data_support: false
  4596. };
  4597. var DraftFeatureFlagsCore = DraftFeatureFlags;
  4598. var DraftFeatureFlags_1 = DraftFeatureFlagsCore;
  4599. var Map$3 = immutable.Map;
  4600. var ContentStateInlineStyle = {
  4601. add: function add(contentState, selectionState, inlineStyle) {
  4602. return modifyInlineStyle(contentState, selectionState, inlineStyle, true);
  4603. },
  4604. remove: function remove(contentState, selectionState, inlineStyle) {
  4605. return modifyInlineStyle(contentState, selectionState, inlineStyle, false);
  4606. }
  4607. };
  4608. function modifyInlineStyle(contentState, selectionState, inlineStyle, addOrRemove) {
  4609. var blockMap = contentState.getBlockMap();
  4610. var startKey = selectionState.getStartKey();
  4611. var startOffset = selectionState.getStartOffset();
  4612. var endKey = selectionState.getEndKey();
  4613. var endOffset = selectionState.getEndOffset();
  4614. var newBlocks = blockMap.skipUntil(function (_, k) {
  4615. return k === startKey;
  4616. }).takeUntil(function (_, k) {
  4617. return k === endKey;
  4618. }).concat(Map$3([[endKey, blockMap.get(endKey)]])).map(function (block, blockKey) {
  4619. var sliceStart;
  4620. var sliceEnd;
  4621. if (startKey === endKey) {
  4622. sliceStart = startOffset;
  4623. sliceEnd = endOffset;
  4624. } else {
  4625. sliceStart = blockKey === startKey ? startOffset : 0;
  4626. sliceEnd = blockKey === endKey ? endOffset : block.getLength();
  4627. }
  4628. var chars = block.getCharacterList();
  4629. var current;
  4630. while (sliceStart < sliceEnd) {
  4631. current = chars.get(sliceStart);
  4632. chars = chars.set(sliceStart, addOrRemove ? CharacterMetadata_1.applyStyle(current, inlineStyle) : CharacterMetadata_1.removeStyle(current, inlineStyle));
  4633. sliceStart++;
  4634. }
  4635. return block.set('characterList', chars);
  4636. });
  4637. return contentState.merge({
  4638. blockMap: blockMap.merge(newBlocks),
  4639. selectionBefore: selectionState,
  4640. selectionAfter: selectionState
  4641. });
  4642. }
  4643. var ContentStateInlineStyle_1 = ContentStateInlineStyle;
  4644. function applyEntityToContentBlock(contentBlock, start, end, entityKey) {
  4645. var characterList = contentBlock.getCharacterList();
  4646. while (start < end) {
  4647. characterList = characterList.set(start, CharacterMetadata_1.applyEntity(characterList.get(start), entityKey));
  4648. start++;
  4649. }
  4650. return contentBlock.set('characterList', characterList);
  4651. }
  4652. var applyEntityToContentBlock_1 = applyEntityToContentBlock;
  4653. function applyEntityToContentState(contentState, selectionState, entityKey) {
  4654. var blockMap = contentState.getBlockMap();
  4655. var startKey = selectionState.getStartKey();
  4656. var startOffset = selectionState.getStartOffset();
  4657. var endKey = selectionState.getEndKey();
  4658. var endOffset = selectionState.getEndOffset();
  4659. var newBlocks = blockMap.skipUntil(function (_, k) {
  4660. return k === startKey;
  4661. }).takeUntil(function (_, k) {
  4662. return k === endKey;
  4663. }).toOrderedMap().merge(immutable.OrderedMap([[endKey, blockMap.get(endKey)]])).map(function (block, blockKey) {
  4664. var sliceStart = blockKey === startKey ? startOffset : 0;
  4665. var sliceEnd = blockKey === endKey ? endOffset : block.getLength();
  4666. return applyEntityToContentBlock_1(block, sliceStart, sliceEnd, entityKey);
  4667. });
  4668. return contentState.merge({
  4669. blockMap: blockMap.merge(newBlocks),
  4670. selectionBefore: selectionState,
  4671. selectionAfter: selectionState
  4672. });
  4673. }
  4674. var applyEntityToContentState_1 = applyEntityToContentState;
  4675. /**
  4676. * Copyright (c) 2013-present, Facebook, Inc.
  4677. * All rights reserved.
  4678. *
  4679. * This source code is licensed under the BSD-style license found in the
  4680. * LICENSE file in the root directory of this source tree. An additional grant
  4681. * of patent rights can be found in the PATENTS file in the same directory.
  4682. *
  4683. * @providesModule DraftEntitySegments
  4684. * @format
  4685. *
  4686. */
  4687. /**
  4688. * Identify the range to delete from a segmented entity.
  4689. *
  4690. * Rules:
  4691. *
  4692. * Example: 'John F. Kennedy'
  4693. *
  4694. * - Deletion from within any non-whitespace (i.e. ['John', 'F.', 'Kennedy'])
  4695. * will return the range of that text.
  4696. *
  4697. * 'John F. Kennedy' -> 'John F.'
  4698. * ^
  4699. *
  4700. * - Forward deletion of whitespace will remove the following section:
  4701. *
  4702. * 'John F. Kennedy' -> 'John Kennedy'
  4703. * ^
  4704. *
  4705. * - Backward deletion of whitespace will remove the previous section:
  4706. *
  4707. * 'John F. Kennedy' -> 'F. Kennedy'
  4708. * ^
  4709. */
  4710. var DraftEntitySegments = {
  4711. getRemovalRange: function getRemovalRange(selectionStart, selectionEnd, text, entityStart, direction) {
  4712. var segments = text.split(' ');
  4713. segments = segments.map(function ( /*string*/segment, /*number*/ii) {
  4714. if (direction === 'forward') {
  4715. if (ii > 0) {
  4716. return ' ' + segment;
  4717. }
  4718. } else if (ii < segments.length - 1) {
  4719. return segment + ' ';
  4720. }
  4721. return segment;
  4722. });
  4723. var segmentStart = entityStart;
  4724. var segmentEnd;
  4725. var segment;
  4726. var removalStart = null;
  4727. var removalEnd = null;
  4728. for (var jj = 0; jj < segments.length; jj++) {
  4729. segment = segments[jj];
  4730. segmentEnd = segmentStart + segment.length;
  4731. // Our selection overlaps this segment.
  4732. if (selectionStart < segmentEnd && segmentStart < selectionEnd) {
  4733. if (removalStart !== null) {
  4734. removalEnd = segmentEnd;
  4735. } else {
  4736. removalStart = segmentStart;
  4737. removalEnd = segmentEnd;
  4738. }
  4739. } else if (removalStart !== null) {
  4740. break;
  4741. }
  4742. segmentStart = segmentEnd;
  4743. }
  4744. var entityEnd = entityStart + text.length;
  4745. var atStart = removalStart === entityStart;
  4746. var atEnd = removalEnd === entityEnd;
  4747. if (!atStart && atEnd || atStart && !atEnd) {
  4748. if (direction === 'forward') {
  4749. if (removalEnd !== entityEnd) {
  4750. removalEnd++;
  4751. }
  4752. } else if (removalStart !== entityStart) {
  4753. removalStart--;
  4754. }
  4755. }
  4756. return {
  4757. start: removalStart,
  4758. end: removalEnd
  4759. };
  4760. }
  4761. };
  4762. var DraftEntitySegments_1 = DraftEntitySegments;
  4763. /**
  4764. * Copyright (c) 2013-present, Facebook, Inc.
  4765. *
  4766. * This source code is licensed under the MIT license found in the
  4767. * LICENSE file in the root directory of this source tree.
  4768. *
  4769. */
  4770. /**
  4771. * Use invariant() to assert state which your program assumes to be true.
  4772. *
  4773. * Provide sprintf-style format (only %s is supported) and arguments
  4774. * to provide information about what broke and what you were
  4775. * expecting.
  4776. *
  4777. * The invariant message will be stripped in production, but the invariant
  4778. * will remain to ensure logic does not differ in production.
  4779. */
  4780. var validateFormat = function validateFormat(format) {};
  4781. if (process.env.NODE_ENV !== 'production') {
  4782. validateFormat = function validateFormat(format) {
  4783. if (format === undefined) {
  4784. throw new Error('invariant requires an error message argument');
  4785. }
  4786. };
  4787. }
  4788. function invariant(condition, format, a, b, c, d, e, f) {
  4789. validateFormat(format);
  4790. if (!condition) {
  4791. var error;
  4792. if (format === undefined) {
  4793. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  4794. } else {
  4795. var args = [a, b, c, d, e, f];
  4796. var argIndex = 0;
  4797. error = new Error(format.replace(/%s/g, function () {
  4798. return args[argIndex++];
  4799. }));
  4800. error.name = 'Invariant Violation';
  4801. }
  4802. error.framesToPop = 1; // we don't care about invariant's own frame
  4803. throw error;
  4804. }
  4805. }
  4806. var invariant_1 = invariant;
  4807. /**
  4808. * Obtain the start and end positions of the range that has the
  4809. * specified entity applied to it.
  4810. *
  4811. * Entity keys are applied only to contiguous stretches of text, so this
  4812. * method searches for the first instance of the entity key and returns
  4813. * the subsequent range.
  4814. */
  4815. function getRangesForDraftEntity(block, key) {
  4816. var ranges = [];
  4817. block.findEntityRanges(function (c) {
  4818. return c.getEntity() === key;
  4819. }, function (start, end) {
  4820. ranges.push({ start: start, end: end });
  4821. });
  4822. !!!ranges.length ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Entity key not found in this range.') : invariant_1(false) : void 0;
  4823. return ranges;
  4824. }
  4825. var getRangesForDraftEntity_1 = getRangesForDraftEntity;
  4826. /**
  4827. * Given a SelectionState and a removal direction, determine the entire range
  4828. * that should be removed from a ContentState. This is based on any entities
  4829. * within the target, with their `mutability` values taken into account.
  4830. *
  4831. * For instance, if we are attempting to remove part of an "immutable" entity
  4832. * range, the entire entity must be removed. The returned `SelectionState`
  4833. * will be adjusted accordingly.
  4834. */
  4835. function getCharacterRemovalRange(entityMap, startBlock, endBlock, selectionState, direction) {
  4836. var start = selectionState.getStartOffset();
  4837. var end = selectionState.getEndOffset();
  4838. var startEntityKey = startBlock.getEntityAt(start);
  4839. var endEntityKey = endBlock.getEntityAt(end - 1);
  4840. if (!startEntityKey && !endEntityKey) {
  4841. return selectionState;
  4842. }
  4843. var newSelectionState = selectionState;
  4844. if (startEntityKey && startEntityKey === endEntityKey) {
  4845. newSelectionState = getEntityRemovalRange(entityMap, startBlock, newSelectionState, direction, startEntityKey, true, true);
  4846. } else if (startEntityKey && endEntityKey) {
  4847. var startSelectionState = getEntityRemovalRange(entityMap, startBlock, newSelectionState, direction, startEntityKey, false, true);
  4848. var endSelectionState = getEntityRemovalRange(entityMap, endBlock, newSelectionState, direction, endEntityKey, false, false);
  4849. newSelectionState = newSelectionState.merge({
  4850. anchorOffset: startSelectionState.getAnchorOffset(),
  4851. focusOffset: endSelectionState.getFocusOffset(),
  4852. isBackward: false
  4853. });
  4854. } else if (startEntityKey) {
  4855. var _startSelectionState = getEntityRemovalRange(entityMap, startBlock, newSelectionState, direction, startEntityKey, false, true);
  4856. newSelectionState = newSelectionState.merge({
  4857. anchorOffset: _startSelectionState.getStartOffset(),
  4858. isBackward: false
  4859. });
  4860. } else if (endEntityKey) {
  4861. var _endSelectionState = getEntityRemovalRange(entityMap, endBlock, newSelectionState, direction, endEntityKey, false, false);
  4862. newSelectionState = newSelectionState.merge({
  4863. focusOffset: _endSelectionState.getEndOffset(),
  4864. isBackward: false
  4865. });
  4866. }
  4867. return newSelectionState;
  4868. }
  4869. function getEntityRemovalRange(entityMap, block, selectionState, direction, entityKey, isEntireSelectionWithinEntity, isEntityAtStart) {
  4870. var start = selectionState.getStartOffset();
  4871. var end = selectionState.getEndOffset();
  4872. var entity = entityMap.__get(entityKey);
  4873. var mutability = entity.getMutability();
  4874. var sideToConsider = isEntityAtStart ? start : end;
  4875. // `MUTABLE` entities can just have the specified range of text removed
  4876. // directly. No adjustments are needed.
  4877. if (mutability === 'MUTABLE') {
  4878. return selectionState;
  4879. }
  4880. // Find the entity range that overlaps with our removal range.
  4881. var entityRanges = getRangesForDraftEntity_1(block, entityKey).filter(function (range) {
  4882. return sideToConsider <= range.end && sideToConsider >= range.start;
  4883. });
  4884. !(entityRanges.length == 1) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'There should only be one entity range within this removal range.') : invariant_1(false) : void 0;
  4885. var entityRange = entityRanges[0];
  4886. // For `IMMUTABLE` entity types, we will remove the entire entity range.
  4887. if (mutability === 'IMMUTABLE') {
  4888. return selectionState.merge({
  4889. anchorOffset: entityRange.start,
  4890. focusOffset: entityRange.end,
  4891. isBackward: false
  4892. });
  4893. }
  4894. // For `SEGMENTED` entity types, determine the appropriate segment to
  4895. // remove.
  4896. if (!isEntireSelectionWithinEntity) {
  4897. if (isEntityAtStart) {
  4898. end = entityRange.end;
  4899. } else {
  4900. start = entityRange.start;
  4901. }
  4902. }
  4903. var removalRange = DraftEntitySegments_1.getRemovalRange(start, end, block.getText().slice(entityRange.start, entityRange.end), entityRange.start, direction);
  4904. return selectionState.merge({
  4905. anchorOffset: removalRange.start,
  4906. focusOffset: removalRange.end,
  4907. isBackward: false
  4908. });
  4909. }
  4910. var getCharacterRemovalRange_1 = getCharacterRemovalRange;
  4911. /**
  4912. * Copyright (c) 2013-present, Facebook, Inc.
  4913. * All rights reserved.
  4914. *
  4915. * This source code is licensed under the BSD-style license found in the
  4916. * LICENSE file in the root directory of this source tree. An additional grant
  4917. * of patent rights can be found in the PATENTS file in the same directory.
  4918. *
  4919. * @providesModule generateRandomKey
  4920. * @format
  4921. *
  4922. */
  4923. var seenKeys = {};
  4924. var MULTIPLIER = Math.pow(2, 24);
  4925. function generateRandomKey() {
  4926. var key = void 0;
  4927. while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
  4928. key = Math.floor(Math.random() * MULTIPLIER).toString(32);
  4929. }
  4930. seenKeys[key] = true;
  4931. return key;
  4932. }
  4933. var generateRandomKey_1 = generateRandomKey;
  4934. var OrderedMap$1 = immutable.OrderedMap;
  4935. var randomizeContentBlockNodeKeys = function randomizeContentBlockNodeKeys(blockMap) {
  4936. var newKeysRef = {};
  4937. // we keep track of root blocks in order to update subsequent sibling links
  4938. var lastRootBlock = void 0;
  4939. return OrderedMap$1(blockMap.withMutations(function (blockMapState) {
  4940. blockMapState.forEach(function (block, index) {
  4941. var oldKey = block.getKey();
  4942. var nextKey = block.getNextSiblingKey();
  4943. var prevKey = block.getPrevSiblingKey();
  4944. var childrenKeys = block.getChildKeys();
  4945. var parentKey = block.getParentKey();
  4946. // new key that we will use to build linking
  4947. var key = generateRandomKey_1();
  4948. // we will add it here to re-use it later
  4949. newKeysRef[oldKey] = key;
  4950. if (nextKey) {
  4951. var nextBlock = blockMapState.get(nextKey);
  4952. if (nextBlock) {
  4953. blockMapState.setIn([nextKey, 'prevSibling'], key);
  4954. } else {
  4955. // this can happen when generating random keys for fragments
  4956. blockMapState.setIn([oldKey, 'nextSibling'], null);
  4957. }
  4958. }
  4959. if (prevKey) {
  4960. var prevBlock = blockMapState.get(prevKey);
  4961. if (prevBlock) {
  4962. blockMapState.setIn([prevKey, 'nextSibling'], key);
  4963. } else {
  4964. // this can happen when generating random keys for fragments
  4965. blockMapState.setIn([oldKey, 'prevSibling'], null);
  4966. }
  4967. }
  4968. if (parentKey && blockMapState.get(parentKey)) {
  4969. var parentBlock = blockMapState.get(parentKey);
  4970. var parentChildrenList = parentBlock.getChildKeys();
  4971. blockMapState.setIn([parentKey, 'children'], parentChildrenList.set(parentChildrenList.indexOf(block.getKey()), key));
  4972. } else {
  4973. // blocks will then be treated as root block nodes
  4974. blockMapState.setIn([oldKey, 'parent'], null);
  4975. if (lastRootBlock) {
  4976. blockMapState.setIn([lastRootBlock.getKey(), 'nextSibling'], key);
  4977. blockMapState.setIn([oldKey, 'prevSibling'], newKeysRef[lastRootBlock.getKey()]);
  4978. }
  4979. lastRootBlock = blockMapState.get(oldKey);
  4980. }
  4981. childrenKeys.forEach(function (childKey) {
  4982. var childBlock = blockMapState.get(childKey);
  4983. if (childBlock) {
  4984. blockMapState.setIn([childKey, 'parent'], key);
  4985. } else {
  4986. blockMapState.setIn([oldKey, 'children'], block.getChildKeys().filter(function (child) {
  4987. return child !== childKey;
  4988. }));
  4989. }
  4990. });
  4991. });
  4992. }).toArray().map(function (block) {
  4993. return [newKeysRef[block.getKey()], block.set('key', newKeysRef[block.getKey()])];
  4994. }));
  4995. };
  4996. var randomizeContentBlockKeys = function randomizeContentBlockKeys(blockMap) {
  4997. return OrderedMap$1(blockMap.toArray().map(function (block) {
  4998. var key = generateRandomKey_1();
  4999. return [key, block.set('key', key)];
  5000. }));
  5001. };
  5002. var randomizeBlockMapKeys = function randomizeBlockMapKeys(blockMap) {
  5003. var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode_1;
  5004. if (!isTreeBasedBlockMap) {
  5005. return randomizeContentBlockKeys(blockMap);
  5006. }
  5007. return randomizeContentBlockNodeKeys(blockMap);
  5008. };
  5009. var randomizeBlockMapKeys_1 = randomizeBlockMapKeys;
  5010. function removeEntitiesAtEdges(contentState, selectionState) {
  5011. var blockMap = contentState.getBlockMap();
  5012. var entityMap = contentState.getEntityMap();
  5013. var updatedBlocks = {};
  5014. var startKey = selectionState.getStartKey();
  5015. var startOffset = selectionState.getStartOffset();
  5016. var startBlock = blockMap.get(startKey);
  5017. var updatedStart = removeForBlock(entityMap, startBlock, startOffset);
  5018. if (updatedStart !== startBlock) {
  5019. updatedBlocks[startKey] = updatedStart;
  5020. }
  5021. var endKey = selectionState.getEndKey();
  5022. var endOffset = selectionState.getEndOffset();
  5023. var endBlock = blockMap.get(endKey);
  5024. if (startKey === endKey) {
  5025. endBlock = updatedStart;
  5026. }
  5027. var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
  5028. if (updatedEnd !== endBlock) {
  5029. updatedBlocks[endKey] = updatedEnd;
  5030. }
  5031. if (!Object.keys(updatedBlocks).length) {
  5032. return contentState.set('selectionAfter', selectionState);
  5033. }
  5034. return contentState.merge({
  5035. blockMap: blockMap.merge(updatedBlocks),
  5036. selectionAfter: selectionState
  5037. });
  5038. }
  5039. function getRemovalRange(characters, key, offset) {
  5040. var removalRange;
  5041. findRangesImmutable_1(characters, function (a, b) {
  5042. return a.getEntity() === b.getEntity();
  5043. }, function (element) {
  5044. return element.getEntity() === key;
  5045. }, function (start, end) {
  5046. if (start <= offset && end >= offset) {
  5047. removalRange = { start: start, end: end };
  5048. }
  5049. });
  5050. !(typeof removalRange === 'object') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Removal range must exist within character list.') : invariant_1(false) : void 0;
  5051. return removalRange;
  5052. }
  5053. function removeForBlock(entityMap, block, offset) {
  5054. var chars = block.getCharacterList();
  5055. var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
  5056. var charAfter = offset < chars.count() ? chars.get(offset) : undefined;
  5057. var entityBeforeCursor = charBefore ? charBefore.getEntity() : undefined;
  5058. var entityAfterCursor = charAfter ? charAfter.getEntity() : undefined;
  5059. if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
  5060. var entity = entityMap.__get(entityAfterCursor);
  5061. if (entity.getMutability() !== 'MUTABLE') {
  5062. var _getRemovalRange = getRemovalRange(chars, entityAfterCursor, offset),
  5063. start = _getRemovalRange.start,
  5064. end = _getRemovalRange.end;
  5065. var current;
  5066. while (start < end) {
  5067. current = chars.get(start);
  5068. chars = chars.set(start, CharacterMetadata_1.applyEntity(current, null));
  5069. start++;
  5070. }
  5071. return block.set('characterList', chars);
  5072. }
  5073. }
  5074. return block;
  5075. }
  5076. var removeEntitiesAtEdges_1 = removeEntitiesAtEdges;
  5077. var getContentStateFragment = function getContentStateFragment(contentState, selectionState) {
  5078. var startKey = selectionState.getStartKey();
  5079. var startOffset = selectionState.getStartOffset();
  5080. var endKey = selectionState.getEndKey();
  5081. var endOffset = selectionState.getEndOffset();
  5082. // Edge entities should be stripped to ensure that we don't preserve
  5083. // invalid partial entities when the fragment is reused. We do, however,
  5084. // preserve entities that are entirely within the selection range.
  5085. var contentWithoutEdgeEntities = removeEntitiesAtEdges_1(contentState, selectionState);
  5086. var blockMap = contentWithoutEdgeEntities.getBlockMap();
  5087. var blockKeys = blockMap.keySeq();
  5088. var startIndex = blockKeys.indexOf(startKey);
  5089. var endIndex = blockKeys.indexOf(endKey) + 1;
  5090. return randomizeBlockMapKeys_1(blockMap.slice(startIndex, endIndex).map(function (block, blockKey) {
  5091. var text = block.getText();
  5092. var chars = block.getCharacterList();
  5093. if (startKey === endKey) {
  5094. return block.merge({
  5095. text: text.slice(startOffset, endOffset),
  5096. characterList: chars.slice(startOffset, endOffset)
  5097. });
  5098. }
  5099. if (blockKey === startKey) {
  5100. return block.merge({
  5101. text: text.slice(startOffset),
  5102. characterList: chars.slice(startOffset)
  5103. });
  5104. }
  5105. if (blockKey === endKey) {
  5106. return block.merge({
  5107. text: text.slice(0, endOffset),
  5108. characterList: chars.slice(0, endOffset)
  5109. });
  5110. }
  5111. return block;
  5112. }));
  5113. };
  5114. var getContentStateFragment_1 = getContentStateFragment;
  5115. /**
  5116. * Copyright (c) 2013-present, Facebook, Inc.
  5117. * All rights reserved.
  5118. *
  5119. * This source code is licensed under the BSD-style license found in the
  5120. * LICENSE file in the root directory of this source tree. An additional grant
  5121. * of patent rights can be found in the PATENTS file in the same directory.
  5122. *
  5123. * @providesModule insertIntoList
  5124. * @format
  5125. *
  5126. */
  5127. /**
  5128. * Maintain persistence for target list when appending and prepending.
  5129. */
  5130. function insertIntoList(targetList, toInsert, offset) {
  5131. if (offset === targetList.count()) {
  5132. toInsert.forEach(function (c) {
  5133. targetList = targetList.push(c);
  5134. });
  5135. } else if (offset === 0) {
  5136. toInsert.reverse().forEach(function (c) {
  5137. targetList = targetList.unshift(c);
  5138. });
  5139. } else {
  5140. var head = targetList.slice(0, offset);
  5141. var tail = targetList.slice(offset);
  5142. targetList = head.concat(toInsert, tail).toList();
  5143. }
  5144. return targetList;
  5145. }
  5146. var insertIntoList_1 = insertIntoList;
  5147. var List$2 = immutable.List;
  5148. var updateExistingBlock = function updateExistingBlock(contentState, selectionState, blockMap, fragmentBlock, targetKey, targetOffset) {
  5149. var targetBlock = blockMap.get(targetKey);
  5150. var text = targetBlock.getText();
  5151. var chars = targetBlock.getCharacterList();
  5152. var finalKey = targetKey;
  5153. var finalOffset = targetOffset + fragmentBlock.getText().length;
  5154. var newBlock = targetBlock.merge({
  5155. text: text.slice(0, targetOffset) + fragmentBlock.getText() + text.slice(targetOffset),
  5156. characterList: insertIntoList_1(chars, fragmentBlock.getCharacterList(), targetOffset),
  5157. data: fragmentBlock.getData()
  5158. });
  5159. return contentState.merge({
  5160. blockMap: blockMap.set(targetKey, newBlock),
  5161. selectionBefore: selectionState,
  5162. selectionAfter: selectionState.merge({
  5163. anchorKey: finalKey,
  5164. anchorOffset: finalOffset,
  5165. focusKey: finalKey,
  5166. focusOffset: finalOffset,
  5167. isBackward: false
  5168. })
  5169. });
  5170. };
  5171. /**
  5172. * Appends text/characterList from the fragment first block to
  5173. * target block.
  5174. */
  5175. var updateHead = function updateHead(block, targetOffset, fragment) {
  5176. var text = block.getText();
  5177. var chars = block.getCharacterList();
  5178. // Modify head portion of block.
  5179. var headText = text.slice(0, targetOffset);
  5180. var headCharacters = chars.slice(0, targetOffset);
  5181. var appendToHead = fragment.first();
  5182. return block.merge({
  5183. text: headText + appendToHead.getText(),
  5184. characterList: headCharacters.concat(appendToHead.getCharacterList()),
  5185. type: headText ? block.getType() : appendToHead.getType(),
  5186. data: appendToHead.getData()
  5187. });
  5188. };
  5189. /**
  5190. * Appends offset text/characterList from the target block to the last
  5191. * fragment block.
  5192. */
  5193. var updateTail = function updateTail(block, targetOffset, fragment) {
  5194. // Modify tail portion of block.
  5195. var text = block.getText();
  5196. var chars = block.getCharacterList();
  5197. // Modify head portion of block.
  5198. var blockSize = text.length;
  5199. var tailText = text.slice(targetOffset, blockSize);
  5200. var tailCharacters = chars.slice(targetOffset, blockSize);
  5201. var prependToTail = fragment.last();
  5202. return prependToTail.merge({
  5203. text: prependToTail.getText() + tailText,
  5204. characterList: prependToTail.getCharacterList().concat(tailCharacters),
  5205. data: prependToTail.getData()
  5206. });
  5207. };
  5208. var getRootBlocks = function getRootBlocks(block, blockMap) {
  5209. var headKey = block.getKey();
  5210. var rootBlock = block;
  5211. var rootBlocks = [];
  5212. // sometimes the fragment head block will not be part of the blockMap itself this can happen when
  5213. // the fragment head is used to update the target block, however when this does not happen we need
  5214. // to make sure that we include it on the rootBlocks since the first block of a fragment is always a
  5215. // fragment root block
  5216. if (blockMap.get(headKey)) {
  5217. rootBlocks.push(headKey);
  5218. }
  5219. while (rootBlock && rootBlock.getNextSiblingKey()) {
  5220. var lastSiblingKey = rootBlock.getNextSiblingKey();
  5221. if (!lastSiblingKey) {
  5222. break;
  5223. }
  5224. rootBlocks.push(lastSiblingKey);
  5225. rootBlock = blockMap.get(lastSiblingKey);
  5226. }
  5227. return rootBlocks;
  5228. };
  5229. var updateBlockMapLinks = function updateBlockMapLinks(blockMap, originalBlockMap, targetBlock, fragmentHeadBlock) {
  5230. return blockMap.withMutations(function (blockMapState) {
  5231. var targetKey = targetBlock.getKey();
  5232. var headKey = fragmentHeadBlock.getKey();
  5233. var targetNextKey = targetBlock.getNextSiblingKey();
  5234. var targetParentKey = targetBlock.getParentKey();
  5235. var fragmentRootBlocks = getRootBlocks(fragmentHeadBlock, blockMap);
  5236. var lastRootFragmentBlockKey = fragmentRootBlocks[fragmentRootBlocks.length - 1];
  5237. if (blockMapState.get(headKey)) {
  5238. // update the fragment head when it is part of the blockMap otherwise
  5239. blockMapState.setIn([targetKey, 'nextSibling'], headKey);
  5240. blockMapState.setIn([headKey, 'prevSibling'], targetKey);
  5241. } else {
  5242. // update the target block that had the fragment head contents merged into it
  5243. blockMapState.setIn([targetKey, 'nextSibling'], fragmentHeadBlock.getNextSiblingKey());
  5244. blockMapState.setIn([fragmentHeadBlock.getNextSiblingKey(), 'prevSibling'], targetKey);
  5245. }
  5246. // update the last root block fragment
  5247. blockMapState.setIn([lastRootFragmentBlockKey, 'nextSibling'], targetNextKey);
  5248. // update the original target next block
  5249. if (targetNextKey) {
  5250. blockMapState.setIn([targetNextKey, 'prevSibling'], lastRootFragmentBlockKey);
  5251. }
  5252. // update fragment parent links
  5253. fragmentRootBlocks.forEach(function (blockKey) {
  5254. return blockMapState.setIn([blockKey, 'parent'], targetParentKey);
  5255. });
  5256. // update targetBlock parent child links
  5257. if (targetParentKey) {
  5258. var targetParent = blockMap.get(targetParentKey);
  5259. var originalTargetParentChildKeys = targetParent.getChildKeys();
  5260. var targetBlockIndex = originalTargetParentChildKeys.indexOf(targetKey);
  5261. var insertionIndex = targetBlockIndex + 1;
  5262. var newChildrenKeysArray = originalTargetParentChildKeys.toArray();
  5263. // insert fragment children
  5264. newChildrenKeysArray.splice.apply(newChildrenKeysArray, [insertionIndex, 0].concat(fragmentRootBlocks));
  5265. blockMapState.setIn([targetParentKey, 'children'], List$2(newChildrenKeysArray));
  5266. }
  5267. });
  5268. };
  5269. var insertFragment = function insertFragment(contentState, selectionState, blockMap, fragment, targetKey, targetOffset) {
  5270. var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode_1;
  5271. var newBlockArr = [];
  5272. var fragmentSize = fragment.size;
  5273. var target = blockMap.get(targetKey);
  5274. var head = fragment.first();
  5275. var tail = fragment.last();
  5276. var finalOffset = tail.getLength();
  5277. var finalKey = tail.getKey();
  5278. var shouldNotUpdateFromFragmentBlock = isTreeBasedBlockMap && (!target.getChildKeys().isEmpty() || !head.getChildKeys().isEmpty());
  5279. blockMap.forEach(function (block, blockKey) {
  5280. if (blockKey !== targetKey) {
  5281. newBlockArr.push(block);
  5282. return;
  5283. }
  5284. if (shouldNotUpdateFromFragmentBlock) {
  5285. newBlockArr.push(block);
  5286. } else {
  5287. newBlockArr.push(updateHead(block, targetOffset, fragment));
  5288. }
  5289. // Insert fragment blocks after the head and before the tail.
  5290. fragment
  5291. // when we are updating the target block with the head fragment block we skip the first fragment
  5292. // head since its contents have already been merged with the target block otherwise we include
  5293. // the whole fragment
  5294. .slice(shouldNotUpdateFromFragmentBlock ? 0 : 1, fragmentSize - 1).forEach(function (fragmentBlock) {
  5295. return newBlockArr.push(fragmentBlock);
  5296. });
  5297. // update tail
  5298. newBlockArr.push(updateTail(block, targetOffset, fragment));
  5299. });
  5300. var updatedBlockMap = BlockMapBuilder_1.createFromArray(newBlockArr);
  5301. if (isTreeBasedBlockMap) {
  5302. updatedBlockMap = updateBlockMapLinks(updatedBlockMap, blockMap, target, head);
  5303. }
  5304. return contentState.merge({
  5305. blockMap: updatedBlockMap,
  5306. selectionBefore: selectionState,
  5307. selectionAfter: selectionState.merge({
  5308. anchorKey: finalKey,
  5309. anchorOffset: finalOffset,
  5310. focusKey: finalKey,
  5311. focusOffset: finalOffset,
  5312. isBackward: false
  5313. })
  5314. });
  5315. };
  5316. var insertFragmentIntoContentState = function insertFragmentIntoContentState(contentState, selectionState, fragmentBlockMap) {
  5317. !selectionState.isCollapsed() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`insertFragment` should only be called with a collapsed selection state.') : invariant_1(false) : void 0;
  5318. var blockMap = contentState.getBlockMap();
  5319. var fragment = randomizeBlockMapKeys_1(fragmentBlockMap);
  5320. var targetKey = selectionState.getStartKey();
  5321. var targetOffset = selectionState.getStartOffset();
  5322. var targetBlock = blockMap.get(targetKey);
  5323. if (targetBlock instanceof ContentBlockNode_1) {
  5324. !targetBlock.getChildKeys().isEmpty() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`insertFragment` should not be called when a container node is selected.') : invariant_1(false) : void 0;
  5325. }
  5326. // When we insert a fragment with a single block we simply update the target block
  5327. // with the contents of the inserted fragment block
  5328. if (fragment.size === 1) {
  5329. return updateExistingBlock(contentState, selectionState, blockMap, fragment.first(), targetKey, targetOffset);
  5330. }
  5331. return insertFragment(contentState, selectionState, blockMap, fragment, targetKey, targetOffset);
  5332. };
  5333. var insertFragmentIntoContentState_1 = insertFragmentIntoContentState;
  5334. var Repeat$2 = immutable.Repeat;
  5335. function insertTextIntoContentState(contentState, selectionState, text, characterMetadata) {
  5336. !selectionState.isCollapsed() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`insertText` should only be called with a collapsed range.') : invariant_1(false) : void 0;
  5337. var len = text.length;
  5338. if (!len) {
  5339. return contentState;
  5340. }
  5341. var blockMap = contentState.getBlockMap();
  5342. var key = selectionState.getStartKey();
  5343. var offset = selectionState.getStartOffset();
  5344. var block = blockMap.get(key);
  5345. var blockText = block.getText();
  5346. var newBlock = block.merge({
  5347. text: blockText.slice(0, offset) + text + blockText.slice(offset, block.getLength()),
  5348. characterList: insertIntoList_1(block.getCharacterList(), Repeat$2(characterMetadata, len).toList(), offset)
  5349. });
  5350. var newOffset = offset + len;
  5351. return contentState.merge({
  5352. blockMap: blockMap.set(key, newBlock),
  5353. selectionAfter: selectionState.merge({
  5354. anchorOffset: newOffset,
  5355. focusOffset: newOffset
  5356. })
  5357. });
  5358. }
  5359. var insertTextIntoContentState_1 = insertTextIntoContentState;
  5360. var Map$4 = immutable.Map;
  5361. function modifyBlockForContentState(contentState, selectionState, operation) {
  5362. var startKey = selectionState.getStartKey();
  5363. var endKey = selectionState.getEndKey();
  5364. var blockMap = contentState.getBlockMap();
  5365. var newBlocks = blockMap.toSeq().skipUntil(function (_, k) {
  5366. return k === startKey;
  5367. }).takeUntil(function (_, k) {
  5368. return k === endKey;
  5369. }).concat(Map$4([[endKey, blockMap.get(endKey)]])).map(operation);
  5370. return contentState.merge({
  5371. blockMap: blockMap.merge(newBlocks),
  5372. selectionBefore: selectionState,
  5373. selectionAfter: selectionState
  5374. });
  5375. }
  5376. var modifyBlockForContentState_1 = modifyBlockForContentState;
  5377. /**
  5378. * Copyright (c) 2013-present, Facebook, Inc.
  5379. * All rights reserved.
  5380. *
  5381. * This source code is licensed under the BSD-style license found in the
  5382. * LICENSE file in the root directory of this source tree. An additional grant
  5383. * of patent rights can be found in the PATENTS file in the same directory.
  5384. *
  5385. * @providesModule getNextDelimiterBlockKey
  5386. * @format
  5387. *
  5388. *
  5389. * This is unstable and not part of the public API and should not be used by
  5390. * production systems. This file may be update/removed without notice.
  5391. */
  5392. var getNextDelimiterBlockKey = function getNextDelimiterBlockKey(block, blockMap) {
  5393. var isExperimentalTreeBlock = block instanceof ContentBlockNode_1;
  5394. if (!isExperimentalTreeBlock) {
  5395. return null;
  5396. }
  5397. var nextSiblingKey = block.getNextSiblingKey();
  5398. if (nextSiblingKey) {
  5399. return nextSiblingKey;
  5400. }
  5401. var parent = block.getParentKey();
  5402. if (!parent) {
  5403. return null;
  5404. }
  5405. var nextNonDescendantBlock = blockMap.get(parent);
  5406. while (nextNonDescendantBlock && !nextNonDescendantBlock.getNextSiblingKey()) {
  5407. var parentKey = nextNonDescendantBlock.getParentKey();
  5408. nextNonDescendantBlock = parentKey ? blockMap.get(parentKey) : null;
  5409. }
  5410. if (!nextNonDescendantBlock) {
  5411. return null;
  5412. }
  5413. return nextNonDescendantBlock.getNextSiblingKey();
  5414. };
  5415. var getNextDelimiterBlockKey_1 = getNextDelimiterBlockKey;
  5416. var List$3 = immutable.List,
  5417. Map$5 = immutable.Map;
  5418. var transformBlock = function transformBlock(key, blockMap, func) {
  5419. if (!key) {
  5420. return;
  5421. }
  5422. var block = blockMap.get(key);
  5423. if (!block) {
  5424. return;
  5425. }
  5426. blockMap.set(key, func(block));
  5427. };
  5428. /**
  5429. * Ancestors needs to be preserved when there are non selected
  5430. * children to make sure we do not leave any orphans behind
  5431. */
  5432. var getAncestorsKeys = function getAncestorsKeys(blockKey, blockMap) {
  5433. var parents = [];
  5434. if (!blockKey) {
  5435. return parents;
  5436. }
  5437. var blockNode = blockMap.get(blockKey);
  5438. while (blockNode && blockNode.getParentKey()) {
  5439. var parentKey = blockNode.getParentKey();
  5440. if (parentKey) {
  5441. parents.push(parentKey);
  5442. }
  5443. blockNode = parentKey ? blockMap.get(parentKey) : null;
  5444. }
  5445. return parents;
  5446. };
  5447. /**
  5448. * Get all next delimiter keys until we hit a root delimiter and return
  5449. * an array of key references
  5450. */
  5451. var getNextDelimitersBlockKeys = function getNextDelimitersBlockKeys(block, blockMap) {
  5452. var nextDelimiters = [];
  5453. if (!block) {
  5454. return nextDelimiters;
  5455. }
  5456. var nextDelimiter = getNextDelimiterBlockKey_1(block, blockMap);
  5457. while (nextDelimiter && blockMap.get(nextDelimiter)) {
  5458. var _block = blockMap.get(nextDelimiter);
  5459. nextDelimiters.push(nextDelimiter);
  5460. // we do not need to keep checking all root node siblings, just the first occurance
  5461. nextDelimiter = _block.getParentKey() ? getNextDelimiterBlockKey_1(_block, blockMap) : null;
  5462. }
  5463. return nextDelimiters;
  5464. };
  5465. var getNextValidSibling = function getNextValidSibling(block, blockMap, originalBlockMap) {
  5466. if (!block) {
  5467. return null;
  5468. }
  5469. // note that we need to make sure we refer to the original block since this
  5470. // function is called within a withMutations
  5471. var nextValidSiblingKey = originalBlockMap.get(block.getKey()).getNextSiblingKey();
  5472. while (nextValidSiblingKey && !blockMap.get(nextValidSiblingKey)) {
  5473. nextValidSiblingKey = originalBlockMap.get(nextValidSiblingKey).getNextSiblingKey() || null;
  5474. }
  5475. return nextValidSiblingKey;
  5476. };
  5477. var getPrevValidSibling = function getPrevValidSibling(block, blockMap, originalBlockMap) {
  5478. if (!block) {
  5479. return null;
  5480. }
  5481. // note that we need to make sure we refer to the original block since this
  5482. // function is called within a withMutations
  5483. var prevValidSiblingKey = originalBlockMap.get(block.getKey()).getPrevSiblingKey();
  5484. while (prevValidSiblingKey && !blockMap.get(prevValidSiblingKey)) {
  5485. prevValidSiblingKey = originalBlockMap.get(prevValidSiblingKey).getPrevSiblingKey() || null;
  5486. }
  5487. return prevValidSiblingKey;
  5488. };
  5489. var updateBlockMapLinks$1 = function updateBlockMapLinks(blockMap, startBlock, endBlock, originalBlockMap) {
  5490. return blockMap.withMutations(function (blocks) {
  5491. // update start block if its retained
  5492. transformBlock(startBlock.getKey(), blocks, function (block) {
  5493. return block.merge({
  5494. nextSibling: getNextValidSibling(startBlock, blocks, originalBlockMap),
  5495. prevSibling: getPrevValidSibling(startBlock, blocks, originalBlockMap)
  5496. });
  5497. });
  5498. // update endblock if its retained
  5499. transformBlock(endBlock.getKey(), blocks, function (block) {
  5500. return block.merge({
  5501. nextSibling: getNextValidSibling(endBlock, blocks, originalBlockMap),
  5502. prevSibling: getPrevValidSibling(endBlock, blocks, originalBlockMap)
  5503. });
  5504. });
  5505. // update start block parent ancestors
  5506. getAncestorsKeys(startBlock.getKey(), originalBlockMap).forEach(function (parentKey) {
  5507. return transformBlock(parentKey, blocks, function (block) {
  5508. return block.merge({
  5509. children: block.getChildKeys().filter(function (key) {
  5510. return blocks.get(key);
  5511. }),
  5512. nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
  5513. prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
  5514. });
  5515. });
  5516. });
  5517. // update start block next - can only happen if startBlock == endBlock
  5518. transformBlock(startBlock.getNextSiblingKey(), blocks, function (block) {
  5519. return block.merge({
  5520. prevSibling: startBlock.getPrevSiblingKey()
  5521. });
  5522. });
  5523. // update start block prev
  5524. transformBlock(startBlock.getPrevSiblingKey(), blocks, function (block) {
  5525. return block.merge({
  5526. nextSibling: getNextValidSibling(startBlock, blocks, originalBlockMap)
  5527. });
  5528. });
  5529. // update end block next
  5530. transformBlock(endBlock.getNextSiblingKey(), blocks, function (block) {
  5531. return block.merge({
  5532. prevSibling: getPrevValidSibling(endBlock, blocks, originalBlockMap)
  5533. });
  5534. });
  5535. // update end block prev
  5536. transformBlock(endBlock.getPrevSiblingKey(), blocks, function (block) {
  5537. return block.merge({
  5538. nextSibling: endBlock.getNextSiblingKey()
  5539. });
  5540. });
  5541. // update end block parent ancestors
  5542. getAncestorsKeys(endBlock.getKey(), originalBlockMap).forEach(function (parentKey) {
  5543. transformBlock(parentKey, blocks, function (block) {
  5544. return block.merge({
  5545. children: block.getChildKeys().filter(function (key) {
  5546. return blocks.get(key);
  5547. }),
  5548. nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
  5549. prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
  5550. });
  5551. });
  5552. });
  5553. // update next delimiters all the way to a root delimiter
  5554. getNextDelimitersBlockKeys(endBlock, originalBlockMap).forEach(function (delimiterKey) {
  5555. return transformBlock(delimiterKey, blocks, function (block) {
  5556. return block.merge({
  5557. nextSibling: getNextValidSibling(block, blocks, originalBlockMap),
  5558. prevSibling: getPrevValidSibling(block, blocks, originalBlockMap)
  5559. });
  5560. });
  5561. });
  5562. });
  5563. };
  5564. var removeRangeFromContentState = function removeRangeFromContentState(contentState, selectionState) {
  5565. if (selectionState.isCollapsed()) {
  5566. return contentState;
  5567. }
  5568. var blockMap = contentState.getBlockMap();
  5569. var startKey = selectionState.getStartKey();
  5570. var startOffset = selectionState.getStartOffset();
  5571. var endKey = selectionState.getEndKey();
  5572. var endOffset = selectionState.getEndOffset();
  5573. var startBlock = blockMap.get(startKey);
  5574. var endBlock = blockMap.get(endKey);
  5575. // we assume that ContentBlockNode and ContentBlocks are not mixed together
  5576. var isExperimentalTreeBlock = startBlock instanceof ContentBlockNode_1;
  5577. // used to retain blocks that should not be deleted to avoid orphan children
  5578. var parentAncestors = [];
  5579. if (isExperimentalTreeBlock) {
  5580. var endBlockchildrenKeys = endBlock.getChildKeys();
  5581. var endBlockAncestors = getAncestorsKeys(endKey, blockMap);
  5582. // endBlock has unselected sibblings so we can not remove its ancestors parents
  5583. if (endBlock.getNextSiblingKey()) {
  5584. parentAncestors = parentAncestors.concat(endBlockAncestors);
  5585. }
  5586. // endBlock has children so can not remove this block or any of its ancestors
  5587. if (!endBlockchildrenKeys.isEmpty()) {
  5588. parentAncestors = parentAncestors.concat(endBlockAncestors.concat([endKey]));
  5589. }
  5590. // we need to retain all ancestors of the next delimiter block
  5591. parentAncestors = parentAncestors.concat(getAncestorsKeys(getNextDelimiterBlockKey_1(endBlock, blockMap), blockMap));
  5592. }
  5593. var characterList = void 0;
  5594. if (startBlock === endBlock) {
  5595. characterList = removeFromList(startBlock.getCharacterList(), startOffset, endOffset);
  5596. } else {
  5597. characterList = startBlock.getCharacterList().slice(0, startOffset).concat(endBlock.getCharacterList().slice(endOffset));
  5598. }
  5599. var modifiedStart = startBlock.merge({
  5600. text: startBlock.getText().slice(0, startOffset) + endBlock.getText().slice(endOffset),
  5601. characterList: characterList
  5602. });
  5603. var newBlocks = blockMap.toSeq().skipUntil(function (_, k) {
  5604. return k === startKey;
  5605. }).takeUntil(function (_, k) {
  5606. return k === endKey;
  5607. }).filter(function (_, k) {
  5608. return parentAncestors.indexOf(k) === -1;
  5609. }).concat(Map$5([[endKey, null]])).map(function (_, k) {
  5610. return k === startKey ? modifiedStart : null;
  5611. });
  5612. var updatedBlockMap = blockMap.merge(newBlocks).filter(function (block) {
  5613. return !!block;
  5614. });
  5615. if (isExperimentalTreeBlock) {
  5616. updatedBlockMap = updateBlockMapLinks$1(updatedBlockMap, startBlock, endBlock, blockMap);
  5617. }
  5618. return contentState.merge({
  5619. blockMap: updatedBlockMap,
  5620. selectionBefore: selectionState,
  5621. selectionAfter: selectionState.merge({
  5622. anchorKey: startKey,
  5623. anchorOffset: startOffset,
  5624. focusKey: startKey,
  5625. focusOffset: startOffset,
  5626. isBackward: false
  5627. })
  5628. });
  5629. };
  5630. /**
  5631. * Maintain persistence for target list when removing characters on the
  5632. * head and tail of the character list.
  5633. */
  5634. var removeFromList = function removeFromList(targetList, startOffset, endOffset) {
  5635. if (startOffset === 0) {
  5636. while (startOffset < endOffset) {
  5637. targetList = targetList.shift();
  5638. startOffset++;
  5639. }
  5640. } else if (endOffset === targetList.count()) {
  5641. while (endOffset > startOffset) {
  5642. targetList = targetList.pop();
  5643. endOffset--;
  5644. }
  5645. } else {
  5646. var head = targetList.slice(0, startOffset);
  5647. var tail = targetList.slice(endOffset);
  5648. targetList = head.concat(tail).toList();
  5649. }
  5650. return targetList;
  5651. };
  5652. var removeRangeFromContentState_1 = removeRangeFromContentState;
  5653. var List$4 = immutable.List,
  5654. Map$6 = immutable.Map;
  5655. var transformBlock$1 = function transformBlock(key, blockMap, func) {
  5656. if (!key) {
  5657. return;
  5658. }
  5659. var block = blockMap.get(key);
  5660. if (!block) {
  5661. return;
  5662. }
  5663. blockMap.set(key, func(block));
  5664. };
  5665. var updateBlockMapLinks$2 = function updateBlockMapLinks(blockMap, originalBlock, belowBlock) {
  5666. return blockMap.withMutations(function (blocks) {
  5667. var originalBlockKey = originalBlock.getKey();
  5668. var belowBlockKey = belowBlock.getKey();
  5669. // update block parent
  5670. transformBlock$1(originalBlock.getParentKey(), blocks, function (block) {
  5671. var parentChildrenList = block.getChildKeys();
  5672. var insertionIndex = parentChildrenList.indexOf(originalBlockKey) + 1;
  5673. var newChildrenArray = parentChildrenList.toArray();
  5674. newChildrenArray.splice(insertionIndex, 0, belowBlockKey);
  5675. return block.merge({
  5676. children: List$4(newChildrenArray)
  5677. });
  5678. });
  5679. // update original next block
  5680. transformBlock$1(originalBlock.getNextSiblingKey(), blocks, function (block) {
  5681. return block.merge({
  5682. prevSibling: belowBlockKey
  5683. });
  5684. });
  5685. // update original block
  5686. transformBlock$1(originalBlockKey, blocks, function (block) {
  5687. return block.merge({
  5688. nextSibling: belowBlockKey
  5689. });
  5690. });
  5691. // update below block
  5692. transformBlock$1(belowBlockKey, blocks, function (block) {
  5693. return block.merge({
  5694. prevSibling: originalBlockKey
  5695. });
  5696. });
  5697. });
  5698. };
  5699. var splitBlockInContentState = function splitBlockInContentState(contentState, selectionState) {
  5700. !selectionState.isCollapsed() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Selection range must be collapsed.') : invariant_1(false) : void 0;
  5701. var key = selectionState.getAnchorKey();
  5702. var offset = selectionState.getAnchorOffset();
  5703. var blockMap = contentState.getBlockMap();
  5704. var blockToSplit = blockMap.get(key);
  5705. var text = blockToSplit.getText();
  5706. var chars = blockToSplit.getCharacterList();
  5707. var keyBelow = generateRandomKey_1();
  5708. var isExperimentalTreeBlock = blockToSplit instanceof ContentBlockNode_1;
  5709. var blockAbove = blockToSplit.merge({
  5710. text: text.slice(0, offset),
  5711. characterList: chars.slice(0, offset)
  5712. });
  5713. var blockBelow = blockAbove.merge({
  5714. key: keyBelow,
  5715. text: text.slice(offset),
  5716. characterList: chars.slice(offset),
  5717. data: Map$6()
  5718. });
  5719. var blocksBefore = blockMap.toSeq().takeUntil(function (v) {
  5720. return v === blockToSplit;
  5721. });
  5722. var blocksAfter = blockMap.toSeq().skipUntil(function (v) {
  5723. return v === blockToSplit;
  5724. }).rest();
  5725. var newBlocks = blocksBefore.concat([[key, blockAbove], [keyBelow, blockBelow]], blocksAfter).toOrderedMap();
  5726. if (isExperimentalTreeBlock) {
  5727. !blockToSplit.getChildKeys().isEmpty() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'ContentBlockNode must not have children') : invariant_1(false) : void 0;
  5728. newBlocks = updateBlockMapLinks$2(newBlocks, blockAbove, blockBelow);
  5729. }
  5730. return contentState.merge({
  5731. blockMap: newBlocks,
  5732. selectionBefore: selectionState,
  5733. selectionAfter: selectionState.merge({
  5734. anchorKey: keyBelow,
  5735. anchorOffset: 0,
  5736. focusKey: keyBelow,
  5737. focusOffset: 0,
  5738. isBackward: false
  5739. })
  5740. });
  5741. };
  5742. var splitBlockInContentState_1 = splitBlockInContentState;
  5743. var OrderedSet$3 = immutable.OrderedSet;
  5744. /**
  5745. * `DraftModifier` provides a set of convenience methods that apply
  5746. * modifications to a `ContentState` object based on a target `SelectionState`.
  5747. *
  5748. * Any change to a `ContentState` should be decomposable into a series of
  5749. * transaction functions that apply the required changes and return output
  5750. * `ContentState` objects.
  5751. *
  5752. * These functions encapsulate some of the most common transaction sequences.
  5753. */
  5754. var DraftModifier = {
  5755. replaceText: function replaceText(contentState, rangeToReplace, text, inlineStyle, entityKey) {
  5756. var withoutEntities = removeEntitiesAtEdges_1(contentState, rangeToReplace);
  5757. var withoutText = removeRangeFromContentState_1(withoutEntities, rangeToReplace);
  5758. var character = CharacterMetadata_1.create({
  5759. style: inlineStyle || OrderedSet$3(),
  5760. entity: entityKey || null
  5761. });
  5762. return insertTextIntoContentState_1(withoutText, withoutText.getSelectionAfter(), text, character);
  5763. },
  5764. insertText: function insertText(contentState, targetRange, text, inlineStyle, entityKey) {
  5765. !targetRange.isCollapsed() ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Target range must be collapsed for `insertText`.') : invariant_1(false) : void 0;
  5766. return DraftModifier.replaceText(contentState, targetRange, text, inlineStyle, entityKey);
  5767. },
  5768. moveText: function moveText(contentState, removalRange, targetRange) {
  5769. var movedFragment = getContentStateFragment_1(contentState, removalRange);
  5770. var afterRemoval = DraftModifier.removeRange(contentState, removalRange, 'backward');
  5771. return DraftModifier.replaceWithFragment(afterRemoval, targetRange, movedFragment);
  5772. },
  5773. replaceWithFragment: function replaceWithFragment(contentState, targetRange, fragment) {
  5774. var withoutEntities = removeEntitiesAtEdges_1(contentState, targetRange);
  5775. var withoutText = removeRangeFromContentState_1(withoutEntities, targetRange);
  5776. return insertFragmentIntoContentState_1(withoutText, withoutText.getSelectionAfter(), fragment);
  5777. },
  5778. removeRange: function removeRange(contentState, rangeToRemove, removalDirection) {
  5779. var startKey = void 0,
  5780. endKey = void 0,
  5781. startBlock = void 0,
  5782. endBlock = void 0;
  5783. if (rangeToRemove.getIsBackward()) {
  5784. rangeToRemove = rangeToRemove.merge({
  5785. anchorKey: rangeToRemove.getFocusKey(),
  5786. anchorOffset: rangeToRemove.getFocusOffset(),
  5787. focusKey: rangeToRemove.getAnchorKey(),
  5788. focusOffset: rangeToRemove.getAnchorOffset(),
  5789. isBackward: false
  5790. });
  5791. }
  5792. startKey = rangeToRemove.getAnchorKey();
  5793. endKey = rangeToRemove.getFocusKey();
  5794. startBlock = contentState.getBlockForKey(startKey);
  5795. endBlock = contentState.getBlockForKey(endKey);
  5796. var startOffset = rangeToRemove.getStartOffset();
  5797. var endOffset = rangeToRemove.getEndOffset();
  5798. var startEntityKey = startBlock.getEntityAt(startOffset);
  5799. var endEntityKey = endBlock.getEntityAt(endOffset - 1);
  5800. // Check whether the selection state overlaps with a single entity.
  5801. // If so, try to remove the appropriate substring of the entity text.
  5802. if (startKey === endKey) {
  5803. if (startEntityKey && startEntityKey === endEntityKey) {
  5804. var _adjustedRemovalRange = getCharacterRemovalRange_1(contentState.getEntityMap(), startBlock, endBlock, rangeToRemove, removalDirection);
  5805. return removeRangeFromContentState_1(contentState, _adjustedRemovalRange);
  5806. }
  5807. }
  5808. var adjustedRemovalRange = rangeToRemove;
  5809. var withoutEntities = removeEntitiesAtEdges_1(contentState, adjustedRemovalRange);
  5810. return removeRangeFromContentState_1(withoutEntities, adjustedRemovalRange);
  5811. },
  5812. splitBlock: function splitBlock(contentState, selectionState) {
  5813. var withoutEntities = removeEntitiesAtEdges_1(contentState, selectionState);
  5814. var withoutText = removeRangeFromContentState_1(withoutEntities, selectionState);
  5815. return splitBlockInContentState_1(withoutText, withoutText.getSelectionAfter());
  5816. },
  5817. applyInlineStyle: function applyInlineStyle(contentState, selectionState, inlineStyle) {
  5818. return ContentStateInlineStyle_1.add(contentState, selectionState, inlineStyle);
  5819. },
  5820. removeInlineStyle: function removeInlineStyle(contentState, selectionState, inlineStyle) {
  5821. return ContentStateInlineStyle_1.remove(contentState, selectionState, inlineStyle);
  5822. },
  5823. setBlockType: function setBlockType(contentState, selectionState, blockType) {
  5824. return modifyBlockForContentState_1(contentState, selectionState, function (block) {
  5825. return block.merge({ type: blockType, depth: 0 });
  5826. });
  5827. },
  5828. setBlockData: function setBlockData(contentState, selectionState, blockData) {
  5829. return modifyBlockForContentState_1(contentState, selectionState, function (block) {
  5830. return block.merge({ data: blockData });
  5831. });
  5832. },
  5833. mergeBlockData: function mergeBlockData(contentState, selectionState, blockData) {
  5834. return modifyBlockForContentState_1(contentState, selectionState, function (block) {
  5835. return block.merge({ data: block.getData().merge(blockData) });
  5836. });
  5837. },
  5838. applyEntity: function applyEntity(contentState, selectionState, entityKey) {
  5839. var withoutEntities = removeEntitiesAtEdges_1(contentState, selectionState);
  5840. return applyEntityToContentState_1(withoutEntities, selectionState, entityKey);
  5841. }
  5842. };
  5843. var DraftModifier_1 = DraftModifier;
  5844. /**
  5845. * Copyright (c) 2013-present, Facebook, Inc.
  5846. *
  5847. * This source code is licensed under the MIT license found in the
  5848. * LICENSE file in the root directory of this source tree.
  5849. *
  5850. *
  5851. */
  5852. function makeEmptyFunction(arg) {
  5853. return function () {
  5854. return arg;
  5855. };
  5856. }
  5857. /**
  5858. * This function accepts and discards inputs; it has no side effects. This is
  5859. * primarily useful idiomatically for overridable function endpoints which
  5860. * always need to be callable, since JS lacks a null-call idiom ala Cocoa.
  5861. */
  5862. var emptyFunction = function emptyFunction() {};
  5863. emptyFunction.thatReturns = makeEmptyFunction;
  5864. emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
  5865. emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
  5866. emptyFunction.thatReturnsNull = makeEmptyFunction(null);
  5867. emptyFunction.thatReturnsThis = function () {
  5868. return this;
  5869. };
  5870. emptyFunction.thatReturnsArgument = function (arg) {
  5871. return arg;
  5872. };
  5873. var emptyFunction_1 = emptyFunction;
  5874. var List$5 = immutable.List,
  5875. Repeat$3 = immutable.Repeat,
  5876. Record$3 = immutable.Record;
  5877. var returnTrue = emptyFunction_1.thatReturnsTrue;
  5878. var FINGERPRINT_DELIMITER = '-';
  5879. var defaultLeafRange = {
  5880. start: null,
  5881. end: null
  5882. };
  5883. var LeafRange = Record$3(defaultLeafRange);
  5884. var defaultDecoratorRange = {
  5885. start: null,
  5886. end: null,
  5887. decoratorKey: null,
  5888. leaves: null
  5889. };
  5890. var DecoratorRange = Record$3(defaultDecoratorRange);
  5891. var BlockTree = {
  5892. /**
  5893. * Generate a block tree for a given ContentBlock/decorator pair.
  5894. */
  5895. generate: function generate(contentState, block, decorator) {
  5896. var textLength = block.getLength();
  5897. if (!textLength) {
  5898. return List$5.of(new DecoratorRange({
  5899. start: 0,
  5900. end: 0,
  5901. decoratorKey: null,
  5902. leaves: List$5.of(new LeafRange({ start: 0, end: 0 }))
  5903. }));
  5904. }
  5905. var leafSets = [];
  5906. var decorations = decorator ? decorator.getDecorations(block, contentState) : List$5(Repeat$3(null, textLength));
  5907. var chars = block.getCharacterList();
  5908. findRangesImmutable_1(decorations, areEqual, returnTrue, function (start, end) {
  5909. leafSets.push(new DecoratorRange({
  5910. start: start,
  5911. end: end,
  5912. decoratorKey: decorations.get(start),
  5913. leaves: generateLeaves(chars.slice(start, end).toList(), start)
  5914. }));
  5915. });
  5916. return List$5(leafSets);
  5917. },
  5918. /**
  5919. * Create a string representation of the given tree map. This allows us
  5920. * to rapidly determine whether a tree has undergone a significant
  5921. * structural change.
  5922. */
  5923. getFingerprint: function getFingerprint(tree) {
  5924. return tree.map(function (leafSet) {
  5925. var decoratorKey = leafSet.get('decoratorKey');
  5926. var fingerprintString = decoratorKey !== null ? decoratorKey + '.' + (leafSet.get('end') - leafSet.get('start')) : '';
  5927. return '' + fingerprintString + '.' + leafSet.get('leaves').size;
  5928. }).join(FINGERPRINT_DELIMITER);
  5929. }
  5930. };
  5931. /**
  5932. * Generate LeafRange records for a given character list.
  5933. */
  5934. function generateLeaves(characters, offset) {
  5935. var leaves = [];
  5936. var inlineStyles = characters.map(function (c) {
  5937. return c.getStyle();
  5938. }).toList();
  5939. findRangesImmutable_1(inlineStyles, areEqual, returnTrue, function (start, end) {
  5940. leaves.push(new LeafRange({
  5941. start: start + offset,
  5942. end: end + offset
  5943. }));
  5944. });
  5945. return List$5(leaves);
  5946. }
  5947. function areEqual(a, b) {
  5948. return a === b;
  5949. }
  5950. var BlockTree_1 = BlockTree;
  5951. function _classCallCheck$3(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  5952. function _possibleConstructorReturn$3(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  5953. function _inherits$3(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  5954. var Record$4 = immutable.Record;
  5955. var DraftEntityInstanceRecord = Record$4({
  5956. type: 'TOKEN',
  5957. mutability: 'IMMUTABLE',
  5958. data: Object
  5959. });
  5960. /**
  5961. * An instance of a document entity, consisting of a `type` and relevant
  5962. * `data`, metadata about the entity.
  5963. *
  5964. * For instance, a "link" entity might provide a URI, and a "mention"
  5965. * entity might provide the mentioned user's ID. These pieces of data
  5966. * may be used when rendering the entity as part of a ContentBlock DOM
  5967. * representation. For a link, the data would be used as an href for
  5968. * the rendered anchor. For a mention, the ID could be used to retrieve
  5969. * a hovercard.
  5970. */
  5971. var DraftEntityInstance = function (_DraftEntityInstanceR) {
  5972. _inherits$3(DraftEntityInstance, _DraftEntityInstanceR);
  5973. function DraftEntityInstance() {
  5974. _classCallCheck$3(this, DraftEntityInstance);
  5975. return _possibleConstructorReturn$3(this, _DraftEntityInstanceR.apply(this, arguments));
  5976. }
  5977. DraftEntityInstance.prototype.getType = function getType() {
  5978. return this.get('type');
  5979. };
  5980. DraftEntityInstance.prototype.getMutability = function getMutability() {
  5981. return this.get('mutability');
  5982. };
  5983. DraftEntityInstance.prototype.getData = function getData() {
  5984. return this.get('data');
  5985. };
  5986. return DraftEntityInstance;
  5987. }(DraftEntityInstanceRecord);
  5988. var DraftEntityInstance_1 = DraftEntityInstance;
  5989. var _extends = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  5990. /**
  5991. * Copyright (c) 2013-present, Facebook, Inc.
  5992. * All rights reserved.
  5993. *
  5994. * This source code is licensed under the BSD-style license found in the
  5995. * LICENSE file in the root directory of this source tree. An additional grant
  5996. * of patent rights can be found in the PATENTS file in the same directory.
  5997. *
  5998. * @providesModule DraftEntity
  5999. * @format
  6000. *
  6001. */
  6002. var Map$7 = immutable.Map;
  6003. var instances = Map$7();
  6004. var instanceKey = 0;
  6005. /**
  6006. * Temporary utility for generating the warnings
  6007. */
  6008. function logWarning(oldMethodCall, newMethodCall) {
  6009. console.warn('WARNING: ' + oldMethodCall + ' will be deprecated soon!\nPlease use "' + newMethodCall + '" instead.');
  6010. }
  6011. /**
  6012. * A "document entity" is an object containing metadata associated with a
  6013. * piece of text in a ContentBlock.
  6014. *
  6015. * For example, a `link` entity might include a `uri` property. When a
  6016. * ContentBlock is rendered in the browser, text that refers to that link
  6017. * entity may be rendered as an anchor, with the `uri` as the href value.
  6018. *
  6019. * In a ContentBlock, every position in the text may correspond to zero
  6020. * or one entities. This correspondence is tracked using a key string,
  6021. * generated via DraftEntity.create() and used to obtain entity metadata
  6022. * via DraftEntity.get().
  6023. */
  6024. var DraftEntity = {
  6025. /**
  6026. * WARNING: This method will be deprecated soon!
  6027. * Please use 'contentState.getLastCreatedEntityKey' instead.
  6028. * ---
  6029. * Get the random key string from whatever entity was last created.
  6030. * We need this to support the new API, as part of transitioning to put Entity
  6031. * storage in contentState.
  6032. */
  6033. getLastCreatedEntityKey: function getLastCreatedEntityKey() {
  6034. logWarning('DraftEntity.getLastCreatedEntityKey', 'contentState.getLastCreatedEntityKey');
  6035. return DraftEntity.__getLastCreatedEntityKey();
  6036. },
  6037. /**
  6038. * WARNING: This method will be deprecated soon!
  6039. * Please use 'contentState.createEntity' instead.
  6040. * ---
  6041. * Create a DraftEntityInstance and store it for later retrieval.
  6042. *
  6043. * A random key string will be generated and returned. This key may
  6044. * be used to track the entity's usage in a ContentBlock, and for
  6045. * retrieving data about the entity at render time.
  6046. */
  6047. create: function create(type, mutability, data) {
  6048. logWarning('DraftEntity.create', 'contentState.createEntity');
  6049. return DraftEntity.__create(type, mutability, data);
  6050. },
  6051. /**
  6052. * WARNING: This method will be deprecated soon!
  6053. * Please use 'contentState.addEntity' instead.
  6054. * ---
  6055. * Add an existing DraftEntityInstance to the DraftEntity map. This is
  6056. * useful when restoring instances from the server.
  6057. */
  6058. add: function add(instance) {
  6059. logWarning('DraftEntity.add', 'contentState.addEntity');
  6060. return DraftEntity.__add(instance);
  6061. },
  6062. /**
  6063. * WARNING: This method will be deprecated soon!
  6064. * Please use 'contentState.getEntity' instead.
  6065. * ---
  6066. * Retrieve the entity corresponding to the supplied key string.
  6067. */
  6068. get: function get(key) {
  6069. logWarning('DraftEntity.get', 'contentState.getEntity');
  6070. return DraftEntity.__get(key);
  6071. },
  6072. /**
  6073. * WARNING: This method will be deprecated soon!
  6074. * Please use 'contentState.mergeEntityData' instead.
  6075. * ---
  6076. * Entity instances are immutable. If you need to update the data for an
  6077. * instance, this method will merge your data updates and return a new
  6078. * instance.
  6079. */
  6080. mergeData: function mergeData(key, toMerge) {
  6081. logWarning('DraftEntity.mergeData', 'contentState.mergeEntityData');
  6082. return DraftEntity.__mergeData(key, toMerge);
  6083. },
  6084. /**
  6085. * WARNING: This method will be deprecated soon!
  6086. * Please use 'contentState.replaceEntityData' instead.
  6087. * ---
  6088. * Completely replace the data for a given instance.
  6089. */
  6090. replaceData: function replaceData(key, newData) {
  6091. logWarning('DraftEntity.replaceData', 'contentState.replaceEntityData');
  6092. return DraftEntity.__replaceData(key, newData);
  6093. },
  6094. // ***********************************WARNING******************************
  6095. // --- the above public API will be deprecated in the next version of Draft!
  6096. // The methods below this line are private - don't call them directly.
  6097. /**
  6098. * Get the random key string from whatever entity was last created.
  6099. * We need this to support the new API, as part of transitioning to put Entity
  6100. * storage in contentState.
  6101. */
  6102. __getLastCreatedEntityKey: function __getLastCreatedEntityKey() {
  6103. return '' + instanceKey;
  6104. },
  6105. /**
  6106. * Create a DraftEntityInstance and store it for later retrieval.
  6107. *
  6108. * A random key string will be generated and returned. This key may
  6109. * be used to track the entity's usage in a ContentBlock, and for
  6110. * retrieving data about the entity at render time.
  6111. */
  6112. __create: function __create(type, mutability, data) {
  6113. return DraftEntity.__add(new DraftEntityInstance_1({ type: type, mutability: mutability, data: data || {} }));
  6114. },
  6115. /**
  6116. * Add an existing DraftEntityInstance to the DraftEntity map. This is
  6117. * useful when restoring instances from the server.
  6118. */
  6119. __add: function __add(instance) {
  6120. var key = '' + ++instanceKey;
  6121. instances = instances.set(key, instance);
  6122. return key;
  6123. },
  6124. /**
  6125. * Retrieve the entity corresponding to the supplied key string.
  6126. */
  6127. __get: function __get(key) {
  6128. var instance = instances.get(key);
  6129. !!!instance ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Unknown DraftEntity key: %s.', key) : invariant_1(false) : void 0;
  6130. return instance;
  6131. },
  6132. /**
  6133. * Entity instances are immutable. If you need to update the data for an
  6134. * instance, this method will merge your data updates and return a new
  6135. * instance.
  6136. */
  6137. __mergeData: function __mergeData(key, toMerge) {
  6138. var instance = DraftEntity.__get(key);
  6139. var newData = _extends({}, instance.getData(), toMerge);
  6140. var newInstance = instance.set('data', newData);
  6141. instances = instances.set(key, newInstance);
  6142. return newInstance;
  6143. },
  6144. /**
  6145. * Completely replace the data for a given instance.
  6146. */
  6147. __replaceData: function __replaceData(key, newData) {
  6148. var instance = DraftEntity.__get(key);
  6149. var newInstance = instance.set('data', newData);
  6150. instances = instances.set(key, newInstance);
  6151. return newInstance;
  6152. }
  6153. };
  6154. var DraftEntity_1 = DraftEntity;
  6155. function _classCallCheck$4(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6156. function _possibleConstructorReturn$4(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  6157. function _inherits$4(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6158. var Record$5 = immutable.Record;
  6159. var defaultRecord$3 = {
  6160. anchorKey: '',
  6161. anchorOffset: 0,
  6162. focusKey: '',
  6163. focusOffset: 0,
  6164. isBackward: false,
  6165. hasFocus: false
  6166. };
  6167. var SelectionStateRecord = Record$5(defaultRecord$3);
  6168. var SelectionState = function (_SelectionStateRecord) {
  6169. _inherits$4(SelectionState, _SelectionStateRecord);
  6170. function SelectionState() {
  6171. _classCallCheck$4(this, SelectionState);
  6172. return _possibleConstructorReturn$4(this, _SelectionStateRecord.apply(this, arguments));
  6173. }
  6174. SelectionState.prototype.serialize = function serialize() {
  6175. return 'Anchor: ' + this.getAnchorKey() + ':' + this.getAnchorOffset() + ', ' + 'Focus: ' + this.getFocusKey() + ':' + this.getFocusOffset() + ', ' + 'Is Backward: ' + String(this.getIsBackward()) + ', ' + 'Has Focus: ' + String(this.getHasFocus());
  6176. };
  6177. SelectionState.prototype.getAnchorKey = function getAnchorKey() {
  6178. return this.get('anchorKey');
  6179. };
  6180. SelectionState.prototype.getAnchorOffset = function getAnchorOffset() {
  6181. return this.get('anchorOffset');
  6182. };
  6183. SelectionState.prototype.getFocusKey = function getFocusKey() {
  6184. return this.get('focusKey');
  6185. };
  6186. SelectionState.prototype.getFocusOffset = function getFocusOffset() {
  6187. return this.get('focusOffset');
  6188. };
  6189. SelectionState.prototype.getIsBackward = function getIsBackward() {
  6190. return this.get('isBackward');
  6191. };
  6192. SelectionState.prototype.getHasFocus = function getHasFocus() {
  6193. return this.get('hasFocus');
  6194. };
  6195. /**
  6196. * Return whether the specified range overlaps with an edge of the
  6197. * SelectionState.
  6198. */
  6199. SelectionState.prototype.hasEdgeWithin = function hasEdgeWithin(blockKey, start, end) {
  6200. var anchorKey = this.getAnchorKey();
  6201. var focusKey = this.getFocusKey();
  6202. if (anchorKey === focusKey && anchorKey === blockKey) {
  6203. var selectionStart = this.getStartOffset();
  6204. var selectionEnd = this.getEndOffset();
  6205. return start <= selectionEnd && selectionStart <= end;
  6206. }
  6207. if (blockKey !== anchorKey && blockKey !== focusKey) {
  6208. return false;
  6209. }
  6210. var offsetToCheck = blockKey === anchorKey ? this.getAnchorOffset() : this.getFocusOffset();
  6211. return start <= offsetToCheck && end >= offsetToCheck;
  6212. };
  6213. SelectionState.prototype.isCollapsed = function isCollapsed() {
  6214. return this.getAnchorKey() === this.getFocusKey() && this.getAnchorOffset() === this.getFocusOffset();
  6215. };
  6216. SelectionState.prototype.getStartKey = function getStartKey() {
  6217. return this.getIsBackward() ? this.getFocusKey() : this.getAnchorKey();
  6218. };
  6219. SelectionState.prototype.getStartOffset = function getStartOffset() {
  6220. return this.getIsBackward() ? this.getFocusOffset() : this.getAnchorOffset();
  6221. };
  6222. SelectionState.prototype.getEndKey = function getEndKey() {
  6223. return this.getIsBackward() ? this.getAnchorKey() : this.getFocusKey();
  6224. };
  6225. SelectionState.prototype.getEndOffset = function getEndOffset() {
  6226. return this.getIsBackward() ? this.getAnchorOffset() : this.getFocusOffset();
  6227. };
  6228. SelectionState.createEmpty = function createEmpty(key) {
  6229. return new SelectionState({
  6230. anchorKey: key,
  6231. anchorOffset: 0,
  6232. focusKey: key,
  6233. focusOffset: 0,
  6234. isBackward: false,
  6235. hasFocus: false
  6236. });
  6237. };
  6238. return SelectionState;
  6239. }(SelectionStateRecord);
  6240. var SelectionState_1 = SelectionState;
  6241. /**
  6242. * Copyright (c) 2013-present, Facebook, Inc.
  6243. * All rights reserved.
  6244. *
  6245. * This source code is licensed under the BSD-style license found in the
  6246. * LICENSE file in the root directory of this source tree. An additional grant
  6247. * of patent rights can be found in the PATENTS file in the same directory.
  6248. *
  6249. * @providesModule sanitizeDraftText
  6250. * @format
  6251. *
  6252. */
  6253. var REGEX_BLOCK_DELIMITER = new RegExp('\r', 'g');
  6254. function sanitizeDraftText(input) {
  6255. return input.replace(REGEX_BLOCK_DELIMITER, '');
  6256. }
  6257. var sanitizeDraftText_1 = sanitizeDraftText;
  6258. function _classCallCheck$5(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6259. function _possibleConstructorReturn$5(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  6260. function _inherits$5(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  6261. var List$6 = immutable.List,
  6262. Record$6 = immutable.Record,
  6263. Repeat$4 = immutable.Repeat;
  6264. var defaultRecord$4 = {
  6265. entityMap: null,
  6266. blockMap: null,
  6267. selectionBefore: null,
  6268. selectionAfter: null
  6269. };
  6270. var ContentBlockNodeRecord = ContentBlock_1;
  6271. var ContentStateRecord = Record$6(defaultRecord$4);
  6272. var ContentState = function (_ContentStateRecord) {
  6273. _inherits$5(ContentState, _ContentStateRecord);
  6274. function ContentState() {
  6275. _classCallCheck$5(this, ContentState);
  6276. return _possibleConstructorReturn$5(this, _ContentStateRecord.apply(this, arguments));
  6277. }
  6278. ContentState.prototype.getEntityMap = function getEntityMap() {
  6279. // TODO: update this when we fully remove DraftEntity
  6280. return DraftEntity_1;
  6281. };
  6282. ContentState.prototype.getBlockMap = function getBlockMap() {
  6283. return this.get('blockMap');
  6284. };
  6285. ContentState.prototype.getSelectionBefore = function getSelectionBefore() {
  6286. return this.get('selectionBefore');
  6287. };
  6288. ContentState.prototype.getSelectionAfter = function getSelectionAfter() {
  6289. return this.get('selectionAfter');
  6290. };
  6291. ContentState.prototype.getBlockForKey = function getBlockForKey(key) {
  6292. var block = this.getBlockMap().get(key);
  6293. return block;
  6294. };
  6295. ContentState.prototype.getKeyBefore = function getKeyBefore(key) {
  6296. return this.getBlockMap().reverse().keySeq().skipUntil(function (v) {
  6297. return v === key;
  6298. }).skip(1).first();
  6299. };
  6300. ContentState.prototype.getKeyAfter = function getKeyAfter(key) {
  6301. return this.getBlockMap().keySeq().skipUntil(function (v) {
  6302. return v === key;
  6303. }).skip(1).first();
  6304. };
  6305. ContentState.prototype.getBlockAfter = function getBlockAfter(key) {
  6306. return this.getBlockMap().skipUntil(function (_, k) {
  6307. return k === key;
  6308. }).skip(1).first();
  6309. };
  6310. ContentState.prototype.getBlockBefore = function getBlockBefore(key) {
  6311. return this.getBlockMap().reverse().skipUntil(function (_, k) {
  6312. return k === key;
  6313. }).skip(1).first();
  6314. };
  6315. ContentState.prototype.getBlocksAsArray = function getBlocksAsArray() {
  6316. return this.getBlockMap().toArray();
  6317. };
  6318. ContentState.prototype.getFirstBlock = function getFirstBlock() {
  6319. return this.getBlockMap().first();
  6320. };
  6321. ContentState.prototype.getLastBlock = function getLastBlock() {
  6322. return this.getBlockMap().last();
  6323. };
  6324. ContentState.prototype.getPlainText = function getPlainText(delimiter) {
  6325. return this.getBlockMap().map(function (block) {
  6326. return block ? block.getText() : '';
  6327. }).join(delimiter || '\n');
  6328. };
  6329. ContentState.prototype.getLastCreatedEntityKey = function getLastCreatedEntityKey() {
  6330. // TODO: update this when we fully remove DraftEntity
  6331. return DraftEntity_1.__getLastCreatedEntityKey();
  6332. };
  6333. ContentState.prototype.hasText = function hasText() {
  6334. var blockMap = this.getBlockMap();
  6335. return blockMap.size > 1 || blockMap.first().getLength() > 0;
  6336. };
  6337. ContentState.prototype.createEntity = function createEntity(type, mutability, data) {
  6338. // TODO: update this when we fully remove DraftEntity
  6339. DraftEntity_1.__create(type, mutability, data);
  6340. return this;
  6341. };
  6342. ContentState.prototype.mergeEntityData = function mergeEntityData(key, toMerge) {
  6343. // TODO: update this when we fully remove DraftEntity
  6344. DraftEntity_1.__mergeData(key, toMerge);
  6345. return this;
  6346. };
  6347. ContentState.prototype.replaceEntityData = function replaceEntityData(key, newData) {
  6348. // TODO: update this when we fully remove DraftEntity
  6349. DraftEntity_1.__replaceData(key, newData);
  6350. return this;
  6351. };
  6352. ContentState.prototype.addEntity = function addEntity(instance) {
  6353. // TODO: update this when we fully remove DraftEntity
  6354. DraftEntity_1.__add(instance);
  6355. return this;
  6356. };
  6357. ContentState.prototype.getEntity = function getEntity(key) {
  6358. // TODO: update this when we fully remove DraftEntity
  6359. return DraftEntity_1.__get(key);
  6360. };
  6361. ContentState.createFromBlockArray = function createFromBlockArray(
  6362. // TODO: update flow type when we completely deprecate the old entity API
  6363. blocks, entityMap) {
  6364. // TODO: remove this when we completely deprecate the old entity API
  6365. var theBlocks = Array.isArray(blocks) ? blocks : blocks.contentBlocks;
  6366. var blockMap = BlockMapBuilder_1.createFromArray(theBlocks);
  6367. var selectionState = blockMap.isEmpty() ? new SelectionState_1() : SelectionState_1.createEmpty(blockMap.first().getKey());
  6368. return new ContentState({
  6369. blockMap: blockMap,
  6370. entityMap: entityMap || DraftEntity_1,
  6371. selectionBefore: selectionState,
  6372. selectionAfter: selectionState
  6373. });
  6374. };
  6375. ContentState.createFromText = function createFromText(text) {
  6376. var delimiter = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : /\r\n?|\n/g;
  6377. var strings = text.split(delimiter);
  6378. var blocks = strings.map(function (block) {
  6379. block = sanitizeDraftText_1(block);
  6380. return new ContentBlockNodeRecord({
  6381. key: generateRandomKey_1(),
  6382. text: block,
  6383. type: 'unstyled',
  6384. characterList: List$6(Repeat$4(CharacterMetadata_1.EMPTY, block.length))
  6385. });
  6386. });
  6387. return ContentState.createFromBlockArray(blocks);
  6388. };
  6389. return ContentState;
  6390. }(ContentStateRecord);
  6391. var ContentState_1 = ContentState;
  6392. var NEUTRAL = 'NEUTRAL'; // No strong direction
  6393. var LTR = 'LTR'; // Left-to-Right direction
  6394. var RTL = 'RTL'; // Right-to-Left direction
  6395. var globalDir = null;
  6396. // == Helpers ==
  6397. /**
  6398. * Check if a directionality value is a Strong one
  6399. */
  6400. function isStrong(dir) {
  6401. return dir === LTR || dir === RTL;
  6402. }
  6403. /**
  6404. * Get string value to be used for `dir` HTML attribute or `direction` CSS
  6405. * property.
  6406. */
  6407. function getHTMLDir(dir) {
  6408. !isStrong(dir) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant_1(false) : void 0;
  6409. return dir === LTR ? 'ltr' : 'rtl';
  6410. }
  6411. /**
  6412. * Get string value to be used for `dir` HTML attribute or `direction` CSS
  6413. * property, but returns null if `dir` has same value as `otherDir`.
  6414. * `null`.
  6415. */
  6416. function getHTMLDirIfDifferent(dir, otherDir) {
  6417. !isStrong(dir) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`dir` must be a strong direction to be converted to HTML Direction') : invariant_1(false) : void 0;
  6418. !isStrong(otherDir) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '`otherDir` must be a strong direction to be converted to HTML Direction') : invariant_1(false) : void 0;
  6419. return dir === otherDir ? null : getHTMLDir(dir);
  6420. }
  6421. // == Global Direction ==
  6422. /**
  6423. * Set the global direction.
  6424. */
  6425. function setGlobalDir(dir) {
  6426. globalDir = dir;
  6427. }
  6428. /**
  6429. * Initialize the global direction
  6430. */
  6431. function initGlobalDir() {
  6432. setGlobalDir(LTR);
  6433. }
  6434. /**
  6435. * Get the global direction
  6436. */
  6437. function getGlobalDir() {
  6438. if (!globalDir) {
  6439. this.initGlobalDir();
  6440. }
  6441. !globalDir ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Global direction not set.') : invariant_1(false) : void 0;
  6442. return globalDir;
  6443. }
  6444. var UnicodeBidiDirection = {
  6445. // Values
  6446. NEUTRAL: NEUTRAL,
  6447. LTR: LTR,
  6448. RTL: RTL,
  6449. // Helpers
  6450. isStrong: isStrong,
  6451. getHTMLDir: getHTMLDir,
  6452. getHTMLDirIfDifferent: getHTMLDirIfDifferent,
  6453. // Global Direction
  6454. setGlobalDir: setGlobalDir,
  6455. initGlobalDir: initGlobalDir,
  6456. getGlobalDir: getGlobalDir
  6457. };
  6458. var UnicodeBidiDirection_1 = UnicodeBidiDirection;
  6459. /**
  6460. * RegExp ranges of characters with a *Strong* Bidi_Class value.
  6461. *
  6462. * Data is based on DerivedBidiClass.txt in UCD version 7.0.0.
  6463. *
  6464. * NOTE: For performance reasons, we only support Unicode's
  6465. * Basic Multilingual Plane (BMP) for now.
  6466. */
  6467. var RANGE_BY_BIDI_TYPE = {
  6468. L: 'A-Za-z\xAA\xB5\xBA\xC0-\xD6\xD8-\xF6\xF8-\u01BA\u01BB' + '\u01BC-\u01BF\u01C0-\u01C3\u01C4-\u0293\u0294\u0295-\u02AF\u02B0-\u02B8' + '\u02BB-\u02C1\u02D0-\u02D1\u02E0-\u02E4\u02EE\u0370-\u0373\u0376-\u0377' + '\u037A\u037B-\u037D\u037F\u0386\u0388-\u038A\u038C\u038E-\u03A1' + '\u03A3-\u03F5\u03F7-\u0481\u0482\u048A-\u052F\u0531-\u0556\u0559' + '\u055A-\u055F\u0561-\u0587\u0589\u0903\u0904-\u0939\u093B\u093D' + '\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0950\u0958-\u0961\u0964-\u0965' + '\u0966-\u096F\u0970\u0971\u0972-\u0980\u0982-\u0983\u0985-\u098C' + '\u098F-\u0990\u0993-\u09A8\u09AA-\u09B0\u09B2\u09B6-\u09B9\u09BD' + '\u09BE-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u09CE\u09D7\u09DC-\u09DD' + '\u09DF-\u09E1\u09E6-\u09EF\u09F0-\u09F1\u09F4-\u09F9\u09FA\u0A03' + '\u0A05-\u0A0A\u0A0F-\u0A10\u0A13-\u0A28\u0A2A-\u0A30\u0A32-\u0A33' + '\u0A35-\u0A36\u0A38-\u0A39\u0A3E-\u0A40\u0A59-\u0A5C\u0A5E\u0A66-\u0A6F' + '\u0A72-\u0A74\u0A83\u0A85-\u0A8D\u0A8F-\u0A91\u0A93-\u0AA8\u0AAA-\u0AB0' + '\u0AB2-\u0AB3\u0AB5-\u0AB9\u0ABD\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0AD0' + '\u0AE0-\u0AE1\u0AE6-\u0AEF\u0AF0\u0B02-\u0B03\u0B05-\u0B0C\u0B0F-\u0B10' + '\u0B13-\u0B28\u0B2A-\u0B30\u0B32-\u0B33\u0B35-\u0B39\u0B3D\u0B3E\u0B40' + '\u0B47-\u0B48\u0B4B-\u0B4C\u0B57\u0B5C-\u0B5D\u0B5F-\u0B61\u0B66-\u0B6F' + '\u0B70\u0B71\u0B72-\u0B77\u0B83\u0B85-\u0B8A\u0B8E-\u0B90\u0B92-\u0B95' + '\u0B99-\u0B9A\u0B9C\u0B9E-\u0B9F\u0BA3-\u0BA4\u0BA8-\u0BAA\u0BAE-\u0BB9' + '\u0BBE-\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0BD0\u0BD7' + '\u0BE6-\u0BEF\u0BF0-\u0BF2\u0C01-\u0C03\u0C05-\u0C0C\u0C0E-\u0C10' + '\u0C12-\u0C28\u0C2A-\u0C39\u0C3D\u0C41-\u0C44\u0C58-\u0C59\u0C60-\u0C61' + '\u0C66-\u0C6F\u0C7F\u0C82-\u0C83\u0C85-\u0C8C\u0C8E-\u0C90\u0C92-\u0CA8' + '\u0CAA-\u0CB3\u0CB5-\u0CB9\u0CBD\u0CBE\u0CBF\u0CC0-\u0CC4\u0CC6' + '\u0CC7-\u0CC8\u0CCA-\u0CCB\u0CD5-\u0CD6\u0CDE\u0CE0-\u0CE1\u0CE6-\u0CEF' + '\u0CF1-\u0CF2\u0D02-\u0D03\u0D05-\u0D0C\u0D0E-\u0D10\u0D12-\u0D3A\u0D3D' + '\u0D3E-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D4E\u0D57\u0D60-\u0D61' + '\u0D66-\u0D6F\u0D70-\u0D75\u0D79\u0D7A-\u0D7F\u0D82-\u0D83\u0D85-\u0D96' + '\u0D9A-\u0DB1\u0DB3-\u0DBB\u0DBD\u0DC0-\u0DC6\u0DCF-\u0DD1\u0DD8-\u0DDF' + '\u0DE6-\u0DEF\u0DF2-\u0DF3\u0DF4\u0E01-\u0E30\u0E32-\u0E33\u0E40-\u0E45' + '\u0E46\u0E4F\u0E50-\u0E59\u0E5A-\u0E5B\u0E81-\u0E82\u0E84\u0E87-\u0E88' + '\u0E8A\u0E8D\u0E94-\u0E97\u0E99-\u0E9F\u0EA1-\u0EA3\u0EA5\u0EA7' + '\u0EAA-\u0EAB\u0EAD-\u0EB0\u0EB2-\u0EB3\u0EBD\u0EC0-\u0EC4\u0EC6' + '\u0ED0-\u0ED9\u0EDC-\u0EDF\u0F00\u0F01-\u0F03\u0F04-\u0F12\u0F13\u0F14' + '\u0F15-\u0F17\u0F1A-\u0F1F\u0F20-\u0F29\u0F2A-\u0F33\u0F34\u0F36\u0F38' + '\u0F3E-\u0F3F\u0F40-\u0F47\u0F49-\u0F6C\u0F7F\u0F85\u0F88-\u0F8C' + '\u0FBE-\u0FC5\u0FC7-\u0FCC\u0FCE-\u0FCF\u0FD0-\u0FD4\u0FD5-\u0FD8' + '\u0FD9-\u0FDA\u1000-\u102A\u102B-\u102C\u1031\u1038\u103B-\u103C\u103F' + '\u1040-\u1049\u104A-\u104F\u1050-\u1055\u1056-\u1057\u105A-\u105D\u1061' + '\u1062-\u1064\u1065-\u1066\u1067-\u106D\u106E-\u1070\u1075-\u1081' + '\u1083-\u1084\u1087-\u108C\u108E\u108F\u1090-\u1099\u109A-\u109C' + '\u109E-\u109F\u10A0-\u10C5\u10C7\u10CD\u10D0-\u10FA\u10FB\u10FC' + '\u10FD-\u1248\u124A-\u124D\u1250-\u1256\u1258\u125A-\u125D\u1260-\u1288' + '\u128A-\u128D\u1290-\u12B0\u12B2-\u12B5\u12B8-\u12BE\u12C0\u12C2-\u12C5' + '\u12C8-\u12D6\u12D8-\u1310\u1312-\u1315\u1318-\u135A\u1360-\u1368' + '\u1369-\u137C\u1380-\u138F\u13A0-\u13F4\u1401-\u166C\u166D-\u166E' + '\u166F-\u167F\u1681-\u169A\u16A0-\u16EA\u16EB-\u16ED\u16EE-\u16F0' + '\u16F1-\u16F8\u1700-\u170C\u170E-\u1711\u1720-\u1731\u1735-\u1736' + '\u1740-\u1751\u1760-\u176C\u176E-\u1770\u1780-\u17B3\u17B6\u17BE-\u17C5' + '\u17C7-\u17C8\u17D4-\u17D6\u17D7\u17D8-\u17DA\u17DC\u17E0-\u17E9' + '\u1810-\u1819\u1820-\u1842\u1843\u1844-\u1877\u1880-\u18A8\u18AA' + '\u18B0-\u18F5\u1900-\u191E\u1923-\u1926\u1929-\u192B\u1930-\u1931' + '\u1933-\u1938\u1946-\u194F\u1950-\u196D\u1970-\u1974\u1980-\u19AB' + '\u19B0-\u19C0\u19C1-\u19C7\u19C8-\u19C9\u19D0-\u19D9\u19DA\u1A00-\u1A16' + '\u1A19-\u1A1A\u1A1E-\u1A1F\u1A20-\u1A54\u1A55\u1A57\u1A61\u1A63-\u1A64' + '\u1A6D-\u1A72\u1A80-\u1A89\u1A90-\u1A99\u1AA0-\u1AA6\u1AA7\u1AA8-\u1AAD' + '\u1B04\u1B05-\u1B33\u1B35\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B45-\u1B4B' + '\u1B50-\u1B59\u1B5A-\u1B60\u1B61-\u1B6A\u1B74-\u1B7C\u1B82\u1B83-\u1BA0' + '\u1BA1\u1BA6-\u1BA7\u1BAA\u1BAE-\u1BAF\u1BB0-\u1BB9\u1BBA-\u1BE5\u1BE7' + '\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1BFC-\u1BFF\u1C00-\u1C23\u1C24-\u1C2B' + '\u1C34-\u1C35\u1C3B-\u1C3F\u1C40-\u1C49\u1C4D-\u1C4F\u1C50-\u1C59' + '\u1C5A-\u1C77\u1C78-\u1C7D\u1C7E-\u1C7F\u1CC0-\u1CC7\u1CD3\u1CE1' + '\u1CE9-\u1CEC\u1CEE-\u1CF1\u1CF2-\u1CF3\u1CF5-\u1CF6\u1D00-\u1D2B' + '\u1D2C-\u1D6A\u1D6B-\u1D77\u1D78\u1D79-\u1D9A\u1D9B-\u1DBF\u1E00-\u1F15' + '\u1F18-\u1F1D\u1F20-\u1F45\u1F48-\u1F4D\u1F50-\u1F57\u1F59\u1F5B\u1F5D' + '\u1F5F-\u1F7D\u1F80-\u1FB4\u1FB6-\u1FBC\u1FBE\u1FC2-\u1FC4\u1FC6-\u1FCC' + '\u1FD0-\u1FD3\u1FD6-\u1FDB\u1FE0-\u1FEC\u1FF2-\u1FF4\u1FF6-\u1FFC\u200E' + '\u2071\u207F\u2090-\u209C\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D' + '\u2124\u2126\u2128\u212A-\u212D\u212F-\u2134\u2135-\u2138\u2139' + '\u213C-\u213F\u2145-\u2149\u214E\u214F\u2160-\u2182\u2183-\u2184' + '\u2185-\u2188\u2336-\u237A\u2395\u249C-\u24E9\u26AC\u2800-\u28FF' + '\u2C00-\u2C2E\u2C30-\u2C5E\u2C60-\u2C7B\u2C7C-\u2C7D\u2C7E-\u2CE4' + '\u2CEB-\u2CEE\u2CF2-\u2CF3\u2D00-\u2D25\u2D27\u2D2D\u2D30-\u2D67\u2D6F' + '\u2D70\u2D80-\u2D96\u2DA0-\u2DA6\u2DA8-\u2DAE\u2DB0-\u2DB6\u2DB8-\u2DBE' + '\u2DC0-\u2DC6\u2DC8-\u2DCE\u2DD0-\u2DD6\u2DD8-\u2DDE\u3005\u3006\u3007' + '\u3021-\u3029\u302E-\u302F\u3031-\u3035\u3038-\u303A\u303B\u303C' + '\u3041-\u3096\u309D-\u309E\u309F\u30A1-\u30FA\u30FC-\u30FE\u30FF' + '\u3105-\u312D\u3131-\u318E\u3190-\u3191\u3192-\u3195\u3196-\u319F' + '\u31A0-\u31BA\u31F0-\u31FF\u3200-\u321C\u3220-\u3229\u322A-\u3247' + '\u3248-\u324F\u3260-\u327B\u327F\u3280-\u3289\u328A-\u32B0\u32C0-\u32CB' + '\u32D0-\u32FE\u3300-\u3376\u337B-\u33DD\u33E0-\u33FE\u3400-\u4DB5' + '\u4E00-\u9FCC\uA000-\uA014\uA015\uA016-\uA48C\uA4D0-\uA4F7\uA4F8-\uA4FD' + '\uA4FE-\uA4FF\uA500-\uA60B\uA60C\uA610-\uA61F\uA620-\uA629\uA62A-\uA62B' + '\uA640-\uA66D\uA66E\uA680-\uA69B\uA69C-\uA69D\uA6A0-\uA6E5\uA6E6-\uA6EF' + '\uA6F2-\uA6F7\uA722-\uA76F\uA770\uA771-\uA787\uA789-\uA78A\uA78B-\uA78E' + '\uA790-\uA7AD\uA7B0-\uA7B1\uA7F7\uA7F8-\uA7F9\uA7FA\uA7FB-\uA801' + '\uA803-\uA805\uA807-\uA80A\uA80C-\uA822\uA823-\uA824\uA827\uA830-\uA835' + '\uA836-\uA837\uA840-\uA873\uA880-\uA881\uA882-\uA8B3\uA8B4-\uA8C3' + '\uA8CE-\uA8CF\uA8D0-\uA8D9\uA8F2-\uA8F7\uA8F8-\uA8FA\uA8FB\uA900-\uA909' + '\uA90A-\uA925\uA92E-\uA92F\uA930-\uA946\uA952-\uA953\uA95F\uA960-\uA97C' + '\uA983\uA984-\uA9B2\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BD-\uA9C0\uA9C1-\uA9CD' + '\uA9CF\uA9D0-\uA9D9\uA9DE-\uA9DF\uA9E0-\uA9E4\uA9E6\uA9E7-\uA9EF' + '\uA9F0-\uA9F9\uA9FA-\uA9FE\uAA00-\uAA28\uAA2F-\uAA30\uAA33-\uAA34' + '\uAA40-\uAA42\uAA44-\uAA4B\uAA4D\uAA50-\uAA59\uAA5C-\uAA5F\uAA60-\uAA6F' + '\uAA70\uAA71-\uAA76\uAA77-\uAA79\uAA7A\uAA7B\uAA7D\uAA7E-\uAAAF\uAAB1' + '\uAAB5-\uAAB6\uAAB9-\uAABD\uAAC0\uAAC2\uAADB-\uAADC\uAADD\uAADE-\uAADF' + '\uAAE0-\uAAEA\uAAEB\uAAEE-\uAAEF\uAAF0-\uAAF1\uAAF2\uAAF3-\uAAF4\uAAF5' + '\uAB01-\uAB06\uAB09-\uAB0E\uAB11-\uAB16\uAB20-\uAB26\uAB28-\uAB2E' + '\uAB30-\uAB5A\uAB5B\uAB5C-\uAB5F\uAB64-\uAB65\uABC0-\uABE2\uABE3-\uABE4' + '\uABE6-\uABE7\uABE9-\uABEA\uABEB\uABEC\uABF0-\uABF9\uAC00-\uD7A3' + '\uD7B0-\uD7C6\uD7CB-\uD7FB\uE000-\uF8FF\uF900-\uFA6D\uFA70-\uFAD9' + '\uFB00-\uFB06\uFB13-\uFB17\uFF21-\uFF3A\uFF41-\uFF5A\uFF66-\uFF6F\uFF70' + '\uFF71-\uFF9D\uFF9E-\uFF9F\uFFA0-\uFFBE\uFFC2-\uFFC7\uFFCA-\uFFCF' + '\uFFD2-\uFFD7\uFFDA-\uFFDC',
  6469. R: '\u0590\u05BE\u05C0\u05C3\u05C6\u05C8-\u05CF\u05D0-\u05EA\u05EB-\u05EF' + '\u05F0-\u05F2\u05F3-\u05F4\u05F5-\u05FF\u07C0-\u07C9\u07CA-\u07EA' + '\u07F4-\u07F5\u07FA\u07FB-\u07FF\u0800-\u0815\u081A\u0824\u0828' + '\u082E-\u082F\u0830-\u083E\u083F\u0840-\u0858\u085C-\u085D\u085E' + '\u085F-\u089F\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFB36\uFB37\uFB38-\uFB3C' + '\uFB3D\uFB3E\uFB3F\uFB40-\uFB41\uFB42\uFB43-\uFB44\uFB45\uFB46-\uFB4F',
  6470. AL: '\u0608\u060B\u060D\u061B\u061C\u061D\u061E-\u061F\u0620-\u063F\u0640' + '\u0641-\u064A\u066D\u066E-\u066F\u0671-\u06D3\u06D4\u06D5\u06E5-\u06E6' + '\u06EE-\u06EF\u06FA-\u06FC\u06FD-\u06FE\u06FF\u0700-\u070D\u070E\u070F' + '\u0710\u0712-\u072F\u074B-\u074C\u074D-\u07A5\u07B1\u07B2-\u07BF' + '\u08A0-\u08B2\u08B3-\u08E3\uFB50-\uFBB1\uFBB2-\uFBC1\uFBC2-\uFBD2' + '\uFBD3-\uFD3D\uFD40-\uFD4F\uFD50-\uFD8F\uFD90-\uFD91\uFD92-\uFDC7' + '\uFDC8-\uFDCF\uFDF0-\uFDFB\uFDFC\uFDFE-\uFDFF\uFE70-\uFE74\uFE75' + '\uFE76-\uFEFC\uFEFD-\uFEFE'
  6471. };
  6472. var REGEX_STRONG = new RegExp('[' + RANGE_BY_BIDI_TYPE.L + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']');
  6473. var REGEX_RTL = new RegExp('[' + RANGE_BY_BIDI_TYPE.R + RANGE_BY_BIDI_TYPE.AL + ']');
  6474. /**
  6475. * Returns the first strong character (has Bidi_Class value of L, R, or AL).
  6476. *
  6477. * @param str A text block; e.g. paragraph, table cell, tag
  6478. * @return A character with strong bidi direction, or null if not found
  6479. */
  6480. function firstStrongChar(str) {
  6481. var match = REGEX_STRONG.exec(str);
  6482. return match == null ? null : match[0];
  6483. }
  6484. /**
  6485. * Returns the direction of a block of text, based on the direction of its
  6486. * first strong character (has Bidi_Class value of L, R, or AL).
  6487. *
  6488. * @param str A text block; e.g. paragraph, table cell, tag
  6489. * @return The resolved direction
  6490. */
  6491. function firstStrongCharDir(str) {
  6492. var strongChar = firstStrongChar(str);
  6493. if (strongChar == null) {
  6494. return UnicodeBidiDirection_1.NEUTRAL;
  6495. }
  6496. return REGEX_RTL.exec(strongChar) ? UnicodeBidiDirection_1.RTL : UnicodeBidiDirection_1.LTR;
  6497. }
  6498. /**
  6499. * Returns the direction of a block of text, based on the direction of its
  6500. * first strong character (has Bidi_Class value of L, R, or AL), or a fallback
  6501. * direction, if no strong character is found.
  6502. *
  6503. * This function is supposed to be used in respect to Higher-Level Protocol
  6504. * rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
  6505. *
  6506. * @param str A text block; e.g. paragraph, table cell, tag
  6507. * @param fallback Fallback direction, used if no strong direction detected
  6508. * for the block (default = NEUTRAL)
  6509. * @return The resolved direction
  6510. */
  6511. function resolveBlockDir(str, fallback) {
  6512. fallback = fallback || UnicodeBidiDirection_1.NEUTRAL;
  6513. if (!str.length) {
  6514. return fallback;
  6515. }
  6516. var blockDir = firstStrongCharDir(str);
  6517. return blockDir === UnicodeBidiDirection_1.NEUTRAL ? fallback : blockDir;
  6518. }
  6519. /**
  6520. * Returns the direction of a block of text, based on the direction of its
  6521. * first strong character (has Bidi_Class value of L, R, or AL), or a fallback
  6522. * direction, if no strong character is found.
  6523. *
  6524. * NOTE: This function is similar to resolveBlockDir(), but uses the global
  6525. * direction as the fallback, so it *always* returns a Strong direction,
  6526. * making it useful for integration in places that you need to make the final
  6527. * decision, like setting some CSS class.
  6528. *
  6529. * This function is supposed to be used in respect to Higher-Level Protocol
  6530. * rule HL1. (http://www.unicode.org/reports/tr9/#HL1)
  6531. *
  6532. * @param str A text block; e.g. paragraph, table cell
  6533. * @param strongFallback Fallback direction, used if no strong direction
  6534. * detected for the block (default = global direction)
  6535. * @return The resolved Strong direction
  6536. */
  6537. function getDirection(str, strongFallback) {
  6538. if (!strongFallback) {
  6539. strongFallback = UnicodeBidiDirection_1.getGlobalDir();
  6540. }
  6541. !UnicodeBidiDirection_1.isStrong(strongFallback) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Fallback direction must be a strong direction') : invariant_1(false) : void 0;
  6542. return resolveBlockDir(str, strongFallback);
  6543. }
  6544. /**
  6545. * Returns true if getDirection(arguments...) returns LTR.
  6546. *
  6547. * @param str A text block; e.g. paragraph, table cell
  6548. * @param strongFallback Fallback direction, used if no strong direction
  6549. * detected for the block (default = global direction)
  6550. * @return True if the resolved direction is LTR
  6551. */
  6552. function isDirectionLTR(str, strongFallback) {
  6553. return getDirection(str, strongFallback) === UnicodeBidiDirection_1.LTR;
  6554. }
  6555. /**
  6556. * Returns true if getDirection(arguments...) returns RTL.
  6557. *
  6558. * @param str A text block; e.g. paragraph, table cell
  6559. * @param strongFallback Fallback direction, used if no strong direction
  6560. * detected for the block (default = global direction)
  6561. * @return True if the resolved direction is RTL
  6562. */
  6563. function isDirectionRTL(str, strongFallback) {
  6564. return getDirection(str, strongFallback) === UnicodeBidiDirection_1.RTL;
  6565. }
  6566. var UnicodeBidi = {
  6567. firstStrongChar: firstStrongChar,
  6568. firstStrongCharDir: firstStrongCharDir,
  6569. resolveBlockDir: resolveBlockDir,
  6570. getDirection: getDirection,
  6571. isDirectionLTR: isDirectionLTR,
  6572. isDirectionRTL: isDirectionRTL
  6573. };
  6574. var UnicodeBidi_1 = UnicodeBidi;
  6575. function _classCallCheck$6(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6576. var UnicodeBidiService = function () {
  6577. /**
  6578. * Stateful class for paragraph direction detection
  6579. *
  6580. * @param defaultDir Default direction of the service
  6581. */
  6582. function UnicodeBidiService(defaultDir) {
  6583. _classCallCheck$6(this, UnicodeBidiService);
  6584. if (!defaultDir) {
  6585. defaultDir = UnicodeBidiDirection_1.getGlobalDir();
  6586. } else {
  6587. !UnicodeBidiDirection_1.isStrong(defaultDir) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Default direction must be a strong direction (LTR or RTL)') : invariant_1(false) : void 0;
  6588. }
  6589. this._defaultDir = defaultDir;
  6590. this.reset();
  6591. }
  6592. /**
  6593. * Reset the internal state
  6594. *
  6595. * Instead of creating a new instance, you can just reset() your instance
  6596. * everytime you start a new loop.
  6597. */
  6598. UnicodeBidiService.prototype.reset = function reset() {
  6599. this._lastDir = this._defaultDir;
  6600. };
  6601. /**
  6602. * Returns the direction of a block of text, and remembers it as the
  6603. * fall-back direction for the next paragraph.
  6604. *
  6605. * @param str A text block, e.g. paragraph, table cell, tag
  6606. * @return The resolved direction
  6607. */
  6608. UnicodeBidiService.prototype.getDirection = function getDirection(str) {
  6609. this._lastDir = UnicodeBidi_1.getDirection(str, this._lastDir);
  6610. return this._lastDir;
  6611. };
  6612. return UnicodeBidiService;
  6613. }();
  6614. var UnicodeBidiService_1 = UnicodeBidiService;
  6615. /**
  6616. * Copyright (c) 2013-present, Facebook, Inc.
  6617. *
  6618. * This source code is licensed under the MIT license found in the
  6619. * LICENSE file in the root directory of this source tree.
  6620. *
  6621. *
  6622. */
  6623. var nullthrows = function nullthrows(x) {
  6624. if (x != null) {
  6625. return x;
  6626. }
  6627. throw new Error("Got unexpected null or undefined");
  6628. };
  6629. var nullthrows_1 = nullthrows;
  6630. var OrderedMap$2 = immutable.OrderedMap;
  6631. var bidiService;
  6632. var EditorBidiService = {
  6633. getDirectionMap: function getDirectionMap(content, prevBidiMap) {
  6634. if (!bidiService) {
  6635. bidiService = new UnicodeBidiService_1();
  6636. } else {
  6637. bidiService.reset();
  6638. }
  6639. var blockMap = content.getBlockMap();
  6640. var nextBidi = blockMap.valueSeq().map(function (block) {
  6641. return nullthrows_1(bidiService).getDirection(block.getText());
  6642. });
  6643. var bidiMap = OrderedMap$2(blockMap.keySeq().zip(nextBidi));
  6644. if (prevBidiMap != null && immutable.is(prevBidiMap, bidiMap)) {
  6645. return prevBidiMap;
  6646. }
  6647. return bidiMap;
  6648. }
  6649. };
  6650. var EditorBidiService_1 = EditorBidiService;
  6651. var _extends$1 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  6652. function _classCallCheck$7(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  6653. var OrderedSet$4 = immutable.OrderedSet,
  6654. Record$7 = immutable.Record,
  6655. Stack = immutable.Stack;
  6656. var defaultRecord$5 = {
  6657. allowUndo: true,
  6658. currentContent: null,
  6659. decorator: null,
  6660. directionMap: null,
  6661. forceSelection: false,
  6662. inCompositionMode: false,
  6663. inlineStyleOverride: null,
  6664. lastChangeType: null,
  6665. nativelyRenderedContent: null,
  6666. redoStack: Stack(),
  6667. selection: null,
  6668. treeMap: null,
  6669. undoStack: Stack()
  6670. };
  6671. var EditorStateRecord = Record$7(defaultRecord$5);
  6672. var EditorState = function () {
  6673. EditorState.createEmpty = function createEmpty(decorator) {
  6674. return EditorState.createWithContent(ContentState_1.createFromText(''), decorator);
  6675. };
  6676. EditorState.createWithContent = function createWithContent(contentState, decorator) {
  6677. var firstKey = contentState.getBlockMap().first().getKey();
  6678. return EditorState.create({
  6679. currentContent: contentState,
  6680. undoStack: Stack(),
  6681. redoStack: Stack(),
  6682. decorator: decorator || null,
  6683. selection: SelectionState_1.createEmpty(firstKey)
  6684. });
  6685. };
  6686. EditorState.create = function create(config) {
  6687. var currentContent = config.currentContent,
  6688. decorator = config.decorator;
  6689. var recordConfig = _extends$1({}, config, {
  6690. treeMap: generateNewTreeMap(currentContent, decorator),
  6691. directionMap: EditorBidiService_1.getDirectionMap(currentContent)
  6692. });
  6693. return new EditorState(new EditorStateRecord(recordConfig));
  6694. };
  6695. EditorState.set = function set(editorState, put) {
  6696. var map = editorState.getImmutable().withMutations(function (state) {
  6697. var existingDecorator = state.get('decorator');
  6698. var decorator = existingDecorator;
  6699. if (put.decorator === null) {
  6700. decorator = null;
  6701. } else if (put.decorator) {
  6702. decorator = put.decorator;
  6703. }
  6704. var newContent = put.currentContent || editorState.getCurrentContent();
  6705. if (decorator !== existingDecorator) {
  6706. var treeMap = state.get('treeMap');
  6707. var newTreeMap;
  6708. if (decorator && existingDecorator) {
  6709. newTreeMap = regenerateTreeForNewDecorator(newContent, newContent.getBlockMap(), treeMap, decorator, existingDecorator);
  6710. } else {
  6711. newTreeMap = generateNewTreeMap(newContent, decorator);
  6712. }
  6713. state.merge({
  6714. decorator: decorator,
  6715. treeMap: newTreeMap,
  6716. nativelyRenderedContent: null
  6717. });
  6718. return;
  6719. }
  6720. var existingContent = editorState.getCurrentContent();
  6721. if (newContent !== existingContent) {
  6722. state.set('treeMap', regenerateTreeForNewBlocks(editorState, newContent.getBlockMap(), newContent.getEntityMap(), decorator));
  6723. }
  6724. state.merge(put);
  6725. });
  6726. return new EditorState(map);
  6727. };
  6728. EditorState.prototype.toJS = function toJS() {
  6729. return this.getImmutable().toJS();
  6730. };
  6731. EditorState.prototype.getAllowUndo = function getAllowUndo() {
  6732. return this.getImmutable().get('allowUndo');
  6733. };
  6734. EditorState.prototype.getCurrentContent = function getCurrentContent() {
  6735. return this.getImmutable().get('currentContent');
  6736. };
  6737. EditorState.prototype.getUndoStack = function getUndoStack() {
  6738. return this.getImmutable().get('undoStack');
  6739. };
  6740. EditorState.prototype.getRedoStack = function getRedoStack() {
  6741. return this.getImmutable().get('redoStack');
  6742. };
  6743. EditorState.prototype.getSelection = function getSelection() {
  6744. return this.getImmutable().get('selection');
  6745. };
  6746. EditorState.prototype.getDecorator = function getDecorator() {
  6747. return this.getImmutable().get('decorator');
  6748. };
  6749. EditorState.prototype.isInCompositionMode = function isInCompositionMode() {
  6750. return this.getImmutable().get('inCompositionMode');
  6751. };
  6752. EditorState.prototype.mustForceSelection = function mustForceSelection() {
  6753. return this.getImmutable().get('forceSelection');
  6754. };
  6755. EditorState.prototype.getNativelyRenderedContent = function getNativelyRenderedContent() {
  6756. return this.getImmutable().get('nativelyRenderedContent');
  6757. };
  6758. EditorState.prototype.getLastChangeType = function getLastChangeType() {
  6759. return this.getImmutable().get('lastChangeType');
  6760. };
  6761. /**
  6762. * While editing, the user may apply inline style commands with a collapsed
  6763. * cursor, intending to type text that adopts the specified style. In this
  6764. * case, we track the specified style as an "override" that takes precedence
  6765. * over the inline style of the text adjacent to the cursor.
  6766. *
  6767. * If null, there is no override in place.
  6768. */
  6769. EditorState.prototype.getInlineStyleOverride = function getInlineStyleOverride() {
  6770. return this.getImmutable().get('inlineStyleOverride');
  6771. };
  6772. EditorState.setInlineStyleOverride = function setInlineStyleOverride(editorState, inlineStyleOverride) {
  6773. return EditorState.set(editorState, { inlineStyleOverride: inlineStyleOverride });
  6774. };
  6775. /**
  6776. * Get the appropriate inline style for the editor state. If an
  6777. * override is in place, use it. Otherwise, the current style is
  6778. * based on the location of the selection state.
  6779. */
  6780. EditorState.prototype.getCurrentInlineStyle = function getCurrentInlineStyle() {
  6781. var override = this.getInlineStyleOverride();
  6782. if (override != null) {
  6783. return override;
  6784. }
  6785. var content = this.getCurrentContent();
  6786. var selection = this.getSelection();
  6787. if (selection.isCollapsed()) {
  6788. return getInlineStyleForCollapsedSelection(content, selection);
  6789. }
  6790. return getInlineStyleForNonCollapsedSelection(content, selection);
  6791. };
  6792. EditorState.prototype.getBlockTree = function getBlockTree(blockKey) {
  6793. return this.getImmutable().getIn(['treeMap', blockKey]);
  6794. };
  6795. EditorState.prototype.isSelectionAtStartOfContent = function isSelectionAtStartOfContent() {
  6796. var firstKey = this.getCurrentContent().getBlockMap().first().getKey();
  6797. return this.getSelection().hasEdgeWithin(firstKey, 0, 0);
  6798. };
  6799. EditorState.prototype.isSelectionAtEndOfContent = function isSelectionAtEndOfContent() {
  6800. var content = this.getCurrentContent();
  6801. var blockMap = content.getBlockMap();
  6802. var last = blockMap.last();
  6803. var end = last.getLength();
  6804. return this.getSelection().hasEdgeWithin(last.getKey(), end, end);
  6805. };
  6806. EditorState.prototype.getDirectionMap = function getDirectionMap() {
  6807. return this.getImmutable().get('directionMap');
  6808. };
  6809. /**
  6810. * Incorporate native DOM selection changes into the EditorState. This
  6811. * method can be used when we simply want to accept whatever the DOM
  6812. * has given us to represent selection, and we do not need to re-render
  6813. * the editor.
  6814. *
  6815. * To forcibly move the DOM selection, see `EditorState.forceSelection`.
  6816. */
  6817. EditorState.acceptSelection = function acceptSelection(editorState, selection) {
  6818. return updateSelection(editorState, selection, false);
  6819. };
  6820. /**
  6821. * At times, we need to force the DOM selection to be where we
  6822. * need it to be. This can occur when the anchor or focus nodes
  6823. * are non-text nodes, for instance. In this case, we want to trigger
  6824. * a re-render of the editor, which in turn forces selection into
  6825. * the correct place in the DOM. The `forceSelection` method
  6826. * accomplishes this.
  6827. *
  6828. * This method should be used in cases where you need to explicitly
  6829. * move the DOM selection from one place to another without a change
  6830. * in ContentState.
  6831. */
  6832. EditorState.forceSelection = function forceSelection(editorState, selection) {
  6833. if (!selection.getHasFocus()) {
  6834. selection = selection.set('hasFocus', true);
  6835. }
  6836. return updateSelection(editorState, selection, true);
  6837. };
  6838. /**
  6839. * Move selection to the end of the editor without forcing focus.
  6840. */
  6841. EditorState.moveSelectionToEnd = function moveSelectionToEnd(editorState) {
  6842. var content = editorState.getCurrentContent();
  6843. var lastBlock = content.getLastBlock();
  6844. var lastKey = lastBlock.getKey();
  6845. var length = lastBlock.getLength();
  6846. return EditorState.acceptSelection(editorState, new SelectionState_1({
  6847. anchorKey: lastKey,
  6848. anchorOffset: length,
  6849. focusKey: lastKey,
  6850. focusOffset: length,
  6851. isBackward: false
  6852. }));
  6853. };
  6854. /**
  6855. * Force focus to the end of the editor. This is useful in scenarios
  6856. * where we want to programmatically focus the input and it makes sense
  6857. * to allow the user to continue working seamlessly.
  6858. */
  6859. EditorState.moveFocusToEnd = function moveFocusToEnd(editorState) {
  6860. var afterSelectionMove = EditorState.moveSelectionToEnd(editorState);
  6861. return EditorState.forceSelection(afterSelectionMove, afterSelectionMove.getSelection());
  6862. };
  6863. /**
  6864. * Push the current ContentState onto the undo stack if it should be
  6865. * considered a boundary state, and set the provided ContentState as the
  6866. * new current content.
  6867. */
  6868. EditorState.push = function push(editorState, contentState, changeType) {
  6869. if (editorState.getCurrentContent() === contentState) {
  6870. return editorState;
  6871. }
  6872. var forceSelection = changeType !== 'insert-characters';
  6873. var directionMap = EditorBidiService_1.getDirectionMap(contentState, editorState.getDirectionMap());
  6874. if (!editorState.getAllowUndo()) {
  6875. return EditorState.set(editorState, {
  6876. currentContent: contentState,
  6877. directionMap: directionMap,
  6878. lastChangeType: changeType,
  6879. selection: contentState.getSelectionAfter(),
  6880. forceSelection: forceSelection,
  6881. inlineStyleOverride: null
  6882. });
  6883. }
  6884. var selection = editorState.getSelection();
  6885. var currentContent = editorState.getCurrentContent();
  6886. var undoStack = editorState.getUndoStack();
  6887. var newContent = contentState;
  6888. if (selection !== currentContent.getSelectionAfter() || mustBecomeBoundary(editorState, changeType)) {
  6889. undoStack = undoStack.push(currentContent);
  6890. newContent = newContent.set('selectionBefore', selection);
  6891. } else if (changeType === 'insert-characters' || changeType === 'backspace-character' || changeType === 'delete-character') {
  6892. // Preserve the previous selection.
  6893. newContent = newContent.set('selectionBefore', currentContent.getSelectionBefore());
  6894. }
  6895. var inlineStyleOverride = editorState.getInlineStyleOverride();
  6896. // Don't discard inline style overrides for the following change types:
  6897. var overrideChangeTypes = ['adjust-depth', 'change-block-type', 'split-block'];
  6898. if (overrideChangeTypes.indexOf(changeType) === -1) {
  6899. inlineStyleOverride = null;
  6900. }
  6901. var editorStateChanges = {
  6902. currentContent: newContent,
  6903. directionMap: directionMap,
  6904. undoStack: undoStack,
  6905. redoStack: Stack(),
  6906. lastChangeType: changeType,
  6907. selection: contentState.getSelectionAfter(),
  6908. forceSelection: forceSelection,
  6909. inlineStyleOverride: inlineStyleOverride
  6910. };
  6911. return EditorState.set(editorState, editorStateChanges);
  6912. };
  6913. /**
  6914. * Make the top ContentState in the undo stack the new current content and
  6915. * push the current content onto the redo stack.
  6916. */
  6917. EditorState.undo = function undo(editorState) {
  6918. if (!editorState.getAllowUndo()) {
  6919. return editorState;
  6920. }
  6921. var undoStack = editorState.getUndoStack();
  6922. var newCurrentContent = undoStack.peek();
  6923. if (!newCurrentContent) {
  6924. return editorState;
  6925. }
  6926. var currentContent = editorState.getCurrentContent();
  6927. var directionMap = EditorBidiService_1.getDirectionMap(newCurrentContent, editorState.getDirectionMap());
  6928. return EditorState.set(editorState, {
  6929. currentContent: newCurrentContent,
  6930. directionMap: directionMap,
  6931. undoStack: undoStack.shift(),
  6932. redoStack: editorState.getRedoStack().push(currentContent),
  6933. forceSelection: true,
  6934. inlineStyleOverride: null,
  6935. lastChangeType: 'undo',
  6936. nativelyRenderedContent: null,
  6937. selection: currentContent.getSelectionBefore()
  6938. });
  6939. };
  6940. /**
  6941. * Make the top ContentState in the redo stack the new current content and
  6942. * push the current content onto the undo stack.
  6943. */
  6944. EditorState.redo = function redo(editorState) {
  6945. if (!editorState.getAllowUndo()) {
  6946. return editorState;
  6947. }
  6948. var redoStack = editorState.getRedoStack();
  6949. var newCurrentContent = redoStack.peek();
  6950. if (!newCurrentContent) {
  6951. return editorState;
  6952. }
  6953. var currentContent = editorState.getCurrentContent();
  6954. var directionMap = EditorBidiService_1.getDirectionMap(newCurrentContent, editorState.getDirectionMap());
  6955. return EditorState.set(editorState, {
  6956. currentContent: newCurrentContent,
  6957. directionMap: directionMap,
  6958. undoStack: editorState.getUndoStack().push(currentContent),
  6959. redoStack: redoStack.shift(),
  6960. forceSelection: true,
  6961. inlineStyleOverride: null,
  6962. lastChangeType: 'redo',
  6963. nativelyRenderedContent: null,
  6964. selection: newCurrentContent.getSelectionAfter()
  6965. });
  6966. };
  6967. /**
  6968. * Not for public consumption.
  6969. */
  6970. function EditorState(immutable) {
  6971. _classCallCheck$7(this, EditorState);
  6972. this._immutable = immutable;
  6973. }
  6974. /**
  6975. * Not for public consumption.
  6976. */
  6977. EditorState.prototype.getImmutable = function getImmutable() {
  6978. return this._immutable;
  6979. };
  6980. return EditorState;
  6981. }();
  6982. /**
  6983. * Set the supplied SelectionState as the new current selection, and set
  6984. * the `force` flag to trigger manual selection placement by the view.
  6985. */
  6986. function updateSelection(editorState, selection, forceSelection) {
  6987. return EditorState.set(editorState, {
  6988. selection: selection,
  6989. forceSelection: forceSelection,
  6990. nativelyRenderedContent: null,
  6991. inlineStyleOverride: null
  6992. });
  6993. }
  6994. /**
  6995. * Regenerate the entire tree map for a given ContentState and decorator.
  6996. * Returns an OrderedMap that maps all available ContentBlock objects.
  6997. */
  6998. function generateNewTreeMap(contentState, decorator) {
  6999. return contentState.getBlockMap().map(function (block) {
  7000. return BlockTree_1.generate(contentState, block, decorator);
  7001. }).toOrderedMap();
  7002. }
  7003. /**
  7004. * Regenerate tree map objects for all ContentBlocks that have changed
  7005. * between the current editorState and newContent. Returns an OrderedMap
  7006. * with only changed regenerated tree map objects.
  7007. */
  7008. function regenerateTreeForNewBlocks(editorState, newBlockMap, newEntityMap, decorator) {
  7009. var contentState = editorState.getCurrentContent().set('entityMap', newEntityMap);
  7010. var prevBlockMap = contentState.getBlockMap();
  7011. var prevTreeMap = editorState.getImmutable().get('treeMap');
  7012. return prevTreeMap.merge(newBlockMap.toSeq().filter(function (block, key) {
  7013. return block !== prevBlockMap.get(key);
  7014. }).map(function (block) {
  7015. return BlockTree_1.generate(contentState, block, decorator);
  7016. }));
  7017. }
  7018. /**
  7019. * Generate tree map objects for a new decorator object, preserving any
  7020. * decorations that are unchanged from the previous decorator.
  7021. *
  7022. * Note that in order for this to perform optimally, decoration Lists for
  7023. * decorators should be preserved when possible to allow for direct immutable
  7024. * List comparison.
  7025. */
  7026. function regenerateTreeForNewDecorator(content, blockMap, previousTreeMap, decorator, existingDecorator) {
  7027. return previousTreeMap.merge(blockMap.toSeq().filter(function (block) {
  7028. return decorator.getDecorations(block, content) !== existingDecorator.getDecorations(block, content);
  7029. }).map(function (block) {
  7030. return BlockTree_1.generate(content, block, decorator);
  7031. }));
  7032. }
  7033. /**
  7034. * Return whether a change should be considered a boundary state, given
  7035. * the previous change type. Allows us to discard potential boundary states
  7036. * during standard typing or deletion behavior.
  7037. */
  7038. function mustBecomeBoundary(editorState, changeType) {
  7039. var lastChangeType = editorState.getLastChangeType();
  7040. return changeType !== lastChangeType || changeType !== 'insert-characters' && changeType !== 'backspace-character' && changeType !== 'delete-character';
  7041. }
  7042. function getInlineStyleForCollapsedSelection(content, selection) {
  7043. var startKey = selection.getStartKey();
  7044. var startOffset = selection.getStartOffset();
  7045. var startBlock = content.getBlockForKey(startKey);
  7046. // If the cursor is not at the start of the block, look backward to
  7047. // preserve the style of the preceding character.
  7048. if (startOffset > 0) {
  7049. return startBlock.getInlineStyleAt(startOffset - 1);
  7050. }
  7051. // The caret is at position zero in this block. If the block has any
  7052. // text at all, use the style of the first character.
  7053. if (startBlock.getLength()) {
  7054. return startBlock.getInlineStyleAt(0);
  7055. }
  7056. // Otherwise, look upward in the document to find the closest character.
  7057. return lookUpwardForInlineStyle(content, startKey);
  7058. }
  7059. function getInlineStyleForNonCollapsedSelection(content, selection) {
  7060. var startKey = selection.getStartKey();
  7061. var startOffset = selection.getStartOffset();
  7062. var startBlock = content.getBlockForKey(startKey);
  7063. // If there is a character just inside the selection, use its style.
  7064. if (startOffset < startBlock.getLength()) {
  7065. return startBlock.getInlineStyleAt(startOffset);
  7066. }
  7067. // Check if the selection at the end of a non-empty block. Use the last
  7068. // style in the block.
  7069. if (startOffset > 0) {
  7070. return startBlock.getInlineStyleAt(startOffset - 1);
  7071. }
  7072. // Otherwise, look upward in the document to find the closest character.
  7073. return lookUpwardForInlineStyle(content, startKey);
  7074. }
  7075. function lookUpwardForInlineStyle(content, fromKey) {
  7076. var lastNonEmpty = content.getBlockMap().reverse().skipUntil(function (_, k) {
  7077. return k === fromKey;
  7078. }).skip(1).skipUntil(function (block, _) {
  7079. return block.getLength();
  7080. }).first();
  7081. if (lastNonEmpty) return lastNonEmpty.getInlineStyleAt(lastNonEmpty.getLength() - 1);
  7082. return OrderedSet$4();
  7083. }
  7084. var EditorState_1 = EditorState;
  7085. var OrderedMap$3 = immutable.OrderedMap,
  7086. List$7 = immutable.List;
  7087. var transformBlock$2 = function transformBlock(key, blockMap, func) {
  7088. if (!key) {
  7089. return;
  7090. }
  7091. var block = blockMap.get(key);
  7092. if (!block) {
  7093. return;
  7094. }
  7095. blockMap.set(key, func(block));
  7096. };
  7097. var updateBlockMapLinks$3 = function updateBlockMapLinks(blockMap, originalBlockToBeMoved, originalTargetBlock, insertionMode, isExperimentalTreeBlock) {
  7098. if (!isExperimentalTreeBlock) {
  7099. return blockMap;
  7100. }
  7101. // possible values of 'insertionMode' are: 'after', 'before'
  7102. var isInsertedAfterTarget = insertionMode === 'after';
  7103. var originalBlockKey = originalBlockToBeMoved.getKey();
  7104. var originalTargetKey = originalTargetBlock.getKey();
  7105. var originalParentKey = originalBlockToBeMoved.getParentKey();
  7106. var originalNextSiblingKey = originalBlockToBeMoved.getNextSiblingKey();
  7107. var originalPrevSiblingKey = originalBlockToBeMoved.getPrevSiblingKey();
  7108. var newParentKey = originalTargetBlock.getParentKey();
  7109. var newNextSiblingKey = isInsertedAfterTarget ? originalTargetBlock.getNextSiblingKey() : originalTargetKey;
  7110. var newPrevSiblingKey = isInsertedAfterTarget ? originalTargetKey : originalTargetBlock.getPrevSiblingKey();
  7111. return blockMap.withMutations(function (blocks) {
  7112. // update old parent
  7113. transformBlock$2(originalParentKey, blocks, function (block) {
  7114. var parentChildrenList = block.getChildKeys();
  7115. return block.merge({
  7116. children: parentChildrenList['delete'](parentChildrenList.indexOf(originalBlockKey))
  7117. });
  7118. });
  7119. // update old prev
  7120. transformBlock$2(originalPrevSiblingKey, blocks, function (block) {
  7121. return block.merge({
  7122. nextSibling: originalNextSiblingKey
  7123. });
  7124. });
  7125. // update old next
  7126. transformBlock$2(originalNextSiblingKey, blocks, function (block) {
  7127. return block.merge({
  7128. prevSibling: originalPrevSiblingKey
  7129. });
  7130. });
  7131. // update new next
  7132. transformBlock$2(newNextSiblingKey, blocks, function (block) {
  7133. return block.merge({
  7134. prevSibling: originalBlockKey
  7135. });
  7136. });
  7137. // update new prev
  7138. transformBlock$2(newPrevSiblingKey, blocks, function (block) {
  7139. return block.merge({
  7140. nextSibling: originalBlockKey
  7141. });
  7142. });
  7143. // update new parent
  7144. transformBlock$2(newParentKey, blocks, function (block) {
  7145. var newParentChildrenList = block.getChildKeys();
  7146. var targetBlockIndex = newParentChildrenList.indexOf(originalTargetKey);
  7147. var insertionIndex = isInsertedAfterTarget ? targetBlockIndex + 1 : targetBlockIndex !== 0 ? targetBlockIndex - 1 : 0;
  7148. var newChildrenArray = newParentChildrenList.toArray();
  7149. newChildrenArray.splice(insertionIndex, 0, originalBlockKey);
  7150. return block.merge({
  7151. children: List$7(newChildrenArray)
  7152. });
  7153. });
  7154. // update block
  7155. transformBlock$2(originalBlockKey, blocks, function (block) {
  7156. return block.merge({
  7157. nextSibling: newNextSiblingKey,
  7158. prevSibling: newPrevSiblingKey,
  7159. parent: newParentKey
  7160. });
  7161. });
  7162. });
  7163. };
  7164. var moveBlockInContentState = function moveBlockInContentState(contentState, blockToBeMoved, targetBlock, insertionMode) {
  7165. !(insertionMode !== 'replace') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Replacing blocks is not supported.') : invariant_1(false) : void 0;
  7166. var targetKey = targetBlock.getKey();
  7167. var blockKey = blockToBeMoved.getKey();
  7168. !(blockKey !== targetKey) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Block cannot be moved next to itself.') : invariant_1(false) : void 0;
  7169. var blockMap = contentState.getBlockMap();
  7170. var isExperimentalTreeBlock = blockToBeMoved instanceof ContentBlockNode_1;
  7171. var blocksToBeMoved = [blockToBeMoved];
  7172. var blockMapWithoutBlocksToBeMoved = blockMap['delete'](blockKey);
  7173. if (isExperimentalTreeBlock) {
  7174. blocksToBeMoved = [];
  7175. blockMapWithoutBlocksToBeMoved = blockMap.withMutations(function (blocks) {
  7176. var nextSiblingKey = blockToBeMoved.getNextSiblingKey();
  7177. var nextDelimiterBlockKey = getNextDelimiterBlockKey_1(blockToBeMoved, blocks);
  7178. blocks.toSeq().skipUntil(function (block) {
  7179. return block.getKey() === blockKey;
  7180. }).takeWhile(function (block) {
  7181. var key = block.getKey();
  7182. var isBlockToBeMoved = key === blockKey;
  7183. var hasNextSiblingAndIsNotNextSibling = nextSiblingKey && key !== nextSiblingKey;
  7184. var doesNotHaveNextSiblingAndIsNotDelimiter = !nextSiblingKey && block.getParentKey() && (!nextDelimiterBlockKey || key !== nextDelimiterBlockKey);
  7185. return !!(isBlockToBeMoved || hasNextSiblingAndIsNotNextSibling || doesNotHaveNextSiblingAndIsNotDelimiter);
  7186. }).forEach(function (block) {
  7187. blocksToBeMoved.push(block);
  7188. blocks['delete'](block.getKey());
  7189. });
  7190. });
  7191. }
  7192. var blocksBefore = blockMapWithoutBlocksToBeMoved.toSeq().takeUntil(function (v) {
  7193. return v === targetBlock;
  7194. });
  7195. var blocksAfter = blockMapWithoutBlocksToBeMoved.toSeq().skipUntil(function (v) {
  7196. return v === targetBlock;
  7197. }).skip(1);
  7198. var slicedBlocks = blocksToBeMoved.map(function (block) {
  7199. return [block.getKey(), block];
  7200. });
  7201. var newBlocks = OrderedMap$3();
  7202. if (insertionMode === 'before') {
  7203. var blockBefore = contentState.getBlockBefore(targetKey);
  7204. !(!blockBefore || blockBefore.getKey() !== blockToBeMoved.getKey()) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Block cannot be moved next to itself.') : invariant_1(false) : void 0;
  7205. newBlocks = blocksBefore.concat([].concat(slicedBlocks, [[targetKey, targetBlock]]), blocksAfter).toOrderedMap();
  7206. } else if (insertionMode === 'after') {
  7207. var blockAfter = contentState.getBlockAfter(targetKey);
  7208. !(!blockAfter || blockAfter.getKey() !== blockKey) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Block cannot be moved next to itself.') : invariant_1(false) : void 0;
  7209. newBlocks = blocksBefore.concat([[targetKey, targetBlock]].concat(slicedBlocks), blocksAfter).toOrderedMap();
  7210. }
  7211. return contentState.merge({
  7212. blockMap: updateBlockMapLinks$3(newBlocks, blockToBeMoved, targetBlock, insertionMode, isExperimentalTreeBlock),
  7213. selectionBefore: contentState.getSelectionAfter(),
  7214. selectionAfter: contentState.getSelectionAfter().merge({
  7215. anchorKey: blockKey,
  7216. focusKey: blockKey
  7217. })
  7218. });
  7219. };
  7220. var moveBlockInContentState_1 = moveBlockInContentState;
  7221. var ContentBlockRecord$1 = ContentBlock_1;
  7222. var List$8 = immutable.List,
  7223. Repeat$5 = immutable.Repeat;
  7224. var AtomicBlockUtils = {
  7225. insertAtomicBlock: function insertAtomicBlock(editorState, entityKey, character) {
  7226. var contentState = editorState.getCurrentContent();
  7227. var selectionState = editorState.getSelection();
  7228. var afterRemoval = DraftModifier_1.removeRange(contentState, selectionState, 'backward');
  7229. var targetSelection = afterRemoval.getSelectionAfter();
  7230. var afterSplit = DraftModifier_1.splitBlock(afterRemoval, targetSelection);
  7231. var insertionTarget = afterSplit.getSelectionAfter();
  7232. var asAtomicBlock = DraftModifier_1.setBlockType(afterSplit, insertionTarget, 'atomic');
  7233. var charData = CharacterMetadata_1.create({ entity: entityKey });
  7234. var atomicBlockConfig = {
  7235. key: generateRandomKey_1(),
  7236. type: 'atomic',
  7237. text: character,
  7238. characterList: List$8(Repeat$5(charData, character.length))
  7239. };
  7240. var atomicDividerBlockConfig = {
  7241. key: generateRandomKey_1(),
  7242. type: 'unstyled'
  7243. };
  7244. var fragmentArray = [new ContentBlockRecord$1(atomicBlockConfig), new ContentBlockRecord$1(atomicDividerBlockConfig)];
  7245. var fragment = BlockMapBuilder_1.createFromArray(fragmentArray);
  7246. var withAtomicBlock = DraftModifier_1.replaceWithFragment(asAtomicBlock, insertionTarget, fragment);
  7247. var newContent = withAtomicBlock.merge({
  7248. selectionBefore: selectionState,
  7249. selectionAfter: withAtomicBlock.getSelectionAfter().set('hasFocus', true)
  7250. });
  7251. return EditorState_1.push(editorState, newContent, 'insert-fragment');
  7252. },
  7253. moveAtomicBlock: function moveAtomicBlock(editorState, atomicBlock, targetRange, insertionMode) {
  7254. var contentState = editorState.getCurrentContent();
  7255. var selectionState = editorState.getSelection();
  7256. var withMovedAtomicBlock = void 0;
  7257. if (insertionMode === 'before' || insertionMode === 'after') {
  7258. var targetBlock = contentState.getBlockForKey(insertionMode === 'before' ? targetRange.getStartKey() : targetRange.getEndKey());
  7259. withMovedAtomicBlock = moveBlockInContentState_1(contentState, atomicBlock, targetBlock, insertionMode);
  7260. } else {
  7261. var afterRemoval = DraftModifier_1.removeRange(contentState, targetRange, 'backward');
  7262. var selectionAfterRemoval = afterRemoval.getSelectionAfter();
  7263. var _targetBlock = afterRemoval.getBlockForKey(selectionAfterRemoval.getFocusKey());
  7264. if (selectionAfterRemoval.getStartOffset() === 0) {
  7265. withMovedAtomicBlock = moveBlockInContentState_1(afterRemoval, atomicBlock, _targetBlock, 'before');
  7266. } else if (selectionAfterRemoval.getEndOffset() === _targetBlock.getLength()) {
  7267. withMovedAtomicBlock = moveBlockInContentState_1(afterRemoval, atomicBlock, _targetBlock, 'after');
  7268. } else {
  7269. var afterSplit = DraftModifier_1.splitBlock(afterRemoval, selectionAfterRemoval);
  7270. var selectionAfterSplit = afterSplit.getSelectionAfter();
  7271. var _targetBlock2 = afterSplit.getBlockForKey(selectionAfterSplit.getFocusKey());
  7272. withMovedAtomicBlock = moveBlockInContentState_1(afterSplit, atomicBlock, _targetBlock2, 'before');
  7273. }
  7274. }
  7275. var newContent = withMovedAtomicBlock.merge({
  7276. selectionBefore: selectionState,
  7277. selectionAfter: withMovedAtomicBlock.getSelectionAfter().set('hasFocus', true)
  7278. });
  7279. return EditorState_1.push(editorState, newContent, 'move-block');
  7280. }
  7281. };
  7282. var AtomicBlockUtils_1 = AtomicBlockUtils;
  7283. function _classCallCheck$8(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  7284. var List$9 = immutable.List;
  7285. var DELIMITER = '.';
  7286. /**
  7287. * A CompositeDraftDecorator traverses through a list of DraftDecorator
  7288. * instances to identify sections of a ContentBlock that should be rendered
  7289. * in a "decorated" manner. For example, hashtags, mentions, and links may
  7290. * be intended to stand out visually, be rendered as anchors, etc.
  7291. *
  7292. * The list of decorators supplied to the constructor will be used in the
  7293. * order they are provided. This allows the caller to specify a priority for
  7294. * string matching, in case of match collisions among decorators.
  7295. *
  7296. * For instance, I may have a link with a `#` in its text. Though this section
  7297. * of text may match our hashtag decorator, it should not be treated as a
  7298. * hashtag. I should therefore list my link DraftDecorator
  7299. * before my hashtag DraftDecorator when constructing this composite
  7300. * decorator instance.
  7301. *
  7302. * Thus, when a collision like this is encountered, the earlier match is
  7303. * preserved and the new match is discarded.
  7304. */
  7305. var CompositeDraftDecorator = function () {
  7306. function CompositeDraftDecorator(decorators) {
  7307. _classCallCheck$8(this, CompositeDraftDecorator);
  7308. // Copy the decorator array, since we use this array order to determine
  7309. // precedence of decoration matching. If the array is mutated externally,
  7310. // we don't want to be affected here.
  7311. this._decorators = decorators.slice();
  7312. }
  7313. CompositeDraftDecorator.prototype.getDecorations = function getDecorations(block, contentState) {
  7314. var decorations = Array(block.getText().length).fill(null);
  7315. this._decorators.forEach(function ( /*object*/decorator, /*number*/ii) {
  7316. var counter = 0;
  7317. var strategy = decorator.strategy;
  7318. var callback = function callback( /*number*/start, /*number*/end) {
  7319. // Find out if any of our matching range is already occupied
  7320. // by another decorator. If so, discard the match. Otherwise, store
  7321. // the component key for rendering.
  7322. if (canOccupySlice(decorations, start, end)) {
  7323. occupySlice(decorations, start, end, ii + DELIMITER + counter);
  7324. counter++;
  7325. }
  7326. };
  7327. strategy(block, callback, contentState);
  7328. });
  7329. return List$9(decorations);
  7330. };
  7331. CompositeDraftDecorator.prototype.getComponentForKey = function getComponentForKey(key) {
  7332. var componentKey = parseInt(key.split(DELIMITER)[0], 10);
  7333. return this._decorators[componentKey].component;
  7334. };
  7335. CompositeDraftDecorator.prototype.getPropsForKey = function getPropsForKey(key) {
  7336. var componentKey = parseInt(key.split(DELIMITER)[0], 10);
  7337. return this._decorators[componentKey].props;
  7338. };
  7339. return CompositeDraftDecorator;
  7340. }();
  7341. /**
  7342. * Determine whether we can occupy the specified slice of the decorations
  7343. * array.
  7344. */
  7345. function canOccupySlice(decorations, start, end) {
  7346. for (var ii = start; ii < end; ii++) {
  7347. if (decorations[ii] != null) {
  7348. return false;
  7349. }
  7350. }
  7351. return true;
  7352. }
  7353. /**
  7354. * Splice the specified component into our decoration array at the desired
  7355. * range.
  7356. */
  7357. function occupySlice(targetArr, start, end, componentKey) {
  7358. for (var ii = start; ii < end; ii++) {
  7359. targetArr[ii] = componentKey;
  7360. }
  7361. }
  7362. var CompositeDraftDecorator_1 = CompositeDraftDecorator;
  7363. /**
  7364. * Copyright (c) 2013-present, Facebook, Inc.
  7365. *
  7366. * This source code is licensed under the MIT license found in the
  7367. * LICENSE file in the root directory of this source tree.
  7368. *
  7369. */
  7370. /**
  7371. * This function is used to mark string literals representing CSS class names
  7372. * so that they can be transformed statically. This allows for modularization
  7373. * and minification of CSS class names.
  7374. *
  7375. * In static_upstream, this function is actually implemented, but it should
  7376. * eventually be replaced with something more descriptive, and the transform
  7377. * that is used in the main stack should be ported for use elsewhere.
  7378. *
  7379. * @param string|object className to modularize, or an object of key/values.
  7380. * In the object case, the values are conditions that
  7381. * determine if the className keys should be included.
  7382. * @param [string ...] Variable list of classNames in the string case.
  7383. * @return string Renderable space-separated CSS className.
  7384. */
  7385. function cx(classNames) {
  7386. if (typeof classNames == 'object') {
  7387. return Object.keys(classNames).filter(function (className) {
  7388. return classNames[className];
  7389. }).map(replace).join(' ');
  7390. }
  7391. return Array.prototype.map.call(arguments, replace).join(' ');
  7392. }
  7393. function replace(str) {
  7394. return str.replace(/\//g, '-');
  7395. }
  7396. var cx_1 = cx;
  7397. var Map$8 = immutable.Map;
  7398. var UL_WRAP = React__default.createElement('ul', { className: cx_1('public/DraftStyleDefault/ul') });
  7399. var OL_WRAP = React__default.createElement('ol', { className: cx_1('public/DraftStyleDefault/ol') });
  7400. var PRE_WRAP = React__default.createElement('pre', { className: cx_1('public/DraftStyleDefault/pre') });
  7401. var DefaultDraftBlockRenderMap = Map$8({
  7402. 'header-one': {
  7403. element: 'h1'
  7404. },
  7405. 'header-two': {
  7406. element: 'h2'
  7407. },
  7408. 'header-three': {
  7409. element: 'h3'
  7410. },
  7411. 'header-four': {
  7412. element: 'h4'
  7413. },
  7414. 'header-five': {
  7415. element: 'h5'
  7416. },
  7417. 'header-six': {
  7418. element: 'h6'
  7419. },
  7420. 'unordered-list-item': {
  7421. element: 'li',
  7422. wrapper: UL_WRAP
  7423. },
  7424. 'ordered-list-item': {
  7425. element: 'li',
  7426. wrapper: OL_WRAP
  7427. },
  7428. blockquote: {
  7429. element: 'blockquote'
  7430. },
  7431. atomic: {
  7432. element: 'figure'
  7433. },
  7434. 'code-block': {
  7435. element: 'pre',
  7436. wrapper: PRE_WRAP
  7437. },
  7438. unstyled: {
  7439. element: 'div',
  7440. aliasedElements: ['p']
  7441. }
  7442. });
  7443. var DefaultDraftBlockRenderMap_1 = DefaultDraftBlockRenderMap;
  7444. /**
  7445. * Copyright (c) 2013-present, Facebook, Inc.
  7446. * All rights reserved.
  7447. *
  7448. * This source code is licensed under the BSD-style license found in the
  7449. * LICENSE file in the root directory of this source tree. An additional grant
  7450. * of patent rights can be found in the PATENTS file in the same directory.
  7451. *
  7452. * @providesModule DefaultDraftInlineStyle
  7453. * @format
  7454. *
  7455. */
  7456. var DefaultDraftInlineStyle = {
  7457. BOLD: {
  7458. fontWeight: 'bold'
  7459. },
  7460. CODE: {
  7461. fontFamily: 'monospace',
  7462. wordWrap: 'break-word'
  7463. },
  7464. ITALIC: {
  7465. fontStyle: 'italic'
  7466. },
  7467. STRIKETHROUGH: {
  7468. textDecoration: 'line-through'
  7469. },
  7470. UNDERLINE: {
  7471. textDecoration: 'underline'
  7472. }
  7473. };
  7474. /**
  7475. * Copyright (c) 2013-present, Facebook, Inc.
  7476. *
  7477. * This source code is licensed under the MIT license found in the
  7478. * LICENSE file in the root directory of this source tree.
  7479. *
  7480. */
  7481. var Keys = {
  7482. BACKSPACE: 8,
  7483. TAB: 9,
  7484. RETURN: 13,
  7485. ALT: 18,
  7486. ESC: 27,
  7487. SPACE: 32,
  7488. PAGE_UP: 33,
  7489. PAGE_DOWN: 34,
  7490. END: 35,
  7491. HOME: 36,
  7492. LEFT: 37,
  7493. UP: 38,
  7494. RIGHT: 39,
  7495. DOWN: 40,
  7496. DELETE: 46,
  7497. COMMA: 188,
  7498. PERIOD: 190,
  7499. A: 65,
  7500. Z: 90,
  7501. ZERO: 48,
  7502. NUMPAD_0: 96,
  7503. NUMPAD_9: 105
  7504. };
  7505. /**
  7506. * Copyright (c) 2013-present, Facebook, Inc.
  7507. * All rights reserved.
  7508. *
  7509. * This source code is licensed under the BSD-style license found in the
  7510. * LICENSE file in the root directory of this source tree. An additional grant
  7511. * of patent rights can be found in the PATENTS file in the same directory.
  7512. *
  7513. * @providesModule getEntityKeyForSelection
  7514. * @format
  7515. *
  7516. */
  7517. /**
  7518. * Return the entity key that should be used when inserting text for the
  7519. * specified target selection, only if the entity is `MUTABLE`. `IMMUTABLE`
  7520. * and `SEGMENTED` entities should not be used for insertion behavior.
  7521. */
  7522. function getEntityKeyForSelection(contentState, targetSelection) {
  7523. var entityKey;
  7524. if (targetSelection.isCollapsed()) {
  7525. var key = targetSelection.getAnchorKey();
  7526. var offset = targetSelection.getAnchorOffset();
  7527. if (offset > 0) {
  7528. entityKey = contentState.getBlockForKey(key).getEntityAt(offset - 1);
  7529. if (entityKey !== contentState.getBlockForKey(key).getEntityAt(offset)) {
  7530. return null;
  7531. }
  7532. return filterKey(contentState.getEntityMap(), entityKey);
  7533. }
  7534. return null;
  7535. }
  7536. var startKey = targetSelection.getStartKey();
  7537. var startOffset = targetSelection.getStartOffset();
  7538. var startBlock = contentState.getBlockForKey(startKey);
  7539. entityKey = startOffset === startBlock.getLength() ? null : startBlock.getEntityAt(startOffset);
  7540. return filterKey(contentState.getEntityMap(), entityKey);
  7541. }
  7542. /**
  7543. * Determine whether an entity key corresponds to a `MUTABLE` entity. If so,
  7544. * return it. If not, return null.
  7545. */
  7546. function filterKey(entityMap, entityKey) {
  7547. if (entityKey) {
  7548. var entity = entityMap.__get(entityKey);
  7549. return entity.getMutability() === 'MUTABLE' ? entityKey : null;
  7550. }
  7551. return null;
  7552. }
  7553. var getEntityKeyForSelection_1 = getEntityKeyForSelection;
  7554. /**
  7555. * Copyright (c) 2013-present, Facebook, Inc.
  7556. * All rights reserved.
  7557. *
  7558. * This source code is licensed under the BSD-style license found in the
  7559. * LICENSE file in the root directory of this source tree. An additional grant
  7560. * of patent rights can be found in the PATENTS file in the same directory.
  7561. *
  7562. * @providesModule isEventHandled
  7563. * @format
  7564. *
  7565. */
  7566. /**
  7567. * Utility method for determining whether or not the value returned
  7568. * from a handler indicates that it was handled.
  7569. */
  7570. function isEventHandled(value) {
  7571. return value === 'handled' || value === true;
  7572. }
  7573. var isEventHandled_1 = isEventHandled;
  7574. /**
  7575. * Copyright (c) 2013-present, Facebook, Inc.
  7576. * All rights reserved.
  7577. *
  7578. * This source code is licensed under the BSD-style license found in the
  7579. * LICENSE file in the root directory of this source tree. An additional grant
  7580. * of patent rights can be found in the PATENTS file in the same directory.
  7581. *
  7582. * @providesModule isSelectionAtLeafStart
  7583. * @format
  7584. *
  7585. */
  7586. function isSelectionAtLeafStart(editorState) {
  7587. var selection = editorState.getSelection();
  7588. var anchorKey = selection.getAnchorKey();
  7589. var blockTree = editorState.getBlockTree(anchorKey);
  7590. var offset = selection.getStartOffset();
  7591. var isAtStart = false;
  7592. blockTree.some(function (leafSet) {
  7593. if (offset === leafSet.get('start')) {
  7594. isAtStart = true;
  7595. return true;
  7596. }
  7597. if (offset < leafSet.get('end')) {
  7598. return leafSet.get('leaves').some(function (leaf) {
  7599. var leafStart = leaf.get('start');
  7600. if (offset === leafStart) {
  7601. isAtStart = true;
  7602. return true;
  7603. }
  7604. return false;
  7605. });
  7606. }
  7607. return false;
  7608. });
  7609. return isAtStart;
  7610. }
  7611. var isSelectionAtLeafStart_1 = isSelectionAtLeafStart;
  7612. /**
  7613. * Millisecond delay to allow `compositionstart` to fire again upon
  7614. * `compositionend`.
  7615. *
  7616. * This is used for Korean input to ensure that typing can continue without
  7617. * the editor trying to render too quickly. More specifically, Safari 7.1+
  7618. * triggers `compositionstart` a little slower than Chrome/FF, which
  7619. * leads to composed characters being resolved and re-render occurring
  7620. * sooner than we want.
  7621. */
  7622. var RESOLVE_DELAY = 20;
  7623. /**
  7624. * A handful of variables used to track the current composition and its
  7625. * resolution status. These exist at the module level because it is not
  7626. * possible to have compositions occurring in multiple editors simultaneously,
  7627. * and it simplifies state management with respect to the DraftEditor component.
  7628. */
  7629. var resolved = false;
  7630. var stillComposing = false;
  7631. var textInputData = '';
  7632. var DraftEditorCompositionHandler = {
  7633. onBeforeInput: function onBeforeInput(editor, e) {
  7634. textInputData = (textInputData || '') + e.data;
  7635. },
  7636. /**
  7637. * A `compositionstart` event has fired while we're still in composition
  7638. * mode. Continue the current composition session to prevent a re-render.
  7639. */
  7640. onCompositionStart: function onCompositionStart(editor) {
  7641. stillComposing = true;
  7642. },
  7643. /**
  7644. * Attempt to end the current composition session.
  7645. *
  7646. * Defer handling because browser will still insert the chars into active
  7647. * element after `compositionend`. If a `compositionstart` event fires
  7648. * before `resolveComposition` executes, our composition session will
  7649. * continue.
  7650. *
  7651. * The `resolved` flag is useful because certain IME interfaces fire the
  7652. * `compositionend` event multiple times, thus queueing up multiple attempts
  7653. * at handling the composition. Since handling the same composition event
  7654. * twice could break the DOM, we only use the first event. Example: Arabic
  7655. * Google Input Tools on Windows 8.1 fires `compositionend` three times.
  7656. */
  7657. onCompositionEnd: function onCompositionEnd(editor) {
  7658. resolved = false;
  7659. stillComposing = false;
  7660. setTimeout(function () {
  7661. if (!resolved) {
  7662. DraftEditorCompositionHandler.resolveComposition(editor);
  7663. }
  7664. }, RESOLVE_DELAY);
  7665. },
  7666. /**
  7667. * In Safari, keydown events may fire when committing compositions. If
  7668. * the arrow keys are used to commit, prevent default so that the cursor
  7669. * doesn't move, otherwise it will jump back noticeably on re-render.
  7670. */
  7671. onKeyDown: function onKeyDown(editor, e) {
  7672. if (!stillComposing) {
  7673. // If a keydown event is received after compositionend but before the
  7674. // 20ms timer expires (ex: type option-E then backspace, or type A then
  7675. // backspace in 2-Set Korean), we should immediately resolve the
  7676. // composition and reinterpret the key press in edit mode.
  7677. DraftEditorCompositionHandler.resolveComposition(editor);
  7678. editor._onKeyDown(e);
  7679. return;
  7680. }
  7681. if (e.which === Keys.RIGHT || e.which === Keys.LEFT) {
  7682. e.preventDefault();
  7683. }
  7684. },
  7685. /**
  7686. * Keypress events may fire when committing compositions. In Firefox,
  7687. * pressing RETURN commits the composition and inserts extra newline
  7688. * characters that we do not want. `preventDefault` allows the composition
  7689. * to be committed while preventing the extra characters.
  7690. */
  7691. onKeyPress: function onKeyPress(editor, e) {
  7692. if (e.which === Keys.RETURN) {
  7693. e.preventDefault();
  7694. }
  7695. },
  7696. /**
  7697. * Attempt to insert composed characters into the document.
  7698. *
  7699. * If we are still in a composition session, do nothing. Otherwise, insert
  7700. * the characters into the document and terminate the composition session.
  7701. *
  7702. * If no characters were composed -- for instance, the user
  7703. * deleted all composed characters and committed nothing new --
  7704. * force a re-render. We also re-render when the composition occurs
  7705. * at the beginning of a leaf, to ensure that if the browser has
  7706. * created a new text node for the composition, we will discard it.
  7707. *
  7708. * Resetting innerHTML will move focus to the beginning of the editor,
  7709. * so we update to force it back to the correct place.
  7710. */
  7711. resolveComposition: function resolveComposition(editor) {
  7712. if (stillComposing) {
  7713. return;
  7714. }
  7715. resolved = true;
  7716. var composedChars = textInputData;
  7717. textInputData = '';
  7718. var editorState = EditorState_1.set(editor._latestEditorState, {
  7719. inCompositionMode: false
  7720. });
  7721. var currentStyle = editorState.getCurrentInlineStyle();
  7722. var entityKey = getEntityKeyForSelection_1(editorState.getCurrentContent(), editorState.getSelection());
  7723. var mustReset = !composedChars || isSelectionAtLeafStart_1(editorState) || currentStyle.size > 0 || entityKey !== null;
  7724. if (mustReset) {
  7725. editor.restoreEditorDOM();
  7726. }
  7727. editor.exitCurrentMode();
  7728. if (composedChars) {
  7729. // If characters have been composed, re-rendering with the update
  7730. // is sufficient to reset the editor.
  7731. var contentState = DraftModifier_1.replaceText(editorState.getCurrentContent(), editorState.getSelection(), composedChars, currentStyle, entityKey);
  7732. editor.update(EditorState_1.push(editorState, contentState, 'insert-characters'));
  7733. return;
  7734. }
  7735. if (mustReset) {
  7736. editor.update(EditorState_1.set(editorState, {
  7737. nativelyRenderedContent: null,
  7738. forceSelection: true
  7739. }));
  7740. }
  7741. }
  7742. };
  7743. var DraftEditorCompositionHandler_1 = DraftEditorCompositionHandler;
  7744. var uaParser = index.createCommonjsModule(function (module, exports) {
  7745. /*!
  7746. * UAParser.js v0.7.21
  7747. * Lightweight JavaScript-based User-Agent string parser
  7748. * https://github.com/faisalman/ua-parser-js
  7749. *
  7750. * Copyright © 2012-2019 Faisal Salman <f@faisalman.com>
  7751. * Licensed under MIT License
  7752. */
  7753. (function (window, undefined$1) {
  7754. //////////////
  7755. // Constants
  7756. /////////////
  7757. var LIBVERSION = '0.7.21',
  7758. EMPTY = '',
  7759. UNKNOWN = '?',
  7760. FUNC_TYPE = 'function',
  7761. OBJ_TYPE = 'object',
  7762. STR_TYPE = 'string',
  7763. MAJOR = 'major', // deprecated
  7764. MODEL = 'model',
  7765. NAME = 'name',
  7766. TYPE = 'type',
  7767. VENDOR = 'vendor',
  7768. VERSION = 'version',
  7769. ARCHITECTURE= 'architecture',
  7770. CONSOLE = 'console',
  7771. MOBILE = 'mobile',
  7772. TABLET = 'tablet',
  7773. SMARTTV = 'smarttv',
  7774. WEARABLE = 'wearable',
  7775. EMBEDDED = 'embedded';
  7776. ///////////
  7777. // Helper
  7778. //////////
  7779. var util = {
  7780. extend : function (regexes, extensions) {
  7781. var mergedRegexes = {};
  7782. for (var i in regexes) {
  7783. if (extensions[i] && extensions[i].length % 2 === 0) {
  7784. mergedRegexes[i] = extensions[i].concat(regexes[i]);
  7785. } else {
  7786. mergedRegexes[i] = regexes[i];
  7787. }
  7788. }
  7789. return mergedRegexes;
  7790. },
  7791. has : function (str1, str2) {
  7792. if (typeof str1 === "string") {
  7793. return str2.toLowerCase().indexOf(str1.toLowerCase()) !== -1;
  7794. } else {
  7795. return false;
  7796. }
  7797. },
  7798. lowerize : function (str) {
  7799. return str.toLowerCase();
  7800. },
  7801. major : function (version) {
  7802. return typeof(version) === STR_TYPE ? version.replace(/[^\d\.]/g,'').split(".")[0] : undefined$1;
  7803. },
  7804. trim : function (str) {
  7805. return str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
  7806. }
  7807. };
  7808. ///////////////
  7809. // Map helper
  7810. //////////////
  7811. var mapper = {
  7812. rgx : function (ua, arrays) {
  7813. var i = 0, j, k, p, q, matches, match;
  7814. // loop through all regexes maps
  7815. while (i < arrays.length && !matches) {
  7816. var regex = arrays[i], // even sequence (0,2,4,..)
  7817. props = arrays[i + 1]; // odd sequence (1,3,5,..)
  7818. j = k = 0;
  7819. // try matching uastring with regexes
  7820. while (j < regex.length && !matches) {
  7821. matches = regex[j++].exec(ua);
  7822. if (!!matches) {
  7823. for (p = 0; p < props.length; p++) {
  7824. match = matches[++k];
  7825. q = props[p];
  7826. // check if given property is actually array
  7827. if (typeof q === OBJ_TYPE && q.length > 0) {
  7828. if (q.length == 2) {
  7829. if (typeof q[1] == FUNC_TYPE) {
  7830. // assign modified match
  7831. this[q[0]] = q[1].call(this, match);
  7832. } else {
  7833. // assign given value, ignore regex match
  7834. this[q[0]] = q[1];
  7835. }
  7836. } else if (q.length == 3) {
  7837. // check whether function or regex
  7838. if (typeof q[1] === FUNC_TYPE && !(q[1].exec && q[1].test)) {
  7839. // call function (usually string mapper)
  7840. this[q[0]] = match ? q[1].call(this, match, q[2]) : undefined$1;
  7841. } else {
  7842. // sanitize match using given regex
  7843. this[q[0]] = match ? match.replace(q[1], q[2]) : undefined$1;
  7844. }
  7845. } else if (q.length == 4) {
  7846. this[q[0]] = match ? q[3].call(this, match.replace(q[1], q[2])) : undefined$1;
  7847. }
  7848. } else {
  7849. this[q] = match ? match : undefined$1;
  7850. }
  7851. }
  7852. }
  7853. }
  7854. i += 2;
  7855. }
  7856. },
  7857. str : function (str, map) {
  7858. for (var i in map) {
  7859. // check if array
  7860. if (typeof map[i] === OBJ_TYPE && map[i].length > 0) {
  7861. for (var j = 0; j < map[i].length; j++) {
  7862. if (util.has(map[i][j], str)) {
  7863. return (i === UNKNOWN) ? undefined$1 : i;
  7864. }
  7865. }
  7866. } else if (util.has(map[i], str)) {
  7867. return (i === UNKNOWN) ? undefined$1 : i;
  7868. }
  7869. }
  7870. return str;
  7871. }
  7872. };
  7873. ///////////////
  7874. // String map
  7875. //////////////
  7876. var maps = {
  7877. browser : {
  7878. oldsafari : {
  7879. version : {
  7880. '1.0' : '/8',
  7881. '1.2' : '/1',
  7882. '1.3' : '/3',
  7883. '2.0' : '/412',
  7884. '2.0.2' : '/416',
  7885. '2.0.3' : '/417',
  7886. '2.0.4' : '/419',
  7887. '?' : '/'
  7888. }
  7889. }
  7890. },
  7891. device : {
  7892. amazon : {
  7893. model : {
  7894. 'Fire Phone' : ['SD', 'KF']
  7895. }
  7896. },
  7897. sprint : {
  7898. model : {
  7899. 'Evo Shift 4G' : '7373KT'
  7900. },
  7901. vendor : {
  7902. 'HTC' : 'APA',
  7903. 'Sprint' : 'Sprint'
  7904. }
  7905. }
  7906. },
  7907. os : {
  7908. windows : {
  7909. version : {
  7910. 'ME' : '4.90',
  7911. 'NT 3.11' : 'NT3.51',
  7912. 'NT 4.0' : 'NT4.0',
  7913. '2000' : 'NT 5.0',
  7914. 'XP' : ['NT 5.1', 'NT 5.2'],
  7915. 'Vista' : 'NT 6.0',
  7916. '7' : 'NT 6.1',
  7917. '8' : 'NT 6.2',
  7918. '8.1' : 'NT 6.3',
  7919. '10' : ['NT 6.4', 'NT 10.0'],
  7920. 'RT' : 'ARM'
  7921. }
  7922. }
  7923. }
  7924. };
  7925. //////////////
  7926. // Regex map
  7927. /////////////
  7928. var regexes = {
  7929. browser : [[
  7930. // Presto based
  7931. /(opera\smini)\/([\w\.-]+)/i, // Opera Mini
  7932. /(opera\s[mobiletab]+).+version\/([\w\.-]+)/i, // Opera Mobi/Tablet
  7933. /(opera).+version\/([\w\.]+)/i, // Opera > 9.80
  7934. /(opera)[\/\s]+([\w\.]+)/i // Opera < 9.80
  7935. ], [NAME, VERSION], [
  7936. /(opios)[\/\s]+([\w\.]+)/i // Opera mini on iphone >= 8.0
  7937. ], [[NAME, 'Opera Mini'], VERSION], [
  7938. /\s(opr)\/([\w\.]+)/i // Opera Webkit
  7939. ], [[NAME, 'Opera'], VERSION], [
  7940. // Mixed
  7941. /(kindle)\/([\w\.]+)/i, // Kindle
  7942. /(lunascape|maxthon|netfront|jasmine|blazer)[\/\s]?([\w\.]*)/i,
  7943. // Lunascape/Maxthon/Netfront/Jasmine/Blazer
  7944. // Trident based
  7945. /(avant\s|iemobile|slim)(?:browser)?[\/\s]?([\w\.]*)/i,
  7946. // Avant/IEMobile/SlimBrowser
  7947. /(bidubrowser|baidubrowser)[\/\s]?([\w\.]+)/i, // Baidu Browser
  7948. /(?:ms|\()(ie)\s([\w\.]+)/i, // Internet Explorer
  7949. // Webkit/KHTML based
  7950. /(rekonq)\/([\w\.]*)/i, // Rekonq
  7951. /(chromium|flock|rockmelt|midori|epiphany|silk|skyfire|ovibrowser|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon)\/([\w\.-]+)/i
  7952. // Chromium/Flock/RockMelt/Midori/Epiphany/Silk/Skyfire/Bolt/Iron/Iridium/PhantomJS/Bowser/QupZilla/Falkon
  7953. ], [NAME, VERSION], [
  7954. /(konqueror)\/([\w\.]+)/i // Konqueror
  7955. ], [[NAME, 'Konqueror'], VERSION], [
  7956. /(trident).+rv[:\s]([\w\.]+).+like\sgecko/i // IE11
  7957. ], [[NAME, 'IE'], VERSION], [
  7958. /(edge|edgios|edga|edg)\/((\d+)?[\w\.]+)/i // Microsoft Edge
  7959. ], [[NAME, 'Edge'], VERSION], [
  7960. /(yabrowser)\/([\w\.]+)/i // Yandex
  7961. ], [[NAME, 'Yandex'], VERSION], [
  7962. /(Avast)\/([\w\.]+)/i // Avast Secure Browser
  7963. ], [[NAME, 'Avast Secure Browser'], VERSION], [
  7964. /(AVG)\/([\w\.]+)/i // AVG Secure Browser
  7965. ], [[NAME, 'AVG Secure Browser'], VERSION], [
  7966. /(puffin)\/([\w\.]+)/i // Puffin
  7967. ], [[NAME, 'Puffin'], VERSION], [
  7968. /(focus)\/([\w\.]+)/i // Firefox Focus
  7969. ], [[NAME, 'Firefox Focus'], VERSION], [
  7970. /(opt)\/([\w\.]+)/i // Opera Touch
  7971. ], [[NAME, 'Opera Touch'], VERSION], [
  7972. /((?:[\s\/])uc?\s?browser|(?:juc.+)ucweb)[\/\s]?([\w\.]+)/i // UCBrowser
  7973. ], [[NAME, 'UCBrowser'], VERSION], [
  7974. /(comodo_dragon)\/([\w\.]+)/i // Comodo Dragon
  7975. ], [[NAME, /_/g, ' '], VERSION], [
  7976. /(windowswechat qbcore)\/([\w\.]+)/i // WeChat Desktop for Windows Built-in Browser
  7977. ], [[NAME, 'WeChat(Win) Desktop'], VERSION], [
  7978. /(micromessenger)\/([\w\.]+)/i // WeChat
  7979. ], [[NAME, 'WeChat'], VERSION], [
  7980. /(brave)\/([\w\.]+)/i // Brave browser
  7981. ], [[NAME, 'Brave'], VERSION], [
  7982. /(qqbrowserlite)\/([\w\.]+)/i // QQBrowserLite
  7983. ], [NAME, VERSION], [
  7984. /(QQ)\/([\d\.]+)/i // QQ, aka ShouQ
  7985. ], [NAME, VERSION], [
  7986. /m?(qqbrowser)[\/\s]?([\w\.]+)/i // QQBrowser
  7987. ], [NAME, VERSION], [
  7988. /(baiduboxapp)[\/\s]?([\w\.]+)/i // Baidu App
  7989. ], [NAME, VERSION], [
  7990. /(2345Explorer)[\/\s]?([\w\.]+)/i // 2345 Browser
  7991. ], [NAME, VERSION], [
  7992. /(MetaSr)[\/\s]?([\w\.]+)/i // SouGouBrowser
  7993. ], [NAME], [
  7994. /(LBBROWSER)/i // LieBao Browser
  7995. ], [NAME], [
  7996. /xiaomi\/miuibrowser\/([\w\.]+)/i // MIUI Browser
  7997. ], [VERSION, [NAME, 'MIUI Browser']], [
  7998. /;fbav\/([\w\.]+);/i // Facebook App for iOS & Android
  7999. ], [VERSION, [NAME, 'Facebook']], [
  8000. /safari\s(line)\/([\w\.]+)/i, // Line App for iOS
  8001. /android.+(line)\/([\w\.]+)\/iab/i // Line App for Android
  8002. ], [NAME, VERSION], [
  8003. /headlesschrome(?:\/([\w\.]+)|\s)/i // Chrome Headless
  8004. ], [VERSION, [NAME, 'Chrome Headless']], [
  8005. /\swv\).+(chrome)\/([\w\.]+)/i // Chrome WebView
  8006. ], [[NAME, /(.+)/, '$1 WebView'], VERSION], [
  8007. /((?:oculus|samsung)browser)\/([\w\.]+)/i
  8008. ], [[NAME, /(.+(?:g|us))(.+)/, '$1 $2'], VERSION], [ // Oculus / Samsung Browser
  8009. /android.+version\/([\w\.]+)\s+(?:mobile\s?safari|safari)*/i // Android Browser
  8010. ], [VERSION, [NAME, 'Android Browser']], [
  8011. /(sailfishbrowser)\/([\w\.]+)/i // Sailfish Browser
  8012. ], [[NAME, 'Sailfish Browser'], VERSION], [
  8013. /(chrome|omniweb|arora|[tizenoka]{5}\s?browser)\/v?([\w\.]+)/i
  8014. // Chrome/OmniWeb/Arora/Tizen/Nokia
  8015. ], [NAME, VERSION], [
  8016. /(dolfin)\/([\w\.]+)/i // Dolphin
  8017. ], [[NAME, 'Dolphin'], VERSION], [
  8018. /(qihu|qhbrowser|qihoobrowser|360browser)/i // 360
  8019. ], [[NAME, '360 Browser']], [
  8020. /((?:android.+)crmo|crios)\/([\w\.]+)/i // Chrome for Android/iOS
  8021. ], [[NAME, 'Chrome'], VERSION], [
  8022. /(coast)\/([\w\.]+)/i // Opera Coast
  8023. ], [[NAME, 'Opera Coast'], VERSION], [
  8024. /fxios\/([\w\.-]+)/i // Firefox for iOS
  8025. ], [VERSION, [NAME, 'Firefox']], [
  8026. /version\/([\w\.]+).+?mobile\/\w+\s(safari)/i // Mobile Safari
  8027. ], [VERSION, [NAME, 'Mobile Safari']], [
  8028. /version\/([\w\.]+).+?(mobile\s?safari|safari)/i // Safari & Safari Mobile
  8029. ], [VERSION, NAME], [
  8030. /webkit.+?(gsa)\/([\w\.]+).+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Google Search Appliance on iOS
  8031. ], [[NAME, 'GSA'], VERSION], [
  8032. /webkit.+?(mobile\s?safari|safari)(\/[\w\.]+)/i // Safari < 3.0
  8033. ], [NAME, [VERSION, mapper.str, maps.browser.oldsafari.version]], [
  8034. /(webkit|khtml)\/([\w\.]+)/i
  8035. ], [NAME, VERSION], [
  8036. // Gecko based
  8037. /(navigator|netscape)\/([\w\.-]+)/i // Netscape
  8038. ], [[NAME, 'Netscape'], VERSION], [
  8039. /(swiftfox)/i, // Swiftfox
  8040. /(icedragon|iceweasel|camino|chimera|fennec|maemo\sbrowser|minimo|conkeror)[\/\s]?([\w\.\+]+)/i,
  8041. // IceDragon/Iceweasel/Camino/Chimera/Fennec/Maemo/Minimo/Conkeror
  8042. /(firefox|seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([\w\.-]+)$/i,
  8043. // Firefox/SeaMonkey/K-Meleon/IceCat/IceApe/Firebird/Phoenix
  8044. /(mozilla)\/([\w\.]+).+rv\:.+gecko\/\d+/i, // Mozilla
  8045. // Other
  8046. /(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir)[\/\s]?([\w\.]+)/i,
  8047. // Polaris/Lynx/Dillo/iCab/Doris/Amaya/w3m/NetSurf/Sleipnir
  8048. /(links)\s\(([\w\.]+)/i, // Links
  8049. /(gobrowser)\/?([\w\.]*)/i, // GoBrowser
  8050. /(ice\s?browser)\/v?([\w\._]+)/i, // ICE Browser
  8051. /(mosaic)[\/\s]([\w\.]+)/i // Mosaic
  8052. ], [NAME, VERSION]
  8053. ],
  8054. cpu : [[
  8055. /(?:(amd|x(?:(?:86|64)[_-])?|wow|win)64)[;\)]/i // AMD64
  8056. ], [[ARCHITECTURE, 'amd64']], [
  8057. /(ia32(?=;))/i // IA32 (quicktime)
  8058. ], [[ARCHITECTURE, util.lowerize]], [
  8059. /((?:i[346]|x)86)[;\)]/i // IA32
  8060. ], [[ARCHITECTURE, 'ia32']], [
  8061. // PocketPC mistakenly identified as PowerPC
  8062. /windows\s(ce|mobile);\sppc;/i
  8063. ], [[ARCHITECTURE, 'arm']], [
  8064. /((?:ppc|powerpc)(?:64)?)(?:\smac|;|\))/i // PowerPC
  8065. ], [[ARCHITECTURE, /ower/, '', util.lowerize]], [
  8066. /(sun4\w)[;\)]/i // SPARC
  8067. ], [[ARCHITECTURE, 'sparc']], [
  8068. /((?:avr32|ia64(?=;))|68k(?=\))|arm(?:64|(?=v\d+[;l]))|(?=atmel\s)avr|(?:irix|mips|sparc)(?:64)?(?=;)|pa-risc)/i
  8069. // IA64, 68K, ARM/64, AVR/32, IRIX/64, MIPS/64, SPARC/64, PA-RISC
  8070. ], [[ARCHITECTURE, util.lowerize]]
  8071. ],
  8072. device : [[
  8073. /\((ipad|playbook);[\w\s\),;-]+(rim|apple)/i // iPad/PlayBook
  8074. ], [MODEL, VENDOR, [TYPE, TABLET]], [
  8075. /applecoremedia\/[\w\.]+ \((ipad)/ // iPad
  8076. ], [MODEL, [VENDOR, 'Apple'], [TYPE, TABLET]], [
  8077. /(apple\s{0,1}tv)/i // Apple TV
  8078. ], [[MODEL, 'Apple TV'], [VENDOR, 'Apple'], [TYPE, SMARTTV]], [
  8079. /(archos)\s(gamepad2?)/i, // Archos
  8080. /(hp).+(touchpad)/i, // HP TouchPad
  8081. /(hp).+(tablet)/i, // HP Tablet
  8082. /(kindle)\/([\w\.]+)/i, // Kindle
  8083. /\s(nook)[\w\s]+build\/(\w+)/i, // Nook
  8084. /(dell)\s(strea[kpr\s\d]*[\dko])/i // Dell Streak
  8085. ], [VENDOR, MODEL, [TYPE, TABLET]], [
  8086. /(kf[A-z]+)\sbuild\/.+silk\//i // Kindle Fire HD
  8087. ], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [
  8088. /(sd|kf)[0349hijorstuw]+\sbuild\/.+silk\//i // Fire Phone
  8089. ], [[MODEL, mapper.str, maps.device.amazon.model], [VENDOR, 'Amazon'], [TYPE, MOBILE]], [
  8090. /android.+aft([bms])\sbuild/i // Fire TV
  8091. ], [MODEL, [VENDOR, 'Amazon'], [TYPE, SMARTTV]], [
  8092. /\((ip[honed|\s\w*]+);.+(apple)/i // iPod/iPhone
  8093. ], [MODEL, VENDOR, [TYPE, MOBILE]], [
  8094. /\((ip[honed|\s\w*]+);/i // iPod/iPhone
  8095. ], [MODEL, [VENDOR, 'Apple'], [TYPE, MOBILE]], [
  8096. /(blackberry)[\s-]?(\w+)/i, // BlackBerry
  8097. /(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[\s_-]?([\w-]*)/i,
  8098. // BenQ/Palm/Sony-Ericsson/Acer/Asus/Dell/Meizu/Motorola/Polytron
  8099. /(hp)\s([\w\s]+\w)/i, // HP iPAQ
  8100. /(asus)-?(\w+)/i // Asus
  8101. ], [VENDOR, MODEL, [TYPE, MOBILE]], [
  8102. /\(bb10;\s(\w+)/i // BlackBerry 10
  8103. ], [MODEL, [VENDOR, 'BlackBerry'], [TYPE, MOBILE]], [
  8104. // Asus Tablets
  8105. /android.+(transfo[prime\s]{4,10}\s\w+|eeepc|slider\s\w+|nexus 7|padfone|p00c)/i
  8106. ], [MODEL, [VENDOR, 'Asus'], [TYPE, TABLET]], [
  8107. /(sony)\s(tablet\s[ps])\sbuild\//i, // Sony
  8108. /(sony)?(?:sgp.+)\sbuild\//i
  8109. ], [[VENDOR, 'Sony'], [MODEL, 'Xperia Tablet'], [TYPE, TABLET]], [
  8110. /android.+\s([c-g]\d{4}|so[-l]\w+)(?=\sbuild\/|\).+chrome\/(?![1-6]{0,1}\d\.))/i
  8111. ], [MODEL, [VENDOR, 'Sony'], [TYPE, MOBILE]], [
  8112. /\s(ouya)\s/i, // Ouya
  8113. /(nintendo)\s([wids3u]+)/i // Nintendo
  8114. ], [VENDOR, MODEL, [TYPE, CONSOLE]], [
  8115. /android.+;\s(shield)\sbuild/i // Nvidia
  8116. ], [MODEL, [VENDOR, 'Nvidia'], [TYPE, CONSOLE]], [
  8117. /(playstation\s[34portablevi]+)/i // Playstation
  8118. ], [MODEL, [VENDOR, 'Sony'], [TYPE, CONSOLE]], [
  8119. /(sprint\s(\w+))/i // Sprint Phones
  8120. ], [[VENDOR, mapper.str, maps.device.sprint.vendor], [MODEL, mapper.str, maps.device.sprint.model], [TYPE, MOBILE]], [
  8121. /(htc)[;_\s-]+([\w\s]+(?=\)|\sbuild)|\w+)/i, // HTC
  8122. /(zte)-(\w*)/i, // ZTE
  8123. /(alcatel|geeksphone|nexian|panasonic|(?=;\s)sony)[_\s-]?([\w-]*)/i
  8124. // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
  8125. ], [VENDOR, [MODEL, /_/g, ' '], [TYPE, MOBILE]], [
  8126. /(nexus\s9)/i // HTC Nexus 9
  8127. ], [MODEL, [VENDOR, 'HTC'], [TYPE, TABLET]], [
  8128. /d\/huawei([\w\s-]+)[;\)]/i,
  8129. /(nexus\s6p|vog-l29|ane-lx1|eml-l29)/i // Huawei
  8130. ], [MODEL, [VENDOR, 'Huawei'], [TYPE, MOBILE]], [
  8131. /android.+(bah2?-a?[lw]\d{2})/i // Huawei MediaPad
  8132. ], [MODEL, [VENDOR, 'Huawei'], [TYPE, TABLET]], [
  8133. /(microsoft);\s(lumia[\s\w]+)/i // Microsoft Lumia
  8134. ], [VENDOR, MODEL, [TYPE, MOBILE]], [
  8135. /[\s\(;](xbox(?:\sone)?)[\s\);]/i // Microsoft Xbox
  8136. ], [MODEL, [VENDOR, 'Microsoft'], [TYPE, CONSOLE]], [
  8137. /(kin\.[onetw]{3})/i // Microsoft Kin
  8138. ], [[MODEL, /\./g, ' '], [VENDOR, 'Microsoft'], [TYPE, MOBILE]], [
  8139. // Motorola
  8140. /\s(milestone|droid(?:[2-4x]|\s(?:bionic|x2|pro|razr))?:?(\s4g)?)[\w\s]+build\//i,
  8141. /mot[\s-]?(\w*)/i,
  8142. /(XT\d{3,4}) build\//i,
  8143. /(nexus\s6)/i
  8144. ], [MODEL, [VENDOR, 'Motorola'], [TYPE, MOBILE]], [
  8145. /android.+\s(mz60\d|xoom[\s2]{0,2})\sbuild\//i
  8146. ], [MODEL, [VENDOR, 'Motorola'], [TYPE, TABLET]], [
  8147. /hbbtv\/\d+\.\d+\.\d+\s+\([\w\s]*;\s*(\w[^;]*);([^;]*)/i // HbbTV devices
  8148. ], [[VENDOR, util.trim], [MODEL, util.trim], [TYPE, SMARTTV]], [
  8149. /hbbtv.+maple;(\d+)/i
  8150. ], [[MODEL, /^/, 'SmartTV'], [VENDOR, 'Samsung'], [TYPE, SMARTTV]], [
  8151. /\(dtv[\);].+(aquos)/i // Sharp
  8152. ], [MODEL, [VENDOR, 'Sharp'], [TYPE, SMARTTV]], [
  8153. /android.+((sch-i[89]0\d|shw-m380s|gt-p\d{4}|gt-n\d+|sgh-t8[56]9|nexus 10))/i,
  8154. /((SM-T\w+))/i
  8155. ], [[VENDOR, 'Samsung'], MODEL, [TYPE, TABLET]], [ // Samsung
  8156. /smart-tv.+(samsung)/i
  8157. ], [VENDOR, [TYPE, SMARTTV], MODEL], [
  8158. /((s[cgp]h-\w+|gt-\w+|galaxy\snexus|sm-\w[\w\d]+))/i,
  8159. /(sam[sung]*)[\s-]*(\w+-?[\w-]*)/i,
  8160. /sec-((sgh\w+))/i
  8161. ], [[VENDOR, 'Samsung'], MODEL, [TYPE, MOBILE]], [
  8162. /sie-(\w*)/i // Siemens
  8163. ], [MODEL, [VENDOR, 'Siemens'], [TYPE, MOBILE]], [
  8164. /(maemo|nokia).*(n900|lumia\s\d+)/i, // Nokia
  8165. /(nokia)[\s_-]?([\w-]*)/i
  8166. ], [[VENDOR, 'Nokia'], MODEL, [TYPE, MOBILE]], [
  8167. /android[x\d\.\s;]+\s([ab][1-7]\-?[0178a]\d\d?)/i // Acer
  8168. ], [MODEL, [VENDOR, 'Acer'], [TYPE, TABLET]], [
  8169. /android.+([vl]k\-?\d{3})\s+build/i // LG Tablet
  8170. ], [MODEL, [VENDOR, 'LG'], [TYPE, TABLET]], [
  8171. /android\s3\.[\s\w;-]{10}(lg?)-([06cv9]{3,4})/i // LG Tablet
  8172. ], [[VENDOR, 'LG'], MODEL, [TYPE, TABLET]], [
  8173. /(lg) netcast\.tv/i // LG SmartTV
  8174. ], [VENDOR, MODEL, [TYPE, SMARTTV]], [
  8175. /(nexus\s[45])/i, // LG
  8176. /lg[e;\s\/-]+(\w*)/i,
  8177. /android.+lg(\-?[\d\w]+)\s+build/i
  8178. ], [MODEL, [VENDOR, 'LG'], [TYPE, MOBILE]], [
  8179. /(lenovo)\s?(s(?:5000|6000)(?:[\w-]+)|tab(?:[\s\w]+))/i // Lenovo tablets
  8180. ], [VENDOR, MODEL, [TYPE, TABLET]], [
  8181. /android.+(ideatab[a-z0-9\-\s]+)/i // Lenovo
  8182. ], [MODEL, [VENDOR, 'Lenovo'], [TYPE, TABLET]], [
  8183. /(lenovo)[_\s-]?([\w-]+)/i
  8184. ], [VENDOR, MODEL, [TYPE, MOBILE]], [
  8185. /linux;.+((jolla));/i // Jolla
  8186. ], [VENDOR, MODEL, [TYPE, MOBILE]], [
  8187. /((pebble))app\/[\d\.]+\s/i // Pebble
  8188. ], [VENDOR, MODEL, [TYPE, WEARABLE]], [
  8189. /android.+;\s(oppo)\s?([\w\s]+)\sbuild/i // OPPO
  8190. ], [VENDOR, MODEL, [TYPE, MOBILE]], [
  8191. /crkey/i // Google Chromecast
  8192. ], [[MODEL, 'Chromecast'], [VENDOR, 'Google'], [TYPE, SMARTTV]], [
  8193. /android.+;\s(glass)\s\d/i // Google Glass
  8194. ], [MODEL, [VENDOR, 'Google'], [TYPE, WEARABLE]], [
  8195. /android.+;\s(pixel c)[\s)]/i // Google Pixel C
  8196. ], [MODEL, [VENDOR, 'Google'], [TYPE, TABLET]], [
  8197. /android.+;\s(pixel( [23])?( xl)?)[\s)]/i // Google Pixel
  8198. ], [MODEL, [VENDOR, 'Google'], [TYPE, MOBILE]], [
  8199. /android.+;\s(\w+)\s+build\/hm\1/i, // Xiaomi Hongmi 'numeric' models
  8200. /android.+(hm[\s\-_]*note?[\s_]*(?:\d\w)?)\s+build/i, // Xiaomi Hongmi
  8201. /android.+(mi[\s\-_]*(?:a\d|one|one[\s_]plus|note lte)?[\s_]*(?:\d?\w?)[\s_]*(?:plus)?)\s+build/i,
  8202. // Xiaomi Mi
  8203. /android.+(redmi[\s\-_]*(?:note)?(?:[\s_]*[\w\s]+))\s+build/i // Redmi Phones
  8204. ], [[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, MOBILE]], [
  8205. /android.+(mi[\s\-_]*(?:pad)(?:[\s_]*[\w\s]+))\s+build/i // Mi Pad tablets
  8206. ],[[MODEL, /_/g, ' '], [VENDOR, 'Xiaomi'], [TYPE, TABLET]], [
  8207. /android.+;\s(m[1-5]\snote)\sbuild/i // Meizu
  8208. ], [MODEL, [VENDOR, 'Meizu'], [TYPE, MOBILE]], [
  8209. /(mz)-([\w-]{2,})/i
  8210. ], [[VENDOR, 'Meizu'], MODEL, [TYPE, MOBILE]], [
  8211. /android.+a000(1)\s+build/i, // OnePlus
  8212. /android.+oneplus\s(a\d{4})[\s)]/i
  8213. ], [MODEL, [VENDOR, 'OnePlus'], [TYPE, MOBILE]], [
  8214. /android.+[;\/]\s*(RCT[\d\w]+)\s+build/i // RCA Tablets
  8215. ], [MODEL, [VENDOR, 'RCA'], [TYPE, TABLET]], [
  8216. /android.+[;\/\s]+(Venue[\d\s]{2,7})\s+build/i // Dell Venue Tablets
  8217. ], [MODEL, [VENDOR, 'Dell'], [TYPE, TABLET]], [
  8218. /android.+[;\/]\s*(Q[T|M][\d\w]+)\s+build/i // Verizon Tablet
  8219. ], [MODEL, [VENDOR, 'Verizon'], [TYPE, TABLET]], [
  8220. /android.+[;\/]\s+(Barnes[&\s]+Noble\s+|BN[RT])(V?.*)\s+build/i // Barnes & Noble Tablet
  8221. ], [[VENDOR, 'Barnes & Noble'], MODEL, [TYPE, TABLET]], [
  8222. /android.+[;\/]\s+(TM\d{3}.*\b)\s+build/i // Barnes & Noble Tablet
  8223. ], [MODEL, [VENDOR, 'NuVision'], [TYPE, TABLET]], [
  8224. /android.+;\s(k88)\sbuild/i // ZTE K Series Tablet
  8225. ], [MODEL, [VENDOR, 'ZTE'], [TYPE, TABLET]], [
  8226. /android.+[;\/]\s*(gen\d{3})\s+build.*49h/i // Swiss GEN Mobile
  8227. ], [MODEL, [VENDOR, 'Swiss'], [TYPE, MOBILE]], [
  8228. /android.+[;\/]\s*(zur\d{3})\s+build/i // Swiss ZUR Tablet
  8229. ], [MODEL, [VENDOR, 'Swiss'], [TYPE, TABLET]], [
  8230. /android.+[;\/]\s*((Zeki)?TB.*\b)\s+build/i // Zeki Tablets
  8231. ], [MODEL, [VENDOR, 'Zeki'], [TYPE, TABLET]], [
  8232. /(android).+[;\/]\s+([YR]\d{2})\s+build/i,
  8233. /android.+[;\/]\s+(Dragon[\-\s]+Touch\s+|DT)(\w{5})\sbuild/i // Dragon Touch Tablet
  8234. ], [[VENDOR, 'Dragon Touch'], MODEL, [TYPE, TABLET]], [
  8235. /android.+[;\/]\s*(NS-?\w{0,9})\sbuild/i // Insignia Tablets
  8236. ], [MODEL, [VENDOR, 'Insignia'], [TYPE, TABLET]], [
  8237. /android.+[;\/]\s*((NX|Next)-?\w{0,9})\s+build/i // NextBook Tablets
  8238. ], [MODEL, [VENDOR, 'NextBook'], [TYPE, TABLET]], [
  8239. /android.+[;\/]\s*(Xtreme\_)?(V(1[045]|2[015]|30|40|60|7[05]|90))\s+build/i
  8240. ], [[VENDOR, 'Voice'], MODEL, [TYPE, MOBILE]], [ // Voice Xtreme Phones
  8241. /android.+[;\/]\s*(LVTEL\-)?(V1[12])\s+build/i // LvTel Phones
  8242. ], [[VENDOR, 'LvTel'], MODEL, [TYPE, MOBILE]], [
  8243. /android.+;\s(PH-1)\s/i
  8244. ], [MODEL, [VENDOR, 'Essential'], [TYPE, MOBILE]], [ // Essential PH-1
  8245. /android.+[;\/]\s*(V(100MD|700NA|7011|917G).*\b)\s+build/i // Envizen Tablets
  8246. ], [MODEL, [VENDOR, 'Envizen'], [TYPE, TABLET]], [
  8247. /android.+[;\/]\s*(Le[\s\-]+Pan)[\s\-]+(\w{1,9})\s+build/i // Le Pan Tablets
  8248. ], [VENDOR, MODEL, [TYPE, TABLET]], [
  8249. /android.+[;\/]\s*(Trio[\s\-]*.*)\s+build/i // MachSpeed Tablets
  8250. ], [MODEL, [VENDOR, 'MachSpeed'], [TYPE, TABLET]], [
  8251. /android.+[;\/]\s*(Trinity)[\-\s]*(T\d{3})\s+build/i // Trinity Tablets
  8252. ], [VENDOR, MODEL, [TYPE, TABLET]], [
  8253. /android.+[;\/]\s*TU_(1491)\s+build/i // Rotor Tablets
  8254. ], [MODEL, [VENDOR, 'Rotor'], [TYPE, TABLET]], [
  8255. /android.+(KS(.+))\s+build/i // Amazon Kindle Tablets
  8256. ], [MODEL, [VENDOR, 'Amazon'], [TYPE, TABLET]], [
  8257. /android.+(Gigaset)[\s\-]+(Q\w{1,9})\s+build/i // Gigaset Tablets
  8258. ], [VENDOR, MODEL, [TYPE, TABLET]], [
  8259. /\s(tablet|tab)[;\/]/i, // Unidentifiable Tablet
  8260. /\s(mobile)(?:[;\/]|\ssafari)/i // Unidentifiable Mobile
  8261. ], [[TYPE, util.lowerize], VENDOR, MODEL], [
  8262. /[\s\/\(](smart-?tv)[;\)]/i // SmartTV
  8263. ], [[TYPE, SMARTTV]], [
  8264. /(android[\w\.\s\-]{0,9});.+build/i // Generic Android Device
  8265. ], [MODEL, [VENDOR, 'Generic']]
  8266. ],
  8267. engine : [[
  8268. /windows.+\sedge\/([\w\.]+)/i // EdgeHTML
  8269. ], [VERSION, [NAME, 'EdgeHTML']], [
  8270. /webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i // Blink
  8271. ], [VERSION, [NAME, 'Blink']], [
  8272. /(presto)\/([\w\.]+)/i, // Presto
  8273. /(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,
  8274. // WebKit/Trident/NetFront/NetSurf/Amaya/Lynx/w3m/Goanna
  8275. /(khtml|tasman|links)[\/\s]\(?([\w\.]+)/i, // KHTML/Tasman/Links
  8276. /(icab)[\/\s]([23]\.[\d\.]+)/i // iCab
  8277. ], [NAME, VERSION], [
  8278. /rv\:([\w\.]{1,9}).+(gecko)/i // Gecko
  8279. ], [VERSION, NAME]
  8280. ],
  8281. os : [[
  8282. // Windows based
  8283. /microsoft\s(windows)\s(vista|xp)/i // Windows (iTunes)
  8284. ], [NAME, VERSION], [
  8285. /(windows)\snt\s6\.2;\s(arm)/i, // Windows RT
  8286. /(windows\sphone(?:\sos)*)[\s\/]?([\d\.\s\w]*)/i, // Windows Phone
  8287. /(windows\smobile|windows)[\s\/]?([ntce\d\.\s]+\w)/i
  8288. ], [NAME, [VERSION, mapper.str, maps.os.windows.version]], [
  8289. /(win(?=3|9|n)|win\s9x\s)([nt\d\.]+)/i
  8290. ], [[NAME, 'Windows'], [VERSION, mapper.str, maps.os.windows.version]], [
  8291. // Mobile/Embedded OS
  8292. /\((bb)(10);/i // BlackBerry 10
  8293. ], [[NAME, 'BlackBerry'], VERSION], [
  8294. /(blackberry)\w*\/?([\w\.]*)/i, // Blackberry
  8295. /(tizen|kaios)[\/\s]([\w\.]+)/i, // Tizen/KaiOS
  8296. /(android|webos|palm\sos|qnx|bada|rim\stablet\sos|meego|sailfish|contiki)[\/\s-]?([\w\.]*)/i
  8297. // Android/WebOS/Palm/QNX/Bada/RIM/MeeGo/Contiki/Sailfish OS
  8298. ], [NAME, VERSION], [
  8299. /(symbian\s?os|symbos|s60(?=;))[\/\s-]?([\w\.]*)/i // Symbian
  8300. ], [[NAME, 'Symbian'], VERSION], [
  8301. /\((series40);/i // Series 40
  8302. ], [NAME], [
  8303. /mozilla.+\(mobile;.+gecko.+firefox/i // Firefox OS
  8304. ], [[NAME, 'Firefox OS'], VERSION], [
  8305. // Console
  8306. /(nintendo|playstation)\s([wids34portablevu]+)/i, // Nintendo/Playstation
  8307. // GNU/Linux based
  8308. /(mint)[\/\s\(]?(\w*)/i, // Mint
  8309. /(mageia|vectorlinux)[;\s]/i, // Mageia/VectorLinux
  8310. /(joli|[kxln]?ubuntu|debian|suse|opensuse|gentoo|(?=\s)arch|slackware|fedora|mandriva|centos|pclinuxos|redhat|zenwalk|linpus)[\/\s-]?(?!chrom)([\w\.-]*)/i,
  8311. // Joli/Ubuntu/Debian/SUSE/Gentoo/Arch/Slackware
  8312. // Fedora/Mandriva/CentOS/PCLinuxOS/RedHat/Zenwalk/Linpus
  8313. /(hurd|linux)\s?([\w\.]*)/i, // Hurd/Linux
  8314. /(gnu)\s?([\w\.]*)/i // GNU
  8315. ], [NAME, VERSION], [
  8316. /(cros)\s[\w]+\s([\w\.]+\w)/i // Chromium OS
  8317. ], [[NAME, 'Chromium OS'], VERSION],[
  8318. // Solaris
  8319. /(sunos)\s?([\w\.\d]*)/i // Solaris
  8320. ], [[NAME, 'Solaris'], VERSION], [
  8321. // BSD based
  8322. /\s([frentopc-]{0,4}bsd|dragonfly)\s?([\w\.]*)/i // FreeBSD/NetBSD/OpenBSD/PC-BSD/DragonFly
  8323. ], [NAME, VERSION],[
  8324. /(haiku)\s(\w+)/i // Haiku
  8325. ], [NAME, VERSION],[
  8326. /cfnetwork\/.+darwin/i,
  8327. /ip[honead]{2,4}(?:.*os\s([\w]+)\slike\smac|;\sopera)/i // iOS
  8328. ], [[VERSION, /_/g, '.'], [NAME, 'iOS']], [
  8329. /(mac\sos\sx)\s?([\w\s\.]*)/i,
  8330. /(macintosh|mac(?=_powerpc)\s)/i // Mac OS
  8331. ], [[NAME, 'Mac OS'], [VERSION, /_/g, '.']], [
  8332. // Other
  8333. /((?:open)?solaris)[\/\s-]?([\w\.]*)/i, // Solaris
  8334. /(aix)\s((\d)(?=\.|\)|\s)[\w\.])*/i, // AIX
  8335. /(plan\s9|minix|beos|os\/2|amigaos|morphos|risc\sos|openvms|fuchsia)/i,
  8336. // Plan9/Minix/BeOS/OS2/AmigaOS/MorphOS/RISCOS/OpenVMS/Fuchsia
  8337. /(unix)\s?([\w\.]*)/i // UNIX
  8338. ], [NAME, VERSION]
  8339. ]
  8340. };
  8341. /////////////////
  8342. // Constructor
  8343. ////////////////
  8344. var UAParser = function (uastring, extensions) {
  8345. if (typeof uastring === 'object') {
  8346. extensions = uastring;
  8347. uastring = undefined$1;
  8348. }
  8349. if (!(this instanceof UAParser)) {
  8350. return new UAParser(uastring, extensions).getResult();
  8351. }
  8352. var ua = uastring || ((window && window.navigator && window.navigator.userAgent) ? window.navigator.userAgent : EMPTY);
  8353. var rgxmap = extensions ? util.extend(regexes, extensions) : regexes;
  8354. this.getBrowser = function () {
  8355. var browser = { name: undefined$1, version: undefined$1 };
  8356. mapper.rgx.call(browser, ua, rgxmap.browser);
  8357. browser.major = util.major(browser.version); // deprecated
  8358. return browser;
  8359. };
  8360. this.getCPU = function () {
  8361. var cpu = { architecture: undefined$1 };
  8362. mapper.rgx.call(cpu, ua, rgxmap.cpu);
  8363. return cpu;
  8364. };
  8365. this.getDevice = function () {
  8366. var device = { vendor: undefined$1, model: undefined$1, type: undefined$1 };
  8367. mapper.rgx.call(device, ua, rgxmap.device);
  8368. return device;
  8369. };
  8370. this.getEngine = function () {
  8371. var engine = { name: undefined$1, version: undefined$1 };
  8372. mapper.rgx.call(engine, ua, rgxmap.engine);
  8373. return engine;
  8374. };
  8375. this.getOS = function () {
  8376. var os = { name: undefined$1, version: undefined$1 };
  8377. mapper.rgx.call(os, ua, rgxmap.os);
  8378. return os;
  8379. };
  8380. this.getResult = function () {
  8381. return {
  8382. ua : this.getUA(),
  8383. browser : this.getBrowser(),
  8384. engine : this.getEngine(),
  8385. os : this.getOS(),
  8386. device : this.getDevice(),
  8387. cpu : this.getCPU()
  8388. };
  8389. };
  8390. this.getUA = function () {
  8391. return ua;
  8392. };
  8393. this.setUA = function (uastring) {
  8394. ua = uastring;
  8395. return this;
  8396. };
  8397. return this;
  8398. };
  8399. UAParser.VERSION = LIBVERSION;
  8400. UAParser.BROWSER = {
  8401. NAME : NAME,
  8402. MAJOR : MAJOR, // deprecated
  8403. VERSION : VERSION
  8404. };
  8405. UAParser.CPU = {
  8406. ARCHITECTURE : ARCHITECTURE
  8407. };
  8408. UAParser.DEVICE = {
  8409. MODEL : MODEL,
  8410. VENDOR : VENDOR,
  8411. TYPE : TYPE,
  8412. CONSOLE : CONSOLE,
  8413. MOBILE : MOBILE,
  8414. SMARTTV : SMARTTV,
  8415. TABLET : TABLET,
  8416. WEARABLE: WEARABLE,
  8417. EMBEDDED: EMBEDDED
  8418. };
  8419. UAParser.ENGINE = {
  8420. NAME : NAME,
  8421. VERSION : VERSION
  8422. };
  8423. UAParser.OS = {
  8424. NAME : NAME,
  8425. VERSION : VERSION
  8426. };
  8427. ///////////
  8428. // Export
  8429. //////////
  8430. // check js environment
  8431. {
  8432. // nodejs env
  8433. if ( module.exports) {
  8434. exports = module.exports = UAParser;
  8435. }
  8436. exports.UAParser = UAParser;
  8437. }
  8438. // jQuery/Zepto specific (optional)
  8439. // Note:
  8440. // In AMD env the global scope should be kept clean, but jQuery is an exception.
  8441. // jQuery always exports to global scope, unless jQuery.noConflict(true) is used,
  8442. // and we should catch that.
  8443. var $ = window && (window.jQuery || window.Zepto);
  8444. if ($ && !$.ua) {
  8445. var parser = new UAParser();
  8446. $.ua = parser.getResult();
  8447. $.ua.get = function () {
  8448. return parser.getUA();
  8449. };
  8450. $.ua.set = function (uastring) {
  8451. parser.setUA(uastring);
  8452. var result = parser.getResult();
  8453. for (var prop in result) {
  8454. $.ua[prop] = result[prop];
  8455. }
  8456. };
  8457. }
  8458. })(typeof window === 'object' ? window : index.commonjsGlobal);
  8459. });
  8460. var uaParser_1 = uaParser.UAParser;
  8461. var UNKNOWN = 'Unknown';
  8462. var PLATFORM_MAP = {
  8463. 'Mac OS': 'Mac OS X'
  8464. };
  8465. /**
  8466. * Convert from UAParser platform name to what we expect.
  8467. */
  8468. function convertPlatformName(name) {
  8469. return PLATFORM_MAP[name] || name;
  8470. }
  8471. /**
  8472. * Get the version number in parts. This is very naive. We actually get major
  8473. * version as a part of UAParser already, which is generally good enough, but
  8474. * let's get the minor just in case.
  8475. */
  8476. function getBrowserVersion(version) {
  8477. if (!version) {
  8478. return {
  8479. major: '',
  8480. minor: ''
  8481. };
  8482. }
  8483. var parts = version.split('.');
  8484. return {
  8485. major: parts[0],
  8486. minor: parts[1]
  8487. };
  8488. }
  8489. /**
  8490. * Get the UA data fom UAParser and then convert it to the format we're
  8491. * expecting for our APIS.
  8492. */
  8493. var parser = new uaParser();
  8494. var results = parser.getResult();
  8495. // Do some conversion first.
  8496. var browserVersionData = getBrowserVersion(results.browser.version);
  8497. var uaData = {
  8498. browserArchitecture: results.cpu.architecture || UNKNOWN,
  8499. browserFullVersion: results.browser.version || UNKNOWN,
  8500. browserMinorVersion: browserVersionData.minor || UNKNOWN,
  8501. browserName: results.browser.name || UNKNOWN,
  8502. browserVersion: results.browser.major || UNKNOWN,
  8503. deviceName: results.device.model || UNKNOWN,
  8504. engineName: results.engine.name || UNKNOWN,
  8505. engineVersion: results.engine.version || UNKNOWN,
  8506. platformArchitecture: results.cpu.architecture || UNKNOWN,
  8507. platformName: convertPlatformName(results.os.name) || UNKNOWN,
  8508. platformVersion: results.os.version || UNKNOWN,
  8509. platformFullVersion: results.os.version || UNKNOWN
  8510. };
  8511. var UserAgentData = uaData;
  8512. var componentRegex = /\./;
  8513. var orRegex = /\|\|/;
  8514. var rangeRegex = /\s+\-\s+/;
  8515. var modifierRegex = /^(<=|<|=|>=|~>|~|>|)?\s*(.+)/;
  8516. var numericRegex = /^(\d*)(.*)/;
  8517. /**
  8518. * Splits input `range` on "||" and returns true if any subrange matches
  8519. * `version`.
  8520. *
  8521. * @param {string} range
  8522. * @param {string} version
  8523. * @returns {boolean}
  8524. */
  8525. function checkOrExpression(range, version) {
  8526. var expressions = range.split(orRegex);
  8527. if (expressions.length > 1) {
  8528. return expressions.some(function (range) {
  8529. return VersionRange.contains(range, version);
  8530. });
  8531. } else {
  8532. range = expressions[0].trim();
  8533. return checkRangeExpression(range, version);
  8534. }
  8535. }
  8536. /**
  8537. * Splits input `range` on " - " (the surrounding whitespace is required) and
  8538. * returns true if version falls between the two operands.
  8539. *
  8540. * @param {string} range
  8541. * @param {string} version
  8542. * @returns {boolean}
  8543. */
  8544. function checkRangeExpression(range, version) {
  8545. var expressions = range.split(rangeRegex);
  8546. !(expressions.length > 0 && expressions.length <= 2) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'the "-" operator expects exactly 2 operands') : invariant_1(false) : void 0;
  8547. if (expressions.length === 1) {
  8548. return checkSimpleExpression(expressions[0], version);
  8549. } else {
  8550. var startVersion = expressions[0],
  8551. endVersion = expressions[1];
  8552. !(isSimpleVersion(startVersion) && isSimpleVersion(endVersion)) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'operands to the "-" operator must be simple (no modifiers)') : invariant_1(false) : void 0;
  8553. return checkSimpleExpression('>=' + startVersion, version) && checkSimpleExpression('<=' + endVersion, version);
  8554. }
  8555. }
  8556. /**
  8557. * Checks if `range` matches `version`. `range` should be a "simple" range (ie.
  8558. * not a compound range using the " - " or "||" operators).
  8559. *
  8560. * @param {string} range
  8561. * @param {string} version
  8562. * @returns {boolean}
  8563. */
  8564. function checkSimpleExpression(range, version) {
  8565. range = range.trim();
  8566. if (range === '') {
  8567. return true;
  8568. }
  8569. var versionComponents = version.split(componentRegex);
  8570. var _getModifierAndCompon = getModifierAndComponents(range),
  8571. modifier = _getModifierAndCompon.modifier,
  8572. rangeComponents = _getModifierAndCompon.rangeComponents;
  8573. switch (modifier) {
  8574. case '<':
  8575. return checkLessThan(versionComponents, rangeComponents);
  8576. case '<=':
  8577. return checkLessThanOrEqual(versionComponents, rangeComponents);
  8578. case '>=':
  8579. return checkGreaterThanOrEqual(versionComponents, rangeComponents);
  8580. case '>':
  8581. return checkGreaterThan(versionComponents, rangeComponents);
  8582. case '~':
  8583. case '~>':
  8584. return checkApproximateVersion(versionComponents, rangeComponents);
  8585. default:
  8586. return checkEqual(versionComponents, rangeComponents);
  8587. }
  8588. }
  8589. /**
  8590. * Checks whether `a` is less than `b`.
  8591. *
  8592. * @param {array<string>} a
  8593. * @param {array<string>} b
  8594. * @returns {boolean}
  8595. */
  8596. function checkLessThan(a, b) {
  8597. return compareComponents(a, b) === -1;
  8598. }
  8599. /**
  8600. * Checks whether `a` is less than or equal to `b`.
  8601. *
  8602. * @param {array<string>} a
  8603. * @param {array<string>} b
  8604. * @returns {boolean}
  8605. */
  8606. function checkLessThanOrEqual(a, b) {
  8607. var result = compareComponents(a, b);
  8608. return result === -1 || result === 0;
  8609. }
  8610. /**
  8611. * Checks whether `a` is equal to `b`.
  8612. *
  8613. * @param {array<string>} a
  8614. * @param {array<string>} b
  8615. * @returns {boolean}
  8616. */
  8617. function checkEqual(a, b) {
  8618. return compareComponents(a, b) === 0;
  8619. }
  8620. /**
  8621. * Checks whether `a` is greater than or equal to `b`.
  8622. *
  8623. * @param {array<string>} a
  8624. * @param {array<string>} b
  8625. * @returns {boolean}
  8626. */
  8627. function checkGreaterThanOrEqual(a, b) {
  8628. var result = compareComponents(a, b);
  8629. return result === 1 || result === 0;
  8630. }
  8631. /**
  8632. * Checks whether `a` is greater than `b`.
  8633. *
  8634. * @param {array<string>} a
  8635. * @param {array<string>} b
  8636. * @returns {boolean}
  8637. */
  8638. function checkGreaterThan(a, b) {
  8639. return compareComponents(a, b) === 1;
  8640. }
  8641. /**
  8642. * Checks whether `a` is "reasonably close" to `b` (as described in
  8643. * https://www.npmjs.org/doc/misc/semver.html). For example, if `b` is "1.3.1"
  8644. * then "reasonably close" is defined as ">= 1.3.1 and < 1.4".
  8645. *
  8646. * @param {array<string>} a
  8647. * @param {array<string>} b
  8648. * @returns {boolean}
  8649. */
  8650. function checkApproximateVersion(a, b) {
  8651. var lowerBound = b.slice();
  8652. var upperBound = b.slice();
  8653. if (upperBound.length > 1) {
  8654. upperBound.pop();
  8655. }
  8656. var lastIndex = upperBound.length - 1;
  8657. var numeric = parseInt(upperBound[lastIndex], 10);
  8658. if (isNumber(numeric)) {
  8659. upperBound[lastIndex] = numeric + 1 + '';
  8660. }
  8661. return checkGreaterThanOrEqual(a, lowerBound) && checkLessThan(a, upperBound);
  8662. }
  8663. /**
  8664. * Extracts the optional modifier (<, <=, =, >=, >, ~, ~>) and version
  8665. * components from `range`.
  8666. *
  8667. * For example, given `range` ">= 1.2.3" returns an object with a `modifier` of
  8668. * `">="` and `components` of `[1, 2, 3]`.
  8669. *
  8670. * @param {string} range
  8671. * @returns {object}
  8672. */
  8673. function getModifierAndComponents(range) {
  8674. var rangeComponents = range.split(componentRegex);
  8675. var matches = rangeComponents[0].match(modifierRegex);
  8676. !matches ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'expected regex to match but it did not') : invariant_1(false) : void 0;
  8677. return {
  8678. modifier: matches[1],
  8679. rangeComponents: [matches[2]].concat(rangeComponents.slice(1))
  8680. };
  8681. }
  8682. /**
  8683. * Determines if `number` is a number.
  8684. *
  8685. * @param {mixed} number
  8686. * @returns {boolean}
  8687. */
  8688. function isNumber(number) {
  8689. return !isNaN(number) && isFinite(number);
  8690. }
  8691. /**
  8692. * Tests whether `range` is a "simple" version number without any modifiers
  8693. * (">", "~" etc).
  8694. *
  8695. * @param {string} range
  8696. * @returns {boolean}
  8697. */
  8698. function isSimpleVersion(range) {
  8699. return !getModifierAndComponents(range).modifier;
  8700. }
  8701. /**
  8702. * Zero-pads array `array` until it is at least `length` long.
  8703. *
  8704. * @param {array} array
  8705. * @param {number} length
  8706. */
  8707. function zeroPad(array, length) {
  8708. for (var i = array.length; i < length; i++) {
  8709. array[i] = '0';
  8710. }
  8711. }
  8712. /**
  8713. * Normalizes `a` and `b` in preparation for comparison by doing the following:
  8714. *
  8715. * - zero-pads `a` and `b`
  8716. * - marks any "x", "X" or "*" component in `b` as equivalent by zero-ing it out
  8717. * in both `a` and `b`
  8718. * - marks any final "*" component in `b` as a greedy wildcard by zero-ing it
  8719. * and all of its successors in `a`
  8720. *
  8721. * @param {array<string>} a
  8722. * @param {array<string>} b
  8723. * @returns {array<array<string>>}
  8724. */
  8725. function normalizeVersions(a, b) {
  8726. a = a.slice();
  8727. b = b.slice();
  8728. zeroPad(a, b.length);
  8729. // mark "x" and "*" components as equal
  8730. for (var i = 0; i < b.length; i++) {
  8731. var matches = b[i].match(/^[x*]$/i);
  8732. if (matches) {
  8733. b[i] = a[i] = '0';
  8734. // final "*" greedily zeros all remaining components
  8735. if (matches[0] === '*' && i === b.length - 1) {
  8736. for (var j = i; j < a.length; j++) {
  8737. a[j] = '0';
  8738. }
  8739. }
  8740. }
  8741. }
  8742. zeroPad(b, a.length);
  8743. return [a, b];
  8744. }
  8745. /**
  8746. * Returns the numerical -- not the lexicographical -- ordering of `a` and `b`.
  8747. *
  8748. * For example, `10-alpha` is greater than `2-beta`.
  8749. *
  8750. * @param {string} a
  8751. * @param {string} b
  8752. * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
  8753. * or greater than `b`, respectively
  8754. */
  8755. function compareNumeric(a, b) {
  8756. var aPrefix = a.match(numericRegex)[1];
  8757. var bPrefix = b.match(numericRegex)[1];
  8758. var aNumeric = parseInt(aPrefix, 10);
  8759. var bNumeric = parseInt(bPrefix, 10);
  8760. if (isNumber(aNumeric) && isNumber(bNumeric) && aNumeric !== bNumeric) {
  8761. return compare(aNumeric, bNumeric);
  8762. } else {
  8763. return compare(a, b);
  8764. }
  8765. }
  8766. /**
  8767. * Returns the ordering of `a` and `b`.
  8768. *
  8769. * @param {string|number} a
  8770. * @param {string|number} b
  8771. * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
  8772. * or greater than `b`, respectively
  8773. */
  8774. function compare(a, b) {
  8775. !(typeof a === typeof b) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, '"a" and "b" must be of the same type') : invariant_1(false) : void 0;
  8776. if (a > b) {
  8777. return 1;
  8778. } else if (a < b) {
  8779. return -1;
  8780. } else {
  8781. return 0;
  8782. }
  8783. }
  8784. /**
  8785. * Compares arrays of version components.
  8786. *
  8787. * @param {array<string>} a
  8788. * @param {array<string>} b
  8789. * @returns {number} -1, 0 or 1 to indicate whether `a` is less than, equal to,
  8790. * or greater than `b`, respectively
  8791. */
  8792. function compareComponents(a, b) {
  8793. var _normalizeVersions = normalizeVersions(a, b),
  8794. aNormalized = _normalizeVersions[0],
  8795. bNormalized = _normalizeVersions[1];
  8796. for (var i = 0; i < bNormalized.length; i++) {
  8797. var result = compareNumeric(aNormalized[i], bNormalized[i]);
  8798. if (result) {
  8799. return result;
  8800. }
  8801. }
  8802. return 0;
  8803. }
  8804. var VersionRange = {
  8805. /**
  8806. * Checks whether `version` satisfies the `range` specification.
  8807. *
  8808. * We support a subset of the expressions defined in
  8809. * https://www.npmjs.org/doc/misc/semver.html:
  8810. *
  8811. * version Must match version exactly
  8812. * =version Same as just version
  8813. * >version Must be greater than version
  8814. * >=version Must be greater than or equal to version
  8815. * <version Must be less than version
  8816. * <=version Must be less than or equal to version
  8817. * ~version Must be at least version, but less than the next significant
  8818. * revision above version:
  8819. * "~1.2.3" is equivalent to ">= 1.2.3 and < 1.3"
  8820. * ~>version Equivalent to ~version
  8821. * 1.2.x Must match "1.2.x", where "x" is a wildcard that matches
  8822. * anything
  8823. * 1.2.* Similar to "1.2.x", but "*" in the trailing position is a
  8824. * "greedy" wildcard, so will match any number of additional
  8825. * components:
  8826. * "1.2.*" will match "1.2.1", "1.2.1.1", "1.2.1.1.1" etc
  8827. * * Any version
  8828. * "" (Empty string) Same as *
  8829. * v1 - v2 Equivalent to ">= v1 and <= v2"
  8830. * r1 || r2 Passes if either r1 or r2 are satisfied
  8831. *
  8832. * @param {string} range
  8833. * @param {string} version
  8834. * @returns {boolean}
  8835. */
  8836. contains: function contains(range, version) {
  8837. return checkOrExpression(range.trim(), version.trim());
  8838. }
  8839. };
  8840. var VersionRange_1 = VersionRange;
  8841. /**
  8842. * Copyright (c) 2013-present, Facebook, Inc.
  8843. *
  8844. * This source code is licensed under the MIT license found in the
  8845. * LICENSE file in the root directory of this source tree.
  8846. *
  8847. */
  8848. var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
  8849. /**
  8850. * Executes the provided `callback` once for each enumerable own property in the
  8851. * object and constructs a new object from the results. The `callback` is
  8852. * invoked with three arguments:
  8853. *
  8854. * - the property value
  8855. * - the property name
  8856. * - the object being traversed
  8857. *
  8858. * Properties that are added after the call to `mapObject` will not be visited
  8859. * by `callback`. If the values of existing properties are changed, the value
  8860. * passed to `callback` will be the value at the time `mapObject` visits them.
  8861. * Properties that are deleted before being visited are not visited.
  8862. *
  8863. * @grep function objectMap()
  8864. * @grep function objMap()
  8865. *
  8866. * @param {?object} object
  8867. * @param {function} callback
  8868. * @param {*} context
  8869. * @return {?object}
  8870. */
  8871. function mapObject(object, callback, context) {
  8872. if (!object) {
  8873. return null;
  8874. }
  8875. var result = {};
  8876. for (var name in object) {
  8877. if (hasOwnProperty$1.call(object, name)) {
  8878. result[name] = callback.call(context, object[name], name, object);
  8879. }
  8880. }
  8881. return result;
  8882. }
  8883. var mapObject_1 = mapObject;
  8884. /**
  8885. * Copyright (c) 2013-present, Facebook, Inc.
  8886. *
  8887. * This source code is licensed under the MIT license found in the
  8888. * LICENSE file in the root directory of this source tree.
  8889. *
  8890. *
  8891. * @typechecks static-only
  8892. */
  8893. /**
  8894. * Memoizes the return value of a function that accepts one string argument.
  8895. */
  8896. function memoizeStringOnly(callback) {
  8897. var cache = {};
  8898. return function (string) {
  8899. if (!cache.hasOwnProperty(string)) {
  8900. cache[string] = callback.call(this, string);
  8901. }
  8902. return cache[string];
  8903. };
  8904. }
  8905. var memoizeStringOnly_1 = memoizeStringOnly;
  8906. /**
  8907. * Checks to see whether `name` and `version` satisfy `query`.
  8908. *
  8909. * @param {string} name Name of the browser, device, engine or platform
  8910. * @param {?string} version Version of the browser, engine or platform
  8911. * @param {string} query Query of form "Name [range expression]"
  8912. * @param {?function} normalizer Optional pre-processor for range expression
  8913. * @return {boolean}
  8914. */
  8915. function compare$1(name, version, query, normalizer) {
  8916. // check for exact match with no version
  8917. if (name === query) {
  8918. return true;
  8919. }
  8920. // check for non-matching names
  8921. if (!query.startsWith(name)) {
  8922. return false;
  8923. }
  8924. // full comparison with version
  8925. var range = query.slice(name.length);
  8926. if (version) {
  8927. range = normalizer ? normalizer(range) : range;
  8928. return VersionRange_1.contains(range, version);
  8929. }
  8930. return false;
  8931. }
  8932. /**
  8933. * Normalizes `version` by stripping any "NT" prefix, but only on the Windows
  8934. * platform.
  8935. *
  8936. * Mimics the stripping performed by the `UserAgentWindowsPlatform` PHP class.
  8937. *
  8938. * @param {string} version
  8939. * @return {string}
  8940. */
  8941. function normalizePlatformVersion(version) {
  8942. if (UserAgentData.platformName === 'Windows') {
  8943. return version.replace(/^\s*NT/, '');
  8944. }
  8945. return version;
  8946. }
  8947. /**
  8948. * Provides client-side access to the authoritative PHP-generated User Agent
  8949. * information supplied by the server.
  8950. */
  8951. var UserAgent = {
  8952. /**
  8953. * Check if the User Agent browser matches `query`.
  8954. *
  8955. * `query` should be a string like "Chrome" or "Chrome > 33".
  8956. *
  8957. * Valid browser names include:
  8958. *
  8959. * - ACCESS NetFront
  8960. * - AOL
  8961. * - Amazon Silk
  8962. * - Android
  8963. * - BlackBerry
  8964. * - BlackBerry PlayBook
  8965. * - Chrome
  8966. * - Chrome for iOS
  8967. * - Chrome frame
  8968. * - Facebook PHP SDK
  8969. * - Facebook for iOS
  8970. * - Firefox
  8971. * - IE
  8972. * - IE Mobile
  8973. * - Mobile Safari
  8974. * - Motorola Internet Browser
  8975. * - Nokia
  8976. * - Openwave Mobile Browser
  8977. * - Opera
  8978. * - Opera Mini
  8979. * - Opera Mobile
  8980. * - Safari
  8981. * - UIWebView
  8982. * - Unknown
  8983. * - webOS
  8984. * - etc...
  8985. *
  8986. * An authoritative list can be found in the PHP `BrowserDetector` class and
  8987. * related classes in the same file (see calls to `new UserAgentBrowser` here:
  8988. * https://fburl.com/50728104).
  8989. *
  8990. * @note Function results are memoized
  8991. *
  8992. * @param {string} query Query of the form "Name [range expression]"
  8993. * @return {boolean}
  8994. */
  8995. isBrowser: function isBrowser(query) {
  8996. return compare$1(UserAgentData.browserName, UserAgentData.browserFullVersion, query);
  8997. },
  8998. /**
  8999. * Check if the User Agent browser uses a 32 or 64 bit architecture.
  9000. *
  9001. * @note Function results are memoized
  9002. *
  9003. * @param {string} query Query of the form "32" or "64".
  9004. * @return {boolean}
  9005. */
  9006. isBrowserArchitecture: function isBrowserArchitecture(query) {
  9007. return compare$1(UserAgentData.browserArchitecture, null, query);
  9008. },
  9009. /**
  9010. * Check if the User Agent device matches `query`.
  9011. *
  9012. * `query` should be a string like "iPhone" or "iPad".
  9013. *
  9014. * Valid device names include:
  9015. *
  9016. * - Kindle
  9017. * - Kindle Fire
  9018. * - Unknown
  9019. * - iPad
  9020. * - iPhone
  9021. * - iPod
  9022. * - etc...
  9023. *
  9024. * An authoritative list can be found in the PHP `DeviceDetector` class and
  9025. * related classes in the same file (see calls to `new UserAgentDevice` here:
  9026. * https://fburl.com/50728332).
  9027. *
  9028. * @note Function results are memoized
  9029. *
  9030. * @param {string} query Query of the form "Name"
  9031. * @return {boolean}
  9032. */
  9033. isDevice: function isDevice(query) {
  9034. return compare$1(UserAgentData.deviceName, null, query);
  9035. },
  9036. /**
  9037. * Check if the User Agent rendering engine matches `query`.
  9038. *
  9039. * `query` should be a string like "WebKit" or "WebKit >= 537".
  9040. *
  9041. * Valid engine names include:
  9042. *
  9043. * - Gecko
  9044. * - Presto
  9045. * - Trident
  9046. * - WebKit
  9047. * - etc...
  9048. *
  9049. * An authoritative list can be found in the PHP `RenderingEngineDetector`
  9050. * class related classes in the same file (see calls to `new
  9051. * UserAgentRenderingEngine` here: https://fburl.com/50728617).
  9052. *
  9053. * @note Function results are memoized
  9054. *
  9055. * @param {string} query Query of the form "Name [range expression]"
  9056. * @return {boolean}
  9057. */
  9058. isEngine: function isEngine(query) {
  9059. return compare$1(UserAgentData.engineName, UserAgentData.engineVersion, query);
  9060. },
  9061. /**
  9062. * Check if the User Agent platform matches `query`.
  9063. *
  9064. * `query` should be a string like "Windows" or "iOS 5 - 6".
  9065. *
  9066. * Valid platform names include:
  9067. *
  9068. * - Android
  9069. * - BlackBerry OS
  9070. * - Java ME
  9071. * - Linux
  9072. * - Mac OS X
  9073. * - Mac OS X Calendar
  9074. * - Mac OS X Internet Account
  9075. * - Symbian
  9076. * - SymbianOS
  9077. * - Windows
  9078. * - Windows Mobile
  9079. * - Windows Phone
  9080. * - iOS
  9081. * - iOS Facebook Integration Account
  9082. * - iOS Facebook Social Sharing UI
  9083. * - webOS
  9084. * - Chrome OS
  9085. * - etc...
  9086. *
  9087. * An authoritative list can be found in the PHP `PlatformDetector` class and
  9088. * related classes in the same file (see calls to `new UserAgentPlatform`
  9089. * here: https://fburl.com/50729226).
  9090. *
  9091. * @note Function results are memoized
  9092. *
  9093. * @param {string} query Query of the form "Name [range expression]"
  9094. * @return {boolean}
  9095. */
  9096. isPlatform: function isPlatform(query) {
  9097. return compare$1(UserAgentData.platformName, UserAgentData.platformFullVersion, query, normalizePlatformVersion);
  9098. },
  9099. /**
  9100. * Check if the User Agent platform is a 32 or 64 bit architecture.
  9101. *
  9102. * @note Function results are memoized
  9103. *
  9104. * @param {string} query Query of the form "32" or "64".
  9105. * @return {boolean}
  9106. */
  9107. isPlatformArchitecture: function isPlatformArchitecture(query) {
  9108. return compare$1(UserAgentData.platformArchitecture, null, query);
  9109. }
  9110. };
  9111. var UserAgent_1 = mapObject_1(UserAgent, memoizeStringOnly_1);
  9112. function _classCallCheck$9(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9113. function _possibleConstructorReturn$6(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9114. function _inherits$6(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9115. // In IE, spans with <br> tags render as two newlines. By rendering a span
  9116. // with only a newline character, we can be sure to render a single line.
  9117. var useNewlineChar = UserAgent_1.isBrowser('IE <= 11');
  9118. /**
  9119. * Check whether the node should be considered a newline.
  9120. */
  9121. function isNewline(node) {
  9122. return useNewlineChar ? node.textContent === '\n' : node.tagName === 'BR';
  9123. }
  9124. /**
  9125. * Placeholder elements for empty text content.
  9126. *
  9127. * What is this `data-text` attribute, anyway? It turns out that we need to
  9128. * put an attribute on the lowest-level text node in order to preserve correct
  9129. * spellcheck handling. If the <span> is naked, Chrome and Safari may do
  9130. * bizarre things to do the DOM -- split text nodes, create extra spans, etc.
  9131. * If the <span> has an attribute, this appears not to happen.
  9132. * See http://jsfiddle.net/9khdavod/ for the failure case, and
  9133. * http://jsfiddle.net/7pg143f7/ for the fixed case.
  9134. */
  9135. var NEWLINE_A = useNewlineChar ? React__default.createElement(
  9136. 'span',
  9137. { key: 'A', 'data-text': 'true' },
  9138. '\n'
  9139. ) : React__default.createElement('br', { key: 'A', 'data-text': 'true' });
  9140. var NEWLINE_B = useNewlineChar ? React__default.createElement(
  9141. 'span',
  9142. { key: 'B', 'data-text': 'true' },
  9143. '\n'
  9144. ) : React__default.createElement('br', { key: 'B', 'data-text': 'true' });
  9145. /**
  9146. * The lowest-level component in a `DraftEditor`, the text node component
  9147. * replaces the default React text node implementation. This allows us to
  9148. * perform custom handling of newline behavior and avoid re-rendering text
  9149. * nodes with DOM state that already matches the expectations of our immutable
  9150. * editor state.
  9151. */
  9152. var DraftEditorTextNode = function (_React$Component) {
  9153. _inherits$6(DraftEditorTextNode, _React$Component);
  9154. function DraftEditorTextNode(props) {
  9155. _classCallCheck$9(this, DraftEditorTextNode);
  9156. // By flipping this flag, we also keep flipping keys which forces
  9157. // React to remount this node every time it rerenders.
  9158. var _this = _possibleConstructorReturn$6(this, _React$Component.call(this, props));
  9159. _this._forceFlag = false;
  9160. return _this;
  9161. }
  9162. DraftEditorTextNode.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
  9163. var node = ReactDOM__default.findDOMNode(this);
  9164. var shouldBeNewline = nextProps.children === '';
  9165. !(node instanceof Element) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'node is not an Element') : invariant_1(false) : void 0;
  9166. if (shouldBeNewline) {
  9167. return !isNewline(node);
  9168. }
  9169. return node.textContent !== nextProps.children;
  9170. };
  9171. DraftEditorTextNode.prototype.componentDidMount = function componentDidMount() {
  9172. this._forceFlag = !this._forceFlag;
  9173. };
  9174. DraftEditorTextNode.prototype.componentDidUpdate = function componentDidUpdate() {
  9175. this._forceFlag = !this._forceFlag;
  9176. };
  9177. DraftEditorTextNode.prototype.render = function render() {
  9178. if (this.props.children === '') {
  9179. return this._forceFlag ? NEWLINE_A : NEWLINE_B;
  9180. }
  9181. return React__default.createElement(
  9182. 'span',
  9183. { key: this._forceFlag ? 'A' : 'B', 'data-text': 'true' },
  9184. this.props.children
  9185. );
  9186. };
  9187. return DraftEditorTextNode;
  9188. }(React__default.Component);
  9189. var DraftEditorTextNode_react = DraftEditorTextNode;
  9190. /**
  9191. * Copyright (c) 2013-present, Facebook, Inc.
  9192. * All rights reserved.
  9193. *
  9194. * This source code is licensed under the BSD-style license found in the
  9195. * LICENSE file in the root directory of this source tree. An additional grant
  9196. * of patent rights can be found in the PATENTS file in the same directory.
  9197. *
  9198. * @providesModule DraftJsDebugLogging
  9199. */
  9200. var DraftJsDebugLogging = {
  9201. logSelectionStateFailure: function logSelectionStateFailure() {
  9202. return null;
  9203. }
  9204. };
  9205. /**
  9206. * Copyright (c) 2013-present, Facebook, Inc.
  9207. *
  9208. * This source code is licensed under the MIT license found in the
  9209. * LICENSE file in the root directory of this source tree.
  9210. *
  9211. * @typechecks
  9212. */
  9213. /**
  9214. * @param {*} object The object to check.
  9215. * @return {boolean} Whether or not the object is a DOM node.
  9216. */
  9217. function isNode(object) {
  9218. var doc = object ? object.ownerDocument || object : document;
  9219. var defaultView = doc.defaultView || window;
  9220. return !!(object && (typeof defaultView.Node === 'function' ? object instanceof defaultView.Node : typeof object === 'object' && typeof object.nodeType === 'number' && typeof object.nodeName === 'string'));
  9221. }
  9222. var isNode_1 = isNode;
  9223. /**
  9224. * Copyright (c) 2013-present, Facebook, Inc.
  9225. *
  9226. * This source code is licensed under the MIT license found in the
  9227. * LICENSE file in the root directory of this source tree.
  9228. *
  9229. * @typechecks
  9230. */
  9231. /**
  9232. * @param {*} object The object to check.
  9233. * @return {boolean} Whether or not the object is a DOM text node.
  9234. */
  9235. function isTextNode(object) {
  9236. return isNode_1(object) && object.nodeType == 3;
  9237. }
  9238. var isTextNode_1 = isTextNode;
  9239. /**
  9240. * Copyright (c) 2013-present, Facebook, Inc.
  9241. *
  9242. * This source code is licensed under the MIT license found in the
  9243. * LICENSE file in the root directory of this source tree.
  9244. *
  9245. *
  9246. */
  9247. /*eslint-disable no-bitwise */
  9248. /**
  9249. * Checks if a given DOM node contains or is another DOM node.
  9250. */
  9251. function containsNode(outerNode, innerNode) {
  9252. if (!outerNode || !innerNode) {
  9253. return false;
  9254. } else if (outerNode === innerNode) {
  9255. return true;
  9256. } else if (isTextNode_1(outerNode)) {
  9257. return false;
  9258. } else if (isTextNode_1(innerNode)) {
  9259. return containsNode(outerNode, innerNode.parentNode);
  9260. } else if ('contains' in outerNode) {
  9261. return outerNode.contains(innerNode);
  9262. } else if (outerNode.compareDocumentPosition) {
  9263. return !!(outerNode.compareDocumentPosition(innerNode) & 16);
  9264. } else {
  9265. return false;
  9266. }
  9267. }
  9268. var containsNode_1 = containsNode;
  9269. /**
  9270. * Copyright (c) 2013-present, Facebook, Inc.
  9271. *
  9272. * This source code is licensed under the MIT license found in the
  9273. * LICENSE file in the root directory of this source tree.
  9274. *
  9275. * @typechecks
  9276. */
  9277. /* eslint-disable fb-www/typeof-undefined */
  9278. /**
  9279. * Same as document.activeElement but wraps in a try-catch block. In IE it is
  9280. * not safe to call document.activeElement if there is nothing focused.
  9281. *
  9282. * The activeElement will be null only if the document or document body is not
  9283. * yet defined.
  9284. *
  9285. * @param {?DOMDocument} doc Defaults to current document.
  9286. * @return {?DOMElement}
  9287. */
  9288. function getActiveElement(doc) /*?DOMElement*/{
  9289. doc = doc || (typeof document !== 'undefined' ? document : undefined);
  9290. if (typeof doc === 'undefined') {
  9291. return null;
  9292. }
  9293. try {
  9294. return doc.activeElement || doc.body;
  9295. } catch (e) {
  9296. return doc.body;
  9297. }
  9298. }
  9299. var getActiveElement_1 = getActiveElement;
  9300. function getAnonymizedDOM(node, getNodeLabels) {
  9301. if (!node) {
  9302. return '[empty]';
  9303. }
  9304. var anonymized = anonymizeTextWithin(node, getNodeLabels);
  9305. if (anonymized.nodeType === Node.TEXT_NODE) {
  9306. return anonymized.textContent;
  9307. }
  9308. !(anonymized instanceof Element) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Node must be an Element if it is not a text node.') : invariant_1(false) : void 0;
  9309. return anonymized.outerHTML;
  9310. }
  9311. function anonymizeTextWithin(node, getNodeLabels) {
  9312. var labels = getNodeLabels !== undefined ? getNodeLabels(node) : [];
  9313. if (node.nodeType === Node.TEXT_NODE) {
  9314. var length = node.textContent.length;
  9315. return document.createTextNode('[text ' + length + (labels.length ? ' | ' + labels.join(', ') : '') + ']');
  9316. }
  9317. var clone = node.cloneNode();
  9318. if (clone.nodeType === 1 && labels.length) {
  9319. clone.setAttribute('data-labels', labels.join(', '));
  9320. }
  9321. var childNodes = node.childNodes;
  9322. for (var ii = 0; ii < childNodes.length; ii++) {
  9323. clone.appendChild(anonymizeTextWithin(childNodes[ii], getNodeLabels));
  9324. }
  9325. return clone;
  9326. }
  9327. function getAnonymizedEditorDOM(node, getNodeLabels) {
  9328. // grabbing the DOM content of the Draft editor
  9329. var currentNode = node;
  9330. while (currentNode) {
  9331. if (currentNode instanceof Element && currentNode.hasAttribute('contenteditable')) {
  9332. // found the Draft editor container
  9333. return getAnonymizedDOM(currentNode, getNodeLabels);
  9334. } else {
  9335. currentNode = currentNode.parentNode;
  9336. }
  9337. }
  9338. return 'Could not find contentEditable parent of node';
  9339. }
  9340. function getNodeLength(node) {
  9341. return node.nodeValue === null ? node.childNodes.length : node.nodeValue.length;
  9342. }
  9343. /**
  9344. * In modern non-IE browsers, we can support both forward and backward
  9345. * selections.
  9346. *
  9347. * Note: IE10+ supports the Selection object, but it does not support
  9348. * the `extend` method, which means that even in modern IE, it's not possible
  9349. * to programatically create a backward selection. Thus, for all IE
  9350. * versions, we use the old IE API to create our selections.
  9351. */
  9352. function setDraftEditorSelection(selectionState, node, blockKey, nodeStart, nodeEnd) {
  9353. // It's possible that the editor has been removed from the DOM but
  9354. // our selection code doesn't know it yet. Forcing selection in
  9355. // this case may lead to errors, so just bail now.
  9356. if (!containsNode_1(document.documentElement, node)) {
  9357. return;
  9358. }
  9359. var selection = index.commonjsGlobal.getSelection();
  9360. var anchorKey = selectionState.getAnchorKey();
  9361. var anchorOffset = selectionState.getAnchorOffset();
  9362. var focusKey = selectionState.getFocusKey();
  9363. var focusOffset = selectionState.getFocusOffset();
  9364. var isBackward = selectionState.getIsBackward();
  9365. // IE doesn't support backward selection. Swap key/offset pairs.
  9366. if (!selection.extend && isBackward) {
  9367. var tempKey = anchorKey;
  9368. var tempOffset = anchorOffset;
  9369. anchorKey = focusKey;
  9370. anchorOffset = focusOffset;
  9371. focusKey = tempKey;
  9372. focusOffset = tempOffset;
  9373. isBackward = false;
  9374. }
  9375. var hasAnchor = anchorKey === blockKey && nodeStart <= anchorOffset && nodeEnd >= anchorOffset;
  9376. var hasFocus = focusKey === blockKey && nodeStart <= focusOffset && nodeEnd >= focusOffset;
  9377. // If the selection is entirely bound within this node, set the selection
  9378. // and be done.
  9379. if (hasAnchor && hasFocus) {
  9380. selection.removeAllRanges();
  9381. addPointToSelection(selection, node, anchorOffset - nodeStart, selectionState);
  9382. addFocusToSelection(selection, node, focusOffset - nodeStart, selectionState);
  9383. return;
  9384. }
  9385. if (!isBackward) {
  9386. // If the anchor is within this node, set the range start.
  9387. if (hasAnchor) {
  9388. selection.removeAllRanges();
  9389. addPointToSelection(selection, node, anchorOffset - nodeStart, selectionState);
  9390. }
  9391. // If the focus is within this node, we can assume that we have
  9392. // already set the appropriate start range on the selection, and
  9393. // can simply extend the selection.
  9394. if (hasFocus) {
  9395. addFocusToSelection(selection, node, focusOffset - nodeStart, selectionState);
  9396. }
  9397. } else {
  9398. // If this node has the focus, set the selection range to be a
  9399. // collapsed range beginning here. Later, when we encounter the anchor,
  9400. // we'll use this information to extend the selection.
  9401. if (hasFocus) {
  9402. selection.removeAllRanges();
  9403. addPointToSelection(selection, node, focusOffset - nodeStart, selectionState);
  9404. }
  9405. // If this node has the anchor, we may assume that the correct
  9406. // focus information is already stored on the selection object.
  9407. // We keep track of it, reset the selection range, and extend it
  9408. // back to the focus point.
  9409. if (hasAnchor) {
  9410. var storedFocusNode = selection.focusNode;
  9411. var storedFocusOffset = selection.focusOffset;
  9412. selection.removeAllRanges();
  9413. addPointToSelection(selection, node, anchorOffset - nodeStart, selectionState);
  9414. addFocusToSelection(selection, storedFocusNode, storedFocusOffset, selectionState);
  9415. }
  9416. }
  9417. }
  9418. /**
  9419. * Extend selection towards focus point.
  9420. */
  9421. function addFocusToSelection(selection, node, offset, selectionState) {
  9422. var activeElement = getActiveElement_1();
  9423. if (selection.extend && containsNode_1(activeElement, node)) {
  9424. // If `extend` is called while another element has focus, an error is
  9425. // thrown. We therefore disable `extend` if the active element is somewhere
  9426. // other than the node we are selecting. This should only occur in Firefox,
  9427. // since it is the only browser to support multiple selections.
  9428. // See https://bugzilla.mozilla.org/show_bug.cgi?id=921444.
  9429. // logging to catch bug that is being reported in t16250795
  9430. if (offset > getNodeLength(node)) {
  9431. // the call to 'selection.extend' is about to throw
  9432. DraftJsDebugLogging.logSelectionStateFailure({
  9433. anonymizedDom: getAnonymizedEditorDOM(node),
  9434. extraParams: JSON.stringify({ offset: offset }),
  9435. selectionState: JSON.stringify(selectionState.toJS())
  9436. });
  9437. }
  9438. // logging to catch bug that is being reported in t18110632
  9439. var nodeWasFocus = node === selection.focusNode;
  9440. try {
  9441. selection.extend(node, offset);
  9442. } catch (e) {
  9443. DraftJsDebugLogging.logSelectionStateFailure({
  9444. anonymizedDom: getAnonymizedEditorDOM(node, function (n) {
  9445. var labels = [];
  9446. if (n === activeElement) {
  9447. labels.push('active element');
  9448. }
  9449. if (n === selection.anchorNode) {
  9450. labels.push('selection anchor node');
  9451. }
  9452. if (n === selection.focusNode) {
  9453. labels.push('selection focus node');
  9454. }
  9455. return labels;
  9456. }),
  9457. extraParams: JSON.stringify({
  9458. activeElementName: activeElement ? activeElement.nodeName : null,
  9459. nodeIsFocus: node === selection.focusNode,
  9460. nodeWasFocus: nodeWasFocus,
  9461. selectionRangeCount: selection.rangeCount,
  9462. selectionAnchorNodeName: selection.anchorNode ? selection.anchorNode.nodeName : null,
  9463. selectionAnchorOffset: selection.anchorOffset,
  9464. selectionFocusNodeName: selection.focusNode ? selection.focusNode.nodeName : null,
  9465. selectionFocusOffset: selection.focusOffset,
  9466. message: e ? '' + e : null,
  9467. offset: offset
  9468. }, null, 2),
  9469. selectionState: JSON.stringify(selectionState.toJS(), null, 2)
  9470. });
  9471. // allow the error to be thrown -
  9472. // better than continuing in a broken state
  9473. throw e;
  9474. }
  9475. } else {
  9476. // IE doesn't support extend. This will mean no backward selection.
  9477. // Extract the existing selection range and add focus to it.
  9478. // Additionally, clone the selection range. IE11 throws an
  9479. // InvalidStateError when attempting to access selection properties
  9480. // after the range is detached.
  9481. var range = selection.getRangeAt(0);
  9482. range.setEnd(node, offset);
  9483. selection.addRange(range.cloneRange());
  9484. }
  9485. }
  9486. function addPointToSelection(selection, node, offset, selectionState) {
  9487. var range = document.createRange();
  9488. // logging to catch bug that is being reported in t16250795
  9489. if (offset > getNodeLength(node)) {
  9490. // in this case we know that the call to 'range.setStart' is about to throw
  9491. DraftJsDebugLogging.logSelectionStateFailure({
  9492. anonymizedDom: getAnonymizedEditorDOM(node),
  9493. extraParams: JSON.stringify({ offset: offset }),
  9494. selectionState: JSON.stringify(selectionState.toJS())
  9495. });
  9496. }
  9497. range.setStart(node, offset);
  9498. selection.addRange(range);
  9499. }
  9500. var setDraftEditorSelection_1 = setDraftEditorSelection;
  9501. function _classCallCheck$a(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9502. function _possibleConstructorReturn$7(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  9503. function _inherits$7(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  9504. /**
  9505. * All leaf nodes in the editor are spans with single text nodes. Leaf
  9506. * elements are styled based on the merging of an optional custom style map
  9507. * and a default style map.
  9508. *
  9509. * `DraftEditorLeaf` also provides a wrapper for calling into the imperative
  9510. * DOM Selection API. In this way, top-level components can declaratively
  9511. * maintain the selection state.
  9512. */
  9513. var DraftEditorLeaf = function (_React$Component) {
  9514. _inherits$7(DraftEditorLeaf, _React$Component);
  9515. function DraftEditorLeaf() {
  9516. _classCallCheck$a(this, DraftEditorLeaf);
  9517. return _possibleConstructorReturn$7(this, _React$Component.apply(this, arguments));
  9518. }
  9519. DraftEditorLeaf.prototype._setSelection = function _setSelection() {
  9520. var selection = this.props.selection;
  9521. // If selection state is irrelevant to the parent block, no-op.
  9522. if (selection == null || !selection.getHasFocus()) {
  9523. return;
  9524. }
  9525. var _props = this.props,
  9526. block = _props.block,
  9527. start = _props.start,
  9528. text = _props.text;
  9529. var blockKey = block.getKey();
  9530. var end = start + text.length;
  9531. if (!selection.hasEdgeWithin(blockKey, start, end)) {
  9532. return;
  9533. }
  9534. // Determine the appropriate target node for selection. If the child
  9535. // is not a text node, it is a <br /> spacer. In this case, use the
  9536. // <span> itself as the selection target.
  9537. var node = ReactDOM__default.findDOMNode(this);
  9538. !node ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing node') : invariant_1(false) : void 0;
  9539. var child = node.firstChild;
  9540. !child ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing child') : invariant_1(false) : void 0;
  9541. var targetNode = void 0;
  9542. if (child.nodeType === Node.TEXT_NODE) {
  9543. targetNode = child;
  9544. } else if (child.tagName === 'BR') {
  9545. targetNode = node;
  9546. } else {
  9547. targetNode = child.firstChild;
  9548. !targetNode ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing targetNode') : invariant_1(false) : void 0;
  9549. }
  9550. setDraftEditorSelection_1(selection, targetNode, blockKey, start, end);
  9551. };
  9552. /**
  9553. * By making individual leaf instances aware of their context within
  9554. * the text of the editor, we can set our selection range more
  9555. * easily than we could in the non-React world.
  9556. *
  9557. * Note that this depends on our maintaining tight control over the
  9558. * DOM structure of the DraftEditor component. If leaves had multiple
  9559. * text nodes, this would be harder.
  9560. */
  9561. DraftEditorLeaf.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
  9562. var leafNode = ReactDOM__default.findDOMNode(this.leaf);
  9563. !leafNode ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing leafNode') : invariant_1(false) : void 0;
  9564. return leafNode.textContent !== nextProps.text || nextProps.styleSet !== this.props.styleSet || nextProps.forceSelection;
  9565. };
  9566. DraftEditorLeaf.prototype.componentDidUpdate = function componentDidUpdate() {
  9567. this._setSelection();
  9568. };
  9569. DraftEditorLeaf.prototype.componentDidMount = function componentDidMount() {
  9570. this._setSelection();
  9571. };
  9572. DraftEditorLeaf.prototype.render = function render() {
  9573. var _this2 = this;
  9574. var block = this.props.block;
  9575. var text = this.props.text;
  9576. // If the leaf is at the end of its block and ends in a soft newline, append
  9577. // an extra line feed character. Browsers collapse trailing newline
  9578. // characters, which leaves the cursor in the wrong place after a
  9579. // shift+enter. The extra character repairs this.
  9580. if (text.endsWith('\n') && this.props.isLast) {
  9581. text += '\n';
  9582. }
  9583. var _props2 = this.props,
  9584. customStyleMap = _props2.customStyleMap,
  9585. customStyleFn = _props2.customStyleFn,
  9586. offsetKey = _props2.offsetKey,
  9587. styleSet = _props2.styleSet;
  9588. var styleObj = styleSet.reduce(function (map, styleName) {
  9589. var mergedStyles = {};
  9590. var style = customStyleMap[styleName];
  9591. if (style !== undefined && map.textDecoration !== style.textDecoration) {
  9592. // .trim() is necessary for IE9/10/11 and Edge
  9593. mergedStyles.textDecoration = [map.textDecoration, style.textDecoration].join(' ').trim();
  9594. }
  9595. return objectAssign(map, style, mergedStyles);
  9596. }, {});
  9597. if (customStyleFn) {
  9598. var newStyles = customStyleFn(styleSet, block);
  9599. styleObj = objectAssign(styleObj, newStyles);
  9600. }
  9601. return React__default.createElement(
  9602. 'span',
  9603. {
  9604. 'data-offset-key': offsetKey,
  9605. ref: function ref(_ref) {
  9606. return _this2.leaf = _ref;
  9607. },
  9608. style: styleObj },
  9609. React__default.createElement(
  9610. DraftEditorTextNode_react,
  9611. null,
  9612. text
  9613. )
  9614. );
  9615. };
  9616. return DraftEditorLeaf;
  9617. }(React__default.Component);
  9618. var DraftEditorLeaf_react = DraftEditorLeaf;
  9619. /**
  9620. * Copyright (c) 2013-present, Facebook, Inc.
  9621. * All rights reserved.
  9622. *
  9623. * This source code is licensed under the BSD-style license found in the
  9624. * LICENSE file in the root directory of this source tree. An additional grant
  9625. * of patent rights can be found in the PATENTS file in the same directory.
  9626. *
  9627. * @providesModule DraftOffsetKey
  9628. * @format
  9629. *
  9630. */
  9631. var KEY_DELIMITER = '-';
  9632. var DraftOffsetKey = {
  9633. encode: function encode(blockKey, decoratorKey, leafKey) {
  9634. return blockKey + KEY_DELIMITER + decoratorKey + KEY_DELIMITER + leafKey;
  9635. },
  9636. decode: function decode(offsetKey) {
  9637. var _offsetKey$split = offsetKey.split(KEY_DELIMITER),
  9638. blockKey = _offsetKey$split[0],
  9639. decoratorKey = _offsetKey$split[1],
  9640. leafKey = _offsetKey$split[2];
  9641. return {
  9642. blockKey: blockKey,
  9643. decoratorKey: parseInt(decoratorKey, 10),
  9644. leafKey: parseInt(leafKey, 10)
  9645. };
  9646. }
  9647. };
  9648. var DraftOffsetKey_1 = DraftOffsetKey;
  9649. /**
  9650. * Copyright (c) 2013-present, Facebook, Inc.
  9651. *
  9652. * This source code is licensed under the MIT license found in the
  9653. * LICENSE file in the root directory of this source tree.
  9654. *
  9655. */
  9656. /**
  9657. * @param {DOMElement} element
  9658. * @param {DOMDocument} doc
  9659. * @return {boolean}
  9660. */
  9661. function _isViewportScrollElement(element, doc) {
  9662. return !!doc && (element === doc.documentElement || element === doc.body);
  9663. }
  9664. /**
  9665. * Scroll Module. This class contains 4 simple static functions
  9666. * to be used to access Element.scrollTop/scrollLeft properties.
  9667. * To solve the inconsistencies between browsers when either
  9668. * document.body or document.documentElement is supplied,
  9669. * below logic will be used to alleviate the issue:
  9670. *
  9671. * 1. If 'element' is either 'document.body' or 'document.documentElement,
  9672. * get whichever element's 'scroll{Top,Left}' is larger.
  9673. * 2. If 'element' is either 'document.body' or 'document.documentElement',
  9674. * set the 'scroll{Top,Left}' on both elements.
  9675. */
  9676. var Scroll = {
  9677. /**
  9678. * @param {DOMElement} element
  9679. * @return {number}
  9680. */
  9681. getTop: function getTop(element) {
  9682. var doc = element.ownerDocument;
  9683. return _isViewportScrollElement(element, doc) ?
  9684. // In practice, they will either both have the same value,
  9685. // or one will be zero and the other will be the scroll position
  9686. // of the viewport. So we can use `X || Y` instead of `Math.max(X, Y)`
  9687. doc.body.scrollTop || doc.documentElement.scrollTop : element.scrollTop;
  9688. },
  9689. /**
  9690. * @param {DOMElement} element
  9691. * @param {number} newTop
  9692. */
  9693. setTop: function setTop(element, newTop) {
  9694. var doc = element.ownerDocument;
  9695. if (_isViewportScrollElement(element, doc)) {
  9696. doc.body.scrollTop = doc.documentElement.scrollTop = newTop;
  9697. } else {
  9698. element.scrollTop = newTop;
  9699. }
  9700. },
  9701. /**
  9702. * @param {DOMElement} element
  9703. * @return {number}
  9704. */
  9705. getLeft: function getLeft(element) {
  9706. var doc = element.ownerDocument;
  9707. return _isViewportScrollElement(element, doc) ? doc.body.scrollLeft || doc.documentElement.scrollLeft : element.scrollLeft;
  9708. },
  9709. /**
  9710. * @param {DOMElement} element
  9711. * @param {number} newLeft
  9712. */
  9713. setLeft: function setLeft(element, newLeft) {
  9714. var doc = element.ownerDocument;
  9715. if (_isViewportScrollElement(element, doc)) {
  9716. doc.body.scrollLeft = doc.documentElement.scrollLeft = newLeft;
  9717. } else {
  9718. element.scrollLeft = newLeft;
  9719. }
  9720. }
  9721. };
  9722. var Scroll_1 = Scroll;
  9723. /**
  9724. * Copyright (c) 2013-present, Facebook, Inc.
  9725. *
  9726. * This source code is licensed under the MIT license found in the
  9727. * LICENSE file in the root directory of this source tree.
  9728. *
  9729. * @typechecks
  9730. */
  9731. var _hyphenPattern = /-(.)/g;
  9732. /**
  9733. * Camelcases a hyphenated string, for example:
  9734. *
  9735. * > camelize('background-color')
  9736. * < "backgroundColor"
  9737. *
  9738. * @param {string} string
  9739. * @return {string}
  9740. */
  9741. function camelize(string) {
  9742. return string.replace(_hyphenPattern, function (_, character) {
  9743. return character.toUpperCase();
  9744. });
  9745. }
  9746. var camelize_1 = camelize;
  9747. /**
  9748. * Copyright (c) 2013-present, Facebook, Inc.
  9749. *
  9750. * This source code is licensed under the MIT license found in the
  9751. * LICENSE file in the root directory of this source tree.
  9752. *
  9753. * @typechecks
  9754. */
  9755. var _uppercasePattern = /([A-Z])/g;
  9756. /**
  9757. * Hyphenates a camelcased string, for example:
  9758. *
  9759. * > hyphenate('backgroundColor')
  9760. * < "background-color"
  9761. *
  9762. * For CSS style names, use `hyphenateStyleName` instead which works properly
  9763. * with all vendor prefixes, including `ms`.
  9764. *
  9765. * @param {string} string
  9766. * @return {string}
  9767. */
  9768. function hyphenate(string) {
  9769. return string.replace(_uppercasePattern, '-$1').toLowerCase();
  9770. }
  9771. var hyphenate_1 = hyphenate;
  9772. /**
  9773. * Copyright (c) 2013-present, Facebook, Inc.
  9774. *
  9775. * This source code is licensed under the MIT license found in the
  9776. * LICENSE file in the root directory of this source tree.
  9777. *
  9778. * @typechecks
  9779. */
  9780. function asString(value) /*?string*/{
  9781. return value == null ? value : String(value);
  9782. }
  9783. function getStyleProperty( /*DOMNode*/node, /*string*/name) /*?string*/{
  9784. var computedStyle = void 0;
  9785. // W3C Standard
  9786. if (window.getComputedStyle) {
  9787. // In certain cases such as within an iframe in FF3, this returns null.
  9788. computedStyle = window.getComputedStyle(node, null);
  9789. if (computedStyle) {
  9790. return asString(computedStyle.getPropertyValue(hyphenate_1(name)));
  9791. }
  9792. }
  9793. // Safari
  9794. if (document.defaultView && document.defaultView.getComputedStyle) {
  9795. computedStyle = document.defaultView.getComputedStyle(node, null);
  9796. // A Safari bug causes this to return null for `display: none` elements.
  9797. if (computedStyle) {
  9798. return asString(computedStyle.getPropertyValue(hyphenate_1(name)));
  9799. }
  9800. if (name === 'display') {
  9801. return 'none';
  9802. }
  9803. }
  9804. // Internet Explorer
  9805. if (node.currentStyle) {
  9806. if (name === 'float') {
  9807. return asString(node.currentStyle.cssFloat || node.currentStyle.styleFloat);
  9808. }
  9809. return asString(node.currentStyle[camelize_1(name)]);
  9810. }
  9811. return asString(node.style && node.style[camelize_1(name)]);
  9812. }
  9813. var getStyleProperty_1 = getStyleProperty;
  9814. /**
  9815. * Copyright (c) 2013-present, Facebook, Inc.
  9816. *
  9817. * This source code is licensed under the MIT license found in the
  9818. * LICENSE file in the root directory of this source tree.
  9819. *
  9820. * @typechecks
  9821. */
  9822. /**
  9823. * @param {DOMNode} element [description]
  9824. * @param {string} name Overflow style property name.
  9825. * @return {boolean} True if the supplied ndoe is scrollable.
  9826. */
  9827. function _isNodeScrollable(element, name) {
  9828. var overflow = Style.get(element, name);
  9829. return overflow === 'auto' || overflow === 'scroll';
  9830. }
  9831. /**
  9832. * Utilities for querying and mutating style properties.
  9833. */
  9834. var Style = {
  9835. /**
  9836. * Gets the style property for the supplied node. This will return either the
  9837. * computed style, if available, or the declared style.
  9838. *
  9839. * @param {DOMNode} node
  9840. * @param {string} name Style property name.
  9841. * @return {?string} Style property value.
  9842. */
  9843. get: getStyleProperty_1,
  9844. /**
  9845. * Determines the nearest ancestor of a node that is scrollable.
  9846. *
  9847. * NOTE: This can be expensive if used repeatedly or on a node nested deeply.
  9848. *
  9849. * @param {?DOMNode} node Node from which to start searching.
  9850. * @return {?DOMWindow|DOMElement} Scroll parent of the supplied node.
  9851. */
  9852. getScrollParent: function getScrollParent(node) {
  9853. if (!node) {
  9854. return null;
  9855. }
  9856. var ownerDocument = node.ownerDocument;
  9857. while (node && node !== ownerDocument.body) {
  9858. if (_isNodeScrollable(node, 'overflow') || _isNodeScrollable(node, 'overflowY') || _isNodeScrollable(node, 'overflowX')) {
  9859. return node;
  9860. }
  9861. node = node.parentNode;
  9862. }
  9863. return ownerDocument.defaultView || ownerDocument.parentWindow;
  9864. }
  9865. };
  9866. var Style_1 = Style;
  9867. /**
  9868. * Copyright (c) 2013-present, Facebook, Inc.
  9869. *
  9870. * This source code is licensed under the MIT license found in the
  9871. * LICENSE file in the root directory of this source tree.
  9872. *
  9873. * @typechecks
  9874. */
  9875. /**
  9876. * Gets an element's bounding rect in pixels relative to the viewport.
  9877. *
  9878. * @param {DOMElement} elem
  9879. * @return {object}
  9880. */
  9881. function getElementRect(elem) {
  9882. var docElem = elem.ownerDocument.documentElement;
  9883. // FF 2, Safari 3 and Opera 9.5- do not support getBoundingClientRect().
  9884. // IE9- will throw if the element is not in the document.
  9885. if (!('getBoundingClientRect' in elem) || !containsNode_1(docElem, elem)) {
  9886. return {
  9887. left: 0,
  9888. right: 0,
  9889. top: 0,
  9890. bottom: 0
  9891. };
  9892. }
  9893. // Subtracts clientTop/Left because IE8- added a 2px border to the
  9894. // <html> element (see http://fburl.com/1493213). IE 7 in
  9895. // Quicksmode does not report clientLeft/clientTop so there
  9896. // will be an unaccounted offset of 2px when in quirksmode
  9897. var rect = elem.getBoundingClientRect();
  9898. return {
  9899. left: Math.round(rect.left) - docElem.clientLeft,
  9900. right: Math.round(rect.right) - docElem.clientLeft,
  9901. top: Math.round(rect.top) - docElem.clientTop,
  9902. bottom: Math.round(rect.bottom) - docElem.clientTop
  9903. };
  9904. }
  9905. var getElementRect_1 = getElementRect;
  9906. /**
  9907. * Copyright (c) 2013-present, Facebook, Inc.
  9908. *
  9909. * This source code is licensed under the MIT license found in the
  9910. * LICENSE file in the root directory of this source tree.
  9911. *
  9912. * @typechecks
  9913. */
  9914. /**
  9915. * Gets an element's position in pixels relative to the viewport. The returned
  9916. * object represents the position of the element's top left corner.
  9917. *
  9918. * @param {DOMElement} element
  9919. * @return {object}
  9920. */
  9921. function getElementPosition(element) {
  9922. var rect = getElementRect_1(element);
  9923. return {
  9924. x: rect.left,
  9925. y: rect.top,
  9926. width: rect.right - rect.left,
  9927. height: rect.bottom - rect.top
  9928. };
  9929. }
  9930. var getElementPosition_1 = getElementPosition;
  9931. /**
  9932. * Copyright (c) 2013-present, Facebook, Inc.
  9933. *
  9934. * This source code is licensed under the MIT license found in the
  9935. * LICENSE file in the root directory of this source tree.
  9936. *
  9937. * @typechecks
  9938. */
  9939. var isWebkit = typeof navigator !== 'undefined' && navigator.userAgent.indexOf('AppleWebKit') > -1;
  9940. /**
  9941. * Gets the element with the document scroll properties such as `scrollLeft` and
  9942. * `scrollHeight`. This may differ across different browsers.
  9943. *
  9944. * NOTE: The return value can be null if the DOM is not yet ready.
  9945. *
  9946. * @param {?DOMDocument} doc Defaults to current document.
  9947. * @return {?DOMElement}
  9948. */
  9949. function getDocumentScrollElement(doc) {
  9950. doc = doc || document;
  9951. if (doc.scrollingElement) {
  9952. return doc.scrollingElement;
  9953. }
  9954. return !isWebkit && doc.compatMode === 'CSS1Compat' ? doc.documentElement : doc.body;
  9955. }
  9956. var getDocumentScrollElement_1 = getDocumentScrollElement;
  9957. /**
  9958. * Copyright (c) 2013-present, Facebook, Inc.
  9959. *
  9960. * This source code is licensed under the MIT license found in the
  9961. * LICENSE file in the root directory of this source tree.
  9962. *
  9963. * @typechecks
  9964. */
  9965. /**
  9966. * Gets the scroll position of the supplied element or window.
  9967. *
  9968. * The return values are unbounded, unlike `getScrollPosition`. This means they
  9969. * may be negative or exceed the element boundaries (which is possible using
  9970. * inertial scrolling).
  9971. *
  9972. * @param {DOMWindow|DOMElement} scrollable
  9973. * @return {object} Map with `x` and `y` keys.
  9974. */
  9975. function getUnboundedScrollPosition(scrollable) {
  9976. if (scrollable.Window && scrollable instanceof scrollable.Window) {
  9977. return {
  9978. x: scrollable.pageXOffset || scrollable.document.documentElement.scrollLeft,
  9979. y: scrollable.pageYOffset || scrollable.document.documentElement.scrollTop
  9980. };
  9981. }
  9982. return {
  9983. x: scrollable.scrollLeft,
  9984. y: scrollable.scrollTop
  9985. };
  9986. }
  9987. var getUnboundedScrollPosition_1 = getUnboundedScrollPosition;
  9988. /**
  9989. * Gets the scroll position of the supplied element or window.
  9990. *
  9991. * The return values are bounded. This means that if the scroll position is
  9992. * negative or exceeds the element boundaries (which is possible using inertial
  9993. * scrolling), you will get zero or the maximum scroll position, respectively.
  9994. *
  9995. * If you need the unbound scroll position, use `getUnboundedScrollPosition`.
  9996. *
  9997. * @param {DOMWindow|DOMElement} scrollable
  9998. * @return {object} Map with `x` and `y` keys.
  9999. */
  10000. function getScrollPosition(scrollable) {
  10001. var documentScrollElement = getDocumentScrollElement_1(scrollable.ownerDocument || scrollable.document);
  10002. if (scrollable.Window && scrollable instanceof scrollable.Window) {
  10003. scrollable = documentScrollElement;
  10004. }
  10005. var scrollPosition = getUnboundedScrollPosition_1(scrollable);
  10006. var viewport = scrollable === documentScrollElement ? scrollable.ownerDocument.documentElement : scrollable;
  10007. var xMax = scrollable.scrollWidth - viewport.clientWidth;
  10008. var yMax = scrollable.scrollHeight - viewport.clientHeight;
  10009. scrollPosition.x = Math.max(0, Math.min(scrollPosition.x, xMax));
  10010. scrollPosition.y = Math.max(0, Math.min(scrollPosition.y, yMax));
  10011. return scrollPosition;
  10012. }
  10013. var getScrollPosition_1 = getScrollPosition;
  10014. function getViewportWidth() {
  10015. var width = void 0;
  10016. if (document.documentElement) {
  10017. width = document.documentElement.clientWidth;
  10018. }
  10019. if (!width && document.body) {
  10020. width = document.body.clientWidth;
  10021. }
  10022. return width || 0;
  10023. } /**
  10024. * Copyright (c) 2013-present, Facebook, Inc.
  10025. *
  10026. * This source code is licensed under the MIT license found in the
  10027. * LICENSE file in the root directory of this source tree.
  10028. *
  10029. *
  10030. * @typechecks
  10031. */
  10032. function getViewportHeight() {
  10033. var height = void 0;
  10034. if (document.documentElement) {
  10035. height = document.documentElement.clientHeight;
  10036. }
  10037. if (!height && document.body) {
  10038. height = document.body.clientHeight;
  10039. }
  10040. return height || 0;
  10041. }
  10042. /**
  10043. * Gets the viewport dimensions including any scrollbars.
  10044. */
  10045. function getViewportDimensions() {
  10046. return {
  10047. width: window.innerWidth || getViewportWidth(),
  10048. height: window.innerHeight || getViewportHeight()
  10049. };
  10050. }
  10051. /**
  10052. * Gets the viewport dimensions excluding any scrollbars.
  10053. */
  10054. getViewportDimensions.withoutScrollbars = function () {
  10055. return {
  10056. width: getViewportWidth(),
  10057. height: getViewportHeight()
  10058. };
  10059. };
  10060. var getViewportDimensions_1 = getViewportDimensions;
  10061. var _extends$2 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  10062. function _classCallCheck$b(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10063. function _possibleConstructorReturn$8(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  10064. function _inherits$8(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  10065. var SCROLL_BUFFER = 10;
  10066. /**
  10067. * Return whether a block overlaps with either edge of the `SelectionState`.
  10068. */
  10069. var isBlockOnSelectionEdge = function isBlockOnSelectionEdge(selection, key) {
  10070. return selection.getAnchorKey() === key || selection.getFocusKey() === key;
  10071. };
  10072. /**
  10073. * The default block renderer for a `DraftEditor` component.
  10074. *
  10075. * A `DraftEditorBlock` is able to render a given `ContentBlock` to its
  10076. * appropriate decorator and inline style components.
  10077. */
  10078. var DraftEditorBlock = function (_React$Component) {
  10079. _inherits$8(DraftEditorBlock, _React$Component);
  10080. function DraftEditorBlock() {
  10081. _classCallCheck$b(this, DraftEditorBlock);
  10082. return _possibleConstructorReturn$8(this, _React$Component.apply(this, arguments));
  10083. }
  10084. DraftEditorBlock.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
  10085. return this.props.block !== nextProps.block || this.props.tree !== nextProps.tree || this.props.direction !== nextProps.direction || isBlockOnSelectionEdge(nextProps.selection, nextProps.block.getKey()) && nextProps.forceSelection;
  10086. };
  10087. /**
  10088. * When a block is mounted and overlaps the selection state, we need to make
  10089. * sure that the cursor is visible to match native behavior. This may not
  10090. * be the case if the user has pressed `RETURN` or pasted some content, since
  10091. * programatically creating these new blocks and setting the DOM selection
  10092. * will miss out on the browser natively scrolling to that position.
  10093. *
  10094. * To replicate native behavior, if the block overlaps the selection state
  10095. * on mount, force the scroll position. Check the scroll state of the scroll
  10096. * parent, and adjust it to align the entire block to the bottom of the
  10097. * scroll parent.
  10098. */
  10099. DraftEditorBlock.prototype.componentDidMount = function componentDidMount() {
  10100. var selection = this.props.selection;
  10101. var endKey = selection.getEndKey();
  10102. if (!selection.getHasFocus() || endKey !== this.props.block.getKey()) {
  10103. return;
  10104. }
  10105. var blockNode = ReactDOM__default.findDOMNode(this);
  10106. var scrollParent = Style_1.getScrollParent(blockNode);
  10107. var scrollPosition = getScrollPosition_1(scrollParent);
  10108. var scrollDelta = void 0;
  10109. if (scrollParent === window) {
  10110. var nodePosition = getElementPosition_1(blockNode);
  10111. var nodeBottom = nodePosition.y + nodePosition.height;
  10112. var viewportHeight = getViewportDimensions_1().height;
  10113. scrollDelta = nodeBottom - viewportHeight;
  10114. if (scrollDelta > 0) {
  10115. window.scrollTo(scrollPosition.x, scrollPosition.y + scrollDelta + SCROLL_BUFFER);
  10116. }
  10117. } else {
  10118. !(blockNode instanceof HTMLElement) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'blockNode is not an HTMLElement') : invariant_1(false) : void 0;
  10119. var blockBottom = blockNode.offsetHeight + blockNode.offsetTop;
  10120. var scrollBottom = scrollParent.offsetHeight + scrollPosition.y;
  10121. scrollDelta = blockBottom - scrollBottom;
  10122. if (scrollDelta > 0) {
  10123. Scroll_1.setTop(scrollParent, Scroll_1.getTop(scrollParent) + scrollDelta + SCROLL_BUFFER);
  10124. }
  10125. }
  10126. };
  10127. DraftEditorBlock.prototype._renderChildren = function _renderChildren() {
  10128. var _this2 = this;
  10129. var block = this.props.block;
  10130. var blockKey = block.getKey();
  10131. var text = block.getText();
  10132. var lastLeafSet = this.props.tree.size - 1;
  10133. var hasSelection = isBlockOnSelectionEdge(this.props.selection, blockKey);
  10134. return this.props.tree.map(function (leafSet, ii) {
  10135. var leavesForLeafSet = leafSet.get('leaves');
  10136. var lastLeaf = leavesForLeafSet.size - 1;
  10137. var leaves = leavesForLeafSet.map(function (leaf, jj) {
  10138. var offsetKey = DraftOffsetKey_1.encode(blockKey, ii, jj);
  10139. var start = leaf.get('start');
  10140. var end = leaf.get('end');
  10141. return React__default.createElement(DraftEditorLeaf_react, {
  10142. key: offsetKey,
  10143. offsetKey: offsetKey,
  10144. block: block,
  10145. start: start,
  10146. selection: hasSelection ? _this2.props.selection : null,
  10147. forceSelection: _this2.props.forceSelection,
  10148. text: text.slice(start, end),
  10149. styleSet: block.getInlineStyleAt(start),
  10150. customStyleMap: _this2.props.customStyleMap,
  10151. customStyleFn: _this2.props.customStyleFn,
  10152. isLast: ii === lastLeafSet && jj === lastLeaf
  10153. });
  10154. }).toArray();
  10155. var decoratorKey = leafSet.get('decoratorKey');
  10156. if (decoratorKey == null) {
  10157. return leaves;
  10158. }
  10159. if (!_this2.props.decorator) {
  10160. return leaves;
  10161. }
  10162. var decorator = nullthrows_1(_this2.props.decorator);
  10163. var DecoratorComponent = decorator.getComponentForKey(decoratorKey);
  10164. if (!DecoratorComponent) {
  10165. return leaves;
  10166. }
  10167. var decoratorProps = decorator.getPropsForKey(decoratorKey);
  10168. var decoratorOffsetKey = DraftOffsetKey_1.encode(blockKey, ii, 0);
  10169. var decoratedText = text.slice(leavesForLeafSet.first().get('start'), leavesForLeafSet.last().get('end'));
  10170. // Resetting dir to the same value on a child node makes Chrome/Firefox
  10171. // confused on cursor movement. See http://jsfiddle.net/d157kLck/3/
  10172. var dir = UnicodeBidiDirection_1.getHTMLDirIfDifferent(UnicodeBidi_1.getDirection(decoratedText), _this2.props.direction);
  10173. return React__default.createElement(
  10174. DecoratorComponent,
  10175. _extends$2({}, decoratorProps, {
  10176. contentState: _this2.props.contentState,
  10177. decoratedText: decoratedText,
  10178. dir: dir,
  10179. key: decoratorOffsetKey,
  10180. entityKey: block.getEntityAt(leafSet.get('start')),
  10181. offsetKey: decoratorOffsetKey }),
  10182. leaves
  10183. );
  10184. }).toArray();
  10185. };
  10186. DraftEditorBlock.prototype.render = function render() {
  10187. var _props = this.props,
  10188. direction = _props.direction,
  10189. offsetKey = _props.offsetKey;
  10190. var className = cx_1({
  10191. 'public/DraftStyleDefault/block': true,
  10192. 'public/DraftStyleDefault/ltr': direction === 'LTR',
  10193. 'public/DraftStyleDefault/rtl': direction === 'RTL'
  10194. });
  10195. return React__default.createElement(
  10196. 'div',
  10197. { 'data-offset-key': offsetKey, className: className },
  10198. this._renderChildren()
  10199. );
  10200. };
  10201. return DraftEditorBlock;
  10202. }(React__default.Component);
  10203. var DraftEditorBlock_react = DraftEditorBlock;
  10204. /**
  10205. * Copyright (c) 2013-present, Facebook, Inc.
  10206. *
  10207. * This source code is licensed under the MIT license found in the
  10208. * LICENSE file in the root directory of this source tree.
  10209. *
  10210. * @typechecks static-only
  10211. */
  10212. /**
  10213. * Combines multiple className strings into one.
  10214. * http://jsperf.com/joinclasses-args-vs-array
  10215. *
  10216. * @param {...?string} className
  10217. * @return {string}
  10218. */
  10219. function joinClasses(className /*, ... */) {
  10220. if (!className) {
  10221. className = '';
  10222. }
  10223. var nextClass = void 0;
  10224. var argLength = arguments.length;
  10225. if (argLength > 1) {
  10226. for (var ii = 1; ii < argLength; ii++) {
  10227. nextClass = arguments[ii];
  10228. if (nextClass) {
  10229. className = (className ? className + ' ' : '') + nextClass;
  10230. }
  10231. }
  10232. }
  10233. return className;
  10234. }
  10235. var joinClasses_1 = joinClasses;
  10236. var _extends$3 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  10237. function _classCallCheck$c(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10238. function _possibleConstructorReturn$9(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  10239. function _inherits$9(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  10240. /**
  10241. * Provide default styling for list items. This way, lists will be styled with
  10242. * proper counters and indentation even if the caller does not specify
  10243. * their own styling at all. If more than five levels of nesting are needed,
  10244. * the necessary CSS classes can be provided via `blockStyleFn` configuration.
  10245. */
  10246. var getListItemClasses = function getListItemClasses(type, depth, shouldResetCount, direction) {
  10247. return cx_1({
  10248. 'public/DraftStyleDefault/unorderedListItem': type === 'unordered-list-item',
  10249. 'public/DraftStyleDefault/orderedListItem': type === 'ordered-list-item',
  10250. 'public/DraftStyleDefault/reset': shouldResetCount,
  10251. 'public/DraftStyleDefault/depth0': depth === 0,
  10252. 'public/DraftStyleDefault/depth1': depth === 1,
  10253. 'public/DraftStyleDefault/depth2': depth === 2,
  10254. 'public/DraftStyleDefault/depth3': depth === 3,
  10255. 'public/DraftStyleDefault/depth4': depth === 4,
  10256. 'public/DraftStyleDefault/listLTR': direction === 'LTR',
  10257. 'public/DraftStyleDefault/listRTL': direction === 'RTL'
  10258. });
  10259. };
  10260. /**
  10261. * `DraftEditorContents` is the container component for all block components
  10262. * rendered for a `DraftEditor`. It is optimized to aggressively avoid
  10263. * re-rendering blocks whenever possible.
  10264. *
  10265. * This component is separate from `DraftEditor` because certain props
  10266. * (for instance, ARIA props) must be allowed to update without affecting
  10267. * the contents of the editor.
  10268. */
  10269. var DraftEditorContents = function (_React$Component) {
  10270. _inherits$9(DraftEditorContents, _React$Component);
  10271. function DraftEditorContents() {
  10272. _classCallCheck$c(this, DraftEditorContents);
  10273. return _possibleConstructorReturn$9(this, _React$Component.apply(this, arguments));
  10274. }
  10275. DraftEditorContents.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
  10276. var prevEditorState = this.props.editorState;
  10277. var nextEditorState = nextProps.editorState;
  10278. var prevDirectionMap = prevEditorState.getDirectionMap();
  10279. var nextDirectionMap = nextEditorState.getDirectionMap();
  10280. // Text direction has changed for one or more blocks. We must re-render.
  10281. if (prevDirectionMap !== nextDirectionMap) {
  10282. return true;
  10283. }
  10284. var didHaveFocus = prevEditorState.getSelection().getHasFocus();
  10285. var nowHasFocus = nextEditorState.getSelection().getHasFocus();
  10286. if (didHaveFocus !== nowHasFocus) {
  10287. return true;
  10288. }
  10289. var nextNativeContent = nextEditorState.getNativelyRenderedContent();
  10290. var wasComposing = prevEditorState.isInCompositionMode();
  10291. var nowComposing = nextEditorState.isInCompositionMode();
  10292. // If the state is unchanged or we're currently rendering a natively
  10293. // rendered state, there's nothing new to be done.
  10294. if (prevEditorState === nextEditorState || nextNativeContent !== null && nextEditorState.getCurrentContent() === nextNativeContent || wasComposing && nowComposing) {
  10295. return false;
  10296. }
  10297. var prevContent = prevEditorState.getCurrentContent();
  10298. var nextContent = nextEditorState.getCurrentContent();
  10299. var prevDecorator = prevEditorState.getDecorator();
  10300. var nextDecorator = nextEditorState.getDecorator();
  10301. return wasComposing !== nowComposing || prevContent !== nextContent || prevDecorator !== nextDecorator || nextEditorState.mustForceSelection();
  10302. };
  10303. DraftEditorContents.prototype.render = function render() {
  10304. var _props = this.props,
  10305. blockRenderMap = _props.blockRenderMap,
  10306. blockRendererFn = _props.blockRendererFn,
  10307. blockStyleFn = _props.blockStyleFn,
  10308. customStyleMap = _props.customStyleMap,
  10309. customStyleFn = _props.customStyleFn,
  10310. editorState = _props.editorState,
  10311. editorKey = _props.editorKey,
  10312. textDirectionality = _props.textDirectionality;
  10313. var content = editorState.getCurrentContent();
  10314. var selection = editorState.getSelection();
  10315. var forceSelection = editorState.mustForceSelection();
  10316. var decorator = editorState.getDecorator();
  10317. var directionMap = nullthrows_1(editorState.getDirectionMap());
  10318. var blocksAsArray = content.getBlocksAsArray();
  10319. var processedBlocks = [];
  10320. var currentDepth = null;
  10321. var lastWrapperTemplate = null;
  10322. for (var ii = 0; ii < blocksAsArray.length; ii++) {
  10323. var _block = blocksAsArray[ii];
  10324. var key = _block.getKey();
  10325. var blockType = _block.getType();
  10326. var customRenderer = blockRendererFn(_block);
  10327. var CustomComponent = void 0,
  10328. customProps = void 0,
  10329. customEditable = void 0;
  10330. if (customRenderer) {
  10331. CustomComponent = customRenderer.component;
  10332. customProps = customRenderer.props;
  10333. customEditable = customRenderer.editable;
  10334. }
  10335. var direction = textDirectionality ? textDirectionality : directionMap.get(key);
  10336. var offsetKey = DraftOffsetKey_1.encode(key, 0, 0);
  10337. var componentProps = {
  10338. contentState: content,
  10339. block: _block,
  10340. blockProps: customProps,
  10341. blockStyleFn: blockStyleFn,
  10342. customStyleMap: customStyleMap,
  10343. customStyleFn: customStyleFn,
  10344. decorator: decorator,
  10345. direction: direction,
  10346. forceSelection: forceSelection,
  10347. key: key,
  10348. offsetKey: offsetKey,
  10349. selection: selection,
  10350. tree: editorState.getBlockTree(key)
  10351. };
  10352. var configForType = blockRenderMap.get(blockType) || blockRenderMap.get('unstyled');
  10353. var wrapperTemplate = configForType.wrapper;
  10354. var Element = configForType.element || blockRenderMap.get('unstyled').element;
  10355. var depth = _block.getDepth();
  10356. var className = '';
  10357. if (blockStyleFn) {
  10358. className = blockStyleFn(_block);
  10359. }
  10360. // List items are special snowflakes, since we handle nesting and
  10361. // counters manually.
  10362. if (Element === 'li') {
  10363. var shouldResetCount = lastWrapperTemplate !== wrapperTemplate || currentDepth === null || depth > currentDepth;
  10364. className = joinClasses_1(className, getListItemClasses(blockType, depth, shouldResetCount, direction));
  10365. }
  10366. var Component = CustomComponent || DraftEditorBlock_react;
  10367. var childProps = {
  10368. className: className,
  10369. 'data-block': true,
  10370. 'data-editor': editorKey,
  10371. 'data-offset-key': offsetKey,
  10372. key: key
  10373. };
  10374. if (customEditable !== undefined) {
  10375. childProps = _extends$3({}, childProps, {
  10376. contentEditable: customEditable,
  10377. suppressContentEditableWarning: true
  10378. });
  10379. }
  10380. var child = React__default.createElement(Element, childProps, React__default.createElement(Component, componentProps));
  10381. processedBlocks.push({
  10382. block: child,
  10383. wrapperTemplate: wrapperTemplate,
  10384. key: key,
  10385. offsetKey: offsetKey
  10386. });
  10387. if (wrapperTemplate) {
  10388. currentDepth = _block.getDepth();
  10389. } else {
  10390. currentDepth = null;
  10391. }
  10392. lastWrapperTemplate = wrapperTemplate;
  10393. }
  10394. // Group contiguous runs of blocks that have the same wrapperTemplate
  10395. var outputBlocks = [];
  10396. for (var _ii = 0; _ii < processedBlocks.length;) {
  10397. var info = processedBlocks[_ii];
  10398. if (info.wrapperTemplate) {
  10399. var blocks = [];
  10400. do {
  10401. blocks.push(processedBlocks[_ii].block);
  10402. _ii++;
  10403. } while (_ii < processedBlocks.length && processedBlocks[_ii].wrapperTemplate === info.wrapperTemplate);
  10404. var wrapperElement = React__default.cloneElement(info.wrapperTemplate, {
  10405. key: info.key + '-wrap',
  10406. 'data-offset-key': info.offsetKey
  10407. }, blocks);
  10408. outputBlocks.push(wrapperElement);
  10409. } else {
  10410. outputBlocks.push(info.block);
  10411. _ii++;
  10412. }
  10413. }
  10414. return React__default.createElement(
  10415. 'div',
  10416. { 'data-contents': 'true' },
  10417. outputBlocks
  10418. );
  10419. };
  10420. return DraftEditorContents;
  10421. }(React__default.Component);
  10422. var DraftEditorContentsCore_react = DraftEditorContents;
  10423. var DraftEditorContents_react = DraftEditorContentsCore_react;
  10424. /**
  10425. * Copyright (c) 2013-present, Facebook, Inc.
  10426. *
  10427. * This source code is licensed under the MIT license found in the
  10428. * LICENSE file in the root directory of this source tree.
  10429. *
  10430. */
  10431. var PhotosMimeType = {
  10432. isImage: function isImage(mimeString) {
  10433. return getParts(mimeString)[0] === 'image';
  10434. },
  10435. isJpeg: function isJpeg(mimeString) {
  10436. var parts = getParts(mimeString);
  10437. return PhotosMimeType.isImage(mimeString) && (
  10438. // see http://fburl.com/10972194
  10439. parts[1] === 'jpeg' || parts[1] === 'pjpeg');
  10440. }
  10441. };
  10442. function getParts(mimeString) {
  10443. return mimeString.split('/');
  10444. }
  10445. var PhotosMimeType_1 = PhotosMimeType;
  10446. /**
  10447. * Copyright (c) 2013-present, Facebook, Inc.
  10448. *
  10449. * This source code is licensed under the MIT license found in the
  10450. * LICENSE file in the root directory of this source tree.
  10451. *
  10452. * @typechecks
  10453. */
  10454. /**
  10455. * Convert array-like objects to arrays.
  10456. *
  10457. * This API assumes the caller knows the contents of the data type. For less
  10458. * well defined inputs use createArrayFromMixed.
  10459. *
  10460. * @param {object|function|filelist} obj
  10461. * @return {array}
  10462. */
  10463. function toArray(obj) {
  10464. var length = obj.length;
  10465. // Some browsers builtin objects can report typeof 'function' (e.g. NodeList
  10466. // in old versions of Safari).
  10467. !(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'toArray: Array-like object expected') : invariant_1(false) : void 0;
  10468. !(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'toArray: Object needs a length property') : invariant_1(false) : void 0;
  10469. !(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'toArray: Object should have keys for indices') : invariant_1(false) : void 0;
  10470. !(typeof obj.callee !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant_1(false) : void 0;
  10471. // Old IE doesn't give collections access to hasOwnProperty. Assume inputs
  10472. // without method will throw during the slice call and skip straight to the
  10473. // fallback.
  10474. if (obj.hasOwnProperty) {
  10475. try {
  10476. return Array.prototype.slice.call(obj);
  10477. } catch (e) {
  10478. // IE < 9 does not support Array#slice on collections objects
  10479. }
  10480. }
  10481. // Fall back to copying key by key. This assumes all keys have a value,
  10482. // so will not preserve sparsely populated inputs.
  10483. var ret = Array(length);
  10484. for (var ii = 0; ii < length; ii++) {
  10485. ret[ii] = obj[ii];
  10486. }
  10487. return ret;
  10488. }
  10489. /**
  10490. * Perform a heuristic test to determine if an object is "array-like".
  10491. *
  10492. * A monk asked Joshu, a Zen master, "Has a dog Buddha nature?"
  10493. * Joshu replied: "Mu."
  10494. *
  10495. * This function determines if its argument has "array nature": it returns
  10496. * true if the argument is an actual array, an `arguments' object, or an
  10497. * HTMLCollection (e.g. node.childNodes or node.getElementsByTagName()).
  10498. *
  10499. * It will return false for other array-like objects like Filelist.
  10500. *
  10501. * @param {*} obj
  10502. * @return {boolean}
  10503. */
  10504. function hasArrayNature(obj) {
  10505. return (
  10506. // not null/false
  10507. !!obj && (
  10508. // arrays are objects, NodeLists are functions in Safari
  10509. typeof obj == 'object' || typeof obj == 'function') &&
  10510. // quacks like an array
  10511. 'length' in obj &&
  10512. // not window
  10513. !('setInterval' in obj) &&
  10514. // no DOM node should be considered an array-like
  10515. // a 'select' element has 'length' and 'item' properties on IE8
  10516. typeof obj.nodeType != 'number' && (
  10517. // a real array
  10518. Array.isArray(obj) ||
  10519. // arguments
  10520. 'callee' in obj ||
  10521. // HTMLCollection/NodeList
  10522. 'item' in obj)
  10523. );
  10524. }
  10525. /**
  10526. * Ensure that the argument is an array by wrapping it in an array if it is not.
  10527. * Creates a copy of the argument if it is already an array.
  10528. *
  10529. * This is mostly useful idiomatically:
  10530. *
  10531. * var createArrayFromMixed = require('createArrayFromMixed');
  10532. *
  10533. * function takesOneOrMoreThings(things) {
  10534. * things = createArrayFromMixed(things);
  10535. * ...
  10536. * }
  10537. *
  10538. * This allows you to treat `things' as an array, but accept scalars in the API.
  10539. *
  10540. * If you need to convert an array-like object, like `arguments`, into an array
  10541. * use toArray instead.
  10542. *
  10543. * @param {*} obj
  10544. * @return {array}
  10545. */
  10546. function createArrayFromMixed(obj) {
  10547. if (!hasArrayNature(obj)) {
  10548. return [obj];
  10549. } else if (Array.isArray(obj)) {
  10550. return obj.slice();
  10551. } else {
  10552. return toArray(obj);
  10553. }
  10554. }
  10555. var createArrayFromMixed_1 = createArrayFromMixed;
  10556. function _classCallCheck$d(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  10557. /**
  10558. * Copyright (c) 2013-present, Facebook, Inc.
  10559. *
  10560. * This source code is licensed under the MIT license found in the
  10561. * LICENSE file in the root directory of this source tree.
  10562. *
  10563. * @typechecks
  10564. */
  10565. var CR_LF_REGEX = new RegExp('\r\n', 'g');
  10566. var LF_ONLY = '\n';
  10567. var RICH_TEXT_TYPES = {
  10568. 'text/rtf': 1,
  10569. 'text/html': 1
  10570. };
  10571. /**
  10572. * If DataTransferItem is a file then return the Blob of data.
  10573. *
  10574. * @param {object} item
  10575. * @return {?blob}
  10576. */
  10577. function getFileFromDataTransfer(item) {
  10578. if (item.kind == 'file') {
  10579. return item.getAsFile();
  10580. }
  10581. }
  10582. var DataTransfer = function () {
  10583. /**
  10584. * @param {object} data
  10585. */
  10586. function DataTransfer(data) {
  10587. _classCallCheck$d(this, DataTransfer);
  10588. this.data = data;
  10589. // Types could be DOMStringList or array
  10590. this.types = data.types ? createArrayFromMixed_1(data.types) : [];
  10591. }
  10592. /**
  10593. * Is this likely to be a rich text data transfer?
  10594. *
  10595. * @return {boolean}
  10596. */
  10597. DataTransfer.prototype.isRichText = function isRichText() {
  10598. // If HTML is available, treat this data as rich text. This way, we avoid
  10599. // using a pasted image if it is packaged with HTML -- this may occur with
  10600. // pastes from MS Word, for example. However this is only rich text if
  10601. // there's accompanying text.
  10602. if (this.getHTML() && this.getText()) {
  10603. return true;
  10604. }
  10605. // When an image is copied from a preview window, you end up with two
  10606. // DataTransferItems one of which is a file's metadata as text. Skip those.
  10607. if (this.isImage()) {
  10608. return false;
  10609. }
  10610. return this.types.some(function (type) {
  10611. return RICH_TEXT_TYPES[type];
  10612. });
  10613. };
  10614. /**
  10615. * Get raw text.
  10616. *
  10617. * @return {?string}
  10618. */
  10619. DataTransfer.prototype.getText = function getText() {
  10620. var text;
  10621. if (this.data.getData) {
  10622. if (!this.types.length) {
  10623. text = this.data.getData('Text');
  10624. } else if (this.types.indexOf('text/plain') != -1) {
  10625. text = this.data.getData('text/plain');
  10626. }
  10627. }
  10628. return text ? text.replace(CR_LF_REGEX, LF_ONLY) : null;
  10629. };
  10630. /**
  10631. * Get HTML paste data
  10632. *
  10633. * @return {?string}
  10634. */
  10635. DataTransfer.prototype.getHTML = function getHTML() {
  10636. if (this.data.getData) {
  10637. if (!this.types.length) {
  10638. return this.data.getData('Text');
  10639. } else if (this.types.indexOf('text/html') != -1) {
  10640. return this.data.getData('text/html');
  10641. }
  10642. }
  10643. };
  10644. /**
  10645. * Is this a link data transfer?
  10646. *
  10647. * @return {boolean}
  10648. */
  10649. DataTransfer.prototype.isLink = function isLink() {
  10650. return this.types.some(function (type) {
  10651. return type.indexOf('Url') != -1 || type.indexOf('text/uri-list') != -1 || type.indexOf('text/x-moz-url');
  10652. });
  10653. };
  10654. /**
  10655. * Get a link url.
  10656. *
  10657. * @return {?string}
  10658. */
  10659. DataTransfer.prototype.getLink = function getLink() {
  10660. if (this.data.getData) {
  10661. if (this.types.indexOf('text/x-moz-url') != -1) {
  10662. var url = this.data.getData('text/x-moz-url').split('\n');
  10663. return url[0];
  10664. }
  10665. return this.types.indexOf('text/uri-list') != -1 ? this.data.getData('text/uri-list') : this.data.getData('url');
  10666. }
  10667. return null;
  10668. };
  10669. /**
  10670. * Is this an image data transfer?
  10671. *
  10672. * @return {boolean}
  10673. */
  10674. DataTransfer.prototype.isImage = function isImage() {
  10675. var isImage = this.types.some(function (type) {
  10676. // Firefox will have a type of application/x-moz-file for images during
  10677. // dragging
  10678. return type.indexOf('application/x-moz-file') != -1;
  10679. });
  10680. if (isImage) {
  10681. return true;
  10682. }
  10683. var items = this.getFiles();
  10684. for (var i = 0; i < items.length; i++) {
  10685. var type = items[i].type;
  10686. if (!PhotosMimeType_1.isImage(type)) {
  10687. return false;
  10688. }
  10689. }
  10690. return true;
  10691. };
  10692. DataTransfer.prototype.getCount = function getCount() {
  10693. if (this.data.hasOwnProperty('items')) {
  10694. return this.data.items.length;
  10695. } else if (this.data.hasOwnProperty('mozItemCount')) {
  10696. return this.data.mozItemCount;
  10697. } else if (this.data.files) {
  10698. return this.data.files.length;
  10699. }
  10700. return null;
  10701. };
  10702. /**
  10703. * Get files.
  10704. *
  10705. * @return {array}
  10706. */
  10707. DataTransfer.prototype.getFiles = function getFiles() {
  10708. if (this.data.items) {
  10709. // createArrayFromMixed doesn't properly handle DataTransferItemLists.
  10710. return Array.prototype.slice.call(this.data.items).map(getFileFromDataTransfer).filter(emptyFunction_1.thatReturnsArgument);
  10711. } else if (this.data.files) {
  10712. return Array.prototype.slice.call(this.data.files);
  10713. } else {
  10714. return [];
  10715. }
  10716. };
  10717. /**
  10718. * Are there any files to fetch?
  10719. *
  10720. * @return {boolean}
  10721. */
  10722. DataTransfer.prototype.hasFiles = function hasFiles() {
  10723. return this.getFiles().length > 0;
  10724. };
  10725. return DataTransfer;
  10726. }();
  10727. var DataTransfer_1 = DataTransfer;
  10728. /**
  10729. * Copyright (c) 2013-present, Facebook, Inc.
  10730. * All rights reserved.
  10731. *
  10732. * This source code is licensed under the BSD-style license found in the
  10733. * LICENSE file in the root directory of this source tree. An additional grant
  10734. * of patent rights can be found in the PATENTS file in the same directory.
  10735. *
  10736. * @providesModule getSelectionOffsetKeyForNode
  10737. * @format
  10738. *
  10739. */
  10740. /**
  10741. * Get offset key from a node or it's child nodes. Return the first offset key
  10742. * found on the DOM tree of given node.
  10743. */
  10744. function getSelectionOffsetKeyForNode(node) {
  10745. if (node instanceof Element) {
  10746. var offsetKey = node.getAttribute('data-offset-key');
  10747. if (offsetKey) {
  10748. return offsetKey;
  10749. }
  10750. for (var ii = 0; ii < node.childNodes.length; ii++) {
  10751. var childOffsetKey = getSelectionOffsetKeyForNode(node.childNodes[ii]);
  10752. if (childOffsetKey) {
  10753. return childOffsetKey;
  10754. }
  10755. }
  10756. }
  10757. return null;
  10758. }
  10759. var getSelectionOffsetKeyForNode_1 = getSelectionOffsetKeyForNode;
  10760. /**
  10761. * Get the key from the node's nearest offset-aware ancestor.
  10762. */
  10763. function findAncestorOffsetKey(node) {
  10764. var searchNode = node;
  10765. while (searchNode && searchNode !== document.documentElement) {
  10766. var key = getSelectionOffsetKeyForNode_1(searchNode);
  10767. if (key != null) {
  10768. return key;
  10769. }
  10770. searchNode = searchNode.parentNode;
  10771. }
  10772. return null;
  10773. }
  10774. var findAncestorOffsetKey_1 = findAncestorOffsetKey;
  10775. var TEXT_CLIPPING_REGEX = /\.textClipping$/;
  10776. var TEXT_TYPES = {
  10777. 'text/plain': true,
  10778. 'text/html': true,
  10779. 'text/rtf': true
  10780. };
  10781. // Somewhat arbitrary upper bound on text size. Let's not lock up the browser.
  10782. var TEXT_SIZE_UPPER_BOUND = 5000;
  10783. /**
  10784. * Extract the text content from a file list.
  10785. */
  10786. function getTextContentFromFiles(files, callback) {
  10787. var readCount = 0;
  10788. var results = [];
  10789. files.forEach(function ( /*blob*/file) {
  10790. readFile(file, function ( /*string*/text) {
  10791. readCount++;
  10792. text && results.push(text.slice(0, TEXT_SIZE_UPPER_BOUND));
  10793. if (readCount == files.length) {
  10794. callback(results.join('\r'));
  10795. }
  10796. });
  10797. });
  10798. }
  10799. /**
  10800. * todo isaac: Do work to turn html/rtf into a content fragment.
  10801. */
  10802. function readFile(file, callback) {
  10803. if (!index.commonjsGlobal.FileReader || file.type && !(file.type in TEXT_TYPES)) {
  10804. callback('');
  10805. return;
  10806. }
  10807. if (file.type === '') {
  10808. var contents = '';
  10809. // Special-case text clippings, which have an empty type but include
  10810. // `.textClipping` in the file name. `readAsText` results in an empty
  10811. // string for text clippings, so we force the file name to serve
  10812. // as the text value for the file.
  10813. if (TEXT_CLIPPING_REGEX.test(file.name)) {
  10814. contents = file.name.replace(TEXT_CLIPPING_REGEX, '');
  10815. }
  10816. callback(contents);
  10817. return;
  10818. }
  10819. var reader = new FileReader();
  10820. reader.onload = function () {
  10821. var result = reader.result;
  10822. !(typeof result === 'string') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'We should be calling "FileReader.readAsText" which returns a string') : invariant_1(false) : void 0;
  10823. callback(result);
  10824. };
  10825. reader.onerror = function () {
  10826. callback('');
  10827. };
  10828. reader.readAsText(file);
  10829. }
  10830. var getTextContentFromFiles_1 = getTextContentFromFiles;
  10831. function getUpdatedSelectionState(editorState, anchorKey, anchorOffset, focusKey, focusOffset) {
  10832. var selection = nullthrows_1(editorState.getSelection());
  10833. if (process.env.NODE_ENV !== 'production') {
  10834. if (!anchorKey || !focusKey) {
  10835. /*eslint-disable no-console */
  10836. console.warn('Invalid selection state.', arguments, editorState.toJS());
  10837. /*eslint-enable no-console */
  10838. return selection;
  10839. }
  10840. }
  10841. var anchorPath = DraftOffsetKey_1.decode(anchorKey);
  10842. var anchorBlockKey = anchorPath.blockKey;
  10843. var anchorLeaf = editorState.getBlockTree(anchorBlockKey).getIn([anchorPath.decoratorKey, 'leaves', anchorPath.leafKey]);
  10844. var focusPath = DraftOffsetKey_1.decode(focusKey);
  10845. var focusBlockKey = focusPath.blockKey;
  10846. var focusLeaf = editorState.getBlockTree(focusBlockKey).getIn([focusPath.decoratorKey, 'leaves', focusPath.leafKey]);
  10847. var anchorLeafStart = anchorLeaf.get('start');
  10848. var focusLeafStart = focusLeaf.get('start');
  10849. var anchorBlockOffset = anchorLeaf ? anchorLeafStart + anchorOffset : null;
  10850. var focusBlockOffset = focusLeaf ? focusLeafStart + focusOffset : null;
  10851. var areEqual = selection.getAnchorKey() === anchorBlockKey && selection.getAnchorOffset() === anchorBlockOffset && selection.getFocusKey() === focusBlockKey && selection.getFocusOffset() === focusBlockOffset;
  10852. if (areEqual) {
  10853. return selection;
  10854. }
  10855. var isBackward = false;
  10856. if (anchorBlockKey === focusBlockKey) {
  10857. var anchorLeafEnd = anchorLeaf.get('end');
  10858. var focusLeafEnd = focusLeaf.get('end');
  10859. if (focusLeafStart === anchorLeafStart && focusLeafEnd === anchorLeafEnd) {
  10860. isBackward = focusOffset < anchorOffset;
  10861. } else {
  10862. isBackward = focusLeafStart < anchorLeafStart;
  10863. }
  10864. } else {
  10865. var startKey = editorState.getCurrentContent().getBlockMap().keySeq().skipUntil(function (v) {
  10866. return v === anchorBlockKey || v === focusBlockKey;
  10867. }).first();
  10868. isBackward = startKey === focusBlockKey;
  10869. }
  10870. return selection.merge({
  10871. anchorKey: anchorBlockKey,
  10872. anchorOffset: anchorBlockOffset,
  10873. focusKey: focusBlockKey,
  10874. focusOffset: focusBlockOffset,
  10875. isBackward: isBackward
  10876. });
  10877. }
  10878. var getUpdatedSelectionState_1 = getUpdatedSelectionState;
  10879. /**
  10880. * Get a SelectionState for the supplied mouse event.
  10881. */
  10882. function getSelectionForEvent(event, editorState) {
  10883. var node = null;
  10884. var offset = null;
  10885. if (typeof document.caretRangeFromPoint === 'function') {
  10886. var dropRange = document.caretRangeFromPoint(event.x, event.y);
  10887. node = dropRange.startContainer;
  10888. offset = dropRange.startOffset;
  10889. } else if (event.rangeParent) {
  10890. node = event.rangeParent;
  10891. offset = event.rangeOffset;
  10892. } else {
  10893. return null;
  10894. }
  10895. node = nullthrows_1(node);
  10896. offset = nullthrows_1(offset);
  10897. var offsetKey = nullthrows_1(findAncestorOffsetKey_1(node));
  10898. return getUpdatedSelectionState_1(editorState, offsetKey, offset, offsetKey, offset);
  10899. }
  10900. var DraftEditorDragHandler = {
  10901. /**
  10902. * Drag originating from input terminated.
  10903. */
  10904. onDragEnd: function onDragEnd(editor) {
  10905. editor.exitCurrentMode();
  10906. },
  10907. /**
  10908. * Handle data being dropped.
  10909. */
  10910. onDrop: function onDrop(editor, e) {
  10911. var data = new DataTransfer_1(e.nativeEvent.dataTransfer);
  10912. var editorState = editor._latestEditorState;
  10913. var dropSelection = getSelectionForEvent(e.nativeEvent, editorState);
  10914. e.preventDefault();
  10915. editor.exitCurrentMode();
  10916. if (dropSelection == null) {
  10917. return;
  10918. }
  10919. var files = data.getFiles();
  10920. if (files.length > 0) {
  10921. if (editor.props.handleDroppedFiles && isEventHandled_1(editor.props.handleDroppedFiles(dropSelection, files))) {
  10922. return;
  10923. }
  10924. getTextContentFromFiles_1(files, function (fileText) {
  10925. fileText && editor.update(insertTextAtSelection(editorState, dropSelection, fileText));
  10926. });
  10927. return;
  10928. }
  10929. var dragType = editor._internalDrag ? 'internal' : 'external';
  10930. if (editor.props.handleDrop && isEventHandled_1(editor.props.handleDrop(dropSelection, data, dragType))) {
  10931. return;
  10932. }
  10933. if (editor._internalDrag) {
  10934. editor.update(moveText(editorState, dropSelection));
  10935. return;
  10936. }
  10937. editor.update(insertTextAtSelection(editorState, dropSelection, data.getText()));
  10938. }
  10939. };
  10940. function moveText(editorState, targetSelection) {
  10941. var newContentState = DraftModifier_1.moveText(editorState.getCurrentContent(), editorState.getSelection(), targetSelection);
  10942. return EditorState_1.push(editorState, newContentState, 'insert-fragment');
  10943. }
  10944. /**
  10945. * Insert text at a specified selection.
  10946. */
  10947. function insertTextAtSelection(editorState, selection, text) {
  10948. var newContentState = DraftModifier_1.insertText(editorState.getCurrentContent(), selection, text, editorState.getCurrentInlineStyle());
  10949. return EditorState_1.push(editorState, newContentState, 'insert-fragment');
  10950. }
  10951. var DraftEditorDragHandler_1 = DraftEditorDragHandler;
  10952. (function (global, undefined$1) {
  10953. if (global.setImmediate) {
  10954. return;
  10955. }
  10956. var nextHandle = 1; // Spec says greater than zero
  10957. var tasksByHandle = {};
  10958. var currentlyRunningATask = false;
  10959. var doc = global.document;
  10960. var registerImmediate;
  10961. function setImmediate(callback) {
  10962. // Callback can either be a function or a string
  10963. if (typeof callback !== "function") {
  10964. callback = new Function("" + callback);
  10965. }
  10966. // Copy function arguments
  10967. var args = new Array(arguments.length - 1);
  10968. for (var i = 0; i < args.length; i++) {
  10969. args[i] = arguments[i + 1];
  10970. }
  10971. // Store and register the task
  10972. var task = { callback: callback, args: args };
  10973. tasksByHandle[nextHandle] = task;
  10974. registerImmediate(nextHandle);
  10975. return nextHandle++;
  10976. }
  10977. function clearImmediate(handle) {
  10978. delete tasksByHandle[handle];
  10979. }
  10980. function run(task) {
  10981. var callback = task.callback;
  10982. var args = task.args;
  10983. switch (args.length) {
  10984. case 0:
  10985. callback();
  10986. break;
  10987. case 1:
  10988. callback(args[0]);
  10989. break;
  10990. case 2:
  10991. callback(args[0], args[1]);
  10992. break;
  10993. case 3:
  10994. callback(args[0], args[1], args[2]);
  10995. break;
  10996. default:
  10997. callback.apply(undefined$1, args);
  10998. break;
  10999. }
  11000. }
  11001. function runIfPresent(handle) {
  11002. // From the spec: "Wait until any invocations of this algorithm started before this one have completed."
  11003. // So if we're currently running a task, we'll need to delay this invocation.
  11004. if (currentlyRunningATask) {
  11005. // Delay by doing a setTimeout. setImmediate was tried instead, but in Firefox 7 it generated a
  11006. // "too much recursion" error.
  11007. setTimeout(runIfPresent, 0, handle);
  11008. } else {
  11009. var task = tasksByHandle[handle];
  11010. if (task) {
  11011. currentlyRunningATask = true;
  11012. try {
  11013. run(task);
  11014. } finally {
  11015. clearImmediate(handle);
  11016. currentlyRunningATask = false;
  11017. }
  11018. }
  11019. }
  11020. }
  11021. function installNextTickImplementation() {
  11022. registerImmediate = function(handle) {
  11023. process.nextTick(function () { runIfPresent(handle); });
  11024. };
  11025. }
  11026. function canUsePostMessage() {
  11027. // The test against `importScripts` prevents this implementation from being installed inside a web worker,
  11028. // where `global.postMessage` means something completely different and can't be used for this purpose.
  11029. if (global.postMessage && !global.importScripts) {
  11030. var postMessageIsAsynchronous = true;
  11031. var oldOnMessage = global.onmessage;
  11032. global.onmessage = function() {
  11033. postMessageIsAsynchronous = false;
  11034. };
  11035. global.postMessage("", "*");
  11036. global.onmessage = oldOnMessage;
  11037. return postMessageIsAsynchronous;
  11038. }
  11039. }
  11040. function installPostMessageImplementation() {
  11041. // Installs an event handler on `global` for the `message` event: see
  11042. // * https://developer.mozilla.org/en/DOM/window.postMessage
  11043. // * http://www.whatwg.org/specs/web-apps/current-work/multipage/comms.html#crossDocumentMessages
  11044. var messagePrefix = "setImmediate$" + Math.random() + "$";
  11045. var onGlobalMessage = function(event) {
  11046. if (event.source === global &&
  11047. typeof event.data === "string" &&
  11048. event.data.indexOf(messagePrefix) === 0) {
  11049. runIfPresent(+event.data.slice(messagePrefix.length));
  11050. }
  11051. };
  11052. if (global.addEventListener) {
  11053. global.addEventListener("message", onGlobalMessage, false);
  11054. } else {
  11055. global.attachEvent("onmessage", onGlobalMessage);
  11056. }
  11057. registerImmediate = function(handle) {
  11058. global.postMessage(messagePrefix + handle, "*");
  11059. };
  11060. }
  11061. function installMessageChannelImplementation() {
  11062. var channel = new MessageChannel();
  11063. channel.port1.onmessage = function(event) {
  11064. var handle = event.data;
  11065. runIfPresent(handle);
  11066. };
  11067. registerImmediate = function(handle) {
  11068. channel.port2.postMessage(handle);
  11069. };
  11070. }
  11071. function installReadyStateChangeImplementation() {
  11072. var html = doc.documentElement;
  11073. registerImmediate = function(handle) {
  11074. // Create a <script> element; its readystatechange event will be fired asynchronously once it is inserted
  11075. // into the document. Do so, thus queuing up the task. Remember to clean up once it's been called.
  11076. var script = doc.createElement("script");
  11077. script.onreadystatechange = function () {
  11078. runIfPresent(handle);
  11079. script.onreadystatechange = null;
  11080. html.removeChild(script);
  11081. script = null;
  11082. };
  11083. html.appendChild(script);
  11084. };
  11085. }
  11086. function installSetTimeoutImplementation() {
  11087. registerImmediate = function(handle) {
  11088. setTimeout(runIfPresent, 0, handle);
  11089. };
  11090. }
  11091. // If supported, we should attach to the prototype of global, since that is where setTimeout et al. live.
  11092. var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
  11093. attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
  11094. // Don't get fooled by e.g. browserify environments.
  11095. if ({}.toString.call(global.process) === "[object process]") {
  11096. // For Node.js before 0.9
  11097. installNextTickImplementation();
  11098. } else if (canUsePostMessage()) {
  11099. // For non-IE10 modern browsers
  11100. installPostMessageImplementation();
  11101. } else if (global.MessageChannel) {
  11102. // For web workers, where supported
  11103. installMessageChannelImplementation();
  11104. } else if (doc && "onreadystatechange" in doc.createElement("script")) {
  11105. // For IE 6–8
  11106. installReadyStateChangeImplementation();
  11107. } else {
  11108. // For older browsers
  11109. installSetTimeoutImplementation();
  11110. }
  11111. attachTo.setImmediate = setImmediate;
  11112. attachTo.clearImmediate = clearImmediate;
  11113. }(typeof self === "undefined" ? typeof index.commonjsGlobal === "undefined" ? index.commonjsGlobal : index.commonjsGlobal : self));
  11114. // setimmediate adds setImmediate to the global. We want to make sure we export
  11115. // the actual function.
  11116. var setImmediate = index.commonjsGlobal.setImmediate;
  11117. // When nothing is focused, Firefox regards two characters, `'` and `/`, as
  11118. // commands that should open and focus the "quickfind" search bar. This should
  11119. // *never* happen while a contenteditable is focused, but as of v28, it
  11120. // sometimes does, even when the keypress event target is the contenteditable.
  11121. // This breaks the input. Special case these characters to ensure that when
  11122. // they are typed, we prevent default on the event to make sure not to
  11123. // trigger quickfind.
  11124. var FF_QUICKFIND_CHAR = "'";
  11125. var FF_QUICKFIND_LINK_CHAR = '/';
  11126. var isFirefox = UserAgent_1.isBrowser('Firefox');
  11127. function mustPreventDefaultForCharacter(character) {
  11128. return isFirefox && (character == FF_QUICKFIND_CHAR || character == FF_QUICKFIND_LINK_CHAR);
  11129. }
  11130. /**
  11131. * Replace the current selection with the specified text string, with the
  11132. * inline style and entity key applied to the newly inserted text.
  11133. */
  11134. function replaceText(editorState, text, inlineStyle, entityKey) {
  11135. var contentState = DraftModifier_1.replaceText(editorState.getCurrentContent(), editorState.getSelection(), text, inlineStyle, entityKey);
  11136. return EditorState_1.push(editorState, contentState, 'insert-characters');
  11137. }
  11138. /**
  11139. * When `onBeforeInput` executes, the browser is attempting to insert a
  11140. * character into the editor. Apply this character data to the document,
  11141. * allowing native insertion if possible.
  11142. *
  11143. * Native insertion is encouraged in order to limit re-rendering and to
  11144. * preserve spellcheck highlighting, which disappears or flashes if re-render
  11145. * occurs on the relevant text nodes.
  11146. */
  11147. function editOnBeforeInput(editor, e) {
  11148. if (editor._pendingStateFromBeforeInput !== undefined) {
  11149. editor.update(editor._pendingStateFromBeforeInput);
  11150. editor._pendingStateFromBeforeInput = undefined;
  11151. }
  11152. var editorState = editor._latestEditorState;
  11153. var chars = e.data;
  11154. // In some cases (ex: IE ideographic space insertion) no character data
  11155. // is provided. There's nothing to do when this happens.
  11156. if (!chars) {
  11157. return;
  11158. }
  11159. // Allow the top-level component to handle the insertion manually. This is
  11160. // useful when triggering interesting behaviors for a character insertion,
  11161. // Simple examples: replacing a raw text ':)' with a smile emoji or image
  11162. // decorator, or setting a block to be a list item after typing '- ' at the
  11163. // start of the block.
  11164. if (editor.props.handleBeforeInput && isEventHandled_1(editor.props.handleBeforeInput(chars, editorState))) {
  11165. e.preventDefault();
  11166. return;
  11167. }
  11168. // If selection is collapsed, conditionally allow native behavior. This
  11169. // reduces re-renders and preserves spellcheck highlighting. If the selection
  11170. // is not collapsed, we will re-render.
  11171. var selection = editorState.getSelection();
  11172. var selectionStart = selection.getStartOffset();
  11173. var selectionEnd = selection.getEndOffset();
  11174. var anchorKey = selection.getAnchorKey();
  11175. if (!selection.isCollapsed()) {
  11176. e.preventDefault();
  11177. // If the currently selected text matches what the user is trying to
  11178. // replace it with, let's just update the `SelectionState`. If not, update
  11179. // the `ContentState` with the new text.
  11180. var currentlySelectedChars = editorState.getCurrentContent().getPlainText().slice(selectionStart, selectionEnd);
  11181. if (chars === currentlySelectedChars) {
  11182. editor.update(EditorState_1.forceSelection(editorState, selection.merge({
  11183. focusOffset: selectionEnd
  11184. })));
  11185. } else {
  11186. editor.update(replaceText(editorState, chars, editorState.getCurrentInlineStyle(), getEntityKeyForSelection_1(editorState.getCurrentContent(), editorState.getSelection())));
  11187. }
  11188. return;
  11189. }
  11190. var newEditorState = replaceText(editorState, chars, editorState.getCurrentInlineStyle(), getEntityKeyForSelection_1(editorState.getCurrentContent(), editorState.getSelection()));
  11191. // Bunch of different cases follow where we need to prevent native insertion.
  11192. var mustPreventNative = false;
  11193. if (!mustPreventNative) {
  11194. // Browsers tend to insert text in weird places in the DOM when typing at
  11195. // the start of a leaf, so we'll handle it ourselves.
  11196. mustPreventNative = isSelectionAtLeafStart_1(editor._latestCommittedEditorState);
  11197. }
  11198. if (!mustPreventNative) {
  11199. // Chrome will also split up a node into two pieces if it contains a Tab
  11200. // char, for no explicable reason. Seemingly caused by this commit:
  11201. // https://chromium.googlesource.com/chromium/src/+/013ac5eaf3%5E%21/
  11202. var nativeSelection = index.commonjsGlobal.getSelection();
  11203. // Selection is necessarily collapsed at this point due to earlier check.
  11204. if (nativeSelection.anchorNode && nativeSelection.anchorNode.nodeType === Node.TEXT_NODE) {
  11205. // See isTabHTMLSpanElement in chromium EditingUtilities.cpp.
  11206. var parentNode = nativeSelection.anchorNode.parentNode;
  11207. mustPreventNative = parentNode.nodeName === 'SPAN' && parentNode.firstChild.nodeType === Node.TEXT_NODE && parentNode.firstChild.nodeValue.indexOf('\t') !== -1;
  11208. }
  11209. }
  11210. if (!mustPreventNative) {
  11211. // Check the old and new "fingerprints" of the current block to determine
  11212. // whether this insertion requires any addition or removal of text nodes,
  11213. // in which case we would prevent the native character insertion.
  11214. var originalFingerprint = BlockTree_1.getFingerprint(editorState.getBlockTree(anchorKey));
  11215. var newFingerprint = BlockTree_1.getFingerprint(newEditorState.getBlockTree(anchorKey));
  11216. mustPreventNative = originalFingerprint !== newFingerprint;
  11217. }
  11218. if (!mustPreventNative) {
  11219. mustPreventNative = mustPreventDefaultForCharacter(chars);
  11220. }
  11221. if (!mustPreventNative) {
  11222. mustPreventNative = nullthrows_1(newEditorState.getDirectionMap()).get(anchorKey) !== nullthrows_1(editorState.getDirectionMap()).get(anchorKey);
  11223. }
  11224. if (mustPreventNative) {
  11225. e.preventDefault();
  11226. editor.update(newEditorState);
  11227. return;
  11228. }
  11229. // We made it all the way! Let the browser do its thing and insert the char.
  11230. newEditorState = EditorState_1.set(newEditorState, {
  11231. nativelyRenderedContent: newEditorState.getCurrentContent()
  11232. });
  11233. // The native event is allowed to occur. To allow user onChange handlers to
  11234. // change the inserted text, we wait until the text is actually inserted
  11235. // before we actually update our state. That way when we rerender, the text
  11236. // we see in the DOM will already have been inserted properly.
  11237. editor._pendingStateFromBeforeInput = newEditorState;
  11238. setImmediate(function () {
  11239. if (editor._pendingStateFromBeforeInput !== undefined) {
  11240. editor.update(editor._pendingStateFromBeforeInput);
  11241. editor._pendingStateFromBeforeInput = undefined;
  11242. }
  11243. });
  11244. }
  11245. var editOnBeforeInput_1 = editOnBeforeInput;
  11246. function editOnBlur(editor, e) {
  11247. // In a contentEditable element, when you select a range and then click
  11248. // another active element, this does trigger a `blur` event but will not
  11249. // remove the DOM selection from the contenteditable.
  11250. // This is consistent across all browsers, but we prefer that the editor
  11251. // behave like a textarea, where a `blur` event clears the DOM selection.
  11252. // We therefore force the issue to be certain, checking whether the active
  11253. // element is `body` to force it when blurring occurs within the window (as
  11254. // opposed to clicking to another tab or window).
  11255. if (getActiveElement_1() === document.body) {
  11256. var _selection = index.commonjsGlobal.getSelection();
  11257. var editorNode = editor.editor;
  11258. if (_selection.rangeCount === 1 && containsNode_1(editorNode, _selection.anchorNode) && containsNode_1(editorNode, _selection.focusNode)) {
  11259. _selection.removeAllRanges();
  11260. }
  11261. }
  11262. var editorState = editor._latestEditorState;
  11263. var currentSelection = editorState.getSelection();
  11264. if (!currentSelection.getHasFocus()) {
  11265. return;
  11266. }
  11267. var selection = currentSelection.set('hasFocus', false);
  11268. editor.props.onBlur && editor.props.onBlur(e);
  11269. editor.update(EditorState_1.acceptSelection(editorState, selection));
  11270. }
  11271. var editOnBlur_1 = editOnBlur;
  11272. /**
  11273. * The user has begun using an IME input system. Switching to `composite` mode
  11274. * allows handling composition input and disables other edit behavior.
  11275. */
  11276. function editOnCompositionStart(editor, e) {
  11277. editor.setMode('composite');
  11278. editor.update(EditorState_1.set(editor._latestEditorState, { inCompositionMode: true }));
  11279. // Allow composition handler to interpret the compositionstart event
  11280. editor._onCompositionStart(e);
  11281. }
  11282. var editOnCompositionStart_1 = editOnCompositionStart;
  11283. function getFragmentFromSelection(editorState) {
  11284. var selectionState = editorState.getSelection();
  11285. if (selectionState.isCollapsed()) {
  11286. return null;
  11287. }
  11288. return getContentStateFragment_1(editorState.getCurrentContent(), selectionState);
  11289. }
  11290. var getFragmentFromSelection_1 = getFragmentFromSelection;
  11291. /**
  11292. * If we have a selection, create a ContentState fragment and store
  11293. * it in our internal clipboard. Subsequent paste events will use this
  11294. * fragment if no external clipboard data is supplied.
  11295. */
  11296. function editOnCopy(editor, e) {
  11297. var editorState = editor._latestEditorState;
  11298. var selection = editorState.getSelection();
  11299. // No selection, so there's nothing to copy.
  11300. if (selection.isCollapsed()) {
  11301. e.preventDefault();
  11302. return;
  11303. }
  11304. editor.setClipboard(getFragmentFromSelection_1(editor._latestEditorState));
  11305. }
  11306. var editOnCopy_1 = editOnCopy;
  11307. /**
  11308. * On `cut` events, native behavior is allowed to occur so that the system
  11309. * clipboard is set properly. This means that we need to take steps to recover
  11310. * the editor DOM state after the `cut` has occurred in order to maintain
  11311. * control of the component.
  11312. *
  11313. * In addition, we can keep a copy of the removed fragment, including all
  11314. * styles and entities, for use as an internal paste.
  11315. */
  11316. function editOnCut(editor, e) {
  11317. var editorState = editor._latestEditorState;
  11318. var selection = editorState.getSelection();
  11319. var element = e.target;
  11320. var scrollPosition = void 0;
  11321. // No selection, so there's nothing to cut.
  11322. if (selection.isCollapsed()) {
  11323. e.preventDefault();
  11324. return;
  11325. }
  11326. // Track the current scroll position so that it can be forced back in place
  11327. // after the editor regains control of the DOM.
  11328. if (element instanceof Node) {
  11329. scrollPosition = getScrollPosition_1(Style_1.getScrollParent(element));
  11330. }
  11331. var fragment = getFragmentFromSelection_1(editorState);
  11332. editor.setClipboard(fragment);
  11333. // Set `cut` mode to disable all event handling temporarily.
  11334. editor.setMode('cut');
  11335. // Let native `cut` behavior occur, then recover control.
  11336. setTimeout(function () {
  11337. editor.restoreEditorDOM(scrollPosition);
  11338. editor.exitCurrentMode();
  11339. editor.update(removeFragment(editorState));
  11340. }, 0);
  11341. }
  11342. function removeFragment(editorState) {
  11343. var newContent = DraftModifier_1.removeRange(editorState.getCurrentContent(), editorState.getSelection(), 'forward');
  11344. return EditorState_1.push(editorState, newContent, 'remove-range');
  11345. }
  11346. var editOnCut_1 = editOnCut;
  11347. /**
  11348. * Copyright (c) 2013-present, Facebook, Inc.
  11349. * All rights reserved.
  11350. *
  11351. * This source code is licensed under the BSD-style license found in the
  11352. * LICENSE file in the root directory of this source tree. An additional grant
  11353. * of patent rights can be found in the PATENTS file in the same directory.
  11354. *
  11355. * @providesModule editOnDragOver
  11356. * @format
  11357. *
  11358. */
  11359. /**
  11360. * Drag behavior has begun from outside the editor element.
  11361. */
  11362. function editOnDragOver(editor, e) {
  11363. editor._internalDrag = false;
  11364. editor.setMode('drag');
  11365. e.preventDefault();
  11366. }
  11367. var editOnDragOver_1 = editOnDragOver;
  11368. /**
  11369. * Copyright (c) 2013-present, Facebook, Inc.
  11370. * All rights reserved.
  11371. *
  11372. * This source code is licensed under the BSD-style license found in the
  11373. * LICENSE file in the root directory of this source tree. An additional grant
  11374. * of patent rights can be found in the PATENTS file in the same directory.
  11375. *
  11376. * @providesModule editOnDragStart
  11377. * @format
  11378. *
  11379. */
  11380. /**
  11381. * A `dragstart` event has begun within the text editor component.
  11382. */
  11383. function editOnDragStart(editor) {
  11384. editor._internalDrag = true;
  11385. editor.setMode('drag');
  11386. }
  11387. var editOnDragStart_1 = editOnDragStart;
  11388. function editOnFocus(editor, e) {
  11389. var editorState = editor._latestEditorState;
  11390. var currentSelection = editorState.getSelection();
  11391. if (currentSelection.getHasFocus()) {
  11392. return;
  11393. }
  11394. var selection = currentSelection.set('hasFocus', true);
  11395. editor.props.onFocus && editor.props.onFocus(e);
  11396. // When the tab containing this text editor is hidden and the user does a
  11397. // find-in-page in a _different_ tab, Chrome on Mac likes to forget what the
  11398. // selection was right after sending this focus event and (if you let it)
  11399. // moves the cursor back to the beginning of the editor, so we force the
  11400. // selection here instead of simply accepting it in order to preserve the
  11401. // old cursor position. See https://crbug.com/540004.
  11402. // But it looks like this is fixed in Chrome 60.0.3081.0.
  11403. // Other browsers also don't have this bug, so we prefer to acceptSelection
  11404. // when possible, to ensure that unfocusing and refocusing a Draft editor
  11405. // doesn't preserve the selection, matching how textareas work.
  11406. if (UserAgent_1.isBrowser('Chrome < 60.0.3081.0')) {
  11407. editor.update(EditorState_1.forceSelection(editorState, selection));
  11408. } else {
  11409. editor.update(EditorState_1.acceptSelection(editorState, selection));
  11410. }
  11411. }
  11412. var editOnFocus_1 = editOnFocus;
  11413. var isGecko = UserAgent_1.isEngine('Gecko');
  11414. var DOUBLE_NEWLINE = '\n\n';
  11415. /**
  11416. * This function is intended to handle spellcheck and autocorrect changes,
  11417. * which occur in the DOM natively without any opportunity to observe or
  11418. * interpret the changes before they occur.
  11419. *
  11420. * The `input` event fires in contentEditable elements reliably for non-IE
  11421. * browsers, immediately after changes occur to the editor DOM. Since our other
  11422. * handlers override or otherwise handle cover other varieties of text input,
  11423. * the DOM state should match the model in all controlled input cases. Thus,
  11424. * when an `input` change leads to a DOM/model mismatch, the change should be
  11425. * due to a spellcheck change, and we can incorporate it into our model.
  11426. */
  11427. function editOnInput(editor) {
  11428. if (editor._pendingStateFromBeforeInput !== undefined) {
  11429. editor.update(editor._pendingStateFromBeforeInput);
  11430. editor._pendingStateFromBeforeInput = undefined;
  11431. }
  11432. var domSelection = index.commonjsGlobal.getSelection();
  11433. var anchorNode = domSelection.anchorNode,
  11434. isCollapsed = domSelection.isCollapsed;
  11435. var isNotTextNode = anchorNode.nodeType !== Node.TEXT_NODE;
  11436. var isNotTextOrElementNode = anchorNode.nodeType !== Node.TEXT_NODE && anchorNode.nodeType !== Node.ELEMENT_NODE;
  11437. {
  11438. if (isNotTextOrElementNode) {
  11439. // TODO: (t16149272) figure out context for this change
  11440. return;
  11441. }
  11442. }
  11443. if (anchorNode.nodeType === Node.TEXT_NODE && (anchorNode.previousSibling !== null || anchorNode.nextSibling !== null)) {
  11444. // When typing at the beginning of a visual line, Chrome splits the text
  11445. // nodes into two. Why? No one knows. This commit is suspicious:
  11446. // https://chromium.googlesource.com/chromium/src/+/a3b600981286b135632371477f902214c55a1724
  11447. // To work around, we'll merge the sibling text nodes back into this one.
  11448. var span = anchorNode.parentNode;
  11449. anchorNode.nodeValue = span.textContent;
  11450. for (var child = span.firstChild; child !== null; child = child.nextSibling) {
  11451. if (child !== anchorNode) {
  11452. span.removeChild(child);
  11453. }
  11454. }
  11455. }
  11456. var domText = anchorNode.textContent;
  11457. var editorState = editor._latestEditorState;
  11458. var offsetKey = nullthrows_1(findAncestorOffsetKey_1(anchorNode));
  11459. var _DraftOffsetKey$decod = DraftOffsetKey_1.decode(offsetKey),
  11460. blockKey = _DraftOffsetKey$decod.blockKey,
  11461. decoratorKey = _DraftOffsetKey$decod.decoratorKey,
  11462. leafKey = _DraftOffsetKey$decod.leafKey;
  11463. var _editorState$getBlock = editorState.getBlockTree(blockKey).getIn([decoratorKey, 'leaves', leafKey]),
  11464. start = _editorState$getBlock.start,
  11465. end = _editorState$getBlock.end;
  11466. var content = editorState.getCurrentContent();
  11467. var block = content.getBlockForKey(blockKey);
  11468. var modelText = block.getText().slice(start, end);
  11469. // Special-case soft newlines here. If the DOM text ends in a soft newline,
  11470. // we will have manually inserted an extra soft newline in DraftEditorLeaf.
  11471. // We want to remove this extra newline for the purpose of our comparison
  11472. // of DOM and model text.
  11473. if (domText.endsWith(DOUBLE_NEWLINE)) {
  11474. domText = domText.slice(0, -1);
  11475. }
  11476. // No change -- the DOM is up to date. Nothing to do here.
  11477. if (domText === modelText) {
  11478. // This can be buggy for some Android keyboards because they don't fire
  11479. // standard onkeydown/pressed events and only fired editOnInput
  11480. // so domText is already changed by the browser and ends up being equal
  11481. // to modelText unexpectedly
  11482. return;
  11483. }
  11484. var selection = editorState.getSelection();
  11485. // We'll replace the entire leaf with the text content of the target.
  11486. var targetRange = selection.merge({
  11487. anchorOffset: start,
  11488. focusOffset: end,
  11489. isBackward: false
  11490. });
  11491. var entityKey = block.getEntityAt(start);
  11492. var entity = entityKey && content.getEntity(entityKey);
  11493. var entityType = entity && entity.getMutability();
  11494. var preserveEntity = entityType === 'MUTABLE';
  11495. // Immutable or segmented entities cannot properly be handled by the
  11496. // default browser undo, so we have to use a different change type to
  11497. // force using our internal undo method instead of falling through to the
  11498. // native browser undo.
  11499. var changeType = preserveEntity ? 'spellcheck-change' : 'apply-entity';
  11500. var newContent = DraftModifier_1.replaceText(content, targetRange, domText, block.getInlineStyleAt(start), preserveEntity ? block.getEntityAt(start) : null);
  11501. var anchorOffset, focusOffset, startOffset, endOffset;
  11502. if (isGecko) {
  11503. // Firefox selection does not change while the context menu is open, so
  11504. // we preserve the anchor and focus values of the DOM selection.
  11505. anchorOffset = domSelection.anchorOffset;
  11506. focusOffset = domSelection.focusOffset;
  11507. startOffset = start + Math.min(anchorOffset, focusOffset);
  11508. endOffset = startOffset + Math.abs(anchorOffset - focusOffset);
  11509. anchorOffset = startOffset;
  11510. focusOffset = endOffset;
  11511. } else {
  11512. // Browsers other than Firefox may adjust DOM selection while the context
  11513. // menu is open, and Safari autocorrect is prone to providing an inaccurate
  11514. // DOM selection. Don't trust it. Instead, use our existing SelectionState
  11515. // and adjust it based on the number of characters changed during the
  11516. // mutation.
  11517. var charDelta = domText.length - modelText.length;
  11518. startOffset = selection.getStartOffset();
  11519. endOffset = selection.getEndOffset();
  11520. anchorOffset = isCollapsed ? endOffset + charDelta : startOffset;
  11521. focusOffset = endOffset + charDelta;
  11522. }
  11523. // Segmented entities are completely or partially removed when their
  11524. // text content changes. For this case we do not want any text to be selected
  11525. // after the change, so we are not merging the selection.
  11526. var contentWithAdjustedDOMSelection = newContent.merge({
  11527. selectionBefore: content.getSelectionAfter(),
  11528. selectionAfter: selection.merge({ anchorOffset: anchorOffset, focusOffset: focusOffset })
  11529. });
  11530. editor.update(EditorState_1.push(editorState, contentWithAdjustedDOMSelection, changeType));
  11531. }
  11532. var editOnInput_1 = editOnInput;
  11533. var isOSX = UserAgent_1.isPlatform('Mac OS X');
  11534. var KeyBindingUtil = {
  11535. /**
  11536. * Check whether the ctrlKey modifier is *not* being used in conjunction with
  11537. * the altKey modifier. If they are combined, the result is an `altGraph`
  11538. * key modifier, which should not be handled by this set of key bindings.
  11539. */
  11540. isCtrlKeyCommand: function isCtrlKeyCommand(e) {
  11541. return !!e.ctrlKey && !e.altKey;
  11542. },
  11543. isOptionKeyCommand: function isOptionKeyCommand(e) {
  11544. return isOSX && e.altKey;
  11545. },
  11546. hasCommandModifier: function hasCommandModifier(e) {
  11547. return isOSX ? !!e.metaKey && !e.altKey : KeyBindingUtil.isCtrlKeyCommand(e);
  11548. }
  11549. };
  11550. var KeyBindingUtil_1 = KeyBindingUtil;
  11551. var clipboard = null;
  11552. /**
  11553. * Some systems offer a "secondary" clipboard to allow quick internal cut
  11554. * and paste behavior. For instance, Ctrl+K (cut) and Ctrl+Y (paste).
  11555. */
  11556. var SecondaryClipboard = {
  11557. cut: function cut(editorState) {
  11558. var content = editorState.getCurrentContent();
  11559. var selection = editorState.getSelection();
  11560. var targetRange = null;
  11561. if (selection.isCollapsed()) {
  11562. var anchorKey = selection.getAnchorKey();
  11563. var blockEnd = content.getBlockForKey(anchorKey).getLength();
  11564. if (blockEnd === selection.getAnchorOffset()) {
  11565. return editorState;
  11566. }
  11567. targetRange = selection.set('focusOffset', blockEnd);
  11568. } else {
  11569. targetRange = selection;
  11570. }
  11571. targetRange = nullthrows_1(targetRange);
  11572. clipboard = getContentStateFragment_1(content, targetRange);
  11573. var afterRemoval = DraftModifier_1.removeRange(content, targetRange, 'forward');
  11574. if (afterRemoval === content) {
  11575. return editorState;
  11576. }
  11577. return EditorState_1.push(editorState, afterRemoval, 'remove-range');
  11578. },
  11579. paste: function paste(editorState) {
  11580. if (!clipboard) {
  11581. return editorState;
  11582. }
  11583. var newContent = DraftModifier_1.replaceWithFragment(editorState.getCurrentContent(), editorState.getSelection(), clipboard);
  11584. return EditorState_1.push(editorState, newContent, 'insert-fragment');
  11585. }
  11586. };
  11587. var SecondaryClipboard_1 = SecondaryClipboard;
  11588. // These two ranges are consecutive so anything in [HIGH_START, LOW_END] is a
  11589. // surrogate code unit.
  11590. var SURROGATE_HIGH_START = 0xD800;
  11591. var SURROGATE_HIGH_END = 0xDBFF;
  11592. var SURROGATE_LOW_START = 0xDC00;
  11593. var SURROGATE_LOW_END = 0xDFFF;
  11594. var SURROGATE_UNITS_REGEX = /[\uD800-\uDFFF]/;
  11595. /**
  11596. * @param {number} codeUnit A Unicode code-unit, in range [0, 0x10FFFF]
  11597. * @return {boolean} Whether code-unit is in a surrogate (hi/low) range
  11598. */
  11599. function isCodeUnitInSurrogateRange(codeUnit) {
  11600. return SURROGATE_HIGH_START <= codeUnit && codeUnit <= SURROGATE_LOW_END;
  11601. }
  11602. /**
  11603. * Returns whether the two characters starting at `index` form a surrogate pair.
  11604. * For example, given the string s = "\uD83D\uDE0A", (s, 0) returns true and
  11605. * (s, 1) returns false.
  11606. *
  11607. * @param {string} str
  11608. * @param {number} index
  11609. * @return {boolean}
  11610. */
  11611. function isSurrogatePair(str, index) {
  11612. !(0 <= index && index < str.length) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'isSurrogatePair: Invalid index %s for string length %s.', index, str.length) : invariant_1(false) : void 0;
  11613. if (index + 1 === str.length) {
  11614. return false;
  11615. }
  11616. var first = str.charCodeAt(index);
  11617. var second = str.charCodeAt(index + 1);
  11618. return SURROGATE_HIGH_START <= first && first <= SURROGATE_HIGH_END && SURROGATE_LOW_START <= second && second <= SURROGATE_LOW_END;
  11619. }
  11620. /**
  11621. * @param {string} str Non-empty string
  11622. * @return {boolean} True if the input includes any surrogate code units
  11623. */
  11624. function hasSurrogateUnit(str) {
  11625. return SURROGATE_UNITS_REGEX.test(str);
  11626. }
  11627. /**
  11628. * Return the length of the original Unicode character at given position in the
  11629. * String by looking into the UTF-16 code unit; that is equal to 1 for any
  11630. * non-surrogate characters in BMP ([U+0000..U+D7FF] and [U+E000, U+FFFF]); and
  11631. * returns 2 for the hi/low surrogates ([U+D800..U+DFFF]), which are in fact
  11632. * representing non-BMP characters ([U+10000..U+10FFFF]).
  11633. *
  11634. * Examples:
  11635. * - '\u0020' => 1
  11636. * - '\u3020' => 1
  11637. * - '\uD835' => 2
  11638. * - '\uD835\uDDEF' => 2
  11639. * - '\uDDEF' => 2
  11640. *
  11641. * @param {string} str Non-empty string
  11642. * @param {number} pos Position in the string to look for one code unit
  11643. * @return {number} Number 1 or 2
  11644. */
  11645. function getUTF16Length(str, pos) {
  11646. return 1 + isCodeUnitInSurrogateRange(str.charCodeAt(pos));
  11647. }
  11648. /**
  11649. * Fully Unicode-enabled replacement for String#length
  11650. *
  11651. * @param {string} str Valid Unicode string
  11652. * @return {number} The number of Unicode characters in the string
  11653. */
  11654. function strlen(str) {
  11655. // Call the native functions if there's no surrogate char
  11656. if (!hasSurrogateUnit(str)) {
  11657. return str.length;
  11658. }
  11659. var len = 0;
  11660. for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
  11661. len++;
  11662. }
  11663. return len;
  11664. }
  11665. /**
  11666. * Fully Unicode-enabled replacement for String#substr()
  11667. *
  11668. * @param {string} str Valid Unicode string
  11669. * @param {number} start Location in Unicode sequence to begin extracting
  11670. * @param {?number} length The number of Unicode characters to extract
  11671. * (default: to the end of the string)
  11672. * @return {string} Extracted sub-string
  11673. */
  11674. function substr(str, start, length) {
  11675. start = start || 0;
  11676. length = length === undefined ? Infinity : length || 0;
  11677. // Call the native functions if there's no surrogate char
  11678. if (!hasSurrogateUnit(str)) {
  11679. return str.substr(start, length);
  11680. }
  11681. // Obvious cases
  11682. var size = str.length;
  11683. if (size <= 0 || start > size || length <= 0) {
  11684. return '';
  11685. }
  11686. // Find the actual starting position
  11687. var posA = 0;
  11688. if (start > 0) {
  11689. for (; start > 0 && posA < size; start--) {
  11690. posA += getUTF16Length(str, posA);
  11691. }
  11692. if (posA >= size) {
  11693. return '';
  11694. }
  11695. } else if (start < 0) {
  11696. for (posA = size; start < 0 && 0 < posA; start++) {
  11697. posA -= getUTF16Length(str, posA - 1);
  11698. }
  11699. if (posA < 0) {
  11700. posA = 0;
  11701. }
  11702. }
  11703. // Find the actual ending position
  11704. var posB = size;
  11705. if (length < size) {
  11706. for (posB = posA; length > 0 && posB < size; length--) {
  11707. posB += getUTF16Length(str, posB);
  11708. }
  11709. }
  11710. return str.substring(posA, posB);
  11711. }
  11712. /**
  11713. * Fully Unicode-enabled replacement for String#substring()
  11714. *
  11715. * @param {string} str Valid Unicode string
  11716. * @param {number} start Location in Unicode sequence to begin extracting
  11717. * @param {?number} end Location in Unicode sequence to end extracting
  11718. * (default: end of the string)
  11719. * @return {string} Extracted sub-string
  11720. */
  11721. function substring(str, start, end) {
  11722. start = start || 0;
  11723. end = end === undefined ? Infinity : end || 0;
  11724. if (start < 0) {
  11725. start = 0;
  11726. }
  11727. if (end < 0) {
  11728. end = 0;
  11729. }
  11730. var length = Math.abs(end - start);
  11731. start = start < end ? start : end;
  11732. return substr(str, start, length);
  11733. }
  11734. /**
  11735. * Get a list of Unicode code-points from a String
  11736. *
  11737. * @param {string} str Valid Unicode string
  11738. * @return {array<number>} A list of code-points in [0..0x10FFFF]
  11739. */
  11740. function getCodePoints(str) {
  11741. var codePoints = [];
  11742. for (var pos = 0; pos < str.length; pos += getUTF16Length(str, pos)) {
  11743. codePoints.push(str.codePointAt(pos));
  11744. }
  11745. return codePoints;
  11746. }
  11747. var UnicodeUtils = {
  11748. getCodePoints: getCodePoints,
  11749. getUTF16Length: getUTF16Length,
  11750. hasSurrogateUnit: hasSurrogateUnit,
  11751. isCodeUnitInSurrogateRange: isCodeUnitInSurrogateRange,
  11752. isSurrogatePair: isSurrogatePair,
  11753. strlen: strlen,
  11754. substring: substring,
  11755. substr: substr
  11756. };
  11757. var UnicodeUtils_1 = UnicodeUtils;
  11758. var isChrome = UserAgent_1.isBrowser('Chrome');
  11759. // In Chrome, the client rects will include the entire bounds of all nodes that
  11760. // begin (have a start tag) within the selection, even if the selection does
  11761. // not overlap the entire node. To resolve this, we split the range at each
  11762. // start tag and join the client rects together.
  11763. // https://code.google.com/p/chromium/issues/detail?id=324437
  11764. /* eslint-disable consistent-return */
  11765. function getRangeClientRectsChrome(range) {
  11766. var tempRange = range.cloneRange();
  11767. var clientRects = [];
  11768. for (var ancestor = range.endContainer; ancestor != null; ancestor = ancestor.parentNode) {
  11769. // If we've climbed up to the common ancestor, we can now use the
  11770. // original start point and stop climbing the tree.
  11771. var atCommonAncestor = ancestor === range.commonAncestorContainer;
  11772. if (atCommonAncestor) {
  11773. tempRange.setStart(range.startContainer, range.startOffset);
  11774. } else {
  11775. tempRange.setStart(tempRange.endContainer, 0);
  11776. }
  11777. var rects = Array.from(tempRange.getClientRects());
  11778. clientRects.push(rects);
  11779. if (atCommonAncestor) {
  11780. var _ref;
  11781. clientRects.reverse();
  11782. return (_ref = []).concat.apply(_ref, clientRects);
  11783. }
  11784. tempRange.setEndBefore(ancestor);
  11785. }
  11786. process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Found an unexpected detached subtree when getting range client rects.') : invariant_1(false) ;
  11787. }
  11788. /* eslint-enable consistent-return */
  11789. /**
  11790. * Like range.getClientRects() but normalizes for browser bugs.
  11791. */
  11792. var getRangeClientRects = isChrome ? getRangeClientRectsChrome : function (range) {
  11793. return Array.from(range.getClientRects());
  11794. };
  11795. var getRangeClientRects_1 = getRangeClientRects;
  11796. /**
  11797. * Copyright (c) 2013-present, Facebook, Inc.
  11798. * All rights reserved.
  11799. *
  11800. * This source code is licensed under the BSD-style license found in the
  11801. * LICENSE file in the root directory of this source tree. An additional grant
  11802. * of patent rights can be found in the PATENTS file in the same directory.
  11803. *
  11804. * @providesModule expandRangeToStartOfLine
  11805. * @format
  11806. *
  11807. */
  11808. /**
  11809. * Return the computed line height, in pixels, for the provided element.
  11810. */
  11811. function getLineHeightPx(element) {
  11812. var computed = getComputedStyle(element);
  11813. var div = document.createElement('div');
  11814. div.style.fontFamily = computed.fontFamily;
  11815. div.style.fontSize = computed.fontSize;
  11816. div.style.fontStyle = computed.fontStyle;
  11817. div.style.fontWeight = computed.fontWeight;
  11818. div.style.lineHeight = computed.lineHeight;
  11819. div.style.position = 'absolute';
  11820. div.textContent = 'M';
  11821. var documentBody = document.body;
  11822. !documentBody ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing document.body') : invariant_1(false) : void 0;
  11823. // forced layout here
  11824. documentBody.appendChild(div);
  11825. var rect = div.getBoundingClientRect();
  11826. documentBody.removeChild(div);
  11827. return rect.height;
  11828. }
  11829. /**
  11830. * Return whether every ClientRect in the provided list lies on the same line.
  11831. *
  11832. * We assume that the rects on the same line all contain the baseline, so the
  11833. * lowest top line needs to be above the highest bottom line (i.e., if you were
  11834. * to project the rects onto the y-axis, their intersection would be nonempty).
  11835. *
  11836. * In addition, we require that no two boxes are lineHeight (or more) apart at
  11837. * either top or bottom, which helps protect against false positives for fonts
  11838. * with extremely large glyph heights (e.g., with a font size of 17px, Zapfino
  11839. * produces rects of height 58px!).
  11840. */
  11841. function areRectsOnOneLine(rects, lineHeight) {
  11842. var minTop = Infinity;
  11843. var minBottom = Infinity;
  11844. var maxTop = -Infinity;
  11845. var maxBottom = -Infinity;
  11846. for (var ii = 0; ii < rects.length; ii++) {
  11847. var rect = rects[ii];
  11848. if (rect.width === 0 || rect.width === 1) {
  11849. // When a range starts or ends a soft wrap, many browsers (Chrome, IE,
  11850. // Safari) include an empty rect on the previous or next line. When the
  11851. // text lies in a container whose position is not integral (e.g., from
  11852. // margin: auto), Safari makes these empty rects have width 1 (instead of
  11853. // 0). Having one-pixel-wide characters seems unlikely (and most browsers
  11854. // report widths in subpixel precision anyway) so it's relatively safe to
  11855. // skip over them.
  11856. continue;
  11857. }
  11858. minTop = Math.min(minTop, rect.top);
  11859. minBottom = Math.min(minBottom, rect.bottom);
  11860. maxTop = Math.max(maxTop, rect.top);
  11861. maxBottom = Math.max(maxBottom, rect.bottom);
  11862. }
  11863. return maxTop <= minBottom && maxTop - minTop < lineHeight && maxBottom - minBottom < lineHeight;
  11864. }
  11865. /**
  11866. * Return the length of a node, as used by Range offsets.
  11867. */
  11868. function getNodeLength$1(node) {
  11869. // http://www.w3.org/TR/dom/#concept-node-length
  11870. switch (node.nodeType) {
  11871. case Node.DOCUMENT_TYPE_NODE:
  11872. return 0;
  11873. case Node.TEXT_NODE:
  11874. case Node.PROCESSING_INSTRUCTION_NODE:
  11875. case Node.COMMENT_NODE:
  11876. return node.length;
  11877. default:
  11878. return node.childNodes.length;
  11879. }
  11880. }
  11881. /**
  11882. * Given a collapsed range, move the start position backwards as far as
  11883. * possible while the range still spans only a single line.
  11884. */
  11885. function expandRangeToStartOfLine(range) {
  11886. !range.collapsed ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'expandRangeToStartOfLine: Provided range is not collapsed.') : invariant_1(false) : void 0;
  11887. range = range.cloneRange();
  11888. var containingElement = range.startContainer;
  11889. if (containingElement.nodeType !== 1) {
  11890. containingElement = containingElement.parentNode;
  11891. }
  11892. var lineHeight = getLineHeightPx(containingElement);
  11893. // Imagine our text looks like:
  11894. // <div><span>once upon a time, there was a <em>boy
  11895. // who lived</em> </span><q><strong>under^ the
  11896. // stairs</strong> in a small closet.</q></div>
  11897. // where the caret represents the cursor. First, we crawl up the tree until
  11898. // the range spans multiple lines (setting the start point to before
  11899. // "<strong>", then before "<div>"), then at each level we do a search to
  11900. // find the latest point which is still on a previous line. We'll find that
  11901. // the break point is inside the span, then inside the <em>, then in its text
  11902. // node child, the actual break point before "who".
  11903. var bestContainer = range.endContainer;
  11904. var bestOffset = range.endOffset;
  11905. range.setStart(range.startContainer, 0);
  11906. while (areRectsOnOneLine(getRangeClientRects_1(range), lineHeight)) {
  11907. bestContainer = range.startContainer;
  11908. bestOffset = range.startOffset;
  11909. !bestContainer.parentNode ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Found unexpected detached subtree when traversing.') : invariant_1(false) : void 0;
  11910. range.setStartBefore(bestContainer);
  11911. if (bestContainer.nodeType === 1 && getComputedStyle(bestContainer).display !== 'inline') {
  11912. // The start of the line is never in a different block-level container.
  11913. break;
  11914. }
  11915. }
  11916. // In the above example, range now spans from "<div>" to "under",
  11917. // bestContainer is <div>, and bestOffset is 1 (index of <q> inside <div>)].
  11918. // Picking out which child to recurse into here is a special case since we
  11919. // don't want to check past <q> -- once we find that the final range starts
  11920. // in <span>, we can look at all of its children (and all of their children)
  11921. // to find the break point.
  11922. // At all times, (bestContainer, bestOffset) is the latest single-line start
  11923. // point that we know of.
  11924. var currentContainer = bestContainer;
  11925. var maxIndexToConsider = bestOffset - 1;
  11926. do {
  11927. var nodeValue = currentContainer.nodeValue;
  11928. for (var ii = maxIndexToConsider; ii >= 0; ii--) {
  11929. if (nodeValue != null && ii > 0 && UnicodeUtils_1.isSurrogatePair(nodeValue, ii - 1)) {
  11930. // We're in the middle of a surrogate pair -- skip over so we never
  11931. // return a range with an endpoint in the middle of a code point.
  11932. continue;
  11933. }
  11934. range.setStart(currentContainer, ii);
  11935. if (areRectsOnOneLine(getRangeClientRects_1(range), lineHeight)) {
  11936. bestContainer = currentContainer;
  11937. bestOffset = ii;
  11938. } else {
  11939. break;
  11940. }
  11941. }
  11942. if (ii === -1 || currentContainer.childNodes.length === 0) {
  11943. // If ii === -1, then (bestContainer, bestOffset), which is equal to
  11944. // (currentContainer, 0), was a single-line start point but a start
  11945. // point before currentContainer wasn't, so the line break seems to
  11946. // have occurred immediately after currentContainer's start tag
  11947. //
  11948. // If currentContainer.childNodes.length === 0, we're already at a
  11949. // terminal node (e.g., text node) and should return our current best.
  11950. break;
  11951. }
  11952. currentContainer = currentContainer.childNodes[ii];
  11953. maxIndexToConsider = getNodeLength$1(currentContainer);
  11954. } while (true);
  11955. range.setStart(bestContainer, bestOffset);
  11956. return range;
  11957. }
  11958. var expandRangeToStartOfLine_1 = expandRangeToStartOfLine;
  11959. /**
  11960. * Convert the current selection range to an anchor/focus pair of offset keys
  11961. * and values that can be interpreted by components.
  11962. */
  11963. function getDraftEditorSelectionWithNodes(editorState, root, anchorNode, anchorOffset, focusNode, focusOffset) {
  11964. var anchorIsTextNode = anchorNode.nodeType === Node.TEXT_NODE;
  11965. var focusIsTextNode = focusNode.nodeType === Node.TEXT_NODE;
  11966. // If the selection range lies only on text nodes, the task is simple.
  11967. // Find the nearest offset-aware elements and use the
  11968. // offset values supplied by the selection range.
  11969. if (anchorIsTextNode && focusIsTextNode) {
  11970. return {
  11971. selectionState: getUpdatedSelectionState_1(editorState, nullthrows_1(findAncestorOffsetKey_1(anchorNode)), anchorOffset, nullthrows_1(findAncestorOffsetKey_1(focusNode)), focusOffset),
  11972. needsRecovery: false
  11973. };
  11974. }
  11975. var anchorPoint = null;
  11976. var focusPoint = null;
  11977. var needsRecovery = true;
  11978. // An element is selected. Convert this selection range into leaf offset
  11979. // keys and offset values for consumption at the component level. This
  11980. // is common in Firefox, where select-all and triple click behavior leads
  11981. // to entire elements being selected.
  11982. //
  11983. // Note that we use the `needsRecovery` parameter in the callback here. This
  11984. // is because when certain elements are selected, the behavior for subsequent
  11985. // cursor movement (e.g. via arrow keys) is uncertain and may not match
  11986. // expectations at the component level. For example, if an entire <div> is
  11987. // selected and the user presses the right arrow, Firefox keeps the selection
  11988. // on the <div>. If we allow subsequent keypresses to insert characters
  11989. // natively, they will be inserted into a browser-created text node to the
  11990. // right of that <div>. This is obviously undesirable.
  11991. //
  11992. // With the `needsRecovery` flag, we inform the caller that it is responsible
  11993. // for manually setting the selection state on the rendered document to
  11994. // ensure proper selection state maintenance.
  11995. if (anchorIsTextNode) {
  11996. anchorPoint = {
  11997. key: nullthrows_1(findAncestorOffsetKey_1(anchorNode)),
  11998. offset: anchorOffset
  11999. };
  12000. focusPoint = getPointForNonTextNode(root, focusNode, focusOffset);
  12001. } else if (focusIsTextNode) {
  12002. focusPoint = {
  12003. key: nullthrows_1(findAncestorOffsetKey_1(focusNode)),
  12004. offset: focusOffset
  12005. };
  12006. anchorPoint = getPointForNonTextNode(root, anchorNode, anchorOffset);
  12007. } else {
  12008. anchorPoint = getPointForNonTextNode(root, anchorNode, anchorOffset);
  12009. focusPoint = getPointForNonTextNode(root, focusNode, focusOffset);
  12010. // If the selection is collapsed on an empty block, don't force recovery.
  12011. // This way, on arrow key selection changes, the browser can move the
  12012. // cursor from a non-zero offset on one block, through empty blocks,
  12013. // to a matching non-zero offset on other text blocks.
  12014. if (anchorNode === focusNode && anchorOffset === focusOffset) {
  12015. needsRecovery = !!anchorNode.firstChild && anchorNode.firstChild.nodeName !== 'BR';
  12016. }
  12017. }
  12018. return {
  12019. selectionState: getUpdatedSelectionState_1(editorState, anchorPoint.key, anchorPoint.offset, focusPoint.key, focusPoint.offset),
  12020. needsRecovery: needsRecovery
  12021. };
  12022. }
  12023. /**
  12024. * Identify the first leaf descendant for the given node.
  12025. */
  12026. function getFirstLeaf(node) {
  12027. while (node.firstChild && (
  12028. // data-blocks has no offset
  12029. node.firstChild instanceof Element && node.firstChild.getAttribute('data-blocks') === 'true' || getSelectionOffsetKeyForNode_1(node.firstChild))) {
  12030. node = node.firstChild;
  12031. }
  12032. return node;
  12033. }
  12034. /**
  12035. * Identify the last leaf descendant for the given node.
  12036. */
  12037. function getLastLeaf(node) {
  12038. while (node.lastChild && (
  12039. // data-blocks has no offset
  12040. node.lastChild instanceof Element && node.lastChild.getAttribute('data-blocks') === 'true' || getSelectionOffsetKeyForNode_1(node.lastChild))) {
  12041. node = node.lastChild;
  12042. }
  12043. return node;
  12044. }
  12045. function getPointForNonTextNode(editorRoot, startNode, childOffset) {
  12046. var node = startNode;
  12047. var offsetKey = findAncestorOffsetKey_1(node);
  12048. !(offsetKey != null || editorRoot && (editorRoot === node || editorRoot.firstChild === node)) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Unknown node in selection range.') : invariant_1(false) : void 0;
  12049. // If the editorRoot is the selection, step downward into the content
  12050. // wrapper.
  12051. if (editorRoot === node) {
  12052. node = node.firstChild;
  12053. !(node instanceof Element && node.getAttribute('data-contents') === 'true') ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Invalid DraftEditorContents structure.') : invariant_1(false) : void 0;
  12054. if (childOffset > 0) {
  12055. childOffset = node.childNodes.length;
  12056. }
  12057. }
  12058. // If the child offset is zero and we have an offset key, we're done.
  12059. // If there's no offset key because the entire editor is selected,
  12060. // find the leftmost ("first") leaf in the tree and use that as the offset
  12061. // key.
  12062. if (childOffset === 0) {
  12063. var key = null;
  12064. if (offsetKey != null) {
  12065. key = offsetKey;
  12066. } else {
  12067. var firstLeaf = getFirstLeaf(node);
  12068. key = nullthrows_1(getSelectionOffsetKeyForNode_1(firstLeaf));
  12069. }
  12070. return { key: key, offset: 0 };
  12071. }
  12072. var nodeBeforeCursor = node.childNodes[childOffset - 1];
  12073. var leafKey = null;
  12074. var textLength = null;
  12075. if (!getSelectionOffsetKeyForNode_1(nodeBeforeCursor)) {
  12076. // Our target node may be a leaf or a text node, in which case we're
  12077. // already where we want to be and can just use the child's length as
  12078. // our offset.
  12079. leafKey = nullthrows_1(offsetKey);
  12080. textLength = getTextContentLength(nodeBeforeCursor);
  12081. } else {
  12082. // Otherwise, we'll look at the child to the left of the cursor and find
  12083. // the last leaf node in its subtree.
  12084. var lastLeaf = getLastLeaf(nodeBeforeCursor);
  12085. leafKey = nullthrows_1(getSelectionOffsetKeyForNode_1(lastLeaf));
  12086. textLength = getTextContentLength(lastLeaf);
  12087. }
  12088. return {
  12089. key: leafKey,
  12090. offset: textLength
  12091. };
  12092. }
  12093. /**
  12094. * Return the length of a node's textContent, regarding single newline
  12095. * characters as zero-length. This allows us to avoid problems with identifying
  12096. * the correct selection offset for empty blocks in IE, in which we
  12097. * render newlines instead of break tags.
  12098. */
  12099. function getTextContentLength(node) {
  12100. var textContent = node.textContent;
  12101. return textContent === '\n' ? 0 : textContent.length;
  12102. }
  12103. var getDraftEditorSelectionWithNodes_1 = getDraftEditorSelectionWithNodes;
  12104. /**
  12105. * Copyright (c) 2013-present, Facebook, Inc.
  12106. * All rights reserved.
  12107. *
  12108. * This source code is licensed under the BSD-style license found in the
  12109. * LICENSE file in the root directory of this source tree. An additional grant
  12110. * of patent rights can be found in the PATENTS file in the same directory.
  12111. *
  12112. * @providesModule moveSelectionBackward
  12113. * @format
  12114. *
  12115. */
  12116. /**
  12117. * Given a collapsed selection, move the focus `maxDistance` backward within
  12118. * the selected block. If the selection will go beyond the start of the block,
  12119. * move focus to the end of the previous block, but no further.
  12120. *
  12121. * This function is not Unicode-aware, so surrogate pairs will be treated
  12122. * as having length 2.
  12123. */
  12124. function moveSelectionBackward(editorState, maxDistance) {
  12125. var selection = editorState.getSelection();
  12126. var content = editorState.getCurrentContent();
  12127. var key = selection.getStartKey();
  12128. var offset = selection.getStartOffset();
  12129. var focusKey = key;
  12130. var focusOffset = 0;
  12131. if (maxDistance > offset) {
  12132. var keyBefore = content.getKeyBefore(key);
  12133. if (keyBefore == null) {
  12134. focusKey = key;
  12135. } else {
  12136. focusKey = keyBefore;
  12137. var blockBefore = content.getBlockForKey(keyBefore);
  12138. focusOffset = blockBefore.getText().length;
  12139. }
  12140. } else {
  12141. focusOffset = offset - maxDistance;
  12142. }
  12143. return selection.merge({
  12144. focusKey: focusKey,
  12145. focusOffset: focusOffset,
  12146. isBackward: true
  12147. });
  12148. }
  12149. var moveSelectionBackward_1 = moveSelectionBackward;
  12150. /**
  12151. * For a collapsed selection state, remove text based on the specified strategy.
  12152. * If the selection state is not collapsed, remove the entire selected range.
  12153. */
  12154. function removeTextWithStrategy(editorState, strategy, direction) {
  12155. var selection = editorState.getSelection();
  12156. var content = editorState.getCurrentContent();
  12157. var target = selection;
  12158. if (selection.isCollapsed()) {
  12159. if (direction === 'forward') {
  12160. if (editorState.isSelectionAtEndOfContent()) {
  12161. return content;
  12162. }
  12163. } else if (editorState.isSelectionAtStartOfContent()) {
  12164. return content;
  12165. }
  12166. target = strategy(editorState);
  12167. if (target === selection) {
  12168. return content;
  12169. }
  12170. }
  12171. return DraftModifier_1.removeRange(content, target, direction);
  12172. }
  12173. var removeTextWithStrategy_1 = removeTextWithStrategy;
  12174. function keyCommandBackspaceToStartOfLine(editorState) {
  12175. var afterRemoval = removeTextWithStrategy_1(editorState, function (strategyState) {
  12176. var selection = strategyState.getSelection();
  12177. if (selection.isCollapsed() && selection.getAnchorOffset() === 0) {
  12178. return moveSelectionBackward_1(strategyState, 1);
  12179. }
  12180. var domSelection = index.commonjsGlobal.getSelection();
  12181. var range = domSelection.getRangeAt(0);
  12182. range = expandRangeToStartOfLine_1(range);
  12183. return getDraftEditorSelectionWithNodes_1(strategyState, null, range.endContainer, range.endOffset, range.startContainer, range.startOffset).selectionState;
  12184. }, 'backward');
  12185. if (afterRemoval === editorState.getCurrentContent()) {
  12186. return editorState;
  12187. }
  12188. return EditorState_1.push(editorState, afterRemoval, 'remove-range');
  12189. }
  12190. var keyCommandBackspaceToStartOfLine_1 = keyCommandBackspaceToStartOfLine;
  12191. /**
  12192. * Copyright (c) 2013-present, Facebook, Inc.
  12193. *
  12194. * This source code is licensed under the MIT license found in the
  12195. * LICENSE file in the root directory of this source tree.
  12196. *
  12197. * @typechecks
  12198. * @stub
  12199. *
  12200. */
  12201. // \u00a1-\u00b1\u00b4-\u00b8\u00ba\u00bb\u00bf
  12202. // is latin supplement punctuation except fractions and superscript
  12203. // numbers
  12204. // \u2010-\u2027\u2030-\u205e
  12205. // is punctuation from the general punctuation block:
  12206. // weird quotes, commas, bullets, dashes, etc.
  12207. // \u30fb\u3001\u3002\u3008-\u3011\u3014-\u301f
  12208. // is CJK punctuation
  12209. // \uff1a-\uff1f\uff01-\uff0f\uff3b-\uff40\uff5b-\uff65
  12210. // is some full-width/half-width punctuation
  12211. // \u2E2E\u061f\u066a-\u066c\u061b\u060c\u060d\uFD3e\uFD3F
  12212. // is some Arabic punctuation marks
  12213. // \u1801\u0964\u104a\u104b
  12214. // is misc. other language punctuation marks
  12215. var PUNCTUATION = '[.,+*?$|#{}()\'\\^\\-\\[\\]\\\\\\/!@%"~=<>_:;' + '\u30FB\u3001\u3002\u3008-\u3011\u3014-\u301F\uFF1A-\uFF1F\uFF01-\uFF0F' + '\uFF3B-\uFF40\uFF5B-\uFF65\u2E2E\u061F\u066A-\u066C\u061B\u060C\u060D' + '\uFD3E\uFD3F\u1801\u0964\u104A\u104B\u2010-\u2027\u2030-\u205E' + '\xA1-\xB1\xB4-\xB8\xBA\xBB\xBF]';
  12216. var TokenizeUtil = {
  12217. getPunctuation: function getPunctuation() {
  12218. return PUNCTUATION;
  12219. }
  12220. };
  12221. var punctuation = TokenizeUtil.getPunctuation();
  12222. // The apostrophe and curly single quotes behave in a curious way: when
  12223. // surrounded on both sides by word characters, they behave as word chars; when
  12224. // either neighbor is punctuation or an end of the string, they behave as
  12225. // punctuation.
  12226. var CHAMELEON_CHARS = '[\'\u2018\u2019]';
  12227. // Remove the underscore, which should count as part of the removable word. The
  12228. // "chameleon chars" also count as punctuation in this regex.
  12229. var WHITESPACE_AND_PUNCTUATION = '\\s|(?![_])' + punctuation;
  12230. var DELETE_STRING = '^' + '(?:' + WHITESPACE_AND_PUNCTUATION + ')*' + '(?:' + CHAMELEON_CHARS + '|(?!' + WHITESPACE_AND_PUNCTUATION + ').)*' + '(?:(?!' + WHITESPACE_AND_PUNCTUATION + ').)';
  12231. var DELETE_REGEX = new RegExp(DELETE_STRING);
  12232. var BACKSPACE_STRING = '(?:(?!' + WHITESPACE_AND_PUNCTUATION + ').)' + '(?:' + CHAMELEON_CHARS + '|(?!' + WHITESPACE_AND_PUNCTUATION + ').)*' + '(?:' + WHITESPACE_AND_PUNCTUATION + ')*' + '$';
  12233. var BACKSPACE_REGEX = new RegExp(BACKSPACE_STRING);
  12234. function getRemovableWord(text, isBackward) {
  12235. var matches = isBackward ? BACKSPACE_REGEX.exec(text) : DELETE_REGEX.exec(text);
  12236. return matches ? matches[0] : text;
  12237. }
  12238. var DraftRemovableWord = {
  12239. getBackward: function getBackward(text) {
  12240. return getRemovableWord(text, true);
  12241. },
  12242. getForward: function getForward(text) {
  12243. return getRemovableWord(text, false);
  12244. }
  12245. };
  12246. var DraftRemovableWord_1 = DraftRemovableWord;
  12247. /**
  12248. * Delete the word that is left of the cursor, as well as any spaces or
  12249. * punctuation after the word.
  12250. */
  12251. function keyCommandBackspaceWord(editorState) {
  12252. var afterRemoval = removeTextWithStrategy_1(editorState, function (strategyState) {
  12253. var selection = strategyState.getSelection();
  12254. var offset = selection.getStartOffset();
  12255. // If there are no words before the cursor, remove the preceding newline.
  12256. if (offset === 0) {
  12257. return moveSelectionBackward_1(strategyState, 1);
  12258. }
  12259. var key = selection.getStartKey();
  12260. var content = strategyState.getCurrentContent();
  12261. var text = content.getBlockForKey(key).getText().slice(0, offset);
  12262. var toRemove = DraftRemovableWord_1.getBackward(text);
  12263. return moveSelectionBackward_1(strategyState, toRemove.length || 1);
  12264. }, 'backward');
  12265. if (afterRemoval === editorState.getCurrentContent()) {
  12266. return editorState;
  12267. }
  12268. return EditorState_1.push(editorState, afterRemoval, 'remove-range');
  12269. }
  12270. var keyCommandBackspaceWord_1 = keyCommandBackspaceWord;
  12271. /**
  12272. * Copyright (c) 2013-present, Facebook, Inc.
  12273. * All rights reserved.
  12274. *
  12275. * This source code is licensed under the BSD-style license found in the
  12276. * LICENSE file in the root directory of this source tree. An additional grant
  12277. * of patent rights can be found in the PATENTS file in the same directory.
  12278. *
  12279. * @providesModule moveSelectionForward
  12280. * @format
  12281. *
  12282. */
  12283. /**
  12284. * Given a collapsed selection, move the focus `maxDistance` forward within
  12285. * the selected block. If the selection will go beyond the end of the block,
  12286. * move focus to the start of the next block, but no further.
  12287. *
  12288. * This function is not Unicode-aware, so surrogate pairs will be treated
  12289. * as having length 2.
  12290. */
  12291. function moveSelectionForward(editorState, maxDistance) {
  12292. var selection = editorState.getSelection();
  12293. var key = selection.getStartKey();
  12294. var offset = selection.getStartOffset();
  12295. var content = editorState.getCurrentContent();
  12296. var focusKey = key;
  12297. var focusOffset;
  12298. var block = content.getBlockForKey(key);
  12299. if (maxDistance > block.getText().length - offset) {
  12300. focusKey = content.getKeyAfter(key);
  12301. focusOffset = 0;
  12302. } else {
  12303. focusOffset = offset + maxDistance;
  12304. }
  12305. return selection.merge({ focusKey: focusKey, focusOffset: focusOffset });
  12306. }
  12307. var moveSelectionForward_1 = moveSelectionForward;
  12308. /**
  12309. * Delete the word that is right of the cursor, as well as any spaces or
  12310. * punctuation before the word.
  12311. */
  12312. function keyCommandDeleteWord(editorState) {
  12313. var afterRemoval = removeTextWithStrategy_1(editorState, function (strategyState) {
  12314. var selection = strategyState.getSelection();
  12315. var offset = selection.getStartOffset();
  12316. var key = selection.getStartKey();
  12317. var content = strategyState.getCurrentContent();
  12318. var text = content.getBlockForKey(key).getText().slice(offset);
  12319. var toRemove = DraftRemovableWord_1.getForward(text);
  12320. // If there are no words in front of the cursor, remove the newline.
  12321. return moveSelectionForward_1(strategyState, toRemove.length || 1);
  12322. }, 'forward');
  12323. if (afterRemoval === editorState.getCurrentContent()) {
  12324. return editorState;
  12325. }
  12326. return EditorState_1.push(editorState, afterRemoval, 'remove-range');
  12327. }
  12328. var keyCommandDeleteWord_1 = keyCommandDeleteWord;
  12329. function keyCommandInsertNewline(editorState) {
  12330. var contentState = DraftModifier_1.splitBlock(editorState.getCurrentContent(), editorState.getSelection());
  12331. return EditorState_1.push(editorState, contentState, 'split-block');
  12332. }
  12333. var keyCommandInsertNewline_1 = keyCommandInsertNewline;
  12334. /**
  12335. * See comment for `moveSelectionToStartOfBlock`.
  12336. */
  12337. function keyCommandMoveSelectionToEndOfBlock(editorState) {
  12338. var selection = editorState.getSelection();
  12339. var endKey = selection.getEndKey();
  12340. var content = editorState.getCurrentContent();
  12341. var textLength = content.getBlockForKey(endKey).getLength();
  12342. return EditorState_1.set(editorState, {
  12343. selection: selection.merge({
  12344. anchorKey: endKey,
  12345. anchorOffset: textLength,
  12346. focusKey: endKey,
  12347. focusOffset: textLength,
  12348. isBackward: false
  12349. }),
  12350. forceSelection: true
  12351. });
  12352. }
  12353. var keyCommandMoveSelectionToEndOfBlock_1 = keyCommandMoveSelectionToEndOfBlock;
  12354. /**
  12355. * Collapse selection at the start of the first selected block. This is used
  12356. * for Firefox versions that attempt to navigate forward/backward instead of
  12357. * moving the cursor. Other browsers are able to move the cursor natively.
  12358. */
  12359. function keyCommandMoveSelectionToStartOfBlock(editorState) {
  12360. var selection = editorState.getSelection();
  12361. var startKey = selection.getStartKey();
  12362. return EditorState_1.set(editorState, {
  12363. selection: selection.merge({
  12364. anchorKey: startKey,
  12365. anchorOffset: 0,
  12366. focusKey: startKey,
  12367. focusOffset: 0,
  12368. isBackward: false
  12369. }),
  12370. forceSelection: true
  12371. });
  12372. }
  12373. var keyCommandMoveSelectionToStartOfBlock_1 = keyCommandMoveSelectionToStartOfBlock;
  12374. /**
  12375. * Remove the selected range. If the cursor is collapsed, remove the preceding
  12376. * character. This operation is Unicode-aware, so removing a single character
  12377. * will remove a surrogate pair properly as well.
  12378. */
  12379. function keyCommandPlainBackspace(editorState) {
  12380. var afterRemoval = removeTextWithStrategy_1(editorState, function (strategyState) {
  12381. var selection = strategyState.getSelection();
  12382. var content = strategyState.getCurrentContent();
  12383. var key = selection.getAnchorKey();
  12384. var offset = selection.getAnchorOffset();
  12385. var charBehind = content.getBlockForKey(key).getText()[offset - 1];
  12386. return moveSelectionBackward_1(strategyState, charBehind ? UnicodeUtils_1.getUTF16Length(charBehind, 0) : 1);
  12387. }, 'backward');
  12388. if (afterRemoval === editorState.getCurrentContent()) {
  12389. return editorState;
  12390. }
  12391. var selection = editorState.getSelection();
  12392. return EditorState_1.push(editorState, afterRemoval.set('selectionBefore', selection), selection.isCollapsed() ? 'backspace-character' : 'remove-range');
  12393. }
  12394. var keyCommandPlainBackspace_1 = keyCommandPlainBackspace;
  12395. /**
  12396. * Remove the selected range. If the cursor is collapsed, remove the following
  12397. * character. This operation is Unicode-aware, so removing a single character
  12398. * will remove a surrogate pair properly as well.
  12399. */
  12400. function keyCommandPlainDelete(editorState) {
  12401. var afterRemoval = removeTextWithStrategy_1(editorState, function (strategyState) {
  12402. var selection = strategyState.getSelection();
  12403. var content = strategyState.getCurrentContent();
  12404. var key = selection.getAnchorKey();
  12405. var offset = selection.getAnchorOffset();
  12406. var charAhead = content.getBlockForKey(key).getText()[offset];
  12407. return moveSelectionForward_1(strategyState, charAhead ? UnicodeUtils_1.getUTF16Length(charAhead, 0) : 1);
  12408. }, 'forward');
  12409. if (afterRemoval === editorState.getCurrentContent()) {
  12410. return editorState;
  12411. }
  12412. var selection = editorState.getSelection();
  12413. return EditorState_1.push(editorState, afterRemoval.set('selectionBefore', selection), selection.isCollapsed() ? 'delete-character' : 'remove-range');
  12414. }
  12415. var keyCommandPlainDelete_1 = keyCommandPlainDelete;
  12416. /**
  12417. * Transpose the characters on either side of a collapsed cursor, or
  12418. * if the cursor is at the end of the block, transpose the last two
  12419. * characters.
  12420. */
  12421. function keyCommandTransposeCharacters(editorState) {
  12422. var selection = editorState.getSelection();
  12423. if (!selection.isCollapsed()) {
  12424. return editorState;
  12425. }
  12426. var offset = selection.getAnchorOffset();
  12427. if (offset === 0) {
  12428. return editorState;
  12429. }
  12430. var blockKey = selection.getAnchorKey();
  12431. var content = editorState.getCurrentContent();
  12432. var block = content.getBlockForKey(blockKey);
  12433. var length = block.getLength();
  12434. // Nothing to transpose if there aren't two characters.
  12435. if (length <= 1) {
  12436. return editorState;
  12437. }
  12438. var removalRange;
  12439. var finalSelection;
  12440. if (offset === length) {
  12441. // The cursor is at the end of the block. Swap the last two characters.
  12442. removalRange = selection.set('anchorOffset', offset - 1);
  12443. finalSelection = selection;
  12444. } else {
  12445. removalRange = selection.set('focusOffset', offset + 1);
  12446. finalSelection = removalRange.set('anchorOffset', offset + 1);
  12447. }
  12448. // Extract the character to move as a fragment. This preserves its
  12449. // styling and entity, if any.
  12450. var movedFragment = getContentStateFragment_1(content, removalRange);
  12451. var afterRemoval = DraftModifier_1.removeRange(content, removalRange, 'backward');
  12452. // After the removal, the insertion target is one character back.
  12453. var selectionAfter = afterRemoval.getSelectionAfter();
  12454. var targetOffset = selectionAfter.getAnchorOffset() - 1;
  12455. var targetRange = selectionAfter.merge({
  12456. anchorOffset: targetOffset,
  12457. focusOffset: targetOffset
  12458. });
  12459. var afterInsert = DraftModifier_1.replaceWithFragment(afterRemoval, targetRange, movedFragment);
  12460. var newEditorState = EditorState_1.push(editorState, afterInsert, 'insert-fragment');
  12461. return EditorState_1.acceptSelection(newEditorState, finalSelection);
  12462. }
  12463. var keyCommandTransposeCharacters_1 = keyCommandTransposeCharacters;
  12464. function keyCommandUndo(e, editorState, updateFn) {
  12465. var undoneState = EditorState_1.undo(editorState);
  12466. // If the last change to occur was a spellcheck change, allow the undo
  12467. // event to fall through to the browser. This allows the browser to record
  12468. // the unwanted change, which should soon lead it to learn not to suggest
  12469. // the correction again.
  12470. if (editorState.getLastChangeType() === 'spellcheck-change') {
  12471. var nativelyRenderedContent = undoneState.getCurrentContent();
  12472. updateFn(EditorState_1.set(undoneState, { nativelyRenderedContent: nativelyRenderedContent }));
  12473. return;
  12474. }
  12475. // Otheriwse, manage the undo behavior manually.
  12476. e.preventDefault();
  12477. if (!editorState.getNativelyRenderedContent()) {
  12478. updateFn(undoneState);
  12479. return;
  12480. }
  12481. // Trigger a re-render with the current content state to ensure that the
  12482. // component tree has up-to-date props for comparison.
  12483. updateFn(EditorState_1.set(editorState, { nativelyRenderedContent: null }));
  12484. // Wait to ensure that the re-render has occurred before performing
  12485. // the undo action.
  12486. setTimeout(function () {
  12487. updateFn(undoneState);
  12488. }, 0);
  12489. }
  12490. var keyCommandUndo_1 = keyCommandUndo;
  12491. var isOptionKeyCommand = KeyBindingUtil_1.isOptionKeyCommand;
  12492. var isChrome$1 = UserAgent_1.isBrowser('Chrome');
  12493. /**
  12494. * Map a `DraftEditorCommand` command value to a corresponding function.
  12495. */
  12496. function onKeyCommand(command, editorState) {
  12497. switch (command) {
  12498. case 'redo':
  12499. return EditorState_1.redo(editorState);
  12500. case 'delete':
  12501. return keyCommandPlainDelete_1(editorState);
  12502. case 'delete-word':
  12503. return keyCommandDeleteWord_1(editorState);
  12504. case 'backspace':
  12505. return keyCommandPlainBackspace_1(editorState);
  12506. case 'backspace-word':
  12507. return keyCommandBackspaceWord_1(editorState);
  12508. case 'backspace-to-start-of-line':
  12509. return keyCommandBackspaceToStartOfLine_1(editorState);
  12510. case 'split-block':
  12511. return keyCommandInsertNewline_1(editorState);
  12512. case 'transpose-characters':
  12513. return keyCommandTransposeCharacters_1(editorState);
  12514. case 'move-selection-to-start-of-block':
  12515. return keyCommandMoveSelectionToStartOfBlock_1(editorState);
  12516. case 'move-selection-to-end-of-block':
  12517. return keyCommandMoveSelectionToEndOfBlock_1(editorState);
  12518. case 'secondary-cut':
  12519. return SecondaryClipboard_1.cut(editorState);
  12520. case 'secondary-paste':
  12521. return SecondaryClipboard_1.paste(editorState);
  12522. default:
  12523. return editorState;
  12524. }
  12525. }
  12526. /**
  12527. * Intercept keydown behavior to handle keys and commands manually, if desired.
  12528. *
  12529. * Keydown combinations may be mapped to `DraftCommand` values, which may
  12530. * correspond to command functions that modify the editor or its contents.
  12531. *
  12532. * See `getDefaultKeyBinding` for defaults. Alternatively, the top-level
  12533. * component may provide a custom mapping via the `keyBindingFn` prop.
  12534. */
  12535. function editOnKeyDown(editor, e) {
  12536. var keyCode = e.which;
  12537. var editorState = editor._latestEditorState;
  12538. switch (keyCode) {
  12539. case Keys.RETURN:
  12540. e.preventDefault();
  12541. // The top-level component may manually handle newline insertion. If
  12542. // no special handling is performed, fall through to command handling.
  12543. if (editor.props.handleReturn && isEventHandled_1(editor.props.handleReturn(e, editorState))) {
  12544. return;
  12545. }
  12546. break;
  12547. case Keys.ESC:
  12548. e.preventDefault();
  12549. editor.props.onEscape && editor.props.onEscape(e);
  12550. return;
  12551. case Keys.TAB:
  12552. editor.props.onTab && editor.props.onTab(e);
  12553. return;
  12554. case Keys.UP:
  12555. editor.props.onUpArrow && editor.props.onUpArrow(e);
  12556. return;
  12557. case Keys.RIGHT:
  12558. editor.props.onRightArrow && editor.props.onRightArrow(e);
  12559. return;
  12560. case Keys.DOWN:
  12561. editor.props.onDownArrow && editor.props.onDownArrow(e);
  12562. return;
  12563. case Keys.LEFT:
  12564. editor.props.onLeftArrow && editor.props.onLeftArrow(e);
  12565. return;
  12566. case Keys.SPACE:
  12567. // Handling for OSX where option + space scrolls.
  12568. if (isChrome$1 && isOptionKeyCommand(e)) {
  12569. e.preventDefault();
  12570. // Insert a nbsp into the editor.
  12571. var contentState = DraftModifier_1.replaceText(editorState.getCurrentContent(), editorState.getSelection(), '\xA0');
  12572. editor.update(EditorState_1.push(editorState, contentState, 'insert-characters'));
  12573. return;
  12574. }
  12575. }
  12576. var command = editor.props.keyBindingFn(e);
  12577. // If no command is specified, allow keydown event to continue.
  12578. if (!command) {
  12579. return;
  12580. }
  12581. if (command === 'undo') {
  12582. // Since undo requires some special updating behavior to keep the editor
  12583. // in sync, handle it separately.
  12584. keyCommandUndo_1(e, editorState, editor.update);
  12585. return;
  12586. }
  12587. // At this point, we know that we're handling a command of some kind, so
  12588. // we don't want to insert a character following the keydown.
  12589. e.preventDefault();
  12590. // Allow components higher up the tree to handle the command first.
  12591. if (editor.props.handleKeyCommand && isEventHandled_1(editor.props.handleKeyCommand(command, editorState))) {
  12592. return;
  12593. }
  12594. var newState = onKeyCommand(command, editorState);
  12595. if (newState !== editorState) {
  12596. editor.update(newState);
  12597. }
  12598. }
  12599. var editOnKeyDown_1 = editOnKeyDown;
  12600. /**
  12601. * Copyright (c) 2013-present, Facebook, Inc.
  12602. *
  12603. * This source code is licensed under the MIT license found in the
  12604. * LICENSE file in the root directory of this source tree.
  12605. *
  12606. *
  12607. */
  12608. function _classCallCheck$e(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12609. var URI = function () {
  12610. function URI(uri) {
  12611. _classCallCheck$e(this, URI);
  12612. this._uri = uri;
  12613. }
  12614. URI.prototype.toString = function toString() {
  12615. return this._uri;
  12616. };
  12617. return URI;
  12618. }();
  12619. var URI_1 = URI;
  12620. var isOldIE = UserAgent_1.isBrowser('IE <= 9');
  12621. // Provides a dom node that will not execute scripts
  12622. // https://developer.mozilla.org/en-US/docs/Web/API/DOMImplementation.createHTMLDocument
  12623. // https://developer.mozilla.org/en-US/Add-ons/Code_snippets/HTML_to_DOM
  12624. function getSafeBodyFromHTML(html) {
  12625. var doc;
  12626. var root = null;
  12627. // Provides a safe context
  12628. if (!isOldIE && document.implementation && document.implementation.createHTMLDocument) {
  12629. doc = document.implementation.createHTMLDocument('foo');
  12630. !doc.documentElement ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing doc.documentElement') : invariant_1(false) : void 0;
  12631. doc.documentElement.innerHTML = html;
  12632. root = doc.getElementsByTagName('body')[0];
  12633. }
  12634. return root;
  12635. }
  12636. var getSafeBodyFromHTML_1 = getSafeBodyFromHTML;
  12637. var _extends$4 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  12638. var _knownListItemDepthCl;
  12639. function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
  12640. var _require = immutable,
  12641. Set = _require.Set;
  12642. var experimentalTreeDataSupport = DraftFeatureFlags_1.draft_tree_data_support;
  12643. var List$a = immutable.List,
  12644. OrderedSet$5 = immutable.OrderedSet;
  12645. var NBSP = '&nbsp;';
  12646. var SPACE = ' ';
  12647. // Arbitrary max indent
  12648. var MAX_DEPTH = 4;
  12649. // used for replacing characters in HTML
  12650. var REGEX_CR = new RegExp('\r', 'g');
  12651. var REGEX_LF = new RegExp('\n', 'g');
  12652. var REGEX_NBSP = new RegExp(NBSP, 'g');
  12653. var REGEX_CARRIAGE = new RegExp('&#13;?', 'g');
  12654. var REGEX_ZWS = new RegExp('&#8203;?', 'g');
  12655. // https://developer.mozilla.org/en-US/docs/Web/CSS/font-weight
  12656. var boldValues = ['bold', 'bolder', '500', '600', '700', '800', '900'];
  12657. var notBoldValues = ['light', 'lighter', '100', '200', '300', '400'];
  12658. // Block tag flow is different because LIs do not have
  12659. // a deterministic style ;_;
  12660. var inlineTags = {
  12661. b: 'BOLD',
  12662. code: 'CODE',
  12663. del: 'STRIKETHROUGH',
  12664. em: 'ITALIC',
  12665. i: 'ITALIC',
  12666. s: 'STRIKETHROUGH',
  12667. strike: 'STRIKETHROUGH',
  12668. strong: 'BOLD',
  12669. u: 'UNDERLINE'
  12670. };
  12671. var knownListItemDepthClasses = (_knownListItemDepthCl = {}, _defineProperty(_knownListItemDepthCl, cx_1('public/DraftStyleDefault/depth0'), 0), _defineProperty(_knownListItemDepthCl, cx_1('public/DraftStyleDefault/depth1'), 1), _defineProperty(_knownListItemDepthCl, cx_1('public/DraftStyleDefault/depth2'), 2), _defineProperty(_knownListItemDepthCl, cx_1('public/DraftStyleDefault/depth3'), 3), _defineProperty(_knownListItemDepthCl, cx_1('public/DraftStyleDefault/depth4'), 4), _knownListItemDepthCl);
  12672. var anchorAttr = ['className', 'href', 'rel', 'target', 'title'];
  12673. var imgAttr = ['alt', 'className', 'height', 'src', 'width'];
  12674. var lastBlock = void 0;
  12675. var EMPTY_CHUNK = {
  12676. text: '',
  12677. inlines: [],
  12678. entities: [],
  12679. blocks: []
  12680. };
  12681. var EMPTY_BLOCK = {
  12682. children: List$a(),
  12683. depth: 0,
  12684. key: '',
  12685. type: ''
  12686. };
  12687. var getListBlockType = function getListBlockType(tag, lastList) {
  12688. if (tag === 'li') {
  12689. return lastList === 'ol' ? 'ordered-list-item' : 'unordered-list-item';
  12690. }
  12691. return null;
  12692. };
  12693. var getBlockMapSupportedTags = function getBlockMapSupportedTags(blockRenderMap) {
  12694. var unstyledElement = blockRenderMap.get('unstyled').element;
  12695. var tags = Set([]);
  12696. blockRenderMap.forEach(function (draftBlock) {
  12697. if (draftBlock.aliasedElements) {
  12698. draftBlock.aliasedElements.forEach(function (tag) {
  12699. tags = tags.add(tag);
  12700. });
  12701. }
  12702. tags = tags.add(draftBlock.element);
  12703. });
  12704. return tags.filter(function (tag) {
  12705. return tag && tag !== unstyledElement;
  12706. }).toArray().sort();
  12707. };
  12708. // custom element conversions
  12709. var getMultiMatchedType = function getMultiMatchedType(tag, lastList, multiMatchExtractor) {
  12710. for (var ii = 0; ii < multiMatchExtractor.length; ii++) {
  12711. var matchType = multiMatchExtractor[ii](tag, lastList);
  12712. if (matchType) {
  12713. return matchType;
  12714. }
  12715. }
  12716. return null;
  12717. };
  12718. var getBlockTypeForTag = function getBlockTypeForTag(tag, lastList, blockRenderMap) {
  12719. var matchedTypes = blockRenderMap.filter(function (draftBlock) {
  12720. return draftBlock.element === tag || draftBlock.wrapper === tag || draftBlock.aliasedElements && draftBlock.aliasedElements.some(function (alias) {
  12721. return alias === tag;
  12722. });
  12723. }).keySeq().toSet().toArray().sort();
  12724. // if we dont have any matched type, return unstyled
  12725. // if we have one matched type return it
  12726. // if we have multi matched types use the multi-match function to gather type
  12727. switch (matchedTypes.length) {
  12728. case 0:
  12729. return 'unstyled';
  12730. case 1:
  12731. return matchedTypes[0];
  12732. default:
  12733. return getMultiMatchedType(tag, lastList, [getListBlockType]) || 'unstyled';
  12734. }
  12735. };
  12736. var processInlineTag = function processInlineTag(tag, node, currentStyle) {
  12737. var styleToCheck = inlineTags[tag];
  12738. if (styleToCheck) {
  12739. currentStyle = currentStyle.add(styleToCheck).toOrderedSet();
  12740. } else if (node instanceof HTMLElement) {
  12741. var htmlElement = node;
  12742. currentStyle = currentStyle.withMutations(function (style) {
  12743. var fontWeight = htmlElement.style.fontWeight;
  12744. var fontStyle = htmlElement.style.fontStyle;
  12745. var textDecoration = htmlElement.style.textDecoration;
  12746. if (boldValues.indexOf(fontWeight) >= 0) {
  12747. style.add('BOLD');
  12748. } else if (notBoldValues.indexOf(fontWeight) >= 0) {
  12749. style.remove('BOLD');
  12750. }
  12751. if (fontStyle === 'italic') {
  12752. style.add('ITALIC');
  12753. } else if (fontStyle === 'normal') {
  12754. style.remove('ITALIC');
  12755. }
  12756. if (textDecoration === 'underline') {
  12757. style.add('UNDERLINE');
  12758. }
  12759. if (textDecoration === 'line-through') {
  12760. style.add('STRIKETHROUGH');
  12761. }
  12762. if (textDecoration === 'none') {
  12763. style.remove('UNDERLINE');
  12764. style.remove('STRIKETHROUGH');
  12765. }
  12766. }).toOrderedSet();
  12767. }
  12768. return currentStyle;
  12769. };
  12770. var joinChunks = function joinChunks(A, B, experimentalHasNestedBlocks) {
  12771. // Sometimes two blocks will touch in the DOM and we need to strip the
  12772. // extra delimiter to preserve niceness.
  12773. var lastInA = A.text.slice(-1);
  12774. var firstInB = B.text.slice(0, 1);
  12775. if (lastInA === '\r' && firstInB === '\r' && !experimentalHasNestedBlocks) {
  12776. A.text = A.text.slice(0, -1);
  12777. A.inlines.pop();
  12778. A.entities.pop();
  12779. A.blocks.pop();
  12780. }
  12781. // Kill whitespace after blocks
  12782. if (lastInA === '\r') {
  12783. if (B.text === SPACE || B.text === '\n') {
  12784. return A;
  12785. } else if (firstInB === SPACE || firstInB === '\n') {
  12786. B.text = B.text.slice(1);
  12787. B.inlines.shift();
  12788. B.entities.shift();
  12789. }
  12790. }
  12791. return {
  12792. text: A.text + B.text,
  12793. inlines: A.inlines.concat(B.inlines),
  12794. entities: A.entities.concat(B.entities),
  12795. blocks: A.blocks.concat(B.blocks)
  12796. };
  12797. };
  12798. /**
  12799. * Check to see if we have anything like <p> <blockquote> <h1>... to create
  12800. * block tags from. If we do, we can use those and ignore <div> tags. If we
  12801. * don't, we can treat <div> tags as meaningful (unstyled) blocks.
  12802. */
  12803. var containsSemanticBlockMarkup = function containsSemanticBlockMarkup(html, blockTags) {
  12804. return blockTags.some(function (tag) {
  12805. return html.indexOf('<' + tag) !== -1;
  12806. });
  12807. };
  12808. var hasValidLinkText = function hasValidLinkText(link) {
  12809. !(link instanceof HTMLAnchorElement) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Link must be an HTMLAnchorElement.') : invariant_1(false) : void 0;
  12810. var protocol = link.protocol;
  12811. return protocol === 'http:' || protocol === 'https:' || protocol === 'mailto:';
  12812. };
  12813. var getWhitespaceChunk = function getWhitespaceChunk(inEntity) {
  12814. var entities = new Array(1);
  12815. if (inEntity) {
  12816. entities[0] = inEntity;
  12817. }
  12818. return _extends$4({}, EMPTY_CHUNK, {
  12819. text: SPACE,
  12820. inlines: [OrderedSet$5()],
  12821. entities: entities
  12822. });
  12823. };
  12824. var getSoftNewlineChunk = function getSoftNewlineChunk() {
  12825. return _extends$4({}, EMPTY_CHUNK, {
  12826. text: '\n',
  12827. inlines: [OrderedSet$5()],
  12828. entities: new Array(1)
  12829. });
  12830. };
  12831. var getChunkedBlock = function getChunkedBlock() {
  12832. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  12833. return _extends$4({}, EMPTY_BLOCK, props);
  12834. };
  12835. var getBlockDividerChunk = function getBlockDividerChunk(block, depth) {
  12836. var parentKey = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  12837. return {
  12838. text: '\r',
  12839. inlines: [OrderedSet$5()],
  12840. entities: new Array(1),
  12841. blocks: [getChunkedBlock({
  12842. parent: parentKey,
  12843. key: generateRandomKey_1(),
  12844. type: block,
  12845. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  12846. })]
  12847. };
  12848. };
  12849. /**
  12850. * If we're pasting from one DraftEditor to another we can check to see if
  12851. * existing list item depth classes are being used and preserve this style
  12852. */
  12853. var getListItemDepth = function getListItemDepth(node) {
  12854. var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  12855. Object.keys(knownListItemDepthClasses).some(function (depthClass) {
  12856. if (node.classList.contains(depthClass)) {
  12857. depth = knownListItemDepthClasses[depthClass];
  12858. }
  12859. });
  12860. return depth;
  12861. };
  12862. var genFragment = function genFragment(entityMap, node, inlineStyle, lastList, inBlock, blockTags, depth, blockRenderMap, inEntity, parentKey) {
  12863. var lastLastBlock = lastBlock;
  12864. var nodeName = node.nodeName.toLowerCase();
  12865. var newEntityMap = entityMap;
  12866. var nextBlockType = 'unstyled';
  12867. var newBlock = false;
  12868. var inBlockType = inBlock && getBlockTypeForTag(inBlock, lastList, blockRenderMap);
  12869. var chunk = _extends$4({}, EMPTY_CHUNK);
  12870. var newChunk = null;
  12871. var blockKey = void 0;
  12872. // Base Case
  12873. if (nodeName === '#text') {
  12874. var _text = node.textContent;
  12875. var nodeTextContent = _text.trim();
  12876. // We should not create blocks for leading spaces that are
  12877. // existing around ol/ul and their children list items
  12878. if (lastList && nodeTextContent === '' && node.parentElement) {
  12879. var parentNodeName = node.parentElement.nodeName.toLowerCase();
  12880. if (parentNodeName === 'ol' || parentNodeName === 'ul') {
  12881. return { chunk: _extends$4({}, EMPTY_CHUNK), entityMap: entityMap };
  12882. }
  12883. }
  12884. if (nodeTextContent === '' && inBlock !== 'pre') {
  12885. return { chunk: getWhitespaceChunk(inEntity), entityMap: entityMap };
  12886. }
  12887. if (inBlock !== 'pre') {
  12888. // Can't use empty string because MSWord
  12889. _text = _text.replace(REGEX_LF, SPACE);
  12890. }
  12891. // save the last block so we can use it later
  12892. lastBlock = nodeName;
  12893. return {
  12894. chunk: {
  12895. text: _text,
  12896. inlines: Array(_text.length).fill(inlineStyle),
  12897. entities: Array(_text.length).fill(inEntity),
  12898. blocks: []
  12899. },
  12900. entityMap: entityMap
  12901. };
  12902. }
  12903. // save the last block so we can use it later
  12904. lastBlock = nodeName;
  12905. // BR tags
  12906. if (nodeName === 'br') {
  12907. if (lastLastBlock === 'br' && (!inBlock || inBlockType === 'unstyled')) {
  12908. return {
  12909. chunk: getBlockDividerChunk('unstyled', depth, parentKey),
  12910. entityMap: entityMap
  12911. };
  12912. }
  12913. return { chunk: getSoftNewlineChunk(), entityMap: entityMap };
  12914. }
  12915. // IMG tags
  12916. if (nodeName === 'img' && node instanceof HTMLImageElement && node.attributes.getNamedItem('src') && node.attributes.getNamedItem('src').value) {
  12917. var image = node;
  12918. var entityConfig = {};
  12919. imgAttr.forEach(function (attr) {
  12920. var imageAttribute = image.getAttribute(attr);
  12921. if (imageAttribute) {
  12922. entityConfig[attr] = imageAttribute;
  12923. }
  12924. });
  12925. // Forcing this node to have children because otherwise no entity will be
  12926. // created for this node.
  12927. // The child text node cannot just have a space or return as content -
  12928. // we strip those out.
  12929. // See https://github.com/facebook/draft-js/issues/231 for some context.
  12930. node.textContent = '\uD83D\uDCF7';
  12931. // TODO: update this when we remove DraftEntity entirely
  12932. inEntity = DraftEntity_1.__create('IMAGE', 'MUTABLE', entityConfig || {});
  12933. }
  12934. // Inline tags
  12935. inlineStyle = processInlineTag(nodeName, node, inlineStyle);
  12936. // Handle lists
  12937. if (nodeName === 'ul' || nodeName === 'ol') {
  12938. if (lastList) {
  12939. depth += 1;
  12940. }
  12941. lastList = nodeName;
  12942. }
  12943. if ( nodeName === 'li' && node instanceof HTMLElement) {
  12944. depth = getListItemDepth(node, depth);
  12945. }
  12946. var blockType = getBlockTypeForTag(nodeName, lastList, blockRenderMap);
  12947. var inListBlock = lastList && inBlock === 'li' && nodeName === 'li';
  12948. var inBlockOrHasNestedBlocks = (!inBlock || experimentalTreeDataSupport) && blockTags.indexOf(nodeName) !== -1;
  12949. // Block Tags
  12950. if (inListBlock || inBlockOrHasNestedBlocks) {
  12951. chunk = getBlockDividerChunk(blockType, depth, parentKey);
  12952. blockKey = chunk.blocks[0].key;
  12953. inBlock = nodeName;
  12954. newBlock = !experimentalTreeDataSupport;
  12955. }
  12956. // this is required so that we can handle 'ul' and 'ol'
  12957. if (inListBlock) {
  12958. nextBlockType = lastList === 'ul' ? 'unordered-list-item' : 'ordered-list-item';
  12959. }
  12960. // Recurse through children
  12961. var child = node.firstChild;
  12962. if (child != null) {
  12963. nodeName = child.nodeName.toLowerCase();
  12964. }
  12965. var entityId = null;
  12966. while (child) {
  12967. if (child instanceof HTMLAnchorElement && child.href && hasValidLinkText(child)) {
  12968. (function () {
  12969. var anchor = child;
  12970. var entityConfig = {};
  12971. anchorAttr.forEach(function (attr) {
  12972. var anchorAttribute = anchor.getAttribute(attr);
  12973. if (anchorAttribute) {
  12974. entityConfig[attr] = anchorAttribute;
  12975. }
  12976. });
  12977. entityConfig.url = new URI_1(anchor.href).toString();
  12978. // TODO: update this when we remove DraftEntity completely
  12979. entityId = DraftEntity_1.__create('LINK', 'MUTABLE', entityConfig || {});
  12980. })();
  12981. } else {
  12982. entityId = undefined;
  12983. }
  12984. var _genFragment = genFragment(newEntityMap, child, inlineStyle, lastList, inBlock, blockTags, depth, blockRenderMap, entityId || inEntity, null),
  12985. generatedChunk = _genFragment.chunk,
  12986. maybeUpdatedEntityMap = _genFragment.entityMap;
  12987. newChunk = generatedChunk;
  12988. newEntityMap = maybeUpdatedEntityMap;
  12989. chunk = joinChunks(chunk, newChunk, experimentalTreeDataSupport);
  12990. var sibling = child.nextSibling;
  12991. // Put in a newline to break up blocks inside blocks
  12992. if (!parentKey && sibling && blockTags.indexOf(nodeName) >= 0 && inBlock) {
  12993. chunk = joinChunks(chunk, getSoftNewlineChunk());
  12994. }
  12995. if (sibling) {
  12996. nodeName = sibling.nodeName.toLowerCase();
  12997. }
  12998. child = sibling;
  12999. }
  13000. if (newBlock) {
  13001. chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, parentKey));
  13002. }
  13003. return { chunk: chunk, entityMap: newEntityMap };
  13004. };
  13005. var getChunkForHTML = function getChunkForHTML(html, DOMBuilder, blockRenderMap, entityMap) {
  13006. html = html.trim().replace(REGEX_CR, '').replace(REGEX_NBSP, SPACE).replace(REGEX_CARRIAGE, '').replace(REGEX_ZWS, '');
  13007. var supportedBlockTags = getBlockMapSupportedTags(blockRenderMap);
  13008. var safeBody = DOMBuilder(html);
  13009. if (!safeBody) {
  13010. return null;
  13011. }
  13012. lastBlock = null;
  13013. // Sometimes we aren't dealing with content that contains nice semantic
  13014. // tags. In this case, use divs to separate everything out into paragraphs
  13015. // and hope for the best.
  13016. var workingBlocks = containsSemanticBlockMarkup(html, supportedBlockTags) ? supportedBlockTags : ['div'];
  13017. // Start with -1 block depth to offset the fact that we are passing in a fake
  13018. // UL block to start with.
  13019. var fragment = genFragment(entityMap, safeBody, OrderedSet$5(), 'ul', null, workingBlocks, -1, blockRenderMap);
  13020. var chunk = fragment.chunk;
  13021. var newEntityMap = fragment.entityMap;
  13022. // join with previous block to prevent weirdness on paste
  13023. if (chunk.text.indexOf('\r') === 0) {
  13024. chunk = {
  13025. text: chunk.text.slice(1),
  13026. inlines: chunk.inlines.slice(1),
  13027. entities: chunk.entities.slice(1),
  13028. blocks: chunk.blocks
  13029. };
  13030. }
  13031. // Kill block delimiter at the end
  13032. if (chunk.text.slice(-1) === '\r') {
  13033. chunk.text = chunk.text.slice(0, -1);
  13034. chunk.inlines = chunk.inlines.slice(0, -1);
  13035. chunk.entities = chunk.entities.slice(0, -1);
  13036. chunk.blocks.pop();
  13037. }
  13038. // If we saw no block tags, put an unstyled one in
  13039. if (chunk.blocks.length === 0) {
  13040. chunk.blocks.push(_extends$4({}, EMPTY_CHUNK, {
  13041. type: 'unstyled',
  13042. depth: 0
  13043. }));
  13044. }
  13045. // Sometimes we start with text that isn't in a block, which is then
  13046. // followed by blocks. Need to fix up the blocks to add in
  13047. // an unstyled block for this content
  13048. if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
  13049. chunk.blocks.unshift({ type: 'unstyled', depth: 0 });
  13050. }
  13051. return { chunk: chunk, entityMap: newEntityMap };
  13052. };
  13053. var convertChunkToContentBlocks = function convertChunkToContentBlocks(chunk) {
  13054. if (!chunk || !chunk.text || !Array.isArray(chunk.blocks)) {
  13055. return null;
  13056. }
  13057. var initialState = {
  13058. cacheRef: {},
  13059. contentBlocks: []
  13060. };
  13061. var start = 0;
  13062. var rawBlocks = chunk.blocks,
  13063. rawInlines = chunk.inlines,
  13064. rawEntities = chunk.entities;
  13065. var BlockNodeRecord = ContentBlock_1;
  13066. return chunk.text.split('\r').reduce(function (acc, textBlock, index) {
  13067. // Make absolutely certain that our text is acceptable.
  13068. textBlock = sanitizeDraftText_1(textBlock);
  13069. var block = rawBlocks[index];
  13070. var end = start + textBlock.length;
  13071. var inlines = rawInlines.slice(start, end);
  13072. var entities = rawEntities.slice(start, end);
  13073. var characterList = List$a(inlines.map(function (style, index) {
  13074. var data = { style: style, entity: null };
  13075. if (entities[index]) {
  13076. data.entity = entities[index];
  13077. }
  13078. return CharacterMetadata_1.create(data);
  13079. }));
  13080. start = end + 1;
  13081. var depth = block.depth,
  13082. type = block.type,
  13083. parent = block.parent;
  13084. var key = block.key || generateRandomKey_1();
  13085. var parentTextNodeKey = null; // will be used to store container text nodes
  13086. // childrens add themselves to their parents since we are iterating in order
  13087. if (parent) {
  13088. var parentIndex = acc.cacheRef[parent];
  13089. var parentRecord = acc.contentBlocks[parentIndex];
  13090. // if parent has text we need to split it into a separate unstyled element
  13091. if (parentRecord.getChildKeys().isEmpty() && parentRecord.getText()) {
  13092. var parentCharacterList = parentRecord.getCharacterList();
  13093. var parentText = parentRecord.getText();
  13094. parentTextNodeKey = generateRandomKey_1();
  13095. var textNode = new ContentBlockNode_1({
  13096. key: parentTextNodeKey,
  13097. text: parentText,
  13098. characterList: parentCharacterList,
  13099. parent: parent,
  13100. nextSibling: key
  13101. });
  13102. acc.contentBlocks.push(textNode);
  13103. parentRecord = parentRecord.withMutations(function (block) {
  13104. block.set('characterList', List$a()).set('text', '').set('children', parentRecord.children.push(textNode.getKey()));
  13105. });
  13106. }
  13107. acc.contentBlocks[parentIndex] = parentRecord.set('children', parentRecord.children.push(key));
  13108. }
  13109. var blockNode = new BlockNodeRecord({
  13110. key: key,
  13111. parent: parent,
  13112. type: type,
  13113. depth: depth,
  13114. text: textBlock,
  13115. characterList: characterList,
  13116. prevSibling: parentTextNodeKey || (index === 0 || rawBlocks[index - 1].parent !== parent ? null : rawBlocks[index - 1].key),
  13117. nextSibling: index === rawBlocks.length - 1 || rawBlocks[index + 1].parent !== parent ? null : rawBlocks[index + 1].key
  13118. });
  13119. // insert node
  13120. acc.contentBlocks.push(blockNode);
  13121. // cache ref for building links
  13122. acc.cacheRef[blockNode.key] = index;
  13123. return acc;
  13124. }, initialState).contentBlocks;
  13125. };
  13126. var convertFromHTMLtoContentBlocks = function convertFromHTMLtoContentBlocks(html) {
  13127. var DOMBuilder = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : getSafeBodyFromHTML_1;
  13128. var blockRenderMap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : DefaultDraftBlockRenderMap_1;
  13129. // Be ABSOLUTELY SURE that the dom builder you pass here won't execute
  13130. // arbitrary code in whatever environment you're running this in. For an
  13131. // example of how we try to do this in-browser, see getSafeBodyFromHTML.
  13132. // TODO: replace DraftEntity with an OrderedMap here
  13133. var chunkData = getChunkForHTML(html, DOMBuilder, blockRenderMap, DraftEntity_1);
  13134. if (chunkData == null) {
  13135. return null;
  13136. }
  13137. var chunk = chunkData.chunk,
  13138. entityMap = chunkData.entityMap;
  13139. var contentBlocks = convertChunkToContentBlocks(chunk);
  13140. return {
  13141. contentBlocks: contentBlocks,
  13142. entityMap: entityMap
  13143. };
  13144. };
  13145. var convertFromHTMLToContentBlocks = convertFromHTMLtoContentBlocks;
  13146. var List$b = immutable.List,
  13147. Repeat$6 = immutable.Repeat;
  13148. var ContentBlockRecord$2 = ContentBlock_1;
  13149. var DraftPasteProcessor = {
  13150. processHTML: function processHTML(html, blockRenderMap) {
  13151. return convertFromHTMLToContentBlocks(html, getSafeBodyFromHTML_1, blockRenderMap);
  13152. },
  13153. processText: function processText(textBlocks, character, type) {
  13154. return textBlocks.reduce(function (acc, textLine, index) {
  13155. textLine = sanitizeDraftText_1(textLine);
  13156. var key = generateRandomKey_1();
  13157. var blockNodeConfig = {
  13158. key: key,
  13159. type: type,
  13160. text: textLine,
  13161. characterList: List$b(Repeat$6(character, textLine.length))
  13162. };
  13163. acc.push(new ContentBlockRecord$2(blockNodeConfig));
  13164. return acc;
  13165. }, []);
  13166. }
  13167. };
  13168. var DraftPasteProcessor_1 = DraftPasteProcessor;
  13169. /**
  13170. * Copyright (c) 2013-present, Facebook, Inc.
  13171. * All rights reserved.
  13172. *
  13173. * This source code is licensed under the BSD-style license found in the
  13174. * LICENSE file in the root directory of this source tree. An additional grant
  13175. * of patent rights can be found in the PATENTS file in the same directory.
  13176. *
  13177. * @providesModule adjustBlockDepthForContentState
  13178. * @format
  13179. *
  13180. */
  13181. function adjustBlockDepthForContentState(contentState, selectionState, adjustment, maxDepth) {
  13182. var startKey = selectionState.getStartKey();
  13183. var endKey = selectionState.getEndKey();
  13184. var blockMap = contentState.getBlockMap();
  13185. var blocks = blockMap.toSeq().skipUntil(function (_, k) {
  13186. return k === startKey;
  13187. }).takeUntil(function (_, k) {
  13188. return k === endKey;
  13189. }).concat([[endKey, blockMap.get(endKey)]]).map(function (block) {
  13190. var depth = block.getDepth() + adjustment;
  13191. depth = Math.max(0, Math.min(depth, maxDepth));
  13192. return block.set('depth', depth);
  13193. });
  13194. blockMap = blockMap.merge(blocks);
  13195. return contentState.merge({
  13196. blockMap: blockMap,
  13197. selectionBefore: selectionState,
  13198. selectionAfter: selectionState
  13199. });
  13200. }
  13201. var adjustBlockDepthForContentState_1 = adjustBlockDepthForContentState;
  13202. var RichTextEditorUtil = {
  13203. currentBlockContainsLink: function currentBlockContainsLink(editorState) {
  13204. var selection = editorState.getSelection();
  13205. var contentState = editorState.getCurrentContent();
  13206. var entityMap = contentState.getEntityMap();
  13207. return contentState.getBlockForKey(selection.getAnchorKey()).getCharacterList().slice(selection.getStartOffset(), selection.getEndOffset()).some(function (v) {
  13208. var entity = v.getEntity();
  13209. return !!entity && entityMap.__get(entity).getType() === 'LINK';
  13210. });
  13211. },
  13212. getCurrentBlockType: function getCurrentBlockType(editorState) {
  13213. var selection = editorState.getSelection();
  13214. return editorState.getCurrentContent().getBlockForKey(selection.getStartKey()).getType();
  13215. },
  13216. getDataObjectForLinkURL: function getDataObjectForLinkURL(uri) {
  13217. return { url: uri.toString() };
  13218. },
  13219. handleKeyCommand: function handleKeyCommand(editorState, command) {
  13220. switch (command) {
  13221. case 'bold':
  13222. return RichTextEditorUtil.toggleInlineStyle(editorState, 'BOLD');
  13223. case 'italic':
  13224. return RichTextEditorUtil.toggleInlineStyle(editorState, 'ITALIC');
  13225. case 'underline':
  13226. return RichTextEditorUtil.toggleInlineStyle(editorState, 'UNDERLINE');
  13227. case 'code':
  13228. return RichTextEditorUtil.toggleCode(editorState);
  13229. case 'backspace':
  13230. case 'backspace-word':
  13231. case 'backspace-to-start-of-line':
  13232. return RichTextEditorUtil.onBackspace(editorState);
  13233. case 'delete':
  13234. case 'delete-word':
  13235. case 'delete-to-end-of-block':
  13236. return RichTextEditorUtil.onDelete(editorState);
  13237. default:
  13238. // they may have custom editor commands; ignore those
  13239. return null;
  13240. }
  13241. },
  13242. insertSoftNewline: function insertSoftNewline(editorState) {
  13243. var contentState = DraftModifier_1.insertText(editorState.getCurrentContent(), editorState.getSelection(), '\n', editorState.getCurrentInlineStyle(), null);
  13244. var newEditorState = EditorState_1.push(editorState, contentState, 'insert-characters');
  13245. return EditorState_1.forceSelection(newEditorState, contentState.getSelectionAfter());
  13246. },
  13247. /**
  13248. * For collapsed selections at the start of styled blocks, backspace should
  13249. * just remove the existing style.
  13250. */
  13251. onBackspace: function onBackspace(editorState) {
  13252. var selection = editorState.getSelection();
  13253. if (!selection.isCollapsed() || selection.getAnchorOffset() || selection.getFocusOffset()) {
  13254. return null;
  13255. }
  13256. // First, try to remove a preceding atomic block.
  13257. var content = editorState.getCurrentContent();
  13258. var startKey = selection.getStartKey();
  13259. var blockBefore = content.getBlockBefore(startKey);
  13260. if (blockBefore && blockBefore.getType() === 'atomic') {
  13261. var blockMap = content.getBlockMap()['delete'](blockBefore.getKey());
  13262. var withoutAtomicBlock = content.merge({
  13263. blockMap: blockMap,
  13264. selectionAfter: selection
  13265. });
  13266. if (withoutAtomicBlock !== content) {
  13267. return EditorState_1.push(editorState, withoutAtomicBlock, 'remove-range');
  13268. }
  13269. }
  13270. // If that doesn't succeed, try to remove the current block style.
  13271. var withoutBlockStyle = RichTextEditorUtil.tryToRemoveBlockStyle(editorState);
  13272. if (withoutBlockStyle) {
  13273. return EditorState_1.push(editorState, withoutBlockStyle, 'change-block-type');
  13274. }
  13275. return null;
  13276. },
  13277. onDelete: function onDelete(editorState) {
  13278. var selection = editorState.getSelection();
  13279. if (!selection.isCollapsed()) {
  13280. return null;
  13281. }
  13282. var content = editorState.getCurrentContent();
  13283. var startKey = selection.getStartKey();
  13284. var block = content.getBlockForKey(startKey);
  13285. var length = block.getLength();
  13286. // The cursor is somewhere within the text. Behave normally.
  13287. if (selection.getStartOffset() < length) {
  13288. return null;
  13289. }
  13290. var blockAfter = content.getBlockAfter(startKey);
  13291. if (!blockAfter || blockAfter.getType() !== 'atomic') {
  13292. return null;
  13293. }
  13294. var atomicBlockTarget = selection.merge({
  13295. focusKey: blockAfter.getKey(),
  13296. focusOffset: blockAfter.getLength()
  13297. });
  13298. var withoutAtomicBlock = DraftModifier_1.removeRange(content, atomicBlockTarget, 'forward');
  13299. if (withoutAtomicBlock !== content) {
  13300. return EditorState_1.push(editorState, withoutAtomicBlock, 'remove-range');
  13301. }
  13302. return null;
  13303. },
  13304. onTab: function onTab(event, editorState, maxDepth) {
  13305. var selection = editorState.getSelection();
  13306. var key = selection.getAnchorKey();
  13307. if (key !== selection.getFocusKey()) {
  13308. return editorState;
  13309. }
  13310. var content = editorState.getCurrentContent();
  13311. var block = content.getBlockForKey(key);
  13312. var type = block.getType();
  13313. if (type !== 'unordered-list-item' && type !== 'ordered-list-item') {
  13314. return editorState;
  13315. }
  13316. event.preventDefault();
  13317. // Only allow indenting one level beyond the block above, and only if
  13318. // the block above is a list item as well.
  13319. var blockAbove = content.getBlockBefore(key);
  13320. if (!blockAbove) {
  13321. return editorState;
  13322. }
  13323. var typeAbove = blockAbove.getType();
  13324. if (typeAbove !== 'unordered-list-item' && typeAbove !== 'ordered-list-item') {
  13325. return editorState;
  13326. }
  13327. var depth = block.getDepth();
  13328. if (!event.shiftKey && depth === maxDepth) {
  13329. return editorState;
  13330. }
  13331. maxDepth = Math.min(blockAbove.getDepth() + 1, maxDepth);
  13332. var withAdjustment = adjustBlockDepthForContentState_1(content, selection, event.shiftKey ? -1 : 1, maxDepth);
  13333. return EditorState_1.push(editorState, withAdjustment, 'adjust-depth');
  13334. },
  13335. toggleBlockType: function toggleBlockType(editorState, blockType) {
  13336. var selection = editorState.getSelection();
  13337. var startKey = selection.getStartKey();
  13338. var endKey = selection.getEndKey();
  13339. var content = editorState.getCurrentContent();
  13340. var target = selection;
  13341. // Triple-click can lead to a selection that includes offset 0 of the
  13342. // following block. The `SelectionState` for this case is accurate, but
  13343. // we should avoid toggling block type for the trailing block because it
  13344. // is a confusing interaction.
  13345. if (startKey !== endKey && selection.getEndOffset() === 0) {
  13346. var blockBefore = nullthrows_1(content.getBlockBefore(endKey));
  13347. endKey = blockBefore.getKey();
  13348. target = target.merge({
  13349. anchorKey: startKey,
  13350. anchorOffset: selection.getStartOffset(),
  13351. focusKey: endKey,
  13352. focusOffset: blockBefore.getLength(),
  13353. isBackward: false
  13354. });
  13355. }
  13356. var hasAtomicBlock = content.getBlockMap().skipWhile(function (_, k) {
  13357. return k !== startKey;
  13358. }).reverse().skipWhile(function (_, k) {
  13359. return k !== endKey;
  13360. }).some(function (v) {
  13361. return v.getType() === 'atomic';
  13362. });
  13363. if (hasAtomicBlock) {
  13364. return editorState;
  13365. }
  13366. var typeToSet = content.getBlockForKey(startKey).getType() === blockType ? 'unstyled' : blockType;
  13367. return EditorState_1.push(editorState, DraftModifier_1.setBlockType(content, target, typeToSet), 'change-block-type');
  13368. },
  13369. toggleCode: function toggleCode(editorState) {
  13370. var selection = editorState.getSelection();
  13371. var anchorKey = selection.getAnchorKey();
  13372. var focusKey = selection.getFocusKey();
  13373. if (selection.isCollapsed() || anchorKey !== focusKey) {
  13374. return RichTextEditorUtil.toggleBlockType(editorState, 'code-block');
  13375. }
  13376. return RichTextEditorUtil.toggleInlineStyle(editorState, 'CODE');
  13377. },
  13378. /**
  13379. * Toggle the specified inline style for the selection. If the
  13380. * user's selection is collapsed, apply or remove the style for the
  13381. * internal state. If it is not collapsed, apply the change directly
  13382. * to the document state.
  13383. */
  13384. toggleInlineStyle: function toggleInlineStyle(editorState, inlineStyle) {
  13385. var selection = editorState.getSelection();
  13386. var currentStyle = editorState.getCurrentInlineStyle();
  13387. // If the selection is collapsed, toggle the specified style on or off and
  13388. // set the result as the new inline style override. This will then be
  13389. // used as the inline style for the next character to be inserted.
  13390. if (selection.isCollapsed()) {
  13391. return EditorState_1.setInlineStyleOverride(editorState, currentStyle.has(inlineStyle) ? currentStyle.remove(inlineStyle) : currentStyle.add(inlineStyle));
  13392. }
  13393. // If characters are selected, immediately apply or remove the
  13394. // inline style on the document state itself.
  13395. var content = editorState.getCurrentContent();
  13396. var newContent;
  13397. // If the style is already present for the selection range, remove it.
  13398. // Otherwise, apply it.
  13399. if (currentStyle.has(inlineStyle)) {
  13400. newContent = DraftModifier_1.removeInlineStyle(content, selection, inlineStyle);
  13401. } else {
  13402. newContent = DraftModifier_1.applyInlineStyle(content, selection, inlineStyle);
  13403. }
  13404. return EditorState_1.push(editorState, newContent, 'change-inline-style');
  13405. },
  13406. toggleLink: function toggleLink(editorState, targetSelection, entityKey) {
  13407. var withoutLink = DraftModifier_1.applyEntity(editorState.getCurrentContent(), targetSelection, entityKey);
  13408. return EditorState_1.push(editorState, withoutLink, 'apply-entity');
  13409. },
  13410. /**
  13411. * When a collapsed cursor is at the start of the first styled block, or
  13412. * an empty styled block, changes block to 'unstyled'. Returns null if
  13413. * block or selection does not meet that criteria.
  13414. */
  13415. tryToRemoveBlockStyle: function tryToRemoveBlockStyle(editorState) {
  13416. var selection = editorState.getSelection();
  13417. var offset = selection.getAnchorOffset();
  13418. if (selection.isCollapsed() && offset === 0) {
  13419. var key = selection.getAnchorKey();
  13420. var content = editorState.getCurrentContent();
  13421. var block = content.getBlockForKey(key);
  13422. var firstBlock = content.getFirstBlock();
  13423. if (block.getLength() > 0 && block !== firstBlock) {
  13424. return null;
  13425. }
  13426. var type = block.getType();
  13427. var blockBefore = content.getBlockBefore(key);
  13428. if (type === 'code-block' && blockBefore && blockBefore.getType() === 'code-block' && blockBefore.getLength() !== 0) {
  13429. return null;
  13430. }
  13431. if (type !== 'unstyled') {
  13432. return DraftModifier_1.setBlockType(content, selection, 'unstyled');
  13433. }
  13434. }
  13435. return null;
  13436. }
  13437. };
  13438. var RichTextEditorUtil_1 = RichTextEditorUtil;
  13439. /**
  13440. * Copyright (c) 2013-present, Facebook, Inc.
  13441. * All rights reserved.
  13442. *
  13443. * This source code is licensed under the BSD-style license found in the
  13444. * LICENSE file in the root directory of this source tree. An additional grant
  13445. * of patent rights can be found in the PATENTS file in the same directory.
  13446. *
  13447. * @providesModule splitTextIntoTextBlocks
  13448. * @format
  13449. *
  13450. */
  13451. var NEWLINE_REGEX = /\r\n?|\n/g;
  13452. function splitTextIntoTextBlocks(text) {
  13453. return text.split(NEWLINE_REGEX);
  13454. }
  13455. var splitTextIntoTextBlocks_1 = splitTextIntoTextBlocks;
  13456. /**
  13457. * Paste content.
  13458. */
  13459. function editOnPaste(editor, e) {
  13460. e.preventDefault();
  13461. var data = new DataTransfer_1(e.clipboardData);
  13462. // Get files, unless this is likely to be a string the user wants inline.
  13463. if (!data.isRichText()) {
  13464. var files = data.getFiles();
  13465. var defaultFileText = data.getText();
  13466. if (files.length > 0) {
  13467. // Allow customized paste handling for images, etc. Otherwise, fall
  13468. // through to insert text contents into the editor.
  13469. if (editor.props.handlePastedFiles && isEventHandled_1(editor.props.handlePastedFiles(files))) {
  13470. return;
  13471. }
  13472. getTextContentFromFiles_1(files, function ( /*string*/fileText) {
  13473. fileText = fileText || defaultFileText;
  13474. if (!fileText) {
  13475. return;
  13476. }
  13477. var editorState = editor._latestEditorState;
  13478. var blocks = splitTextIntoTextBlocks_1(fileText);
  13479. var character = CharacterMetadata_1.create({
  13480. style: editorState.getCurrentInlineStyle(),
  13481. entity: getEntityKeyForSelection_1(editorState.getCurrentContent(), editorState.getSelection())
  13482. });
  13483. var currentBlockType = RichTextEditorUtil_1.getCurrentBlockType(editorState);
  13484. var text = DraftPasteProcessor_1.processText(blocks, character, currentBlockType);
  13485. var fragment = BlockMapBuilder_1.createFromArray(text);
  13486. var withInsertedText = DraftModifier_1.replaceWithFragment(editorState.getCurrentContent(), editorState.getSelection(), fragment);
  13487. editor.update(EditorState_1.push(editorState, withInsertedText, 'insert-fragment'));
  13488. });
  13489. return;
  13490. }
  13491. }
  13492. var textBlocks = [];
  13493. var text = data.getText();
  13494. var html = data.getHTML();
  13495. var editorState = editor._latestEditorState;
  13496. if (editor.props.handlePastedText && isEventHandled_1(editor.props.handlePastedText(text, html, editorState))) {
  13497. return;
  13498. }
  13499. if (text) {
  13500. textBlocks = splitTextIntoTextBlocks_1(text);
  13501. }
  13502. if (!editor.props.stripPastedStyles) {
  13503. // If the text from the paste event is rich content that matches what we
  13504. // already have on the internal clipboard, assume that we should just use
  13505. // the clipboard fragment for the paste. This will allow us to preserve
  13506. // styling and entities, if any are present. Note that newlines are
  13507. // stripped during comparison -- this is because copy/paste within the
  13508. // editor in Firefox and IE will not include empty lines. The resulting
  13509. // paste will preserve the newlines correctly.
  13510. var internalClipboard = editor.getClipboard();
  13511. if (data.isRichText() && internalClipboard) {
  13512. if (
  13513. // If the editorKey is present in the pasted HTML, it should be safe to
  13514. // assume this is an internal paste.
  13515. html.indexOf(editor.getEditorKey()) !== -1 ||
  13516. // The copy may have been made within a single block, in which case the
  13517. // editor key won't be part of the paste. In this case, just check
  13518. // whether the pasted text matches the internal clipboard.
  13519. textBlocks.length === 1 && internalClipboard.size === 1 && internalClipboard.first().getText() === text) {
  13520. editor.update(insertFragment$1(editor._latestEditorState, internalClipboard));
  13521. return;
  13522. }
  13523. } else if (internalClipboard && data.types.includes('com.apple.webarchive') && !data.types.includes('text/html') && areTextBlocksAndClipboardEqual(textBlocks, internalClipboard)) {
  13524. // Safari does not properly store text/html in some cases.
  13525. // Use the internalClipboard if present and equal to what is on
  13526. // the clipboard. See https://bugs.webkit.org/show_bug.cgi?id=19893.
  13527. editor.update(insertFragment$1(editor._latestEditorState, internalClipboard));
  13528. return;
  13529. }
  13530. // If there is html paste data, try to parse that.
  13531. if (html) {
  13532. var htmlFragment = DraftPasteProcessor_1.processHTML(html, editor.props.blockRenderMap);
  13533. if (htmlFragment) {
  13534. var contentBlocks = htmlFragment.contentBlocks,
  13535. entityMap = htmlFragment.entityMap;
  13536. if (contentBlocks) {
  13537. var htmlMap = BlockMapBuilder_1.createFromArray(contentBlocks);
  13538. editor.update(insertFragment$1(editor._latestEditorState, htmlMap, entityMap));
  13539. return;
  13540. }
  13541. }
  13542. }
  13543. // Otherwise, create a new fragment from our pasted text. Also
  13544. // empty the internal clipboard, since it's no longer valid.
  13545. editor.setClipboard(null);
  13546. }
  13547. if (textBlocks.length) {
  13548. var character = CharacterMetadata_1.create({
  13549. style: editorState.getCurrentInlineStyle(),
  13550. entity: getEntityKeyForSelection_1(editorState.getCurrentContent(), editorState.getSelection())
  13551. });
  13552. var currentBlockType = RichTextEditorUtil_1.getCurrentBlockType(editorState);
  13553. var textFragment = DraftPasteProcessor_1.processText(textBlocks, character, currentBlockType);
  13554. var textMap = BlockMapBuilder_1.createFromArray(textFragment);
  13555. editor.update(insertFragment$1(editor._latestEditorState, textMap));
  13556. }
  13557. }
  13558. function insertFragment$1(editorState, fragment, entityMap) {
  13559. var newContent = DraftModifier_1.replaceWithFragment(editorState.getCurrentContent(), editorState.getSelection(), fragment);
  13560. // TODO: merge the entity map once we stop using DraftEntity
  13561. // like this:
  13562. // const mergedEntityMap = newContent.getEntityMap().merge(entityMap);
  13563. return EditorState_1.push(editorState, newContent.set('entityMap', entityMap), 'insert-fragment');
  13564. }
  13565. function areTextBlocksAndClipboardEqual(textBlocks, blockMap) {
  13566. return textBlocks.length === blockMap.size && blockMap.valueSeq().every(function (block, ii) {
  13567. return block.getText() === textBlocks[ii];
  13568. });
  13569. }
  13570. var editOnPaste_1 = editOnPaste;
  13571. /**
  13572. * Convert the current selection range to an anchor/focus pair of offset keys
  13573. * and values that can be interpreted by components.
  13574. */
  13575. function getDraftEditorSelection(editorState, root) {
  13576. var selection = index.commonjsGlobal.getSelection();
  13577. // No active selection.
  13578. if (selection.rangeCount === 0) {
  13579. return {
  13580. selectionState: editorState.getSelection().set('hasFocus', false),
  13581. needsRecovery: false
  13582. };
  13583. }
  13584. return getDraftEditorSelectionWithNodes_1(editorState, root, selection.anchorNode, selection.anchorOffset, selection.focusNode, selection.focusOffset);
  13585. }
  13586. var getDraftEditorSelection_1 = getDraftEditorSelection;
  13587. function editOnSelect(editor) {
  13588. if (editor._blockSelectEvents || editor._latestEditorState !== editor.props.editorState) {
  13589. return;
  13590. }
  13591. var editorState = editor.props.editorState;
  13592. var editorNode = ReactDOM__default.findDOMNode(editor.editorContainer);
  13593. !editorNode ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Missing editorNode') : invariant_1(false) : void 0;
  13594. !(editorNode.firstChild instanceof HTMLElement) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'editorNode.firstChild is not an HTMLElement') : invariant_1(false) : void 0;
  13595. var documentSelection = getDraftEditorSelection_1(editorState, editorNode.firstChild);
  13596. var updatedSelectionState = documentSelection.selectionState;
  13597. if (updatedSelectionState !== editorState.getSelection()) {
  13598. if (documentSelection.needsRecovery) {
  13599. editorState = EditorState_1.forceSelection(editorState, updatedSelectionState);
  13600. } else {
  13601. editorState = EditorState_1.acceptSelection(editorState, updatedSelectionState);
  13602. }
  13603. editor.update(editorState);
  13604. }
  13605. }
  13606. var editOnSelect_1 = editOnSelect;
  13607. var DraftEditorEditHandler = {
  13608. onBeforeInput: editOnBeforeInput_1,
  13609. onBlur: editOnBlur_1,
  13610. onCompositionStart: editOnCompositionStart_1,
  13611. onCopy: editOnCopy_1,
  13612. onCut: editOnCut_1,
  13613. onDragOver: editOnDragOver_1,
  13614. onDragStart: editOnDragStart_1,
  13615. onFocus: editOnFocus_1,
  13616. onInput: editOnInput_1,
  13617. onKeyDown: editOnKeyDown_1,
  13618. onPaste: editOnPaste_1,
  13619. onSelect: editOnSelect_1
  13620. };
  13621. var DraftEditorEditHandler_1 = DraftEditorEditHandler;
  13622. function _classCallCheck$f(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13623. function _possibleConstructorReturn$a(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  13624. function _inherits$a(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  13625. /**
  13626. * This component is responsible for rendering placeholder text for the
  13627. * `DraftEditor` component.
  13628. *
  13629. * Override placeholder style via CSS.
  13630. */
  13631. var DraftEditorPlaceholder = function (_React$Component) {
  13632. _inherits$a(DraftEditorPlaceholder, _React$Component);
  13633. function DraftEditorPlaceholder() {
  13634. _classCallCheck$f(this, DraftEditorPlaceholder);
  13635. return _possibleConstructorReturn$a(this, _React$Component.apply(this, arguments));
  13636. }
  13637. DraftEditorPlaceholder.prototype.shouldComponentUpdate = function shouldComponentUpdate(nextProps) {
  13638. return this.props.text !== nextProps.text || this.props.editorState.getSelection().getHasFocus() !== nextProps.editorState.getSelection().getHasFocus();
  13639. };
  13640. DraftEditorPlaceholder.prototype.render = function render() {
  13641. var hasFocus = this.props.editorState.getSelection().getHasFocus();
  13642. var className = cx_1({
  13643. 'public/DraftEditorPlaceholder/root': true,
  13644. 'public/DraftEditorPlaceholder/hasFocus': hasFocus
  13645. });
  13646. var contentStyle = {
  13647. whiteSpace: 'pre-wrap'
  13648. };
  13649. return React__default.createElement(
  13650. 'div',
  13651. { className: className },
  13652. React__default.createElement(
  13653. 'div',
  13654. {
  13655. className: cx_1('public/DraftEditorPlaceholder/inner'),
  13656. id: this.props.accessibilityID,
  13657. style: contentStyle },
  13658. this.props.text
  13659. )
  13660. );
  13661. };
  13662. return DraftEditorPlaceholder;
  13663. }(React__default.Component);
  13664. var DraftEditorPlaceholder_react = DraftEditorPlaceholder;
  13665. var isOSX$1 = UserAgent_1.isPlatform('Mac OS X');
  13666. var isWindows = UserAgent_1.isPlatform('Windows');
  13667. // Firefox on OSX had a bug resulting in navigation instead of cursor movement.
  13668. // This bug was fixed in Firefox 29. Feature detection is virtually impossible
  13669. // so we just check the version number. See #342765.
  13670. var shouldFixFirefoxMovement = isOSX$1 && UserAgent_1.isBrowser('Firefox < 29');
  13671. var hasCommandModifier = KeyBindingUtil_1.hasCommandModifier,
  13672. isCtrlKeyCommand = KeyBindingUtil_1.isCtrlKeyCommand;
  13673. function shouldRemoveWord(e) {
  13674. return isOSX$1 && e.altKey || isCtrlKeyCommand(e);
  13675. }
  13676. /**
  13677. * Get the appropriate undo/redo command for a Z key command.
  13678. */
  13679. function getZCommand(e) {
  13680. if (!hasCommandModifier(e)) {
  13681. return null;
  13682. }
  13683. return e.shiftKey ? 'redo' : 'undo';
  13684. }
  13685. function getDeleteCommand(e) {
  13686. // Allow default "cut" behavior for Windows on Shift + Delete.
  13687. if (isWindows && e.shiftKey) {
  13688. return null;
  13689. }
  13690. return shouldRemoveWord(e) ? 'delete-word' : 'delete';
  13691. }
  13692. function getBackspaceCommand(e) {
  13693. if (hasCommandModifier(e) && isOSX$1) {
  13694. return 'backspace-to-start-of-line';
  13695. }
  13696. return shouldRemoveWord(e) ? 'backspace-word' : 'backspace';
  13697. }
  13698. /**
  13699. * Retrieve a bound key command for the given event.
  13700. */
  13701. function getDefaultKeyBinding(e) {
  13702. switch (e.keyCode) {
  13703. case 66:
  13704. // B
  13705. return hasCommandModifier(e) ? 'bold' : null;
  13706. case 68:
  13707. // D
  13708. return isCtrlKeyCommand(e) ? 'delete' : null;
  13709. case 72:
  13710. // H
  13711. return isCtrlKeyCommand(e) ? 'backspace' : null;
  13712. case 73:
  13713. // I
  13714. return hasCommandModifier(e) ? 'italic' : null;
  13715. case 74:
  13716. // J
  13717. return hasCommandModifier(e) ? 'code' : null;
  13718. case 75:
  13719. // K
  13720. return !isWindows && isCtrlKeyCommand(e) ? 'secondary-cut' : null;
  13721. case 77:
  13722. // M
  13723. return isCtrlKeyCommand(e) ? 'split-block' : null;
  13724. case 79:
  13725. // O
  13726. return isCtrlKeyCommand(e) ? 'split-block' : null;
  13727. case 84:
  13728. // T
  13729. return isOSX$1 && isCtrlKeyCommand(e) ? 'transpose-characters' : null;
  13730. case 85:
  13731. // U
  13732. return hasCommandModifier(e) ? 'underline' : null;
  13733. case 87:
  13734. // W
  13735. return isOSX$1 && isCtrlKeyCommand(e) ? 'backspace-word' : null;
  13736. case 89:
  13737. // Y
  13738. if (isCtrlKeyCommand(e)) {
  13739. return isWindows ? 'redo' : 'secondary-paste';
  13740. }
  13741. return null;
  13742. case 90:
  13743. // Z
  13744. return getZCommand(e) || null;
  13745. case Keys.RETURN:
  13746. return 'split-block';
  13747. case Keys.DELETE:
  13748. return getDeleteCommand(e);
  13749. case Keys.BACKSPACE:
  13750. return getBackspaceCommand(e);
  13751. // LEFT/RIGHT handlers serve as a workaround for a Firefox bug.
  13752. case Keys.LEFT:
  13753. return shouldFixFirefoxMovement && hasCommandModifier(e) ? 'move-selection-to-start-of-block' : null;
  13754. case Keys.RIGHT:
  13755. return shouldFixFirefoxMovement && hasCommandModifier(e) ? 'move-selection-to-end-of-block' : null;
  13756. default:
  13757. return null;
  13758. }
  13759. }
  13760. var getDefaultKeyBinding_1 = getDefaultKeyBinding;
  13761. var _extends$5 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  13762. function _classCallCheck$g(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13763. function _possibleConstructorReturn$b(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  13764. function _inherits$b(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  13765. var isIE = UserAgent_1.isBrowser('IE');
  13766. // IE does not support the `input` event on contentEditable, so we can't
  13767. // observe spellcheck behavior.
  13768. var allowSpellCheck = !isIE;
  13769. // Define a set of handler objects to correspond to each possible `mode`
  13770. // of editor behavior.
  13771. var handlerMap = {
  13772. edit: DraftEditorEditHandler_1,
  13773. composite: DraftEditorCompositionHandler_1,
  13774. drag: DraftEditorDragHandler_1,
  13775. cut: null,
  13776. render: null
  13777. };
  13778. /**
  13779. * `DraftEditor` is the root editor component. It composes a `contentEditable`
  13780. * div, and provides a wide variety of useful function props for managing the
  13781. * state of the editor. See `DraftEditorProps` for details.
  13782. */
  13783. var DraftEditor = function (_React$Component) {
  13784. _inherits$b(DraftEditor, _React$Component);
  13785. function DraftEditor(props) {
  13786. _classCallCheck$g(this, DraftEditor);
  13787. var _this = _possibleConstructorReturn$b(this, _React$Component.call(this, props));
  13788. _this.focus = function (scrollPosition) {
  13789. var editorState = _this.props.editorState;
  13790. var alreadyHasFocus = editorState.getSelection().getHasFocus();
  13791. var editorNode = ReactDOM__default.findDOMNode(_this.editor);
  13792. if (!editorNode) {
  13793. // once in a while people call 'focus' in a setTimeout, and the node has
  13794. // been deleted, so it can be null in that case.
  13795. return;
  13796. }
  13797. var scrollParent = Style_1.getScrollParent(editorNode);
  13798. var _ref = scrollPosition || getScrollPosition_1(scrollParent),
  13799. x = _ref.x,
  13800. y = _ref.y;
  13801. !(editorNode instanceof HTMLElement) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'editorNode is not an HTMLElement') : invariant_1(false) : void 0;
  13802. editorNode.focus();
  13803. // Restore scroll position
  13804. if (scrollParent === window) {
  13805. window.scrollTo(x, y);
  13806. } else {
  13807. Scroll_1.setTop(scrollParent, y);
  13808. }
  13809. // On Chrome and Safari, calling focus on contenteditable focuses the
  13810. // cursor at the first character. This is something you don't expect when
  13811. // you're clicking on an input element but not directly on a character.
  13812. // Put the cursor back where it was before the blur.
  13813. if (!alreadyHasFocus) {
  13814. _this.update(EditorState_1.forceSelection(editorState, editorState.getSelection()));
  13815. }
  13816. };
  13817. _this.blur = function () {
  13818. var editorNode = ReactDOM__default.findDOMNode(_this.editor);
  13819. !(editorNode instanceof HTMLElement) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'editorNode is not an HTMLElement') : invariant_1(false) : void 0;
  13820. editorNode.blur();
  13821. };
  13822. _this.setMode = function (mode) {
  13823. _this._handler = handlerMap[mode];
  13824. };
  13825. _this.exitCurrentMode = function () {
  13826. _this.setMode('edit');
  13827. };
  13828. _this.restoreEditorDOM = function (scrollPosition) {
  13829. _this.setState({ contentsKey: _this.state.contentsKey + 1 }, function () {
  13830. _this.focus(scrollPosition);
  13831. });
  13832. };
  13833. _this.setClipboard = function (clipboard) {
  13834. _this._clipboard = clipboard;
  13835. };
  13836. _this.getClipboard = function () {
  13837. return _this._clipboard;
  13838. };
  13839. _this.update = function (editorState) {
  13840. _this._latestEditorState = editorState;
  13841. _this.props.onChange(editorState);
  13842. };
  13843. _this.onDragEnter = function () {
  13844. _this._dragCount++;
  13845. };
  13846. _this.onDragLeave = function () {
  13847. _this._dragCount--;
  13848. if (_this._dragCount === 0) {
  13849. _this.exitCurrentMode();
  13850. }
  13851. };
  13852. _this._blockSelectEvents = false;
  13853. _this._clipboard = null;
  13854. _this._handler = null;
  13855. _this._dragCount = 0;
  13856. _this._editorKey = props.editorKey || generateRandomKey_1();
  13857. _this._placeholderAccessibilityID = 'placeholder-' + _this._editorKey;
  13858. _this._latestEditorState = props.editorState;
  13859. _this._latestCommittedEditorState = props.editorState;
  13860. _this._onBeforeInput = _this._buildHandler('onBeforeInput');
  13861. _this._onBlur = _this._buildHandler('onBlur');
  13862. _this._onCharacterData = _this._buildHandler('onCharacterData');
  13863. _this._onCompositionEnd = _this._buildHandler('onCompositionEnd');
  13864. _this._onCompositionStart = _this._buildHandler('onCompositionStart');
  13865. _this._onCopy = _this._buildHandler('onCopy');
  13866. _this._onCut = _this._buildHandler('onCut');
  13867. _this._onDragEnd = _this._buildHandler('onDragEnd');
  13868. _this._onDragOver = _this._buildHandler('onDragOver');
  13869. _this._onDragStart = _this._buildHandler('onDragStart');
  13870. _this._onDrop = _this._buildHandler('onDrop');
  13871. _this._onInput = _this._buildHandler('onInput');
  13872. _this._onFocus = _this._buildHandler('onFocus');
  13873. _this._onKeyDown = _this._buildHandler('onKeyDown');
  13874. _this._onKeyPress = _this._buildHandler('onKeyPress');
  13875. _this._onKeyUp = _this._buildHandler('onKeyUp');
  13876. _this._onMouseDown = _this._buildHandler('onMouseDown');
  13877. _this._onMouseUp = _this._buildHandler('onMouseUp');
  13878. _this._onPaste = _this._buildHandler('onPaste');
  13879. _this._onSelect = _this._buildHandler('onSelect');
  13880. _this.getEditorKey = function () {
  13881. return _this._editorKey;
  13882. };
  13883. // See `restoreEditorDOM()`.
  13884. _this.state = { contentsKey: 0 };
  13885. return _this;
  13886. }
  13887. /**
  13888. * Build a method that will pass the event to the specified handler method.
  13889. * This allows us to look up the correct handler function for the current
  13890. * editor mode, if any has been specified.
  13891. */
  13892. /**
  13893. * Define proxies that can route events to the current handler.
  13894. */
  13895. DraftEditor.prototype._buildHandler = function _buildHandler(eventName) {
  13896. var _this2 = this;
  13897. return function (e) {
  13898. if (!_this2.props.readOnly) {
  13899. var method = _this2._handler && _this2._handler[eventName];
  13900. method && method(_this2, e);
  13901. }
  13902. };
  13903. };
  13904. DraftEditor.prototype._showPlaceholder = function _showPlaceholder() {
  13905. return !!this.props.placeholder && !this.props.editorState.isInCompositionMode() && !this.props.editorState.getCurrentContent().hasText();
  13906. };
  13907. DraftEditor.prototype._renderPlaceholder = function _renderPlaceholder() {
  13908. if (this._showPlaceholder()) {
  13909. var placeHolderProps = {
  13910. text: nullthrows_1(this.props.placeholder),
  13911. editorState: this.props.editorState,
  13912. textAlignment: this.props.textAlignment,
  13913. accessibilityID: this._placeholderAccessibilityID
  13914. };
  13915. return React__default.createElement(DraftEditorPlaceholder_react, placeHolderProps);
  13916. }
  13917. return null;
  13918. };
  13919. DraftEditor.prototype.render = function render() {
  13920. var _this3 = this;
  13921. var _props = this.props,
  13922. blockRenderMap = _props.blockRenderMap,
  13923. blockRendererFn = _props.blockRendererFn,
  13924. blockStyleFn = _props.blockStyleFn,
  13925. customStyleFn = _props.customStyleFn,
  13926. customStyleMap = _props.customStyleMap,
  13927. editorState = _props.editorState,
  13928. readOnly = _props.readOnly,
  13929. textAlignment = _props.textAlignment,
  13930. textDirectionality = _props.textDirectionality;
  13931. var rootClass = cx_1({
  13932. 'DraftEditor/root': true,
  13933. 'DraftEditor/alignLeft': textAlignment === 'left',
  13934. 'DraftEditor/alignRight': textAlignment === 'right',
  13935. 'DraftEditor/alignCenter': textAlignment === 'center'
  13936. });
  13937. var contentStyle = {
  13938. outline: 'none',
  13939. // fix parent-draggable Safari bug. #1326
  13940. userSelect: 'text',
  13941. WebkitUserSelect: 'text',
  13942. whiteSpace: 'pre-wrap',
  13943. wordWrap: 'break-word'
  13944. };
  13945. // The aria-expanded and aria-haspopup properties should only be rendered
  13946. // for a combobox.
  13947. var ariaRole = this.props.role || 'textbox';
  13948. var ariaExpanded = ariaRole === 'combobox' ? !!this.props.ariaExpanded : null;
  13949. var editorContentsProps = {
  13950. blockRenderMap: blockRenderMap,
  13951. blockRendererFn: blockRendererFn,
  13952. blockStyleFn: blockStyleFn,
  13953. customStyleMap: _extends$5({}, DefaultDraftInlineStyle, customStyleMap),
  13954. customStyleFn: customStyleFn,
  13955. editorKey: this._editorKey,
  13956. editorState: editorState,
  13957. key: 'contents' + this.state.contentsKey,
  13958. textDirectionality: textDirectionality
  13959. };
  13960. return React__default.createElement(
  13961. 'div',
  13962. { className: rootClass },
  13963. this._renderPlaceholder(),
  13964. React__default.createElement(
  13965. 'div',
  13966. {
  13967. className: cx_1('DraftEditor/editorContainer'),
  13968. ref: function ref(_ref3) {
  13969. return _this3.editorContainer = _ref3;
  13970. } },
  13971. React__default.createElement(
  13972. 'div',
  13973. {
  13974. 'aria-activedescendant': readOnly ? null : this.props.ariaActiveDescendantID,
  13975. 'aria-autocomplete': readOnly ? null : this.props.ariaAutoComplete,
  13976. 'aria-controls': readOnly ? null : this.props.ariaControls,
  13977. 'aria-describedby': this.props.ariaDescribedBy || this._placeholderAccessibilityID,
  13978. 'aria-expanded': readOnly ? null : ariaExpanded,
  13979. 'aria-label': this.props.ariaLabel,
  13980. 'aria-labelledby': this.props.ariaLabelledBy,
  13981. 'aria-multiline': this.props.ariaMultiline,
  13982. autoCapitalize: this.props.autoCapitalize,
  13983. autoComplete: this.props.autoComplete,
  13984. autoCorrect: this.props.autoCorrect,
  13985. className: cx_1({
  13986. // Chrome's built-in translation feature mutates the DOM in ways
  13987. // that Draft doesn't expect (ex: adding <font> tags inside
  13988. // DraftEditorLeaf spans) and causes problems. We add notranslate
  13989. // here which makes its autotranslation skip over this subtree.
  13990. notranslate: !readOnly,
  13991. 'public/DraftEditor/content': true
  13992. }),
  13993. contentEditable: !readOnly,
  13994. 'data-testid': this.props.webDriverTestID,
  13995. onBeforeInput: this._onBeforeInput,
  13996. onBlur: this._onBlur,
  13997. onCompositionEnd: this._onCompositionEnd,
  13998. onCompositionStart: this._onCompositionStart,
  13999. onCopy: this._onCopy,
  14000. onCut: this._onCut,
  14001. onDragEnd: this._onDragEnd,
  14002. onDragEnter: this.onDragEnter,
  14003. onDragLeave: this.onDragLeave,
  14004. onDragOver: this._onDragOver,
  14005. onDragStart: this._onDragStart,
  14006. onDrop: this._onDrop,
  14007. onFocus: this._onFocus,
  14008. onInput: this._onInput,
  14009. onKeyDown: this._onKeyDown,
  14010. onKeyPress: this._onKeyPress,
  14011. onKeyUp: this._onKeyUp,
  14012. onMouseUp: this._onMouseUp,
  14013. onPaste: this._onPaste,
  14014. onSelect: this._onSelect,
  14015. ref: function ref(_ref2) {
  14016. return _this3.editor = _ref2;
  14017. },
  14018. role: readOnly ? null : ariaRole,
  14019. spellCheck: allowSpellCheck && this.props.spellCheck,
  14020. style: contentStyle,
  14021. suppressContentEditableWarning: true,
  14022. tabIndex: this.props.tabIndex },
  14023. React__default.createElement(DraftEditorContents_react, editorContentsProps)
  14024. )
  14025. )
  14026. );
  14027. };
  14028. DraftEditor.prototype.componentDidMount = function componentDidMount() {
  14029. this.setMode('edit');
  14030. /**
  14031. * IE has a hardcoded "feature" that attempts to convert link text into
  14032. * anchors in contentEditable DOM. This breaks the editor's expectations of
  14033. * the DOM, and control is lost. Disable it to make IE behave.
  14034. * See: http://blogs.msdn.com/b/ieinternals/archive/2010/09/15/
  14035. * ie9-beta-minor-change-list.aspx
  14036. */
  14037. if (isIE) {
  14038. document.execCommand('AutoUrlDetect', false, false);
  14039. }
  14040. };
  14041. /**
  14042. * Prevent selection events from affecting the current editor state. This
  14043. * is mostly intended to defend against IE, which fires off `selectionchange`
  14044. * events regardless of whether the selection is set via the browser or
  14045. * programmatically. We only care about selection events that occur because
  14046. * of browser interaction, not re-renders and forced selections.
  14047. */
  14048. DraftEditor.prototype.componentWillUpdate = function componentWillUpdate(nextProps) {
  14049. this._blockSelectEvents = true;
  14050. this._latestEditorState = nextProps.editorState;
  14051. };
  14052. DraftEditor.prototype.componentDidUpdate = function componentDidUpdate() {
  14053. this._blockSelectEvents = false;
  14054. this._latestCommittedEditorState = this.props.editorState;
  14055. };
  14056. /**
  14057. * Used via `this.focus()`.
  14058. *
  14059. * Force focus back onto the editor node.
  14060. *
  14061. * We attempt to preserve scroll position when focusing. You can also pass
  14062. * a specified scroll position (for cases like `cut` behavior where it should
  14063. * be restored to a known position).
  14064. */
  14065. /**
  14066. * Used via `this.setMode(...)`.
  14067. *
  14068. * Set the behavior mode for the editor component. This switches the current
  14069. * handler module to ensure that DOM events are managed appropriately for
  14070. * the active mode.
  14071. */
  14072. /**
  14073. * Used via `this.restoreEditorDOM()`.
  14074. *
  14075. * Force a complete re-render of the DraftEditorContents based on the current
  14076. * EditorState. This is useful when we know we are going to lose control of
  14077. * the DOM state (cut command, IME) and we want to make sure that
  14078. * reconciliation occurs on a version of the DOM that is synchronized with
  14079. * our EditorState.
  14080. */
  14081. /**
  14082. * Used via `this.setClipboard(...)`.
  14083. *
  14084. * Set the clipboard state for a cut/copy event.
  14085. */
  14086. /**
  14087. * Used via `this.getClipboard()`.
  14088. *
  14089. * Retrieve the clipboard state for a cut/copy event.
  14090. */
  14091. /**
  14092. * Used via `this.update(...)`.
  14093. *
  14094. * Propagate a new `EditorState` object to higher-level components. This is
  14095. * the method by which event handlers inform the `DraftEditor` component of
  14096. * state changes. A component that composes a `DraftEditor` **must** provide
  14097. * an `onChange` prop to receive state updates passed along from this
  14098. * function.
  14099. */
  14100. /**
  14101. * Used in conjunction with `onDragLeave()`, by counting the number of times
  14102. * a dragged element enters and leaves the editor (or any of its children),
  14103. * to determine when the dragged element absolutely leaves the editor.
  14104. */
  14105. /**
  14106. * See `onDragEnter()`.
  14107. */
  14108. return DraftEditor;
  14109. }(React__default.Component);
  14110. DraftEditor.defaultProps = {
  14111. blockRenderMap: DefaultDraftBlockRenderMap_1,
  14112. blockRendererFn: emptyFunction_1.thatReturnsNull,
  14113. blockStyleFn: emptyFunction_1.thatReturns(''),
  14114. keyBindingFn: getDefaultKeyBinding_1,
  14115. readOnly: false,
  14116. spellCheck: false,
  14117. stripPastedStyles: false
  14118. };
  14119. var DraftEditor_react = DraftEditor;
  14120. /**
  14121. * Copyright (c) 2013-present, Facebook, Inc.
  14122. * All rights reserved.
  14123. *
  14124. * This source code is licensed under the BSD-style license found in the
  14125. * LICENSE file in the root directory of this source tree. An additional grant
  14126. * of patent rights can be found in the PATENTS file in the same directory.
  14127. *
  14128. * @providesModule DraftStringKey
  14129. * @format
  14130. *
  14131. */
  14132. var DraftStringKey = {
  14133. stringify: function stringify(key) {
  14134. return '_' + String(key);
  14135. },
  14136. unstringify: function unstringify(key) {
  14137. return key.slice(1);
  14138. }
  14139. };
  14140. var DraftStringKey_1 = DraftStringKey;
  14141. var strlen$1 = UnicodeUtils_1.strlen;
  14142. /**
  14143. * Convert to UTF-8 character counts for storage.
  14144. */
  14145. function encodeEntityRanges(block, storageMap) {
  14146. var encoded = [];
  14147. block.findEntityRanges(function (character) {
  14148. return !!character.getEntity();
  14149. }, function ( /*number*/start, /*number*/end) {
  14150. var text = block.getText();
  14151. var key = block.getEntityAt(start);
  14152. encoded.push({
  14153. offset: strlen$1(text.slice(0, start)),
  14154. length: strlen$1(text.slice(start, end)),
  14155. // Encode the key as a number for range storage.
  14156. key: Number(storageMap[DraftStringKey_1.stringify(key)])
  14157. });
  14158. });
  14159. return encoded;
  14160. }
  14161. var encodeEntityRanges_1 = encodeEntityRanges;
  14162. var areEqual$1 = function areEqual(a, b) {
  14163. return a === b;
  14164. };
  14165. var isTruthy = function isTruthy(a) {
  14166. return !!a;
  14167. };
  14168. var EMPTY_ARRAY = [];
  14169. /**
  14170. * Helper function for getting encoded styles for each inline style. Convert
  14171. * to UTF-8 character counts for storage.
  14172. */
  14173. function getEncodedInlinesForType(block, styleList, styleToEncode) {
  14174. var ranges = [];
  14175. // Obtain an array with ranges for only the specified style.
  14176. var filteredInlines = styleList.map(function (style) {
  14177. return style.has(styleToEncode);
  14178. }).toList();
  14179. findRangesImmutable_1(filteredInlines, areEqual$1,
  14180. // We only want to keep ranges with nonzero style values.
  14181. isTruthy, function (start, end) {
  14182. var text = block.getText();
  14183. ranges.push({
  14184. offset: UnicodeUtils_1.strlen(text.slice(0, start)),
  14185. length: UnicodeUtils_1.strlen(text.slice(start, end)),
  14186. style: styleToEncode
  14187. });
  14188. });
  14189. return ranges;
  14190. }
  14191. /*
  14192. * Retrieve the encoded arrays of inline styles, with each individual style
  14193. * treated separately.
  14194. */
  14195. function encodeInlineStyleRanges(block) {
  14196. var styleList = block.getCharacterList().map(function (c) {
  14197. return c.getStyle();
  14198. }).toList();
  14199. var ranges = styleList.flatten().toSet().map(function (style) {
  14200. return getEncodedInlinesForType(block, styleList, style);
  14201. });
  14202. return Array.prototype.concat.apply(EMPTY_ARRAY, ranges.toJS());
  14203. }
  14204. var encodeInlineStyleRanges_1 = encodeInlineStyleRanges;
  14205. var _extends$6 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  14206. var createRawBlock = function createRawBlock(block, entityStorageMap) {
  14207. return {
  14208. key: block.getKey(),
  14209. text: block.getText(),
  14210. type: block.getType(),
  14211. depth: block.getDepth(),
  14212. inlineStyleRanges: encodeInlineStyleRanges_1(block),
  14213. entityRanges: encodeEntityRanges_1(block, entityStorageMap),
  14214. data: block.getData().toObject()
  14215. };
  14216. };
  14217. var insertRawBlock = function insertRawBlock(block, entityMap, rawBlocks, blockCacheRef) {
  14218. if (block instanceof ContentBlock_1) {
  14219. rawBlocks.push(createRawBlock(block, entityMap));
  14220. return;
  14221. }
  14222. !(block instanceof ContentBlockNode_1) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'block is not a BlockNode') : invariant_1(false) : void 0;
  14223. var parentKey = block.getParentKey();
  14224. var rawBlock = blockCacheRef[block.getKey()] = _extends$6({}, createRawBlock(block, entityMap), {
  14225. children: []
  14226. });
  14227. if (parentKey) {
  14228. blockCacheRef[parentKey].children.push(rawBlock);
  14229. return;
  14230. }
  14231. rawBlocks.push(rawBlock);
  14232. };
  14233. var encodeRawBlocks = function encodeRawBlocks(contentState, rawState) {
  14234. var entityMap = rawState.entityMap;
  14235. var rawBlocks = [];
  14236. var blockCacheRef = {};
  14237. var entityCacheRef = {};
  14238. var entityStorageKey = 0;
  14239. contentState.getBlockMap().forEach(function (block) {
  14240. block.findEntityRanges(function (character) {
  14241. return character.getEntity() !== null;
  14242. }, function (start) {
  14243. var entityKey = block.getEntityAt(start);
  14244. // Stringify to maintain order of otherwise numeric keys.
  14245. var stringifiedEntityKey = DraftStringKey_1.stringify(entityKey);
  14246. // This makes this function resilient to two entities
  14247. // erroneously having the same key
  14248. if (entityCacheRef[stringifiedEntityKey]) {
  14249. return;
  14250. }
  14251. entityCacheRef[stringifiedEntityKey] = entityKey;
  14252. // we need the `any` casting here since this is a temporary state
  14253. // where we will later on flip the entity map and populate it with
  14254. // real entity, at this stage we just need to map back the entity
  14255. // key used by the BlockNode
  14256. entityMap[stringifiedEntityKey] = '' + entityStorageKey;
  14257. entityStorageKey++;
  14258. });
  14259. insertRawBlock(block, entityMap, rawBlocks, blockCacheRef);
  14260. });
  14261. return {
  14262. blocks: rawBlocks,
  14263. entityMap: entityMap
  14264. };
  14265. };
  14266. // Flip storage map so that our storage keys map to global
  14267. // DraftEntity keys.
  14268. var encodeRawEntityMap = function encodeRawEntityMap(contentState, rawState) {
  14269. var blocks = rawState.blocks,
  14270. entityMap = rawState.entityMap;
  14271. var rawEntityMap = {};
  14272. Object.keys(entityMap).forEach(function (key, index) {
  14273. var entity = contentState.getEntity(DraftStringKey_1.unstringify(key));
  14274. rawEntityMap[index] = {
  14275. type: entity.getType(),
  14276. mutability: entity.getMutability(),
  14277. data: entity.getData()
  14278. };
  14279. });
  14280. return {
  14281. blocks: blocks,
  14282. entityMap: rawEntityMap
  14283. };
  14284. };
  14285. var convertFromDraftStateToRaw = function convertFromDraftStateToRaw(contentState) {
  14286. var rawDraftContentState = {
  14287. entityMap: {},
  14288. blocks: []
  14289. };
  14290. // add blocks
  14291. rawDraftContentState = encodeRawBlocks(contentState, rawDraftContentState);
  14292. // add entities
  14293. rawDraftContentState = encodeRawEntityMap(contentState, rawDraftContentState);
  14294. return rawDraftContentState;
  14295. };
  14296. var convertFromDraftStateToRaw_1 = convertFromDraftStateToRaw;
  14297. var _extends$7 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  14298. /**
  14299. * Copyright (c) 2013-present, Facebook, Inc.
  14300. * All rights reserved.
  14301. *
  14302. * This source code is licensed under the BSD-style license found in the
  14303. * LICENSE file in the root directory of this source tree. An additional grant
  14304. * of patent rights can be found in the PATENTS file in the same directory.
  14305. *
  14306. * @providesModule DraftTreeAdapter
  14307. * @format
  14308. *
  14309. *
  14310. * This is unstable and not part of the public API and should not be used by
  14311. * production systems. This file may be update/removed without notice.
  14312. */
  14313. var traverseInDepthOrder = function traverseInDepthOrder(blocks, fn) {
  14314. var stack = [].concat(blocks).reverse();
  14315. while (stack.length) {
  14316. var _block = stack.pop();
  14317. fn(_block);
  14318. var children = _block.children;
  14319. !Array.isArray(children) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Invalid tree raw block') : invariant_1(false) : void 0;
  14320. stack = stack.concat([].concat(children.reverse()));
  14321. }
  14322. };
  14323. var isListBlock = function isListBlock(block) {
  14324. if (!(block && block.type)) {
  14325. return false;
  14326. }
  14327. var type = block.type;
  14328. return type === 'unordered-list-item' || type === 'ordered-list-item';
  14329. };
  14330. var addDepthToChildren = function addDepthToChildren(block) {
  14331. if (Array.isArray(block.children)) {
  14332. block.children = block.children.map(function (child) {
  14333. return child.type === block.type ? _extends$7({}, child, { depth: (block.depth || 0) + 1 }) : child;
  14334. });
  14335. }
  14336. };
  14337. /**
  14338. * This adapter is intended to be be used as an adapter to draft tree data
  14339. *
  14340. * draft state <=====> draft tree state
  14341. */
  14342. var DraftTreeAdapter = {
  14343. /**
  14344. * Converts from a tree raw state back to draft raw state
  14345. */
  14346. fromRawTreeStateToRawState: function fromRawTreeStateToRawState(draftTreeState) {
  14347. var blocks = draftTreeState.blocks;
  14348. var transformedBlocks = [];
  14349. !Array.isArray(blocks) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Invalid raw state') : invariant_1(false) : void 0;
  14350. if (!Array.isArray(blocks) || !blocks.length) {
  14351. return draftTreeState;
  14352. }
  14353. traverseInDepthOrder(blocks, function (block) {
  14354. var newBlock = _extends$7({}, block);
  14355. if (isListBlock(block)) {
  14356. newBlock.depth = newBlock.depth || 0;
  14357. addDepthToChildren(block);
  14358. }
  14359. delete newBlock.children;
  14360. transformedBlocks.push(newBlock);
  14361. });
  14362. draftTreeState.blocks = transformedBlocks;
  14363. return _extends$7({}, draftTreeState, {
  14364. blocks: transformedBlocks
  14365. });
  14366. },
  14367. /**
  14368. * Converts from draft raw state to tree draft state
  14369. */
  14370. fromRawStateToRawTreeState: function fromRawStateToRawTreeState(draftState) {
  14371. var lastListDepthCacheRef = {};
  14372. var transformedBlocks = [];
  14373. draftState.blocks.forEach(function (block) {
  14374. var isList = isListBlock(block);
  14375. var depth = block.depth || 0;
  14376. var treeBlock = _extends$7({}, block, {
  14377. children: []
  14378. });
  14379. if (!isList) {
  14380. // reset the cache path
  14381. lastListDepthCacheRef = {};
  14382. transformedBlocks.push(treeBlock);
  14383. return;
  14384. }
  14385. // update our depth cache reference path
  14386. lastListDepthCacheRef[depth] = treeBlock;
  14387. // if we are greater than zero we must have seen a parent already
  14388. if (depth > 0) {
  14389. var parent = lastListDepthCacheRef[depth - 1];
  14390. !parent ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'Invalid depth for RawDraftContentBlock') : invariant_1(false) : void 0;
  14391. // push nested list blocks
  14392. parent.children.push(treeBlock);
  14393. return;
  14394. }
  14395. // push root list blocks
  14396. transformedBlocks.push(treeBlock);
  14397. });
  14398. return _extends$7({}, draftState, {
  14399. blocks: transformedBlocks
  14400. });
  14401. }
  14402. };
  14403. var DraftTreeAdapter_1 = DraftTreeAdapter;
  14404. var List$c = immutable.List;
  14405. function createCharacterList(inlineStyles, entities) {
  14406. var characterArray = inlineStyles.map(function (style, ii) {
  14407. var entity = entities[ii];
  14408. return CharacterMetadata_1.create({ style: style, entity: entity });
  14409. });
  14410. return List$c(characterArray);
  14411. }
  14412. var createCharacterList_1 = createCharacterList;
  14413. var substr$1 = UnicodeUtils_1.substr;
  14414. /**
  14415. * Convert to native JavaScript string lengths to determine ranges.
  14416. */
  14417. function decodeEntityRanges(text, ranges) {
  14418. var entities = Array(text.length).fill(null);
  14419. if (ranges) {
  14420. ranges.forEach(function (range) {
  14421. // Using Unicode-enabled substrings converted to JavaScript lengths,
  14422. // fill the output array with entity keys.
  14423. var start = substr$1(text, 0, range.offset).length;
  14424. var end = start + substr$1(text, range.offset, range.length).length;
  14425. for (var ii = start; ii < end; ii++) {
  14426. entities[ii] = range.key;
  14427. }
  14428. });
  14429. }
  14430. return entities;
  14431. }
  14432. var decodeEntityRanges_1 = decodeEntityRanges;
  14433. var OrderedSet$6 = immutable.OrderedSet;
  14434. var substr$2 = UnicodeUtils_1.substr;
  14435. var EMPTY_SET$3 = OrderedSet$6();
  14436. /**
  14437. * Convert to native JavaScript string lengths to determine ranges.
  14438. */
  14439. function decodeInlineStyleRanges(text, ranges) {
  14440. var styles = Array(text.length).fill(EMPTY_SET$3);
  14441. if (ranges) {
  14442. ranges.forEach(function ( /*object*/range) {
  14443. var cursor = substr$2(text, 0, range.offset).length;
  14444. var end = cursor + substr$2(text, range.offset, range.length).length;
  14445. while (cursor < end) {
  14446. styles[cursor] = styles[cursor].add(range.style);
  14447. cursor++;
  14448. }
  14449. });
  14450. }
  14451. return styles;
  14452. }
  14453. var decodeInlineStyleRanges_1 = decodeInlineStyleRanges;
  14454. var _extends$8 = objectAssign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  14455. var List$d = immutable.List,
  14456. Map$9 = immutable.Map,
  14457. OrderedMap$4 = immutable.OrderedMap;
  14458. var decodeBlockNodeConfig = function decodeBlockNodeConfig(block, entityMap) {
  14459. var key = block.key,
  14460. type = block.type,
  14461. data = block.data,
  14462. text = block.text,
  14463. depth = block.depth;
  14464. var blockNodeConfig = {
  14465. text: text,
  14466. depth: depth || 0,
  14467. type: type || 'unstyled',
  14468. key: key || generateRandomKey_1(),
  14469. data: Map$9(data),
  14470. characterList: decodeCharacterList(block, entityMap)
  14471. };
  14472. return blockNodeConfig;
  14473. };
  14474. var decodeCharacterList = function decodeCharacterList(block, entityMap) {
  14475. var text = block.text,
  14476. rawEntityRanges = block.entityRanges,
  14477. rawInlineStyleRanges = block.inlineStyleRanges;
  14478. var entityRanges = rawEntityRanges || [];
  14479. var inlineStyleRanges = rawInlineStyleRanges || [];
  14480. // Translate entity range keys to the DraftEntity map.
  14481. return createCharacterList_1(decodeInlineStyleRanges_1(text, inlineStyleRanges), decodeEntityRanges_1(text, entityRanges.filter(function (range) {
  14482. return entityMap.hasOwnProperty(range.key);
  14483. }).map(function (range) {
  14484. return _extends$8({}, range, { key: entityMap[range.key] });
  14485. })));
  14486. };
  14487. var decodeContentBlocks = function decodeContentBlocks(blocks, entityMap) {
  14488. return OrderedMap$4(blocks.map(function (block) {
  14489. var contentBlock = new ContentBlock_1(decodeBlockNodeConfig(block, entityMap));
  14490. return [contentBlock.getKey(), contentBlock];
  14491. }));
  14492. };
  14493. var decodeRawBlocks = function decodeRawBlocks(rawState, entityMap) {
  14494. var isTreeRawBlock = Array.isArray(rawState.blocks[0].children);
  14495. var rawBlocks = rawState.blocks;
  14496. {
  14497. return decodeContentBlocks(isTreeRawBlock ? DraftTreeAdapter_1.fromRawTreeStateToRawState(rawState).blocks : rawBlocks, entityMap);
  14498. }
  14499. };
  14500. var decodeRawEntityMap = function decodeRawEntityMap(rawState) {
  14501. var rawEntityMap = rawState.entityMap;
  14502. var entityMap = {};
  14503. // TODO: Update this once we completely remove DraftEntity
  14504. Object.keys(rawEntityMap).forEach(function (rawEntityKey) {
  14505. var _rawEntityMap$rawEnti = rawEntityMap[rawEntityKey],
  14506. type = _rawEntityMap$rawEnti.type,
  14507. mutability = _rawEntityMap$rawEnti.mutability,
  14508. data = _rawEntityMap$rawEnti.data;
  14509. // get the key reference to created entity
  14510. entityMap[rawEntityKey] = DraftEntity_1.__create(type, mutability, data || {});
  14511. });
  14512. return entityMap;
  14513. };
  14514. var convertFromRawToDraftState = function convertFromRawToDraftState(rawState) {
  14515. !Array.isArray(rawState.blocks) ? process.env.NODE_ENV !== 'production' ? invariant_1(false, 'invalid RawDraftContentState') : invariant_1(false) : void 0;
  14516. // decode entities
  14517. var entityMap = decodeRawEntityMap(rawState);
  14518. // decode blockMap
  14519. var blockMap = decodeRawBlocks(rawState, entityMap);
  14520. // create initial selection
  14521. var selectionState = blockMap.isEmpty() ? new SelectionState_1() : SelectionState_1.createEmpty(blockMap.first().getKey());
  14522. return new ContentState_1({
  14523. blockMap: blockMap,
  14524. entityMap: entityMap,
  14525. selectionBefore: selectionState,
  14526. selectionAfter: selectionState
  14527. });
  14528. };
  14529. var convertFromRawToDraftState_1 = convertFromRawToDraftState;
  14530. /**
  14531. * Like range.getBoundingClientRect() but normalizes for browser bugs.
  14532. */
  14533. function getRangeBoundingClientRect(range) {
  14534. // "Return a DOMRect object describing the smallest rectangle that includes
  14535. // the first rectangle in list and all of the remaining rectangles of which
  14536. // the height or width is not zero."
  14537. // http://www.w3.org/TR/cssom-view/#dom-range-getboundingclientrect
  14538. var rects = getRangeClientRects_1(range);
  14539. var top = 0;
  14540. var right = 0;
  14541. var bottom = 0;
  14542. var left = 0;
  14543. if (rects.length) {
  14544. // If the first rectangle has 0 width, we use the second, this is needed
  14545. // because Chrome renders a 0 width rectangle when the selection contains
  14546. // a line break.
  14547. if (rects.length > 1 && rects[0].width === 0) {
  14548. var _rects$ = rects[1];
  14549. top = _rects$.top;
  14550. right = _rects$.right;
  14551. bottom = _rects$.bottom;
  14552. left = _rects$.left;
  14553. } else {
  14554. var _rects$2 = rects[0];
  14555. top = _rects$2.top;
  14556. right = _rects$2.right;
  14557. bottom = _rects$2.bottom;
  14558. left = _rects$2.left;
  14559. }
  14560. for (var ii = 1; ii < rects.length; ii++) {
  14561. var rect = rects[ii];
  14562. if (rect.height !== 0 && rect.width !== 0) {
  14563. top = Math.min(top, rect.top);
  14564. right = Math.max(right, rect.right);
  14565. bottom = Math.max(bottom, rect.bottom);
  14566. left = Math.min(left, rect.left);
  14567. }
  14568. }
  14569. }
  14570. return {
  14571. top: top,
  14572. right: right,
  14573. bottom: bottom,
  14574. left: left,
  14575. width: right - left,
  14576. height: bottom - top
  14577. };
  14578. }
  14579. var getRangeBoundingClientRect_1 = getRangeBoundingClientRect;
  14580. /**
  14581. * Return the bounding ClientRect for the visible DOM selection, if any.
  14582. * In cases where there are no selected ranges or the bounding rect is
  14583. * temporarily invalid, return null.
  14584. */
  14585. function getVisibleSelectionRect(global) {
  14586. var selection = global.getSelection();
  14587. if (!selection.rangeCount) {
  14588. return null;
  14589. }
  14590. var range = selection.getRangeAt(0);
  14591. var boundingRect = getRangeBoundingClientRect_1(range);
  14592. var top = boundingRect.top,
  14593. right = boundingRect.right,
  14594. bottom = boundingRect.bottom,
  14595. left = boundingRect.left;
  14596. // When a re-render leads to a node being removed, the DOM selection will
  14597. // temporarily be placed on an ancestor node, which leads to an invalid
  14598. // bounding rect. Discard this state.
  14599. if (top === 0 && right === 0 && bottom === 0 && left === 0) {
  14600. return null;
  14601. }
  14602. return boundingRect;
  14603. }
  14604. var getVisibleSelectionRect_1 = getVisibleSelectionRect;
  14605. var DraftPublic = {
  14606. Editor: DraftEditor_react,
  14607. EditorBlock: DraftEditorBlock_react,
  14608. EditorState: EditorState_1,
  14609. CompositeDecorator: CompositeDraftDecorator_1,
  14610. Entity: DraftEntity_1,
  14611. EntityInstance: DraftEntityInstance_1,
  14612. BlockMapBuilder: BlockMapBuilder_1,
  14613. CharacterMetadata: CharacterMetadata_1,
  14614. ContentBlock: ContentBlock_1,
  14615. ContentState: ContentState_1,
  14616. SelectionState: SelectionState_1,
  14617. AtomicBlockUtils: AtomicBlockUtils_1,
  14618. KeyBindingUtil: KeyBindingUtil_1,
  14619. Modifier: DraftModifier_1,
  14620. RichUtils: RichTextEditorUtil_1,
  14621. DefaultDraftBlockRenderMap: DefaultDraftBlockRenderMap_1,
  14622. DefaultDraftInlineStyle: DefaultDraftInlineStyle,
  14623. convertFromHTML: convertFromHTMLToContentBlocks,
  14624. convertFromRaw: convertFromRawToDraftState_1,
  14625. convertToRaw: convertFromDraftStateToRaw_1,
  14626. genKey: generateRandomKey_1,
  14627. getDefaultKeyBinding: getDefaultKeyBinding_1,
  14628. getVisibleSelectionRect: getVisibleSelectionRect_1
  14629. };
  14630. var Draft = DraftPublic;
  14631. var immutable$1 = index.createCommonjsModule(function (module, exports) {
  14632. /**
  14633. * Copyright (c) 2014-present, Facebook, Inc.
  14634. *
  14635. * This source code is licensed under the MIT license found in the
  14636. * LICENSE file in the root directory of this source tree.
  14637. */
  14638. (function (global, factory) {
  14639. factory(exports) ;
  14640. }(index.commonjsGlobal, (function (exports) {
  14641. // Used for setting prototype methods that IE8 chokes on.
  14642. var DELETE = 'delete';
  14643. // Constants describing the size of trie nodes.
  14644. var SHIFT = 5; // Resulted in best performance after ______?
  14645. var SIZE = 1 << SHIFT;
  14646. var MASK = SIZE - 1;
  14647. // A consistent shared value representing "not set" which equals nothing other
  14648. // than itself, and nothing that could be provided externally.
  14649. var NOT_SET = {};
  14650. // Boolean references, Rough equivalent of `bool &`.
  14651. function MakeRef() {
  14652. return { value: false };
  14653. }
  14654. function SetRef(ref) {
  14655. if (ref) {
  14656. ref.value = true;
  14657. }
  14658. }
  14659. // A function which returns a value representing an "owner" for transient writes
  14660. // to tries. The return value will only ever equal itself, and will not equal
  14661. // the return of any subsequent call of this function.
  14662. function OwnerID() {}
  14663. function ensureSize(iter) {
  14664. if (iter.size === undefined) {
  14665. iter.size = iter.__iterate(returnTrue);
  14666. }
  14667. return iter.size;
  14668. }
  14669. function wrapIndex(iter, index) {
  14670. // This implements "is array index" which the ECMAString spec defines as:
  14671. //
  14672. // A String property name P is an array index if and only if
  14673. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  14674. // to 2^32−1.
  14675. //
  14676. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  14677. if (typeof index !== 'number') {
  14678. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  14679. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  14680. return NaN;
  14681. }
  14682. index = uint32Index;
  14683. }
  14684. return index < 0 ? ensureSize(iter) + index : index;
  14685. }
  14686. function returnTrue() {
  14687. return true;
  14688. }
  14689. function wholeSlice(begin, end, size) {
  14690. return (
  14691. ((begin === 0 && !isNeg(begin)) ||
  14692. (size !== undefined && begin <= -size)) &&
  14693. (end === undefined || (size !== undefined && end >= size))
  14694. );
  14695. }
  14696. function resolveBegin(begin, size) {
  14697. return resolveIndex(begin, size, 0);
  14698. }
  14699. function resolveEnd(end, size) {
  14700. return resolveIndex(end, size, size);
  14701. }
  14702. function resolveIndex(index, size, defaultIndex) {
  14703. // Sanitize indices using this shorthand for ToInt32(argument)
  14704. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  14705. return index === undefined
  14706. ? defaultIndex
  14707. : isNeg(index)
  14708. ? size === Infinity
  14709. ? size
  14710. : Math.max(0, size + index) | 0
  14711. : size === undefined || size === index
  14712. ? index
  14713. : Math.min(size, index) | 0;
  14714. }
  14715. function isNeg(value) {
  14716. // Account for -0 which is negative, but not less than 0.
  14717. return value < 0 || (value === 0 && 1 / value === -Infinity);
  14718. }
  14719. // Note: value is unchanged to not break immutable-devtools.
  14720. var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
  14721. function isCollection(maybeCollection) {
  14722. return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]);
  14723. }
  14724. var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';
  14725. function isKeyed(maybeKeyed) {
  14726. return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]);
  14727. }
  14728. var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';
  14729. function isIndexed(maybeIndexed) {
  14730. return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]);
  14731. }
  14732. function isAssociative(maybeAssociative) {
  14733. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  14734. }
  14735. var Collection = function Collection(value) {
  14736. return isCollection(value) ? value : Seq(value);
  14737. };
  14738. var KeyedCollection = /*@__PURE__*/(function (Collection) {
  14739. function KeyedCollection(value) {
  14740. return isKeyed(value) ? value : KeyedSeq(value);
  14741. }
  14742. if ( Collection ) KeyedCollection.__proto__ = Collection;
  14743. KeyedCollection.prototype = Object.create( Collection && Collection.prototype );
  14744. KeyedCollection.prototype.constructor = KeyedCollection;
  14745. return KeyedCollection;
  14746. }(Collection));
  14747. var IndexedCollection = /*@__PURE__*/(function (Collection) {
  14748. function IndexedCollection(value) {
  14749. return isIndexed(value) ? value : IndexedSeq(value);
  14750. }
  14751. if ( Collection ) IndexedCollection.__proto__ = Collection;
  14752. IndexedCollection.prototype = Object.create( Collection && Collection.prototype );
  14753. IndexedCollection.prototype.constructor = IndexedCollection;
  14754. return IndexedCollection;
  14755. }(Collection));
  14756. var SetCollection = /*@__PURE__*/(function (Collection) {
  14757. function SetCollection(value) {
  14758. return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);
  14759. }
  14760. if ( Collection ) SetCollection.__proto__ = Collection;
  14761. SetCollection.prototype = Object.create( Collection && Collection.prototype );
  14762. SetCollection.prototype.constructor = SetCollection;
  14763. return SetCollection;
  14764. }(Collection));
  14765. Collection.Keyed = KeyedCollection;
  14766. Collection.Indexed = IndexedCollection;
  14767. Collection.Set = SetCollection;
  14768. var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';
  14769. function isSeq(maybeSeq) {
  14770. return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]);
  14771. }
  14772. var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
  14773. function isRecord(maybeRecord) {
  14774. return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]);
  14775. }
  14776. function isImmutable(maybeImmutable) {
  14777. return isCollection(maybeImmutable) || isRecord(maybeImmutable);
  14778. }
  14779. var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';
  14780. function isOrdered(maybeOrdered) {
  14781. return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]);
  14782. }
  14783. var ITERATE_KEYS = 0;
  14784. var ITERATE_VALUES = 1;
  14785. var ITERATE_ENTRIES = 2;
  14786. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  14787. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  14788. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  14789. var Iterator = function Iterator(next) {
  14790. this.next = next;
  14791. };
  14792. Iterator.prototype.toString = function toString () {
  14793. return '[Iterator]';
  14794. };
  14795. Iterator.KEYS = ITERATE_KEYS;
  14796. Iterator.VALUES = ITERATE_VALUES;
  14797. Iterator.ENTRIES = ITERATE_ENTRIES;
  14798. Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
  14799. return this.toString();
  14800. };
  14801. Iterator.prototype[ITERATOR_SYMBOL] = function() {
  14802. return this;
  14803. };
  14804. function iteratorValue(type, k, v, iteratorResult) {
  14805. var value = type === 0 ? k : type === 1 ? v : [k, v];
  14806. iteratorResult
  14807. ? (iteratorResult.value = value)
  14808. : (iteratorResult = {
  14809. value: value,
  14810. done: false,
  14811. });
  14812. return iteratorResult;
  14813. }
  14814. function iteratorDone() {
  14815. return { value: undefined, done: true };
  14816. }
  14817. function hasIterator(maybeIterable) {
  14818. return !!getIteratorFn(maybeIterable);
  14819. }
  14820. function isIterator(maybeIterator) {
  14821. return maybeIterator && typeof maybeIterator.next === 'function';
  14822. }
  14823. function getIterator(iterable) {
  14824. var iteratorFn = getIteratorFn(iterable);
  14825. return iteratorFn && iteratorFn.call(iterable);
  14826. }
  14827. function getIteratorFn(iterable) {
  14828. var iteratorFn =
  14829. iterable &&
  14830. ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  14831. iterable[FAUX_ITERATOR_SYMBOL]);
  14832. if (typeof iteratorFn === 'function') {
  14833. return iteratorFn;
  14834. }
  14835. }
  14836. var hasOwnProperty = Object.prototype.hasOwnProperty;
  14837. function isArrayLike(value) {
  14838. if (Array.isArray(value) || typeof value === 'string') {
  14839. return true;
  14840. }
  14841. return (
  14842. value &&
  14843. typeof value === 'object' &&
  14844. Number.isInteger(value.length) &&
  14845. value.length >= 0 &&
  14846. (value.length === 0
  14847. ? // Only {length: 0} is considered Array-like.
  14848. Object.keys(value).length === 1
  14849. : // An object is only Array-like if it has a property where the last value
  14850. // in the array-like may be found (which could be undefined).
  14851. value.hasOwnProperty(value.length - 1))
  14852. );
  14853. }
  14854. var Seq = /*@__PURE__*/(function (Collection$$1) {
  14855. function Seq(value) {
  14856. return value === null || value === undefined
  14857. ? emptySequence()
  14858. : isImmutable(value)
  14859. ? value.toSeq()
  14860. : seqFromValue(value);
  14861. }
  14862. if ( Collection$$1 ) Seq.__proto__ = Collection$$1;
  14863. Seq.prototype = Object.create( Collection$$1 && Collection$$1.prototype );
  14864. Seq.prototype.constructor = Seq;
  14865. Seq.prototype.toSeq = function toSeq () {
  14866. return this;
  14867. };
  14868. Seq.prototype.toString = function toString () {
  14869. return this.__toString('Seq {', '}');
  14870. };
  14871. Seq.prototype.cacheResult = function cacheResult () {
  14872. if (!this._cache && this.__iterateUncached) {
  14873. this._cache = this.entrySeq().toArray();
  14874. this.size = this._cache.length;
  14875. }
  14876. return this;
  14877. };
  14878. // abstract __iterateUncached(fn, reverse)
  14879. Seq.prototype.__iterate = function __iterate (fn, reverse) {
  14880. var cache = this._cache;
  14881. if (cache) {
  14882. var size = cache.length;
  14883. var i = 0;
  14884. while (i !== size) {
  14885. var entry = cache[reverse ? size - ++i : i++];
  14886. if (fn(entry[1], entry[0], this) === false) {
  14887. break;
  14888. }
  14889. }
  14890. return i;
  14891. }
  14892. return this.__iterateUncached(fn, reverse);
  14893. };
  14894. // abstract __iteratorUncached(type, reverse)
  14895. Seq.prototype.__iterator = function __iterator (type, reverse) {
  14896. var cache = this._cache;
  14897. if (cache) {
  14898. var size = cache.length;
  14899. var i = 0;
  14900. return new Iterator(function () {
  14901. if (i === size) {
  14902. return iteratorDone();
  14903. }
  14904. var entry = cache[reverse ? size - ++i : i++];
  14905. return iteratorValue(type, entry[0], entry[1]);
  14906. });
  14907. }
  14908. return this.__iteratorUncached(type, reverse);
  14909. };
  14910. return Seq;
  14911. }(Collection));
  14912. var KeyedSeq = /*@__PURE__*/(function (Seq) {
  14913. function KeyedSeq(value) {
  14914. return value === null || value === undefined
  14915. ? emptySequence().toKeyedSeq()
  14916. : isCollection(value)
  14917. ? isKeyed(value)
  14918. ? value.toSeq()
  14919. : value.fromEntrySeq()
  14920. : isRecord(value)
  14921. ? value.toSeq()
  14922. : keyedSeqFromValue(value);
  14923. }
  14924. if ( Seq ) KeyedSeq.__proto__ = Seq;
  14925. KeyedSeq.prototype = Object.create( Seq && Seq.prototype );
  14926. KeyedSeq.prototype.constructor = KeyedSeq;
  14927. KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () {
  14928. return this;
  14929. };
  14930. return KeyedSeq;
  14931. }(Seq));
  14932. var IndexedSeq = /*@__PURE__*/(function (Seq) {
  14933. function IndexedSeq(value) {
  14934. return value === null || value === undefined
  14935. ? emptySequence()
  14936. : isCollection(value)
  14937. ? isKeyed(value)
  14938. ? value.entrySeq()
  14939. : value.toIndexedSeq()
  14940. : isRecord(value)
  14941. ? value.toSeq().entrySeq()
  14942. : indexedSeqFromValue(value);
  14943. }
  14944. if ( Seq ) IndexedSeq.__proto__ = Seq;
  14945. IndexedSeq.prototype = Object.create( Seq && Seq.prototype );
  14946. IndexedSeq.prototype.constructor = IndexedSeq;
  14947. IndexedSeq.of = function of (/*...values*/) {
  14948. return IndexedSeq(arguments);
  14949. };
  14950. IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () {
  14951. return this;
  14952. };
  14953. IndexedSeq.prototype.toString = function toString () {
  14954. return this.__toString('Seq [', ']');
  14955. };
  14956. return IndexedSeq;
  14957. }(Seq));
  14958. var SetSeq = /*@__PURE__*/(function (Seq) {
  14959. function SetSeq(value) {
  14960. return (isCollection(value) && !isAssociative(value)
  14961. ? value
  14962. : IndexedSeq(value)
  14963. ).toSetSeq();
  14964. }
  14965. if ( Seq ) SetSeq.__proto__ = Seq;
  14966. SetSeq.prototype = Object.create( Seq && Seq.prototype );
  14967. SetSeq.prototype.constructor = SetSeq;
  14968. SetSeq.of = function of (/*...values*/) {
  14969. return SetSeq(arguments);
  14970. };
  14971. SetSeq.prototype.toSetSeq = function toSetSeq () {
  14972. return this;
  14973. };
  14974. return SetSeq;
  14975. }(Seq));
  14976. Seq.isSeq = isSeq;
  14977. Seq.Keyed = KeyedSeq;
  14978. Seq.Set = SetSeq;
  14979. Seq.Indexed = IndexedSeq;
  14980. Seq.prototype[IS_SEQ_SYMBOL] = true;
  14981. // #pragma Root Sequences
  14982. var ArraySeq = /*@__PURE__*/(function (IndexedSeq) {
  14983. function ArraySeq(array) {
  14984. this._array = array;
  14985. this.size = array.length;
  14986. }
  14987. if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq;
  14988. ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  14989. ArraySeq.prototype.constructor = ArraySeq;
  14990. ArraySeq.prototype.get = function get (index, notSetValue) {
  14991. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  14992. };
  14993. ArraySeq.prototype.__iterate = function __iterate (fn, reverse) {
  14994. var array = this._array;
  14995. var size = array.length;
  14996. var i = 0;
  14997. while (i !== size) {
  14998. var ii = reverse ? size - ++i : i++;
  14999. if (fn(array[ii], ii, this) === false) {
  15000. break;
  15001. }
  15002. }
  15003. return i;
  15004. };
  15005. ArraySeq.prototype.__iterator = function __iterator (type, reverse) {
  15006. var array = this._array;
  15007. var size = array.length;
  15008. var i = 0;
  15009. return new Iterator(function () {
  15010. if (i === size) {
  15011. return iteratorDone();
  15012. }
  15013. var ii = reverse ? size - ++i : i++;
  15014. return iteratorValue(type, ii, array[ii]);
  15015. });
  15016. };
  15017. return ArraySeq;
  15018. }(IndexedSeq));
  15019. var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) {
  15020. function ObjectSeq(object) {
  15021. var keys = Object.keys(object);
  15022. this._object = object;
  15023. this._keys = keys;
  15024. this.size = keys.length;
  15025. }
  15026. if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq;
  15027. ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
  15028. ObjectSeq.prototype.constructor = ObjectSeq;
  15029. ObjectSeq.prototype.get = function get (key, notSetValue) {
  15030. if (notSetValue !== undefined && !this.has(key)) {
  15031. return notSetValue;
  15032. }
  15033. return this._object[key];
  15034. };
  15035. ObjectSeq.prototype.has = function has (key) {
  15036. return hasOwnProperty.call(this._object, key);
  15037. };
  15038. ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {
  15039. var object = this._object;
  15040. var keys = this._keys;
  15041. var size = keys.length;
  15042. var i = 0;
  15043. while (i !== size) {
  15044. var key = keys[reverse ? size - ++i : i++];
  15045. if (fn(object[key], key, this) === false) {
  15046. break;
  15047. }
  15048. }
  15049. return i;
  15050. };
  15051. ObjectSeq.prototype.__iterator = function __iterator (type, reverse) {
  15052. var object = this._object;
  15053. var keys = this._keys;
  15054. var size = keys.length;
  15055. var i = 0;
  15056. return new Iterator(function () {
  15057. if (i === size) {
  15058. return iteratorDone();
  15059. }
  15060. var key = keys[reverse ? size - ++i : i++];
  15061. return iteratorValue(type, key, object[key]);
  15062. });
  15063. };
  15064. return ObjectSeq;
  15065. }(KeyedSeq));
  15066. ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;
  15067. var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) {
  15068. function CollectionSeq(collection) {
  15069. this._collection = collection;
  15070. this.size = collection.length || collection.size;
  15071. }
  15072. if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq;
  15073. CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  15074. CollectionSeq.prototype.constructor = CollectionSeq;
  15075. CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {
  15076. if (reverse) {
  15077. return this.cacheResult().__iterate(fn, reverse);
  15078. }
  15079. var collection = this._collection;
  15080. var iterator = getIterator(collection);
  15081. var iterations = 0;
  15082. if (isIterator(iterator)) {
  15083. var step;
  15084. while (!(step = iterator.next()).done) {
  15085. if (fn(step.value, iterations++, this) === false) {
  15086. break;
  15087. }
  15088. }
  15089. }
  15090. return iterations;
  15091. };
  15092. CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {
  15093. if (reverse) {
  15094. return this.cacheResult().__iterator(type, reverse);
  15095. }
  15096. var collection = this._collection;
  15097. var iterator = getIterator(collection);
  15098. if (!isIterator(iterator)) {
  15099. return new Iterator(iteratorDone);
  15100. }
  15101. var iterations = 0;
  15102. return new Iterator(function () {
  15103. var step = iterator.next();
  15104. return step.done ? step : iteratorValue(type, iterations++, step.value);
  15105. });
  15106. };
  15107. return CollectionSeq;
  15108. }(IndexedSeq));
  15109. // # pragma Helper functions
  15110. var EMPTY_SEQ;
  15111. function emptySequence() {
  15112. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  15113. }
  15114. function keyedSeqFromValue(value) {
  15115. var seq = Array.isArray(value)
  15116. ? new ArraySeq(value)
  15117. : hasIterator(value)
  15118. ? new CollectionSeq(value)
  15119. : undefined;
  15120. if (seq) {
  15121. return seq.fromEntrySeq();
  15122. }
  15123. if (typeof value === 'object') {
  15124. return new ObjectSeq(value);
  15125. }
  15126. throw new TypeError(
  15127. 'Expected Array or collection object of [k, v] entries, or keyed object: ' +
  15128. value
  15129. );
  15130. }
  15131. function indexedSeqFromValue(value) {
  15132. var seq = maybeIndexedSeqFromValue(value);
  15133. if (seq) {
  15134. return seq;
  15135. }
  15136. throw new TypeError(
  15137. 'Expected Array or collection object of values: ' + value
  15138. );
  15139. }
  15140. function seqFromValue(value) {
  15141. var seq = maybeIndexedSeqFromValue(value);
  15142. if (seq) {
  15143. return seq;
  15144. }
  15145. if (typeof value === 'object') {
  15146. return new ObjectSeq(value);
  15147. }
  15148. throw new TypeError(
  15149. 'Expected Array or collection object of values, or keyed object: ' + value
  15150. );
  15151. }
  15152. function maybeIndexedSeqFromValue(value) {
  15153. return isArrayLike(value)
  15154. ? new ArraySeq(value)
  15155. : hasIterator(value)
  15156. ? new CollectionSeq(value)
  15157. : undefined;
  15158. }
  15159. var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@';
  15160. function isMap(maybeMap) {
  15161. return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]);
  15162. }
  15163. function isOrderedMap(maybeOrderedMap) {
  15164. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  15165. }
  15166. function isValueObject(maybeValue) {
  15167. return Boolean(
  15168. maybeValue &&
  15169. typeof maybeValue.equals === 'function' &&
  15170. typeof maybeValue.hashCode === 'function'
  15171. );
  15172. }
  15173. /**
  15174. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  15175. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  15176. *
  15177. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  15178. * value, which is different from the algorithm described by
  15179. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  15180. *
  15181. * This is extended further to allow Objects to describe the values they
  15182. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  15183. *
  15184. * Note: because of this extension, the key equality of Immutable.Map and the
  15185. * value equality of Immutable.Set will differ from ES6 Map and Set.
  15186. *
  15187. * ### Defining custom values
  15188. *
  15189. * The easiest way to describe the value an object represents is by implementing
  15190. * `valueOf`. For example, `Date` represents a value by returning a unix
  15191. * timestamp for `valueOf`:
  15192. *
  15193. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  15194. * var date2 = new Date(1234567890000);
  15195. * date1.valueOf(); // 1234567890000
  15196. * assert( date1 !== date2 );
  15197. * assert( Immutable.is( date1, date2 ) );
  15198. *
  15199. * Note: overriding `valueOf` may have other implications if you use this object
  15200. * where JavaScript expects a primitive, such as implicit string coercion.
  15201. *
  15202. * For more complex types, especially collections, implementing `valueOf` may
  15203. * not be performant. An alternative is to implement `equals` and `hashCode`.
  15204. *
  15205. * `equals` takes another object, presumably of similar type, and returns true
  15206. * if it is equal. Equality is symmetrical, so the same result should be
  15207. * returned if this and the argument are flipped.
  15208. *
  15209. * assert( a.equals(b) === b.equals(a) );
  15210. *
  15211. * `hashCode` returns a 32bit integer number representing the object which will
  15212. * be used to determine how to store the value object in a Map or Set. You must
  15213. * provide both or neither methods, one must not exist without the other.
  15214. *
  15215. * Also, an important relationship between these methods must be upheld: if two
  15216. * values are equal, they *must* return the same hashCode. If the values are not
  15217. * equal, they might have the same hashCode; this is called a hash collision,
  15218. * and while undesirable for performance reasons, it is acceptable.
  15219. *
  15220. * if (a.equals(b)) {
  15221. * assert( a.hashCode() === b.hashCode() );
  15222. * }
  15223. *
  15224. * All Immutable collections are Value Objects: they implement `equals()`
  15225. * and `hashCode()`.
  15226. */
  15227. function is(valueA, valueB) {
  15228. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  15229. return true;
  15230. }
  15231. if (!valueA || !valueB) {
  15232. return false;
  15233. }
  15234. if (
  15235. typeof valueA.valueOf === 'function' &&
  15236. typeof valueB.valueOf === 'function'
  15237. ) {
  15238. valueA = valueA.valueOf();
  15239. valueB = valueB.valueOf();
  15240. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  15241. return true;
  15242. }
  15243. if (!valueA || !valueB) {
  15244. return false;
  15245. }
  15246. }
  15247. return !!(
  15248. isValueObject(valueA) &&
  15249. isValueObject(valueB) &&
  15250. valueA.equals(valueB)
  15251. );
  15252. }
  15253. var imul =
  15254. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2
  15255. ? Math.imul
  15256. : function imul(a, b) {
  15257. a |= 0; // int
  15258. b |= 0; // int
  15259. var c = a & 0xffff;
  15260. var d = b & 0xffff;
  15261. // Shift by 0 fixes the sign on the high part.
  15262. return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int
  15263. };
  15264. // v8 has an optimization for storing 31-bit signed numbers.
  15265. // Values which have either 00 or 11 as the high order bits qualify.
  15266. // This function drops the highest order bit in a signed number, maintaining
  15267. // the sign bit.
  15268. function smi(i32) {
  15269. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
  15270. }
  15271. var defaultValueOf = Object.prototype.valueOf;
  15272. function hash(o) {
  15273. switch (typeof o) {
  15274. case 'boolean':
  15275. // The hash values for built-in constants are a 1 value for each 5-byte
  15276. // shift region expect for the first, which encodes the value. This
  15277. // reduces the odds of a hash collision for these common values.
  15278. return o ? 0x42108421 : 0x42108420;
  15279. case 'number':
  15280. return hashNumber(o);
  15281. case 'string':
  15282. return o.length > STRING_HASH_CACHE_MIN_STRLEN
  15283. ? cachedHashString(o)
  15284. : hashString(o);
  15285. case 'object':
  15286. case 'function':
  15287. if (o === null) {
  15288. return 0x42108422;
  15289. }
  15290. if (typeof o.hashCode === 'function') {
  15291. // Drop any high bits from accidentally long hash codes.
  15292. return smi(o.hashCode(o));
  15293. }
  15294. if (o.valueOf !== defaultValueOf && typeof o.valueOf === 'function') {
  15295. o = o.valueOf(o);
  15296. }
  15297. return hashJSObj(o);
  15298. case 'undefined':
  15299. return 0x42108423;
  15300. default:
  15301. if (typeof o.toString === 'function') {
  15302. return hashString(o.toString());
  15303. }
  15304. throw new Error('Value type ' + typeof o + ' cannot be hashed.');
  15305. }
  15306. }
  15307. // Compress arbitrarily large numbers into smi hashes.
  15308. function hashNumber(n) {
  15309. if (n !== n || n === Infinity) {
  15310. return 0;
  15311. }
  15312. var hash = n | 0;
  15313. if (hash !== n) {
  15314. hash ^= n * 0xffffffff;
  15315. }
  15316. while (n > 0xffffffff) {
  15317. n /= 0xffffffff;
  15318. hash ^= n;
  15319. }
  15320. return smi(hash);
  15321. }
  15322. function cachedHashString(string) {
  15323. var hashed = stringHashCache[string];
  15324. if (hashed === undefined) {
  15325. hashed = hashString(string);
  15326. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  15327. STRING_HASH_CACHE_SIZE = 0;
  15328. stringHashCache = {};
  15329. }
  15330. STRING_HASH_CACHE_SIZE++;
  15331. stringHashCache[string] = hashed;
  15332. }
  15333. return hashed;
  15334. }
  15335. // http://jsperf.com/hashing-strings
  15336. function hashString(string) {
  15337. // This is the hash from JVM
  15338. // The hash code for a string is computed as
  15339. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  15340. // where s[i] is the ith character of the string and n is the length of
  15341. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  15342. // (exclusive) by dropping high bits.
  15343. var hashed = 0;
  15344. for (var ii = 0; ii < string.length; ii++) {
  15345. hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
  15346. }
  15347. return smi(hashed);
  15348. }
  15349. function hashJSObj(obj) {
  15350. var hashed;
  15351. if (usingWeakMap) {
  15352. hashed = weakMap.get(obj);
  15353. if (hashed !== undefined) {
  15354. return hashed;
  15355. }
  15356. }
  15357. hashed = obj[UID_HASH_KEY];
  15358. if (hashed !== undefined) {
  15359. return hashed;
  15360. }
  15361. if (!canDefineProperty) {
  15362. hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  15363. if (hashed !== undefined) {
  15364. return hashed;
  15365. }
  15366. hashed = getIENodeHash(obj);
  15367. if (hashed !== undefined) {
  15368. return hashed;
  15369. }
  15370. }
  15371. hashed = ++objHashUID;
  15372. if (objHashUID & 0x40000000) {
  15373. objHashUID = 0;
  15374. }
  15375. if (usingWeakMap) {
  15376. weakMap.set(obj, hashed);
  15377. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  15378. throw new Error('Non-extensible objects are not allowed as keys.');
  15379. } else if (canDefineProperty) {
  15380. Object.defineProperty(obj, UID_HASH_KEY, {
  15381. enumerable: false,
  15382. configurable: false,
  15383. writable: false,
  15384. value: hashed,
  15385. });
  15386. } else if (
  15387. obj.propertyIsEnumerable !== undefined &&
  15388. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable
  15389. ) {
  15390. // Since we can't define a non-enumerable property on the object
  15391. // we'll hijack one of the less-used non-enumerable properties to
  15392. // save our hash on it. Since this is a function it will not show up in
  15393. // `JSON.stringify` which is what we want.
  15394. obj.propertyIsEnumerable = function() {
  15395. return this.constructor.prototype.propertyIsEnumerable.apply(
  15396. this,
  15397. arguments
  15398. );
  15399. };
  15400. obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;
  15401. } else if (obj.nodeType !== undefined) {
  15402. // At this point we couldn't get the IE `uniqueID` to use as a hash
  15403. // and we couldn't use a non-enumerable property to exploit the
  15404. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  15405. // itself.
  15406. obj[UID_HASH_KEY] = hashed;
  15407. } else {
  15408. throw new Error('Unable to set a non-enumerable property on object.');
  15409. }
  15410. return hashed;
  15411. }
  15412. // Get references to ES5 object methods.
  15413. var isExtensible = Object.isExtensible;
  15414. // True if Object.defineProperty works as expected. IE8 fails this test.
  15415. var canDefineProperty = (function() {
  15416. try {
  15417. Object.defineProperty({}, '@', {});
  15418. return true;
  15419. } catch (e) {
  15420. return false;
  15421. }
  15422. })();
  15423. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  15424. // and avoid memory leaks from the IE cloneNode bug.
  15425. function getIENodeHash(node) {
  15426. if (node && node.nodeType > 0) {
  15427. switch (node.nodeType) {
  15428. case 1: // Element
  15429. return node.uniqueID;
  15430. case 9: // Document
  15431. return node.documentElement && node.documentElement.uniqueID;
  15432. }
  15433. }
  15434. }
  15435. // If possible, use a WeakMap.
  15436. var usingWeakMap = typeof WeakMap === 'function';
  15437. var weakMap;
  15438. if (usingWeakMap) {
  15439. weakMap = new WeakMap();
  15440. }
  15441. var objHashUID = 0;
  15442. var UID_HASH_KEY = '__immutablehash__';
  15443. if (typeof Symbol === 'function') {
  15444. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  15445. }
  15446. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  15447. var STRING_HASH_CACHE_MAX_SIZE = 255;
  15448. var STRING_HASH_CACHE_SIZE = 0;
  15449. var stringHashCache = {};
  15450. var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq$$1) {
  15451. function ToKeyedSequence(indexed, useKeys) {
  15452. this._iter = indexed;
  15453. this._useKeys = useKeys;
  15454. this.size = indexed.size;
  15455. }
  15456. if ( KeyedSeq$$1 ) ToKeyedSequence.__proto__ = KeyedSeq$$1;
  15457. ToKeyedSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
  15458. ToKeyedSequence.prototype.constructor = ToKeyedSequence;
  15459. ToKeyedSequence.prototype.get = function get (key, notSetValue) {
  15460. return this._iter.get(key, notSetValue);
  15461. };
  15462. ToKeyedSequence.prototype.has = function has (key) {
  15463. return this._iter.has(key);
  15464. };
  15465. ToKeyedSequence.prototype.valueSeq = function valueSeq () {
  15466. return this._iter.valueSeq();
  15467. };
  15468. ToKeyedSequence.prototype.reverse = function reverse () {
  15469. var this$1 = this;
  15470. var reversedSequence = reverseFactory(this, true);
  15471. if (!this._useKeys) {
  15472. reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); };
  15473. }
  15474. return reversedSequence;
  15475. };
  15476. ToKeyedSequence.prototype.map = function map (mapper, context) {
  15477. var this$1 = this;
  15478. var mappedSequence = mapFactory(this, mapper, context);
  15479. if (!this._useKeys) {
  15480. mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); };
  15481. }
  15482. return mappedSequence;
  15483. };
  15484. ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  15485. var this$1 = this;
  15486. return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse);
  15487. };
  15488. ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) {
  15489. return this._iter.__iterator(type, reverse);
  15490. };
  15491. return ToKeyedSequence;
  15492. }(KeyedSeq));
  15493. ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;
  15494. var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq$$1) {
  15495. function ToIndexedSequence(iter) {
  15496. this._iter = iter;
  15497. this.size = iter.size;
  15498. }
  15499. if ( IndexedSeq$$1 ) ToIndexedSequence.__proto__ = IndexedSeq$$1;
  15500. ToIndexedSequence.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  15501. ToIndexedSequence.prototype.constructor = ToIndexedSequence;
  15502. ToIndexedSequence.prototype.includes = function includes (value) {
  15503. return this._iter.includes(value);
  15504. };
  15505. ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  15506. var this$1 = this;
  15507. var i = 0;
  15508. reverse && ensureSize(this);
  15509. return this._iter.__iterate(
  15510. function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); },
  15511. reverse
  15512. );
  15513. };
  15514. ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) {
  15515. var this$1 = this;
  15516. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  15517. var i = 0;
  15518. reverse && ensureSize(this);
  15519. return new Iterator(function () {
  15520. var step = iterator.next();
  15521. return step.done
  15522. ? step
  15523. : iteratorValue(
  15524. type,
  15525. reverse ? this$1.size - ++i : i++,
  15526. step.value,
  15527. step
  15528. );
  15529. });
  15530. };
  15531. return ToIndexedSequence;
  15532. }(IndexedSeq));
  15533. var ToSetSequence = /*@__PURE__*/(function (SetSeq$$1) {
  15534. function ToSetSequence(iter) {
  15535. this._iter = iter;
  15536. this.size = iter.size;
  15537. }
  15538. if ( SetSeq$$1 ) ToSetSequence.__proto__ = SetSeq$$1;
  15539. ToSetSequence.prototype = Object.create( SetSeq$$1 && SetSeq$$1.prototype );
  15540. ToSetSequence.prototype.constructor = ToSetSequence;
  15541. ToSetSequence.prototype.has = function has (key) {
  15542. return this._iter.includes(key);
  15543. };
  15544. ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) {
  15545. var this$1 = this;
  15546. return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse);
  15547. };
  15548. ToSetSequence.prototype.__iterator = function __iterator (type, reverse) {
  15549. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  15550. return new Iterator(function () {
  15551. var step = iterator.next();
  15552. return step.done
  15553. ? step
  15554. : iteratorValue(type, step.value, step.value, step);
  15555. });
  15556. };
  15557. return ToSetSequence;
  15558. }(SetSeq));
  15559. var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq$$1) {
  15560. function FromEntriesSequence(entries) {
  15561. this._iter = entries;
  15562. this.size = entries.size;
  15563. }
  15564. if ( KeyedSeq$$1 ) FromEntriesSequence.__proto__ = KeyedSeq$$1;
  15565. FromEntriesSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
  15566. FromEntriesSequence.prototype.constructor = FromEntriesSequence;
  15567. FromEntriesSequence.prototype.entrySeq = function entrySeq () {
  15568. return this._iter.toSeq();
  15569. };
  15570. FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) {
  15571. var this$1 = this;
  15572. return this._iter.__iterate(function (entry) {
  15573. // Check if entry exists first so array access doesn't throw for holes
  15574. // in the parent iteration.
  15575. if (entry) {
  15576. validateEntry(entry);
  15577. var indexedCollection = isCollection(entry);
  15578. return fn(
  15579. indexedCollection ? entry.get(1) : entry[1],
  15580. indexedCollection ? entry.get(0) : entry[0],
  15581. this$1
  15582. );
  15583. }
  15584. }, reverse);
  15585. };
  15586. FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) {
  15587. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  15588. return new Iterator(function () {
  15589. while (true) {
  15590. var step = iterator.next();
  15591. if (step.done) {
  15592. return step;
  15593. }
  15594. var entry = step.value;
  15595. // Check if entry exists first so array access doesn't throw for holes
  15596. // in the parent iteration.
  15597. if (entry) {
  15598. validateEntry(entry);
  15599. var indexedCollection = isCollection(entry);
  15600. return iteratorValue(
  15601. type,
  15602. indexedCollection ? entry.get(0) : entry[0],
  15603. indexedCollection ? entry.get(1) : entry[1],
  15604. step
  15605. );
  15606. }
  15607. }
  15608. });
  15609. };
  15610. return FromEntriesSequence;
  15611. }(KeyedSeq));
  15612. ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
  15613. function flipFactory(collection) {
  15614. var flipSequence = makeSequence(collection);
  15615. flipSequence._iter = collection;
  15616. flipSequence.size = collection.size;
  15617. flipSequence.flip = function () { return collection; };
  15618. flipSequence.reverse = function() {
  15619. var reversedSequence = collection.reverse.apply(this); // super.reverse()
  15620. reversedSequence.flip = function () { return collection.reverse(); };
  15621. return reversedSequence;
  15622. };
  15623. flipSequence.has = function (key) { return collection.includes(key); };
  15624. flipSequence.includes = function (key) { return collection.has(key); };
  15625. flipSequence.cacheResult = cacheResultThrough;
  15626. flipSequence.__iterateUncached = function(fn, reverse) {
  15627. var this$1 = this;
  15628. return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse);
  15629. };
  15630. flipSequence.__iteratorUncached = function(type, reverse) {
  15631. if (type === ITERATE_ENTRIES) {
  15632. var iterator = collection.__iterator(type, reverse);
  15633. return new Iterator(function () {
  15634. var step = iterator.next();
  15635. if (!step.done) {
  15636. var k = step.value[0];
  15637. step.value[0] = step.value[1];
  15638. step.value[1] = k;
  15639. }
  15640. return step;
  15641. });
  15642. }
  15643. return collection.__iterator(
  15644. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  15645. reverse
  15646. );
  15647. };
  15648. return flipSequence;
  15649. }
  15650. function mapFactory(collection, mapper, context) {
  15651. var mappedSequence = makeSequence(collection);
  15652. mappedSequence.size = collection.size;
  15653. mappedSequence.has = function (key) { return collection.has(key); };
  15654. mappedSequence.get = function (key, notSetValue) {
  15655. var v = collection.get(key, NOT_SET);
  15656. return v === NOT_SET
  15657. ? notSetValue
  15658. : mapper.call(context, v, key, collection);
  15659. };
  15660. mappedSequence.__iterateUncached = function(fn, reverse) {
  15661. var this$1 = this;
  15662. return collection.__iterate(
  15663. function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; },
  15664. reverse
  15665. );
  15666. };
  15667. mappedSequence.__iteratorUncached = function(type, reverse) {
  15668. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  15669. return new Iterator(function () {
  15670. var step = iterator.next();
  15671. if (step.done) {
  15672. return step;
  15673. }
  15674. var entry = step.value;
  15675. var key = entry[0];
  15676. return iteratorValue(
  15677. type,
  15678. key,
  15679. mapper.call(context, entry[1], key, collection),
  15680. step
  15681. );
  15682. });
  15683. };
  15684. return mappedSequence;
  15685. }
  15686. function reverseFactory(collection, useKeys) {
  15687. var this$1 = this;
  15688. var reversedSequence = makeSequence(collection);
  15689. reversedSequence._iter = collection;
  15690. reversedSequence.size = collection.size;
  15691. reversedSequence.reverse = function () { return collection; };
  15692. if (collection.flip) {
  15693. reversedSequence.flip = function() {
  15694. var flipSequence = flipFactory(collection);
  15695. flipSequence.reverse = function () { return collection.flip(); };
  15696. return flipSequence;
  15697. };
  15698. }
  15699. reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); };
  15700. reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); };
  15701. reversedSequence.includes = function (value) { return collection.includes(value); };
  15702. reversedSequence.cacheResult = cacheResultThrough;
  15703. reversedSequence.__iterate = function(fn, reverse) {
  15704. var this$1 = this;
  15705. var i = 0;
  15706. reverse && ensureSize(collection);
  15707. return collection.__iterate(
  15708. function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); },
  15709. !reverse
  15710. );
  15711. };
  15712. reversedSequence.__iterator = function (type, reverse) {
  15713. var i = 0;
  15714. reverse && ensureSize(collection);
  15715. var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse);
  15716. return new Iterator(function () {
  15717. var step = iterator.next();
  15718. if (step.done) {
  15719. return step;
  15720. }
  15721. var entry = step.value;
  15722. return iteratorValue(
  15723. type,
  15724. useKeys ? entry[0] : reverse ? this$1.size - ++i : i++,
  15725. entry[1],
  15726. step
  15727. );
  15728. });
  15729. };
  15730. return reversedSequence;
  15731. }
  15732. function filterFactory(collection, predicate, context, useKeys) {
  15733. var filterSequence = makeSequence(collection);
  15734. if (useKeys) {
  15735. filterSequence.has = function (key) {
  15736. var v = collection.get(key, NOT_SET);
  15737. return v !== NOT_SET && !!predicate.call(context, v, key, collection);
  15738. };
  15739. filterSequence.get = function (key, notSetValue) {
  15740. var v = collection.get(key, NOT_SET);
  15741. return v !== NOT_SET && predicate.call(context, v, key, collection)
  15742. ? v
  15743. : notSetValue;
  15744. };
  15745. }
  15746. filterSequence.__iterateUncached = function(fn, reverse) {
  15747. var this$1 = this;
  15748. var iterations = 0;
  15749. collection.__iterate(function (v, k, c) {
  15750. if (predicate.call(context, v, k, c)) {
  15751. iterations++;
  15752. return fn(v, useKeys ? k : iterations - 1, this$1);
  15753. }
  15754. }, reverse);
  15755. return iterations;
  15756. };
  15757. filterSequence.__iteratorUncached = function(type, reverse) {
  15758. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  15759. var iterations = 0;
  15760. return new Iterator(function () {
  15761. while (true) {
  15762. var step = iterator.next();
  15763. if (step.done) {
  15764. return step;
  15765. }
  15766. var entry = step.value;
  15767. var key = entry[0];
  15768. var value = entry[1];
  15769. if (predicate.call(context, value, key, collection)) {
  15770. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  15771. }
  15772. }
  15773. });
  15774. };
  15775. return filterSequence;
  15776. }
  15777. function countByFactory(collection, grouper, context) {
  15778. var groups = Map().asMutable();
  15779. collection.__iterate(function (v, k) {
  15780. groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; });
  15781. });
  15782. return groups.asImmutable();
  15783. }
  15784. function groupByFactory(collection, grouper, context) {
  15785. var isKeyedIter = isKeyed(collection);
  15786. var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable();
  15787. collection.__iterate(function (v, k) {
  15788. groups.update(
  15789. grouper.call(context, v, k, collection),
  15790. function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); }
  15791. );
  15792. });
  15793. var coerce = collectionClass(collection);
  15794. return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable();
  15795. }
  15796. function sliceFactory(collection, begin, end, useKeys) {
  15797. var originalSize = collection.size;
  15798. if (wholeSlice(begin, end, originalSize)) {
  15799. return collection;
  15800. }
  15801. var resolvedBegin = resolveBegin(begin, originalSize);
  15802. var resolvedEnd = resolveEnd(end, originalSize);
  15803. // begin or end will be NaN if they were provided as negative numbers and
  15804. // this collection's size is unknown. In that case, cache first so there is
  15805. // a known size and these do not resolve to NaN.
  15806. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  15807. return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys);
  15808. }
  15809. // Note: resolvedEnd is undefined when the original sequence's length is
  15810. // unknown and this slice did not supply an end and should contain all
  15811. // elements after resolvedBegin.
  15812. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  15813. var resolvedSize = resolvedEnd - resolvedBegin;
  15814. var sliceSize;
  15815. if (resolvedSize === resolvedSize) {
  15816. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  15817. }
  15818. var sliceSeq = makeSequence(collection);
  15819. // If collection.size is undefined, the size of the realized sliceSeq is
  15820. // unknown at this point unless the number of items to slice is 0
  15821. sliceSeq.size =
  15822. sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined;
  15823. if (!useKeys && isSeq(collection) && sliceSize >= 0) {
  15824. sliceSeq.get = function(index, notSetValue) {
  15825. index = wrapIndex(this, index);
  15826. return index >= 0 && index < sliceSize
  15827. ? collection.get(index + resolvedBegin, notSetValue)
  15828. : notSetValue;
  15829. };
  15830. }
  15831. sliceSeq.__iterateUncached = function(fn, reverse) {
  15832. var this$1 = this;
  15833. if (sliceSize === 0) {
  15834. return 0;
  15835. }
  15836. if (reverse) {
  15837. return this.cacheResult().__iterate(fn, reverse);
  15838. }
  15839. var skipped = 0;
  15840. var isSkipping = true;
  15841. var iterations = 0;
  15842. collection.__iterate(function (v, k) {
  15843. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  15844. iterations++;
  15845. return (
  15846. fn(v, useKeys ? k : iterations - 1, this$1) !== false &&
  15847. iterations !== sliceSize
  15848. );
  15849. }
  15850. });
  15851. return iterations;
  15852. };
  15853. sliceSeq.__iteratorUncached = function(type, reverse) {
  15854. if (sliceSize !== 0 && reverse) {
  15855. return this.cacheResult().__iterator(type, reverse);
  15856. }
  15857. // Don't bother instantiating parent iterator if taking 0.
  15858. if (sliceSize === 0) {
  15859. return new Iterator(iteratorDone);
  15860. }
  15861. var iterator = collection.__iterator(type, reverse);
  15862. var skipped = 0;
  15863. var iterations = 0;
  15864. return new Iterator(function () {
  15865. while (skipped++ < resolvedBegin) {
  15866. iterator.next();
  15867. }
  15868. if (++iterations > sliceSize) {
  15869. return iteratorDone();
  15870. }
  15871. var step = iterator.next();
  15872. if (useKeys || type === ITERATE_VALUES || step.done) {
  15873. return step;
  15874. }
  15875. if (type === ITERATE_KEYS) {
  15876. return iteratorValue(type, iterations - 1, undefined, step);
  15877. }
  15878. return iteratorValue(type, iterations - 1, step.value[1], step);
  15879. });
  15880. };
  15881. return sliceSeq;
  15882. }
  15883. function takeWhileFactory(collection, predicate, context) {
  15884. var takeSequence = makeSequence(collection);
  15885. takeSequence.__iterateUncached = function(fn, reverse) {
  15886. var this$1 = this;
  15887. if (reverse) {
  15888. return this.cacheResult().__iterate(fn, reverse);
  15889. }
  15890. var iterations = 0;
  15891. collection.__iterate(
  15892. function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); }
  15893. );
  15894. return iterations;
  15895. };
  15896. takeSequence.__iteratorUncached = function(type, reverse) {
  15897. var this$1 = this;
  15898. if (reverse) {
  15899. return this.cacheResult().__iterator(type, reverse);
  15900. }
  15901. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  15902. var iterating = true;
  15903. return new Iterator(function () {
  15904. if (!iterating) {
  15905. return iteratorDone();
  15906. }
  15907. var step = iterator.next();
  15908. if (step.done) {
  15909. return step;
  15910. }
  15911. var entry = step.value;
  15912. var k = entry[0];
  15913. var v = entry[1];
  15914. if (!predicate.call(context, v, k, this$1)) {
  15915. iterating = false;
  15916. return iteratorDone();
  15917. }
  15918. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  15919. });
  15920. };
  15921. return takeSequence;
  15922. }
  15923. function skipWhileFactory(collection, predicate, context, useKeys) {
  15924. var skipSequence = makeSequence(collection);
  15925. skipSequence.__iterateUncached = function(fn, reverse) {
  15926. var this$1 = this;
  15927. if (reverse) {
  15928. return this.cacheResult().__iterate(fn, reverse);
  15929. }
  15930. var isSkipping = true;
  15931. var iterations = 0;
  15932. collection.__iterate(function (v, k, c) {
  15933. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  15934. iterations++;
  15935. return fn(v, useKeys ? k : iterations - 1, this$1);
  15936. }
  15937. });
  15938. return iterations;
  15939. };
  15940. skipSequence.__iteratorUncached = function(type, reverse) {
  15941. var this$1 = this;
  15942. if (reverse) {
  15943. return this.cacheResult().__iterator(type, reverse);
  15944. }
  15945. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  15946. var skipping = true;
  15947. var iterations = 0;
  15948. return new Iterator(function () {
  15949. var step;
  15950. var k;
  15951. var v;
  15952. do {
  15953. step = iterator.next();
  15954. if (step.done) {
  15955. if (useKeys || type === ITERATE_VALUES) {
  15956. return step;
  15957. }
  15958. if (type === ITERATE_KEYS) {
  15959. return iteratorValue(type, iterations++, undefined, step);
  15960. }
  15961. return iteratorValue(type, iterations++, step.value[1], step);
  15962. }
  15963. var entry = step.value;
  15964. k = entry[0];
  15965. v = entry[1];
  15966. skipping && (skipping = predicate.call(context, v, k, this$1));
  15967. } while (skipping);
  15968. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  15969. });
  15970. };
  15971. return skipSequence;
  15972. }
  15973. function concatFactory(collection, values) {
  15974. var isKeyedCollection = isKeyed(collection);
  15975. var iters = [collection]
  15976. .concat(values)
  15977. .map(function (v) {
  15978. if (!isCollection(v)) {
  15979. v = isKeyedCollection
  15980. ? keyedSeqFromValue(v)
  15981. : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  15982. } else if (isKeyedCollection) {
  15983. v = KeyedCollection(v);
  15984. }
  15985. return v;
  15986. })
  15987. .filter(function (v) { return v.size !== 0; });
  15988. if (iters.length === 0) {
  15989. return collection;
  15990. }
  15991. if (iters.length === 1) {
  15992. var singleton = iters[0];
  15993. if (
  15994. singleton === collection ||
  15995. (isKeyedCollection && isKeyed(singleton)) ||
  15996. (isIndexed(collection) && isIndexed(singleton))
  15997. ) {
  15998. return singleton;
  15999. }
  16000. }
  16001. var concatSeq = new ArraySeq(iters);
  16002. if (isKeyedCollection) {
  16003. concatSeq = concatSeq.toKeyedSeq();
  16004. } else if (!isIndexed(collection)) {
  16005. concatSeq = concatSeq.toSetSeq();
  16006. }
  16007. concatSeq = concatSeq.flatten(true);
  16008. concatSeq.size = iters.reduce(function (sum, seq) {
  16009. if (sum !== undefined) {
  16010. var size = seq.size;
  16011. if (size !== undefined) {
  16012. return sum + size;
  16013. }
  16014. }
  16015. }, 0);
  16016. return concatSeq;
  16017. }
  16018. function flattenFactory(collection, depth, useKeys) {
  16019. var flatSequence = makeSequence(collection);
  16020. flatSequence.__iterateUncached = function(fn, reverse) {
  16021. if (reverse) {
  16022. return this.cacheResult().__iterate(fn, reverse);
  16023. }
  16024. var iterations = 0;
  16025. var stopped = false;
  16026. function flatDeep(iter, currentDepth) {
  16027. iter.__iterate(function (v, k) {
  16028. if ((!depth || currentDepth < depth) && isCollection(v)) {
  16029. flatDeep(v, currentDepth + 1);
  16030. } else {
  16031. iterations++;
  16032. if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) {
  16033. stopped = true;
  16034. }
  16035. }
  16036. return !stopped;
  16037. }, reverse);
  16038. }
  16039. flatDeep(collection, 0);
  16040. return iterations;
  16041. };
  16042. flatSequence.__iteratorUncached = function(type, reverse) {
  16043. if (reverse) {
  16044. return this.cacheResult().__iterator(type, reverse);
  16045. }
  16046. var iterator = collection.__iterator(type, reverse);
  16047. var stack = [];
  16048. var iterations = 0;
  16049. return new Iterator(function () {
  16050. while (iterator) {
  16051. var step = iterator.next();
  16052. if (step.done !== false) {
  16053. iterator = stack.pop();
  16054. continue;
  16055. }
  16056. var v = step.value;
  16057. if (type === ITERATE_ENTRIES) {
  16058. v = v[1];
  16059. }
  16060. if ((!depth || stack.length < depth) && isCollection(v)) {
  16061. stack.push(iterator);
  16062. iterator = v.__iterator(type, reverse);
  16063. } else {
  16064. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  16065. }
  16066. }
  16067. return iteratorDone();
  16068. });
  16069. };
  16070. return flatSequence;
  16071. }
  16072. function flatMapFactory(collection, mapper, context) {
  16073. var coerce = collectionClass(collection);
  16074. return collection
  16075. .toSeq()
  16076. .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); })
  16077. .flatten(true);
  16078. }
  16079. function interposeFactory(collection, separator) {
  16080. var interposedSequence = makeSequence(collection);
  16081. interposedSequence.size = collection.size && collection.size * 2 - 1;
  16082. interposedSequence.__iterateUncached = function(fn, reverse) {
  16083. var this$1 = this;
  16084. var iterations = 0;
  16085. collection.__iterate(
  16086. function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) &&
  16087. fn(v, iterations++, this$1) !== false; },
  16088. reverse
  16089. );
  16090. return iterations;
  16091. };
  16092. interposedSequence.__iteratorUncached = function(type, reverse) {
  16093. var iterator = collection.__iterator(ITERATE_VALUES, reverse);
  16094. var iterations = 0;
  16095. var step;
  16096. return new Iterator(function () {
  16097. if (!step || iterations % 2) {
  16098. step = iterator.next();
  16099. if (step.done) {
  16100. return step;
  16101. }
  16102. }
  16103. return iterations % 2
  16104. ? iteratorValue(type, iterations++, separator)
  16105. : iteratorValue(type, iterations++, step.value, step);
  16106. });
  16107. };
  16108. return interposedSequence;
  16109. }
  16110. function sortFactory(collection, comparator, mapper) {
  16111. if (!comparator) {
  16112. comparator = defaultComparator;
  16113. }
  16114. var isKeyedCollection = isKeyed(collection);
  16115. var index = 0;
  16116. var entries = collection
  16117. .toSeq()
  16118. .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; })
  16119. .valueSeq()
  16120. .toArray();
  16121. entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach(
  16122. isKeyedCollection
  16123. ? function (v, i) {
  16124. entries[i].length = 2;
  16125. }
  16126. : function (v, i) {
  16127. entries[i] = v[1];
  16128. }
  16129. );
  16130. return isKeyedCollection
  16131. ? KeyedSeq(entries)
  16132. : isIndexed(collection)
  16133. ? IndexedSeq(entries)
  16134. : SetSeq(entries);
  16135. }
  16136. function maxFactory(collection, comparator, mapper) {
  16137. if (!comparator) {
  16138. comparator = defaultComparator;
  16139. }
  16140. if (mapper) {
  16141. var entry = collection
  16142. .toSeq()
  16143. .map(function (v, k) { return [v, mapper(v, k, collection)]; })
  16144. .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); });
  16145. return entry && entry[0];
  16146. }
  16147. return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); });
  16148. }
  16149. function maxCompare(comparator, a, b) {
  16150. var comp = comparator(b, a);
  16151. // b is considered the new max if the comparator declares them equal, but
  16152. // they are not equal and b is in fact a nullish value.
  16153. return (
  16154. (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
  16155. comp > 0
  16156. );
  16157. }
  16158. function zipWithFactory(keyIter, zipper, iters, zipAll) {
  16159. var zipSequence = makeSequence(keyIter);
  16160. var sizes = new ArraySeq(iters).map(function (i) { return i.size; });
  16161. zipSequence.size = zipAll ? sizes.max() : sizes.min();
  16162. // Note: this a generic base implementation of __iterate in terms of
  16163. // __iterator which may be more generically useful in the future.
  16164. zipSequence.__iterate = function(fn, reverse) {
  16165. /* generic:
  16166. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  16167. var step;
  16168. var iterations = 0;
  16169. while (!(step = iterator.next()).done) {
  16170. iterations++;
  16171. if (fn(step.value[1], step.value[0], this) === false) {
  16172. break;
  16173. }
  16174. }
  16175. return iterations;
  16176. */
  16177. // indexed:
  16178. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  16179. var step;
  16180. var iterations = 0;
  16181. while (!(step = iterator.next()).done) {
  16182. if (fn(step.value, iterations++, this) === false) {
  16183. break;
  16184. }
  16185. }
  16186. return iterations;
  16187. };
  16188. zipSequence.__iteratorUncached = function(type, reverse) {
  16189. var iterators = iters.map(
  16190. function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); }
  16191. );
  16192. var iterations = 0;
  16193. var isDone = false;
  16194. return new Iterator(function () {
  16195. var steps;
  16196. if (!isDone) {
  16197. steps = iterators.map(function (i) { return i.next(); });
  16198. isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; });
  16199. }
  16200. if (isDone) {
  16201. return iteratorDone();
  16202. }
  16203. return iteratorValue(
  16204. type,
  16205. iterations++,
  16206. zipper.apply(null, steps.map(function (s) { return s.value; }))
  16207. );
  16208. });
  16209. };
  16210. return zipSequence;
  16211. }
  16212. // #pragma Helper Functions
  16213. function reify(iter, seq) {
  16214. return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq);
  16215. }
  16216. function validateEntry(entry) {
  16217. if (entry !== Object(entry)) {
  16218. throw new TypeError('Expected [K, V] tuple: ' + entry);
  16219. }
  16220. }
  16221. function collectionClass(collection) {
  16222. return isKeyed(collection)
  16223. ? KeyedCollection
  16224. : isIndexed(collection)
  16225. ? IndexedCollection
  16226. : SetCollection;
  16227. }
  16228. function makeSequence(collection) {
  16229. return Object.create(
  16230. (isKeyed(collection)
  16231. ? KeyedSeq
  16232. : isIndexed(collection)
  16233. ? IndexedSeq
  16234. : SetSeq
  16235. ).prototype
  16236. );
  16237. }
  16238. function cacheResultThrough() {
  16239. if (this._iter.cacheResult) {
  16240. this._iter.cacheResult();
  16241. this.size = this._iter.size;
  16242. return this;
  16243. }
  16244. return Seq.prototype.cacheResult.call(this);
  16245. }
  16246. function defaultComparator(a, b) {
  16247. if (a === undefined && b === undefined) {
  16248. return 0;
  16249. }
  16250. if (a === undefined) {
  16251. return 1;
  16252. }
  16253. if (b === undefined) {
  16254. return -1;
  16255. }
  16256. return a > b ? 1 : a < b ? -1 : 0;
  16257. }
  16258. // http://jsperf.com/copy-array-inline
  16259. function arrCopy(arr, offset) {
  16260. offset = offset || 0;
  16261. var len = Math.max(0, arr.length - offset);
  16262. var newArr = new Array(len);
  16263. for (var ii = 0; ii < len; ii++) {
  16264. newArr[ii] = arr[ii + offset];
  16265. }
  16266. return newArr;
  16267. }
  16268. function invariant(condition, error) {
  16269. if (!condition) { throw new Error(error); }
  16270. }
  16271. function assertNotInfinite(size) {
  16272. invariant(
  16273. size !== Infinity,
  16274. 'Cannot perform this action with an infinite size.'
  16275. );
  16276. }
  16277. function coerceKeyPath(keyPath) {
  16278. if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
  16279. return keyPath;
  16280. }
  16281. if (isOrdered(keyPath)) {
  16282. return keyPath.toArray();
  16283. }
  16284. throw new TypeError(
  16285. 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath
  16286. );
  16287. }
  16288. function isPlainObj(value) {
  16289. return (
  16290. value &&
  16291. (typeof value.constructor !== 'function' ||
  16292. value.constructor.name === 'Object')
  16293. );
  16294. }
  16295. /**
  16296. * Returns true if the value is a potentially-persistent data structure, either
  16297. * provided by Immutable.js or a plain Array or Object.
  16298. */
  16299. function isDataStructure(value) {
  16300. return (
  16301. typeof value === 'object' &&
  16302. (isImmutable(value) || Array.isArray(value) || isPlainObj(value))
  16303. );
  16304. }
  16305. /**
  16306. * Converts a value to a string, adding quotes if a string was provided.
  16307. */
  16308. function quoteString(value) {
  16309. try {
  16310. return typeof value === 'string' ? JSON.stringify(value) : String(value);
  16311. } catch (_ignoreError) {
  16312. return JSON.stringify(value);
  16313. }
  16314. }
  16315. function has(collection, key) {
  16316. return isImmutable(collection)
  16317. ? collection.has(key)
  16318. : isDataStructure(collection) && hasOwnProperty.call(collection, key);
  16319. }
  16320. function get(collection, key, notSetValue) {
  16321. return isImmutable(collection)
  16322. ? collection.get(key, notSetValue)
  16323. : !has(collection, key)
  16324. ? notSetValue
  16325. : typeof collection.get === 'function'
  16326. ? collection.get(key)
  16327. : collection[key];
  16328. }
  16329. function shallowCopy(from) {
  16330. if (Array.isArray(from)) {
  16331. return arrCopy(from);
  16332. }
  16333. var to = {};
  16334. for (var key in from) {
  16335. if (hasOwnProperty.call(from, key)) {
  16336. to[key] = from[key];
  16337. }
  16338. }
  16339. return to;
  16340. }
  16341. function remove(collection, key) {
  16342. if (!isDataStructure(collection)) {
  16343. throw new TypeError(
  16344. 'Cannot update non-data-structure value: ' + collection
  16345. );
  16346. }
  16347. if (isImmutable(collection)) {
  16348. if (!collection.remove) {
  16349. throw new TypeError(
  16350. 'Cannot update immutable value without .remove() method: ' + collection
  16351. );
  16352. }
  16353. return collection.remove(key);
  16354. }
  16355. if (!hasOwnProperty.call(collection, key)) {
  16356. return collection;
  16357. }
  16358. var collectionCopy = shallowCopy(collection);
  16359. if (Array.isArray(collectionCopy)) {
  16360. collectionCopy.splice(key, 1);
  16361. } else {
  16362. delete collectionCopy[key];
  16363. }
  16364. return collectionCopy;
  16365. }
  16366. function set(collection, key, value) {
  16367. if (!isDataStructure(collection)) {
  16368. throw new TypeError(
  16369. 'Cannot update non-data-structure value: ' + collection
  16370. );
  16371. }
  16372. if (isImmutable(collection)) {
  16373. if (!collection.set) {
  16374. throw new TypeError(
  16375. 'Cannot update immutable value without .set() method: ' + collection
  16376. );
  16377. }
  16378. return collection.set(key, value);
  16379. }
  16380. if (hasOwnProperty.call(collection, key) && value === collection[key]) {
  16381. return collection;
  16382. }
  16383. var collectionCopy = shallowCopy(collection);
  16384. collectionCopy[key] = value;
  16385. return collectionCopy;
  16386. }
  16387. function updateIn(collection, keyPath, notSetValue, updater) {
  16388. if (!updater) {
  16389. updater = notSetValue;
  16390. notSetValue = undefined;
  16391. }
  16392. var updatedValue = updateInDeeply(
  16393. isImmutable(collection),
  16394. collection,
  16395. coerceKeyPath(keyPath),
  16396. 0,
  16397. notSetValue,
  16398. updater
  16399. );
  16400. return updatedValue === NOT_SET ? notSetValue : updatedValue;
  16401. }
  16402. function updateInDeeply(
  16403. inImmutable,
  16404. existing,
  16405. keyPath,
  16406. i,
  16407. notSetValue,
  16408. updater
  16409. ) {
  16410. var wasNotSet = existing === NOT_SET;
  16411. if (i === keyPath.length) {
  16412. var existingValue = wasNotSet ? notSetValue : existing;
  16413. var newValue = updater(existingValue);
  16414. return newValue === existingValue ? existing : newValue;
  16415. }
  16416. if (!wasNotSet && !isDataStructure(existing)) {
  16417. throw new TypeError(
  16418. 'Cannot update within non-data-structure value in path [' +
  16419. keyPath.slice(0, i).map(quoteString) +
  16420. ']: ' +
  16421. existing
  16422. );
  16423. }
  16424. var key = keyPath[i];
  16425. var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
  16426. var nextUpdated = updateInDeeply(
  16427. nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
  16428. nextExisting,
  16429. keyPath,
  16430. i + 1,
  16431. notSetValue,
  16432. updater
  16433. );
  16434. return nextUpdated === nextExisting
  16435. ? existing
  16436. : nextUpdated === NOT_SET
  16437. ? remove(existing, key)
  16438. : set(
  16439. wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
  16440. key,
  16441. nextUpdated
  16442. );
  16443. }
  16444. function setIn(collection, keyPath, value) {
  16445. return updateIn(collection, keyPath, NOT_SET, function () { return value; });
  16446. }
  16447. function setIn$1(keyPath, v) {
  16448. return setIn(this, keyPath, v);
  16449. }
  16450. function removeIn(collection, keyPath) {
  16451. return updateIn(collection, keyPath, function () { return NOT_SET; });
  16452. }
  16453. function deleteIn(keyPath) {
  16454. return removeIn(this, keyPath);
  16455. }
  16456. function update(collection, key, notSetValue, updater) {
  16457. return updateIn(collection, [key], notSetValue, updater);
  16458. }
  16459. function update$1(key, notSetValue, updater) {
  16460. return arguments.length === 1
  16461. ? key(this)
  16462. : update(this, key, notSetValue, updater);
  16463. }
  16464. function updateIn$1(keyPath, notSetValue, updater) {
  16465. return updateIn(this, keyPath, notSetValue, updater);
  16466. }
  16467. function merge() {
  16468. var iters = [], len = arguments.length;
  16469. while ( len-- ) iters[ len ] = arguments[ len ];
  16470. return mergeIntoKeyedWith(this, iters);
  16471. }
  16472. function mergeWith(merger) {
  16473. var iters = [], len = arguments.length - 1;
  16474. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  16475. if (typeof merger !== 'function') {
  16476. throw new TypeError('Invalid merger function: ' + merger);
  16477. }
  16478. return mergeIntoKeyedWith(this, iters, merger);
  16479. }
  16480. function mergeIntoKeyedWith(collection, collections, merger) {
  16481. var iters = [];
  16482. for (var ii = 0; ii < collections.length; ii++) {
  16483. var collection$1 = KeyedCollection(collections[ii]);
  16484. if (collection$1.size !== 0) {
  16485. iters.push(collection$1);
  16486. }
  16487. }
  16488. if (iters.length === 0) {
  16489. return collection;
  16490. }
  16491. if (
  16492. collection.toSeq().size === 0 &&
  16493. !collection.__ownerID &&
  16494. iters.length === 1
  16495. ) {
  16496. return collection.constructor(iters[0]);
  16497. }
  16498. return collection.withMutations(function (collection) {
  16499. var mergeIntoCollection = merger
  16500. ? function (value, key) {
  16501. update(
  16502. collection,
  16503. key,
  16504. NOT_SET,
  16505. function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); }
  16506. );
  16507. }
  16508. : function (value, key) {
  16509. collection.set(key, value);
  16510. };
  16511. for (var ii = 0; ii < iters.length; ii++) {
  16512. iters[ii].forEach(mergeIntoCollection);
  16513. }
  16514. });
  16515. }
  16516. function merge$1(collection) {
  16517. var sources = [], len = arguments.length - 1;
  16518. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  16519. return mergeWithSources(collection, sources);
  16520. }
  16521. function mergeWith$1(merger, collection) {
  16522. var sources = [], len = arguments.length - 2;
  16523. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  16524. return mergeWithSources(collection, sources, merger);
  16525. }
  16526. function mergeDeep(collection) {
  16527. var sources = [], len = arguments.length - 1;
  16528. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  16529. return mergeDeepWithSources(collection, sources);
  16530. }
  16531. function mergeDeepWith(merger, collection) {
  16532. var sources = [], len = arguments.length - 2;
  16533. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  16534. return mergeDeepWithSources(collection, sources, merger);
  16535. }
  16536. function mergeDeepWithSources(collection, sources, merger) {
  16537. return mergeWithSources(collection, sources, deepMergerWith(merger));
  16538. }
  16539. function mergeWithSources(collection, sources, merger) {
  16540. if (!isDataStructure(collection)) {
  16541. throw new TypeError(
  16542. 'Cannot merge into non-data-structure value: ' + collection
  16543. );
  16544. }
  16545. if (isImmutable(collection)) {
  16546. return typeof merger === 'function' && collection.mergeWith
  16547. ? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
  16548. : collection.merge
  16549. ? collection.merge.apply(collection, sources)
  16550. : collection.concat.apply(collection, sources);
  16551. }
  16552. var isArray = Array.isArray(collection);
  16553. var merged = collection;
  16554. var Collection$$1 = isArray ? IndexedCollection : KeyedCollection;
  16555. var mergeItem = isArray
  16556. ? function (value) {
  16557. // Copy on write
  16558. if (merged === collection) {
  16559. merged = shallowCopy(merged);
  16560. }
  16561. merged.push(value);
  16562. }
  16563. : function (value, key) {
  16564. var hasVal = hasOwnProperty.call(merged, key);
  16565. var nextVal =
  16566. hasVal && merger ? merger(merged[key], value, key) : value;
  16567. if (!hasVal || nextVal !== merged[key]) {
  16568. // Copy on write
  16569. if (merged === collection) {
  16570. merged = shallowCopy(merged);
  16571. }
  16572. merged[key] = nextVal;
  16573. }
  16574. };
  16575. for (var i = 0; i < sources.length; i++) {
  16576. Collection$$1(sources[i]).forEach(mergeItem);
  16577. }
  16578. return merged;
  16579. }
  16580. function deepMergerWith(merger) {
  16581. function deepMerger(oldValue, newValue, key) {
  16582. return isDataStructure(oldValue) && isDataStructure(newValue)
  16583. ? mergeWithSources(oldValue, [newValue], deepMerger)
  16584. : merger
  16585. ? merger(oldValue, newValue, key)
  16586. : newValue;
  16587. }
  16588. return deepMerger;
  16589. }
  16590. function mergeDeep$1() {
  16591. var iters = [], len = arguments.length;
  16592. while ( len-- ) iters[ len ] = arguments[ len ];
  16593. return mergeDeepWithSources(this, iters);
  16594. }
  16595. function mergeDeepWith$1(merger) {
  16596. var iters = [], len = arguments.length - 1;
  16597. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  16598. return mergeDeepWithSources(this, iters, merger);
  16599. }
  16600. function mergeIn(keyPath) {
  16601. var iters = [], len = arguments.length - 1;
  16602. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  16603. return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); });
  16604. }
  16605. function mergeDeepIn(keyPath) {
  16606. var iters = [], len = arguments.length - 1;
  16607. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  16608. return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); }
  16609. );
  16610. }
  16611. function withMutations(fn) {
  16612. var mutable = this.asMutable();
  16613. fn(mutable);
  16614. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  16615. }
  16616. function asMutable() {
  16617. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  16618. }
  16619. function asImmutable() {
  16620. return this.__ensureOwner();
  16621. }
  16622. function wasAltered() {
  16623. return this.__altered;
  16624. }
  16625. var Map = /*@__PURE__*/(function (KeyedCollection$$1) {
  16626. function Map(value) {
  16627. return value === null || value === undefined
  16628. ? emptyMap()
  16629. : isMap(value) && !isOrdered(value)
  16630. ? value
  16631. : emptyMap().withMutations(function (map) {
  16632. var iter = KeyedCollection$$1(value);
  16633. assertNotInfinite(iter.size);
  16634. iter.forEach(function (v, k) { return map.set(k, v); });
  16635. });
  16636. }
  16637. if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1;
  16638. Map.prototype = Object.create( KeyedCollection$$1 && KeyedCollection$$1.prototype );
  16639. Map.prototype.constructor = Map;
  16640. Map.of = function of () {
  16641. var keyValues = [], len = arguments.length;
  16642. while ( len-- ) keyValues[ len ] = arguments[ len ];
  16643. return emptyMap().withMutations(function (map) {
  16644. for (var i = 0; i < keyValues.length; i += 2) {
  16645. if (i + 1 >= keyValues.length) {
  16646. throw new Error('Missing value for key: ' + keyValues[i]);
  16647. }
  16648. map.set(keyValues[i], keyValues[i + 1]);
  16649. }
  16650. });
  16651. };
  16652. Map.prototype.toString = function toString () {
  16653. return this.__toString('Map {', '}');
  16654. };
  16655. // @pragma Access
  16656. Map.prototype.get = function get (k, notSetValue) {
  16657. return this._root
  16658. ? this._root.get(0, undefined, k, notSetValue)
  16659. : notSetValue;
  16660. };
  16661. // @pragma Modification
  16662. Map.prototype.set = function set (k, v) {
  16663. return updateMap(this, k, v);
  16664. };
  16665. Map.prototype.remove = function remove (k) {
  16666. return updateMap(this, k, NOT_SET);
  16667. };
  16668. Map.prototype.deleteAll = function deleteAll (keys) {
  16669. var collection = Collection(keys);
  16670. if (collection.size === 0) {
  16671. return this;
  16672. }
  16673. return this.withMutations(function (map) {
  16674. collection.forEach(function (key) { return map.remove(key); });
  16675. });
  16676. };
  16677. Map.prototype.clear = function clear () {
  16678. if (this.size === 0) {
  16679. return this;
  16680. }
  16681. if (this.__ownerID) {
  16682. this.size = 0;
  16683. this._root = null;
  16684. this.__hash = undefined;
  16685. this.__altered = true;
  16686. return this;
  16687. }
  16688. return emptyMap();
  16689. };
  16690. // @pragma Composition
  16691. Map.prototype.sort = function sort (comparator) {
  16692. // Late binding
  16693. return OrderedMap(sortFactory(this, comparator));
  16694. };
  16695. Map.prototype.sortBy = function sortBy (mapper, comparator) {
  16696. // Late binding
  16697. return OrderedMap(sortFactory(this, comparator, mapper));
  16698. };
  16699. Map.prototype.map = function map (mapper, context) {
  16700. return this.withMutations(function (map) {
  16701. map.forEach(function (value, key) {
  16702. map.set(key, mapper.call(context, value, key, map));
  16703. });
  16704. });
  16705. };
  16706. // @pragma Mutability
  16707. Map.prototype.__iterator = function __iterator (type, reverse) {
  16708. return new MapIterator(this, type, reverse);
  16709. };
  16710. Map.prototype.__iterate = function __iterate (fn, reverse) {
  16711. var this$1 = this;
  16712. var iterations = 0;
  16713. this._root &&
  16714. this._root.iterate(function (entry) {
  16715. iterations++;
  16716. return fn(entry[1], entry[0], this$1);
  16717. }, reverse);
  16718. return iterations;
  16719. };
  16720. Map.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  16721. if (ownerID === this.__ownerID) {
  16722. return this;
  16723. }
  16724. if (!ownerID) {
  16725. if (this.size === 0) {
  16726. return emptyMap();
  16727. }
  16728. this.__ownerID = ownerID;
  16729. this.__altered = false;
  16730. return this;
  16731. }
  16732. return makeMap(this.size, this._root, ownerID, this.__hash);
  16733. };
  16734. return Map;
  16735. }(KeyedCollection));
  16736. Map.isMap = isMap;
  16737. var MapPrototype = Map.prototype;
  16738. MapPrototype[IS_MAP_SYMBOL] = true;
  16739. MapPrototype[DELETE] = MapPrototype.remove;
  16740. MapPrototype.removeAll = MapPrototype.deleteAll;
  16741. MapPrototype.setIn = setIn$1;
  16742. MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
  16743. MapPrototype.update = update$1;
  16744. MapPrototype.updateIn = updateIn$1;
  16745. MapPrototype.merge = MapPrototype.concat = merge;
  16746. MapPrototype.mergeWith = mergeWith;
  16747. MapPrototype.mergeDeep = mergeDeep$1;
  16748. MapPrototype.mergeDeepWith = mergeDeepWith$1;
  16749. MapPrototype.mergeIn = mergeIn;
  16750. MapPrototype.mergeDeepIn = mergeDeepIn;
  16751. MapPrototype.withMutations = withMutations;
  16752. MapPrototype.wasAltered = wasAltered;
  16753. MapPrototype.asImmutable = asImmutable;
  16754. MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable;
  16755. MapPrototype['@@transducer/step'] = function(result, arr) {
  16756. return result.set(arr[0], arr[1]);
  16757. };
  16758. MapPrototype['@@transducer/result'] = function(obj) {
  16759. return obj.asImmutable();
  16760. };
  16761. // #pragma Trie Nodes
  16762. var ArrayMapNode = function ArrayMapNode(ownerID, entries) {
  16763. this.ownerID = ownerID;
  16764. this.entries = entries;
  16765. };
  16766. ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  16767. var entries = this.entries;
  16768. for (var ii = 0, len = entries.length; ii < len; ii++) {
  16769. if (is(key, entries[ii][0])) {
  16770. return entries[ii][1];
  16771. }
  16772. }
  16773. return notSetValue;
  16774. };
  16775. ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  16776. var removed = value === NOT_SET;
  16777. var entries = this.entries;
  16778. var idx = 0;
  16779. var len = entries.length;
  16780. for (; idx < len; idx++) {
  16781. if (is(key, entries[idx][0])) {
  16782. break;
  16783. }
  16784. }
  16785. var exists = idx < len;
  16786. if (exists ? entries[idx][1] === value : removed) {
  16787. return this;
  16788. }
  16789. SetRef(didAlter);
  16790. (removed || !exists) && SetRef(didChangeSize);
  16791. if (removed && entries.length === 1) {
  16792. return; // undefined
  16793. }
  16794. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  16795. return createNodes(ownerID, entries, key, value);
  16796. }
  16797. var isEditable = ownerID && ownerID === this.ownerID;
  16798. var newEntries = isEditable ? entries : arrCopy(entries);
  16799. if (exists) {
  16800. if (removed) {
  16801. idx === len - 1
  16802. ? newEntries.pop()
  16803. : (newEntries[idx] = newEntries.pop());
  16804. } else {
  16805. newEntries[idx] = [key, value];
  16806. }
  16807. } else {
  16808. newEntries.push([key, value]);
  16809. }
  16810. if (isEditable) {
  16811. this.entries = newEntries;
  16812. return this;
  16813. }
  16814. return new ArrayMapNode(ownerID, newEntries);
  16815. };
  16816. var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) {
  16817. this.ownerID = ownerID;
  16818. this.bitmap = bitmap;
  16819. this.nodes = nodes;
  16820. };
  16821. BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  16822. if (keyHash === undefined) {
  16823. keyHash = hash(key);
  16824. }
  16825. var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
  16826. var bitmap = this.bitmap;
  16827. return (bitmap & bit) === 0
  16828. ? notSetValue
  16829. : this.nodes[popCount(bitmap & (bit - 1))].get(
  16830. shift + SHIFT,
  16831. keyHash,
  16832. key,
  16833. notSetValue
  16834. );
  16835. };
  16836. BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  16837. if (keyHash === undefined) {
  16838. keyHash = hash(key);
  16839. }
  16840. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  16841. var bit = 1 << keyHashFrag;
  16842. var bitmap = this.bitmap;
  16843. var exists = (bitmap & bit) !== 0;
  16844. if (!exists && value === NOT_SET) {
  16845. return this;
  16846. }
  16847. var idx = popCount(bitmap & (bit - 1));
  16848. var nodes = this.nodes;
  16849. var node = exists ? nodes[idx] : undefined;
  16850. var newNode = updateNode(
  16851. node,
  16852. ownerID,
  16853. shift + SHIFT,
  16854. keyHash,
  16855. key,
  16856. value,
  16857. didChangeSize,
  16858. didAlter
  16859. );
  16860. if (newNode === node) {
  16861. return this;
  16862. }
  16863. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  16864. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  16865. }
  16866. if (
  16867. exists &&
  16868. !newNode &&
  16869. nodes.length === 2 &&
  16870. isLeafNode(nodes[idx ^ 1])
  16871. ) {
  16872. return nodes[idx ^ 1];
  16873. }
  16874. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  16875. return newNode;
  16876. }
  16877. var isEditable = ownerID && ownerID === this.ownerID;
  16878. var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
  16879. var newNodes = exists
  16880. ? newNode
  16881. ? setAt(nodes, idx, newNode, isEditable)
  16882. : spliceOut(nodes, idx, isEditable)
  16883. : spliceIn(nodes, idx, newNode, isEditable);
  16884. if (isEditable) {
  16885. this.bitmap = newBitmap;
  16886. this.nodes = newNodes;
  16887. return this;
  16888. }
  16889. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  16890. };
  16891. var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) {
  16892. this.ownerID = ownerID;
  16893. this.count = count;
  16894. this.nodes = nodes;
  16895. };
  16896. HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  16897. if (keyHash === undefined) {
  16898. keyHash = hash(key);
  16899. }
  16900. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  16901. var node = this.nodes[idx];
  16902. return node
  16903. ? node.get(shift + SHIFT, keyHash, key, notSetValue)
  16904. : notSetValue;
  16905. };
  16906. HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  16907. if (keyHash === undefined) {
  16908. keyHash = hash(key);
  16909. }
  16910. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  16911. var removed = value === NOT_SET;
  16912. var nodes = this.nodes;
  16913. var node = nodes[idx];
  16914. if (removed && !node) {
  16915. return this;
  16916. }
  16917. var newNode = updateNode(
  16918. node,
  16919. ownerID,
  16920. shift + SHIFT,
  16921. keyHash,
  16922. key,
  16923. value,
  16924. didChangeSize,
  16925. didAlter
  16926. );
  16927. if (newNode === node) {
  16928. return this;
  16929. }
  16930. var newCount = this.count;
  16931. if (!node) {
  16932. newCount++;
  16933. } else if (!newNode) {
  16934. newCount--;
  16935. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  16936. return packNodes(ownerID, nodes, newCount, idx);
  16937. }
  16938. }
  16939. var isEditable = ownerID && ownerID === this.ownerID;
  16940. var newNodes = setAt(nodes, idx, newNode, isEditable);
  16941. if (isEditable) {
  16942. this.count = newCount;
  16943. this.nodes = newNodes;
  16944. return this;
  16945. }
  16946. return new HashArrayMapNode(ownerID, newCount, newNodes);
  16947. };
  16948. var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) {
  16949. this.ownerID = ownerID;
  16950. this.keyHash = keyHash;
  16951. this.entries = entries;
  16952. };
  16953. HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  16954. var entries = this.entries;
  16955. for (var ii = 0, len = entries.length; ii < len; ii++) {
  16956. if (is(key, entries[ii][0])) {
  16957. return entries[ii][1];
  16958. }
  16959. }
  16960. return notSetValue;
  16961. };
  16962. HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  16963. if (keyHash === undefined) {
  16964. keyHash = hash(key);
  16965. }
  16966. var removed = value === NOT_SET;
  16967. if (keyHash !== this.keyHash) {
  16968. if (removed) {
  16969. return this;
  16970. }
  16971. SetRef(didAlter);
  16972. SetRef(didChangeSize);
  16973. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  16974. }
  16975. var entries = this.entries;
  16976. var idx = 0;
  16977. var len = entries.length;
  16978. for (; idx < len; idx++) {
  16979. if (is(key, entries[idx][0])) {
  16980. break;
  16981. }
  16982. }
  16983. var exists = idx < len;
  16984. if (exists ? entries[idx][1] === value : removed) {
  16985. return this;
  16986. }
  16987. SetRef(didAlter);
  16988. (removed || !exists) && SetRef(didChangeSize);
  16989. if (removed && len === 2) {
  16990. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  16991. }
  16992. var isEditable = ownerID && ownerID === this.ownerID;
  16993. var newEntries = isEditable ? entries : arrCopy(entries);
  16994. if (exists) {
  16995. if (removed) {
  16996. idx === len - 1
  16997. ? newEntries.pop()
  16998. : (newEntries[idx] = newEntries.pop());
  16999. } else {
  17000. newEntries[idx] = [key, value];
  17001. }
  17002. } else {
  17003. newEntries.push([key, value]);
  17004. }
  17005. if (isEditable) {
  17006. this.entries = newEntries;
  17007. return this;
  17008. }
  17009. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  17010. };
  17011. var ValueNode = function ValueNode(ownerID, keyHash, entry) {
  17012. this.ownerID = ownerID;
  17013. this.keyHash = keyHash;
  17014. this.entry = entry;
  17015. };
  17016. ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  17017. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  17018. };
  17019. ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  17020. var removed = value === NOT_SET;
  17021. var keyMatch = is(key, this.entry[0]);
  17022. if (keyMatch ? value === this.entry[1] : removed) {
  17023. return this;
  17024. }
  17025. SetRef(didAlter);
  17026. if (removed) {
  17027. SetRef(didChangeSize);
  17028. return; // undefined
  17029. }
  17030. if (keyMatch) {
  17031. if (ownerID && ownerID === this.ownerID) {
  17032. this.entry[1] = value;
  17033. return this;
  17034. }
  17035. return new ValueNode(ownerID, this.keyHash, [key, value]);
  17036. }
  17037. SetRef(didChangeSize);
  17038. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  17039. };
  17040. // #pragma Iterators
  17041. ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(
  17042. fn,
  17043. reverse
  17044. ) {
  17045. var entries = this.entries;
  17046. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  17047. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  17048. return false;
  17049. }
  17050. }
  17051. };
  17052. BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(
  17053. fn,
  17054. reverse
  17055. ) {
  17056. var nodes = this.nodes;
  17057. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  17058. var node = nodes[reverse ? maxIndex - ii : ii];
  17059. if (node && node.iterate(fn, reverse) === false) {
  17060. return false;
  17061. }
  17062. }
  17063. };
  17064. // eslint-disable-next-line no-unused-vars
  17065. ValueNode.prototype.iterate = function(fn, reverse) {
  17066. return fn(this.entry);
  17067. };
  17068. var MapIterator = /*@__PURE__*/(function (Iterator$$1) {
  17069. function MapIterator(map, type, reverse) {
  17070. this._type = type;
  17071. this._reverse = reverse;
  17072. this._stack = map._root && mapIteratorFrame(map._root);
  17073. }
  17074. if ( Iterator$$1 ) MapIterator.__proto__ = Iterator$$1;
  17075. MapIterator.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype );
  17076. MapIterator.prototype.constructor = MapIterator;
  17077. MapIterator.prototype.next = function next () {
  17078. var type = this._type;
  17079. var stack = this._stack;
  17080. while (stack) {
  17081. var node = stack.node;
  17082. var index = stack.index++;
  17083. var maxIndex = (void 0);
  17084. if (node.entry) {
  17085. if (index === 0) {
  17086. return mapIteratorValue(type, node.entry);
  17087. }
  17088. } else if (node.entries) {
  17089. maxIndex = node.entries.length - 1;
  17090. if (index <= maxIndex) {
  17091. return mapIteratorValue(
  17092. type,
  17093. node.entries[this._reverse ? maxIndex - index : index]
  17094. );
  17095. }
  17096. } else {
  17097. maxIndex = node.nodes.length - 1;
  17098. if (index <= maxIndex) {
  17099. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  17100. if (subNode) {
  17101. if (subNode.entry) {
  17102. return mapIteratorValue(type, subNode.entry);
  17103. }
  17104. stack = this._stack = mapIteratorFrame(subNode, stack);
  17105. }
  17106. continue;
  17107. }
  17108. }
  17109. stack = this._stack = this._stack.__prev;
  17110. }
  17111. return iteratorDone();
  17112. };
  17113. return MapIterator;
  17114. }(Iterator));
  17115. function mapIteratorValue(type, entry) {
  17116. return iteratorValue(type, entry[0], entry[1]);
  17117. }
  17118. function mapIteratorFrame(node, prev) {
  17119. return {
  17120. node: node,
  17121. index: 0,
  17122. __prev: prev,
  17123. };
  17124. }
  17125. function makeMap(size, root, ownerID, hash$$1) {
  17126. var map = Object.create(MapPrototype);
  17127. map.size = size;
  17128. map._root = root;
  17129. map.__ownerID = ownerID;
  17130. map.__hash = hash$$1;
  17131. map.__altered = false;
  17132. return map;
  17133. }
  17134. var EMPTY_MAP;
  17135. function emptyMap() {
  17136. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  17137. }
  17138. function updateMap(map, k, v) {
  17139. var newRoot;
  17140. var newSize;
  17141. if (!map._root) {
  17142. if (v === NOT_SET) {
  17143. return map;
  17144. }
  17145. newSize = 1;
  17146. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  17147. } else {
  17148. var didChangeSize = MakeRef();
  17149. var didAlter = MakeRef();
  17150. newRoot = updateNode(
  17151. map._root,
  17152. map.__ownerID,
  17153. 0,
  17154. undefined,
  17155. k,
  17156. v,
  17157. didChangeSize,
  17158. didAlter
  17159. );
  17160. if (!didAlter.value) {
  17161. return map;
  17162. }
  17163. newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
  17164. }
  17165. if (map.__ownerID) {
  17166. map.size = newSize;
  17167. map._root = newRoot;
  17168. map.__hash = undefined;
  17169. map.__altered = true;
  17170. return map;
  17171. }
  17172. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  17173. }
  17174. function updateNode(
  17175. node,
  17176. ownerID,
  17177. shift,
  17178. keyHash,
  17179. key,
  17180. value,
  17181. didChangeSize,
  17182. didAlter
  17183. ) {
  17184. if (!node) {
  17185. if (value === NOT_SET) {
  17186. return node;
  17187. }
  17188. SetRef(didAlter);
  17189. SetRef(didChangeSize);
  17190. return new ValueNode(ownerID, keyHash, [key, value]);
  17191. }
  17192. return node.update(
  17193. ownerID,
  17194. shift,
  17195. keyHash,
  17196. key,
  17197. value,
  17198. didChangeSize,
  17199. didAlter
  17200. );
  17201. }
  17202. function isLeafNode(node) {
  17203. return (
  17204. node.constructor === ValueNode || node.constructor === HashCollisionNode
  17205. );
  17206. }
  17207. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  17208. if (node.keyHash === keyHash) {
  17209. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  17210. }
  17211. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  17212. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  17213. var newNode;
  17214. var nodes =
  17215. idx1 === idx2
  17216. ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
  17217. : ((newNode = new ValueNode(ownerID, keyHash, entry)),
  17218. idx1 < idx2 ? [node, newNode] : [newNode, node]);
  17219. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  17220. }
  17221. function createNodes(ownerID, entries, key, value) {
  17222. if (!ownerID) {
  17223. ownerID = new OwnerID();
  17224. }
  17225. var node = new ValueNode(ownerID, hash(key), [key, value]);
  17226. for (var ii = 0; ii < entries.length; ii++) {
  17227. var entry = entries[ii];
  17228. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  17229. }
  17230. return node;
  17231. }
  17232. function packNodes(ownerID, nodes, count, excluding) {
  17233. var bitmap = 0;
  17234. var packedII = 0;
  17235. var packedNodes = new Array(count);
  17236. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  17237. var node = nodes[ii];
  17238. if (node !== undefined && ii !== excluding) {
  17239. bitmap |= bit;
  17240. packedNodes[packedII++] = node;
  17241. }
  17242. }
  17243. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  17244. }
  17245. function expandNodes(ownerID, nodes, bitmap, including, node) {
  17246. var count = 0;
  17247. var expandedNodes = new Array(SIZE);
  17248. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  17249. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  17250. }
  17251. expandedNodes[including] = node;
  17252. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  17253. }
  17254. function popCount(x) {
  17255. x -= (x >> 1) & 0x55555555;
  17256. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  17257. x = (x + (x >> 4)) & 0x0f0f0f0f;
  17258. x += x >> 8;
  17259. x += x >> 16;
  17260. return x & 0x7f;
  17261. }
  17262. function setAt(array, idx, val, canEdit) {
  17263. var newArray = canEdit ? array : arrCopy(array);
  17264. newArray[idx] = val;
  17265. return newArray;
  17266. }
  17267. function spliceIn(array, idx, val, canEdit) {
  17268. var newLen = array.length + 1;
  17269. if (canEdit && idx + 1 === newLen) {
  17270. array[idx] = val;
  17271. return array;
  17272. }
  17273. var newArray = new Array(newLen);
  17274. var after = 0;
  17275. for (var ii = 0; ii < newLen; ii++) {
  17276. if (ii === idx) {
  17277. newArray[ii] = val;
  17278. after = -1;
  17279. } else {
  17280. newArray[ii] = array[ii + after];
  17281. }
  17282. }
  17283. return newArray;
  17284. }
  17285. function spliceOut(array, idx, canEdit) {
  17286. var newLen = array.length - 1;
  17287. if (canEdit && idx === newLen) {
  17288. array.pop();
  17289. return array;
  17290. }
  17291. var newArray = new Array(newLen);
  17292. var after = 0;
  17293. for (var ii = 0; ii < newLen; ii++) {
  17294. if (ii === idx) {
  17295. after = 1;
  17296. }
  17297. newArray[ii] = array[ii + after];
  17298. }
  17299. return newArray;
  17300. }
  17301. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  17302. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  17303. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  17304. var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@';
  17305. function isList(maybeList) {
  17306. return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]);
  17307. }
  17308. var List = /*@__PURE__*/(function (IndexedCollection$$1) {
  17309. function List(value) {
  17310. var empty = emptyList();
  17311. if (value === null || value === undefined) {
  17312. return empty;
  17313. }
  17314. if (isList(value)) {
  17315. return value;
  17316. }
  17317. var iter = IndexedCollection$$1(value);
  17318. var size = iter.size;
  17319. if (size === 0) {
  17320. return empty;
  17321. }
  17322. assertNotInfinite(size);
  17323. if (size > 0 && size < SIZE) {
  17324. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  17325. }
  17326. return empty.withMutations(function (list) {
  17327. list.setSize(size);
  17328. iter.forEach(function (v, i) { return list.set(i, v); });
  17329. });
  17330. }
  17331. if ( IndexedCollection$$1 ) List.__proto__ = IndexedCollection$$1;
  17332. List.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
  17333. List.prototype.constructor = List;
  17334. List.of = function of (/*...values*/) {
  17335. return this(arguments);
  17336. };
  17337. List.prototype.toString = function toString () {
  17338. return this.__toString('List [', ']');
  17339. };
  17340. // @pragma Access
  17341. List.prototype.get = function get (index, notSetValue) {
  17342. index = wrapIndex(this, index);
  17343. if (index >= 0 && index < this.size) {
  17344. index += this._origin;
  17345. var node = listNodeFor(this, index);
  17346. return node && node.array[index & MASK];
  17347. }
  17348. return notSetValue;
  17349. };
  17350. // @pragma Modification
  17351. List.prototype.set = function set (index, value) {
  17352. return updateList(this, index, value);
  17353. };
  17354. List.prototype.remove = function remove (index) {
  17355. return !this.has(index)
  17356. ? this
  17357. : index === 0
  17358. ? this.shift()
  17359. : index === this.size - 1
  17360. ? this.pop()
  17361. : this.splice(index, 1);
  17362. };
  17363. List.prototype.insert = function insert (index, value) {
  17364. return this.splice(index, 0, value);
  17365. };
  17366. List.prototype.clear = function clear () {
  17367. if (this.size === 0) {
  17368. return this;
  17369. }
  17370. if (this.__ownerID) {
  17371. this.size = this._origin = this._capacity = 0;
  17372. this._level = SHIFT;
  17373. this._root = this._tail = null;
  17374. this.__hash = undefined;
  17375. this.__altered = true;
  17376. return this;
  17377. }
  17378. return emptyList();
  17379. };
  17380. List.prototype.push = function push (/*...values*/) {
  17381. var values = arguments;
  17382. var oldSize = this.size;
  17383. return this.withMutations(function (list) {
  17384. setListBounds(list, 0, oldSize + values.length);
  17385. for (var ii = 0; ii < values.length; ii++) {
  17386. list.set(oldSize + ii, values[ii]);
  17387. }
  17388. });
  17389. };
  17390. List.prototype.pop = function pop () {
  17391. return setListBounds(this, 0, -1);
  17392. };
  17393. List.prototype.unshift = function unshift (/*...values*/) {
  17394. var values = arguments;
  17395. return this.withMutations(function (list) {
  17396. setListBounds(list, -values.length);
  17397. for (var ii = 0; ii < values.length; ii++) {
  17398. list.set(ii, values[ii]);
  17399. }
  17400. });
  17401. };
  17402. List.prototype.shift = function shift () {
  17403. return setListBounds(this, 1);
  17404. };
  17405. // @pragma Composition
  17406. List.prototype.concat = function concat (/*...collections*/) {
  17407. var arguments$1 = arguments;
  17408. var seqs = [];
  17409. for (var i = 0; i < arguments.length; i++) {
  17410. var argument = arguments$1[i];
  17411. var seq = IndexedCollection$$1(
  17412. typeof argument !== 'string' && hasIterator(argument)
  17413. ? argument
  17414. : [argument]
  17415. );
  17416. if (seq.size !== 0) {
  17417. seqs.push(seq);
  17418. }
  17419. }
  17420. if (seqs.length === 0) {
  17421. return this;
  17422. }
  17423. if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
  17424. return this.constructor(seqs[0]);
  17425. }
  17426. return this.withMutations(function (list) {
  17427. seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); });
  17428. });
  17429. };
  17430. List.prototype.setSize = function setSize (size) {
  17431. return setListBounds(this, 0, size);
  17432. };
  17433. List.prototype.map = function map (mapper, context) {
  17434. var this$1 = this;
  17435. return this.withMutations(function (list) {
  17436. for (var i = 0; i < this$1.size; i++) {
  17437. list.set(i, mapper.call(context, list.get(i), i, list));
  17438. }
  17439. });
  17440. };
  17441. // @pragma Iteration
  17442. List.prototype.slice = function slice (begin, end) {
  17443. var size = this.size;
  17444. if (wholeSlice(begin, end, size)) {
  17445. return this;
  17446. }
  17447. return setListBounds(
  17448. this,
  17449. resolveBegin(begin, size),
  17450. resolveEnd(end, size)
  17451. );
  17452. };
  17453. List.prototype.__iterator = function __iterator (type, reverse) {
  17454. var index = reverse ? this.size : 0;
  17455. var values = iterateList(this, reverse);
  17456. return new Iterator(function () {
  17457. var value = values();
  17458. return value === DONE
  17459. ? iteratorDone()
  17460. : iteratorValue(type, reverse ? --index : index++, value);
  17461. });
  17462. };
  17463. List.prototype.__iterate = function __iterate (fn, reverse) {
  17464. var index = reverse ? this.size : 0;
  17465. var values = iterateList(this, reverse);
  17466. var value;
  17467. while ((value = values()) !== DONE) {
  17468. if (fn(value, reverse ? --index : index++, this) === false) {
  17469. break;
  17470. }
  17471. }
  17472. return index;
  17473. };
  17474. List.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  17475. if (ownerID === this.__ownerID) {
  17476. return this;
  17477. }
  17478. if (!ownerID) {
  17479. if (this.size === 0) {
  17480. return emptyList();
  17481. }
  17482. this.__ownerID = ownerID;
  17483. this.__altered = false;
  17484. return this;
  17485. }
  17486. return makeList(
  17487. this._origin,
  17488. this._capacity,
  17489. this._level,
  17490. this._root,
  17491. this._tail,
  17492. ownerID,
  17493. this.__hash
  17494. );
  17495. };
  17496. return List;
  17497. }(IndexedCollection));
  17498. List.isList = isList;
  17499. var ListPrototype = List.prototype;
  17500. ListPrototype[IS_LIST_SYMBOL] = true;
  17501. ListPrototype[DELETE] = ListPrototype.remove;
  17502. ListPrototype.merge = ListPrototype.concat;
  17503. ListPrototype.setIn = setIn$1;
  17504. ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
  17505. ListPrototype.update = update$1;
  17506. ListPrototype.updateIn = updateIn$1;
  17507. ListPrototype.mergeIn = mergeIn;
  17508. ListPrototype.mergeDeepIn = mergeDeepIn;
  17509. ListPrototype.withMutations = withMutations;
  17510. ListPrototype.wasAltered = wasAltered;
  17511. ListPrototype.asImmutable = asImmutable;
  17512. ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable;
  17513. ListPrototype['@@transducer/step'] = function(result, arr) {
  17514. return result.push(arr);
  17515. };
  17516. ListPrototype['@@transducer/result'] = function(obj) {
  17517. return obj.asImmutable();
  17518. };
  17519. var VNode = function VNode(array, ownerID) {
  17520. this.array = array;
  17521. this.ownerID = ownerID;
  17522. };
  17523. // TODO: seems like these methods are very similar
  17524. VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) {
  17525. if (index === level ? 1 << level : this.array.length === 0) {
  17526. return this;
  17527. }
  17528. var originIndex = (index >>> level) & MASK;
  17529. if (originIndex >= this.array.length) {
  17530. return new VNode([], ownerID);
  17531. }
  17532. var removingFirst = originIndex === 0;
  17533. var newChild;
  17534. if (level > 0) {
  17535. var oldChild = this.array[originIndex];
  17536. newChild =
  17537. oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  17538. if (newChild === oldChild && removingFirst) {
  17539. return this;
  17540. }
  17541. }
  17542. if (removingFirst && !newChild) {
  17543. return this;
  17544. }
  17545. var editable = editableVNode(this, ownerID);
  17546. if (!removingFirst) {
  17547. for (var ii = 0; ii < originIndex; ii++) {
  17548. editable.array[ii] = undefined;
  17549. }
  17550. }
  17551. if (newChild) {
  17552. editable.array[originIndex] = newChild;
  17553. }
  17554. return editable;
  17555. };
  17556. VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) {
  17557. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  17558. return this;
  17559. }
  17560. var sizeIndex = ((index - 1) >>> level) & MASK;
  17561. if (sizeIndex >= this.array.length) {
  17562. return this;
  17563. }
  17564. var newChild;
  17565. if (level > 0) {
  17566. var oldChild = this.array[sizeIndex];
  17567. newChild =
  17568. oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  17569. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  17570. return this;
  17571. }
  17572. }
  17573. var editable = editableVNode(this, ownerID);
  17574. editable.array.splice(sizeIndex + 1);
  17575. if (newChild) {
  17576. editable.array[sizeIndex] = newChild;
  17577. }
  17578. return editable;
  17579. };
  17580. var DONE = {};
  17581. function iterateList(list, reverse) {
  17582. var left = list._origin;
  17583. var right = list._capacity;
  17584. var tailPos = getTailOffset(right);
  17585. var tail = list._tail;
  17586. return iterateNodeOrLeaf(list._root, list._level, 0);
  17587. function iterateNodeOrLeaf(node, level, offset) {
  17588. return level === 0
  17589. ? iterateLeaf(node, offset)
  17590. : iterateNode(node, level, offset);
  17591. }
  17592. function iterateLeaf(node, offset) {
  17593. var array = offset === tailPos ? tail && tail.array : node && node.array;
  17594. var from = offset > left ? 0 : left - offset;
  17595. var to = right - offset;
  17596. if (to > SIZE) {
  17597. to = SIZE;
  17598. }
  17599. return function () {
  17600. if (from === to) {
  17601. return DONE;
  17602. }
  17603. var idx = reverse ? --to : from++;
  17604. return array && array[idx];
  17605. };
  17606. }
  17607. function iterateNode(node, level, offset) {
  17608. var values;
  17609. var array = node && node.array;
  17610. var from = offset > left ? 0 : (left - offset) >> level;
  17611. var to = ((right - offset) >> level) + 1;
  17612. if (to > SIZE) {
  17613. to = SIZE;
  17614. }
  17615. return function () {
  17616. while (true) {
  17617. if (values) {
  17618. var value = values();
  17619. if (value !== DONE) {
  17620. return value;
  17621. }
  17622. values = null;
  17623. }
  17624. if (from === to) {
  17625. return DONE;
  17626. }
  17627. var idx = reverse ? --to : from++;
  17628. values = iterateNodeOrLeaf(
  17629. array && array[idx],
  17630. level - SHIFT,
  17631. offset + (idx << level)
  17632. );
  17633. }
  17634. };
  17635. }
  17636. }
  17637. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  17638. var list = Object.create(ListPrototype);
  17639. list.size = capacity - origin;
  17640. list._origin = origin;
  17641. list._capacity = capacity;
  17642. list._level = level;
  17643. list._root = root;
  17644. list._tail = tail;
  17645. list.__ownerID = ownerID;
  17646. list.__hash = hash;
  17647. list.__altered = false;
  17648. return list;
  17649. }
  17650. var EMPTY_LIST;
  17651. function emptyList() {
  17652. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  17653. }
  17654. function updateList(list, index, value) {
  17655. index = wrapIndex(list, index);
  17656. if (index !== index) {
  17657. return list;
  17658. }
  17659. if (index >= list.size || index < 0) {
  17660. return list.withMutations(function (list) {
  17661. index < 0
  17662. ? setListBounds(list, index).set(0, value)
  17663. : setListBounds(list, 0, index + 1).set(index, value);
  17664. });
  17665. }
  17666. index += list._origin;
  17667. var newTail = list._tail;
  17668. var newRoot = list._root;
  17669. var didAlter = MakeRef();
  17670. if (index >= getTailOffset(list._capacity)) {
  17671. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  17672. } else {
  17673. newRoot = updateVNode(
  17674. newRoot,
  17675. list.__ownerID,
  17676. list._level,
  17677. index,
  17678. value,
  17679. didAlter
  17680. );
  17681. }
  17682. if (!didAlter.value) {
  17683. return list;
  17684. }
  17685. if (list.__ownerID) {
  17686. list._root = newRoot;
  17687. list._tail = newTail;
  17688. list.__hash = undefined;
  17689. list.__altered = true;
  17690. return list;
  17691. }
  17692. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  17693. }
  17694. function updateVNode(node, ownerID, level, index, value, didAlter) {
  17695. var idx = (index >>> level) & MASK;
  17696. var nodeHas = node && idx < node.array.length;
  17697. if (!nodeHas && value === undefined) {
  17698. return node;
  17699. }
  17700. var newNode;
  17701. if (level > 0) {
  17702. var lowerNode = node && node.array[idx];
  17703. var newLowerNode = updateVNode(
  17704. lowerNode,
  17705. ownerID,
  17706. level - SHIFT,
  17707. index,
  17708. value,
  17709. didAlter
  17710. );
  17711. if (newLowerNode === lowerNode) {
  17712. return node;
  17713. }
  17714. newNode = editableVNode(node, ownerID);
  17715. newNode.array[idx] = newLowerNode;
  17716. return newNode;
  17717. }
  17718. if (nodeHas && node.array[idx] === value) {
  17719. return node;
  17720. }
  17721. if (didAlter) {
  17722. SetRef(didAlter);
  17723. }
  17724. newNode = editableVNode(node, ownerID);
  17725. if (value === undefined && idx === newNode.array.length - 1) {
  17726. newNode.array.pop();
  17727. } else {
  17728. newNode.array[idx] = value;
  17729. }
  17730. return newNode;
  17731. }
  17732. function editableVNode(node, ownerID) {
  17733. if (ownerID && node && ownerID === node.ownerID) {
  17734. return node;
  17735. }
  17736. return new VNode(node ? node.array.slice() : [], ownerID);
  17737. }
  17738. function listNodeFor(list, rawIndex) {
  17739. if (rawIndex >= getTailOffset(list._capacity)) {
  17740. return list._tail;
  17741. }
  17742. if (rawIndex < 1 << (list._level + SHIFT)) {
  17743. var node = list._root;
  17744. var level = list._level;
  17745. while (node && level > 0) {
  17746. node = node.array[(rawIndex >>> level) & MASK];
  17747. level -= SHIFT;
  17748. }
  17749. return node;
  17750. }
  17751. }
  17752. function setListBounds(list, begin, end) {
  17753. // Sanitize begin & end using this shorthand for ToInt32(argument)
  17754. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  17755. if (begin !== undefined) {
  17756. begin |= 0;
  17757. }
  17758. if (end !== undefined) {
  17759. end |= 0;
  17760. }
  17761. var owner = list.__ownerID || new OwnerID();
  17762. var oldOrigin = list._origin;
  17763. var oldCapacity = list._capacity;
  17764. var newOrigin = oldOrigin + begin;
  17765. var newCapacity =
  17766. end === undefined
  17767. ? oldCapacity
  17768. : end < 0
  17769. ? oldCapacity + end
  17770. : oldOrigin + end;
  17771. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  17772. return list;
  17773. }
  17774. // If it's going to end after it starts, it's empty.
  17775. if (newOrigin >= newCapacity) {
  17776. return list.clear();
  17777. }
  17778. var newLevel = list._level;
  17779. var newRoot = list._root;
  17780. // New origin might need creating a higher root.
  17781. var offsetShift = 0;
  17782. while (newOrigin + offsetShift < 0) {
  17783. newRoot = new VNode(
  17784. newRoot && newRoot.array.length ? [undefined, newRoot] : [],
  17785. owner
  17786. );
  17787. newLevel += SHIFT;
  17788. offsetShift += 1 << newLevel;
  17789. }
  17790. if (offsetShift) {
  17791. newOrigin += offsetShift;
  17792. oldOrigin += offsetShift;
  17793. newCapacity += offsetShift;
  17794. oldCapacity += offsetShift;
  17795. }
  17796. var oldTailOffset = getTailOffset(oldCapacity);
  17797. var newTailOffset = getTailOffset(newCapacity);
  17798. // New size might need creating a higher root.
  17799. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  17800. newRoot = new VNode(
  17801. newRoot && newRoot.array.length ? [newRoot] : [],
  17802. owner
  17803. );
  17804. newLevel += SHIFT;
  17805. }
  17806. // Locate or create the new tail.
  17807. var oldTail = list._tail;
  17808. var newTail =
  17809. newTailOffset < oldTailOffset
  17810. ? listNodeFor(list, newCapacity - 1)
  17811. : newTailOffset > oldTailOffset
  17812. ? new VNode([], owner)
  17813. : oldTail;
  17814. // Merge Tail into tree.
  17815. if (
  17816. oldTail &&
  17817. newTailOffset > oldTailOffset &&
  17818. newOrigin < oldCapacity &&
  17819. oldTail.array.length
  17820. ) {
  17821. newRoot = editableVNode(newRoot, owner);
  17822. var node = newRoot;
  17823. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  17824. var idx = (oldTailOffset >>> level) & MASK;
  17825. node = node.array[idx] = editableVNode(node.array[idx], owner);
  17826. }
  17827. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  17828. }
  17829. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  17830. if (newCapacity < oldCapacity) {
  17831. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  17832. }
  17833. // If the new origin is within the tail, then we do not need a root.
  17834. if (newOrigin >= newTailOffset) {
  17835. newOrigin -= newTailOffset;
  17836. newCapacity -= newTailOffset;
  17837. newLevel = SHIFT;
  17838. newRoot = null;
  17839. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  17840. // Otherwise, if the root has been trimmed, garbage collect.
  17841. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  17842. offsetShift = 0;
  17843. // Identify the new top root node of the subtree of the old root.
  17844. while (newRoot) {
  17845. var beginIndex = (newOrigin >>> newLevel) & MASK;
  17846. if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
  17847. break;
  17848. }
  17849. if (beginIndex) {
  17850. offsetShift += (1 << newLevel) * beginIndex;
  17851. }
  17852. newLevel -= SHIFT;
  17853. newRoot = newRoot.array[beginIndex];
  17854. }
  17855. // Trim the new sides of the new root.
  17856. if (newRoot && newOrigin > oldOrigin) {
  17857. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  17858. }
  17859. if (newRoot && newTailOffset < oldTailOffset) {
  17860. newRoot = newRoot.removeAfter(
  17861. owner,
  17862. newLevel,
  17863. newTailOffset - offsetShift
  17864. );
  17865. }
  17866. if (offsetShift) {
  17867. newOrigin -= offsetShift;
  17868. newCapacity -= offsetShift;
  17869. }
  17870. }
  17871. if (list.__ownerID) {
  17872. list.size = newCapacity - newOrigin;
  17873. list._origin = newOrigin;
  17874. list._capacity = newCapacity;
  17875. list._level = newLevel;
  17876. list._root = newRoot;
  17877. list._tail = newTail;
  17878. list.__hash = undefined;
  17879. list.__altered = true;
  17880. return list;
  17881. }
  17882. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  17883. }
  17884. function getTailOffset(size) {
  17885. return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
  17886. }
  17887. var OrderedMap = /*@__PURE__*/(function (Map$$1) {
  17888. function OrderedMap(value) {
  17889. return value === null || value === undefined
  17890. ? emptyOrderedMap()
  17891. : isOrderedMap(value)
  17892. ? value
  17893. : emptyOrderedMap().withMutations(function (map) {
  17894. var iter = KeyedCollection(value);
  17895. assertNotInfinite(iter.size);
  17896. iter.forEach(function (v, k) { return map.set(k, v); });
  17897. });
  17898. }
  17899. if ( Map$$1 ) OrderedMap.__proto__ = Map$$1;
  17900. OrderedMap.prototype = Object.create( Map$$1 && Map$$1.prototype );
  17901. OrderedMap.prototype.constructor = OrderedMap;
  17902. OrderedMap.of = function of (/*...values*/) {
  17903. return this(arguments);
  17904. };
  17905. OrderedMap.prototype.toString = function toString () {
  17906. return this.__toString('OrderedMap {', '}');
  17907. };
  17908. // @pragma Access
  17909. OrderedMap.prototype.get = function get (k, notSetValue) {
  17910. var index = this._map.get(k);
  17911. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  17912. };
  17913. // @pragma Modification
  17914. OrderedMap.prototype.clear = function clear () {
  17915. if (this.size === 0) {
  17916. return this;
  17917. }
  17918. if (this.__ownerID) {
  17919. this.size = 0;
  17920. this._map.clear();
  17921. this._list.clear();
  17922. return this;
  17923. }
  17924. return emptyOrderedMap();
  17925. };
  17926. OrderedMap.prototype.set = function set (k, v) {
  17927. return updateOrderedMap(this, k, v);
  17928. };
  17929. OrderedMap.prototype.remove = function remove (k) {
  17930. return updateOrderedMap(this, k, NOT_SET);
  17931. };
  17932. OrderedMap.prototype.wasAltered = function wasAltered () {
  17933. return this._map.wasAltered() || this._list.wasAltered();
  17934. };
  17935. OrderedMap.prototype.__iterate = function __iterate (fn, reverse) {
  17936. var this$1 = this;
  17937. return this._list.__iterate(
  17938. function (entry) { return entry && fn(entry[1], entry[0], this$1); },
  17939. reverse
  17940. );
  17941. };
  17942. OrderedMap.prototype.__iterator = function __iterator (type, reverse) {
  17943. return this._list.fromEntrySeq().__iterator(type, reverse);
  17944. };
  17945. OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  17946. if (ownerID === this.__ownerID) {
  17947. return this;
  17948. }
  17949. var newMap = this._map.__ensureOwner(ownerID);
  17950. var newList = this._list.__ensureOwner(ownerID);
  17951. if (!ownerID) {
  17952. if (this.size === 0) {
  17953. return emptyOrderedMap();
  17954. }
  17955. this.__ownerID = ownerID;
  17956. this._map = newMap;
  17957. this._list = newList;
  17958. return this;
  17959. }
  17960. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  17961. };
  17962. return OrderedMap;
  17963. }(Map));
  17964. OrderedMap.isOrderedMap = isOrderedMap;
  17965. OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
  17966. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  17967. function makeOrderedMap(map, list, ownerID, hash) {
  17968. var omap = Object.create(OrderedMap.prototype);
  17969. omap.size = map ? map.size : 0;
  17970. omap._map = map;
  17971. omap._list = list;
  17972. omap.__ownerID = ownerID;
  17973. omap.__hash = hash;
  17974. return omap;
  17975. }
  17976. var EMPTY_ORDERED_MAP;
  17977. function emptyOrderedMap() {
  17978. return (
  17979. EMPTY_ORDERED_MAP ||
  17980. (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
  17981. );
  17982. }
  17983. function updateOrderedMap(omap, k, v) {
  17984. var map = omap._map;
  17985. var list = omap._list;
  17986. var i = map.get(k);
  17987. var has = i !== undefined;
  17988. var newMap;
  17989. var newList;
  17990. if (v === NOT_SET) {
  17991. // removed
  17992. if (!has) {
  17993. return omap;
  17994. }
  17995. if (list.size >= SIZE && list.size >= map.size * 2) {
  17996. newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; });
  17997. newMap = newList
  17998. .toKeyedSeq()
  17999. .map(function (entry) { return entry[0]; })
  18000. .flip()
  18001. .toMap();
  18002. if (omap.__ownerID) {
  18003. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  18004. }
  18005. } else {
  18006. newMap = map.remove(k);
  18007. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  18008. }
  18009. } else if (has) {
  18010. if (v === list.get(i)[1]) {
  18011. return omap;
  18012. }
  18013. newMap = map;
  18014. newList = list.set(i, [k, v]);
  18015. } else {
  18016. newMap = map.set(k, list.size);
  18017. newList = list.set(list.size, [k, v]);
  18018. }
  18019. if (omap.__ownerID) {
  18020. omap.size = newMap.size;
  18021. omap._map = newMap;
  18022. omap._list = newList;
  18023. omap.__hash = undefined;
  18024. return omap;
  18025. }
  18026. return makeOrderedMap(newMap, newList);
  18027. }
  18028. var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@';
  18029. function isStack(maybeStack) {
  18030. return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]);
  18031. }
  18032. var Stack = /*@__PURE__*/(function (IndexedCollection$$1) {
  18033. function Stack(value) {
  18034. return value === null || value === undefined
  18035. ? emptyStack()
  18036. : isStack(value)
  18037. ? value
  18038. : emptyStack().pushAll(value);
  18039. }
  18040. if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1;
  18041. Stack.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
  18042. Stack.prototype.constructor = Stack;
  18043. Stack.of = function of (/*...values*/) {
  18044. return this(arguments);
  18045. };
  18046. Stack.prototype.toString = function toString () {
  18047. return this.__toString('Stack [', ']');
  18048. };
  18049. // @pragma Access
  18050. Stack.prototype.get = function get (index, notSetValue) {
  18051. var head = this._head;
  18052. index = wrapIndex(this, index);
  18053. while (head && index--) {
  18054. head = head.next;
  18055. }
  18056. return head ? head.value : notSetValue;
  18057. };
  18058. Stack.prototype.peek = function peek () {
  18059. return this._head && this._head.value;
  18060. };
  18061. // @pragma Modification
  18062. Stack.prototype.push = function push (/*...values*/) {
  18063. var arguments$1 = arguments;
  18064. if (arguments.length === 0) {
  18065. return this;
  18066. }
  18067. var newSize = this.size + arguments.length;
  18068. var head = this._head;
  18069. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  18070. head = {
  18071. value: arguments$1[ii],
  18072. next: head,
  18073. };
  18074. }
  18075. if (this.__ownerID) {
  18076. this.size = newSize;
  18077. this._head = head;
  18078. this.__hash = undefined;
  18079. this.__altered = true;
  18080. return this;
  18081. }
  18082. return makeStack(newSize, head);
  18083. };
  18084. Stack.prototype.pushAll = function pushAll (iter) {
  18085. iter = IndexedCollection$$1(iter);
  18086. if (iter.size === 0) {
  18087. return this;
  18088. }
  18089. if (this.size === 0 && isStack(iter)) {
  18090. return iter;
  18091. }
  18092. assertNotInfinite(iter.size);
  18093. var newSize = this.size;
  18094. var head = this._head;
  18095. iter.__iterate(function (value) {
  18096. newSize++;
  18097. head = {
  18098. value: value,
  18099. next: head,
  18100. };
  18101. }, /* reverse */ true);
  18102. if (this.__ownerID) {
  18103. this.size = newSize;
  18104. this._head = head;
  18105. this.__hash = undefined;
  18106. this.__altered = true;
  18107. return this;
  18108. }
  18109. return makeStack(newSize, head);
  18110. };
  18111. Stack.prototype.pop = function pop () {
  18112. return this.slice(1);
  18113. };
  18114. Stack.prototype.clear = function clear () {
  18115. if (this.size === 0) {
  18116. return this;
  18117. }
  18118. if (this.__ownerID) {
  18119. this.size = 0;
  18120. this._head = undefined;
  18121. this.__hash = undefined;
  18122. this.__altered = true;
  18123. return this;
  18124. }
  18125. return emptyStack();
  18126. };
  18127. Stack.prototype.slice = function slice (begin, end) {
  18128. if (wholeSlice(begin, end, this.size)) {
  18129. return this;
  18130. }
  18131. var resolvedBegin = resolveBegin(begin, this.size);
  18132. var resolvedEnd = resolveEnd(end, this.size);
  18133. if (resolvedEnd !== this.size) {
  18134. // super.slice(begin, end);
  18135. return IndexedCollection$$1.prototype.slice.call(this, begin, end);
  18136. }
  18137. var newSize = this.size - resolvedBegin;
  18138. var head = this._head;
  18139. while (resolvedBegin--) {
  18140. head = head.next;
  18141. }
  18142. if (this.__ownerID) {
  18143. this.size = newSize;
  18144. this._head = head;
  18145. this.__hash = undefined;
  18146. this.__altered = true;
  18147. return this;
  18148. }
  18149. return makeStack(newSize, head);
  18150. };
  18151. // @pragma Mutability
  18152. Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  18153. if (ownerID === this.__ownerID) {
  18154. return this;
  18155. }
  18156. if (!ownerID) {
  18157. if (this.size === 0) {
  18158. return emptyStack();
  18159. }
  18160. this.__ownerID = ownerID;
  18161. this.__altered = false;
  18162. return this;
  18163. }
  18164. return makeStack(this.size, this._head, ownerID, this.__hash);
  18165. };
  18166. // @pragma Iteration
  18167. Stack.prototype.__iterate = function __iterate (fn, reverse) {
  18168. var this$1 = this;
  18169. if (reverse) {
  18170. return new ArraySeq(this.toArray()).__iterate(
  18171. function (v, k) { return fn(v, k, this$1); },
  18172. reverse
  18173. );
  18174. }
  18175. var iterations = 0;
  18176. var node = this._head;
  18177. while (node) {
  18178. if (fn(node.value, iterations++, this) === false) {
  18179. break;
  18180. }
  18181. node = node.next;
  18182. }
  18183. return iterations;
  18184. };
  18185. Stack.prototype.__iterator = function __iterator (type, reverse) {
  18186. if (reverse) {
  18187. return new ArraySeq(this.toArray()).__iterator(type, reverse);
  18188. }
  18189. var iterations = 0;
  18190. var node = this._head;
  18191. return new Iterator(function () {
  18192. if (node) {
  18193. var value = node.value;
  18194. node = node.next;
  18195. return iteratorValue(type, iterations++, value);
  18196. }
  18197. return iteratorDone();
  18198. });
  18199. };
  18200. return Stack;
  18201. }(IndexedCollection));
  18202. Stack.isStack = isStack;
  18203. var StackPrototype = Stack.prototype;
  18204. StackPrototype[IS_STACK_SYMBOL] = true;
  18205. StackPrototype.shift = StackPrototype.pop;
  18206. StackPrototype.unshift = StackPrototype.push;
  18207. StackPrototype.unshiftAll = StackPrototype.pushAll;
  18208. StackPrototype.withMutations = withMutations;
  18209. StackPrototype.wasAltered = wasAltered;
  18210. StackPrototype.asImmutable = asImmutable;
  18211. StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
  18212. StackPrototype['@@transducer/step'] = function(result, arr) {
  18213. return result.unshift(arr);
  18214. };
  18215. StackPrototype['@@transducer/result'] = function(obj) {
  18216. return obj.asImmutable();
  18217. };
  18218. function makeStack(size, head, ownerID, hash) {
  18219. var map = Object.create(StackPrototype);
  18220. map.size = size;
  18221. map._head = head;
  18222. map.__ownerID = ownerID;
  18223. map.__hash = hash;
  18224. map.__altered = false;
  18225. return map;
  18226. }
  18227. var EMPTY_STACK;
  18228. function emptyStack() {
  18229. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  18230. }
  18231. var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@';
  18232. function isSet(maybeSet) {
  18233. return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]);
  18234. }
  18235. function isOrderedSet(maybeOrderedSet) {
  18236. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  18237. }
  18238. function deepEqual(a, b) {
  18239. if (a === b) {
  18240. return true;
  18241. }
  18242. if (
  18243. !isCollection(b) ||
  18244. (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
  18245. (a.__hash !== undefined &&
  18246. b.__hash !== undefined &&
  18247. a.__hash !== b.__hash) ||
  18248. isKeyed(a) !== isKeyed(b) ||
  18249. isIndexed(a) !== isIndexed(b) ||
  18250. isOrdered(a) !== isOrdered(b)
  18251. ) {
  18252. return false;
  18253. }
  18254. if (a.size === 0 && b.size === 0) {
  18255. return true;
  18256. }
  18257. var notAssociative = !isAssociative(a);
  18258. if (isOrdered(a)) {
  18259. var entries = a.entries();
  18260. return (
  18261. b.every(function (v, k) {
  18262. var entry = entries.next().value;
  18263. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  18264. }) && entries.next().done
  18265. );
  18266. }
  18267. var flipped = false;
  18268. if (a.size === undefined) {
  18269. if (b.size === undefined) {
  18270. if (typeof a.cacheResult === 'function') {
  18271. a.cacheResult();
  18272. }
  18273. } else {
  18274. flipped = true;
  18275. var _ = a;
  18276. a = b;
  18277. b = _;
  18278. }
  18279. }
  18280. var allEqual = true;
  18281. var bSize = b.__iterate(function (v, k) {
  18282. if (
  18283. notAssociative
  18284. ? !a.has(v)
  18285. : flipped
  18286. ? !is(v, a.get(k, NOT_SET))
  18287. : !is(a.get(k, NOT_SET), v)
  18288. ) {
  18289. allEqual = false;
  18290. return false;
  18291. }
  18292. });
  18293. return allEqual && a.size === bSize;
  18294. }
  18295. /**
  18296. * Contributes additional methods to a constructor
  18297. */
  18298. function mixin(ctor, methods) {
  18299. var keyCopier = function (key) {
  18300. ctor.prototype[key] = methods[key];
  18301. };
  18302. Object.keys(methods).forEach(keyCopier);
  18303. Object.getOwnPropertySymbols &&
  18304. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  18305. return ctor;
  18306. }
  18307. function toJS(value) {
  18308. if (!value || typeof value !== 'object') {
  18309. return value;
  18310. }
  18311. if (!isCollection(value)) {
  18312. if (!isDataStructure(value)) {
  18313. return value;
  18314. }
  18315. value = Seq(value);
  18316. }
  18317. if (isKeyed(value)) {
  18318. var result$1 = {};
  18319. value.__iterate(function (v, k) {
  18320. result$1[k] = toJS(v);
  18321. });
  18322. return result$1;
  18323. }
  18324. var result = [];
  18325. value.__iterate(function (v) {
  18326. result.push(toJS(v));
  18327. });
  18328. return result;
  18329. }
  18330. var Set = /*@__PURE__*/(function (SetCollection$$1) {
  18331. function Set(value) {
  18332. return value === null || value === undefined
  18333. ? emptySet()
  18334. : isSet(value) && !isOrdered(value)
  18335. ? value
  18336. : emptySet().withMutations(function (set) {
  18337. var iter = SetCollection$$1(value);
  18338. assertNotInfinite(iter.size);
  18339. iter.forEach(function (v) { return set.add(v); });
  18340. });
  18341. }
  18342. if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1;
  18343. Set.prototype = Object.create( SetCollection$$1 && SetCollection$$1.prototype );
  18344. Set.prototype.constructor = Set;
  18345. Set.of = function of (/*...values*/) {
  18346. return this(arguments);
  18347. };
  18348. Set.fromKeys = function fromKeys (value) {
  18349. return this(KeyedCollection(value).keySeq());
  18350. };
  18351. Set.intersect = function intersect (sets) {
  18352. sets = Collection(sets).toArray();
  18353. return sets.length
  18354. ? SetPrototype.intersect.apply(Set(sets.pop()), sets)
  18355. : emptySet();
  18356. };
  18357. Set.union = function union (sets) {
  18358. sets = Collection(sets).toArray();
  18359. return sets.length
  18360. ? SetPrototype.union.apply(Set(sets.pop()), sets)
  18361. : emptySet();
  18362. };
  18363. Set.prototype.toString = function toString () {
  18364. return this.__toString('Set {', '}');
  18365. };
  18366. // @pragma Access
  18367. Set.prototype.has = function has (value) {
  18368. return this._map.has(value);
  18369. };
  18370. // @pragma Modification
  18371. Set.prototype.add = function add (value) {
  18372. return updateSet(this, this._map.set(value, value));
  18373. };
  18374. Set.prototype.remove = function remove (value) {
  18375. return updateSet(this, this._map.remove(value));
  18376. };
  18377. Set.prototype.clear = function clear () {
  18378. return updateSet(this, this._map.clear());
  18379. };
  18380. // @pragma Composition
  18381. Set.prototype.map = function map (mapper, context) {
  18382. var this$1 = this;
  18383. var removes = [];
  18384. var adds = [];
  18385. this.forEach(function (value) {
  18386. var mapped = mapper.call(context, value, value, this$1);
  18387. if (mapped !== value) {
  18388. removes.push(value);
  18389. adds.push(mapped);
  18390. }
  18391. });
  18392. return this.withMutations(function (set) {
  18393. removes.forEach(function (value) { return set.remove(value); });
  18394. adds.forEach(function (value) { return set.add(value); });
  18395. });
  18396. };
  18397. Set.prototype.union = function union () {
  18398. var iters = [], len = arguments.length;
  18399. while ( len-- ) iters[ len ] = arguments[ len ];
  18400. iters = iters.filter(function (x) { return x.size !== 0; });
  18401. if (iters.length === 0) {
  18402. return this;
  18403. }
  18404. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  18405. return this.constructor(iters[0]);
  18406. }
  18407. return this.withMutations(function (set) {
  18408. for (var ii = 0; ii < iters.length; ii++) {
  18409. SetCollection$$1(iters[ii]).forEach(function (value) { return set.add(value); });
  18410. }
  18411. });
  18412. };
  18413. Set.prototype.intersect = function intersect () {
  18414. var iters = [], len = arguments.length;
  18415. while ( len-- ) iters[ len ] = arguments[ len ];
  18416. if (iters.length === 0) {
  18417. return this;
  18418. }
  18419. iters = iters.map(function (iter) { return SetCollection$$1(iter); });
  18420. var toRemove = [];
  18421. this.forEach(function (value) {
  18422. if (!iters.every(function (iter) { return iter.includes(value); })) {
  18423. toRemove.push(value);
  18424. }
  18425. });
  18426. return this.withMutations(function (set) {
  18427. toRemove.forEach(function (value) {
  18428. set.remove(value);
  18429. });
  18430. });
  18431. };
  18432. Set.prototype.subtract = function subtract () {
  18433. var iters = [], len = arguments.length;
  18434. while ( len-- ) iters[ len ] = arguments[ len ];
  18435. if (iters.length === 0) {
  18436. return this;
  18437. }
  18438. iters = iters.map(function (iter) { return SetCollection$$1(iter); });
  18439. var toRemove = [];
  18440. this.forEach(function (value) {
  18441. if (iters.some(function (iter) { return iter.includes(value); })) {
  18442. toRemove.push(value);
  18443. }
  18444. });
  18445. return this.withMutations(function (set) {
  18446. toRemove.forEach(function (value) {
  18447. set.remove(value);
  18448. });
  18449. });
  18450. };
  18451. Set.prototype.sort = function sort (comparator) {
  18452. // Late binding
  18453. return OrderedSet(sortFactory(this, comparator));
  18454. };
  18455. Set.prototype.sortBy = function sortBy (mapper, comparator) {
  18456. // Late binding
  18457. return OrderedSet(sortFactory(this, comparator, mapper));
  18458. };
  18459. Set.prototype.wasAltered = function wasAltered () {
  18460. return this._map.wasAltered();
  18461. };
  18462. Set.prototype.__iterate = function __iterate (fn, reverse) {
  18463. var this$1 = this;
  18464. return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse);
  18465. };
  18466. Set.prototype.__iterator = function __iterator (type, reverse) {
  18467. return this._map.__iterator(type, reverse);
  18468. };
  18469. Set.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  18470. if (ownerID === this.__ownerID) {
  18471. return this;
  18472. }
  18473. var newMap = this._map.__ensureOwner(ownerID);
  18474. if (!ownerID) {
  18475. if (this.size === 0) {
  18476. return this.__empty();
  18477. }
  18478. this.__ownerID = ownerID;
  18479. this._map = newMap;
  18480. return this;
  18481. }
  18482. return this.__make(newMap, ownerID);
  18483. };
  18484. return Set;
  18485. }(SetCollection));
  18486. Set.isSet = isSet;
  18487. var SetPrototype = Set.prototype;
  18488. SetPrototype[IS_SET_SYMBOL] = true;
  18489. SetPrototype[DELETE] = SetPrototype.remove;
  18490. SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
  18491. SetPrototype.withMutations = withMutations;
  18492. SetPrototype.asImmutable = asImmutable;
  18493. SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable;
  18494. SetPrototype['@@transducer/step'] = function(result, arr) {
  18495. return result.add(arr);
  18496. };
  18497. SetPrototype['@@transducer/result'] = function(obj) {
  18498. return obj.asImmutable();
  18499. };
  18500. SetPrototype.__empty = emptySet;
  18501. SetPrototype.__make = makeSet;
  18502. function updateSet(set, newMap) {
  18503. if (set.__ownerID) {
  18504. set.size = newMap.size;
  18505. set._map = newMap;
  18506. return set;
  18507. }
  18508. return newMap === set._map
  18509. ? set
  18510. : newMap.size === 0
  18511. ? set.__empty()
  18512. : set.__make(newMap);
  18513. }
  18514. function makeSet(map, ownerID) {
  18515. var set = Object.create(SetPrototype);
  18516. set.size = map ? map.size : 0;
  18517. set._map = map;
  18518. set.__ownerID = ownerID;
  18519. return set;
  18520. }
  18521. var EMPTY_SET;
  18522. function emptySet() {
  18523. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  18524. }
  18525. /**
  18526. * Returns a lazy seq of nums from start (inclusive) to end
  18527. * (exclusive), by step, where start defaults to 0, step to 1, and end to
  18528. * infinity. When start is equal to end, returns empty list.
  18529. */
  18530. var Range = /*@__PURE__*/(function (IndexedSeq$$1) {
  18531. function Range(start, end, step) {
  18532. if (!(this instanceof Range)) {
  18533. return new Range(start, end, step);
  18534. }
  18535. invariant(step !== 0, 'Cannot step a Range by 0');
  18536. start = start || 0;
  18537. if (end === undefined) {
  18538. end = Infinity;
  18539. }
  18540. step = step === undefined ? 1 : Math.abs(step);
  18541. if (end < start) {
  18542. step = -step;
  18543. }
  18544. this._start = start;
  18545. this._end = end;
  18546. this._step = step;
  18547. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  18548. if (this.size === 0) {
  18549. if (EMPTY_RANGE) {
  18550. return EMPTY_RANGE;
  18551. }
  18552. EMPTY_RANGE = this;
  18553. }
  18554. }
  18555. if ( IndexedSeq$$1 ) Range.__proto__ = IndexedSeq$$1;
  18556. Range.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  18557. Range.prototype.constructor = Range;
  18558. Range.prototype.toString = function toString () {
  18559. if (this.size === 0) {
  18560. return 'Range []';
  18561. }
  18562. return (
  18563. 'Range [ ' +
  18564. this._start +
  18565. '...' +
  18566. this._end +
  18567. (this._step !== 1 ? ' by ' + this._step : '') +
  18568. ' ]'
  18569. );
  18570. };
  18571. Range.prototype.get = function get (index, notSetValue) {
  18572. return this.has(index)
  18573. ? this._start + wrapIndex(this, index) * this._step
  18574. : notSetValue;
  18575. };
  18576. Range.prototype.includes = function includes (searchValue) {
  18577. var possibleIndex = (searchValue - this._start) / this._step;
  18578. return (
  18579. possibleIndex >= 0 &&
  18580. possibleIndex < this.size &&
  18581. possibleIndex === Math.floor(possibleIndex)
  18582. );
  18583. };
  18584. Range.prototype.slice = function slice (begin, end) {
  18585. if (wholeSlice(begin, end, this.size)) {
  18586. return this;
  18587. }
  18588. begin = resolveBegin(begin, this.size);
  18589. end = resolveEnd(end, this.size);
  18590. if (end <= begin) {
  18591. return new Range(0, 0);
  18592. }
  18593. return new Range(
  18594. this.get(begin, this._end),
  18595. this.get(end, this._end),
  18596. this._step
  18597. );
  18598. };
  18599. Range.prototype.indexOf = function indexOf (searchValue) {
  18600. var offsetValue = searchValue - this._start;
  18601. if (offsetValue % this._step === 0) {
  18602. var index = offsetValue / this._step;
  18603. if (index >= 0 && index < this.size) {
  18604. return index;
  18605. }
  18606. }
  18607. return -1;
  18608. };
  18609. Range.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  18610. return this.indexOf(searchValue);
  18611. };
  18612. Range.prototype.__iterate = function __iterate (fn, reverse) {
  18613. var size = this.size;
  18614. var step = this._step;
  18615. var value = reverse ? this._start + (size - 1) * step : this._start;
  18616. var i = 0;
  18617. while (i !== size) {
  18618. if (fn(value, reverse ? size - ++i : i++, this) === false) {
  18619. break;
  18620. }
  18621. value += reverse ? -step : step;
  18622. }
  18623. return i;
  18624. };
  18625. Range.prototype.__iterator = function __iterator (type, reverse) {
  18626. var size = this.size;
  18627. var step = this._step;
  18628. var value = reverse ? this._start + (size - 1) * step : this._start;
  18629. var i = 0;
  18630. return new Iterator(function () {
  18631. if (i === size) {
  18632. return iteratorDone();
  18633. }
  18634. var v = value;
  18635. value += reverse ? -step : step;
  18636. return iteratorValue(type, reverse ? size - ++i : i++, v);
  18637. });
  18638. };
  18639. Range.prototype.equals = function equals (other) {
  18640. return other instanceof Range
  18641. ? this._start === other._start &&
  18642. this._end === other._end &&
  18643. this._step === other._step
  18644. : deepEqual(this, other);
  18645. };
  18646. return Range;
  18647. }(IndexedSeq));
  18648. var EMPTY_RANGE;
  18649. function getIn(collection, searchKeyPath, notSetValue) {
  18650. var keyPath = coerceKeyPath(searchKeyPath);
  18651. var i = 0;
  18652. while (i !== keyPath.length) {
  18653. collection = get(collection, keyPath[i++], NOT_SET);
  18654. if (collection === NOT_SET) {
  18655. return notSetValue;
  18656. }
  18657. }
  18658. return collection;
  18659. }
  18660. function getIn$1(searchKeyPath, notSetValue) {
  18661. return getIn(this, searchKeyPath, notSetValue);
  18662. }
  18663. function hasIn(collection, keyPath) {
  18664. return getIn(collection, keyPath, NOT_SET) !== NOT_SET;
  18665. }
  18666. function hasIn$1(searchKeyPath) {
  18667. return hasIn(this, searchKeyPath);
  18668. }
  18669. function toObject() {
  18670. assertNotInfinite(this.size);
  18671. var object = {};
  18672. this.__iterate(function (v, k) {
  18673. object[k] = v;
  18674. });
  18675. return object;
  18676. }
  18677. // Note: all of these methods are deprecated.
  18678. Collection.isIterable = isCollection;
  18679. Collection.isKeyed = isKeyed;
  18680. Collection.isIndexed = isIndexed;
  18681. Collection.isAssociative = isAssociative;
  18682. Collection.isOrdered = isOrdered;
  18683. Collection.Iterator = Iterator;
  18684. mixin(Collection, {
  18685. // ### Conversion to other types
  18686. toArray: function toArray() {
  18687. assertNotInfinite(this.size);
  18688. var array = new Array(this.size || 0);
  18689. var useTuples = isKeyed(this);
  18690. var i = 0;
  18691. this.__iterate(function (v, k) {
  18692. // Keyed collections produce an array of tuples.
  18693. array[i++] = useTuples ? [k, v] : v;
  18694. });
  18695. return array;
  18696. },
  18697. toIndexedSeq: function toIndexedSeq() {
  18698. return new ToIndexedSequence(this);
  18699. },
  18700. toJS: function toJS$1() {
  18701. return toJS(this);
  18702. },
  18703. toKeyedSeq: function toKeyedSeq() {
  18704. return new ToKeyedSequence(this, true);
  18705. },
  18706. toMap: function toMap() {
  18707. // Use Late Binding here to solve the circular dependency.
  18708. return Map(this.toKeyedSeq());
  18709. },
  18710. toObject: toObject,
  18711. toOrderedMap: function toOrderedMap() {
  18712. // Use Late Binding here to solve the circular dependency.
  18713. return OrderedMap(this.toKeyedSeq());
  18714. },
  18715. toOrderedSet: function toOrderedSet() {
  18716. // Use Late Binding here to solve the circular dependency.
  18717. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  18718. },
  18719. toSet: function toSet() {
  18720. // Use Late Binding here to solve the circular dependency.
  18721. return Set(isKeyed(this) ? this.valueSeq() : this);
  18722. },
  18723. toSetSeq: function toSetSeq() {
  18724. return new ToSetSequence(this);
  18725. },
  18726. toSeq: function toSeq() {
  18727. return isIndexed(this)
  18728. ? this.toIndexedSeq()
  18729. : isKeyed(this)
  18730. ? this.toKeyedSeq()
  18731. : this.toSetSeq();
  18732. },
  18733. toStack: function toStack() {
  18734. // Use Late Binding here to solve the circular dependency.
  18735. return Stack(isKeyed(this) ? this.valueSeq() : this);
  18736. },
  18737. toList: function toList() {
  18738. // Use Late Binding here to solve the circular dependency.
  18739. return List(isKeyed(this) ? this.valueSeq() : this);
  18740. },
  18741. // ### Common JavaScript methods and properties
  18742. toString: function toString() {
  18743. return '[Collection]';
  18744. },
  18745. __toString: function __toString(head, tail) {
  18746. if (this.size === 0) {
  18747. return head + tail;
  18748. }
  18749. return (
  18750. head +
  18751. ' ' +
  18752. this.toSeq()
  18753. .map(this.__toStringMapper)
  18754. .join(', ') +
  18755. ' ' +
  18756. tail
  18757. );
  18758. },
  18759. // ### ES6 Collection methods (ES6 Array and Map)
  18760. concat: function concat() {
  18761. var values = [], len = arguments.length;
  18762. while ( len-- ) values[ len ] = arguments[ len ];
  18763. return reify(this, concatFactory(this, values));
  18764. },
  18765. includes: function includes(searchValue) {
  18766. return this.some(function (value) { return is(value, searchValue); });
  18767. },
  18768. entries: function entries() {
  18769. return this.__iterator(ITERATE_ENTRIES);
  18770. },
  18771. every: function every(predicate, context) {
  18772. assertNotInfinite(this.size);
  18773. var returnValue = true;
  18774. this.__iterate(function (v, k, c) {
  18775. if (!predicate.call(context, v, k, c)) {
  18776. returnValue = false;
  18777. return false;
  18778. }
  18779. });
  18780. return returnValue;
  18781. },
  18782. filter: function filter(predicate, context) {
  18783. return reify(this, filterFactory(this, predicate, context, true));
  18784. },
  18785. find: function find(predicate, context, notSetValue) {
  18786. var entry = this.findEntry(predicate, context);
  18787. return entry ? entry[1] : notSetValue;
  18788. },
  18789. forEach: function forEach(sideEffect, context) {
  18790. assertNotInfinite(this.size);
  18791. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  18792. },
  18793. join: function join(separator) {
  18794. assertNotInfinite(this.size);
  18795. separator = separator !== undefined ? '' + separator : ',';
  18796. var joined = '';
  18797. var isFirst = true;
  18798. this.__iterate(function (v) {
  18799. isFirst ? (isFirst = false) : (joined += separator);
  18800. joined += v !== null && v !== undefined ? v.toString() : '';
  18801. });
  18802. return joined;
  18803. },
  18804. keys: function keys() {
  18805. return this.__iterator(ITERATE_KEYS);
  18806. },
  18807. map: function map(mapper, context) {
  18808. return reify(this, mapFactory(this, mapper, context));
  18809. },
  18810. reduce: function reduce$1(reducer, initialReduction, context) {
  18811. return reduce(
  18812. this,
  18813. reducer,
  18814. initialReduction,
  18815. context,
  18816. arguments.length < 2,
  18817. false
  18818. );
  18819. },
  18820. reduceRight: function reduceRight(reducer, initialReduction, context) {
  18821. return reduce(
  18822. this,
  18823. reducer,
  18824. initialReduction,
  18825. context,
  18826. arguments.length < 2,
  18827. true
  18828. );
  18829. },
  18830. reverse: function reverse() {
  18831. return reify(this, reverseFactory(this, true));
  18832. },
  18833. slice: function slice(begin, end) {
  18834. return reify(this, sliceFactory(this, begin, end, true));
  18835. },
  18836. some: function some(predicate, context) {
  18837. return !this.every(not(predicate), context);
  18838. },
  18839. sort: function sort(comparator) {
  18840. return reify(this, sortFactory(this, comparator));
  18841. },
  18842. values: function values() {
  18843. return this.__iterator(ITERATE_VALUES);
  18844. },
  18845. // ### More sequential methods
  18846. butLast: function butLast() {
  18847. return this.slice(0, -1);
  18848. },
  18849. isEmpty: function isEmpty() {
  18850. return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; });
  18851. },
  18852. count: function count(predicate, context) {
  18853. return ensureSize(
  18854. predicate ? this.toSeq().filter(predicate, context) : this
  18855. );
  18856. },
  18857. countBy: function countBy(grouper, context) {
  18858. return countByFactory(this, grouper, context);
  18859. },
  18860. equals: function equals(other) {
  18861. return deepEqual(this, other);
  18862. },
  18863. entrySeq: function entrySeq() {
  18864. var collection = this;
  18865. if (collection._cache) {
  18866. // We cache as an entries array, so we can just return the cache!
  18867. return new ArraySeq(collection._cache);
  18868. }
  18869. var entriesSequence = collection
  18870. .toSeq()
  18871. .map(entryMapper)
  18872. .toIndexedSeq();
  18873. entriesSequence.fromEntrySeq = function () { return collection.toSeq(); };
  18874. return entriesSequence;
  18875. },
  18876. filterNot: function filterNot(predicate, context) {
  18877. return this.filter(not(predicate), context);
  18878. },
  18879. findEntry: function findEntry(predicate, context, notSetValue) {
  18880. var found = notSetValue;
  18881. this.__iterate(function (v, k, c) {
  18882. if (predicate.call(context, v, k, c)) {
  18883. found = [k, v];
  18884. return false;
  18885. }
  18886. });
  18887. return found;
  18888. },
  18889. findKey: function findKey(predicate, context) {
  18890. var entry = this.findEntry(predicate, context);
  18891. return entry && entry[0];
  18892. },
  18893. findLast: function findLast(predicate, context, notSetValue) {
  18894. return this.toKeyedSeq()
  18895. .reverse()
  18896. .find(predicate, context, notSetValue);
  18897. },
  18898. findLastEntry: function findLastEntry(predicate, context, notSetValue) {
  18899. return this.toKeyedSeq()
  18900. .reverse()
  18901. .findEntry(predicate, context, notSetValue);
  18902. },
  18903. findLastKey: function findLastKey(predicate, context) {
  18904. return this.toKeyedSeq()
  18905. .reverse()
  18906. .findKey(predicate, context);
  18907. },
  18908. first: function first(notSetValue) {
  18909. return this.find(returnTrue, null, notSetValue);
  18910. },
  18911. flatMap: function flatMap(mapper, context) {
  18912. return reify(this, flatMapFactory(this, mapper, context));
  18913. },
  18914. flatten: function flatten(depth) {
  18915. return reify(this, flattenFactory(this, depth, true));
  18916. },
  18917. fromEntrySeq: function fromEntrySeq() {
  18918. return new FromEntriesSequence(this);
  18919. },
  18920. get: function get(searchKey, notSetValue) {
  18921. return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue);
  18922. },
  18923. getIn: getIn$1,
  18924. groupBy: function groupBy(grouper, context) {
  18925. return groupByFactory(this, grouper, context);
  18926. },
  18927. has: function has(searchKey) {
  18928. return this.get(searchKey, NOT_SET) !== NOT_SET;
  18929. },
  18930. hasIn: hasIn$1,
  18931. isSubset: function isSubset(iter) {
  18932. iter = typeof iter.includes === 'function' ? iter : Collection(iter);
  18933. return this.every(function (value) { return iter.includes(value); });
  18934. },
  18935. isSuperset: function isSuperset(iter) {
  18936. iter = typeof iter.isSubset === 'function' ? iter : Collection(iter);
  18937. return iter.isSubset(this);
  18938. },
  18939. keyOf: function keyOf(searchValue) {
  18940. return this.findKey(function (value) { return is(value, searchValue); });
  18941. },
  18942. keySeq: function keySeq() {
  18943. return this.toSeq()
  18944. .map(keyMapper)
  18945. .toIndexedSeq();
  18946. },
  18947. last: function last(notSetValue) {
  18948. return this.toSeq()
  18949. .reverse()
  18950. .first(notSetValue);
  18951. },
  18952. lastKeyOf: function lastKeyOf(searchValue) {
  18953. return this.toKeyedSeq()
  18954. .reverse()
  18955. .keyOf(searchValue);
  18956. },
  18957. max: function max(comparator) {
  18958. return maxFactory(this, comparator);
  18959. },
  18960. maxBy: function maxBy(mapper, comparator) {
  18961. return maxFactory(this, comparator, mapper);
  18962. },
  18963. min: function min(comparator) {
  18964. return maxFactory(
  18965. this,
  18966. comparator ? neg(comparator) : defaultNegComparator
  18967. );
  18968. },
  18969. minBy: function minBy(mapper, comparator) {
  18970. return maxFactory(
  18971. this,
  18972. comparator ? neg(comparator) : defaultNegComparator,
  18973. mapper
  18974. );
  18975. },
  18976. rest: function rest() {
  18977. return this.slice(1);
  18978. },
  18979. skip: function skip(amount) {
  18980. return amount === 0 ? this : this.slice(Math.max(0, amount));
  18981. },
  18982. skipLast: function skipLast(amount) {
  18983. return amount === 0 ? this : this.slice(0, -Math.max(0, amount));
  18984. },
  18985. skipWhile: function skipWhile(predicate, context) {
  18986. return reify(this, skipWhileFactory(this, predicate, context, true));
  18987. },
  18988. skipUntil: function skipUntil(predicate, context) {
  18989. return this.skipWhile(not(predicate), context);
  18990. },
  18991. sortBy: function sortBy(mapper, comparator) {
  18992. return reify(this, sortFactory(this, comparator, mapper));
  18993. },
  18994. take: function take(amount) {
  18995. return this.slice(0, Math.max(0, amount));
  18996. },
  18997. takeLast: function takeLast(amount) {
  18998. return this.slice(-Math.max(0, amount));
  18999. },
  19000. takeWhile: function takeWhile(predicate, context) {
  19001. return reify(this, takeWhileFactory(this, predicate, context));
  19002. },
  19003. takeUntil: function takeUntil(predicate, context) {
  19004. return this.takeWhile(not(predicate), context);
  19005. },
  19006. update: function update(fn) {
  19007. return fn(this);
  19008. },
  19009. valueSeq: function valueSeq() {
  19010. return this.toIndexedSeq();
  19011. },
  19012. // ### Hashable Object
  19013. hashCode: function hashCode() {
  19014. return this.__hash || (this.__hash = hashCollection(this));
  19015. },
  19016. // ### Internal
  19017. // abstract __iterate(fn, reverse)
  19018. // abstract __iterator(type, reverse)
  19019. });
  19020. var CollectionPrototype = Collection.prototype;
  19021. CollectionPrototype[IS_COLLECTION_SYMBOL] = true;
  19022. CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values;
  19023. CollectionPrototype.toJSON = CollectionPrototype.toArray;
  19024. CollectionPrototype.__toStringMapper = quoteString;
  19025. CollectionPrototype.inspect = CollectionPrototype.toSource = function() {
  19026. return this.toString();
  19027. };
  19028. CollectionPrototype.chain = CollectionPrototype.flatMap;
  19029. CollectionPrototype.contains = CollectionPrototype.includes;
  19030. mixin(KeyedCollection, {
  19031. // ### More sequential methods
  19032. flip: function flip() {
  19033. return reify(this, flipFactory(this));
  19034. },
  19035. mapEntries: function mapEntries(mapper, context) {
  19036. var this$1 = this;
  19037. var iterations = 0;
  19038. return reify(
  19039. this,
  19040. this.toSeq()
  19041. .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); })
  19042. .fromEntrySeq()
  19043. );
  19044. },
  19045. mapKeys: function mapKeys(mapper, context) {
  19046. var this$1 = this;
  19047. return reify(
  19048. this,
  19049. this.toSeq()
  19050. .flip()
  19051. .map(function (k, v) { return mapper.call(context, k, v, this$1); })
  19052. .flip()
  19053. );
  19054. },
  19055. });
  19056. var KeyedCollectionPrototype = KeyedCollection.prototype;
  19057. KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true;
  19058. KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
  19059. KeyedCollectionPrototype.toJSON = toObject;
  19060. KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); };
  19061. mixin(IndexedCollection, {
  19062. // ### Conversion to other types
  19063. toKeyedSeq: function toKeyedSeq() {
  19064. return new ToKeyedSequence(this, false);
  19065. },
  19066. // ### ES6 Collection methods (ES6 Array and Map)
  19067. filter: function filter(predicate, context) {
  19068. return reify(this, filterFactory(this, predicate, context, false));
  19069. },
  19070. findIndex: function findIndex(predicate, context) {
  19071. var entry = this.findEntry(predicate, context);
  19072. return entry ? entry[0] : -1;
  19073. },
  19074. indexOf: function indexOf(searchValue) {
  19075. var key = this.keyOf(searchValue);
  19076. return key === undefined ? -1 : key;
  19077. },
  19078. lastIndexOf: function lastIndexOf(searchValue) {
  19079. var key = this.lastKeyOf(searchValue);
  19080. return key === undefined ? -1 : key;
  19081. },
  19082. reverse: function reverse() {
  19083. return reify(this, reverseFactory(this, false));
  19084. },
  19085. slice: function slice(begin, end) {
  19086. return reify(this, sliceFactory(this, begin, end, false));
  19087. },
  19088. splice: function splice(index, removeNum /*, ...values*/) {
  19089. var numArgs = arguments.length;
  19090. removeNum = Math.max(removeNum || 0, 0);
  19091. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  19092. return this;
  19093. }
  19094. // If index is negative, it should resolve relative to the size of the
  19095. // collection. However size may be expensive to compute if not cached, so
  19096. // only call count() if the number is in fact negative.
  19097. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  19098. var spliced = this.slice(0, index);
  19099. return reify(
  19100. this,
  19101. numArgs === 1
  19102. ? spliced
  19103. : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  19104. );
  19105. },
  19106. // ### More collection methods
  19107. findLastIndex: function findLastIndex(predicate, context) {
  19108. var entry = this.findLastEntry(predicate, context);
  19109. return entry ? entry[0] : -1;
  19110. },
  19111. first: function first(notSetValue) {
  19112. return this.get(0, notSetValue);
  19113. },
  19114. flatten: function flatten(depth) {
  19115. return reify(this, flattenFactory(this, depth, false));
  19116. },
  19117. get: function get(index, notSetValue) {
  19118. index = wrapIndex(this, index);
  19119. return index < 0 ||
  19120. (this.size === Infinity || (this.size !== undefined && index > this.size))
  19121. ? notSetValue
  19122. : this.find(function (_, key) { return key === index; }, undefined, notSetValue);
  19123. },
  19124. has: function has(index) {
  19125. index = wrapIndex(this, index);
  19126. return (
  19127. index >= 0 &&
  19128. (this.size !== undefined
  19129. ? this.size === Infinity || index < this.size
  19130. : this.indexOf(index) !== -1)
  19131. );
  19132. },
  19133. interpose: function interpose(separator) {
  19134. return reify(this, interposeFactory(this, separator));
  19135. },
  19136. interleave: function interleave(/*...collections*/) {
  19137. var collections = [this].concat(arrCopy(arguments));
  19138. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections);
  19139. var interleaved = zipped.flatten(true);
  19140. if (zipped.size) {
  19141. interleaved.size = zipped.size * collections.length;
  19142. }
  19143. return reify(this, interleaved);
  19144. },
  19145. keySeq: function keySeq() {
  19146. return Range(0, this.size);
  19147. },
  19148. last: function last(notSetValue) {
  19149. return this.get(-1, notSetValue);
  19150. },
  19151. skipWhile: function skipWhile(predicate, context) {
  19152. return reify(this, skipWhileFactory(this, predicate, context, false));
  19153. },
  19154. zip: function zip(/*, ...collections */) {
  19155. var collections = [this].concat(arrCopy(arguments));
  19156. return reify(this, zipWithFactory(this, defaultZipper, collections));
  19157. },
  19158. zipAll: function zipAll(/*, ...collections */) {
  19159. var collections = [this].concat(arrCopy(arguments));
  19160. return reify(this, zipWithFactory(this, defaultZipper, collections, true));
  19161. },
  19162. zipWith: function zipWith(zipper /*, ...collections */) {
  19163. var collections = arrCopy(arguments);
  19164. collections[0] = this;
  19165. return reify(this, zipWithFactory(this, zipper, collections));
  19166. },
  19167. });
  19168. var IndexedCollectionPrototype = IndexedCollection.prototype;
  19169. IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true;
  19170. IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true;
  19171. mixin(SetCollection, {
  19172. // ### ES6 Collection methods (ES6 Array and Map)
  19173. get: function get(value, notSetValue) {
  19174. return this.has(value) ? value : notSetValue;
  19175. },
  19176. includes: function includes(value) {
  19177. return this.has(value);
  19178. },
  19179. // ### More sequential methods
  19180. keySeq: function keySeq() {
  19181. return this.valueSeq();
  19182. },
  19183. });
  19184. SetCollection.prototype.has = CollectionPrototype.includes;
  19185. SetCollection.prototype.contains = SetCollection.prototype.includes;
  19186. // Mixin subclasses
  19187. mixin(KeyedSeq, KeyedCollection.prototype);
  19188. mixin(IndexedSeq, IndexedCollection.prototype);
  19189. mixin(SetSeq, SetCollection.prototype);
  19190. // #pragma Helper functions
  19191. function reduce(collection, reducer, reduction, context, useFirst, reverse) {
  19192. assertNotInfinite(collection.size);
  19193. collection.__iterate(function (v, k, c) {
  19194. if (useFirst) {
  19195. useFirst = false;
  19196. reduction = v;
  19197. } else {
  19198. reduction = reducer.call(context, reduction, v, k, c);
  19199. }
  19200. }, reverse);
  19201. return reduction;
  19202. }
  19203. function keyMapper(v, k) {
  19204. return k;
  19205. }
  19206. function entryMapper(v, k) {
  19207. return [k, v];
  19208. }
  19209. function not(predicate) {
  19210. return function() {
  19211. return !predicate.apply(this, arguments);
  19212. };
  19213. }
  19214. function neg(predicate) {
  19215. return function() {
  19216. return -predicate.apply(this, arguments);
  19217. };
  19218. }
  19219. function defaultZipper() {
  19220. return arrCopy(arguments);
  19221. }
  19222. function defaultNegComparator(a, b) {
  19223. return a < b ? 1 : a > b ? -1 : 0;
  19224. }
  19225. function hashCollection(collection) {
  19226. if (collection.size === Infinity) {
  19227. return 0;
  19228. }
  19229. var ordered = isOrdered(collection);
  19230. var keyed = isKeyed(collection);
  19231. var h = ordered ? 1 : 0;
  19232. var size = collection.__iterate(
  19233. keyed
  19234. ? ordered
  19235. ? function (v, k) {
  19236. h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
  19237. }
  19238. : function (v, k) {
  19239. h = (h + hashMerge(hash(v), hash(k))) | 0;
  19240. }
  19241. : ordered
  19242. ? function (v) {
  19243. h = (31 * h + hash(v)) | 0;
  19244. }
  19245. : function (v) {
  19246. h = (h + hash(v)) | 0;
  19247. }
  19248. );
  19249. return murmurHashOfSize(size, h);
  19250. }
  19251. function murmurHashOfSize(size, h) {
  19252. h = imul(h, 0xcc9e2d51);
  19253. h = imul((h << 15) | (h >>> -15), 0x1b873593);
  19254. h = imul((h << 13) | (h >>> -13), 5);
  19255. h = ((h + 0xe6546b64) | 0) ^ size;
  19256. h = imul(h ^ (h >>> 16), 0x85ebca6b);
  19257. h = imul(h ^ (h >>> 13), 0xc2b2ae35);
  19258. h = smi(h ^ (h >>> 16));
  19259. return h;
  19260. }
  19261. function hashMerge(a, b) {
  19262. return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
  19263. }
  19264. var OrderedSet = /*@__PURE__*/(function (Set$$1) {
  19265. function OrderedSet(value) {
  19266. return value === null || value === undefined
  19267. ? emptyOrderedSet()
  19268. : isOrderedSet(value)
  19269. ? value
  19270. : emptyOrderedSet().withMutations(function (set) {
  19271. var iter = SetCollection(value);
  19272. assertNotInfinite(iter.size);
  19273. iter.forEach(function (v) { return set.add(v); });
  19274. });
  19275. }
  19276. if ( Set$$1 ) OrderedSet.__proto__ = Set$$1;
  19277. OrderedSet.prototype = Object.create( Set$$1 && Set$$1.prototype );
  19278. OrderedSet.prototype.constructor = OrderedSet;
  19279. OrderedSet.of = function of (/*...values*/) {
  19280. return this(arguments);
  19281. };
  19282. OrderedSet.fromKeys = function fromKeys (value) {
  19283. return this(KeyedCollection(value).keySeq());
  19284. };
  19285. OrderedSet.prototype.toString = function toString () {
  19286. return this.__toString('OrderedSet {', '}');
  19287. };
  19288. return OrderedSet;
  19289. }(Set));
  19290. OrderedSet.isOrderedSet = isOrderedSet;
  19291. var OrderedSetPrototype = OrderedSet.prototype;
  19292. OrderedSetPrototype[IS_ORDERED_SYMBOL] = true;
  19293. OrderedSetPrototype.zip = IndexedCollectionPrototype.zip;
  19294. OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith;
  19295. OrderedSetPrototype.__empty = emptyOrderedSet;
  19296. OrderedSetPrototype.__make = makeOrderedSet;
  19297. function makeOrderedSet(map, ownerID) {
  19298. var set = Object.create(OrderedSetPrototype);
  19299. set.size = map ? map.size : 0;
  19300. set._map = map;
  19301. set.__ownerID = ownerID;
  19302. return set;
  19303. }
  19304. var EMPTY_ORDERED_SET;
  19305. function emptyOrderedSet() {
  19306. return (
  19307. EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
  19308. );
  19309. }
  19310. var Record = function Record(defaultValues, name) {
  19311. var hasInitialized;
  19312. var RecordType = function Record(values) {
  19313. var this$1 = this;
  19314. if (values instanceof RecordType) {
  19315. return values;
  19316. }
  19317. if (!(this instanceof RecordType)) {
  19318. return new RecordType(values);
  19319. }
  19320. if (!hasInitialized) {
  19321. hasInitialized = true;
  19322. var keys = Object.keys(defaultValues);
  19323. var indices = (RecordTypePrototype._indices = {});
  19324. // Deprecated: left to attempt not to break any external code which
  19325. // relies on a ._name property existing on record instances.
  19326. // Use Record.getDescriptiveName() instead
  19327. RecordTypePrototype._name = name;
  19328. RecordTypePrototype._keys = keys;
  19329. RecordTypePrototype._defaultValues = defaultValues;
  19330. for (var i = 0; i < keys.length; i++) {
  19331. var propName = keys[i];
  19332. indices[propName] = i;
  19333. if (RecordTypePrototype[propName]) {
  19334. /* eslint-disable no-console */
  19335. typeof console === 'object' &&
  19336. console.warn &&
  19337. console.warn(
  19338. 'Cannot define ' +
  19339. recordName(this) +
  19340. ' with property "' +
  19341. propName +
  19342. '" since that property name is part of the Record API.'
  19343. );
  19344. /* eslint-enable no-console */
  19345. } else {
  19346. setProp(RecordTypePrototype, propName);
  19347. }
  19348. }
  19349. }
  19350. this.__ownerID = undefined;
  19351. this._values = List().withMutations(function (l) {
  19352. l.setSize(this$1._keys.length);
  19353. KeyedCollection(values).forEach(function (v, k) {
  19354. l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v);
  19355. });
  19356. });
  19357. };
  19358. var RecordTypePrototype = (RecordType.prototype = Object.create(
  19359. RecordPrototype
  19360. ));
  19361. RecordTypePrototype.constructor = RecordType;
  19362. if (name) {
  19363. RecordType.displayName = name;
  19364. }
  19365. return RecordType;
  19366. };
  19367. Record.prototype.toString = function toString () {
  19368. var str = recordName(this) + ' { ';
  19369. var keys = this._keys;
  19370. var k;
  19371. for (var i = 0, l = keys.length; i !== l; i++) {
  19372. k = keys[i];
  19373. str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k));
  19374. }
  19375. return str + ' }';
  19376. };
  19377. Record.prototype.equals = function equals (other) {
  19378. return (
  19379. this === other ||
  19380. (other &&
  19381. this._keys === other._keys &&
  19382. recordSeq(this).equals(recordSeq(other)))
  19383. );
  19384. };
  19385. Record.prototype.hashCode = function hashCode () {
  19386. return recordSeq(this).hashCode();
  19387. };
  19388. // @pragma Access
  19389. Record.prototype.has = function has (k) {
  19390. return this._indices.hasOwnProperty(k);
  19391. };
  19392. Record.prototype.get = function get (k, notSetValue) {
  19393. if (!this.has(k)) {
  19394. return notSetValue;
  19395. }
  19396. var index = this._indices[k];
  19397. var value = this._values.get(index);
  19398. return value === undefined ? this._defaultValues[k] : value;
  19399. };
  19400. // @pragma Modification
  19401. Record.prototype.set = function set (k, v) {
  19402. if (this.has(k)) {
  19403. var newValues = this._values.set(
  19404. this._indices[k],
  19405. v === this._defaultValues[k] ? undefined : v
  19406. );
  19407. if (newValues !== this._values && !this.__ownerID) {
  19408. return makeRecord(this, newValues);
  19409. }
  19410. }
  19411. return this;
  19412. };
  19413. Record.prototype.remove = function remove (k) {
  19414. return this.set(k);
  19415. };
  19416. Record.prototype.clear = function clear () {
  19417. var newValues = this._values.clear().setSize(this._keys.length);
  19418. return this.__ownerID ? this : makeRecord(this, newValues);
  19419. };
  19420. Record.prototype.wasAltered = function wasAltered () {
  19421. return this._values.wasAltered();
  19422. };
  19423. Record.prototype.toSeq = function toSeq () {
  19424. return recordSeq(this);
  19425. };
  19426. Record.prototype.toJS = function toJS$1 () {
  19427. return toJS(this);
  19428. };
  19429. Record.prototype.entries = function entries () {
  19430. return this.__iterator(ITERATE_ENTRIES);
  19431. };
  19432. Record.prototype.__iterator = function __iterator (type, reverse) {
  19433. return recordSeq(this).__iterator(type, reverse);
  19434. };
  19435. Record.prototype.__iterate = function __iterate (fn, reverse) {
  19436. return recordSeq(this).__iterate(fn, reverse);
  19437. };
  19438. Record.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  19439. if (ownerID === this.__ownerID) {
  19440. return this;
  19441. }
  19442. var newValues = this._values.__ensureOwner(ownerID);
  19443. if (!ownerID) {
  19444. this.__ownerID = ownerID;
  19445. this._values = newValues;
  19446. return this;
  19447. }
  19448. return makeRecord(this, newValues, ownerID);
  19449. };
  19450. Record.isRecord = isRecord;
  19451. Record.getDescriptiveName = recordName;
  19452. var RecordPrototype = Record.prototype;
  19453. RecordPrototype[IS_RECORD_SYMBOL] = true;
  19454. RecordPrototype[DELETE] = RecordPrototype.remove;
  19455. RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
  19456. RecordPrototype.getIn = getIn$1;
  19457. RecordPrototype.hasIn = CollectionPrototype.hasIn;
  19458. RecordPrototype.merge = merge;
  19459. RecordPrototype.mergeWith = mergeWith;
  19460. RecordPrototype.mergeIn = mergeIn;
  19461. RecordPrototype.mergeDeep = mergeDeep$1;
  19462. RecordPrototype.mergeDeepWith = mergeDeepWith$1;
  19463. RecordPrototype.mergeDeepIn = mergeDeepIn;
  19464. RecordPrototype.setIn = setIn$1;
  19465. RecordPrototype.update = update$1;
  19466. RecordPrototype.updateIn = updateIn$1;
  19467. RecordPrototype.withMutations = withMutations;
  19468. RecordPrototype.asMutable = asMutable;
  19469. RecordPrototype.asImmutable = asImmutable;
  19470. RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
  19471. RecordPrototype.toJSON = RecordPrototype.toObject =
  19472. CollectionPrototype.toObject;
  19473. RecordPrototype.inspect = RecordPrototype.toSource = function() {
  19474. return this.toString();
  19475. };
  19476. function makeRecord(likeRecord, values, ownerID) {
  19477. var record = Object.create(Object.getPrototypeOf(likeRecord));
  19478. record._values = values;
  19479. record.__ownerID = ownerID;
  19480. return record;
  19481. }
  19482. function recordName(record) {
  19483. return record.constructor.displayName || record.constructor.name || 'Record';
  19484. }
  19485. function recordSeq(record) {
  19486. return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; }));
  19487. }
  19488. function setProp(prototype, name) {
  19489. try {
  19490. Object.defineProperty(prototype, name, {
  19491. get: function() {
  19492. return this.get(name);
  19493. },
  19494. set: function(value) {
  19495. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  19496. this.set(name, value);
  19497. },
  19498. });
  19499. } catch (error) {
  19500. // Object.defineProperty failed. Probably IE8.
  19501. }
  19502. }
  19503. /**
  19504. * Returns a lazy Seq of `value` repeated `times` times. When `times` is
  19505. * undefined, returns an infinite sequence of `value`.
  19506. */
  19507. var Repeat = /*@__PURE__*/(function (IndexedSeq$$1) {
  19508. function Repeat(value, times) {
  19509. if (!(this instanceof Repeat)) {
  19510. return new Repeat(value, times);
  19511. }
  19512. this._value = value;
  19513. this.size = times === undefined ? Infinity : Math.max(0, times);
  19514. if (this.size === 0) {
  19515. if (EMPTY_REPEAT) {
  19516. return EMPTY_REPEAT;
  19517. }
  19518. EMPTY_REPEAT = this;
  19519. }
  19520. }
  19521. if ( IndexedSeq$$1 ) Repeat.__proto__ = IndexedSeq$$1;
  19522. Repeat.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  19523. Repeat.prototype.constructor = Repeat;
  19524. Repeat.prototype.toString = function toString () {
  19525. if (this.size === 0) {
  19526. return 'Repeat []';
  19527. }
  19528. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  19529. };
  19530. Repeat.prototype.get = function get (index, notSetValue) {
  19531. return this.has(index) ? this._value : notSetValue;
  19532. };
  19533. Repeat.prototype.includes = function includes (searchValue) {
  19534. return is(this._value, searchValue);
  19535. };
  19536. Repeat.prototype.slice = function slice (begin, end) {
  19537. var size = this.size;
  19538. return wholeSlice(begin, end, size)
  19539. ? this
  19540. : new Repeat(
  19541. this._value,
  19542. resolveEnd(end, size) - resolveBegin(begin, size)
  19543. );
  19544. };
  19545. Repeat.prototype.reverse = function reverse () {
  19546. return this;
  19547. };
  19548. Repeat.prototype.indexOf = function indexOf (searchValue) {
  19549. if (is(this._value, searchValue)) {
  19550. return 0;
  19551. }
  19552. return -1;
  19553. };
  19554. Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  19555. if (is(this._value, searchValue)) {
  19556. return this.size;
  19557. }
  19558. return -1;
  19559. };
  19560. Repeat.prototype.__iterate = function __iterate (fn, reverse) {
  19561. var size = this.size;
  19562. var i = 0;
  19563. while (i !== size) {
  19564. if (fn(this._value, reverse ? size - ++i : i++, this) === false) {
  19565. break;
  19566. }
  19567. }
  19568. return i;
  19569. };
  19570. Repeat.prototype.__iterator = function __iterator (type, reverse) {
  19571. var this$1 = this;
  19572. var size = this.size;
  19573. var i = 0;
  19574. return new Iterator(
  19575. function () { return i === size
  19576. ? iteratorDone()
  19577. : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); }
  19578. );
  19579. };
  19580. Repeat.prototype.equals = function equals (other) {
  19581. return other instanceof Repeat
  19582. ? is(this._value, other._value)
  19583. : deepEqual(other);
  19584. };
  19585. return Repeat;
  19586. }(IndexedSeq));
  19587. var EMPTY_REPEAT;
  19588. function fromJS(value, converter) {
  19589. return fromJSWith(
  19590. [],
  19591. converter || defaultConverter,
  19592. value,
  19593. '',
  19594. converter && converter.length > 2 ? [] : undefined,
  19595. { '': value }
  19596. );
  19597. }
  19598. function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
  19599. var toSeq = Array.isArray(value)
  19600. ? IndexedSeq
  19601. : isPlainObj(value)
  19602. ? KeyedSeq
  19603. : null;
  19604. if (toSeq) {
  19605. if (~stack.indexOf(value)) {
  19606. throw new TypeError('Cannot convert circular structure to Immutable');
  19607. }
  19608. stack.push(value);
  19609. keyPath && key !== '' && keyPath.push(key);
  19610. var converted = converter.call(
  19611. parentValue,
  19612. key,
  19613. toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }
  19614. ),
  19615. keyPath && keyPath.slice()
  19616. );
  19617. stack.pop();
  19618. keyPath && keyPath.pop();
  19619. return converted;
  19620. }
  19621. return value;
  19622. }
  19623. function defaultConverter(k, v) {
  19624. return isKeyed(v) ? v.toMap() : v.toList();
  19625. }
  19626. var version = "4.0.0-rc.11";
  19627. var Immutable = {
  19628. version: version,
  19629. Collection: Collection,
  19630. // Note: Iterable is deprecated
  19631. Iterable: Collection,
  19632. Seq: Seq,
  19633. Map: Map,
  19634. OrderedMap: OrderedMap,
  19635. List: List,
  19636. Stack: Stack,
  19637. Set: Set,
  19638. OrderedSet: OrderedSet,
  19639. Record: Record,
  19640. Range: Range,
  19641. Repeat: Repeat,
  19642. is: is,
  19643. fromJS: fromJS,
  19644. hash: hash,
  19645. isImmutable: isImmutable,
  19646. isCollection: isCollection,
  19647. isKeyed: isKeyed,
  19648. isIndexed: isIndexed,
  19649. isAssociative: isAssociative,
  19650. isOrdered: isOrdered,
  19651. isValueObject: isValueObject,
  19652. isSeq: isSeq,
  19653. isList: isList,
  19654. isMap: isMap,
  19655. isOrderedMap: isOrderedMap,
  19656. isStack: isStack,
  19657. isSet: isSet,
  19658. isOrderedSet: isOrderedSet,
  19659. isRecord: isRecord,
  19660. get: get,
  19661. getIn: getIn,
  19662. has: has,
  19663. hasIn: hasIn,
  19664. merge: merge$1,
  19665. mergeDeep: mergeDeep,
  19666. mergeWith: mergeWith$1,
  19667. mergeDeepWith: mergeDeepWith,
  19668. remove: remove,
  19669. removeIn: removeIn,
  19670. set: set,
  19671. setIn: setIn,
  19672. update: update,
  19673. updateIn: updateIn,
  19674. };
  19675. // Note: Iterable is deprecated
  19676. var Iterable = Collection;
  19677. exports.default = Immutable;
  19678. exports.version = version;
  19679. exports.Collection = Collection;
  19680. exports.Iterable = Iterable;
  19681. exports.Seq = Seq;
  19682. exports.Map = Map;
  19683. exports.OrderedMap = OrderedMap;
  19684. exports.List = List;
  19685. exports.Stack = Stack;
  19686. exports.Set = Set;
  19687. exports.OrderedSet = OrderedSet;
  19688. exports.Record = Record;
  19689. exports.Range = Range;
  19690. exports.Repeat = Repeat;
  19691. exports.is = is;
  19692. exports.fromJS = fromJS;
  19693. exports.hash = hash;
  19694. exports.isImmutable = isImmutable;
  19695. exports.isCollection = isCollection;
  19696. exports.isKeyed = isKeyed;
  19697. exports.isIndexed = isIndexed;
  19698. exports.isAssociative = isAssociative;
  19699. exports.isOrdered = isOrdered;
  19700. exports.isValueObject = isValueObject;
  19701. exports.get = get;
  19702. exports.getIn = getIn;
  19703. exports.has = has;
  19704. exports.hasIn = hasIn;
  19705. exports.merge = merge$1;
  19706. exports.mergeDeep = mergeDeep;
  19707. exports.mergeWith = mergeWith$1;
  19708. exports.mergeDeepWith = mergeDeepWith;
  19709. exports.remove = remove;
  19710. exports.removeIn = removeIn;
  19711. exports.set = set;
  19712. exports.setIn = setIn;
  19713. exports.update = update;
  19714. exports.updateIn = updateIn;
  19715. Object.defineProperty(exports, '__esModule', { value: true });
  19716. })));
  19717. });
  19718. index.unwrapExports(immutable$1);
  19719. var draftjsUtils = index.createCommonjsModule(function (module, exports) {
  19720. !function(t,e){module.exports=e(Draft,immutable$1);}(window,function(n,r){return u={},o.m=i=[function(t,e){t.exports=n;},function(t,e){t.exports=r;},function(t,e,n){t.exports=n(3);},function(t,e,n){n.r(e);var C=n(0),i=n(1);function m(t){var e=t.getSelection(),n=t.getCurrentContent(),r=e.getStartKey(),o=e.getEndKey(),i=n.getBlockMap();return i.toSeq().skipUntil(function(t,e){return e===r}).takeUntil(function(t,e){return e===o}).concat([[o,i.get(o)]])}function a(t){return m(t).toList()}function f(t){if(t)return a(t).get(0)}function r(t){if(t){var n=f(t),e=t.getCurrentContent().getBlockMap().toSeq().toList(),r=0;if(e.forEach(function(t,e){t.get("key")===n.get("key")&&(r=e-1);}),-1<r)return e.get(r)}}function o(t){return t?t.getCurrentContent().getBlockMap().toList():new i.List}function u(t){var e=a(t);if(!e.some(function(t){return t.type!==e.get(0).type}))return e.get(0).type}function c(t){var e=C.RichUtils.tryToRemoveBlockStyle(t);return e?C.EditorState.push(t,e,"change-block-type"):t}function l(t){var e="",n=t.getSelection(),r=n.getAnchorOffset(),o=n.getFocusOffset(),i=a(t);if(0<i.size){if(n.getIsBackward()){var u=r;r=o,o=u;}for(var c=0;c<i.size;c+=1){var f=0===c?r:0,l=c===i.size-1?o:i.get(c).getText().length;e+=i.get(c).getText().slice(f,l);}}return e}function s(t){var e=t.getCurrentContent(),n=t.getSelection(),r=C.Modifier.removeRange(e,n,"forward"),o=r.getSelectionAfter(),i=r.getBlockForKey(o.getStartKey());return r=C.Modifier.insertText(r,o,"\n",i.getInlineStyleAt(o.getStartOffset()),null),C.EditorState.push(t,r,"insert-fragment")}function g(t){var e=C.Modifier.splitBlock(t.getCurrentContent(),t.getSelection());return c(C.EditorState.push(t,e,"split-block"))}function d(t){var e=t.getCurrentContent().getBlockMap().toList(),n=t.getSelection().merge({anchorKey:e.first().get("key"),anchorOffset:0,focusKey:e.last().get("key"),focusOffset:e.last().getLength()}),r=C.Modifier.removeRange(t.getCurrentContent(),n,"forward");return C.EditorState.push(t,r,"remove-range")}function S(t,e){var n=C.Modifier.setBlockData(t.getCurrentContent(),t.getSelection(),e);return C.EditorState.push(t,n,"change-block-data")}function p(t){var r=new i.Map({}),e=a(t);if(e&&0<e.size)for(var n=function(t){var n=e.get(t).getData();if(!n||0===n.size)return r=r.clear(),"break";if(0===t)r=n;else if(r.forEach(function(t,e){n.get(e)&&n.get(e)===t||(r=r.delete(e));}),0===r.size)return r=r.clear(),"break"},o=0;o<e.size;o+=1){if("break"===n(o))break}return r}var y=Object(i.Map)({code:{element:"pre"}}),v=C.DefaultDraftBlockRenderMap.merge(y);function b(t){if(t){var e=t.getType();return "unordered-list-item"===e||"ordered-list-item"===e}return !1}function h(t,e,n){var r,o=t.getSelection();r=o.getIsBackward()?o.getFocusKey():o.getAnchorKey();var i=t.getCurrentContent(),u=i.getBlockForKey(r),c=u.getType();if("unordered-list-item"!==c&&"ordered-list-item"!==c)return t;var f=i.getBlockBefore(r);if(!f)return t;if(f.getType()!==c)return t;var l=u.getDepth();if(1===e&&l===n)return t;var a,s,g,d,S,p,y,v=Math.min(f.getDepth()+1,n),b=(s=e,g=v,d=(a=t).getSelection(),S=a.getCurrentContent(),p=S.getBlockMap(),y=m(a).map(function(t){var e=t.getDepth()+s;return e=Math.max(0,Math.min(e,g)),t.set("depth",e)}),p=p.merge(y),S.merge({blockMap:p,selectionBefore:d,selectionAfter:d}));return C.EditorState.push(t,b,"adjust-depth")}function O(t,e){var n;return 13===(n=e).which&&(n.getModifierState("Shift")||n.getModifierState("Alt")||n.getModifierState("Control"))?t.getSelection().isCollapsed()?C.RichUtils.insertSoftNewline(t):s(t):function(t){var e=t.getSelection();if(e.isCollapsed()){var n=t.getCurrentContent(),r=e.getStartKey(),o=n.getBlockForKey(r);if(!b(o)&&"unstyled"!==o.getType()&&o.getLength()===e.getStartOffset())return g(t);if(b(o)&&0===o.getLength()){var i=o.getDepth();if(0===i)return c(t);if(0<i)return h(t,-1,i)}}}(t)}function k(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r);}return n}function E(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function I(t){return (I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function R(t){var e=t.getSelection();if(e.isCollapsed()){var n={},r=t.getCurrentInlineStyle().toList().toJS();if(r)return ["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(t){n[t]=0<=r.indexOf(t);}),n}var u=e.getStartOffset(),c=e.getEndOffset(),f=a(t);if(0<f.size){var o=function(){for(var n={BOLD:!0,ITALIC:!0,UNDERLINE:!0,STRIKETHROUGH:!0,CODE:!0,SUPERSCRIPT:!0,SUBSCRIPT:!0},r=0;r<f.size;r+=1){var t=0===r?u:0,e=r===f.size-1?c:f.get(r).getText().length;t===e&&0===t?(t=1,e=2):t===e&&--t;for(var o=function(t){var e=f.get(r).getInlineStyleAt(t);["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(t){n[t]=n[t]&&e.get(t)===t;});},i=t;i<e;i+=1)o(i);}return {v:n}}();if("object"===I(o))return o.v}return {}}function B(t){var e,n=t.getSelection(),r=n.getStartOffset(),o=n.getEndOffset();r===o&&0===r?o=1:r===o&&--r;for(var i=f(t),u=r;u<o;u+=1){var c=i.getEntityAt(u);if(!c){e=void 0;break}if(u===r)e=c;else if(e!==c){e=void 0;break}}return e}function T(t,e){var n,r=f(t);return r.findEntityRanges(function(t){return t.get("entity")===e},function(t,e){n={start:t,end:e,text:r.get("text").slice(t,e)};}),n}function P(t,e,n){x[t]["".concat(t.toLowerCase(),"-").concat(n)]=E({},"".concat(e),n);}function j(){return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?k(Object(n),!0).forEach(function(t){E(e,t,n[t]);}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):k(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t));});}return e}({},x.color,{},x.bgcolor,{},x.fontSize,{},x.fontFamily,{CODE:x.CODE,SUPERSCRIPT:x.SUPERSCRIPT,SUBSCRIPT:x.SUBSCRIPT})}var x={color:{},bgcolor:{},fontSize:{},fontFamily:{},CODE:{fontFamily:"monospace",wordWrap:"break-word",background:"#f1f1f1",borderRadius:3,padding:"1px 3px"},SUPERSCRIPT:{fontSize:11,position:"relative",top:-8,display:"inline-flex"},SUBSCRIPT:{fontSize:11,position:"relative",bottom:-8,display:"inline-flex"}};function M(t,e,n){var r=t.getSelection(),o=Object.keys(x[e]).reduce(function(t,e){return C.Modifier.removeInlineStyle(t,r,e)},t.getCurrentContent()),i=C.EditorState.push(t,o,"changeinline-style"),u=t.getCurrentInlineStyle();if(r.isCollapsed()&&(i=u.reduce(function(t,e){return C.RichUtils.toggleInlineStyle(t,e)},i)),"SUPERSCRIPT"===e||"SUBSCRIPT"==e)u.has(n)||(i=C.RichUtils.toggleInlineStyle(i,n));else{var c="bgcolor"===e?"backgroundColor":e;u.has("".concat(c,"-").concat(n))||(i=C.RichUtils.toggleInlineStyle(i,"".concat(e.toLowerCase(),"-").concat(n)),P(e,c,n));}return i}function L(t){t&&t.getCurrentContent().getBlockMap().map(function(t){return t.get("characterList")}).toList().flatten().forEach(function(t){t&&0===t.indexOf("color-")?P("color","color",t.substr(6)):t&&0===t.indexOf("bgcolor-")?P("bgcolor","backgroundColor",t.substr(8)):t&&0===t.indexOf("fontsize-")?P("fontSize","fontSize",+t.substr(9)):t&&0===t.indexOf("fontfamily-")&&P("fontFamily","fontFamily",t.substr(11));});}function U(t,e,n){var r=t.getInlineStyleAt(n).toList().filter(function(t){return t.startsWith(e.toLowerCase())});if(r&&0<r.size)return r.get(0)}function w(r,l){if(r&&l&&0<l.length){var t=function(){var t=r.getSelection(),i={};if(t.isCollapsed())return l.forEach(function(t){i[t]=function(t,e){var n=t.getCurrentInlineStyle().toList().filter(function(t){return t.startsWith(e.toLowerCase())});if(n&&0<n.size)return n.get(0)}(r,t);}),{v:i};var u=t.getStartOffset(),c=t.getEndOffset(),f=a(r);if(0<f.size){for(var e=function(n){var t=0===n?u:0,e=n===f.size-1?c:f.get(n).getText().length;t===e&&0===t?(t=1,e=2):t===e&&--t;for(var r=function(e){e===t?l.forEach(function(t){i[t]=U(f.get(n),t,e);}):l.forEach(function(t){i[t]&&i[t]!==U(f.get(n),t,e)&&(i[t]=void 0);});},o=t;o<e;o+=1)r(o);},n=0;n<f.size;n+=1)e(n);return {v:i}}}();if("object"===I(t))return t.v}return {}}function D(e){var t=e.getCurrentInlineStyle(),n=e.getCurrentContent();return t.forEach(function(t){n=C.Modifier.removeInlineStyle(n,e.getSelection(),t);}),C.EditorState.push(e,n,"change-inline-style")}n.d(e,"isListBlock",function(){return b}),n.d(e,"changeDepth",function(){return h}),n.d(e,"handleNewLine",function(){return O}),n.d(e,"getEntityRange",function(){return T}),n.d(e,"getCustomStyleMap",function(){return j}),n.d(e,"toggleCustomInlineStyle",function(){return M}),n.d(e,"getSelectionEntity",function(){return B}),n.d(e,"extractInlineStyle",function(){return L}),n.d(e,"removeAllInlineStyles",function(){return D}),n.d(e,"getSelectionInlineStyle",function(){return R}),n.d(e,"getSelectionCustomInlineStyle",function(){return w}),n.d(e,"getSelectedBlocksMap",function(){return m}),n.d(e,"getSelectedBlocksList",function(){return a}),n.d(e,"getSelectedBlock",function(){return f}),n.d(e,"getBlockBeforeSelectedBlock",function(){return r}),n.d(e,"getAllBlocks",function(){return o}),n.d(e,"getSelectedBlocksType",function(){return u}),n.d(e,"removeSelectedBlocksStyle",function(){return c}),n.d(e,"getSelectionText",function(){return l}),n.d(e,"addLineBreakRemovingSelection",function(){return s}),n.d(e,"insertNewUnstyledBlock",function(){return g}),n.d(e,"clearEditorContent",function(){return d}),n.d(e,"setBlockData",function(){return S}),n.d(e,"getSelectedBlocksMetadata",function(){return p}),n.d(e,"blockRenderMap",function(){return v});}],o.c=u,o.d=function(t,e,n){o.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n});},o.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0});},o.t=function(e,t){if(1&t&&(e=o(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(o.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)o.d(n,r,function(t){return e[t]}.bind(null,r));return n},o.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return o.d(e,"a",e),e},o.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},o.p="",o(o.s=2);function o(t){if(u[t])return u[t].exports;var e=u[t]={i:t,l:!1,exports:{}};return i[t].call(e.exports,e,e.exports,o),e.l=!0,e.exports}var i,u;});
  19721. });
  19722. index.unwrapExports(draftjsUtils);
  19723. var draftjsUtils_1 = draftjsUtils.draftjsUtils;
  19724. var interopRequireDefault = index.createCommonjsModule(function (module) {
  19725. function _interopRequireDefault(obj) {
  19726. return obj && obj.__esModule ? obj : {
  19727. "default": obj
  19728. };
  19729. }
  19730. module.exports = _interopRequireDefault;
  19731. });
  19732. index.unwrapExports(interopRequireDefault);
  19733. /**
  19734. * Copyright (c) 2013-present, Facebook, Inc.
  19735. *
  19736. * This source code is licensed under the MIT license found in the
  19737. * LICENSE file in the root directory of this source tree.
  19738. */
  19739. /**
  19740. * Use invariant() to assert state which your program assumes to be true.
  19741. *
  19742. * Provide sprintf-style format (only %s is supported) and arguments
  19743. * to provide information about what broke and what you were
  19744. * expecting.
  19745. *
  19746. * The invariant message will be stripped in production, but the invariant
  19747. * will remain to ensure logic does not differ in production.
  19748. */
  19749. var invariant$1 = function(condition, format, a, b, c, d, e, f) {
  19750. if (process.env.NODE_ENV !== 'production') {
  19751. if (format === undefined) {
  19752. throw new Error('invariant requires an error message argument');
  19753. }
  19754. }
  19755. if (!condition) {
  19756. var error;
  19757. if (format === undefined) {
  19758. error = new Error(
  19759. 'Minified exception occurred; use the non-minified dev environment ' +
  19760. 'for the full error message and additional helpful warnings.'
  19761. );
  19762. } else {
  19763. var args = [a, b, c, d, e, f];
  19764. var argIndex = 0;
  19765. error = new Error(
  19766. format.replace(/%s/g, function() { return args[argIndex++]; })
  19767. );
  19768. error.name = 'Invariant Violation';
  19769. }
  19770. error.framesToPop = 1; // we don't care about invariant's own frame
  19771. throw error;
  19772. }
  19773. };
  19774. var browser = invariant$1;
  19775. function _arrayWithoutHoles(arr) {
  19776. if (Array.isArray(arr)) {
  19777. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  19778. arr2[i] = arr[i];
  19779. }
  19780. return arr2;
  19781. }
  19782. }
  19783. var arrayWithoutHoles = _arrayWithoutHoles;
  19784. function _iterableToArray(iter) {
  19785. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  19786. }
  19787. var iterableToArray = _iterableToArray;
  19788. function _nonIterableSpread() {
  19789. throw new TypeError("Invalid attempt to spread non-iterable instance");
  19790. }
  19791. var nonIterableSpread = _nonIterableSpread;
  19792. function _toConsumableArray(arr) {
  19793. return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
  19794. }
  19795. var toConsumableArray = _toConsumableArray;
  19796. var updateMutation_1 = index.createCommonjsModule(function (module, exports) {
  19797. Object.defineProperty(exports, "__esModule", {
  19798. value: true
  19799. });
  19800. exports["default"] = updateMutation;
  19801. function updateMutation(mutation, originalOffset, originalLength, newLength, prefixLength, suffixLength) {
  19802. // three cases we can reasonably adjust - disjoint mutations that
  19803. // happen later on where the offset will need to be changed,
  19804. // mutations that completely contain the new one where we can adjust
  19805. // the length, and mutations that occur partially within the new one.
  19806. var lengthDiff = newLength - originalLength;
  19807. var mutationAfterChange = originalOffset + originalLength <= mutation.offset;
  19808. if (mutationAfterChange) {
  19809. return Object.assign({}, mutation, {
  19810. offset: mutation.offset + lengthDiff
  19811. });
  19812. }
  19813. var mutationContainsChange = originalOffset >= mutation.offset && originalOffset + originalLength <= mutation.offset + mutation.length;
  19814. if (mutationContainsChange) {
  19815. return Object.assign({}, mutation, {
  19816. length: mutation.length + lengthDiff
  19817. });
  19818. }
  19819. var mutationWithinPrefixChange = mutation.offset >= originalOffset && mutation.offset + mutation.length <= originalOffset + originalLength && prefixLength > 0;
  19820. if (mutationWithinPrefixChange) {
  19821. return Object.assign({}, mutation, {
  19822. offset: mutation.offset + prefixLength
  19823. });
  19824. }
  19825. var mutationContainsPrefix = mutation.offset < originalOffset && mutation.offset + mutation.length <= originalOffset + originalLength && mutation.offset + mutation.length > originalOffset && prefixLength > 0;
  19826. if (mutationContainsPrefix) {
  19827. return [Object.assign({}, mutation, {
  19828. length: originalOffset - mutation.offset
  19829. }), Object.assign({}, mutation, {
  19830. offset: originalOffset + prefixLength,
  19831. length: mutation.offset - originalOffset + mutation.length
  19832. })];
  19833. }
  19834. var mutationContainsSuffix = mutation.offset >= originalOffset && mutation.offset + mutation.length > originalOffset + originalLength && originalOffset + originalLength > mutation.offset && suffixLength > 0;
  19835. if (mutationContainsSuffix) {
  19836. return [Object.assign({}, mutation, {
  19837. offset: mutation.offset + prefixLength,
  19838. length: originalOffset + originalLength - mutation.offset
  19839. }), Object.assign({}, mutation, {
  19840. offset: originalOffset + originalLength + prefixLength + suffixLength,
  19841. length: mutation.offset + mutation.length - (originalOffset + originalLength)
  19842. })];
  19843. }
  19844. return mutation;
  19845. }
  19846. });
  19847. index.unwrapExports(updateMutation_1);
  19848. var rangeSort = index.createCommonjsModule(function (module, exports) {
  19849. Object.defineProperty(exports, "__esModule", {
  19850. value: true
  19851. });
  19852. exports["default"] = void 0;
  19853. var _default = function _default(r1, r2) {
  19854. if (r1.offset === r2.offset) {
  19855. return r2.length - r1.length;
  19856. }
  19857. return r1.offset - r2.offset;
  19858. };
  19859. exports["default"] = _default;
  19860. });
  19861. index.unwrapExports(rangeSort);
  19862. var encodeBlock = index.createCommonjsModule(function (module, exports) {
  19863. Object.defineProperty(exports, "__esModule", {
  19864. value: true
  19865. });
  19866. exports["default"] = void 0;
  19867. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  19868. var _updateMutation = interopRequireDefault(updateMutation_1);
  19869. var _rangeSort = interopRequireDefault(rangeSort);
  19870. var ENTITY_MAP = {
  19871. '&': '&amp;',
  19872. '<': '&lt;',
  19873. '>': '&gt;',
  19874. '"': '&quot;',
  19875. "'": '&#x27;',
  19876. '`': '&#x60;',
  19877. '\n': '<br/>'
  19878. };
  19879. var _default = function _default(block) {
  19880. var blockText = (0, _toConsumableArray2["default"])(block.text);
  19881. var entities = block.entityRanges.sort(_rangeSort["default"]);
  19882. var styles = block.inlineStyleRanges.sort(_rangeSort["default"]);
  19883. var resultText = '';
  19884. var _loop = function _loop(index) {
  19885. var _char = blockText[index];
  19886. if (ENTITY_MAP[_char] !== undefined) {
  19887. var encoded = ENTITY_MAP[_char];
  19888. var resultIndex = (0, _toConsumableArray2["default"])(resultText).length;
  19889. resultText += encoded;
  19890. var updateForChar = function updateForChar(mutation) {
  19891. return (0, _updateMutation["default"])(mutation, resultIndex, _char.length, encoded.length, 0, 0);
  19892. };
  19893. entities = entities.map(updateForChar);
  19894. styles = styles.map(updateForChar);
  19895. } else {
  19896. resultText += _char;
  19897. }
  19898. };
  19899. for (var index = 0; index < blockText.length; index++) {
  19900. _loop(index);
  19901. }
  19902. return Object.assign({}, block, {
  19903. text: resultText,
  19904. inlineStyleRanges: styles,
  19905. entityRanges: entities
  19906. });
  19907. };
  19908. exports["default"] = _default;
  19909. });
  19910. index.unwrapExports(encodeBlock);
  19911. var _typeof_1 = index.createCommonjsModule(function (module) {
  19912. function _typeof(obj) {
  19913. "@babel/helpers - typeof";
  19914. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  19915. module.exports = _typeof = function _typeof(obj) {
  19916. return typeof obj;
  19917. };
  19918. } else {
  19919. module.exports = _typeof = function _typeof(obj) {
  19920. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  19921. };
  19922. }
  19923. return _typeof(obj);
  19924. }
  19925. module.exports = _typeof;
  19926. });
  19927. var splitReactElement_1 = index.createCommonjsModule(function (module, exports) {
  19928. Object.defineProperty(exports, "__esModule", {
  19929. value: true
  19930. });
  19931. exports["default"] = splitReactElement;
  19932. var _invariant = interopRequireDefault(browser);
  19933. var _react = interopRequireDefault(React__default);
  19934. var _server = interopRequireDefault(server);
  19935. // see http://w3c.github.io/html/syntax.html#writing-html-documents-elements
  19936. var VOID_TAGS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
  19937. function splitReactElement(element) {
  19938. if (VOID_TAGS.indexOf(element.type) !== -1) {
  19939. return _server["default"].renderToStaticMarkup(element);
  19940. }
  19941. var tags = _server["default"].renderToStaticMarkup(_react["default"].cloneElement(element, {}, '\r')).split('\r');
  19942. (0, _invariant["default"])(tags.length > 1, "convertToHTML: Element of type ".concat(element.type, " must render children"));
  19943. (0, _invariant["default"])(tags.length < 3, "convertToHTML: Element of type ".concat(element.type, " cannot use carriage return character"));
  19944. return {
  19945. start: tags[0],
  19946. end: tags[1]
  19947. };
  19948. }
  19949. });
  19950. index.unwrapExports(splitReactElement_1);
  19951. var getElementHTML_1 = index.createCommonjsModule(function (module, exports) {
  19952. Object.defineProperty(exports, "__esModule", {
  19953. value: true
  19954. });
  19955. exports["default"] = getElementHTML;
  19956. var _typeof2 = interopRequireDefault(_typeof_1);
  19957. var _invariant = interopRequireDefault(browser);
  19958. var _react = interopRequireDefault(React__default);
  19959. var _server = interopRequireDefault(server);
  19960. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  19961. function hasChildren(element) {
  19962. return _react["default"].isValidElement(element) && _react["default"].Children.count(element.props.children) > 0;
  19963. }
  19964. function getElementHTML(element) {
  19965. var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  19966. if (element === undefined || element === null) {
  19967. return element;
  19968. }
  19969. if (typeof element === 'string') {
  19970. return element;
  19971. }
  19972. if (_react["default"].isValidElement(element)) {
  19973. if (hasChildren(element)) {
  19974. return _server["default"].renderToStaticMarkup(element);
  19975. }
  19976. var tags = (0, _splitReactElement["default"])(element);
  19977. if (text !== null && (0, _typeof2["default"])(tags) === 'object') {
  19978. var start = tags.start,
  19979. end = tags.end;
  19980. return start + text + end;
  19981. }
  19982. return tags;
  19983. }
  19984. (0, _invariant["default"])(Object.prototype.hasOwnProperty.call(element, 'start') && Object.prototype.hasOwnProperty.call(element, 'end'), 'convertToHTML: received conversion data without either an HTML string, ReactElement or an object with start/end tags');
  19985. if (text !== null) {
  19986. var _start = element.start,
  19987. _end = element.end;
  19988. return _start + text + _end;
  19989. }
  19990. return element;
  19991. }
  19992. });
  19993. index.unwrapExports(getElementHTML_1);
  19994. var getElementTagLength_1 = index.createCommonjsModule(function (module, exports) {
  19995. Object.defineProperty(exports, "__esModule", {
  19996. value: true
  19997. });
  19998. exports["default"] = void 0;
  19999. var _typeof2 = interopRequireDefault(_typeof_1);
  20000. var _react = interopRequireDefault(React__default);
  20001. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  20002. var getElementTagLength = function getElementTagLength(element) {
  20003. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'start';
  20004. if (_react["default"].isValidElement(element)) {
  20005. var splitElement = (0, _splitReactElement["default"])(element);
  20006. if (typeof splitElement === 'string') {
  20007. return 0;
  20008. }
  20009. var length = splitElement[type].length;
  20010. var child = _react["default"].Children.toArray(element.props.children)[0];
  20011. return length + (child && _react["default"].isValidElement(child) ? getElementTagLength(child, type) : 0);
  20012. }
  20013. if ((0, _typeof2["default"])(element) === 'object') {
  20014. return element[type] ? element[type].length : 0;
  20015. }
  20016. return 0;
  20017. };
  20018. var _default = getElementTagLength;
  20019. exports["default"] = _default;
  20020. });
  20021. index.unwrapExports(getElementTagLength_1);
  20022. var blockEntities = index.createCommonjsModule(function (module, exports) {
  20023. Object.defineProperty(exports, "__esModule", {
  20024. value: true
  20025. });
  20026. exports["default"] = void 0;
  20027. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  20028. var _updateMutation = interopRequireDefault(updateMutation_1);
  20029. var _rangeSort = interopRequireDefault(rangeSort);
  20030. var _getElementHTML = interopRequireDefault(getElementHTML_1);
  20031. var _getElementTagLength = interopRequireDefault(getElementTagLength_1);
  20032. var converter = function converter() {
  20033. var originalText = arguments.length > 1 ? arguments[1] : undefined;
  20034. return originalText;
  20035. };
  20036. var _default = function _default(block, entityMap) {
  20037. var entityConverter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : converter;
  20038. var resultText = (0, _toConsumableArray2["default"])(block.text);
  20039. var getEntityHTML = entityConverter;
  20040. if (entityConverter.__isMiddleware) {
  20041. getEntityHTML = entityConverter(converter);
  20042. }
  20043. if (Object.prototype.hasOwnProperty.call(block, 'entityRanges') && block.entityRanges.length > 0) {
  20044. var entities = block.entityRanges.sort(_rangeSort["default"]);
  20045. var styles = block.inlineStyleRanges;
  20046. var _loop = function _loop(index) {
  20047. var entityRange = entities[index];
  20048. var entity = entityMap[entityRange.key];
  20049. var originalText = resultText.slice(entityRange.offset, entityRange.offset + entityRange.length).join('');
  20050. var entityHTML = getEntityHTML(entity, originalText);
  20051. var converted = (0, _toConsumableArray2["default"])((0, _getElementHTML["default"])(entityHTML, originalText) || originalText);
  20052. var prefixLength = (0, _getElementTagLength["default"])(entityHTML, 'start');
  20053. var suffixLength = (0, _getElementTagLength["default"])(entityHTML, 'end');
  20054. var updateLaterMutation = function updateLaterMutation(mutation, mutationIndex) {
  20055. if (mutationIndex > index || Object.prototype.hasOwnProperty.call(mutation, 'style')) {
  20056. return (0, _updateMutation["default"])(mutation, entityRange.offset, entityRange.length, converted.length, prefixLength, suffixLength);
  20057. }
  20058. return mutation;
  20059. };
  20060. var updateLaterMutations = function updateLaterMutations(mutationList) {
  20061. return mutationList.reduce(function (acc, mutation, mutationIndex) {
  20062. var updatedMutation = updateLaterMutation(mutation, mutationIndex);
  20063. if (Array.isArray(updatedMutation)) {
  20064. return acc.concat(updatedMutation);
  20065. }
  20066. return acc.concat([updatedMutation]);
  20067. }, []);
  20068. };
  20069. entities = updateLaterMutations(entities);
  20070. styles = updateLaterMutations(styles);
  20071. resultText = [].concat((0, _toConsumableArray2["default"])(resultText.slice(0, entityRange.offset)), (0, _toConsumableArray2["default"])(converted), (0, _toConsumableArray2["default"])(resultText.slice(entityRange.offset + entityRange.length)));
  20072. };
  20073. for (var index = 0; index < entities.length; index++) {
  20074. _loop(index);
  20075. }
  20076. return Object.assign({}, block, {
  20077. text: resultText.join(''),
  20078. inlineStyleRanges: styles,
  20079. entityRanges: entities
  20080. });
  20081. }
  20082. return block;
  20083. };
  20084. exports["default"] = _default;
  20085. });
  20086. index.unwrapExports(blockEntities);
  20087. var styleObjectFunction = index.createCommonjsModule(function (module, exports) {
  20088. Object.defineProperty(exports, "__esModule", {
  20089. value: true
  20090. });
  20091. exports["default"] = void 0;
  20092. var _default = function _default(object) {
  20093. return function (style) {
  20094. if (typeof object === 'function') {
  20095. return object(style);
  20096. }
  20097. return object[style];
  20098. };
  20099. };
  20100. exports["default"] = _default;
  20101. });
  20102. index.unwrapExports(styleObjectFunction);
  20103. var accumulateFunction = index.createCommonjsModule(function (module, exports) {
  20104. Object.defineProperty(exports, "__esModule", {
  20105. value: true
  20106. });
  20107. exports["default"] = void 0;
  20108. var _default = function _default(newFn, rest) {
  20109. return function () {
  20110. var newResult = newFn.apply(void 0, arguments);
  20111. if (newResult !== undefined && newResult !== null) {
  20112. return newResult;
  20113. }
  20114. return rest.apply(void 0, arguments);
  20115. };
  20116. };
  20117. exports["default"] = _default;
  20118. });
  20119. index.unwrapExports(accumulateFunction);
  20120. var defaultInlineHTML_1 = index.createCommonjsModule(function (module, exports) {
  20121. Object.defineProperty(exports, "__esModule", {
  20122. value: true
  20123. });
  20124. exports["default"] = defaultInlineHTML;
  20125. var _react = interopRequireDefault(React__default);
  20126. function defaultInlineHTML(style) {
  20127. switch (style) {
  20128. case 'BOLD':
  20129. return _react["default"].createElement("strong", null);
  20130. case 'ITALIC':
  20131. return _react["default"].createElement("em", null);
  20132. case 'UNDERLINE':
  20133. return _react["default"].createElement("u", null);
  20134. case 'CODE':
  20135. return _react["default"].createElement("code", null);
  20136. default:
  20137. return {
  20138. start: '',
  20139. end: ''
  20140. };
  20141. }
  20142. }
  20143. });
  20144. index.unwrapExports(defaultInlineHTML_1);
  20145. var blockInlineStyles = index.createCommonjsModule(function (module, exports) {
  20146. Object.defineProperty(exports, "__esModule", {
  20147. value: true
  20148. });
  20149. exports["default"] = void 0;
  20150. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  20151. var _invariant = interopRequireDefault(browser);
  20152. var _styleObjectFunction = interopRequireDefault(styleObjectFunction);
  20153. var _accumulateFunction = interopRequireDefault(accumulateFunction);
  20154. var _getElementHTML = interopRequireDefault(getElementHTML_1);
  20155. var _rangeSort = interopRequireDefault(rangeSort);
  20156. var _defaultInlineHTML = interopRequireDefault(defaultInlineHTML_1);
  20157. var subtractStyles = function subtractStyles(original, toRemove) {
  20158. return original.filter(function (el) {
  20159. return !toRemove.some(function (elToRemove) {
  20160. return elToRemove.style === el.style;
  20161. });
  20162. });
  20163. };
  20164. var popEndingStyles = function popEndingStyles(styleStack, endingStyles) {
  20165. return endingStyles.reduceRight(function (stack, style) {
  20166. var styleToRemove = stack[stack.length - 1];
  20167. (0, _invariant["default"])(styleToRemove.style === style.style, "Style ".concat(styleToRemove.style, " to be removed doesn't match expected ").concat(style.style));
  20168. return stack.slice(0, -1);
  20169. }, styleStack);
  20170. };
  20171. var characterStyles = function characterStyles(offset, ranges) {
  20172. return ranges.filter(function (range) {
  20173. return offset >= range.offset && offset < range.offset + range.length;
  20174. });
  20175. };
  20176. var rangeIsSubset = function rangeIsSubset(firstRange, secondRange) {
  20177. // returns true if the second range is a subset of the first
  20178. var secondStartWithinFirst = firstRange.offset <= secondRange.offset;
  20179. var secondEndWithinFirst = firstRange.offset + firstRange.length >= secondRange.offset + secondRange.length;
  20180. return secondStartWithinFirst && secondEndWithinFirst;
  20181. };
  20182. var latestStyleLast = function latestStyleLast(s1, s2) {
  20183. // make sure longer-lasting styles are added first
  20184. var s2endIndex = s2.offset + s2.length;
  20185. var s1endIndex = s1.offset + s1.length;
  20186. return s2endIndex - s1endIndex;
  20187. };
  20188. var getStylesToReset = function getStylesToReset(remainingStyles, newStyles) {
  20189. var i = 0;
  20190. while (i < remainingStyles.length) {
  20191. if (newStyles.every(rangeIsSubset.bind(null, remainingStyles[i]))) {
  20192. i++;
  20193. } else {
  20194. return remainingStyles.slice(i);
  20195. }
  20196. }
  20197. return [];
  20198. };
  20199. var appendStartMarkup = function appendStartMarkup(inlineHTML, string, styleRange) {
  20200. return string + (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).start;
  20201. };
  20202. var prependEndMarkup = function prependEndMarkup(inlineHTML, string, styleRange) {
  20203. return (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).end + string;
  20204. };
  20205. var defaultCustomInlineHTML = function defaultCustomInlineHTML(next) {
  20206. return function (style) {
  20207. return next(style);
  20208. };
  20209. };
  20210. defaultCustomInlineHTML.__isMiddleware = true;
  20211. var _default = function _default(rawBlock) {
  20212. var customInlineHTML = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCustomInlineHTML;
  20213. (0, _invariant["default"])(rawBlock !== null && rawBlock !== undefined, 'Expected raw block to be non-null');
  20214. var inlineHTML;
  20215. if (customInlineHTML.__isMiddleware === true) {
  20216. inlineHTML = customInlineHTML(_defaultInlineHTML["default"]);
  20217. } else {
  20218. inlineHTML = (0, _accumulateFunction["default"])((0, _styleObjectFunction["default"])(customInlineHTML), (0, _styleObjectFunction["default"])(_defaultInlineHTML["default"]));
  20219. }
  20220. var result = '';
  20221. var styleStack = [];
  20222. var sortedRanges = rawBlock.inlineStyleRanges.sort(_rangeSort["default"]);
  20223. var originalTextArray = (0, _toConsumableArray2["default"])(rawBlock.text);
  20224. for (var i = 0; i < originalTextArray.length; i++) {
  20225. var styles = characterStyles(i, sortedRanges);
  20226. var endingStyles = subtractStyles(styleStack, styles);
  20227. var newStyles = subtractStyles(styles, styleStack);
  20228. var remainingStyles = subtractStyles(styleStack, endingStyles); // reset styles: look for any already existing styles that will need to
  20229. // end before styles that are being added on this character. to solve this
  20230. // close out those current tags and all nested children,
  20231. // then open new ones nested within the new styles.
  20232. var resetStyles = getStylesToReset(remainingStyles, newStyles);
  20233. var openingStyles = resetStyles.concat(newStyles).sort(latestStyleLast);
  20234. var openingStyleTags = openingStyles.reduce(appendStartMarkup.bind(null, inlineHTML), '');
  20235. var endingStyleTags = endingStyles.concat(resetStyles).reduce(prependEndMarkup.bind(null, inlineHTML), '');
  20236. result += endingStyleTags + openingStyleTags + originalTextArray[i];
  20237. styleStack = popEndingStyles(styleStack, resetStyles.concat(endingStyles));
  20238. styleStack = styleStack.concat(openingStyles);
  20239. (0, _invariant["default"])(styleStack.length === styles.length, "Character ".concat(i, ": ").concat(styleStack.length - styles.length, " styles left on stack that should no longer be there"));
  20240. }
  20241. result = styleStack.reduceRight(function (res, openStyle) {
  20242. return res + (0, _getElementHTML["default"])(inlineHTML(openStyle.style)).end;
  20243. }, result);
  20244. return result;
  20245. };
  20246. exports["default"] = _default;
  20247. });
  20248. index.unwrapExports(blockInlineStyles);
  20249. var blockTypeObjectFunction = index.createCommonjsModule(function (module, exports) {
  20250. Object.defineProperty(exports, "__esModule", {
  20251. value: true
  20252. });
  20253. exports["default"] = void 0;
  20254. var _default = function _default(typeObject) {
  20255. return function (block) {
  20256. if (typeof typeObject === 'function') {
  20257. // handle case where typeObject is already a function
  20258. return typeObject(block);
  20259. }
  20260. return typeObject[block.type];
  20261. };
  20262. };
  20263. exports["default"] = _default;
  20264. });
  20265. index.unwrapExports(blockTypeObjectFunction);
  20266. var getBlockTags_1 = index.createCommonjsModule(function (module, exports) {
  20267. Object.defineProperty(exports, "__esModule", {
  20268. value: true
  20269. });
  20270. exports["default"] = getBlockTags;
  20271. var _invariant = interopRequireDefault(browser);
  20272. var _react = interopRequireDefault(React__default);
  20273. var _server = interopRequireDefault(server);
  20274. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  20275. function hasChildren(element) {
  20276. return _react["default"].isValidElement(element) && _react["default"].Children.count(element.props.children) > 0;
  20277. }
  20278. function getBlockTags(blockHTML) {
  20279. (0, _invariant["default"])(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
  20280. if (typeof blockHTML === 'string') {
  20281. return blockHTML;
  20282. }
  20283. if (_react["default"].isValidElement(blockHTML)) {
  20284. if (hasChildren(blockHTML)) {
  20285. return _server["default"].renderToStaticMarkup(blockHTML);
  20286. }
  20287. return (0, _splitReactElement["default"])(blockHTML);
  20288. }
  20289. if (Object.prototype.hasOwnProperty.call(blockHTML, 'element') && _react["default"].isValidElement(blockHTML.element)) {
  20290. return Object.assign({}, blockHTML, (0, _splitReactElement["default"])(blockHTML.element));
  20291. }
  20292. (0, _invariant["default"])(Object.prototype.hasOwnProperty.call(blockHTML, 'start') && Object.prototype.hasOwnProperty.call(blockHTML, 'end'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
  20293. return blockHTML;
  20294. }
  20295. });
  20296. index.unwrapExports(getBlockTags_1);
  20297. var getNestedBlockTags_1 = index.createCommonjsModule(function (module, exports) {
  20298. Object.defineProperty(exports, "__esModule", {
  20299. value: true
  20300. });
  20301. exports["default"] = getNestedBlockTags;
  20302. var _invariant = interopRequireDefault(browser);
  20303. var _react = interopRequireDefault(React__default);
  20304. var _splitReactElement2 = interopRequireDefault(splitReactElement_1);
  20305. function getNestedBlockTags(blockHTML) {
  20306. (0, _invariant["default"])(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
  20307. if (_react["default"].isValidElement(blockHTML.nest)) {
  20308. var _splitReactElement = (0, _splitReactElement2["default"])(blockHTML.nest),
  20309. start = _splitReactElement.start,
  20310. end = _splitReactElement.end;
  20311. return Object.assign({}, blockHTML, {
  20312. nestStart: start,
  20313. nestEnd: end
  20314. });
  20315. }
  20316. (0, _invariant["default"])(Object.prototype.hasOwnProperty.call(blockHTML, 'nestStart') && Object.prototype.hasOwnProperty.call(blockHTML, 'nestEnd'), 'convertToHTML: received block information without either a ReactElement or an object with start/end tags');
  20317. return blockHTML;
  20318. }
  20319. });
  20320. index.unwrapExports(getNestedBlockTags_1);
  20321. var defaultBlockHTML = index.createCommonjsModule(function (module, exports) {
  20322. Object.defineProperty(exports, "__esModule", {
  20323. value: true
  20324. });
  20325. exports["default"] = void 0;
  20326. var _react = interopRequireDefault(React__default);
  20327. var _default = {
  20328. unstyled: _react["default"].createElement("p", null),
  20329. paragraph: _react["default"].createElement("p", null),
  20330. 'header-one': _react["default"].createElement("h1", null),
  20331. 'header-two': _react["default"].createElement("h2", null),
  20332. 'header-three': _react["default"].createElement("h3", null),
  20333. 'header-four': _react["default"].createElement("h4", null),
  20334. 'header-five': _react["default"].createElement("h5", null),
  20335. 'header-six': _react["default"].createElement("h6", null),
  20336. blockquote: _react["default"].createElement("blockquote", null),
  20337. 'unordered-list-item': {
  20338. element: _react["default"].createElement("li", null),
  20339. nest: _react["default"].createElement("ul", null)
  20340. },
  20341. 'ordered-list-item': {
  20342. element: _react["default"].createElement("li", null),
  20343. nest: _react["default"].createElement("ol", null)
  20344. },
  20345. media: _react["default"].createElement("figure", null),
  20346. atomic: _react["default"].createElement("figure", null)
  20347. };
  20348. exports["default"] = _default;
  20349. });
  20350. index.unwrapExports(defaultBlockHTML);
  20351. var convertToHTML_1 = index.createCommonjsModule(function (module, exports) {
  20352. Object.defineProperty(exports, "__esModule", {
  20353. value: true
  20354. });
  20355. exports["default"] = void 0;
  20356. var _invariant = interopRequireDefault(browser);
  20357. var _react = interopRequireDefault(React__default);
  20358. var _server = interopRequireDefault(server);
  20359. var _encodeBlock = interopRequireDefault(encodeBlock);
  20360. var _blockEntities = interopRequireDefault(blockEntities);
  20361. var _blockInlineStyles = interopRequireDefault(blockInlineStyles);
  20362. var _accumulateFunction = interopRequireDefault(accumulateFunction);
  20363. var _blockTypeObjectFunction = interopRequireDefault(blockTypeObjectFunction);
  20364. var _getBlockTags = interopRequireDefault(getBlockTags_1);
  20365. var _getNestedBlockTags = interopRequireDefault(getNestedBlockTags_1);
  20366. var _defaultBlockHTML = interopRequireDefault(defaultBlockHTML);
  20367. // import Immutable from 'immutable'; // eslint-disable-line no-unused-vars
  20368. var defaultEntityToHTML = function defaultEntityToHTML(entity, originalText) {
  20369. return originalText;
  20370. };
  20371. var convertToHTML = function convertToHTML(_ref) {
  20372. var _ref$styleToHTML = _ref.styleToHTML,
  20373. styleToHTML = _ref$styleToHTML === void 0 ? {} : _ref$styleToHTML,
  20374. _ref$blockToHTML = _ref.blockToHTML,
  20375. blockToHTML = _ref$blockToHTML === void 0 ? {} : _ref$blockToHTML,
  20376. _ref$entityToHTML = _ref.entityToHTML,
  20377. entityToHTML = _ref$entityToHTML === void 0 ? defaultEntityToHTML : _ref$entityToHTML;
  20378. return function (contentState) {
  20379. (0, _invariant["default"])(contentState !== null && contentState !== undefined, 'Expected contentState to be non-null');
  20380. var getBlockHTML;
  20381. if (blockToHTML.__isMiddleware === true) {
  20382. getBlockHTML = blockToHTML((0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"]));
  20383. } else {
  20384. getBlockHTML = (0, _accumulateFunction["default"])((0, _blockTypeObjectFunction["default"])(blockToHTML), (0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"]));
  20385. }
  20386. var rawState = (0, Draft.convertToRaw)(contentState);
  20387. var listStack = [];
  20388. var result = rawState.blocks.map(function (block) {
  20389. var type = block.type,
  20390. depth = block.depth;
  20391. var closeNestTags = '';
  20392. var openNestTags = '';
  20393. var blockHTMLResult = getBlockHTML(block);
  20394. if (!blockHTMLResult) {
  20395. throw new Error("convertToHTML: missing HTML definition for block with type ".concat(block.type));
  20396. }
  20397. if (!blockHTMLResult.nest) {
  20398. // this block can't be nested, so reset all nesting if necessary
  20399. closeNestTags = listStack.reduceRight(function (string, nestedBlock) {
  20400. return string + (0, _getNestedBlockTags["default"])(getBlockHTML(nestedBlock)).nestEnd;
  20401. }, '');
  20402. listStack = [];
  20403. } else {
  20404. while (depth + 1 !== listStack.length || type !== listStack[depth].type) {
  20405. if (depth + 1 === listStack.length) {
  20406. // depth is right but doesn't match type
  20407. var blockToClose = listStack[depth];
  20408. closeNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(blockToClose)).nestEnd;
  20409. openNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(block)).nestStart;
  20410. listStack[depth] = block;
  20411. } else if (depth + 1 < listStack.length) {
  20412. var _blockToClose = listStack[listStack.length - 1];
  20413. closeNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(_blockToClose)).nestEnd;
  20414. listStack = listStack.slice(0, -1);
  20415. } else {
  20416. openNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(block)).nestStart;
  20417. listStack.push(block);
  20418. }
  20419. }
  20420. }
  20421. var innerHTML = (0, _blockInlineStyles["default"])((0, _blockEntities["default"])((0, _encodeBlock["default"])(block), rawState.entityMap, entityToHTML), styleToHTML);
  20422. var blockHTML = (0, _getBlockTags["default"])(getBlockHTML(block));
  20423. var html;
  20424. if (typeof blockHTML === 'string') {
  20425. html = blockHTML;
  20426. } else {
  20427. html = blockHTML.start + innerHTML + blockHTML.end;
  20428. }
  20429. if (innerHTML.length === 0 && Object.prototype.hasOwnProperty.call(blockHTML, 'empty')) {
  20430. if (_react["default"].isValidElement(blockHTML.empty)) {
  20431. html = _server["default"].renderToStaticMarkup(blockHTML.empty);
  20432. } else {
  20433. html = blockHTML.empty;
  20434. }
  20435. }
  20436. return closeNestTags + openNestTags + html;
  20437. }).join('');
  20438. result = listStack.reduce(function (res, nestBlock) {
  20439. return res + (0, _getNestedBlockTags["default"])(getBlockHTML(nestBlock)).nestEnd;
  20440. }, result);
  20441. return result;
  20442. };
  20443. };
  20444. var _default = function _default() {
  20445. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  20446. args[_key] = arguments[_key];
  20447. }
  20448. if (args.length === 1 && Object.prototype.hasOwnProperty.call(args[0], '_map') && args[0].getBlockMap != null) {
  20449. // skip higher-order function and use defaults
  20450. return convertToHTML({}).apply(void 0, args);
  20451. }
  20452. return convertToHTML.apply(void 0, args);
  20453. };
  20454. exports["default"] = _default;
  20455. });
  20456. index.unwrapExports(convertToHTML_1);
  20457. var immutable$2 = index.createCommonjsModule(function (module, exports) {
  20458. /**
  20459. * Copyright (c) 2014-2015, Facebook, Inc.
  20460. * All rights reserved.
  20461. *
  20462. * This source code is licensed under the BSD-style license found in the
  20463. * LICENSE file in the root directory of this source tree. An additional grant
  20464. * of patent rights can be found in the PATENTS file in the same directory.
  20465. */
  20466. (function (global, factory) {
  20467. module.exports = factory() ;
  20468. }(index.commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
  20469. function createClass(ctor, superClass) {
  20470. if (superClass) {
  20471. ctor.prototype = Object.create(superClass.prototype);
  20472. }
  20473. ctor.prototype.constructor = ctor;
  20474. }
  20475. function Iterable(value) {
  20476. return isIterable(value) ? value : Seq(value);
  20477. }
  20478. createClass(KeyedIterable, Iterable);
  20479. function KeyedIterable(value) {
  20480. return isKeyed(value) ? value : KeyedSeq(value);
  20481. }
  20482. createClass(IndexedIterable, Iterable);
  20483. function IndexedIterable(value) {
  20484. return isIndexed(value) ? value : IndexedSeq(value);
  20485. }
  20486. createClass(SetIterable, Iterable);
  20487. function SetIterable(value) {
  20488. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  20489. }
  20490. function isIterable(maybeIterable) {
  20491. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  20492. }
  20493. function isKeyed(maybeKeyed) {
  20494. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  20495. }
  20496. function isIndexed(maybeIndexed) {
  20497. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  20498. }
  20499. function isAssociative(maybeAssociative) {
  20500. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  20501. }
  20502. function isOrdered(maybeOrdered) {
  20503. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  20504. }
  20505. Iterable.isIterable = isIterable;
  20506. Iterable.isKeyed = isKeyed;
  20507. Iterable.isIndexed = isIndexed;
  20508. Iterable.isAssociative = isAssociative;
  20509. Iterable.isOrdered = isOrdered;
  20510. Iterable.Keyed = KeyedIterable;
  20511. Iterable.Indexed = IndexedIterable;
  20512. Iterable.Set = SetIterable;
  20513. var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  20514. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  20515. var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  20516. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  20517. // Used for setting prototype methods that IE8 chokes on.
  20518. var DELETE = 'delete';
  20519. // Constants describing the size of trie nodes.
  20520. var SHIFT = 5; // Resulted in best performance after ______?
  20521. var SIZE = 1 << SHIFT;
  20522. var MASK = SIZE - 1;
  20523. // A consistent shared value representing "not set" which equals nothing other
  20524. // than itself, and nothing that could be provided externally.
  20525. var NOT_SET = {};
  20526. // Boolean references, Rough equivalent of `bool &`.
  20527. var CHANGE_LENGTH = { value: false };
  20528. var DID_ALTER = { value: false };
  20529. function MakeRef(ref) {
  20530. ref.value = false;
  20531. return ref;
  20532. }
  20533. function SetRef(ref) {
  20534. ref && (ref.value = true);
  20535. }
  20536. // A function which returns a value representing an "owner" for transient writes
  20537. // to tries. The return value will only ever equal itself, and will not equal
  20538. // the return of any subsequent call of this function.
  20539. function OwnerID() {}
  20540. // http://jsperf.com/copy-array-inline
  20541. function arrCopy(arr, offset) {
  20542. offset = offset || 0;
  20543. var len = Math.max(0, arr.length - offset);
  20544. var newArr = new Array(len);
  20545. for (var ii = 0; ii < len; ii++) {
  20546. newArr[ii] = arr[ii + offset];
  20547. }
  20548. return newArr;
  20549. }
  20550. function ensureSize(iter) {
  20551. if (iter.size === undefined) {
  20552. iter.size = iter.__iterate(returnTrue);
  20553. }
  20554. return iter.size;
  20555. }
  20556. function wrapIndex(iter, index) {
  20557. // This implements "is array index" which the ECMAString spec defines as:
  20558. //
  20559. // A String property name P is an array index if and only if
  20560. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  20561. // to 2^32−1.
  20562. //
  20563. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  20564. if (typeof index !== 'number') {
  20565. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  20566. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  20567. return NaN;
  20568. }
  20569. index = uint32Index;
  20570. }
  20571. return index < 0 ? ensureSize(iter) + index : index;
  20572. }
  20573. function returnTrue() {
  20574. return true;
  20575. }
  20576. function wholeSlice(begin, end, size) {
  20577. return (begin === 0 || (size !== undefined && begin <= -size)) &&
  20578. (end === undefined || (size !== undefined && end >= size));
  20579. }
  20580. function resolveBegin(begin, size) {
  20581. return resolveIndex(begin, size, 0);
  20582. }
  20583. function resolveEnd(end, size) {
  20584. return resolveIndex(end, size, size);
  20585. }
  20586. function resolveIndex(index, size, defaultIndex) {
  20587. return index === undefined ?
  20588. defaultIndex :
  20589. index < 0 ?
  20590. Math.max(0, size + index) :
  20591. size === undefined ?
  20592. index :
  20593. Math.min(size, index);
  20594. }
  20595. /* global Symbol */
  20596. var ITERATE_KEYS = 0;
  20597. var ITERATE_VALUES = 1;
  20598. var ITERATE_ENTRIES = 2;
  20599. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  20600. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  20601. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  20602. function Iterator(next) {
  20603. this.next = next;
  20604. }
  20605. Iterator.prototype.toString = function() {
  20606. return '[Iterator]';
  20607. };
  20608. Iterator.KEYS = ITERATE_KEYS;
  20609. Iterator.VALUES = ITERATE_VALUES;
  20610. Iterator.ENTRIES = ITERATE_ENTRIES;
  20611. Iterator.prototype.inspect =
  20612. Iterator.prototype.toSource = function () { return this.toString(); };
  20613. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  20614. return this;
  20615. };
  20616. function iteratorValue(type, k, v, iteratorResult) {
  20617. var value = type === 0 ? k : type === 1 ? v : [k, v];
  20618. iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
  20619. value: value, done: false
  20620. });
  20621. return iteratorResult;
  20622. }
  20623. function iteratorDone() {
  20624. return { value: undefined, done: true };
  20625. }
  20626. function hasIterator(maybeIterable) {
  20627. return !!getIteratorFn(maybeIterable);
  20628. }
  20629. function isIterator(maybeIterator) {
  20630. return maybeIterator && typeof maybeIterator.next === 'function';
  20631. }
  20632. function getIterator(iterable) {
  20633. var iteratorFn = getIteratorFn(iterable);
  20634. return iteratorFn && iteratorFn.call(iterable);
  20635. }
  20636. function getIteratorFn(iterable) {
  20637. var iteratorFn = iterable && (
  20638. (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  20639. iterable[FAUX_ITERATOR_SYMBOL]
  20640. );
  20641. if (typeof iteratorFn === 'function') {
  20642. return iteratorFn;
  20643. }
  20644. }
  20645. function isArrayLike(value) {
  20646. return value && typeof value.length === 'number';
  20647. }
  20648. createClass(Seq, Iterable);
  20649. function Seq(value) {
  20650. return value === null || value === undefined ? emptySequence() :
  20651. isIterable(value) ? value.toSeq() : seqFromValue(value);
  20652. }
  20653. Seq.of = function(/*...values*/) {
  20654. return Seq(arguments);
  20655. };
  20656. Seq.prototype.toSeq = function() {
  20657. return this;
  20658. };
  20659. Seq.prototype.toString = function() {
  20660. return this.__toString('Seq {', '}');
  20661. };
  20662. Seq.prototype.cacheResult = function() {
  20663. if (!this._cache && this.__iterateUncached) {
  20664. this._cache = this.entrySeq().toArray();
  20665. this.size = this._cache.length;
  20666. }
  20667. return this;
  20668. };
  20669. // abstract __iterateUncached(fn, reverse)
  20670. Seq.prototype.__iterate = function(fn, reverse) {
  20671. return seqIterate(this, fn, reverse, true);
  20672. };
  20673. // abstract __iteratorUncached(type, reverse)
  20674. Seq.prototype.__iterator = function(type, reverse) {
  20675. return seqIterator(this, type, reverse, true);
  20676. };
  20677. createClass(KeyedSeq, Seq);
  20678. function KeyedSeq(value) {
  20679. return value === null || value === undefined ?
  20680. emptySequence().toKeyedSeq() :
  20681. isIterable(value) ?
  20682. (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
  20683. keyedSeqFromValue(value);
  20684. }
  20685. KeyedSeq.prototype.toKeyedSeq = function() {
  20686. return this;
  20687. };
  20688. createClass(IndexedSeq, Seq);
  20689. function IndexedSeq(value) {
  20690. return value === null || value === undefined ? emptySequence() :
  20691. !isIterable(value) ? indexedSeqFromValue(value) :
  20692. isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
  20693. }
  20694. IndexedSeq.of = function(/*...values*/) {
  20695. return IndexedSeq(arguments);
  20696. };
  20697. IndexedSeq.prototype.toIndexedSeq = function() {
  20698. return this;
  20699. };
  20700. IndexedSeq.prototype.toString = function() {
  20701. return this.__toString('Seq [', ']');
  20702. };
  20703. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  20704. return seqIterate(this, fn, reverse, false);
  20705. };
  20706. IndexedSeq.prototype.__iterator = function(type, reverse) {
  20707. return seqIterator(this, type, reverse, false);
  20708. };
  20709. createClass(SetSeq, Seq);
  20710. function SetSeq(value) {
  20711. return (
  20712. value === null || value === undefined ? emptySequence() :
  20713. !isIterable(value) ? indexedSeqFromValue(value) :
  20714. isKeyed(value) ? value.entrySeq() : value
  20715. ).toSetSeq();
  20716. }
  20717. SetSeq.of = function(/*...values*/) {
  20718. return SetSeq(arguments);
  20719. };
  20720. SetSeq.prototype.toSetSeq = function() {
  20721. return this;
  20722. };
  20723. Seq.isSeq = isSeq;
  20724. Seq.Keyed = KeyedSeq;
  20725. Seq.Set = SetSeq;
  20726. Seq.Indexed = IndexedSeq;
  20727. var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  20728. Seq.prototype[IS_SEQ_SENTINEL] = true;
  20729. createClass(ArraySeq, IndexedSeq);
  20730. function ArraySeq(array) {
  20731. this._array = array;
  20732. this.size = array.length;
  20733. }
  20734. ArraySeq.prototype.get = function(index, notSetValue) {
  20735. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  20736. };
  20737. ArraySeq.prototype.__iterate = function(fn, reverse) {
  20738. var array = this._array;
  20739. var maxIndex = array.length - 1;
  20740. for (var ii = 0; ii <= maxIndex; ii++) {
  20741. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  20742. return ii + 1;
  20743. }
  20744. }
  20745. return ii;
  20746. };
  20747. ArraySeq.prototype.__iterator = function(type, reverse) {
  20748. var array = this._array;
  20749. var maxIndex = array.length - 1;
  20750. var ii = 0;
  20751. return new Iterator(function()
  20752. {return ii > maxIndex ?
  20753. iteratorDone() :
  20754. iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
  20755. );
  20756. };
  20757. createClass(ObjectSeq, KeyedSeq);
  20758. function ObjectSeq(object) {
  20759. var keys = Object.keys(object);
  20760. this._object = object;
  20761. this._keys = keys;
  20762. this.size = keys.length;
  20763. }
  20764. ObjectSeq.prototype.get = function(key, notSetValue) {
  20765. if (notSetValue !== undefined && !this.has(key)) {
  20766. return notSetValue;
  20767. }
  20768. return this._object[key];
  20769. };
  20770. ObjectSeq.prototype.has = function(key) {
  20771. return this._object.hasOwnProperty(key);
  20772. };
  20773. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  20774. var object = this._object;
  20775. var keys = this._keys;
  20776. var maxIndex = keys.length - 1;
  20777. for (var ii = 0; ii <= maxIndex; ii++) {
  20778. var key = keys[reverse ? maxIndex - ii : ii];
  20779. if (fn(object[key], key, this) === false) {
  20780. return ii + 1;
  20781. }
  20782. }
  20783. return ii;
  20784. };
  20785. ObjectSeq.prototype.__iterator = function(type, reverse) {
  20786. var object = this._object;
  20787. var keys = this._keys;
  20788. var maxIndex = keys.length - 1;
  20789. var ii = 0;
  20790. return new Iterator(function() {
  20791. var key = keys[reverse ? maxIndex - ii : ii];
  20792. return ii++ > maxIndex ?
  20793. iteratorDone() :
  20794. iteratorValue(type, key, object[key]);
  20795. });
  20796. };
  20797. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  20798. createClass(IterableSeq, IndexedSeq);
  20799. function IterableSeq(iterable) {
  20800. this._iterable = iterable;
  20801. this.size = iterable.length || iterable.size;
  20802. }
  20803. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  20804. if (reverse) {
  20805. return this.cacheResult().__iterate(fn, reverse);
  20806. }
  20807. var iterable = this._iterable;
  20808. var iterator = getIterator(iterable);
  20809. var iterations = 0;
  20810. if (isIterator(iterator)) {
  20811. var step;
  20812. while (!(step = iterator.next()).done) {
  20813. if (fn(step.value, iterations++, this) === false) {
  20814. break;
  20815. }
  20816. }
  20817. }
  20818. return iterations;
  20819. };
  20820. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  20821. if (reverse) {
  20822. return this.cacheResult().__iterator(type, reverse);
  20823. }
  20824. var iterable = this._iterable;
  20825. var iterator = getIterator(iterable);
  20826. if (!isIterator(iterator)) {
  20827. return new Iterator(iteratorDone);
  20828. }
  20829. var iterations = 0;
  20830. return new Iterator(function() {
  20831. var step = iterator.next();
  20832. return step.done ? step : iteratorValue(type, iterations++, step.value);
  20833. });
  20834. };
  20835. createClass(IteratorSeq, IndexedSeq);
  20836. function IteratorSeq(iterator) {
  20837. this._iterator = iterator;
  20838. this._iteratorCache = [];
  20839. }
  20840. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  20841. if (reverse) {
  20842. return this.cacheResult().__iterate(fn, reverse);
  20843. }
  20844. var iterator = this._iterator;
  20845. var cache = this._iteratorCache;
  20846. var iterations = 0;
  20847. while (iterations < cache.length) {
  20848. if (fn(cache[iterations], iterations++, this) === false) {
  20849. return iterations;
  20850. }
  20851. }
  20852. var step;
  20853. while (!(step = iterator.next()).done) {
  20854. var val = step.value;
  20855. cache[iterations] = val;
  20856. if (fn(val, iterations++, this) === false) {
  20857. break;
  20858. }
  20859. }
  20860. return iterations;
  20861. };
  20862. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  20863. if (reverse) {
  20864. return this.cacheResult().__iterator(type, reverse);
  20865. }
  20866. var iterator = this._iterator;
  20867. var cache = this._iteratorCache;
  20868. var iterations = 0;
  20869. return new Iterator(function() {
  20870. if (iterations >= cache.length) {
  20871. var step = iterator.next();
  20872. if (step.done) {
  20873. return step;
  20874. }
  20875. cache[iterations] = step.value;
  20876. }
  20877. return iteratorValue(type, iterations, cache[iterations++]);
  20878. });
  20879. };
  20880. // # pragma Helper functions
  20881. function isSeq(maybeSeq) {
  20882. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  20883. }
  20884. var EMPTY_SEQ;
  20885. function emptySequence() {
  20886. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  20887. }
  20888. function keyedSeqFromValue(value) {
  20889. var seq =
  20890. Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
  20891. isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
  20892. hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
  20893. typeof value === 'object' ? new ObjectSeq(value) :
  20894. undefined;
  20895. if (!seq) {
  20896. throw new TypeError(
  20897. 'Expected Array or iterable object of [k, v] entries, '+
  20898. 'or keyed object: ' + value
  20899. );
  20900. }
  20901. return seq;
  20902. }
  20903. function indexedSeqFromValue(value) {
  20904. var seq = maybeIndexedSeqFromValue(value);
  20905. if (!seq) {
  20906. throw new TypeError(
  20907. 'Expected Array or iterable object of values: ' + value
  20908. );
  20909. }
  20910. return seq;
  20911. }
  20912. function seqFromValue(value) {
  20913. var seq = maybeIndexedSeqFromValue(value) ||
  20914. (typeof value === 'object' && new ObjectSeq(value));
  20915. if (!seq) {
  20916. throw new TypeError(
  20917. 'Expected Array or iterable object of values, or keyed object: ' + value
  20918. );
  20919. }
  20920. return seq;
  20921. }
  20922. function maybeIndexedSeqFromValue(value) {
  20923. return (
  20924. isArrayLike(value) ? new ArraySeq(value) :
  20925. isIterator(value) ? new IteratorSeq(value) :
  20926. hasIterator(value) ? new IterableSeq(value) :
  20927. undefined
  20928. );
  20929. }
  20930. function seqIterate(seq, fn, reverse, useKeys) {
  20931. var cache = seq._cache;
  20932. if (cache) {
  20933. var maxIndex = cache.length - 1;
  20934. for (var ii = 0; ii <= maxIndex; ii++) {
  20935. var entry = cache[reverse ? maxIndex - ii : ii];
  20936. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  20937. return ii + 1;
  20938. }
  20939. }
  20940. return ii;
  20941. }
  20942. return seq.__iterateUncached(fn, reverse);
  20943. }
  20944. function seqIterator(seq, type, reverse, useKeys) {
  20945. var cache = seq._cache;
  20946. if (cache) {
  20947. var maxIndex = cache.length - 1;
  20948. var ii = 0;
  20949. return new Iterator(function() {
  20950. var entry = cache[reverse ? maxIndex - ii : ii];
  20951. return ii++ > maxIndex ?
  20952. iteratorDone() :
  20953. iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  20954. });
  20955. }
  20956. return seq.__iteratorUncached(type, reverse);
  20957. }
  20958. function fromJS(json, converter) {
  20959. return converter ?
  20960. fromJSWith(converter, json, '', {'': json}) :
  20961. fromJSDefault(json);
  20962. }
  20963. function fromJSWith(converter, json, key, parentJSON) {
  20964. if (Array.isArray(json)) {
  20965. return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  20966. }
  20967. if (isPlainObj(json)) {
  20968. return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  20969. }
  20970. return json;
  20971. }
  20972. function fromJSDefault(json) {
  20973. if (Array.isArray(json)) {
  20974. return IndexedSeq(json).map(fromJSDefault).toList();
  20975. }
  20976. if (isPlainObj(json)) {
  20977. return KeyedSeq(json).map(fromJSDefault).toMap();
  20978. }
  20979. return json;
  20980. }
  20981. function isPlainObj(value) {
  20982. return value && (value.constructor === Object || value.constructor === undefined);
  20983. }
  20984. /**
  20985. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  20986. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  20987. *
  20988. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  20989. * value, which is different from the algorithm described by
  20990. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  20991. *
  20992. * This is extended further to allow Objects to describe the values they
  20993. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  20994. *
  20995. * Note: because of this extension, the key equality of Immutable.Map and the
  20996. * value equality of Immutable.Set will differ from ES6 Map and Set.
  20997. *
  20998. * ### Defining custom values
  20999. *
  21000. * The easiest way to describe the value an object represents is by implementing
  21001. * `valueOf`. For example, `Date` represents a value by returning a unix
  21002. * timestamp for `valueOf`:
  21003. *
  21004. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  21005. * var date2 = new Date(1234567890000);
  21006. * date1.valueOf(); // 1234567890000
  21007. * assert( date1 !== date2 );
  21008. * assert( Immutable.is( date1, date2 ) );
  21009. *
  21010. * Note: overriding `valueOf` may have other implications if you use this object
  21011. * where JavaScript expects a primitive, such as implicit string coercion.
  21012. *
  21013. * For more complex types, especially collections, implementing `valueOf` may
  21014. * not be performant. An alternative is to implement `equals` and `hashCode`.
  21015. *
  21016. * `equals` takes another object, presumably of similar type, and returns true
  21017. * if the it is equal. Equality is symmetrical, so the same result should be
  21018. * returned if this and the argument are flipped.
  21019. *
  21020. * assert( a.equals(b) === b.equals(a) );
  21021. *
  21022. * `hashCode` returns a 32bit integer number representing the object which will
  21023. * be used to determine how to store the value object in a Map or Set. You must
  21024. * provide both or neither methods, one must not exist without the other.
  21025. *
  21026. * Also, an important relationship between these methods must be upheld: if two
  21027. * values are equal, they *must* return the same hashCode. If the values are not
  21028. * equal, they might have the same hashCode; this is called a hash collision,
  21029. * and while undesirable for performance reasons, it is acceptable.
  21030. *
  21031. * if (a.equals(b)) {
  21032. * assert( a.hashCode() === b.hashCode() );
  21033. * }
  21034. *
  21035. * All Immutable collections implement `equals` and `hashCode`.
  21036. *
  21037. */
  21038. function is(valueA, valueB) {
  21039. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  21040. return true;
  21041. }
  21042. if (!valueA || !valueB) {
  21043. return false;
  21044. }
  21045. if (typeof valueA.valueOf === 'function' &&
  21046. typeof valueB.valueOf === 'function') {
  21047. valueA = valueA.valueOf();
  21048. valueB = valueB.valueOf();
  21049. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  21050. return true;
  21051. }
  21052. if (!valueA || !valueB) {
  21053. return false;
  21054. }
  21055. }
  21056. if (typeof valueA.equals === 'function' &&
  21057. typeof valueB.equals === 'function' &&
  21058. valueA.equals(valueB)) {
  21059. return true;
  21060. }
  21061. return false;
  21062. }
  21063. function deepEqual(a, b) {
  21064. if (a === b) {
  21065. return true;
  21066. }
  21067. if (
  21068. !isIterable(b) ||
  21069. a.size !== undefined && b.size !== undefined && a.size !== b.size ||
  21070. a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
  21071. isKeyed(a) !== isKeyed(b) ||
  21072. isIndexed(a) !== isIndexed(b) ||
  21073. isOrdered(a) !== isOrdered(b)
  21074. ) {
  21075. return false;
  21076. }
  21077. if (a.size === 0 && b.size === 0) {
  21078. return true;
  21079. }
  21080. var notAssociative = !isAssociative(a);
  21081. if (isOrdered(a)) {
  21082. var entries = a.entries();
  21083. return b.every(function(v, k) {
  21084. var entry = entries.next().value;
  21085. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  21086. }) && entries.next().done;
  21087. }
  21088. var flipped = false;
  21089. if (a.size === undefined) {
  21090. if (b.size === undefined) {
  21091. if (typeof a.cacheResult === 'function') {
  21092. a.cacheResult();
  21093. }
  21094. } else {
  21095. flipped = true;
  21096. var _ = a;
  21097. a = b;
  21098. b = _;
  21099. }
  21100. }
  21101. var allEqual = true;
  21102. var bSize = b.__iterate(function(v, k) {
  21103. if (notAssociative ? !a.has(v) :
  21104. flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
  21105. allEqual = false;
  21106. return false;
  21107. }
  21108. });
  21109. return allEqual && a.size === bSize;
  21110. }
  21111. createClass(Repeat, IndexedSeq);
  21112. function Repeat(value, times) {
  21113. if (!(this instanceof Repeat)) {
  21114. return new Repeat(value, times);
  21115. }
  21116. this._value = value;
  21117. this.size = times === undefined ? Infinity : Math.max(0, times);
  21118. if (this.size === 0) {
  21119. if (EMPTY_REPEAT) {
  21120. return EMPTY_REPEAT;
  21121. }
  21122. EMPTY_REPEAT = this;
  21123. }
  21124. }
  21125. Repeat.prototype.toString = function() {
  21126. if (this.size === 0) {
  21127. return 'Repeat []';
  21128. }
  21129. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  21130. };
  21131. Repeat.prototype.get = function(index, notSetValue) {
  21132. return this.has(index) ? this._value : notSetValue;
  21133. };
  21134. Repeat.prototype.includes = function(searchValue) {
  21135. return is(this._value, searchValue);
  21136. };
  21137. Repeat.prototype.slice = function(begin, end) {
  21138. var size = this.size;
  21139. return wholeSlice(begin, end, size) ? this :
  21140. new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
  21141. };
  21142. Repeat.prototype.reverse = function() {
  21143. return this;
  21144. };
  21145. Repeat.prototype.indexOf = function(searchValue) {
  21146. if (is(this._value, searchValue)) {
  21147. return 0;
  21148. }
  21149. return -1;
  21150. };
  21151. Repeat.prototype.lastIndexOf = function(searchValue) {
  21152. if (is(this._value, searchValue)) {
  21153. return this.size;
  21154. }
  21155. return -1;
  21156. };
  21157. Repeat.prototype.__iterate = function(fn, reverse) {
  21158. for (var ii = 0; ii < this.size; ii++) {
  21159. if (fn(this._value, ii, this) === false) {
  21160. return ii + 1;
  21161. }
  21162. }
  21163. return ii;
  21164. };
  21165. Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
  21166. var ii = 0;
  21167. return new Iterator(function()
  21168. {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
  21169. );
  21170. };
  21171. Repeat.prototype.equals = function(other) {
  21172. return other instanceof Repeat ?
  21173. is(this._value, other._value) :
  21174. deepEqual(other);
  21175. };
  21176. var EMPTY_REPEAT;
  21177. function invariant(condition, error) {
  21178. if (!condition) throw new Error(error);
  21179. }
  21180. createClass(Range, IndexedSeq);
  21181. function Range(start, end, step) {
  21182. if (!(this instanceof Range)) {
  21183. return new Range(start, end, step);
  21184. }
  21185. invariant(step !== 0, 'Cannot step a Range by 0');
  21186. start = start || 0;
  21187. if (end === undefined) {
  21188. end = Infinity;
  21189. }
  21190. step = step === undefined ? 1 : Math.abs(step);
  21191. if (end < start) {
  21192. step = -step;
  21193. }
  21194. this._start = start;
  21195. this._end = end;
  21196. this._step = step;
  21197. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  21198. if (this.size === 0) {
  21199. if (EMPTY_RANGE) {
  21200. return EMPTY_RANGE;
  21201. }
  21202. EMPTY_RANGE = this;
  21203. }
  21204. }
  21205. Range.prototype.toString = function() {
  21206. if (this.size === 0) {
  21207. return 'Range []';
  21208. }
  21209. return 'Range [ ' +
  21210. this._start + '...' + this._end +
  21211. (this._step > 1 ? ' by ' + this._step : '') +
  21212. ' ]';
  21213. };
  21214. Range.prototype.get = function(index, notSetValue) {
  21215. return this.has(index) ?
  21216. this._start + wrapIndex(this, index) * this._step :
  21217. notSetValue;
  21218. };
  21219. Range.prototype.includes = function(searchValue) {
  21220. var possibleIndex = (searchValue - this._start) / this._step;
  21221. return possibleIndex >= 0 &&
  21222. possibleIndex < this.size &&
  21223. possibleIndex === Math.floor(possibleIndex);
  21224. };
  21225. Range.prototype.slice = function(begin, end) {
  21226. if (wholeSlice(begin, end, this.size)) {
  21227. return this;
  21228. }
  21229. begin = resolveBegin(begin, this.size);
  21230. end = resolveEnd(end, this.size);
  21231. if (end <= begin) {
  21232. return new Range(0, 0);
  21233. }
  21234. return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
  21235. };
  21236. Range.prototype.indexOf = function(searchValue) {
  21237. var offsetValue = searchValue - this._start;
  21238. if (offsetValue % this._step === 0) {
  21239. var index = offsetValue / this._step;
  21240. if (index >= 0 && index < this.size) {
  21241. return index
  21242. }
  21243. }
  21244. return -1;
  21245. };
  21246. Range.prototype.lastIndexOf = function(searchValue) {
  21247. return this.indexOf(searchValue);
  21248. };
  21249. Range.prototype.__iterate = function(fn, reverse) {
  21250. var maxIndex = this.size - 1;
  21251. var step = this._step;
  21252. var value = reverse ? this._start + maxIndex * step : this._start;
  21253. for (var ii = 0; ii <= maxIndex; ii++) {
  21254. if (fn(value, ii, this) === false) {
  21255. return ii + 1;
  21256. }
  21257. value += reverse ? -step : step;
  21258. }
  21259. return ii;
  21260. };
  21261. Range.prototype.__iterator = function(type, reverse) {
  21262. var maxIndex = this.size - 1;
  21263. var step = this._step;
  21264. var value = reverse ? this._start + maxIndex * step : this._start;
  21265. var ii = 0;
  21266. return new Iterator(function() {
  21267. var v = value;
  21268. value += reverse ? -step : step;
  21269. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  21270. });
  21271. };
  21272. Range.prototype.equals = function(other) {
  21273. return other instanceof Range ?
  21274. this._start === other._start &&
  21275. this._end === other._end &&
  21276. this._step === other._step :
  21277. deepEqual(this, other);
  21278. };
  21279. var EMPTY_RANGE;
  21280. createClass(Collection, Iterable);
  21281. function Collection() {
  21282. throw TypeError('Abstract');
  21283. }
  21284. createClass(KeyedCollection, Collection);function KeyedCollection() {}
  21285. createClass(IndexedCollection, Collection);function IndexedCollection() {}
  21286. createClass(SetCollection, Collection);function SetCollection() {}
  21287. Collection.Keyed = KeyedCollection;
  21288. Collection.Indexed = IndexedCollection;
  21289. Collection.Set = SetCollection;
  21290. var imul =
  21291. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
  21292. Math.imul :
  21293. function imul(a, b) {
  21294. a = a | 0; // int
  21295. b = b | 0; // int
  21296. var c = a & 0xffff;
  21297. var d = b & 0xffff;
  21298. // Shift by 0 fixes the sign on the high part.
  21299. return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
  21300. };
  21301. // v8 has an optimization for storing 31-bit signed numbers.
  21302. // Values which have either 00 or 11 as the high order bits qualify.
  21303. // This function drops the highest order bit in a signed number, maintaining
  21304. // the sign bit.
  21305. function smi(i32) {
  21306. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
  21307. }
  21308. function hash(o) {
  21309. if (o === false || o === null || o === undefined) {
  21310. return 0;
  21311. }
  21312. if (typeof o.valueOf === 'function') {
  21313. o = o.valueOf();
  21314. if (o === false || o === null || o === undefined) {
  21315. return 0;
  21316. }
  21317. }
  21318. if (o === true) {
  21319. return 1;
  21320. }
  21321. var type = typeof o;
  21322. if (type === 'number') {
  21323. var h = o | 0;
  21324. if (h !== o) {
  21325. h ^= o * 0xFFFFFFFF;
  21326. }
  21327. while (o > 0xFFFFFFFF) {
  21328. o /= 0xFFFFFFFF;
  21329. h ^= o;
  21330. }
  21331. return smi(h);
  21332. }
  21333. if (type === 'string') {
  21334. return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
  21335. }
  21336. if (typeof o.hashCode === 'function') {
  21337. return o.hashCode();
  21338. }
  21339. if (type === 'object') {
  21340. return hashJSObj(o);
  21341. }
  21342. if (typeof o.toString === 'function') {
  21343. return hashString(o.toString());
  21344. }
  21345. throw new Error('Value type ' + type + ' cannot be hashed.');
  21346. }
  21347. function cachedHashString(string) {
  21348. var hash = stringHashCache[string];
  21349. if (hash === undefined) {
  21350. hash = hashString(string);
  21351. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  21352. STRING_HASH_CACHE_SIZE = 0;
  21353. stringHashCache = {};
  21354. }
  21355. STRING_HASH_CACHE_SIZE++;
  21356. stringHashCache[string] = hash;
  21357. }
  21358. return hash;
  21359. }
  21360. // http://jsperf.com/hashing-strings
  21361. function hashString(string) {
  21362. // This is the hash from JVM
  21363. // The hash code for a string is computed as
  21364. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  21365. // where s[i] is the ith character of the string and n is the length of
  21366. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  21367. // (exclusive) by dropping high bits.
  21368. var hash = 0;
  21369. for (var ii = 0; ii < string.length; ii++) {
  21370. hash = 31 * hash + string.charCodeAt(ii) | 0;
  21371. }
  21372. return smi(hash);
  21373. }
  21374. function hashJSObj(obj) {
  21375. var hash;
  21376. if (usingWeakMap) {
  21377. hash = weakMap.get(obj);
  21378. if (hash !== undefined) {
  21379. return hash;
  21380. }
  21381. }
  21382. hash = obj[UID_HASH_KEY];
  21383. if (hash !== undefined) {
  21384. return hash;
  21385. }
  21386. if (!canDefineProperty) {
  21387. hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  21388. if (hash !== undefined) {
  21389. return hash;
  21390. }
  21391. hash = getIENodeHash(obj);
  21392. if (hash !== undefined) {
  21393. return hash;
  21394. }
  21395. }
  21396. hash = ++objHashUID;
  21397. if (objHashUID & 0x40000000) {
  21398. objHashUID = 0;
  21399. }
  21400. if (usingWeakMap) {
  21401. weakMap.set(obj, hash);
  21402. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  21403. throw new Error('Non-extensible objects are not allowed as keys.');
  21404. } else if (canDefineProperty) {
  21405. Object.defineProperty(obj, UID_HASH_KEY, {
  21406. 'enumerable': false,
  21407. 'configurable': false,
  21408. 'writable': false,
  21409. 'value': hash
  21410. });
  21411. } else if (obj.propertyIsEnumerable !== undefined &&
  21412. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
  21413. // Since we can't define a non-enumerable property on the object
  21414. // we'll hijack one of the less-used non-enumerable properties to
  21415. // save our hash on it. Since this is a function it will not show up in
  21416. // `JSON.stringify` which is what we want.
  21417. obj.propertyIsEnumerable = function() {
  21418. return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
  21419. };
  21420. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  21421. } else if (obj.nodeType !== undefined) {
  21422. // At this point we couldn't get the IE `uniqueID` to use as a hash
  21423. // and we couldn't use a non-enumerable property to exploit the
  21424. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  21425. // itself.
  21426. obj[UID_HASH_KEY] = hash;
  21427. } else {
  21428. throw new Error('Unable to set a non-enumerable property on object.');
  21429. }
  21430. return hash;
  21431. }
  21432. // Get references to ES5 object methods.
  21433. var isExtensible = Object.isExtensible;
  21434. // True if Object.defineProperty works as expected. IE8 fails this test.
  21435. var canDefineProperty = (function() {
  21436. try {
  21437. Object.defineProperty({}, '@', {});
  21438. return true;
  21439. } catch (e) {
  21440. return false;
  21441. }
  21442. }());
  21443. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  21444. // and avoid memory leaks from the IE cloneNode bug.
  21445. function getIENodeHash(node) {
  21446. if (node && node.nodeType > 0) {
  21447. switch (node.nodeType) {
  21448. case 1: // Element
  21449. return node.uniqueID;
  21450. case 9: // Document
  21451. return node.documentElement && node.documentElement.uniqueID;
  21452. }
  21453. }
  21454. }
  21455. // If possible, use a WeakMap.
  21456. var usingWeakMap = typeof WeakMap === 'function';
  21457. var weakMap;
  21458. if (usingWeakMap) {
  21459. weakMap = new WeakMap();
  21460. }
  21461. var objHashUID = 0;
  21462. var UID_HASH_KEY = '__immutablehash__';
  21463. if (typeof Symbol === 'function') {
  21464. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  21465. }
  21466. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  21467. var STRING_HASH_CACHE_MAX_SIZE = 255;
  21468. var STRING_HASH_CACHE_SIZE = 0;
  21469. var stringHashCache = {};
  21470. function assertNotInfinite(size) {
  21471. invariant(
  21472. size !== Infinity,
  21473. 'Cannot perform this action with an infinite size.'
  21474. );
  21475. }
  21476. createClass(Map, KeyedCollection);
  21477. // @pragma Construction
  21478. function Map(value) {
  21479. return value === null || value === undefined ? emptyMap() :
  21480. isMap(value) && !isOrdered(value) ? value :
  21481. emptyMap().withMutations(function(map ) {
  21482. var iter = KeyedIterable(value);
  21483. assertNotInfinite(iter.size);
  21484. iter.forEach(function(v, k) {return map.set(k, v)});
  21485. });
  21486. }
  21487. Map.prototype.toString = function() {
  21488. return this.__toString('Map {', '}');
  21489. };
  21490. // @pragma Access
  21491. Map.prototype.get = function(k, notSetValue) {
  21492. return this._root ?
  21493. this._root.get(0, undefined, k, notSetValue) :
  21494. notSetValue;
  21495. };
  21496. // @pragma Modification
  21497. Map.prototype.set = function(k, v) {
  21498. return updateMap(this, k, v);
  21499. };
  21500. Map.prototype.setIn = function(keyPath, v) {
  21501. return this.updateIn(keyPath, NOT_SET, function() {return v});
  21502. };
  21503. Map.prototype.remove = function(k) {
  21504. return updateMap(this, k, NOT_SET);
  21505. };
  21506. Map.prototype.deleteIn = function(keyPath) {
  21507. return this.updateIn(keyPath, function() {return NOT_SET});
  21508. };
  21509. Map.prototype.update = function(k, notSetValue, updater) {
  21510. return arguments.length === 1 ?
  21511. k(this) :
  21512. this.updateIn([k], notSetValue, updater);
  21513. };
  21514. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  21515. if (!updater) {
  21516. updater = notSetValue;
  21517. notSetValue = undefined;
  21518. }
  21519. var updatedValue = updateInDeepMap(
  21520. this,
  21521. forceIterator(keyPath),
  21522. notSetValue,
  21523. updater
  21524. );
  21525. return updatedValue === NOT_SET ? undefined : updatedValue;
  21526. };
  21527. Map.prototype.clear = function() {
  21528. if (this.size === 0) {
  21529. return this;
  21530. }
  21531. if (this.__ownerID) {
  21532. this.size = 0;
  21533. this._root = null;
  21534. this.__hash = undefined;
  21535. this.__altered = true;
  21536. return this;
  21537. }
  21538. return emptyMap();
  21539. };
  21540. // @pragma Composition
  21541. Map.prototype.merge = function(/*...iters*/) {
  21542. return mergeIntoMapWith(this, undefined, arguments);
  21543. };
  21544. Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  21545. return mergeIntoMapWith(this, merger, iters);
  21546. };
  21547. Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  21548. return this.updateIn(
  21549. keyPath,
  21550. emptyMap(),
  21551. function(m ) {return typeof m.merge === 'function' ?
  21552. m.merge.apply(m, iters) :
  21553. iters[iters.length - 1]}
  21554. );
  21555. };
  21556. Map.prototype.mergeDeep = function(/*...iters*/) {
  21557. return mergeIntoMapWith(this, deepMerger, arguments);
  21558. };
  21559. Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  21560. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  21561. };
  21562. Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  21563. return this.updateIn(
  21564. keyPath,
  21565. emptyMap(),
  21566. function(m ) {return typeof m.mergeDeep === 'function' ?
  21567. m.mergeDeep.apply(m, iters) :
  21568. iters[iters.length - 1]}
  21569. );
  21570. };
  21571. Map.prototype.sort = function(comparator) {
  21572. // Late binding
  21573. return OrderedMap(sortFactory(this, comparator));
  21574. };
  21575. Map.prototype.sortBy = function(mapper, comparator) {
  21576. // Late binding
  21577. return OrderedMap(sortFactory(this, comparator, mapper));
  21578. };
  21579. // @pragma Mutability
  21580. Map.prototype.withMutations = function(fn) {
  21581. var mutable = this.asMutable();
  21582. fn(mutable);
  21583. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  21584. };
  21585. Map.prototype.asMutable = function() {
  21586. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  21587. };
  21588. Map.prototype.asImmutable = function() {
  21589. return this.__ensureOwner();
  21590. };
  21591. Map.prototype.wasAltered = function() {
  21592. return this.__altered;
  21593. };
  21594. Map.prototype.__iterator = function(type, reverse) {
  21595. return new MapIterator(this, type, reverse);
  21596. };
  21597. Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  21598. var iterations = 0;
  21599. this._root && this._root.iterate(function(entry ) {
  21600. iterations++;
  21601. return fn(entry[1], entry[0], this$0);
  21602. }, reverse);
  21603. return iterations;
  21604. };
  21605. Map.prototype.__ensureOwner = function(ownerID) {
  21606. if (ownerID === this.__ownerID) {
  21607. return this;
  21608. }
  21609. if (!ownerID) {
  21610. this.__ownerID = ownerID;
  21611. this.__altered = false;
  21612. return this;
  21613. }
  21614. return makeMap(this.size, this._root, ownerID, this.__hash);
  21615. };
  21616. function isMap(maybeMap) {
  21617. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  21618. }
  21619. Map.isMap = isMap;
  21620. var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  21621. var MapPrototype = Map.prototype;
  21622. MapPrototype[IS_MAP_SENTINEL] = true;
  21623. MapPrototype[DELETE] = MapPrototype.remove;
  21624. MapPrototype.removeIn = MapPrototype.deleteIn;
  21625. // #pragma Trie Nodes
  21626. function ArrayMapNode(ownerID, entries) {
  21627. this.ownerID = ownerID;
  21628. this.entries = entries;
  21629. }
  21630. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  21631. var entries = this.entries;
  21632. for (var ii = 0, len = entries.length; ii < len; ii++) {
  21633. if (is(key, entries[ii][0])) {
  21634. return entries[ii][1];
  21635. }
  21636. }
  21637. return notSetValue;
  21638. };
  21639. ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  21640. var removed = value === NOT_SET;
  21641. var entries = this.entries;
  21642. var idx = 0;
  21643. for (var len = entries.length; idx < len; idx++) {
  21644. if (is(key, entries[idx][0])) {
  21645. break;
  21646. }
  21647. }
  21648. var exists = idx < len;
  21649. if (exists ? entries[idx][1] === value : removed) {
  21650. return this;
  21651. }
  21652. SetRef(didAlter);
  21653. (removed || !exists) && SetRef(didChangeSize);
  21654. if (removed && entries.length === 1) {
  21655. return; // undefined
  21656. }
  21657. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  21658. return createNodes(ownerID, entries, key, value);
  21659. }
  21660. var isEditable = ownerID && ownerID === this.ownerID;
  21661. var newEntries = isEditable ? entries : arrCopy(entries);
  21662. if (exists) {
  21663. if (removed) {
  21664. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  21665. } else {
  21666. newEntries[idx] = [key, value];
  21667. }
  21668. } else {
  21669. newEntries.push([key, value]);
  21670. }
  21671. if (isEditable) {
  21672. this.entries = newEntries;
  21673. return this;
  21674. }
  21675. return new ArrayMapNode(ownerID, newEntries);
  21676. };
  21677. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  21678. this.ownerID = ownerID;
  21679. this.bitmap = bitmap;
  21680. this.nodes = nodes;
  21681. }
  21682. BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  21683. if (keyHash === undefined) {
  21684. keyHash = hash(key);
  21685. }
  21686. var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
  21687. var bitmap = this.bitmap;
  21688. return (bitmap & bit) === 0 ? notSetValue :
  21689. this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
  21690. };
  21691. BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  21692. if (keyHash === undefined) {
  21693. keyHash = hash(key);
  21694. }
  21695. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  21696. var bit = 1 << keyHashFrag;
  21697. var bitmap = this.bitmap;
  21698. var exists = (bitmap & bit) !== 0;
  21699. if (!exists && value === NOT_SET) {
  21700. return this;
  21701. }
  21702. var idx = popCount(bitmap & (bit - 1));
  21703. var nodes = this.nodes;
  21704. var node = exists ? nodes[idx] : undefined;
  21705. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  21706. if (newNode === node) {
  21707. return this;
  21708. }
  21709. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  21710. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  21711. }
  21712. if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
  21713. return nodes[idx ^ 1];
  21714. }
  21715. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  21716. return newNode;
  21717. }
  21718. var isEditable = ownerID && ownerID === this.ownerID;
  21719. var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
  21720. var newNodes = exists ? newNode ?
  21721. setIn(nodes, idx, newNode, isEditable) :
  21722. spliceOut(nodes, idx, isEditable) :
  21723. spliceIn(nodes, idx, newNode, isEditable);
  21724. if (isEditable) {
  21725. this.bitmap = newBitmap;
  21726. this.nodes = newNodes;
  21727. return this;
  21728. }
  21729. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  21730. };
  21731. function HashArrayMapNode(ownerID, count, nodes) {
  21732. this.ownerID = ownerID;
  21733. this.count = count;
  21734. this.nodes = nodes;
  21735. }
  21736. HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  21737. if (keyHash === undefined) {
  21738. keyHash = hash(key);
  21739. }
  21740. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  21741. var node = this.nodes[idx];
  21742. return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
  21743. };
  21744. HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  21745. if (keyHash === undefined) {
  21746. keyHash = hash(key);
  21747. }
  21748. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  21749. var removed = value === NOT_SET;
  21750. var nodes = this.nodes;
  21751. var node = nodes[idx];
  21752. if (removed && !node) {
  21753. return this;
  21754. }
  21755. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  21756. if (newNode === node) {
  21757. return this;
  21758. }
  21759. var newCount = this.count;
  21760. if (!node) {
  21761. newCount++;
  21762. } else if (!newNode) {
  21763. newCount--;
  21764. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  21765. return packNodes(ownerID, nodes, newCount, idx);
  21766. }
  21767. }
  21768. var isEditable = ownerID && ownerID === this.ownerID;
  21769. var newNodes = setIn(nodes, idx, newNode, isEditable);
  21770. if (isEditable) {
  21771. this.count = newCount;
  21772. this.nodes = newNodes;
  21773. return this;
  21774. }
  21775. return new HashArrayMapNode(ownerID, newCount, newNodes);
  21776. };
  21777. function HashCollisionNode(ownerID, keyHash, entries) {
  21778. this.ownerID = ownerID;
  21779. this.keyHash = keyHash;
  21780. this.entries = entries;
  21781. }
  21782. HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  21783. var entries = this.entries;
  21784. for (var ii = 0, len = entries.length; ii < len; ii++) {
  21785. if (is(key, entries[ii][0])) {
  21786. return entries[ii][1];
  21787. }
  21788. }
  21789. return notSetValue;
  21790. };
  21791. HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  21792. if (keyHash === undefined) {
  21793. keyHash = hash(key);
  21794. }
  21795. var removed = value === NOT_SET;
  21796. if (keyHash !== this.keyHash) {
  21797. if (removed) {
  21798. return this;
  21799. }
  21800. SetRef(didAlter);
  21801. SetRef(didChangeSize);
  21802. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  21803. }
  21804. var entries = this.entries;
  21805. var idx = 0;
  21806. for (var len = entries.length; idx < len; idx++) {
  21807. if (is(key, entries[idx][0])) {
  21808. break;
  21809. }
  21810. }
  21811. var exists = idx < len;
  21812. if (exists ? entries[idx][1] === value : removed) {
  21813. return this;
  21814. }
  21815. SetRef(didAlter);
  21816. (removed || !exists) && SetRef(didChangeSize);
  21817. if (removed && len === 2) {
  21818. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  21819. }
  21820. var isEditable = ownerID && ownerID === this.ownerID;
  21821. var newEntries = isEditable ? entries : arrCopy(entries);
  21822. if (exists) {
  21823. if (removed) {
  21824. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  21825. } else {
  21826. newEntries[idx] = [key, value];
  21827. }
  21828. } else {
  21829. newEntries.push([key, value]);
  21830. }
  21831. if (isEditable) {
  21832. this.entries = newEntries;
  21833. return this;
  21834. }
  21835. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  21836. };
  21837. function ValueNode(ownerID, keyHash, entry) {
  21838. this.ownerID = ownerID;
  21839. this.keyHash = keyHash;
  21840. this.entry = entry;
  21841. }
  21842. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  21843. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  21844. };
  21845. ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  21846. var removed = value === NOT_SET;
  21847. var keyMatch = is(key, this.entry[0]);
  21848. if (keyMatch ? value === this.entry[1] : removed) {
  21849. return this;
  21850. }
  21851. SetRef(didAlter);
  21852. if (removed) {
  21853. SetRef(didChangeSize);
  21854. return; // undefined
  21855. }
  21856. if (keyMatch) {
  21857. if (ownerID && ownerID === this.ownerID) {
  21858. this.entry[1] = value;
  21859. return this;
  21860. }
  21861. return new ValueNode(ownerID, this.keyHash, [key, value]);
  21862. }
  21863. SetRef(didChangeSize);
  21864. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  21865. };
  21866. // #pragma Iterators
  21867. ArrayMapNode.prototype.iterate =
  21868. HashCollisionNode.prototype.iterate = function (fn, reverse) {
  21869. var entries = this.entries;
  21870. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  21871. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  21872. return false;
  21873. }
  21874. }
  21875. };
  21876. BitmapIndexedNode.prototype.iterate =
  21877. HashArrayMapNode.prototype.iterate = function (fn, reverse) {
  21878. var nodes = this.nodes;
  21879. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  21880. var node = nodes[reverse ? maxIndex - ii : ii];
  21881. if (node && node.iterate(fn, reverse) === false) {
  21882. return false;
  21883. }
  21884. }
  21885. };
  21886. ValueNode.prototype.iterate = function (fn, reverse) {
  21887. return fn(this.entry);
  21888. };
  21889. createClass(MapIterator, Iterator);
  21890. function MapIterator(map, type, reverse) {
  21891. this._type = type;
  21892. this._reverse = reverse;
  21893. this._stack = map._root && mapIteratorFrame(map._root);
  21894. }
  21895. MapIterator.prototype.next = function() {
  21896. var type = this._type;
  21897. var stack = this._stack;
  21898. while (stack) {
  21899. var node = stack.node;
  21900. var index = stack.index++;
  21901. var maxIndex;
  21902. if (node.entry) {
  21903. if (index === 0) {
  21904. return mapIteratorValue(type, node.entry);
  21905. }
  21906. } else if (node.entries) {
  21907. maxIndex = node.entries.length - 1;
  21908. if (index <= maxIndex) {
  21909. return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
  21910. }
  21911. } else {
  21912. maxIndex = node.nodes.length - 1;
  21913. if (index <= maxIndex) {
  21914. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  21915. if (subNode) {
  21916. if (subNode.entry) {
  21917. return mapIteratorValue(type, subNode.entry);
  21918. }
  21919. stack = this._stack = mapIteratorFrame(subNode, stack);
  21920. }
  21921. continue;
  21922. }
  21923. }
  21924. stack = this._stack = this._stack.__prev;
  21925. }
  21926. return iteratorDone();
  21927. };
  21928. function mapIteratorValue(type, entry) {
  21929. return iteratorValue(type, entry[0], entry[1]);
  21930. }
  21931. function mapIteratorFrame(node, prev) {
  21932. return {
  21933. node: node,
  21934. index: 0,
  21935. __prev: prev
  21936. };
  21937. }
  21938. function makeMap(size, root, ownerID, hash) {
  21939. var map = Object.create(MapPrototype);
  21940. map.size = size;
  21941. map._root = root;
  21942. map.__ownerID = ownerID;
  21943. map.__hash = hash;
  21944. map.__altered = false;
  21945. return map;
  21946. }
  21947. var EMPTY_MAP;
  21948. function emptyMap() {
  21949. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  21950. }
  21951. function updateMap(map, k, v) {
  21952. var newRoot;
  21953. var newSize;
  21954. if (!map._root) {
  21955. if (v === NOT_SET) {
  21956. return map;
  21957. }
  21958. newSize = 1;
  21959. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  21960. } else {
  21961. var didChangeSize = MakeRef(CHANGE_LENGTH);
  21962. var didAlter = MakeRef(DID_ALTER);
  21963. newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
  21964. if (!didAlter.value) {
  21965. return map;
  21966. }
  21967. newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
  21968. }
  21969. if (map.__ownerID) {
  21970. map.size = newSize;
  21971. map._root = newRoot;
  21972. map.__hash = undefined;
  21973. map.__altered = true;
  21974. return map;
  21975. }
  21976. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  21977. }
  21978. function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  21979. if (!node) {
  21980. if (value === NOT_SET) {
  21981. return node;
  21982. }
  21983. SetRef(didAlter);
  21984. SetRef(didChangeSize);
  21985. return new ValueNode(ownerID, keyHash, [key, value]);
  21986. }
  21987. return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
  21988. }
  21989. function isLeafNode(node) {
  21990. return node.constructor === ValueNode || node.constructor === HashCollisionNode;
  21991. }
  21992. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  21993. if (node.keyHash === keyHash) {
  21994. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  21995. }
  21996. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  21997. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  21998. var newNode;
  21999. var nodes = idx1 === idx2 ?
  22000. [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
  22001. ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
  22002. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  22003. }
  22004. function createNodes(ownerID, entries, key, value) {
  22005. if (!ownerID) {
  22006. ownerID = new OwnerID();
  22007. }
  22008. var node = new ValueNode(ownerID, hash(key), [key, value]);
  22009. for (var ii = 0; ii < entries.length; ii++) {
  22010. var entry = entries[ii];
  22011. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  22012. }
  22013. return node;
  22014. }
  22015. function packNodes(ownerID, nodes, count, excluding) {
  22016. var bitmap = 0;
  22017. var packedII = 0;
  22018. var packedNodes = new Array(count);
  22019. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  22020. var node = nodes[ii];
  22021. if (node !== undefined && ii !== excluding) {
  22022. bitmap |= bit;
  22023. packedNodes[packedII++] = node;
  22024. }
  22025. }
  22026. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  22027. }
  22028. function expandNodes(ownerID, nodes, bitmap, including, node) {
  22029. var count = 0;
  22030. var expandedNodes = new Array(SIZE);
  22031. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  22032. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  22033. }
  22034. expandedNodes[including] = node;
  22035. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  22036. }
  22037. function mergeIntoMapWith(map, merger, iterables) {
  22038. var iters = [];
  22039. for (var ii = 0; ii < iterables.length; ii++) {
  22040. var value = iterables[ii];
  22041. var iter = KeyedIterable(value);
  22042. if (!isIterable(value)) {
  22043. iter = iter.map(function(v ) {return fromJS(v)});
  22044. }
  22045. iters.push(iter);
  22046. }
  22047. return mergeIntoCollectionWith(map, merger, iters);
  22048. }
  22049. function deepMerger(existing, value, key) {
  22050. return existing && existing.mergeDeep && isIterable(value) ?
  22051. existing.mergeDeep(value) :
  22052. is(existing, value) ? existing : value;
  22053. }
  22054. function deepMergerWith(merger) {
  22055. return function(existing, value, key) {
  22056. if (existing && existing.mergeDeepWith && isIterable(value)) {
  22057. return existing.mergeDeepWith(merger, value);
  22058. }
  22059. var nextValue = merger(existing, value, key);
  22060. return is(existing, nextValue) ? existing : nextValue;
  22061. };
  22062. }
  22063. function mergeIntoCollectionWith(collection, merger, iters) {
  22064. iters = iters.filter(function(x ) {return x.size !== 0});
  22065. if (iters.length === 0) {
  22066. return collection;
  22067. }
  22068. if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
  22069. return collection.constructor(iters[0]);
  22070. }
  22071. return collection.withMutations(function(collection ) {
  22072. var mergeIntoMap = merger ?
  22073. function(value, key) {
  22074. collection.update(key, NOT_SET, function(existing )
  22075. {return existing === NOT_SET ? value : merger(existing, value, key)}
  22076. );
  22077. } :
  22078. function(value, key) {
  22079. collection.set(key, value);
  22080. };
  22081. for (var ii = 0; ii < iters.length; ii++) {
  22082. iters[ii].forEach(mergeIntoMap);
  22083. }
  22084. });
  22085. }
  22086. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  22087. var isNotSet = existing === NOT_SET;
  22088. var step = keyPathIter.next();
  22089. if (step.done) {
  22090. var existingValue = isNotSet ? notSetValue : existing;
  22091. var newValue = updater(existingValue);
  22092. return newValue === existingValue ? existing : newValue;
  22093. }
  22094. invariant(
  22095. isNotSet || (existing && existing.set),
  22096. 'invalid keyPath'
  22097. );
  22098. var key = step.value;
  22099. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  22100. var nextUpdated = updateInDeepMap(
  22101. nextExisting,
  22102. keyPathIter,
  22103. notSetValue,
  22104. updater
  22105. );
  22106. return nextUpdated === nextExisting ? existing :
  22107. nextUpdated === NOT_SET ? existing.remove(key) :
  22108. (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  22109. }
  22110. function popCount(x) {
  22111. x = x - ((x >> 1) & 0x55555555);
  22112. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  22113. x = (x + (x >> 4)) & 0x0f0f0f0f;
  22114. x = x + (x >> 8);
  22115. x = x + (x >> 16);
  22116. return x & 0x7f;
  22117. }
  22118. function setIn(array, idx, val, canEdit) {
  22119. var newArray = canEdit ? array : arrCopy(array);
  22120. newArray[idx] = val;
  22121. return newArray;
  22122. }
  22123. function spliceIn(array, idx, val, canEdit) {
  22124. var newLen = array.length + 1;
  22125. if (canEdit && idx + 1 === newLen) {
  22126. array[idx] = val;
  22127. return array;
  22128. }
  22129. var newArray = new Array(newLen);
  22130. var after = 0;
  22131. for (var ii = 0; ii < newLen; ii++) {
  22132. if (ii === idx) {
  22133. newArray[ii] = val;
  22134. after = -1;
  22135. } else {
  22136. newArray[ii] = array[ii + after];
  22137. }
  22138. }
  22139. return newArray;
  22140. }
  22141. function spliceOut(array, idx, canEdit) {
  22142. var newLen = array.length - 1;
  22143. if (canEdit && idx === newLen) {
  22144. array.pop();
  22145. return array;
  22146. }
  22147. var newArray = new Array(newLen);
  22148. var after = 0;
  22149. for (var ii = 0; ii < newLen; ii++) {
  22150. if (ii === idx) {
  22151. after = 1;
  22152. }
  22153. newArray[ii] = array[ii + after];
  22154. }
  22155. return newArray;
  22156. }
  22157. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  22158. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  22159. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  22160. createClass(List, IndexedCollection);
  22161. // @pragma Construction
  22162. function List(value) {
  22163. var empty = emptyList();
  22164. if (value === null || value === undefined) {
  22165. return empty;
  22166. }
  22167. if (isList(value)) {
  22168. return value;
  22169. }
  22170. var iter = IndexedIterable(value);
  22171. var size = iter.size;
  22172. if (size === 0) {
  22173. return empty;
  22174. }
  22175. assertNotInfinite(size);
  22176. if (size > 0 && size < SIZE) {
  22177. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  22178. }
  22179. return empty.withMutations(function(list ) {
  22180. list.setSize(size);
  22181. iter.forEach(function(v, i) {return list.set(i, v)});
  22182. });
  22183. }
  22184. List.of = function(/*...values*/) {
  22185. return this(arguments);
  22186. };
  22187. List.prototype.toString = function() {
  22188. return this.__toString('List [', ']');
  22189. };
  22190. // @pragma Access
  22191. List.prototype.get = function(index, notSetValue) {
  22192. index = wrapIndex(this, index);
  22193. if (index >= 0 && index < this.size) {
  22194. index += this._origin;
  22195. var node = listNodeFor(this, index);
  22196. return node && node.array[index & MASK];
  22197. }
  22198. return notSetValue;
  22199. };
  22200. // @pragma Modification
  22201. List.prototype.set = function(index, value) {
  22202. return updateList(this, index, value);
  22203. };
  22204. List.prototype.remove = function(index) {
  22205. return !this.has(index) ? this :
  22206. index === 0 ? this.shift() :
  22207. index === this.size - 1 ? this.pop() :
  22208. this.splice(index, 1);
  22209. };
  22210. List.prototype.insert = function(index, value) {
  22211. return this.splice(index, 0, value);
  22212. };
  22213. List.prototype.clear = function() {
  22214. if (this.size === 0) {
  22215. return this;
  22216. }
  22217. if (this.__ownerID) {
  22218. this.size = this._origin = this._capacity = 0;
  22219. this._level = SHIFT;
  22220. this._root = this._tail = null;
  22221. this.__hash = undefined;
  22222. this.__altered = true;
  22223. return this;
  22224. }
  22225. return emptyList();
  22226. };
  22227. List.prototype.push = function(/*...values*/) {
  22228. var values = arguments;
  22229. var oldSize = this.size;
  22230. return this.withMutations(function(list ) {
  22231. setListBounds(list, 0, oldSize + values.length);
  22232. for (var ii = 0; ii < values.length; ii++) {
  22233. list.set(oldSize + ii, values[ii]);
  22234. }
  22235. });
  22236. };
  22237. List.prototype.pop = function() {
  22238. return setListBounds(this, 0, -1);
  22239. };
  22240. List.prototype.unshift = function(/*...values*/) {
  22241. var values = arguments;
  22242. return this.withMutations(function(list ) {
  22243. setListBounds(list, -values.length);
  22244. for (var ii = 0; ii < values.length; ii++) {
  22245. list.set(ii, values[ii]);
  22246. }
  22247. });
  22248. };
  22249. List.prototype.shift = function() {
  22250. return setListBounds(this, 1);
  22251. };
  22252. // @pragma Composition
  22253. List.prototype.merge = function(/*...iters*/) {
  22254. return mergeIntoListWith(this, undefined, arguments);
  22255. };
  22256. List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  22257. return mergeIntoListWith(this, merger, iters);
  22258. };
  22259. List.prototype.mergeDeep = function(/*...iters*/) {
  22260. return mergeIntoListWith(this, deepMerger, arguments);
  22261. };
  22262. List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  22263. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  22264. };
  22265. List.prototype.setSize = function(size) {
  22266. return setListBounds(this, 0, size);
  22267. };
  22268. // @pragma Iteration
  22269. List.prototype.slice = function(begin, end) {
  22270. var size = this.size;
  22271. if (wholeSlice(begin, end, size)) {
  22272. return this;
  22273. }
  22274. return setListBounds(
  22275. this,
  22276. resolveBegin(begin, size),
  22277. resolveEnd(end, size)
  22278. );
  22279. };
  22280. List.prototype.__iterator = function(type, reverse) {
  22281. var index = 0;
  22282. var values = iterateList(this, reverse);
  22283. return new Iterator(function() {
  22284. var value = values();
  22285. return value === DONE ?
  22286. iteratorDone() :
  22287. iteratorValue(type, index++, value);
  22288. });
  22289. };
  22290. List.prototype.__iterate = function(fn, reverse) {
  22291. var index = 0;
  22292. var values = iterateList(this, reverse);
  22293. var value;
  22294. while ((value = values()) !== DONE) {
  22295. if (fn(value, index++, this) === false) {
  22296. break;
  22297. }
  22298. }
  22299. return index;
  22300. };
  22301. List.prototype.__ensureOwner = function(ownerID) {
  22302. if (ownerID === this.__ownerID) {
  22303. return this;
  22304. }
  22305. if (!ownerID) {
  22306. this.__ownerID = ownerID;
  22307. return this;
  22308. }
  22309. return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
  22310. };
  22311. function isList(maybeList) {
  22312. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  22313. }
  22314. List.isList = isList;
  22315. var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  22316. var ListPrototype = List.prototype;
  22317. ListPrototype[IS_LIST_SENTINEL] = true;
  22318. ListPrototype[DELETE] = ListPrototype.remove;
  22319. ListPrototype.setIn = MapPrototype.setIn;
  22320. ListPrototype.deleteIn =
  22321. ListPrototype.removeIn = MapPrototype.removeIn;
  22322. ListPrototype.update = MapPrototype.update;
  22323. ListPrototype.updateIn = MapPrototype.updateIn;
  22324. ListPrototype.mergeIn = MapPrototype.mergeIn;
  22325. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  22326. ListPrototype.withMutations = MapPrototype.withMutations;
  22327. ListPrototype.asMutable = MapPrototype.asMutable;
  22328. ListPrototype.asImmutable = MapPrototype.asImmutable;
  22329. ListPrototype.wasAltered = MapPrototype.wasAltered;
  22330. function VNode(array, ownerID) {
  22331. this.array = array;
  22332. this.ownerID = ownerID;
  22333. }
  22334. // TODO: seems like these methods are very similar
  22335. VNode.prototype.removeBefore = function(ownerID, level, index) {
  22336. if (index === level ? 1 << level : this.array.length === 0) {
  22337. return this;
  22338. }
  22339. var originIndex = (index >>> level) & MASK;
  22340. if (originIndex >= this.array.length) {
  22341. return new VNode([], ownerID);
  22342. }
  22343. var removingFirst = originIndex === 0;
  22344. var newChild;
  22345. if (level > 0) {
  22346. var oldChild = this.array[originIndex];
  22347. newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  22348. if (newChild === oldChild && removingFirst) {
  22349. return this;
  22350. }
  22351. }
  22352. if (removingFirst && !newChild) {
  22353. return this;
  22354. }
  22355. var editable = editableVNode(this, ownerID);
  22356. if (!removingFirst) {
  22357. for (var ii = 0; ii < originIndex; ii++) {
  22358. editable.array[ii] = undefined;
  22359. }
  22360. }
  22361. if (newChild) {
  22362. editable.array[originIndex] = newChild;
  22363. }
  22364. return editable;
  22365. };
  22366. VNode.prototype.removeAfter = function(ownerID, level, index) {
  22367. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  22368. return this;
  22369. }
  22370. var sizeIndex = ((index - 1) >>> level) & MASK;
  22371. if (sizeIndex >= this.array.length) {
  22372. return this;
  22373. }
  22374. var newChild;
  22375. if (level > 0) {
  22376. var oldChild = this.array[sizeIndex];
  22377. newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  22378. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  22379. return this;
  22380. }
  22381. }
  22382. var editable = editableVNode(this, ownerID);
  22383. editable.array.splice(sizeIndex + 1);
  22384. if (newChild) {
  22385. editable.array[sizeIndex] = newChild;
  22386. }
  22387. return editable;
  22388. };
  22389. var DONE = {};
  22390. function iterateList(list, reverse) {
  22391. var left = list._origin;
  22392. var right = list._capacity;
  22393. var tailPos = getTailOffset(right);
  22394. var tail = list._tail;
  22395. return iterateNodeOrLeaf(list._root, list._level, 0);
  22396. function iterateNodeOrLeaf(node, level, offset) {
  22397. return level === 0 ?
  22398. iterateLeaf(node, offset) :
  22399. iterateNode(node, level, offset);
  22400. }
  22401. function iterateLeaf(node, offset) {
  22402. var array = offset === tailPos ? tail && tail.array : node && node.array;
  22403. var from = offset > left ? 0 : left - offset;
  22404. var to = right - offset;
  22405. if (to > SIZE) {
  22406. to = SIZE;
  22407. }
  22408. return function() {
  22409. if (from === to) {
  22410. return DONE;
  22411. }
  22412. var idx = reverse ? --to : from++;
  22413. return array && array[idx];
  22414. };
  22415. }
  22416. function iterateNode(node, level, offset) {
  22417. var values;
  22418. var array = node && node.array;
  22419. var from = offset > left ? 0 : (left - offset) >> level;
  22420. var to = ((right - offset) >> level) + 1;
  22421. if (to > SIZE) {
  22422. to = SIZE;
  22423. }
  22424. return function() {
  22425. do {
  22426. if (values) {
  22427. var value = values();
  22428. if (value !== DONE) {
  22429. return value;
  22430. }
  22431. values = null;
  22432. }
  22433. if (from === to) {
  22434. return DONE;
  22435. }
  22436. var idx = reverse ? --to : from++;
  22437. values = iterateNodeOrLeaf(
  22438. array && array[idx], level - SHIFT, offset + (idx << level)
  22439. );
  22440. } while (true);
  22441. };
  22442. }
  22443. }
  22444. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  22445. var list = Object.create(ListPrototype);
  22446. list.size = capacity - origin;
  22447. list._origin = origin;
  22448. list._capacity = capacity;
  22449. list._level = level;
  22450. list._root = root;
  22451. list._tail = tail;
  22452. list.__ownerID = ownerID;
  22453. list.__hash = hash;
  22454. list.__altered = false;
  22455. return list;
  22456. }
  22457. var EMPTY_LIST;
  22458. function emptyList() {
  22459. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  22460. }
  22461. function updateList(list, index, value) {
  22462. index = wrapIndex(list, index);
  22463. if (index !== index) {
  22464. return list;
  22465. }
  22466. if (index >= list.size || index < 0) {
  22467. return list.withMutations(function(list ) {
  22468. index < 0 ?
  22469. setListBounds(list, index).set(0, value) :
  22470. setListBounds(list, 0, index + 1).set(index, value);
  22471. });
  22472. }
  22473. index += list._origin;
  22474. var newTail = list._tail;
  22475. var newRoot = list._root;
  22476. var didAlter = MakeRef(DID_ALTER);
  22477. if (index >= getTailOffset(list._capacity)) {
  22478. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  22479. } else {
  22480. newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
  22481. }
  22482. if (!didAlter.value) {
  22483. return list;
  22484. }
  22485. if (list.__ownerID) {
  22486. list._root = newRoot;
  22487. list._tail = newTail;
  22488. list.__hash = undefined;
  22489. list.__altered = true;
  22490. return list;
  22491. }
  22492. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  22493. }
  22494. function updateVNode(node, ownerID, level, index, value, didAlter) {
  22495. var idx = (index >>> level) & MASK;
  22496. var nodeHas = node && idx < node.array.length;
  22497. if (!nodeHas && value === undefined) {
  22498. return node;
  22499. }
  22500. var newNode;
  22501. if (level > 0) {
  22502. var lowerNode = node && node.array[idx];
  22503. var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
  22504. if (newLowerNode === lowerNode) {
  22505. return node;
  22506. }
  22507. newNode = editableVNode(node, ownerID);
  22508. newNode.array[idx] = newLowerNode;
  22509. return newNode;
  22510. }
  22511. if (nodeHas && node.array[idx] === value) {
  22512. return node;
  22513. }
  22514. SetRef(didAlter);
  22515. newNode = editableVNode(node, ownerID);
  22516. if (value === undefined && idx === newNode.array.length - 1) {
  22517. newNode.array.pop();
  22518. } else {
  22519. newNode.array[idx] = value;
  22520. }
  22521. return newNode;
  22522. }
  22523. function editableVNode(node, ownerID) {
  22524. if (ownerID && node && ownerID === node.ownerID) {
  22525. return node;
  22526. }
  22527. return new VNode(node ? node.array.slice() : [], ownerID);
  22528. }
  22529. function listNodeFor(list, rawIndex) {
  22530. if (rawIndex >= getTailOffset(list._capacity)) {
  22531. return list._tail;
  22532. }
  22533. if (rawIndex < 1 << (list._level + SHIFT)) {
  22534. var node = list._root;
  22535. var level = list._level;
  22536. while (node && level > 0) {
  22537. node = node.array[(rawIndex >>> level) & MASK];
  22538. level -= SHIFT;
  22539. }
  22540. return node;
  22541. }
  22542. }
  22543. function setListBounds(list, begin, end) {
  22544. // Sanitize begin & end using this shorthand for ToInt32(argument)
  22545. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  22546. if (begin !== undefined) {
  22547. begin = begin | 0;
  22548. }
  22549. if (end !== undefined) {
  22550. end = end | 0;
  22551. }
  22552. var owner = list.__ownerID || new OwnerID();
  22553. var oldOrigin = list._origin;
  22554. var oldCapacity = list._capacity;
  22555. var newOrigin = oldOrigin + begin;
  22556. var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
  22557. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  22558. return list;
  22559. }
  22560. // If it's going to end after it starts, it's empty.
  22561. if (newOrigin >= newCapacity) {
  22562. return list.clear();
  22563. }
  22564. var newLevel = list._level;
  22565. var newRoot = list._root;
  22566. // New origin might need creating a higher root.
  22567. var offsetShift = 0;
  22568. while (newOrigin + offsetShift < 0) {
  22569. newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
  22570. newLevel += SHIFT;
  22571. offsetShift += 1 << newLevel;
  22572. }
  22573. if (offsetShift) {
  22574. newOrigin += offsetShift;
  22575. oldOrigin += offsetShift;
  22576. newCapacity += offsetShift;
  22577. oldCapacity += offsetShift;
  22578. }
  22579. var oldTailOffset = getTailOffset(oldCapacity);
  22580. var newTailOffset = getTailOffset(newCapacity);
  22581. // New size might need creating a higher root.
  22582. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  22583. newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
  22584. newLevel += SHIFT;
  22585. }
  22586. // Locate or create the new tail.
  22587. var oldTail = list._tail;
  22588. var newTail = newTailOffset < oldTailOffset ?
  22589. listNodeFor(list, newCapacity - 1) :
  22590. newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
  22591. // Merge Tail into tree.
  22592. if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
  22593. newRoot = editableVNode(newRoot, owner);
  22594. var node = newRoot;
  22595. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  22596. var idx = (oldTailOffset >>> level) & MASK;
  22597. node = node.array[idx] = editableVNode(node.array[idx], owner);
  22598. }
  22599. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  22600. }
  22601. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  22602. if (newCapacity < oldCapacity) {
  22603. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  22604. }
  22605. // If the new origin is within the tail, then we do not need a root.
  22606. if (newOrigin >= newTailOffset) {
  22607. newOrigin -= newTailOffset;
  22608. newCapacity -= newTailOffset;
  22609. newLevel = SHIFT;
  22610. newRoot = null;
  22611. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  22612. // Otherwise, if the root has been trimmed, garbage collect.
  22613. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  22614. offsetShift = 0;
  22615. // Identify the new top root node of the subtree of the old root.
  22616. while (newRoot) {
  22617. var beginIndex = (newOrigin >>> newLevel) & MASK;
  22618. if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
  22619. break;
  22620. }
  22621. if (beginIndex) {
  22622. offsetShift += (1 << newLevel) * beginIndex;
  22623. }
  22624. newLevel -= SHIFT;
  22625. newRoot = newRoot.array[beginIndex];
  22626. }
  22627. // Trim the new sides of the new root.
  22628. if (newRoot && newOrigin > oldOrigin) {
  22629. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  22630. }
  22631. if (newRoot && newTailOffset < oldTailOffset) {
  22632. newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
  22633. }
  22634. if (offsetShift) {
  22635. newOrigin -= offsetShift;
  22636. newCapacity -= offsetShift;
  22637. }
  22638. }
  22639. if (list.__ownerID) {
  22640. list.size = newCapacity - newOrigin;
  22641. list._origin = newOrigin;
  22642. list._capacity = newCapacity;
  22643. list._level = newLevel;
  22644. list._root = newRoot;
  22645. list._tail = newTail;
  22646. list.__hash = undefined;
  22647. list.__altered = true;
  22648. return list;
  22649. }
  22650. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  22651. }
  22652. function mergeIntoListWith(list, merger, iterables) {
  22653. var iters = [];
  22654. var maxSize = 0;
  22655. for (var ii = 0; ii < iterables.length; ii++) {
  22656. var value = iterables[ii];
  22657. var iter = IndexedIterable(value);
  22658. if (iter.size > maxSize) {
  22659. maxSize = iter.size;
  22660. }
  22661. if (!isIterable(value)) {
  22662. iter = iter.map(function(v ) {return fromJS(v)});
  22663. }
  22664. iters.push(iter);
  22665. }
  22666. if (maxSize > list.size) {
  22667. list = list.setSize(maxSize);
  22668. }
  22669. return mergeIntoCollectionWith(list, merger, iters);
  22670. }
  22671. function getTailOffset(size) {
  22672. return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
  22673. }
  22674. createClass(OrderedMap, Map);
  22675. // @pragma Construction
  22676. function OrderedMap(value) {
  22677. return value === null || value === undefined ? emptyOrderedMap() :
  22678. isOrderedMap(value) ? value :
  22679. emptyOrderedMap().withMutations(function(map ) {
  22680. var iter = KeyedIterable(value);
  22681. assertNotInfinite(iter.size);
  22682. iter.forEach(function(v, k) {return map.set(k, v)});
  22683. });
  22684. }
  22685. OrderedMap.of = function(/*...values*/) {
  22686. return this(arguments);
  22687. };
  22688. OrderedMap.prototype.toString = function() {
  22689. return this.__toString('OrderedMap {', '}');
  22690. };
  22691. // @pragma Access
  22692. OrderedMap.prototype.get = function(k, notSetValue) {
  22693. var index = this._map.get(k);
  22694. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  22695. };
  22696. // @pragma Modification
  22697. OrderedMap.prototype.clear = function() {
  22698. if (this.size === 0) {
  22699. return this;
  22700. }
  22701. if (this.__ownerID) {
  22702. this.size = 0;
  22703. this._map.clear();
  22704. this._list.clear();
  22705. return this;
  22706. }
  22707. return emptyOrderedMap();
  22708. };
  22709. OrderedMap.prototype.set = function(k, v) {
  22710. return updateOrderedMap(this, k, v);
  22711. };
  22712. OrderedMap.prototype.remove = function(k) {
  22713. return updateOrderedMap(this, k, NOT_SET);
  22714. };
  22715. OrderedMap.prototype.wasAltered = function() {
  22716. return this._map.wasAltered() || this._list.wasAltered();
  22717. };
  22718. OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  22719. return this._list.__iterate(
  22720. function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
  22721. reverse
  22722. );
  22723. };
  22724. OrderedMap.prototype.__iterator = function(type, reverse) {
  22725. return this._list.fromEntrySeq().__iterator(type, reverse);
  22726. };
  22727. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  22728. if (ownerID === this.__ownerID) {
  22729. return this;
  22730. }
  22731. var newMap = this._map.__ensureOwner(ownerID);
  22732. var newList = this._list.__ensureOwner(ownerID);
  22733. if (!ownerID) {
  22734. this.__ownerID = ownerID;
  22735. this._map = newMap;
  22736. this._list = newList;
  22737. return this;
  22738. }
  22739. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  22740. };
  22741. function isOrderedMap(maybeOrderedMap) {
  22742. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  22743. }
  22744. OrderedMap.isOrderedMap = isOrderedMap;
  22745. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  22746. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  22747. function makeOrderedMap(map, list, ownerID, hash) {
  22748. var omap = Object.create(OrderedMap.prototype);
  22749. omap.size = map ? map.size : 0;
  22750. omap._map = map;
  22751. omap._list = list;
  22752. omap.__ownerID = ownerID;
  22753. omap.__hash = hash;
  22754. return omap;
  22755. }
  22756. var EMPTY_ORDERED_MAP;
  22757. function emptyOrderedMap() {
  22758. return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
  22759. }
  22760. function updateOrderedMap(omap, k, v) {
  22761. var map = omap._map;
  22762. var list = omap._list;
  22763. var i = map.get(k);
  22764. var has = i !== undefined;
  22765. var newMap;
  22766. var newList;
  22767. if (v === NOT_SET) { // removed
  22768. if (!has) {
  22769. return omap;
  22770. }
  22771. if (list.size >= SIZE && list.size >= map.size * 2) {
  22772. newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
  22773. newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
  22774. if (omap.__ownerID) {
  22775. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  22776. }
  22777. } else {
  22778. newMap = map.remove(k);
  22779. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  22780. }
  22781. } else {
  22782. if (has) {
  22783. if (v === list.get(i)[1]) {
  22784. return omap;
  22785. }
  22786. newMap = map;
  22787. newList = list.set(i, [k, v]);
  22788. } else {
  22789. newMap = map.set(k, list.size);
  22790. newList = list.set(list.size, [k, v]);
  22791. }
  22792. }
  22793. if (omap.__ownerID) {
  22794. omap.size = newMap.size;
  22795. omap._map = newMap;
  22796. omap._list = newList;
  22797. omap.__hash = undefined;
  22798. return omap;
  22799. }
  22800. return makeOrderedMap(newMap, newList);
  22801. }
  22802. createClass(ToKeyedSequence, KeyedSeq);
  22803. function ToKeyedSequence(indexed, useKeys) {
  22804. this._iter = indexed;
  22805. this._useKeys = useKeys;
  22806. this.size = indexed.size;
  22807. }
  22808. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  22809. return this._iter.get(key, notSetValue);
  22810. };
  22811. ToKeyedSequence.prototype.has = function(key) {
  22812. return this._iter.has(key);
  22813. };
  22814. ToKeyedSequence.prototype.valueSeq = function() {
  22815. return this._iter.valueSeq();
  22816. };
  22817. ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
  22818. var reversedSequence = reverseFactory(this, true);
  22819. if (!this._useKeys) {
  22820. reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
  22821. }
  22822. return reversedSequence;
  22823. };
  22824. ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
  22825. var mappedSequence = mapFactory(this, mapper, context);
  22826. if (!this._useKeys) {
  22827. mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
  22828. }
  22829. return mappedSequence;
  22830. };
  22831. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  22832. var ii;
  22833. return this._iter.__iterate(
  22834. this._useKeys ?
  22835. function(v, k) {return fn(v, k, this$0)} :
  22836. ((ii = reverse ? resolveSize(this) : 0),
  22837. function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
  22838. reverse
  22839. );
  22840. };
  22841. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  22842. if (this._useKeys) {
  22843. return this._iter.__iterator(type, reverse);
  22844. }
  22845. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  22846. var ii = reverse ? resolveSize(this) : 0;
  22847. return new Iterator(function() {
  22848. var step = iterator.next();
  22849. return step.done ? step :
  22850. iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  22851. });
  22852. };
  22853. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  22854. createClass(ToIndexedSequence, IndexedSeq);
  22855. function ToIndexedSequence(iter) {
  22856. this._iter = iter;
  22857. this.size = iter.size;
  22858. }
  22859. ToIndexedSequence.prototype.includes = function(value) {
  22860. return this._iter.includes(value);
  22861. };
  22862. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  22863. var iterations = 0;
  22864. return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
  22865. };
  22866. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  22867. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  22868. var iterations = 0;
  22869. return new Iterator(function() {
  22870. var step = iterator.next();
  22871. return step.done ? step :
  22872. iteratorValue(type, iterations++, step.value, step)
  22873. });
  22874. };
  22875. createClass(ToSetSequence, SetSeq);
  22876. function ToSetSequence(iter) {
  22877. this._iter = iter;
  22878. this.size = iter.size;
  22879. }
  22880. ToSetSequence.prototype.has = function(key) {
  22881. return this._iter.includes(key);
  22882. };
  22883. ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  22884. return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
  22885. };
  22886. ToSetSequence.prototype.__iterator = function(type, reverse) {
  22887. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  22888. return new Iterator(function() {
  22889. var step = iterator.next();
  22890. return step.done ? step :
  22891. iteratorValue(type, step.value, step.value, step);
  22892. });
  22893. };
  22894. createClass(FromEntriesSequence, KeyedSeq);
  22895. function FromEntriesSequence(entries) {
  22896. this._iter = entries;
  22897. this.size = entries.size;
  22898. }
  22899. FromEntriesSequence.prototype.entrySeq = function() {
  22900. return this._iter.toSeq();
  22901. };
  22902. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  22903. return this._iter.__iterate(function(entry ) {
  22904. // Check if entry exists first so array access doesn't throw for holes
  22905. // in the parent iteration.
  22906. if (entry) {
  22907. validateEntry(entry);
  22908. var indexedIterable = isIterable(entry);
  22909. return fn(
  22910. indexedIterable ? entry.get(1) : entry[1],
  22911. indexedIterable ? entry.get(0) : entry[0],
  22912. this$0
  22913. );
  22914. }
  22915. }, reverse);
  22916. };
  22917. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  22918. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  22919. return new Iterator(function() {
  22920. while (true) {
  22921. var step = iterator.next();
  22922. if (step.done) {
  22923. return step;
  22924. }
  22925. var entry = step.value;
  22926. // Check if entry exists first so array access doesn't throw for holes
  22927. // in the parent iteration.
  22928. if (entry) {
  22929. validateEntry(entry);
  22930. var indexedIterable = isIterable(entry);
  22931. return iteratorValue(
  22932. type,
  22933. indexedIterable ? entry.get(0) : entry[0],
  22934. indexedIterable ? entry.get(1) : entry[1],
  22935. step
  22936. );
  22937. }
  22938. }
  22939. });
  22940. };
  22941. ToIndexedSequence.prototype.cacheResult =
  22942. ToKeyedSequence.prototype.cacheResult =
  22943. ToSetSequence.prototype.cacheResult =
  22944. FromEntriesSequence.prototype.cacheResult =
  22945. cacheResultThrough;
  22946. function flipFactory(iterable) {
  22947. var flipSequence = makeSequence(iterable);
  22948. flipSequence._iter = iterable;
  22949. flipSequence.size = iterable.size;
  22950. flipSequence.flip = function() {return iterable};
  22951. flipSequence.reverse = function () {
  22952. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  22953. reversedSequence.flip = function() {return iterable.reverse()};
  22954. return reversedSequence;
  22955. };
  22956. flipSequence.has = function(key ) {return iterable.includes(key)};
  22957. flipSequence.includes = function(key ) {return iterable.has(key)};
  22958. flipSequence.cacheResult = cacheResultThrough;
  22959. flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  22960. return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
  22961. };
  22962. flipSequence.__iteratorUncached = function(type, reverse) {
  22963. if (type === ITERATE_ENTRIES) {
  22964. var iterator = iterable.__iterator(type, reverse);
  22965. return new Iterator(function() {
  22966. var step = iterator.next();
  22967. if (!step.done) {
  22968. var k = step.value[0];
  22969. step.value[0] = step.value[1];
  22970. step.value[1] = k;
  22971. }
  22972. return step;
  22973. });
  22974. }
  22975. return iterable.__iterator(
  22976. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  22977. reverse
  22978. );
  22979. };
  22980. return flipSequence;
  22981. }
  22982. function mapFactory(iterable, mapper, context) {
  22983. var mappedSequence = makeSequence(iterable);
  22984. mappedSequence.size = iterable.size;
  22985. mappedSequence.has = function(key ) {return iterable.has(key)};
  22986. mappedSequence.get = function(key, notSetValue) {
  22987. var v = iterable.get(key, NOT_SET);
  22988. return v === NOT_SET ?
  22989. notSetValue :
  22990. mapper.call(context, v, key, iterable);
  22991. };
  22992. mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  22993. return iterable.__iterate(
  22994. function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
  22995. reverse
  22996. );
  22997. };
  22998. mappedSequence.__iteratorUncached = function (type, reverse) {
  22999. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  23000. return new Iterator(function() {
  23001. var step = iterator.next();
  23002. if (step.done) {
  23003. return step;
  23004. }
  23005. var entry = step.value;
  23006. var key = entry[0];
  23007. return iteratorValue(
  23008. type,
  23009. key,
  23010. mapper.call(context, entry[1], key, iterable),
  23011. step
  23012. );
  23013. });
  23014. };
  23015. return mappedSequence;
  23016. }
  23017. function reverseFactory(iterable, useKeys) {
  23018. var reversedSequence = makeSequence(iterable);
  23019. reversedSequence._iter = iterable;
  23020. reversedSequence.size = iterable.size;
  23021. reversedSequence.reverse = function() {return iterable};
  23022. if (iterable.flip) {
  23023. reversedSequence.flip = function () {
  23024. var flipSequence = flipFactory(iterable);
  23025. flipSequence.reverse = function() {return iterable.flip()};
  23026. return flipSequence;
  23027. };
  23028. }
  23029. reversedSequence.get = function(key, notSetValue)
  23030. {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
  23031. reversedSequence.has = function(key )
  23032. {return iterable.has(useKeys ? key : -1 - key)};
  23033. reversedSequence.includes = function(value ) {return iterable.includes(value)};
  23034. reversedSequence.cacheResult = cacheResultThrough;
  23035. reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
  23036. return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
  23037. };
  23038. reversedSequence.__iterator =
  23039. function(type, reverse) {return iterable.__iterator(type, !reverse)};
  23040. return reversedSequence;
  23041. }
  23042. function filterFactory(iterable, predicate, context, useKeys) {
  23043. var filterSequence = makeSequence(iterable);
  23044. if (useKeys) {
  23045. filterSequence.has = function(key ) {
  23046. var v = iterable.get(key, NOT_SET);
  23047. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  23048. };
  23049. filterSequence.get = function(key, notSetValue) {
  23050. var v = iterable.get(key, NOT_SET);
  23051. return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
  23052. v : notSetValue;
  23053. };
  23054. }
  23055. filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  23056. var iterations = 0;
  23057. iterable.__iterate(function(v, k, c) {
  23058. if (predicate.call(context, v, k, c)) {
  23059. iterations++;
  23060. return fn(v, useKeys ? k : iterations - 1, this$0);
  23061. }
  23062. }, reverse);
  23063. return iterations;
  23064. };
  23065. filterSequence.__iteratorUncached = function (type, reverse) {
  23066. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  23067. var iterations = 0;
  23068. return new Iterator(function() {
  23069. while (true) {
  23070. var step = iterator.next();
  23071. if (step.done) {
  23072. return step;
  23073. }
  23074. var entry = step.value;
  23075. var key = entry[0];
  23076. var value = entry[1];
  23077. if (predicate.call(context, value, key, iterable)) {
  23078. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  23079. }
  23080. }
  23081. });
  23082. };
  23083. return filterSequence;
  23084. }
  23085. function countByFactory(iterable, grouper, context) {
  23086. var groups = Map().asMutable();
  23087. iterable.__iterate(function(v, k) {
  23088. groups.update(
  23089. grouper.call(context, v, k, iterable),
  23090. 0,
  23091. function(a ) {return a + 1}
  23092. );
  23093. });
  23094. return groups.asImmutable();
  23095. }
  23096. function groupByFactory(iterable, grouper, context) {
  23097. var isKeyedIter = isKeyed(iterable);
  23098. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  23099. iterable.__iterate(function(v, k) {
  23100. groups.update(
  23101. grouper.call(context, v, k, iterable),
  23102. function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
  23103. );
  23104. });
  23105. var coerce = iterableClass(iterable);
  23106. return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
  23107. }
  23108. function sliceFactory(iterable, begin, end, useKeys) {
  23109. var originalSize = iterable.size;
  23110. // Sanitize begin & end using this shorthand for ToInt32(argument)
  23111. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  23112. if (begin !== undefined) {
  23113. begin = begin | 0;
  23114. }
  23115. if (end !== undefined) {
  23116. end = end | 0;
  23117. }
  23118. if (wholeSlice(begin, end, originalSize)) {
  23119. return iterable;
  23120. }
  23121. var resolvedBegin = resolveBegin(begin, originalSize);
  23122. var resolvedEnd = resolveEnd(end, originalSize);
  23123. // begin or end will be NaN if they were provided as negative numbers and
  23124. // this iterable's size is unknown. In that case, cache first so there is
  23125. // a known size and these do not resolve to NaN.
  23126. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  23127. return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
  23128. }
  23129. // Note: resolvedEnd is undefined when the original sequence's length is
  23130. // unknown and this slice did not supply an end and should contain all
  23131. // elements after resolvedBegin.
  23132. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  23133. var resolvedSize = resolvedEnd - resolvedBegin;
  23134. var sliceSize;
  23135. if (resolvedSize === resolvedSize) {
  23136. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  23137. }
  23138. var sliceSeq = makeSequence(iterable);
  23139. // If iterable.size is undefined, the size of the realized sliceSeq is
  23140. // unknown at this point unless the number of items to slice is 0
  23141. sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
  23142. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  23143. sliceSeq.get = function (index, notSetValue) {
  23144. index = wrapIndex(this, index);
  23145. return index >= 0 && index < sliceSize ?
  23146. iterable.get(index + resolvedBegin, notSetValue) :
  23147. notSetValue;
  23148. };
  23149. }
  23150. sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
  23151. if (sliceSize === 0) {
  23152. return 0;
  23153. }
  23154. if (reverse) {
  23155. return this.cacheResult().__iterate(fn, reverse);
  23156. }
  23157. var skipped = 0;
  23158. var isSkipping = true;
  23159. var iterations = 0;
  23160. iterable.__iterate(function(v, k) {
  23161. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  23162. iterations++;
  23163. return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  23164. iterations !== sliceSize;
  23165. }
  23166. });
  23167. return iterations;
  23168. };
  23169. sliceSeq.__iteratorUncached = function(type, reverse) {
  23170. if (sliceSize !== 0 && reverse) {
  23171. return this.cacheResult().__iterator(type, reverse);
  23172. }
  23173. // Don't bother instantiating parent iterator if taking 0.
  23174. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  23175. var skipped = 0;
  23176. var iterations = 0;
  23177. return new Iterator(function() {
  23178. while (skipped++ < resolvedBegin) {
  23179. iterator.next();
  23180. }
  23181. if (++iterations > sliceSize) {
  23182. return iteratorDone();
  23183. }
  23184. var step = iterator.next();
  23185. if (useKeys || type === ITERATE_VALUES) {
  23186. return step;
  23187. } else if (type === ITERATE_KEYS) {
  23188. return iteratorValue(type, iterations - 1, undefined, step);
  23189. } else {
  23190. return iteratorValue(type, iterations - 1, step.value[1], step);
  23191. }
  23192. });
  23193. };
  23194. return sliceSeq;
  23195. }
  23196. function takeWhileFactory(iterable, predicate, context) {
  23197. var takeSequence = makeSequence(iterable);
  23198. takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  23199. if (reverse) {
  23200. return this.cacheResult().__iterate(fn, reverse);
  23201. }
  23202. var iterations = 0;
  23203. iterable.__iterate(function(v, k, c)
  23204. {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
  23205. );
  23206. return iterations;
  23207. };
  23208. takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  23209. if (reverse) {
  23210. return this.cacheResult().__iterator(type, reverse);
  23211. }
  23212. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  23213. var iterating = true;
  23214. return new Iterator(function() {
  23215. if (!iterating) {
  23216. return iteratorDone();
  23217. }
  23218. var step = iterator.next();
  23219. if (step.done) {
  23220. return step;
  23221. }
  23222. var entry = step.value;
  23223. var k = entry[0];
  23224. var v = entry[1];
  23225. if (!predicate.call(context, v, k, this$0)) {
  23226. iterating = false;
  23227. return iteratorDone();
  23228. }
  23229. return type === ITERATE_ENTRIES ? step :
  23230. iteratorValue(type, k, v, step);
  23231. });
  23232. };
  23233. return takeSequence;
  23234. }
  23235. function skipWhileFactory(iterable, predicate, context, useKeys) {
  23236. var skipSequence = makeSequence(iterable);
  23237. skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  23238. if (reverse) {
  23239. return this.cacheResult().__iterate(fn, reverse);
  23240. }
  23241. var isSkipping = true;
  23242. var iterations = 0;
  23243. iterable.__iterate(function(v, k, c) {
  23244. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  23245. iterations++;
  23246. return fn(v, useKeys ? k : iterations - 1, this$0);
  23247. }
  23248. });
  23249. return iterations;
  23250. };
  23251. skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  23252. if (reverse) {
  23253. return this.cacheResult().__iterator(type, reverse);
  23254. }
  23255. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  23256. var skipping = true;
  23257. var iterations = 0;
  23258. return new Iterator(function() {
  23259. var step, k, v;
  23260. do {
  23261. step = iterator.next();
  23262. if (step.done) {
  23263. if (useKeys || type === ITERATE_VALUES) {
  23264. return step;
  23265. } else if (type === ITERATE_KEYS) {
  23266. return iteratorValue(type, iterations++, undefined, step);
  23267. } else {
  23268. return iteratorValue(type, iterations++, step.value[1], step);
  23269. }
  23270. }
  23271. var entry = step.value;
  23272. k = entry[0];
  23273. v = entry[1];
  23274. skipping && (skipping = predicate.call(context, v, k, this$0));
  23275. } while (skipping);
  23276. return type === ITERATE_ENTRIES ? step :
  23277. iteratorValue(type, k, v, step);
  23278. });
  23279. };
  23280. return skipSequence;
  23281. }
  23282. function concatFactory(iterable, values) {
  23283. var isKeyedIterable = isKeyed(iterable);
  23284. var iters = [iterable].concat(values).map(function(v ) {
  23285. if (!isIterable(v)) {
  23286. v = isKeyedIterable ?
  23287. keyedSeqFromValue(v) :
  23288. indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  23289. } else if (isKeyedIterable) {
  23290. v = KeyedIterable(v);
  23291. }
  23292. return v;
  23293. }).filter(function(v ) {return v.size !== 0});
  23294. if (iters.length === 0) {
  23295. return iterable;
  23296. }
  23297. if (iters.length === 1) {
  23298. var singleton = iters[0];
  23299. if (singleton === iterable ||
  23300. isKeyedIterable && isKeyed(singleton) ||
  23301. isIndexed(iterable) && isIndexed(singleton)) {
  23302. return singleton;
  23303. }
  23304. }
  23305. var concatSeq = new ArraySeq(iters);
  23306. if (isKeyedIterable) {
  23307. concatSeq = concatSeq.toKeyedSeq();
  23308. } else if (!isIndexed(iterable)) {
  23309. concatSeq = concatSeq.toSetSeq();
  23310. }
  23311. concatSeq = concatSeq.flatten(true);
  23312. concatSeq.size = iters.reduce(
  23313. function(sum, seq) {
  23314. if (sum !== undefined) {
  23315. var size = seq.size;
  23316. if (size !== undefined) {
  23317. return sum + size;
  23318. }
  23319. }
  23320. },
  23321. 0
  23322. );
  23323. return concatSeq;
  23324. }
  23325. function flattenFactory(iterable, depth, useKeys) {
  23326. var flatSequence = makeSequence(iterable);
  23327. flatSequence.__iterateUncached = function(fn, reverse) {
  23328. var iterations = 0;
  23329. var stopped = false;
  23330. function flatDeep(iter, currentDepth) {var this$0 = this;
  23331. iter.__iterate(function(v, k) {
  23332. if ((!depth || currentDepth < depth) && isIterable(v)) {
  23333. flatDeep(v, currentDepth + 1);
  23334. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  23335. stopped = true;
  23336. }
  23337. return !stopped;
  23338. }, reverse);
  23339. }
  23340. flatDeep(iterable, 0);
  23341. return iterations;
  23342. };
  23343. flatSequence.__iteratorUncached = function(type, reverse) {
  23344. var iterator = iterable.__iterator(type, reverse);
  23345. var stack = [];
  23346. var iterations = 0;
  23347. return new Iterator(function() {
  23348. while (iterator) {
  23349. var step = iterator.next();
  23350. if (step.done !== false) {
  23351. iterator = stack.pop();
  23352. continue;
  23353. }
  23354. var v = step.value;
  23355. if (type === ITERATE_ENTRIES) {
  23356. v = v[1];
  23357. }
  23358. if ((!depth || stack.length < depth) && isIterable(v)) {
  23359. stack.push(iterator);
  23360. iterator = v.__iterator(type, reverse);
  23361. } else {
  23362. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  23363. }
  23364. }
  23365. return iteratorDone();
  23366. });
  23367. };
  23368. return flatSequence;
  23369. }
  23370. function flatMapFactory(iterable, mapper, context) {
  23371. var coerce = iterableClass(iterable);
  23372. return iterable.toSeq().map(
  23373. function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
  23374. ).flatten(true);
  23375. }
  23376. function interposeFactory(iterable, separator) {
  23377. var interposedSequence = makeSequence(iterable);
  23378. interposedSequence.size = iterable.size && iterable.size * 2 -1;
  23379. interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  23380. var iterations = 0;
  23381. iterable.__iterate(function(v, k)
  23382. {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
  23383. fn(v, iterations++, this$0) !== false},
  23384. reverse
  23385. );
  23386. return iterations;
  23387. };
  23388. interposedSequence.__iteratorUncached = function(type, reverse) {
  23389. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  23390. var iterations = 0;
  23391. var step;
  23392. return new Iterator(function() {
  23393. if (!step || iterations % 2) {
  23394. step = iterator.next();
  23395. if (step.done) {
  23396. return step;
  23397. }
  23398. }
  23399. return iterations % 2 ?
  23400. iteratorValue(type, iterations++, separator) :
  23401. iteratorValue(type, iterations++, step.value, step);
  23402. });
  23403. };
  23404. return interposedSequence;
  23405. }
  23406. function sortFactory(iterable, comparator, mapper) {
  23407. if (!comparator) {
  23408. comparator = defaultComparator;
  23409. }
  23410. var isKeyedIterable = isKeyed(iterable);
  23411. var index = 0;
  23412. var entries = iterable.toSeq().map(
  23413. function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
  23414. ).toArray();
  23415. entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
  23416. isKeyedIterable ?
  23417. function(v, i) { entries[i].length = 2; } :
  23418. function(v, i) { entries[i] = v[1]; }
  23419. );
  23420. return isKeyedIterable ? KeyedSeq(entries) :
  23421. isIndexed(iterable) ? IndexedSeq(entries) :
  23422. SetSeq(entries);
  23423. }
  23424. function maxFactory(iterable, comparator, mapper) {
  23425. if (!comparator) {
  23426. comparator = defaultComparator;
  23427. }
  23428. if (mapper) {
  23429. var entry = iterable.toSeq()
  23430. .map(function(v, k) {return [v, mapper(v, k, iterable)]})
  23431. .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
  23432. return entry && entry[0];
  23433. } else {
  23434. return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
  23435. }
  23436. }
  23437. function maxCompare(comparator, a, b) {
  23438. var comp = comparator(b, a);
  23439. // b is considered the new max if the comparator declares them equal, but
  23440. // they are not equal and b is in fact a nullish value.
  23441. return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
  23442. }
  23443. function zipWithFactory(keyIter, zipper, iters) {
  23444. var zipSequence = makeSequence(keyIter);
  23445. zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
  23446. // Note: this a generic base implementation of __iterate in terms of
  23447. // __iterator which may be more generically useful in the future.
  23448. zipSequence.__iterate = function(fn, reverse) {
  23449. /* generic:
  23450. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  23451. var step;
  23452. var iterations = 0;
  23453. while (!(step = iterator.next()).done) {
  23454. iterations++;
  23455. if (fn(step.value[1], step.value[0], this) === false) {
  23456. break;
  23457. }
  23458. }
  23459. return iterations;
  23460. */
  23461. // indexed:
  23462. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  23463. var step;
  23464. var iterations = 0;
  23465. while (!(step = iterator.next()).done) {
  23466. if (fn(step.value, iterations++, this) === false) {
  23467. break;
  23468. }
  23469. }
  23470. return iterations;
  23471. };
  23472. zipSequence.__iteratorUncached = function(type, reverse) {
  23473. var iterators = iters.map(function(i )
  23474. {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
  23475. );
  23476. var iterations = 0;
  23477. var isDone = false;
  23478. return new Iterator(function() {
  23479. var steps;
  23480. if (!isDone) {
  23481. steps = iterators.map(function(i ) {return i.next()});
  23482. isDone = steps.some(function(s ) {return s.done});
  23483. }
  23484. if (isDone) {
  23485. return iteratorDone();
  23486. }
  23487. return iteratorValue(
  23488. type,
  23489. iterations++,
  23490. zipper.apply(null, steps.map(function(s ) {return s.value}))
  23491. );
  23492. });
  23493. };
  23494. return zipSequence
  23495. }
  23496. // #pragma Helper Functions
  23497. function reify(iter, seq) {
  23498. return isSeq(iter) ? seq : iter.constructor(seq);
  23499. }
  23500. function validateEntry(entry) {
  23501. if (entry !== Object(entry)) {
  23502. throw new TypeError('Expected [K, V] tuple: ' + entry);
  23503. }
  23504. }
  23505. function resolveSize(iter) {
  23506. assertNotInfinite(iter.size);
  23507. return ensureSize(iter);
  23508. }
  23509. function iterableClass(iterable) {
  23510. return isKeyed(iterable) ? KeyedIterable :
  23511. isIndexed(iterable) ? IndexedIterable :
  23512. SetIterable;
  23513. }
  23514. function makeSequence(iterable) {
  23515. return Object.create(
  23516. (
  23517. isKeyed(iterable) ? KeyedSeq :
  23518. isIndexed(iterable) ? IndexedSeq :
  23519. SetSeq
  23520. ).prototype
  23521. );
  23522. }
  23523. function cacheResultThrough() {
  23524. if (this._iter.cacheResult) {
  23525. this._iter.cacheResult();
  23526. this.size = this._iter.size;
  23527. return this;
  23528. } else {
  23529. return Seq.prototype.cacheResult.call(this);
  23530. }
  23531. }
  23532. function defaultComparator(a, b) {
  23533. return a > b ? 1 : a < b ? -1 : 0;
  23534. }
  23535. function forceIterator(keyPath) {
  23536. var iter = getIterator(keyPath);
  23537. if (!iter) {
  23538. // Array might not be iterable in this environment, so we need a fallback
  23539. // to our wrapped type.
  23540. if (!isArrayLike(keyPath)) {
  23541. throw new TypeError('Expected iterable or array-like: ' + keyPath);
  23542. }
  23543. iter = getIterator(Iterable(keyPath));
  23544. }
  23545. return iter;
  23546. }
  23547. createClass(Record, KeyedCollection);
  23548. function Record(defaultValues, name) {
  23549. var hasInitialized;
  23550. var RecordType = function Record(values) {
  23551. if (values instanceof RecordType) {
  23552. return values;
  23553. }
  23554. if (!(this instanceof RecordType)) {
  23555. return new RecordType(values);
  23556. }
  23557. if (!hasInitialized) {
  23558. hasInitialized = true;
  23559. var keys = Object.keys(defaultValues);
  23560. setProps(RecordTypePrototype, keys);
  23561. RecordTypePrototype.size = keys.length;
  23562. RecordTypePrototype._name = name;
  23563. RecordTypePrototype._keys = keys;
  23564. RecordTypePrototype._defaultValues = defaultValues;
  23565. }
  23566. this._map = Map(values);
  23567. };
  23568. var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
  23569. RecordTypePrototype.constructor = RecordType;
  23570. return RecordType;
  23571. }
  23572. Record.prototype.toString = function() {
  23573. return this.__toString(recordName(this) + ' {', '}');
  23574. };
  23575. // @pragma Access
  23576. Record.prototype.has = function(k) {
  23577. return this._defaultValues.hasOwnProperty(k);
  23578. };
  23579. Record.prototype.get = function(k, notSetValue) {
  23580. if (!this.has(k)) {
  23581. return notSetValue;
  23582. }
  23583. var defaultVal = this._defaultValues[k];
  23584. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  23585. };
  23586. // @pragma Modification
  23587. Record.prototype.clear = function() {
  23588. if (this.__ownerID) {
  23589. this._map && this._map.clear();
  23590. return this;
  23591. }
  23592. var RecordType = this.constructor;
  23593. return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
  23594. };
  23595. Record.prototype.set = function(k, v) {
  23596. if (!this.has(k)) {
  23597. throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
  23598. }
  23599. var newMap = this._map && this._map.set(k, v);
  23600. if (this.__ownerID || newMap === this._map) {
  23601. return this;
  23602. }
  23603. return makeRecord(this, newMap);
  23604. };
  23605. Record.prototype.remove = function(k) {
  23606. if (!this.has(k)) {
  23607. return this;
  23608. }
  23609. var newMap = this._map && this._map.remove(k);
  23610. if (this.__ownerID || newMap === this._map) {
  23611. return this;
  23612. }
  23613. return makeRecord(this, newMap);
  23614. };
  23615. Record.prototype.wasAltered = function() {
  23616. return this._map.wasAltered();
  23617. };
  23618. Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
  23619. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
  23620. };
  23621. Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  23622. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
  23623. };
  23624. Record.prototype.__ensureOwner = function(ownerID) {
  23625. if (ownerID === this.__ownerID) {
  23626. return this;
  23627. }
  23628. var newMap = this._map && this._map.__ensureOwner(ownerID);
  23629. if (!ownerID) {
  23630. this.__ownerID = ownerID;
  23631. this._map = newMap;
  23632. return this;
  23633. }
  23634. return makeRecord(this, newMap, ownerID);
  23635. };
  23636. var RecordPrototype = Record.prototype;
  23637. RecordPrototype[DELETE] = RecordPrototype.remove;
  23638. RecordPrototype.deleteIn =
  23639. RecordPrototype.removeIn = MapPrototype.removeIn;
  23640. RecordPrototype.merge = MapPrototype.merge;
  23641. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  23642. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  23643. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  23644. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  23645. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  23646. RecordPrototype.setIn = MapPrototype.setIn;
  23647. RecordPrototype.update = MapPrototype.update;
  23648. RecordPrototype.updateIn = MapPrototype.updateIn;
  23649. RecordPrototype.withMutations = MapPrototype.withMutations;
  23650. RecordPrototype.asMutable = MapPrototype.asMutable;
  23651. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  23652. function makeRecord(likeRecord, map, ownerID) {
  23653. var record = Object.create(Object.getPrototypeOf(likeRecord));
  23654. record._map = map;
  23655. record.__ownerID = ownerID;
  23656. return record;
  23657. }
  23658. function recordName(record) {
  23659. return record._name || record.constructor.name || 'Record';
  23660. }
  23661. function setProps(prototype, names) {
  23662. try {
  23663. names.forEach(setProp.bind(undefined, prototype));
  23664. } catch (error) {
  23665. // Object.defineProperty failed. Probably IE8.
  23666. }
  23667. }
  23668. function setProp(prototype, name) {
  23669. Object.defineProperty(prototype, name, {
  23670. get: function() {
  23671. return this.get(name);
  23672. },
  23673. set: function(value) {
  23674. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  23675. this.set(name, value);
  23676. }
  23677. });
  23678. }
  23679. createClass(Set, SetCollection);
  23680. // @pragma Construction
  23681. function Set(value) {
  23682. return value === null || value === undefined ? emptySet() :
  23683. isSet(value) && !isOrdered(value) ? value :
  23684. emptySet().withMutations(function(set ) {
  23685. var iter = SetIterable(value);
  23686. assertNotInfinite(iter.size);
  23687. iter.forEach(function(v ) {return set.add(v)});
  23688. });
  23689. }
  23690. Set.of = function(/*...values*/) {
  23691. return this(arguments);
  23692. };
  23693. Set.fromKeys = function(value) {
  23694. return this(KeyedIterable(value).keySeq());
  23695. };
  23696. Set.prototype.toString = function() {
  23697. return this.__toString('Set {', '}');
  23698. };
  23699. // @pragma Access
  23700. Set.prototype.has = function(value) {
  23701. return this._map.has(value);
  23702. };
  23703. // @pragma Modification
  23704. Set.prototype.add = function(value) {
  23705. return updateSet(this, this._map.set(value, true));
  23706. };
  23707. Set.prototype.remove = function(value) {
  23708. return updateSet(this, this._map.remove(value));
  23709. };
  23710. Set.prototype.clear = function() {
  23711. return updateSet(this, this._map.clear());
  23712. };
  23713. // @pragma Composition
  23714. Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
  23715. iters = iters.filter(function(x ) {return x.size !== 0});
  23716. if (iters.length === 0) {
  23717. return this;
  23718. }
  23719. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  23720. return this.constructor(iters[0]);
  23721. }
  23722. return this.withMutations(function(set ) {
  23723. for (var ii = 0; ii < iters.length; ii++) {
  23724. SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
  23725. }
  23726. });
  23727. };
  23728. Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
  23729. if (iters.length === 0) {
  23730. return this;
  23731. }
  23732. iters = iters.map(function(iter ) {return SetIterable(iter)});
  23733. var originalSet = this;
  23734. return this.withMutations(function(set ) {
  23735. originalSet.forEach(function(value ) {
  23736. if (!iters.every(function(iter ) {return iter.includes(value)})) {
  23737. set.remove(value);
  23738. }
  23739. });
  23740. });
  23741. };
  23742. Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
  23743. if (iters.length === 0) {
  23744. return this;
  23745. }
  23746. iters = iters.map(function(iter ) {return SetIterable(iter)});
  23747. var originalSet = this;
  23748. return this.withMutations(function(set ) {
  23749. originalSet.forEach(function(value ) {
  23750. if (iters.some(function(iter ) {return iter.includes(value)})) {
  23751. set.remove(value);
  23752. }
  23753. });
  23754. });
  23755. };
  23756. Set.prototype.merge = function() {
  23757. return this.union.apply(this, arguments);
  23758. };
  23759. Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  23760. return this.union.apply(this, iters);
  23761. };
  23762. Set.prototype.sort = function(comparator) {
  23763. // Late binding
  23764. return OrderedSet(sortFactory(this, comparator));
  23765. };
  23766. Set.prototype.sortBy = function(mapper, comparator) {
  23767. // Late binding
  23768. return OrderedSet(sortFactory(this, comparator, mapper));
  23769. };
  23770. Set.prototype.wasAltered = function() {
  23771. return this._map.wasAltered();
  23772. };
  23773. Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  23774. return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
  23775. };
  23776. Set.prototype.__iterator = function(type, reverse) {
  23777. return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
  23778. };
  23779. Set.prototype.__ensureOwner = function(ownerID) {
  23780. if (ownerID === this.__ownerID) {
  23781. return this;
  23782. }
  23783. var newMap = this._map.__ensureOwner(ownerID);
  23784. if (!ownerID) {
  23785. this.__ownerID = ownerID;
  23786. this._map = newMap;
  23787. return this;
  23788. }
  23789. return this.__make(newMap, ownerID);
  23790. };
  23791. function isSet(maybeSet) {
  23792. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  23793. }
  23794. Set.isSet = isSet;
  23795. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  23796. var SetPrototype = Set.prototype;
  23797. SetPrototype[IS_SET_SENTINEL] = true;
  23798. SetPrototype[DELETE] = SetPrototype.remove;
  23799. SetPrototype.mergeDeep = SetPrototype.merge;
  23800. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  23801. SetPrototype.withMutations = MapPrototype.withMutations;
  23802. SetPrototype.asMutable = MapPrototype.asMutable;
  23803. SetPrototype.asImmutable = MapPrototype.asImmutable;
  23804. SetPrototype.__empty = emptySet;
  23805. SetPrototype.__make = makeSet;
  23806. function updateSet(set, newMap) {
  23807. if (set.__ownerID) {
  23808. set.size = newMap.size;
  23809. set._map = newMap;
  23810. return set;
  23811. }
  23812. return newMap === set._map ? set :
  23813. newMap.size === 0 ? set.__empty() :
  23814. set.__make(newMap);
  23815. }
  23816. function makeSet(map, ownerID) {
  23817. var set = Object.create(SetPrototype);
  23818. set.size = map ? map.size : 0;
  23819. set._map = map;
  23820. set.__ownerID = ownerID;
  23821. return set;
  23822. }
  23823. var EMPTY_SET;
  23824. function emptySet() {
  23825. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  23826. }
  23827. createClass(OrderedSet, Set);
  23828. // @pragma Construction
  23829. function OrderedSet(value) {
  23830. return value === null || value === undefined ? emptyOrderedSet() :
  23831. isOrderedSet(value) ? value :
  23832. emptyOrderedSet().withMutations(function(set ) {
  23833. var iter = SetIterable(value);
  23834. assertNotInfinite(iter.size);
  23835. iter.forEach(function(v ) {return set.add(v)});
  23836. });
  23837. }
  23838. OrderedSet.of = function(/*...values*/) {
  23839. return this(arguments);
  23840. };
  23841. OrderedSet.fromKeys = function(value) {
  23842. return this(KeyedIterable(value).keySeq());
  23843. };
  23844. OrderedSet.prototype.toString = function() {
  23845. return this.__toString('OrderedSet {', '}');
  23846. };
  23847. function isOrderedSet(maybeOrderedSet) {
  23848. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  23849. }
  23850. OrderedSet.isOrderedSet = isOrderedSet;
  23851. var OrderedSetPrototype = OrderedSet.prototype;
  23852. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  23853. OrderedSetPrototype.__empty = emptyOrderedSet;
  23854. OrderedSetPrototype.__make = makeOrderedSet;
  23855. function makeOrderedSet(map, ownerID) {
  23856. var set = Object.create(OrderedSetPrototype);
  23857. set.size = map ? map.size : 0;
  23858. set._map = map;
  23859. set.__ownerID = ownerID;
  23860. return set;
  23861. }
  23862. var EMPTY_ORDERED_SET;
  23863. function emptyOrderedSet() {
  23864. return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
  23865. }
  23866. createClass(Stack, IndexedCollection);
  23867. // @pragma Construction
  23868. function Stack(value) {
  23869. return value === null || value === undefined ? emptyStack() :
  23870. isStack(value) ? value :
  23871. emptyStack().unshiftAll(value);
  23872. }
  23873. Stack.of = function(/*...values*/) {
  23874. return this(arguments);
  23875. };
  23876. Stack.prototype.toString = function() {
  23877. return this.__toString('Stack [', ']');
  23878. };
  23879. // @pragma Access
  23880. Stack.prototype.get = function(index, notSetValue) {
  23881. var head = this._head;
  23882. index = wrapIndex(this, index);
  23883. while (head && index--) {
  23884. head = head.next;
  23885. }
  23886. return head ? head.value : notSetValue;
  23887. };
  23888. Stack.prototype.peek = function() {
  23889. return this._head && this._head.value;
  23890. };
  23891. // @pragma Modification
  23892. Stack.prototype.push = function(/*...values*/) {
  23893. if (arguments.length === 0) {
  23894. return this;
  23895. }
  23896. var newSize = this.size + arguments.length;
  23897. var head = this._head;
  23898. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  23899. head = {
  23900. value: arguments[ii],
  23901. next: head
  23902. };
  23903. }
  23904. if (this.__ownerID) {
  23905. this.size = newSize;
  23906. this._head = head;
  23907. this.__hash = undefined;
  23908. this.__altered = true;
  23909. return this;
  23910. }
  23911. return makeStack(newSize, head);
  23912. };
  23913. Stack.prototype.pushAll = function(iter) {
  23914. iter = IndexedIterable(iter);
  23915. if (iter.size === 0) {
  23916. return this;
  23917. }
  23918. assertNotInfinite(iter.size);
  23919. var newSize = this.size;
  23920. var head = this._head;
  23921. iter.reverse().forEach(function(value ) {
  23922. newSize++;
  23923. head = {
  23924. value: value,
  23925. next: head
  23926. };
  23927. });
  23928. if (this.__ownerID) {
  23929. this.size = newSize;
  23930. this._head = head;
  23931. this.__hash = undefined;
  23932. this.__altered = true;
  23933. return this;
  23934. }
  23935. return makeStack(newSize, head);
  23936. };
  23937. Stack.prototype.pop = function() {
  23938. return this.slice(1);
  23939. };
  23940. Stack.prototype.unshift = function(/*...values*/) {
  23941. return this.push.apply(this, arguments);
  23942. };
  23943. Stack.prototype.unshiftAll = function(iter) {
  23944. return this.pushAll(iter);
  23945. };
  23946. Stack.prototype.shift = function() {
  23947. return this.pop.apply(this, arguments);
  23948. };
  23949. Stack.prototype.clear = function() {
  23950. if (this.size === 0) {
  23951. return this;
  23952. }
  23953. if (this.__ownerID) {
  23954. this.size = 0;
  23955. this._head = undefined;
  23956. this.__hash = undefined;
  23957. this.__altered = true;
  23958. return this;
  23959. }
  23960. return emptyStack();
  23961. };
  23962. Stack.prototype.slice = function(begin, end) {
  23963. if (wholeSlice(begin, end, this.size)) {
  23964. return this;
  23965. }
  23966. var resolvedBegin = resolveBegin(begin, this.size);
  23967. var resolvedEnd = resolveEnd(end, this.size);
  23968. if (resolvedEnd !== this.size) {
  23969. // super.slice(begin, end);
  23970. return IndexedCollection.prototype.slice.call(this, begin, end);
  23971. }
  23972. var newSize = this.size - resolvedBegin;
  23973. var head = this._head;
  23974. while (resolvedBegin--) {
  23975. head = head.next;
  23976. }
  23977. if (this.__ownerID) {
  23978. this.size = newSize;
  23979. this._head = head;
  23980. this.__hash = undefined;
  23981. this.__altered = true;
  23982. return this;
  23983. }
  23984. return makeStack(newSize, head);
  23985. };
  23986. // @pragma Mutability
  23987. Stack.prototype.__ensureOwner = function(ownerID) {
  23988. if (ownerID === this.__ownerID) {
  23989. return this;
  23990. }
  23991. if (!ownerID) {
  23992. this.__ownerID = ownerID;
  23993. this.__altered = false;
  23994. return this;
  23995. }
  23996. return makeStack(this.size, this._head, ownerID, this.__hash);
  23997. };
  23998. // @pragma Iteration
  23999. Stack.prototype.__iterate = function(fn, reverse) {
  24000. if (reverse) {
  24001. return this.reverse().__iterate(fn);
  24002. }
  24003. var iterations = 0;
  24004. var node = this._head;
  24005. while (node) {
  24006. if (fn(node.value, iterations++, this) === false) {
  24007. break;
  24008. }
  24009. node = node.next;
  24010. }
  24011. return iterations;
  24012. };
  24013. Stack.prototype.__iterator = function(type, reverse) {
  24014. if (reverse) {
  24015. return this.reverse().__iterator(type);
  24016. }
  24017. var iterations = 0;
  24018. var node = this._head;
  24019. return new Iterator(function() {
  24020. if (node) {
  24021. var value = node.value;
  24022. node = node.next;
  24023. return iteratorValue(type, iterations++, value);
  24024. }
  24025. return iteratorDone();
  24026. });
  24027. };
  24028. function isStack(maybeStack) {
  24029. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  24030. }
  24031. Stack.isStack = isStack;
  24032. var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  24033. var StackPrototype = Stack.prototype;
  24034. StackPrototype[IS_STACK_SENTINEL] = true;
  24035. StackPrototype.withMutations = MapPrototype.withMutations;
  24036. StackPrototype.asMutable = MapPrototype.asMutable;
  24037. StackPrototype.asImmutable = MapPrototype.asImmutable;
  24038. StackPrototype.wasAltered = MapPrototype.wasAltered;
  24039. function makeStack(size, head, ownerID, hash) {
  24040. var map = Object.create(StackPrototype);
  24041. map.size = size;
  24042. map._head = head;
  24043. map.__ownerID = ownerID;
  24044. map.__hash = hash;
  24045. map.__altered = false;
  24046. return map;
  24047. }
  24048. var EMPTY_STACK;
  24049. function emptyStack() {
  24050. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  24051. }
  24052. /**
  24053. * Contributes additional methods to a constructor
  24054. */
  24055. function mixin(ctor, methods) {
  24056. var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
  24057. Object.keys(methods).forEach(keyCopier);
  24058. Object.getOwnPropertySymbols &&
  24059. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  24060. return ctor;
  24061. }
  24062. Iterable.Iterator = Iterator;
  24063. mixin(Iterable, {
  24064. // ### Conversion to other types
  24065. toArray: function() {
  24066. assertNotInfinite(this.size);
  24067. var array = new Array(this.size || 0);
  24068. this.valueSeq().__iterate(function(v, i) { array[i] = v; });
  24069. return array;
  24070. },
  24071. toIndexedSeq: function() {
  24072. return new ToIndexedSequence(this);
  24073. },
  24074. toJS: function() {
  24075. return this.toSeq().map(
  24076. function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
  24077. ).__toJS();
  24078. },
  24079. toJSON: function() {
  24080. return this.toSeq().map(
  24081. function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
  24082. ).__toJS();
  24083. },
  24084. toKeyedSeq: function() {
  24085. return new ToKeyedSequence(this, true);
  24086. },
  24087. toMap: function() {
  24088. // Use Late Binding here to solve the circular dependency.
  24089. return Map(this.toKeyedSeq());
  24090. },
  24091. toObject: function() {
  24092. assertNotInfinite(this.size);
  24093. var object = {};
  24094. this.__iterate(function(v, k) { object[k] = v; });
  24095. return object;
  24096. },
  24097. toOrderedMap: function() {
  24098. // Use Late Binding here to solve the circular dependency.
  24099. return OrderedMap(this.toKeyedSeq());
  24100. },
  24101. toOrderedSet: function() {
  24102. // Use Late Binding here to solve the circular dependency.
  24103. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  24104. },
  24105. toSet: function() {
  24106. // Use Late Binding here to solve the circular dependency.
  24107. return Set(isKeyed(this) ? this.valueSeq() : this);
  24108. },
  24109. toSetSeq: function() {
  24110. return new ToSetSequence(this);
  24111. },
  24112. toSeq: function() {
  24113. return isIndexed(this) ? this.toIndexedSeq() :
  24114. isKeyed(this) ? this.toKeyedSeq() :
  24115. this.toSetSeq();
  24116. },
  24117. toStack: function() {
  24118. // Use Late Binding here to solve the circular dependency.
  24119. return Stack(isKeyed(this) ? this.valueSeq() : this);
  24120. },
  24121. toList: function() {
  24122. // Use Late Binding here to solve the circular dependency.
  24123. return List(isKeyed(this) ? this.valueSeq() : this);
  24124. },
  24125. // ### Common JavaScript methods and properties
  24126. toString: function() {
  24127. return '[Iterable]';
  24128. },
  24129. __toString: function(head, tail) {
  24130. if (this.size === 0) {
  24131. return head + tail;
  24132. }
  24133. return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
  24134. },
  24135. // ### ES6 Collection methods (ES6 Array and Map)
  24136. concat: function() {var values = SLICE$0.call(arguments, 0);
  24137. return reify(this, concatFactory(this, values));
  24138. },
  24139. includes: function(searchValue) {
  24140. return this.some(function(value ) {return is(value, searchValue)});
  24141. },
  24142. entries: function() {
  24143. return this.__iterator(ITERATE_ENTRIES);
  24144. },
  24145. every: function(predicate, context) {
  24146. assertNotInfinite(this.size);
  24147. var returnValue = true;
  24148. this.__iterate(function(v, k, c) {
  24149. if (!predicate.call(context, v, k, c)) {
  24150. returnValue = false;
  24151. return false;
  24152. }
  24153. });
  24154. return returnValue;
  24155. },
  24156. filter: function(predicate, context) {
  24157. return reify(this, filterFactory(this, predicate, context, true));
  24158. },
  24159. find: function(predicate, context, notSetValue) {
  24160. var entry = this.findEntry(predicate, context);
  24161. return entry ? entry[1] : notSetValue;
  24162. },
  24163. findEntry: function(predicate, context) {
  24164. var found;
  24165. this.__iterate(function(v, k, c) {
  24166. if (predicate.call(context, v, k, c)) {
  24167. found = [k, v];
  24168. return false;
  24169. }
  24170. });
  24171. return found;
  24172. },
  24173. findLastEntry: function(predicate, context) {
  24174. return this.toSeq().reverse().findEntry(predicate, context);
  24175. },
  24176. forEach: function(sideEffect, context) {
  24177. assertNotInfinite(this.size);
  24178. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  24179. },
  24180. join: function(separator) {
  24181. assertNotInfinite(this.size);
  24182. separator = separator !== undefined ? '' + separator : ',';
  24183. var joined = '';
  24184. var isFirst = true;
  24185. this.__iterate(function(v ) {
  24186. isFirst ? (isFirst = false) : (joined += separator);
  24187. joined += v !== null && v !== undefined ? v.toString() : '';
  24188. });
  24189. return joined;
  24190. },
  24191. keys: function() {
  24192. return this.__iterator(ITERATE_KEYS);
  24193. },
  24194. map: function(mapper, context) {
  24195. return reify(this, mapFactory(this, mapper, context));
  24196. },
  24197. reduce: function(reducer, initialReduction, context) {
  24198. assertNotInfinite(this.size);
  24199. var reduction;
  24200. var useFirst;
  24201. if (arguments.length < 2) {
  24202. useFirst = true;
  24203. } else {
  24204. reduction = initialReduction;
  24205. }
  24206. this.__iterate(function(v, k, c) {
  24207. if (useFirst) {
  24208. useFirst = false;
  24209. reduction = v;
  24210. } else {
  24211. reduction = reducer.call(context, reduction, v, k, c);
  24212. }
  24213. });
  24214. return reduction;
  24215. },
  24216. reduceRight: function(reducer, initialReduction, context) {
  24217. var reversed = this.toKeyedSeq().reverse();
  24218. return reversed.reduce.apply(reversed, arguments);
  24219. },
  24220. reverse: function() {
  24221. return reify(this, reverseFactory(this, true));
  24222. },
  24223. slice: function(begin, end) {
  24224. return reify(this, sliceFactory(this, begin, end, true));
  24225. },
  24226. some: function(predicate, context) {
  24227. return !this.every(not(predicate), context);
  24228. },
  24229. sort: function(comparator) {
  24230. return reify(this, sortFactory(this, comparator));
  24231. },
  24232. values: function() {
  24233. return this.__iterator(ITERATE_VALUES);
  24234. },
  24235. // ### More sequential methods
  24236. butLast: function() {
  24237. return this.slice(0, -1);
  24238. },
  24239. isEmpty: function() {
  24240. return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
  24241. },
  24242. count: function(predicate, context) {
  24243. return ensureSize(
  24244. predicate ? this.toSeq().filter(predicate, context) : this
  24245. );
  24246. },
  24247. countBy: function(grouper, context) {
  24248. return countByFactory(this, grouper, context);
  24249. },
  24250. equals: function(other) {
  24251. return deepEqual(this, other);
  24252. },
  24253. entrySeq: function() {
  24254. var iterable = this;
  24255. if (iterable._cache) {
  24256. // We cache as an entries array, so we can just return the cache!
  24257. return new ArraySeq(iterable._cache);
  24258. }
  24259. var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
  24260. entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
  24261. return entriesSequence;
  24262. },
  24263. filterNot: function(predicate, context) {
  24264. return this.filter(not(predicate), context);
  24265. },
  24266. findLast: function(predicate, context, notSetValue) {
  24267. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  24268. },
  24269. first: function() {
  24270. return this.find(returnTrue);
  24271. },
  24272. flatMap: function(mapper, context) {
  24273. return reify(this, flatMapFactory(this, mapper, context));
  24274. },
  24275. flatten: function(depth) {
  24276. return reify(this, flattenFactory(this, depth, true));
  24277. },
  24278. fromEntrySeq: function() {
  24279. return new FromEntriesSequence(this);
  24280. },
  24281. get: function(searchKey, notSetValue) {
  24282. return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
  24283. },
  24284. getIn: function(searchKeyPath, notSetValue) {
  24285. var nested = this;
  24286. // Note: in an ES6 environment, we would prefer:
  24287. // for (var key of searchKeyPath) {
  24288. var iter = forceIterator(searchKeyPath);
  24289. var step;
  24290. while (!(step = iter.next()).done) {
  24291. var key = step.value;
  24292. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  24293. if (nested === NOT_SET) {
  24294. return notSetValue;
  24295. }
  24296. }
  24297. return nested;
  24298. },
  24299. groupBy: function(grouper, context) {
  24300. return groupByFactory(this, grouper, context);
  24301. },
  24302. has: function(searchKey) {
  24303. return this.get(searchKey, NOT_SET) !== NOT_SET;
  24304. },
  24305. hasIn: function(searchKeyPath) {
  24306. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  24307. },
  24308. isSubset: function(iter) {
  24309. iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
  24310. return this.every(function(value ) {return iter.includes(value)});
  24311. },
  24312. isSuperset: function(iter) {
  24313. iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
  24314. return iter.isSubset(this);
  24315. },
  24316. keySeq: function() {
  24317. return this.toSeq().map(keyMapper).toIndexedSeq();
  24318. },
  24319. last: function() {
  24320. return this.toSeq().reverse().first();
  24321. },
  24322. max: function(comparator) {
  24323. return maxFactory(this, comparator);
  24324. },
  24325. maxBy: function(mapper, comparator) {
  24326. return maxFactory(this, comparator, mapper);
  24327. },
  24328. min: function(comparator) {
  24329. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
  24330. },
  24331. minBy: function(mapper, comparator) {
  24332. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
  24333. },
  24334. rest: function() {
  24335. return this.slice(1);
  24336. },
  24337. skip: function(amount) {
  24338. return this.slice(Math.max(0, amount));
  24339. },
  24340. skipLast: function(amount) {
  24341. return reify(this, this.toSeq().reverse().skip(amount).reverse());
  24342. },
  24343. skipWhile: function(predicate, context) {
  24344. return reify(this, skipWhileFactory(this, predicate, context, true));
  24345. },
  24346. skipUntil: function(predicate, context) {
  24347. return this.skipWhile(not(predicate), context);
  24348. },
  24349. sortBy: function(mapper, comparator) {
  24350. return reify(this, sortFactory(this, comparator, mapper));
  24351. },
  24352. take: function(amount) {
  24353. return this.slice(0, Math.max(0, amount));
  24354. },
  24355. takeLast: function(amount) {
  24356. return reify(this, this.toSeq().reverse().take(amount).reverse());
  24357. },
  24358. takeWhile: function(predicate, context) {
  24359. return reify(this, takeWhileFactory(this, predicate, context));
  24360. },
  24361. takeUntil: function(predicate, context) {
  24362. return this.takeWhile(not(predicate), context);
  24363. },
  24364. valueSeq: function() {
  24365. return this.toIndexedSeq();
  24366. },
  24367. // ### Hashable Object
  24368. hashCode: function() {
  24369. return this.__hash || (this.__hash = hashIterable(this));
  24370. }
  24371. // ### Internal
  24372. // abstract __iterate(fn, reverse)
  24373. // abstract __iterator(type, reverse)
  24374. });
  24375. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  24376. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  24377. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  24378. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  24379. var IterablePrototype = Iterable.prototype;
  24380. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  24381. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  24382. IterablePrototype.__toJS = IterablePrototype.toArray;
  24383. IterablePrototype.__toStringMapper = quoteString;
  24384. IterablePrototype.inspect =
  24385. IterablePrototype.toSource = function() { return this.toString(); };
  24386. IterablePrototype.chain = IterablePrototype.flatMap;
  24387. IterablePrototype.contains = IterablePrototype.includes;
  24388. // Temporary warning about using length
  24389. (function () {
  24390. try {
  24391. Object.defineProperty(IterablePrototype, 'length', {
  24392. get: function () {
  24393. if (!Iterable.noLengthWarning) {
  24394. var stack;
  24395. try {
  24396. throw new Error();
  24397. } catch (error) {
  24398. stack = error.stack;
  24399. }
  24400. if (stack.indexOf('_wrapObject') === -1) {
  24401. console && console.warn && console.warn(
  24402. 'iterable.length has been deprecated, '+
  24403. 'use iterable.size or iterable.count(). '+
  24404. 'This warning will become a silent error in a future version. ' +
  24405. stack
  24406. );
  24407. return this.size;
  24408. }
  24409. }
  24410. }
  24411. });
  24412. } catch (e) {}
  24413. })();
  24414. mixin(KeyedIterable, {
  24415. // ### More sequential methods
  24416. flip: function() {
  24417. return reify(this, flipFactory(this));
  24418. },
  24419. findKey: function(predicate, context) {
  24420. var entry = this.findEntry(predicate, context);
  24421. return entry && entry[0];
  24422. },
  24423. findLastKey: function(predicate, context) {
  24424. return this.toSeq().reverse().findKey(predicate, context);
  24425. },
  24426. keyOf: function(searchValue) {
  24427. return this.findKey(function(value ) {return is(value, searchValue)});
  24428. },
  24429. lastKeyOf: function(searchValue) {
  24430. return this.findLastKey(function(value ) {return is(value, searchValue)});
  24431. },
  24432. mapEntries: function(mapper, context) {var this$0 = this;
  24433. var iterations = 0;
  24434. return reify(this,
  24435. this.toSeq().map(
  24436. function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
  24437. ).fromEntrySeq()
  24438. );
  24439. },
  24440. mapKeys: function(mapper, context) {var this$0 = this;
  24441. return reify(this,
  24442. this.toSeq().flip().map(
  24443. function(k, v) {return mapper.call(context, k, v, this$0)}
  24444. ).flip()
  24445. );
  24446. }
  24447. });
  24448. var KeyedIterablePrototype = KeyedIterable.prototype;
  24449. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  24450. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  24451. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  24452. KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
  24453. mixin(IndexedIterable, {
  24454. // ### Conversion to other types
  24455. toKeyedSeq: function() {
  24456. return new ToKeyedSequence(this, false);
  24457. },
  24458. // ### ES6 Collection methods (ES6 Array and Map)
  24459. filter: function(predicate, context) {
  24460. return reify(this, filterFactory(this, predicate, context, false));
  24461. },
  24462. findIndex: function(predicate, context) {
  24463. var entry = this.findEntry(predicate, context);
  24464. return entry ? entry[0] : -1;
  24465. },
  24466. indexOf: function(searchValue) {
  24467. var key = this.toKeyedSeq().keyOf(searchValue);
  24468. return key === undefined ? -1 : key;
  24469. },
  24470. lastIndexOf: function(searchValue) {
  24471. var key = this.toKeyedSeq().reverse().keyOf(searchValue);
  24472. return key === undefined ? -1 : key;
  24473. // var index =
  24474. // return this.toSeq().reverse().indexOf(searchValue);
  24475. },
  24476. reverse: function() {
  24477. return reify(this, reverseFactory(this, false));
  24478. },
  24479. slice: function(begin, end) {
  24480. return reify(this, sliceFactory(this, begin, end, false));
  24481. },
  24482. splice: function(index, removeNum /*, ...values*/) {
  24483. var numArgs = arguments.length;
  24484. removeNum = Math.max(removeNum | 0, 0);
  24485. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  24486. return this;
  24487. }
  24488. // If index is negative, it should resolve relative to the size of the
  24489. // collection. However size may be expensive to compute if not cached, so
  24490. // only call count() if the number is in fact negative.
  24491. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  24492. var spliced = this.slice(0, index);
  24493. return reify(
  24494. this,
  24495. numArgs === 1 ?
  24496. spliced :
  24497. spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  24498. );
  24499. },
  24500. // ### More collection methods
  24501. findLastIndex: function(predicate, context) {
  24502. var key = this.toKeyedSeq().findLastKey(predicate, context);
  24503. return key === undefined ? -1 : key;
  24504. },
  24505. first: function() {
  24506. return this.get(0);
  24507. },
  24508. flatten: function(depth) {
  24509. return reify(this, flattenFactory(this, depth, false));
  24510. },
  24511. get: function(index, notSetValue) {
  24512. index = wrapIndex(this, index);
  24513. return (index < 0 || (this.size === Infinity ||
  24514. (this.size !== undefined && index > this.size))) ?
  24515. notSetValue :
  24516. this.find(function(_, key) {return key === index}, undefined, notSetValue);
  24517. },
  24518. has: function(index) {
  24519. index = wrapIndex(this, index);
  24520. return index >= 0 && (this.size !== undefined ?
  24521. this.size === Infinity || index < this.size :
  24522. this.indexOf(index) !== -1
  24523. );
  24524. },
  24525. interpose: function(separator) {
  24526. return reify(this, interposeFactory(this, separator));
  24527. },
  24528. interleave: function(/*...iterables*/) {
  24529. var iterables = [this].concat(arrCopy(arguments));
  24530. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  24531. var interleaved = zipped.flatten(true);
  24532. if (zipped.size) {
  24533. interleaved.size = zipped.size * iterables.length;
  24534. }
  24535. return reify(this, interleaved);
  24536. },
  24537. last: function() {
  24538. return this.get(-1);
  24539. },
  24540. skipWhile: function(predicate, context) {
  24541. return reify(this, skipWhileFactory(this, predicate, context, false));
  24542. },
  24543. zip: function(/*, ...iterables */) {
  24544. var iterables = [this].concat(arrCopy(arguments));
  24545. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  24546. },
  24547. zipWith: function(zipper/*, ...iterables */) {
  24548. var iterables = arrCopy(arguments);
  24549. iterables[0] = this;
  24550. return reify(this, zipWithFactory(this, zipper, iterables));
  24551. }
  24552. });
  24553. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  24554. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  24555. mixin(SetIterable, {
  24556. // ### ES6 Collection methods (ES6 Array and Map)
  24557. get: function(value, notSetValue) {
  24558. return this.has(value) ? value : notSetValue;
  24559. },
  24560. includes: function(value) {
  24561. return this.has(value);
  24562. },
  24563. // ### More sequential methods
  24564. keySeq: function() {
  24565. return this.valueSeq();
  24566. }
  24567. });
  24568. SetIterable.prototype.has = IterablePrototype.includes;
  24569. // Mixin subclasses
  24570. mixin(KeyedSeq, KeyedIterable.prototype);
  24571. mixin(IndexedSeq, IndexedIterable.prototype);
  24572. mixin(SetSeq, SetIterable.prototype);
  24573. mixin(KeyedCollection, KeyedIterable.prototype);
  24574. mixin(IndexedCollection, IndexedIterable.prototype);
  24575. mixin(SetCollection, SetIterable.prototype);
  24576. // #pragma Helper functions
  24577. function keyMapper(v, k) {
  24578. return k;
  24579. }
  24580. function entryMapper(v, k) {
  24581. return [k, v];
  24582. }
  24583. function not(predicate) {
  24584. return function() {
  24585. return !predicate.apply(this, arguments);
  24586. }
  24587. }
  24588. function neg(predicate) {
  24589. return function() {
  24590. return -predicate.apply(this, arguments);
  24591. }
  24592. }
  24593. function quoteString(value) {
  24594. return typeof value === 'string' ? JSON.stringify(value) : value;
  24595. }
  24596. function defaultZipper() {
  24597. return arrCopy(arguments);
  24598. }
  24599. function defaultNegComparator(a, b) {
  24600. return a < b ? 1 : a > b ? -1 : 0;
  24601. }
  24602. function hashIterable(iterable) {
  24603. if (iterable.size === Infinity) {
  24604. return 0;
  24605. }
  24606. var ordered = isOrdered(iterable);
  24607. var keyed = isKeyed(iterable);
  24608. var h = ordered ? 1 : 0;
  24609. var size = iterable.__iterate(
  24610. keyed ?
  24611. ordered ?
  24612. function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
  24613. function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
  24614. ordered ?
  24615. function(v ) { h = 31 * h + hash(v) | 0; } :
  24616. function(v ) { h = h + hash(v) | 0; }
  24617. );
  24618. return murmurHashOfSize(size, h);
  24619. }
  24620. function murmurHashOfSize(size, h) {
  24621. h = imul(h, 0xCC9E2D51);
  24622. h = imul(h << 15 | h >>> -15, 0x1B873593);
  24623. h = imul(h << 13 | h >>> -13, 5);
  24624. h = (h + 0xE6546B64 | 0) ^ size;
  24625. h = imul(h ^ h >>> 16, 0x85EBCA6B);
  24626. h = imul(h ^ h >>> 13, 0xC2B2AE35);
  24627. h = smi(h ^ h >>> 16);
  24628. return h;
  24629. }
  24630. function hashMerge(a, b) {
  24631. return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
  24632. }
  24633. var Immutable = {
  24634. Iterable: Iterable,
  24635. Seq: Seq,
  24636. Collection: Collection,
  24637. Map: Map,
  24638. OrderedMap: OrderedMap,
  24639. List: List,
  24640. Stack: Stack,
  24641. Set: Set,
  24642. OrderedSet: OrderedSet,
  24643. Record: Record,
  24644. Range: Range,
  24645. Repeat: Repeat,
  24646. is: is,
  24647. fromJS: fromJS
  24648. };
  24649. return Immutable;
  24650. }));
  24651. });
  24652. var parseHTML_1 = index.createCommonjsModule(function (module, exports) {
  24653. Object.defineProperty(exports, "__esModule", {
  24654. value: true
  24655. });
  24656. exports["default"] = parseHTML;
  24657. var fallback = function fallback(html) {
  24658. var doc = document.implementation.createHTMLDocument('');
  24659. doc.documentElement.innerHTML = html;
  24660. return doc;
  24661. };
  24662. function parseHTML(html) {
  24663. var doc;
  24664. if (typeof DOMParser !== 'undefined') {
  24665. var parser = new DOMParser();
  24666. doc = parser.parseFromString(html, 'text/html');
  24667. if (doc === null || doc.body === null) {
  24668. doc = fallback(html);
  24669. }
  24670. } else {
  24671. doc = fallback(html);
  24672. }
  24673. return doc.body;
  24674. }
  24675. });
  24676. index.unwrapExports(parseHTML_1);
  24677. var convertFromHTML_1 = index.createCommonjsModule(function (module, exports) {
  24678. Object.defineProperty(exports, "__esModule", {
  24679. value: true
  24680. });
  24681. exports["default"] = void 0;
  24682. var _parseHTML = interopRequireDefault(parseHTML_1);
  24683. var _rangeSort = interopRequireDefault(rangeSort);
  24684. /**
  24685. * Copyright (c) 2013-present, Facebook, Inc.
  24686. * All rights reserved.
  24687. *
  24688. * Copyright (c) 2013-present, Facebook, Inc.
  24689. * All rights reserved.
  24690. *
  24691. * This source code is licensed under the BSD-style license found in the
  24692. * LICENSE file in the /src directory of this source tree. An additional grant
  24693. * of patent rights can be found in the PATENTS file in the same directory.
  24694. */
  24695. var NBSP = '&nbsp;';
  24696. var SPACE = ' '; // Arbitrary max indent
  24697. var MAX_DEPTH = 4; // used for replacing characters in HTML
  24698. /* eslint-disable no-control-regex */
  24699. var REGEX_CR = new RegExp('\r', 'g');
  24700. var REGEX_LF = new RegExp('\n', 'g');
  24701. var REGEX_NBSP = new RegExp(NBSP, 'g');
  24702. var REGEX_BLOCK_DELIMITER = new RegExp('\r', 'g');
  24703. /* eslint-enable no-control-regex */
  24704. // Block tag flow is different because LIs do not have
  24705. // a deterministic style ;_;
  24706. var blockTags = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'blockquote', 'pre'];
  24707. var inlineTags = {
  24708. b: 'BOLD',
  24709. code: 'CODE',
  24710. del: 'STRIKETHROUGH',
  24711. em: 'ITALIC',
  24712. i: 'ITALIC',
  24713. s: 'STRIKETHROUGH',
  24714. strike: 'STRIKETHROUGH',
  24715. strong: 'BOLD',
  24716. u: 'UNDERLINE'
  24717. };
  24718. var handleMiddleware = function handleMiddleware(maybeMiddleware, base) {
  24719. if (maybeMiddleware && maybeMiddleware.__isMiddleware === true) {
  24720. return maybeMiddleware(base);
  24721. }
  24722. return maybeMiddleware;
  24723. };
  24724. var defaultHTMLToBlock = function defaultHTMLToBlock(nodeName, node, lastList) {
  24725. return undefined;
  24726. };
  24727. var defaultHTMLToStyle = function defaultHTMLToStyle(nodeName, node, currentStyle) {
  24728. return currentStyle;
  24729. };
  24730. var defaultHTMLToEntity = function defaultHTMLToEntity(nodeName, node) {
  24731. return undefined;
  24732. };
  24733. var defaultTextToEntity = function defaultTextToEntity(text) {
  24734. return [];
  24735. };
  24736. var nullthrows = function nullthrows(x) {
  24737. if (x != null) {
  24738. return x;
  24739. }
  24740. throw new Error('Got unexpected null or undefined');
  24741. };
  24742. var sanitizeDraftText = function sanitizeDraftText(input) {
  24743. return input.replace(REGEX_BLOCK_DELIMITER, '');
  24744. };
  24745. function getEmptyChunk() {
  24746. return {
  24747. text: '',
  24748. inlines: [],
  24749. entities: [],
  24750. blocks: []
  24751. };
  24752. }
  24753. function getWhitespaceChunk(inEntity) {
  24754. var entities = new Array(1);
  24755. if (inEntity) {
  24756. entities[0] = inEntity;
  24757. }
  24758. return {
  24759. text: SPACE,
  24760. inlines: [(0, immutable$2.OrderedSet)()],
  24761. entities: entities,
  24762. blocks: []
  24763. };
  24764. }
  24765. function getSoftNewlineChunk(block, depth) {
  24766. var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  24767. var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : (0, immutable$2.Map)();
  24768. if (flat === true) {
  24769. return {
  24770. text: '\r',
  24771. inlines: [(0, immutable$2.OrderedSet)()],
  24772. entities: new Array(1),
  24773. blocks: [{
  24774. type: block,
  24775. data: data,
  24776. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  24777. }],
  24778. isNewline: true
  24779. };
  24780. }
  24781. return {
  24782. text: '\n',
  24783. inlines: [(0, immutable$2.OrderedSet)()],
  24784. entities: new Array(1),
  24785. blocks: []
  24786. };
  24787. }
  24788. function getBlockDividerChunk(block, depth) {
  24789. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, immutable$2.Map)();
  24790. return {
  24791. text: '\r',
  24792. inlines: [(0, immutable$2.OrderedSet)()],
  24793. entities: new Array(1),
  24794. blocks: [{
  24795. type: block,
  24796. data: data,
  24797. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  24798. }]
  24799. };
  24800. }
  24801. function getBlockTypeForTag(tag, lastList) {
  24802. switch (tag) {
  24803. case 'h1':
  24804. return 'header-one';
  24805. case 'h2':
  24806. return 'header-two';
  24807. case 'h3':
  24808. return 'header-three';
  24809. case 'h4':
  24810. return 'header-four';
  24811. case 'h5':
  24812. return 'header-five';
  24813. case 'h6':
  24814. return 'header-six';
  24815. case 'li':
  24816. if (lastList === 'ol') {
  24817. return 'ordered-list-item';
  24818. }
  24819. return 'unordered-list-item';
  24820. case 'blockquote':
  24821. return 'blockquote';
  24822. case 'pre':
  24823. return 'code-block';
  24824. case 'div':
  24825. case 'p':
  24826. return 'unstyled';
  24827. default:
  24828. return null;
  24829. }
  24830. }
  24831. function baseCheckBlockType(nodeName, node, lastList) {
  24832. return getBlockTypeForTag(nodeName, lastList);
  24833. }
  24834. function processInlineTag(tag, node, currentStyle) {
  24835. var styleToCheck = inlineTags[tag];
  24836. if (styleToCheck) {
  24837. currentStyle = currentStyle.add(styleToCheck).toOrderedSet();
  24838. } else if (node instanceof HTMLElement) {
  24839. var htmlElement = node;
  24840. currentStyle = currentStyle.withMutations(function (style) {
  24841. if (htmlElement.style.fontWeight === 'bold') {
  24842. style.add('BOLD');
  24843. }
  24844. if (htmlElement.style.fontStyle === 'italic') {
  24845. style.add('ITALIC');
  24846. }
  24847. if (htmlElement.style.textDecoration === 'underline') {
  24848. style.add('UNDERLINE');
  24849. }
  24850. if (htmlElement.style.textDecoration === 'line-through') {
  24851. style.add('STRIKETHROUGH');
  24852. }
  24853. }).toOrderedSet();
  24854. }
  24855. return currentStyle;
  24856. }
  24857. function baseProcessInlineTag(tag, node) {
  24858. var inlineStyles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, immutable$2.OrderedSet)();
  24859. return processInlineTag(tag, node, inlineStyles);
  24860. }
  24861. function joinChunks(A, B) {
  24862. var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  24863. // Sometimes two blocks will touch in the DOM and we need to strip the
  24864. // extra delimiter to preserve niceness.
  24865. var firstInB = B.text.slice(0, 1);
  24866. var lastInA = A.text.slice(-1);
  24867. var adjacentDividers = lastInA === '\r' && firstInB === '\r';
  24868. var isJoiningBlocks = A.text !== '\r' && B.text !== '\r'; // when joining two full blocks like this we want to pop one divider
  24869. var addingNewlineToEmptyBlock = A.text === '\r' && !A.isNewline && B.isNewline; // when joining a newline to an empty block we want to remove the newline
  24870. if (adjacentDividers && (isJoiningBlocks || addingNewlineToEmptyBlock)) {
  24871. A.text = A.text.slice(0, -1);
  24872. A.inlines.pop();
  24873. A.entities.pop();
  24874. A.blocks.pop();
  24875. } // Kill whitespace after blocks if flat mode is on
  24876. if (A.text.slice(-1) === '\r' && flat === true) {
  24877. if (B.text === SPACE || B.text === '\n') {
  24878. return A;
  24879. } else if (firstInB === SPACE || firstInB === '\n') {
  24880. B.text = B.text.slice(1);
  24881. B.inlines.shift();
  24882. B.entities.shift();
  24883. }
  24884. }
  24885. var isNewline = A.text.length === 0 && B.isNewline;
  24886. return {
  24887. text: A.text + B.text,
  24888. inlines: A.inlines.concat(B.inlines),
  24889. entities: A.entities.concat(B.entities),
  24890. blocks: A.blocks.concat(B.blocks),
  24891. isNewline: isNewline
  24892. };
  24893. }
  24894. /*
  24895. * Check to see if we have anything like <p> <blockquote> <h1>... to create
  24896. * block tags from. If we do, we can use those and ignore <div> tags. If we
  24897. * don't, we can treat <div> tags as meaningful (unstyled) blocks.
  24898. */
  24899. function containsSemanticBlockMarkup(html) {
  24900. return blockTags.some(function (tag) {
  24901. return html.indexOf("<".concat(tag)) !== -1;
  24902. });
  24903. }
  24904. function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, inEntity) {
  24905. var nodeName = node.nodeName.toLowerCase();
  24906. var newBlock = false;
  24907. var nextBlockType = 'unstyled'; // Base Case
  24908. if (nodeName === '#text') {
  24909. var text = node.textContent;
  24910. if (text.trim() === '' && inBlock === null) {
  24911. return getEmptyChunk();
  24912. }
  24913. if (text.trim() === '' && inBlock !== 'code-block') {
  24914. return getWhitespaceChunk(inEntity);
  24915. }
  24916. if (inBlock !== 'code-block') {
  24917. // Can't use empty string because MSWord
  24918. text = text.replace(REGEX_LF, SPACE);
  24919. }
  24920. var entities = Array(text.length).fill(inEntity);
  24921. var offsetChange = 0;
  24922. var textEntities = checkEntityText(text, createEntity, getEntity, mergeEntityData, replaceEntityData).sort(_rangeSort["default"]);
  24923. textEntities.forEach(function (_ref) {
  24924. var entity = _ref.entity,
  24925. offset = _ref.offset,
  24926. length = _ref.length,
  24927. result = _ref.result;
  24928. var adjustedOffset = offset + offsetChange;
  24929. if (result === null || result === undefined) {
  24930. result = text.substr(adjustedOffset, length);
  24931. }
  24932. var textArray = text.split('');
  24933. textArray.splice.bind(textArray, adjustedOffset, length).apply(textArray, result.split(''));
  24934. text = textArray.join('');
  24935. entities.splice.bind(entities, adjustedOffset, length).apply(entities, Array(result.length).fill(entity));
  24936. offsetChange += result.length - length;
  24937. });
  24938. return {
  24939. text: text,
  24940. inlines: Array(text.length).fill(inlineStyle),
  24941. entities: entities,
  24942. blocks: []
  24943. };
  24944. } // BR tags
  24945. if (nodeName === 'br') {
  24946. var _blockType = inBlock;
  24947. if (_blockType === null) {
  24948. // BR tag is at top level, treat it as an unstyled block
  24949. return getSoftNewlineChunk('unstyled', depth, true);
  24950. }
  24951. return getSoftNewlineChunk(_blockType || 'unstyled', depth, options.flat);
  24952. }
  24953. var chunk = getEmptyChunk();
  24954. var newChunk = null; // Inline tags
  24955. inlineStyle = processInlineTag(nodeName, node, inlineStyle);
  24956. inlineStyle = processCustomInlineStyles(nodeName, node, inlineStyle); // Handle lists
  24957. if (nodeName === 'ul' || nodeName === 'ol') {
  24958. if (lastList) {
  24959. depth += 1;
  24960. }
  24961. lastList = nodeName;
  24962. inBlock = null;
  24963. } // Block Tags
  24964. var blockInfo = checkBlockType(nodeName, node, lastList, inBlock);
  24965. var blockType;
  24966. var blockDataMap;
  24967. if (blockInfo === false) {
  24968. return getEmptyChunk();
  24969. }
  24970. blockInfo = blockInfo || {};
  24971. if (typeof blockInfo === 'string') {
  24972. blockType = blockInfo;
  24973. blockDataMap = (0, immutable$2.Map)();
  24974. } else {
  24975. blockType = typeof blockInfo === 'string' ? blockInfo : blockInfo.type;
  24976. blockDataMap = blockInfo.data ? (0, immutable$2.Map)(blockInfo.data) : (0, immutable$2.Map)();
  24977. }
  24978. if (!inBlock && (fragmentBlockTags.indexOf(nodeName) !== -1 || blockType)) {
  24979. chunk = getBlockDividerChunk(blockType || getBlockTypeForTag(nodeName, lastList), depth, blockDataMap);
  24980. inBlock = blockType || getBlockTypeForTag(nodeName, lastList);
  24981. newBlock = true;
  24982. } else if (lastList && (inBlock === 'ordered-list-item' || inBlock === 'unordered-list-item') && nodeName === 'li') {
  24983. var listItemBlockType = getBlockTypeForTag(nodeName, lastList);
  24984. chunk = getBlockDividerChunk(listItemBlockType, depth);
  24985. inBlock = listItemBlockType;
  24986. newBlock = true;
  24987. nextBlockType = lastList === 'ul' ? 'unordered-list-item' : 'ordered-list-item';
  24988. } else if (inBlock && inBlock !== 'atomic' && blockType === 'atomic') {
  24989. inBlock = blockType;
  24990. newBlock = true;
  24991. chunk = getSoftNewlineChunk(blockType, depth, true, // atomic blocks within non-atomic blocks must always be split out
  24992. blockDataMap);
  24993. } // Recurse through children
  24994. var child = node.firstChild; // hack to allow conversion of atomic blocks from HTML (e.g. <figure><img
  24995. // src="..." /></figure>). since metadata must be stored on an entity text
  24996. // must exist for the entity to apply to. the way chunks are joined strips
  24997. // whitespace at the end so it cannot be a space character.
  24998. if (child == null && inEntity && (blockType === 'atomic' || inBlock === 'atomic')) {
  24999. child = document.createTextNode('a');
  25000. }
  25001. if (child != null) {
  25002. nodeName = child.nodeName.toLowerCase();
  25003. }
  25004. var entityId = null;
  25005. while (child) {
  25006. entityId = checkEntityNode(nodeName, child, createEntity, getEntity, mergeEntityData, replaceEntityData);
  25007. newChunk = genFragment(child, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, entityId || inEntity);
  25008. chunk = joinChunks(chunk, newChunk, options.flat);
  25009. var sibling = child.nextSibling; // Put in a newline to break up blocks inside blocks
  25010. if (sibling && fragmentBlockTags.indexOf(nodeName) >= 0 && inBlock) {
  25011. var newBlockInfo = checkBlockType(nodeName, child, lastList, inBlock);
  25012. var newBlockType = void 0;
  25013. var newBlockData = void 0;
  25014. if (newBlockInfo !== false) {
  25015. newBlockInfo = newBlockInfo || {};
  25016. if (typeof newBlockInfo === 'string') {
  25017. newBlockType = newBlockInfo;
  25018. newBlockData = (0, immutable$2.Map)();
  25019. } else {
  25020. newBlockType = newBlockInfo.type || getBlockTypeForTag(nodeName, lastList);
  25021. newBlockData = newBlockInfo.data ? (0, immutable$2.Map)(newBlockInfo.data) : (0, immutable$2.Map)();
  25022. }
  25023. chunk = joinChunks(chunk, getSoftNewlineChunk(newBlockType, depth, options.flat, newBlockData), options.flat);
  25024. }
  25025. }
  25026. if (sibling) {
  25027. nodeName = sibling.nodeName.toLowerCase();
  25028. }
  25029. child = sibling;
  25030. }
  25031. if (newBlock) {
  25032. chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, (0, immutable$2.Map)()), options.flat);
  25033. }
  25034. return chunk;
  25035. }
  25036. function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder) {
  25037. html = html.trim().replace(REGEX_CR, '').replace(REGEX_NBSP, SPACE);
  25038. var safeBody = DOMBuilder(html);
  25039. if (!safeBody) {
  25040. return null;
  25041. } // Sometimes we aren't dealing with content that contains nice semantic
  25042. // tags. In this case, use divs to separate everything out into paragraphs
  25043. // and hope for the best.
  25044. var workingBlocks = containsSemanticBlockMarkup(html) ? blockTags.concat(['div']) : ['div']; // Start with -1 block depth to offset the fact that we are passing in a fake
  25045. // UL block to sta rt with.
  25046. var chunk = genFragment(safeBody, (0, immutable$2.OrderedSet)(), 'ul', null, workingBlocks, -1, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options); // join with previous block to prevent weirdness on paste
  25047. if (chunk.text.indexOf('\r') === 0) {
  25048. chunk = {
  25049. text: chunk.text.slice(1),
  25050. inlines: chunk.inlines.slice(1),
  25051. entities: chunk.entities.slice(1),
  25052. blocks: chunk.blocks
  25053. };
  25054. } // Kill block delimiter at the end
  25055. if (chunk.text.slice(-1) === '\r') {
  25056. chunk.text = chunk.text.slice(0, -1);
  25057. chunk.inlines = chunk.inlines.slice(0, -1);
  25058. chunk.entities = chunk.entities.slice(0, -1);
  25059. chunk.blocks.pop();
  25060. } // If we saw no block tags, put an unstyled one in
  25061. if (chunk.blocks.length === 0) {
  25062. chunk.blocks.push({
  25063. type: 'unstyled',
  25064. data: (0, immutable$2.Map)(),
  25065. depth: 0
  25066. });
  25067. } // Sometimes we start with text that isn't in a block, which is then
  25068. // followed by blocks. Need to fix up the blocks to add in
  25069. // an unstyled block for this content
  25070. if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
  25071. chunk.blocks.unshift({
  25072. type: 'unstyled',
  25073. data: (0, immutable$2.Map)(),
  25074. depth: 0
  25075. });
  25076. }
  25077. return chunk;
  25078. }
  25079. function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey) {
  25080. // Be ABSOLUTELY SURE that the dom builder you pass hare won't execute
  25081. // arbitrary code in whatever environment you're running this in. For an
  25082. // example of how we try to do this in-browser, see getSafeBodyFromHTML.
  25083. var chunk = getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder);
  25084. if (chunk == null) {
  25085. return [];
  25086. }
  25087. var start = 0;
  25088. return chunk.text.split('\r').map(function (textBlock, blockIndex) {
  25089. // Make absolutely certain that our text is acceptable.
  25090. textBlock = sanitizeDraftText(textBlock);
  25091. var end = start + textBlock.length;
  25092. var inlines = nullthrows(chunk).inlines.slice(start, end);
  25093. var entities = nullthrows(chunk).entities.slice(start, end);
  25094. var characterList = (0, immutable$2.List)(inlines.map(function (style, entityIndex) {
  25095. var data = {
  25096. style: style,
  25097. entity: null
  25098. };
  25099. if (entities[entityIndex]) {
  25100. data.entity = entities[entityIndex];
  25101. }
  25102. return Draft.CharacterMetadata.create(data);
  25103. }));
  25104. start = end + 1;
  25105. return new Draft.ContentBlock({
  25106. key: generateKey(),
  25107. type: nullthrows(chunk).blocks[blockIndex].type,
  25108. data: nullthrows(chunk).blocks[blockIndex].data,
  25109. depth: nullthrows(chunk).blocks[blockIndex].depth,
  25110. text: textBlock,
  25111. characterList: characterList
  25112. });
  25113. });
  25114. }
  25115. var convertFromHTML = function convertFromHTML(_ref2) {
  25116. var _ref2$htmlToStyle = _ref2.htmlToStyle,
  25117. htmlToStyle = _ref2$htmlToStyle === void 0 ? defaultHTMLToStyle : _ref2$htmlToStyle,
  25118. _ref2$htmlToEntity = _ref2.htmlToEntity,
  25119. htmlToEntity = _ref2$htmlToEntity === void 0 ? defaultHTMLToEntity : _ref2$htmlToEntity,
  25120. _ref2$textToEntity = _ref2.textToEntity,
  25121. textToEntity = _ref2$textToEntity === void 0 ? defaultTextToEntity : _ref2$textToEntity,
  25122. _ref2$htmlToBlock = _ref2.htmlToBlock,
  25123. htmlToBlock = _ref2$htmlToBlock === void 0 ? defaultHTMLToBlock : _ref2$htmlToBlock;
  25124. return function (html) {
  25125. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  25126. flat: false
  25127. };
  25128. var DOMBuilder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _parseHTML["default"];
  25129. var generateKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Draft.genKey;
  25130. var contentState = Draft.ContentState.createFromText('');
  25131. var createEntityWithContentState = function createEntityWithContentState() {
  25132. if (contentState.createEntity) {
  25133. var _contentState;
  25134. contentState = (_contentState = contentState).createEntity.apply(_contentState, arguments);
  25135. return contentState.getLastCreatedEntityKey();
  25136. }
  25137. return Draft.Entity.create.apply(Draft.Entity, arguments);
  25138. };
  25139. var getEntityWithContentState = function getEntityWithContentState() {
  25140. if (contentState.getEntity) {
  25141. var _contentState2;
  25142. return (_contentState2 = contentState).getEntity.apply(_contentState2, arguments);
  25143. }
  25144. return Draft.Entity.get.apply(Draft.Entity, arguments);
  25145. };
  25146. var mergeEntityDataWithContentState = function mergeEntityDataWithContentState() {
  25147. if (contentState.mergeEntityData) {
  25148. var _contentState3;
  25149. contentState = (_contentState3 = contentState).mergeEntityData.apply(_contentState3, arguments);
  25150. return;
  25151. }
  25152. Draft.Entity.mergeData.apply(Draft.Entity, arguments);
  25153. };
  25154. var replaceEntityDataWithContentState = function replaceEntityDataWithContentState() {
  25155. if (contentState.replaceEntityData) {
  25156. var _contentState4;
  25157. contentState = (_contentState4 = contentState).replaceEntityData.apply(_contentState4, arguments);
  25158. return;
  25159. }
  25160. Draft.Entity.replaceData.apply(Draft.Entity, arguments);
  25161. };
  25162. var contentBlocks = convertFromHTMLtoContentBlocks(html, handleMiddleware(htmlToStyle, baseProcessInlineTag), handleMiddleware(htmlToEntity, defaultHTMLToEntity), handleMiddleware(textToEntity, defaultTextToEntity), handleMiddleware(htmlToBlock, baseCheckBlockType), createEntityWithContentState, getEntityWithContentState, mergeEntityDataWithContentState, replaceEntityDataWithContentState, options, DOMBuilder, generateKey);
  25163. var blockMap = Draft.BlockMapBuilder.createFromArray(contentBlocks);
  25164. var firstBlockKey = contentBlocks[0].getKey();
  25165. return contentState.merge({
  25166. blockMap: blockMap,
  25167. selectionBefore: Draft.SelectionState.createEmpty(firstBlockKey),
  25168. selectionAfter: Draft.SelectionState.createEmpty(firstBlockKey)
  25169. });
  25170. };
  25171. };
  25172. var _default = function _default() {
  25173. if (arguments.length >= 1 && typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'string') {
  25174. return convertFromHTML({}).apply(void 0, arguments);
  25175. }
  25176. return convertFromHTML.apply(void 0, arguments);
  25177. };
  25178. exports["default"] = _default;
  25179. });
  25180. index.unwrapExports(convertFromHTML_1);
  25181. var lib = index.createCommonjsModule(function (module, exports) {
  25182. Object.defineProperty(exports, "__esModule", {
  25183. value: true
  25184. });
  25185. Object.defineProperty(exports, "convertToHTML", {
  25186. enumerable: true,
  25187. get: function get() {
  25188. return _convertToHTML["default"];
  25189. }
  25190. });
  25191. Object.defineProperty(exports, "convertFromHTML", {
  25192. enumerable: true,
  25193. get: function get() {
  25194. return _convertFromHTML["default"];
  25195. }
  25196. });
  25197. Object.defineProperty(exports, "parseHTML", {
  25198. enumerable: true,
  25199. get: function get() {
  25200. return _parseHTML["default"];
  25201. }
  25202. });
  25203. var _convertToHTML = interopRequireDefault(convertToHTML_1);
  25204. var _convertFromHTML = interopRequireDefault(convertFromHTML_1);
  25205. var _parseHTML = interopRequireDefault(parseHTML_1);
  25206. });
  25207. index.unwrapExports(lib);
  25208. var configs = index.createCommonjsModule(function (module, exports) {
  25209. Object.defineProperty(exports, "__esModule", {
  25210. value: true
  25211. });
  25212. exports.getFromHTMLConfig = exports.getToHTMLConfig = exports.blocks = exports.getHexColor = exports.defaultFontFamilies = exports.namedColors = undefined;
  25213. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  25214. var _react2 = _interopRequireDefault(React__default);
  25215. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25216. function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
  25217. var namedColors = exports.namedColors = {
  25218. "aliceblue": "#f0f8ff",
  25219. "antiquewhite": "#faebd7",
  25220. "aqua": "#00ffff",
  25221. "aquamarine": "#7fffd4",
  25222. "azure": "#f0ffff",
  25223. "beige": "#f5f5dc",
  25224. "bisque": "#ffe4c4",
  25225. "black": "#000000",
  25226. "blanchedalmond": "#ffebcd",
  25227. "blue": "#0000ff",
  25228. "blueviolet": "#8a2be2",
  25229. "brown": "#a52a2a",
  25230. "burlywood": "#deb887",
  25231. "cadetblue": "#5f9ea0",
  25232. "chartreuse": "#7fff00",
  25233. "chocolate": "#d2691e",
  25234. "coral": "#ff7f50",
  25235. "cornflowerblue": "#6495ed",
  25236. "cornsilk": "#fff8dc",
  25237. "crimson": "#dc143c",
  25238. "cyan": "#00ffff",
  25239. "darkblue": "#00008b",
  25240. "darkcyan": "#008b8b",
  25241. "darkgoldenrod": "#b8860b",
  25242. "darkgray": "#a9a9a9",
  25243. "darkgreen": "#006400",
  25244. "darkkhaki": "#bdb76b",
  25245. "darkmagenta": "#8b008b",
  25246. "darkolivegreen": "#556b2f",
  25247. "darkorange": "#ff8c00",
  25248. "darkorchid": "#9932cc",
  25249. "darkred": "#8b0000",
  25250. "darksalmon": "#e9967a",
  25251. "darkseagreen": "#8fbc8f",
  25252. "darkslateblue": "#483d8b",
  25253. "darkslategray": "#2f4f4f",
  25254. "darkturquoise": "#00ced1",
  25255. "darkviolet": "#9400d3",
  25256. "deeppink": "#ff1493",
  25257. "deepskyblue": "#00bfff",
  25258. "dimgray": "#696969",
  25259. "dodgerblue": "#1e90ff",
  25260. "firebrick": "#b22222",
  25261. "floralwhite": "#fffaf0",
  25262. "forestgreen": "#228b22",
  25263. "fuchsia": "#ff00ff",
  25264. "gainsboro": "#dcdcdc",
  25265. "ghostwhite": "#f8f8ff",
  25266. "gold": "#ffd700",
  25267. "goldenrod": "#daa520",
  25268. "gray": "#808080",
  25269. "green": "#008000",
  25270. "greenyellow": "#adff2f",
  25271. "honeydew": "#f0fff0",
  25272. "hotpink": "#ff69b4",
  25273. "indianred ": "#cd5c5c",
  25274. "indigo": "#4b0082",
  25275. "ivory": "#fffff0",
  25276. "khaki": "#f0e68c",
  25277. "lavender": "#e6e6fa",
  25278. "lavenderblush": "#fff0f5",
  25279. "lawngreen": "#7cfc00",
  25280. "lemonchiffon": "#fffacd",
  25281. "lightblue": "#add8e6",
  25282. "lightcoral": "#f08080",
  25283. "lightcyan": "#e0ffff",
  25284. "lightgoldenrodyellow": "#fafad2",
  25285. "lightgrey": "#d3d3d3",
  25286. "lightgreen": "#90ee90",
  25287. "lightpink": "#ffb6c1",
  25288. "lightsalmon": "#ffa07a",
  25289. "lightseagreen": "#20b2aa",
  25290. "lightskyblue": "#87cefa",
  25291. "lightslategray": "#778899",
  25292. "lightsteelblue": "#b0c4de",
  25293. "lightyellow": "#ffffe0",
  25294. "lime": "#00ff00",
  25295. "limegreen": "#32cd32",
  25296. "linen": "#faf0e6",
  25297. "magenta": "#ff00ff",
  25298. "maroon": "#800000",
  25299. "mediumaquamarine": "#66cdaa",
  25300. "mediumblue": "#0000cd",
  25301. "mediumorchid": "#ba55d3",
  25302. "mediumpurple": "#9370d8",
  25303. "mediumseagreen": "#3cb371",
  25304. "mediumslateblue": "#7b68ee",
  25305. "mediumspringgreen": "#00fa9a",
  25306. "mediumturquoise": "#48d1cc",
  25307. "mediumvioletred": "#c71585",
  25308. "midnightblue": "#191970",
  25309. "mintcream": "#f5fffa",
  25310. "mistyrose": "#ffe4e1",
  25311. "moccasin": "#ffe4b5",
  25312. "navajowhite": "#ffdead",
  25313. "navy": "#000080",
  25314. "oldlace": "#fdf5e6",
  25315. "olive": "#808000",
  25316. "olivedrab": "#6b8e23",
  25317. "orange": "#ffa500",
  25318. "orangered": "#ff4500",
  25319. "orchid": "#da70d6",
  25320. "palegoldenrod": "#eee8aa",
  25321. "palegreen": "#98fb98",
  25322. "paleturquoise": "#afeeee",
  25323. "palevioletred": "#d87093",
  25324. "papayawhip": "#ffefd5",
  25325. "peachpuff": "#ffdab9",
  25326. "peru": "#cd853f",
  25327. "pink": "#ffc0cb",
  25328. "plum": "#dda0dd",
  25329. "powderblue": "#b0e0e6",
  25330. "purple": "#800080",
  25331. "rebeccapurple": "#663399",
  25332. "red": "#ff0000",
  25333. "rosybrown": "#bc8f8f",
  25334. "royalblue": "#4169e1",
  25335. "saddlebrown": "#8b4513",
  25336. "salmon": "#fa8072",
  25337. "sandybrown": "#f4a460",
  25338. "seagreen": "#2e8b57",
  25339. "seashell": "#fff5ee",
  25340. "sienna": "#a0522d",
  25341. "silver": "#c0c0c0",
  25342. "skyblue": "#87ceeb",
  25343. "slateblue": "#6a5acd",
  25344. "slategray": "#708090",
  25345. "snow": "#fffafa",
  25346. "springgreen": "#00ff7f",
  25347. "steelblue": "#4682b4",
  25348. "tan": "#d2b48c",
  25349. "teal": "#008080",
  25350. "thistle": "#d8bfd8",
  25351. "tomato": "#ff6347",
  25352. "turquoise": "#40e0d0",
  25353. "violet": "#ee82ee",
  25354. "wheat": "#f5deb3",
  25355. "white": "#ffffff",
  25356. "whitesmoke": "#f5f5f5",
  25357. "yellow": "#ffff00",
  25358. "yellowgreen": "#9acd32"
  25359. };
  25360. var getStyleValue = function getStyleValue(style) {
  25361. return style.split('-')[1];
  25362. };
  25363. var defaultUnitExportFn = function defaultUnitExportFn(unit) {
  25364. return unit + 'px';
  25365. };
  25366. var defaultUnitImportFn = function defaultUnitImportFn(unit) {
  25367. return unit.replace('px', '');
  25368. };
  25369. var ignoredNodeAttributes = ['style'];
  25370. var ignoredEntityNodeAttributes = ['style', 'href', 'target', 'alt', 'title', 'id', 'controls', 'autoplay', 'loop', 'poster'];
  25371. var spreadNodeAttributes = function spreadNodeAttributes(attributesObject) {
  25372. return Object.keys(attributesObject).reduce(function (attributeString, attributeName) {
  25373. return attributeString + " " + attributeName + "=\"" + attributesObject[attributeName] + "\"";
  25374. }, '').replace(/^\s$/, '');
  25375. };
  25376. var defaultFontFamilies = exports.defaultFontFamilies = [{
  25377. name: 'Araial',
  25378. family: 'Arial, Helvetica, sans-serif'
  25379. }, {
  25380. name: 'Georgia',
  25381. family: 'Georgia, serif'
  25382. }, {
  25383. name: 'Impact',
  25384. family: 'Impact, serif'
  25385. }, {
  25386. name: 'Monospace',
  25387. family: '"Courier New", Courier, monospace'
  25388. }, {
  25389. name: 'Tahoma',
  25390. family: "tahoma, arial, 'Hiragino Sans GB', 宋体, sans-serif"
  25391. }];
  25392. var getHexColor = exports.getHexColor = function getHexColor(color) {
  25393. color = color.replace('color:', '').replace(';', '').replace(' ', '');
  25394. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  25395. return color;
  25396. } else if (namedColors[color]) {
  25397. return namedColors[color];
  25398. } else if (color.indexOf('rgb') === 0) {
  25399. var rgbArray = color.split(',');
  25400. var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
  25401. var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
  25402. return hex.length === 1 ? '0' + hex : hex;
  25403. }).join('');
  25404. return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
  25405. );
  25406. } else {
  25407. return null;
  25408. }
  25409. };
  25410. var blocks = exports.blocks = {
  25411. 'header-one': 'h1',
  25412. 'header-two': 'h2',
  25413. 'header-three': 'h3',
  25414. 'header-four': 'h4',
  25415. 'header-five': 'h5',
  25416. 'header-six': 'h6',
  25417. 'unstyled': 'p',
  25418. 'blockquote': 'blockquote'
  25419. };
  25420. var blockTypes = Object.keys(blocks);
  25421. var blockNames = blockTypes.map(function (key) {
  25422. return blocks[key];
  25423. });
  25424. var convertAtomicBlock = function convertAtomicBlock(block, contentState, blockNodeAttributes) {
  25425. if (!block || !block.key) {
  25426. return _react2.default.createElement("p", null);
  25427. }
  25428. var contentBlock = contentState.getBlockForKey(block.key);
  25429. var className = blockNodeAttributes.class,
  25430. nodeAttrAsProps = _objectWithoutProperties(blockNodeAttributes, ["class"]);
  25431. nodeAttrAsProps.className = className;
  25432. if (!contentBlock) {
  25433. return _react2.default.createElement("p", null);
  25434. }
  25435. var entityKey = contentBlock.getEntityAt(0);
  25436. if (!entityKey) {
  25437. return _react2.default.createElement("p", null);
  25438. }
  25439. var entity = contentState.getEntity(entityKey);
  25440. var mediaType = entity.getType().toLowerCase();
  25441. var _block$data = block.data,
  25442. float = _block$data.float,
  25443. alignment = _block$data.alignment;
  25444. var _entity$getData = entity.getData(),
  25445. url = _entity$getData.url,
  25446. link = _entity$getData.link,
  25447. link_target = _entity$getData.link_target,
  25448. width = _entity$getData.width,
  25449. height = _entity$getData.height,
  25450. meta = _entity$getData.meta;
  25451. if (mediaType === 'image') {
  25452. var imageWrapStyle = {};
  25453. var styledClassName = '';
  25454. if (float) {
  25455. imageWrapStyle.float = float;
  25456. styledClassName += ' float-' + float;
  25457. } else if (alignment) {
  25458. imageWrapStyle.textAlign = alignment;
  25459. styledClassName += ' align-' + alignment;
  25460. }
  25461. if (link) {
  25462. return _react2.default.createElement(
  25463. "div",
  25464. { className: "media-wrap image-wrap" + styledClassName, style: imageWrapStyle },
  25465. _react2.default.createElement(
  25466. "a",
  25467. { style: { display: 'inline-block' }, href: link, target: link_target },
  25468. _react2.default.createElement("img", _extends({}, nodeAttrAsProps, meta, { src: url, width: width, height: height, style: { width: width, height: height } }))
  25469. )
  25470. );
  25471. } else {
  25472. return _react2.default.createElement(
  25473. "div",
  25474. { className: "media-wrap image-wrap" + styledClassName, style: imageWrapStyle },
  25475. _react2.default.createElement("img", _extends({}, nodeAttrAsProps, meta, { src: url, width: width, height: height, style: { width: width, height: height } }))
  25476. );
  25477. }
  25478. } else if (mediaType === 'audio') {
  25479. return _react2.default.createElement(
  25480. "div",
  25481. { className: "media-wrap audio-wrap" },
  25482. _react2.default.createElement("audio", _extends({ controls: true }, nodeAttrAsProps, meta, { src: url }))
  25483. );
  25484. } else if (mediaType === 'video') {
  25485. return _react2.default.createElement(
  25486. "div",
  25487. { className: "media-wrap video-wrap" },
  25488. _react2.default.createElement("video", _extends({ controls: true }, nodeAttrAsProps, meta, { src: url, width: width, height: height }))
  25489. );
  25490. } else if (mediaType === 'embed') {
  25491. return _react2.default.createElement(
  25492. "div",
  25493. { className: "media-wrap embed-wrap" },
  25494. _react2.default.createElement("div", { dangerouslySetInnerHTML: { __html: url } })
  25495. );
  25496. } else if (mediaType === 'hr') {
  25497. return _react2.default.createElement("hr", null);
  25498. } else {
  25499. return _react2.default.createElement("p", null);
  25500. }
  25501. };
  25502. var entityToHTML = function entityToHTML(options) {
  25503. return function (entity, originalText) {
  25504. var entityExportFn = options.entityExportFn;
  25505. var entityType = entity.type.toLowerCase();
  25506. if (entityExportFn) {
  25507. var customOutput = entityExportFn(entity, originalText);
  25508. if (customOutput) {
  25509. return customOutput;
  25510. }
  25511. }
  25512. if (entityType === 'link') {
  25513. var _ref = entity.data.nodeAttributes || {},
  25514. className = _ref.class,
  25515. nodeAttrAsProps = _objectWithoutProperties(_ref, ["class"]);
  25516. nodeAttrAsProps.className = className;
  25517. return _react2.default.createElement("a", _extends({ href: entity.data.href, target: entity.data.target }, nodeAttrAsProps));
  25518. }
  25519. };
  25520. };
  25521. var styleToHTML = function styleToHTML(options) {
  25522. return function (style) {
  25523. var unitExportFn = options.unitExportFn || defaultUnitExportFn;
  25524. if (options.styleExportFn) {
  25525. var customOutput = options.styleExportFn(style, options);
  25526. if (customOutput) {
  25527. return customOutput;
  25528. }
  25529. }
  25530. style = style.toLowerCase();
  25531. if (style === 'strikethrough') {
  25532. return _react2.default.createElement("span", { style: { textDecoration: 'line-through' } });
  25533. } else if (style === 'superscript') {
  25534. return _react2.default.createElement("sup", null);
  25535. } else if (style === 'subscript') {
  25536. return _react2.default.createElement("sub", null);
  25537. } else if (style.indexOf('color-') === 0) {
  25538. return _react2.default.createElement("span", { style: { color: '#' + getStyleValue(style) } });
  25539. } else if (style.indexOf('bgcolor-') === 0) {
  25540. return _react2.default.createElement("span", { style: { backgroundColor: '#' + getStyleValue(style) } });
  25541. } else if (style.indexOf('fontsize-') === 0) {
  25542. return _react2.default.createElement("span", { style: { fontSize: unitExportFn(getStyleValue(style), 'font-size', 'html') } });
  25543. } else if (style.indexOf('lineheight-') === 0) {
  25544. return _react2.default.createElement("span", { style: { lineHeight: unitExportFn(getStyleValue(style), 'line-height', 'html') } });
  25545. } else if (style.indexOf('letterspacing-') === 0) {
  25546. return _react2.default.createElement("span", { style: { letterSpacing: unitExportFn(getStyleValue(style), 'letter-spacing', 'html') } });
  25547. } else if (style.indexOf('fontfamily-') === 0) {
  25548. var fontFamily = options.fontFamilies.find(function (item) {
  25549. return item.name.toLowerCase() === getStyleValue(style);
  25550. });
  25551. if (!fontFamily) return;
  25552. return _react2.default.createElement("span", { style: { fontFamily: fontFamily.family } });
  25553. }
  25554. };
  25555. };
  25556. var blockToHTML = function blockToHTML(options) {
  25557. return function (block) {
  25558. var blockExportFn = options.blockExportFn,
  25559. contentState = options.contentState;
  25560. if (blockExportFn) {
  25561. var customOutput = blockExportFn(contentState, block);
  25562. if (customOutput) {
  25563. return customOutput;
  25564. }
  25565. }
  25566. var blockStyle = '';
  25567. var blockType = block.type.toLowerCase();
  25568. var _block$data2 = block.data,
  25569. textAlign = _block$data2.textAlign,
  25570. textIndent = _block$data2.textIndent,
  25571. _block$data2$nodeAttr = _block$data2.nodeAttributes,
  25572. nodeAttributes = _block$data2$nodeAttr === undefined ? {} : _block$data2$nodeAttr;
  25573. var attributeString = spreadNodeAttributes(nodeAttributes);
  25574. if (textAlign || textIndent) {
  25575. blockStyle = ' style="';
  25576. if (textAlign) {
  25577. blockStyle += "text-align:" + textAlign + ";";
  25578. }
  25579. if (textIndent && !isNaN(textIndent) && textIndent > 0) {
  25580. blockStyle += "text-indent:" + textIndent * 2 + "em;";
  25581. }
  25582. blockStyle += '"';
  25583. }
  25584. if (blockType === 'atomic') {
  25585. return convertAtomicBlock(block, contentState, nodeAttributes);
  25586. } else if (blockType === 'code-block') {
  25587. var previousBlock = contentState.getBlockBefore(block.key);
  25588. var nextBlock = contentState.getBlockAfter(block.key);
  25589. var previousBlockType = previousBlock && previousBlock.getType();
  25590. var nextBlockType = nextBlock && nextBlock.getType();
  25591. var start = '';
  25592. var end = '';
  25593. if (previousBlockType !== 'code-block') {
  25594. start = "<pre" + attributeString + "><code>";
  25595. } else {
  25596. start = '';
  25597. }
  25598. if (nextBlockType !== 'code-block') {
  25599. end = '</code></pre>';
  25600. } else {
  25601. end = '<br/>';
  25602. }
  25603. return { start: start, end: end };
  25604. } else if (blocks[blockType]) {
  25605. return {
  25606. start: "<" + blocks[blockType] + blockStyle + attributeString + ">",
  25607. end: "</" + blocks[blockType] + ">"
  25608. };
  25609. } else if (blockType === 'unordered-list-item') {
  25610. return {
  25611. start: "<li" + blockStyle + attributeString + ">",
  25612. end: '</li>',
  25613. nest: _react2.default.createElement("ul", null)
  25614. };
  25615. } else if (blockType === 'ordered-list-item') {
  25616. return {
  25617. start: "<li" + blockStyle + attributeString + ">",
  25618. end: '</li>',
  25619. nest: _react2.default.createElement("ol", null)
  25620. };
  25621. }
  25622. };
  25623. };
  25624. var htmlToStyle = function htmlToStyle(options, source) {
  25625. return function (nodeName, node, currentStyle) {
  25626. if (!node || !node.style) {
  25627. return currentStyle;
  25628. }
  25629. var unitImportFn = options.unitImportFn || defaultUnitImportFn;
  25630. var newStyle = currentStyle;
  25631. [].forEach.call(node.style, function (style) {
  25632. if (nodeName === 'span' && style === 'color') {
  25633. var color = getHexColor(node.style.color);
  25634. newStyle = color ? newStyle.add('COLOR-' + color.replace('#', '').toUpperCase()) : newStyle;
  25635. } else if (nodeName === 'span' && style === 'background-color') {
  25636. var _color = getHexColor(node.style.backgroundColor);
  25637. newStyle = _color ? newStyle.add('BGCOLOR-' + _color.replace('#', '').toUpperCase()) : newStyle;
  25638. } else if (nodeName === 'span' && style === 'font-size') {
  25639. newStyle = newStyle.add('FONTSIZE-' + unitImportFn(node.style.fontSize, 'font-size', source));
  25640. } else if (nodeName === 'span' && style === 'line-height' && !isNaN(parseFloat(node.style.lineHeight, 10))) {
  25641. newStyle = newStyle.add('LINEHEIGHT-' + unitImportFn(node.style.lineHeight, 'line-height', source));
  25642. } else if (nodeName === 'span' && style === 'letter-spacing' && !isNaN(parseFloat(node.style.letterSpacing, 10))) {
  25643. newStyle = newStyle.add('LETTERSPACING-' + unitImportFn(node.style.letterSpacing, 'letter-spacing', source));
  25644. } else if (nodeName === 'span' && style === 'text-decoration') {
  25645. if (node.style.textDecoration === 'line-through') {
  25646. newStyle = newStyle.add('STRIKETHROUGH');
  25647. } else if (node.style.textDecoration === 'underline') {
  25648. newStyle = newStyle.add('UNDERLINE');
  25649. }
  25650. } else if (nodeName === 'span' && style === 'font-family') {
  25651. var fontFamily = options.fontFamilies.find(function (item) {
  25652. return item.family.toLowerCase() === node.style.fontFamily.toLowerCase();
  25653. });
  25654. if (!fontFamily) return;
  25655. newStyle = newStyle.add('FONTFAMILY-' + fontFamily.name.toUpperCase());
  25656. }
  25657. });
  25658. if (nodeName === 'sup') {
  25659. newStyle = newStyle.add('SUPERSCRIPT');
  25660. } else if (nodeName === 'sub') {
  25661. newStyle = newStyle.add('SUBSCRIPT');
  25662. }
  25663. options.styleImportFn && (newStyle = options.styleImportFn(nodeName, node, newStyle, source) || newStyle);
  25664. return newStyle;
  25665. };
  25666. };
  25667. var htmlToEntity = function htmlToEntity(options, source) {
  25668. return function (nodeName, node, createEntity) {
  25669. if (options && options.entityImportFn) {
  25670. var customInput = options.entityImportFn(nodeName, node, createEntity, source);
  25671. if (customInput) {
  25672. return customInput;
  25673. }
  25674. }
  25675. nodeName = nodeName.toLowerCase();
  25676. var alt = node.alt,
  25677. title = node.title,
  25678. id = node.id,
  25679. controls = node.controls,
  25680. autoplay = node.autoplay,
  25681. loop = node.loop,
  25682. poster = node.poster;
  25683. var meta = {};
  25684. var nodeAttributes = {};
  25685. id && (meta.id = id);
  25686. alt && (meta.alt = alt);
  25687. title && (meta.title = title);
  25688. controls && (meta.controls = controls);
  25689. autoplay && (meta.autoPlay = autoplay);
  25690. loop && (meta.loop = loop);
  25691. poster && (meta.poster = poster);
  25692. node.attributes && Object.keys(node.attributes).forEach(function (key) {
  25693. var attr = node.attributes[key];
  25694. ignoredEntityNodeAttributes.indexOf(attr.name) === -1 && (nodeAttributes[attr.name] = attr.value);
  25695. });
  25696. if (nodeName === 'a' && !node.querySelectorAll('img').length) {
  25697. var href = node.getAttribute('href');
  25698. var _target = node.getAttribute('target');
  25699. return createEntity('LINK', 'MUTABLE', { href: href, target: _target, nodeAttributes: nodeAttributes });
  25700. } else if (nodeName === 'audio') {
  25701. return createEntity('AUDIO', 'IMMUTABLE', { url: node.getAttribute('src'), meta: meta, nodeAttributes: nodeAttributes });
  25702. } else if (nodeName === 'video') {
  25703. return createEntity('VIDEO', 'IMMUTABLE', { url: node.getAttribute('src'), meta: meta, nodeAttributes: nodeAttributes });
  25704. } else if (nodeName === 'img') {
  25705. var parentNode = node.parentNode;
  25706. var entityData = { meta: meta };
  25707. var _node$style = node.style,
  25708. width = _node$style.width,
  25709. height = _node$style.height;
  25710. entityData.url = node.getAttribute('src');
  25711. width && (entityData.width = width);
  25712. height && (entityData.height = height);
  25713. if (parentNode.nodeName.toLowerCase() === 'a') {
  25714. entityData.link = parentNode.getAttribute('href');
  25715. entityData.link_target = parentNode.getAttribute('target');
  25716. }
  25717. return createEntity('IMAGE', 'IMMUTABLE', entityData);
  25718. } else if (nodeName === 'hr') {
  25719. return createEntity('HR', 'IMMUTABLE', {});
  25720. } else if (node.parentNode && node.parentNode.classList.contains('embed-wrap')) {
  25721. var embedContent = node.innerHTML || node.outerHTML;
  25722. if (embedContent) {
  25723. return createEntity('EMBED', 'IMMUTABLE', {
  25724. url: embedContent
  25725. });
  25726. }
  25727. }
  25728. };
  25729. };
  25730. var htmlToBlock = function htmlToBlock(options, source) {
  25731. return function (nodeName, node) {
  25732. if (options && options.blockImportFn) {
  25733. var customInput = options.blockImportFn(nodeName, node, source);
  25734. if (customInput) {
  25735. return customInput;
  25736. }
  25737. }
  25738. var nodeAttributes = {};
  25739. var nodeStyle = node.style || {};
  25740. node.attributes && Object.keys(node.attributes).forEach(function (key) {
  25741. var attr = node.attributes[key];
  25742. ignoredNodeAttributes.indexOf(attr.name) === -1 && (nodeAttributes[attr.name] = attr.value);
  25743. });
  25744. if (node.classList && node.classList.contains('media-wrap')) {
  25745. return {
  25746. type: 'atomic',
  25747. data: {
  25748. nodeAttributes: nodeAttributes,
  25749. float: nodeStyle.float,
  25750. alignment: nodeStyle.textAlign
  25751. }
  25752. };
  25753. } else if (nodeName === 'img') {
  25754. return {
  25755. type: 'atomic',
  25756. data: {
  25757. nodeAttributes: nodeAttributes,
  25758. float: nodeStyle.float,
  25759. alignment: nodeStyle.textAlign
  25760. }
  25761. };
  25762. } else if (nodeName === 'hr') {
  25763. return {
  25764. type: 'atomic',
  25765. data: { nodeAttributes: nodeAttributes }
  25766. };
  25767. } else if (nodeName === 'pre') {
  25768. node.innerHTML = node.innerHTML.replace(/<code(.*?)>/g, '').replace(/<\/code>/g, '');
  25769. return {
  25770. type: 'code-block',
  25771. data: { nodeAttributes: nodeAttributes }
  25772. };
  25773. } else if (blockNames.indexOf(nodeName) !== -1) {
  25774. var blockData = { nodeAttributes: nodeAttributes };
  25775. if (nodeStyle.textAlign) {
  25776. blockData.textAlign = nodeStyle.textAlign;
  25777. }
  25778. if (nodeStyle.textIndent) {
  25779. blockData.textIndent = /^\d+em$/.test(nodeStyle.textIndent) ? Math.ceil(parseInt(nodeStyle.textIndent, 10) / 2) : 1;
  25780. }
  25781. return {
  25782. type: blockTypes[blockNames.indexOf(nodeName)],
  25783. data: blockData
  25784. };
  25785. }
  25786. };
  25787. };
  25788. var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(options) {
  25789. return {
  25790. styleToHTML: styleToHTML(options),
  25791. entityToHTML: entityToHTML(options),
  25792. blockToHTML: blockToHTML(options)
  25793. };
  25794. };
  25795. var getFromHTMLConfig = exports.getFromHTMLConfig = function getFromHTMLConfig(options) {
  25796. var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unknow';
  25797. return {
  25798. htmlToStyle: htmlToStyle(options, source),
  25799. htmlToEntity: htmlToEntity(options, source),
  25800. htmlToBlock: htmlToBlock(options, source)
  25801. };
  25802. };
  25803. });
  25804. index.unwrapExports(configs);
  25805. var configs_1 = configs.getFromHTMLConfig;
  25806. var configs_2 = configs.getToHTMLConfig;
  25807. var configs_3 = configs.blocks;
  25808. var configs_4 = configs.getHexColor;
  25809. var configs_5 = configs.defaultFontFamilies;
  25810. var configs_6 = configs.namedColors;
  25811. var dist = index.createCommonjsModule(function (module, exports) {
  25812. Object.defineProperty(exports, "__esModule", {
  25813. value: true
  25814. });
  25815. exports.convertRawToEditorState = exports.convertEditorStateToRaw = exports.convertHTMLToEditorState = exports.convertEditorStateToHTML = exports.convertHTMLToRaw = exports.convertRawToHTML = undefined;
  25816. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  25817. var defaultConvertOptions = {
  25818. fontFamilies: configs.defaultFontFamilies
  25819. };
  25820. var convertRawToHTML = exports.convertRawToHTML = function convertRawToHTML(rawContent, options) {
  25821. options = _extends({}, defaultConvertOptions, options);
  25822. try {
  25823. var contentState = (0, Draft.convertFromRaw)(rawContent);
  25824. options.contentState = contentState;
  25825. return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(contentState);
  25826. } catch (error) {
  25827. console.warn(error);
  25828. return '';
  25829. }
  25830. };
  25831. var convertHTMLToRaw = exports.convertHTMLToRaw = function convertHTMLToRaw(HTMLString, options, source) {
  25832. options = _extends({}, defaultConvertOptions, options);
  25833. try {
  25834. var contentState = (0, lib.convertFromHTML)((0, configs.getFromHTMLConfig)(options, source))(HTMLString);
  25835. return (0, Draft.convertToRaw)(contentState);
  25836. } catch (error) {
  25837. console.warn(error);
  25838. return {};
  25839. }
  25840. };
  25841. var convertEditorStateToHTML = exports.convertEditorStateToHTML = function convertEditorStateToHTML(editorState, options) {
  25842. options = _extends({}, defaultConvertOptions, options);
  25843. try {
  25844. var contentState = editorState.getCurrentContent();
  25845. options.contentState = contentState;
  25846. return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(contentState);
  25847. } catch (error) {
  25848. console.warn(error);
  25849. return '';
  25850. }
  25851. };
  25852. var convertHTMLToEditorState = exports.convertHTMLToEditorState = function convertHTMLToEditorState(HTMLString, editorDecorators, options, source) {
  25853. options = _extends({}, defaultConvertOptions, options);
  25854. try {
  25855. return Draft.EditorState.createWithContent((0, lib.convertFromHTML)((0, configs.getFromHTMLConfig)(options, source))(HTMLString), editorDecorators);
  25856. } catch (error) {
  25857. console.warn(error);
  25858. return Draft.EditorState.createEmpty(editorDecorators);
  25859. }
  25860. };
  25861. var convertEditorStateToRaw = exports.convertEditorStateToRaw = function convertEditorStateToRaw(editorState) {
  25862. return (0, Draft.convertToRaw)(editorState.getCurrentContent());
  25863. };
  25864. var convertRawToEditorState = exports.convertRawToEditorState = function convertRawToEditorState(rawContent, editorDecorators) {
  25865. try {
  25866. return Draft.EditorState.createWithContent((0, Draft.convertFromRaw)(rawContent), editorDecorators);
  25867. } catch (error) {
  25868. console.warn(error);
  25869. return Draft.EditorState.createEmpty(editorDecorators);
  25870. }
  25871. };
  25872. });
  25873. index.unwrapExports(dist);
  25874. var dist_1 = dist.convertRawToEditorState;
  25875. var dist_2 = dist.convertEditorStateToRaw;
  25876. var dist_3 = dist.convertHTMLToEditorState;
  25877. var dist_4 = dist.convertEditorStateToHTML;
  25878. var dist_5 = dist.convertHTMLToRaw;
  25879. var dist_6 = dist.convertRawToHTML;
  25880. var content = index.createCommonjsModule(function (module, exports) {
  25881. Object.defineProperty(exports, "__esModule", {
  25882. value: true
  25883. });
  25884. exports.redo = exports.undo = exports.handleKeyCommand = exports.clear = exports.setMediaPosition = exports.removeMedia = exports.setMediaData = exports.insertMedias = exports.insertHorizontalLine = exports.insertAtomicBlock = exports.insertHTML = exports.insertText = exports.toggleSelectionLetterSpacing = exports.toggleSelectionFontFamily = exports.toggleSelectionLineHeight = exports.toggleSelectionFontSize = exports.toggleSelectionBackgroundColor = exports.toggleSelectionColor = exports.decreaseSelectionIndent = exports.increaseSelectionIndent = exports.toggleSelectionIndent = exports.toggleSelectionAlignment = exports.removeSelectionInlineStyles = exports.toggleSelectionInlineStyle = exports.selectionHasInlineStyle = exports.getSelectionInlineStyle = exports.toggleSelectionLink = exports.toggleSelectionEntity = exports.getSelectionEntityData = exports.getSelectionEntityType = exports.toggleSelectionBlockType = exports.getSelectionText = exports.getSelectionBlockType = exports.getSelectionBlockData = exports.setSelectionBlockData = exports.getSelectedBlocks = exports.updateEachCharacterOfSelection = exports.getSelectionBlock = exports.removeBlock = exports.selectNextBlock = exports.selectBlock = exports.selectionContainsStrictBlock = exports.selectionContainsBlockType = exports.isSelectionCollapsed = exports.createEditorState = exports.createEmptyEditorState = exports.isEditorState = exports.registerStrictBlockType = undefined;
  25885. var _immutable2 = _interopRequireDefault(immutable$1);
  25886. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  25887. var strictBlockTypes = ['atomic'];
  25888. var registerStrictBlockType = exports.registerStrictBlockType = function registerStrictBlockType(blockType) {
  25889. strictBlockTypes.indexOf(blockType) === -1 && strictBlockTypes.push(blockType);
  25890. };
  25891. var isEditorState = exports.isEditorState = function isEditorState(editorState) {
  25892. return editorState instanceof Draft.EditorState;
  25893. };
  25894. var createEmptyEditorState = exports.createEmptyEditorState = function createEmptyEditorState(editorDecorators) {
  25895. return Draft.EditorState.createEmpty(editorDecorators);
  25896. };
  25897. var createEditorState = exports.createEditorState = function createEditorState(contentState, editorDecorators) {
  25898. return Draft.EditorState.createWithContent(contentState, editorDecorators);
  25899. };
  25900. var isSelectionCollapsed = exports.isSelectionCollapsed = function isSelectionCollapsed(editorState) {
  25901. return editorState.getSelection().isCollapsed();
  25902. };
  25903. var selectionContainsBlockType = exports.selectionContainsBlockType = function selectionContainsBlockType(editorState, blockType) {
  25904. return getSelectedBlocks(editorState).find(function (block) {
  25905. return block.getType() === blockType;
  25906. });
  25907. };
  25908. var selectionContainsStrictBlock = exports.selectionContainsStrictBlock = function selectionContainsStrictBlock(editorState) {
  25909. return getSelectedBlocks(editorState).find(function (block) {
  25910. return ~strictBlockTypes.indexOf(block.getType());
  25911. });
  25912. };
  25913. var selectBlock = exports.selectBlock = function selectBlock(editorState, block) {
  25914. var blockKey = block.getKey();
  25915. return Draft.EditorState.forceSelection(editorState, new Draft.SelectionState({
  25916. anchorKey: blockKey,
  25917. anchorOffset: 0,
  25918. focusKey: blockKey,
  25919. focusOffset: block.getLength()
  25920. }));
  25921. };
  25922. var selectNextBlock = exports.selectNextBlock = function selectNextBlock(editorState, block) {
  25923. var nextBlock = editorState.getCurrentContent().getBlockAfter(block.getKey());
  25924. return nextBlock ? selectBlock(editorState, nextBlock) : editorState;
  25925. };
  25926. var removeBlock = exports.removeBlock = function removeBlock(editorState, block) {
  25927. var lastSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  25928. var nextContentState = void 0,
  25929. nextEditorState = void 0;
  25930. var blockKey = block.getKey();
  25931. nextContentState = Draft.Modifier.removeRange(editorState.getCurrentContent(), new Draft.SelectionState({
  25932. anchorKey: blockKey,
  25933. anchorOffset: 0,
  25934. focusKey: blockKey,
  25935. focusOffset: block.getLength()
  25936. }), 'backward');
  25937. nextContentState = Draft.Modifier.setBlockType(nextContentState, nextContentState.getSelectionAfter(), 'unstyled');
  25938. nextEditorState = Draft.EditorState.push(editorState, nextContentState, 'remove-range');
  25939. return Draft.EditorState.forceSelection(nextEditorState, lastSelection || nextContentState.getSelectionAfter());
  25940. };
  25941. var getSelectionBlock = exports.getSelectionBlock = function getSelectionBlock(editorState) {
  25942. return editorState.getCurrentContent().getBlockForKey(editorState.getSelection().getAnchorKey());
  25943. };
  25944. var updateEachCharacterOfSelection = exports.updateEachCharacterOfSelection = function updateEachCharacterOfSelection(editorState, callback) {
  25945. var selectionState = editorState.getSelection();
  25946. var contentState = editorState.getCurrentContent();
  25947. var contentBlocks = contentState.getBlockMap();
  25948. var selectedBlocks = getSelectedBlocks(editorState);
  25949. if (selectedBlocks.length === 0) {
  25950. return editorState;
  25951. }
  25952. var startKey = selectionState.getStartKey();
  25953. var startOffset = selectionState.getStartOffset();
  25954. var endKey = selectionState.getEndKey();
  25955. var endOffset = selectionState.getEndOffset();
  25956. var nextContentBlocks = contentBlocks.map(function (block) {
  25957. if (selectedBlocks.indexOf(block) === -1) {
  25958. return block;
  25959. }
  25960. var blockKey = block.getKey();
  25961. var charactersList = block.getCharacterList();
  25962. var nextCharactersList = null;
  25963. if (blockKey === startKey && blockKey === endKey) {
  25964. nextCharactersList = charactersList.map(function (character, index) {
  25965. if (index >= startOffset && index < endOffset) {
  25966. return callback(character);
  25967. }
  25968. return character;
  25969. });
  25970. } else if (blockKey === startKey) {
  25971. nextCharactersList = charactersList.map(function (character, index) {
  25972. if (index >= startOffset) {
  25973. return callback(character);
  25974. }
  25975. return character;
  25976. });
  25977. } else if (blockKey === endKey) {
  25978. nextCharactersList = charactersList.map(function (character, index) {
  25979. if (index < endOffset) {
  25980. return callback(character);
  25981. }
  25982. return character;
  25983. });
  25984. } else {
  25985. nextCharactersList = charactersList.map(function (character) {
  25986. return callback(character);
  25987. });
  25988. }
  25989. return block.merge({
  25990. 'characterList': nextCharactersList
  25991. });
  25992. });
  25993. return Draft.EditorState.push(editorState, contentState.merge({
  25994. blockMap: nextContentBlocks,
  25995. selectionBefore: selectionState,
  25996. selectionAfter: selectionState
  25997. }), 'update-selection-character-list');
  25998. };
  25999. var getSelectedBlocks = exports.getSelectedBlocks = function getSelectedBlocks(editorState) {
  26000. var selectionState = editorState.getSelection();
  26001. var contentState = editorState.getCurrentContent();
  26002. var startKey = selectionState.getStartKey();
  26003. var endKey = selectionState.getEndKey();
  26004. var isSameBlock = startKey === endKey;
  26005. var startingBlock = contentState.getBlockForKey(startKey);
  26006. var selectedBlocks = [startingBlock];
  26007. if (!isSameBlock) {
  26008. var blockKey = startKey;
  26009. while (blockKey !== endKey) {
  26010. var nextBlock = contentState.getBlockAfter(blockKey);
  26011. selectedBlocks.push(nextBlock);
  26012. blockKey = nextBlock.getKey();
  26013. }
  26014. }
  26015. return selectedBlocks;
  26016. };
  26017. var setSelectionBlockData = exports.setSelectionBlockData = function setSelectionBlockData(editorState, blockData, override) {
  26018. var newBlockData = override ? blockData : Object.assign({}, getSelectionBlockData(editorState).toJS(), blockData);
  26019. Object.keys(newBlockData).forEach(function (key) {
  26020. if (newBlockData.hasOwnProperty(key) && newBlockData[key] === undefined) {
  26021. delete newBlockData[key];
  26022. }
  26023. });
  26024. return (0, draftjsUtils.setBlockData)(editorState, newBlockData);
  26025. };
  26026. var getSelectionBlockData = exports.getSelectionBlockData = function getSelectionBlockData(editorState, name) {
  26027. var blockData = getSelectionBlock(editorState).getData();
  26028. return name ? blockData.get(name) : blockData;
  26029. };
  26030. var getSelectionBlockType = exports.getSelectionBlockType = function getSelectionBlockType(editorState) {
  26031. return getSelectionBlock(editorState).getType();
  26032. };
  26033. var getSelectionText = exports.getSelectionText = function getSelectionText(editorState) {
  26034. var selectionState = editorState.getSelection();
  26035. var contentState = editorState.getCurrentContent();
  26036. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  26037. return '';
  26038. }
  26039. var anchorKey = selectionState.getAnchorKey();
  26040. var currentContentBlock = contentState.getBlockForKey(anchorKey);
  26041. var start = selectionState.getStartOffset();
  26042. var end = selectionState.getEndOffset();
  26043. return currentContentBlock.getText().slice(start, end);
  26044. };
  26045. var toggleSelectionBlockType = exports.toggleSelectionBlockType = function toggleSelectionBlockType(editorState, blockType) {
  26046. if (selectionContainsStrictBlock(editorState)) {
  26047. return editorState;
  26048. }
  26049. return Draft.RichUtils.toggleBlockType(editorState, blockType);
  26050. };
  26051. var getSelectionEntityType = exports.getSelectionEntityType = function getSelectionEntityType(editorState) {
  26052. var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
  26053. if (entityKey) {
  26054. var entity = editorState.getCurrentContent().getEntity(entityKey);
  26055. return entity ? entity.get('type') : null;
  26056. }
  26057. return null;
  26058. };
  26059. var getSelectionEntityData = exports.getSelectionEntityData = function getSelectionEntityData(editorState, type) {
  26060. var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
  26061. if (entityKey) {
  26062. var entity = editorState.getCurrentContent().getEntity(entityKey);
  26063. if (entity && entity.get('type') === type) {
  26064. return entity.getData();
  26065. } else {
  26066. return {};
  26067. }
  26068. } else {
  26069. return {};
  26070. }
  26071. };
  26072. var toggleSelectionEntity = exports.toggleSelectionEntity = function toggleSelectionEntity(editorState, entity) {
  26073. var contentState = editorState.getCurrentContent();
  26074. var selectionState = editorState.getSelection();
  26075. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  26076. return editorState;
  26077. }
  26078. if (!entity || !entity.type || getSelectionEntityType(editorState) === entity.type) {
  26079. return Draft.EditorState.push(editorState, Draft.Modifier.applyEntity(contentState, selectionState, null), 'apply-entity');
  26080. }
  26081. try {
  26082. var nextContentState = contentState.createEntity(entity.type, entity.mutability, entity.data);
  26083. var entityKey = nextContentState.getLastCreatedEntityKey();
  26084. var nextEditorState = Draft.EditorState.set(editorState, {
  26085. currentContent: nextContentState
  26086. });
  26087. return Draft.EditorState.push(nextEditorState, Draft.Modifier.applyEntity(nextContentState, selectionState, entityKey), 'apply-entity');
  26088. } catch (error) {
  26089. console.warn(error);
  26090. return editorState;
  26091. }
  26092. };
  26093. var toggleSelectionLink = exports.toggleSelectionLink = function toggleSelectionLink(editorState, href, target) {
  26094. var contentState = editorState.getCurrentContent();
  26095. var selectionState = editorState.getSelection();
  26096. var entityData = { href: href, target: target };
  26097. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  26098. return editorState;
  26099. }
  26100. if (href === false) {
  26101. return Draft.RichUtils.toggleLink(editorState, selectionState, null);
  26102. }
  26103. if (href === null) {
  26104. delete entityData.href;
  26105. }
  26106. try {
  26107. var nextContentState = contentState.createEntity('LINK', 'MUTABLE', entityData);
  26108. var entityKey = nextContentState.getLastCreatedEntityKey();
  26109. var nextEditorState = Draft.EditorState.set(editorState, {
  26110. currentContent: nextContentState
  26111. });
  26112. nextEditorState = Draft.RichUtils.toggleLink(nextEditorState, selectionState, entityKey);
  26113. nextEditorState = Draft.EditorState.forceSelection(nextEditorState, selectionState.merge({
  26114. anchorOffset: selectionState.getEndOffset(),
  26115. focusOffset: selectionState.getEndOffset()
  26116. }));
  26117. nextEditorState = Draft.EditorState.push(nextEditorState, Draft.Modifier.insertText(nextEditorState.getCurrentContent(), nextEditorState.getSelection(), ''), 'insert-text');
  26118. return nextEditorState;
  26119. } catch (error) {
  26120. console.warn(error);
  26121. return editorState;
  26122. }
  26123. };
  26124. var getSelectionInlineStyle = exports.getSelectionInlineStyle = function getSelectionInlineStyle(editorState) {
  26125. return editorState.getCurrentInlineStyle();
  26126. };
  26127. var selectionHasInlineStyle = exports.selectionHasInlineStyle = function selectionHasInlineStyle(editorState, style) {
  26128. return getSelectionInlineStyle(editorState).has(style.toUpperCase());
  26129. };
  26130. var toggleSelectionInlineStyle = exports.toggleSelectionInlineStyle = function toggleSelectionInlineStyle(editorState, style) {
  26131. var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  26132. var nextEditorState = editorState;
  26133. style = prefix + style.toUpperCase();
  26134. if (prefix) {
  26135. nextEditorState = updateEachCharacterOfSelection(nextEditorState, function (characterMetadata) {
  26136. return characterMetadata.toJS().style.reduce(function (characterMetadata, characterStyle) {
  26137. if (characterStyle.indexOf(prefix) === 0 && style !== characterStyle) {
  26138. return Draft.CharacterMetadata.removeStyle(characterMetadata, characterStyle);
  26139. } else {
  26140. return characterMetadata;
  26141. }
  26142. }, characterMetadata);
  26143. });
  26144. }
  26145. return Draft.RichUtils.toggleInlineStyle(nextEditorState, style);
  26146. };
  26147. var removeSelectionInlineStyles = exports.removeSelectionInlineStyles = function removeSelectionInlineStyles(editorState) {
  26148. return updateEachCharacterOfSelection(editorState, function (characterMetadata) {
  26149. return characterMetadata.merge({
  26150. style: _immutable2.default.OrderedSet([])
  26151. });
  26152. });
  26153. };
  26154. var toggleSelectionAlignment = exports.toggleSelectionAlignment = function toggleSelectionAlignment(editorState, alignment) {
  26155. return setSelectionBlockData(editorState, {
  26156. textAlign: getSelectionBlockData(editorState, 'textAlign') !== alignment ? alignment : undefined
  26157. });
  26158. };
  26159. var toggleSelectionIndent = exports.toggleSelectionIndent = function toggleSelectionIndent(editorState, textIndent) {
  26160. var maxIndent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6;
  26161. return textIndent < 0 || textIndent > maxIndent || isNaN(textIndent) ? editorState : setSelectionBlockData(editorState, {
  26162. textIndent: textIndent || undefined
  26163. });
  26164. };
  26165. var increaseSelectionIndent = exports.increaseSelectionIndent = function increaseSelectionIndent(editorState) {
  26166. var maxIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
  26167. var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
  26168. return toggleSelectionIndent(editorState, currentIndent + 1, maxIndent);
  26169. };
  26170. var decreaseSelectionIndent = exports.decreaseSelectionIndent = function decreaseSelectionIndent(editorState) {
  26171. var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
  26172. return toggleSelectionIndent(editorState, currentIndent - 1);
  26173. };
  26174. var toggleSelectionColor = exports.toggleSelectionColor = function toggleSelectionColor(editorState, color) {
  26175. return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'COLOR-');
  26176. };
  26177. var toggleSelectionBackgroundColor = exports.toggleSelectionBackgroundColor = function toggleSelectionBackgroundColor(editorState, color) {
  26178. return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'BGCOLOR-');
  26179. };
  26180. var toggleSelectionFontSize = exports.toggleSelectionFontSize = function toggleSelectionFontSize(editorState, fontSize) {
  26181. return toggleSelectionInlineStyle(editorState, fontSize, 'FONTSIZE-');
  26182. };
  26183. var toggleSelectionLineHeight = exports.toggleSelectionLineHeight = function toggleSelectionLineHeight(editorState, lineHeight) {
  26184. return toggleSelectionInlineStyle(editorState, lineHeight, 'LINEHEIGHT-');
  26185. };
  26186. var toggleSelectionFontFamily = exports.toggleSelectionFontFamily = function toggleSelectionFontFamily(editorState, fontFamily) {
  26187. return toggleSelectionInlineStyle(editorState, fontFamily, 'FONTFAMILY-');
  26188. };
  26189. var toggleSelectionLetterSpacing = exports.toggleSelectionLetterSpacing = function toggleSelectionLetterSpacing(editorState, letterSpacing) {
  26190. return toggleSelectionInlineStyle(editorState, letterSpacing, 'LETTERSPACING-');
  26191. };
  26192. var insertText = exports.insertText = function insertText(editorState, text, inlineStyle, entity) {
  26193. var selectionState = editorState.getSelection();
  26194. var currentSelectedBlockType = getSelectionBlockType(editorState);
  26195. if (currentSelectedBlockType === 'atomic') {
  26196. return editorState;
  26197. }
  26198. var entityKey = void 0;
  26199. var contentState = editorState.getCurrentContent();
  26200. if (entity && entity.type) {
  26201. contentState = contentState.createEntity(entity.type, entity.mutability || 'MUTABLE', entity.data || entityData);
  26202. entityKey = contentState.getLastCreatedEntityKey();
  26203. }
  26204. if (!selectionState.isCollapsed()) {
  26205. return Draft.EditorState.push(editorState, Draft.Modifier.replaceText(contentState, selectionState, text, inlineStyle, entityKey), 'replace-text');
  26206. } else {
  26207. return Draft.EditorState.push(editorState, Draft.Modifier.insertText(contentState, selectionState, text, inlineStyle, entityKey), 'insert-text');
  26208. }
  26209. };
  26210. var insertHTML = exports.insertHTML = function insertHTML(editorState, htmlString, source) {
  26211. if (!htmlString) {
  26212. return editorState;
  26213. }
  26214. var selectionState = editorState.getSelection();
  26215. var contentState = editorState.getCurrentContent();
  26216. var options = editorState.convertOptions || {};
  26217. try {
  26218. var _convertFromRaw = (0, Draft.convertFromRaw)((0, dist.convertHTMLToRaw)(htmlString, options, source)),
  26219. blockMap = _convertFromRaw.blockMap;
  26220. return Draft.EditorState.push(editorState, Draft.Modifier.replaceWithFragment(contentState, selectionState, blockMap), 'insert-fragment');
  26221. } catch (error) {
  26222. console.warn(error);
  26223. return editorState;
  26224. }
  26225. };
  26226. var insertAtomicBlock = exports.insertAtomicBlock = function insertAtomicBlock(editorState, type) {
  26227. var immutable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  26228. var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  26229. if (selectionContainsStrictBlock(editorState)) {
  26230. return insertAtomicBlock(selectNextBlock(editorState, getSelectionBlock(editorState)), type, immutable, data);
  26231. }
  26232. var selectionState = editorState.getSelection();
  26233. var contentState = editorState.getCurrentContent();
  26234. if (!selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  26235. return editorState;
  26236. }
  26237. var contentStateWithEntity = contentState.createEntity(type, immutable ? 'IMMUTABLE' : 'MUTABLE', data);
  26238. var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
  26239. var newEditorState = Draft.AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, ' ');
  26240. return newEditorState;
  26241. };
  26242. var insertHorizontalLine = exports.insertHorizontalLine = function insertHorizontalLine(editorState) {
  26243. return insertAtomicBlock(editorState, 'HR');
  26244. };
  26245. var insertMedias = exports.insertMedias = function insertMedias(editorState) {
  26246. var medias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  26247. if (!medias.length) {
  26248. return editorState;
  26249. }
  26250. return medias.reduce(function (editorState, media) {
  26251. var url = media.url,
  26252. link = media.link,
  26253. link_target = media.link_target,
  26254. name = media.name,
  26255. type = media.type,
  26256. width = media.width,
  26257. height = media.height,
  26258. meta = media.meta;
  26259. return insertAtomicBlock(editorState, type, true, { url: url, link: link, link_target: link_target, name: name, type: type, width: width, height: height, meta: meta });
  26260. }, editorState);
  26261. };
  26262. var setMediaData = exports.setMediaData = function setMediaData(editorState, entityKey, data) {
  26263. return Draft.EditorState.push(editorState, editorState.getCurrentContent().mergeEntityData(entityKey, data), 'change-block-data');
  26264. };
  26265. var removeMedia = exports.removeMedia = function removeMedia(editorState, mediaBlock) {
  26266. return removeBlock(editorState, mediaBlock);
  26267. };
  26268. var setMediaPosition = exports.setMediaPosition = function setMediaPosition(editorState, mediaBlock, position) {
  26269. var newPosition = {};
  26270. var float = position.float,
  26271. alignment = position.alignment;
  26272. if (typeof float !== 'undefined') {
  26273. newPosition.float = mediaBlock.getData().get('float') === float ? null : float;
  26274. }
  26275. if (typeof alignment !== 'undefined') {
  26276. newPosition.alignment = mediaBlock.getData().get('alignment') === alignment ? null : alignment;
  26277. }
  26278. return setSelectionBlockData(selectBlock(editorState, mediaBlock), newPosition);
  26279. };
  26280. var clear = exports.clear = function clear(editorState) {
  26281. var contentState = editorState.getCurrentContent();
  26282. var firstBlock = contentState.getFirstBlock();
  26283. var lastBlock = contentState.getLastBlock();
  26284. var allSelected = new Draft.SelectionState({
  26285. anchorKey: firstBlock.getKey(),
  26286. anchorOffset: 0,
  26287. focusKey: lastBlock.getKey(),
  26288. focusOffset: lastBlock.getLength(),
  26289. hasFocus: true
  26290. });
  26291. return Draft.RichUtils.toggleBlockType(Draft.EditorState.push(editorState, Draft.Modifier.removeRange(contentState, allSelected, 'backward'), 'remove-range'), 'unstyled');
  26292. };
  26293. var handleKeyCommand = exports.handleKeyCommand = function handleKeyCommand(editorState, command) {
  26294. return Draft.RichUtils.handleKeyCommand(editorState, command);
  26295. };
  26296. var undo = exports.undo = function undo(editorState) {
  26297. return Draft.EditorState.undo(editorState);
  26298. };
  26299. var redo = exports.redo = function redo(editorState) {
  26300. return Draft.EditorState.redo(editorState);
  26301. };
  26302. });
  26303. index.unwrapExports(content);
  26304. var content_1 = content.redo;
  26305. var content_2 = content.undo;
  26306. var content_3 = content.handleKeyCommand;
  26307. var content_4 = content.clear;
  26308. var content_5 = content.setMediaPosition;
  26309. var content_6 = content.removeMedia;
  26310. var content_7 = content.setMediaData;
  26311. var content_8 = content.insertMedias;
  26312. var content_9 = content.insertHorizontalLine;
  26313. var content_10 = content.insertAtomicBlock;
  26314. var content_11 = content.insertHTML;
  26315. var content_12 = content.insertText;
  26316. var content_13 = content.toggleSelectionLetterSpacing;
  26317. var content_14 = content.toggleSelectionFontFamily;
  26318. var content_15 = content.toggleSelectionLineHeight;
  26319. var content_16 = content.toggleSelectionFontSize;
  26320. var content_17 = content.toggleSelectionBackgroundColor;
  26321. var content_18 = content.toggleSelectionColor;
  26322. var content_19 = content.decreaseSelectionIndent;
  26323. var content_20 = content.increaseSelectionIndent;
  26324. var content_21 = content.toggleSelectionIndent;
  26325. var content_22 = content.toggleSelectionAlignment;
  26326. var content_23 = content.removeSelectionInlineStyles;
  26327. var content_24 = content.toggleSelectionInlineStyle;
  26328. var content_25 = content.selectionHasInlineStyle;
  26329. var content_26 = content.getSelectionInlineStyle;
  26330. var content_27 = content.toggleSelectionLink;
  26331. var content_28 = content.toggleSelectionEntity;
  26332. var content_29 = content.getSelectionEntityData;
  26333. var content_30 = content.getSelectionEntityType;
  26334. var content_31 = content.toggleSelectionBlockType;
  26335. var content_32 = content.getSelectionText;
  26336. var content_33 = content.getSelectionBlockType;
  26337. var content_34 = content.getSelectionBlockData;
  26338. var content_35 = content.setSelectionBlockData;
  26339. var content_36 = content.getSelectedBlocks;
  26340. var content_37 = content.updateEachCharacterOfSelection;
  26341. var content_38 = content.getSelectionBlock;
  26342. var content_39 = content.removeBlock;
  26343. var content_40 = content.selectNextBlock;
  26344. var content_41 = content.selectBlock;
  26345. var content_42 = content.selectionContainsStrictBlock;
  26346. var content_43 = content.selectionContainsBlockType;
  26347. var content_44 = content.isSelectionCollapsed;
  26348. var content_45 = content.createEditorState;
  26349. var content_46 = content.createEmptyEditorState;
  26350. var content_47 = content.isEditorState;
  26351. var content_48 = content.registerStrictBlockType;
  26352. var base = index.createCommonjsModule(function (module, exports) {
  26353. Object.defineProperty(exports, "__esModule", {
  26354. value: true
  26355. });
  26356. var braftUniqueIndex = 0;
  26357. var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
  26358. return braftUniqueIndex += 1;
  26359. };
  26360. });
  26361. index.unwrapExports(base);
  26362. var base_1 = base.UniqueIndex;
  26363. var color = index.createCommonjsModule(function (module, exports) {
  26364. Object.defineProperty(exports, "__esModule", {
  26365. value: true
  26366. });
  26367. var _namedColors = {
  26368. "aliceblue": "#f0f8ff",
  26369. "antiquewhite": "#faebd7",
  26370. "aqua": "#00ffff",
  26371. "aquamarine": "#7fffd4",
  26372. "azure": "#f0ffff",
  26373. "beige": "#f5f5dc",
  26374. "bisque": "#ffe4c4",
  26375. "black": "#000000",
  26376. "blanchedalmond": "#ffebcd",
  26377. "blue": "#0000ff",
  26378. "blueviolet": "#8a2be2",
  26379. "brown": "#a52a2a",
  26380. "burlywood": "#deb887",
  26381. "cadetblue": "#5f9ea0",
  26382. "chartreuse": "#7fff00",
  26383. "chocolate": "#d2691e",
  26384. "coral": "#ff7f50",
  26385. "cornflowerblue": "#6495ed",
  26386. "cornsilk": "#fff8dc",
  26387. "crimson": "#dc143c",
  26388. "cyan": "#00ffff",
  26389. "darkblue": "#00008b",
  26390. "darkcyan": "#008b8b",
  26391. "darkgoldenrod": "#b8860b",
  26392. "darkgray": "#a9a9a9",
  26393. "darkgreen": "#006400",
  26394. "darkkhaki": "#bdb76b",
  26395. "darkmagenta": "#8b008b",
  26396. "darkolivegreen": "#556b2f",
  26397. "darkorange": "#ff8c00",
  26398. "darkorchid": "#9932cc",
  26399. "darkred": "#8b0000",
  26400. "darksalmon": "#e9967a",
  26401. "darkseagreen": "#8fbc8f",
  26402. "darkslateblue": "#483d8b",
  26403. "darkslategray": "#2f4f4f",
  26404. "darkturquoise": "#00ced1",
  26405. "darkviolet": "#9400d3",
  26406. "deeppink": "#ff1493",
  26407. "deepskyblue": "#00bfff",
  26408. "dimgray": "#696969",
  26409. "dodgerblue": "#1e90ff",
  26410. "firebrick": "#b22222",
  26411. "floralwhite": "#fffaf0",
  26412. "forestgreen": "#228b22",
  26413. "fuchsia": "#ff00ff",
  26414. "gainsboro": "#dcdcdc",
  26415. "ghostwhite": "#f8f8ff",
  26416. "gold": "#ffd700",
  26417. "goldenrod": "#daa520",
  26418. "gray": "#808080",
  26419. "green": "#008000",
  26420. "greenyellow": "#adff2f",
  26421. "honeydew": "#f0fff0",
  26422. "hotpink": "#ff69b4",
  26423. "indianred ": "#cd5c5c",
  26424. "indigo": "#4b0082",
  26425. "ivory": "#fffff0",
  26426. "khaki": "#f0e68c",
  26427. "lavender": "#e6e6fa",
  26428. "lavenderblush": "#fff0f5",
  26429. "lawngreen": "#7cfc00",
  26430. "lemonchiffon": "#fffacd",
  26431. "lightblue": "#add8e6",
  26432. "lightcoral": "#f08080",
  26433. "lightcyan": "#e0ffff",
  26434. "lightgoldenrodyellow": "#fafad2",
  26435. "lightgrey": "#d3d3d3",
  26436. "lightgreen": "#90ee90",
  26437. "lightpink": "#ffb6c1",
  26438. "lightsalmon": "#ffa07a",
  26439. "lightseagreen": "#20b2aa",
  26440. "lightskyblue": "#87cefa",
  26441. "lightslategray": "#778899",
  26442. "lightsteelblue": "#b0c4de",
  26443. "lightyellow": "#ffffe0",
  26444. "lime": "#00ff00",
  26445. "limegreen": "#32cd32",
  26446. "linen": "#faf0e6",
  26447. "magenta": "#ff00ff",
  26448. "maroon": "#800000",
  26449. "mediumaquamarine": "#66cdaa",
  26450. "mediumblue": "#0000cd",
  26451. "mediumorchid": "#ba55d3",
  26452. "mediumpurple": "#9370d8",
  26453. "mediumseagreen": "#3cb371",
  26454. "mediumslateblue": "#7b68ee",
  26455. "mediumspringgreen": "#00fa9a",
  26456. "mediumturquoise": "#48d1cc",
  26457. "mediumvioletred": "#c71585",
  26458. "midnightblue": "#191970",
  26459. "mintcream": "#f5fffa",
  26460. "mistyrose": "#ffe4e1",
  26461. "moccasin": "#ffe4b5",
  26462. "navajowhite": "#ffdead",
  26463. "navy": "#000080",
  26464. "oldlace": "#fdf5e6",
  26465. "olive": "#808000",
  26466. "olivedrab": "#6b8e23",
  26467. "orange": "#ffa500",
  26468. "orangered": "#ff4500",
  26469. "orchid": "#da70d6",
  26470. "palegoldenrod": "#eee8aa",
  26471. "palegreen": "#98fb98",
  26472. "paleturquoise": "#afeeee",
  26473. "palevioletred": "#d87093",
  26474. "papayawhip": "#ffefd5",
  26475. "peachpuff": "#ffdab9",
  26476. "peru": "#cd853f",
  26477. "pink": "#ffc0cb",
  26478. "plum": "#dda0dd",
  26479. "powderblue": "#b0e0e6",
  26480. "purple": "#800080",
  26481. "rebeccapurple": "#663399",
  26482. "red": "#ff0000",
  26483. "rosybrown": "#bc8f8f",
  26484. "royalblue": "#4169e1",
  26485. "saddlebrown": "#8b4513",
  26486. "salmon": "#fa8072",
  26487. "sandybrown": "#f4a460",
  26488. "seagreen": "#2e8b57",
  26489. "seashell": "#fff5ee",
  26490. "sienna": "#a0522d",
  26491. "silver": "#c0c0c0",
  26492. "skyblue": "#87ceeb",
  26493. "slateblue": "#6a5acd",
  26494. "slategray": "#708090",
  26495. "snow": "#fffafa",
  26496. "springgreen": "#00ff7f",
  26497. "steelblue": "#4682b4",
  26498. "tan": "#d2b48c",
  26499. "teal": "#008080",
  26500. "thistle": "#d8bfd8",
  26501. "tomato": "#ff6347",
  26502. "turquoise": "#40e0d0",
  26503. "violet": "#ee82ee",
  26504. "wheat": "#f5deb3",
  26505. "white": "#ffffff",
  26506. "whitesmoke": "#f5f5f5",
  26507. "yellow": "#ffff00",
  26508. "yellowgreen": "#9acd32"
  26509. };
  26510. var _getHexColor = function _getHexColor(color) {
  26511. color = color.replace('color:', '').replace(';', '').replace(' ', '');
  26512. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  26513. return color;
  26514. } else if (namedColors[color]) {
  26515. return namedColors[color];
  26516. } else if (color.indexOf('rgb') === 0) {
  26517. var rgbArray = color.split(',');
  26518. var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
  26519. var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
  26520. return hex.length === 1 ? '0' + hex : hex;
  26521. }).join('');
  26522. return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
  26523. );
  26524. } else {
  26525. return null;
  26526. }
  26527. };
  26528. var namedColors = exports.namedColors = _namedColors;
  26529. var getHexColor = exports.getHexColor = _getHexColor;
  26530. var detectColorsFromHTMLString = exports.detectColorsFromHTMLString = function detectColorsFromHTMLString(html) {
  26531. return typeof html !== 'string' ? [] : (html.match(/color:[^;]{3,24};/g) || []).map(getHexColor).filter(function (color) {
  26532. return color;
  26533. });
  26534. };
  26535. var detectColorsFromDraftState = exports.detectColorsFromDraftState = function detectColorsFromDraftState(draftState) {
  26536. var result = [];
  26537. if (!draftState || !draftState.blocks || !draftState.blocks.length) {
  26538. return result;
  26539. }
  26540. draftState.blocks.forEach(function (block) {
  26541. if (block && block.inlineStyleRanges && block.inlineStyleRanges.length) {
  26542. block.inlineStyleRanges.forEach(function (inlineStyle) {
  26543. if (inlineStyle.style && inlineStyle.style.indexOf('COLOR-') >= 0) {
  26544. result.push('#' + inlineStyle.style.split('COLOR-')[1]);
  26545. }
  26546. });
  26547. }
  26548. });
  26549. return result.filter(function (color) {
  26550. return color;
  26551. });
  26552. };
  26553. });
  26554. index.unwrapExports(color);
  26555. var color_1 = color.namedColors;
  26556. var color_2 = color.getHexColor;
  26557. var color_3 = color.detectColorsFromHTMLString;
  26558. var color_4 = color.detectColorsFromDraftState;
  26559. var dist$1 = index.createCommonjsModule(function (module, exports) {
  26560. Object.defineProperty(exports, "__esModule", {
  26561. value: true
  26562. });
  26563. exports.ColorUtils = exports.BaseUtils = exports.ContentUtils = undefined;
  26564. var _ContentUtils = _interopRequireWildcard(content);
  26565. var _BaseUtils = _interopRequireWildcard(base);
  26566. var _ColorUtils = _interopRequireWildcard(color);
  26567. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  26568. var ContentUtils = exports.ContentUtils = _ContentUtils;
  26569. var BaseUtils = exports.BaseUtils = _BaseUtils;
  26570. var ColorUtils = exports.ColorUtils = _ColorUtils;
  26571. });
  26572. index.unwrapExports(dist$1);
  26573. var dist_1$1 = dist$1.ColorUtils;
  26574. var dist_2$1 = dist$1.BaseUtils;
  26575. var dist_3$1 = dist$1.ContentUtils;
  26576. var immutable$3 = index.createCommonjsModule(function (module, exports) {
  26577. /**
  26578. * Copyright (c) 2014-2015, Facebook, Inc.
  26579. * All rights reserved.
  26580. *
  26581. * This source code is licensed under the BSD-style license found in the
  26582. * LICENSE file in the root directory of this source tree. An additional grant
  26583. * of patent rights can be found in the PATENTS file in the same directory.
  26584. */
  26585. (function (global, factory) {
  26586. module.exports = factory() ;
  26587. }(index.commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
  26588. function createClass(ctor, superClass) {
  26589. if (superClass) {
  26590. ctor.prototype = Object.create(superClass.prototype);
  26591. }
  26592. ctor.prototype.constructor = ctor;
  26593. }
  26594. function Iterable(value) {
  26595. return isIterable(value) ? value : Seq(value);
  26596. }
  26597. createClass(KeyedIterable, Iterable);
  26598. function KeyedIterable(value) {
  26599. return isKeyed(value) ? value : KeyedSeq(value);
  26600. }
  26601. createClass(IndexedIterable, Iterable);
  26602. function IndexedIterable(value) {
  26603. return isIndexed(value) ? value : IndexedSeq(value);
  26604. }
  26605. createClass(SetIterable, Iterable);
  26606. function SetIterable(value) {
  26607. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  26608. }
  26609. function isIterable(maybeIterable) {
  26610. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  26611. }
  26612. function isKeyed(maybeKeyed) {
  26613. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  26614. }
  26615. function isIndexed(maybeIndexed) {
  26616. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  26617. }
  26618. function isAssociative(maybeAssociative) {
  26619. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  26620. }
  26621. function isOrdered(maybeOrdered) {
  26622. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  26623. }
  26624. Iterable.isIterable = isIterable;
  26625. Iterable.isKeyed = isKeyed;
  26626. Iterable.isIndexed = isIndexed;
  26627. Iterable.isAssociative = isAssociative;
  26628. Iterable.isOrdered = isOrdered;
  26629. Iterable.Keyed = KeyedIterable;
  26630. Iterable.Indexed = IndexedIterable;
  26631. Iterable.Set = SetIterable;
  26632. var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  26633. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  26634. var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  26635. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  26636. // Used for setting prototype methods that IE8 chokes on.
  26637. var DELETE = 'delete';
  26638. // Constants describing the size of trie nodes.
  26639. var SHIFT = 5; // Resulted in best performance after ______?
  26640. var SIZE = 1 << SHIFT;
  26641. var MASK = SIZE - 1;
  26642. // A consistent shared value representing "not set" which equals nothing other
  26643. // than itself, and nothing that could be provided externally.
  26644. var NOT_SET = {};
  26645. // Boolean references, Rough equivalent of `bool &`.
  26646. var CHANGE_LENGTH = { value: false };
  26647. var DID_ALTER = { value: false };
  26648. function MakeRef(ref) {
  26649. ref.value = false;
  26650. return ref;
  26651. }
  26652. function SetRef(ref) {
  26653. ref && (ref.value = true);
  26654. }
  26655. // A function which returns a value representing an "owner" for transient writes
  26656. // to tries. The return value will only ever equal itself, and will not equal
  26657. // the return of any subsequent call of this function.
  26658. function OwnerID() {}
  26659. // http://jsperf.com/copy-array-inline
  26660. function arrCopy(arr, offset) {
  26661. offset = offset || 0;
  26662. var len = Math.max(0, arr.length - offset);
  26663. var newArr = new Array(len);
  26664. for (var ii = 0; ii < len; ii++) {
  26665. newArr[ii] = arr[ii + offset];
  26666. }
  26667. return newArr;
  26668. }
  26669. function ensureSize(iter) {
  26670. if (iter.size === undefined) {
  26671. iter.size = iter.__iterate(returnTrue);
  26672. }
  26673. return iter.size;
  26674. }
  26675. function wrapIndex(iter, index) {
  26676. // This implements "is array index" which the ECMAString spec defines as:
  26677. //
  26678. // A String property name P is an array index if and only if
  26679. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  26680. // to 2^32−1.
  26681. //
  26682. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  26683. if (typeof index !== 'number') {
  26684. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  26685. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  26686. return NaN;
  26687. }
  26688. index = uint32Index;
  26689. }
  26690. return index < 0 ? ensureSize(iter) + index : index;
  26691. }
  26692. function returnTrue() {
  26693. return true;
  26694. }
  26695. function wholeSlice(begin, end, size) {
  26696. return (begin === 0 || (size !== undefined && begin <= -size)) &&
  26697. (end === undefined || (size !== undefined && end >= size));
  26698. }
  26699. function resolveBegin(begin, size) {
  26700. return resolveIndex(begin, size, 0);
  26701. }
  26702. function resolveEnd(end, size) {
  26703. return resolveIndex(end, size, size);
  26704. }
  26705. function resolveIndex(index, size, defaultIndex) {
  26706. return index === undefined ?
  26707. defaultIndex :
  26708. index < 0 ?
  26709. Math.max(0, size + index) :
  26710. size === undefined ?
  26711. index :
  26712. Math.min(size, index);
  26713. }
  26714. /* global Symbol */
  26715. var ITERATE_KEYS = 0;
  26716. var ITERATE_VALUES = 1;
  26717. var ITERATE_ENTRIES = 2;
  26718. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  26719. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  26720. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  26721. function Iterator(next) {
  26722. this.next = next;
  26723. }
  26724. Iterator.prototype.toString = function() {
  26725. return '[Iterator]';
  26726. };
  26727. Iterator.KEYS = ITERATE_KEYS;
  26728. Iterator.VALUES = ITERATE_VALUES;
  26729. Iterator.ENTRIES = ITERATE_ENTRIES;
  26730. Iterator.prototype.inspect =
  26731. Iterator.prototype.toSource = function () { return this.toString(); };
  26732. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  26733. return this;
  26734. };
  26735. function iteratorValue(type, k, v, iteratorResult) {
  26736. var value = type === 0 ? k : type === 1 ? v : [k, v];
  26737. iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
  26738. value: value, done: false
  26739. });
  26740. return iteratorResult;
  26741. }
  26742. function iteratorDone() {
  26743. return { value: undefined, done: true };
  26744. }
  26745. function hasIterator(maybeIterable) {
  26746. return !!getIteratorFn(maybeIterable);
  26747. }
  26748. function isIterator(maybeIterator) {
  26749. return maybeIterator && typeof maybeIterator.next === 'function';
  26750. }
  26751. function getIterator(iterable) {
  26752. var iteratorFn = getIteratorFn(iterable);
  26753. return iteratorFn && iteratorFn.call(iterable);
  26754. }
  26755. function getIteratorFn(iterable) {
  26756. var iteratorFn = iterable && (
  26757. (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  26758. iterable[FAUX_ITERATOR_SYMBOL]
  26759. );
  26760. if (typeof iteratorFn === 'function') {
  26761. return iteratorFn;
  26762. }
  26763. }
  26764. function isArrayLike(value) {
  26765. return value && typeof value.length === 'number';
  26766. }
  26767. createClass(Seq, Iterable);
  26768. function Seq(value) {
  26769. return value === null || value === undefined ? emptySequence() :
  26770. isIterable(value) ? value.toSeq() : seqFromValue(value);
  26771. }
  26772. Seq.of = function(/*...values*/) {
  26773. return Seq(arguments);
  26774. };
  26775. Seq.prototype.toSeq = function() {
  26776. return this;
  26777. };
  26778. Seq.prototype.toString = function() {
  26779. return this.__toString('Seq {', '}');
  26780. };
  26781. Seq.prototype.cacheResult = function() {
  26782. if (!this._cache && this.__iterateUncached) {
  26783. this._cache = this.entrySeq().toArray();
  26784. this.size = this._cache.length;
  26785. }
  26786. return this;
  26787. };
  26788. // abstract __iterateUncached(fn, reverse)
  26789. Seq.prototype.__iterate = function(fn, reverse) {
  26790. return seqIterate(this, fn, reverse, true);
  26791. };
  26792. // abstract __iteratorUncached(type, reverse)
  26793. Seq.prototype.__iterator = function(type, reverse) {
  26794. return seqIterator(this, type, reverse, true);
  26795. };
  26796. createClass(KeyedSeq, Seq);
  26797. function KeyedSeq(value) {
  26798. return value === null || value === undefined ?
  26799. emptySequence().toKeyedSeq() :
  26800. isIterable(value) ?
  26801. (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
  26802. keyedSeqFromValue(value);
  26803. }
  26804. KeyedSeq.prototype.toKeyedSeq = function() {
  26805. return this;
  26806. };
  26807. createClass(IndexedSeq, Seq);
  26808. function IndexedSeq(value) {
  26809. return value === null || value === undefined ? emptySequence() :
  26810. !isIterable(value) ? indexedSeqFromValue(value) :
  26811. isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
  26812. }
  26813. IndexedSeq.of = function(/*...values*/) {
  26814. return IndexedSeq(arguments);
  26815. };
  26816. IndexedSeq.prototype.toIndexedSeq = function() {
  26817. return this;
  26818. };
  26819. IndexedSeq.prototype.toString = function() {
  26820. return this.__toString('Seq [', ']');
  26821. };
  26822. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  26823. return seqIterate(this, fn, reverse, false);
  26824. };
  26825. IndexedSeq.prototype.__iterator = function(type, reverse) {
  26826. return seqIterator(this, type, reverse, false);
  26827. };
  26828. createClass(SetSeq, Seq);
  26829. function SetSeq(value) {
  26830. return (
  26831. value === null || value === undefined ? emptySequence() :
  26832. !isIterable(value) ? indexedSeqFromValue(value) :
  26833. isKeyed(value) ? value.entrySeq() : value
  26834. ).toSetSeq();
  26835. }
  26836. SetSeq.of = function(/*...values*/) {
  26837. return SetSeq(arguments);
  26838. };
  26839. SetSeq.prototype.toSetSeq = function() {
  26840. return this;
  26841. };
  26842. Seq.isSeq = isSeq;
  26843. Seq.Keyed = KeyedSeq;
  26844. Seq.Set = SetSeq;
  26845. Seq.Indexed = IndexedSeq;
  26846. var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  26847. Seq.prototype[IS_SEQ_SENTINEL] = true;
  26848. createClass(ArraySeq, IndexedSeq);
  26849. function ArraySeq(array) {
  26850. this._array = array;
  26851. this.size = array.length;
  26852. }
  26853. ArraySeq.prototype.get = function(index, notSetValue) {
  26854. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  26855. };
  26856. ArraySeq.prototype.__iterate = function(fn, reverse) {
  26857. var array = this._array;
  26858. var maxIndex = array.length - 1;
  26859. for (var ii = 0; ii <= maxIndex; ii++) {
  26860. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  26861. return ii + 1;
  26862. }
  26863. }
  26864. return ii;
  26865. };
  26866. ArraySeq.prototype.__iterator = function(type, reverse) {
  26867. var array = this._array;
  26868. var maxIndex = array.length - 1;
  26869. var ii = 0;
  26870. return new Iterator(function()
  26871. {return ii > maxIndex ?
  26872. iteratorDone() :
  26873. iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
  26874. );
  26875. };
  26876. createClass(ObjectSeq, KeyedSeq);
  26877. function ObjectSeq(object) {
  26878. var keys = Object.keys(object);
  26879. this._object = object;
  26880. this._keys = keys;
  26881. this.size = keys.length;
  26882. }
  26883. ObjectSeq.prototype.get = function(key, notSetValue) {
  26884. if (notSetValue !== undefined && !this.has(key)) {
  26885. return notSetValue;
  26886. }
  26887. return this._object[key];
  26888. };
  26889. ObjectSeq.prototype.has = function(key) {
  26890. return this._object.hasOwnProperty(key);
  26891. };
  26892. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  26893. var object = this._object;
  26894. var keys = this._keys;
  26895. var maxIndex = keys.length - 1;
  26896. for (var ii = 0; ii <= maxIndex; ii++) {
  26897. var key = keys[reverse ? maxIndex - ii : ii];
  26898. if (fn(object[key], key, this) === false) {
  26899. return ii + 1;
  26900. }
  26901. }
  26902. return ii;
  26903. };
  26904. ObjectSeq.prototype.__iterator = function(type, reverse) {
  26905. var object = this._object;
  26906. var keys = this._keys;
  26907. var maxIndex = keys.length - 1;
  26908. var ii = 0;
  26909. return new Iterator(function() {
  26910. var key = keys[reverse ? maxIndex - ii : ii];
  26911. return ii++ > maxIndex ?
  26912. iteratorDone() :
  26913. iteratorValue(type, key, object[key]);
  26914. });
  26915. };
  26916. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  26917. createClass(IterableSeq, IndexedSeq);
  26918. function IterableSeq(iterable) {
  26919. this._iterable = iterable;
  26920. this.size = iterable.length || iterable.size;
  26921. }
  26922. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  26923. if (reverse) {
  26924. return this.cacheResult().__iterate(fn, reverse);
  26925. }
  26926. var iterable = this._iterable;
  26927. var iterator = getIterator(iterable);
  26928. var iterations = 0;
  26929. if (isIterator(iterator)) {
  26930. var step;
  26931. while (!(step = iterator.next()).done) {
  26932. if (fn(step.value, iterations++, this) === false) {
  26933. break;
  26934. }
  26935. }
  26936. }
  26937. return iterations;
  26938. };
  26939. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  26940. if (reverse) {
  26941. return this.cacheResult().__iterator(type, reverse);
  26942. }
  26943. var iterable = this._iterable;
  26944. var iterator = getIterator(iterable);
  26945. if (!isIterator(iterator)) {
  26946. return new Iterator(iteratorDone);
  26947. }
  26948. var iterations = 0;
  26949. return new Iterator(function() {
  26950. var step = iterator.next();
  26951. return step.done ? step : iteratorValue(type, iterations++, step.value);
  26952. });
  26953. };
  26954. createClass(IteratorSeq, IndexedSeq);
  26955. function IteratorSeq(iterator) {
  26956. this._iterator = iterator;
  26957. this._iteratorCache = [];
  26958. }
  26959. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  26960. if (reverse) {
  26961. return this.cacheResult().__iterate(fn, reverse);
  26962. }
  26963. var iterator = this._iterator;
  26964. var cache = this._iteratorCache;
  26965. var iterations = 0;
  26966. while (iterations < cache.length) {
  26967. if (fn(cache[iterations], iterations++, this) === false) {
  26968. return iterations;
  26969. }
  26970. }
  26971. var step;
  26972. while (!(step = iterator.next()).done) {
  26973. var val = step.value;
  26974. cache[iterations] = val;
  26975. if (fn(val, iterations++, this) === false) {
  26976. break;
  26977. }
  26978. }
  26979. return iterations;
  26980. };
  26981. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  26982. if (reverse) {
  26983. return this.cacheResult().__iterator(type, reverse);
  26984. }
  26985. var iterator = this._iterator;
  26986. var cache = this._iteratorCache;
  26987. var iterations = 0;
  26988. return new Iterator(function() {
  26989. if (iterations >= cache.length) {
  26990. var step = iterator.next();
  26991. if (step.done) {
  26992. return step;
  26993. }
  26994. cache[iterations] = step.value;
  26995. }
  26996. return iteratorValue(type, iterations, cache[iterations++]);
  26997. });
  26998. };
  26999. // # pragma Helper functions
  27000. function isSeq(maybeSeq) {
  27001. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  27002. }
  27003. var EMPTY_SEQ;
  27004. function emptySequence() {
  27005. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  27006. }
  27007. function keyedSeqFromValue(value) {
  27008. var seq =
  27009. Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
  27010. isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
  27011. hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
  27012. typeof value === 'object' ? new ObjectSeq(value) :
  27013. undefined;
  27014. if (!seq) {
  27015. throw new TypeError(
  27016. 'Expected Array or iterable object of [k, v] entries, '+
  27017. 'or keyed object: ' + value
  27018. );
  27019. }
  27020. return seq;
  27021. }
  27022. function indexedSeqFromValue(value) {
  27023. var seq = maybeIndexedSeqFromValue(value);
  27024. if (!seq) {
  27025. throw new TypeError(
  27026. 'Expected Array or iterable object of values: ' + value
  27027. );
  27028. }
  27029. return seq;
  27030. }
  27031. function seqFromValue(value) {
  27032. var seq = maybeIndexedSeqFromValue(value) ||
  27033. (typeof value === 'object' && new ObjectSeq(value));
  27034. if (!seq) {
  27035. throw new TypeError(
  27036. 'Expected Array or iterable object of values, or keyed object: ' + value
  27037. );
  27038. }
  27039. return seq;
  27040. }
  27041. function maybeIndexedSeqFromValue(value) {
  27042. return (
  27043. isArrayLike(value) ? new ArraySeq(value) :
  27044. isIterator(value) ? new IteratorSeq(value) :
  27045. hasIterator(value) ? new IterableSeq(value) :
  27046. undefined
  27047. );
  27048. }
  27049. function seqIterate(seq, fn, reverse, useKeys) {
  27050. var cache = seq._cache;
  27051. if (cache) {
  27052. var maxIndex = cache.length - 1;
  27053. for (var ii = 0; ii <= maxIndex; ii++) {
  27054. var entry = cache[reverse ? maxIndex - ii : ii];
  27055. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  27056. return ii + 1;
  27057. }
  27058. }
  27059. return ii;
  27060. }
  27061. return seq.__iterateUncached(fn, reverse);
  27062. }
  27063. function seqIterator(seq, type, reverse, useKeys) {
  27064. var cache = seq._cache;
  27065. if (cache) {
  27066. var maxIndex = cache.length - 1;
  27067. var ii = 0;
  27068. return new Iterator(function() {
  27069. var entry = cache[reverse ? maxIndex - ii : ii];
  27070. return ii++ > maxIndex ?
  27071. iteratorDone() :
  27072. iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  27073. });
  27074. }
  27075. return seq.__iteratorUncached(type, reverse);
  27076. }
  27077. function fromJS(json, converter) {
  27078. return converter ?
  27079. fromJSWith(converter, json, '', {'': json}) :
  27080. fromJSDefault(json);
  27081. }
  27082. function fromJSWith(converter, json, key, parentJSON) {
  27083. if (Array.isArray(json)) {
  27084. return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  27085. }
  27086. if (isPlainObj(json)) {
  27087. return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  27088. }
  27089. return json;
  27090. }
  27091. function fromJSDefault(json) {
  27092. if (Array.isArray(json)) {
  27093. return IndexedSeq(json).map(fromJSDefault).toList();
  27094. }
  27095. if (isPlainObj(json)) {
  27096. return KeyedSeq(json).map(fromJSDefault).toMap();
  27097. }
  27098. return json;
  27099. }
  27100. function isPlainObj(value) {
  27101. return value && (value.constructor === Object || value.constructor === undefined);
  27102. }
  27103. /**
  27104. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  27105. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  27106. *
  27107. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  27108. * value, which is different from the algorithm described by
  27109. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  27110. *
  27111. * This is extended further to allow Objects to describe the values they
  27112. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  27113. *
  27114. * Note: because of this extension, the key equality of Immutable.Map and the
  27115. * value equality of Immutable.Set will differ from ES6 Map and Set.
  27116. *
  27117. * ### Defining custom values
  27118. *
  27119. * The easiest way to describe the value an object represents is by implementing
  27120. * `valueOf`. For example, `Date` represents a value by returning a unix
  27121. * timestamp for `valueOf`:
  27122. *
  27123. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  27124. * var date2 = new Date(1234567890000);
  27125. * date1.valueOf(); // 1234567890000
  27126. * assert( date1 !== date2 );
  27127. * assert( Immutable.is( date1, date2 ) );
  27128. *
  27129. * Note: overriding `valueOf` may have other implications if you use this object
  27130. * where JavaScript expects a primitive, such as implicit string coercion.
  27131. *
  27132. * For more complex types, especially collections, implementing `valueOf` may
  27133. * not be performant. An alternative is to implement `equals` and `hashCode`.
  27134. *
  27135. * `equals` takes another object, presumably of similar type, and returns true
  27136. * if the it is equal. Equality is symmetrical, so the same result should be
  27137. * returned if this and the argument are flipped.
  27138. *
  27139. * assert( a.equals(b) === b.equals(a) );
  27140. *
  27141. * `hashCode` returns a 32bit integer number representing the object which will
  27142. * be used to determine how to store the value object in a Map or Set. You must
  27143. * provide both or neither methods, one must not exist without the other.
  27144. *
  27145. * Also, an important relationship between these methods must be upheld: if two
  27146. * values are equal, they *must* return the same hashCode. If the values are not
  27147. * equal, they might have the same hashCode; this is called a hash collision,
  27148. * and while undesirable for performance reasons, it is acceptable.
  27149. *
  27150. * if (a.equals(b)) {
  27151. * assert( a.hashCode() === b.hashCode() );
  27152. * }
  27153. *
  27154. * All Immutable collections implement `equals` and `hashCode`.
  27155. *
  27156. */
  27157. function is(valueA, valueB) {
  27158. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  27159. return true;
  27160. }
  27161. if (!valueA || !valueB) {
  27162. return false;
  27163. }
  27164. if (typeof valueA.valueOf === 'function' &&
  27165. typeof valueB.valueOf === 'function') {
  27166. valueA = valueA.valueOf();
  27167. valueB = valueB.valueOf();
  27168. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  27169. return true;
  27170. }
  27171. if (!valueA || !valueB) {
  27172. return false;
  27173. }
  27174. }
  27175. if (typeof valueA.equals === 'function' &&
  27176. typeof valueB.equals === 'function' &&
  27177. valueA.equals(valueB)) {
  27178. return true;
  27179. }
  27180. return false;
  27181. }
  27182. function deepEqual(a, b) {
  27183. if (a === b) {
  27184. return true;
  27185. }
  27186. if (
  27187. !isIterable(b) ||
  27188. a.size !== undefined && b.size !== undefined && a.size !== b.size ||
  27189. a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
  27190. isKeyed(a) !== isKeyed(b) ||
  27191. isIndexed(a) !== isIndexed(b) ||
  27192. isOrdered(a) !== isOrdered(b)
  27193. ) {
  27194. return false;
  27195. }
  27196. if (a.size === 0 && b.size === 0) {
  27197. return true;
  27198. }
  27199. var notAssociative = !isAssociative(a);
  27200. if (isOrdered(a)) {
  27201. var entries = a.entries();
  27202. return b.every(function(v, k) {
  27203. var entry = entries.next().value;
  27204. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  27205. }) && entries.next().done;
  27206. }
  27207. var flipped = false;
  27208. if (a.size === undefined) {
  27209. if (b.size === undefined) {
  27210. if (typeof a.cacheResult === 'function') {
  27211. a.cacheResult();
  27212. }
  27213. } else {
  27214. flipped = true;
  27215. var _ = a;
  27216. a = b;
  27217. b = _;
  27218. }
  27219. }
  27220. var allEqual = true;
  27221. var bSize = b.__iterate(function(v, k) {
  27222. if (notAssociative ? !a.has(v) :
  27223. flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
  27224. allEqual = false;
  27225. return false;
  27226. }
  27227. });
  27228. return allEqual && a.size === bSize;
  27229. }
  27230. createClass(Repeat, IndexedSeq);
  27231. function Repeat(value, times) {
  27232. if (!(this instanceof Repeat)) {
  27233. return new Repeat(value, times);
  27234. }
  27235. this._value = value;
  27236. this.size = times === undefined ? Infinity : Math.max(0, times);
  27237. if (this.size === 0) {
  27238. if (EMPTY_REPEAT) {
  27239. return EMPTY_REPEAT;
  27240. }
  27241. EMPTY_REPEAT = this;
  27242. }
  27243. }
  27244. Repeat.prototype.toString = function() {
  27245. if (this.size === 0) {
  27246. return 'Repeat []';
  27247. }
  27248. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  27249. };
  27250. Repeat.prototype.get = function(index, notSetValue) {
  27251. return this.has(index) ? this._value : notSetValue;
  27252. };
  27253. Repeat.prototype.includes = function(searchValue) {
  27254. return is(this._value, searchValue);
  27255. };
  27256. Repeat.prototype.slice = function(begin, end) {
  27257. var size = this.size;
  27258. return wholeSlice(begin, end, size) ? this :
  27259. new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
  27260. };
  27261. Repeat.prototype.reverse = function() {
  27262. return this;
  27263. };
  27264. Repeat.prototype.indexOf = function(searchValue) {
  27265. if (is(this._value, searchValue)) {
  27266. return 0;
  27267. }
  27268. return -1;
  27269. };
  27270. Repeat.prototype.lastIndexOf = function(searchValue) {
  27271. if (is(this._value, searchValue)) {
  27272. return this.size;
  27273. }
  27274. return -1;
  27275. };
  27276. Repeat.prototype.__iterate = function(fn, reverse) {
  27277. for (var ii = 0; ii < this.size; ii++) {
  27278. if (fn(this._value, ii, this) === false) {
  27279. return ii + 1;
  27280. }
  27281. }
  27282. return ii;
  27283. };
  27284. Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
  27285. var ii = 0;
  27286. return new Iterator(function()
  27287. {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
  27288. );
  27289. };
  27290. Repeat.prototype.equals = function(other) {
  27291. return other instanceof Repeat ?
  27292. is(this._value, other._value) :
  27293. deepEqual(other);
  27294. };
  27295. var EMPTY_REPEAT;
  27296. function invariant(condition, error) {
  27297. if (!condition) throw new Error(error);
  27298. }
  27299. createClass(Range, IndexedSeq);
  27300. function Range(start, end, step) {
  27301. if (!(this instanceof Range)) {
  27302. return new Range(start, end, step);
  27303. }
  27304. invariant(step !== 0, 'Cannot step a Range by 0');
  27305. start = start || 0;
  27306. if (end === undefined) {
  27307. end = Infinity;
  27308. }
  27309. step = step === undefined ? 1 : Math.abs(step);
  27310. if (end < start) {
  27311. step = -step;
  27312. }
  27313. this._start = start;
  27314. this._end = end;
  27315. this._step = step;
  27316. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  27317. if (this.size === 0) {
  27318. if (EMPTY_RANGE) {
  27319. return EMPTY_RANGE;
  27320. }
  27321. EMPTY_RANGE = this;
  27322. }
  27323. }
  27324. Range.prototype.toString = function() {
  27325. if (this.size === 0) {
  27326. return 'Range []';
  27327. }
  27328. return 'Range [ ' +
  27329. this._start + '...' + this._end +
  27330. (this._step > 1 ? ' by ' + this._step : '') +
  27331. ' ]';
  27332. };
  27333. Range.prototype.get = function(index, notSetValue) {
  27334. return this.has(index) ?
  27335. this._start + wrapIndex(this, index) * this._step :
  27336. notSetValue;
  27337. };
  27338. Range.prototype.includes = function(searchValue) {
  27339. var possibleIndex = (searchValue - this._start) / this._step;
  27340. return possibleIndex >= 0 &&
  27341. possibleIndex < this.size &&
  27342. possibleIndex === Math.floor(possibleIndex);
  27343. };
  27344. Range.prototype.slice = function(begin, end) {
  27345. if (wholeSlice(begin, end, this.size)) {
  27346. return this;
  27347. }
  27348. begin = resolveBegin(begin, this.size);
  27349. end = resolveEnd(end, this.size);
  27350. if (end <= begin) {
  27351. return new Range(0, 0);
  27352. }
  27353. return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
  27354. };
  27355. Range.prototype.indexOf = function(searchValue) {
  27356. var offsetValue = searchValue - this._start;
  27357. if (offsetValue % this._step === 0) {
  27358. var index = offsetValue / this._step;
  27359. if (index >= 0 && index < this.size) {
  27360. return index
  27361. }
  27362. }
  27363. return -1;
  27364. };
  27365. Range.prototype.lastIndexOf = function(searchValue) {
  27366. return this.indexOf(searchValue);
  27367. };
  27368. Range.prototype.__iterate = function(fn, reverse) {
  27369. var maxIndex = this.size - 1;
  27370. var step = this._step;
  27371. var value = reverse ? this._start + maxIndex * step : this._start;
  27372. for (var ii = 0; ii <= maxIndex; ii++) {
  27373. if (fn(value, ii, this) === false) {
  27374. return ii + 1;
  27375. }
  27376. value += reverse ? -step : step;
  27377. }
  27378. return ii;
  27379. };
  27380. Range.prototype.__iterator = function(type, reverse) {
  27381. var maxIndex = this.size - 1;
  27382. var step = this._step;
  27383. var value = reverse ? this._start + maxIndex * step : this._start;
  27384. var ii = 0;
  27385. return new Iterator(function() {
  27386. var v = value;
  27387. value += reverse ? -step : step;
  27388. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  27389. });
  27390. };
  27391. Range.prototype.equals = function(other) {
  27392. return other instanceof Range ?
  27393. this._start === other._start &&
  27394. this._end === other._end &&
  27395. this._step === other._step :
  27396. deepEqual(this, other);
  27397. };
  27398. var EMPTY_RANGE;
  27399. createClass(Collection, Iterable);
  27400. function Collection() {
  27401. throw TypeError('Abstract');
  27402. }
  27403. createClass(KeyedCollection, Collection);function KeyedCollection() {}
  27404. createClass(IndexedCollection, Collection);function IndexedCollection() {}
  27405. createClass(SetCollection, Collection);function SetCollection() {}
  27406. Collection.Keyed = KeyedCollection;
  27407. Collection.Indexed = IndexedCollection;
  27408. Collection.Set = SetCollection;
  27409. var imul =
  27410. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
  27411. Math.imul :
  27412. function imul(a, b) {
  27413. a = a | 0; // int
  27414. b = b | 0; // int
  27415. var c = a & 0xffff;
  27416. var d = b & 0xffff;
  27417. // Shift by 0 fixes the sign on the high part.
  27418. return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
  27419. };
  27420. // v8 has an optimization for storing 31-bit signed numbers.
  27421. // Values which have either 00 or 11 as the high order bits qualify.
  27422. // This function drops the highest order bit in a signed number, maintaining
  27423. // the sign bit.
  27424. function smi(i32) {
  27425. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
  27426. }
  27427. function hash(o) {
  27428. if (o === false || o === null || o === undefined) {
  27429. return 0;
  27430. }
  27431. if (typeof o.valueOf === 'function') {
  27432. o = o.valueOf();
  27433. if (o === false || o === null || o === undefined) {
  27434. return 0;
  27435. }
  27436. }
  27437. if (o === true) {
  27438. return 1;
  27439. }
  27440. var type = typeof o;
  27441. if (type === 'number') {
  27442. var h = o | 0;
  27443. if (h !== o) {
  27444. h ^= o * 0xFFFFFFFF;
  27445. }
  27446. while (o > 0xFFFFFFFF) {
  27447. o /= 0xFFFFFFFF;
  27448. h ^= o;
  27449. }
  27450. return smi(h);
  27451. }
  27452. if (type === 'string') {
  27453. return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
  27454. }
  27455. if (typeof o.hashCode === 'function') {
  27456. return o.hashCode();
  27457. }
  27458. if (type === 'object') {
  27459. return hashJSObj(o);
  27460. }
  27461. if (typeof o.toString === 'function') {
  27462. return hashString(o.toString());
  27463. }
  27464. throw new Error('Value type ' + type + ' cannot be hashed.');
  27465. }
  27466. function cachedHashString(string) {
  27467. var hash = stringHashCache[string];
  27468. if (hash === undefined) {
  27469. hash = hashString(string);
  27470. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  27471. STRING_HASH_CACHE_SIZE = 0;
  27472. stringHashCache = {};
  27473. }
  27474. STRING_HASH_CACHE_SIZE++;
  27475. stringHashCache[string] = hash;
  27476. }
  27477. return hash;
  27478. }
  27479. // http://jsperf.com/hashing-strings
  27480. function hashString(string) {
  27481. // This is the hash from JVM
  27482. // The hash code for a string is computed as
  27483. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  27484. // where s[i] is the ith character of the string and n is the length of
  27485. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  27486. // (exclusive) by dropping high bits.
  27487. var hash = 0;
  27488. for (var ii = 0; ii < string.length; ii++) {
  27489. hash = 31 * hash + string.charCodeAt(ii) | 0;
  27490. }
  27491. return smi(hash);
  27492. }
  27493. function hashJSObj(obj) {
  27494. var hash;
  27495. if (usingWeakMap) {
  27496. hash = weakMap.get(obj);
  27497. if (hash !== undefined) {
  27498. return hash;
  27499. }
  27500. }
  27501. hash = obj[UID_HASH_KEY];
  27502. if (hash !== undefined) {
  27503. return hash;
  27504. }
  27505. if (!canDefineProperty) {
  27506. hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  27507. if (hash !== undefined) {
  27508. return hash;
  27509. }
  27510. hash = getIENodeHash(obj);
  27511. if (hash !== undefined) {
  27512. return hash;
  27513. }
  27514. }
  27515. hash = ++objHashUID;
  27516. if (objHashUID & 0x40000000) {
  27517. objHashUID = 0;
  27518. }
  27519. if (usingWeakMap) {
  27520. weakMap.set(obj, hash);
  27521. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  27522. throw new Error('Non-extensible objects are not allowed as keys.');
  27523. } else if (canDefineProperty) {
  27524. Object.defineProperty(obj, UID_HASH_KEY, {
  27525. 'enumerable': false,
  27526. 'configurable': false,
  27527. 'writable': false,
  27528. 'value': hash
  27529. });
  27530. } else if (obj.propertyIsEnumerable !== undefined &&
  27531. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
  27532. // Since we can't define a non-enumerable property on the object
  27533. // we'll hijack one of the less-used non-enumerable properties to
  27534. // save our hash on it. Since this is a function it will not show up in
  27535. // `JSON.stringify` which is what we want.
  27536. obj.propertyIsEnumerable = function() {
  27537. return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
  27538. };
  27539. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  27540. } else if (obj.nodeType !== undefined) {
  27541. // At this point we couldn't get the IE `uniqueID` to use as a hash
  27542. // and we couldn't use a non-enumerable property to exploit the
  27543. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  27544. // itself.
  27545. obj[UID_HASH_KEY] = hash;
  27546. } else {
  27547. throw new Error('Unable to set a non-enumerable property on object.');
  27548. }
  27549. return hash;
  27550. }
  27551. // Get references to ES5 object methods.
  27552. var isExtensible = Object.isExtensible;
  27553. // True if Object.defineProperty works as expected. IE8 fails this test.
  27554. var canDefineProperty = (function() {
  27555. try {
  27556. Object.defineProperty({}, '@', {});
  27557. return true;
  27558. } catch (e) {
  27559. return false;
  27560. }
  27561. }());
  27562. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  27563. // and avoid memory leaks from the IE cloneNode bug.
  27564. function getIENodeHash(node) {
  27565. if (node && node.nodeType > 0) {
  27566. switch (node.nodeType) {
  27567. case 1: // Element
  27568. return node.uniqueID;
  27569. case 9: // Document
  27570. return node.documentElement && node.documentElement.uniqueID;
  27571. }
  27572. }
  27573. }
  27574. // If possible, use a WeakMap.
  27575. var usingWeakMap = typeof WeakMap === 'function';
  27576. var weakMap;
  27577. if (usingWeakMap) {
  27578. weakMap = new WeakMap();
  27579. }
  27580. var objHashUID = 0;
  27581. var UID_HASH_KEY = '__immutablehash__';
  27582. if (typeof Symbol === 'function') {
  27583. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  27584. }
  27585. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  27586. var STRING_HASH_CACHE_MAX_SIZE = 255;
  27587. var STRING_HASH_CACHE_SIZE = 0;
  27588. var stringHashCache = {};
  27589. function assertNotInfinite(size) {
  27590. invariant(
  27591. size !== Infinity,
  27592. 'Cannot perform this action with an infinite size.'
  27593. );
  27594. }
  27595. createClass(Map, KeyedCollection);
  27596. // @pragma Construction
  27597. function Map(value) {
  27598. return value === null || value === undefined ? emptyMap() :
  27599. isMap(value) && !isOrdered(value) ? value :
  27600. emptyMap().withMutations(function(map ) {
  27601. var iter = KeyedIterable(value);
  27602. assertNotInfinite(iter.size);
  27603. iter.forEach(function(v, k) {return map.set(k, v)});
  27604. });
  27605. }
  27606. Map.prototype.toString = function() {
  27607. return this.__toString('Map {', '}');
  27608. };
  27609. // @pragma Access
  27610. Map.prototype.get = function(k, notSetValue) {
  27611. return this._root ?
  27612. this._root.get(0, undefined, k, notSetValue) :
  27613. notSetValue;
  27614. };
  27615. // @pragma Modification
  27616. Map.prototype.set = function(k, v) {
  27617. return updateMap(this, k, v);
  27618. };
  27619. Map.prototype.setIn = function(keyPath, v) {
  27620. return this.updateIn(keyPath, NOT_SET, function() {return v});
  27621. };
  27622. Map.prototype.remove = function(k) {
  27623. return updateMap(this, k, NOT_SET);
  27624. };
  27625. Map.prototype.deleteIn = function(keyPath) {
  27626. return this.updateIn(keyPath, function() {return NOT_SET});
  27627. };
  27628. Map.prototype.update = function(k, notSetValue, updater) {
  27629. return arguments.length === 1 ?
  27630. k(this) :
  27631. this.updateIn([k], notSetValue, updater);
  27632. };
  27633. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  27634. if (!updater) {
  27635. updater = notSetValue;
  27636. notSetValue = undefined;
  27637. }
  27638. var updatedValue = updateInDeepMap(
  27639. this,
  27640. forceIterator(keyPath),
  27641. notSetValue,
  27642. updater
  27643. );
  27644. return updatedValue === NOT_SET ? undefined : updatedValue;
  27645. };
  27646. Map.prototype.clear = function() {
  27647. if (this.size === 0) {
  27648. return this;
  27649. }
  27650. if (this.__ownerID) {
  27651. this.size = 0;
  27652. this._root = null;
  27653. this.__hash = undefined;
  27654. this.__altered = true;
  27655. return this;
  27656. }
  27657. return emptyMap();
  27658. };
  27659. // @pragma Composition
  27660. Map.prototype.merge = function(/*...iters*/) {
  27661. return mergeIntoMapWith(this, undefined, arguments);
  27662. };
  27663. Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  27664. return mergeIntoMapWith(this, merger, iters);
  27665. };
  27666. Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  27667. return this.updateIn(
  27668. keyPath,
  27669. emptyMap(),
  27670. function(m ) {return typeof m.merge === 'function' ?
  27671. m.merge.apply(m, iters) :
  27672. iters[iters.length - 1]}
  27673. );
  27674. };
  27675. Map.prototype.mergeDeep = function(/*...iters*/) {
  27676. return mergeIntoMapWith(this, deepMerger, arguments);
  27677. };
  27678. Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  27679. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  27680. };
  27681. Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  27682. return this.updateIn(
  27683. keyPath,
  27684. emptyMap(),
  27685. function(m ) {return typeof m.mergeDeep === 'function' ?
  27686. m.mergeDeep.apply(m, iters) :
  27687. iters[iters.length - 1]}
  27688. );
  27689. };
  27690. Map.prototype.sort = function(comparator) {
  27691. // Late binding
  27692. return OrderedMap(sortFactory(this, comparator));
  27693. };
  27694. Map.prototype.sortBy = function(mapper, comparator) {
  27695. // Late binding
  27696. return OrderedMap(sortFactory(this, comparator, mapper));
  27697. };
  27698. // @pragma Mutability
  27699. Map.prototype.withMutations = function(fn) {
  27700. var mutable = this.asMutable();
  27701. fn(mutable);
  27702. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  27703. };
  27704. Map.prototype.asMutable = function() {
  27705. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  27706. };
  27707. Map.prototype.asImmutable = function() {
  27708. return this.__ensureOwner();
  27709. };
  27710. Map.prototype.wasAltered = function() {
  27711. return this.__altered;
  27712. };
  27713. Map.prototype.__iterator = function(type, reverse) {
  27714. return new MapIterator(this, type, reverse);
  27715. };
  27716. Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  27717. var iterations = 0;
  27718. this._root && this._root.iterate(function(entry ) {
  27719. iterations++;
  27720. return fn(entry[1], entry[0], this$0);
  27721. }, reverse);
  27722. return iterations;
  27723. };
  27724. Map.prototype.__ensureOwner = function(ownerID) {
  27725. if (ownerID === this.__ownerID) {
  27726. return this;
  27727. }
  27728. if (!ownerID) {
  27729. this.__ownerID = ownerID;
  27730. this.__altered = false;
  27731. return this;
  27732. }
  27733. return makeMap(this.size, this._root, ownerID, this.__hash);
  27734. };
  27735. function isMap(maybeMap) {
  27736. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  27737. }
  27738. Map.isMap = isMap;
  27739. var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  27740. var MapPrototype = Map.prototype;
  27741. MapPrototype[IS_MAP_SENTINEL] = true;
  27742. MapPrototype[DELETE] = MapPrototype.remove;
  27743. MapPrototype.removeIn = MapPrototype.deleteIn;
  27744. // #pragma Trie Nodes
  27745. function ArrayMapNode(ownerID, entries) {
  27746. this.ownerID = ownerID;
  27747. this.entries = entries;
  27748. }
  27749. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  27750. var entries = this.entries;
  27751. for (var ii = 0, len = entries.length; ii < len; ii++) {
  27752. if (is(key, entries[ii][0])) {
  27753. return entries[ii][1];
  27754. }
  27755. }
  27756. return notSetValue;
  27757. };
  27758. ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  27759. var removed = value === NOT_SET;
  27760. var entries = this.entries;
  27761. var idx = 0;
  27762. for (var len = entries.length; idx < len; idx++) {
  27763. if (is(key, entries[idx][0])) {
  27764. break;
  27765. }
  27766. }
  27767. var exists = idx < len;
  27768. if (exists ? entries[idx][1] === value : removed) {
  27769. return this;
  27770. }
  27771. SetRef(didAlter);
  27772. (removed || !exists) && SetRef(didChangeSize);
  27773. if (removed && entries.length === 1) {
  27774. return; // undefined
  27775. }
  27776. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  27777. return createNodes(ownerID, entries, key, value);
  27778. }
  27779. var isEditable = ownerID && ownerID === this.ownerID;
  27780. var newEntries = isEditable ? entries : arrCopy(entries);
  27781. if (exists) {
  27782. if (removed) {
  27783. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  27784. } else {
  27785. newEntries[idx] = [key, value];
  27786. }
  27787. } else {
  27788. newEntries.push([key, value]);
  27789. }
  27790. if (isEditable) {
  27791. this.entries = newEntries;
  27792. return this;
  27793. }
  27794. return new ArrayMapNode(ownerID, newEntries);
  27795. };
  27796. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  27797. this.ownerID = ownerID;
  27798. this.bitmap = bitmap;
  27799. this.nodes = nodes;
  27800. }
  27801. BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  27802. if (keyHash === undefined) {
  27803. keyHash = hash(key);
  27804. }
  27805. var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
  27806. var bitmap = this.bitmap;
  27807. return (bitmap & bit) === 0 ? notSetValue :
  27808. this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
  27809. };
  27810. BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  27811. if (keyHash === undefined) {
  27812. keyHash = hash(key);
  27813. }
  27814. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  27815. var bit = 1 << keyHashFrag;
  27816. var bitmap = this.bitmap;
  27817. var exists = (bitmap & bit) !== 0;
  27818. if (!exists && value === NOT_SET) {
  27819. return this;
  27820. }
  27821. var idx = popCount(bitmap & (bit - 1));
  27822. var nodes = this.nodes;
  27823. var node = exists ? nodes[idx] : undefined;
  27824. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  27825. if (newNode === node) {
  27826. return this;
  27827. }
  27828. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  27829. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  27830. }
  27831. if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
  27832. return nodes[idx ^ 1];
  27833. }
  27834. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  27835. return newNode;
  27836. }
  27837. var isEditable = ownerID && ownerID === this.ownerID;
  27838. var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
  27839. var newNodes = exists ? newNode ?
  27840. setIn(nodes, idx, newNode, isEditable) :
  27841. spliceOut(nodes, idx, isEditable) :
  27842. spliceIn(nodes, idx, newNode, isEditable);
  27843. if (isEditable) {
  27844. this.bitmap = newBitmap;
  27845. this.nodes = newNodes;
  27846. return this;
  27847. }
  27848. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  27849. };
  27850. function HashArrayMapNode(ownerID, count, nodes) {
  27851. this.ownerID = ownerID;
  27852. this.count = count;
  27853. this.nodes = nodes;
  27854. }
  27855. HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  27856. if (keyHash === undefined) {
  27857. keyHash = hash(key);
  27858. }
  27859. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  27860. var node = this.nodes[idx];
  27861. return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
  27862. };
  27863. HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  27864. if (keyHash === undefined) {
  27865. keyHash = hash(key);
  27866. }
  27867. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  27868. var removed = value === NOT_SET;
  27869. var nodes = this.nodes;
  27870. var node = nodes[idx];
  27871. if (removed && !node) {
  27872. return this;
  27873. }
  27874. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  27875. if (newNode === node) {
  27876. return this;
  27877. }
  27878. var newCount = this.count;
  27879. if (!node) {
  27880. newCount++;
  27881. } else if (!newNode) {
  27882. newCount--;
  27883. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  27884. return packNodes(ownerID, nodes, newCount, idx);
  27885. }
  27886. }
  27887. var isEditable = ownerID && ownerID === this.ownerID;
  27888. var newNodes = setIn(nodes, idx, newNode, isEditable);
  27889. if (isEditable) {
  27890. this.count = newCount;
  27891. this.nodes = newNodes;
  27892. return this;
  27893. }
  27894. return new HashArrayMapNode(ownerID, newCount, newNodes);
  27895. };
  27896. function HashCollisionNode(ownerID, keyHash, entries) {
  27897. this.ownerID = ownerID;
  27898. this.keyHash = keyHash;
  27899. this.entries = entries;
  27900. }
  27901. HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  27902. var entries = this.entries;
  27903. for (var ii = 0, len = entries.length; ii < len; ii++) {
  27904. if (is(key, entries[ii][0])) {
  27905. return entries[ii][1];
  27906. }
  27907. }
  27908. return notSetValue;
  27909. };
  27910. HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  27911. if (keyHash === undefined) {
  27912. keyHash = hash(key);
  27913. }
  27914. var removed = value === NOT_SET;
  27915. if (keyHash !== this.keyHash) {
  27916. if (removed) {
  27917. return this;
  27918. }
  27919. SetRef(didAlter);
  27920. SetRef(didChangeSize);
  27921. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  27922. }
  27923. var entries = this.entries;
  27924. var idx = 0;
  27925. for (var len = entries.length; idx < len; idx++) {
  27926. if (is(key, entries[idx][0])) {
  27927. break;
  27928. }
  27929. }
  27930. var exists = idx < len;
  27931. if (exists ? entries[idx][1] === value : removed) {
  27932. return this;
  27933. }
  27934. SetRef(didAlter);
  27935. (removed || !exists) && SetRef(didChangeSize);
  27936. if (removed && len === 2) {
  27937. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  27938. }
  27939. var isEditable = ownerID && ownerID === this.ownerID;
  27940. var newEntries = isEditable ? entries : arrCopy(entries);
  27941. if (exists) {
  27942. if (removed) {
  27943. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  27944. } else {
  27945. newEntries[idx] = [key, value];
  27946. }
  27947. } else {
  27948. newEntries.push([key, value]);
  27949. }
  27950. if (isEditable) {
  27951. this.entries = newEntries;
  27952. return this;
  27953. }
  27954. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  27955. };
  27956. function ValueNode(ownerID, keyHash, entry) {
  27957. this.ownerID = ownerID;
  27958. this.keyHash = keyHash;
  27959. this.entry = entry;
  27960. }
  27961. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  27962. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  27963. };
  27964. ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  27965. var removed = value === NOT_SET;
  27966. var keyMatch = is(key, this.entry[0]);
  27967. if (keyMatch ? value === this.entry[1] : removed) {
  27968. return this;
  27969. }
  27970. SetRef(didAlter);
  27971. if (removed) {
  27972. SetRef(didChangeSize);
  27973. return; // undefined
  27974. }
  27975. if (keyMatch) {
  27976. if (ownerID && ownerID === this.ownerID) {
  27977. this.entry[1] = value;
  27978. return this;
  27979. }
  27980. return new ValueNode(ownerID, this.keyHash, [key, value]);
  27981. }
  27982. SetRef(didChangeSize);
  27983. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  27984. };
  27985. // #pragma Iterators
  27986. ArrayMapNode.prototype.iterate =
  27987. HashCollisionNode.prototype.iterate = function (fn, reverse) {
  27988. var entries = this.entries;
  27989. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  27990. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  27991. return false;
  27992. }
  27993. }
  27994. };
  27995. BitmapIndexedNode.prototype.iterate =
  27996. HashArrayMapNode.prototype.iterate = function (fn, reverse) {
  27997. var nodes = this.nodes;
  27998. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  27999. var node = nodes[reverse ? maxIndex - ii : ii];
  28000. if (node && node.iterate(fn, reverse) === false) {
  28001. return false;
  28002. }
  28003. }
  28004. };
  28005. ValueNode.prototype.iterate = function (fn, reverse) {
  28006. return fn(this.entry);
  28007. };
  28008. createClass(MapIterator, Iterator);
  28009. function MapIterator(map, type, reverse) {
  28010. this._type = type;
  28011. this._reverse = reverse;
  28012. this._stack = map._root && mapIteratorFrame(map._root);
  28013. }
  28014. MapIterator.prototype.next = function() {
  28015. var type = this._type;
  28016. var stack = this._stack;
  28017. while (stack) {
  28018. var node = stack.node;
  28019. var index = stack.index++;
  28020. var maxIndex;
  28021. if (node.entry) {
  28022. if (index === 0) {
  28023. return mapIteratorValue(type, node.entry);
  28024. }
  28025. } else if (node.entries) {
  28026. maxIndex = node.entries.length - 1;
  28027. if (index <= maxIndex) {
  28028. return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
  28029. }
  28030. } else {
  28031. maxIndex = node.nodes.length - 1;
  28032. if (index <= maxIndex) {
  28033. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  28034. if (subNode) {
  28035. if (subNode.entry) {
  28036. return mapIteratorValue(type, subNode.entry);
  28037. }
  28038. stack = this._stack = mapIteratorFrame(subNode, stack);
  28039. }
  28040. continue;
  28041. }
  28042. }
  28043. stack = this._stack = this._stack.__prev;
  28044. }
  28045. return iteratorDone();
  28046. };
  28047. function mapIteratorValue(type, entry) {
  28048. return iteratorValue(type, entry[0], entry[1]);
  28049. }
  28050. function mapIteratorFrame(node, prev) {
  28051. return {
  28052. node: node,
  28053. index: 0,
  28054. __prev: prev
  28055. };
  28056. }
  28057. function makeMap(size, root, ownerID, hash) {
  28058. var map = Object.create(MapPrototype);
  28059. map.size = size;
  28060. map._root = root;
  28061. map.__ownerID = ownerID;
  28062. map.__hash = hash;
  28063. map.__altered = false;
  28064. return map;
  28065. }
  28066. var EMPTY_MAP;
  28067. function emptyMap() {
  28068. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  28069. }
  28070. function updateMap(map, k, v) {
  28071. var newRoot;
  28072. var newSize;
  28073. if (!map._root) {
  28074. if (v === NOT_SET) {
  28075. return map;
  28076. }
  28077. newSize = 1;
  28078. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  28079. } else {
  28080. var didChangeSize = MakeRef(CHANGE_LENGTH);
  28081. var didAlter = MakeRef(DID_ALTER);
  28082. newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
  28083. if (!didAlter.value) {
  28084. return map;
  28085. }
  28086. newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
  28087. }
  28088. if (map.__ownerID) {
  28089. map.size = newSize;
  28090. map._root = newRoot;
  28091. map.__hash = undefined;
  28092. map.__altered = true;
  28093. return map;
  28094. }
  28095. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  28096. }
  28097. function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  28098. if (!node) {
  28099. if (value === NOT_SET) {
  28100. return node;
  28101. }
  28102. SetRef(didAlter);
  28103. SetRef(didChangeSize);
  28104. return new ValueNode(ownerID, keyHash, [key, value]);
  28105. }
  28106. return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
  28107. }
  28108. function isLeafNode(node) {
  28109. return node.constructor === ValueNode || node.constructor === HashCollisionNode;
  28110. }
  28111. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  28112. if (node.keyHash === keyHash) {
  28113. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  28114. }
  28115. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  28116. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  28117. var newNode;
  28118. var nodes = idx1 === idx2 ?
  28119. [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
  28120. ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
  28121. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  28122. }
  28123. function createNodes(ownerID, entries, key, value) {
  28124. if (!ownerID) {
  28125. ownerID = new OwnerID();
  28126. }
  28127. var node = new ValueNode(ownerID, hash(key), [key, value]);
  28128. for (var ii = 0; ii < entries.length; ii++) {
  28129. var entry = entries[ii];
  28130. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  28131. }
  28132. return node;
  28133. }
  28134. function packNodes(ownerID, nodes, count, excluding) {
  28135. var bitmap = 0;
  28136. var packedII = 0;
  28137. var packedNodes = new Array(count);
  28138. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  28139. var node = nodes[ii];
  28140. if (node !== undefined && ii !== excluding) {
  28141. bitmap |= bit;
  28142. packedNodes[packedII++] = node;
  28143. }
  28144. }
  28145. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  28146. }
  28147. function expandNodes(ownerID, nodes, bitmap, including, node) {
  28148. var count = 0;
  28149. var expandedNodes = new Array(SIZE);
  28150. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  28151. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  28152. }
  28153. expandedNodes[including] = node;
  28154. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  28155. }
  28156. function mergeIntoMapWith(map, merger, iterables) {
  28157. var iters = [];
  28158. for (var ii = 0; ii < iterables.length; ii++) {
  28159. var value = iterables[ii];
  28160. var iter = KeyedIterable(value);
  28161. if (!isIterable(value)) {
  28162. iter = iter.map(function(v ) {return fromJS(v)});
  28163. }
  28164. iters.push(iter);
  28165. }
  28166. return mergeIntoCollectionWith(map, merger, iters);
  28167. }
  28168. function deepMerger(existing, value, key) {
  28169. return existing && existing.mergeDeep && isIterable(value) ?
  28170. existing.mergeDeep(value) :
  28171. is(existing, value) ? existing : value;
  28172. }
  28173. function deepMergerWith(merger) {
  28174. return function(existing, value, key) {
  28175. if (existing && existing.mergeDeepWith && isIterable(value)) {
  28176. return existing.mergeDeepWith(merger, value);
  28177. }
  28178. var nextValue = merger(existing, value, key);
  28179. return is(existing, nextValue) ? existing : nextValue;
  28180. };
  28181. }
  28182. function mergeIntoCollectionWith(collection, merger, iters) {
  28183. iters = iters.filter(function(x ) {return x.size !== 0});
  28184. if (iters.length === 0) {
  28185. return collection;
  28186. }
  28187. if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
  28188. return collection.constructor(iters[0]);
  28189. }
  28190. return collection.withMutations(function(collection ) {
  28191. var mergeIntoMap = merger ?
  28192. function(value, key) {
  28193. collection.update(key, NOT_SET, function(existing )
  28194. {return existing === NOT_SET ? value : merger(existing, value, key)}
  28195. );
  28196. } :
  28197. function(value, key) {
  28198. collection.set(key, value);
  28199. };
  28200. for (var ii = 0; ii < iters.length; ii++) {
  28201. iters[ii].forEach(mergeIntoMap);
  28202. }
  28203. });
  28204. }
  28205. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  28206. var isNotSet = existing === NOT_SET;
  28207. var step = keyPathIter.next();
  28208. if (step.done) {
  28209. var existingValue = isNotSet ? notSetValue : existing;
  28210. var newValue = updater(existingValue);
  28211. return newValue === existingValue ? existing : newValue;
  28212. }
  28213. invariant(
  28214. isNotSet || (existing && existing.set),
  28215. 'invalid keyPath'
  28216. );
  28217. var key = step.value;
  28218. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  28219. var nextUpdated = updateInDeepMap(
  28220. nextExisting,
  28221. keyPathIter,
  28222. notSetValue,
  28223. updater
  28224. );
  28225. return nextUpdated === nextExisting ? existing :
  28226. nextUpdated === NOT_SET ? existing.remove(key) :
  28227. (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  28228. }
  28229. function popCount(x) {
  28230. x = x - ((x >> 1) & 0x55555555);
  28231. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  28232. x = (x + (x >> 4)) & 0x0f0f0f0f;
  28233. x = x + (x >> 8);
  28234. x = x + (x >> 16);
  28235. return x & 0x7f;
  28236. }
  28237. function setIn(array, idx, val, canEdit) {
  28238. var newArray = canEdit ? array : arrCopy(array);
  28239. newArray[idx] = val;
  28240. return newArray;
  28241. }
  28242. function spliceIn(array, idx, val, canEdit) {
  28243. var newLen = array.length + 1;
  28244. if (canEdit && idx + 1 === newLen) {
  28245. array[idx] = val;
  28246. return array;
  28247. }
  28248. var newArray = new Array(newLen);
  28249. var after = 0;
  28250. for (var ii = 0; ii < newLen; ii++) {
  28251. if (ii === idx) {
  28252. newArray[ii] = val;
  28253. after = -1;
  28254. } else {
  28255. newArray[ii] = array[ii + after];
  28256. }
  28257. }
  28258. return newArray;
  28259. }
  28260. function spliceOut(array, idx, canEdit) {
  28261. var newLen = array.length - 1;
  28262. if (canEdit && idx === newLen) {
  28263. array.pop();
  28264. return array;
  28265. }
  28266. var newArray = new Array(newLen);
  28267. var after = 0;
  28268. for (var ii = 0; ii < newLen; ii++) {
  28269. if (ii === idx) {
  28270. after = 1;
  28271. }
  28272. newArray[ii] = array[ii + after];
  28273. }
  28274. return newArray;
  28275. }
  28276. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  28277. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  28278. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  28279. createClass(List, IndexedCollection);
  28280. // @pragma Construction
  28281. function List(value) {
  28282. var empty = emptyList();
  28283. if (value === null || value === undefined) {
  28284. return empty;
  28285. }
  28286. if (isList(value)) {
  28287. return value;
  28288. }
  28289. var iter = IndexedIterable(value);
  28290. var size = iter.size;
  28291. if (size === 0) {
  28292. return empty;
  28293. }
  28294. assertNotInfinite(size);
  28295. if (size > 0 && size < SIZE) {
  28296. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  28297. }
  28298. return empty.withMutations(function(list ) {
  28299. list.setSize(size);
  28300. iter.forEach(function(v, i) {return list.set(i, v)});
  28301. });
  28302. }
  28303. List.of = function(/*...values*/) {
  28304. return this(arguments);
  28305. };
  28306. List.prototype.toString = function() {
  28307. return this.__toString('List [', ']');
  28308. };
  28309. // @pragma Access
  28310. List.prototype.get = function(index, notSetValue) {
  28311. index = wrapIndex(this, index);
  28312. if (index >= 0 && index < this.size) {
  28313. index += this._origin;
  28314. var node = listNodeFor(this, index);
  28315. return node && node.array[index & MASK];
  28316. }
  28317. return notSetValue;
  28318. };
  28319. // @pragma Modification
  28320. List.prototype.set = function(index, value) {
  28321. return updateList(this, index, value);
  28322. };
  28323. List.prototype.remove = function(index) {
  28324. return !this.has(index) ? this :
  28325. index === 0 ? this.shift() :
  28326. index === this.size - 1 ? this.pop() :
  28327. this.splice(index, 1);
  28328. };
  28329. List.prototype.insert = function(index, value) {
  28330. return this.splice(index, 0, value);
  28331. };
  28332. List.prototype.clear = function() {
  28333. if (this.size === 0) {
  28334. return this;
  28335. }
  28336. if (this.__ownerID) {
  28337. this.size = this._origin = this._capacity = 0;
  28338. this._level = SHIFT;
  28339. this._root = this._tail = null;
  28340. this.__hash = undefined;
  28341. this.__altered = true;
  28342. return this;
  28343. }
  28344. return emptyList();
  28345. };
  28346. List.prototype.push = function(/*...values*/) {
  28347. var values = arguments;
  28348. var oldSize = this.size;
  28349. return this.withMutations(function(list ) {
  28350. setListBounds(list, 0, oldSize + values.length);
  28351. for (var ii = 0; ii < values.length; ii++) {
  28352. list.set(oldSize + ii, values[ii]);
  28353. }
  28354. });
  28355. };
  28356. List.prototype.pop = function() {
  28357. return setListBounds(this, 0, -1);
  28358. };
  28359. List.prototype.unshift = function(/*...values*/) {
  28360. var values = arguments;
  28361. return this.withMutations(function(list ) {
  28362. setListBounds(list, -values.length);
  28363. for (var ii = 0; ii < values.length; ii++) {
  28364. list.set(ii, values[ii]);
  28365. }
  28366. });
  28367. };
  28368. List.prototype.shift = function() {
  28369. return setListBounds(this, 1);
  28370. };
  28371. // @pragma Composition
  28372. List.prototype.merge = function(/*...iters*/) {
  28373. return mergeIntoListWith(this, undefined, arguments);
  28374. };
  28375. List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  28376. return mergeIntoListWith(this, merger, iters);
  28377. };
  28378. List.prototype.mergeDeep = function(/*...iters*/) {
  28379. return mergeIntoListWith(this, deepMerger, arguments);
  28380. };
  28381. List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  28382. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  28383. };
  28384. List.prototype.setSize = function(size) {
  28385. return setListBounds(this, 0, size);
  28386. };
  28387. // @pragma Iteration
  28388. List.prototype.slice = function(begin, end) {
  28389. var size = this.size;
  28390. if (wholeSlice(begin, end, size)) {
  28391. return this;
  28392. }
  28393. return setListBounds(
  28394. this,
  28395. resolveBegin(begin, size),
  28396. resolveEnd(end, size)
  28397. );
  28398. };
  28399. List.prototype.__iterator = function(type, reverse) {
  28400. var index = 0;
  28401. var values = iterateList(this, reverse);
  28402. return new Iterator(function() {
  28403. var value = values();
  28404. return value === DONE ?
  28405. iteratorDone() :
  28406. iteratorValue(type, index++, value);
  28407. });
  28408. };
  28409. List.prototype.__iterate = function(fn, reverse) {
  28410. var index = 0;
  28411. var values = iterateList(this, reverse);
  28412. var value;
  28413. while ((value = values()) !== DONE) {
  28414. if (fn(value, index++, this) === false) {
  28415. break;
  28416. }
  28417. }
  28418. return index;
  28419. };
  28420. List.prototype.__ensureOwner = function(ownerID) {
  28421. if (ownerID === this.__ownerID) {
  28422. return this;
  28423. }
  28424. if (!ownerID) {
  28425. this.__ownerID = ownerID;
  28426. return this;
  28427. }
  28428. return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
  28429. };
  28430. function isList(maybeList) {
  28431. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  28432. }
  28433. List.isList = isList;
  28434. var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  28435. var ListPrototype = List.prototype;
  28436. ListPrototype[IS_LIST_SENTINEL] = true;
  28437. ListPrototype[DELETE] = ListPrototype.remove;
  28438. ListPrototype.setIn = MapPrototype.setIn;
  28439. ListPrototype.deleteIn =
  28440. ListPrototype.removeIn = MapPrototype.removeIn;
  28441. ListPrototype.update = MapPrototype.update;
  28442. ListPrototype.updateIn = MapPrototype.updateIn;
  28443. ListPrototype.mergeIn = MapPrototype.mergeIn;
  28444. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  28445. ListPrototype.withMutations = MapPrototype.withMutations;
  28446. ListPrototype.asMutable = MapPrototype.asMutable;
  28447. ListPrototype.asImmutable = MapPrototype.asImmutable;
  28448. ListPrototype.wasAltered = MapPrototype.wasAltered;
  28449. function VNode(array, ownerID) {
  28450. this.array = array;
  28451. this.ownerID = ownerID;
  28452. }
  28453. // TODO: seems like these methods are very similar
  28454. VNode.prototype.removeBefore = function(ownerID, level, index) {
  28455. if (index === level ? 1 << level : this.array.length === 0) {
  28456. return this;
  28457. }
  28458. var originIndex = (index >>> level) & MASK;
  28459. if (originIndex >= this.array.length) {
  28460. return new VNode([], ownerID);
  28461. }
  28462. var removingFirst = originIndex === 0;
  28463. var newChild;
  28464. if (level > 0) {
  28465. var oldChild = this.array[originIndex];
  28466. newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  28467. if (newChild === oldChild && removingFirst) {
  28468. return this;
  28469. }
  28470. }
  28471. if (removingFirst && !newChild) {
  28472. return this;
  28473. }
  28474. var editable = editableVNode(this, ownerID);
  28475. if (!removingFirst) {
  28476. for (var ii = 0; ii < originIndex; ii++) {
  28477. editable.array[ii] = undefined;
  28478. }
  28479. }
  28480. if (newChild) {
  28481. editable.array[originIndex] = newChild;
  28482. }
  28483. return editable;
  28484. };
  28485. VNode.prototype.removeAfter = function(ownerID, level, index) {
  28486. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  28487. return this;
  28488. }
  28489. var sizeIndex = ((index - 1) >>> level) & MASK;
  28490. if (sizeIndex >= this.array.length) {
  28491. return this;
  28492. }
  28493. var newChild;
  28494. if (level > 0) {
  28495. var oldChild = this.array[sizeIndex];
  28496. newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  28497. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  28498. return this;
  28499. }
  28500. }
  28501. var editable = editableVNode(this, ownerID);
  28502. editable.array.splice(sizeIndex + 1);
  28503. if (newChild) {
  28504. editable.array[sizeIndex] = newChild;
  28505. }
  28506. return editable;
  28507. };
  28508. var DONE = {};
  28509. function iterateList(list, reverse) {
  28510. var left = list._origin;
  28511. var right = list._capacity;
  28512. var tailPos = getTailOffset(right);
  28513. var tail = list._tail;
  28514. return iterateNodeOrLeaf(list._root, list._level, 0);
  28515. function iterateNodeOrLeaf(node, level, offset) {
  28516. return level === 0 ?
  28517. iterateLeaf(node, offset) :
  28518. iterateNode(node, level, offset);
  28519. }
  28520. function iterateLeaf(node, offset) {
  28521. var array = offset === tailPos ? tail && tail.array : node && node.array;
  28522. var from = offset > left ? 0 : left - offset;
  28523. var to = right - offset;
  28524. if (to > SIZE) {
  28525. to = SIZE;
  28526. }
  28527. return function() {
  28528. if (from === to) {
  28529. return DONE;
  28530. }
  28531. var idx = reverse ? --to : from++;
  28532. return array && array[idx];
  28533. };
  28534. }
  28535. function iterateNode(node, level, offset) {
  28536. var values;
  28537. var array = node && node.array;
  28538. var from = offset > left ? 0 : (left - offset) >> level;
  28539. var to = ((right - offset) >> level) + 1;
  28540. if (to > SIZE) {
  28541. to = SIZE;
  28542. }
  28543. return function() {
  28544. do {
  28545. if (values) {
  28546. var value = values();
  28547. if (value !== DONE) {
  28548. return value;
  28549. }
  28550. values = null;
  28551. }
  28552. if (from === to) {
  28553. return DONE;
  28554. }
  28555. var idx = reverse ? --to : from++;
  28556. values = iterateNodeOrLeaf(
  28557. array && array[idx], level - SHIFT, offset + (idx << level)
  28558. );
  28559. } while (true);
  28560. };
  28561. }
  28562. }
  28563. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  28564. var list = Object.create(ListPrototype);
  28565. list.size = capacity - origin;
  28566. list._origin = origin;
  28567. list._capacity = capacity;
  28568. list._level = level;
  28569. list._root = root;
  28570. list._tail = tail;
  28571. list.__ownerID = ownerID;
  28572. list.__hash = hash;
  28573. list.__altered = false;
  28574. return list;
  28575. }
  28576. var EMPTY_LIST;
  28577. function emptyList() {
  28578. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  28579. }
  28580. function updateList(list, index, value) {
  28581. index = wrapIndex(list, index);
  28582. if (index !== index) {
  28583. return list;
  28584. }
  28585. if (index >= list.size || index < 0) {
  28586. return list.withMutations(function(list ) {
  28587. index < 0 ?
  28588. setListBounds(list, index).set(0, value) :
  28589. setListBounds(list, 0, index + 1).set(index, value);
  28590. });
  28591. }
  28592. index += list._origin;
  28593. var newTail = list._tail;
  28594. var newRoot = list._root;
  28595. var didAlter = MakeRef(DID_ALTER);
  28596. if (index >= getTailOffset(list._capacity)) {
  28597. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  28598. } else {
  28599. newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
  28600. }
  28601. if (!didAlter.value) {
  28602. return list;
  28603. }
  28604. if (list.__ownerID) {
  28605. list._root = newRoot;
  28606. list._tail = newTail;
  28607. list.__hash = undefined;
  28608. list.__altered = true;
  28609. return list;
  28610. }
  28611. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  28612. }
  28613. function updateVNode(node, ownerID, level, index, value, didAlter) {
  28614. var idx = (index >>> level) & MASK;
  28615. var nodeHas = node && idx < node.array.length;
  28616. if (!nodeHas && value === undefined) {
  28617. return node;
  28618. }
  28619. var newNode;
  28620. if (level > 0) {
  28621. var lowerNode = node && node.array[idx];
  28622. var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
  28623. if (newLowerNode === lowerNode) {
  28624. return node;
  28625. }
  28626. newNode = editableVNode(node, ownerID);
  28627. newNode.array[idx] = newLowerNode;
  28628. return newNode;
  28629. }
  28630. if (nodeHas && node.array[idx] === value) {
  28631. return node;
  28632. }
  28633. SetRef(didAlter);
  28634. newNode = editableVNode(node, ownerID);
  28635. if (value === undefined && idx === newNode.array.length - 1) {
  28636. newNode.array.pop();
  28637. } else {
  28638. newNode.array[idx] = value;
  28639. }
  28640. return newNode;
  28641. }
  28642. function editableVNode(node, ownerID) {
  28643. if (ownerID && node && ownerID === node.ownerID) {
  28644. return node;
  28645. }
  28646. return new VNode(node ? node.array.slice() : [], ownerID);
  28647. }
  28648. function listNodeFor(list, rawIndex) {
  28649. if (rawIndex >= getTailOffset(list._capacity)) {
  28650. return list._tail;
  28651. }
  28652. if (rawIndex < 1 << (list._level + SHIFT)) {
  28653. var node = list._root;
  28654. var level = list._level;
  28655. while (node && level > 0) {
  28656. node = node.array[(rawIndex >>> level) & MASK];
  28657. level -= SHIFT;
  28658. }
  28659. return node;
  28660. }
  28661. }
  28662. function setListBounds(list, begin, end) {
  28663. // Sanitize begin & end using this shorthand for ToInt32(argument)
  28664. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  28665. if (begin !== undefined) {
  28666. begin = begin | 0;
  28667. }
  28668. if (end !== undefined) {
  28669. end = end | 0;
  28670. }
  28671. var owner = list.__ownerID || new OwnerID();
  28672. var oldOrigin = list._origin;
  28673. var oldCapacity = list._capacity;
  28674. var newOrigin = oldOrigin + begin;
  28675. var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
  28676. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  28677. return list;
  28678. }
  28679. // If it's going to end after it starts, it's empty.
  28680. if (newOrigin >= newCapacity) {
  28681. return list.clear();
  28682. }
  28683. var newLevel = list._level;
  28684. var newRoot = list._root;
  28685. // New origin might need creating a higher root.
  28686. var offsetShift = 0;
  28687. while (newOrigin + offsetShift < 0) {
  28688. newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
  28689. newLevel += SHIFT;
  28690. offsetShift += 1 << newLevel;
  28691. }
  28692. if (offsetShift) {
  28693. newOrigin += offsetShift;
  28694. oldOrigin += offsetShift;
  28695. newCapacity += offsetShift;
  28696. oldCapacity += offsetShift;
  28697. }
  28698. var oldTailOffset = getTailOffset(oldCapacity);
  28699. var newTailOffset = getTailOffset(newCapacity);
  28700. // New size might need creating a higher root.
  28701. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  28702. newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
  28703. newLevel += SHIFT;
  28704. }
  28705. // Locate or create the new tail.
  28706. var oldTail = list._tail;
  28707. var newTail = newTailOffset < oldTailOffset ?
  28708. listNodeFor(list, newCapacity - 1) :
  28709. newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
  28710. // Merge Tail into tree.
  28711. if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
  28712. newRoot = editableVNode(newRoot, owner);
  28713. var node = newRoot;
  28714. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  28715. var idx = (oldTailOffset >>> level) & MASK;
  28716. node = node.array[idx] = editableVNode(node.array[idx], owner);
  28717. }
  28718. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  28719. }
  28720. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  28721. if (newCapacity < oldCapacity) {
  28722. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  28723. }
  28724. // If the new origin is within the tail, then we do not need a root.
  28725. if (newOrigin >= newTailOffset) {
  28726. newOrigin -= newTailOffset;
  28727. newCapacity -= newTailOffset;
  28728. newLevel = SHIFT;
  28729. newRoot = null;
  28730. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  28731. // Otherwise, if the root has been trimmed, garbage collect.
  28732. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  28733. offsetShift = 0;
  28734. // Identify the new top root node of the subtree of the old root.
  28735. while (newRoot) {
  28736. var beginIndex = (newOrigin >>> newLevel) & MASK;
  28737. if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
  28738. break;
  28739. }
  28740. if (beginIndex) {
  28741. offsetShift += (1 << newLevel) * beginIndex;
  28742. }
  28743. newLevel -= SHIFT;
  28744. newRoot = newRoot.array[beginIndex];
  28745. }
  28746. // Trim the new sides of the new root.
  28747. if (newRoot && newOrigin > oldOrigin) {
  28748. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  28749. }
  28750. if (newRoot && newTailOffset < oldTailOffset) {
  28751. newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
  28752. }
  28753. if (offsetShift) {
  28754. newOrigin -= offsetShift;
  28755. newCapacity -= offsetShift;
  28756. }
  28757. }
  28758. if (list.__ownerID) {
  28759. list.size = newCapacity - newOrigin;
  28760. list._origin = newOrigin;
  28761. list._capacity = newCapacity;
  28762. list._level = newLevel;
  28763. list._root = newRoot;
  28764. list._tail = newTail;
  28765. list.__hash = undefined;
  28766. list.__altered = true;
  28767. return list;
  28768. }
  28769. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  28770. }
  28771. function mergeIntoListWith(list, merger, iterables) {
  28772. var iters = [];
  28773. var maxSize = 0;
  28774. for (var ii = 0; ii < iterables.length; ii++) {
  28775. var value = iterables[ii];
  28776. var iter = IndexedIterable(value);
  28777. if (iter.size > maxSize) {
  28778. maxSize = iter.size;
  28779. }
  28780. if (!isIterable(value)) {
  28781. iter = iter.map(function(v ) {return fromJS(v)});
  28782. }
  28783. iters.push(iter);
  28784. }
  28785. if (maxSize > list.size) {
  28786. list = list.setSize(maxSize);
  28787. }
  28788. return mergeIntoCollectionWith(list, merger, iters);
  28789. }
  28790. function getTailOffset(size) {
  28791. return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
  28792. }
  28793. createClass(OrderedMap, Map);
  28794. // @pragma Construction
  28795. function OrderedMap(value) {
  28796. return value === null || value === undefined ? emptyOrderedMap() :
  28797. isOrderedMap(value) ? value :
  28798. emptyOrderedMap().withMutations(function(map ) {
  28799. var iter = KeyedIterable(value);
  28800. assertNotInfinite(iter.size);
  28801. iter.forEach(function(v, k) {return map.set(k, v)});
  28802. });
  28803. }
  28804. OrderedMap.of = function(/*...values*/) {
  28805. return this(arguments);
  28806. };
  28807. OrderedMap.prototype.toString = function() {
  28808. return this.__toString('OrderedMap {', '}');
  28809. };
  28810. // @pragma Access
  28811. OrderedMap.prototype.get = function(k, notSetValue) {
  28812. var index = this._map.get(k);
  28813. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  28814. };
  28815. // @pragma Modification
  28816. OrderedMap.prototype.clear = function() {
  28817. if (this.size === 0) {
  28818. return this;
  28819. }
  28820. if (this.__ownerID) {
  28821. this.size = 0;
  28822. this._map.clear();
  28823. this._list.clear();
  28824. return this;
  28825. }
  28826. return emptyOrderedMap();
  28827. };
  28828. OrderedMap.prototype.set = function(k, v) {
  28829. return updateOrderedMap(this, k, v);
  28830. };
  28831. OrderedMap.prototype.remove = function(k) {
  28832. return updateOrderedMap(this, k, NOT_SET);
  28833. };
  28834. OrderedMap.prototype.wasAltered = function() {
  28835. return this._map.wasAltered() || this._list.wasAltered();
  28836. };
  28837. OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  28838. return this._list.__iterate(
  28839. function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
  28840. reverse
  28841. );
  28842. };
  28843. OrderedMap.prototype.__iterator = function(type, reverse) {
  28844. return this._list.fromEntrySeq().__iterator(type, reverse);
  28845. };
  28846. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  28847. if (ownerID === this.__ownerID) {
  28848. return this;
  28849. }
  28850. var newMap = this._map.__ensureOwner(ownerID);
  28851. var newList = this._list.__ensureOwner(ownerID);
  28852. if (!ownerID) {
  28853. this.__ownerID = ownerID;
  28854. this._map = newMap;
  28855. this._list = newList;
  28856. return this;
  28857. }
  28858. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  28859. };
  28860. function isOrderedMap(maybeOrderedMap) {
  28861. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  28862. }
  28863. OrderedMap.isOrderedMap = isOrderedMap;
  28864. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  28865. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  28866. function makeOrderedMap(map, list, ownerID, hash) {
  28867. var omap = Object.create(OrderedMap.prototype);
  28868. omap.size = map ? map.size : 0;
  28869. omap._map = map;
  28870. omap._list = list;
  28871. omap.__ownerID = ownerID;
  28872. omap.__hash = hash;
  28873. return omap;
  28874. }
  28875. var EMPTY_ORDERED_MAP;
  28876. function emptyOrderedMap() {
  28877. return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
  28878. }
  28879. function updateOrderedMap(omap, k, v) {
  28880. var map = omap._map;
  28881. var list = omap._list;
  28882. var i = map.get(k);
  28883. var has = i !== undefined;
  28884. var newMap;
  28885. var newList;
  28886. if (v === NOT_SET) { // removed
  28887. if (!has) {
  28888. return omap;
  28889. }
  28890. if (list.size >= SIZE && list.size >= map.size * 2) {
  28891. newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
  28892. newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
  28893. if (omap.__ownerID) {
  28894. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  28895. }
  28896. } else {
  28897. newMap = map.remove(k);
  28898. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  28899. }
  28900. } else {
  28901. if (has) {
  28902. if (v === list.get(i)[1]) {
  28903. return omap;
  28904. }
  28905. newMap = map;
  28906. newList = list.set(i, [k, v]);
  28907. } else {
  28908. newMap = map.set(k, list.size);
  28909. newList = list.set(list.size, [k, v]);
  28910. }
  28911. }
  28912. if (omap.__ownerID) {
  28913. omap.size = newMap.size;
  28914. omap._map = newMap;
  28915. omap._list = newList;
  28916. omap.__hash = undefined;
  28917. return omap;
  28918. }
  28919. return makeOrderedMap(newMap, newList);
  28920. }
  28921. createClass(ToKeyedSequence, KeyedSeq);
  28922. function ToKeyedSequence(indexed, useKeys) {
  28923. this._iter = indexed;
  28924. this._useKeys = useKeys;
  28925. this.size = indexed.size;
  28926. }
  28927. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  28928. return this._iter.get(key, notSetValue);
  28929. };
  28930. ToKeyedSequence.prototype.has = function(key) {
  28931. return this._iter.has(key);
  28932. };
  28933. ToKeyedSequence.prototype.valueSeq = function() {
  28934. return this._iter.valueSeq();
  28935. };
  28936. ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
  28937. var reversedSequence = reverseFactory(this, true);
  28938. if (!this._useKeys) {
  28939. reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
  28940. }
  28941. return reversedSequence;
  28942. };
  28943. ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
  28944. var mappedSequence = mapFactory(this, mapper, context);
  28945. if (!this._useKeys) {
  28946. mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
  28947. }
  28948. return mappedSequence;
  28949. };
  28950. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  28951. var ii;
  28952. return this._iter.__iterate(
  28953. this._useKeys ?
  28954. function(v, k) {return fn(v, k, this$0)} :
  28955. ((ii = reverse ? resolveSize(this) : 0),
  28956. function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
  28957. reverse
  28958. );
  28959. };
  28960. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  28961. if (this._useKeys) {
  28962. return this._iter.__iterator(type, reverse);
  28963. }
  28964. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  28965. var ii = reverse ? resolveSize(this) : 0;
  28966. return new Iterator(function() {
  28967. var step = iterator.next();
  28968. return step.done ? step :
  28969. iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  28970. });
  28971. };
  28972. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  28973. createClass(ToIndexedSequence, IndexedSeq);
  28974. function ToIndexedSequence(iter) {
  28975. this._iter = iter;
  28976. this.size = iter.size;
  28977. }
  28978. ToIndexedSequence.prototype.includes = function(value) {
  28979. return this._iter.includes(value);
  28980. };
  28981. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  28982. var iterations = 0;
  28983. return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
  28984. };
  28985. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  28986. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  28987. var iterations = 0;
  28988. return new Iterator(function() {
  28989. var step = iterator.next();
  28990. return step.done ? step :
  28991. iteratorValue(type, iterations++, step.value, step)
  28992. });
  28993. };
  28994. createClass(ToSetSequence, SetSeq);
  28995. function ToSetSequence(iter) {
  28996. this._iter = iter;
  28997. this.size = iter.size;
  28998. }
  28999. ToSetSequence.prototype.has = function(key) {
  29000. return this._iter.includes(key);
  29001. };
  29002. ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  29003. return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
  29004. };
  29005. ToSetSequence.prototype.__iterator = function(type, reverse) {
  29006. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  29007. return new Iterator(function() {
  29008. var step = iterator.next();
  29009. return step.done ? step :
  29010. iteratorValue(type, step.value, step.value, step);
  29011. });
  29012. };
  29013. createClass(FromEntriesSequence, KeyedSeq);
  29014. function FromEntriesSequence(entries) {
  29015. this._iter = entries;
  29016. this.size = entries.size;
  29017. }
  29018. FromEntriesSequence.prototype.entrySeq = function() {
  29019. return this._iter.toSeq();
  29020. };
  29021. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  29022. return this._iter.__iterate(function(entry ) {
  29023. // Check if entry exists first so array access doesn't throw for holes
  29024. // in the parent iteration.
  29025. if (entry) {
  29026. validateEntry(entry);
  29027. var indexedIterable = isIterable(entry);
  29028. return fn(
  29029. indexedIterable ? entry.get(1) : entry[1],
  29030. indexedIterable ? entry.get(0) : entry[0],
  29031. this$0
  29032. );
  29033. }
  29034. }, reverse);
  29035. };
  29036. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  29037. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  29038. return new Iterator(function() {
  29039. while (true) {
  29040. var step = iterator.next();
  29041. if (step.done) {
  29042. return step;
  29043. }
  29044. var entry = step.value;
  29045. // Check if entry exists first so array access doesn't throw for holes
  29046. // in the parent iteration.
  29047. if (entry) {
  29048. validateEntry(entry);
  29049. var indexedIterable = isIterable(entry);
  29050. return iteratorValue(
  29051. type,
  29052. indexedIterable ? entry.get(0) : entry[0],
  29053. indexedIterable ? entry.get(1) : entry[1],
  29054. step
  29055. );
  29056. }
  29057. }
  29058. });
  29059. };
  29060. ToIndexedSequence.prototype.cacheResult =
  29061. ToKeyedSequence.prototype.cacheResult =
  29062. ToSetSequence.prototype.cacheResult =
  29063. FromEntriesSequence.prototype.cacheResult =
  29064. cacheResultThrough;
  29065. function flipFactory(iterable) {
  29066. var flipSequence = makeSequence(iterable);
  29067. flipSequence._iter = iterable;
  29068. flipSequence.size = iterable.size;
  29069. flipSequence.flip = function() {return iterable};
  29070. flipSequence.reverse = function () {
  29071. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  29072. reversedSequence.flip = function() {return iterable.reverse()};
  29073. return reversedSequence;
  29074. };
  29075. flipSequence.has = function(key ) {return iterable.includes(key)};
  29076. flipSequence.includes = function(key ) {return iterable.has(key)};
  29077. flipSequence.cacheResult = cacheResultThrough;
  29078. flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  29079. return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
  29080. };
  29081. flipSequence.__iteratorUncached = function(type, reverse) {
  29082. if (type === ITERATE_ENTRIES) {
  29083. var iterator = iterable.__iterator(type, reverse);
  29084. return new Iterator(function() {
  29085. var step = iterator.next();
  29086. if (!step.done) {
  29087. var k = step.value[0];
  29088. step.value[0] = step.value[1];
  29089. step.value[1] = k;
  29090. }
  29091. return step;
  29092. });
  29093. }
  29094. return iterable.__iterator(
  29095. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  29096. reverse
  29097. );
  29098. };
  29099. return flipSequence;
  29100. }
  29101. function mapFactory(iterable, mapper, context) {
  29102. var mappedSequence = makeSequence(iterable);
  29103. mappedSequence.size = iterable.size;
  29104. mappedSequence.has = function(key ) {return iterable.has(key)};
  29105. mappedSequence.get = function(key, notSetValue) {
  29106. var v = iterable.get(key, NOT_SET);
  29107. return v === NOT_SET ?
  29108. notSetValue :
  29109. mapper.call(context, v, key, iterable);
  29110. };
  29111. mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  29112. return iterable.__iterate(
  29113. function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
  29114. reverse
  29115. );
  29116. };
  29117. mappedSequence.__iteratorUncached = function (type, reverse) {
  29118. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  29119. return new Iterator(function() {
  29120. var step = iterator.next();
  29121. if (step.done) {
  29122. return step;
  29123. }
  29124. var entry = step.value;
  29125. var key = entry[0];
  29126. return iteratorValue(
  29127. type,
  29128. key,
  29129. mapper.call(context, entry[1], key, iterable),
  29130. step
  29131. );
  29132. });
  29133. };
  29134. return mappedSequence;
  29135. }
  29136. function reverseFactory(iterable, useKeys) {
  29137. var reversedSequence = makeSequence(iterable);
  29138. reversedSequence._iter = iterable;
  29139. reversedSequence.size = iterable.size;
  29140. reversedSequence.reverse = function() {return iterable};
  29141. if (iterable.flip) {
  29142. reversedSequence.flip = function () {
  29143. var flipSequence = flipFactory(iterable);
  29144. flipSequence.reverse = function() {return iterable.flip()};
  29145. return flipSequence;
  29146. };
  29147. }
  29148. reversedSequence.get = function(key, notSetValue)
  29149. {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
  29150. reversedSequence.has = function(key )
  29151. {return iterable.has(useKeys ? key : -1 - key)};
  29152. reversedSequence.includes = function(value ) {return iterable.includes(value)};
  29153. reversedSequence.cacheResult = cacheResultThrough;
  29154. reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
  29155. return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
  29156. };
  29157. reversedSequence.__iterator =
  29158. function(type, reverse) {return iterable.__iterator(type, !reverse)};
  29159. return reversedSequence;
  29160. }
  29161. function filterFactory(iterable, predicate, context, useKeys) {
  29162. var filterSequence = makeSequence(iterable);
  29163. if (useKeys) {
  29164. filterSequence.has = function(key ) {
  29165. var v = iterable.get(key, NOT_SET);
  29166. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  29167. };
  29168. filterSequence.get = function(key, notSetValue) {
  29169. var v = iterable.get(key, NOT_SET);
  29170. return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
  29171. v : notSetValue;
  29172. };
  29173. }
  29174. filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  29175. var iterations = 0;
  29176. iterable.__iterate(function(v, k, c) {
  29177. if (predicate.call(context, v, k, c)) {
  29178. iterations++;
  29179. return fn(v, useKeys ? k : iterations - 1, this$0);
  29180. }
  29181. }, reverse);
  29182. return iterations;
  29183. };
  29184. filterSequence.__iteratorUncached = function (type, reverse) {
  29185. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  29186. var iterations = 0;
  29187. return new Iterator(function() {
  29188. while (true) {
  29189. var step = iterator.next();
  29190. if (step.done) {
  29191. return step;
  29192. }
  29193. var entry = step.value;
  29194. var key = entry[0];
  29195. var value = entry[1];
  29196. if (predicate.call(context, value, key, iterable)) {
  29197. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  29198. }
  29199. }
  29200. });
  29201. };
  29202. return filterSequence;
  29203. }
  29204. function countByFactory(iterable, grouper, context) {
  29205. var groups = Map().asMutable();
  29206. iterable.__iterate(function(v, k) {
  29207. groups.update(
  29208. grouper.call(context, v, k, iterable),
  29209. 0,
  29210. function(a ) {return a + 1}
  29211. );
  29212. });
  29213. return groups.asImmutable();
  29214. }
  29215. function groupByFactory(iterable, grouper, context) {
  29216. var isKeyedIter = isKeyed(iterable);
  29217. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  29218. iterable.__iterate(function(v, k) {
  29219. groups.update(
  29220. grouper.call(context, v, k, iterable),
  29221. function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
  29222. );
  29223. });
  29224. var coerce = iterableClass(iterable);
  29225. return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
  29226. }
  29227. function sliceFactory(iterable, begin, end, useKeys) {
  29228. var originalSize = iterable.size;
  29229. // Sanitize begin & end using this shorthand for ToInt32(argument)
  29230. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  29231. if (begin !== undefined) {
  29232. begin = begin | 0;
  29233. }
  29234. if (end !== undefined) {
  29235. end = end | 0;
  29236. }
  29237. if (wholeSlice(begin, end, originalSize)) {
  29238. return iterable;
  29239. }
  29240. var resolvedBegin = resolveBegin(begin, originalSize);
  29241. var resolvedEnd = resolveEnd(end, originalSize);
  29242. // begin or end will be NaN if they were provided as negative numbers and
  29243. // this iterable's size is unknown. In that case, cache first so there is
  29244. // a known size and these do not resolve to NaN.
  29245. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  29246. return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
  29247. }
  29248. // Note: resolvedEnd is undefined when the original sequence's length is
  29249. // unknown and this slice did not supply an end and should contain all
  29250. // elements after resolvedBegin.
  29251. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  29252. var resolvedSize = resolvedEnd - resolvedBegin;
  29253. var sliceSize;
  29254. if (resolvedSize === resolvedSize) {
  29255. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  29256. }
  29257. var sliceSeq = makeSequence(iterable);
  29258. // If iterable.size is undefined, the size of the realized sliceSeq is
  29259. // unknown at this point unless the number of items to slice is 0
  29260. sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
  29261. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  29262. sliceSeq.get = function (index, notSetValue) {
  29263. index = wrapIndex(this, index);
  29264. return index >= 0 && index < sliceSize ?
  29265. iterable.get(index + resolvedBegin, notSetValue) :
  29266. notSetValue;
  29267. };
  29268. }
  29269. sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
  29270. if (sliceSize === 0) {
  29271. return 0;
  29272. }
  29273. if (reverse) {
  29274. return this.cacheResult().__iterate(fn, reverse);
  29275. }
  29276. var skipped = 0;
  29277. var isSkipping = true;
  29278. var iterations = 0;
  29279. iterable.__iterate(function(v, k) {
  29280. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  29281. iterations++;
  29282. return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  29283. iterations !== sliceSize;
  29284. }
  29285. });
  29286. return iterations;
  29287. };
  29288. sliceSeq.__iteratorUncached = function(type, reverse) {
  29289. if (sliceSize !== 0 && reverse) {
  29290. return this.cacheResult().__iterator(type, reverse);
  29291. }
  29292. // Don't bother instantiating parent iterator if taking 0.
  29293. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  29294. var skipped = 0;
  29295. var iterations = 0;
  29296. return new Iterator(function() {
  29297. while (skipped++ < resolvedBegin) {
  29298. iterator.next();
  29299. }
  29300. if (++iterations > sliceSize) {
  29301. return iteratorDone();
  29302. }
  29303. var step = iterator.next();
  29304. if (useKeys || type === ITERATE_VALUES) {
  29305. return step;
  29306. } else if (type === ITERATE_KEYS) {
  29307. return iteratorValue(type, iterations - 1, undefined, step);
  29308. } else {
  29309. return iteratorValue(type, iterations - 1, step.value[1], step);
  29310. }
  29311. });
  29312. };
  29313. return sliceSeq;
  29314. }
  29315. function takeWhileFactory(iterable, predicate, context) {
  29316. var takeSequence = makeSequence(iterable);
  29317. takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  29318. if (reverse) {
  29319. return this.cacheResult().__iterate(fn, reverse);
  29320. }
  29321. var iterations = 0;
  29322. iterable.__iterate(function(v, k, c)
  29323. {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
  29324. );
  29325. return iterations;
  29326. };
  29327. takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  29328. if (reverse) {
  29329. return this.cacheResult().__iterator(type, reverse);
  29330. }
  29331. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  29332. var iterating = true;
  29333. return new Iterator(function() {
  29334. if (!iterating) {
  29335. return iteratorDone();
  29336. }
  29337. var step = iterator.next();
  29338. if (step.done) {
  29339. return step;
  29340. }
  29341. var entry = step.value;
  29342. var k = entry[0];
  29343. var v = entry[1];
  29344. if (!predicate.call(context, v, k, this$0)) {
  29345. iterating = false;
  29346. return iteratorDone();
  29347. }
  29348. return type === ITERATE_ENTRIES ? step :
  29349. iteratorValue(type, k, v, step);
  29350. });
  29351. };
  29352. return takeSequence;
  29353. }
  29354. function skipWhileFactory(iterable, predicate, context, useKeys) {
  29355. var skipSequence = makeSequence(iterable);
  29356. skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  29357. if (reverse) {
  29358. return this.cacheResult().__iterate(fn, reverse);
  29359. }
  29360. var isSkipping = true;
  29361. var iterations = 0;
  29362. iterable.__iterate(function(v, k, c) {
  29363. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  29364. iterations++;
  29365. return fn(v, useKeys ? k : iterations - 1, this$0);
  29366. }
  29367. });
  29368. return iterations;
  29369. };
  29370. skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  29371. if (reverse) {
  29372. return this.cacheResult().__iterator(type, reverse);
  29373. }
  29374. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  29375. var skipping = true;
  29376. var iterations = 0;
  29377. return new Iterator(function() {
  29378. var step, k, v;
  29379. do {
  29380. step = iterator.next();
  29381. if (step.done) {
  29382. if (useKeys || type === ITERATE_VALUES) {
  29383. return step;
  29384. } else if (type === ITERATE_KEYS) {
  29385. return iteratorValue(type, iterations++, undefined, step);
  29386. } else {
  29387. return iteratorValue(type, iterations++, step.value[1], step);
  29388. }
  29389. }
  29390. var entry = step.value;
  29391. k = entry[0];
  29392. v = entry[1];
  29393. skipping && (skipping = predicate.call(context, v, k, this$0));
  29394. } while (skipping);
  29395. return type === ITERATE_ENTRIES ? step :
  29396. iteratorValue(type, k, v, step);
  29397. });
  29398. };
  29399. return skipSequence;
  29400. }
  29401. function concatFactory(iterable, values) {
  29402. var isKeyedIterable = isKeyed(iterable);
  29403. var iters = [iterable].concat(values).map(function(v ) {
  29404. if (!isIterable(v)) {
  29405. v = isKeyedIterable ?
  29406. keyedSeqFromValue(v) :
  29407. indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  29408. } else if (isKeyedIterable) {
  29409. v = KeyedIterable(v);
  29410. }
  29411. return v;
  29412. }).filter(function(v ) {return v.size !== 0});
  29413. if (iters.length === 0) {
  29414. return iterable;
  29415. }
  29416. if (iters.length === 1) {
  29417. var singleton = iters[0];
  29418. if (singleton === iterable ||
  29419. isKeyedIterable && isKeyed(singleton) ||
  29420. isIndexed(iterable) && isIndexed(singleton)) {
  29421. return singleton;
  29422. }
  29423. }
  29424. var concatSeq = new ArraySeq(iters);
  29425. if (isKeyedIterable) {
  29426. concatSeq = concatSeq.toKeyedSeq();
  29427. } else if (!isIndexed(iterable)) {
  29428. concatSeq = concatSeq.toSetSeq();
  29429. }
  29430. concatSeq = concatSeq.flatten(true);
  29431. concatSeq.size = iters.reduce(
  29432. function(sum, seq) {
  29433. if (sum !== undefined) {
  29434. var size = seq.size;
  29435. if (size !== undefined) {
  29436. return sum + size;
  29437. }
  29438. }
  29439. },
  29440. 0
  29441. );
  29442. return concatSeq;
  29443. }
  29444. function flattenFactory(iterable, depth, useKeys) {
  29445. var flatSequence = makeSequence(iterable);
  29446. flatSequence.__iterateUncached = function(fn, reverse) {
  29447. var iterations = 0;
  29448. var stopped = false;
  29449. function flatDeep(iter, currentDepth) {var this$0 = this;
  29450. iter.__iterate(function(v, k) {
  29451. if ((!depth || currentDepth < depth) && isIterable(v)) {
  29452. flatDeep(v, currentDepth + 1);
  29453. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  29454. stopped = true;
  29455. }
  29456. return !stopped;
  29457. }, reverse);
  29458. }
  29459. flatDeep(iterable, 0);
  29460. return iterations;
  29461. };
  29462. flatSequence.__iteratorUncached = function(type, reverse) {
  29463. var iterator = iterable.__iterator(type, reverse);
  29464. var stack = [];
  29465. var iterations = 0;
  29466. return new Iterator(function() {
  29467. while (iterator) {
  29468. var step = iterator.next();
  29469. if (step.done !== false) {
  29470. iterator = stack.pop();
  29471. continue;
  29472. }
  29473. var v = step.value;
  29474. if (type === ITERATE_ENTRIES) {
  29475. v = v[1];
  29476. }
  29477. if ((!depth || stack.length < depth) && isIterable(v)) {
  29478. stack.push(iterator);
  29479. iterator = v.__iterator(type, reverse);
  29480. } else {
  29481. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  29482. }
  29483. }
  29484. return iteratorDone();
  29485. });
  29486. };
  29487. return flatSequence;
  29488. }
  29489. function flatMapFactory(iterable, mapper, context) {
  29490. var coerce = iterableClass(iterable);
  29491. return iterable.toSeq().map(
  29492. function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
  29493. ).flatten(true);
  29494. }
  29495. function interposeFactory(iterable, separator) {
  29496. var interposedSequence = makeSequence(iterable);
  29497. interposedSequence.size = iterable.size && iterable.size * 2 -1;
  29498. interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  29499. var iterations = 0;
  29500. iterable.__iterate(function(v, k)
  29501. {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
  29502. fn(v, iterations++, this$0) !== false},
  29503. reverse
  29504. );
  29505. return iterations;
  29506. };
  29507. interposedSequence.__iteratorUncached = function(type, reverse) {
  29508. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  29509. var iterations = 0;
  29510. var step;
  29511. return new Iterator(function() {
  29512. if (!step || iterations % 2) {
  29513. step = iterator.next();
  29514. if (step.done) {
  29515. return step;
  29516. }
  29517. }
  29518. return iterations % 2 ?
  29519. iteratorValue(type, iterations++, separator) :
  29520. iteratorValue(type, iterations++, step.value, step);
  29521. });
  29522. };
  29523. return interposedSequence;
  29524. }
  29525. function sortFactory(iterable, comparator, mapper) {
  29526. if (!comparator) {
  29527. comparator = defaultComparator;
  29528. }
  29529. var isKeyedIterable = isKeyed(iterable);
  29530. var index = 0;
  29531. var entries = iterable.toSeq().map(
  29532. function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
  29533. ).toArray();
  29534. entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
  29535. isKeyedIterable ?
  29536. function(v, i) { entries[i].length = 2; } :
  29537. function(v, i) { entries[i] = v[1]; }
  29538. );
  29539. return isKeyedIterable ? KeyedSeq(entries) :
  29540. isIndexed(iterable) ? IndexedSeq(entries) :
  29541. SetSeq(entries);
  29542. }
  29543. function maxFactory(iterable, comparator, mapper) {
  29544. if (!comparator) {
  29545. comparator = defaultComparator;
  29546. }
  29547. if (mapper) {
  29548. var entry = iterable.toSeq()
  29549. .map(function(v, k) {return [v, mapper(v, k, iterable)]})
  29550. .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
  29551. return entry && entry[0];
  29552. } else {
  29553. return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
  29554. }
  29555. }
  29556. function maxCompare(comparator, a, b) {
  29557. var comp = comparator(b, a);
  29558. // b is considered the new max if the comparator declares them equal, but
  29559. // they are not equal and b is in fact a nullish value.
  29560. return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
  29561. }
  29562. function zipWithFactory(keyIter, zipper, iters) {
  29563. var zipSequence = makeSequence(keyIter);
  29564. zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
  29565. // Note: this a generic base implementation of __iterate in terms of
  29566. // __iterator which may be more generically useful in the future.
  29567. zipSequence.__iterate = function(fn, reverse) {
  29568. /* generic:
  29569. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  29570. var step;
  29571. var iterations = 0;
  29572. while (!(step = iterator.next()).done) {
  29573. iterations++;
  29574. if (fn(step.value[1], step.value[0], this) === false) {
  29575. break;
  29576. }
  29577. }
  29578. return iterations;
  29579. */
  29580. // indexed:
  29581. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  29582. var step;
  29583. var iterations = 0;
  29584. while (!(step = iterator.next()).done) {
  29585. if (fn(step.value, iterations++, this) === false) {
  29586. break;
  29587. }
  29588. }
  29589. return iterations;
  29590. };
  29591. zipSequence.__iteratorUncached = function(type, reverse) {
  29592. var iterators = iters.map(function(i )
  29593. {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
  29594. );
  29595. var iterations = 0;
  29596. var isDone = false;
  29597. return new Iterator(function() {
  29598. var steps;
  29599. if (!isDone) {
  29600. steps = iterators.map(function(i ) {return i.next()});
  29601. isDone = steps.some(function(s ) {return s.done});
  29602. }
  29603. if (isDone) {
  29604. return iteratorDone();
  29605. }
  29606. return iteratorValue(
  29607. type,
  29608. iterations++,
  29609. zipper.apply(null, steps.map(function(s ) {return s.value}))
  29610. );
  29611. });
  29612. };
  29613. return zipSequence
  29614. }
  29615. // #pragma Helper Functions
  29616. function reify(iter, seq) {
  29617. return isSeq(iter) ? seq : iter.constructor(seq);
  29618. }
  29619. function validateEntry(entry) {
  29620. if (entry !== Object(entry)) {
  29621. throw new TypeError('Expected [K, V] tuple: ' + entry);
  29622. }
  29623. }
  29624. function resolveSize(iter) {
  29625. assertNotInfinite(iter.size);
  29626. return ensureSize(iter);
  29627. }
  29628. function iterableClass(iterable) {
  29629. return isKeyed(iterable) ? KeyedIterable :
  29630. isIndexed(iterable) ? IndexedIterable :
  29631. SetIterable;
  29632. }
  29633. function makeSequence(iterable) {
  29634. return Object.create(
  29635. (
  29636. isKeyed(iterable) ? KeyedSeq :
  29637. isIndexed(iterable) ? IndexedSeq :
  29638. SetSeq
  29639. ).prototype
  29640. );
  29641. }
  29642. function cacheResultThrough() {
  29643. if (this._iter.cacheResult) {
  29644. this._iter.cacheResult();
  29645. this.size = this._iter.size;
  29646. return this;
  29647. } else {
  29648. return Seq.prototype.cacheResult.call(this);
  29649. }
  29650. }
  29651. function defaultComparator(a, b) {
  29652. return a > b ? 1 : a < b ? -1 : 0;
  29653. }
  29654. function forceIterator(keyPath) {
  29655. var iter = getIterator(keyPath);
  29656. if (!iter) {
  29657. // Array might not be iterable in this environment, so we need a fallback
  29658. // to our wrapped type.
  29659. if (!isArrayLike(keyPath)) {
  29660. throw new TypeError('Expected iterable or array-like: ' + keyPath);
  29661. }
  29662. iter = getIterator(Iterable(keyPath));
  29663. }
  29664. return iter;
  29665. }
  29666. createClass(Record, KeyedCollection);
  29667. function Record(defaultValues, name) {
  29668. var hasInitialized;
  29669. var RecordType = function Record(values) {
  29670. if (values instanceof RecordType) {
  29671. return values;
  29672. }
  29673. if (!(this instanceof RecordType)) {
  29674. return new RecordType(values);
  29675. }
  29676. if (!hasInitialized) {
  29677. hasInitialized = true;
  29678. var keys = Object.keys(defaultValues);
  29679. setProps(RecordTypePrototype, keys);
  29680. RecordTypePrototype.size = keys.length;
  29681. RecordTypePrototype._name = name;
  29682. RecordTypePrototype._keys = keys;
  29683. RecordTypePrototype._defaultValues = defaultValues;
  29684. }
  29685. this._map = Map(values);
  29686. };
  29687. var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
  29688. RecordTypePrototype.constructor = RecordType;
  29689. return RecordType;
  29690. }
  29691. Record.prototype.toString = function() {
  29692. return this.__toString(recordName(this) + ' {', '}');
  29693. };
  29694. // @pragma Access
  29695. Record.prototype.has = function(k) {
  29696. return this._defaultValues.hasOwnProperty(k);
  29697. };
  29698. Record.prototype.get = function(k, notSetValue) {
  29699. if (!this.has(k)) {
  29700. return notSetValue;
  29701. }
  29702. var defaultVal = this._defaultValues[k];
  29703. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  29704. };
  29705. // @pragma Modification
  29706. Record.prototype.clear = function() {
  29707. if (this.__ownerID) {
  29708. this._map && this._map.clear();
  29709. return this;
  29710. }
  29711. var RecordType = this.constructor;
  29712. return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
  29713. };
  29714. Record.prototype.set = function(k, v) {
  29715. if (!this.has(k)) {
  29716. throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
  29717. }
  29718. var newMap = this._map && this._map.set(k, v);
  29719. if (this.__ownerID || newMap === this._map) {
  29720. return this;
  29721. }
  29722. return makeRecord(this, newMap);
  29723. };
  29724. Record.prototype.remove = function(k) {
  29725. if (!this.has(k)) {
  29726. return this;
  29727. }
  29728. var newMap = this._map && this._map.remove(k);
  29729. if (this.__ownerID || newMap === this._map) {
  29730. return this;
  29731. }
  29732. return makeRecord(this, newMap);
  29733. };
  29734. Record.prototype.wasAltered = function() {
  29735. return this._map.wasAltered();
  29736. };
  29737. Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
  29738. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
  29739. };
  29740. Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  29741. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
  29742. };
  29743. Record.prototype.__ensureOwner = function(ownerID) {
  29744. if (ownerID === this.__ownerID) {
  29745. return this;
  29746. }
  29747. var newMap = this._map && this._map.__ensureOwner(ownerID);
  29748. if (!ownerID) {
  29749. this.__ownerID = ownerID;
  29750. this._map = newMap;
  29751. return this;
  29752. }
  29753. return makeRecord(this, newMap, ownerID);
  29754. };
  29755. var RecordPrototype = Record.prototype;
  29756. RecordPrototype[DELETE] = RecordPrototype.remove;
  29757. RecordPrototype.deleteIn =
  29758. RecordPrototype.removeIn = MapPrototype.removeIn;
  29759. RecordPrototype.merge = MapPrototype.merge;
  29760. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  29761. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  29762. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  29763. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  29764. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  29765. RecordPrototype.setIn = MapPrototype.setIn;
  29766. RecordPrototype.update = MapPrototype.update;
  29767. RecordPrototype.updateIn = MapPrototype.updateIn;
  29768. RecordPrototype.withMutations = MapPrototype.withMutations;
  29769. RecordPrototype.asMutable = MapPrototype.asMutable;
  29770. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  29771. function makeRecord(likeRecord, map, ownerID) {
  29772. var record = Object.create(Object.getPrototypeOf(likeRecord));
  29773. record._map = map;
  29774. record.__ownerID = ownerID;
  29775. return record;
  29776. }
  29777. function recordName(record) {
  29778. return record._name || record.constructor.name || 'Record';
  29779. }
  29780. function setProps(prototype, names) {
  29781. try {
  29782. names.forEach(setProp.bind(undefined, prototype));
  29783. } catch (error) {
  29784. // Object.defineProperty failed. Probably IE8.
  29785. }
  29786. }
  29787. function setProp(prototype, name) {
  29788. Object.defineProperty(prototype, name, {
  29789. get: function() {
  29790. return this.get(name);
  29791. },
  29792. set: function(value) {
  29793. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  29794. this.set(name, value);
  29795. }
  29796. });
  29797. }
  29798. createClass(Set, SetCollection);
  29799. // @pragma Construction
  29800. function Set(value) {
  29801. return value === null || value === undefined ? emptySet() :
  29802. isSet(value) && !isOrdered(value) ? value :
  29803. emptySet().withMutations(function(set ) {
  29804. var iter = SetIterable(value);
  29805. assertNotInfinite(iter.size);
  29806. iter.forEach(function(v ) {return set.add(v)});
  29807. });
  29808. }
  29809. Set.of = function(/*...values*/) {
  29810. return this(arguments);
  29811. };
  29812. Set.fromKeys = function(value) {
  29813. return this(KeyedIterable(value).keySeq());
  29814. };
  29815. Set.prototype.toString = function() {
  29816. return this.__toString('Set {', '}');
  29817. };
  29818. // @pragma Access
  29819. Set.prototype.has = function(value) {
  29820. return this._map.has(value);
  29821. };
  29822. // @pragma Modification
  29823. Set.prototype.add = function(value) {
  29824. return updateSet(this, this._map.set(value, true));
  29825. };
  29826. Set.prototype.remove = function(value) {
  29827. return updateSet(this, this._map.remove(value));
  29828. };
  29829. Set.prototype.clear = function() {
  29830. return updateSet(this, this._map.clear());
  29831. };
  29832. // @pragma Composition
  29833. Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
  29834. iters = iters.filter(function(x ) {return x.size !== 0});
  29835. if (iters.length === 0) {
  29836. return this;
  29837. }
  29838. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  29839. return this.constructor(iters[0]);
  29840. }
  29841. return this.withMutations(function(set ) {
  29842. for (var ii = 0; ii < iters.length; ii++) {
  29843. SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
  29844. }
  29845. });
  29846. };
  29847. Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
  29848. if (iters.length === 0) {
  29849. return this;
  29850. }
  29851. iters = iters.map(function(iter ) {return SetIterable(iter)});
  29852. var originalSet = this;
  29853. return this.withMutations(function(set ) {
  29854. originalSet.forEach(function(value ) {
  29855. if (!iters.every(function(iter ) {return iter.includes(value)})) {
  29856. set.remove(value);
  29857. }
  29858. });
  29859. });
  29860. };
  29861. Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
  29862. if (iters.length === 0) {
  29863. return this;
  29864. }
  29865. iters = iters.map(function(iter ) {return SetIterable(iter)});
  29866. var originalSet = this;
  29867. return this.withMutations(function(set ) {
  29868. originalSet.forEach(function(value ) {
  29869. if (iters.some(function(iter ) {return iter.includes(value)})) {
  29870. set.remove(value);
  29871. }
  29872. });
  29873. });
  29874. };
  29875. Set.prototype.merge = function() {
  29876. return this.union.apply(this, arguments);
  29877. };
  29878. Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  29879. return this.union.apply(this, iters);
  29880. };
  29881. Set.prototype.sort = function(comparator) {
  29882. // Late binding
  29883. return OrderedSet(sortFactory(this, comparator));
  29884. };
  29885. Set.prototype.sortBy = function(mapper, comparator) {
  29886. // Late binding
  29887. return OrderedSet(sortFactory(this, comparator, mapper));
  29888. };
  29889. Set.prototype.wasAltered = function() {
  29890. return this._map.wasAltered();
  29891. };
  29892. Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  29893. return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
  29894. };
  29895. Set.prototype.__iterator = function(type, reverse) {
  29896. return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
  29897. };
  29898. Set.prototype.__ensureOwner = function(ownerID) {
  29899. if (ownerID === this.__ownerID) {
  29900. return this;
  29901. }
  29902. var newMap = this._map.__ensureOwner(ownerID);
  29903. if (!ownerID) {
  29904. this.__ownerID = ownerID;
  29905. this._map = newMap;
  29906. return this;
  29907. }
  29908. return this.__make(newMap, ownerID);
  29909. };
  29910. function isSet(maybeSet) {
  29911. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  29912. }
  29913. Set.isSet = isSet;
  29914. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  29915. var SetPrototype = Set.prototype;
  29916. SetPrototype[IS_SET_SENTINEL] = true;
  29917. SetPrototype[DELETE] = SetPrototype.remove;
  29918. SetPrototype.mergeDeep = SetPrototype.merge;
  29919. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  29920. SetPrototype.withMutations = MapPrototype.withMutations;
  29921. SetPrototype.asMutable = MapPrototype.asMutable;
  29922. SetPrototype.asImmutable = MapPrototype.asImmutable;
  29923. SetPrototype.__empty = emptySet;
  29924. SetPrototype.__make = makeSet;
  29925. function updateSet(set, newMap) {
  29926. if (set.__ownerID) {
  29927. set.size = newMap.size;
  29928. set._map = newMap;
  29929. return set;
  29930. }
  29931. return newMap === set._map ? set :
  29932. newMap.size === 0 ? set.__empty() :
  29933. set.__make(newMap);
  29934. }
  29935. function makeSet(map, ownerID) {
  29936. var set = Object.create(SetPrototype);
  29937. set.size = map ? map.size : 0;
  29938. set._map = map;
  29939. set.__ownerID = ownerID;
  29940. return set;
  29941. }
  29942. var EMPTY_SET;
  29943. function emptySet() {
  29944. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  29945. }
  29946. createClass(OrderedSet, Set);
  29947. // @pragma Construction
  29948. function OrderedSet(value) {
  29949. return value === null || value === undefined ? emptyOrderedSet() :
  29950. isOrderedSet(value) ? value :
  29951. emptyOrderedSet().withMutations(function(set ) {
  29952. var iter = SetIterable(value);
  29953. assertNotInfinite(iter.size);
  29954. iter.forEach(function(v ) {return set.add(v)});
  29955. });
  29956. }
  29957. OrderedSet.of = function(/*...values*/) {
  29958. return this(arguments);
  29959. };
  29960. OrderedSet.fromKeys = function(value) {
  29961. return this(KeyedIterable(value).keySeq());
  29962. };
  29963. OrderedSet.prototype.toString = function() {
  29964. return this.__toString('OrderedSet {', '}');
  29965. };
  29966. function isOrderedSet(maybeOrderedSet) {
  29967. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  29968. }
  29969. OrderedSet.isOrderedSet = isOrderedSet;
  29970. var OrderedSetPrototype = OrderedSet.prototype;
  29971. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  29972. OrderedSetPrototype.__empty = emptyOrderedSet;
  29973. OrderedSetPrototype.__make = makeOrderedSet;
  29974. function makeOrderedSet(map, ownerID) {
  29975. var set = Object.create(OrderedSetPrototype);
  29976. set.size = map ? map.size : 0;
  29977. set._map = map;
  29978. set.__ownerID = ownerID;
  29979. return set;
  29980. }
  29981. var EMPTY_ORDERED_SET;
  29982. function emptyOrderedSet() {
  29983. return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
  29984. }
  29985. createClass(Stack, IndexedCollection);
  29986. // @pragma Construction
  29987. function Stack(value) {
  29988. return value === null || value === undefined ? emptyStack() :
  29989. isStack(value) ? value :
  29990. emptyStack().unshiftAll(value);
  29991. }
  29992. Stack.of = function(/*...values*/) {
  29993. return this(arguments);
  29994. };
  29995. Stack.prototype.toString = function() {
  29996. return this.__toString('Stack [', ']');
  29997. };
  29998. // @pragma Access
  29999. Stack.prototype.get = function(index, notSetValue) {
  30000. var head = this._head;
  30001. index = wrapIndex(this, index);
  30002. while (head && index--) {
  30003. head = head.next;
  30004. }
  30005. return head ? head.value : notSetValue;
  30006. };
  30007. Stack.prototype.peek = function() {
  30008. return this._head && this._head.value;
  30009. };
  30010. // @pragma Modification
  30011. Stack.prototype.push = function(/*...values*/) {
  30012. if (arguments.length === 0) {
  30013. return this;
  30014. }
  30015. var newSize = this.size + arguments.length;
  30016. var head = this._head;
  30017. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  30018. head = {
  30019. value: arguments[ii],
  30020. next: head
  30021. };
  30022. }
  30023. if (this.__ownerID) {
  30024. this.size = newSize;
  30025. this._head = head;
  30026. this.__hash = undefined;
  30027. this.__altered = true;
  30028. return this;
  30029. }
  30030. return makeStack(newSize, head);
  30031. };
  30032. Stack.prototype.pushAll = function(iter) {
  30033. iter = IndexedIterable(iter);
  30034. if (iter.size === 0) {
  30035. return this;
  30036. }
  30037. assertNotInfinite(iter.size);
  30038. var newSize = this.size;
  30039. var head = this._head;
  30040. iter.reverse().forEach(function(value ) {
  30041. newSize++;
  30042. head = {
  30043. value: value,
  30044. next: head
  30045. };
  30046. });
  30047. if (this.__ownerID) {
  30048. this.size = newSize;
  30049. this._head = head;
  30050. this.__hash = undefined;
  30051. this.__altered = true;
  30052. return this;
  30053. }
  30054. return makeStack(newSize, head);
  30055. };
  30056. Stack.prototype.pop = function() {
  30057. return this.slice(1);
  30058. };
  30059. Stack.prototype.unshift = function(/*...values*/) {
  30060. return this.push.apply(this, arguments);
  30061. };
  30062. Stack.prototype.unshiftAll = function(iter) {
  30063. return this.pushAll(iter);
  30064. };
  30065. Stack.prototype.shift = function() {
  30066. return this.pop.apply(this, arguments);
  30067. };
  30068. Stack.prototype.clear = function() {
  30069. if (this.size === 0) {
  30070. return this;
  30071. }
  30072. if (this.__ownerID) {
  30073. this.size = 0;
  30074. this._head = undefined;
  30075. this.__hash = undefined;
  30076. this.__altered = true;
  30077. return this;
  30078. }
  30079. return emptyStack();
  30080. };
  30081. Stack.prototype.slice = function(begin, end) {
  30082. if (wholeSlice(begin, end, this.size)) {
  30083. return this;
  30084. }
  30085. var resolvedBegin = resolveBegin(begin, this.size);
  30086. var resolvedEnd = resolveEnd(end, this.size);
  30087. if (resolvedEnd !== this.size) {
  30088. // super.slice(begin, end);
  30089. return IndexedCollection.prototype.slice.call(this, begin, end);
  30090. }
  30091. var newSize = this.size - resolvedBegin;
  30092. var head = this._head;
  30093. while (resolvedBegin--) {
  30094. head = head.next;
  30095. }
  30096. if (this.__ownerID) {
  30097. this.size = newSize;
  30098. this._head = head;
  30099. this.__hash = undefined;
  30100. this.__altered = true;
  30101. return this;
  30102. }
  30103. return makeStack(newSize, head);
  30104. };
  30105. // @pragma Mutability
  30106. Stack.prototype.__ensureOwner = function(ownerID) {
  30107. if (ownerID === this.__ownerID) {
  30108. return this;
  30109. }
  30110. if (!ownerID) {
  30111. this.__ownerID = ownerID;
  30112. this.__altered = false;
  30113. return this;
  30114. }
  30115. return makeStack(this.size, this._head, ownerID, this.__hash);
  30116. };
  30117. // @pragma Iteration
  30118. Stack.prototype.__iterate = function(fn, reverse) {
  30119. if (reverse) {
  30120. return this.reverse().__iterate(fn);
  30121. }
  30122. var iterations = 0;
  30123. var node = this._head;
  30124. while (node) {
  30125. if (fn(node.value, iterations++, this) === false) {
  30126. break;
  30127. }
  30128. node = node.next;
  30129. }
  30130. return iterations;
  30131. };
  30132. Stack.prototype.__iterator = function(type, reverse) {
  30133. if (reverse) {
  30134. return this.reverse().__iterator(type);
  30135. }
  30136. var iterations = 0;
  30137. var node = this._head;
  30138. return new Iterator(function() {
  30139. if (node) {
  30140. var value = node.value;
  30141. node = node.next;
  30142. return iteratorValue(type, iterations++, value);
  30143. }
  30144. return iteratorDone();
  30145. });
  30146. };
  30147. function isStack(maybeStack) {
  30148. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  30149. }
  30150. Stack.isStack = isStack;
  30151. var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  30152. var StackPrototype = Stack.prototype;
  30153. StackPrototype[IS_STACK_SENTINEL] = true;
  30154. StackPrototype.withMutations = MapPrototype.withMutations;
  30155. StackPrototype.asMutable = MapPrototype.asMutable;
  30156. StackPrototype.asImmutable = MapPrototype.asImmutable;
  30157. StackPrototype.wasAltered = MapPrototype.wasAltered;
  30158. function makeStack(size, head, ownerID, hash) {
  30159. var map = Object.create(StackPrototype);
  30160. map.size = size;
  30161. map._head = head;
  30162. map.__ownerID = ownerID;
  30163. map.__hash = hash;
  30164. map.__altered = false;
  30165. return map;
  30166. }
  30167. var EMPTY_STACK;
  30168. function emptyStack() {
  30169. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  30170. }
  30171. /**
  30172. * Contributes additional methods to a constructor
  30173. */
  30174. function mixin(ctor, methods) {
  30175. var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
  30176. Object.keys(methods).forEach(keyCopier);
  30177. Object.getOwnPropertySymbols &&
  30178. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  30179. return ctor;
  30180. }
  30181. Iterable.Iterator = Iterator;
  30182. mixin(Iterable, {
  30183. // ### Conversion to other types
  30184. toArray: function() {
  30185. assertNotInfinite(this.size);
  30186. var array = new Array(this.size || 0);
  30187. this.valueSeq().__iterate(function(v, i) { array[i] = v; });
  30188. return array;
  30189. },
  30190. toIndexedSeq: function() {
  30191. return new ToIndexedSequence(this);
  30192. },
  30193. toJS: function() {
  30194. return this.toSeq().map(
  30195. function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
  30196. ).__toJS();
  30197. },
  30198. toJSON: function() {
  30199. return this.toSeq().map(
  30200. function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
  30201. ).__toJS();
  30202. },
  30203. toKeyedSeq: function() {
  30204. return new ToKeyedSequence(this, true);
  30205. },
  30206. toMap: function() {
  30207. // Use Late Binding here to solve the circular dependency.
  30208. return Map(this.toKeyedSeq());
  30209. },
  30210. toObject: function() {
  30211. assertNotInfinite(this.size);
  30212. var object = {};
  30213. this.__iterate(function(v, k) { object[k] = v; });
  30214. return object;
  30215. },
  30216. toOrderedMap: function() {
  30217. // Use Late Binding here to solve the circular dependency.
  30218. return OrderedMap(this.toKeyedSeq());
  30219. },
  30220. toOrderedSet: function() {
  30221. // Use Late Binding here to solve the circular dependency.
  30222. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  30223. },
  30224. toSet: function() {
  30225. // Use Late Binding here to solve the circular dependency.
  30226. return Set(isKeyed(this) ? this.valueSeq() : this);
  30227. },
  30228. toSetSeq: function() {
  30229. return new ToSetSequence(this);
  30230. },
  30231. toSeq: function() {
  30232. return isIndexed(this) ? this.toIndexedSeq() :
  30233. isKeyed(this) ? this.toKeyedSeq() :
  30234. this.toSetSeq();
  30235. },
  30236. toStack: function() {
  30237. // Use Late Binding here to solve the circular dependency.
  30238. return Stack(isKeyed(this) ? this.valueSeq() : this);
  30239. },
  30240. toList: function() {
  30241. // Use Late Binding here to solve the circular dependency.
  30242. return List(isKeyed(this) ? this.valueSeq() : this);
  30243. },
  30244. // ### Common JavaScript methods and properties
  30245. toString: function() {
  30246. return '[Iterable]';
  30247. },
  30248. __toString: function(head, tail) {
  30249. if (this.size === 0) {
  30250. return head + tail;
  30251. }
  30252. return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
  30253. },
  30254. // ### ES6 Collection methods (ES6 Array and Map)
  30255. concat: function() {var values = SLICE$0.call(arguments, 0);
  30256. return reify(this, concatFactory(this, values));
  30257. },
  30258. includes: function(searchValue) {
  30259. return this.some(function(value ) {return is(value, searchValue)});
  30260. },
  30261. entries: function() {
  30262. return this.__iterator(ITERATE_ENTRIES);
  30263. },
  30264. every: function(predicate, context) {
  30265. assertNotInfinite(this.size);
  30266. var returnValue = true;
  30267. this.__iterate(function(v, k, c) {
  30268. if (!predicate.call(context, v, k, c)) {
  30269. returnValue = false;
  30270. return false;
  30271. }
  30272. });
  30273. return returnValue;
  30274. },
  30275. filter: function(predicate, context) {
  30276. return reify(this, filterFactory(this, predicate, context, true));
  30277. },
  30278. find: function(predicate, context, notSetValue) {
  30279. var entry = this.findEntry(predicate, context);
  30280. return entry ? entry[1] : notSetValue;
  30281. },
  30282. findEntry: function(predicate, context) {
  30283. var found;
  30284. this.__iterate(function(v, k, c) {
  30285. if (predicate.call(context, v, k, c)) {
  30286. found = [k, v];
  30287. return false;
  30288. }
  30289. });
  30290. return found;
  30291. },
  30292. findLastEntry: function(predicate, context) {
  30293. return this.toSeq().reverse().findEntry(predicate, context);
  30294. },
  30295. forEach: function(sideEffect, context) {
  30296. assertNotInfinite(this.size);
  30297. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  30298. },
  30299. join: function(separator) {
  30300. assertNotInfinite(this.size);
  30301. separator = separator !== undefined ? '' + separator : ',';
  30302. var joined = '';
  30303. var isFirst = true;
  30304. this.__iterate(function(v ) {
  30305. isFirst ? (isFirst = false) : (joined += separator);
  30306. joined += v !== null && v !== undefined ? v.toString() : '';
  30307. });
  30308. return joined;
  30309. },
  30310. keys: function() {
  30311. return this.__iterator(ITERATE_KEYS);
  30312. },
  30313. map: function(mapper, context) {
  30314. return reify(this, mapFactory(this, mapper, context));
  30315. },
  30316. reduce: function(reducer, initialReduction, context) {
  30317. assertNotInfinite(this.size);
  30318. var reduction;
  30319. var useFirst;
  30320. if (arguments.length < 2) {
  30321. useFirst = true;
  30322. } else {
  30323. reduction = initialReduction;
  30324. }
  30325. this.__iterate(function(v, k, c) {
  30326. if (useFirst) {
  30327. useFirst = false;
  30328. reduction = v;
  30329. } else {
  30330. reduction = reducer.call(context, reduction, v, k, c);
  30331. }
  30332. });
  30333. return reduction;
  30334. },
  30335. reduceRight: function(reducer, initialReduction, context) {
  30336. var reversed = this.toKeyedSeq().reverse();
  30337. return reversed.reduce.apply(reversed, arguments);
  30338. },
  30339. reverse: function() {
  30340. return reify(this, reverseFactory(this, true));
  30341. },
  30342. slice: function(begin, end) {
  30343. return reify(this, sliceFactory(this, begin, end, true));
  30344. },
  30345. some: function(predicate, context) {
  30346. return !this.every(not(predicate), context);
  30347. },
  30348. sort: function(comparator) {
  30349. return reify(this, sortFactory(this, comparator));
  30350. },
  30351. values: function() {
  30352. return this.__iterator(ITERATE_VALUES);
  30353. },
  30354. // ### More sequential methods
  30355. butLast: function() {
  30356. return this.slice(0, -1);
  30357. },
  30358. isEmpty: function() {
  30359. return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
  30360. },
  30361. count: function(predicate, context) {
  30362. return ensureSize(
  30363. predicate ? this.toSeq().filter(predicate, context) : this
  30364. );
  30365. },
  30366. countBy: function(grouper, context) {
  30367. return countByFactory(this, grouper, context);
  30368. },
  30369. equals: function(other) {
  30370. return deepEqual(this, other);
  30371. },
  30372. entrySeq: function() {
  30373. var iterable = this;
  30374. if (iterable._cache) {
  30375. // We cache as an entries array, so we can just return the cache!
  30376. return new ArraySeq(iterable._cache);
  30377. }
  30378. var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
  30379. entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
  30380. return entriesSequence;
  30381. },
  30382. filterNot: function(predicate, context) {
  30383. return this.filter(not(predicate), context);
  30384. },
  30385. findLast: function(predicate, context, notSetValue) {
  30386. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  30387. },
  30388. first: function() {
  30389. return this.find(returnTrue);
  30390. },
  30391. flatMap: function(mapper, context) {
  30392. return reify(this, flatMapFactory(this, mapper, context));
  30393. },
  30394. flatten: function(depth) {
  30395. return reify(this, flattenFactory(this, depth, true));
  30396. },
  30397. fromEntrySeq: function() {
  30398. return new FromEntriesSequence(this);
  30399. },
  30400. get: function(searchKey, notSetValue) {
  30401. return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
  30402. },
  30403. getIn: function(searchKeyPath, notSetValue) {
  30404. var nested = this;
  30405. // Note: in an ES6 environment, we would prefer:
  30406. // for (var key of searchKeyPath) {
  30407. var iter = forceIterator(searchKeyPath);
  30408. var step;
  30409. while (!(step = iter.next()).done) {
  30410. var key = step.value;
  30411. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  30412. if (nested === NOT_SET) {
  30413. return notSetValue;
  30414. }
  30415. }
  30416. return nested;
  30417. },
  30418. groupBy: function(grouper, context) {
  30419. return groupByFactory(this, grouper, context);
  30420. },
  30421. has: function(searchKey) {
  30422. return this.get(searchKey, NOT_SET) !== NOT_SET;
  30423. },
  30424. hasIn: function(searchKeyPath) {
  30425. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  30426. },
  30427. isSubset: function(iter) {
  30428. iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
  30429. return this.every(function(value ) {return iter.includes(value)});
  30430. },
  30431. isSuperset: function(iter) {
  30432. iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
  30433. return iter.isSubset(this);
  30434. },
  30435. keySeq: function() {
  30436. return this.toSeq().map(keyMapper).toIndexedSeq();
  30437. },
  30438. last: function() {
  30439. return this.toSeq().reverse().first();
  30440. },
  30441. max: function(comparator) {
  30442. return maxFactory(this, comparator);
  30443. },
  30444. maxBy: function(mapper, comparator) {
  30445. return maxFactory(this, comparator, mapper);
  30446. },
  30447. min: function(comparator) {
  30448. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
  30449. },
  30450. minBy: function(mapper, comparator) {
  30451. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
  30452. },
  30453. rest: function() {
  30454. return this.slice(1);
  30455. },
  30456. skip: function(amount) {
  30457. return this.slice(Math.max(0, amount));
  30458. },
  30459. skipLast: function(amount) {
  30460. return reify(this, this.toSeq().reverse().skip(amount).reverse());
  30461. },
  30462. skipWhile: function(predicate, context) {
  30463. return reify(this, skipWhileFactory(this, predicate, context, true));
  30464. },
  30465. skipUntil: function(predicate, context) {
  30466. return this.skipWhile(not(predicate), context);
  30467. },
  30468. sortBy: function(mapper, comparator) {
  30469. return reify(this, sortFactory(this, comparator, mapper));
  30470. },
  30471. take: function(amount) {
  30472. return this.slice(0, Math.max(0, amount));
  30473. },
  30474. takeLast: function(amount) {
  30475. return reify(this, this.toSeq().reverse().take(amount).reverse());
  30476. },
  30477. takeWhile: function(predicate, context) {
  30478. return reify(this, takeWhileFactory(this, predicate, context));
  30479. },
  30480. takeUntil: function(predicate, context) {
  30481. return this.takeWhile(not(predicate), context);
  30482. },
  30483. valueSeq: function() {
  30484. return this.toIndexedSeq();
  30485. },
  30486. // ### Hashable Object
  30487. hashCode: function() {
  30488. return this.__hash || (this.__hash = hashIterable(this));
  30489. }
  30490. // ### Internal
  30491. // abstract __iterate(fn, reverse)
  30492. // abstract __iterator(type, reverse)
  30493. });
  30494. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  30495. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  30496. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  30497. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  30498. var IterablePrototype = Iterable.prototype;
  30499. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  30500. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  30501. IterablePrototype.__toJS = IterablePrototype.toArray;
  30502. IterablePrototype.__toStringMapper = quoteString;
  30503. IterablePrototype.inspect =
  30504. IterablePrototype.toSource = function() { return this.toString(); };
  30505. IterablePrototype.chain = IterablePrototype.flatMap;
  30506. IterablePrototype.contains = IterablePrototype.includes;
  30507. // Temporary warning about using length
  30508. (function () {
  30509. try {
  30510. Object.defineProperty(IterablePrototype, 'length', {
  30511. get: function () {
  30512. if (!Iterable.noLengthWarning) {
  30513. var stack;
  30514. try {
  30515. throw new Error();
  30516. } catch (error) {
  30517. stack = error.stack;
  30518. }
  30519. if (stack.indexOf('_wrapObject') === -1) {
  30520. console && console.warn && console.warn(
  30521. 'iterable.length has been deprecated, '+
  30522. 'use iterable.size or iterable.count(). '+
  30523. 'This warning will become a silent error in a future version. ' +
  30524. stack
  30525. );
  30526. return this.size;
  30527. }
  30528. }
  30529. }
  30530. });
  30531. } catch (e) {}
  30532. })();
  30533. mixin(KeyedIterable, {
  30534. // ### More sequential methods
  30535. flip: function() {
  30536. return reify(this, flipFactory(this));
  30537. },
  30538. findKey: function(predicate, context) {
  30539. var entry = this.findEntry(predicate, context);
  30540. return entry && entry[0];
  30541. },
  30542. findLastKey: function(predicate, context) {
  30543. return this.toSeq().reverse().findKey(predicate, context);
  30544. },
  30545. keyOf: function(searchValue) {
  30546. return this.findKey(function(value ) {return is(value, searchValue)});
  30547. },
  30548. lastKeyOf: function(searchValue) {
  30549. return this.findLastKey(function(value ) {return is(value, searchValue)});
  30550. },
  30551. mapEntries: function(mapper, context) {var this$0 = this;
  30552. var iterations = 0;
  30553. return reify(this,
  30554. this.toSeq().map(
  30555. function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
  30556. ).fromEntrySeq()
  30557. );
  30558. },
  30559. mapKeys: function(mapper, context) {var this$0 = this;
  30560. return reify(this,
  30561. this.toSeq().flip().map(
  30562. function(k, v) {return mapper.call(context, k, v, this$0)}
  30563. ).flip()
  30564. );
  30565. }
  30566. });
  30567. var KeyedIterablePrototype = KeyedIterable.prototype;
  30568. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  30569. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  30570. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  30571. KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
  30572. mixin(IndexedIterable, {
  30573. // ### Conversion to other types
  30574. toKeyedSeq: function() {
  30575. return new ToKeyedSequence(this, false);
  30576. },
  30577. // ### ES6 Collection methods (ES6 Array and Map)
  30578. filter: function(predicate, context) {
  30579. return reify(this, filterFactory(this, predicate, context, false));
  30580. },
  30581. findIndex: function(predicate, context) {
  30582. var entry = this.findEntry(predicate, context);
  30583. return entry ? entry[0] : -1;
  30584. },
  30585. indexOf: function(searchValue) {
  30586. var key = this.toKeyedSeq().keyOf(searchValue);
  30587. return key === undefined ? -1 : key;
  30588. },
  30589. lastIndexOf: function(searchValue) {
  30590. var key = this.toKeyedSeq().reverse().keyOf(searchValue);
  30591. return key === undefined ? -1 : key;
  30592. // var index =
  30593. // return this.toSeq().reverse().indexOf(searchValue);
  30594. },
  30595. reverse: function() {
  30596. return reify(this, reverseFactory(this, false));
  30597. },
  30598. slice: function(begin, end) {
  30599. return reify(this, sliceFactory(this, begin, end, false));
  30600. },
  30601. splice: function(index, removeNum /*, ...values*/) {
  30602. var numArgs = arguments.length;
  30603. removeNum = Math.max(removeNum | 0, 0);
  30604. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  30605. return this;
  30606. }
  30607. // If index is negative, it should resolve relative to the size of the
  30608. // collection. However size may be expensive to compute if not cached, so
  30609. // only call count() if the number is in fact negative.
  30610. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  30611. var spliced = this.slice(0, index);
  30612. return reify(
  30613. this,
  30614. numArgs === 1 ?
  30615. spliced :
  30616. spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  30617. );
  30618. },
  30619. // ### More collection methods
  30620. findLastIndex: function(predicate, context) {
  30621. var key = this.toKeyedSeq().findLastKey(predicate, context);
  30622. return key === undefined ? -1 : key;
  30623. },
  30624. first: function() {
  30625. return this.get(0);
  30626. },
  30627. flatten: function(depth) {
  30628. return reify(this, flattenFactory(this, depth, false));
  30629. },
  30630. get: function(index, notSetValue) {
  30631. index = wrapIndex(this, index);
  30632. return (index < 0 || (this.size === Infinity ||
  30633. (this.size !== undefined && index > this.size))) ?
  30634. notSetValue :
  30635. this.find(function(_, key) {return key === index}, undefined, notSetValue);
  30636. },
  30637. has: function(index) {
  30638. index = wrapIndex(this, index);
  30639. return index >= 0 && (this.size !== undefined ?
  30640. this.size === Infinity || index < this.size :
  30641. this.indexOf(index) !== -1
  30642. );
  30643. },
  30644. interpose: function(separator) {
  30645. return reify(this, interposeFactory(this, separator));
  30646. },
  30647. interleave: function(/*...iterables*/) {
  30648. var iterables = [this].concat(arrCopy(arguments));
  30649. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  30650. var interleaved = zipped.flatten(true);
  30651. if (zipped.size) {
  30652. interleaved.size = zipped.size * iterables.length;
  30653. }
  30654. return reify(this, interleaved);
  30655. },
  30656. last: function() {
  30657. return this.get(-1);
  30658. },
  30659. skipWhile: function(predicate, context) {
  30660. return reify(this, skipWhileFactory(this, predicate, context, false));
  30661. },
  30662. zip: function(/*, ...iterables */) {
  30663. var iterables = [this].concat(arrCopy(arguments));
  30664. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  30665. },
  30666. zipWith: function(zipper/*, ...iterables */) {
  30667. var iterables = arrCopy(arguments);
  30668. iterables[0] = this;
  30669. return reify(this, zipWithFactory(this, zipper, iterables));
  30670. }
  30671. });
  30672. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  30673. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  30674. mixin(SetIterable, {
  30675. // ### ES6 Collection methods (ES6 Array and Map)
  30676. get: function(value, notSetValue) {
  30677. return this.has(value) ? value : notSetValue;
  30678. },
  30679. includes: function(value) {
  30680. return this.has(value);
  30681. },
  30682. // ### More sequential methods
  30683. keySeq: function() {
  30684. return this.valueSeq();
  30685. }
  30686. });
  30687. SetIterable.prototype.has = IterablePrototype.includes;
  30688. // Mixin subclasses
  30689. mixin(KeyedSeq, KeyedIterable.prototype);
  30690. mixin(IndexedSeq, IndexedIterable.prototype);
  30691. mixin(SetSeq, SetIterable.prototype);
  30692. mixin(KeyedCollection, KeyedIterable.prototype);
  30693. mixin(IndexedCollection, IndexedIterable.prototype);
  30694. mixin(SetCollection, SetIterable.prototype);
  30695. // #pragma Helper functions
  30696. function keyMapper(v, k) {
  30697. return k;
  30698. }
  30699. function entryMapper(v, k) {
  30700. return [k, v];
  30701. }
  30702. function not(predicate) {
  30703. return function() {
  30704. return !predicate.apply(this, arguments);
  30705. }
  30706. }
  30707. function neg(predicate) {
  30708. return function() {
  30709. return -predicate.apply(this, arguments);
  30710. }
  30711. }
  30712. function quoteString(value) {
  30713. return typeof value === 'string' ? JSON.stringify(value) : value;
  30714. }
  30715. function defaultZipper() {
  30716. return arrCopy(arguments);
  30717. }
  30718. function defaultNegComparator(a, b) {
  30719. return a < b ? 1 : a > b ? -1 : 0;
  30720. }
  30721. function hashIterable(iterable) {
  30722. if (iterable.size === Infinity) {
  30723. return 0;
  30724. }
  30725. var ordered = isOrdered(iterable);
  30726. var keyed = isKeyed(iterable);
  30727. var h = ordered ? 1 : 0;
  30728. var size = iterable.__iterate(
  30729. keyed ?
  30730. ordered ?
  30731. function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
  30732. function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
  30733. ordered ?
  30734. function(v ) { h = 31 * h + hash(v) | 0; } :
  30735. function(v ) { h = h + hash(v) | 0; }
  30736. );
  30737. return murmurHashOfSize(size, h);
  30738. }
  30739. function murmurHashOfSize(size, h) {
  30740. h = imul(h, 0xCC9E2D51);
  30741. h = imul(h << 15 | h >>> -15, 0x1B873593);
  30742. h = imul(h << 13 | h >>> -13, 5);
  30743. h = (h + 0xE6546B64 | 0) ^ size;
  30744. h = imul(h ^ h >>> 16, 0x85EBCA6B);
  30745. h = imul(h ^ h >>> 13, 0xC2B2AE35);
  30746. h = smi(h ^ h >>> 16);
  30747. return h;
  30748. }
  30749. function hashMerge(a, b) {
  30750. return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
  30751. }
  30752. var Immutable = {
  30753. Iterable: Iterable,
  30754. Seq: Seq,
  30755. Collection: Collection,
  30756. Map: Map,
  30757. OrderedMap: OrderedMap,
  30758. List: List,
  30759. Stack: Stack,
  30760. Set: Set,
  30761. OrderedSet: OrderedSet,
  30762. Record: Record,
  30763. Range: Range,
  30764. Repeat: Repeat,
  30765. is: is,
  30766. fromJS: fromJS
  30767. };
  30768. return Immutable;
  30769. }));
  30770. });
  30771. var dist$2 = index.createCommonjsModule(function (module, exports) {
  30772. (function webpackUniversalModuleDefinition(root, factory) {
  30773. module.exports = factory(React__default);
  30774. })(window, function(__WEBPACK_EXTERNAL_MODULE__2__) {
  30775. return /******/ (function(modules) { // webpackBootstrap
  30776. /******/ // The module cache
  30777. /******/ var installedModules = {};
  30778. /******/
  30779. /******/ // The require function
  30780. /******/ function __webpack_require__(moduleId) {
  30781. /******/
  30782. /******/ // Check if module is in cache
  30783. /******/ if(installedModules[moduleId]) {
  30784. /******/ return installedModules[moduleId].exports;
  30785. /******/ }
  30786. /******/ // Create a new module (and put it into the cache)
  30787. /******/ var module = installedModules[moduleId] = {
  30788. /******/ i: moduleId,
  30789. /******/ l: false,
  30790. /******/ exports: {}
  30791. /******/ };
  30792. /******/
  30793. /******/ // Execute the module function
  30794. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  30795. /******/
  30796. /******/ // Flag the module as loaded
  30797. /******/ module.l = true;
  30798. /******/
  30799. /******/ // Return the exports of the module
  30800. /******/ return module.exports;
  30801. /******/ }
  30802. /******/
  30803. /******/
  30804. /******/ // expose the modules object (__webpack_modules__)
  30805. /******/ __webpack_require__.m = modules;
  30806. /******/
  30807. /******/ // expose the module cache
  30808. /******/ __webpack_require__.c = installedModules;
  30809. /******/
  30810. /******/ // define getter function for harmony exports
  30811. /******/ __webpack_require__.d = function(exports, name, getter) {
  30812. /******/ if(!__webpack_require__.o(exports, name)) {
  30813. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  30814. /******/ }
  30815. /******/ };
  30816. /******/
  30817. /******/ // define __esModule on exports
  30818. /******/ __webpack_require__.r = function(exports) {
  30819. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  30820. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  30821. /******/ }
  30822. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  30823. /******/ };
  30824. /******/
  30825. /******/ // create a fake namespace object
  30826. /******/ // mode & 1: value is a module id, require it
  30827. /******/ // mode & 2: merge all properties of value into the ns
  30828. /******/ // mode & 4: return value when already ns object
  30829. /******/ // mode & 8|1: behave like require
  30830. /******/ __webpack_require__.t = function(value, mode) {
  30831. /******/ if(mode & 1) value = __webpack_require__(value);
  30832. /******/ if(mode & 8) return value;
  30833. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  30834. /******/ var ns = Object.create(null);
  30835. /******/ __webpack_require__.r(ns);
  30836. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  30837. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  30838. /******/ return ns;
  30839. /******/ };
  30840. /******/
  30841. /******/ // getDefaultExport function for compatibility with non-harmony modules
  30842. /******/ __webpack_require__.n = function(module) {
  30843. /******/ var getter = module && module.__esModule ?
  30844. /******/ function getDefault() { return module['default']; } :
  30845. /******/ function getModuleExports() { return module; };
  30846. /******/ __webpack_require__.d(getter, 'a', getter);
  30847. /******/ return getter;
  30848. /******/ };
  30849. /******/
  30850. /******/ // Object.prototype.hasOwnProperty.call
  30851. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  30852. /******/
  30853. /******/ // __webpack_public_path__
  30854. /******/ __webpack_require__.p = "/";
  30855. /******/
  30856. /******/
  30857. /******/ // Load entry module and return exports
  30858. /******/ return __webpack_require__(__webpack_require__.s = 20);
  30859. /******/ })
  30860. /************************************************************************/
  30861. /******/ ([
  30862. /* 0 */
  30863. /***/ (function(module, exports, __webpack_require__) {
  30864. Object.defineProperty(exports, "__esModule", {
  30865. value: true
  30866. });
  30867. var compressImage = exports.compressImage = function compressImage(url) {
  30868. var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1280;
  30869. var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 800;
  30870. return new Promise(function (resolve, reject) {
  30871. var image = new Image();
  30872. image.src = url;
  30873. image.onerror = function (error) {
  30874. reject(error);
  30875. };
  30876. image.onload = function () {
  30877. try {
  30878. var compressCanvas = document.createElement('canvas');
  30879. var scale = this.width > width || this.height > height ? this.width > this.height ? width / this.width : height / this.height : 1;
  30880. compressCanvas.width = this.width * scale;
  30881. compressCanvas.height = this.height * scale;
  30882. var canvasContext = compressCanvas.getContext('2d');
  30883. canvasContext.drawImage(this, 0, 0, compressCanvas.width, compressCanvas.height);
  30884. resolve({
  30885. url: compressCanvas.toDataURL('image/png', 1),
  30886. width: compressCanvas.width,
  30887. height: compressCanvas.height
  30888. });
  30889. } catch (error) {
  30890. reject(error);
  30891. }
  30892. };
  30893. });
  30894. };
  30895. /***/ }),
  30896. /* 1 */
  30897. /***/ (function(module, exports, __webpack_require__) {
  30898. Object.defineProperty(exports, "__esModule", {
  30899. value: true
  30900. });
  30901. var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
  30902. if (isNaN(window.__BRAFT_MM_UNIQUE_INDEX__)) {
  30903. window.__BRAFT_MM_UNIQUE_INDEX__ = 1;
  30904. } else {
  30905. window.__BRAFT_MM_UNIQUE_INDEX__ += 1;
  30906. }
  30907. return window.__BRAFT_MM_UNIQUE_INDEX__;
  30908. };
  30909. /***/ }),
  30910. /* 2 */
  30911. /***/ (function(module, exports) {
  30912. module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
  30913. /***/ }),
  30914. /* 3 */
  30915. /***/ (function(module, exports, __webpack_require__) {
  30916. Object.defineProperty(exports, "__esModule", {
  30917. value: true
  30918. });
  30919. exports.default = {
  30920. remove: 'Kaldır',
  30921. cancel: 'İptal',
  30922. confirm: 'Onayla',
  30923. insert: 'Seçilenleri ekle',
  30924. width: 'Genişlik',
  30925. height: 'Yükseklik',
  30926. image: 'Resim',
  30927. video: 'Görüntü',
  30928. audio: 'Ses',
  30929. embed: 'Nesne göm',
  30930. caption: 'Kitaplık',
  30931. dragTip: 'Tıkla ya da dosya sürükle',
  30932. dropTip: 'Yüklemek için sürükleyin',
  30933. selectAll: 'Tümünü seç',
  30934. deselect: 'Seçimi kaldır',
  30935. removeSelected: 'Seçilenleri kaldır',
  30936. externalInputPlaceHolder: 'Kaynak adı|Kaynak bağlantısı',
  30937. externalInputTip: 'Kaynak asını ve bağlantısını "|" ile ayırın ve Enter\' a basın.',
  30938. addLocalFile: 'Yerel\' den ekle',
  30939. addExternalSource: 'Harici kaynaktan ekle',
  30940. unnamedItem: 'Adlandırılmamış giriş',
  30941. confirmInsert: 'Seçilenleri ekle'
  30942. };
  30943. /***/ }),
  30944. /* 4 */
  30945. /***/ (function(module, exports, __webpack_require__) {
  30946. Object.defineProperty(exports, "__esModule", {
  30947. value: true
  30948. });
  30949. exports.default = {
  30950. remove: '削除する',
  30951. cancel: 'キャンセル',
  30952. confirm: '確認する',
  30953. insert: '選択したアイテムを挿入',
  30954. width: '幅',
  30955. height: '身長',
  30956. image: '絵',
  30957. video: 'ビデオ',
  30958. audio: '音声',
  30959. embed: '埋め込みメディア',
  30960. caption: 'メディアライブラリー',
  30961. dragTip: 'ファイルをこの位置までクリックまたはドラッグします',
  30962. dropTip: 'アップロードするマウスを放します',
  30963. selectAll: 'すべて選択',
  30964. deselect: '選択を解除',
  30965. removeSelected: '選択したアイテムを削除',
  30966. externalInputPlaceHolder: 'リソース名|リソースアドレス',
  30967. externalInputTip: 'リソース名とリソースアドレスは "|"で区切ります。',
  30968. addLocalFile: 'ローカルリソースを追加する',
  30969. addExternalSource: 'ネットワークリソースを追加する',
  30970. unnamedItem: '名前のないアイテム',
  30971. confirmInsert: '選択したアイテムを挿入'
  30972. };
  30973. /***/ }),
  30974. /* 5 */
  30975. /***/ (function(module, exports, __webpack_require__) {
  30976. Object.defineProperty(exports, "__esModule", {
  30977. value: true
  30978. });
  30979. exports.default = {
  30980. remove: '삭제',
  30981. cancel: '취소',
  30982. confirm: '확인',
  30983. insert: '선택한항목삽입',
  30984. width: '너비',
  30985. height: '높이',
  30986. image: '그림',
  30987. video: '비디오',
  30988. audio: '오디오',
  30989. embed: '임베디드미디어',
  30990. caption: '미디어라이브러리',
  30991. dragTip: '파일을 클릭하거나이 지점으로 드래그하십시오.',
  30992. dropTip: '업로드하려면마우스를놓으십시오.',
  30993. selectAll: '모두 선택',
  30994. deselect: '선택 취소',
  30995. removeSelected: '선택한 항목 삭제',
  30996. externalInputPlaceHolder: '리소스 이름 | 리소스 주소',
  30997. externalInputTip: '자원 이름과 자원 주소를 "|"',
  30998. addLocalFile: '로컬 리소스 추가',
  30999. addExternalSource: '네트워크 리소스 추가',
  31000. unnamedItem: '이름없는 항목',
  31001. confirmInsert: '선택한 항목 삽입'
  31002. };
  31003. /***/ }),
  31004. /* 6 */
  31005. /***/ (function(module, exports, __webpack_require__) {
  31006. Object.defineProperty(exports, "__esModule", {
  31007. value: true
  31008. });
  31009. exports.default = {
  31010. remove: 'Usuń',
  31011. cancel: 'Anuluj',
  31012. confirm: 'Potwierdź',
  31013. insert: 'Wstaw wybrane elementy',
  31014. width: 'Szerokość',
  31015. height: 'Wysokość',
  31016. image: 'Obraz',
  31017. video: 'Wideo',
  31018. audio: 'Dźwięk',
  31019. embed: 'Obiekt',
  31020. caption: 'Biblioteka mediów',
  31021. dragTip: 'Kliknij lub przenieś tu pliki',
  31022. dropTip: 'Upuść aby dodać plik',
  31023. selectAll: 'Zaznacz wszystko',
  31024. deselect: 'Odznacz',
  31025. removeSelected: 'Usuń wybrane',
  31026. externalInputPlaceHolder: 'Nazwa źródła|Adres URL',
  31027. externalInputTip: 'Oddziel nazwę i adres URL źródła z pomocą "|", Potwierdź Enter-em',
  31028. addLocalFile: 'Dodaj z komputera',
  31029. addExternalSource: 'Dodaj z Internetu',
  31030. unnamedItem: 'Bez nazwy',
  31031. confirmInsert: 'Dodaj wybrane elementy'
  31032. };
  31033. /***/ }),
  31034. /* 7 */
  31035. /***/ (function(module, exports, __webpack_require__) {
  31036. Object.defineProperty(exports, "__esModule", {
  31037. value: true
  31038. });
  31039. exports.default = {
  31040. remove: '删除',
  31041. cancel: '取消',
  31042. confirm: '确认',
  31043. insert: '插入所选项目',
  31044. width: '宽度',
  31045. height: '高度',
  31046. image: '图片',
  31047. video: '视频',
  31048. audio: '音频',
  31049. embed: '嵌入式媒体',
  31050. caption: '媒体库',
  31051. dragTip: '点击或拖动文件至此',
  31052. dropTip: '放开鼠标以上传',
  31053. selectAll: '选择全部',
  31054. deselect: '取消选择',
  31055. removeSelected: '删除选中项目',
  31056. externalInputPlaceHolder: '资源名称|资源地址',
  31057. externalInputTip: '使用“|”分隔资源名称和资源地址',
  31058. addLocalFile: '添加本地资源',
  31059. addExternalSource: '添加网络资源',
  31060. unnamedItem: '未命名项目',
  31061. confirmInsert: '插入选中项目'
  31062. };
  31063. /***/ }),
  31064. /* 8 */
  31065. /***/ (function(module, exports, __webpack_require__) {
  31066. Object.defineProperty(exports, "__esModule", {
  31067. value: true
  31068. });
  31069. exports.default = {
  31070. remove: '删除',
  31071. cancel: '取消',
  31072. confirm: '确认',
  31073. insert: '插入所选项目',
  31074. width: '宽度',
  31075. height: '高度',
  31076. image: '图片',
  31077. video: '视频',
  31078. audio: '音频',
  31079. embed: '嵌入式媒体',
  31080. caption: '媒体库',
  31081. dragTip: '点击或拖动文件至此',
  31082. dropTip: '放开鼠标以上传',
  31083. selectAll: '选择全部',
  31084. deselect: '取消选择',
  31085. removeSelected: '删除选中项目',
  31086. externalInputPlaceHolder: '资源名称|资源地址',
  31087. externalInputTip: '使用“|”分隔资源名称和资源地址',
  31088. addLocalFile: '添加本地资源',
  31089. addExternalSource: '添加网络资源',
  31090. unnamedItem: '未命名项目',
  31091. confirmInsert: '插入选中项目'
  31092. };
  31093. /***/ }),
  31094. /* 9 */
  31095. /***/ (function(module, exports, __webpack_require__) {
  31096. Object.defineProperty(exports, "__esModule", {
  31097. value: true
  31098. });
  31099. exports.default = {
  31100. remove: 'Remove',
  31101. cancel: 'Cancel',
  31102. confirm: 'Confirm',
  31103. insert: 'Insert Selected Items',
  31104. width: 'Width',
  31105. height: 'Height',
  31106. image: 'Image',
  31107. video: 'Video',
  31108. audio: 'Audio',
  31109. embed: 'Embed',
  31110. caption: 'Media Library',
  31111. dragTip: 'Click Or Drag Files Here',
  31112. dropTip: 'Drop To Upload',
  31113. selectAll: 'Select All',
  31114. deselect: 'Deselect',
  31115. removeSelected: 'Remove Selected Items',
  31116. externalInputPlaceHolder: 'Source Name|Source URL',
  31117. externalInputTip: 'Split source name and source URL with "|", confirm by hit Enter.',
  31118. addLocalFile: 'Add from local',
  31119. addExternalSource: 'Add from Internet',
  31120. unnamedItem: 'Unnamed Item',
  31121. confirmInsert: 'Insert selected items'
  31122. };
  31123. /***/ }),
  31124. /* 10 */
  31125. /***/ (function(module, exports, __webpack_require__) {
  31126. Object.defineProperty(exports, "__esModule", {
  31127. value: true
  31128. });
  31129. var _en = __webpack_require__(9);
  31130. var _en2 = _interopRequireDefault(_en);
  31131. var _zh = __webpack_require__(8);
  31132. var _zh2 = _interopRequireDefault(_zh);
  31133. var _zhHant = __webpack_require__(7);
  31134. var _zhHant2 = _interopRequireDefault(_zhHant);
  31135. var _pl = __webpack_require__(6);
  31136. var _pl2 = _interopRequireDefault(_pl);
  31137. var _kr = __webpack_require__(5);
  31138. var _kr2 = _interopRequireDefault(_kr);
  31139. var _jpn = __webpack_require__(4);
  31140. var _jpn2 = _interopRequireDefault(_jpn);
  31141. var _tr = __webpack_require__(3);
  31142. var _tr2 = _interopRequireDefault(_tr);
  31143. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31144. exports.default = {
  31145. "en": _en2.default,
  31146. "zh": _zh2.default,
  31147. "zh-hant": _zhHant2.default,
  31148. "pl": _pl2.default,
  31149. "kr": _kr2.default,
  31150. "jpn": _jpn2.default,
  31151. "tr": _tr2.default
  31152. };
  31153. /***/ }),
  31154. /* 11 */
  31155. /***/ (function(module, exports) {
  31156. /**
  31157. * When source maps are enabled, `style-loader` uses a link element with a data-uri to
  31158. * embed the css on the page. This breaks all relative urls because now they are relative to a
  31159. * bundle instead of the current page.
  31160. *
  31161. * One solution is to only use full urls, but that may be impossible.
  31162. *
  31163. * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
  31164. *
  31165. * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
  31166. *
  31167. */
  31168. module.exports = function (css) {
  31169. // get current location
  31170. var location = typeof window !== "undefined" && window.location;
  31171. if (!location) {
  31172. throw new Error("fixUrls requires window.location");
  31173. }
  31174. // blank or null?
  31175. if (!css || typeof css !== "string") {
  31176. return css;
  31177. }
  31178. var baseUrl = location.protocol + "//" + location.host;
  31179. var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
  31180. // convert each url(...)
  31181. /*
  31182. This regular expression is just a way to recursively match brackets within
  31183. a string.
  31184. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
  31185. ( = Start a capturing group
  31186. (?: = Start a non-capturing group
  31187. [^)(] = Match anything that isn't a parentheses
  31188. | = OR
  31189. \( = Match a start parentheses
  31190. (?: = Start another non-capturing groups
  31191. [^)(]+ = Match anything that isn't a parentheses
  31192. | = OR
  31193. \( = Match a start parentheses
  31194. [^)(]* = Match anything that isn't a parentheses
  31195. \) = Match a end parentheses
  31196. ) = End Group
  31197. *\) = Match anything and then a close parens
  31198. ) = Close non-capturing group
  31199. * = Match anything
  31200. ) = Close capturing group
  31201. \) = Match a close parens
  31202. /gi = Get all matches, not the first. Be case insensitive.
  31203. */
  31204. var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
  31205. // strip quotes (if they exist)
  31206. var unquotedOrigUrl = origUrl
  31207. .trim()
  31208. .replace(/^"(.*)"$/, function(o, $1){ return $1; })
  31209. .replace(/^'(.*)'$/, function(o, $1){ return $1; });
  31210. // already a full url? no change
  31211. if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
  31212. return fullMatch;
  31213. }
  31214. // convert the url to a full url
  31215. var newUrl;
  31216. if (unquotedOrigUrl.indexOf("//") === 0) {
  31217. //TODO: should we add protocol?
  31218. newUrl = unquotedOrigUrl;
  31219. } else if (unquotedOrigUrl.indexOf("/") === 0) {
  31220. // path should be relative to the base url
  31221. newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
  31222. } else {
  31223. // path should be relative to current directory
  31224. newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
  31225. }
  31226. // send back the fixed url(...)
  31227. return "url(" + JSON.stringify(newUrl) + ")";
  31228. });
  31229. // send back the fixed css
  31230. return fixedCss;
  31231. };
  31232. /***/ }),
  31233. /* 12 */
  31234. /***/ (function(module, exports, __webpack_require__) {
  31235. /*
  31236. MIT License http://www.opensource.org/licenses/mit-license.php
  31237. Author Tobias Koppers @sokra
  31238. */
  31239. var stylesInDom = {};
  31240. var memoize = function (fn) {
  31241. var memo;
  31242. return function () {
  31243. if (typeof memo === "undefined") memo = fn.apply(this, arguments);
  31244. return memo;
  31245. };
  31246. };
  31247. var isOldIE = memoize(function () {
  31248. // Test for IE <= 9 as proposed by Browserhacks
  31249. // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
  31250. // Tests for existence of standard globals is to allow style-loader
  31251. // to operate correctly into non-standard environments
  31252. // @see https://github.com/webpack-contrib/style-loader/issues/177
  31253. return window && document && document.all && !window.atob;
  31254. });
  31255. var getTarget = function (target) {
  31256. return document.querySelector(target);
  31257. };
  31258. var getElement = (function (fn) {
  31259. var memo = {};
  31260. return function(target) {
  31261. // If passing function in options, then use it for resolve "head" element.
  31262. // Useful for Shadow Root style i.e
  31263. // {
  31264. // insertInto: function () { return document.querySelector("#foo").shadowRoot }
  31265. // }
  31266. if (typeof target === 'function') {
  31267. return target();
  31268. }
  31269. if (typeof memo[target] === "undefined") {
  31270. var styleTarget = getTarget.call(this, target);
  31271. // Special case to return head of iframe instead of iframe itself
  31272. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  31273. try {
  31274. // This will throw an exception if access to iframe is blocked
  31275. // due to cross-origin restrictions
  31276. styleTarget = styleTarget.contentDocument.head;
  31277. } catch(e) {
  31278. styleTarget = null;
  31279. }
  31280. }
  31281. memo[target] = styleTarget;
  31282. }
  31283. return memo[target]
  31284. };
  31285. })();
  31286. var singleton = null;
  31287. var singletonCounter = 0;
  31288. var stylesInsertedAtTop = [];
  31289. var fixUrls = __webpack_require__(11);
  31290. module.exports = function(list, options) {
  31291. if (typeof DEBUG !== "undefined" && DEBUG) {
  31292. if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
  31293. }
  31294. options = options || {};
  31295. options.attrs = typeof options.attrs === "object" ? options.attrs : {};
  31296. // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  31297. // tags it will allow on a page
  31298. if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();
  31299. // By default, add <style> tags to the <head> element
  31300. if (!options.insertInto) options.insertInto = "head";
  31301. // By default, add <style> tags to the bottom of the target
  31302. if (!options.insertAt) options.insertAt = "bottom";
  31303. var styles = listToStyles(list, options);
  31304. addStylesToDom(styles, options);
  31305. return function update (newList) {
  31306. var mayRemove = [];
  31307. for (var i = 0; i < styles.length; i++) {
  31308. var item = styles[i];
  31309. var domStyle = stylesInDom[item.id];
  31310. domStyle.refs--;
  31311. mayRemove.push(domStyle);
  31312. }
  31313. if(newList) {
  31314. var newStyles = listToStyles(newList, options);
  31315. addStylesToDom(newStyles, options);
  31316. }
  31317. for (var i = 0; i < mayRemove.length; i++) {
  31318. var domStyle = mayRemove[i];
  31319. if(domStyle.refs === 0) {
  31320. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
  31321. delete stylesInDom[domStyle.id];
  31322. }
  31323. }
  31324. };
  31325. };
  31326. function addStylesToDom (styles, options) {
  31327. for (var i = 0; i < styles.length; i++) {
  31328. var item = styles[i];
  31329. var domStyle = stylesInDom[item.id];
  31330. if(domStyle) {
  31331. domStyle.refs++;
  31332. for(var j = 0; j < domStyle.parts.length; j++) {
  31333. domStyle.parts[j](item.parts[j]);
  31334. }
  31335. for(; j < item.parts.length; j++) {
  31336. domStyle.parts.push(addStyle(item.parts[j], options));
  31337. }
  31338. } else {
  31339. var parts = [];
  31340. for(var j = 0; j < item.parts.length; j++) {
  31341. parts.push(addStyle(item.parts[j], options));
  31342. }
  31343. stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
  31344. }
  31345. }
  31346. }
  31347. function listToStyles (list, options) {
  31348. var styles = [];
  31349. var newStyles = {};
  31350. for (var i = 0; i < list.length; i++) {
  31351. var item = list[i];
  31352. var id = options.base ? item[0] + options.base : item[0];
  31353. var css = item[1];
  31354. var media = item[2];
  31355. var sourceMap = item[3];
  31356. var part = {css: css, media: media, sourceMap: sourceMap};
  31357. if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
  31358. else newStyles[id].parts.push(part);
  31359. }
  31360. return styles;
  31361. }
  31362. function insertStyleElement (options, style) {
  31363. var target = getElement(options.insertInto);
  31364. if (!target) {
  31365. throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
  31366. }
  31367. var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
  31368. if (options.insertAt === "top") {
  31369. if (!lastStyleElementInsertedAtTop) {
  31370. target.insertBefore(style, target.firstChild);
  31371. } else if (lastStyleElementInsertedAtTop.nextSibling) {
  31372. target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
  31373. } else {
  31374. target.appendChild(style);
  31375. }
  31376. stylesInsertedAtTop.push(style);
  31377. } else if (options.insertAt === "bottom") {
  31378. target.appendChild(style);
  31379. } else if (typeof options.insertAt === "object" && options.insertAt.before) {
  31380. var nextSibling = getElement(options.insertInto + " " + options.insertAt.before);
  31381. target.insertBefore(style, nextSibling);
  31382. } else {
  31383. throw new Error("[Style Loader]\n\n Invalid value for parameter 'insertAt' ('options.insertAt') found.\n Must be 'top', 'bottom', or Object.\n (https://github.com/webpack-contrib/style-loader#insertat)\n");
  31384. }
  31385. }
  31386. function removeStyleElement (style) {
  31387. if (style.parentNode === null) return false;
  31388. style.parentNode.removeChild(style);
  31389. var idx = stylesInsertedAtTop.indexOf(style);
  31390. if(idx >= 0) {
  31391. stylesInsertedAtTop.splice(idx, 1);
  31392. }
  31393. }
  31394. function createStyleElement (options) {
  31395. var style = document.createElement("style");
  31396. if(options.attrs.type === undefined) {
  31397. options.attrs.type = "text/css";
  31398. }
  31399. addAttrs(style, options.attrs);
  31400. insertStyleElement(options, style);
  31401. return style;
  31402. }
  31403. function createLinkElement (options) {
  31404. var link = document.createElement("link");
  31405. if(options.attrs.type === undefined) {
  31406. options.attrs.type = "text/css";
  31407. }
  31408. options.attrs.rel = "stylesheet";
  31409. addAttrs(link, options.attrs);
  31410. insertStyleElement(options, link);
  31411. return link;
  31412. }
  31413. function addAttrs (el, attrs) {
  31414. Object.keys(attrs).forEach(function (key) {
  31415. el.setAttribute(key, attrs[key]);
  31416. });
  31417. }
  31418. function addStyle (obj, options) {
  31419. var style, update, remove, result;
  31420. // If a transform function was defined, run it on the css
  31421. if (options.transform && obj.css) {
  31422. result = options.transform(obj.css);
  31423. if (result) {
  31424. // If transform returns a value, use that instead of the original css.
  31425. // This allows running runtime transformations on the css.
  31426. obj.css = result;
  31427. } else {
  31428. // If the transform function returns a falsy value, don't add this css.
  31429. // This allows conditional loading of css
  31430. return function() {
  31431. // noop
  31432. };
  31433. }
  31434. }
  31435. if (options.singleton) {
  31436. var styleIndex = singletonCounter++;
  31437. style = singleton || (singleton = createStyleElement(options));
  31438. update = applyToSingletonTag.bind(null, style, styleIndex, false);
  31439. remove = applyToSingletonTag.bind(null, style, styleIndex, true);
  31440. } else if (
  31441. obj.sourceMap &&
  31442. typeof URL === "function" &&
  31443. typeof URL.createObjectURL === "function" &&
  31444. typeof URL.revokeObjectURL === "function" &&
  31445. typeof Blob === "function" &&
  31446. typeof btoa === "function"
  31447. ) {
  31448. style = createLinkElement(options);
  31449. update = updateLink.bind(null, style, options);
  31450. remove = function () {
  31451. removeStyleElement(style);
  31452. if(style.href) URL.revokeObjectURL(style.href);
  31453. };
  31454. } else {
  31455. style = createStyleElement(options);
  31456. update = applyToTag.bind(null, style);
  31457. remove = function () {
  31458. removeStyleElement(style);
  31459. };
  31460. }
  31461. update(obj);
  31462. return function updateStyle (newObj) {
  31463. if (newObj) {
  31464. if (
  31465. newObj.css === obj.css &&
  31466. newObj.media === obj.media &&
  31467. newObj.sourceMap === obj.sourceMap
  31468. ) {
  31469. return;
  31470. }
  31471. update(obj = newObj);
  31472. } else {
  31473. remove();
  31474. }
  31475. };
  31476. }
  31477. var replaceText = (function () {
  31478. var textStore = [];
  31479. return function (index, replacement) {
  31480. textStore[index] = replacement;
  31481. return textStore.filter(Boolean).join('\n');
  31482. };
  31483. })();
  31484. function applyToSingletonTag (style, index, remove, obj) {
  31485. var css = remove ? "" : obj.css;
  31486. if (style.styleSheet) {
  31487. style.styleSheet.cssText = replaceText(index, css);
  31488. } else {
  31489. var cssNode = document.createTextNode(css);
  31490. var childNodes = style.childNodes;
  31491. if (childNodes[index]) style.removeChild(childNodes[index]);
  31492. if (childNodes.length) {
  31493. style.insertBefore(cssNode, childNodes[index]);
  31494. } else {
  31495. style.appendChild(cssNode);
  31496. }
  31497. }
  31498. }
  31499. function applyToTag (style, obj) {
  31500. var css = obj.css;
  31501. var media = obj.media;
  31502. if(media) {
  31503. style.setAttribute("media", media);
  31504. }
  31505. if(style.styleSheet) {
  31506. style.styleSheet.cssText = css;
  31507. } else {
  31508. while(style.firstChild) {
  31509. style.removeChild(style.firstChild);
  31510. }
  31511. style.appendChild(document.createTextNode(css));
  31512. }
  31513. }
  31514. function updateLink (link, options, obj) {
  31515. var css = obj.css;
  31516. var sourceMap = obj.sourceMap;
  31517. /*
  31518. If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
  31519. and there is no publicPath defined then lets turn convertToAbsoluteUrls
  31520. on by default. Otherwise default to the convertToAbsoluteUrls option
  31521. directly
  31522. */
  31523. var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
  31524. if (options.convertToAbsoluteUrls || autoFixUrls) {
  31525. css = fixUrls(css);
  31526. }
  31527. if (sourceMap) {
  31528. // http://stackoverflow.com/a/26603875
  31529. css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
  31530. }
  31531. var blob = new Blob([css], { type: "text/css" });
  31532. var oldSrc = link.href;
  31533. link.href = URL.createObjectURL(blob);
  31534. if(oldSrc) URL.revokeObjectURL(oldSrc);
  31535. }
  31536. /***/ }),
  31537. /* 13 */
  31538. /***/ (function(module, exports) {
  31539. module.exports = "data:font/ttf;base64,AAEAAAALAIAAAwAwT1MvMg8SBsIAAAC8AAAAYGNtYXBWNv1DAAABHAAAANRnYXNwAAAAEAAAAfAAAAAIZ2x5ZtZLKCQAAAH4AAAPTGhlYWQT25ZrAAARRAAAADZoaGVhB8ID3gAAEXwAAAAkaG10eGoAC+sAABGgAAAAdGxvY2EqcC3wAAASFAAAADxtYXhwACcAewAAElAAAAAgbmFtZZlKCfsAABJwAAABhnBvc3QAAwAAAAAT+AAAACAAAwPsAZAABQAAApkCzAAAAI8CmQLMAAAB6wAzAQkAAAAAAAAAAAAAAAAAAAABEAAAAAAAAAAAAAAAAAAAAABAAADprAPA/8AAQAPAAEAAAAABAAAAAAAAAAAAAAAgAAAAAAADAAAAAwAAABwAAQADAAAAHAADAAEAAAAcAAQAuAAAACoAIAAEAAoAAQAg4DTgN+BC4V3iQ+gN6Mno/ukD6QjpD+kT6RjpHOkm6YDprP/9//8AAAAAACDgNOA34ELhXeJD6A3oyej+6QHpB+kO6RHpFukc6SbpgOms//3//wAB/+Mf0B/OH8Qeqh3FF/wXQRcNFwsXCBcDFwIXABb9FvQWmxZwAAMAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAPAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAIBAACBAwAC1QADAAcAAAEzESMhETMRAlaqqv6qqgLV/awCVP2sAAABAVYAgQMqAtUAAgAACQIBVgHU/iwC1f7W/tYAAQCqACsDVgOBAC4AAAEyFx4BFxYVFAcOAQcGIyInLgEnJjUzFBceARcWMzI3PgE3NjU0Jy4BJyYjFSc3AgBGPz5dGxsbG10+PkdGPz5dGxtWFBRFLy81NS8vRRQUFBRFLy811tYC1RsbXD4+Rkc+Pl0bGxsbXT4+RzYuL0UUFBQURS8uNjUvLkYUFKzW1gAAAwBWAAEDqgNVABsANwA7AAAlMjc+ATc2NTQnLgEnJiMiBw4BBwYVFBceARcWEzIXHgEXFhUUBw4BBwYjIicuAScmNTQ3PgE3NgMhFSECAEY/Pl0bGxsbXT4+R0Y/Pl0bGxsbXT4+R1hOTnMiISEic05NWVhOTnMiISEic05NfQGs/lRVGxtdPj5HRj4/XRsbGxtdPz5GRz4+XRsbAwAiIXRNTlhZTU50ISEhIXROTVlYTk10ISL+gFQAAAABAKoAAQOAA1UAHwAAATMRIREUBisBIiY1ESE1IxUUBiMhIiY9ATQ2MyEyFhUDAID+qhgSVhIYAaoqGBL+ABIaGhICABIYAwH+qv6AEhgYEgHWqioSGhoSqhIYGBIAAAABAIAAAwOAA1UAMwAAJTIWFRQGIyImNTwBNyUOASMiJjU0NjMyFhclLgE1NDYzMhYVFAYjIiYnBR4BFRQGBwU+AQMAM0lJMzNJAv7SEiwaNExLNRktEgEsAQNLNTRMSzUZLRL+1AEDAgIBMBAs/UkzM0tLMwcPBrAREUs1NEwSEK4HDwg0TEw0NUsTEbAIDwcIDwewDxEAAAMAVgArA6oDVQACAAYAGgAALQI3FTM1FyERFAYjISImNREhNTQ2OwEyFhUBgAFA/sAqrFQBADAk/VQkMAEAMCSsJDCr1qrWVlZW/dYkMjIkAipWJDAwJAAEAIAAgQOAAtUAAwAHAAsADwAAEyEVIRU1IRUBNSEVJTUhFYADAP0AAwD9AAMA/QADAALVVKxWVv6sVFSqVlYABABVACIDqwN3AAQAIQA9AEIAACUzESMREyIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMRIicuAScmNTQ3PgE3NjMyFx4BFxYVFAcOAQcGAzM1IxUB1VZWK1hOTnQhIiIhdE5OWFhOTnQhIiIhdE5OWEc+Pl0aGxsaXT4+R0c+Pl0aGxsaXT4+clZW9wEA/wACgCEic05OWFlNTnQhIiIhdE5NWVhOTnMiIf0AGxtdPj5HRj8+XBsbGxtcPj9GRz4+XRsbAdZVVQAABABVACIDqwN3AAQAIQA9AFIAACUzNSMVEyIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMRIicuAScmNTQ3PgE3NjMyFx4BFxYVFAcOAQcGAyIGFTM0NjMyFhUUBhUzNDY1NCYjAdVWVitYTk50ISIiIXROTlhYTk50ISIiIXROTlhHPj5dGhsbGl0+PkdHPj5dGhsbGl0+PkdHZFYyIyMygFaAZEfNVVUCqiEic05OWFlNTnQhIiIhdE5NWVhOTnMiIf0AGxtdPj5HRj8+XBsbGxtcPj9GRz4+XRsbAlZkRyMyMiNALWhIPVBHZAAAAgBVAM0DqwLNAAUACwAAASc3JwkBJTcnNwkBAZHExDz/AAEAARrExDwBAP8AAQnExDz/AP8APMTEPP8A/wAAAAMAVQAiA6sDdwAcACsAOgAAASIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMBNDc+ATc2MzIWFwEuATUBIiYnAR4BFRQHDgEHBiMCAFhOTXQiIiIidE1OWFhOTXQiIiIidE1OWP6rGxtcPj9GOmot/iIjJQFVOmotAd4jJRsbXD4/RgN3ISJ0Tk1YWE5OdCEiIiF0Tk5YWE1OdCIh/lZGPj5dGxslI/4iLWo6/qomIwHeLWs5Rz4+XRsbAAAAAAMAgADNA4ACzQADAAcACwAANyE1ITUhNSE1FSE1gAMA/QADAP0AAwDNVYBV1lZWAAEAZAAlA1wDXABEAAABERQHBgcGBwYjIicmJyYnJjU0NzY3Njc2MzIXEQURFAcGBwYHBiMiJyYnJicmNTQ3Njc2NzYzMhcRNDc2NyU2MzIXFhUDXBERGhkaGRYXGRoZGhEREREaGRoZFzMr/oURERoZGhkXFhkaGRoRERERGhkaGRY0KwoJDwGbBggUDg4DLP3WGBQTCgsFBQUFCwoTFBgZExQKCwUFEwEKdv6iGRMTCwsFBQUFCwsTExkZExMLCgYFEwHeDw0MBX8CDg4UAAAEAHUAQgOJA1YALwA8AGIAeAAAAS4BBw4BJy4BJy4BBwYiJyYGBw4BJyYGBxQVHAEVFBUeATM2MzoBMzIzMjY3PAE1BSImNTQ2MzIWFRQGJyUqASM8ATU6ATMUFhUUFxwBFQYHFAYHDgEnLgE3PgE3OgEzPAE1BT4BNzoBMxQWBw4BJy4BNz4BNzoBMwKBARkZChUJCxcEFEMvBw8HHikMDCgdFyILCxgWNDM0ZzQzNBsaAf77L0FBMDBAQDEBtx8/IDRoNgEBAQENCxVFICIlBgc3JAcNCf7OAQICEyQTAwUFSiMmOAIBOiYHEAkCzhcaAQEBAwIJCC0fCAEBBhgbGxYGBBMVKCgpUCgoKQ8VARcaSpRK7T8uMEA/LzBAARchPyAKEgkzMjNmMjMzFCwRIBAOD0IjJjQDN2053QwUCi5dLSUsBgVEJig+BAAAAAAEAAAAAAQAA0AAGwAzAE8AUwAAARQXHgEXFjMyNz4BNzY1NCcuAScmIyIHDgEHBgEjLgEjISIGByMiBhURFBYzITI2NRE0JgEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYBIzUzATAQETgmJisrJiY4ERAQETgmJisrJiY4ERACkOAMJDD/ADAkDOAaJiYaA4AaJib+Jjs0M00XFhYXTTM0Ozs0M00XFhYXTTM0AYWAgAFgKyYmOBEQEBE4JiYrKyYmOBEQEBE4JiYBNTBQUDAmGv3AGiYmGgJAGib9hBYXTTM0Ozs0M00XFhYXTTM0Ozs0M00XFgG8QAABAJEAogOAAt4ABgAAAScHFwEnAQGAszzvAgA8/jwBGrM87wIAPP48AAAAAAEA4gCAAx4CyQAmAAABNzY0JyYiDwEnJiIHBhQfAQcGFBceATMyNj8BFx4BMzI2NzY0LwECPOINDQwkDOLiDCQMDQ3i4g0NBhAICBAG4uIGEAgIEAYNDeIBq+IMIw0MDOLiDAwNIwzi4g0jDAcGBgfh4QcGBgcMIw3iAAACAIAAYwNqA00AIgAvAAABIyc+ATU0Jy4BJyYjIgcOAQcGFRQXHgEXFjMyNjcXFRc3JyEiJjU0NjMyFhUUBiMClSEMHyQWFkszMjo5MzJLFhYWFksyMzk0XCUL1j/V/wBPcXFPUHBwUAF3DCRdMzoyM0sWFhYWSzMyOjkyM0sWFiQfDCLUP9VxT1BwcFBPcQACAGQAIgOcA3cATQBZAAABPgE1NCYnNz4BLwEuAQ8BLgEvAS4BKwEiBg8BDgEHJyYGDwEGFh8BDgEVFBYXBw4BHwEeAT8BHgEfAR4BOwEyNj8BPgE3FxY2PwE2JicFIiY1NDYzMhYVFAYDPQECAgFaBgMEVQQPB2oRJBQQAQwIqggMARAUJBFqBw8EVQQDBloBAgIBWgYDBFUEDwdqESQUEAEMCKoIDAEQFCQRagcPBFUEAwb+aT5XVz4+V1cBowoVCwsUC0YFDweUBwUDKgwVCHIHCgoHcggVDCoDBQeUBw8FRgsVCgsVCkYFEAeTBwUCKw0VCHEICgoIcQgVDSsDBgeTBxAFJlg+PldXPj5YAAEA1QCiAysC9wALAAABIREjESE1IREzESEDK/8AVv8AAQBWAQABov8AAQBVAQD/AAAAAAAJAAAAQAQAA0AAAwAHAAsADwATABcAGwAfACIAABMRIREBIzUzNSM1MzUjNTMBIREhEyM1MzUjNTM1IzUzBRElAAQA/MCAgICAgIACQP4AAgDAgICAgICA/cABAANA/QADAP1AgICAgID9gAKA/YCAgICAgID+gMAAAAAABgBA/8ADwAPAABkAIQA5AEcAVQBjAAABLgEnLgEnLgEjISIGFREUFjMhMjY1ETQmJyceARcjNR4BExQGIyEiJjURNDYzMDM6ATMyMRUUFjsBAyEiJjU0NjMhMhYVFAYnISImNTQ2MyEyFhUUBichIiY1NDYzITIWFRQGA5YRLRkaMxcnKQv+ECEvLyEC4CEvDhyFFyUNmhEphgkH/SAHCQkHTU66TU4TDeCg/kANExMNAcANExMN/kANExMNAcANExMN/kANExMNAcANExMC2xczGhktERwOLyH8oCEvLyECcAspJzYXKRGaDSX86AcJCQcDYAcJ4A0T/gATDQ0TEw0NE4ATDQ0TEw0NE4ATDQ0TEw0NEwAAAAcAAP/ABAADRgALABcAIwAvADsARwBTAAAlNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYlNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYlNDYzMhYVFAYjIiYBNDYzMhYVFAYjIiYBoDgoKDg4KCg4/mA4KCg4OCgoOANAOCgoODgoKDj9OjgoKDg4KCg4Akw4KCg4OCgoOP20OCgoODgoKDgCTDgoKDg4KCg4ICg4OCgoODgByCg4OCgoODgoKDg4KCg4OAFOKDg4KCg4OP3cKDg4KCg4OCgoODgoKDg4AnQoODgoKDg4AAUAfAAAA4QDVQAiAC0AOABGAFQAAAEjNTQmKwEiBh0BIyIGFRQWOwERFBYzITI2NREzMjY1NCYjJTQ2OwEyFh0BIzUBFAYjISImNREhEQEiBh0BFBYzMjY9ATQmMyIGHQEUFjMyNj0BNCYDXZtEMJwwRJsQFxcQJ0QwAYQwRCcQFxcQ/i8WEJwQFugBXRcQ/nwQFwHS/skQFhYQEBcXjBAXFxAQFhYCuicwREQwJxcQEBb+BzBERDAB+RYQEBcnEBcXECcn/ZMQFhYQAfn+BwGEFxDoEBcXEOgQFxcQ6BAXFxDoEBcAAAABAAAAAQAANAmLwV8PPPUACwQAAAAAANheKPcAAAAA2F4o9wAA/8AEAAPAAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAQAAAEAAAAAAAAAAAAAAAAAAAAdBAAAAAAAAAAAAAAAAgAAAAQAAQAEAAFWBAAAqgQAAFYEAACqBAAAgAQAAFYEAACABAAAVQQAAFUEAABVBAAAVQQAAIAEAABkBAAAdQQAAAAEAACRBAAA4gQAAIAEAABkBAAA1QQAAAAEAABABAAAAAQAAHwAAAAAAAoAFAAeADIAQACIAOYBFgFiAY4BrgIUAowCrAMMAyQDjAQ0BLIEyAUGBU4F1gXwBi4GugcyB6YAAQAAAB0AeQAJAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGljb21vb24AaQBjAG8AbQBvAG8AblZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGljb21vb24AaQBjAG8AbQBvAG8Abmljb21vb24AaQBjAG8AbQBvAG8AblJlZ3VsYXIAUgBlAGcAdQBsAGEAcmljb21vb24AaQBjAG8AbQBvAG8AbkZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";
  31540. /***/ }),
  31541. /* 14 */
  31542. /***/ (function(module, exports) {
  31543. /*
  31544. MIT License http://www.opensource.org/licenses/mit-license.php
  31545. Author Tobias Koppers @sokra
  31546. */
  31547. // css base code, injected by the css-loader
  31548. module.exports = function(useSourceMap) {
  31549. var list = [];
  31550. // return the list of modules as css string
  31551. list.toString = function toString() {
  31552. return this.map(function (item) {
  31553. var content = cssWithMappingToString(item, useSourceMap);
  31554. if(item[2]) {
  31555. return "@media " + item[2] + "{" + content + "}";
  31556. } else {
  31557. return content;
  31558. }
  31559. }).join("");
  31560. };
  31561. // import a list of modules into the list
  31562. list.i = function(modules, mediaQuery) {
  31563. if(typeof modules === "string")
  31564. modules = [[null, modules, ""]];
  31565. var alreadyImportedModules = {};
  31566. for(var i = 0; i < this.length; i++) {
  31567. var id = this[i][0];
  31568. if(typeof id === "number")
  31569. alreadyImportedModules[id] = true;
  31570. }
  31571. for(i = 0; i < modules.length; i++) {
  31572. var item = modules[i];
  31573. // skip already imported module
  31574. // this implementation is not 100% perfect for weird media query combinations
  31575. // when a module is imported multiple times with different media queries.
  31576. // I hope this will never occur (Hey this way we have smaller bundles)
  31577. if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
  31578. if(mediaQuery && !item[2]) {
  31579. item[2] = mediaQuery;
  31580. } else if(mediaQuery) {
  31581. item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
  31582. }
  31583. list.push(item);
  31584. }
  31585. }
  31586. };
  31587. return list;
  31588. };
  31589. function cssWithMappingToString(item, useSourceMap) {
  31590. var content = item[1] || '';
  31591. var cssMapping = item[3];
  31592. if (!cssMapping) {
  31593. return content;
  31594. }
  31595. if (useSourceMap && typeof btoa === 'function') {
  31596. var sourceMapping = toComment(cssMapping);
  31597. var sourceURLs = cssMapping.sources.map(function (source) {
  31598. return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
  31599. });
  31600. return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  31601. }
  31602. return [content].join('\n');
  31603. }
  31604. // Adapted from convert-source-map (MIT)
  31605. function toComment(sourceMap) {
  31606. // eslint-disable-next-line no-undef
  31607. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
  31608. var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
  31609. return '/*# ' + data + ' */';
  31610. }
  31611. /***/ }),
  31612. /* 15 */
  31613. /***/ (function(module, exports) {
  31614. module.exports = function escape(url) {
  31615. if (typeof url !== 'string') {
  31616. return url
  31617. }
  31618. // If url is already wrapped in quotes, remove them
  31619. if (/^['"].*['"]$/.test(url)) {
  31620. url = url.slice(1, -1);
  31621. }
  31622. // Should url be wrapped?
  31623. // See https://drafts.csswg.org/css-values-3/#urls
  31624. if (/["'() \t\n]/.test(url)) {
  31625. return '"' + url.replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"'
  31626. }
  31627. return url
  31628. };
  31629. /***/ }),
  31630. /* 16 */
  31631. /***/ (function(module, exports, __webpack_require__) {
  31632. var escape = __webpack_require__(15);
  31633. exports = module.exports = __webpack_require__(14)(false);
  31634. // imports
  31635. // module
  31636. exports.push([module.i, "@font-face {\n font-family: 'bf-icons';\n src: url(" + escape(__webpack_require__(13)) + ") format(\"truetype\");\n font-weight: normal;\n font-style: normal; }\n\n.braft-finder [class^=\"braft-icon-\"], .braft-finder [class*=\" braft-icon-\"] {\n /* use !important to prevent issues with browser extensions that change fonts */\n font-family: 'bf-icons' !important;\n font-style: normal;\n font-weight: normal;\n font-variant: normal;\n text-transform: none;\n /* Better Font Rendering =========== */\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale; }\n\n.braft-finder .braft-icon-code:before {\n content: \"\\E903\"; }\n\n.braft-finder .braft-icon-pause:before {\n content: \"\\E034\"; }\n\n.braft-finder .braft-icon-play_arrow:before {\n content: \"\\E037\"; }\n\n.braft-finder .braft-icon-bin:before {\n content: \"\\E9AC\"; }\n\n.braft-finder .braft-icon-replay:before {\n content: \"\\E042\"; }\n\n.braft-finder .braft-icon-close:before {\n content: \"\\E913\"; }\n\n.braft-finder .braft-icon-music:before {\n content: \"\\E90E\"; }\n\n.braft-finder .braft-icon-camera:before {\n content: \"\\E911\"; }\n\n.braft-finder .braft-icon-file-text:before {\n content: \"\\E926\"; }\n\n.braft-finder .braft-icon-film:before {\n content: \"\\E91C\"; }\n\n.braft-finder .braft-icon-paste:before {\n content: \"\\E92D\"; }\n\n.braft-finder .braft-icon-spinner:before {\n content: \"\\E980\"; }\n\n.braft-finder .braft-icon-media:before {\n content: \"\\E90F\"; }\n\n.braft-finder .braft-icon-add:before {\n content: \"\\E918\"; }\n\n.braft-finder .braft-icon-done:before {\n content: \"\\E912\"; }\n\n.braft-finder .braft-icon-drop-down:before {\n content: \"\\E906\"; }\n\n.braft-finder .braft-icon-drop-up:before {\n content: \"\\E909\"; }\n\n.braft-finder .braft-icon-help:before {\n content: \"\\E902\"; }\n\n.braft-finder .braft-icon-info:before {\n content: \"\\E901\"; }\n\n.braft-finder .braft-icon-menu:before {\n content: \"\\E908\"; }\n\n.pull-left {\n float: left; }\n\n.pull-right {\n float: right; }\n\n.braft-finder .bf-uploader {\n position: relative;\n height: 370px;\n margin: 0; }\n .braft-finder .bf-uploader.draging .bf-list-wrap,\n .braft-finder .bf-uploader.draging .bf-add-external {\n pointer-events: none; }\n .braft-finder .bf-uploader input::-webkit-input-placeholder {\n color: #ccc; }\n .braft-finder .bf-uploader input::-moz-placeholder {\n color: #ccc; }\n .braft-finder .bf-uploader input::-ms-input-placeholder {\n color: #ccc; }\n\n.braft-finder .bf-list-wrap {\n position: relative;\n height: 370px; }\n\n.braft-finder .bf-list-tools {\n z-index: 1;\n position: absolute;\n top: 0;\n right: 0;\n left: 0;\n height: 20px;\n padding: 0 15px;\n background-color: #fff; }\n .braft-finder .bf-list-tools span {\n height: 26px;\n font-size: 12px;\n line-height: 20px;\n cursor: pointer;\n user-select: none; }\n .braft-finder .bf-list-tools span[disabled] {\n opacity: .3;\n pointer-events: none; }\n .braft-finder .bf-list-tools .bf-select-all,\n .braft-finder .bf-list-tools .bf-deselect-all {\n float: left;\n margin-right: 5px;\n color: #bbb; }\n .braft-finder .bf-list-tools .bf-select-all:hover,\n .braft-finder .bf-list-tools .bf-deselect-all:hover {\n color: #3498db; }\n .braft-finder .bf-list-tools .bf-remove-selected {\n float: right;\n color: #e74c3c; }\n .braft-finder .bf-list-tools .bf-remove-selected:hover {\n color: #c92e1e; }\n\n.braft-finder .bf-list {\n position: absolute;\n z-index: 1;\n top: 30px;\n right: 0;\n left: 0;\n bottom: 0;\n margin: 0;\n padding: 0 10px;\n list-style: none;\n overflow: auto; }\n .braft-finder .bf-list::-webkit-scrollbar {\n width: 5px;\n height: 5px;\n background-color: #fff; }\n .braft-finder .bf-list::-webkit-scrollbar-track {\n background-color: #fff; }\n .braft-finder .bf-list::-webkit-scrollbar-thumb {\n background-color: rgba(0, 0, 0, 0.1); }\n\n.braft-finder .bf-item,\n.braft-finder .bf-add-item {\n position: relative;\n display: block;\n float: left;\n width: 113px;\n height: 113px;\n margin: 5px;\n overflow: hidden;\n border-radius: 3px; }\n\n.braft-finder .bf-item.uploading {\n pointer-events: none; }\n\n.braft-finder .bf-item.error::before {\n display: block;\n content: \"\\E901\"; }\n\n.braft-finder .bf-item.error::after {\n position: absolute;\n z-index: 1;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(231, 76, 60, 0.8);\n content: ''; }\n\n.braft-finder .bf-item.error:hover::after {\n background-color: rgba(231, 76, 60, 0.9); }\n\n.braft-finder .bf-item.error .bf-item-uploading {\n display: none; }\n\n.braft-finder .bf-add-item {\n background-color: #ecedef;\n color: #999; }\n .braft-finder .bf-add-item:hover {\n background-color: #e1e2e3; }\n .braft-finder .bf-add-item i {\n display: block;\n width: 113px;\n height: 113px;\n font-size: 48px;\n line-height: 113px;\n text-align: center; }\n .braft-finder .bf-add-item input {\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n opacity: 0;\n cursor: pointer; }\n\n.braft-finder .bf-item::before {\n display: none;\n position: absolute;\n z-index: 2;\n top: 0;\n left: 0;\n width: 113px;\n height: 113px;\n color: #fff;\n font-size: 48px;\n font-family: 'bf-icons';\n line-height: 113px;\n text-align: center; }\n\n.braft-finder .bf-item::after {\n position: absolute;\n z-index: 1;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: rgba(52, 152, 219, 0);\n content: ''; }\n\n.braft-finder .bf-item:hover::after {\n background-color: rgba(52, 152, 219, 0.3); }\n\n.braft-finder .bf-item:hover .bf-item-remove {\n display: block; }\n\n.braft-finder .bf-item.active::before {\n display: block;\n content: \"\\E912\"; }\n\n.braft-finder .bf-item.active::after {\n background-color: rgba(52, 152, 219, 0.6); }\n\n.braft-finder .bf-item.active:hover::after {\n background-color: rgba(52, 152, 219, 0.8); }\n\n.braft-finder .bf-item.active:hover .bf-item-remove {\n display: none; }\n\n.braft-finder .bf-item-uploading {\n box-sizing: border-box;\n position: absolute;\n z-index: 3;\n top: 52px;\n left: 10px;\n width: 93px;\n height: 10px;\n overflow: hidden;\n background-color: rgba(255, 255, 255, 0.3);\n border-radius: 5px;\n box-shadow: 0 0 0 100px rgba(0, 0, 0, 0.5); }\n\n.braft-finder .bf-item-uploading-bar {\n height: 10px;\n background-color: #3498db;\n border-radius: 0; }\n\n.braft-finder .bf-item-remove {\n display: none;\n position: absolute;\n z-index: 2;\n top: 0;\n right: 0;\n width: 28px;\n height: 28px;\n color: #fff;\n font-size: 18px;\n line-height: 28px;\n text-align: center;\n cursor: pointer; }\n .braft-finder .bf-item-remove:hover {\n color: #e74c3c; }\n\n.braft-finder .bf-item-title {\n display: none;\n box-sizing: border-box;\n position: absolute;\n z-index: 2;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 40px;\n padding: 0 5px;\n overflow: hidden;\n background-image: linear-gradient(rgba(0, 0, 0, 0), black);\n color: #fff;\n font-size: 12px;\n line-height: 55px;\n text-align: center;\n text-overflow: ellipsis;\n white-space: nowrap; }\n\n.braft-finder .bf-image {\n width: 100%;\n height: 100%;\n background-color: #eee;\n user-select: none; }\n .braft-finder .bf-image img {\n display: block;\n width: 100%;\n height: 100%;\n object-fit: cover; }\n\n.braft-finder .bf-video {\n background-color: #8e44ad; }\n\n.braft-finder .bf-audio {\n background-color: #f39c12; }\n\n.braft-finder .bf-embed {\n background-color: #f1c40f; }\n\n.braft-finder .bf-icon {\n display: block;\n width: 113px;\n height: 113px;\n overflow: hidden;\n color: #fff;\n text-align: center;\n text-decoration: none; }\n .braft-finder .bf-icon i, .braft-finder .bf-icon span {\n display: block; }\n .braft-finder .bf-icon i {\n margin-top: 35px;\n font-size: 24px; }\n .braft-finder .bf-icon span {\n width: 103px;\n margin: 10px auto;\n overflow: hidden;\n font-size: 12px;\n text-overflow: ellipsis;\n white-space: nowrap; }\n\n.braft-finder .bf-drag-uploader {\n box-sizing: border-box;\n position: absolute;\n z-index: 2;\n top: 0;\n right: 15px;\n left: 15px;\n height: 100%;\n background-color: #fff;\n border: dashed 1px #bbb;\n text-align: center;\n opacity: 0;\n pointer-events: none; }\n .braft-finder .bf-drag-uploader:hover, .braft-finder .bf-drag-uploader.draging {\n background-color: #f1f2f3; }\n .braft-finder .bf-drag-uploader.active {\n opacity: 1;\n pointer-events: auto; }\n\n.braft-finder .bf-uploader-buttons {\n height: 370px;\n margin: auto;\n text-align: center; }\n\n.braft-finder .bf-drag-tip {\n display: inline-block;\n margin-top: 150px;\n color: #ccc;\n text-align: center;\n font-size: 28px;\n font-weight: normal;\n line-height: 40px; }\n .braft-finder .bf-drag-tip input {\n position: absolute;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n width: 100%;\n height: 100%;\n opacity: 0;\n color: #fff;\n text-indent: -100px;\n cursor: pointer; }\n\n.braft-finder .bf-manager-footer {\n height: 36px;\n margin: 10px 0;\n padding: 0 15px; }\n .braft-finder .bf-manager-footer .button {\n float: right;\n height: 36px;\n margin-left: 5px;\n padding: 0 35px;\n font-size: 12px;\n font-weight: 700;\n border: none;\n border-radius: 3px;\n cursor: pointer; }\n .braft-finder .bf-manager-footer .button-insert {\n color: #fff;\n background-color: #3498db; }\n .braft-finder .bf-manager-footer .button-insert:hover {\n background-color: #2084c7; }\n .braft-finder .bf-manager-footer .button-insert[disabled] {\n opacity: .3;\n pointer-events: none;\n filter: grayscale(0.4); }\n .braft-finder .bf-manager-footer .button-cancel {\n color: #999;\n background-color: #e8e8e9; }\n .braft-finder .bf-manager-footer .button-cancel:hover {\n background-color: #d8d8d9; }\n\n.braft-finder .bf-toggle-external-form {\n color: #666;\n font-size: 12px;\n line-height: 36px; }\n .braft-finder .bf-toggle-external-form span {\n color: #bbb;\n line-height: 16px;\n cursor: pointer;\n user-select: none; }\n .braft-finder .bf-toggle-external-form span:hover {\n color: #3498db; }\n .braft-finder .bf-toggle-external-form span i {\n position: relative;\n top: 2px;\n font-size: 16px; }\n\n.braft-finder .bf-add-external {\n position: absolute;\n z-index: 3;\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n background-color: #fff; }\n .braft-finder .bf-add-external input {\n border: solid 1px rgba(0, 0, 0, 0.3);\n border: solid 0.5px rgba(0, 0, 0, 0.3);\n box-shadow: none; }\n .braft-finder .bf-add-external input:focus {\n border-color: #3498db;\n box-shadow: none; }\n\n.braft-finder .bf-external-form {\n width: 500px;\n max-width: 90%;\n margin: 91px auto 0 auto; }\n\n.braft-finder .bf-external-input {\n position: relative;\n width: 100%;\n height: 40px;\n margin-bottom: 10px; }\n .braft-finder .bf-external-input div {\n position: absolute;\n top: 0;\n right: 85px;\n left: 0;\n height: 40px; }\n .braft-finder .bf-external-input input,\n .braft-finder .bf-external-input textarea {\n display: block;\n box-sizing: border-box;\n width: 100%;\n height: 40px;\n padding: 0 10px;\n border: none;\n border-radius: 3px;\n outline: none;\n box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.3);\n color: #999;\n font-size: 18px; }\n .braft-finder .bf-external-input input:focus,\n .braft-finder .bf-external-input textarea:focus {\n box-shadow: inset 0 0 0 1px #3498db; }\n .braft-finder .bf-external-input textarea {\n height: 100px;\n font-size: 14px; }\n .braft-finder .bf-external-input button {\n position: absolute;\n top: 0;\n right: 0;\n width: 80px;\n height: 40px;\n background-color: #3498db;\n border: none;\n border-radius: 3px;\n color: #fff;\n font-size: 14px;\n font-weight: bold;\n cursor: pointer; }\n .braft-finder .bf-external-input button:disabled {\n opacity: .3;\n pointer-events: none;\n filter: grayscale(0.4); }\n .braft-finder .bf-external-input button:hover {\n background-color: #2084c7; }\n\n.braft-finder .bf-switch-external-type {\n overflow: hidden;\n text-align: center; }\n .braft-finder .bf-switch-external-type button {\n width: auto;\n height: 30px;\n margin: 10px 5px;\n padding: 0 10px;\n background-color: #e8e9ea;\n border: none;\n border-radius: 3px;\n color: #999;\n font-size: 12px;\n cursor: pointer; }\n .braft-finder .bf-switch-external-type button:hover {\n background-color: #d8d9da; }\n .braft-finder .bf-switch-external-type button:only-child {\n display: none; }\n .braft-finder .bf-switch-external-type[data-type=\"IMAGE\"] [data-type=\"IMAGE\"],\n .braft-finder .bf-switch-external-type[data-type=\"VIDEO\"] [data-type=\"VIDEO\"],\n .braft-finder .bf-switch-external-type[data-type=\"AUDIO\"] [data-type=\"AUDIO\"],\n .braft-finder .bf-switch-external-type[data-type=\"EMBED\"] [data-type=\"EMBED\"],\n .braft-finder .bf-switch-external-type[data-type=\"FILE\"] [data-type=\"FILE\"] {\n background-color: #3498db;\n color: #fff; }\n\n.braft-finder .bf-external-tip {\n display: block;\n margin-top: 15px;\n color: #ccc;\n font-size: 12px;\n text-align: center; }\n", ""]);
  31637. // exports
  31638. /***/ }),
  31639. /* 17 */
  31640. /***/ (function(module, exports, __webpack_require__) {
  31641. var content = __webpack_require__(16);
  31642. if(typeof content === 'string') content = [[module.i, content, '']];
  31643. var transform;
  31644. var options = {"hmr":true};
  31645. options.transform = transform;
  31646. options.insertInto = undefined;
  31647. var update = __webpack_require__(12)(content, options);
  31648. if(content.locals) module.exports = content.locals;
  31649. /***/ }),
  31650. /* 18 */
  31651. /***/ (function(module, exports, __webpack_require__) {
  31652. Object.defineProperty(exports, "__esModule", {
  31653. value: true
  31654. });
  31655. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  31656. var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
  31657. __webpack_require__(17);
  31658. var _react = __webpack_require__(2);
  31659. var _react2 = _interopRequireDefault(_react);
  31660. var _base = __webpack_require__(1);
  31661. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  31662. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  31663. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  31664. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  31665. var defaultAccepts = {
  31666. image: 'image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg',
  31667. video: 'video/mp4',
  31668. audio: 'audio/mp3'
  31669. };
  31670. var BraftFinderView = function (_React$Component) {
  31671. _inherits(BraftFinderView, _React$Component);
  31672. function BraftFinderView(props) {
  31673. _classCallCheck(this, BraftFinderView);
  31674. var _this = _possibleConstructorReturn(this, (BraftFinderView.__proto__ || Object.getPrototypeOf(BraftFinderView)).call(this, props));
  31675. _this.toggleSelectItem = function (event) {
  31676. var itemId = event.currentTarget.dataset.id;
  31677. var item = _this.controller.getMediaItem(itemId);
  31678. if (!item) {
  31679. return false;
  31680. }
  31681. if (item.selected) {
  31682. if (!_this.props.onBeforeDeselect || _this.props.onBeforeDeselect([item], _this.controller.getItems()) !== false) {
  31683. _this.controller.deselectMediaItem(itemId);
  31684. _this.props.onDeselect && _this.props.onDeselect([item], _this.controller.getItems());
  31685. }
  31686. } else {
  31687. if (!_this.props.onBeforeSelect || _this.props.onBeforeSelect([item], _this.controller.getItems()) !== false) {
  31688. _this.controller.selectMediaItem(itemId);
  31689. _this.props.onSelect && _this.props.onSelect([item], _this.controller.getItems());
  31690. }
  31691. }
  31692. };
  31693. _this.removeItem = function (event) {
  31694. var itemId = event.currentTarget.dataset.id;
  31695. var item = _this.controller.getMediaItem(itemId);
  31696. if (!item) {
  31697. return false;
  31698. }
  31699. if (!_this.props.onBeforeRemove || _this.props.onBeforeRemove([item], _this.controller.getItems()) !== false) {
  31700. _this.controller.removeMediaItem(itemId);
  31701. _this.props.onRemove && _this.props.onRemove([item], _this.controller.getItems());
  31702. }
  31703. event.stopPropagation();
  31704. };
  31705. _this.selectAllItems = function () {
  31706. var allItems = _this.controller.getItems();
  31707. if (!_this.props.onBeforeSelect || _this.props.onBeforeSelect(allItems, allItems) !== false) {
  31708. _this.controller.selectAllItems();
  31709. _this.props.onSelect && _this.props.onSelect(allItems, allItems);
  31710. }
  31711. };
  31712. _this.deselectAllItems = function () {
  31713. var allItems = _this.controller.getItems();
  31714. if (!_this.props.onBeforeDeselect || _this.props.onBeforeDeselect(allItems, allItems) !== false) {
  31715. _this.controller.deselectAllItems();
  31716. _this.props.onDeselect && _this.props.onDeselect(allItems, allItems);
  31717. }
  31718. };
  31719. _this.removeSelectedItems = function () {
  31720. var selectedItems = _this.controller.getSelectedItems();
  31721. if (!_this.props.onBeforeRemove || _this.props.onBeforeRemove(selectedItems, _this.controller.getItems()) !== false) {
  31722. _this.controller.removeSelectedItems();
  31723. _this.props.onRemove && _this.props.onRemove(selectedItems, _this.controller.getItems());
  31724. }
  31725. };
  31726. _this.handleDragLeave = function (event) {
  31727. event.preventDefault();
  31728. _this.dragCounter--;
  31729. _this.dragCounter === 0 && _this.setState({
  31730. draging: false
  31731. });
  31732. };
  31733. _this.handleDragDrop = function (event) {
  31734. event.preventDefault();
  31735. _this.dragCounter = 0;
  31736. _this.setState({ draging: false });
  31737. _this.reslovePickedFiles(event);
  31738. };
  31739. _this.handleDragEnter = function (event) {
  31740. event.preventDefault();
  31741. _this.dragCounter++;
  31742. _this.setState({ draging: true });
  31743. };
  31744. _this.reslovePickedFiles = function (event) {
  31745. event.persist();
  31746. var _ref = event.type === 'drop' ? event.dataTransfer : event.target,
  31747. files = _ref.files;
  31748. if (_this.props.onFileSelect) {
  31749. var result = _this.props.onFileSelect(files);
  31750. if (result === false) {
  31751. return false;
  31752. } else if (result instanceof FileList || result instanceof Array) {
  31753. files = result;
  31754. }
  31755. }
  31756. var accepts = _extends({}, defaultAccepts, _this.props.accepts);
  31757. _this.controller.resolveFiles({
  31758. files: files,
  31759. onItemReady: function onItemReady(_ref2) {
  31760. var id = _ref2.id;
  31761. return _this.controller.selectMediaItem(id);
  31762. },
  31763. onAllReady: function onAllReady() {
  31764. return event.target.value = null;
  31765. }
  31766. }, 0, accepts);
  31767. };
  31768. _this.inputExternal = function (event) {
  31769. _this.setState({
  31770. external: _extends({}, _this.state.external, {
  31771. url: event.target.value
  31772. })
  31773. });
  31774. };
  31775. _this.switchExternalType = function (event) {
  31776. _this.setState({
  31777. external: _extends({}, _this.state.external, { type: event.target.dataset.type })
  31778. });
  31779. };
  31780. _this.confirmAddExternal = function (event) {
  31781. if (event.target.nodeName.toLowerCase() === 'button' || event.keyCode === 13) {
  31782. var _this$state$external = _this.state.external,
  31783. url = _this$state$external.url,
  31784. type = _this$state$external.type;
  31785. url = url.split('|');
  31786. var name = url.length > 1 ? url[0] : _this.props.language.unnamedItem;
  31787. url = url.length > 1 ? url[1] : url[0];
  31788. var thumbnail = type === 'IMAGE' ? url : null;
  31789. _this.controller.addItems([{
  31790. thumbnail: thumbnail, url: url, name: name, type: type,
  31791. id: new Date().getTime() + '_' + (0, _base.UniqueIndex)(),
  31792. uploading: false,
  31793. uploadProgress: 1,
  31794. selected: true
  31795. }]);
  31796. _this.setState({
  31797. showExternalForm: false,
  31798. external: {
  31799. url: '',
  31800. type: 'IMAGE'
  31801. }
  31802. });
  31803. }
  31804. };
  31805. _this.toggleExternalForm = function () {
  31806. _this.setState({
  31807. showExternalForm: !_this.state.showExternalForm
  31808. });
  31809. };
  31810. _this.cancelInsert = function () {
  31811. _this.props.onCancel && _this.props.onCancel();
  31812. };
  31813. _this.confirmInsert = function () {
  31814. var selectedItems = _this.controller.getSelectedItems();
  31815. if (_this.props.onBeforeInsert) {
  31816. var filteredItems = _this.props.onBeforeInsert(selectedItems);
  31817. if (filteredItems && filteredItems instanceof Array) {
  31818. _this.controller.deselectAllItems();
  31819. _this.props.onInsert && _this.props.onInsert(filteredItems);
  31820. } else if (filteredItems !== false) {
  31821. _this.controller.deselectAllItems();
  31822. _this.props.onInsert && _this.props.onInsert(selectedItems);
  31823. }
  31824. } else {
  31825. _this.controller.deselectAllItems();
  31826. _this.props.onInsert && _this.props.onInsert(selectedItems);
  31827. }
  31828. };
  31829. _this.dragCounter = 0;
  31830. _this.controller = _this.props.controller;
  31831. var initialItems = _this.controller.getItems();
  31832. _this.state = {
  31833. draging: false,
  31834. error: false,
  31835. confirmable: initialItems.find(function (_ref3) {
  31836. var selected = _ref3.selected;
  31837. return selected;
  31838. }),
  31839. external: {
  31840. url: '',
  31841. type: 'IMAGE'
  31842. },
  31843. fileAccept: '',
  31844. showExternalForm: false,
  31845. allowExternal: false,
  31846. items: initialItems
  31847. };
  31848. _this.changeListenerId = _this.controller.onChange(function (items) {
  31849. _this.setState({ items: items, confirmable: items.find(function (_ref4) {
  31850. var selected = _ref4.selected;
  31851. return selected;
  31852. }) });
  31853. _this.props.onChange && _this.props.onChange(items);
  31854. });
  31855. return _this;
  31856. }
  31857. _createClass(BraftFinderView, [{
  31858. key: 'mapPropsToState',
  31859. value: function mapPropsToState(props) {
  31860. var accepts = props.accepts,
  31861. externals = props.externals;
  31862. accepts = _extends({}, defaultAccepts, accepts);
  31863. var fileAccept = !accepts ? [defaultAccepts.image, defaultAccepts.video, defaultAccepts.audio].join(',') : [accepts.image, accepts.video, accepts.audio].filter(function (item) {
  31864. return item;
  31865. }).join(',');
  31866. var external = {
  31867. url: '',
  31868. type: externals.image ? 'IMAGE' : externals.audio ? 'AUDIO' : externals.video ? 'VIDEO' : externals.embed ? 'EMBED' : ''
  31869. };
  31870. return {
  31871. fileAccept: fileAccept,
  31872. external: external,
  31873. allowExternal: externals && (externals.image || externals.audio || externals.video || externals.embed)
  31874. };
  31875. }
  31876. }, {
  31877. key: 'componentDidMount',
  31878. value: function componentDidMount() {
  31879. this.setState(this.mapPropsToState(this.props));
  31880. }
  31881. }, {
  31882. key: 'componentWillReceiveProps',
  31883. value: function componentWillReceiveProps(nextProps) {
  31884. this.setState(this.mapPropsToState(nextProps));
  31885. }
  31886. }, {
  31887. key: 'componentWillUnmount',
  31888. value: function componentWillUnmount() {
  31889. this.controller.offChange(this.changeListenerId);
  31890. }
  31891. }, {
  31892. key: 'render',
  31893. value: function render() {
  31894. var _props = this.props,
  31895. language = _props.language,
  31896. externals = _props.externals;
  31897. var _state = this.state,
  31898. items = _state.items,
  31899. draging = _state.draging,
  31900. confirmable = _state.confirmable,
  31901. fileAccept = _state.fileAccept,
  31902. external = _state.external,
  31903. showExternalForm = _state.showExternalForm,
  31904. allowExternal = _state.allowExternal;
  31905. return _react2.default.createElement(
  31906. 'div',
  31907. { className: 'braft-finder' },
  31908. _react2.default.createElement(
  31909. 'div',
  31910. {
  31911. onDragEnter: this.handleDragEnter,
  31912. onDragOver: this.handleDragEnter,
  31913. onDragLeave: this.handleDragLeave,
  31914. onDrop: this.handleDragDrop,
  31915. className: 'bf-uploader'
  31916. },
  31917. _react2.default.createElement(
  31918. 'div',
  31919. { className: "bf-drag-uploader " + (draging || !items.length ? 'active ' : ' ') + (draging ? 'draging' : '') },
  31920. _react2.default.createElement(
  31921. 'span',
  31922. { className: 'bf-drag-tip' },
  31923. _react2.default.createElement('input', { accept: fileAccept, onChange: this.reslovePickedFiles, multiple: true, type: 'file' }),
  31924. draging ? language.dropTip : language.dragTip
  31925. )
  31926. ),
  31927. items.length ? _react2.default.createElement(
  31928. 'div',
  31929. { className: 'bf-list-wrap' },
  31930. _react2.default.createElement(
  31931. 'div',
  31932. { className: 'bf-list-tools' },
  31933. _react2.default.createElement(
  31934. 'span',
  31935. { onClick: this.selectAllItems, className: 'bf-select-all' },
  31936. _react2.default.createElement('i', { className: 'braft-icon-done' }),
  31937. ' ',
  31938. language.selectAll
  31939. ),
  31940. _react2.default.createElement(
  31941. 'span',
  31942. { onClick: this.deselectAllItems, disabled: !confirmable, className: 'bf-deselect-all' },
  31943. _react2.default.createElement('i', { className: 'braft-icon-close' }),
  31944. ' ',
  31945. language.deselect
  31946. ),
  31947. _react2.default.createElement(
  31948. 'span',
  31949. { onClick: this.removeSelectedItems, disabled: !confirmable, className: 'bf-remove-selected' },
  31950. _react2.default.createElement('i', { className: 'braft-icon-bin' }),
  31951. ' ',
  31952. language.removeSelected
  31953. )
  31954. ),
  31955. this.buildItemList()
  31956. ) : null,
  31957. showExternalForm && allowExternal ? _react2.default.createElement(
  31958. 'div',
  31959. { className: 'bf-add-external' },
  31960. _react2.default.createElement(
  31961. 'div',
  31962. { className: 'bf-external-form' },
  31963. _react2.default.createElement(
  31964. 'div',
  31965. { className: 'bf-external-input' },
  31966. _react2.default.createElement(
  31967. 'div',
  31968. null,
  31969. _react2.default.createElement('input', { onKeyDown: this.confirmAddExternal, value: external.url, onChange: this.inputExternal, placeholder: language.externalInputPlaceHolder })
  31970. ),
  31971. _react2.default.createElement(
  31972. 'button',
  31973. { type: 'button', onClick: this.confirmAddExternal, disabled: !external.url.trim().length },
  31974. language.confirm
  31975. )
  31976. ),
  31977. _react2.default.createElement(
  31978. 'div',
  31979. { 'data-type': external.type, className: 'bf-switch-external-type' },
  31980. externals.image ? _react2.default.createElement(
  31981. 'button',
  31982. { type: 'button', onClick: this.switchExternalType, 'data-type': 'IMAGE' },
  31983. language.image
  31984. ) : null,
  31985. externals.audio ? _react2.default.createElement(
  31986. 'button',
  31987. { type: 'button', onClick: this.switchExternalType, 'data-type': 'AUDIO' },
  31988. language.audio
  31989. ) : null,
  31990. externals.video ? _react2.default.createElement(
  31991. 'button',
  31992. { type: 'button', onClick: this.switchExternalType, 'data-type': 'VIDEO' },
  31993. language.video
  31994. ) : null,
  31995. externals.embed ? _react2.default.createElement(
  31996. 'button',
  31997. { type: 'button', onClick: this.switchExternalType, 'data-type': 'EMBED' },
  31998. language.embed
  31999. ) : null
  32000. ),
  32001. _react2.default.createElement(
  32002. 'span',
  32003. { className: 'bf-external-tip' },
  32004. language.externalInputTip
  32005. )
  32006. )
  32007. ) : null
  32008. ),
  32009. _react2.default.createElement(
  32010. 'footer',
  32011. { className: 'bf-manager-footer' },
  32012. _react2.default.createElement(
  32013. 'div',
  32014. { className: 'pull-left' },
  32015. allowExternal ? _react2.default.createElement(
  32016. 'span',
  32017. {
  32018. onClick: this.toggleExternalForm,
  32019. className: 'bf-toggle-external-form'
  32020. },
  32021. showExternalForm ? _react2.default.createElement(
  32022. 'span',
  32023. { className: 'bf-bottom-text' },
  32024. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  32025. ' ',
  32026. language.addLocalFile
  32027. ) : _react2.default.createElement(
  32028. 'span',
  32029. { className: 'bf-bottom-text' },
  32030. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  32031. ' ',
  32032. language.addExternalSource
  32033. )
  32034. ) : null
  32035. ),
  32036. _react2.default.createElement(
  32037. 'div',
  32038. { className: 'pull-right' },
  32039. _react2.default.createElement(
  32040. 'button',
  32041. { onClick: this.confirmInsert, className: 'button button-insert', disabled: !confirmable },
  32042. language.insert
  32043. ),
  32044. _react2.default.createElement(
  32045. 'button',
  32046. { onClick: this.cancelInsert, className: 'button button-cancel' },
  32047. language.cancel
  32048. )
  32049. )
  32050. )
  32051. );
  32052. }
  32053. }, {
  32054. key: 'buildItemList',
  32055. value: function buildItemList() {
  32056. var _this2 = this;
  32057. return _react2.default.createElement(
  32058. 'ul',
  32059. { className: 'bf-list' },
  32060. _react2.default.createElement(
  32061. 'li',
  32062. { className: 'bf-add-item' },
  32063. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  32064. _react2.default.createElement('input', { accept: this.state.fileAccept, onChange: this.reslovePickedFiles, multiple: true, type: 'file' })
  32065. ),
  32066. this.state.items.map(function (item, index) {
  32067. var previewerComponents = null;
  32068. var progressMarker = item.uploading && !_this2.props.hideProgress ? _react2.default.createElement(
  32069. 'div',
  32070. { className: 'bf-item-uploading' },
  32071. _react2.default.createElement('div', { className: 'bf-item-uploading-bar', style: { width: item.uploadProgress / 1 + '%' } })
  32072. ) : '';
  32073. switch (item.type) {
  32074. case 'IMAGE':
  32075. previewerComponents = _react2.default.createElement(
  32076. 'div',
  32077. { className: 'bf-image' },
  32078. progressMarker,
  32079. _react2.default.createElement('img', { src: item.thumbnail || item.url })
  32080. );
  32081. break;
  32082. case 'VIDEO':
  32083. previewerComponents = _react2.default.createElement(
  32084. 'div',
  32085. { className: 'bf-icon bf-video', title: item.url },
  32086. progressMarker,
  32087. _react2.default.createElement('i', { className: 'braft-icon-film' }),
  32088. _react2.default.createElement(
  32089. 'span',
  32090. null,
  32091. item.name || item.url
  32092. )
  32093. );
  32094. break;
  32095. case 'AUDIO':
  32096. previewerComponents = _react2.default.createElement(
  32097. 'div',
  32098. { className: 'bf-icon bf-audio', title: item.url },
  32099. progressMarker,
  32100. _react2.default.createElement('i', { className: 'braft-icon-music' }),
  32101. _react2.default.createElement(
  32102. 'span',
  32103. null,
  32104. item.name || item.url
  32105. )
  32106. );
  32107. break;
  32108. case 'EMBED':
  32109. previewerComponents = _react2.default.createElement(
  32110. 'div',
  32111. { className: 'bf-icon bf-embed', title: item.url },
  32112. progressMarker,
  32113. _react2.default.createElement('i', { className: 'braft-icon-code' }),
  32114. _react2.default.createElement(
  32115. 'span',
  32116. null,
  32117. item.name || _this2.props.language.embed
  32118. )
  32119. );
  32120. break;
  32121. default:
  32122. previewerComponents = _react2.default.createElement(
  32123. 'a',
  32124. { className: 'bf-icon bf-file', title: item.url, href: item.url },
  32125. progressMarker,
  32126. _react2.default.createElement('i', { className: 'braft-icon-file-text' }),
  32127. _react2.default.createElement(
  32128. 'span',
  32129. null,
  32130. item.name || item.url
  32131. )
  32132. );
  32133. break;
  32134. }
  32135. var className = ['bf-item'];
  32136. item.selected && className.push('active');
  32137. item.uploading && className.push('uploading');
  32138. item.error && className.push('error');
  32139. return _react2.default.createElement(
  32140. 'li',
  32141. {
  32142. key: index,
  32143. title: item.name,
  32144. 'data-id': item.id,
  32145. className: className.join(' '),
  32146. onClick: _this2.toggleSelectItem
  32147. },
  32148. previewerComponents,
  32149. _react2.default.createElement('span', { 'data-id': item.id, onClick: _this2.removeItem, className: 'bf-item-remove braft-icon-close' }),
  32150. _react2.default.createElement(
  32151. 'span',
  32152. { className: 'bf-item-title' },
  32153. item.name
  32154. )
  32155. );
  32156. })
  32157. );
  32158. }
  32159. }]);
  32160. return BraftFinderView;
  32161. }(_react2.default.Component);
  32162. BraftFinderView.defaultProps = {
  32163. accepts: defaultAccepts,
  32164. externals: {
  32165. image: true,
  32166. video: true,
  32167. audio: true,
  32168. embed: true
  32169. }
  32170. };
  32171. exports.default = BraftFinderView;
  32172. /***/ }),
  32173. /* 19 */
  32174. /***/ (function(module, exports, __webpack_require__) {
  32175. Object.defineProperty(exports, "__esModule", {
  32176. value: true
  32177. });
  32178. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  32179. var _base = __webpack_require__(1);
  32180. var _image = __webpack_require__(0);
  32181. function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
  32182. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32183. var defaultValidator = function defaultValidator() {
  32184. return true;
  32185. };
  32186. var BraftFinderController = function BraftFinderController() {
  32187. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  32188. _classCallCheck(this, BraftFinderController);
  32189. _initialiseProps.call(this);
  32190. this.items = props.items || [];
  32191. this.uploadFn = props.uploader;
  32192. this.validateFn = props.validator || defaultValidator;
  32193. this.changeListeners = [];
  32194. }
  32195. // resolvePastedFiles ({ clipboardData }, callback) {
  32196. // if (clipboardData && clipboardData.items && clipboardData.items[0].type.indexOf('image') > -1) {
  32197. // this.uploadImage(clipboardData.items[0].getAsFile(), callback)
  32198. // }
  32199. // }
  32200. ;
  32201. var _initialiseProps = function _initialiseProps() {
  32202. var _this = this;
  32203. this.setProps = function () {
  32204. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  32205. _this.items = props.items || _this.items || [];
  32206. _this.uploadFn = props.uploader;
  32207. _this.validateFn = props.validator || defaultValidator;
  32208. };
  32209. this.getMediaItem = function (id) {
  32210. return _this.items.find(function (item) {
  32211. return item.id === id;
  32212. });
  32213. };
  32214. this.getSelectedItems = function () {
  32215. return _this.items.filter(function (item) {
  32216. return item.selected;
  32217. });
  32218. };
  32219. this.getItems = function () {
  32220. return _this.items;
  32221. };
  32222. this.setItems = function (items) {
  32223. _this.items = items.map(function (item) {
  32224. return _extends({}, item, { id: item.id.toString() });
  32225. }) || [];
  32226. _this.applyChange();
  32227. _this.uploadItems();
  32228. };
  32229. this.addMediaItem = function (item) {
  32230. _this.addItems([item]);
  32231. };
  32232. this.addItems = function (items) {
  32233. _this.items = [].concat(_toConsumableArray(_this.items), _toConsumableArray(items.map(function (item) {
  32234. return _extends({}, item, { id: item.id.toString() });
  32235. })));
  32236. _this.applyChange();
  32237. _this.uploadItems();
  32238. };
  32239. this.selectMediaItem = function (id) {
  32240. var item = _this.getMediaItem(id);
  32241. if (item && (item.uploading || item.error)) {
  32242. return false;
  32243. }
  32244. _this.setMediaItemState(id, {
  32245. selected: true
  32246. });
  32247. };
  32248. this.selectAllItems = function () {
  32249. _this.items = _this.items.filter(function (item) {
  32250. return !item.error && !item.uploading;
  32251. }).map(function (item) {
  32252. return _extends({}, item, { selected: true });
  32253. });
  32254. _this.applyChange();
  32255. };
  32256. this.deselectMediaItem = function (id) {
  32257. _this.setMediaItemState(id, {
  32258. selected: false
  32259. });
  32260. };
  32261. this.deselectAllItems = function () {
  32262. _this.items = _this.items.map(function (item) {
  32263. return _extends({}, item, { selected: false });
  32264. });
  32265. _this.applyChange();
  32266. };
  32267. this.removeMediaItem = function (id) {
  32268. _this.items = _this.items.filter(function (item) {
  32269. return item.id !== id;
  32270. });
  32271. _this.applyChange();
  32272. };
  32273. this.removeItems = function () {
  32274. var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  32275. _this.items = _this.items.filter(function (item) {
  32276. return !ids.includes(item.id);
  32277. });
  32278. _this.applyChange();
  32279. };
  32280. this.removeSelectedItems = function () {
  32281. _this.items = _this.items.filter(function (item) {
  32282. return !item.selected;
  32283. });
  32284. _this.applyChange();
  32285. };
  32286. this.removeErrorItems = function () {
  32287. _this.items = _this.items.filter(function (item) {
  32288. return !item.error;
  32289. });
  32290. _this.applyChange();
  32291. };
  32292. this.removeAllItems = function () {
  32293. _this.items = [];
  32294. _this.applyChange();
  32295. };
  32296. this.setMediaItemState = function (id, state) {
  32297. _this.items = _this.items.map(function (item) {
  32298. return item.id === id ? _extends({}, item, state) : item;
  32299. });
  32300. _this.applyChange();
  32301. };
  32302. this.reuploadErrorItems = function () {
  32303. _this.uploadItems(true);
  32304. };
  32305. this.uploadItems = function () {
  32306. var ignoreError = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  32307. _this.items.forEach(function (item, index) {
  32308. if (item.uploading || item.url) {
  32309. return false;
  32310. }
  32311. if (!ignoreError && item.error) {
  32312. return false;
  32313. }
  32314. if (item.type === 'IMAGE') {
  32315. _this.createThumbnail(item);
  32316. _this.uploadFn = _this.uploadFn || _this.createInlineImage;
  32317. } else if (!_this.uploadFn) {
  32318. _this.setMediaItemState(item.id, { error: 1 });
  32319. return false;
  32320. }
  32321. _this.setMediaItemState(item.id, {
  32322. uploading: true,
  32323. uploadProgress: 0,
  32324. error: 0
  32325. });
  32326. _this.uploadFn({
  32327. id: item.id,
  32328. file: item.file,
  32329. success: function success(res) {
  32330. _this.handleUploadSuccess(item.id, res);
  32331. },
  32332. progress: function progress(_progress) {
  32333. _this.setMediaItemState(item.id, {
  32334. uploading: true,
  32335. uploadProgress: _progress
  32336. });
  32337. },
  32338. error: function error(_error) {
  32339. _this.setMediaItemState(item.id, {
  32340. uploading: false,
  32341. error: 2
  32342. });
  32343. }
  32344. });
  32345. });
  32346. };
  32347. this.createThumbnail = function (_ref) {
  32348. var id = _ref.id,
  32349. file = _ref.file;
  32350. (0, _image.compressImage)(URL.createObjectURL(file), 226, 226).then(function (result) {
  32351. _this.setMediaItemState(id, { thumbnail: result.url });
  32352. });
  32353. };
  32354. this.createInlineImage = function (param) {
  32355. (0, _image.compressImage)(URL.createObjectURL(param.file), 1280, 800).then(function (result) {
  32356. param.success({ url: result.url });
  32357. }).catch(function (error) {
  32358. param.error(error);
  32359. });
  32360. };
  32361. this.handleUploadSuccess = function (id, data) {
  32362. _this.setMediaItemState(id, _extends({}, data, {
  32363. file: null,
  32364. uploadProgress: 1,
  32365. uploading: false,
  32366. selected: false
  32367. }));
  32368. var item = _this.getMediaItem(data.id || id);
  32369. item.onReady && item.onReady(item);
  32370. };
  32371. this.applyChange = function () {
  32372. _this.changeListeners.forEach(function (_ref2) {
  32373. var callback = _ref2.callback;
  32374. return callback(_this.items);
  32375. });
  32376. };
  32377. this.uploadImage = function (file, callback) {
  32378. var fileId = new Date().getTime() + '_' + (0, _base.UniqueIndex)();
  32379. _this.addMediaItem({
  32380. type: 'IMAGE',
  32381. id: fileId,
  32382. file: file,
  32383. name: fileId,
  32384. size: file.size,
  32385. uploadProgress: 0,
  32386. uploading: false,
  32387. selected: false,
  32388. error: 0,
  32389. onReady: callback
  32390. });
  32391. };
  32392. this.uploadImageRecursively = function (files, callback) {
  32393. var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  32394. if (files[index] && files[index].type.indexOf('image') > -1) {
  32395. _this.uploadImage(files[index], function (image) {
  32396. callback && callback(image);
  32397. index < files.length - 1 && _this.uploadImageRecursively(files, callback, index + 1);
  32398. });
  32399. } else {
  32400. index < files.length - 1 && _this.uploadImageRecursively(files, callback, index + 1);
  32401. }
  32402. };
  32403. this.addResolvedFiles = function (param, index, accepts) {
  32404. var data = {
  32405. id: new Date().getTime() + '_' + (0, _base.UniqueIndex)(),
  32406. file: param.files[index],
  32407. name: param.files[index].name,
  32408. size: param.files[index].size,
  32409. uploadProgress: 0,
  32410. uploading: false,
  32411. selected: false,
  32412. error: 0,
  32413. onReady: function onReady(item) {
  32414. param.onItemReady && param.onItemReady(item);
  32415. }
  32416. };
  32417. if (param.files[index].type.indexOf('image/') === 0 && accepts.image) {
  32418. data.type = 'IMAGE';
  32419. _this.addMediaItem(data);
  32420. } else if (param.files[index].type.indexOf('video/') === 0 && accepts.video) {
  32421. data.type = 'VIDEO';
  32422. _this.addMediaItem(data);
  32423. } else if (param.files[index].type.indexOf('audio/') === 0 && accepts.audio) {
  32424. data.type = 'AUDIO';
  32425. _this.addMediaItem(data);
  32426. }
  32427. setTimeout(function () {
  32428. _this.resolveFiles(param, index + 1, accepts);
  32429. }, 60);
  32430. };
  32431. this.resolveFiles = function (param, index, accepts) {
  32432. if (index < param.files.length) {
  32433. var validateResult = _this.validateFn(param.files[index]);
  32434. if (validateResult instanceof Promise) {
  32435. validateResult.then(function () {
  32436. _this.addResolvedFiles(param, index, accepts);
  32437. });
  32438. } else if (validateResult) {
  32439. _this.addResolvedFiles(param, index, accepts);
  32440. }
  32441. } else {
  32442. param.onAllReady && param.onAllReady();
  32443. }
  32444. };
  32445. this.onChange = function (callback) {
  32446. var listenerId = (0, _base.UniqueIndex)();
  32447. _this.changeListeners.push({
  32448. id: listenerId,
  32449. callback: callback
  32450. });
  32451. return listenerId;
  32452. };
  32453. this.offChange = function (listenerId) {
  32454. _this.changeListeners = _this.changeListeners.filter(function (_ref3) {
  32455. var id = _ref3.id;
  32456. return id !== listenerId;
  32457. });
  32458. };
  32459. };
  32460. exports.default = BraftFinderController;
  32461. /***/ }),
  32462. /* 20 */
  32463. /***/ (function(module, exports, __webpack_require__) {
  32464. Object.defineProperty(exports, "__esModule", {
  32465. value: true
  32466. });
  32467. exports.ImageUtils = undefined;
  32468. var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
  32469. var _react = __webpack_require__(2);
  32470. var _react2 = _interopRequireDefault(_react);
  32471. var _controller = __webpack_require__(19);
  32472. var _controller2 = _interopRequireDefault(_controller);
  32473. var _view = __webpack_require__(18);
  32474. var _view2 = _interopRequireDefault(_view);
  32475. var _languages = __webpack_require__(10);
  32476. var _languages2 = _interopRequireDefault(_languages);
  32477. var _image = __webpack_require__(0);
  32478. var ImageUtils = _interopRequireWildcard(_image);
  32479. function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
  32480. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  32481. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32482. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  32483. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  32484. var BraftFinder = function (_FinderController) {
  32485. _inherits(BraftFinder, _FinderController);
  32486. function BraftFinder(props) {
  32487. _classCallCheck(this, BraftFinder);
  32488. var _this = _possibleConstructorReturn(this, (BraftFinder.__proto__ || Object.getPrototypeOf(BraftFinder)).call(this, props));
  32489. _initialiseProps.call(_this);
  32490. _this.superProps = props;
  32491. return _this;
  32492. }
  32493. return BraftFinder;
  32494. }(_controller2.default);
  32495. var _initialiseProps = function _initialiseProps() {
  32496. var _this2 = this;
  32497. this.ReactComponent = function () {
  32498. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  32499. var componentProps = _extends({}, _this2.superProps, props);
  32500. var language = (typeof componentProps.language === 'function' ? componentProps.language(_languages2.default, 'braft-finder') : _languages2.default[componentProps.language]) || _languages2.default['zh'];
  32501. return _react2.default.createElement(_view2.default, _extends({}, componentProps, {
  32502. language: language,
  32503. controller: _this2
  32504. }));
  32505. };
  32506. };
  32507. exports.default = BraftFinder;
  32508. exports.ImageUtils = ImageUtils;
  32509. /***/ })
  32510. /******/ ]);
  32511. });
  32512. });
  32513. index.unwrapExports(dist$2);
  32514. var draftjsUtils$1 = index.createCommonjsModule(function (module, exports) {
  32515. !function(e,t){module.exports=t(Draft,immutable$3);}("undefined"!=typeof self?self:index.commonjsGlobal,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r});},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=3)}([function(t,n){t.exports=e;},function(e,t,n){function r(e){var t=e.getSelection(),n=e.getCurrentContent(),r=t.getStartKey(),o=t.getEndKey(),i=n.getBlockMap();return i.toSeq().skipUntil(function(e,t){return t===r}).takeUntil(function(e,t){return t===o}).concat([[o,i.get(o)]])}function o(e){return r(e).toList()}function i(e){if(e)return o(e).get(0)}function l(e){if(e){var t=i(e),n=e.getCurrentContent(),r=n.getBlockMap().toSeq().toList(),o=0;if(r.forEach(function(e,n){e.get("key")===t.get("key")&&(o=n-1);}),o>-1)return r.get(o)}}function c(e){return e?e.getCurrentContent().getBlockMap().toList():new v.List}function a(e){var t=o(e);if(!t.some(function(e){return e.type!==t.get(0).type}))return t.get(0).type}function f(e){var t=p.RichUtils.tryToRemoveBlockStyle(e);return t?p.EditorState.push(e,t,"change-block-type"):e}function u(e){var t="",n=e.getSelection(),r=n.getAnchorOffset(),i=n.getFocusOffset(),l=o(e);if(l.size>0){if(n.getIsBackward()){var c=r;r=i,i=c;}for(var a=0;a<l.size;a+=1){var f=0===a?r:0,u=a===l.size-1?i:l.get(a).getText().length;t+=l.get(a).getText().slice(f,u);}}return t}function s(e){var t=e.getCurrentContent(),n=e.getSelection(),r=p.Modifier.removeRange(t,n,"forward"),o=r.getSelectionAfter(),i=r.getBlockForKey(o.getStartKey());return r=p.Modifier.insertText(r,o,"\n",i.getInlineStyleAt(o.getStartOffset()),null),p.EditorState.push(e,r,"insert-fragment")}function g(e){var t=p.Modifier.splitBlock(e.getCurrentContent(),e.getSelection());return f(p.EditorState.push(e,t,"split-block"))}function d(e){var t=e.getCurrentContent().getBlockMap().toList(),n=e.getSelection().merge({anchorKey:t.first().get("key"),anchorOffset:0,focusKey:t.last().get("key"),focusOffset:t.last().getLength()}),r=p.Modifier.removeRange(e.getCurrentContent(),n,"forward");return p.EditorState.push(e,r,"remove-range")}function S(e,t){var n=p.Modifier.setBlockData(e.getCurrentContent(),e.getSelection(),t);return p.EditorState.push(e,n,"change-block-data")}function y(e){var t=new v.Map({}),n=o(e);if(n&&n.size>0)for(var r=0;r<n.size;r+=1){var i=function(e){var r=n.get(e).getData();if(!r||0===r.size)return t=t.clear(),"break";if(0===e)t=r;else if(t.forEach(function(e,n){r.get(n)&&r.get(n)===e||(t=t.delete(n));}),0===t.size)return t=t.clear(),"break"}(r);if("break"===i)break}return t}Object.defineProperty(t,"__esModule",{value:!0}),t.blockRenderMap=void 0,t.getSelectedBlocksMap=r,t.getSelectedBlocksList=o,t.getSelectedBlock=i,t.getBlockBeforeSelectedBlock=l,t.getAllBlocks=c,t.getSelectedBlocksType=a,t.removeSelectedBlocksStyle=f,t.getSelectionText=u,t.addLineBreakRemovingSelection=s,t.insertNewUnstyledBlock=g,t.clearEditorContent=d,t.setBlockData=S,t.getSelectedBlocksMetadata=y;var p=n(0),v=n(6),k=(0, v.Map)({code:{element:"pre"}});t.blockRenderMap=p.DefaultDraftBlockRenderMap.merge(k);},function(e,t,n){function r(e){if(e){var t=e.getType();return "unordered-list-item"===t||"ordered-list-item"===t}return !1}function o(e,t,n){var r=e.getSelection(),o=e.getCurrentContent(),i=o.getBlockMap(),l=(0, c.getSelectedBlocksMap)(e).map(function(e){var r=e.getDepth()+t;return r=Math.max(0,Math.min(r,n)),e.set("depth",r)});return i=i.merge(l),o.merge({blockMap:i,selectionBefore:r,selectionAfter:r})}function i(e,t,n){var r=e.getSelection(),i=void 0;i=r.getIsBackward()?r.getFocusKey():r.getAnchorKey();var c=e.getCurrentContent(),a=c.getBlockForKey(i),f=a.getType();if("unordered-list-item"!==f&&"ordered-list-item"!==f)return e;var u=c.getBlockBefore(i);if(!u)return e;if(u.getType()!==f)return e;var s=a.getDepth();if(1===t&&s===n)return e;var g=Math.min(u.getDepth()+1,n),d=o(e,t,g);return l.EditorState.push(e,d,"adjust-depth")}Object.defineProperty(t,"__esModule",{value:!0}),t.isListBlock=r,t.changeDepth=i;var l=n(0),c=n(1);},function(e,t,n){e.exports=n(4);},function(e,t,n){var r=n(5),o=n(1),i=n(7),l=function(e){return e&&e.__esModule?e:{default:e}}(i),c=n(2);e.exports={getSelectedBlocksMap:o.getSelectedBlocksMap,getSelectedBlocksList:o.getSelectedBlocksList,getSelectedBlock:o.getSelectedBlock,getBlockBeforeSelectedBlock:o.getBlockBeforeSelectedBlock,getAllBlocks:o.getAllBlocks,getSelectedBlocksType:o.getSelectedBlocksType,removeSelectedBlocksStyle:o.removeSelectedBlocksStyle,getSelectionText:o.getSelectionText,addLineBreakRemovingSelection:o.addLineBreakRemovingSelection,insertNewUnstyledBlock:o.insertNewUnstyledBlock,clearEditorContent:o.clearEditorContent,setBlockData:o.setBlockData,getSelectedBlocksMetadata:o.getSelectedBlocksMetadata,blockRenderMap:o.blockRenderMap,getEntityRange:r.getEntityRange,getCustomStyleMap:r.getCustomStyleMap,toggleCustomInlineStyle:r.toggleCustomInlineStyle,getSelectionEntity:r.getSelectionEntity,extractInlineStyle:r.extractInlineStyle,removeAllInlineStyles:r.removeAllInlineStyles,getSelectionInlineStyle:r.getSelectionInlineStyle,getSelectionCustomInlineStyle:r.getSelectionCustomInlineStyle,handleNewLine:l.default,isListBlock:c.isListBlock,changeDepth:c.changeDepth};},function(e,t,n){function r(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function o(e){var t=e.getSelection();if(t.isCollapsed()){var n={},r=e.getCurrentInlineStyle().toList().toJS();if(r)return ["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(e){n[e]=r.indexOf(e)>=0;}),n}var o=t.getStartOffset(),i=t.getEndOffset(),l=(0, p.getSelectedBlocksList)(e);if(l.size>0){var c=function(){for(var e={BOLD:!0,ITALIC:!0,UNDERLINE:!0,STRIKETHROUGH:!0,CODE:!0,SUPERSCRIPT:!0,SUBSCRIPT:!0},t=0;t<l.size;t+=1){var n=0===t?o:0,r=t===l.size-1?i:l.get(t).getText().length;n===r&&0===n?(n=1,r=2):n===r&&(n-=1);for(var c=n;c<r;c+=1)!function(n){var r=l.get(t).getInlineStyleAt(n);["BOLD","ITALIC","UNDERLINE","STRIKETHROUGH","CODE","SUPERSCRIPT","SUBSCRIPT"].forEach(function(t){e[t]=e[t]&&r.get(t)===t;});}(c);}return {v:e}}();if("object"===(void 0===c?"undefined":S(c)))return c.v}return {}}function i(e){var t=void 0,n=e.getSelection(),r=n.getStartOffset(),o=n.getEndOffset();r===o&&0===r?o=1:r===o&&(r-=1);for(var i=(0, p.getSelectedBlock)(e),l=r;l<o;l+=1){var c=i.getEntityAt(l);if(!c){t=void 0;break}if(l===r)t=c;else if(t!==c){t=void 0;break}}return t}function l(e,t){var n=(0, p.getSelectedBlock)(e),r=void 0;return n.findEntityRanges(function(e){return e.get("entity")===t},function(e,t){r={start:e,end:t,text:n.get("text").slice(e,t)};}),r}function c(e,t,n){var r=e.getSelection(),o=Object.keys(v[t]).reduce(function(e,t){return y.Modifier.removeInlineStyle(e,r,t)},e.getCurrentContent()),i=y.EditorState.push(e,o,"changeinline-style"),l=e.getCurrentInlineStyle();if(r.isCollapsed()&&(i=l.reduce(function(e,t){return y.RichUtils.toggleInlineStyle(e,t)},i)),"SUPERSCRIPT"===t||"SUBSCRIPT"==t)l.has(n)||(i=y.RichUtils.toggleInlineStyle(i,n));else{var c="bgcolor"===t?"backgroundColor":t;l.has(c+"-"+n)||(i=y.RichUtils.toggleInlineStyle(i,t.toLowerCase()+"-"+n),k(t,c,n));}return i}function a(e){if(e){e.getCurrentContent().getBlockMap().map(function(e){return e.get("characterList")}).toList().flatten().forEach(function(e){e&&0===e.indexOf("color-")?k("color","color",e.substr(6)):e&&0===e.indexOf("bgcolor-")?k("bgcolor","backgroundColor",e.substr(8)):e&&0===e.indexOf("fontsize-")?k("fontSize","fontSize",+e.substr(9)):e&&0===e.indexOf("fontfamily-")&&k("fontFamily","fontFamily",e.substr(11));});}}function f(e,t,n){var r=e.getInlineStyleAt(n).toList(),o=r.filter(function(e){return e.startsWith(t.toLowerCase())});if(o&&o.size>0)return o.get(0)}function u(e,t){var n=e.getCurrentInlineStyle().toList(),r=n.filter(function(e){return e.startsWith(t.toLowerCase())});if(r&&r.size>0)return r.get(0)}function s(e,t){if(e&&t&&t.length>0){var n=function(){var n=e.getSelection(),r={};if(n.isCollapsed())return t.forEach(function(t){r[t]=u(e,t);}),{v:r};var o=n.getStartOffset(),i=n.getEndOffset(),l=(0, p.getSelectedBlocksList)(e);if(l.size>0){for(var c=0;c<l.size;c+=1)!function(e){var n=0===e?o:0,c=e===l.size-1?i:l.get(e).getText().length;n===c&&0===n?(n=1,c=2):n===c&&(n-=1);for(var a=n;a<c;a+=1)!function(o){o===n?t.forEach(function(t){r[t]=f(l.get(e),t,o);}):t.forEach(function(t){r[t]&&r[t]!==f(l.get(e),t,o)&&(r[t]=void 0);});}(a);}(c);return {v:r}}}();if("object"===(void 0===n?"undefined":S(n)))return n.v}return {}}function g(e){var t=e.getCurrentInlineStyle(),n=e.getCurrentContent();return t.forEach(function(t){n=y.Modifier.removeInlineStyle(n,e.getSelection(),t);}),y.EditorState.push(e,n,"change-inline-style")}Object.defineProperty(t,"__esModule",{value:!0}),t.getCustomStyleMap=void 0;var d=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r]);}return e},S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.getSelectionInlineStyle=o,t.getSelectionEntity=i,t.getEntityRange=l,t.toggleCustomInlineStyle=c,t.extractInlineStyle=a,t.getSelectionCustomInlineStyle=s,t.removeAllInlineStyles=g;var y=n(0),p=n(1),v={color:{},bgcolor:{},fontSize:{},fontFamily:{},CODE:{fontFamily:"monospace",wordWrap:"break-word",background:"#f1f1f1",borderRadius:3,padding:"1px 3px"},SUPERSCRIPT:{fontSize:11,position:"relative",top:-8,display:"inline-flex"},SUBSCRIPT:{fontSize:11,position:"relative",bottom:-8,display:"inline-flex"}},k=function(e,t,n){v[e][e.toLowerCase()+"-"+n]=r({},""+t,n);};t.getCustomStyleMap=function(){return d({},v.color,v.bgcolor,v.fontSize,v.fontFamily,{CODE:v.CODE,SUPERSCRIPT:v.SUPERSCRIPT,SUBSCRIPT:v.SUBSCRIPT})};},function(e,n){e.exports=t;},function(e,t,n){function r(e){var t=e.getSelection();if(t.isCollapsed()){var n=e.getCurrentContent(),r=t.getStartKey(),o=n.getBlockForKey(r);if(!(0, a.isListBlock)(o)&&"unstyled"!==o.getType()&&o.getLength()===t.getStartOffset())return (0, c.insertNewUnstyledBlock)(e);if((0, a.isListBlock)(o)&&0===o.getLength()){var i=o.getDepth();if(0===i)return (0, c.removeSelectedBlocksStyle)(e);if(i>0)return (0, a.changeDepth)(e,-1,i)}}}function o(e){return 13===e.which&&(e.getModifierState("Shift")||e.getModifierState("Alt")||e.getModifierState("Control"))}function i(e,t){if(o(t)){return e.getSelection().isCollapsed()?l.RichUtils.insertSoftNewline(e):(0, c.addLineBreakRemovingSelection)(e)}return r(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=i;var l=n(0),c=n(1),a=n(2);}])});
  32516. });
  32517. index.unwrapExports(draftjsUtils$1);
  32518. var draftjsUtils_1$1 = draftjsUtils$1.draftjsUtils;
  32519. var dist$3 = index.createCommonjsModule(function (module, exports) {
  32520. (function webpackUniversalModuleDefinition(root, factory) {
  32521. module.exports = factory(React__default, dist$1, Draft, immutable$3, dist, ReactDOM__default, dist$2, draftjsUtils$1);
  32522. })(window, function(__WEBPACK_EXTERNAL_MODULE__0__, __WEBPACK_EXTERNAL_MODULE__3__, __WEBPACK_EXTERNAL_MODULE__6__, __WEBPACK_EXTERNAL_MODULE__13__, __WEBPACK_EXTERNAL_MODULE__14__, __WEBPACK_EXTERNAL_MODULE__16__, __WEBPACK_EXTERNAL_MODULE__17__, __WEBPACK_EXTERNAL_MODULE__23__) {
  32523. return /******/ (function(modules) { // webpackBootstrap
  32524. /******/ // The module cache
  32525. /******/ var installedModules = {};
  32526. /******/
  32527. /******/ // The require function
  32528. /******/ function __webpack_require__(moduleId) {
  32529. /******/
  32530. /******/ // Check if module is in cache
  32531. /******/ if(installedModules[moduleId]) {
  32532. /******/ return installedModules[moduleId].exports;
  32533. /******/ }
  32534. /******/ // Create a new module (and put it into the cache)
  32535. /******/ var module = installedModules[moduleId] = {
  32536. /******/ i: moduleId,
  32537. /******/ l: false,
  32538. /******/ exports: {}
  32539. /******/ };
  32540. /******/
  32541. /******/ // Execute the module function
  32542. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  32543. /******/
  32544. /******/ // Flag the module as loaded
  32545. /******/ module.l = true;
  32546. /******/
  32547. /******/ // Return the exports of the module
  32548. /******/ return module.exports;
  32549. /******/ }
  32550. /******/
  32551. /******/
  32552. /******/ // expose the modules object (__webpack_modules__)
  32553. /******/ __webpack_require__.m = modules;
  32554. /******/
  32555. /******/ // expose the module cache
  32556. /******/ __webpack_require__.c = installedModules;
  32557. /******/
  32558. /******/ // define getter function for harmony exports
  32559. /******/ __webpack_require__.d = function(exports, name, getter) {
  32560. /******/ if(!__webpack_require__.o(exports, name)) {
  32561. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  32562. /******/ }
  32563. /******/ };
  32564. /******/
  32565. /******/ // define __esModule on exports
  32566. /******/ __webpack_require__.r = function(exports) {
  32567. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  32568. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  32569. /******/ }
  32570. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  32571. /******/ };
  32572. /******/
  32573. /******/ // create a fake namespace object
  32574. /******/ // mode & 1: value is a module id, require it
  32575. /******/ // mode & 2: merge all properties of value into the ns
  32576. /******/ // mode & 4: return value when already ns object
  32577. /******/ // mode & 8|1: behave like require
  32578. /******/ __webpack_require__.t = function(value, mode) {
  32579. /******/ if(mode & 1) value = __webpack_require__(value);
  32580. /******/ if(mode & 8) return value;
  32581. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  32582. /******/ var ns = Object.create(null);
  32583. /******/ __webpack_require__.r(ns);
  32584. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  32585. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  32586. /******/ return ns;
  32587. /******/ };
  32588. /******/
  32589. /******/ // getDefaultExport function for compatibility with non-harmony modules
  32590. /******/ __webpack_require__.n = function(module) {
  32591. /******/ var getter = module && module.__esModule ?
  32592. /******/ function getDefault() { return module['default']; } :
  32593. /******/ function getModuleExports() { return module; };
  32594. /******/ __webpack_require__.d(getter, 'a', getter);
  32595. /******/ return getter;
  32596. /******/ };
  32597. /******/
  32598. /******/ // Object.prototype.hasOwnProperty.call
  32599. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  32600. /******/
  32601. /******/ // __webpack_public_path__
  32602. /******/ __webpack_require__.p = "/";
  32603. /******/
  32604. /******/
  32605. /******/ // Load entry module and return exports
  32606. /******/ return __webpack_require__(__webpack_require__.s = 39);
  32607. /******/ })
  32608. /************************************************************************/
  32609. /******/ ([
  32610. /* 0 */
  32611. /***/ (function(module, exports) {
  32612. module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
  32613. /***/ }),
  32614. /* 1 */
  32615. /***/ (function(module, exports) {
  32616. function _assertThisInitialized(self) {
  32617. if (self === void 0) {
  32618. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  32619. }
  32620. return self;
  32621. }
  32622. module.exports = _assertThisInitialized;
  32623. /***/ }),
  32624. /* 2 */
  32625. /***/ (function(module, exports) {
  32626. function _defineProperty(obj, key, value) {
  32627. if (key in obj) {
  32628. Object.defineProperty(obj, key, {
  32629. value: value,
  32630. enumerable: true,
  32631. configurable: true,
  32632. writable: true
  32633. });
  32634. } else {
  32635. obj[key] = value;
  32636. }
  32637. return obj;
  32638. }
  32639. module.exports = _defineProperty;
  32640. /***/ }),
  32641. /* 3 */
  32642. /***/ (function(module, exports) {
  32643. module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
  32644. /***/ }),
  32645. /* 4 */
  32646. /***/ (function(module, exports) {
  32647. function _classCallCheck(instance, Constructor) {
  32648. if (!(instance instanceof Constructor)) {
  32649. throw new TypeError("Cannot call a class as a function");
  32650. }
  32651. }
  32652. module.exports = _classCallCheck;
  32653. /***/ }),
  32654. /* 5 */
  32655. /***/ (function(module, exports, __webpack_require__) {
  32656. var defineProperty = __webpack_require__(2);
  32657. function _objectSpread(target) {
  32658. for (var i = 1; i < arguments.length; i++) {
  32659. var source = arguments[i] != null ? arguments[i] : {};
  32660. var ownKeys = Object.keys(source);
  32661. if (typeof Object.getOwnPropertySymbols === 'function') {
  32662. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  32663. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  32664. }));
  32665. }
  32666. ownKeys.forEach(function (key) {
  32667. defineProperty(target, key, source[key]);
  32668. });
  32669. }
  32670. return target;
  32671. }
  32672. module.exports = _objectSpread;
  32673. /***/ }),
  32674. /* 6 */
  32675. /***/ (function(module, exports) {
  32676. module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
  32677. /***/ }),
  32678. /* 7 */
  32679. /***/ (function(module, exports) {
  32680. function _defineProperties(target, props) {
  32681. for (var i = 0; i < props.length; i++) {
  32682. var descriptor = props[i];
  32683. descriptor.enumerable = descriptor.enumerable || false;
  32684. descriptor.configurable = true;
  32685. if ("value" in descriptor) descriptor.writable = true;
  32686. Object.defineProperty(target, descriptor.key, descriptor);
  32687. }
  32688. }
  32689. function _createClass(Constructor, protoProps, staticProps) {
  32690. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  32691. if (staticProps) _defineProperties(Constructor, staticProps);
  32692. return Constructor;
  32693. }
  32694. module.exports = _createClass;
  32695. /***/ }),
  32696. /* 8 */
  32697. /***/ (function(module, exports, __webpack_require__) {
  32698. var _typeof = __webpack_require__(15);
  32699. var assertThisInitialized = __webpack_require__(1);
  32700. function _possibleConstructorReturn(self, call) {
  32701. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  32702. return call;
  32703. }
  32704. return assertThisInitialized(self);
  32705. }
  32706. module.exports = _possibleConstructorReturn;
  32707. /***/ }),
  32708. /* 9 */
  32709. /***/ (function(module, exports) {
  32710. function _getPrototypeOf(o) {
  32711. module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  32712. return o.__proto__ || Object.getPrototypeOf(o);
  32713. };
  32714. return _getPrototypeOf(o);
  32715. }
  32716. module.exports = _getPrototypeOf;
  32717. /***/ }),
  32718. /* 10 */
  32719. /***/ (function(module, exports, __webpack_require__) {
  32720. var setPrototypeOf = __webpack_require__(26);
  32721. function _inherits(subClass, superClass) {
  32722. if (typeof superClass !== "function" && superClass !== null) {
  32723. throw new TypeError("Super expression must either be null or a function");
  32724. }
  32725. subClass.prototype = Object.create(superClass && superClass.prototype, {
  32726. constructor: {
  32727. value: subClass,
  32728. writable: true,
  32729. configurable: true
  32730. }
  32731. });
  32732. if (superClass) setPrototypeOf(subClass, superClass);
  32733. }
  32734. module.exports = _inherits;
  32735. /***/ }),
  32736. /* 11 */
  32737. /***/ (function(module, exports) {
  32738. function _extends() {
  32739. module.exports = _extends = Object.assign || function (target) {
  32740. for (var i = 1; i < arguments.length; i++) {
  32741. var source = arguments[i];
  32742. for (var key in source) {
  32743. if (Object.prototype.hasOwnProperty.call(source, key)) {
  32744. target[key] = source[key];
  32745. }
  32746. }
  32747. }
  32748. return target;
  32749. };
  32750. return _extends.apply(this, arguments);
  32751. }
  32752. module.exports = _extends;
  32753. /***/ }),
  32754. /* 12 */
  32755. /***/ (function(module, exports, __webpack_require__) {
  32756. var arrayWithoutHoles = __webpack_require__(27);
  32757. var iterableToArray = __webpack_require__(28);
  32758. var nonIterableSpread = __webpack_require__(29);
  32759. function _toConsumableArray(arr) {
  32760. return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
  32761. }
  32762. module.exports = _toConsumableArray;
  32763. /***/ }),
  32764. /* 13 */
  32765. /***/ (function(module, exports) {
  32766. module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
  32767. /***/ }),
  32768. /* 14 */
  32769. /***/ (function(module, exports) {
  32770. module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
  32771. /***/ }),
  32772. /* 15 */
  32773. /***/ (function(module, exports) {
  32774. function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); }
  32775. function _typeof(obj) {
  32776. if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
  32777. module.exports = _typeof = function _typeof(obj) {
  32778. return _typeof2(obj);
  32779. };
  32780. } else {
  32781. module.exports = _typeof = function _typeof(obj) {
  32782. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
  32783. };
  32784. }
  32785. return _typeof(obj);
  32786. }
  32787. module.exports = _typeof;
  32788. /***/ }),
  32789. /* 16 */
  32790. /***/ (function(module, exports) {
  32791. module.exports = __WEBPACK_EXTERNAL_MODULE__16__;
  32792. /***/ }),
  32793. /* 17 */
  32794. /***/ (function(module, exports) {
  32795. module.exports = __WEBPACK_EXTERNAL_MODULE__17__;
  32796. /***/ }),
  32797. /* 18 */
  32798. /***/ (function(module, exports, __webpack_require__) {
  32799. var Immutable = __webpack_require__(13);
  32800. var KEY_SEPARATOR = '-';
  32801. function MultiDecorator(decorators) {
  32802. this.decorators = Immutable.List(decorators);
  32803. }
  32804. /**
  32805. Return list of decoration IDs per character
  32806. @param {ContentBlock}
  32807. @return {List<String>}
  32808. */
  32809. MultiDecorator.prototype.getDecorations = function(block) {
  32810. var decorations = Array(block.getText().length).fill(null);
  32811. this.decorators.forEach(function(decorator, i) {
  32812. var _decorations = decorator.getDecorations(block);
  32813. _decorations.forEach(function(key, offset) {
  32814. if (!key) {
  32815. return;
  32816. }
  32817. key = i + KEY_SEPARATOR + key;
  32818. decorations[offset] = key;
  32819. });
  32820. });
  32821. return Immutable.List(decorations);
  32822. };
  32823. /**
  32824. Return component to render a decoration
  32825. @param {String}
  32826. @return {Function}
  32827. */
  32828. MultiDecorator.prototype.getComponentForKey = function(key) {
  32829. var decorator = this.getDecoratorForKey(key);
  32830. return decorator.getComponentForKey(
  32831. this.getInnerKey(key)
  32832. );
  32833. };
  32834. /**
  32835. Return props to render a decoration
  32836. @param {String}
  32837. @return {Object}
  32838. */
  32839. MultiDecorator.prototype.getPropsForKey = function(key) {
  32840. var decorator = this.getDecoratorForKey(key);
  32841. return decorator.getPropsForKey(
  32842. this.getInnerKey(key)
  32843. );
  32844. };
  32845. /**
  32846. Return a decorator for a specific key
  32847. @param {String}
  32848. @return {Decorator}
  32849. */
  32850. MultiDecorator.prototype.getDecoratorForKey = function(key) {
  32851. var parts = key.split(KEY_SEPARATOR);
  32852. var index = Number(parts[0]);
  32853. return this.decorators.get(index);
  32854. };
  32855. /**
  32856. Return inner key for a decorator
  32857. @param {String}
  32858. @return {String}
  32859. */
  32860. MultiDecorator.prototype.getInnerKey = function(key) {
  32861. var parts = key.split(KEY_SEPARATOR);
  32862. return parts.slice(1).join(KEY_SEPARATOR);
  32863. };
  32864. module.exports = MultiDecorator;
  32865. /***/ }),
  32866. /* 19 */
  32867. /***/ (function(module, exports, __webpack_require__) {
  32868. /**
  32869. * Copyright (c) 2013-present, Facebook, Inc.
  32870. * All rights reserved.
  32871. *
  32872. * This source code is licensed under the BSD-style license found in the
  32873. * LICENSE file in the root directory of this source tree. An additional grant
  32874. * of patent rights can be found in the PATENTS file in the same directory.
  32875. *
  32876. * @providesModule CharacterMetadata
  32877. * @format
  32878. *
  32879. */
  32880. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  32881. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  32882. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  32883. var _require = __webpack_require__(13),
  32884. Map = _require.Map,
  32885. OrderedSet = _require.OrderedSet,
  32886. Record = _require.Record;
  32887. // Immutable.map is typed such that the value for every key in the map
  32888. // must be the same type
  32889. var EMPTY_SET = OrderedSet();
  32890. var defaultRecord = {
  32891. style: EMPTY_SET,
  32892. entity: null
  32893. };
  32894. var CharacterMetadataRecord = Record(defaultRecord);
  32895. var CharacterMetadata = function (_CharacterMetadataRec) {
  32896. _inherits(CharacterMetadata, _CharacterMetadataRec);
  32897. function CharacterMetadata() {
  32898. _classCallCheck(this, CharacterMetadata);
  32899. return _possibleConstructorReturn(this, _CharacterMetadataRec.apply(this, arguments));
  32900. }
  32901. CharacterMetadata.prototype.getStyle = function getStyle() {
  32902. return this.get('style');
  32903. };
  32904. CharacterMetadata.prototype.getEntity = function getEntity() {
  32905. return this.get('entity');
  32906. };
  32907. CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
  32908. return this.getStyle().includes(style);
  32909. };
  32910. CharacterMetadata.applyStyle = function applyStyle(record, style) {
  32911. var withStyle = record.set('style', record.getStyle().add(style));
  32912. return CharacterMetadata.create(withStyle);
  32913. };
  32914. CharacterMetadata.removeStyle = function removeStyle(record, style) {
  32915. var withoutStyle = record.set('style', record.getStyle().remove(style));
  32916. return CharacterMetadata.create(withoutStyle);
  32917. };
  32918. CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
  32919. var withEntity = record.getEntity() === entityKey ? record : record.set('entity', entityKey);
  32920. return CharacterMetadata.create(withEntity);
  32921. };
  32922. /**
  32923. * Use this function instead of the `CharacterMetadata` constructor.
  32924. * Since most content generally uses only a very small number of
  32925. * style/entity permutations, we can reuse these objects as often as
  32926. * possible.
  32927. */
  32928. CharacterMetadata.create = function create(config) {
  32929. if (!config) {
  32930. return EMPTY;
  32931. }
  32932. var defaultConfig = {
  32933. style: EMPTY_SET,
  32934. entity: null
  32935. };
  32936. // Fill in unspecified properties, if necessary.
  32937. var configMap = Map(defaultConfig).merge(config);
  32938. var existing = pool.get(configMap);
  32939. if (existing) {
  32940. return existing;
  32941. }
  32942. var newCharacter = new CharacterMetadata(configMap);
  32943. pool = pool.set(configMap, newCharacter);
  32944. return newCharacter;
  32945. };
  32946. return CharacterMetadata;
  32947. }(CharacterMetadataRecord);
  32948. var EMPTY = new CharacterMetadata();
  32949. var pool = Map([[Map(defaultRecord), EMPTY]]);
  32950. CharacterMetadata.EMPTY = EMPTY;
  32951. module.exports = CharacterMetadata;
  32952. /***/ }),
  32953. /* 20 */
  32954. /***/ (function(module, exports, __webpack_require__) {
  32955. /**
  32956. * Copyright (c) 2013-present, Facebook, Inc.
  32957. * All rights reserved.
  32958. *
  32959. * This source code is licensed under the BSD-style license found in the
  32960. * LICENSE file in the root directory of this source tree. An additional grant
  32961. * of patent rights can be found in the PATENTS file in the same directory.
  32962. *
  32963. * @providesModule findRangesImmutable
  32964. * @format
  32965. *
  32966. */
  32967. /**
  32968. * Search through an array to find contiguous stretches of elements that
  32969. * match a specified filter function.
  32970. *
  32971. * When ranges are found, execute a specified `found` function to supply
  32972. * the values to the caller.
  32973. */
  32974. function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
  32975. if (!haystack.size) {
  32976. return;
  32977. }
  32978. var cursor = 0;
  32979. haystack.reduce(function (value, nextValue, nextIndex) {
  32980. if (!areEqualFn(value, nextValue)) {
  32981. if (filterFn(value)) {
  32982. foundFn(cursor, nextIndex);
  32983. }
  32984. cursor = nextIndex;
  32985. }
  32986. return nextValue;
  32987. });
  32988. filterFn(haystack.last()) && foundFn(cursor, haystack.count());
  32989. }
  32990. module.exports = findRangesImmutable;
  32991. /***/ }),
  32992. /* 21 */
  32993. /***/ (function(module, exports, __webpack_require__) {
  32994. var objectWithoutPropertiesLoose = __webpack_require__(25);
  32995. function _objectWithoutProperties(source, excluded) {
  32996. if (source == null) return {};
  32997. var target = objectWithoutPropertiesLoose(source, excluded);
  32998. var key, i;
  32999. if (Object.getOwnPropertySymbols) {
  33000. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  33001. for (i = 0; i < sourceSymbolKeys.length; i++) {
  33002. key = sourceSymbolKeys[i];
  33003. if (excluded.indexOf(key) >= 0) continue;
  33004. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  33005. target[key] = source[key];
  33006. }
  33007. }
  33008. return target;
  33009. }
  33010. module.exports = _objectWithoutProperties;
  33011. /***/ }),
  33012. /* 22 */
  33013. /***/ (function(module, exports, __webpack_require__) {
  33014. /**
  33015. * Copyright (c) 2013-present, Facebook, Inc.
  33016. * All rights reserved.
  33017. *
  33018. * This source code is licensed under the BSD-style license found in the
  33019. * LICENSE file in the root directory of this source tree. An additional grant
  33020. * of patent rights can be found in the PATENTS file in the same directory.
  33021. *
  33022. * @providesModule getFragmentFromSelection
  33023. * @format
  33024. *
  33025. */
  33026. var getContentStateFragment = __webpack_require__(30);
  33027. function getFragmentFromSelection(editorState) {
  33028. var selectionState = editorState.getSelection();
  33029. if (selectionState.isCollapsed()) {
  33030. return null;
  33031. }
  33032. return getContentStateFragment(editorState.getCurrentContent(), selectionState);
  33033. }
  33034. module.exports = getFragmentFromSelection;
  33035. /***/ }),
  33036. /* 23 */
  33037. /***/ (function(module, exports) {
  33038. module.exports = __WEBPACK_EXTERNAL_MODULE__23__;
  33039. /***/ }),
  33040. /* 24 */
  33041. /***/ (function(module, exports, __webpack_require__) {
  33042. var arrayWithHoles = __webpack_require__(36);
  33043. var iterableToArrayLimit = __webpack_require__(37);
  33044. var nonIterableRest = __webpack_require__(38);
  33045. function _slicedToArray(arr, i) {
  33046. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();
  33047. }
  33048. module.exports = _slicedToArray;
  33049. /***/ }),
  33050. /* 25 */
  33051. /***/ (function(module, exports) {
  33052. function _objectWithoutPropertiesLoose(source, excluded) {
  33053. if (source == null) return {};
  33054. var target = {};
  33055. var sourceKeys = Object.keys(source);
  33056. var key, i;
  33057. for (i = 0; i < sourceKeys.length; i++) {
  33058. key = sourceKeys[i];
  33059. if (excluded.indexOf(key) >= 0) continue;
  33060. target[key] = source[key];
  33061. }
  33062. return target;
  33063. }
  33064. module.exports = _objectWithoutPropertiesLoose;
  33065. /***/ }),
  33066. /* 26 */
  33067. /***/ (function(module, exports) {
  33068. function _setPrototypeOf(o, p) {
  33069. module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  33070. o.__proto__ = p;
  33071. return o;
  33072. };
  33073. return _setPrototypeOf(o, p);
  33074. }
  33075. module.exports = _setPrototypeOf;
  33076. /***/ }),
  33077. /* 27 */
  33078. /***/ (function(module, exports) {
  33079. function _arrayWithoutHoles(arr) {
  33080. if (Array.isArray(arr)) {
  33081. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  33082. arr2[i] = arr[i];
  33083. }
  33084. return arr2;
  33085. }
  33086. }
  33087. module.exports = _arrayWithoutHoles;
  33088. /***/ }),
  33089. /* 28 */
  33090. /***/ (function(module, exports) {
  33091. function _iterableToArray(iter) {
  33092. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  33093. }
  33094. module.exports = _iterableToArray;
  33095. /***/ }),
  33096. /* 29 */
  33097. /***/ (function(module, exports) {
  33098. function _nonIterableSpread() {
  33099. throw new TypeError("Invalid attempt to spread non-iterable instance");
  33100. }
  33101. module.exports = _nonIterableSpread;
  33102. /***/ }),
  33103. /* 30 */
  33104. /***/ (function(module, exports, __webpack_require__) {
  33105. /**
  33106. * Copyright (c) 2013-present, Facebook, Inc.
  33107. * All rights reserved.
  33108. *
  33109. * This source code is licensed under the BSD-style license found in the
  33110. * LICENSE file in the root directory of this source tree. An additional grant
  33111. * of patent rights can be found in the PATENTS file in the same directory.
  33112. *
  33113. * @providesModule getContentStateFragment
  33114. * @format
  33115. *
  33116. */
  33117. var randomizeBlockMapKeys = __webpack_require__(31);
  33118. var removeEntitiesAtEdges = __webpack_require__(34);
  33119. var getContentStateFragment = function getContentStateFragment(contentState, selectionState) {
  33120. var startKey = selectionState.getStartKey();
  33121. var startOffset = selectionState.getStartOffset();
  33122. var endKey = selectionState.getEndKey();
  33123. var endOffset = selectionState.getEndOffset();
  33124. // Edge entities should be stripped to ensure that we don't preserve
  33125. // invalid partial entities when the fragment is reused. We do, however,
  33126. // preserve entities that are entirely within the selection range.
  33127. var contentWithoutEdgeEntities = removeEntitiesAtEdges(contentState, selectionState);
  33128. var blockMap = contentWithoutEdgeEntities.getBlockMap();
  33129. var blockKeys = blockMap.keySeq();
  33130. var startIndex = blockKeys.indexOf(startKey);
  33131. var endIndex = blockKeys.indexOf(endKey) + 1;
  33132. return randomizeBlockMapKeys(blockMap.slice(startIndex, endIndex).map(function (block, blockKey) {
  33133. var text = block.getText();
  33134. var chars = block.getCharacterList();
  33135. if (startKey === endKey) {
  33136. return block.merge({
  33137. text: text.slice(startOffset, endOffset),
  33138. characterList: chars.slice(startOffset, endOffset)
  33139. });
  33140. }
  33141. if (blockKey === startKey) {
  33142. return block.merge({
  33143. text: text.slice(startOffset),
  33144. characterList: chars.slice(startOffset)
  33145. });
  33146. }
  33147. if (blockKey === endKey) {
  33148. return block.merge({
  33149. text: text.slice(0, endOffset),
  33150. characterList: chars.slice(0, endOffset)
  33151. });
  33152. }
  33153. return block;
  33154. }));
  33155. };
  33156. module.exports = getContentStateFragment;
  33157. /***/ }),
  33158. /* 31 */
  33159. /***/ (function(module, exports, __webpack_require__) {
  33160. /**
  33161. * Copyright (c) 2013-present, Facebook, Inc.
  33162. * All rights reserved.
  33163. *
  33164. * This source code is licensed under the BSD-style license found in the
  33165. * LICENSE file in the root directory of this source tree. An additional grant
  33166. * of patent rights can be found in the PATENTS file in the same directory.
  33167. *
  33168. * @providesModule randomizeBlockMapKeys
  33169. * @format
  33170. *
  33171. */
  33172. var ContentBlockNode = __webpack_require__(32);
  33173. var Immutable = __webpack_require__(13);
  33174. var generateRandomKey = __webpack_require__(33);
  33175. var OrderedMap = Immutable.OrderedMap;
  33176. var randomizeContentBlockNodeKeys = function randomizeContentBlockNodeKeys(blockMap) {
  33177. var newKeysRef = {};
  33178. // we keep track of root blocks in order to update subsequent sibling links
  33179. var lastRootBlock = void 0;
  33180. return OrderedMap(blockMap.withMutations(function (blockMapState) {
  33181. blockMapState.forEach(function (block, index) {
  33182. var oldKey = block.getKey();
  33183. var nextKey = block.getNextSiblingKey();
  33184. var prevKey = block.getPrevSiblingKey();
  33185. var childrenKeys = block.getChildKeys();
  33186. var parentKey = block.getParentKey();
  33187. // new key that we will use to build linking
  33188. var key = generateRandomKey();
  33189. // we will add it here to re-use it later
  33190. newKeysRef[oldKey] = key;
  33191. if (nextKey) {
  33192. var nextBlock = blockMapState.get(nextKey);
  33193. if (nextBlock) {
  33194. blockMapState.setIn([nextKey, 'prevSibling'], key);
  33195. } else {
  33196. // this can happen when generating random keys for fragments
  33197. blockMapState.setIn([oldKey, 'nextSibling'], null);
  33198. }
  33199. }
  33200. if (prevKey) {
  33201. var prevBlock = blockMapState.get(prevKey);
  33202. if (prevBlock) {
  33203. blockMapState.setIn([prevKey, 'nextSibling'], key);
  33204. } else {
  33205. // this can happen when generating random keys for fragments
  33206. blockMapState.setIn([oldKey, 'prevSibling'], null);
  33207. }
  33208. }
  33209. if (parentKey && blockMapState.get(parentKey)) {
  33210. var parentBlock = blockMapState.get(parentKey);
  33211. var parentChildrenList = parentBlock.getChildKeys();
  33212. blockMapState.setIn([parentKey, 'children'], parentChildrenList.set(parentChildrenList.indexOf(block.getKey()), key));
  33213. } else {
  33214. // blocks will then be treated as root block nodes
  33215. blockMapState.setIn([oldKey, 'parent'], null);
  33216. if (lastRootBlock) {
  33217. blockMapState.setIn([lastRootBlock.getKey(), 'nextSibling'], key);
  33218. blockMapState.setIn([oldKey, 'prevSibling'], newKeysRef[lastRootBlock.getKey()]);
  33219. }
  33220. lastRootBlock = blockMapState.get(oldKey);
  33221. }
  33222. childrenKeys.forEach(function (childKey) {
  33223. var childBlock = blockMapState.get(childKey);
  33224. if (childBlock) {
  33225. blockMapState.setIn([childKey, 'parent'], key);
  33226. } else {
  33227. blockMapState.setIn([oldKey, 'children'], block.getChildKeys().filter(function (child) {
  33228. return child !== childKey;
  33229. }));
  33230. }
  33231. });
  33232. });
  33233. }).toArray().map(function (block) {
  33234. return [newKeysRef[block.getKey()], block.set('key', newKeysRef[block.getKey()])];
  33235. }));
  33236. };
  33237. var randomizeContentBlockKeys = function randomizeContentBlockKeys(blockMap) {
  33238. return OrderedMap(blockMap.toArray().map(function (block) {
  33239. var key = generateRandomKey();
  33240. return [key, block.set('key', key)];
  33241. }));
  33242. };
  33243. var randomizeBlockMapKeys = function randomizeBlockMapKeys(blockMap) {
  33244. var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode;
  33245. if (!isTreeBasedBlockMap) {
  33246. return randomizeContentBlockKeys(blockMap);
  33247. }
  33248. return randomizeContentBlockNodeKeys(blockMap);
  33249. };
  33250. module.exports = randomizeBlockMapKeys;
  33251. /***/ }),
  33252. /* 32 */
  33253. /***/ (function(module, exports, __webpack_require__) {
  33254. /**
  33255. * Copyright (c) 2013-present, Facebook, Inc.
  33256. * All rights reserved.
  33257. *
  33258. * This source code is licensed under the BSD-style license found in the
  33259. * LICENSE file in the root directory of this source tree. An additional grant
  33260. * of patent rights can be found in the PATENTS file in the same directory.
  33261. *
  33262. * @providesModule ContentBlockNode
  33263. * @format
  33264. *
  33265. *
  33266. * This file is a fork of ContentBlock adding support for nesting references by
  33267. * providing links to children, parent, prevSibling, and nextSibling.
  33268. *
  33269. * This is unstable and not part of the public API and should not be used by
  33270. * production systems. This file may be update/removed without notice.
  33271. */
  33272. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  33273. function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
  33274. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
  33275. var CharacterMetadata = __webpack_require__(19);
  33276. var Immutable = __webpack_require__(13);
  33277. var findRangesImmutable = __webpack_require__(20);
  33278. var List = Immutable.List,
  33279. Map = Immutable.Map,
  33280. OrderedSet = Immutable.OrderedSet,
  33281. Record = Immutable.Record,
  33282. Repeat = Immutable.Repeat;
  33283. var EMPTY_SET = OrderedSet();
  33284. var defaultRecord = {
  33285. parent: null,
  33286. characterList: List(),
  33287. data: Map(),
  33288. depth: 0,
  33289. key: '',
  33290. text: '',
  33291. type: 'unstyled',
  33292. children: List(),
  33293. prevSibling: null,
  33294. nextSibling: null
  33295. };
  33296. var haveEqualStyle = function haveEqualStyle(charA, charB) {
  33297. return charA.getStyle() === charB.getStyle();
  33298. };
  33299. var haveEqualEntity = function haveEqualEntity(charA, charB) {
  33300. return charA.getEntity() === charB.getEntity();
  33301. };
  33302. var decorateCharacterList = function decorateCharacterList(config) {
  33303. if (!config) {
  33304. return config;
  33305. }
  33306. var characterList = config.characterList,
  33307. text = config.text;
  33308. if (text && !characterList) {
  33309. config.characterList = List(Repeat(CharacterMetadata.EMPTY, text.length));
  33310. }
  33311. return config;
  33312. };
  33313. var ContentBlockNode = function (_Record) {
  33314. _inherits(ContentBlockNode, _Record);
  33315. function ContentBlockNode() {
  33316. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultRecord;
  33317. _classCallCheck(this, ContentBlockNode);
  33318. return _possibleConstructorReturn(this, _Record.call(this, decorateCharacterList(props)));
  33319. }
  33320. ContentBlockNode.prototype.getKey = function getKey() {
  33321. return this.get('key');
  33322. };
  33323. ContentBlockNode.prototype.getType = function getType() {
  33324. return this.get('type');
  33325. };
  33326. ContentBlockNode.prototype.getText = function getText() {
  33327. return this.get('text');
  33328. };
  33329. ContentBlockNode.prototype.getCharacterList = function getCharacterList() {
  33330. return this.get('characterList');
  33331. };
  33332. ContentBlockNode.prototype.getLength = function getLength() {
  33333. return this.getText().length;
  33334. };
  33335. ContentBlockNode.prototype.getDepth = function getDepth() {
  33336. return this.get('depth');
  33337. };
  33338. ContentBlockNode.prototype.getData = function getData() {
  33339. return this.get('data');
  33340. };
  33341. ContentBlockNode.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
  33342. var character = this.getCharacterList().get(offset);
  33343. return character ? character.getStyle() : EMPTY_SET;
  33344. };
  33345. ContentBlockNode.prototype.getEntityAt = function getEntityAt(offset) {
  33346. var character = this.getCharacterList().get(offset);
  33347. return character ? character.getEntity() : null;
  33348. };
  33349. ContentBlockNode.prototype.getChildKeys = function getChildKeys() {
  33350. return this.get('children');
  33351. };
  33352. ContentBlockNode.prototype.getParentKey = function getParentKey() {
  33353. return this.get('parent');
  33354. };
  33355. ContentBlockNode.prototype.getPrevSiblingKey = function getPrevSiblingKey() {
  33356. return this.get('prevSibling');
  33357. };
  33358. ContentBlockNode.prototype.getNextSiblingKey = function getNextSiblingKey() {
  33359. return this.get('nextSibling');
  33360. };
  33361. ContentBlockNode.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
  33362. findRangesImmutable(this.getCharacterList(), haveEqualStyle, filterFn, callback);
  33363. };
  33364. ContentBlockNode.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
  33365. findRangesImmutable(this.getCharacterList(), haveEqualEntity, filterFn, callback);
  33366. };
  33367. return ContentBlockNode;
  33368. }(Record(defaultRecord));
  33369. module.exports = ContentBlockNode;
  33370. /***/ }),
  33371. /* 33 */
  33372. /***/ (function(module, exports, __webpack_require__) {
  33373. /**
  33374. * Copyright (c) 2013-present, Facebook, Inc.
  33375. * All rights reserved.
  33376. *
  33377. * This source code is licensed under the BSD-style license found in the
  33378. * LICENSE file in the root directory of this source tree. An additional grant
  33379. * of patent rights can be found in the PATENTS file in the same directory.
  33380. *
  33381. * @providesModule generateRandomKey
  33382. * @format
  33383. *
  33384. */
  33385. var seenKeys = {};
  33386. var MULTIPLIER = Math.pow(2, 24);
  33387. function generateRandomKey() {
  33388. var key = void 0;
  33389. while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
  33390. key = Math.floor(Math.random() * MULTIPLIER).toString(32);
  33391. }
  33392. seenKeys[key] = true;
  33393. return key;
  33394. }
  33395. module.exports = generateRandomKey;
  33396. /***/ }),
  33397. /* 34 */
  33398. /***/ (function(module, exports, __webpack_require__) {
  33399. /**
  33400. * Copyright (c) 2013-present, Facebook, Inc.
  33401. * All rights reserved.
  33402. *
  33403. * This source code is licensed under the BSD-style license found in the
  33404. * LICENSE file in the root directory of this source tree. An additional grant
  33405. * of patent rights can be found in the PATENTS file in the same directory.
  33406. *
  33407. * @providesModule removeEntitiesAtEdges
  33408. * @format
  33409. *
  33410. */
  33411. var CharacterMetadata = __webpack_require__(19);
  33412. var findRangesImmutable = __webpack_require__(20);
  33413. var invariant = __webpack_require__(35);
  33414. function removeEntitiesAtEdges(contentState, selectionState) {
  33415. var blockMap = contentState.getBlockMap();
  33416. var entityMap = contentState.getEntityMap();
  33417. var updatedBlocks = {};
  33418. var startKey = selectionState.getStartKey();
  33419. var startOffset = selectionState.getStartOffset();
  33420. var startBlock = blockMap.get(startKey);
  33421. var updatedStart = removeForBlock(entityMap, startBlock, startOffset);
  33422. if (updatedStart !== startBlock) {
  33423. updatedBlocks[startKey] = updatedStart;
  33424. }
  33425. var endKey = selectionState.getEndKey();
  33426. var endOffset = selectionState.getEndOffset();
  33427. var endBlock = blockMap.get(endKey);
  33428. if (startKey === endKey) {
  33429. endBlock = updatedStart;
  33430. }
  33431. var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
  33432. if (updatedEnd !== endBlock) {
  33433. updatedBlocks[endKey] = updatedEnd;
  33434. }
  33435. if (!Object.keys(updatedBlocks).length) {
  33436. return contentState.set('selectionAfter', selectionState);
  33437. }
  33438. return contentState.merge({
  33439. blockMap: blockMap.merge(updatedBlocks),
  33440. selectionAfter: selectionState
  33441. });
  33442. }
  33443. function getRemovalRange(characters, key, offset) {
  33444. var removalRange;
  33445. findRangesImmutable(characters, function (a, b) {
  33446. return a.getEntity() === b.getEntity();
  33447. }, function (element) {
  33448. return element.getEntity() === key;
  33449. }, function (start, end) {
  33450. if (start <= offset && end >= offset) {
  33451. removalRange = { start: start, end: end };
  33452. }
  33453. });
  33454. !(typeof removalRange === 'object') ? invariant(false) : void 0;
  33455. return removalRange;
  33456. }
  33457. function removeForBlock(entityMap, block, offset) {
  33458. var chars = block.getCharacterList();
  33459. var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
  33460. var charAfter = offset < chars.count() ? chars.get(offset) : undefined;
  33461. var entityBeforeCursor = charBefore ? charBefore.getEntity() : undefined;
  33462. var entityAfterCursor = charAfter ? charAfter.getEntity() : undefined;
  33463. if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
  33464. var entity = entityMap.__get(entityAfterCursor);
  33465. if (entity.getMutability() !== 'MUTABLE') {
  33466. var _getRemovalRange = getRemovalRange(chars, entityAfterCursor, offset),
  33467. start = _getRemovalRange.start,
  33468. end = _getRemovalRange.end;
  33469. var current;
  33470. while (start < end) {
  33471. current = chars.get(start);
  33472. chars = chars.set(start, CharacterMetadata.applyEntity(current, null));
  33473. start++;
  33474. }
  33475. return block.set('characterList', chars);
  33476. }
  33477. }
  33478. return block;
  33479. }
  33480. module.exports = removeEntitiesAtEdges;
  33481. /***/ }),
  33482. /* 35 */
  33483. /***/ (function(module, exports, __webpack_require__) {
  33484. function invariant(condition, format, a, b, c, d, e, f) {
  33485. if (!condition) {
  33486. var error;
  33487. if (format === undefined) {
  33488. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  33489. } else {
  33490. var args = [a, b, c, d, e, f];
  33491. var argIndex = 0;
  33492. error = new Error(format.replace(/%s/g, function () {
  33493. return args[argIndex++];
  33494. }));
  33495. error.name = 'Invariant Violation';
  33496. }
  33497. error.framesToPop = 1; // we don't care about invariant's own frame
  33498. throw error;
  33499. }
  33500. }
  33501. module.exports = invariant;
  33502. /***/ }),
  33503. /* 36 */
  33504. /***/ (function(module, exports) {
  33505. function _arrayWithHoles(arr) {
  33506. if (Array.isArray(arr)) return arr;
  33507. }
  33508. module.exports = _arrayWithHoles;
  33509. /***/ }),
  33510. /* 37 */
  33511. /***/ (function(module, exports) {
  33512. function _iterableToArrayLimit(arr, i) {
  33513. var _arr = [];
  33514. var _n = true;
  33515. var _d = false;
  33516. var _e = undefined;
  33517. try {
  33518. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  33519. _arr.push(_s.value);
  33520. if (i && _arr.length === i) break;
  33521. }
  33522. } catch (err) {
  33523. _d = true;
  33524. _e = err;
  33525. } finally {
  33526. try {
  33527. if (!_n && _i["return"] != null) _i["return"]();
  33528. } finally {
  33529. if (_d) throw _e;
  33530. }
  33531. }
  33532. return _arr;
  33533. }
  33534. module.exports = _iterableToArrayLimit;
  33535. /***/ }),
  33536. /* 38 */
  33537. /***/ (function(module, exports) {
  33538. function _nonIterableRest() {
  33539. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  33540. }
  33541. module.exports = _nonIterableRest;
  33542. /***/ }),
  33543. /* 39 */
  33544. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33545. __webpack_require__.r(__webpack_exports__);
  33546. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/typeof.js
  33547. var helpers_typeof = __webpack_require__(15);
  33548. var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);
  33549. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectSpread.js
  33550. var objectSpread = __webpack_require__(5);
  33551. var objectSpread_default = /*#__PURE__*/__webpack_require__.n(objectSpread);
  33552. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectWithoutProperties.js
  33553. var objectWithoutProperties = __webpack_require__(21);
  33554. var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
  33555. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/classCallCheck.js
  33556. var classCallCheck = __webpack_require__(4);
  33557. var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);
  33558. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/createClass.js
  33559. var createClass = __webpack_require__(7);
  33560. var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);
  33561. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js
  33562. var possibleConstructorReturn = __webpack_require__(8);
  33563. var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn);
  33564. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/getPrototypeOf.js
  33565. var getPrototypeOf = __webpack_require__(9);
  33566. var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf);
  33567. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/inherits.js
  33568. var inherits = __webpack_require__(10);
  33569. var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits);
  33570. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/assertThisInitialized.js
  33571. var assertThisInitialized = __webpack_require__(1);
  33572. var assertThisInitialized_default = /*#__PURE__*/__webpack_require__.n(assertThisInitialized);
  33573. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/defineProperty.js
  33574. var defineProperty = __webpack_require__(2);
  33575. var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
  33576. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/toConsumableArray.js
  33577. var toConsumableArray = __webpack_require__(12);
  33578. var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
  33579. // EXTERNAL MODULE: ../node_modules/draft-js/dist/Draft.css
  33580. var Draft = __webpack_require__(40);
  33581. // EXTERNAL MODULE: ./assets/scss/_base.scss
  33582. var _base = __webpack_require__(42);
  33583. // EXTERNAL MODULE: external "react"
  33584. var external_react_ = __webpack_require__(0);
  33585. var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
  33586. // CONCATENATED MODULE: ./languages/en.js
  33587. /* harmony default export */ var en = ({
  33588. base: {
  33589. remove: 'Remove',
  33590. cancel: 'Cancel',
  33591. confirm: 'Confirm',
  33592. inert: 'Insert',
  33593. width: 'Width',
  33594. height: 'Height'
  33595. },
  33596. controls: {
  33597. clear: 'Clear',
  33598. undo: 'Undo',
  33599. redo: 'Redo',
  33600. fontSize: 'Font Size',
  33601. color: 'Color',
  33602. textColor: 'Text',
  33603. tempColors: 'Temp Colors',
  33604. backgroundColor: 'Background',
  33605. bold: 'Bold',
  33606. lineHeight: 'Line Height',
  33607. letterSpacing: 'Letter Spacing',
  33608. textIndent: 'Text Indent',
  33609. increaseIndent: 'Increase Indent',
  33610. decreaseIndent: 'Decrease Indent',
  33611. italic: 'Italic',
  33612. underline: 'Underline',
  33613. strikeThrough: 'Strike Through',
  33614. fontFamily: 'Font Family',
  33615. textAlign: 'Text Alignment',
  33616. alignLeft: 'Left Alignment',
  33617. alignCenter: 'Center Alignment',
  33618. alignRight: 'Right Alignment',
  33619. alignJustify: 'Justify Alignment',
  33620. floatLeft: 'Left Float',
  33621. floatRight: 'Right Float',
  33622. superScript: 'Super Script',
  33623. subScript: 'Sub Script',
  33624. removeStyles: 'Remove Styles',
  33625. headings: 'Headings',
  33626. header: 'Header',
  33627. normal: 'Normal',
  33628. orderedList: 'Ordered List',
  33629. unorderedList: 'Unordered List',
  33630. blockQuote: 'Quote',
  33631. code: 'Code',
  33632. link: 'Link',
  33633. unlink: 'Unlink',
  33634. hr: 'Horizontal Line',
  33635. media: 'Media',
  33636. mediaLibirary: 'Media Library',
  33637. emoji: 'Emoji',
  33638. fullscreen: 'Fullscreen',
  33639. exitFullscreen: 'Exit Fullscreen'
  33640. },
  33641. linkEditor: {
  33642. textInputPlaceHolder: 'Input link text',
  33643. linkInputPlaceHolder: 'Input link URL',
  33644. inputWithEnterPlaceHolder: 'Input link URL and press Enter',
  33645. openInNewWindow: 'Open in new window',
  33646. removeLink: 'Remove Link'
  33647. },
  33648. audioPlayer: {
  33649. title: 'Play Audio'
  33650. },
  33651. videoPlayer: {
  33652. title: 'Play Video',
  33653. embedTitle: 'Embed Media'
  33654. },
  33655. media: {
  33656. image: 'Image',
  33657. video: 'Video',
  33658. audio: 'Audio',
  33659. embed: 'Embed'
  33660. }
  33661. });
  33662. // CONCATENATED MODULE: ./languages/zh.js
  33663. /* harmony default export */ var zh = ({
  33664. base: {
  33665. remove: '删除',
  33666. cancel: '取消',
  33667. confirm: '确定',
  33668. inert: '插入',
  33669. width: '宽度',
  33670. height: '高度'
  33671. },
  33672. controls: {
  33673. clear: '清除内容',
  33674. undo: '撤销',
  33675. redo: '重做',
  33676. fontSize: '字号',
  33677. lineHeight: '行高',
  33678. letterSpacing: '字间距',
  33679. textIndent: '段落缩进',
  33680. increaseIndent: '增加缩进',
  33681. decreaseIndent: '减少缩进',
  33682. border: '边框',
  33683. color: '颜色',
  33684. textColor: '文字颜色',
  33685. backgroundColor: '背景颜色',
  33686. tempColors: '临时颜色',
  33687. bold: '加粗',
  33688. italic: '斜体',
  33689. underline: '下划线',
  33690. strikeThrough: '删除线',
  33691. fontFamily: '字体',
  33692. textAlign: '文本对齐',
  33693. alignLeft: '居左',
  33694. alignCenter: '居中',
  33695. alignRight: '居右',
  33696. alignJustify: '两端',
  33697. floatLeft: '左浮动',
  33698. floatRight: '右浮动',
  33699. superScript: '上标',
  33700. subScript: '下标',
  33701. removeStyles: '清除样式',
  33702. headings: '标题',
  33703. header: '标题',
  33704. normal: '常规',
  33705. orderedList: '有序列表',
  33706. unorderedList: '无序列表',
  33707. blockQuote: '引用',
  33708. code: '代码',
  33709. link: '链接',
  33710. unlink: '清除链接',
  33711. hr: '水平线',
  33712. media: '媒体',
  33713. mediaLibirary: '媒体库',
  33714. emoji: '小表情',
  33715. fullscreen: '全屏',
  33716. exitFullscreen: '退出全屏'
  33717. },
  33718. linkEditor: {
  33719. textInputPlaceHolder: '输入链接文字',
  33720. linkInputPlaceHolder: '输入链接地址',
  33721. inputWithEnterPlaceHolder: '输入链接地址并回车',
  33722. openInNewWindow: '在新窗口打开',
  33723. removeLink: '移除链接'
  33724. },
  33725. audioPlayer: {
  33726. title: '播放音频文件'
  33727. },
  33728. videoPlayer: {
  33729. title: '播放视频文件',
  33730. embedTitle: '嵌入式媒体'
  33731. },
  33732. media: {
  33733. image: '图像',
  33734. video: '视频',
  33735. audio: '音频',
  33736. embed: '嵌入式媒体'
  33737. }
  33738. });
  33739. // CONCATENATED MODULE: ./languages/zh-hant.js
  33740. /* harmony default export */ var zh_hant = ({
  33741. base: {
  33742. remove: '刪除',
  33743. cancel: '取消',
  33744. confirm: '確定',
  33745. inert: '插入',
  33746. width: '宽度',
  33747. height: '高度'
  33748. },
  33749. controls: {
  33750. clear: '清除内容',
  33751. undo: '撤銷',
  33752. redo: '重做',
  33753. fontSize: '字號',
  33754. color: '顏色',
  33755. textColor: '文字顏色',
  33756. backgroundColor: '背景顏色',
  33757. tempColors: '臨時顏色',
  33758. bold: '加粗',
  33759. lineHeight: '行高',
  33760. letterSpacing: '字間距',
  33761. textIndent: '段落縮進',
  33762. increaseIndent: '增加縮進',
  33763. decreaseIndent: '减少縮進',
  33764. border: '邊框',
  33765. italic: '斜體',
  33766. underline: '下劃線',
  33767. strikeThrough: '刪除線',
  33768. fontFamily: '字體',
  33769. textAlign: '文本對齊',
  33770. alignLeft: '居左',
  33771. alignCenter: '居中',
  33772. alignRight: '居右',
  33773. alignJustify: '兩端對齊',
  33774. floatLeft: '左浮動',
  33775. floatRight: '右浮動',
  33776. superScript: '上標',
  33777. subScript: '下標',
  33778. removeStyles: '清除样式',
  33779. headings: '標題',
  33780. header: '標題',
  33781. normal: '常規',
  33782. orderedList: '有序列表',
  33783. unorderedList: '無序列表',
  33784. blockQuote: '引用',
  33785. code: '代碼',
  33786. link: '鏈接',
  33787. unlink: '清除鏈接',
  33788. hr: '水平线',
  33789. media: '媒體',
  33790. mediaLibirary: '媒體库',
  33791. emoji: '小表情',
  33792. fullscreen: '全熒幕',
  33793. exitFullscreen: '退出全熒幕'
  33794. },
  33795. linkEditor: {
  33796. textInputPlaceHolder: '輸入鏈接文字',
  33797. linkInputPlaceHolder: '輸入鏈接地址',
  33798. inputWithEnterPlaceHolder: '輸入鏈接地址並回車',
  33799. openInNewWindow: '在新窗口打開',
  33800. removeLink: '移除鏈接'
  33801. },
  33802. audioPlayer: {
  33803. title: '播放音頻文件'
  33804. },
  33805. videoPlayer: {
  33806. title: '播放視頻文件',
  33807. embedTitle: '嵌入式媒體'
  33808. },
  33809. media: {
  33810. image: '圖像',
  33811. video: '視頻',
  33812. audio: '音頻',
  33813. embed: '嵌入式媒體'
  33814. }
  33815. });
  33816. // CONCATENATED MODULE: ./languages/pl.js
  33817. /* harmony default export */ var pl = ({
  33818. base: {
  33819. remove: 'Usuń',
  33820. cancel: 'Anuluj',
  33821. confirm: 'Potwierdź',
  33822. inert: 'Wstaw',
  33823. width: 'Szerokość',
  33824. height: 'Wysokość'
  33825. },
  33826. controls: {
  33827. clear: 'Wyczyść',
  33828. undo: 'Cofnij',
  33829. redo: 'Przywróć',
  33830. fontSize: 'Wielkość',
  33831. color: 'Kolor',
  33832. textColor: 'Kolor tekstu',
  33833. tempColors: 'Kolory',
  33834. backgroundColor: 'Tło',
  33835. bold: 'Pogrubienie',
  33836. lineHeight: 'Wysokość linii',
  33837. letterSpacing: 'Odstęp znaków',
  33838. textIndent: 'Wcięcie tekstu',
  33839. increaseIndent: 'Zwiększ wcięcie',
  33840. decreaseIndent: 'Zmniejsz wcięcie',
  33841. italic: 'Italiki',
  33842. underline: 'Podkreślenie',
  33843. strikeThrough: 'Przekreślenie',
  33844. fontFamily: 'Czcionka',
  33845. textAlign: 'Wyrównanie tekstu',
  33846. alignLeft: 'Do lewej',
  33847. alignCenter: 'Wycentruj',
  33848. alignRight: 'Do prawej',
  33849. alignJustify: 'Wyjustuj',
  33850. floatLeft: 'Do lewej',
  33851. floatRight: 'Do prawej',
  33852. superScript: 'Superskrypt',
  33853. subScript: 'Subskrypt',
  33854. removeStyles: 'Usuń stylowanie',
  33855. headings: 'Nagłówki',
  33856. header: 'Nagłówek',
  33857. normal: 'Normalny',
  33858. orderedList: 'Lista uporządkowana',
  33859. unorderedList: 'Lista nieuporządkowana',
  33860. blockQuote: 'Cytat',
  33861. code: 'Kod',
  33862. link: 'Link',
  33863. unlink: 'Usuń link',
  33864. hr: 'Linia pozioma',
  33865. media: 'Media',
  33866. mediaLibirary: 'Biblioteka mediów',
  33867. emoji: 'Emoji'
  33868. },
  33869. linkEditor: {
  33870. textInputPlaceHolder: 'Wpisz tekst linku',
  33871. linkInputPlaceHolder: 'Wpisz Adres URL',
  33872. inputWithEnterPlaceHolder: 'Wpisz adres URL i naciśnij Enter',
  33873. openInNewWindow: 'Otwórz w nowym oknie',
  33874. removeLink: 'Usuń link'
  33875. },
  33876. audioPlayer: {
  33877. title: 'Odtwórz audio'
  33878. },
  33879. videoPlayer: {
  33880. title: 'Odtwórz wideo',
  33881. embedTitle: 'Tytuł'
  33882. },
  33883. media: {
  33884. image: 'Obraz',
  33885. video: 'Wideo',
  33886. audio: 'Audio',
  33887. embed: 'Obiekt osadzony'
  33888. }
  33889. });
  33890. // CONCATENATED MODULE: ./languages/kr.js
  33891. /* harmony default export */ var kr = ({
  33892. base: {
  33893. remove: '삭제',
  33894. cancel: '취소',
  33895. confirm: '결정',
  33896. inert: '삽입',
  33897. width: '너비',
  33898. height: '높이'
  33899. },
  33900. controls: {
  33901. clear: '콘텐츠지우기',
  33902. undo: '취소',
  33903. redo: '다시하기',
  33904. fontSize: '글자크기',
  33905. lineHeight: '행높이',
  33906. letterSpacing: '단어간격',
  33907. textIndent: '단락들여쓰기',
  33908. increaseIndent: '들여쓰기늘리기',
  33909. decreaseIndent: '들여쓰기줄이기',
  33910. border: '국경',
  33911. color: '색상',
  33912. textColor: '텍스트색상',
  33913. backgroundColor: '배경색상',
  33914. tempColors: '임시색',
  33915. bold: '굵게',
  33916. italic: '기울임꼴',
  33917. underline: '밑줄',
  33918. strikeThrough: '취소선',
  33919. fontFamily: '글꼴',
  33920. textAlign: '텍스트정렬',
  33921. alignLeft: '왼쪽',
  33922. alignCenter: '중심',
  33923. alignRight: '오른쪽',
  33924. alignJustify: '양쪽끝',
  33925. floatLeft: '떠다니기',
  33926. floatRight: '오른쪽부동',
  33927. superScript: '위첨자',
  33928. subScript: '첨자',
  33929. removeStyles: '스타일지우기',
  33930. headings: '제목',
  33931. header: '제목',
  33932. normal: '재래식',
  33933. orderedList: '순서가지정된목록',
  33934. unorderedList: '정렬되지않은목록',
  33935. blockQuote: '참고문헌',
  33936. code: '코드',
  33937. link: '링크',
  33938. unlink: '링크삭제',
  33939. hr: '수평선',
  33940. media: '미디어',
  33941. mediaLibirary: '미디어라이브러리',
  33942. emoji: '작은표현',
  33943. fullscreen: '전체화면',
  33944. exitFullscreen: '전체화면종료'
  33945. },
  33946. linkEditor: {
  33947. textInputPlaceHolder: '링크텍스트입력',
  33948. linkInputPlaceHolder: '링크주소입력',
  33949. inputWithEnterPlaceHolder: '링크주소입력.',
  33950. openInNewWindow: '새창열기',
  33951. removeLink: '링크삭제'
  33952. },
  33953. audioPlayer: {
  33954. title: '오디오파일재생'
  33955. },
  33956. videoPlayer: {
  33957. title: '비디오파일재생',
  33958. embedTitle: '임베디드미디어'
  33959. },
  33960. media: {
  33961. image: '이미지',
  33962. video: '비디오',
  33963. audio: '오디오',
  33964. embed: '임베디드미디어'
  33965. }
  33966. });
  33967. // CONCATENATED MODULE: ./languages/tr.js
  33968. /* harmony default export */ var tr = ({
  33969. base: {
  33970. remove: 'Kaldır',
  33971. cancel: 'İptal',
  33972. confirm: 'Onayla',
  33973. inert: 'Ekle',
  33974. width: 'Genişlik',
  33975. height: 'Yükseklik'
  33976. },
  33977. controls: {
  33978. clear: 'Temizle',
  33979. undo: 'Geri al',
  33980. redo: 'İleri al',
  33981. fontSize: 'Yazı boyutu',
  33982. color: 'Renk',
  33983. textColor: 'Yazı rengi',
  33984. tempColors: 'Geçici renkler',
  33985. backgroundColor: 'Arkaplan',
  33986. bold: 'Kalın',
  33987. lineHeight: 'Satır yüksekliği',
  33988. letterSpacing: 'Harf aralığı',
  33989. textIndent: 'Çentik aralığı',
  33990. increaseIndent: 'Çentiği genişlet',
  33991. decreaseIndent: 'Çentiği daralt',
  33992. italic: 'Eğik',
  33993. underline: 'Altı çizili',
  33994. strikeThrough: 'Üstü çizili',
  33995. fontFamily: 'Yazı tipi',
  33996. textAlign: 'Metin Hizalama',
  33997. alignLeft: 'Sola hizala',
  33998. alignCenter: 'Ortaya hizala',
  33999. alignRight: 'Sağa hizala',
  34000. alignJustify: 'Her iki tarafa hizala',
  34001. floatLeft: 'Sola yatır',
  34002. floatRight: 'Sağa yatır',
  34003. superScript: 'Ana kod',
  34004. subScript: 'Alt kod',
  34005. removeStyles: 'Stilleri kaldır',
  34006. headings: 'Başlıklar',
  34007. header: 'Başlık',
  34008. normal: 'Normal',
  34009. orderedList: 'Sıralı liste',
  34010. unorderedList: 'Sırasız liste',
  34011. blockQuote: 'Alıntı',
  34012. code: 'Kod',
  34013. link: 'Bağlantı',
  34014. unlink: 'Bağlantıyı kaldır',
  34015. hr: 'Yatay çizgi',
  34016. media: 'Medya',
  34017. mediaLibirary: 'Kütüphane',
  34018. emoji: 'İfade',
  34019. fullscreen: 'Tam ekran',
  34020. exitFullscreen: 'Tam ekrandan çık'
  34021. },
  34022. linkEditor: {
  34023. textInputPlaceHolder: 'Bağlantı metnini girin',
  34024. linkInputPlaceHolder: 'Bağlantı URL\' si girin',
  34025. inputWithEnterPlaceHolder: 'Bağlantı URL\'si girin ve Enter\' a basın',
  34026. openInNewWindow: 'Yeni pencerede aç',
  34027. removeLink: 'Bağlantıyı kaldır'
  34028. },
  34029. audioPlayer: {
  34030. title: 'Ses çal'
  34031. },
  34032. videoPlayer: {
  34033. title: 'Görüntü oynat',
  34034. embedTitle: 'Görüntüyü göm'
  34035. },
  34036. media: {
  34037. image: 'Resim',
  34038. video: 'Görüntü',
  34039. audio: 'Ses',
  34040. embed: 'Gömülü nesne'
  34041. }
  34042. });
  34043. // CONCATENATED MODULE: ./languages/jpn.js
  34044. /* harmony default export */ var jpn = ({
  34045. base: {
  34046. remove: '削除',
  34047. cancel: 'キャンセル',
  34048. confirm: '決定',
  34049. inert: '挿入',
  34050. width: '幅',
  34051. height: '高さ'
  34052. },
  34053. controls: {
  34054. clear: 'クリアコンテンツ',
  34055. undo: 'キャンセル',
  34056. redo: 'キャンセル',
  34057. fontSize: 'フォントサイズ',
  34058. lineHeight: 'フォントサイズ',
  34059. letterSpacing: 'ワード間隔',
  34060. textIndent: '段落のインデント',
  34061. increaseIndent: 'インデントを増やす',
  34062. decreaseIndent: 'インデントを減らす',
  34063. border: '国境',
  34064. color: '色',
  34065. textColor: 'テキストの色',
  34066. backgroundColor: '背景色',
  34067. tempColors: '仮色',
  34068. bold: '太字',
  34069. italic: 'イタリック体',
  34070. underline: '下線',
  34071. strikeThrough: '取り消し線',
  34072. fontFamily: 'フォント',
  34073. textAlign: 'テキストの配置',
  34074. alignLeft: '左',
  34075. alignCenter: '中央揃え',
  34076. alignRight: '右に立つ',
  34077. alignJustify: '両端',
  34078. floatLeft: '左フローティング',
  34079. floatRight: '右フローティング',
  34080. superScript: '上付き',
  34081. subScript: '下付き文字',
  34082. removeStyles: 'クリアスタイル',
  34083. headings: '役職',
  34084. header: '役職',
  34085. normal: '従来の',
  34086. orderedList: '順序付きリスト',
  34087. unorderedList: '番号なしリスト',
  34088. blockQuote: '参照',
  34089. code: 'コード',
  34090. link: 'リンク',
  34091. unlink: 'リンクを解除',
  34092. hr: '横線',
  34093. media: 'メディア',
  34094. mediaLibirary: 'メディアライブラリー',
  34095. emoji: '小さな表現',
  34096. fullscreen: '全画面',
  34097. exitFullscreen: '全画面を退く'
  34098. },
  34099. linkEditor: {
  34100. textInputPlaceHolder: 'リンクテキストを入力',
  34101. linkInputPlaceHolder: 'リンクアドレスを入力',
  34102. inputWithEnterPlaceHolder: 'リンクアドレスを入力して戻ります',
  34103. openInNewWindow: '新しいウィンドウで開く',
  34104. removeLink: '新しいウィンドウで開く'
  34105. },
  34106. audioPlayer: {
  34107. title: 'オーディオファイルを再生する'
  34108. },
  34109. videoPlayer: {
  34110. title: 'ビデオファイルを再生する',
  34111. embedTitle: '埋め込みメディア'
  34112. },
  34113. media: {
  34114. image: '画像',
  34115. video: 'ビデオ',
  34116. audio: '音声',
  34117. embed: '埋め込みメディア'
  34118. }
  34119. });
  34120. // CONCATENATED MODULE: ./languages/ru.js
  34121. /* harmony default export */ var ru = ({
  34122. base: {
  34123. remove: 'Удалить',
  34124. cancel: 'Отмена',
  34125. confirm: 'Подтвердить',
  34126. insert: 'Вставить',
  34127. width: 'Ширина',
  34128. height: 'Высота'
  34129. },
  34130. controls: {
  34131. clear: 'Очистить',
  34132. undo: 'Отменить',
  34133. redo: 'Повторить',
  34134. fontSize: 'Размер шрифта',
  34135. color: 'Цвет',
  34136. textColor: 'Цвет текста',
  34137. tempColors: 'Temp Colors',
  34138. backgroundColor: 'Цвет фона',
  34139. bold: 'Жирный',
  34140. lineHeight: 'Межстрочный интервал',
  34141. letterSpacing: 'Межбуквенный интервал',
  34142. textIndent: 'Отступ',
  34143. increaseIndent: 'Увеличить отступ',
  34144. decreaseIndent: 'Уменьшить отступ',
  34145. italic: 'Курсив',
  34146. underline: 'Подчеркнутый',
  34147. strikeThrough: 'Перечеркнутый',
  34148. fontFamily: 'Шрифт',
  34149. textAlign: 'Расположение текста',
  34150. alignLeft: 'По левому краю',
  34151. alignCenter: 'По центру',
  34152. alignRight: 'По правому краю',
  34153. alignJustify: 'По ширине',
  34154. floatLeft: 'Обтекание слева',
  34155. floatRight: 'Обтекание справа',
  34156. superScript: 'Надстрочный индекс',
  34157. subScript: 'Подстрочный индекс',
  34158. removeStyles: 'Убрать стили',
  34159. headings: 'Заголовки',
  34160. header: 'Заголовок',
  34161. normal: 'Обычный',
  34162. orderedList: 'Упорядоченный список',
  34163. unorderedList: 'Неупорядоченный список',
  34164. blockQuote: 'Цитата',
  34165. code: 'Код',
  34166. link: 'Вставить ссылку',
  34167. unlink: 'Убрать ссылку',
  34168. hr: 'Горизонтальная линия',
  34169. media: 'Медиа',
  34170. mediaLibirary: 'Медиа библиотека',
  34171. emoji: 'Emoji',
  34172. fullscreen: 'Полноэкранный режим',
  34173. exitFullscreen: 'Выйти из полноэкранного режима'
  34174. },
  34175. linkEditor: {
  34176. textInputPlaceHolder: 'Введите текст ссылки',
  34177. linkInputPlaceHolder: 'Вставить ссылку',
  34178. inputWithEnterPlaceHolder: 'Вставить ссылку и нажать Enter',
  34179. openInNewWindow: 'Открыть в новом окне',
  34180. removeLink: 'Убрать ссылку'
  34181. },
  34182. audioPlayer: {
  34183. title: 'Воспроизвести аудиофайл'
  34184. },
  34185. videoPlayer: {
  34186. title: 'Воспроизвести видеофайл',
  34187. embedTitle: 'Embed Media'
  34188. },
  34189. media: {
  34190. image: 'Картинка',
  34191. video: 'Видео',
  34192. audio: 'Аудио',
  34193. embed: 'Встроенное'
  34194. }
  34195. });
  34196. // CONCATENATED MODULE: ./languages/fr.js
  34197. /* harmony default export */ var fr = ({
  34198. base: {
  34199. remove: 'Supprimer',
  34200. cancel: 'Annuler',
  34201. confirm: 'Confirmer',
  34202. inert: 'Insérer',
  34203. width: 'Largeur',
  34204. height: 'Hauteur'
  34205. },
  34206. controls: {
  34207. clear: 'Effacer',
  34208. undo: 'Annuler',
  34209. redo: 'Refaire',
  34210. fontSize: 'Taille de police',
  34211. color: 'Couleur',
  34212. textColor: 'Texte',
  34213. tempColors: 'Couleurs temporaire',
  34214. backgroundColor: 'Couleur d\'arrière plan',
  34215. bold: 'Gras',
  34216. lineHeight: 'Hauteur de ligne',
  34217. letterSpacing: 'Espacement des lettres',
  34218. textIndent: 'Indentation du texte',
  34219. increaseIndent: 'Augmenter l\'indentation',
  34220. decreaseIndent: 'Réduire l\'indentation',
  34221. italic: 'Italique',
  34222. underline: 'Souligner',
  34223. strikeThrough: 'Barrer',
  34224. fontFamily: 'Police d\'écriture',
  34225. textAlign: 'Alignement du texte',
  34226. alignLeft: 'Aligner à gauche',
  34227. alignCenter: 'Aligner au centre',
  34228. alignRight: 'Aligner à droite',
  34229. alignJustify: 'Justifier',
  34230. floatLeft: 'Déplacer à gauche',
  34231. floatRight: 'Déplacer à droite',
  34232. superScript: 'Super-script',
  34233. subScript: 'Sous-script',
  34234. removeStyles: 'Supprimer les styles',
  34235. headings: 'Titres',
  34236. header: 'Entêtes',
  34237. normal: 'Normal',
  34238. orderedList: 'Liste ordonnée',
  34239. unorderedList: 'Liste non-ordonnée',
  34240. blockQuote: 'Citation',
  34241. code: 'Code',
  34242. link: 'Insérer un lien',
  34243. unlink: 'Supprimer le lien',
  34244. hr: 'Ligne horizontale',
  34245. media: 'Média',
  34246. mediaLibirary: 'Bibliothêque',
  34247. emoji: 'Emoji',
  34248. fullscreen: 'Plein écran',
  34249. exitFullscreen: 'Quitter le plein écran'
  34250. },
  34251. linkEditor: {
  34252. textInputPlaceHolder: 'Insérer le texte à afficher',
  34253. linkInputPlaceHolder: 'Insérer le lien URL',
  34254. inputWithEnterPlaceHolder: 'Insérer le lien URL puis appuyer sur Entrée',
  34255. openInNewWindow: 'Ouvrir dans une nouvelle fenêtre',
  34256. removeLink: 'Supprimer le lien'
  34257. },
  34258. audioPlayer: {
  34259. title: 'Lancer le son audio'
  34260. },
  34261. videoPlayer: {
  34262. title: 'Lancer la video',
  34263. embedTitle: 'Intégrer média'
  34264. },
  34265. media: {
  34266. image: 'Image',
  34267. video: 'Vidéo',
  34268. audio: 'Audio',
  34269. embed: 'Intégré'
  34270. }
  34271. });
  34272. // CONCATENATED MODULE: ./languages/pt-br.js
  34273. /* harmony default export */ var pt_br = ({
  34274. base: {
  34275. remove: 'Remover',
  34276. cancel: 'Cancelar',
  34277. confirm: 'Confirmar',
  34278. inert: 'Inserir',
  34279. width: 'Largura',
  34280. height: 'Altura'
  34281. },
  34282. controls: {
  34283. clear: 'Limpar',
  34284. undo: 'Desfazer',
  34285. redo: 'Refazer',
  34286. fontSize: 'Tamanho da Fonte',
  34287. color: 'Cor',
  34288. textColor: 'Texto',
  34289. tempColors: 'Temp Colors',
  34290. backgroundColor: 'Cor de Fundo',
  34291. bold: 'Negrito',
  34292. lineHeight: 'Altura da LinhaLine Height',
  34293. letterSpacing: 'Espaçamento entre Letras',
  34294. textIndent: 'Identação de Texto',
  34295. increaseIndent: 'Aumentar Identação',
  34296. decreaseIndent: 'Diminuir Identção',
  34297. italic: 'Itálico',
  34298. underline: 'Sublinhado',
  34299. strikeThrough: 'Riscado',
  34300. fontFamily: 'Família da Fonte',
  34301. textAlign: 'Alinhamento de Texto',
  34302. alignLeft: 'Alinhamento à Esquerda',
  34303. alignCenter: 'Alinhamento Centralizado',
  34304. alignRight: 'Alinhamento à Direita',
  34305. alignJustify: 'Alinhamento Justificado',
  34306. floatLeft: 'Flutuação à Esquerda',
  34307. floatRight: 'Flutuação à Direita',
  34308. superScript: 'Sobrescrito',
  34309. subScript: 'Subscrito',
  34310. removeStyles: 'Remover Estilos',
  34311. headings: 'Cabeçalhos',
  34312. header: 'Cabeçalho',
  34313. normal: 'Normal',
  34314. orderedList: 'Lista Ordenada',
  34315. unorderedList: 'Lista Não Ordenada',
  34316. blockQuote: 'Citação',
  34317. code: 'Código',
  34318. link: 'Link',
  34319. unlink: 'Remover Link',
  34320. hr: 'Linha Horizontal',
  34321. media: 'Mídia',
  34322. mediaLibirary: 'Biblioteca de Mídia',
  34323. emoji: 'Emoji',
  34324. fullscreen: 'Tela Cheia',
  34325. exitFullscreen: 'Sair de Tela Cheia'
  34326. },
  34327. linkEditor: {
  34328. textInputPlaceHolder: 'Insira o texto do link',
  34329. linkInputPlaceHolder: 'Insira a URL do link',
  34330. inputWithEnterPlaceHolder: 'Insira a URL do link e aperte Enter',
  34331. openInNewWindow: 'Abrir em nova janela',
  34332. removeLink: 'Remover Link'
  34333. },
  34334. audioPlayer: {
  34335. title: 'Tocar Áudio'
  34336. },
  34337. videoPlayer: {
  34338. title: 'Tocar Vídeo',
  34339. embedTitle: 'Mídia Embutida'
  34340. },
  34341. media: {
  34342. image: 'Imagem',
  34343. video: 'Vídeo',
  34344. audio: 'Áudio',
  34345. embed: 'Embutido'
  34346. }
  34347. });
  34348. // CONCATENATED MODULE: ./languages/index.js
  34349. /* harmony default export */ var languages = ({
  34350. 'en': en,
  34351. 'zh': zh,
  34352. 'zh-hant': zh_hant,
  34353. 'pl': pl,
  34354. 'kr': kr,
  34355. 'tr': tr,
  34356. 'jpn': jpn,
  34357. 'ru': ru,
  34358. 'fr': fr,
  34359. 'pt-br': pt_br
  34360. });
  34361. // EXTERNAL MODULE: external "braft-finder"
  34362. var external_braft_finder_ = __webpack_require__(17);
  34363. var external_braft_finder_default = /*#__PURE__*/__webpack_require__.n(external_braft_finder_);
  34364. // EXTERNAL MODULE: external "braft-utils"
  34365. var external_braft_utils_ = __webpack_require__(3);
  34366. // EXTERNAL MODULE: external "draft-js"
  34367. var external_draft_js_ = __webpack_require__(6);
  34368. // EXTERNAL MODULE: external "immutable"
  34369. var external_immutable_ = __webpack_require__(13);
  34370. var external_immutable_default = /*#__PURE__*/__webpack_require__.n(external_immutable_);
  34371. // CONCATENATED MODULE: ./configs/keybindings.js
  34372. // TODO
  34373. // 允许自定义的快捷键设置
  34374. /* harmony default export */ var keybindings = (function (customKeyBindingFn) {
  34375. return function (event) {
  34376. if (event.keyCode === 83 && (external_draft_js_["KeyBindingUtil"].hasCommandModifier(event) || external_draft_js_["KeyBindingUtil"].isCtrlKeyCommand(event))) {
  34377. return 'braft-save';
  34378. }
  34379. if (customKeyBindingFn) {
  34380. return customKeyBindingFn(event) || Object(external_draft_js_["getDefaultKeyBinding"])(event);
  34381. }
  34382. return Object(external_draft_js_["getDefaultKeyBinding"])(event);
  34383. };
  34384. });
  34385. // CONCATENATED MODULE: ./configs/props.js
  34386. /* harmony default export */ var configs_props = ({
  34387. language: 'zh',
  34388. controls: ['undo', 'redo', 'separator', 'font-size', 'line-height', 'letter-spacing', 'separator', 'text-color', 'bold', 'italic', 'underline', 'strike-through', 'separator', 'superscript', 'subscript', 'remove-styles', 'emoji', 'separator', 'text-indent', 'text-align', 'separator', 'headings', 'list-ul', 'list-ol', 'blockquote', 'code', 'separator', 'media', 'link', 'table', 'split', 'hr', 'separator', 'clear', 'separator', 'fullscreen'],
  34389. excludeControls: [],
  34390. extendControls: [],
  34391. extendAtomics: [],
  34392. componentBelowControlBar: null,
  34393. media: {
  34394. pasteImage: true,
  34395. imagePasteLimit: 5,
  34396. image: true,
  34397. video: true,
  34398. audio: true,
  34399. uploadFn: null,
  34400. validateFn: null,
  34401. onBeforeDeselect: null,
  34402. onDeselect: null,
  34403. onBeforeSelect: null,
  34404. onSelect: null,
  34405. onBeforeRemove: null,
  34406. onRemove: null,
  34407. onCancel: null,
  34408. onFileSelect: null,
  34409. onBeforeInsert: null,
  34410. onInsert: null,
  34411. onChange: null,
  34412. accepts: {
  34413. image: 'image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg',
  34414. video: 'video/mp4',
  34415. audio: 'audio/mp3'
  34416. },
  34417. externals: {
  34418. audio: true,
  34419. video: true,
  34420. image: true,
  34421. embed: true
  34422. }
  34423. },
  34424. imageControls: ['float-left', 'float-right', 'align-left', 'align-center', 'align-right', 'link', 'size', 'remove'],
  34425. imageResizable: true,
  34426. colors: ['#000000', '#333333', '#666666', '#999999', '#cccccc', '#ffffff', '#61a951', '#16a085', '#07a9fe', '#003ba5', '#8e44ad', '#f32784', '#c0392b', '#d35400', '#f39c12', '#fdda00'],
  34427. colorPicker: null,
  34428. colorPickerTheme: 'dark',
  34429. colorPickerAutoHide: true,
  34430. codeTabIndents: 2,
  34431. headings: ['header-one', 'header-two', 'header-three', 'header-four', 'header-five', 'header-six', 'unstyled'],
  34432. textAligns: ['left', 'center', 'right', 'justify'],
  34433. textBackgroundColor: true,
  34434. allowInsertLinkText: false,
  34435. defaultLinkTarget: '',
  34436. letterSpacings: [0, 1, 2, 3, 4, 5, 6],
  34437. lineHeights: [1, 1.2, 1.5, 1.75, 2, 2.5, 3, 4],
  34438. fontSizes: [12, 14, 16, 18, 20, 24, 28, 30, 32, 36, 40, 48, 56, 64, 72, 96, 120, 144],
  34439. fontFamilies: [{
  34440. name: 'Araial',
  34441. family: 'Arial, Helvetica, sans-serif'
  34442. }, {
  34443. name: 'Georgia',
  34444. family: 'Georgia, serif'
  34445. }, {
  34446. name: 'Impact',
  34447. family: 'Impact, serif'
  34448. }, {
  34449. name: 'Monospace',
  34450. family: '"Courier New", Courier, monospace'
  34451. }, {
  34452. name: 'Tahoma',
  34453. family: 'tahoma, arial, "Hiragino Sans GB", 宋体, sans-serif'
  34454. }],
  34455. converts: {
  34456. unitExportFn: function unitExportFn(value, type) {
  34457. return type === 'line-height' ? value : "".concat(value, "px");
  34458. }
  34459. },
  34460. emojis: ['🤣', '🙌', '💚', '💛', '👏', '😉', '💯', '💕', '💞', '💘', '💙', '💝', '🖤', '💜', '❤️', '😍', '😻', '💓', '💗', '😋', '😇', '😂', '😹', '😘', '💖', '😁', '😀', '🤞', '😲', '😄', '😊', '👍', '😌', '😃', '😅', '✌️', '🤗', '💋', '😗', '😽', '😚', '🤠', '😙', '😺', '👄', '😸', '😏', '😼', '👌', '😎', '😆', '😛', '🙏', '🤝', '🙂', '🤑', '😝', '😐', '😑', '🤤', '😤', '🙃', '🤡', '😶', '😪', '😴', '😵', '😓', '👊', '😦', '😷', '🤐', '😜', '🤓', '👻', '😥', '🙄', '🤔', '🤒', '🙁', '😔', '😯', '☹️', '☠️', '😰', '😩', '😖', '😕', '😒', '😣', '😢', '😮', '😿', '🤧', '😫', '🤥', '😞', '😬', '👎', '💀', '😳', '😨', '🤕', '🤢', '😱', '😭', '😠', '😈', '😧', '💔', '😟', '🙀', '💩', '👿', '😡', '😾', '🖕'],
  34461. stripPastedStyles: false,
  34462. triggerChangeOnMount: true,
  34463. className: '',
  34464. style: {},
  34465. controlBarClassName: '',
  34466. controlBarStyle: {},
  34467. contentClassName: '',
  34468. contentStyle: {},
  34469. draftProps: {},
  34470. hooks: {},
  34471. onChange: null,
  34472. onFocus: null,
  34473. onBlur: null,
  34474. onTab: null,
  34475. onDelete: null,
  34476. onSave: null,
  34477. fixPlaceholder: false
  34478. });
  34479. // EXTERNAL MODULE: ../node_modules/draft-js/lib/getFragmentFromSelection.js
  34480. var getFragmentFromSelection = __webpack_require__(22);
  34481. var getFragmentFromSelection_default = /*#__PURE__*/__webpack_require__.n(getFragmentFromSelection);
  34482. // EXTERNAL MODULE: external "draftjs-utils"
  34483. var external_draftjs_utils_ = __webpack_require__(23);
  34484. // CONCATENATED MODULE: ./configs/handlers.js
  34485. var handlers_keyCommandHandlers = function keyCommandHandlers(command, editorState, editor) {
  34486. if (editor.editorProps.handleKeyCommand && editor.editorProps.handleKeyCommand(command, editorState, editor) === 'handled') {
  34487. return 'handled';
  34488. }
  34489. if (command === 'braft-save') {
  34490. editor.editorProps.onSave && editor.editorProps.onSave(editorState);
  34491. return 'handled';
  34492. }
  34493. var _editor$editorProps = editor.editorProps,
  34494. controls = _editor$editorProps.controls,
  34495. excludeControls = _editor$editorProps.excludeControls;
  34496. var allowIndent = (controls.indexOf('text-indent') !== 0 || controls.find(function (item) {
  34497. return item.key === 'text-indent';
  34498. })) && excludeControls.indexOf('text-indent') === -1;
  34499. var cursorStart = editorState.getSelection().getStartOffset();
  34500. var cursorEnd = editorState.getSelection().getEndOffset();
  34501. var cursorIsAtFirst = cursorStart === 0 && cursorEnd === 0;
  34502. if (command === 'backspace') {
  34503. if (editor.editorProps.onDelete && editor.editorProps.onDelete(editorState) === false) {
  34504. return 'handled';
  34505. }
  34506. var blockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  34507. if (allowIndent && cursorIsAtFirst && blockType !== 'code-block') {
  34508. editor.setValue(external_braft_utils_["ContentUtils"].decreaseSelectionIndent(editorState));
  34509. }
  34510. }
  34511. if (command === 'tab') {
  34512. var _blockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  34513. if (_blockType === 'code-block') {
  34514. editor.setValue(external_braft_utils_["ContentUtils"].insertText(editorState, ' '.repeat(editor.editorProps.codeTabIndents)));
  34515. return 'handled';
  34516. } else if (_blockType === 'ordered-list-item' || _blockType === 'unordered-list-item') {
  34517. var newEditorState = external_draft_js_["RichUtils"].onTab(event, editorState, 4);
  34518. if (newEditorState !== editorState) {
  34519. editor.setValue(newEditorState);
  34520. }
  34521. return 'handled';
  34522. } else if (_blockType !== 'atomic' && allowIndent && cursorIsAtFirst) {
  34523. editor.setValue(external_braft_utils_["ContentUtils"].increaseSelectionIndent(editorState));
  34524. return 'handled';
  34525. }
  34526. }
  34527. var nextEditorState = external_braft_utils_["ContentUtils"].handleKeyCommand(editorState, command);
  34528. if (nextEditorState) {
  34529. editor.setValue(nextEditorState);
  34530. return 'handled';
  34531. }
  34532. return 'not-handled';
  34533. };
  34534. var handlers_returnHandlers = function returnHandlers(event, editorState, editor) {
  34535. if (editor.editorProps.handleReturn && editor.editorProps.handleReturn(event, editorState, editor) === 'handled') {
  34536. return 'handled';
  34537. }
  34538. var currentBlock = external_braft_utils_["ContentUtils"].getSelectionBlock(editorState);
  34539. var currentBlockType = currentBlock.getType();
  34540. if (currentBlockType === 'unordered-list-item' || currentBlockType === 'ordered-list-item') {
  34541. if (currentBlock.getLength() === 0) {
  34542. editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, 'unstyled'));
  34543. return 'handled';
  34544. }
  34545. return 'not-handled';
  34546. } else if (currentBlockType === 'code-block') {
  34547. if (event.which === 13 && (event.getModifierState('Shift') || event.getModifierState('Alt') || event.getModifierState('Control'))) {
  34548. editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, 'unstyled'));
  34549. return 'handled';
  34550. }
  34551. return 'not-handled';
  34552. } else if (currentBlockType === 'blockquote') {
  34553. if (event.which === 13) {
  34554. if (event.getModifierState('Shift') || event.getModifierState('Alt') || event.getModifierState('Control')) {
  34555. event.which = 0;
  34556. } else {
  34557. editor.setValue(external_draft_js_["RichUtils"].insertSoftNewline(editorState));
  34558. return 'handled';
  34559. }
  34560. }
  34561. }
  34562. var nextEditorState = Object(external_draftjs_utils_["handleNewLine"])(editorState, event);
  34563. if (nextEditorState) {
  34564. editor.setValue(nextEditorState);
  34565. return 'handled';
  34566. }
  34567. return 'not-handled';
  34568. };
  34569. var beforeInputHandlers = function beforeInputHandlers(chars, editorState, editor) {
  34570. if (editor.editorProps.handleBeforeInput && editor.editorProps.handleBeforeInput(chars, editorState, editor) === 'handled') {
  34571. return 'handled';
  34572. }
  34573. return 'not-handled';
  34574. };
  34575. var handlers_compositionStartHandler = function compositionStartHandler(_, editor) {
  34576. var editorState = editor.state.editorState;
  34577. var selectedBlocks = external_braft_utils_["ContentUtils"].getSelectedBlocks(editorState);
  34578. if (selectedBlocks && selectedBlocks.length > 1) {
  34579. var nextEditorState = external_draft_js_["EditorState"].push(editorState, external_draft_js_["Modifier"].removeRange(editorState.getCurrentContent(), editorState.getSelection(), 'backward'), 'remove-range');
  34580. editor.setValue(nextEditorState);
  34581. }
  34582. };
  34583. var handlers_dropHandlers = function dropHandlers(selectionState, dataTransfer, editor) {
  34584. if (editor.editorProps.readOnly || editor.editorProps.disabled) {
  34585. return 'handled';
  34586. }
  34587. if (window && window.__BRAFT_DRAGING__IMAGE__) {
  34588. var nextEditorState = external_draft_js_["EditorState"].forceSelection(editor.state.editorState, selectionState);
  34589. nextEditorState = external_braft_utils_["ContentUtils"].insertMedias(nextEditorState, [window.__BRAFT_DRAGING__IMAGE__.mediaData]);
  34590. nextEditorState = external_braft_utils_["ContentUtils"].removeBlock(nextEditorState, window.__BRAFT_DRAGING__IMAGE__.block, nextEditorState.getSelection());
  34591. window.__BRAFT_DRAGING__IMAGE__ = null;
  34592. editor.lockOrUnlockEditor(true);
  34593. editor.setValue(nextEditorState);
  34594. return 'handled';
  34595. } else if (!dataTransfer || !dataTransfer.getText()) {
  34596. return 'handled';
  34597. }
  34598. return 'not-handled';
  34599. };
  34600. var handlers_handleFiles = function handleFiles(files, editor) {
  34601. var _editor$constructor$d = objectSpread_default()({}, editor.constructor.defaultProps.media, editor.editorProps.media),
  34602. pasteImage = _editor$constructor$d.pasteImage,
  34603. validateFn = _editor$constructor$d.validateFn,
  34604. imagePasteLimit = _editor$constructor$d.imagePasteLimit;
  34605. pasteImage && files.slice(0, imagePasteLimit).forEach(function (file) {
  34606. if (file && file.type.indexOf('image') > -1 && editor.braftFinder) {
  34607. var validateResult = validateFn ? validateFn(file) : true;
  34608. if (validateResult instanceof Promise) {
  34609. validateResult.then(function () {
  34610. editor.braftFinder.uploadImage(file, function (image) {
  34611. editor.isLiving && editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(editor.state.editorState, [image]));
  34612. });
  34613. });
  34614. } else if (validateResult) {
  34615. editor.braftFinder.uploadImage(file, function (image) {
  34616. editor.isLiving && editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(editor.state.editorState, [image]));
  34617. });
  34618. }
  34619. }
  34620. });
  34621. if (files[0] && files[0].type.indexOf('image') > -1 && pasteImage) {
  34622. return 'handled';
  34623. }
  34624. return 'not-handled';
  34625. };
  34626. var droppedFilesHandlers = function droppedFilesHandlers(selectionState, files, editor) {
  34627. if (editor.editorProps.handleDroppedFiles && editor.editorProps.handleDroppedFiles(selectionState, files, editor) === 'handled') {
  34628. return 'handled';
  34629. }
  34630. return handlers_handleFiles(files, editor);
  34631. };
  34632. var pastedFilesHandlers = function pastedFilesHandlers(files, editor) {
  34633. if (editor.editorProps.handlePastedFiles && editor.editorProps.handlePastedFiles(files, editor) === 'handled') {
  34634. return 'handled';
  34635. }
  34636. return handlers_handleFiles(files, editor);
  34637. };
  34638. var handlers_copyHandlers = function copyHandlers(event, editor) {
  34639. var blockMap = getFragmentFromSelection_default()(editor.state.editorState);
  34640. if (blockMap && blockMap.toArray) {
  34641. try {
  34642. var tempContentState = external_draft_js_["ContentState"].createFromBlockArray(blockMap.toArray());
  34643. var tempEditorState = external_draft_js_["EditorState"].createWithContent(tempContentState);
  34644. var clipboardData = event.clipboardData || window.clipboardData || event.originalEvent.clipboardData;
  34645. tempEditorState.setConvertOptions(editor.state.editorState.convertOptions);
  34646. clipboardData.setData('text/html', tempEditorState.toHTML());
  34647. clipboardData.setData('text/plain', tempEditorState.toText());
  34648. event.preventDefault();
  34649. } catch (error) {
  34650. console.warn(error);
  34651. }
  34652. }
  34653. };
  34654. var handlers_pastedTextHandlers = function pastedTextHandlers(text, html, editorState, editor) {
  34655. if (editor.editorProps.handlePastedText && editor.editorProps.handlePastedText(text, html, editorState, editor) === 'handled') {
  34656. return 'handled';
  34657. }
  34658. if (!html || editor.editorProps.stripPastedStyles) {
  34659. return false;
  34660. }
  34661. var tempColors = external_braft_utils_["ColorUtils"].detectColorsFromHTMLString(html);
  34662. editor.setState({
  34663. tempColors: toConsumableArray_default()(editor.state.tempColors).concat(toConsumableArray_default()(tempColors)).filter(function (item) {
  34664. return editor.editorProps.colors.indexOf(item) === -1;
  34665. }).filter(function (item, index, array) {
  34666. return array.indexOf(item) === index;
  34667. })
  34668. }, function () {
  34669. editor.setValue(external_braft_utils_["ContentUtils"].insertHTML(editorState, html, 'paste'));
  34670. });
  34671. return 'handled';
  34672. };
  34673. // CONCATENATED MODULE: ./helpers/extension.js
  34674. // TODO
  34675. // - block-style和atomic类型的扩展支持
  34676. var extension_extensionControls = [];
  34677. var extension_extensionDecorators = [];
  34678. var extension_propInterceptors = [];
  34679. var extension_extensionBlockRenderMaps = [];
  34680. var extension_extensionBlockRendererFns = [];
  34681. var extensionInlineStyleMaps = [];
  34682. var extension_extensionInlineStyleFns = [];
  34683. var extensionEntities = [];
  34684. var inlineStyleImporters = [];
  34685. var inlineStyleExporters = [];
  34686. var blockImporters = [];
  34687. var blockExporters = [];
  34688. var filterByEditorId = function filterByEditorId(items, editorId) {
  34689. if (!editorId) {
  34690. return items.filter(function (item) {
  34691. return !item.includeEditors;
  34692. }).map(function (item) {
  34693. return item.data;
  34694. });
  34695. }
  34696. return items.map(function (item) {
  34697. if (!item.includeEditors && !item.excludeEditors) {
  34698. return item.data;
  34699. }
  34700. if (item.includeEditors) {
  34701. return item.includeEditors.indexOf(editorId) !== -1 ? item.data : false;
  34702. }
  34703. if (item.excludeEditors) {
  34704. return item.excludeEditors.indexOf(editorId) !== -1 ? false : item.data;
  34705. }
  34706. return false;
  34707. }).filter(function (item) {
  34708. return item;
  34709. });
  34710. };
  34711. var getPropInterceptors = function getPropInterceptors(editorId) {
  34712. return filterByEditorId(extension_propInterceptors, editorId);
  34713. };
  34714. var getExtensionControls = function getExtensionControls(editorId) {
  34715. return filterByEditorId(extension_extensionControls, editorId);
  34716. };
  34717. var getExtensionDecorators = function getExtensionDecorators(editorId) {
  34718. return filterByEditorId(extension_extensionDecorators, editorId);
  34719. };
  34720. var getExtensionBlockRenderMaps = function getExtensionBlockRenderMaps(editorId) {
  34721. return filterByEditorId(extension_extensionBlockRenderMaps, editorId);
  34722. };
  34723. var getExtensionBlockRendererFns = function getExtensionBlockRendererFns(editorId) {
  34724. return filterByEditorId(extension_extensionBlockRendererFns, editorId);
  34725. };
  34726. var getExtensionInlineStyleMap = function getExtensionInlineStyleMap(editorId) {
  34727. var inlineStyleMap = {};
  34728. filterByEditorId(extensionInlineStyleMaps, editorId).forEach(function (item) {
  34729. inlineStyleMap[item.inlineStyleName] = item.styleMap;
  34730. });
  34731. return inlineStyleMap;
  34732. };
  34733. var getExtensionInlineStyleFns = function getExtensionInlineStyleFns(editorId) {
  34734. return filterByEditorId(extension_extensionInlineStyleFns, editorId);
  34735. };
  34736. var compositeStyleImportFn = function compositeStyleImportFn(styleImportFn, editorId) {
  34737. return function (nodeName, node, style) {
  34738. filterByEditorId(inlineStyleImporters, editorId).forEach(function (styleImporter) {
  34739. if (styleImporter.importer && styleImporter.importer(nodeName, node)) {
  34740. style = style.add(styleImporter.inlineStyleName);
  34741. }
  34742. });
  34743. return styleImportFn ? styleImportFn(nodeName, node, style) : style;
  34744. };
  34745. };
  34746. var compositeStyleExportFn = function compositeStyleExportFn(styleExportFn, editorId) {
  34747. return function (style) {
  34748. style = style.toUpperCase();
  34749. var result = styleExportFn ? styleExportFn(style) : undefined;
  34750. if (result) {
  34751. return result;
  34752. }
  34753. filterByEditorId(inlineStyleExporters, editorId).find(function (item) {
  34754. if (item.inlineStyleName === style) {
  34755. result = item.exporter;
  34756. return true;
  34757. }
  34758. });
  34759. return result;
  34760. };
  34761. };
  34762. var compositeEntityImportFn = function compositeEntityImportFn(entityImportFn, editorId) {
  34763. return function (nodeName, node, createEntity, source) {
  34764. var result = entityImportFn ? entityImportFn(nodeName, node, createEntity, source) : null;
  34765. if (result) {
  34766. return result;
  34767. }
  34768. filterByEditorId(extensionEntities, editorId).find(function (entityItem) {
  34769. var matched = entityItem.importer ? entityItem.importer(nodeName, node, source) : null;
  34770. matched && (result = createEntity(entityItem.entityType, matched.mutability || 'MUTABLE', matched.data || {}));
  34771. return !!matched;
  34772. });
  34773. return result;
  34774. };
  34775. };
  34776. var compositeEntityExportFn = function compositeEntityExportFn(entityExportFn, editorId) {
  34777. return function (entity, originalText) {
  34778. var result = entityExportFn ? entityExportFn(entity, originalText) : undefined;
  34779. if (result) {
  34780. return result;
  34781. }
  34782. var entityType = entity.type.toUpperCase();
  34783. filterByEditorId(extensionEntities, editorId).find(function (entityItem) {
  34784. if (entityItem.entityType === entityType) {
  34785. result = entityItem.exporter ? entityItem.exporter(entity, originalText) : undefined;
  34786. return true;
  34787. }
  34788. });
  34789. return result;
  34790. };
  34791. };
  34792. var compositeBlockImportFn = function compositeBlockImportFn(blockImportFn, editorId) {
  34793. return function (nodeName, node, source) {
  34794. var result = blockImportFn ? blockImportFn(nodeName, node, source) : null;
  34795. if (result) {
  34796. return result;
  34797. }
  34798. filterByEditorId(blockImporters, editorId).find(function (blockImporter) {
  34799. var matched = blockImporter.importer ? blockImporter.importer(nodeName, node, source) : undefined;
  34800. matched && (result = matched);
  34801. return !!matched;
  34802. });
  34803. return result;
  34804. };
  34805. };
  34806. var compositeBlockExportFn = function compositeBlockExportFn(blockExportFn, editorId) {
  34807. return function (contentState, block) {
  34808. var result = blockExportFn ? blockExportFn(contentState, block) : null;
  34809. if (result) {
  34810. return result;
  34811. }
  34812. filterByEditorId(blockExporters, editorId).find(function (blockExporter) {
  34813. var matched = blockExporter.exporter ? blockExporter.exporter(contentState, block) : undefined;
  34814. matched && (result = matched);
  34815. return !!matched;
  34816. });
  34817. return result;
  34818. };
  34819. };
  34820. var extension_useExtension = function useExtension(extension) {
  34821. if (extension instanceof Array) {
  34822. extension.forEach(useExtension);
  34823. return false;
  34824. }
  34825. if (!extension || !extension.type || typeof extension.type !== 'string') {
  34826. return false;
  34827. }
  34828. var includeEditors = extension.includeEditors,
  34829. excludeEditors = extension.excludeEditors;
  34830. if (extension.type === 'control') {
  34831. extension_extensionControls.push({
  34832. includeEditors: includeEditors,
  34833. excludeEditors: excludeEditors,
  34834. data: extension.control
  34835. });
  34836. } else if (extension.type === 'inline-style') {
  34837. var inlineStyleName = extension.name.toUpperCase();
  34838. if (extension.control) {
  34839. extension_extensionControls.push({
  34840. includeEditors: includeEditors,
  34841. excludeEditors: excludeEditors,
  34842. data: objectSpread_default()({
  34843. key: inlineStyleName,
  34844. type: 'inline-style',
  34845. command: inlineStyleName
  34846. }, extension.control)
  34847. });
  34848. }
  34849. if (extension.style) {
  34850. extensionInlineStyleMaps.push({
  34851. includeEditors: includeEditors,
  34852. excludeEditors: excludeEditors,
  34853. data: {
  34854. inlineStyleName: inlineStyleName,
  34855. styleMap: extension.style
  34856. }
  34857. });
  34858. }
  34859. if (extension.styleFn) {
  34860. extension_extensionInlineStyleFns.push({
  34861. includeEditors: includeEditors,
  34862. excludeEditors: excludeEditors,
  34863. data: {
  34864. inlineStyleName: inlineStyleName,
  34865. styleFn: extension.styleFn
  34866. }
  34867. });
  34868. }
  34869. if (extension.importer) {
  34870. inlineStyleImporters.push({
  34871. includeEditors: includeEditors,
  34872. excludeEditors: excludeEditors,
  34873. data: {
  34874. inlineStyleName: inlineStyleName,
  34875. importer: extension.importer
  34876. }
  34877. });
  34878. }
  34879. inlineStyleExporters.push({
  34880. includeEditors: includeEditors,
  34881. excludeEditors: excludeEditors,
  34882. data: {
  34883. inlineStyleName: inlineStyleName,
  34884. exporter: extension.exporter ? extension.exporter(extension) : external_react_default.a.createElement("span", {
  34885. style: extension.style
  34886. })
  34887. }
  34888. });
  34889. } else if (extension.type === 'block-style') ; else if (extension.type === 'entity') {
  34890. var entityType = extension.name.toUpperCase();
  34891. if (extension.control) {
  34892. extension_extensionControls.push({
  34893. includeEditors: includeEditors,
  34894. excludeEditors: excludeEditors,
  34895. data: typeof extension.control === 'function' ? extension.control : objectSpread_default()({
  34896. key: entityType,
  34897. type: 'entity',
  34898. command: entityType,
  34899. data: {
  34900. mutability: extension.mutability || 'MUTABLE',
  34901. data: extension.data || {}
  34902. }
  34903. }, extension.control)
  34904. });
  34905. }
  34906. extensionEntities.push({
  34907. includeEditors: includeEditors,
  34908. excludeEditors: excludeEditors,
  34909. data: {
  34910. entityType: entityType,
  34911. importer: extension.importer,
  34912. exporter: extension.exporter
  34913. }
  34914. });
  34915. extension_extensionDecorators.push({
  34916. includeEditors: includeEditors,
  34917. excludeEditors: excludeEditors,
  34918. data: {
  34919. type: 'entity',
  34920. decorator: {
  34921. key: entityType,
  34922. component: extension.component
  34923. }
  34924. }
  34925. });
  34926. } else if (extension.type === 'block') {
  34927. var blockType = extension.name;
  34928. if (extension.renderMap) {
  34929. extension_extensionBlockRenderMaps.push({
  34930. includeEditors: includeEditors,
  34931. excludeEditors: excludeEditors,
  34932. data: {
  34933. blockType: blockType,
  34934. renderMap: extension.renderMap
  34935. }
  34936. });
  34937. }
  34938. if (extension.rendererFn) {
  34939. extension_extensionBlockRendererFns.push({
  34940. includeEditors: includeEditors,
  34941. excludeEditors: excludeEditors,
  34942. data: {
  34943. blockType: blockType,
  34944. rendererFn: extension.rendererFn
  34945. }
  34946. });
  34947. }
  34948. if (extension.importer) {
  34949. blockImporters.push({
  34950. includeEditors: includeEditors,
  34951. excludeEditors: excludeEditors,
  34952. data: {
  34953. blockType: blockType,
  34954. importer: extension.importer
  34955. }
  34956. });
  34957. }
  34958. if (extension.exporter) {
  34959. blockExporters.push({
  34960. includeEditors: includeEditors,
  34961. excludeEditors: excludeEditors,
  34962. data: {
  34963. blockType: blockType,
  34964. exporter: extension.exporter
  34965. }
  34966. });
  34967. }
  34968. } else if (extension.type === 'atomic') ; else if (extension.type === 'decorator') {
  34969. var decorator = extension.decorator;
  34970. if (decorator && decorator.strategy && decorator.component) {
  34971. extension_extensionDecorators.push({
  34972. includeEditors: includeEditors,
  34973. excludeEditors: excludeEditors,
  34974. data: {
  34975. type: 'strategy',
  34976. decorator: decorator
  34977. }
  34978. });
  34979. } else if (decorator && decorator.getDecorations) {
  34980. extension_extensionDecorators.push({
  34981. includeEditors: includeEditors,
  34982. excludeEditors: excludeEditors,
  34983. data: {
  34984. type: 'class',
  34985. decorator: decorator
  34986. }
  34987. });
  34988. }
  34989. } else if (extension.type === 'prop-interception') {
  34990. extension_propInterceptors.push({
  34991. includeEditors: includeEditors,
  34992. excludeEditors: excludeEditors,
  34993. data: extension.interceptor
  34994. });
  34995. }
  34996. };
  34997. var createExtensibleEditor = function createExtensibleEditor(BraftEditor) {
  34998. BraftEditor.use = extension_useExtension;
  34999. return BraftEditor;
  35000. };
  35001. // CONCATENATED MODULE: ./renderers/block/blockRenderMap.js
  35002. /* harmony default export */ var block_blockRenderMap = (function (props, blockRenderMap) {
  35003. var customBlockRenderMap = Object(external_immutable_["Map"])({
  35004. 'atomic': {
  35005. element: ''
  35006. },
  35007. 'code-block': {
  35008. element: 'code',
  35009. wrapper: external_react_default.a.createElement("pre", {
  35010. className: "braft-code-block"
  35011. })
  35012. }
  35013. });
  35014. try {
  35015. var extensionBlockRenderMaps = getExtensionBlockRenderMaps(props.editorId);
  35016. customBlockRenderMap = extensionBlockRenderMaps.reduce(function (customBlockRenderMap, item) {
  35017. return customBlockRenderMap.merge(typeof item.renderMap === 'function' ? item.renderMap(props) : item.renderMap);
  35018. }, customBlockRenderMap);
  35019. if (blockRenderMap) {
  35020. if (typeof blockRenderMap === 'function') {
  35021. customBlockRenderMap = customBlockRenderMap.merge(blockRenderMap(props));
  35022. } else {
  35023. customBlockRenderMap = customBlockRenderMap.merge(blockRenderMap);
  35024. }
  35025. }
  35026. customBlockRenderMap = external_draft_js_["DefaultDraftBlockRenderMap"].merge(customBlockRenderMap);
  35027. } catch (error) {
  35028. console.warn(error);
  35029. }
  35030. return customBlockRenderMap;
  35031. });
  35032. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/extends.js
  35033. var helpers_extends = __webpack_require__(11);
  35034. var extends_default = /*#__PURE__*/__webpack_require__.n(helpers_extends);
  35035. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/slicedToArray.js
  35036. var slicedToArray = __webpack_require__(24);
  35037. var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
  35038. // EXTERNAL MODULE: ./renderers/atomics/Image/style.scss
  35039. var Image_style = __webpack_require__(45);
  35040. // EXTERNAL MODULE: ./components/common/Switch/style.scss
  35041. var Switch_style = __webpack_require__(46);
  35042. // CONCATENATED MODULE: ./components/common/Switch/index.jsx
  35043. /* harmony default export */ var Switch = (function (props) {
  35044. var active = props.active,
  35045. _onClick = props.onClick,
  35046. className = props.className;
  35047. return external_react_default.a.createElement("div", {
  35048. onClick: function onClick() {
  35049. return _onClick();
  35050. },
  35051. className: 'bf-switch ' + className + (active ? ' active' : '')
  35052. });
  35053. });
  35054. // CONCATENATED MODULE: ./configs/controls.js
  35055. /* harmony default export */ var configs_controls = (function (lang, editor) {
  35056. return [{
  35057. key: 'undo',
  35058. title: lang.controls.undo,
  35059. text: external_react_default.a.createElement("i", {
  35060. className: "bfi-undo"
  35061. }),
  35062. type: 'editor-method',
  35063. command: 'undo'
  35064. }, {
  35065. key: 'redo',
  35066. title: lang.controls.redo,
  35067. text: external_react_default.a.createElement("i", {
  35068. className: "bfi-redo"
  35069. }),
  35070. type: 'editor-method',
  35071. command: 'redo'
  35072. }, {
  35073. key: 'remove-styles',
  35074. title: lang.controls.removeStyles,
  35075. text: external_react_default.a.createElement("i", {
  35076. className: "bfi-format_clear"
  35077. }),
  35078. type: 'editor-method',
  35079. command: 'removeSelectionInlineStyles'
  35080. }, {
  35081. key: 'hr',
  35082. title: lang.controls.hr,
  35083. text: external_react_default.a.createElement("i", {
  35084. className: "bfi-hr"
  35085. }),
  35086. type: 'editor-method',
  35087. command: 'insertHorizontalLine'
  35088. }, {
  35089. key: 'bold',
  35090. title: lang.controls.bold,
  35091. text: external_react_default.a.createElement("i", {
  35092. className: "bfi-bold"
  35093. }),
  35094. type: 'inline-style',
  35095. command: 'bold'
  35096. }, {
  35097. key: 'italic',
  35098. title: lang.controls.italic,
  35099. text: external_react_default.a.createElement("i", {
  35100. className: "bfi-italic"
  35101. }),
  35102. type: 'inline-style',
  35103. command: 'italic'
  35104. }, {
  35105. key: 'underline',
  35106. title: lang.controls.underline,
  35107. text: external_react_default.a.createElement("i", {
  35108. className: "bfi-underlined"
  35109. }),
  35110. type: 'inline-style',
  35111. command: 'underline'
  35112. }, {
  35113. key: 'strike-through',
  35114. title: lang.controls.strikeThrough,
  35115. text: external_react_default.a.createElement("i", {
  35116. className: "bfi-strikethrough"
  35117. }),
  35118. type: 'inline-style',
  35119. command: 'strikethrough'
  35120. }, {
  35121. key: 'superscript',
  35122. title: lang.controls.superScript,
  35123. text: external_react_default.a.createElement("i", {
  35124. className: "bfi-superscript"
  35125. }),
  35126. type: 'inline-style',
  35127. command: 'superscript'
  35128. }, {
  35129. key: 'subscript',
  35130. title: lang.controls.subScript,
  35131. text: external_react_default.a.createElement("i", {
  35132. className: "bfi-subscript"
  35133. }),
  35134. type: 'inline-style',
  35135. command: 'subscript'
  35136. }, {
  35137. key: 'headings',
  35138. title: lang.controls.headings,
  35139. type: 'headings'
  35140. }, {
  35141. key: 'blockquote',
  35142. title: lang.controls.blockQuote,
  35143. text: external_react_default.a.createElement("i", {
  35144. className: "bfi-quote"
  35145. }),
  35146. type: 'block-type',
  35147. command: 'blockquote'
  35148. }, {
  35149. key: 'code',
  35150. title: lang.controls.code,
  35151. text: external_react_default.a.createElement("i", {
  35152. className: "bfi-code"
  35153. }),
  35154. type: 'block-type',
  35155. command: 'code-block'
  35156. }, {
  35157. key: 'list-ul',
  35158. title: lang.controls.unorderedList,
  35159. text: external_react_default.a.createElement("i", {
  35160. className: "bfi-list"
  35161. }),
  35162. type: 'block-type',
  35163. command: 'unordered-list-item'
  35164. }, {
  35165. key: 'list-ol',
  35166. title: lang.controls.orderedList,
  35167. text: external_react_default.a.createElement("i", {
  35168. className: "bfi-list-numbered"
  35169. }),
  35170. type: 'block-type',
  35171. command: 'ordered-list-item'
  35172. }, {
  35173. key: 'link',
  35174. title: lang.controls.link,
  35175. type: 'link'
  35176. }, {
  35177. key: 'text-color',
  35178. title: lang.controls.color,
  35179. type: 'text-color'
  35180. }, {
  35181. key: 'line-height',
  35182. title: lang.controls.lineHeight,
  35183. type: 'line-height'
  35184. }, {
  35185. key: 'letter-spacing',
  35186. title: lang.controls.letterSpacing,
  35187. type: 'letter-spacing'
  35188. }, {
  35189. key: 'text-indent',
  35190. title: lang.controls.textIndent,
  35191. type: 'text-indent'
  35192. }, {
  35193. key: 'font-size',
  35194. title: lang.controls.fontSize,
  35195. type: 'font-size'
  35196. }, {
  35197. key: 'font-family',
  35198. title: lang.controls.fontFamily,
  35199. type: 'font-family'
  35200. }, {
  35201. key: 'text-align',
  35202. title: lang.controls.textAlign,
  35203. type: 'text-align'
  35204. }, {
  35205. key: 'media',
  35206. title: lang.controls.media,
  35207. text: external_react_default.a.createElement("i", {
  35208. className: "bfi-media"
  35209. }),
  35210. type: 'media'
  35211. }, {
  35212. key: 'emoji',
  35213. title: lang.controls.emoji,
  35214. text: external_react_default.a.createElement("i", {
  35215. className: "bfi-emoji"
  35216. }),
  35217. type: 'emoji'
  35218. }, {
  35219. key: 'clear',
  35220. title: lang.controls.clear,
  35221. text: external_react_default.a.createElement("i", {
  35222. className: "bfi-clear_all"
  35223. }),
  35224. type: 'editor-method',
  35225. command: 'clearEditorContent'
  35226. }, {
  35227. key: 'fullscreen',
  35228. title: editor.state.isFullscreen ? lang.controls.exitFullscreen : lang.controls.fullscreen,
  35229. text: external_react_default.a.createElement("i", {
  35230. className: editor.state.isFullscreen ? 'bfi-fullscreen-exit' : 'bfi-fullscreen'
  35231. }),
  35232. type: 'editor-method',
  35233. command: 'toggleFullscreen'
  35234. }, {
  35235. key: 'modal',
  35236. type: 'modal'
  35237. }, {
  35238. key: 'button',
  35239. type: 'button'
  35240. }, {
  35241. key: 'dropdown',
  35242. type: 'dropdown'
  35243. }, {
  35244. key: 'component',
  35245. type: 'component'
  35246. }];
  35247. });
  35248. var imageControlItems = {
  35249. 'float-left': {
  35250. text: external_react_default.a.createElement("span", {
  35251. "data-float": "left"
  35252. }, "\uE91E"),
  35253. command: 'setImageFloat|left'
  35254. },
  35255. 'float-right': {
  35256. text: external_react_default.a.createElement("span", {
  35257. "data-float": "right"
  35258. }, "\uE914"),
  35259. command: 'setImageFloat|right'
  35260. },
  35261. 'align-left': {
  35262. text: external_react_default.a.createElement("span", {
  35263. "data-align": "left"
  35264. }, "\uE027"),
  35265. command: 'setImageAlignment|left'
  35266. },
  35267. 'align-center': {
  35268. text: external_react_default.a.createElement("span", {
  35269. "data-align": "center"
  35270. }, "\uE028"),
  35271. command: 'setImageAlignment|center'
  35272. },
  35273. 'align-right': {
  35274. text: external_react_default.a.createElement("span", {
  35275. "data-align": "right"
  35276. }, "\uE029"),
  35277. command: 'setImageAlignment|right'
  35278. },
  35279. 'size': {
  35280. text: external_react_default.a.createElement("span", null, "\uE3C2"),
  35281. command: 'toggleSizeEditor'
  35282. },
  35283. 'link': {
  35284. text: external_react_default.a.createElement("span", null, "\uE91A"),
  35285. command: 'toggleLinkEditor'
  35286. },
  35287. 'remove': {
  35288. text: external_react_default.a.createElement("span", null, "\uE9AC"),
  35289. command: 'removeImage'
  35290. }
  35291. };
  35292. // CONCATENATED MODULE: ./renderers/atomics/Image/index.jsx
  35293. var Image_Image =
  35294. /*#__PURE__*/
  35295. function (_React$Component) {
  35296. inherits_default()(Image, _React$Component);
  35297. function Image() {
  35298. var _getPrototypeOf2;
  35299. var _this;
  35300. classCallCheck_default()(this, Image);
  35301. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  35302. args[_key] = arguments[_key];
  35303. }
  35304. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Image)).call.apply(_getPrototypeOf2, [this].concat(args)));
  35305. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  35306. toolbarVisible: false,
  35307. toolbarOffset: 0,
  35308. linkEditorVisible: false,
  35309. sizeEditorVisible: false,
  35310. tempLink: null,
  35311. tempWidth: null,
  35312. tempHeight: null
  35313. });
  35314. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialLeft", void 0);
  35315. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialTop", void 0);
  35316. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialWidth", void 0);
  35317. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialHeight", void 0);
  35318. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "reSizeType", void 0);
  35319. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "changeSize", function (e) {
  35320. var type = _this.reSizeType;
  35321. if (!_this.initialLeft) {
  35322. _this.initialLeft = e.screenX;
  35323. _this.initialTop = e.screenY;
  35324. }
  35325. if (type === 'rightbottom') {
  35326. _this.initialHeight += e.screenY - _this.initialTop;
  35327. _this.initialWidth += e.screenX - _this.initialLeft;
  35328. }
  35329. if (type === 'leftbottom') {
  35330. _this.initialHeight += e.screenY - _this.initialTop;
  35331. _this.initialWidth += -e.screenX + _this.initialLeft;
  35332. }
  35333. _this.initialLeft = e.screenX;
  35334. _this.initialTop = e.screenY;
  35335. });
  35336. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "moveImage", function (e) {
  35337. _this.changeSize(e);
  35338. _this.setState({
  35339. tempWidth: Math.abs(_this.initialWidth),
  35340. tempHeight: Math.abs(_this.initialHeight)
  35341. });
  35342. });
  35343. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "upImage", function () {
  35344. _this.confirmImageSize();
  35345. document.removeEventListener('mousemove', _this.moveImage);
  35346. document.removeEventListener('mouseup', _this.upImage);
  35347. });
  35348. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "repareChangeSize", function (type) {
  35349. return function (e) {
  35350. _this.reSizeType = type;
  35351. var imageRect = _this.imageElement.getBoundingClientRect();
  35352. _this.initialLeft = _this.initialTop = 0;
  35353. _this.initialWidth = imageRect.width;
  35354. _this.initialHeight = imageRect.height;
  35355. e.preventDefault();
  35356. document.addEventListener('mousemove', _this.moveImage);
  35357. document.addEventListener('mouseup', _this.upImage);
  35358. };
  35359. });
  35360. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "preventDragEvent", function (event) {
  35361. event.stopPropagation();
  35362. event.preventDefault();
  35363. });
  35364. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDragStart", function () {
  35365. if (_this.props.editor.editorProps.readOnly || _this.props.editor.editorProps.disabled) {
  35366. return false;
  35367. }
  35368. window.__BRAFT_DRAGING__IMAGE__ = {
  35369. block: _this.props.block,
  35370. mediaData: objectSpread_default()({
  35371. type: 'IMAGE'
  35372. }, _this.props.mediaData)
  35373. };
  35374. _this.setState({
  35375. toolbarVisible: false
  35376. }, function () {
  35377. _this.unlockEditor();
  35378. });
  35379. return true;
  35380. });
  35381. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDragEnd", function () {
  35382. window.__BRAFT_DRAGING__IMAGE__ = null;
  35383. return false;
  35384. });
  35385. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "executeCommand", function (command) {
  35386. if (typeof command === 'string') {
  35387. var _command$split = command.split('|'),
  35388. _command$split2 = slicedToArray_default()(_command$split, 2),
  35389. method = _command$split2[0],
  35390. param = _command$split2[1];
  35391. _this[method] && _this[method](param);
  35392. } else if (typeof command === 'function') {
  35393. command(_this.props.block, _this.props.mediaData, _this.props.editor.getValue());
  35394. }
  35395. });
  35396. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeImage", function () {
  35397. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editor.getValue(), _this.props.block));
  35398. _this.unlockEditor();
  35399. });
  35400. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleLinkEditor", function () {
  35401. _this.setState({
  35402. linkEditorVisible: !_this.state.linkEditorVisible,
  35403. sizeEditorVisible: false
  35404. });
  35405. });
  35406. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleSizeEditor", function () {
  35407. _this.setState({
  35408. linkEditorVisible: false,
  35409. sizeEditorVisible: !_this.state.sizeEditorVisible
  35410. });
  35411. });
  35412. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleLinkInputKeyDown", function (e) {
  35413. if (e.keyCode === 13) {
  35414. _this.confirmImageLink();
  35415. } else {
  35416. return;
  35417. }
  35418. });
  35419. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageLink", function (e) {
  35420. _this.setState({
  35421. tempLink: e.currentTarget.value
  35422. });
  35423. return;
  35424. });
  35425. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "confirmImageLink", function () {
  35426. var link = _this.state.tempLink;
  35427. var hookReturns = _this.props.hooks('set-image-link', link)(link);
  35428. if (hookReturns === false) {
  35429. return false;
  35430. }
  35431. if (typeof hookReturns === 'string') {
  35432. link = hookReturns;
  35433. }
  35434. if (link !== null) {
  35435. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(_this.props.editor.getValue(), _this.props.entityKey, {
  35436. link: link
  35437. }));
  35438. window.setImmediate(_this.props.editor.forceRender);
  35439. }
  35440. });
  35441. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleSizeInputKeyDown", function (e) {
  35442. if (e.keyCode === 13) {
  35443. _this.confirmImageSize();
  35444. } else {
  35445. return;
  35446. }
  35447. });
  35448. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageWidth", function (_ref) {
  35449. var currentTarget = _ref.currentTarget;
  35450. var value = currentTarget.value;
  35451. value && !isNaN(value) && (value = value + 'px');
  35452. _this.setState({
  35453. tempWidth: value
  35454. });
  35455. return;
  35456. });
  35457. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageHeight", function (_ref2) {
  35458. var currentTarget = _ref2.currentTarget;
  35459. var value = currentTarget.value;
  35460. value && !isNaN(value) && (value = value + 'px');
  35461. _this.setState({
  35462. tempHeight: value
  35463. });
  35464. return;
  35465. });
  35466. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "confirmImageSize", function () {
  35467. var _this$state = _this.state,
  35468. width = _this$state.tempWidth,
  35469. height = _this$state.tempHeight;
  35470. var newImageSize = {};
  35471. width !== null && (newImageSize.width = width);
  35472. height !== null && (newImageSize.height = height);
  35473. var hookReturns = _this.props.hooks('set-image-size', newImageSize)(newImageSize);
  35474. if (hookReturns === false) {
  35475. return false;
  35476. }
  35477. if (hookReturns && (hookReturns.width || hookReturns.height)) {
  35478. newImageSize = hookReturns;
  35479. }
  35480. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(_this.props.editor.getValue(), _this.props.entityKey, newImageSize));
  35481. window.setImmediate(_this.props.editor.forceRender);
  35482. });
  35483. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageFloat", function (float) {
  35484. var hookReturns = _this.props.hooks('set-image-float', float)(float);
  35485. if (hookReturns === false) {
  35486. return false;
  35487. }
  35488. if (typeof hookReturns === 'string') {
  35489. float = hookReturns;
  35490. }
  35491. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaPosition(_this.props.editor.getValue(), _this.props.block, {
  35492. float: float
  35493. }));
  35494. _this.unlockEditor();
  35495. });
  35496. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageAlignment", function (alignment) {
  35497. var hookReturns = _this.props.hooks('set-image-alignment', alignment)(alignment);
  35498. if (hookReturns === false) {
  35499. return false;
  35500. }
  35501. if (typeof hookReturns === 'string') {
  35502. alignment = hookReturns;
  35503. }
  35504. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaPosition(_this.props.editor.getValue(), _this.props.block, {
  35505. alignment: alignment
  35506. }));
  35507. _this.unlockEditor();
  35508. });
  35509. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "showToolbar", function (event) {
  35510. if (_this.props.editor.editorProps.readOnly || _this.props.editor.editorProps.disabled) {
  35511. return false;
  35512. }
  35513. event.preventDefault();
  35514. if (!_this.state.toolbarVisible) {
  35515. _this.setState({
  35516. toolbarVisible: true
  35517. }, function () {
  35518. _this.lockEditor();
  35519. _this.setState({
  35520. toolbarOffset: _this.calcToolbarOffset()
  35521. });
  35522. });
  35523. }
  35524. });
  35525. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "hideToolbar", function (event) {
  35526. event.preventDefault();
  35527. _this.setState({
  35528. toolbarVisible: false
  35529. }, function () {
  35530. _this.unlockEditor(); // this.props.editor.requestFocus()
  35531. });
  35532. });
  35533. return _this;
  35534. }
  35535. createClass_default()(Image, [{
  35536. key: "render",
  35537. value: function render() {
  35538. var _this2 = this;
  35539. var _this$props = this.props,
  35540. mediaData = _this$props.mediaData,
  35541. language = _this$props.language,
  35542. imageControls = _this$props.imageControls,
  35543. imageResizable = _this$props.imageResizable;
  35544. var _this$state2 = this.state,
  35545. toolbarVisible = _this$state2.toolbarVisible,
  35546. toolbarOffset = _this$state2.toolbarOffset,
  35547. linkEditorVisible = _this$state2.linkEditorVisible,
  35548. sizeEditorVisible = _this$state2.sizeEditorVisible,
  35549. tempWidth = _this$state2.tempWidth,
  35550. tempHeight = _this$state2.tempHeight;
  35551. var blockData = this.props.block.getData();
  35552. var float = blockData.get('float');
  35553. var alignment = blockData.get('alignment');
  35554. var url = mediaData.url,
  35555. link = mediaData.link,
  35556. link_target = mediaData.link_target,
  35557. width = mediaData.width,
  35558. height = mediaData.height,
  35559. meta = mediaData.meta;
  35560. var imageStyles = {};
  35561. var clearFix = false;
  35562. if (float) {
  35563. alignment = null;
  35564. } else if (alignment === 'left') {
  35565. imageStyles.float = 'left';
  35566. clearFix = true;
  35567. } else if (alignment === 'right') {
  35568. imageStyles.float = 'right';
  35569. clearFix = true;
  35570. } else if (alignment === 'center') {
  35571. imageStyles.textAlign = 'center';
  35572. } else {
  35573. imageStyles.float = 'left';
  35574. clearFix = true;
  35575. }
  35576. var renderedControlItems = imageControls.map(function (item, index) {
  35577. if (typeof item === 'string' && imageControlItems[item]) {
  35578. return external_react_default.a.createElement("a", {
  35579. className: item === 'link' && link ? 'active' : '',
  35580. key: index,
  35581. onClick: function onClick() {
  35582. return _this2.executeCommand(imageControlItems[item].command);
  35583. }
  35584. }, imageControlItems[item].text);
  35585. } else if (item && (item.render || item.text)) {
  35586. return item.render ? item.render(mediaData, _this2.props.block) : external_react_default.a.createElement("a", {
  35587. key: index,
  35588. onClick: function onClick() {
  35589. return item.onClick && _this2.executeCommand(item.onClick);
  35590. }
  35591. }, item.text);
  35592. } else {
  35593. return null;
  35594. }
  35595. });
  35596. return external_react_default.a.createElement("div", {
  35597. className: "bf-media"
  35598. }, external_react_default.a.createElement("div", {
  35599. style: imageStyles,
  35600. draggable: true,
  35601. onMouseEnter: this.showToolbar,
  35602. onMouseMove: this.showToolbar,
  35603. onMouseLeave: this.hideToolbar,
  35604. onDragStart: this.handleDragStart,
  35605. onDragEnd: this.handleDragEnd,
  35606. ref: function ref(instance) {
  35607. return _this2.mediaEmbederInstance = instance;
  35608. },
  35609. className: "bf-image"
  35610. }, toolbarVisible ? external_react_default.a.createElement("div", {
  35611. style: {
  35612. marginLeft: toolbarOffset
  35613. },
  35614. ref: function ref(instance) {
  35615. return _this2.toolbarElement = instance;
  35616. },
  35617. "data-float": float,
  35618. "data-align": alignment,
  35619. className: "bf-media-toolbar"
  35620. }, linkEditorVisible ? external_react_default.a.createElement("div", {
  35621. className: "bf-image-link-editor"
  35622. }, external_react_default.a.createElement("div", {
  35623. className: "editor-input-group"
  35624. }, external_react_default.a.createElement("input", {
  35625. type: "text",
  35626. placeholder: language.linkEditor.inputWithEnterPlaceHolder,
  35627. onKeyDown: this.handleLinkInputKeyDown,
  35628. onChange: this.setImageLink,
  35629. defaultValue: link
  35630. }), external_react_default.a.createElement("button", {
  35631. type: "button",
  35632. onClick: this.confirmImageLink
  35633. }, language.base.confirm)), external_react_default.a.createElement("div", {
  35634. className: "switch-group"
  35635. }, external_react_default.a.createElement(Switch, {
  35636. active: link_target === '_blank',
  35637. onClick: function onClick() {
  35638. return _this2.setImageLinkTarget(link_target);
  35639. }
  35640. }), external_react_default.a.createElement("label", null, language.linkEditor.openInNewWindow))) : null, sizeEditorVisible ? external_react_default.a.createElement("div", {
  35641. className: "bf-image-size-editor"
  35642. }, external_react_default.a.createElement("div", {
  35643. className: "editor-input-group"
  35644. }, external_react_default.a.createElement("input", {
  35645. type: "text",
  35646. placeholder: language.base.width,
  35647. onKeyDown: this.handleSizeInputKeyDown,
  35648. onChange: this.setImageWidth,
  35649. defaultValue: width
  35650. }), external_react_default.a.createElement("input", {
  35651. type: "text",
  35652. placeholder: language.base.height,
  35653. onKeyDown: this.handleSizeInputKeyDown,
  35654. onChange: this.setImageHeight,
  35655. defaultValue: height
  35656. }), external_react_default.a.createElement("button", {
  35657. type: "button",
  35658. onClick: this.confirmImageSize
  35659. }, language.base.confirm))) : null, renderedControlItems, external_react_default.a.createElement("i", {
  35660. style: {
  35661. marginLeft: toolbarOffset * -1
  35662. },
  35663. className: "bf-media-toolbar-arrow"
  35664. })) : null, external_react_default.a.createElement("div", {
  35665. style: {
  35666. position: 'relative',
  35667. width: "".concat(width, "px"),
  35668. height: "".concat(height, "px"),
  35669. display: 'inline-block'
  35670. }
  35671. }, external_react_default.a.createElement("img", extends_default()({
  35672. ref: function ref(instance) {
  35673. return _this2.imageElement = instance;
  35674. },
  35675. src: url,
  35676. width: width,
  35677. height: height
  35678. }, meta)), toolbarVisible && imageResizable ? external_react_default.a.createElement("div", {
  35679. className: "bf-csize-icon right-bottom",
  35680. onMouseDown: this.repareChangeSize('rightbottom')
  35681. }) : null, toolbarVisible && imageResizable ? external_react_default.a.createElement("div", {
  35682. className: "bf-csize-icon left-bottom",
  35683. onMouseDown: this.repareChangeSize('leftbottom')
  35684. }) : null, external_react_default.a.createElement("div", {
  35685. className: "bf-pre-csize ".concat(this.reSizeType),
  35686. style: {
  35687. width: "".concat(tempWidth, "px"),
  35688. height: "".concat(tempHeight, "px")
  35689. }
  35690. }))), clearFix && external_react_default.a.createElement("div", {
  35691. className: "clearfix",
  35692. style: {
  35693. clear: 'both',
  35694. height: 0,
  35695. lineHeight: 0,
  35696. float: 'none'
  35697. }
  35698. }));
  35699. }
  35700. }, {
  35701. key: "lockEditor",
  35702. value: function lockEditor() {
  35703. this.props.editor.lockOrUnlockEditor(true);
  35704. }
  35705. }, {
  35706. key: "unlockEditor",
  35707. value: function unlockEditor() {
  35708. this.props.editor.lockOrUnlockEditor(false);
  35709. }
  35710. }, {
  35711. key: "calcToolbarOffset",
  35712. value: function calcToolbarOffset() {
  35713. var _this$props2 = this.props,
  35714. getContainerNode = _this$props2.getContainerNode,
  35715. containerNode = _this$props2.containerNode;
  35716. var container = getContainerNode ? getContainerNode() : containerNode;
  35717. if (!container) {
  35718. return 0;
  35719. }
  35720. var viewRect = container.querySelector('.bf-content').getBoundingClientRect();
  35721. var toolbarRect = this.toolbarElement.getBoundingClientRect();
  35722. var imageRect = this.imageElement.getBoundingClientRect();
  35723. var right = viewRect.right - (imageRect.right - imageRect.width / 2 + toolbarRect.width / 2);
  35724. var left = imageRect.left + imageRect.width / 2 - toolbarRect.width / 2 - viewRect.left;
  35725. if (right < 10) {
  35726. return right - 10;
  35727. } else if (left < 10) {
  35728. return left * -1 + 10;
  35729. } else {
  35730. return 0;
  35731. }
  35732. }
  35733. }, {
  35734. key: "setImageLinkTarget",
  35735. value: function setImageLinkTarget(link_target) {
  35736. var hookReturns = this.props.hooks('set-image-link-target', link_target)(link_target);
  35737. if (hookReturns === false) {
  35738. return false;
  35739. }
  35740. if (typeof hookReturns === 'string') {
  35741. link_target = hookReturns;
  35742. }
  35743. link_target = link_target === '_blank' ? '' : '_blank';
  35744. this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(this.props.editor.getValue(), this.props.entityKey, {
  35745. link_target: link_target
  35746. }));
  35747. window.setImmediate(this.props.editor.forceRender);
  35748. }
  35749. }]);
  35750. return Image;
  35751. }(external_react_default.a.Component);
  35752. // EXTERNAL MODULE: ./renderers/atomics/Video/style.scss
  35753. var Video_style = __webpack_require__(47);
  35754. // EXTERNAL MODULE: ./components/common/Modal/style.scss
  35755. var Modal_style = __webpack_require__(48);
  35756. // EXTERNAL MODULE: external "react-dom"
  35757. var external_react_dom_ = __webpack_require__(16);
  35758. var external_react_dom_default = /*#__PURE__*/__webpack_require__.n(external_react_dom_);
  35759. // CONCATENATED MODULE: ./components/common/Modal/index.jsx
  35760. var Modal_Modal =
  35761. /*#__PURE__*/
  35762. function (_React$Component) {
  35763. inherits_default()(Modal, _React$Component);
  35764. function Modal(props) {
  35765. var _this;
  35766. classCallCheck_default()(this, Modal);
  35767. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(Modal).call(this, props));
  35768. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleTransitionEnd", function () {
  35769. if (!_this.rootElement || !_this.rootElement.classList) {
  35770. return false;
  35771. }
  35772. if (!_this.rootElement.classList.contains('active')) {
  35773. external_react_dom_default.a.unmountComponentAtNode(_this.rootElement) && _this.rootElement.parentNode.removeChild(_this.rootElement);
  35774. }
  35775. });
  35776. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleMouseDown", function (event) {
  35777. var tagName = event.target.tagName.toLowerCase();
  35778. if (tagName === 'input' || tagName === 'textarea') {
  35779. return false;
  35780. }
  35781. event.preventDefault();
  35782. });
  35783. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCancel", function () {
  35784. _this.props.closeOnCancel && _this.close();
  35785. _this.props.onCancel && _this.props.onCancel();
  35786. });
  35787. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleConfirm", function () {
  35788. _this.props.closeOnConfirm && _this.close();
  35789. _this.props.onConfirm && _this.props.onConfirm();
  35790. });
  35791. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleMaskClick", function () {
  35792. _this.props.closeOnBlur && _this.close();
  35793. _this.props.onBlue && _this.props.onBlue();
  35794. });
  35795. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "close", function () {
  35796. _this.unrenderComponent();
  35797. _this.props.onClose && _this.props.onClose();
  35798. });
  35799. _this.active = false;
  35800. _this.componentId = 'BRAFT-MODAL-' + external_braft_utils_["BaseUtils"].UniqueIndex();
  35801. return _this;
  35802. }
  35803. createClass_default()(Modal, [{
  35804. key: "componentDidMount",
  35805. value: function componentDidMount() {
  35806. if (this.props.visible) {
  35807. this.active = true;
  35808. this.renderComponent(this.props);
  35809. }
  35810. }
  35811. }, {
  35812. key: "componentWillReceiveProps",
  35813. value: function componentWillReceiveProps(next) {
  35814. if (this.props.visible && !next.visible) {
  35815. this.unrenderComponent();
  35816. } else if (this.props.visible || next.visible) {
  35817. this.active = true;
  35818. this.renderComponent(next);
  35819. }
  35820. }
  35821. }, {
  35822. key: "render",
  35823. value: function render() {
  35824. return null;
  35825. }
  35826. }, {
  35827. key: "unrenderComponent",
  35828. value: function unrenderComponent() {
  35829. this.active = false;
  35830. this.activeId && window.clearImmediate(this.activeId);
  35831. if (this.rootElement && this.rootElement.classList) {
  35832. this.rootElement.classList.remove('active');
  35833. }
  35834. }
  35835. }, {
  35836. key: "renderComponent",
  35837. value: function renderComponent(props) {
  35838. var _this2 = this;
  35839. if (!this.active) {
  35840. return false;
  35841. }
  35842. var title = props.title,
  35843. className = props.className,
  35844. width = props.width,
  35845. height = props.height,
  35846. children = props.children,
  35847. component = props.component,
  35848. confirmable = props.confirmable,
  35849. showFooter = props.showFooter,
  35850. showCancel = props.showCancel,
  35851. showConfirm = props.showConfirm,
  35852. showClose = props.showClose,
  35853. cancelText = props.cancelText,
  35854. confirmText = props.confirmText,
  35855. bottomText = props.bottomText,
  35856. language = props.language;
  35857. typeof showCancel === 'undefined' && (showCancel = true);
  35858. typeof showClose === 'undefined' && (showClose = true);
  35859. typeof showConfirm === 'undefined' && (showConfirm = true);
  35860. typeof showFooter === 'undefined' && (showFooter = true);
  35861. var childComponent = external_react_default.a.createElement("div", {
  35862. onMouseDown: this.handleMouseDown,
  35863. className: 'bf-modal ' + (className || '')
  35864. }, external_react_default.a.createElement("div", {
  35865. className: "bf-modal-mask",
  35866. onClick: this.handleMaskClick
  35867. }), external_react_default.a.createElement("div", {
  35868. onTransitionEnd: this.handleTransitionEnd,
  35869. style: {
  35870. width: width,
  35871. height: height
  35872. },
  35873. className: "bf-modal-content"
  35874. }, external_react_default.a.createElement("div", {
  35875. className: "bf-modal-header"
  35876. }, external_react_default.a.createElement("h3", {
  35877. className: "bf-modal-caption"
  35878. }, title), showClose && external_react_default.a.createElement("button", {
  35879. type: "button",
  35880. onClick: this.close,
  35881. className: "bf-modal-close-button"
  35882. }, external_react_default.a.createElement("i", {
  35883. className: "bfi-close"
  35884. }))), external_react_default.a.createElement("div", {
  35885. className: "bf-modal-body"
  35886. }, children || component), showFooter ? external_react_default.a.createElement("div", {
  35887. className: "bf-modal-footer"
  35888. }, external_react_default.a.createElement("div", {
  35889. className: "bf-modal-addon-text"
  35890. }, bottomText), external_react_default.a.createElement("div", {
  35891. className: "bf-modal-buttons"
  35892. }, showCancel && external_react_default.a.createElement("button", {
  35893. type: "button",
  35894. onClick: this.handleCancel,
  35895. className: "bf-modal-cancel"
  35896. }, cancelText || language.base.cancel), showConfirm && external_react_default.a.createElement("button", {
  35897. type: "button",
  35898. onClick: this.handleConfirm,
  35899. className: 'bf-modal-confirm ' + (!confirmable ? 'disabled' : '')
  35900. }, confirmText || language.base.confirm))) : null));
  35901. this.rootElement = document.querySelector('#' + this.componentId);
  35902. if (!this.rootElement) {
  35903. this.rootElement = document.createElement('div');
  35904. this.rootElement.id = this.componentId;
  35905. this.rootElement.className = 'bf-modal-root';
  35906. document.body.appendChild(this.rootElement);
  35907. }
  35908. external_react_dom_default.a.render(childComponent, this.rootElement);
  35909. this.activeId = window.setImmediate(function () {
  35910. _this2.rootElement.classList.add('active');
  35911. });
  35912. }
  35913. }]);
  35914. return Modal;
  35915. }(external_react_default.a.Component);
  35916. defineProperty_default()(Modal_Modal, "defaultProps", {
  35917. showFooter: true,
  35918. closeOnBlur: true
  35919. });
  35920. var Modal_showModal = function showModal(props) {
  35921. var hostNode = document.createElement('div');
  35922. hostNode.style.display = 'none';
  35923. document.body.appendChild(hostNode);
  35924. props = objectSpread_default()({
  35925. visible: true,
  35926. closeOnConfirm: true,
  35927. closeOnCancel: true
  35928. }, props);
  35929. var close = function close() {
  35930. external_react_dom_default.a.unmountComponentAtNode(hostNode) && hostNode.parentNode.removeChild(hostNode);
  35931. };
  35932. var onConfirm = function onConfirm() {
  35933. props.onConfirm && props.onConfirm();
  35934. };
  35935. var onCancel = function onCancel() {
  35936. props.onCancel && props.onCancel();
  35937. };
  35938. var onClose = function onClose() {
  35939. close();
  35940. props.onClose && props.onClose();
  35941. };
  35942. var modalInstance = external_react_dom_default.a.render(external_react_default.a.createElement(Modal_Modal, extends_default()({}, props, {
  35943. onConfirm: onConfirm,
  35944. onCancel: onCancel,
  35945. onClose: onClose
  35946. })), hostNode);
  35947. modalInstance.destroy = close;
  35948. modalInstance.update = modalInstance.renderComponent;
  35949. return modalInstance;
  35950. };
  35951. // EXTERNAL MODULE: ./components/business/PlayerModal/style.scss
  35952. var PlayerModal_style = __webpack_require__(49);
  35953. // CONCATENATED MODULE: ./components/business/PlayerModal/index.jsx
  35954. var PlayerModal_playViaModal = function playViaModal(title, component, language) {
  35955. return Modal_showModal({
  35956. title: title,
  35957. component: component,
  35958. language: language,
  35959. showFooter: false
  35960. });
  35961. };
  35962. var typeIconsMap = {
  35963. 'video': 'bfi-film',
  35964. 'audio': 'bfi-music',
  35965. 'embed': 'bfi-code'
  35966. };
  35967. /* harmony default export */ var PlayerModal = (function (_ref) {
  35968. var title = _ref.title,
  35969. type = _ref.type,
  35970. language = _ref.language,
  35971. name = _ref.name,
  35972. url = _ref.url,
  35973. poster = _ref.poster,
  35974. children = _ref.children,
  35975. onRemove = _ref.onRemove;
  35976. return external_react_default.a.createElement("div", {
  35977. className: "bf-player-holder ".concat(type)
  35978. }, external_react_default.a.createElement("div", {
  35979. className: "icon-badge"
  35980. }, external_react_default.a.createElement("i", {
  35981. className: typeIconsMap[type]
  35982. }), external_react_default.a.createElement("span", {
  35983. className: "text"
  35984. }, language.media[type])), external_react_default.a.createElement("button", {
  35985. onMouseDown: onRemove,
  35986. className: "button-remove"
  35987. }, external_react_default.a.createElement("i", {
  35988. className: "bfi-close"
  35989. })), external_react_default.a.createElement("button", {
  35990. onMouseDown: function onMouseDown() {
  35991. return PlayerModal_playViaModal(name ? "".concat(title, ":").concat(name) : title, children, language);
  35992. },
  35993. className: "button-play"
  35994. }, external_react_default.a.createElement("i", {
  35995. className: "bfi-play_arrow"
  35996. })), name ? external_react_default.a.createElement("h5", {
  35997. className: "bf-name"
  35998. }, name) : null, external_react_default.a.createElement("h6", {
  35999. className: "bf-url"
  36000. }, url), poster ? external_react_default.a.createElement("div", {
  36001. className: "bf-poster",
  36002. style: {
  36003. backgroundImage: "url(".concat(poster, ")")
  36004. }
  36005. }) : null);
  36006. });
  36007. // CONCATENATED MODULE: ./renderers/atomics/Video/index.jsx
  36008. var Video_Video =
  36009. /*#__PURE__*/
  36010. function (_React$Component) {
  36011. inherits_default()(Video, _React$Component);
  36012. function Video() {
  36013. var _getPrototypeOf2;
  36014. var _this;
  36015. classCallCheck_default()(this, Video);
  36016. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  36017. args[_key] = arguments[_key];
  36018. }
  36019. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Video)).call.apply(_getPrototypeOf2, [this].concat(args)));
  36020. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeVideo", function () {
  36021. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  36022. });
  36023. return _this;
  36024. }
  36025. createClass_default()(Video, [{
  36026. key: "render",
  36027. value: function render() {
  36028. var _this$props = this.props,
  36029. mediaData = _this$props.mediaData,
  36030. language = _this$props.language;
  36031. var url = mediaData.url,
  36032. name = mediaData.name,
  36033. meta = mediaData.meta;
  36034. return external_react_default.a.createElement("div", {
  36035. className: "bf-video-wrap"
  36036. }, external_react_default.a.createElement(PlayerModal, {
  36037. type: "video",
  36038. onRemove: this.removeVideo,
  36039. poster: meta ? meta.poster || '' : '',
  36040. language: language,
  36041. url: url,
  36042. name: name,
  36043. title: language.videoPlayer.title
  36044. }, external_react_default.a.createElement("div", {
  36045. className: "bf-video-player"
  36046. }, external_react_default.a.createElement("video", {
  36047. controls: true,
  36048. poster: meta ? meta.poster || '' : ''
  36049. }, external_react_default.a.createElement("source", {
  36050. src: url
  36051. })))));
  36052. }
  36053. }]);
  36054. return Video;
  36055. }(external_react_default.a.Component);
  36056. // EXTERNAL MODULE: ./renderers/atomics/Audio/style.scss
  36057. var Audio_style = __webpack_require__(50);
  36058. // CONCATENATED MODULE: ./renderers/atomics/Audio/index.jsx
  36059. var Audio_Audio =
  36060. /*#__PURE__*/
  36061. function (_React$Component) {
  36062. inherits_default()(Audio, _React$Component);
  36063. function Audio() {
  36064. var _getPrototypeOf2;
  36065. var _this;
  36066. classCallCheck_default()(this, Audio);
  36067. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  36068. args[_key] = arguments[_key];
  36069. }
  36070. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Audio)).call.apply(_getPrototypeOf2, [this].concat(args)));
  36071. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeAudio", function () {
  36072. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  36073. });
  36074. return _this;
  36075. }
  36076. createClass_default()(Audio, [{
  36077. key: "render",
  36078. value: function render() {
  36079. var _this$props = this.props,
  36080. mediaData = _this$props.mediaData,
  36081. language = _this$props.language;
  36082. var url = mediaData.url,
  36083. name = mediaData.name,
  36084. meta = mediaData.meta;
  36085. return external_react_default.a.createElement("div", {
  36086. className: "bf-audio-wrap"
  36087. }, external_react_default.a.createElement(PlayerModal, {
  36088. type: "audio",
  36089. onRemove: this.removeAudio,
  36090. poster: meta ? meta.poster || '' : '',
  36091. language: language,
  36092. url: url,
  36093. name: name,
  36094. title: language.audioPlayer.title
  36095. }, external_react_default.a.createElement("div", {
  36096. className: "bf-audio-player"
  36097. }, external_react_default.a.createElement("audio", {
  36098. controls: true,
  36099. src: url
  36100. }))));
  36101. }
  36102. }]);
  36103. return Audio;
  36104. }(external_react_default.a.Component);
  36105. // EXTERNAL MODULE: ./renderers/atomics/Embed/style.scss
  36106. var Embed_style = __webpack_require__(51);
  36107. // CONCATENATED MODULE: ./renderers/atomics/Embed/index.jsx
  36108. var Embed_Embed =
  36109. /*#__PURE__*/
  36110. function (_React$Component) {
  36111. inherits_default()(Embed, _React$Component);
  36112. function Embed() {
  36113. var _getPrototypeOf2;
  36114. var _this;
  36115. classCallCheck_default()(this, Embed);
  36116. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  36117. args[_key] = arguments[_key];
  36118. }
  36119. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Embed)).call.apply(_getPrototypeOf2, [this].concat(args)));
  36120. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeEmbed", function () {
  36121. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  36122. });
  36123. return _this;
  36124. }
  36125. createClass_default()(Embed, [{
  36126. key: "render",
  36127. value: function render() {
  36128. var _this$props = this.props,
  36129. mediaData = _this$props.mediaData,
  36130. language = _this$props.language;
  36131. var name = mediaData.name,
  36132. url = mediaData.url,
  36133. meta = mediaData.meta;
  36134. return external_react_default.a.createElement("div", {
  36135. className: "bf-embed-wrap"
  36136. }, external_react_default.a.createElement(PlayerModal, {
  36137. type: "embed",
  36138. onRemove: this.removeEmbed,
  36139. poster: meta ? meta.poster || '' : '',
  36140. language: language,
  36141. url: url,
  36142. name: name,
  36143. title: language.videoPlayer.embedTitle
  36144. }, external_react_default.a.createElement("div", {
  36145. className: "bf-embed-player",
  36146. dangerouslySetInnerHTML: {
  36147. __html: url
  36148. }
  36149. })));
  36150. }
  36151. }]);
  36152. return Embed;
  36153. }(external_react_default.a.Component);
  36154. // EXTERNAL MODULE: ./renderers/atomics/HorizontalLine/style.scss
  36155. var HorizontalLine_style = __webpack_require__(52);
  36156. // CONCATENATED MODULE: ./renderers/atomics/HorizontalLine/index.jsx
  36157. var HorizontalLine_HorizontalLine =
  36158. /*#__PURE__*/
  36159. function (_React$Component) {
  36160. inherits_default()(HorizontalLine, _React$Component);
  36161. function HorizontalLine() {
  36162. var _getPrototypeOf2;
  36163. var _this;
  36164. classCallCheck_default()(this, HorizontalLine);
  36165. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  36166. args[_key] = arguments[_key];
  36167. }
  36168. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(HorizontalLine)).call.apply(_getPrototypeOf2, [this].concat(args)));
  36169. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeHorizontalLine", function () {
  36170. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  36171. });
  36172. return _this;
  36173. }
  36174. createClass_default()(HorizontalLine, [{
  36175. key: "render",
  36176. value: function render() {
  36177. return external_react_default.a.createElement("div", {
  36178. className: "bf-hr"
  36179. }, external_react_default.a.createElement("div", {
  36180. className: "bf-media-toolbar"
  36181. }, external_react_default.a.createElement("a", {
  36182. onClick: this.removeHorizontalLine
  36183. }, "\uE9AC")));
  36184. }
  36185. }]);
  36186. return HorizontalLine;
  36187. }(external_react_default.a.Component);
  36188. // CONCATENATED MODULE: ./renderers/block/blockRendererFn.js
  36189. var blockRendererFn_BlockRenderFnContext = function BlockRenderFnContext() {
  36190. var _this = this;
  36191. classCallCheck_default()(this, BlockRenderFnContext);
  36192. defineProperty_default()(this, "superProps", void 0);
  36193. defineProperty_default()(this, "customBlockRendererFn", void 0);
  36194. defineProperty_default()(this, "getRenderFn", function (superProps, customBlockRendererFn) {
  36195. _this.superProps = superProps;
  36196. _this.customBlockRendererFn = customBlockRendererFn;
  36197. return _this.blockRendererFn;
  36198. });
  36199. defineProperty_default()(this, "renderAtomicBlock", function (props) {
  36200. var superProps = _this.superProps;
  36201. var entityKey = props.block.getEntityAt(0);
  36202. if (!entityKey) {
  36203. return null;
  36204. }
  36205. var entity = props.contentState.getEntity(entityKey);
  36206. var mediaData = entity.getData();
  36207. var mediaType = entity.getType();
  36208. var mediaProps = objectSpread_default()({}, superProps, {
  36209. block: props.block,
  36210. mediaData: mediaData,
  36211. entityKey: entityKey
  36212. });
  36213. if (mediaType === 'IMAGE') {
  36214. return external_react_default.a.createElement(Image_Image, mediaProps);
  36215. } else if (mediaType === 'AUDIO') {
  36216. return external_react_default.a.createElement(Audio_Audio, mediaProps);
  36217. } else if (mediaType === 'VIDEO') {
  36218. return external_react_default.a.createElement(Video_Video, mediaProps);
  36219. } else if (mediaType === 'EMBED') {
  36220. return external_react_default.a.createElement(Embed_Embed, mediaProps);
  36221. } else if (mediaType === 'HR') {
  36222. return external_react_default.a.createElement(HorizontalLine_HorizontalLine, mediaProps);
  36223. }
  36224. if (superProps.extendAtomics) {
  36225. var atomics = superProps.extendAtomics;
  36226. for (var i = 0; i < atomics.length; i++) {
  36227. if (mediaType === atomics[i].type) {
  36228. var Component = atomics[i].component;
  36229. return external_react_default.a.createElement(Component, mediaProps);
  36230. }
  36231. }
  36232. }
  36233. return null;
  36234. });
  36235. defineProperty_default()(this, "blockRendererFn", function (block) {
  36236. var customBlockRendererFn = _this.customBlockRendererFn,
  36237. superProps = _this.superProps;
  36238. var blockType = block.getType();
  36239. var blockRenderer = null;
  36240. if (customBlockRendererFn) {
  36241. blockRenderer = customBlockRendererFn(block, superProps) || null;
  36242. }
  36243. if (blockRenderer) {
  36244. return blockRenderer;
  36245. }
  36246. var extensionBlockRendererFns = getExtensionBlockRendererFns(superProps.editorId);
  36247. extensionBlockRendererFns.find(function (item) {
  36248. if (item.blockType === blockType || item.blockType instanceof RegExp && item.blockType.test(blockType)) {
  36249. blockRenderer = item.rendererFn ? item.rendererFn(superProps) : null;
  36250. return true;
  36251. }
  36252. });
  36253. if (blockRenderer) {
  36254. return blockRenderer;
  36255. }
  36256. if (blockType === 'atomic') {
  36257. blockRenderer = {
  36258. component: _this.renderAtomicBlock,
  36259. editable: false
  36260. };
  36261. }
  36262. return blockRenderer;
  36263. });
  36264. };
  36265. var blockRenderFnContext = new blockRendererFn_BlockRenderFnContext();
  36266. /* harmony default export */ var block_blockRendererFn = (blockRenderFnContext.getRenderFn);
  36267. // CONCATENATED MODULE: ./renderers/block/blockStyleFn.js
  36268. /* harmony default export */ var block_blockStyleFn = (function (customBlockStyleFn) {
  36269. return function (block) {
  36270. var blockAlignment = block.getData() && block.getData().get('textAlign');
  36271. var blockIndent = block.getData() && block.getData().get('textIndent');
  36272. var blockFloat = block.getData() && block.getData().get('float');
  36273. var result = '';
  36274. if (blockAlignment) {
  36275. result = "bfa-".concat(blockAlignment);
  36276. }
  36277. if (blockIndent && blockIndent !== 0) {
  36278. result += " bftd-".concat(blockIndent);
  36279. }
  36280. if (blockFloat) {
  36281. result += " bff-".concat(blockFloat);
  36282. }
  36283. if (customBlockStyleFn) {
  36284. result += customBlockStyleFn(block) || '';
  36285. }
  36286. return result;
  36287. };
  36288. });
  36289. // CONCATENATED MODULE: ./renderers/inline/inlineStyleMap.js
  36290. /* harmony default export */ var inlineStyleMap = (function (props) {
  36291. var customStyleMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  36292. var extensionInlineStyleMap = getExtensionInlineStyleMap(props.editorId);
  36293. return objectSpread_default()({
  36294. 'SUPERSCRIPT': {
  36295. position: 'relative',
  36296. top: '-8px',
  36297. fontSize: '11px'
  36298. },
  36299. 'SUBSCRIPT': {
  36300. position: 'relative',
  36301. bottom: '-8px',
  36302. fontSize: '11px'
  36303. }
  36304. }, extensionInlineStyleMap, customStyleMap);
  36305. });
  36306. // CONCATENATED MODULE: ./renderers/inline/inlineStyleFn.js
  36307. var getStyleValue = function getStyleValue(style) {
  36308. return style.split('-')[1];
  36309. };
  36310. /* harmony default export */ var inlineStyleFn = (function (props, options) {
  36311. return function (styles, block) {
  36312. var output = {};
  36313. var fontFamilies = options.fontFamilies,
  36314. unitExportFn = options.unitExportFn,
  36315. customStyleFn = options.customStyleFn;
  36316. var extensionInlineStyleFns = getExtensionInlineStyleFns(props.editorId);
  36317. extensionInlineStyleFns.forEach(function (item) {
  36318. output = item.styleFn ? item.styleFn(styles, block, output) : output;
  36319. });
  36320. output = customStyleFn ? customStyleFn(styles, block, output) : {};
  36321. styles.forEach(function (style) {
  36322. if (style.indexOf('COLOR-') === 0) {
  36323. output.color = '#' + getStyleValue(style);
  36324. } else if (style.indexOf('BGCOLOR-') === 0) {
  36325. output.backgroundColor = '#' + getStyleValue(style);
  36326. } else if (style.indexOf('FONTSIZE-') === 0) {
  36327. output.fontSize = unitExportFn(getStyleValue(style), 'font-size', 'editor');
  36328. } else if (style.indexOf('LINEHEIGHT-') === 0) {
  36329. output.lineHeight = unitExportFn(getStyleValue(style), 'line-height', 'editor');
  36330. } else if (style.indexOf('LETTERSPACING-') === 0) {
  36331. output.letterSpacing = unitExportFn(getStyleValue(style), 'letter-spacing', 'editor');
  36332. } else if (style.indexOf('TEXTINDENT-') === 0) {
  36333. output.textIndent = unitExportFn(getStyleValue(style), 'text-indent', 'editor');
  36334. } else if (style.indexOf('FONTFAMILY-') === 0) {
  36335. output.fontFamily = (fontFamilies.find(function (item) {
  36336. return item.name.toUpperCase() === getStyleValue(style);
  36337. }) || {}).family || '';
  36338. }
  36339. });
  36340. return output;
  36341. };
  36342. });
  36343. // EXTERNAL MODULE: ../node_modules/draft-js-multidecorators/index.js
  36344. var draft_js_multidecorators = __webpack_require__(18);
  36345. var draft_js_multidecorators_default = /*#__PURE__*/__webpack_require__.n(draft_js_multidecorators);
  36346. // CONCATENATED MODULE: ./renderers/decorators/Link/index.jsx
  36347. /* harmony default export */ var Link = (function (props) {
  36348. var children = props.children,
  36349. entityKey = props.entityKey,
  36350. contentState = props.contentState;
  36351. var _contentState$getEnti = contentState.getEntity(entityKey).getData(),
  36352. href = _contentState$getEnti.href,
  36353. target = _contentState$getEnti.target;
  36354. return external_react_default.a.createElement("span", {
  36355. className: "bf-link-wrap"
  36356. }, external_react_default.a.createElement("a", {
  36357. onClick: function onClick(event) {
  36358. return viewLink(event, href);
  36359. },
  36360. className: "bf-link",
  36361. href: href,
  36362. target: target
  36363. }, children));
  36364. });
  36365. var viewLink = function viewLink(event, link) {
  36366. // 当按下Ctrl/command键时,点击打开链接文字中的url
  36367. if (event.getModifierState('Control') || event.getModifierState('Meta')) {
  36368. var tempLink = document.createElement('a');
  36369. tempLink.href = link;
  36370. tempLink.target = event.currentTarget.target;
  36371. tempLink.click();
  36372. }
  36373. };
  36374. // CONCATENATED MODULE: ./renderers/decorators/index.js
  36375. var KEY_SEPARATOR = '-';
  36376. draft_js_multidecorators_default.a.prototype.getDecorations = function (block, contentState) {
  36377. var decorations = Array(block.getText().length).fill(null);
  36378. this.decorators.forEach(function (decorator, i) {
  36379. decorator.getDecorations(block, contentState).forEach(function (key, offset) {
  36380. if (!key) {
  36381. return;
  36382. }
  36383. key = i + KEY_SEPARATOR + key;
  36384. decorations[offset] = key;
  36385. });
  36386. });
  36387. return external_immutable_default.a.List(decorations);
  36388. };
  36389. var builtinDecorators = [{
  36390. type: 'entity',
  36391. decorator: {
  36392. key: 'LINK',
  36393. component: Link
  36394. }
  36395. }];
  36396. var createStrategy = function createStrategy(type) {
  36397. return function (block, callback, contentState) {
  36398. block.findEntityRanges(function (character) {
  36399. var entityKey = character.getEntity();
  36400. return entityKey !== null && contentState.getEntity(entityKey).getType() === type;
  36401. }, callback);
  36402. };
  36403. };
  36404. /* harmony default export */ var decorators = (function (editorId) {
  36405. var extensionDecorators = getExtensionDecorators(editorId);
  36406. var entityDecorators = builtinDecorators.concat(toConsumableArray_default()(extensionDecorators.filter(function (item) {
  36407. return item.type === 'entity';
  36408. })));
  36409. var strategyDecorators = extensionDecorators.filter(function (item) {
  36410. return item.type === 'strategy';
  36411. });
  36412. var classDecorators = extensionDecorators.filter(function (item) {
  36413. return item.type === 'class';
  36414. });
  36415. return new draft_js_multidecorators_default.a(toConsumableArray_default()(classDecorators.map(function (item) {
  36416. return item.decorator;
  36417. })).concat([// combine decorators created with strategy
  36418. new external_draft_js_["CompositeDecorator"](strategyDecorators.map(function (item) {
  36419. return item.decorator;
  36420. })), // combine decorators for entities
  36421. new external_draft_js_["CompositeDecorator"](entityDecorators.map(function (item) {
  36422. return {
  36423. strategy: createStrategy(item.decorator.key),
  36424. component: item.decorator.component
  36425. };
  36426. }))]));
  36427. });
  36428. // CONCATENATED MODULE: ./renderers/index.js
  36429. var getBlockRenderMap = block_blockRenderMap;
  36430. var getBlockRendererFn = block_blockRendererFn;
  36431. var getBlockStyleFn = block_blockStyleFn;
  36432. var getCustomStyleMap = inlineStyleMap;
  36433. var getCustomStyleFn = inlineStyleFn;
  36434. var getDecorators = decorators;
  36435. // EXTERNAL MODULE: ./components/business/ControlBar/style.scss
  36436. var ControlBar_style = __webpack_require__(53);
  36437. // EXTERNAL MODULE: ./components/business/LinkEditor/style.scss
  36438. var LinkEditor_style = __webpack_require__(54);
  36439. // EXTERNAL MODULE: ./components/common/DropDown/style.scss
  36440. var DropDown_style = __webpack_require__(55);
  36441. // CONCATENATED MODULE: ./helpers/responsive.js
  36442. var resizeEventHandlers = [];
  36443. var responsiveHelperInited = false;
  36444. var debouce = false;
  36445. /* harmony default export */ var responsive = ({
  36446. resolve: function resolve(eventHandler) {
  36447. var id = external_braft_utils_["BaseUtils"].UniqueIndex();
  36448. resizeEventHandlers.push({
  36449. id: id,
  36450. eventHandler: eventHandler
  36451. });
  36452. return id;
  36453. },
  36454. unresolve: function unresolve(id) {
  36455. resizeEventHandlers = resizeEventHandlers.filter(function (item) {
  36456. return item.id !== id;
  36457. });
  36458. }
  36459. });
  36460. if (!responsiveHelperInited && (typeof window === "undefined" ? "undefined" : typeof_default()(window)) === 'object') {
  36461. window.addEventListener('resize', function (event) {
  36462. clearTimeout(debouce);
  36463. debouce = setTimeout(function () {
  36464. resizeEventHandlers.map(function (item) {
  36465. typeof item.eventHandler === 'function' && item.eventHandler(event);
  36466. });
  36467. debouce = false;
  36468. }, 100);
  36469. });
  36470. responsiveHelperInited = true;
  36471. }
  36472. // CONCATENATED MODULE: ./components/common/DropDown/index.jsx
  36473. var DropDown_DropDown =
  36474. /*#__PURE__*/
  36475. function (_React$Component) {
  36476. inherits_default()(DropDown, _React$Component);
  36477. function DropDown() {
  36478. var _getPrototypeOf2;
  36479. var _this;
  36480. classCallCheck_default()(this, DropDown);
  36481. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  36482. args[_key] = arguments[_key];
  36483. }
  36484. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(DropDown)).call.apply(_getPrototypeOf2, [this].concat(args)));
  36485. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "responsiveResolveId", null);
  36486. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownHandlerElement", null);
  36487. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownContentElement", null);
  36488. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  36489. active: false,
  36490. offset: 0
  36491. });
  36492. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "fixDropDownPosition", function () {
  36493. var viewRect = _this.props.getContainerNode().getBoundingClientRect();
  36494. var handlerRect = _this.dropDownHandlerElement.getBoundingClientRect();
  36495. var contentRect = _this.dropDownContentElement.getBoundingClientRect();
  36496. var offset = 0;
  36497. var right = handlerRect.right - handlerRect.width / 2 + contentRect.width / 2;
  36498. var left = handlerRect.left + handlerRect.width / 2 - contentRect.width / 2;
  36499. right = viewRect.right - right;
  36500. left = left - viewRect.left;
  36501. if (right < 10) {
  36502. offset = right - 10;
  36503. } else if (left < 10) {
  36504. offset = left * -1 + 10;
  36505. }
  36506. if (offset !== _this.state.offset) {
  36507. _this.setState({
  36508. offset: offset
  36509. });
  36510. }
  36511. });
  36512. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "registerClickEvent", function (event) {
  36513. var autoHide = _this.props.autoHide;
  36514. var active = _this.state.active;
  36515. if (_this.dropDownContentElement.contains(event.target) || _this.dropDownHandlerElement.contains(event.target)) {
  36516. return false;
  36517. }
  36518. autoHide && active && _this.hide();
  36519. });
  36520. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggle", function () {
  36521. _this.setState({
  36522. active: !_this.state.active
  36523. });
  36524. });
  36525. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "show", function () {
  36526. _this.setState({
  36527. active: true
  36528. });
  36529. });
  36530. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "hide", function () {
  36531. _this.setState({
  36532. active: false
  36533. });
  36534. });
  36535. return _this;
  36536. }
  36537. createClass_default()(DropDown, [{
  36538. key: "componentDidMount",
  36539. value: function componentDidMount() {
  36540. if (document) {
  36541. document.body.addEventListener('click', this.registerClickEvent);
  36542. this.responsiveResolveId = responsive.resolve(this.fixDropDownPosition);
  36543. }
  36544. }
  36545. }, {
  36546. key: "componentWillReceiveProps",
  36547. value: function componentWillReceiveProps(next) {
  36548. if (!this.props.disabled && next.disabled) {
  36549. this.hide();
  36550. }
  36551. }
  36552. }, {
  36553. key: "componentDidUpdate",
  36554. value: function componentDidUpdate(prevState) {
  36555. if (!prevState.active && this.state.active) {
  36556. this.fixDropDownPosition();
  36557. }
  36558. }
  36559. }, {
  36560. key: "componentWillUnmount",
  36561. value: function componentWillUnmount() {
  36562. if (document) {
  36563. document.body.removeEventListener('click', this.registerClickEvent);
  36564. responsive.unresolve(this.responsiveResolveId);
  36565. }
  36566. }
  36567. }, {
  36568. key: "render",
  36569. value: function render() {
  36570. var _this2 = this;
  36571. var _this$state = this.state,
  36572. active = _this$state.active,
  36573. offset = _this$state.offset;
  36574. var _this$props = this.props,
  36575. caption = _this$props.caption,
  36576. htmlCaption = _this$props.htmlCaption,
  36577. title = _this$props.title,
  36578. disabled = _this$props.disabled,
  36579. showArrow = _this$props.showArrow,
  36580. arrowActive = _this$props.arrowActive,
  36581. className = _this$props.className,
  36582. children = _this$props.children,
  36583. theme = _this$props.theme;
  36584. disabled && (active = false);
  36585. theme === 'light' && (className = ' light-theme ' + className);
  36586. return external_react_default.a.createElement("div", {
  36587. className: 'bf-dropdown ' + (active ? 'active ' : '') + (disabled ? 'disabled ' : '') + className
  36588. }, htmlCaption ? external_react_default.a.createElement("button", {
  36589. type: "button",
  36590. className: "dropdown-handler",
  36591. "data-title": title,
  36592. onClick: this.toggle,
  36593. dangerouslySetInnerHTML: htmlCaption ? {
  36594. __html: htmlCaption
  36595. } : null,
  36596. ref: function ref(instance) {
  36597. return _this2.dropDownHandlerElement = instance;
  36598. }
  36599. }) : external_react_default.a.createElement("button", {
  36600. type: "button",
  36601. className: "dropdown-handler",
  36602. "data-title": title,
  36603. onClick: this.toggle,
  36604. ref: function ref(instance) {
  36605. return _this2.dropDownHandlerElement = instance;
  36606. }
  36607. }, external_react_default.a.createElement("span", null, caption), showArrow !== false ? external_react_default.a.createElement("i", {
  36608. className: "bfi-drop-down"
  36609. }) : null), external_react_default.a.createElement("div", {
  36610. className: "dropdown-content",
  36611. style: {
  36612. marginLeft: offset
  36613. },
  36614. ref: function ref(instance) {
  36615. return _this2.dropDownContentElement = instance;
  36616. }
  36617. }, external_react_default.a.createElement("i", {
  36618. style: {
  36619. marginLeft: offset * -1
  36620. },
  36621. className: 'dropdown-arrow' + (arrowActive ? ' active' : '')
  36622. }), external_react_default.a.createElement("div", {
  36623. className: "dropdown-content-inner"
  36624. }, children)));
  36625. }
  36626. }]);
  36627. return DropDown;
  36628. }(external_react_default.a.Component);
  36629. // CONCATENATED MODULE: ./components/business/ControlGroup/index.jsx
  36630. /* harmony default export */ var ControlGroup = (function (props) {
  36631. if (external_react_default.a.Fragment) {
  36632. return external_react_default.a.createElement(external_react_default.a.Fragment, null, props.children);
  36633. } else {
  36634. return external_react_default.a.createElement("div", {
  36635. className: "control-item-group"
  36636. }, props.children);
  36637. }
  36638. });
  36639. // CONCATENATED MODULE: ./components/business/LinkEditor/index.jsx
  36640. var LinkEditor_LinkEditor =
  36641. /*#__PURE__*/
  36642. function (_React$Component) {
  36643. inherits_default()(LinkEditor, _React$Component);
  36644. function LinkEditor(props) {
  36645. var _this;
  36646. classCallCheck_default()(this, LinkEditor);
  36647. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(LinkEditor).call(this, props));
  36648. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownInstance", null);
  36649. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handeKeyDown", function (e) {
  36650. if (e.keyCode === 13) {
  36651. _this.handleConfirm();
  36652. e.preventDefault();
  36653. return false;
  36654. }
  36655. });
  36656. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleTnputText", function (e) {
  36657. _this.setState({
  36658. text: e.currentTarget.value
  36659. });
  36660. });
  36661. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleInputLink", function (e) {
  36662. _this.setState({
  36663. href: e.currentTarget.value
  36664. });
  36665. });
  36666. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setTarget", function () {
  36667. _this.setState({
  36668. target: _this.state.target === '_blank' ? '' : '_blank'
  36669. });
  36670. });
  36671. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCancel", function () {
  36672. _this.dropDownInstance.hide();
  36673. });
  36674. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleUnlink", function () {
  36675. _this.dropDownInstance.hide();
  36676. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, false));
  36677. });
  36678. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleConfirm", function () {
  36679. var _this$state = _this.state,
  36680. text = _this$state.text,
  36681. href = _this$state.href,
  36682. target = _this$state.target,
  36683. textSelected = _this$state.textSelected;
  36684. var hookReturns = _this.props.hooks('toggle-link', {
  36685. href: href,
  36686. target: target
  36687. })({
  36688. href: href,
  36689. target: target
  36690. });
  36691. _this.dropDownInstance.hide();
  36692. _this.props.editor.requestFocus();
  36693. if (hookReturns === false) {
  36694. return false;
  36695. }
  36696. if (hookReturns) {
  36697. typeof hookReturns.href === 'string' && (href = hookReturns.href);
  36698. typeof hookReturns.target === 'string' && (target = hookReturns.target);
  36699. }
  36700. if (textSelected) {
  36701. if (href) {
  36702. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, href, target));
  36703. } else {
  36704. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, false));
  36705. }
  36706. } else {
  36707. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].insertText(_this.props.editorState, text || href, null, {
  36708. type: 'LINK',
  36709. data: {
  36710. href: href,
  36711. target: target
  36712. }
  36713. }));
  36714. }
  36715. });
  36716. _this.state = {
  36717. text: '',
  36718. href: '',
  36719. target: props.defaultLinkTarget || '',
  36720. textSelected: false
  36721. };
  36722. return _this;
  36723. }
  36724. createClass_default()(LinkEditor, [{
  36725. key: "componentWillReceiveProps",
  36726. value: function componentWillReceiveProps(nextProps) {
  36727. var _ContentUtils$getSele = external_braft_utils_["ContentUtils"].getSelectionEntityData(nextProps.editorState, 'LINK'),
  36728. href = _ContentUtils$getSele.href,
  36729. target = _ContentUtils$getSele.target;
  36730. var textSelected = !external_braft_utils_["ContentUtils"].isSelectionCollapsed(this.props.editorState) && external_braft_utils_["ContentUtils"].getSelectionBlockType(this.props.editorState) !== 'atomic';
  36731. var selectedText = '';
  36732. if (textSelected) {
  36733. selectedText = external_braft_utils_["ContentUtils"].getSelectionText(this.props.editorState);
  36734. }
  36735. this.setState({
  36736. textSelected: textSelected,
  36737. text: selectedText,
  36738. href: href || '',
  36739. target: typeof target === 'undefined' ? nextProps.defaultLinkTarget || '' : target || ''
  36740. });
  36741. }
  36742. }, {
  36743. key: "render",
  36744. value: function render() {
  36745. var _this2 = this;
  36746. var allowInsertLinkText = this.props.allowInsertLinkText;
  36747. var _this$state2 = this.state,
  36748. text = _this$state2.text,
  36749. href = _this$state2.href,
  36750. target = _this$state2.target,
  36751. textSelected = _this$state2.textSelected;
  36752. var caption = external_react_default.a.createElement("i", {
  36753. className: "bfi-link"
  36754. });
  36755. return external_react_default.a.createElement(ControlGroup, null, external_react_default.a.createElement(DropDown_DropDown, {
  36756. key: 0,
  36757. caption: caption,
  36758. title: this.props.language.controls.link,
  36759. autoHide: true,
  36760. getContainerNode: this.props.getContainerNode,
  36761. showArrow: false,
  36762. ref: function ref(instance) {
  36763. return _this2.dropDownInstance = instance;
  36764. },
  36765. className: 'control-item dropdown link-editor-dropdown'
  36766. }, external_react_default.a.createElement("div", {
  36767. className: "bf-link-editor"
  36768. }, allowInsertLinkText ? external_react_default.a.createElement("div", {
  36769. className: "input-group"
  36770. }, external_react_default.a.createElement("input", {
  36771. type: "text",
  36772. value: text,
  36773. spellCheck: false,
  36774. disabled: textSelected,
  36775. placeholder: this.props.language.linkEditor.textInputPlaceHolder,
  36776. onKeyDown: this.handeKeyDown,
  36777. onChange: this.handleTnputText
  36778. })) : null, external_react_default.a.createElement("div", {
  36779. className: "input-group"
  36780. }, external_react_default.a.createElement("input", {
  36781. type: "text",
  36782. value: href,
  36783. spellCheck: false,
  36784. placeholder: this.props.language.linkEditor.linkInputPlaceHolder,
  36785. onKeyDown: this.handeKeyDown,
  36786. onChange: this.handleInputLink
  36787. })), external_react_default.a.createElement("div", {
  36788. className: "switch-group"
  36789. }, external_react_default.a.createElement(Switch, {
  36790. active: target === '_blank',
  36791. onClick: this.setTarget
  36792. }), external_react_default.a.createElement("label", null, this.props.language.linkEditor.openInNewWindow)), external_react_default.a.createElement("div", {
  36793. className: "buttons"
  36794. }, external_react_default.a.createElement("a", {
  36795. onClick: this.handleUnlink,
  36796. className: "primary button-remove-link pull-left"
  36797. }, external_react_default.a.createElement("i", {
  36798. className: "bfi-close"
  36799. }), external_react_default.a.createElement("span", null, this.props.language.linkEditor.removeLink)), external_react_default.a.createElement("button", {
  36800. type: "button",
  36801. onClick: this.handleConfirm,
  36802. className: "primary pull-right"
  36803. }, this.props.language.base.confirm), external_react_default.a.createElement("button", {
  36804. type: "button",
  36805. onClick: this.handleCancel,
  36806. className: "default pull-right"
  36807. }, this.props.language.base.cancel)))), external_react_default.a.createElement("button", {
  36808. key: 1,
  36809. type: "button",
  36810. "data-title": this.props.language.controls.unlink,
  36811. className: "control-item button",
  36812. onClick: this.handleUnlink,
  36813. disabled: !textSelected || !href
  36814. }, external_react_default.a.createElement("i", {
  36815. className: "bfi-link-off"
  36816. })));
  36817. }
  36818. }]);
  36819. return LinkEditor;
  36820. }(external_react_default.a.Component);
  36821. // EXTERNAL MODULE: ./components/business/Headings/style.scss
  36822. var Headings_style = __webpack_require__(56);
  36823. // CONCATENATED MODULE: ./configs/maps.js
  36824. var maps_getHeadings = function getHeadings(lang) {
  36825. return [{
  36826. key: 'header-one',
  36827. title: lang.controls.header + ' 1',
  36828. text: external_react_default.a.createElement("h1", null, lang.controls.header, " 1"),
  36829. type: 'block-type',
  36830. command: 'header-one'
  36831. }, {
  36832. key: 'header-two',
  36833. title: lang.controls.header + ' 2',
  36834. text: external_react_default.a.createElement("h2", null, lang.controls.header, " 2"),
  36835. type: 'block-type',
  36836. command: 'header-two'
  36837. }, {
  36838. key: 'header-three',
  36839. title: lang.controls.header + ' 3',
  36840. text: external_react_default.a.createElement("h3", null, lang.controls.header, " 3"),
  36841. type: 'block-type',
  36842. command: 'header-three'
  36843. }, {
  36844. key: 'header-four',
  36845. title: lang.controls.header + ' 4',
  36846. text: external_react_default.a.createElement("h4", null, lang.controls.header, " 4"),
  36847. type: 'block-type',
  36848. command: 'header-four'
  36849. }, {
  36850. key: 'header-five',
  36851. title: lang.controls.header + ' 5',
  36852. text: external_react_default.a.createElement("h5", null, lang.controls.header, " 5"),
  36853. type: 'block-type',
  36854. command: 'header-five'
  36855. }, {
  36856. key: 'header-six',
  36857. title: lang.controls.header + ' 6',
  36858. text: external_react_default.a.createElement("h6", null, lang.controls.header, " 6"),
  36859. type: 'block-type',
  36860. command: 'header-six'
  36861. }, {
  36862. key: 'unstyled',
  36863. title: lang.controls.normal,
  36864. text: lang.controls.normal,
  36865. type: 'block-type',
  36866. command: 'unstyled'
  36867. }];
  36868. };
  36869. // CONCATENATED MODULE: ./components/business/Headings/index.jsx
  36870. /* harmony default export */ var Headings = (function (props) {
  36871. var dropDownInstance = null;
  36872. var headings = maps_getHeadings(props.language).filter(function (item) {
  36873. return props.headings.indexOf(item.key) !== -1;
  36874. });
  36875. var currentHeadingIndex = headings.findIndex(function (item) {
  36876. return item.command === props.current;
  36877. });
  36878. var caption = headings[currentHeadingIndex] ? headings[currentHeadingIndex].title : props.language.controls.normal;
  36879. return external_react_default.a.createElement(DropDown_DropDown, {
  36880. caption: caption,
  36881. autoHide: true,
  36882. getContainerNode: props.getContainerNode,
  36883. title: props.language.controls.headings,
  36884. arrowActive: currentHeadingIndex === 0,
  36885. ref: function ref(instance) {
  36886. return dropDownInstance = instance;
  36887. },
  36888. className: 'control-item dropdown headings-dropdown'
  36889. }, external_react_default.a.createElement("ul", {
  36890. className: "menu"
  36891. }, headings.map(function (item, index) {
  36892. var isActive = props.current === item.command;
  36893. return external_react_default.a.createElement("li", {
  36894. key: index,
  36895. className: 'menu-item' + (isActive ? ' active' : ''),
  36896. onClick: function onClick() {
  36897. props.onChange(item.command, item.type), dropDownInstance.hide();
  36898. }
  36899. }, item.text);
  36900. })));
  36901. });
  36902. // EXTERNAL MODULE: ./components/business/TextColor/style.scss
  36903. var TextColor_style = __webpack_require__(57);
  36904. // EXTERNAL MODULE: ./components/common/ColorPicker/style.scss
  36905. var ColorPicker_style = __webpack_require__(58);
  36906. // CONCATENATED MODULE: ./components/common/ColorPicker/index.jsx
  36907. /* harmony default export */ var common_ColorPicker = (function (props) {
  36908. return external_react_default.a.createElement("div", {
  36909. className: "bf-colors-wrap"
  36910. }, external_react_default.a.createElement("ul", {
  36911. className: "bf-colors"
  36912. }, props.presetColors.map(function (item, index) {
  36913. var className = props.color && item.toLowerCase() === props.color.toLowerCase() ? 'color-item active' : 'color-item';
  36914. return external_react_default.a.createElement("li", {
  36915. key: index,
  36916. title: item,
  36917. className: className,
  36918. style: {
  36919. color: item
  36920. },
  36921. "data-color": item.replace('#', ''),
  36922. onClick: function onClick(e) {
  36923. props.onChange(e.currentTarget.dataset.color, true);
  36924. }
  36925. });
  36926. })));
  36927. });
  36928. // CONCATENATED MODULE: ./components/business/TextColor/index.jsx
  36929. var TextColor_TextColor =
  36930. /*#__PURE__*/
  36931. function (_React$Component) {
  36932. inherits_default()(TextColor, _React$Component);
  36933. function TextColor() {
  36934. var _getPrototypeOf2;
  36935. var _this;
  36936. classCallCheck_default()(this, TextColor);
  36937. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  36938. args[_key] = arguments[_key];
  36939. }
  36940. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextColor)).call.apply(_getPrototypeOf2, [this].concat(args)));
  36941. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  36942. colorType: 'color'
  36943. });
  36944. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "switchColorType", function (_ref) {
  36945. var currentTarget = _ref.currentTarget;
  36946. _this.setState({
  36947. colorType: currentTarget.dataset.type
  36948. });
  36949. });
  36950. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleColor", function (color, closePicker) {
  36951. if (color) {
  36952. var hookReturns = _this.props.hooks("toggle-text-".concat(_this.state.colorType), color)(color);
  36953. if (hookReturns === false) {
  36954. return false;
  36955. }
  36956. if (typeof hookReturns === 'string') {
  36957. color = hookReturns;
  36958. }
  36959. if (_this.state.colorType === 'color') {
  36960. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionColor(_this.props.editorState, color));
  36961. } else {
  36962. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBackgroundColor(_this.props.editorState, color));
  36963. }
  36964. }
  36965. if (closePicker) {
  36966. _this.dropDownInstance.hide();
  36967. _this.props.editor.requestFocus();
  36968. }
  36969. });
  36970. return _this;
  36971. }
  36972. createClass_default()(TextColor, [{
  36973. key: "render",
  36974. value: function render() {
  36975. var _this2 = this;
  36976. var captionStyle = {};
  36977. var currentColor = null;
  36978. var colorType = this.state.colorType;
  36979. var selectionStyles = this.props.editorState.getCurrentInlineStyle().toJS();
  36980. selectionStyles.forEach(function (style) {
  36981. if (style.indexOf('COLOR-') === 0) {
  36982. captionStyle.color = '#' + style.split('-')[1];
  36983. colorType === 'color' && (currentColor = captionStyle.color);
  36984. }
  36985. if (style.indexOf('BGCOLOR-') === 0) {
  36986. captionStyle.backgroundColor = '#' + style.split('-')[1];
  36987. colorType === 'background-color' && (currentColor = captionStyle.backgroundColor);
  36988. }
  36989. });
  36990. var caption = external_react_default.a.createElement("i", {
  36991. style: captionStyle,
  36992. className: "bfi-text-color"
  36993. }, external_react_default.a.createElement("span", {
  36994. className: "path1"
  36995. }), external_react_default.a.createElement("span", {
  36996. className: "path2"
  36997. }));
  36998. var ColorPicker = this.props.colorPicker || common_ColorPicker;
  36999. return external_react_default.a.createElement(DropDown_DropDown, {
  37000. caption: caption,
  37001. title: this.props.language.controls.color,
  37002. showArrow: false,
  37003. autoHide: this.props.autoHide,
  37004. theme: this.props.theme,
  37005. getContainerNode: this.props.getContainerNode,
  37006. ref: function ref(instance) {
  37007. return _this2.dropDownInstance = instance;
  37008. },
  37009. className: 'control-item dropdown text-color-dropdown'
  37010. }, external_react_default.a.createElement("div", {
  37011. className: "bf-text-color-picker-wrap"
  37012. }, external_react_default.a.createElement("div", {
  37013. className: "bf-color-switch-buttons",
  37014. style: this.props.enableBackgroundColor ? {} : {
  37015. display: 'none'
  37016. }
  37017. }, external_react_default.a.createElement("button", {
  37018. type: "button",
  37019. "data-type": "color",
  37020. className: colorType === 'color' ? 'active' : '',
  37021. onClick: this.switchColorType
  37022. }, this.props.language.controls.textColor), external_react_default.a.createElement("button", {
  37023. type: "button",
  37024. "data-type": "background-color",
  37025. className: colorType === 'background-color' ? 'active' : '',
  37026. onClick: this.switchColorType
  37027. }, this.props.language.controls.backgroundColor)), external_react_default.a.createElement(ColorPicker, {
  37028. width: 200,
  37029. color: currentColor,
  37030. disableAlpha: true,
  37031. presetColors: this.props.colors,
  37032. onChange: this.toggleColor
  37033. })));
  37034. }
  37035. }]);
  37036. return TextColor;
  37037. }(external_react_default.a.Component);
  37038. // EXTERNAL MODULE: ./components/business/FontSize/style.scss
  37039. var FontSize_style = __webpack_require__(59);
  37040. // CONCATENATED MODULE: ./components/business/FontSize/index.jsx
  37041. var FontSize_toggleFontSize = function toggleFontSize(event, props) {
  37042. var fontSize = event.currentTarget.dataset.size;
  37043. var hookReturns = props.hooks('toggle-font-size', fontSize)(fontSize);
  37044. if (hookReturns === false) {
  37045. return false;
  37046. }
  37047. if (!isNaN(fontSize)) {
  37048. fontSize = hookReturns;
  37049. }
  37050. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionFontSize(props.editorState, fontSize));
  37051. props.editor.requestFocus();
  37052. };
  37053. /* harmony default export */ var FontSize = (function (props) {
  37054. var caption = null;
  37055. var currentFontSize = null;
  37056. var dropDownInstance = null;
  37057. props.fontSizes.find(function (item) {
  37058. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'FONTSIZE-' + item)) {
  37059. caption = item;
  37060. currentFontSize = item;
  37061. return true;
  37062. }
  37063. return false;
  37064. });
  37065. return external_react_default.a.createElement(DropDown_DropDown, {
  37066. autoHide: true,
  37067. caption: caption || props.defaultCaption,
  37068. getContainerNode: props.getContainerNode,
  37069. title: props.language.controls.fontSize,
  37070. ref: function ref(instance) {
  37071. return dropDownInstance = instance;
  37072. },
  37073. className: 'control-item dropdown bf-font-size-dropdown'
  37074. }, external_react_default.a.createElement("ul", {
  37075. className: "bf-font-sizes"
  37076. }, props.fontSizes.map(function (item, index) {
  37077. return external_react_default.a.createElement("li", {
  37078. key: index,
  37079. className: item === currentFontSize ? 'active' : null,
  37080. "data-size": item,
  37081. onClick: function onClick(event) {
  37082. FontSize_toggleFontSize(event, props), dropDownInstance.hide();
  37083. }
  37084. }, item);
  37085. })));
  37086. });
  37087. // EXTERNAL MODULE: ./components/business/LineHeight/style.scss
  37088. var LineHeight_style = __webpack_require__(60);
  37089. // CONCATENATED MODULE: ./components/business/LineHeight/index.jsx
  37090. var LineHeight_toggleLineHeight = function toggleLineHeight(event, props) {
  37091. var lineHeight = event.currentTarget.dataset.size;
  37092. var hookReturns = props.hooks('toggle-line-height', lineHeight)(lineHeight);
  37093. if (hookReturns === false) {
  37094. return false;
  37095. }
  37096. if (!isNaN(hookReturns)) {
  37097. lineHeight = hookReturns;
  37098. }
  37099. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLineHeight(props.editorState, lineHeight));
  37100. props.editor.requestFocus();
  37101. };
  37102. /* harmony default export */ var LineHeight = (function (props) {
  37103. var caption = null;
  37104. var currentLineHeight = null;
  37105. var dropDownInstance = null;
  37106. props.lineHeights.find(function (item) {
  37107. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'LINEHEIGHT-' + item)) {
  37108. caption = item;
  37109. currentLineHeight = item;
  37110. return true;
  37111. }
  37112. return false;
  37113. });
  37114. return external_react_default.a.createElement(DropDown_DropDown, {
  37115. autoHide: true,
  37116. caption: caption || props.defaultCaption,
  37117. getContainerNode: props.getContainerNode,
  37118. title: props.language.controls.lineHeight,
  37119. ref: function ref(instance) {
  37120. return dropDownInstance = instance;
  37121. },
  37122. className: 'control-item dropdown bf-line-height-dropdown'
  37123. }, external_react_default.a.createElement("ul", {
  37124. className: "bf-line-heights"
  37125. }, props.lineHeights.map(function (item, index) {
  37126. return external_react_default.a.createElement("li", {
  37127. key: index,
  37128. className: item === currentLineHeight ? 'active' : null,
  37129. "data-size": item,
  37130. onClick: function onClick(event) {
  37131. LineHeight_toggleLineHeight(event, props), dropDownInstance.hide();
  37132. }
  37133. }, item);
  37134. })));
  37135. });
  37136. // EXTERNAL MODULE: ./components/business/FontFamily/style.scss
  37137. var FontFamily_style = __webpack_require__(61);
  37138. // CONCATENATED MODULE: ./components/business/FontFamily/index.jsx
  37139. var FontFamily_toggleFontFamily = function toggleFontFamily(event, props) {
  37140. var fontFamilyName = event.currentTarget.dataset.name;
  37141. var hookReturns = props.hooks('toggle-font-family', fontFamilyName)(fontFamilyName, props.fontFamilies);
  37142. if (hookReturns === false) {
  37143. return false;
  37144. }
  37145. if (typeof hookReturns === 'string') {
  37146. fontFamilyName = hookReturns;
  37147. }
  37148. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionFontFamily(props.editorState, fontFamilyName));
  37149. props.editor.requestFocus();
  37150. };
  37151. /* harmony default export */ var FontFamily = (function (props) {
  37152. var caption = null;
  37153. var currentIndex = null;
  37154. var dropDownInstance = null;
  37155. props.fontFamilies.find(function (item, index) {
  37156. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'FONTFAMILY-' + item.name)) {
  37157. caption = item.name;
  37158. currentIndex = index;
  37159. return true;
  37160. }
  37161. return false;
  37162. });
  37163. return external_react_default.a.createElement(DropDown_DropDown, {
  37164. caption: caption || props.defaultCaption,
  37165. getContainerNode: props.getContainerNode,
  37166. title: props.language.controls.fontFamily,
  37167. autoHide: true,
  37168. arrowActive: currentIndex === 0,
  37169. ref: function ref(instance) {
  37170. return dropDownInstance = instance;
  37171. },
  37172. className: 'control-item dropdown font-family-dropdown'
  37173. }, external_react_default.a.createElement("ul", {
  37174. className: "menu"
  37175. }, props.fontFamilies.map(function (item, index) {
  37176. return external_react_default.a.createElement("li", {
  37177. key: index,
  37178. className: 'menu-item ' + (index === currentIndex ? 'active' : ''),
  37179. "data-name": item.name,
  37180. onClick: function onClick(event) {
  37181. FontFamily_toggleFontFamily(event, props), dropDownInstance.hide();
  37182. }
  37183. }, external_react_default.a.createElement("span", {
  37184. style: {
  37185. fontFamily: item.family
  37186. }
  37187. }, item.name));
  37188. })));
  37189. });
  37190. // CONCATENATED MODULE: ./components/business/TextAlign/index.jsx
  37191. var TextAlign_TextAlign =
  37192. /*#__PURE__*/
  37193. function (_React$Component) {
  37194. inherits_default()(TextAlign, _React$Component);
  37195. function TextAlign() {
  37196. var _getPrototypeOf2;
  37197. var _this;
  37198. classCallCheck_default()(this, TextAlign);
  37199. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  37200. args[_key] = arguments[_key];
  37201. }
  37202. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextAlign)).call.apply(_getPrototypeOf2, [this].concat(args)));
  37203. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  37204. currentAlignment: undefined
  37205. });
  37206. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setAlignment", function (event) {
  37207. var alignment = event.currentTarget.dataset.alignment;
  37208. var hookReturns = _this.props.hooks('toggle-text-alignment', alignment)(alignment);
  37209. if (_this.props.textAligns.indexOf(hookReturns) > -1) {
  37210. alignment = hookReturns;
  37211. }
  37212. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionAlignment(_this.props.editorState, alignment));
  37213. _this.props.editor.requestFocus();
  37214. });
  37215. return _this;
  37216. }
  37217. createClass_default()(TextAlign, [{
  37218. key: "componentWillReceiveProps",
  37219. value: function componentWillReceiveProps(next) {
  37220. this.setState({
  37221. currentAlignment: external_braft_utils_["ContentUtils"].getSelectionBlockData(next.editorState, 'textAlign')
  37222. });
  37223. }
  37224. }, {
  37225. key: "render",
  37226. value: function render() {
  37227. var _this2 = this;
  37228. var textAlignmentTitles = [this.props.language.controls.alignLeft, this.props.language.controls.alignCenter, this.props.language.controls.alignRight, this.props.language.controls.alignJustify];
  37229. return external_react_default.a.createElement(ControlGroup, null, this.props.textAligns.map(function (item, index) {
  37230. return external_react_default.a.createElement("button", {
  37231. type: "button",
  37232. key: index,
  37233. "data-title": textAlignmentTitles[index],
  37234. "data-alignment": item,
  37235. className: 'control-item button ' + (item === _this2.state.currentAlignment ? 'active' : null),
  37236. onClick: _this2.setAlignment
  37237. }, external_react_default.a.createElement("i", {
  37238. className: 'bfi-align-' + item
  37239. }));
  37240. }));
  37241. }
  37242. }]);
  37243. return TextAlign;
  37244. }(external_react_default.a.Component);
  37245. // EXTERNAL MODULE: ./components/business/EmojiPicker/style.scss
  37246. var EmojiPicker_style = __webpack_require__(62);
  37247. // CONCATENATED MODULE: ./components/business/EmojiPicker/index.jsx
  37248. var EmojiPicker_insertEmoji = function insertEmoji(event, props) {
  37249. var emoji = event.currentTarget.dataset.emoji;
  37250. var hookReturns = props.hooks('insert-emoji', emoji)(emoji);
  37251. if (hookReturns === false) {
  37252. return false;
  37253. }
  37254. if (typeof hookReturns === 'string') {
  37255. emoji = hookReturns;
  37256. }
  37257. props.editor.setValue(external_braft_utils_["ContentUtils"].insertText(props.editorState, emoji));
  37258. props.editor.requestFocus();
  37259. };
  37260. /* harmony default export */ var EmojiPicker = (function (props) {
  37261. return external_react_default.a.createElement(DropDown_DropDown, {
  37262. caption: props.defaultCaption,
  37263. autoHide: true,
  37264. showArrow: false,
  37265. getContainerNode: props.getContainerNode,
  37266. title: props.language.controls.emoji,
  37267. className: 'control-item dropdown bf-emoji-dropdown'
  37268. }, external_react_default.a.createElement("div", {
  37269. className: "bf-emojis-wrap"
  37270. }, external_react_default.a.createElement("ul", {
  37271. className: "bf-emojis"
  37272. }, props.emojis.map(function (item, index) {
  37273. return external_react_default.a.createElement("li", {
  37274. key: index,
  37275. "data-emoji": item,
  37276. onClick: function onClick(event) {
  37277. return EmojiPicker_insertEmoji(event, props);
  37278. }
  37279. }, item);
  37280. }))));
  37281. });
  37282. // EXTERNAL MODULE: ./components/business/LetterSpacing/style.scss
  37283. var LetterSpacing_style = __webpack_require__(63);
  37284. // CONCATENATED MODULE: ./components/business/LetterSpacing/index.jsx
  37285. var LetterSpacing_toggleLetterSpacing = function toggleLetterSpacing(event, props) {
  37286. var letterSpacing = event.currentTarget.dataset.size;
  37287. var hookReturns = props.hooks('toggle-letter-spacing', letterSpacing)(letterSpacing);
  37288. if (hookReturns === false) {
  37289. return false;
  37290. }
  37291. if (!isNaN(hookReturns)) {
  37292. letterSpacing = hookReturns;
  37293. }
  37294. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLetterSpacing(props.editorState, letterSpacing));
  37295. props.editor.requestFocus();
  37296. };
  37297. /* harmony default export */ var LetterSpacing = (function (props) {
  37298. var caption = null;
  37299. var currentLetterSpacing = null;
  37300. var dropDownInstance = null;
  37301. props.letterSpacings.find(function (item) {
  37302. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'LETTERSPACING-' + item)) {
  37303. caption = item;
  37304. currentLetterSpacing = item;
  37305. return true;
  37306. }
  37307. return false;
  37308. });
  37309. return external_react_default.a.createElement(DropDown_DropDown, {
  37310. autoHide: true,
  37311. caption: caption || props.defaultCaption,
  37312. getContainerNode: props.getContainerNode,
  37313. title: props.language.controls.letterSpacing,
  37314. ref: function ref(instance) {
  37315. return dropDownInstance = instance;
  37316. },
  37317. className: 'control-item dropdown bf-letter-spacing-dropdown'
  37318. }, external_react_default.a.createElement("ul", {
  37319. className: "bf-letter-spacings"
  37320. }, props.letterSpacings.map(function (item, index) {
  37321. return external_react_default.a.createElement("li", {
  37322. key: index,
  37323. className: item === currentLetterSpacing ? 'active' : null,
  37324. "data-size": item,
  37325. onClick: function onClick(event) {
  37326. LetterSpacing_toggleLetterSpacing(event, props), dropDownInstance.hide();
  37327. }
  37328. }, item);
  37329. })));
  37330. });
  37331. // CONCATENATED MODULE: ./components/business/TextIndent/index.jsx
  37332. var TextIndent_TextAlign =
  37333. /*#__PURE__*/
  37334. function (_React$Component) {
  37335. inherits_default()(TextAlign, _React$Component);
  37336. function TextAlign() {
  37337. var _getPrototypeOf2;
  37338. var _this;
  37339. classCallCheck_default()(this, TextAlign);
  37340. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  37341. args[_key] = arguments[_key];
  37342. }
  37343. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextAlign)).call.apply(_getPrototypeOf2, [this].concat(args)));
  37344. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  37345. currentIndent: 0
  37346. });
  37347. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "increaseIndent", function () {
  37348. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].increaseSelectionIndent(_this.props.editorState));
  37349. _this.props.editor.requestFocus();
  37350. });
  37351. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "decreaseIndent", function () {
  37352. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].decreaseSelectionIndent(_this.props.editorState));
  37353. _this.props.editor.requestFocus();
  37354. });
  37355. return _this;
  37356. }
  37357. createClass_default()(TextAlign, [{
  37358. key: "componentWillReceiveProps",
  37359. value: function componentWillReceiveProps(nextProps) {
  37360. this.setState({
  37361. currentIndent: external_braft_utils_["ContentUtils"].getSelectionBlockData(nextProps.editorState, 'textIndent') || 0
  37362. });
  37363. }
  37364. }, {
  37365. key: "render",
  37366. value: function render() {
  37367. var currentIndent = this.state.currentIndent;
  37368. var language = this.props.language;
  37369. return external_react_default.a.createElement(ControlGroup, null, external_react_default.a.createElement("button", {
  37370. key: 0,
  37371. type: "button",
  37372. "data-title": language.controls.increaseIndent,
  37373. disabled: currentIndent >= 6,
  37374. className: "control-item button button-indent-increase".concat(currentIndent > 0 && currentIndent < 6 ? ' active' : ''),
  37375. onClick: this.increaseIndent
  37376. }, external_react_default.a.createElement("i", {
  37377. className: 'bfi-indent-increase'
  37378. })), external_react_default.a.createElement("button", {
  37379. key: 1,
  37380. type: "button",
  37381. "data-title": language.controls.decreaseIndent,
  37382. disabled: currentIndent <= 0,
  37383. className: "control-item button button-indent-decrease",
  37384. onClick: this.decreaseIndent
  37385. }, external_react_default.a.createElement("i", {
  37386. className: 'bfi-indent-decrease'
  37387. })));
  37388. }
  37389. }]);
  37390. return TextAlign;
  37391. }(external_react_default.a.Component);
  37392. // CONCATENATED MODULE: ./components/business/ControlBar/index.jsx
  37393. var commandHookMap = {
  37394. 'inline-style': 'toggle-inline-style',
  37395. 'block-type': 'change-block-type',
  37396. 'editor-method': 'exec-editor-command'
  37397. };
  37398. var exclusiveInlineStyles = {
  37399. 'superscript': 'subscript',
  37400. 'subscript': 'superscript'
  37401. };
  37402. var mergeControls = function mergeControls(commonProps, builtControls, extensionControls, extendControls) {
  37403. extensionControls = extensionControls.map(function (item) {
  37404. return typeof item === 'function' ? item(commonProps) : item;
  37405. });
  37406. extendControls = extendControls.map(function (item) {
  37407. return typeof item === 'function' ? item(commonProps) : item;
  37408. });
  37409. if (extensionControls.length === 0 && extendControls.length === 0) {
  37410. return builtControls;
  37411. }
  37412. return builtControls.map(function (item) {
  37413. return extendControls.find(function (subItem) {
  37414. return subItem.replace === (item.key || item);
  37415. }) || extensionControls.find(function (subItem) {
  37416. return subItem.replace === (item.key || item);
  37417. }) || item;
  37418. }).concat(extensionControls.length ? 'separator' : '').concat(extensionControls.filter(function (item) {
  37419. return !item.replace;
  37420. })).concat(extendControls.filter(function (item) {
  37421. return typeof item === 'string' || !item.replace;
  37422. }));
  37423. };
  37424. var ControlBar_ControlBar =
  37425. /*#__PURE__*/
  37426. function (_React$Component) {
  37427. inherits_default()(ControlBar, _React$Component);
  37428. function ControlBar() {
  37429. var _getPrototypeOf2;
  37430. var _this;
  37431. classCallCheck_default()(this, ControlBar);
  37432. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  37433. args[_key] = arguments[_key];
  37434. }
  37435. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(ControlBar)).call.apply(_getPrototypeOf2, [this].concat(args)));
  37436. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "allControls", []);
  37437. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "mediaLibiraryModal", null);
  37438. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "extendedModals", {});
  37439. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "openBraftFinder", function () {
  37440. if (!_this.props.braftFinder || !_this.props.braftFinder.ReactComponent) {
  37441. return false;
  37442. }
  37443. if (_this.props.hooks('open-braft-finder')() === false) {
  37444. return false;
  37445. }
  37446. var mediaProps = _this.props.media;
  37447. var MediaLibrary = _this.props.braftFinder.ReactComponent;
  37448. _this.mediaLibiraryModal = Modal_showModal({
  37449. title: _this.props.language.controls.mediaLibirary,
  37450. language: _this.props.language,
  37451. width: 640,
  37452. showFooter: false,
  37453. component: external_react_default.a.createElement(MediaLibrary, {
  37454. accepts: mediaProps.accepts,
  37455. onCancel: _this.closeBraftFinder,
  37456. onInsert: _this.insertMedias,
  37457. onChange: mediaProps.onChange,
  37458. externals: mediaProps.externals,
  37459. onBeforeSelect: _this.bindBraftFinderHook('select-medias'),
  37460. onBeforeDeselect: _this.bindBraftFinderHook('deselect-medias'),
  37461. onBeforeRemove: _this.bindBraftFinderHook('remove-medias'),
  37462. onBeforeInsert: _this.bindBraftFinderHook('insert-medias'),
  37463. onFileSelect: _this.bindBraftFinderHook('select-files')
  37464. })
  37465. });
  37466. });
  37467. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "bindBraftFinderHook", function (hookName) {
  37468. return function () {
  37469. return _this.props.hooks(hookName, arguments.length <= 0 ? undefined : arguments[0]).apply(void 0, arguments);
  37470. };
  37471. });
  37472. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "insertMedias", function (medias) {
  37473. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(_this.props.editorState, medias));
  37474. _this.props.editor.requestFocus();
  37475. _this.props.media.onInsert && _this.props.media.onInsert(medias);
  37476. _this.closeBraftFinder();
  37477. });
  37478. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "closeBraftFinder", function () {
  37479. _this.props.media.onCancel && _this.props.media.onCancel();
  37480. _this.mediaLibiraryModal && _this.mediaLibiraryModal.close();
  37481. });
  37482. return _this;
  37483. }
  37484. createClass_default()(ControlBar, [{
  37485. key: "componentDidUpdate",
  37486. value: function componentDidUpdate() {
  37487. var _this2 = this;
  37488. var language = this.props.language;
  37489. this.allControls.forEach(function (item) {
  37490. if (item.type === 'modal') {
  37491. if (item.modal && item.modal.id && _this2.extendedModals[item.modal.id]) {
  37492. _this2.extendedModals[item.modal.id].update(objectSpread_default()({}, item.modal, {
  37493. language: language
  37494. }));
  37495. }
  37496. }
  37497. });
  37498. }
  37499. }, {
  37500. key: "getControlItemClassName",
  37501. value: function getControlItemClassName(data) {
  37502. var className = 'control-item button';
  37503. var type = data.type,
  37504. command = data.command;
  37505. if (type === 'inline-style' && external_braft_utils_["ContentUtils"].selectionHasInlineStyle(this.props.editorState, command)) {
  37506. className += ' active';
  37507. } else if (type === 'block-type' && external_braft_utils_["ContentUtils"].getSelectionBlockType(this.props.editorState) === command) {
  37508. className += ' active';
  37509. } else if (type === 'entity' && external_braft_utils_["ContentUtils"].getSelectionEntityType(this.props.editorState) === command) {
  37510. className += ' active';
  37511. }
  37512. return className;
  37513. }
  37514. }, {
  37515. key: "applyControl",
  37516. value: function applyControl(command, type) {
  37517. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  37518. var hookReturns = this.props.hooks(commandHookMap[type] || type, command)(command);
  37519. var editorState = this.props.editorState;
  37520. if (hookReturns === false) {
  37521. return false;
  37522. }
  37523. if (typeof hookReturns === 'string') {
  37524. command = hookReturns;
  37525. }
  37526. if (type === 'inline-style') {
  37527. var exclusiveInlineStyle = exclusiveInlineStyles[command];
  37528. if (exclusiveInlineStyle && external_braft_utils_["ContentUtils"].selectionHasInlineStyle(editorState, exclusiveInlineStyle)) {
  37529. editorState = external_braft_utils_["ContentUtils"].toggleSelectionInlineStyle(editorState, exclusiveInlineStyle);
  37530. }
  37531. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionInlineStyle(editorState, command));
  37532. } else if (type === 'block-type') {
  37533. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, command));
  37534. } else if (type === 'entity') {
  37535. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionEntity(editorState, {
  37536. type: command,
  37537. mutability: data.mutability || 'MUTABLE',
  37538. data: data.data || {}
  37539. }));
  37540. } else if (type === 'editor-method') {
  37541. this.props.editor[command] && this.props.editor[command]();
  37542. }
  37543. }
  37544. }, {
  37545. key: "render",
  37546. value: function render() {
  37547. var _this3 = this;
  37548. var _this$props = this.props,
  37549. editor = _this$props.editor,
  37550. editorId = _this$props.editorId,
  37551. editorState = _this$props.editorState,
  37552. className = _this$props.className,
  37553. style = _this$props.style,
  37554. controls = _this$props.controls,
  37555. media = _this$props.media,
  37556. extendControls = _this$props.extendControls,
  37557. language = _this$props.language,
  37558. hooks = _this$props.hooks,
  37559. colors = _this$props.colors,
  37560. colorPicker = _this$props.colorPicker,
  37561. colorPickerTheme = _this$props.colorPickerTheme,
  37562. colorPickerAutoHide = _this$props.colorPickerAutoHide,
  37563. headings = _this$props.headings,
  37564. fontSizes = _this$props.fontSizes,
  37565. fontFamilies = _this$props.fontFamilies,
  37566. emojis = _this$props.emojis,
  37567. getContainerNode = _this$props.getContainerNode,
  37568. lineHeights = _this$props.lineHeights,
  37569. letterSpacings = _this$props.letterSpacings,
  37570. textAligns = _this$props.textAligns,
  37571. textBackgroundColor = _this$props.textBackgroundColor,
  37572. allowInsertLinkText = _this$props.allowInsertLinkText,
  37573. defaultLinkTarget = _this$props.defaultLinkTarget;
  37574. var currentBlockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  37575. var commonProps = {
  37576. editor: editor,
  37577. editorId: editorId,
  37578. editorState: editorState,
  37579. language: language,
  37580. getContainerNode: getContainerNode,
  37581. hooks: hooks
  37582. };
  37583. var renderedControls = [];
  37584. var editorControls = configs_controls(language, editor);
  37585. var extensionControls = getExtensionControls(editorId);
  37586. var allControls = mergeControls(commonProps, controls, extensionControls, extendControls);
  37587. this.allControls = allControls;
  37588. return external_react_default.a.createElement("div", {
  37589. className: "bf-controlbar ".concat(className || ''),
  37590. style: style,
  37591. onMouseDown: this.preventDefault
  37592. }, allControls.map(function (item, index) {
  37593. var itemKey = typeof item === 'string' ? item : item.key;
  37594. if (typeof itemKey !== 'string') {
  37595. return null;
  37596. }
  37597. if (renderedControls.indexOf(itemKey) > -1) {
  37598. return null;
  37599. }
  37600. if (itemKey.toLowerCase() === 'separator') {
  37601. return external_react_default.a.createElement("span", {
  37602. key: index,
  37603. className: "separator-line"
  37604. });
  37605. }
  37606. var controlItem = editorControls.find(function (subItem) {
  37607. return subItem.key.toLowerCase() === itemKey.toLowerCase();
  37608. });
  37609. if (typeof item !== 'string') {
  37610. controlItem = objectSpread_default()({}, controlItem, item);
  37611. }
  37612. if (!controlItem) {
  37613. return null;
  37614. }
  37615. renderedControls.push(itemKey);
  37616. if (controlItem.type === 'headings') {
  37617. return external_react_default.a.createElement(Headings, extends_default()({
  37618. key: index,
  37619. headings: headings,
  37620. current: currentBlockType,
  37621. onChange: function onChange(command) {
  37622. return _this3.applyControl(command, 'block-type');
  37623. }
  37624. }, commonProps));
  37625. } else if (controlItem.type === 'text-color') {
  37626. return external_react_default.a.createElement(TextColor_TextColor, extends_default()({
  37627. key: index,
  37628. colors: colors,
  37629. colorPicker: colorPicker,
  37630. theme: colorPickerTheme,
  37631. autoHide: colorPickerAutoHide,
  37632. enableBackgroundColor: textBackgroundColor
  37633. }, commonProps));
  37634. } else if (controlItem.type === 'font-size') {
  37635. return external_react_default.a.createElement(FontSize, extends_default()({
  37636. key: index,
  37637. fontSizes: fontSizes,
  37638. defaultCaption: controlItem.title
  37639. }, commonProps));
  37640. } else if (controlItem.type === 'line-height') {
  37641. return external_react_default.a.createElement(LineHeight, extends_default()({
  37642. key: index,
  37643. lineHeights: lineHeights,
  37644. defaultCaption: controlItem.title
  37645. }, commonProps));
  37646. } else if (controlItem.type === 'letter-spacing') {
  37647. return external_react_default.a.createElement(LetterSpacing, extends_default()({
  37648. key: index,
  37649. letterSpacings: letterSpacings,
  37650. defaultCaption: controlItem.title
  37651. }, commonProps));
  37652. } else if (controlItem.type === 'text-indent') {
  37653. return external_react_default.a.createElement(TextIndent_TextAlign, extends_default()({
  37654. key: index,
  37655. defaultCaption: controlItem.title
  37656. }, commonProps));
  37657. } else if (controlItem.type === 'font-family') {
  37658. return external_react_default.a.createElement(FontFamily, extends_default()({
  37659. key: index,
  37660. fontFamilies: fontFamilies,
  37661. defaultCaption: controlItem.title
  37662. }, commonProps));
  37663. } else if (controlItem.type === 'emoji') {
  37664. return external_react_default.a.createElement(EmojiPicker, extends_default()({
  37665. key: index,
  37666. emojis: emojis,
  37667. defaultCaption: controlItem.text
  37668. }, commonProps));
  37669. } else if (controlItem.type === 'link') {
  37670. return external_react_default.a.createElement(LinkEditor_LinkEditor, extends_default()({
  37671. key: index,
  37672. defaultLinkTarget: defaultLinkTarget,
  37673. allowInsertLinkText: allowInsertLinkText
  37674. }, commonProps));
  37675. } else if (controlItem.type === 'text-align') {
  37676. return external_react_default.a.createElement(TextAlign_TextAlign, extends_default()({
  37677. key: index,
  37678. textAligns: textAligns
  37679. }, commonProps));
  37680. } else if (controlItem.type === 'media') {
  37681. if (!media.image && !media.video && !media.audio) {
  37682. return null;
  37683. }
  37684. return external_react_default.a.createElement("button", {
  37685. type: "button",
  37686. key: index,
  37687. "data-title": controlItem.title,
  37688. disabled: controlItem.disabled,
  37689. className: "control-item media button",
  37690. onClick: _this3.openBraftFinder
  37691. }, controlItem.text);
  37692. } else if (controlItem.type === 'dropdown') {
  37693. return external_react_default.a.createElement(DropDown_DropDown, extends_default()({
  37694. key: index,
  37695. className: "control-item extend-control-item dropdown ".concat(controlItem.className || ''),
  37696. caption: controlItem.text,
  37697. htmlCaption: controlItem.html,
  37698. showArrow: controlItem.showArrow,
  37699. title: controlItem.title,
  37700. arrowActive: controlItem.arrowActive,
  37701. theme: controlItem.theme,
  37702. autoHide: controlItem.autoHide,
  37703. disabled: controlItem.disabled,
  37704. ref: controlItem.ref
  37705. }, commonProps), controlItem.component);
  37706. } else if (controlItem.type === 'modal') {
  37707. return external_react_default.a.createElement("button", {
  37708. type: "button",
  37709. key: index,
  37710. "data-title": controlItem.title,
  37711. disabled: controlItem.disabled,
  37712. className: "control-item extend-control-item button ".concat(controlItem.className || ''),
  37713. dangerouslySetInnerHTML: controlItem.html ? {
  37714. __html: controlItem.html
  37715. } : null,
  37716. onClick: function onClick(event) {
  37717. if (controlItem.modal && controlItem.modal.id) {
  37718. if (_this3.extendedModals[controlItem.modal.id]) {
  37719. _this3.extendedModals[controlItem.modal.id].active = true;
  37720. _this3.extendedModals[controlItem.modal.id].update(objectSpread_default()({}, controlItem.modal, {
  37721. language: language
  37722. }));
  37723. } else {
  37724. _this3.extendedModals[controlItem.modal.id] = Modal_showModal(objectSpread_default()({}, controlItem.modal, {
  37725. language: language
  37726. }));
  37727. controlItem.modal.onCreate && controlItem.modal.onCreate(_this3.extendedModals[controlItem.modal.id]);
  37728. }
  37729. }
  37730. controlItem.onClick && controlItem.onClick(event);
  37731. }
  37732. }, !controlItem.html ? controlItem.text : null);
  37733. } else if (controlItem.type === 'component') {
  37734. return external_react_default.a.createElement("div", {
  37735. key: index,
  37736. className: "component-wrapper ".concat(controlItem.className || '')
  37737. }, controlItem.component);
  37738. } else if (controlItem.type === 'button') {
  37739. return external_react_default.a.createElement("button", {
  37740. type: "button",
  37741. key: index,
  37742. "data-title": controlItem.title,
  37743. disabled: controlItem.disabled,
  37744. className: "control-item button ".concat(controlItem.className || ''),
  37745. dangerouslySetInnerHTML: controlItem.html ? {
  37746. __html: controlItem.html
  37747. } : null,
  37748. onClick: function onClick(event) {
  37749. return controlItem.onClick && controlItem.onClick(event);
  37750. }
  37751. }, !controlItem.html ? controlItem.text : null);
  37752. } else if (controlItem) {
  37753. var disabled = false;
  37754. if (controlItem.command === 'undo') {
  37755. disabled = editorState.getUndoStack().size === 0;
  37756. } else if (controlItem.command === 'redo') {
  37757. disabled = editorState.getRedoStack().size === 0;
  37758. }
  37759. return external_react_default.a.createElement("button", {
  37760. type: "button",
  37761. key: index,
  37762. disabled: disabled,
  37763. "data-title": controlItem.title,
  37764. className: _this3.getControlItemClassName({
  37765. type: controlItem.type,
  37766. command: controlItem.command
  37767. }),
  37768. onClick: function onClick() {
  37769. return _this3.applyControl(controlItem.command, controlItem.type, controlItem.data);
  37770. }
  37771. }, controlItem.text);
  37772. }
  37773. }));
  37774. }
  37775. }, {
  37776. key: "preventDefault",
  37777. value: function preventDefault(event) {
  37778. var tagName = event.target.tagName.toLowerCase();
  37779. if (tagName === 'input' || tagName === 'label') ; else {
  37780. event.preventDefault();
  37781. }
  37782. }
  37783. }]);
  37784. return ControlBar;
  37785. }(external_react_default.a.Component);
  37786. // CONCATENATED MODULE: ./editor/index.jsx
  37787. var buildHooks = function buildHooks(hooks) {
  37788. return function (hookName) {
  37789. var defaultReturns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  37790. return hooks[hookName] || function () {
  37791. return defaultReturns;
  37792. };
  37793. };
  37794. };
  37795. var filterColors = function filterColors(colors, colors2) {
  37796. return colors.filter(function (item) {
  37797. return !colors2.find(function (color) {
  37798. return color.toLowerCase() === item.toLowerCase();
  37799. });
  37800. }).filter(function (item, index, array) {
  37801. return array.indexOf(item) === index;
  37802. });
  37803. };
  37804. var editor_isControlEnabled = function isControlEnabled(props, controlName) {
  37805. return toConsumableArray_default()(props.controls).concat(toConsumableArray_default()(props.extendControls)).find(function (item) {
  37806. return item === controlName || item.key === controlName;
  37807. }) && props.excludeControls.indexOf(controlName) === -1;
  37808. };
  37809. var editor_getConvertOptions = function getConvertOptions(props) {
  37810. var editorId = props.editorId || props.id;
  37811. var convertOptions = objectSpread_default()({}, configs_props.converts, props.converts, {
  37812. fontFamilies: props.fontFamilies
  37813. });
  37814. convertOptions.styleImportFn = compositeStyleImportFn(convertOptions.styleImportFn, editorId);
  37815. convertOptions.styleExportFn = compositeStyleExportFn(convertOptions.styleExportFn, editorId);
  37816. convertOptions.entityImportFn = compositeEntityImportFn(convertOptions.entityImportFn, editorId);
  37817. convertOptions.entityExportFn = compositeEntityExportFn(convertOptions.entityExportFn, editorId);
  37818. convertOptions.blockImportFn = compositeBlockImportFn(convertOptions.blockImportFn, editorId);
  37819. convertOptions.blockExportFn = compositeBlockExportFn(convertOptions.blockExportFn, editorId);
  37820. return convertOptions;
  37821. };
  37822. var editor_BraftEditor =
  37823. /*#__PURE__*/
  37824. function (_React$Component) {
  37825. inherits_default()(BraftEditor, _React$Component);
  37826. function BraftEditor(props) {
  37827. var _this;
  37828. classCallCheck_default()(this, BraftEditor);
  37829. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(BraftEditor).call(this, props));
  37830. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onChange", function (editorState, callback) {
  37831. if (!(editorState instanceof external_draft_js_["EditorState"])) {
  37832. editorState = external_draft_js_["EditorState"].set(editorState, {
  37833. decorator: _this.editorDecorators
  37834. });
  37835. }
  37836. if (!editorState.convertOptions) {
  37837. editorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  37838. }
  37839. _this.setState({
  37840. editorState: editorState
  37841. }, function () {
  37842. _this.props.onChange && _this.props.onChange(editorState);
  37843. callback && callback(editorState);
  37844. });
  37845. });
  37846. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getDraftInstance", function () {
  37847. return _this.draftInstance;
  37848. });
  37849. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getFinderInstance", function () {
  37850. return _this.braftFinder;
  37851. });
  37852. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getValue", function () {
  37853. return _this.state.editorState;
  37854. });
  37855. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setValue", function (editorState, callback) {
  37856. return _this.onChange(editorState, callback);
  37857. });
  37858. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "forceRender", function () {
  37859. var selectionState = _this.state.editorState.getSelection();
  37860. _this.setValue(external_draft_js_["EditorState"].set(_this.state.editorState, {
  37861. decorator: _this.editorDecorators
  37862. }), function () {
  37863. _this.setValue(external_draft_js_["EditorState"].forceSelection(_this.state.editorState, selectionState));
  37864. });
  37865. });
  37866. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onTab", function (event) {
  37867. if (handlers_keyCommandHandlers('tab', _this.state.editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this))) === 'handled') {
  37868. event.preventDefault();
  37869. }
  37870. _this.editorProps.onTab && _this.editorProps.onTab(event);
  37871. });
  37872. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onFocus", function () {
  37873. _this.isFocused = true;
  37874. _this.editorProps.onFocus && _this.editorProps.onFocus(_this.state.editorState);
  37875. });
  37876. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onBlur", function () {
  37877. _this.isFocused = false;
  37878. _this.editorProps.onBlur && _this.editorProps.onBlur(_this.state.editorState);
  37879. });
  37880. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "requestFocus", function () {
  37881. setTimeout(function () {
  37882. return _this.draftInstance.focus();
  37883. }, 0);
  37884. });
  37885. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleKeyCommand", function (command, editorState) {
  37886. return handlers_keyCommandHandlers(command, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  37887. });
  37888. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleReturn", function (event, editorState) {
  37889. return handlers_returnHandlers(event, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  37890. });
  37891. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleBeforeInput", function (chars, editorState) {
  37892. return beforeInputHandlers(chars, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  37893. });
  37894. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDrop", function (selectionState, dataTransfer) {
  37895. return handlers_dropHandlers(selectionState, dataTransfer, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  37896. });
  37897. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDroppedFiles", function (selectionState, files) {
  37898. return droppedFilesHandlers(selectionState, files, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  37899. });
  37900. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handlePastedFiles", function (files) {
  37901. return pastedFilesHandlers(files, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  37902. });
  37903. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCopyContent", function (event) {
  37904. return handlers_copyHandlers(event, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  37905. });
  37906. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handlePastedText", function (text, html, editorState) {
  37907. return handlers_pastedTextHandlers(text, html, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  37908. });
  37909. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCompositionStart", function (event) {
  37910. return handlers_compositionStartHandler(event, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  37911. });
  37912. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "undo", function () {
  37913. _this.setValue(external_braft_utils_["ContentUtils"].undo(_this.state.editorState));
  37914. });
  37915. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "redo", function () {
  37916. _this.setValue(external_braft_utils_["ContentUtils"].redo(_this.state.editorState));
  37917. });
  37918. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeSelectionInlineStyles", function () {
  37919. _this.setValue(external_braft_utils_["ContentUtils"].removeSelectionInlineStyles(_this.state.editorState));
  37920. });
  37921. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "insertHorizontalLine", function () {
  37922. _this.setValue(external_braft_utils_["ContentUtils"].insertHorizontalLine(_this.state.editorState));
  37923. });
  37924. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "clearEditorContent", function () {
  37925. _this.setValue(external_braft_utils_["ContentUtils"].clear(_this.state.editorState), function (editorState) {
  37926. _this.setValue(external_braft_utils_["ContentUtils"].toggleSelectionIndent(editorState, 0));
  37927. });
  37928. });
  37929. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleFullscreen", function (fullscreen) {
  37930. _this.setState({
  37931. isFullscreen: typeof fullscreen !== 'undefined' ? fullscreen : !_this.state.isFullscreen
  37932. }, function () {
  37933. _this.editorProps.onFullscreen && _this.editorProps.onFullscreen(_this.state.isFullscreen);
  37934. });
  37935. });
  37936. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setEditorContainerNode", function (containerNode) {
  37937. _this.containerNode = containerNode;
  37938. });
  37939. _this.editorProps = _this.getEditorProps(props);
  37940. _this.editorDecorators = getDecorators(_this.editorProps.editorId || _this.editorProps.id);
  37941. _this.isFocused = false;
  37942. _this.isLiving = false;
  37943. _this.braftFinder = null;
  37944. _this.valueInitialized = !!(_this.props.defaultValue || _this.props.value);
  37945. var defaultEditorState = (_this.props.defaultValue || _this.props.value) instanceof external_draft_js_["EditorState"] ? _this.props.defaultValue || _this.props.value : external_draft_js_["EditorState"].createEmpty(_this.editorDecorators);
  37946. defaultEditorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  37947. var tempColors = [];
  37948. if (external_braft_utils_["ContentUtils"].isEditorState(defaultEditorState)) {
  37949. var colors = external_braft_utils_["ColorUtils"].detectColorsFromDraftState(defaultEditorState.toRAW(true));
  37950. defaultEditorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  37951. tempColors = filterColors(colors, _this.editorProps.colors);
  37952. }
  37953. _this.state = {
  37954. tempColors: tempColors,
  37955. editorState: defaultEditorState,
  37956. isFullscreen: false,
  37957. draftProps: {}
  37958. };
  37959. _this.containerNode = null;
  37960. return _this;
  37961. }
  37962. createClass_default()(BraftEditor, [{
  37963. key: "getEditorProps",
  37964. value: function getEditorProps(props) {
  37965. var _this2 = this;
  37966. props = props || this.props;
  37967. var _props = props,
  37968. value = _props.value,
  37969. defaultValue = _props.defaultValue,
  37970. onChange = _props.onChange,
  37971. restProps = objectWithoutProperties_default()(_props, ["value", "defaultValue", "onChange"]); // eslint-disable-line no-unused-vars
  37972. var propInterceptors = getPropInterceptors(restProps.editorId || restProps.id);
  37973. if (propInterceptors.length === 0) {
  37974. return restProps;
  37975. }
  37976. var porpsMap = Object(external_immutable_["Map"])(restProps);
  37977. propInterceptors.forEach(function (interceptor) {
  37978. porpsMap = porpsMap.merge(Object(external_immutable_["Map"])(interceptor(porpsMap.toJS(), _this2) || {}));
  37979. });
  37980. return porpsMap.toJS();
  37981. }
  37982. }, {
  37983. key: "componentWillMount",
  37984. value: function componentWillMount() {
  37985. if (editor_isControlEnabled(this.editorProps, 'media')) {
  37986. var _this$editorProps = this.editorProps,
  37987. language = _this$editorProps.language,
  37988. media = _this$editorProps.media;
  37989. var _defaultProps$media$m = objectSpread_default()({}, configs_props.media, media),
  37990. uploadFn = _defaultProps$media$m.uploadFn,
  37991. validateFn = _defaultProps$media$m.validateFn,
  37992. items = _defaultProps$media$m.items;
  37993. this.braftFinder = new external_braft_finder_default.a({
  37994. items: items,
  37995. language: language,
  37996. uploader: uploadFn,
  37997. validator: validateFn
  37998. });
  37999. this.forceUpdate();
  38000. }
  38001. }
  38002. }, {
  38003. key: "componentDidMount",
  38004. value: function componentDidMount() {
  38005. this.isLiving = true;
  38006. }
  38007. }, {
  38008. key: "componentDidUpdate",
  38009. value: function componentDidUpdate(_, prevState) {
  38010. if (prevState.editorState !== this.state.editorState) {
  38011. this.state.editorState.setConvertOptions(editor_getConvertOptions(this.editorProps));
  38012. }
  38013. }
  38014. }, {
  38015. key: "componentWillReceiveProps",
  38016. value: function componentWillReceiveProps(props) {
  38017. var _this3 = this;
  38018. this.editorProps = this.getEditorProps(props);
  38019. var editorState = props.value;
  38020. var _this$editorProps2 = this.editorProps,
  38021. media = _this$editorProps2.media,
  38022. language = _this$editorProps2.language;
  38023. var currentProps = this.getEditorProps();
  38024. if (!editor_isControlEnabled(currentProps, 'media') && editor_isControlEnabled(this.editorProps, 'media') && !this.braftFinder) {
  38025. var _defaultProps$media$m2 = objectSpread_default()({}, configs_props.media, media),
  38026. uploadFn = _defaultProps$media$m2.uploadFn,
  38027. validateFn = _defaultProps$media$m2.validateFn,
  38028. items = _defaultProps$media$m2.items;
  38029. this.braftFinder = new external_braft_finder_default.a({
  38030. items: items,
  38031. language: language,
  38032. uploader: uploadFn,
  38033. validator: validateFn
  38034. });
  38035. this.forceUpdate();
  38036. }
  38037. if (media && media.items && this.braftFinder) {
  38038. this.braftFinder.setItems(media.items);
  38039. }
  38040. var nextEditorState;
  38041. if (!this.valueInitialized && typeof this.props.defaultValue === 'undefined' && external_braft_utils_["ContentUtils"].isEditorState(props.defaultValue)) {
  38042. nextEditorState = props.defaultValue;
  38043. } else if (external_braft_utils_["ContentUtils"].isEditorState(editorState)) {
  38044. nextEditorState = editorState;
  38045. }
  38046. if (nextEditorState) {
  38047. if (nextEditorState && nextEditorState !== this.state.editorState) {
  38048. var tempColors = external_braft_utils_["ColorUtils"].detectColorsFromDraftState(nextEditorState.toRAW(true));
  38049. nextEditorState.setConvertOptions(editor_getConvertOptions(this.editorProps));
  38050. this.setState({
  38051. tempColors: filterColors(toConsumableArray_default()(this.state.tempColors).concat(toConsumableArray_default()(tempColors)), currentProps.colors),
  38052. editorState: nextEditorState
  38053. }, function () {
  38054. _this3.props.onChange && _this3.props.onChange(nextEditorState);
  38055. });
  38056. } else {
  38057. this.setState({
  38058. editorState: nextEditorState
  38059. });
  38060. }
  38061. }
  38062. }
  38063. }, {
  38064. key: "componentWillUnmount",
  38065. value: function componentWillUnmount() {
  38066. this.isLiving = false;
  38067. this.controlBarInstance && this.controlBarInstance.closeBraftFinder();
  38068. }
  38069. }, {
  38070. key: "lockOrUnlockEditor",
  38071. value: function lockOrUnlockEditor(editorLocked) {
  38072. this.setState({
  38073. editorLocked: editorLocked
  38074. });
  38075. }
  38076. }, {
  38077. key: "render",
  38078. value: function render() {
  38079. var _this4 = this;
  38080. var _this$editorProps3 = this.editorProps,
  38081. id = _this$editorProps3.id,
  38082. editorId = _this$editorProps3.editorId,
  38083. controls = _this$editorProps3.controls,
  38084. excludeControls = _this$editorProps3.excludeControls,
  38085. extendControls = _this$editorProps3.extendControls,
  38086. readOnly = _this$editorProps3.readOnly,
  38087. disabled = _this$editorProps3.disabled,
  38088. media = _this$editorProps3.media,
  38089. language = _this$editorProps3.language,
  38090. colors = _this$editorProps3.colors,
  38091. colorPicker = _this$editorProps3.colorPicker,
  38092. colorPickerTheme = _this$editorProps3.colorPickerTheme,
  38093. colorPickerAutoHide = _this$editorProps3.colorPickerAutoHide,
  38094. hooks = _this$editorProps3.hooks,
  38095. fontSizes = _this$editorProps3.fontSizes,
  38096. fontFamilies = _this$editorProps3.fontFamilies,
  38097. emojis = _this$editorProps3.emojis,
  38098. placeholder = _this$editorProps3.placeholder,
  38099. fixPlaceholder = _this$editorProps3.fixPlaceholder,
  38100. headings = _this$editorProps3.headings,
  38101. imageControls = _this$editorProps3.imageControls,
  38102. imageResizable = _this$editorProps3.imageResizable,
  38103. lineHeights = _this$editorProps3.lineHeights,
  38104. letterSpacings = _this$editorProps3.letterSpacings,
  38105. textAligns = _this$editorProps3.textAligns,
  38106. textBackgroundColor = _this$editorProps3.textBackgroundColor,
  38107. allowInsertLinkText = _this$editorProps3.allowInsertLinkText,
  38108. defaultLinkTarget = _this$editorProps3.defaultLinkTarget,
  38109. extendAtomics = _this$editorProps3.extendAtomics,
  38110. className = _this$editorProps3.className,
  38111. style = _this$editorProps3.style,
  38112. controlBarClassName = _this$editorProps3.controlBarClassName,
  38113. controlBarStyle = _this$editorProps3.controlBarStyle,
  38114. contentClassName = _this$editorProps3.contentClassName,
  38115. contentStyle = _this$editorProps3.contentStyle,
  38116. stripPastedStyles = _this$editorProps3.stripPastedStyles,
  38117. componentBelowControlBar = _this$editorProps3.componentBelowControlBar;
  38118. var _this$state = this.state,
  38119. isFullscreen = _this$state.isFullscreen,
  38120. editorState = _this$state.editorState;
  38121. editorId = editorId || id;
  38122. hooks = buildHooks(hooks);
  38123. controls = controls.filter(function (item) {
  38124. return excludeControls.indexOf(item) === -1;
  38125. });
  38126. language = (typeof language === 'function' ? language(languages, 'braft-editor') : languages[language]) || languages[configs_props.language];
  38127. var externalMedias = media && media.externals ? objectSpread_default()({}, configs_props.media.externals, media.externals) : configs_props.media.externals;
  38128. var accepts = media && media.accepts ? objectSpread_default()({}, configs_props.media.accepts, media.accepts) : configs_props.media.accepts;
  38129. media = objectSpread_default()({}, configs_props.media, media, {
  38130. externalMedias: externalMedias,
  38131. accepts: accepts
  38132. });
  38133. if (!media.uploadFn) {
  38134. media.video = false;
  38135. media.audio = false;
  38136. }
  38137. var controlBarProps = {
  38138. editor: this,
  38139. editorState: editorState,
  38140. braftFinder: this.braftFinder,
  38141. ref: function ref(instance) {
  38142. return _this4.controlBarInstance = instance;
  38143. },
  38144. getContainerNode: function getContainerNode() {
  38145. return _this4.containerNode;
  38146. },
  38147. className: controlBarClassName,
  38148. style: controlBarStyle,
  38149. colors: toConsumableArray_default()(colors).concat(toConsumableArray_default()(this.state.tempColors)),
  38150. colorPicker: colorPicker,
  38151. colorPickerTheme: colorPickerTheme,
  38152. colorPickerAutoHide: colorPickerAutoHide,
  38153. hooks: hooks,
  38154. editorId: editorId,
  38155. media: media,
  38156. controls: controls,
  38157. language: language,
  38158. extendControls: extendControls,
  38159. headings: headings,
  38160. fontSizes: fontSizes,
  38161. fontFamilies: fontFamilies,
  38162. emojis: emojis,
  38163. lineHeights: lineHeights,
  38164. letterSpacings: letterSpacings,
  38165. textAligns: textAligns,
  38166. textBackgroundColor: textBackgroundColor,
  38167. allowInsertLinkText: allowInsertLinkText,
  38168. defaultLinkTarget: defaultLinkTarget
  38169. };
  38170. var unitExportFn = editorState.convertOptions.unitExportFn;
  38171. var commonProps = {
  38172. editor: this,
  38173. editorId: editorId,
  38174. hooks: hooks,
  38175. editorState: editorState,
  38176. containerNode: this.containerNode,
  38177. imageControls: imageControls,
  38178. imageResizable: imageResizable,
  38179. language: language,
  38180. extendAtomics: extendAtomics
  38181. };
  38182. var blockRendererFn = getBlockRendererFn(commonProps, this.editorProps.blockRendererFn);
  38183. var blockRenderMap = getBlockRenderMap(commonProps, this.editorProps.blockRenderMap);
  38184. var blockStyleFn = getBlockStyleFn(this.editorProps.blockStyleFn);
  38185. var customStyleMap = getCustomStyleMap(commonProps, this.editorProps.customStyleMap);
  38186. var customStyleFn = getCustomStyleFn(commonProps, {
  38187. fontFamilies: fontFamilies,
  38188. unitExportFn: unitExportFn,
  38189. customStyleFn: this.editorProps.customStyleFn
  38190. });
  38191. var keyBindingFn = keybindings(this.editorProps.keyBindingFn);
  38192. var mixedProps = {};
  38193. if (this.state.editorLocked || this.editorProps.disabled || this.editorProps.readOnly || this.editorProps.draftProps.readOnly) {
  38194. mixedProps.readOnly = true;
  38195. }
  38196. if (placeholder && fixPlaceholder && editorState.isEmpty() && editorState.getCurrentContent().getFirstBlock().getType() !== 'unstyled') {
  38197. placeholder = '';
  38198. }
  38199. var draftProps = objectSpread_default()({
  38200. ref: function ref(instance) {
  38201. _this4.draftInstance = instance;
  38202. },
  38203. editorState: editorState,
  38204. handleKeyCommand: this.handleKeyCommand,
  38205. handleReturn: this.handleReturn,
  38206. handleBeforeInput: this.handleBeforeInput,
  38207. handleDrop: this.handleDrop,
  38208. handleDroppedFiles: this.handleDroppedFiles,
  38209. handlePastedText: this.handlePastedText,
  38210. handlePastedFiles: this.handlePastedFiles,
  38211. onChange: this.onChange,
  38212. onTab: this.onTab,
  38213. onFocus: this.onFocus,
  38214. onBlur: this.onBlur,
  38215. blockRenderMap: blockRenderMap,
  38216. blockRendererFn: blockRendererFn,
  38217. blockStyleFn: blockStyleFn,
  38218. customStyleMap: customStyleMap,
  38219. customStyleFn: customStyleFn,
  38220. keyBindingFn: keyBindingFn,
  38221. placeholder: placeholder,
  38222. stripPastedStyles: stripPastedStyles
  38223. }, this.editorProps.draftProps, mixedProps);
  38224. return external_react_default.a.createElement("div", {
  38225. style: style,
  38226. ref: this.setEditorContainerNode,
  38227. className: "bf-container ".concat(className).concat(disabled ? ' disabled' : '').concat(readOnly ? ' read-only' : '').concat(isFullscreen ? ' fullscreen' : '')
  38228. }, external_react_default.a.createElement(ControlBar_ControlBar, controlBarProps), componentBelowControlBar, external_react_default.a.createElement("div", {
  38229. onCompositionStart: this.handleCompositionStart,
  38230. className: "bf-content ".concat(contentClassName),
  38231. onCopy: this.handleCopyContent,
  38232. style: contentStyle
  38233. }, external_react_default.a.createElement(external_draft_js_["Editor"], draftProps)));
  38234. }
  38235. }]);
  38236. return BraftEditor;
  38237. }(external_react_default.a.Component);
  38238. defineProperty_default()(editor_BraftEditor, "defaultProps", configs_props);
  38239. // EXTERNAL MODULE: external "braft-convert"
  38240. var external_braft_convert_ = __webpack_require__(14);
  38241. // CONCATENATED MODULE: ./index.jsx
  38242. /* concated harmony reexport EditorState */__webpack_require__.d(__webpack_exports__, "EditorState", function() { return external_draft_js_["EditorState"]; });
  38243. /* concated harmony reexport getDecorators */__webpack_require__.d(__webpack_exports__, "getDecorators", function() { return getDecorators; });
  38244. external_draft_js_["EditorState"].prototype.setConvertOptions = function () {
  38245. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  38246. this.convertOptions = options;
  38247. };
  38248. external_draft_js_["EditorState"].prototype.toHTML = function () {
  38249. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  38250. var convertOptions = this.convertOptions || {};
  38251. return Object(external_braft_convert_["convertEditorStateToHTML"])(this, objectSpread_default()({}, convertOptions, options));
  38252. };
  38253. external_draft_js_["EditorState"].prototype.toRAW = function (noStringify) {
  38254. return noStringify ? Object(external_braft_convert_["convertEditorStateToRaw"])(this) : JSON.stringify(Object(external_braft_convert_["convertEditorStateToRaw"])(this));
  38255. };
  38256. external_draft_js_["EditorState"].prototype.toText = function () {
  38257. return this.getCurrentContent().getPlainText();
  38258. };
  38259. external_draft_js_["EditorState"].prototype.isEmpty = function () {
  38260. return !this.getCurrentContent().hasText();
  38261. };
  38262. editor_BraftEditor.createEditorState = external_draft_js_["EditorState"].createFrom = function (content) {
  38263. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  38264. options.unitExportFn = options.unitExportFn || editor_BraftEditor.defaultProps.converts.unitExportFn;
  38265. options.styleImportFn = compositeStyleImportFn(options.styleImportFn, options.editorId);
  38266. options.entityImportFn = compositeEntityImportFn(options.entityImportFn, options.editorId);
  38267. options.blockImportFn = compositeBlockImportFn(options.blockImportFn, options.editorId);
  38268. var editorState = null;
  38269. if (content instanceof external_draft_js_["EditorState"]) {
  38270. editorState = content;
  38271. } else if (typeof_default()(content) === 'object' && content && content.blocks && content.entityMap) {
  38272. editorState = Object(external_braft_convert_["convertRawToEditorState"])(content, getDecorators(options.editorId));
  38273. } else if (typeof content === 'string') {
  38274. try {
  38275. if (/^(-)?\d+$/.test(content)) {
  38276. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content, getDecorators(options.editorId), options, 'create');
  38277. } else {
  38278. editorState = external_draft_js_["EditorState"].createFrom(JSON.parse(content), options);
  38279. }
  38280. } catch (error) {
  38281. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content, getDecorators(options.editorId), options, 'create');
  38282. }
  38283. } else if (typeof content === 'number') {
  38284. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content.toLocaleString().replace(/,/g, ''), getDecorators(options.editorId), options, 'create');
  38285. } else {
  38286. editorState = external_draft_js_["EditorState"].createEmpty(getDecorators(options.editorId));
  38287. }
  38288. options.styleExportFn = compositeStyleExportFn(options.styleExportFn, options.editorId);
  38289. options.entityExportFn = compositeEntityExportFn(options.entityExportFn, options.editorId);
  38290. options.blockExportFn = compositeBlockExportFn(options.blockExportFn, options.editorId);
  38291. editorState.setConvertOptions(options);
  38292. return editorState;
  38293. };
  38294. /* harmony default export */ var index_0 = __webpack_exports__["default"] = (createExtensibleEditor(editor_BraftEditor));
  38295. // 2.1版本开发计划
  38296. // [ ]优化选中多行文字是插入链接报错的问题
  38297. // [ ]新增编辑器内图片删除hook
  38298. // 2.2版本开发计划
  38299. // [ ]表格功能
  38300. // [ ]美化UI,包括图标和界面风格
  38301. // 2.3版本开发计划
  38302. // [ ]初级md快捷输入支持
  38303. // [ ]图片裁切等简单的编辑功能
  38304. // [ ]允许自定义快捷键
  38305. /***/ }),
  38306. /* 40 */
  38307. /***/ (function(module, exports) {
  38308. // removed by extract-text-webpack-plugin
  38309. /***/ }),
  38310. /* 41 */,
  38311. /* 42 */
  38312. /***/ (function(module, exports) {
  38313. // removed by extract-text-webpack-plugin
  38314. /***/ }),
  38315. /* 43 */,
  38316. /* 44 */,
  38317. /* 45 */
  38318. /***/ (function(module, exports) {
  38319. // removed by extract-text-webpack-plugin
  38320. /***/ }),
  38321. /* 46 */
  38322. /***/ (function(module, exports) {
  38323. // removed by extract-text-webpack-plugin
  38324. /***/ }),
  38325. /* 47 */
  38326. /***/ (function(module, exports) {
  38327. // removed by extract-text-webpack-plugin
  38328. /***/ }),
  38329. /* 48 */
  38330. /***/ (function(module, exports) {
  38331. // removed by extract-text-webpack-plugin
  38332. /***/ }),
  38333. /* 49 */
  38334. /***/ (function(module, exports) {
  38335. // removed by extract-text-webpack-plugin
  38336. /***/ }),
  38337. /* 50 */
  38338. /***/ (function(module, exports) {
  38339. // removed by extract-text-webpack-plugin
  38340. /***/ }),
  38341. /* 51 */
  38342. /***/ (function(module, exports) {
  38343. // removed by extract-text-webpack-plugin
  38344. /***/ }),
  38345. /* 52 */
  38346. /***/ (function(module, exports) {
  38347. // removed by extract-text-webpack-plugin
  38348. /***/ }),
  38349. /* 53 */
  38350. /***/ (function(module, exports) {
  38351. // removed by extract-text-webpack-plugin
  38352. /***/ }),
  38353. /* 54 */
  38354. /***/ (function(module, exports) {
  38355. // removed by extract-text-webpack-plugin
  38356. /***/ }),
  38357. /* 55 */
  38358. /***/ (function(module, exports) {
  38359. // removed by extract-text-webpack-plugin
  38360. /***/ }),
  38361. /* 56 */
  38362. /***/ (function(module, exports) {
  38363. // removed by extract-text-webpack-plugin
  38364. /***/ }),
  38365. /* 57 */
  38366. /***/ (function(module, exports) {
  38367. // removed by extract-text-webpack-plugin
  38368. /***/ }),
  38369. /* 58 */
  38370. /***/ (function(module, exports) {
  38371. // removed by extract-text-webpack-plugin
  38372. /***/ }),
  38373. /* 59 */
  38374. /***/ (function(module, exports) {
  38375. // removed by extract-text-webpack-plugin
  38376. /***/ }),
  38377. /* 60 */
  38378. /***/ (function(module, exports) {
  38379. // removed by extract-text-webpack-plugin
  38380. /***/ }),
  38381. /* 61 */
  38382. /***/ (function(module, exports) {
  38383. // removed by extract-text-webpack-plugin
  38384. /***/ }),
  38385. /* 62 */
  38386. /***/ (function(module, exports) {
  38387. // removed by extract-text-webpack-plugin
  38388. /***/ }),
  38389. /* 63 */
  38390. /***/ (function(module, exports) {
  38391. // removed by extract-text-webpack-plugin
  38392. /***/ })
  38393. /******/ ]);
  38394. });
  38395. });
  38396. var BraftEditor = index.unwrapExports(dist$3);
  38397. var css = ".index_baseWrapper__1_-58 {\n position: relative;\n}\n.index_baseWrapper__1_-58 .bf-container {\n display: flex;\n flex-direction: column;\n}\n.index_baseWrapper__1_-58 .bf-container .index_controlBar__3SzSH {\n box-shadow: none;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX {\n border: 1px solid #ccc;\n border-radius: 4px;\n height: auto;\n transition: border-color 0.3s;\n}\n.index_baseWrapper__1_-58 .bf-container .index_editorContent__2UOaX.index_focus__puDJA {\n border-color: #1790ff;\n}\n.index_baseWrapper__1_-58 .index_floatControls__2hVPf {\n position: absolute;\n right: 15px;\n bottom: 15px;\n display: flex;\n z-index: 2;\n}\n";
  38398. var styles = {
  38399. "baseWrapper": "index_baseWrapper__1_-58",
  38400. "controlBar": "index_controlBar__3SzSH",
  38401. "editorContent": "index_editorContent__2UOaX",
  38402. "focus": "index_focus__puDJA",
  38403. "floatControls": "index_floatControls__2hVPf"
  38404. };
  38405. styleInject_es.styleInject(css);
  38406. var css$1 = ".index_bf-controlbar__ej8fA{margin:0;padding:0 5px;box-shadow:inset 0 -1px 0 0 rgba(0,0,0,.2)}.index_bf-controlbar__ej8fA:after{display:block;content:\"\";clear:both}.index_bf-controlbar__ej8fA button{padding:0;outline:none}.index_bf-controlbar__ej8fA button[disabled]{pointer-events:none;opacity:.3}.index_bf-controlbar__ej8fA [data-title]{position:relative}.index_bf-controlbar__ej8fA [data-title]:after,.index_bf-controlbar__ej8fA [data-title]:before{position:absolute;z-index:10;top:100%;left:50%;pointer-events:none;opacity:0;transform:translateX(-50%) translateY(-5px);transition:opacity .3s,transform .3s}.index_bf-controlbar__ej8fA [data-title]:before{margin-top:3px;border:5px solid transparent;border-bottom-color:#21242a;content:\"\"}.index_bf-controlbar__ej8fA [data-title]:after{margin-top:12px;padding:5px;background-color:#21242a;border-radius:2px;box-shadow:0 5px 15px rgba(0,0,0,.2);color:#fff;font-size:12px;line-height:16px;white-space:nowrap;content:attr(data-title)}.index_bf-controlbar__ej8fA [data-title]:hover:after,.index_bf-controlbar__ej8fA [data-title]:hover:before{opacity:1;transform:translateX(-50%) translateY(0)}.index_bf-controlbar__ej8fA input{outline:none}.index_bf-controlbar__ej8fA .index_separator-line__3SV92{display:block;float:left;height:26px;width:1px;margin:10px;box-shadow:inset -1px 0 0 0 rgba(0,0,0,.1)}.index_bf-controlbar__ej8fA .index_separator-line__3SV92+.index_control-item__2E9Ul,.index_bf-controlbar__ej8fA .index_separator-line__3SV92+.index_control-item-group__2GENZ{margin-left:0}.index_bf-controlbar__ej8fA .index_separator-line__3SV92+.index_separator-line__3SV92,.index_bf-controlbar__ej8fA .index_separator-line__3SV92.index_first-child__2fRfM,.index_bf-controlbar__ej8fA .index_separator-line__3SV92.index_last-child__1d0yb{display:none}.index_bf-controlbar__ej8fA .index_control-item-group__2GENZ{float:left;height:36px;margin:5px 0 5px 3px}.index_bf-controlbar__ej8fA .index_control-item-group__2GENZ:first-child{margin-left:0}.index_bf-controlbar__ej8fA .index_control-item-group__2GENZ>.index_control-item__2E9Ul{margin-top:0;margin-bottom:0}.index_bf-controlbar__ej8fA .index_dropdown-handler__1xChS{border-radius:2px}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul{display:block;float:left;height:36px;margin:5px 0 5px 3px;border-radius:2px;cursor:pointer}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_component-wrapper__OLlmp{cursor:default}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul:first-child{margin-left:0}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw{box-sizing:border-box;min-width:36px;padding:0 8px;background-color:transparent;border:none;color:#6a6f7b;font-size:14px}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw:hover{background-color:rgba(0,0,0,.05)}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw.index_active__3_mlp{color:#3498db}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw i:before{display:block;height:36px;font-size:18px;line-height:36px}.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw .index_bfi-redo__1Q-LG:before,.index_bf-controlbar__ej8fA .index_control-item__2E9Ul.index_button__2IaUw .index_bfi-undo___pDce:before{font-size:14px}.index_bf-controlbar__ej8fA .index_dropdown__1rkgF .index_control-item__2E9Ul{width:100%;float:none;margin:0}.index_DraftEditor-editorContainer__1FR0o,.index_DraftEditor-root__mlfOI,.index_public-DraftEditor-content__T2mZu{height:inherit;text-align:initial}.index_public-DraftEditor-content__T2mZu[contenteditable=true]{-webkit-user-modify:read-write-plaintext-only}.index_DraftEditor-root__mlfOI{position:relative}.index_DraftEditor-editorContainer__1FR0o{background-color:hsla(0,0%,100%,0);border-left:.1px solid transparent;position:relative;z-index:1}.index_public-DraftEditor-block__IOQ0s{position:relative}.index_DraftEditor-alignLeft__gR9_E .index_public-DraftStyleDefault-block__3m05I{text-align:left}.index_DraftEditor-alignLeft__gR9_E .index_public-DraftEditorPlaceholder-root__1T6lJ{left:0;text-align:left}.index_DraftEditor-alignCenter__3Fyko .index_public-DraftStyleDefault-block__3m05I{text-align:center}.index_DraftEditor-alignCenter__3Fyko .index_public-DraftEditorPlaceholder-root__1T6lJ{margin:0 auto;text-align:center;width:100%}.index_DraftEditor-alignRight__3ghf4 .index_public-DraftStyleDefault-block__3m05I{text-align:right}.index_DraftEditor-alignRight__3ghf4 .index_public-DraftEditorPlaceholder-root__1T6lJ{right:0;text-align:right}.index_public-DraftEditorPlaceholder-root__1T6lJ{color:#9197a3;position:absolute;z-index:1}.index_public-DraftEditorPlaceholder-hasFocus__kQoHC{color:#bdc1c9}.index_DraftEditorPlaceholder-hidden__22I_U{display:none}.index_public-DraftStyleDefault-block__3m05I{position:relative;white-space:pre-wrap}.index_public-DraftStyleDefault-ltr__3qMdW{direction:ltr;text-align:left}.index_public-DraftStyleDefault-rtl__2k3sG{direction:rtl;text-align:right}.index_public-DraftStyleDefault-listLTR__Mmamr{direction:ltr}.index_public-DraftStyleDefault-listRTL__2WhLE{direction:rtl}.index_public-DraftStyleDefault-ol__32plX,.index_public-DraftStyleDefault-ul__1_opE{margin:16px 0;padding:0}.index_public-DraftStyleDefault-depth0__2YvNJ.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:1.5em}.index_public-DraftStyleDefault-depth0__2YvNJ.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:1.5em}.index_public-DraftStyleDefault-depth1__3dbfg.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:3em}.index_public-DraftStyleDefault-depth1__3dbfg.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:3em}.index_public-DraftStyleDefault-depth2__2mADP.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:4.5em}.index_public-DraftStyleDefault-depth2__2mADP.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:4.5em}.index_public-DraftStyleDefault-depth3__1V80Q.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:6em}.index_public-DraftStyleDefault-depth3__1V80Q.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:6em}.index_public-DraftStyleDefault-depth4__9Zzf6.index_public-DraftStyleDefault-listLTR__Mmamr{margin-left:7.5em}.index_public-DraftStyleDefault-depth4__9Zzf6.index_public-DraftStyleDefault-listRTL__2WhLE{margin-right:7.5em}.index_public-DraftStyleDefault-unorderedListItem__fNkjl{list-style-type:square;position:relative}.index_public-DraftStyleDefault-unorderedListItem__fNkjl.index_public-DraftStyleDefault-depth0__2YvNJ{list-style-type:disc}.index_public-DraftStyleDefault-unorderedListItem__fNkjl.index_public-DraftStyleDefault-depth1__3dbfg{list-style-type:circle}.index_public-DraftStyleDefault-orderedListItem__3J0MZ{list-style-type:none;position:relative}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-listLTR__Mmamr:before{left:-36px;position:absolute;text-align:right;width:30px}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-listRTL__2WhLE:before{position:absolute;right:-36px;text-align:left;width:30px}.index_public-DraftStyleDefault-orderedListItem__3J0MZ:before{content:counter(a) \". \";counter-increment:a}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth1__3dbfg:before{content:counter(b) \". \";counter-increment:b}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth2__2mADP:before{content:counter(c) \". \";counter-increment:c}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth3__1V80Q:before{content:counter(d) \". \";counter-increment:d}.index_public-DraftStyleDefault-orderedListItem__3J0MZ.index_public-DraftStyleDefault-depth4__9Zzf6:before{content:counter(e) \". \";counter-increment:e}.index_public-DraftStyleDefault-depth0__2YvNJ.index_public-DraftStyleDefault-reset__1awm7{counter-reset:a}.index_public-DraftStyleDefault-depth1__3dbfg.index_public-DraftStyleDefault-reset__1awm7{counter-reset:b}.index_public-DraftStyleDefault-depth2__2mADP.index_public-DraftStyleDefault-reset__1awm7{counter-reset:c}.index_public-DraftStyleDefault-depth3__1V80Q.index_public-DraftStyleDefault-reset__1awm7{counter-reset:d}.index_public-DraftStyleDefault-depth4__9Zzf6.index_public-DraftStyleDefault-reset__1awm7{counter-reset:e}.index_bf-switch__1LPr-{position:relative;width:32px;height:16px;background-color:hsla(0,0%,100%,.15);border-radius:8px;transition:background .3s}.index_bf-switch__1LPr-.index_active__3_mlp{background-color:#3498db}.index_bf-switch__1LPr-.index_active__3_mlp:before{left:16px}.index_bf-switch__1LPr-:before{position:absolute;left:0;display:block;width:16px;height:16px;border-radius:8px;background-color:#eee;content:\"\";transform:scale(1.2);transition:.3s}@font-face{font-family:braft-icons;src:url(data:application/font-woff;base64,d09GRgABAAAAACxUAAsAAAAALAgAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAABPUy8yAAABCAAAAGAAAABgDxIH02NtYXAAAAFoAAAA9AAAAPQXCcwWZ2FzcAAAAlwAAAAIAAAACAAAABBnbHlmAAACZAAAJggAACYI9aImY2hlYWQAAChsAAAANgAAADYTSfwFaGhlYQAAKKQAAAAkAAAAJAfCBAxobXR4AAAoyAAAASwAAAEsIgAgXGxvY2EAACn0AAAAmAAAAJhQxVqgbWF4cAAAKowAAAAgAAAAIABVAH1uYW1lAAAqrAAAAYYAAAGGmUoJ+3Bvc3QAACw0AAAAIAAAACAAAwAAAAMD+QGQAAUAAAKZAswAAACPApkCzAAAAesAMwEJAAAAAAAAAAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAQAAA6rADwP/AAEADwABAAAAAAQAAAAAAAAAAAAAAIAAAAAAAAwAAAAMAAAAcAAEAAwAAABwAAwABAAAAHAAEANgAAAAyACAABAASAAEAIOAp4DTgN+BC4LjiKOI547jjwuQp6SbpMelG6WjpgOms6mjqbOpu6nXqsP/9//8AAAAAACDgJuA04DfgQuC44ijiOeO448LkKekA6SzpRuln6YDprOpo6mvqbupz6rD//f//AAH/4x/eH9Qf0h/IH1Md5B3UHFYcTRvnFxEXDBb4FtgWwRaWFdsV2RXYFdQVmgADAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAH//wAPAAEAAAAAAAAAAAACAAA3OQEAAAAAAQAAAAAAAAAAAAIAADc5AQAAAAABAAAAAAAAAAAAAgAANzkBAAAAAAQAVQCAA6sC1QARACMANQBHAAATITIXFhUUBwYjISInJjU0NzYTITIXFhUUBwYjISInJjU0NzY3ITIXFhUUBwYjISInJjU0NzY3ITIXFhUUBwYjISInJjU0NzaAAwASDA0NDBL9ABIMDQ0MEgMAEgwNDQwS/QASDA0NDBIDABIMDQ0MEv0AEgwNDQwSAwASDA0NDBL9ABIMDQ0MAtUMDRESDQwMDRIRDQz+AAwNERINDAwNEhENDKsNDBIRDQwMDRESDA2rDQwSEgwNDQwSEgwNAAAABABVAIADqwLVABEAIwA1AEcAABMhMhcWFRQHBiMhIicmNTQ3NhMhMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NoADABIMDQ0MEv0AEgwNDQwSAlUSDA0MDRL9qxIMDQ0MEgMAEgwNDQwS/QASDA0NDBICVRIMDQwNEv2rEgwNDQwC1QwNERINDAwNEhENDP4ADA0REg0MDA0SEQ0Mqw0MEhENDAwNERIMDasNDBISDA0NDBISDA0AAAAEAFUAgAOrAtUAEQAkADYASQAAEyEyFxYVFAcGIyEiJyY1NDc2EyEyFxYVFAcGIyEiJyY1NDc2MychMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NjOAAwASDA0NDBL9ABIMDQ0MZwJWEQ0MDA0R/aoRDQwMDRFVAwASDA0NDBL9ABIMDQ0MZwJWEQ0MDA0R/aoRDQwMDREC1QwNERINDAwNEhENDP4ADA0REg0MDA0SEQ0Mqw0MEhENDAwNERIMDasNDBISDA0NDBISDA0AAAAEAFUAgAOrAtUAEQAkADYASQAAEyEyFxYVFAcGIyEiJyY1NDc2EyEyFxYVFAcGIyEiJyY1NDc2MychMhcWFRQHBiMhIicmNTQ3NjchMhcWFRQHBiMhIicmNTQ3NjOAAwASDA0NDBL9ABIMDQ0MvQJVEgwNDQwS/asSDA0MDRKrAwASDA0NDBL9ABIMDQ0MvQJVEgwNDQwS/asSDA0MDRIC1QwNERINDAwNEhENDP4ADA0REg0MDA0SEQ0Mqw0MEhENDAwNERIMDasNDBISDA0NDBISDA0AAAACAQAAgQMAAtUAAwAHAAABMxEjIREzEQJWqqr+qqoC1f2sAlT9rAAAAQFWAIEDKgLVAAIAAAkCAVYB1P4sAtX+1v7WAAEAqgArA1YDgQAuAAABMhceARcWFRQHDgEHBiMiJy4BJyY1MxQXHgEXFjMyNz4BNzY1NCcuAScmIxUnNwIARj8+XRsbGxtdPj5HRj8+XRsbVhQURS8vNTUvL0UUFBQURS8vNdbWAtUbG1w+PkZHPj5dGxsbG10+Pkc2Li9FFBQUFEUvLjY1Ly5GFBSs1tYAAAMAMwCqA80CqwAEAAkADQAAEyEVITUDNSEVITc1IRX/As79MswCzv0yaALKAqtnZ/3/Z2fOZWUABQCAACsDgAMrAAMABwALAA8AEwAAAREhEQERIREDESERAREhEQMhESEDKv8AAQD/AFT/AAEA/wBWAwD9AAHVAQD/AP6sAQD/AAFUAQD/AP6sAQD/AAKq/QAAAAACAFYAKwNWAtUACAARAAABIRUjByc3IycnFwEHJwcjNwEBAAJW+ERaHmZ4dAwCaDbyQoBo/tgC1YCgWEh4CAr9ljbynPYBKAACAIAAKwN0Ax8AAwAWAAAlAScBAR4BDwEXBycBIzUBJzcXNzYyFwEoAVhS/qgCngwBDYZSPDz+gsoBfDw8UoYMJAyBAVhS/qgB6AwjDYZSPDz+hMoBfjw8UoYMDAAAAAAEAIAAKwOAAysACAARABoAIwAAATIWHQEjNSM1EzUzFRQGKwE1JRUzFSMiJj0BETQ2OwEVIxUjAyoiNFaqqlYzI6r+VqqqIjQzI6qqVgMrNCKqqlb9VqqqIzNWqqpWMyOqAaoiNFaqAAYAgAArA4ADKwAHAAsAEwAbAB8AIwAAAREzFTMVIxUXITUhJTMRIzUjNTMBIxEzFSEVIQEhFSERIRUhAoBWqqqq/lYBqv2qVlaqqgEAVFQBVv6q/lYBqv5WAQD/AAIrAQBWVFaqVFb/AFZU/lYBAFZUAlRU/lRUAAIAgABNA4ADTQATAB0AACUhESE1ISIGFREUFjMhMjY1ESMRAxUzARcBFTMRIQMr/aoBK/7VIzIyIwJWIzJV1pr+XDwBpFX+1aICVVYyJP2rIzIyIwEr/tUCq1b+XTwBo5kBKwAEAFUAIgOrA3cABAAhAD0AQgAAJTMRIxETIgcOAQcGFRQXHgEXFjMyNz4BNzY1NCcuAScmIxEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYDMzUjFQHVVlYrWE5OdCEiIiF0Tk5YWE5OdCEiIiF0Tk5YRz4+XRobGxpdPj5HRz4+XRobGxpdPj5yVlb3AQD/AAKAISJzTk5YWU1OdCEiIiF0Tk1ZWE5OcyIh/QAbG10+PkdGPz5cGxsbG1w+P0ZHPj5dGxsB1lVVAAAEAFUAIgOrA3cABAAhAD0AUgAAJTM1IxUTIgcOAQcGFRQXHgEXFjMyNz4BNzY1NCcuAScmIxEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYDIgYVMzQ2MzIWFRQGFTM0NjU0JiMB1VZWK1hOTnQhIiIhdE5OWFhOTnQhIiIhdE5OWEc+Pl0aGxsaXT4+R0c+Pl0aGxsaXT4+R0dkVjIjIzKAVoBkR81VVQKqISJzTk5YWU1OdCEiIiF0Tk1ZWE5OcyIh/QAbG10+PkdGPz5cGxsbG1w+P0ZHPj5dGxsCVmRHIzIyI0AtaEg9UEdkAAACAFUAzQOrAs0ABQALAAABJzcnCQElNyc3CQEBkcTEPP8AAQABGsTEPAEA/wABCcTEPP8A/wA8xMQ8/wD/AAAAAwErAM0C9QMiAA8AGQAiAAABPgE1NCYjIREhMjY1NCYnJzMyFhUUBisBNRMjNTMyFhUUBgKaHydjSP72ASxDWzIp74AaJiYagJWVlRslJQIAFkEgSWL9q19DME4TtyUbGiaA/oCAJRsaJgAAAQCAACYDgAN3ADQAAAEiBgclPgE1NCYnJR4BMzI2NTQmIyIGFRQWFwUuASMiBhUUFjMyNjcFDgEVFBYzMjY1NCYjAwAYKxH+0AICAgIBLREtGTVLSzU1SwIC/tMRLRk1S0s1GS0RATACAkk0NElJNAEfEg+xBw8IBw8IrxATSzU2Sko2Bw8HsBATSzU1SxIQsQcOBzNJSTM0SQAAAQErAU0C1QIiAAIAAAEXNwEr1dUCItXVAAAAAAMAVQAiA6sDdwAcACsAOgAAASIHDgEHBhUUFx4BFxYzMjc+ATc2NTQnLgEnJiMBNDc+ATc2MzIWFwEuATUBIiYnAR4BFRQHDgEHBiMCAFhOTXQiIiIidE1OWFhOTXQiIiIidE1OWP6rGxtcPj9GOmot/iIjJQFVOmotAd4jJRsbXD4/RgN3ISJ0Tk1YWE5OdCEiIiF0Tk5YWE1OdCIh/lZGPj5dGxslI/4iLWo6/qomIwHeLWs5Rz4+XRsbAAAAAAMAgADNA4ACzQADAAcACwAANyE1ITUhNSE1FSE1gAMA/QADAP0AAwDNVYBV1lZWAAEBKwF3AtUCTQACAAABNxcBK9XVAXfW1gAAAAADAasAdwJVAyIADAAYACQAAAEyNjU0JiMiBhUUFjMVIgYVFBYzMjY1NCYDIgYVFBYzMjY1NCYCACMyMiMjMjIjIzIyIyMyMiMjMjIjIzIyAnczIyMyMiMjM1UyIyMzMyMjMv8AMiMjMzMjIzIAAAAAAwCrAXcDVQIiAAwAGAAkAAABIgYVFBYzMjY1NCYjISIGFRQWMzI2NTQmISIGFRQWMzI2NTQmAQAjMjIjIzIyIwIAIzIyIyMyMv7dIzIyIyMyMgIiMiMjMzMjIzIyIyMzMyMjMjIjIzMzIyMyAAAAAAIAAP/ABAADgAApAC0AAAERIzU0JiMhIgYdARQWMyEyNj0BMxEhFSMiBhURFBY7ATI2NRE0JisBNQEhNSEEAMAmGv1AGiYmGgLAGiaA/cAgDRMTDYANExMNIAFA/UACwAGAAYBAGiYmGsAaJiYaQP8AgBMN/sANExMNAUANE0ABgEAAAAQA1QCiAysC9wAGAA0AEwAaAAATMxUzNSMVEyMVMzUjFQEzNTM1IxM1IxUzNSPVgFbWgIDWVgEAVoDWVlbWgAEigNVVAVVV1YD+K4BVAQCA1VUAAAEAZAAlA1wDXABEAAABERQHBgcGBwYjIicmJyYnJjU0NzY3Njc2MzIXEQURFAcGBwYHBiMiJyYnJicmNTQ3Njc2NzYzMhcRNDc2NyU2MzIXFhUDXBERGhkaGRYXGRoZGhEREREaGRoZFzMr/oURERoZGhkXFhkaGRoRERERGhkaGRY0KwoJDwGbBggUDg4DLP3WGBQTCgsFBQUFCwoTFBgZExQKCwUFEwEKdv6iGRMTCwsFBQUFCwsTExkZExMLCgYFEwHeDw0MBX8CDg4UAAAEAHUAQgOJA1YALwA8AGIAeAAAAS4BBw4BJy4BJy4BBwYiJyYGBw4BJyYGBxQVHAEVFBUeATM2MzoBMzIzMjY3PAE1BSImNTQ2MzIWFRQGJyUqASM8ATU6ATMUFhUUFxwBFQYHFAYHDgEnLgE3PgE3OgEzPAE1BT4BNzoBMxQWBw4BJy4BNz4BNzoBMwKBARkZChUJCxcEFEMvBw8HHikMDCgdFyILCxgWNDM0ZzQzNBsaAf77L0FBMDBAQDEBtx8/IDRoNgEBAQENCxVFICIlBgc3JAcNCf7OAQICEyQTAwUFSiMmOAIBOiYHEAkCzhcaAQEBAwIJCC0fCAEBBhgbGxYGBBMVKCgpUCgoKQ8VARcaSpRK7T8uMEA/LzBAARchPyAKEgkzMjNmMjMzFCwRIBAOD0IjJjQDN2053QwUCi5dLSUsBgVEJig+BAAAAAAEANUAogMrAvcABQALABEAFwAAASMVMzUjAzM1MzUjASMVMzUjAxUzFTM1AStW1oBWVoDWAgCA1laAgFYBd9VVASuAVf4AVdUBgFWA1QAAAAQAAAAABAADQAAbADMATwBTAAABFBceARcWMzI3PgE3NjU0Jy4BJyYjIgcOAQcGASMuASMhIgYHIyIGFREUFjMhMjY1ETQmASInLgEnJjU0Nz4BNzYzMhceARcWFRQHDgEHBgEjNTMBMBAROCYmKysmJjgREBAROCYmKysmJjgREAKQ4AwkMP8AMCQM4BomJhoDgBomJv4mOzQzTRcWFhdNMzQ7OzQzTRcWFhdNMzQBhYCAAWArJiY4ERAQETgmJisrJiY4ERAQETgmJgE1MFBQMCYa/cAaJiYaAkAaJv2EFhdNMzQ7OzQzTRcWFhdNMzQ7OzQzTRcWAbxAAAEAkQCiA4AC3gAGAAABJwcXAScBAYCzPO8CADz+PAEaszzvAgA8/jwAAAAAAQDiAIADHgLJACYAAAE3NjQnJiIPAScmIgcGFB8BBwYUFx4BMzI2PwEXHgEzMjY3NjQvAQI84g0NDCQM4uIMJAwNDeLiDQ0GEAgIEAbi4gYQCAgQBg0N4gGr4gwjDQwM4uIMDA0jDOLiDSMMBwYGB+HhBwYGBwwjDeIAAAUAVQCVA6sC6wAZACoARABeAHgAAAEhIgYHDgEVFBYXHgEzITI2Nz4BNTQmJy4BJTQmIyEiBh0BFBYzITI2PQEDISIGBw4BFRQWFx4BMyEyNjc+ATU0JicuAQMhIgYHDgEVFBYXHgEzITI2Nz4BNTQmJy4BBSEiBgcOARUUFhceATMhMjY3PgE1NCYnLgEB1f6rCQ8GBgcHBgYPCQFVCQ8GBwYGBwYPAc0ZEv8AEhkZEgEAEhkr/QAJDwYGBwcGBg8JAwAJDwYGBwcGBg8J/QAJDwYGBwcGBg8JAwAJDwYGBwcGBg/+TP6rCQ8GBgcHBgYPCQFVCQ8GBwYGBwYPAZUGBgYQCAkPBgcGBgcGDwkIEAYGBoERGRkRrBEZGRGs/tUHBgYPCQkPBgYHBwYGDwkJDwYGBwIABwYGDwkJDwYGBwcGBg8JCQ8GBgerBgcGDwkIEAYGBgYGBhAICQ8GBwYAAAAABABVAE0DqwNNAA4AEgAeACIAAAEhIgYVETMVITUzETQmIwMhNSE3IiY1NDYzMhYVFAYDIRUhAyv9qjVLqwIAq0s1gP6qAVaAEhkZEhEZGTz+AAIAAndKNv8AqqoBADZK/ivVVhkREhkZEhEZAYCrAAIAgABjA2oDTQAiAC8AAAEjJz4BNTQnLgEnJiMiBw4BBwYVFBceARcWMzI2NxcVFzcnISImNTQ2MzIWFRQGIwKVIQwfJBYWSzMyOjkzMksWFhYWSzIzOTRcJQvWP9X/AE9xcU9QcHBQAXcMJF0zOjIzSxYWFhZLMzI6OTIzSxYWJB8MItQ/1XFPUHBwUE9xAAIAZAAiA5wDdwBNAFkAAAE+ATU0Jic3PgEvAS4BDwEuAS8BLgErASIGDwEOAQcnJgYPAQYWHwEOARUUFhcHDgEfAR4BPwEeAR8BHgE7ATI2PwE+ATcXFjY/ATYmJwUiJjU0NjMyFhUUBgM9AQICAVoGAwRVBA8HahEkFBABDAiqCAwBEBQkEWoHDwRVBAMGWgECAgFaBgMEVQQPB2oRJBQQAQwIqggMARAUJBFqBw8EVQQDBv5pPldXPj5XVwGjChULCxQLRgUPB5QHBQMqDBUIcgcKCgdyCBUMKgMFB5QHDwVGCxUKCxUKRgUQB5MHBQIrDRUIcQgKCghxCBUNKwMGB5MHEAUmWD4+V1c+PlgAAQDVAKIDKwL3AAsAAAEhESMRITUhETMRIQMr/wBW/wABAFYBAAGi/wABAFUBAP8AAAAAAAQAVf/vA6sC7wAeADMAOAA9AAATNwEHJyM1JyM1Jw4BFRQWOwEVIyInLgEnJjU0NjcnBTIXHgEXFhUUBgcnPgE1NCYrATUzITMVIycFFSMnM1U3Ask2q0mMSmogJWdIgIA1Li9FFRQyKlwCVjUuL0UVFEc5PC88Z0iAgP6qgDZRAV0zVYgCuTb9NzerSYxKaxhIKklmURQURS8vNTpnIlwfFRRFLy41R3YhPRRWN0hnUVFR1lVVAAADAFUAmgOrApoAGgA1ADkAAAEjFTMyFhUUBisBFTMyNz4BNzY1NCcuAScmIwE0NjsBNSMiBw4BBwYVFBceARcWOwE1IyImNRchNSECq4CASGdnSICANS4vRRUUFBVFLy41/ftnSICANS4vRRUUFBVFLy41gIBIZ68BVv6qAppRZ0hJZlEUFEUvLzU1Li9FFRT/AEhnURUURS8uNTUvL0UUFFFmSStVAAAFAFUAIgOrA3cAHAA4AEQAUABYAAABIgcOAQcGFRQXHgEXFjMyNz4BNzY1NCcuAScmIxEiJy4BJyY1NDc+ATc2MzIXHgEXFhUUBw4BBwYTMjY1NCYjIgYVFBYhMjY1NCYjIgYVFBYTMjY3IR4BMwIAWU1OdCEiIiF0Tk1ZWE5OdCEiIiF0Tk5YRz4+XRsaGhtdPj5HRz4+XRsaGhtdPj5OGyUlGxomJv7wGiYmGhslJbBLdRr+TBp1SwN3ISJzTk5YWU1OdCEiIiF0Tk1ZWE5OcyIh/QAbG10+PkdHPj5dGhsbGl0+PkdHPj5dGxsBgCYaGyUlGxomJhobJSUbGib+61RBQVQAAAAJAAAAQAQAA0AAAwAHAAsADwATABcAGwAfACIAABMRIREBIzUzNSM1MzUjNTMBIREhEyM1MzUjNTM1IzUzBRElAAQA/MCAgICAgIACQP4AAgDAgICAgICA/cABAANA/QADAP1AgICAgID9gAKA/YCAgICAgID+gMAAAAAAAgDVAE0DKwNNABkAHgAAJTI3PgE3NjURIxEUBiMiJjURIxEUFx4BFxYHFSE1IQIANS8uRhQUa1c+PldrFBRGLi/2Alb9qvcVFEUvLzQBVv6qPVhYPQFW/qo0Ly9FFBVVVVUAAAUAVQCVA6sC6wAaACsARQBfAHoAAAEhMhYXHgEVFAYHDgEjISImJy4BNTQ2Nz4BMyU0NjMhMhYdARQGIyEiJj0BEyEyFhceARUUBgcOASMhIiYnLgE1NDY3PgETITIWFx4BFRQGBw4BIyEiJicuATU0Njc+AQUhMhYXHgEVFAYHDgEjISImJy4BNTQ2Nz4BMwIrAVUJDwYGBwcGBg8J/qsJDwYHBgYHBg8J/ioZEgEAEhkZEv8AEhkrAwAJDwYGBwcGBg8J/QAJDwYGBwcGBg8JAwAJDwYGBwcGBg8J/QAJDwYGBwcGBg8BtAFVCQ8GBgcHBgYPCf6rCQ8GBwYGBwYPCQGVBgYGEAgJDwYHBgYHBg8JCBAGBgaBERkZEawRGRkRrP7VBwYGDwkJDwYGBwcGBg8JCQ8GBgcCAAcGBg8JCQ8GBgcHBgYPCQkPBgYHqwYHBg8JCBAGBgYGBgYQCAkPBgcGAAAAAAMAgACiA4ADIgAEAA0AEQAAJTM1IxUDFTMVMzUzNSEDITUhAauqqtbWqtb9qlUDAP0AooCAAoCAgICA/lVWAAACAIAAogOrAyIACAARAAABFTMRMxEzNSEBMxEzETM1IRUBgNWA1v3V/wCAgID+gAMigP4AAgCA/qv+1QErgIAAAgDVAPcDKwKiAAYADQAAJTM3ESERMwUzNxEhETMBAIBV/wCAAQCAVv8AgPerAQD/AKurAQD/AAAGAFUAdwOAAyIACwASAB0AIgAnACwAADczFSMVMxUjFTM1IxMzNSMVMxUHMwcVMzUjNzUjFRMVITUhESE1IRURITUhFVVWKytWgIArK1YrK01NgExMgNYCVf2rAlX9qwJV/av3FSsVK6sBVasrgIBZJytaJisBAFVV/atVVQEAVVUAAAAGAGsAjQOAAw0ACwAXACMAKAAtADIAABMiBhUUFjMyNjU0JgMiBhUUFjMyNjU0JgMiBhUUFjMyNjU0JhchNSEVESE1IRURFSE1IasbJSUbGiYmGhslJRsaJiYaGyUlGxomJmYCVf2rAlX9qwJV/asCDSYaGyUlGxomAQAmGhslJRsaJv4AJhoaJiYaGiZrVVUBAFVVAVVVVQAAAAABAQAAzQMAAyIACwAAARUzAyMVITUjEzM1AatekncBVV6SdwMigP6rgIABVYAAAAABAAABawQAAesAAwAAEyEVIQAEAPwAAeuAAAAABgBA/8ADwAPAABkAIQA5AEcAVQBjAAABLgEnLgEnLgEjISIGFREUFjMhMjY1ETQmJyceARcjNR4BExQGIyEiJjURNDYzMDM6ATMyMRUUFjsBAyEiJjU0NjMhMhYVFAYnISImNTQ2MyEyFhUUBichIiY1NDYzITIWFRQGA5YRLRkaMxcnKQv+ECEvLyEC4CEvDhyFFyUNmhEphgkH/SAHCQkHTU66TU4TDeCg/kANExMNAcANExMN/kANExMNAcANExMN/kANExMNAcANExMC2xczGhktERwOLyH8oCEvLyECcAspJzYXKRGaDSX86AcJCQcDYAcJ4A0T/gATDQ0TEw0NE4ATDQ0TEw0NE4ATDQ0TEw0NEwAAAAUAAP/ABAADwAAIAAsAEwAWABwAAAERIQcRIREhESUVIwMRMzUhFQcRExUjASERMzUhAoD+QMABgAKA/MBlG8ABQMDAZQHl/gDAAUACwAEAwP3A/wADAKVl/gABwMDAwP8AAWVl/gABwMAAAAUAQP/ABAADwAANABgANAA3AD0AAAEjNTQmKwEiBh0BIxUhJyM1OAExMzgBMRUFNTQmKwEVMxUjBxEhETM1IyIGFREUFjMhFSERBRUjASERMzUhAsCAJhqAGiaAAgDAgIABQBMNQCDAwP8AIEANExMNASACgP5AZQHl/gDAAUADQEAaJiYaQICAQEDAoA0TQIDA/wACQEATDf2ADRPAAsBbZf5AAYDAAAYAgABNA4ADTQADAAcACwAPABMAFwAANyE1IRkBNycBITUhARUhNQEhNSERITUhgAMA/QCrqwFVAav+Vf6rAwD+VQGr/lUBq/5VTVUB1f6rq6r+gFYCAFZW/wBV/wBVAAYAgABNA4ADTQADAAcACwAPABMAFwAAJSE1ISUXEQcRITUhERUhNQEhNSERITUhAdUBq/5V/qurqwMA/QADAP5VAav+VQGr/lX3VoCrAVWq/oBVAqtWVv8AVf8AVQAAAAEAAP/NBAAAdwADAAA3IRUhAAQA/AB3qgAAAAACAOsA9wMVA00ACAAMAAABAzM3IRczAyMDGwEjAdXqYC8BCzBg6lY7ZmbMA039qoCAAlb+gAEO/vIAAAACAAD/wAQAA8AADgASAAABBxcDIxcBFTMBFzUlFzcFJzcXAiBgYODgsP7wJwFpsAEAYGD9wEDgQAPAYGD/ALD+lycBELDg4GBgQEDgQAAAAAEAQP/AA4oDwAARAAAFNjc2JicmBxUJARU2Fx4BBwYC+isTEzhVVqj+gAGAyXFyRignQE1bW5ozMgT+AYABgPgFTk7siokAAAEAdv/AA8ADwAASAAABNQkBNSYHDgEXFhcmJyY2NzYXAkABgP6AqFZVOBMTK2knKEZycckCyPj+gP6A/gQyM5pbW01yiYrsTk4FAAAHAAD/wAQAA0YACwAXACMALwA7AEcAUwAAJTQ2MzIWFRQGIyImATQ2MzIWFRQGIyImJTQ2MzIWFRQGIyImATQ2MzIWFRQGIyImATQ2MzIWFRQGIyImJTQ2MzIWFRQGIyImATQ2MzIWFRQGIyImAaA4KCg4OCgoOP5gOCgoODgoKDgDQDgoKDg4KCg4/To4KCg4OCgoOAJMOCgoODgoKDj9tDgoKDg4KCg4Akw4KCg4OCgoOCAoODgoKDg4AcgoODgoKDg4KCg4OCgoODgBTig4OCgoODj93Cg4OCgoODgoKDg4KCg4OAJ0KDg4KCg4OAAFAHwAAAOEA1UAIgAtADgARgBUAAABIzU0JisBIgYdASMiBhUUFjsBERQWMyEyNjURMzI2NTQmIyU0NjsBMhYdASM1ARQGIyEiJjURIREBIgYdARQWMzI2PQE0JjMiBh0BFBYzMjY9ATQmA12bRDCcMESbEBcXECdEMAGEMEQnEBcXEP4vFhCcEBboAV0XEP58EBcB0v7JEBYWEBAXF4wQFxcQEBYWAronMEREMCcXEBAW/gcwREQwAfkWEBAXJxAXFxAnJ/2TEBYWEAH5/gcBhBcQ6BAXFxDoEBcXEOgQFxcQ6BAXAAAABwAA/8AEAAPAAAMABwALAA8AEwAbACMAABMzFSM3MxUjJTMVIzczFSMlMxUjAxMhEzMTIRMBAyEDIwMhAwCAgMDAwAEAgIDAwMABAICAEBD9ABAgEAKAEP1AEAMAECAQ/YAQAcBAQEBAQEBAQEACQP5AAcD+gAGA/AABgP6AAUD+wAAABABQAIAEAAPAAAgADQAQAEAAAD8BIRczAyMDMxMzFyM3ARsBAyMiJjU0NjsBMjY1NCYrASIGFRQWFx4BOwEyFhUUBisBIgYVFBY7ATI2NTQmJy4BwjoBCDpywODAcppIOrw6AWSgoKBADRMTDYANExMNgCg4DQwNJRVADRMTDYANExMNgCg4DQwNJYDAwAKA/YACAMDA/gABAP8AAsATDQ0TEw0NEzgoEiENDxETDQ0TEw0NEzgoEiENDxEAAAAABABQ/8AEAAMAAAgADQAQAEAAAD8BIRczAyMDMxMzFyM3JQsBEyMiJjU0NjsBMjY1NCYrASIGFRQWFx4BOwEyFhUUBisBIgYVFBY7ATI2NTQmJy4BwjoBCDpywODAcppIOrw6AqSgoKBADRMTDYANExMNgCg4DQwNJRVADRMTDYANExMNgCg4DQwNJYDAwAKA/YACAMDAgP8AAQD9gBMNDRMTDQ0TOCgSIQ0PERMNDRMTDQ0TOCgSIQ0PEQAHAAD/wAQAA8AABwAPABMAFwAbAB8AIgAAAREhESMRIREFESERMxEhESUzFSMnMxUjJTMVIzczFSMlFwcBAAMAQP2AAsD9AEACgP5AgIDAgIABgICAwICA/IDAwAJAAYD+gAFA/sDA/kABwP6AAYCAQEBAQEBAQODAwAAAAQCA/8ADgAPAABcAAAEhFSMRIxEjESMRIicuAScmNTQ3PgE3NgGAAgCAgICANS8uRhQUFBRGLi8DwID8gAOA/IACABQURi4vNTUvLkYUFAACAAD/wAQAA8AAFwAaAAABIgcOAQcGFRQXHgEXFjMRMxEzETMRMzUJAgIANS8uRhQUFBRGLi81gICAgPwAAQD/AAPAFBRGLi81NS8uRhQU/gADgPyAA4CA/UABAAEAAAACAAD/wAQAA8AAFwAaAAABIgcOAQcGFRQXHgEXFjMRMxEzETMRMzUFCQEBADUvLkYUFBQURi4vNYCAgIABAP8AAQADwBQURi4vNTUvLkYUFP4AA4D8gAOAgMD/AP8AAAABAAD/zgQAA7MAYwAAASIHDgEHBhUUFx4BFxYXFjY1PAEnBiYxLgExJjYxHgExFjY3PgE3JicuAScmNTQ2Ny4BNzAWFz4BMzIWFz4BMRYGBx4BFRQHDgEHBgceARUUBhUUFjc2Nz4BNzY1NCcuAScmIwIAal1eiygoGhpdQUBMExABakISJyMnJigiXRYEEgsrKipCFBUcGQQMFUNKHkEhIUEeSkMVDAQZHBUUQyopKw4VARATTEFAXRoaKCiLXl1qA7MoKItdXmpUTU2ALy8ZBBIKCTYgF1QsHxgHAzI7BwoYIgoFDA04Ly9JKkUbCUk1AzEICQkIMQM1SQkbRSpKLy44DA0FCzAjNEwNChIEGS8wf01NVGpeXYsoKAAAAAABAAAAAQAAt9HlfV8PPPUACwQAAAAAANgVW8QAAAAA2BVbxAAA/8AEAAPAAAAACAACAAAAAAAAAAEAAAPA/8AAAAQAAAAAAAQAAAEAAAAAAAAAAAAAAAAAAABLBAAAAAAAAAAAAAAAAgAAAAQAAFUEAABVBAAAVQQAAFUEAAEABAABVgQAAKoEAAAzBAAAgAQAAFYEAACABAAAgAQAAIAEAACABAAAVQQAAFUEAABVBAABKwQAAIAEAAErBAAAVQQAAIAEAAErBAABqwQAAKsEAAAABAAA1QQAAGQEAAB1BAAA1QQAAAAEAACRBAAA4gQAAFUEAABVBAAAgAQAAGQEAADVBAAAVQQAAFUEAABVBAAAAAQAANUEAABVBAAAgAQAAIAEAADVBAAAVQQAAGsEAAEABAAAAAQAAEAEAAAABAAAQAQAAIAEAACABAAAAAQAAOsEAAAABAAAQAQAAHYEAAAABAAAfAQAAAAEAABQBAAAUAQAAAAEAACABAAAAAQAAAAEAAAAAAAAAAAKABQAHgCIAPIBXgHKAd4B7AI0AlACfgKiAtIDBgNCA3QD2gRSBHIEqAT2BQQFZAV8BYoFwgX6BjwGZgbOB3YHnggcCDIIcAkiCVoJogoqCkQKoAr0C3gLtgvoDJwMvAzcDPgNOg2IDaANrg46DnAOxA70DyQPMg9QD3gPnA/CEDoQrhDwEVARrhHsEhQSRBJ0EwQAAQAAAEsAewAJAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAA4ArgABAAAAAAABAAcAAAABAAAAAAACAAcAYAABAAAAAAADAAcANgABAAAAAAAEAAcAdQABAAAAAAAFAAsAFQABAAAAAAAGAAcASwABAAAAAAAKABoAigADAAEECQABAA4ABwADAAEECQACAA4AZwADAAEECQADAA4APQADAAEECQAEAA4AfAADAAEECQAFABYAIAADAAEECQAGAA4AUgADAAEECQAKADQApGljb21vb24AaQBjAG8AbQBvAG8AblZlcnNpb24gMS4wAFYAZQByAHMAaQBvAG4AIAAxAC4AMGljb21vb24AaQBjAG8AbQBvAG8Abmljb21vb24AaQBjAG8AbQBvAG8AblJlZ3VsYXIAUgBlAGcAdQBsAGEAcmljb21vb24AaQBjAG8AbQBvAG8AbkZvbnQgZ2VuZXJhdGVkIGJ5IEljb01vb24uAEYAbwBuAHQAIABnAGUAbgBlAHIAYQB0AGUAZAAgAGIAeQAgAEkAYwBvAE0AbwBvAG4ALgAAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=);font-weight:400;font-style:normal}.index_bf-container__1HxhF [class*=\" bfi-\"],.index_bf-container__1HxhF [class^=bfi-],.index_bf-modal-root__1P_VQ [class*=\" bfi-\"],.index_bf-modal-root__1P_VQ [class^=bfi-]{font-family:braft-icons!important;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.index_bf-container__1HxhF .index_bfi-table__2fSIV:before,.index_bf-modal-root__1P_VQ .index_bfi-table__2fSIV:before{content:\"\\E228\"}.index_bf-container__1HxhF .index_bfi-clear_all__2OHjw:before,.index_bf-modal-root__1P_VQ .index_bfi-clear_all__2OHjw:before{content:\"\\E0B8\"}.index_bf-container__1HxhF .index_bfi-format_clear__2Z6-D:before,.index_bf-modal-root__1P_VQ .index_bfi-format_clear__2Z6-D:before{content:\"\\E239\"}.index_bf-container__1HxhF .index_bfi-hr__1-frF:before,.index_bf-modal-root__1P_VQ .index_bfi-hr__1-frF:before{content:\"\\E925\"}.index_bf-container__1HxhF .index_bfi-colorize__itEld:before,.index_bf-modal-root__1P_VQ .index_bfi-colorize__itEld:before{content:\"\\E3B8\"}.index_bf-container__1HxhF .index_bfi-crop_free__1UXYS:before,.index_bf-modal-root__1P_VQ .index_bfi-crop_free__1UXYS:before{content:\"\\E3C2\"}.index_bf-container__1HxhF .index_bfi-pause__1OwwZ:before,.index_bf-modal-root__1P_VQ .index_bfi-pause__1OwwZ:before{content:\"\\E034\"}.index_bf-container__1HxhF .index_bfi-play_arrow__1hL7J:before,.index_bf-modal-root__1P_VQ .index_bfi-play_arrow__1hL7J:before{content:\"\\E037\"}.index_bf-container__1HxhF .index_bfi-bin__h1RKN:before,.index_bf-modal-root__1P_VQ .index_bfi-bin__h1RKN:before{content:\"\\E9AC\"}.index_bf-container__1HxhF .index_bfi-replay__11NQk:before,.index_bf-modal-root__1P_VQ .index_bfi-replay__11NQk:before{content:\"\\E042\"}.index_bf-container__1HxhF .index_bfi-tune__axH8Q:before,.index_bf-modal-root__1P_VQ .index_bfi-tune__axH8Q:before{content:\"\\E429\"}.index_bf-container__1HxhF .index_bfi-close__3PhYm:before,.index_bf-modal-root__1P_VQ .index_bfi-close__3PhYm:before{content:\"\\E913\"}.index_bf-container__1HxhF .index_bfi-align-center__3WjMb:before,.index_bf-modal-root__1P_VQ .index_bfi-align-center__3WjMb:before{content:\"\\E028\"}.index_bf-container__1HxhF .index_bfi-align-justify__1QkRU:before,.index_bf-modal-root__1P_VQ .index_bfi-align-justify__1QkRU:before{content:\"\\E026\"}.index_bf-container__1HxhF .index_bfi-align-left__1oX7J:before,.index_bf-modal-root__1P_VQ .index_bfi-align-left__1oX7J:before{content:\"\\E027\"}.index_bf-container__1HxhF .index_bfi-align-right__1eM5M:before,.index_bf-modal-root__1P_VQ .index_bfi-align-right__1eM5M:before{content:\"\\E029\"}.index_bf-container__1HxhF .index_bfi-image-right__2H-ST:before,.index_bf-modal-root__1P_VQ .index_bfi-image-right__2H-ST:before{content:\"\\E914\"}.index_bf-container__1HxhF .index_bfi-image-left__zW8ok:before,.index_bf-modal-root__1P_VQ .index_bfi-image-left__zW8ok:before{content:\"\\E91E\"}.index_bf-container__1HxhF .index_bfi-music__1XtpY:before,.index_bf-modal-root__1P_VQ .index_bfi-music__1XtpY:before{content:\"\\E90E\"}.index_bf-container__1HxhF .index_bfi-camera__2X5Zb:before,.index_bf-modal-root__1P_VQ .index_bfi-camera__2X5Zb:before{content:\"\\E911\"}.index_bf-container__1HxhF .index_bfi-copy__16C-6:before,.index_bf-modal-root__1P_VQ .index_bfi-copy__16C-6:before{content:\"\\E92C\"}.index_bf-container__1HxhF .index_bfi-file-text__12Obf:before,.index_bf-modal-root__1P_VQ .index_bfi-file-text__12Obf:before{content:\"\\E926\"}.index_bf-container__1HxhF .index_bfi-film__2C48n:before,.index_bf-modal-root__1P_VQ .index_bfi-film__2C48n:before{content:\"\\E91C\"}.index_bf-container__1HxhF .index_bfi-github__3XePr:before,.index_bf-modal-root__1P_VQ .index_bfi-github__3XePr:before{content:\"\\EAB0\"}.index_bf-container__1HxhF .index_bfi-ltr__rDkrQ:before,.index_bf-modal-root__1P_VQ .index_bfi-ltr__rDkrQ:before{content:\"\\EA74\"}.index_bf-container__1HxhF .index_bfi-page-break__DhcNp:before,.index_bf-modal-root__1P_VQ .index_bfi-page-break__DhcNp:before{content:\"\\EA68\"}.index_bf-container__1HxhF .index_bfi-pagebreak__m3gAm:before,.index_bf-modal-root__1P_VQ .index_bfi-pagebreak__m3gAm:before{content:\"\\EA6E\"}.index_bf-container__1HxhF .index_bfi-paint-format__pjAiv:before,.index_bf-modal-root__1P_VQ .index_bfi-paint-format__pjAiv:before{content:\"\\E90C\"}.index_bf-container__1HxhF .index_bfi-paste__G7Hrh:before,.index_bf-modal-root__1P_VQ .index_bfi-paste__G7Hrh:before{content:\"\\E92D\"}.index_bf-container__1HxhF .index_bfi-pilcrow__4zJYM:before,.index_bf-modal-root__1P_VQ .index_bfi-pilcrow__4zJYM:before{content:\"\\EA73\"}.index_bf-container__1HxhF .index_bfi-pushpin__3PUoC:before,.index_bf-modal-root__1P_VQ .index_bfi-pushpin__3PUoC:before{content:\"\\E946\"}.index_bf-container__1HxhF .index_bfi-redo__1Q-LG:before,.index_bf-modal-root__1P_VQ .index_bfi-redo__1Q-LG:before{content:\"\\E968\"}.index_bf-container__1HxhF .index_bfi-rtl__sPVOR:before,.index_bf-modal-root__1P_VQ .index_bfi-rtl__sPVOR:before{content:\"\\EA75\"}.index_bf-container__1HxhF .index_bfi-spinner__Dek6M:before,.index_bf-modal-root__1P_VQ .index_bfi-spinner__Dek6M:before{content:\"\\E980\"}.index_bf-container__1HxhF .index_bfi-subscript__kYu6m:before,.index_bf-modal-root__1P_VQ .index_bfi-subscript__kYu6m:before{content:\"\\EA6C\"}.index_bf-container__1HxhF .index_bfi-superscript__3qvwy:before,.index_bf-modal-root__1P_VQ .index_bfi-superscript__3qvwy:before{content:\"\\EA6B\"}.index_bf-container__1HxhF .index_bfi-undo___pDce:before,.index_bf-modal-root__1P_VQ .index_bfi-undo___pDce:before{content:\"\\E967\"}.index_bf-container__1HxhF .index_bfi-media__3Ijxb:before,.index_bf-modal-root__1P_VQ .index_bfi-media__3Ijxb:before{content:\"\\E90F\"}.index_bf-container__1HxhF .index_bfi-add__LigZq:before,.index_bf-modal-root__1P_VQ .index_bfi-add__LigZq:before{content:\"\\E918\"}.index_bf-container__1HxhF .index_bfi-bold__dn9AC:before,.index_bf-modal-root__1P_VQ .index_bfi-bold__dn9AC:before{content:\"\\E904\"}.index_bf-container__1HxhF .index_bfi-code__3tDKj:before,.index_bf-modal-root__1P_VQ .index_bfi-code__3tDKj:before{content:\"\\E903\"}.index_bf-container__1HxhF .index_bfi-done__J_3zM:before,.index_bf-modal-root__1P_VQ .index_bfi-done__J_3zM:before{content:\"\\E912\"}.index_bf-container__1HxhF .index_bfi-drop-down__2-Azn:before,.index_bf-modal-root__1P_VQ .index_bfi-drop-down__2-Azn:before{content:\"\\E906\"}.index_bf-container__1HxhF .index_bfi-drop-up__f9cHI:before,.index_bf-modal-root__1P_VQ .index_bfi-drop-up__f9cHI:before{content:\"\\E909\"}.index_bf-container__1HxhF .index_bfi-emoji__37yM6:before,.index_bf-modal-root__1P_VQ .index_bfi-emoji__37yM6:before{content:\"\\E91B\"}.index_bf-container__1HxhF .index_bfi-font-size__1cbPf:before,.index_bf-modal-root__1P_VQ .index_bfi-font-size__1cbPf:before{content:\"\\E920\"}.index_bf-container__1HxhF .index_bfi-fullscreen__2txWy:before,.index_bf-modal-root__1P_VQ .index_bfi-fullscreen__2txWy:before{content:\"\\E910\"}.index_bf-container__1HxhF .index_bfi-fullscreen-exit__33svQ:before,.index_bf-modal-root__1P_VQ .index_bfi-fullscreen-exit__33svQ:before{content:\"\\E90D\"}.index_bf-container__1HxhF .index_bfi-help__xa9vi:before,.index_bf-modal-root__1P_VQ .index_bfi-help__xa9vi:before{content:\"\\E902\"}.index_bf-container__1HxhF .index_bfi-indent-decrease__1CtRw:before,.index_bf-modal-root__1P_VQ .index_bfi-indent-decrease__1CtRw:before{content:\"\\E92F\"}.index_bf-container__1HxhF .index_bfi-indent-increase__2kSOy:before,.index_bf-modal-root__1P_VQ .index_bfi-indent-increase__2kSOy:before{content:\"\\E92E\"}.index_bf-container__1HxhF .index_bfi-info__3gDtD:before,.index_bf-modal-root__1P_VQ .index_bfi-info__3gDtD:before{content:\"\\E901\"}.index_bf-container__1HxhF .index_bfi-italic__1ENXj:before,.index_bf-modal-root__1P_VQ .index_bfi-italic__1ENXj:before{content:\"\\E924\"}.index_bf-container__1HxhF .index_bfi-link__3-0Rp:before,.index_bf-modal-root__1P_VQ .index_bfi-link__3-0Rp:before{content:\"\\E91A\"}.index_bf-container__1HxhF .index_bfi-link-off__2xzYa:before,.index_bf-modal-root__1P_VQ .index_bfi-link-off__2xzYa:before{content:\"\\E919\"}.index_bf-container__1HxhF .index_bfi-list__3GI0k:before,.index_bf-modal-root__1P_VQ .index_bfi-list__3GI0k:before{content:\"\\E923\"}.index_bf-container__1HxhF .index_bfi-list-numbered__U2An6:before,.index_bf-modal-root__1P_VQ .index_bfi-list-numbered__U2An6:before{content:\"\\E922\"}.index_bf-container__1HxhF .index_bfi-menu__YEtEG:before,.index_bf-modal-root__1P_VQ .index_bfi-menu__YEtEG:before{content:\"\\E908\"}.index_bf-container__1HxhF .index_bfi-more-horiz__38Kqk:before,.index_bf-modal-root__1P_VQ .index_bfi-more-horiz__38Kqk:before{content:\"\\E90B\"}.index_bf-container__1HxhF .index_bfi-more-vert__1Xpoy:before,.index_bf-modal-root__1P_VQ .index_bfi-more-vert__1Xpoy:before{content:\"\\E90A\"}.index_bf-container__1HxhF .index_bfi-not-disturb__2wwfA:before,.index_bf-modal-root__1P_VQ .index_bfi-not-disturb__2wwfA:before{content:\"\\E907\"}.index_bf-container__1HxhF .index_bfi-print__1Vdsh:before,.index_bf-modal-root__1P_VQ .index_bfi-print__1Vdsh:before{content:\"\\E915\"}.index_bf-container__1HxhF .index_bfi-quote__1xD3O:before,.index_bf-modal-root__1P_VQ .index_bfi-quote__1xD3O:before{content:\"\\E921\"}.index_bf-container__1HxhF .index_bfi-search__2G21G:before,.index_bf-modal-root__1P_VQ .index_bfi-search__2G21G:before{content:\"\\E916\"}.index_bf-container__1HxhF .index_bfi-settingsx__5qqai:before,.index_bf-modal-root__1P_VQ .index_bfi-settingsx__5qqai:before{content:\"\\E917\"}.index_bf-container__1HxhF .index_bfi-share__LmF7D:before,.index_bf-modal-root__1P_VQ .index_bfi-share__LmF7D:before{content:\"\\E905\"}.index_bf-container__1HxhF .index_bfi-share-square__sA_aV:before,.index_bf-modal-root__1P_VQ .index_bfi-share-square__sA_aV:before{content:\"\\E900\"}.index_bf-container__1HxhF .index_bfi-strikethrough__3Oij6:before,.index_bf-modal-root__1P_VQ .index_bfi-strikethrough__3Oij6:before{content:\"\\E91F\"}.index_bf-container__1HxhF .index_bfi-text-color__1p69s .index_path1__1i_Zc:before,.index_bf-modal-root__1P_VQ .index_bfi-text-color__1p69s .index_path1__1i_Zc:before{font-family:braft-icons!important;content:\"\\E930\";opacity:.36}.index_bf-container__1HxhF .index_bfi-text-color__1p69s .index_path2__DFG_e:before,.index_bf-modal-root__1P_VQ .index_bfi-text-color__1p69s .index_path2__DFG_e:before{font-family:braft-icons!important;content:\"\\E931\";margin-left:-1em}.index_bf-container__1HxhF .index_bfi-underlined__oAOe6:before,.index_bf-modal-root__1P_VQ .index_bfi-underlined__oAOe6:before{content:\"\\E91D\"}.index_bf-content__5lf-j{height:500px;padding-bottom:10px;overflow:auto;font-size:16px}.index_bf-content__5lf-j img{-webkit-user-select:none;user-select:none}.index_bf-content__5lf-j *{line-height:normal}.index_bf-container__1HxhF{position:relative;height:100%;padding:0}.index_bf-container__1HxhF.index_disabled__KFBp_{pointer-events:none;opacity:.7;filter:grayscale(70%)}.index_bf-container__1HxhF.index_read-only__3HgNB .index_bf-controlbar__ej8fA{pointer-events:none}.index_bf-container__1HxhF.index_read-only__3HgNB .index_bf-image__1MXDI img:hover{outline:none}.index_bf-container__1HxhF.index_read-only__3HgNB .index_bf-hr__39L4E{pointer-events:none}.index_bf-container__1HxhF.index_fullscreen__2MrQv{position:fixed;display:flex;flex-direction:column;z-index:99999;top:0;right:0;bottom:0;left:0;background-color:#fff;height:100%!important}.index_bf-container__1HxhF.index_fullscreen__2MrQv .index_bf-content__5lf-j{flex-grow:1;height:auto}.index_bf-container__1HxhF .index_input-group__1Y0_d{display:block}.index_bf-container__1HxhF .index_input-group__1Y0_d input{box-sizing:border-box;width:100%;height:36px;padding:0 15px;font-size:14px}.index_bf-container__1HxhF .index_pull-left__33hHK{float:left}.index_bf-container__1HxhF .index_pull-right__22QW0{float:right}.index_bf-container__1HxhF button{line-height:normal}.index_bf-container__1HxhF button.index_default__11aE1,.index_bf-container__1HxhF button.index_ghost__q2A8s,.index_bf-container__1HxhF button.index_primary__1ex4f{height:32px;padding:0 20px;color:#fff;font-size:12px}.index_bf-container__1HxhF button.index_default__11aE1{background-color:hsla(0,0%,100%,.15);border:none}.index_bf-container__1HxhF button.index_default__11aE1:hover{background-color:hsla(0,0%,100%,.1)}.index_bf-container__1HxhF button.index_ghost__q2A8s{background-color:transparent;border:none;box-shadow:inset 0 0 0 .5px hsla(0,0%,100%,.5)}.index_bf-container__1HxhF button.index_ghost__q2A8s:hover{box-shadow:inset 0 0 0 .5px hsla(0,0%,100%,.7)}.index_bf-container__1HxhF button.index_primary__1ex4f{background-color:#3498db;border:none;color:#fff}.index_bf-container__1HxhF button.index_primary__1ex4f:hover{background-color:#2084c7}.index_bf-container__1HxhF .index_public-DraftEditorPlaceholder-root__1T6lJ{top:15px;left:15px;font-size:16px;pointer-events:none}.index_bf-container__1HxhF .index_DraftEditor-editorContainer__1FR0o{box-sizing:border-box;border:none}.index_bf-container__1HxhF .index_DraftEditor-root__mlfOI,.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu{height:100%}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu{box-sizing:border-box;padding:15px;word-wrap:break-word;word-break:break-all}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu>div{padding-bottom:20px}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu .index_braft-link__1ZeMr{color:#4078c0}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu blockquote{margin:0 0 10px;padding:15px 20px;background-color:#f1f2f3;border-left:5px solid #ccc;color:#666;font-style:italic}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu pre{max-width:100%;max-height:100%;margin:10px 0;padding:15px;overflow:auto;background-color:#f1f2f3;border-radius:3px;color:#666;font-family:monospace;font-size:14px;font-weight:400;line-height:16px;word-wrap:break-word;white-space:pre-wrap}.index_bf-container__1HxhF .index_public-DraftEditor-content__T2mZu pre pre{margin:0;padding:0}.index_bf-container__1HxhF .index_bfa-left__3CWAj,.index_bf-container__1HxhF .index_bfa-left__3CWAj .index_public-DraftStyleDefault-ltr__3qMdW{text-align:left}.index_bf-container__1HxhF .index_bfa-right__Sy5sn,.index_bf-container__1HxhF .index_bfa-right__Sy5sn .index_public-DraftStyleDefault-ltr__3qMdW{text-align:right}.index_bf-container__1HxhF .index_bfa-center__3iBxk,.index_bf-container__1HxhF .index_bfa-center__3iBxk .index_public-DraftStyleDefault-ltr__3qMdW{text-align:center}.index_bf-container__1HxhF .index_bfa-justify__C4cm4,.index_bf-container__1HxhF .index_bfa-justify__C4cm4 .index_public-DraftStyleDefault-ltr__3qMdW{text-align:justify}.index_bf-container__1HxhF .index_bfa-center__3iBxk>div,.index_bf-container__1HxhF .index_bfa-justify__C4cm4>div,.index_bf-container__1HxhF .index_bfa-left__3CWAj>div,.index_bf-container__1HxhF .index_bfa-right__Sy5sn>div{display:inline-block}.index_bf-container__1HxhF .index_bff-left__pCNho:hover,.index_bf-container__1HxhF .index_bff-right__vpxtc:hover{z-index:2}.index_bf-container__1HxhF .index_bff-left__pCNho{position:relative;z-index:1;float:left;margin:0 10px 0 0}.index_bf-container__1HxhF .index_bff-right__vpxtc{position:relative;z-index:1;float:right;margin:0 0 0 10px}.index_bf-container__1HxhF .index_bftd-1__382qR{text-indent:2em;display:initial}.index_bf-container__1HxhF .index_bftd-2__11te-{text-indent:4em;display:initial}.index_bf-container__1HxhF .index_bftd-3__2BZeG{text-indent:6em;display:initial}.index_bf-container__1HxhF .index_bftd-4__4c1Sw{text-indent:8em;display:initial}.index_bf-container__1HxhF .index_bftd-5__34mlP{text-indent:10em;display:initial}.index_bf-container__1HxhF .index_bftd-6__1bsox{text-indent:12em;display:initial}.index_bf-container__1HxhF .index_bf-image__1MXDI,.index_bf-container__1HxhF .index_bf-media__33Dic{position:relative}.index_bf-container__1HxhF .index_bf-image__1MXDI img{display:block;max-width:100%;font-size:0;resize:both;outline-offset:1px}.index_bf-container__1HxhF .index_bf-image__1MXDI img:hover{outline:1px solid #3498db}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5{position:absolute;z-index:3;bottom:15px;left:50%;width:auto;background-color:#21242a;border-radius:2px;font-weight:400;text-align:center;white-space:nowrap;transform:translateX(-50%);box-shadow:0 5px 15px rgba(0,0,0,.2);-webkit-user-select:none;user-select:none}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 .index_bf-media-toolbar-arrow__M3uMb,.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5:before{position:absolute;bottom:-10px;left:50%;display:block;border:5px solid transparent;border-top-color:#21242a;content:\"\";transform:translateX(-5px)}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a{display:inline-block;min-width:40px;height:40px;color:hsla(0,0%,100%,.5);font-family:braft-icons!important;font-size:18px;font-weight:400;line-height:40px;text-align:center;text-decoration:none;text-transform:uppercase;cursor:pointer}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a:hover{color:#fff}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a:first-child{border-radius:2px 0 0 2px}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a:last-child{border-radius:0 2px 2px 0}.index_bf-container__1HxhF .index_bf-media-toolbar__28qi5 a.index_active__3_mlp{color:#3498db}.index_bf-video-player__3Eqxs video{display:block;width:640px;max-width:80vw;height:auto;margin:0 10px 10px;object-fit:contain}.index_bf-audio-player__67sKu audio{width:480px;max-width:80vw;margin:0 10px 10px}.index_bf-player-holder__1k4R5{position:relative;height:240px;overflow:hidden;background-color:#21242a;border-radius:3px}.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN{position:absolute;z-index:2;top:0;left:0;height:30px;padding:0 15px;border-radius:0 0 3px 0;color:#fff;background-color:hsla(0,0%,100%,.1)}.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN i,.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN span{display:block;float:left;line-height:30px}.index_bf-player-holder__1k4R5 .index_icon-badge__35ukN span{margin-left:5px;font-size:12px}.index_bf-player-holder__1k4R5 .index_button-remove__cTw4D{position:absolute;z-index:2;top:5px;right:5px;width:40px;height:40px;background-color:transparent;border:none;border-radius:50%;outline:none;color:#fff;font-size:24px;text-align:center;cursor:pointer}.index_bf-player-holder__1k4R5 .index_button-remove__cTw4D:hover{color:#e74c3c}.index_bf-player-holder__1k4R5 .index_button-play__1GpMM{position:relative;z-index:2;display:block;width:80px;height:80px;margin:40px auto 20px;background-color:rgba(0,0,0,.7);border:none;border-radius:50%;outline:none;color:#fff;font-size:48px;line-height:80px;text-align:center;backdrop-filter:blur(10px);-webkit-backdrop-filter:blur(10px);cursor:pointer}.index_bf-player-holder__1k4R5 .index_button-play__1GpMM:hover{background-color:#3498db}.index_bf-player-holder__1k4R5 .index_bf-name__3FBAI{position:relative;z-index:2;margin:0;color:#fff;font-size:14px;font-weight:500;text-align:center}.index_bf-player-holder__1k4R5 .index_bf-url__1di3g{position:relative;z-index:2;width:70%;margin:10px auto;color:hsla(0,0%,100%,.5);font-size:12px;font-weight:400;text-align:center}.index_bf-player-holder__1k4R5 .index_bf-poster__drCvq{position:absolute;top:0;left:0;width:100%;height:100%;background-repeat:no-repeat;background-position:50% 50%;background-size:cover;opacity:.3}.index_bf-modal__23mEu{position:fixed;z-index:99999;top:0;left:0;width:100%;height:100%}.index_bf-modal__23mEu button{outline:none}.index_bf-modal-mask__3MKbg{position:absolute;z-index:1;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.1);opacity:0;transition:opacity .2s}.index_bf-modal-content__1RScF{position:absolute;z-index:2;top:45%;left:50%;max-width:95%;background-color:#fff;border-radius:2px;box-shadow:0 15px 30px rgba(0,0,0,.1);opacity:0;transform:translate(-50%,-40%);transition:transform .2s,opacity .2s}.index_bf-modal-header__3jeX-{height:50px}.index_bf-modal-caption__2z9hD{float:left;margin:0;padding:0 15px;color:#999;font-size:14px;font-weight:400;line-height:50px}.index_bf-modal-close-button__13UMv{float:right;width:50px;height:50px;background-color:transparent;border:none;color:#ccc;font-size:18px;cursor:pointer}.index_bf-modal-close-button__13UMv:hover{color:#e74c3c}.index_bf-modal-body__3MjbZ{overflow:auto}.index_bf-modal-footer__3Pc0k{min-height:15px;padding:0 15px;overflow:hidden}.index_bf-modal-addon-text__3dQDG{float:left;color:#999;font-size:12px;line-height:60px}.index_bf-modal-buttons__2IuAO{float:right}.index_bf-modal-cancel__30ePe,.index_bf-modal-confirm__3woeJ{height:36px;margin:12px 0 12px 15px;padding:0 30px;border:none;border-radius:2px;font-size:12px;font-weight:700;cursor:pointer}.index_bf-modal-cancel__30ePe{background-color:#e8e9ea;color:#999}.index_bf-modal-cancel__30ePe:hover{background-color:#d8d9da}.index_bf-modal-confirm__3woeJ{background-color:#3498db;color:#fff}.index_bf-modal-confirm__3woeJ:hover{background-color:#2084c7}.index_bf-modal-confirm__3woeJ.index_disabled__KFBp_{opacity:.3;pointer-events:none;filter:grayscale(.4)}.index_bf-modal-root__1P_VQ.index_active__3_mlp .index_bf-modal-mask__3MKbg{opacity:1}.index_bf-modal-root__1P_VQ.index_active__3_mlp .index_bf-modal-content__1RScF{opacity:1;transform:translate(-50%,-50%)}.index_bf-content__5lf-j .index_bf-hr__39L4E{position:relative;box-sizing:content-box;height:15px;padding-top:15px;text-align:center}.index_bf-content__5lf-j .index_bf-hr__39L4E:before{display:block;height:1px;background-color:rgba(0,0,0,.1);content:\"\"}.index_bf-content__5lf-j .index_bf-hr__39L4E:hover:before{background-color:rgba(0,0,0,.3)}.index_bf-content__5lf-j .index_bf-hr__39L4E:hover .index_bf-media-toolbar__28qi5{display:block}.index_bf-content__5lf-j .index_bf-hr__39L4E .index_bf-media-toolbar__28qi5{display:none}.index_bf-image-link-editor__L5XLU,.index_bf-image-size-editor__3DAVi{padding-bottom:1px;overflow:hidden;border-radius:2px 2px 0 0;box-shadow:inset 0 -1px 0 0 hsla(0,0%,100%,.1)}.index_bf-image-link-editor__L5XLU .index_editor-input-group__1hcX3,.index_bf-image-size-editor__3DAVi .index_editor-input-group__1hcX3{width:300px;margin:8px 10px;overflow:hidden}.index_bf-image-link-editor__L5XLU input,.index_bf-image-size-editor__3DAVi input{display:block;float:left;box-sizing:content-box;height:32px;margin:0 5px 0 0;padding:0 10px;background-color:hsla(0,0%,100%,.1);border:none;border-radius:2px;outline:none;box-shadow:inset 0 0 0 1px hsla(0,0%,100%,.1);color:#fff;font-weight:700}.index_bf-image-link-editor__L5XLU input:hover,.index_bf-image-size-editor__3DAVi input:hover{box-shadow:inset 0 0 0 1px rgba(52,152,219,.5)}.index_bf-image-link-editor__L5XLU input:focus,.index_bf-image-size-editor__3DAVi input:focus{box-shadow:inset 0 0 0 1px #3498db}.index_bf-image-link-editor__L5XLU button,.index_bf-image-size-editor__3DAVi button{float:left;width:90px;height:32px;margin:0;padding:0 20px;background-color:#3498db;border:none;color:#fff;font-size:12px;border-radius:2px;cursor:pointer}.index_bf-image-link-editor__L5XLU button:hover,.index_bf-image-size-editor__3DAVi button:hover{background-color:#2084c7}.index_bf-image-size-editor__3DAVi input{width:80px}.index_bf-image-link-editor__L5XLU input{width:185px}.index_bf-image-link-editor__L5XLU .index_switch-group__3nsEF{height:16px;margin:10px}.index_bf-image-link-editor__L5XLU .index_switch-group__3nsEF .index_bf-switch__1LPr-{float:left}.index_bf-image-link-editor__L5XLU .index_switch-group__3nsEF label{float:left;margin-left:15px;color:#999;font-size:12px;line-height:16px}.index_bf-content__5lf-j .index_bf-image__1MXDI{position:relative}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-csize-icon__13EM-{position:absolute;z-index:2;width:10px;height:10px;background-color:rgba(52,152,219,.3)}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-csize-icon__13EM-.index_right-bottom__2jlUD{right:0;bottom:0;cursor:se-resize}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-csize-icon__13EM-.index_left-bottom__1H0sb{left:0;bottom:0;cursor:sw-resize}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-pre-csize__2lLOX{position:absolute;z-index:1;background:transparent}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-pre-csize__2lLOX.index_rightbottom__S1Zly{left:0;top:0;border:1px dashed #00bfff}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-pre-csize__2lLOX.index_leftbottom__wbQiO{right:0;top:0;border:1px dashed #00bfff}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5:before{visibility:hidden}.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-align=center] [data-align=center],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-align=left] [data-align=left],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-align=right] [data-align=right],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-float=left] [data-float=left],.index_bf-content__5lf-j .index_bf-image__1MXDI .index_bf-media-toolbar__28qi5[data-float=right] [data-float=right]{color:#3498db}.index_headings-dropdown__1KzQP{min-width:110px}.index_headings-dropdown__1KzQP .index_menu__10kCt{width:200px;overflow:hidden}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov-{padding:15px 20px;text-align:left;line-height:normal}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h1,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h2,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h3,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h4,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h5,.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h6{margin:0;padding:0;color:inherit}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h1{font-size:28px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h2{font-size:24px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h3{font-size:20px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h4{font-size:16px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h5{font-size:14px}.index_headings-dropdown__1KzQP .index_menu__10kCt .index_menu-item__2_Ov- h6{font-size:12px}.index_bf-link-editor__w7aBK{width:360px;padding-top:25px}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d{margin:0 15px 8px}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input{background-color:hsla(0,0%,100%,.07);border:none;border-radius:2px;box-shadow:inset 0 0 0 1px hsla(0,0%,100%,.1);color:#fff;font-weight:700}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input:hover{box-shadow:inset 0 0 0 1px rgba(52,152,219,.5)}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input:focus{box-shadow:inset 0 0 0 1px #3498db}.index_bf-link-editor__w7aBK .index_input-group__1Y0_d input:disabled{color:hsla(0,0%,100%,.7);box-shadow:none}.index_bf-link-editor__w7aBK .index_switch-group__3nsEF{height:16px;margin:15px}.index_bf-link-editor__w7aBK .index_switch-group__3nsEF .index_bf-switch__1LPr-{float:left}.index_bf-link-editor__w7aBK .index_switch-group__3nsEF label{float:left;margin-left:15px;color:#999;font-size:12px;line-height:16px}.index_bf-link-editor__w7aBK .index_buttons__3QT_I{box-sizing:content-box;height:32px;margin-top:20px;padding:15px;overflow:hidden;box-shadow:inset 0 1px 0 0 hsla(0,0%,100%,.1)}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W{color:#999;font-size:12px;line-height:32px;cursor:pointer}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W:hover{color:#e74c3c}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W i{margin-right:5px;font-size:16px}.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W i,.index_bf-link-editor__w7aBK .index_buttons__3QT_I .index_button-remove-link__2004W span{display:block;float:left;line-height:32px}.index_bf-link-editor__w7aBK .index_buttons__3QT_I button{margin-left:10px;border-radius:2px;font-weight:700;cursor:pointer}.index_bf-dropdown__zgKp1{position:relative;width:auto;height:36px;margin:0}.index_bf-dropdown__zgKp1.index_disabled__KFBp_{pointer-events:none;opacity:.3}.index_bf-dropdown__zgKp1.index_light-theme__iYoel .index_dropdown-content__2HerW{border:1px solid #ccc}.index_bf-dropdown__zgKp1.index_light-theme__iYoel .index_dropdown-content__2HerW .index_dropdown-arrow__3KWgU{background-color:#fff;border:1px solid #ccc}.index_bf-dropdown__zgKp1.index_light-theme__iYoel .index_dropdown-content__2HerW .index_dropdown-content-inner__5r4YN{background-color:#fff}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW{box-sizing:content-box;position:absolute;z-index:10;top:100%;left:50%;visibility:hidden;float:left;width:auto;min-width:100%;margin-top:9px;border-radius:2px;box-shadow:0 5px 15px rgba(0,0,0,.2);opacity:0;cursor:default;transform:translate(-50%,20px);transition:.2s}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW ::-webkit-scrollbar-track{background-color:transparent}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW ::-webkit-scrollbar{width:4px;background-color:transparent;border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW ::-webkit-scrollbar-thumb{background-color:hsla(0,0%,100%,.3);border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_dropdown-arrow__3KWgU{position:absolute;z-index:1;top:-3px;left:50%;width:10px;height:10px;background-color:#21242a;transform:translateX(-50%) rotate(45deg);transition:margin .2s}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_dropdown-arrow__3KWgU.index_active__3_mlp{background-color:#3498db}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu__10kCt{list-style:none;margin:0;padding:0;overflow:hidden;border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-{display:block;list-style:none;margin:0;font-size:16px;cursor:pointer}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-:hover{background-color:rgba(0,0,0,.1)}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-.index_active__3_mlp{background-color:#3498db;color:#fff}.index_bf-dropdown__zgKp1 .index_dropdown-content__2HerW .index_menu-item__2_Ov-:not(.index_active__3_mlp){color:hsla(0,0%,100%,.6);box-shadow:inset 0 -1px 0 0 hsla(0,0%,100%,.1)}.index_bf-dropdown__zgKp1 .index_dropdown-content-inner__5r4YN{position:relative;z-index:2;overflow:auto;background-color:#21242a;border-radius:2px}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS{position:relative;display:block;width:100%;height:36px;background-color:transparent;border:none;color:#6a6f7b;cursor:pointer}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS:hover{background-color:rgba(0,0,0,.05)}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS *{display:inline;padding:0;font-size:inherit;font-weight:400}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS>span{float:left;padding:0 10px;font-size:14px;line-height:36px;pointer-events:none}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS>span i{display:block;height:36px;font-size:16px;line-height:36px;text-align:center}.index_bf-dropdown__zgKp1 .index_dropdown-handler__1xChS .index_bfi-drop-down__2-Azn{float:right;width:30px;height:36px;font-size:16px;line-height:36px;text-align:center;pointer-events:none}.index_bf-dropdown__zgKp1.index_active__3_mlp .index_dropdown-handler__1xChS{background-color:rgba(0,0,0,.05)}.index_bf-dropdown__zgKp1.index_active__3_mlp .index_dropdown-content__2HerW{visibility:visible;opacity:1;transform:translate(-50%)}.index_text-color-dropdown__pnJCI.index_light-theme__iYoel .index_bf-color-switch-buttons__R4l-y button{border-bottom:1px solid #ccc;color:#616569}.index_text-color-dropdown__pnJCI.index_light-theme__iYoel .index_bf-color-switch-buttons__R4l-y button.index_active__3_mlp{border-bottom-color:#3498db;color:#3498db}.index_text-color-dropdown__pnJCI button.index_dropdown-handler__1xChS span{width:36px;padding:0;overflow:hidden;border-radius:2px}.index_text-color-dropdown__pnJCI .index_bf-text-color-picker-wrap__2xWAh{overflow:hidden}.index_text-color-dropdown__pnJCI .index_bf-color-switch-buttons__R4l-y{height:36px}.index_text-color-dropdown__pnJCI .index_bf-color-switch-buttons__R4l-y button{float:left;width:50%;height:36px;background-color:transparent;border:none;border-bottom:1px solid hsla(0,0%,100%,.1);color:hsla(0,0%,100%,.5);font-size:12px;font-weight:400;text-transform:uppercase;cursor:pointer}.index_text-color-dropdown__pnJCI .index_bf-color-switch-buttons__R4l-y button.index_active__3_mlp{border-bottom-color:#3498db;color:#3498db}.index_bf-colors__2Jog3{box-sizing:content-box;list-style:none;width:240px;margin:0;padding:15px;overflow:hidden}.index_bf-colors__2Jog3 li{box-sizing:content-box;display:block;float:left;width:24px;height:24px;margin:5px;padding:0;background-color:currentColor;border:3px solid transparent;border-radius:50%;cursor:pointer;transition:transform .2s}.index_bf-colors__2Jog3 li:hover{transform:scale(1.3)}.index_bf-colors__2Jog3 li.index_active__3_mlp{box-shadow:0 0 0 2px #3498db}.index_bf-font-size-dropdown__38pES{min-width:95px}.index_bf-font-sizes__2rRGp{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-font-sizes__2rRGp li{display:block;float:left;width:60px;height:30px;background-color:hsla(0,0%,100%,.1);border-radius:2px;margin:5px;color:#fff;font-size:12px;line-height:30px;text-align:center;text-transform:uppercase;cursor:pointer}.index_bf-font-sizes__2rRGp li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-font-sizes__2rRGp li.index_active__3_mlp{background-color:#3498db}.index_font-family-dropdown__rYXD5{min-width:120px}.index_font-family-dropdown__rYXD5 .index_dropdown-content__2HerW{width:180px}.index_font-family-dropdown__rYXD5 .index_menu-item__2_Ov-{padding:12px 15px}.index_bf-line-height-dropdown__ee0Ld{min-width:95px}.index_bf-line-heights__2Oa0w{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-line-heights__2Oa0w li{display:block;float:left;width:60px;height:30px;background-color:hsla(0,0%,100%,.1);border-radius:2px;margin:5px;color:#fff;font-size:12px;line-height:30px;text-align:center;text-transform:uppercase;cursor:pointer}.index_bf-line-heights__2Oa0w li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-line-heights__2Oa0w li.index_active__3_mlp{background-color:#3498db}.index_bf-letter-spacing-dropdown__1t21I{min-width:95px}.index_bf-letter-spacings__MYcL5{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-letter-spacings__MYcL5 li{display:block;float:left;width:60px;height:30px;background-color:hsla(0,0%,100%,.1);border-radius:2px;margin:5px;color:#fff;font-size:12px;line-height:30px;text-align:center;text-transform:uppercase;cursor:pointer}.index_bf-letter-spacings__MYcL5 li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-letter-spacings__MYcL5 li.index_active__3_mlp{background-color:#3498db}.index_bf-emojis-wrap__3FqEM{position:relative;width:210px;height:220px;overflow:hidden}.index_bf-emojis-wrap__3FqEM:after,.index_bf-emojis-wrap__3FqEM:before{position:absolute;z-index:1;right:0;left:0;height:30px;border-radius:2px;content:\"\";pointer-events:none}.index_bf-emojis-wrap__3FqEM:before{top:0;background-image:linear-gradient(0deg,rgba(33,36,42,0),#21242a)}.index_bf-emojis-wrap__3FqEM:after{bottom:0;background-image:linear-gradient(rgba(33,36,42,0),#21242a)}.index_bf-emojis__3p4Ps{box-sizing:content-box;width:200px;height:195px;list-style:none;margin:0;padding:15px 15px 20px;overflow:auto}.index_bf-emojis__3p4Ps li{display:block;float:left;width:30px;height:30px;margin:0;padding:0;color:#fff;border-radius:2px;font-family:Apple Color Emoji,Segoe UI,Segoe UI Emoji,Segoe UI Symbol;font-size:18px;line-height:32px;text-align:center;cursor:pointer;-webkit-user-select:none;user-select:none;transition:transform .2s}.index_bf-emojis__3p4Ps li:hover{transform:scale(1.5)}";
  38407. styleInject_es.styleInject(css$1);
  38408. var css$2 = ".emoticon_braft-emoticon-picker__26_HU{box-sizing:border-box;width:210px;height:210px;overflow:hidden}.emoticon_braft-emoticon-picker__26_HU:after,.emoticon_braft-emoticon-picker__26_HU:before{position:absolute;z-index:1;right:0;left:0;height:30px;border-radius:2px;content:\"\";pointer-events:none}.emoticon_braft-emoticon-picker__26_HU:before{top:0;background-image:linear-gradient(0deg,rgba(33,36,42,0),#21242a)}.emoticon_braft-emoticon-picker__26_HU:after{bottom:0;background-image:linear-gradient(rgba(33,36,42,0),#21242a)}.emoticon_braft-emoticon-picker__26_HU .emoticon_braft-emoticons-list__P1AeK{box-sizing:content-box;width:200px;height:190px;margin:0;padding:15px 15px 20px;overflow:auto}.emoticon_braft-emoticon-picker__26_HU .emoticon_braft-emoticons-list__P1AeK img{display:block;box-sizing:content-box;float:left;width:20px;height:20px;margin:3px;padding:5px;border-radius:3px}.emoticon_braft-emoticon-picker__26_HU .emoticon_braft-emoticons-list__P1AeK img:hover{background-color:#3498db}.emoticon_braft-emoticon-in-editor__10cwl{position:relative;padding:0 2px;letter-spacing:12px}.emoticon_braft-emoticon-in-editor__10cwl img{position:absolute;top:0;left:2px;width:16px;height:16px}";
  38409. styleInject_es.styleInject(css$2);
  38410. var emoticon = index.createCommonjsModule(function (module, exports) {
  38411. (function webpackUniversalModuleDefinition(root, factory) {
  38412. module.exports = factory(React__default, dist$1);
  38413. })(window, function(__WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__6__) {
  38414. return /******/ (function(modules) { // webpackBootstrap
  38415. /******/ // The module cache
  38416. /******/ var installedModules = {};
  38417. /******/
  38418. /******/ // The require function
  38419. /******/ function __webpack_require__(moduleId) {
  38420. /******/
  38421. /******/ // Check if module is in cache
  38422. /******/ if(installedModules[moduleId]) {
  38423. /******/ return installedModules[moduleId].exports;
  38424. /******/ }
  38425. /******/ // Create a new module (and put it into the cache)
  38426. /******/ var module = installedModules[moduleId] = {
  38427. /******/ i: moduleId,
  38428. /******/ l: false,
  38429. /******/ exports: {}
  38430. /******/ };
  38431. /******/
  38432. /******/ // Execute the module function
  38433. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  38434. /******/
  38435. /******/ // Flag the module as loaded
  38436. /******/ module.l = true;
  38437. /******/
  38438. /******/ // Return the exports of the module
  38439. /******/ return module.exports;
  38440. /******/ }
  38441. /******/
  38442. /******/
  38443. /******/ // expose the modules object (__webpack_modules__)
  38444. /******/ __webpack_require__.m = modules;
  38445. /******/
  38446. /******/ // expose the module cache
  38447. /******/ __webpack_require__.c = installedModules;
  38448. /******/
  38449. /******/ // define getter function for harmony exports
  38450. /******/ __webpack_require__.d = function(exports, name, getter) {
  38451. /******/ if(!__webpack_require__.o(exports, name)) {
  38452. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  38453. /******/ }
  38454. /******/ };
  38455. /******/
  38456. /******/ // define __esModule on exports
  38457. /******/ __webpack_require__.r = function(exports) {
  38458. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  38459. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  38460. /******/ }
  38461. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  38462. /******/ };
  38463. /******/
  38464. /******/ // create a fake namespace object
  38465. /******/ // mode & 1: value is a module id, require it
  38466. /******/ // mode & 2: merge all properties of value into the ns
  38467. /******/ // mode & 4: return value when already ns object
  38468. /******/ // mode & 8|1: behave like require
  38469. /******/ __webpack_require__.t = function(value, mode) {
  38470. /******/ if(mode & 1) value = __webpack_require__(value);
  38471. /******/ if(mode & 8) return value;
  38472. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  38473. /******/ var ns = Object.create(null);
  38474. /******/ __webpack_require__.r(ns);
  38475. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  38476. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  38477. /******/ return ns;
  38478. /******/ };
  38479. /******/
  38480. /******/ // getDefaultExport function for compatibility with non-harmony modules
  38481. /******/ __webpack_require__.n = function(module) {
  38482. /******/ var getter = module && module.__esModule ?
  38483. /******/ function getDefault() { return module['default']; } :
  38484. /******/ function getModuleExports() { return module; };
  38485. /******/ __webpack_require__.d(getter, 'a', getter);
  38486. /******/ return getter;
  38487. /******/ };
  38488. /******/
  38489. /******/ // Object.prototype.hasOwnProperty.call
  38490. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  38491. /******/
  38492. /******/ // __webpack_public_path__
  38493. /******/ __webpack_require__.p = "/";
  38494. /******/
  38495. /******/
  38496. /******/ // Load entry module and return exports
  38497. /******/ return __webpack_require__(__webpack_require__.s = 33);
  38498. /******/ })
  38499. /************************************************************************/
  38500. /******/ ({
  38501. /***/ 1:
  38502. /***/ (function(module, exports) {
  38503. module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
  38504. /***/ }),
  38505. /***/ 2:
  38506. /***/ (function(module, exports) {
  38507. function _defineProperty(obj, key, value) {
  38508. if (key in obj) {
  38509. Object.defineProperty(obj, key, {
  38510. value: value,
  38511. enumerable: true,
  38512. configurable: true,
  38513. writable: true
  38514. });
  38515. } else {
  38516. obj[key] = value;
  38517. }
  38518. return obj;
  38519. }
  38520. module.exports = _defineProperty;
  38521. /***/ }),
  38522. /***/ 33:
  38523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38524. __webpack_require__.r(__webpack_exports__);
  38525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultEmoticons", function() { return defaultEmoticons; });
  38526. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
  38527. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);
  38528. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
  38529. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  38530. /* harmony import */ var braft_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
  38531. /* harmony import */ var _styles_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(48);
  38532. // https://www.iconfinder.com/iconsets/emoji-18
  38533. var defaultEmoticons = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25].map(function (item) {
  38534. return "".concat(item, ".png");
  38535. });
  38536. var insertEmoticon = function insertEmoticon(editor, editorState, src) {
  38537. editor.setValue(braft_utils__WEBPACK_IMPORTED_MODULE_2__["ContentUtils"].insertText(editorState, ' ', null, {
  38538. type: 'EMOTICON',
  38539. mutability: 'IMMUTABLE',
  38540. data: {
  38541. src: src
  38542. }
  38543. }));
  38544. };
  38545. var controlRef = null;
  38546. var bindControlRef = function bindControlRef(ref) {
  38547. return controlRef = ref;
  38548. };
  38549. /* harmony default export */ __webpack_exports__["default"] = (function (options) {
  38550. options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({
  38551. emoticons: [],
  38552. closeOnSelect: false,
  38553. closeOnBlur: false
  38554. }, options);
  38555. var _options = options,
  38556. emoticons = _options.emoticons,
  38557. closeOnSelect = _options.closeOnSelect,
  38558. closeOnBlur = _options.closeOnBlur,
  38559. includeEditors = _options.includeEditors,
  38560. excludeEditors = _options.excludeEditors;
  38561. return {
  38562. type: 'entity',
  38563. includeEditors: includeEditors,
  38564. excludeEditors: excludeEditors,
  38565. name: 'EMOTICON',
  38566. control: function control(props) {
  38567. return {
  38568. key: 'EMOTICON',
  38569. replace: 'emoji',
  38570. type: 'dropdown',
  38571. text: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("i", {
  38572. className: "bfi-emoji"
  38573. }),
  38574. showArrow: false,
  38575. ref: bindControlRef,
  38576. autoHide: closeOnBlur,
  38577. component: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("div", {
  38578. className: "braft-emoticon-picker"
  38579. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("div", {
  38580. className: "braft-emoticons-list"
  38581. }, emoticons.map(function (item, index) {
  38582. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  38583. onClick: function onClick() {
  38584. insertEmoticon(props.editor, props.editorState, item);
  38585. closeOnSelect && controlRef && controlRef.hide();
  38586. },
  38587. key: index,
  38588. src: item
  38589. });
  38590. })))
  38591. };
  38592. },
  38593. mutability: 'IMMUTABLE',
  38594. component: function component(props) {
  38595. var entity = props.contentState.getEntity(props.entityKey);
  38596. var _entity$getData = entity.getData(),
  38597. src = _entity$getData.src;
  38598. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("span", {
  38599. className: "braft-emoticon-in-editor"
  38600. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  38601. src: src
  38602. }), props.children);
  38603. },
  38604. importer: function importer(nodeName, node) {
  38605. if (nodeName.toLowerCase() === 'span' && node.classList && node.classList.contains('braft-emoticon-wrap')) {
  38606. var imgNode = node.querySelector('img');
  38607. var src = imgNode.getAttribute('src'); // 移除img节点以避免生成atomic block
  38608. node.removeChild(imgNode);
  38609. return {
  38610. mutability: 'IMMUTABLE',
  38611. data: {
  38612. src: src
  38613. }
  38614. };
  38615. }
  38616. },
  38617. exporter: function exporter(entityObject, initialText) {
  38618. var src = entityObject.data.src;
  38619. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("span", {
  38620. className: "braft-emoticon-wrap"
  38621. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  38622. src: src
  38623. }), initialText);
  38624. }
  38625. };
  38626. });
  38627. /***/ }),
  38628. /***/ 48:
  38629. /***/ (function(module, exports) {
  38630. // removed by extract-text-webpack-plugin
  38631. /***/ }),
  38632. /***/ 5:
  38633. /***/ (function(module, exports, __webpack_require__) {
  38634. var defineProperty = __webpack_require__(2);
  38635. function _objectSpread(target) {
  38636. for (var i = 1; i < arguments.length; i++) {
  38637. var source = arguments[i] != null ? arguments[i] : {};
  38638. var ownKeys = Object.keys(source);
  38639. if (typeof Object.getOwnPropertySymbols === 'function') {
  38640. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  38641. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  38642. }));
  38643. }
  38644. ownKeys.forEach(function (key) {
  38645. defineProperty(target, key, source[key]);
  38646. });
  38647. }
  38648. return target;
  38649. }
  38650. module.exports = _objectSpread;
  38651. /***/ }),
  38652. /***/ 6:
  38653. /***/ (function(module, exports) {
  38654. module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
  38655. /***/ })
  38656. /******/ });
  38657. });
  38658. });
  38659. var Emoticon = index.unwrapExports(emoticon);
  38660. var emoticon_1 = emoticon.defaultEmoticons;
  38661. var maxLength = index.createCommonjsModule(function (module, exports) {
  38662. (function webpackUniversalModuleDefinition(root, factory) {
  38663. module.exports = factory();
  38664. })(window, function() {
  38665. return /******/ (function(modules) { // webpackBootstrap
  38666. /******/ // The module cache
  38667. /******/ var installedModules = {};
  38668. /******/
  38669. /******/ // The require function
  38670. /******/ function __webpack_require__(moduleId) {
  38671. /******/
  38672. /******/ // Check if module is in cache
  38673. /******/ if(installedModules[moduleId]) {
  38674. /******/ return installedModules[moduleId].exports;
  38675. /******/ }
  38676. /******/ // Create a new module (and put it into the cache)
  38677. /******/ var module = installedModules[moduleId] = {
  38678. /******/ i: moduleId,
  38679. /******/ l: false,
  38680. /******/ exports: {}
  38681. /******/ };
  38682. /******/
  38683. /******/ // Execute the module function
  38684. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  38685. /******/
  38686. /******/ // Flag the module as loaded
  38687. /******/ module.l = true;
  38688. /******/
  38689. /******/ // Return the exports of the module
  38690. /******/ return module.exports;
  38691. /******/ }
  38692. /******/
  38693. /******/
  38694. /******/ // expose the modules object (__webpack_modules__)
  38695. /******/ __webpack_require__.m = modules;
  38696. /******/
  38697. /******/ // expose the module cache
  38698. /******/ __webpack_require__.c = installedModules;
  38699. /******/
  38700. /******/ // define getter function for harmony exports
  38701. /******/ __webpack_require__.d = function(exports, name, getter) {
  38702. /******/ if(!__webpack_require__.o(exports, name)) {
  38703. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  38704. /******/ }
  38705. /******/ };
  38706. /******/
  38707. /******/ // define __esModule on exports
  38708. /******/ __webpack_require__.r = function(exports) {
  38709. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  38710. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  38711. /******/ }
  38712. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  38713. /******/ };
  38714. /******/
  38715. /******/ // create a fake namespace object
  38716. /******/ // mode & 1: value is a module id, require it
  38717. /******/ // mode & 2: merge all properties of value into the ns
  38718. /******/ // mode & 4: return value when already ns object
  38719. /******/ // mode & 8|1: behave like require
  38720. /******/ __webpack_require__.t = function(value, mode) {
  38721. /******/ if(mode & 1) value = __webpack_require__(value);
  38722. /******/ if(mode & 8) return value;
  38723. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  38724. /******/ var ns = Object.create(null);
  38725. /******/ __webpack_require__.r(ns);
  38726. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  38727. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  38728. /******/ return ns;
  38729. /******/ };
  38730. /******/
  38731. /******/ // getDefaultExport function for compatibility with non-harmony modules
  38732. /******/ __webpack_require__.n = function(module) {
  38733. /******/ var getter = module && module.__esModule ?
  38734. /******/ function getDefault() { return module['default']; } :
  38735. /******/ function getModuleExports() { return module; };
  38736. /******/ __webpack_require__.d(getter, 'a', getter);
  38737. /******/ return getter;
  38738. /******/ };
  38739. /******/
  38740. /******/ // Object.prototype.hasOwnProperty.call
  38741. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  38742. /******/
  38743. /******/ // __webpack_public_path__
  38744. /******/ __webpack_require__.p = "/";
  38745. /******/
  38746. /******/
  38747. /******/ // Load entry module and return exports
  38748. /******/ return __webpack_require__(__webpack_require__.s = 34);
  38749. /******/ })
  38750. /************************************************************************/
  38751. /******/ ({
  38752. /***/ 2:
  38753. /***/ (function(module, exports) {
  38754. function _defineProperty(obj, key, value) {
  38755. if (key in obj) {
  38756. Object.defineProperty(obj, key, {
  38757. value: value,
  38758. enumerable: true,
  38759. configurable: true,
  38760. writable: true
  38761. });
  38762. } else {
  38763. obj[key] = value;
  38764. }
  38765. return obj;
  38766. }
  38767. module.exports = _defineProperty;
  38768. /***/ }),
  38769. /***/ 34:
  38770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38771. __webpack_require__.r(__webpack_exports__);
  38772. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
  38773. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);
  38774. var getSelectedTextLength = function getSelectedTextLength(editorState) {
  38775. var currentSelection = editorState.getSelection();
  38776. var isCollapsed = currentSelection.isCollapsed();
  38777. var length = 0;
  38778. if (!isCollapsed) {
  38779. var currentContent = editorState.getCurrentContent();
  38780. var startKey = currentSelection.getStartKey();
  38781. var endKey = currentSelection.getEndKey();
  38782. var startBlock = currentContent.getBlockForKey(startKey);
  38783. var isStartAndEndBlockAreTheSame = startKey === endKey;
  38784. var startBlockTextLength = startBlock.getLength();
  38785. var startSelectedTextLength = startBlockTextLength - currentSelection.getStartOffset();
  38786. var endSelectedTextLength = currentSelection.getEndOffset();
  38787. var keyAfterEnd = currentContent.getKeyAfter(endKey);
  38788. if (isStartAndEndBlockAreTheSame) {
  38789. length += currentSelection.getEndOffset() - currentSelection.getStartOffset();
  38790. } else {
  38791. var currentKey = startKey;
  38792. while (currentKey && currentKey !== keyAfterEnd) {
  38793. if (currentKey === startKey) {
  38794. length += startSelectedTextLength + 1;
  38795. } else if (currentKey === endKey) {
  38796. length += endSelectedTextLength;
  38797. } else {
  38798. length += currentContent.getBlockForKey(currentKey).getLength() + 1;
  38799. }
  38800. currentKey = currentContent.getKeyAfter(currentKey);
  38801. }
  38802. }
  38803. }
  38804. return length;
  38805. };
  38806. /* harmony default export */ __webpack_exports__["default"] = (function (options) {
  38807. options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({
  38808. defaultValue: Infinity
  38809. }, options);
  38810. var _options = options,
  38811. includeEditors = _options.includeEditors,
  38812. excludeEditors = _options.excludeEditors,
  38813. defaultValue = _options.defaultValue;
  38814. return {
  38815. type: 'prop-interception',
  38816. includeEditors: includeEditors,
  38817. excludeEditors: excludeEditors,
  38818. interceptor: function interceptor(editorProps) {
  38819. var maxLength = editorProps.maxLength || defaultValue;
  38820. editorProps.handleBeforeInput = function (_, editorState) {
  38821. if (maxLength === Infinity) {
  38822. return 'not-handled';
  38823. }
  38824. var currentContentLength = editorState.toText().length;
  38825. var selectedTextLength = getSelectedTextLength(editorState);
  38826. if (currentContentLength - selectedTextLength > maxLength - 1) {
  38827. editorProps.onReachMaxLength && editorProps.onReachMaxLength(maxLength);
  38828. return 'handled';
  38829. }
  38830. };
  38831. editorProps.handlePastedText = function (pastedText, _, editorState) {
  38832. if (maxLength === Infinity) {
  38833. return 'not-handled';
  38834. }
  38835. var currentContentLength = editorState.toText().length;
  38836. var selectedTextLength = getSelectedTextLength(editorState);
  38837. if (currentContentLength + pastedText.length - selectedTextLength > maxLength) {
  38838. editorProps.onReachMaxLength && editorProps.onReachMaxLength(maxLength);
  38839. return 'handled';
  38840. }
  38841. };
  38842. return editorProps;
  38843. }
  38844. };
  38845. });
  38846. /***/ }),
  38847. /***/ 5:
  38848. /***/ (function(module, exports, __webpack_require__) {
  38849. var defineProperty = __webpack_require__(2);
  38850. function _objectSpread(target) {
  38851. for (var i = 1; i < arguments.length; i++) {
  38852. var source = arguments[i] != null ? arguments[i] : {};
  38853. var ownKeys = Object.keys(source);
  38854. if (typeof Object.getOwnPropertySymbols === 'function') {
  38855. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  38856. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  38857. }));
  38858. }
  38859. ownKeys.forEach(function (key) {
  38860. defineProperty(target, key, source[key]);
  38861. });
  38862. }
  38863. return target;
  38864. }
  38865. module.exports = _objectSpread;
  38866. /***/ })
  38867. /******/ });
  38868. });
  38869. });
  38870. var MaxLength = index.unwrapExports(maxLength);
  38871. var lengthOptions = {
  38872. defaultValue: 100
  38873. };
  38874. BraftEditor.use(MaxLength(lengthOptions));
  38875. var emoticons = emoticon_1.map(function (item) {
  38876. return require("braft-extensions/dist/assets/".concat(item));
  38877. });
  38878. var emotionOptions = {
  38879. emoticons: emoticons,
  38880. closeOnBlur: true,
  38881. closeOnSelect: false
  38882. };
  38883. BraftEditor.use(Emoticon(emotionOptions));
  38884. var BarftEditorPage = function BarftEditorPage(_ref) {
  38885. var _classnames2;
  38886. var initValue = _ref.initValue,
  38887. value = _ref.value,
  38888. onChange = _ref.onChange,
  38889. controls = _ref.controls,
  38890. FloatControls = _ref.FloatControls;
  38891. var optionsControls = controls ? controls : ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
  38892. var options = {
  38893. controls: optionsControls,
  38894. uncontrolled: !value && !onChange,
  38895. showControlsBar: optionsControls && optionsControls.length > 0 && !FloatControls,
  38896. showFloatControls: FloatControls
  38897. };
  38898. var _useState = React.useState(BraftEditor.createEditorState(initValue || "<p>Hello <b>World!</b></p>")),
  38899. _useState2 = slicedToArray._slicedToArray(_useState, 2),
  38900. insideValue = _useState2[0],
  38901. setInsideValue = _useState2[1];
  38902. var _useState3 = React.useState(false),
  38903. _useState4 = slicedToArray._slicedToArray(_useState3, 2),
  38904. focusState = _useState4[0],
  38905. setFocusState = _useState4[1];
  38906. var resultValue;
  38907. var resultAction;
  38908. if (options.uncontrolled) {
  38909. resultValue = insideValue;
  38910. resultAction = setInsideValue;
  38911. } else {
  38912. resultValue = value;
  38913. resultAction = onChange;
  38914. }
  38915. return React__default.createElement("div", {
  38916. className: styles.baseWrapper
  38917. }, React__default.createElement(BraftEditor, {
  38918. value: resultValue,
  38919. onChange: resultAction,
  38920. controls: options.controls,
  38921. controlBarClassName: index.classnames(styles.controlBar, defineProperty._defineProperty({}, styles.focus, focusState)),
  38922. controlBarStyle: options.showControlsBar ? {} : {
  38923. display: "none"
  38924. },
  38925. contentClassName: index.classnames(styles.editorContent, (_classnames2 = {}, defineProperty._defineProperty(_classnames2, styles.focus, focusState), defineProperty._defineProperty(_classnames2, styles.hasFloatControls, options.showFloatControls), _classnames2)),
  38926. contentStyle: {},
  38927. onFocus: function onFocus() {
  38928. return setFocusState(true);
  38929. },
  38930. onBlur: function onBlur() {
  38931. return setFocusState(false);
  38932. },
  38933. hooks: {
  38934. "toggle-link": function toggleLink(_ref2) {
  38935. var href = _ref2.href,
  38936. target = _ref2.target;
  38937. href = href.indexOf("http") === 0 ? href : "http://".concat(href);
  38938. return {
  38939. href: href,
  38940. target: target
  38941. };
  38942. }
  38943. }
  38944. }), options.showFloatControls ? React__default.createElement("div", {
  38945. className: index.classnames(styles.floatControls)
  38946. }, React__default.createElement(FloatControls, {
  38947. editorState: resultValue,
  38948. setEditorState: resultAction
  38949. })) : null);
  38950. };
  38951. exports.BarftEditorPage = BarftEditorPage;
  38952. exports.default = BarftEditorPage;
  38953. //# sourceMappingURL=index.js.map