暫無描述

index.js 962KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033
  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 _commonjsHelpers = require('../_commonjsHelpers-4ed3570f.js');
  5. var React = require('react');
  6. var React__default = _interopDefault(React);
  7. var styleInject_es = require('../style-inject.es-dcee06b6.js');
  8. var Draft = require('../Draft-7ee7c163.js');
  9. var _reactDom_commonjsExternal = require('../_react-dom_commonjs-external-55867475.js');
  10. require('react-dom');
  11. var server = _interopDefault(require('react-dom/server'));
  12. var immutable = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  13. /**
  14. * Copyright (c) 2014-present, Facebook, Inc.
  15. *
  16. * This source code is licensed under the MIT license found in the
  17. * LICENSE file in the root directory of this source tree.
  18. */
  19. (function (global, factory) {
  20. factory(exports) ;
  21. }(_commonjsHelpers.commonjsGlobal, (function (exports) {
  22. // Used for setting prototype methods that IE8 chokes on.
  23. var DELETE = 'delete';
  24. // Constants describing the size of trie nodes.
  25. var SHIFT = 5; // Resulted in best performance after ______?
  26. var SIZE = 1 << SHIFT;
  27. var MASK = SIZE - 1;
  28. // A consistent shared value representing "not set" which equals nothing other
  29. // than itself, and nothing that could be provided externally.
  30. var NOT_SET = {};
  31. // Boolean references, Rough equivalent of `bool &`.
  32. function MakeRef() {
  33. return { value: false };
  34. }
  35. function SetRef(ref) {
  36. if (ref) {
  37. ref.value = true;
  38. }
  39. }
  40. // A function which returns a value representing an "owner" for transient writes
  41. // to tries. The return value will only ever equal itself, and will not equal
  42. // the return of any subsequent call of this function.
  43. function OwnerID() {}
  44. function ensureSize(iter) {
  45. if (iter.size === undefined) {
  46. iter.size = iter.__iterate(returnTrue);
  47. }
  48. return iter.size;
  49. }
  50. function wrapIndex(iter, index) {
  51. // This implements "is array index" which the ECMAString spec defines as:
  52. //
  53. // A String property name P is an array index if and only if
  54. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  55. // to 2^32−1.
  56. //
  57. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  58. if (typeof index !== 'number') {
  59. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  60. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  61. return NaN;
  62. }
  63. index = uint32Index;
  64. }
  65. return index < 0 ? ensureSize(iter) + index : index;
  66. }
  67. function returnTrue() {
  68. return true;
  69. }
  70. function wholeSlice(begin, end, size) {
  71. return (
  72. ((begin === 0 && !isNeg(begin)) ||
  73. (size !== undefined && begin <= -size)) &&
  74. (end === undefined || (size !== undefined && end >= size))
  75. );
  76. }
  77. function resolveBegin(begin, size) {
  78. return resolveIndex(begin, size, 0);
  79. }
  80. function resolveEnd(end, size) {
  81. return resolveIndex(end, size, size);
  82. }
  83. function resolveIndex(index, size, defaultIndex) {
  84. // Sanitize indices using this shorthand for ToInt32(argument)
  85. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  86. return index === undefined
  87. ? defaultIndex
  88. : isNeg(index)
  89. ? size === Infinity
  90. ? size
  91. : Math.max(0, size + index) | 0
  92. : size === undefined || size === index
  93. ? index
  94. : Math.min(size, index) | 0;
  95. }
  96. function isNeg(value) {
  97. // Account for -0 which is negative, but not less than 0.
  98. return value < 0 || (value === 0 && 1 / value === -Infinity);
  99. }
  100. // Note: value is unchanged to not break immutable-devtools.
  101. var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
  102. function isCollection(maybeCollection) {
  103. return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]);
  104. }
  105. var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';
  106. function isKeyed(maybeKeyed) {
  107. return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]);
  108. }
  109. var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';
  110. function isIndexed(maybeIndexed) {
  111. return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]);
  112. }
  113. function isAssociative(maybeAssociative) {
  114. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  115. }
  116. var Collection = function Collection(value) {
  117. return isCollection(value) ? value : Seq(value);
  118. };
  119. var KeyedCollection = /*@__PURE__*/(function (Collection) {
  120. function KeyedCollection(value) {
  121. return isKeyed(value) ? value : KeyedSeq(value);
  122. }
  123. if ( Collection ) KeyedCollection.__proto__ = Collection;
  124. KeyedCollection.prototype = Object.create( Collection && Collection.prototype );
  125. KeyedCollection.prototype.constructor = KeyedCollection;
  126. return KeyedCollection;
  127. }(Collection));
  128. var IndexedCollection = /*@__PURE__*/(function (Collection) {
  129. function IndexedCollection(value) {
  130. return isIndexed(value) ? value : IndexedSeq(value);
  131. }
  132. if ( Collection ) IndexedCollection.__proto__ = Collection;
  133. IndexedCollection.prototype = Object.create( Collection && Collection.prototype );
  134. IndexedCollection.prototype.constructor = IndexedCollection;
  135. return IndexedCollection;
  136. }(Collection));
  137. var SetCollection = /*@__PURE__*/(function (Collection) {
  138. function SetCollection(value) {
  139. return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);
  140. }
  141. if ( Collection ) SetCollection.__proto__ = Collection;
  142. SetCollection.prototype = Object.create( Collection && Collection.prototype );
  143. SetCollection.prototype.constructor = SetCollection;
  144. return SetCollection;
  145. }(Collection));
  146. Collection.Keyed = KeyedCollection;
  147. Collection.Indexed = IndexedCollection;
  148. Collection.Set = SetCollection;
  149. var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';
  150. function isSeq(maybeSeq) {
  151. return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]);
  152. }
  153. var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
  154. function isRecord(maybeRecord) {
  155. return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]);
  156. }
  157. function isImmutable(maybeImmutable) {
  158. return isCollection(maybeImmutable) || isRecord(maybeImmutable);
  159. }
  160. var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';
  161. function isOrdered(maybeOrdered) {
  162. return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]);
  163. }
  164. var ITERATE_KEYS = 0;
  165. var ITERATE_VALUES = 1;
  166. var ITERATE_ENTRIES = 2;
  167. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  168. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  169. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  170. var Iterator = function Iterator(next) {
  171. this.next = next;
  172. };
  173. Iterator.prototype.toString = function toString () {
  174. return '[Iterator]';
  175. };
  176. Iterator.KEYS = ITERATE_KEYS;
  177. Iterator.VALUES = ITERATE_VALUES;
  178. Iterator.ENTRIES = ITERATE_ENTRIES;
  179. Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
  180. return this.toString();
  181. };
  182. Iterator.prototype[ITERATOR_SYMBOL] = function() {
  183. return this;
  184. };
  185. function iteratorValue(type, k, v, iteratorResult) {
  186. var value = type === 0 ? k : type === 1 ? v : [k, v];
  187. iteratorResult
  188. ? (iteratorResult.value = value)
  189. : (iteratorResult = {
  190. value: value,
  191. done: false,
  192. });
  193. return iteratorResult;
  194. }
  195. function iteratorDone() {
  196. return { value: undefined, done: true };
  197. }
  198. function hasIterator(maybeIterable) {
  199. return !!getIteratorFn(maybeIterable);
  200. }
  201. function isIterator(maybeIterator) {
  202. return maybeIterator && typeof maybeIterator.next === 'function';
  203. }
  204. function getIterator(iterable) {
  205. var iteratorFn = getIteratorFn(iterable);
  206. return iteratorFn && iteratorFn.call(iterable);
  207. }
  208. function getIteratorFn(iterable) {
  209. var iteratorFn =
  210. iterable &&
  211. ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  212. iterable[FAUX_ITERATOR_SYMBOL]);
  213. if (typeof iteratorFn === 'function') {
  214. return iteratorFn;
  215. }
  216. }
  217. var hasOwnProperty = Object.prototype.hasOwnProperty;
  218. function isArrayLike(value) {
  219. if (Array.isArray(value) || typeof value === 'string') {
  220. return true;
  221. }
  222. return (
  223. value &&
  224. typeof value === 'object' &&
  225. Number.isInteger(value.length) &&
  226. value.length >= 0 &&
  227. (value.length === 0
  228. ? // Only {length: 0} is considered Array-like.
  229. Object.keys(value).length === 1
  230. : // An object is only Array-like if it has a property where the last value
  231. // in the array-like may be found (which could be undefined).
  232. value.hasOwnProperty(value.length - 1))
  233. );
  234. }
  235. var Seq = /*@__PURE__*/(function (Collection$$1) {
  236. function Seq(value) {
  237. return value === null || value === undefined
  238. ? emptySequence()
  239. : isImmutable(value)
  240. ? value.toSeq()
  241. : seqFromValue(value);
  242. }
  243. if ( Collection$$1 ) Seq.__proto__ = Collection$$1;
  244. Seq.prototype = Object.create( Collection$$1 && Collection$$1.prototype );
  245. Seq.prototype.constructor = Seq;
  246. Seq.prototype.toSeq = function toSeq () {
  247. return this;
  248. };
  249. Seq.prototype.toString = function toString () {
  250. return this.__toString('Seq {', '}');
  251. };
  252. Seq.prototype.cacheResult = function cacheResult () {
  253. if (!this._cache && this.__iterateUncached) {
  254. this._cache = this.entrySeq().toArray();
  255. this.size = this._cache.length;
  256. }
  257. return this;
  258. };
  259. // abstract __iterateUncached(fn, reverse)
  260. Seq.prototype.__iterate = function __iterate (fn, reverse) {
  261. var cache = this._cache;
  262. if (cache) {
  263. var size = cache.length;
  264. var i = 0;
  265. while (i !== size) {
  266. var entry = cache[reverse ? size - ++i : i++];
  267. if (fn(entry[1], entry[0], this) === false) {
  268. break;
  269. }
  270. }
  271. return i;
  272. }
  273. return this.__iterateUncached(fn, reverse);
  274. };
  275. // abstract __iteratorUncached(type, reverse)
  276. Seq.prototype.__iterator = function __iterator (type, reverse) {
  277. var cache = this._cache;
  278. if (cache) {
  279. var size = cache.length;
  280. var i = 0;
  281. return new Iterator(function () {
  282. if (i === size) {
  283. return iteratorDone();
  284. }
  285. var entry = cache[reverse ? size - ++i : i++];
  286. return iteratorValue(type, entry[0], entry[1]);
  287. });
  288. }
  289. return this.__iteratorUncached(type, reverse);
  290. };
  291. return Seq;
  292. }(Collection));
  293. var KeyedSeq = /*@__PURE__*/(function (Seq) {
  294. function KeyedSeq(value) {
  295. return value === null || value === undefined
  296. ? emptySequence().toKeyedSeq()
  297. : isCollection(value)
  298. ? isKeyed(value)
  299. ? value.toSeq()
  300. : value.fromEntrySeq()
  301. : isRecord(value)
  302. ? value.toSeq()
  303. : keyedSeqFromValue(value);
  304. }
  305. if ( Seq ) KeyedSeq.__proto__ = Seq;
  306. KeyedSeq.prototype = Object.create( Seq && Seq.prototype );
  307. KeyedSeq.prototype.constructor = KeyedSeq;
  308. KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () {
  309. return this;
  310. };
  311. return KeyedSeq;
  312. }(Seq));
  313. var IndexedSeq = /*@__PURE__*/(function (Seq) {
  314. function IndexedSeq(value) {
  315. return value === null || value === undefined
  316. ? emptySequence()
  317. : isCollection(value)
  318. ? isKeyed(value)
  319. ? value.entrySeq()
  320. : value.toIndexedSeq()
  321. : isRecord(value)
  322. ? value.toSeq().entrySeq()
  323. : indexedSeqFromValue(value);
  324. }
  325. if ( Seq ) IndexedSeq.__proto__ = Seq;
  326. IndexedSeq.prototype = Object.create( Seq && Seq.prototype );
  327. IndexedSeq.prototype.constructor = IndexedSeq;
  328. IndexedSeq.of = function of (/*...values*/) {
  329. return IndexedSeq(arguments);
  330. };
  331. IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () {
  332. return this;
  333. };
  334. IndexedSeq.prototype.toString = function toString () {
  335. return this.__toString('Seq [', ']');
  336. };
  337. return IndexedSeq;
  338. }(Seq));
  339. var SetSeq = /*@__PURE__*/(function (Seq) {
  340. function SetSeq(value) {
  341. return (isCollection(value) && !isAssociative(value)
  342. ? value
  343. : IndexedSeq(value)
  344. ).toSetSeq();
  345. }
  346. if ( Seq ) SetSeq.__proto__ = Seq;
  347. SetSeq.prototype = Object.create( Seq && Seq.prototype );
  348. SetSeq.prototype.constructor = SetSeq;
  349. SetSeq.of = function of (/*...values*/) {
  350. return SetSeq(arguments);
  351. };
  352. SetSeq.prototype.toSetSeq = function toSetSeq () {
  353. return this;
  354. };
  355. return SetSeq;
  356. }(Seq));
  357. Seq.isSeq = isSeq;
  358. Seq.Keyed = KeyedSeq;
  359. Seq.Set = SetSeq;
  360. Seq.Indexed = IndexedSeq;
  361. Seq.prototype[IS_SEQ_SYMBOL] = true;
  362. // #pragma Root Sequences
  363. var ArraySeq = /*@__PURE__*/(function (IndexedSeq) {
  364. function ArraySeq(array) {
  365. this._array = array;
  366. this.size = array.length;
  367. }
  368. if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq;
  369. ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  370. ArraySeq.prototype.constructor = ArraySeq;
  371. ArraySeq.prototype.get = function get (index, notSetValue) {
  372. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  373. };
  374. ArraySeq.prototype.__iterate = function __iterate (fn, reverse) {
  375. var array = this._array;
  376. var size = array.length;
  377. var i = 0;
  378. while (i !== size) {
  379. var ii = reverse ? size - ++i : i++;
  380. if (fn(array[ii], ii, this) === false) {
  381. break;
  382. }
  383. }
  384. return i;
  385. };
  386. ArraySeq.prototype.__iterator = function __iterator (type, reverse) {
  387. var array = this._array;
  388. var size = array.length;
  389. var i = 0;
  390. return new Iterator(function () {
  391. if (i === size) {
  392. return iteratorDone();
  393. }
  394. var ii = reverse ? size - ++i : i++;
  395. return iteratorValue(type, ii, array[ii]);
  396. });
  397. };
  398. return ArraySeq;
  399. }(IndexedSeq));
  400. var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) {
  401. function ObjectSeq(object) {
  402. var keys = Object.keys(object);
  403. this._object = object;
  404. this._keys = keys;
  405. this.size = keys.length;
  406. }
  407. if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq;
  408. ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
  409. ObjectSeq.prototype.constructor = ObjectSeq;
  410. ObjectSeq.prototype.get = function get (key, notSetValue) {
  411. if (notSetValue !== undefined && !this.has(key)) {
  412. return notSetValue;
  413. }
  414. return this._object[key];
  415. };
  416. ObjectSeq.prototype.has = function has (key) {
  417. return hasOwnProperty.call(this._object, key);
  418. };
  419. ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {
  420. var object = this._object;
  421. var keys = this._keys;
  422. var size = keys.length;
  423. var i = 0;
  424. while (i !== size) {
  425. var key = keys[reverse ? size - ++i : i++];
  426. if (fn(object[key], key, this) === false) {
  427. break;
  428. }
  429. }
  430. return i;
  431. };
  432. ObjectSeq.prototype.__iterator = function __iterator (type, reverse) {
  433. var object = this._object;
  434. var keys = this._keys;
  435. var size = keys.length;
  436. var i = 0;
  437. return new Iterator(function () {
  438. if (i === size) {
  439. return iteratorDone();
  440. }
  441. var key = keys[reverse ? size - ++i : i++];
  442. return iteratorValue(type, key, object[key]);
  443. });
  444. };
  445. return ObjectSeq;
  446. }(KeyedSeq));
  447. ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;
  448. var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) {
  449. function CollectionSeq(collection) {
  450. this._collection = collection;
  451. this.size = collection.length || collection.size;
  452. }
  453. if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq;
  454. CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  455. CollectionSeq.prototype.constructor = CollectionSeq;
  456. CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {
  457. if (reverse) {
  458. return this.cacheResult().__iterate(fn, reverse);
  459. }
  460. var collection = this._collection;
  461. var iterator = getIterator(collection);
  462. var iterations = 0;
  463. if (isIterator(iterator)) {
  464. var step;
  465. while (!(step = iterator.next()).done) {
  466. if (fn(step.value, iterations++, this) === false) {
  467. break;
  468. }
  469. }
  470. }
  471. return iterations;
  472. };
  473. CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {
  474. if (reverse) {
  475. return this.cacheResult().__iterator(type, reverse);
  476. }
  477. var collection = this._collection;
  478. var iterator = getIterator(collection);
  479. if (!isIterator(iterator)) {
  480. return new Iterator(iteratorDone);
  481. }
  482. var iterations = 0;
  483. return new Iterator(function () {
  484. var step = iterator.next();
  485. return step.done ? step : iteratorValue(type, iterations++, step.value);
  486. });
  487. };
  488. return CollectionSeq;
  489. }(IndexedSeq));
  490. // # pragma Helper functions
  491. var EMPTY_SEQ;
  492. function emptySequence() {
  493. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  494. }
  495. function keyedSeqFromValue(value) {
  496. var seq = Array.isArray(value)
  497. ? new ArraySeq(value)
  498. : hasIterator(value)
  499. ? new CollectionSeq(value)
  500. : undefined;
  501. if (seq) {
  502. return seq.fromEntrySeq();
  503. }
  504. if (typeof value === 'object') {
  505. return new ObjectSeq(value);
  506. }
  507. throw new TypeError(
  508. 'Expected Array or collection object of [k, v] entries, or keyed object: ' +
  509. value
  510. );
  511. }
  512. function indexedSeqFromValue(value) {
  513. var seq = maybeIndexedSeqFromValue(value);
  514. if (seq) {
  515. return seq;
  516. }
  517. throw new TypeError(
  518. 'Expected Array or collection object of values: ' + value
  519. );
  520. }
  521. function seqFromValue(value) {
  522. var seq = maybeIndexedSeqFromValue(value);
  523. if (seq) {
  524. return seq;
  525. }
  526. if (typeof value === 'object') {
  527. return new ObjectSeq(value);
  528. }
  529. throw new TypeError(
  530. 'Expected Array or collection object of values, or keyed object: ' + value
  531. );
  532. }
  533. function maybeIndexedSeqFromValue(value) {
  534. return isArrayLike(value)
  535. ? new ArraySeq(value)
  536. : hasIterator(value)
  537. ? new CollectionSeq(value)
  538. : undefined;
  539. }
  540. var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@';
  541. function isMap(maybeMap) {
  542. return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]);
  543. }
  544. function isOrderedMap(maybeOrderedMap) {
  545. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  546. }
  547. function isValueObject(maybeValue) {
  548. return Boolean(
  549. maybeValue &&
  550. typeof maybeValue.equals === 'function' &&
  551. typeof maybeValue.hashCode === 'function'
  552. );
  553. }
  554. /**
  555. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  556. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  557. *
  558. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  559. * value, which is different from the algorithm described by
  560. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  561. *
  562. * This is extended further to allow Objects to describe the values they
  563. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  564. *
  565. * Note: because of this extension, the key equality of Immutable.Map and the
  566. * value equality of Immutable.Set will differ from ES6 Map and Set.
  567. *
  568. * ### Defining custom values
  569. *
  570. * The easiest way to describe the value an object represents is by implementing
  571. * `valueOf`. For example, `Date` represents a value by returning a unix
  572. * timestamp for `valueOf`:
  573. *
  574. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  575. * var date2 = new Date(1234567890000);
  576. * date1.valueOf(); // 1234567890000
  577. * assert( date1 !== date2 );
  578. * assert( Immutable.is( date1, date2 ) );
  579. *
  580. * Note: overriding `valueOf` may have other implications if you use this object
  581. * where JavaScript expects a primitive, such as implicit string coercion.
  582. *
  583. * For more complex types, especially collections, implementing `valueOf` may
  584. * not be performant. An alternative is to implement `equals` and `hashCode`.
  585. *
  586. * `equals` takes another object, presumably of similar type, and returns true
  587. * if it is equal. Equality is symmetrical, so the same result should be
  588. * returned if this and the argument are flipped.
  589. *
  590. * assert( a.equals(b) === b.equals(a) );
  591. *
  592. * `hashCode` returns a 32bit integer number representing the object which will
  593. * be used to determine how to store the value object in a Map or Set. You must
  594. * provide both or neither methods, one must not exist without the other.
  595. *
  596. * Also, an important relationship between these methods must be upheld: if two
  597. * values are equal, they *must* return the same hashCode. If the values are not
  598. * equal, they might have the same hashCode; this is called a hash collision,
  599. * and while undesirable for performance reasons, it is acceptable.
  600. *
  601. * if (a.equals(b)) {
  602. * assert( a.hashCode() === b.hashCode() );
  603. * }
  604. *
  605. * All Immutable collections are Value Objects: they implement `equals()`
  606. * and `hashCode()`.
  607. */
  608. function is(valueA, valueB) {
  609. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  610. return true;
  611. }
  612. if (!valueA || !valueB) {
  613. return false;
  614. }
  615. if (
  616. typeof valueA.valueOf === 'function' &&
  617. typeof valueB.valueOf === 'function'
  618. ) {
  619. valueA = valueA.valueOf();
  620. valueB = valueB.valueOf();
  621. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  622. return true;
  623. }
  624. if (!valueA || !valueB) {
  625. return false;
  626. }
  627. }
  628. return !!(
  629. isValueObject(valueA) &&
  630. isValueObject(valueB) &&
  631. valueA.equals(valueB)
  632. );
  633. }
  634. var imul =
  635. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2
  636. ? Math.imul
  637. : function imul(a, b) {
  638. a |= 0; // int
  639. b |= 0; // int
  640. var c = a & 0xffff;
  641. var d = b & 0xffff;
  642. // Shift by 0 fixes the sign on the high part.
  643. return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int
  644. };
  645. // v8 has an optimization for storing 31-bit signed numbers.
  646. // Values which have either 00 or 11 as the high order bits qualify.
  647. // This function drops the highest order bit in a signed number, maintaining
  648. // the sign bit.
  649. function smi(i32) {
  650. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
  651. }
  652. var defaultValueOf = Object.prototype.valueOf;
  653. function hash(o) {
  654. switch (typeof o) {
  655. case 'boolean':
  656. // The hash values for built-in constants are a 1 value for each 5-byte
  657. // shift region expect for the first, which encodes the value. This
  658. // reduces the odds of a hash collision for these common values.
  659. return o ? 0x42108421 : 0x42108420;
  660. case 'number':
  661. return hashNumber(o);
  662. case 'string':
  663. return o.length > STRING_HASH_CACHE_MIN_STRLEN
  664. ? cachedHashString(o)
  665. : hashString(o);
  666. case 'object':
  667. case 'function':
  668. if (o === null) {
  669. return 0x42108422;
  670. }
  671. if (typeof o.hashCode === 'function') {
  672. // Drop any high bits from accidentally long hash codes.
  673. return smi(o.hashCode(o));
  674. }
  675. if (o.valueOf !== defaultValueOf && typeof o.valueOf === 'function') {
  676. o = o.valueOf(o);
  677. }
  678. return hashJSObj(o);
  679. case 'undefined':
  680. return 0x42108423;
  681. default:
  682. if (typeof o.toString === 'function') {
  683. return hashString(o.toString());
  684. }
  685. throw new Error('Value type ' + typeof o + ' cannot be hashed.');
  686. }
  687. }
  688. // Compress arbitrarily large numbers into smi hashes.
  689. function hashNumber(n) {
  690. if (n !== n || n === Infinity) {
  691. return 0;
  692. }
  693. var hash = n | 0;
  694. if (hash !== n) {
  695. hash ^= n * 0xffffffff;
  696. }
  697. while (n > 0xffffffff) {
  698. n /= 0xffffffff;
  699. hash ^= n;
  700. }
  701. return smi(hash);
  702. }
  703. function cachedHashString(string) {
  704. var hashed = stringHashCache[string];
  705. if (hashed === undefined) {
  706. hashed = hashString(string);
  707. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  708. STRING_HASH_CACHE_SIZE = 0;
  709. stringHashCache = {};
  710. }
  711. STRING_HASH_CACHE_SIZE++;
  712. stringHashCache[string] = hashed;
  713. }
  714. return hashed;
  715. }
  716. // http://jsperf.com/hashing-strings
  717. function hashString(string) {
  718. // This is the hash from JVM
  719. // The hash code for a string is computed as
  720. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  721. // where s[i] is the ith character of the string and n is the length of
  722. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  723. // (exclusive) by dropping high bits.
  724. var hashed = 0;
  725. for (var ii = 0; ii < string.length; ii++) {
  726. hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
  727. }
  728. return smi(hashed);
  729. }
  730. function hashJSObj(obj) {
  731. var hashed;
  732. if (usingWeakMap) {
  733. hashed = weakMap.get(obj);
  734. if (hashed !== undefined) {
  735. return hashed;
  736. }
  737. }
  738. hashed = obj[UID_HASH_KEY];
  739. if (hashed !== undefined) {
  740. return hashed;
  741. }
  742. if (!canDefineProperty) {
  743. hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  744. if (hashed !== undefined) {
  745. return hashed;
  746. }
  747. hashed = getIENodeHash(obj);
  748. if (hashed !== undefined) {
  749. return hashed;
  750. }
  751. }
  752. hashed = ++objHashUID;
  753. if (objHashUID & 0x40000000) {
  754. objHashUID = 0;
  755. }
  756. if (usingWeakMap) {
  757. weakMap.set(obj, hashed);
  758. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  759. throw new Error('Non-extensible objects are not allowed as keys.');
  760. } else if (canDefineProperty) {
  761. Object.defineProperty(obj, UID_HASH_KEY, {
  762. enumerable: false,
  763. configurable: false,
  764. writable: false,
  765. value: hashed,
  766. });
  767. } else if (
  768. obj.propertyIsEnumerable !== undefined &&
  769. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable
  770. ) {
  771. // Since we can't define a non-enumerable property on the object
  772. // we'll hijack one of the less-used non-enumerable properties to
  773. // save our hash on it. Since this is a function it will not show up in
  774. // `JSON.stringify` which is what we want.
  775. obj.propertyIsEnumerable = function() {
  776. return this.constructor.prototype.propertyIsEnumerable.apply(
  777. this,
  778. arguments
  779. );
  780. };
  781. obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;
  782. } else if (obj.nodeType !== undefined) {
  783. // At this point we couldn't get the IE `uniqueID` to use as a hash
  784. // and we couldn't use a non-enumerable property to exploit the
  785. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  786. // itself.
  787. obj[UID_HASH_KEY] = hashed;
  788. } else {
  789. throw new Error('Unable to set a non-enumerable property on object.');
  790. }
  791. return hashed;
  792. }
  793. // Get references to ES5 object methods.
  794. var isExtensible = Object.isExtensible;
  795. // True if Object.defineProperty works as expected. IE8 fails this test.
  796. var canDefineProperty = (function() {
  797. try {
  798. Object.defineProperty({}, '@', {});
  799. return true;
  800. } catch (e) {
  801. return false;
  802. }
  803. })();
  804. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  805. // and avoid memory leaks from the IE cloneNode bug.
  806. function getIENodeHash(node) {
  807. if (node && node.nodeType > 0) {
  808. switch (node.nodeType) {
  809. case 1: // Element
  810. return node.uniqueID;
  811. case 9: // Document
  812. return node.documentElement && node.documentElement.uniqueID;
  813. }
  814. }
  815. }
  816. // If possible, use a WeakMap.
  817. var usingWeakMap = typeof WeakMap === 'function';
  818. var weakMap;
  819. if (usingWeakMap) {
  820. weakMap = new WeakMap();
  821. }
  822. var objHashUID = 0;
  823. var UID_HASH_KEY = '__immutablehash__';
  824. if (typeof Symbol === 'function') {
  825. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  826. }
  827. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  828. var STRING_HASH_CACHE_MAX_SIZE = 255;
  829. var STRING_HASH_CACHE_SIZE = 0;
  830. var stringHashCache = {};
  831. var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq$$1) {
  832. function ToKeyedSequence(indexed, useKeys) {
  833. this._iter = indexed;
  834. this._useKeys = useKeys;
  835. this.size = indexed.size;
  836. }
  837. if ( KeyedSeq$$1 ) ToKeyedSequence.__proto__ = KeyedSeq$$1;
  838. ToKeyedSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
  839. ToKeyedSequence.prototype.constructor = ToKeyedSequence;
  840. ToKeyedSequence.prototype.get = function get (key, notSetValue) {
  841. return this._iter.get(key, notSetValue);
  842. };
  843. ToKeyedSequence.prototype.has = function has (key) {
  844. return this._iter.has(key);
  845. };
  846. ToKeyedSequence.prototype.valueSeq = function valueSeq () {
  847. return this._iter.valueSeq();
  848. };
  849. ToKeyedSequence.prototype.reverse = function reverse () {
  850. var this$1 = this;
  851. var reversedSequence = reverseFactory(this, true);
  852. if (!this._useKeys) {
  853. reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); };
  854. }
  855. return reversedSequence;
  856. };
  857. ToKeyedSequence.prototype.map = function map (mapper, context) {
  858. var this$1 = this;
  859. var mappedSequence = mapFactory(this, mapper, context);
  860. if (!this._useKeys) {
  861. mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); };
  862. }
  863. return mappedSequence;
  864. };
  865. ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  866. var this$1 = this;
  867. return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse);
  868. };
  869. ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) {
  870. return this._iter.__iterator(type, reverse);
  871. };
  872. return ToKeyedSequence;
  873. }(KeyedSeq));
  874. ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;
  875. var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq$$1) {
  876. function ToIndexedSequence(iter) {
  877. this._iter = iter;
  878. this.size = iter.size;
  879. }
  880. if ( IndexedSeq$$1 ) ToIndexedSequence.__proto__ = IndexedSeq$$1;
  881. ToIndexedSequence.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  882. ToIndexedSequence.prototype.constructor = ToIndexedSequence;
  883. ToIndexedSequence.prototype.includes = function includes (value) {
  884. return this._iter.includes(value);
  885. };
  886. ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  887. var this$1 = this;
  888. var i = 0;
  889. reverse && ensureSize(this);
  890. return this._iter.__iterate(
  891. function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); },
  892. reverse
  893. );
  894. };
  895. ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) {
  896. var this$1 = this;
  897. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  898. var i = 0;
  899. reverse && ensureSize(this);
  900. return new Iterator(function () {
  901. var step = iterator.next();
  902. return step.done
  903. ? step
  904. : iteratorValue(
  905. type,
  906. reverse ? this$1.size - ++i : i++,
  907. step.value,
  908. step
  909. );
  910. });
  911. };
  912. return ToIndexedSequence;
  913. }(IndexedSeq));
  914. var ToSetSequence = /*@__PURE__*/(function (SetSeq$$1) {
  915. function ToSetSequence(iter) {
  916. this._iter = iter;
  917. this.size = iter.size;
  918. }
  919. if ( SetSeq$$1 ) ToSetSequence.__proto__ = SetSeq$$1;
  920. ToSetSequence.prototype = Object.create( SetSeq$$1 && SetSeq$$1.prototype );
  921. ToSetSequence.prototype.constructor = ToSetSequence;
  922. ToSetSequence.prototype.has = function has (key) {
  923. return this._iter.includes(key);
  924. };
  925. ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) {
  926. var this$1 = this;
  927. return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse);
  928. };
  929. ToSetSequence.prototype.__iterator = function __iterator (type, reverse) {
  930. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  931. return new Iterator(function () {
  932. var step = iterator.next();
  933. return step.done
  934. ? step
  935. : iteratorValue(type, step.value, step.value, step);
  936. });
  937. };
  938. return ToSetSequence;
  939. }(SetSeq));
  940. var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq$$1) {
  941. function FromEntriesSequence(entries) {
  942. this._iter = entries;
  943. this.size = entries.size;
  944. }
  945. if ( KeyedSeq$$1 ) FromEntriesSequence.__proto__ = KeyedSeq$$1;
  946. FromEntriesSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
  947. FromEntriesSequence.prototype.constructor = FromEntriesSequence;
  948. FromEntriesSequence.prototype.entrySeq = function entrySeq () {
  949. return this._iter.toSeq();
  950. };
  951. FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) {
  952. var this$1 = this;
  953. return this._iter.__iterate(function (entry) {
  954. // Check if entry exists first so array access doesn't throw for holes
  955. // in the parent iteration.
  956. if (entry) {
  957. validateEntry(entry);
  958. var indexedCollection = isCollection(entry);
  959. return fn(
  960. indexedCollection ? entry.get(1) : entry[1],
  961. indexedCollection ? entry.get(0) : entry[0],
  962. this$1
  963. );
  964. }
  965. }, reverse);
  966. };
  967. FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) {
  968. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  969. return new Iterator(function () {
  970. while (true) {
  971. var step = iterator.next();
  972. if (step.done) {
  973. return step;
  974. }
  975. var entry = step.value;
  976. // Check if entry exists first so array access doesn't throw for holes
  977. // in the parent iteration.
  978. if (entry) {
  979. validateEntry(entry);
  980. var indexedCollection = isCollection(entry);
  981. return iteratorValue(
  982. type,
  983. indexedCollection ? entry.get(0) : entry[0],
  984. indexedCollection ? entry.get(1) : entry[1],
  985. step
  986. );
  987. }
  988. }
  989. });
  990. };
  991. return FromEntriesSequence;
  992. }(KeyedSeq));
  993. ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
  994. function flipFactory(collection) {
  995. var flipSequence = makeSequence(collection);
  996. flipSequence._iter = collection;
  997. flipSequence.size = collection.size;
  998. flipSequence.flip = function () { return collection; };
  999. flipSequence.reverse = function() {
  1000. var reversedSequence = collection.reverse.apply(this); // super.reverse()
  1001. reversedSequence.flip = function () { return collection.reverse(); };
  1002. return reversedSequence;
  1003. };
  1004. flipSequence.has = function (key) { return collection.includes(key); };
  1005. flipSequence.includes = function (key) { return collection.has(key); };
  1006. flipSequence.cacheResult = cacheResultThrough;
  1007. flipSequence.__iterateUncached = function(fn, reverse) {
  1008. var this$1 = this;
  1009. return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse);
  1010. };
  1011. flipSequence.__iteratorUncached = function(type, reverse) {
  1012. if (type === ITERATE_ENTRIES) {
  1013. var iterator = collection.__iterator(type, reverse);
  1014. return new Iterator(function () {
  1015. var step = iterator.next();
  1016. if (!step.done) {
  1017. var k = step.value[0];
  1018. step.value[0] = step.value[1];
  1019. step.value[1] = k;
  1020. }
  1021. return step;
  1022. });
  1023. }
  1024. return collection.__iterator(
  1025. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  1026. reverse
  1027. );
  1028. };
  1029. return flipSequence;
  1030. }
  1031. function mapFactory(collection, mapper, context) {
  1032. var mappedSequence = makeSequence(collection);
  1033. mappedSequence.size = collection.size;
  1034. mappedSequence.has = function (key) { return collection.has(key); };
  1035. mappedSequence.get = function (key, notSetValue) {
  1036. var v = collection.get(key, NOT_SET);
  1037. return v === NOT_SET
  1038. ? notSetValue
  1039. : mapper.call(context, v, key, collection);
  1040. };
  1041. mappedSequence.__iterateUncached = function(fn, reverse) {
  1042. var this$1 = this;
  1043. return collection.__iterate(
  1044. function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; },
  1045. reverse
  1046. );
  1047. };
  1048. mappedSequence.__iteratorUncached = function(type, reverse) {
  1049. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1050. return new Iterator(function () {
  1051. var step = iterator.next();
  1052. if (step.done) {
  1053. return step;
  1054. }
  1055. var entry = step.value;
  1056. var key = entry[0];
  1057. return iteratorValue(
  1058. type,
  1059. key,
  1060. mapper.call(context, entry[1], key, collection),
  1061. step
  1062. );
  1063. });
  1064. };
  1065. return mappedSequence;
  1066. }
  1067. function reverseFactory(collection, useKeys) {
  1068. var this$1 = this;
  1069. var reversedSequence = makeSequence(collection);
  1070. reversedSequence._iter = collection;
  1071. reversedSequence.size = collection.size;
  1072. reversedSequence.reverse = function () { return collection; };
  1073. if (collection.flip) {
  1074. reversedSequence.flip = function() {
  1075. var flipSequence = flipFactory(collection);
  1076. flipSequence.reverse = function () { return collection.flip(); };
  1077. return flipSequence;
  1078. };
  1079. }
  1080. reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); };
  1081. reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); };
  1082. reversedSequence.includes = function (value) { return collection.includes(value); };
  1083. reversedSequence.cacheResult = cacheResultThrough;
  1084. reversedSequence.__iterate = function(fn, reverse) {
  1085. var this$1 = this;
  1086. var i = 0;
  1087. reverse && ensureSize(collection);
  1088. return collection.__iterate(
  1089. function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); },
  1090. !reverse
  1091. );
  1092. };
  1093. reversedSequence.__iterator = function (type, reverse) {
  1094. var i = 0;
  1095. reverse && ensureSize(collection);
  1096. var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse);
  1097. return new Iterator(function () {
  1098. var step = iterator.next();
  1099. if (step.done) {
  1100. return step;
  1101. }
  1102. var entry = step.value;
  1103. return iteratorValue(
  1104. type,
  1105. useKeys ? entry[0] : reverse ? this$1.size - ++i : i++,
  1106. entry[1],
  1107. step
  1108. );
  1109. });
  1110. };
  1111. return reversedSequence;
  1112. }
  1113. function filterFactory(collection, predicate, context, useKeys) {
  1114. var filterSequence = makeSequence(collection);
  1115. if (useKeys) {
  1116. filterSequence.has = function (key) {
  1117. var v = collection.get(key, NOT_SET);
  1118. return v !== NOT_SET && !!predicate.call(context, v, key, collection);
  1119. };
  1120. filterSequence.get = function (key, notSetValue) {
  1121. var v = collection.get(key, NOT_SET);
  1122. return v !== NOT_SET && predicate.call(context, v, key, collection)
  1123. ? v
  1124. : notSetValue;
  1125. };
  1126. }
  1127. filterSequence.__iterateUncached = function(fn, reverse) {
  1128. var this$1 = this;
  1129. var iterations = 0;
  1130. collection.__iterate(function (v, k, c) {
  1131. if (predicate.call(context, v, k, c)) {
  1132. iterations++;
  1133. return fn(v, useKeys ? k : iterations - 1, this$1);
  1134. }
  1135. }, reverse);
  1136. return iterations;
  1137. };
  1138. filterSequence.__iteratorUncached = function(type, reverse) {
  1139. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1140. var iterations = 0;
  1141. return new Iterator(function () {
  1142. while (true) {
  1143. var step = iterator.next();
  1144. if (step.done) {
  1145. return step;
  1146. }
  1147. var entry = step.value;
  1148. var key = entry[0];
  1149. var value = entry[1];
  1150. if (predicate.call(context, value, key, collection)) {
  1151. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  1152. }
  1153. }
  1154. });
  1155. };
  1156. return filterSequence;
  1157. }
  1158. function countByFactory(collection, grouper, context) {
  1159. var groups = Map().asMutable();
  1160. collection.__iterate(function (v, k) {
  1161. groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; });
  1162. });
  1163. return groups.asImmutable();
  1164. }
  1165. function groupByFactory(collection, grouper, context) {
  1166. var isKeyedIter = isKeyed(collection);
  1167. var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable();
  1168. collection.__iterate(function (v, k) {
  1169. groups.update(
  1170. grouper.call(context, v, k, collection),
  1171. function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); }
  1172. );
  1173. });
  1174. var coerce = collectionClass(collection);
  1175. return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable();
  1176. }
  1177. function sliceFactory(collection, begin, end, useKeys) {
  1178. var originalSize = collection.size;
  1179. if (wholeSlice(begin, end, originalSize)) {
  1180. return collection;
  1181. }
  1182. var resolvedBegin = resolveBegin(begin, originalSize);
  1183. var resolvedEnd = resolveEnd(end, originalSize);
  1184. // begin or end will be NaN if they were provided as negative numbers and
  1185. // this collection's size is unknown. In that case, cache first so there is
  1186. // a known size and these do not resolve to NaN.
  1187. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  1188. return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys);
  1189. }
  1190. // Note: resolvedEnd is undefined when the original sequence's length is
  1191. // unknown and this slice did not supply an end and should contain all
  1192. // elements after resolvedBegin.
  1193. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  1194. var resolvedSize = resolvedEnd - resolvedBegin;
  1195. var sliceSize;
  1196. if (resolvedSize === resolvedSize) {
  1197. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  1198. }
  1199. var sliceSeq = makeSequence(collection);
  1200. // If collection.size is undefined, the size of the realized sliceSeq is
  1201. // unknown at this point unless the number of items to slice is 0
  1202. sliceSeq.size =
  1203. sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined;
  1204. if (!useKeys && isSeq(collection) && sliceSize >= 0) {
  1205. sliceSeq.get = function(index, notSetValue) {
  1206. index = wrapIndex(this, index);
  1207. return index >= 0 && index < sliceSize
  1208. ? collection.get(index + resolvedBegin, notSetValue)
  1209. : notSetValue;
  1210. };
  1211. }
  1212. sliceSeq.__iterateUncached = function(fn, reverse) {
  1213. var this$1 = this;
  1214. if (sliceSize === 0) {
  1215. return 0;
  1216. }
  1217. if (reverse) {
  1218. return this.cacheResult().__iterate(fn, reverse);
  1219. }
  1220. var skipped = 0;
  1221. var isSkipping = true;
  1222. var iterations = 0;
  1223. collection.__iterate(function (v, k) {
  1224. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  1225. iterations++;
  1226. return (
  1227. fn(v, useKeys ? k : iterations - 1, this$1) !== false &&
  1228. iterations !== sliceSize
  1229. );
  1230. }
  1231. });
  1232. return iterations;
  1233. };
  1234. sliceSeq.__iteratorUncached = function(type, reverse) {
  1235. if (sliceSize !== 0 && reverse) {
  1236. return this.cacheResult().__iterator(type, reverse);
  1237. }
  1238. // Don't bother instantiating parent iterator if taking 0.
  1239. if (sliceSize === 0) {
  1240. return new Iterator(iteratorDone);
  1241. }
  1242. var iterator = collection.__iterator(type, reverse);
  1243. var skipped = 0;
  1244. var iterations = 0;
  1245. return new Iterator(function () {
  1246. while (skipped++ < resolvedBegin) {
  1247. iterator.next();
  1248. }
  1249. if (++iterations > sliceSize) {
  1250. return iteratorDone();
  1251. }
  1252. var step = iterator.next();
  1253. if (useKeys || type === ITERATE_VALUES || step.done) {
  1254. return step;
  1255. }
  1256. if (type === ITERATE_KEYS) {
  1257. return iteratorValue(type, iterations - 1, undefined, step);
  1258. }
  1259. return iteratorValue(type, iterations - 1, step.value[1], step);
  1260. });
  1261. };
  1262. return sliceSeq;
  1263. }
  1264. function takeWhileFactory(collection, predicate, context) {
  1265. var takeSequence = makeSequence(collection);
  1266. takeSequence.__iterateUncached = function(fn, reverse) {
  1267. var this$1 = this;
  1268. if (reverse) {
  1269. return this.cacheResult().__iterate(fn, reverse);
  1270. }
  1271. var iterations = 0;
  1272. collection.__iterate(
  1273. function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); }
  1274. );
  1275. return iterations;
  1276. };
  1277. takeSequence.__iteratorUncached = function(type, reverse) {
  1278. var this$1 = this;
  1279. if (reverse) {
  1280. return this.cacheResult().__iterator(type, reverse);
  1281. }
  1282. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1283. var iterating = true;
  1284. return new Iterator(function () {
  1285. if (!iterating) {
  1286. return iteratorDone();
  1287. }
  1288. var step = iterator.next();
  1289. if (step.done) {
  1290. return step;
  1291. }
  1292. var entry = step.value;
  1293. var k = entry[0];
  1294. var v = entry[1];
  1295. if (!predicate.call(context, v, k, this$1)) {
  1296. iterating = false;
  1297. return iteratorDone();
  1298. }
  1299. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  1300. });
  1301. };
  1302. return takeSequence;
  1303. }
  1304. function skipWhileFactory(collection, predicate, context, useKeys) {
  1305. var skipSequence = makeSequence(collection);
  1306. skipSequence.__iterateUncached = function(fn, reverse) {
  1307. var this$1 = this;
  1308. if (reverse) {
  1309. return this.cacheResult().__iterate(fn, reverse);
  1310. }
  1311. var isSkipping = true;
  1312. var iterations = 0;
  1313. collection.__iterate(function (v, k, c) {
  1314. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  1315. iterations++;
  1316. return fn(v, useKeys ? k : iterations - 1, this$1);
  1317. }
  1318. });
  1319. return iterations;
  1320. };
  1321. skipSequence.__iteratorUncached = function(type, reverse) {
  1322. var this$1 = this;
  1323. if (reverse) {
  1324. return this.cacheResult().__iterator(type, reverse);
  1325. }
  1326. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1327. var skipping = true;
  1328. var iterations = 0;
  1329. return new Iterator(function () {
  1330. var step;
  1331. var k;
  1332. var v;
  1333. do {
  1334. step = iterator.next();
  1335. if (step.done) {
  1336. if (useKeys || type === ITERATE_VALUES) {
  1337. return step;
  1338. }
  1339. if (type === ITERATE_KEYS) {
  1340. return iteratorValue(type, iterations++, undefined, step);
  1341. }
  1342. return iteratorValue(type, iterations++, step.value[1], step);
  1343. }
  1344. var entry = step.value;
  1345. k = entry[0];
  1346. v = entry[1];
  1347. skipping && (skipping = predicate.call(context, v, k, this$1));
  1348. } while (skipping);
  1349. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  1350. });
  1351. };
  1352. return skipSequence;
  1353. }
  1354. function concatFactory(collection, values) {
  1355. var isKeyedCollection = isKeyed(collection);
  1356. var iters = [collection]
  1357. .concat(values)
  1358. .map(function (v) {
  1359. if (!isCollection(v)) {
  1360. v = isKeyedCollection
  1361. ? keyedSeqFromValue(v)
  1362. : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  1363. } else if (isKeyedCollection) {
  1364. v = KeyedCollection(v);
  1365. }
  1366. return v;
  1367. })
  1368. .filter(function (v) { return v.size !== 0; });
  1369. if (iters.length === 0) {
  1370. return collection;
  1371. }
  1372. if (iters.length === 1) {
  1373. var singleton = iters[0];
  1374. if (
  1375. singleton === collection ||
  1376. (isKeyedCollection && isKeyed(singleton)) ||
  1377. (isIndexed(collection) && isIndexed(singleton))
  1378. ) {
  1379. return singleton;
  1380. }
  1381. }
  1382. var concatSeq = new ArraySeq(iters);
  1383. if (isKeyedCollection) {
  1384. concatSeq = concatSeq.toKeyedSeq();
  1385. } else if (!isIndexed(collection)) {
  1386. concatSeq = concatSeq.toSetSeq();
  1387. }
  1388. concatSeq = concatSeq.flatten(true);
  1389. concatSeq.size = iters.reduce(function (sum, seq) {
  1390. if (sum !== undefined) {
  1391. var size = seq.size;
  1392. if (size !== undefined) {
  1393. return sum + size;
  1394. }
  1395. }
  1396. }, 0);
  1397. return concatSeq;
  1398. }
  1399. function flattenFactory(collection, depth, useKeys) {
  1400. var flatSequence = makeSequence(collection);
  1401. flatSequence.__iterateUncached = function(fn, reverse) {
  1402. if (reverse) {
  1403. return this.cacheResult().__iterate(fn, reverse);
  1404. }
  1405. var iterations = 0;
  1406. var stopped = false;
  1407. function flatDeep(iter, currentDepth) {
  1408. iter.__iterate(function (v, k) {
  1409. if ((!depth || currentDepth < depth) && isCollection(v)) {
  1410. flatDeep(v, currentDepth + 1);
  1411. } else {
  1412. iterations++;
  1413. if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) {
  1414. stopped = true;
  1415. }
  1416. }
  1417. return !stopped;
  1418. }, reverse);
  1419. }
  1420. flatDeep(collection, 0);
  1421. return iterations;
  1422. };
  1423. flatSequence.__iteratorUncached = function(type, reverse) {
  1424. if (reverse) {
  1425. return this.cacheResult().__iterator(type, reverse);
  1426. }
  1427. var iterator = collection.__iterator(type, reverse);
  1428. var stack = [];
  1429. var iterations = 0;
  1430. return new Iterator(function () {
  1431. while (iterator) {
  1432. var step = iterator.next();
  1433. if (step.done !== false) {
  1434. iterator = stack.pop();
  1435. continue;
  1436. }
  1437. var v = step.value;
  1438. if (type === ITERATE_ENTRIES) {
  1439. v = v[1];
  1440. }
  1441. if ((!depth || stack.length < depth) && isCollection(v)) {
  1442. stack.push(iterator);
  1443. iterator = v.__iterator(type, reverse);
  1444. } else {
  1445. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  1446. }
  1447. }
  1448. return iteratorDone();
  1449. });
  1450. };
  1451. return flatSequence;
  1452. }
  1453. function flatMapFactory(collection, mapper, context) {
  1454. var coerce = collectionClass(collection);
  1455. return collection
  1456. .toSeq()
  1457. .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); })
  1458. .flatten(true);
  1459. }
  1460. function interposeFactory(collection, separator) {
  1461. var interposedSequence = makeSequence(collection);
  1462. interposedSequence.size = collection.size && collection.size * 2 - 1;
  1463. interposedSequence.__iterateUncached = function(fn, reverse) {
  1464. var this$1 = this;
  1465. var iterations = 0;
  1466. collection.__iterate(
  1467. function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) &&
  1468. fn(v, iterations++, this$1) !== false; },
  1469. reverse
  1470. );
  1471. return iterations;
  1472. };
  1473. interposedSequence.__iteratorUncached = function(type, reverse) {
  1474. var iterator = collection.__iterator(ITERATE_VALUES, reverse);
  1475. var iterations = 0;
  1476. var step;
  1477. return new Iterator(function () {
  1478. if (!step || iterations % 2) {
  1479. step = iterator.next();
  1480. if (step.done) {
  1481. return step;
  1482. }
  1483. }
  1484. return iterations % 2
  1485. ? iteratorValue(type, iterations++, separator)
  1486. : iteratorValue(type, iterations++, step.value, step);
  1487. });
  1488. };
  1489. return interposedSequence;
  1490. }
  1491. function sortFactory(collection, comparator, mapper) {
  1492. if (!comparator) {
  1493. comparator = defaultComparator;
  1494. }
  1495. var isKeyedCollection = isKeyed(collection);
  1496. var index = 0;
  1497. var entries = collection
  1498. .toSeq()
  1499. .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; })
  1500. .valueSeq()
  1501. .toArray();
  1502. entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach(
  1503. isKeyedCollection
  1504. ? function (v, i) {
  1505. entries[i].length = 2;
  1506. }
  1507. : function (v, i) {
  1508. entries[i] = v[1];
  1509. }
  1510. );
  1511. return isKeyedCollection
  1512. ? KeyedSeq(entries)
  1513. : isIndexed(collection)
  1514. ? IndexedSeq(entries)
  1515. : SetSeq(entries);
  1516. }
  1517. function maxFactory(collection, comparator, mapper) {
  1518. if (!comparator) {
  1519. comparator = defaultComparator;
  1520. }
  1521. if (mapper) {
  1522. var entry = collection
  1523. .toSeq()
  1524. .map(function (v, k) { return [v, mapper(v, k, collection)]; })
  1525. .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); });
  1526. return entry && entry[0];
  1527. }
  1528. return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); });
  1529. }
  1530. function maxCompare(comparator, a, b) {
  1531. var comp = comparator(b, a);
  1532. // b is considered the new max if the comparator declares them equal, but
  1533. // they are not equal and b is in fact a nullish value.
  1534. return (
  1535. (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
  1536. comp > 0
  1537. );
  1538. }
  1539. function zipWithFactory(keyIter, zipper, iters, zipAll) {
  1540. var zipSequence = makeSequence(keyIter);
  1541. var sizes = new ArraySeq(iters).map(function (i) { return i.size; });
  1542. zipSequence.size = zipAll ? sizes.max() : sizes.min();
  1543. // Note: this a generic base implementation of __iterate in terms of
  1544. // __iterator which may be more generically useful in the future.
  1545. zipSequence.__iterate = function(fn, reverse) {
  1546. /* generic:
  1547. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  1548. var step;
  1549. var iterations = 0;
  1550. while (!(step = iterator.next()).done) {
  1551. iterations++;
  1552. if (fn(step.value[1], step.value[0], this) === false) {
  1553. break;
  1554. }
  1555. }
  1556. return iterations;
  1557. */
  1558. // indexed:
  1559. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  1560. var step;
  1561. var iterations = 0;
  1562. while (!(step = iterator.next()).done) {
  1563. if (fn(step.value, iterations++, this) === false) {
  1564. break;
  1565. }
  1566. }
  1567. return iterations;
  1568. };
  1569. zipSequence.__iteratorUncached = function(type, reverse) {
  1570. var iterators = iters.map(
  1571. function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); }
  1572. );
  1573. var iterations = 0;
  1574. var isDone = false;
  1575. return new Iterator(function () {
  1576. var steps;
  1577. if (!isDone) {
  1578. steps = iterators.map(function (i) { return i.next(); });
  1579. isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; });
  1580. }
  1581. if (isDone) {
  1582. return iteratorDone();
  1583. }
  1584. return iteratorValue(
  1585. type,
  1586. iterations++,
  1587. zipper.apply(null, steps.map(function (s) { return s.value; }))
  1588. );
  1589. });
  1590. };
  1591. return zipSequence;
  1592. }
  1593. // #pragma Helper Functions
  1594. function reify(iter, seq) {
  1595. return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq);
  1596. }
  1597. function validateEntry(entry) {
  1598. if (entry !== Object(entry)) {
  1599. throw new TypeError('Expected [K, V] tuple: ' + entry);
  1600. }
  1601. }
  1602. function collectionClass(collection) {
  1603. return isKeyed(collection)
  1604. ? KeyedCollection
  1605. : isIndexed(collection)
  1606. ? IndexedCollection
  1607. : SetCollection;
  1608. }
  1609. function makeSequence(collection) {
  1610. return Object.create(
  1611. (isKeyed(collection)
  1612. ? KeyedSeq
  1613. : isIndexed(collection)
  1614. ? IndexedSeq
  1615. : SetSeq
  1616. ).prototype
  1617. );
  1618. }
  1619. function cacheResultThrough() {
  1620. if (this._iter.cacheResult) {
  1621. this._iter.cacheResult();
  1622. this.size = this._iter.size;
  1623. return this;
  1624. }
  1625. return Seq.prototype.cacheResult.call(this);
  1626. }
  1627. function defaultComparator(a, b) {
  1628. if (a === undefined && b === undefined) {
  1629. return 0;
  1630. }
  1631. if (a === undefined) {
  1632. return 1;
  1633. }
  1634. if (b === undefined) {
  1635. return -1;
  1636. }
  1637. return a > b ? 1 : a < b ? -1 : 0;
  1638. }
  1639. // http://jsperf.com/copy-array-inline
  1640. function arrCopy(arr, offset) {
  1641. offset = offset || 0;
  1642. var len = Math.max(0, arr.length - offset);
  1643. var newArr = new Array(len);
  1644. for (var ii = 0; ii < len; ii++) {
  1645. newArr[ii] = arr[ii + offset];
  1646. }
  1647. return newArr;
  1648. }
  1649. function invariant(condition, error) {
  1650. if (!condition) { throw new Error(error); }
  1651. }
  1652. function assertNotInfinite(size) {
  1653. invariant(
  1654. size !== Infinity,
  1655. 'Cannot perform this action with an infinite size.'
  1656. );
  1657. }
  1658. function coerceKeyPath(keyPath) {
  1659. if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
  1660. return keyPath;
  1661. }
  1662. if (isOrdered(keyPath)) {
  1663. return keyPath.toArray();
  1664. }
  1665. throw new TypeError(
  1666. 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath
  1667. );
  1668. }
  1669. function isPlainObj(value) {
  1670. return (
  1671. value &&
  1672. (typeof value.constructor !== 'function' ||
  1673. value.constructor.name === 'Object')
  1674. );
  1675. }
  1676. /**
  1677. * Returns true if the value is a potentially-persistent data structure, either
  1678. * provided by Immutable.js or a plain Array or Object.
  1679. */
  1680. function isDataStructure(value) {
  1681. return (
  1682. typeof value === 'object' &&
  1683. (isImmutable(value) || Array.isArray(value) || isPlainObj(value))
  1684. );
  1685. }
  1686. /**
  1687. * Converts a value to a string, adding quotes if a string was provided.
  1688. */
  1689. function quoteString(value) {
  1690. try {
  1691. return typeof value === 'string' ? JSON.stringify(value) : String(value);
  1692. } catch (_ignoreError) {
  1693. return JSON.stringify(value);
  1694. }
  1695. }
  1696. function has(collection, key) {
  1697. return isImmutable(collection)
  1698. ? collection.has(key)
  1699. : isDataStructure(collection) && hasOwnProperty.call(collection, key);
  1700. }
  1701. function get(collection, key, notSetValue) {
  1702. return isImmutable(collection)
  1703. ? collection.get(key, notSetValue)
  1704. : !has(collection, key)
  1705. ? notSetValue
  1706. : typeof collection.get === 'function'
  1707. ? collection.get(key)
  1708. : collection[key];
  1709. }
  1710. function shallowCopy(from) {
  1711. if (Array.isArray(from)) {
  1712. return arrCopy(from);
  1713. }
  1714. var to = {};
  1715. for (var key in from) {
  1716. if (hasOwnProperty.call(from, key)) {
  1717. to[key] = from[key];
  1718. }
  1719. }
  1720. return to;
  1721. }
  1722. function remove(collection, key) {
  1723. if (!isDataStructure(collection)) {
  1724. throw new TypeError(
  1725. 'Cannot update non-data-structure value: ' + collection
  1726. );
  1727. }
  1728. if (isImmutable(collection)) {
  1729. if (!collection.remove) {
  1730. throw new TypeError(
  1731. 'Cannot update immutable value without .remove() method: ' + collection
  1732. );
  1733. }
  1734. return collection.remove(key);
  1735. }
  1736. if (!hasOwnProperty.call(collection, key)) {
  1737. return collection;
  1738. }
  1739. var collectionCopy = shallowCopy(collection);
  1740. if (Array.isArray(collectionCopy)) {
  1741. collectionCopy.splice(key, 1);
  1742. } else {
  1743. delete collectionCopy[key];
  1744. }
  1745. return collectionCopy;
  1746. }
  1747. function set(collection, key, value) {
  1748. if (!isDataStructure(collection)) {
  1749. throw new TypeError(
  1750. 'Cannot update non-data-structure value: ' + collection
  1751. );
  1752. }
  1753. if (isImmutable(collection)) {
  1754. if (!collection.set) {
  1755. throw new TypeError(
  1756. 'Cannot update immutable value without .set() method: ' + collection
  1757. );
  1758. }
  1759. return collection.set(key, value);
  1760. }
  1761. if (hasOwnProperty.call(collection, key) && value === collection[key]) {
  1762. return collection;
  1763. }
  1764. var collectionCopy = shallowCopy(collection);
  1765. collectionCopy[key] = value;
  1766. return collectionCopy;
  1767. }
  1768. function updateIn(collection, keyPath, notSetValue, updater) {
  1769. if (!updater) {
  1770. updater = notSetValue;
  1771. notSetValue = undefined;
  1772. }
  1773. var updatedValue = updateInDeeply(
  1774. isImmutable(collection),
  1775. collection,
  1776. coerceKeyPath(keyPath),
  1777. 0,
  1778. notSetValue,
  1779. updater
  1780. );
  1781. return updatedValue === NOT_SET ? notSetValue : updatedValue;
  1782. }
  1783. function updateInDeeply(
  1784. inImmutable,
  1785. existing,
  1786. keyPath,
  1787. i,
  1788. notSetValue,
  1789. updater
  1790. ) {
  1791. var wasNotSet = existing === NOT_SET;
  1792. if (i === keyPath.length) {
  1793. var existingValue = wasNotSet ? notSetValue : existing;
  1794. var newValue = updater(existingValue);
  1795. return newValue === existingValue ? existing : newValue;
  1796. }
  1797. if (!wasNotSet && !isDataStructure(existing)) {
  1798. throw new TypeError(
  1799. 'Cannot update within non-data-structure value in path [' +
  1800. keyPath.slice(0, i).map(quoteString) +
  1801. ']: ' +
  1802. existing
  1803. );
  1804. }
  1805. var key = keyPath[i];
  1806. var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
  1807. var nextUpdated = updateInDeeply(
  1808. nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
  1809. nextExisting,
  1810. keyPath,
  1811. i + 1,
  1812. notSetValue,
  1813. updater
  1814. );
  1815. return nextUpdated === nextExisting
  1816. ? existing
  1817. : nextUpdated === NOT_SET
  1818. ? remove(existing, key)
  1819. : set(
  1820. wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
  1821. key,
  1822. nextUpdated
  1823. );
  1824. }
  1825. function setIn(collection, keyPath, value) {
  1826. return updateIn(collection, keyPath, NOT_SET, function () { return value; });
  1827. }
  1828. function setIn$1(keyPath, v) {
  1829. return setIn(this, keyPath, v);
  1830. }
  1831. function removeIn(collection, keyPath) {
  1832. return updateIn(collection, keyPath, function () { return NOT_SET; });
  1833. }
  1834. function deleteIn(keyPath) {
  1835. return removeIn(this, keyPath);
  1836. }
  1837. function update(collection, key, notSetValue, updater) {
  1838. return updateIn(collection, [key], notSetValue, updater);
  1839. }
  1840. function update$1(key, notSetValue, updater) {
  1841. return arguments.length === 1
  1842. ? key(this)
  1843. : update(this, key, notSetValue, updater);
  1844. }
  1845. function updateIn$1(keyPath, notSetValue, updater) {
  1846. return updateIn(this, keyPath, notSetValue, updater);
  1847. }
  1848. function merge() {
  1849. var iters = [], len = arguments.length;
  1850. while ( len-- ) iters[ len ] = arguments[ len ];
  1851. return mergeIntoKeyedWith(this, iters);
  1852. }
  1853. function mergeWith(merger) {
  1854. var iters = [], len = arguments.length - 1;
  1855. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  1856. if (typeof merger !== 'function') {
  1857. throw new TypeError('Invalid merger function: ' + merger);
  1858. }
  1859. return mergeIntoKeyedWith(this, iters, merger);
  1860. }
  1861. function mergeIntoKeyedWith(collection, collections, merger) {
  1862. var iters = [];
  1863. for (var ii = 0; ii < collections.length; ii++) {
  1864. var collection$1 = KeyedCollection(collections[ii]);
  1865. if (collection$1.size !== 0) {
  1866. iters.push(collection$1);
  1867. }
  1868. }
  1869. if (iters.length === 0) {
  1870. return collection;
  1871. }
  1872. if (
  1873. collection.toSeq().size === 0 &&
  1874. !collection.__ownerID &&
  1875. iters.length === 1
  1876. ) {
  1877. return collection.constructor(iters[0]);
  1878. }
  1879. return collection.withMutations(function (collection) {
  1880. var mergeIntoCollection = merger
  1881. ? function (value, key) {
  1882. update(
  1883. collection,
  1884. key,
  1885. NOT_SET,
  1886. function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); }
  1887. );
  1888. }
  1889. : function (value, key) {
  1890. collection.set(key, value);
  1891. };
  1892. for (var ii = 0; ii < iters.length; ii++) {
  1893. iters[ii].forEach(mergeIntoCollection);
  1894. }
  1895. });
  1896. }
  1897. function merge$1(collection) {
  1898. var sources = [], len = arguments.length - 1;
  1899. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  1900. return mergeWithSources(collection, sources);
  1901. }
  1902. function mergeWith$1(merger, collection) {
  1903. var sources = [], len = arguments.length - 2;
  1904. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  1905. return mergeWithSources(collection, sources, merger);
  1906. }
  1907. function mergeDeep(collection) {
  1908. var sources = [], len = arguments.length - 1;
  1909. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  1910. return mergeDeepWithSources(collection, sources);
  1911. }
  1912. function mergeDeepWith(merger, collection) {
  1913. var sources = [], len = arguments.length - 2;
  1914. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  1915. return mergeDeepWithSources(collection, sources, merger);
  1916. }
  1917. function mergeDeepWithSources(collection, sources, merger) {
  1918. return mergeWithSources(collection, sources, deepMergerWith(merger));
  1919. }
  1920. function mergeWithSources(collection, sources, merger) {
  1921. if (!isDataStructure(collection)) {
  1922. throw new TypeError(
  1923. 'Cannot merge into non-data-structure value: ' + collection
  1924. );
  1925. }
  1926. if (isImmutable(collection)) {
  1927. return typeof merger === 'function' && collection.mergeWith
  1928. ? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
  1929. : collection.merge
  1930. ? collection.merge.apply(collection, sources)
  1931. : collection.concat.apply(collection, sources);
  1932. }
  1933. var isArray = Array.isArray(collection);
  1934. var merged = collection;
  1935. var Collection$$1 = isArray ? IndexedCollection : KeyedCollection;
  1936. var mergeItem = isArray
  1937. ? function (value) {
  1938. // Copy on write
  1939. if (merged === collection) {
  1940. merged = shallowCopy(merged);
  1941. }
  1942. merged.push(value);
  1943. }
  1944. : function (value, key) {
  1945. var hasVal = hasOwnProperty.call(merged, key);
  1946. var nextVal =
  1947. hasVal && merger ? merger(merged[key], value, key) : value;
  1948. if (!hasVal || nextVal !== merged[key]) {
  1949. // Copy on write
  1950. if (merged === collection) {
  1951. merged = shallowCopy(merged);
  1952. }
  1953. merged[key] = nextVal;
  1954. }
  1955. };
  1956. for (var i = 0; i < sources.length; i++) {
  1957. Collection$$1(sources[i]).forEach(mergeItem);
  1958. }
  1959. return merged;
  1960. }
  1961. function deepMergerWith(merger) {
  1962. function deepMerger(oldValue, newValue, key) {
  1963. return isDataStructure(oldValue) && isDataStructure(newValue)
  1964. ? mergeWithSources(oldValue, [newValue], deepMerger)
  1965. : merger
  1966. ? merger(oldValue, newValue, key)
  1967. : newValue;
  1968. }
  1969. return deepMerger;
  1970. }
  1971. function mergeDeep$1() {
  1972. var iters = [], len = arguments.length;
  1973. while ( len-- ) iters[ len ] = arguments[ len ];
  1974. return mergeDeepWithSources(this, iters);
  1975. }
  1976. function mergeDeepWith$1(merger) {
  1977. var iters = [], len = arguments.length - 1;
  1978. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  1979. return mergeDeepWithSources(this, iters, merger);
  1980. }
  1981. function mergeIn(keyPath) {
  1982. var iters = [], len = arguments.length - 1;
  1983. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  1984. return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); });
  1985. }
  1986. function mergeDeepIn(keyPath) {
  1987. var iters = [], len = arguments.length - 1;
  1988. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  1989. return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); }
  1990. );
  1991. }
  1992. function withMutations(fn) {
  1993. var mutable = this.asMutable();
  1994. fn(mutable);
  1995. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  1996. }
  1997. function asMutable() {
  1998. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  1999. }
  2000. function asImmutable() {
  2001. return this.__ensureOwner();
  2002. }
  2003. function wasAltered() {
  2004. return this.__altered;
  2005. }
  2006. var Map = /*@__PURE__*/(function (KeyedCollection$$1) {
  2007. function Map(value) {
  2008. return value === null || value === undefined
  2009. ? emptyMap()
  2010. : isMap(value) && !isOrdered(value)
  2011. ? value
  2012. : emptyMap().withMutations(function (map) {
  2013. var iter = KeyedCollection$$1(value);
  2014. assertNotInfinite(iter.size);
  2015. iter.forEach(function (v, k) { return map.set(k, v); });
  2016. });
  2017. }
  2018. if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1;
  2019. Map.prototype = Object.create( KeyedCollection$$1 && KeyedCollection$$1.prototype );
  2020. Map.prototype.constructor = Map;
  2021. Map.of = function of () {
  2022. var keyValues = [], len = arguments.length;
  2023. while ( len-- ) keyValues[ len ] = arguments[ len ];
  2024. return emptyMap().withMutations(function (map) {
  2025. for (var i = 0; i < keyValues.length; i += 2) {
  2026. if (i + 1 >= keyValues.length) {
  2027. throw new Error('Missing value for key: ' + keyValues[i]);
  2028. }
  2029. map.set(keyValues[i], keyValues[i + 1]);
  2030. }
  2031. });
  2032. };
  2033. Map.prototype.toString = function toString () {
  2034. return this.__toString('Map {', '}');
  2035. };
  2036. // @pragma Access
  2037. Map.prototype.get = function get (k, notSetValue) {
  2038. return this._root
  2039. ? this._root.get(0, undefined, k, notSetValue)
  2040. : notSetValue;
  2041. };
  2042. // @pragma Modification
  2043. Map.prototype.set = function set (k, v) {
  2044. return updateMap(this, k, v);
  2045. };
  2046. Map.prototype.remove = function remove (k) {
  2047. return updateMap(this, k, NOT_SET);
  2048. };
  2049. Map.prototype.deleteAll = function deleteAll (keys) {
  2050. var collection = Collection(keys);
  2051. if (collection.size === 0) {
  2052. return this;
  2053. }
  2054. return this.withMutations(function (map) {
  2055. collection.forEach(function (key) { return map.remove(key); });
  2056. });
  2057. };
  2058. Map.prototype.clear = function clear () {
  2059. if (this.size === 0) {
  2060. return this;
  2061. }
  2062. if (this.__ownerID) {
  2063. this.size = 0;
  2064. this._root = null;
  2065. this.__hash = undefined;
  2066. this.__altered = true;
  2067. return this;
  2068. }
  2069. return emptyMap();
  2070. };
  2071. // @pragma Composition
  2072. Map.prototype.sort = function sort (comparator) {
  2073. // Late binding
  2074. return OrderedMap(sortFactory(this, comparator));
  2075. };
  2076. Map.prototype.sortBy = function sortBy (mapper, comparator) {
  2077. // Late binding
  2078. return OrderedMap(sortFactory(this, comparator, mapper));
  2079. };
  2080. Map.prototype.map = function map (mapper, context) {
  2081. return this.withMutations(function (map) {
  2082. map.forEach(function (value, key) {
  2083. map.set(key, mapper.call(context, value, key, map));
  2084. });
  2085. });
  2086. };
  2087. // @pragma Mutability
  2088. Map.prototype.__iterator = function __iterator (type, reverse) {
  2089. return new MapIterator(this, type, reverse);
  2090. };
  2091. Map.prototype.__iterate = function __iterate (fn, reverse) {
  2092. var this$1 = this;
  2093. var iterations = 0;
  2094. this._root &&
  2095. this._root.iterate(function (entry) {
  2096. iterations++;
  2097. return fn(entry[1], entry[0], this$1);
  2098. }, reverse);
  2099. return iterations;
  2100. };
  2101. Map.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  2102. if (ownerID === this.__ownerID) {
  2103. return this;
  2104. }
  2105. if (!ownerID) {
  2106. if (this.size === 0) {
  2107. return emptyMap();
  2108. }
  2109. this.__ownerID = ownerID;
  2110. this.__altered = false;
  2111. return this;
  2112. }
  2113. return makeMap(this.size, this._root, ownerID, this.__hash);
  2114. };
  2115. return Map;
  2116. }(KeyedCollection));
  2117. Map.isMap = isMap;
  2118. var MapPrototype = Map.prototype;
  2119. MapPrototype[IS_MAP_SYMBOL] = true;
  2120. MapPrototype[DELETE] = MapPrototype.remove;
  2121. MapPrototype.removeAll = MapPrototype.deleteAll;
  2122. MapPrototype.setIn = setIn$1;
  2123. MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
  2124. MapPrototype.update = update$1;
  2125. MapPrototype.updateIn = updateIn$1;
  2126. MapPrototype.merge = MapPrototype.concat = merge;
  2127. MapPrototype.mergeWith = mergeWith;
  2128. MapPrototype.mergeDeep = mergeDeep$1;
  2129. MapPrototype.mergeDeepWith = mergeDeepWith$1;
  2130. MapPrototype.mergeIn = mergeIn;
  2131. MapPrototype.mergeDeepIn = mergeDeepIn;
  2132. MapPrototype.withMutations = withMutations;
  2133. MapPrototype.wasAltered = wasAltered;
  2134. MapPrototype.asImmutable = asImmutable;
  2135. MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable;
  2136. MapPrototype['@@transducer/step'] = function(result, arr) {
  2137. return result.set(arr[0], arr[1]);
  2138. };
  2139. MapPrototype['@@transducer/result'] = function(obj) {
  2140. return obj.asImmutable();
  2141. };
  2142. // #pragma Trie Nodes
  2143. var ArrayMapNode = function ArrayMapNode(ownerID, entries) {
  2144. this.ownerID = ownerID;
  2145. this.entries = entries;
  2146. };
  2147. ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2148. var entries = this.entries;
  2149. for (var ii = 0, len = entries.length; ii < len; ii++) {
  2150. if (is(key, entries[ii][0])) {
  2151. return entries[ii][1];
  2152. }
  2153. }
  2154. return notSetValue;
  2155. };
  2156. ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2157. var removed = value === NOT_SET;
  2158. var entries = this.entries;
  2159. var idx = 0;
  2160. var len = entries.length;
  2161. for (; idx < len; idx++) {
  2162. if (is(key, entries[idx][0])) {
  2163. break;
  2164. }
  2165. }
  2166. var exists = idx < len;
  2167. if (exists ? entries[idx][1] === value : removed) {
  2168. return this;
  2169. }
  2170. SetRef(didAlter);
  2171. (removed || !exists) && SetRef(didChangeSize);
  2172. if (removed && entries.length === 1) {
  2173. return; // undefined
  2174. }
  2175. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  2176. return createNodes(ownerID, entries, key, value);
  2177. }
  2178. var isEditable = ownerID && ownerID === this.ownerID;
  2179. var newEntries = isEditable ? entries : arrCopy(entries);
  2180. if (exists) {
  2181. if (removed) {
  2182. idx === len - 1
  2183. ? newEntries.pop()
  2184. : (newEntries[idx] = newEntries.pop());
  2185. } else {
  2186. newEntries[idx] = [key, value];
  2187. }
  2188. } else {
  2189. newEntries.push([key, value]);
  2190. }
  2191. if (isEditable) {
  2192. this.entries = newEntries;
  2193. return this;
  2194. }
  2195. return new ArrayMapNode(ownerID, newEntries);
  2196. };
  2197. var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) {
  2198. this.ownerID = ownerID;
  2199. this.bitmap = bitmap;
  2200. this.nodes = nodes;
  2201. };
  2202. BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2203. if (keyHash === undefined) {
  2204. keyHash = hash(key);
  2205. }
  2206. var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
  2207. var bitmap = this.bitmap;
  2208. return (bitmap & bit) === 0
  2209. ? notSetValue
  2210. : this.nodes[popCount(bitmap & (bit - 1))].get(
  2211. shift + SHIFT,
  2212. keyHash,
  2213. key,
  2214. notSetValue
  2215. );
  2216. };
  2217. BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2218. if (keyHash === undefined) {
  2219. keyHash = hash(key);
  2220. }
  2221. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2222. var bit = 1 << keyHashFrag;
  2223. var bitmap = this.bitmap;
  2224. var exists = (bitmap & bit) !== 0;
  2225. if (!exists && value === NOT_SET) {
  2226. return this;
  2227. }
  2228. var idx = popCount(bitmap & (bit - 1));
  2229. var nodes = this.nodes;
  2230. var node = exists ? nodes[idx] : undefined;
  2231. var newNode = updateNode(
  2232. node,
  2233. ownerID,
  2234. shift + SHIFT,
  2235. keyHash,
  2236. key,
  2237. value,
  2238. didChangeSize,
  2239. didAlter
  2240. );
  2241. if (newNode === node) {
  2242. return this;
  2243. }
  2244. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  2245. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  2246. }
  2247. if (
  2248. exists &&
  2249. !newNode &&
  2250. nodes.length === 2 &&
  2251. isLeafNode(nodes[idx ^ 1])
  2252. ) {
  2253. return nodes[idx ^ 1];
  2254. }
  2255. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  2256. return newNode;
  2257. }
  2258. var isEditable = ownerID && ownerID === this.ownerID;
  2259. var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
  2260. var newNodes = exists
  2261. ? newNode
  2262. ? setAt(nodes, idx, newNode, isEditable)
  2263. : spliceOut(nodes, idx, isEditable)
  2264. : spliceIn(nodes, idx, newNode, isEditable);
  2265. if (isEditable) {
  2266. this.bitmap = newBitmap;
  2267. this.nodes = newNodes;
  2268. return this;
  2269. }
  2270. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  2271. };
  2272. var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) {
  2273. this.ownerID = ownerID;
  2274. this.count = count;
  2275. this.nodes = nodes;
  2276. };
  2277. HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2278. if (keyHash === undefined) {
  2279. keyHash = hash(key);
  2280. }
  2281. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2282. var node = this.nodes[idx];
  2283. return node
  2284. ? node.get(shift + SHIFT, keyHash, key, notSetValue)
  2285. : notSetValue;
  2286. };
  2287. HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2288. if (keyHash === undefined) {
  2289. keyHash = hash(key);
  2290. }
  2291. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2292. var removed = value === NOT_SET;
  2293. var nodes = this.nodes;
  2294. var node = nodes[idx];
  2295. if (removed && !node) {
  2296. return this;
  2297. }
  2298. var newNode = updateNode(
  2299. node,
  2300. ownerID,
  2301. shift + SHIFT,
  2302. keyHash,
  2303. key,
  2304. value,
  2305. didChangeSize,
  2306. didAlter
  2307. );
  2308. if (newNode === node) {
  2309. return this;
  2310. }
  2311. var newCount = this.count;
  2312. if (!node) {
  2313. newCount++;
  2314. } else if (!newNode) {
  2315. newCount--;
  2316. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  2317. return packNodes(ownerID, nodes, newCount, idx);
  2318. }
  2319. }
  2320. var isEditable = ownerID && ownerID === this.ownerID;
  2321. var newNodes = setAt(nodes, idx, newNode, isEditable);
  2322. if (isEditable) {
  2323. this.count = newCount;
  2324. this.nodes = newNodes;
  2325. return this;
  2326. }
  2327. return new HashArrayMapNode(ownerID, newCount, newNodes);
  2328. };
  2329. var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) {
  2330. this.ownerID = ownerID;
  2331. this.keyHash = keyHash;
  2332. this.entries = entries;
  2333. };
  2334. HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2335. var entries = this.entries;
  2336. for (var ii = 0, len = entries.length; ii < len; ii++) {
  2337. if (is(key, entries[ii][0])) {
  2338. return entries[ii][1];
  2339. }
  2340. }
  2341. return notSetValue;
  2342. };
  2343. HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2344. if (keyHash === undefined) {
  2345. keyHash = hash(key);
  2346. }
  2347. var removed = value === NOT_SET;
  2348. if (keyHash !== this.keyHash) {
  2349. if (removed) {
  2350. return this;
  2351. }
  2352. SetRef(didAlter);
  2353. SetRef(didChangeSize);
  2354. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  2355. }
  2356. var entries = this.entries;
  2357. var idx = 0;
  2358. var len = entries.length;
  2359. for (; idx < len; idx++) {
  2360. if (is(key, entries[idx][0])) {
  2361. break;
  2362. }
  2363. }
  2364. var exists = idx < len;
  2365. if (exists ? entries[idx][1] === value : removed) {
  2366. return this;
  2367. }
  2368. SetRef(didAlter);
  2369. (removed || !exists) && SetRef(didChangeSize);
  2370. if (removed && len === 2) {
  2371. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  2372. }
  2373. var isEditable = ownerID && ownerID === this.ownerID;
  2374. var newEntries = isEditable ? entries : arrCopy(entries);
  2375. if (exists) {
  2376. if (removed) {
  2377. idx === len - 1
  2378. ? newEntries.pop()
  2379. : (newEntries[idx] = newEntries.pop());
  2380. } else {
  2381. newEntries[idx] = [key, value];
  2382. }
  2383. } else {
  2384. newEntries.push([key, value]);
  2385. }
  2386. if (isEditable) {
  2387. this.entries = newEntries;
  2388. return this;
  2389. }
  2390. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  2391. };
  2392. var ValueNode = function ValueNode(ownerID, keyHash, entry) {
  2393. this.ownerID = ownerID;
  2394. this.keyHash = keyHash;
  2395. this.entry = entry;
  2396. };
  2397. ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2398. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  2399. };
  2400. ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2401. var removed = value === NOT_SET;
  2402. var keyMatch = is(key, this.entry[0]);
  2403. if (keyMatch ? value === this.entry[1] : removed) {
  2404. return this;
  2405. }
  2406. SetRef(didAlter);
  2407. if (removed) {
  2408. SetRef(didChangeSize);
  2409. return; // undefined
  2410. }
  2411. if (keyMatch) {
  2412. if (ownerID && ownerID === this.ownerID) {
  2413. this.entry[1] = value;
  2414. return this;
  2415. }
  2416. return new ValueNode(ownerID, this.keyHash, [key, value]);
  2417. }
  2418. SetRef(didChangeSize);
  2419. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  2420. };
  2421. // #pragma Iterators
  2422. ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(
  2423. fn,
  2424. reverse
  2425. ) {
  2426. var entries = this.entries;
  2427. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  2428. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  2429. return false;
  2430. }
  2431. }
  2432. };
  2433. BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(
  2434. fn,
  2435. reverse
  2436. ) {
  2437. var nodes = this.nodes;
  2438. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  2439. var node = nodes[reverse ? maxIndex - ii : ii];
  2440. if (node && node.iterate(fn, reverse) === false) {
  2441. return false;
  2442. }
  2443. }
  2444. };
  2445. // eslint-disable-next-line no-unused-vars
  2446. ValueNode.prototype.iterate = function(fn, reverse) {
  2447. return fn(this.entry);
  2448. };
  2449. var MapIterator = /*@__PURE__*/(function (Iterator$$1) {
  2450. function MapIterator(map, type, reverse) {
  2451. this._type = type;
  2452. this._reverse = reverse;
  2453. this._stack = map._root && mapIteratorFrame(map._root);
  2454. }
  2455. if ( Iterator$$1 ) MapIterator.__proto__ = Iterator$$1;
  2456. MapIterator.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype );
  2457. MapIterator.prototype.constructor = MapIterator;
  2458. MapIterator.prototype.next = function next () {
  2459. var type = this._type;
  2460. var stack = this._stack;
  2461. while (stack) {
  2462. var node = stack.node;
  2463. var index = stack.index++;
  2464. var maxIndex = (void 0);
  2465. if (node.entry) {
  2466. if (index === 0) {
  2467. return mapIteratorValue(type, node.entry);
  2468. }
  2469. } else if (node.entries) {
  2470. maxIndex = node.entries.length - 1;
  2471. if (index <= maxIndex) {
  2472. return mapIteratorValue(
  2473. type,
  2474. node.entries[this._reverse ? maxIndex - index : index]
  2475. );
  2476. }
  2477. } else {
  2478. maxIndex = node.nodes.length - 1;
  2479. if (index <= maxIndex) {
  2480. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  2481. if (subNode) {
  2482. if (subNode.entry) {
  2483. return mapIteratorValue(type, subNode.entry);
  2484. }
  2485. stack = this._stack = mapIteratorFrame(subNode, stack);
  2486. }
  2487. continue;
  2488. }
  2489. }
  2490. stack = this._stack = this._stack.__prev;
  2491. }
  2492. return iteratorDone();
  2493. };
  2494. return MapIterator;
  2495. }(Iterator));
  2496. function mapIteratorValue(type, entry) {
  2497. return iteratorValue(type, entry[0], entry[1]);
  2498. }
  2499. function mapIteratorFrame(node, prev) {
  2500. return {
  2501. node: node,
  2502. index: 0,
  2503. __prev: prev,
  2504. };
  2505. }
  2506. function makeMap(size, root, ownerID, hash$$1) {
  2507. var map = Object.create(MapPrototype);
  2508. map.size = size;
  2509. map._root = root;
  2510. map.__ownerID = ownerID;
  2511. map.__hash = hash$$1;
  2512. map.__altered = false;
  2513. return map;
  2514. }
  2515. var EMPTY_MAP;
  2516. function emptyMap() {
  2517. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  2518. }
  2519. function updateMap(map, k, v) {
  2520. var newRoot;
  2521. var newSize;
  2522. if (!map._root) {
  2523. if (v === NOT_SET) {
  2524. return map;
  2525. }
  2526. newSize = 1;
  2527. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  2528. } else {
  2529. var didChangeSize = MakeRef();
  2530. var didAlter = MakeRef();
  2531. newRoot = updateNode(
  2532. map._root,
  2533. map.__ownerID,
  2534. 0,
  2535. undefined,
  2536. k,
  2537. v,
  2538. didChangeSize,
  2539. didAlter
  2540. );
  2541. if (!didAlter.value) {
  2542. return map;
  2543. }
  2544. newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
  2545. }
  2546. if (map.__ownerID) {
  2547. map.size = newSize;
  2548. map._root = newRoot;
  2549. map.__hash = undefined;
  2550. map.__altered = true;
  2551. return map;
  2552. }
  2553. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  2554. }
  2555. function updateNode(
  2556. node,
  2557. ownerID,
  2558. shift,
  2559. keyHash,
  2560. key,
  2561. value,
  2562. didChangeSize,
  2563. didAlter
  2564. ) {
  2565. if (!node) {
  2566. if (value === NOT_SET) {
  2567. return node;
  2568. }
  2569. SetRef(didAlter);
  2570. SetRef(didChangeSize);
  2571. return new ValueNode(ownerID, keyHash, [key, value]);
  2572. }
  2573. return node.update(
  2574. ownerID,
  2575. shift,
  2576. keyHash,
  2577. key,
  2578. value,
  2579. didChangeSize,
  2580. didAlter
  2581. );
  2582. }
  2583. function isLeafNode(node) {
  2584. return (
  2585. node.constructor === ValueNode || node.constructor === HashCollisionNode
  2586. );
  2587. }
  2588. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  2589. if (node.keyHash === keyHash) {
  2590. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  2591. }
  2592. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  2593. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2594. var newNode;
  2595. var nodes =
  2596. idx1 === idx2
  2597. ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
  2598. : ((newNode = new ValueNode(ownerID, keyHash, entry)),
  2599. idx1 < idx2 ? [node, newNode] : [newNode, node]);
  2600. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  2601. }
  2602. function createNodes(ownerID, entries, key, value) {
  2603. if (!ownerID) {
  2604. ownerID = new OwnerID();
  2605. }
  2606. var node = new ValueNode(ownerID, hash(key), [key, value]);
  2607. for (var ii = 0; ii < entries.length; ii++) {
  2608. var entry = entries[ii];
  2609. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  2610. }
  2611. return node;
  2612. }
  2613. function packNodes(ownerID, nodes, count, excluding) {
  2614. var bitmap = 0;
  2615. var packedII = 0;
  2616. var packedNodes = new Array(count);
  2617. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  2618. var node = nodes[ii];
  2619. if (node !== undefined && ii !== excluding) {
  2620. bitmap |= bit;
  2621. packedNodes[packedII++] = node;
  2622. }
  2623. }
  2624. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  2625. }
  2626. function expandNodes(ownerID, nodes, bitmap, including, node) {
  2627. var count = 0;
  2628. var expandedNodes = new Array(SIZE);
  2629. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  2630. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  2631. }
  2632. expandedNodes[including] = node;
  2633. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  2634. }
  2635. function popCount(x) {
  2636. x -= (x >> 1) & 0x55555555;
  2637. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  2638. x = (x + (x >> 4)) & 0x0f0f0f0f;
  2639. x += x >> 8;
  2640. x += x >> 16;
  2641. return x & 0x7f;
  2642. }
  2643. function setAt(array, idx, val, canEdit) {
  2644. var newArray = canEdit ? array : arrCopy(array);
  2645. newArray[idx] = val;
  2646. return newArray;
  2647. }
  2648. function spliceIn(array, idx, val, canEdit) {
  2649. var newLen = array.length + 1;
  2650. if (canEdit && idx + 1 === newLen) {
  2651. array[idx] = val;
  2652. return array;
  2653. }
  2654. var newArray = new Array(newLen);
  2655. var after = 0;
  2656. for (var ii = 0; ii < newLen; ii++) {
  2657. if (ii === idx) {
  2658. newArray[ii] = val;
  2659. after = -1;
  2660. } else {
  2661. newArray[ii] = array[ii + after];
  2662. }
  2663. }
  2664. return newArray;
  2665. }
  2666. function spliceOut(array, idx, canEdit) {
  2667. var newLen = array.length - 1;
  2668. if (canEdit && idx === newLen) {
  2669. array.pop();
  2670. return array;
  2671. }
  2672. var newArray = new Array(newLen);
  2673. var after = 0;
  2674. for (var ii = 0; ii < newLen; ii++) {
  2675. if (ii === idx) {
  2676. after = 1;
  2677. }
  2678. newArray[ii] = array[ii + after];
  2679. }
  2680. return newArray;
  2681. }
  2682. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  2683. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  2684. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  2685. var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@';
  2686. function isList(maybeList) {
  2687. return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]);
  2688. }
  2689. var List = /*@__PURE__*/(function (IndexedCollection$$1) {
  2690. function List(value) {
  2691. var empty = emptyList();
  2692. if (value === null || value === undefined) {
  2693. return empty;
  2694. }
  2695. if (isList(value)) {
  2696. return value;
  2697. }
  2698. var iter = IndexedCollection$$1(value);
  2699. var size = iter.size;
  2700. if (size === 0) {
  2701. return empty;
  2702. }
  2703. assertNotInfinite(size);
  2704. if (size > 0 && size < SIZE) {
  2705. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  2706. }
  2707. return empty.withMutations(function (list) {
  2708. list.setSize(size);
  2709. iter.forEach(function (v, i) { return list.set(i, v); });
  2710. });
  2711. }
  2712. if ( IndexedCollection$$1 ) List.__proto__ = IndexedCollection$$1;
  2713. List.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
  2714. List.prototype.constructor = List;
  2715. List.of = function of (/*...values*/) {
  2716. return this(arguments);
  2717. };
  2718. List.prototype.toString = function toString () {
  2719. return this.__toString('List [', ']');
  2720. };
  2721. // @pragma Access
  2722. List.prototype.get = function get (index, notSetValue) {
  2723. index = wrapIndex(this, index);
  2724. if (index >= 0 && index < this.size) {
  2725. index += this._origin;
  2726. var node = listNodeFor(this, index);
  2727. return node && node.array[index & MASK];
  2728. }
  2729. return notSetValue;
  2730. };
  2731. // @pragma Modification
  2732. List.prototype.set = function set (index, value) {
  2733. return updateList(this, index, value);
  2734. };
  2735. List.prototype.remove = function remove (index) {
  2736. return !this.has(index)
  2737. ? this
  2738. : index === 0
  2739. ? this.shift()
  2740. : index === this.size - 1
  2741. ? this.pop()
  2742. : this.splice(index, 1);
  2743. };
  2744. List.prototype.insert = function insert (index, value) {
  2745. return this.splice(index, 0, value);
  2746. };
  2747. List.prototype.clear = function clear () {
  2748. if (this.size === 0) {
  2749. return this;
  2750. }
  2751. if (this.__ownerID) {
  2752. this.size = this._origin = this._capacity = 0;
  2753. this._level = SHIFT;
  2754. this._root = this._tail = null;
  2755. this.__hash = undefined;
  2756. this.__altered = true;
  2757. return this;
  2758. }
  2759. return emptyList();
  2760. };
  2761. List.prototype.push = function push (/*...values*/) {
  2762. var values = arguments;
  2763. var oldSize = this.size;
  2764. return this.withMutations(function (list) {
  2765. setListBounds(list, 0, oldSize + values.length);
  2766. for (var ii = 0; ii < values.length; ii++) {
  2767. list.set(oldSize + ii, values[ii]);
  2768. }
  2769. });
  2770. };
  2771. List.prototype.pop = function pop () {
  2772. return setListBounds(this, 0, -1);
  2773. };
  2774. List.prototype.unshift = function unshift (/*...values*/) {
  2775. var values = arguments;
  2776. return this.withMutations(function (list) {
  2777. setListBounds(list, -values.length);
  2778. for (var ii = 0; ii < values.length; ii++) {
  2779. list.set(ii, values[ii]);
  2780. }
  2781. });
  2782. };
  2783. List.prototype.shift = function shift () {
  2784. return setListBounds(this, 1);
  2785. };
  2786. // @pragma Composition
  2787. List.prototype.concat = function concat (/*...collections*/) {
  2788. var arguments$1 = arguments;
  2789. var seqs = [];
  2790. for (var i = 0; i < arguments.length; i++) {
  2791. var argument = arguments$1[i];
  2792. var seq = IndexedCollection$$1(
  2793. typeof argument !== 'string' && hasIterator(argument)
  2794. ? argument
  2795. : [argument]
  2796. );
  2797. if (seq.size !== 0) {
  2798. seqs.push(seq);
  2799. }
  2800. }
  2801. if (seqs.length === 0) {
  2802. return this;
  2803. }
  2804. if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
  2805. return this.constructor(seqs[0]);
  2806. }
  2807. return this.withMutations(function (list) {
  2808. seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); });
  2809. });
  2810. };
  2811. List.prototype.setSize = function setSize (size) {
  2812. return setListBounds(this, 0, size);
  2813. };
  2814. List.prototype.map = function map (mapper, context) {
  2815. var this$1 = this;
  2816. return this.withMutations(function (list) {
  2817. for (var i = 0; i < this$1.size; i++) {
  2818. list.set(i, mapper.call(context, list.get(i), i, list));
  2819. }
  2820. });
  2821. };
  2822. // @pragma Iteration
  2823. List.prototype.slice = function slice (begin, end) {
  2824. var size = this.size;
  2825. if (wholeSlice(begin, end, size)) {
  2826. return this;
  2827. }
  2828. return setListBounds(
  2829. this,
  2830. resolveBegin(begin, size),
  2831. resolveEnd(end, size)
  2832. );
  2833. };
  2834. List.prototype.__iterator = function __iterator (type, reverse) {
  2835. var index = reverse ? this.size : 0;
  2836. var values = iterateList(this, reverse);
  2837. return new Iterator(function () {
  2838. var value = values();
  2839. return value === DONE
  2840. ? iteratorDone()
  2841. : iteratorValue(type, reverse ? --index : index++, value);
  2842. });
  2843. };
  2844. List.prototype.__iterate = function __iterate (fn, reverse) {
  2845. var index = reverse ? this.size : 0;
  2846. var values = iterateList(this, reverse);
  2847. var value;
  2848. while ((value = values()) !== DONE) {
  2849. if (fn(value, reverse ? --index : index++, this) === false) {
  2850. break;
  2851. }
  2852. }
  2853. return index;
  2854. };
  2855. List.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  2856. if (ownerID === this.__ownerID) {
  2857. return this;
  2858. }
  2859. if (!ownerID) {
  2860. if (this.size === 0) {
  2861. return emptyList();
  2862. }
  2863. this.__ownerID = ownerID;
  2864. this.__altered = false;
  2865. return this;
  2866. }
  2867. return makeList(
  2868. this._origin,
  2869. this._capacity,
  2870. this._level,
  2871. this._root,
  2872. this._tail,
  2873. ownerID,
  2874. this.__hash
  2875. );
  2876. };
  2877. return List;
  2878. }(IndexedCollection));
  2879. List.isList = isList;
  2880. var ListPrototype = List.prototype;
  2881. ListPrototype[IS_LIST_SYMBOL] = true;
  2882. ListPrototype[DELETE] = ListPrototype.remove;
  2883. ListPrototype.merge = ListPrototype.concat;
  2884. ListPrototype.setIn = setIn$1;
  2885. ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
  2886. ListPrototype.update = update$1;
  2887. ListPrototype.updateIn = updateIn$1;
  2888. ListPrototype.mergeIn = mergeIn;
  2889. ListPrototype.mergeDeepIn = mergeDeepIn;
  2890. ListPrototype.withMutations = withMutations;
  2891. ListPrototype.wasAltered = wasAltered;
  2892. ListPrototype.asImmutable = asImmutable;
  2893. ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable;
  2894. ListPrototype['@@transducer/step'] = function(result, arr) {
  2895. return result.push(arr);
  2896. };
  2897. ListPrototype['@@transducer/result'] = function(obj) {
  2898. return obj.asImmutable();
  2899. };
  2900. var VNode = function VNode(array, ownerID) {
  2901. this.array = array;
  2902. this.ownerID = ownerID;
  2903. };
  2904. // TODO: seems like these methods are very similar
  2905. VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) {
  2906. if (index === level ? 1 << level : this.array.length === 0) {
  2907. return this;
  2908. }
  2909. var originIndex = (index >>> level) & MASK;
  2910. if (originIndex >= this.array.length) {
  2911. return new VNode([], ownerID);
  2912. }
  2913. var removingFirst = originIndex === 0;
  2914. var newChild;
  2915. if (level > 0) {
  2916. var oldChild = this.array[originIndex];
  2917. newChild =
  2918. oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  2919. if (newChild === oldChild && removingFirst) {
  2920. return this;
  2921. }
  2922. }
  2923. if (removingFirst && !newChild) {
  2924. return this;
  2925. }
  2926. var editable = editableVNode(this, ownerID);
  2927. if (!removingFirst) {
  2928. for (var ii = 0; ii < originIndex; ii++) {
  2929. editable.array[ii] = undefined;
  2930. }
  2931. }
  2932. if (newChild) {
  2933. editable.array[originIndex] = newChild;
  2934. }
  2935. return editable;
  2936. };
  2937. VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) {
  2938. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  2939. return this;
  2940. }
  2941. var sizeIndex = ((index - 1) >>> level) & MASK;
  2942. if (sizeIndex >= this.array.length) {
  2943. return this;
  2944. }
  2945. var newChild;
  2946. if (level > 0) {
  2947. var oldChild = this.array[sizeIndex];
  2948. newChild =
  2949. oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  2950. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  2951. return this;
  2952. }
  2953. }
  2954. var editable = editableVNode(this, ownerID);
  2955. editable.array.splice(sizeIndex + 1);
  2956. if (newChild) {
  2957. editable.array[sizeIndex] = newChild;
  2958. }
  2959. return editable;
  2960. };
  2961. var DONE = {};
  2962. function iterateList(list, reverse) {
  2963. var left = list._origin;
  2964. var right = list._capacity;
  2965. var tailPos = getTailOffset(right);
  2966. var tail = list._tail;
  2967. return iterateNodeOrLeaf(list._root, list._level, 0);
  2968. function iterateNodeOrLeaf(node, level, offset) {
  2969. return level === 0
  2970. ? iterateLeaf(node, offset)
  2971. : iterateNode(node, level, offset);
  2972. }
  2973. function iterateLeaf(node, offset) {
  2974. var array = offset === tailPos ? tail && tail.array : node && node.array;
  2975. var from = offset > left ? 0 : left - offset;
  2976. var to = right - offset;
  2977. if (to > SIZE) {
  2978. to = SIZE;
  2979. }
  2980. return function () {
  2981. if (from === to) {
  2982. return DONE;
  2983. }
  2984. var idx = reverse ? --to : from++;
  2985. return array && array[idx];
  2986. };
  2987. }
  2988. function iterateNode(node, level, offset) {
  2989. var values;
  2990. var array = node && node.array;
  2991. var from = offset > left ? 0 : (left - offset) >> level;
  2992. var to = ((right - offset) >> level) + 1;
  2993. if (to > SIZE) {
  2994. to = SIZE;
  2995. }
  2996. return function () {
  2997. while (true) {
  2998. if (values) {
  2999. var value = values();
  3000. if (value !== DONE) {
  3001. return value;
  3002. }
  3003. values = null;
  3004. }
  3005. if (from === to) {
  3006. return DONE;
  3007. }
  3008. var idx = reverse ? --to : from++;
  3009. values = iterateNodeOrLeaf(
  3010. array && array[idx],
  3011. level - SHIFT,
  3012. offset + (idx << level)
  3013. );
  3014. }
  3015. };
  3016. }
  3017. }
  3018. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  3019. var list = Object.create(ListPrototype);
  3020. list.size = capacity - origin;
  3021. list._origin = origin;
  3022. list._capacity = capacity;
  3023. list._level = level;
  3024. list._root = root;
  3025. list._tail = tail;
  3026. list.__ownerID = ownerID;
  3027. list.__hash = hash;
  3028. list.__altered = false;
  3029. return list;
  3030. }
  3031. var EMPTY_LIST;
  3032. function emptyList() {
  3033. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  3034. }
  3035. function updateList(list, index, value) {
  3036. index = wrapIndex(list, index);
  3037. if (index !== index) {
  3038. return list;
  3039. }
  3040. if (index >= list.size || index < 0) {
  3041. return list.withMutations(function (list) {
  3042. index < 0
  3043. ? setListBounds(list, index).set(0, value)
  3044. : setListBounds(list, 0, index + 1).set(index, value);
  3045. });
  3046. }
  3047. index += list._origin;
  3048. var newTail = list._tail;
  3049. var newRoot = list._root;
  3050. var didAlter = MakeRef();
  3051. if (index >= getTailOffset(list._capacity)) {
  3052. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  3053. } else {
  3054. newRoot = updateVNode(
  3055. newRoot,
  3056. list.__ownerID,
  3057. list._level,
  3058. index,
  3059. value,
  3060. didAlter
  3061. );
  3062. }
  3063. if (!didAlter.value) {
  3064. return list;
  3065. }
  3066. if (list.__ownerID) {
  3067. list._root = newRoot;
  3068. list._tail = newTail;
  3069. list.__hash = undefined;
  3070. list.__altered = true;
  3071. return list;
  3072. }
  3073. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  3074. }
  3075. function updateVNode(node, ownerID, level, index, value, didAlter) {
  3076. var idx = (index >>> level) & MASK;
  3077. var nodeHas = node && idx < node.array.length;
  3078. if (!nodeHas && value === undefined) {
  3079. return node;
  3080. }
  3081. var newNode;
  3082. if (level > 0) {
  3083. var lowerNode = node && node.array[idx];
  3084. var newLowerNode = updateVNode(
  3085. lowerNode,
  3086. ownerID,
  3087. level - SHIFT,
  3088. index,
  3089. value,
  3090. didAlter
  3091. );
  3092. if (newLowerNode === lowerNode) {
  3093. return node;
  3094. }
  3095. newNode = editableVNode(node, ownerID);
  3096. newNode.array[idx] = newLowerNode;
  3097. return newNode;
  3098. }
  3099. if (nodeHas && node.array[idx] === value) {
  3100. return node;
  3101. }
  3102. if (didAlter) {
  3103. SetRef(didAlter);
  3104. }
  3105. newNode = editableVNode(node, ownerID);
  3106. if (value === undefined && idx === newNode.array.length - 1) {
  3107. newNode.array.pop();
  3108. } else {
  3109. newNode.array[idx] = value;
  3110. }
  3111. return newNode;
  3112. }
  3113. function editableVNode(node, ownerID) {
  3114. if (ownerID && node && ownerID === node.ownerID) {
  3115. return node;
  3116. }
  3117. return new VNode(node ? node.array.slice() : [], ownerID);
  3118. }
  3119. function listNodeFor(list, rawIndex) {
  3120. if (rawIndex >= getTailOffset(list._capacity)) {
  3121. return list._tail;
  3122. }
  3123. if (rawIndex < 1 << (list._level + SHIFT)) {
  3124. var node = list._root;
  3125. var level = list._level;
  3126. while (node && level > 0) {
  3127. node = node.array[(rawIndex >>> level) & MASK];
  3128. level -= SHIFT;
  3129. }
  3130. return node;
  3131. }
  3132. }
  3133. function setListBounds(list, begin, end) {
  3134. // Sanitize begin & end using this shorthand for ToInt32(argument)
  3135. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  3136. if (begin !== undefined) {
  3137. begin |= 0;
  3138. }
  3139. if (end !== undefined) {
  3140. end |= 0;
  3141. }
  3142. var owner = list.__ownerID || new OwnerID();
  3143. var oldOrigin = list._origin;
  3144. var oldCapacity = list._capacity;
  3145. var newOrigin = oldOrigin + begin;
  3146. var newCapacity =
  3147. end === undefined
  3148. ? oldCapacity
  3149. : end < 0
  3150. ? oldCapacity + end
  3151. : oldOrigin + end;
  3152. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  3153. return list;
  3154. }
  3155. // If it's going to end after it starts, it's empty.
  3156. if (newOrigin >= newCapacity) {
  3157. return list.clear();
  3158. }
  3159. var newLevel = list._level;
  3160. var newRoot = list._root;
  3161. // New origin might need creating a higher root.
  3162. var offsetShift = 0;
  3163. while (newOrigin + offsetShift < 0) {
  3164. newRoot = new VNode(
  3165. newRoot && newRoot.array.length ? [undefined, newRoot] : [],
  3166. owner
  3167. );
  3168. newLevel += SHIFT;
  3169. offsetShift += 1 << newLevel;
  3170. }
  3171. if (offsetShift) {
  3172. newOrigin += offsetShift;
  3173. oldOrigin += offsetShift;
  3174. newCapacity += offsetShift;
  3175. oldCapacity += offsetShift;
  3176. }
  3177. var oldTailOffset = getTailOffset(oldCapacity);
  3178. var newTailOffset = getTailOffset(newCapacity);
  3179. // New size might need creating a higher root.
  3180. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  3181. newRoot = new VNode(
  3182. newRoot && newRoot.array.length ? [newRoot] : [],
  3183. owner
  3184. );
  3185. newLevel += SHIFT;
  3186. }
  3187. // Locate or create the new tail.
  3188. var oldTail = list._tail;
  3189. var newTail =
  3190. newTailOffset < oldTailOffset
  3191. ? listNodeFor(list, newCapacity - 1)
  3192. : newTailOffset > oldTailOffset
  3193. ? new VNode([], owner)
  3194. : oldTail;
  3195. // Merge Tail into tree.
  3196. if (
  3197. oldTail &&
  3198. newTailOffset > oldTailOffset &&
  3199. newOrigin < oldCapacity &&
  3200. oldTail.array.length
  3201. ) {
  3202. newRoot = editableVNode(newRoot, owner);
  3203. var node = newRoot;
  3204. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  3205. var idx = (oldTailOffset >>> level) & MASK;
  3206. node = node.array[idx] = editableVNode(node.array[idx], owner);
  3207. }
  3208. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  3209. }
  3210. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  3211. if (newCapacity < oldCapacity) {
  3212. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  3213. }
  3214. // If the new origin is within the tail, then we do not need a root.
  3215. if (newOrigin >= newTailOffset) {
  3216. newOrigin -= newTailOffset;
  3217. newCapacity -= newTailOffset;
  3218. newLevel = SHIFT;
  3219. newRoot = null;
  3220. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  3221. // Otherwise, if the root has been trimmed, garbage collect.
  3222. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  3223. offsetShift = 0;
  3224. // Identify the new top root node of the subtree of the old root.
  3225. while (newRoot) {
  3226. var beginIndex = (newOrigin >>> newLevel) & MASK;
  3227. if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
  3228. break;
  3229. }
  3230. if (beginIndex) {
  3231. offsetShift += (1 << newLevel) * beginIndex;
  3232. }
  3233. newLevel -= SHIFT;
  3234. newRoot = newRoot.array[beginIndex];
  3235. }
  3236. // Trim the new sides of the new root.
  3237. if (newRoot && newOrigin > oldOrigin) {
  3238. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  3239. }
  3240. if (newRoot && newTailOffset < oldTailOffset) {
  3241. newRoot = newRoot.removeAfter(
  3242. owner,
  3243. newLevel,
  3244. newTailOffset - offsetShift
  3245. );
  3246. }
  3247. if (offsetShift) {
  3248. newOrigin -= offsetShift;
  3249. newCapacity -= offsetShift;
  3250. }
  3251. }
  3252. if (list.__ownerID) {
  3253. list.size = newCapacity - newOrigin;
  3254. list._origin = newOrigin;
  3255. list._capacity = newCapacity;
  3256. list._level = newLevel;
  3257. list._root = newRoot;
  3258. list._tail = newTail;
  3259. list.__hash = undefined;
  3260. list.__altered = true;
  3261. return list;
  3262. }
  3263. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  3264. }
  3265. function getTailOffset(size) {
  3266. return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
  3267. }
  3268. var OrderedMap = /*@__PURE__*/(function (Map$$1) {
  3269. function OrderedMap(value) {
  3270. return value === null || value === undefined
  3271. ? emptyOrderedMap()
  3272. : isOrderedMap(value)
  3273. ? value
  3274. : emptyOrderedMap().withMutations(function (map) {
  3275. var iter = KeyedCollection(value);
  3276. assertNotInfinite(iter.size);
  3277. iter.forEach(function (v, k) { return map.set(k, v); });
  3278. });
  3279. }
  3280. if ( Map$$1 ) OrderedMap.__proto__ = Map$$1;
  3281. OrderedMap.prototype = Object.create( Map$$1 && Map$$1.prototype );
  3282. OrderedMap.prototype.constructor = OrderedMap;
  3283. OrderedMap.of = function of (/*...values*/) {
  3284. return this(arguments);
  3285. };
  3286. OrderedMap.prototype.toString = function toString () {
  3287. return this.__toString('OrderedMap {', '}');
  3288. };
  3289. // @pragma Access
  3290. OrderedMap.prototype.get = function get (k, notSetValue) {
  3291. var index = this._map.get(k);
  3292. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  3293. };
  3294. // @pragma Modification
  3295. OrderedMap.prototype.clear = function clear () {
  3296. if (this.size === 0) {
  3297. return this;
  3298. }
  3299. if (this.__ownerID) {
  3300. this.size = 0;
  3301. this._map.clear();
  3302. this._list.clear();
  3303. return this;
  3304. }
  3305. return emptyOrderedMap();
  3306. };
  3307. OrderedMap.prototype.set = function set (k, v) {
  3308. return updateOrderedMap(this, k, v);
  3309. };
  3310. OrderedMap.prototype.remove = function remove (k) {
  3311. return updateOrderedMap(this, k, NOT_SET);
  3312. };
  3313. OrderedMap.prototype.wasAltered = function wasAltered () {
  3314. return this._map.wasAltered() || this._list.wasAltered();
  3315. };
  3316. OrderedMap.prototype.__iterate = function __iterate (fn, reverse) {
  3317. var this$1 = this;
  3318. return this._list.__iterate(
  3319. function (entry) { return entry && fn(entry[1], entry[0], this$1); },
  3320. reverse
  3321. );
  3322. };
  3323. OrderedMap.prototype.__iterator = function __iterator (type, reverse) {
  3324. return this._list.fromEntrySeq().__iterator(type, reverse);
  3325. };
  3326. OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3327. if (ownerID === this.__ownerID) {
  3328. return this;
  3329. }
  3330. var newMap = this._map.__ensureOwner(ownerID);
  3331. var newList = this._list.__ensureOwner(ownerID);
  3332. if (!ownerID) {
  3333. if (this.size === 0) {
  3334. return emptyOrderedMap();
  3335. }
  3336. this.__ownerID = ownerID;
  3337. this._map = newMap;
  3338. this._list = newList;
  3339. return this;
  3340. }
  3341. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  3342. };
  3343. return OrderedMap;
  3344. }(Map));
  3345. OrderedMap.isOrderedMap = isOrderedMap;
  3346. OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
  3347. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  3348. function makeOrderedMap(map, list, ownerID, hash) {
  3349. var omap = Object.create(OrderedMap.prototype);
  3350. omap.size = map ? map.size : 0;
  3351. omap._map = map;
  3352. omap._list = list;
  3353. omap.__ownerID = ownerID;
  3354. omap.__hash = hash;
  3355. return omap;
  3356. }
  3357. var EMPTY_ORDERED_MAP;
  3358. function emptyOrderedMap() {
  3359. return (
  3360. EMPTY_ORDERED_MAP ||
  3361. (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
  3362. );
  3363. }
  3364. function updateOrderedMap(omap, k, v) {
  3365. var map = omap._map;
  3366. var list = omap._list;
  3367. var i = map.get(k);
  3368. var has = i !== undefined;
  3369. var newMap;
  3370. var newList;
  3371. if (v === NOT_SET) {
  3372. // removed
  3373. if (!has) {
  3374. return omap;
  3375. }
  3376. if (list.size >= SIZE && list.size >= map.size * 2) {
  3377. newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; });
  3378. newMap = newList
  3379. .toKeyedSeq()
  3380. .map(function (entry) { return entry[0]; })
  3381. .flip()
  3382. .toMap();
  3383. if (omap.__ownerID) {
  3384. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  3385. }
  3386. } else {
  3387. newMap = map.remove(k);
  3388. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  3389. }
  3390. } else if (has) {
  3391. if (v === list.get(i)[1]) {
  3392. return omap;
  3393. }
  3394. newMap = map;
  3395. newList = list.set(i, [k, v]);
  3396. } else {
  3397. newMap = map.set(k, list.size);
  3398. newList = list.set(list.size, [k, v]);
  3399. }
  3400. if (omap.__ownerID) {
  3401. omap.size = newMap.size;
  3402. omap._map = newMap;
  3403. omap._list = newList;
  3404. omap.__hash = undefined;
  3405. return omap;
  3406. }
  3407. return makeOrderedMap(newMap, newList);
  3408. }
  3409. var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@';
  3410. function isStack(maybeStack) {
  3411. return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]);
  3412. }
  3413. var Stack = /*@__PURE__*/(function (IndexedCollection$$1) {
  3414. function Stack(value) {
  3415. return value === null || value === undefined
  3416. ? emptyStack()
  3417. : isStack(value)
  3418. ? value
  3419. : emptyStack().pushAll(value);
  3420. }
  3421. if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1;
  3422. Stack.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
  3423. Stack.prototype.constructor = Stack;
  3424. Stack.of = function of (/*...values*/) {
  3425. return this(arguments);
  3426. };
  3427. Stack.prototype.toString = function toString () {
  3428. return this.__toString('Stack [', ']');
  3429. };
  3430. // @pragma Access
  3431. Stack.prototype.get = function get (index, notSetValue) {
  3432. var head = this._head;
  3433. index = wrapIndex(this, index);
  3434. while (head && index--) {
  3435. head = head.next;
  3436. }
  3437. return head ? head.value : notSetValue;
  3438. };
  3439. Stack.prototype.peek = function peek () {
  3440. return this._head && this._head.value;
  3441. };
  3442. // @pragma Modification
  3443. Stack.prototype.push = function push (/*...values*/) {
  3444. var arguments$1 = arguments;
  3445. if (arguments.length === 0) {
  3446. return this;
  3447. }
  3448. var newSize = this.size + arguments.length;
  3449. var head = this._head;
  3450. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  3451. head = {
  3452. value: arguments$1[ii],
  3453. next: head,
  3454. };
  3455. }
  3456. if (this.__ownerID) {
  3457. this.size = newSize;
  3458. this._head = head;
  3459. this.__hash = undefined;
  3460. this.__altered = true;
  3461. return this;
  3462. }
  3463. return makeStack(newSize, head);
  3464. };
  3465. Stack.prototype.pushAll = function pushAll (iter) {
  3466. iter = IndexedCollection$$1(iter);
  3467. if (iter.size === 0) {
  3468. return this;
  3469. }
  3470. if (this.size === 0 && isStack(iter)) {
  3471. return iter;
  3472. }
  3473. assertNotInfinite(iter.size);
  3474. var newSize = this.size;
  3475. var head = this._head;
  3476. iter.__iterate(function (value) {
  3477. newSize++;
  3478. head = {
  3479. value: value,
  3480. next: head,
  3481. };
  3482. }, /* reverse */ true);
  3483. if (this.__ownerID) {
  3484. this.size = newSize;
  3485. this._head = head;
  3486. this.__hash = undefined;
  3487. this.__altered = true;
  3488. return this;
  3489. }
  3490. return makeStack(newSize, head);
  3491. };
  3492. Stack.prototype.pop = function pop () {
  3493. return this.slice(1);
  3494. };
  3495. Stack.prototype.clear = function clear () {
  3496. if (this.size === 0) {
  3497. return this;
  3498. }
  3499. if (this.__ownerID) {
  3500. this.size = 0;
  3501. this._head = undefined;
  3502. this.__hash = undefined;
  3503. this.__altered = true;
  3504. return this;
  3505. }
  3506. return emptyStack();
  3507. };
  3508. Stack.prototype.slice = function slice (begin, end) {
  3509. if (wholeSlice(begin, end, this.size)) {
  3510. return this;
  3511. }
  3512. var resolvedBegin = resolveBegin(begin, this.size);
  3513. var resolvedEnd = resolveEnd(end, this.size);
  3514. if (resolvedEnd !== this.size) {
  3515. // super.slice(begin, end);
  3516. return IndexedCollection$$1.prototype.slice.call(this, begin, end);
  3517. }
  3518. var newSize = this.size - resolvedBegin;
  3519. var head = this._head;
  3520. while (resolvedBegin--) {
  3521. head = head.next;
  3522. }
  3523. if (this.__ownerID) {
  3524. this.size = newSize;
  3525. this._head = head;
  3526. this.__hash = undefined;
  3527. this.__altered = true;
  3528. return this;
  3529. }
  3530. return makeStack(newSize, head);
  3531. };
  3532. // @pragma Mutability
  3533. Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3534. if (ownerID === this.__ownerID) {
  3535. return this;
  3536. }
  3537. if (!ownerID) {
  3538. if (this.size === 0) {
  3539. return emptyStack();
  3540. }
  3541. this.__ownerID = ownerID;
  3542. this.__altered = false;
  3543. return this;
  3544. }
  3545. return makeStack(this.size, this._head, ownerID, this.__hash);
  3546. };
  3547. // @pragma Iteration
  3548. Stack.prototype.__iterate = function __iterate (fn, reverse) {
  3549. var this$1 = this;
  3550. if (reverse) {
  3551. return new ArraySeq(this.toArray()).__iterate(
  3552. function (v, k) { return fn(v, k, this$1); },
  3553. reverse
  3554. );
  3555. }
  3556. var iterations = 0;
  3557. var node = this._head;
  3558. while (node) {
  3559. if (fn(node.value, iterations++, this) === false) {
  3560. break;
  3561. }
  3562. node = node.next;
  3563. }
  3564. return iterations;
  3565. };
  3566. Stack.prototype.__iterator = function __iterator (type, reverse) {
  3567. if (reverse) {
  3568. return new ArraySeq(this.toArray()).__iterator(type, reverse);
  3569. }
  3570. var iterations = 0;
  3571. var node = this._head;
  3572. return new Iterator(function () {
  3573. if (node) {
  3574. var value = node.value;
  3575. node = node.next;
  3576. return iteratorValue(type, iterations++, value);
  3577. }
  3578. return iteratorDone();
  3579. });
  3580. };
  3581. return Stack;
  3582. }(IndexedCollection));
  3583. Stack.isStack = isStack;
  3584. var StackPrototype = Stack.prototype;
  3585. StackPrototype[IS_STACK_SYMBOL] = true;
  3586. StackPrototype.shift = StackPrototype.pop;
  3587. StackPrototype.unshift = StackPrototype.push;
  3588. StackPrototype.unshiftAll = StackPrototype.pushAll;
  3589. StackPrototype.withMutations = withMutations;
  3590. StackPrototype.wasAltered = wasAltered;
  3591. StackPrototype.asImmutable = asImmutable;
  3592. StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
  3593. StackPrototype['@@transducer/step'] = function(result, arr) {
  3594. return result.unshift(arr);
  3595. };
  3596. StackPrototype['@@transducer/result'] = function(obj) {
  3597. return obj.asImmutable();
  3598. };
  3599. function makeStack(size, head, ownerID, hash) {
  3600. var map = Object.create(StackPrototype);
  3601. map.size = size;
  3602. map._head = head;
  3603. map.__ownerID = ownerID;
  3604. map.__hash = hash;
  3605. map.__altered = false;
  3606. return map;
  3607. }
  3608. var EMPTY_STACK;
  3609. function emptyStack() {
  3610. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  3611. }
  3612. var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@';
  3613. function isSet(maybeSet) {
  3614. return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]);
  3615. }
  3616. function isOrderedSet(maybeOrderedSet) {
  3617. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  3618. }
  3619. function deepEqual(a, b) {
  3620. if (a === b) {
  3621. return true;
  3622. }
  3623. if (
  3624. !isCollection(b) ||
  3625. (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
  3626. (a.__hash !== undefined &&
  3627. b.__hash !== undefined &&
  3628. a.__hash !== b.__hash) ||
  3629. isKeyed(a) !== isKeyed(b) ||
  3630. isIndexed(a) !== isIndexed(b) ||
  3631. isOrdered(a) !== isOrdered(b)
  3632. ) {
  3633. return false;
  3634. }
  3635. if (a.size === 0 && b.size === 0) {
  3636. return true;
  3637. }
  3638. var notAssociative = !isAssociative(a);
  3639. if (isOrdered(a)) {
  3640. var entries = a.entries();
  3641. return (
  3642. b.every(function (v, k) {
  3643. var entry = entries.next().value;
  3644. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  3645. }) && entries.next().done
  3646. );
  3647. }
  3648. var flipped = false;
  3649. if (a.size === undefined) {
  3650. if (b.size === undefined) {
  3651. if (typeof a.cacheResult === 'function') {
  3652. a.cacheResult();
  3653. }
  3654. } else {
  3655. flipped = true;
  3656. var _ = a;
  3657. a = b;
  3658. b = _;
  3659. }
  3660. }
  3661. var allEqual = true;
  3662. var bSize = b.__iterate(function (v, k) {
  3663. if (
  3664. notAssociative
  3665. ? !a.has(v)
  3666. : flipped
  3667. ? !is(v, a.get(k, NOT_SET))
  3668. : !is(a.get(k, NOT_SET), v)
  3669. ) {
  3670. allEqual = false;
  3671. return false;
  3672. }
  3673. });
  3674. return allEqual && a.size === bSize;
  3675. }
  3676. /**
  3677. * Contributes additional methods to a constructor
  3678. */
  3679. function mixin(ctor, methods) {
  3680. var keyCopier = function (key) {
  3681. ctor.prototype[key] = methods[key];
  3682. };
  3683. Object.keys(methods).forEach(keyCopier);
  3684. Object.getOwnPropertySymbols &&
  3685. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  3686. return ctor;
  3687. }
  3688. function toJS(value) {
  3689. if (!value || typeof value !== 'object') {
  3690. return value;
  3691. }
  3692. if (!isCollection(value)) {
  3693. if (!isDataStructure(value)) {
  3694. return value;
  3695. }
  3696. value = Seq(value);
  3697. }
  3698. if (isKeyed(value)) {
  3699. var result$1 = {};
  3700. value.__iterate(function (v, k) {
  3701. result$1[k] = toJS(v);
  3702. });
  3703. return result$1;
  3704. }
  3705. var result = [];
  3706. value.__iterate(function (v) {
  3707. result.push(toJS(v));
  3708. });
  3709. return result;
  3710. }
  3711. var Set = /*@__PURE__*/(function (SetCollection$$1) {
  3712. function Set(value) {
  3713. return value === null || value === undefined
  3714. ? emptySet()
  3715. : isSet(value) && !isOrdered(value)
  3716. ? value
  3717. : emptySet().withMutations(function (set) {
  3718. var iter = SetCollection$$1(value);
  3719. assertNotInfinite(iter.size);
  3720. iter.forEach(function (v) { return set.add(v); });
  3721. });
  3722. }
  3723. if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1;
  3724. Set.prototype = Object.create( SetCollection$$1 && SetCollection$$1.prototype );
  3725. Set.prototype.constructor = Set;
  3726. Set.of = function of (/*...values*/) {
  3727. return this(arguments);
  3728. };
  3729. Set.fromKeys = function fromKeys (value) {
  3730. return this(KeyedCollection(value).keySeq());
  3731. };
  3732. Set.intersect = function intersect (sets) {
  3733. sets = Collection(sets).toArray();
  3734. return sets.length
  3735. ? SetPrototype.intersect.apply(Set(sets.pop()), sets)
  3736. : emptySet();
  3737. };
  3738. Set.union = function union (sets) {
  3739. sets = Collection(sets).toArray();
  3740. return sets.length
  3741. ? SetPrototype.union.apply(Set(sets.pop()), sets)
  3742. : emptySet();
  3743. };
  3744. Set.prototype.toString = function toString () {
  3745. return this.__toString('Set {', '}');
  3746. };
  3747. // @pragma Access
  3748. Set.prototype.has = function has (value) {
  3749. return this._map.has(value);
  3750. };
  3751. // @pragma Modification
  3752. Set.prototype.add = function add (value) {
  3753. return updateSet(this, this._map.set(value, value));
  3754. };
  3755. Set.prototype.remove = function remove (value) {
  3756. return updateSet(this, this._map.remove(value));
  3757. };
  3758. Set.prototype.clear = function clear () {
  3759. return updateSet(this, this._map.clear());
  3760. };
  3761. // @pragma Composition
  3762. Set.prototype.map = function map (mapper, context) {
  3763. var this$1 = this;
  3764. var removes = [];
  3765. var adds = [];
  3766. this.forEach(function (value) {
  3767. var mapped = mapper.call(context, value, value, this$1);
  3768. if (mapped !== value) {
  3769. removes.push(value);
  3770. adds.push(mapped);
  3771. }
  3772. });
  3773. return this.withMutations(function (set) {
  3774. removes.forEach(function (value) { return set.remove(value); });
  3775. adds.forEach(function (value) { return set.add(value); });
  3776. });
  3777. };
  3778. Set.prototype.union = function union () {
  3779. var iters = [], len = arguments.length;
  3780. while ( len-- ) iters[ len ] = arguments[ len ];
  3781. iters = iters.filter(function (x) { return x.size !== 0; });
  3782. if (iters.length === 0) {
  3783. return this;
  3784. }
  3785. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  3786. return this.constructor(iters[0]);
  3787. }
  3788. return this.withMutations(function (set) {
  3789. for (var ii = 0; ii < iters.length; ii++) {
  3790. SetCollection$$1(iters[ii]).forEach(function (value) { return set.add(value); });
  3791. }
  3792. });
  3793. };
  3794. Set.prototype.intersect = function intersect () {
  3795. var iters = [], len = arguments.length;
  3796. while ( len-- ) iters[ len ] = arguments[ len ];
  3797. if (iters.length === 0) {
  3798. return this;
  3799. }
  3800. iters = iters.map(function (iter) { return SetCollection$$1(iter); });
  3801. var toRemove = [];
  3802. this.forEach(function (value) {
  3803. if (!iters.every(function (iter) { return iter.includes(value); })) {
  3804. toRemove.push(value);
  3805. }
  3806. });
  3807. return this.withMutations(function (set) {
  3808. toRemove.forEach(function (value) {
  3809. set.remove(value);
  3810. });
  3811. });
  3812. };
  3813. Set.prototype.subtract = function subtract () {
  3814. var iters = [], len = arguments.length;
  3815. while ( len-- ) iters[ len ] = arguments[ len ];
  3816. if (iters.length === 0) {
  3817. return this;
  3818. }
  3819. iters = iters.map(function (iter) { return SetCollection$$1(iter); });
  3820. var toRemove = [];
  3821. this.forEach(function (value) {
  3822. if (iters.some(function (iter) { return iter.includes(value); })) {
  3823. toRemove.push(value);
  3824. }
  3825. });
  3826. return this.withMutations(function (set) {
  3827. toRemove.forEach(function (value) {
  3828. set.remove(value);
  3829. });
  3830. });
  3831. };
  3832. Set.prototype.sort = function sort (comparator) {
  3833. // Late binding
  3834. return OrderedSet(sortFactory(this, comparator));
  3835. };
  3836. Set.prototype.sortBy = function sortBy (mapper, comparator) {
  3837. // Late binding
  3838. return OrderedSet(sortFactory(this, comparator, mapper));
  3839. };
  3840. Set.prototype.wasAltered = function wasAltered () {
  3841. return this._map.wasAltered();
  3842. };
  3843. Set.prototype.__iterate = function __iterate (fn, reverse) {
  3844. var this$1 = this;
  3845. return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse);
  3846. };
  3847. Set.prototype.__iterator = function __iterator (type, reverse) {
  3848. return this._map.__iterator(type, reverse);
  3849. };
  3850. Set.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3851. if (ownerID === this.__ownerID) {
  3852. return this;
  3853. }
  3854. var newMap = this._map.__ensureOwner(ownerID);
  3855. if (!ownerID) {
  3856. if (this.size === 0) {
  3857. return this.__empty();
  3858. }
  3859. this.__ownerID = ownerID;
  3860. this._map = newMap;
  3861. return this;
  3862. }
  3863. return this.__make(newMap, ownerID);
  3864. };
  3865. return Set;
  3866. }(SetCollection));
  3867. Set.isSet = isSet;
  3868. var SetPrototype = Set.prototype;
  3869. SetPrototype[IS_SET_SYMBOL] = true;
  3870. SetPrototype[DELETE] = SetPrototype.remove;
  3871. SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
  3872. SetPrototype.withMutations = withMutations;
  3873. SetPrototype.asImmutable = asImmutable;
  3874. SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable;
  3875. SetPrototype['@@transducer/step'] = function(result, arr) {
  3876. return result.add(arr);
  3877. };
  3878. SetPrototype['@@transducer/result'] = function(obj) {
  3879. return obj.asImmutable();
  3880. };
  3881. SetPrototype.__empty = emptySet;
  3882. SetPrototype.__make = makeSet;
  3883. function updateSet(set, newMap) {
  3884. if (set.__ownerID) {
  3885. set.size = newMap.size;
  3886. set._map = newMap;
  3887. return set;
  3888. }
  3889. return newMap === set._map
  3890. ? set
  3891. : newMap.size === 0
  3892. ? set.__empty()
  3893. : set.__make(newMap);
  3894. }
  3895. function makeSet(map, ownerID) {
  3896. var set = Object.create(SetPrototype);
  3897. set.size = map ? map.size : 0;
  3898. set._map = map;
  3899. set.__ownerID = ownerID;
  3900. return set;
  3901. }
  3902. var EMPTY_SET;
  3903. function emptySet() {
  3904. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  3905. }
  3906. /**
  3907. * Returns a lazy seq of nums from start (inclusive) to end
  3908. * (exclusive), by step, where start defaults to 0, step to 1, and end to
  3909. * infinity. When start is equal to end, returns empty list.
  3910. */
  3911. var Range = /*@__PURE__*/(function (IndexedSeq$$1) {
  3912. function Range(start, end, step) {
  3913. if (!(this instanceof Range)) {
  3914. return new Range(start, end, step);
  3915. }
  3916. invariant(step !== 0, 'Cannot step a Range by 0');
  3917. start = start || 0;
  3918. if (end === undefined) {
  3919. end = Infinity;
  3920. }
  3921. step = step === undefined ? 1 : Math.abs(step);
  3922. if (end < start) {
  3923. step = -step;
  3924. }
  3925. this._start = start;
  3926. this._end = end;
  3927. this._step = step;
  3928. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  3929. if (this.size === 0) {
  3930. if (EMPTY_RANGE) {
  3931. return EMPTY_RANGE;
  3932. }
  3933. EMPTY_RANGE = this;
  3934. }
  3935. }
  3936. if ( IndexedSeq$$1 ) Range.__proto__ = IndexedSeq$$1;
  3937. Range.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  3938. Range.prototype.constructor = Range;
  3939. Range.prototype.toString = function toString () {
  3940. if (this.size === 0) {
  3941. return 'Range []';
  3942. }
  3943. return (
  3944. 'Range [ ' +
  3945. this._start +
  3946. '...' +
  3947. this._end +
  3948. (this._step !== 1 ? ' by ' + this._step : '') +
  3949. ' ]'
  3950. );
  3951. };
  3952. Range.prototype.get = function get (index, notSetValue) {
  3953. return this.has(index)
  3954. ? this._start + wrapIndex(this, index) * this._step
  3955. : notSetValue;
  3956. };
  3957. Range.prototype.includes = function includes (searchValue) {
  3958. var possibleIndex = (searchValue - this._start) / this._step;
  3959. return (
  3960. possibleIndex >= 0 &&
  3961. possibleIndex < this.size &&
  3962. possibleIndex === Math.floor(possibleIndex)
  3963. );
  3964. };
  3965. Range.prototype.slice = function slice (begin, end) {
  3966. if (wholeSlice(begin, end, this.size)) {
  3967. return this;
  3968. }
  3969. begin = resolveBegin(begin, this.size);
  3970. end = resolveEnd(end, this.size);
  3971. if (end <= begin) {
  3972. return new Range(0, 0);
  3973. }
  3974. return new Range(
  3975. this.get(begin, this._end),
  3976. this.get(end, this._end),
  3977. this._step
  3978. );
  3979. };
  3980. Range.prototype.indexOf = function indexOf (searchValue) {
  3981. var offsetValue = searchValue - this._start;
  3982. if (offsetValue % this._step === 0) {
  3983. var index = offsetValue / this._step;
  3984. if (index >= 0 && index < this.size) {
  3985. return index;
  3986. }
  3987. }
  3988. return -1;
  3989. };
  3990. Range.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  3991. return this.indexOf(searchValue);
  3992. };
  3993. Range.prototype.__iterate = function __iterate (fn, reverse) {
  3994. var size = this.size;
  3995. var step = this._step;
  3996. var value = reverse ? this._start + (size - 1) * step : this._start;
  3997. var i = 0;
  3998. while (i !== size) {
  3999. if (fn(value, reverse ? size - ++i : i++, this) === false) {
  4000. break;
  4001. }
  4002. value += reverse ? -step : step;
  4003. }
  4004. return i;
  4005. };
  4006. Range.prototype.__iterator = function __iterator (type, reverse) {
  4007. var size = this.size;
  4008. var step = this._step;
  4009. var value = reverse ? this._start + (size - 1) * step : this._start;
  4010. var i = 0;
  4011. return new Iterator(function () {
  4012. if (i === size) {
  4013. return iteratorDone();
  4014. }
  4015. var v = value;
  4016. value += reverse ? -step : step;
  4017. return iteratorValue(type, reverse ? size - ++i : i++, v);
  4018. });
  4019. };
  4020. Range.prototype.equals = function equals (other) {
  4021. return other instanceof Range
  4022. ? this._start === other._start &&
  4023. this._end === other._end &&
  4024. this._step === other._step
  4025. : deepEqual(this, other);
  4026. };
  4027. return Range;
  4028. }(IndexedSeq));
  4029. var EMPTY_RANGE;
  4030. function getIn(collection, searchKeyPath, notSetValue) {
  4031. var keyPath = coerceKeyPath(searchKeyPath);
  4032. var i = 0;
  4033. while (i !== keyPath.length) {
  4034. collection = get(collection, keyPath[i++], NOT_SET);
  4035. if (collection === NOT_SET) {
  4036. return notSetValue;
  4037. }
  4038. }
  4039. return collection;
  4040. }
  4041. function getIn$1(searchKeyPath, notSetValue) {
  4042. return getIn(this, searchKeyPath, notSetValue);
  4043. }
  4044. function hasIn(collection, keyPath) {
  4045. return getIn(collection, keyPath, NOT_SET) !== NOT_SET;
  4046. }
  4047. function hasIn$1(searchKeyPath) {
  4048. return hasIn(this, searchKeyPath);
  4049. }
  4050. function toObject() {
  4051. assertNotInfinite(this.size);
  4052. var object = {};
  4053. this.__iterate(function (v, k) {
  4054. object[k] = v;
  4055. });
  4056. return object;
  4057. }
  4058. // Note: all of these methods are deprecated.
  4059. Collection.isIterable = isCollection;
  4060. Collection.isKeyed = isKeyed;
  4061. Collection.isIndexed = isIndexed;
  4062. Collection.isAssociative = isAssociative;
  4063. Collection.isOrdered = isOrdered;
  4064. Collection.Iterator = Iterator;
  4065. mixin(Collection, {
  4066. // ### Conversion to other types
  4067. toArray: function toArray() {
  4068. assertNotInfinite(this.size);
  4069. var array = new Array(this.size || 0);
  4070. var useTuples = isKeyed(this);
  4071. var i = 0;
  4072. this.__iterate(function (v, k) {
  4073. // Keyed collections produce an array of tuples.
  4074. array[i++] = useTuples ? [k, v] : v;
  4075. });
  4076. return array;
  4077. },
  4078. toIndexedSeq: function toIndexedSeq() {
  4079. return new ToIndexedSequence(this);
  4080. },
  4081. toJS: function toJS$1() {
  4082. return toJS(this);
  4083. },
  4084. toKeyedSeq: function toKeyedSeq() {
  4085. return new ToKeyedSequence(this, true);
  4086. },
  4087. toMap: function toMap() {
  4088. // Use Late Binding here to solve the circular dependency.
  4089. return Map(this.toKeyedSeq());
  4090. },
  4091. toObject: toObject,
  4092. toOrderedMap: function toOrderedMap() {
  4093. // Use Late Binding here to solve the circular dependency.
  4094. return OrderedMap(this.toKeyedSeq());
  4095. },
  4096. toOrderedSet: function toOrderedSet() {
  4097. // Use Late Binding here to solve the circular dependency.
  4098. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  4099. },
  4100. toSet: function toSet() {
  4101. // Use Late Binding here to solve the circular dependency.
  4102. return Set(isKeyed(this) ? this.valueSeq() : this);
  4103. },
  4104. toSetSeq: function toSetSeq() {
  4105. return new ToSetSequence(this);
  4106. },
  4107. toSeq: function toSeq() {
  4108. return isIndexed(this)
  4109. ? this.toIndexedSeq()
  4110. : isKeyed(this)
  4111. ? this.toKeyedSeq()
  4112. : this.toSetSeq();
  4113. },
  4114. toStack: function toStack() {
  4115. // Use Late Binding here to solve the circular dependency.
  4116. return Stack(isKeyed(this) ? this.valueSeq() : this);
  4117. },
  4118. toList: function toList() {
  4119. // Use Late Binding here to solve the circular dependency.
  4120. return List(isKeyed(this) ? this.valueSeq() : this);
  4121. },
  4122. // ### Common JavaScript methods and properties
  4123. toString: function toString() {
  4124. return '[Collection]';
  4125. },
  4126. __toString: function __toString(head, tail) {
  4127. if (this.size === 0) {
  4128. return head + tail;
  4129. }
  4130. return (
  4131. head +
  4132. ' ' +
  4133. this.toSeq()
  4134. .map(this.__toStringMapper)
  4135. .join(', ') +
  4136. ' ' +
  4137. tail
  4138. );
  4139. },
  4140. // ### ES6 Collection methods (ES6 Array and Map)
  4141. concat: function concat() {
  4142. var values = [], len = arguments.length;
  4143. while ( len-- ) values[ len ] = arguments[ len ];
  4144. return reify(this, concatFactory(this, values));
  4145. },
  4146. includes: function includes(searchValue) {
  4147. return this.some(function (value) { return is(value, searchValue); });
  4148. },
  4149. entries: function entries() {
  4150. return this.__iterator(ITERATE_ENTRIES);
  4151. },
  4152. every: function every(predicate, context) {
  4153. assertNotInfinite(this.size);
  4154. var returnValue = true;
  4155. this.__iterate(function (v, k, c) {
  4156. if (!predicate.call(context, v, k, c)) {
  4157. returnValue = false;
  4158. return false;
  4159. }
  4160. });
  4161. return returnValue;
  4162. },
  4163. filter: function filter(predicate, context) {
  4164. return reify(this, filterFactory(this, predicate, context, true));
  4165. },
  4166. find: function find(predicate, context, notSetValue) {
  4167. var entry = this.findEntry(predicate, context);
  4168. return entry ? entry[1] : notSetValue;
  4169. },
  4170. forEach: function forEach(sideEffect, context) {
  4171. assertNotInfinite(this.size);
  4172. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  4173. },
  4174. join: function join(separator) {
  4175. assertNotInfinite(this.size);
  4176. separator = separator !== undefined ? '' + separator : ',';
  4177. var joined = '';
  4178. var isFirst = true;
  4179. this.__iterate(function (v) {
  4180. isFirst ? (isFirst = false) : (joined += separator);
  4181. joined += v !== null && v !== undefined ? v.toString() : '';
  4182. });
  4183. return joined;
  4184. },
  4185. keys: function keys() {
  4186. return this.__iterator(ITERATE_KEYS);
  4187. },
  4188. map: function map(mapper, context) {
  4189. return reify(this, mapFactory(this, mapper, context));
  4190. },
  4191. reduce: function reduce$1(reducer, initialReduction, context) {
  4192. return reduce(
  4193. this,
  4194. reducer,
  4195. initialReduction,
  4196. context,
  4197. arguments.length < 2,
  4198. false
  4199. );
  4200. },
  4201. reduceRight: function reduceRight(reducer, initialReduction, context) {
  4202. return reduce(
  4203. this,
  4204. reducer,
  4205. initialReduction,
  4206. context,
  4207. arguments.length < 2,
  4208. true
  4209. );
  4210. },
  4211. reverse: function reverse() {
  4212. return reify(this, reverseFactory(this, true));
  4213. },
  4214. slice: function slice(begin, end) {
  4215. return reify(this, sliceFactory(this, begin, end, true));
  4216. },
  4217. some: function some(predicate, context) {
  4218. return !this.every(not(predicate), context);
  4219. },
  4220. sort: function sort(comparator) {
  4221. return reify(this, sortFactory(this, comparator));
  4222. },
  4223. values: function values() {
  4224. return this.__iterator(ITERATE_VALUES);
  4225. },
  4226. // ### More sequential methods
  4227. butLast: function butLast() {
  4228. return this.slice(0, -1);
  4229. },
  4230. isEmpty: function isEmpty() {
  4231. return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; });
  4232. },
  4233. count: function count(predicate, context) {
  4234. return ensureSize(
  4235. predicate ? this.toSeq().filter(predicate, context) : this
  4236. );
  4237. },
  4238. countBy: function countBy(grouper, context) {
  4239. return countByFactory(this, grouper, context);
  4240. },
  4241. equals: function equals(other) {
  4242. return deepEqual(this, other);
  4243. },
  4244. entrySeq: function entrySeq() {
  4245. var collection = this;
  4246. if (collection._cache) {
  4247. // We cache as an entries array, so we can just return the cache!
  4248. return new ArraySeq(collection._cache);
  4249. }
  4250. var entriesSequence = collection
  4251. .toSeq()
  4252. .map(entryMapper)
  4253. .toIndexedSeq();
  4254. entriesSequence.fromEntrySeq = function () { return collection.toSeq(); };
  4255. return entriesSequence;
  4256. },
  4257. filterNot: function filterNot(predicate, context) {
  4258. return this.filter(not(predicate), context);
  4259. },
  4260. findEntry: function findEntry(predicate, context, notSetValue) {
  4261. var found = notSetValue;
  4262. this.__iterate(function (v, k, c) {
  4263. if (predicate.call(context, v, k, c)) {
  4264. found = [k, v];
  4265. return false;
  4266. }
  4267. });
  4268. return found;
  4269. },
  4270. findKey: function findKey(predicate, context) {
  4271. var entry = this.findEntry(predicate, context);
  4272. return entry && entry[0];
  4273. },
  4274. findLast: function findLast(predicate, context, notSetValue) {
  4275. return this.toKeyedSeq()
  4276. .reverse()
  4277. .find(predicate, context, notSetValue);
  4278. },
  4279. findLastEntry: function findLastEntry(predicate, context, notSetValue) {
  4280. return this.toKeyedSeq()
  4281. .reverse()
  4282. .findEntry(predicate, context, notSetValue);
  4283. },
  4284. findLastKey: function findLastKey(predicate, context) {
  4285. return this.toKeyedSeq()
  4286. .reverse()
  4287. .findKey(predicate, context);
  4288. },
  4289. first: function first(notSetValue) {
  4290. return this.find(returnTrue, null, notSetValue);
  4291. },
  4292. flatMap: function flatMap(mapper, context) {
  4293. return reify(this, flatMapFactory(this, mapper, context));
  4294. },
  4295. flatten: function flatten(depth) {
  4296. return reify(this, flattenFactory(this, depth, true));
  4297. },
  4298. fromEntrySeq: function fromEntrySeq() {
  4299. return new FromEntriesSequence(this);
  4300. },
  4301. get: function get(searchKey, notSetValue) {
  4302. return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue);
  4303. },
  4304. getIn: getIn$1,
  4305. groupBy: function groupBy(grouper, context) {
  4306. return groupByFactory(this, grouper, context);
  4307. },
  4308. has: function has(searchKey) {
  4309. return this.get(searchKey, NOT_SET) !== NOT_SET;
  4310. },
  4311. hasIn: hasIn$1,
  4312. isSubset: function isSubset(iter) {
  4313. iter = typeof iter.includes === 'function' ? iter : Collection(iter);
  4314. return this.every(function (value) { return iter.includes(value); });
  4315. },
  4316. isSuperset: function isSuperset(iter) {
  4317. iter = typeof iter.isSubset === 'function' ? iter : Collection(iter);
  4318. return iter.isSubset(this);
  4319. },
  4320. keyOf: function keyOf(searchValue) {
  4321. return this.findKey(function (value) { return is(value, searchValue); });
  4322. },
  4323. keySeq: function keySeq() {
  4324. return this.toSeq()
  4325. .map(keyMapper)
  4326. .toIndexedSeq();
  4327. },
  4328. last: function last(notSetValue) {
  4329. return this.toSeq()
  4330. .reverse()
  4331. .first(notSetValue);
  4332. },
  4333. lastKeyOf: function lastKeyOf(searchValue) {
  4334. return this.toKeyedSeq()
  4335. .reverse()
  4336. .keyOf(searchValue);
  4337. },
  4338. max: function max(comparator) {
  4339. return maxFactory(this, comparator);
  4340. },
  4341. maxBy: function maxBy(mapper, comparator) {
  4342. return maxFactory(this, comparator, mapper);
  4343. },
  4344. min: function min(comparator) {
  4345. return maxFactory(
  4346. this,
  4347. comparator ? neg(comparator) : defaultNegComparator
  4348. );
  4349. },
  4350. minBy: function minBy(mapper, comparator) {
  4351. return maxFactory(
  4352. this,
  4353. comparator ? neg(comparator) : defaultNegComparator,
  4354. mapper
  4355. );
  4356. },
  4357. rest: function rest() {
  4358. return this.slice(1);
  4359. },
  4360. skip: function skip(amount) {
  4361. return amount === 0 ? this : this.slice(Math.max(0, amount));
  4362. },
  4363. skipLast: function skipLast(amount) {
  4364. return amount === 0 ? this : this.slice(0, -Math.max(0, amount));
  4365. },
  4366. skipWhile: function skipWhile(predicate, context) {
  4367. return reify(this, skipWhileFactory(this, predicate, context, true));
  4368. },
  4369. skipUntil: function skipUntil(predicate, context) {
  4370. return this.skipWhile(not(predicate), context);
  4371. },
  4372. sortBy: function sortBy(mapper, comparator) {
  4373. return reify(this, sortFactory(this, comparator, mapper));
  4374. },
  4375. take: function take(amount) {
  4376. return this.slice(0, Math.max(0, amount));
  4377. },
  4378. takeLast: function takeLast(amount) {
  4379. return this.slice(-Math.max(0, amount));
  4380. },
  4381. takeWhile: function takeWhile(predicate, context) {
  4382. return reify(this, takeWhileFactory(this, predicate, context));
  4383. },
  4384. takeUntil: function takeUntil(predicate, context) {
  4385. return this.takeWhile(not(predicate), context);
  4386. },
  4387. update: function update(fn) {
  4388. return fn(this);
  4389. },
  4390. valueSeq: function valueSeq() {
  4391. return this.toIndexedSeq();
  4392. },
  4393. // ### Hashable Object
  4394. hashCode: function hashCode() {
  4395. return this.__hash || (this.__hash = hashCollection(this));
  4396. },
  4397. // ### Internal
  4398. // abstract __iterate(fn, reverse)
  4399. // abstract __iterator(type, reverse)
  4400. });
  4401. var CollectionPrototype = Collection.prototype;
  4402. CollectionPrototype[IS_COLLECTION_SYMBOL] = true;
  4403. CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values;
  4404. CollectionPrototype.toJSON = CollectionPrototype.toArray;
  4405. CollectionPrototype.__toStringMapper = quoteString;
  4406. CollectionPrototype.inspect = CollectionPrototype.toSource = function() {
  4407. return this.toString();
  4408. };
  4409. CollectionPrototype.chain = CollectionPrototype.flatMap;
  4410. CollectionPrototype.contains = CollectionPrototype.includes;
  4411. mixin(KeyedCollection, {
  4412. // ### More sequential methods
  4413. flip: function flip() {
  4414. return reify(this, flipFactory(this));
  4415. },
  4416. mapEntries: function mapEntries(mapper, context) {
  4417. var this$1 = this;
  4418. var iterations = 0;
  4419. return reify(
  4420. this,
  4421. this.toSeq()
  4422. .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); })
  4423. .fromEntrySeq()
  4424. );
  4425. },
  4426. mapKeys: function mapKeys(mapper, context) {
  4427. var this$1 = this;
  4428. return reify(
  4429. this,
  4430. this.toSeq()
  4431. .flip()
  4432. .map(function (k, v) { return mapper.call(context, k, v, this$1); })
  4433. .flip()
  4434. );
  4435. },
  4436. });
  4437. var KeyedCollectionPrototype = KeyedCollection.prototype;
  4438. KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true;
  4439. KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
  4440. KeyedCollectionPrototype.toJSON = toObject;
  4441. KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); };
  4442. mixin(IndexedCollection, {
  4443. // ### Conversion to other types
  4444. toKeyedSeq: function toKeyedSeq() {
  4445. return new ToKeyedSequence(this, false);
  4446. },
  4447. // ### ES6 Collection methods (ES6 Array and Map)
  4448. filter: function filter(predicate, context) {
  4449. return reify(this, filterFactory(this, predicate, context, false));
  4450. },
  4451. findIndex: function findIndex(predicate, context) {
  4452. var entry = this.findEntry(predicate, context);
  4453. return entry ? entry[0] : -1;
  4454. },
  4455. indexOf: function indexOf(searchValue) {
  4456. var key = this.keyOf(searchValue);
  4457. return key === undefined ? -1 : key;
  4458. },
  4459. lastIndexOf: function lastIndexOf(searchValue) {
  4460. var key = this.lastKeyOf(searchValue);
  4461. return key === undefined ? -1 : key;
  4462. },
  4463. reverse: function reverse() {
  4464. return reify(this, reverseFactory(this, false));
  4465. },
  4466. slice: function slice(begin, end) {
  4467. return reify(this, sliceFactory(this, begin, end, false));
  4468. },
  4469. splice: function splice(index, removeNum /*, ...values*/) {
  4470. var numArgs = arguments.length;
  4471. removeNum = Math.max(removeNum || 0, 0);
  4472. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  4473. return this;
  4474. }
  4475. // If index is negative, it should resolve relative to the size of the
  4476. // collection. However size may be expensive to compute if not cached, so
  4477. // only call count() if the number is in fact negative.
  4478. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  4479. var spliced = this.slice(0, index);
  4480. return reify(
  4481. this,
  4482. numArgs === 1
  4483. ? spliced
  4484. : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  4485. );
  4486. },
  4487. // ### More collection methods
  4488. findLastIndex: function findLastIndex(predicate, context) {
  4489. var entry = this.findLastEntry(predicate, context);
  4490. return entry ? entry[0] : -1;
  4491. },
  4492. first: function first(notSetValue) {
  4493. return this.get(0, notSetValue);
  4494. },
  4495. flatten: function flatten(depth) {
  4496. return reify(this, flattenFactory(this, depth, false));
  4497. },
  4498. get: function get(index, notSetValue) {
  4499. index = wrapIndex(this, index);
  4500. return index < 0 ||
  4501. (this.size === Infinity || (this.size !== undefined && index > this.size))
  4502. ? notSetValue
  4503. : this.find(function (_, key) { return key === index; }, undefined, notSetValue);
  4504. },
  4505. has: function has(index) {
  4506. index = wrapIndex(this, index);
  4507. return (
  4508. index >= 0 &&
  4509. (this.size !== undefined
  4510. ? this.size === Infinity || index < this.size
  4511. : this.indexOf(index) !== -1)
  4512. );
  4513. },
  4514. interpose: function interpose(separator) {
  4515. return reify(this, interposeFactory(this, separator));
  4516. },
  4517. interleave: function interleave(/*...collections*/) {
  4518. var collections = [this].concat(arrCopy(arguments));
  4519. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections);
  4520. var interleaved = zipped.flatten(true);
  4521. if (zipped.size) {
  4522. interleaved.size = zipped.size * collections.length;
  4523. }
  4524. return reify(this, interleaved);
  4525. },
  4526. keySeq: function keySeq() {
  4527. return Range(0, this.size);
  4528. },
  4529. last: function last(notSetValue) {
  4530. return this.get(-1, notSetValue);
  4531. },
  4532. skipWhile: function skipWhile(predicate, context) {
  4533. return reify(this, skipWhileFactory(this, predicate, context, false));
  4534. },
  4535. zip: function zip(/*, ...collections */) {
  4536. var collections = [this].concat(arrCopy(arguments));
  4537. return reify(this, zipWithFactory(this, defaultZipper, collections));
  4538. },
  4539. zipAll: function zipAll(/*, ...collections */) {
  4540. var collections = [this].concat(arrCopy(arguments));
  4541. return reify(this, zipWithFactory(this, defaultZipper, collections, true));
  4542. },
  4543. zipWith: function zipWith(zipper /*, ...collections */) {
  4544. var collections = arrCopy(arguments);
  4545. collections[0] = this;
  4546. return reify(this, zipWithFactory(this, zipper, collections));
  4547. },
  4548. });
  4549. var IndexedCollectionPrototype = IndexedCollection.prototype;
  4550. IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true;
  4551. IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true;
  4552. mixin(SetCollection, {
  4553. // ### ES6 Collection methods (ES6 Array and Map)
  4554. get: function get(value, notSetValue) {
  4555. return this.has(value) ? value : notSetValue;
  4556. },
  4557. includes: function includes(value) {
  4558. return this.has(value);
  4559. },
  4560. // ### More sequential methods
  4561. keySeq: function keySeq() {
  4562. return this.valueSeq();
  4563. },
  4564. });
  4565. SetCollection.prototype.has = CollectionPrototype.includes;
  4566. SetCollection.prototype.contains = SetCollection.prototype.includes;
  4567. // Mixin subclasses
  4568. mixin(KeyedSeq, KeyedCollection.prototype);
  4569. mixin(IndexedSeq, IndexedCollection.prototype);
  4570. mixin(SetSeq, SetCollection.prototype);
  4571. // #pragma Helper functions
  4572. function reduce(collection, reducer, reduction, context, useFirst, reverse) {
  4573. assertNotInfinite(collection.size);
  4574. collection.__iterate(function (v, k, c) {
  4575. if (useFirst) {
  4576. useFirst = false;
  4577. reduction = v;
  4578. } else {
  4579. reduction = reducer.call(context, reduction, v, k, c);
  4580. }
  4581. }, reverse);
  4582. return reduction;
  4583. }
  4584. function keyMapper(v, k) {
  4585. return k;
  4586. }
  4587. function entryMapper(v, k) {
  4588. return [k, v];
  4589. }
  4590. function not(predicate) {
  4591. return function() {
  4592. return !predicate.apply(this, arguments);
  4593. };
  4594. }
  4595. function neg(predicate) {
  4596. return function() {
  4597. return -predicate.apply(this, arguments);
  4598. };
  4599. }
  4600. function defaultZipper() {
  4601. return arrCopy(arguments);
  4602. }
  4603. function defaultNegComparator(a, b) {
  4604. return a < b ? 1 : a > b ? -1 : 0;
  4605. }
  4606. function hashCollection(collection) {
  4607. if (collection.size === Infinity) {
  4608. return 0;
  4609. }
  4610. var ordered = isOrdered(collection);
  4611. var keyed = isKeyed(collection);
  4612. var h = ordered ? 1 : 0;
  4613. var size = collection.__iterate(
  4614. keyed
  4615. ? ordered
  4616. ? function (v, k) {
  4617. h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
  4618. }
  4619. : function (v, k) {
  4620. h = (h + hashMerge(hash(v), hash(k))) | 0;
  4621. }
  4622. : ordered
  4623. ? function (v) {
  4624. h = (31 * h + hash(v)) | 0;
  4625. }
  4626. : function (v) {
  4627. h = (h + hash(v)) | 0;
  4628. }
  4629. );
  4630. return murmurHashOfSize(size, h);
  4631. }
  4632. function murmurHashOfSize(size, h) {
  4633. h = imul(h, 0xcc9e2d51);
  4634. h = imul((h << 15) | (h >>> -15), 0x1b873593);
  4635. h = imul((h << 13) | (h >>> -13), 5);
  4636. h = ((h + 0xe6546b64) | 0) ^ size;
  4637. h = imul(h ^ (h >>> 16), 0x85ebca6b);
  4638. h = imul(h ^ (h >>> 13), 0xc2b2ae35);
  4639. h = smi(h ^ (h >>> 16));
  4640. return h;
  4641. }
  4642. function hashMerge(a, b) {
  4643. return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
  4644. }
  4645. var OrderedSet = /*@__PURE__*/(function (Set$$1) {
  4646. function OrderedSet(value) {
  4647. return value === null || value === undefined
  4648. ? emptyOrderedSet()
  4649. : isOrderedSet(value)
  4650. ? value
  4651. : emptyOrderedSet().withMutations(function (set) {
  4652. var iter = SetCollection(value);
  4653. assertNotInfinite(iter.size);
  4654. iter.forEach(function (v) { return set.add(v); });
  4655. });
  4656. }
  4657. if ( Set$$1 ) OrderedSet.__proto__ = Set$$1;
  4658. OrderedSet.prototype = Object.create( Set$$1 && Set$$1.prototype );
  4659. OrderedSet.prototype.constructor = OrderedSet;
  4660. OrderedSet.of = function of (/*...values*/) {
  4661. return this(arguments);
  4662. };
  4663. OrderedSet.fromKeys = function fromKeys (value) {
  4664. return this(KeyedCollection(value).keySeq());
  4665. };
  4666. OrderedSet.prototype.toString = function toString () {
  4667. return this.__toString('OrderedSet {', '}');
  4668. };
  4669. return OrderedSet;
  4670. }(Set));
  4671. OrderedSet.isOrderedSet = isOrderedSet;
  4672. var OrderedSetPrototype = OrderedSet.prototype;
  4673. OrderedSetPrototype[IS_ORDERED_SYMBOL] = true;
  4674. OrderedSetPrototype.zip = IndexedCollectionPrototype.zip;
  4675. OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith;
  4676. OrderedSetPrototype.__empty = emptyOrderedSet;
  4677. OrderedSetPrototype.__make = makeOrderedSet;
  4678. function makeOrderedSet(map, ownerID) {
  4679. var set = Object.create(OrderedSetPrototype);
  4680. set.size = map ? map.size : 0;
  4681. set._map = map;
  4682. set.__ownerID = ownerID;
  4683. return set;
  4684. }
  4685. var EMPTY_ORDERED_SET;
  4686. function emptyOrderedSet() {
  4687. return (
  4688. EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
  4689. );
  4690. }
  4691. var Record = function Record(defaultValues, name) {
  4692. var hasInitialized;
  4693. var RecordType = function Record(values) {
  4694. var this$1 = this;
  4695. if (values instanceof RecordType) {
  4696. return values;
  4697. }
  4698. if (!(this instanceof RecordType)) {
  4699. return new RecordType(values);
  4700. }
  4701. if (!hasInitialized) {
  4702. hasInitialized = true;
  4703. var keys = Object.keys(defaultValues);
  4704. var indices = (RecordTypePrototype._indices = {});
  4705. // Deprecated: left to attempt not to break any external code which
  4706. // relies on a ._name property existing on record instances.
  4707. // Use Record.getDescriptiveName() instead
  4708. RecordTypePrototype._name = name;
  4709. RecordTypePrototype._keys = keys;
  4710. RecordTypePrototype._defaultValues = defaultValues;
  4711. for (var i = 0; i < keys.length; i++) {
  4712. var propName = keys[i];
  4713. indices[propName] = i;
  4714. if (RecordTypePrototype[propName]) {
  4715. /* eslint-disable no-console */
  4716. typeof console === 'object' &&
  4717. console.warn &&
  4718. console.warn(
  4719. 'Cannot define ' +
  4720. recordName(this) +
  4721. ' with property "' +
  4722. propName +
  4723. '" since that property name is part of the Record API.'
  4724. );
  4725. /* eslint-enable no-console */
  4726. } else {
  4727. setProp(RecordTypePrototype, propName);
  4728. }
  4729. }
  4730. }
  4731. this.__ownerID = undefined;
  4732. this._values = List().withMutations(function (l) {
  4733. l.setSize(this$1._keys.length);
  4734. KeyedCollection(values).forEach(function (v, k) {
  4735. l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v);
  4736. });
  4737. });
  4738. };
  4739. var RecordTypePrototype = (RecordType.prototype = Object.create(
  4740. RecordPrototype
  4741. ));
  4742. RecordTypePrototype.constructor = RecordType;
  4743. if (name) {
  4744. RecordType.displayName = name;
  4745. }
  4746. return RecordType;
  4747. };
  4748. Record.prototype.toString = function toString () {
  4749. var str = recordName(this) + ' { ';
  4750. var keys = this._keys;
  4751. var k;
  4752. for (var i = 0, l = keys.length; i !== l; i++) {
  4753. k = keys[i];
  4754. str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k));
  4755. }
  4756. return str + ' }';
  4757. };
  4758. Record.prototype.equals = function equals (other) {
  4759. return (
  4760. this === other ||
  4761. (other &&
  4762. this._keys === other._keys &&
  4763. recordSeq(this).equals(recordSeq(other)))
  4764. );
  4765. };
  4766. Record.prototype.hashCode = function hashCode () {
  4767. return recordSeq(this).hashCode();
  4768. };
  4769. // @pragma Access
  4770. Record.prototype.has = function has (k) {
  4771. return this._indices.hasOwnProperty(k);
  4772. };
  4773. Record.prototype.get = function get (k, notSetValue) {
  4774. if (!this.has(k)) {
  4775. return notSetValue;
  4776. }
  4777. var index = this._indices[k];
  4778. var value = this._values.get(index);
  4779. return value === undefined ? this._defaultValues[k] : value;
  4780. };
  4781. // @pragma Modification
  4782. Record.prototype.set = function set (k, v) {
  4783. if (this.has(k)) {
  4784. var newValues = this._values.set(
  4785. this._indices[k],
  4786. v === this._defaultValues[k] ? undefined : v
  4787. );
  4788. if (newValues !== this._values && !this.__ownerID) {
  4789. return makeRecord(this, newValues);
  4790. }
  4791. }
  4792. return this;
  4793. };
  4794. Record.prototype.remove = function remove (k) {
  4795. return this.set(k);
  4796. };
  4797. Record.prototype.clear = function clear () {
  4798. var newValues = this._values.clear().setSize(this._keys.length);
  4799. return this.__ownerID ? this : makeRecord(this, newValues);
  4800. };
  4801. Record.prototype.wasAltered = function wasAltered () {
  4802. return this._values.wasAltered();
  4803. };
  4804. Record.prototype.toSeq = function toSeq () {
  4805. return recordSeq(this);
  4806. };
  4807. Record.prototype.toJS = function toJS$1 () {
  4808. return toJS(this);
  4809. };
  4810. Record.prototype.entries = function entries () {
  4811. return this.__iterator(ITERATE_ENTRIES);
  4812. };
  4813. Record.prototype.__iterator = function __iterator (type, reverse) {
  4814. return recordSeq(this).__iterator(type, reverse);
  4815. };
  4816. Record.prototype.__iterate = function __iterate (fn, reverse) {
  4817. return recordSeq(this).__iterate(fn, reverse);
  4818. };
  4819. Record.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  4820. if (ownerID === this.__ownerID) {
  4821. return this;
  4822. }
  4823. var newValues = this._values.__ensureOwner(ownerID);
  4824. if (!ownerID) {
  4825. this.__ownerID = ownerID;
  4826. this._values = newValues;
  4827. return this;
  4828. }
  4829. return makeRecord(this, newValues, ownerID);
  4830. };
  4831. Record.isRecord = isRecord;
  4832. Record.getDescriptiveName = recordName;
  4833. var RecordPrototype = Record.prototype;
  4834. RecordPrototype[IS_RECORD_SYMBOL] = true;
  4835. RecordPrototype[DELETE] = RecordPrototype.remove;
  4836. RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
  4837. RecordPrototype.getIn = getIn$1;
  4838. RecordPrototype.hasIn = CollectionPrototype.hasIn;
  4839. RecordPrototype.merge = merge;
  4840. RecordPrototype.mergeWith = mergeWith;
  4841. RecordPrototype.mergeIn = mergeIn;
  4842. RecordPrototype.mergeDeep = mergeDeep$1;
  4843. RecordPrototype.mergeDeepWith = mergeDeepWith$1;
  4844. RecordPrototype.mergeDeepIn = mergeDeepIn;
  4845. RecordPrototype.setIn = setIn$1;
  4846. RecordPrototype.update = update$1;
  4847. RecordPrototype.updateIn = updateIn$1;
  4848. RecordPrototype.withMutations = withMutations;
  4849. RecordPrototype.asMutable = asMutable;
  4850. RecordPrototype.asImmutable = asImmutable;
  4851. RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
  4852. RecordPrototype.toJSON = RecordPrototype.toObject =
  4853. CollectionPrototype.toObject;
  4854. RecordPrototype.inspect = RecordPrototype.toSource = function() {
  4855. return this.toString();
  4856. };
  4857. function makeRecord(likeRecord, values, ownerID) {
  4858. var record = Object.create(Object.getPrototypeOf(likeRecord));
  4859. record._values = values;
  4860. record.__ownerID = ownerID;
  4861. return record;
  4862. }
  4863. function recordName(record) {
  4864. return record.constructor.displayName || record.constructor.name || 'Record';
  4865. }
  4866. function recordSeq(record) {
  4867. return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; }));
  4868. }
  4869. function setProp(prototype, name) {
  4870. try {
  4871. Object.defineProperty(prototype, name, {
  4872. get: function() {
  4873. return this.get(name);
  4874. },
  4875. set: function(value) {
  4876. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  4877. this.set(name, value);
  4878. },
  4879. });
  4880. } catch (error) {
  4881. // Object.defineProperty failed. Probably IE8.
  4882. }
  4883. }
  4884. /**
  4885. * Returns a lazy Seq of `value` repeated `times` times. When `times` is
  4886. * undefined, returns an infinite sequence of `value`.
  4887. */
  4888. var Repeat = /*@__PURE__*/(function (IndexedSeq$$1) {
  4889. function Repeat(value, times) {
  4890. if (!(this instanceof Repeat)) {
  4891. return new Repeat(value, times);
  4892. }
  4893. this._value = value;
  4894. this.size = times === undefined ? Infinity : Math.max(0, times);
  4895. if (this.size === 0) {
  4896. if (EMPTY_REPEAT) {
  4897. return EMPTY_REPEAT;
  4898. }
  4899. EMPTY_REPEAT = this;
  4900. }
  4901. }
  4902. if ( IndexedSeq$$1 ) Repeat.__proto__ = IndexedSeq$$1;
  4903. Repeat.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  4904. Repeat.prototype.constructor = Repeat;
  4905. Repeat.prototype.toString = function toString () {
  4906. if (this.size === 0) {
  4907. return 'Repeat []';
  4908. }
  4909. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  4910. };
  4911. Repeat.prototype.get = function get (index, notSetValue) {
  4912. return this.has(index) ? this._value : notSetValue;
  4913. };
  4914. Repeat.prototype.includes = function includes (searchValue) {
  4915. return is(this._value, searchValue);
  4916. };
  4917. Repeat.prototype.slice = function slice (begin, end) {
  4918. var size = this.size;
  4919. return wholeSlice(begin, end, size)
  4920. ? this
  4921. : new Repeat(
  4922. this._value,
  4923. resolveEnd(end, size) - resolveBegin(begin, size)
  4924. );
  4925. };
  4926. Repeat.prototype.reverse = function reverse () {
  4927. return this;
  4928. };
  4929. Repeat.prototype.indexOf = function indexOf (searchValue) {
  4930. if (is(this._value, searchValue)) {
  4931. return 0;
  4932. }
  4933. return -1;
  4934. };
  4935. Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  4936. if (is(this._value, searchValue)) {
  4937. return this.size;
  4938. }
  4939. return -1;
  4940. };
  4941. Repeat.prototype.__iterate = function __iterate (fn, reverse) {
  4942. var size = this.size;
  4943. var i = 0;
  4944. while (i !== size) {
  4945. if (fn(this._value, reverse ? size - ++i : i++, this) === false) {
  4946. break;
  4947. }
  4948. }
  4949. return i;
  4950. };
  4951. Repeat.prototype.__iterator = function __iterator (type, reverse) {
  4952. var this$1 = this;
  4953. var size = this.size;
  4954. var i = 0;
  4955. return new Iterator(
  4956. function () { return i === size
  4957. ? iteratorDone()
  4958. : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); }
  4959. );
  4960. };
  4961. Repeat.prototype.equals = function equals (other) {
  4962. return other instanceof Repeat
  4963. ? is(this._value, other._value)
  4964. : deepEqual(other);
  4965. };
  4966. return Repeat;
  4967. }(IndexedSeq));
  4968. var EMPTY_REPEAT;
  4969. function fromJS(value, converter) {
  4970. return fromJSWith(
  4971. [],
  4972. converter || defaultConverter,
  4973. value,
  4974. '',
  4975. converter && converter.length > 2 ? [] : undefined,
  4976. { '': value }
  4977. );
  4978. }
  4979. function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
  4980. var toSeq = Array.isArray(value)
  4981. ? IndexedSeq
  4982. : isPlainObj(value)
  4983. ? KeyedSeq
  4984. : null;
  4985. if (toSeq) {
  4986. if (~stack.indexOf(value)) {
  4987. throw new TypeError('Cannot convert circular structure to Immutable');
  4988. }
  4989. stack.push(value);
  4990. keyPath && key !== '' && keyPath.push(key);
  4991. var converted = converter.call(
  4992. parentValue,
  4993. key,
  4994. toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }
  4995. ),
  4996. keyPath && keyPath.slice()
  4997. );
  4998. stack.pop();
  4999. keyPath && keyPath.pop();
  5000. return converted;
  5001. }
  5002. return value;
  5003. }
  5004. function defaultConverter(k, v) {
  5005. return isKeyed(v) ? v.toMap() : v.toList();
  5006. }
  5007. var version = "4.0.0-rc.11";
  5008. var Immutable = {
  5009. version: version,
  5010. Collection: Collection,
  5011. // Note: Iterable is deprecated
  5012. Iterable: Collection,
  5013. Seq: Seq,
  5014. Map: Map,
  5015. OrderedMap: OrderedMap,
  5016. List: List,
  5017. Stack: Stack,
  5018. Set: Set,
  5019. OrderedSet: OrderedSet,
  5020. Record: Record,
  5021. Range: Range,
  5022. Repeat: Repeat,
  5023. is: is,
  5024. fromJS: fromJS,
  5025. hash: hash,
  5026. isImmutable: isImmutable,
  5027. isCollection: isCollection,
  5028. isKeyed: isKeyed,
  5029. isIndexed: isIndexed,
  5030. isAssociative: isAssociative,
  5031. isOrdered: isOrdered,
  5032. isValueObject: isValueObject,
  5033. isSeq: isSeq,
  5034. isList: isList,
  5035. isMap: isMap,
  5036. isOrderedMap: isOrderedMap,
  5037. isStack: isStack,
  5038. isSet: isSet,
  5039. isOrderedSet: isOrderedSet,
  5040. isRecord: isRecord,
  5041. get: get,
  5042. getIn: getIn,
  5043. has: has,
  5044. hasIn: hasIn,
  5045. merge: merge$1,
  5046. mergeDeep: mergeDeep,
  5047. mergeWith: mergeWith$1,
  5048. mergeDeepWith: mergeDeepWith,
  5049. remove: remove,
  5050. removeIn: removeIn,
  5051. set: set,
  5052. setIn: setIn,
  5053. update: update,
  5054. updateIn: updateIn,
  5055. };
  5056. // Note: Iterable is deprecated
  5057. var Iterable = Collection;
  5058. exports.default = Immutable;
  5059. exports.version = version;
  5060. exports.Collection = Collection;
  5061. exports.Iterable = Iterable;
  5062. exports.Seq = Seq;
  5063. exports.Map = Map;
  5064. exports.OrderedMap = OrderedMap;
  5065. exports.List = List;
  5066. exports.Stack = Stack;
  5067. exports.Set = Set;
  5068. exports.OrderedSet = OrderedSet;
  5069. exports.Record = Record;
  5070. exports.Range = Range;
  5071. exports.Repeat = Repeat;
  5072. exports.is = is;
  5073. exports.fromJS = fromJS;
  5074. exports.hash = hash;
  5075. exports.isImmutable = isImmutable;
  5076. exports.isCollection = isCollection;
  5077. exports.isKeyed = isKeyed;
  5078. exports.isIndexed = isIndexed;
  5079. exports.isAssociative = isAssociative;
  5080. exports.isOrdered = isOrdered;
  5081. exports.isValueObject = isValueObject;
  5082. exports.get = get;
  5083. exports.getIn = getIn;
  5084. exports.has = has;
  5085. exports.hasIn = hasIn;
  5086. exports.merge = merge$1;
  5087. exports.mergeDeep = mergeDeep;
  5088. exports.mergeWith = mergeWith$1;
  5089. exports.mergeDeepWith = mergeDeepWith;
  5090. exports.remove = remove;
  5091. exports.removeIn = removeIn;
  5092. exports.set = set;
  5093. exports.setIn = setIn;
  5094. exports.update = update;
  5095. exports.updateIn = updateIn;
  5096. Object.defineProperty(exports, '__esModule', { value: true });
  5097. })));
  5098. });
  5099. _commonjsHelpers.unwrapExports(immutable);
  5100. var draftjsUtils = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5101. !function(t,e){module.exports=e(Draft.Draft,immutable);}(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;});
  5102. });
  5103. _commonjsHelpers.unwrapExports(draftjsUtils);
  5104. var draftjsUtils_1 = draftjsUtils.draftjsUtils;
  5105. var interopRequireDefault = _commonjsHelpers.createCommonjsModule(function (module) {
  5106. function _interopRequireDefault(obj) {
  5107. return obj && obj.__esModule ? obj : {
  5108. "default": obj
  5109. };
  5110. }
  5111. module.exports = _interopRequireDefault;
  5112. });
  5113. _commonjsHelpers.unwrapExports(interopRequireDefault);
  5114. /**
  5115. * Copyright (c) 2013-present, Facebook, Inc.
  5116. *
  5117. * This source code is licensed under the MIT license found in the
  5118. * LICENSE file in the root directory of this source tree.
  5119. */
  5120. /**
  5121. * Use invariant() to assert state which your program assumes to be true.
  5122. *
  5123. * Provide sprintf-style format (only %s is supported) and arguments
  5124. * to provide information about what broke and what you were
  5125. * expecting.
  5126. *
  5127. * The invariant message will be stripped in production, but the invariant
  5128. * will remain to ensure logic does not differ in production.
  5129. */
  5130. var invariant = function(condition, format, a, b, c, d, e, f) {
  5131. if (process.env.NODE_ENV !== 'production') {
  5132. if (format === undefined) {
  5133. throw new Error('invariant requires an error message argument');
  5134. }
  5135. }
  5136. if (!condition) {
  5137. var error;
  5138. if (format === undefined) {
  5139. error = new Error(
  5140. 'Minified exception occurred; use the non-minified dev environment ' +
  5141. 'for the full error message and additional helpful warnings.'
  5142. );
  5143. } else {
  5144. var args = [a, b, c, d, e, f];
  5145. var argIndex = 0;
  5146. error = new Error(
  5147. format.replace(/%s/g, function() { return args[argIndex++]; })
  5148. );
  5149. error.name = 'Invariant Violation';
  5150. }
  5151. error.framesToPop = 1; // we don't care about invariant's own frame
  5152. throw error;
  5153. }
  5154. };
  5155. var browser = invariant;
  5156. function _arrayWithoutHoles(arr) {
  5157. if (Array.isArray(arr)) {
  5158. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  5159. arr2[i] = arr[i];
  5160. }
  5161. return arr2;
  5162. }
  5163. }
  5164. var arrayWithoutHoles = _arrayWithoutHoles;
  5165. function _iterableToArray(iter) {
  5166. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  5167. }
  5168. var iterableToArray = _iterableToArray;
  5169. function _nonIterableSpread() {
  5170. throw new TypeError("Invalid attempt to spread non-iterable instance");
  5171. }
  5172. var nonIterableSpread = _nonIterableSpread;
  5173. function _toConsumableArray(arr) {
  5174. return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
  5175. }
  5176. var toConsumableArray = _toConsumableArray;
  5177. var updateMutation_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5178. Object.defineProperty(exports, "__esModule", {
  5179. value: true
  5180. });
  5181. exports["default"] = updateMutation;
  5182. function updateMutation(mutation, originalOffset, originalLength, newLength, prefixLength, suffixLength) {
  5183. // three cases we can reasonably adjust - disjoint mutations that
  5184. // happen later on where the offset will need to be changed,
  5185. // mutations that completely contain the new one where we can adjust
  5186. // the length, and mutations that occur partially within the new one.
  5187. var lengthDiff = newLength - originalLength;
  5188. var mutationAfterChange = originalOffset + originalLength <= mutation.offset;
  5189. if (mutationAfterChange) {
  5190. return Object.assign({}, mutation, {
  5191. offset: mutation.offset + lengthDiff
  5192. });
  5193. }
  5194. var mutationContainsChange = originalOffset >= mutation.offset && originalOffset + originalLength <= mutation.offset + mutation.length;
  5195. if (mutationContainsChange) {
  5196. return Object.assign({}, mutation, {
  5197. length: mutation.length + lengthDiff
  5198. });
  5199. }
  5200. var mutationWithinPrefixChange = mutation.offset >= originalOffset && mutation.offset + mutation.length <= originalOffset + originalLength && prefixLength > 0;
  5201. if (mutationWithinPrefixChange) {
  5202. return Object.assign({}, mutation, {
  5203. offset: mutation.offset + prefixLength
  5204. });
  5205. }
  5206. var mutationContainsPrefix = mutation.offset < originalOffset && mutation.offset + mutation.length <= originalOffset + originalLength && mutation.offset + mutation.length > originalOffset && prefixLength > 0;
  5207. if (mutationContainsPrefix) {
  5208. return [Object.assign({}, mutation, {
  5209. length: originalOffset - mutation.offset
  5210. }), Object.assign({}, mutation, {
  5211. offset: originalOffset + prefixLength,
  5212. length: mutation.offset - originalOffset + mutation.length
  5213. })];
  5214. }
  5215. var mutationContainsSuffix = mutation.offset >= originalOffset && mutation.offset + mutation.length > originalOffset + originalLength && originalOffset + originalLength > mutation.offset && suffixLength > 0;
  5216. if (mutationContainsSuffix) {
  5217. return [Object.assign({}, mutation, {
  5218. offset: mutation.offset + prefixLength,
  5219. length: originalOffset + originalLength - mutation.offset
  5220. }), Object.assign({}, mutation, {
  5221. offset: originalOffset + originalLength + prefixLength + suffixLength,
  5222. length: mutation.offset + mutation.length - (originalOffset + originalLength)
  5223. })];
  5224. }
  5225. return mutation;
  5226. }
  5227. });
  5228. _commonjsHelpers.unwrapExports(updateMutation_1);
  5229. var rangeSort = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5230. Object.defineProperty(exports, "__esModule", {
  5231. value: true
  5232. });
  5233. exports["default"] = void 0;
  5234. var _default = function _default(r1, r2) {
  5235. if (r1.offset === r2.offset) {
  5236. return r2.length - r1.length;
  5237. }
  5238. return r1.offset - r2.offset;
  5239. };
  5240. exports["default"] = _default;
  5241. });
  5242. _commonjsHelpers.unwrapExports(rangeSort);
  5243. var encodeBlock = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5244. Object.defineProperty(exports, "__esModule", {
  5245. value: true
  5246. });
  5247. exports["default"] = void 0;
  5248. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  5249. var _updateMutation = interopRequireDefault(updateMutation_1);
  5250. var _rangeSort = interopRequireDefault(rangeSort);
  5251. var ENTITY_MAP = {
  5252. '&': '&amp;',
  5253. '<': '&lt;',
  5254. '>': '&gt;',
  5255. '"': '&quot;',
  5256. "'": '&#x27;',
  5257. '`': '&#x60;',
  5258. '\n': '<br/>'
  5259. };
  5260. var _default = function _default(block) {
  5261. var blockText = (0, _toConsumableArray2["default"])(block.text);
  5262. var entities = block.entityRanges.sort(_rangeSort["default"]);
  5263. var styles = block.inlineStyleRanges.sort(_rangeSort["default"]);
  5264. var resultText = '';
  5265. var _loop = function _loop(index) {
  5266. var _char = blockText[index];
  5267. if (ENTITY_MAP[_char] !== undefined) {
  5268. var encoded = ENTITY_MAP[_char];
  5269. var resultIndex = (0, _toConsumableArray2["default"])(resultText).length;
  5270. resultText += encoded;
  5271. var updateForChar = function updateForChar(mutation) {
  5272. return (0, _updateMutation["default"])(mutation, resultIndex, _char.length, encoded.length, 0, 0);
  5273. };
  5274. entities = entities.map(updateForChar);
  5275. styles = styles.map(updateForChar);
  5276. } else {
  5277. resultText += _char;
  5278. }
  5279. };
  5280. for (var index = 0; index < blockText.length; index++) {
  5281. _loop(index);
  5282. }
  5283. return Object.assign({}, block, {
  5284. text: resultText,
  5285. inlineStyleRanges: styles,
  5286. entityRanges: entities
  5287. });
  5288. };
  5289. exports["default"] = _default;
  5290. });
  5291. _commonjsHelpers.unwrapExports(encodeBlock);
  5292. var _typeof_1 = _commonjsHelpers.createCommonjsModule(function (module) {
  5293. function _typeof(obj) {
  5294. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  5295. module.exports = _typeof = function _typeof(obj) {
  5296. return typeof obj;
  5297. };
  5298. } else {
  5299. module.exports = _typeof = function _typeof(obj) {
  5300. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  5301. };
  5302. }
  5303. return _typeof(obj);
  5304. }
  5305. module.exports = _typeof;
  5306. });
  5307. var splitReactElement_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5308. Object.defineProperty(exports, "__esModule", {
  5309. value: true
  5310. });
  5311. exports["default"] = splitReactElement;
  5312. var _invariant = interopRequireDefault(browser);
  5313. var _react = interopRequireDefault(React__default);
  5314. var _server = interopRequireDefault(server);
  5315. // see http://w3c.github.io/html/syntax.html#writing-html-documents-elements
  5316. var VOID_TAGS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
  5317. function splitReactElement(element) {
  5318. if (VOID_TAGS.indexOf(element.type) !== -1) {
  5319. return _server["default"].renderToStaticMarkup(element);
  5320. }
  5321. var tags = _server["default"].renderToStaticMarkup(_react["default"].cloneElement(element, {}, '\r')).split('\r');
  5322. (0, _invariant["default"])(tags.length > 1, "convertToHTML: Element of type ".concat(element.type, " must render children"));
  5323. (0, _invariant["default"])(tags.length < 3, "convertToHTML: Element of type ".concat(element.type, " cannot use carriage return character"));
  5324. return {
  5325. start: tags[0],
  5326. end: tags[1]
  5327. };
  5328. }
  5329. });
  5330. _commonjsHelpers.unwrapExports(splitReactElement_1);
  5331. var getElementHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5332. Object.defineProperty(exports, "__esModule", {
  5333. value: true
  5334. });
  5335. exports["default"] = getElementHTML;
  5336. var _typeof2 = interopRequireDefault(_typeof_1);
  5337. var _invariant = interopRequireDefault(browser);
  5338. var _react = interopRequireDefault(React__default);
  5339. var _server = interopRequireDefault(server);
  5340. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  5341. function hasChildren(element) {
  5342. return _react["default"].isValidElement(element) && _react["default"].Children.count(element.props.children) > 0;
  5343. }
  5344. function getElementHTML(element) {
  5345. var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5346. if (element === undefined || element === null) {
  5347. return element;
  5348. }
  5349. if (typeof element === 'string') {
  5350. return element;
  5351. }
  5352. if (_react["default"].isValidElement(element)) {
  5353. if (hasChildren(element)) {
  5354. return _server["default"].renderToStaticMarkup(element);
  5355. }
  5356. var tags = (0, _splitReactElement["default"])(element);
  5357. if (text !== null && (0, _typeof2["default"])(tags) === 'object') {
  5358. var start = tags.start,
  5359. end = tags.end;
  5360. return start + text + end;
  5361. }
  5362. return tags;
  5363. }
  5364. (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');
  5365. if (text !== null) {
  5366. var _start = element.start,
  5367. _end = element.end;
  5368. return _start + text + _end;
  5369. }
  5370. return element;
  5371. }
  5372. });
  5373. _commonjsHelpers.unwrapExports(getElementHTML_1);
  5374. var getElementTagLength_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5375. Object.defineProperty(exports, "__esModule", {
  5376. value: true
  5377. });
  5378. exports["default"] = void 0;
  5379. var _typeof2 = interopRequireDefault(_typeof_1);
  5380. var _react = interopRequireDefault(React__default);
  5381. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  5382. var getElementTagLength = function getElementTagLength(element) {
  5383. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'start';
  5384. if (_react["default"].isValidElement(element)) {
  5385. var splitElement = (0, _splitReactElement["default"])(element);
  5386. if (typeof splitElement === 'string') {
  5387. return 0;
  5388. }
  5389. var length = splitElement[type].length;
  5390. var child = _react["default"].Children.toArray(element.props.children)[0];
  5391. return length + (child && _react["default"].isValidElement(child) ? getElementTagLength(child, type) : 0);
  5392. }
  5393. if ((0, _typeof2["default"])(element) === 'object') {
  5394. return element[type] ? element[type].length : 0;
  5395. }
  5396. return 0;
  5397. };
  5398. var _default = getElementTagLength;
  5399. exports["default"] = _default;
  5400. });
  5401. _commonjsHelpers.unwrapExports(getElementTagLength_1);
  5402. var blockEntities = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5403. Object.defineProperty(exports, "__esModule", {
  5404. value: true
  5405. });
  5406. exports["default"] = void 0;
  5407. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  5408. var _updateMutation = interopRequireDefault(updateMutation_1);
  5409. var _rangeSort = interopRequireDefault(rangeSort);
  5410. var _getElementHTML = interopRequireDefault(getElementHTML_1);
  5411. var _getElementTagLength = interopRequireDefault(getElementTagLength_1);
  5412. var converter = function converter() {
  5413. var originalText = arguments.length > 1 ? arguments[1] : undefined;
  5414. return originalText;
  5415. };
  5416. var _default = function _default(block, entityMap) {
  5417. var entityConverter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : converter;
  5418. var resultText = (0, _toConsumableArray2["default"])(block.text);
  5419. var getEntityHTML = entityConverter;
  5420. if (entityConverter.__isMiddleware) {
  5421. getEntityHTML = entityConverter(converter);
  5422. }
  5423. if (Object.prototype.hasOwnProperty.call(block, 'entityRanges') && block.entityRanges.length > 0) {
  5424. var entities = block.entityRanges.sort(_rangeSort["default"]);
  5425. var styles = block.inlineStyleRanges;
  5426. var _loop = function _loop(index) {
  5427. var entityRange = entities[index];
  5428. var entity = entityMap[entityRange.key];
  5429. var originalText = resultText.slice(entityRange.offset, entityRange.offset + entityRange.length).join('');
  5430. var entityHTML = getEntityHTML(entity, originalText);
  5431. var converted = (0, _toConsumableArray2["default"])((0, _getElementHTML["default"])(entityHTML, originalText) || originalText);
  5432. var prefixLength = (0, _getElementTagLength["default"])(entityHTML, 'start');
  5433. var suffixLength = (0, _getElementTagLength["default"])(entityHTML, 'end');
  5434. var updateLaterMutation = function updateLaterMutation(mutation, mutationIndex) {
  5435. if (mutationIndex > index || Object.prototype.hasOwnProperty.call(mutation, 'style')) {
  5436. return (0, _updateMutation["default"])(mutation, entityRange.offset, entityRange.length, converted.length, prefixLength, suffixLength);
  5437. }
  5438. return mutation;
  5439. };
  5440. var updateLaterMutations = function updateLaterMutations(mutationList) {
  5441. return mutationList.reduce(function (acc, mutation, mutationIndex) {
  5442. var updatedMutation = updateLaterMutation(mutation, mutationIndex);
  5443. if (Array.isArray(updatedMutation)) {
  5444. return acc.concat(updatedMutation);
  5445. }
  5446. return acc.concat([updatedMutation]);
  5447. }, []);
  5448. };
  5449. entities = updateLaterMutations(entities);
  5450. styles = updateLaterMutations(styles);
  5451. resultText = [].concat((0, _toConsumableArray2["default"])(resultText.slice(0, entityRange.offset)), (0, _toConsumableArray2["default"])(converted), (0, _toConsumableArray2["default"])(resultText.slice(entityRange.offset + entityRange.length)));
  5452. };
  5453. for (var index = 0; index < entities.length; index++) {
  5454. _loop(index);
  5455. }
  5456. return Object.assign({}, block, {
  5457. text: resultText.join(''),
  5458. inlineStyleRanges: styles,
  5459. entityRanges: entities
  5460. });
  5461. }
  5462. return block;
  5463. };
  5464. exports["default"] = _default;
  5465. });
  5466. _commonjsHelpers.unwrapExports(blockEntities);
  5467. var styleObjectFunction = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5468. Object.defineProperty(exports, "__esModule", {
  5469. value: true
  5470. });
  5471. exports["default"] = void 0;
  5472. var _default = function _default(object) {
  5473. return function (style) {
  5474. if (typeof object === 'function') {
  5475. return object(style);
  5476. }
  5477. return object[style];
  5478. };
  5479. };
  5480. exports["default"] = _default;
  5481. });
  5482. _commonjsHelpers.unwrapExports(styleObjectFunction);
  5483. var accumulateFunction = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5484. Object.defineProperty(exports, "__esModule", {
  5485. value: true
  5486. });
  5487. exports["default"] = void 0;
  5488. var _default = function _default(newFn, rest) {
  5489. return function () {
  5490. var newResult = newFn.apply(void 0, arguments);
  5491. if (newResult !== undefined && newResult !== null) {
  5492. return newResult;
  5493. }
  5494. return rest.apply(void 0, arguments);
  5495. };
  5496. };
  5497. exports["default"] = _default;
  5498. });
  5499. _commonjsHelpers.unwrapExports(accumulateFunction);
  5500. var defaultInlineHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5501. Object.defineProperty(exports, "__esModule", {
  5502. value: true
  5503. });
  5504. exports["default"] = defaultInlineHTML;
  5505. var _react = interopRequireDefault(React__default);
  5506. function defaultInlineHTML(style) {
  5507. switch (style) {
  5508. case 'BOLD':
  5509. return _react["default"].createElement("strong", null);
  5510. case 'ITALIC':
  5511. return _react["default"].createElement("em", null);
  5512. case 'UNDERLINE':
  5513. return _react["default"].createElement("u", null);
  5514. case 'CODE':
  5515. return _react["default"].createElement("code", null);
  5516. default:
  5517. return {
  5518. start: '',
  5519. end: ''
  5520. };
  5521. }
  5522. }
  5523. });
  5524. _commonjsHelpers.unwrapExports(defaultInlineHTML_1);
  5525. var blockInlineStyles = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5526. Object.defineProperty(exports, "__esModule", {
  5527. value: true
  5528. });
  5529. exports["default"] = void 0;
  5530. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  5531. var _invariant = interopRequireDefault(browser);
  5532. var _styleObjectFunction = interopRequireDefault(styleObjectFunction);
  5533. var _accumulateFunction = interopRequireDefault(accumulateFunction);
  5534. var _getElementHTML = interopRequireDefault(getElementHTML_1);
  5535. var _rangeSort = interopRequireDefault(rangeSort);
  5536. var _defaultInlineHTML = interopRequireDefault(defaultInlineHTML_1);
  5537. var subtractStyles = function subtractStyles(original, toRemove) {
  5538. return original.filter(function (el) {
  5539. return !toRemove.some(function (elToRemove) {
  5540. return elToRemove.style === el.style;
  5541. });
  5542. });
  5543. };
  5544. var popEndingStyles = function popEndingStyles(styleStack, endingStyles) {
  5545. return endingStyles.reduceRight(function (stack, style) {
  5546. var styleToRemove = stack[stack.length - 1];
  5547. (0, _invariant["default"])(styleToRemove.style === style.style, "Style ".concat(styleToRemove.style, " to be removed doesn't match expected ").concat(style.style));
  5548. return stack.slice(0, -1);
  5549. }, styleStack);
  5550. };
  5551. var characterStyles = function characterStyles(offset, ranges) {
  5552. return ranges.filter(function (range) {
  5553. return offset >= range.offset && offset < range.offset + range.length;
  5554. });
  5555. };
  5556. var rangeIsSubset = function rangeIsSubset(firstRange, secondRange) {
  5557. // returns true if the second range is a subset of the first
  5558. var secondStartWithinFirst = firstRange.offset <= secondRange.offset;
  5559. var secondEndWithinFirst = firstRange.offset + firstRange.length >= secondRange.offset + secondRange.length;
  5560. return secondStartWithinFirst && secondEndWithinFirst;
  5561. };
  5562. var latestStyleLast = function latestStyleLast(s1, s2) {
  5563. // make sure longer-lasting styles are added first
  5564. var s2endIndex = s2.offset + s2.length;
  5565. var s1endIndex = s1.offset + s1.length;
  5566. return s2endIndex - s1endIndex;
  5567. };
  5568. var getStylesToReset = function getStylesToReset(remainingStyles, newStyles) {
  5569. var i = 0;
  5570. while (i < remainingStyles.length) {
  5571. if (newStyles.every(rangeIsSubset.bind(null, remainingStyles[i]))) {
  5572. i++;
  5573. } else {
  5574. return remainingStyles.slice(i);
  5575. }
  5576. }
  5577. return [];
  5578. };
  5579. var appendStartMarkup = function appendStartMarkup(inlineHTML, string, styleRange) {
  5580. return string + (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).start;
  5581. };
  5582. var prependEndMarkup = function prependEndMarkup(inlineHTML, string, styleRange) {
  5583. return (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).end + string;
  5584. };
  5585. var defaultCustomInlineHTML = function defaultCustomInlineHTML(next) {
  5586. return function (style) {
  5587. return next(style);
  5588. };
  5589. };
  5590. defaultCustomInlineHTML.__isMiddleware = true;
  5591. var _default = function _default(rawBlock) {
  5592. var customInlineHTML = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCustomInlineHTML;
  5593. (0, _invariant["default"])(rawBlock !== null && rawBlock !== undefined, 'Expected raw block to be non-null');
  5594. var inlineHTML;
  5595. if (customInlineHTML.__isMiddleware === true) {
  5596. inlineHTML = customInlineHTML(_defaultInlineHTML["default"]);
  5597. } else {
  5598. inlineHTML = (0, _accumulateFunction["default"])((0, _styleObjectFunction["default"])(customInlineHTML), (0, _styleObjectFunction["default"])(_defaultInlineHTML["default"]));
  5599. }
  5600. var result = '';
  5601. var styleStack = [];
  5602. var sortedRanges = rawBlock.inlineStyleRanges.sort(_rangeSort["default"]);
  5603. var originalTextArray = (0, _toConsumableArray2["default"])(rawBlock.text);
  5604. for (var i = 0; i < originalTextArray.length; i++) {
  5605. var styles = characterStyles(i, sortedRanges);
  5606. var endingStyles = subtractStyles(styleStack, styles);
  5607. var newStyles = subtractStyles(styles, styleStack);
  5608. var remainingStyles = subtractStyles(styleStack, endingStyles); // reset styles: look for any already existing styles that will need to
  5609. // end before styles that are being added on this character. to solve this
  5610. // close out those current tags and all nested children,
  5611. // then open new ones nested within the new styles.
  5612. var resetStyles = getStylesToReset(remainingStyles, newStyles);
  5613. var openingStyles = resetStyles.concat(newStyles).sort(latestStyleLast);
  5614. var openingStyleTags = openingStyles.reduce(appendStartMarkup.bind(null, inlineHTML), '');
  5615. var endingStyleTags = endingStyles.concat(resetStyles).reduce(prependEndMarkup.bind(null, inlineHTML), '');
  5616. result += endingStyleTags + openingStyleTags + originalTextArray[i];
  5617. styleStack = popEndingStyles(styleStack, resetStyles.concat(endingStyles));
  5618. styleStack = styleStack.concat(openingStyles);
  5619. (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"));
  5620. }
  5621. result = styleStack.reduceRight(function (res, openStyle) {
  5622. return res + (0, _getElementHTML["default"])(inlineHTML(openStyle.style)).end;
  5623. }, result);
  5624. return result;
  5625. };
  5626. exports["default"] = _default;
  5627. });
  5628. _commonjsHelpers.unwrapExports(blockInlineStyles);
  5629. var blockTypeObjectFunction = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5630. Object.defineProperty(exports, "__esModule", {
  5631. value: true
  5632. });
  5633. exports["default"] = void 0;
  5634. var _default = function _default(typeObject) {
  5635. return function (block) {
  5636. if (typeof typeObject === 'function') {
  5637. // handle case where typeObject is already a function
  5638. return typeObject(block);
  5639. }
  5640. return typeObject[block.type];
  5641. };
  5642. };
  5643. exports["default"] = _default;
  5644. });
  5645. _commonjsHelpers.unwrapExports(blockTypeObjectFunction);
  5646. var getBlockTags_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5647. Object.defineProperty(exports, "__esModule", {
  5648. value: true
  5649. });
  5650. exports["default"] = getBlockTags;
  5651. var _invariant = interopRequireDefault(browser);
  5652. var _react = interopRequireDefault(React__default);
  5653. var _server = interopRequireDefault(server);
  5654. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  5655. function hasChildren(element) {
  5656. return _react["default"].isValidElement(element) && _react["default"].Children.count(element.props.children) > 0;
  5657. }
  5658. function getBlockTags(blockHTML) {
  5659. (0, _invariant["default"])(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
  5660. if (typeof blockHTML === 'string') {
  5661. return blockHTML;
  5662. }
  5663. if (_react["default"].isValidElement(blockHTML)) {
  5664. if (hasChildren(blockHTML)) {
  5665. return _server["default"].renderToStaticMarkup(blockHTML);
  5666. }
  5667. return (0, _splitReactElement["default"])(blockHTML);
  5668. }
  5669. if (Object.prototype.hasOwnProperty.call(blockHTML, 'element') && _react["default"].isValidElement(blockHTML.element)) {
  5670. return Object.assign({}, blockHTML, (0, _splitReactElement["default"])(blockHTML.element));
  5671. }
  5672. (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');
  5673. return blockHTML;
  5674. }
  5675. });
  5676. _commonjsHelpers.unwrapExports(getBlockTags_1);
  5677. var getNestedBlockTags_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5678. Object.defineProperty(exports, "__esModule", {
  5679. value: true
  5680. });
  5681. exports["default"] = getNestedBlockTags;
  5682. var _invariant = interopRequireDefault(browser);
  5683. var _react = interopRequireDefault(React__default);
  5684. var _splitReactElement2 = interopRequireDefault(splitReactElement_1);
  5685. function getNestedBlockTags(blockHTML) {
  5686. (0, _invariant["default"])(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
  5687. if (_react["default"].isValidElement(blockHTML.nest)) {
  5688. var _splitReactElement = (0, _splitReactElement2["default"])(blockHTML.nest),
  5689. start = _splitReactElement.start,
  5690. end = _splitReactElement.end;
  5691. return Object.assign({}, blockHTML, {
  5692. nestStart: start,
  5693. nestEnd: end
  5694. });
  5695. }
  5696. (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');
  5697. return blockHTML;
  5698. }
  5699. });
  5700. _commonjsHelpers.unwrapExports(getNestedBlockTags_1);
  5701. var defaultBlockHTML = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5702. Object.defineProperty(exports, "__esModule", {
  5703. value: true
  5704. });
  5705. exports["default"] = void 0;
  5706. var _react = interopRequireDefault(React__default);
  5707. var _default = {
  5708. unstyled: _react["default"].createElement("p", null),
  5709. paragraph: _react["default"].createElement("p", null),
  5710. 'header-one': _react["default"].createElement("h1", null),
  5711. 'header-two': _react["default"].createElement("h2", null),
  5712. 'header-three': _react["default"].createElement("h3", null),
  5713. 'header-four': _react["default"].createElement("h4", null),
  5714. 'header-five': _react["default"].createElement("h5", null),
  5715. 'header-six': _react["default"].createElement("h6", null),
  5716. blockquote: _react["default"].createElement("blockquote", null),
  5717. 'unordered-list-item': {
  5718. element: _react["default"].createElement("li", null),
  5719. nest: _react["default"].createElement("ul", null)
  5720. },
  5721. 'ordered-list-item': {
  5722. element: _react["default"].createElement("li", null),
  5723. nest: _react["default"].createElement("ol", null)
  5724. },
  5725. media: _react["default"].createElement("figure", null),
  5726. atomic: _react["default"].createElement("figure", null)
  5727. };
  5728. exports["default"] = _default;
  5729. });
  5730. _commonjsHelpers.unwrapExports(defaultBlockHTML);
  5731. var convertToHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5732. Object.defineProperty(exports, "__esModule", {
  5733. value: true
  5734. });
  5735. exports["default"] = void 0;
  5736. var _invariant = interopRequireDefault(browser);
  5737. var _react = interopRequireDefault(React__default);
  5738. var _server = interopRequireDefault(server);
  5739. var _encodeBlock = interopRequireDefault(encodeBlock);
  5740. var _blockEntities = interopRequireDefault(blockEntities);
  5741. var _blockInlineStyles = interopRequireDefault(blockInlineStyles);
  5742. var _accumulateFunction = interopRequireDefault(accumulateFunction);
  5743. var _blockTypeObjectFunction = interopRequireDefault(blockTypeObjectFunction);
  5744. var _getBlockTags = interopRequireDefault(getBlockTags_1);
  5745. var _getNestedBlockTags = interopRequireDefault(getNestedBlockTags_1);
  5746. var _defaultBlockHTML = interopRequireDefault(defaultBlockHTML);
  5747. // import Immutable from 'immutable'; // eslint-disable-line no-unused-vars
  5748. var defaultEntityToHTML = function defaultEntityToHTML(entity, originalText) {
  5749. return originalText;
  5750. };
  5751. var convertToHTML = function convertToHTML(_ref) {
  5752. var _ref$styleToHTML = _ref.styleToHTML,
  5753. styleToHTML = _ref$styleToHTML === void 0 ? {} : _ref$styleToHTML,
  5754. _ref$blockToHTML = _ref.blockToHTML,
  5755. blockToHTML = _ref$blockToHTML === void 0 ? {} : _ref$blockToHTML,
  5756. _ref$entityToHTML = _ref.entityToHTML,
  5757. entityToHTML = _ref$entityToHTML === void 0 ? defaultEntityToHTML : _ref$entityToHTML;
  5758. return function (contentState) {
  5759. (0, _invariant["default"])(contentState !== null && contentState !== undefined, 'Expected contentState to be non-null');
  5760. var getBlockHTML;
  5761. if (blockToHTML.__isMiddleware === true) {
  5762. getBlockHTML = blockToHTML((0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"]));
  5763. } else {
  5764. getBlockHTML = (0, _accumulateFunction["default"])((0, _blockTypeObjectFunction["default"])(blockToHTML), (0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"]));
  5765. }
  5766. var rawState = (0, Draft.Draft.convertToRaw)(contentState);
  5767. var listStack = [];
  5768. var result = rawState.blocks.map(function (block) {
  5769. var type = block.type,
  5770. depth = block.depth;
  5771. var closeNestTags = '';
  5772. var openNestTags = '';
  5773. var blockHTMLResult = getBlockHTML(block);
  5774. if (!blockHTMLResult) {
  5775. throw new Error("convertToHTML: missing HTML definition for block with type ".concat(block.type));
  5776. }
  5777. if (!blockHTMLResult.nest) {
  5778. // this block can't be nested, so reset all nesting if necessary
  5779. closeNestTags = listStack.reduceRight(function (string, nestedBlock) {
  5780. return string + (0, _getNestedBlockTags["default"])(getBlockHTML(nestedBlock)).nestEnd;
  5781. }, '');
  5782. listStack = [];
  5783. } else {
  5784. while (depth + 1 !== listStack.length || type !== listStack[depth].type) {
  5785. if (depth + 1 === listStack.length) {
  5786. // depth is right but doesn't match type
  5787. var blockToClose = listStack[depth];
  5788. closeNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(blockToClose)).nestEnd;
  5789. openNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(block)).nestStart;
  5790. listStack[depth] = block;
  5791. } else if (depth + 1 < listStack.length) {
  5792. var _blockToClose = listStack[listStack.length - 1];
  5793. closeNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(_blockToClose)).nestEnd;
  5794. listStack = listStack.slice(0, -1);
  5795. } else {
  5796. openNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(block)).nestStart;
  5797. listStack.push(block);
  5798. }
  5799. }
  5800. }
  5801. var innerHTML = (0, _blockInlineStyles["default"])((0, _blockEntities["default"])((0, _encodeBlock["default"])(block), rawState.entityMap, entityToHTML), styleToHTML);
  5802. var blockHTML = (0, _getBlockTags["default"])(getBlockHTML(block));
  5803. var html;
  5804. if (typeof blockHTML === 'string') {
  5805. html = blockHTML;
  5806. } else {
  5807. html = blockHTML.start + innerHTML + blockHTML.end;
  5808. }
  5809. if (innerHTML.length === 0 && Object.prototype.hasOwnProperty.call(blockHTML, 'empty')) {
  5810. if (_react["default"].isValidElement(blockHTML.empty)) {
  5811. html = _server["default"].renderToStaticMarkup(blockHTML.empty);
  5812. } else {
  5813. html = blockHTML.empty;
  5814. }
  5815. }
  5816. return closeNestTags + openNestTags + html;
  5817. }).join('');
  5818. result = listStack.reduce(function (res, nestBlock) {
  5819. return res + (0, _getNestedBlockTags["default"])(getBlockHTML(nestBlock)).nestEnd;
  5820. }, result);
  5821. return result;
  5822. };
  5823. };
  5824. var _default = function _default() {
  5825. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5826. args[_key] = arguments[_key];
  5827. }
  5828. if (args.length === 1 && Object.prototype.hasOwnProperty.call(args[0], '_map') && args[0].getBlockMap != null) {
  5829. // skip higher-order function and use defaults
  5830. return convertToHTML({}).apply(void 0, args);
  5831. }
  5832. return convertToHTML.apply(void 0, args);
  5833. };
  5834. exports["default"] = _default;
  5835. });
  5836. _commonjsHelpers.unwrapExports(convertToHTML_1);
  5837. var immutable$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5838. /**
  5839. * Copyright (c) 2014-2015, Facebook, Inc.
  5840. * All rights reserved.
  5841. *
  5842. * This source code is licensed under the BSD-style license found in the
  5843. * LICENSE file in the root directory of this source tree. An additional grant
  5844. * of patent rights can be found in the PATENTS file in the same directory.
  5845. */
  5846. (function (global, factory) {
  5847. module.exports = factory() ;
  5848. }(_commonjsHelpers.commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
  5849. function createClass(ctor, superClass) {
  5850. if (superClass) {
  5851. ctor.prototype = Object.create(superClass.prototype);
  5852. }
  5853. ctor.prototype.constructor = ctor;
  5854. }
  5855. function Iterable(value) {
  5856. return isIterable(value) ? value : Seq(value);
  5857. }
  5858. createClass(KeyedIterable, Iterable);
  5859. function KeyedIterable(value) {
  5860. return isKeyed(value) ? value : KeyedSeq(value);
  5861. }
  5862. createClass(IndexedIterable, Iterable);
  5863. function IndexedIterable(value) {
  5864. return isIndexed(value) ? value : IndexedSeq(value);
  5865. }
  5866. createClass(SetIterable, Iterable);
  5867. function SetIterable(value) {
  5868. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  5869. }
  5870. function isIterable(maybeIterable) {
  5871. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  5872. }
  5873. function isKeyed(maybeKeyed) {
  5874. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  5875. }
  5876. function isIndexed(maybeIndexed) {
  5877. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  5878. }
  5879. function isAssociative(maybeAssociative) {
  5880. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  5881. }
  5882. function isOrdered(maybeOrdered) {
  5883. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  5884. }
  5885. Iterable.isIterable = isIterable;
  5886. Iterable.isKeyed = isKeyed;
  5887. Iterable.isIndexed = isIndexed;
  5888. Iterable.isAssociative = isAssociative;
  5889. Iterable.isOrdered = isOrdered;
  5890. Iterable.Keyed = KeyedIterable;
  5891. Iterable.Indexed = IndexedIterable;
  5892. Iterable.Set = SetIterable;
  5893. var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  5894. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  5895. var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  5896. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  5897. // Used for setting prototype methods that IE8 chokes on.
  5898. var DELETE = 'delete';
  5899. // Constants describing the size of trie nodes.
  5900. var SHIFT = 5; // Resulted in best performance after ______?
  5901. var SIZE = 1 << SHIFT;
  5902. var MASK = SIZE - 1;
  5903. // A consistent shared value representing "not set" which equals nothing other
  5904. // than itself, and nothing that could be provided externally.
  5905. var NOT_SET = {};
  5906. // Boolean references, Rough equivalent of `bool &`.
  5907. var CHANGE_LENGTH = { value: false };
  5908. var DID_ALTER = { value: false };
  5909. function MakeRef(ref) {
  5910. ref.value = false;
  5911. return ref;
  5912. }
  5913. function SetRef(ref) {
  5914. ref && (ref.value = true);
  5915. }
  5916. // A function which returns a value representing an "owner" for transient writes
  5917. // to tries. The return value will only ever equal itself, and will not equal
  5918. // the return of any subsequent call of this function.
  5919. function OwnerID() {}
  5920. // http://jsperf.com/copy-array-inline
  5921. function arrCopy(arr, offset) {
  5922. offset = offset || 0;
  5923. var len = Math.max(0, arr.length - offset);
  5924. var newArr = new Array(len);
  5925. for (var ii = 0; ii < len; ii++) {
  5926. newArr[ii] = arr[ii + offset];
  5927. }
  5928. return newArr;
  5929. }
  5930. function ensureSize(iter) {
  5931. if (iter.size === undefined) {
  5932. iter.size = iter.__iterate(returnTrue);
  5933. }
  5934. return iter.size;
  5935. }
  5936. function wrapIndex(iter, index) {
  5937. // This implements "is array index" which the ECMAString spec defines as:
  5938. //
  5939. // A String property name P is an array index if and only if
  5940. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  5941. // to 2^32−1.
  5942. //
  5943. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  5944. if (typeof index !== 'number') {
  5945. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  5946. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  5947. return NaN;
  5948. }
  5949. index = uint32Index;
  5950. }
  5951. return index < 0 ? ensureSize(iter) + index : index;
  5952. }
  5953. function returnTrue() {
  5954. return true;
  5955. }
  5956. function wholeSlice(begin, end, size) {
  5957. return (begin === 0 || (size !== undefined && begin <= -size)) &&
  5958. (end === undefined || (size !== undefined && end >= size));
  5959. }
  5960. function resolveBegin(begin, size) {
  5961. return resolveIndex(begin, size, 0);
  5962. }
  5963. function resolveEnd(end, size) {
  5964. return resolveIndex(end, size, size);
  5965. }
  5966. function resolveIndex(index, size, defaultIndex) {
  5967. return index === undefined ?
  5968. defaultIndex :
  5969. index < 0 ?
  5970. Math.max(0, size + index) :
  5971. size === undefined ?
  5972. index :
  5973. Math.min(size, index);
  5974. }
  5975. /* global Symbol */
  5976. var ITERATE_KEYS = 0;
  5977. var ITERATE_VALUES = 1;
  5978. var ITERATE_ENTRIES = 2;
  5979. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  5980. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  5981. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  5982. function Iterator(next) {
  5983. this.next = next;
  5984. }
  5985. Iterator.prototype.toString = function() {
  5986. return '[Iterator]';
  5987. };
  5988. Iterator.KEYS = ITERATE_KEYS;
  5989. Iterator.VALUES = ITERATE_VALUES;
  5990. Iterator.ENTRIES = ITERATE_ENTRIES;
  5991. Iterator.prototype.inspect =
  5992. Iterator.prototype.toSource = function () { return this.toString(); };
  5993. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  5994. return this;
  5995. };
  5996. function iteratorValue(type, k, v, iteratorResult) {
  5997. var value = type === 0 ? k : type === 1 ? v : [k, v];
  5998. iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
  5999. value: value, done: false
  6000. });
  6001. return iteratorResult;
  6002. }
  6003. function iteratorDone() {
  6004. return { value: undefined, done: true };
  6005. }
  6006. function hasIterator(maybeIterable) {
  6007. return !!getIteratorFn(maybeIterable);
  6008. }
  6009. function isIterator(maybeIterator) {
  6010. return maybeIterator && typeof maybeIterator.next === 'function';
  6011. }
  6012. function getIterator(iterable) {
  6013. var iteratorFn = getIteratorFn(iterable);
  6014. return iteratorFn && iteratorFn.call(iterable);
  6015. }
  6016. function getIteratorFn(iterable) {
  6017. var iteratorFn = iterable && (
  6018. (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  6019. iterable[FAUX_ITERATOR_SYMBOL]
  6020. );
  6021. if (typeof iteratorFn === 'function') {
  6022. return iteratorFn;
  6023. }
  6024. }
  6025. function isArrayLike(value) {
  6026. return value && typeof value.length === 'number';
  6027. }
  6028. createClass(Seq, Iterable);
  6029. function Seq(value) {
  6030. return value === null || value === undefined ? emptySequence() :
  6031. isIterable(value) ? value.toSeq() : seqFromValue(value);
  6032. }
  6033. Seq.of = function(/*...values*/) {
  6034. return Seq(arguments);
  6035. };
  6036. Seq.prototype.toSeq = function() {
  6037. return this;
  6038. };
  6039. Seq.prototype.toString = function() {
  6040. return this.__toString('Seq {', '}');
  6041. };
  6042. Seq.prototype.cacheResult = function() {
  6043. if (!this._cache && this.__iterateUncached) {
  6044. this._cache = this.entrySeq().toArray();
  6045. this.size = this._cache.length;
  6046. }
  6047. return this;
  6048. };
  6049. // abstract __iterateUncached(fn, reverse)
  6050. Seq.prototype.__iterate = function(fn, reverse) {
  6051. return seqIterate(this, fn, reverse, true);
  6052. };
  6053. // abstract __iteratorUncached(type, reverse)
  6054. Seq.prototype.__iterator = function(type, reverse) {
  6055. return seqIterator(this, type, reverse, true);
  6056. };
  6057. createClass(KeyedSeq, Seq);
  6058. function KeyedSeq(value) {
  6059. return value === null || value === undefined ?
  6060. emptySequence().toKeyedSeq() :
  6061. isIterable(value) ?
  6062. (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
  6063. keyedSeqFromValue(value);
  6064. }
  6065. KeyedSeq.prototype.toKeyedSeq = function() {
  6066. return this;
  6067. };
  6068. createClass(IndexedSeq, Seq);
  6069. function IndexedSeq(value) {
  6070. return value === null || value === undefined ? emptySequence() :
  6071. !isIterable(value) ? indexedSeqFromValue(value) :
  6072. isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
  6073. }
  6074. IndexedSeq.of = function(/*...values*/) {
  6075. return IndexedSeq(arguments);
  6076. };
  6077. IndexedSeq.prototype.toIndexedSeq = function() {
  6078. return this;
  6079. };
  6080. IndexedSeq.prototype.toString = function() {
  6081. return this.__toString('Seq [', ']');
  6082. };
  6083. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  6084. return seqIterate(this, fn, reverse, false);
  6085. };
  6086. IndexedSeq.prototype.__iterator = function(type, reverse) {
  6087. return seqIterator(this, type, reverse, false);
  6088. };
  6089. createClass(SetSeq, Seq);
  6090. function SetSeq(value) {
  6091. return (
  6092. value === null || value === undefined ? emptySequence() :
  6093. !isIterable(value) ? indexedSeqFromValue(value) :
  6094. isKeyed(value) ? value.entrySeq() : value
  6095. ).toSetSeq();
  6096. }
  6097. SetSeq.of = function(/*...values*/) {
  6098. return SetSeq(arguments);
  6099. };
  6100. SetSeq.prototype.toSetSeq = function() {
  6101. return this;
  6102. };
  6103. Seq.isSeq = isSeq;
  6104. Seq.Keyed = KeyedSeq;
  6105. Seq.Set = SetSeq;
  6106. Seq.Indexed = IndexedSeq;
  6107. var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  6108. Seq.prototype[IS_SEQ_SENTINEL] = true;
  6109. createClass(ArraySeq, IndexedSeq);
  6110. function ArraySeq(array) {
  6111. this._array = array;
  6112. this.size = array.length;
  6113. }
  6114. ArraySeq.prototype.get = function(index, notSetValue) {
  6115. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  6116. };
  6117. ArraySeq.prototype.__iterate = function(fn, reverse) {
  6118. var array = this._array;
  6119. var maxIndex = array.length - 1;
  6120. for (var ii = 0; ii <= maxIndex; ii++) {
  6121. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  6122. return ii + 1;
  6123. }
  6124. }
  6125. return ii;
  6126. };
  6127. ArraySeq.prototype.__iterator = function(type, reverse) {
  6128. var array = this._array;
  6129. var maxIndex = array.length - 1;
  6130. var ii = 0;
  6131. return new Iterator(function()
  6132. {return ii > maxIndex ?
  6133. iteratorDone() :
  6134. iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
  6135. );
  6136. };
  6137. createClass(ObjectSeq, KeyedSeq);
  6138. function ObjectSeq(object) {
  6139. var keys = Object.keys(object);
  6140. this._object = object;
  6141. this._keys = keys;
  6142. this.size = keys.length;
  6143. }
  6144. ObjectSeq.prototype.get = function(key, notSetValue) {
  6145. if (notSetValue !== undefined && !this.has(key)) {
  6146. return notSetValue;
  6147. }
  6148. return this._object[key];
  6149. };
  6150. ObjectSeq.prototype.has = function(key) {
  6151. return this._object.hasOwnProperty(key);
  6152. };
  6153. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  6154. var object = this._object;
  6155. var keys = this._keys;
  6156. var maxIndex = keys.length - 1;
  6157. for (var ii = 0; ii <= maxIndex; ii++) {
  6158. var key = keys[reverse ? maxIndex - ii : ii];
  6159. if (fn(object[key], key, this) === false) {
  6160. return ii + 1;
  6161. }
  6162. }
  6163. return ii;
  6164. };
  6165. ObjectSeq.prototype.__iterator = function(type, reverse) {
  6166. var object = this._object;
  6167. var keys = this._keys;
  6168. var maxIndex = keys.length - 1;
  6169. var ii = 0;
  6170. return new Iterator(function() {
  6171. var key = keys[reverse ? maxIndex - ii : ii];
  6172. return ii++ > maxIndex ?
  6173. iteratorDone() :
  6174. iteratorValue(type, key, object[key]);
  6175. });
  6176. };
  6177. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  6178. createClass(IterableSeq, IndexedSeq);
  6179. function IterableSeq(iterable) {
  6180. this._iterable = iterable;
  6181. this.size = iterable.length || iterable.size;
  6182. }
  6183. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  6184. if (reverse) {
  6185. return this.cacheResult().__iterate(fn, reverse);
  6186. }
  6187. var iterable = this._iterable;
  6188. var iterator = getIterator(iterable);
  6189. var iterations = 0;
  6190. if (isIterator(iterator)) {
  6191. var step;
  6192. while (!(step = iterator.next()).done) {
  6193. if (fn(step.value, iterations++, this) === false) {
  6194. break;
  6195. }
  6196. }
  6197. }
  6198. return iterations;
  6199. };
  6200. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  6201. if (reverse) {
  6202. return this.cacheResult().__iterator(type, reverse);
  6203. }
  6204. var iterable = this._iterable;
  6205. var iterator = getIterator(iterable);
  6206. if (!isIterator(iterator)) {
  6207. return new Iterator(iteratorDone);
  6208. }
  6209. var iterations = 0;
  6210. return new Iterator(function() {
  6211. var step = iterator.next();
  6212. return step.done ? step : iteratorValue(type, iterations++, step.value);
  6213. });
  6214. };
  6215. createClass(IteratorSeq, IndexedSeq);
  6216. function IteratorSeq(iterator) {
  6217. this._iterator = iterator;
  6218. this._iteratorCache = [];
  6219. }
  6220. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  6221. if (reverse) {
  6222. return this.cacheResult().__iterate(fn, reverse);
  6223. }
  6224. var iterator = this._iterator;
  6225. var cache = this._iteratorCache;
  6226. var iterations = 0;
  6227. while (iterations < cache.length) {
  6228. if (fn(cache[iterations], iterations++, this) === false) {
  6229. return iterations;
  6230. }
  6231. }
  6232. var step;
  6233. while (!(step = iterator.next()).done) {
  6234. var val = step.value;
  6235. cache[iterations] = val;
  6236. if (fn(val, iterations++, this) === false) {
  6237. break;
  6238. }
  6239. }
  6240. return iterations;
  6241. };
  6242. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  6243. if (reverse) {
  6244. return this.cacheResult().__iterator(type, reverse);
  6245. }
  6246. var iterator = this._iterator;
  6247. var cache = this._iteratorCache;
  6248. var iterations = 0;
  6249. return new Iterator(function() {
  6250. if (iterations >= cache.length) {
  6251. var step = iterator.next();
  6252. if (step.done) {
  6253. return step;
  6254. }
  6255. cache[iterations] = step.value;
  6256. }
  6257. return iteratorValue(type, iterations, cache[iterations++]);
  6258. });
  6259. };
  6260. // # pragma Helper functions
  6261. function isSeq(maybeSeq) {
  6262. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  6263. }
  6264. var EMPTY_SEQ;
  6265. function emptySequence() {
  6266. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  6267. }
  6268. function keyedSeqFromValue(value) {
  6269. var seq =
  6270. Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
  6271. isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
  6272. hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
  6273. typeof value === 'object' ? new ObjectSeq(value) :
  6274. undefined;
  6275. if (!seq) {
  6276. throw new TypeError(
  6277. 'Expected Array or iterable object of [k, v] entries, '+
  6278. 'or keyed object: ' + value
  6279. );
  6280. }
  6281. return seq;
  6282. }
  6283. function indexedSeqFromValue(value) {
  6284. var seq = maybeIndexedSeqFromValue(value);
  6285. if (!seq) {
  6286. throw new TypeError(
  6287. 'Expected Array or iterable object of values: ' + value
  6288. );
  6289. }
  6290. return seq;
  6291. }
  6292. function seqFromValue(value) {
  6293. var seq = maybeIndexedSeqFromValue(value) ||
  6294. (typeof value === 'object' && new ObjectSeq(value));
  6295. if (!seq) {
  6296. throw new TypeError(
  6297. 'Expected Array or iterable object of values, or keyed object: ' + value
  6298. );
  6299. }
  6300. return seq;
  6301. }
  6302. function maybeIndexedSeqFromValue(value) {
  6303. return (
  6304. isArrayLike(value) ? new ArraySeq(value) :
  6305. isIterator(value) ? new IteratorSeq(value) :
  6306. hasIterator(value) ? new IterableSeq(value) :
  6307. undefined
  6308. );
  6309. }
  6310. function seqIterate(seq, fn, reverse, useKeys) {
  6311. var cache = seq._cache;
  6312. if (cache) {
  6313. var maxIndex = cache.length - 1;
  6314. for (var ii = 0; ii <= maxIndex; ii++) {
  6315. var entry = cache[reverse ? maxIndex - ii : ii];
  6316. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  6317. return ii + 1;
  6318. }
  6319. }
  6320. return ii;
  6321. }
  6322. return seq.__iterateUncached(fn, reverse);
  6323. }
  6324. function seqIterator(seq, type, reverse, useKeys) {
  6325. var cache = seq._cache;
  6326. if (cache) {
  6327. var maxIndex = cache.length - 1;
  6328. var ii = 0;
  6329. return new Iterator(function() {
  6330. var entry = cache[reverse ? maxIndex - ii : ii];
  6331. return ii++ > maxIndex ?
  6332. iteratorDone() :
  6333. iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  6334. });
  6335. }
  6336. return seq.__iteratorUncached(type, reverse);
  6337. }
  6338. function fromJS(json, converter) {
  6339. return converter ?
  6340. fromJSWith(converter, json, '', {'': json}) :
  6341. fromJSDefault(json);
  6342. }
  6343. function fromJSWith(converter, json, key, parentJSON) {
  6344. if (Array.isArray(json)) {
  6345. return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  6346. }
  6347. if (isPlainObj(json)) {
  6348. return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  6349. }
  6350. return json;
  6351. }
  6352. function fromJSDefault(json) {
  6353. if (Array.isArray(json)) {
  6354. return IndexedSeq(json).map(fromJSDefault).toList();
  6355. }
  6356. if (isPlainObj(json)) {
  6357. return KeyedSeq(json).map(fromJSDefault).toMap();
  6358. }
  6359. return json;
  6360. }
  6361. function isPlainObj(value) {
  6362. return value && (value.constructor === Object || value.constructor === undefined);
  6363. }
  6364. /**
  6365. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  6366. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  6367. *
  6368. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  6369. * value, which is different from the algorithm described by
  6370. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  6371. *
  6372. * This is extended further to allow Objects to describe the values they
  6373. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  6374. *
  6375. * Note: because of this extension, the key equality of Immutable.Map and the
  6376. * value equality of Immutable.Set will differ from ES6 Map and Set.
  6377. *
  6378. * ### Defining custom values
  6379. *
  6380. * The easiest way to describe the value an object represents is by implementing
  6381. * `valueOf`. For example, `Date` represents a value by returning a unix
  6382. * timestamp for `valueOf`:
  6383. *
  6384. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  6385. * var date2 = new Date(1234567890000);
  6386. * date1.valueOf(); // 1234567890000
  6387. * assert( date1 !== date2 );
  6388. * assert( Immutable.is( date1, date2 ) );
  6389. *
  6390. * Note: overriding `valueOf` may have other implications if you use this object
  6391. * where JavaScript expects a primitive, such as implicit string coercion.
  6392. *
  6393. * For more complex types, especially collections, implementing `valueOf` may
  6394. * not be performant. An alternative is to implement `equals` and `hashCode`.
  6395. *
  6396. * `equals` takes another object, presumably of similar type, and returns true
  6397. * if the it is equal. Equality is symmetrical, so the same result should be
  6398. * returned if this and the argument are flipped.
  6399. *
  6400. * assert( a.equals(b) === b.equals(a) );
  6401. *
  6402. * `hashCode` returns a 32bit integer number representing the object which will
  6403. * be used to determine how to store the value object in a Map or Set. You must
  6404. * provide both or neither methods, one must not exist without the other.
  6405. *
  6406. * Also, an important relationship between these methods must be upheld: if two
  6407. * values are equal, they *must* return the same hashCode. If the values are not
  6408. * equal, they might have the same hashCode; this is called a hash collision,
  6409. * and while undesirable for performance reasons, it is acceptable.
  6410. *
  6411. * if (a.equals(b)) {
  6412. * assert( a.hashCode() === b.hashCode() );
  6413. * }
  6414. *
  6415. * All Immutable collections implement `equals` and `hashCode`.
  6416. *
  6417. */
  6418. function is(valueA, valueB) {
  6419. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  6420. return true;
  6421. }
  6422. if (!valueA || !valueB) {
  6423. return false;
  6424. }
  6425. if (typeof valueA.valueOf === 'function' &&
  6426. typeof valueB.valueOf === 'function') {
  6427. valueA = valueA.valueOf();
  6428. valueB = valueB.valueOf();
  6429. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  6430. return true;
  6431. }
  6432. if (!valueA || !valueB) {
  6433. return false;
  6434. }
  6435. }
  6436. if (typeof valueA.equals === 'function' &&
  6437. typeof valueB.equals === 'function' &&
  6438. valueA.equals(valueB)) {
  6439. return true;
  6440. }
  6441. return false;
  6442. }
  6443. function deepEqual(a, b) {
  6444. if (a === b) {
  6445. return true;
  6446. }
  6447. if (
  6448. !isIterable(b) ||
  6449. a.size !== undefined && b.size !== undefined && a.size !== b.size ||
  6450. a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
  6451. isKeyed(a) !== isKeyed(b) ||
  6452. isIndexed(a) !== isIndexed(b) ||
  6453. isOrdered(a) !== isOrdered(b)
  6454. ) {
  6455. return false;
  6456. }
  6457. if (a.size === 0 && b.size === 0) {
  6458. return true;
  6459. }
  6460. var notAssociative = !isAssociative(a);
  6461. if (isOrdered(a)) {
  6462. var entries = a.entries();
  6463. return b.every(function(v, k) {
  6464. var entry = entries.next().value;
  6465. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  6466. }) && entries.next().done;
  6467. }
  6468. var flipped = false;
  6469. if (a.size === undefined) {
  6470. if (b.size === undefined) {
  6471. if (typeof a.cacheResult === 'function') {
  6472. a.cacheResult();
  6473. }
  6474. } else {
  6475. flipped = true;
  6476. var _ = a;
  6477. a = b;
  6478. b = _;
  6479. }
  6480. }
  6481. var allEqual = true;
  6482. var bSize = b.__iterate(function(v, k) {
  6483. if (notAssociative ? !a.has(v) :
  6484. flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
  6485. allEqual = false;
  6486. return false;
  6487. }
  6488. });
  6489. return allEqual && a.size === bSize;
  6490. }
  6491. createClass(Repeat, IndexedSeq);
  6492. function Repeat(value, times) {
  6493. if (!(this instanceof Repeat)) {
  6494. return new Repeat(value, times);
  6495. }
  6496. this._value = value;
  6497. this.size = times === undefined ? Infinity : Math.max(0, times);
  6498. if (this.size === 0) {
  6499. if (EMPTY_REPEAT) {
  6500. return EMPTY_REPEAT;
  6501. }
  6502. EMPTY_REPEAT = this;
  6503. }
  6504. }
  6505. Repeat.prototype.toString = function() {
  6506. if (this.size === 0) {
  6507. return 'Repeat []';
  6508. }
  6509. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  6510. };
  6511. Repeat.prototype.get = function(index, notSetValue) {
  6512. return this.has(index) ? this._value : notSetValue;
  6513. };
  6514. Repeat.prototype.includes = function(searchValue) {
  6515. return is(this._value, searchValue);
  6516. };
  6517. Repeat.prototype.slice = function(begin, end) {
  6518. var size = this.size;
  6519. return wholeSlice(begin, end, size) ? this :
  6520. new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
  6521. };
  6522. Repeat.prototype.reverse = function() {
  6523. return this;
  6524. };
  6525. Repeat.prototype.indexOf = function(searchValue) {
  6526. if (is(this._value, searchValue)) {
  6527. return 0;
  6528. }
  6529. return -1;
  6530. };
  6531. Repeat.prototype.lastIndexOf = function(searchValue) {
  6532. if (is(this._value, searchValue)) {
  6533. return this.size;
  6534. }
  6535. return -1;
  6536. };
  6537. Repeat.prototype.__iterate = function(fn, reverse) {
  6538. for (var ii = 0; ii < this.size; ii++) {
  6539. if (fn(this._value, ii, this) === false) {
  6540. return ii + 1;
  6541. }
  6542. }
  6543. return ii;
  6544. };
  6545. Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
  6546. var ii = 0;
  6547. return new Iterator(function()
  6548. {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
  6549. );
  6550. };
  6551. Repeat.prototype.equals = function(other) {
  6552. return other instanceof Repeat ?
  6553. is(this._value, other._value) :
  6554. deepEqual(other);
  6555. };
  6556. var EMPTY_REPEAT;
  6557. function invariant(condition, error) {
  6558. if (!condition) throw new Error(error);
  6559. }
  6560. createClass(Range, IndexedSeq);
  6561. function Range(start, end, step) {
  6562. if (!(this instanceof Range)) {
  6563. return new Range(start, end, step);
  6564. }
  6565. invariant(step !== 0, 'Cannot step a Range by 0');
  6566. start = start || 0;
  6567. if (end === undefined) {
  6568. end = Infinity;
  6569. }
  6570. step = step === undefined ? 1 : Math.abs(step);
  6571. if (end < start) {
  6572. step = -step;
  6573. }
  6574. this._start = start;
  6575. this._end = end;
  6576. this._step = step;
  6577. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  6578. if (this.size === 0) {
  6579. if (EMPTY_RANGE) {
  6580. return EMPTY_RANGE;
  6581. }
  6582. EMPTY_RANGE = this;
  6583. }
  6584. }
  6585. Range.prototype.toString = function() {
  6586. if (this.size === 0) {
  6587. return 'Range []';
  6588. }
  6589. return 'Range [ ' +
  6590. this._start + '...' + this._end +
  6591. (this._step > 1 ? ' by ' + this._step : '') +
  6592. ' ]';
  6593. };
  6594. Range.prototype.get = function(index, notSetValue) {
  6595. return this.has(index) ?
  6596. this._start + wrapIndex(this, index) * this._step :
  6597. notSetValue;
  6598. };
  6599. Range.prototype.includes = function(searchValue) {
  6600. var possibleIndex = (searchValue - this._start) / this._step;
  6601. return possibleIndex >= 0 &&
  6602. possibleIndex < this.size &&
  6603. possibleIndex === Math.floor(possibleIndex);
  6604. };
  6605. Range.prototype.slice = function(begin, end) {
  6606. if (wholeSlice(begin, end, this.size)) {
  6607. return this;
  6608. }
  6609. begin = resolveBegin(begin, this.size);
  6610. end = resolveEnd(end, this.size);
  6611. if (end <= begin) {
  6612. return new Range(0, 0);
  6613. }
  6614. return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
  6615. };
  6616. Range.prototype.indexOf = function(searchValue) {
  6617. var offsetValue = searchValue - this._start;
  6618. if (offsetValue % this._step === 0) {
  6619. var index = offsetValue / this._step;
  6620. if (index >= 0 && index < this.size) {
  6621. return index
  6622. }
  6623. }
  6624. return -1;
  6625. };
  6626. Range.prototype.lastIndexOf = function(searchValue) {
  6627. return this.indexOf(searchValue);
  6628. };
  6629. Range.prototype.__iterate = function(fn, reverse) {
  6630. var maxIndex = this.size - 1;
  6631. var step = this._step;
  6632. var value = reverse ? this._start + maxIndex * step : this._start;
  6633. for (var ii = 0; ii <= maxIndex; ii++) {
  6634. if (fn(value, ii, this) === false) {
  6635. return ii + 1;
  6636. }
  6637. value += reverse ? -step : step;
  6638. }
  6639. return ii;
  6640. };
  6641. Range.prototype.__iterator = function(type, reverse) {
  6642. var maxIndex = this.size - 1;
  6643. var step = this._step;
  6644. var value = reverse ? this._start + maxIndex * step : this._start;
  6645. var ii = 0;
  6646. return new Iterator(function() {
  6647. var v = value;
  6648. value += reverse ? -step : step;
  6649. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  6650. });
  6651. };
  6652. Range.prototype.equals = function(other) {
  6653. return other instanceof Range ?
  6654. this._start === other._start &&
  6655. this._end === other._end &&
  6656. this._step === other._step :
  6657. deepEqual(this, other);
  6658. };
  6659. var EMPTY_RANGE;
  6660. createClass(Collection, Iterable);
  6661. function Collection() {
  6662. throw TypeError('Abstract');
  6663. }
  6664. createClass(KeyedCollection, Collection);function KeyedCollection() {}
  6665. createClass(IndexedCollection, Collection);function IndexedCollection() {}
  6666. createClass(SetCollection, Collection);function SetCollection() {}
  6667. Collection.Keyed = KeyedCollection;
  6668. Collection.Indexed = IndexedCollection;
  6669. Collection.Set = SetCollection;
  6670. var imul =
  6671. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
  6672. Math.imul :
  6673. function imul(a, b) {
  6674. a = a | 0; // int
  6675. b = b | 0; // int
  6676. var c = a & 0xffff;
  6677. var d = b & 0xffff;
  6678. // Shift by 0 fixes the sign on the high part.
  6679. return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
  6680. };
  6681. // v8 has an optimization for storing 31-bit signed numbers.
  6682. // Values which have either 00 or 11 as the high order bits qualify.
  6683. // This function drops the highest order bit in a signed number, maintaining
  6684. // the sign bit.
  6685. function smi(i32) {
  6686. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
  6687. }
  6688. function hash(o) {
  6689. if (o === false || o === null || o === undefined) {
  6690. return 0;
  6691. }
  6692. if (typeof o.valueOf === 'function') {
  6693. o = o.valueOf();
  6694. if (o === false || o === null || o === undefined) {
  6695. return 0;
  6696. }
  6697. }
  6698. if (o === true) {
  6699. return 1;
  6700. }
  6701. var type = typeof o;
  6702. if (type === 'number') {
  6703. var h = o | 0;
  6704. if (h !== o) {
  6705. h ^= o * 0xFFFFFFFF;
  6706. }
  6707. while (o > 0xFFFFFFFF) {
  6708. o /= 0xFFFFFFFF;
  6709. h ^= o;
  6710. }
  6711. return smi(h);
  6712. }
  6713. if (type === 'string') {
  6714. return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
  6715. }
  6716. if (typeof o.hashCode === 'function') {
  6717. return o.hashCode();
  6718. }
  6719. if (type === 'object') {
  6720. return hashJSObj(o);
  6721. }
  6722. if (typeof o.toString === 'function') {
  6723. return hashString(o.toString());
  6724. }
  6725. throw new Error('Value type ' + type + ' cannot be hashed.');
  6726. }
  6727. function cachedHashString(string) {
  6728. var hash = stringHashCache[string];
  6729. if (hash === undefined) {
  6730. hash = hashString(string);
  6731. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  6732. STRING_HASH_CACHE_SIZE = 0;
  6733. stringHashCache = {};
  6734. }
  6735. STRING_HASH_CACHE_SIZE++;
  6736. stringHashCache[string] = hash;
  6737. }
  6738. return hash;
  6739. }
  6740. // http://jsperf.com/hashing-strings
  6741. function hashString(string) {
  6742. // This is the hash from JVM
  6743. // The hash code for a string is computed as
  6744. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  6745. // where s[i] is the ith character of the string and n is the length of
  6746. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  6747. // (exclusive) by dropping high bits.
  6748. var hash = 0;
  6749. for (var ii = 0; ii < string.length; ii++) {
  6750. hash = 31 * hash + string.charCodeAt(ii) | 0;
  6751. }
  6752. return smi(hash);
  6753. }
  6754. function hashJSObj(obj) {
  6755. var hash;
  6756. if (usingWeakMap) {
  6757. hash = weakMap.get(obj);
  6758. if (hash !== undefined) {
  6759. return hash;
  6760. }
  6761. }
  6762. hash = obj[UID_HASH_KEY];
  6763. if (hash !== undefined) {
  6764. return hash;
  6765. }
  6766. if (!canDefineProperty) {
  6767. hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  6768. if (hash !== undefined) {
  6769. return hash;
  6770. }
  6771. hash = getIENodeHash(obj);
  6772. if (hash !== undefined) {
  6773. return hash;
  6774. }
  6775. }
  6776. hash = ++objHashUID;
  6777. if (objHashUID & 0x40000000) {
  6778. objHashUID = 0;
  6779. }
  6780. if (usingWeakMap) {
  6781. weakMap.set(obj, hash);
  6782. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  6783. throw new Error('Non-extensible objects are not allowed as keys.');
  6784. } else if (canDefineProperty) {
  6785. Object.defineProperty(obj, UID_HASH_KEY, {
  6786. 'enumerable': false,
  6787. 'configurable': false,
  6788. 'writable': false,
  6789. 'value': hash
  6790. });
  6791. } else if (obj.propertyIsEnumerable !== undefined &&
  6792. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
  6793. // Since we can't define a non-enumerable property on the object
  6794. // we'll hijack one of the less-used non-enumerable properties to
  6795. // save our hash on it. Since this is a function it will not show up in
  6796. // `JSON.stringify` which is what we want.
  6797. obj.propertyIsEnumerable = function() {
  6798. return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
  6799. };
  6800. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  6801. } else if (obj.nodeType !== undefined) {
  6802. // At this point we couldn't get the IE `uniqueID` to use as a hash
  6803. // and we couldn't use a non-enumerable property to exploit the
  6804. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  6805. // itself.
  6806. obj[UID_HASH_KEY] = hash;
  6807. } else {
  6808. throw new Error('Unable to set a non-enumerable property on object.');
  6809. }
  6810. return hash;
  6811. }
  6812. // Get references to ES5 object methods.
  6813. var isExtensible = Object.isExtensible;
  6814. // True if Object.defineProperty works as expected. IE8 fails this test.
  6815. var canDefineProperty = (function() {
  6816. try {
  6817. Object.defineProperty({}, '@', {});
  6818. return true;
  6819. } catch (e) {
  6820. return false;
  6821. }
  6822. }());
  6823. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  6824. // and avoid memory leaks from the IE cloneNode bug.
  6825. function getIENodeHash(node) {
  6826. if (node && node.nodeType > 0) {
  6827. switch (node.nodeType) {
  6828. case 1: // Element
  6829. return node.uniqueID;
  6830. case 9: // Document
  6831. return node.documentElement && node.documentElement.uniqueID;
  6832. }
  6833. }
  6834. }
  6835. // If possible, use a WeakMap.
  6836. var usingWeakMap = typeof WeakMap === 'function';
  6837. var weakMap;
  6838. if (usingWeakMap) {
  6839. weakMap = new WeakMap();
  6840. }
  6841. var objHashUID = 0;
  6842. var UID_HASH_KEY = '__immutablehash__';
  6843. if (typeof Symbol === 'function') {
  6844. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  6845. }
  6846. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  6847. var STRING_HASH_CACHE_MAX_SIZE = 255;
  6848. var STRING_HASH_CACHE_SIZE = 0;
  6849. var stringHashCache = {};
  6850. function assertNotInfinite(size) {
  6851. invariant(
  6852. size !== Infinity,
  6853. 'Cannot perform this action with an infinite size.'
  6854. );
  6855. }
  6856. createClass(Map, KeyedCollection);
  6857. // @pragma Construction
  6858. function Map(value) {
  6859. return value === null || value === undefined ? emptyMap() :
  6860. isMap(value) && !isOrdered(value) ? value :
  6861. emptyMap().withMutations(function(map ) {
  6862. var iter = KeyedIterable(value);
  6863. assertNotInfinite(iter.size);
  6864. iter.forEach(function(v, k) {return map.set(k, v)});
  6865. });
  6866. }
  6867. Map.prototype.toString = function() {
  6868. return this.__toString('Map {', '}');
  6869. };
  6870. // @pragma Access
  6871. Map.prototype.get = function(k, notSetValue) {
  6872. return this._root ?
  6873. this._root.get(0, undefined, k, notSetValue) :
  6874. notSetValue;
  6875. };
  6876. // @pragma Modification
  6877. Map.prototype.set = function(k, v) {
  6878. return updateMap(this, k, v);
  6879. };
  6880. Map.prototype.setIn = function(keyPath, v) {
  6881. return this.updateIn(keyPath, NOT_SET, function() {return v});
  6882. };
  6883. Map.prototype.remove = function(k) {
  6884. return updateMap(this, k, NOT_SET);
  6885. };
  6886. Map.prototype.deleteIn = function(keyPath) {
  6887. return this.updateIn(keyPath, function() {return NOT_SET});
  6888. };
  6889. Map.prototype.update = function(k, notSetValue, updater) {
  6890. return arguments.length === 1 ?
  6891. k(this) :
  6892. this.updateIn([k], notSetValue, updater);
  6893. };
  6894. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  6895. if (!updater) {
  6896. updater = notSetValue;
  6897. notSetValue = undefined;
  6898. }
  6899. var updatedValue = updateInDeepMap(
  6900. this,
  6901. forceIterator(keyPath),
  6902. notSetValue,
  6903. updater
  6904. );
  6905. return updatedValue === NOT_SET ? undefined : updatedValue;
  6906. };
  6907. Map.prototype.clear = function() {
  6908. if (this.size === 0) {
  6909. return this;
  6910. }
  6911. if (this.__ownerID) {
  6912. this.size = 0;
  6913. this._root = null;
  6914. this.__hash = undefined;
  6915. this.__altered = true;
  6916. return this;
  6917. }
  6918. return emptyMap();
  6919. };
  6920. // @pragma Composition
  6921. Map.prototype.merge = function(/*...iters*/) {
  6922. return mergeIntoMapWith(this, undefined, arguments);
  6923. };
  6924. Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  6925. return mergeIntoMapWith(this, merger, iters);
  6926. };
  6927. Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  6928. return this.updateIn(
  6929. keyPath,
  6930. emptyMap(),
  6931. function(m ) {return typeof m.merge === 'function' ?
  6932. m.merge.apply(m, iters) :
  6933. iters[iters.length - 1]}
  6934. );
  6935. };
  6936. Map.prototype.mergeDeep = function(/*...iters*/) {
  6937. return mergeIntoMapWith(this, deepMerger, arguments);
  6938. };
  6939. Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  6940. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  6941. };
  6942. Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  6943. return this.updateIn(
  6944. keyPath,
  6945. emptyMap(),
  6946. function(m ) {return typeof m.mergeDeep === 'function' ?
  6947. m.mergeDeep.apply(m, iters) :
  6948. iters[iters.length - 1]}
  6949. );
  6950. };
  6951. Map.prototype.sort = function(comparator) {
  6952. // Late binding
  6953. return OrderedMap(sortFactory(this, comparator));
  6954. };
  6955. Map.prototype.sortBy = function(mapper, comparator) {
  6956. // Late binding
  6957. return OrderedMap(sortFactory(this, comparator, mapper));
  6958. };
  6959. // @pragma Mutability
  6960. Map.prototype.withMutations = function(fn) {
  6961. var mutable = this.asMutable();
  6962. fn(mutable);
  6963. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  6964. };
  6965. Map.prototype.asMutable = function() {
  6966. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  6967. };
  6968. Map.prototype.asImmutable = function() {
  6969. return this.__ensureOwner();
  6970. };
  6971. Map.prototype.wasAltered = function() {
  6972. return this.__altered;
  6973. };
  6974. Map.prototype.__iterator = function(type, reverse) {
  6975. return new MapIterator(this, type, reverse);
  6976. };
  6977. Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  6978. var iterations = 0;
  6979. this._root && this._root.iterate(function(entry ) {
  6980. iterations++;
  6981. return fn(entry[1], entry[0], this$0);
  6982. }, reverse);
  6983. return iterations;
  6984. };
  6985. Map.prototype.__ensureOwner = function(ownerID) {
  6986. if (ownerID === this.__ownerID) {
  6987. return this;
  6988. }
  6989. if (!ownerID) {
  6990. this.__ownerID = ownerID;
  6991. this.__altered = false;
  6992. return this;
  6993. }
  6994. return makeMap(this.size, this._root, ownerID, this.__hash);
  6995. };
  6996. function isMap(maybeMap) {
  6997. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  6998. }
  6999. Map.isMap = isMap;
  7000. var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  7001. var MapPrototype = Map.prototype;
  7002. MapPrototype[IS_MAP_SENTINEL] = true;
  7003. MapPrototype[DELETE] = MapPrototype.remove;
  7004. MapPrototype.removeIn = MapPrototype.deleteIn;
  7005. // #pragma Trie Nodes
  7006. function ArrayMapNode(ownerID, entries) {
  7007. this.ownerID = ownerID;
  7008. this.entries = entries;
  7009. }
  7010. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  7011. var entries = this.entries;
  7012. for (var ii = 0, len = entries.length; ii < len; ii++) {
  7013. if (is(key, entries[ii][0])) {
  7014. return entries[ii][1];
  7015. }
  7016. }
  7017. return notSetValue;
  7018. };
  7019. ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7020. var removed = value === NOT_SET;
  7021. var entries = this.entries;
  7022. var idx = 0;
  7023. for (var len = entries.length; idx < len; idx++) {
  7024. if (is(key, entries[idx][0])) {
  7025. break;
  7026. }
  7027. }
  7028. var exists = idx < len;
  7029. if (exists ? entries[idx][1] === value : removed) {
  7030. return this;
  7031. }
  7032. SetRef(didAlter);
  7033. (removed || !exists) && SetRef(didChangeSize);
  7034. if (removed && entries.length === 1) {
  7035. return; // undefined
  7036. }
  7037. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  7038. return createNodes(ownerID, entries, key, value);
  7039. }
  7040. var isEditable = ownerID && ownerID === this.ownerID;
  7041. var newEntries = isEditable ? entries : arrCopy(entries);
  7042. if (exists) {
  7043. if (removed) {
  7044. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  7045. } else {
  7046. newEntries[idx] = [key, value];
  7047. }
  7048. } else {
  7049. newEntries.push([key, value]);
  7050. }
  7051. if (isEditable) {
  7052. this.entries = newEntries;
  7053. return this;
  7054. }
  7055. return new ArrayMapNode(ownerID, newEntries);
  7056. };
  7057. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  7058. this.ownerID = ownerID;
  7059. this.bitmap = bitmap;
  7060. this.nodes = nodes;
  7061. }
  7062. BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  7063. if (keyHash === undefined) {
  7064. keyHash = hash(key);
  7065. }
  7066. var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
  7067. var bitmap = this.bitmap;
  7068. return (bitmap & bit) === 0 ? notSetValue :
  7069. this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
  7070. };
  7071. BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7072. if (keyHash === undefined) {
  7073. keyHash = hash(key);
  7074. }
  7075. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  7076. var bit = 1 << keyHashFrag;
  7077. var bitmap = this.bitmap;
  7078. var exists = (bitmap & bit) !== 0;
  7079. if (!exists && value === NOT_SET) {
  7080. return this;
  7081. }
  7082. var idx = popCount(bitmap & (bit - 1));
  7083. var nodes = this.nodes;
  7084. var node = exists ? nodes[idx] : undefined;
  7085. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  7086. if (newNode === node) {
  7087. return this;
  7088. }
  7089. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  7090. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  7091. }
  7092. if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
  7093. return nodes[idx ^ 1];
  7094. }
  7095. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  7096. return newNode;
  7097. }
  7098. var isEditable = ownerID && ownerID === this.ownerID;
  7099. var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
  7100. var newNodes = exists ? newNode ?
  7101. setIn(nodes, idx, newNode, isEditable) :
  7102. spliceOut(nodes, idx, isEditable) :
  7103. spliceIn(nodes, idx, newNode, isEditable);
  7104. if (isEditable) {
  7105. this.bitmap = newBitmap;
  7106. this.nodes = newNodes;
  7107. return this;
  7108. }
  7109. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  7110. };
  7111. function HashArrayMapNode(ownerID, count, nodes) {
  7112. this.ownerID = ownerID;
  7113. this.count = count;
  7114. this.nodes = nodes;
  7115. }
  7116. HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  7117. if (keyHash === undefined) {
  7118. keyHash = hash(key);
  7119. }
  7120. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  7121. var node = this.nodes[idx];
  7122. return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
  7123. };
  7124. HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7125. if (keyHash === undefined) {
  7126. keyHash = hash(key);
  7127. }
  7128. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  7129. var removed = value === NOT_SET;
  7130. var nodes = this.nodes;
  7131. var node = nodes[idx];
  7132. if (removed && !node) {
  7133. return this;
  7134. }
  7135. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  7136. if (newNode === node) {
  7137. return this;
  7138. }
  7139. var newCount = this.count;
  7140. if (!node) {
  7141. newCount++;
  7142. } else if (!newNode) {
  7143. newCount--;
  7144. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  7145. return packNodes(ownerID, nodes, newCount, idx);
  7146. }
  7147. }
  7148. var isEditable = ownerID && ownerID === this.ownerID;
  7149. var newNodes = setIn(nodes, idx, newNode, isEditable);
  7150. if (isEditable) {
  7151. this.count = newCount;
  7152. this.nodes = newNodes;
  7153. return this;
  7154. }
  7155. return new HashArrayMapNode(ownerID, newCount, newNodes);
  7156. };
  7157. function HashCollisionNode(ownerID, keyHash, entries) {
  7158. this.ownerID = ownerID;
  7159. this.keyHash = keyHash;
  7160. this.entries = entries;
  7161. }
  7162. HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  7163. var entries = this.entries;
  7164. for (var ii = 0, len = entries.length; ii < len; ii++) {
  7165. if (is(key, entries[ii][0])) {
  7166. return entries[ii][1];
  7167. }
  7168. }
  7169. return notSetValue;
  7170. };
  7171. HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7172. if (keyHash === undefined) {
  7173. keyHash = hash(key);
  7174. }
  7175. var removed = value === NOT_SET;
  7176. if (keyHash !== this.keyHash) {
  7177. if (removed) {
  7178. return this;
  7179. }
  7180. SetRef(didAlter);
  7181. SetRef(didChangeSize);
  7182. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  7183. }
  7184. var entries = this.entries;
  7185. var idx = 0;
  7186. for (var len = entries.length; idx < len; idx++) {
  7187. if (is(key, entries[idx][0])) {
  7188. break;
  7189. }
  7190. }
  7191. var exists = idx < len;
  7192. if (exists ? entries[idx][1] === value : removed) {
  7193. return this;
  7194. }
  7195. SetRef(didAlter);
  7196. (removed || !exists) && SetRef(didChangeSize);
  7197. if (removed && len === 2) {
  7198. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  7199. }
  7200. var isEditable = ownerID && ownerID === this.ownerID;
  7201. var newEntries = isEditable ? entries : arrCopy(entries);
  7202. if (exists) {
  7203. if (removed) {
  7204. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  7205. } else {
  7206. newEntries[idx] = [key, value];
  7207. }
  7208. } else {
  7209. newEntries.push([key, value]);
  7210. }
  7211. if (isEditable) {
  7212. this.entries = newEntries;
  7213. return this;
  7214. }
  7215. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  7216. };
  7217. function ValueNode(ownerID, keyHash, entry) {
  7218. this.ownerID = ownerID;
  7219. this.keyHash = keyHash;
  7220. this.entry = entry;
  7221. }
  7222. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  7223. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  7224. };
  7225. ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7226. var removed = value === NOT_SET;
  7227. var keyMatch = is(key, this.entry[0]);
  7228. if (keyMatch ? value === this.entry[1] : removed) {
  7229. return this;
  7230. }
  7231. SetRef(didAlter);
  7232. if (removed) {
  7233. SetRef(didChangeSize);
  7234. return; // undefined
  7235. }
  7236. if (keyMatch) {
  7237. if (ownerID && ownerID === this.ownerID) {
  7238. this.entry[1] = value;
  7239. return this;
  7240. }
  7241. return new ValueNode(ownerID, this.keyHash, [key, value]);
  7242. }
  7243. SetRef(didChangeSize);
  7244. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  7245. };
  7246. // #pragma Iterators
  7247. ArrayMapNode.prototype.iterate =
  7248. HashCollisionNode.prototype.iterate = function (fn, reverse) {
  7249. var entries = this.entries;
  7250. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  7251. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  7252. return false;
  7253. }
  7254. }
  7255. };
  7256. BitmapIndexedNode.prototype.iterate =
  7257. HashArrayMapNode.prototype.iterate = function (fn, reverse) {
  7258. var nodes = this.nodes;
  7259. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  7260. var node = nodes[reverse ? maxIndex - ii : ii];
  7261. if (node && node.iterate(fn, reverse) === false) {
  7262. return false;
  7263. }
  7264. }
  7265. };
  7266. ValueNode.prototype.iterate = function (fn, reverse) {
  7267. return fn(this.entry);
  7268. };
  7269. createClass(MapIterator, Iterator);
  7270. function MapIterator(map, type, reverse) {
  7271. this._type = type;
  7272. this._reverse = reverse;
  7273. this._stack = map._root && mapIteratorFrame(map._root);
  7274. }
  7275. MapIterator.prototype.next = function() {
  7276. var type = this._type;
  7277. var stack = this._stack;
  7278. while (stack) {
  7279. var node = stack.node;
  7280. var index = stack.index++;
  7281. var maxIndex;
  7282. if (node.entry) {
  7283. if (index === 0) {
  7284. return mapIteratorValue(type, node.entry);
  7285. }
  7286. } else if (node.entries) {
  7287. maxIndex = node.entries.length - 1;
  7288. if (index <= maxIndex) {
  7289. return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
  7290. }
  7291. } else {
  7292. maxIndex = node.nodes.length - 1;
  7293. if (index <= maxIndex) {
  7294. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  7295. if (subNode) {
  7296. if (subNode.entry) {
  7297. return mapIteratorValue(type, subNode.entry);
  7298. }
  7299. stack = this._stack = mapIteratorFrame(subNode, stack);
  7300. }
  7301. continue;
  7302. }
  7303. }
  7304. stack = this._stack = this._stack.__prev;
  7305. }
  7306. return iteratorDone();
  7307. };
  7308. function mapIteratorValue(type, entry) {
  7309. return iteratorValue(type, entry[0], entry[1]);
  7310. }
  7311. function mapIteratorFrame(node, prev) {
  7312. return {
  7313. node: node,
  7314. index: 0,
  7315. __prev: prev
  7316. };
  7317. }
  7318. function makeMap(size, root, ownerID, hash) {
  7319. var map = Object.create(MapPrototype);
  7320. map.size = size;
  7321. map._root = root;
  7322. map.__ownerID = ownerID;
  7323. map.__hash = hash;
  7324. map.__altered = false;
  7325. return map;
  7326. }
  7327. var EMPTY_MAP;
  7328. function emptyMap() {
  7329. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  7330. }
  7331. function updateMap(map, k, v) {
  7332. var newRoot;
  7333. var newSize;
  7334. if (!map._root) {
  7335. if (v === NOT_SET) {
  7336. return map;
  7337. }
  7338. newSize = 1;
  7339. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  7340. } else {
  7341. var didChangeSize = MakeRef(CHANGE_LENGTH);
  7342. var didAlter = MakeRef(DID_ALTER);
  7343. newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
  7344. if (!didAlter.value) {
  7345. return map;
  7346. }
  7347. newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
  7348. }
  7349. if (map.__ownerID) {
  7350. map.size = newSize;
  7351. map._root = newRoot;
  7352. map.__hash = undefined;
  7353. map.__altered = true;
  7354. return map;
  7355. }
  7356. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  7357. }
  7358. function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7359. if (!node) {
  7360. if (value === NOT_SET) {
  7361. return node;
  7362. }
  7363. SetRef(didAlter);
  7364. SetRef(didChangeSize);
  7365. return new ValueNode(ownerID, keyHash, [key, value]);
  7366. }
  7367. return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
  7368. }
  7369. function isLeafNode(node) {
  7370. return node.constructor === ValueNode || node.constructor === HashCollisionNode;
  7371. }
  7372. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  7373. if (node.keyHash === keyHash) {
  7374. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  7375. }
  7376. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  7377. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  7378. var newNode;
  7379. var nodes = idx1 === idx2 ?
  7380. [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
  7381. ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
  7382. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  7383. }
  7384. function createNodes(ownerID, entries, key, value) {
  7385. if (!ownerID) {
  7386. ownerID = new OwnerID();
  7387. }
  7388. var node = new ValueNode(ownerID, hash(key), [key, value]);
  7389. for (var ii = 0; ii < entries.length; ii++) {
  7390. var entry = entries[ii];
  7391. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  7392. }
  7393. return node;
  7394. }
  7395. function packNodes(ownerID, nodes, count, excluding) {
  7396. var bitmap = 0;
  7397. var packedII = 0;
  7398. var packedNodes = new Array(count);
  7399. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  7400. var node = nodes[ii];
  7401. if (node !== undefined && ii !== excluding) {
  7402. bitmap |= bit;
  7403. packedNodes[packedII++] = node;
  7404. }
  7405. }
  7406. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  7407. }
  7408. function expandNodes(ownerID, nodes, bitmap, including, node) {
  7409. var count = 0;
  7410. var expandedNodes = new Array(SIZE);
  7411. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  7412. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  7413. }
  7414. expandedNodes[including] = node;
  7415. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  7416. }
  7417. function mergeIntoMapWith(map, merger, iterables) {
  7418. var iters = [];
  7419. for (var ii = 0; ii < iterables.length; ii++) {
  7420. var value = iterables[ii];
  7421. var iter = KeyedIterable(value);
  7422. if (!isIterable(value)) {
  7423. iter = iter.map(function(v ) {return fromJS(v)});
  7424. }
  7425. iters.push(iter);
  7426. }
  7427. return mergeIntoCollectionWith(map, merger, iters);
  7428. }
  7429. function deepMerger(existing, value, key) {
  7430. return existing && existing.mergeDeep && isIterable(value) ?
  7431. existing.mergeDeep(value) :
  7432. is(existing, value) ? existing : value;
  7433. }
  7434. function deepMergerWith(merger) {
  7435. return function(existing, value, key) {
  7436. if (existing && existing.mergeDeepWith && isIterable(value)) {
  7437. return existing.mergeDeepWith(merger, value);
  7438. }
  7439. var nextValue = merger(existing, value, key);
  7440. return is(existing, nextValue) ? existing : nextValue;
  7441. };
  7442. }
  7443. function mergeIntoCollectionWith(collection, merger, iters) {
  7444. iters = iters.filter(function(x ) {return x.size !== 0});
  7445. if (iters.length === 0) {
  7446. return collection;
  7447. }
  7448. if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
  7449. return collection.constructor(iters[0]);
  7450. }
  7451. return collection.withMutations(function(collection ) {
  7452. var mergeIntoMap = merger ?
  7453. function(value, key) {
  7454. collection.update(key, NOT_SET, function(existing )
  7455. {return existing === NOT_SET ? value : merger(existing, value, key)}
  7456. );
  7457. } :
  7458. function(value, key) {
  7459. collection.set(key, value);
  7460. };
  7461. for (var ii = 0; ii < iters.length; ii++) {
  7462. iters[ii].forEach(mergeIntoMap);
  7463. }
  7464. });
  7465. }
  7466. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  7467. var isNotSet = existing === NOT_SET;
  7468. var step = keyPathIter.next();
  7469. if (step.done) {
  7470. var existingValue = isNotSet ? notSetValue : existing;
  7471. var newValue = updater(existingValue);
  7472. return newValue === existingValue ? existing : newValue;
  7473. }
  7474. invariant(
  7475. isNotSet || (existing && existing.set),
  7476. 'invalid keyPath'
  7477. );
  7478. var key = step.value;
  7479. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  7480. var nextUpdated = updateInDeepMap(
  7481. nextExisting,
  7482. keyPathIter,
  7483. notSetValue,
  7484. updater
  7485. );
  7486. return nextUpdated === nextExisting ? existing :
  7487. nextUpdated === NOT_SET ? existing.remove(key) :
  7488. (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  7489. }
  7490. function popCount(x) {
  7491. x = x - ((x >> 1) & 0x55555555);
  7492. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  7493. x = (x + (x >> 4)) & 0x0f0f0f0f;
  7494. x = x + (x >> 8);
  7495. x = x + (x >> 16);
  7496. return x & 0x7f;
  7497. }
  7498. function setIn(array, idx, val, canEdit) {
  7499. var newArray = canEdit ? array : arrCopy(array);
  7500. newArray[idx] = val;
  7501. return newArray;
  7502. }
  7503. function spliceIn(array, idx, val, canEdit) {
  7504. var newLen = array.length + 1;
  7505. if (canEdit && idx + 1 === newLen) {
  7506. array[idx] = val;
  7507. return array;
  7508. }
  7509. var newArray = new Array(newLen);
  7510. var after = 0;
  7511. for (var ii = 0; ii < newLen; ii++) {
  7512. if (ii === idx) {
  7513. newArray[ii] = val;
  7514. after = -1;
  7515. } else {
  7516. newArray[ii] = array[ii + after];
  7517. }
  7518. }
  7519. return newArray;
  7520. }
  7521. function spliceOut(array, idx, canEdit) {
  7522. var newLen = array.length - 1;
  7523. if (canEdit && idx === newLen) {
  7524. array.pop();
  7525. return array;
  7526. }
  7527. var newArray = new Array(newLen);
  7528. var after = 0;
  7529. for (var ii = 0; ii < newLen; ii++) {
  7530. if (ii === idx) {
  7531. after = 1;
  7532. }
  7533. newArray[ii] = array[ii + after];
  7534. }
  7535. return newArray;
  7536. }
  7537. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  7538. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  7539. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  7540. createClass(List, IndexedCollection);
  7541. // @pragma Construction
  7542. function List(value) {
  7543. var empty = emptyList();
  7544. if (value === null || value === undefined) {
  7545. return empty;
  7546. }
  7547. if (isList(value)) {
  7548. return value;
  7549. }
  7550. var iter = IndexedIterable(value);
  7551. var size = iter.size;
  7552. if (size === 0) {
  7553. return empty;
  7554. }
  7555. assertNotInfinite(size);
  7556. if (size > 0 && size < SIZE) {
  7557. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  7558. }
  7559. return empty.withMutations(function(list ) {
  7560. list.setSize(size);
  7561. iter.forEach(function(v, i) {return list.set(i, v)});
  7562. });
  7563. }
  7564. List.of = function(/*...values*/) {
  7565. return this(arguments);
  7566. };
  7567. List.prototype.toString = function() {
  7568. return this.__toString('List [', ']');
  7569. };
  7570. // @pragma Access
  7571. List.prototype.get = function(index, notSetValue) {
  7572. index = wrapIndex(this, index);
  7573. if (index >= 0 && index < this.size) {
  7574. index += this._origin;
  7575. var node = listNodeFor(this, index);
  7576. return node && node.array[index & MASK];
  7577. }
  7578. return notSetValue;
  7579. };
  7580. // @pragma Modification
  7581. List.prototype.set = function(index, value) {
  7582. return updateList(this, index, value);
  7583. };
  7584. List.prototype.remove = function(index) {
  7585. return !this.has(index) ? this :
  7586. index === 0 ? this.shift() :
  7587. index === this.size - 1 ? this.pop() :
  7588. this.splice(index, 1);
  7589. };
  7590. List.prototype.insert = function(index, value) {
  7591. return this.splice(index, 0, value);
  7592. };
  7593. List.prototype.clear = function() {
  7594. if (this.size === 0) {
  7595. return this;
  7596. }
  7597. if (this.__ownerID) {
  7598. this.size = this._origin = this._capacity = 0;
  7599. this._level = SHIFT;
  7600. this._root = this._tail = null;
  7601. this.__hash = undefined;
  7602. this.__altered = true;
  7603. return this;
  7604. }
  7605. return emptyList();
  7606. };
  7607. List.prototype.push = function(/*...values*/) {
  7608. var values = arguments;
  7609. var oldSize = this.size;
  7610. return this.withMutations(function(list ) {
  7611. setListBounds(list, 0, oldSize + values.length);
  7612. for (var ii = 0; ii < values.length; ii++) {
  7613. list.set(oldSize + ii, values[ii]);
  7614. }
  7615. });
  7616. };
  7617. List.prototype.pop = function() {
  7618. return setListBounds(this, 0, -1);
  7619. };
  7620. List.prototype.unshift = function(/*...values*/) {
  7621. var values = arguments;
  7622. return this.withMutations(function(list ) {
  7623. setListBounds(list, -values.length);
  7624. for (var ii = 0; ii < values.length; ii++) {
  7625. list.set(ii, values[ii]);
  7626. }
  7627. });
  7628. };
  7629. List.prototype.shift = function() {
  7630. return setListBounds(this, 1);
  7631. };
  7632. // @pragma Composition
  7633. List.prototype.merge = function(/*...iters*/) {
  7634. return mergeIntoListWith(this, undefined, arguments);
  7635. };
  7636. List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  7637. return mergeIntoListWith(this, merger, iters);
  7638. };
  7639. List.prototype.mergeDeep = function(/*...iters*/) {
  7640. return mergeIntoListWith(this, deepMerger, arguments);
  7641. };
  7642. List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  7643. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  7644. };
  7645. List.prototype.setSize = function(size) {
  7646. return setListBounds(this, 0, size);
  7647. };
  7648. // @pragma Iteration
  7649. List.prototype.slice = function(begin, end) {
  7650. var size = this.size;
  7651. if (wholeSlice(begin, end, size)) {
  7652. return this;
  7653. }
  7654. return setListBounds(
  7655. this,
  7656. resolveBegin(begin, size),
  7657. resolveEnd(end, size)
  7658. );
  7659. };
  7660. List.prototype.__iterator = function(type, reverse) {
  7661. var index = 0;
  7662. var values = iterateList(this, reverse);
  7663. return new Iterator(function() {
  7664. var value = values();
  7665. return value === DONE ?
  7666. iteratorDone() :
  7667. iteratorValue(type, index++, value);
  7668. });
  7669. };
  7670. List.prototype.__iterate = function(fn, reverse) {
  7671. var index = 0;
  7672. var values = iterateList(this, reverse);
  7673. var value;
  7674. while ((value = values()) !== DONE) {
  7675. if (fn(value, index++, this) === false) {
  7676. break;
  7677. }
  7678. }
  7679. return index;
  7680. };
  7681. List.prototype.__ensureOwner = function(ownerID) {
  7682. if (ownerID === this.__ownerID) {
  7683. return this;
  7684. }
  7685. if (!ownerID) {
  7686. this.__ownerID = ownerID;
  7687. return this;
  7688. }
  7689. return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
  7690. };
  7691. function isList(maybeList) {
  7692. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  7693. }
  7694. List.isList = isList;
  7695. var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  7696. var ListPrototype = List.prototype;
  7697. ListPrototype[IS_LIST_SENTINEL] = true;
  7698. ListPrototype[DELETE] = ListPrototype.remove;
  7699. ListPrototype.setIn = MapPrototype.setIn;
  7700. ListPrototype.deleteIn =
  7701. ListPrototype.removeIn = MapPrototype.removeIn;
  7702. ListPrototype.update = MapPrototype.update;
  7703. ListPrototype.updateIn = MapPrototype.updateIn;
  7704. ListPrototype.mergeIn = MapPrototype.mergeIn;
  7705. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  7706. ListPrototype.withMutations = MapPrototype.withMutations;
  7707. ListPrototype.asMutable = MapPrototype.asMutable;
  7708. ListPrototype.asImmutable = MapPrototype.asImmutable;
  7709. ListPrototype.wasAltered = MapPrototype.wasAltered;
  7710. function VNode(array, ownerID) {
  7711. this.array = array;
  7712. this.ownerID = ownerID;
  7713. }
  7714. // TODO: seems like these methods are very similar
  7715. VNode.prototype.removeBefore = function(ownerID, level, index) {
  7716. if (index === level ? 1 << level : this.array.length === 0) {
  7717. return this;
  7718. }
  7719. var originIndex = (index >>> level) & MASK;
  7720. if (originIndex >= this.array.length) {
  7721. return new VNode([], ownerID);
  7722. }
  7723. var removingFirst = originIndex === 0;
  7724. var newChild;
  7725. if (level > 0) {
  7726. var oldChild = this.array[originIndex];
  7727. newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  7728. if (newChild === oldChild && removingFirst) {
  7729. return this;
  7730. }
  7731. }
  7732. if (removingFirst && !newChild) {
  7733. return this;
  7734. }
  7735. var editable = editableVNode(this, ownerID);
  7736. if (!removingFirst) {
  7737. for (var ii = 0; ii < originIndex; ii++) {
  7738. editable.array[ii] = undefined;
  7739. }
  7740. }
  7741. if (newChild) {
  7742. editable.array[originIndex] = newChild;
  7743. }
  7744. return editable;
  7745. };
  7746. VNode.prototype.removeAfter = function(ownerID, level, index) {
  7747. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  7748. return this;
  7749. }
  7750. var sizeIndex = ((index - 1) >>> level) & MASK;
  7751. if (sizeIndex >= this.array.length) {
  7752. return this;
  7753. }
  7754. var newChild;
  7755. if (level > 0) {
  7756. var oldChild = this.array[sizeIndex];
  7757. newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  7758. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  7759. return this;
  7760. }
  7761. }
  7762. var editable = editableVNode(this, ownerID);
  7763. editable.array.splice(sizeIndex + 1);
  7764. if (newChild) {
  7765. editable.array[sizeIndex] = newChild;
  7766. }
  7767. return editable;
  7768. };
  7769. var DONE = {};
  7770. function iterateList(list, reverse) {
  7771. var left = list._origin;
  7772. var right = list._capacity;
  7773. var tailPos = getTailOffset(right);
  7774. var tail = list._tail;
  7775. return iterateNodeOrLeaf(list._root, list._level, 0);
  7776. function iterateNodeOrLeaf(node, level, offset) {
  7777. return level === 0 ?
  7778. iterateLeaf(node, offset) :
  7779. iterateNode(node, level, offset);
  7780. }
  7781. function iterateLeaf(node, offset) {
  7782. var array = offset === tailPos ? tail && tail.array : node && node.array;
  7783. var from = offset > left ? 0 : left - offset;
  7784. var to = right - offset;
  7785. if (to > SIZE) {
  7786. to = SIZE;
  7787. }
  7788. return function() {
  7789. if (from === to) {
  7790. return DONE;
  7791. }
  7792. var idx = reverse ? --to : from++;
  7793. return array && array[idx];
  7794. };
  7795. }
  7796. function iterateNode(node, level, offset) {
  7797. var values;
  7798. var array = node && node.array;
  7799. var from = offset > left ? 0 : (left - offset) >> level;
  7800. var to = ((right - offset) >> level) + 1;
  7801. if (to > SIZE) {
  7802. to = SIZE;
  7803. }
  7804. return function() {
  7805. do {
  7806. if (values) {
  7807. var value = values();
  7808. if (value !== DONE) {
  7809. return value;
  7810. }
  7811. values = null;
  7812. }
  7813. if (from === to) {
  7814. return DONE;
  7815. }
  7816. var idx = reverse ? --to : from++;
  7817. values = iterateNodeOrLeaf(
  7818. array && array[idx], level - SHIFT, offset + (idx << level)
  7819. );
  7820. } while (true);
  7821. };
  7822. }
  7823. }
  7824. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  7825. var list = Object.create(ListPrototype);
  7826. list.size = capacity - origin;
  7827. list._origin = origin;
  7828. list._capacity = capacity;
  7829. list._level = level;
  7830. list._root = root;
  7831. list._tail = tail;
  7832. list.__ownerID = ownerID;
  7833. list.__hash = hash;
  7834. list.__altered = false;
  7835. return list;
  7836. }
  7837. var EMPTY_LIST;
  7838. function emptyList() {
  7839. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  7840. }
  7841. function updateList(list, index, value) {
  7842. index = wrapIndex(list, index);
  7843. if (index !== index) {
  7844. return list;
  7845. }
  7846. if (index >= list.size || index < 0) {
  7847. return list.withMutations(function(list ) {
  7848. index < 0 ?
  7849. setListBounds(list, index).set(0, value) :
  7850. setListBounds(list, 0, index + 1).set(index, value);
  7851. });
  7852. }
  7853. index += list._origin;
  7854. var newTail = list._tail;
  7855. var newRoot = list._root;
  7856. var didAlter = MakeRef(DID_ALTER);
  7857. if (index >= getTailOffset(list._capacity)) {
  7858. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  7859. } else {
  7860. newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
  7861. }
  7862. if (!didAlter.value) {
  7863. return list;
  7864. }
  7865. if (list.__ownerID) {
  7866. list._root = newRoot;
  7867. list._tail = newTail;
  7868. list.__hash = undefined;
  7869. list.__altered = true;
  7870. return list;
  7871. }
  7872. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  7873. }
  7874. function updateVNode(node, ownerID, level, index, value, didAlter) {
  7875. var idx = (index >>> level) & MASK;
  7876. var nodeHas = node && idx < node.array.length;
  7877. if (!nodeHas && value === undefined) {
  7878. return node;
  7879. }
  7880. var newNode;
  7881. if (level > 0) {
  7882. var lowerNode = node && node.array[idx];
  7883. var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
  7884. if (newLowerNode === lowerNode) {
  7885. return node;
  7886. }
  7887. newNode = editableVNode(node, ownerID);
  7888. newNode.array[idx] = newLowerNode;
  7889. return newNode;
  7890. }
  7891. if (nodeHas && node.array[idx] === value) {
  7892. return node;
  7893. }
  7894. SetRef(didAlter);
  7895. newNode = editableVNode(node, ownerID);
  7896. if (value === undefined && idx === newNode.array.length - 1) {
  7897. newNode.array.pop();
  7898. } else {
  7899. newNode.array[idx] = value;
  7900. }
  7901. return newNode;
  7902. }
  7903. function editableVNode(node, ownerID) {
  7904. if (ownerID && node && ownerID === node.ownerID) {
  7905. return node;
  7906. }
  7907. return new VNode(node ? node.array.slice() : [], ownerID);
  7908. }
  7909. function listNodeFor(list, rawIndex) {
  7910. if (rawIndex >= getTailOffset(list._capacity)) {
  7911. return list._tail;
  7912. }
  7913. if (rawIndex < 1 << (list._level + SHIFT)) {
  7914. var node = list._root;
  7915. var level = list._level;
  7916. while (node && level > 0) {
  7917. node = node.array[(rawIndex >>> level) & MASK];
  7918. level -= SHIFT;
  7919. }
  7920. return node;
  7921. }
  7922. }
  7923. function setListBounds(list, begin, end) {
  7924. // Sanitize begin & end using this shorthand for ToInt32(argument)
  7925. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  7926. if (begin !== undefined) {
  7927. begin = begin | 0;
  7928. }
  7929. if (end !== undefined) {
  7930. end = end | 0;
  7931. }
  7932. var owner = list.__ownerID || new OwnerID();
  7933. var oldOrigin = list._origin;
  7934. var oldCapacity = list._capacity;
  7935. var newOrigin = oldOrigin + begin;
  7936. var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
  7937. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  7938. return list;
  7939. }
  7940. // If it's going to end after it starts, it's empty.
  7941. if (newOrigin >= newCapacity) {
  7942. return list.clear();
  7943. }
  7944. var newLevel = list._level;
  7945. var newRoot = list._root;
  7946. // New origin might need creating a higher root.
  7947. var offsetShift = 0;
  7948. while (newOrigin + offsetShift < 0) {
  7949. newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
  7950. newLevel += SHIFT;
  7951. offsetShift += 1 << newLevel;
  7952. }
  7953. if (offsetShift) {
  7954. newOrigin += offsetShift;
  7955. oldOrigin += offsetShift;
  7956. newCapacity += offsetShift;
  7957. oldCapacity += offsetShift;
  7958. }
  7959. var oldTailOffset = getTailOffset(oldCapacity);
  7960. var newTailOffset = getTailOffset(newCapacity);
  7961. // New size might need creating a higher root.
  7962. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  7963. newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
  7964. newLevel += SHIFT;
  7965. }
  7966. // Locate or create the new tail.
  7967. var oldTail = list._tail;
  7968. var newTail = newTailOffset < oldTailOffset ?
  7969. listNodeFor(list, newCapacity - 1) :
  7970. newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
  7971. // Merge Tail into tree.
  7972. if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
  7973. newRoot = editableVNode(newRoot, owner);
  7974. var node = newRoot;
  7975. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  7976. var idx = (oldTailOffset >>> level) & MASK;
  7977. node = node.array[idx] = editableVNode(node.array[idx], owner);
  7978. }
  7979. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  7980. }
  7981. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  7982. if (newCapacity < oldCapacity) {
  7983. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  7984. }
  7985. // If the new origin is within the tail, then we do not need a root.
  7986. if (newOrigin >= newTailOffset) {
  7987. newOrigin -= newTailOffset;
  7988. newCapacity -= newTailOffset;
  7989. newLevel = SHIFT;
  7990. newRoot = null;
  7991. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  7992. // Otherwise, if the root has been trimmed, garbage collect.
  7993. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  7994. offsetShift = 0;
  7995. // Identify the new top root node of the subtree of the old root.
  7996. while (newRoot) {
  7997. var beginIndex = (newOrigin >>> newLevel) & MASK;
  7998. if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
  7999. break;
  8000. }
  8001. if (beginIndex) {
  8002. offsetShift += (1 << newLevel) * beginIndex;
  8003. }
  8004. newLevel -= SHIFT;
  8005. newRoot = newRoot.array[beginIndex];
  8006. }
  8007. // Trim the new sides of the new root.
  8008. if (newRoot && newOrigin > oldOrigin) {
  8009. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  8010. }
  8011. if (newRoot && newTailOffset < oldTailOffset) {
  8012. newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
  8013. }
  8014. if (offsetShift) {
  8015. newOrigin -= offsetShift;
  8016. newCapacity -= offsetShift;
  8017. }
  8018. }
  8019. if (list.__ownerID) {
  8020. list.size = newCapacity - newOrigin;
  8021. list._origin = newOrigin;
  8022. list._capacity = newCapacity;
  8023. list._level = newLevel;
  8024. list._root = newRoot;
  8025. list._tail = newTail;
  8026. list.__hash = undefined;
  8027. list.__altered = true;
  8028. return list;
  8029. }
  8030. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  8031. }
  8032. function mergeIntoListWith(list, merger, iterables) {
  8033. var iters = [];
  8034. var maxSize = 0;
  8035. for (var ii = 0; ii < iterables.length; ii++) {
  8036. var value = iterables[ii];
  8037. var iter = IndexedIterable(value);
  8038. if (iter.size > maxSize) {
  8039. maxSize = iter.size;
  8040. }
  8041. if (!isIterable(value)) {
  8042. iter = iter.map(function(v ) {return fromJS(v)});
  8043. }
  8044. iters.push(iter);
  8045. }
  8046. if (maxSize > list.size) {
  8047. list = list.setSize(maxSize);
  8048. }
  8049. return mergeIntoCollectionWith(list, merger, iters);
  8050. }
  8051. function getTailOffset(size) {
  8052. return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
  8053. }
  8054. createClass(OrderedMap, Map);
  8055. // @pragma Construction
  8056. function OrderedMap(value) {
  8057. return value === null || value === undefined ? emptyOrderedMap() :
  8058. isOrderedMap(value) ? value :
  8059. emptyOrderedMap().withMutations(function(map ) {
  8060. var iter = KeyedIterable(value);
  8061. assertNotInfinite(iter.size);
  8062. iter.forEach(function(v, k) {return map.set(k, v)});
  8063. });
  8064. }
  8065. OrderedMap.of = function(/*...values*/) {
  8066. return this(arguments);
  8067. };
  8068. OrderedMap.prototype.toString = function() {
  8069. return this.__toString('OrderedMap {', '}');
  8070. };
  8071. // @pragma Access
  8072. OrderedMap.prototype.get = function(k, notSetValue) {
  8073. var index = this._map.get(k);
  8074. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  8075. };
  8076. // @pragma Modification
  8077. OrderedMap.prototype.clear = function() {
  8078. if (this.size === 0) {
  8079. return this;
  8080. }
  8081. if (this.__ownerID) {
  8082. this.size = 0;
  8083. this._map.clear();
  8084. this._list.clear();
  8085. return this;
  8086. }
  8087. return emptyOrderedMap();
  8088. };
  8089. OrderedMap.prototype.set = function(k, v) {
  8090. return updateOrderedMap(this, k, v);
  8091. };
  8092. OrderedMap.prototype.remove = function(k) {
  8093. return updateOrderedMap(this, k, NOT_SET);
  8094. };
  8095. OrderedMap.prototype.wasAltered = function() {
  8096. return this._map.wasAltered() || this._list.wasAltered();
  8097. };
  8098. OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8099. return this._list.__iterate(
  8100. function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
  8101. reverse
  8102. );
  8103. };
  8104. OrderedMap.prototype.__iterator = function(type, reverse) {
  8105. return this._list.fromEntrySeq().__iterator(type, reverse);
  8106. };
  8107. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  8108. if (ownerID === this.__ownerID) {
  8109. return this;
  8110. }
  8111. var newMap = this._map.__ensureOwner(ownerID);
  8112. var newList = this._list.__ensureOwner(ownerID);
  8113. if (!ownerID) {
  8114. this.__ownerID = ownerID;
  8115. this._map = newMap;
  8116. this._list = newList;
  8117. return this;
  8118. }
  8119. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  8120. };
  8121. function isOrderedMap(maybeOrderedMap) {
  8122. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  8123. }
  8124. OrderedMap.isOrderedMap = isOrderedMap;
  8125. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  8126. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  8127. function makeOrderedMap(map, list, ownerID, hash) {
  8128. var omap = Object.create(OrderedMap.prototype);
  8129. omap.size = map ? map.size : 0;
  8130. omap._map = map;
  8131. omap._list = list;
  8132. omap.__ownerID = ownerID;
  8133. omap.__hash = hash;
  8134. return omap;
  8135. }
  8136. var EMPTY_ORDERED_MAP;
  8137. function emptyOrderedMap() {
  8138. return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
  8139. }
  8140. function updateOrderedMap(omap, k, v) {
  8141. var map = omap._map;
  8142. var list = omap._list;
  8143. var i = map.get(k);
  8144. var has = i !== undefined;
  8145. var newMap;
  8146. var newList;
  8147. if (v === NOT_SET) { // removed
  8148. if (!has) {
  8149. return omap;
  8150. }
  8151. if (list.size >= SIZE && list.size >= map.size * 2) {
  8152. newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
  8153. newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
  8154. if (omap.__ownerID) {
  8155. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  8156. }
  8157. } else {
  8158. newMap = map.remove(k);
  8159. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  8160. }
  8161. } else {
  8162. if (has) {
  8163. if (v === list.get(i)[1]) {
  8164. return omap;
  8165. }
  8166. newMap = map;
  8167. newList = list.set(i, [k, v]);
  8168. } else {
  8169. newMap = map.set(k, list.size);
  8170. newList = list.set(list.size, [k, v]);
  8171. }
  8172. }
  8173. if (omap.__ownerID) {
  8174. omap.size = newMap.size;
  8175. omap._map = newMap;
  8176. omap._list = newList;
  8177. omap.__hash = undefined;
  8178. return omap;
  8179. }
  8180. return makeOrderedMap(newMap, newList);
  8181. }
  8182. createClass(ToKeyedSequence, KeyedSeq);
  8183. function ToKeyedSequence(indexed, useKeys) {
  8184. this._iter = indexed;
  8185. this._useKeys = useKeys;
  8186. this.size = indexed.size;
  8187. }
  8188. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  8189. return this._iter.get(key, notSetValue);
  8190. };
  8191. ToKeyedSequence.prototype.has = function(key) {
  8192. return this._iter.has(key);
  8193. };
  8194. ToKeyedSequence.prototype.valueSeq = function() {
  8195. return this._iter.valueSeq();
  8196. };
  8197. ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
  8198. var reversedSequence = reverseFactory(this, true);
  8199. if (!this._useKeys) {
  8200. reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
  8201. }
  8202. return reversedSequence;
  8203. };
  8204. ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
  8205. var mappedSequence = mapFactory(this, mapper, context);
  8206. if (!this._useKeys) {
  8207. mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
  8208. }
  8209. return mappedSequence;
  8210. };
  8211. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8212. var ii;
  8213. return this._iter.__iterate(
  8214. this._useKeys ?
  8215. function(v, k) {return fn(v, k, this$0)} :
  8216. ((ii = reverse ? resolveSize(this) : 0),
  8217. function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
  8218. reverse
  8219. );
  8220. };
  8221. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  8222. if (this._useKeys) {
  8223. return this._iter.__iterator(type, reverse);
  8224. }
  8225. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  8226. var ii = reverse ? resolveSize(this) : 0;
  8227. return new Iterator(function() {
  8228. var step = iterator.next();
  8229. return step.done ? step :
  8230. iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  8231. });
  8232. };
  8233. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  8234. createClass(ToIndexedSequence, IndexedSeq);
  8235. function ToIndexedSequence(iter) {
  8236. this._iter = iter;
  8237. this.size = iter.size;
  8238. }
  8239. ToIndexedSequence.prototype.includes = function(value) {
  8240. return this._iter.includes(value);
  8241. };
  8242. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8243. var iterations = 0;
  8244. return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
  8245. };
  8246. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  8247. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  8248. var iterations = 0;
  8249. return new Iterator(function() {
  8250. var step = iterator.next();
  8251. return step.done ? step :
  8252. iteratorValue(type, iterations++, step.value, step)
  8253. });
  8254. };
  8255. createClass(ToSetSequence, SetSeq);
  8256. function ToSetSequence(iter) {
  8257. this._iter = iter;
  8258. this.size = iter.size;
  8259. }
  8260. ToSetSequence.prototype.has = function(key) {
  8261. return this._iter.includes(key);
  8262. };
  8263. ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8264. return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
  8265. };
  8266. ToSetSequence.prototype.__iterator = function(type, reverse) {
  8267. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  8268. return new Iterator(function() {
  8269. var step = iterator.next();
  8270. return step.done ? step :
  8271. iteratorValue(type, step.value, step.value, step);
  8272. });
  8273. };
  8274. createClass(FromEntriesSequence, KeyedSeq);
  8275. function FromEntriesSequence(entries) {
  8276. this._iter = entries;
  8277. this.size = entries.size;
  8278. }
  8279. FromEntriesSequence.prototype.entrySeq = function() {
  8280. return this._iter.toSeq();
  8281. };
  8282. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8283. return this._iter.__iterate(function(entry ) {
  8284. // Check if entry exists first so array access doesn't throw for holes
  8285. // in the parent iteration.
  8286. if (entry) {
  8287. validateEntry(entry);
  8288. var indexedIterable = isIterable(entry);
  8289. return fn(
  8290. indexedIterable ? entry.get(1) : entry[1],
  8291. indexedIterable ? entry.get(0) : entry[0],
  8292. this$0
  8293. );
  8294. }
  8295. }, reverse);
  8296. };
  8297. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  8298. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  8299. return new Iterator(function() {
  8300. while (true) {
  8301. var step = iterator.next();
  8302. if (step.done) {
  8303. return step;
  8304. }
  8305. var entry = step.value;
  8306. // Check if entry exists first so array access doesn't throw for holes
  8307. // in the parent iteration.
  8308. if (entry) {
  8309. validateEntry(entry);
  8310. var indexedIterable = isIterable(entry);
  8311. return iteratorValue(
  8312. type,
  8313. indexedIterable ? entry.get(0) : entry[0],
  8314. indexedIterable ? entry.get(1) : entry[1],
  8315. step
  8316. );
  8317. }
  8318. }
  8319. });
  8320. };
  8321. ToIndexedSequence.prototype.cacheResult =
  8322. ToKeyedSequence.prototype.cacheResult =
  8323. ToSetSequence.prototype.cacheResult =
  8324. FromEntriesSequence.prototype.cacheResult =
  8325. cacheResultThrough;
  8326. function flipFactory(iterable) {
  8327. var flipSequence = makeSequence(iterable);
  8328. flipSequence._iter = iterable;
  8329. flipSequence.size = iterable.size;
  8330. flipSequence.flip = function() {return iterable};
  8331. flipSequence.reverse = function () {
  8332. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  8333. reversedSequence.flip = function() {return iterable.reverse()};
  8334. return reversedSequence;
  8335. };
  8336. flipSequence.has = function(key ) {return iterable.includes(key)};
  8337. flipSequence.includes = function(key ) {return iterable.has(key)};
  8338. flipSequence.cacheResult = cacheResultThrough;
  8339. flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  8340. return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
  8341. };
  8342. flipSequence.__iteratorUncached = function(type, reverse) {
  8343. if (type === ITERATE_ENTRIES) {
  8344. var iterator = iterable.__iterator(type, reverse);
  8345. return new Iterator(function() {
  8346. var step = iterator.next();
  8347. if (!step.done) {
  8348. var k = step.value[0];
  8349. step.value[0] = step.value[1];
  8350. step.value[1] = k;
  8351. }
  8352. return step;
  8353. });
  8354. }
  8355. return iterable.__iterator(
  8356. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  8357. reverse
  8358. );
  8359. };
  8360. return flipSequence;
  8361. }
  8362. function mapFactory(iterable, mapper, context) {
  8363. var mappedSequence = makeSequence(iterable);
  8364. mappedSequence.size = iterable.size;
  8365. mappedSequence.has = function(key ) {return iterable.has(key)};
  8366. mappedSequence.get = function(key, notSetValue) {
  8367. var v = iterable.get(key, NOT_SET);
  8368. return v === NOT_SET ?
  8369. notSetValue :
  8370. mapper.call(context, v, key, iterable);
  8371. };
  8372. mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  8373. return iterable.__iterate(
  8374. function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
  8375. reverse
  8376. );
  8377. };
  8378. mappedSequence.__iteratorUncached = function (type, reverse) {
  8379. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  8380. return new Iterator(function() {
  8381. var step = iterator.next();
  8382. if (step.done) {
  8383. return step;
  8384. }
  8385. var entry = step.value;
  8386. var key = entry[0];
  8387. return iteratorValue(
  8388. type,
  8389. key,
  8390. mapper.call(context, entry[1], key, iterable),
  8391. step
  8392. );
  8393. });
  8394. };
  8395. return mappedSequence;
  8396. }
  8397. function reverseFactory(iterable, useKeys) {
  8398. var reversedSequence = makeSequence(iterable);
  8399. reversedSequence._iter = iterable;
  8400. reversedSequence.size = iterable.size;
  8401. reversedSequence.reverse = function() {return iterable};
  8402. if (iterable.flip) {
  8403. reversedSequence.flip = function () {
  8404. var flipSequence = flipFactory(iterable);
  8405. flipSequence.reverse = function() {return iterable.flip()};
  8406. return flipSequence;
  8407. };
  8408. }
  8409. reversedSequence.get = function(key, notSetValue)
  8410. {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
  8411. reversedSequence.has = function(key )
  8412. {return iterable.has(useKeys ? key : -1 - key)};
  8413. reversedSequence.includes = function(value ) {return iterable.includes(value)};
  8414. reversedSequence.cacheResult = cacheResultThrough;
  8415. reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
  8416. return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
  8417. };
  8418. reversedSequence.__iterator =
  8419. function(type, reverse) {return iterable.__iterator(type, !reverse)};
  8420. return reversedSequence;
  8421. }
  8422. function filterFactory(iterable, predicate, context, useKeys) {
  8423. var filterSequence = makeSequence(iterable);
  8424. if (useKeys) {
  8425. filterSequence.has = function(key ) {
  8426. var v = iterable.get(key, NOT_SET);
  8427. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  8428. };
  8429. filterSequence.get = function(key, notSetValue) {
  8430. var v = iterable.get(key, NOT_SET);
  8431. return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
  8432. v : notSetValue;
  8433. };
  8434. }
  8435. filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  8436. var iterations = 0;
  8437. iterable.__iterate(function(v, k, c) {
  8438. if (predicate.call(context, v, k, c)) {
  8439. iterations++;
  8440. return fn(v, useKeys ? k : iterations - 1, this$0);
  8441. }
  8442. }, reverse);
  8443. return iterations;
  8444. };
  8445. filterSequence.__iteratorUncached = function (type, reverse) {
  8446. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  8447. var iterations = 0;
  8448. return new Iterator(function() {
  8449. while (true) {
  8450. var step = iterator.next();
  8451. if (step.done) {
  8452. return step;
  8453. }
  8454. var entry = step.value;
  8455. var key = entry[0];
  8456. var value = entry[1];
  8457. if (predicate.call(context, value, key, iterable)) {
  8458. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  8459. }
  8460. }
  8461. });
  8462. };
  8463. return filterSequence;
  8464. }
  8465. function countByFactory(iterable, grouper, context) {
  8466. var groups = Map().asMutable();
  8467. iterable.__iterate(function(v, k) {
  8468. groups.update(
  8469. grouper.call(context, v, k, iterable),
  8470. 0,
  8471. function(a ) {return a + 1}
  8472. );
  8473. });
  8474. return groups.asImmutable();
  8475. }
  8476. function groupByFactory(iterable, grouper, context) {
  8477. var isKeyedIter = isKeyed(iterable);
  8478. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  8479. iterable.__iterate(function(v, k) {
  8480. groups.update(
  8481. grouper.call(context, v, k, iterable),
  8482. function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
  8483. );
  8484. });
  8485. var coerce = iterableClass(iterable);
  8486. return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
  8487. }
  8488. function sliceFactory(iterable, begin, end, useKeys) {
  8489. var originalSize = iterable.size;
  8490. // Sanitize begin & end using this shorthand for ToInt32(argument)
  8491. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  8492. if (begin !== undefined) {
  8493. begin = begin | 0;
  8494. }
  8495. if (end !== undefined) {
  8496. end = end | 0;
  8497. }
  8498. if (wholeSlice(begin, end, originalSize)) {
  8499. return iterable;
  8500. }
  8501. var resolvedBegin = resolveBegin(begin, originalSize);
  8502. var resolvedEnd = resolveEnd(end, originalSize);
  8503. // begin or end will be NaN if they were provided as negative numbers and
  8504. // this iterable's size is unknown. In that case, cache first so there is
  8505. // a known size and these do not resolve to NaN.
  8506. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  8507. return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
  8508. }
  8509. // Note: resolvedEnd is undefined when the original sequence's length is
  8510. // unknown and this slice did not supply an end and should contain all
  8511. // elements after resolvedBegin.
  8512. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  8513. var resolvedSize = resolvedEnd - resolvedBegin;
  8514. var sliceSize;
  8515. if (resolvedSize === resolvedSize) {
  8516. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  8517. }
  8518. var sliceSeq = makeSequence(iterable);
  8519. // If iterable.size is undefined, the size of the realized sliceSeq is
  8520. // unknown at this point unless the number of items to slice is 0
  8521. sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
  8522. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  8523. sliceSeq.get = function (index, notSetValue) {
  8524. index = wrapIndex(this, index);
  8525. return index >= 0 && index < sliceSize ?
  8526. iterable.get(index + resolvedBegin, notSetValue) :
  8527. notSetValue;
  8528. };
  8529. }
  8530. sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
  8531. if (sliceSize === 0) {
  8532. return 0;
  8533. }
  8534. if (reverse) {
  8535. return this.cacheResult().__iterate(fn, reverse);
  8536. }
  8537. var skipped = 0;
  8538. var isSkipping = true;
  8539. var iterations = 0;
  8540. iterable.__iterate(function(v, k) {
  8541. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  8542. iterations++;
  8543. return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  8544. iterations !== sliceSize;
  8545. }
  8546. });
  8547. return iterations;
  8548. };
  8549. sliceSeq.__iteratorUncached = function(type, reverse) {
  8550. if (sliceSize !== 0 && reverse) {
  8551. return this.cacheResult().__iterator(type, reverse);
  8552. }
  8553. // Don't bother instantiating parent iterator if taking 0.
  8554. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  8555. var skipped = 0;
  8556. var iterations = 0;
  8557. return new Iterator(function() {
  8558. while (skipped++ < resolvedBegin) {
  8559. iterator.next();
  8560. }
  8561. if (++iterations > sliceSize) {
  8562. return iteratorDone();
  8563. }
  8564. var step = iterator.next();
  8565. if (useKeys || type === ITERATE_VALUES) {
  8566. return step;
  8567. } else if (type === ITERATE_KEYS) {
  8568. return iteratorValue(type, iterations - 1, undefined, step);
  8569. } else {
  8570. return iteratorValue(type, iterations - 1, step.value[1], step);
  8571. }
  8572. });
  8573. };
  8574. return sliceSeq;
  8575. }
  8576. function takeWhileFactory(iterable, predicate, context) {
  8577. var takeSequence = makeSequence(iterable);
  8578. takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  8579. if (reverse) {
  8580. return this.cacheResult().__iterate(fn, reverse);
  8581. }
  8582. var iterations = 0;
  8583. iterable.__iterate(function(v, k, c)
  8584. {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
  8585. );
  8586. return iterations;
  8587. };
  8588. takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  8589. if (reverse) {
  8590. return this.cacheResult().__iterator(type, reverse);
  8591. }
  8592. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  8593. var iterating = true;
  8594. return new Iterator(function() {
  8595. if (!iterating) {
  8596. return iteratorDone();
  8597. }
  8598. var step = iterator.next();
  8599. if (step.done) {
  8600. return step;
  8601. }
  8602. var entry = step.value;
  8603. var k = entry[0];
  8604. var v = entry[1];
  8605. if (!predicate.call(context, v, k, this$0)) {
  8606. iterating = false;
  8607. return iteratorDone();
  8608. }
  8609. return type === ITERATE_ENTRIES ? step :
  8610. iteratorValue(type, k, v, step);
  8611. });
  8612. };
  8613. return takeSequence;
  8614. }
  8615. function skipWhileFactory(iterable, predicate, context, useKeys) {
  8616. var skipSequence = makeSequence(iterable);
  8617. skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  8618. if (reverse) {
  8619. return this.cacheResult().__iterate(fn, reverse);
  8620. }
  8621. var isSkipping = true;
  8622. var iterations = 0;
  8623. iterable.__iterate(function(v, k, c) {
  8624. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  8625. iterations++;
  8626. return fn(v, useKeys ? k : iterations - 1, this$0);
  8627. }
  8628. });
  8629. return iterations;
  8630. };
  8631. skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  8632. if (reverse) {
  8633. return this.cacheResult().__iterator(type, reverse);
  8634. }
  8635. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  8636. var skipping = true;
  8637. var iterations = 0;
  8638. return new Iterator(function() {
  8639. var step, k, v;
  8640. do {
  8641. step = iterator.next();
  8642. if (step.done) {
  8643. if (useKeys || type === ITERATE_VALUES) {
  8644. return step;
  8645. } else if (type === ITERATE_KEYS) {
  8646. return iteratorValue(type, iterations++, undefined, step);
  8647. } else {
  8648. return iteratorValue(type, iterations++, step.value[1], step);
  8649. }
  8650. }
  8651. var entry = step.value;
  8652. k = entry[0];
  8653. v = entry[1];
  8654. skipping && (skipping = predicate.call(context, v, k, this$0));
  8655. } while (skipping);
  8656. return type === ITERATE_ENTRIES ? step :
  8657. iteratorValue(type, k, v, step);
  8658. });
  8659. };
  8660. return skipSequence;
  8661. }
  8662. function concatFactory(iterable, values) {
  8663. var isKeyedIterable = isKeyed(iterable);
  8664. var iters = [iterable].concat(values).map(function(v ) {
  8665. if (!isIterable(v)) {
  8666. v = isKeyedIterable ?
  8667. keyedSeqFromValue(v) :
  8668. indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  8669. } else if (isKeyedIterable) {
  8670. v = KeyedIterable(v);
  8671. }
  8672. return v;
  8673. }).filter(function(v ) {return v.size !== 0});
  8674. if (iters.length === 0) {
  8675. return iterable;
  8676. }
  8677. if (iters.length === 1) {
  8678. var singleton = iters[0];
  8679. if (singleton === iterable ||
  8680. isKeyedIterable && isKeyed(singleton) ||
  8681. isIndexed(iterable) && isIndexed(singleton)) {
  8682. return singleton;
  8683. }
  8684. }
  8685. var concatSeq = new ArraySeq(iters);
  8686. if (isKeyedIterable) {
  8687. concatSeq = concatSeq.toKeyedSeq();
  8688. } else if (!isIndexed(iterable)) {
  8689. concatSeq = concatSeq.toSetSeq();
  8690. }
  8691. concatSeq = concatSeq.flatten(true);
  8692. concatSeq.size = iters.reduce(
  8693. function(sum, seq) {
  8694. if (sum !== undefined) {
  8695. var size = seq.size;
  8696. if (size !== undefined) {
  8697. return sum + size;
  8698. }
  8699. }
  8700. },
  8701. 0
  8702. );
  8703. return concatSeq;
  8704. }
  8705. function flattenFactory(iterable, depth, useKeys) {
  8706. var flatSequence = makeSequence(iterable);
  8707. flatSequence.__iterateUncached = function(fn, reverse) {
  8708. var iterations = 0;
  8709. var stopped = false;
  8710. function flatDeep(iter, currentDepth) {var this$0 = this;
  8711. iter.__iterate(function(v, k) {
  8712. if ((!depth || currentDepth < depth) && isIterable(v)) {
  8713. flatDeep(v, currentDepth + 1);
  8714. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  8715. stopped = true;
  8716. }
  8717. return !stopped;
  8718. }, reverse);
  8719. }
  8720. flatDeep(iterable, 0);
  8721. return iterations;
  8722. };
  8723. flatSequence.__iteratorUncached = function(type, reverse) {
  8724. var iterator = iterable.__iterator(type, reverse);
  8725. var stack = [];
  8726. var iterations = 0;
  8727. return new Iterator(function() {
  8728. while (iterator) {
  8729. var step = iterator.next();
  8730. if (step.done !== false) {
  8731. iterator = stack.pop();
  8732. continue;
  8733. }
  8734. var v = step.value;
  8735. if (type === ITERATE_ENTRIES) {
  8736. v = v[1];
  8737. }
  8738. if ((!depth || stack.length < depth) && isIterable(v)) {
  8739. stack.push(iterator);
  8740. iterator = v.__iterator(type, reverse);
  8741. } else {
  8742. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  8743. }
  8744. }
  8745. return iteratorDone();
  8746. });
  8747. };
  8748. return flatSequence;
  8749. }
  8750. function flatMapFactory(iterable, mapper, context) {
  8751. var coerce = iterableClass(iterable);
  8752. return iterable.toSeq().map(
  8753. function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
  8754. ).flatten(true);
  8755. }
  8756. function interposeFactory(iterable, separator) {
  8757. var interposedSequence = makeSequence(iterable);
  8758. interposedSequence.size = iterable.size && iterable.size * 2 -1;
  8759. interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  8760. var iterations = 0;
  8761. iterable.__iterate(function(v, k)
  8762. {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
  8763. fn(v, iterations++, this$0) !== false},
  8764. reverse
  8765. );
  8766. return iterations;
  8767. };
  8768. interposedSequence.__iteratorUncached = function(type, reverse) {
  8769. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  8770. var iterations = 0;
  8771. var step;
  8772. return new Iterator(function() {
  8773. if (!step || iterations % 2) {
  8774. step = iterator.next();
  8775. if (step.done) {
  8776. return step;
  8777. }
  8778. }
  8779. return iterations % 2 ?
  8780. iteratorValue(type, iterations++, separator) :
  8781. iteratorValue(type, iterations++, step.value, step);
  8782. });
  8783. };
  8784. return interposedSequence;
  8785. }
  8786. function sortFactory(iterable, comparator, mapper) {
  8787. if (!comparator) {
  8788. comparator = defaultComparator;
  8789. }
  8790. var isKeyedIterable = isKeyed(iterable);
  8791. var index = 0;
  8792. var entries = iterable.toSeq().map(
  8793. function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
  8794. ).toArray();
  8795. entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
  8796. isKeyedIterable ?
  8797. function(v, i) { entries[i].length = 2; } :
  8798. function(v, i) { entries[i] = v[1]; }
  8799. );
  8800. return isKeyedIterable ? KeyedSeq(entries) :
  8801. isIndexed(iterable) ? IndexedSeq(entries) :
  8802. SetSeq(entries);
  8803. }
  8804. function maxFactory(iterable, comparator, mapper) {
  8805. if (!comparator) {
  8806. comparator = defaultComparator;
  8807. }
  8808. if (mapper) {
  8809. var entry = iterable.toSeq()
  8810. .map(function(v, k) {return [v, mapper(v, k, iterable)]})
  8811. .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
  8812. return entry && entry[0];
  8813. } else {
  8814. return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
  8815. }
  8816. }
  8817. function maxCompare(comparator, a, b) {
  8818. var comp = comparator(b, a);
  8819. // b is considered the new max if the comparator declares them equal, but
  8820. // they are not equal and b is in fact a nullish value.
  8821. return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
  8822. }
  8823. function zipWithFactory(keyIter, zipper, iters) {
  8824. var zipSequence = makeSequence(keyIter);
  8825. zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
  8826. // Note: this a generic base implementation of __iterate in terms of
  8827. // __iterator which may be more generically useful in the future.
  8828. zipSequence.__iterate = function(fn, reverse) {
  8829. /* generic:
  8830. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  8831. var step;
  8832. var iterations = 0;
  8833. while (!(step = iterator.next()).done) {
  8834. iterations++;
  8835. if (fn(step.value[1], step.value[0], this) === false) {
  8836. break;
  8837. }
  8838. }
  8839. return iterations;
  8840. */
  8841. // indexed:
  8842. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  8843. var step;
  8844. var iterations = 0;
  8845. while (!(step = iterator.next()).done) {
  8846. if (fn(step.value, iterations++, this) === false) {
  8847. break;
  8848. }
  8849. }
  8850. return iterations;
  8851. };
  8852. zipSequence.__iteratorUncached = function(type, reverse) {
  8853. var iterators = iters.map(function(i )
  8854. {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
  8855. );
  8856. var iterations = 0;
  8857. var isDone = false;
  8858. return new Iterator(function() {
  8859. var steps;
  8860. if (!isDone) {
  8861. steps = iterators.map(function(i ) {return i.next()});
  8862. isDone = steps.some(function(s ) {return s.done});
  8863. }
  8864. if (isDone) {
  8865. return iteratorDone();
  8866. }
  8867. return iteratorValue(
  8868. type,
  8869. iterations++,
  8870. zipper.apply(null, steps.map(function(s ) {return s.value}))
  8871. );
  8872. });
  8873. };
  8874. return zipSequence
  8875. }
  8876. // #pragma Helper Functions
  8877. function reify(iter, seq) {
  8878. return isSeq(iter) ? seq : iter.constructor(seq);
  8879. }
  8880. function validateEntry(entry) {
  8881. if (entry !== Object(entry)) {
  8882. throw new TypeError('Expected [K, V] tuple: ' + entry);
  8883. }
  8884. }
  8885. function resolveSize(iter) {
  8886. assertNotInfinite(iter.size);
  8887. return ensureSize(iter);
  8888. }
  8889. function iterableClass(iterable) {
  8890. return isKeyed(iterable) ? KeyedIterable :
  8891. isIndexed(iterable) ? IndexedIterable :
  8892. SetIterable;
  8893. }
  8894. function makeSequence(iterable) {
  8895. return Object.create(
  8896. (
  8897. isKeyed(iterable) ? KeyedSeq :
  8898. isIndexed(iterable) ? IndexedSeq :
  8899. SetSeq
  8900. ).prototype
  8901. );
  8902. }
  8903. function cacheResultThrough() {
  8904. if (this._iter.cacheResult) {
  8905. this._iter.cacheResult();
  8906. this.size = this._iter.size;
  8907. return this;
  8908. } else {
  8909. return Seq.prototype.cacheResult.call(this);
  8910. }
  8911. }
  8912. function defaultComparator(a, b) {
  8913. return a > b ? 1 : a < b ? -1 : 0;
  8914. }
  8915. function forceIterator(keyPath) {
  8916. var iter = getIterator(keyPath);
  8917. if (!iter) {
  8918. // Array might not be iterable in this environment, so we need a fallback
  8919. // to our wrapped type.
  8920. if (!isArrayLike(keyPath)) {
  8921. throw new TypeError('Expected iterable or array-like: ' + keyPath);
  8922. }
  8923. iter = getIterator(Iterable(keyPath));
  8924. }
  8925. return iter;
  8926. }
  8927. createClass(Record, KeyedCollection);
  8928. function Record(defaultValues, name) {
  8929. var hasInitialized;
  8930. var RecordType = function Record(values) {
  8931. if (values instanceof RecordType) {
  8932. return values;
  8933. }
  8934. if (!(this instanceof RecordType)) {
  8935. return new RecordType(values);
  8936. }
  8937. if (!hasInitialized) {
  8938. hasInitialized = true;
  8939. var keys = Object.keys(defaultValues);
  8940. setProps(RecordTypePrototype, keys);
  8941. RecordTypePrototype.size = keys.length;
  8942. RecordTypePrototype._name = name;
  8943. RecordTypePrototype._keys = keys;
  8944. RecordTypePrototype._defaultValues = defaultValues;
  8945. }
  8946. this._map = Map(values);
  8947. };
  8948. var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
  8949. RecordTypePrototype.constructor = RecordType;
  8950. return RecordType;
  8951. }
  8952. Record.prototype.toString = function() {
  8953. return this.__toString(recordName(this) + ' {', '}');
  8954. };
  8955. // @pragma Access
  8956. Record.prototype.has = function(k) {
  8957. return this._defaultValues.hasOwnProperty(k);
  8958. };
  8959. Record.prototype.get = function(k, notSetValue) {
  8960. if (!this.has(k)) {
  8961. return notSetValue;
  8962. }
  8963. var defaultVal = this._defaultValues[k];
  8964. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  8965. };
  8966. // @pragma Modification
  8967. Record.prototype.clear = function() {
  8968. if (this.__ownerID) {
  8969. this._map && this._map.clear();
  8970. return this;
  8971. }
  8972. var RecordType = this.constructor;
  8973. return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
  8974. };
  8975. Record.prototype.set = function(k, v) {
  8976. if (!this.has(k)) {
  8977. throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
  8978. }
  8979. var newMap = this._map && this._map.set(k, v);
  8980. if (this.__ownerID || newMap === this._map) {
  8981. return this;
  8982. }
  8983. return makeRecord(this, newMap);
  8984. };
  8985. Record.prototype.remove = function(k) {
  8986. if (!this.has(k)) {
  8987. return this;
  8988. }
  8989. var newMap = this._map && this._map.remove(k);
  8990. if (this.__ownerID || newMap === this._map) {
  8991. return this;
  8992. }
  8993. return makeRecord(this, newMap);
  8994. };
  8995. Record.prototype.wasAltered = function() {
  8996. return this._map.wasAltered();
  8997. };
  8998. Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
  8999. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
  9000. };
  9001. Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  9002. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
  9003. };
  9004. Record.prototype.__ensureOwner = function(ownerID) {
  9005. if (ownerID === this.__ownerID) {
  9006. return this;
  9007. }
  9008. var newMap = this._map && this._map.__ensureOwner(ownerID);
  9009. if (!ownerID) {
  9010. this.__ownerID = ownerID;
  9011. this._map = newMap;
  9012. return this;
  9013. }
  9014. return makeRecord(this, newMap, ownerID);
  9015. };
  9016. var RecordPrototype = Record.prototype;
  9017. RecordPrototype[DELETE] = RecordPrototype.remove;
  9018. RecordPrototype.deleteIn =
  9019. RecordPrototype.removeIn = MapPrototype.removeIn;
  9020. RecordPrototype.merge = MapPrototype.merge;
  9021. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  9022. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  9023. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  9024. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  9025. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  9026. RecordPrototype.setIn = MapPrototype.setIn;
  9027. RecordPrototype.update = MapPrototype.update;
  9028. RecordPrototype.updateIn = MapPrototype.updateIn;
  9029. RecordPrototype.withMutations = MapPrototype.withMutations;
  9030. RecordPrototype.asMutable = MapPrototype.asMutable;
  9031. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  9032. function makeRecord(likeRecord, map, ownerID) {
  9033. var record = Object.create(Object.getPrototypeOf(likeRecord));
  9034. record._map = map;
  9035. record.__ownerID = ownerID;
  9036. return record;
  9037. }
  9038. function recordName(record) {
  9039. return record._name || record.constructor.name || 'Record';
  9040. }
  9041. function setProps(prototype, names) {
  9042. try {
  9043. names.forEach(setProp.bind(undefined, prototype));
  9044. } catch (error) {
  9045. // Object.defineProperty failed. Probably IE8.
  9046. }
  9047. }
  9048. function setProp(prototype, name) {
  9049. Object.defineProperty(prototype, name, {
  9050. get: function() {
  9051. return this.get(name);
  9052. },
  9053. set: function(value) {
  9054. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  9055. this.set(name, value);
  9056. }
  9057. });
  9058. }
  9059. createClass(Set, SetCollection);
  9060. // @pragma Construction
  9061. function Set(value) {
  9062. return value === null || value === undefined ? emptySet() :
  9063. isSet(value) && !isOrdered(value) ? value :
  9064. emptySet().withMutations(function(set ) {
  9065. var iter = SetIterable(value);
  9066. assertNotInfinite(iter.size);
  9067. iter.forEach(function(v ) {return set.add(v)});
  9068. });
  9069. }
  9070. Set.of = function(/*...values*/) {
  9071. return this(arguments);
  9072. };
  9073. Set.fromKeys = function(value) {
  9074. return this(KeyedIterable(value).keySeq());
  9075. };
  9076. Set.prototype.toString = function() {
  9077. return this.__toString('Set {', '}');
  9078. };
  9079. // @pragma Access
  9080. Set.prototype.has = function(value) {
  9081. return this._map.has(value);
  9082. };
  9083. // @pragma Modification
  9084. Set.prototype.add = function(value) {
  9085. return updateSet(this, this._map.set(value, true));
  9086. };
  9087. Set.prototype.remove = function(value) {
  9088. return updateSet(this, this._map.remove(value));
  9089. };
  9090. Set.prototype.clear = function() {
  9091. return updateSet(this, this._map.clear());
  9092. };
  9093. // @pragma Composition
  9094. Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
  9095. iters = iters.filter(function(x ) {return x.size !== 0});
  9096. if (iters.length === 0) {
  9097. return this;
  9098. }
  9099. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  9100. return this.constructor(iters[0]);
  9101. }
  9102. return this.withMutations(function(set ) {
  9103. for (var ii = 0; ii < iters.length; ii++) {
  9104. SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
  9105. }
  9106. });
  9107. };
  9108. Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
  9109. if (iters.length === 0) {
  9110. return this;
  9111. }
  9112. iters = iters.map(function(iter ) {return SetIterable(iter)});
  9113. var originalSet = this;
  9114. return this.withMutations(function(set ) {
  9115. originalSet.forEach(function(value ) {
  9116. if (!iters.every(function(iter ) {return iter.includes(value)})) {
  9117. set.remove(value);
  9118. }
  9119. });
  9120. });
  9121. };
  9122. Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
  9123. if (iters.length === 0) {
  9124. return this;
  9125. }
  9126. iters = iters.map(function(iter ) {return SetIterable(iter)});
  9127. var originalSet = this;
  9128. return this.withMutations(function(set ) {
  9129. originalSet.forEach(function(value ) {
  9130. if (iters.some(function(iter ) {return iter.includes(value)})) {
  9131. set.remove(value);
  9132. }
  9133. });
  9134. });
  9135. };
  9136. Set.prototype.merge = function() {
  9137. return this.union.apply(this, arguments);
  9138. };
  9139. Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  9140. return this.union.apply(this, iters);
  9141. };
  9142. Set.prototype.sort = function(comparator) {
  9143. // Late binding
  9144. return OrderedSet(sortFactory(this, comparator));
  9145. };
  9146. Set.prototype.sortBy = function(mapper, comparator) {
  9147. // Late binding
  9148. return OrderedSet(sortFactory(this, comparator, mapper));
  9149. };
  9150. Set.prototype.wasAltered = function() {
  9151. return this._map.wasAltered();
  9152. };
  9153. Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  9154. return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
  9155. };
  9156. Set.prototype.__iterator = function(type, reverse) {
  9157. return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
  9158. };
  9159. Set.prototype.__ensureOwner = function(ownerID) {
  9160. if (ownerID === this.__ownerID) {
  9161. return this;
  9162. }
  9163. var newMap = this._map.__ensureOwner(ownerID);
  9164. if (!ownerID) {
  9165. this.__ownerID = ownerID;
  9166. this._map = newMap;
  9167. return this;
  9168. }
  9169. return this.__make(newMap, ownerID);
  9170. };
  9171. function isSet(maybeSet) {
  9172. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  9173. }
  9174. Set.isSet = isSet;
  9175. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  9176. var SetPrototype = Set.prototype;
  9177. SetPrototype[IS_SET_SENTINEL] = true;
  9178. SetPrototype[DELETE] = SetPrototype.remove;
  9179. SetPrototype.mergeDeep = SetPrototype.merge;
  9180. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  9181. SetPrototype.withMutations = MapPrototype.withMutations;
  9182. SetPrototype.asMutable = MapPrototype.asMutable;
  9183. SetPrototype.asImmutable = MapPrototype.asImmutable;
  9184. SetPrototype.__empty = emptySet;
  9185. SetPrototype.__make = makeSet;
  9186. function updateSet(set, newMap) {
  9187. if (set.__ownerID) {
  9188. set.size = newMap.size;
  9189. set._map = newMap;
  9190. return set;
  9191. }
  9192. return newMap === set._map ? set :
  9193. newMap.size === 0 ? set.__empty() :
  9194. set.__make(newMap);
  9195. }
  9196. function makeSet(map, ownerID) {
  9197. var set = Object.create(SetPrototype);
  9198. set.size = map ? map.size : 0;
  9199. set._map = map;
  9200. set.__ownerID = ownerID;
  9201. return set;
  9202. }
  9203. var EMPTY_SET;
  9204. function emptySet() {
  9205. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  9206. }
  9207. createClass(OrderedSet, Set);
  9208. // @pragma Construction
  9209. function OrderedSet(value) {
  9210. return value === null || value === undefined ? emptyOrderedSet() :
  9211. isOrderedSet(value) ? value :
  9212. emptyOrderedSet().withMutations(function(set ) {
  9213. var iter = SetIterable(value);
  9214. assertNotInfinite(iter.size);
  9215. iter.forEach(function(v ) {return set.add(v)});
  9216. });
  9217. }
  9218. OrderedSet.of = function(/*...values*/) {
  9219. return this(arguments);
  9220. };
  9221. OrderedSet.fromKeys = function(value) {
  9222. return this(KeyedIterable(value).keySeq());
  9223. };
  9224. OrderedSet.prototype.toString = function() {
  9225. return this.__toString('OrderedSet {', '}');
  9226. };
  9227. function isOrderedSet(maybeOrderedSet) {
  9228. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  9229. }
  9230. OrderedSet.isOrderedSet = isOrderedSet;
  9231. var OrderedSetPrototype = OrderedSet.prototype;
  9232. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  9233. OrderedSetPrototype.__empty = emptyOrderedSet;
  9234. OrderedSetPrototype.__make = makeOrderedSet;
  9235. function makeOrderedSet(map, ownerID) {
  9236. var set = Object.create(OrderedSetPrototype);
  9237. set.size = map ? map.size : 0;
  9238. set._map = map;
  9239. set.__ownerID = ownerID;
  9240. return set;
  9241. }
  9242. var EMPTY_ORDERED_SET;
  9243. function emptyOrderedSet() {
  9244. return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
  9245. }
  9246. createClass(Stack, IndexedCollection);
  9247. // @pragma Construction
  9248. function Stack(value) {
  9249. return value === null || value === undefined ? emptyStack() :
  9250. isStack(value) ? value :
  9251. emptyStack().unshiftAll(value);
  9252. }
  9253. Stack.of = function(/*...values*/) {
  9254. return this(arguments);
  9255. };
  9256. Stack.prototype.toString = function() {
  9257. return this.__toString('Stack [', ']');
  9258. };
  9259. // @pragma Access
  9260. Stack.prototype.get = function(index, notSetValue) {
  9261. var head = this._head;
  9262. index = wrapIndex(this, index);
  9263. while (head && index--) {
  9264. head = head.next;
  9265. }
  9266. return head ? head.value : notSetValue;
  9267. };
  9268. Stack.prototype.peek = function() {
  9269. return this._head && this._head.value;
  9270. };
  9271. // @pragma Modification
  9272. Stack.prototype.push = function(/*...values*/) {
  9273. if (arguments.length === 0) {
  9274. return this;
  9275. }
  9276. var newSize = this.size + arguments.length;
  9277. var head = this._head;
  9278. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  9279. head = {
  9280. value: arguments[ii],
  9281. next: head
  9282. };
  9283. }
  9284. if (this.__ownerID) {
  9285. this.size = newSize;
  9286. this._head = head;
  9287. this.__hash = undefined;
  9288. this.__altered = true;
  9289. return this;
  9290. }
  9291. return makeStack(newSize, head);
  9292. };
  9293. Stack.prototype.pushAll = function(iter) {
  9294. iter = IndexedIterable(iter);
  9295. if (iter.size === 0) {
  9296. return this;
  9297. }
  9298. assertNotInfinite(iter.size);
  9299. var newSize = this.size;
  9300. var head = this._head;
  9301. iter.reverse().forEach(function(value ) {
  9302. newSize++;
  9303. head = {
  9304. value: value,
  9305. next: head
  9306. };
  9307. });
  9308. if (this.__ownerID) {
  9309. this.size = newSize;
  9310. this._head = head;
  9311. this.__hash = undefined;
  9312. this.__altered = true;
  9313. return this;
  9314. }
  9315. return makeStack(newSize, head);
  9316. };
  9317. Stack.prototype.pop = function() {
  9318. return this.slice(1);
  9319. };
  9320. Stack.prototype.unshift = function(/*...values*/) {
  9321. return this.push.apply(this, arguments);
  9322. };
  9323. Stack.prototype.unshiftAll = function(iter) {
  9324. return this.pushAll(iter);
  9325. };
  9326. Stack.prototype.shift = function() {
  9327. return this.pop.apply(this, arguments);
  9328. };
  9329. Stack.prototype.clear = function() {
  9330. if (this.size === 0) {
  9331. return this;
  9332. }
  9333. if (this.__ownerID) {
  9334. this.size = 0;
  9335. this._head = undefined;
  9336. this.__hash = undefined;
  9337. this.__altered = true;
  9338. return this;
  9339. }
  9340. return emptyStack();
  9341. };
  9342. Stack.prototype.slice = function(begin, end) {
  9343. if (wholeSlice(begin, end, this.size)) {
  9344. return this;
  9345. }
  9346. var resolvedBegin = resolveBegin(begin, this.size);
  9347. var resolvedEnd = resolveEnd(end, this.size);
  9348. if (resolvedEnd !== this.size) {
  9349. // super.slice(begin, end);
  9350. return IndexedCollection.prototype.slice.call(this, begin, end);
  9351. }
  9352. var newSize = this.size - resolvedBegin;
  9353. var head = this._head;
  9354. while (resolvedBegin--) {
  9355. head = head.next;
  9356. }
  9357. if (this.__ownerID) {
  9358. this.size = newSize;
  9359. this._head = head;
  9360. this.__hash = undefined;
  9361. this.__altered = true;
  9362. return this;
  9363. }
  9364. return makeStack(newSize, head);
  9365. };
  9366. // @pragma Mutability
  9367. Stack.prototype.__ensureOwner = function(ownerID) {
  9368. if (ownerID === this.__ownerID) {
  9369. return this;
  9370. }
  9371. if (!ownerID) {
  9372. this.__ownerID = ownerID;
  9373. this.__altered = false;
  9374. return this;
  9375. }
  9376. return makeStack(this.size, this._head, ownerID, this.__hash);
  9377. };
  9378. // @pragma Iteration
  9379. Stack.prototype.__iterate = function(fn, reverse) {
  9380. if (reverse) {
  9381. return this.reverse().__iterate(fn);
  9382. }
  9383. var iterations = 0;
  9384. var node = this._head;
  9385. while (node) {
  9386. if (fn(node.value, iterations++, this) === false) {
  9387. break;
  9388. }
  9389. node = node.next;
  9390. }
  9391. return iterations;
  9392. };
  9393. Stack.prototype.__iterator = function(type, reverse) {
  9394. if (reverse) {
  9395. return this.reverse().__iterator(type);
  9396. }
  9397. var iterations = 0;
  9398. var node = this._head;
  9399. return new Iterator(function() {
  9400. if (node) {
  9401. var value = node.value;
  9402. node = node.next;
  9403. return iteratorValue(type, iterations++, value);
  9404. }
  9405. return iteratorDone();
  9406. });
  9407. };
  9408. function isStack(maybeStack) {
  9409. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  9410. }
  9411. Stack.isStack = isStack;
  9412. var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  9413. var StackPrototype = Stack.prototype;
  9414. StackPrototype[IS_STACK_SENTINEL] = true;
  9415. StackPrototype.withMutations = MapPrototype.withMutations;
  9416. StackPrototype.asMutable = MapPrototype.asMutable;
  9417. StackPrototype.asImmutable = MapPrototype.asImmutable;
  9418. StackPrototype.wasAltered = MapPrototype.wasAltered;
  9419. function makeStack(size, head, ownerID, hash) {
  9420. var map = Object.create(StackPrototype);
  9421. map.size = size;
  9422. map._head = head;
  9423. map.__ownerID = ownerID;
  9424. map.__hash = hash;
  9425. map.__altered = false;
  9426. return map;
  9427. }
  9428. var EMPTY_STACK;
  9429. function emptyStack() {
  9430. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  9431. }
  9432. /**
  9433. * Contributes additional methods to a constructor
  9434. */
  9435. function mixin(ctor, methods) {
  9436. var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
  9437. Object.keys(methods).forEach(keyCopier);
  9438. Object.getOwnPropertySymbols &&
  9439. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  9440. return ctor;
  9441. }
  9442. Iterable.Iterator = Iterator;
  9443. mixin(Iterable, {
  9444. // ### Conversion to other types
  9445. toArray: function() {
  9446. assertNotInfinite(this.size);
  9447. var array = new Array(this.size || 0);
  9448. this.valueSeq().__iterate(function(v, i) { array[i] = v; });
  9449. return array;
  9450. },
  9451. toIndexedSeq: function() {
  9452. return new ToIndexedSequence(this);
  9453. },
  9454. toJS: function() {
  9455. return this.toSeq().map(
  9456. function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
  9457. ).__toJS();
  9458. },
  9459. toJSON: function() {
  9460. return this.toSeq().map(
  9461. function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
  9462. ).__toJS();
  9463. },
  9464. toKeyedSeq: function() {
  9465. return new ToKeyedSequence(this, true);
  9466. },
  9467. toMap: function() {
  9468. // Use Late Binding here to solve the circular dependency.
  9469. return Map(this.toKeyedSeq());
  9470. },
  9471. toObject: function() {
  9472. assertNotInfinite(this.size);
  9473. var object = {};
  9474. this.__iterate(function(v, k) { object[k] = v; });
  9475. return object;
  9476. },
  9477. toOrderedMap: function() {
  9478. // Use Late Binding here to solve the circular dependency.
  9479. return OrderedMap(this.toKeyedSeq());
  9480. },
  9481. toOrderedSet: function() {
  9482. // Use Late Binding here to solve the circular dependency.
  9483. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  9484. },
  9485. toSet: function() {
  9486. // Use Late Binding here to solve the circular dependency.
  9487. return Set(isKeyed(this) ? this.valueSeq() : this);
  9488. },
  9489. toSetSeq: function() {
  9490. return new ToSetSequence(this);
  9491. },
  9492. toSeq: function() {
  9493. return isIndexed(this) ? this.toIndexedSeq() :
  9494. isKeyed(this) ? this.toKeyedSeq() :
  9495. this.toSetSeq();
  9496. },
  9497. toStack: function() {
  9498. // Use Late Binding here to solve the circular dependency.
  9499. return Stack(isKeyed(this) ? this.valueSeq() : this);
  9500. },
  9501. toList: function() {
  9502. // Use Late Binding here to solve the circular dependency.
  9503. return List(isKeyed(this) ? this.valueSeq() : this);
  9504. },
  9505. // ### Common JavaScript methods and properties
  9506. toString: function() {
  9507. return '[Iterable]';
  9508. },
  9509. __toString: function(head, tail) {
  9510. if (this.size === 0) {
  9511. return head + tail;
  9512. }
  9513. return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
  9514. },
  9515. // ### ES6 Collection methods (ES6 Array and Map)
  9516. concat: function() {var values = SLICE$0.call(arguments, 0);
  9517. return reify(this, concatFactory(this, values));
  9518. },
  9519. includes: function(searchValue) {
  9520. return this.some(function(value ) {return is(value, searchValue)});
  9521. },
  9522. entries: function() {
  9523. return this.__iterator(ITERATE_ENTRIES);
  9524. },
  9525. every: function(predicate, context) {
  9526. assertNotInfinite(this.size);
  9527. var returnValue = true;
  9528. this.__iterate(function(v, k, c) {
  9529. if (!predicate.call(context, v, k, c)) {
  9530. returnValue = false;
  9531. return false;
  9532. }
  9533. });
  9534. return returnValue;
  9535. },
  9536. filter: function(predicate, context) {
  9537. return reify(this, filterFactory(this, predicate, context, true));
  9538. },
  9539. find: function(predicate, context, notSetValue) {
  9540. var entry = this.findEntry(predicate, context);
  9541. return entry ? entry[1] : notSetValue;
  9542. },
  9543. findEntry: function(predicate, context) {
  9544. var found;
  9545. this.__iterate(function(v, k, c) {
  9546. if (predicate.call(context, v, k, c)) {
  9547. found = [k, v];
  9548. return false;
  9549. }
  9550. });
  9551. return found;
  9552. },
  9553. findLastEntry: function(predicate, context) {
  9554. return this.toSeq().reverse().findEntry(predicate, context);
  9555. },
  9556. forEach: function(sideEffect, context) {
  9557. assertNotInfinite(this.size);
  9558. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  9559. },
  9560. join: function(separator) {
  9561. assertNotInfinite(this.size);
  9562. separator = separator !== undefined ? '' + separator : ',';
  9563. var joined = '';
  9564. var isFirst = true;
  9565. this.__iterate(function(v ) {
  9566. isFirst ? (isFirst = false) : (joined += separator);
  9567. joined += v !== null && v !== undefined ? v.toString() : '';
  9568. });
  9569. return joined;
  9570. },
  9571. keys: function() {
  9572. return this.__iterator(ITERATE_KEYS);
  9573. },
  9574. map: function(mapper, context) {
  9575. return reify(this, mapFactory(this, mapper, context));
  9576. },
  9577. reduce: function(reducer, initialReduction, context) {
  9578. assertNotInfinite(this.size);
  9579. var reduction;
  9580. var useFirst;
  9581. if (arguments.length < 2) {
  9582. useFirst = true;
  9583. } else {
  9584. reduction = initialReduction;
  9585. }
  9586. this.__iterate(function(v, k, c) {
  9587. if (useFirst) {
  9588. useFirst = false;
  9589. reduction = v;
  9590. } else {
  9591. reduction = reducer.call(context, reduction, v, k, c);
  9592. }
  9593. });
  9594. return reduction;
  9595. },
  9596. reduceRight: function(reducer, initialReduction, context) {
  9597. var reversed = this.toKeyedSeq().reverse();
  9598. return reversed.reduce.apply(reversed, arguments);
  9599. },
  9600. reverse: function() {
  9601. return reify(this, reverseFactory(this, true));
  9602. },
  9603. slice: function(begin, end) {
  9604. return reify(this, sliceFactory(this, begin, end, true));
  9605. },
  9606. some: function(predicate, context) {
  9607. return !this.every(not(predicate), context);
  9608. },
  9609. sort: function(comparator) {
  9610. return reify(this, sortFactory(this, comparator));
  9611. },
  9612. values: function() {
  9613. return this.__iterator(ITERATE_VALUES);
  9614. },
  9615. // ### More sequential methods
  9616. butLast: function() {
  9617. return this.slice(0, -1);
  9618. },
  9619. isEmpty: function() {
  9620. return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
  9621. },
  9622. count: function(predicate, context) {
  9623. return ensureSize(
  9624. predicate ? this.toSeq().filter(predicate, context) : this
  9625. );
  9626. },
  9627. countBy: function(grouper, context) {
  9628. return countByFactory(this, grouper, context);
  9629. },
  9630. equals: function(other) {
  9631. return deepEqual(this, other);
  9632. },
  9633. entrySeq: function() {
  9634. var iterable = this;
  9635. if (iterable._cache) {
  9636. // We cache as an entries array, so we can just return the cache!
  9637. return new ArraySeq(iterable._cache);
  9638. }
  9639. var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
  9640. entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
  9641. return entriesSequence;
  9642. },
  9643. filterNot: function(predicate, context) {
  9644. return this.filter(not(predicate), context);
  9645. },
  9646. findLast: function(predicate, context, notSetValue) {
  9647. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  9648. },
  9649. first: function() {
  9650. return this.find(returnTrue);
  9651. },
  9652. flatMap: function(mapper, context) {
  9653. return reify(this, flatMapFactory(this, mapper, context));
  9654. },
  9655. flatten: function(depth) {
  9656. return reify(this, flattenFactory(this, depth, true));
  9657. },
  9658. fromEntrySeq: function() {
  9659. return new FromEntriesSequence(this);
  9660. },
  9661. get: function(searchKey, notSetValue) {
  9662. return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
  9663. },
  9664. getIn: function(searchKeyPath, notSetValue) {
  9665. var nested = this;
  9666. // Note: in an ES6 environment, we would prefer:
  9667. // for (var key of searchKeyPath) {
  9668. var iter = forceIterator(searchKeyPath);
  9669. var step;
  9670. while (!(step = iter.next()).done) {
  9671. var key = step.value;
  9672. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  9673. if (nested === NOT_SET) {
  9674. return notSetValue;
  9675. }
  9676. }
  9677. return nested;
  9678. },
  9679. groupBy: function(grouper, context) {
  9680. return groupByFactory(this, grouper, context);
  9681. },
  9682. has: function(searchKey) {
  9683. return this.get(searchKey, NOT_SET) !== NOT_SET;
  9684. },
  9685. hasIn: function(searchKeyPath) {
  9686. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  9687. },
  9688. isSubset: function(iter) {
  9689. iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
  9690. return this.every(function(value ) {return iter.includes(value)});
  9691. },
  9692. isSuperset: function(iter) {
  9693. iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
  9694. return iter.isSubset(this);
  9695. },
  9696. keySeq: function() {
  9697. return this.toSeq().map(keyMapper).toIndexedSeq();
  9698. },
  9699. last: function() {
  9700. return this.toSeq().reverse().first();
  9701. },
  9702. max: function(comparator) {
  9703. return maxFactory(this, comparator);
  9704. },
  9705. maxBy: function(mapper, comparator) {
  9706. return maxFactory(this, comparator, mapper);
  9707. },
  9708. min: function(comparator) {
  9709. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
  9710. },
  9711. minBy: function(mapper, comparator) {
  9712. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
  9713. },
  9714. rest: function() {
  9715. return this.slice(1);
  9716. },
  9717. skip: function(amount) {
  9718. return this.slice(Math.max(0, amount));
  9719. },
  9720. skipLast: function(amount) {
  9721. return reify(this, this.toSeq().reverse().skip(amount).reverse());
  9722. },
  9723. skipWhile: function(predicate, context) {
  9724. return reify(this, skipWhileFactory(this, predicate, context, true));
  9725. },
  9726. skipUntil: function(predicate, context) {
  9727. return this.skipWhile(not(predicate), context);
  9728. },
  9729. sortBy: function(mapper, comparator) {
  9730. return reify(this, sortFactory(this, comparator, mapper));
  9731. },
  9732. take: function(amount) {
  9733. return this.slice(0, Math.max(0, amount));
  9734. },
  9735. takeLast: function(amount) {
  9736. return reify(this, this.toSeq().reverse().take(amount).reverse());
  9737. },
  9738. takeWhile: function(predicate, context) {
  9739. return reify(this, takeWhileFactory(this, predicate, context));
  9740. },
  9741. takeUntil: function(predicate, context) {
  9742. return this.takeWhile(not(predicate), context);
  9743. },
  9744. valueSeq: function() {
  9745. return this.toIndexedSeq();
  9746. },
  9747. // ### Hashable Object
  9748. hashCode: function() {
  9749. return this.__hash || (this.__hash = hashIterable(this));
  9750. }
  9751. // ### Internal
  9752. // abstract __iterate(fn, reverse)
  9753. // abstract __iterator(type, reverse)
  9754. });
  9755. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  9756. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  9757. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  9758. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  9759. var IterablePrototype = Iterable.prototype;
  9760. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  9761. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  9762. IterablePrototype.__toJS = IterablePrototype.toArray;
  9763. IterablePrototype.__toStringMapper = quoteString;
  9764. IterablePrototype.inspect =
  9765. IterablePrototype.toSource = function() { return this.toString(); };
  9766. IterablePrototype.chain = IterablePrototype.flatMap;
  9767. IterablePrototype.contains = IterablePrototype.includes;
  9768. // Temporary warning about using length
  9769. (function () {
  9770. try {
  9771. Object.defineProperty(IterablePrototype, 'length', {
  9772. get: function () {
  9773. if (!Iterable.noLengthWarning) {
  9774. var stack;
  9775. try {
  9776. throw new Error();
  9777. } catch (error) {
  9778. stack = error.stack;
  9779. }
  9780. if (stack.indexOf('_wrapObject') === -1) {
  9781. console && console.warn && console.warn(
  9782. 'iterable.length has been deprecated, '+
  9783. 'use iterable.size or iterable.count(). '+
  9784. 'This warning will become a silent error in a future version. ' +
  9785. stack
  9786. );
  9787. return this.size;
  9788. }
  9789. }
  9790. }
  9791. });
  9792. } catch (e) {}
  9793. })();
  9794. mixin(KeyedIterable, {
  9795. // ### More sequential methods
  9796. flip: function() {
  9797. return reify(this, flipFactory(this));
  9798. },
  9799. findKey: function(predicate, context) {
  9800. var entry = this.findEntry(predicate, context);
  9801. return entry && entry[0];
  9802. },
  9803. findLastKey: function(predicate, context) {
  9804. return this.toSeq().reverse().findKey(predicate, context);
  9805. },
  9806. keyOf: function(searchValue) {
  9807. return this.findKey(function(value ) {return is(value, searchValue)});
  9808. },
  9809. lastKeyOf: function(searchValue) {
  9810. return this.findLastKey(function(value ) {return is(value, searchValue)});
  9811. },
  9812. mapEntries: function(mapper, context) {var this$0 = this;
  9813. var iterations = 0;
  9814. return reify(this,
  9815. this.toSeq().map(
  9816. function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
  9817. ).fromEntrySeq()
  9818. );
  9819. },
  9820. mapKeys: function(mapper, context) {var this$0 = this;
  9821. return reify(this,
  9822. this.toSeq().flip().map(
  9823. function(k, v) {return mapper.call(context, k, v, this$0)}
  9824. ).flip()
  9825. );
  9826. }
  9827. });
  9828. var KeyedIterablePrototype = KeyedIterable.prototype;
  9829. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  9830. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  9831. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  9832. KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
  9833. mixin(IndexedIterable, {
  9834. // ### Conversion to other types
  9835. toKeyedSeq: function() {
  9836. return new ToKeyedSequence(this, false);
  9837. },
  9838. // ### ES6 Collection methods (ES6 Array and Map)
  9839. filter: function(predicate, context) {
  9840. return reify(this, filterFactory(this, predicate, context, false));
  9841. },
  9842. findIndex: function(predicate, context) {
  9843. var entry = this.findEntry(predicate, context);
  9844. return entry ? entry[0] : -1;
  9845. },
  9846. indexOf: function(searchValue) {
  9847. var key = this.toKeyedSeq().keyOf(searchValue);
  9848. return key === undefined ? -1 : key;
  9849. },
  9850. lastIndexOf: function(searchValue) {
  9851. var key = this.toKeyedSeq().reverse().keyOf(searchValue);
  9852. return key === undefined ? -1 : key;
  9853. // var index =
  9854. // return this.toSeq().reverse().indexOf(searchValue);
  9855. },
  9856. reverse: function() {
  9857. return reify(this, reverseFactory(this, false));
  9858. },
  9859. slice: function(begin, end) {
  9860. return reify(this, sliceFactory(this, begin, end, false));
  9861. },
  9862. splice: function(index, removeNum /*, ...values*/) {
  9863. var numArgs = arguments.length;
  9864. removeNum = Math.max(removeNum | 0, 0);
  9865. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  9866. return this;
  9867. }
  9868. // If index is negative, it should resolve relative to the size of the
  9869. // collection. However size may be expensive to compute if not cached, so
  9870. // only call count() if the number is in fact negative.
  9871. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  9872. var spliced = this.slice(0, index);
  9873. return reify(
  9874. this,
  9875. numArgs === 1 ?
  9876. spliced :
  9877. spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  9878. );
  9879. },
  9880. // ### More collection methods
  9881. findLastIndex: function(predicate, context) {
  9882. var key = this.toKeyedSeq().findLastKey(predicate, context);
  9883. return key === undefined ? -1 : key;
  9884. },
  9885. first: function() {
  9886. return this.get(0);
  9887. },
  9888. flatten: function(depth) {
  9889. return reify(this, flattenFactory(this, depth, false));
  9890. },
  9891. get: function(index, notSetValue) {
  9892. index = wrapIndex(this, index);
  9893. return (index < 0 || (this.size === Infinity ||
  9894. (this.size !== undefined && index > this.size))) ?
  9895. notSetValue :
  9896. this.find(function(_, key) {return key === index}, undefined, notSetValue);
  9897. },
  9898. has: function(index) {
  9899. index = wrapIndex(this, index);
  9900. return index >= 0 && (this.size !== undefined ?
  9901. this.size === Infinity || index < this.size :
  9902. this.indexOf(index) !== -1
  9903. );
  9904. },
  9905. interpose: function(separator) {
  9906. return reify(this, interposeFactory(this, separator));
  9907. },
  9908. interleave: function(/*...iterables*/) {
  9909. var iterables = [this].concat(arrCopy(arguments));
  9910. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  9911. var interleaved = zipped.flatten(true);
  9912. if (zipped.size) {
  9913. interleaved.size = zipped.size * iterables.length;
  9914. }
  9915. return reify(this, interleaved);
  9916. },
  9917. last: function() {
  9918. return this.get(-1);
  9919. },
  9920. skipWhile: function(predicate, context) {
  9921. return reify(this, skipWhileFactory(this, predicate, context, false));
  9922. },
  9923. zip: function(/*, ...iterables */) {
  9924. var iterables = [this].concat(arrCopy(arguments));
  9925. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  9926. },
  9927. zipWith: function(zipper/*, ...iterables */) {
  9928. var iterables = arrCopy(arguments);
  9929. iterables[0] = this;
  9930. return reify(this, zipWithFactory(this, zipper, iterables));
  9931. }
  9932. });
  9933. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  9934. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  9935. mixin(SetIterable, {
  9936. // ### ES6 Collection methods (ES6 Array and Map)
  9937. get: function(value, notSetValue) {
  9938. return this.has(value) ? value : notSetValue;
  9939. },
  9940. includes: function(value) {
  9941. return this.has(value);
  9942. },
  9943. // ### More sequential methods
  9944. keySeq: function() {
  9945. return this.valueSeq();
  9946. }
  9947. });
  9948. SetIterable.prototype.has = IterablePrototype.includes;
  9949. // Mixin subclasses
  9950. mixin(KeyedSeq, KeyedIterable.prototype);
  9951. mixin(IndexedSeq, IndexedIterable.prototype);
  9952. mixin(SetSeq, SetIterable.prototype);
  9953. mixin(KeyedCollection, KeyedIterable.prototype);
  9954. mixin(IndexedCollection, IndexedIterable.prototype);
  9955. mixin(SetCollection, SetIterable.prototype);
  9956. // #pragma Helper functions
  9957. function keyMapper(v, k) {
  9958. return k;
  9959. }
  9960. function entryMapper(v, k) {
  9961. return [k, v];
  9962. }
  9963. function not(predicate) {
  9964. return function() {
  9965. return !predicate.apply(this, arguments);
  9966. }
  9967. }
  9968. function neg(predicate) {
  9969. return function() {
  9970. return -predicate.apply(this, arguments);
  9971. }
  9972. }
  9973. function quoteString(value) {
  9974. return typeof value === 'string' ? JSON.stringify(value) : value;
  9975. }
  9976. function defaultZipper() {
  9977. return arrCopy(arguments);
  9978. }
  9979. function defaultNegComparator(a, b) {
  9980. return a < b ? 1 : a > b ? -1 : 0;
  9981. }
  9982. function hashIterable(iterable) {
  9983. if (iterable.size === Infinity) {
  9984. return 0;
  9985. }
  9986. var ordered = isOrdered(iterable);
  9987. var keyed = isKeyed(iterable);
  9988. var h = ordered ? 1 : 0;
  9989. var size = iterable.__iterate(
  9990. keyed ?
  9991. ordered ?
  9992. function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
  9993. function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
  9994. ordered ?
  9995. function(v ) { h = 31 * h + hash(v) | 0; } :
  9996. function(v ) { h = h + hash(v) | 0; }
  9997. );
  9998. return murmurHashOfSize(size, h);
  9999. }
  10000. function murmurHashOfSize(size, h) {
  10001. h = imul(h, 0xCC9E2D51);
  10002. h = imul(h << 15 | h >>> -15, 0x1B873593);
  10003. h = imul(h << 13 | h >>> -13, 5);
  10004. h = (h + 0xE6546B64 | 0) ^ size;
  10005. h = imul(h ^ h >>> 16, 0x85EBCA6B);
  10006. h = imul(h ^ h >>> 13, 0xC2B2AE35);
  10007. h = smi(h ^ h >>> 16);
  10008. return h;
  10009. }
  10010. function hashMerge(a, b) {
  10011. return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
  10012. }
  10013. var Immutable = {
  10014. Iterable: Iterable,
  10015. Seq: Seq,
  10016. Collection: Collection,
  10017. Map: Map,
  10018. OrderedMap: OrderedMap,
  10019. List: List,
  10020. Stack: Stack,
  10021. Set: Set,
  10022. OrderedSet: OrderedSet,
  10023. Record: Record,
  10024. Range: Range,
  10025. Repeat: Repeat,
  10026. is: is,
  10027. fromJS: fromJS
  10028. };
  10029. return Immutable;
  10030. }));
  10031. });
  10032. var parseHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10033. Object.defineProperty(exports, "__esModule", {
  10034. value: true
  10035. });
  10036. exports["default"] = parseHTML;
  10037. var fallback = function fallback(html) {
  10038. var doc = document.implementation.createHTMLDocument('');
  10039. doc.documentElement.innerHTML = html;
  10040. return doc;
  10041. };
  10042. function parseHTML(html) {
  10043. var doc;
  10044. if (typeof DOMParser !== 'undefined') {
  10045. var parser = new DOMParser();
  10046. doc = parser.parseFromString(html, 'text/html');
  10047. if (doc === null || doc.body === null) {
  10048. doc = fallback(html);
  10049. }
  10050. } else {
  10051. doc = fallback(html);
  10052. }
  10053. return doc.body;
  10054. }
  10055. });
  10056. _commonjsHelpers.unwrapExports(parseHTML_1);
  10057. var convertFromHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10058. Object.defineProperty(exports, "__esModule", {
  10059. value: true
  10060. });
  10061. exports["default"] = void 0;
  10062. var _parseHTML = interopRequireDefault(parseHTML_1);
  10063. var _rangeSort = interopRequireDefault(rangeSort);
  10064. /**
  10065. * Copyright (c) 2013-present, Facebook, Inc.
  10066. * All rights reserved.
  10067. *
  10068. * Copyright (c) 2013-present, Facebook, Inc.
  10069. * All rights reserved.
  10070. *
  10071. * This source code is licensed under the BSD-style license found in the
  10072. * LICENSE file in the /src directory of this source tree. An additional grant
  10073. * of patent rights can be found in the PATENTS file in the same directory.
  10074. */
  10075. var NBSP = '&nbsp;';
  10076. var SPACE = ' '; // Arbitrary max indent
  10077. var MAX_DEPTH = 4; // used for replacing characters in HTML
  10078. /* eslint-disable no-control-regex */
  10079. var REGEX_CR = new RegExp('\r', 'g');
  10080. var REGEX_LF = new RegExp('\n', 'g');
  10081. var REGEX_NBSP = new RegExp(NBSP, 'g');
  10082. var REGEX_BLOCK_DELIMITER = new RegExp('\r', 'g');
  10083. /* eslint-enable no-control-regex */
  10084. // Block tag flow is different because LIs do not have
  10085. // a deterministic style ;_;
  10086. var blockTags = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'blockquote', 'pre'];
  10087. var inlineTags = {
  10088. b: 'BOLD',
  10089. code: 'CODE',
  10090. del: 'STRIKETHROUGH',
  10091. em: 'ITALIC',
  10092. i: 'ITALIC',
  10093. s: 'STRIKETHROUGH',
  10094. strike: 'STRIKETHROUGH',
  10095. strong: 'BOLD',
  10096. u: 'UNDERLINE'
  10097. };
  10098. var handleMiddleware = function handleMiddleware(maybeMiddleware, base) {
  10099. if (maybeMiddleware && maybeMiddleware.__isMiddleware === true) {
  10100. return maybeMiddleware(base);
  10101. }
  10102. return maybeMiddleware;
  10103. };
  10104. var defaultHTMLToBlock = function defaultHTMLToBlock(nodeName, node, lastList) {
  10105. return undefined;
  10106. };
  10107. var defaultHTMLToStyle = function defaultHTMLToStyle(nodeName, node, currentStyle) {
  10108. return currentStyle;
  10109. };
  10110. var defaultHTMLToEntity = function defaultHTMLToEntity(nodeName, node) {
  10111. return undefined;
  10112. };
  10113. var defaultTextToEntity = function defaultTextToEntity(text) {
  10114. return [];
  10115. };
  10116. var nullthrows = function nullthrows(x) {
  10117. if (x != null) {
  10118. return x;
  10119. }
  10120. throw new Error('Got unexpected null or undefined');
  10121. };
  10122. var sanitizeDraftText = function sanitizeDraftText(input) {
  10123. return input.replace(REGEX_BLOCK_DELIMITER, '');
  10124. };
  10125. function getEmptyChunk() {
  10126. return {
  10127. text: '',
  10128. inlines: [],
  10129. entities: [],
  10130. blocks: []
  10131. };
  10132. }
  10133. function getWhitespaceChunk(inEntity) {
  10134. var entities = new Array(1);
  10135. if (inEntity) {
  10136. entities[0] = inEntity;
  10137. }
  10138. return {
  10139. text: SPACE,
  10140. inlines: [(0, immutable$1.OrderedSet)()],
  10141. entities: entities,
  10142. blocks: []
  10143. };
  10144. }
  10145. function getSoftNewlineChunk(block, depth) {
  10146. var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10147. var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : (0, immutable$1.Map)();
  10148. if (flat === true) {
  10149. return {
  10150. text: '\r',
  10151. inlines: [(0, immutable$1.OrderedSet)()],
  10152. entities: new Array(1),
  10153. blocks: [{
  10154. type: block,
  10155. data: data,
  10156. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  10157. }],
  10158. isNewline: true
  10159. };
  10160. }
  10161. return {
  10162. text: '\n',
  10163. inlines: [(0, immutable$1.OrderedSet)()],
  10164. entities: new Array(1),
  10165. blocks: []
  10166. };
  10167. }
  10168. function getBlockDividerChunk(block, depth) {
  10169. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, immutable$1.Map)();
  10170. return {
  10171. text: '\r',
  10172. inlines: [(0, immutable$1.OrderedSet)()],
  10173. entities: new Array(1),
  10174. blocks: [{
  10175. type: block,
  10176. data: data,
  10177. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  10178. }]
  10179. };
  10180. }
  10181. function getBlockTypeForTag(tag, lastList) {
  10182. switch (tag) {
  10183. case 'h1':
  10184. return 'header-one';
  10185. case 'h2':
  10186. return 'header-two';
  10187. case 'h3':
  10188. return 'header-three';
  10189. case 'h4':
  10190. return 'header-four';
  10191. case 'h5':
  10192. return 'header-five';
  10193. case 'h6':
  10194. return 'header-six';
  10195. case 'li':
  10196. if (lastList === 'ol') {
  10197. return 'ordered-list-item';
  10198. }
  10199. return 'unordered-list-item';
  10200. case 'blockquote':
  10201. return 'blockquote';
  10202. case 'pre':
  10203. return 'code-block';
  10204. case 'div':
  10205. case 'p':
  10206. return 'unstyled';
  10207. default:
  10208. return null;
  10209. }
  10210. }
  10211. function baseCheckBlockType(nodeName, node, lastList) {
  10212. return getBlockTypeForTag(nodeName, lastList);
  10213. }
  10214. function processInlineTag(tag, node, currentStyle) {
  10215. var styleToCheck = inlineTags[tag];
  10216. if (styleToCheck) {
  10217. currentStyle = currentStyle.add(styleToCheck).toOrderedSet();
  10218. } else if (node instanceof HTMLElement) {
  10219. var htmlElement = node;
  10220. currentStyle = currentStyle.withMutations(function (style) {
  10221. if (htmlElement.style.fontWeight === 'bold') {
  10222. style.add('BOLD');
  10223. }
  10224. if (htmlElement.style.fontStyle === 'italic') {
  10225. style.add('ITALIC');
  10226. }
  10227. if (htmlElement.style.textDecoration === 'underline') {
  10228. style.add('UNDERLINE');
  10229. }
  10230. if (htmlElement.style.textDecoration === 'line-through') {
  10231. style.add('STRIKETHROUGH');
  10232. }
  10233. }).toOrderedSet();
  10234. }
  10235. return currentStyle;
  10236. }
  10237. function baseProcessInlineTag(tag, node) {
  10238. var inlineStyles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, immutable$1.OrderedSet)();
  10239. return processInlineTag(tag, node, inlineStyles);
  10240. }
  10241. function joinChunks(A, B) {
  10242. var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10243. // Sometimes two blocks will touch in the DOM and we need to strip the
  10244. // extra delimiter to preserve niceness.
  10245. var firstInB = B.text.slice(0, 1);
  10246. var lastInA = A.text.slice(-1);
  10247. var adjacentDividers = lastInA === '\r' && firstInB === '\r';
  10248. var isJoiningBlocks = A.text !== '\r' && B.text !== '\r'; // when joining two full blocks like this we want to pop one divider
  10249. var addingNewlineToEmptyBlock = A.text === '\r' && !A.isNewline && B.isNewline; // when joining a newline to an empty block we want to remove the newline
  10250. if (adjacentDividers && (isJoiningBlocks || addingNewlineToEmptyBlock)) {
  10251. A.text = A.text.slice(0, -1);
  10252. A.inlines.pop();
  10253. A.entities.pop();
  10254. A.blocks.pop();
  10255. } // Kill whitespace after blocks if flat mode is on
  10256. if (A.text.slice(-1) === '\r' && flat === true) {
  10257. if (B.text === SPACE || B.text === '\n') {
  10258. return A;
  10259. } else if (firstInB === SPACE || firstInB === '\n') {
  10260. B.text = B.text.slice(1);
  10261. B.inlines.shift();
  10262. B.entities.shift();
  10263. }
  10264. }
  10265. var isNewline = A.text.length === 0 && B.isNewline;
  10266. return {
  10267. text: A.text + B.text,
  10268. inlines: A.inlines.concat(B.inlines),
  10269. entities: A.entities.concat(B.entities),
  10270. blocks: A.blocks.concat(B.blocks),
  10271. isNewline: isNewline
  10272. };
  10273. }
  10274. /*
  10275. * Check to see if we have anything like <p> <blockquote> <h1>... to create
  10276. * block tags from. If we do, we can use those and ignore <div> tags. If we
  10277. * don't, we can treat <div> tags as meaningful (unstyled) blocks.
  10278. */
  10279. function containsSemanticBlockMarkup(html) {
  10280. return blockTags.some(function (tag) {
  10281. return html.indexOf("<".concat(tag)) !== -1;
  10282. });
  10283. }
  10284. function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, inEntity) {
  10285. var nodeName = node.nodeName.toLowerCase();
  10286. var newBlock = false;
  10287. var nextBlockType = 'unstyled'; // Base Case
  10288. if (nodeName === '#text') {
  10289. var text = node.textContent;
  10290. if (text.trim() === '' && inBlock === null) {
  10291. return getEmptyChunk();
  10292. }
  10293. if (text.trim() === '' && inBlock !== 'code-block') {
  10294. return getWhitespaceChunk(inEntity);
  10295. }
  10296. if (inBlock !== 'code-block') {
  10297. // Can't use empty string because MSWord
  10298. text = text.replace(REGEX_LF, SPACE);
  10299. }
  10300. var entities = Array(text.length).fill(inEntity);
  10301. var offsetChange = 0;
  10302. var textEntities = checkEntityText(text, createEntity, getEntity, mergeEntityData, replaceEntityData).sort(_rangeSort["default"]);
  10303. textEntities.forEach(function (_ref) {
  10304. var entity = _ref.entity,
  10305. offset = _ref.offset,
  10306. length = _ref.length,
  10307. result = _ref.result;
  10308. var adjustedOffset = offset + offsetChange;
  10309. if (result === null || result === undefined) {
  10310. result = text.substr(adjustedOffset, length);
  10311. }
  10312. var textArray = text.split('');
  10313. textArray.splice.bind(textArray, adjustedOffset, length).apply(textArray, result.split(''));
  10314. text = textArray.join('');
  10315. entities.splice.bind(entities, adjustedOffset, length).apply(entities, Array(result.length).fill(entity));
  10316. offsetChange += result.length - length;
  10317. });
  10318. return {
  10319. text: text,
  10320. inlines: Array(text.length).fill(inlineStyle),
  10321. entities: entities,
  10322. blocks: []
  10323. };
  10324. } // BR tags
  10325. if (nodeName === 'br') {
  10326. var _blockType = inBlock;
  10327. if (_blockType === null) {
  10328. // BR tag is at top level, treat it as an unstyled block
  10329. return getSoftNewlineChunk('unstyled', depth, true);
  10330. }
  10331. return getSoftNewlineChunk(_blockType || 'unstyled', depth, options.flat);
  10332. }
  10333. var chunk = getEmptyChunk();
  10334. var newChunk = null; // Inline tags
  10335. inlineStyle = processInlineTag(nodeName, node, inlineStyle);
  10336. inlineStyle = processCustomInlineStyles(nodeName, node, inlineStyle); // Handle lists
  10337. if (nodeName === 'ul' || nodeName === 'ol') {
  10338. if (lastList) {
  10339. depth += 1;
  10340. }
  10341. lastList = nodeName;
  10342. inBlock = null;
  10343. } // Block Tags
  10344. var blockInfo = checkBlockType(nodeName, node, lastList, inBlock);
  10345. var blockType;
  10346. var blockDataMap;
  10347. if (blockInfo === false) {
  10348. return getEmptyChunk();
  10349. }
  10350. blockInfo = blockInfo || {};
  10351. if (typeof blockInfo === 'string') {
  10352. blockType = blockInfo;
  10353. blockDataMap = (0, immutable$1.Map)();
  10354. } else {
  10355. blockType = typeof blockInfo === 'string' ? blockInfo : blockInfo.type;
  10356. blockDataMap = blockInfo.data ? (0, immutable$1.Map)(blockInfo.data) : (0, immutable$1.Map)();
  10357. }
  10358. if (!inBlock && (fragmentBlockTags.indexOf(nodeName) !== -1 || blockType)) {
  10359. chunk = getBlockDividerChunk(blockType || getBlockTypeForTag(nodeName, lastList), depth, blockDataMap);
  10360. inBlock = blockType || getBlockTypeForTag(nodeName, lastList);
  10361. newBlock = true;
  10362. } else if (lastList && (inBlock === 'ordered-list-item' || inBlock === 'unordered-list-item') && nodeName === 'li') {
  10363. var listItemBlockType = getBlockTypeForTag(nodeName, lastList);
  10364. chunk = getBlockDividerChunk(listItemBlockType, depth);
  10365. inBlock = listItemBlockType;
  10366. newBlock = true;
  10367. nextBlockType = lastList === 'ul' ? 'unordered-list-item' : 'ordered-list-item';
  10368. } else if (inBlock && inBlock !== 'atomic' && blockType === 'atomic') {
  10369. inBlock = blockType;
  10370. newBlock = true;
  10371. chunk = getSoftNewlineChunk(blockType, depth, true, // atomic blocks within non-atomic blocks must always be split out
  10372. blockDataMap);
  10373. } // Recurse through children
  10374. var child = node.firstChild; // hack to allow conversion of atomic blocks from HTML (e.g. <figure><img
  10375. // src="..." /></figure>). since metadata must be stored on an entity text
  10376. // must exist for the entity to apply to. the way chunks are joined strips
  10377. // whitespace at the end so it cannot be a space character.
  10378. if (child == null && inEntity && (blockType === 'atomic' || inBlock === 'atomic')) {
  10379. child = document.createTextNode('a');
  10380. }
  10381. if (child != null) {
  10382. nodeName = child.nodeName.toLowerCase();
  10383. }
  10384. var entityId = null;
  10385. while (child) {
  10386. entityId = checkEntityNode(nodeName, child, createEntity, getEntity, mergeEntityData, replaceEntityData);
  10387. newChunk = genFragment(child, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, entityId || inEntity);
  10388. chunk = joinChunks(chunk, newChunk, options.flat);
  10389. var sibling = child.nextSibling; // Put in a newline to break up blocks inside blocks
  10390. if (sibling && fragmentBlockTags.indexOf(nodeName) >= 0 && inBlock) {
  10391. var newBlockInfo = checkBlockType(nodeName, child, lastList, inBlock);
  10392. var newBlockType = void 0;
  10393. var newBlockData = void 0;
  10394. if (newBlockInfo !== false) {
  10395. newBlockInfo = newBlockInfo || {};
  10396. if (typeof newBlockInfo === 'string') {
  10397. newBlockType = newBlockInfo;
  10398. newBlockData = (0, immutable$1.Map)();
  10399. } else {
  10400. newBlockType = newBlockInfo.type || getBlockTypeForTag(nodeName, lastList);
  10401. newBlockData = newBlockInfo.data ? (0, immutable$1.Map)(newBlockInfo.data) : (0, immutable$1.Map)();
  10402. }
  10403. chunk = joinChunks(chunk, getSoftNewlineChunk(newBlockType, depth, options.flat, newBlockData), options.flat);
  10404. }
  10405. }
  10406. if (sibling) {
  10407. nodeName = sibling.nodeName.toLowerCase();
  10408. }
  10409. child = sibling;
  10410. }
  10411. if (newBlock) {
  10412. chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, (0, immutable$1.Map)()), options.flat);
  10413. }
  10414. return chunk;
  10415. }
  10416. function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder) {
  10417. html = html.trim().replace(REGEX_CR, '').replace(REGEX_NBSP, SPACE);
  10418. var safeBody = DOMBuilder(html);
  10419. if (!safeBody) {
  10420. return null;
  10421. } // Sometimes we aren't dealing with content that contains nice semantic
  10422. // tags. In this case, use divs to separate everything out into paragraphs
  10423. // and hope for the best.
  10424. var workingBlocks = containsSemanticBlockMarkup(html) ? blockTags.concat(['div']) : ['div']; // Start with -1 block depth to offset the fact that we are passing in a fake
  10425. // UL block to sta rt with.
  10426. var chunk = genFragment(safeBody, (0, immutable$1.OrderedSet)(), 'ul', null, workingBlocks, -1, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options); // join with previous block to prevent weirdness on paste
  10427. if (chunk.text.indexOf('\r') === 0) {
  10428. chunk = {
  10429. text: chunk.text.slice(1),
  10430. inlines: chunk.inlines.slice(1),
  10431. entities: chunk.entities.slice(1),
  10432. blocks: chunk.blocks
  10433. };
  10434. } // Kill block delimiter at the end
  10435. if (chunk.text.slice(-1) === '\r') {
  10436. chunk.text = chunk.text.slice(0, -1);
  10437. chunk.inlines = chunk.inlines.slice(0, -1);
  10438. chunk.entities = chunk.entities.slice(0, -1);
  10439. chunk.blocks.pop();
  10440. } // If we saw no block tags, put an unstyled one in
  10441. if (chunk.blocks.length === 0) {
  10442. chunk.blocks.push({
  10443. type: 'unstyled',
  10444. data: (0, immutable$1.Map)(),
  10445. depth: 0
  10446. });
  10447. } // Sometimes we start with text that isn't in a block, which is then
  10448. // followed by blocks. Need to fix up the blocks to add in
  10449. // an unstyled block for this content
  10450. if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
  10451. chunk.blocks.unshift({
  10452. type: 'unstyled',
  10453. data: (0, immutable$1.Map)(),
  10454. depth: 0
  10455. });
  10456. }
  10457. return chunk;
  10458. }
  10459. function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey) {
  10460. // Be ABSOLUTELY SURE that the dom builder you pass hare won't execute
  10461. // arbitrary code in whatever environment you're running this in. For an
  10462. // example of how we try to do this in-browser, see getSafeBodyFromHTML.
  10463. var chunk = getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder);
  10464. if (chunk == null) {
  10465. return [];
  10466. }
  10467. var start = 0;
  10468. return chunk.text.split('\r').map(function (textBlock, blockIndex) {
  10469. // Make absolutely certain that our text is acceptable.
  10470. textBlock = sanitizeDraftText(textBlock);
  10471. var end = start + textBlock.length;
  10472. var inlines = nullthrows(chunk).inlines.slice(start, end);
  10473. var entities = nullthrows(chunk).entities.slice(start, end);
  10474. var characterList = (0, immutable$1.List)(inlines.map(function (style, entityIndex) {
  10475. var data = {
  10476. style: style,
  10477. entity: null
  10478. };
  10479. if (entities[entityIndex]) {
  10480. data.entity = entities[entityIndex];
  10481. }
  10482. return Draft.Draft.CharacterMetadata.create(data);
  10483. }));
  10484. start = end + 1;
  10485. return new Draft.Draft.ContentBlock({
  10486. key: generateKey(),
  10487. type: nullthrows(chunk).blocks[blockIndex].type,
  10488. data: nullthrows(chunk).blocks[blockIndex].data,
  10489. depth: nullthrows(chunk).blocks[blockIndex].depth,
  10490. text: textBlock,
  10491. characterList: characterList
  10492. });
  10493. });
  10494. }
  10495. var convertFromHTML = function convertFromHTML(_ref2) {
  10496. var _ref2$htmlToStyle = _ref2.htmlToStyle,
  10497. htmlToStyle = _ref2$htmlToStyle === void 0 ? defaultHTMLToStyle : _ref2$htmlToStyle,
  10498. _ref2$htmlToEntity = _ref2.htmlToEntity,
  10499. htmlToEntity = _ref2$htmlToEntity === void 0 ? defaultHTMLToEntity : _ref2$htmlToEntity,
  10500. _ref2$textToEntity = _ref2.textToEntity,
  10501. textToEntity = _ref2$textToEntity === void 0 ? defaultTextToEntity : _ref2$textToEntity,
  10502. _ref2$htmlToBlock = _ref2.htmlToBlock,
  10503. htmlToBlock = _ref2$htmlToBlock === void 0 ? defaultHTMLToBlock : _ref2$htmlToBlock;
  10504. return function (html) {
  10505. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  10506. flat: false
  10507. };
  10508. var DOMBuilder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _parseHTML["default"];
  10509. var generateKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Draft.Draft.genKey;
  10510. var contentState = Draft.Draft.ContentState.createFromText('');
  10511. var createEntityWithContentState = function createEntityWithContentState() {
  10512. if (contentState.createEntity) {
  10513. var _contentState;
  10514. contentState = (_contentState = contentState).createEntity.apply(_contentState, arguments);
  10515. return contentState.getLastCreatedEntityKey();
  10516. }
  10517. return Draft.Draft.Entity.create.apply(Draft.Draft.Entity, arguments);
  10518. };
  10519. var getEntityWithContentState = function getEntityWithContentState() {
  10520. if (contentState.getEntity) {
  10521. var _contentState2;
  10522. return (_contentState2 = contentState).getEntity.apply(_contentState2, arguments);
  10523. }
  10524. return Draft.Draft.Entity.get.apply(Draft.Draft.Entity, arguments);
  10525. };
  10526. var mergeEntityDataWithContentState = function mergeEntityDataWithContentState() {
  10527. if (contentState.mergeEntityData) {
  10528. var _contentState3;
  10529. contentState = (_contentState3 = contentState).mergeEntityData.apply(_contentState3, arguments);
  10530. return;
  10531. }
  10532. Draft.Draft.Entity.mergeData.apply(Draft.Draft.Entity, arguments);
  10533. };
  10534. var replaceEntityDataWithContentState = function replaceEntityDataWithContentState() {
  10535. if (contentState.replaceEntityData) {
  10536. var _contentState4;
  10537. contentState = (_contentState4 = contentState).replaceEntityData.apply(_contentState4, arguments);
  10538. return;
  10539. }
  10540. Draft.Draft.Entity.replaceData.apply(Draft.Draft.Entity, arguments);
  10541. };
  10542. var contentBlocks = convertFromHTMLtoContentBlocks(html, handleMiddleware(htmlToStyle, baseProcessInlineTag), handleMiddleware(htmlToEntity, defaultHTMLToEntity), handleMiddleware(textToEntity, defaultTextToEntity), handleMiddleware(htmlToBlock, baseCheckBlockType), createEntityWithContentState, getEntityWithContentState, mergeEntityDataWithContentState, replaceEntityDataWithContentState, options, DOMBuilder, generateKey);
  10543. var blockMap = Draft.Draft.BlockMapBuilder.createFromArray(contentBlocks);
  10544. var firstBlockKey = contentBlocks[0].getKey();
  10545. return contentState.merge({
  10546. blockMap: blockMap,
  10547. selectionBefore: Draft.Draft.SelectionState.createEmpty(firstBlockKey),
  10548. selectionAfter: Draft.Draft.SelectionState.createEmpty(firstBlockKey)
  10549. });
  10550. };
  10551. };
  10552. var _default = function _default() {
  10553. if (arguments.length >= 1 && typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'string') {
  10554. return convertFromHTML({}).apply(void 0, arguments);
  10555. }
  10556. return convertFromHTML.apply(void 0, arguments);
  10557. };
  10558. exports["default"] = _default;
  10559. });
  10560. _commonjsHelpers.unwrapExports(convertFromHTML_1);
  10561. var lib = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10562. Object.defineProperty(exports, "__esModule", {
  10563. value: true
  10564. });
  10565. Object.defineProperty(exports, "convertToHTML", {
  10566. enumerable: true,
  10567. get: function get() {
  10568. return _convertToHTML["default"];
  10569. }
  10570. });
  10571. Object.defineProperty(exports, "convertFromHTML", {
  10572. enumerable: true,
  10573. get: function get() {
  10574. return _convertFromHTML["default"];
  10575. }
  10576. });
  10577. Object.defineProperty(exports, "parseHTML", {
  10578. enumerable: true,
  10579. get: function get() {
  10580. return _parseHTML["default"];
  10581. }
  10582. });
  10583. var _convertToHTML = interopRequireDefault(convertToHTML_1);
  10584. var _convertFromHTML = interopRequireDefault(convertFromHTML_1);
  10585. var _parseHTML = interopRequireDefault(parseHTML_1);
  10586. });
  10587. _commonjsHelpers.unwrapExports(lib);
  10588. var configs = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10589. Object.defineProperty(exports, "__esModule", {
  10590. value: true
  10591. });
  10592. exports.getFromHTMLConfig = exports.getToHTMLConfig = exports.blocks = exports.getHexColor = exports.defaultFontFamilies = exports.namedColors = undefined;
  10593. 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; };
  10594. var _react2 = _interopRequireDefault(React__default);
  10595. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10596. 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; }
  10597. var namedColors = exports.namedColors = {
  10598. "aliceblue": "#f0f8ff",
  10599. "antiquewhite": "#faebd7",
  10600. "aqua": "#00ffff",
  10601. "aquamarine": "#7fffd4",
  10602. "azure": "#f0ffff",
  10603. "beige": "#f5f5dc",
  10604. "bisque": "#ffe4c4",
  10605. "black": "#000000",
  10606. "blanchedalmond": "#ffebcd",
  10607. "blue": "#0000ff",
  10608. "blueviolet": "#8a2be2",
  10609. "brown": "#a52a2a",
  10610. "burlywood": "#deb887",
  10611. "cadetblue": "#5f9ea0",
  10612. "chartreuse": "#7fff00",
  10613. "chocolate": "#d2691e",
  10614. "coral": "#ff7f50",
  10615. "cornflowerblue": "#6495ed",
  10616. "cornsilk": "#fff8dc",
  10617. "crimson": "#dc143c",
  10618. "cyan": "#00ffff",
  10619. "darkblue": "#00008b",
  10620. "darkcyan": "#008b8b",
  10621. "darkgoldenrod": "#b8860b",
  10622. "darkgray": "#a9a9a9",
  10623. "darkgreen": "#006400",
  10624. "darkkhaki": "#bdb76b",
  10625. "darkmagenta": "#8b008b",
  10626. "darkolivegreen": "#556b2f",
  10627. "darkorange": "#ff8c00",
  10628. "darkorchid": "#9932cc",
  10629. "darkred": "#8b0000",
  10630. "darksalmon": "#e9967a",
  10631. "darkseagreen": "#8fbc8f",
  10632. "darkslateblue": "#483d8b",
  10633. "darkslategray": "#2f4f4f",
  10634. "darkturquoise": "#00ced1",
  10635. "darkviolet": "#9400d3",
  10636. "deeppink": "#ff1493",
  10637. "deepskyblue": "#00bfff",
  10638. "dimgray": "#696969",
  10639. "dodgerblue": "#1e90ff",
  10640. "firebrick": "#b22222",
  10641. "floralwhite": "#fffaf0",
  10642. "forestgreen": "#228b22",
  10643. "fuchsia": "#ff00ff",
  10644. "gainsboro": "#dcdcdc",
  10645. "ghostwhite": "#f8f8ff",
  10646. "gold": "#ffd700",
  10647. "goldenrod": "#daa520",
  10648. "gray": "#808080",
  10649. "green": "#008000",
  10650. "greenyellow": "#adff2f",
  10651. "honeydew": "#f0fff0",
  10652. "hotpink": "#ff69b4",
  10653. "indianred ": "#cd5c5c",
  10654. "indigo": "#4b0082",
  10655. "ivory": "#fffff0",
  10656. "khaki": "#f0e68c",
  10657. "lavender": "#e6e6fa",
  10658. "lavenderblush": "#fff0f5",
  10659. "lawngreen": "#7cfc00",
  10660. "lemonchiffon": "#fffacd",
  10661. "lightblue": "#add8e6",
  10662. "lightcoral": "#f08080",
  10663. "lightcyan": "#e0ffff",
  10664. "lightgoldenrodyellow": "#fafad2",
  10665. "lightgrey": "#d3d3d3",
  10666. "lightgreen": "#90ee90",
  10667. "lightpink": "#ffb6c1",
  10668. "lightsalmon": "#ffa07a",
  10669. "lightseagreen": "#20b2aa",
  10670. "lightskyblue": "#87cefa",
  10671. "lightslategray": "#778899",
  10672. "lightsteelblue": "#b0c4de",
  10673. "lightyellow": "#ffffe0",
  10674. "lime": "#00ff00",
  10675. "limegreen": "#32cd32",
  10676. "linen": "#faf0e6",
  10677. "magenta": "#ff00ff",
  10678. "maroon": "#800000",
  10679. "mediumaquamarine": "#66cdaa",
  10680. "mediumblue": "#0000cd",
  10681. "mediumorchid": "#ba55d3",
  10682. "mediumpurple": "#9370d8",
  10683. "mediumseagreen": "#3cb371",
  10684. "mediumslateblue": "#7b68ee",
  10685. "mediumspringgreen": "#00fa9a",
  10686. "mediumturquoise": "#48d1cc",
  10687. "mediumvioletred": "#c71585",
  10688. "midnightblue": "#191970",
  10689. "mintcream": "#f5fffa",
  10690. "mistyrose": "#ffe4e1",
  10691. "moccasin": "#ffe4b5",
  10692. "navajowhite": "#ffdead",
  10693. "navy": "#000080",
  10694. "oldlace": "#fdf5e6",
  10695. "olive": "#808000",
  10696. "olivedrab": "#6b8e23",
  10697. "orange": "#ffa500",
  10698. "orangered": "#ff4500",
  10699. "orchid": "#da70d6",
  10700. "palegoldenrod": "#eee8aa",
  10701. "palegreen": "#98fb98",
  10702. "paleturquoise": "#afeeee",
  10703. "palevioletred": "#d87093",
  10704. "papayawhip": "#ffefd5",
  10705. "peachpuff": "#ffdab9",
  10706. "peru": "#cd853f",
  10707. "pink": "#ffc0cb",
  10708. "plum": "#dda0dd",
  10709. "powderblue": "#b0e0e6",
  10710. "purple": "#800080",
  10711. "rebeccapurple": "#663399",
  10712. "red": "#ff0000",
  10713. "rosybrown": "#bc8f8f",
  10714. "royalblue": "#4169e1",
  10715. "saddlebrown": "#8b4513",
  10716. "salmon": "#fa8072",
  10717. "sandybrown": "#f4a460",
  10718. "seagreen": "#2e8b57",
  10719. "seashell": "#fff5ee",
  10720. "sienna": "#a0522d",
  10721. "silver": "#c0c0c0",
  10722. "skyblue": "#87ceeb",
  10723. "slateblue": "#6a5acd",
  10724. "slategray": "#708090",
  10725. "snow": "#fffafa",
  10726. "springgreen": "#00ff7f",
  10727. "steelblue": "#4682b4",
  10728. "tan": "#d2b48c",
  10729. "teal": "#008080",
  10730. "thistle": "#d8bfd8",
  10731. "tomato": "#ff6347",
  10732. "turquoise": "#40e0d0",
  10733. "violet": "#ee82ee",
  10734. "wheat": "#f5deb3",
  10735. "white": "#ffffff",
  10736. "whitesmoke": "#f5f5f5",
  10737. "yellow": "#ffff00",
  10738. "yellowgreen": "#9acd32"
  10739. };
  10740. var getStyleValue = function getStyleValue(style) {
  10741. return style.split('-')[1];
  10742. };
  10743. var defaultUnitExportFn = function defaultUnitExportFn(unit) {
  10744. return unit + 'px';
  10745. };
  10746. var defaultUnitImportFn = function defaultUnitImportFn(unit) {
  10747. return unit.replace('px', '');
  10748. };
  10749. var ignoredNodeAttributes = ['style'];
  10750. var ignoredEntityNodeAttributes = ['style', 'href', 'target', 'alt', 'title', 'id', 'controls', 'autoplay', 'loop', 'poster'];
  10751. var spreadNodeAttributes = function spreadNodeAttributes(attributesObject) {
  10752. return Object.keys(attributesObject).reduce(function (attributeString, attributeName) {
  10753. return attributeString + " " + attributeName + "=\"" + attributesObject[attributeName] + "\"";
  10754. }, '').replace(/^\s$/, '');
  10755. };
  10756. var defaultFontFamilies = exports.defaultFontFamilies = [{
  10757. name: 'Araial',
  10758. family: 'Arial, Helvetica, sans-serif'
  10759. }, {
  10760. name: 'Georgia',
  10761. family: 'Georgia, serif'
  10762. }, {
  10763. name: 'Impact',
  10764. family: 'Impact, serif'
  10765. }, {
  10766. name: 'Monospace',
  10767. family: '"Courier New", Courier, monospace'
  10768. }, {
  10769. name: 'Tahoma',
  10770. family: "tahoma, arial, 'Hiragino Sans GB', 宋体, sans-serif"
  10771. }];
  10772. var getHexColor = exports.getHexColor = function getHexColor(color) {
  10773. color = color.replace('color:', '').replace(';', '').replace(' ', '');
  10774. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  10775. return color;
  10776. } else if (namedColors[color]) {
  10777. return namedColors[color];
  10778. } else if (color.indexOf('rgb') === 0) {
  10779. var rgbArray = color.split(',');
  10780. var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
  10781. var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
  10782. return hex.length === 1 ? '0' + hex : hex;
  10783. }).join('');
  10784. return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
  10785. );
  10786. } else {
  10787. return null;
  10788. }
  10789. };
  10790. var blocks = exports.blocks = {
  10791. 'header-one': 'h1',
  10792. 'header-two': 'h2',
  10793. 'header-three': 'h3',
  10794. 'header-four': 'h4',
  10795. 'header-five': 'h5',
  10796. 'header-six': 'h6',
  10797. 'unstyled': 'p',
  10798. 'blockquote': 'blockquote'
  10799. };
  10800. var blockTypes = Object.keys(blocks);
  10801. var blockNames = blockTypes.map(function (key) {
  10802. return blocks[key];
  10803. });
  10804. var convertAtomicBlock = function convertAtomicBlock(block, contentState, blockNodeAttributes) {
  10805. if (!block || !block.key) {
  10806. return _react2.default.createElement("p", null);
  10807. }
  10808. var contentBlock = contentState.getBlockForKey(block.key);
  10809. var className = blockNodeAttributes.class,
  10810. nodeAttrAsProps = _objectWithoutProperties(blockNodeAttributes, ["class"]);
  10811. nodeAttrAsProps.className = className;
  10812. if (!contentBlock) {
  10813. return _react2.default.createElement("p", null);
  10814. }
  10815. var entityKey = contentBlock.getEntityAt(0);
  10816. if (!entityKey) {
  10817. return _react2.default.createElement("p", null);
  10818. }
  10819. var entity = contentState.getEntity(entityKey);
  10820. var mediaType = entity.getType().toLowerCase();
  10821. var _block$data = block.data,
  10822. float = _block$data.float,
  10823. alignment = _block$data.alignment;
  10824. var _entity$getData = entity.getData(),
  10825. url = _entity$getData.url,
  10826. link = _entity$getData.link,
  10827. link_target = _entity$getData.link_target,
  10828. width = _entity$getData.width,
  10829. height = _entity$getData.height,
  10830. meta = _entity$getData.meta;
  10831. if (mediaType === 'image') {
  10832. var imageWrapStyle = {};
  10833. var styledClassName = '';
  10834. if (float) {
  10835. imageWrapStyle.float = float;
  10836. styledClassName += ' float-' + float;
  10837. } else if (alignment) {
  10838. imageWrapStyle.textAlign = alignment;
  10839. styledClassName += ' align-' + alignment;
  10840. }
  10841. if (link) {
  10842. return _react2.default.createElement(
  10843. "div",
  10844. { className: "media-wrap image-wrap" + styledClassName, style: imageWrapStyle },
  10845. _react2.default.createElement(
  10846. "a",
  10847. { style: { display: 'inline-block' }, href: link, target: link_target },
  10848. _react2.default.createElement("img", _extends({}, nodeAttrAsProps, meta, { src: url, width: width, height: height, style: { width: width, height: height } }))
  10849. )
  10850. );
  10851. } else {
  10852. return _react2.default.createElement(
  10853. "div",
  10854. { className: "media-wrap image-wrap" + styledClassName, style: imageWrapStyle },
  10855. _react2.default.createElement("img", _extends({}, nodeAttrAsProps, meta, { src: url, width: width, height: height, style: { width: width, height: height } }))
  10856. );
  10857. }
  10858. } else if (mediaType === 'audio') {
  10859. return _react2.default.createElement(
  10860. "div",
  10861. { className: "media-wrap audio-wrap" },
  10862. _react2.default.createElement("audio", _extends({ controls: true }, nodeAttrAsProps, meta, { src: url }))
  10863. );
  10864. } else if (mediaType === 'video') {
  10865. return _react2.default.createElement(
  10866. "div",
  10867. { className: "media-wrap video-wrap" },
  10868. _react2.default.createElement("video", _extends({ controls: true }, nodeAttrAsProps, meta, { src: url, width: width, height: height }))
  10869. );
  10870. } else if (mediaType === 'embed') {
  10871. return _react2.default.createElement(
  10872. "div",
  10873. { className: "media-wrap embed-wrap" },
  10874. _react2.default.createElement("div", { dangerouslySetInnerHTML: { __html: url } })
  10875. );
  10876. } else if (mediaType === 'hr') {
  10877. return _react2.default.createElement("hr", null);
  10878. } else {
  10879. return _react2.default.createElement("p", null);
  10880. }
  10881. };
  10882. var entityToHTML = function entityToHTML(options) {
  10883. return function (entity, originalText) {
  10884. var entityExportFn = options.entityExportFn;
  10885. var entityType = entity.type.toLowerCase();
  10886. if (entityExportFn) {
  10887. var customOutput = entityExportFn(entity, originalText);
  10888. if (customOutput) {
  10889. return customOutput;
  10890. }
  10891. }
  10892. if (entityType === 'link') {
  10893. var _ref = entity.data.nodeAttributes || {},
  10894. className = _ref.class,
  10895. nodeAttrAsProps = _objectWithoutProperties(_ref, ["class"]);
  10896. nodeAttrAsProps.className = className;
  10897. return _react2.default.createElement("a", _extends({ href: entity.data.href, target: entity.data.target }, nodeAttrAsProps));
  10898. }
  10899. };
  10900. };
  10901. var styleToHTML = function styleToHTML(options) {
  10902. return function (style) {
  10903. var unitExportFn = options.unitExportFn || defaultUnitExportFn;
  10904. if (options.styleExportFn) {
  10905. var customOutput = options.styleExportFn(style, options);
  10906. if (customOutput) {
  10907. return customOutput;
  10908. }
  10909. }
  10910. style = style.toLowerCase();
  10911. if (style === 'strikethrough') {
  10912. return _react2.default.createElement("span", { style: { textDecoration: 'line-through' } });
  10913. } else if (style === 'superscript') {
  10914. return _react2.default.createElement("sup", null);
  10915. } else if (style === 'subscript') {
  10916. return _react2.default.createElement("sub", null);
  10917. } else if (style.indexOf('color-') === 0) {
  10918. return _react2.default.createElement("span", { style: { color: '#' + getStyleValue(style) } });
  10919. } else if (style.indexOf('bgcolor-') === 0) {
  10920. return _react2.default.createElement("span", { style: { backgroundColor: '#' + getStyleValue(style) } });
  10921. } else if (style.indexOf('fontsize-') === 0) {
  10922. return _react2.default.createElement("span", { style: { fontSize: unitExportFn(getStyleValue(style), 'font-size', 'html') } });
  10923. } else if (style.indexOf('lineheight-') === 0) {
  10924. return _react2.default.createElement("span", { style: { lineHeight: unitExportFn(getStyleValue(style), 'line-height', 'html') } });
  10925. } else if (style.indexOf('letterspacing-') === 0) {
  10926. return _react2.default.createElement("span", { style: { letterSpacing: unitExportFn(getStyleValue(style), 'letter-spacing', 'html') } });
  10927. } else if (style.indexOf('fontfamily-') === 0) {
  10928. var fontFamily = options.fontFamilies.find(function (item) {
  10929. return item.name.toLowerCase() === getStyleValue(style);
  10930. });
  10931. if (!fontFamily) return;
  10932. return _react2.default.createElement("span", { style: { fontFamily: fontFamily.family } });
  10933. }
  10934. };
  10935. };
  10936. var blockToHTML = function blockToHTML(options) {
  10937. return function (block) {
  10938. var blockExportFn = options.blockExportFn,
  10939. contentState = options.contentState;
  10940. if (blockExportFn) {
  10941. var customOutput = blockExportFn(contentState, block);
  10942. if (customOutput) {
  10943. return customOutput;
  10944. }
  10945. }
  10946. var blockStyle = '';
  10947. var blockType = block.type.toLowerCase();
  10948. var _block$data2 = block.data,
  10949. textAlign = _block$data2.textAlign,
  10950. textIndent = _block$data2.textIndent,
  10951. _block$data2$nodeAttr = _block$data2.nodeAttributes,
  10952. nodeAttributes = _block$data2$nodeAttr === undefined ? {} : _block$data2$nodeAttr;
  10953. var attributeString = spreadNodeAttributes(nodeAttributes);
  10954. if (textAlign || textIndent) {
  10955. blockStyle = ' style="';
  10956. if (textAlign) {
  10957. blockStyle += "text-align:" + textAlign + ";";
  10958. }
  10959. if (textIndent && !isNaN(textIndent) && textIndent > 0) {
  10960. blockStyle += "text-indent:" + textIndent * 2 + "em;";
  10961. }
  10962. blockStyle += '"';
  10963. }
  10964. if (blockType === 'atomic') {
  10965. return convertAtomicBlock(block, contentState, nodeAttributes);
  10966. } else if (blockType === 'code-block') {
  10967. var previousBlock = contentState.getBlockBefore(block.key);
  10968. var nextBlock = contentState.getBlockAfter(block.key);
  10969. var previousBlockType = previousBlock && previousBlock.getType();
  10970. var nextBlockType = nextBlock && nextBlock.getType();
  10971. var start = '';
  10972. var end = '';
  10973. if (previousBlockType !== 'code-block') {
  10974. start = "<pre" + attributeString + "><code>";
  10975. } else {
  10976. start = '';
  10977. }
  10978. if (nextBlockType !== 'code-block') {
  10979. end = '</code></pre>';
  10980. } else {
  10981. end = '<br/>';
  10982. }
  10983. return { start: start, end: end };
  10984. } else if (blocks[blockType]) {
  10985. return {
  10986. start: "<" + blocks[blockType] + blockStyle + attributeString + ">",
  10987. end: "</" + blocks[blockType] + ">"
  10988. };
  10989. } else if (blockType === 'unordered-list-item') {
  10990. return {
  10991. start: "<li" + blockStyle + attributeString + ">",
  10992. end: '</li>',
  10993. nest: _react2.default.createElement("ul", null)
  10994. };
  10995. } else if (blockType === 'ordered-list-item') {
  10996. return {
  10997. start: "<li" + blockStyle + attributeString + ">",
  10998. end: '</li>',
  10999. nest: _react2.default.createElement("ol", null)
  11000. };
  11001. }
  11002. };
  11003. };
  11004. var htmlToStyle = function htmlToStyle(options, source) {
  11005. return function (nodeName, node, currentStyle) {
  11006. if (!node || !node.style) {
  11007. return currentStyle;
  11008. }
  11009. var unitImportFn = options.unitImportFn || defaultUnitImportFn;
  11010. var newStyle = currentStyle;
  11011. [].forEach.call(node.style, function (style) {
  11012. if (nodeName === 'span' && style === 'color') {
  11013. var color = getHexColor(node.style.color);
  11014. newStyle = color ? newStyle.add('COLOR-' + color.replace('#', '').toUpperCase()) : newStyle;
  11015. } else if (nodeName === 'span' && style === 'background-color') {
  11016. var _color = getHexColor(node.style.backgroundColor);
  11017. newStyle = _color ? newStyle.add('BGCOLOR-' + _color.replace('#', '').toUpperCase()) : newStyle;
  11018. } else if (nodeName === 'span' && style === 'font-size') {
  11019. newStyle = newStyle.add('FONTSIZE-' + unitImportFn(node.style.fontSize, 'font-size', source));
  11020. } else if (nodeName === 'span' && style === 'line-height' && !isNaN(parseFloat(node.style.lineHeight, 10))) {
  11021. newStyle = newStyle.add('LINEHEIGHT-' + unitImportFn(node.style.lineHeight, 'line-height', source));
  11022. } else if (nodeName === 'span' && style === 'letter-spacing' && !isNaN(parseFloat(node.style.letterSpacing, 10))) {
  11023. newStyle = newStyle.add('LETTERSPACING-' + unitImportFn(node.style.letterSpacing, 'letter-spacing', source));
  11024. } else if (nodeName === 'span' && style === 'text-decoration') {
  11025. if (node.style.textDecoration === 'line-through') {
  11026. newStyle = newStyle.add('STRIKETHROUGH');
  11027. } else if (node.style.textDecoration === 'underline') {
  11028. newStyle = newStyle.add('UNDERLINE');
  11029. }
  11030. } else if (nodeName === 'span' && style === 'font-family') {
  11031. var fontFamily = options.fontFamilies.find(function (item) {
  11032. return item.family.toLowerCase() === node.style.fontFamily.toLowerCase();
  11033. });
  11034. if (!fontFamily) return;
  11035. newStyle = newStyle.add('FONTFAMILY-' + fontFamily.name.toUpperCase());
  11036. }
  11037. });
  11038. if (nodeName === 'sup') {
  11039. newStyle = newStyle.add('SUPERSCRIPT');
  11040. } else if (nodeName === 'sub') {
  11041. newStyle = newStyle.add('SUBSCRIPT');
  11042. }
  11043. options.styleImportFn && (newStyle = options.styleImportFn(nodeName, node, newStyle, source) || newStyle);
  11044. return newStyle;
  11045. };
  11046. };
  11047. var htmlToEntity = function htmlToEntity(options, source) {
  11048. return function (nodeName, node, createEntity) {
  11049. if (options && options.entityImportFn) {
  11050. var customInput = options.entityImportFn(nodeName, node, createEntity, source);
  11051. if (customInput) {
  11052. return customInput;
  11053. }
  11054. }
  11055. nodeName = nodeName.toLowerCase();
  11056. var alt = node.alt,
  11057. title = node.title,
  11058. id = node.id,
  11059. controls = node.controls,
  11060. autoplay = node.autoplay,
  11061. loop = node.loop,
  11062. poster = node.poster;
  11063. var meta = {};
  11064. var nodeAttributes = {};
  11065. id && (meta.id = id);
  11066. alt && (meta.alt = alt);
  11067. title && (meta.title = title);
  11068. controls && (meta.controls = controls);
  11069. autoplay && (meta.autoPlay = autoplay);
  11070. loop && (meta.loop = loop);
  11071. poster && (meta.poster = poster);
  11072. node.attributes && Object.keys(node.attributes).forEach(function (key) {
  11073. var attr = node.attributes[key];
  11074. ignoredEntityNodeAttributes.indexOf(attr.name) === -1 && (nodeAttributes[attr.name] = attr.value);
  11075. });
  11076. if (nodeName === 'a' && !node.querySelectorAll('img').length) {
  11077. var href = node.getAttribute('href');
  11078. var _target = node.getAttribute('target');
  11079. return createEntity('LINK', 'MUTABLE', { href: href, target: _target, nodeAttributes: nodeAttributes });
  11080. } else if (nodeName === 'audio') {
  11081. return createEntity('AUDIO', 'IMMUTABLE', { url: node.getAttribute('src'), meta: meta, nodeAttributes: nodeAttributes });
  11082. } else if (nodeName === 'video') {
  11083. return createEntity('VIDEO', 'IMMUTABLE', { url: node.getAttribute('src'), meta: meta, nodeAttributes: nodeAttributes });
  11084. } else if (nodeName === 'img') {
  11085. var parentNode = node.parentNode;
  11086. var entityData = { meta: meta };
  11087. var _node$style = node.style,
  11088. width = _node$style.width,
  11089. height = _node$style.height;
  11090. entityData.url = node.getAttribute('src');
  11091. width && (entityData.width = width);
  11092. height && (entityData.height = height);
  11093. if (parentNode.nodeName.toLowerCase() === 'a') {
  11094. entityData.link = parentNode.getAttribute('href');
  11095. entityData.link_target = parentNode.getAttribute('target');
  11096. }
  11097. return createEntity('IMAGE', 'IMMUTABLE', entityData);
  11098. } else if (nodeName === 'hr') {
  11099. return createEntity('HR', 'IMMUTABLE', {});
  11100. } else if (node.parentNode && node.parentNode.classList.contains('embed-wrap')) {
  11101. var embedContent = node.innerHTML || node.outerHTML;
  11102. if (embedContent) {
  11103. return createEntity('EMBED', 'IMMUTABLE', {
  11104. url: embedContent
  11105. });
  11106. }
  11107. }
  11108. };
  11109. };
  11110. var htmlToBlock = function htmlToBlock(options, source) {
  11111. return function (nodeName, node) {
  11112. if (options && options.blockImportFn) {
  11113. var customInput = options.blockImportFn(nodeName, node, source);
  11114. if (customInput) {
  11115. return customInput;
  11116. }
  11117. }
  11118. var nodeAttributes = {};
  11119. var nodeStyle = node.style || {};
  11120. node.attributes && Object.keys(node.attributes).forEach(function (key) {
  11121. var attr = node.attributes[key];
  11122. ignoredNodeAttributes.indexOf(attr.name) === -1 && (nodeAttributes[attr.name] = attr.value);
  11123. });
  11124. if (node.classList && node.classList.contains('media-wrap')) {
  11125. return {
  11126. type: 'atomic',
  11127. data: {
  11128. nodeAttributes: nodeAttributes,
  11129. float: nodeStyle.float,
  11130. alignment: nodeStyle.textAlign
  11131. }
  11132. };
  11133. } else if (nodeName === 'img') {
  11134. return {
  11135. type: 'atomic',
  11136. data: {
  11137. nodeAttributes: nodeAttributes,
  11138. float: nodeStyle.float,
  11139. alignment: nodeStyle.textAlign
  11140. }
  11141. };
  11142. } else if (nodeName === 'hr') {
  11143. return {
  11144. type: 'atomic',
  11145. data: { nodeAttributes: nodeAttributes }
  11146. };
  11147. } else if (nodeName === 'pre') {
  11148. node.innerHTML = node.innerHTML.replace(/<code(.*?)>/g, '').replace(/<\/code>/g, '');
  11149. return {
  11150. type: 'code-block',
  11151. data: { nodeAttributes: nodeAttributes }
  11152. };
  11153. } else if (blockNames.indexOf(nodeName) !== -1) {
  11154. var blockData = { nodeAttributes: nodeAttributes };
  11155. if (nodeStyle.textAlign) {
  11156. blockData.textAlign = nodeStyle.textAlign;
  11157. }
  11158. if (nodeStyle.textIndent) {
  11159. blockData.textIndent = /^\d+em$/.test(nodeStyle.textIndent) ? Math.ceil(parseInt(nodeStyle.textIndent, 10) / 2) : 1;
  11160. }
  11161. return {
  11162. type: blockTypes[blockNames.indexOf(nodeName)],
  11163. data: blockData
  11164. };
  11165. }
  11166. };
  11167. };
  11168. var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(options) {
  11169. return {
  11170. styleToHTML: styleToHTML(options),
  11171. entityToHTML: entityToHTML(options),
  11172. blockToHTML: blockToHTML(options)
  11173. };
  11174. };
  11175. var getFromHTMLConfig = exports.getFromHTMLConfig = function getFromHTMLConfig(options) {
  11176. var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unknow';
  11177. return {
  11178. htmlToStyle: htmlToStyle(options, source),
  11179. htmlToEntity: htmlToEntity(options, source),
  11180. htmlToBlock: htmlToBlock(options, source)
  11181. };
  11182. };
  11183. });
  11184. _commonjsHelpers.unwrapExports(configs);
  11185. var configs_1 = configs.getFromHTMLConfig;
  11186. var configs_2 = configs.getToHTMLConfig;
  11187. var configs_3 = configs.blocks;
  11188. var configs_4 = configs.getHexColor;
  11189. var configs_5 = configs.defaultFontFamilies;
  11190. var configs_6 = configs.namedColors;
  11191. var dist = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11192. Object.defineProperty(exports, "__esModule", {
  11193. value: true
  11194. });
  11195. exports.convertRawToEditorState = exports.convertEditorStateToRaw = exports.convertHTMLToEditorState = exports.convertEditorStateToHTML = exports.convertHTMLToRaw = exports.convertRawToHTML = undefined;
  11196. 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; };
  11197. var defaultConvertOptions = {
  11198. fontFamilies: configs.defaultFontFamilies
  11199. };
  11200. var convertRawToHTML = exports.convertRawToHTML = function convertRawToHTML(rawContent, options) {
  11201. options = _extends({}, defaultConvertOptions, options);
  11202. try {
  11203. var contentState = (0, Draft.Draft.convertFromRaw)(rawContent);
  11204. options.contentState = contentState;
  11205. return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(contentState);
  11206. } catch (error) {
  11207. console.warn(error);
  11208. return '';
  11209. }
  11210. };
  11211. var convertHTMLToRaw = exports.convertHTMLToRaw = function convertHTMLToRaw(HTMLString, options, source) {
  11212. options = _extends({}, defaultConvertOptions, options);
  11213. try {
  11214. var contentState = (0, lib.convertFromHTML)((0, configs.getFromHTMLConfig)(options, source))(HTMLString);
  11215. return (0, Draft.Draft.convertToRaw)(contentState);
  11216. } catch (error) {
  11217. console.warn(error);
  11218. return {};
  11219. }
  11220. };
  11221. var convertEditorStateToHTML = exports.convertEditorStateToHTML = function convertEditorStateToHTML(editorState, options) {
  11222. options = _extends({}, defaultConvertOptions, options);
  11223. try {
  11224. var contentState = editorState.getCurrentContent();
  11225. options.contentState = contentState;
  11226. return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(contentState);
  11227. } catch (error) {
  11228. console.warn(error);
  11229. return '';
  11230. }
  11231. };
  11232. var convertHTMLToEditorState = exports.convertHTMLToEditorState = function convertHTMLToEditorState(HTMLString, editorDecorators, options, source) {
  11233. options = _extends({}, defaultConvertOptions, options);
  11234. try {
  11235. return Draft.Draft.EditorState.createWithContent((0, lib.convertFromHTML)((0, configs.getFromHTMLConfig)(options, source))(HTMLString), editorDecorators);
  11236. } catch (error) {
  11237. console.warn(error);
  11238. return Draft.Draft.EditorState.createEmpty(editorDecorators);
  11239. }
  11240. };
  11241. var convertEditorStateToRaw = exports.convertEditorStateToRaw = function convertEditorStateToRaw(editorState) {
  11242. return (0, Draft.Draft.convertToRaw)(editorState.getCurrentContent());
  11243. };
  11244. var convertRawToEditorState = exports.convertRawToEditorState = function convertRawToEditorState(rawContent, editorDecorators) {
  11245. try {
  11246. return Draft.Draft.EditorState.createWithContent((0, Draft.Draft.convertFromRaw)(rawContent), editorDecorators);
  11247. } catch (error) {
  11248. console.warn(error);
  11249. return Draft.Draft.EditorState.createEmpty(editorDecorators);
  11250. }
  11251. };
  11252. });
  11253. _commonjsHelpers.unwrapExports(dist);
  11254. var dist_1 = dist.convertRawToEditorState;
  11255. var dist_2 = dist.convertEditorStateToRaw;
  11256. var dist_3 = dist.convertHTMLToEditorState;
  11257. var dist_4 = dist.convertEditorStateToHTML;
  11258. var dist_5 = dist.convertHTMLToRaw;
  11259. var dist_6 = dist.convertRawToHTML;
  11260. var content = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11261. Object.defineProperty(exports, "__esModule", {
  11262. value: true
  11263. });
  11264. 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;
  11265. var _immutable2 = _interopRequireDefault(immutable);
  11266. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11267. var strictBlockTypes = ['atomic'];
  11268. var registerStrictBlockType = exports.registerStrictBlockType = function registerStrictBlockType(blockType) {
  11269. strictBlockTypes.indexOf(blockType) === -1 && strictBlockTypes.push(blockType);
  11270. };
  11271. var isEditorState = exports.isEditorState = function isEditorState(editorState) {
  11272. return editorState instanceof Draft.Draft.EditorState;
  11273. };
  11274. var createEmptyEditorState = exports.createEmptyEditorState = function createEmptyEditorState(editorDecorators) {
  11275. return Draft.Draft.EditorState.createEmpty(editorDecorators);
  11276. };
  11277. var createEditorState = exports.createEditorState = function createEditorState(contentState, editorDecorators) {
  11278. return Draft.Draft.EditorState.createWithContent(contentState, editorDecorators);
  11279. };
  11280. var isSelectionCollapsed = exports.isSelectionCollapsed = function isSelectionCollapsed(editorState) {
  11281. return editorState.getSelection().isCollapsed();
  11282. };
  11283. var selectionContainsBlockType = exports.selectionContainsBlockType = function selectionContainsBlockType(editorState, blockType) {
  11284. return getSelectedBlocks(editorState).find(function (block) {
  11285. return block.getType() === blockType;
  11286. });
  11287. };
  11288. var selectionContainsStrictBlock = exports.selectionContainsStrictBlock = function selectionContainsStrictBlock(editorState) {
  11289. return getSelectedBlocks(editorState).find(function (block) {
  11290. return ~strictBlockTypes.indexOf(block.getType());
  11291. });
  11292. };
  11293. var selectBlock = exports.selectBlock = function selectBlock(editorState, block) {
  11294. var blockKey = block.getKey();
  11295. return Draft.Draft.EditorState.forceSelection(editorState, new Draft.Draft.SelectionState({
  11296. anchorKey: blockKey,
  11297. anchorOffset: 0,
  11298. focusKey: blockKey,
  11299. focusOffset: block.getLength()
  11300. }));
  11301. };
  11302. var selectNextBlock = exports.selectNextBlock = function selectNextBlock(editorState, block) {
  11303. var nextBlock = editorState.getCurrentContent().getBlockAfter(block.getKey());
  11304. return nextBlock ? selectBlock(editorState, nextBlock) : editorState;
  11305. };
  11306. var removeBlock = exports.removeBlock = function removeBlock(editorState, block) {
  11307. var lastSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11308. var nextContentState = void 0,
  11309. nextEditorState = void 0;
  11310. var blockKey = block.getKey();
  11311. nextContentState = Draft.Draft.Modifier.removeRange(editorState.getCurrentContent(), new Draft.Draft.SelectionState({
  11312. anchorKey: blockKey,
  11313. anchorOffset: 0,
  11314. focusKey: blockKey,
  11315. focusOffset: block.getLength()
  11316. }), 'backward');
  11317. nextContentState = Draft.Draft.Modifier.setBlockType(nextContentState, nextContentState.getSelectionAfter(), 'unstyled');
  11318. nextEditorState = Draft.Draft.EditorState.push(editorState, nextContentState, 'remove-range');
  11319. return Draft.Draft.EditorState.forceSelection(nextEditorState, lastSelection || nextContentState.getSelectionAfter());
  11320. };
  11321. var getSelectionBlock = exports.getSelectionBlock = function getSelectionBlock(editorState) {
  11322. return editorState.getCurrentContent().getBlockForKey(editorState.getSelection().getAnchorKey());
  11323. };
  11324. var updateEachCharacterOfSelection = exports.updateEachCharacterOfSelection = function updateEachCharacterOfSelection(editorState, callback) {
  11325. var selectionState = editorState.getSelection();
  11326. var contentState = editorState.getCurrentContent();
  11327. var contentBlocks = contentState.getBlockMap();
  11328. var selectedBlocks = getSelectedBlocks(editorState);
  11329. if (selectedBlocks.length === 0) {
  11330. return editorState;
  11331. }
  11332. var startKey = selectionState.getStartKey();
  11333. var startOffset = selectionState.getStartOffset();
  11334. var endKey = selectionState.getEndKey();
  11335. var endOffset = selectionState.getEndOffset();
  11336. var nextContentBlocks = contentBlocks.map(function (block) {
  11337. if (selectedBlocks.indexOf(block) === -1) {
  11338. return block;
  11339. }
  11340. var blockKey = block.getKey();
  11341. var charactersList = block.getCharacterList();
  11342. var nextCharactersList = null;
  11343. if (blockKey === startKey && blockKey === endKey) {
  11344. nextCharactersList = charactersList.map(function (character, index) {
  11345. if (index >= startOffset && index < endOffset) {
  11346. return callback(character);
  11347. }
  11348. return character;
  11349. });
  11350. } else if (blockKey === startKey) {
  11351. nextCharactersList = charactersList.map(function (character, index) {
  11352. if (index >= startOffset) {
  11353. return callback(character);
  11354. }
  11355. return character;
  11356. });
  11357. } else if (blockKey === endKey) {
  11358. nextCharactersList = charactersList.map(function (character, index) {
  11359. if (index < endOffset) {
  11360. return callback(character);
  11361. }
  11362. return character;
  11363. });
  11364. } else {
  11365. nextCharactersList = charactersList.map(function (character) {
  11366. return callback(character);
  11367. });
  11368. }
  11369. return block.merge({
  11370. 'characterList': nextCharactersList
  11371. });
  11372. });
  11373. return Draft.Draft.EditorState.push(editorState, contentState.merge({
  11374. blockMap: nextContentBlocks,
  11375. selectionBefore: selectionState,
  11376. selectionAfter: selectionState
  11377. }), 'update-selection-character-list');
  11378. };
  11379. var getSelectedBlocks = exports.getSelectedBlocks = function getSelectedBlocks(editorState) {
  11380. var selectionState = editorState.getSelection();
  11381. var contentState = editorState.getCurrentContent();
  11382. var startKey = selectionState.getStartKey();
  11383. var endKey = selectionState.getEndKey();
  11384. var isSameBlock = startKey === endKey;
  11385. var startingBlock = contentState.getBlockForKey(startKey);
  11386. var selectedBlocks = [startingBlock];
  11387. if (!isSameBlock) {
  11388. var blockKey = startKey;
  11389. while (blockKey !== endKey) {
  11390. var nextBlock = contentState.getBlockAfter(blockKey);
  11391. selectedBlocks.push(nextBlock);
  11392. blockKey = nextBlock.getKey();
  11393. }
  11394. }
  11395. return selectedBlocks;
  11396. };
  11397. var setSelectionBlockData = exports.setSelectionBlockData = function setSelectionBlockData(editorState, blockData, override) {
  11398. var newBlockData = override ? blockData : Object.assign({}, getSelectionBlockData(editorState).toJS(), blockData);
  11399. Object.keys(newBlockData).forEach(function (key) {
  11400. if (newBlockData.hasOwnProperty(key) && newBlockData[key] === undefined) {
  11401. delete newBlockData[key];
  11402. }
  11403. });
  11404. return (0, draftjsUtils.setBlockData)(editorState, newBlockData);
  11405. };
  11406. var getSelectionBlockData = exports.getSelectionBlockData = function getSelectionBlockData(editorState, name) {
  11407. var blockData = getSelectionBlock(editorState).getData();
  11408. return name ? blockData.get(name) : blockData;
  11409. };
  11410. var getSelectionBlockType = exports.getSelectionBlockType = function getSelectionBlockType(editorState) {
  11411. return getSelectionBlock(editorState).getType();
  11412. };
  11413. var getSelectionText = exports.getSelectionText = function getSelectionText(editorState) {
  11414. var selectionState = editorState.getSelection();
  11415. var contentState = editorState.getCurrentContent();
  11416. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  11417. return '';
  11418. }
  11419. var anchorKey = selectionState.getAnchorKey();
  11420. var currentContentBlock = contentState.getBlockForKey(anchorKey);
  11421. var start = selectionState.getStartOffset();
  11422. var end = selectionState.getEndOffset();
  11423. return currentContentBlock.getText().slice(start, end);
  11424. };
  11425. var toggleSelectionBlockType = exports.toggleSelectionBlockType = function toggleSelectionBlockType(editorState, blockType) {
  11426. if (selectionContainsStrictBlock(editorState)) {
  11427. return editorState;
  11428. }
  11429. return Draft.Draft.RichUtils.toggleBlockType(editorState, blockType);
  11430. };
  11431. var getSelectionEntityType = exports.getSelectionEntityType = function getSelectionEntityType(editorState) {
  11432. var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
  11433. if (entityKey) {
  11434. var entity = editorState.getCurrentContent().getEntity(entityKey);
  11435. return entity ? entity.get('type') : null;
  11436. }
  11437. return null;
  11438. };
  11439. var getSelectionEntityData = exports.getSelectionEntityData = function getSelectionEntityData(editorState, type) {
  11440. var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
  11441. if (entityKey) {
  11442. var entity = editorState.getCurrentContent().getEntity(entityKey);
  11443. if (entity && entity.get('type') === type) {
  11444. return entity.getData();
  11445. } else {
  11446. return {};
  11447. }
  11448. } else {
  11449. return {};
  11450. }
  11451. };
  11452. var toggleSelectionEntity = exports.toggleSelectionEntity = function toggleSelectionEntity(editorState, entity) {
  11453. var contentState = editorState.getCurrentContent();
  11454. var selectionState = editorState.getSelection();
  11455. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  11456. return editorState;
  11457. }
  11458. if (!entity || !entity.type || getSelectionEntityType(editorState) === entity.type) {
  11459. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.applyEntity(contentState, selectionState, null), 'apply-entity');
  11460. }
  11461. try {
  11462. var nextContentState = contentState.createEntity(entity.type, entity.mutability, entity.data);
  11463. var entityKey = nextContentState.getLastCreatedEntityKey();
  11464. var nextEditorState = Draft.Draft.EditorState.set(editorState, {
  11465. currentContent: nextContentState
  11466. });
  11467. return Draft.Draft.EditorState.push(nextEditorState, Draft.Draft.Modifier.applyEntity(nextContentState, selectionState, entityKey), 'apply-entity');
  11468. } catch (error) {
  11469. console.warn(error);
  11470. return editorState;
  11471. }
  11472. };
  11473. var toggleSelectionLink = exports.toggleSelectionLink = function toggleSelectionLink(editorState, href, target) {
  11474. var contentState = editorState.getCurrentContent();
  11475. var selectionState = editorState.getSelection();
  11476. var entityData = { href: href, target: target };
  11477. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  11478. return editorState;
  11479. }
  11480. if (href === false) {
  11481. return Draft.Draft.RichUtils.toggleLink(editorState, selectionState, null);
  11482. }
  11483. if (href === null) {
  11484. delete entityData.href;
  11485. }
  11486. try {
  11487. var nextContentState = contentState.createEntity('LINK', 'MUTABLE', entityData);
  11488. var entityKey = nextContentState.getLastCreatedEntityKey();
  11489. var nextEditorState = Draft.Draft.EditorState.set(editorState, {
  11490. currentContent: nextContentState
  11491. });
  11492. nextEditorState = Draft.Draft.RichUtils.toggleLink(nextEditorState, selectionState, entityKey);
  11493. nextEditorState = Draft.Draft.EditorState.forceSelection(nextEditorState, selectionState.merge({
  11494. anchorOffset: selectionState.getEndOffset(),
  11495. focusOffset: selectionState.getEndOffset()
  11496. }));
  11497. nextEditorState = Draft.Draft.EditorState.push(nextEditorState, Draft.Draft.Modifier.insertText(nextEditorState.getCurrentContent(), nextEditorState.getSelection(), ''), 'insert-text');
  11498. return nextEditorState;
  11499. } catch (error) {
  11500. console.warn(error);
  11501. return editorState;
  11502. }
  11503. };
  11504. var getSelectionInlineStyle = exports.getSelectionInlineStyle = function getSelectionInlineStyle(editorState) {
  11505. return editorState.getCurrentInlineStyle();
  11506. };
  11507. var selectionHasInlineStyle = exports.selectionHasInlineStyle = function selectionHasInlineStyle(editorState, style) {
  11508. return getSelectionInlineStyle(editorState).has(style.toUpperCase());
  11509. };
  11510. var toggleSelectionInlineStyle = exports.toggleSelectionInlineStyle = function toggleSelectionInlineStyle(editorState, style) {
  11511. var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  11512. var nextEditorState = editorState;
  11513. style = prefix + style.toUpperCase();
  11514. if (prefix) {
  11515. nextEditorState = updateEachCharacterOfSelection(nextEditorState, function (characterMetadata) {
  11516. return characterMetadata.toJS().style.reduce(function (characterMetadata, characterStyle) {
  11517. if (characterStyle.indexOf(prefix) === 0 && style !== characterStyle) {
  11518. return Draft.Draft.CharacterMetadata.removeStyle(characterMetadata, characterStyle);
  11519. } else {
  11520. return characterMetadata;
  11521. }
  11522. }, characterMetadata);
  11523. });
  11524. }
  11525. return Draft.Draft.RichUtils.toggleInlineStyle(nextEditorState, style);
  11526. };
  11527. var removeSelectionInlineStyles = exports.removeSelectionInlineStyles = function removeSelectionInlineStyles(editorState) {
  11528. return updateEachCharacterOfSelection(editorState, function (characterMetadata) {
  11529. return characterMetadata.merge({
  11530. style: _immutable2.default.OrderedSet([])
  11531. });
  11532. });
  11533. };
  11534. var toggleSelectionAlignment = exports.toggleSelectionAlignment = function toggleSelectionAlignment(editorState, alignment) {
  11535. return setSelectionBlockData(editorState, {
  11536. textAlign: getSelectionBlockData(editorState, 'textAlign') !== alignment ? alignment : undefined
  11537. });
  11538. };
  11539. var toggleSelectionIndent = exports.toggleSelectionIndent = function toggleSelectionIndent(editorState, textIndent) {
  11540. var maxIndent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6;
  11541. return textIndent < 0 || textIndent > maxIndent || isNaN(textIndent) ? editorState : setSelectionBlockData(editorState, {
  11542. textIndent: textIndent || undefined
  11543. });
  11544. };
  11545. var increaseSelectionIndent = exports.increaseSelectionIndent = function increaseSelectionIndent(editorState) {
  11546. var maxIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
  11547. var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
  11548. return toggleSelectionIndent(editorState, currentIndent + 1, maxIndent);
  11549. };
  11550. var decreaseSelectionIndent = exports.decreaseSelectionIndent = function decreaseSelectionIndent(editorState) {
  11551. var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
  11552. return toggleSelectionIndent(editorState, currentIndent - 1);
  11553. };
  11554. var toggleSelectionColor = exports.toggleSelectionColor = function toggleSelectionColor(editorState, color) {
  11555. return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'COLOR-');
  11556. };
  11557. var toggleSelectionBackgroundColor = exports.toggleSelectionBackgroundColor = function toggleSelectionBackgroundColor(editorState, color) {
  11558. return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'BGCOLOR-');
  11559. };
  11560. var toggleSelectionFontSize = exports.toggleSelectionFontSize = function toggleSelectionFontSize(editorState, fontSize) {
  11561. return toggleSelectionInlineStyle(editorState, fontSize, 'FONTSIZE-');
  11562. };
  11563. var toggleSelectionLineHeight = exports.toggleSelectionLineHeight = function toggleSelectionLineHeight(editorState, lineHeight) {
  11564. return toggleSelectionInlineStyle(editorState, lineHeight, 'LINEHEIGHT-');
  11565. };
  11566. var toggleSelectionFontFamily = exports.toggleSelectionFontFamily = function toggleSelectionFontFamily(editorState, fontFamily) {
  11567. return toggleSelectionInlineStyle(editorState, fontFamily, 'FONTFAMILY-');
  11568. };
  11569. var toggleSelectionLetterSpacing = exports.toggleSelectionLetterSpacing = function toggleSelectionLetterSpacing(editorState, letterSpacing) {
  11570. return toggleSelectionInlineStyle(editorState, letterSpacing, 'LETTERSPACING-');
  11571. };
  11572. var insertText = exports.insertText = function insertText(editorState, text, inlineStyle, entity) {
  11573. var selectionState = editorState.getSelection();
  11574. var currentSelectedBlockType = getSelectionBlockType(editorState);
  11575. if (currentSelectedBlockType === 'atomic') {
  11576. return editorState;
  11577. }
  11578. var entityKey = void 0;
  11579. var contentState = editorState.getCurrentContent();
  11580. if (entity && entity.type) {
  11581. contentState = contentState.createEntity(entity.type, entity.mutability || 'MUTABLE', entity.data || entityData);
  11582. entityKey = contentState.getLastCreatedEntityKey();
  11583. }
  11584. if (!selectionState.isCollapsed()) {
  11585. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.replaceText(contentState, selectionState, text, inlineStyle, entityKey), 'replace-text');
  11586. } else {
  11587. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.insertText(contentState, selectionState, text, inlineStyle, entityKey), 'insert-text');
  11588. }
  11589. };
  11590. var insertHTML = exports.insertHTML = function insertHTML(editorState, htmlString, source) {
  11591. if (!htmlString) {
  11592. return editorState;
  11593. }
  11594. var selectionState = editorState.getSelection();
  11595. var contentState = editorState.getCurrentContent();
  11596. var options = editorState.convertOptions || {};
  11597. try {
  11598. var _convertFromRaw = (0, Draft.Draft.convertFromRaw)((0, dist.convertHTMLToRaw)(htmlString, options, source)),
  11599. blockMap = _convertFromRaw.blockMap;
  11600. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.replaceWithFragment(contentState, selectionState, blockMap), 'insert-fragment');
  11601. } catch (error) {
  11602. console.warn(error);
  11603. return editorState;
  11604. }
  11605. };
  11606. var insertAtomicBlock = exports.insertAtomicBlock = function insertAtomicBlock(editorState, type) {
  11607. var immutable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  11608. var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  11609. if (selectionContainsStrictBlock(editorState)) {
  11610. return insertAtomicBlock(selectNextBlock(editorState, getSelectionBlock(editorState)), type, immutable, data);
  11611. }
  11612. var selectionState = editorState.getSelection();
  11613. var contentState = editorState.getCurrentContent();
  11614. if (!selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  11615. return editorState;
  11616. }
  11617. var contentStateWithEntity = contentState.createEntity(type, immutable ? 'IMMUTABLE' : 'MUTABLE', data);
  11618. var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
  11619. var newEditorState = Draft.Draft.AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, ' ');
  11620. return newEditorState;
  11621. };
  11622. var insertHorizontalLine = exports.insertHorizontalLine = function insertHorizontalLine(editorState) {
  11623. return insertAtomicBlock(editorState, 'HR');
  11624. };
  11625. var insertMedias = exports.insertMedias = function insertMedias(editorState) {
  11626. var medias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  11627. if (!medias.length) {
  11628. return editorState;
  11629. }
  11630. return medias.reduce(function (editorState, media) {
  11631. var url = media.url,
  11632. link = media.link,
  11633. link_target = media.link_target,
  11634. name = media.name,
  11635. type = media.type,
  11636. width = media.width,
  11637. height = media.height,
  11638. meta = media.meta;
  11639. return insertAtomicBlock(editorState, type, true, { url: url, link: link, link_target: link_target, name: name, type: type, width: width, height: height, meta: meta });
  11640. }, editorState);
  11641. };
  11642. var setMediaData = exports.setMediaData = function setMediaData(editorState, entityKey, data) {
  11643. return Draft.Draft.EditorState.push(editorState, editorState.getCurrentContent().mergeEntityData(entityKey, data), 'change-block-data');
  11644. };
  11645. var removeMedia = exports.removeMedia = function removeMedia(editorState, mediaBlock) {
  11646. return removeBlock(editorState, mediaBlock);
  11647. };
  11648. var setMediaPosition = exports.setMediaPosition = function setMediaPosition(editorState, mediaBlock, position) {
  11649. var newPosition = {};
  11650. var float = position.float,
  11651. alignment = position.alignment;
  11652. if (typeof float !== 'undefined') {
  11653. newPosition.float = mediaBlock.getData().get('float') === float ? null : float;
  11654. }
  11655. if (typeof alignment !== 'undefined') {
  11656. newPosition.alignment = mediaBlock.getData().get('alignment') === alignment ? null : alignment;
  11657. }
  11658. return setSelectionBlockData(selectBlock(editorState, mediaBlock), newPosition);
  11659. };
  11660. var clear = exports.clear = function clear(editorState) {
  11661. var contentState = editorState.getCurrentContent();
  11662. var firstBlock = contentState.getFirstBlock();
  11663. var lastBlock = contentState.getLastBlock();
  11664. var allSelected = new Draft.Draft.SelectionState({
  11665. anchorKey: firstBlock.getKey(),
  11666. anchorOffset: 0,
  11667. focusKey: lastBlock.getKey(),
  11668. focusOffset: lastBlock.getLength(),
  11669. hasFocus: true
  11670. });
  11671. return Draft.Draft.RichUtils.toggleBlockType(Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.removeRange(contentState, allSelected, 'backward'), 'remove-range'), 'unstyled');
  11672. };
  11673. var handleKeyCommand = exports.handleKeyCommand = function handleKeyCommand(editorState, command) {
  11674. return Draft.Draft.RichUtils.handleKeyCommand(editorState, command);
  11675. };
  11676. var undo = exports.undo = function undo(editorState) {
  11677. return Draft.Draft.EditorState.undo(editorState);
  11678. };
  11679. var redo = exports.redo = function redo(editorState) {
  11680. return Draft.Draft.EditorState.redo(editorState);
  11681. };
  11682. });
  11683. _commonjsHelpers.unwrapExports(content);
  11684. var content_1 = content.redo;
  11685. var content_2 = content.undo;
  11686. var content_3 = content.handleKeyCommand;
  11687. var content_4 = content.clear;
  11688. var content_5 = content.setMediaPosition;
  11689. var content_6 = content.removeMedia;
  11690. var content_7 = content.setMediaData;
  11691. var content_8 = content.insertMedias;
  11692. var content_9 = content.insertHorizontalLine;
  11693. var content_10 = content.insertAtomicBlock;
  11694. var content_11 = content.insertHTML;
  11695. var content_12 = content.insertText;
  11696. var content_13 = content.toggleSelectionLetterSpacing;
  11697. var content_14 = content.toggleSelectionFontFamily;
  11698. var content_15 = content.toggleSelectionLineHeight;
  11699. var content_16 = content.toggleSelectionFontSize;
  11700. var content_17 = content.toggleSelectionBackgroundColor;
  11701. var content_18 = content.toggleSelectionColor;
  11702. var content_19 = content.decreaseSelectionIndent;
  11703. var content_20 = content.increaseSelectionIndent;
  11704. var content_21 = content.toggleSelectionIndent;
  11705. var content_22 = content.toggleSelectionAlignment;
  11706. var content_23 = content.removeSelectionInlineStyles;
  11707. var content_24 = content.toggleSelectionInlineStyle;
  11708. var content_25 = content.selectionHasInlineStyle;
  11709. var content_26 = content.getSelectionInlineStyle;
  11710. var content_27 = content.toggleSelectionLink;
  11711. var content_28 = content.toggleSelectionEntity;
  11712. var content_29 = content.getSelectionEntityData;
  11713. var content_30 = content.getSelectionEntityType;
  11714. var content_31 = content.toggleSelectionBlockType;
  11715. var content_32 = content.getSelectionText;
  11716. var content_33 = content.getSelectionBlockType;
  11717. var content_34 = content.getSelectionBlockData;
  11718. var content_35 = content.setSelectionBlockData;
  11719. var content_36 = content.getSelectedBlocks;
  11720. var content_37 = content.updateEachCharacterOfSelection;
  11721. var content_38 = content.getSelectionBlock;
  11722. var content_39 = content.removeBlock;
  11723. var content_40 = content.selectNextBlock;
  11724. var content_41 = content.selectBlock;
  11725. var content_42 = content.selectionContainsStrictBlock;
  11726. var content_43 = content.selectionContainsBlockType;
  11727. var content_44 = content.isSelectionCollapsed;
  11728. var content_45 = content.createEditorState;
  11729. var content_46 = content.createEmptyEditorState;
  11730. var content_47 = content.isEditorState;
  11731. var content_48 = content.registerStrictBlockType;
  11732. var base = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11733. Object.defineProperty(exports, "__esModule", {
  11734. value: true
  11735. });
  11736. var braftUniqueIndex = 0;
  11737. var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
  11738. return braftUniqueIndex += 1;
  11739. };
  11740. });
  11741. _commonjsHelpers.unwrapExports(base);
  11742. var base_1 = base.UniqueIndex;
  11743. var color = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11744. Object.defineProperty(exports, "__esModule", {
  11745. value: true
  11746. });
  11747. var _namedColors = {
  11748. "aliceblue": "#f0f8ff",
  11749. "antiquewhite": "#faebd7",
  11750. "aqua": "#00ffff",
  11751. "aquamarine": "#7fffd4",
  11752. "azure": "#f0ffff",
  11753. "beige": "#f5f5dc",
  11754. "bisque": "#ffe4c4",
  11755. "black": "#000000",
  11756. "blanchedalmond": "#ffebcd",
  11757. "blue": "#0000ff",
  11758. "blueviolet": "#8a2be2",
  11759. "brown": "#a52a2a",
  11760. "burlywood": "#deb887",
  11761. "cadetblue": "#5f9ea0",
  11762. "chartreuse": "#7fff00",
  11763. "chocolate": "#d2691e",
  11764. "coral": "#ff7f50",
  11765. "cornflowerblue": "#6495ed",
  11766. "cornsilk": "#fff8dc",
  11767. "crimson": "#dc143c",
  11768. "cyan": "#00ffff",
  11769. "darkblue": "#00008b",
  11770. "darkcyan": "#008b8b",
  11771. "darkgoldenrod": "#b8860b",
  11772. "darkgray": "#a9a9a9",
  11773. "darkgreen": "#006400",
  11774. "darkkhaki": "#bdb76b",
  11775. "darkmagenta": "#8b008b",
  11776. "darkolivegreen": "#556b2f",
  11777. "darkorange": "#ff8c00",
  11778. "darkorchid": "#9932cc",
  11779. "darkred": "#8b0000",
  11780. "darksalmon": "#e9967a",
  11781. "darkseagreen": "#8fbc8f",
  11782. "darkslateblue": "#483d8b",
  11783. "darkslategray": "#2f4f4f",
  11784. "darkturquoise": "#00ced1",
  11785. "darkviolet": "#9400d3",
  11786. "deeppink": "#ff1493",
  11787. "deepskyblue": "#00bfff",
  11788. "dimgray": "#696969",
  11789. "dodgerblue": "#1e90ff",
  11790. "firebrick": "#b22222",
  11791. "floralwhite": "#fffaf0",
  11792. "forestgreen": "#228b22",
  11793. "fuchsia": "#ff00ff",
  11794. "gainsboro": "#dcdcdc",
  11795. "ghostwhite": "#f8f8ff",
  11796. "gold": "#ffd700",
  11797. "goldenrod": "#daa520",
  11798. "gray": "#808080",
  11799. "green": "#008000",
  11800. "greenyellow": "#adff2f",
  11801. "honeydew": "#f0fff0",
  11802. "hotpink": "#ff69b4",
  11803. "indianred ": "#cd5c5c",
  11804. "indigo": "#4b0082",
  11805. "ivory": "#fffff0",
  11806. "khaki": "#f0e68c",
  11807. "lavender": "#e6e6fa",
  11808. "lavenderblush": "#fff0f5",
  11809. "lawngreen": "#7cfc00",
  11810. "lemonchiffon": "#fffacd",
  11811. "lightblue": "#add8e6",
  11812. "lightcoral": "#f08080",
  11813. "lightcyan": "#e0ffff",
  11814. "lightgoldenrodyellow": "#fafad2",
  11815. "lightgrey": "#d3d3d3",
  11816. "lightgreen": "#90ee90",
  11817. "lightpink": "#ffb6c1",
  11818. "lightsalmon": "#ffa07a",
  11819. "lightseagreen": "#20b2aa",
  11820. "lightskyblue": "#87cefa",
  11821. "lightslategray": "#778899",
  11822. "lightsteelblue": "#b0c4de",
  11823. "lightyellow": "#ffffe0",
  11824. "lime": "#00ff00",
  11825. "limegreen": "#32cd32",
  11826. "linen": "#faf0e6",
  11827. "magenta": "#ff00ff",
  11828. "maroon": "#800000",
  11829. "mediumaquamarine": "#66cdaa",
  11830. "mediumblue": "#0000cd",
  11831. "mediumorchid": "#ba55d3",
  11832. "mediumpurple": "#9370d8",
  11833. "mediumseagreen": "#3cb371",
  11834. "mediumslateblue": "#7b68ee",
  11835. "mediumspringgreen": "#00fa9a",
  11836. "mediumturquoise": "#48d1cc",
  11837. "mediumvioletred": "#c71585",
  11838. "midnightblue": "#191970",
  11839. "mintcream": "#f5fffa",
  11840. "mistyrose": "#ffe4e1",
  11841. "moccasin": "#ffe4b5",
  11842. "navajowhite": "#ffdead",
  11843. "navy": "#000080",
  11844. "oldlace": "#fdf5e6",
  11845. "olive": "#808000",
  11846. "olivedrab": "#6b8e23",
  11847. "orange": "#ffa500",
  11848. "orangered": "#ff4500",
  11849. "orchid": "#da70d6",
  11850. "palegoldenrod": "#eee8aa",
  11851. "palegreen": "#98fb98",
  11852. "paleturquoise": "#afeeee",
  11853. "palevioletred": "#d87093",
  11854. "papayawhip": "#ffefd5",
  11855. "peachpuff": "#ffdab9",
  11856. "peru": "#cd853f",
  11857. "pink": "#ffc0cb",
  11858. "plum": "#dda0dd",
  11859. "powderblue": "#b0e0e6",
  11860. "purple": "#800080",
  11861. "rebeccapurple": "#663399",
  11862. "red": "#ff0000",
  11863. "rosybrown": "#bc8f8f",
  11864. "royalblue": "#4169e1",
  11865. "saddlebrown": "#8b4513",
  11866. "salmon": "#fa8072",
  11867. "sandybrown": "#f4a460",
  11868. "seagreen": "#2e8b57",
  11869. "seashell": "#fff5ee",
  11870. "sienna": "#a0522d",
  11871. "silver": "#c0c0c0",
  11872. "skyblue": "#87ceeb",
  11873. "slateblue": "#6a5acd",
  11874. "slategray": "#708090",
  11875. "snow": "#fffafa",
  11876. "springgreen": "#00ff7f",
  11877. "steelblue": "#4682b4",
  11878. "tan": "#d2b48c",
  11879. "teal": "#008080",
  11880. "thistle": "#d8bfd8",
  11881. "tomato": "#ff6347",
  11882. "turquoise": "#40e0d0",
  11883. "violet": "#ee82ee",
  11884. "wheat": "#f5deb3",
  11885. "white": "#ffffff",
  11886. "whitesmoke": "#f5f5f5",
  11887. "yellow": "#ffff00",
  11888. "yellowgreen": "#9acd32"
  11889. };
  11890. var _getHexColor = function _getHexColor(color) {
  11891. color = color.replace('color:', '').replace(';', '').replace(' ', '');
  11892. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  11893. return color;
  11894. } else if (namedColors[color]) {
  11895. return namedColors[color];
  11896. } else if (color.indexOf('rgb') === 0) {
  11897. var rgbArray = color.split(',');
  11898. var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
  11899. var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
  11900. return hex.length === 1 ? '0' + hex : hex;
  11901. }).join('');
  11902. return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
  11903. );
  11904. } else {
  11905. return null;
  11906. }
  11907. };
  11908. var namedColors = exports.namedColors = _namedColors;
  11909. var getHexColor = exports.getHexColor = _getHexColor;
  11910. var detectColorsFromHTMLString = exports.detectColorsFromHTMLString = function detectColorsFromHTMLString(html) {
  11911. return typeof html !== 'string' ? [] : (html.match(/color:[^;]{3,24};/g) || []).map(getHexColor).filter(function (color) {
  11912. return color;
  11913. });
  11914. };
  11915. var detectColorsFromDraftState = exports.detectColorsFromDraftState = function detectColorsFromDraftState(draftState) {
  11916. var result = [];
  11917. if (!draftState || !draftState.blocks || !draftState.blocks.length) {
  11918. return result;
  11919. }
  11920. draftState.blocks.forEach(function (block) {
  11921. if (block && block.inlineStyleRanges && block.inlineStyleRanges.length) {
  11922. block.inlineStyleRanges.forEach(function (inlineStyle) {
  11923. if (inlineStyle.style && inlineStyle.style.indexOf('COLOR-') >= 0) {
  11924. result.push('#' + inlineStyle.style.split('COLOR-')[1]);
  11925. }
  11926. });
  11927. }
  11928. });
  11929. return result.filter(function (color) {
  11930. return color;
  11931. });
  11932. };
  11933. });
  11934. _commonjsHelpers.unwrapExports(color);
  11935. var color_1 = color.namedColors;
  11936. var color_2 = color.getHexColor;
  11937. var color_3 = color.detectColorsFromHTMLString;
  11938. var color_4 = color.detectColorsFromDraftState;
  11939. var dist$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11940. Object.defineProperty(exports, "__esModule", {
  11941. value: true
  11942. });
  11943. exports.ColorUtils = exports.BaseUtils = exports.ContentUtils = undefined;
  11944. var _ContentUtils = _interopRequireWildcard(content);
  11945. var _BaseUtils = _interopRequireWildcard(base);
  11946. var _ColorUtils = _interopRequireWildcard(color);
  11947. 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; } }
  11948. var ContentUtils = exports.ContentUtils = _ContentUtils;
  11949. var BaseUtils = exports.BaseUtils = _BaseUtils;
  11950. var ColorUtils = exports.ColorUtils = _ColorUtils;
  11951. });
  11952. _commonjsHelpers.unwrapExports(dist$1);
  11953. var dist_1$1 = dist$1.ColorUtils;
  11954. var dist_2$1 = dist$1.BaseUtils;
  11955. var dist_3$1 = dist$1.ContentUtils;
  11956. var immutable$2 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11957. /**
  11958. * Copyright (c) 2014-2015, Facebook, Inc.
  11959. * All rights reserved.
  11960. *
  11961. * This source code is licensed under the BSD-style license found in the
  11962. * LICENSE file in the root directory of this source tree. An additional grant
  11963. * of patent rights can be found in the PATENTS file in the same directory.
  11964. */
  11965. (function (global, factory) {
  11966. module.exports = factory() ;
  11967. }(_commonjsHelpers.commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
  11968. function createClass(ctor, superClass) {
  11969. if (superClass) {
  11970. ctor.prototype = Object.create(superClass.prototype);
  11971. }
  11972. ctor.prototype.constructor = ctor;
  11973. }
  11974. function Iterable(value) {
  11975. return isIterable(value) ? value : Seq(value);
  11976. }
  11977. createClass(KeyedIterable, Iterable);
  11978. function KeyedIterable(value) {
  11979. return isKeyed(value) ? value : KeyedSeq(value);
  11980. }
  11981. createClass(IndexedIterable, Iterable);
  11982. function IndexedIterable(value) {
  11983. return isIndexed(value) ? value : IndexedSeq(value);
  11984. }
  11985. createClass(SetIterable, Iterable);
  11986. function SetIterable(value) {
  11987. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  11988. }
  11989. function isIterable(maybeIterable) {
  11990. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  11991. }
  11992. function isKeyed(maybeKeyed) {
  11993. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  11994. }
  11995. function isIndexed(maybeIndexed) {
  11996. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  11997. }
  11998. function isAssociative(maybeAssociative) {
  11999. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  12000. }
  12001. function isOrdered(maybeOrdered) {
  12002. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  12003. }
  12004. Iterable.isIterable = isIterable;
  12005. Iterable.isKeyed = isKeyed;
  12006. Iterable.isIndexed = isIndexed;
  12007. Iterable.isAssociative = isAssociative;
  12008. Iterable.isOrdered = isOrdered;
  12009. Iterable.Keyed = KeyedIterable;
  12010. Iterable.Indexed = IndexedIterable;
  12011. Iterable.Set = SetIterable;
  12012. var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  12013. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  12014. var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  12015. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  12016. // Used for setting prototype methods that IE8 chokes on.
  12017. var DELETE = 'delete';
  12018. // Constants describing the size of trie nodes.
  12019. var SHIFT = 5; // Resulted in best performance after ______?
  12020. var SIZE = 1 << SHIFT;
  12021. var MASK = SIZE - 1;
  12022. // A consistent shared value representing "not set" which equals nothing other
  12023. // than itself, and nothing that could be provided externally.
  12024. var NOT_SET = {};
  12025. // Boolean references, Rough equivalent of `bool &`.
  12026. var CHANGE_LENGTH = { value: false };
  12027. var DID_ALTER = { value: false };
  12028. function MakeRef(ref) {
  12029. ref.value = false;
  12030. return ref;
  12031. }
  12032. function SetRef(ref) {
  12033. ref && (ref.value = true);
  12034. }
  12035. // A function which returns a value representing an "owner" for transient writes
  12036. // to tries. The return value will only ever equal itself, and will not equal
  12037. // the return of any subsequent call of this function.
  12038. function OwnerID() {}
  12039. // http://jsperf.com/copy-array-inline
  12040. function arrCopy(arr, offset) {
  12041. offset = offset || 0;
  12042. var len = Math.max(0, arr.length - offset);
  12043. var newArr = new Array(len);
  12044. for (var ii = 0; ii < len; ii++) {
  12045. newArr[ii] = arr[ii + offset];
  12046. }
  12047. return newArr;
  12048. }
  12049. function ensureSize(iter) {
  12050. if (iter.size === undefined) {
  12051. iter.size = iter.__iterate(returnTrue);
  12052. }
  12053. return iter.size;
  12054. }
  12055. function wrapIndex(iter, index) {
  12056. // This implements "is array index" which the ECMAString spec defines as:
  12057. //
  12058. // A String property name P is an array index if and only if
  12059. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  12060. // to 2^32−1.
  12061. //
  12062. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  12063. if (typeof index !== 'number') {
  12064. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  12065. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  12066. return NaN;
  12067. }
  12068. index = uint32Index;
  12069. }
  12070. return index < 0 ? ensureSize(iter) + index : index;
  12071. }
  12072. function returnTrue() {
  12073. return true;
  12074. }
  12075. function wholeSlice(begin, end, size) {
  12076. return (begin === 0 || (size !== undefined && begin <= -size)) &&
  12077. (end === undefined || (size !== undefined && end >= size));
  12078. }
  12079. function resolveBegin(begin, size) {
  12080. return resolveIndex(begin, size, 0);
  12081. }
  12082. function resolveEnd(end, size) {
  12083. return resolveIndex(end, size, size);
  12084. }
  12085. function resolveIndex(index, size, defaultIndex) {
  12086. return index === undefined ?
  12087. defaultIndex :
  12088. index < 0 ?
  12089. Math.max(0, size + index) :
  12090. size === undefined ?
  12091. index :
  12092. Math.min(size, index);
  12093. }
  12094. /* global Symbol */
  12095. var ITERATE_KEYS = 0;
  12096. var ITERATE_VALUES = 1;
  12097. var ITERATE_ENTRIES = 2;
  12098. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  12099. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  12100. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  12101. function Iterator(next) {
  12102. this.next = next;
  12103. }
  12104. Iterator.prototype.toString = function() {
  12105. return '[Iterator]';
  12106. };
  12107. Iterator.KEYS = ITERATE_KEYS;
  12108. Iterator.VALUES = ITERATE_VALUES;
  12109. Iterator.ENTRIES = ITERATE_ENTRIES;
  12110. Iterator.prototype.inspect =
  12111. Iterator.prototype.toSource = function () { return this.toString(); };
  12112. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  12113. return this;
  12114. };
  12115. function iteratorValue(type, k, v, iteratorResult) {
  12116. var value = type === 0 ? k : type === 1 ? v : [k, v];
  12117. iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
  12118. value: value, done: false
  12119. });
  12120. return iteratorResult;
  12121. }
  12122. function iteratorDone() {
  12123. return { value: undefined, done: true };
  12124. }
  12125. function hasIterator(maybeIterable) {
  12126. return !!getIteratorFn(maybeIterable);
  12127. }
  12128. function isIterator(maybeIterator) {
  12129. return maybeIterator && typeof maybeIterator.next === 'function';
  12130. }
  12131. function getIterator(iterable) {
  12132. var iteratorFn = getIteratorFn(iterable);
  12133. return iteratorFn && iteratorFn.call(iterable);
  12134. }
  12135. function getIteratorFn(iterable) {
  12136. var iteratorFn = iterable && (
  12137. (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  12138. iterable[FAUX_ITERATOR_SYMBOL]
  12139. );
  12140. if (typeof iteratorFn === 'function') {
  12141. return iteratorFn;
  12142. }
  12143. }
  12144. function isArrayLike(value) {
  12145. return value && typeof value.length === 'number';
  12146. }
  12147. createClass(Seq, Iterable);
  12148. function Seq(value) {
  12149. return value === null || value === undefined ? emptySequence() :
  12150. isIterable(value) ? value.toSeq() : seqFromValue(value);
  12151. }
  12152. Seq.of = function(/*...values*/) {
  12153. return Seq(arguments);
  12154. };
  12155. Seq.prototype.toSeq = function() {
  12156. return this;
  12157. };
  12158. Seq.prototype.toString = function() {
  12159. return this.__toString('Seq {', '}');
  12160. };
  12161. Seq.prototype.cacheResult = function() {
  12162. if (!this._cache && this.__iterateUncached) {
  12163. this._cache = this.entrySeq().toArray();
  12164. this.size = this._cache.length;
  12165. }
  12166. return this;
  12167. };
  12168. // abstract __iterateUncached(fn, reverse)
  12169. Seq.prototype.__iterate = function(fn, reverse) {
  12170. return seqIterate(this, fn, reverse, true);
  12171. };
  12172. // abstract __iteratorUncached(type, reverse)
  12173. Seq.prototype.__iterator = function(type, reverse) {
  12174. return seqIterator(this, type, reverse, true);
  12175. };
  12176. createClass(KeyedSeq, Seq);
  12177. function KeyedSeq(value) {
  12178. return value === null || value === undefined ?
  12179. emptySequence().toKeyedSeq() :
  12180. isIterable(value) ?
  12181. (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
  12182. keyedSeqFromValue(value);
  12183. }
  12184. KeyedSeq.prototype.toKeyedSeq = function() {
  12185. return this;
  12186. };
  12187. createClass(IndexedSeq, Seq);
  12188. function IndexedSeq(value) {
  12189. return value === null || value === undefined ? emptySequence() :
  12190. !isIterable(value) ? indexedSeqFromValue(value) :
  12191. isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
  12192. }
  12193. IndexedSeq.of = function(/*...values*/) {
  12194. return IndexedSeq(arguments);
  12195. };
  12196. IndexedSeq.prototype.toIndexedSeq = function() {
  12197. return this;
  12198. };
  12199. IndexedSeq.prototype.toString = function() {
  12200. return this.__toString('Seq [', ']');
  12201. };
  12202. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  12203. return seqIterate(this, fn, reverse, false);
  12204. };
  12205. IndexedSeq.prototype.__iterator = function(type, reverse) {
  12206. return seqIterator(this, type, reverse, false);
  12207. };
  12208. createClass(SetSeq, Seq);
  12209. function SetSeq(value) {
  12210. return (
  12211. value === null || value === undefined ? emptySequence() :
  12212. !isIterable(value) ? indexedSeqFromValue(value) :
  12213. isKeyed(value) ? value.entrySeq() : value
  12214. ).toSetSeq();
  12215. }
  12216. SetSeq.of = function(/*...values*/) {
  12217. return SetSeq(arguments);
  12218. };
  12219. SetSeq.prototype.toSetSeq = function() {
  12220. return this;
  12221. };
  12222. Seq.isSeq = isSeq;
  12223. Seq.Keyed = KeyedSeq;
  12224. Seq.Set = SetSeq;
  12225. Seq.Indexed = IndexedSeq;
  12226. var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  12227. Seq.prototype[IS_SEQ_SENTINEL] = true;
  12228. createClass(ArraySeq, IndexedSeq);
  12229. function ArraySeq(array) {
  12230. this._array = array;
  12231. this.size = array.length;
  12232. }
  12233. ArraySeq.prototype.get = function(index, notSetValue) {
  12234. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  12235. };
  12236. ArraySeq.prototype.__iterate = function(fn, reverse) {
  12237. var array = this._array;
  12238. var maxIndex = array.length - 1;
  12239. for (var ii = 0; ii <= maxIndex; ii++) {
  12240. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  12241. return ii + 1;
  12242. }
  12243. }
  12244. return ii;
  12245. };
  12246. ArraySeq.prototype.__iterator = function(type, reverse) {
  12247. var array = this._array;
  12248. var maxIndex = array.length - 1;
  12249. var ii = 0;
  12250. return new Iterator(function()
  12251. {return ii > maxIndex ?
  12252. iteratorDone() :
  12253. iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
  12254. );
  12255. };
  12256. createClass(ObjectSeq, KeyedSeq);
  12257. function ObjectSeq(object) {
  12258. var keys = Object.keys(object);
  12259. this._object = object;
  12260. this._keys = keys;
  12261. this.size = keys.length;
  12262. }
  12263. ObjectSeq.prototype.get = function(key, notSetValue) {
  12264. if (notSetValue !== undefined && !this.has(key)) {
  12265. return notSetValue;
  12266. }
  12267. return this._object[key];
  12268. };
  12269. ObjectSeq.prototype.has = function(key) {
  12270. return this._object.hasOwnProperty(key);
  12271. };
  12272. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  12273. var object = this._object;
  12274. var keys = this._keys;
  12275. var maxIndex = keys.length - 1;
  12276. for (var ii = 0; ii <= maxIndex; ii++) {
  12277. var key = keys[reverse ? maxIndex - ii : ii];
  12278. if (fn(object[key], key, this) === false) {
  12279. return ii + 1;
  12280. }
  12281. }
  12282. return ii;
  12283. };
  12284. ObjectSeq.prototype.__iterator = function(type, reverse) {
  12285. var object = this._object;
  12286. var keys = this._keys;
  12287. var maxIndex = keys.length - 1;
  12288. var ii = 0;
  12289. return new Iterator(function() {
  12290. var key = keys[reverse ? maxIndex - ii : ii];
  12291. return ii++ > maxIndex ?
  12292. iteratorDone() :
  12293. iteratorValue(type, key, object[key]);
  12294. });
  12295. };
  12296. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  12297. createClass(IterableSeq, IndexedSeq);
  12298. function IterableSeq(iterable) {
  12299. this._iterable = iterable;
  12300. this.size = iterable.length || iterable.size;
  12301. }
  12302. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  12303. if (reverse) {
  12304. return this.cacheResult().__iterate(fn, reverse);
  12305. }
  12306. var iterable = this._iterable;
  12307. var iterator = getIterator(iterable);
  12308. var iterations = 0;
  12309. if (isIterator(iterator)) {
  12310. var step;
  12311. while (!(step = iterator.next()).done) {
  12312. if (fn(step.value, iterations++, this) === false) {
  12313. break;
  12314. }
  12315. }
  12316. }
  12317. return iterations;
  12318. };
  12319. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  12320. if (reverse) {
  12321. return this.cacheResult().__iterator(type, reverse);
  12322. }
  12323. var iterable = this._iterable;
  12324. var iterator = getIterator(iterable);
  12325. if (!isIterator(iterator)) {
  12326. return new Iterator(iteratorDone);
  12327. }
  12328. var iterations = 0;
  12329. return new Iterator(function() {
  12330. var step = iterator.next();
  12331. return step.done ? step : iteratorValue(type, iterations++, step.value);
  12332. });
  12333. };
  12334. createClass(IteratorSeq, IndexedSeq);
  12335. function IteratorSeq(iterator) {
  12336. this._iterator = iterator;
  12337. this._iteratorCache = [];
  12338. }
  12339. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  12340. if (reverse) {
  12341. return this.cacheResult().__iterate(fn, reverse);
  12342. }
  12343. var iterator = this._iterator;
  12344. var cache = this._iteratorCache;
  12345. var iterations = 0;
  12346. while (iterations < cache.length) {
  12347. if (fn(cache[iterations], iterations++, this) === false) {
  12348. return iterations;
  12349. }
  12350. }
  12351. var step;
  12352. while (!(step = iterator.next()).done) {
  12353. var val = step.value;
  12354. cache[iterations] = val;
  12355. if (fn(val, iterations++, this) === false) {
  12356. break;
  12357. }
  12358. }
  12359. return iterations;
  12360. };
  12361. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  12362. if (reverse) {
  12363. return this.cacheResult().__iterator(type, reverse);
  12364. }
  12365. var iterator = this._iterator;
  12366. var cache = this._iteratorCache;
  12367. var iterations = 0;
  12368. return new Iterator(function() {
  12369. if (iterations >= cache.length) {
  12370. var step = iterator.next();
  12371. if (step.done) {
  12372. return step;
  12373. }
  12374. cache[iterations] = step.value;
  12375. }
  12376. return iteratorValue(type, iterations, cache[iterations++]);
  12377. });
  12378. };
  12379. // # pragma Helper functions
  12380. function isSeq(maybeSeq) {
  12381. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  12382. }
  12383. var EMPTY_SEQ;
  12384. function emptySequence() {
  12385. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  12386. }
  12387. function keyedSeqFromValue(value) {
  12388. var seq =
  12389. Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
  12390. isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
  12391. hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
  12392. typeof value === 'object' ? new ObjectSeq(value) :
  12393. undefined;
  12394. if (!seq) {
  12395. throw new TypeError(
  12396. 'Expected Array or iterable object of [k, v] entries, '+
  12397. 'or keyed object: ' + value
  12398. );
  12399. }
  12400. return seq;
  12401. }
  12402. function indexedSeqFromValue(value) {
  12403. var seq = maybeIndexedSeqFromValue(value);
  12404. if (!seq) {
  12405. throw new TypeError(
  12406. 'Expected Array or iterable object of values: ' + value
  12407. );
  12408. }
  12409. return seq;
  12410. }
  12411. function seqFromValue(value) {
  12412. var seq = maybeIndexedSeqFromValue(value) ||
  12413. (typeof value === 'object' && new ObjectSeq(value));
  12414. if (!seq) {
  12415. throw new TypeError(
  12416. 'Expected Array or iterable object of values, or keyed object: ' + value
  12417. );
  12418. }
  12419. return seq;
  12420. }
  12421. function maybeIndexedSeqFromValue(value) {
  12422. return (
  12423. isArrayLike(value) ? new ArraySeq(value) :
  12424. isIterator(value) ? new IteratorSeq(value) :
  12425. hasIterator(value) ? new IterableSeq(value) :
  12426. undefined
  12427. );
  12428. }
  12429. function seqIterate(seq, fn, reverse, useKeys) {
  12430. var cache = seq._cache;
  12431. if (cache) {
  12432. var maxIndex = cache.length - 1;
  12433. for (var ii = 0; ii <= maxIndex; ii++) {
  12434. var entry = cache[reverse ? maxIndex - ii : ii];
  12435. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  12436. return ii + 1;
  12437. }
  12438. }
  12439. return ii;
  12440. }
  12441. return seq.__iterateUncached(fn, reverse);
  12442. }
  12443. function seqIterator(seq, type, reverse, useKeys) {
  12444. var cache = seq._cache;
  12445. if (cache) {
  12446. var maxIndex = cache.length - 1;
  12447. var ii = 0;
  12448. return new Iterator(function() {
  12449. var entry = cache[reverse ? maxIndex - ii : ii];
  12450. return ii++ > maxIndex ?
  12451. iteratorDone() :
  12452. iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  12453. });
  12454. }
  12455. return seq.__iteratorUncached(type, reverse);
  12456. }
  12457. function fromJS(json, converter) {
  12458. return converter ?
  12459. fromJSWith(converter, json, '', {'': json}) :
  12460. fromJSDefault(json);
  12461. }
  12462. function fromJSWith(converter, json, key, parentJSON) {
  12463. if (Array.isArray(json)) {
  12464. return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  12465. }
  12466. if (isPlainObj(json)) {
  12467. return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  12468. }
  12469. return json;
  12470. }
  12471. function fromJSDefault(json) {
  12472. if (Array.isArray(json)) {
  12473. return IndexedSeq(json).map(fromJSDefault).toList();
  12474. }
  12475. if (isPlainObj(json)) {
  12476. return KeyedSeq(json).map(fromJSDefault).toMap();
  12477. }
  12478. return json;
  12479. }
  12480. function isPlainObj(value) {
  12481. return value && (value.constructor === Object || value.constructor === undefined);
  12482. }
  12483. /**
  12484. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  12485. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  12486. *
  12487. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  12488. * value, which is different from the algorithm described by
  12489. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  12490. *
  12491. * This is extended further to allow Objects to describe the values they
  12492. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  12493. *
  12494. * Note: because of this extension, the key equality of Immutable.Map and the
  12495. * value equality of Immutable.Set will differ from ES6 Map and Set.
  12496. *
  12497. * ### Defining custom values
  12498. *
  12499. * The easiest way to describe the value an object represents is by implementing
  12500. * `valueOf`. For example, `Date` represents a value by returning a unix
  12501. * timestamp for `valueOf`:
  12502. *
  12503. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  12504. * var date2 = new Date(1234567890000);
  12505. * date1.valueOf(); // 1234567890000
  12506. * assert( date1 !== date2 );
  12507. * assert( Immutable.is( date1, date2 ) );
  12508. *
  12509. * Note: overriding `valueOf` may have other implications if you use this object
  12510. * where JavaScript expects a primitive, such as implicit string coercion.
  12511. *
  12512. * For more complex types, especially collections, implementing `valueOf` may
  12513. * not be performant. An alternative is to implement `equals` and `hashCode`.
  12514. *
  12515. * `equals` takes another object, presumably of similar type, and returns true
  12516. * if the it is equal. Equality is symmetrical, so the same result should be
  12517. * returned if this and the argument are flipped.
  12518. *
  12519. * assert( a.equals(b) === b.equals(a) );
  12520. *
  12521. * `hashCode` returns a 32bit integer number representing the object which will
  12522. * be used to determine how to store the value object in a Map or Set. You must
  12523. * provide both or neither methods, one must not exist without the other.
  12524. *
  12525. * Also, an important relationship between these methods must be upheld: if two
  12526. * values are equal, they *must* return the same hashCode. If the values are not
  12527. * equal, they might have the same hashCode; this is called a hash collision,
  12528. * and while undesirable for performance reasons, it is acceptable.
  12529. *
  12530. * if (a.equals(b)) {
  12531. * assert( a.hashCode() === b.hashCode() );
  12532. * }
  12533. *
  12534. * All Immutable collections implement `equals` and `hashCode`.
  12535. *
  12536. */
  12537. function is(valueA, valueB) {
  12538. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  12539. return true;
  12540. }
  12541. if (!valueA || !valueB) {
  12542. return false;
  12543. }
  12544. if (typeof valueA.valueOf === 'function' &&
  12545. typeof valueB.valueOf === 'function') {
  12546. valueA = valueA.valueOf();
  12547. valueB = valueB.valueOf();
  12548. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  12549. return true;
  12550. }
  12551. if (!valueA || !valueB) {
  12552. return false;
  12553. }
  12554. }
  12555. if (typeof valueA.equals === 'function' &&
  12556. typeof valueB.equals === 'function' &&
  12557. valueA.equals(valueB)) {
  12558. return true;
  12559. }
  12560. return false;
  12561. }
  12562. function deepEqual(a, b) {
  12563. if (a === b) {
  12564. return true;
  12565. }
  12566. if (
  12567. !isIterable(b) ||
  12568. a.size !== undefined && b.size !== undefined && a.size !== b.size ||
  12569. a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
  12570. isKeyed(a) !== isKeyed(b) ||
  12571. isIndexed(a) !== isIndexed(b) ||
  12572. isOrdered(a) !== isOrdered(b)
  12573. ) {
  12574. return false;
  12575. }
  12576. if (a.size === 0 && b.size === 0) {
  12577. return true;
  12578. }
  12579. var notAssociative = !isAssociative(a);
  12580. if (isOrdered(a)) {
  12581. var entries = a.entries();
  12582. return b.every(function(v, k) {
  12583. var entry = entries.next().value;
  12584. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  12585. }) && entries.next().done;
  12586. }
  12587. var flipped = false;
  12588. if (a.size === undefined) {
  12589. if (b.size === undefined) {
  12590. if (typeof a.cacheResult === 'function') {
  12591. a.cacheResult();
  12592. }
  12593. } else {
  12594. flipped = true;
  12595. var _ = a;
  12596. a = b;
  12597. b = _;
  12598. }
  12599. }
  12600. var allEqual = true;
  12601. var bSize = b.__iterate(function(v, k) {
  12602. if (notAssociative ? !a.has(v) :
  12603. flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
  12604. allEqual = false;
  12605. return false;
  12606. }
  12607. });
  12608. return allEqual && a.size === bSize;
  12609. }
  12610. createClass(Repeat, IndexedSeq);
  12611. function Repeat(value, times) {
  12612. if (!(this instanceof Repeat)) {
  12613. return new Repeat(value, times);
  12614. }
  12615. this._value = value;
  12616. this.size = times === undefined ? Infinity : Math.max(0, times);
  12617. if (this.size === 0) {
  12618. if (EMPTY_REPEAT) {
  12619. return EMPTY_REPEAT;
  12620. }
  12621. EMPTY_REPEAT = this;
  12622. }
  12623. }
  12624. Repeat.prototype.toString = function() {
  12625. if (this.size === 0) {
  12626. return 'Repeat []';
  12627. }
  12628. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  12629. };
  12630. Repeat.prototype.get = function(index, notSetValue) {
  12631. return this.has(index) ? this._value : notSetValue;
  12632. };
  12633. Repeat.prototype.includes = function(searchValue) {
  12634. return is(this._value, searchValue);
  12635. };
  12636. Repeat.prototype.slice = function(begin, end) {
  12637. var size = this.size;
  12638. return wholeSlice(begin, end, size) ? this :
  12639. new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
  12640. };
  12641. Repeat.prototype.reverse = function() {
  12642. return this;
  12643. };
  12644. Repeat.prototype.indexOf = function(searchValue) {
  12645. if (is(this._value, searchValue)) {
  12646. return 0;
  12647. }
  12648. return -1;
  12649. };
  12650. Repeat.prototype.lastIndexOf = function(searchValue) {
  12651. if (is(this._value, searchValue)) {
  12652. return this.size;
  12653. }
  12654. return -1;
  12655. };
  12656. Repeat.prototype.__iterate = function(fn, reverse) {
  12657. for (var ii = 0; ii < this.size; ii++) {
  12658. if (fn(this._value, ii, this) === false) {
  12659. return ii + 1;
  12660. }
  12661. }
  12662. return ii;
  12663. };
  12664. Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
  12665. var ii = 0;
  12666. return new Iterator(function()
  12667. {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
  12668. );
  12669. };
  12670. Repeat.prototype.equals = function(other) {
  12671. return other instanceof Repeat ?
  12672. is(this._value, other._value) :
  12673. deepEqual(other);
  12674. };
  12675. var EMPTY_REPEAT;
  12676. function invariant(condition, error) {
  12677. if (!condition) throw new Error(error);
  12678. }
  12679. createClass(Range, IndexedSeq);
  12680. function Range(start, end, step) {
  12681. if (!(this instanceof Range)) {
  12682. return new Range(start, end, step);
  12683. }
  12684. invariant(step !== 0, 'Cannot step a Range by 0');
  12685. start = start || 0;
  12686. if (end === undefined) {
  12687. end = Infinity;
  12688. }
  12689. step = step === undefined ? 1 : Math.abs(step);
  12690. if (end < start) {
  12691. step = -step;
  12692. }
  12693. this._start = start;
  12694. this._end = end;
  12695. this._step = step;
  12696. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  12697. if (this.size === 0) {
  12698. if (EMPTY_RANGE) {
  12699. return EMPTY_RANGE;
  12700. }
  12701. EMPTY_RANGE = this;
  12702. }
  12703. }
  12704. Range.prototype.toString = function() {
  12705. if (this.size === 0) {
  12706. return 'Range []';
  12707. }
  12708. return 'Range [ ' +
  12709. this._start + '...' + this._end +
  12710. (this._step > 1 ? ' by ' + this._step : '') +
  12711. ' ]';
  12712. };
  12713. Range.prototype.get = function(index, notSetValue) {
  12714. return this.has(index) ?
  12715. this._start + wrapIndex(this, index) * this._step :
  12716. notSetValue;
  12717. };
  12718. Range.prototype.includes = function(searchValue) {
  12719. var possibleIndex = (searchValue - this._start) / this._step;
  12720. return possibleIndex >= 0 &&
  12721. possibleIndex < this.size &&
  12722. possibleIndex === Math.floor(possibleIndex);
  12723. };
  12724. Range.prototype.slice = function(begin, end) {
  12725. if (wholeSlice(begin, end, this.size)) {
  12726. return this;
  12727. }
  12728. begin = resolveBegin(begin, this.size);
  12729. end = resolveEnd(end, this.size);
  12730. if (end <= begin) {
  12731. return new Range(0, 0);
  12732. }
  12733. return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
  12734. };
  12735. Range.prototype.indexOf = function(searchValue) {
  12736. var offsetValue = searchValue - this._start;
  12737. if (offsetValue % this._step === 0) {
  12738. var index = offsetValue / this._step;
  12739. if (index >= 0 && index < this.size) {
  12740. return index
  12741. }
  12742. }
  12743. return -1;
  12744. };
  12745. Range.prototype.lastIndexOf = function(searchValue) {
  12746. return this.indexOf(searchValue);
  12747. };
  12748. Range.prototype.__iterate = function(fn, reverse) {
  12749. var maxIndex = this.size - 1;
  12750. var step = this._step;
  12751. var value = reverse ? this._start + maxIndex * step : this._start;
  12752. for (var ii = 0; ii <= maxIndex; ii++) {
  12753. if (fn(value, ii, this) === false) {
  12754. return ii + 1;
  12755. }
  12756. value += reverse ? -step : step;
  12757. }
  12758. return ii;
  12759. };
  12760. Range.prototype.__iterator = function(type, reverse) {
  12761. var maxIndex = this.size - 1;
  12762. var step = this._step;
  12763. var value = reverse ? this._start + maxIndex * step : this._start;
  12764. var ii = 0;
  12765. return new Iterator(function() {
  12766. var v = value;
  12767. value += reverse ? -step : step;
  12768. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  12769. });
  12770. };
  12771. Range.prototype.equals = function(other) {
  12772. return other instanceof Range ?
  12773. this._start === other._start &&
  12774. this._end === other._end &&
  12775. this._step === other._step :
  12776. deepEqual(this, other);
  12777. };
  12778. var EMPTY_RANGE;
  12779. createClass(Collection, Iterable);
  12780. function Collection() {
  12781. throw TypeError('Abstract');
  12782. }
  12783. createClass(KeyedCollection, Collection);function KeyedCollection() {}
  12784. createClass(IndexedCollection, Collection);function IndexedCollection() {}
  12785. createClass(SetCollection, Collection);function SetCollection() {}
  12786. Collection.Keyed = KeyedCollection;
  12787. Collection.Indexed = IndexedCollection;
  12788. Collection.Set = SetCollection;
  12789. var imul =
  12790. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
  12791. Math.imul :
  12792. function imul(a, b) {
  12793. a = a | 0; // int
  12794. b = b | 0; // int
  12795. var c = a & 0xffff;
  12796. var d = b & 0xffff;
  12797. // Shift by 0 fixes the sign on the high part.
  12798. return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
  12799. };
  12800. // v8 has an optimization for storing 31-bit signed numbers.
  12801. // Values which have either 00 or 11 as the high order bits qualify.
  12802. // This function drops the highest order bit in a signed number, maintaining
  12803. // the sign bit.
  12804. function smi(i32) {
  12805. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
  12806. }
  12807. function hash(o) {
  12808. if (o === false || o === null || o === undefined) {
  12809. return 0;
  12810. }
  12811. if (typeof o.valueOf === 'function') {
  12812. o = o.valueOf();
  12813. if (o === false || o === null || o === undefined) {
  12814. return 0;
  12815. }
  12816. }
  12817. if (o === true) {
  12818. return 1;
  12819. }
  12820. var type = typeof o;
  12821. if (type === 'number') {
  12822. var h = o | 0;
  12823. if (h !== o) {
  12824. h ^= o * 0xFFFFFFFF;
  12825. }
  12826. while (o > 0xFFFFFFFF) {
  12827. o /= 0xFFFFFFFF;
  12828. h ^= o;
  12829. }
  12830. return smi(h);
  12831. }
  12832. if (type === 'string') {
  12833. return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
  12834. }
  12835. if (typeof o.hashCode === 'function') {
  12836. return o.hashCode();
  12837. }
  12838. if (type === 'object') {
  12839. return hashJSObj(o);
  12840. }
  12841. if (typeof o.toString === 'function') {
  12842. return hashString(o.toString());
  12843. }
  12844. throw new Error('Value type ' + type + ' cannot be hashed.');
  12845. }
  12846. function cachedHashString(string) {
  12847. var hash = stringHashCache[string];
  12848. if (hash === undefined) {
  12849. hash = hashString(string);
  12850. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  12851. STRING_HASH_CACHE_SIZE = 0;
  12852. stringHashCache = {};
  12853. }
  12854. STRING_HASH_CACHE_SIZE++;
  12855. stringHashCache[string] = hash;
  12856. }
  12857. return hash;
  12858. }
  12859. // http://jsperf.com/hashing-strings
  12860. function hashString(string) {
  12861. // This is the hash from JVM
  12862. // The hash code for a string is computed as
  12863. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  12864. // where s[i] is the ith character of the string and n is the length of
  12865. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  12866. // (exclusive) by dropping high bits.
  12867. var hash = 0;
  12868. for (var ii = 0; ii < string.length; ii++) {
  12869. hash = 31 * hash + string.charCodeAt(ii) | 0;
  12870. }
  12871. return smi(hash);
  12872. }
  12873. function hashJSObj(obj) {
  12874. var hash;
  12875. if (usingWeakMap) {
  12876. hash = weakMap.get(obj);
  12877. if (hash !== undefined) {
  12878. return hash;
  12879. }
  12880. }
  12881. hash = obj[UID_HASH_KEY];
  12882. if (hash !== undefined) {
  12883. return hash;
  12884. }
  12885. if (!canDefineProperty) {
  12886. hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  12887. if (hash !== undefined) {
  12888. return hash;
  12889. }
  12890. hash = getIENodeHash(obj);
  12891. if (hash !== undefined) {
  12892. return hash;
  12893. }
  12894. }
  12895. hash = ++objHashUID;
  12896. if (objHashUID & 0x40000000) {
  12897. objHashUID = 0;
  12898. }
  12899. if (usingWeakMap) {
  12900. weakMap.set(obj, hash);
  12901. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  12902. throw new Error('Non-extensible objects are not allowed as keys.');
  12903. } else if (canDefineProperty) {
  12904. Object.defineProperty(obj, UID_HASH_KEY, {
  12905. 'enumerable': false,
  12906. 'configurable': false,
  12907. 'writable': false,
  12908. 'value': hash
  12909. });
  12910. } else if (obj.propertyIsEnumerable !== undefined &&
  12911. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
  12912. // Since we can't define a non-enumerable property on the object
  12913. // we'll hijack one of the less-used non-enumerable properties to
  12914. // save our hash on it. Since this is a function it will not show up in
  12915. // `JSON.stringify` which is what we want.
  12916. obj.propertyIsEnumerable = function() {
  12917. return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
  12918. };
  12919. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  12920. } else if (obj.nodeType !== undefined) {
  12921. // At this point we couldn't get the IE `uniqueID` to use as a hash
  12922. // and we couldn't use a non-enumerable property to exploit the
  12923. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  12924. // itself.
  12925. obj[UID_HASH_KEY] = hash;
  12926. } else {
  12927. throw new Error('Unable to set a non-enumerable property on object.');
  12928. }
  12929. return hash;
  12930. }
  12931. // Get references to ES5 object methods.
  12932. var isExtensible = Object.isExtensible;
  12933. // True if Object.defineProperty works as expected. IE8 fails this test.
  12934. var canDefineProperty = (function() {
  12935. try {
  12936. Object.defineProperty({}, '@', {});
  12937. return true;
  12938. } catch (e) {
  12939. return false;
  12940. }
  12941. }());
  12942. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  12943. // and avoid memory leaks from the IE cloneNode bug.
  12944. function getIENodeHash(node) {
  12945. if (node && node.nodeType > 0) {
  12946. switch (node.nodeType) {
  12947. case 1: // Element
  12948. return node.uniqueID;
  12949. case 9: // Document
  12950. return node.documentElement && node.documentElement.uniqueID;
  12951. }
  12952. }
  12953. }
  12954. // If possible, use a WeakMap.
  12955. var usingWeakMap = typeof WeakMap === 'function';
  12956. var weakMap;
  12957. if (usingWeakMap) {
  12958. weakMap = new WeakMap();
  12959. }
  12960. var objHashUID = 0;
  12961. var UID_HASH_KEY = '__immutablehash__';
  12962. if (typeof Symbol === 'function') {
  12963. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  12964. }
  12965. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  12966. var STRING_HASH_CACHE_MAX_SIZE = 255;
  12967. var STRING_HASH_CACHE_SIZE = 0;
  12968. var stringHashCache = {};
  12969. function assertNotInfinite(size) {
  12970. invariant(
  12971. size !== Infinity,
  12972. 'Cannot perform this action with an infinite size.'
  12973. );
  12974. }
  12975. createClass(Map, KeyedCollection);
  12976. // @pragma Construction
  12977. function Map(value) {
  12978. return value === null || value === undefined ? emptyMap() :
  12979. isMap(value) && !isOrdered(value) ? value :
  12980. emptyMap().withMutations(function(map ) {
  12981. var iter = KeyedIterable(value);
  12982. assertNotInfinite(iter.size);
  12983. iter.forEach(function(v, k) {return map.set(k, v)});
  12984. });
  12985. }
  12986. Map.prototype.toString = function() {
  12987. return this.__toString('Map {', '}');
  12988. };
  12989. // @pragma Access
  12990. Map.prototype.get = function(k, notSetValue) {
  12991. return this._root ?
  12992. this._root.get(0, undefined, k, notSetValue) :
  12993. notSetValue;
  12994. };
  12995. // @pragma Modification
  12996. Map.prototype.set = function(k, v) {
  12997. return updateMap(this, k, v);
  12998. };
  12999. Map.prototype.setIn = function(keyPath, v) {
  13000. return this.updateIn(keyPath, NOT_SET, function() {return v});
  13001. };
  13002. Map.prototype.remove = function(k) {
  13003. return updateMap(this, k, NOT_SET);
  13004. };
  13005. Map.prototype.deleteIn = function(keyPath) {
  13006. return this.updateIn(keyPath, function() {return NOT_SET});
  13007. };
  13008. Map.prototype.update = function(k, notSetValue, updater) {
  13009. return arguments.length === 1 ?
  13010. k(this) :
  13011. this.updateIn([k], notSetValue, updater);
  13012. };
  13013. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  13014. if (!updater) {
  13015. updater = notSetValue;
  13016. notSetValue = undefined;
  13017. }
  13018. var updatedValue = updateInDeepMap(
  13019. this,
  13020. forceIterator(keyPath),
  13021. notSetValue,
  13022. updater
  13023. );
  13024. return updatedValue === NOT_SET ? undefined : updatedValue;
  13025. };
  13026. Map.prototype.clear = function() {
  13027. if (this.size === 0) {
  13028. return this;
  13029. }
  13030. if (this.__ownerID) {
  13031. this.size = 0;
  13032. this._root = null;
  13033. this.__hash = undefined;
  13034. this.__altered = true;
  13035. return this;
  13036. }
  13037. return emptyMap();
  13038. };
  13039. // @pragma Composition
  13040. Map.prototype.merge = function(/*...iters*/) {
  13041. return mergeIntoMapWith(this, undefined, arguments);
  13042. };
  13043. Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  13044. return mergeIntoMapWith(this, merger, iters);
  13045. };
  13046. Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  13047. return this.updateIn(
  13048. keyPath,
  13049. emptyMap(),
  13050. function(m ) {return typeof m.merge === 'function' ?
  13051. m.merge.apply(m, iters) :
  13052. iters[iters.length - 1]}
  13053. );
  13054. };
  13055. Map.prototype.mergeDeep = function(/*...iters*/) {
  13056. return mergeIntoMapWith(this, deepMerger, arguments);
  13057. };
  13058. Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  13059. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  13060. };
  13061. Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  13062. return this.updateIn(
  13063. keyPath,
  13064. emptyMap(),
  13065. function(m ) {return typeof m.mergeDeep === 'function' ?
  13066. m.mergeDeep.apply(m, iters) :
  13067. iters[iters.length - 1]}
  13068. );
  13069. };
  13070. Map.prototype.sort = function(comparator) {
  13071. // Late binding
  13072. return OrderedMap(sortFactory(this, comparator));
  13073. };
  13074. Map.prototype.sortBy = function(mapper, comparator) {
  13075. // Late binding
  13076. return OrderedMap(sortFactory(this, comparator, mapper));
  13077. };
  13078. // @pragma Mutability
  13079. Map.prototype.withMutations = function(fn) {
  13080. var mutable = this.asMutable();
  13081. fn(mutable);
  13082. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  13083. };
  13084. Map.prototype.asMutable = function() {
  13085. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  13086. };
  13087. Map.prototype.asImmutable = function() {
  13088. return this.__ensureOwner();
  13089. };
  13090. Map.prototype.wasAltered = function() {
  13091. return this.__altered;
  13092. };
  13093. Map.prototype.__iterator = function(type, reverse) {
  13094. return new MapIterator(this, type, reverse);
  13095. };
  13096. Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  13097. var iterations = 0;
  13098. this._root && this._root.iterate(function(entry ) {
  13099. iterations++;
  13100. return fn(entry[1], entry[0], this$0);
  13101. }, reverse);
  13102. return iterations;
  13103. };
  13104. Map.prototype.__ensureOwner = function(ownerID) {
  13105. if (ownerID === this.__ownerID) {
  13106. return this;
  13107. }
  13108. if (!ownerID) {
  13109. this.__ownerID = ownerID;
  13110. this.__altered = false;
  13111. return this;
  13112. }
  13113. return makeMap(this.size, this._root, ownerID, this.__hash);
  13114. };
  13115. function isMap(maybeMap) {
  13116. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  13117. }
  13118. Map.isMap = isMap;
  13119. var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  13120. var MapPrototype = Map.prototype;
  13121. MapPrototype[IS_MAP_SENTINEL] = true;
  13122. MapPrototype[DELETE] = MapPrototype.remove;
  13123. MapPrototype.removeIn = MapPrototype.deleteIn;
  13124. // #pragma Trie Nodes
  13125. function ArrayMapNode(ownerID, entries) {
  13126. this.ownerID = ownerID;
  13127. this.entries = entries;
  13128. }
  13129. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  13130. var entries = this.entries;
  13131. for (var ii = 0, len = entries.length; ii < len; ii++) {
  13132. if (is(key, entries[ii][0])) {
  13133. return entries[ii][1];
  13134. }
  13135. }
  13136. return notSetValue;
  13137. };
  13138. ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13139. var removed = value === NOT_SET;
  13140. var entries = this.entries;
  13141. var idx = 0;
  13142. for (var len = entries.length; idx < len; idx++) {
  13143. if (is(key, entries[idx][0])) {
  13144. break;
  13145. }
  13146. }
  13147. var exists = idx < len;
  13148. if (exists ? entries[idx][1] === value : removed) {
  13149. return this;
  13150. }
  13151. SetRef(didAlter);
  13152. (removed || !exists) && SetRef(didChangeSize);
  13153. if (removed && entries.length === 1) {
  13154. return; // undefined
  13155. }
  13156. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  13157. return createNodes(ownerID, entries, key, value);
  13158. }
  13159. var isEditable = ownerID && ownerID === this.ownerID;
  13160. var newEntries = isEditable ? entries : arrCopy(entries);
  13161. if (exists) {
  13162. if (removed) {
  13163. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  13164. } else {
  13165. newEntries[idx] = [key, value];
  13166. }
  13167. } else {
  13168. newEntries.push([key, value]);
  13169. }
  13170. if (isEditable) {
  13171. this.entries = newEntries;
  13172. return this;
  13173. }
  13174. return new ArrayMapNode(ownerID, newEntries);
  13175. };
  13176. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  13177. this.ownerID = ownerID;
  13178. this.bitmap = bitmap;
  13179. this.nodes = nodes;
  13180. }
  13181. BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  13182. if (keyHash === undefined) {
  13183. keyHash = hash(key);
  13184. }
  13185. var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
  13186. var bitmap = this.bitmap;
  13187. return (bitmap & bit) === 0 ? notSetValue :
  13188. this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
  13189. };
  13190. BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13191. if (keyHash === undefined) {
  13192. keyHash = hash(key);
  13193. }
  13194. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  13195. var bit = 1 << keyHashFrag;
  13196. var bitmap = this.bitmap;
  13197. var exists = (bitmap & bit) !== 0;
  13198. if (!exists && value === NOT_SET) {
  13199. return this;
  13200. }
  13201. var idx = popCount(bitmap & (bit - 1));
  13202. var nodes = this.nodes;
  13203. var node = exists ? nodes[idx] : undefined;
  13204. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  13205. if (newNode === node) {
  13206. return this;
  13207. }
  13208. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  13209. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  13210. }
  13211. if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
  13212. return nodes[idx ^ 1];
  13213. }
  13214. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  13215. return newNode;
  13216. }
  13217. var isEditable = ownerID && ownerID === this.ownerID;
  13218. var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
  13219. var newNodes = exists ? newNode ?
  13220. setIn(nodes, idx, newNode, isEditable) :
  13221. spliceOut(nodes, idx, isEditable) :
  13222. spliceIn(nodes, idx, newNode, isEditable);
  13223. if (isEditable) {
  13224. this.bitmap = newBitmap;
  13225. this.nodes = newNodes;
  13226. return this;
  13227. }
  13228. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  13229. };
  13230. function HashArrayMapNode(ownerID, count, nodes) {
  13231. this.ownerID = ownerID;
  13232. this.count = count;
  13233. this.nodes = nodes;
  13234. }
  13235. HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  13236. if (keyHash === undefined) {
  13237. keyHash = hash(key);
  13238. }
  13239. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  13240. var node = this.nodes[idx];
  13241. return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
  13242. };
  13243. HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13244. if (keyHash === undefined) {
  13245. keyHash = hash(key);
  13246. }
  13247. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  13248. var removed = value === NOT_SET;
  13249. var nodes = this.nodes;
  13250. var node = nodes[idx];
  13251. if (removed && !node) {
  13252. return this;
  13253. }
  13254. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  13255. if (newNode === node) {
  13256. return this;
  13257. }
  13258. var newCount = this.count;
  13259. if (!node) {
  13260. newCount++;
  13261. } else if (!newNode) {
  13262. newCount--;
  13263. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  13264. return packNodes(ownerID, nodes, newCount, idx);
  13265. }
  13266. }
  13267. var isEditable = ownerID && ownerID === this.ownerID;
  13268. var newNodes = setIn(nodes, idx, newNode, isEditable);
  13269. if (isEditable) {
  13270. this.count = newCount;
  13271. this.nodes = newNodes;
  13272. return this;
  13273. }
  13274. return new HashArrayMapNode(ownerID, newCount, newNodes);
  13275. };
  13276. function HashCollisionNode(ownerID, keyHash, entries) {
  13277. this.ownerID = ownerID;
  13278. this.keyHash = keyHash;
  13279. this.entries = entries;
  13280. }
  13281. HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  13282. var entries = this.entries;
  13283. for (var ii = 0, len = entries.length; ii < len; ii++) {
  13284. if (is(key, entries[ii][0])) {
  13285. return entries[ii][1];
  13286. }
  13287. }
  13288. return notSetValue;
  13289. };
  13290. HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13291. if (keyHash === undefined) {
  13292. keyHash = hash(key);
  13293. }
  13294. var removed = value === NOT_SET;
  13295. if (keyHash !== this.keyHash) {
  13296. if (removed) {
  13297. return this;
  13298. }
  13299. SetRef(didAlter);
  13300. SetRef(didChangeSize);
  13301. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  13302. }
  13303. var entries = this.entries;
  13304. var idx = 0;
  13305. for (var len = entries.length; idx < len; idx++) {
  13306. if (is(key, entries[idx][0])) {
  13307. break;
  13308. }
  13309. }
  13310. var exists = idx < len;
  13311. if (exists ? entries[idx][1] === value : removed) {
  13312. return this;
  13313. }
  13314. SetRef(didAlter);
  13315. (removed || !exists) && SetRef(didChangeSize);
  13316. if (removed && len === 2) {
  13317. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  13318. }
  13319. var isEditable = ownerID && ownerID === this.ownerID;
  13320. var newEntries = isEditable ? entries : arrCopy(entries);
  13321. if (exists) {
  13322. if (removed) {
  13323. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  13324. } else {
  13325. newEntries[idx] = [key, value];
  13326. }
  13327. } else {
  13328. newEntries.push([key, value]);
  13329. }
  13330. if (isEditable) {
  13331. this.entries = newEntries;
  13332. return this;
  13333. }
  13334. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  13335. };
  13336. function ValueNode(ownerID, keyHash, entry) {
  13337. this.ownerID = ownerID;
  13338. this.keyHash = keyHash;
  13339. this.entry = entry;
  13340. }
  13341. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  13342. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  13343. };
  13344. ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13345. var removed = value === NOT_SET;
  13346. var keyMatch = is(key, this.entry[0]);
  13347. if (keyMatch ? value === this.entry[1] : removed) {
  13348. return this;
  13349. }
  13350. SetRef(didAlter);
  13351. if (removed) {
  13352. SetRef(didChangeSize);
  13353. return; // undefined
  13354. }
  13355. if (keyMatch) {
  13356. if (ownerID && ownerID === this.ownerID) {
  13357. this.entry[1] = value;
  13358. return this;
  13359. }
  13360. return new ValueNode(ownerID, this.keyHash, [key, value]);
  13361. }
  13362. SetRef(didChangeSize);
  13363. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  13364. };
  13365. // #pragma Iterators
  13366. ArrayMapNode.prototype.iterate =
  13367. HashCollisionNode.prototype.iterate = function (fn, reverse) {
  13368. var entries = this.entries;
  13369. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  13370. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  13371. return false;
  13372. }
  13373. }
  13374. };
  13375. BitmapIndexedNode.prototype.iterate =
  13376. HashArrayMapNode.prototype.iterate = function (fn, reverse) {
  13377. var nodes = this.nodes;
  13378. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  13379. var node = nodes[reverse ? maxIndex - ii : ii];
  13380. if (node && node.iterate(fn, reverse) === false) {
  13381. return false;
  13382. }
  13383. }
  13384. };
  13385. ValueNode.prototype.iterate = function (fn, reverse) {
  13386. return fn(this.entry);
  13387. };
  13388. createClass(MapIterator, Iterator);
  13389. function MapIterator(map, type, reverse) {
  13390. this._type = type;
  13391. this._reverse = reverse;
  13392. this._stack = map._root && mapIteratorFrame(map._root);
  13393. }
  13394. MapIterator.prototype.next = function() {
  13395. var type = this._type;
  13396. var stack = this._stack;
  13397. while (stack) {
  13398. var node = stack.node;
  13399. var index = stack.index++;
  13400. var maxIndex;
  13401. if (node.entry) {
  13402. if (index === 0) {
  13403. return mapIteratorValue(type, node.entry);
  13404. }
  13405. } else if (node.entries) {
  13406. maxIndex = node.entries.length - 1;
  13407. if (index <= maxIndex) {
  13408. return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
  13409. }
  13410. } else {
  13411. maxIndex = node.nodes.length - 1;
  13412. if (index <= maxIndex) {
  13413. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  13414. if (subNode) {
  13415. if (subNode.entry) {
  13416. return mapIteratorValue(type, subNode.entry);
  13417. }
  13418. stack = this._stack = mapIteratorFrame(subNode, stack);
  13419. }
  13420. continue;
  13421. }
  13422. }
  13423. stack = this._stack = this._stack.__prev;
  13424. }
  13425. return iteratorDone();
  13426. };
  13427. function mapIteratorValue(type, entry) {
  13428. return iteratorValue(type, entry[0], entry[1]);
  13429. }
  13430. function mapIteratorFrame(node, prev) {
  13431. return {
  13432. node: node,
  13433. index: 0,
  13434. __prev: prev
  13435. };
  13436. }
  13437. function makeMap(size, root, ownerID, hash) {
  13438. var map = Object.create(MapPrototype);
  13439. map.size = size;
  13440. map._root = root;
  13441. map.__ownerID = ownerID;
  13442. map.__hash = hash;
  13443. map.__altered = false;
  13444. return map;
  13445. }
  13446. var EMPTY_MAP;
  13447. function emptyMap() {
  13448. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  13449. }
  13450. function updateMap(map, k, v) {
  13451. var newRoot;
  13452. var newSize;
  13453. if (!map._root) {
  13454. if (v === NOT_SET) {
  13455. return map;
  13456. }
  13457. newSize = 1;
  13458. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  13459. } else {
  13460. var didChangeSize = MakeRef(CHANGE_LENGTH);
  13461. var didAlter = MakeRef(DID_ALTER);
  13462. newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
  13463. if (!didAlter.value) {
  13464. return map;
  13465. }
  13466. newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
  13467. }
  13468. if (map.__ownerID) {
  13469. map.size = newSize;
  13470. map._root = newRoot;
  13471. map.__hash = undefined;
  13472. map.__altered = true;
  13473. return map;
  13474. }
  13475. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  13476. }
  13477. function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13478. if (!node) {
  13479. if (value === NOT_SET) {
  13480. return node;
  13481. }
  13482. SetRef(didAlter);
  13483. SetRef(didChangeSize);
  13484. return new ValueNode(ownerID, keyHash, [key, value]);
  13485. }
  13486. return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
  13487. }
  13488. function isLeafNode(node) {
  13489. return node.constructor === ValueNode || node.constructor === HashCollisionNode;
  13490. }
  13491. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  13492. if (node.keyHash === keyHash) {
  13493. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  13494. }
  13495. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  13496. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  13497. var newNode;
  13498. var nodes = idx1 === idx2 ?
  13499. [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
  13500. ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
  13501. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  13502. }
  13503. function createNodes(ownerID, entries, key, value) {
  13504. if (!ownerID) {
  13505. ownerID = new OwnerID();
  13506. }
  13507. var node = new ValueNode(ownerID, hash(key), [key, value]);
  13508. for (var ii = 0; ii < entries.length; ii++) {
  13509. var entry = entries[ii];
  13510. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  13511. }
  13512. return node;
  13513. }
  13514. function packNodes(ownerID, nodes, count, excluding) {
  13515. var bitmap = 0;
  13516. var packedII = 0;
  13517. var packedNodes = new Array(count);
  13518. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  13519. var node = nodes[ii];
  13520. if (node !== undefined && ii !== excluding) {
  13521. bitmap |= bit;
  13522. packedNodes[packedII++] = node;
  13523. }
  13524. }
  13525. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  13526. }
  13527. function expandNodes(ownerID, nodes, bitmap, including, node) {
  13528. var count = 0;
  13529. var expandedNodes = new Array(SIZE);
  13530. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  13531. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  13532. }
  13533. expandedNodes[including] = node;
  13534. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  13535. }
  13536. function mergeIntoMapWith(map, merger, iterables) {
  13537. var iters = [];
  13538. for (var ii = 0; ii < iterables.length; ii++) {
  13539. var value = iterables[ii];
  13540. var iter = KeyedIterable(value);
  13541. if (!isIterable(value)) {
  13542. iter = iter.map(function(v ) {return fromJS(v)});
  13543. }
  13544. iters.push(iter);
  13545. }
  13546. return mergeIntoCollectionWith(map, merger, iters);
  13547. }
  13548. function deepMerger(existing, value, key) {
  13549. return existing && existing.mergeDeep && isIterable(value) ?
  13550. existing.mergeDeep(value) :
  13551. is(existing, value) ? existing : value;
  13552. }
  13553. function deepMergerWith(merger) {
  13554. return function(existing, value, key) {
  13555. if (existing && existing.mergeDeepWith && isIterable(value)) {
  13556. return existing.mergeDeepWith(merger, value);
  13557. }
  13558. var nextValue = merger(existing, value, key);
  13559. return is(existing, nextValue) ? existing : nextValue;
  13560. };
  13561. }
  13562. function mergeIntoCollectionWith(collection, merger, iters) {
  13563. iters = iters.filter(function(x ) {return x.size !== 0});
  13564. if (iters.length === 0) {
  13565. return collection;
  13566. }
  13567. if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
  13568. return collection.constructor(iters[0]);
  13569. }
  13570. return collection.withMutations(function(collection ) {
  13571. var mergeIntoMap = merger ?
  13572. function(value, key) {
  13573. collection.update(key, NOT_SET, function(existing )
  13574. {return existing === NOT_SET ? value : merger(existing, value, key)}
  13575. );
  13576. } :
  13577. function(value, key) {
  13578. collection.set(key, value);
  13579. };
  13580. for (var ii = 0; ii < iters.length; ii++) {
  13581. iters[ii].forEach(mergeIntoMap);
  13582. }
  13583. });
  13584. }
  13585. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  13586. var isNotSet = existing === NOT_SET;
  13587. var step = keyPathIter.next();
  13588. if (step.done) {
  13589. var existingValue = isNotSet ? notSetValue : existing;
  13590. var newValue = updater(existingValue);
  13591. return newValue === existingValue ? existing : newValue;
  13592. }
  13593. invariant(
  13594. isNotSet || (existing && existing.set),
  13595. 'invalid keyPath'
  13596. );
  13597. var key = step.value;
  13598. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  13599. var nextUpdated = updateInDeepMap(
  13600. nextExisting,
  13601. keyPathIter,
  13602. notSetValue,
  13603. updater
  13604. );
  13605. return nextUpdated === nextExisting ? existing :
  13606. nextUpdated === NOT_SET ? existing.remove(key) :
  13607. (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  13608. }
  13609. function popCount(x) {
  13610. x = x - ((x >> 1) & 0x55555555);
  13611. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  13612. x = (x + (x >> 4)) & 0x0f0f0f0f;
  13613. x = x + (x >> 8);
  13614. x = x + (x >> 16);
  13615. return x & 0x7f;
  13616. }
  13617. function setIn(array, idx, val, canEdit) {
  13618. var newArray = canEdit ? array : arrCopy(array);
  13619. newArray[idx] = val;
  13620. return newArray;
  13621. }
  13622. function spliceIn(array, idx, val, canEdit) {
  13623. var newLen = array.length + 1;
  13624. if (canEdit && idx + 1 === newLen) {
  13625. array[idx] = val;
  13626. return array;
  13627. }
  13628. var newArray = new Array(newLen);
  13629. var after = 0;
  13630. for (var ii = 0; ii < newLen; ii++) {
  13631. if (ii === idx) {
  13632. newArray[ii] = val;
  13633. after = -1;
  13634. } else {
  13635. newArray[ii] = array[ii + after];
  13636. }
  13637. }
  13638. return newArray;
  13639. }
  13640. function spliceOut(array, idx, canEdit) {
  13641. var newLen = array.length - 1;
  13642. if (canEdit && idx === newLen) {
  13643. array.pop();
  13644. return array;
  13645. }
  13646. var newArray = new Array(newLen);
  13647. var after = 0;
  13648. for (var ii = 0; ii < newLen; ii++) {
  13649. if (ii === idx) {
  13650. after = 1;
  13651. }
  13652. newArray[ii] = array[ii + after];
  13653. }
  13654. return newArray;
  13655. }
  13656. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  13657. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  13658. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  13659. createClass(List, IndexedCollection);
  13660. // @pragma Construction
  13661. function List(value) {
  13662. var empty = emptyList();
  13663. if (value === null || value === undefined) {
  13664. return empty;
  13665. }
  13666. if (isList(value)) {
  13667. return value;
  13668. }
  13669. var iter = IndexedIterable(value);
  13670. var size = iter.size;
  13671. if (size === 0) {
  13672. return empty;
  13673. }
  13674. assertNotInfinite(size);
  13675. if (size > 0 && size < SIZE) {
  13676. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  13677. }
  13678. return empty.withMutations(function(list ) {
  13679. list.setSize(size);
  13680. iter.forEach(function(v, i) {return list.set(i, v)});
  13681. });
  13682. }
  13683. List.of = function(/*...values*/) {
  13684. return this(arguments);
  13685. };
  13686. List.prototype.toString = function() {
  13687. return this.__toString('List [', ']');
  13688. };
  13689. // @pragma Access
  13690. List.prototype.get = function(index, notSetValue) {
  13691. index = wrapIndex(this, index);
  13692. if (index >= 0 && index < this.size) {
  13693. index += this._origin;
  13694. var node = listNodeFor(this, index);
  13695. return node && node.array[index & MASK];
  13696. }
  13697. return notSetValue;
  13698. };
  13699. // @pragma Modification
  13700. List.prototype.set = function(index, value) {
  13701. return updateList(this, index, value);
  13702. };
  13703. List.prototype.remove = function(index) {
  13704. return !this.has(index) ? this :
  13705. index === 0 ? this.shift() :
  13706. index === this.size - 1 ? this.pop() :
  13707. this.splice(index, 1);
  13708. };
  13709. List.prototype.insert = function(index, value) {
  13710. return this.splice(index, 0, value);
  13711. };
  13712. List.prototype.clear = function() {
  13713. if (this.size === 0) {
  13714. return this;
  13715. }
  13716. if (this.__ownerID) {
  13717. this.size = this._origin = this._capacity = 0;
  13718. this._level = SHIFT;
  13719. this._root = this._tail = null;
  13720. this.__hash = undefined;
  13721. this.__altered = true;
  13722. return this;
  13723. }
  13724. return emptyList();
  13725. };
  13726. List.prototype.push = function(/*...values*/) {
  13727. var values = arguments;
  13728. var oldSize = this.size;
  13729. return this.withMutations(function(list ) {
  13730. setListBounds(list, 0, oldSize + values.length);
  13731. for (var ii = 0; ii < values.length; ii++) {
  13732. list.set(oldSize + ii, values[ii]);
  13733. }
  13734. });
  13735. };
  13736. List.prototype.pop = function() {
  13737. return setListBounds(this, 0, -1);
  13738. };
  13739. List.prototype.unshift = function(/*...values*/) {
  13740. var values = arguments;
  13741. return this.withMutations(function(list ) {
  13742. setListBounds(list, -values.length);
  13743. for (var ii = 0; ii < values.length; ii++) {
  13744. list.set(ii, values[ii]);
  13745. }
  13746. });
  13747. };
  13748. List.prototype.shift = function() {
  13749. return setListBounds(this, 1);
  13750. };
  13751. // @pragma Composition
  13752. List.prototype.merge = function(/*...iters*/) {
  13753. return mergeIntoListWith(this, undefined, arguments);
  13754. };
  13755. List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  13756. return mergeIntoListWith(this, merger, iters);
  13757. };
  13758. List.prototype.mergeDeep = function(/*...iters*/) {
  13759. return mergeIntoListWith(this, deepMerger, arguments);
  13760. };
  13761. List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  13762. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  13763. };
  13764. List.prototype.setSize = function(size) {
  13765. return setListBounds(this, 0, size);
  13766. };
  13767. // @pragma Iteration
  13768. List.prototype.slice = function(begin, end) {
  13769. var size = this.size;
  13770. if (wholeSlice(begin, end, size)) {
  13771. return this;
  13772. }
  13773. return setListBounds(
  13774. this,
  13775. resolveBegin(begin, size),
  13776. resolveEnd(end, size)
  13777. );
  13778. };
  13779. List.prototype.__iterator = function(type, reverse) {
  13780. var index = 0;
  13781. var values = iterateList(this, reverse);
  13782. return new Iterator(function() {
  13783. var value = values();
  13784. return value === DONE ?
  13785. iteratorDone() :
  13786. iteratorValue(type, index++, value);
  13787. });
  13788. };
  13789. List.prototype.__iterate = function(fn, reverse) {
  13790. var index = 0;
  13791. var values = iterateList(this, reverse);
  13792. var value;
  13793. while ((value = values()) !== DONE) {
  13794. if (fn(value, index++, this) === false) {
  13795. break;
  13796. }
  13797. }
  13798. return index;
  13799. };
  13800. List.prototype.__ensureOwner = function(ownerID) {
  13801. if (ownerID === this.__ownerID) {
  13802. return this;
  13803. }
  13804. if (!ownerID) {
  13805. this.__ownerID = ownerID;
  13806. return this;
  13807. }
  13808. return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
  13809. };
  13810. function isList(maybeList) {
  13811. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  13812. }
  13813. List.isList = isList;
  13814. var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  13815. var ListPrototype = List.prototype;
  13816. ListPrototype[IS_LIST_SENTINEL] = true;
  13817. ListPrototype[DELETE] = ListPrototype.remove;
  13818. ListPrototype.setIn = MapPrototype.setIn;
  13819. ListPrototype.deleteIn =
  13820. ListPrototype.removeIn = MapPrototype.removeIn;
  13821. ListPrototype.update = MapPrototype.update;
  13822. ListPrototype.updateIn = MapPrototype.updateIn;
  13823. ListPrototype.mergeIn = MapPrototype.mergeIn;
  13824. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  13825. ListPrototype.withMutations = MapPrototype.withMutations;
  13826. ListPrototype.asMutable = MapPrototype.asMutable;
  13827. ListPrototype.asImmutable = MapPrototype.asImmutable;
  13828. ListPrototype.wasAltered = MapPrototype.wasAltered;
  13829. function VNode(array, ownerID) {
  13830. this.array = array;
  13831. this.ownerID = ownerID;
  13832. }
  13833. // TODO: seems like these methods are very similar
  13834. VNode.prototype.removeBefore = function(ownerID, level, index) {
  13835. if (index === level ? 1 << level : this.array.length === 0) {
  13836. return this;
  13837. }
  13838. var originIndex = (index >>> level) & MASK;
  13839. if (originIndex >= this.array.length) {
  13840. return new VNode([], ownerID);
  13841. }
  13842. var removingFirst = originIndex === 0;
  13843. var newChild;
  13844. if (level > 0) {
  13845. var oldChild = this.array[originIndex];
  13846. newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  13847. if (newChild === oldChild && removingFirst) {
  13848. return this;
  13849. }
  13850. }
  13851. if (removingFirst && !newChild) {
  13852. return this;
  13853. }
  13854. var editable = editableVNode(this, ownerID);
  13855. if (!removingFirst) {
  13856. for (var ii = 0; ii < originIndex; ii++) {
  13857. editable.array[ii] = undefined;
  13858. }
  13859. }
  13860. if (newChild) {
  13861. editable.array[originIndex] = newChild;
  13862. }
  13863. return editable;
  13864. };
  13865. VNode.prototype.removeAfter = function(ownerID, level, index) {
  13866. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  13867. return this;
  13868. }
  13869. var sizeIndex = ((index - 1) >>> level) & MASK;
  13870. if (sizeIndex >= this.array.length) {
  13871. return this;
  13872. }
  13873. var newChild;
  13874. if (level > 0) {
  13875. var oldChild = this.array[sizeIndex];
  13876. newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  13877. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  13878. return this;
  13879. }
  13880. }
  13881. var editable = editableVNode(this, ownerID);
  13882. editable.array.splice(sizeIndex + 1);
  13883. if (newChild) {
  13884. editable.array[sizeIndex] = newChild;
  13885. }
  13886. return editable;
  13887. };
  13888. var DONE = {};
  13889. function iterateList(list, reverse) {
  13890. var left = list._origin;
  13891. var right = list._capacity;
  13892. var tailPos = getTailOffset(right);
  13893. var tail = list._tail;
  13894. return iterateNodeOrLeaf(list._root, list._level, 0);
  13895. function iterateNodeOrLeaf(node, level, offset) {
  13896. return level === 0 ?
  13897. iterateLeaf(node, offset) :
  13898. iterateNode(node, level, offset);
  13899. }
  13900. function iterateLeaf(node, offset) {
  13901. var array = offset === tailPos ? tail && tail.array : node && node.array;
  13902. var from = offset > left ? 0 : left - offset;
  13903. var to = right - offset;
  13904. if (to > SIZE) {
  13905. to = SIZE;
  13906. }
  13907. return function() {
  13908. if (from === to) {
  13909. return DONE;
  13910. }
  13911. var idx = reverse ? --to : from++;
  13912. return array && array[idx];
  13913. };
  13914. }
  13915. function iterateNode(node, level, offset) {
  13916. var values;
  13917. var array = node && node.array;
  13918. var from = offset > left ? 0 : (left - offset) >> level;
  13919. var to = ((right - offset) >> level) + 1;
  13920. if (to > SIZE) {
  13921. to = SIZE;
  13922. }
  13923. return function() {
  13924. do {
  13925. if (values) {
  13926. var value = values();
  13927. if (value !== DONE) {
  13928. return value;
  13929. }
  13930. values = null;
  13931. }
  13932. if (from === to) {
  13933. return DONE;
  13934. }
  13935. var idx = reverse ? --to : from++;
  13936. values = iterateNodeOrLeaf(
  13937. array && array[idx], level - SHIFT, offset + (idx << level)
  13938. );
  13939. } while (true);
  13940. };
  13941. }
  13942. }
  13943. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  13944. var list = Object.create(ListPrototype);
  13945. list.size = capacity - origin;
  13946. list._origin = origin;
  13947. list._capacity = capacity;
  13948. list._level = level;
  13949. list._root = root;
  13950. list._tail = tail;
  13951. list.__ownerID = ownerID;
  13952. list.__hash = hash;
  13953. list.__altered = false;
  13954. return list;
  13955. }
  13956. var EMPTY_LIST;
  13957. function emptyList() {
  13958. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  13959. }
  13960. function updateList(list, index, value) {
  13961. index = wrapIndex(list, index);
  13962. if (index !== index) {
  13963. return list;
  13964. }
  13965. if (index >= list.size || index < 0) {
  13966. return list.withMutations(function(list ) {
  13967. index < 0 ?
  13968. setListBounds(list, index).set(0, value) :
  13969. setListBounds(list, 0, index + 1).set(index, value);
  13970. });
  13971. }
  13972. index += list._origin;
  13973. var newTail = list._tail;
  13974. var newRoot = list._root;
  13975. var didAlter = MakeRef(DID_ALTER);
  13976. if (index >= getTailOffset(list._capacity)) {
  13977. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  13978. } else {
  13979. newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
  13980. }
  13981. if (!didAlter.value) {
  13982. return list;
  13983. }
  13984. if (list.__ownerID) {
  13985. list._root = newRoot;
  13986. list._tail = newTail;
  13987. list.__hash = undefined;
  13988. list.__altered = true;
  13989. return list;
  13990. }
  13991. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  13992. }
  13993. function updateVNode(node, ownerID, level, index, value, didAlter) {
  13994. var idx = (index >>> level) & MASK;
  13995. var nodeHas = node && idx < node.array.length;
  13996. if (!nodeHas && value === undefined) {
  13997. return node;
  13998. }
  13999. var newNode;
  14000. if (level > 0) {
  14001. var lowerNode = node && node.array[idx];
  14002. var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
  14003. if (newLowerNode === lowerNode) {
  14004. return node;
  14005. }
  14006. newNode = editableVNode(node, ownerID);
  14007. newNode.array[idx] = newLowerNode;
  14008. return newNode;
  14009. }
  14010. if (nodeHas && node.array[idx] === value) {
  14011. return node;
  14012. }
  14013. SetRef(didAlter);
  14014. newNode = editableVNode(node, ownerID);
  14015. if (value === undefined && idx === newNode.array.length - 1) {
  14016. newNode.array.pop();
  14017. } else {
  14018. newNode.array[idx] = value;
  14019. }
  14020. return newNode;
  14021. }
  14022. function editableVNode(node, ownerID) {
  14023. if (ownerID && node && ownerID === node.ownerID) {
  14024. return node;
  14025. }
  14026. return new VNode(node ? node.array.slice() : [], ownerID);
  14027. }
  14028. function listNodeFor(list, rawIndex) {
  14029. if (rawIndex >= getTailOffset(list._capacity)) {
  14030. return list._tail;
  14031. }
  14032. if (rawIndex < 1 << (list._level + SHIFT)) {
  14033. var node = list._root;
  14034. var level = list._level;
  14035. while (node && level > 0) {
  14036. node = node.array[(rawIndex >>> level) & MASK];
  14037. level -= SHIFT;
  14038. }
  14039. return node;
  14040. }
  14041. }
  14042. function setListBounds(list, begin, end) {
  14043. // Sanitize begin & end using this shorthand for ToInt32(argument)
  14044. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  14045. if (begin !== undefined) {
  14046. begin = begin | 0;
  14047. }
  14048. if (end !== undefined) {
  14049. end = end | 0;
  14050. }
  14051. var owner = list.__ownerID || new OwnerID();
  14052. var oldOrigin = list._origin;
  14053. var oldCapacity = list._capacity;
  14054. var newOrigin = oldOrigin + begin;
  14055. var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
  14056. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  14057. return list;
  14058. }
  14059. // If it's going to end after it starts, it's empty.
  14060. if (newOrigin >= newCapacity) {
  14061. return list.clear();
  14062. }
  14063. var newLevel = list._level;
  14064. var newRoot = list._root;
  14065. // New origin might need creating a higher root.
  14066. var offsetShift = 0;
  14067. while (newOrigin + offsetShift < 0) {
  14068. newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
  14069. newLevel += SHIFT;
  14070. offsetShift += 1 << newLevel;
  14071. }
  14072. if (offsetShift) {
  14073. newOrigin += offsetShift;
  14074. oldOrigin += offsetShift;
  14075. newCapacity += offsetShift;
  14076. oldCapacity += offsetShift;
  14077. }
  14078. var oldTailOffset = getTailOffset(oldCapacity);
  14079. var newTailOffset = getTailOffset(newCapacity);
  14080. // New size might need creating a higher root.
  14081. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  14082. newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
  14083. newLevel += SHIFT;
  14084. }
  14085. // Locate or create the new tail.
  14086. var oldTail = list._tail;
  14087. var newTail = newTailOffset < oldTailOffset ?
  14088. listNodeFor(list, newCapacity - 1) :
  14089. newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
  14090. // Merge Tail into tree.
  14091. if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
  14092. newRoot = editableVNode(newRoot, owner);
  14093. var node = newRoot;
  14094. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  14095. var idx = (oldTailOffset >>> level) & MASK;
  14096. node = node.array[idx] = editableVNode(node.array[idx], owner);
  14097. }
  14098. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  14099. }
  14100. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  14101. if (newCapacity < oldCapacity) {
  14102. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  14103. }
  14104. // If the new origin is within the tail, then we do not need a root.
  14105. if (newOrigin >= newTailOffset) {
  14106. newOrigin -= newTailOffset;
  14107. newCapacity -= newTailOffset;
  14108. newLevel = SHIFT;
  14109. newRoot = null;
  14110. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  14111. // Otherwise, if the root has been trimmed, garbage collect.
  14112. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  14113. offsetShift = 0;
  14114. // Identify the new top root node of the subtree of the old root.
  14115. while (newRoot) {
  14116. var beginIndex = (newOrigin >>> newLevel) & MASK;
  14117. if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
  14118. break;
  14119. }
  14120. if (beginIndex) {
  14121. offsetShift += (1 << newLevel) * beginIndex;
  14122. }
  14123. newLevel -= SHIFT;
  14124. newRoot = newRoot.array[beginIndex];
  14125. }
  14126. // Trim the new sides of the new root.
  14127. if (newRoot && newOrigin > oldOrigin) {
  14128. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  14129. }
  14130. if (newRoot && newTailOffset < oldTailOffset) {
  14131. newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
  14132. }
  14133. if (offsetShift) {
  14134. newOrigin -= offsetShift;
  14135. newCapacity -= offsetShift;
  14136. }
  14137. }
  14138. if (list.__ownerID) {
  14139. list.size = newCapacity - newOrigin;
  14140. list._origin = newOrigin;
  14141. list._capacity = newCapacity;
  14142. list._level = newLevel;
  14143. list._root = newRoot;
  14144. list._tail = newTail;
  14145. list.__hash = undefined;
  14146. list.__altered = true;
  14147. return list;
  14148. }
  14149. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  14150. }
  14151. function mergeIntoListWith(list, merger, iterables) {
  14152. var iters = [];
  14153. var maxSize = 0;
  14154. for (var ii = 0; ii < iterables.length; ii++) {
  14155. var value = iterables[ii];
  14156. var iter = IndexedIterable(value);
  14157. if (iter.size > maxSize) {
  14158. maxSize = iter.size;
  14159. }
  14160. if (!isIterable(value)) {
  14161. iter = iter.map(function(v ) {return fromJS(v)});
  14162. }
  14163. iters.push(iter);
  14164. }
  14165. if (maxSize > list.size) {
  14166. list = list.setSize(maxSize);
  14167. }
  14168. return mergeIntoCollectionWith(list, merger, iters);
  14169. }
  14170. function getTailOffset(size) {
  14171. return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
  14172. }
  14173. createClass(OrderedMap, Map);
  14174. // @pragma Construction
  14175. function OrderedMap(value) {
  14176. return value === null || value === undefined ? emptyOrderedMap() :
  14177. isOrderedMap(value) ? value :
  14178. emptyOrderedMap().withMutations(function(map ) {
  14179. var iter = KeyedIterable(value);
  14180. assertNotInfinite(iter.size);
  14181. iter.forEach(function(v, k) {return map.set(k, v)});
  14182. });
  14183. }
  14184. OrderedMap.of = function(/*...values*/) {
  14185. return this(arguments);
  14186. };
  14187. OrderedMap.prototype.toString = function() {
  14188. return this.__toString('OrderedMap {', '}');
  14189. };
  14190. // @pragma Access
  14191. OrderedMap.prototype.get = function(k, notSetValue) {
  14192. var index = this._map.get(k);
  14193. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  14194. };
  14195. // @pragma Modification
  14196. OrderedMap.prototype.clear = function() {
  14197. if (this.size === 0) {
  14198. return this;
  14199. }
  14200. if (this.__ownerID) {
  14201. this.size = 0;
  14202. this._map.clear();
  14203. this._list.clear();
  14204. return this;
  14205. }
  14206. return emptyOrderedMap();
  14207. };
  14208. OrderedMap.prototype.set = function(k, v) {
  14209. return updateOrderedMap(this, k, v);
  14210. };
  14211. OrderedMap.prototype.remove = function(k) {
  14212. return updateOrderedMap(this, k, NOT_SET);
  14213. };
  14214. OrderedMap.prototype.wasAltered = function() {
  14215. return this._map.wasAltered() || this._list.wasAltered();
  14216. };
  14217. OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  14218. return this._list.__iterate(
  14219. function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
  14220. reverse
  14221. );
  14222. };
  14223. OrderedMap.prototype.__iterator = function(type, reverse) {
  14224. return this._list.fromEntrySeq().__iterator(type, reverse);
  14225. };
  14226. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  14227. if (ownerID === this.__ownerID) {
  14228. return this;
  14229. }
  14230. var newMap = this._map.__ensureOwner(ownerID);
  14231. var newList = this._list.__ensureOwner(ownerID);
  14232. if (!ownerID) {
  14233. this.__ownerID = ownerID;
  14234. this._map = newMap;
  14235. this._list = newList;
  14236. return this;
  14237. }
  14238. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  14239. };
  14240. function isOrderedMap(maybeOrderedMap) {
  14241. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  14242. }
  14243. OrderedMap.isOrderedMap = isOrderedMap;
  14244. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  14245. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  14246. function makeOrderedMap(map, list, ownerID, hash) {
  14247. var omap = Object.create(OrderedMap.prototype);
  14248. omap.size = map ? map.size : 0;
  14249. omap._map = map;
  14250. omap._list = list;
  14251. omap.__ownerID = ownerID;
  14252. omap.__hash = hash;
  14253. return omap;
  14254. }
  14255. var EMPTY_ORDERED_MAP;
  14256. function emptyOrderedMap() {
  14257. return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
  14258. }
  14259. function updateOrderedMap(omap, k, v) {
  14260. var map = omap._map;
  14261. var list = omap._list;
  14262. var i = map.get(k);
  14263. var has = i !== undefined;
  14264. var newMap;
  14265. var newList;
  14266. if (v === NOT_SET) { // removed
  14267. if (!has) {
  14268. return omap;
  14269. }
  14270. if (list.size >= SIZE && list.size >= map.size * 2) {
  14271. newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
  14272. newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
  14273. if (omap.__ownerID) {
  14274. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  14275. }
  14276. } else {
  14277. newMap = map.remove(k);
  14278. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  14279. }
  14280. } else {
  14281. if (has) {
  14282. if (v === list.get(i)[1]) {
  14283. return omap;
  14284. }
  14285. newMap = map;
  14286. newList = list.set(i, [k, v]);
  14287. } else {
  14288. newMap = map.set(k, list.size);
  14289. newList = list.set(list.size, [k, v]);
  14290. }
  14291. }
  14292. if (omap.__ownerID) {
  14293. omap.size = newMap.size;
  14294. omap._map = newMap;
  14295. omap._list = newList;
  14296. omap.__hash = undefined;
  14297. return omap;
  14298. }
  14299. return makeOrderedMap(newMap, newList);
  14300. }
  14301. createClass(ToKeyedSequence, KeyedSeq);
  14302. function ToKeyedSequence(indexed, useKeys) {
  14303. this._iter = indexed;
  14304. this._useKeys = useKeys;
  14305. this.size = indexed.size;
  14306. }
  14307. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  14308. return this._iter.get(key, notSetValue);
  14309. };
  14310. ToKeyedSequence.prototype.has = function(key) {
  14311. return this._iter.has(key);
  14312. };
  14313. ToKeyedSequence.prototype.valueSeq = function() {
  14314. return this._iter.valueSeq();
  14315. };
  14316. ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
  14317. var reversedSequence = reverseFactory(this, true);
  14318. if (!this._useKeys) {
  14319. reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
  14320. }
  14321. return reversedSequence;
  14322. };
  14323. ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
  14324. var mappedSequence = mapFactory(this, mapper, context);
  14325. if (!this._useKeys) {
  14326. mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
  14327. }
  14328. return mappedSequence;
  14329. };
  14330. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  14331. var ii;
  14332. return this._iter.__iterate(
  14333. this._useKeys ?
  14334. function(v, k) {return fn(v, k, this$0)} :
  14335. ((ii = reverse ? resolveSize(this) : 0),
  14336. function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
  14337. reverse
  14338. );
  14339. };
  14340. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  14341. if (this._useKeys) {
  14342. return this._iter.__iterator(type, reverse);
  14343. }
  14344. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  14345. var ii = reverse ? resolveSize(this) : 0;
  14346. return new Iterator(function() {
  14347. var step = iterator.next();
  14348. return step.done ? step :
  14349. iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  14350. });
  14351. };
  14352. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  14353. createClass(ToIndexedSequence, IndexedSeq);
  14354. function ToIndexedSequence(iter) {
  14355. this._iter = iter;
  14356. this.size = iter.size;
  14357. }
  14358. ToIndexedSequence.prototype.includes = function(value) {
  14359. return this._iter.includes(value);
  14360. };
  14361. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  14362. var iterations = 0;
  14363. return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
  14364. };
  14365. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  14366. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  14367. var iterations = 0;
  14368. return new Iterator(function() {
  14369. var step = iterator.next();
  14370. return step.done ? step :
  14371. iteratorValue(type, iterations++, step.value, step)
  14372. });
  14373. };
  14374. createClass(ToSetSequence, SetSeq);
  14375. function ToSetSequence(iter) {
  14376. this._iter = iter;
  14377. this.size = iter.size;
  14378. }
  14379. ToSetSequence.prototype.has = function(key) {
  14380. return this._iter.includes(key);
  14381. };
  14382. ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  14383. return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
  14384. };
  14385. ToSetSequence.prototype.__iterator = function(type, reverse) {
  14386. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  14387. return new Iterator(function() {
  14388. var step = iterator.next();
  14389. return step.done ? step :
  14390. iteratorValue(type, step.value, step.value, step);
  14391. });
  14392. };
  14393. createClass(FromEntriesSequence, KeyedSeq);
  14394. function FromEntriesSequence(entries) {
  14395. this._iter = entries;
  14396. this.size = entries.size;
  14397. }
  14398. FromEntriesSequence.prototype.entrySeq = function() {
  14399. return this._iter.toSeq();
  14400. };
  14401. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  14402. return this._iter.__iterate(function(entry ) {
  14403. // Check if entry exists first so array access doesn't throw for holes
  14404. // in the parent iteration.
  14405. if (entry) {
  14406. validateEntry(entry);
  14407. var indexedIterable = isIterable(entry);
  14408. return fn(
  14409. indexedIterable ? entry.get(1) : entry[1],
  14410. indexedIterable ? entry.get(0) : entry[0],
  14411. this$0
  14412. );
  14413. }
  14414. }, reverse);
  14415. };
  14416. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  14417. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  14418. return new Iterator(function() {
  14419. while (true) {
  14420. var step = iterator.next();
  14421. if (step.done) {
  14422. return step;
  14423. }
  14424. var entry = step.value;
  14425. // Check if entry exists first so array access doesn't throw for holes
  14426. // in the parent iteration.
  14427. if (entry) {
  14428. validateEntry(entry);
  14429. var indexedIterable = isIterable(entry);
  14430. return iteratorValue(
  14431. type,
  14432. indexedIterable ? entry.get(0) : entry[0],
  14433. indexedIterable ? entry.get(1) : entry[1],
  14434. step
  14435. );
  14436. }
  14437. }
  14438. });
  14439. };
  14440. ToIndexedSequence.prototype.cacheResult =
  14441. ToKeyedSequence.prototype.cacheResult =
  14442. ToSetSequence.prototype.cacheResult =
  14443. FromEntriesSequence.prototype.cacheResult =
  14444. cacheResultThrough;
  14445. function flipFactory(iterable) {
  14446. var flipSequence = makeSequence(iterable);
  14447. flipSequence._iter = iterable;
  14448. flipSequence.size = iterable.size;
  14449. flipSequence.flip = function() {return iterable};
  14450. flipSequence.reverse = function () {
  14451. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  14452. reversedSequence.flip = function() {return iterable.reverse()};
  14453. return reversedSequence;
  14454. };
  14455. flipSequence.has = function(key ) {return iterable.includes(key)};
  14456. flipSequence.includes = function(key ) {return iterable.has(key)};
  14457. flipSequence.cacheResult = cacheResultThrough;
  14458. flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  14459. return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
  14460. };
  14461. flipSequence.__iteratorUncached = function(type, reverse) {
  14462. if (type === ITERATE_ENTRIES) {
  14463. var iterator = iterable.__iterator(type, reverse);
  14464. return new Iterator(function() {
  14465. var step = iterator.next();
  14466. if (!step.done) {
  14467. var k = step.value[0];
  14468. step.value[0] = step.value[1];
  14469. step.value[1] = k;
  14470. }
  14471. return step;
  14472. });
  14473. }
  14474. return iterable.__iterator(
  14475. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  14476. reverse
  14477. );
  14478. };
  14479. return flipSequence;
  14480. }
  14481. function mapFactory(iterable, mapper, context) {
  14482. var mappedSequence = makeSequence(iterable);
  14483. mappedSequence.size = iterable.size;
  14484. mappedSequence.has = function(key ) {return iterable.has(key)};
  14485. mappedSequence.get = function(key, notSetValue) {
  14486. var v = iterable.get(key, NOT_SET);
  14487. return v === NOT_SET ?
  14488. notSetValue :
  14489. mapper.call(context, v, key, iterable);
  14490. };
  14491. mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  14492. return iterable.__iterate(
  14493. function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
  14494. reverse
  14495. );
  14496. };
  14497. mappedSequence.__iteratorUncached = function (type, reverse) {
  14498. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  14499. return new Iterator(function() {
  14500. var step = iterator.next();
  14501. if (step.done) {
  14502. return step;
  14503. }
  14504. var entry = step.value;
  14505. var key = entry[0];
  14506. return iteratorValue(
  14507. type,
  14508. key,
  14509. mapper.call(context, entry[1], key, iterable),
  14510. step
  14511. );
  14512. });
  14513. };
  14514. return mappedSequence;
  14515. }
  14516. function reverseFactory(iterable, useKeys) {
  14517. var reversedSequence = makeSequence(iterable);
  14518. reversedSequence._iter = iterable;
  14519. reversedSequence.size = iterable.size;
  14520. reversedSequence.reverse = function() {return iterable};
  14521. if (iterable.flip) {
  14522. reversedSequence.flip = function () {
  14523. var flipSequence = flipFactory(iterable);
  14524. flipSequence.reverse = function() {return iterable.flip()};
  14525. return flipSequence;
  14526. };
  14527. }
  14528. reversedSequence.get = function(key, notSetValue)
  14529. {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
  14530. reversedSequence.has = function(key )
  14531. {return iterable.has(useKeys ? key : -1 - key)};
  14532. reversedSequence.includes = function(value ) {return iterable.includes(value)};
  14533. reversedSequence.cacheResult = cacheResultThrough;
  14534. reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
  14535. return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
  14536. };
  14537. reversedSequence.__iterator =
  14538. function(type, reverse) {return iterable.__iterator(type, !reverse)};
  14539. return reversedSequence;
  14540. }
  14541. function filterFactory(iterable, predicate, context, useKeys) {
  14542. var filterSequence = makeSequence(iterable);
  14543. if (useKeys) {
  14544. filterSequence.has = function(key ) {
  14545. var v = iterable.get(key, NOT_SET);
  14546. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  14547. };
  14548. filterSequence.get = function(key, notSetValue) {
  14549. var v = iterable.get(key, NOT_SET);
  14550. return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
  14551. v : notSetValue;
  14552. };
  14553. }
  14554. filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  14555. var iterations = 0;
  14556. iterable.__iterate(function(v, k, c) {
  14557. if (predicate.call(context, v, k, c)) {
  14558. iterations++;
  14559. return fn(v, useKeys ? k : iterations - 1, this$0);
  14560. }
  14561. }, reverse);
  14562. return iterations;
  14563. };
  14564. filterSequence.__iteratorUncached = function (type, reverse) {
  14565. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  14566. var iterations = 0;
  14567. return new Iterator(function() {
  14568. while (true) {
  14569. var step = iterator.next();
  14570. if (step.done) {
  14571. return step;
  14572. }
  14573. var entry = step.value;
  14574. var key = entry[0];
  14575. var value = entry[1];
  14576. if (predicate.call(context, value, key, iterable)) {
  14577. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  14578. }
  14579. }
  14580. });
  14581. };
  14582. return filterSequence;
  14583. }
  14584. function countByFactory(iterable, grouper, context) {
  14585. var groups = Map().asMutable();
  14586. iterable.__iterate(function(v, k) {
  14587. groups.update(
  14588. grouper.call(context, v, k, iterable),
  14589. 0,
  14590. function(a ) {return a + 1}
  14591. );
  14592. });
  14593. return groups.asImmutable();
  14594. }
  14595. function groupByFactory(iterable, grouper, context) {
  14596. var isKeyedIter = isKeyed(iterable);
  14597. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  14598. iterable.__iterate(function(v, k) {
  14599. groups.update(
  14600. grouper.call(context, v, k, iterable),
  14601. function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
  14602. );
  14603. });
  14604. var coerce = iterableClass(iterable);
  14605. return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
  14606. }
  14607. function sliceFactory(iterable, begin, end, useKeys) {
  14608. var originalSize = iterable.size;
  14609. // Sanitize begin & end using this shorthand for ToInt32(argument)
  14610. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  14611. if (begin !== undefined) {
  14612. begin = begin | 0;
  14613. }
  14614. if (end !== undefined) {
  14615. end = end | 0;
  14616. }
  14617. if (wholeSlice(begin, end, originalSize)) {
  14618. return iterable;
  14619. }
  14620. var resolvedBegin = resolveBegin(begin, originalSize);
  14621. var resolvedEnd = resolveEnd(end, originalSize);
  14622. // begin or end will be NaN if they were provided as negative numbers and
  14623. // this iterable's size is unknown. In that case, cache first so there is
  14624. // a known size and these do not resolve to NaN.
  14625. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  14626. return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
  14627. }
  14628. // Note: resolvedEnd is undefined when the original sequence's length is
  14629. // unknown and this slice did not supply an end and should contain all
  14630. // elements after resolvedBegin.
  14631. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  14632. var resolvedSize = resolvedEnd - resolvedBegin;
  14633. var sliceSize;
  14634. if (resolvedSize === resolvedSize) {
  14635. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  14636. }
  14637. var sliceSeq = makeSequence(iterable);
  14638. // If iterable.size is undefined, the size of the realized sliceSeq is
  14639. // unknown at this point unless the number of items to slice is 0
  14640. sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
  14641. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  14642. sliceSeq.get = function (index, notSetValue) {
  14643. index = wrapIndex(this, index);
  14644. return index >= 0 && index < sliceSize ?
  14645. iterable.get(index + resolvedBegin, notSetValue) :
  14646. notSetValue;
  14647. };
  14648. }
  14649. sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
  14650. if (sliceSize === 0) {
  14651. return 0;
  14652. }
  14653. if (reverse) {
  14654. return this.cacheResult().__iterate(fn, reverse);
  14655. }
  14656. var skipped = 0;
  14657. var isSkipping = true;
  14658. var iterations = 0;
  14659. iterable.__iterate(function(v, k) {
  14660. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  14661. iterations++;
  14662. return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  14663. iterations !== sliceSize;
  14664. }
  14665. });
  14666. return iterations;
  14667. };
  14668. sliceSeq.__iteratorUncached = function(type, reverse) {
  14669. if (sliceSize !== 0 && reverse) {
  14670. return this.cacheResult().__iterator(type, reverse);
  14671. }
  14672. // Don't bother instantiating parent iterator if taking 0.
  14673. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  14674. var skipped = 0;
  14675. var iterations = 0;
  14676. return new Iterator(function() {
  14677. while (skipped++ < resolvedBegin) {
  14678. iterator.next();
  14679. }
  14680. if (++iterations > sliceSize) {
  14681. return iteratorDone();
  14682. }
  14683. var step = iterator.next();
  14684. if (useKeys || type === ITERATE_VALUES) {
  14685. return step;
  14686. } else if (type === ITERATE_KEYS) {
  14687. return iteratorValue(type, iterations - 1, undefined, step);
  14688. } else {
  14689. return iteratorValue(type, iterations - 1, step.value[1], step);
  14690. }
  14691. });
  14692. };
  14693. return sliceSeq;
  14694. }
  14695. function takeWhileFactory(iterable, predicate, context) {
  14696. var takeSequence = makeSequence(iterable);
  14697. takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  14698. if (reverse) {
  14699. return this.cacheResult().__iterate(fn, reverse);
  14700. }
  14701. var iterations = 0;
  14702. iterable.__iterate(function(v, k, c)
  14703. {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
  14704. );
  14705. return iterations;
  14706. };
  14707. takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  14708. if (reverse) {
  14709. return this.cacheResult().__iterator(type, reverse);
  14710. }
  14711. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  14712. var iterating = true;
  14713. return new Iterator(function() {
  14714. if (!iterating) {
  14715. return iteratorDone();
  14716. }
  14717. var step = iterator.next();
  14718. if (step.done) {
  14719. return step;
  14720. }
  14721. var entry = step.value;
  14722. var k = entry[0];
  14723. var v = entry[1];
  14724. if (!predicate.call(context, v, k, this$0)) {
  14725. iterating = false;
  14726. return iteratorDone();
  14727. }
  14728. return type === ITERATE_ENTRIES ? step :
  14729. iteratorValue(type, k, v, step);
  14730. });
  14731. };
  14732. return takeSequence;
  14733. }
  14734. function skipWhileFactory(iterable, predicate, context, useKeys) {
  14735. var skipSequence = makeSequence(iterable);
  14736. skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  14737. if (reverse) {
  14738. return this.cacheResult().__iterate(fn, reverse);
  14739. }
  14740. var isSkipping = true;
  14741. var iterations = 0;
  14742. iterable.__iterate(function(v, k, c) {
  14743. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  14744. iterations++;
  14745. return fn(v, useKeys ? k : iterations - 1, this$0);
  14746. }
  14747. });
  14748. return iterations;
  14749. };
  14750. skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  14751. if (reverse) {
  14752. return this.cacheResult().__iterator(type, reverse);
  14753. }
  14754. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  14755. var skipping = true;
  14756. var iterations = 0;
  14757. return new Iterator(function() {
  14758. var step, k, v;
  14759. do {
  14760. step = iterator.next();
  14761. if (step.done) {
  14762. if (useKeys || type === ITERATE_VALUES) {
  14763. return step;
  14764. } else if (type === ITERATE_KEYS) {
  14765. return iteratorValue(type, iterations++, undefined, step);
  14766. } else {
  14767. return iteratorValue(type, iterations++, step.value[1], step);
  14768. }
  14769. }
  14770. var entry = step.value;
  14771. k = entry[0];
  14772. v = entry[1];
  14773. skipping && (skipping = predicate.call(context, v, k, this$0));
  14774. } while (skipping);
  14775. return type === ITERATE_ENTRIES ? step :
  14776. iteratorValue(type, k, v, step);
  14777. });
  14778. };
  14779. return skipSequence;
  14780. }
  14781. function concatFactory(iterable, values) {
  14782. var isKeyedIterable = isKeyed(iterable);
  14783. var iters = [iterable].concat(values).map(function(v ) {
  14784. if (!isIterable(v)) {
  14785. v = isKeyedIterable ?
  14786. keyedSeqFromValue(v) :
  14787. indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  14788. } else if (isKeyedIterable) {
  14789. v = KeyedIterable(v);
  14790. }
  14791. return v;
  14792. }).filter(function(v ) {return v.size !== 0});
  14793. if (iters.length === 0) {
  14794. return iterable;
  14795. }
  14796. if (iters.length === 1) {
  14797. var singleton = iters[0];
  14798. if (singleton === iterable ||
  14799. isKeyedIterable && isKeyed(singleton) ||
  14800. isIndexed(iterable) && isIndexed(singleton)) {
  14801. return singleton;
  14802. }
  14803. }
  14804. var concatSeq = new ArraySeq(iters);
  14805. if (isKeyedIterable) {
  14806. concatSeq = concatSeq.toKeyedSeq();
  14807. } else if (!isIndexed(iterable)) {
  14808. concatSeq = concatSeq.toSetSeq();
  14809. }
  14810. concatSeq = concatSeq.flatten(true);
  14811. concatSeq.size = iters.reduce(
  14812. function(sum, seq) {
  14813. if (sum !== undefined) {
  14814. var size = seq.size;
  14815. if (size !== undefined) {
  14816. return sum + size;
  14817. }
  14818. }
  14819. },
  14820. 0
  14821. );
  14822. return concatSeq;
  14823. }
  14824. function flattenFactory(iterable, depth, useKeys) {
  14825. var flatSequence = makeSequence(iterable);
  14826. flatSequence.__iterateUncached = function(fn, reverse) {
  14827. var iterations = 0;
  14828. var stopped = false;
  14829. function flatDeep(iter, currentDepth) {var this$0 = this;
  14830. iter.__iterate(function(v, k) {
  14831. if ((!depth || currentDepth < depth) && isIterable(v)) {
  14832. flatDeep(v, currentDepth + 1);
  14833. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  14834. stopped = true;
  14835. }
  14836. return !stopped;
  14837. }, reverse);
  14838. }
  14839. flatDeep(iterable, 0);
  14840. return iterations;
  14841. };
  14842. flatSequence.__iteratorUncached = function(type, reverse) {
  14843. var iterator = iterable.__iterator(type, reverse);
  14844. var stack = [];
  14845. var iterations = 0;
  14846. return new Iterator(function() {
  14847. while (iterator) {
  14848. var step = iterator.next();
  14849. if (step.done !== false) {
  14850. iterator = stack.pop();
  14851. continue;
  14852. }
  14853. var v = step.value;
  14854. if (type === ITERATE_ENTRIES) {
  14855. v = v[1];
  14856. }
  14857. if ((!depth || stack.length < depth) && isIterable(v)) {
  14858. stack.push(iterator);
  14859. iterator = v.__iterator(type, reverse);
  14860. } else {
  14861. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  14862. }
  14863. }
  14864. return iteratorDone();
  14865. });
  14866. };
  14867. return flatSequence;
  14868. }
  14869. function flatMapFactory(iterable, mapper, context) {
  14870. var coerce = iterableClass(iterable);
  14871. return iterable.toSeq().map(
  14872. function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
  14873. ).flatten(true);
  14874. }
  14875. function interposeFactory(iterable, separator) {
  14876. var interposedSequence = makeSequence(iterable);
  14877. interposedSequence.size = iterable.size && iterable.size * 2 -1;
  14878. interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  14879. var iterations = 0;
  14880. iterable.__iterate(function(v, k)
  14881. {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
  14882. fn(v, iterations++, this$0) !== false},
  14883. reverse
  14884. );
  14885. return iterations;
  14886. };
  14887. interposedSequence.__iteratorUncached = function(type, reverse) {
  14888. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  14889. var iterations = 0;
  14890. var step;
  14891. return new Iterator(function() {
  14892. if (!step || iterations % 2) {
  14893. step = iterator.next();
  14894. if (step.done) {
  14895. return step;
  14896. }
  14897. }
  14898. return iterations % 2 ?
  14899. iteratorValue(type, iterations++, separator) :
  14900. iteratorValue(type, iterations++, step.value, step);
  14901. });
  14902. };
  14903. return interposedSequence;
  14904. }
  14905. function sortFactory(iterable, comparator, mapper) {
  14906. if (!comparator) {
  14907. comparator = defaultComparator;
  14908. }
  14909. var isKeyedIterable = isKeyed(iterable);
  14910. var index = 0;
  14911. var entries = iterable.toSeq().map(
  14912. function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
  14913. ).toArray();
  14914. entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
  14915. isKeyedIterable ?
  14916. function(v, i) { entries[i].length = 2; } :
  14917. function(v, i) { entries[i] = v[1]; }
  14918. );
  14919. return isKeyedIterable ? KeyedSeq(entries) :
  14920. isIndexed(iterable) ? IndexedSeq(entries) :
  14921. SetSeq(entries);
  14922. }
  14923. function maxFactory(iterable, comparator, mapper) {
  14924. if (!comparator) {
  14925. comparator = defaultComparator;
  14926. }
  14927. if (mapper) {
  14928. var entry = iterable.toSeq()
  14929. .map(function(v, k) {return [v, mapper(v, k, iterable)]})
  14930. .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
  14931. return entry && entry[0];
  14932. } else {
  14933. return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
  14934. }
  14935. }
  14936. function maxCompare(comparator, a, b) {
  14937. var comp = comparator(b, a);
  14938. // b is considered the new max if the comparator declares them equal, but
  14939. // they are not equal and b is in fact a nullish value.
  14940. return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
  14941. }
  14942. function zipWithFactory(keyIter, zipper, iters) {
  14943. var zipSequence = makeSequence(keyIter);
  14944. zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
  14945. // Note: this a generic base implementation of __iterate in terms of
  14946. // __iterator which may be more generically useful in the future.
  14947. zipSequence.__iterate = function(fn, reverse) {
  14948. /* generic:
  14949. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  14950. var step;
  14951. var iterations = 0;
  14952. while (!(step = iterator.next()).done) {
  14953. iterations++;
  14954. if (fn(step.value[1], step.value[0], this) === false) {
  14955. break;
  14956. }
  14957. }
  14958. return iterations;
  14959. */
  14960. // indexed:
  14961. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  14962. var step;
  14963. var iterations = 0;
  14964. while (!(step = iterator.next()).done) {
  14965. if (fn(step.value, iterations++, this) === false) {
  14966. break;
  14967. }
  14968. }
  14969. return iterations;
  14970. };
  14971. zipSequence.__iteratorUncached = function(type, reverse) {
  14972. var iterators = iters.map(function(i )
  14973. {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
  14974. );
  14975. var iterations = 0;
  14976. var isDone = false;
  14977. return new Iterator(function() {
  14978. var steps;
  14979. if (!isDone) {
  14980. steps = iterators.map(function(i ) {return i.next()});
  14981. isDone = steps.some(function(s ) {return s.done});
  14982. }
  14983. if (isDone) {
  14984. return iteratorDone();
  14985. }
  14986. return iteratorValue(
  14987. type,
  14988. iterations++,
  14989. zipper.apply(null, steps.map(function(s ) {return s.value}))
  14990. );
  14991. });
  14992. };
  14993. return zipSequence
  14994. }
  14995. // #pragma Helper Functions
  14996. function reify(iter, seq) {
  14997. return isSeq(iter) ? seq : iter.constructor(seq);
  14998. }
  14999. function validateEntry(entry) {
  15000. if (entry !== Object(entry)) {
  15001. throw new TypeError('Expected [K, V] tuple: ' + entry);
  15002. }
  15003. }
  15004. function resolveSize(iter) {
  15005. assertNotInfinite(iter.size);
  15006. return ensureSize(iter);
  15007. }
  15008. function iterableClass(iterable) {
  15009. return isKeyed(iterable) ? KeyedIterable :
  15010. isIndexed(iterable) ? IndexedIterable :
  15011. SetIterable;
  15012. }
  15013. function makeSequence(iterable) {
  15014. return Object.create(
  15015. (
  15016. isKeyed(iterable) ? KeyedSeq :
  15017. isIndexed(iterable) ? IndexedSeq :
  15018. SetSeq
  15019. ).prototype
  15020. );
  15021. }
  15022. function cacheResultThrough() {
  15023. if (this._iter.cacheResult) {
  15024. this._iter.cacheResult();
  15025. this.size = this._iter.size;
  15026. return this;
  15027. } else {
  15028. return Seq.prototype.cacheResult.call(this);
  15029. }
  15030. }
  15031. function defaultComparator(a, b) {
  15032. return a > b ? 1 : a < b ? -1 : 0;
  15033. }
  15034. function forceIterator(keyPath) {
  15035. var iter = getIterator(keyPath);
  15036. if (!iter) {
  15037. // Array might not be iterable in this environment, so we need a fallback
  15038. // to our wrapped type.
  15039. if (!isArrayLike(keyPath)) {
  15040. throw new TypeError('Expected iterable or array-like: ' + keyPath);
  15041. }
  15042. iter = getIterator(Iterable(keyPath));
  15043. }
  15044. return iter;
  15045. }
  15046. createClass(Record, KeyedCollection);
  15047. function Record(defaultValues, name) {
  15048. var hasInitialized;
  15049. var RecordType = function Record(values) {
  15050. if (values instanceof RecordType) {
  15051. return values;
  15052. }
  15053. if (!(this instanceof RecordType)) {
  15054. return new RecordType(values);
  15055. }
  15056. if (!hasInitialized) {
  15057. hasInitialized = true;
  15058. var keys = Object.keys(defaultValues);
  15059. setProps(RecordTypePrototype, keys);
  15060. RecordTypePrototype.size = keys.length;
  15061. RecordTypePrototype._name = name;
  15062. RecordTypePrototype._keys = keys;
  15063. RecordTypePrototype._defaultValues = defaultValues;
  15064. }
  15065. this._map = Map(values);
  15066. };
  15067. var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
  15068. RecordTypePrototype.constructor = RecordType;
  15069. return RecordType;
  15070. }
  15071. Record.prototype.toString = function() {
  15072. return this.__toString(recordName(this) + ' {', '}');
  15073. };
  15074. // @pragma Access
  15075. Record.prototype.has = function(k) {
  15076. return this._defaultValues.hasOwnProperty(k);
  15077. };
  15078. Record.prototype.get = function(k, notSetValue) {
  15079. if (!this.has(k)) {
  15080. return notSetValue;
  15081. }
  15082. var defaultVal = this._defaultValues[k];
  15083. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  15084. };
  15085. // @pragma Modification
  15086. Record.prototype.clear = function() {
  15087. if (this.__ownerID) {
  15088. this._map && this._map.clear();
  15089. return this;
  15090. }
  15091. var RecordType = this.constructor;
  15092. return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
  15093. };
  15094. Record.prototype.set = function(k, v) {
  15095. if (!this.has(k)) {
  15096. throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
  15097. }
  15098. var newMap = this._map && this._map.set(k, v);
  15099. if (this.__ownerID || newMap === this._map) {
  15100. return this;
  15101. }
  15102. return makeRecord(this, newMap);
  15103. };
  15104. Record.prototype.remove = function(k) {
  15105. if (!this.has(k)) {
  15106. return this;
  15107. }
  15108. var newMap = this._map && this._map.remove(k);
  15109. if (this.__ownerID || newMap === this._map) {
  15110. return this;
  15111. }
  15112. return makeRecord(this, newMap);
  15113. };
  15114. Record.prototype.wasAltered = function() {
  15115. return this._map.wasAltered();
  15116. };
  15117. Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
  15118. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
  15119. };
  15120. Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  15121. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
  15122. };
  15123. Record.prototype.__ensureOwner = function(ownerID) {
  15124. if (ownerID === this.__ownerID) {
  15125. return this;
  15126. }
  15127. var newMap = this._map && this._map.__ensureOwner(ownerID);
  15128. if (!ownerID) {
  15129. this.__ownerID = ownerID;
  15130. this._map = newMap;
  15131. return this;
  15132. }
  15133. return makeRecord(this, newMap, ownerID);
  15134. };
  15135. var RecordPrototype = Record.prototype;
  15136. RecordPrototype[DELETE] = RecordPrototype.remove;
  15137. RecordPrototype.deleteIn =
  15138. RecordPrototype.removeIn = MapPrototype.removeIn;
  15139. RecordPrototype.merge = MapPrototype.merge;
  15140. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  15141. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  15142. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  15143. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  15144. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  15145. RecordPrototype.setIn = MapPrototype.setIn;
  15146. RecordPrototype.update = MapPrototype.update;
  15147. RecordPrototype.updateIn = MapPrototype.updateIn;
  15148. RecordPrototype.withMutations = MapPrototype.withMutations;
  15149. RecordPrototype.asMutable = MapPrototype.asMutable;
  15150. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  15151. function makeRecord(likeRecord, map, ownerID) {
  15152. var record = Object.create(Object.getPrototypeOf(likeRecord));
  15153. record._map = map;
  15154. record.__ownerID = ownerID;
  15155. return record;
  15156. }
  15157. function recordName(record) {
  15158. return record._name || record.constructor.name || 'Record';
  15159. }
  15160. function setProps(prototype, names) {
  15161. try {
  15162. names.forEach(setProp.bind(undefined, prototype));
  15163. } catch (error) {
  15164. // Object.defineProperty failed. Probably IE8.
  15165. }
  15166. }
  15167. function setProp(prototype, name) {
  15168. Object.defineProperty(prototype, name, {
  15169. get: function() {
  15170. return this.get(name);
  15171. },
  15172. set: function(value) {
  15173. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  15174. this.set(name, value);
  15175. }
  15176. });
  15177. }
  15178. createClass(Set, SetCollection);
  15179. // @pragma Construction
  15180. function Set(value) {
  15181. return value === null || value === undefined ? emptySet() :
  15182. isSet(value) && !isOrdered(value) ? value :
  15183. emptySet().withMutations(function(set ) {
  15184. var iter = SetIterable(value);
  15185. assertNotInfinite(iter.size);
  15186. iter.forEach(function(v ) {return set.add(v)});
  15187. });
  15188. }
  15189. Set.of = function(/*...values*/) {
  15190. return this(arguments);
  15191. };
  15192. Set.fromKeys = function(value) {
  15193. return this(KeyedIterable(value).keySeq());
  15194. };
  15195. Set.prototype.toString = function() {
  15196. return this.__toString('Set {', '}');
  15197. };
  15198. // @pragma Access
  15199. Set.prototype.has = function(value) {
  15200. return this._map.has(value);
  15201. };
  15202. // @pragma Modification
  15203. Set.prototype.add = function(value) {
  15204. return updateSet(this, this._map.set(value, true));
  15205. };
  15206. Set.prototype.remove = function(value) {
  15207. return updateSet(this, this._map.remove(value));
  15208. };
  15209. Set.prototype.clear = function() {
  15210. return updateSet(this, this._map.clear());
  15211. };
  15212. // @pragma Composition
  15213. Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
  15214. iters = iters.filter(function(x ) {return x.size !== 0});
  15215. if (iters.length === 0) {
  15216. return this;
  15217. }
  15218. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  15219. return this.constructor(iters[0]);
  15220. }
  15221. return this.withMutations(function(set ) {
  15222. for (var ii = 0; ii < iters.length; ii++) {
  15223. SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
  15224. }
  15225. });
  15226. };
  15227. Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
  15228. if (iters.length === 0) {
  15229. return this;
  15230. }
  15231. iters = iters.map(function(iter ) {return SetIterable(iter)});
  15232. var originalSet = this;
  15233. return this.withMutations(function(set ) {
  15234. originalSet.forEach(function(value ) {
  15235. if (!iters.every(function(iter ) {return iter.includes(value)})) {
  15236. set.remove(value);
  15237. }
  15238. });
  15239. });
  15240. };
  15241. Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
  15242. if (iters.length === 0) {
  15243. return this;
  15244. }
  15245. iters = iters.map(function(iter ) {return SetIterable(iter)});
  15246. var originalSet = this;
  15247. return this.withMutations(function(set ) {
  15248. originalSet.forEach(function(value ) {
  15249. if (iters.some(function(iter ) {return iter.includes(value)})) {
  15250. set.remove(value);
  15251. }
  15252. });
  15253. });
  15254. };
  15255. Set.prototype.merge = function() {
  15256. return this.union.apply(this, arguments);
  15257. };
  15258. Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  15259. return this.union.apply(this, iters);
  15260. };
  15261. Set.prototype.sort = function(comparator) {
  15262. // Late binding
  15263. return OrderedSet(sortFactory(this, comparator));
  15264. };
  15265. Set.prototype.sortBy = function(mapper, comparator) {
  15266. // Late binding
  15267. return OrderedSet(sortFactory(this, comparator, mapper));
  15268. };
  15269. Set.prototype.wasAltered = function() {
  15270. return this._map.wasAltered();
  15271. };
  15272. Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  15273. return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
  15274. };
  15275. Set.prototype.__iterator = function(type, reverse) {
  15276. return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
  15277. };
  15278. Set.prototype.__ensureOwner = function(ownerID) {
  15279. if (ownerID === this.__ownerID) {
  15280. return this;
  15281. }
  15282. var newMap = this._map.__ensureOwner(ownerID);
  15283. if (!ownerID) {
  15284. this.__ownerID = ownerID;
  15285. this._map = newMap;
  15286. return this;
  15287. }
  15288. return this.__make(newMap, ownerID);
  15289. };
  15290. function isSet(maybeSet) {
  15291. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  15292. }
  15293. Set.isSet = isSet;
  15294. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  15295. var SetPrototype = Set.prototype;
  15296. SetPrototype[IS_SET_SENTINEL] = true;
  15297. SetPrototype[DELETE] = SetPrototype.remove;
  15298. SetPrototype.mergeDeep = SetPrototype.merge;
  15299. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  15300. SetPrototype.withMutations = MapPrototype.withMutations;
  15301. SetPrototype.asMutable = MapPrototype.asMutable;
  15302. SetPrototype.asImmutable = MapPrototype.asImmutable;
  15303. SetPrototype.__empty = emptySet;
  15304. SetPrototype.__make = makeSet;
  15305. function updateSet(set, newMap) {
  15306. if (set.__ownerID) {
  15307. set.size = newMap.size;
  15308. set._map = newMap;
  15309. return set;
  15310. }
  15311. return newMap === set._map ? set :
  15312. newMap.size === 0 ? set.__empty() :
  15313. set.__make(newMap);
  15314. }
  15315. function makeSet(map, ownerID) {
  15316. var set = Object.create(SetPrototype);
  15317. set.size = map ? map.size : 0;
  15318. set._map = map;
  15319. set.__ownerID = ownerID;
  15320. return set;
  15321. }
  15322. var EMPTY_SET;
  15323. function emptySet() {
  15324. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  15325. }
  15326. createClass(OrderedSet, Set);
  15327. // @pragma Construction
  15328. function OrderedSet(value) {
  15329. return value === null || value === undefined ? emptyOrderedSet() :
  15330. isOrderedSet(value) ? value :
  15331. emptyOrderedSet().withMutations(function(set ) {
  15332. var iter = SetIterable(value);
  15333. assertNotInfinite(iter.size);
  15334. iter.forEach(function(v ) {return set.add(v)});
  15335. });
  15336. }
  15337. OrderedSet.of = function(/*...values*/) {
  15338. return this(arguments);
  15339. };
  15340. OrderedSet.fromKeys = function(value) {
  15341. return this(KeyedIterable(value).keySeq());
  15342. };
  15343. OrderedSet.prototype.toString = function() {
  15344. return this.__toString('OrderedSet {', '}');
  15345. };
  15346. function isOrderedSet(maybeOrderedSet) {
  15347. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  15348. }
  15349. OrderedSet.isOrderedSet = isOrderedSet;
  15350. var OrderedSetPrototype = OrderedSet.prototype;
  15351. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  15352. OrderedSetPrototype.__empty = emptyOrderedSet;
  15353. OrderedSetPrototype.__make = makeOrderedSet;
  15354. function makeOrderedSet(map, ownerID) {
  15355. var set = Object.create(OrderedSetPrototype);
  15356. set.size = map ? map.size : 0;
  15357. set._map = map;
  15358. set.__ownerID = ownerID;
  15359. return set;
  15360. }
  15361. var EMPTY_ORDERED_SET;
  15362. function emptyOrderedSet() {
  15363. return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
  15364. }
  15365. createClass(Stack, IndexedCollection);
  15366. // @pragma Construction
  15367. function Stack(value) {
  15368. return value === null || value === undefined ? emptyStack() :
  15369. isStack(value) ? value :
  15370. emptyStack().unshiftAll(value);
  15371. }
  15372. Stack.of = function(/*...values*/) {
  15373. return this(arguments);
  15374. };
  15375. Stack.prototype.toString = function() {
  15376. return this.__toString('Stack [', ']');
  15377. };
  15378. // @pragma Access
  15379. Stack.prototype.get = function(index, notSetValue) {
  15380. var head = this._head;
  15381. index = wrapIndex(this, index);
  15382. while (head && index--) {
  15383. head = head.next;
  15384. }
  15385. return head ? head.value : notSetValue;
  15386. };
  15387. Stack.prototype.peek = function() {
  15388. return this._head && this._head.value;
  15389. };
  15390. // @pragma Modification
  15391. Stack.prototype.push = function(/*...values*/) {
  15392. if (arguments.length === 0) {
  15393. return this;
  15394. }
  15395. var newSize = this.size + arguments.length;
  15396. var head = this._head;
  15397. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  15398. head = {
  15399. value: arguments[ii],
  15400. next: head
  15401. };
  15402. }
  15403. if (this.__ownerID) {
  15404. this.size = newSize;
  15405. this._head = head;
  15406. this.__hash = undefined;
  15407. this.__altered = true;
  15408. return this;
  15409. }
  15410. return makeStack(newSize, head);
  15411. };
  15412. Stack.prototype.pushAll = function(iter) {
  15413. iter = IndexedIterable(iter);
  15414. if (iter.size === 0) {
  15415. return this;
  15416. }
  15417. assertNotInfinite(iter.size);
  15418. var newSize = this.size;
  15419. var head = this._head;
  15420. iter.reverse().forEach(function(value ) {
  15421. newSize++;
  15422. head = {
  15423. value: value,
  15424. next: head
  15425. };
  15426. });
  15427. if (this.__ownerID) {
  15428. this.size = newSize;
  15429. this._head = head;
  15430. this.__hash = undefined;
  15431. this.__altered = true;
  15432. return this;
  15433. }
  15434. return makeStack(newSize, head);
  15435. };
  15436. Stack.prototype.pop = function() {
  15437. return this.slice(1);
  15438. };
  15439. Stack.prototype.unshift = function(/*...values*/) {
  15440. return this.push.apply(this, arguments);
  15441. };
  15442. Stack.prototype.unshiftAll = function(iter) {
  15443. return this.pushAll(iter);
  15444. };
  15445. Stack.prototype.shift = function() {
  15446. return this.pop.apply(this, arguments);
  15447. };
  15448. Stack.prototype.clear = function() {
  15449. if (this.size === 0) {
  15450. return this;
  15451. }
  15452. if (this.__ownerID) {
  15453. this.size = 0;
  15454. this._head = undefined;
  15455. this.__hash = undefined;
  15456. this.__altered = true;
  15457. return this;
  15458. }
  15459. return emptyStack();
  15460. };
  15461. Stack.prototype.slice = function(begin, end) {
  15462. if (wholeSlice(begin, end, this.size)) {
  15463. return this;
  15464. }
  15465. var resolvedBegin = resolveBegin(begin, this.size);
  15466. var resolvedEnd = resolveEnd(end, this.size);
  15467. if (resolvedEnd !== this.size) {
  15468. // super.slice(begin, end);
  15469. return IndexedCollection.prototype.slice.call(this, begin, end);
  15470. }
  15471. var newSize = this.size - resolvedBegin;
  15472. var head = this._head;
  15473. while (resolvedBegin--) {
  15474. head = head.next;
  15475. }
  15476. if (this.__ownerID) {
  15477. this.size = newSize;
  15478. this._head = head;
  15479. this.__hash = undefined;
  15480. this.__altered = true;
  15481. return this;
  15482. }
  15483. return makeStack(newSize, head);
  15484. };
  15485. // @pragma Mutability
  15486. Stack.prototype.__ensureOwner = function(ownerID) {
  15487. if (ownerID === this.__ownerID) {
  15488. return this;
  15489. }
  15490. if (!ownerID) {
  15491. this.__ownerID = ownerID;
  15492. this.__altered = false;
  15493. return this;
  15494. }
  15495. return makeStack(this.size, this._head, ownerID, this.__hash);
  15496. };
  15497. // @pragma Iteration
  15498. Stack.prototype.__iterate = function(fn, reverse) {
  15499. if (reverse) {
  15500. return this.reverse().__iterate(fn);
  15501. }
  15502. var iterations = 0;
  15503. var node = this._head;
  15504. while (node) {
  15505. if (fn(node.value, iterations++, this) === false) {
  15506. break;
  15507. }
  15508. node = node.next;
  15509. }
  15510. return iterations;
  15511. };
  15512. Stack.prototype.__iterator = function(type, reverse) {
  15513. if (reverse) {
  15514. return this.reverse().__iterator(type);
  15515. }
  15516. var iterations = 0;
  15517. var node = this._head;
  15518. return new Iterator(function() {
  15519. if (node) {
  15520. var value = node.value;
  15521. node = node.next;
  15522. return iteratorValue(type, iterations++, value);
  15523. }
  15524. return iteratorDone();
  15525. });
  15526. };
  15527. function isStack(maybeStack) {
  15528. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  15529. }
  15530. Stack.isStack = isStack;
  15531. var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  15532. var StackPrototype = Stack.prototype;
  15533. StackPrototype[IS_STACK_SENTINEL] = true;
  15534. StackPrototype.withMutations = MapPrototype.withMutations;
  15535. StackPrototype.asMutable = MapPrototype.asMutable;
  15536. StackPrototype.asImmutable = MapPrototype.asImmutable;
  15537. StackPrototype.wasAltered = MapPrototype.wasAltered;
  15538. function makeStack(size, head, ownerID, hash) {
  15539. var map = Object.create(StackPrototype);
  15540. map.size = size;
  15541. map._head = head;
  15542. map.__ownerID = ownerID;
  15543. map.__hash = hash;
  15544. map.__altered = false;
  15545. return map;
  15546. }
  15547. var EMPTY_STACK;
  15548. function emptyStack() {
  15549. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  15550. }
  15551. /**
  15552. * Contributes additional methods to a constructor
  15553. */
  15554. function mixin(ctor, methods) {
  15555. var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
  15556. Object.keys(methods).forEach(keyCopier);
  15557. Object.getOwnPropertySymbols &&
  15558. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  15559. return ctor;
  15560. }
  15561. Iterable.Iterator = Iterator;
  15562. mixin(Iterable, {
  15563. // ### Conversion to other types
  15564. toArray: function() {
  15565. assertNotInfinite(this.size);
  15566. var array = new Array(this.size || 0);
  15567. this.valueSeq().__iterate(function(v, i) { array[i] = v; });
  15568. return array;
  15569. },
  15570. toIndexedSeq: function() {
  15571. return new ToIndexedSequence(this);
  15572. },
  15573. toJS: function() {
  15574. return this.toSeq().map(
  15575. function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
  15576. ).__toJS();
  15577. },
  15578. toJSON: function() {
  15579. return this.toSeq().map(
  15580. function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
  15581. ).__toJS();
  15582. },
  15583. toKeyedSeq: function() {
  15584. return new ToKeyedSequence(this, true);
  15585. },
  15586. toMap: function() {
  15587. // Use Late Binding here to solve the circular dependency.
  15588. return Map(this.toKeyedSeq());
  15589. },
  15590. toObject: function() {
  15591. assertNotInfinite(this.size);
  15592. var object = {};
  15593. this.__iterate(function(v, k) { object[k] = v; });
  15594. return object;
  15595. },
  15596. toOrderedMap: function() {
  15597. // Use Late Binding here to solve the circular dependency.
  15598. return OrderedMap(this.toKeyedSeq());
  15599. },
  15600. toOrderedSet: function() {
  15601. // Use Late Binding here to solve the circular dependency.
  15602. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  15603. },
  15604. toSet: function() {
  15605. // Use Late Binding here to solve the circular dependency.
  15606. return Set(isKeyed(this) ? this.valueSeq() : this);
  15607. },
  15608. toSetSeq: function() {
  15609. return new ToSetSequence(this);
  15610. },
  15611. toSeq: function() {
  15612. return isIndexed(this) ? this.toIndexedSeq() :
  15613. isKeyed(this) ? this.toKeyedSeq() :
  15614. this.toSetSeq();
  15615. },
  15616. toStack: function() {
  15617. // Use Late Binding here to solve the circular dependency.
  15618. return Stack(isKeyed(this) ? this.valueSeq() : this);
  15619. },
  15620. toList: function() {
  15621. // Use Late Binding here to solve the circular dependency.
  15622. return List(isKeyed(this) ? this.valueSeq() : this);
  15623. },
  15624. // ### Common JavaScript methods and properties
  15625. toString: function() {
  15626. return '[Iterable]';
  15627. },
  15628. __toString: function(head, tail) {
  15629. if (this.size === 0) {
  15630. return head + tail;
  15631. }
  15632. return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
  15633. },
  15634. // ### ES6 Collection methods (ES6 Array and Map)
  15635. concat: function() {var values = SLICE$0.call(arguments, 0);
  15636. return reify(this, concatFactory(this, values));
  15637. },
  15638. includes: function(searchValue) {
  15639. return this.some(function(value ) {return is(value, searchValue)});
  15640. },
  15641. entries: function() {
  15642. return this.__iterator(ITERATE_ENTRIES);
  15643. },
  15644. every: function(predicate, context) {
  15645. assertNotInfinite(this.size);
  15646. var returnValue = true;
  15647. this.__iterate(function(v, k, c) {
  15648. if (!predicate.call(context, v, k, c)) {
  15649. returnValue = false;
  15650. return false;
  15651. }
  15652. });
  15653. return returnValue;
  15654. },
  15655. filter: function(predicate, context) {
  15656. return reify(this, filterFactory(this, predicate, context, true));
  15657. },
  15658. find: function(predicate, context, notSetValue) {
  15659. var entry = this.findEntry(predicate, context);
  15660. return entry ? entry[1] : notSetValue;
  15661. },
  15662. findEntry: function(predicate, context) {
  15663. var found;
  15664. this.__iterate(function(v, k, c) {
  15665. if (predicate.call(context, v, k, c)) {
  15666. found = [k, v];
  15667. return false;
  15668. }
  15669. });
  15670. return found;
  15671. },
  15672. findLastEntry: function(predicate, context) {
  15673. return this.toSeq().reverse().findEntry(predicate, context);
  15674. },
  15675. forEach: function(sideEffect, context) {
  15676. assertNotInfinite(this.size);
  15677. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  15678. },
  15679. join: function(separator) {
  15680. assertNotInfinite(this.size);
  15681. separator = separator !== undefined ? '' + separator : ',';
  15682. var joined = '';
  15683. var isFirst = true;
  15684. this.__iterate(function(v ) {
  15685. isFirst ? (isFirst = false) : (joined += separator);
  15686. joined += v !== null && v !== undefined ? v.toString() : '';
  15687. });
  15688. return joined;
  15689. },
  15690. keys: function() {
  15691. return this.__iterator(ITERATE_KEYS);
  15692. },
  15693. map: function(mapper, context) {
  15694. return reify(this, mapFactory(this, mapper, context));
  15695. },
  15696. reduce: function(reducer, initialReduction, context) {
  15697. assertNotInfinite(this.size);
  15698. var reduction;
  15699. var useFirst;
  15700. if (arguments.length < 2) {
  15701. useFirst = true;
  15702. } else {
  15703. reduction = initialReduction;
  15704. }
  15705. this.__iterate(function(v, k, c) {
  15706. if (useFirst) {
  15707. useFirst = false;
  15708. reduction = v;
  15709. } else {
  15710. reduction = reducer.call(context, reduction, v, k, c);
  15711. }
  15712. });
  15713. return reduction;
  15714. },
  15715. reduceRight: function(reducer, initialReduction, context) {
  15716. var reversed = this.toKeyedSeq().reverse();
  15717. return reversed.reduce.apply(reversed, arguments);
  15718. },
  15719. reverse: function() {
  15720. return reify(this, reverseFactory(this, true));
  15721. },
  15722. slice: function(begin, end) {
  15723. return reify(this, sliceFactory(this, begin, end, true));
  15724. },
  15725. some: function(predicate, context) {
  15726. return !this.every(not(predicate), context);
  15727. },
  15728. sort: function(comparator) {
  15729. return reify(this, sortFactory(this, comparator));
  15730. },
  15731. values: function() {
  15732. return this.__iterator(ITERATE_VALUES);
  15733. },
  15734. // ### More sequential methods
  15735. butLast: function() {
  15736. return this.slice(0, -1);
  15737. },
  15738. isEmpty: function() {
  15739. return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
  15740. },
  15741. count: function(predicate, context) {
  15742. return ensureSize(
  15743. predicate ? this.toSeq().filter(predicate, context) : this
  15744. );
  15745. },
  15746. countBy: function(grouper, context) {
  15747. return countByFactory(this, grouper, context);
  15748. },
  15749. equals: function(other) {
  15750. return deepEqual(this, other);
  15751. },
  15752. entrySeq: function() {
  15753. var iterable = this;
  15754. if (iterable._cache) {
  15755. // We cache as an entries array, so we can just return the cache!
  15756. return new ArraySeq(iterable._cache);
  15757. }
  15758. var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
  15759. entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
  15760. return entriesSequence;
  15761. },
  15762. filterNot: function(predicate, context) {
  15763. return this.filter(not(predicate), context);
  15764. },
  15765. findLast: function(predicate, context, notSetValue) {
  15766. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  15767. },
  15768. first: function() {
  15769. return this.find(returnTrue);
  15770. },
  15771. flatMap: function(mapper, context) {
  15772. return reify(this, flatMapFactory(this, mapper, context));
  15773. },
  15774. flatten: function(depth) {
  15775. return reify(this, flattenFactory(this, depth, true));
  15776. },
  15777. fromEntrySeq: function() {
  15778. return new FromEntriesSequence(this);
  15779. },
  15780. get: function(searchKey, notSetValue) {
  15781. return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
  15782. },
  15783. getIn: function(searchKeyPath, notSetValue) {
  15784. var nested = this;
  15785. // Note: in an ES6 environment, we would prefer:
  15786. // for (var key of searchKeyPath) {
  15787. var iter = forceIterator(searchKeyPath);
  15788. var step;
  15789. while (!(step = iter.next()).done) {
  15790. var key = step.value;
  15791. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  15792. if (nested === NOT_SET) {
  15793. return notSetValue;
  15794. }
  15795. }
  15796. return nested;
  15797. },
  15798. groupBy: function(grouper, context) {
  15799. return groupByFactory(this, grouper, context);
  15800. },
  15801. has: function(searchKey) {
  15802. return this.get(searchKey, NOT_SET) !== NOT_SET;
  15803. },
  15804. hasIn: function(searchKeyPath) {
  15805. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  15806. },
  15807. isSubset: function(iter) {
  15808. iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
  15809. return this.every(function(value ) {return iter.includes(value)});
  15810. },
  15811. isSuperset: function(iter) {
  15812. iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
  15813. return iter.isSubset(this);
  15814. },
  15815. keySeq: function() {
  15816. return this.toSeq().map(keyMapper).toIndexedSeq();
  15817. },
  15818. last: function() {
  15819. return this.toSeq().reverse().first();
  15820. },
  15821. max: function(comparator) {
  15822. return maxFactory(this, comparator);
  15823. },
  15824. maxBy: function(mapper, comparator) {
  15825. return maxFactory(this, comparator, mapper);
  15826. },
  15827. min: function(comparator) {
  15828. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
  15829. },
  15830. minBy: function(mapper, comparator) {
  15831. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
  15832. },
  15833. rest: function() {
  15834. return this.slice(1);
  15835. },
  15836. skip: function(amount) {
  15837. return this.slice(Math.max(0, amount));
  15838. },
  15839. skipLast: function(amount) {
  15840. return reify(this, this.toSeq().reverse().skip(amount).reverse());
  15841. },
  15842. skipWhile: function(predicate, context) {
  15843. return reify(this, skipWhileFactory(this, predicate, context, true));
  15844. },
  15845. skipUntil: function(predicate, context) {
  15846. return this.skipWhile(not(predicate), context);
  15847. },
  15848. sortBy: function(mapper, comparator) {
  15849. return reify(this, sortFactory(this, comparator, mapper));
  15850. },
  15851. take: function(amount) {
  15852. return this.slice(0, Math.max(0, amount));
  15853. },
  15854. takeLast: function(amount) {
  15855. return reify(this, this.toSeq().reverse().take(amount).reverse());
  15856. },
  15857. takeWhile: function(predicate, context) {
  15858. return reify(this, takeWhileFactory(this, predicate, context));
  15859. },
  15860. takeUntil: function(predicate, context) {
  15861. return this.takeWhile(not(predicate), context);
  15862. },
  15863. valueSeq: function() {
  15864. return this.toIndexedSeq();
  15865. },
  15866. // ### Hashable Object
  15867. hashCode: function() {
  15868. return this.__hash || (this.__hash = hashIterable(this));
  15869. }
  15870. // ### Internal
  15871. // abstract __iterate(fn, reverse)
  15872. // abstract __iterator(type, reverse)
  15873. });
  15874. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  15875. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  15876. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  15877. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  15878. var IterablePrototype = Iterable.prototype;
  15879. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  15880. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  15881. IterablePrototype.__toJS = IterablePrototype.toArray;
  15882. IterablePrototype.__toStringMapper = quoteString;
  15883. IterablePrototype.inspect =
  15884. IterablePrototype.toSource = function() { return this.toString(); };
  15885. IterablePrototype.chain = IterablePrototype.flatMap;
  15886. IterablePrototype.contains = IterablePrototype.includes;
  15887. // Temporary warning about using length
  15888. (function () {
  15889. try {
  15890. Object.defineProperty(IterablePrototype, 'length', {
  15891. get: function () {
  15892. if (!Iterable.noLengthWarning) {
  15893. var stack;
  15894. try {
  15895. throw new Error();
  15896. } catch (error) {
  15897. stack = error.stack;
  15898. }
  15899. if (stack.indexOf('_wrapObject') === -1) {
  15900. console && console.warn && console.warn(
  15901. 'iterable.length has been deprecated, '+
  15902. 'use iterable.size or iterable.count(). '+
  15903. 'This warning will become a silent error in a future version. ' +
  15904. stack
  15905. );
  15906. return this.size;
  15907. }
  15908. }
  15909. }
  15910. });
  15911. } catch (e) {}
  15912. })();
  15913. mixin(KeyedIterable, {
  15914. // ### More sequential methods
  15915. flip: function() {
  15916. return reify(this, flipFactory(this));
  15917. },
  15918. findKey: function(predicate, context) {
  15919. var entry = this.findEntry(predicate, context);
  15920. return entry && entry[0];
  15921. },
  15922. findLastKey: function(predicate, context) {
  15923. return this.toSeq().reverse().findKey(predicate, context);
  15924. },
  15925. keyOf: function(searchValue) {
  15926. return this.findKey(function(value ) {return is(value, searchValue)});
  15927. },
  15928. lastKeyOf: function(searchValue) {
  15929. return this.findLastKey(function(value ) {return is(value, searchValue)});
  15930. },
  15931. mapEntries: function(mapper, context) {var this$0 = this;
  15932. var iterations = 0;
  15933. return reify(this,
  15934. this.toSeq().map(
  15935. function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
  15936. ).fromEntrySeq()
  15937. );
  15938. },
  15939. mapKeys: function(mapper, context) {var this$0 = this;
  15940. return reify(this,
  15941. this.toSeq().flip().map(
  15942. function(k, v) {return mapper.call(context, k, v, this$0)}
  15943. ).flip()
  15944. );
  15945. }
  15946. });
  15947. var KeyedIterablePrototype = KeyedIterable.prototype;
  15948. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  15949. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  15950. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  15951. KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
  15952. mixin(IndexedIterable, {
  15953. // ### Conversion to other types
  15954. toKeyedSeq: function() {
  15955. return new ToKeyedSequence(this, false);
  15956. },
  15957. // ### ES6 Collection methods (ES6 Array and Map)
  15958. filter: function(predicate, context) {
  15959. return reify(this, filterFactory(this, predicate, context, false));
  15960. },
  15961. findIndex: function(predicate, context) {
  15962. var entry = this.findEntry(predicate, context);
  15963. return entry ? entry[0] : -1;
  15964. },
  15965. indexOf: function(searchValue) {
  15966. var key = this.toKeyedSeq().keyOf(searchValue);
  15967. return key === undefined ? -1 : key;
  15968. },
  15969. lastIndexOf: function(searchValue) {
  15970. var key = this.toKeyedSeq().reverse().keyOf(searchValue);
  15971. return key === undefined ? -1 : key;
  15972. // var index =
  15973. // return this.toSeq().reverse().indexOf(searchValue);
  15974. },
  15975. reverse: function() {
  15976. return reify(this, reverseFactory(this, false));
  15977. },
  15978. slice: function(begin, end) {
  15979. return reify(this, sliceFactory(this, begin, end, false));
  15980. },
  15981. splice: function(index, removeNum /*, ...values*/) {
  15982. var numArgs = arguments.length;
  15983. removeNum = Math.max(removeNum | 0, 0);
  15984. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  15985. return this;
  15986. }
  15987. // If index is negative, it should resolve relative to the size of the
  15988. // collection. However size may be expensive to compute if not cached, so
  15989. // only call count() if the number is in fact negative.
  15990. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  15991. var spliced = this.slice(0, index);
  15992. return reify(
  15993. this,
  15994. numArgs === 1 ?
  15995. spliced :
  15996. spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  15997. );
  15998. },
  15999. // ### More collection methods
  16000. findLastIndex: function(predicate, context) {
  16001. var key = this.toKeyedSeq().findLastKey(predicate, context);
  16002. return key === undefined ? -1 : key;
  16003. },
  16004. first: function() {
  16005. return this.get(0);
  16006. },
  16007. flatten: function(depth) {
  16008. return reify(this, flattenFactory(this, depth, false));
  16009. },
  16010. get: function(index, notSetValue) {
  16011. index = wrapIndex(this, index);
  16012. return (index < 0 || (this.size === Infinity ||
  16013. (this.size !== undefined && index > this.size))) ?
  16014. notSetValue :
  16015. this.find(function(_, key) {return key === index}, undefined, notSetValue);
  16016. },
  16017. has: function(index) {
  16018. index = wrapIndex(this, index);
  16019. return index >= 0 && (this.size !== undefined ?
  16020. this.size === Infinity || index < this.size :
  16021. this.indexOf(index) !== -1
  16022. );
  16023. },
  16024. interpose: function(separator) {
  16025. return reify(this, interposeFactory(this, separator));
  16026. },
  16027. interleave: function(/*...iterables*/) {
  16028. var iterables = [this].concat(arrCopy(arguments));
  16029. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  16030. var interleaved = zipped.flatten(true);
  16031. if (zipped.size) {
  16032. interleaved.size = zipped.size * iterables.length;
  16033. }
  16034. return reify(this, interleaved);
  16035. },
  16036. last: function() {
  16037. return this.get(-1);
  16038. },
  16039. skipWhile: function(predicate, context) {
  16040. return reify(this, skipWhileFactory(this, predicate, context, false));
  16041. },
  16042. zip: function(/*, ...iterables */) {
  16043. var iterables = [this].concat(arrCopy(arguments));
  16044. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  16045. },
  16046. zipWith: function(zipper/*, ...iterables */) {
  16047. var iterables = arrCopy(arguments);
  16048. iterables[0] = this;
  16049. return reify(this, zipWithFactory(this, zipper, iterables));
  16050. }
  16051. });
  16052. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  16053. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  16054. mixin(SetIterable, {
  16055. // ### ES6 Collection methods (ES6 Array and Map)
  16056. get: function(value, notSetValue) {
  16057. return this.has(value) ? value : notSetValue;
  16058. },
  16059. includes: function(value) {
  16060. return this.has(value);
  16061. },
  16062. // ### More sequential methods
  16063. keySeq: function() {
  16064. return this.valueSeq();
  16065. }
  16066. });
  16067. SetIterable.prototype.has = IterablePrototype.includes;
  16068. // Mixin subclasses
  16069. mixin(KeyedSeq, KeyedIterable.prototype);
  16070. mixin(IndexedSeq, IndexedIterable.prototype);
  16071. mixin(SetSeq, SetIterable.prototype);
  16072. mixin(KeyedCollection, KeyedIterable.prototype);
  16073. mixin(IndexedCollection, IndexedIterable.prototype);
  16074. mixin(SetCollection, SetIterable.prototype);
  16075. // #pragma Helper functions
  16076. function keyMapper(v, k) {
  16077. return k;
  16078. }
  16079. function entryMapper(v, k) {
  16080. return [k, v];
  16081. }
  16082. function not(predicate) {
  16083. return function() {
  16084. return !predicate.apply(this, arguments);
  16085. }
  16086. }
  16087. function neg(predicate) {
  16088. return function() {
  16089. return -predicate.apply(this, arguments);
  16090. }
  16091. }
  16092. function quoteString(value) {
  16093. return typeof value === 'string' ? JSON.stringify(value) : value;
  16094. }
  16095. function defaultZipper() {
  16096. return arrCopy(arguments);
  16097. }
  16098. function defaultNegComparator(a, b) {
  16099. return a < b ? 1 : a > b ? -1 : 0;
  16100. }
  16101. function hashIterable(iterable) {
  16102. if (iterable.size === Infinity) {
  16103. return 0;
  16104. }
  16105. var ordered = isOrdered(iterable);
  16106. var keyed = isKeyed(iterable);
  16107. var h = ordered ? 1 : 0;
  16108. var size = iterable.__iterate(
  16109. keyed ?
  16110. ordered ?
  16111. function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
  16112. function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
  16113. ordered ?
  16114. function(v ) { h = 31 * h + hash(v) | 0; } :
  16115. function(v ) { h = h + hash(v) | 0; }
  16116. );
  16117. return murmurHashOfSize(size, h);
  16118. }
  16119. function murmurHashOfSize(size, h) {
  16120. h = imul(h, 0xCC9E2D51);
  16121. h = imul(h << 15 | h >>> -15, 0x1B873593);
  16122. h = imul(h << 13 | h >>> -13, 5);
  16123. h = (h + 0xE6546B64 | 0) ^ size;
  16124. h = imul(h ^ h >>> 16, 0x85EBCA6B);
  16125. h = imul(h ^ h >>> 13, 0xC2B2AE35);
  16126. h = smi(h ^ h >>> 16);
  16127. return h;
  16128. }
  16129. function hashMerge(a, b) {
  16130. return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
  16131. }
  16132. var Immutable = {
  16133. Iterable: Iterable,
  16134. Seq: Seq,
  16135. Collection: Collection,
  16136. Map: Map,
  16137. OrderedMap: OrderedMap,
  16138. List: List,
  16139. Stack: Stack,
  16140. Set: Set,
  16141. OrderedSet: OrderedSet,
  16142. Record: Record,
  16143. Range: Range,
  16144. Repeat: Repeat,
  16145. is: is,
  16146. fromJS: fromJS
  16147. };
  16148. return Immutable;
  16149. }));
  16150. });
  16151. var dist$2 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  16152. (function webpackUniversalModuleDefinition(root, factory) {
  16153. module.exports = factory(React__default);
  16154. })(window, function(__WEBPACK_EXTERNAL_MODULE__2__) {
  16155. return /******/ (function(modules) { // webpackBootstrap
  16156. /******/ // The module cache
  16157. /******/ var installedModules = {};
  16158. /******/
  16159. /******/ // The require function
  16160. /******/ function __webpack_require__(moduleId) {
  16161. /******/
  16162. /******/ // Check if module is in cache
  16163. /******/ if(installedModules[moduleId]) {
  16164. /******/ return installedModules[moduleId].exports;
  16165. /******/ }
  16166. /******/ // Create a new module (and put it into the cache)
  16167. /******/ var module = installedModules[moduleId] = {
  16168. /******/ i: moduleId,
  16169. /******/ l: false,
  16170. /******/ exports: {}
  16171. /******/ };
  16172. /******/
  16173. /******/ // Execute the module function
  16174. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  16175. /******/
  16176. /******/ // Flag the module as loaded
  16177. /******/ module.l = true;
  16178. /******/
  16179. /******/ // Return the exports of the module
  16180. /******/ return module.exports;
  16181. /******/ }
  16182. /******/
  16183. /******/
  16184. /******/ // expose the modules object (__webpack_modules__)
  16185. /******/ __webpack_require__.m = modules;
  16186. /******/
  16187. /******/ // expose the module cache
  16188. /******/ __webpack_require__.c = installedModules;
  16189. /******/
  16190. /******/ // define getter function for harmony exports
  16191. /******/ __webpack_require__.d = function(exports, name, getter) {
  16192. /******/ if(!__webpack_require__.o(exports, name)) {
  16193. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  16194. /******/ }
  16195. /******/ };
  16196. /******/
  16197. /******/ // define __esModule on exports
  16198. /******/ __webpack_require__.r = function(exports) {
  16199. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  16200. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  16201. /******/ }
  16202. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  16203. /******/ };
  16204. /******/
  16205. /******/ // create a fake namespace object
  16206. /******/ // mode & 1: value is a module id, require it
  16207. /******/ // mode & 2: merge all properties of value into the ns
  16208. /******/ // mode & 4: return value when already ns object
  16209. /******/ // mode & 8|1: behave like require
  16210. /******/ __webpack_require__.t = function(value, mode) {
  16211. /******/ if(mode & 1) value = __webpack_require__(value);
  16212. /******/ if(mode & 8) return value;
  16213. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  16214. /******/ var ns = Object.create(null);
  16215. /******/ __webpack_require__.r(ns);
  16216. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  16217. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  16218. /******/ return ns;
  16219. /******/ };
  16220. /******/
  16221. /******/ // getDefaultExport function for compatibility with non-harmony modules
  16222. /******/ __webpack_require__.n = function(module) {
  16223. /******/ var getter = module && module.__esModule ?
  16224. /******/ function getDefault() { return module['default']; } :
  16225. /******/ function getModuleExports() { return module; };
  16226. /******/ __webpack_require__.d(getter, 'a', getter);
  16227. /******/ return getter;
  16228. /******/ };
  16229. /******/
  16230. /******/ // Object.prototype.hasOwnProperty.call
  16231. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  16232. /******/
  16233. /******/ // __webpack_public_path__
  16234. /******/ __webpack_require__.p = "/";
  16235. /******/
  16236. /******/
  16237. /******/ // Load entry module and return exports
  16238. /******/ return __webpack_require__(__webpack_require__.s = 20);
  16239. /******/ })
  16240. /************************************************************************/
  16241. /******/ ([
  16242. /* 0 */
  16243. /***/ (function(module, exports, __webpack_require__) {
  16244. Object.defineProperty(exports, "__esModule", {
  16245. value: true
  16246. });
  16247. var compressImage = exports.compressImage = function compressImage(url) {
  16248. var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1280;
  16249. var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 800;
  16250. return new Promise(function (resolve, reject) {
  16251. var image = new Image();
  16252. image.src = url;
  16253. image.onerror = function (error) {
  16254. reject(error);
  16255. };
  16256. image.onload = function () {
  16257. try {
  16258. var compressCanvas = document.createElement('canvas');
  16259. var scale = this.width > width || this.height > height ? this.width > this.height ? width / this.width : height / this.height : 1;
  16260. compressCanvas.width = this.width * scale;
  16261. compressCanvas.height = this.height * scale;
  16262. var canvasContext = compressCanvas.getContext('2d');
  16263. canvasContext.drawImage(this, 0, 0, compressCanvas.width, compressCanvas.height);
  16264. resolve({
  16265. url: compressCanvas.toDataURL('image/png', 1),
  16266. width: compressCanvas.width,
  16267. height: compressCanvas.height
  16268. });
  16269. } catch (error) {
  16270. reject(error);
  16271. }
  16272. };
  16273. });
  16274. };
  16275. /***/ }),
  16276. /* 1 */
  16277. /***/ (function(module, exports, __webpack_require__) {
  16278. Object.defineProperty(exports, "__esModule", {
  16279. value: true
  16280. });
  16281. var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
  16282. if (isNaN(window.__BRAFT_MM_UNIQUE_INDEX__)) {
  16283. window.__BRAFT_MM_UNIQUE_INDEX__ = 1;
  16284. } else {
  16285. window.__BRAFT_MM_UNIQUE_INDEX__ += 1;
  16286. }
  16287. return window.__BRAFT_MM_UNIQUE_INDEX__;
  16288. };
  16289. /***/ }),
  16290. /* 2 */
  16291. /***/ (function(module, exports) {
  16292. module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
  16293. /***/ }),
  16294. /* 3 */
  16295. /***/ (function(module, exports, __webpack_require__) {
  16296. Object.defineProperty(exports, "__esModule", {
  16297. value: true
  16298. });
  16299. exports.default = {
  16300. remove: 'Kaldır',
  16301. cancel: 'İptal',
  16302. confirm: 'Onayla',
  16303. insert: 'Seçilenleri ekle',
  16304. width: 'Genişlik',
  16305. height: 'Yükseklik',
  16306. image: 'Resim',
  16307. video: 'Görüntü',
  16308. audio: 'Ses',
  16309. embed: 'Nesne göm',
  16310. caption: 'Kitaplık',
  16311. dragTip: 'Tıkla ya da dosya sürükle',
  16312. dropTip: 'Yüklemek için sürükleyin',
  16313. selectAll: 'Tümünü seç',
  16314. deselect: 'Seçimi kaldır',
  16315. removeSelected: 'Seçilenleri kaldır',
  16316. externalInputPlaceHolder: 'Kaynak adı|Kaynak bağlantısı',
  16317. externalInputTip: 'Kaynak asını ve bağlantısını "|" ile ayırın ve Enter\' a basın.',
  16318. addLocalFile: 'Yerel\' den ekle',
  16319. addExternalSource: 'Harici kaynaktan ekle',
  16320. unnamedItem: 'Adlandırılmamış giriş',
  16321. confirmInsert: 'Seçilenleri ekle'
  16322. };
  16323. /***/ }),
  16324. /* 4 */
  16325. /***/ (function(module, exports, __webpack_require__) {
  16326. Object.defineProperty(exports, "__esModule", {
  16327. value: true
  16328. });
  16329. exports.default = {
  16330. remove: '削除する',
  16331. cancel: 'キャンセル',
  16332. confirm: '確認する',
  16333. insert: '選択したアイテムを挿入',
  16334. width: '幅',
  16335. height: '身長',
  16336. image: '絵',
  16337. video: 'ビデオ',
  16338. audio: '音声',
  16339. embed: '埋め込みメディア',
  16340. caption: 'メディアライブラリー',
  16341. dragTip: 'ファイルをこの位置までクリックまたはドラッグします',
  16342. dropTip: 'アップロードするマウスを放します',
  16343. selectAll: 'すべて選択',
  16344. deselect: '選択を解除',
  16345. removeSelected: '選択したアイテムを削除',
  16346. externalInputPlaceHolder: 'リソース名|リソースアドレス',
  16347. externalInputTip: 'リソース名とリソースアドレスは "|"で区切ります。',
  16348. addLocalFile: 'ローカルリソースを追加する',
  16349. addExternalSource: 'ネットワークリソースを追加する',
  16350. unnamedItem: '名前のないアイテム',
  16351. confirmInsert: '選択したアイテムを挿入'
  16352. };
  16353. /***/ }),
  16354. /* 5 */
  16355. /***/ (function(module, exports, __webpack_require__) {
  16356. Object.defineProperty(exports, "__esModule", {
  16357. value: true
  16358. });
  16359. exports.default = {
  16360. remove: '삭제',
  16361. cancel: '취소',
  16362. confirm: '확인',
  16363. insert: '선택한항목삽입',
  16364. width: '너비',
  16365. height: '높이',
  16366. image: '그림',
  16367. video: '비디오',
  16368. audio: '오디오',
  16369. embed: '임베디드미디어',
  16370. caption: '미디어라이브러리',
  16371. dragTip: '파일을 클릭하거나이 지점으로 드래그하십시오.',
  16372. dropTip: '업로드하려면마우스를놓으십시오.',
  16373. selectAll: '모두 선택',
  16374. deselect: '선택 취소',
  16375. removeSelected: '선택한 항목 삭제',
  16376. externalInputPlaceHolder: '리소스 이름 | 리소스 주소',
  16377. externalInputTip: '자원 이름과 자원 주소를 "|"',
  16378. addLocalFile: '로컬 리소스 추가',
  16379. addExternalSource: '네트워크 리소스 추가',
  16380. unnamedItem: '이름없는 항목',
  16381. confirmInsert: '선택한 항목 삽입'
  16382. };
  16383. /***/ }),
  16384. /* 6 */
  16385. /***/ (function(module, exports, __webpack_require__) {
  16386. Object.defineProperty(exports, "__esModule", {
  16387. value: true
  16388. });
  16389. exports.default = {
  16390. remove: 'Usuń',
  16391. cancel: 'Anuluj',
  16392. confirm: 'Potwierdź',
  16393. insert: 'Wstaw wybrane elementy',
  16394. width: 'Szerokość',
  16395. height: 'Wysokość',
  16396. image: 'Obraz',
  16397. video: 'Wideo',
  16398. audio: 'Dźwięk',
  16399. embed: 'Obiekt',
  16400. caption: 'Biblioteka mediów',
  16401. dragTip: 'Kliknij lub przenieś tu pliki',
  16402. dropTip: 'Upuść aby dodać plik',
  16403. selectAll: 'Zaznacz wszystko',
  16404. deselect: 'Odznacz',
  16405. removeSelected: 'Usuń wybrane',
  16406. externalInputPlaceHolder: 'Nazwa źródła|Adres URL',
  16407. externalInputTip: 'Oddziel nazwę i adres URL źródła z pomocą "|", Potwierdź Enter-em',
  16408. addLocalFile: 'Dodaj z komputera',
  16409. addExternalSource: 'Dodaj z Internetu',
  16410. unnamedItem: 'Bez nazwy',
  16411. confirmInsert: 'Dodaj wybrane elementy'
  16412. };
  16413. /***/ }),
  16414. /* 7 */
  16415. /***/ (function(module, exports, __webpack_require__) {
  16416. Object.defineProperty(exports, "__esModule", {
  16417. value: true
  16418. });
  16419. exports.default = {
  16420. remove: '删除',
  16421. cancel: '取消',
  16422. confirm: '确认',
  16423. insert: '插入所选项目',
  16424. width: '宽度',
  16425. height: '高度',
  16426. image: '图片',
  16427. video: '视频',
  16428. audio: '音频',
  16429. embed: '嵌入式媒体',
  16430. caption: '媒体库',
  16431. dragTip: '点击或拖动文件至此',
  16432. dropTip: '放开鼠标以上传',
  16433. selectAll: '选择全部',
  16434. deselect: '取消选择',
  16435. removeSelected: '删除选中项目',
  16436. externalInputPlaceHolder: '资源名称|资源地址',
  16437. externalInputTip: '使用“|”分隔资源名称和资源地址',
  16438. addLocalFile: '添加本地资源',
  16439. addExternalSource: '添加网络资源',
  16440. unnamedItem: '未命名项目',
  16441. confirmInsert: '插入选中项目'
  16442. };
  16443. /***/ }),
  16444. /* 8 */
  16445. /***/ (function(module, exports, __webpack_require__) {
  16446. Object.defineProperty(exports, "__esModule", {
  16447. value: true
  16448. });
  16449. exports.default = {
  16450. remove: '删除',
  16451. cancel: '取消',
  16452. confirm: '确认',
  16453. insert: '插入所选项目',
  16454. width: '宽度',
  16455. height: '高度',
  16456. image: '图片',
  16457. video: '视频',
  16458. audio: '音频',
  16459. embed: '嵌入式媒体',
  16460. caption: '媒体库',
  16461. dragTip: '点击或拖动文件至此',
  16462. dropTip: '放开鼠标以上传',
  16463. selectAll: '选择全部',
  16464. deselect: '取消选择',
  16465. removeSelected: '删除选中项目',
  16466. externalInputPlaceHolder: '资源名称|资源地址',
  16467. externalInputTip: '使用“|”分隔资源名称和资源地址',
  16468. addLocalFile: '添加本地资源',
  16469. addExternalSource: '添加网络资源',
  16470. unnamedItem: '未命名项目',
  16471. confirmInsert: '插入选中项目'
  16472. };
  16473. /***/ }),
  16474. /* 9 */
  16475. /***/ (function(module, exports, __webpack_require__) {
  16476. Object.defineProperty(exports, "__esModule", {
  16477. value: true
  16478. });
  16479. exports.default = {
  16480. remove: 'Remove',
  16481. cancel: 'Cancel',
  16482. confirm: 'Confirm',
  16483. insert: 'Insert Selected Items',
  16484. width: 'Width',
  16485. height: 'Height',
  16486. image: 'Image',
  16487. video: 'Video',
  16488. audio: 'Audio',
  16489. embed: 'Embed',
  16490. caption: 'Media Library',
  16491. dragTip: 'Click Or Drag Files Here',
  16492. dropTip: 'Drop To Upload',
  16493. selectAll: 'Select All',
  16494. deselect: 'Deselect',
  16495. removeSelected: 'Remove Selected Items',
  16496. externalInputPlaceHolder: 'Source Name|Source URL',
  16497. externalInputTip: 'Split source name and source URL with "|", confirm by hit Enter.',
  16498. addLocalFile: 'Add from local',
  16499. addExternalSource: 'Add from Internet',
  16500. unnamedItem: 'Unnamed Item',
  16501. confirmInsert: 'Insert selected items'
  16502. };
  16503. /***/ }),
  16504. /* 10 */
  16505. /***/ (function(module, exports, __webpack_require__) {
  16506. Object.defineProperty(exports, "__esModule", {
  16507. value: true
  16508. });
  16509. var _en = __webpack_require__(9);
  16510. var _en2 = _interopRequireDefault(_en);
  16511. var _zh = __webpack_require__(8);
  16512. var _zh2 = _interopRequireDefault(_zh);
  16513. var _zhHant = __webpack_require__(7);
  16514. var _zhHant2 = _interopRequireDefault(_zhHant);
  16515. var _pl = __webpack_require__(6);
  16516. var _pl2 = _interopRequireDefault(_pl);
  16517. var _kr = __webpack_require__(5);
  16518. var _kr2 = _interopRequireDefault(_kr);
  16519. var _jpn = __webpack_require__(4);
  16520. var _jpn2 = _interopRequireDefault(_jpn);
  16521. var _tr = __webpack_require__(3);
  16522. var _tr2 = _interopRequireDefault(_tr);
  16523. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16524. exports.default = {
  16525. "en": _en2.default,
  16526. "zh": _zh2.default,
  16527. "zh-hant": _zhHant2.default,
  16528. "pl": _pl2.default,
  16529. "kr": _kr2.default,
  16530. "jpn": _jpn2.default,
  16531. "tr": _tr2.default
  16532. };
  16533. /***/ }),
  16534. /* 11 */
  16535. /***/ (function(module, exports) {
  16536. /**
  16537. * When source maps are enabled, `style-loader` uses a link element with a data-uri to
  16538. * embed the css on the page. This breaks all relative urls because now they are relative to a
  16539. * bundle instead of the current page.
  16540. *
  16541. * One solution is to only use full urls, but that may be impossible.
  16542. *
  16543. * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
  16544. *
  16545. * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
  16546. *
  16547. */
  16548. module.exports = function (css) {
  16549. // get current location
  16550. var location = typeof window !== "undefined" && window.location;
  16551. if (!location) {
  16552. throw new Error("fixUrls requires window.location");
  16553. }
  16554. // blank or null?
  16555. if (!css || typeof css !== "string") {
  16556. return css;
  16557. }
  16558. var baseUrl = location.protocol + "//" + location.host;
  16559. var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
  16560. // convert each url(...)
  16561. /*
  16562. This regular expression is just a way to recursively match brackets within
  16563. a string.
  16564. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
  16565. ( = Start a capturing group
  16566. (?: = Start a non-capturing group
  16567. [^)(] = Match anything that isn't a parentheses
  16568. | = OR
  16569. \( = Match a start parentheses
  16570. (?: = Start another non-capturing groups
  16571. [^)(]+ = Match anything that isn't a parentheses
  16572. | = OR
  16573. \( = Match a start parentheses
  16574. [^)(]* = Match anything that isn't a parentheses
  16575. \) = Match a end parentheses
  16576. ) = End Group
  16577. *\) = Match anything and then a close parens
  16578. ) = Close non-capturing group
  16579. * = Match anything
  16580. ) = Close capturing group
  16581. \) = Match a close parens
  16582. /gi = Get all matches, not the first. Be case insensitive.
  16583. */
  16584. var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
  16585. // strip quotes (if they exist)
  16586. var unquotedOrigUrl = origUrl
  16587. .trim()
  16588. .replace(/^"(.*)"$/, function(o, $1){ return $1; })
  16589. .replace(/^'(.*)'$/, function(o, $1){ return $1; });
  16590. // already a full url? no change
  16591. if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
  16592. return fullMatch;
  16593. }
  16594. // convert the url to a full url
  16595. var newUrl;
  16596. if (unquotedOrigUrl.indexOf("//") === 0) {
  16597. //TODO: should we add protocol?
  16598. newUrl = unquotedOrigUrl;
  16599. } else if (unquotedOrigUrl.indexOf("/") === 0) {
  16600. // path should be relative to the base url
  16601. newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
  16602. } else {
  16603. // path should be relative to current directory
  16604. newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
  16605. }
  16606. // send back the fixed url(...)
  16607. return "url(" + JSON.stringify(newUrl) + ")";
  16608. });
  16609. // send back the fixed css
  16610. return fixedCss;
  16611. };
  16612. /***/ }),
  16613. /* 12 */
  16614. /***/ (function(module, exports, __webpack_require__) {
  16615. /*
  16616. MIT License http://www.opensource.org/licenses/mit-license.php
  16617. Author Tobias Koppers @sokra
  16618. */
  16619. var stylesInDom = {};
  16620. var memoize = function (fn) {
  16621. var memo;
  16622. return function () {
  16623. if (typeof memo === "undefined") memo = fn.apply(this, arguments);
  16624. return memo;
  16625. };
  16626. };
  16627. var isOldIE = memoize(function () {
  16628. // Test for IE <= 9 as proposed by Browserhacks
  16629. // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
  16630. // Tests for existence of standard globals is to allow style-loader
  16631. // to operate correctly into non-standard environments
  16632. // @see https://github.com/webpack-contrib/style-loader/issues/177
  16633. return window && document && document.all && !window.atob;
  16634. });
  16635. var getTarget = function (target) {
  16636. return document.querySelector(target);
  16637. };
  16638. var getElement = (function (fn) {
  16639. var memo = {};
  16640. return function(target) {
  16641. // If passing function in options, then use it for resolve "head" element.
  16642. // Useful for Shadow Root style i.e
  16643. // {
  16644. // insertInto: function () { return document.querySelector("#foo").shadowRoot }
  16645. // }
  16646. if (typeof target === 'function') {
  16647. return target();
  16648. }
  16649. if (typeof memo[target] === "undefined") {
  16650. var styleTarget = getTarget.call(this, target);
  16651. // Special case to return head of iframe instead of iframe itself
  16652. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  16653. try {
  16654. // This will throw an exception if access to iframe is blocked
  16655. // due to cross-origin restrictions
  16656. styleTarget = styleTarget.contentDocument.head;
  16657. } catch(e) {
  16658. styleTarget = null;
  16659. }
  16660. }
  16661. memo[target] = styleTarget;
  16662. }
  16663. return memo[target]
  16664. };
  16665. })();
  16666. var singleton = null;
  16667. var singletonCounter = 0;
  16668. var stylesInsertedAtTop = [];
  16669. var fixUrls = __webpack_require__(11);
  16670. module.exports = function(list, options) {
  16671. if (typeof DEBUG !== "undefined" && DEBUG) {
  16672. if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
  16673. }
  16674. options = options || {};
  16675. options.attrs = typeof options.attrs === "object" ? options.attrs : {};
  16676. // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  16677. // tags it will allow on a page
  16678. if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();
  16679. // By default, add <style> tags to the <head> element
  16680. if (!options.insertInto) options.insertInto = "head";
  16681. // By default, add <style> tags to the bottom of the target
  16682. if (!options.insertAt) options.insertAt = "bottom";
  16683. var styles = listToStyles(list, options);
  16684. addStylesToDom(styles, options);
  16685. return function update (newList) {
  16686. var mayRemove = [];
  16687. for (var i = 0; i < styles.length; i++) {
  16688. var item = styles[i];
  16689. var domStyle = stylesInDom[item.id];
  16690. domStyle.refs--;
  16691. mayRemove.push(domStyle);
  16692. }
  16693. if(newList) {
  16694. var newStyles = listToStyles(newList, options);
  16695. addStylesToDom(newStyles, options);
  16696. }
  16697. for (var i = 0; i < mayRemove.length; i++) {
  16698. var domStyle = mayRemove[i];
  16699. if(domStyle.refs === 0) {
  16700. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
  16701. delete stylesInDom[domStyle.id];
  16702. }
  16703. }
  16704. };
  16705. };
  16706. function addStylesToDom (styles, options) {
  16707. for (var i = 0; i < styles.length; i++) {
  16708. var item = styles[i];
  16709. var domStyle = stylesInDom[item.id];
  16710. if(domStyle) {
  16711. domStyle.refs++;
  16712. for(var j = 0; j < domStyle.parts.length; j++) {
  16713. domStyle.parts[j](item.parts[j]);
  16714. }
  16715. for(; j < item.parts.length; j++) {
  16716. domStyle.parts.push(addStyle(item.parts[j], options));
  16717. }
  16718. } else {
  16719. var parts = [];
  16720. for(var j = 0; j < item.parts.length; j++) {
  16721. parts.push(addStyle(item.parts[j], options));
  16722. }
  16723. stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
  16724. }
  16725. }
  16726. }
  16727. function listToStyles (list, options) {
  16728. var styles = [];
  16729. var newStyles = {};
  16730. for (var i = 0; i < list.length; i++) {
  16731. var item = list[i];
  16732. var id = options.base ? item[0] + options.base : item[0];
  16733. var css = item[1];
  16734. var media = item[2];
  16735. var sourceMap = item[3];
  16736. var part = {css: css, media: media, sourceMap: sourceMap};
  16737. if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
  16738. else newStyles[id].parts.push(part);
  16739. }
  16740. return styles;
  16741. }
  16742. function insertStyleElement (options, style) {
  16743. var target = getElement(options.insertInto);
  16744. if (!target) {
  16745. throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
  16746. }
  16747. var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
  16748. if (options.insertAt === "top") {
  16749. if (!lastStyleElementInsertedAtTop) {
  16750. target.insertBefore(style, target.firstChild);
  16751. } else if (lastStyleElementInsertedAtTop.nextSibling) {
  16752. target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
  16753. } else {
  16754. target.appendChild(style);
  16755. }
  16756. stylesInsertedAtTop.push(style);
  16757. } else if (options.insertAt === "bottom") {
  16758. target.appendChild(style);
  16759. } else if (typeof options.insertAt === "object" && options.insertAt.before) {
  16760. var nextSibling = getElement(options.insertInto + " " + options.insertAt.before);
  16761. target.insertBefore(style, nextSibling);
  16762. } else {
  16763. 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");
  16764. }
  16765. }
  16766. function removeStyleElement (style) {
  16767. if (style.parentNode === null) return false;
  16768. style.parentNode.removeChild(style);
  16769. var idx = stylesInsertedAtTop.indexOf(style);
  16770. if(idx >= 0) {
  16771. stylesInsertedAtTop.splice(idx, 1);
  16772. }
  16773. }
  16774. function createStyleElement (options) {
  16775. var style = document.createElement("style");
  16776. if(options.attrs.type === undefined) {
  16777. options.attrs.type = "text/css";
  16778. }
  16779. addAttrs(style, options.attrs);
  16780. insertStyleElement(options, style);
  16781. return style;
  16782. }
  16783. function createLinkElement (options) {
  16784. var link = document.createElement("link");
  16785. if(options.attrs.type === undefined) {
  16786. options.attrs.type = "text/css";
  16787. }
  16788. options.attrs.rel = "stylesheet";
  16789. addAttrs(link, options.attrs);
  16790. insertStyleElement(options, link);
  16791. return link;
  16792. }
  16793. function addAttrs (el, attrs) {
  16794. Object.keys(attrs).forEach(function (key) {
  16795. el.setAttribute(key, attrs[key]);
  16796. });
  16797. }
  16798. function addStyle (obj, options) {
  16799. var style, update, remove, result;
  16800. // If a transform function was defined, run it on the css
  16801. if (options.transform && obj.css) {
  16802. result = options.transform(obj.css);
  16803. if (result) {
  16804. // If transform returns a value, use that instead of the original css.
  16805. // This allows running runtime transformations on the css.
  16806. obj.css = result;
  16807. } else {
  16808. // If the transform function returns a falsy value, don't add this css.
  16809. // This allows conditional loading of css
  16810. return function() {
  16811. // noop
  16812. };
  16813. }
  16814. }
  16815. if (options.singleton) {
  16816. var styleIndex = singletonCounter++;
  16817. style = singleton || (singleton = createStyleElement(options));
  16818. update = applyToSingletonTag.bind(null, style, styleIndex, false);
  16819. remove = applyToSingletonTag.bind(null, style, styleIndex, true);
  16820. } else if (
  16821. obj.sourceMap &&
  16822. typeof URL === "function" &&
  16823. typeof URL.createObjectURL === "function" &&
  16824. typeof URL.revokeObjectURL === "function" &&
  16825. typeof Blob === "function" &&
  16826. typeof btoa === "function"
  16827. ) {
  16828. style = createLinkElement(options);
  16829. update = updateLink.bind(null, style, options);
  16830. remove = function () {
  16831. removeStyleElement(style);
  16832. if(style.href) URL.revokeObjectURL(style.href);
  16833. };
  16834. } else {
  16835. style = createStyleElement(options);
  16836. update = applyToTag.bind(null, style);
  16837. remove = function () {
  16838. removeStyleElement(style);
  16839. };
  16840. }
  16841. update(obj);
  16842. return function updateStyle (newObj) {
  16843. if (newObj) {
  16844. if (
  16845. newObj.css === obj.css &&
  16846. newObj.media === obj.media &&
  16847. newObj.sourceMap === obj.sourceMap
  16848. ) {
  16849. return;
  16850. }
  16851. update(obj = newObj);
  16852. } else {
  16853. remove();
  16854. }
  16855. };
  16856. }
  16857. var replaceText = (function () {
  16858. var textStore = [];
  16859. return function (index, replacement) {
  16860. textStore[index] = replacement;
  16861. return textStore.filter(Boolean).join('\n');
  16862. };
  16863. })();
  16864. function applyToSingletonTag (style, index, remove, obj) {
  16865. var css = remove ? "" : obj.css;
  16866. if (style.styleSheet) {
  16867. style.styleSheet.cssText = replaceText(index, css);
  16868. } else {
  16869. var cssNode = document.createTextNode(css);
  16870. var childNodes = style.childNodes;
  16871. if (childNodes[index]) style.removeChild(childNodes[index]);
  16872. if (childNodes.length) {
  16873. style.insertBefore(cssNode, childNodes[index]);
  16874. } else {
  16875. style.appendChild(cssNode);
  16876. }
  16877. }
  16878. }
  16879. function applyToTag (style, obj) {
  16880. var css = obj.css;
  16881. var media = obj.media;
  16882. if(media) {
  16883. style.setAttribute("media", media);
  16884. }
  16885. if(style.styleSheet) {
  16886. style.styleSheet.cssText = css;
  16887. } else {
  16888. while(style.firstChild) {
  16889. style.removeChild(style.firstChild);
  16890. }
  16891. style.appendChild(document.createTextNode(css));
  16892. }
  16893. }
  16894. function updateLink (link, options, obj) {
  16895. var css = obj.css;
  16896. var sourceMap = obj.sourceMap;
  16897. /*
  16898. If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
  16899. and there is no publicPath defined then lets turn convertToAbsoluteUrls
  16900. on by default. Otherwise default to the convertToAbsoluteUrls option
  16901. directly
  16902. */
  16903. var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
  16904. if (options.convertToAbsoluteUrls || autoFixUrls) {
  16905. css = fixUrls(css);
  16906. }
  16907. if (sourceMap) {
  16908. // http://stackoverflow.com/a/26603875
  16909. css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
  16910. }
  16911. var blob = new Blob([css], { type: "text/css" });
  16912. var oldSrc = link.href;
  16913. link.href = URL.createObjectURL(blob);
  16914. if(oldSrc) URL.revokeObjectURL(oldSrc);
  16915. }
  16916. /***/ }),
  16917. /* 13 */
  16918. /***/ (function(module, exports) {
  16919. 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=";
  16920. /***/ }),
  16921. /* 14 */
  16922. /***/ (function(module, exports) {
  16923. /*
  16924. MIT License http://www.opensource.org/licenses/mit-license.php
  16925. Author Tobias Koppers @sokra
  16926. */
  16927. // css base code, injected by the css-loader
  16928. module.exports = function(useSourceMap) {
  16929. var list = [];
  16930. // return the list of modules as css string
  16931. list.toString = function toString() {
  16932. return this.map(function (item) {
  16933. var content = cssWithMappingToString(item, useSourceMap);
  16934. if(item[2]) {
  16935. return "@media " + item[2] + "{" + content + "}";
  16936. } else {
  16937. return content;
  16938. }
  16939. }).join("");
  16940. };
  16941. // import a list of modules into the list
  16942. list.i = function(modules, mediaQuery) {
  16943. if(typeof modules === "string")
  16944. modules = [[null, modules, ""]];
  16945. var alreadyImportedModules = {};
  16946. for(var i = 0; i < this.length; i++) {
  16947. var id = this[i][0];
  16948. if(typeof id === "number")
  16949. alreadyImportedModules[id] = true;
  16950. }
  16951. for(i = 0; i < modules.length; i++) {
  16952. var item = modules[i];
  16953. // skip already imported module
  16954. // this implementation is not 100% perfect for weird media query combinations
  16955. // when a module is imported multiple times with different media queries.
  16956. // I hope this will never occur (Hey this way we have smaller bundles)
  16957. if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
  16958. if(mediaQuery && !item[2]) {
  16959. item[2] = mediaQuery;
  16960. } else if(mediaQuery) {
  16961. item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
  16962. }
  16963. list.push(item);
  16964. }
  16965. }
  16966. };
  16967. return list;
  16968. };
  16969. function cssWithMappingToString(item, useSourceMap) {
  16970. var content = item[1] || '';
  16971. var cssMapping = item[3];
  16972. if (!cssMapping) {
  16973. return content;
  16974. }
  16975. if (useSourceMap && typeof btoa === 'function') {
  16976. var sourceMapping = toComment(cssMapping);
  16977. var sourceURLs = cssMapping.sources.map(function (source) {
  16978. return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
  16979. });
  16980. return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  16981. }
  16982. return [content].join('\n');
  16983. }
  16984. // Adapted from convert-source-map (MIT)
  16985. function toComment(sourceMap) {
  16986. // eslint-disable-next-line no-undef
  16987. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
  16988. var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
  16989. return '/*# ' + data + ' */';
  16990. }
  16991. /***/ }),
  16992. /* 15 */
  16993. /***/ (function(module, exports) {
  16994. module.exports = function escape(url) {
  16995. if (typeof url !== 'string') {
  16996. return url
  16997. }
  16998. // If url is already wrapped in quotes, remove them
  16999. if (/^['"].*['"]$/.test(url)) {
  17000. url = url.slice(1, -1);
  17001. }
  17002. // Should url be wrapped?
  17003. // See https://drafts.csswg.org/css-values-3/#urls
  17004. if (/["'() \t\n]/.test(url)) {
  17005. return '"' + url.replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"'
  17006. }
  17007. return url
  17008. };
  17009. /***/ }),
  17010. /* 16 */
  17011. /***/ (function(module, exports, __webpack_require__) {
  17012. var escape = __webpack_require__(15);
  17013. exports = module.exports = __webpack_require__(14)(false);
  17014. // imports
  17015. // module
  17016. 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", ""]);
  17017. // exports
  17018. /***/ }),
  17019. /* 17 */
  17020. /***/ (function(module, exports, __webpack_require__) {
  17021. var content = __webpack_require__(16);
  17022. if(typeof content === 'string') content = [[module.i, content, '']];
  17023. var transform;
  17024. var options = {"hmr":true};
  17025. options.transform = transform;
  17026. options.insertInto = undefined;
  17027. var update = __webpack_require__(12)(content, options);
  17028. if(content.locals) module.exports = content.locals;
  17029. /***/ }),
  17030. /* 18 */
  17031. /***/ (function(module, exports, __webpack_require__) {
  17032. Object.defineProperty(exports, "__esModule", {
  17033. value: true
  17034. });
  17035. 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; };
  17036. 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; }; }();
  17037. __webpack_require__(17);
  17038. var _react = __webpack_require__(2);
  17039. var _react2 = _interopRequireDefault(_react);
  17040. var _base = __webpack_require__(1);
  17041. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17042. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17043. 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; }
  17044. 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; }
  17045. var defaultAccepts = {
  17046. image: 'image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg',
  17047. video: 'video/mp4',
  17048. audio: 'audio/mp3'
  17049. };
  17050. var BraftFinderView = function (_React$Component) {
  17051. _inherits(BraftFinderView, _React$Component);
  17052. function BraftFinderView(props) {
  17053. _classCallCheck(this, BraftFinderView);
  17054. var _this = _possibleConstructorReturn(this, (BraftFinderView.__proto__ || Object.getPrototypeOf(BraftFinderView)).call(this, props));
  17055. _this.toggleSelectItem = function (event) {
  17056. var itemId = event.currentTarget.dataset.id;
  17057. var item = _this.controller.getMediaItem(itemId);
  17058. if (!item) {
  17059. return false;
  17060. }
  17061. if (item.selected) {
  17062. if (!_this.props.onBeforeDeselect || _this.props.onBeforeDeselect([item], _this.controller.getItems()) !== false) {
  17063. _this.controller.deselectMediaItem(itemId);
  17064. _this.props.onDeselect && _this.props.onDeselect([item], _this.controller.getItems());
  17065. }
  17066. } else {
  17067. if (!_this.props.onBeforeSelect || _this.props.onBeforeSelect([item], _this.controller.getItems()) !== false) {
  17068. _this.controller.selectMediaItem(itemId);
  17069. _this.props.onSelect && _this.props.onSelect([item], _this.controller.getItems());
  17070. }
  17071. }
  17072. };
  17073. _this.removeItem = function (event) {
  17074. var itemId = event.currentTarget.dataset.id;
  17075. var item = _this.controller.getMediaItem(itemId);
  17076. if (!item) {
  17077. return false;
  17078. }
  17079. if (!_this.props.onBeforeRemove || _this.props.onBeforeRemove([item], _this.controller.getItems()) !== false) {
  17080. _this.controller.removeMediaItem(itemId);
  17081. _this.props.onRemove && _this.props.onRemove([item], _this.controller.getItems());
  17082. }
  17083. event.stopPropagation();
  17084. };
  17085. _this.selectAllItems = function () {
  17086. var allItems = _this.controller.getItems();
  17087. if (!_this.props.onBeforeSelect || _this.props.onBeforeSelect(allItems, allItems) !== false) {
  17088. _this.controller.selectAllItems();
  17089. _this.props.onSelect && _this.props.onSelect(allItems, allItems);
  17090. }
  17091. };
  17092. _this.deselectAllItems = function () {
  17093. var allItems = _this.controller.getItems();
  17094. if (!_this.props.onBeforeDeselect || _this.props.onBeforeDeselect(allItems, allItems) !== false) {
  17095. _this.controller.deselectAllItems();
  17096. _this.props.onDeselect && _this.props.onDeselect(allItems, allItems);
  17097. }
  17098. };
  17099. _this.removeSelectedItems = function () {
  17100. var selectedItems = _this.controller.getSelectedItems();
  17101. if (!_this.props.onBeforeRemove || _this.props.onBeforeRemove(selectedItems, _this.controller.getItems()) !== false) {
  17102. _this.controller.removeSelectedItems();
  17103. _this.props.onRemove && _this.props.onRemove(selectedItems, _this.controller.getItems());
  17104. }
  17105. };
  17106. _this.handleDragLeave = function (event) {
  17107. event.preventDefault();
  17108. _this.dragCounter--;
  17109. _this.dragCounter === 0 && _this.setState({
  17110. draging: false
  17111. });
  17112. };
  17113. _this.handleDragDrop = function (event) {
  17114. event.preventDefault();
  17115. _this.dragCounter = 0;
  17116. _this.setState({ draging: false });
  17117. _this.reslovePickedFiles(event);
  17118. };
  17119. _this.handleDragEnter = function (event) {
  17120. event.preventDefault();
  17121. _this.dragCounter++;
  17122. _this.setState({ draging: true });
  17123. };
  17124. _this.reslovePickedFiles = function (event) {
  17125. event.persist();
  17126. var _ref = event.type === 'drop' ? event.dataTransfer : event.target,
  17127. files = _ref.files;
  17128. if (_this.props.onFileSelect) {
  17129. var result = _this.props.onFileSelect(files);
  17130. if (result === false) {
  17131. return false;
  17132. } else if (result instanceof FileList || result instanceof Array) {
  17133. files = result;
  17134. }
  17135. }
  17136. var accepts = _extends({}, defaultAccepts, _this.props.accepts);
  17137. _this.controller.resolveFiles({
  17138. files: files,
  17139. onItemReady: function onItemReady(_ref2) {
  17140. var id = _ref2.id;
  17141. return _this.controller.selectMediaItem(id);
  17142. },
  17143. onAllReady: function onAllReady() {
  17144. return event.target.value = null;
  17145. }
  17146. }, 0, accepts);
  17147. };
  17148. _this.inputExternal = function (event) {
  17149. _this.setState({
  17150. external: _extends({}, _this.state.external, {
  17151. url: event.target.value
  17152. })
  17153. });
  17154. };
  17155. _this.switchExternalType = function (event) {
  17156. _this.setState({
  17157. external: _extends({}, _this.state.external, { type: event.target.dataset.type })
  17158. });
  17159. };
  17160. _this.confirmAddExternal = function (event) {
  17161. if (event.target.nodeName.toLowerCase() === 'button' || event.keyCode === 13) {
  17162. var _this$state$external = _this.state.external,
  17163. url = _this$state$external.url,
  17164. type = _this$state$external.type;
  17165. url = url.split('|');
  17166. var name = url.length > 1 ? url[0] : _this.props.language.unnamedItem;
  17167. url = url.length > 1 ? url[1] : url[0];
  17168. var thumbnail = type === 'IMAGE' ? url : null;
  17169. _this.controller.addItems([{
  17170. thumbnail: thumbnail, url: url, name: name, type: type,
  17171. id: new Date().getTime() + '_' + (0, _base.UniqueIndex)(),
  17172. uploading: false,
  17173. uploadProgress: 1,
  17174. selected: true
  17175. }]);
  17176. _this.setState({
  17177. showExternalForm: false,
  17178. external: {
  17179. url: '',
  17180. type: 'IMAGE'
  17181. }
  17182. });
  17183. }
  17184. };
  17185. _this.toggleExternalForm = function () {
  17186. _this.setState({
  17187. showExternalForm: !_this.state.showExternalForm
  17188. });
  17189. };
  17190. _this.cancelInsert = function () {
  17191. _this.props.onCancel && _this.props.onCancel();
  17192. };
  17193. _this.confirmInsert = function () {
  17194. var selectedItems = _this.controller.getSelectedItems();
  17195. if (_this.props.onBeforeInsert) {
  17196. var filteredItems = _this.props.onBeforeInsert(selectedItems);
  17197. if (filteredItems && filteredItems instanceof Array) {
  17198. _this.controller.deselectAllItems();
  17199. _this.props.onInsert && _this.props.onInsert(filteredItems);
  17200. } else if (filteredItems !== false) {
  17201. _this.controller.deselectAllItems();
  17202. _this.props.onInsert && _this.props.onInsert(selectedItems);
  17203. }
  17204. } else {
  17205. _this.controller.deselectAllItems();
  17206. _this.props.onInsert && _this.props.onInsert(selectedItems);
  17207. }
  17208. };
  17209. _this.dragCounter = 0;
  17210. _this.controller = _this.props.controller;
  17211. var initialItems = _this.controller.getItems();
  17212. _this.state = {
  17213. draging: false,
  17214. error: false,
  17215. confirmable: initialItems.find(function (_ref3) {
  17216. var selected = _ref3.selected;
  17217. return selected;
  17218. }),
  17219. external: {
  17220. url: '',
  17221. type: 'IMAGE'
  17222. },
  17223. fileAccept: '',
  17224. showExternalForm: false,
  17225. allowExternal: false,
  17226. items: initialItems
  17227. };
  17228. _this.changeListenerId = _this.controller.onChange(function (items) {
  17229. _this.setState({ items: items, confirmable: items.find(function (_ref4) {
  17230. var selected = _ref4.selected;
  17231. return selected;
  17232. }) });
  17233. _this.props.onChange && _this.props.onChange(items);
  17234. });
  17235. return _this;
  17236. }
  17237. _createClass(BraftFinderView, [{
  17238. key: 'mapPropsToState',
  17239. value: function mapPropsToState(props) {
  17240. var accepts = props.accepts,
  17241. externals = props.externals;
  17242. accepts = _extends({}, defaultAccepts, accepts);
  17243. var fileAccept = !accepts ? [defaultAccepts.image, defaultAccepts.video, defaultAccepts.audio].join(',') : [accepts.image, accepts.video, accepts.audio].filter(function (item) {
  17244. return item;
  17245. }).join(',');
  17246. var external = {
  17247. url: '',
  17248. type: externals.image ? 'IMAGE' : externals.audio ? 'AUDIO' : externals.video ? 'VIDEO' : externals.embed ? 'EMBED' : ''
  17249. };
  17250. return {
  17251. fileAccept: fileAccept,
  17252. external: external,
  17253. allowExternal: externals && (externals.image || externals.audio || externals.video || externals.embed)
  17254. };
  17255. }
  17256. }, {
  17257. key: 'componentDidMount',
  17258. value: function componentDidMount() {
  17259. this.setState(this.mapPropsToState(this.props));
  17260. }
  17261. }, {
  17262. key: 'componentWillReceiveProps',
  17263. value: function componentWillReceiveProps(nextProps) {
  17264. this.setState(this.mapPropsToState(nextProps));
  17265. }
  17266. }, {
  17267. key: 'componentWillUnmount',
  17268. value: function componentWillUnmount() {
  17269. this.controller.offChange(this.changeListenerId);
  17270. }
  17271. }, {
  17272. key: 'render',
  17273. value: function render() {
  17274. var _props = this.props,
  17275. language = _props.language,
  17276. externals = _props.externals;
  17277. var _state = this.state,
  17278. items = _state.items,
  17279. draging = _state.draging,
  17280. confirmable = _state.confirmable,
  17281. fileAccept = _state.fileAccept,
  17282. external = _state.external,
  17283. showExternalForm = _state.showExternalForm,
  17284. allowExternal = _state.allowExternal;
  17285. return _react2.default.createElement(
  17286. 'div',
  17287. { className: 'braft-finder' },
  17288. _react2.default.createElement(
  17289. 'div',
  17290. {
  17291. onDragEnter: this.handleDragEnter,
  17292. onDragOver: this.handleDragEnter,
  17293. onDragLeave: this.handleDragLeave,
  17294. onDrop: this.handleDragDrop,
  17295. className: 'bf-uploader'
  17296. },
  17297. _react2.default.createElement(
  17298. 'div',
  17299. { className: "bf-drag-uploader " + (draging || !items.length ? 'active ' : ' ') + (draging ? 'draging' : '') },
  17300. _react2.default.createElement(
  17301. 'span',
  17302. { className: 'bf-drag-tip' },
  17303. _react2.default.createElement('input', { accept: fileAccept, onChange: this.reslovePickedFiles, multiple: true, type: 'file' }),
  17304. draging ? language.dropTip : language.dragTip
  17305. )
  17306. ),
  17307. items.length ? _react2.default.createElement(
  17308. 'div',
  17309. { className: 'bf-list-wrap' },
  17310. _react2.default.createElement(
  17311. 'div',
  17312. { className: 'bf-list-tools' },
  17313. _react2.default.createElement(
  17314. 'span',
  17315. { onClick: this.selectAllItems, className: 'bf-select-all' },
  17316. _react2.default.createElement('i', { className: 'braft-icon-done' }),
  17317. ' ',
  17318. language.selectAll
  17319. ),
  17320. _react2.default.createElement(
  17321. 'span',
  17322. { onClick: this.deselectAllItems, disabled: !confirmable, className: 'bf-deselect-all' },
  17323. _react2.default.createElement('i', { className: 'braft-icon-close' }),
  17324. ' ',
  17325. language.deselect
  17326. ),
  17327. _react2.default.createElement(
  17328. 'span',
  17329. { onClick: this.removeSelectedItems, disabled: !confirmable, className: 'bf-remove-selected' },
  17330. _react2.default.createElement('i', { className: 'braft-icon-bin' }),
  17331. ' ',
  17332. language.removeSelected
  17333. )
  17334. ),
  17335. this.buildItemList()
  17336. ) : null,
  17337. showExternalForm && allowExternal ? _react2.default.createElement(
  17338. 'div',
  17339. { className: 'bf-add-external' },
  17340. _react2.default.createElement(
  17341. 'div',
  17342. { className: 'bf-external-form' },
  17343. _react2.default.createElement(
  17344. 'div',
  17345. { className: 'bf-external-input' },
  17346. _react2.default.createElement(
  17347. 'div',
  17348. null,
  17349. _react2.default.createElement('input', { onKeyDown: this.confirmAddExternal, value: external.url, onChange: this.inputExternal, placeholder: language.externalInputPlaceHolder })
  17350. ),
  17351. _react2.default.createElement(
  17352. 'button',
  17353. { type: 'button', onClick: this.confirmAddExternal, disabled: !external.url.trim().length },
  17354. language.confirm
  17355. )
  17356. ),
  17357. _react2.default.createElement(
  17358. 'div',
  17359. { 'data-type': external.type, className: 'bf-switch-external-type' },
  17360. externals.image ? _react2.default.createElement(
  17361. 'button',
  17362. { type: 'button', onClick: this.switchExternalType, 'data-type': 'IMAGE' },
  17363. language.image
  17364. ) : null,
  17365. externals.audio ? _react2.default.createElement(
  17366. 'button',
  17367. { type: 'button', onClick: this.switchExternalType, 'data-type': 'AUDIO' },
  17368. language.audio
  17369. ) : null,
  17370. externals.video ? _react2.default.createElement(
  17371. 'button',
  17372. { type: 'button', onClick: this.switchExternalType, 'data-type': 'VIDEO' },
  17373. language.video
  17374. ) : null,
  17375. externals.embed ? _react2.default.createElement(
  17376. 'button',
  17377. { type: 'button', onClick: this.switchExternalType, 'data-type': 'EMBED' },
  17378. language.embed
  17379. ) : null
  17380. ),
  17381. _react2.default.createElement(
  17382. 'span',
  17383. { className: 'bf-external-tip' },
  17384. language.externalInputTip
  17385. )
  17386. )
  17387. ) : null
  17388. ),
  17389. _react2.default.createElement(
  17390. 'footer',
  17391. { className: 'bf-manager-footer' },
  17392. _react2.default.createElement(
  17393. 'div',
  17394. { className: 'pull-left' },
  17395. allowExternal ? _react2.default.createElement(
  17396. 'span',
  17397. {
  17398. onClick: this.toggleExternalForm,
  17399. className: 'bf-toggle-external-form'
  17400. },
  17401. showExternalForm ? _react2.default.createElement(
  17402. 'span',
  17403. { className: 'bf-bottom-text' },
  17404. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  17405. ' ',
  17406. language.addLocalFile
  17407. ) : _react2.default.createElement(
  17408. 'span',
  17409. { className: 'bf-bottom-text' },
  17410. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  17411. ' ',
  17412. language.addExternalSource
  17413. )
  17414. ) : null
  17415. ),
  17416. _react2.default.createElement(
  17417. 'div',
  17418. { className: 'pull-right' },
  17419. _react2.default.createElement(
  17420. 'button',
  17421. { onClick: this.confirmInsert, className: 'button button-insert', disabled: !confirmable },
  17422. language.insert
  17423. ),
  17424. _react2.default.createElement(
  17425. 'button',
  17426. { onClick: this.cancelInsert, className: 'button button-cancel' },
  17427. language.cancel
  17428. )
  17429. )
  17430. )
  17431. );
  17432. }
  17433. }, {
  17434. key: 'buildItemList',
  17435. value: function buildItemList() {
  17436. var _this2 = this;
  17437. return _react2.default.createElement(
  17438. 'ul',
  17439. { className: 'bf-list' },
  17440. _react2.default.createElement(
  17441. 'li',
  17442. { className: 'bf-add-item' },
  17443. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  17444. _react2.default.createElement('input', { accept: this.state.fileAccept, onChange: this.reslovePickedFiles, multiple: true, type: 'file' })
  17445. ),
  17446. this.state.items.map(function (item, index) {
  17447. var previewerComponents = null;
  17448. var progressMarker = item.uploading && !_this2.props.hideProgress ? _react2.default.createElement(
  17449. 'div',
  17450. { className: 'bf-item-uploading' },
  17451. _react2.default.createElement('div', { className: 'bf-item-uploading-bar', style: { width: item.uploadProgress / 1 + '%' } })
  17452. ) : '';
  17453. switch (item.type) {
  17454. case 'IMAGE':
  17455. previewerComponents = _react2.default.createElement(
  17456. 'div',
  17457. { className: 'bf-image' },
  17458. progressMarker,
  17459. _react2.default.createElement('img', { src: item.thumbnail || item.url })
  17460. );
  17461. break;
  17462. case 'VIDEO':
  17463. previewerComponents = _react2.default.createElement(
  17464. 'div',
  17465. { className: 'bf-icon bf-video', title: item.url },
  17466. progressMarker,
  17467. _react2.default.createElement('i', { className: 'braft-icon-film' }),
  17468. _react2.default.createElement(
  17469. 'span',
  17470. null,
  17471. item.name || item.url
  17472. )
  17473. );
  17474. break;
  17475. case 'AUDIO':
  17476. previewerComponents = _react2.default.createElement(
  17477. 'div',
  17478. { className: 'bf-icon bf-audio', title: item.url },
  17479. progressMarker,
  17480. _react2.default.createElement('i', { className: 'braft-icon-music' }),
  17481. _react2.default.createElement(
  17482. 'span',
  17483. null,
  17484. item.name || item.url
  17485. )
  17486. );
  17487. break;
  17488. case 'EMBED':
  17489. previewerComponents = _react2.default.createElement(
  17490. 'div',
  17491. { className: 'bf-icon bf-embed', title: item.url },
  17492. progressMarker,
  17493. _react2.default.createElement('i', { className: 'braft-icon-code' }),
  17494. _react2.default.createElement(
  17495. 'span',
  17496. null,
  17497. item.name || _this2.props.language.embed
  17498. )
  17499. );
  17500. break;
  17501. default:
  17502. previewerComponents = _react2.default.createElement(
  17503. 'a',
  17504. { className: 'bf-icon bf-file', title: item.url, href: item.url },
  17505. progressMarker,
  17506. _react2.default.createElement('i', { className: 'braft-icon-file-text' }),
  17507. _react2.default.createElement(
  17508. 'span',
  17509. null,
  17510. item.name || item.url
  17511. )
  17512. );
  17513. break;
  17514. }
  17515. var className = ['bf-item'];
  17516. item.selected && className.push('active');
  17517. item.uploading && className.push('uploading');
  17518. item.error && className.push('error');
  17519. return _react2.default.createElement(
  17520. 'li',
  17521. {
  17522. key: index,
  17523. title: item.name,
  17524. 'data-id': item.id,
  17525. className: className.join(' '),
  17526. onClick: _this2.toggleSelectItem
  17527. },
  17528. previewerComponents,
  17529. _react2.default.createElement('span', { 'data-id': item.id, onClick: _this2.removeItem, className: 'bf-item-remove braft-icon-close' }),
  17530. _react2.default.createElement(
  17531. 'span',
  17532. { className: 'bf-item-title' },
  17533. item.name
  17534. )
  17535. );
  17536. })
  17537. );
  17538. }
  17539. }]);
  17540. return BraftFinderView;
  17541. }(_react2.default.Component);
  17542. BraftFinderView.defaultProps = {
  17543. accepts: defaultAccepts,
  17544. externals: {
  17545. image: true,
  17546. video: true,
  17547. audio: true,
  17548. embed: true
  17549. }
  17550. };
  17551. exports.default = BraftFinderView;
  17552. /***/ }),
  17553. /* 19 */
  17554. /***/ (function(module, exports, __webpack_require__) {
  17555. Object.defineProperty(exports, "__esModule", {
  17556. value: true
  17557. });
  17558. 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; };
  17559. var _base = __webpack_require__(1);
  17560. var _image = __webpack_require__(0);
  17561. 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); } }
  17562. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17563. var defaultValidator = function defaultValidator() {
  17564. return true;
  17565. };
  17566. var BraftFinderController = function BraftFinderController() {
  17567. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  17568. _classCallCheck(this, BraftFinderController);
  17569. _initialiseProps.call(this);
  17570. this.items = props.items || [];
  17571. this.uploadFn = props.uploader;
  17572. this.validateFn = props.validator || defaultValidator;
  17573. this.changeListeners = [];
  17574. }
  17575. // resolvePastedFiles ({ clipboardData }, callback) {
  17576. // if (clipboardData && clipboardData.items && clipboardData.items[0].type.indexOf('image') > -1) {
  17577. // this.uploadImage(clipboardData.items[0].getAsFile(), callback)
  17578. // }
  17579. // }
  17580. ;
  17581. var _initialiseProps = function _initialiseProps() {
  17582. var _this = this;
  17583. this.setProps = function () {
  17584. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  17585. _this.items = props.items || _this.items || [];
  17586. _this.uploadFn = props.uploader;
  17587. _this.validateFn = props.validator || defaultValidator;
  17588. };
  17589. this.getMediaItem = function (id) {
  17590. return _this.items.find(function (item) {
  17591. return item.id === id;
  17592. });
  17593. };
  17594. this.getSelectedItems = function () {
  17595. return _this.items.filter(function (item) {
  17596. return item.selected;
  17597. });
  17598. };
  17599. this.getItems = function () {
  17600. return _this.items;
  17601. };
  17602. this.setItems = function (items) {
  17603. _this.items = items.map(function (item) {
  17604. return _extends({}, item, { id: item.id.toString() });
  17605. }) || [];
  17606. _this.applyChange();
  17607. _this.uploadItems();
  17608. };
  17609. this.addMediaItem = function (item) {
  17610. _this.addItems([item]);
  17611. };
  17612. this.addItems = function (items) {
  17613. _this.items = [].concat(_toConsumableArray(_this.items), _toConsumableArray(items.map(function (item) {
  17614. return _extends({}, item, { id: item.id.toString() });
  17615. })));
  17616. _this.applyChange();
  17617. _this.uploadItems();
  17618. };
  17619. this.selectMediaItem = function (id) {
  17620. var item = _this.getMediaItem(id);
  17621. if (item && (item.uploading || item.error)) {
  17622. return false;
  17623. }
  17624. _this.setMediaItemState(id, {
  17625. selected: true
  17626. });
  17627. };
  17628. this.selectAllItems = function () {
  17629. _this.items = _this.items.filter(function (item) {
  17630. return !item.error && !item.uploading;
  17631. }).map(function (item) {
  17632. return _extends({}, item, { selected: true });
  17633. });
  17634. _this.applyChange();
  17635. };
  17636. this.deselectMediaItem = function (id) {
  17637. _this.setMediaItemState(id, {
  17638. selected: false
  17639. });
  17640. };
  17641. this.deselectAllItems = function () {
  17642. _this.items = _this.items.map(function (item) {
  17643. return _extends({}, item, { selected: false });
  17644. });
  17645. _this.applyChange();
  17646. };
  17647. this.removeMediaItem = function (id) {
  17648. _this.items = _this.items.filter(function (item) {
  17649. return item.id !== id;
  17650. });
  17651. _this.applyChange();
  17652. };
  17653. this.removeItems = function () {
  17654. var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  17655. _this.items = _this.items.filter(function (item) {
  17656. return !ids.includes(item.id);
  17657. });
  17658. _this.applyChange();
  17659. };
  17660. this.removeSelectedItems = function () {
  17661. _this.items = _this.items.filter(function (item) {
  17662. return !item.selected;
  17663. });
  17664. _this.applyChange();
  17665. };
  17666. this.removeErrorItems = function () {
  17667. _this.items = _this.items.filter(function (item) {
  17668. return !item.error;
  17669. });
  17670. _this.applyChange();
  17671. };
  17672. this.removeAllItems = function () {
  17673. _this.items = [];
  17674. _this.applyChange();
  17675. };
  17676. this.setMediaItemState = function (id, state) {
  17677. _this.items = _this.items.map(function (item) {
  17678. return item.id === id ? _extends({}, item, state) : item;
  17679. });
  17680. _this.applyChange();
  17681. };
  17682. this.reuploadErrorItems = function () {
  17683. _this.uploadItems(true);
  17684. };
  17685. this.uploadItems = function () {
  17686. var ignoreError = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17687. _this.items.forEach(function (item, index) {
  17688. if (item.uploading || item.url) {
  17689. return false;
  17690. }
  17691. if (!ignoreError && item.error) {
  17692. return false;
  17693. }
  17694. if (item.type === 'IMAGE') {
  17695. _this.createThumbnail(item);
  17696. _this.uploadFn = _this.uploadFn || _this.createInlineImage;
  17697. } else if (!_this.uploadFn) {
  17698. _this.setMediaItemState(item.id, { error: 1 });
  17699. return false;
  17700. }
  17701. _this.setMediaItemState(item.id, {
  17702. uploading: true,
  17703. uploadProgress: 0,
  17704. error: 0
  17705. });
  17706. _this.uploadFn({
  17707. id: item.id,
  17708. file: item.file,
  17709. success: function success(res) {
  17710. _this.handleUploadSuccess(item.id, res);
  17711. },
  17712. progress: function progress(_progress) {
  17713. _this.setMediaItemState(item.id, {
  17714. uploading: true,
  17715. uploadProgress: _progress
  17716. });
  17717. },
  17718. error: function error(_error) {
  17719. _this.setMediaItemState(item.id, {
  17720. uploading: false,
  17721. error: 2
  17722. });
  17723. }
  17724. });
  17725. });
  17726. };
  17727. this.createThumbnail = function (_ref) {
  17728. var id = _ref.id,
  17729. file = _ref.file;
  17730. (0, _image.compressImage)(URL.createObjectURL(file), 226, 226).then(function (result) {
  17731. _this.setMediaItemState(id, { thumbnail: result.url });
  17732. });
  17733. };
  17734. this.createInlineImage = function (param) {
  17735. (0, _image.compressImage)(URL.createObjectURL(param.file), 1280, 800).then(function (result) {
  17736. param.success({ url: result.url });
  17737. }).catch(function (error) {
  17738. param.error(error);
  17739. });
  17740. };
  17741. this.handleUploadSuccess = function (id, data) {
  17742. _this.setMediaItemState(id, _extends({}, data, {
  17743. file: null,
  17744. uploadProgress: 1,
  17745. uploading: false,
  17746. selected: false
  17747. }));
  17748. var item = _this.getMediaItem(data.id || id);
  17749. item.onReady && item.onReady(item);
  17750. };
  17751. this.applyChange = function () {
  17752. _this.changeListeners.forEach(function (_ref2) {
  17753. var callback = _ref2.callback;
  17754. return callback(_this.items);
  17755. });
  17756. };
  17757. this.uploadImage = function (file, callback) {
  17758. var fileId = new Date().getTime() + '_' + (0, _base.UniqueIndex)();
  17759. _this.addMediaItem({
  17760. type: 'IMAGE',
  17761. id: fileId,
  17762. file: file,
  17763. name: fileId,
  17764. size: file.size,
  17765. uploadProgress: 0,
  17766. uploading: false,
  17767. selected: false,
  17768. error: 0,
  17769. onReady: callback
  17770. });
  17771. };
  17772. this.uploadImageRecursively = function (files, callback) {
  17773. var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  17774. if (files[index] && files[index].type.indexOf('image') > -1) {
  17775. _this.uploadImage(files[index], function (image) {
  17776. callback && callback(image);
  17777. index < files.length - 1 && _this.uploadImageRecursively(files, callback, index + 1);
  17778. });
  17779. } else {
  17780. index < files.length - 1 && _this.uploadImageRecursively(files, callback, index + 1);
  17781. }
  17782. };
  17783. this.addResolvedFiles = function (param, index, accepts) {
  17784. var data = {
  17785. id: new Date().getTime() + '_' + (0, _base.UniqueIndex)(),
  17786. file: param.files[index],
  17787. name: param.files[index].name,
  17788. size: param.files[index].size,
  17789. uploadProgress: 0,
  17790. uploading: false,
  17791. selected: false,
  17792. error: 0,
  17793. onReady: function onReady(item) {
  17794. param.onItemReady && param.onItemReady(item);
  17795. }
  17796. };
  17797. if (param.files[index].type.indexOf('image/') === 0 && accepts.image) {
  17798. data.type = 'IMAGE';
  17799. _this.addMediaItem(data);
  17800. } else if (param.files[index].type.indexOf('video/') === 0 && accepts.video) {
  17801. data.type = 'VIDEO';
  17802. _this.addMediaItem(data);
  17803. } else if (param.files[index].type.indexOf('audio/') === 0 && accepts.audio) {
  17804. data.type = 'AUDIO';
  17805. _this.addMediaItem(data);
  17806. }
  17807. setTimeout(function () {
  17808. _this.resolveFiles(param, index + 1, accepts);
  17809. }, 60);
  17810. };
  17811. this.resolveFiles = function (param, index, accepts) {
  17812. if (index < param.files.length) {
  17813. var validateResult = _this.validateFn(param.files[index]);
  17814. if (validateResult instanceof Promise) {
  17815. validateResult.then(function () {
  17816. _this.addResolvedFiles(param, index, accepts);
  17817. });
  17818. } else if (validateResult) {
  17819. _this.addResolvedFiles(param, index, accepts);
  17820. }
  17821. } else {
  17822. param.onAllReady && param.onAllReady();
  17823. }
  17824. };
  17825. this.onChange = function (callback) {
  17826. var listenerId = (0, _base.UniqueIndex)();
  17827. _this.changeListeners.push({
  17828. id: listenerId,
  17829. callback: callback
  17830. });
  17831. return listenerId;
  17832. };
  17833. this.offChange = function (listenerId) {
  17834. _this.changeListeners = _this.changeListeners.filter(function (_ref3) {
  17835. var id = _ref3.id;
  17836. return id !== listenerId;
  17837. });
  17838. };
  17839. };
  17840. exports.default = BraftFinderController;
  17841. /***/ }),
  17842. /* 20 */
  17843. /***/ (function(module, exports, __webpack_require__) {
  17844. Object.defineProperty(exports, "__esModule", {
  17845. value: true
  17846. });
  17847. exports.ImageUtils = undefined;
  17848. 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; };
  17849. var _react = __webpack_require__(2);
  17850. var _react2 = _interopRequireDefault(_react);
  17851. var _controller = __webpack_require__(19);
  17852. var _controller2 = _interopRequireDefault(_controller);
  17853. var _view = __webpack_require__(18);
  17854. var _view2 = _interopRequireDefault(_view);
  17855. var _languages = __webpack_require__(10);
  17856. var _languages2 = _interopRequireDefault(_languages);
  17857. var _image = __webpack_require__(0);
  17858. var ImageUtils = _interopRequireWildcard(_image);
  17859. 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; } }
  17860. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17861. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17862. 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; }
  17863. 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; }
  17864. var BraftFinder = function (_FinderController) {
  17865. _inherits(BraftFinder, _FinderController);
  17866. function BraftFinder(props) {
  17867. _classCallCheck(this, BraftFinder);
  17868. var _this = _possibleConstructorReturn(this, (BraftFinder.__proto__ || Object.getPrototypeOf(BraftFinder)).call(this, props));
  17869. _initialiseProps.call(_this);
  17870. _this.superProps = props;
  17871. return _this;
  17872. }
  17873. return BraftFinder;
  17874. }(_controller2.default);
  17875. var _initialiseProps = function _initialiseProps() {
  17876. var _this2 = this;
  17877. this.ReactComponent = function () {
  17878. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  17879. var componentProps = _extends({}, _this2.superProps, props);
  17880. var language = (typeof componentProps.language === 'function' ? componentProps.language(_languages2.default, 'braft-finder') : _languages2.default[componentProps.language]) || _languages2.default['zh'];
  17881. return _react2.default.createElement(_view2.default, _extends({}, componentProps, {
  17882. language: language,
  17883. controller: _this2
  17884. }));
  17885. };
  17886. };
  17887. exports.default = BraftFinder;
  17888. exports.ImageUtils = ImageUtils;
  17889. /***/ })
  17890. /******/ ]);
  17891. });
  17892. });
  17893. _commonjsHelpers.unwrapExports(dist$2);
  17894. var draftjsUtils$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  17895. !function(e,t){module.exports=t(Draft.Draft,immutable$2);}("undefined"!=typeof self?self:_commonjsHelpers.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);}])});
  17896. });
  17897. _commonjsHelpers.unwrapExports(draftjsUtils$1);
  17898. var draftjsUtils_1$1 = draftjsUtils$1.draftjsUtils;
  17899. var dist$3 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  17900. (function webpackUniversalModuleDefinition(root, factory) {
  17901. module.exports = factory(React__default, dist$1, Draft.Draft, immutable$2, dist, _reactDom_commonjsExternal.require$$3, dist$2, draftjsUtils$1);
  17902. })(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__) {
  17903. return /******/ (function(modules) { // webpackBootstrap
  17904. /******/ // The module cache
  17905. /******/ var installedModules = {};
  17906. /******/
  17907. /******/ // The require function
  17908. /******/ function __webpack_require__(moduleId) {
  17909. /******/
  17910. /******/ // Check if module is in cache
  17911. /******/ if(installedModules[moduleId]) {
  17912. /******/ return installedModules[moduleId].exports;
  17913. /******/ }
  17914. /******/ // Create a new module (and put it into the cache)
  17915. /******/ var module = installedModules[moduleId] = {
  17916. /******/ i: moduleId,
  17917. /******/ l: false,
  17918. /******/ exports: {}
  17919. /******/ };
  17920. /******/
  17921. /******/ // Execute the module function
  17922. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  17923. /******/
  17924. /******/ // Flag the module as loaded
  17925. /******/ module.l = true;
  17926. /******/
  17927. /******/ // Return the exports of the module
  17928. /******/ return module.exports;
  17929. /******/ }
  17930. /******/
  17931. /******/
  17932. /******/ // expose the modules object (__webpack_modules__)
  17933. /******/ __webpack_require__.m = modules;
  17934. /******/
  17935. /******/ // expose the module cache
  17936. /******/ __webpack_require__.c = installedModules;
  17937. /******/
  17938. /******/ // define getter function for harmony exports
  17939. /******/ __webpack_require__.d = function(exports, name, getter) {
  17940. /******/ if(!__webpack_require__.o(exports, name)) {
  17941. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  17942. /******/ }
  17943. /******/ };
  17944. /******/
  17945. /******/ // define __esModule on exports
  17946. /******/ __webpack_require__.r = function(exports) {
  17947. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  17948. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  17949. /******/ }
  17950. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  17951. /******/ };
  17952. /******/
  17953. /******/ // create a fake namespace object
  17954. /******/ // mode & 1: value is a module id, require it
  17955. /******/ // mode & 2: merge all properties of value into the ns
  17956. /******/ // mode & 4: return value when already ns object
  17957. /******/ // mode & 8|1: behave like require
  17958. /******/ __webpack_require__.t = function(value, mode) {
  17959. /******/ if(mode & 1) value = __webpack_require__(value);
  17960. /******/ if(mode & 8) return value;
  17961. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  17962. /******/ var ns = Object.create(null);
  17963. /******/ __webpack_require__.r(ns);
  17964. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  17965. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  17966. /******/ return ns;
  17967. /******/ };
  17968. /******/
  17969. /******/ // getDefaultExport function for compatibility with non-harmony modules
  17970. /******/ __webpack_require__.n = function(module) {
  17971. /******/ var getter = module && module.__esModule ?
  17972. /******/ function getDefault() { return module['default']; } :
  17973. /******/ function getModuleExports() { return module; };
  17974. /******/ __webpack_require__.d(getter, 'a', getter);
  17975. /******/ return getter;
  17976. /******/ };
  17977. /******/
  17978. /******/ // Object.prototype.hasOwnProperty.call
  17979. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  17980. /******/
  17981. /******/ // __webpack_public_path__
  17982. /******/ __webpack_require__.p = "/";
  17983. /******/
  17984. /******/
  17985. /******/ // Load entry module and return exports
  17986. /******/ return __webpack_require__(__webpack_require__.s = 39);
  17987. /******/ })
  17988. /************************************************************************/
  17989. /******/ ([
  17990. /* 0 */
  17991. /***/ (function(module, exports) {
  17992. module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
  17993. /***/ }),
  17994. /* 1 */
  17995. /***/ (function(module, exports) {
  17996. function _assertThisInitialized(self) {
  17997. if (self === void 0) {
  17998. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  17999. }
  18000. return self;
  18001. }
  18002. module.exports = _assertThisInitialized;
  18003. /***/ }),
  18004. /* 2 */
  18005. /***/ (function(module, exports) {
  18006. function _defineProperty(obj, key, value) {
  18007. if (key in obj) {
  18008. Object.defineProperty(obj, key, {
  18009. value: value,
  18010. enumerable: true,
  18011. configurable: true,
  18012. writable: true
  18013. });
  18014. } else {
  18015. obj[key] = value;
  18016. }
  18017. return obj;
  18018. }
  18019. module.exports = _defineProperty;
  18020. /***/ }),
  18021. /* 3 */
  18022. /***/ (function(module, exports) {
  18023. module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
  18024. /***/ }),
  18025. /* 4 */
  18026. /***/ (function(module, exports) {
  18027. function _classCallCheck(instance, Constructor) {
  18028. if (!(instance instanceof Constructor)) {
  18029. throw new TypeError("Cannot call a class as a function");
  18030. }
  18031. }
  18032. module.exports = _classCallCheck;
  18033. /***/ }),
  18034. /* 5 */
  18035. /***/ (function(module, exports, __webpack_require__) {
  18036. var defineProperty = __webpack_require__(2);
  18037. function _objectSpread(target) {
  18038. for (var i = 1; i < arguments.length; i++) {
  18039. var source = arguments[i] != null ? arguments[i] : {};
  18040. var ownKeys = Object.keys(source);
  18041. if (typeof Object.getOwnPropertySymbols === 'function') {
  18042. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  18043. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  18044. }));
  18045. }
  18046. ownKeys.forEach(function (key) {
  18047. defineProperty(target, key, source[key]);
  18048. });
  18049. }
  18050. return target;
  18051. }
  18052. module.exports = _objectSpread;
  18053. /***/ }),
  18054. /* 6 */
  18055. /***/ (function(module, exports) {
  18056. module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
  18057. /***/ }),
  18058. /* 7 */
  18059. /***/ (function(module, exports) {
  18060. function _defineProperties(target, props) {
  18061. for (var i = 0; i < props.length; i++) {
  18062. var descriptor = props[i];
  18063. descriptor.enumerable = descriptor.enumerable || false;
  18064. descriptor.configurable = true;
  18065. if ("value" in descriptor) descriptor.writable = true;
  18066. Object.defineProperty(target, descriptor.key, descriptor);
  18067. }
  18068. }
  18069. function _createClass(Constructor, protoProps, staticProps) {
  18070. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  18071. if (staticProps) _defineProperties(Constructor, staticProps);
  18072. return Constructor;
  18073. }
  18074. module.exports = _createClass;
  18075. /***/ }),
  18076. /* 8 */
  18077. /***/ (function(module, exports, __webpack_require__) {
  18078. var _typeof = __webpack_require__(15);
  18079. var assertThisInitialized = __webpack_require__(1);
  18080. function _possibleConstructorReturn(self, call) {
  18081. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  18082. return call;
  18083. }
  18084. return assertThisInitialized(self);
  18085. }
  18086. module.exports = _possibleConstructorReturn;
  18087. /***/ }),
  18088. /* 9 */
  18089. /***/ (function(module, exports) {
  18090. function _getPrototypeOf(o) {
  18091. module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  18092. return o.__proto__ || Object.getPrototypeOf(o);
  18093. };
  18094. return _getPrototypeOf(o);
  18095. }
  18096. module.exports = _getPrototypeOf;
  18097. /***/ }),
  18098. /* 10 */
  18099. /***/ (function(module, exports, __webpack_require__) {
  18100. var setPrototypeOf = __webpack_require__(26);
  18101. function _inherits(subClass, superClass) {
  18102. if (typeof superClass !== "function" && superClass !== null) {
  18103. throw new TypeError("Super expression must either be null or a function");
  18104. }
  18105. subClass.prototype = Object.create(superClass && superClass.prototype, {
  18106. constructor: {
  18107. value: subClass,
  18108. writable: true,
  18109. configurable: true
  18110. }
  18111. });
  18112. if (superClass) setPrototypeOf(subClass, superClass);
  18113. }
  18114. module.exports = _inherits;
  18115. /***/ }),
  18116. /* 11 */
  18117. /***/ (function(module, exports) {
  18118. function _extends() {
  18119. module.exports = _extends = Object.assign || function (target) {
  18120. for (var i = 1; i < arguments.length; i++) {
  18121. var source = arguments[i];
  18122. for (var key in source) {
  18123. if (Object.prototype.hasOwnProperty.call(source, key)) {
  18124. target[key] = source[key];
  18125. }
  18126. }
  18127. }
  18128. return target;
  18129. };
  18130. return _extends.apply(this, arguments);
  18131. }
  18132. module.exports = _extends;
  18133. /***/ }),
  18134. /* 12 */
  18135. /***/ (function(module, exports, __webpack_require__) {
  18136. var arrayWithoutHoles = __webpack_require__(27);
  18137. var iterableToArray = __webpack_require__(28);
  18138. var nonIterableSpread = __webpack_require__(29);
  18139. function _toConsumableArray(arr) {
  18140. return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
  18141. }
  18142. module.exports = _toConsumableArray;
  18143. /***/ }),
  18144. /* 13 */
  18145. /***/ (function(module, exports) {
  18146. module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
  18147. /***/ }),
  18148. /* 14 */
  18149. /***/ (function(module, exports) {
  18150. module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
  18151. /***/ }),
  18152. /* 15 */
  18153. /***/ (function(module, exports) {
  18154. 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); }
  18155. function _typeof(obj) {
  18156. if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
  18157. module.exports = _typeof = function _typeof(obj) {
  18158. return _typeof2(obj);
  18159. };
  18160. } else {
  18161. module.exports = _typeof = function _typeof(obj) {
  18162. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
  18163. };
  18164. }
  18165. return _typeof(obj);
  18166. }
  18167. module.exports = _typeof;
  18168. /***/ }),
  18169. /* 16 */
  18170. /***/ (function(module, exports) {
  18171. module.exports = __WEBPACK_EXTERNAL_MODULE__16__;
  18172. /***/ }),
  18173. /* 17 */
  18174. /***/ (function(module, exports) {
  18175. module.exports = __WEBPACK_EXTERNAL_MODULE__17__;
  18176. /***/ }),
  18177. /* 18 */
  18178. /***/ (function(module, exports, __webpack_require__) {
  18179. var Immutable = __webpack_require__(13);
  18180. var KEY_SEPARATOR = '-';
  18181. function MultiDecorator(decorators) {
  18182. this.decorators = Immutable.List(decorators);
  18183. }
  18184. /**
  18185. Return list of decoration IDs per character
  18186. @param {ContentBlock}
  18187. @return {List<String>}
  18188. */
  18189. MultiDecorator.prototype.getDecorations = function(block) {
  18190. var decorations = Array(block.getText().length).fill(null);
  18191. this.decorators.forEach(function(decorator, i) {
  18192. var _decorations = decorator.getDecorations(block);
  18193. _decorations.forEach(function(key, offset) {
  18194. if (!key) {
  18195. return;
  18196. }
  18197. key = i + KEY_SEPARATOR + key;
  18198. decorations[offset] = key;
  18199. });
  18200. });
  18201. return Immutable.List(decorations);
  18202. };
  18203. /**
  18204. Return component to render a decoration
  18205. @param {String}
  18206. @return {Function}
  18207. */
  18208. MultiDecorator.prototype.getComponentForKey = function(key) {
  18209. var decorator = this.getDecoratorForKey(key);
  18210. return decorator.getComponentForKey(
  18211. this.getInnerKey(key)
  18212. );
  18213. };
  18214. /**
  18215. Return props to render a decoration
  18216. @param {String}
  18217. @return {Object}
  18218. */
  18219. MultiDecorator.prototype.getPropsForKey = function(key) {
  18220. var decorator = this.getDecoratorForKey(key);
  18221. return decorator.getPropsForKey(
  18222. this.getInnerKey(key)
  18223. );
  18224. };
  18225. /**
  18226. Return a decorator for a specific key
  18227. @param {String}
  18228. @return {Decorator}
  18229. */
  18230. MultiDecorator.prototype.getDecoratorForKey = function(key) {
  18231. var parts = key.split(KEY_SEPARATOR);
  18232. var index = Number(parts[0]);
  18233. return this.decorators.get(index);
  18234. };
  18235. /**
  18236. Return inner key for a decorator
  18237. @param {String}
  18238. @return {String}
  18239. */
  18240. MultiDecorator.prototype.getInnerKey = function(key) {
  18241. var parts = key.split(KEY_SEPARATOR);
  18242. return parts.slice(1).join(KEY_SEPARATOR);
  18243. };
  18244. module.exports = MultiDecorator;
  18245. /***/ }),
  18246. /* 19 */
  18247. /***/ (function(module, exports, __webpack_require__) {
  18248. /**
  18249. * Copyright (c) 2013-present, Facebook, Inc.
  18250. * All rights reserved.
  18251. *
  18252. * This source code is licensed under the BSD-style license found in the
  18253. * LICENSE file in the root directory of this source tree. An additional grant
  18254. * of patent rights can be found in the PATENTS file in the same directory.
  18255. *
  18256. * @providesModule CharacterMetadata
  18257. * @format
  18258. *
  18259. */
  18260. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18261. 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; }
  18262. 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; }
  18263. var _require = __webpack_require__(13),
  18264. Map = _require.Map,
  18265. OrderedSet = _require.OrderedSet,
  18266. Record = _require.Record;
  18267. // Immutable.map is typed such that the value for every key in the map
  18268. // must be the same type
  18269. var EMPTY_SET = OrderedSet();
  18270. var defaultRecord = {
  18271. style: EMPTY_SET,
  18272. entity: null
  18273. };
  18274. var CharacterMetadataRecord = Record(defaultRecord);
  18275. var CharacterMetadata = function (_CharacterMetadataRec) {
  18276. _inherits(CharacterMetadata, _CharacterMetadataRec);
  18277. function CharacterMetadata() {
  18278. _classCallCheck(this, CharacterMetadata);
  18279. return _possibleConstructorReturn(this, _CharacterMetadataRec.apply(this, arguments));
  18280. }
  18281. CharacterMetadata.prototype.getStyle = function getStyle() {
  18282. return this.get('style');
  18283. };
  18284. CharacterMetadata.prototype.getEntity = function getEntity() {
  18285. return this.get('entity');
  18286. };
  18287. CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
  18288. return this.getStyle().includes(style);
  18289. };
  18290. CharacterMetadata.applyStyle = function applyStyle(record, style) {
  18291. var withStyle = record.set('style', record.getStyle().add(style));
  18292. return CharacterMetadata.create(withStyle);
  18293. };
  18294. CharacterMetadata.removeStyle = function removeStyle(record, style) {
  18295. var withoutStyle = record.set('style', record.getStyle().remove(style));
  18296. return CharacterMetadata.create(withoutStyle);
  18297. };
  18298. CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
  18299. var withEntity = record.getEntity() === entityKey ? record : record.set('entity', entityKey);
  18300. return CharacterMetadata.create(withEntity);
  18301. };
  18302. /**
  18303. * Use this function instead of the `CharacterMetadata` constructor.
  18304. * Since most content generally uses only a very small number of
  18305. * style/entity permutations, we can reuse these objects as often as
  18306. * possible.
  18307. */
  18308. CharacterMetadata.create = function create(config) {
  18309. if (!config) {
  18310. return EMPTY;
  18311. }
  18312. var defaultConfig = {
  18313. style: EMPTY_SET,
  18314. entity: null
  18315. };
  18316. // Fill in unspecified properties, if necessary.
  18317. var configMap = Map(defaultConfig).merge(config);
  18318. var existing = pool.get(configMap);
  18319. if (existing) {
  18320. return existing;
  18321. }
  18322. var newCharacter = new CharacterMetadata(configMap);
  18323. pool = pool.set(configMap, newCharacter);
  18324. return newCharacter;
  18325. };
  18326. return CharacterMetadata;
  18327. }(CharacterMetadataRecord);
  18328. var EMPTY = new CharacterMetadata();
  18329. var pool = Map([[Map(defaultRecord), EMPTY]]);
  18330. CharacterMetadata.EMPTY = EMPTY;
  18331. module.exports = CharacterMetadata;
  18332. /***/ }),
  18333. /* 20 */
  18334. /***/ (function(module, exports, __webpack_require__) {
  18335. /**
  18336. * Copyright (c) 2013-present, Facebook, Inc.
  18337. * All rights reserved.
  18338. *
  18339. * This source code is licensed under the BSD-style license found in the
  18340. * LICENSE file in the root directory of this source tree. An additional grant
  18341. * of patent rights can be found in the PATENTS file in the same directory.
  18342. *
  18343. * @providesModule findRangesImmutable
  18344. * @format
  18345. *
  18346. */
  18347. /**
  18348. * Search through an array to find contiguous stretches of elements that
  18349. * match a specified filter function.
  18350. *
  18351. * When ranges are found, execute a specified `found` function to supply
  18352. * the values to the caller.
  18353. */
  18354. function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
  18355. if (!haystack.size) {
  18356. return;
  18357. }
  18358. var cursor = 0;
  18359. haystack.reduce(function (value, nextValue, nextIndex) {
  18360. if (!areEqualFn(value, nextValue)) {
  18361. if (filterFn(value)) {
  18362. foundFn(cursor, nextIndex);
  18363. }
  18364. cursor = nextIndex;
  18365. }
  18366. return nextValue;
  18367. });
  18368. filterFn(haystack.last()) && foundFn(cursor, haystack.count());
  18369. }
  18370. module.exports = findRangesImmutable;
  18371. /***/ }),
  18372. /* 21 */
  18373. /***/ (function(module, exports, __webpack_require__) {
  18374. var objectWithoutPropertiesLoose = __webpack_require__(25);
  18375. function _objectWithoutProperties(source, excluded) {
  18376. if (source == null) return {};
  18377. var target = objectWithoutPropertiesLoose(source, excluded);
  18378. var key, i;
  18379. if (Object.getOwnPropertySymbols) {
  18380. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  18381. for (i = 0; i < sourceSymbolKeys.length; i++) {
  18382. key = sourceSymbolKeys[i];
  18383. if (excluded.indexOf(key) >= 0) continue;
  18384. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  18385. target[key] = source[key];
  18386. }
  18387. }
  18388. return target;
  18389. }
  18390. module.exports = _objectWithoutProperties;
  18391. /***/ }),
  18392. /* 22 */
  18393. /***/ (function(module, exports, __webpack_require__) {
  18394. /**
  18395. * Copyright (c) 2013-present, Facebook, Inc.
  18396. * All rights reserved.
  18397. *
  18398. * This source code is licensed under the BSD-style license found in the
  18399. * LICENSE file in the root directory of this source tree. An additional grant
  18400. * of patent rights can be found in the PATENTS file in the same directory.
  18401. *
  18402. * @providesModule getFragmentFromSelection
  18403. * @format
  18404. *
  18405. */
  18406. var getContentStateFragment = __webpack_require__(30);
  18407. function getFragmentFromSelection(editorState) {
  18408. var selectionState = editorState.getSelection();
  18409. if (selectionState.isCollapsed()) {
  18410. return null;
  18411. }
  18412. return getContentStateFragment(editorState.getCurrentContent(), selectionState);
  18413. }
  18414. module.exports = getFragmentFromSelection;
  18415. /***/ }),
  18416. /* 23 */
  18417. /***/ (function(module, exports) {
  18418. module.exports = __WEBPACK_EXTERNAL_MODULE__23__;
  18419. /***/ }),
  18420. /* 24 */
  18421. /***/ (function(module, exports, __webpack_require__) {
  18422. var arrayWithHoles = __webpack_require__(36);
  18423. var iterableToArrayLimit = __webpack_require__(37);
  18424. var nonIterableRest = __webpack_require__(38);
  18425. function _slicedToArray(arr, i) {
  18426. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();
  18427. }
  18428. module.exports = _slicedToArray;
  18429. /***/ }),
  18430. /* 25 */
  18431. /***/ (function(module, exports) {
  18432. function _objectWithoutPropertiesLoose(source, excluded) {
  18433. if (source == null) return {};
  18434. var target = {};
  18435. var sourceKeys = Object.keys(source);
  18436. var key, i;
  18437. for (i = 0; i < sourceKeys.length; i++) {
  18438. key = sourceKeys[i];
  18439. if (excluded.indexOf(key) >= 0) continue;
  18440. target[key] = source[key];
  18441. }
  18442. return target;
  18443. }
  18444. module.exports = _objectWithoutPropertiesLoose;
  18445. /***/ }),
  18446. /* 26 */
  18447. /***/ (function(module, exports) {
  18448. function _setPrototypeOf(o, p) {
  18449. module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  18450. o.__proto__ = p;
  18451. return o;
  18452. };
  18453. return _setPrototypeOf(o, p);
  18454. }
  18455. module.exports = _setPrototypeOf;
  18456. /***/ }),
  18457. /* 27 */
  18458. /***/ (function(module, exports) {
  18459. function _arrayWithoutHoles(arr) {
  18460. if (Array.isArray(arr)) {
  18461. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  18462. arr2[i] = arr[i];
  18463. }
  18464. return arr2;
  18465. }
  18466. }
  18467. module.exports = _arrayWithoutHoles;
  18468. /***/ }),
  18469. /* 28 */
  18470. /***/ (function(module, exports) {
  18471. function _iterableToArray(iter) {
  18472. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  18473. }
  18474. module.exports = _iterableToArray;
  18475. /***/ }),
  18476. /* 29 */
  18477. /***/ (function(module, exports) {
  18478. function _nonIterableSpread() {
  18479. throw new TypeError("Invalid attempt to spread non-iterable instance");
  18480. }
  18481. module.exports = _nonIterableSpread;
  18482. /***/ }),
  18483. /* 30 */
  18484. /***/ (function(module, exports, __webpack_require__) {
  18485. /**
  18486. * Copyright (c) 2013-present, Facebook, Inc.
  18487. * All rights reserved.
  18488. *
  18489. * This source code is licensed under the BSD-style license found in the
  18490. * LICENSE file in the root directory of this source tree. An additional grant
  18491. * of patent rights can be found in the PATENTS file in the same directory.
  18492. *
  18493. * @providesModule getContentStateFragment
  18494. * @format
  18495. *
  18496. */
  18497. var randomizeBlockMapKeys = __webpack_require__(31);
  18498. var removeEntitiesAtEdges = __webpack_require__(34);
  18499. var getContentStateFragment = function getContentStateFragment(contentState, selectionState) {
  18500. var startKey = selectionState.getStartKey();
  18501. var startOffset = selectionState.getStartOffset();
  18502. var endKey = selectionState.getEndKey();
  18503. var endOffset = selectionState.getEndOffset();
  18504. // Edge entities should be stripped to ensure that we don't preserve
  18505. // invalid partial entities when the fragment is reused. We do, however,
  18506. // preserve entities that are entirely within the selection range.
  18507. var contentWithoutEdgeEntities = removeEntitiesAtEdges(contentState, selectionState);
  18508. var blockMap = contentWithoutEdgeEntities.getBlockMap();
  18509. var blockKeys = blockMap.keySeq();
  18510. var startIndex = blockKeys.indexOf(startKey);
  18511. var endIndex = blockKeys.indexOf(endKey) + 1;
  18512. return randomizeBlockMapKeys(blockMap.slice(startIndex, endIndex).map(function (block, blockKey) {
  18513. var text = block.getText();
  18514. var chars = block.getCharacterList();
  18515. if (startKey === endKey) {
  18516. return block.merge({
  18517. text: text.slice(startOffset, endOffset),
  18518. characterList: chars.slice(startOffset, endOffset)
  18519. });
  18520. }
  18521. if (blockKey === startKey) {
  18522. return block.merge({
  18523. text: text.slice(startOffset),
  18524. characterList: chars.slice(startOffset)
  18525. });
  18526. }
  18527. if (blockKey === endKey) {
  18528. return block.merge({
  18529. text: text.slice(0, endOffset),
  18530. characterList: chars.slice(0, endOffset)
  18531. });
  18532. }
  18533. return block;
  18534. }));
  18535. };
  18536. module.exports = getContentStateFragment;
  18537. /***/ }),
  18538. /* 31 */
  18539. /***/ (function(module, exports, __webpack_require__) {
  18540. /**
  18541. * Copyright (c) 2013-present, Facebook, Inc.
  18542. * All rights reserved.
  18543. *
  18544. * This source code is licensed under the BSD-style license found in the
  18545. * LICENSE file in the root directory of this source tree. An additional grant
  18546. * of patent rights can be found in the PATENTS file in the same directory.
  18547. *
  18548. * @providesModule randomizeBlockMapKeys
  18549. * @format
  18550. *
  18551. */
  18552. var ContentBlockNode = __webpack_require__(32);
  18553. var Immutable = __webpack_require__(13);
  18554. var generateRandomKey = __webpack_require__(33);
  18555. var OrderedMap = Immutable.OrderedMap;
  18556. var randomizeContentBlockNodeKeys = function randomizeContentBlockNodeKeys(blockMap) {
  18557. var newKeysRef = {};
  18558. // we keep track of root blocks in order to update subsequent sibling links
  18559. var lastRootBlock = void 0;
  18560. return OrderedMap(blockMap.withMutations(function (blockMapState) {
  18561. blockMapState.forEach(function (block, index) {
  18562. var oldKey = block.getKey();
  18563. var nextKey = block.getNextSiblingKey();
  18564. var prevKey = block.getPrevSiblingKey();
  18565. var childrenKeys = block.getChildKeys();
  18566. var parentKey = block.getParentKey();
  18567. // new key that we will use to build linking
  18568. var key = generateRandomKey();
  18569. // we will add it here to re-use it later
  18570. newKeysRef[oldKey] = key;
  18571. if (nextKey) {
  18572. var nextBlock = blockMapState.get(nextKey);
  18573. if (nextBlock) {
  18574. blockMapState.setIn([nextKey, 'prevSibling'], key);
  18575. } else {
  18576. // this can happen when generating random keys for fragments
  18577. blockMapState.setIn([oldKey, 'nextSibling'], null);
  18578. }
  18579. }
  18580. if (prevKey) {
  18581. var prevBlock = blockMapState.get(prevKey);
  18582. if (prevBlock) {
  18583. blockMapState.setIn([prevKey, 'nextSibling'], key);
  18584. } else {
  18585. // this can happen when generating random keys for fragments
  18586. blockMapState.setIn([oldKey, 'prevSibling'], null);
  18587. }
  18588. }
  18589. if (parentKey && blockMapState.get(parentKey)) {
  18590. var parentBlock = blockMapState.get(parentKey);
  18591. var parentChildrenList = parentBlock.getChildKeys();
  18592. blockMapState.setIn([parentKey, 'children'], parentChildrenList.set(parentChildrenList.indexOf(block.getKey()), key));
  18593. } else {
  18594. // blocks will then be treated as root block nodes
  18595. blockMapState.setIn([oldKey, 'parent'], null);
  18596. if (lastRootBlock) {
  18597. blockMapState.setIn([lastRootBlock.getKey(), 'nextSibling'], key);
  18598. blockMapState.setIn([oldKey, 'prevSibling'], newKeysRef[lastRootBlock.getKey()]);
  18599. }
  18600. lastRootBlock = blockMapState.get(oldKey);
  18601. }
  18602. childrenKeys.forEach(function (childKey) {
  18603. var childBlock = blockMapState.get(childKey);
  18604. if (childBlock) {
  18605. blockMapState.setIn([childKey, 'parent'], key);
  18606. } else {
  18607. blockMapState.setIn([oldKey, 'children'], block.getChildKeys().filter(function (child) {
  18608. return child !== childKey;
  18609. }));
  18610. }
  18611. });
  18612. });
  18613. }).toArray().map(function (block) {
  18614. return [newKeysRef[block.getKey()], block.set('key', newKeysRef[block.getKey()])];
  18615. }));
  18616. };
  18617. var randomizeContentBlockKeys = function randomizeContentBlockKeys(blockMap) {
  18618. return OrderedMap(blockMap.toArray().map(function (block) {
  18619. var key = generateRandomKey();
  18620. return [key, block.set('key', key)];
  18621. }));
  18622. };
  18623. var randomizeBlockMapKeys = function randomizeBlockMapKeys(blockMap) {
  18624. var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode;
  18625. if (!isTreeBasedBlockMap) {
  18626. return randomizeContentBlockKeys(blockMap);
  18627. }
  18628. return randomizeContentBlockNodeKeys(blockMap);
  18629. };
  18630. module.exports = randomizeBlockMapKeys;
  18631. /***/ }),
  18632. /* 32 */
  18633. /***/ (function(module, exports, __webpack_require__) {
  18634. /**
  18635. * Copyright (c) 2013-present, Facebook, Inc.
  18636. * All rights reserved.
  18637. *
  18638. * This source code is licensed under the BSD-style license found in the
  18639. * LICENSE file in the root directory of this source tree. An additional grant
  18640. * of patent rights can be found in the PATENTS file in the same directory.
  18641. *
  18642. * @providesModule ContentBlockNode
  18643. * @format
  18644. *
  18645. *
  18646. * This file is a fork of ContentBlock adding support for nesting references by
  18647. * providing links to children, parent, prevSibling, and nextSibling.
  18648. *
  18649. * This is unstable and not part of the public API and should not be used by
  18650. * production systems. This file may be update/removed without notice.
  18651. */
  18652. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18653. 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; }
  18654. 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; }
  18655. var CharacterMetadata = __webpack_require__(19);
  18656. var Immutable = __webpack_require__(13);
  18657. var findRangesImmutable = __webpack_require__(20);
  18658. var List = Immutable.List,
  18659. Map = Immutable.Map,
  18660. OrderedSet = Immutable.OrderedSet,
  18661. Record = Immutable.Record,
  18662. Repeat = Immutable.Repeat;
  18663. var EMPTY_SET = OrderedSet();
  18664. var defaultRecord = {
  18665. parent: null,
  18666. characterList: List(),
  18667. data: Map(),
  18668. depth: 0,
  18669. key: '',
  18670. text: '',
  18671. type: 'unstyled',
  18672. children: List(),
  18673. prevSibling: null,
  18674. nextSibling: null
  18675. };
  18676. var haveEqualStyle = function haveEqualStyle(charA, charB) {
  18677. return charA.getStyle() === charB.getStyle();
  18678. };
  18679. var haveEqualEntity = function haveEqualEntity(charA, charB) {
  18680. return charA.getEntity() === charB.getEntity();
  18681. };
  18682. var decorateCharacterList = function decorateCharacterList(config) {
  18683. if (!config) {
  18684. return config;
  18685. }
  18686. var characterList = config.characterList,
  18687. text = config.text;
  18688. if (text && !characterList) {
  18689. config.characterList = List(Repeat(CharacterMetadata.EMPTY, text.length));
  18690. }
  18691. return config;
  18692. };
  18693. var ContentBlockNode = function (_Record) {
  18694. _inherits(ContentBlockNode, _Record);
  18695. function ContentBlockNode() {
  18696. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultRecord;
  18697. _classCallCheck(this, ContentBlockNode);
  18698. return _possibleConstructorReturn(this, _Record.call(this, decorateCharacterList(props)));
  18699. }
  18700. ContentBlockNode.prototype.getKey = function getKey() {
  18701. return this.get('key');
  18702. };
  18703. ContentBlockNode.prototype.getType = function getType() {
  18704. return this.get('type');
  18705. };
  18706. ContentBlockNode.prototype.getText = function getText() {
  18707. return this.get('text');
  18708. };
  18709. ContentBlockNode.prototype.getCharacterList = function getCharacterList() {
  18710. return this.get('characterList');
  18711. };
  18712. ContentBlockNode.prototype.getLength = function getLength() {
  18713. return this.getText().length;
  18714. };
  18715. ContentBlockNode.prototype.getDepth = function getDepth() {
  18716. return this.get('depth');
  18717. };
  18718. ContentBlockNode.prototype.getData = function getData() {
  18719. return this.get('data');
  18720. };
  18721. ContentBlockNode.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
  18722. var character = this.getCharacterList().get(offset);
  18723. return character ? character.getStyle() : EMPTY_SET;
  18724. };
  18725. ContentBlockNode.prototype.getEntityAt = function getEntityAt(offset) {
  18726. var character = this.getCharacterList().get(offset);
  18727. return character ? character.getEntity() : null;
  18728. };
  18729. ContentBlockNode.prototype.getChildKeys = function getChildKeys() {
  18730. return this.get('children');
  18731. };
  18732. ContentBlockNode.prototype.getParentKey = function getParentKey() {
  18733. return this.get('parent');
  18734. };
  18735. ContentBlockNode.prototype.getPrevSiblingKey = function getPrevSiblingKey() {
  18736. return this.get('prevSibling');
  18737. };
  18738. ContentBlockNode.prototype.getNextSiblingKey = function getNextSiblingKey() {
  18739. return this.get('nextSibling');
  18740. };
  18741. ContentBlockNode.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
  18742. findRangesImmutable(this.getCharacterList(), haveEqualStyle, filterFn, callback);
  18743. };
  18744. ContentBlockNode.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
  18745. findRangesImmutable(this.getCharacterList(), haveEqualEntity, filterFn, callback);
  18746. };
  18747. return ContentBlockNode;
  18748. }(Record(defaultRecord));
  18749. module.exports = ContentBlockNode;
  18750. /***/ }),
  18751. /* 33 */
  18752. /***/ (function(module, exports, __webpack_require__) {
  18753. /**
  18754. * Copyright (c) 2013-present, Facebook, Inc.
  18755. * All rights reserved.
  18756. *
  18757. * This source code is licensed under the BSD-style license found in the
  18758. * LICENSE file in the root directory of this source tree. An additional grant
  18759. * of patent rights can be found in the PATENTS file in the same directory.
  18760. *
  18761. * @providesModule generateRandomKey
  18762. * @format
  18763. *
  18764. */
  18765. var seenKeys = {};
  18766. var MULTIPLIER = Math.pow(2, 24);
  18767. function generateRandomKey() {
  18768. var key = void 0;
  18769. while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
  18770. key = Math.floor(Math.random() * MULTIPLIER).toString(32);
  18771. }
  18772. seenKeys[key] = true;
  18773. return key;
  18774. }
  18775. module.exports = generateRandomKey;
  18776. /***/ }),
  18777. /* 34 */
  18778. /***/ (function(module, exports, __webpack_require__) {
  18779. /**
  18780. * Copyright (c) 2013-present, Facebook, Inc.
  18781. * All rights reserved.
  18782. *
  18783. * This source code is licensed under the BSD-style license found in the
  18784. * LICENSE file in the root directory of this source tree. An additional grant
  18785. * of patent rights can be found in the PATENTS file in the same directory.
  18786. *
  18787. * @providesModule removeEntitiesAtEdges
  18788. * @format
  18789. *
  18790. */
  18791. var CharacterMetadata = __webpack_require__(19);
  18792. var findRangesImmutable = __webpack_require__(20);
  18793. var invariant = __webpack_require__(35);
  18794. function removeEntitiesAtEdges(contentState, selectionState) {
  18795. var blockMap = contentState.getBlockMap();
  18796. var entityMap = contentState.getEntityMap();
  18797. var updatedBlocks = {};
  18798. var startKey = selectionState.getStartKey();
  18799. var startOffset = selectionState.getStartOffset();
  18800. var startBlock = blockMap.get(startKey);
  18801. var updatedStart = removeForBlock(entityMap, startBlock, startOffset);
  18802. if (updatedStart !== startBlock) {
  18803. updatedBlocks[startKey] = updatedStart;
  18804. }
  18805. var endKey = selectionState.getEndKey();
  18806. var endOffset = selectionState.getEndOffset();
  18807. var endBlock = blockMap.get(endKey);
  18808. if (startKey === endKey) {
  18809. endBlock = updatedStart;
  18810. }
  18811. var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
  18812. if (updatedEnd !== endBlock) {
  18813. updatedBlocks[endKey] = updatedEnd;
  18814. }
  18815. if (!Object.keys(updatedBlocks).length) {
  18816. return contentState.set('selectionAfter', selectionState);
  18817. }
  18818. return contentState.merge({
  18819. blockMap: blockMap.merge(updatedBlocks),
  18820. selectionAfter: selectionState
  18821. });
  18822. }
  18823. function getRemovalRange(characters, key, offset) {
  18824. var removalRange;
  18825. findRangesImmutable(characters, function (a, b) {
  18826. return a.getEntity() === b.getEntity();
  18827. }, function (element) {
  18828. return element.getEntity() === key;
  18829. }, function (start, end) {
  18830. if (start <= offset && end >= offset) {
  18831. removalRange = { start: start, end: end };
  18832. }
  18833. });
  18834. !(typeof removalRange === 'object') ? invariant(false) : void 0;
  18835. return removalRange;
  18836. }
  18837. function removeForBlock(entityMap, block, offset) {
  18838. var chars = block.getCharacterList();
  18839. var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
  18840. var charAfter = offset < chars.count() ? chars.get(offset) : undefined;
  18841. var entityBeforeCursor = charBefore ? charBefore.getEntity() : undefined;
  18842. var entityAfterCursor = charAfter ? charAfter.getEntity() : undefined;
  18843. if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
  18844. var entity = entityMap.__get(entityAfterCursor);
  18845. if (entity.getMutability() !== 'MUTABLE') {
  18846. var _getRemovalRange = getRemovalRange(chars, entityAfterCursor, offset),
  18847. start = _getRemovalRange.start,
  18848. end = _getRemovalRange.end;
  18849. var current;
  18850. while (start < end) {
  18851. current = chars.get(start);
  18852. chars = chars.set(start, CharacterMetadata.applyEntity(current, null));
  18853. start++;
  18854. }
  18855. return block.set('characterList', chars);
  18856. }
  18857. }
  18858. return block;
  18859. }
  18860. module.exports = removeEntitiesAtEdges;
  18861. /***/ }),
  18862. /* 35 */
  18863. /***/ (function(module, exports, __webpack_require__) {
  18864. function invariant(condition, format, a, b, c, d, e, f) {
  18865. if (!condition) {
  18866. var error;
  18867. if (format === undefined) {
  18868. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  18869. } else {
  18870. var args = [a, b, c, d, e, f];
  18871. var argIndex = 0;
  18872. error = new Error(format.replace(/%s/g, function () {
  18873. return args[argIndex++];
  18874. }));
  18875. error.name = 'Invariant Violation';
  18876. }
  18877. error.framesToPop = 1; // we don't care about invariant's own frame
  18878. throw error;
  18879. }
  18880. }
  18881. module.exports = invariant;
  18882. /***/ }),
  18883. /* 36 */
  18884. /***/ (function(module, exports) {
  18885. function _arrayWithHoles(arr) {
  18886. if (Array.isArray(arr)) return arr;
  18887. }
  18888. module.exports = _arrayWithHoles;
  18889. /***/ }),
  18890. /* 37 */
  18891. /***/ (function(module, exports) {
  18892. function _iterableToArrayLimit(arr, i) {
  18893. var _arr = [];
  18894. var _n = true;
  18895. var _d = false;
  18896. var _e = undefined;
  18897. try {
  18898. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  18899. _arr.push(_s.value);
  18900. if (i && _arr.length === i) break;
  18901. }
  18902. } catch (err) {
  18903. _d = true;
  18904. _e = err;
  18905. } finally {
  18906. try {
  18907. if (!_n && _i["return"] != null) _i["return"]();
  18908. } finally {
  18909. if (_d) throw _e;
  18910. }
  18911. }
  18912. return _arr;
  18913. }
  18914. module.exports = _iterableToArrayLimit;
  18915. /***/ }),
  18916. /* 38 */
  18917. /***/ (function(module, exports) {
  18918. function _nonIterableRest() {
  18919. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  18920. }
  18921. module.exports = _nonIterableRest;
  18922. /***/ }),
  18923. /* 39 */
  18924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18925. __webpack_require__.r(__webpack_exports__);
  18926. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/typeof.js
  18927. var helpers_typeof = __webpack_require__(15);
  18928. var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);
  18929. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectSpread.js
  18930. var objectSpread = __webpack_require__(5);
  18931. var objectSpread_default = /*#__PURE__*/__webpack_require__.n(objectSpread);
  18932. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectWithoutProperties.js
  18933. var objectWithoutProperties = __webpack_require__(21);
  18934. var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
  18935. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/classCallCheck.js
  18936. var classCallCheck = __webpack_require__(4);
  18937. var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);
  18938. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/createClass.js
  18939. var createClass = __webpack_require__(7);
  18940. var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);
  18941. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js
  18942. var possibleConstructorReturn = __webpack_require__(8);
  18943. var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn);
  18944. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/getPrototypeOf.js
  18945. var getPrototypeOf = __webpack_require__(9);
  18946. var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf);
  18947. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/inherits.js
  18948. var inherits = __webpack_require__(10);
  18949. var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits);
  18950. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/assertThisInitialized.js
  18951. var assertThisInitialized = __webpack_require__(1);
  18952. var assertThisInitialized_default = /*#__PURE__*/__webpack_require__.n(assertThisInitialized);
  18953. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/defineProperty.js
  18954. var defineProperty = __webpack_require__(2);
  18955. var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
  18956. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/toConsumableArray.js
  18957. var toConsumableArray = __webpack_require__(12);
  18958. var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
  18959. // EXTERNAL MODULE: ../node_modules/draft-js/dist/Draft.css
  18960. var Draft = __webpack_require__(40);
  18961. // EXTERNAL MODULE: ./assets/scss/_base.scss
  18962. var _base = __webpack_require__(42);
  18963. // EXTERNAL MODULE: external "react"
  18964. var external_react_ = __webpack_require__(0);
  18965. var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
  18966. // CONCATENATED MODULE: ./languages/en.js
  18967. /* harmony default export */ var en = ({
  18968. base: {
  18969. remove: 'Remove',
  18970. cancel: 'Cancel',
  18971. confirm: 'Confirm',
  18972. inert: 'Insert',
  18973. width: 'Width',
  18974. height: 'Height'
  18975. },
  18976. controls: {
  18977. clear: 'Clear',
  18978. undo: 'Undo',
  18979. redo: 'Redo',
  18980. fontSize: 'Font Size',
  18981. color: 'Color',
  18982. textColor: 'Text',
  18983. tempColors: 'Temp Colors',
  18984. backgroundColor: 'Background',
  18985. bold: 'Bold',
  18986. lineHeight: 'Line Height',
  18987. letterSpacing: 'Letter Spacing',
  18988. textIndent: 'Text Indent',
  18989. increaseIndent: 'Increase Indent',
  18990. decreaseIndent: 'Decrease Indent',
  18991. italic: 'Italic',
  18992. underline: 'Underline',
  18993. strikeThrough: 'Strike Through',
  18994. fontFamily: 'Font Family',
  18995. textAlign: 'Text Alignment',
  18996. alignLeft: 'Left Alignment',
  18997. alignCenter: 'Center Alignment',
  18998. alignRight: 'Right Alignment',
  18999. alignJustify: 'Justify Alignment',
  19000. floatLeft: 'Left Float',
  19001. floatRight: 'Right Float',
  19002. superScript: 'Super Script',
  19003. subScript: 'Sub Script',
  19004. removeStyles: 'Remove Styles',
  19005. headings: 'Headings',
  19006. header: 'Header',
  19007. normal: 'Normal',
  19008. orderedList: 'Ordered List',
  19009. unorderedList: 'Unordered List',
  19010. blockQuote: 'Quote',
  19011. code: 'Code',
  19012. link: 'Link',
  19013. unlink: 'Unlink',
  19014. hr: 'Horizontal Line',
  19015. media: 'Media',
  19016. mediaLibirary: 'Media Library',
  19017. emoji: 'Emoji',
  19018. fullscreen: 'Fullscreen',
  19019. exitFullscreen: 'Exit Fullscreen'
  19020. },
  19021. linkEditor: {
  19022. textInputPlaceHolder: 'Input link text',
  19023. linkInputPlaceHolder: 'Input link URL',
  19024. inputWithEnterPlaceHolder: 'Input link URL and press Enter',
  19025. openInNewWindow: 'Open in new window',
  19026. removeLink: 'Remove Link'
  19027. },
  19028. audioPlayer: {
  19029. title: 'Play Audio'
  19030. },
  19031. videoPlayer: {
  19032. title: 'Play Video',
  19033. embedTitle: 'Embed Media'
  19034. },
  19035. media: {
  19036. image: 'Image',
  19037. video: 'Video',
  19038. audio: 'Audio',
  19039. embed: 'Embed'
  19040. }
  19041. });
  19042. // CONCATENATED MODULE: ./languages/zh.js
  19043. /* harmony default export */ var zh = ({
  19044. base: {
  19045. remove: '删除',
  19046. cancel: '取消',
  19047. confirm: '确定',
  19048. inert: '插入',
  19049. width: '宽度',
  19050. height: '高度'
  19051. },
  19052. controls: {
  19053. clear: '清除内容',
  19054. undo: '撤销',
  19055. redo: '重做',
  19056. fontSize: '字号',
  19057. lineHeight: '行高',
  19058. letterSpacing: '字间距',
  19059. textIndent: '段落缩进',
  19060. increaseIndent: '增加缩进',
  19061. decreaseIndent: '减少缩进',
  19062. border: '边框',
  19063. color: '颜色',
  19064. textColor: '文字颜色',
  19065. backgroundColor: '背景颜色',
  19066. tempColors: '临时颜色',
  19067. bold: '加粗',
  19068. italic: '斜体',
  19069. underline: '下划线',
  19070. strikeThrough: '删除线',
  19071. fontFamily: '字体',
  19072. textAlign: '文本对齐',
  19073. alignLeft: '居左',
  19074. alignCenter: '居中',
  19075. alignRight: '居右',
  19076. alignJustify: '两端',
  19077. floatLeft: '左浮动',
  19078. floatRight: '右浮动',
  19079. superScript: '上标',
  19080. subScript: '下标',
  19081. removeStyles: '清除样式',
  19082. headings: '标题',
  19083. header: '标题',
  19084. normal: '常规',
  19085. orderedList: '有序列表',
  19086. unorderedList: '无序列表',
  19087. blockQuote: '引用',
  19088. code: '代码',
  19089. link: '链接',
  19090. unlink: '清除链接',
  19091. hr: '水平线',
  19092. media: '媒体',
  19093. mediaLibirary: '媒体库',
  19094. emoji: '小表情',
  19095. fullscreen: '全屏',
  19096. exitFullscreen: '退出全屏'
  19097. },
  19098. linkEditor: {
  19099. textInputPlaceHolder: '输入链接文字',
  19100. linkInputPlaceHolder: '输入链接地址',
  19101. inputWithEnterPlaceHolder: '输入链接地址并回车',
  19102. openInNewWindow: '在新窗口打开',
  19103. removeLink: '移除链接'
  19104. },
  19105. audioPlayer: {
  19106. title: '播放音频文件'
  19107. },
  19108. videoPlayer: {
  19109. title: '播放视频文件',
  19110. embedTitle: '嵌入式媒体'
  19111. },
  19112. media: {
  19113. image: '图像',
  19114. video: '视频',
  19115. audio: '音频',
  19116. embed: '嵌入式媒体'
  19117. }
  19118. });
  19119. // CONCATENATED MODULE: ./languages/zh-hant.js
  19120. /* harmony default export */ var zh_hant = ({
  19121. base: {
  19122. remove: '刪除',
  19123. cancel: '取消',
  19124. confirm: '確定',
  19125. inert: '插入',
  19126. width: '宽度',
  19127. height: '高度'
  19128. },
  19129. controls: {
  19130. clear: '清除内容',
  19131. undo: '撤銷',
  19132. redo: '重做',
  19133. fontSize: '字號',
  19134. color: '顏色',
  19135. textColor: '文字顏色',
  19136. backgroundColor: '背景顏色',
  19137. tempColors: '臨時顏色',
  19138. bold: '加粗',
  19139. lineHeight: '行高',
  19140. letterSpacing: '字間距',
  19141. textIndent: '段落縮進',
  19142. increaseIndent: '增加縮進',
  19143. decreaseIndent: '减少縮進',
  19144. border: '邊框',
  19145. italic: '斜體',
  19146. underline: '下劃線',
  19147. strikeThrough: '刪除線',
  19148. fontFamily: '字體',
  19149. textAlign: '文本對齊',
  19150. alignLeft: '居左',
  19151. alignCenter: '居中',
  19152. alignRight: '居右',
  19153. alignJustify: '兩端對齊',
  19154. floatLeft: '左浮動',
  19155. floatRight: '右浮動',
  19156. superScript: '上標',
  19157. subScript: '下標',
  19158. removeStyles: '清除样式',
  19159. headings: '標題',
  19160. header: '標題',
  19161. normal: '常規',
  19162. orderedList: '有序列表',
  19163. unorderedList: '無序列表',
  19164. blockQuote: '引用',
  19165. code: '代碼',
  19166. link: '鏈接',
  19167. unlink: '清除鏈接',
  19168. hr: '水平线',
  19169. media: '媒體',
  19170. mediaLibirary: '媒體库',
  19171. emoji: '小表情',
  19172. fullscreen: '全熒幕',
  19173. exitFullscreen: '退出全熒幕'
  19174. },
  19175. linkEditor: {
  19176. textInputPlaceHolder: '輸入鏈接文字',
  19177. linkInputPlaceHolder: '輸入鏈接地址',
  19178. inputWithEnterPlaceHolder: '輸入鏈接地址並回車',
  19179. openInNewWindow: '在新窗口打開',
  19180. removeLink: '移除鏈接'
  19181. },
  19182. audioPlayer: {
  19183. title: '播放音頻文件'
  19184. },
  19185. videoPlayer: {
  19186. title: '播放視頻文件',
  19187. embedTitle: '嵌入式媒體'
  19188. },
  19189. media: {
  19190. image: '圖像',
  19191. video: '視頻',
  19192. audio: '音頻',
  19193. embed: '嵌入式媒體'
  19194. }
  19195. });
  19196. // CONCATENATED MODULE: ./languages/pl.js
  19197. /* harmony default export */ var pl = ({
  19198. base: {
  19199. remove: 'Usuń',
  19200. cancel: 'Anuluj',
  19201. confirm: 'Potwierdź',
  19202. inert: 'Wstaw',
  19203. width: 'Szerokość',
  19204. height: 'Wysokość'
  19205. },
  19206. controls: {
  19207. clear: 'Wyczyść',
  19208. undo: 'Cofnij',
  19209. redo: 'Przywróć',
  19210. fontSize: 'Wielkość',
  19211. color: 'Kolor',
  19212. textColor: 'Kolor tekstu',
  19213. tempColors: 'Kolory',
  19214. backgroundColor: 'Tło',
  19215. bold: 'Pogrubienie',
  19216. lineHeight: 'Wysokość linii',
  19217. letterSpacing: 'Odstęp znaków',
  19218. textIndent: 'Wcięcie tekstu',
  19219. increaseIndent: 'Zwiększ wcięcie',
  19220. decreaseIndent: 'Zmniejsz wcięcie',
  19221. italic: 'Italiki',
  19222. underline: 'Podkreślenie',
  19223. strikeThrough: 'Przekreślenie',
  19224. fontFamily: 'Czcionka',
  19225. textAlign: 'Wyrównanie tekstu',
  19226. alignLeft: 'Do lewej',
  19227. alignCenter: 'Wycentruj',
  19228. alignRight: 'Do prawej',
  19229. alignJustify: 'Wyjustuj',
  19230. floatLeft: 'Do lewej',
  19231. floatRight: 'Do prawej',
  19232. superScript: 'Superskrypt',
  19233. subScript: 'Subskrypt',
  19234. removeStyles: 'Usuń stylowanie',
  19235. headings: 'Nagłówki',
  19236. header: 'Nagłówek',
  19237. normal: 'Normalny',
  19238. orderedList: 'Lista uporządkowana',
  19239. unorderedList: 'Lista nieuporządkowana',
  19240. blockQuote: 'Cytat',
  19241. code: 'Kod',
  19242. link: 'Link',
  19243. unlink: 'Usuń link',
  19244. hr: 'Linia pozioma',
  19245. media: 'Media',
  19246. mediaLibirary: 'Biblioteka mediów',
  19247. emoji: 'Emoji'
  19248. },
  19249. linkEditor: {
  19250. textInputPlaceHolder: 'Wpisz tekst linku',
  19251. linkInputPlaceHolder: 'Wpisz Adres URL',
  19252. inputWithEnterPlaceHolder: 'Wpisz adres URL i naciśnij Enter',
  19253. openInNewWindow: 'Otwórz w nowym oknie',
  19254. removeLink: 'Usuń link'
  19255. },
  19256. audioPlayer: {
  19257. title: 'Odtwórz audio'
  19258. },
  19259. videoPlayer: {
  19260. title: 'Odtwórz wideo',
  19261. embedTitle: 'Tytuł'
  19262. },
  19263. media: {
  19264. image: 'Obraz',
  19265. video: 'Wideo',
  19266. audio: 'Audio',
  19267. embed: 'Obiekt osadzony'
  19268. }
  19269. });
  19270. // CONCATENATED MODULE: ./languages/kr.js
  19271. /* harmony default export */ var kr = ({
  19272. base: {
  19273. remove: '삭제',
  19274. cancel: '취소',
  19275. confirm: '결정',
  19276. inert: '삽입',
  19277. width: '너비',
  19278. height: '높이'
  19279. },
  19280. controls: {
  19281. clear: '콘텐츠지우기',
  19282. undo: '취소',
  19283. redo: '다시하기',
  19284. fontSize: '글자크기',
  19285. lineHeight: '행높이',
  19286. letterSpacing: '단어간격',
  19287. textIndent: '단락들여쓰기',
  19288. increaseIndent: '들여쓰기늘리기',
  19289. decreaseIndent: '들여쓰기줄이기',
  19290. border: '국경',
  19291. color: '색상',
  19292. textColor: '텍스트색상',
  19293. backgroundColor: '배경색상',
  19294. tempColors: '임시색',
  19295. bold: '굵게',
  19296. italic: '기울임꼴',
  19297. underline: '밑줄',
  19298. strikeThrough: '취소선',
  19299. fontFamily: '글꼴',
  19300. textAlign: '텍스트정렬',
  19301. alignLeft: '왼쪽',
  19302. alignCenter: '중심',
  19303. alignRight: '오른쪽',
  19304. alignJustify: '양쪽끝',
  19305. floatLeft: '떠다니기',
  19306. floatRight: '오른쪽부동',
  19307. superScript: '위첨자',
  19308. subScript: '첨자',
  19309. removeStyles: '스타일지우기',
  19310. headings: '제목',
  19311. header: '제목',
  19312. normal: '재래식',
  19313. orderedList: '순서가지정된목록',
  19314. unorderedList: '정렬되지않은목록',
  19315. blockQuote: '참고문헌',
  19316. code: '코드',
  19317. link: '링크',
  19318. unlink: '링크삭제',
  19319. hr: '수평선',
  19320. media: '미디어',
  19321. mediaLibirary: '미디어라이브러리',
  19322. emoji: '작은표현',
  19323. fullscreen: '전체화면',
  19324. exitFullscreen: '전체화면종료'
  19325. },
  19326. linkEditor: {
  19327. textInputPlaceHolder: '링크텍스트입력',
  19328. linkInputPlaceHolder: '링크주소입력',
  19329. inputWithEnterPlaceHolder: '링크주소입력.',
  19330. openInNewWindow: '새창열기',
  19331. removeLink: '링크삭제'
  19332. },
  19333. audioPlayer: {
  19334. title: '오디오파일재생'
  19335. },
  19336. videoPlayer: {
  19337. title: '비디오파일재생',
  19338. embedTitle: '임베디드미디어'
  19339. },
  19340. media: {
  19341. image: '이미지',
  19342. video: '비디오',
  19343. audio: '오디오',
  19344. embed: '임베디드미디어'
  19345. }
  19346. });
  19347. // CONCATENATED MODULE: ./languages/tr.js
  19348. /* harmony default export */ var tr = ({
  19349. base: {
  19350. remove: 'Kaldır',
  19351. cancel: 'İptal',
  19352. confirm: 'Onayla',
  19353. inert: 'Ekle',
  19354. width: 'Genişlik',
  19355. height: 'Yükseklik'
  19356. },
  19357. controls: {
  19358. clear: 'Temizle',
  19359. undo: 'Geri al',
  19360. redo: 'İleri al',
  19361. fontSize: 'Yazı boyutu',
  19362. color: 'Renk',
  19363. textColor: 'Yazı rengi',
  19364. tempColors: 'Geçici renkler',
  19365. backgroundColor: 'Arkaplan',
  19366. bold: 'Kalın',
  19367. lineHeight: 'Satır yüksekliği',
  19368. letterSpacing: 'Harf aralığı',
  19369. textIndent: 'Çentik aralığı',
  19370. increaseIndent: 'Çentiği genişlet',
  19371. decreaseIndent: 'Çentiği daralt',
  19372. italic: 'Eğik',
  19373. underline: 'Altı çizili',
  19374. strikeThrough: 'Üstü çizili',
  19375. fontFamily: 'Yazı tipi',
  19376. textAlign: 'Metin Hizalama',
  19377. alignLeft: 'Sola hizala',
  19378. alignCenter: 'Ortaya hizala',
  19379. alignRight: 'Sağa hizala',
  19380. alignJustify: 'Her iki tarafa hizala',
  19381. floatLeft: 'Sola yatır',
  19382. floatRight: 'Sağa yatır',
  19383. superScript: 'Ana kod',
  19384. subScript: 'Alt kod',
  19385. removeStyles: 'Stilleri kaldır',
  19386. headings: 'Başlıklar',
  19387. header: 'Başlık',
  19388. normal: 'Normal',
  19389. orderedList: 'Sıralı liste',
  19390. unorderedList: 'Sırasız liste',
  19391. blockQuote: 'Alıntı',
  19392. code: 'Kod',
  19393. link: 'Bağlantı',
  19394. unlink: 'Bağlantıyı kaldır',
  19395. hr: 'Yatay çizgi',
  19396. media: 'Medya',
  19397. mediaLibirary: 'Kütüphane',
  19398. emoji: 'İfade',
  19399. fullscreen: 'Tam ekran',
  19400. exitFullscreen: 'Tam ekrandan çık'
  19401. },
  19402. linkEditor: {
  19403. textInputPlaceHolder: 'Bağlantı metnini girin',
  19404. linkInputPlaceHolder: 'Bağlantı URL\' si girin',
  19405. inputWithEnterPlaceHolder: 'Bağlantı URL\'si girin ve Enter\' a basın',
  19406. openInNewWindow: 'Yeni pencerede aç',
  19407. removeLink: 'Bağlantıyı kaldır'
  19408. },
  19409. audioPlayer: {
  19410. title: 'Ses çal'
  19411. },
  19412. videoPlayer: {
  19413. title: 'Görüntü oynat',
  19414. embedTitle: 'Görüntüyü göm'
  19415. },
  19416. media: {
  19417. image: 'Resim',
  19418. video: 'Görüntü',
  19419. audio: 'Ses',
  19420. embed: 'Gömülü nesne'
  19421. }
  19422. });
  19423. // CONCATENATED MODULE: ./languages/jpn.js
  19424. /* harmony default export */ var jpn = ({
  19425. base: {
  19426. remove: '削除',
  19427. cancel: 'キャンセル',
  19428. confirm: '決定',
  19429. inert: '挿入',
  19430. width: '幅',
  19431. height: '高さ'
  19432. },
  19433. controls: {
  19434. clear: 'クリアコンテンツ',
  19435. undo: 'キャンセル',
  19436. redo: 'キャンセル',
  19437. fontSize: 'フォントサイズ',
  19438. lineHeight: 'フォントサイズ',
  19439. letterSpacing: 'ワード間隔',
  19440. textIndent: '段落のインデント',
  19441. increaseIndent: 'インデントを増やす',
  19442. decreaseIndent: 'インデントを減らす',
  19443. border: '国境',
  19444. color: '色',
  19445. textColor: 'テキストの色',
  19446. backgroundColor: '背景色',
  19447. tempColors: '仮色',
  19448. bold: '太字',
  19449. italic: 'イタリック体',
  19450. underline: '下線',
  19451. strikeThrough: '取り消し線',
  19452. fontFamily: 'フォント',
  19453. textAlign: 'テキストの配置',
  19454. alignLeft: '左',
  19455. alignCenter: '中央揃え',
  19456. alignRight: '右に立つ',
  19457. alignJustify: '両端',
  19458. floatLeft: '左フローティング',
  19459. floatRight: '右フローティング',
  19460. superScript: '上付き',
  19461. subScript: '下付き文字',
  19462. removeStyles: 'クリアスタイル',
  19463. headings: '役職',
  19464. header: '役職',
  19465. normal: '従来の',
  19466. orderedList: '順序付きリスト',
  19467. unorderedList: '番号なしリスト',
  19468. blockQuote: '参照',
  19469. code: 'コード',
  19470. link: 'リンク',
  19471. unlink: 'リンクを解除',
  19472. hr: '横線',
  19473. media: 'メディア',
  19474. mediaLibirary: 'メディアライブラリー',
  19475. emoji: '小さな表現',
  19476. fullscreen: '全画面',
  19477. exitFullscreen: '全画面を退く'
  19478. },
  19479. linkEditor: {
  19480. textInputPlaceHolder: 'リンクテキストを入力',
  19481. linkInputPlaceHolder: 'リンクアドレスを入力',
  19482. inputWithEnterPlaceHolder: 'リンクアドレスを入力して戻ります',
  19483. openInNewWindow: '新しいウィンドウで開く',
  19484. removeLink: '新しいウィンドウで開く'
  19485. },
  19486. audioPlayer: {
  19487. title: 'オーディオファイルを再生する'
  19488. },
  19489. videoPlayer: {
  19490. title: 'ビデオファイルを再生する',
  19491. embedTitle: '埋め込みメディア'
  19492. },
  19493. media: {
  19494. image: '画像',
  19495. video: 'ビデオ',
  19496. audio: '音声',
  19497. embed: '埋め込みメディア'
  19498. }
  19499. });
  19500. // CONCATENATED MODULE: ./languages/ru.js
  19501. /* harmony default export */ var ru = ({
  19502. base: {
  19503. remove: 'Удалить',
  19504. cancel: 'Отмена',
  19505. confirm: 'Подтвердить',
  19506. insert: 'Вставить',
  19507. width: 'Ширина',
  19508. height: 'Высота'
  19509. },
  19510. controls: {
  19511. clear: 'Очистить',
  19512. undo: 'Отменить',
  19513. redo: 'Повторить',
  19514. fontSize: 'Размер шрифта',
  19515. color: 'Цвет',
  19516. textColor: 'Цвет текста',
  19517. tempColors: 'Temp Colors',
  19518. backgroundColor: 'Цвет фона',
  19519. bold: 'Жирный',
  19520. lineHeight: 'Межстрочный интервал',
  19521. letterSpacing: 'Межбуквенный интервал',
  19522. textIndent: 'Отступ',
  19523. increaseIndent: 'Увеличить отступ',
  19524. decreaseIndent: 'Уменьшить отступ',
  19525. italic: 'Курсив',
  19526. underline: 'Подчеркнутый',
  19527. strikeThrough: 'Перечеркнутый',
  19528. fontFamily: 'Шрифт',
  19529. textAlign: 'Расположение текста',
  19530. alignLeft: 'По левому краю',
  19531. alignCenter: 'По центру',
  19532. alignRight: 'По правому краю',
  19533. alignJustify: 'По ширине',
  19534. floatLeft: 'Обтекание слева',
  19535. floatRight: 'Обтекание справа',
  19536. superScript: 'Надстрочный индекс',
  19537. subScript: 'Подстрочный индекс',
  19538. removeStyles: 'Убрать стили',
  19539. headings: 'Заголовки',
  19540. header: 'Заголовок',
  19541. normal: 'Обычный',
  19542. orderedList: 'Упорядоченный список',
  19543. unorderedList: 'Неупорядоченный список',
  19544. blockQuote: 'Цитата',
  19545. code: 'Код',
  19546. link: 'Вставить ссылку',
  19547. unlink: 'Убрать ссылку',
  19548. hr: 'Горизонтальная линия',
  19549. media: 'Медиа',
  19550. mediaLibirary: 'Медиа библиотека',
  19551. emoji: 'Emoji',
  19552. fullscreen: 'Полноэкранный режим',
  19553. exitFullscreen: 'Выйти из полноэкранного режима'
  19554. },
  19555. linkEditor: {
  19556. textInputPlaceHolder: 'Введите текст ссылки',
  19557. linkInputPlaceHolder: 'Вставить ссылку',
  19558. inputWithEnterPlaceHolder: 'Вставить ссылку и нажать Enter',
  19559. openInNewWindow: 'Открыть в новом окне',
  19560. removeLink: 'Убрать ссылку'
  19561. },
  19562. audioPlayer: {
  19563. title: 'Воспроизвести аудиофайл'
  19564. },
  19565. videoPlayer: {
  19566. title: 'Воспроизвести видеофайл',
  19567. embedTitle: 'Embed Media'
  19568. },
  19569. media: {
  19570. image: 'Картинка',
  19571. video: 'Видео',
  19572. audio: 'Аудио',
  19573. embed: 'Встроенное'
  19574. }
  19575. });
  19576. // CONCATENATED MODULE: ./languages/fr.js
  19577. /* harmony default export */ var fr = ({
  19578. base: {
  19579. remove: 'Supprimer',
  19580. cancel: 'Annuler',
  19581. confirm: 'Confirmer',
  19582. inert: 'Insérer',
  19583. width: 'Largeur',
  19584. height: 'Hauteur'
  19585. },
  19586. controls: {
  19587. clear: 'Effacer',
  19588. undo: 'Annuler',
  19589. redo: 'Refaire',
  19590. fontSize: 'Taille de police',
  19591. color: 'Couleur',
  19592. textColor: 'Texte',
  19593. tempColors: 'Couleurs temporaire',
  19594. backgroundColor: 'Couleur d\'arrière plan',
  19595. bold: 'Gras',
  19596. lineHeight: 'Hauteur de ligne',
  19597. letterSpacing: 'Espacement des lettres',
  19598. textIndent: 'Indentation du texte',
  19599. increaseIndent: 'Augmenter l\'indentation',
  19600. decreaseIndent: 'Réduire l\'indentation',
  19601. italic: 'Italique',
  19602. underline: 'Souligner',
  19603. strikeThrough: 'Barrer',
  19604. fontFamily: 'Police d\'écriture',
  19605. textAlign: 'Alignement du texte',
  19606. alignLeft: 'Aligner à gauche',
  19607. alignCenter: 'Aligner au centre',
  19608. alignRight: 'Aligner à droite',
  19609. alignJustify: 'Justifier',
  19610. floatLeft: 'Déplacer à gauche',
  19611. floatRight: 'Déplacer à droite',
  19612. superScript: 'Super-script',
  19613. subScript: 'Sous-script',
  19614. removeStyles: 'Supprimer les styles',
  19615. headings: 'Titres',
  19616. header: 'Entêtes',
  19617. normal: 'Normal',
  19618. orderedList: 'Liste ordonnée',
  19619. unorderedList: 'Liste non-ordonnée',
  19620. blockQuote: 'Citation',
  19621. code: 'Code',
  19622. link: 'Insérer un lien',
  19623. unlink: 'Supprimer le lien',
  19624. hr: 'Ligne horizontale',
  19625. media: 'Média',
  19626. mediaLibirary: 'Bibliothêque',
  19627. emoji: 'Emoji',
  19628. fullscreen: 'Plein écran',
  19629. exitFullscreen: 'Quitter le plein écran'
  19630. },
  19631. linkEditor: {
  19632. textInputPlaceHolder: 'Insérer le texte à afficher',
  19633. linkInputPlaceHolder: 'Insérer le lien URL',
  19634. inputWithEnterPlaceHolder: 'Insérer le lien URL puis appuyer sur Entrée',
  19635. openInNewWindow: 'Ouvrir dans une nouvelle fenêtre',
  19636. removeLink: 'Supprimer le lien'
  19637. },
  19638. audioPlayer: {
  19639. title: 'Lancer le son audio'
  19640. },
  19641. videoPlayer: {
  19642. title: 'Lancer la video',
  19643. embedTitle: 'Intégrer média'
  19644. },
  19645. media: {
  19646. image: 'Image',
  19647. video: 'Vidéo',
  19648. audio: 'Audio',
  19649. embed: 'Intégré'
  19650. }
  19651. });
  19652. // CONCATENATED MODULE: ./languages/pt-br.js
  19653. /* harmony default export */ var pt_br = ({
  19654. base: {
  19655. remove: 'Remover',
  19656. cancel: 'Cancelar',
  19657. confirm: 'Confirmar',
  19658. inert: 'Inserir',
  19659. width: 'Largura',
  19660. height: 'Altura'
  19661. },
  19662. controls: {
  19663. clear: 'Limpar',
  19664. undo: 'Desfazer',
  19665. redo: 'Refazer',
  19666. fontSize: 'Tamanho da Fonte',
  19667. color: 'Cor',
  19668. textColor: 'Texto',
  19669. tempColors: 'Temp Colors',
  19670. backgroundColor: 'Cor de Fundo',
  19671. bold: 'Negrito',
  19672. lineHeight: 'Altura da LinhaLine Height',
  19673. letterSpacing: 'Espaçamento entre Letras',
  19674. textIndent: 'Identação de Texto',
  19675. increaseIndent: 'Aumentar Identação',
  19676. decreaseIndent: 'Diminuir Identção',
  19677. italic: 'Itálico',
  19678. underline: 'Sublinhado',
  19679. strikeThrough: 'Riscado',
  19680. fontFamily: 'Família da Fonte',
  19681. textAlign: 'Alinhamento de Texto',
  19682. alignLeft: 'Alinhamento à Esquerda',
  19683. alignCenter: 'Alinhamento Centralizado',
  19684. alignRight: 'Alinhamento à Direita',
  19685. alignJustify: 'Alinhamento Justificado',
  19686. floatLeft: 'Flutuação à Esquerda',
  19687. floatRight: 'Flutuação à Direita',
  19688. superScript: 'Sobrescrito',
  19689. subScript: 'Subscrito',
  19690. removeStyles: 'Remover Estilos',
  19691. headings: 'Cabeçalhos',
  19692. header: 'Cabeçalho',
  19693. normal: 'Normal',
  19694. orderedList: 'Lista Ordenada',
  19695. unorderedList: 'Lista Não Ordenada',
  19696. blockQuote: 'Citação',
  19697. code: 'Código',
  19698. link: 'Link',
  19699. unlink: 'Remover Link',
  19700. hr: 'Linha Horizontal',
  19701. media: 'Mídia',
  19702. mediaLibirary: 'Biblioteca de Mídia',
  19703. emoji: 'Emoji',
  19704. fullscreen: 'Tela Cheia',
  19705. exitFullscreen: 'Sair de Tela Cheia'
  19706. },
  19707. linkEditor: {
  19708. textInputPlaceHolder: 'Insira o texto do link',
  19709. linkInputPlaceHolder: 'Insira a URL do link',
  19710. inputWithEnterPlaceHolder: 'Insira a URL do link e aperte Enter',
  19711. openInNewWindow: 'Abrir em nova janela',
  19712. removeLink: 'Remover Link'
  19713. },
  19714. audioPlayer: {
  19715. title: 'Tocar Áudio'
  19716. },
  19717. videoPlayer: {
  19718. title: 'Tocar Vídeo',
  19719. embedTitle: 'Mídia Embutida'
  19720. },
  19721. media: {
  19722. image: 'Imagem',
  19723. video: 'Vídeo',
  19724. audio: 'Áudio',
  19725. embed: 'Embutido'
  19726. }
  19727. });
  19728. // CONCATENATED MODULE: ./languages/index.js
  19729. /* harmony default export */ var languages = ({
  19730. 'en': en,
  19731. 'zh': zh,
  19732. 'zh-hant': zh_hant,
  19733. 'pl': pl,
  19734. 'kr': kr,
  19735. 'tr': tr,
  19736. 'jpn': jpn,
  19737. 'ru': ru,
  19738. 'fr': fr,
  19739. 'pt-br': pt_br
  19740. });
  19741. // EXTERNAL MODULE: external "braft-finder"
  19742. var external_braft_finder_ = __webpack_require__(17);
  19743. var external_braft_finder_default = /*#__PURE__*/__webpack_require__.n(external_braft_finder_);
  19744. // EXTERNAL MODULE: external "braft-utils"
  19745. var external_braft_utils_ = __webpack_require__(3);
  19746. // EXTERNAL MODULE: external "draft-js"
  19747. var external_draft_js_ = __webpack_require__(6);
  19748. // EXTERNAL MODULE: external "immutable"
  19749. var external_immutable_ = __webpack_require__(13);
  19750. var external_immutable_default = /*#__PURE__*/__webpack_require__.n(external_immutable_);
  19751. // CONCATENATED MODULE: ./configs/keybindings.js
  19752. // TODO
  19753. // 允许自定义的快捷键设置
  19754. /* harmony default export */ var keybindings = (function (customKeyBindingFn) {
  19755. return function (event) {
  19756. if (event.keyCode === 83 && (external_draft_js_["KeyBindingUtil"].hasCommandModifier(event) || external_draft_js_["KeyBindingUtil"].isCtrlKeyCommand(event))) {
  19757. return 'braft-save';
  19758. }
  19759. if (customKeyBindingFn) {
  19760. return customKeyBindingFn(event) || Object(external_draft_js_["getDefaultKeyBinding"])(event);
  19761. }
  19762. return Object(external_draft_js_["getDefaultKeyBinding"])(event);
  19763. };
  19764. });
  19765. // CONCATENATED MODULE: ./configs/props.js
  19766. /* harmony default export */ var configs_props = ({
  19767. language: 'zh',
  19768. 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'],
  19769. excludeControls: [],
  19770. extendControls: [],
  19771. extendAtomics: [],
  19772. componentBelowControlBar: null,
  19773. media: {
  19774. pasteImage: true,
  19775. imagePasteLimit: 5,
  19776. image: true,
  19777. video: true,
  19778. audio: true,
  19779. uploadFn: null,
  19780. validateFn: null,
  19781. onBeforeDeselect: null,
  19782. onDeselect: null,
  19783. onBeforeSelect: null,
  19784. onSelect: null,
  19785. onBeforeRemove: null,
  19786. onRemove: null,
  19787. onCancel: null,
  19788. onFileSelect: null,
  19789. onBeforeInsert: null,
  19790. onInsert: null,
  19791. onChange: null,
  19792. accepts: {
  19793. image: 'image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg',
  19794. video: 'video/mp4',
  19795. audio: 'audio/mp3'
  19796. },
  19797. externals: {
  19798. audio: true,
  19799. video: true,
  19800. image: true,
  19801. embed: true
  19802. }
  19803. },
  19804. imageControls: ['float-left', 'float-right', 'align-left', 'align-center', 'align-right', 'link', 'size', 'remove'],
  19805. imageResizable: true,
  19806. colors: ['#000000', '#333333', '#666666', '#999999', '#cccccc', '#ffffff', '#61a951', '#16a085', '#07a9fe', '#003ba5', '#8e44ad', '#f32784', '#c0392b', '#d35400', '#f39c12', '#fdda00'],
  19807. colorPicker: null,
  19808. colorPickerTheme: 'dark',
  19809. colorPickerAutoHide: true,
  19810. codeTabIndents: 2,
  19811. headings: ['header-one', 'header-two', 'header-three', 'header-four', 'header-five', 'header-six', 'unstyled'],
  19812. textAligns: ['left', 'center', 'right', 'justify'],
  19813. textBackgroundColor: true,
  19814. allowInsertLinkText: false,
  19815. defaultLinkTarget: '',
  19816. letterSpacings: [0, 1, 2, 3, 4, 5, 6],
  19817. lineHeights: [1, 1.2, 1.5, 1.75, 2, 2.5, 3, 4],
  19818. fontSizes: [12, 14, 16, 18, 20, 24, 28, 30, 32, 36, 40, 48, 56, 64, 72, 96, 120, 144],
  19819. fontFamilies: [{
  19820. name: 'Araial',
  19821. family: 'Arial, Helvetica, sans-serif'
  19822. }, {
  19823. name: 'Georgia',
  19824. family: 'Georgia, serif'
  19825. }, {
  19826. name: 'Impact',
  19827. family: 'Impact, serif'
  19828. }, {
  19829. name: 'Monospace',
  19830. family: '"Courier New", Courier, monospace'
  19831. }, {
  19832. name: 'Tahoma',
  19833. family: 'tahoma, arial, "Hiragino Sans GB", 宋体, sans-serif'
  19834. }],
  19835. converts: {
  19836. unitExportFn: function unitExportFn(value, type) {
  19837. return type === 'line-height' ? value : "".concat(value, "px");
  19838. }
  19839. },
  19840. emojis: ['🤣', '🙌', '💚', '💛', '👏', '😉', '💯', '💕', '💞', '💘', '💙', '💝', '🖤', '💜', '❤️', '😍', '😻', '💓', '💗', '😋', '😇', '😂', '😹', '😘', '💖', '😁', '😀', '🤞', '😲', '😄', '😊', '👍', '😌', '😃', '😅', '✌️', '🤗', '💋', '😗', '😽', '😚', '🤠', '😙', '😺', '👄', '😸', '😏', '😼', '👌', '😎', '😆', '😛', '🙏', '🤝', '🙂', '🤑', '😝', '😐', '😑', '🤤', '😤', '🙃', '🤡', '😶', '😪', '😴', '😵', '😓', '👊', '😦', '😷', '🤐', '😜', '🤓', '👻', '😥', '🙄', '🤔', '🤒', '🙁', '😔', '😯', '☹️', '☠️', '😰', '😩', '😖', '😕', '😒', '😣', '😢', '😮', '😿', '🤧', '😫', '🤥', '😞', '😬', '👎', '💀', '😳', '😨', '🤕', '🤢', '😱', '😭', '😠', '😈', '😧', '💔', '😟', '🙀', '💩', '👿', '😡', '😾', '🖕'],
  19841. stripPastedStyles: false,
  19842. triggerChangeOnMount: true,
  19843. className: '',
  19844. style: {},
  19845. controlBarClassName: '',
  19846. controlBarStyle: {},
  19847. contentClassName: '',
  19848. contentStyle: {},
  19849. draftProps: {},
  19850. hooks: {},
  19851. onChange: null,
  19852. onFocus: null,
  19853. onBlur: null,
  19854. onTab: null,
  19855. onDelete: null,
  19856. onSave: null,
  19857. fixPlaceholder: false
  19858. });
  19859. // EXTERNAL MODULE: ../node_modules/draft-js/lib/getFragmentFromSelection.js
  19860. var getFragmentFromSelection = __webpack_require__(22);
  19861. var getFragmentFromSelection_default = /*#__PURE__*/__webpack_require__.n(getFragmentFromSelection);
  19862. // EXTERNAL MODULE: external "draftjs-utils"
  19863. var external_draftjs_utils_ = __webpack_require__(23);
  19864. // CONCATENATED MODULE: ./configs/handlers.js
  19865. var handlers_keyCommandHandlers = function keyCommandHandlers(command, editorState, editor) {
  19866. if (editor.editorProps.handleKeyCommand && editor.editorProps.handleKeyCommand(command, editorState, editor) === 'handled') {
  19867. return 'handled';
  19868. }
  19869. if (command === 'braft-save') {
  19870. editor.editorProps.onSave && editor.editorProps.onSave(editorState);
  19871. return 'handled';
  19872. }
  19873. var _editor$editorProps = editor.editorProps,
  19874. controls = _editor$editorProps.controls,
  19875. excludeControls = _editor$editorProps.excludeControls;
  19876. var allowIndent = (controls.indexOf('text-indent') !== 0 || controls.find(function (item) {
  19877. return item.key === 'text-indent';
  19878. })) && excludeControls.indexOf('text-indent') === -1;
  19879. var cursorStart = editorState.getSelection().getStartOffset();
  19880. var cursorEnd = editorState.getSelection().getEndOffset();
  19881. var cursorIsAtFirst = cursorStart === 0 && cursorEnd === 0;
  19882. if (command === 'backspace') {
  19883. if (editor.editorProps.onDelete && editor.editorProps.onDelete(editorState) === false) {
  19884. return 'handled';
  19885. }
  19886. var blockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  19887. if (allowIndent && cursorIsAtFirst && blockType !== 'code-block') {
  19888. editor.setValue(external_braft_utils_["ContentUtils"].decreaseSelectionIndent(editorState));
  19889. }
  19890. }
  19891. if (command === 'tab') {
  19892. var _blockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  19893. if (_blockType === 'code-block') {
  19894. editor.setValue(external_braft_utils_["ContentUtils"].insertText(editorState, ' '.repeat(editor.editorProps.codeTabIndents)));
  19895. return 'handled';
  19896. } else if (_blockType === 'ordered-list-item' || _blockType === 'unordered-list-item') {
  19897. var newEditorState = external_draft_js_["RichUtils"].onTab(event, editorState, 4);
  19898. if (newEditorState !== editorState) {
  19899. editor.setValue(newEditorState);
  19900. }
  19901. return 'handled';
  19902. } else if (_blockType !== 'atomic' && allowIndent && cursorIsAtFirst) {
  19903. editor.setValue(external_braft_utils_["ContentUtils"].increaseSelectionIndent(editorState));
  19904. return 'handled';
  19905. }
  19906. }
  19907. var nextEditorState = external_braft_utils_["ContentUtils"].handleKeyCommand(editorState, command);
  19908. if (nextEditorState) {
  19909. editor.setValue(nextEditorState);
  19910. return 'handled';
  19911. }
  19912. return 'not-handled';
  19913. };
  19914. var handlers_returnHandlers = function returnHandlers(event, editorState, editor) {
  19915. if (editor.editorProps.handleReturn && editor.editorProps.handleReturn(event, editorState, editor) === 'handled') {
  19916. return 'handled';
  19917. }
  19918. var currentBlock = external_braft_utils_["ContentUtils"].getSelectionBlock(editorState);
  19919. var currentBlockType = currentBlock.getType();
  19920. if (currentBlockType === 'unordered-list-item' || currentBlockType === 'ordered-list-item') {
  19921. if (currentBlock.getLength() === 0) {
  19922. editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, 'unstyled'));
  19923. return 'handled';
  19924. }
  19925. return 'not-handled';
  19926. } else if (currentBlockType === 'code-block') {
  19927. if (event.which === 13 && (event.getModifierState('Shift') || event.getModifierState('Alt') || event.getModifierState('Control'))) {
  19928. editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, 'unstyled'));
  19929. return 'handled';
  19930. }
  19931. return 'not-handled';
  19932. } else if (currentBlockType === 'blockquote') {
  19933. if (event.which === 13) {
  19934. if (event.getModifierState('Shift') || event.getModifierState('Alt') || event.getModifierState('Control')) {
  19935. event.which = 0;
  19936. } else {
  19937. editor.setValue(external_draft_js_["RichUtils"].insertSoftNewline(editorState));
  19938. return 'handled';
  19939. }
  19940. }
  19941. }
  19942. var nextEditorState = Object(external_draftjs_utils_["handleNewLine"])(editorState, event);
  19943. if (nextEditorState) {
  19944. editor.setValue(nextEditorState);
  19945. return 'handled';
  19946. }
  19947. return 'not-handled';
  19948. };
  19949. var beforeInputHandlers = function beforeInputHandlers(chars, editorState, editor) {
  19950. if (editor.editorProps.handleBeforeInput && editor.editorProps.handleBeforeInput(chars, editorState, editor) === 'handled') {
  19951. return 'handled';
  19952. }
  19953. return 'not-handled';
  19954. };
  19955. var handlers_compositionStartHandler = function compositionStartHandler(_, editor) {
  19956. var editorState = editor.state.editorState;
  19957. var selectedBlocks = external_braft_utils_["ContentUtils"].getSelectedBlocks(editorState);
  19958. if (selectedBlocks && selectedBlocks.length > 1) {
  19959. var nextEditorState = external_draft_js_["EditorState"].push(editorState, external_draft_js_["Modifier"].removeRange(editorState.getCurrentContent(), editorState.getSelection(), 'backward'), 'remove-range');
  19960. editor.setValue(nextEditorState);
  19961. }
  19962. };
  19963. var handlers_dropHandlers = function dropHandlers(selectionState, dataTransfer, editor) {
  19964. if (editor.editorProps.readOnly || editor.editorProps.disabled) {
  19965. return 'handled';
  19966. }
  19967. if (window && window.__BRAFT_DRAGING__IMAGE__) {
  19968. var nextEditorState = external_draft_js_["EditorState"].forceSelection(editor.state.editorState, selectionState);
  19969. nextEditorState = external_braft_utils_["ContentUtils"].insertMedias(nextEditorState, [window.__BRAFT_DRAGING__IMAGE__.mediaData]);
  19970. nextEditorState = external_braft_utils_["ContentUtils"].removeBlock(nextEditorState, window.__BRAFT_DRAGING__IMAGE__.block, nextEditorState.getSelection());
  19971. window.__BRAFT_DRAGING__IMAGE__ = null;
  19972. editor.lockOrUnlockEditor(true);
  19973. editor.setValue(nextEditorState);
  19974. return 'handled';
  19975. } else if (!dataTransfer || !dataTransfer.getText()) {
  19976. return 'handled';
  19977. }
  19978. return 'not-handled';
  19979. };
  19980. var handlers_handleFiles = function handleFiles(files, editor) {
  19981. var _editor$constructor$d = objectSpread_default()({}, editor.constructor.defaultProps.media, editor.editorProps.media),
  19982. pasteImage = _editor$constructor$d.pasteImage,
  19983. validateFn = _editor$constructor$d.validateFn,
  19984. imagePasteLimit = _editor$constructor$d.imagePasteLimit;
  19985. pasteImage && files.slice(0, imagePasteLimit).forEach(function (file) {
  19986. if (file && file.type.indexOf('image') > -1 && editor.braftFinder) {
  19987. var validateResult = validateFn ? validateFn(file) : true;
  19988. if (validateResult instanceof Promise) {
  19989. validateResult.then(function () {
  19990. editor.braftFinder.uploadImage(file, function (image) {
  19991. editor.isLiving && editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(editor.state.editorState, [image]));
  19992. });
  19993. });
  19994. } else if (validateResult) {
  19995. editor.braftFinder.uploadImage(file, function (image) {
  19996. editor.isLiving && editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(editor.state.editorState, [image]));
  19997. });
  19998. }
  19999. }
  20000. });
  20001. if (files[0] && files[0].type.indexOf('image') > -1 && pasteImage) {
  20002. return 'handled';
  20003. }
  20004. return 'not-handled';
  20005. };
  20006. var droppedFilesHandlers = function droppedFilesHandlers(selectionState, files, editor) {
  20007. if (editor.editorProps.handleDroppedFiles && editor.editorProps.handleDroppedFiles(selectionState, files, editor) === 'handled') {
  20008. return 'handled';
  20009. }
  20010. return handlers_handleFiles(files, editor);
  20011. };
  20012. var pastedFilesHandlers = function pastedFilesHandlers(files, editor) {
  20013. if (editor.editorProps.handlePastedFiles && editor.editorProps.handlePastedFiles(files, editor) === 'handled') {
  20014. return 'handled';
  20015. }
  20016. return handlers_handleFiles(files, editor);
  20017. };
  20018. var handlers_copyHandlers = function copyHandlers(event, editor) {
  20019. var blockMap = getFragmentFromSelection_default()(editor.state.editorState);
  20020. if (blockMap && blockMap.toArray) {
  20021. try {
  20022. var tempContentState = external_draft_js_["ContentState"].createFromBlockArray(blockMap.toArray());
  20023. var tempEditorState = external_draft_js_["EditorState"].createWithContent(tempContentState);
  20024. var clipboardData = event.clipboardData || window.clipboardData || event.originalEvent.clipboardData;
  20025. tempEditorState.setConvertOptions(editor.state.editorState.convertOptions);
  20026. clipboardData.setData('text/html', tempEditorState.toHTML());
  20027. clipboardData.setData('text/plain', tempEditorState.toText());
  20028. event.preventDefault();
  20029. } catch (error) {
  20030. console.warn(error);
  20031. }
  20032. }
  20033. };
  20034. var handlers_pastedTextHandlers = function pastedTextHandlers(text, html, editorState, editor) {
  20035. if (editor.editorProps.handlePastedText && editor.editorProps.handlePastedText(text, html, editorState, editor) === 'handled') {
  20036. return 'handled';
  20037. }
  20038. if (!html || editor.editorProps.stripPastedStyles) {
  20039. return false;
  20040. }
  20041. var tempColors = external_braft_utils_["ColorUtils"].detectColorsFromHTMLString(html);
  20042. editor.setState({
  20043. tempColors: toConsumableArray_default()(editor.state.tempColors).concat(toConsumableArray_default()(tempColors)).filter(function (item) {
  20044. return editor.editorProps.colors.indexOf(item) === -1;
  20045. }).filter(function (item, index, array) {
  20046. return array.indexOf(item) === index;
  20047. })
  20048. }, function () {
  20049. editor.setValue(external_braft_utils_["ContentUtils"].insertHTML(editorState, html, 'paste'));
  20050. });
  20051. return 'handled';
  20052. };
  20053. // CONCATENATED MODULE: ./helpers/extension.js
  20054. // TODO
  20055. // - block-style和atomic类型的扩展支持
  20056. var extension_extensionControls = [];
  20057. var extension_extensionDecorators = [];
  20058. var extension_propInterceptors = [];
  20059. var extension_extensionBlockRenderMaps = [];
  20060. var extension_extensionBlockRendererFns = [];
  20061. var extensionInlineStyleMaps = [];
  20062. var extension_extensionInlineStyleFns = [];
  20063. var extensionEntities = [];
  20064. var inlineStyleImporters = [];
  20065. var inlineStyleExporters = [];
  20066. var blockImporters = [];
  20067. var blockExporters = [];
  20068. var filterByEditorId = function filterByEditorId(items, editorId) {
  20069. if (!editorId) {
  20070. return items.filter(function (item) {
  20071. return !item.includeEditors;
  20072. }).map(function (item) {
  20073. return item.data;
  20074. });
  20075. }
  20076. return items.map(function (item) {
  20077. if (!item.includeEditors && !item.excludeEditors) {
  20078. return item.data;
  20079. }
  20080. if (item.includeEditors) {
  20081. return item.includeEditors.indexOf(editorId) !== -1 ? item.data : false;
  20082. }
  20083. if (item.excludeEditors) {
  20084. return item.excludeEditors.indexOf(editorId) !== -1 ? false : item.data;
  20085. }
  20086. return false;
  20087. }).filter(function (item) {
  20088. return item;
  20089. });
  20090. };
  20091. var getPropInterceptors = function getPropInterceptors(editorId) {
  20092. return filterByEditorId(extension_propInterceptors, editorId);
  20093. };
  20094. var getExtensionControls = function getExtensionControls(editorId) {
  20095. return filterByEditorId(extension_extensionControls, editorId);
  20096. };
  20097. var getExtensionDecorators = function getExtensionDecorators(editorId) {
  20098. return filterByEditorId(extension_extensionDecorators, editorId);
  20099. };
  20100. var getExtensionBlockRenderMaps = function getExtensionBlockRenderMaps(editorId) {
  20101. return filterByEditorId(extension_extensionBlockRenderMaps, editorId);
  20102. };
  20103. var getExtensionBlockRendererFns = function getExtensionBlockRendererFns(editorId) {
  20104. return filterByEditorId(extension_extensionBlockRendererFns, editorId);
  20105. };
  20106. var getExtensionInlineStyleMap = function getExtensionInlineStyleMap(editorId) {
  20107. var inlineStyleMap = {};
  20108. filterByEditorId(extensionInlineStyleMaps, editorId).forEach(function (item) {
  20109. inlineStyleMap[item.inlineStyleName] = item.styleMap;
  20110. });
  20111. return inlineStyleMap;
  20112. };
  20113. var getExtensionInlineStyleFns = function getExtensionInlineStyleFns(editorId) {
  20114. return filterByEditorId(extension_extensionInlineStyleFns, editorId);
  20115. };
  20116. var compositeStyleImportFn = function compositeStyleImportFn(styleImportFn, editorId) {
  20117. return function (nodeName, node, style) {
  20118. filterByEditorId(inlineStyleImporters, editorId).forEach(function (styleImporter) {
  20119. if (styleImporter.importer && styleImporter.importer(nodeName, node)) {
  20120. style = style.add(styleImporter.inlineStyleName);
  20121. }
  20122. });
  20123. return styleImportFn ? styleImportFn(nodeName, node, style) : style;
  20124. };
  20125. };
  20126. var compositeStyleExportFn = function compositeStyleExportFn(styleExportFn, editorId) {
  20127. return function (style) {
  20128. style = style.toUpperCase();
  20129. var result = styleExportFn ? styleExportFn(style) : undefined;
  20130. if (result) {
  20131. return result;
  20132. }
  20133. filterByEditorId(inlineStyleExporters, editorId).find(function (item) {
  20134. if (item.inlineStyleName === style) {
  20135. result = item.exporter;
  20136. return true;
  20137. }
  20138. });
  20139. return result;
  20140. };
  20141. };
  20142. var compositeEntityImportFn = function compositeEntityImportFn(entityImportFn, editorId) {
  20143. return function (nodeName, node, createEntity, source) {
  20144. var result = entityImportFn ? entityImportFn(nodeName, node, createEntity, source) : null;
  20145. if (result) {
  20146. return result;
  20147. }
  20148. filterByEditorId(extensionEntities, editorId).find(function (entityItem) {
  20149. var matched = entityItem.importer ? entityItem.importer(nodeName, node, source) : null;
  20150. matched && (result = createEntity(entityItem.entityType, matched.mutability || 'MUTABLE', matched.data || {}));
  20151. return !!matched;
  20152. });
  20153. return result;
  20154. };
  20155. };
  20156. var compositeEntityExportFn = function compositeEntityExportFn(entityExportFn, editorId) {
  20157. return function (entity, originalText) {
  20158. var result = entityExportFn ? entityExportFn(entity, originalText) : undefined;
  20159. if (result) {
  20160. return result;
  20161. }
  20162. var entityType = entity.type.toUpperCase();
  20163. filterByEditorId(extensionEntities, editorId).find(function (entityItem) {
  20164. if (entityItem.entityType === entityType) {
  20165. result = entityItem.exporter ? entityItem.exporter(entity, originalText) : undefined;
  20166. return true;
  20167. }
  20168. });
  20169. return result;
  20170. };
  20171. };
  20172. var compositeBlockImportFn = function compositeBlockImportFn(blockImportFn, editorId) {
  20173. return function (nodeName, node, source) {
  20174. var result = blockImportFn ? blockImportFn(nodeName, node, source) : null;
  20175. if (result) {
  20176. return result;
  20177. }
  20178. filterByEditorId(blockImporters, editorId).find(function (blockImporter) {
  20179. var matched = blockImporter.importer ? blockImporter.importer(nodeName, node, source) : undefined;
  20180. matched && (result = matched);
  20181. return !!matched;
  20182. });
  20183. return result;
  20184. };
  20185. };
  20186. var compositeBlockExportFn = function compositeBlockExportFn(blockExportFn, editorId) {
  20187. return function (contentState, block) {
  20188. var result = blockExportFn ? blockExportFn(contentState, block) : null;
  20189. if (result) {
  20190. return result;
  20191. }
  20192. filterByEditorId(blockExporters, editorId).find(function (blockExporter) {
  20193. var matched = blockExporter.exporter ? blockExporter.exporter(contentState, block) : undefined;
  20194. matched && (result = matched);
  20195. return !!matched;
  20196. });
  20197. return result;
  20198. };
  20199. };
  20200. var extension_useExtension = function useExtension(extension) {
  20201. if (extension instanceof Array) {
  20202. extension.forEach(useExtension);
  20203. return false;
  20204. }
  20205. if (!extension || !extension.type || typeof extension.type !== 'string') {
  20206. return false;
  20207. }
  20208. var includeEditors = extension.includeEditors,
  20209. excludeEditors = extension.excludeEditors;
  20210. if (extension.type === 'control') {
  20211. extension_extensionControls.push({
  20212. includeEditors: includeEditors,
  20213. excludeEditors: excludeEditors,
  20214. data: extension.control
  20215. });
  20216. } else if (extension.type === 'inline-style') {
  20217. var inlineStyleName = extension.name.toUpperCase();
  20218. if (extension.control) {
  20219. extension_extensionControls.push({
  20220. includeEditors: includeEditors,
  20221. excludeEditors: excludeEditors,
  20222. data: objectSpread_default()({
  20223. key: inlineStyleName,
  20224. type: 'inline-style',
  20225. command: inlineStyleName
  20226. }, extension.control)
  20227. });
  20228. }
  20229. if (extension.style) {
  20230. extensionInlineStyleMaps.push({
  20231. includeEditors: includeEditors,
  20232. excludeEditors: excludeEditors,
  20233. data: {
  20234. inlineStyleName: inlineStyleName,
  20235. styleMap: extension.style
  20236. }
  20237. });
  20238. }
  20239. if (extension.styleFn) {
  20240. extension_extensionInlineStyleFns.push({
  20241. includeEditors: includeEditors,
  20242. excludeEditors: excludeEditors,
  20243. data: {
  20244. inlineStyleName: inlineStyleName,
  20245. styleFn: extension.styleFn
  20246. }
  20247. });
  20248. }
  20249. if (extension.importer) {
  20250. inlineStyleImporters.push({
  20251. includeEditors: includeEditors,
  20252. excludeEditors: excludeEditors,
  20253. data: {
  20254. inlineStyleName: inlineStyleName,
  20255. importer: extension.importer
  20256. }
  20257. });
  20258. }
  20259. inlineStyleExporters.push({
  20260. includeEditors: includeEditors,
  20261. excludeEditors: excludeEditors,
  20262. data: {
  20263. inlineStyleName: inlineStyleName,
  20264. exporter: extension.exporter ? extension.exporter(extension) : external_react_default.a.createElement("span", {
  20265. style: extension.style
  20266. })
  20267. }
  20268. });
  20269. } else if (extension.type === 'block-style') ; else if (extension.type === 'entity') {
  20270. var entityType = extension.name.toUpperCase();
  20271. if (extension.control) {
  20272. extension_extensionControls.push({
  20273. includeEditors: includeEditors,
  20274. excludeEditors: excludeEditors,
  20275. data: typeof extension.control === 'function' ? extension.control : objectSpread_default()({
  20276. key: entityType,
  20277. type: 'entity',
  20278. command: entityType,
  20279. data: {
  20280. mutability: extension.mutability || 'MUTABLE',
  20281. data: extension.data || {}
  20282. }
  20283. }, extension.control)
  20284. });
  20285. }
  20286. extensionEntities.push({
  20287. includeEditors: includeEditors,
  20288. excludeEditors: excludeEditors,
  20289. data: {
  20290. entityType: entityType,
  20291. importer: extension.importer,
  20292. exporter: extension.exporter
  20293. }
  20294. });
  20295. extension_extensionDecorators.push({
  20296. includeEditors: includeEditors,
  20297. excludeEditors: excludeEditors,
  20298. data: {
  20299. type: 'entity',
  20300. decorator: {
  20301. key: entityType,
  20302. component: extension.component
  20303. }
  20304. }
  20305. });
  20306. } else if (extension.type === 'block') {
  20307. var blockType = extension.name;
  20308. if (extension.renderMap) {
  20309. extension_extensionBlockRenderMaps.push({
  20310. includeEditors: includeEditors,
  20311. excludeEditors: excludeEditors,
  20312. data: {
  20313. blockType: blockType,
  20314. renderMap: extension.renderMap
  20315. }
  20316. });
  20317. }
  20318. if (extension.rendererFn) {
  20319. extension_extensionBlockRendererFns.push({
  20320. includeEditors: includeEditors,
  20321. excludeEditors: excludeEditors,
  20322. data: {
  20323. blockType: blockType,
  20324. rendererFn: extension.rendererFn
  20325. }
  20326. });
  20327. }
  20328. if (extension.importer) {
  20329. blockImporters.push({
  20330. includeEditors: includeEditors,
  20331. excludeEditors: excludeEditors,
  20332. data: {
  20333. blockType: blockType,
  20334. importer: extension.importer
  20335. }
  20336. });
  20337. }
  20338. if (extension.exporter) {
  20339. blockExporters.push({
  20340. includeEditors: includeEditors,
  20341. excludeEditors: excludeEditors,
  20342. data: {
  20343. blockType: blockType,
  20344. exporter: extension.exporter
  20345. }
  20346. });
  20347. }
  20348. } else if (extension.type === 'atomic') ; else if (extension.type === 'decorator') {
  20349. var decorator = extension.decorator;
  20350. if (decorator && decorator.strategy && decorator.component) {
  20351. extension_extensionDecorators.push({
  20352. includeEditors: includeEditors,
  20353. excludeEditors: excludeEditors,
  20354. data: {
  20355. type: 'strategy',
  20356. decorator: decorator
  20357. }
  20358. });
  20359. } else if (decorator && decorator.getDecorations) {
  20360. extension_extensionDecorators.push({
  20361. includeEditors: includeEditors,
  20362. excludeEditors: excludeEditors,
  20363. data: {
  20364. type: 'class',
  20365. decorator: decorator
  20366. }
  20367. });
  20368. }
  20369. } else if (extension.type === 'prop-interception') {
  20370. extension_propInterceptors.push({
  20371. includeEditors: includeEditors,
  20372. excludeEditors: excludeEditors,
  20373. data: extension.interceptor
  20374. });
  20375. }
  20376. };
  20377. var createExtensibleEditor = function createExtensibleEditor(BraftEditor) {
  20378. BraftEditor.use = extension_useExtension;
  20379. return BraftEditor;
  20380. };
  20381. // CONCATENATED MODULE: ./renderers/block/blockRenderMap.js
  20382. /* harmony default export */ var block_blockRenderMap = (function (props, blockRenderMap) {
  20383. var customBlockRenderMap = Object(external_immutable_["Map"])({
  20384. 'atomic': {
  20385. element: ''
  20386. },
  20387. 'code-block': {
  20388. element: 'code',
  20389. wrapper: external_react_default.a.createElement("pre", {
  20390. className: "braft-code-block"
  20391. })
  20392. }
  20393. });
  20394. try {
  20395. var extensionBlockRenderMaps = getExtensionBlockRenderMaps(props.editorId);
  20396. customBlockRenderMap = extensionBlockRenderMaps.reduce(function (customBlockRenderMap, item) {
  20397. return customBlockRenderMap.merge(typeof item.renderMap === 'function' ? item.renderMap(props) : item.renderMap);
  20398. }, customBlockRenderMap);
  20399. if (blockRenderMap) {
  20400. if (typeof blockRenderMap === 'function') {
  20401. customBlockRenderMap = customBlockRenderMap.merge(blockRenderMap(props));
  20402. } else {
  20403. customBlockRenderMap = customBlockRenderMap.merge(blockRenderMap);
  20404. }
  20405. }
  20406. customBlockRenderMap = external_draft_js_["DefaultDraftBlockRenderMap"].merge(customBlockRenderMap);
  20407. } catch (error) {
  20408. console.warn(error);
  20409. }
  20410. return customBlockRenderMap;
  20411. });
  20412. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/extends.js
  20413. var helpers_extends = __webpack_require__(11);
  20414. var extends_default = /*#__PURE__*/__webpack_require__.n(helpers_extends);
  20415. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/slicedToArray.js
  20416. var slicedToArray = __webpack_require__(24);
  20417. var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
  20418. // EXTERNAL MODULE: ./renderers/atomics/Image/style.scss
  20419. var Image_style = __webpack_require__(45);
  20420. // EXTERNAL MODULE: ./components/common/Switch/style.scss
  20421. var Switch_style = __webpack_require__(46);
  20422. // CONCATENATED MODULE: ./components/common/Switch/index.jsx
  20423. /* harmony default export */ var Switch = (function (props) {
  20424. var active = props.active,
  20425. _onClick = props.onClick,
  20426. className = props.className;
  20427. return external_react_default.a.createElement("div", {
  20428. onClick: function onClick() {
  20429. return _onClick();
  20430. },
  20431. className: 'bf-switch ' + className + (active ? ' active' : '')
  20432. });
  20433. });
  20434. // CONCATENATED MODULE: ./configs/controls.js
  20435. /* harmony default export */ var configs_controls = (function (lang, editor) {
  20436. return [{
  20437. key: 'undo',
  20438. title: lang.controls.undo,
  20439. text: external_react_default.a.createElement("i", {
  20440. className: "bfi-undo"
  20441. }),
  20442. type: 'editor-method',
  20443. command: 'undo'
  20444. }, {
  20445. key: 'redo',
  20446. title: lang.controls.redo,
  20447. text: external_react_default.a.createElement("i", {
  20448. className: "bfi-redo"
  20449. }),
  20450. type: 'editor-method',
  20451. command: 'redo'
  20452. }, {
  20453. key: 'remove-styles',
  20454. title: lang.controls.removeStyles,
  20455. text: external_react_default.a.createElement("i", {
  20456. className: "bfi-format_clear"
  20457. }),
  20458. type: 'editor-method',
  20459. command: 'removeSelectionInlineStyles'
  20460. }, {
  20461. key: 'hr',
  20462. title: lang.controls.hr,
  20463. text: external_react_default.a.createElement("i", {
  20464. className: "bfi-hr"
  20465. }),
  20466. type: 'editor-method',
  20467. command: 'insertHorizontalLine'
  20468. }, {
  20469. key: 'bold',
  20470. title: lang.controls.bold,
  20471. text: external_react_default.a.createElement("i", {
  20472. className: "bfi-bold"
  20473. }),
  20474. type: 'inline-style',
  20475. command: 'bold'
  20476. }, {
  20477. key: 'italic',
  20478. title: lang.controls.italic,
  20479. text: external_react_default.a.createElement("i", {
  20480. className: "bfi-italic"
  20481. }),
  20482. type: 'inline-style',
  20483. command: 'italic'
  20484. }, {
  20485. key: 'underline',
  20486. title: lang.controls.underline,
  20487. text: external_react_default.a.createElement("i", {
  20488. className: "bfi-underlined"
  20489. }),
  20490. type: 'inline-style',
  20491. command: 'underline'
  20492. }, {
  20493. key: 'strike-through',
  20494. title: lang.controls.strikeThrough,
  20495. text: external_react_default.a.createElement("i", {
  20496. className: "bfi-strikethrough"
  20497. }),
  20498. type: 'inline-style',
  20499. command: 'strikethrough'
  20500. }, {
  20501. key: 'superscript',
  20502. title: lang.controls.superScript,
  20503. text: external_react_default.a.createElement("i", {
  20504. className: "bfi-superscript"
  20505. }),
  20506. type: 'inline-style',
  20507. command: 'superscript'
  20508. }, {
  20509. key: 'subscript',
  20510. title: lang.controls.subScript,
  20511. text: external_react_default.a.createElement("i", {
  20512. className: "bfi-subscript"
  20513. }),
  20514. type: 'inline-style',
  20515. command: 'subscript'
  20516. }, {
  20517. key: 'headings',
  20518. title: lang.controls.headings,
  20519. type: 'headings'
  20520. }, {
  20521. key: 'blockquote',
  20522. title: lang.controls.blockQuote,
  20523. text: external_react_default.a.createElement("i", {
  20524. className: "bfi-quote"
  20525. }),
  20526. type: 'block-type',
  20527. command: 'blockquote'
  20528. }, {
  20529. key: 'code',
  20530. title: lang.controls.code,
  20531. text: external_react_default.a.createElement("i", {
  20532. className: "bfi-code"
  20533. }),
  20534. type: 'block-type',
  20535. command: 'code-block'
  20536. }, {
  20537. key: 'list-ul',
  20538. title: lang.controls.unorderedList,
  20539. text: external_react_default.a.createElement("i", {
  20540. className: "bfi-list"
  20541. }),
  20542. type: 'block-type',
  20543. command: 'unordered-list-item'
  20544. }, {
  20545. key: 'list-ol',
  20546. title: lang.controls.orderedList,
  20547. text: external_react_default.a.createElement("i", {
  20548. className: "bfi-list-numbered"
  20549. }),
  20550. type: 'block-type',
  20551. command: 'ordered-list-item'
  20552. }, {
  20553. key: 'link',
  20554. title: lang.controls.link,
  20555. type: 'link'
  20556. }, {
  20557. key: 'text-color',
  20558. title: lang.controls.color,
  20559. type: 'text-color'
  20560. }, {
  20561. key: 'line-height',
  20562. title: lang.controls.lineHeight,
  20563. type: 'line-height'
  20564. }, {
  20565. key: 'letter-spacing',
  20566. title: lang.controls.letterSpacing,
  20567. type: 'letter-spacing'
  20568. }, {
  20569. key: 'text-indent',
  20570. title: lang.controls.textIndent,
  20571. type: 'text-indent'
  20572. }, {
  20573. key: 'font-size',
  20574. title: lang.controls.fontSize,
  20575. type: 'font-size'
  20576. }, {
  20577. key: 'font-family',
  20578. title: lang.controls.fontFamily,
  20579. type: 'font-family'
  20580. }, {
  20581. key: 'text-align',
  20582. title: lang.controls.textAlign,
  20583. type: 'text-align'
  20584. }, {
  20585. key: 'media',
  20586. title: lang.controls.media,
  20587. text: external_react_default.a.createElement("i", {
  20588. className: "bfi-media"
  20589. }),
  20590. type: 'media'
  20591. }, {
  20592. key: 'emoji',
  20593. title: lang.controls.emoji,
  20594. text: external_react_default.a.createElement("i", {
  20595. className: "bfi-emoji"
  20596. }),
  20597. type: 'emoji'
  20598. }, {
  20599. key: 'clear',
  20600. title: lang.controls.clear,
  20601. text: external_react_default.a.createElement("i", {
  20602. className: "bfi-clear_all"
  20603. }),
  20604. type: 'editor-method',
  20605. command: 'clearEditorContent'
  20606. }, {
  20607. key: 'fullscreen',
  20608. title: editor.state.isFullscreen ? lang.controls.exitFullscreen : lang.controls.fullscreen,
  20609. text: external_react_default.a.createElement("i", {
  20610. className: editor.state.isFullscreen ? 'bfi-fullscreen-exit' : 'bfi-fullscreen'
  20611. }),
  20612. type: 'editor-method',
  20613. command: 'toggleFullscreen'
  20614. }, {
  20615. key: 'modal',
  20616. type: 'modal'
  20617. }, {
  20618. key: 'button',
  20619. type: 'button'
  20620. }, {
  20621. key: 'dropdown',
  20622. type: 'dropdown'
  20623. }, {
  20624. key: 'component',
  20625. type: 'component'
  20626. }];
  20627. });
  20628. var imageControlItems = {
  20629. 'float-left': {
  20630. text: external_react_default.a.createElement("span", {
  20631. "data-float": "left"
  20632. }, "\uE91E"),
  20633. command: 'setImageFloat|left'
  20634. },
  20635. 'float-right': {
  20636. text: external_react_default.a.createElement("span", {
  20637. "data-float": "right"
  20638. }, "\uE914"),
  20639. command: 'setImageFloat|right'
  20640. },
  20641. 'align-left': {
  20642. text: external_react_default.a.createElement("span", {
  20643. "data-align": "left"
  20644. }, "\uE027"),
  20645. command: 'setImageAlignment|left'
  20646. },
  20647. 'align-center': {
  20648. text: external_react_default.a.createElement("span", {
  20649. "data-align": "center"
  20650. }, "\uE028"),
  20651. command: 'setImageAlignment|center'
  20652. },
  20653. 'align-right': {
  20654. text: external_react_default.a.createElement("span", {
  20655. "data-align": "right"
  20656. }, "\uE029"),
  20657. command: 'setImageAlignment|right'
  20658. },
  20659. 'size': {
  20660. text: external_react_default.a.createElement("span", null, "\uE3C2"),
  20661. command: 'toggleSizeEditor'
  20662. },
  20663. 'link': {
  20664. text: external_react_default.a.createElement("span", null, "\uE91A"),
  20665. command: 'toggleLinkEditor'
  20666. },
  20667. 'remove': {
  20668. text: external_react_default.a.createElement("span", null, "\uE9AC"),
  20669. command: 'removeImage'
  20670. }
  20671. };
  20672. // CONCATENATED MODULE: ./renderers/atomics/Image/index.jsx
  20673. var Image_Image =
  20674. /*#__PURE__*/
  20675. function (_React$Component) {
  20676. inherits_default()(Image, _React$Component);
  20677. function Image() {
  20678. var _getPrototypeOf2;
  20679. var _this;
  20680. classCallCheck_default()(this, Image);
  20681. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  20682. args[_key] = arguments[_key];
  20683. }
  20684. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Image)).call.apply(_getPrototypeOf2, [this].concat(args)));
  20685. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  20686. toolbarVisible: false,
  20687. toolbarOffset: 0,
  20688. linkEditorVisible: false,
  20689. sizeEditorVisible: false,
  20690. tempLink: null,
  20691. tempWidth: null,
  20692. tempHeight: null
  20693. });
  20694. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialLeft", void 0);
  20695. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialTop", void 0);
  20696. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialWidth", void 0);
  20697. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialHeight", void 0);
  20698. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "reSizeType", void 0);
  20699. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "changeSize", function (e) {
  20700. var type = _this.reSizeType;
  20701. if (!_this.initialLeft) {
  20702. _this.initialLeft = e.screenX;
  20703. _this.initialTop = e.screenY;
  20704. }
  20705. if (type === 'rightbottom') {
  20706. _this.initialHeight += e.screenY - _this.initialTop;
  20707. _this.initialWidth += e.screenX - _this.initialLeft;
  20708. }
  20709. if (type === 'leftbottom') {
  20710. _this.initialHeight += e.screenY - _this.initialTop;
  20711. _this.initialWidth += -e.screenX + _this.initialLeft;
  20712. }
  20713. _this.initialLeft = e.screenX;
  20714. _this.initialTop = e.screenY;
  20715. });
  20716. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "moveImage", function (e) {
  20717. _this.changeSize(e);
  20718. _this.setState({
  20719. tempWidth: Math.abs(_this.initialWidth),
  20720. tempHeight: Math.abs(_this.initialHeight)
  20721. });
  20722. });
  20723. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "upImage", function () {
  20724. _this.confirmImageSize();
  20725. document.removeEventListener('mousemove', _this.moveImage);
  20726. document.removeEventListener('mouseup', _this.upImage);
  20727. });
  20728. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "repareChangeSize", function (type) {
  20729. return function (e) {
  20730. _this.reSizeType = type;
  20731. var imageRect = _this.imageElement.getBoundingClientRect();
  20732. _this.initialLeft = _this.initialTop = 0;
  20733. _this.initialWidth = imageRect.width;
  20734. _this.initialHeight = imageRect.height;
  20735. e.preventDefault();
  20736. document.addEventListener('mousemove', _this.moveImage);
  20737. document.addEventListener('mouseup', _this.upImage);
  20738. };
  20739. });
  20740. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "preventDragEvent", function (event) {
  20741. event.stopPropagation();
  20742. event.preventDefault();
  20743. });
  20744. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDragStart", function () {
  20745. if (_this.props.editor.editorProps.readOnly || _this.props.editor.editorProps.disabled) {
  20746. return false;
  20747. }
  20748. window.__BRAFT_DRAGING__IMAGE__ = {
  20749. block: _this.props.block,
  20750. mediaData: objectSpread_default()({
  20751. type: 'IMAGE'
  20752. }, _this.props.mediaData)
  20753. };
  20754. _this.setState({
  20755. toolbarVisible: false
  20756. }, function () {
  20757. _this.unlockEditor();
  20758. });
  20759. return true;
  20760. });
  20761. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDragEnd", function () {
  20762. window.__BRAFT_DRAGING__IMAGE__ = null;
  20763. return false;
  20764. });
  20765. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "executeCommand", function (command) {
  20766. if (typeof command === 'string') {
  20767. var _command$split = command.split('|'),
  20768. _command$split2 = slicedToArray_default()(_command$split, 2),
  20769. method = _command$split2[0],
  20770. param = _command$split2[1];
  20771. _this[method] && _this[method](param);
  20772. } else if (typeof command === 'function') {
  20773. command(_this.props.block, _this.props.mediaData, _this.props.editor.getValue());
  20774. }
  20775. });
  20776. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeImage", function () {
  20777. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editor.getValue(), _this.props.block));
  20778. _this.unlockEditor();
  20779. });
  20780. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleLinkEditor", function () {
  20781. _this.setState({
  20782. linkEditorVisible: !_this.state.linkEditorVisible,
  20783. sizeEditorVisible: false
  20784. });
  20785. });
  20786. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleSizeEditor", function () {
  20787. _this.setState({
  20788. linkEditorVisible: false,
  20789. sizeEditorVisible: !_this.state.sizeEditorVisible
  20790. });
  20791. });
  20792. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleLinkInputKeyDown", function (e) {
  20793. if (e.keyCode === 13) {
  20794. _this.confirmImageLink();
  20795. } else {
  20796. return;
  20797. }
  20798. });
  20799. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageLink", function (e) {
  20800. _this.setState({
  20801. tempLink: e.currentTarget.value
  20802. });
  20803. return;
  20804. });
  20805. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "confirmImageLink", function () {
  20806. var link = _this.state.tempLink;
  20807. var hookReturns = _this.props.hooks('set-image-link', link)(link);
  20808. if (hookReturns === false) {
  20809. return false;
  20810. }
  20811. if (typeof hookReturns === 'string') {
  20812. link = hookReturns;
  20813. }
  20814. if (link !== null) {
  20815. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(_this.props.editor.getValue(), _this.props.entityKey, {
  20816. link: link
  20817. }));
  20818. window.setImmediate(_this.props.editor.forceRender);
  20819. }
  20820. });
  20821. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleSizeInputKeyDown", function (e) {
  20822. if (e.keyCode === 13) {
  20823. _this.confirmImageSize();
  20824. } else {
  20825. return;
  20826. }
  20827. });
  20828. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageWidth", function (_ref) {
  20829. var currentTarget = _ref.currentTarget;
  20830. var value = currentTarget.value;
  20831. value && !isNaN(value) && (value = value + 'px');
  20832. _this.setState({
  20833. tempWidth: value
  20834. });
  20835. return;
  20836. });
  20837. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageHeight", function (_ref2) {
  20838. var currentTarget = _ref2.currentTarget;
  20839. var value = currentTarget.value;
  20840. value && !isNaN(value) && (value = value + 'px');
  20841. _this.setState({
  20842. tempHeight: value
  20843. });
  20844. return;
  20845. });
  20846. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "confirmImageSize", function () {
  20847. var _this$state = _this.state,
  20848. width = _this$state.tempWidth,
  20849. height = _this$state.tempHeight;
  20850. var newImageSize = {};
  20851. width !== null && (newImageSize.width = width);
  20852. height !== null && (newImageSize.height = height);
  20853. var hookReturns = _this.props.hooks('set-image-size', newImageSize)(newImageSize);
  20854. if (hookReturns === false) {
  20855. return false;
  20856. }
  20857. if (hookReturns && (hookReturns.width || hookReturns.height)) {
  20858. newImageSize = hookReturns;
  20859. }
  20860. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(_this.props.editor.getValue(), _this.props.entityKey, newImageSize));
  20861. window.setImmediate(_this.props.editor.forceRender);
  20862. });
  20863. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageFloat", function (float) {
  20864. var hookReturns = _this.props.hooks('set-image-float', float)(float);
  20865. if (hookReturns === false) {
  20866. return false;
  20867. }
  20868. if (typeof hookReturns === 'string') {
  20869. float = hookReturns;
  20870. }
  20871. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaPosition(_this.props.editor.getValue(), _this.props.block, {
  20872. float: float
  20873. }));
  20874. _this.unlockEditor();
  20875. });
  20876. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageAlignment", function (alignment) {
  20877. var hookReturns = _this.props.hooks('set-image-alignment', alignment)(alignment);
  20878. if (hookReturns === false) {
  20879. return false;
  20880. }
  20881. if (typeof hookReturns === 'string') {
  20882. alignment = hookReturns;
  20883. }
  20884. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaPosition(_this.props.editor.getValue(), _this.props.block, {
  20885. alignment: alignment
  20886. }));
  20887. _this.unlockEditor();
  20888. });
  20889. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "showToolbar", function (event) {
  20890. if (_this.props.editor.editorProps.readOnly || _this.props.editor.editorProps.disabled) {
  20891. return false;
  20892. }
  20893. event.preventDefault();
  20894. if (!_this.state.toolbarVisible) {
  20895. _this.setState({
  20896. toolbarVisible: true
  20897. }, function () {
  20898. _this.lockEditor();
  20899. _this.setState({
  20900. toolbarOffset: _this.calcToolbarOffset()
  20901. });
  20902. });
  20903. }
  20904. });
  20905. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "hideToolbar", function (event) {
  20906. event.preventDefault();
  20907. _this.setState({
  20908. toolbarVisible: false
  20909. }, function () {
  20910. _this.unlockEditor(); // this.props.editor.requestFocus()
  20911. });
  20912. });
  20913. return _this;
  20914. }
  20915. createClass_default()(Image, [{
  20916. key: "render",
  20917. value: function render() {
  20918. var _this2 = this;
  20919. var _this$props = this.props,
  20920. mediaData = _this$props.mediaData,
  20921. language = _this$props.language,
  20922. imageControls = _this$props.imageControls,
  20923. imageResizable = _this$props.imageResizable;
  20924. var _this$state2 = this.state,
  20925. toolbarVisible = _this$state2.toolbarVisible,
  20926. toolbarOffset = _this$state2.toolbarOffset,
  20927. linkEditorVisible = _this$state2.linkEditorVisible,
  20928. sizeEditorVisible = _this$state2.sizeEditorVisible,
  20929. tempWidth = _this$state2.tempWidth,
  20930. tempHeight = _this$state2.tempHeight;
  20931. var blockData = this.props.block.getData();
  20932. var float = blockData.get('float');
  20933. var alignment = blockData.get('alignment');
  20934. var url = mediaData.url,
  20935. link = mediaData.link,
  20936. link_target = mediaData.link_target,
  20937. width = mediaData.width,
  20938. height = mediaData.height,
  20939. meta = mediaData.meta;
  20940. var imageStyles = {};
  20941. var clearFix = false;
  20942. if (float) {
  20943. alignment = null;
  20944. } else if (alignment === 'left') {
  20945. imageStyles.float = 'left';
  20946. clearFix = true;
  20947. } else if (alignment === 'right') {
  20948. imageStyles.float = 'right';
  20949. clearFix = true;
  20950. } else if (alignment === 'center') {
  20951. imageStyles.textAlign = 'center';
  20952. } else {
  20953. imageStyles.float = 'left';
  20954. clearFix = true;
  20955. }
  20956. var renderedControlItems = imageControls.map(function (item, index) {
  20957. if (typeof item === 'string' && imageControlItems[item]) {
  20958. return external_react_default.a.createElement("a", {
  20959. className: item === 'link' && link ? 'active' : '',
  20960. key: index,
  20961. onClick: function onClick() {
  20962. return _this2.executeCommand(imageControlItems[item].command);
  20963. }
  20964. }, imageControlItems[item].text);
  20965. } else if (item && (item.render || item.text)) {
  20966. return item.render ? item.render(mediaData, _this2.props.block) : external_react_default.a.createElement("a", {
  20967. key: index,
  20968. onClick: function onClick() {
  20969. return item.onClick && _this2.executeCommand(item.onClick);
  20970. }
  20971. }, item.text);
  20972. } else {
  20973. return null;
  20974. }
  20975. });
  20976. return external_react_default.a.createElement("div", {
  20977. className: "bf-media"
  20978. }, external_react_default.a.createElement("div", {
  20979. style: imageStyles,
  20980. draggable: true,
  20981. onMouseEnter: this.showToolbar,
  20982. onMouseMove: this.showToolbar,
  20983. onMouseLeave: this.hideToolbar,
  20984. onDragStart: this.handleDragStart,
  20985. onDragEnd: this.handleDragEnd,
  20986. ref: function ref(instance) {
  20987. return _this2.mediaEmbederInstance = instance;
  20988. },
  20989. className: "bf-image"
  20990. }, toolbarVisible ? external_react_default.a.createElement("div", {
  20991. style: {
  20992. marginLeft: toolbarOffset
  20993. },
  20994. ref: function ref(instance) {
  20995. return _this2.toolbarElement = instance;
  20996. },
  20997. "data-float": float,
  20998. "data-align": alignment,
  20999. className: "bf-media-toolbar"
  21000. }, linkEditorVisible ? external_react_default.a.createElement("div", {
  21001. className: "bf-image-link-editor"
  21002. }, external_react_default.a.createElement("div", {
  21003. className: "editor-input-group"
  21004. }, external_react_default.a.createElement("input", {
  21005. type: "text",
  21006. placeholder: language.linkEditor.inputWithEnterPlaceHolder,
  21007. onKeyDown: this.handleLinkInputKeyDown,
  21008. onChange: this.setImageLink,
  21009. defaultValue: link
  21010. }), external_react_default.a.createElement("button", {
  21011. type: "button",
  21012. onClick: this.confirmImageLink
  21013. }, language.base.confirm)), external_react_default.a.createElement("div", {
  21014. className: "switch-group"
  21015. }, external_react_default.a.createElement(Switch, {
  21016. active: link_target === '_blank',
  21017. onClick: function onClick() {
  21018. return _this2.setImageLinkTarget(link_target);
  21019. }
  21020. }), external_react_default.a.createElement("label", null, language.linkEditor.openInNewWindow))) : null, sizeEditorVisible ? external_react_default.a.createElement("div", {
  21021. className: "bf-image-size-editor"
  21022. }, external_react_default.a.createElement("div", {
  21023. className: "editor-input-group"
  21024. }, external_react_default.a.createElement("input", {
  21025. type: "text",
  21026. placeholder: language.base.width,
  21027. onKeyDown: this.handleSizeInputKeyDown,
  21028. onChange: this.setImageWidth,
  21029. defaultValue: width
  21030. }), external_react_default.a.createElement("input", {
  21031. type: "text",
  21032. placeholder: language.base.height,
  21033. onKeyDown: this.handleSizeInputKeyDown,
  21034. onChange: this.setImageHeight,
  21035. defaultValue: height
  21036. }), external_react_default.a.createElement("button", {
  21037. type: "button",
  21038. onClick: this.confirmImageSize
  21039. }, language.base.confirm))) : null, renderedControlItems, external_react_default.a.createElement("i", {
  21040. style: {
  21041. marginLeft: toolbarOffset * -1
  21042. },
  21043. className: "bf-media-toolbar-arrow"
  21044. })) : null, external_react_default.a.createElement("div", {
  21045. style: {
  21046. position: 'relative',
  21047. width: "".concat(width, "px"),
  21048. height: "".concat(height, "px"),
  21049. display: 'inline-block'
  21050. }
  21051. }, external_react_default.a.createElement("img", extends_default()({
  21052. ref: function ref(instance) {
  21053. return _this2.imageElement = instance;
  21054. },
  21055. src: url,
  21056. width: width,
  21057. height: height
  21058. }, meta)), toolbarVisible && imageResizable ? external_react_default.a.createElement("div", {
  21059. className: "bf-csize-icon right-bottom",
  21060. onMouseDown: this.repareChangeSize('rightbottom')
  21061. }) : null, toolbarVisible && imageResizable ? external_react_default.a.createElement("div", {
  21062. className: "bf-csize-icon left-bottom",
  21063. onMouseDown: this.repareChangeSize('leftbottom')
  21064. }) : null, external_react_default.a.createElement("div", {
  21065. className: "bf-pre-csize ".concat(this.reSizeType),
  21066. style: {
  21067. width: "".concat(tempWidth, "px"),
  21068. height: "".concat(tempHeight, "px")
  21069. }
  21070. }))), clearFix && external_react_default.a.createElement("div", {
  21071. className: "clearfix",
  21072. style: {
  21073. clear: 'both',
  21074. height: 0,
  21075. lineHeight: 0,
  21076. float: 'none'
  21077. }
  21078. }));
  21079. }
  21080. }, {
  21081. key: "lockEditor",
  21082. value: function lockEditor() {
  21083. this.props.editor.lockOrUnlockEditor(true);
  21084. }
  21085. }, {
  21086. key: "unlockEditor",
  21087. value: function unlockEditor() {
  21088. this.props.editor.lockOrUnlockEditor(false);
  21089. }
  21090. }, {
  21091. key: "calcToolbarOffset",
  21092. value: function calcToolbarOffset() {
  21093. var _this$props2 = this.props,
  21094. getContainerNode = _this$props2.getContainerNode,
  21095. containerNode = _this$props2.containerNode;
  21096. var container = getContainerNode ? getContainerNode() : containerNode;
  21097. if (!container) {
  21098. return 0;
  21099. }
  21100. var viewRect = container.querySelector('.bf-content').getBoundingClientRect();
  21101. var toolbarRect = this.toolbarElement.getBoundingClientRect();
  21102. var imageRect = this.imageElement.getBoundingClientRect();
  21103. var right = viewRect.right - (imageRect.right - imageRect.width / 2 + toolbarRect.width / 2);
  21104. var left = imageRect.left + imageRect.width / 2 - toolbarRect.width / 2 - viewRect.left;
  21105. if (right < 10) {
  21106. return right - 10;
  21107. } else if (left < 10) {
  21108. return left * -1 + 10;
  21109. } else {
  21110. return 0;
  21111. }
  21112. }
  21113. }, {
  21114. key: "setImageLinkTarget",
  21115. value: function setImageLinkTarget(link_target) {
  21116. var hookReturns = this.props.hooks('set-image-link-target', link_target)(link_target);
  21117. if (hookReturns === false) {
  21118. return false;
  21119. }
  21120. if (typeof hookReturns === 'string') {
  21121. link_target = hookReturns;
  21122. }
  21123. link_target = link_target === '_blank' ? '' : '_blank';
  21124. this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(this.props.editor.getValue(), this.props.entityKey, {
  21125. link_target: link_target
  21126. }));
  21127. window.setImmediate(this.props.editor.forceRender);
  21128. }
  21129. }]);
  21130. return Image;
  21131. }(external_react_default.a.Component);
  21132. // EXTERNAL MODULE: ./renderers/atomics/Video/style.scss
  21133. var Video_style = __webpack_require__(47);
  21134. // EXTERNAL MODULE: ./components/common/Modal/style.scss
  21135. var Modal_style = __webpack_require__(48);
  21136. // EXTERNAL MODULE: external "react-dom"
  21137. var external_react_dom_ = __webpack_require__(16);
  21138. var external_react_dom_default = /*#__PURE__*/__webpack_require__.n(external_react_dom_);
  21139. // CONCATENATED MODULE: ./components/common/Modal/index.jsx
  21140. var Modal_Modal =
  21141. /*#__PURE__*/
  21142. function (_React$Component) {
  21143. inherits_default()(Modal, _React$Component);
  21144. function Modal(props) {
  21145. var _this;
  21146. classCallCheck_default()(this, Modal);
  21147. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(Modal).call(this, props));
  21148. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleTransitionEnd", function () {
  21149. if (!_this.rootElement || !_this.rootElement.classList) {
  21150. return false;
  21151. }
  21152. if (!_this.rootElement.classList.contains('active')) {
  21153. external_react_dom_default.a.unmountComponentAtNode(_this.rootElement) && _this.rootElement.parentNode.removeChild(_this.rootElement);
  21154. }
  21155. });
  21156. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleMouseDown", function (event) {
  21157. var tagName = event.target.tagName.toLowerCase();
  21158. if (tagName === 'input' || tagName === 'textarea') {
  21159. return false;
  21160. }
  21161. event.preventDefault();
  21162. });
  21163. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCancel", function () {
  21164. _this.props.closeOnCancel && _this.close();
  21165. _this.props.onCancel && _this.props.onCancel();
  21166. });
  21167. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleConfirm", function () {
  21168. _this.props.closeOnConfirm && _this.close();
  21169. _this.props.onConfirm && _this.props.onConfirm();
  21170. });
  21171. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleMaskClick", function () {
  21172. _this.props.closeOnBlur && _this.close();
  21173. _this.props.onBlue && _this.props.onBlue();
  21174. });
  21175. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "close", function () {
  21176. _this.unrenderComponent();
  21177. _this.props.onClose && _this.props.onClose();
  21178. });
  21179. _this.active = false;
  21180. _this.componentId = 'BRAFT-MODAL-' + external_braft_utils_["BaseUtils"].UniqueIndex();
  21181. return _this;
  21182. }
  21183. createClass_default()(Modal, [{
  21184. key: "componentDidMount",
  21185. value: function componentDidMount() {
  21186. if (this.props.visible) {
  21187. this.active = true;
  21188. this.renderComponent(this.props);
  21189. }
  21190. }
  21191. }, {
  21192. key: "componentWillReceiveProps",
  21193. value: function componentWillReceiveProps(next) {
  21194. if (this.props.visible && !next.visible) {
  21195. this.unrenderComponent();
  21196. } else if (this.props.visible || next.visible) {
  21197. this.active = true;
  21198. this.renderComponent(next);
  21199. }
  21200. }
  21201. }, {
  21202. key: "render",
  21203. value: function render() {
  21204. return null;
  21205. }
  21206. }, {
  21207. key: "unrenderComponent",
  21208. value: function unrenderComponent() {
  21209. this.active = false;
  21210. this.activeId && window.clearImmediate(this.activeId);
  21211. if (this.rootElement && this.rootElement.classList) {
  21212. this.rootElement.classList.remove('active');
  21213. }
  21214. }
  21215. }, {
  21216. key: "renderComponent",
  21217. value: function renderComponent(props) {
  21218. var _this2 = this;
  21219. if (!this.active) {
  21220. return false;
  21221. }
  21222. var title = props.title,
  21223. className = props.className,
  21224. width = props.width,
  21225. height = props.height,
  21226. children = props.children,
  21227. component = props.component,
  21228. confirmable = props.confirmable,
  21229. showFooter = props.showFooter,
  21230. showCancel = props.showCancel,
  21231. showConfirm = props.showConfirm,
  21232. showClose = props.showClose,
  21233. cancelText = props.cancelText,
  21234. confirmText = props.confirmText,
  21235. bottomText = props.bottomText,
  21236. language = props.language;
  21237. typeof showCancel === 'undefined' && (showCancel = true);
  21238. typeof showClose === 'undefined' && (showClose = true);
  21239. typeof showConfirm === 'undefined' && (showConfirm = true);
  21240. typeof showFooter === 'undefined' && (showFooter = true);
  21241. var childComponent = external_react_default.a.createElement("div", {
  21242. onMouseDown: this.handleMouseDown,
  21243. className: 'bf-modal ' + (className || '')
  21244. }, external_react_default.a.createElement("div", {
  21245. className: "bf-modal-mask",
  21246. onClick: this.handleMaskClick
  21247. }), external_react_default.a.createElement("div", {
  21248. onTransitionEnd: this.handleTransitionEnd,
  21249. style: {
  21250. width: width,
  21251. height: height
  21252. },
  21253. className: "bf-modal-content"
  21254. }, external_react_default.a.createElement("div", {
  21255. className: "bf-modal-header"
  21256. }, external_react_default.a.createElement("h3", {
  21257. className: "bf-modal-caption"
  21258. }, title), showClose && external_react_default.a.createElement("button", {
  21259. type: "button",
  21260. onClick: this.close,
  21261. className: "bf-modal-close-button"
  21262. }, external_react_default.a.createElement("i", {
  21263. className: "bfi-close"
  21264. }))), external_react_default.a.createElement("div", {
  21265. className: "bf-modal-body"
  21266. }, children || component), showFooter ? external_react_default.a.createElement("div", {
  21267. className: "bf-modal-footer"
  21268. }, external_react_default.a.createElement("div", {
  21269. className: "bf-modal-addon-text"
  21270. }, bottomText), external_react_default.a.createElement("div", {
  21271. className: "bf-modal-buttons"
  21272. }, showCancel && external_react_default.a.createElement("button", {
  21273. type: "button",
  21274. onClick: this.handleCancel,
  21275. className: "bf-modal-cancel"
  21276. }, cancelText || language.base.cancel), showConfirm && external_react_default.a.createElement("button", {
  21277. type: "button",
  21278. onClick: this.handleConfirm,
  21279. className: 'bf-modal-confirm ' + (!confirmable ? 'disabled' : '')
  21280. }, confirmText || language.base.confirm))) : null));
  21281. this.rootElement = document.querySelector('#' + this.componentId);
  21282. if (!this.rootElement) {
  21283. this.rootElement = document.createElement('div');
  21284. this.rootElement.id = this.componentId;
  21285. this.rootElement.className = 'bf-modal-root';
  21286. document.body.appendChild(this.rootElement);
  21287. }
  21288. external_react_dom_default.a.render(childComponent, this.rootElement);
  21289. this.activeId = window.setImmediate(function () {
  21290. _this2.rootElement.classList.add('active');
  21291. });
  21292. }
  21293. }]);
  21294. return Modal;
  21295. }(external_react_default.a.Component);
  21296. defineProperty_default()(Modal_Modal, "defaultProps", {
  21297. showFooter: true,
  21298. closeOnBlur: true
  21299. });
  21300. var Modal_showModal = function showModal(props) {
  21301. var hostNode = document.createElement('div');
  21302. hostNode.style.display = 'none';
  21303. document.body.appendChild(hostNode);
  21304. props = objectSpread_default()({
  21305. visible: true,
  21306. closeOnConfirm: true,
  21307. closeOnCancel: true
  21308. }, props);
  21309. var close = function close() {
  21310. external_react_dom_default.a.unmountComponentAtNode(hostNode) && hostNode.parentNode.removeChild(hostNode);
  21311. };
  21312. var onConfirm = function onConfirm() {
  21313. props.onConfirm && props.onConfirm();
  21314. };
  21315. var onCancel = function onCancel() {
  21316. props.onCancel && props.onCancel();
  21317. };
  21318. var onClose = function onClose() {
  21319. close();
  21320. props.onClose && props.onClose();
  21321. };
  21322. var modalInstance = external_react_dom_default.a.render(external_react_default.a.createElement(Modal_Modal, extends_default()({}, props, {
  21323. onConfirm: onConfirm,
  21324. onCancel: onCancel,
  21325. onClose: onClose
  21326. })), hostNode);
  21327. modalInstance.destroy = close;
  21328. modalInstance.update = modalInstance.renderComponent;
  21329. return modalInstance;
  21330. };
  21331. // EXTERNAL MODULE: ./components/business/PlayerModal/style.scss
  21332. var PlayerModal_style = __webpack_require__(49);
  21333. // CONCATENATED MODULE: ./components/business/PlayerModal/index.jsx
  21334. var PlayerModal_playViaModal = function playViaModal(title, component, language) {
  21335. return Modal_showModal({
  21336. title: title,
  21337. component: component,
  21338. language: language,
  21339. showFooter: false
  21340. });
  21341. };
  21342. var typeIconsMap = {
  21343. 'video': 'bfi-film',
  21344. 'audio': 'bfi-music',
  21345. 'embed': 'bfi-code'
  21346. };
  21347. /* harmony default export */ var PlayerModal = (function (_ref) {
  21348. var title = _ref.title,
  21349. type = _ref.type,
  21350. language = _ref.language,
  21351. name = _ref.name,
  21352. url = _ref.url,
  21353. poster = _ref.poster,
  21354. children = _ref.children,
  21355. onRemove = _ref.onRemove;
  21356. return external_react_default.a.createElement("div", {
  21357. className: "bf-player-holder ".concat(type)
  21358. }, external_react_default.a.createElement("div", {
  21359. className: "icon-badge"
  21360. }, external_react_default.a.createElement("i", {
  21361. className: typeIconsMap[type]
  21362. }), external_react_default.a.createElement("span", {
  21363. className: "text"
  21364. }, language.media[type])), external_react_default.a.createElement("button", {
  21365. onMouseDown: onRemove,
  21366. className: "button-remove"
  21367. }, external_react_default.a.createElement("i", {
  21368. className: "bfi-close"
  21369. })), external_react_default.a.createElement("button", {
  21370. onMouseDown: function onMouseDown() {
  21371. return PlayerModal_playViaModal(name ? "".concat(title, ":").concat(name) : title, children, language);
  21372. },
  21373. className: "button-play"
  21374. }, external_react_default.a.createElement("i", {
  21375. className: "bfi-play_arrow"
  21376. })), name ? external_react_default.a.createElement("h5", {
  21377. className: "bf-name"
  21378. }, name) : null, external_react_default.a.createElement("h6", {
  21379. className: "bf-url"
  21380. }, url), poster ? external_react_default.a.createElement("div", {
  21381. className: "bf-poster",
  21382. style: {
  21383. backgroundImage: "url(".concat(poster, ")")
  21384. }
  21385. }) : null);
  21386. });
  21387. // CONCATENATED MODULE: ./renderers/atomics/Video/index.jsx
  21388. var Video_Video =
  21389. /*#__PURE__*/
  21390. function (_React$Component) {
  21391. inherits_default()(Video, _React$Component);
  21392. function Video() {
  21393. var _getPrototypeOf2;
  21394. var _this;
  21395. classCallCheck_default()(this, Video);
  21396. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  21397. args[_key] = arguments[_key];
  21398. }
  21399. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Video)).call.apply(_getPrototypeOf2, [this].concat(args)));
  21400. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeVideo", function () {
  21401. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  21402. });
  21403. return _this;
  21404. }
  21405. createClass_default()(Video, [{
  21406. key: "render",
  21407. value: function render() {
  21408. var _this$props = this.props,
  21409. mediaData = _this$props.mediaData,
  21410. language = _this$props.language;
  21411. var url = mediaData.url,
  21412. name = mediaData.name,
  21413. meta = mediaData.meta;
  21414. return external_react_default.a.createElement("div", {
  21415. className: "bf-video-wrap"
  21416. }, external_react_default.a.createElement(PlayerModal, {
  21417. type: "video",
  21418. onRemove: this.removeVideo,
  21419. poster: meta ? meta.poster || '' : '',
  21420. language: language,
  21421. url: url,
  21422. name: name,
  21423. title: language.videoPlayer.title
  21424. }, external_react_default.a.createElement("div", {
  21425. className: "bf-video-player"
  21426. }, external_react_default.a.createElement("video", {
  21427. controls: true,
  21428. poster: meta ? meta.poster || '' : ''
  21429. }, external_react_default.a.createElement("source", {
  21430. src: url
  21431. })))));
  21432. }
  21433. }]);
  21434. return Video;
  21435. }(external_react_default.a.Component);
  21436. // EXTERNAL MODULE: ./renderers/atomics/Audio/style.scss
  21437. var Audio_style = __webpack_require__(50);
  21438. // CONCATENATED MODULE: ./renderers/atomics/Audio/index.jsx
  21439. var Audio_Audio =
  21440. /*#__PURE__*/
  21441. function (_React$Component) {
  21442. inherits_default()(Audio, _React$Component);
  21443. function Audio() {
  21444. var _getPrototypeOf2;
  21445. var _this;
  21446. classCallCheck_default()(this, Audio);
  21447. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  21448. args[_key] = arguments[_key];
  21449. }
  21450. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Audio)).call.apply(_getPrototypeOf2, [this].concat(args)));
  21451. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeAudio", function () {
  21452. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  21453. });
  21454. return _this;
  21455. }
  21456. createClass_default()(Audio, [{
  21457. key: "render",
  21458. value: function render() {
  21459. var _this$props = this.props,
  21460. mediaData = _this$props.mediaData,
  21461. language = _this$props.language;
  21462. var url = mediaData.url,
  21463. name = mediaData.name,
  21464. meta = mediaData.meta;
  21465. return external_react_default.a.createElement("div", {
  21466. className: "bf-audio-wrap"
  21467. }, external_react_default.a.createElement(PlayerModal, {
  21468. type: "audio",
  21469. onRemove: this.removeAudio,
  21470. poster: meta ? meta.poster || '' : '',
  21471. language: language,
  21472. url: url,
  21473. name: name,
  21474. title: language.audioPlayer.title
  21475. }, external_react_default.a.createElement("div", {
  21476. className: "bf-audio-player"
  21477. }, external_react_default.a.createElement("audio", {
  21478. controls: true,
  21479. src: url
  21480. }))));
  21481. }
  21482. }]);
  21483. return Audio;
  21484. }(external_react_default.a.Component);
  21485. // EXTERNAL MODULE: ./renderers/atomics/Embed/style.scss
  21486. var Embed_style = __webpack_require__(51);
  21487. // CONCATENATED MODULE: ./renderers/atomics/Embed/index.jsx
  21488. var Embed_Embed =
  21489. /*#__PURE__*/
  21490. function (_React$Component) {
  21491. inherits_default()(Embed, _React$Component);
  21492. function Embed() {
  21493. var _getPrototypeOf2;
  21494. var _this;
  21495. classCallCheck_default()(this, Embed);
  21496. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  21497. args[_key] = arguments[_key];
  21498. }
  21499. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Embed)).call.apply(_getPrototypeOf2, [this].concat(args)));
  21500. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeEmbed", function () {
  21501. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  21502. });
  21503. return _this;
  21504. }
  21505. createClass_default()(Embed, [{
  21506. key: "render",
  21507. value: function render() {
  21508. var _this$props = this.props,
  21509. mediaData = _this$props.mediaData,
  21510. language = _this$props.language;
  21511. var name = mediaData.name,
  21512. url = mediaData.url,
  21513. meta = mediaData.meta;
  21514. return external_react_default.a.createElement("div", {
  21515. className: "bf-embed-wrap"
  21516. }, external_react_default.a.createElement(PlayerModal, {
  21517. type: "embed",
  21518. onRemove: this.removeEmbed,
  21519. poster: meta ? meta.poster || '' : '',
  21520. language: language,
  21521. url: url,
  21522. name: name,
  21523. title: language.videoPlayer.embedTitle
  21524. }, external_react_default.a.createElement("div", {
  21525. className: "bf-embed-player",
  21526. dangerouslySetInnerHTML: {
  21527. __html: url
  21528. }
  21529. })));
  21530. }
  21531. }]);
  21532. return Embed;
  21533. }(external_react_default.a.Component);
  21534. // EXTERNAL MODULE: ./renderers/atomics/HorizontalLine/style.scss
  21535. var HorizontalLine_style = __webpack_require__(52);
  21536. // CONCATENATED MODULE: ./renderers/atomics/HorizontalLine/index.jsx
  21537. var HorizontalLine_HorizontalLine =
  21538. /*#__PURE__*/
  21539. function (_React$Component) {
  21540. inherits_default()(HorizontalLine, _React$Component);
  21541. function HorizontalLine() {
  21542. var _getPrototypeOf2;
  21543. var _this;
  21544. classCallCheck_default()(this, HorizontalLine);
  21545. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  21546. args[_key] = arguments[_key];
  21547. }
  21548. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(HorizontalLine)).call.apply(_getPrototypeOf2, [this].concat(args)));
  21549. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeHorizontalLine", function () {
  21550. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  21551. });
  21552. return _this;
  21553. }
  21554. createClass_default()(HorizontalLine, [{
  21555. key: "render",
  21556. value: function render() {
  21557. return external_react_default.a.createElement("div", {
  21558. className: "bf-hr"
  21559. }, external_react_default.a.createElement("div", {
  21560. className: "bf-media-toolbar"
  21561. }, external_react_default.a.createElement("a", {
  21562. onClick: this.removeHorizontalLine
  21563. }, "\uE9AC")));
  21564. }
  21565. }]);
  21566. return HorizontalLine;
  21567. }(external_react_default.a.Component);
  21568. // CONCATENATED MODULE: ./renderers/block/blockRendererFn.js
  21569. var blockRendererFn_BlockRenderFnContext = function BlockRenderFnContext() {
  21570. var _this = this;
  21571. classCallCheck_default()(this, BlockRenderFnContext);
  21572. defineProperty_default()(this, "superProps", void 0);
  21573. defineProperty_default()(this, "customBlockRendererFn", void 0);
  21574. defineProperty_default()(this, "getRenderFn", function (superProps, customBlockRendererFn) {
  21575. _this.superProps = superProps;
  21576. _this.customBlockRendererFn = customBlockRendererFn;
  21577. return _this.blockRendererFn;
  21578. });
  21579. defineProperty_default()(this, "renderAtomicBlock", function (props) {
  21580. var superProps = _this.superProps;
  21581. var entityKey = props.block.getEntityAt(0);
  21582. if (!entityKey) {
  21583. return null;
  21584. }
  21585. var entity = props.contentState.getEntity(entityKey);
  21586. var mediaData = entity.getData();
  21587. var mediaType = entity.getType();
  21588. var mediaProps = objectSpread_default()({}, superProps, {
  21589. block: props.block,
  21590. mediaData: mediaData,
  21591. entityKey: entityKey
  21592. });
  21593. if (mediaType === 'IMAGE') {
  21594. return external_react_default.a.createElement(Image_Image, mediaProps);
  21595. } else if (mediaType === 'AUDIO') {
  21596. return external_react_default.a.createElement(Audio_Audio, mediaProps);
  21597. } else if (mediaType === 'VIDEO') {
  21598. return external_react_default.a.createElement(Video_Video, mediaProps);
  21599. } else if (mediaType === 'EMBED') {
  21600. return external_react_default.a.createElement(Embed_Embed, mediaProps);
  21601. } else if (mediaType === 'HR') {
  21602. return external_react_default.a.createElement(HorizontalLine_HorizontalLine, mediaProps);
  21603. }
  21604. if (superProps.extendAtomics) {
  21605. var atomics = superProps.extendAtomics;
  21606. for (var i = 0; i < atomics.length; i++) {
  21607. if (mediaType === atomics[i].type) {
  21608. var Component = atomics[i].component;
  21609. return external_react_default.a.createElement(Component, mediaProps);
  21610. }
  21611. }
  21612. }
  21613. return null;
  21614. });
  21615. defineProperty_default()(this, "blockRendererFn", function (block) {
  21616. var customBlockRendererFn = _this.customBlockRendererFn,
  21617. superProps = _this.superProps;
  21618. var blockType = block.getType();
  21619. var blockRenderer = null;
  21620. if (customBlockRendererFn) {
  21621. blockRenderer = customBlockRendererFn(block, superProps) || null;
  21622. }
  21623. if (blockRenderer) {
  21624. return blockRenderer;
  21625. }
  21626. var extensionBlockRendererFns = getExtensionBlockRendererFns(superProps.editorId);
  21627. extensionBlockRendererFns.find(function (item) {
  21628. if (item.blockType === blockType || item.blockType instanceof RegExp && item.blockType.test(blockType)) {
  21629. blockRenderer = item.rendererFn ? item.rendererFn(superProps) : null;
  21630. return true;
  21631. }
  21632. });
  21633. if (blockRenderer) {
  21634. return blockRenderer;
  21635. }
  21636. if (blockType === 'atomic') {
  21637. blockRenderer = {
  21638. component: _this.renderAtomicBlock,
  21639. editable: false
  21640. };
  21641. }
  21642. return blockRenderer;
  21643. });
  21644. };
  21645. var blockRenderFnContext = new blockRendererFn_BlockRenderFnContext();
  21646. /* harmony default export */ var block_blockRendererFn = (blockRenderFnContext.getRenderFn);
  21647. // CONCATENATED MODULE: ./renderers/block/blockStyleFn.js
  21648. /* harmony default export */ var block_blockStyleFn = (function (customBlockStyleFn) {
  21649. return function (block) {
  21650. var blockAlignment = block.getData() && block.getData().get('textAlign');
  21651. var blockIndent = block.getData() && block.getData().get('textIndent');
  21652. var blockFloat = block.getData() && block.getData().get('float');
  21653. var result = '';
  21654. if (blockAlignment) {
  21655. result = "bfa-".concat(blockAlignment);
  21656. }
  21657. if (blockIndent && blockIndent !== 0) {
  21658. result += " bftd-".concat(blockIndent);
  21659. }
  21660. if (blockFloat) {
  21661. result += " bff-".concat(blockFloat);
  21662. }
  21663. if (customBlockStyleFn) {
  21664. result += customBlockStyleFn(block) || '';
  21665. }
  21666. return result;
  21667. };
  21668. });
  21669. // CONCATENATED MODULE: ./renderers/inline/inlineStyleMap.js
  21670. /* harmony default export */ var inlineStyleMap = (function (props) {
  21671. var customStyleMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  21672. var extensionInlineStyleMap = getExtensionInlineStyleMap(props.editorId);
  21673. return objectSpread_default()({
  21674. 'SUPERSCRIPT': {
  21675. position: 'relative',
  21676. top: '-8px',
  21677. fontSize: '11px'
  21678. },
  21679. 'SUBSCRIPT': {
  21680. position: 'relative',
  21681. bottom: '-8px',
  21682. fontSize: '11px'
  21683. }
  21684. }, extensionInlineStyleMap, customStyleMap);
  21685. });
  21686. // CONCATENATED MODULE: ./renderers/inline/inlineStyleFn.js
  21687. var getStyleValue = function getStyleValue(style) {
  21688. return style.split('-')[1];
  21689. };
  21690. /* harmony default export */ var inlineStyleFn = (function (props, options) {
  21691. return function (styles, block) {
  21692. var output = {};
  21693. var fontFamilies = options.fontFamilies,
  21694. unitExportFn = options.unitExportFn,
  21695. customStyleFn = options.customStyleFn;
  21696. var extensionInlineStyleFns = getExtensionInlineStyleFns(props.editorId);
  21697. extensionInlineStyleFns.forEach(function (item) {
  21698. output = item.styleFn ? item.styleFn(styles, block, output) : output;
  21699. });
  21700. output = customStyleFn ? customStyleFn(styles, block, output) : {};
  21701. styles.forEach(function (style) {
  21702. if (style.indexOf('COLOR-') === 0) {
  21703. output.color = '#' + getStyleValue(style);
  21704. } else if (style.indexOf('BGCOLOR-') === 0) {
  21705. output.backgroundColor = '#' + getStyleValue(style);
  21706. } else if (style.indexOf('FONTSIZE-') === 0) {
  21707. output.fontSize = unitExportFn(getStyleValue(style), 'font-size', 'editor');
  21708. } else if (style.indexOf('LINEHEIGHT-') === 0) {
  21709. output.lineHeight = unitExportFn(getStyleValue(style), 'line-height', 'editor');
  21710. } else if (style.indexOf('LETTERSPACING-') === 0) {
  21711. output.letterSpacing = unitExportFn(getStyleValue(style), 'letter-spacing', 'editor');
  21712. } else if (style.indexOf('TEXTINDENT-') === 0) {
  21713. output.textIndent = unitExportFn(getStyleValue(style), 'text-indent', 'editor');
  21714. } else if (style.indexOf('FONTFAMILY-') === 0) {
  21715. output.fontFamily = (fontFamilies.find(function (item) {
  21716. return item.name.toUpperCase() === getStyleValue(style);
  21717. }) || {}).family || '';
  21718. }
  21719. });
  21720. return output;
  21721. };
  21722. });
  21723. // EXTERNAL MODULE: ../node_modules/draft-js-multidecorators/index.js
  21724. var draft_js_multidecorators = __webpack_require__(18);
  21725. var draft_js_multidecorators_default = /*#__PURE__*/__webpack_require__.n(draft_js_multidecorators);
  21726. // CONCATENATED MODULE: ./renderers/decorators/Link/index.jsx
  21727. /* harmony default export */ var Link = (function (props) {
  21728. var children = props.children,
  21729. entityKey = props.entityKey,
  21730. contentState = props.contentState;
  21731. var _contentState$getEnti = contentState.getEntity(entityKey).getData(),
  21732. href = _contentState$getEnti.href,
  21733. target = _contentState$getEnti.target;
  21734. return external_react_default.a.createElement("span", {
  21735. className: "bf-link-wrap"
  21736. }, external_react_default.a.createElement("a", {
  21737. onClick: function onClick(event) {
  21738. return viewLink(event, href);
  21739. },
  21740. className: "bf-link",
  21741. href: href,
  21742. target: target
  21743. }, children));
  21744. });
  21745. var viewLink = function viewLink(event, link) {
  21746. // 当按下Ctrl/command键时,点击打开链接文字中的url
  21747. if (event.getModifierState('Control') || event.getModifierState('Meta')) {
  21748. var tempLink = document.createElement('a');
  21749. tempLink.href = link;
  21750. tempLink.target = event.currentTarget.target;
  21751. tempLink.click();
  21752. }
  21753. };
  21754. // CONCATENATED MODULE: ./renderers/decorators/index.js
  21755. var KEY_SEPARATOR = '-';
  21756. draft_js_multidecorators_default.a.prototype.getDecorations = function (block, contentState) {
  21757. var decorations = Array(block.getText().length).fill(null);
  21758. this.decorators.forEach(function (decorator, i) {
  21759. decorator.getDecorations(block, contentState).forEach(function (key, offset) {
  21760. if (!key) {
  21761. return;
  21762. }
  21763. key = i + KEY_SEPARATOR + key;
  21764. decorations[offset] = key;
  21765. });
  21766. });
  21767. return external_immutable_default.a.List(decorations);
  21768. };
  21769. var builtinDecorators = [{
  21770. type: 'entity',
  21771. decorator: {
  21772. key: 'LINK',
  21773. component: Link
  21774. }
  21775. }];
  21776. var createStrategy = function createStrategy(type) {
  21777. return function (block, callback, contentState) {
  21778. block.findEntityRanges(function (character) {
  21779. var entityKey = character.getEntity();
  21780. return entityKey !== null && contentState.getEntity(entityKey).getType() === type;
  21781. }, callback);
  21782. };
  21783. };
  21784. /* harmony default export */ var decorators = (function (editorId) {
  21785. var extensionDecorators = getExtensionDecorators(editorId);
  21786. var entityDecorators = builtinDecorators.concat(toConsumableArray_default()(extensionDecorators.filter(function (item) {
  21787. return item.type === 'entity';
  21788. })));
  21789. var strategyDecorators = extensionDecorators.filter(function (item) {
  21790. return item.type === 'strategy';
  21791. });
  21792. var classDecorators = extensionDecorators.filter(function (item) {
  21793. return item.type === 'class';
  21794. });
  21795. return new draft_js_multidecorators_default.a(toConsumableArray_default()(classDecorators.map(function (item) {
  21796. return item.decorator;
  21797. })).concat([// combine decorators created with strategy
  21798. new external_draft_js_["CompositeDecorator"](strategyDecorators.map(function (item) {
  21799. return item.decorator;
  21800. })), // combine decorators for entities
  21801. new external_draft_js_["CompositeDecorator"](entityDecorators.map(function (item) {
  21802. return {
  21803. strategy: createStrategy(item.decorator.key),
  21804. component: item.decorator.component
  21805. };
  21806. }))]));
  21807. });
  21808. // CONCATENATED MODULE: ./renderers/index.js
  21809. var getBlockRenderMap = block_blockRenderMap;
  21810. var getBlockRendererFn = block_blockRendererFn;
  21811. var getBlockStyleFn = block_blockStyleFn;
  21812. var getCustomStyleMap = inlineStyleMap;
  21813. var getCustomStyleFn = inlineStyleFn;
  21814. var getDecorators = decorators;
  21815. // EXTERNAL MODULE: ./components/business/ControlBar/style.scss
  21816. var ControlBar_style = __webpack_require__(53);
  21817. // EXTERNAL MODULE: ./components/business/LinkEditor/style.scss
  21818. var LinkEditor_style = __webpack_require__(54);
  21819. // EXTERNAL MODULE: ./components/common/DropDown/style.scss
  21820. var DropDown_style = __webpack_require__(55);
  21821. // CONCATENATED MODULE: ./helpers/responsive.js
  21822. var resizeEventHandlers = [];
  21823. var responsiveHelperInited = false;
  21824. var debouce = false;
  21825. /* harmony default export */ var responsive = ({
  21826. resolve: function resolve(eventHandler) {
  21827. var id = external_braft_utils_["BaseUtils"].UniqueIndex();
  21828. resizeEventHandlers.push({
  21829. id: id,
  21830. eventHandler: eventHandler
  21831. });
  21832. return id;
  21833. },
  21834. unresolve: function unresolve(id) {
  21835. resizeEventHandlers = resizeEventHandlers.filter(function (item) {
  21836. return item.id !== id;
  21837. });
  21838. }
  21839. });
  21840. if (!responsiveHelperInited && (typeof window === "undefined" ? "undefined" : typeof_default()(window)) === 'object') {
  21841. window.addEventListener('resize', function (event) {
  21842. clearTimeout(debouce);
  21843. debouce = setTimeout(function () {
  21844. resizeEventHandlers.map(function (item) {
  21845. typeof item.eventHandler === 'function' && item.eventHandler(event);
  21846. });
  21847. debouce = false;
  21848. }, 100);
  21849. });
  21850. responsiveHelperInited = true;
  21851. }
  21852. // CONCATENATED MODULE: ./components/common/DropDown/index.jsx
  21853. var DropDown_DropDown =
  21854. /*#__PURE__*/
  21855. function (_React$Component) {
  21856. inherits_default()(DropDown, _React$Component);
  21857. function DropDown() {
  21858. var _getPrototypeOf2;
  21859. var _this;
  21860. classCallCheck_default()(this, DropDown);
  21861. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  21862. args[_key] = arguments[_key];
  21863. }
  21864. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(DropDown)).call.apply(_getPrototypeOf2, [this].concat(args)));
  21865. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "responsiveResolveId", null);
  21866. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownHandlerElement", null);
  21867. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownContentElement", null);
  21868. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  21869. active: false,
  21870. offset: 0
  21871. });
  21872. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "fixDropDownPosition", function () {
  21873. var viewRect = _this.props.getContainerNode().getBoundingClientRect();
  21874. var handlerRect = _this.dropDownHandlerElement.getBoundingClientRect();
  21875. var contentRect = _this.dropDownContentElement.getBoundingClientRect();
  21876. var offset = 0;
  21877. var right = handlerRect.right - handlerRect.width / 2 + contentRect.width / 2;
  21878. var left = handlerRect.left + handlerRect.width / 2 - contentRect.width / 2;
  21879. right = viewRect.right - right;
  21880. left = left - viewRect.left;
  21881. if (right < 10) {
  21882. offset = right - 10;
  21883. } else if (left < 10) {
  21884. offset = left * -1 + 10;
  21885. }
  21886. if (offset !== _this.state.offset) {
  21887. _this.setState({
  21888. offset: offset
  21889. });
  21890. }
  21891. });
  21892. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "registerClickEvent", function (event) {
  21893. var autoHide = _this.props.autoHide;
  21894. var active = _this.state.active;
  21895. if (_this.dropDownContentElement.contains(event.target) || _this.dropDownHandlerElement.contains(event.target)) {
  21896. return false;
  21897. }
  21898. autoHide && active && _this.hide();
  21899. });
  21900. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggle", function () {
  21901. _this.setState({
  21902. active: !_this.state.active
  21903. });
  21904. });
  21905. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "show", function () {
  21906. _this.setState({
  21907. active: true
  21908. });
  21909. });
  21910. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "hide", function () {
  21911. _this.setState({
  21912. active: false
  21913. });
  21914. });
  21915. return _this;
  21916. }
  21917. createClass_default()(DropDown, [{
  21918. key: "componentDidMount",
  21919. value: function componentDidMount() {
  21920. if (document) {
  21921. document.body.addEventListener('click', this.registerClickEvent);
  21922. this.responsiveResolveId = responsive.resolve(this.fixDropDownPosition);
  21923. }
  21924. }
  21925. }, {
  21926. key: "componentWillReceiveProps",
  21927. value: function componentWillReceiveProps(next) {
  21928. if (!this.props.disabled && next.disabled) {
  21929. this.hide();
  21930. }
  21931. }
  21932. }, {
  21933. key: "componentDidUpdate",
  21934. value: function componentDidUpdate(prevState) {
  21935. if (!prevState.active && this.state.active) {
  21936. this.fixDropDownPosition();
  21937. }
  21938. }
  21939. }, {
  21940. key: "componentWillUnmount",
  21941. value: function componentWillUnmount() {
  21942. if (document) {
  21943. document.body.removeEventListener('click', this.registerClickEvent);
  21944. responsive.unresolve(this.responsiveResolveId);
  21945. }
  21946. }
  21947. }, {
  21948. key: "render",
  21949. value: function render() {
  21950. var _this2 = this;
  21951. var _this$state = this.state,
  21952. active = _this$state.active,
  21953. offset = _this$state.offset;
  21954. var _this$props = this.props,
  21955. caption = _this$props.caption,
  21956. htmlCaption = _this$props.htmlCaption,
  21957. title = _this$props.title,
  21958. disabled = _this$props.disabled,
  21959. showArrow = _this$props.showArrow,
  21960. arrowActive = _this$props.arrowActive,
  21961. className = _this$props.className,
  21962. children = _this$props.children,
  21963. theme = _this$props.theme;
  21964. disabled && (active = false);
  21965. theme === 'light' && (className = ' light-theme ' + className);
  21966. return external_react_default.a.createElement("div", {
  21967. className: 'bf-dropdown ' + (active ? 'active ' : '') + (disabled ? 'disabled ' : '') + className
  21968. }, htmlCaption ? external_react_default.a.createElement("button", {
  21969. type: "button",
  21970. className: "dropdown-handler",
  21971. "data-title": title,
  21972. onClick: this.toggle,
  21973. dangerouslySetInnerHTML: htmlCaption ? {
  21974. __html: htmlCaption
  21975. } : null,
  21976. ref: function ref(instance) {
  21977. return _this2.dropDownHandlerElement = instance;
  21978. }
  21979. }) : external_react_default.a.createElement("button", {
  21980. type: "button",
  21981. className: "dropdown-handler",
  21982. "data-title": title,
  21983. onClick: this.toggle,
  21984. ref: function ref(instance) {
  21985. return _this2.dropDownHandlerElement = instance;
  21986. }
  21987. }, external_react_default.a.createElement("span", null, caption), showArrow !== false ? external_react_default.a.createElement("i", {
  21988. className: "bfi-drop-down"
  21989. }) : null), external_react_default.a.createElement("div", {
  21990. className: "dropdown-content",
  21991. style: {
  21992. marginLeft: offset
  21993. },
  21994. ref: function ref(instance) {
  21995. return _this2.dropDownContentElement = instance;
  21996. }
  21997. }, external_react_default.a.createElement("i", {
  21998. style: {
  21999. marginLeft: offset * -1
  22000. },
  22001. className: 'dropdown-arrow' + (arrowActive ? ' active' : '')
  22002. }), external_react_default.a.createElement("div", {
  22003. className: "dropdown-content-inner"
  22004. }, children)));
  22005. }
  22006. }]);
  22007. return DropDown;
  22008. }(external_react_default.a.Component);
  22009. // CONCATENATED MODULE: ./components/business/ControlGroup/index.jsx
  22010. /* harmony default export */ var ControlGroup = (function (props) {
  22011. if (external_react_default.a.Fragment) {
  22012. return external_react_default.a.createElement(external_react_default.a.Fragment, null, props.children);
  22013. } else {
  22014. return external_react_default.a.createElement("div", {
  22015. className: "control-item-group"
  22016. }, props.children);
  22017. }
  22018. });
  22019. // CONCATENATED MODULE: ./components/business/LinkEditor/index.jsx
  22020. var LinkEditor_LinkEditor =
  22021. /*#__PURE__*/
  22022. function (_React$Component) {
  22023. inherits_default()(LinkEditor, _React$Component);
  22024. function LinkEditor(props) {
  22025. var _this;
  22026. classCallCheck_default()(this, LinkEditor);
  22027. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(LinkEditor).call(this, props));
  22028. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownInstance", null);
  22029. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handeKeyDown", function (e) {
  22030. if (e.keyCode === 13) {
  22031. _this.handleConfirm();
  22032. e.preventDefault();
  22033. return false;
  22034. }
  22035. });
  22036. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleTnputText", function (e) {
  22037. _this.setState({
  22038. text: e.currentTarget.value
  22039. });
  22040. });
  22041. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleInputLink", function (e) {
  22042. _this.setState({
  22043. href: e.currentTarget.value
  22044. });
  22045. });
  22046. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setTarget", function () {
  22047. _this.setState({
  22048. target: _this.state.target === '_blank' ? '' : '_blank'
  22049. });
  22050. });
  22051. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCancel", function () {
  22052. _this.dropDownInstance.hide();
  22053. });
  22054. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleUnlink", function () {
  22055. _this.dropDownInstance.hide();
  22056. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, false));
  22057. });
  22058. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleConfirm", function () {
  22059. var _this$state = _this.state,
  22060. text = _this$state.text,
  22061. href = _this$state.href,
  22062. target = _this$state.target,
  22063. textSelected = _this$state.textSelected;
  22064. var hookReturns = _this.props.hooks('toggle-link', {
  22065. href: href,
  22066. target: target
  22067. })({
  22068. href: href,
  22069. target: target
  22070. });
  22071. _this.dropDownInstance.hide();
  22072. _this.props.editor.requestFocus();
  22073. if (hookReturns === false) {
  22074. return false;
  22075. }
  22076. if (hookReturns) {
  22077. typeof hookReturns.href === 'string' && (href = hookReturns.href);
  22078. typeof hookReturns.target === 'string' && (target = hookReturns.target);
  22079. }
  22080. if (textSelected) {
  22081. if (href) {
  22082. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, href, target));
  22083. } else {
  22084. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, false));
  22085. }
  22086. } else {
  22087. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].insertText(_this.props.editorState, text || href, null, {
  22088. type: 'LINK',
  22089. data: {
  22090. href: href,
  22091. target: target
  22092. }
  22093. }));
  22094. }
  22095. });
  22096. _this.state = {
  22097. text: '',
  22098. href: '',
  22099. target: props.defaultLinkTarget || '',
  22100. textSelected: false
  22101. };
  22102. return _this;
  22103. }
  22104. createClass_default()(LinkEditor, [{
  22105. key: "componentWillReceiveProps",
  22106. value: function componentWillReceiveProps(nextProps) {
  22107. var _ContentUtils$getSele = external_braft_utils_["ContentUtils"].getSelectionEntityData(nextProps.editorState, 'LINK'),
  22108. href = _ContentUtils$getSele.href,
  22109. target = _ContentUtils$getSele.target;
  22110. var textSelected = !external_braft_utils_["ContentUtils"].isSelectionCollapsed(this.props.editorState) && external_braft_utils_["ContentUtils"].getSelectionBlockType(this.props.editorState) !== 'atomic';
  22111. var selectedText = '';
  22112. if (textSelected) {
  22113. selectedText = external_braft_utils_["ContentUtils"].getSelectionText(this.props.editorState);
  22114. }
  22115. this.setState({
  22116. textSelected: textSelected,
  22117. text: selectedText,
  22118. href: href || '',
  22119. target: typeof target === 'undefined' ? nextProps.defaultLinkTarget || '' : target || ''
  22120. });
  22121. }
  22122. }, {
  22123. key: "render",
  22124. value: function render() {
  22125. var _this2 = this;
  22126. var allowInsertLinkText = this.props.allowInsertLinkText;
  22127. var _this$state2 = this.state,
  22128. text = _this$state2.text,
  22129. href = _this$state2.href,
  22130. target = _this$state2.target,
  22131. textSelected = _this$state2.textSelected;
  22132. var caption = external_react_default.a.createElement("i", {
  22133. className: "bfi-link"
  22134. });
  22135. return external_react_default.a.createElement(ControlGroup, null, external_react_default.a.createElement(DropDown_DropDown, {
  22136. key: 0,
  22137. caption: caption,
  22138. title: this.props.language.controls.link,
  22139. autoHide: true,
  22140. getContainerNode: this.props.getContainerNode,
  22141. showArrow: false,
  22142. ref: function ref(instance) {
  22143. return _this2.dropDownInstance = instance;
  22144. },
  22145. className: 'control-item dropdown link-editor-dropdown'
  22146. }, external_react_default.a.createElement("div", {
  22147. className: "bf-link-editor"
  22148. }, allowInsertLinkText ? external_react_default.a.createElement("div", {
  22149. className: "input-group"
  22150. }, external_react_default.a.createElement("input", {
  22151. type: "text",
  22152. value: text,
  22153. spellCheck: false,
  22154. disabled: textSelected,
  22155. placeholder: this.props.language.linkEditor.textInputPlaceHolder,
  22156. onKeyDown: this.handeKeyDown,
  22157. onChange: this.handleTnputText
  22158. })) : null, external_react_default.a.createElement("div", {
  22159. className: "input-group"
  22160. }, external_react_default.a.createElement("input", {
  22161. type: "text",
  22162. value: href,
  22163. spellCheck: false,
  22164. placeholder: this.props.language.linkEditor.linkInputPlaceHolder,
  22165. onKeyDown: this.handeKeyDown,
  22166. onChange: this.handleInputLink
  22167. })), external_react_default.a.createElement("div", {
  22168. className: "switch-group"
  22169. }, external_react_default.a.createElement(Switch, {
  22170. active: target === '_blank',
  22171. onClick: this.setTarget
  22172. }), external_react_default.a.createElement("label", null, this.props.language.linkEditor.openInNewWindow)), external_react_default.a.createElement("div", {
  22173. className: "buttons"
  22174. }, external_react_default.a.createElement("a", {
  22175. onClick: this.handleUnlink,
  22176. className: "primary button-remove-link pull-left"
  22177. }, external_react_default.a.createElement("i", {
  22178. className: "bfi-close"
  22179. }), external_react_default.a.createElement("span", null, this.props.language.linkEditor.removeLink)), external_react_default.a.createElement("button", {
  22180. type: "button",
  22181. onClick: this.handleConfirm,
  22182. className: "primary pull-right"
  22183. }, this.props.language.base.confirm), external_react_default.a.createElement("button", {
  22184. type: "button",
  22185. onClick: this.handleCancel,
  22186. className: "default pull-right"
  22187. }, this.props.language.base.cancel)))), external_react_default.a.createElement("button", {
  22188. key: 1,
  22189. type: "button",
  22190. "data-title": this.props.language.controls.unlink,
  22191. className: "control-item button",
  22192. onClick: this.handleUnlink,
  22193. disabled: !textSelected || !href
  22194. }, external_react_default.a.createElement("i", {
  22195. className: "bfi-link-off"
  22196. })));
  22197. }
  22198. }]);
  22199. return LinkEditor;
  22200. }(external_react_default.a.Component);
  22201. // EXTERNAL MODULE: ./components/business/Headings/style.scss
  22202. var Headings_style = __webpack_require__(56);
  22203. // CONCATENATED MODULE: ./configs/maps.js
  22204. var maps_getHeadings = function getHeadings(lang) {
  22205. return [{
  22206. key: 'header-one',
  22207. title: lang.controls.header + ' 1',
  22208. text: external_react_default.a.createElement("h1", null, lang.controls.header, " 1"),
  22209. type: 'block-type',
  22210. command: 'header-one'
  22211. }, {
  22212. key: 'header-two',
  22213. title: lang.controls.header + ' 2',
  22214. text: external_react_default.a.createElement("h2", null, lang.controls.header, " 2"),
  22215. type: 'block-type',
  22216. command: 'header-two'
  22217. }, {
  22218. key: 'header-three',
  22219. title: lang.controls.header + ' 3',
  22220. text: external_react_default.a.createElement("h3", null, lang.controls.header, " 3"),
  22221. type: 'block-type',
  22222. command: 'header-three'
  22223. }, {
  22224. key: 'header-four',
  22225. title: lang.controls.header + ' 4',
  22226. text: external_react_default.a.createElement("h4", null, lang.controls.header, " 4"),
  22227. type: 'block-type',
  22228. command: 'header-four'
  22229. }, {
  22230. key: 'header-five',
  22231. title: lang.controls.header + ' 5',
  22232. text: external_react_default.a.createElement("h5", null, lang.controls.header, " 5"),
  22233. type: 'block-type',
  22234. command: 'header-five'
  22235. }, {
  22236. key: 'header-six',
  22237. title: lang.controls.header + ' 6',
  22238. text: external_react_default.a.createElement("h6", null, lang.controls.header, " 6"),
  22239. type: 'block-type',
  22240. command: 'header-six'
  22241. }, {
  22242. key: 'unstyled',
  22243. title: lang.controls.normal,
  22244. text: lang.controls.normal,
  22245. type: 'block-type',
  22246. command: 'unstyled'
  22247. }];
  22248. };
  22249. // CONCATENATED MODULE: ./components/business/Headings/index.jsx
  22250. /* harmony default export */ var Headings = (function (props) {
  22251. var dropDownInstance = null;
  22252. var headings = maps_getHeadings(props.language).filter(function (item) {
  22253. return props.headings.indexOf(item.key) !== -1;
  22254. });
  22255. var currentHeadingIndex = headings.findIndex(function (item) {
  22256. return item.command === props.current;
  22257. });
  22258. var caption = headings[currentHeadingIndex] ? headings[currentHeadingIndex].title : props.language.controls.normal;
  22259. return external_react_default.a.createElement(DropDown_DropDown, {
  22260. caption: caption,
  22261. autoHide: true,
  22262. getContainerNode: props.getContainerNode,
  22263. title: props.language.controls.headings,
  22264. arrowActive: currentHeadingIndex === 0,
  22265. ref: function ref(instance) {
  22266. return dropDownInstance = instance;
  22267. },
  22268. className: 'control-item dropdown headings-dropdown'
  22269. }, external_react_default.a.createElement("ul", {
  22270. className: "menu"
  22271. }, headings.map(function (item, index) {
  22272. var isActive = props.current === item.command;
  22273. return external_react_default.a.createElement("li", {
  22274. key: index,
  22275. className: 'menu-item' + (isActive ? ' active' : ''),
  22276. onClick: function onClick() {
  22277. props.onChange(item.command, item.type), dropDownInstance.hide();
  22278. }
  22279. }, item.text);
  22280. })));
  22281. });
  22282. // EXTERNAL MODULE: ./components/business/TextColor/style.scss
  22283. var TextColor_style = __webpack_require__(57);
  22284. // EXTERNAL MODULE: ./components/common/ColorPicker/style.scss
  22285. var ColorPicker_style = __webpack_require__(58);
  22286. // CONCATENATED MODULE: ./components/common/ColorPicker/index.jsx
  22287. /* harmony default export */ var common_ColorPicker = (function (props) {
  22288. return external_react_default.a.createElement("div", {
  22289. className: "bf-colors-wrap"
  22290. }, external_react_default.a.createElement("ul", {
  22291. className: "bf-colors"
  22292. }, props.presetColors.map(function (item, index) {
  22293. var className = props.color && item.toLowerCase() === props.color.toLowerCase() ? 'color-item active' : 'color-item';
  22294. return external_react_default.a.createElement("li", {
  22295. key: index,
  22296. title: item,
  22297. className: className,
  22298. style: {
  22299. color: item
  22300. },
  22301. "data-color": item.replace('#', ''),
  22302. onClick: function onClick(e) {
  22303. props.onChange(e.currentTarget.dataset.color, true);
  22304. }
  22305. });
  22306. })));
  22307. });
  22308. // CONCATENATED MODULE: ./components/business/TextColor/index.jsx
  22309. var TextColor_TextColor =
  22310. /*#__PURE__*/
  22311. function (_React$Component) {
  22312. inherits_default()(TextColor, _React$Component);
  22313. function TextColor() {
  22314. var _getPrototypeOf2;
  22315. var _this;
  22316. classCallCheck_default()(this, TextColor);
  22317. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  22318. args[_key] = arguments[_key];
  22319. }
  22320. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextColor)).call.apply(_getPrototypeOf2, [this].concat(args)));
  22321. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  22322. colorType: 'color'
  22323. });
  22324. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "switchColorType", function (_ref) {
  22325. var currentTarget = _ref.currentTarget;
  22326. _this.setState({
  22327. colorType: currentTarget.dataset.type
  22328. });
  22329. });
  22330. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleColor", function (color, closePicker) {
  22331. if (color) {
  22332. var hookReturns = _this.props.hooks("toggle-text-".concat(_this.state.colorType), color)(color);
  22333. if (hookReturns === false) {
  22334. return false;
  22335. }
  22336. if (typeof hookReturns === 'string') {
  22337. color = hookReturns;
  22338. }
  22339. if (_this.state.colorType === 'color') {
  22340. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionColor(_this.props.editorState, color));
  22341. } else {
  22342. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBackgroundColor(_this.props.editorState, color));
  22343. }
  22344. }
  22345. if (closePicker) {
  22346. _this.dropDownInstance.hide();
  22347. _this.props.editor.requestFocus();
  22348. }
  22349. });
  22350. return _this;
  22351. }
  22352. createClass_default()(TextColor, [{
  22353. key: "render",
  22354. value: function render() {
  22355. var _this2 = this;
  22356. var captionStyle = {};
  22357. var currentColor = null;
  22358. var colorType = this.state.colorType;
  22359. var selectionStyles = this.props.editorState.getCurrentInlineStyle().toJS();
  22360. selectionStyles.forEach(function (style) {
  22361. if (style.indexOf('COLOR-') === 0) {
  22362. captionStyle.color = '#' + style.split('-')[1];
  22363. colorType === 'color' && (currentColor = captionStyle.color);
  22364. }
  22365. if (style.indexOf('BGCOLOR-') === 0) {
  22366. captionStyle.backgroundColor = '#' + style.split('-')[1];
  22367. colorType === 'background-color' && (currentColor = captionStyle.backgroundColor);
  22368. }
  22369. });
  22370. var caption = external_react_default.a.createElement("i", {
  22371. style: captionStyle,
  22372. className: "bfi-text-color"
  22373. }, external_react_default.a.createElement("span", {
  22374. className: "path1"
  22375. }), external_react_default.a.createElement("span", {
  22376. className: "path2"
  22377. }));
  22378. var ColorPicker = this.props.colorPicker || common_ColorPicker;
  22379. return external_react_default.a.createElement(DropDown_DropDown, {
  22380. caption: caption,
  22381. title: this.props.language.controls.color,
  22382. showArrow: false,
  22383. autoHide: this.props.autoHide,
  22384. theme: this.props.theme,
  22385. getContainerNode: this.props.getContainerNode,
  22386. ref: function ref(instance) {
  22387. return _this2.dropDownInstance = instance;
  22388. },
  22389. className: 'control-item dropdown text-color-dropdown'
  22390. }, external_react_default.a.createElement("div", {
  22391. className: "bf-text-color-picker-wrap"
  22392. }, external_react_default.a.createElement("div", {
  22393. className: "bf-color-switch-buttons",
  22394. style: this.props.enableBackgroundColor ? {} : {
  22395. display: 'none'
  22396. }
  22397. }, external_react_default.a.createElement("button", {
  22398. type: "button",
  22399. "data-type": "color",
  22400. className: colorType === 'color' ? 'active' : '',
  22401. onClick: this.switchColorType
  22402. }, this.props.language.controls.textColor), external_react_default.a.createElement("button", {
  22403. type: "button",
  22404. "data-type": "background-color",
  22405. className: colorType === 'background-color' ? 'active' : '',
  22406. onClick: this.switchColorType
  22407. }, this.props.language.controls.backgroundColor)), external_react_default.a.createElement(ColorPicker, {
  22408. width: 200,
  22409. color: currentColor,
  22410. disableAlpha: true,
  22411. presetColors: this.props.colors,
  22412. onChange: this.toggleColor
  22413. })));
  22414. }
  22415. }]);
  22416. return TextColor;
  22417. }(external_react_default.a.Component);
  22418. // EXTERNAL MODULE: ./components/business/FontSize/style.scss
  22419. var FontSize_style = __webpack_require__(59);
  22420. // CONCATENATED MODULE: ./components/business/FontSize/index.jsx
  22421. var FontSize_toggleFontSize = function toggleFontSize(event, props) {
  22422. var fontSize = event.currentTarget.dataset.size;
  22423. var hookReturns = props.hooks('toggle-font-size', fontSize)(fontSize);
  22424. if (hookReturns === false) {
  22425. return false;
  22426. }
  22427. if (!isNaN(fontSize)) {
  22428. fontSize = hookReturns;
  22429. }
  22430. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionFontSize(props.editorState, fontSize));
  22431. props.editor.requestFocus();
  22432. };
  22433. /* harmony default export */ var FontSize = (function (props) {
  22434. var caption = null;
  22435. var currentFontSize = null;
  22436. var dropDownInstance = null;
  22437. props.fontSizes.find(function (item) {
  22438. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'FONTSIZE-' + item)) {
  22439. caption = item;
  22440. currentFontSize = item;
  22441. return true;
  22442. }
  22443. return false;
  22444. });
  22445. return external_react_default.a.createElement(DropDown_DropDown, {
  22446. autoHide: true,
  22447. caption: caption || props.defaultCaption,
  22448. getContainerNode: props.getContainerNode,
  22449. title: props.language.controls.fontSize,
  22450. ref: function ref(instance) {
  22451. return dropDownInstance = instance;
  22452. },
  22453. className: 'control-item dropdown bf-font-size-dropdown'
  22454. }, external_react_default.a.createElement("ul", {
  22455. className: "bf-font-sizes"
  22456. }, props.fontSizes.map(function (item, index) {
  22457. return external_react_default.a.createElement("li", {
  22458. key: index,
  22459. className: item === currentFontSize ? 'active' : null,
  22460. "data-size": item,
  22461. onClick: function onClick(event) {
  22462. FontSize_toggleFontSize(event, props), dropDownInstance.hide();
  22463. }
  22464. }, item);
  22465. })));
  22466. });
  22467. // EXTERNAL MODULE: ./components/business/LineHeight/style.scss
  22468. var LineHeight_style = __webpack_require__(60);
  22469. // CONCATENATED MODULE: ./components/business/LineHeight/index.jsx
  22470. var LineHeight_toggleLineHeight = function toggleLineHeight(event, props) {
  22471. var lineHeight = event.currentTarget.dataset.size;
  22472. var hookReturns = props.hooks('toggle-line-height', lineHeight)(lineHeight);
  22473. if (hookReturns === false) {
  22474. return false;
  22475. }
  22476. if (!isNaN(hookReturns)) {
  22477. lineHeight = hookReturns;
  22478. }
  22479. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLineHeight(props.editorState, lineHeight));
  22480. props.editor.requestFocus();
  22481. };
  22482. /* harmony default export */ var LineHeight = (function (props) {
  22483. var caption = null;
  22484. var currentLineHeight = null;
  22485. var dropDownInstance = null;
  22486. props.lineHeights.find(function (item) {
  22487. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'LINEHEIGHT-' + item)) {
  22488. caption = item;
  22489. currentLineHeight = item;
  22490. return true;
  22491. }
  22492. return false;
  22493. });
  22494. return external_react_default.a.createElement(DropDown_DropDown, {
  22495. autoHide: true,
  22496. caption: caption || props.defaultCaption,
  22497. getContainerNode: props.getContainerNode,
  22498. title: props.language.controls.lineHeight,
  22499. ref: function ref(instance) {
  22500. return dropDownInstance = instance;
  22501. },
  22502. className: 'control-item dropdown bf-line-height-dropdown'
  22503. }, external_react_default.a.createElement("ul", {
  22504. className: "bf-line-heights"
  22505. }, props.lineHeights.map(function (item, index) {
  22506. return external_react_default.a.createElement("li", {
  22507. key: index,
  22508. className: item === currentLineHeight ? 'active' : null,
  22509. "data-size": item,
  22510. onClick: function onClick(event) {
  22511. LineHeight_toggleLineHeight(event, props), dropDownInstance.hide();
  22512. }
  22513. }, item);
  22514. })));
  22515. });
  22516. // EXTERNAL MODULE: ./components/business/FontFamily/style.scss
  22517. var FontFamily_style = __webpack_require__(61);
  22518. // CONCATENATED MODULE: ./components/business/FontFamily/index.jsx
  22519. var FontFamily_toggleFontFamily = function toggleFontFamily(event, props) {
  22520. var fontFamilyName = event.currentTarget.dataset.name;
  22521. var hookReturns = props.hooks('toggle-font-family', fontFamilyName)(fontFamilyName, props.fontFamilies);
  22522. if (hookReturns === false) {
  22523. return false;
  22524. }
  22525. if (typeof hookReturns === 'string') {
  22526. fontFamilyName = hookReturns;
  22527. }
  22528. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionFontFamily(props.editorState, fontFamilyName));
  22529. props.editor.requestFocus();
  22530. };
  22531. /* harmony default export */ var FontFamily = (function (props) {
  22532. var caption = null;
  22533. var currentIndex = null;
  22534. var dropDownInstance = null;
  22535. props.fontFamilies.find(function (item, index) {
  22536. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'FONTFAMILY-' + item.name)) {
  22537. caption = item.name;
  22538. currentIndex = index;
  22539. return true;
  22540. }
  22541. return false;
  22542. });
  22543. return external_react_default.a.createElement(DropDown_DropDown, {
  22544. caption: caption || props.defaultCaption,
  22545. getContainerNode: props.getContainerNode,
  22546. title: props.language.controls.fontFamily,
  22547. autoHide: true,
  22548. arrowActive: currentIndex === 0,
  22549. ref: function ref(instance) {
  22550. return dropDownInstance = instance;
  22551. },
  22552. className: 'control-item dropdown font-family-dropdown'
  22553. }, external_react_default.a.createElement("ul", {
  22554. className: "menu"
  22555. }, props.fontFamilies.map(function (item, index) {
  22556. return external_react_default.a.createElement("li", {
  22557. key: index,
  22558. className: 'menu-item ' + (index === currentIndex ? 'active' : ''),
  22559. "data-name": item.name,
  22560. onClick: function onClick(event) {
  22561. FontFamily_toggleFontFamily(event, props), dropDownInstance.hide();
  22562. }
  22563. }, external_react_default.a.createElement("span", {
  22564. style: {
  22565. fontFamily: item.family
  22566. }
  22567. }, item.name));
  22568. })));
  22569. });
  22570. // CONCATENATED MODULE: ./components/business/TextAlign/index.jsx
  22571. var TextAlign_TextAlign =
  22572. /*#__PURE__*/
  22573. function (_React$Component) {
  22574. inherits_default()(TextAlign, _React$Component);
  22575. function TextAlign() {
  22576. var _getPrototypeOf2;
  22577. var _this;
  22578. classCallCheck_default()(this, TextAlign);
  22579. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  22580. args[_key] = arguments[_key];
  22581. }
  22582. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextAlign)).call.apply(_getPrototypeOf2, [this].concat(args)));
  22583. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  22584. currentAlignment: undefined
  22585. });
  22586. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setAlignment", function (event) {
  22587. var alignment = event.currentTarget.dataset.alignment;
  22588. var hookReturns = _this.props.hooks('toggle-text-alignment', alignment)(alignment);
  22589. if (_this.props.textAligns.indexOf(hookReturns) > -1) {
  22590. alignment = hookReturns;
  22591. }
  22592. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionAlignment(_this.props.editorState, alignment));
  22593. _this.props.editor.requestFocus();
  22594. });
  22595. return _this;
  22596. }
  22597. createClass_default()(TextAlign, [{
  22598. key: "componentWillReceiveProps",
  22599. value: function componentWillReceiveProps(next) {
  22600. this.setState({
  22601. currentAlignment: external_braft_utils_["ContentUtils"].getSelectionBlockData(next.editorState, 'textAlign')
  22602. });
  22603. }
  22604. }, {
  22605. key: "render",
  22606. value: function render() {
  22607. var _this2 = this;
  22608. var textAlignmentTitles = [this.props.language.controls.alignLeft, this.props.language.controls.alignCenter, this.props.language.controls.alignRight, this.props.language.controls.alignJustify];
  22609. return external_react_default.a.createElement(ControlGroup, null, this.props.textAligns.map(function (item, index) {
  22610. return external_react_default.a.createElement("button", {
  22611. type: "button",
  22612. key: index,
  22613. "data-title": textAlignmentTitles[index],
  22614. "data-alignment": item,
  22615. className: 'control-item button ' + (item === _this2.state.currentAlignment ? 'active' : null),
  22616. onClick: _this2.setAlignment
  22617. }, external_react_default.a.createElement("i", {
  22618. className: 'bfi-align-' + item
  22619. }));
  22620. }));
  22621. }
  22622. }]);
  22623. return TextAlign;
  22624. }(external_react_default.a.Component);
  22625. // EXTERNAL MODULE: ./components/business/EmojiPicker/style.scss
  22626. var EmojiPicker_style = __webpack_require__(62);
  22627. // CONCATENATED MODULE: ./components/business/EmojiPicker/index.jsx
  22628. var EmojiPicker_insertEmoji = function insertEmoji(event, props) {
  22629. var emoji = event.currentTarget.dataset.emoji;
  22630. var hookReturns = props.hooks('insert-emoji', emoji)(emoji);
  22631. if (hookReturns === false) {
  22632. return false;
  22633. }
  22634. if (typeof hookReturns === 'string') {
  22635. emoji = hookReturns;
  22636. }
  22637. props.editor.setValue(external_braft_utils_["ContentUtils"].insertText(props.editorState, emoji));
  22638. props.editor.requestFocus();
  22639. };
  22640. /* harmony default export */ var EmojiPicker = (function (props) {
  22641. return external_react_default.a.createElement(DropDown_DropDown, {
  22642. caption: props.defaultCaption,
  22643. autoHide: true,
  22644. showArrow: false,
  22645. getContainerNode: props.getContainerNode,
  22646. title: props.language.controls.emoji,
  22647. className: 'control-item dropdown bf-emoji-dropdown'
  22648. }, external_react_default.a.createElement("div", {
  22649. className: "bf-emojis-wrap"
  22650. }, external_react_default.a.createElement("ul", {
  22651. className: "bf-emojis"
  22652. }, props.emojis.map(function (item, index) {
  22653. return external_react_default.a.createElement("li", {
  22654. key: index,
  22655. "data-emoji": item,
  22656. onClick: function onClick(event) {
  22657. return EmojiPicker_insertEmoji(event, props);
  22658. }
  22659. }, item);
  22660. }))));
  22661. });
  22662. // EXTERNAL MODULE: ./components/business/LetterSpacing/style.scss
  22663. var LetterSpacing_style = __webpack_require__(63);
  22664. // CONCATENATED MODULE: ./components/business/LetterSpacing/index.jsx
  22665. var LetterSpacing_toggleLetterSpacing = function toggleLetterSpacing(event, props) {
  22666. var letterSpacing = event.currentTarget.dataset.size;
  22667. var hookReturns = props.hooks('toggle-letter-spacing', letterSpacing)(letterSpacing);
  22668. if (hookReturns === false) {
  22669. return false;
  22670. }
  22671. if (!isNaN(hookReturns)) {
  22672. letterSpacing = hookReturns;
  22673. }
  22674. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLetterSpacing(props.editorState, letterSpacing));
  22675. props.editor.requestFocus();
  22676. };
  22677. /* harmony default export */ var LetterSpacing = (function (props) {
  22678. var caption = null;
  22679. var currentLetterSpacing = null;
  22680. var dropDownInstance = null;
  22681. props.letterSpacings.find(function (item) {
  22682. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'LETTERSPACING-' + item)) {
  22683. caption = item;
  22684. currentLetterSpacing = item;
  22685. return true;
  22686. }
  22687. return false;
  22688. });
  22689. return external_react_default.a.createElement(DropDown_DropDown, {
  22690. autoHide: true,
  22691. caption: caption || props.defaultCaption,
  22692. getContainerNode: props.getContainerNode,
  22693. title: props.language.controls.letterSpacing,
  22694. ref: function ref(instance) {
  22695. return dropDownInstance = instance;
  22696. },
  22697. className: 'control-item dropdown bf-letter-spacing-dropdown'
  22698. }, external_react_default.a.createElement("ul", {
  22699. className: "bf-letter-spacings"
  22700. }, props.letterSpacings.map(function (item, index) {
  22701. return external_react_default.a.createElement("li", {
  22702. key: index,
  22703. className: item === currentLetterSpacing ? 'active' : null,
  22704. "data-size": item,
  22705. onClick: function onClick(event) {
  22706. LetterSpacing_toggleLetterSpacing(event, props), dropDownInstance.hide();
  22707. }
  22708. }, item);
  22709. })));
  22710. });
  22711. // CONCATENATED MODULE: ./components/business/TextIndent/index.jsx
  22712. var TextIndent_TextAlign =
  22713. /*#__PURE__*/
  22714. function (_React$Component) {
  22715. inherits_default()(TextAlign, _React$Component);
  22716. function TextAlign() {
  22717. var _getPrototypeOf2;
  22718. var _this;
  22719. classCallCheck_default()(this, TextAlign);
  22720. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  22721. args[_key] = arguments[_key];
  22722. }
  22723. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextAlign)).call.apply(_getPrototypeOf2, [this].concat(args)));
  22724. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  22725. currentIndent: 0
  22726. });
  22727. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "increaseIndent", function () {
  22728. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].increaseSelectionIndent(_this.props.editorState));
  22729. _this.props.editor.requestFocus();
  22730. });
  22731. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "decreaseIndent", function () {
  22732. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].decreaseSelectionIndent(_this.props.editorState));
  22733. _this.props.editor.requestFocus();
  22734. });
  22735. return _this;
  22736. }
  22737. createClass_default()(TextAlign, [{
  22738. key: "componentWillReceiveProps",
  22739. value: function componentWillReceiveProps(nextProps) {
  22740. this.setState({
  22741. currentIndent: external_braft_utils_["ContentUtils"].getSelectionBlockData(nextProps.editorState, 'textIndent') || 0
  22742. });
  22743. }
  22744. }, {
  22745. key: "render",
  22746. value: function render() {
  22747. var currentIndent = this.state.currentIndent;
  22748. var language = this.props.language;
  22749. return external_react_default.a.createElement(ControlGroup, null, external_react_default.a.createElement("button", {
  22750. key: 0,
  22751. type: "button",
  22752. "data-title": language.controls.increaseIndent,
  22753. disabled: currentIndent >= 6,
  22754. className: "control-item button button-indent-increase".concat(currentIndent > 0 && currentIndent < 6 ? ' active' : ''),
  22755. onClick: this.increaseIndent
  22756. }, external_react_default.a.createElement("i", {
  22757. className: 'bfi-indent-increase'
  22758. })), external_react_default.a.createElement("button", {
  22759. key: 1,
  22760. type: "button",
  22761. "data-title": language.controls.decreaseIndent,
  22762. disabled: currentIndent <= 0,
  22763. className: "control-item button button-indent-decrease",
  22764. onClick: this.decreaseIndent
  22765. }, external_react_default.a.createElement("i", {
  22766. className: 'bfi-indent-decrease'
  22767. })));
  22768. }
  22769. }]);
  22770. return TextAlign;
  22771. }(external_react_default.a.Component);
  22772. // CONCATENATED MODULE: ./components/business/ControlBar/index.jsx
  22773. var commandHookMap = {
  22774. 'inline-style': 'toggle-inline-style',
  22775. 'block-type': 'change-block-type',
  22776. 'editor-method': 'exec-editor-command'
  22777. };
  22778. var exclusiveInlineStyles = {
  22779. 'superscript': 'subscript',
  22780. 'subscript': 'superscript'
  22781. };
  22782. var mergeControls = function mergeControls(commonProps, builtControls, extensionControls, extendControls) {
  22783. extensionControls = extensionControls.map(function (item) {
  22784. return typeof item === 'function' ? item(commonProps) : item;
  22785. });
  22786. extendControls = extendControls.map(function (item) {
  22787. return typeof item === 'function' ? item(commonProps) : item;
  22788. });
  22789. if (extensionControls.length === 0 && extendControls.length === 0) {
  22790. return builtControls;
  22791. }
  22792. return builtControls.map(function (item) {
  22793. return extendControls.find(function (subItem) {
  22794. return subItem.replace === (item.key || item);
  22795. }) || extensionControls.find(function (subItem) {
  22796. return subItem.replace === (item.key || item);
  22797. }) || item;
  22798. }).concat(extensionControls.length ? 'separator' : '').concat(extensionControls.filter(function (item) {
  22799. return !item.replace;
  22800. })).concat(extendControls.filter(function (item) {
  22801. return typeof item === 'string' || !item.replace;
  22802. }));
  22803. };
  22804. var ControlBar_ControlBar =
  22805. /*#__PURE__*/
  22806. function (_React$Component) {
  22807. inherits_default()(ControlBar, _React$Component);
  22808. function ControlBar() {
  22809. var _getPrototypeOf2;
  22810. var _this;
  22811. classCallCheck_default()(this, ControlBar);
  22812. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  22813. args[_key] = arguments[_key];
  22814. }
  22815. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(ControlBar)).call.apply(_getPrototypeOf2, [this].concat(args)));
  22816. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "allControls", []);
  22817. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "mediaLibiraryModal", null);
  22818. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "extendedModals", {});
  22819. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "openBraftFinder", function () {
  22820. if (!_this.props.braftFinder || !_this.props.braftFinder.ReactComponent) {
  22821. return false;
  22822. }
  22823. if (_this.props.hooks('open-braft-finder')() === false) {
  22824. return false;
  22825. }
  22826. var mediaProps = _this.props.media;
  22827. var MediaLibrary = _this.props.braftFinder.ReactComponent;
  22828. _this.mediaLibiraryModal = Modal_showModal({
  22829. title: _this.props.language.controls.mediaLibirary,
  22830. language: _this.props.language,
  22831. width: 640,
  22832. showFooter: false,
  22833. component: external_react_default.a.createElement(MediaLibrary, {
  22834. accepts: mediaProps.accepts,
  22835. onCancel: _this.closeBraftFinder,
  22836. onInsert: _this.insertMedias,
  22837. onChange: mediaProps.onChange,
  22838. externals: mediaProps.externals,
  22839. onBeforeSelect: _this.bindBraftFinderHook('select-medias'),
  22840. onBeforeDeselect: _this.bindBraftFinderHook('deselect-medias'),
  22841. onBeforeRemove: _this.bindBraftFinderHook('remove-medias'),
  22842. onBeforeInsert: _this.bindBraftFinderHook('insert-medias'),
  22843. onFileSelect: _this.bindBraftFinderHook('select-files')
  22844. })
  22845. });
  22846. });
  22847. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "bindBraftFinderHook", function (hookName) {
  22848. return function () {
  22849. return _this.props.hooks(hookName, arguments.length <= 0 ? undefined : arguments[0]).apply(void 0, arguments);
  22850. };
  22851. });
  22852. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "insertMedias", function (medias) {
  22853. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(_this.props.editorState, medias));
  22854. _this.props.editor.requestFocus();
  22855. _this.props.media.onInsert && _this.props.media.onInsert(medias);
  22856. _this.closeBraftFinder();
  22857. });
  22858. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "closeBraftFinder", function () {
  22859. _this.props.media.onCancel && _this.props.media.onCancel();
  22860. _this.mediaLibiraryModal && _this.mediaLibiraryModal.close();
  22861. });
  22862. return _this;
  22863. }
  22864. createClass_default()(ControlBar, [{
  22865. key: "componentDidUpdate",
  22866. value: function componentDidUpdate() {
  22867. var _this2 = this;
  22868. var language = this.props.language;
  22869. this.allControls.forEach(function (item) {
  22870. if (item.type === 'modal') {
  22871. if (item.modal && item.modal.id && _this2.extendedModals[item.modal.id]) {
  22872. _this2.extendedModals[item.modal.id].update(objectSpread_default()({}, item.modal, {
  22873. language: language
  22874. }));
  22875. }
  22876. }
  22877. });
  22878. }
  22879. }, {
  22880. key: "getControlItemClassName",
  22881. value: function getControlItemClassName(data) {
  22882. var className = 'control-item button';
  22883. var type = data.type,
  22884. command = data.command;
  22885. if (type === 'inline-style' && external_braft_utils_["ContentUtils"].selectionHasInlineStyle(this.props.editorState, command)) {
  22886. className += ' active';
  22887. } else if (type === 'block-type' && external_braft_utils_["ContentUtils"].getSelectionBlockType(this.props.editorState) === command) {
  22888. className += ' active';
  22889. } else if (type === 'entity' && external_braft_utils_["ContentUtils"].getSelectionEntityType(this.props.editorState) === command) {
  22890. className += ' active';
  22891. }
  22892. return className;
  22893. }
  22894. }, {
  22895. key: "applyControl",
  22896. value: function applyControl(command, type) {
  22897. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  22898. var hookReturns = this.props.hooks(commandHookMap[type] || type, command)(command);
  22899. var editorState = this.props.editorState;
  22900. if (hookReturns === false) {
  22901. return false;
  22902. }
  22903. if (typeof hookReturns === 'string') {
  22904. command = hookReturns;
  22905. }
  22906. if (type === 'inline-style') {
  22907. var exclusiveInlineStyle = exclusiveInlineStyles[command];
  22908. if (exclusiveInlineStyle && external_braft_utils_["ContentUtils"].selectionHasInlineStyle(editorState, exclusiveInlineStyle)) {
  22909. editorState = external_braft_utils_["ContentUtils"].toggleSelectionInlineStyle(editorState, exclusiveInlineStyle);
  22910. }
  22911. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionInlineStyle(editorState, command));
  22912. } else if (type === 'block-type') {
  22913. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, command));
  22914. } else if (type === 'entity') {
  22915. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionEntity(editorState, {
  22916. type: command,
  22917. mutability: data.mutability || 'MUTABLE',
  22918. data: data.data || {}
  22919. }));
  22920. } else if (type === 'editor-method') {
  22921. this.props.editor[command] && this.props.editor[command]();
  22922. }
  22923. }
  22924. }, {
  22925. key: "render",
  22926. value: function render() {
  22927. var _this3 = this;
  22928. var _this$props = this.props,
  22929. editor = _this$props.editor,
  22930. editorId = _this$props.editorId,
  22931. editorState = _this$props.editorState,
  22932. className = _this$props.className,
  22933. style = _this$props.style,
  22934. controls = _this$props.controls,
  22935. media = _this$props.media,
  22936. extendControls = _this$props.extendControls,
  22937. language = _this$props.language,
  22938. hooks = _this$props.hooks,
  22939. colors = _this$props.colors,
  22940. colorPicker = _this$props.colorPicker,
  22941. colorPickerTheme = _this$props.colorPickerTheme,
  22942. colorPickerAutoHide = _this$props.colorPickerAutoHide,
  22943. headings = _this$props.headings,
  22944. fontSizes = _this$props.fontSizes,
  22945. fontFamilies = _this$props.fontFamilies,
  22946. emojis = _this$props.emojis,
  22947. getContainerNode = _this$props.getContainerNode,
  22948. lineHeights = _this$props.lineHeights,
  22949. letterSpacings = _this$props.letterSpacings,
  22950. textAligns = _this$props.textAligns,
  22951. textBackgroundColor = _this$props.textBackgroundColor,
  22952. allowInsertLinkText = _this$props.allowInsertLinkText,
  22953. defaultLinkTarget = _this$props.defaultLinkTarget;
  22954. var currentBlockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  22955. var commonProps = {
  22956. editor: editor,
  22957. editorId: editorId,
  22958. editorState: editorState,
  22959. language: language,
  22960. getContainerNode: getContainerNode,
  22961. hooks: hooks
  22962. };
  22963. var renderedControls = [];
  22964. var editorControls = configs_controls(language, editor);
  22965. var extensionControls = getExtensionControls(editorId);
  22966. var allControls = mergeControls(commonProps, controls, extensionControls, extendControls);
  22967. this.allControls = allControls;
  22968. return external_react_default.a.createElement("div", {
  22969. className: "bf-controlbar ".concat(className || ''),
  22970. style: style,
  22971. onMouseDown: this.preventDefault
  22972. }, allControls.map(function (item, index) {
  22973. var itemKey = typeof item === 'string' ? item : item.key;
  22974. if (typeof itemKey !== 'string') {
  22975. return null;
  22976. }
  22977. if (renderedControls.indexOf(itemKey) > -1) {
  22978. return null;
  22979. }
  22980. if (itemKey.toLowerCase() === 'separator') {
  22981. return external_react_default.a.createElement("span", {
  22982. key: index,
  22983. className: "separator-line"
  22984. });
  22985. }
  22986. var controlItem = editorControls.find(function (subItem) {
  22987. return subItem.key.toLowerCase() === itemKey.toLowerCase();
  22988. });
  22989. if (typeof item !== 'string') {
  22990. controlItem = objectSpread_default()({}, controlItem, item);
  22991. }
  22992. if (!controlItem) {
  22993. return null;
  22994. }
  22995. renderedControls.push(itemKey);
  22996. if (controlItem.type === 'headings') {
  22997. return external_react_default.a.createElement(Headings, extends_default()({
  22998. key: index,
  22999. headings: headings,
  23000. current: currentBlockType,
  23001. onChange: function onChange(command) {
  23002. return _this3.applyControl(command, 'block-type');
  23003. }
  23004. }, commonProps));
  23005. } else if (controlItem.type === 'text-color') {
  23006. return external_react_default.a.createElement(TextColor_TextColor, extends_default()({
  23007. key: index,
  23008. colors: colors,
  23009. colorPicker: colorPicker,
  23010. theme: colorPickerTheme,
  23011. autoHide: colorPickerAutoHide,
  23012. enableBackgroundColor: textBackgroundColor
  23013. }, commonProps));
  23014. } else if (controlItem.type === 'font-size') {
  23015. return external_react_default.a.createElement(FontSize, extends_default()({
  23016. key: index,
  23017. fontSizes: fontSizes,
  23018. defaultCaption: controlItem.title
  23019. }, commonProps));
  23020. } else if (controlItem.type === 'line-height') {
  23021. return external_react_default.a.createElement(LineHeight, extends_default()({
  23022. key: index,
  23023. lineHeights: lineHeights,
  23024. defaultCaption: controlItem.title
  23025. }, commonProps));
  23026. } else if (controlItem.type === 'letter-spacing') {
  23027. return external_react_default.a.createElement(LetterSpacing, extends_default()({
  23028. key: index,
  23029. letterSpacings: letterSpacings,
  23030. defaultCaption: controlItem.title
  23031. }, commonProps));
  23032. } else if (controlItem.type === 'text-indent') {
  23033. return external_react_default.a.createElement(TextIndent_TextAlign, extends_default()({
  23034. key: index,
  23035. defaultCaption: controlItem.title
  23036. }, commonProps));
  23037. } else if (controlItem.type === 'font-family') {
  23038. return external_react_default.a.createElement(FontFamily, extends_default()({
  23039. key: index,
  23040. fontFamilies: fontFamilies,
  23041. defaultCaption: controlItem.title
  23042. }, commonProps));
  23043. } else if (controlItem.type === 'emoji') {
  23044. return external_react_default.a.createElement(EmojiPicker, extends_default()({
  23045. key: index,
  23046. emojis: emojis,
  23047. defaultCaption: controlItem.text
  23048. }, commonProps));
  23049. } else if (controlItem.type === 'link') {
  23050. return external_react_default.a.createElement(LinkEditor_LinkEditor, extends_default()({
  23051. key: index,
  23052. defaultLinkTarget: defaultLinkTarget,
  23053. allowInsertLinkText: allowInsertLinkText
  23054. }, commonProps));
  23055. } else if (controlItem.type === 'text-align') {
  23056. return external_react_default.a.createElement(TextAlign_TextAlign, extends_default()({
  23057. key: index,
  23058. textAligns: textAligns
  23059. }, commonProps));
  23060. } else if (controlItem.type === 'media') {
  23061. if (!media.image && !media.video && !media.audio) {
  23062. return null;
  23063. }
  23064. return external_react_default.a.createElement("button", {
  23065. type: "button",
  23066. key: index,
  23067. "data-title": controlItem.title,
  23068. disabled: controlItem.disabled,
  23069. className: "control-item media button",
  23070. onClick: _this3.openBraftFinder
  23071. }, controlItem.text);
  23072. } else if (controlItem.type === 'dropdown') {
  23073. return external_react_default.a.createElement(DropDown_DropDown, extends_default()({
  23074. key: index,
  23075. className: "control-item extend-control-item dropdown ".concat(controlItem.className || ''),
  23076. caption: controlItem.text,
  23077. htmlCaption: controlItem.html,
  23078. showArrow: controlItem.showArrow,
  23079. title: controlItem.title,
  23080. arrowActive: controlItem.arrowActive,
  23081. theme: controlItem.theme,
  23082. autoHide: controlItem.autoHide,
  23083. disabled: controlItem.disabled,
  23084. ref: controlItem.ref
  23085. }, commonProps), controlItem.component);
  23086. } else if (controlItem.type === 'modal') {
  23087. return external_react_default.a.createElement("button", {
  23088. type: "button",
  23089. key: index,
  23090. "data-title": controlItem.title,
  23091. disabled: controlItem.disabled,
  23092. className: "control-item extend-control-item button ".concat(controlItem.className || ''),
  23093. dangerouslySetInnerHTML: controlItem.html ? {
  23094. __html: controlItem.html
  23095. } : null,
  23096. onClick: function onClick(event) {
  23097. if (controlItem.modal && controlItem.modal.id) {
  23098. if (_this3.extendedModals[controlItem.modal.id]) {
  23099. _this3.extendedModals[controlItem.modal.id].active = true;
  23100. _this3.extendedModals[controlItem.modal.id].update(objectSpread_default()({}, controlItem.modal, {
  23101. language: language
  23102. }));
  23103. } else {
  23104. _this3.extendedModals[controlItem.modal.id] = Modal_showModal(objectSpread_default()({}, controlItem.modal, {
  23105. language: language
  23106. }));
  23107. controlItem.modal.onCreate && controlItem.modal.onCreate(_this3.extendedModals[controlItem.modal.id]);
  23108. }
  23109. }
  23110. controlItem.onClick && controlItem.onClick(event);
  23111. }
  23112. }, !controlItem.html ? controlItem.text : null);
  23113. } else if (controlItem.type === 'component') {
  23114. return external_react_default.a.createElement("div", {
  23115. key: index,
  23116. className: "component-wrapper ".concat(controlItem.className || '')
  23117. }, controlItem.component);
  23118. } else if (controlItem.type === 'button') {
  23119. return external_react_default.a.createElement("button", {
  23120. type: "button",
  23121. key: index,
  23122. "data-title": controlItem.title,
  23123. disabled: controlItem.disabled,
  23124. className: "control-item button ".concat(controlItem.className || ''),
  23125. dangerouslySetInnerHTML: controlItem.html ? {
  23126. __html: controlItem.html
  23127. } : null,
  23128. onClick: function onClick(event) {
  23129. return controlItem.onClick && controlItem.onClick(event);
  23130. }
  23131. }, !controlItem.html ? controlItem.text : null);
  23132. } else if (controlItem) {
  23133. var disabled = false;
  23134. if (controlItem.command === 'undo') {
  23135. disabled = editorState.getUndoStack().size === 0;
  23136. } else if (controlItem.command === 'redo') {
  23137. disabled = editorState.getRedoStack().size === 0;
  23138. }
  23139. return external_react_default.a.createElement("button", {
  23140. type: "button",
  23141. key: index,
  23142. disabled: disabled,
  23143. "data-title": controlItem.title,
  23144. className: _this3.getControlItemClassName({
  23145. type: controlItem.type,
  23146. command: controlItem.command
  23147. }),
  23148. onClick: function onClick() {
  23149. return _this3.applyControl(controlItem.command, controlItem.type, controlItem.data);
  23150. }
  23151. }, controlItem.text);
  23152. }
  23153. }));
  23154. }
  23155. }, {
  23156. key: "preventDefault",
  23157. value: function preventDefault(event) {
  23158. var tagName = event.target.tagName.toLowerCase();
  23159. if (tagName === 'input' || tagName === 'label') ; else {
  23160. event.preventDefault();
  23161. }
  23162. }
  23163. }]);
  23164. return ControlBar;
  23165. }(external_react_default.a.Component);
  23166. // CONCATENATED MODULE: ./editor/index.jsx
  23167. var buildHooks = function buildHooks(hooks) {
  23168. return function (hookName) {
  23169. var defaultReturns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  23170. return hooks[hookName] || function () {
  23171. return defaultReturns;
  23172. };
  23173. };
  23174. };
  23175. var filterColors = function filterColors(colors, colors2) {
  23176. return colors.filter(function (item) {
  23177. return !colors2.find(function (color) {
  23178. return color.toLowerCase() === item.toLowerCase();
  23179. });
  23180. }).filter(function (item, index, array) {
  23181. return array.indexOf(item) === index;
  23182. });
  23183. };
  23184. var editor_isControlEnabled = function isControlEnabled(props, controlName) {
  23185. return toConsumableArray_default()(props.controls).concat(toConsumableArray_default()(props.extendControls)).find(function (item) {
  23186. return item === controlName || item.key === controlName;
  23187. }) && props.excludeControls.indexOf(controlName) === -1;
  23188. };
  23189. var editor_getConvertOptions = function getConvertOptions(props) {
  23190. var editorId = props.editorId || props.id;
  23191. var convertOptions = objectSpread_default()({}, configs_props.converts, props.converts, {
  23192. fontFamilies: props.fontFamilies
  23193. });
  23194. convertOptions.styleImportFn = compositeStyleImportFn(convertOptions.styleImportFn, editorId);
  23195. convertOptions.styleExportFn = compositeStyleExportFn(convertOptions.styleExportFn, editorId);
  23196. convertOptions.entityImportFn = compositeEntityImportFn(convertOptions.entityImportFn, editorId);
  23197. convertOptions.entityExportFn = compositeEntityExportFn(convertOptions.entityExportFn, editorId);
  23198. convertOptions.blockImportFn = compositeBlockImportFn(convertOptions.blockImportFn, editorId);
  23199. convertOptions.blockExportFn = compositeBlockExportFn(convertOptions.blockExportFn, editorId);
  23200. return convertOptions;
  23201. };
  23202. var editor_BraftEditor =
  23203. /*#__PURE__*/
  23204. function (_React$Component) {
  23205. inherits_default()(BraftEditor, _React$Component);
  23206. function BraftEditor(props) {
  23207. var _this;
  23208. classCallCheck_default()(this, BraftEditor);
  23209. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(BraftEditor).call(this, props));
  23210. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onChange", function (editorState, callback) {
  23211. if (!(editorState instanceof external_draft_js_["EditorState"])) {
  23212. editorState = external_draft_js_["EditorState"].set(editorState, {
  23213. decorator: _this.editorDecorators
  23214. });
  23215. }
  23216. if (!editorState.convertOptions) {
  23217. editorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  23218. }
  23219. _this.setState({
  23220. editorState: editorState
  23221. }, function () {
  23222. _this.props.onChange && _this.props.onChange(editorState);
  23223. callback && callback(editorState);
  23224. });
  23225. });
  23226. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getDraftInstance", function () {
  23227. return _this.draftInstance;
  23228. });
  23229. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getFinderInstance", function () {
  23230. return _this.braftFinder;
  23231. });
  23232. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getValue", function () {
  23233. return _this.state.editorState;
  23234. });
  23235. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setValue", function (editorState, callback) {
  23236. return _this.onChange(editorState, callback);
  23237. });
  23238. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "forceRender", function () {
  23239. var selectionState = _this.state.editorState.getSelection();
  23240. _this.setValue(external_draft_js_["EditorState"].set(_this.state.editorState, {
  23241. decorator: _this.editorDecorators
  23242. }), function () {
  23243. _this.setValue(external_draft_js_["EditorState"].forceSelection(_this.state.editorState, selectionState));
  23244. });
  23245. });
  23246. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onTab", function (event) {
  23247. if (handlers_keyCommandHandlers('tab', _this.state.editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this))) === 'handled') {
  23248. event.preventDefault();
  23249. }
  23250. _this.editorProps.onTab && _this.editorProps.onTab(event);
  23251. });
  23252. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onFocus", function () {
  23253. _this.isFocused = true;
  23254. _this.editorProps.onFocus && _this.editorProps.onFocus(_this.state.editorState);
  23255. });
  23256. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onBlur", function () {
  23257. _this.isFocused = false;
  23258. _this.editorProps.onBlur && _this.editorProps.onBlur(_this.state.editorState);
  23259. });
  23260. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "requestFocus", function () {
  23261. setTimeout(function () {
  23262. return _this.draftInstance.focus();
  23263. }, 0);
  23264. });
  23265. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleKeyCommand", function (command, editorState) {
  23266. return handlers_keyCommandHandlers(command, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23267. });
  23268. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleReturn", function (event, editorState) {
  23269. return handlers_returnHandlers(event, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23270. });
  23271. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleBeforeInput", function (chars, editorState) {
  23272. return beforeInputHandlers(chars, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23273. });
  23274. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDrop", function (selectionState, dataTransfer) {
  23275. return handlers_dropHandlers(selectionState, dataTransfer, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23276. });
  23277. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDroppedFiles", function (selectionState, files) {
  23278. return droppedFilesHandlers(selectionState, files, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23279. });
  23280. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handlePastedFiles", function (files) {
  23281. return pastedFilesHandlers(files, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23282. });
  23283. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCopyContent", function (event) {
  23284. return handlers_copyHandlers(event, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23285. });
  23286. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handlePastedText", function (text, html, editorState) {
  23287. return handlers_pastedTextHandlers(text, html, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23288. });
  23289. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCompositionStart", function (event) {
  23290. return handlers_compositionStartHandler(event, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23291. });
  23292. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "undo", function () {
  23293. _this.setValue(external_braft_utils_["ContentUtils"].undo(_this.state.editorState));
  23294. });
  23295. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "redo", function () {
  23296. _this.setValue(external_braft_utils_["ContentUtils"].redo(_this.state.editorState));
  23297. });
  23298. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeSelectionInlineStyles", function () {
  23299. _this.setValue(external_braft_utils_["ContentUtils"].removeSelectionInlineStyles(_this.state.editorState));
  23300. });
  23301. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "insertHorizontalLine", function () {
  23302. _this.setValue(external_braft_utils_["ContentUtils"].insertHorizontalLine(_this.state.editorState));
  23303. });
  23304. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "clearEditorContent", function () {
  23305. _this.setValue(external_braft_utils_["ContentUtils"].clear(_this.state.editorState), function (editorState) {
  23306. _this.setValue(external_braft_utils_["ContentUtils"].toggleSelectionIndent(editorState, 0));
  23307. });
  23308. });
  23309. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleFullscreen", function (fullscreen) {
  23310. _this.setState({
  23311. isFullscreen: typeof fullscreen !== 'undefined' ? fullscreen : !_this.state.isFullscreen
  23312. }, function () {
  23313. _this.editorProps.onFullscreen && _this.editorProps.onFullscreen(_this.state.isFullscreen);
  23314. });
  23315. });
  23316. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setEditorContainerNode", function (containerNode) {
  23317. _this.containerNode = containerNode;
  23318. });
  23319. _this.editorProps = _this.getEditorProps(props);
  23320. _this.editorDecorators = getDecorators(_this.editorProps.editorId || _this.editorProps.id);
  23321. _this.isFocused = false;
  23322. _this.isLiving = false;
  23323. _this.braftFinder = null;
  23324. _this.valueInitialized = !!(_this.props.defaultValue || _this.props.value);
  23325. 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);
  23326. defaultEditorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  23327. var tempColors = [];
  23328. if (external_braft_utils_["ContentUtils"].isEditorState(defaultEditorState)) {
  23329. var colors = external_braft_utils_["ColorUtils"].detectColorsFromDraftState(defaultEditorState.toRAW(true));
  23330. defaultEditorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  23331. tempColors = filterColors(colors, _this.editorProps.colors);
  23332. }
  23333. _this.state = {
  23334. tempColors: tempColors,
  23335. editorState: defaultEditorState,
  23336. isFullscreen: false,
  23337. draftProps: {}
  23338. };
  23339. _this.containerNode = null;
  23340. return _this;
  23341. }
  23342. createClass_default()(BraftEditor, [{
  23343. key: "getEditorProps",
  23344. value: function getEditorProps(props) {
  23345. var _this2 = this;
  23346. props = props || this.props;
  23347. var _props = props,
  23348. value = _props.value,
  23349. defaultValue = _props.defaultValue,
  23350. onChange = _props.onChange,
  23351. restProps = objectWithoutProperties_default()(_props, ["value", "defaultValue", "onChange"]); // eslint-disable-line no-unused-vars
  23352. var propInterceptors = getPropInterceptors(restProps.editorId || restProps.id);
  23353. if (propInterceptors.length === 0) {
  23354. return restProps;
  23355. }
  23356. var porpsMap = Object(external_immutable_["Map"])(restProps);
  23357. propInterceptors.forEach(function (interceptor) {
  23358. porpsMap = porpsMap.merge(Object(external_immutable_["Map"])(interceptor(porpsMap.toJS(), _this2) || {}));
  23359. });
  23360. return porpsMap.toJS();
  23361. }
  23362. }, {
  23363. key: "componentWillMount",
  23364. value: function componentWillMount() {
  23365. if (editor_isControlEnabled(this.editorProps, 'media')) {
  23366. var _this$editorProps = this.editorProps,
  23367. language = _this$editorProps.language,
  23368. media = _this$editorProps.media;
  23369. var _defaultProps$media$m = objectSpread_default()({}, configs_props.media, media),
  23370. uploadFn = _defaultProps$media$m.uploadFn,
  23371. validateFn = _defaultProps$media$m.validateFn,
  23372. items = _defaultProps$media$m.items;
  23373. this.braftFinder = new external_braft_finder_default.a({
  23374. items: items,
  23375. language: language,
  23376. uploader: uploadFn,
  23377. validator: validateFn
  23378. });
  23379. this.forceUpdate();
  23380. }
  23381. }
  23382. }, {
  23383. key: "componentDidMount",
  23384. value: function componentDidMount() {
  23385. this.isLiving = true;
  23386. }
  23387. }, {
  23388. key: "componentDidUpdate",
  23389. value: function componentDidUpdate(_, prevState) {
  23390. if (prevState.editorState !== this.state.editorState) {
  23391. this.state.editorState.setConvertOptions(editor_getConvertOptions(this.editorProps));
  23392. }
  23393. }
  23394. }, {
  23395. key: "componentWillReceiveProps",
  23396. value: function componentWillReceiveProps(props) {
  23397. var _this3 = this;
  23398. this.editorProps = this.getEditorProps(props);
  23399. var editorState = props.value;
  23400. var _this$editorProps2 = this.editorProps,
  23401. media = _this$editorProps2.media,
  23402. language = _this$editorProps2.language;
  23403. var currentProps = this.getEditorProps();
  23404. if (!editor_isControlEnabled(currentProps, 'media') && editor_isControlEnabled(this.editorProps, 'media') && !this.braftFinder) {
  23405. var _defaultProps$media$m2 = objectSpread_default()({}, configs_props.media, media),
  23406. uploadFn = _defaultProps$media$m2.uploadFn,
  23407. validateFn = _defaultProps$media$m2.validateFn,
  23408. items = _defaultProps$media$m2.items;
  23409. this.braftFinder = new external_braft_finder_default.a({
  23410. items: items,
  23411. language: language,
  23412. uploader: uploadFn,
  23413. validator: validateFn
  23414. });
  23415. this.forceUpdate();
  23416. }
  23417. if (media && media.items && this.braftFinder) {
  23418. this.braftFinder.setItems(media.items);
  23419. }
  23420. var nextEditorState;
  23421. if (!this.valueInitialized && typeof this.props.defaultValue === 'undefined' && external_braft_utils_["ContentUtils"].isEditorState(props.defaultValue)) {
  23422. nextEditorState = props.defaultValue;
  23423. } else if (external_braft_utils_["ContentUtils"].isEditorState(editorState)) {
  23424. nextEditorState = editorState;
  23425. }
  23426. if (nextEditorState) {
  23427. if (nextEditorState && nextEditorState !== this.state.editorState) {
  23428. var tempColors = external_braft_utils_["ColorUtils"].detectColorsFromDraftState(nextEditorState.toRAW(true));
  23429. nextEditorState.setConvertOptions(editor_getConvertOptions(this.editorProps));
  23430. this.setState({
  23431. tempColors: filterColors(toConsumableArray_default()(this.state.tempColors).concat(toConsumableArray_default()(tempColors)), currentProps.colors),
  23432. editorState: nextEditorState
  23433. }, function () {
  23434. _this3.props.onChange && _this3.props.onChange(nextEditorState);
  23435. });
  23436. } else {
  23437. this.setState({
  23438. editorState: nextEditorState
  23439. });
  23440. }
  23441. }
  23442. }
  23443. }, {
  23444. key: "componentWillUnmount",
  23445. value: function componentWillUnmount() {
  23446. this.isLiving = false;
  23447. this.controlBarInstance && this.controlBarInstance.closeBraftFinder();
  23448. }
  23449. }, {
  23450. key: "lockOrUnlockEditor",
  23451. value: function lockOrUnlockEditor(editorLocked) {
  23452. this.setState({
  23453. editorLocked: editorLocked
  23454. });
  23455. }
  23456. }, {
  23457. key: "render",
  23458. value: function render() {
  23459. var _this4 = this;
  23460. var _this$editorProps3 = this.editorProps,
  23461. id = _this$editorProps3.id,
  23462. editorId = _this$editorProps3.editorId,
  23463. controls = _this$editorProps3.controls,
  23464. excludeControls = _this$editorProps3.excludeControls,
  23465. extendControls = _this$editorProps3.extendControls,
  23466. readOnly = _this$editorProps3.readOnly,
  23467. disabled = _this$editorProps3.disabled,
  23468. media = _this$editorProps3.media,
  23469. language = _this$editorProps3.language,
  23470. colors = _this$editorProps3.colors,
  23471. colorPicker = _this$editorProps3.colorPicker,
  23472. colorPickerTheme = _this$editorProps3.colorPickerTheme,
  23473. colorPickerAutoHide = _this$editorProps3.colorPickerAutoHide,
  23474. hooks = _this$editorProps3.hooks,
  23475. fontSizes = _this$editorProps3.fontSizes,
  23476. fontFamilies = _this$editorProps3.fontFamilies,
  23477. emojis = _this$editorProps3.emojis,
  23478. placeholder = _this$editorProps3.placeholder,
  23479. fixPlaceholder = _this$editorProps3.fixPlaceholder,
  23480. headings = _this$editorProps3.headings,
  23481. imageControls = _this$editorProps3.imageControls,
  23482. imageResizable = _this$editorProps3.imageResizable,
  23483. lineHeights = _this$editorProps3.lineHeights,
  23484. letterSpacings = _this$editorProps3.letterSpacings,
  23485. textAligns = _this$editorProps3.textAligns,
  23486. textBackgroundColor = _this$editorProps3.textBackgroundColor,
  23487. allowInsertLinkText = _this$editorProps3.allowInsertLinkText,
  23488. defaultLinkTarget = _this$editorProps3.defaultLinkTarget,
  23489. extendAtomics = _this$editorProps3.extendAtomics,
  23490. className = _this$editorProps3.className,
  23491. style = _this$editorProps3.style,
  23492. controlBarClassName = _this$editorProps3.controlBarClassName,
  23493. controlBarStyle = _this$editorProps3.controlBarStyle,
  23494. contentClassName = _this$editorProps3.contentClassName,
  23495. contentStyle = _this$editorProps3.contentStyle,
  23496. stripPastedStyles = _this$editorProps3.stripPastedStyles,
  23497. componentBelowControlBar = _this$editorProps3.componentBelowControlBar;
  23498. var _this$state = this.state,
  23499. isFullscreen = _this$state.isFullscreen,
  23500. editorState = _this$state.editorState;
  23501. editorId = editorId || id;
  23502. hooks = buildHooks(hooks);
  23503. controls = controls.filter(function (item) {
  23504. return excludeControls.indexOf(item) === -1;
  23505. });
  23506. language = (typeof language === 'function' ? language(languages, 'braft-editor') : languages[language]) || languages[configs_props.language];
  23507. var externalMedias = media && media.externals ? objectSpread_default()({}, configs_props.media.externals, media.externals) : configs_props.media.externals;
  23508. var accepts = media && media.accepts ? objectSpread_default()({}, configs_props.media.accepts, media.accepts) : configs_props.media.accepts;
  23509. media = objectSpread_default()({}, configs_props.media, media, {
  23510. externalMedias: externalMedias,
  23511. accepts: accepts
  23512. });
  23513. if (!media.uploadFn) {
  23514. media.video = false;
  23515. media.audio = false;
  23516. }
  23517. var controlBarProps = {
  23518. editor: this,
  23519. editorState: editorState,
  23520. braftFinder: this.braftFinder,
  23521. ref: function ref(instance) {
  23522. return _this4.controlBarInstance = instance;
  23523. },
  23524. getContainerNode: function getContainerNode() {
  23525. return _this4.containerNode;
  23526. },
  23527. className: controlBarClassName,
  23528. style: controlBarStyle,
  23529. colors: toConsumableArray_default()(colors).concat(toConsumableArray_default()(this.state.tempColors)),
  23530. colorPicker: colorPicker,
  23531. colorPickerTheme: colorPickerTheme,
  23532. colorPickerAutoHide: colorPickerAutoHide,
  23533. hooks: hooks,
  23534. editorId: editorId,
  23535. media: media,
  23536. controls: controls,
  23537. language: language,
  23538. extendControls: extendControls,
  23539. headings: headings,
  23540. fontSizes: fontSizes,
  23541. fontFamilies: fontFamilies,
  23542. emojis: emojis,
  23543. lineHeights: lineHeights,
  23544. letterSpacings: letterSpacings,
  23545. textAligns: textAligns,
  23546. textBackgroundColor: textBackgroundColor,
  23547. allowInsertLinkText: allowInsertLinkText,
  23548. defaultLinkTarget: defaultLinkTarget
  23549. };
  23550. var unitExportFn = editorState.convertOptions.unitExportFn;
  23551. var commonProps = {
  23552. editor: this,
  23553. editorId: editorId,
  23554. hooks: hooks,
  23555. editorState: editorState,
  23556. containerNode: this.containerNode,
  23557. imageControls: imageControls,
  23558. imageResizable: imageResizable,
  23559. language: language,
  23560. extendAtomics: extendAtomics
  23561. };
  23562. var blockRendererFn = getBlockRendererFn(commonProps, this.editorProps.blockRendererFn);
  23563. var blockRenderMap = getBlockRenderMap(commonProps, this.editorProps.blockRenderMap);
  23564. var blockStyleFn = getBlockStyleFn(this.editorProps.blockStyleFn);
  23565. var customStyleMap = getCustomStyleMap(commonProps, this.editorProps.customStyleMap);
  23566. var customStyleFn = getCustomStyleFn(commonProps, {
  23567. fontFamilies: fontFamilies,
  23568. unitExportFn: unitExportFn,
  23569. customStyleFn: this.editorProps.customStyleFn
  23570. });
  23571. var keyBindingFn = keybindings(this.editorProps.keyBindingFn);
  23572. var mixedProps = {};
  23573. if (this.state.editorLocked || this.editorProps.disabled || this.editorProps.readOnly || this.editorProps.draftProps.readOnly) {
  23574. mixedProps.readOnly = true;
  23575. }
  23576. if (placeholder && fixPlaceholder && editorState.isEmpty() && editorState.getCurrentContent().getFirstBlock().getType() !== 'unstyled') {
  23577. placeholder = '';
  23578. }
  23579. var draftProps = objectSpread_default()({
  23580. ref: function ref(instance) {
  23581. _this4.draftInstance = instance;
  23582. },
  23583. editorState: editorState,
  23584. handleKeyCommand: this.handleKeyCommand,
  23585. handleReturn: this.handleReturn,
  23586. handleBeforeInput: this.handleBeforeInput,
  23587. handleDrop: this.handleDrop,
  23588. handleDroppedFiles: this.handleDroppedFiles,
  23589. handlePastedText: this.handlePastedText,
  23590. handlePastedFiles: this.handlePastedFiles,
  23591. onChange: this.onChange,
  23592. onTab: this.onTab,
  23593. onFocus: this.onFocus,
  23594. onBlur: this.onBlur,
  23595. blockRenderMap: blockRenderMap,
  23596. blockRendererFn: blockRendererFn,
  23597. blockStyleFn: blockStyleFn,
  23598. customStyleMap: customStyleMap,
  23599. customStyleFn: customStyleFn,
  23600. keyBindingFn: keyBindingFn,
  23601. placeholder: placeholder,
  23602. stripPastedStyles: stripPastedStyles
  23603. }, this.editorProps.draftProps, mixedProps);
  23604. return external_react_default.a.createElement("div", {
  23605. style: style,
  23606. ref: this.setEditorContainerNode,
  23607. className: "bf-container ".concat(className).concat(disabled ? ' disabled' : '').concat(readOnly ? ' read-only' : '').concat(isFullscreen ? ' fullscreen' : '')
  23608. }, external_react_default.a.createElement(ControlBar_ControlBar, controlBarProps), componentBelowControlBar, external_react_default.a.createElement("div", {
  23609. onCompositionStart: this.handleCompositionStart,
  23610. className: "bf-content ".concat(contentClassName),
  23611. onCopy: this.handleCopyContent,
  23612. style: contentStyle
  23613. }, external_react_default.a.createElement(external_draft_js_["Editor"], draftProps)));
  23614. }
  23615. }]);
  23616. return BraftEditor;
  23617. }(external_react_default.a.Component);
  23618. defineProperty_default()(editor_BraftEditor, "defaultProps", configs_props);
  23619. // EXTERNAL MODULE: external "braft-convert"
  23620. var external_braft_convert_ = __webpack_require__(14);
  23621. // CONCATENATED MODULE: ./index.jsx
  23622. /* concated harmony reexport EditorState */__webpack_require__.d(__webpack_exports__, "EditorState", function() { return external_draft_js_["EditorState"]; });
  23623. /* concated harmony reexport getDecorators */__webpack_require__.d(__webpack_exports__, "getDecorators", function() { return getDecorators; });
  23624. external_draft_js_["EditorState"].prototype.setConvertOptions = function () {
  23625. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  23626. this.convertOptions = options;
  23627. };
  23628. external_draft_js_["EditorState"].prototype.toHTML = function () {
  23629. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  23630. var convertOptions = this.convertOptions || {};
  23631. return Object(external_braft_convert_["convertEditorStateToHTML"])(this, objectSpread_default()({}, convertOptions, options));
  23632. };
  23633. external_draft_js_["EditorState"].prototype.toRAW = function (noStringify) {
  23634. return noStringify ? Object(external_braft_convert_["convertEditorStateToRaw"])(this) : JSON.stringify(Object(external_braft_convert_["convertEditorStateToRaw"])(this));
  23635. };
  23636. external_draft_js_["EditorState"].prototype.toText = function () {
  23637. return this.getCurrentContent().getPlainText();
  23638. };
  23639. external_draft_js_["EditorState"].prototype.isEmpty = function () {
  23640. return !this.getCurrentContent().hasText();
  23641. };
  23642. editor_BraftEditor.createEditorState = external_draft_js_["EditorState"].createFrom = function (content) {
  23643. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  23644. options.unitExportFn = options.unitExportFn || editor_BraftEditor.defaultProps.converts.unitExportFn;
  23645. options.styleImportFn = compositeStyleImportFn(options.styleImportFn, options.editorId);
  23646. options.entityImportFn = compositeEntityImportFn(options.entityImportFn, options.editorId);
  23647. options.blockImportFn = compositeBlockImportFn(options.blockImportFn, options.editorId);
  23648. var editorState = null;
  23649. if (content instanceof external_draft_js_["EditorState"]) {
  23650. editorState = content;
  23651. } else if (typeof_default()(content) === 'object' && content && content.blocks && content.entityMap) {
  23652. editorState = Object(external_braft_convert_["convertRawToEditorState"])(content, getDecorators(options.editorId));
  23653. } else if (typeof content === 'string') {
  23654. try {
  23655. if (/^(-)?\d+$/.test(content)) {
  23656. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content, getDecorators(options.editorId), options, 'create');
  23657. } else {
  23658. editorState = external_draft_js_["EditorState"].createFrom(JSON.parse(content), options);
  23659. }
  23660. } catch (error) {
  23661. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content, getDecorators(options.editorId), options, 'create');
  23662. }
  23663. } else if (typeof content === 'number') {
  23664. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content.toLocaleString().replace(/,/g, ''), getDecorators(options.editorId), options, 'create');
  23665. } else {
  23666. editorState = external_draft_js_["EditorState"].createEmpty(getDecorators(options.editorId));
  23667. }
  23668. options.styleExportFn = compositeStyleExportFn(options.styleExportFn, options.editorId);
  23669. options.entityExportFn = compositeEntityExportFn(options.entityExportFn, options.editorId);
  23670. options.blockExportFn = compositeBlockExportFn(options.blockExportFn, options.editorId);
  23671. editorState.setConvertOptions(options);
  23672. return editorState;
  23673. };
  23674. /* harmony default export */ var index_0 = __webpack_exports__["default"] = (createExtensibleEditor(editor_BraftEditor));
  23675. // 2.1版本开发计划
  23676. // [ ]优化选中多行文字是插入链接报错的问题
  23677. // [ ]新增编辑器内图片删除hook
  23678. // 2.2版本开发计划
  23679. // [ ]表格功能
  23680. // [ ]美化UI,包括图标和界面风格
  23681. // 2.3版本开发计划
  23682. // [ ]初级md快捷输入支持
  23683. // [ ]图片裁切等简单的编辑功能
  23684. // [ ]允许自定义快捷键
  23685. /***/ }),
  23686. /* 40 */
  23687. /***/ (function(module, exports) {
  23688. // removed by extract-text-webpack-plugin
  23689. /***/ }),
  23690. /* 41 */,
  23691. /* 42 */
  23692. /***/ (function(module, exports) {
  23693. // removed by extract-text-webpack-plugin
  23694. /***/ }),
  23695. /* 43 */,
  23696. /* 44 */,
  23697. /* 45 */
  23698. /***/ (function(module, exports) {
  23699. // removed by extract-text-webpack-plugin
  23700. /***/ }),
  23701. /* 46 */
  23702. /***/ (function(module, exports) {
  23703. // removed by extract-text-webpack-plugin
  23704. /***/ }),
  23705. /* 47 */
  23706. /***/ (function(module, exports) {
  23707. // removed by extract-text-webpack-plugin
  23708. /***/ }),
  23709. /* 48 */
  23710. /***/ (function(module, exports) {
  23711. // removed by extract-text-webpack-plugin
  23712. /***/ }),
  23713. /* 49 */
  23714. /***/ (function(module, exports) {
  23715. // removed by extract-text-webpack-plugin
  23716. /***/ }),
  23717. /* 50 */
  23718. /***/ (function(module, exports) {
  23719. // removed by extract-text-webpack-plugin
  23720. /***/ }),
  23721. /* 51 */
  23722. /***/ (function(module, exports) {
  23723. // removed by extract-text-webpack-plugin
  23724. /***/ }),
  23725. /* 52 */
  23726. /***/ (function(module, exports) {
  23727. // removed by extract-text-webpack-plugin
  23728. /***/ }),
  23729. /* 53 */
  23730. /***/ (function(module, exports) {
  23731. // removed by extract-text-webpack-plugin
  23732. /***/ }),
  23733. /* 54 */
  23734. /***/ (function(module, exports) {
  23735. // removed by extract-text-webpack-plugin
  23736. /***/ }),
  23737. /* 55 */
  23738. /***/ (function(module, exports) {
  23739. // removed by extract-text-webpack-plugin
  23740. /***/ }),
  23741. /* 56 */
  23742. /***/ (function(module, exports) {
  23743. // removed by extract-text-webpack-plugin
  23744. /***/ }),
  23745. /* 57 */
  23746. /***/ (function(module, exports) {
  23747. // removed by extract-text-webpack-plugin
  23748. /***/ }),
  23749. /* 58 */
  23750. /***/ (function(module, exports) {
  23751. // removed by extract-text-webpack-plugin
  23752. /***/ }),
  23753. /* 59 */
  23754. /***/ (function(module, exports) {
  23755. // removed by extract-text-webpack-plugin
  23756. /***/ }),
  23757. /* 60 */
  23758. /***/ (function(module, exports) {
  23759. // removed by extract-text-webpack-plugin
  23760. /***/ }),
  23761. /* 61 */
  23762. /***/ (function(module, exports) {
  23763. // removed by extract-text-webpack-plugin
  23764. /***/ }),
  23765. /* 62 */
  23766. /***/ (function(module, exports) {
  23767. // removed by extract-text-webpack-plugin
  23768. /***/ }),
  23769. /* 63 */
  23770. /***/ (function(module, exports) {
  23771. // removed by extract-text-webpack-plugin
  23772. /***/ })
  23773. /******/ ]);
  23774. });
  23775. });
  23776. var BraftEditor = _commonjsHelpers.unwrapExports(dist$3);
  23777. var css = ".index_bf-controlbar__3CCYm{margin:0;padding:0 5px;box-shadow:inset 0 -1px 0 0 rgba(0,0,0,.2)}.index_bf-controlbar__3CCYm:after{display:block;content:\"\";clear:both}.index_bf-controlbar__3CCYm button{padding:0;outline:none}.index_bf-controlbar__3CCYm button[disabled]{pointer-events:none;opacity:.3}.index_bf-controlbar__3CCYm [data-title]{position:relative}.index_bf-controlbar__3CCYm [data-title]:after,.index_bf-controlbar__3CCYm [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__3CCYm [data-title]:before{margin-top:3px;border:5px solid transparent;border-bottom-color:#21242a;content:\"\"}.index_bf-controlbar__3CCYm [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__3CCYm [data-title]:hover:after,.index_bf-controlbar__3CCYm [data-title]:hover:before{opacity:1;transform:translateX(-50%) translateY(0)}.index_bf-controlbar__3CCYm input{outline:none}.index_bf-controlbar__3CCYm .index_separator-line__2q8N5{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__3CCYm .index_separator-line__2q8N5+.index_control-item__14OBf,.index_bf-controlbar__3CCYm .index_separator-line__2q8N5+.index_control-item-group__1J9a7{margin-left:0}.index_bf-controlbar__3CCYm .index_separator-line__2q8N5+.index_separator-line__2q8N5,.index_bf-controlbar__3CCYm .index_separator-line__2q8N5.index_first-child__o980o,.index_bf-controlbar__3CCYm .index_separator-line__2q8N5.index_last-child__1erOy{display:none}.index_bf-controlbar__3CCYm .index_control-item-group__1J9a7{float:left;height:36px;margin:5px 0 5px 3px}.index_bf-controlbar__3CCYm .index_control-item-group__1J9a7:first-child{margin-left:0}.index_bf-controlbar__3CCYm .index_control-item-group__1J9a7>.index_control-item__14OBf{margin-top:0;margin-bottom:0}.index_bf-controlbar__3CCYm .index_dropdown-handler__MTW22{border-radius:2px}.index_bf-controlbar__3CCYm .index_control-item__14OBf{display:block;float:left;height:36px;margin:5px 0 5px 3px;border-radius:2px;cursor:pointer}.index_bf-controlbar__3CCYm .index_control-item__14OBf.index_component-wrapper__3TwHO{cursor:default}.index_bf-controlbar__3CCYm .index_control-item__14OBf:first-child{margin-left:0}.index_bf-controlbar__3CCYm .index_control-item__14OBf.index_button__3Upba{box-sizing:border-box;min-width:36px;padding:0 8px;background-color:transparent;border:none;color:#6a6f7b;font-size:14px}.index_bf-controlbar__3CCYm .index_control-item__14OBf.index_button__3Upba:hover{background-color:rgba(0,0,0,.05)}.index_bf-controlbar__3CCYm .index_control-item__14OBf.index_button__3Upba.index_active__-pMJD{color:#3498db}.index_bf-controlbar__3CCYm .index_control-item__14OBf.index_button__3Upba i:before{display:block;height:36px;font-size:18px;line-height:36px}.index_bf-controlbar__3CCYm .index_control-item__14OBf.index_button__3Upba .index_bfi-redo__1zMS1:before,.index_bf-controlbar__3CCYm .index_control-item__14OBf.index_button__3Upba .index_bfi-undo__1uH1l:before{font-size:14px}.index_bf-controlbar__3CCYm .index_dropdown__JBUUP .index_control-item__14OBf{width:100%;float:none;margin:0}.index_DraftEditor-editorContainer__2JNtE,.index_DraftEditor-root__1ecF2,.index_public-DraftEditor-content__24kl-{height:inherit;text-align:initial}.index_public-DraftEditor-content__24kl-[contenteditable=true]{-webkit-user-modify:read-write-plaintext-only}.index_DraftEditor-root__1ecF2{position:relative}.index_DraftEditor-editorContainer__2JNtE{background-color:hsla(0,0%,100%,0);border-left:.1px solid transparent;position:relative;z-index:1}.index_public-DraftEditor-block__BK5Tu{position:relative}.index_DraftEditor-alignLeft__1wXXz .index_public-DraftStyleDefault-block__Sv4nb{text-align:left}.index_DraftEditor-alignLeft__1wXXz .index_public-DraftEditorPlaceholder-root__q1VIv{left:0;text-align:left}.index_DraftEditor-alignCenter__1GFcJ .index_public-DraftStyleDefault-block__Sv4nb{text-align:center}.index_DraftEditor-alignCenter__1GFcJ .index_public-DraftEditorPlaceholder-root__q1VIv{margin:0 auto;text-align:center;width:100%}.index_DraftEditor-alignRight__31w6Z .index_public-DraftStyleDefault-block__Sv4nb{text-align:right}.index_DraftEditor-alignRight__31w6Z .index_public-DraftEditorPlaceholder-root__q1VIv{right:0;text-align:right}.index_public-DraftEditorPlaceholder-root__q1VIv{color:#9197a3;position:absolute;z-index:1}.index_public-DraftEditorPlaceholder-hasFocus__3gswB{color:#bdc1c9}.index_DraftEditorPlaceholder-hidden__2vqlD{display:none}.index_public-DraftStyleDefault-block__Sv4nb{position:relative;white-space:pre-wrap}.index_public-DraftStyleDefault-ltr__3nF5D{direction:ltr;text-align:left}.index_public-DraftStyleDefault-rtl__1NKvZ{direction:rtl;text-align:right}.index_public-DraftStyleDefault-listLTR__2_H8S{direction:ltr}.index_public-DraftStyleDefault-listRTL__3aocB{direction:rtl}.index_public-DraftStyleDefault-ol__2Rnls,.index_public-DraftStyleDefault-ul__26fcv{margin:16px 0;padding:0}.index_public-DraftStyleDefault-depth0__3A7Cc.index_public-DraftStyleDefault-listLTR__2_H8S{margin-left:1.5em}.index_public-DraftStyleDefault-depth0__3A7Cc.index_public-DraftStyleDefault-listRTL__3aocB{margin-right:1.5em}.index_public-DraftStyleDefault-depth1__2qvXA.index_public-DraftStyleDefault-listLTR__2_H8S{margin-left:3em}.index_public-DraftStyleDefault-depth1__2qvXA.index_public-DraftStyleDefault-listRTL__3aocB{margin-right:3em}.index_public-DraftStyleDefault-depth2__eQTbg.index_public-DraftStyleDefault-listLTR__2_H8S{margin-left:4.5em}.index_public-DraftStyleDefault-depth2__eQTbg.index_public-DraftStyleDefault-listRTL__3aocB{margin-right:4.5em}.index_public-DraftStyleDefault-depth3__1Lulo.index_public-DraftStyleDefault-listLTR__2_H8S{margin-left:6em}.index_public-DraftStyleDefault-depth3__1Lulo.index_public-DraftStyleDefault-listRTL__3aocB{margin-right:6em}.index_public-DraftStyleDefault-depth4__wdX4S.index_public-DraftStyleDefault-listLTR__2_H8S{margin-left:7.5em}.index_public-DraftStyleDefault-depth4__wdX4S.index_public-DraftStyleDefault-listRTL__3aocB{margin-right:7.5em}.index_public-DraftStyleDefault-unorderedListItem__2as-n{list-style-type:square;position:relative}.index_public-DraftStyleDefault-unorderedListItem__2as-n.index_public-DraftStyleDefault-depth0__3A7Cc{list-style-type:disc}.index_public-DraftStyleDefault-unorderedListItem__2as-n.index_public-DraftStyleDefault-depth1__2qvXA{list-style-type:circle}.index_public-DraftStyleDefault-orderedListItem__7JV9o{list-style-type:none;position:relative}.index_public-DraftStyleDefault-orderedListItem__7JV9o.index_public-DraftStyleDefault-listLTR__2_H8S:before{left:-36px;position:absolute;text-align:right;width:30px}.index_public-DraftStyleDefault-orderedListItem__7JV9o.index_public-DraftStyleDefault-listRTL__3aocB:before{position:absolute;right:-36px;text-align:left;width:30px}.index_public-DraftStyleDefault-orderedListItem__7JV9o:before{content:counter(a) \". \";counter-increment:a}.index_public-DraftStyleDefault-orderedListItem__7JV9o.index_public-DraftStyleDefault-depth1__2qvXA:before{content:counter(b) \". \";counter-increment:b}.index_public-DraftStyleDefault-orderedListItem__7JV9o.index_public-DraftStyleDefault-depth2__eQTbg:before{content:counter(c) \". \";counter-increment:c}.index_public-DraftStyleDefault-orderedListItem__7JV9o.index_public-DraftStyleDefault-depth3__1Lulo:before{content:counter(d) \". \";counter-increment:d}.index_public-DraftStyleDefault-orderedListItem__7JV9o.index_public-DraftStyleDefault-depth4__wdX4S:before{content:counter(e) \". \";counter-increment:e}.index_public-DraftStyleDefault-depth0__3A7Cc.index_public-DraftStyleDefault-reset__8e5iQ{counter-reset:a}.index_public-DraftStyleDefault-depth1__2qvXA.index_public-DraftStyleDefault-reset__8e5iQ{counter-reset:b}.index_public-DraftStyleDefault-depth2__eQTbg.index_public-DraftStyleDefault-reset__8e5iQ{counter-reset:c}.index_public-DraftStyleDefault-depth3__1Lulo.index_public-DraftStyleDefault-reset__8e5iQ{counter-reset:d}.index_public-DraftStyleDefault-depth4__wdX4S.index_public-DraftStyleDefault-reset__8e5iQ{counter-reset:e}.index_bf-switch__5k7Z0{position:relative;width:32px;height:16px;background-color:hsla(0,0%,100%,.15);border-radius:8px;transition:background .3s}.index_bf-switch__5k7Z0.index_active__-pMJD{background-color:#3498db}.index_bf-switch__5k7Z0.index_active__-pMJD:before{left:16px}.index_bf-switch__5k7Z0: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__pDnZN [class*=\" bfi-\"],.index_bf-container__pDnZN [class^=bfi-],.index_bf-modal-root__1vZsk [class*=\" bfi-\"],.index_bf-modal-root__1vZsk [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__pDnZN .index_bfi-table__2n-Nu:before,.index_bf-modal-root__1vZsk .index_bfi-table__2n-Nu:before{content:\"\\E228\"}.index_bf-container__pDnZN .index_bfi-clear_all__1DWPd:before,.index_bf-modal-root__1vZsk .index_bfi-clear_all__1DWPd:before{content:\"\\E0B8\"}.index_bf-container__pDnZN .index_bfi-format_clear__18bKu:before,.index_bf-modal-root__1vZsk .index_bfi-format_clear__18bKu:before{content:\"\\E239\"}.index_bf-container__pDnZN .index_bfi-hr__3Dyol:before,.index_bf-modal-root__1vZsk .index_bfi-hr__3Dyol:before{content:\"\\E925\"}.index_bf-container__pDnZN .index_bfi-colorize__3kvdJ:before,.index_bf-modal-root__1vZsk .index_bfi-colorize__3kvdJ:before{content:\"\\E3B8\"}.index_bf-container__pDnZN .index_bfi-crop_free___WShj:before,.index_bf-modal-root__1vZsk .index_bfi-crop_free___WShj:before{content:\"\\E3C2\"}.index_bf-container__pDnZN .index_bfi-pause__1yVdD:before,.index_bf-modal-root__1vZsk .index_bfi-pause__1yVdD:before{content:\"\\E034\"}.index_bf-container__pDnZN .index_bfi-play_arrow__TAu2k:before,.index_bf-modal-root__1vZsk .index_bfi-play_arrow__TAu2k:before{content:\"\\E037\"}.index_bf-container__pDnZN .index_bfi-bin__1RNIO:before,.index_bf-modal-root__1vZsk .index_bfi-bin__1RNIO:before{content:\"\\E9AC\"}.index_bf-container__pDnZN .index_bfi-replay__a2eQS:before,.index_bf-modal-root__1vZsk .index_bfi-replay__a2eQS:before{content:\"\\E042\"}.index_bf-container__pDnZN .index_bfi-tune__3djXd:before,.index_bf-modal-root__1vZsk .index_bfi-tune__3djXd:before{content:\"\\E429\"}.index_bf-container__pDnZN .index_bfi-close__3nM0K:before,.index_bf-modal-root__1vZsk .index_bfi-close__3nM0K:before{content:\"\\E913\"}.index_bf-container__pDnZN .index_bfi-align-center__32OAW:before,.index_bf-modal-root__1vZsk .index_bfi-align-center__32OAW:before{content:\"\\E028\"}.index_bf-container__pDnZN .index_bfi-align-justify__28esT:before,.index_bf-modal-root__1vZsk .index_bfi-align-justify__28esT:before{content:\"\\E026\"}.index_bf-container__pDnZN .index_bfi-align-left__1xURH:before,.index_bf-modal-root__1vZsk .index_bfi-align-left__1xURH:before{content:\"\\E027\"}.index_bf-container__pDnZN .index_bfi-align-right__dTKZi:before,.index_bf-modal-root__1vZsk .index_bfi-align-right__dTKZi:before{content:\"\\E029\"}.index_bf-container__pDnZN .index_bfi-image-right__dC3pp:before,.index_bf-modal-root__1vZsk .index_bfi-image-right__dC3pp:before{content:\"\\E914\"}.index_bf-container__pDnZN .index_bfi-image-left__1RS1z:before,.index_bf-modal-root__1vZsk .index_bfi-image-left__1RS1z:before{content:\"\\E91E\"}.index_bf-container__pDnZN .index_bfi-music__1icOF:before,.index_bf-modal-root__1vZsk .index_bfi-music__1icOF:before{content:\"\\E90E\"}.index_bf-container__pDnZN .index_bfi-camera__1iPe1:before,.index_bf-modal-root__1vZsk .index_bfi-camera__1iPe1:before{content:\"\\E911\"}.index_bf-container__pDnZN .index_bfi-copy__2zFg6:before,.index_bf-modal-root__1vZsk .index_bfi-copy__2zFg6:before{content:\"\\E92C\"}.index_bf-container__pDnZN .index_bfi-file-text__3mXsh:before,.index_bf-modal-root__1vZsk .index_bfi-file-text__3mXsh:before{content:\"\\E926\"}.index_bf-container__pDnZN .index_bfi-film__2iCvn:before,.index_bf-modal-root__1vZsk .index_bfi-film__2iCvn:before{content:\"\\E91C\"}.index_bf-container__pDnZN .index_bfi-github__brZ94:before,.index_bf-modal-root__1vZsk .index_bfi-github__brZ94:before{content:\"\\EAB0\"}.index_bf-container__pDnZN .index_bfi-ltr__27xC4:before,.index_bf-modal-root__1vZsk .index_bfi-ltr__27xC4:before{content:\"\\EA74\"}.index_bf-container__pDnZN .index_bfi-page-break__4-FKT:before,.index_bf-modal-root__1vZsk .index_bfi-page-break__4-FKT:before{content:\"\\EA68\"}.index_bf-container__pDnZN .index_bfi-pagebreak__1BIxj:before,.index_bf-modal-root__1vZsk .index_bfi-pagebreak__1BIxj:before{content:\"\\EA6E\"}.index_bf-container__pDnZN .index_bfi-paint-format__3Eyz1:before,.index_bf-modal-root__1vZsk .index_bfi-paint-format__3Eyz1:before{content:\"\\E90C\"}.index_bf-container__pDnZN .index_bfi-paste__2D7ES:before,.index_bf-modal-root__1vZsk .index_bfi-paste__2D7ES:before{content:\"\\E92D\"}.index_bf-container__pDnZN .index_bfi-pilcrow__1hD8x:before,.index_bf-modal-root__1vZsk .index_bfi-pilcrow__1hD8x:before{content:\"\\EA73\"}.index_bf-container__pDnZN .index_bfi-pushpin__ddOjX:before,.index_bf-modal-root__1vZsk .index_bfi-pushpin__ddOjX:before{content:\"\\E946\"}.index_bf-container__pDnZN .index_bfi-redo__1zMS1:before,.index_bf-modal-root__1vZsk .index_bfi-redo__1zMS1:before{content:\"\\E968\"}.index_bf-container__pDnZN .index_bfi-rtl__WVUh3:before,.index_bf-modal-root__1vZsk .index_bfi-rtl__WVUh3:before{content:\"\\EA75\"}.index_bf-container__pDnZN .index_bfi-spinner__zgwYo:before,.index_bf-modal-root__1vZsk .index_bfi-spinner__zgwYo:before{content:\"\\E980\"}.index_bf-container__pDnZN .index_bfi-subscript__2lvcn:before,.index_bf-modal-root__1vZsk .index_bfi-subscript__2lvcn:before{content:\"\\EA6C\"}.index_bf-container__pDnZN .index_bfi-superscript__39qvB:before,.index_bf-modal-root__1vZsk .index_bfi-superscript__39qvB:before{content:\"\\EA6B\"}.index_bf-container__pDnZN .index_bfi-undo__1uH1l:before,.index_bf-modal-root__1vZsk .index_bfi-undo__1uH1l:before{content:\"\\E967\"}.index_bf-container__pDnZN .index_bfi-media__1X3ie:before,.index_bf-modal-root__1vZsk .index_bfi-media__1X3ie:before{content:\"\\E90F\"}.index_bf-container__pDnZN .index_bfi-add__Senjb:before,.index_bf-modal-root__1vZsk .index_bfi-add__Senjb:before{content:\"\\E918\"}.index_bf-container__pDnZN .index_bfi-bold__3XBUf:before,.index_bf-modal-root__1vZsk .index_bfi-bold__3XBUf:before{content:\"\\E904\"}.index_bf-container__pDnZN .index_bfi-code__2_u8T:before,.index_bf-modal-root__1vZsk .index_bfi-code__2_u8T:before{content:\"\\E903\"}.index_bf-container__pDnZN .index_bfi-done__2SBW5:before,.index_bf-modal-root__1vZsk .index_bfi-done__2SBW5:before{content:\"\\E912\"}.index_bf-container__pDnZN .index_bfi-drop-down__hwaaA:before,.index_bf-modal-root__1vZsk .index_bfi-drop-down__hwaaA:before{content:\"\\E906\"}.index_bf-container__pDnZN .index_bfi-drop-up__30tNg:before,.index_bf-modal-root__1vZsk .index_bfi-drop-up__30tNg:before{content:\"\\E909\"}.index_bf-container__pDnZN .index_bfi-emoji__1kiSF:before,.index_bf-modal-root__1vZsk .index_bfi-emoji__1kiSF:before{content:\"\\E91B\"}.index_bf-container__pDnZN .index_bfi-font-size__3Ze0F:before,.index_bf-modal-root__1vZsk .index_bfi-font-size__3Ze0F:before{content:\"\\E920\"}.index_bf-container__pDnZN .index_bfi-fullscreen__rXrOP:before,.index_bf-modal-root__1vZsk .index_bfi-fullscreen__rXrOP:before{content:\"\\E910\"}.index_bf-container__pDnZN .index_bfi-fullscreen-exit__3Mqrf:before,.index_bf-modal-root__1vZsk .index_bfi-fullscreen-exit__3Mqrf:before{content:\"\\E90D\"}.index_bf-container__pDnZN .index_bfi-help__fDlhJ:before,.index_bf-modal-root__1vZsk .index_bfi-help__fDlhJ:before{content:\"\\E902\"}.index_bf-container__pDnZN .index_bfi-indent-decrease__CiP-9:before,.index_bf-modal-root__1vZsk .index_bfi-indent-decrease__CiP-9:before{content:\"\\E92F\"}.index_bf-container__pDnZN .index_bfi-indent-increase__ri4Fd:before,.index_bf-modal-root__1vZsk .index_bfi-indent-increase__ri4Fd:before{content:\"\\E92E\"}.index_bf-container__pDnZN .index_bfi-info__1Yirj:before,.index_bf-modal-root__1vZsk .index_bfi-info__1Yirj:before{content:\"\\E901\"}.index_bf-container__pDnZN .index_bfi-italic__pSD0Q:before,.index_bf-modal-root__1vZsk .index_bfi-italic__pSD0Q:before{content:\"\\E924\"}.index_bf-container__pDnZN .index_bfi-link__1G6mh:before,.index_bf-modal-root__1vZsk .index_bfi-link__1G6mh:before{content:\"\\E91A\"}.index_bf-container__pDnZN .index_bfi-link-off__3BJ9G:before,.index_bf-modal-root__1vZsk .index_bfi-link-off__3BJ9G:before{content:\"\\E919\"}.index_bf-container__pDnZN .index_bfi-list__34DiG:before,.index_bf-modal-root__1vZsk .index_bfi-list__34DiG:before{content:\"\\E923\"}.index_bf-container__pDnZN .index_bfi-list-numbered__1smmd:before,.index_bf-modal-root__1vZsk .index_bfi-list-numbered__1smmd:before{content:\"\\E922\"}.index_bf-container__pDnZN .index_bfi-menu__1NUnm:before,.index_bf-modal-root__1vZsk .index_bfi-menu__1NUnm:before{content:\"\\E908\"}.index_bf-container__pDnZN .index_bfi-more-horiz__44PbX:before,.index_bf-modal-root__1vZsk .index_bfi-more-horiz__44PbX:before{content:\"\\E90B\"}.index_bf-container__pDnZN .index_bfi-more-vert__hz05g:before,.index_bf-modal-root__1vZsk .index_bfi-more-vert__hz05g:before{content:\"\\E90A\"}.index_bf-container__pDnZN .index_bfi-not-disturb__2T4dR:before,.index_bf-modal-root__1vZsk .index_bfi-not-disturb__2T4dR:before{content:\"\\E907\"}.index_bf-container__pDnZN .index_bfi-print__16wCn:before,.index_bf-modal-root__1vZsk .index_bfi-print__16wCn:before{content:\"\\E915\"}.index_bf-container__pDnZN .index_bfi-quote__3DFSY:before,.index_bf-modal-root__1vZsk .index_bfi-quote__3DFSY:before{content:\"\\E921\"}.index_bf-container__pDnZN .index_bfi-search__2ZXmI:before,.index_bf-modal-root__1vZsk .index_bfi-search__2ZXmI:before{content:\"\\E916\"}.index_bf-container__pDnZN .index_bfi-settingsx__B0nTj:before,.index_bf-modal-root__1vZsk .index_bfi-settingsx__B0nTj:before{content:\"\\E917\"}.index_bf-container__pDnZN .index_bfi-share__1YW3x:before,.index_bf-modal-root__1vZsk .index_bfi-share__1YW3x:before{content:\"\\E905\"}.index_bf-container__pDnZN .index_bfi-share-square__1WnYO:before,.index_bf-modal-root__1vZsk .index_bfi-share-square__1WnYO:before{content:\"\\E900\"}.index_bf-container__pDnZN .index_bfi-strikethrough__2PgId:before,.index_bf-modal-root__1vZsk .index_bfi-strikethrough__2PgId:before{content:\"\\E91F\"}.index_bf-container__pDnZN .index_bfi-text-color__1O4Kp .index_path1__1A5aH:before,.index_bf-modal-root__1vZsk .index_bfi-text-color__1O4Kp .index_path1__1A5aH:before{font-family:braft-icons!important;content:\"\\E930\";opacity:.36}.index_bf-container__pDnZN .index_bfi-text-color__1O4Kp .index_path2__2v3Cp:before,.index_bf-modal-root__1vZsk .index_bfi-text-color__1O4Kp .index_path2__2v3Cp:before{font-family:braft-icons!important;content:\"\\E931\";margin-left:-1em}.index_bf-container__pDnZN .index_bfi-underlined__3WKo2:before,.index_bf-modal-root__1vZsk .index_bfi-underlined__3WKo2:before{content:\"\\E91D\"}.index_bf-content__216XJ{height:500px;padding-bottom:10px;overflow:auto;font-size:16px}.index_bf-content__216XJ img{-webkit-user-select:none;user-select:none}.index_bf-content__216XJ *{line-height:normal}.index_bf-container__pDnZN{position:relative;height:100%;padding:0}.index_bf-container__pDnZN.index_disabled__QRqWr{pointer-events:none;opacity:.7;filter:grayscale(70%)}.index_bf-container__pDnZN.index_read-only__1ud0X .index_bf-controlbar__3CCYm{pointer-events:none}.index_bf-container__pDnZN.index_read-only__1ud0X .index_bf-image__1aolB img:hover{outline:none}.index_bf-container__pDnZN.index_read-only__1ud0X .index_bf-hr__1U3wo{pointer-events:none}.index_bf-container__pDnZN.index_fullscreen__2ZKS5{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__pDnZN.index_fullscreen__2ZKS5 .index_bf-content__216XJ{flex-grow:1;height:auto}.index_bf-container__pDnZN .index_input-group__3B65V{display:block}.index_bf-container__pDnZN .index_input-group__3B65V input{box-sizing:border-box;width:100%;height:36px;padding:0 15px;font-size:14px}.index_bf-container__pDnZN .index_pull-left__3uitd{float:left}.index_bf-container__pDnZN .index_pull-right__3l3V5{float:right}.index_bf-container__pDnZN button{line-height:normal}.index_bf-container__pDnZN button.index_default__dCgOD,.index_bf-container__pDnZN button.index_ghost__22h6J,.index_bf-container__pDnZN button.index_primary__2l-C6{height:32px;padding:0 20px;color:#fff;font-size:12px}.index_bf-container__pDnZN button.index_default__dCgOD{background-color:hsla(0,0%,100%,.15);border:none}.index_bf-container__pDnZN button.index_default__dCgOD:hover{background-color:hsla(0,0%,100%,.1)}.index_bf-container__pDnZN button.index_ghost__22h6J{background-color:transparent;border:none;box-shadow:inset 0 0 0 .5px hsla(0,0%,100%,.5)}.index_bf-container__pDnZN button.index_ghost__22h6J:hover{box-shadow:inset 0 0 0 .5px hsla(0,0%,100%,.7)}.index_bf-container__pDnZN button.index_primary__2l-C6{background-color:#3498db;border:none;color:#fff}.index_bf-container__pDnZN button.index_primary__2l-C6:hover{background-color:#2084c7}.index_bf-container__pDnZN .index_public-DraftEditorPlaceholder-root__q1VIv{top:15px;left:15px;font-size:16px;pointer-events:none}.index_bf-container__pDnZN .index_DraftEditor-editorContainer__2JNtE{box-sizing:border-box;border:none}.index_bf-container__pDnZN .index_DraftEditor-root__1ecF2,.index_bf-container__pDnZN .index_public-DraftEditor-content__24kl-{height:100%}.index_bf-container__pDnZN .index_public-DraftEditor-content__24kl-{box-sizing:border-box;padding:15px;word-wrap:break-word;word-break:break-all}.index_bf-container__pDnZN .index_public-DraftEditor-content__24kl->div{padding-bottom:20px}.index_bf-container__pDnZN .index_public-DraftEditor-content__24kl- .index_braft-link__3aKL8{color:#4078c0}.index_bf-container__pDnZN .index_public-DraftEditor-content__24kl- blockquote{margin:0 0 10px;padding:15px 20px;background-color:#f1f2f3;border-left:5px solid #ccc;color:#666;font-style:italic}.index_bf-container__pDnZN .index_public-DraftEditor-content__24kl- 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__pDnZN .index_public-DraftEditor-content__24kl- pre pre{margin:0;padding:0}.index_bf-container__pDnZN .index_bfa-left__3-1T_,.index_bf-container__pDnZN .index_bfa-left__3-1T_ .index_public-DraftStyleDefault-ltr__3nF5D{text-align:left}.index_bf-container__pDnZN .index_bfa-right__VstO0,.index_bf-container__pDnZN .index_bfa-right__VstO0 .index_public-DraftStyleDefault-ltr__3nF5D{text-align:right}.index_bf-container__pDnZN .index_bfa-center__1Gy81,.index_bf-container__pDnZN .index_bfa-center__1Gy81 .index_public-DraftStyleDefault-ltr__3nF5D{text-align:center}.index_bf-container__pDnZN .index_bfa-justify__TPlSj,.index_bf-container__pDnZN .index_bfa-justify__TPlSj .index_public-DraftStyleDefault-ltr__3nF5D{text-align:justify}.index_bf-container__pDnZN .index_bfa-center__1Gy81>div,.index_bf-container__pDnZN .index_bfa-justify__TPlSj>div,.index_bf-container__pDnZN .index_bfa-left__3-1T_>div,.index_bf-container__pDnZN .index_bfa-right__VstO0>div{display:inline-block}.index_bf-container__pDnZN .index_bff-left__3vDOo:hover,.index_bf-container__pDnZN .index_bff-right__3X5rQ:hover{z-index:2}.index_bf-container__pDnZN .index_bff-left__3vDOo{position:relative;z-index:1;float:left;margin:0 10px 0 0}.index_bf-container__pDnZN .index_bff-right__3X5rQ{position:relative;z-index:1;float:right;margin:0 0 0 10px}.index_bf-container__pDnZN .index_bftd-1__15-5d{text-indent:2em;display:initial}.index_bf-container__pDnZN .index_bftd-2__1JQXC{text-indent:4em;display:initial}.index_bf-container__pDnZN .index_bftd-3__3gI7R{text-indent:6em;display:initial}.index_bf-container__pDnZN .index_bftd-4__2mnyV{text-indent:8em;display:initial}.index_bf-container__pDnZN .index_bftd-5__2dFUN{text-indent:10em;display:initial}.index_bf-container__pDnZN .index_bftd-6__DN8IU{text-indent:12em;display:initial}.index_bf-container__pDnZN .index_bf-image__1aolB,.index_bf-container__pDnZN .index_bf-media__1enRX{position:relative}.index_bf-container__pDnZN .index_bf-image__1aolB img{display:block;max-width:100%;font-size:0;resize:both;outline-offset:1px}.index_bf-container__pDnZN .index_bf-image__1aolB img:hover{outline:1px solid #3498db}.index_bf-container__pDnZN .index_bf-media-toolbar__2V9Pp{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__pDnZN .index_bf-media-toolbar__2V9Pp .index_bf-media-toolbar-arrow__wQs6N,.index_bf-container__pDnZN .index_bf-media-toolbar__2V9Pp:before{position:absolute;bottom:-10px;left:50%;display:block;border:5px solid transparent;border-top-color:#21242a;content:\"\";transform:translateX(-5px)}.index_bf-container__pDnZN .index_bf-media-toolbar__2V9Pp 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__pDnZN .index_bf-media-toolbar__2V9Pp a:hover{color:#fff}.index_bf-container__pDnZN .index_bf-media-toolbar__2V9Pp a:first-child{border-radius:2px 0 0 2px}.index_bf-container__pDnZN .index_bf-media-toolbar__2V9Pp a:last-child{border-radius:0 2px 2px 0}.index_bf-container__pDnZN .index_bf-media-toolbar__2V9Pp a.index_active__-pMJD{color:#3498db}.index_bf-video-player__ShN8m video{display:block;width:640px;max-width:80vw;height:auto;margin:0 10px 10px;object-fit:contain}.index_bf-audio-player__1Lhv8 audio{width:480px;max-width:80vw;margin:0 10px 10px}.index_bf-player-holder__1jMDw{position:relative;height:240px;overflow:hidden;background-color:#21242a;border-radius:3px}.index_bf-player-holder__1jMDw .index_icon-badge__3vdSq{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__1jMDw .index_icon-badge__3vdSq i,.index_bf-player-holder__1jMDw .index_icon-badge__3vdSq span{display:block;float:left;line-height:30px}.index_bf-player-holder__1jMDw .index_icon-badge__3vdSq span{margin-left:5px;font-size:12px}.index_bf-player-holder__1jMDw .index_button-remove__3gFzp{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__1jMDw .index_button-remove__3gFzp:hover{color:#e74c3c}.index_bf-player-holder__1jMDw .index_button-play__1DEoA{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__1jMDw .index_button-play__1DEoA:hover{background-color:#3498db}.index_bf-player-holder__1jMDw .index_bf-name__45BKL{position:relative;z-index:2;margin:0;color:#fff;font-size:14px;font-weight:500;text-align:center}.index_bf-player-holder__1jMDw .index_bf-url__8vnVl{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__1jMDw .index_bf-poster__2mGu4{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__1v7vJ{position:fixed;z-index:99999;top:0;left:0;width:100%;height:100%}.index_bf-modal__1v7vJ button{outline:none}.index_bf-modal-mask__17u3f{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__1NJ2r{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__1_5Y9{height:50px}.index_bf-modal-caption__3Iajr{float:left;margin:0;padding:0 15px;color:#999;font-size:14px;font-weight:400;line-height:50px}.index_bf-modal-close-button__1-IHh{float:right;width:50px;height:50px;background-color:transparent;border:none;color:#ccc;font-size:18px;cursor:pointer}.index_bf-modal-close-button__1-IHh:hover{color:#e74c3c}.index_bf-modal-body__1WIdL{overflow:auto}.index_bf-modal-footer__L6ZDV{min-height:15px;padding:0 15px;overflow:hidden}.index_bf-modal-addon-text__1Ovsi{float:left;color:#999;font-size:12px;line-height:60px}.index_bf-modal-buttons__1oq66{float:right}.index_bf-modal-cancel__2rR_W,.index_bf-modal-confirm__1wWIW{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__2rR_W{background-color:#e8e9ea;color:#999}.index_bf-modal-cancel__2rR_W:hover{background-color:#d8d9da}.index_bf-modal-confirm__1wWIW{background-color:#3498db;color:#fff}.index_bf-modal-confirm__1wWIW:hover{background-color:#2084c7}.index_bf-modal-confirm__1wWIW.index_disabled__QRqWr{opacity:.3;pointer-events:none;filter:grayscale(.4)}.index_bf-modal-root__1vZsk.index_active__-pMJD .index_bf-modal-mask__17u3f{opacity:1}.index_bf-modal-root__1vZsk.index_active__-pMJD .index_bf-modal-content__1NJ2r{opacity:1;transform:translate(-50%,-50%)}.index_bf-content__216XJ .index_bf-hr__1U3wo{position:relative;box-sizing:content-box;height:15px;padding-top:15px;text-align:center}.index_bf-content__216XJ .index_bf-hr__1U3wo:before{display:block;height:1px;background-color:rgba(0,0,0,.1);content:\"\"}.index_bf-content__216XJ .index_bf-hr__1U3wo:hover:before{background-color:rgba(0,0,0,.3)}.index_bf-content__216XJ .index_bf-hr__1U3wo:hover .index_bf-media-toolbar__2V9Pp{display:block}.index_bf-content__216XJ .index_bf-hr__1U3wo .index_bf-media-toolbar__2V9Pp{display:none}.index_bf-image-link-editor__1bXBJ,.index_bf-image-size-editor__1FDp7{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__1bXBJ .index_editor-input-group__3JCRG,.index_bf-image-size-editor__1FDp7 .index_editor-input-group__3JCRG{width:300px;margin:8px 10px;overflow:hidden}.index_bf-image-link-editor__1bXBJ input,.index_bf-image-size-editor__1FDp7 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__1bXBJ input:hover,.index_bf-image-size-editor__1FDp7 input:hover{box-shadow:inset 0 0 0 1px rgba(52,152,219,.5)}.index_bf-image-link-editor__1bXBJ input:focus,.index_bf-image-size-editor__1FDp7 input:focus{box-shadow:inset 0 0 0 1px #3498db}.index_bf-image-link-editor__1bXBJ button,.index_bf-image-size-editor__1FDp7 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__1bXBJ button:hover,.index_bf-image-size-editor__1FDp7 button:hover{background-color:#2084c7}.index_bf-image-size-editor__1FDp7 input{width:80px}.index_bf-image-link-editor__1bXBJ input{width:185px}.index_bf-image-link-editor__1bXBJ .index_switch-group__3EJZe{height:16px;margin:10px}.index_bf-image-link-editor__1bXBJ .index_switch-group__3EJZe .index_bf-switch__5k7Z0{float:left}.index_bf-image-link-editor__1bXBJ .index_switch-group__3EJZe label{float:left;margin-left:15px;color:#999;font-size:12px;line-height:16px}.index_bf-content__216XJ .index_bf-image__1aolB{position:relative}.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-csize-icon__hs23I{position:absolute;z-index:2;width:10px;height:10px;background-color:rgba(52,152,219,.3)}.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-csize-icon__hs23I.index_right-bottom__1m3h4{right:0;bottom:0;cursor:se-resize}.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-csize-icon__hs23I.index_left-bottom__3H_hO{left:0;bottom:0;cursor:sw-resize}.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-pre-csize__26hDk{position:absolute;z-index:1;background:transparent}.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-pre-csize__26hDk.index_rightbottom__12aca{left:0;top:0;border:1px dashed #00bfff}.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-pre-csize__26hDk.index_leftbottom__1mn5L{right:0;top:0;border:1px dashed #00bfff}.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-media-toolbar__2V9Pp:before{visibility:hidden}.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-media-toolbar__2V9Pp[data-align=center] [data-align=center],.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-media-toolbar__2V9Pp[data-align=left] [data-align=left],.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-media-toolbar__2V9Pp[data-align=right] [data-align=right],.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-media-toolbar__2V9Pp[data-float=left] [data-float=left],.index_bf-content__216XJ .index_bf-image__1aolB .index_bf-media-toolbar__2V9Pp[data-float=right] [data-float=right]{color:#3498db}.index_headings-dropdown__3zS22{min-width:110px}.index_headings-dropdown__3zS22 .index_menu__369Um{width:200px;overflow:hidden}.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal{padding:15px 20px;text-align:left;line-height:normal}.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h1,.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h2,.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h3,.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h4,.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h5,.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h6{margin:0;padding:0;color:inherit}.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h1{font-size:28px}.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h2{font-size:24px}.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h3{font-size:20px}.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h4{font-size:16px}.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h5{font-size:14px}.index_headings-dropdown__3zS22 .index_menu__369Um .index_menu-item__3Ybal h6{font-size:12px}.index_bf-link-editor__fEYeX{width:360px;padding-top:25px}.index_bf-link-editor__fEYeX .index_input-group__3B65V{margin:0 15px 8px}.index_bf-link-editor__fEYeX .index_input-group__3B65V 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__fEYeX .index_input-group__3B65V input:hover{box-shadow:inset 0 0 0 1px rgba(52,152,219,.5)}.index_bf-link-editor__fEYeX .index_input-group__3B65V input:focus{box-shadow:inset 0 0 0 1px #3498db}.index_bf-link-editor__fEYeX .index_input-group__3B65V input:disabled{color:hsla(0,0%,100%,.7);box-shadow:none}.index_bf-link-editor__fEYeX .index_switch-group__3EJZe{height:16px;margin:15px}.index_bf-link-editor__fEYeX .index_switch-group__3EJZe .index_bf-switch__5k7Z0{float:left}.index_bf-link-editor__fEYeX .index_switch-group__3EJZe label{float:left;margin-left:15px;color:#999;font-size:12px;line-height:16px}.index_bf-link-editor__fEYeX .index_buttons__14sII{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__fEYeX .index_buttons__14sII .index_button-remove-link__2g1bP{color:#999;font-size:12px;line-height:32px;cursor:pointer}.index_bf-link-editor__fEYeX .index_buttons__14sII .index_button-remove-link__2g1bP:hover{color:#e74c3c}.index_bf-link-editor__fEYeX .index_buttons__14sII .index_button-remove-link__2g1bP i{margin-right:5px;font-size:16px}.index_bf-link-editor__fEYeX .index_buttons__14sII .index_button-remove-link__2g1bP i,.index_bf-link-editor__fEYeX .index_buttons__14sII .index_button-remove-link__2g1bP span{display:block;float:left;line-height:32px}.index_bf-link-editor__fEYeX .index_buttons__14sII button{margin-left:10px;border-radius:2px;font-weight:700;cursor:pointer}.index_bf-dropdown__oN6FC{position:relative;width:auto;height:36px;margin:0}.index_bf-dropdown__oN6FC.index_disabled__QRqWr{pointer-events:none;opacity:.3}.index_bf-dropdown__oN6FC.index_light-theme__3jxMV .index_dropdown-content__2MgGm{border:1px solid #ccc}.index_bf-dropdown__oN6FC.index_light-theme__3jxMV .index_dropdown-content__2MgGm .index_dropdown-arrow__1VDfJ{background-color:#fff;border:1px solid #ccc}.index_bf-dropdown__oN6FC.index_light-theme__3jxMV .index_dropdown-content__2MgGm .index_dropdown-content-inner__1Norc{background-color:#fff}.index_bf-dropdown__oN6FC .index_dropdown-content__2MgGm{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__oN6FC .index_dropdown-content__2MgGm ::-webkit-scrollbar-track{background-color:transparent}.index_bf-dropdown__oN6FC .index_dropdown-content__2MgGm ::-webkit-scrollbar{width:4px;background-color:transparent;border-radius:2px}.index_bf-dropdown__oN6FC .index_dropdown-content__2MgGm ::-webkit-scrollbar-thumb{background-color:hsla(0,0%,100%,.3);border-radius:2px}.index_bf-dropdown__oN6FC .index_dropdown-content__2MgGm .index_dropdown-arrow__1VDfJ{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__oN6FC .index_dropdown-content__2MgGm .index_dropdown-arrow__1VDfJ.index_active__-pMJD{background-color:#3498db}.index_bf-dropdown__oN6FC .index_dropdown-content__2MgGm .index_menu__369Um{list-style:none;margin:0;padding:0;overflow:hidden;border-radius:2px}.index_bf-dropdown__oN6FC .index_dropdown-content__2MgGm .index_menu-item__3Ybal{display:block;list-style:none;margin:0;font-size:16px;cursor:pointer}.index_bf-dropdown__oN6FC .index_dropdown-content__2MgGm .index_menu-item__3Ybal:hover{background-color:rgba(0,0,0,.1)}.index_bf-dropdown__oN6FC .index_dropdown-content__2MgGm .index_menu-item__3Ybal.index_active__-pMJD{background-color:#3498db;color:#fff}.index_bf-dropdown__oN6FC .index_dropdown-content__2MgGm .index_menu-item__3Ybal:not(.index_active__-pMJD){color:hsla(0,0%,100%,.6);box-shadow:inset 0 -1px 0 0 hsla(0,0%,100%,.1)}.index_bf-dropdown__oN6FC .index_dropdown-content-inner__1Norc{position:relative;z-index:2;overflow:auto;background-color:#21242a;border-radius:2px}.index_bf-dropdown__oN6FC .index_dropdown-handler__MTW22{position:relative;display:block;width:100%;height:36px;background-color:transparent;border:none;color:#6a6f7b;cursor:pointer}.index_bf-dropdown__oN6FC .index_dropdown-handler__MTW22:hover{background-color:rgba(0,0,0,.05)}.index_bf-dropdown__oN6FC .index_dropdown-handler__MTW22 *{display:inline;padding:0;font-size:inherit;font-weight:400}.index_bf-dropdown__oN6FC .index_dropdown-handler__MTW22>span{float:left;padding:0 10px;font-size:14px;line-height:36px;pointer-events:none}.index_bf-dropdown__oN6FC .index_dropdown-handler__MTW22>span i{display:block;height:36px;font-size:16px;line-height:36px;text-align:center}.index_bf-dropdown__oN6FC .index_dropdown-handler__MTW22 .index_bfi-drop-down__hwaaA{float:right;width:30px;height:36px;font-size:16px;line-height:36px;text-align:center;pointer-events:none}.index_bf-dropdown__oN6FC.index_active__-pMJD .index_dropdown-handler__MTW22{background-color:rgba(0,0,0,.05)}.index_bf-dropdown__oN6FC.index_active__-pMJD .index_dropdown-content__2MgGm{visibility:visible;opacity:1;transform:translate(-50%)}.index_text-color-dropdown__MG26p.index_light-theme__3jxMV .index_bf-color-switch-buttons__PLYUW button{border-bottom:1px solid #ccc;color:#616569}.index_text-color-dropdown__MG26p.index_light-theme__3jxMV .index_bf-color-switch-buttons__PLYUW button.index_active__-pMJD{border-bottom-color:#3498db;color:#3498db}.index_text-color-dropdown__MG26p button.index_dropdown-handler__MTW22 span{width:36px;padding:0;overflow:hidden;border-radius:2px}.index_text-color-dropdown__MG26p .index_bf-text-color-picker-wrap__3BVM3{overflow:hidden}.index_text-color-dropdown__MG26p .index_bf-color-switch-buttons__PLYUW{height:36px}.index_text-color-dropdown__MG26p .index_bf-color-switch-buttons__PLYUW 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__MG26p .index_bf-color-switch-buttons__PLYUW button.index_active__-pMJD{border-bottom-color:#3498db;color:#3498db}.index_bf-colors__3herU{box-sizing:content-box;list-style:none;width:240px;margin:0;padding:15px;overflow:hidden}.index_bf-colors__3herU 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__3herU li:hover{transform:scale(1.3)}.index_bf-colors__3herU li.index_active__-pMJD{box-shadow:0 0 0 2px #3498db}.index_bf-font-size-dropdown__2e1Ks{min-width:95px}.index_bf-font-sizes__7rSPu{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-font-sizes__7rSPu 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__7rSPu li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-font-sizes__7rSPu li.index_active__-pMJD{background-color:#3498db}.index_font-family-dropdown__3I8Gd{min-width:120px}.index_font-family-dropdown__3I8Gd .index_dropdown-content__2MgGm{width:180px}.index_font-family-dropdown__3I8Gd .index_menu-item__3Ybal{padding:12px 15px}.index_bf-line-height-dropdown__1-8zQ{min-width:95px}.index_bf-line-heights__1Db9U{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-line-heights__1Db9U 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__1Db9U li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-line-heights__1Db9U li.index_active__-pMJD{background-color:#3498db}.index_bf-letter-spacing-dropdown__POLhV{min-width:95px}.index_bf-letter-spacings__2k6yk{box-sizing:content-box;width:210px;list-style:none;margin:0;padding:5px;overflow:hidden}.index_bf-letter-spacings__2k6yk 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__2k6yk li:hover{background-color:hsla(0,0%,100%,.2)}.index_bf-letter-spacings__2k6yk li.index_active__-pMJD{background-color:#3498db}.index_bf-emojis-wrap__208kW{position:relative;width:210px;height:220px;overflow:hidden}.index_bf-emojis-wrap__208kW:after,.index_bf-emojis-wrap__208kW:before{position:absolute;z-index:1;right:0;left:0;height:30px;border-radius:2px;content:\"\";pointer-events:none}.index_bf-emojis-wrap__208kW:before{top:0;background-image:linear-gradient(0deg,rgba(33,36,42,0),#21242a)}.index_bf-emojis-wrap__208kW:after{bottom:0;background-image:linear-gradient(rgba(33,36,42,0),#21242a)}.index_bf-emojis__VNlnW{box-sizing:content-box;width:200px;height:195px;list-style:none;margin:0;padding:15px 15px 20px;overflow:auto}.index_bf-emojis__VNlnW 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__VNlnW li:hover{transform:scale(1.5)}";
  23778. styleInject_es.styleInject(css);
  23779. var css$1 = ".emoticon_braft-emoticon-picker__3fALT{box-sizing:border-box;width:210px;height:210px;overflow:hidden}.emoticon_braft-emoticon-picker__3fALT:after,.emoticon_braft-emoticon-picker__3fALT:before{position:absolute;z-index:1;right:0;left:0;height:30px;border-radius:2px;content:\"\";pointer-events:none}.emoticon_braft-emoticon-picker__3fALT:before{top:0;background-image:linear-gradient(0deg,rgba(33,36,42,0),#21242a)}.emoticon_braft-emoticon-picker__3fALT:after{bottom:0;background-image:linear-gradient(rgba(33,36,42,0),#21242a)}.emoticon_braft-emoticon-picker__3fALT .emoticon_braft-emoticons-list__1Wu0r{box-sizing:content-box;width:200px;height:190px;margin:0;padding:15px 15px 20px;overflow:auto}.emoticon_braft-emoticon-picker__3fALT .emoticon_braft-emoticons-list__1Wu0r img{display:block;box-sizing:content-box;float:left;width:20px;height:20px;margin:3px;padding:5px;border-radius:3px}.emoticon_braft-emoticon-picker__3fALT .emoticon_braft-emoticons-list__1Wu0r img:hover{background-color:#3498db}.emoticon_braft-emoticon-in-editor__1xLtg{position:relative;padding:0 2px;letter-spacing:12px}.emoticon_braft-emoticon-in-editor__1xLtg img{position:absolute;top:0;left:2px;width:16px;height:16px}";
  23780. styleInject_es.styleInject(css$1);
  23781. var emoticon = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  23782. (function webpackUniversalModuleDefinition(root, factory) {
  23783. module.exports = factory(React__default, dist$1);
  23784. })(window, function(__WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__6__) {
  23785. return /******/ (function(modules) { // webpackBootstrap
  23786. /******/ // The module cache
  23787. /******/ var installedModules = {};
  23788. /******/
  23789. /******/ // The require function
  23790. /******/ function __webpack_require__(moduleId) {
  23791. /******/
  23792. /******/ // Check if module is in cache
  23793. /******/ if(installedModules[moduleId]) {
  23794. /******/ return installedModules[moduleId].exports;
  23795. /******/ }
  23796. /******/ // Create a new module (and put it into the cache)
  23797. /******/ var module = installedModules[moduleId] = {
  23798. /******/ i: moduleId,
  23799. /******/ l: false,
  23800. /******/ exports: {}
  23801. /******/ };
  23802. /******/
  23803. /******/ // Execute the module function
  23804. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  23805. /******/
  23806. /******/ // Flag the module as loaded
  23807. /******/ module.l = true;
  23808. /******/
  23809. /******/ // Return the exports of the module
  23810. /******/ return module.exports;
  23811. /******/ }
  23812. /******/
  23813. /******/
  23814. /******/ // expose the modules object (__webpack_modules__)
  23815. /******/ __webpack_require__.m = modules;
  23816. /******/
  23817. /******/ // expose the module cache
  23818. /******/ __webpack_require__.c = installedModules;
  23819. /******/
  23820. /******/ // define getter function for harmony exports
  23821. /******/ __webpack_require__.d = function(exports, name, getter) {
  23822. /******/ if(!__webpack_require__.o(exports, name)) {
  23823. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  23824. /******/ }
  23825. /******/ };
  23826. /******/
  23827. /******/ // define __esModule on exports
  23828. /******/ __webpack_require__.r = function(exports) {
  23829. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  23830. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  23831. /******/ }
  23832. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  23833. /******/ };
  23834. /******/
  23835. /******/ // create a fake namespace object
  23836. /******/ // mode & 1: value is a module id, require it
  23837. /******/ // mode & 2: merge all properties of value into the ns
  23838. /******/ // mode & 4: return value when already ns object
  23839. /******/ // mode & 8|1: behave like require
  23840. /******/ __webpack_require__.t = function(value, mode) {
  23841. /******/ if(mode & 1) value = __webpack_require__(value);
  23842. /******/ if(mode & 8) return value;
  23843. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  23844. /******/ var ns = Object.create(null);
  23845. /******/ __webpack_require__.r(ns);
  23846. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  23847. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  23848. /******/ return ns;
  23849. /******/ };
  23850. /******/
  23851. /******/ // getDefaultExport function for compatibility with non-harmony modules
  23852. /******/ __webpack_require__.n = function(module) {
  23853. /******/ var getter = module && module.__esModule ?
  23854. /******/ function getDefault() { return module['default']; } :
  23855. /******/ function getModuleExports() { return module; };
  23856. /******/ __webpack_require__.d(getter, 'a', getter);
  23857. /******/ return getter;
  23858. /******/ };
  23859. /******/
  23860. /******/ // Object.prototype.hasOwnProperty.call
  23861. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  23862. /******/
  23863. /******/ // __webpack_public_path__
  23864. /******/ __webpack_require__.p = "/";
  23865. /******/
  23866. /******/
  23867. /******/ // Load entry module and return exports
  23868. /******/ return __webpack_require__(__webpack_require__.s = 33);
  23869. /******/ })
  23870. /************************************************************************/
  23871. /******/ ({
  23872. /***/ 1:
  23873. /***/ (function(module, exports) {
  23874. module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
  23875. /***/ }),
  23876. /***/ 2:
  23877. /***/ (function(module, exports) {
  23878. function _defineProperty(obj, key, value) {
  23879. if (key in obj) {
  23880. Object.defineProperty(obj, key, {
  23881. value: value,
  23882. enumerable: true,
  23883. configurable: true,
  23884. writable: true
  23885. });
  23886. } else {
  23887. obj[key] = value;
  23888. }
  23889. return obj;
  23890. }
  23891. module.exports = _defineProperty;
  23892. /***/ }),
  23893. /***/ 33:
  23894. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23895. __webpack_require__.r(__webpack_exports__);
  23896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultEmoticons", function() { return defaultEmoticons; });
  23897. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
  23898. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);
  23899. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
  23900. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  23901. /* harmony import */ var braft_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
  23902. /* harmony import */ var _styles_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(48);
  23903. // https://www.iconfinder.com/iconsets/emoji-18
  23904. 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) {
  23905. return "".concat(item, ".png");
  23906. });
  23907. var insertEmoticon = function insertEmoticon(editor, editorState, src) {
  23908. editor.setValue(braft_utils__WEBPACK_IMPORTED_MODULE_2__["ContentUtils"].insertText(editorState, ' ', null, {
  23909. type: 'EMOTICON',
  23910. mutability: 'IMMUTABLE',
  23911. data: {
  23912. src: src
  23913. }
  23914. }));
  23915. };
  23916. var controlRef = null;
  23917. var bindControlRef = function bindControlRef(ref) {
  23918. return controlRef = ref;
  23919. };
  23920. /* harmony default export */ __webpack_exports__["default"] = (function (options) {
  23921. options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({
  23922. emoticons: [],
  23923. closeOnSelect: false,
  23924. closeOnBlur: false
  23925. }, options);
  23926. var _options = options,
  23927. emoticons = _options.emoticons,
  23928. closeOnSelect = _options.closeOnSelect,
  23929. closeOnBlur = _options.closeOnBlur,
  23930. includeEditors = _options.includeEditors,
  23931. excludeEditors = _options.excludeEditors;
  23932. return {
  23933. type: 'entity',
  23934. includeEditors: includeEditors,
  23935. excludeEditors: excludeEditors,
  23936. name: 'EMOTICON',
  23937. control: function control(props) {
  23938. return {
  23939. key: 'EMOTICON',
  23940. replace: 'emoji',
  23941. type: 'dropdown',
  23942. text: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("i", {
  23943. className: "bfi-emoji"
  23944. }),
  23945. showArrow: false,
  23946. ref: bindControlRef,
  23947. autoHide: closeOnBlur,
  23948. component: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("div", {
  23949. className: "braft-emoticon-picker"
  23950. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("div", {
  23951. className: "braft-emoticons-list"
  23952. }, emoticons.map(function (item, index) {
  23953. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  23954. onClick: function onClick() {
  23955. insertEmoticon(props.editor, props.editorState, item);
  23956. closeOnSelect && controlRef && controlRef.hide();
  23957. },
  23958. key: index,
  23959. src: item
  23960. });
  23961. })))
  23962. };
  23963. },
  23964. mutability: 'IMMUTABLE',
  23965. component: function component(props) {
  23966. var entity = props.contentState.getEntity(props.entityKey);
  23967. var _entity$getData = entity.getData(),
  23968. src = _entity$getData.src;
  23969. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("span", {
  23970. className: "braft-emoticon-in-editor"
  23971. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  23972. src: src
  23973. }), props.children);
  23974. },
  23975. importer: function importer(nodeName, node) {
  23976. if (nodeName.toLowerCase() === 'span' && node.classList && node.classList.contains('braft-emoticon-wrap')) {
  23977. var imgNode = node.querySelector('img');
  23978. var src = imgNode.getAttribute('src'); // 移除img节点以避免生成atomic block
  23979. node.removeChild(imgNode);
  23980. return {
  23981. mutability: 'IMMUTABLE',
  23982. data: {
  23983. src: src
  23984. }
  23985. };
  23986. }
  23987. },
  23988. exporter: function exporter(entityObject, initialText) {
  23989. var src = entityObject.data.src;
  23990. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("span", {
  23991. className: "braft-emoticon-wrap"
  23992. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  23993. src: src
  23994. }), initialText);
  23995. }
  23996. };
  23997. });
  23998. /***/ }),
  23999. /***/ 48:
  24000. /***/ (function(module, exports) {
  24001. // removed by extract-text-webpack-plugin
  24002. /***/ }),
  24003. /***/ 5:
  24004. /***/ (function(module, exports, __webpack_require__) {
  24005. var defineProperty = __webpack_require__(2);
  24006. function _objectSpread(target) {
  24007. for (var i = 1; i < arguments.length; i++) {
  24008. var source = arguments[i] != null ? arguments[i] : {};
  24009. var ownKeys = Object.keys(source);
  24010. if (typeof Object.getOwnPropertySymbols === 'function') {
  24011. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  24012. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  24013. }));
  24014. }
  24015. ownKeys.forEach(function (key) {
  24016. defineProperty(target, key, source[key]);
  24017. });
  24018. }
  24019. return target;
  24020. }
  24021. module.exports = _objectSpread;
  24022. /***/ }),
  24023. /***/ 6:
  24024. /***/ (function(module, exports) {
  24025. module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
  24026. /***/ })
  24027. /******/ });
  24028. });
  24029. });
  24030. var Emoticon = _commonjsHelpers.unwrapExports(emoticon);
  24031. var emoticon_1 = emoticon.defaultEmoticons;
  24032. var maxLength = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  24033. (function webpackUniversalModuleDefinition(root, factory) {
  24034. module.exports = factory();
  24035. })(window, function() {
  24036. return /******/ (function(modules) { // webpackBootstrap
  24037. /******/ // The module cache
  24038. /******/ var installedModules = {};
  24039. /******/
  24040. /******/ // The require function
  24041. /******/ function __webpack_require__(moduleId) {
  24042. /******/
  24043. /******/ // Check if module is in cache
  24044. /******/ if(installedModules[moduleId]) {
  24045. /******/ return installedModules[moduleId].exports;
  24046. /******/ }
  24047. /******/ // Create a new module (and put it into the cache)
  24048. /******/ var module = installedModules[moduleId] = {
  24049. /******/ i: moduleId,
  24050. /******/ l: false,
  24051. /******/ exports: {}
  24052. /******/ };
  24053. /******/
  24054. /******/ // Execute the module function
  24055. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  24056. /******/
  24057. /******/ // Flag the module as loaded
  24058. /******/ module.l = true;
  24059. /******/
  24060. /******/ // Return the exports of the module
  24061. /******/ return module.exports;
  24062. /******/ }
  24063. /******/
  24064. /******/
  24065. /******/ // expose the modules object (__webpack_modules__)
  24066. /******/ __webpack_require__.m = modules;
  24067. /******/
  24068. /******/ // expose the module cache
  24069. /******/ __webpack_require__.c = installedModules;
  24070. /******/
  24071. /******/ // define getter function for harmony exports
  24072. /******/ __webpack_require__.d = function(exports, name, getter) {
  24073. /******/ if(!__webpack_require__.o(exports, name)) {
  24074. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  24075. /******/ }
  24076. /******/ };
  24077. /******/
  24078. /******/ // define __esModule on exports
  24079. /******/ __webpack_require__.r = function(exports) {
  24080. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  24081. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  24082. /******/ }
  24083. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  24084. /******/ };
  24085. /******/
  24086. /******/ // create a fake namespace object
  24087. /******/ // mode & 1: value is a module id, require it
  24088. /******/ // mode & 2: merge all properties of value into the ns
  24089. /******/ // mode & 4: return value when already ns object
  24090. /******/ // mode & 8|1: behave like require
  24091. /******/ __webpack_require__.t = function(value, mode) {
  24092. /******/ if(mode & 1) value = __webpack_require__(value);
  24093. /******/ if(mode & 8) return value;
  24094. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  24095. /******/ var ns = Object.create(null);
  24096. /******/ __webpack_require__.r(ns);
  24097. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  24098. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  24099. /******/ return ns;
  24100. /******/ };
  24101. /******/
  24102. /******/ // getDefaultExport function for compatibility with non-harmony modules
  24103. /******/ __webpack_require__.n = function(module) {
  24104. /******/ var getter = module && module.__esModule ?
  24105. /******/ function getDefault() { return module['default']; } :
  24106. /******/ function getModuleExports() { return module; };
  24107. /******/ __webpack_require__.d(getter, 'a', getter);
  24108. /******/ return getter;
  24109. /******/ };
  24110. /******/
  24111. /******/ // Object.prototype.hasOwnProperty.call
  24112. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  24113. /******/
  24114. /******/ // __webpack_public_path__
  24115. /******/ __webpack_require__.p = "/";
  24116. /******/
  24117. /******/
  24118. /******/ // Load entry module and return exports
  24119. /******/ return __webpack_require__(__webpack_require__.s = 34);
  24120. /******/ })
  24121. /************************************************************************/
  24122. /******/ ({
  24123. /***/ 2:
  24124. /***/ (function(module, exports) {
  24125. function _defineProperty(obj, key, value) {
  24126. if (key in obj) {
  24127. Object.defineProperty(obj, key, {
  24128. value: value,
  24129. enumerable: true,
  24130. configurable: true,
  24131. writable: true
  24132. });
  24133. } else {
  24134. obj[key] = value;
  24135. }
  24136. return obj;
  24137. }
  24138. module.exports = _defineProperty;
  24139. /***/ }),
  24140. /***/ 34:
  24141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24142. __webpack_require__.r(__webpack_exports__);
  24143. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
  24144. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);
  24145. var getSelectedTextLength = function getSelectedTextLength(editorState) {
  24146. var currentSelection = editorState.getSelection();
  24147. var isCollapsed = currentSelection.isCollapsed();
  24148. var length = 0;
  24149. if (!isCollapsed) {
  24150. var currentContent = editorState.getCurrentContent();
  24151. var startKey = currentSelection.getStartKey();
  24152. var endKey = currentSelection.getEndKey();
  24153. var startBlock = currentContent.getBlockForKey(startKey);
  24154. var isStartAndEndBlockAreTheSame = startKey === endKey;
  24155. var startBlockTextLength = startBlock.getLength();
  24156. var startSelectedTextLength = startBlockTextLength - currentSelection.getStartOffset();
  24157. var endSelectedTextLength = currentSelection.getEndOffset();
  24158. var keyAfterEnd = currentContent.getKeyAfter(endKey);
  24159. if (isStartAndEndBlockAreTheSame) {
  24160. length += currentSelection.getEndOffset() - currentSelection.getStartOffset();
  24161. } else {
  24162. var currentKey = startKey;
  24163. while (currentKey && currentKey !== keyAfterEnd) {
  24164. if (currentKey === startKey) {
  24165. length += startSelectedTextLength + 1;
  24166. } else if (currentKey === endKey) {
  24167. length += endSelectedTextLength;
  24168. } else {
  24169. length += currentContent.getBlockForKey(currentKey).getLength() + 1;
  24170. }
  24171. currentKey = currentContent.getKeyAfter(currentKey);
  24172. }
  24173. }
  24174. }
  24175. return length;
  24176. };
  24177. /* harmony default export */ __webpack_exports__["default"] = (function (options) {
  24178. options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({
  24179. defaultValue: Infinity
  24180. }, options);
  24181. var _options = options,
  24182. includeEditors = _options.includeEditors,
  24183. excludeEditors = _options.excludeEditors,
  24184. defaultValue = _options.defaultValue;
  24185. return {
  24186. type: 'prop-interception',
  24187. includeEditors: includeEditors,
  24188. excludeEditors: excludeEditors,
  24189. interceptor: function interceptor(editorProps) {
  24190. var maxLength = editorProps.maxLength || defaultValue;
  24191. editorProps.handleBeforeInput = function (_, editorState) {
  24192. if (maxLength === Infinity) {
  24193. return 'not-handled';
  24194. }
  24195. var currentContentLength = editorState.toText().length;
  24196. var selectedTextLength = getSelectedTextLength(editorState);
  24197. if (currentContentLength - selectedTextLength > maxLength - 1) {
  24198. editorProps.onReachMaxLength && editorProps.onReachMaxLength(maxLength);
  24199. return 'handled';
  24200. }
  24201. };
  24202. editorProps.handlePastedText = function (pastedText, _, editorState) {
  24203. if (maxLength === Infinity) {
  24204. return 'not-handled';
  24205. }
  24206. var currentContentLength = editorState.toText().length;
  24207. var selectedTextLength = getSelectedTextLength(editorState);
  24208. if (currentContentLength + pastedText.length - selectedTextLength > maxLength) {
  24209. editorProps.onReachMaxLength && editorProps.onReachMaxLength(maxLength);
  24210. return 'handled';
  24211. }
  24212. };
  24213. return editorProps;
  24214. }
  24215. };
  24216. });
  24217. /***/ }),
  24218. /***/ 5:
  24219. /***/ (function(module, exports, __webpack_require__) {
  24220. var defineProperty = __webpack_require__(2);
  24221. function _objectSpread(target) {
  24222. for (var i = 1; i < arguments.length; i++) {
  24223. var source = arguments[i] != null ? arguments[i] : {};
  24224. var ownKeys = Object.keys(source);
  24225. if (typeof Object.getOwnPropertySymbols === 'function') {
  24226. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  24227. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  24228. }));
  24229. }
  24230. ownKeys.forEach(function (key) {
  24231. defineProperty(target, key, source[key]);
  24232. });
  24233. }
  24234. return target;
  24235. }
  24236. module.exports = _objectSpread;
  24237. /***/ })
  24238. /******/ });
  24239. });
  24240. });
  24241. var MaxLength = _commonjsHelpers.unwrapExports(maxLength);
  24242. var lengthOptions = {
  24243. defaultValue: 100 // 指定默认限制数,如不指定则为Infinity(无限)
  24244. // includeEditors: ['editor-id-1'], // 指定该模块对哪些BraftEditor生效,不传此属性则对所有BraftEditor有效
  24245. // excludeEditors: ['editor-id-2'], // 指定该模块对哪些BraftEditor无效
  24246. };
  24247. BraftEditor.use(MaxLength(lengthOptions)); // 转换默认表情包列表,让webpack可以正确加载到默认表情包中的图片,请确保已对png格式的文件配置了loader
  24248. // 如果你使用的webpack版本不支持动态require,或者使用的其他打包工具,请勿使用此写法
  24249. var emoticons = emoticon_1.map(function (item) {
  24250. return require("braft-extensions/dist/assets/".concat(item));
  24251. }); // 也可以使用自己的表情包资源,不受打包工具限制
  24252. // const emoticons = ['http://path/to/emoticon-1.png', 'http://path/to/emoticon-2.png', 'http://path/to/emoticon-3.png', 'http://path/to/emoticon-4.png', ...]
  24253. var emotionOptions = {
  24254. // includeEditors: ['editor-id-1'], // 指定该模块对哪些BraftEditor生效,不传此属性则对所有BraftEditor有效
  24255. // excludeEditors: ['editor-id-2'], // 指定该模块对哪些BraftEditor无效
  24256. emoticons: emoticons,
  24257. // 指定可用表情图片列表,默认为空
  24258. closeOnBlur: true,
  24259. // 指定是否在点击表情选择器之外的地方时关闭表情选择器,默认false
  24260. closeOnSelect: false // 指定是否在选择表情后关闭表情选择器,默认false
  24261. };
  24262. BraftEditor.use(Emoticon(emotionOptions));
  24263. var BarftEditorPage = function BarftEditorPage(_ref) {
  24264. var value = _ref.value;
  24265. var controls = ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
  24266. var _useState = React.useState(BraftEditor.createEditorState(value || "<p>Hello <b>World!</b></p>")),
  24267. _useState2 = _commonjsHelpers._slicedToArray(_useState, 2),
  24268. editorState = _useState2[0],
  24269. setEditorState = _useState2[1];
  24270. return React__default.createElement("div", {
  24271. className: "editor-wrapper"
  24272. }, React__default.createElement(BraftEditor, {
  24273. value: editorState,
  24274. onChange: setEditorState,
  24275. controls: controls,
  24276. contentStyle: {
  24277. boxShadow: "inset 0 1px 3px rgba(0,0,0,.1)"
  24278. }
  24279. }));
  24280. };
  24281. exports.BarftEditorPage = BarftEditorPage;
  24282. exports.default = BarftEditorPage;
  24283. //# sourceMappingURL=index.js.map