暫無描述

index.js 962KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034
  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 _rollupPluginBabelHelpers = require('../_rollupPluginBabelHelpers-3469b70d.js');
  5. var React = require('react');
  6. var React__default = _interopDefault(React);
  7. var _commonjsHelpers = require('../_commonjsHelpers-72d386ba.js');
  8. var styleInject_es = require('../style-inject.es-dcee06b6.js');
  9. require('react-dom');
  10. var Draft = require('../Draft-a5afe13a.js');
  11. var _reactDom_commonjsExternal = require('../_react-dom_commonjs-external-55867475.js');
  12. var server = _interopDefault(require('react-dom/server'));
  13. var immutable = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  14. /**
  15. * Copyright (c) 2014-present, Facebook, Inc.
  16. *
  17. * This source code is licensed under the MIT license found in the
  18. * LICENSE file in the root directory of this source tree.
  19. */
  20. (function (global, factory) {
  21. factory(exports) ;
  22. }(_commonjsHelpers.commonjsGlobal, (function (exports) {
  23. // Used for setting prototype methods that IE8 chokes on.
  24. var DELETE = 'delete';
  25. // Constants describing the size of trie nodes.
  26. var SHIFT = 5; // Resulted in best performance after ______?
  27. var SIZE = 1 << SHIFT;
  28. var MASK = SIZE - 1;
  29. // A consistent shared value representing "not set" which equals nothing other
  30. // than itself, and nothing that could be provided externally.
  31. var NOT_SET = {};
  32. // Boolean references, Rough equivalent of `bool &`.
  33. function MakeRef() {
  34. return { value: false };
  35. }
  36. function SetRef(ref) {
  37. if (ref) {
  38. ref.value = true;
  39. }
  40. }
  41. // A function which returns a value representing an "owner" for transient writes
  42. // to tries. The return value will only ever equal itself, and will not equal
  43. // the return of any subsequent call of this function.
  44. function OwnerID() {}
  45. function ensureSize(iter) {
  46. if (iter.size === undefined) {
  47. iter.size = iter.__iterate(returnTrue);
  48. }
  49. return iter.size;
  50. }
  51. function wrapIndex(iter, index) {
  52. // This implements "is array index" which the ECMAString spec defines as:
  53. //
  54. // A String property name P is an array index if and only if
  55. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  56. // to 2^32−1.
  57. //
  58. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  59. if (typeof index !== 'number') {
  60. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  61. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  62. return NaN;
  63. }
  64. index = uint32Index;
  65. }
  66. return index < 0 ? ensureSize(iter) + index : index;
  67. }
  68. function returnTrue() {
  69. return true;
  70. }
  71. function wholeSlice(begin, end, size) {
  72. return (
  73. ((begin === 0 && !isNeg(begin)) ||
  74. (size !== undefined && begin <= -size)) &&
  75. (end === undefined || (size !== undefined && end >= size))
  76. );
  77. }
  78. function resolveBegin(begin, size) {
  79. return resolveIndex(begin, size, 0);
  80. }
  81. function resolveEnd(end, size) {
  82. return resolveIndex(end, size, size);
  83. }
  84. function resolveIndex(index, size, defaultIndex) {
  85. // Sanitize indices using this shorthand for ToInt32(argument)
  86. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  87. return index === undefined
  88. ? defaultIndex
  89. : isNeg(index)
  90. ? size === Infinity
  91. ? size
  92. : Math.max(0, size + index) | 0
  93. : size === undefined || size === index
  94. ? index
  95. : Math.min(size, index) | 0;
  96. }
  97. function isNeg(value) {
  98. // Account for -0 which is negative, but not less than 0.
  99. return value < 0 || (value === 0 && 1 / value === -Infinity);
  100. }
  101. // Note: value is unchanged to not break immutable-devtools.
  102. var IS_COLLECTION_SYMBOL = '@@__IMMUTABLE_ITERABLE__@@';
  103. function isCollection(maybeCollection) {
  104. return Boolean(maybeCollection && maybeCollection[IS_COLLECTION_SYMBOL]);
  105. }
  106. var IS_KEYED_SYMBOL = '@@__IMMUTABLE_KEYED__@@';
  107. function isKeyed(maybeKeyed) {
  108. return Boolean(maybeKeyed && maybeKeyed[IS_KEYED_SYMBOL]);
  109. }
  110. var IS_INDEXED_SYMBOL = '@@__IMMUTABLE_INDEXED__@@';
  111. function isIndexed(maybeIndexed) {
  112. return Boolean(maybeIndexed && maybeIndexed[IS_INDEXED_SYMBOL]);
  113. }
  114. function isAssociative(maybeAssociative) {
  115. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  116. }
  117. var Collection = function Collection(value) {
  118. return isCollection(value) ? value : Seq(value);
  119. };
  120. var KeyedCollection = /*@__PURE__*/(function (Collection) {
  121. function KeyedCollection(value) {
  122. return isKeyed(value) ? value : KeyedSeq(value);
  123. }
  124. if ( Collection ) KeyedCollection.__proto__ = Collection;
  125. KeyedCollection.prototype = Object.create( Collection && Collection.prototype );
  126. KeyedCollection.prototype.constructor = KeyedCollection;
  127. return KeyedCollection;
  128. }(Collection));
  129. var IndexedCollection = /*@__PURE__*/(function (Collection) {
  130. function IndexedCollection(value) {
  131. return isIndexed(value) ? value : IndexedSeq(value);
  132. }
  133. if ( Collection ) IndexedCollection.__proto__ = Collection;
  134. IndexedCollection.prototype = Object.create( Collection && Collection.prototype );
  135. IndexedCollection.prototype.constructor = IndexedCollection;
  136. return IndexedCollection;
  137. }(Collection));
  138. var SetCollection = /*@__PURE__*/(function (Collection) {
  139. function SetCollection(value) {
  140. return isCollection(value) && !isAssociative(value) ? value : SetSeq(value);
  141. }
  142. if ( Collection ) SetCollection.__proto__ = Collection;
  143. SetCollection.prototype = Object.create( Collection && Collection.prototype );
  144. SetCollection.prototype.constructor = SetCollection;
  145. return SetCollection;
  146. }(Collection));
  147. Collection.Keyed = KeyedCollection;
  148. Collection.Indexed = IndexedCollection;
  149. Collection.Set = SetCollection;
  150. var IS_SEQ_SYMBOL = '@@__IMMUTABLE_SEQ__@@';
  151. function isSeq(maybeSeq) {
  152. return Boolean(maybeSeq && maybeSeq[IS_SEQ_SYMBOL]);
  153. }
  154. var IS_RECORD_SYMBOL = '@@__IMMUTABLE_RECORD__@@';
  155. function isRecord(maybeRecord) {
  156. return Boolean(maybeRecord && maybeRecord[IS_RECORD_SYMBOL]);
  157. }
  158. function isImmutable(maybeImmutable) {
  159. return isCollection(maybeImmutable) || isRecord(maybeImmutable);
  160. }
  161. var IS_ORDERED_SYMBOL = '@@__IMMUTABLE_ORDERED__@@';
  162. function isOrdered(maybeOrdered) {
  163. return Boolean(maybeOrdered && maybeOrdered[IS_ORDERED_SYMBOL]);
  164. }
  165. var ITERATE_KEYS = 0;
  166. var ITERATE_VALUES = 1;
  167. var ITERATE_ENTRIES = 2;
  168. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  169. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  170. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  171. var Iterator = function Iterator(next) {
  172. this.next = next;
  173. };
  174. Iterator.prototype.toString = function toString () {
  175. return '[Iterator]';
  176. };
  177. Iterator.KEYS = ITERATE_KEYS;
  178. Iterator.VALUES = ITERATE_VALUES;
  179. Iterator.ENTRIES = ITERATE_ENTRIES;
  180. Iterator.prototype.inspect = Iterator.prototype.toSource = function() {
  181. return this.toString();
  182. };
  183. Iterator.prototype[ITERATOR_SYMBOL] = function() {
  184. return this;
  185. };
  186. function iteratorValue(type, k, v, iteratorResult) {
  187. var value = type === 0 ? k : type === 1 ? v : [k, v];
  188. iteratorResult
  189. ? (iteratorResult.value = value)
  190. : (iteratorResult = {
  191. value: value,
  192. done: false,
  193. });
  194. return iteratorResult;
  195. }
  196. function iteratorDone() {
  197. return { value: undefined, done: true };
  198. }
  199. function hasIterator(maybeIterable) {
  200. return !!getIteratorFn(maybeIterable);
  201. }
  202. function isIterator(maybeIterator) {
  203. return maybeIterator && typeof maybeIterator.next === 'function';
  204. }
  205. function getIterator(iterable) {
  206. var iteratorFn = getIteratorFn(iterable);
  207. return iteratorFn && iteratorFn.call(iterable);
  208. }
  209. function getIteratorFn(iterable) {
  210. var iteratorFn =
  211. iterable &&
  212. ((REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  213. iterable[FAUX_ITERATOR_SYMBOL]);
  214. if (typeof iteratorFn === 'function') {
  215. return iteratorFn;
  216. }
  217. }
  218. var hasOwnProperty = Object.prototype.hasOwnProperty;
  219. function isArrayLike(value) {
  220. if (Array.isArray(value) || typeof value === 'string') {
  221. return true;
  222. }
  223. return (
  224. value &&
  225. typeof value === 'object' &&
  226. Number.isInteger(value.length) &&
  227. value.length >= 0 &&
  228. (value.length === 0
  229. ? // Only {length: 0} is considered Array-like.
  230. Object.keys(value).length === 1
  231. : // An object is only Array-like if it has a property where the last value
  232. // in the array-like may be found (which could be undefined).
  233. value.hasOwnProperty(value.length - 1))
  234. );
  235. }
  236. var Seq = /*@__PURE__*/(function (Collection$$1) {
  237. function Seq(value) {
  238. return value === null || value === undefined
  239. ? emptySequence()
  240. : isImmutable(value)
  241. ? value.toSeq()
  242. : seqFromValue(value);
  243. }
  244. if ( Collection$$1 ) Seq.__proto__ = Collection$$1;
  245. Seq.prototype = Object.create( Collection$$1 && Collection$$1.prototype );
  246. Seq.prototype.constructor = Seq;
  247. Seq.prototype.toSeq = function toSeq () {
  248. return this;
  249. };
  250. Seq.prototype.toString = function toString () {
  251. return this.__toString('Seq {', '}');
  252. };
  253. Seq.prototype.cacheResult = function cacheResult () {
  254. if (!this._cache && this.__iterateUncached) {
  255. this._cache = this.entrySeq().toArray();
  256. this.size = this._cache.length;
  257. }
  258. return this;
  259. };
  260. // abstract __iterateUncached(fn, reverse)
  261. Seq.prototype.__iterate = function __iterate (fn, reverse) {
  262. var cache = this._cache;
  263. if (cache) {
  264. var size = cache.length;
  265. var i = 0;
  266. while (i !== size) {
  267. var entry = cache[reverse ? size - ++i : i++];
  268. if (fn(entry[1], entry[0], this) === false) {
  269. break;
  270. }
  271. }
  272. return i;
  273. }
  274. return this.__iterateUncached(fn, reverse);
  275. };
  276. // abstract __iteratorUncached(type, reverse)
  277. Seq.prototype.__iterator = function __iterator (type, reverse) {
  278. var cache = this._cache;
  279. if (cache) {
  280. var size = cache.length;
  281. var i = 0;
  282. return new Iterator(function () {
  283. if (i === size) {
  284. return iteratorDone();
  285. }
  286. var entry = cache[reverse ? size - ++i : i++];
  287. return iteratorValue(type, entry[0], entry[1]);
  288. });
  289. }
  290. return this.__iteratorUncached(type, reverse);
  291. };
  292. return Seq;
  293. }(Collection));
  294. var KeyedSeq = /*@__PURE__*/(function (Seq) {
  295. function KeyedSeq(value) {
  296. return value === null || value === undefined
  297. ? emptySequence().toKeyedSeq()
  298. : isCollection(value)
  299. ? isKeyed(value)
  300. ? value.toSeq()
  301. : value.fromEntrySeq()
  302. : isRecord(value)
  303. ? value.toSeq()
  304. : keyedSeqFromValue(value);
  305. }
  306. if ( Seq ) KeyedSeq.__proto__ = Seq;
  307. KeyedSeq.prototype = Object.create( Seq && Seq.prototype );
  308. KeyedSeq.prototype.constructor = KeyedSeq;
  309. KeyedSeq.prototype.toKeyedSeq = function toKeyedSeq () {
  310. return this;
  311. };
  312. return KeyedSeq;
  313. }(Seq));
  314. var IndexedSeq = /*@__PURE__*/(function (Seq) {
  315. function IndexedSeq(value) {
  316. return value === null || value === undefined
  317. ? emptySequence()
  318. : isCollection(value)
  319. ? isKeyed(value)
  320. ? value.entrySeq()
  321. : value.toIndexedSeq()
  322. : isRecord(value)
  323. ? value.toSeq().entrySeq()
  324. : indexedSeqFromValue(value);
  325. }
  326. if ( Seq ) IndexedSeq.__proto__ = Seq;
  327. IndexedSeq.prototype = Object.create( Seq && Seq.prototype );
  328. IndexedSeq.prototype.constructor = IndexedSeq;
  329. IndexedSeq.of = function of (/*...values*/) {
  330. return IndexedSeq(arguments);
  331. };
  332. IndexedSeq.prototype.toIndexedSeq = function toIndexedSeq () {
  333. return this;
  334. };
  335. IndexedSeq.prototype.toString = function toString () {
  336. return this.__toString('Seq [', ']');
  337. };
  338. return IndexedSeq;
  339. }(Seq));
  340. var SetSeq = /*@__PURE__*/(function (Seq) {
  341. function SetSeq(value) {
  342. return (isCollection(value) && !isAssociative(value)
  343. ? value
  344. : IndexedSeq(value)
  345. ).toSetSeq();
  346. }
  347. if ( Seq ) SetSeq.__proto__ = Seq;
  348. SetSeq.prototype = Object.create( Seq && Seq.prototype );
  349. SetSeq.prototype.constructor = SetSeq;
  350. SetSeq.of = function of (/*...values*/) {
  351. return SetSeq(arguments);
  352. };
  353. SetSeq.prototype.toSetSeq = function toSetSeq () {
  354. return this;
  355. };
  356. return SetSeq;
  357. }(Seq));
  358. Seq.isSeq = isSeq;
  359. Seq.Keyed = KeyedSeq;
  360. Seq.Set = SetSeq;
  361. Seq.Indexed = IndexedSeq;
  362. Seq.prototype[IS_SEQ_SYMBOL] = true;
  363. // #pragma Root Sequences
  364. var ArraySeq = /*@__PURE__*/(function (IndexedSeq) {
  365. function ArraySeq(array) {
  366. this._array = array;
  367. this.size = array.length;
  368. }
  369. if ( IndexedSeq ) ArraySeq.__proto__ = IndexedSeq;
  370. ArraySeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  371. ArraySeq.prototype.constructor = ArraySeq;
  372. ArraySeq.prototype.get = function get (index, notSetValue) {
  373. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  374. };
  375. ArraySeq.prototype.__iterate = function __iterate (fn, reverse) {
  376. var array = this._array;
  377. var size = array.length;
  378. var i = 0;
  379. while (i !== size) {
  380. var ii = reverse ? size - ++i : i++;
  381. if (fn(array[ii], ii, this) === false) {
  382. break;
  383. }
  384. }
  385. return i;
  386. };
  387. ArraySeq.prototype.__iterator = function __iterator (type, reverse) {
  388. var array = this._array;
  389. var size = array.length;
  390. var i = 0;
  391. return new Iterator(function () {
  392. if (i === size) {
  393. return iteratorDone();
  394. }
  395. var ii = reverse ? size - ++i : i++;
  396. return iteratorValue(type, ii, array[ii]);
  397. });
  398. };
  399. return ArraySeq;
  400. }(IndexedSeq));
  401. var ObjectSeq = /*@__PURE__*/(function (KeyedSeq) {
  402. function ObjectSeq(object) {
  403. var keys = Object.keys(object);
  404. this._object = object;
  405. this._keys = keys;
  406. this.size = keys.length;
  407. }
  408. if ( KeyedSeq ) ObjectSeq.__proto__ = KeyedSeq;
  409. ObjectSeq.prototype = Object.create( KeyedSeq && KeyedSeq.prototype );
  410. ObjectSeq.prototype.constructor = ObjectSeq;
  411. ObjectSeq.prototype.get = function get (key, notSetValue) {
  412. if (notSetValue !== undefined && !this.has(key)) {
  413. return notSetValue;
  414. }
  415. return this._object[key];
  416. };
  417. ObjectSeq.prototype.has = function has (key) {
  418. return hasOwnProperty.call(this._object, key);
  419. };
  420. ObjectSeq.prototype.__iterate = function __iterate (fn, reverse) {
  421. var object = this._object;
  422. var keys = this._keys;
  423. var size = keys.length;
  424. var i = 0;
  425. while (i !== size) {
  426. var key = keys[reverse ? size - ++i : i++];
  427. if (fn(object[key], key, this) === false) {
  428. break;
  429. }
  430. }
  431. return i;
  432. };
  433. ObjectSeq.prototype.__iterator = function __iterator (type, reverse) {
  434. var object = this._object;
  435. var keys = this._keys;
  436. var size = keys.length;
  437. var i = 0;
  438. return new Iterator(function () {
  439. if (i === size) {
  440. return iteratorDone();
  441. }
  442. var key = keys[reverse ? size - ++i : i++];
  443. return iteratorValue(type, key, object[key]);
  444. });
  445. };
  446. return ObjectSeq;
  447. }(KeyedSeq));
  448. ObjectSeq.prototype[IS_ORDERED_SYMBOL] = true;
  449. var CollectionSeq = /*@__PURE__*/(function (IndexedSeq) {
  450. function CollectionSeq(collection) {
  451. this._collection = collection;
  452. this.size = collection.length || collection.size;
  453. }
  454. if ( IndexedSeq ) CollectionSeq.__proto__ = IndexedSeq;
  455. CollectionSeq.prototype = Object.create( IndexedSeq && IndexedSeq.prototype );
  456. CollectionSeq.prototype.constructor = CollectionSeq;
  457. CollectionSeq.prototype.__iterateUncached = function __iterateUncached (fn, reverse) {
  458. if (reverse) {
  459. return this.cacheResult().__iterate(fn, reverse);
  460. }
  461. var collection = this._collection;
  462. var iterator = getIterator(collection);
  463. var iterations = 0;
  464. if (isIterator(iterator)) {
  465. var step;
  466. while (!(step = iterator.next()).done) {
  467. if (fn(step.value, iterations++, this) === false) {
  468. break;
  469. }
  470. }
  471. }
  472. return iterations;
  473. };
  474. CollectionSeq.prototype.__iteratorUncached = function __iteratorUncached (type, reverse) {
  475. if (reverse) {
  476. return this.cacheResult().__iterator(type, reverse);
  477. }
  478. var collection = this._collection;
  479. var iterator = getIterator(collection);
  480. if (!isIterator(iterator)) {
  481. return new Iterator(iteratorDone);
  482. }
  483. var iterations = 0;
  484. return new Iterator(function () {
  485. var step = iterator.next();
  486. return step.done ? step : iteratorValue(type, iterations++, step.value);
  487. });
  488. };
  489. return CollectionSeq;
  490. }(IndexedSeq));
  491. // # pragma Helper functions
  492. var EMPTY_SEQ;
  493. function emptySequence() {
  494. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  495. }
  496. function keyedSeqFromValue(value) {
  497. var seq = Array.isArray(value)
  498. ? new ArraySeq(value)
  499. : hasIterator(value)
  500. ? new CollectionSeq(value)
  501. : undefined;
  502. if (seq) {
  503. return seq.fromEntrySeq();
  504. }
  505. if (typeof value === 'object') {
  506. return new ObjectSeq(value);
  507. }
  508. throw new TypeError(
  509. 'Expected Array or collection object of [k, v] entries, or keyed object: ' +
  510. value
  511. );
  512. }
  513. function indexedSeqFromValue(value) {
  514. var seq = maybeIndexedSeqFromValue(value);
  515. if (seq) {
  516. return seq;
  517. }
  518. throw new TypeError(
  519. 'Expected Array or collection object of values: ' + value
  520. );
  521. }
  522. function seqFromValue(value) {
  523. var seq = maybeIndexedSeqFromValue(value);
  524. if (seq) {
  525. return seq;
  526. }
  527. if (typeof value === 'object') {
  528. return new ObjectSeq(value);
  529. }
  530. throw new TypeError(
  531. 'Expected Array or collection object of values, or keyed object: ' + value
  532. );
  533. }
  534. function maybeIndexedSeqFromValue(value) {
  535. return isArrayLike(value)
  536. ? new ArraySeq(value)
  537. : hasIterator(value)
  538. ? new CollectionSeq(value)
  539. : undefined;
  540. }
  541. var IS_MAP_SYMBOL = '@@__IMMUTABLE_MAP__@@';
  542. function isMap(maybeMap) {
  543. return Boolean(maybeMap && maybeMap[IS_MAP_SYMBOL]);
  544. }
  545. function isOrderedMap(maybeOrderedMap) {
  546. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  547. }
  548. function isValueObject(maybeValue) {
  549. return Boolean(
  550. maybeValue &&
  551. typeof maybeValue.equals === 'function' &&
  552. typeof maybeValue.hashCode === 'function'
  553. );
  554. }
  555. /**
  556. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  557. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  558. *
  559. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  560. * value, which is different from the algorithm described by
  561. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  562. *
  563. * This is extended further to allow Objects to describe the values they
  564. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  565. *
  566. * Note: because of this extension, the key equality of Immutable.Map and the
  567. * value equality of Immutable.Set will differ from ES6 Map and Set.
  568. *
  569. * ### Defining custom values
  570. *
  571. * The easiest way to describe the value an object represents is by implementing
  572. * `valueOf`. For example, `Date` represents a value by returning a unix
  573. * timestamp for `valueOf`:
  574. *
  575. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  576. * var date2 = new Date(1234567890000);
  577. * date1.valueOf(); // 1234567890000
  578. * assert( date1 !== date2 );
  579. * assert( Immutable.is( date1, date2 ) );
  580. *
  581. * Note: overriding `valueOf` may have other implications if you use this object
  582. * where JavaScript expects a primitive, such as implicit string coercion.
  583. *
  584. * For more complex types, especially collections, implementing `valueOf` may
  585. * not be performant. An alternative is to implement `equals` and `hashCode`.
  586. *
  587. * `equals` takes another object, presumably of similar type, and returns true
  588. * if it is equal. Equality is symmetrical, so the same result should be
  589. * returned if this and the argument are flipped.
  590. *
  591. * assert( a.equals(b) === b.equals(a) );
  592. *
  593. * `hashCode` returns a 32bit integer number representing the object which will
  594. * be used to determine how to store the value object in a Map or Set. You must
  595. * provide both or neither methods, one must not exist without the other.
  596. *
  597. * Also, an important relationship between these methods must be upheld: if two
  598. * values are equal, they *must* return the same hashCode. If the values are not
  599. * equal, they might have the same hashCode; this is called a hash collision,
  600. * and while undesirable for performance reasons, it is acceptable.
  601. *
  602. * if (a.equals(b)) {
  603. * assert( a.hashCode() === b.hashCode() );
  604. * }
  605. *
  606. * All Immutable collections are Value Objects: they implement `equals()`
  607. * and `hashCode()`.
  608. */
  609. function is(valueA, valueB) {
  610. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  611. return true;
  612. }
  613. if (!valueA || !valueB) {
  614. return false;
  615. }
  616. if (
  617. typeof valueA.valueOf === 'function' &&
  618. typeof valueB.valueOf === 'function'
  619. ) {
  620. valueA = valueA.valueOf();
  621. valueB = valueB.valueOf();
  622. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  623. return true;
  624. }
  625. if (!valueA || !valueB) {
  626. return false;
  627. }
  628. }
  629. return !!(
  630. isValueObject(valueA) &&
  631. isValueObject(valueB) &&
  632. valueA.equals(valueB)
  633. );
  634. }
  635. var imul =
  636. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2
  637. ? Math.imul
  638. : function imul(a, b) {
  639. a |= 0; // int
  640. b |= 0; // int
  641. var c = a & 0xffff;
  642. var d = b & 0xffff;
  643. // Shift by 0 fixes the sign on the high part.
  644. return (c * d + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0)) | 0; // int
  645. };
  646. // v8 has an optimization for storing 31-bit signed numbers.
  647. // Values which have either 00 or 11 as the high order bits qualify.
  648. // This function drops the highest order bit in a signed number, maintaining
  649. // the sign bit.
  650. function smi(i32) {
  651. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xbfffffff);
  652. }
  653. var defaultValueOf = Object.prototype.valueOf;
  654. function hash(o) {
  655. switch (typeof o) {
  656. case 'boolean':
  657. // The hash values for built-in constants are a 1 value for each 5-byte
  658. // shift region expect for the first, which encodes the value. This
  659. // reduces the odds of a hash collision for these common values.
  660. return o ? 0x42108421 : 0x42108420;
  661. case 'number':
  662. return hashNumber(o);
  663. case 'string':
  664. return o.length > STRING_HASH_CACHE_MIN_STRLEN
  665. ? cachedHashString(o)
  666. : hashString(o);
  667. case 'object':
  668. case 'function':
  669. if (o === null) {
  670. return 0x42108422;
  671. }
  672. if (typeof o.hashCode === 'function') {
  673. // Drop any high bits from accidentally long hash codes.
  674. return smi(o.hashCode(o));
  675. }
  676. if (o.valueOf !== defaultValueOf && typeof o.valueOf === 'function') {
  677. o = o.valueOf(o);
  678. }
  679. return hashJSObj(o);
  680. case 'undefined':
  681. return 0x42108423;
  682. default:
  683. if (typeof o.toString === 'function') {
  684. return hashString(o.toString());
  685. }
  686. throw new Error('Value type ' + typeof o + ' cannot be hashed.');
  687. }
  688. }
  689. // Compress arbitrarily large numbers into smi hashes.
  690. function hashNumber(n) {
  691. if (n !== n || n === Infinity) {
  692. return 0;
  693. }
  694. var hash = n | 0;
  695. if (hash !== n) {
  696. hash ^= n * 0xffffffff;
  697. }
  698. while (n > 0xffffffff) {
  699. n /= 0xffffffff;
  700. hash ^= n;
  701. }
  702. return smi(hash);
  703. }
  704. function cachedHashString(string) {
  705. var hashed = stringHashCache[string];
  706. if (hashed === undefined) {
  707. hashed = hashString(string);
  708. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  709. STRING_HASH_CACHE_SIZE = 0;
  710. stringHashCache = {};
  711. }
  712. STRING_HASH_CACHE_SIZE++;
  713. stringHashCache[string] = hashed;
  714. }
  715. return hashed;
  716. }
  717. // http://jsperf.com/hashing-strings
  718. function hashString(string) {
  719. // This is the hash from JVM
  720. // The hash code for a string is computed as
  721. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  722. // where s[i] is the ith character of the string and n is the length of
  723. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  724. // (exclusive) by dropping high bits.
  725. var hashed = 0;
  726. for (var ii = 0; ii < string.length; ii++) {
  727. hashed = (31 * hashed + string.charCodeAt(ii)) | 0;
  728. }
  729. return smi(hashed);
  730. }
  731. function hashJSObj(obj) {
  732. var hashed;
  733. if (usingWeakMap) {
  734. hashed = weakMap.get(obj);
  735. if (hashed !== undefined) {
  736. return hashed;
  737. }
  738. }
  739. hashed = obj[UID_HASH_KEY];
  740. if (hashed !== undefined) {
  741. return hashed;
  742. }
  743. if (!canDefineProperty) {
  744. hashed = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  745. if (hashed !== undefined) {
  746. return hashed;
  747. }
  748. hashed = getIENodeHash(obj);
  749. if (hashed !== undefined) {
  750. return hashed;
  751. }
  752. }
  753. hashed = ++objHashUID;
  754. if (objHashUID & 0x40000000) {
  755. objHashUID = 0;
  756. }
  757. if (usingWeakMap) {
  758. weakMap.set(obj, hashed);
  759. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  760. throw new Error('Non-extensible objects are not allowed as keys.');
  761. } else if (canDefineProperty) {
  762. Object.defineProperty(obj, UID_HASH_KEY, {
  763. enumerable: false,
  764. configurable: false,
  765. writable: false,
  766. value: hashed,
  767. });
  768. } else if (
  769. obj.propertyIsEnumerable !== undefined &&
  770. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable
  771. ) {
  772. // Since we can't define a non-enumerable property on the object
  773. // we'll hijack one of the less-used non-enumerable properties to
  774. // save our hash on it. Since this is a function it will not show up in
  775. // `JSON.stringify` which is what we want.
  776. obj.propertyIsEnumerable = function() {
  777. return this.constructor.prototype.propertyIsEnumerable.apply(
  778. this,
  779. arguments
  780. );
  781. };
  782. obj.propertyIsEnumerable[UID_HASH_KEY] = hashed;
  783. } else if (obj.nodeType !== undefined) {
  784. // At this point we couldn't get the IE `uniqueID` to use as a hash
  785. // and we couldn't use a non-enumerable property to exploit the
  786. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  787. // itself.
  788. obj[UID_HASH_KEY] = hashed;
  789. } else {
  790. throw new Error('Unable to set a non-enumerable property on object.');
  791. }
  792. return hashed;
  793. }
  794. // Get references to ES5 object methods.
  795. var isExtensible = Object.isExtensible;
  796. // True if Object.defineProperty works as expected. IE8 fails this test.
  797. var canDefineProperty = (function() {
  798. try {
  799. Object.defineProperty({}, '@', {});
  800. return true;
  801. } catch (e) {
  802. return false;
  803. }
  804. })();
  805. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  806. // and avoid memory leaks from the IE cloneNode bug.
  807. function getIENodeHash(node) {
  808. if (node && node.nodeType > 0) {
  809. switch (node.nodeType) {
  810. case 1: // Element
  811. return node.uniqueID;
  812. case 9: // Document
  813. return node.documentElement && node.documentElement.uniqueID;
  814. }
  815. }
  816. }
  817. // If possible, use a WeakMap.
  818. var usingWeakMap = typeof WeakMap === 'function';
  819. var weakMap;
  820. if (usingWeakMap) {
  821. weakMap = new WeakMap();
  822. }
  823. var objHashUID = 0;
  824. var UID_HASH_KEY = '__immutablehash__';
  825. if (typeof Symbol === 'function') {
  826. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  827. }
  828. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  829. var STRING_HASH_CACHE_MAX_SIZE = 255;
  830. var STRING_HASH_CACHE_SIZE = 0;
  831. var stringHashCache = {};
  832. var ToKeyedSequence = /*@__PURE__*/(function (KeyedSeq$$1) {
  833. function ToKeyedSequence(indexed, useKeys) {
  834. this._iter = indexed;
  835. this._useKeys = useKeys;
  836. this.size = indexed.size;
  837. }
  838. if ( KeyedSeq$$1 ) ToKeyedSequence.__proto__ = KeyedSeq$$1;
  839. ToKeyedSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
  840. ToKeyedSequence.prototype.constructor = ToKeyedSequence;
  841. ToKeyedSequence.prototype.get = function get (key, notSetValue) {
  842. return this._iter.get(key, notSetValue);
  843. };
  844. ToKeyedSequence.prototype.has = function has (key) {
  845. return this._iter.has(key);
  846. };
  847. ToKeyedSequence.prototype.valueSeq = function valueSeq () {
  848. return this._iter.valueSeq();
  849. };
  850. ToKeyedSequence.prototype.reverse = function reverse () {
  851. var this$1 = this;
  852. var reversedSequence = reverseFactory(this, true);
  853. if (!this._useKeys) {
  854. reversedSequence.valueSeq = function () { return this$1._iter.toSeq().reverse(); };
  855. }
  856. return reversedSequence;
  857. };
  858. ToKeyedSequence.prototype.map = function map (mapper, context) {
  859. var this$1 = this;
  860. var mappedSequence = mapFactory(this, mapper, context);
  861. if (!this._useKeys) {
  862. mappedSequence.valueSeq = function () { return this$1._iter.toSeq().map(mapper, context); };
  863. }
  864. return mappedSequence;
  865. };
  866. ToKeyedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  867. var this$1 = this;
  868. return this._iter.__iterate(function (v, k) { return fn(v, k, this$1); }, reverse);
  869. };
  870. ToKeyedSequence.prototype.__iterator = function __iterator (type, reverse) {
  871. return this._iter.__iterator(type, reverse);
  872. };
  873. return ToKeyedSequence;
  874. }(KeyedSeq));
  875. ToKeyedSequence.prototype[IS_ORDERED_SYMBOL] = true;
  876. var ToIndexedSequence = /*@__PURE__*/(function (IndexedSeq$$1) {
  877. function ToIndexedSequence(iter) {
  878. this._iter = iter;
  879. this.size = iter.size;
  880. }
  881. if ( IndexedSeq$$1 ) ToIndexedSequence.__proto__ = IndexedSeq$$1;
  882. ToIndexedSequence.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  883. ToIndexedSequence.prototype.constructor = ToIndexedSequence;
  884. ToIndexedSequence.prototype.includes = function includes (value) {
  885. return this._iter.includes(value);
  886. };
  887. ToIndexedSequence.prototype.__iterate = function __iterate (fn, reverse) {
  888. var this$1 = this;
  889. var i = 0;
  890. reverse && ensureSize(this);
  891. return this._iter.__iterate(
  892. function (v) { return fn(v, reverse ? this$1.size - ++i : i++, this$1); },
  893. reverse
  894. );
  895. };
  896. ToIndexedSequence.prototype.__iterator = function __iterator (type, reverse) {
  897. var this$1 = this;
  898. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  899. var i = 0;
  900. reverse && ensureSize(this);
  901. return new Iterator(function () {
  902. var step = iterator.next();
  903. return step.done
  904. ? step
  905. : iteratorValue(
  906. type,
  907. reverse ? this$1.size - ++i : i++,
  908. step.value,
  909. step
  910. );
  911. });
  912. };
  913. return ToIndexedSequence;
  914. }(IndexedSeq));
  915. var ToSetSequence = /*@__PURE__*/(function (SetSeq$$1) {
  916. function ToSetSequence(iter) {
  917. this._iter = iter;
  918. this.size = iter.size;
  919. }
  920. if ( SetSeq$$1 ) ToSetSequence.__proto__ = SetSeq$$1;
  921. ToSetSequence.prototype = Object.create( SetSeq$$1 && SetSeq$$1.prototype );
  922. ToSetSequence.prototype.constructor = ToSetSequence;
  923. ToSetSequence.prototype.has = function has (key) {
  924. return this._iter.includes(key);
  925. };
  926. ToSetSequence.prototype.__iterate = function __iterate (fn, reverse) {
  927. var this$1 = this;
  928. return this._iter.__iterate(function (v) { return fn(v, v, this$1); }, reverse);
  929. };
  930. ToSetSequence.prototype.__iterator = function __iterator (type, reverse) {
  931. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  932. return new Iterator(function () {
  933. var step = iterator.next();
  934. return step.done
  935. ? step
  936. : iteratorValue(type, step.value, step.value, step);
  937. });
  938. };
  939. return ToSetSequence;
  940. }(SetSeq));
  941. var FromEntriesSequence = /*@__PURE__*/(function (KeyedSeq$$1) {
  942. function FromEntriesSequence(entries) {
  943. this._iter = entries;
  944. this.size = entries.size;
  945. }
  946. if ( KeyedSeq$$1 ) FromEntriesSequence.__proto__ = KeyedSeq$$1;
  947. FromEntriesSequence.prototype = Object.create( KeyedSeq$$1 && KeyedSeq$$1.prototype );
  948. FromEntriesSequence.prototype.constructor = FromEntriesSequence;
  949. FromEntriesSequence.prototype.entrySeq = function entrySeq () {
  950. return this._iter.toSeq();
  951. };
  952. FromEntriesSequence.prototype.__iterate = function __iterate (fn, reverse) {
  953. var this$1 = this;
  954. return this._iter.__iterate(function (entry) {
  955. // Check if entry exists first so array access doesn't throw for holes
  956. // in the parent iteration.
  957. if (entry) {
  958. validateEntry(entry);
  959. var indexedCollection = isCollection(entry);
  960. return fn(
  961. indexedCollection ? entry.get(1) : entry[1],
  962. indexedCollection ? entry.get(0) : entry[0],
  963. this$1
  964. );
  965. }
  966. }, reverse);
  967. };
  968. FromEntriesSequence.prototype.__iterator = function __iterator (type, reverse) {
  969. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  970. return new Iterator(function () {
  971. while (true) {
  972. var step = iterator.next();
  973. if (step.done) {
  974. return step;
  975. }
  976. var entry = step.value;
  977. // Check if entry exists first so array access doesn't throw for holes
  978. // in the parent iteration.
  979. if (entry) {
  980. validateEntry(entry);
  981. var indexedCollection = isCollection(entry);
  982. return iteratorValue(
  983. type,
  984. indexedCollection ? entry.get(0) : entry[0],
  985. indexedCollection ? entry.get(1) : entry[1],
  986. step
  987. );
  988. }
  989. }
  990. });
  991. };
  992. return FromEntriesSequence;
  993. }(KeyedSeq));
  994. ToIndexedSequence.prototype.cacheResult = ToKeyedSequence.prototype.cacheResult = ToSetSequence.prototype.cacheResult = FromEntriesSequence.prototype.cacheResult = cacheResultThrough;
  995. function flipFactory(collection) {
  996. var flipSequence = makeSequence(collection);
  997. flipSequence._iter = collection;
  998. flipSequence.size = collection.size;
  999. flipSequence.flip = function () { return collection; };
  1000. flipSequence.reverse = function() {
  1001. var reversedSequence = collection.reverse.apply(this); // super.reverse()
  1002. reversedSequence.flip = function () { return collection.reverse(); };
  1003. return reversedSequence;
  1004. };
  1005. flipSequence.has = function (key) { return collection.includes(key); };
  1006. flipSequence.includes = function (key) { return collection.has(key); };
  1007. flipSequence.cacheResult = cacheResultThrough;
  1008. flipSequence.__iterateUncached = function(fn, reverse) {
  1009. var this$1 = this;
  1010. return collection.__iterate(function (v, k) { return fn(k, v, this$1) !== false; }, reverse);
  1011. };
  1012. flipSequence.__iteratorUncached = function(type, reverse) {
  1013. if (type === ITERATE_ENTRIES) {
  1014. var iterator = collection.__iterator(type, reverse);
  1015. return new Iterator(function () {
  1016. var step = iterator.next();
  1017. if (!step.done) {
  1018. var k = step.value[0];
  1019. step.value[0] = step.value[1];
  1020. step.value[1] = k;
  1021. }
  1022. return step;
  1023. });
  1024. }
  1025. return collection.__iterator(
  1026. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  1027. reverse
  1028. );
  1029. };
  1030. return flipSequence;
  1031. }
  1032. function mapFactory(collection, mapper, context) {
  1033. var mappedSequence = makeSequence(collection);
  1034. mappedSequence.size = collection.size;
  1035. mappedSequence.has = function (key) { return collection.has(key); };
  1036. mappedSequence.get = function (key, notSetValue) {
  1037. var v = collection.get(key, NOT_SET);
  1038. return v === NOT_SET
  1039. ? notSetValue
  1040. : mapper.call(context, v, key, collection);
  1041. };
  1042. mappedSequence.__iterateUncached = function(fn, reverse) {
  1043. var this$1 = this;
  1044. return collection.__iterate(
  1045. function (v, k, c) { return fn(mapper.call(context, v, k, c), k, this$1) !== false; },
  1046. reverse
  1047. );
  1048. };
  1049. mappedSequence.__iteratorUncached = function(type, reverse) {
  1050. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1051. return new Iterator(function () {
  1052. var step = iterator.next();
  1053. if (step.done) {
  1054. return step;
  1055. }
  1056. var entry = step.value;
  1057. var key = entry[0];
  1058. return iteratorValue(
  1059. type,
  1060. key,
  1061. mapper.call(context, entry[1], key, collection),
  1062. step
  1063. );
  1064. });
  1065. };
  1066. return mappedSequence;
  1067. }
  1068. function reverseFactory(collection, useKeys) {
  1069. var this$1 = this;
  1070. var reversedSequence = makeSequence(collection);
  1071. reversedSequence._iter = collection;
  1072. reversedSequence.size = collection.size;
  1073. reversedSequence.reverse = function () { return collection; };
  1074. if (collection.flip) {
  1075. reversedSequence.flip = function() {
  1076. var flipSequence = flipFactory(collection);
  1077. flipSequence.reverse = function () { return collection.flip(); };
  1078. return flipSequence;
  1079. };
  1080. }
  1081. reversedSequence.get = function (key, notSetValue) { return collection.get(useKeys ? key : -1 - key, notSetValue); };
  1082. reversedSequence.has = function (key) { return collection.has(useKeys ? key : -1 - key); };
  1083. reversedSequence.includes = function (value) { return collection.includes(value); };
  1084. reversedSequence.cacheResult = cacheResultThrough;
  1085. reversedSequence.__iterate = function(fn, reverse) {
  1086. var this$1 = this;
  1087. var i = 0;
  1088. reverse && ensureSize(collection);
  1089. return collection.__iterate(
  1090. function (v, k) { return fn(v, useKeys ? k : reverse ? this$1.size - ++i : i++, this$1); },
  1091. !reverse
  1092. );
  1093. };
  1094. reversedSequence.__iterator = function (type, reverse) {
  1095. var i = 0;
  1096. reverse && ensureSize(collection);
  1097. var iterator = collection.__iterator(ITERATE_ENTRIES, !reverse);
  1098. return new Iterator(function () {
  1099. var step = iterator.next();
  1100. if (step.done) {
  1101. return step;
  1102. }
  1103. var entry = step.value;
  1104. return iteratorValue(
  1105. type,
  1106. useKeys ? entry[0] : reverse ? this$1.size - ++i : i++,
  1107. entry[1],
  1108. step
  1109. );
  1110. });
  1111. };
  1112. return reversedSequence;
  1113. }
  1114. function filterFactory(collection, predicate, context, useKeys) {
  1115. var filterSequence = makeSequence(collection);
  1116. if (useKeys) {
  1117. filterSequence.has = function (key) {
  1118. var v = collection.get(key, NOT_SET);
  1119. return v !== NOT_SET && !!predicate.call(context, v, key, collection);
  1120. };
  1121. filterSequence.get = function (key, notSetValue) {
  1122. var v = collection.get(key, NOT_SET);
  1123. return v !== NOT_SET && predicate.call(context, v, key, collection)
  1124. ? v
  1125. : notSetValue;
  1126. };
  1127. }
  1128. filterSequence.__iterateUncached = function(fn, reverse) {
  1129. var this$1 = this;
  1130. var iterations = 0;
  1131. collection.__iterate(function (v, k, c) {
  1132. if (predicate.call(context, v, k, c)) {
  1133. iterations++;
  1134. return fn(v, useKeys ? k : iterations - 1, this$1);
  1135. }
  1136. }, reverse);
  1137. return iterations;
  1138. };
  1139. filterSequence.__iteratorUncached = function(type, reverse) {
  1140. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1141. var iterations = 0;
  1142. return new Iterator(function () {
  1143. while (true) {
  1144. var step = iterator.next();
  1145. if (step.done) {
  1146. return step;
  1147. }
  1148. var entry = step.value;
  1149. var key = entry[0];
  1150. var value = entry[1];
  1151. if (predicate.call(context, value, key, collection)) {
  1152. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  1153. }
  1154. }
  1155. });
  1156. };
  1157. return filterSequence;
  1158. }
  1159. function countByFactory(collection, grouper, context) {
  1160. var groups = Map().asMutable();
  1161. collection.__iterate(function (v, k) {
  1162. groups.update(grouper.call(context, v, k, collection), 0, function (a) { return a + 1; });
  1163. });
  1164. return groups.asImmutable();
  1165. }
  1166. function groupByFactory(collection, grouper, context) {
  1167. var isKeyedIter = isKeyed(collection);
  1168. var groups = (isOrdered(collection) ? OrderedMap() : Map()).asMutable();
  1169. collection.__iterate(function (v, k) {
  1170. groups.update(
  1171. grouper.call(context, v, k, collection),
  1172. function (a) { return ((a = a || []), a.push(isKeyedIter ? [k, v] : v), a); }
  1173. );
  1174. });
  1175. var coerce = collectionClass(collection);
  1176. return groups.map(function (arr) { return reify(collection, coerce(arr)); }).asImmutable();
  1177. }
  1178. function sliceFactory(collection, begin, end, useKeys) {
  1179. var originalSize = collection.size;
  1180. if (wholeSlice(begin, end, originalSize)) {
  1181. return collection;
  1182. }
  1183. var resolvedBegin = resolveBegin(begin, originalSize);
  1184. var resolvedEnd = resolveEnd(end, originalSize);
  1185. // begin or end will be NaN if they were provided as negative numbers and
  1186. // this collection's size is unknown. In that case, cache first so there is
  1187. // a known size and these do not resolve to NaN.
  1188. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  1189. return sliceFactory(collection.toSeq().cacheResult(), begin, end, useKeys);
  1190. }
  1191. // Note: resolvedEnd is undefined when the original sequence's length is
  1192. // unknown and this slice did not supply an end and should contain all
  1193. // elements after resolvedBegin.
  1194. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  1195. var resolvedSize = resolvedEnd - resolvedBegin;
  1196. var sliceSize;
  1197. if (resolvedSize === resolvedSize) {
  1198. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  1199. }
  1200. var sliceSeq = makeSequence(collection);
  1201. // If collection.size is undefined, the size of the realized sliceSeq is
  1202. // unknown at this point unless the number of items to slice is 0
  1203. sliceSeq.size =
  1204. sliceSize === 0 ? sliceSize : (collection.size && sliceSize) || undefined;
  1205. if (!useKeys && isSeq(collection) && sliceSize >= 0) {
  1206. sliceSeq.get = function(index, notSetValue) {
  1207. index = wrapIndex(this, index);
  1208. return index >= 0 && index < sliceSize
  1209. ? collection.get(index + resolvedBegin, notSetValue)
  1210. : notSetValue;
  1211. };
  1212. }
  1213. sliceSeq.__iterateUncached = function(fn, reverse) {
  1214. var this$1 = this;
  1215. if (sliceSize === 0) {
  1216. return 0;
  1217. }
  1218. if (reverse) {
  1219. return this.cacheResult().__iterate(fn, reverse);
  1220. }
  1221. var skipped = 0;
  1222. var isSkipping = true;
  1223. var iterations = 0;
  1224. collection.__iterate(function (v, k) {
  1225. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  1226. iterations++;
  1227. return (
  1228. fn(v, useKeys ? k : iterations - 1, this$1) !== false &&
  1229. iterations !== sliceSize
  1230. );
  1231. }
  1232. });
  1233. return iterations;
  1234. };
  1235. sliceSeq.__iteratorUncached = function(type, reverse) {
  1236. if (sliceSize !== 0 && reverse) {
  1237. return this.cacheResult().__iterator(type, reverse);
  1238. }
  1239. // Don't bother instantiating parent iterator if taking 0.
  1240. if (sliceSize === 0) {
  1241. return new Iterator(iteratorDone);
  1242. }
  1243. var iterator = collection.__iterator(type, reverse);
  1244. var skipped = 0;
  1245. var iterations = 0;
  1246. return new Iterator(function () {
  1247. while (skipped++ < resolvedBegin) {
  1248. iterator.next();
  1249. }
  1250. if (++iterations > sliceSize) {
  1251. return iteratorDone();
  1252. }
  1253. var step = iterator.next();
  1254. if (useKeys || type === ITERATE_VALUES || step.done) {
  1255. return step;
  1256. }
  1257. if (type === ITERATE_KEYS) {
  1258. return iteratorValue(type, iterations - 1, undefined, step);
  1259. }
  1260. return iteratorValue(type, iterations - 1, step.value[1], step);
  1261. });
  1262. };
  1263. return sliceSeq;
  1264. }
  1265. function takeWhileFactory(collection, predicate, context) {
  1266. var takeSequence = makeSequence(collection);
  1267. takeSequence.__iterateUncached = function(fn, reverse) {
  1268. var this$1 = this;
  1269. if (reverse) {
  1270. return this.cacheResult().__iterate(fn, reverse);
  1271. }
  1272. var iterations = 0;
  1273. collection.__iterate(
  1274. function (v, k, c) { return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$1); }
  1275. );
  1276. return iterations;
  1277. };
  1278. takeSequence.__iteratorUncached = function(type, reverse) {
  1279. var this$1 = this;
  1280. if (reverse) {
  1281. return this.cacheResult().__iterator(type, reverse);
  1282. }
  1283. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1284. var iterating = true;
  1285. return new Iterator(function () {
  1286. if (!iterating) {
  1287. return iteratorDone();
  1288. }
  1289. var step = iterator.next();
  1290. if (step.done) {
  1291. return step;
  1292. }
  1293. var entry = step.value;
  1294. var k = entry[0];
  1295. var v = entry[1];
  1296. if (!predicate.call(context, v, k, this$1)) {
  1297. iterating = false;
  1298. return iteratorDone();
  1299. }
  1300. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  1301. });
  1302. };
  1303. return takeSequence;
  1304. }
  1305. function skipWhileFactory(collection, predicate, context, useKeys) {
  1306. var skipSequence = makeSequence(collection);
  1307. skipSequence.__iterateUncached = function(fn, reverse) {
  1308. var this$1 = this;
  1309. if (reverse) {
  1310. return this.cacheResult().__iterate(fn, reverse);
  1311. }
  1312. var isSkipping = true;
  1313. var iterations = 0;
  1314. collection.__iterate(function (v, k, c) {
  1315. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  1316. iterations++;
  1317. return fn(v, useKeys ? k : iterations - 1, this$1);
  1318. }
  1319. });
  1320. return iterations;
  1321. };
  1322. skipSequence.__iteratorUncached = function(type, reverse) {
  1323. var this$1 = this;
  1324. if (reverse) {
  1325. return this.cacheResult().__iterator(type, reverse);
  1326. }
  1327. var iterator = collection.__iterator(ITERATE_ENTRIES, reverse);
  1328. var skipping = true;
  1329. var iterations = 0;
  1330. return new Iterator(function () {
  1331. var step;
  1332. var k;
  1333. var v;
  1334. do {
  1335. step = iterator.next();
  1336. if (step.done) {
  1337. if (useKeys || type === ITERATE_VALUES) {
  1338. return step;
  1339. }
  1340. if (type === ITERATE_KEYS) {
  1341. return iteratorValue(type, iterations++, undefined, step);
  1342. }
  1343. return iteratorValue(type, iterations++, step.value[1], step);
  1344. }
  1345. var entry = step.value;
  1346. k = entry[0];
  1347. v = entry[1];
  1348. skipping && (skipping = predicate.call(context, v, k, this$1));
  1349. } while (skipping);
  1350. return type === ITERATE_ENTRIES ? step : iteratorValue(type, k, v, step);
  1351. });
  1352. };
  1353. return skipSequence;
  1354. }
  1355. function concatFactory(collection, values) {
  1356. var isKeyedCollection = isKeyed(collection);
  1357. var iters = [collection]
  1358. .concat(values)
  1359. .map(function (v) {
  1360. if (!isCollection(v)) {
  1361. v = isKeyedCollection
  1362. ? keyedSeqFromValue(v)
  1363. : indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  1364. } else if (isKeyedCollection) {
  1365. v = KeyedCollection(v);
  1366. }
  1367. return v;
  1368. })
  1369. .filter(function (v) { return v.size !== 0; });
  1370. if (iters.length === 0) {
  1371. return collection;
  1372. }
  1373. if (iters.length === 1) {
  1374. var singleton = iters[0];
  1375. if (
  1376. singleton === collection ||
  1377. (isKeyedCollection && isKeyed(singleton)) ||
  1378. (isIndexed(collection) && isIndexed(singleton))
  1379. ) {
  1380. return singleton;
  1381. }
  1382. }
  1383. var concatSeq = new ArraySeq(iters);
  1384. if (isKeyedCollection) {
  1385. concatSeq = concatSeq.toKeyedSeq();
  1386. } else if (!isIndexed(collection)) {
  1387. concatSeq = concatSeq.toSetSeq();
  1388. }
  1389. concatSeq = concatSeq.flatten(true);
  1390. concatSeq.size = iters.reduce(function (sum, seq) {
  1391. if (sum !== undefined) {
  1392. var size = seq.size;
  1393. if (size !== undefined) {
  1394. return sum + size;
  1395. }
  1396. }
  1397. }, 0);
  1398. return concatSeq;
  1399. }
  1400. function flattenFactory(collection, depth, useKeys) {
  1401. var flatSequence = makeSequence(collection);
  1402. flatSequence.__iterateUncached = function(fn, reverse) {
  1403. if (reverse) {
  1404. return this.cacheResult().__iterate(fn, reverse);
  1405. }
  1406. var iterations = 0;
  1407. var stopped = false;
  1408. function flatDeep(iter, currentDepth) {
  1409. iter.__iterate(function (v, k) {
  1410. if ((!depth || currentDepth < depth) && isCollection(v)) {
  1411. flatDeep(v, currentDepth + 1);
  1412. } else {
  1413. iterations++;
  1414. if (fn(v, useKeys ? k : iterations - 1, flatSequence) === false) {
  1415. stopped = true;
  1416. }
  1417. }
  1418. return !stopped;
  1419. }, reverse);
  1420. }
  1421. flatDeep(collection, 0);
  1422. return iterations;
  1423. };
  1424. flatSequence.__iteratorUncached = function(type, reverse) {
  1425. if (reverse) {
  1426. return this.cacheResult().__iterator(type, reverse);
  1427. }
  1428. var iterator = collection.__iterator(type, reverse);
  1429. var stack = [];
  1430. var iterations = 0;
  1431. return new Iterator(function () {
  1432. while (iterator) {
  1433. var step = iterator.next();
  1434. if (step.done !== false) {
  1435. iterator = stack.pop();
  1436. continue;
  1437. }
  1438. var v = step.value;
  1439. if (type === ITERATE_ENTRIES) {
  1440. v = v[1];
  1441. }
  1442. if ((!depth || stack.length < depth) && isCollection(v)) {
  1443. stack.push(iterator);
  1444. iterator = v.__iterator(type, reverse);
  1445. } else {
  1446. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  1447. }
  1448. }
  1449. return iteratorDone();
  1450. });
  1451. };
  1452. return flatSequence;
  1453. }
  1454. function flatMapFactory(collection, mapper, context) {
  1455. var coerce = collectionClass(collection);
  1456. return collection
  1457. .toSeq()
  1458. .map(function (v, k) { return coerce(mapper.call(context, v, k, collection)); })
  1459. .flatten(true);
  1460. }
  1461. function interposeFactory(collection, separator) {
  1462. var interposedSequence = makeSequence(collection);
  1463. interposedSequence.size = collection.size && collection.size * 2 - 1;
  1464. interposedSequence.__iterateUncached = function(fn, reverse) {
  1465. var this$1 = this;
  1466. var iterations = 0;
  1467. collection.__iterate(
  1468. function (v) { return (!iterations || fn(separator, iterations++, this$1) !== false) &&
  1469. fn(v, iterations++, this$1) !== false; },
  1470. reverse
  1471. );
  1472. return iterations;
  1473. };
  1474. interposedSequence.__iteratorUncached = function(type, reverse) {
  1475. var iterator = collection.__iterator(ITERATE_VALUES, reverse);
  1476. var iterations = 0;
  1477. var step;
  1478. return new Iterator(function () {
  1479. if (!step || iterations % 2) {
  1480. step = iterator.next();
  1481. if (step.done) {
  1482. return step;
  1483. }
  1484. }
  1485. return iterations % 2
  1486. ? iteratorValue(type, iterations++, separator)
  1487. : iteratorValue(type, iterations++, step.value, step);
  1488. });
  1489. };
  1490. return interposedSequence;
  1491. }
  1492. function sortFactory(collection, comparator, mapper) {
  1493. if (!comparator) {
  1494. comparator = defaultComparator;
  1495. }
  1496. var isKeyedCollection = isKeyed(collection);
  1497. var index = 0;
  1498. var entries = collection
  1499. .toSeq()
  1500. .map(function (v, k) { return [k, v, index++, mapper ? mapper(v, k, collection) : v]; })
  1501. .valueSeq()
  1502. .toArray();
  1503. entries.sort(function (a, b) { return comparator(a[3], b[3]) || a[2] - b[2]; }).forEach(
  1504. isKeyedCollection
  1505. ? function (v, i) {
  1506. entries[i].length = 2;
  1507. }
  1508. : function (v, i) {
  1509. entries[i] = v[1];
  1510. }
  1511. );
  1512. return isKeyedCollection
  1513. ? KeyedSeq(entries)
  1514. : isIndexed(collection)
  1515. ? IndexedSeq(entries)
  1516. : SetSeq(entries);
  1517. }
  1518. function maxFactory(collection, comparator, mapper) {
  1519. if (!comparator) {
  1520. comparator = defaultComparator;
  1521. }
  1522. if (mapper) {
  1523. var entry = collection
  1524. .toSeq()
  1525. .map(function (v, k) { return [v, mapper(v, k, collection)]; })
  1526. .reduce(function (a, b) { return (maxCompare(comparator, a[1], b[1]) ? b : a); });
  1527. return entry && entry[0];
  1528. }
  1529. return collection.reduce(function (a, b) { return (maxCompare(comparator, a, b) ? b : a); });
  1530. }
  1531. function maxCompare(comparator, a, b) {
  1532. var comp = comparator(b, a);
  1533. // b is considered the new max if the comparator declares them equal, but
  1534. // they are not equal and b is in fact a nullish value.
  1535. return (
  1536. (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) ||
  1537. comp > 0
  1538. );
  1539. }
  1540. function zipWithFactory(keyIter, zipper, iters, zipAll) {
  1541. var zipSequence = makeSequence(keyIter);
  1542. var sizes = new ArraySeq(iters).map(function (i) { return i.size; });
  1543. zipSequence.size = zipAll ? sizes.max() : sizes.min();
  1544. // Note: this a generic base implementation of __iterate in terms of
  1545. // __iterator which may be more generically useful in the future.
  1546. zipSequence.__iterate = function(fn, reverse) {
  1547. /* generic:
  1548. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  1549. var step;
  1550. var iterations = 0;
  1551. while (!(step = iterator.next()).done) {
  1552. iterations++;
  1553. if (fn(step.value[1], step.value[0], this) === false) {
  1554. break;
  1555. }
  1556. }
  1557. return iterations;
  1558. */
  1559. // indexed:
  1560. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  1561. var step;
  1562. var iterations = 0;
  1563. while (!(step = iterator.next()).done) {
  1564. if (fn(step.value, iterations++, this) === false) {
  1565. break;
  1566. }
  1567. }
  1568. return iterations;
  1569. };
  1570. zipSequence.__iteratorUncached = function(type, reverse) {
  1571. var iterators = iters.map(
  1572. function (i) { return ((i = Collection(i)), getIterator(reverse ? i.reverse() : i)); }
  1573. );
  1574. var iterations = 0;
  1575. var isDone = false;
  1576. return new Iterator(function () {
  1577. var steps;
  1578. if (!isDone) {
  1579. steps = iterators.map(function (i) { return i.next(); });
  1580. isDone = zipAll ? steps.every(function (s) { return s.done; }) : steps.some(function (s) { return s.done; });
  1581. }
  1582. if (isDone) {
  1583. return iteratorDone();
  1584. }
  1585. return iteratorValue(
  1586. type,
  1587. iterations++,
  1588. zipper.apply(null, steps.map(function (s) { return s.value; }))
  1589. );
  1590. });
  1591. };
  1592. return zipSequence;
  1593. }
  1594. // #pragma Helper Functions
  1595. function reify(iter, seq) {
  1596. return iter === seq ? iter : isSeq(iter) ? seq : iter.constructor(seq);
  1597. }
  1598. function validateEntry(entry) {
  1599. if (entry !== Object(entry)) {
  1600. throw new TypeError('Expected [K, V] tuple: ' + entry);
  1601. }
  1602. }
  1603. function collectionClass(collection) {
  1604. return isKeyed(collection)
  1605. ? KeyedCollection
  1606. : isIndexed(collection)
  1607. ? IndexedCollection
  1608. : SetCollection;
  1609. }
  1610. function makeSequence(collection) {
  1611. return Object.create(
  1612. (isKeyed(collection)
  1613. ? KeyedSeq
  1614. : isIndexed(collection)
  1615. ? IndexedSeq
  1616. : SetSeq
  1617. ).prototype
  1618. );
  1619. }
  1620. function cacheResultThrough() {
  1621. if (this._iter.cacheResult) {
  1622. this._iter.cacheResult();
  1623. this.size = this._iter.size;
  1624. return this;
  1625. }
  1626. return Seq.prototype.cacheResult.call(this);
  1627. }
  1628. function defaultComparator(a, b) {
  1629. if (a === undefined && b === undefined) {
  1630. return 0;
  1631. }
  1632. if (a === undefined) {
  1633. return 1;
  1634. }
  1635. if (b === undefined) {
  1636. return -1;
  1637. }
  1638. return a > b ? 1 : a < b ? -1 : 0;
  1639. }
  1640. // http://jsperf.com/copy-array-inline
  1641. function arrCopy(arr, offset) {
  1642. offset = offset || 0;
  1643. var len = Math.max(0, arr.length - offset);
  1644. var newArr = new Array(len);
  1645. for (var ii = 0; ii < len; ii++) {
  1646. newArr[ii] = arr[ii + offset];
  1647. }
  1648. return newArr;
  1649. }
  1650. function invariant(condition, error) {
  1651. if (!condition) { throw new Error(error); }
  1652. }
  1653. function assertNotInfinite(size) {
  1654. invariant(
  1655. size !== Infinity,
  1656. 'Cannot perform this action with an infinite size.'
  1657. );
  1658. }
  1659. function coerceKeyPath(keyPath) {
  1660. if (isArrayLike(keyPath) && typeof keyPath !== 'string') {
  1661. return keyPath;
  1662. }
  1663. if (isOrdered(keyPath)) {
  1664. return keyPath.toArray();
  1665. }
  1666. throw new TypeError(
  1667. 'Invalid keyPath: expected Ordered Collection or Array: ' + keyPath
  1668. );
  1669. }
  1670. function isPlainObj(value) {
  1671. return (
  1672. value &&
  1673. (typeof value.constructor !== 'function' ||
  1674. value.constructor.name === 'Object')
  1675. );
  1676. }
  1677. /**
  1678. * Returns true if the value is a potentially-persistent data structure, either
  1679. * provided by Immutable.js or a plain Array or Object.
  1680. */
  1681. function isDataStructure(value) {
  1682. return (
  1683. typeof value === 'object' &&
  1684. (isImmutable(value) || Array.isArray(value) || isPlainObj(value))
  1685. );
  1686. }
  1687. /**
  1688. * Converts a value to a string, adding quotes if a string was provided.
  1689. */
  1690. function quoteString(value) {
  1691. try {
  1692. return typeof value === 'string' ? JSON.stringify(value) : String(value);
  1693. } catch (_ignoreError) {
  1694. return JSON.stringify(value);
  1695. }
  1696. }
  1697. function has(collection, key) {
  1698. return isImmutable(collection)
  1699. ? collection.has(key)
  1700. : isDataStructure(collection) && hasOwnProperty.call(collection, key);
  1701. }
  1702. function get(collection, key, notSetValue) {
  1703. return isImmutable(collection)
  1704. ? collection.get(key, notSetValue)
  1705. : !has(collection, key)
  1706. ? notSetValue
  1707. : typeof collection.get === 'function'
  1708. ? collection.get(key)
  1709. : collection[key];
  1710. }
  1711. function shallowCopy(from) {
  1712. if (Array.isArray(from)) {
  1713. return arrCopy(from);
  1714. }
  1715. var to = {};
  1716. for (var key in from) {
  1717. if (hasOwnProperty.call(from, key)) {
  1718. to[key] = from[key];
  1719. }
  1720. }
  1721. return to;
  1722. }
  1723. function remove(collection, key) {
  1724. if (!isDataStructure(collection)) {
  1725. throw new TypeError(
  1726. 'Cannot update non-data-structure value: ' + collection
  1727. );
  1728. }
  1729. if (isImmutable(collection)) {
  1730. if (!collection.remove) {
  1731. throw new TypeError(
  1732. 'Cannot update immutable value without .remove() method: ' + collection
  1733. );
  1734. }
  1735. return collection.remove(key);
  1736. }
  1737. if (!hasOwnProperty.call(collection, key)) {
  1738. return collection;
  1739. }
  1740. var collectionCopy = shallowCopy(collection);
  1741. if (Array.isArray(collectionCopy)) {
  1742. collectionCopy.splice(key, 1);
  1743. } else {
  1744. delete collectionCopy[key];
  1745. }
  1746. return collectionCopy;
  1747. }
  1748. function set(collection, key, value) {
  1749. if (!isDataStructure(collection)) {
  1750. throw new TypeError(
  1751. 'Cannot update non-data-structure value: ' + collection
  1752. );
  1753. }
  1754. if (isImmutable(collection)) {
  1755. if (!collection.set) {
  1756. throw new TypeError(
  1757. 'Cannot update immutable value without .set() method: ' + collection
  1758. );
  1759. }
  1760. return collection.set(key, value);
  1761. }
  1762. if (hasOwnProperty.call(collection, key) && value === collection[key]) {
  1763. return collection;
  1764. }
  1765. var collectionCopy = shallowCopy(collection);
  1766. collectionCopy[key] = value;
  1767. return collectionCopy;
  1768. }
  1769. function updateIn(collection, keyPath, notSetValue, updater) {
  1770. if (!updater) {
  1771. updater = notSetValue;
  1772. notSetValue = undefined;
  1773. }
  1774. var updatedValue = updateInDeeply(
  1775. isImmutable(collection),
  1776. collection,
  1777. coerceKeyPath(keyPath),
  1778. 0,
  1779. notSetValue,
  1780. updater
  1781. );
  1782. return updatedValue === NOT_SET ? notSetValue : updatedValue;
  1783. }
  1784. function updateInDeeply(
  1785. inImmutable,
  1786. existing,
  1787. keyPath,
  1788. i,
  1789. notSetValue,
  1790. updater
  1791. ) {
  1792. var wasNotSet = existing === NOT_SET;
  1793. if (i === keyPath.length) {
  1794. var existingValue = wasNotSet ? notSetValue : existing;
  1795. var newValue = updater(existingValue);
  1796. return newValue === existingValue ? existing : newValue;
  1797. }
  1798. if (!wasNotSet && !isDataStructure(existing)) {
  1799. throw new TypeError(
  1800. 'Cannot update within non-data-structure value in path [' +
  1801. keyPath.slice(0, i).map(quoteString) +
  1802. ']: ' +
  1803. existing
  1804. );
  1805. }
  1806. var key = keyPath[i];
  1807. var nextExisting = wasNotSet ? NOT_SET : get(existing, key, NOT_SET);
  1808. var nextUpdated = updateInDeeply(
  1809. nextExisting === NOT_SET ? inImmutable : isImmutable(nextExisting),
  1810. nextExisting,
  1811. keyPath,
  1812. i + 1,
  1813. notSetValue,
  1814. updater
  1815. );
  1816. return nextUpdated === nextExisting
  1817. ? existing
  1818. : nextUpdated === NOT_SET
  1819. ? remove(existing, key)
  1820. : set(
  1821. wasNotSet ? (inImmutable ? emptyMap() : {}) : existing,
  1822. key,
  1823. nextUpdated
  1824. );
  1825. }
  1826. function setIn(collection, keyPath, value) {
  1827. return updateIn(collection, keyPath, NOT_SET, function () { return value; });
  1828. }
  1829. function setIn$1(keyPath, v) {
  1830. return setIn(this, keyPath, v);
  1831. }
  1832. function removeIn(collection, keyPath) {
  1833. return updateIn(collection, keyPath, function () { return NOT_SET; });
  1834. }
  1835. function deleteIn(keyPath) {
  1836. return removeIn(this, keyPath);
  1837. }
  1838. function update(collection, key, notSetValue, updater) {
  1839. return updateIn(collection, [key], notSetValue, updater);
  1840. }
  1841. function update$1(key, notSetValue, updater) {
  1842. return arguments.length === 1
  1843. ? key(this)
  1844. : update(this, key, notSetValue, updater);
  1845. }
  1846. function updateIn$1(keyPath, notSetValue, updater) {
  1847. return updateIn(this, keyPath, notSetValue, updater);
  1848. }
  1849. function merge() {
  1850. var iters = [], len = arguments.length;
  1851. while ( len-- ) iters[ len ] = arguments[ len ];
  1852. return mergeIntoKeyedWith(this, iters);
  1853. }
  1854. function mergeWith(merger) {
  1855. var iters = [], len = arguments.length - 1;
  1856. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  1857. if (typeof merger !== 'function') {
  1858. throw new TypeError('Invalid merger function: ' + merger);
  1859. }
  1860. return mergeIntoKeyedWith(this, iters, merger);
  1861. }
  1862. function mergeIntoKeyedWith(collection, collections, merger) {
  1863. var iters = [];
  1864. for (var ii = 0; ii < collections.length; ii++) {
  1865. var collection$1 = KeyedCollection(collections[ii]);
  1866. if (collection$1.size !== 0) {
  1867. iters.push(collection$1);
  1868. }
  1869. }
  1870. if (iters.length === 0) {
  1871. return collection;
  1872. }
  1873. if (
  1874. collection.toSeq().size === 0 &&
  1875. !collection.__ownerID &&
  1876. iters.length === 1
  1877. ) {
  1878. return collection.constructor(iters[0]);
  1879. }
  1880. return collection.withMutations(function (collection) {
  1881. var mergeIntoCollection = merger
  1882. ? function (value, key) {
  1883. update(
  1884. collection,
  1885. key,
  1886. NOT_SET,
  1887. function (oldVal) { return (oldVal === NOT_SET ? value : merger(oldVal, value, key)); }
  1888. );
  1889. }
  1890. : function (value, key) {
  1891. collection.set(key, value);
  1892. };
  1893. for (var ii = 0; ii < iters.length; ii++) {
  1894. iters[ii].forEach(mergeIntoCollection);
  1895. }
  1896. });
  1897. }
  1898. function merge$1(collection) {
  1899. var sources = [], len = arguments.length - 1;
  1900. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  1901. return mergeWithSources(collection, sources);
  1902. }
  1903. function mergeWith$1(merger, collection) {
  1904. var sources = [], len = arguments.length - 2;
  1905. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  1906. return mergeWithSources(collection, sources, merger);
  1907. }
  1908. function mergeDeep(collection) {
  1909. var sources = [], len = arguments.length - 1;
  1910. while ( len-- > 0 ) sources[ len ] = arguments[ len + 1 ];
  1911. return mergeDeepWithSources(collection, sources);
  1912. }
  1913. function mergeDeepWith(merger, collection) {
  1914. var sources = [], len = arguments.length - 2;
  1915. while ( len-- > 0 ) sources[ len ] = arguments[ len + 2 ];
  1916. return mergeDeepWithSources(collection, sources, merger);
  1917. }
  1918. function mergeDeepWithSources(collection, sources, merger) {
  1919. return mergeWithSources(collection, sources, deepMergerWith(merger));
  1920. }
  1921. function mergeWithSources(collection, sources, merger) {
  1922. if (!isDataStructure(collection)) {
  1923. throw new TypeError(
  1924. 'Cannot merge into non-data-structure value: ' + collection
  1925. );
  1926. }
  1927. if (isImmutable(collection)) {
  1928. return typeof merger === 'function' && collection.mergeWith
  1929. ? collection.mergeWith.apply(collection, [ merger ].concat( sources ))
  1930. : collection.merge
  1931. ? collection.merge.apply(collection, sources)
  1932. : collection.concat.apply(collection, sources);
  1933. }
  1934. var isArray = Array.isArray(collection);
  1935. var merged = collection;
  1936. var Collection$$1 = isArray ? IndexedCollection : KeyedCollection;
  1937. var mergeItem = isArray
  1938. ? function (value) {
  1939. // Copy on write
  1940. if (merged === collection) {
  1941. merged = shallowCopy(merged);
  1942. }
  1943. merged.push(value);
  1944. }
  1945. : function (value, key) {
  1946. var hasVal = hasOwnProperty.call(merged, key);
  1947. var nextVal =
  1948. hasVal && merger ? merger(merged[key], value, key) : value;
  1949. if (!hasVal || nextVal !== merged[key]) {
  1950. // Copy on write
  1951. if (merged === collection) {
  1952. merged = shallowCopy(merged);
  1953. }
  1954. merged[key] = nextVal;
  1955. }
  1956. };
  1957. for (var i = 0; i < sources.length; i++) {
  1958. Collection$$1(sources[i]).forEach(mergeItem);
  1959. }
  1960. return merged;
  1961. }
  1962. function deepMergerWith(merger) {
  1963. function deepMerger(oldValue, newValue, key) {
  1964. return isDataStructure(oldValue) && isDataStructure(newValue)
  1965. ? mergeWithSources(oldValue, [newValue], deepMerger)
  1966. : merger
  1967. ? merger(oldValue, newValue, key)
  1968. : newValue;
  1969. }
  1970. return deepMerger;
  1971. }
  1972. function mergeDeep$1() {
  1973. var iters = [], len = arguments.length;
  1974. while ( len-- ) iters[ len ] = arguments[ len ];
  1975. return mergeDeepWithSources(this, iters);
  1976. }
  1977. function mergeDeepWith$1(merger) {
  1978. var iters = [], len = arguments.length - 1;
  1979. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  1980. return mergeDeepWithSources(this, iters, merger);
  1981. }
  1982. function mergeIn(keyPath) {
  1983. var iters = [], len = arguments.length - 1;
  1984. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  1985. return updateIn(this, keyPath, emptyMap(), function (m) { return mergeWithSources(m, iters); });
  1986. }
  1987. function mergeDeepIn(keyPath) {
  1988. var iters = [], len = arguments.length - 1;
  1989. while ( len-- > 0 ) iters[ len ] = arguments[ len + 1 ];
  1990. return updateIn(this, keyPath, emptyMap(), function (m) { return mergeDeepWithSources(m, iters); }
  1991. );
  1992. }
  1993. function withMutations(fn) {
  1994. var mutable = this.asMutable();
  1995. fn(mutable);
  1996. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  1997. }
  1998. function asMutable() {
  1999. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  2000. }
  2001. function asImmutable() {
  2002. return this.__ensureOwner();
  2003. }
  2004. function wasAltered() {
  2005. return this.__altered;
  2006. }
  2007. var Map = /*@__PURE__*/(function (KeyedCollection$$1) {
  2008. function Map(value) {
  2009. return value === null || value === undefined
  2010. ? emptyMap()
  2011. : isMap(value) && !isOrdered(value)
  2012. ? value
  2013. : emptyMap().withMutations(function (map) {
  2014. var iter = KeyedCollection$$1(value);
  2015. assertNotInfinite(iter.size);
  2016. iter.forEach(function (v, k) { return map.set(k, v); });
  2017. });
  2018. }
  2019. if ( KeyedCollection$$1 ) Map.__proto__ = KeyedCollection$$1;
  2020. Map.prototype = Object.create( KeyedCollection$$1 && KeyedCollection$$1.prototype );
  2021. Map.prototype.constructor = Map;
  2022. Map.of = function of () {
  2023. var keyValues = [], len = arguments.length;
  2024. while ( len-- ) keyValues[ len ] = arguments[ len ];
  2025. return emptyMap().withMutations(function (map) {
  2026. for (var i = 0; i < keyValues.length; i += 2) {
  2027. if (i + 1 >= keyValues.length) {
  2028. throw new Error('Missing value for key: ' + keyValues[i]);
  2029. }
  2030. map.set(keyValues[i], keyValues[i + 1]);
  2031. }
  2032. });
  2033. };
  2034. Map.prototype.toString = function toString () {
  2035. return this.__toString('Map {', '}');
  2036. };
  2037. // @pragma Access
  2038. Map.prototype.get = function get (k, notSetValue) {
  2039. return this._root
  2040. ? this._root.get(0, undefined, k, notSetValue)
  2041. : notSetValue;
  2042. };
  2043. // @pragma Modification
  2044. Map.prototype.set = function set (k, v) {
  2045. return updateMap(this, k, v);
  2046. };
  2047. Map.prototype.remove = function remove (k) {
  2048. return updateMap(this, k, NOT_SET);
  2049. };
  2050. Map.prototype.deleteAll = function deleteAll (keys) {
  2051. var collection = Collection(keys);
  2052. if (collection.size === 0) {
  2053. return this;
  2054. }
  2055. return this.withMutations(function (map) {
  2056. collection.forEach(function (key) { return map.remove(key); });
  2057. });
  2058. };
  2059. Map.prototype.clear = function clear () {
  2060. if (this.size === 0) {
  2061. return this;
  2062. }
  2063. if (this.__ownerID) {
  2064. this.size = 0;
  2065. this._root = null;
  2066. this.__hash = undefined;
  2067. this.__altered = true;
  2068. return this;
  2069. }
  2070. return emptyMap();
  2071. };
  2072. // @pragma Composition
  2073. Map.prototype.sort = function sort (comparator) {
  2074. // Late binding
  2075. return OrderedMap(sortFactory(this, comparator));
  2076. };
  2077. Map.prototype.sortBy = function sortBy (mapper, comparator) {
  2078. // Late binding
  2079. return OrderedMap(sortFactory(this, comparator, mapper));
  2080. };
  2081. Map.prototype.map = function map (mapper, context) {
  2082. return this.withMutations(function (map) {
  2083. map.forEach(function (value, key) {
  2084. map.set(key, mapper.call(context, value, key, map));
  2085. });
  2086. });
  2087. };
  2088. // @pragma Mutability
  2089. Map.prototype.__iterator = function __iterator (type, reverse) {
  2090. return new MapIterator(this, type, reverse);
  2091. };
  2092. Map.prototype.__iterate = function __iterate (fn, reverse) {
  2093. var this$1 = this;
  2094. var iterations = 0;
  2095. this._root &&
  2096. this._root.iterate(function (entry) {
  2097. iterations++;
  2098. return fn(entry[1], entry[0], this$1);
  2099. }, reverse);
  2100. return iterations;
  2101. };
  2102. Map.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  2103. if (ownerID === this.__ownerID) {
  2104. return this;
  2105. }
  2106. if (!ownerID) {
  2107. if (this.size === 0) {
  2108. return emptyMap();
  2109. }
  2110. this.__ownerID = ownerID;
  2111. this.__altered = false;
  2112. return this;
  2113. }
  2114. return makeMap(this.size, this._root, ownerID, this.__hash);
  2115. };
  2116. return Map;
  2117. }(KeyedCollection));
  2118. Map.isMap = isMap;
  2119. var MapPrototype = Map.prototype;
  2120. MapPrototype[IS_MAP_SYMBOL] = true;
  2121. MapPrototype[DELETE] = MapPrototype.remove;
  2122. MapPrototype.removeAll = MapPrototype.deleteAll;
  2123. MapPrototype.setIn = setIn$1;
  2124. MapPrototype.removeIn = MapPrototype.deleteIn = deleteIn;
  2125. MapPrototype.update = update$1;
  2126. MapPrototype.updateIn = updateIn$1;
  2127. MapPrototype.merge = MapPrototype.concat = merge;
  2128. MapPrototype.mergeWith = mergeWith;
  2129. MapPrototype.mergeDeep = mergeDeep$1;
  2130. MapPrototype.mergeDeepWith = mergeDeepWith$1;
  2131. MapPrototype.mergeIn = mergeIn;
  2132. MapPrototype.mergeDeepIn = mergeDeepIn;
  2133. MapPrototype.withMutations = withMutations;
  2134. MapPrototype.wasAltered = wasAltered;
  2135. MapPrototype.asImmutable = asImmutable;
  2136. MapPrototype['@@transducer/init'] = MapPrototype.asMutable = asMutable;
  2137. MapPrototype['@@transducer/step'] = function(result, arr) {
  2138. return result.set(arr[0], arr[1]);
  2139. };
  2140. MapPrototype['@@transducer/result'] = function(obj) {
  2141. return obj.asImmutable();
  2142. };
  2143. // #pragma Trie Nodes
  2144. var ArrayMapNode = function ArrayMapNode(ownerID, entries) {
  2145. this.ownerID = ownerID;
  2146. this.entries = entries;
  2147. };
  2148. ArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2149. var entries = this.entries;
  2150. for (var ii = 0, len = entries.length; ii < len; ii++) {
  2151. if (is(key, entries[ii][0])) {
  2152. return entries[ii][1];
  2153. }
  2154. }
  2155. return notSetValue;
  2156. };
  2157. ArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2158. var removed = value === NOT_SET;
  2159. var entries = this.entries;
  2160. var idx = 0;
  2161. var len = entries.length;
  2162. for (; idx < len; idx++) {
  2163. if (is(key, entries[idx][0])) {
  2164. break;
  2165. }
  2166. }
  2167. var exists = idx < len;
  2168. if (exists ? entries[idx][1] === value : removed) {
  2169. return this;
  2170. }
  2171. SetRef(didAlter);
  2172. (removed || !exists) && SetRef(didChangeSize);
  2173. if (removed && entries.length === 1) {
  2174. return; // undefined
  2175. }
  2176. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  2177. return createNodes(ownerID, entries, key, value);
  2178. }
  2179. var isEditable = ownerID && ownerID === this.ownerID;
  2180. var newEntries = isEditable ? entries : arrCopy(entries);
  2181. if (exists) {
  2182. if (removed) {
  2183. idx === len - 1
  2184. ? newEntries.pop()
  2185. : (newEntries[idx] = newEntries.pop());
  2186. } else {
  2187. newEntries[idx] = [key, value];
  2188. }
  2189. } else {
  2190. newEntries.push([key, value]);
  2191. }
  2192. if (isEditable) {
  2193. this.entries = newEntries;
  2194. return this;
  2195. }
  2196. return new ArrayMapNode(ownerID, newEntries);
  2197. };
  2198. var BitmapIndexedNode = function BitmapIndexedNode(ownerID, bitmap, nodes) {
  2199. this.ownerID = ownerID;
  2200. this.bitmap = bitmap;
  2201. this.nodes = nodes;
  2202. };
  2203. BitmapIndexedNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2204. if (keyHash === undefined) {
  2205. keyHash = hash(key);
  2206. }
  2207. var bit = 1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK);
  2208. var bitmap = this.bitmap;
  2209. return (bitmap & bit) === 0
  2210. ? notSetValue
  2211. : this.nodes[popCount(bitmap & (bit - 1))].get(
  2212. shift + SHIFT,
  2213. keyHash,
  2214. key,
  2215. notSetValue
  2216. );
  2217. };
  2218. BitmapIndexedNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2219. if (keyHash === undefined) {
  2220. keyHash = hash(key);
  2221. }
  2222. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2223. var bit = 1 << keyHashFrag;
  2224. var bitmap = this.bitmap;
  2225. var exists = (bitmap & bit) !== 0;
  2226. if (!exists && value === NOT_SET) {
  2227. return this;
  2228. }
  2229. var idx = popCount(bitmap & (bit - 1));
  2230. var nodes = this.nodes;
  2231. var node = exists ? nodes[idx] : undefined;
  2232. var newNode = updateNode(
  2233. node,
  2234. ownerID,
  2235. shift + SHIFT,
  2236. keyHash,
  2237. key,
  2238. value,
  2239. didChangeSize,
  2240. didAlter
  2241. );
  2242. if (newNode === node) {
  2243. return this;
  2244. }
  2245. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  2246. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  2247. }
  2248. if (
  2249. exists &&
  2250. !newNode &&
  2251. nodes.length === 2 &&
  2252. isLeafNode(nodes[idx ^ 1])
  2253. ) {
  2254. return nodes[idx ^ 1];
  2255. }
  2256. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  2257. return newNode;
  2258. }
  2259. var isEditable = ownerID && ownerID === this.ownerID;
  2260. var newBitmap = exists ? (newNode ? bitmap : bitmap ^ bit) : bitmap | bit;
  2261. var newNodes = exists
  2262. ? newNode
  2263. ? setAt(nodes, idx, newNode, isEditable)
  2264. : spliceOut(nodes, idx, isEditable)
  2265. : spliceIn(nodes, idx, newNode, isEditable);
  2266. if (isEditable) {
  2267. this.bitmap = newBitmap;
  2268. this.nodes = newNodes;
  2269. return this;
  2270. }
  2271. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  2272. };
  2273. var HashArrayMapNode = function HashArrayMapNode(ownerID, count, nodes) {
  2274. this.ownerID = ownerID;
  2275. this.count = count;
  2276. this.nodes = nodes;
  2277. };
  2278. HashArrayMapNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2279. if (keyHash === undefined) {
  2280. keyHash = hash(key);
  2281. }
  2282. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2283. var node = this.nodes[idx];
  2284. return node
  2285. ? node.get(shift + SHIFT, keyHash, key, notSetValue)
  2286. : notSetValue;
  2287. };
  2288. HashArrayMapNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2289. if (keyHash === undefined) {
  2290. keyHash = hash(key);
  2291. }
  2292. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2293. var removed = value === NOT_SET;
  2294. var nodes = this.nodes;
  2295. var node = nodes[idx];
  2296. if (removed && !node) {
  2297. return this;
  2298. }
  2299. var newNode = updateNode(
  2300. node,
  2301. ownerID,
  2302. shift + SHIFT,
  2303. keyHash,
  2304. key,
  2305. value,
  2306. didChangeSize,
  2307. didAlter
  2308. );
  2309. if (newNode === node) {
  2310. return this;
  2311. }
  2312. var newCount = this.count;
  2313. if (!node) {
  2314. newCount++;
  2315. } else if (!newNode) {
  2316. newCount--;
  2317. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  2318. return packNodes(ownerID, nodes, newCount, idx);
  2319. }
  2320. }
  2321. var isEditable = ownerID && ownerID === this.ownerID;
  2322. var newNodes = setAt(nodes, idx, newNode, isEditable);
  2323. if (isEditable) {
  2324. this.count = newCount;
  2325. this.nodes = newNodes;
  2326. return this;
  2327. }
  2328. return new HashArrayMapNode(ownerID, newCount, newNodes);
  2329. };
  2330. var HashCollisionNode = function HashCollisionNode(ownerID, keyHash, entries) {
  2331. this.ownerID = ownerID;
  2332. this.keyHash = keyHash;
  2333. this.entries = entries;
  2334. };
  2335. HashCollisionNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2336. var entries = this.entries;
  2337. for (var ii = 0, len = entries.length; ii < len; ii++) {
  2338. if (is(key, entries[ii][0])) {
  2339. return entries[ii][1];
  2340. }
  2341. }
  2342. return notSetValue;
  2343. };
  2344. HashCollisionNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2345. if (keyHash === undefined) {
  2346. keyHash = hash(key);
  2347. }
  2348. var removed = value === NOT_SET;
  2349. if (keyHash !== this.keyHash) {
  2350. if (removed) {
  2351. return this;
  2352. }
  2353. SetRef(didAlter);
  2354. SetRef(didChangeSize);
  2355. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  2356. }
  2357. var entries = this.entries;
  2358. var idx = 0;
  2359. var len = entries.length;
  2360. for (; idx < len; idx++) {
  2361. if (is(key, entries[idx][0])) {
  2362. break;
  2363. }
  2364. }
  2365. var exists = idx < len;
  2366. if (exists ? entries[idx][1] === value : removed) {
  2367. return this;
  2368. }
  2369. SetRef(didAlter);
  2370. (removed || !exists) && SetRef(didChangeSize);
  2371. if (removed && len === 2) {
  2372. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  2373. }
  2374. var isEditable = ownerID && ownerID === this.ownerID;
  2375. var newEntries = isEditable ? entries : arrCopy(entries);
  2376. if (exists) {
  2377. if (removed) {
  2378. idx === len - 1
  2379. ? newEntries.pop()
  2380. : (newEntries[idx] = newEntries.pop());
  2381. } else {
  2382. newEntries[idx] = [key, value];
  2383. }
  2384. } else {
  2385. newEntries.push([key, value]);
  2386. }
  2387. if (isEditable) {
  2388. this.entries = newEntries;
  2389. return this;
  2390. }
  2391. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  2392. };
  2393. var ValueNode = function ValueNode(ownerID, keyHash, entry) {
  2394. this.ownerID = ownerID;
  2395. this.keyHash = keyHash;
  2396. this.entry = entry;
  2397. };
  2398. ValueNode.prototype.get = function get (shift, keyHash, key, notSetValue) {
  2399. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  2400. };
  2401. ValueNode.prototype.update = function update (ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  2402. var removed = value === NOT_SET;
  2403. var keyMatch = is(key, this.entry[0]);
  2404. if (keyMatch ? value === this.entry[1] : removed) {
  2405. return this;
  2406. }
  2407. SetRef(didAlter);
  2408. if (removed) {
  2409. SetRef(didChangeSize);
  2410. return; // undefined
  2411. }
  2412. if (keyMatch) {
  2413. if (ownerID && ownerID === this.ownerID) {
  2414. this.entry[1] = value;
  2415. return this;
  2416. }
  2417. return new ValueNode(ownerID, this.keyHash, [key, value]);
  2418. }
  2419. SetRef(didChangeSize);
  2420. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  2421. };
  2422. // #pragma Iterators
  2423. ArrayMapNode.prototype.iterate = HashCollisionNode.prototype.iterate = function(
  2424. fn,
  2425. reverse
  2426. ) {
  2427. var entries = this.entries;
  2428. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  2429. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  2430. return false;
  2431. }
  2432. }
  2433. };
  2434. BitmapIndexedNode.prototype.iterate = HashArrayMapNode.prototype.iterate = function(
  2435. fn,
  2436. reverse
  2437. ) {
  2438. var nodes = this.nodes;
  2439. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  2440. var node = nodes[reverse ? maxIndex - ii : ii];
  2441. if (node && node.iterate(fn, reverse) === false) {
  2442. return false;
  2443. }
  2444. }
  2445. };
  2446. // eslint-disable-next-line no-unused-vars
  2447. ValueNode.prototype.iterate = function(fn, reverse) {
  2448. return fn(this.entry);
  2449. };
  2450. var MapIterator = /*@__PURE__*/(function (Iterator$$1) {
  2451. function MapIterator(map, type, reverse) {
  2452. this._type = type;
  2453. this._reverse = reverse;
  2454. this._stack = map._root && mapIteratorFrame(map._root);
  2455. }
  2456. if ( Iterator$$1 ) MapIterator.__proto__ = Iterator$$1;
  2457. MapIterator.prototype = Object.create( Iterator$$1 && Iterator$$1.prototype );
  2458. MapIterator.prototype.constructor = MapIterator;
  2459. MapIterator.prototype.next = function next () {
  2460. var type = this._type;
  2461. var stack = this._stack;
  2462. while (stack) {
  2463. var node = stack.node;
  2464. var index = stack.index++;
  2465. var maxIndex = (void 0);
  2466. if (node.entry) {
  2467. if (index === 0) {
  2468. return mapIteratorValue(type, node.entry);
  2469. }
  2470. } else if (node.entries) {
  2471. maxIndex = node.entries.length - 1;
  2472. if (index <= maxIndex) {
  2473. return mapIteratorValue(
  2474. type,
  2475. node.entries[this._reverse ? maxIndex - index : index]
  2476. );
  2477. }
  2478. } else {
  2479. maxIndex = node.nodes.length - 1;
  2480. if (index <= maxIndex) {
  2481. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  2482. if (subNode) {
  2483. if (subNode.entry) {
  2484. return mapIteratorValue(type, subNode.entry);
  2485. }
  2486. stack = this._stack = mapIteratorFrame(subNode, stack);
  2487. }
  2488. continue;
  2489. }
  2490. }
  2491. stack = this._stack = this._stack.__prev;
  2492. }
  2493. return iteratorDone();
  2494. };
  2495. return MapIterator;
  2496. }(Iterator));
  2497. function mapIteratorValue(type, entry) {
  2498. return iteratorValue(type, entry[0], entry[1]);
  2499. }
  2500. function mapIteratorFrame(node, prev) {
  2501. return {
  2502. node: node,
  2503. index: 0,
  2504. __prev: prev,
  2505. };
  2506. }
  2507. function makeMap(size, root, ownerID, hash$$1) {
  2508. var map = Object.create(MapPrototype);
  2509. map.size = size;
  2510. map._root = root;
  2511. map.__ownerID = ownerID;
  2512. map.__hash = hash$$1;
  2513. map.__altered = false;
  2514. return map;
  2515. }
  2516. var EMPTY_MAP;
  2517. function emptyMap() {
  2518. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  2519. }
  2520. function updateMap(map, k, v) {
  2521. var newRoot;
  2522. var newSize;
  2523. if (!map._root) {
  2524. if (v === NOT_SET) {
  2525. return map;
  2526. }
  2527. newSize = 1;
  2528. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  2529. } else {
  2530. var didChangeSize = MakeRef();
  2531. var didAlter = MakeRef();
  2532. newRoot = updateNode(
  2533. map._root,
  2534. map.__ownerID,
  2535. 0,
  2536. undefined,
  2537. k,
  2538. v,
  2539. didChangeSize,
  2540. didAlter
  2541. );
  2542. if (!didAlter.value) {
  2543. return map;
  2544. }
  2545. newSize = map.size + (didChangeSize.value ? (v === NOT_SET ? -1 : 1) : 0);
  2546. }
  2547. if (map.__ownerID) {
  2548. map.size = newSize;
  2549. map._root = newRoot;
  2550. map.__hash = undefined;
  2551. map.__altered = true;
  2552. return map;
  2553. }
  2554. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  2555. }
  2556. function updateNode(
  2557. node,
  2558. ownerID,
  2559. shift,
  2560. keyHash,
  2561. key,
  2562. value,
  2563. didChangeSize,
  2564. didAlter
  2565. ) {
  2566. if (!node) {
  2567. if (value === NOT_SET) {
  2568. return node;
  2569. }
  2570. SetRef(didAlter);
  2571. SetRef(didChangeSize);
  2572. return new ValueNode(ownerID, keyHash, [key, value]);
  2573. }
  2574. return node.update(
  2575. ownerID,
  2576. shift,
  2577. keyHash,
  2578. key,
  2579. value,
  2580. didChangeSize,
  2581. didAlter
  2582. );
  2583. }
  2584. function isLeafNode(node) {
  2585. return (
  2586. node.constructor === ValueNode || node.constructor === HashCollisionNode
  2587. );
  2588. }
  2589. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  2590. if (node.keyHash === keyHash) {
  2591. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  2592. }
  2593. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  2594. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  2595. var newNode;
  2596. var nodes =
  2597. idx1 === idx2
  2598. ? [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)]
  2599. : ((newNode = new ValueNode(ownerID, keyHash, entry)),
  2600. idx1 < idx2 ? [node, newNode] : [newNode, node]);
  2601. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  2602. }
  2603. function createNodes(ownerID, entries, key, value) {
  2604. if (!ownerID) {
  2605. ownerID = new OwnerID();
  2606. }
  2607. var node = new ValueNode(ownerID, hash(key), [key, value]);
  2608. for (var ii = 0; ii < entries.length; ii++) {
  2609. var entry = entries[ii];
  2610. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  2611. }
  2612. return node;
  2613. }
  2614. function packNodes(ownerID, nodes, count, excluding) {
  2615. var bitmap = 0;
  2616. var packedII = 0;
  2617. var packedNodes = new Array(count);
  2618. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  2619. var node = nodes[ii];
  2620. if (node !== undefined && ii !== excluding) {
  2621. bitmap |= bit;
  2622. packedNodes[packedII++] = node;
  2623. }
  2624. }
  2625. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  2626. }
  2627. function expandNodes(ownerID, nodes, bitmap, including, node) {
  2628. var count = 0;
  2629. var expandedNodes = new Array(SIZE);
  2630. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  2631. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  2632. }
  2633. expandedNodes[including] = node;
  2634. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  2635. }
  2636. function popCount(x) {
  2637. x -= (x >> 1) & 0x55555555;
  2638. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  2639. x = (x + (x >> 4)) & 0x0f0f0f0f;
  2640. x += x >> 8;
  2641. x += x >> 16;
  2642. return x & 0x7f;
  2643. }
  2644. function setAt(array, idx, val, canEdit) {
  2645. var newArray = canEdit ? array : arrCopy(array);
  2646. newArray[idx] = val;
  2647. return newArray;
  2648. }
  2649. function spliceIn(array, idx, val, canEdit) {
  2650. var newLen = array.length + 1;
  2651. if (canEdit && idx + 1 === newLen) {
  2652. array[idx] = val;
  2653. return array;
  2654. }
  2655. var newArray = new Array(newLen);
  2656. var after = 0;
  2657. for (var ii = 0; ii < newLen; ii++) {
  2658. if (ii === idx) {
  2659. newArray[ii] = val;
  2660. after = -1;
  2661. } else {
  2662. newArray[ii] = array[ii + after];
  2663. }
  2664. }
  2665. return newArray;
  2666. }
  2667. function spliceOut(array, idx, canEdit) {
  2668. var newLen = array.length - 1;
  2669. if (canEdit && idx === newLen) {
  2670. array.pop();
  2671. return array;
  2672. }
  2673. var newArray = new Array(newLen);
  2674. var after = 0;
  2675. for (var ii = 0; ii < newLen; ii++) {
  2676. if (ii === idx) {
  2677. after = 1;
  2678. }
  2679. newArray[ii] = array[ii + after];
  2680. }
  2681. return newArray;
  2682. }
  2683. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  2684. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  2685. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  2686. var IS_LIST_SYMBOL = '@@__IMMUTABLE_LIST__@@';
  2687. function isList(maybeList) {
  2688. return Boolean(maybeList && maybeList[IS_LIST_SYMBOL]);
  2689. }
  2690. var List = /*@__PURE__*/(function (IndexedCollection$$1) {
  2691. function List(value) {
  2692. var empty = emptyList();
  2693. if (value === null || value === undefined) {
  2694. return empty;
  2695. }
  2696. if (isList(value)) {
  2697. return value;
  2698. }
  2699. var iter = IndexedCollection$$1(value);
  2700. var size = iter.size;
  2701. if (size === 0) {
  2702. return empty;
  2703. }
  2704. assertNotInfinite(size);
  2705. if (size > 0 && size < SIZE) {
  2706. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  2707. }
  2708. return empty.withMutations(function (list) {
  2709. list.setSize(size);
  2710. iter.forEach(function (v, i) { return list.set(i, v); });
  2711. });
  2712. }
  2713. if ( IndexedCollection$$1 ) List.__proto__ = IndexedCollection$$1;
  2714. List.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
  2715. List.prototype.constructor = List;
  2716. List.of = function of (/*...values*/) {
  2717. return this(arguments);
  2718. };
  2719. List.prototype.toString = function toString () {
  2720. return this.__toString('List [', ']');
  2721. };
  2722. // @pragma Access
  2723. List.prototype.get = function get (index, notSetValue) {
  2724. index = wrapIndex(this, index);
  2725. if (index >= 0 && index < this.size) {
  2726. index += this._origin;
  2727. var node = listNodeFor(this, index);
  2728. return node && node.array[index & MASK];
  2729. }
  2730. return notSetValue;
  2731. };
  2732. // @pragma Modification
  2733. List.prototype.set = function set (index, value) {
  2734. return updateList(this, index, value);
  2735. };
  2736. List.prototype.remove = function remove (index) {
  2737. return !this.has(index)
  2738. ? this
  2739. : index === 0
  2740. ? this.shift()
  2741. : index === this.size - 1
  2742. ? this.pop()
  2743. : this.splice(index, 1);
  2744. };
  2745. List.prototype.insert = function insert (index, value) {
  2746. return this.splice(index, 0, value);
  2747. };
  2748. List.prototype.clear = function clear () {
  2749. if (this.size === 0) {
  2750. return this;
  2751. }
  2752. if (this.__ownerID) {
  2753. this.size = this._origin = this._capacity = 0;
  2754. this._level = SHIFT;
  2755. this._root = this._tail = null;
  2756. this.__hash = undefined;
  2757. this.__altered = true;
  2758. return this;
  2759. }
  2760. return emptyList();
  2761. };
  2762. List.prototype.push = function push (/*...values*/) {
  2763. var values = arguments;
  2764. var oldSize = this.size;
  2765. return this.withMutations(function (list) {
  2766. setListBounds(list, 0, oldSize + values.length);
  2767. for (var ii = 0; ii < values.length; ii++) {
  2768. list.set(oldSize + ii, values[ii]);
  2769. }
  2770. });
  2771. };
  2772. List.prototype.pop = function pop () {
  2773. return setListBounds(this, 0, -1);
  2774. };
  2775. List.prototype.unshift = function unshift (/*...values*/) {
  2776. var values = arguments;
  2777. return this.withMutations(function (list) {
  2778. setListBounds(list, -values.length);
  2779. for (var ii = 0; ii < values.length; ii++) {
  2780. list.set(ii, values[ii]);
  2781. }
  2782. });
  2783. };
  2784. List.prototype.shift = function shift () {
  2785. return setListBounds(this, 1);
  2786. };
  2787. // @pragma Composition
  2788. List.prototype.concat = function concat (/*...collections*/) {
  2789. var arguments$1 = arguments;
  2790. var seqs = [];
  2791. for (var i = 0; i < arguments.length; i++) {
  2792. var argument = arguments$1[i];
  2793. var seq = IndexedCollection$$1(
  2794. typeof argument !== 'string' && hasIterator(argument)
  2795. ? argument
  2796. : [argument]
  2797. );
  2798. if (seq.size !== 0) {
  2799. seqs.push(seq);
  2800. }
  2801. }
  2802. if (seqs.length === 0) {
  2803. return this;
  2804. }
  2805. if (this.size === 0 && !this.__ownerID && seqs.length === 1) {
  2806. return this.constructor(seqs[0]);
  2807. }
  2808. return this.withMutations(function (list) {
  2809. seqs.forEach(function (seq) { return seq.forEach(function (value) { return list.push(value); }); });
  2810. });
  2811. };
  2812. List.prototype.setSize = function setSize (size) {
  2813. return setListBounds(this, 0, size);
  2814. };
  2815. List.prototype.map = function map (mapper, context) {
  2816. var this$1 = this;
  2817. return this.withMutations(function (list) {
  2818. for (var i = 0; i < this$1.size; i++) {
  2819. list.set(i, mapper.call(context, list.get(i), i, list));
  2820. }
  2821. });
  2822. };
  2823. // @pragma Iteration
  2824. List.prototype.slice = function slice (begin, end) {
  2825. var size = this.size;
  2826. if (wholeSlice(begin, end, size)) {
  2827. return this;
  2828. }
  2829. return setListBounds(
  2830. this,
  2831. resolveBegin(begin, size),
  2832. resolveEnd(end, size)
  2833. );
  2834. };
  2835. List.prototype.__iterator = function __iterator (type, reverse) {
  2836. var index = reverse ? this.size : 0;
  2837. var values = iterateList(this, reverse);
  2838. return new Iterator(function () {
  2839. var value = values();
  2840. return value === DONE
  2841. ? iteratorDone()
  2842. : iteratorValue(type, reverse ? --index : index++, value);
  2843. });
  2844. };
  2845. List.prototype.__iterate = function __iterate (fn, reverse) {
  2846. var index = reverse ? this.size : 0;
  2847. var values = iterateList(this, reverse);
  2848. var value;
  2849. while ((value = values()) !== DONE) {
  2850. if (fn(value, reverse ? --index : index++, this) === false) {
  2851. break;
  2852. }
  2853. }
  2854. return index;
  2855. };
  2856. List.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  2857. if (ownerID === this.__ownerID) {
  2858. return this;
  2859. }
  2860. if (!ownerID) {
  2861. if (this.size === 0) {
  2862. return emptyList();
  2863. }
  2864. this.__ownerID = ownerID;
  2865. this.__altered = false;
  2866. return this;
  2867. }
  2868. return makeList(
  2869. this._origin,
  2870. this._capacity,
  2871. this._level,
  2872. this._root,
  2873. this._tail,
  2874. ownerID,
  2875. this.__hash
  2876. );
  2877. };
  2878. return List;
  2879. }(IndexedCollection));
  2880. List.isList = isList;
  2881. var ListPrototype = List.prototype;
  2882. ListPrototype[IS_LIST_SYMBOL] = true;
  2883. ListPrototype[DELETE] = ListPrototype.remove;
  2884. ListPrototype.merge = ListPrototype.concat;
  2885. ListPrototype.setIn = setIn$1;
  2886. ListPrototype.deleteIn = ListPrototype.removeIn = deleteIn;
  2887. ListPrototype.update = update$1;
  2888. ListPrototype.updateIn = updateIn$1;
  2889. ListPrototype.mergeIn = mergeIn;
  2890. ListPrototype.mergeDeepIn = mergeDeepIn;
  2891. ListPrototype.withMutations = withMutations;
  2892. ListPrototype.wasAltered = wasAltered;
  2893. ListPrototype.asImmutable = asImmutable;
  2894. ListPrototype['@@transducer/init'] = ListPrototype.asMutable = asMutable;
  2895. ListPrototype['@@transducer/step'] = function(result, arr) {
  2896. return result.push(arr);
  2897. };
  2898. ListPrototype['@@transducer/result'] = function(obj) {
  2899. return obj.asImmutable();
  2900. };
  2901. var VNode = function VNode(array, ownerID) {
  2902. this.array = array;
  2903. this.ownerID = ownerID;
  2904. };
  2905. // TODO: seems like these methods are very similar
  2906. VNode.prototype.removeBefore = function removeBefore (ownerID, level, index) {
  2907. if (index === level ? 1 << level : this.array.length === 0) {
  2908. return this;
  2909. }
  2910. var originIndex = (index >>> level) & MASK;
  2911. if (originIndex >= this.array.length) {
  2912. return new VNode([], ownerID);
  2913. }
  2914. var removingFirst = originIndex === 0;
  2915. var newChild;
  2916. if (level > 0) {
  2917. var oldChild = this.array[originIndex];
  2918. newChild =
  2919. oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  2920. if (newChild === oldChild && removingFirst) {
  2921. return this;
  2922. }
  2923. }
  2924. if (removingFirst && !newChild) {
  2925. return this;
  2926. }
  2927. var editable = editableVNode(this, ownerID);
  2928. if (!removingFirst) {
  2929. for (var ii = 0; ii < originIndex; ii++) {
  2930. editable.array[ii] = undefined;
  2931. }
  2932. }
  2933. if (newChild) {
  2934. editable.array[originIndex] = newChild;
  2935. }
  2936. return editable;
  2937. };
  2938. VNode.prototype.removeAfter = function removeAfter (ownerID, level, index) {
  2939. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  2940. return this;
  2941. }
  2942. var sizeIndex = ((index - 1) >>> level) & MASK;
  2943. if (sizeIndex >= this.array.length) {
  2944. return this;
  2945. }
  2946. var newChild;
  2947. if (level > 0) {
  2948. var oldChild = this.array[sizeIndex];
  2949. newChild =
  2950. oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  2951. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  2952. return this;
  2953. }
  2954. }
  2955. var editable = editableVNode(this, ownerID);
  2956. editable.array.splice(sizeIndex + 1);
  2957. if (newChild) {
  2958. editable.array[sizeIndex] = newChild;
  2959. }
  2960. return editable;
  2961. };
  2962. var DONE = {};
  2963. function iterateList(list, reverse) {
  2964. var left = list._origin;
  2965. var right = list._capacity;
  2966. var tailPos = getTailOffset(right);
  2967. var tail = list._tail;
  2968. return iterateNodeOrLeaf(list._root, list._level, 0);
  2969. function iterateNodeOrLeaf(node, level, offset) {
  2970. return level === 0
  2971. ? iterateLeaf(node, offset)
  2972. : iterateNode(node, level, offset);
  2973. }
  2974. function iterateLeaf(node, offset) {
  2975. var array = offset === tailPos ? tail && tail.array : node && node.array;
  2976. var from = offset > left ? 0 : left - offset;
  2977. var to = right - offset;
  2978. if (to > SIZE) {
  2979. to = SIZE;
  2980. }
  2981. return function () {
  2982. if (from === to) {
  2983. return DONE;
  2984. }
  2985. var idx = reverse ? --to : from++;
  2986. return array && array[idx];
  2987. };
  2988. }
  2989. function iterateNode(node, level, offset) {
  2990. var values;
  2991. var array = node && node.array;
  2992. var from = offset > left ? 0 : (left - offset) >> level;
  2993. var to = ((right - offset) >> level) + 1;
  2994. if (to > SIZE) {
  2995. to = SIZE;
  2996. }
  2997. return function () {
  2998. while (true) {
  2999. if (values) {
  3000. var value = values();
  3001. if (value !== DONE) {
  3002. return value;
  3003. }
  3004. values = null;
  3005. }
  3006. if (from === to) {
  3007. return DONE;
  3008. }
  3009. var idx = reverse ? --to : from++;
  3010. values = iterateNodeOrLeaf(
  3011. array && array[idx],
  3012. level - SHIFT,
  3013. offset + (idx << level)
  3014. );
  3015. }
  3016. };
  3017. }
  3018. }
  3019. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  3020. var list = Object.create(ListPrototype);
  3021. list.size = capacity - origin;
  3022. list._origin = origin;
  3023. list._capacity = capacity;
  3024. list._level = level;
  3025. list._root = root;
  3026. list._tail = tail;
  3027. list.__ownerID = ownerID;
  3028. list.__hash = hash;
  3029. list.__altered = false;
  3030. return list;
  3031. }
  3032. var EMPTY_LIST;
  3033. function emptyList() {
  3034. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  3035. }
  3036. function updateList(list, index, value) {
  3037. index = wrapIndex(list, index);
  3038. if (index !== index) {
  3039. return list;
  3040. }
  3041. if (index >= list.size || index < 0) {
  3042. return list.withMutations(function (list) {
  3043. index < 0
  3044. ? setListBounds(list, index).set(0, value)
  3045. : setListBounds(list, 0, index + 1).set(index, value);
  3046. });
  3047. }
  3048. index += list._origin;
  3049. var newTail = list._tail;
  3050. var newRoot = list._root;
  3051. var didAlter = MakeRef();
  3052. if (index >= getTailOffset(list._capacity)) {
  3053. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  3054. } else {
  3055. newRoot = updateVNode(
  3056. newRoot,
  3057. list.__ownerID,
  3058. list._level,
  3059. index,
  3060. value,
  3061. didAlter
  3062. );
  3063. }
  3064. if (!didAlter.value) {
  3065. return list;
  3066. }
  3067. if (list.__ownerID) {
  3068. list._root = newRoot;
  3069. list._tail = newTail;
  3070. list.__hash = undefined;
  3071. list.__altered = true;
  3072. return list;
  3073. }
  3074. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  3075. }
  3076. function updateVNode(node, ownerID, level, index, value, didAlter) {
  3077. var idx = (index >>> level) & MASK;
  3078. var nodeHas = node && idx < node.array.length;
  3079. if (!nodeHas && value === undefined) {
  3080. return node;
  3081. }
  3082. var newNode;
  3083. if (level > 0) {
  3084. var lowerNode = node && node.array[idx];
  3085. var newLowerNode = updateVNode(
  3086. lowerNode,
  3087. ownerID,
  3088. level - SHIFT,
  3089. index,
  3090. value,
  3091. didAlter
  3092. );
  3093. if (newLowerNode === lowerNode) {
  3094. return node;
  3095. }
  3096. newNode = editableVNode(node, ownerID);
  3097. newNode.array[idx] = newLowerNode;
  3098. return newNode;
  3099. }
  3100. if (nodeHas && node.array[idx] === value) {
  3101. return node;
  3102. }
  3103. if (didAlter) {
  3104. SetRef(didAlter);
  3105. }
  3106. newNode = editableVNode(node, ownerID);
  3107. if (value === undefined && idx === newNode.array.length - 1) {
  3108. newNode.array.pop();
  3109. } else {
  3110. newNode.array[idx] = value;
  3111. }
  3112. return newNode;
  3113. }
  3114. function editableVNode(node, ownerID) {
  3115. if (ownerID && node && ownerID === node.ownerID) {
  3116. return node;
  3117. }
  3118. return new VNode(node ? node.array.slice() : [], ownerID);
  3119. }
  3120. function listNodeFor(list, rawIndex) {
  3121. if (rawIndex >= getTailOffset(list._capacity)) {
  3122. return list._tail;
  3123. }
  3124. if (rawIndex < 1 << (list._level + SHIFT)) {
  3125. var node = list._root;
  3126. var level = list._level;
  3127. while (node && level > 0) {
  3128. node = node.array[(rawIndex >>> level) & MASK];
  3129. level -= SHIFT;
  3130. }
  3131. return node;
  3132. }
  3133. }
  3134. function setListBounds(list, begin, end) {
  3135. // Sanitize begin & end using this shorthand for ToInt32(argument)
  3136. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  3137. if (begin !== undefined) {
  3138. begin |= 0;
  3139. }
  3140. if (end !== undefined) {
  3141. end |= 0;
  3142. }
  3143. var owner = list.__ownerID || new OwnerID();
  3144. var oldOrigin = list._origin;
  3145. var oldCapacity = list._capacity;
  3146. var newOrigin = oldOrigin + begin;
  3147. var newCapacity =
  3148. end === undefined
  3149. ? oldCapacity
  3150. : end < 0
  3151. ? oldCapacity + end
  3152. : oldOrigin + end;
  3153. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  3154. return list;
  3155. }
  3156. // If it's going to end after it starts, it's empty.
  3157. if (newOrigin >= newCapacity) {
  3158. return list.clear();
  3159. }
  3160. var newLevel = list._level;
  3161. var newRoot = list._root;
  3162. // New origin might need creating a higher root.
  3163. var offsetShift = 0;
  3164. while (newOrigin + offsetShift < 0) {
  3165. newRoot = new VNode(
  3166. newRoot && newRoot.array.length ? [undefined, newRoot] : [],
  3167. owner
  3168. );
  3169. newLevel += SHIFT;
  3170. offsetShift += 1 << newLevel;
  3171. }
  3172. if (offsetShift) {
  3173. newOrigin += offsetShift;
  3174. oldOrigin += offsetShift;
  3175. newCapacity += offsetShift;
  3176. oldCapacity += offsetShift;
  3177. }
  3178. var oldTailOffset = getTailOffset(oldCapacity);
  3179. var newTailOffset = getTailOffset(newCapacity);
  3180. // New size might need creating a higher root.
  3181. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  3182. newRoot = new VNode(
  3183. newRoot && newRoot.array.length ? [newRoot] : [],
  3184. owner
  3185. );
  3186. newLevel += SHIFT;
  3187. }
  3188. // Locate or create the new tail.
  3189. var oldTail = list._tail;
  3190. var newTail =
  3191. newTailOffset < oldTailOffset
  3192. ? listNodeFor(list, newCapacity - 1)
  3193. : newTailOffset > oldTailOffset
  3194. ? new VNode([], owner)
  3195. : oldTail;
  3196. // Merge Tail into tree.
  3197. if (
  3198. oldTail &&
  3199. newTailOffset > oldTailOffset &&
  3200. newOrigin < oldCapacity &&
  3201. oldTail.array.length
  3202. ) {
  3203. newRoot = editableVNode(newRoot, owner);
  3204. var node = newRoot;
  3205. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  3206. var idx = (oldTailOffset >>> level) & MASK;
  3207. node = node.array[idx] = editableVNode(node.array[idx], owner);
  3208. }
  3209. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  3210. }
  3211. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  3212. if (newCapacity < oldCapacity) {
  3213. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  3214. }
  3215. // If the new origin is within the tail, then we do not need a root.
  3216. if (newOrigin >= newTailOffset) {
  3217. newOrigin -= newTailOffset;
  3218. newCapacity -= newTailOffset;
  3219. newLevel = SHIFT;
  3220. newRoot = null;
  3221. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  3222. // Otherwise, if the root has been trimmed, garbage collect.
  3223. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  3224. offsetShift = 0;
  3225. // Identify the new top root node of the subtree of the old root.
  3226. while (newRoot) {
  3227. var beginIndex = (newOrigin >>> newLevel) & MASK;
  3228. if ((beginIndex !== newTailOffset >>> newLevel) & MASK) {
  3229. break;
  3230. }
  3231. if (beginIndex) {
  3232. offsetShift += (1 << newLevel) * beginIndex;
  3233. }
  3234. newLevel -= SHIFT;
  3235. newRoot = newRoot.array[beginIndex];
  3236. }
  3237. // Trim the new sides of the new root.
  3238. if (newRoot && newOrigin > oldOrigin) {
  3239. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  3240. }
  3241. if (newRoot && newTailOffset < oldTailOffset) {
  3242. newRoot = newRoot.removeAfter(
  3243. owner,
  3244. newLevel,
  3245. newTailOffset - offsetShift
  3246. );
  3247. }
  3248. if (offsetShift) {
  3249. newOrigin -= offsetShift;
  3250. newCapacity -= offsetShift;
  3251. }
  3252. }
  3253. if (list.__ownerID) {
  3254. list.size = newCapacity - newOrigin;
  3255. list._origin = newOrigin;
  3256. list._capacity = newCapacity;
  3257. list._level = newLevel;
  3258. list._root = newRoot;
  3259. list._tail = newTail;
  3260. list.__hash = undefined;
  3261. list.__altered = true;
  3262. return list;
  3263. }
  3264. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  3265. }
  3266. function getTailOffset(size) {
  3267. return size < SIZE ? 0 : ((size - 1) >>> SHIFT) << SHIFT;
  3268. }
  3269. var OrderedMap = /*@__PURE__*/(function (Map$$1) {
  3270. function OrderedMap(value) {
  3271. return value === null || value === undefined
  3272. ? emptyOrderedMap()
  3273. : isOrderedMap(value)
  3274. ? value
  3275. : emptyOrderedMap().withMutations(function (map) {
  3276. var iter = KeyedCollection(value);
  3277. assertNotInfinite(iter.size);
  3278. iter.forEach(function (v, k) { return map.set(k, v); });
  3279. });
  3280. }
  3281. if ( Map$$1 ) OrderedMap.__proto__ = Map$$1;
  3282. OrderedMap.prototype = Object.create( Map$$1 && Map$$1.prototype );
  3283. OrderedMap.prototype.constructor = OrderedMap;
  3284. OrderedMap.of = function of (/*...values*/) {
  3285. return this(arguments);
  3286. };
  3287. OrderedMap.prototype.toString = function toString () {
  3288. return this.__toString('OrderedMap {', '}');
  3289. };
  3290. // @pragma Access
  3291. OrderedMap.prototype.get = function get (k, notSetValue) {
  3292. var index = this._map.get(k);
  3293. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  3294. };
  3295. // @pragma Modification
  3296. OrderedMap.prototype.clear = function clear () {
  3297. if (this.size === 0) {
  3298. return this;
  3299. }
  3300. if (this.__ownerID) {
  3301. this.size = 0;
  3302. this._map.clear();
  3303. this._list.clear();
  3304. return this;
  3305. }
  3306. return emptyOrderedMap();
  3307. };
  3308. OrderedMap.prototype.set = function set (k, v) {
  3309. return updateOrderedMap(this, k, v);
  3310. };
  3311. OrderedMap.prototype.remove = function remove (k) {
  3312. return updateOrderedMap(this, k, NOT_SET);
  3313. };
  3314. OrderedMap.prototype.wasAltered = function wasAltered () {
  3315. return this._map.wasAltered() || this._list.wasAltered();
  3316. };
  3317. OrderedMap.prototype.__iterate = function __iterate (fn, reverse) {
  3318. var this$1 = this;
  3319. return this._list.__iterate(
  3320. function (entry) { return entry && fn(entry[1], entry[0], this$1); },
  3321. reverse
  3322. );
  3323. };
  3324. OrderedMap.prototype.__iterator = function __iterator (type, reverse) {
  3325. return this._list.fromEntrySeq().__iterator(type, reverse);
  3326. };
  3327. OrderedMap.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3328. if (ownerID === this.__ownerID) {
  3329. return this;
  3330. }
  3331. var newMap = this._map.__ensureOwner(ownerID);
  3332. var newList = this._list.__ensureOwner(ownerID);
  3333. if (!ownerID) {
  3334. if (this.size === 0) {
  3335. return emptyOrderedMap();
  3336. }
  3337. this.__ownerID = ownerID;
  3338. this._map = newMap;
  3339. this._list = newList;
  3340. return this;
  3341. }
  3342. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  3343. };
  3344. return OrderedMap;
  3345. }(Map));
  3346. OrderedMap.isOrderedMap = isOrderedMap;
  3347. OrderedMap.prototype[IS_ORDERED_SYMBOL] = true;
  3348. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  3349. function makeOrderedMap(map, list, ownerID, hash) {
  3350. var omap = Object.create(OrderedMap.prototype);
  3351. omap.size = map ? map.size : 0;
  3352. omap._map = map;
  3353. omap._list = list;
  3354. omap.__ownerID = ownerID;
  3355. omap.__hash = hash;
  3356. return omap;
  3357. }
  3358. var EMPTY_ORDERED_MAP;
  3359. function emptyOrderedMap() {
  3360. return (
  3361. EMPTY_ORDERED_MAP ||
  3362. (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()))
  3363. );
  3364. }
  3365. function updateOrderedMap(omap, k, v) {
  3366. var map = omap._map;
  3367. var list = omap._list;
  3368. var i = map.get(k);
  3369. var has = i !== undefined;
  3370. var newMap;
  3371. var newList;
  3372. if (v === NOT_SET) {
  3373. // removed
  3374. if (!has) {
  3375. return omap;
  3376. }
  3377. if (list.size >= SIZE && list.size >= map.size * 2) {
  3378. newList = list.filter(function (entry, idx) { return entry !== undefined && i !== idx; });
  3379. newMap = newList
  3380. .toKeyedSeq()
  3381. .map(function (entry) { return entry[0]; })
  3382. .flip()
  3383. .toMap();
  3384. if (omap.__ownerID) {
  3385. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  3386. }
  3387. } else {
  3388. newMap = map.remove(k);
  3389. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  3390. }
  3391. } else if (has) {
  3392. if (v === list.get(i)[1]) {
  3393. return omap;
  3394. }
  3395. newMap = map;
  3396. newList = list.set(i, [k, v]);
  3397. } else {
  3398. newMap = map.set(k, list.size);
  3399. newList = list.set(list.size, [k, v]);
  3400. }
  3401. if (omap.__ownerID) {
  3402. omap.size = newMap.size;
  3403. omap._map = newMap;
  3404. omap._list = newList;
  3405. omap.__hash = undefined;
  3406. return omap;
  3407. }
  3408. return makeOrderedMap(newMap, newList);
  3409. }
  3410. var IS_STACK_SYMBOL = '@@__IMMUTABLE_STACK__@@';
  3411. function isStack(maybeStack) {
  3412. return Boolean(maybeStack && maybeStack[IS_STACK_SYMBOL]);
  3413. }
  3414. var Stack = /*@__PURE__*/(function (IndexedCollection$$1) {
  3415. function Stack(value) {
  3416. return value === null || value === undefined
  3417. ? emptyStack()
  3418. : isStack(value)
  3419. ? value
  3420. : emptyStack().pushAll(value);
  3421. }
  3422. if ( IndexedCollection$$1 ) Stack.__proto__ = IndexedCollection$$1;
  3423. Stack.prototype = Object.create( IndexedCollection$$1 && IndexedCollection$$1.prototype );
  3424. Stack.prototype.constructor = Stack;
  3425. Stack.of = function of (/*...values*/) {
  3426. return this(arguments);
  3427. };
  3428. Stack.prototype.toString = function toString () {
  3429. return this.__toString('Stack [', ']');
  3430. };
  3431. // @pragma Access
  3432. Stack.prototype.get = function get (index, notSetValue) {
  3433. var head = this._head;
  3434. index = wrapIndex(this, index);
  3435. while (head && index--) {
  3436. head = head.next;
  3437. }
  3438. return head ? head.value : notSetValue;
  3439. };
  3440. Stack.prototype.peek = function peek () {
  3441. return this._head && this._head.value;
  3442. };
  3443. // @pragma Modification
  3444. Stack.prototype.push = function push (/*...values*/) {
  3445. var arguments$1 = arguments;
  3446. if (arguments.length === 0) {
  3447. return this;
  3448. }
  3449. var newSize = this.size + arguments.length;
  3450. var head = this._head;
  3451. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  3452. head = {
  3453. value: arguments$1[ii],
  3454. next: head,
  3455. };
  3456. }
  3457. if (this.__ownerID) {
  3458. this.size = newSize;
  3459. this._head = head;
  3460. this.__hash = undefined;
  3461. this.__altered = true;
  3462. return this;
  3463. }
  3464. return makeStack(newSize, head);
  3465. };
  3466. Stack.prototype.pushAll = function pushAll (iter) {
  3467. iter = IndexedCollection$$1(iter);
  3468. if (iter.size === 0) {
  3469. return this;
  3470. }
  3471. if (this.size === 0 && isStack(iter)) {
  3472. return iter;
  3473. }
  3474. assertNotInfinite(iter.size);
  3475. var newSize = this.size;
  3476. var head = this._head;
  3477. iter.__iterate(function (value) {
  3478. newSize++;
  3479. head = {
  3480. value: value,
  3481. next: head,
  3482. };
  3483. }, /* reverse */ true);
  3484. if (this.__ownerID) {
  3485. this.size = newSize;
  3486. this._head = head;
  3487. this.__hash = undefined;
  3488. this.__altered = true;
  3489. return this;
  3490. }
  3491. return makeStack(newSize, head);
  3492. };
  3493. Stack.prototype.pop = function pop () {
  3494. return this.slice(1);
  3495. };
  3496. Stack.prototype.clear = function clear () {
  3497. if (this.size === 0) {
  3498. return this;
  3499. }
  3500. if (this.__ownerID) {
  3501. this.size = 0;
  3502. this._head = undefined;
  3503. this.__hash = undefined;
  3504. this.__altered = true;
  3505. return this;
  3506. }
  3507. return emptyStack();
  3508. };
  3509. Stack.prototype.slice = function slice (begin, end) {
  3510. if (wholeSlice(begin, end, this.size)) {
  3511. return this;
  3512. }
  3513. var resolvedBegin = resolveBegin(begin, this.size);
  3514. var resolvedEnd = resolveEnd(end, this.size);
  3515. if (resolvedEnd !== this.size) {
  3516. // super.slice(begin, end);
  3517. return IndexedCollection$$1.prototype.slice.call(this, begin, end);
  3518. }
  3519. var newSize = this.size - resolvedBegin;
  3520. var head = this._head;
  3521. while (resolvedBegin--) {
  3522. head = head.next;
  3523. }
  3524. if (this.__ownerID) {
  3525. this.size = newSize;
  3526. this._head = head;
  3527. this.__hash = undefined;
  3528. this.__altered = true;
  3529. return this;
  3530. }
  3531. return makeStack(newSize, head);
  3532. };
  3533. // @pragma Mutability
  3534. Stack.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3535. if (ownerID === this.__ownerID) {
  3536. return this;
  3537. }
  3538. if (!ownerID) {
  3539. if (this.size === 0) {
  3540. return emptyStack();
  3541. }
  3542. this.__ownerID = ownerID;
  3543. this.__altered = false;
  3544. return this;
  3545. }
  3546. return makeStack(this.size, this._head, ownerID, this.__hash);
  3547. };
  3548. // @pragma Iteration
  3549. Stack.prototype.__iterate = function __iterate (fn, reverse) {
  3550. var this$1 = this;
  3551. if (reverse) {
  3552. return new ArraySeq(this.toArray()).__iterate(
  3553. function (v, k) { return fn(v, k, this$1); },
  3554. reverse
  3555. );
  3556. }
  3557. var iterations = 0;
  3558. var node = this._head;
  3559. while (node) {
  3560. if (fn(node.value, iterations++, this) === false) {
  3561. break;
  3562. }
  3563. node = node.next;
  3564. }
  3565. return iterations;
  3566. };
  3567. Stack.prototype.__iterator = function __iterator (type, reverse) {
  3568. if (reverse) {
  3569. return new ArraySeq(this.toArray()).__iterator(type, reverse);
  3570. }
  3571. var iterations = 0;
  3572. var node = this._head;
  3573. return new Iterator(function () {
  3574. if (node) {
  3575. var value = node.value;
  3576. node = node.next;
  3577. return iteratorValue(type, iterations++, value);
  3578. }
  3579. return iteratorDone();
  3580. });
  3581. };
  3582. return Stack;
  3583. }(IndexedCollection));
  3584. Stack.isStack = isStack;
  3585. var StackPrototype = Stack.prototype;
  3586. StackPrototype[IS_STACK_SYMBOL] = true;
  3587. StackPrototype.shift = StackPrototype.pop;
  3588. StackPrototype.unshift = StackPrototype.push;
  3589. StackPrototype.unshiftAll = StackPrototype.pushAll;
  3590. StackPrototype.withMutations = withMutations;
  3591. StackPrototype.wasAltered = wasAltered;
  3592. StackPrototype.asImmutable = asImmutable;
  3593. StackPrototype['@@transducer/init'] = StackPrototype.asMutable = asMutable;
  3594. StackPrototype['@@transducer/step'] = function(result, arr) {
  3595. return result.unshift(arr);
  3596. };
  3597. StackPrototype['@@transducer/result'] = function(obj) {
  3598. return obj.asImmutable();
  3599. };
  3600. function makeStack(size, head, ownerID, hash) {
  3601. var map = Object.create(StackPrototype);
  3602. map.size = size;
  3603. map._head = head;
  3604. map.__ownerID = ownerID;
  3605. map.__hash = hash;
  3606. map.__altered = false;
  3607. return map;
  3608. }
  3609. var EMPTY_STACK;
  3610. function emptyStack() {
  3611. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  3612. }
  3613. var IS_SET_SYMBOL = '@@__IMMUTABLE_SET__@@';
  3614. function isSet(maybeSet) {
  3615. return Boolean(maybeSet && maybeSet[IS_SET_SYMBOL]);
  3616. }
  3617. function isOrderedSet(maybeOrderedSet) {
  3618. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  3619. }
  3620. function deepEqual(a, b) {
  3621. if (a === b) {
  3622. return true;
  3623. }
  3624. if (
  3625. !isCollection(b) ||
  3626. (a.size !== undefined && b.size !== undefined && a.size !== b.size) ||
  3627. (a.__hash !== undefined &&
  3628. b.__hash !== undefined &&
  3629. a.__hash !== b.__hash) ||
  3630. isKeyed(a) !== isKeyed(b) ||
  3631. isIndexed(a) !== isIndexed(b) ||
  3632. isOrdered(a) !== isOrdered(b)
  3633. ) {
  3634. return false;
  3635. }
  3636. if (a.size === 0 && b.size === 0) {
  3637. return true;
  3638. }
  3639. var notAssociative = !isAssociative(a);
  3640. if (isOrdered(a)) {
  3641. var entries = a.entries();
  3642. return (
  3643. b.every(function (v, k) {
  3644. var entry = entries.next().value;
  3645. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  3646. }) && entries.next().done
  3647. );
  3648. }
  3649. var flipped = false;
  3650. if (a.size === undefined) {
  3651. if (b.size === undefined) {
  3652. if (typeof a.cacheResult === 'function') {
  3653. a.cacheResult();
  3654. }
  3655. } else {
  3656. flipped = true;
  3657. var _ = a;
  3658. a = b;
  3659. b = _;
  3660. }
  3661. }
  3662. var allEqual = true;
  3663. var bSize = b.__iterate(function (v, k) {
  3664. if (
  3665. notAssociative
  3666. ? !a.has(v)
  3667. : flipped
  3668. ? !is(v, a.get(k, NOT_SET))
  3669. : !is(a.get(k, NOT_SET), v)
  3670. ) {
  3671. allEqual = false;
  3672. return false;
  3673. }
  3674. });
  3675. return allEqual && a.size === bSize;
  3676. }
  3677. /**
  3678. * Contributes additional methods to a constructor
  3679. */
  3680. function mixin(ctor, methods) {
  3681. var keyCopier = function (key) {
  3682. ctor.prototype[key] = methods[key];
  3683. };
  3684. Object.keys(methods).forEach(keyCopier);
  3685. Object.getOwnPropertySymbols &&
  3686. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  3687. return ctor;
  3688. }
  3689. function toJS(value) {
  3690. if (!value || typeof value !== 'object') {
  3691. return value;
  3692. }
  3693. if (!isCollection(value)) {
  3694. if (!isDataStructure(value)) {
  3695. return value;
  3696. }
  3697. value = Seq(value);
  3698. }
  3699. if (isKeyed(value)) {
  3700. var result$1 = {};
  3701. value.__iterate(function (v, k) {
  3702. result$1[k] = toJS(v);
  3703. });
  3704. return result$1;
  3705. }
  3706. var result = [];
  3707. value.__iterate(function (v) {
  3708. result.push(toJS(v));
  3709. });
  3710. return result;
  3711. }
  3712. var Set = /*@__PURE__*/(function (SetCollection$$1) {
  3713. function Set(value) {
  3714. return value === null || value === undefined
  3715. ? emptySet()
  3716. : isSet(value) && !isOrdered(value)
  3717. ? value
  3718. : emptySet().withMutations(function (set) {
  3719. var iter = SetCollection$$1(value);
  3720. assertNotInfinite(iter.size);
  3721. iter.forEach(function (v) { return set.add(v); });
  3722. });
  3723. }
  3724. if ( SetCollection$$1 ) Set.__proto__ = SetCollection$$1;
  3725. Set.prototype = Object.create( SetCollection$$1 && SetCollection$$1.prototype );
  3726. Set.prototype.constructor = Set;
  3727. Set.of = function of (/*...values*/) {
  3728. return this(arguments);
  3729. };
  3730. Set.fromKeys = function fromKeys (value) {
  3731. return this(KeyedCollection(value).keySeq());
  3732. };
  3733. Set.intersect = function intersect (sets) {
  3734. sets = Collection(sets).toArray();
  3735. return sets.length
  3736. ? SetPrototype.intersect.apply(Set(sets.pop()), sets)
  3737. : emptySet();
  3738. };
  3739. Set.union = function union (sets) {
  3740. sets = Collection(sets).toArray();
  3741. return sets.length
  3742. ? SetPrototype.union.apply(Set(sets.pop()), sets)
  3743. : emptySet();
  3744. };
  3745. Set.prototype.toString = function toString () {
  3746. return this.__toString('Set {', '}');
  3747. };
  3748. // @pragma Access
  3749. Set.prototype.has = function has (value) {
  3750. return this._map.has(value);
  3751. };
  3752. // @pragma Modification
  3753. Set.prototype.add = function add (value) {
  3754. return updateSet(this, this._map.set(value, value));
  3755. };
  3756. Set.prototype.remove = function remove (value) {
  3757. return updateSet(this, this._map.remove(value));
  3758. };
  3759. Set.prototype.clear = function clear () {
  3760. return updateSet(this, this._map.clear());
  3761. };
  3762. // @pragma Composition
  3763. Set.prototype.map = function map (mapper, context) {
  3764. var this$1 = this;
  3765. var removes = [];
  3766. var adds = [];
  3767. this.forEach(function (value) {
  3768. var mapped = mapper.call(context, value, value, this$1);
  3769. if (mapped !== value) {
  3770. removes.push(value);
  3771. adds.push(mapped);
  3772. }
  3773. });
  3774. return this.withMutations(function (set) {
  3775. removes.forEach(function (value) { return set.remove(value); });
  3776. adds.forEach(function (value) { return set.add(value); });
  3777. });
  3778. };
  3779. Set.prototype.union = function union () {
  3780. var iters = [], len = arguments.length;
  3781. while ( len-- ) iters[ len ] = arguments[ len ];
  3782. iters = iters.filter(function (x) { return x.size !== 0; });
  3783. if (iters.length === 0) {
  3784. return this;
  3785. }
  3786. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  3787. return this.constructor(iters[0]);
  3788. }
  3789. return this.withMutations(function (set) {
  3790. for (var ii = 0; ii < iters.length; ii++) {
  3791. SetCollection$$1(iters[ii]).forEach(function (value) { return set.add(value); });
  3792. }
  3793. });
  3794. };
  3795. Set.prototype.intersect = function intersect () {
  3796. var iters = [], len = arguments.length;
  3797. while ( len-- ) iters[ len ] = arguments[ len ];
  3798. if (iters.length === 0) {
  3799. return this;
  3800. }
  3801. iters = iters.map(function (iter) { return SetCollection$$1(iter); });
  3802. var toRemove = [];
  3803. this.forEach(function (value) {
  3804. if (!iters.every(function (iter) { return iter.includes(value); })) {
  3805. toRemove.push(value);
  3806. }
  3807. });
  3808. return this.withMutations(function (set) {
  3809. toRemove.forEach(function (value) {
  3810. set.remove(value);
  3811. });
  3812. });
  3813. };
  3814. Set.prototype.subtract = function subtract () {
  3815. var iters = [], len = arguments.length;
  3816. while ( len-- ) iters[ len ] = arguments[ len ];
  3817. if (iters.length === 0) {
  3818. return this;
  3819. }
  3820. iters = iters.map(function (iter) { return SetCollection$$1(iter); });
  3821. var toRemove = [];
  3822. this.forEach(function (value) {
  3823. if (iters.some(function (iter) { return iter.includes(value); })) {
  3824. toRemove.push(value);
  3825. }
  3826. });
  3827. return this.withMutations(function (set) {
  3828. toRemove.forEach(function (value) {
  3829. set.remove(value);
  3830. });
  3831. });
  3832. };
  3833. Set.prototype.sort = function sort (comparator) {
  3834. // Late binding
  3835. return OrderedSet(sortFactory(this, comparator));
  3836. };
  3837. Set.prototype.sortBy = function sortBy (mapper, comparator) {
  3838. // Late binding
  3839. return OrderedSet(sortFactory(this, comparator, mapper));
  3840. };
  3841. Set.prototype.wasAltered = function wasAltered () {
  3842. return this._map.wasAltered();
  3843. };
  3844. Set.prototype.__iterate = function __iterate (fn, reverse) {
  3845. var this$1 = this;
  3846. return this._map.__iterate(function (k) { return fn(k, k, this$1); }, reverse);
  3847. };
  3848. Set.prototype.__iterator = function __iterator (type, reverse) {
  3849. return this._map.__iterator(type, reverse);
  3850. };
  3851. Set.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  3852. if (ownerID === this.__ownerID) {
  3853. return this;
  3854. }
  3855. var newMap = this._map.__ensureOwner(ownerID);
  3856. if (!ownerID) {
  3857. if (this.size === 0) {
  3858. return this.__empty();
  3859. }
  3860. this.__ownerID = ownerID;
  3861. this._map = newMap;
  3862. return this;
  3863. }
  3864. return this.__make(newMap, ownerID);
  3865. };
  3866. return Set;
  3867. }(SetCollection));
  3868. Set.isSet = isSet;
  3869. var SetPrototype = Set.prototype;
  3870. SetPrototype[IS_SET_SYMBOL] = true;
  3871. SetPrototype[DELETE] = SetPrototype.remove;
  3872. SetPrototype.merge = SetPrototype.concat = SetPrototype.union;
  3873. SetPrototype.withMutations = withMutations;
  3874. SetPrototype.asImmutable = asImmutable;
  3875. SetPrototype['@@transducer/init'] = SetPrototype.asMutable = asMutable;
  3876. SetPrototype['@@transducer/step'] = function(result, arr) {
  3877. return result.add(arr);
  3878. };
  3879. SetPrototype['@@transducer/result'] = function(obj) {
  3880. return obj.asImmutable();
  3881. };
  3882. SetPrototype.__empty = emptySet;
  3883. SetPrototype.__make = makeSet;
  3884. function updateSet(set, newMap) {
  3885. if (set.__ownerID) {
  3886. set.size = newMap.size;
  3887. set._map = newMap;
  3888. return set;
  3889. }
  3890. return newMap === set._map
  3891. ? set
  3892. : newMap.size === 0
  3893. ? set.__empty()
  3894. : set.__make(newMap);
  3895. }
  3896. function makeSet(map, ownerID) {
  3897. var set = Object.create(SetPrototype);
  3898. set.size = map ? map.size : 0;
  3899. set._map = map;
  3900. set.__ownerID = ownerID;
  3901. return set;
  3902. }
  3903. var EMPTY_SET;
  3904. function emptySet() {
  3905. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  3906. }
  3907. /**
  3908. * Returns a lazy seq of nums from start (inclusive) to end
  3909. * (exclusive), by step, where start defaults to 0, step to 1, and end to
  3910. * infinity. When start is equal to end, returns empty list.
  3911. */
  3912. var Range = /*@__PURE__*/(function (IndexedSeq$$1) {
  3913. function Range(start, end, step) {
  3914. if (!(this instanceof Range)) {
  3915. return new Range(start, end, step);
  3916. }
  3917. invariant(step !== 0, 'Cannot step a Range by 0');
  3918. start = start || 0;
  3919. if (end === undefined) {
  3920. end = Infinity;
  3921. }
  3922. step = step === undefined ? 1 : Math.abs(step);
  3923. if (end < start) {
  3924. step = -step;
  3925. }
  3926. this._start = start;
  3927. this._end = end;
  3928. this._step = step;
  3929. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  3930. if (this.size === 0) {
  3931. if (EMPTY_RANGE) {
  3932. return EMPTY_RANGE;
  3933. }
  3934. EMPTY_RANGE = this;
  3935. }
  3936. }
  3937. if ( IndexedSeq$$1 ) Range.__proto__ = IndexedSeq$$1;
  3938. Range.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  3939. Range.prototype.constructor = Range;
  3940. Range.prototype.toString = function toString () {
  3941. if (this.size === 0) {
  3942. return 'Range []';
  3943. }
  3944. return (
  3945. 'Range [ ' +
  3946. this._start +
  3947. '...' +
  3948. this._end +
  3949. (this._step !== 1 ? ' by ' + this._step : '') +
  3950. ' ]'
  3951. );
  3952. };
  3953. Range.prototype.get = function get (index, notSetValue) {
  3954. return this.has(index)
  3955. ? this._start + wrapIndex(this, index) * this._step
  3956. : notSetValue;
  3957. };
  3958. Range.prototype.includes = function includes (searchValue) {
  3959. var possibleIndex = (searchValue - this._start) / this._step;
  3960. return (
  3961. possibleIndex >= 0 &&
  3962. possibleIndex < this.size &&
  3963. possibleIndex === Math.floor(possibleIndex)
  3964. );
  3965. };
  3966. Range.prototype.slice = function slice (begin, end) {
  3967. if (wholeSlice(begin, end, this.size)) {
  3968. return this;
  3969. }
  3970. begin = resolveBegin(begin, this.size);
  3971. end = resolveEnd(end, this.size);
  3972. if (end <= begin) {
  3973. return new Range(0, 0);
  3974. }
  3975. return new Range(
  3976. this.get(begin, this._end),
  3977. this.get(end, this._end),
  3978. this._step
  3979. );
  3980. };
  3981. Range.prototype.indexOf = function indexOf (searchValue) {
  3982. var offsetValue = searchValue - this._start;
  3983. if (offsetValue % this._step === 0) {
  3984. var index = offsetValue / this._step;
  3985. if (index >= 0 && index < this.size) {
  3986. return index;
  3987. }
  3988. }
  3989. return -1;
  3990. };
  3991. Range.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  3992. return this.indexOf(searchValue);
  3993. };
  3994. Range.prototype.__iterate = function __iterate (fn, reverse) {
  3995. var size = this.size;
  3996. var step = this._step;
  3997. var value = reverse ? this._start + (size - 1) * step : this._start;
  3998. var i = 0;
  3999. while (i !== size) {
  4000. if (fn(value, reverse ? size - ++i : i++, this) === false) {
  4001. break;
  4002. }
  4003. value += reverse ? -step : step;
  4004. }
  4005. return i;
  4006. };
  4007. Range.prototype.__iterator = function __iterator (type, reverse) {
  4008. var size = this.size;
  4009. var step = this._step;
  4010. var value = reverse ? this._start + (size - 1) * step : this._start;
  4011. var i = 0;
  4012. return new Iterator(function () {
  4013. if (i === size) {
  4014. return iteratorDone();
  4015. }
  4016. var v = value;
  4017. value += reverse ? -step : step;
  4018. return iteratorValue(type, reverse ? size - ++i : i++, v);
  4019. });
  4020. };
  4021. Range.prototype.equals = function equals (other) {
  4022. return other instanceof Range
  4023. ? this._start === other._start &&
  4024. this._end === other._end &&
  4025. this._step === other._step
  4026. : deepEqual(this, other);
  4027. };
  4028. return Range;
  4029. }(IndexedSeq));
  4030. var EMPTY_RANGE;
  4031. function getIn(collection, searchKeyPath, notSetValue) {
  4032. var keyPath = coerceKeyPath(searchKeyPath);
  4033. var i = 0;
  4034. while (i !== keyPath.length) {
  4035. collection = get(collection, keyPath[i++], NOT_SET);
  4036. if (collection === NOT_SET) {
  4037. return notSetValue;
  4038. }
  4039. }
  4040. return collection;
  4041. }
  4042. function getIn$1(searchKeyPath, notSetValue) {
  4043. return getIn(this, searchKeyPath, notSetValue);
  4044. }
  4045. function hasIn(collection, keyPath) {
  4046. return getIn(collection, keyPath, NOT_SET) !== NOT_SET;
  4047. }
  4048. function hasIn$1(searchKeyPath) {
  4049. return hasIn(this, searchKeyPath);
  4050. }
  4051. function toObject() {
  4052. assertNotInfinite(this.size);
  4053. var object = {};
  4054. this.__iterate(function (v, k) {
  4055. object[k] = v;
  4056. });
  4057. return object;
  4058. }
  4059. // Note: all of these methods are deprecated.
  4060. Collection.isIterable = isCollection;
  4061. Collection.isKeyed = isKeyed;
  4062. Collection.isIndexed = isIndexed;
  4063. Collection.isAssociative = isAssociative;
  4064. Collection.isOrdered = isOrdered;
  4065. Collection.Iterator = Iterator;
  4066. mixin(Collection, {
  4067. // ### Conversion to other types
  4068. toArray: function toArray() {
  4069. assertNotInfinite(this.size);
  4070. var array = new Array(this.size || 0);
  4071. var useTuples = isKeyed(this);
  4072. var i = 0;
  4073. this.__iterate(function (v, k) {
  4074. // Keyed collections produce an array of tuples.
  4075. array[i++] = useTuples ? [k, v] : v;
  4076. });
  4077. return array;
  4078. },
  4079. toIndexedSeq: function toIndexedSeq() {
  4080. return new ToIndexedSequence(this);
  4081. },
  4082. toJS: function toJS$1() {
  4083. return toJS(this);
  4084. },
  4085. toKeyedSeq: function toKeyedSeq() {
  4086. return new ToKeyedSequence(this, true);
  4087. },
  4088. toMap: function toMap() {
  4089. // Use Late Binding here to solve the circular dependency.
  4090. return Map(this.toKeyedSeq());
  4091. },
  4092. toObject: toObject,
  4093. toOrderedMap: function toOrderedMap() {
  4094. // Use Late Binding here to solve the circular dependency.
  4095. return OrderedMap(this.toKeyedSeq());
  4096. },
  4097. toOrderedSet: function toOrderedSet() {
  4098. // Use Late Binding here to solve the circular dependency.
  4099. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  4100. },
  4101. toSet: function toSet() {
  4102. // Use Late Binding here to solve the circular dependency.
  4103. return Set(isKeyed(this) ? this.valueSeq() : this);
  4104. },
  4105. toSetSeq: function toSetSeq() {
  4106. return new ToSetSequence(this);
  4107. },
  4108. toSeq: function toSeq() {
  4109. return isIndexed(this)
  4110. ? this.toIndexedSeq()
  4111. : isKeyed(this)
  4112. ? this.toKeyedSeq()
  4113. : this.toSetSeq();
  4114. },
  4115. toStack: function toStack() {
  4116. // Use Late Binding here to solve the circular dependency.
  4117. return Stack(isKeyed(this) ? this.valueSeq() : this);
  4118. },
  4119. toList: function toList() {
  4120. // Use Late Binding here to solve the circular dependency.
  4121. return List(isKeyed(this) ? this.valueSeq() : this);
  4122. },
  4123. // ### Common JavaScript methods and properties
  4124. toString: function toString() {
  4125. return '[Collection]';
  4126. },
  4127. __toString: function __toString(head, tail) {
  4128. if (this.size === 0) {
  4129. return head + tail;
  4130. }
  4131. return (
  4132. head +
  4133. ' ' +
  4134. this.toSeq()
  4135. .map(this.__toStringMapper)
  4136. .join(', ') +
  4137. ' ' +
  4138. tail
  4139. );
  4140. },
  4141. // ### ES6 Collection methods (ES6 Array and Map)
  4142. concat: function concat() {
  4143. var values = [], len = arguments.length;
  4144. while ( len-- ) values[ len ] = arguments[ len ];
  4145. return reify(this, concatFactory(this, values));
  4146. },
  4147. includes: function includes(searchValue) {
  4148. return this.some(function (value) { return is(value, searchValue); });
  4149. },
  4150. entries: function entries() {
  4151. return this.__iterator(ITERATE_ENTRIES);
  4152. },
  4153. every: function every(predicate, context) {
  4154. assertNotInfinite(this.size);
  4155. var returnValue = true;
  4156. this.__iterate(function (v, k, c) {
  4157. if (!predicate.call(context, v, k, c)) {
  4158. returnValue = false;
  4159. return false;
  4160. }
  4161. });
  4162. return returnValue;
  4163. },
  4164. filter: function filter(predicate, context) {
  4165. return reify(this, filterFactory(this, predicate, context, true));
  4166. },
  4167. find: function find(predicate, context, notSetValue) {
  4168. var entry = this.findEntry(predicate, context);
  4169. return entry ? entry[1] : notSetValue;
  4170. },
  4171. forEach: function forEach(sideEffect, context) {
  4172. assertNotInfinite(this.size);
  4173. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  4174. },
  4175. join: function join(separator) {
  4176. assertNotInfinite(this.size);
  4177. separator = separator !== undefined ? '' + separator : ',';
  4178. var joined = '';
  4179. var isFirst = true;
  4180. this.__iterate(function (v) {
  4181. isFirst ? (isFirst = false) : (joined += separator);
  4182. joined += v !== null && v !== undefined ? v.toString() : '';
  4183. });
  4184. return joined;
  4185. },
  4186. keys: function keys() {
  4187. return this.__iterator(ITERATE_KEYS);
  4188. },
  4189. map: function map(mapper, context) {
  4190. return reify(this, mapFactory(this, mapper, context));
  4191. },
  4192. reduce: function reduce$1(reducer, initialReduction, context) {
  4193. return reduce(
  4194. this,
  4195. reducer,
  4196. initialReduction,
  4197. context,
  4198. arguments.length < 2,
  4199. false
  4200. );
  4201. },
  4202. reduceRight: function reduceRight(reducer, initialReduction, context) {
  4203. return reduce(
  4204. this,
  4205. reducer,
  4206. initialReduction,
  4207. context,
  4208. arguments.length < 2,
  4209. true
  4210. );
  4211. },
  4212. reverse: function reverse() {
  4213. return reify(this, reverseFactory(this, true));
  4214. },
  4215. slice: function slice(begin, end) {
  4216. return reify(this, sliceFactory(this, begin, end, true));
  4217. },
  4218. some: function some(predicate, context) {
  4219. return !this.every(not(predicate), context);
  4220. },
  4221. sort: function sort(comparator) {
  4222. return reify(this, sortFactory(this, comparator));
  4223. },
  4224. values: function values() {
  4225. return this.__iterator(ITERATE_VALUES);
  4226. },
  4227. // ### More sequential methods
  4228. butLast: function butLast() {
  4229. return this.slice(0, -1);
  4230. },
  4231. isEmpty: function isEmpty() {
  4232. return this.size !== undefined ? this.size === 0 : !this.some(function () { return true; });
  4233. },
  4234. count: function count(predicate, context) {
  4235. return ensureSize(
  4236. predicate ? this.toSeq().filter(predicate, context) : this
  4237. );
  4238. },
  4239. countBy: function countBy(grouper, context) {
  4240. return countByFactory(this, grouper, context);
  4241. },
  4242. equals: function equals(other) {
  4243. return deepEqual(this, other);
  4244. },
  4245. entrySeq: function entrySeq() {
  4246. var collection = this;
  4247. if (collection._cache) {
  4248. // We cache as an entries array, so we can just return the cache!
  4249. return new ArraySeq(collection._cache);
  4250. }
  4251. var entriesSequence = collection
  4252. .toSeq()
  4253. .map(entryMapper)
  4254. .toIndexedSeq();
  4255. entriesSequence.fromEntrySeq = function () { return collection.toSeq(); };
  4256. return entriesSequence;
  4257. },
  4258. filterNot: function filterNot(predicate, context) {
  4259. return this.filter(not(predicate), context);
  4260. },
  4261. findEntry: function findEntry(predicate, context, notSetValue) {
  4262. var found = notSetValue;
  4263. this.__iterate(function (v, k, c) {
  4264. if (predicate.call(context, v, k, c)) {
  4265. found = [k, v];
  4266. return false;
  4267. }
  4268. });
  4269. return found;
  4270. },
  4271. findKey: function findKey(predicate, context) {
  4272. var entry = this.findEntry(predicate, context);
  4273. return entry && entry[0];
  4274. },
  4275. findLast: function findLast(predicate, context, notSetValue) {
  4276. return this.toKeyedSeq()
  4277. .reverse()
  4278. .find(predicate, context, notSetValue);
  4279. },
  4280. findLastEntry: function findLastEntry(predicate, context, notSetValue) {
  4281. return this.toKeyedSeq()
  4282. .reverse()
  4283. .findEntry(predicate, context, notSetValue);
  4284. },
  4285. findLastKey: function findLastKey(predicate, context) {
  4286. return this.toKeyedSeq()
  4287. .reverse()
  4288. .findKey(predicate, context);
  4289. },
  4290. first: function first(notSetValue) {
  4291. return this.find(returnTrue, null, notSetValue);
  4292. },
  4293. flatMap: function flatMap(mapper, context) {
  4294. return reify(this, flatMapFactory(this, mapper, context));
  4295. },
  4296. flatten: function flatten(depth) {
  4297. return reify(this, flattenFactory(this, depth, true));
  4298. },
  4299. fromEntrySeq: function fromEntrySeq() {
  4300. return new FromEntriesSequence(this);
  4301. },
  4302. get: function get(searchKey, notSetValue) {
  4303. return this.find(function (_, key) { return is(key, searchKey); }, undefined, notSetValue);
  4304. },
  4305. getIn: getIn$1,
  4306. groupBy: function groupBy(grouper, context) {
  4307. return groupByFactory(this, grouper, context);
  4308. },
  4309. has: function has(searchKey) {
  4310. return this.get(searchKey, NOT_SET) !== NOT_SET;
  4311. },
  4312. hasIn: hasIn$1,
  4313. isSubset: function isSubset(iter) {
  4314. iter = typeof iter.includes === 'function' ? iter : Collection(iter);
  4315. return this.every(function (value) { return iter.includes(value); });
  4316. },
  4317. isSuperset: function isSuperset(iter) {
  4318. iter = typeof iter.isSubset === 'function' ? iter : Collection(iter);
  4319. return iter.isSubset(this);
  4320. },
  4321. keyOf: function keyOf(searchValue) {
  4322. return this.findKey(function (value) { return is(value, searchValue); });
  4323. },
  4324. keySeq: function keySeq() {
  4325. return this.toSeq()
  4326. .map(keyMapper)
  4327. .toIndexedSeq();
  4328. },
  4329. last: function last(notSetValue) {
  4330. return this.toSeq()
  4331. .reverse()
  4332. .first(notSetValue);
  4333. },
  4334. lastKeyOf: function lastKeyOf(searchValue) {
  4335. return this.toKeyedSeq()
  4336. .reverse()
  4337. .keyOf(searchValue);
  4338. },
  4339. max: function max(comparator) {
  4340. return maxFactory(this, comparator);
  4341. },
  4342. maxBy: function maxBy(mapper, comparator) {
  4343. return maxFactory(this, comparator, mapper);
  4344. },
  4345. min: function min(comparator) {
  4346. return maxFactory(
  4347. this,
  4348. comparator ? neg(comparator) : defaultNegComparator
  4349. );
  4350. },
  4351. minBy: function minBy(mapper, comparator) {
  4352. return maxFactory(
  4353. this,
  4354. comparator ? neg(comparator) : defaultNegComparator,
  4355. mapper
  4356. );
  4357. },
  4358. rest: function rest() {
  4359. return this.slice(1);
  4360. },
  4361. skip: function skip(amount) {
  4362. return amount === 0 ? this : this.slice(Math.max(0, amount));
  4363. },
  4364. skipLast: function skipLast(amount) {
  4365. return amount === 0 ? this : this.slice(0, -Math.max(0, amount));
  4366. },
  4367. skipWhile: function skipWhile(predicate, context) {
  4368. return reify(this, skipWhileFactory(this, predicate, context, true));
  4369. },
  4370. skipUntil: function skipUntil(predicate, context) {
  4371. return this.skipWhile(not(predicate), context);
  4372. },
  4373. sortBy: function sortBy(mapper, comparator) {
  4374. return reify(this, sortFactory(this, comparator, mapper));
  4375. },
  4376. take: function take(amount) {
  4377. return this.slice(0, Math.max(0, amount));
  4378. },
  4379. takeLast: function takeLast(amount) {
  4380. return this.slice(-Math.max(0, amount));
  4381. },
  4382. takeWhile: function takeWhile(predicate, context) {
  4383. return reify(this, takeWhileFactory(this, predicate, context));
  4384. },
  4385. takeUntil: function takeUntil(predicate, context) {
  4386. return this.takeWhile(not(predicate), context);
  4387. },
  4388. update: function update(fn) {
  4389. return fn(this);
  4390. },
  4391. valueSeq: function valueSeq() {
  4392. return this.toIndexedSeq();
  4393. },
  4394. // ### Hashable Object
  4395. hashCode: function hashCode() {
  4396. return this.__hash || (this.__hash = hashCollection(this));
  4397. },
  4398. // ### Internal
  4399. // abstract __iterate(fn, reverse)
  4400. // abstract __iterator(type, reverse)
  4401. });
  4402. var CollectionPrototype = Collection.prototype;
  4403. CollectionPrototype[IS_COLLECTION_SYMBOL] = true;
  4404. CollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.values;
  4405. CollectionPrototype.toJSON = CollectionPrototype.toArray;
  4406. CollectionPrototype.__toStringMapper = quoteString;
  4407. CollectionPrototype.inspect = CollectionPrototype.toSource = function() {
  4408. return this.toString();
  4409. };
  4410. CollectionPrototype.chain = CollectionPrototype.flatMap;
  4411. CollectionPrototype.contains = CollectionPrototype.includes;
  4412. mixin(KeyedCollection, {
  4413. // ### More sequential methods
  4414. flip: function flip() {
  4415. return reify(this, flipFactory(this));
  4416. },
  4417. mapEntries: function mapEntries(mapper, context) {
  4418. var this$1 = this;
  4419. var iterations = 0;
  4420. return reify(
  4421. this,
  4422. this.toSeq()
  4423. .map(function (v, k) { return mapper.call(context, [k, v], iterations++, this$1); })
  4424. .fromEntrySeq()
  4425. );
  4426. },
  4427. mapKeys: function mapKeys(mapper, context) {
  4428. var this$1 = this;
  4429. return reify(
  4430. this,
  4431. this.toSeq()
  4432. .flip()
  4433. .map(function (k, v) { return mapper.call(context, k, v, this$1); })
  4434. .flip()
  4435. );
  4436. },
  4437. });
  4438. var KeyedCollectionPrototype = KeyedCollection.prototype;
  4439. KeyedCollectionPrototype[IS_KEYED_SYMBOL] = true;
  4440. KeyedCollectionPrototype[ITERATOR_SYMBOL] = CollectionPrototype.entries;
  4441. KeyedCollectionPrototype.toJSON = toObject;
  4442. KeyedCollectionPrototype.__toStringMapper = function (v, k) { return quoteString(k) + ': ' + quoteString(v); };
  4443. mixin(IndexedCollection, {
  4444. // ### Conversion to other types
  4445. toKeyedSeq: function toKeyedSeq() {
  4446. return new ToKeyedSequence(this, false);
  4447. },
  4448. // ### ES6 Collection methods (ES6 Array and Map)
  4449. filter: function filter(predicate, context) {
  4450. return reify(this, filterFactory(this, predicate, context, false));
  4451. },
  4452. findIndex: function findIndex(predicate, context) {
  4453. var entry = this.findEntry(predicate, context);
  4454. return entry ? entry[0] : -1;
  4455. },
  4456. indexOf: function indexOf(searchValue) {
  4457. var key = this.keyOf(searchValue);
  4458. return key === undefined ? -1 : key;
  4459. },
  4460. lastIndexOf: function lastIndexOf(searchValue) {
  4461. var key = this.lastKeyOf(searchValue);
  4462. return key === undefined ? -1 : key;
  4463. },
  4464. reverse: function reverse() {
  4465. return reify(this, reverseFactory(this, false));
  4466. },
  4467. slice: function slice(begin, end) {
  4468. return reify(this, sliceFactory(this, begin, end, false));
  4469. },
  4470. splice: function splice(index, removeNum /*, ...values*/) {
  4471. var numArgs = arguments.length;
  4472. removeNum = Math.max(removeNum || 0, 0);
  4473. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  4474. return this;
  4475. }
  4476. // If index is negative, it should resolve relative to the size of the
  4477. // collection. However size may be expensive to compute if not cached, so
  4478. // only call count() if the number is in fact negative.
  4479. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  4480. var spliced = this.slice(0, index);
  4481. return reify(
  4482. this,
  4483. numArgs === 1
  4484. ? spliced
  4485. : spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  4486. );
  4487. },
  4488. // ### More collection methods
  4489. findLastIndex: function findLastIndex(predicate, context) {
  4490. var entry = this.findLastEntry(predicate, context);
  4491. return entry ? entry[0] : -1;
  4492. },
  4493. first: function first(notSetValue) {
  4494. return this.get(0, notSetValue);
  4495. },
  4496. flatten: function flatten(depth) {
  4497. return reify(this, flattenFactory(this, depth, false));
  4498. },
  4499. get: function get(index, notSetValue) {
  4500. index = wrapIndex(this, index);
  4501. return index < 0 ||
  4502. (this.size === Infinity || (this.size !== undefined && index > this.size))
  4503. ? notSetValue
  4504. : this.find(function (_, key) { return key === index; }, undefined, notSetValue);
  4505. },
  4506. has: function has(index) {
  4507. index = wrapIndex(this, index);
  4508. return (
  4509. index >= 0 &&
  4510. (this.size !== undefined
  4511. ? this.size === Infinity || index < this.size
  4512. : this.indexOf(index) !== -1)
  4513. );
  4514. },
  4515. interpose: function interpose(separator) {
  4516. return reify(this, interposeFactory(this, separator));
  4517. },
  4518. interleave: function interleave(/*...collections*/) {
  4519. var collections = [this].concat(arrCopy(arguments));
  4520. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, collections);
  4521. var interleaved = zipped.flatten(true);
  4522. if (zipped.size) {
  4523. interleaved.size = zipped.size * collections.length;
  4524. }
  4525. return reify(this, interleaved);
  4526. },
  4527. keySeq: function keySeq() {
  4528. return Range(0, this.size);
  4529. },
  4530. last: function last(notSetValue) {
  4531. return this.get(-1, notSetValue);
  4532. },
  4533. skipWhile: function skipWhile(predicate, context) {
  4534. return reify(this, skipWhileFactory(this, predicate, context, false));
  4535. },
  4536. zip: function zip(/*, ...collections */) {
  4537. var collections = [this].concat(arrCopy(arguments));
  4538. return reify(this, zipWithFactory(this, defaultZipper, collections));
  4539. },
  4540. zipAll: function zipAll(/*, ...collections */) {
  4541. var collections = [this].concat(arrCopy(arguments));
  4542. return reify(this, zipWithFactory(this, defaultZipper, collections, true));
  4543. },
  4544. zipWith: function zipWith(zipper /*, ...collections */) {
  4545. var collections = arrCopy(arguments);
  4546. collections[0] = this;
  4547. return reify(this, zipWithFactory(this, zipper, collections));
  4548. },
  4549. });
  4550. var IndexedCollectionPrototype = IndexedCollection.prototype;
  4551. IndexedCollectionPrototype[IS_INDEXED_SYMBOL] = true;
  4552. IndexedCollectionPrototype[IS_ORDERED_SYMBOL] = true;
  4553. mixin(SetCollection, {
  4554. // ### ES6 Collection methods (ES6 Array and Map)
  4555. get: function get(value, notSetValue) {
  4556. return this.has(value) ? value : notSetValue;
  4557. },
  4558. includes: function includes(value) {
  4559. return this.has(value);
  4560. },
  4561. // ### More sequential methods
  4562. keySeq: function keySeq() {
  4563. return this.valueSeq();
  4564. },
  4565. });
  4566. SetCollection.prototype.has = CollectionPrototype.includes;
  4567. SetCollection.prototype.contains = SetCollection.prototype.includes;
  4568. // Mixin subclasses
  4569. mixin(KeyedSeq, KeyedCollection.prototype);
  4570. mixin(IndexedSeq, IndexedCollection.prototype);
  4571. mixin(SetSeq, SetCollection.prototype);
  4572. // #pragma Helper functions
  4573. function reduce(collection, reducer, reduction, context, useFirst, reverse) {
  4574. assertNotInfinite(collection.size);
  4575. collection.__iterate(function (v, k, c) {
  4576. if (useFirst) {
  4577. useFirst = false;
  4578. reduction = v;
  4579. } else {
  4580. reduction = reducer.call(context, reduction, v, k, c);
  4581. }
  4582. }, reverse);
  4583. return reduction;
  4584. }
  4585. function keyMapper(v, k) {
  4586. return k;
  4587. }
  4588. function entryMapper(v, k) {
  4589. return [k, v];
  4590. }
  4591. function not(predicate) {
  4592. return function() {
  4593. return !predicate.apply(this, arguments);
  4594. };
  4595. }
  4596. function neg(predicate) {
  4597. return function() {
  4598. return -predicate.apply(this, arguments);
  4599. };
  4600. }
  4601. function defaultZipper() {
  4602. return arrCopy(arguments);
  4603. }
  4604. function defaultNegComparator(a, b) {
  4605. return a < b ? 1 : a > b ? -1 : 0;
  4606. }
  4607. function hashCollection(collection) {
  4608. if (collection.size === Infinity) {
  4609. return 0;
  4610. }
  4611. var ordered = isOrdered(collection);
  4612. var keyed = isKeyed(collection);
  4613. var h = ordered ? 1 : 0;
  4614. var size = collection.__iterate(
  4615. keyed
  4616. ? ordered
  4617. ? function (v, k) {
  4618. h = (31 * h + hashMerge(hash(v), hash(k))) | 0;
  4619. }
  4620. : function (v, k) {
  4621. h = (h + hashMerge(hash(v), hash(k))) | 0;
  4622. }
  4623. : ordered
  4624. ? function (v) {
  4625. h = (31 * h + hash(v)) | 0;
  4626. }
  4627. : function (v) {
  4628. h = (h + hash(v)) | 0;
  4629. }
  4630. );
  4631. return murmurHashOfSize(size, h);
  4632. }
  4633. function murmurHashOfSize(size, h) {
  4634. h = imul(h, 0xcc9e2d51);
  4635. h = imul((h << 15) | (h >>> -15), 0x1b873593);
  4636. h = imul((h << 13) | (h >>> -13), 5);
  4637. h = ((h + 0xe6546b64) | 0) ^ size;
  4638. h = imul(h ^ (h >>> 16), 0x85ebca6b);
  4639. h = imul(h ^ (h >>> 13), 0xc2b2ae35);
  4640. h = smi(h ^ (h >>> 16));
  4641. return h;
  4642. }
  4643. function hashMerge(a, b) {
  4644. return (a ^ (b + 0x9e3779b9 + (a << 6) + (a >> 2))) | 0; // int
  4645. }
  4646. var OrderedSet = /*@__PURE__*/(function (Set$$1) {
  4647. function OrderedSet(value) {
  4648. return value === null || value === undefined
  4649. ? emptyOrderedSet()
  4650. : isOrderedSet(value)
  4651. ? value
  4652. : emptyOrderedSet().withMutations(function (set) {
  4653. var iter = SetCollection(value);
  4654. assertNotInfinite(iter.size);
  4655. iter.forEach(function (v) { return set.add(v); });
  4656. });
  4657. }
  4658. if ( Set$$1 ) OrderedSet.__proto__ = Set$$1;
  4659. OrderedSet.prototype = Object.create( Set$$1 && Set$$1.prototype );
  4660. OrderedSet.prototype.constructor = OrderedSet;
  4661. OrderedSet.of = function of (/*...values*/) {
  4662. return this(arguments);
  4663. };
  4664. OrderedSet.fromKeys = function fromKeys (value) {
  4665. return this(KeyedCollection(value).keySeq());
  4666. };
  4667. OrderedSet.prototype.toString = function toString () {
  4668. return this.__toString('OrderedSet {', '}');
  4669. };
  4670. return OrderedSet;
  4671. }(Set));
  4672. OrderedSet.isOrderedSet = isOrderedSet;
  4673. var OrderedSetPrototype = OrderedSet.prototype;
  4674. OrderedSetPrototype[IS_ORDERED_SYMBOL] = true;
  4675. OrderedSetPrototype.zip = IndexedCollectionPrototype.zip;
  4676. OrderedSetPrototype.zipWith = IndexedCollectionPrototype.zipWith;
  4677. OrderedSetPrototype.__empty = emptyOrderedSet;
  4678. OrderedSetPrototype.__make = makeOrderedSet;
  4679. function makeOrderedSet(map, ownerID) {
  4680. var set = Object.create(OrderedSetPrototype);
  4681. set.size = map ? map.size : 0;
  4682. set._map = map;
  4683. set.__ownerID = ownerID;
  4684. return set;
  4685. }
  4686. var EMPTY_ORDERED_SET;
  4687. function emptyOrderedSet() {
  4688. return (
  4689. EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()))
  4690. );
  4691. }
  4692. var Record = function Record(defaultValues, name) {
  4693. var hasInitialized;
  4694. var RecordType = function Record(values) {
  4695. var this$1 = this;
  4696. if (values instanceof RecordType) {
  4697. return values;
  4698. }
  4699. if (!(this instanceof RecordType)) {
  4700. return new RecordType(values);
  4701. }
  4702. if (!hasInitialized) {
  4703. hasInitialized = true;
  4704. var keys = Object.keys(defaultValues);
  4705. var indices = (RecordTypePrototype._indices = {});
  4706. // Deprecated: left to attempt not to break any external code which
  4707. // relies on a ._name property existing on record instances.
  4708. // Use Record.getDescriptiveName() instead
  4709. RecordTypePrototype._name = name;
  4710. RecordTypePrototype._keys = keys;
  4711. RecordTypePrototype._defaultValues = defaultValues;
  4712. for (var i = 0; i < keys.length; i++) {
  4713. var propName = keys[i];
  4714. indices[propName] = i;
  4715. if (RecordTypePrototype[propName]) {
  4716. /* eslint-disable no-console */
  4717. typeof console === 'object' &&
  4718. console.warn &&
  4719. console.warn(
  4720. 'Cannot define ' +
  4721. recordName(this) +
  4722. ' with property "' +
  4723. propName +
  4724. '" since that property name is part of the Record API.'
  4725. );
  4726. /* eslint-enable no-console */
  4727. } else {
  4728. setProp(RecordTypePrototype, propName);
  4729. }
  4730. }
  4731. }
  4732. this.__ownerID = undefined;
  4733. this._values = List().withMutations(function (l) {
  4734. l.setSize(this$1._keys.length);
  4735. KeyedCollection(values).forEach(function (v, k) {
  4736. l.set(this$1._indices[k], v === this$1._defaultValues[k] ? undefined : v);
  4737. });
  4738. });
  4739. };
  4740. var RecordTypePrototype = (RecordType.prototype = Object.create(
  4741. RecordPrototype
  4742. ));
  4743. RecordTypePrototype.constructor = RecordType;
  4744. if (name) {
  4745. RecordType.displayName = name;
  4746. }
  4747. return RecordType;
  4748. };
  4749. Record.prototype.toString = function toString () {
  4750. var str = recordName(this) + ' { ';
  4751. var keys = this._keys;
  4752. var k;
  4753. for (var i = 0, l = keys.length; i !== l; i++) {
  4754. k = keys[i];
  4755. str += (i ? ', ' : '') + k + ': ' + quoteString(this.get(k));
  4756. }
  4757. return str + ' }';
  4758. };
  4759. Record.prototype.equals = function equals (other) {
  4760. return (
  4761. this === other ||
  4762. (other &&
  4763. this._keys === other._keys &&
  4764. recordSeq(this).equals(recordSeq(other)))
  4765. );
  4766. };
  4767. Record.prototype.hashCode = function hashCode () {
  4768. return recordSeq(this).hashCode();
  4769. };
  4770. // @pragma Access
  4771. Record.prototype.has = function has (k) {
  4772. return this._indices.hasOwnProperty(k);
  4773. };
  4774. Record.prototype.get = function get (k, notSetValue) {
  4775. if (!this.has(k)) {
  4776. return notSetValue;
  4777. }
  4778. var index = this._indices[k];
  4779. var value = this._values.get(index);
  4780. return value === undefined ? this._defaultValues[k] : value;
  4781. };
  4782. // @pragma Modification
  4783. Record.prototype.set = function set (k, v) {
  4784. if (this.has(k)) {
  4785. var newValues = this._values.set(
  4786. this._indices[k],
  4787. v === this._defaultValues[k] ? undefined : v
  4788. );
  4789. if (newValues !== this._values && !this.__ownerID) {
  4790. return makeRecord(this, newValues);
  4791. }
  4792. }
  4793. return this;
  4794. };
  4795. Record.prototype.remove = function remove (k) {
  4796. return this.set(k);
  4797. };
  4798. Record.prototype.clear = function clear () {
  4799. var newValues = this._values.clear().setSize(this._keys.length);
  4800. return this.__ownerID ? this : makeRecord(this, newValues);
  4801. };
  4802. Record.prototype.wasAltered = function wasAltered () {
  4803. return this._values.wasAltered();
  4804. };
  4805. Record.prototype.toSeq = function toSeq () {
  4806. return recordSeq(this);
  4807. };
  4808. Record.prototype.toJS = function toJS$1 () {
  4809. return toJS(this);
  4810. };
  4811. Record.prototype.entries = function entries () {
  4812. return this.__iterator(ITERATE_ENTRIES);
  4813. };
  4814. Record.prototype.__iterator = function __iterator (type, reverse) {
  4815. return recordSeq(this).__iterator(type, reverse);
  4816. };
  4817. Record.prototype.__iterate = function __iterate (fn, reverse) {
  4818. return recordSeq(this).__iterate(fn, reverse);
  4819. };
  4820. Record.prototype.__ensureOwner = function __ensureOwner (ownerID) {
  4821. if (ownerID === this.__ownerID) {
  4822. return this;
  4823. }
  4824. var newValues = this._values.__ensureOwner(ownerID);
  4825. if (!ownerID) {
  4826. this.__ownerID = ownerID;
  4827. this._values = newValues;
  4828. return this;
  4829. }
  4830. return makeRecord(this, newValues, ownerID);
  4831. };
  4832. Record.isRecord = isRecord;
  4833. Record.getDescriptiveName = recordName;
  4834. var RecordPrototype = Record.prototype;
  4835. RecordPrototype[IS_RECORD_SYMBOL] = true;
  4836. RecordPrototype[DELETE] = RecordPrototype.remove;
  4837. RecordPrototype.deleteIn = RecordPrototype.removeIn = deleteIn;
  4838. RecordPrototype.getIn = getIn$1;
  4839. RecordPrototype.hasIn = CollectionPrototype.hasIn;
  4840. RecordPrototype.merge = merge;
  4841. RecordPrototype.mergeWith = mergeWith;
  4842. RecordPrototype.mergeIn = mergeIn;
  4843. RecordPrototype.mergeDeep = mergeDeep$1;
  4844. RecordPrototype.mergeDeepWith = mergeDeepWith$1;
  4845. RecordPrototype.mergeDeepIn = mergeDeepIn;
  4846. RecordPrototype.setIn = setIn$1;
  4847. RecordPrototype.update = update$1;
  4848. RecordPrototype.updateIn = updateIn$1;
  4849. RecordPrototype.withMutations = withMutations;
  4850. RecordPrototype.asMutable = asMutable;
  4851. RecordPrototype.asImmutable = asImmutable;
  4852. RecordPrototype[ITERATOR_SYMBOL] = RecordPrototype.entries;
  4853. RecordPrototype.toJSON = RecordPrototype.toObject =
  4854. CollectionPrototype.toObject;
  4855. RecordPrototype.inspect = RecordPrototype.toSource = function() {
  4856. return this.toString();
  4857. };
  4858. function makeRecord(likeRecord, values, ownerID) {
  4859. var record = Object.create(Object.getPrototypeOf(likeRecord));
  4860. record._values = values;
  4861. record.__ownerID = ownerID;
  4862. return record;
  4863. }
  4864. function recordName(record) {
  4865. return record.constructor.displayName || record.constructor.name || 'Record';
  4866. }
  4867. function recordSeq(record) {
  4868. return keyedSeqFromValue(record._keys.map(function (k) { return [k, record.get(k)]; }));
  4869. }
  4870. function setProp(prototype, name) {
  4871. try {
  4872. Object.defineProperty(prototype, name, {
  4873. get: function() {
  4874. return this.get(name);
  4875. },
  4876. set: function(value) {
  4877. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  4878. this.set(name, value);
  4879. },
  4880. });
  4881. } catch (error) {
  4882. // Object.defineProperty failed. Probably IE8.
  4883. }
  4884. }
  4885. /**
  4886. * Returns a lazy Seq of `value` repeated `times` times. When `times` is
  4887. * undefined, returns an infinite sequence of `value`.
  4888. */
  4889. var Repeat = /*@__PURE__*/(function (IndexedSeq$$1) {
  4890. function Repeat(value, times) {
  4891. if (!(this instanceof Repeat)) {
  4892. return new Repeat(value, times);
  4893. }
  4894. this._value = value;
  4895. this.size = times === undefined ? Infinity : Math.max(0, times);
  4896. if (this.size === 0) {
  4897. if (EMPTY_REPEAT) {
  4898. return EMPTY_REPEAT;
  4899. }
  4900. EMPTY_REPEAT = this;
  4901. }
  4902. }
  4903. if ( IndexedSeq$$1 ) Repeat.__proto__ = IndexedSeq$$1;
  4904. Repeat.prototype = Object.create( IndexedSeq$$1 && IndexedSeq$$1.prototype );
  4905. Repeat.prototype.constructor = Repeat;
  4906. Repeat.prototype.toString = function toString () {
  4907. if (this.size === 0) {
  4908. return 'Repeat []';
  4909. }
  4910. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  4911. };
  4912. Repeat.prototype.get = function get (index, notSetValue) {
  4913. return this.has(index) ? this._value : notSetValue;
  4914. };
  4915. Repeat.prototype.includes = function includes (searchValue) {
  4916. return is(this._value, searchValue);
  4917. };
  4918. Repeat.prototype.slice = function slice (begin, end) {
  4919. var size = this.size;
  4920. return wholeSlice(begin, end, size)
  4921. ? this
  4922. : new Repeat(
  4923. this._value,
  4924. resolveEnd(end, size) - resolveBegin(begin, size)
  4925. );
  4926. };
  4927. Repeat.prototype.reverse = function reverse () {
  4928. return this;
  4929. };
  4930. Repeat.prototype.indexOf = function indexOf (searchValue) {
  4931. if (is(this._value, searchValue)) {
  4932. return 0;
  4933. }
  4934. return -1;
  4935. };
  4936. Repeat.prototype.lastIndexOf = function lastIndexOf (searchValue) {
  4937. if (is(this._value, searchValue)) {
  4938. return this.size;
  4939. }
  4940. return -1;
  4941. };
  4942. Repeat.prototype.__iterate = function __iterate (fn, reverse) {
  4943. var size = this.size;
  4944. var i = 0;
  4945. while (i !== size) {
  4946. if (fn(this._value, reverse ? size - ++i : i++, this) === false) {
  4947. break;
  4948. }
  4949. }
  4950. return i;
  4951. };
  4952. Repeat.prototype.__iterator = function __iterator (type, reverse) {
  4953. var this$1 = this;
  4954. var size = this.size;
  4955. var i = 0;
  4956. return new Iterator(
  4957. function () { return i === size
  4958. ? iteratorDone()
  4959. : iteratorValue(type, reverse ? size - ++i : i++, this$1._value); }
  4960. );
  4961. };
  4962. Repeat.prototype.equals = function equals (other) {
  4963. return other instanceof Repeat
  4964. ? is(this._value, other._value)
  4965. : deepEqual(other);
  4966. };
  4967. return Repeat;
  4968. }(IndexedSeq));
  4969. var EMPTY_REPEAT;
  4970. function fromJS(value, converter) {
  4971. return fromJSWith(
  4972. [],
  4973. converter || defaultConverter,
  4974. value,
  4975. '',
  4976. converter && converter.length > 2 ? [] : undefined,
  4977. { '': value }
  4978. );
  4979. }
  4980. function fromJSWith(stack, converter, value, key, keyPath, parentValue) {
  4981. var toSeq = Array.isArray(value)
  4982. ? IndexedSeq
  4983. : isPlainObj(value)
  4984. ? KeyedSeq
  4985. : null;
  4986. if (toSeq) {
  4987. if (~stack.indexOf(value)) {
  4988. throw new TypeError('Cannot convert circular structure to Immutable');
  4989. }
  4990. stack.push(value);
  4991. keyPath && key !== '' && keyPath.push(key);
  4992. var converted = converter.call(
  4993. parentValue,
  4994. key,
  4995. toSeq(value).map(function (v, k) { return fromJSWith(stack, converter, v, k, keyPath, value); }
  4996. ),
  4997. keyPath && keyPath.slice()
  4998. );
  4999. stack.pop();
  5000. keyPath && keyPath.pop();
  5001. return converted;
  5002. }
  5003. return value;
  5004. }
  5005. function defaultConverter(k, v) {
  5006. return isKeyed(v) ? v.toMap() : v.toList();
  5007. }
  5008. var version = "4.0.0-rc.11";
  5009. var Immutable = {
  5010. version: version,
  5011. Collection: Collection,
  5012. // Note: Iterable is deprecated
  5013. Iterable: Collection,
  5014. Seq: Seq,
  5015. Map: Map,
  5016. OrderedMap: OrderedMap,
  5017. List: List,
  5018. Stack: Stack,
  5019. Set: Set,
  5020. OrderedSet: OrderedSet,
  5021. Record: Record,
  5022. Range: Range,
  5023. Repeat: Repeat,
  5024. is: is,
  5025. fromJS: fromJS,
  5026. hash: hash,
  5027. isImmutable: isImmutable,
  5028. isCollection: isCollection,
  5029. isKeyed: isKeyed,
  5030. isIndexed: isIndexed,
  5031. isAssociative: isAssociative,
  5032. isOrdered: isOrdered,
  5033. isValueObject: isValueObject,
  5034. isSeq: isSeq,
  5035. isList: isList,
  5036. isMap: isMap,
  5037. isOrderedMap: isOrderedMap,
  5038. isStack: isStack,
  5039. isSet: isSet,
  5040. isOrderedSet: isOrderedSet,
  5041. isRecord: isRecord,
  5042. get: get,
  5043. getIn: getIn,
  5044. has: has,
  5045. hasIn: hasIn,
  5046. merge: merge$1,
  5047. mergeDeep: mergeDeep,
  5048. mergeWith: mergeWith$1,
  5049. mergeDeepWith: mergeDeepWith,
  5050. remove: remove,
  5051. removeIn: removeIn,
  5052. set: set,
  5053. setIn: setIn,
  5054. update: update,
  5055. updateIn: updateIn,
  5056. };
  5057. // Note: Iterable is deprecated
  5058. var Iterable = Collection;
  5059. exports.default = Immutable;
  5060. exports.version = version;
  5061. exports.Collection = Collection;
  5062. exports.Iterable = Iterable;
  5063. exports.Seq = Seq;
  5064. exports.Map = Map;
  5065. exports.OrderedMap = OrderedMap;
  5066. exports.List = List;
  5067. exports.Stack = Stack;
  5068. exports.Set = Set;
  5069. exports.OrderedSet = OrderedSet;
  5070. exports.Record = Record;
  5071. exports.Range = Range;
  5072. exports.Repeat = Repeat;
  5073. exports.is = is;
  5074. exports.fromJS = fromJS;
  5075. exports.hash = hash;
  5076. exports.isImmutable = isImmutable;
  5077. exports.isCollection = isCollection;
  5078. exports.isKeyed = isKeyed;
  5079. exports.isIndexed = isIndexed;
  5080. exports.isAssociative = isAssociative;
  5081. exports.isOrdered = isOrdered;
  5082. exports.isValueObject = isValueObject;
  5083. exports.get = get;
  5084. exports.getIn = getIn;
  5085. exports.has = has;
  5086. exports.hasIn = hasIn;
  5087. exports.merge = merge$1;
  5088. exports.mergeDeep = mergeDeep;
  5089. exports.mergeWith = mergeWith$1;
  5090. exports.mergeDeepWith = mergeDeepWith;
  5091. exports.remove = remove;
  5092. exports.removeIn = removeIn;
  5093. exports.set = set;
  5094. exports.setIn = setIn;
  5095. exports.update = update;
  5096. exports.updateIn = updateIn;
  5097. Object.defineProperty(exports, '__esModule', { value: true });
  5098. })));
  5099. });
  5100. _commonjsHelpers.unwrapExports(immutable);
  5101. var draftjsUtils = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5102. !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;});
  5103. });
  5104. _commonjsHelpers.unwrapExports(draftjsUtils);
  5105. var draftjsUtils_1 = draftjsUtils.draftjsUtils;
  5106. var interopRequireDefault = _commonjsHelpers.createCommonjsModule(function (module) {
  5107. function _interopRequireDefault(obj) {
  5108. return obj && obj.__esModule ? obj : {
  5109. "default": obj
  5110. };
  5111. }
  5112. module.exports = _interopRequireDefault;
  5113. });
  5114. _commonjsHelpers.unwrapExports(interopRequireDefault);
  5115. /**
  5116. * Copyright (c) 2013-present, Facebook, Inc.
  5117. *
  5118. * This source code is licensed under the MIT license found in the
  5119. * LICENSE file in the root directory of this source tree.
  5120. */
  5121. /**
  5122. * Use invariant() to assert state which your program assumes to be true.
  5123. *
  5124. * Provide sprintf-style format (only %s is supported) and arguments
  5125. * to provide information about what broke and what you were
  5126. * expecting.
  5127. *
  5128. * The invariant message will be stripped in production, but the invariant
  5129. * will remain to ensure logic does not differ in production.
  5130. */
  5131. var invariant = function(condition, format, a, b, c, d, e, f) {
  5132. if (process.env.NODE_ENV !== 'production') {
  5133. if (format === undefined) {
  5134. throw new Error('invariant requires an error message argument');
  5135. }
  5136. }
  5137. if (!condition) {
  5138. var error;
  5139. if (format === undefined) {
  5140. error = new Error(
  5141. 'Minified exception occurred; use the non-minified dev environment ' +
  5142. 'for the full error message and additional helpful warnings.'
  5143. );
  5144. } else {
  5145. var args = [a, b, c, d, e, f];
  5146. var argIndex = 0;
  5147. error = new Error(
  5148. format.replace(/%s/g, function() { return args[argIndex++]; })
  5149. );
  5150. error.name = 'Invariant Violation';
  5151. }
  5152. error.framesToPop = 1; // we don't care about invariant's own frame
  5153. throw error;
  5154. }
  5155. };
  5156. var browser = invariant;
  5157. function _arrayWithoutHoles(arr) {
  5158. if (Array.isArray(arr)) {
  5159. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  5160. arr2[i] = arr[i];
  5161. }
  5162. return arr2;
  5163. }
  5164. }
  5165. var arrayWithoutHoles = _arrayWithoutHoles;
  5166. function _iterableToArray(iter) {
  5167. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  5168. }
  5169. var iterableToArray = _iterableToArray;
  5170. function _nonIterableSpread() {
  5171. throw new TypeError("Invalid attempt to spread non-iterable instance");
  5172. }
  5173. var nonIterableSpread = _nonIterableSpread;
  5174. function _toConsumableArray(arr) {
  5175. return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
  5176. }
  5177. var toConsumableArray = _toConsumableArray;
  5178. var updateMutation_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5179. Object.defineProperty(exports, "__esModule", {
  5180. value: true
  5181. });
  5182. exports["default"] = updateMutation;
  5183. function updateMutation(mutation, originalOffset, originalLength, newLength, prefixLength, suffixLength) {
  5184. // three cases we can reasonably adjust - disjoint mutations that
  5185. // happen later on where the offset will need to be changed,
  5186. // mutations that completely contain the new one where we can adjust
  5187. // the length, and mutations that occur partially within the new one.
  5188. var lengthDiff = newLength - originalLength;
  5189. var mutationAfterChange = originalOffset + originalLength <= mutation.offset;
  5190. if (mutationAfterChange) {
  5191. return Object.assign({}, mutation, {
  5192. offset: mutation.offset + lengthDiff
  5193. });
  5194. }
  5195. var mutationContainsChange = originalOffset >= mutation.offset && originalOffset + originalLength <= mutation.offset + mutation.length;
  5196. if (mutationContainsChange) {
  5197. return Object.assign({}, mutation, {
  5198. length: mutation.length + lengthDiff
  5199. });
  5200. }
  5201. var mutationWithinPrefixChange = mutation.offset >= originalOffset && mutation.offset + mutation.length <= originalOffset + originalLength && prefixLength > 0;
  5202. if (mutationWithinPrefixChange) {
  5203. return Object.assign({}, mutation, {
  5204. offset: mutation.offset + prefixLength
  5205. });
  5206. }
  5207. var mutationContainsPrefix = mutation.offset < originalOffset && mutation.offset + mutation.length <= originalOffset + originalLength && mutation.offset + mutation.length > originalOffset && prefixLength > 0;
  5208. if (mutationContainsPrefix) {
  5209. return [Object.assign({}, mutation, {
  5210. length: originalOffset - mutation.offset
  5211. }), Object.assign({}, mutation, {
  5212. offset: originalOffset + prefixLength,
  5213. length: mutation.offset - originalOffset + mutation.length
  5214. })];
  5215. }
  5216. var mutationContainsSuffix = mutation.offset >= originalOffset && mutation.offset + mutation.length > originalOffset + originalLength && originalOffset + originalLength > mutation.offset && suffixLength > 0;
  5217. if (mutationContainsSuffix) {
  5218. return [Object.assign({}, mutation, {
  5219. offset: mutation.offset + prefixLength,
  5220. length: originalOffset + originalLength - mutation.offset
  5221. }), Object.assign({}, mutation, {
  5222. offset: originalOffset + originalLength + prefixLength + suffixLength,
  5223. length: mutation.offset + mutation.length - (originalOffset + originalLength)
  5224. })];
  5225. }
  5226. return mutation;
  5227. }
  5228. });
  5229. _commonjsHelpers.unwrapExports(updateMutation_1);
  5230. var rangeSort = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5231. Object.defineProperty(exports, "__esModule", {
  5232. value: true
  5233. });
  5234. exports["default"] = void 0;
  5235. var _default = function _default(r1, r2) {
  5236. if (r1.offset === r2.offset) {
  5237. return r2.length - r1.length;
  5238. }
  5239. return r1.offset - r2.offset;
  5240. };
  5241. exports["default"] = _default;
  5242. });
  5243. _commonjsHelpers.unwrapExports(rangeSort);
  5244. var encodeBlock = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5245. Object.defineProperty(exports, "__esModule", {
  5246. value: true
  5247. });
  5248. exports["default"] = void 0;
  5249. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  5250. var _updateMutation = interopRequireDefault(updateMutation_1);
  5251. var _rangeSort = interopRequireDefault(rangeSort);
  5252. var ENTITY_MAP = {
  5253. '&': '&amp;',
  5254. '<': '&lt;',
  5255. '>': '&gt;',
  5256. '"': '&quot;',
  5257. "'": '&#x27;',
  5258. '`': '&#x60;',
  5259. '\n': '<br/>'
  5260. };
  5261. var _default = function _default(block) {
  5262. var blockText = (0, _toConsumableArray2["default"])(block.text);
  5263. var entities = block.entityRanges.sort(_rangeSort["default"]);
  5264. var styles = block.inlineStyleRanges.sort(_rangeSort["default"]);
  5265. var resultText = '';
  5266. var _loop = function _loop(index) {
  5267. var _char = blockText[index];
  5268. if (ENTITY_MAP[_char] !== undefined) {
  5269. var encoded = ENTITY_MAP[_char];
  5270. var resultIndex = (0, _toConsumableArray2["default"])(resultText).length;
  5271. resultText += encoded;
  5272. var updateForChar = function updateForChar(mutation) {
  5273. return (0, _updateMutation["default"])(mutation, resultIndex, _char.length, encoded.length, 0, 0);
  5274. };
  5275. entities = entities.map(updateForChar);
  5276. styles = styles.map(updateForChar);
  5277. } else {
  5278. resultText += _char;
  5279. }
  5280. };
  5281. for (var index = 0; index < blockText.length; index++) {
  5282. _loop(index);
  5283. }
  5284. return Object.assign({}, block, {
  5285. text: resultText,
  5286. inlineStyleRanges: styles,
  5287. entityRanges: entities
  5288. });
  5289. };
  5290. exports["default"] = _default;
  5291. });
  5292. _commonjsHelpers.unwrapExports(encodeBlock);
  5293. var _typeof_1 = _commonjsHelpers.createCommonjsModule(function (module) {
  5294. function _typeof(obj) {
  5295. if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
  5296. module.exports = _typeof = function _typeof(obj) {
  5297. return typeof obj;
  5298. };
  5299. } else {
  5300. module.exports = _typeof = function _typeof(obj) {
  5301. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
  5302. };
  5303. }
  5304. return _typeof(obj);
  5305. }
  5306. module.exports = _typeof;
  5307. });
  5308. var splitReactElement_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5309. Object.defineProperty(exports, "__esModule", {
  5310. value: true
  5311. });
  5312. exports["default"] = splitReactElement;
  5313. var _invariant = interopRequireDefault(browser);
  5314. var _react = interopRequireDefault(React__default);
  5315. var _server = interopRequireDefault(server);
  5316. // see http://w3c.github.io/html/syntax.html#writing-html-documents-elements
  5317. var VOID_TAGS = ['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'link', 'meta', 'param', 'source', 'track', 'wbr'];
  5318. function splitReactElement(element) {
  5319. if (VOID_TAGS.indexOf(element.type) !== -1) {
  5320. return _server["default"].renderToStaticMarkup(element);
  5321. }
  5322. var tags = _server["default"].renderToStaticMarkup(_react["default"].cloneElement(element, {}, '\r')).split('\r');
  5323. (0, _invariant["default"])(tags.length > 1, "convertToHTML: Element of type ".concat(element.type, " must render children"));
  5324. (0, _invariant["default"])(tags.length < 3, "convertToHTML: Element of type ".concat(element.type, " cannot use carriage return character"));
  5325. return {
  5326. start: tags[0],
  5327. end: tags[1]
  5328. };
  5329. }
  5330. });
  5331. _commonjsHelpers.unwrapExports(splitReactElement_1);
  5332. var getElementHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5333. Object.defineProperty(exports, "__esModule", {
  5334. value: true
  5335. });
  5336. exports["default"] = getElementHTML;
  5337. var _typeof2 = interopRequireDefault(_typeof_1);
  5338. var _invariant = interopRequireDefault(browser);
  5339. var _react = interopRequireDefault(React__default);
  5340. var _server = interopRequireDefault(server);
  5341. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  5342. function hasChildren(element) {
  5343. return _react["default"].isValidElement(element) && _react["default"].Children.count(element.props.children) > 0;
  5344. }
  5345. function getElementHTML(element) {
  5346. var text = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  5347. if (element === undefined || element === null) {
  5348. return element;
  5349. }
  5350. if (typeof element === 'string') {
  5351. return element;
  5352. }
  5353. if (_react["default"].isValidElement(element)) {
  5354. if (hasChildren(element)) {
  5355. return _server["default"].renderToStaticMarkup(element);
  5356. }
  5357. var tags = (0, _splitReactElement["default"])(element);
  5358. if (text !== null && (0, _typeof2["default"])(tags) === 'object') {
  5359. var start = tags.start,
  5360. end = tags.end;
  5361. return start + text + end;
  5362. }
  5363. return tags;
  5364. }
  5365. (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');
  5366. if (text !== null) {
  5367. var _start = element.start,
  5368. _end = element.end;
  5369. return _start + text + _end;
  5370. }
  5371. return element;
  5372. }
  5373. });
  5374. _commonjsHelpers.unwrapExports(getElementHTML_1);
  5375. var getElementTagLength_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5376. Object.defineProperty(exports, "__esModule", {
  5377. value: true
  5378. });
  5379. exports["default"] = void 0;
  5380. var _typeof2 = interopRequireDefault(_typeof_1);
  5381. var _react = interopRequireDefault(React__default);
  5382. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  5383. var getElementTagLength = function getElementTagLength(element) {
  5384. var type = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'start';
  5385. if (_react["default"].isValidElement(element)) {
  5386. var splitElement = (0, _splitReactElement["default"])(element);
  5387. if (typeof splitElement === 'string') {
  5388. return 0;
  5389. }
  5390. var length = splitElement[type].length;
  5391. var child = _react["default"].Children.toArray(element.props.children)[0];
  5392. return length + (child && _react["default"].isValidElement(child) ? getElementTagLength(child, type) : 0);
  5393. }
  5394. if ((0, _typeof2["default"])(element) === 'object') {
  5395. return element[type] ? element[type].length : 0;
  5396. }
  5397. return 0;
  5398. };
  5399. var _default = getElementTagLength;
  5400. exports["default"] = _default;
  5401. });
  5402. _commonjsHelpers.unwrapExports(getElementTagLength_1);
  5403. var blockEntities = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5404. Object.defineProperty(exports, "__esModule", {
  5405. value: true
  5406. });
  5407. exports["default"] = void 0;
  5408. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  5409. var _updateMutation = interopRequireDefault(updateMutation_1);
  5410. var _rangeSort = interopRequireDefault(rangeSort);
  5411. var _getElementHTML = interopRequireDefault(getElementHTML_1);
  5412. var _getElementTagLength = interopRequireDefault(getElementTagLength_1);
  5413. var converter = function converter() {
  5414. var originalText = arguments.length > 1 ? arguments[1] : undefined;
  5415. return originalText;
  5416. };
  5417. var _default = function _default(block, entityMap) {
  5418. var entityConverter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : converter;
  5419. var resultText = (0, _toConsumableArray2["default"])(block.text);
  5420. var getEntityHTML = entityConverter;
  5421. if (entityConverter.__isMiddleware) {
  5422. getEntityHTML = entityConverter(converter);
  5423. }
  5424. if (Object.prototype.hasOwnProperty.call(block, 'entityRanges') && block.entityRanges.length > 0) {
  5425. var entities = block.entityRanges.sort(_rangeSort["default"]);
  5426. var styles = block.inlineStyleRanges;
  5427. var _loop = function _loop(index) {
  5428. var entityRange = entities[index];
  5429. var entity = entityMap[entityRange.key];
  5430. var originalText = resultText.slice(entityRange.offset, entityRange.offset + entityRange.length).join('');
  5431. var entityHTML = getEntityHTML(entity, originalText);
  5432. var converted = (0, _toConsumableArray2["default"])((0, _getElementHTML["default"])(entityHTML, originalText) || originalText);
  5433. var prefixLength = (0, _getElementTagLength["default"])(entityHTML, 'start');
  5434. var suffixLength = (0, _getElementTagLength["default"])(entityHTML, 'end');
  5435. var updateLaterMutation = function updateLaterMutation(mutation, mutationIndex) {
  5436. if (mutationIndex > index || Object.prototype.hasOwnProperty.call(mutation, 'style')) {
  5437. return (0, _updateMutation["default"])(mutation, entityRange.offset, entityRange.length, converted.length, prefixLength, suffixLength);
  5438. }
  5439. return mutation;
  5440. };
  5441. var updateLaterMutations = function updateLaterMutations(mutationList) {
  5442. return mutationList.reduce(function (acc, mutation, mutationIndex) {
  5443. var updatedMutation = updateLaterMutation(mutation, mutationIndex);
  5444. if (Array.isArray(updatedMutation)) {
  5445. return acc.concat(updatedMutation);
  5446. }
  5447. return acc.concat([updatedMutation]);
  5448. }, []);
  5449. };
  5450. entities = updateLaterMutations(entities);
  5451. styles = updateLaterMutations(styles);
  5452. resultText = [].concat((0, _toConsumableArray2["default"])(resultText.slice(0, entityRange.offset)), (0, _toConsumableArray2["default"])(converted), (0, _toConsumableArray2["default"])(resultText.slice(entityRange.offset + entityRange.length)));
  5453. };
  5454. for (var index = 0; index < entities.length; index++) {
  5455. _loop(index);
  5456. }
  5457. return Object.assign({}, block, {
  5458. text: resultText.join(''),
  5459. inlineStyleRanges: styles,
  5460. entityRanges: entities
  5461. });
  5462. }
  5463. return block;
  5464. };
  5465. exports["default"] = _default;
  5466. });
  5467. _commonjsHelpers.unwrapExports(blockEntities);
  5468. var styleObjectFunction = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5469. Object.defineProperty(exports, "__esModule", {
  5470. value: true
  5471. });
  5472. exports["default"] = void 0;
  5473. var _default = function _default(object) {
  5474. return function (style) {
  5475. if (typeof object === 'function') {
  5476. return object(style);
  5477. }
  5478. return object[style];
  5479. };
  5480. };
  5481. exports["default"] = _default;
  5482. });
  5483. _commonjsHelpers.unwrapExports(styleObjectFunction);
  5484. var accumulateFunction = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5485. Object.defineProperty(exports, "__esModule", {
  5486. value: true
  5487. });
  5488. exports["default"] = void 0;
  5489. var _default = function _default(newFn, rest) {
  5490. return function () {
  5491. var newResult = newFn.apply(void 0, arguments);
  5492. if (newResult !== undefined && newResult !== null) {
  5493. return newResult;
  5494. }
  5495. return rest.apply(void 0, arguments);
  5496. };
  5497. };
  5498. exports["default"] = _default;
  5499. });
  5500. _commonjsHelpers.unwrapExports(accumulateFunction);
  5501. var defaultInlineHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5502. Object.defineProperty(exports, "__esModule", {
  5503. value: true
  5504. });
  5505. exports["default"] = defaultInlineHTML;
  5506. var _react = interopRequireDefault(React__default);
  5507. function defaultInlineHTML(style) {
  5508. switch (style) {
  5509. case 'BOLD':
  5510. return _react["default"].createElement("strong", null);
  5511. case 'ITALIC':
  5512. return _react["default"].createElement("em", null);
  5513. case 'UNDERLINE':
  5514. return _react["default"].createElement("u", null);
  5515. case 'CODE':
  5516. return _react["default"].createElement("code", null);
  5517. default:
  5518. return {
  5519. start: '',
  5520. end: ''
  5521. };
  5522. }
  5523. }
  5524. });
  5525. _commonjsHelpers.unwrapExports(defaultInlineHTML_1);
  5526. var blockInlineStyles = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5527. Object.defineProperty(exports, "__esModule", {
  5528. value: true
  5529. });
  5530. exports["default"] = void 0;
  5531. var _toConsumableArray2 = interopRequireDefault(toConsumableArray);
  5532. var _invariant = interopRequireDefault(browser);
  5533. var _styleObjectFunction = interopRequireDefault(styleObjectFunction);
  5534. var _accumulateFunction = interopRequireDefault(accumulateFunction);
  5535. var _getElementHTML = interopRequireDefault(getElementHTML_1);
  5536. var _rangeSort = interopRequireDefault(rangeSort);
  5537. var _defaultInlineHTML = interopRequireDefault(defaultInlineHTML_1);
  5538. var subtractStyles = function subtractStyles(original, toRemove) {
  5539. return original.filter(function (el) {
  5540. return !toRemove.some(function (elToRemove) {
  5541. return elToRemove.style === el.style;
  5542. });
  5543. });
  5544. };
  5545. var popEndingStyles = function popEndingStyles(styleStack, endingStyles) {
  5546. return endingStyles.reduceRight(function (stack, style) {
  5547. var styleToRemove = stack[stack.length - 1];
  5548. (0, _invariant["default"])(styleToRemove.style === style.style, "Style ".concat(styleToRemove.style, " to be removed doesn't match expected ").concat(style.style));
  5549. return stack.slice(0, -1);
  5550. }, styleStack);
  5551. };
  5552. var characterStyles = function characterStyles(offset, ranges) {
  5553. return ranges.filter(function (range) {
  5554. return offset >= range.offset && offset < range.offset + range.length;
  5555. });
  5556. };
  5557. var rangeIsSubset = function rangeIsSubset(firstRange, secondRange) {
  5558. // returns true if the second range is a subset of the first
  5559. var secondStartWithinFirst = firstRange.offset <= secondRange.offset;
  5560. var secondEndWithinFirst = firstRange.offset + firstRange.length >= secondRange.offset + secondRange.length;
  5561. return secondStartWithinFirst && secondEndWithinFirst;
  5562. };
  5563. var latestStyleLast = function latestStyleLast(s1, s2) {
  5564. // make sure longer-lasting styles are added first
  5565. var s2endIndex = s2.offset + s2.length;
  5566. var s1endIndex = s1.offset + s1.length;
  5567. return s2endIndex - s1endIndex;
  5568. };
  5569. var getStylesToReset = function getStylesToReset(remainingStyles, newStyles) {
  5570. var i = 0;
  5571. while (i < remainingStyles.length) {
  5572. if (newStyles.every(rangeIsSubset.bind(null, remainingStyles[i]))) {
  5573. i++;
  5574. } else {
  5575. return remainingStyles.slice(i);
  5576. }
  5577. }
  5578. return [];
  5579. };
  5580. var appendStartMarkup = function appendStartMarkup(inlineHTML, string, styleRange) {
  5581. return string + (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).start;
  5582. };
  5583. var prependEndMarkup = function prependEndMarkup(inlineHTML, string, styleRange) {
  5584. return (0, _getElementHTML["default"])(inlineHTML(styleRange.style)).end + string;
  5585. };
  5586. var defaultCustomInlineHTML = function defaultCustomInlineHTML(next) {
  5587. return function (style) {
  5588. return next(style);
  5589. };
  5590. };
  5591. defaultCustomInlineHTML.__isMiddleware = true;
  5592. var _default = function _default(rawBlock) {
  5593. var customInlineHTML = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : defaultCustomInlineHTML;
  5594. (0, _invariant["default"])(rawBlock !== null && rawBlock !== undefined, 'Expected raw block to be non-null');
  5595. var inlineHTML;
  5596. if (customInlineHTML.__isMiddleware === true) {
  5597. inlineHTML = customInlineHTML(_defaultInlineHTML["default"]);
  5598. } else {
  5599. inlineHTML = (0, _accumulateFunction["default"])((0, _styleObjectFunction["default"])(customInlineHTML), (0, _styleObjectFunction["default"])(_defaultInlineHTML["default"]));
  5600. }
  5601. var result = '';
  5602. var styleStack = [];
  5603. var sortedRanges = rawBlock.inlineStyleRanges.sort(_rangeSort["default"]);
  5604. var originalTextArray = (0, _toConsumableArray2["default"])(rawBlock.text);
  5605. for (var i = 0; i < originalTextArray.length; i++) {
  5606. var styles = characterStyles(i, sortedRanges);
  5607. var endingStyles = subtractStyles(styleStack, styles);
  5608. var newStyles = subtractStyles(styles, styleStack);
  5609. var remainingStyles = subtractStyles(styleStack, endingStyles); // reset styles: look for any already existing styles that will need to
  5610. // end before styles that are being added on this character. to solve this
  5611. // close out those current tags and all nested children,
  5612. // then open new ones nested within the new styles.
  5613. var resetStyles = getStylesToReset(remainingStyles, newStyles);
  5614. var openingStyles = resetStyles.concat(newStyles).sort(latestStyleLast);
  5615. var openingStyleTags = openingStyles.reduce(appendStartMarkup.bind(null, inlineHTML), '');
  5616. var endingStyleTags = endingStyles.concat(resetStyles).reduce(prependEndMarkup.bind(null, inlineHTML), '');
  5617. result += endingStyleTags + openingStyleTags + originalTextArray[i];
  5618. styleStack = popEndingStyles(styleStack, resetStyles.concat(endingStyles));
  5619. styleStack = styleStack.concat(openingStyles);
  5620. (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"));
  5621. }
  5622. result = styleStack.reduceRight(function (res, openStyle) {
  5623. return res + (0, _getElementHTML["default"])(inlineHTML(openStyle.style)).end;
  5624. }, result);
  5625. return result;
  5626. };
  5627. exports["default"] = _default;
  5628. });
  5629. _commonjsHelpers.unwrapExports(blockInlineStyles);
  5630. var blockTypeObjectFunction = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5631. Object.defineProperty(exports, "__esModule", {
  5632. value: true
  5633. });
  5634. exports["default"] = void 0;
  5635. var _default = function _default(typeObject) {
  5636. return function (block) {
  5637. if (typeof typeObject === 'function') {
  5638. // handle case where typeObject is already a function
  5639. return typeObject(block);
  5640. }
  5641. return typeObject[block.type];
  5642. };
  5643. };
  5644. exports["default"] = _default;
  5645. });
  5646. _commonjsHelpers.unwrapExports(blockTypeObjectFunction);
  5647. var getBlockTags_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5648. Object.defineProperty(exports, "__esModule", {
  5649. value: true
  5650. });
  5651. exports["default"] = getBlockTags;
  5652. var _invariant = interopRequireDefault(browser);
  5653. var _react = interopRequireDefault(React__default);
  5654. var _server = interopRequireDefault(server);
  5655. var _splitReactElement = interopRequireDefault(splitReactElement_1);
  5656. function hasChildren(element) {
  5657. return _react["default"].isValidElement(element) && _react["default"].Children.count(element.props.children) > 0;
  5658. }
  5659. function getBlockTags(blockHTML) {
  5660. (0, _invariant["default"])(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
  5661. if (typeof blockHTML === 'string') {
  5662. return blockHTML;
  5663. }
  5664. if (_react["default"].isValidElement(blockHTML)) {
  5665. if (hasChildren(blockHTML)) {
  5666. return _server["default"].renderToStaticMarkup(blockHTML);
  5667. }
  5668. return (0, _splitReactElement["default"])(blockHTML);
  5669. }
  5670. if (Object.prototype.hasOwnProperty.call(blockHTML, 'element') && _react["default"].isValidElement(blockHTML.element)) {
  5671. return Object.assign({}, blockHTML, (0, _splitReactElement["default"])(blockHTML.element));
  5672. }
  5673. (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');
  5674. return blockHTML;
  5675. }
  5676. });
  5677. _commonjsHelpers.unwrapExports(getBlockTags_1);
  5678. var getNestedBlockTags_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5679. Object.defineProperty(exports, "__esModule", {
  5680. value: true
  5681. });
  5682. exports["default"] = getNestedBlockTags;
  5683. var _invariant = interopRequireDefault(browser);
  5684. var _react = interopRequireDefault(React__default);
  5685. var _splitReactElement2 = interopRequireDefault(splitReactElement_1);
  5686. function getNestedBlockTags(blockHTML) {
  5687. (0, _invariant["default"])(blockHTML !== null && blockHTML !== undefined, 'Expected block HTML value to be non-null');
  5688. if (_react["default"].isValidElement(blockHTML.nest)) {
  5689. var _splitReactElement = (0, _splitReactElement2["default"])(blockHTML.nest),
  5690. start = _splitReactElement.start,
  5691. end = _splitReactElement.end;
  5692. return Object.assign({}, blockHTML, {
  5693. nestStart: start,
  5694. nestEnd: end
  5695. });
  5696. }
  5697. (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');
  5698. return blockHTML;
  5699. }
  5700. });
  5701. _commonjsHelpers.unwrapExports(getNestedBlockTags_1);
  5702. var defaultBlockHTML = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5703. Object.defineProperty(exports, "__esModule", {
  5704. value: true
  5705. });
  5706. exports["default"] = void 0;
  5707. var _react = interopRequireDefault(React__default);
  5708. var _default = {
  5709. unstyled: _react["default"].createElement("p", null),
  5710. paragraph: _react["default"].createElement("p", null),
  5711. 'header-one': _react["default"].createElement("h1", null),
  5712. 'header-two': _react["default"].createElement("h2", null),
  5713. 'header-three': _react["default"].createElement("h3", null),
  5714. 'header-four': _react["default"].createElement("h4", null),
  5715. 'header-five': _react["default"].createElement("h5", null),
  5716. 'header-six': _react["default"].createElement("h6", null),
  5717. blockquote: _react["default"].createElement("blockquote", null),
  5718. 'unordered-list-item': {
  5719. element: _react["default"].createElement("li", null),
  5720. nest: _react["default"].createElement("ul", null)
  5721. },
  5722. 'ordered-list-item': {
  5723. element: _react["default"].createElement("li", null),
  5724. nest: _react["default"].createElement("ol", null)
  5725. },
  5726. media: _react["default"].createElement("figure", null),
  5727. atomic: _react["default"].createElement("figure", null)
  5728. };
  5729. exports["default"] = _default;
  5730. });
  5731. _commonjsHelpers.unwrapExports(defaultBlockHTML);
  5732. var convertToHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5733. Object.defineProperty(exports, "__esModule", {
  5734. value: true
  5735. });
  5736. exports["default"] = void 0;
  5737. var _invariant = interopRequireDefault(browser);
  5738. var _react = interopRequireDefault(React__default);
  5739. var _server = interopRequireDefault(server);
  5740. var _encodeBlock = interopRequireDefault(encodeBlock);
  5741. var _blockEntities = interopRequireDefault(blockEntities);
  5742. var _blockInlineStyles = interopRequireDefault(blockInlineStyles);
  5743. var _accumulateFunction = interopRequireDefault(accumulateFunction);
  5744. var _blockTypeObjectFunction = interopRequireDefault(blockTypeObjectFunction);
  5745. var _getBlockTags = interopRequireDefault(getBlockTags_1);
  5746. var _getNestedBlockTags = interopRequireDefault(getNestedBlockTags_1);
  5747. var _defaultBlockHTML = interopRequireDefault(defaultBlockHTML);
  5748. // import Immutable from 'immutable'; // eslint-disable-line no-unused-vars
  5749. var defaultEntityToHTML = function defaultEntityToHTML(entity, originalText) {
  5750. return originalText;
  5751. };
  5752. var convertToHTML = function convertToHTML(_ref) {
  5753. var _ref$styleToHTML = _ref.styleToHTML,
  5754. styleToHTML = _ref$styleToHTML === void 0 ? {} : _ref$styleToHTML,
  5755. _ref$blockToHTML = _ref.blockToHTML,
  5756. blockToHTML = _ref$blockToHTML === void 0 ? {} : _ref$blockToHTML,
  5757. _ref$entityToHTML = _ref.entityToHTML,
  5758. entityToHTML = _ref$entityToHTML === void 0 ? defaultEntityToHTML : _ref$entityToHTML;
  5759. return function (contentState) {
  5760. (0, _invariant["default"])(contentState !== null && contentState !== undefined, 'Expected contentState to be non-null');
  5761. var getBlockHTML;
  5762. if (blockToHTML.__isMiddleware === true) {
  5763. getBlockHTML = blockToHTML((0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"]));
  5764. } else {
  5765. getBlockHTML = (0, _accumulateFunction["default"])((0, _blockTypeObjectFunction["default"])(blockToHTML), (0, _blockTypeObjectFunction["default"])(_defaultBlockHTML["default"]));
  5766. }
  5767. var rawState = (0, Draft.Draft.convertToRaw)(contentState);
  5768. var listStack = [];
  5769. var result = rawState.blocks.map(function (block) {
  5770. var type = block.type,
  5771. depth = block.depth;
  5772. var closeNestTags = '';
  5773. var openNestTags = '';
  5774. var blockHTMLResult = getBlockHTML(block);
  5775. if (!blockHTMLResult) {
  5776. throw new Error("convertToHTML: missing HTML definition for block with type ".concat(block.type));
  5777. }
  5778. if (!blockHTMLResult.nest) {
  5779. // this block can't be nested, so reset all nesting if necessary
  5780. closeNestTags = listStack.reduceRight(function (string, nestedBlock) {
  5781. return string + (0, _getNestedBlockTags["default"])(getBlockHTML(nestedBlock)).nestEnd;
  5782. }, '');
  5783. listStack = [];
  5784. } else {
  5785. while (depth + 1 !== listStack.length || type !== listStack[depth].type) {
  5786. if (depth + 1 === listStack.length) {
  5787. // depth is right but doesn't match type
  5788. var blockToClose = listStack[depth];
  5789. closeNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(blockToClose)).nestEnd;
  5790. openNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(block)).nestStart;
  5791. listStack[depth] = block;
  5792. } else if (depth + 1 < listStack.length) {
  5793. var _blockToClose = listStack[listStack.length - 1];
  5794. closeNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(_blockToClose)).nestEnd;
  5795. listStack = listStack.slice(0, -1);
  5796. } else {
  5797. openNestTags += (0, _getNestedBlockTags["default"])(getBlockHTML(block)).nestStart;
  5798. listStack.push(block);
  5799. }
  5800. }
  5801. }
  5802. var innerHTML = (0, _blockInlineStyles["default"])((0, _blockEntities["default"])((0, _encodeBlock["default"])(block), rawState.entityMap, entityToHTML), styleToHTML);
  5803. var blockHTML = (0, _getBlockTags["default"])(getBlockHTML(block));
  5804. var html;
  5805. if (typeof blockHTML === 'string') {
  5806. html = blockHTML;
  5807. } else {
  5808. html = blockHTML.start + innerHTML + blockHTML.end;
  5809. }
  5810. if (innerHTML.length === 0 && Object.prototype.hasOwnProperty.call(blockHTML, 'empty')) {
  5811. if (_react["default"].isValidElement(blockHTML.empty)) {
  5812. html = _server["default"].renderToStaticMarkup(blockHTML.empty);
  5813. } else {
  5814. html = blockHTML.empty;
  5815. }
  5816. }
  5817. return closeNestTags + openNestTags + html;
  5818. }).join('');
  5819. result = listStack.reduce(function (res, nestBlock) {
  5820. return res + (0, _getNestedBlockTags["default"])(getBlockHTML(nestBlock)).nestEnd;
  5821. }, result);
  5822. return result;
  5823. };
  5824. };
  5825. var _default = function _default() {
  5826. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  5827. args[_key] = arguments[_key];
  5828. }
  5829. if (args.length === 1 && Object.prototype.hasOwnProperty.call(args[0], '_map') && args[0].getBlockMap != null) {
  5830. // skip higher-order function and use defaults
  5831. return convertToHTML({}).apply(void 0, args);
  5832. }
  5833. return convertToHTML.apply(void 0, args);
  5834. };
  5835. exports["default"] = _default;
  5836. });
  5837. _commonjsHelpers.unwrapExports(convertToHTML_1);
  5838. var immutable$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  5839. /**
  5840. * Copyright (c) 2014-2015, Facebook, Inc.
  5841. * All rights reserved.
  5842. *
  5843. * This source code is licensed under the BSD-style license found in the
  5844. * LICENSE file in the root directory of this source tree. An additional grant
  5845. * of patent rights can be found in the PATENTS file in the same directory.
  5846. */
  5847. (function (global, factory) {
  5848. module.exports = factory() ;
  5849. }(_commonjsHelpers.commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
  5850. function createClass(ctor, superClass) {
  5851. if (superClass) {
  5852. ctor.prototype = Object.create(superClass.prototype);
  5853. }
  5854. ctor.prototype.constructor = ctor;
  5855. }
  5856. function Iterable(value) {
  5857. return isIterable(value) ? value : Seq(value);
  5858. }
  5859. createClass(KeyedIterable, Iterable);
  5860. function KeyedIterable(value) {
  5861. return isKeyed(value) ? value : KeyedSeq(value);
  5862. }
  5863. createClass(IndexedIterable, Iterable);
  5864. function IndexedIterable(value) {
  5865. return isIndexed(value) ? value : IndexedSeq(value);
  5866. }
  5867. createClass(SetIterable, Iterable);
  5868. function SetIterable(value) {
  5869. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  5870. }
  5871. function isIterable(maybeIterable) {
  5872. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  5873. }
  5874. function isKeyed(maybeKeyed) {
  5875. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  5876. }
  5877. function isIndexed(maybeIndexed) {
  5878. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  5879. }
  5880. function isAssociative(maybeAssociative) {
  5881. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  5882. }
  5883. function isOrdered(maybeOrdered) {
  5884. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  5885. }
  5886. Iterable.isIterable = isIterable;
  5887. Iterable.isKeyed = isKeyed;
  5888. Iterable.isIndexed = isIndexed;
  5889. Iterable.isAssociative = isAssociative;
  5890. Iterable.isOrdered = isOrdered;
  5891. Iterable.Keyed = KeyedIterable;
  5892. Iterable.Indexed = IndexedIterable;
  5893. Iterable.Set = SetIterable;
  5894. var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  5895. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  5896. var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  5897. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  5898. // Used for setting prototype methods that IE8 chokes on.
  5899. var DELETE = 'delete';
  5900. // Constants describing the size of trie nodes.
  5901. var SHIFT = 5; // Resulted in best performance after ______?
  5902. var SIZE = 1 << SHIFT;
  5903. var MASK = SIZE - 1;
  5904. // A consistent shared value representing "not set" which equals nothing other
  5905. // than itself, and nothing that could be provided externally.
  5906. var NOT_SET = {};
  5907. // Boolean references, Rough equivalent of `bool &`.
  5908. var CHANGE_LENGTH = { value: false };
  5909. var DID_ALTER = { value: false };
  5910. function MakeRef(ref) {
  5911. ref.value = false;
  5912. return ref;
  5913. }
  5914. function SetRef(ref) {
  5915. ref && (ref.value = true);
  5916. }
  5917. // A function which returns a value representing an "owner" for transient writes
  5918. // to tries. The return value will only ever equal itself, and will not equal
  5919. // the return of any subsequent call of this function.
  5920. function OwnerID() {}
  5921. // http://jsperf.com/copy-array-inline
  5922. function arrCopy(arr, offset) {
  5923. offset = offset || 0;
  5924. var len = Math.max(0, arr.length - offset);
  5925. var newArr = new Array(len);
  5926. for (var ii = 0; ii < len; ii++) {
  5927. newArr[ii] = arr[ii + offset];
  5928. }
  5929. return newArr;
  5930. }
  5931. function ensureSize(iter) {
  5932. if (iter.size === undefined) {
  5933. iter.size = iter.__iterate(returnTrue);
  5934. }
  5935. return iter.size;
  5936. }
  5937. function wrapIndex(iter, index) {
  5938. // This implements "is array index" which the ECMAString spec defines as:
  5939. //
  5940. // A String property name P is an array index if and only if
  5941. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  5942. // to 2^32−1.
  5943. //
  5944. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  5945. if (typeof index !== 'number') {
  5946. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  5947. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  5948. return NaN;
  5949. }
  5950. index = uint32Index;
  5951. }
  5952. return index < 0 ? ensureSize(iter) + index : index;
  5953. }
  5954. function returnTrue() {
  5955. return true;
  5956. }
  5957. function wholeSlice(begin, end, size) {
  5958. return (begin === 0 || (size !== undefined && begin <= -size)) &&
  5959. (end === undefined || (size !== undefined && end >= size));
  5960. }
  5961. function resolveBegin(begin, size) {
  5962. return resolveIndex(begin, size, 0);
  5963. }
  5964. function resolveEnd(end, size) {
  5965. return resolveIndex(end, size, size);
  5966. }
  5967. function resolveIndex(index, size, defaultIndex) {
  5968. return index === undefined ?
  5969. defaultIndex :
  5970. index < 0 ?
  5971. Math.max(0, size + index) :
  5972. size === undefined ?
  5973. index :
  5974. Math.min(size, index);
  5975. }
  5976. /* global Symbol */
  5977. var ITERATE_KEYS = 0;
  5978. var ITERATE_VALUES = 1;
  5979. var ITERATE_ENTRIES = 2;
  5980. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  5981. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  5982. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  5983. function Iterator(next) {
  5984. this.next = next;
  5985. }
  5986. Iterator.prototype.toString = function() {
  5987. return '[Iterator]';
  5988. };
  5989. Iterator.KEYS = ITERATE_KEYS;
  5990. Iterator.VALUES = ITERATE_VALUES;
  5991. Iterator.ENTRIES = ITERATE_ENTRIES;
  5992. Iterator.prototype.inspect =
  5993. Iterator.prototype.toSource = function () { return this.toString(); };
  5994. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  5995. return this;
  5996. };
  5997. function iteratorValue(type, k, v, iteratorResult) {
  5998. var value = type === 0 ? k : type === 1 ? v : [k, v];
  5999. iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
  6000. value: value, done: false
  6001. });
  6002. return iteratorResult;
  6003. }
  6004. function iteratorDone() {
  6005. return { value: undefined, done: true };
  6006. }
  6007. function hasIterator(maybeIterable) {
  6008. return !!getIteratorFn(maybeIterable);
  6009. }
  6010. function isIterator(maybeIterator) {
  6011. return maybeIterator && typeof maybeIterator.next === 'function';
  6012. }
  6013. function getIterator(iterable) {
  6014. var iteratorFn = getIteratorFn(iterable);
  6015. return iteratorFn && iteratorFn.call(iterable);
  6016. }
  6017. function getIteratorFn(iterable) {
  6018. var iteratorFn = iterable && (
  6019. (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  6020. iterable[FAUX_ITERATOR_SYMBOL]
  6021. );
  6022. if (typeof iteratorFn === 'function') {
  6023. return iteratorFn;
  6024. }
  6025. }
  6026. function isArrayLike(value) {
  6027. return value && typeof value.length === 'number';
  6028. }
  6029. createClass(Seq, Iterable);
  6030. function Seq(value) {
  6031. return value === null || value === undefined ? emptySequence() :
  6032. isIterable(value) ? value.toSeq() : seqFromValue(value);
  6033. }
  6034. Seq.of = function(/*...values*/) {
  6035. return Seq(arguments);
  6036. };
  6037. Seq.prototype.toSeq = function() {
  6038. return this;
  6039. };
  6040. Seq.prototype.toString = function() {
  6041. return this.__toString('Seq {', '}');
  6042. };
  6043. Seq.prototype.cacheResult = function() {
  6044. if (!this._cache && this.__iterateUncached) {
  6045. this._cache = this.entrySeq().toArray();
  6046. this.size = this._cache.length;
  6047. }
  6048. return this;
  6049. };
  6050. // abstract __iterateUncached(fn, reverse)
  6051. Seq.prototype.__iterate = function(fn, reverse) {
  6052. return seqIterate(this, fn, reverse, true);
  6053. };
  6054. // abstract __iteratorUncached(type, reverse)
  6055. Seq.prototype.__iterator = function(type, reverse) {
  6056. return seqIterator(this, type, reverse, true);
  6057. };
  6058. createClass(KeyedSeq, Seq);
  6059. function KeyedSeq(value) {
  6060. return value === null || value === undefined ?
  6061. emptySequence().toKeyedSeq() :
  6062. isIterable(value) ?
  6063. (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
  6064. keyedSeqFromValue(value);
  6065. }
  6066. KeyedSeq.prototype.toKeyedSeq = function() {
  6067. return this;
  6068. };
  6069. createClass(IndexedSeq, Seq);
  6070. function IndexedSeq(value) {
  6071. return value === null || value === undefined ? emptySequence() :
  6072. !isIterable(value) ? indexedSeqFromValue(value) :
  6073. isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
  6074. }
  6075. IndexedSeq.of = function(/*...values*/) {
  6076. return IndexedSeq(arguments);
  6077. };
  6078. IndexedSeq.prototype.toIndexedSeq = function() {
  6079. return this;
  6080. };
  6081. IndexedSeq.prototype.toString = function() {
  6082. return this.__toString('Seq [', ']');
  6083. };
  6084. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  6085. return seqIterate(this, fn, reverse, false);
  6086. };
  6087. IndexedSeq.prototype.__iterator = function(type, reverse) {
  6088. return seqIterator(this, type, reverse, false);
  6089. };
  6090. createClass(SetSeq, Seq);
  6091. function SetSeq(value) {
  6092. return (
  6093. value === null || value === undefined ? emptySequence() :
  6094. !isIterable(value) ? indexedSeqFromValue(value) :
  6095. isKeyed(value) ? value.entrySeq() : value
  6096. ).toSetSeq();
  6097. }
  6098. SetSeq.of = function(/*...values*/) {
  6099. return SetSeq(arguments);
  6100. };
  6101. SetSeq.prototype.toSetSeq = function() {
  6102. return this;
  6103. };
  6104. Seq.isSeq = isSeq;
  6105. Seq.Keyed = KeyedSeq;
  6106. Seq.Set = SetSeq;
  6107. Seq.Indexed = IndexedSeq;
  6108. var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  6109. Seq.prototype[IS_SEQ_SENTINEL] = true;
  6110. createClass(ArraySeq, IndexedSeq);
  6111. function ArraySeq(array) {
  6112. this._array = array;
  6113. this.size = array.length;
  6114. }
  6115. ArraySeq.prototype.get = function(index, notSetValue) {
  6116. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  6117. };
  6118. ArraySeq.prototype.__iterate = function(fn, reverse) {
  6119. var array = this._array;
  6120. var maxIndex = array.length - 1;
  6121. for (var ii = 0; ii <= maxIndex; ii++) {
  6122. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  6123. return ii + 1;
  6124. }
  6125. }
  6126. return ii;
  6127. };
  6128. ArraySeq.prototype.__iterator = function(type, reverse) {
  6129. var array = this._array;
  6130. var maxIndex = array.length - 1;
  6131. var ii = 0;
  6132. return new Iterator(function()
  6133. {return ii > maxIndex ?
  6134. iteratorDone() :
  6135. iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
  6136. );
  6137. };
  6138. createClass(ObjectSeq, KeyedSeq);
  6139. function ObjectSeq(object) {
  6140. var keys = Object.keys(object);
  6141. this._object = object;
  6142. this._keys = keys;
  6143. this.size = keys.length;
  6144. }
  6145. ObjectSeq.prototype.get = function(key, notSetValue) {
  6146. if (notSetValue !== undefined && !this.has(key)) {
  6147. return notSetValue;
  6148. }
  6149. return this._object[key];
  6150. };
  6151. ObjectSeq.prototype.has = function(key) {
  6152. return this._object.hasOwnProperty(key);
  6153. };
  6154. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  6155. var object = this._object;
  6156. var keys = this._keys;
  6157. var maxIndex = keys.length - 1;
  6158. for (var ii = 0; ii <= maxIndex; ii++) {
  6159. var key = keys[reverse ? maxIndex - ii : ii];
  6160. if (fn(object[key], key, this) === false) {
  6161. return ii + 1;
  6162. }
  6163. }
  6164. return ii;
  6165. };
  6166. ObjectSeq.prototype.__iterator = function(type, reverse) {
  6167. var object = this._object;
  6168. var keys = this._keys;
  6169. var maxIndex = keys.length - 1;
  6170. var ii = 0;
  6171. return new Iterator(function() {
  6172. var key = keys[reverse ? maxIndex - ii : ii];
  6173. return ii++ > maxIndex ?
  6174. iteratorDone() :
  6175. iteratorValue(type, key, object[key]);
  6176. });
  6177. };
  6178. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  6179. createClass(IterableSeq, IndexedSeq);
  6180. function IterableSeq(iterable) {
  6181. this._iterable = iterable;
  6182. this.size = iterable.length || iterable.size;
  6183. }
  6184. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  6185. if (reverse) {
  6186. return this.cacheResult().__iterate(fn, reverse);
  6187. }
  6188. var iterable = this._iterable;
  6189. var iterator = getIterator(iterable);
  6190. var iterations = 0;
  6191. if (isIterator(iterator)) {
  6192. var step;
  6193. while (!(step = iterator.next()).done) {
  6194. if (fn(step.value, iterations++, this) === false) {
  6195. break;
  6196. }
  6197. }
  6198. }
  6199. return iterations;
  6200. };
  6201. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  6202. if (reverse) {
  6203. return this.cacheResult().__iterator(type, reverse);
  6204. }
  6205. var iterable = this._iterable;
  6206. var iterator = getIterator(iterable);
  6207. if (!isIterator(iterator)) {
  6208. return new Iterator(iteratorDone);
  6209. }
  6210. var iterations = 0;
  6211. return new Iterator(function() {
  6212. var step = iterator.next();
  6213. return step.done ? step : iteratorValue(type, iterations++, step.value);
  6214. });
  6215. };
  6216. createClass(IteratorSeq, IndexedSeq);
  6217. function IteratorSeq(iterator) {
  6218. this._iterator = iterator;
  6219. this._iteratorCache = [];
  6220. }
  6221. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  6222. if (reverse) {
  6223. return this.cacheResult().__iterate(fn, reverse);
  6224. }
  6225. var iterator = this._iterator;
  6226. var cache = this._iteratorCache;
  6227. var iterations = 0;
  6228. while (iterations < cache.length) {
  6229. if (fn(cache[iterations], iterations++, this) === false) {
  6230. return iterations;
  6231. }
  6232. }
  6233. var step;
  6234. while (!(step = iterator.next()).done) {
  6235. var val = step.value;
  6236. cache[iterations] = val;
  6237. if (fn(val, iterations++, this) === false) {
  6238. break;
  6239. }
  6240. }
  6241. return iterations;
  6242. };
  6243. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  6244. if (reverse) {
  6245. return this.cacheResult().__iterator(type, reverse);
  6246. }
  6247. var iterator = this._iterator;
  6248. var cache = this._iteratorCache;
  6249. var iterations = 0;
  6250. return new Iterator(function() {
  6251. if (iterations >= cache.length) {
  6252. var step = iterator.next();
  6253. if (step.done) {
  6254. return step;
  6255. }
  6256. cache[iterations] = step.value;
  6257. }
  6258. return iteratorValue(type, iterations, cache[iterations++]);
  6259. });
  6260. };
  6261. // # pragma Helper functions
  6262. function isSeq(maybeSeq) {
  6263. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  6264. }
  6265. var EMPTY_SEQ;
  6266. function emptySequence() {
  6267. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  6268. }
  6269. function keyedSeqFromValue(value) {
  6270. var seq =
  6271. Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
  6272. isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
  6273. hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
  6274. typeof value === 'object' ? new ObjectSeq(value) :
  6275. undefined;
  6276. if (!seq) {
  6277. throw new TypeError(
  6278. 'Expected Array or iterable object of [k, v] entries, '+
  6279. 'or keyed object: ' + value
  6280. );
  6281. }
  6282. return seq;
  6283. }
  6284. function indexedSeqFromValue(value) {
  6285. var seq = maybeIndexedSeqFromValue(value);
  6286. if (!seq) {
  6287. throw new TypeError(
  6288. 'Expected Array or iterable object of values: ' + value
  6289. );
  6290. }
  6291. return seq;
  6292. }
  6293. function seqFromValue(value) {
  6294. var seq = maybeIndexedSeqFromValue(value) ||
  6295. (typeof value === 'object' && new ObjectSeq(value));
  6296. if (!seq) {
  6297. throw new TypeError(
  6298. 'Expected Array or iterable object of values, or keyed object: ' + value
  6299. );
  6300. }
  6301. return seq;
  6302. }
  6303. function maybeIndexedSeqFromValue(value) {
  6304. return (
  6305. isArrayLike(value) ? new ArraySeq(value) :
  6306. isIterator(value) ? new IteratorSeq(value) :
  6307. hasIterator(value) ? new IterableSeq(value) :
  6308. undefined
  6309. );
  6310. }
  6311. function seqIterate(seq, fn, reverse, useKeys) {
  6312. var cache = seq._cache;
  6313. if (cache) {
  6314. var maxIndex = cache.length - 1;
  6315. for (var ii = 0; ii <= maxIndex; ii++) {
  6316. var entry = cache[reverse ? maxIndex - ii : ii];
  6317. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  6318. return ii + 1;
  6319. }
  6320. }
  6321. return ii;
  6322. }
  6323. return seq.__iterateUncached(fn, reverse);
  6324. }
  6325. function seqIterator(seq, type, reverse, useKeys) {
  6326. var cache = seq._cache;
  6327. if (cache) {
  6328. var maxIndex = cache.length - 1;
  6329. var ii = 0;
  6330. return new Iterator(function() {
  6331. var entry = cache[reverse ? maxIndex - ii : ii];
  6332. return ii++ > maxIndex ?
  6333. iteratorDone() :
  6334. iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  6335. });
  6336. }
  6337. return seq.__iteratorUncached(type, reverse);
  6338. }
  6339. function fromJS(json, converter) {
  6340. return converter ?
  6341. fromJSWith(converter, json, '', {'': json}) :
  6342. fromJSDefault(json);
  6343. }
  6344. function fromJSWith(converter, json, key, parentJSON) {
  6345. if (Array.isArray(json)) {
  6346. return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  6347. }
  6348. if (isPlainObj(json)) {
  6349. return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  6350. }
  6351. return json;
  6352. }
  6353. function fromJSDefault(json) {
  6354. if (Array.isArray(json)) {
  6355. return IndexedSeq(json).map(fromJSDefault).toList();
  6356. }
  6357. if (isPlainObj(json)) {
  6358. return KeyedSeq(json).map(fromJSDefault).toMap();
  6359. }
  6360. return json;
  6361. }
  6362. function isPlainObj(value) {
  6363. return value && (value.constructor === Object || value.constructor === undefined);
  6364. }
  6365. /**
  6366. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  6367. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  6368. *
  6369. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  6370. * value, which is different from the algorithm described by
  6371. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  6372. *
  6373. * This is extended further to allow Objects to describe the values they
  6374. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  6375. *
  6376. * Note: because of this extension, the key equality of Immutable.Map and the
  6377. * value equality of Immutable.Set will differ from ES6 Map and Set.
  6378. *
  6379. * ### Defining custom values
  6380. *
  6381. * The easiest way to describe the value an object represents is by implementing
  6382. * `valueOf`. For example, `Date` represents a value by returning a unix
  6383. * timestamp for `valueOf`:
  6384. *
  6385. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  6386. * var date2 = new Date(1234567890000);
  6387. * date1.valueOf(); // 1234567890000
  6388. * assert( date1 !== date2 );
  6389. * assert( Immutable.is( date1, date2 ) );
  6390. *
  6391. * Note: overriding `valueOf` may have other implications if you use this object
  6392. * where JavaScript expects a primitive, such as implicit string coercion.
  6393. *
  6394. * For more complex types, especially collections, implementing `valueOf` may
  6395. * not be performant. An alternative is to implement `equals` and `hashCode`.
  6396. *
  6397. * `equals` takes another object, presumably of similar type, and returns true
  6398. * if the it is equal. Equality is symmetrical, so the same result should be
  6399. * returned if this and the argument are flipped.
  6400. *
  6401. * assert( a.equals(b) === b.equals(a) );
  6402. *
  6403. * `hashCode` returns a 32bit integer number representing the object which will
  6404. * be used to determine how to store the value object in a Map or Set. You must
  6405. * provide both or neither methods, one must not exist without the other.
  6406. *
  6407. * Also, an important relationship between these methods must be upheld: if two
  6408. * values are equal, they *must* return the same hashCode. If the values are not
  6409. * equal, they might have the same hashCode; this is called a hash collision,
  6410. * and while undesirable for performance reasons, it is acceptable.
  6411. *
  6412. * if (a.equals(b)) {
  6413. * assert( a.hashCode() === b.hashCode() );
  6414. * }
  6415. *
  6416. * All Immutable collections implement `equals` and `hashCode`.
  6417. *
  6418. */
  6419. function is(valueA, valueB) {
  6420. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  6421. return true;
  6422. }
  6423. if (!valueA || !valueB) {
  6424. return false;
  6425. }
  6426. if (typeof valueA.valueOf === 'function' &&
  6427. typeof valueB.valueOf === 'function') {
  6428. valueA = valueA.valueOf();
  6429. valueB = valueB.valueOf();
  6430. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  6431. return true;
  6432. }
  6433. if (!valueA || !valueB) {
  6434. return false;
  6435. }
  6436. }
  6437. if (typeof valueA.equals === 'function' &&
  6438. typeof valueB.equals === 'function' &&
  6439. valueA.equals(valueB)) {
  6440. return true;
  6441. }
  6442. return false;
  6443. }
  6444. function deepEqual(a, b) {
  6445. if (a === b) {
  6446. return true;
  6447. }
  6448. if (
  6449. !isIterable(b) ||
  6450. a.size !== undefined && b.size !== undefined && a.size !== b.size ||
  6451. a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
  6452. isKeyed(a) !== isKeyed(b) ||
  6453. isIndexed(a) !== isIndexed(b) ||
  6454. isOrdered(a) !== isOrdered(b)
  6455. ) {
  6456. return false;
  6457. }
  6458. if (a.size === 0 && b.size === 0) {
  6459. return true;
  6460. }
  6461. var notAssociative = !isAssociative(a);
  6462. if (isOrdered(a)) {
  6463. var entries = a.entries();
  6464. return b.every(function(v, k) {
  6465. var entry = entries.next().value;
  6466. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  6467. }) && entries.next().done;
  6468. }
  6469. var flipped = false;
  6470. if (a.size === undefined) {
  6471. if (b.size === undefined) {
  6472. if (typeof a.cacheResult === 'function') {
  6473. a.cacheResult();
  6474. }
  6475. } else {
  6476. flipped = true;
  6477. var _ = a;
  6478. a = b;
  6479. b = _;
  6480. }
  6481. }
  6482. var allEqual = true;
  6483. var bSize = b.__iterate(function(v, k) {
  6484. if (notAssociative ? !a.has(v) :
  6485. flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
  6486. allEqual = false;
  6487. return false;
  6488. }
  6489. });
  6490. return allEqual && a.size === bSize;
  6491. }
  6492. createClass(Repeat, IndexedSeq);
  6493. function Repeat(value, times) {
  6494. if (!(this instanceof Repeat)) {
  6495. return new Repeat(value, times);
  6496. }
  6497. this._value = value;
  6498. this.size = times === undefined ? Infinity : Math.max(0, times);
  6499. if (this.size === 0) {
  6500. if (EMPTY_REPEAT) {
  6501. return EMPTY_REPEAT;
  6502. }
  6503. EMPTY_REPEAT = this;
  6504. }
  6505. }
  6506. Repeat.prototype.toString = function() {
  6507. if (this.size === 0) {
  6508. return 'Repeat []';
  6509. }
  6510. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  6511. };
  6512. Repeat.prototype.get = function(index, notSetValue) {
  6513. return this.has(index) ? this._value : notSetValue;
  6514. };
  6515. Repeat.prototype.includes = function(searchValue) {
  6516. return is(this._value, searchValue);
  6517. };
  6518. Repeat.prototype.slice = function(begin, end) {
  6519. var size = this.size;
  6520. return wholeSlice(begin, end, size) ? this :
  6521. new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
  6522. };
  6523. Repeat.prototype.reverse = function() {
  6524. return this;
  6525. };
  6526. Repeat.prototype.indexOf = function(searchValue) {
  6527. if (is(this._value, searchValue)) {
  6528. return 0;
  6529. }
  6530. return -1;
  6531. };
  6532. Repeat.prototype.lastIndexOf = function(searchValue) {
  6533. if (is(this._value, searchValue)) {
  6534. return this.size;
  6535. }
  6536. return -1;
  6537. };
  6538. Repeat.prototype.__iterate = function(fn, reverse) {
  6539. for (var ii = 0; ii < this.size; ii++) {
  6540. if (fn(this._value, ii, this) === false) {
  6541. return ii + 1;
  6542. }
  6543. }
  6544. return ii;
  6545. };
  6546. Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
  6547. var ii = 0;
  6548. return new Iterator(function()
  6549. {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
  6550. );
  6551. };
  6552. Repeat.prototype.equals = function(other) {
  6553. return other instanceof Repeat ?
  6554. is(this._value, other._value) :
  6555. deepEqual(other);
  6556. };
  6557. var EMPTY_REPEAT;
  6558. function invariant(condition, error) {
  6559. if (!condition) throw new Error(error);
  6560. }
  6561. createClass(Range, IndexedSeq);
  6562. function Range(start, end, step) {
  6563. if (!(this instanceof Range)) {
  6564. return new Range(start, end, step);
  6565. }
  6566. invariant(step !== 0, 'Cannot step a Range by 0');
  6567. start = start || 0;
  6568. if (end === undefined) {
  6569. end = Infinity;
  6570. }
  6571. step = step === undefined ? 1 : Math.abs(step);
  6572. if (end < start) {
  6573. step = -step;
  6574. }
  6575. this._start = start;
  6576. this._end = end;
  6577. this._step = step;
  6578. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  6579. if (this.size === 0) {
  6580. if (EMPTY_RANGE) {
  6581. return EMPTY_RANGE;
  6582. }
  6583. EMPTY_RANGE = this;
  6584. }
  6585. }
  6586. Range.prototype.toString = function() {
  6587. if (this.size === 0) {
  6588. return 'Range []';
  6589. }
  6590. return 'Range [ ' +
  6591. this._start + '...' + this._end +
  6592. (this._step > 1 ? ' by ' + this._step : '') +
  6593. ' ]';
  6594. };
  6595. Range.prototype.get = function(index, notSetValue) {
  6596. return this.has(index) ?
  6597. this._start + wrapIndex(this, index) * this._step :
  6598. notSetValue;
  6599. };
  6600. Range.prototype.includes = function(searchValue) {
  6601. var possibleIndex = (searchValue - this._start) / this._step;
  6602. return possibleIndex >= 0 &&
  6603. possibleIndex < this.size &&
  6604. possibleIndex === Math.floor(possibleIndex);
  6605. };
  6606. Range.prototype.slice = function(begin, end) {
  6607. if (wholeSlice(begin, end, this.size)) {
  6608. return this;
  6609. }
  6610. begin = resolveBegin(begin, this.size);
  6611. end = resolveEnd(end, this.size);
  6612. if (end <= begin) {
  6613. return new Range(0, 0);
  6614. }
  6615. return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
  6616. };
  6617. Range.prototype.indexOf = function(searchValue) {
  6618. var offsetValue = searchValue - this._start;
  6619. if (offsetValue % this._step === 0) {
  6620. var index = offsetValue / this._step;
  6621. if (index >= 0 && index < this.size) {
  6622. return index
  6623. }
  6624. }
  6625. return -1;
  6626. };
  6627. Range.prototype.lastIndexOf = function(searchValue) {
  6628. return this.indexOf(searchValue);
  6629. };
  6630. Range.prototype.__iterate = function(fn, reverse) {
  6631. var maxIndex = this.size - 1;
  6632. var step = this._step;
  6633. var value = reverse ? this._start + maxIndex * step : this._start;
  6634. for (var ii = 0; ii <= maxIndex; ii++) {
  6635. if (fn(value, ii, this) === false) {
  6636. return ii + 1;
  6637. }
  6638. value += reverse ? -step : step;
  6639. }
  6640. return ii;
  6641. };
  6642. Range.prototype.__iterator = function(type, reverse) {
  6643. var maxIndex = this.size - 1;
  6644. var step = this._step;
  6645. var value = reverse ? this._start + maxIndex * step : this._start;
  6646. var ii = 0;
  6647. return new Iterator(function() {
  6648. var v = value;
  6649. value += reverse ? -step : step;
  6650. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  6651. });
  6652. };
  6653. Range.prototype.equals = function(other) {
  6654. return other instanceof Range ?
  6655. this._start === other._start &&
  6656. this._end === other._end &&
  6657. this._step === other._step :
  6658. deepEqual(this, other);
  6659. };
  6660. var EMPTY_RANGE;
  6661. createClass(Collection, Iterable);
  6662. function Collection() {
  6663. throw TypeError('Abstract');
  6664. }
  6665. createClass(KeyedCollection, Collection);function KeyedCollection() {}
  6666. createClass(IndexedCollection, Collection);function IndexedCollection() {}
  6667. createClass(SetCollection, Collection);function SetCollection() {}
  6668. Collection.Keyed = KeyedCollection;
  6669. Collection.Indexed = IndexedCollection;
  6670. Collection.Set = SetCollection;
  6671. var imul =
  6672. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
  6673. Math.imul :
  6674. function imul(a, b) {
  6675. a = a | 0; // int
  6676. b = b | 0; // int
  6677. var c = a & 0xffff;
  6678. var d = b & 0xffff;
  6679. // Shift by 0 fixes the sign on the high part.
  6680. return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
  6681. };
  6682. // v8 has an optimization for storing 31-bit signed numbers.
  6683. // Values which have either 00 or 11 as the high order bits qualify.
  6684. // This function drops the highest order bit in a signed number, maintaining
  6685. // the sign bit.
  6686. function smi(i32) {
  6687. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
  6688. }
  6689. function hash(o) {
  6690. if (o === false || o === null || o === undefined) {
  6691. return 0;
  6692. }
  6693. if (typeof o.valueOf === 'function') {
  6694. o = o.valueOf();
  6695. if (o === false || o === null || o === undefined) {
  6696. return 0;
  6697. }
  6698. }
  6699. if (o === true) {
  6700. return 1;
  6701. }
  6702. var type = typeof o;
  6703. if (type === 'number') {
  6704. var h = o | 0;
  6705. if (h !== o) {
  6706. h ^= o * 0xFFFFFFFF;
  6707. }
  6708. while (o > 0xFFFFFFFF) {
  6709. o /= 0xFFFFFFFF;
  6710. h ^= o;
  6711. }
  6712. return smi(h);
  6713. }
  6714. if (type === 'string') {
  6715. return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
  6716. }
  6717. if (typeof o.hashCode === 'function') {
  6718. return o.hashCode();
  6719. }
  6720. if (type === 'object') {
  6721. return hashJSObj(o);
  6722. }
  6723. if (typeof o.toString === 'function') {
  6724. return hashString(o.toString());
  6725. }
  6726. throw new Error('Value type ' + type + ' cannot be hashed.');
  6727. }
  6728. function cachedHashString(string) {
  6729. var hash = stringHashCache[string];
  6730. if (hash === undefined) {
  6731. hash = hashString(string);
  6732. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  6733. STRING_HASH_CACHE_SIZE = 0;
  6734. stringHashCache = {};
  6735. }
  6736. STRING_HASH_CACHE_SIZE++;
  6737. stringHashCache[string] = hash;
  6738. }
  6739. return hash;
  6740. }
  6741. // http://jsperf.com/hashing-strings
  6742. function hashString(string) {
  6743. // This is the hash from JVM
  6744. // The hash code for a string is computed as
  6745. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  6746. // where s[i] is the ith character of the string and n is the length of
  6747. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  6748. // (exclusive) by dropping high bits.
  6749. var hash = 0;
  6750. for (var ii = 0; ii < string.length; ii++) {
  6751. hash = 31 * hash + string.charCodeAt(ii) | 0;
  6752. }
  6753. return smi(hash);
  6754. }
  6755. function hashJSObj(obj) {
  6756. var hash;
  6757. if (usingWeakMap) {
  6758. hash = weakMap.get(obj);
  6759. if (hash !== undefined) {
  6760. return hash;
  6761. }
  6762. }
  6763. hash = obj[UID_HASH_KEY];
  6764. if (hash !== undefined) {
  6765. return hash;
  6766. }
  6767. if (!canDefineProperty) {
  6768. hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  6769. if (hash !== undefined) {
  6770. return hash;
  6771. }
  6772. hash = getIENodeHash(obj);
  6773. if (hash !== undefined) {
  6774. return hash;
  6775. }
  6776. }
  6777. hash = ++objHashUID;
  6778. if (objHashUID & 0x40000000) {
  6779. objHashUID = 0;
  6780. }
  6781. if (usingWeakMap) {
  6782. weakMap.set(obj, hash);
  6783. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  6784. throw new Error('Non-extensible objects are not allowed as keys.');
  6785. } else if (canDefineProperty) {
  6786. Object.defineProperty(obj, UID_HASH_KEY, {
  6787. 'enumerable': false,
  6788. 'configurable': false,
  6789. 'writable': false,
  6790. 'value': hash
  6791. });
  6792. } else if (obj.propertyIsEnumerable !== undefined &&
  6793. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
  6794. // Since we can't define a non-enumerable property on the object
  6795. // we'll hijack one of the less-used non-enumerable properties to
  6796. // save our hash on it. Since this is a function it will not show up in
  6797. // `JSON.stringify` which is what we want.
  6798. obj.propertyIsEnumerable = function() {
  6799. return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
  6800. };
  6801. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  6802. } else if (obj.nodeType !== undefined) {
  6803. // At this point we couldn't get the IE `uniqueID` to use as a hash
  6804. // and we couldn't use a non-enumerable property to exploit the
  6805. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  6806. // itself.
  6807. obj[UID_HASH_KEY] = hash;
  6808. } else {
  6809. throw new Error('Unable to set a non-enumerable property on object.');
  6810. }
  6811. return hash;
  6812. }
  6813. // Get references to ES5 object methods.
  6814. var isExtensible = Object.isExtensible;
  6815. // True if Object.defineProperty works as expected. IE8 fails this test.
  6816. var canDefineProperty = (function() {
  6817. try {
  6818. Object.defineProperty({}, '@', {});
  6819. return true;
  6820. } catch (e) {
  6821. return false;
  6822. }
  6823. }());
  6824. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  6825. // and avoid memory leaks from the IE cloneNode bug.
  6826. function getIENodeHash(node) {
  6827. if (node && node.nodeType > 0) {
  6828. switch (node.nodeType) {
  6829. case 1: // Element
  6830. return node.uniqueID;
  6831. case 9: // Document
  6832. return node.documentElement && node.documentElement.uniqueID;
  6833. }
  6834. }
  6835. }
  6836. // If possible, use a WeakMap.
  6837. var usingWeakMap = typeof WeakMap === 'function';
  6838. var weakMap;
  6839. if (usingWeakMap) {
  6840. weakMap = new WeakMap();
  6841. }
  6842. var objHashUID = 0;
  6843. var UID_HASH_KEY = '__immutablehash__';
  6844. if (typeof Symbol === 'function') {
  6845. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  6846. }
  6847. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  6848. var STRING_HASH_CACHE_MAX_SIZE = 255;
  6849. var STRING_HASH_CACHE_SIZE = 0;
  6850. var stringHashCache = {};
  6851. function assertNotInfinite(size) {
  6852. invariant(
  6853. size !== Infinity,
  6854. 'Cannot perform this action with an infinite size.'
  6855. );
  6856. }
  6857. createClass(Map, KeyedCollection);
  6858. // @pragma Construction
  6859. function Map(value) {
  6860. return value === null || value === undefined ? emptyMap() :
  6861. isMap(value) && !isOrdered(value) ? value :
  6862. emptyMap().withMutations(function(map ) {
  6863. var iter = KeyedIterable(value);
  6864. assertNotInfinite(iter.size);
  6865. iter.forEach(function(v, k) {return map.set(k, v)});
  6866. });
  6867. }
  6868. Map.prototype.toString = function() {
  6869. return this.__toString('Map {', '}');
  6870. };
  6871. // @pragma Access
  6872. Map.prototype.get = function(k, notSetValue) {
  6873. return this._root ?
  6874. this._root.get(0, undefined, k, notSetValue) :
  6875. notSetValue;
  6876. };
  6877. // @pragma Modification
  6878. Map.prototype.set = function(k, v) {
  6879. return updateMap(this, k, v);
  6880. };
  6881. Map.prototype.setIn = function(keyPath, v) {
  6882. return this.updateIn(keyPath, NOT_SET, function() {return v});
  6883. };
  6884. Map.prototype.remove = function(k) {
  6885. return updateMap(this, k, NOT_SET);
  6886. };
  6887. Map.prototype.deleteIn = function(keyPath) {
  6888. return this.updateIn(keyPath, function() {return NOT_SET});
  6889. };
  6890. Map.prototype.update = function(k, notSetValue, updater) {
  6891. return arguments.length === 1 ?
  6892. k(this) :
  6893. this.updateIn([k], notSetValue, updater);
  6894. };
  6895. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  6896. if (!updater) {
  6897. updater = notSetValue;
  6898. notSetValue = undefined;
  6899. }
  6900. var updatedValue = updateInDeepMap(
  6901. this,
  6902. forceIterator(keyPath),
  6903. notSetValue,
  6904. updater
  6905. );
  6906. return updatedValue === NOT_SET ? undefined : updatedValue;
  6907. };
  6908. Map.prototype.clear = function() {
  6909. if (this.size === 0) {
  6910. return this;
  6911. }
  6912. if (this.__ownerID) {
  6913. this.size = 0;
  6914. this._root = null;
  6915. this.__hash = undefined;
  6916. this.__altered = true;
  6917. return this;
  6918. }
  6919. return emptyMap();
  6920. };
  6921. // @pragma Composition
  6922. Map.prototype.merge = function(/*...iters*/) {
  6923. return mergeIntoMapWith(this, undefined, arguments);
  6924. };
  6925. Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  6926. return mergeIntoMapWith(this, merger, iters);
  6927. };
  6928. Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  6929. return this.updateIn(
  6930. keyPath,
  6931. emptyMap(),
  6932. function(m ) {return typeof m.merge === 'function' ?
  6933. m.merge.apply(m, iters) :
  6934. iters[iters.length - 1]}
  6935. );
  6936. };
  6937. Map.prototype.mergeDeep = function(/*...iters*/) {
  6938. return mergeIntoMapWith(this, deepMerger, arguments);
  6939. };
  6940. Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  6941. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  6942. };
  6943. Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  6944. return this.updateIn(
  6945. keyPath,
  6946. emptyMap(),
  6947. function(m ) {return typeof m.mergeDeep === 'function' ?
  6948. m.mergeDeep.apply(m, iters) :
  6949. iters[iters.length - 1]}
  6950. );
  6951. };
  6952. Map.prototype.sort = function(comparator) {
  6953. // Late binding
  6954. return OrderedMap(sortFactory(this, comparator));
  6955. };
  6956. Map.prototype.sortBy = function(mapper, comparator) {
  6957. // Late binding
  6958. return OrderedMap(sortFactory(this, comparator, mapper));
  6959. };
  6960. // @pragma Mutability
  6961. Map.prototype.withMutations = function(fn) {
  6962. var mutable = this.asMutable();
  6963. fn(mutable);
  6964. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  6965. };
  6966. Map.prototype.asMutable = function() {
  6967. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  6968. };
  6969. Map.prototype.asImmutable = function() {
  6970. return this.__ensureOwner();
  6971. };
  6972. Map.prototype.wasAltered = function() {
  6973. return this.__altered;
  6974. };
  6975. Map.prototype.__iterator = function(type, reverse) {
  6976. return new MapIterator(this, type, reverse);
  6977. };
  6978. Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  6979. var iterations = 0;
  6980. this._root && this._root.iterate(function(entry ) {
  6981. iterations++;
  6982. return fn(entry[1], entry[0], this$0);
  6983. }, reverse);
  6984. return iterations;
  6985. };
  6986. Map.prototype.__ensureOwner = function(ownerID) {
  6987. if (ownerID === this.__ownerID) {
  6988. return this;
  6989. }
  6990. if (!ownerID) {
  6991. this.__ownerID = ownerID;
  6992. this.__altered = false;
  6993. return this;
  6994. }
  6995. return makeMap(this.size, this._root, ownerID, this.__hash);
  6996. };
  6997. function isMap(maybeMap) {
  6998. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  6999. }
  7000. Map.isMap = isMap;
  7001. var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  7002. var MapPrototype = Map.prototype;
  7003. MapPrototype[IS_MAP_SENTINEL] = true;
  7004. MapPrototype[DELETE] = MapPrototype.remove;
  7005. MapPrototype.removeIn = MapPrototype.deleteIn;
  7006. // #pragma Trie Nodes
  7007. function ArrayMapNode(ownerID, entries) {
  7008. this.ownerID = ownerID;
  7009. this.entries = entries;
  7010. }
  7011. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  7012. var entries = this.entries;
  7013. for (var ii = 0, len = entries.length; ii < len; ii++) {
  7014. if (is(key, entries[ii][0])) {
  7015. return entries[ii][1];
  7016. }
  7017. }
  7018. return notSetValue;
  7019. };
  7020. ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7021. var removed = value === NOT_SET;
  7022. var entries = this.entries;
  7023. var idx = 0;
  7024. for (var len = entries.length; idx < len; idx++) {
  7025. if (is(key, entries[idx][0])) {
  7026. break;
  7027. }
  7028. }
  7029. var exists = idx < len;
  7030. if (exists ? entries[idx][1] === value : removed) {
  7031. return this;
  7032. }
  7033. SetRef(didAlter);
  7034. (removed || !exists) && SetRef(didChangeSize);
  7035. if (removed && entries.length === 1) {
  7036. return; // undefined
  7037. }
  7038. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  7039. return createNodes(ownerID, entries, key, value);
  7040. }
  7041. var isEditable = ownerID && ownerID === this.ownerID;
  7042. var newEntries = isEditable ? entries : arrCopy(entries);
  7043. if (exists) {
  7044. if (removed) {
  7045. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  7046. } else {
  7047. newEntries[idx] = [key, value];
  7048. }
  7049. } else {
  7050. newEntries.push([key, value]);
  7051. }
  7052. if (isEditable) {
  7053. this.entries = newEntries;
  7054. return this;
  7055. }
  7056. return new ArrayMapNode(ownerID, newEntries);
  7057. };
  7058. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  7059. this.ownerID = ownerID;
  7060. this.bitmap = bitmap;
  7061. this.nodes = nodes;
  7062. }
  7063. BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  7064. if (keyHash === undefined) {
  7065. keyHash = hash(key);
  7066. }
  7067. var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
  7068. var bitmap = this.bitmap;
  7069. return (bitmap & bit) === 0 ? notSetValue :
  7070. this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
  7071. };
  7072. BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7073. if (keyHash === undefined) {
  7074. keyHash = hash(key);
  7075. }
  7076. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  7077. var bit = 1 << keyHashFrag;
  7078. var bitmap = this.bitmap;
  7079. var exists = (bitmap & bit) !== 0;
  7080. if (!exists && value === NOT_SET) {
  7081. return this;
  7082. }
  7083. var idx = popCount(bitmap & (bit - 1));
  7084. var nodes = this.nodes;
  7085. var node = exists ? nodes[idx] : undefined;
  7086. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  7087. if (newNode === node) {
  7088. return this;
  7089. }
  7090. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  7091. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  7092. }
  7093. if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
  7094. return nodes[idx ^ 1];
  7095. }
  7096. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  7097. return newNode;
  7098. }
  7099. var isEditable = ownerID && ownerID === this.ownerID;
  7100. var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
  7101. var newNodes = exists ? newNode ?
  7102. setIn(nodes, idx, newNode, isEditable) :
  7103. spliceOut(nodes, idx, isEditable) :
  7104. spliceIn(nodes, idx, newNode, isEditable);
  7105. if (isEditable) {
  7106. this.bitmap = newBitmap;
  7107. this.nodes = newNodes;
  7108. return this;
  7109. }
  7110. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  7111. };
  7112. function HashArrayMapNode(ownerID, count, nodes) {
  7113. this.ownerID = ownerID;
  7114. this.count = count;
  7115. this.nodes = nodes;
  7116. }
  7117. HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  7118. if (keyHash === undefined) {
  7119. keyHash = hash(key);
  7120. }
  7121. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  7122. var node = this.nodes[idx];
  7123. return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
  7124. };
  7125. HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7126. if (keyHash === undefined) {
  7127. keyHash = hash(key);
  7128. }
  7129. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  7130. var removed = value === NOT_SET;
  7131. var nodes = this.nodes;
  7132. var node = nodes[idx];
  7133. if (removed && !node) {
  7134. return this;
  7135. }
  7136. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  7137. if (newNode === node) {
  7138. return this;
  7139. }
  7140. var newCount = this.count;
  7141. if (!node) {
  7142. newCount++;
  7143. } else if (!newNode) {
  7144. newCount--;
  7145. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  7146. return packNodes(ownerID, nodes, newCount, idx);
  7147. }
  7148. }
  7149. var isEditable = ownerID && ownerID === this.ownerID;
  7150. var newNodes = setIn(nodes, idx, newNode, isEditable);
  7151. if (isEditable) {
  7152. this.count = newCount;
  7153. this.nodes = newNodes;
  7154. return this;
  7155. }
  7156. return new HashArrayMapNode(ownerID, newCount, newNodes);
  7157. };
  7158. function HashCollisionNode(ownerID, keyHash, entries) {
  7159. this.ownerID = ownerID;
  7160. this.keyHash = keyHash;
  7161. this.entries = entries;
  7162. }
  7163. HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  7164. var entries = this.entries;
  7165. for (var ii = 0, len = entries.length; ii < len; ii++) {
  7166. if (is(key, entries[ii][0])) {
  7167. return entries[ii][1];
  7168. }
  7169. }
  7170. return notSetValue;
  7171. };
  7172. HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7173. if (keyHash === undefined) {
  7174. keyHash = hash(key);
  7175. }
  7176. var removed = value === NOT_SET;
  7177. if (keyHash !== this.keyHash) {
  7178. if (removed) {
  7179. return this;
  7180. }
  7181. SetRef(didAlter);
  7182. SetRef(didChangeSize);
  7183. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  7184. }
  7185. var entries = this.entries;
  7186. var idx = 0;
  7187. for (var len = entries.length; idx < len; idx++) {
  7188. if (is(key, entries[idx][0])) {
  7189. break;
  7190. }
  7191. }
  7192. var exists = idx < len;
  7193. if (exists ? entries[idx][1] === value : removed) {
  7194. return this;
  7195. }
  7196. SetRef(didAlter);
  7197. (removed || !exists) && SetRef(didChangeSize);
  7198. if (removed && len === 2) {
  7199. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  7200. }
  7201. var isEditable = ownerID && ownerID === this.ownerID;
  7202. var newEntries = isEditable ? entries : arrCopy(entries);
  7203. if (exists) {
  7204. if (removed) {
  7205. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  7206. } else {
  7207. newEntries[idx] = [key, value];
  7208. }
  7209. } else {
  7210. newEntries.push([key, value]);
  7211. }
  7212. if (isEditable) {
  7213. this.entries = newEntries;
  7214. return this;
  7215. }
  7216. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  7217. };
  7218. function ValueNode(ownerID, keyHash, entry) {
  7219. this.ownerID = ownerID;
  7220. this.keyHash = keyHash;
  7221. this.entry = entry;
  7222. }
  7223. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  7224. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  7225. };
  7226. ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7227. var removed = value === NOT_SET;
  7228. var keyMatch = is(key, this.entry[0]);
  7229. if (keyMatch ? value === this.entry[1] : removed) {
  7230. return this;
  7231. }
  7232. SetRef(didAlter);
  7233. if (removed) {
  7234. SetRef(didChangeSize);
  7235. return; // undefined
  7236. }
  7237. if (keyMatch) {
  7238. if (ownerID && ownerID === this.ownerID) {
  7239. this.entry[1] = value;
  7240. return this;
  7241. }
  7242. return new ValueNode(ownerID, this.keyHash, [key, value]);
  7243. }
  7244. SetRef(didChangeSize);
  7245. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  7246. };
  7247. // #pragma Iterators
  7248. ArrayMapNode.prototype.iterate =
  7249. HashCollisionNode.prototype.iterate = function (fn, reverse) {
  7250. var entries = this.entries;
  7251. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  7252. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  7253. return false;
  7254. }
  7255. }
  7256. };
  7257. BitmapIndexedNode.prototype.iterate =
  7258. HashArrayMapNode.prototype.iterate = function (fn, reverse) {
  7259. var nodes = this.nodes;
  7260. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  7261. var node = nodes[reverse ? maxIndex - ii : ii];
  7262. if (node && node.iterate(fn, reverse) === false) {
  7263. return false;
  7264. }
  7265. }
  7266. };
  7267. ValueNode.prototype.iterate = function (fn, reverse) {
  7268. return fn(this.entry);
  7269. };
  7270. createClass(MapIterator, Iterator);
  7271. function MapIterator(map, type, reverse) {
  7272. this._type = type;
  7273. this._reverse = reverse;
  7274. this._stack = map._root && mapIteratorFrame(map._root);
  7275. }
  7276. MapIterator.prototype.next = function() {
  7277. var type = this._type;
  7278. var stack = this._stack;
  7279. while (stack) {
  7280. var node = stack.node;
  7281. var index = stack.index++;
  7282. var maxIndex;
  7283. if (node.entry) {
  7284. if (index === 0) {
  7285. return mapIteratorValue(type, node.entry);
  7286. }
  7287. } else if (node.entries) {
  7288. maxIndex = node.entries.length - 1;
  7289. if (index <= maxIndex) {
  7290. return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
  7291. }
  7292. } else {
  7293. maxIndex = node.nodes.length - 1;
  7294. if (index <= maxIndex) {
  7295. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  7296. if (subNode) {
  7297. if (subNode.entry) {
  7298. return mapIteratorValue(type, subNode.entry);
  7299. }
  7300. stack = this._stack = mapIteratorFrame(subNode, stack);
  7301. }
  7302. continue;
  7303. }
  7304. }
  7305. stack = this._stack = this._stack.__prev;
  7306. }
  7307. return iteratorDone();
  7308. };
  7309. function mapIteratorValue(type, entry) {
  7310. return iteratorValue(type, entry[0], entry[1]);
  7311. }
  7312. function mapIteratorFrame(node, prev) {
  7313. return {
  7314. node: node,
  7315. index: 0,
  7316. __prev: prev
  7317. };
  7318. }
  7319. function makeMap(size, root, ownerID, hash) {
  7320. var map = Object.create(MapPrototype);
  7321. map.size = size;
  7322. map._root = root;
  7323. map.__ownerID = ownerID;
  7324. map.__hash = hash;
  7325. map.__altered = false;
  7326. return map;
  7327. }
  7328. var EMPTY_MAP;
  7329. function emptyMap() {
  7330. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  7331. }
  7332. function updateMap(map, k, v) {
  7333. var newRoot;
  7334. var newSize;
  7335. if (!map._root) {
  7336. if (v === NOT_SET) {
  7337. return map;
  7338. }
  7339. newSize = 1;
  7340. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  7341. } else {
  7342. var didChangeSize = MakeRef(CHANGE_LENGTH);
  7343. var didAlter = MakeRef(DID_ALTER);
  7344. newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
  7345. if (!didAlter.value) {
  7346. return map;
  7347. }
  7348. newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
  7349. }
  7350. if (map.__ownerID) {
  7351. map.size = newSize;
  7352. map._root = newRoot;
  7353. map.__hash = undefined;
  7354. map.__altered = true;
  7355. return map;
  7356. }
  7357. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  7358. }
  7359. function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  7360. if (!node) {
  7361. if (value === NOT_SET) {
  7362. return node;
  7363. }
  7364. SetRef(didAlter);
  7365. SetRef(didChangeSize);
  7366. return new ValueNode(ownerID, keyHash, [key, value]);
  7367. }
  7368. return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
  7369. }
  7370. function isLeafNode(node) {
  7371. return node.constructor === ValueNode || node.constructor === HashCollisionNode;
  7372. }
  7373. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  7374. if (node.keyHash === keyHash) {
  7375. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  7376. }
  7377. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  7378. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  7379. var newNode;
  7380. var nodes = idx1 === idx2 ?
  7381. [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
  7382. ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
  7383. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  7384. }
  7385. function createNodes(ownerID, entries, key, value) {
  7386. if (!ownerID) {
  7387. ownerID = new OwnerID();
  7388. }
  7389. var node = new ValueNode(ownerID, hash(key), [key, value]);
  7390. for (var ii = 0; ii < entries.length; ii++) {
  7391. var entry = entries[ii];
  7392. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  7393. }
  7394. return node;
  7395. }
  7396. function packNodes(ownerID, nodes, count, excluding) {
  7397. var bitmap = 0;
  7398. var packedII = 0;
  7399. var packedNodes = new Array(count);
  7400. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  7401. var node = nodes[ii];
  7402. if (node !== undefined && ii !== excluding) {
  7403. bitmap |= bit;
  7404. packedNodes[packedII++] = node;
  7405. }
  7406. }
  7407. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  7408. }
  7409. function expandNodes(ownerID, nodes, bitmap, including, node) {
  7410. var count = 0;
  7411. var expandedNodes = new Array(SIZE);
  7412. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  7413. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  7414. }
  7415. expandedNodes[including] = node;
  7416. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  7417. }
  7418. function mergeIntoMapWith(map, merger, iterables) {
  7419. var iters = [];
  7420. for (var ii = 0; ii < iterables.length; ii++) {
  7421. var value = iterables[ii];
  7422. var iter = KeyedIterable(value);
  7423. if (!isIterable(value)) {
  7424. iter = iter.map(function(v ) {return fromJS(v)});
  7425. }
  7426. iters.push(iter);
  7427. }
  7428. return mergeIntoCollectionWith(map, merger, iters);
  7429. }
  7430. function deepMerger(existing, value, key) {
  7431. return existing && existing.mergeDeep && isIterable(value) ?
  7432. existing.mergeDeep(value) :
  7433. is(existing, value) ? existing : value;
  7434. }
  7435. function deepMergerWith(merger) {
  7436. return function(existing, value, key) {
  7437. if (existing && existing.mergeDeepWith && isIterable(value)) {
  7438. return existing.mergeDeepWith(merger, value);
  7439. }
  7440. var nextValue = merger(existing, value, key);
  7441. return is(existing, nextValue) ? existing : nextValue;
  7442. };
  7443. }
  7444. function mergeIntoCollectionWith(collection, merger, iters) {
  7445. iters = iters.filter(function(x ) {return x.size !== 0});
  7446. if (iters.length === 0) {
  7447. return collection;
  7448. }
  7449. if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
  7450. return collection.constructor(iters[0]);
  7451. }
  7452. return collection.withMutations(function(collection ) {
  7453. var mergeIntoMap = merger ?
  7454. function(value, key) {
  7455. collection.update(key, NOT_SET, function(existing )
  7456. {return existing === NOT_SET ? value : merger(existing, value, key)}
  7457. );
  7458. } :
  7459. function(value, key) {
  7460. collection.set(key, value);
  7461. };
  7462. for (var ii = 0; ii < iters.length; ii++) {
  7463. iters[ii].forEach(mergeIntoMap);
  7464. }
  7465. });
  7466. }
  7467. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  7468. var isNotSet = existing === NOT_SET;
  7469. var step = keyPathIter.next();
  7470. if (step.done) {
  7471. var existingValue = isNotSet ? notSetValue : existing;
  7472. var newValue = updater(existingValue);
  7473. return newValue === existingValue ? existing : newValue;
  7474. }
  7475. invariant(
  7476. isNotSet || (existing && existing.set),
  7477. 'invalid keyPath'
  7478. );
  7479. var key = step.value;
  7480. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  7481. var nextUpdated = updateInDeepMap(
  7482. nextExisting,
  7483. keyPathIter,
  7484. notSetValue,
  7485. updater
  7486. );
  7487. return nextUpdated === nextExisting ? existing :
  7488. nextUpdated === NOT_SET ? existing.remove(key) :
  7489. (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  7490. }
  7491. function popCount(x) {
  7492. x = x - ((x >> 1) & 0x55555555);
  7493. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  7494. x = (x + (x >> 4)) & 0x0f0f0f0f;
  7495. x = x + (x >> 8);
  7496. x = x + (x >> 16);
  7497. return x & 0x7f;
  7498. }
  7499. function setIn(array, idx, val, canEdit) {
  7500. var newArray = canEdit ? array : arrCopy(array);
  7501. newArray[idx] = val;
  7502. return newArray;
  7503. }
  7504. function spliceIn(array, idx, val, canEdit) {
  7505. var newLen = array.length + 1;
  7506. if (canEdit && idx + 1 === newLen) {
  7507. array[idx] = val;
  7508. return array;
  7509. }
  7510. var newArray = new Array(newLen);
  7511. var after = 0;
  7512. for (var ii = 0; ii < newLen; ii++) {
  7513. if (ii === idx) {
  7514. newArray[ii] = val;
  7515. after = -1;
  7516. } else {
  7517. newArray[ii] = array[ii + after];
  7518. }
  7519. }
  7520. return newArray;
  7521. }
  7522. function spliceOut(array, idx, canEdit) {
  7523. var newLen = array.length - 1;
  7524. if (canEdit && idx === newLen) {
  7525. array.pop();
  7526. return array;
  7527. }
  7528. var newArray = new Array(newLen);
  7529. var after = 0;
  7530. for (var ii = 0; ii < newLen; ii++) {
  7531. if (ii === idx) {
  7532. after = 1;
  7533. }
  7534. newArray[ii] = array[ii + after];
  7535. }
  7536. return newArray;
  7537. }
  7538. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  7539. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  7540. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  7541. createClass(List, IndexedCollection);
  7542. // @pragma Construction
  7543. function List(value) {
  7544. var empty = emptyList();
  7545. if (value === null || value === undefined) {
  7546. return empty;
  7547. }
  7548. if (isList(value)) {
  7549. return value;
  7550. }
  7551. var iter = IndexedIterable(value);
  7552. var size = iter.size;
  7553. if (size === 0) {
  7554. return empty;
  7555. }
  7556. assertNotInfinite(size);
  7557. if (size > 0 && size < SIZE) {
  7558. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  7559. }
  7560. return empty.withMutations(function(list ) {
  7561. list.setSize(size);
  7562. iter.forEach(function(v, i) {return list.set(i, v)});
  7563. });
  7564. }
  7565. List.of = function(/*...values*/) {
  7566. return this(arguments);
  7567. };
  7568. List.prototype.toString = function() {
  7569. return this.__toString('List [', ']');
  7570. };
  7571. // @pragma Access
  7572. List.prototype.get = function(index, notSetValue) {
  7573. index = wrapIndex(this, index);
  7574. if (index >= 0 && index < this.size) {
  7575. index += this._origin;
  7576. var node = listNodeFor(this, index);
  7577. return node && node.array[index & MASK];
  7578. }
  7579. return notSetValue;
  7580. };
  7581. // @pragma Modification
  7582. List.prototype.set = function(index, value) {
  7583. return updateList(this, index, value);
  7584. };
  7585. List.prototype.remove = function(index) {
  7586. return !this.has(index) ? this :
  7587. index === 0 ? this.shift() :
  7588. index === this.size - 1 ? this.pop() :
  7589. this.splice(index, 1);
  7590. };
  7591. List.prototype.insert = function(index, value) {
  7592. return this.splice(index, 0, value);
  7593. };
  7594. List.prototype.clear = function() {
  7595. if (this.size === 0) {
  7596. return this;
  7597. }
  7598. if (this.__ownerID) {
  7599. this.size = this._origin = this._capacity = 0;
  7600. this._level = SHIFT;
  7601. this._root = this._tail = null;
  7602. this.__hash = undefined;
  7603. this.__altered = true;
  7604. return this;
  7605. }
  7606. return emptyList();
  7607. };
  7608. List.prototype.push = function(/*...values*/) {
  7609. var values = arguments;
  7610. var oldSize = this.size;
  7611. return this.withMutations(function(list ) {
  7612. setListBounds(list, 0, oldSize + values.length);
  7613. for (var ii = 0; ii < values.length; ii++) {
  7614. list.set(oldSize + ii, values[ii]);
  7615. }
  7616. });
  7617. };
  7618. List.prototype.pop = function() {
  7619. return setListBounds(this, 0, -1);
  7620. };
  7621. List.prototype.unshift = function(/*...values*/) {
  7622. var values = arguments;
  7623. return this.withMutations(function(list ) {
  7624. setListBounds(list, -values.length);
  7625. for (var ii = 0; ii < values.length; ii++) {
  7626. list.set(ii, values[ii]);
  7627. }
  7628. });
  7629. };
  7630. List.prototype.shift = function() {
  7631. return setListBounds(this, 1);
  7632. };
  7633. // @pragma Composition
  7634. List.prototype.merge = function(/*...iters*/) {
  7635. return mergeIntoListWith(this, undefined, arguments);
  7636. };
  7637. List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  7638. return mergeIntoListWith(this, merger, iters);
  7639. };
  7640. List.prototype.mergeDeep = function(/*...iters*/) {
  7641. return mergeIntoListWith(this, deepMerger, arguments);
  7642. };
  7643. List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  7644. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  7645. };
  7646. List.prototype.setSize = function(size) {
  7647. return setListBounds(this, 0, size);
  7648. };
  7649. // @pragma Iteration
  7650. List.prototype.slice = function(begin, end) {
  7651. var size = this.size;
  7652. if (wholeSlice(begin, end, size)) {
  7653. return this;
  7654. }
  7655. return setListBounds(
  7656. this,
  7657. resolveBegin(begin, size),
  7658. resolveEnd(end, size)
  7659. );
  7660. };
  7661. List.prototype.__iterator = function(type, reverse) {
  7662. var index = 0;
  7663. var values = iterateList(this, reverse);
  7664. return new Iterator(function() {
  7665. var value = values();
  7666. return value === DONE ?
  7667. iteratorDone() :
  7668. iteratorValue(type, index++, value);
  7669. });
  7670. };
  7671. List.prototype.__iterate = function(fn, reverse) {
  7672. var index = 0;
  7673. var values = iterateList(this, reverse);
  7674. var value;
  7675. while ((value = values()) !== DONE) {
  7676. if (fn(value, index++, this) === false) {
  7677. break;
  7678. }
  7679. }
  7680. return index;
  7681. };
  7682. List.prototype.__ensureOwner = function(ownerID) {
  7683. if (ownerID === this.__ownerID) {
  7684. return this;
  7685. }
  7686. if (!ownerID) {
  7687. this.__ownerID = ownerID;
  7688. return this;
  7689. }
  7690. return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
  7691. };
  7692. function isList(maybeList) {
  7693. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  7694. }
  7695. List.isList = isList;
  7696. var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  7697. var ListPrototype = List.prototype;
  7698. ListPrototype[IS_LIST_SENTINEL] = true;
  7699. ListPrototype[DELETE] = ListPrototype.remove;
  7700. ListPrototype.setIn = MapPrototype.setIn;
  7701. ListPrototype.deleteIn =
  7702. ListPrototype.removeIn = MapPrototype.removeIn;
  7703. ListPrototype.update = MapPrototype.update;
  7704. ListPrototype.updateIn = MapPrototype.updateIn;
  7705. ListPrototype.mergeIn = MapPrototype.mergeIn;
  7706. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  7707. ListPrototype.withMutations = MapPrototype.withMutations;
  7708. ListPrototype.asMutable = MapPrototype.asMutable;
  7709. ListPrototype.asImmutable = MapPrototype.asImmutable;
  7710. ListPrototype.wasAltered = MapPrototype.wasAltered;
  7711. function VNode(array, ownerID) {
  7712. this.array = array;
  7713. this.ownerID = ownerID;
  7714. }
  7715. // TODO: seems like these methods are very similar
  7716. VNode.prototype.removeBefore = function(ownerID, level, index) {
  7717. if (index === level ? 1 << level : this.array.length === 0) {
  7718. return this;
  7719. }
  7720. var originIndex = (index >>> level) & MASK;
  7721. if (originIndex >= this.array.length) {
  7722. return new VNode([], ownerID);
  7723. }
  7724. var removingFirst = originIndex === 0;
  7725. var newChild;
  7726. if (level > 0) {
  7727. var oldChild = this.array[originIndex];
  7728. newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  7729. if (newChild === oldChild && removingFirst) {
  7730. return this;
  7731. }
  7732. }
  7733. if (removingFirst && !newChild) {
  7734. return this;
  7735. }
  7736. var editable = editableVNode(this, ownerID);
  7737. if (!removingFirst) {
  7738. for (var ii = 0; ii < originIndex; ii++) {
  7739. editable.array[ii] = undefined;
  7740. }
  7741. }
  7742. if (newChild) {
  7743. editable.array[originIndex] = newChild;
  7744. }
  7745. return editable;
  7746. };
  7747. VNode.prototype.removeAfter = function(ownerID, level, index) {
  7748. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  7749. return this;
  7750. }
  7751. var sizeIndex = ((index - 1) >>> level) & MASK;
  7752. if (sizeIndex >= this.array.length) {
  7753. return this;
  7754. }
  7755. var newChild;
  7756. if (level > 0) {
  7757. var oldChild = this.array[sizeIndex];
  7758. newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  7759. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  7760. return this;
  7761. }
  7762. }
  7763. var editable = editableVNode(this, ownerID);
  7764. editable.array.splice(sizeIndex + 1);
  7765. if (newChild) {
  7766. editable.array[sizeIndex] = newChild;
  7767. }
  7768. return editable;
  7769. };
  7770. var DONE = {};
  7771. function iterateList(list, reverse) {
  7772. var left = list._origin;
  7773. var right = list._capacity;
  7774. var tailPos = getTailOffset(right);
  7775. var tail = list._tail;
  7776. return iterateNodeOrLeaf(list._root, list._level, 0);
  7777. function iterateNodeOrLeaf(node, level, offset) {
  7778. return level === 0 ?
  7779. iterateLeaf(node, offset) :
  7780. iterateNode(node, level, offset);
  7781. }
  7782. function iterateLeaf(node, offset) {
  7783. var array = offset === tailPos ? tail && tail.array : node && node.array;
  7784. var from = offset > left ? 0 : left - offset;
  7785. var to = right - offset;
  7786. if (to > SIZE) {
  7787. to = SIZE;
  7788. }
  7789. return function() {
  7790. if (from === to) {
  7791. return DONE;
  7792. }
  7793. var idx = reverse ? --to : from++;
  7794. return array && array[idx];
  7795. };
  7796. }
  7797. function iterateNode(node, level, offset) {
  7798. var values;
  7799. var array = node && node.array;
  7800. var from = offset > left ? 0 : (left - offset) >> level;
  7801. var to = ((right - offset) >> level) + 1;
  7802. if (to > SIZE) {
  7803. to = SIZE;
  7804. }
  7805. return function() {
  7806. do {
  7807. if (values) {
  7808. var value = values();
  7809. if (value !== DONE) {
  7810. return value;
  7811. }
  7812. values = null;
  7813. }
  7814. if (from === to) {
  7815. return DONE;
  7816. }
  7817. var idx = reverse ? --to : from++;
  7818. values = iterateNodeOrLeaf(
  7819. array && array[idx], level - SHIFT, offset + (idx << level)
  7820. );
  7821. } while (true);
  7822. };
  7823. }
  7824. }
  7825. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  7826. var list = Object.create(ListPrototype);
  7827. list.size = capacity - origin;
  7828. list._origin = origin;
  7829. list._capacity = capacity;
  7830. list._level = level;
  7831. list._root = root;
  7832. list._tail = tail;
  7833. list.__ownerID = ownerID;
  7834. list.__hash = hash;
  7835. list.__altered = false;
  7836. return list;
  7837. }
  7838. var EMPTY_LIST;
  7839. function emptyList() {
  7840. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  7841. }
  7842. function updateList(list, index, value) {
  7843. index = wrapIndex(list, index);
  7844. if (index !== index) {
  7845. return list;
  7846. }
  7847. if (index >= list.size || index < 0) {
  7848. return list.withMutations(function(list ) {
  7849. index < 0 ?
  7850. setListBounds(list, index).set(0, value) :
  7851. setListBounds(list, 0, index + 1).set(index, value);
  7852. });
  7853. }
  7854. index += list._origin;
  7855. var newTail = list._tail;
  7856. var newRoot = list._root;
  7857. var didAlter = MakeRef(DID_ALTER);
  7858. if (index >= getTailOffset(list._capacity)) {
  7859. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  7860. } else {
  7861. newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
  7862. }
  7863. if (!didAlter.value) {
  7864. return list;
  7865. }
  7866. if (list.__ownerID) {
  7867. list._root = newRoot;
  7868. list._tail = newTail;
  7869. list.__hash = undefined;
  7870. list.__altered = true;
  7871. return list;
  7872. }
  7873. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  7874. }
  7875. function updateVNode(node, ownerID, level, index, value, didAlter) {
  7876. var idx = (index >>> level) & MASK;
  7877. var nodeHas = node && idx < node.array.length;
  7878. if (!nodeHas && value === undefined) {
  7879. return node;
  7880. }
  7881. var newNode;
  7882. if (level > 0) {
  7883. var lowerNode = node && node.array[idx];
  7884. var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
  7885. if (newLowerNode === lowerNode) {
  7886. return node;
  7887. }
  7888. newNode = editableVNode(node, ownerID);
  7889. newNode.array[idx] = newLowerNode;
  7890. return newNode;
  7891. }
  7892. if (nodeHas && node.array[idx] === value) {
  7893. return node;
  7894. }
  7895. SetRef(didAlter);
  7896. newNode = editableVNode(node, ownerID);
  7897. if (value === undefined && idx === newNode.array.length - 1) {
  7898. newNode.array.pop();
  7899. } else {
  7900. newNode.array[idx] = value;
  7901. }
  7902. return newNode;
  7903. }
  7904. function editableVNode(node, ownerID) {
  7905. if (ownerID && node && ownerID === node.ownerID) {
  7906. return node;
  7907. }
  7908. return new VNode(node ? node.array.slice() : [], ownerID);
  7909. }
  7910. function listNodeFor(list, rawIndex) {
  7911. if (rawIndex >= getTailOffset(list._capacity)) {
  7912. return list._tail;
  7913. }
  7914. if (rawIndex < 1 << (list._level + SHIFT)) {
  7915. var node = list._root;
  7916. var level = list._level;
  7917. while (node && level > 0) {
  7918. node = node.array[(rawIndex >>> level) & MASK];
  7919. level -= SHIFT;
  7920. }
  7921. return node;
  7922. }
  7923. }
  7924. function setListBounds(list, begin, end) {
  7925. // Sanitize begin & end using this shorthand for ToInt32(argument)
  7926. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  7927. if (begin !== undefined) {
  7928. begin = begin | 0;
  7929. }
  7930. if (end !== undefined) {
  7931. end = end | 0;
  7932. }
  7933. var owner = list.__ownerID || new OwnerID();
  7934. var oldOrigin = list._origin;
  7935. var oldCapacity = list._capacity;
  7936. var newOrigin = oldOrigin + begin;
  7937. var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
  7938. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  7939. return list;
  7940. }
  7941. // If it's going to end after it starts, it's empty.
  7942. if (newOrigin >= newCapacity) {
  7943. return list.clear();
  7944. }
  7945. var newLevel = list._level;
  7946. var newRoot = list._root;
  7947. // New origin might need creating a higher root.
  7948. var offsetShift = 0;
  7949. while (newOrigin + offsetShift < 0) {
  7950. newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
  7951. newLevel += SHIFT;
  7952. offsetShift += 1 << newLevel;
  7953. }
  7954. if (offsetShift) {
  7955. newOrigin += offsetShift;
  7956. oldOrigin += offsetShift;
  7957. newCapacity += offsetShift;
  7958. oldCapacity += offsetShift;
  7959. }
  7960. var oldTailOffset = getTailOffset(oldCapacity);
  7961. var newTailOffset = getTailOffset(newCapacity);
  7962. // New size might need creating a higher root.
  7963. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  7964. newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
  7965. newLevel += SHIFT;
  7966. }
  7967. // Locate or create the new tail.
  7968. var oldTail = list._tail;
  7969. var newTail = newTailOffset < oldTailOffset ?
  7970. listNodeFor(list, newCapacity - 1) :
  7971. newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
  7972. // Merge Tail into tree.
  7973. if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
  7974. newRoot = editableVNode(newRoot, owner);
  7975. var node = newRoot;
  7976. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  7977. var idx = (oldTailOffset >>> level) & MASK;
  7978. node = node.array[idx] = editableVNode(node.array[idx], owner);
  7979. }
  7980. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  7981. }
  7982. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  7983. if (newCapacity < oldCapacity) {
  7984. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  7985. }
  7986. // If the new origin is within the tail, then we do not need a root.
  7987. if (newOrigin >= newTailOffset) {
  7988. newOrigin -= newTailOffset;
  7989. newCapacity -= newTailOffset;
  7990. newLevel = SHIFT;
  7991. newRoot = null;
  7992. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  7993. // Otherwise, if the root has been trimmed, garbage collect.
  7994. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  7995. offsetShift = 0;
  7996. // Identify the new top root node of the subtree of the old root.
  7997. while (newRoot) {
  7998. var beginIndex = (newOrigin >>> newLevel) & MASK;
  7999. if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
  8000. break;
  8001. }
  8002. if (beginIndex) {
  8003. offsetShift += (1 << newLevel) * beginIndex;
  8004. }
  8005. newLevel -= SHIFT;
  8006. newRoot = newRoot.array[beginIndex];
  8007. }
  8008. // Trim the new sides of the new root.
  8009. if (newRoot && newOrigin > oldOrigin) {
  8010. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  8011. }
  8012. if (newRoot && newTailOffset < oldTailOffset) {
  8013. newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
  8014. }
  8015. if (offsetShift) {
  8016. newOrigin -= offsetShift;
  8017. newCapacity -= offsetShift;
  8018. }
  8019. }
  8020. if (list.__ownerID) {
  8021. list.size = newCapacity - newOrigin;
  8022. list._origin = newOrigin;
  8023. list._capacity = newCapacity;
  8024. list._level = newLevel;
  8025. list._root = newRoot;
  8026. list._tail = newTail;
  8027. list.__hash = undefined;
  8028. list.__altered = true;
  8029. return list;
  8030. }
  8031. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  8032. }
  8033. function mergeIntoListWith(list, merger, iterables) {
  8034. var iters = [];
  8035. var maxSize = 0;
  8036. for (var ii = 0; ii < iterables.length; ii++) {
  8037. var value = iterables[ii];
  8038. var iter = IndexedIterable(value);
  8039. if (iter.size > maxSize) {
  8040. maxSize = iter.size;
  8041. }
  8042. if (!isIterable(value)) {
  8043. iter = iter.map(function(v ) {return fromJS(v)});
  8044. }
  8045. iters.push(iter);
  8046. }
  8047. if (maxSize > list.size) {
  8048. list = list.setSize(maxSize);
  8049. }
  8050. return mergeIntoCollectionWith(list, merger, iters);
  8051. }
  8052. function getTailOffset(size) {
  8053. return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
  8054. }
  8055. createClass(OrderedMap, Map);
  8056. // @pragma Construction
  8057. function OrderedMap(value) {
  8058. return value === null || value === undefined ? emptyOrderedMap() :
  8059. isOrderedMap(value) ? value :
  8060. emptyOrderedMap().withMutations(function(map ) {
  8061. var iter = KeyedIterable(value);
  8062. assertNotInfinite(iter.size);
  8063. iter.forEach(function(v, k) {return map.set(k, v)});
  8064. });
  8065. }
  8066. OrderedMap.of = function(/*...values*/) {
  8067. return this(arguments);
  8068. };
  8069. OrderedMap.prototype.toString = function() {
  8070. return this.__toString('OrderedMap {', '}');
  8071. };
  8072. // @pragma Access
  8073. OrderedMap.prototype.get = function(k, notSetValue) {
  8074. var index = this._map.get(k);
  8075. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  8076. };
  8077. // @pragma Modification
  8078. OrderedMap.prototype.clear = function() {
  8079. if (this.size === 0) {
  8080. return this;
  8081. }
  8082. if (this.__ownerID) {
  8083. this.size = 0;
  8084. this._map.clear();
  8085. this._list.clear();
  8086. return this;
  8087. }
  8088. return emptyOrderedMap();
  8089. };
  8090. OrderedMap.prototype.set = function(k, v) {
  8091. return updateOrderedMap(this, k, v);
  8092. };
  8093. OrderedMap.prototype.remove = function(k) {
  8094. return updateOrderedMap(this, k, NOT_SET);
  8095. };
  8096. OrderedMap.prototype.wasAltered = function() {
  8097. return this._map.wasAltered() || this._list.wasAltered();
  8098. };
  8099. OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8100. return this._list.__iterate(
  8101. function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
  8102. reverse
  8103. );
  8104. };
  8105. OrderedMap.prototype.__iterator = function(type, reverse) {
  8106. return this._list.fromEntrySeq().__iterator(type, reverse);
  8107. };
  8108. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  8109. if (ownerID === this.__ownerID) {
  8110. return this;
  8111. }
  8112. var newMap = this._map.__ensureOwner(ownerID);
  8113. var newList = this._list.__ensureOwner(ownerID);
  8114. if (!ownerID) {
  8115. this.__ownerID = ownerID;
  8116. this._map = newMap;
  8117. this._list = newList;
  8118. return this;
  8119. }
  8120. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  8121. };
  8122. function isOrderedMap(maybeOrderedMap) {
  8123. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  8124. }
  8125. OrderedMap.isOrderedMap = isOrderedMap;
  8126. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  8127. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  8128. function makeOrderedMap(map, list, ownerID, hash) {
  8129. var omap = Object.create(OrderedMap.prototype);
  8130. omap.size = map ? map.size : 0;
  8131. omap._map = map;
  8132. omap._list = list;
  8133. omap.__ownerID = ownerID;
  8134. omap.__hash = hash;
  8135. return omap;
  8136. }
  8137. var EMPTY_ORDERED_MAP;
  8138. function emptyOrderedMap() {
  8139. return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
  8140. }
  8141. function updateOrderedMap(omap, k, v) {
  8142. var map = omap._map;
  8143. var list = omap._list;
  8144. var i = map.get(k);
  8145. var has = i !== undefined;
  8146. var newMap;
  8147. var newList;
  8148. if (v === NOT_SET) { // removed
  8149. if (!has) {
  8150. return omap;
  8151. }
  8152. if (list.size >= SIZE && list.size >= map.size * 2) {
  8153. newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
  8154. newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
  8155. if (omap.__ownerID) {
  8156. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  8157. }
  8158. } else {
  8159. newMap = map.remove(k);
  8160. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  8161. }
  8162. } else {
  8163. if (has) {
  8164. if (v === list.get(i)[1]) {
  8165. return omap;
  8166. }
  8167. newMap = map;
  8168. newList = list.set(i, [k, v]);
  8169. } else {
  8170. newMap = map.set(k, list.size);
  8171. newList = list.set(list.size, [k, v]);
  8172. }
  8173. }
  8174. if (omap.__ownerID) {
  8175. omap.size = newMap.size;
  8176. omap._map = newMap;
  8177. omap._list = newList;
  8178. omap.__hash = undefined;
  8179. return omap;
  8180. }
  8181. return makeOrderedMap(newMap, newList);
  8182. }
  8183. createClass(ToKeyedSequence, KeyedSeq);
  8184. function ToKeyedSequence(indexed, useKeys) {
  8185. this._iter = indexed;
  8186. this._useKeys = useKeys;
  8187. this.size = indexed.size;
  8188. }
  8189. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  8190. return this._iter.get(key, notSetValue);
  8191. };
  8192. ToKeyedSequence.prototype.has = function(key) {
  8193. return this._iter.has(key);
  8194. };
  8195. ToKeyedSequence.prototype.valueSeq = function() {
  8196. return this._iter.valueSeq();
  8197. };
  8198. ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
  8199. var reversedSequence = reverseFactory(this, true);
  8200. if (!this._useKeys) {
  8201. reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
  8202. }
  8203. return reversedSequence;
  8204. };
  8205. ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
  8206. var mappedSequence = mapFactory(this, mapper, context);
  8207. if (!this._useKeys) {
  8208. mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
  8209. }
  8210. return mappedSequence;
  8211. };
  8212. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8213. var ii;
  8214. return this._iter.__iterate(
  8215. this._useKeys ?
  8216. function(v, k) {return fn(v, k, this$0)} :
  8217. ((ii = reverse ? resolveSize(this) : 0),
  8218. function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
  8219. reverse
  8220. );
  8221. };
  8222. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  8223. if (this._useKeys) {
  8224. return this._iter.__iterator(type, reverse);
  8225. }
  8226. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  8227. var ii = reverse ? resolveSize(this) : 0;
  8228. return new Iterator(function() {
  8229. var step = iterator.next();
  8230. return step.done ? step :
  8231. iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  8232. });
  8233. };
  8234. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  8235. createClass(ToIndexedSequence, IndexedSeq);
  8236. function ToIndexedSequence(iter) {
  8237. this._iter = iter;
  8238. this.size = iter.size;
  8239. }
  8240. ToIndexedSequence.prototype.includes = function(value) {
  8241. return this._iter.includes(value);
  8242. };
  8243. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8244. var iterations = 0;
  8245. return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
  8246. };
  8247. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  8248. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  8249. var iterations = 0;
  8250. return new Iterator(function() {
  8251. var step = iterator.next();
  8252. return step.done ? step :
  8253. iteratorValue(type, iterations++, step.value, step)
  8254. });
  8255. };
  8256. createClass(ToSetSequence, SetSeq);
  8257. function ToSetSequence(iter) {
  8258. this._iter = iter;
  8259. this.size = iter.size;
  8260. }
  8261. ToSetSequence.prototype.has = function(key) {
  8262. return this._iter.includes(key);
  8263. };
  8264. ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8265. return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
  8266. };
  8267. ToSetSequence.prototype.__iterator = function(type, reverse) {
  8268. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  8269. return new Iterator(function() {
  8270. var step = iterator.next();
  8271. return step.done ? step :
  8272. iteratorValue(type, step.value, step.value, step);
  8273. });
  8274. };
  8275. createClass(FromEntriesSequence, KeyedSeq);
  8276. function FromEntriesSequence(entries) {
  8277. this._iter = entries;
  8278. this.size = entries.size;
  8279. }
  8280. FromEntriesSequence.prototype.entrySeq = function() {
  8281. return this._iter.toSeq();
  8282. };
  8283. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  8284. return this._iter.__iterate(function(entry ) {
  8285. // Check if entry exists first so array access doesn't throw for holes
  8286. // in the parent iteration.
  8287. if (entry) {
  8288. validateEntry(entry);
  8289. var indexedIterable = isIterable(entry);
  8290. return fn(
  8291. indexedIterable ? entry.get(1) : entry[1],
  8292. indexedIterable ? entry.get(0) : entry[0],
  8293. this$0
  8294. );
  8295. }
  8296. }, reverse);
  8297. };
  8298. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  8299. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  8300. return new Iterator(function() {
  8301. while (true) {
  8302. var step = iterator.next();
  8303. if (step.done) {
  8304. return step;
  8305. }
  8306. var entry = step.value;
  8307. // Check if entry exists first so array access doesn't throw for holes
  8308. // in the parent iteration.
  8309. if (entry) {
  8310. validateEntry(entry);
  8311. var indexedIterable = isIterable(entry);
  8312. return iteratorValue(
  8313. type,
  8314. indexedIterable ? entry.get(0) : entry[0],
  8315. indexedIterable ? entry.get(1) : entry[1],
  8316. step
  8317. );
  8318. }
  8319. }
  8320. });
  8321. };
  8322. ToIndexedSequence.prototype.cacheResult =
  8323. ToKeyedSequence.prototype.cacheResult =
  8324. ToSetSequence.prototype.cacheResult =
  8325. FromEntriesSequence.prototype.cacheResult =
  8326. cacheResultThrough;
  8327. function flipFactory(iterable) {
  8328. var flipSequence = makeSequence(iterable);
  8329. flipSequence._iter = iterable;
  8330. flipSequence.size = iterable.size;
  8331. flipSequence.flip = function() {return iterable};
  8332. flipSequence.reverse = function () {
  8333. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  8334. reversedSequence.flip = function() {return iterable.reverse()};
  8335. return reversedSequence;
  8336. };
  8337. flipSequence.has = function(key ) {return iterable.includes(key)};
  8338. flipSequence.includes = function(key ) {return iterable.has(key)};
  8339. flipSequence.cacheResult = cacheResultThrough;
  8340. flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  8341. return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
  8342. };
  8343. flipSequence.__iteratorUncached = function(type, reverse) {
  8344. if (type === ITERATE_ENTRIES) {
  8345. var iterator = iterable.__iterator(type, reverse);
  8346. return new Iterator(function() {
  8347. var step = iterator.next();
  8348. if (!step.done) {
  8349. var k = step.value[0];
  8350. step.value[0] = step.value[1];
  8351. step.value[1] = k;
  8352. }
  8353. return step;
  8354. });
  8355. }
  8356. return iterable.__iterator(
  8357. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  8358. reverse
  8359. );
  8360. };
  8361. return flipSequence;
  8362. }
  8363. function mapFactory(iterable, mapper, context) {
  8364. var mappedSequence = makeSequence(iterable);
  8365. mappedSequence.size = iterable.size;
  8366. mappedSequence.has = function(key ) {return iterable.has(key)};
  8367. mappedSequence.get = function(key, notSetValue) {
  8368. var v = iterable.get(key, NOT_SET);
  8369. return v === NOT_SET ?
  8370. notSetValue :
  8371. mapper.call(context, v, key, iterable);
  8372. };
  8373. mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  8374. return iterable.__iterate(
  8375. function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
  8376. reverse
  8377. );
  8378. };
  8379. mappedSequence.__iteratorUncached = function (type, reverse) {
  8380. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  8381. return new Iterator(function() {
  8382. var step = iterator.next();
  8383. if (step.done) {
  8384. return step;
  8385. }
  8386. var entry = step.value;
  8387. var key = entry[0];
  8388. return iteratorValue(
  8389. type,
  8390. key,
  8391. mapper.call(context, entry[1], key, iterable),
  8392. step
  8393. );
  8394. });
  8395. };
  8396. return mappedSequence;
  8397. }
  8398. function reverseFactory(iterable, useKeys) {
  8399. var reversedSequence = makeSequence(iterable);
  8400. reversedSequence._iter = iterable;
  8401. reversedSequence.size = iterable.size;
  8402. reversedSequence.reverse = function() {return iterable};
  8403. if (iterable.flip) {
  8404. reversedSequence.flip = function () {
  8405. var flipSequence = flipFactory(iterable);
  8406. flipSequence.reverse = function() {return iterable.flip()};
  8407. return flipSequence;
  8408. };
  8409. }
  8410. reversedSequence.get = function(key, notSetValue)
  8411. {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
  8412. reversedSequence.has = function(key )
  8413. {return iterable.has(useKeys ? key : -1 - key)};
  8414. reversedSequence.includes = function(value ) {return iterable.includes(value)};
  8415. reversedSequence.cacheResult = cacheResultThrough;
  8416. reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
  8417. return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
  8418. };
  8419. reversedSequence.__iterator =
  8420. function(type, reverse) {return iterable.__iterator(type, !reverse)};
  8421. return reversedSequence;
  8422. }
  8423. function filterFactory(iterable, predicate, context, useKeys) {
  8424. var filterSequence = makeSequence(iterable);
  8425. if (useKeys) {
  8426. filterSequence.has = function(key ) {
  8427. var v = iterable.get(key, NOT_SET);
  8428. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  8429. };
  8430. filterSequence.get = function(key, notSetValue) {
  8431. var v = iterable.get(key, NOT_SET);
  8432. return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
  8433. v : notSetValue;
  8434. };
  8435. }
  8436. filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  8437. var iterations = 0;
  8438. iterable.__iterate(function(v, k, c) {
  8439. if (predicate.call(context, v, k, c)) {
  8440. iterations++;
  8441. return fn(v, useKeys ? k : iterations - 1, this$0);
  8442. }
  8443. }, reverse);
  8444. return iterations;
  8445. };
  8446. filterSequence.__iteratorUncached = function (type, reverse) {
  8447. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  8448. var iterations = 0;
  8449. return new Iterator(function() {
  8450. while (true) {
  8451. var step = iterator.next();
  8452. if (step.done) {
  8453. return step;
  8454. }
  8455. var entry = step.value;
  8456. var key = entry[0];
  8457. var value = entry[1];
  8458. if (predicate.call(context, value, key, iterable)) {
  8459. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  8460. }
  8461. }
  8462. });
  8463. };
  8464. return filterSequence;
  8465. }
  8466. function countByFactory(iterable, grouper, context) {
  8467. var groups = Map().asMutable();
  8468. iterable.__iterate(function(v, k) {
  8469. groups.update(
  8470. grouper.call(context, v, k, iterable),
  8471. 0,
  8472. function(a ) {return a + 1}
  8473. );
  8474. });
  8475. return groups.asImmutable();
  8476. }
  8477. function groupByFactory(iterable, grouper, context) {
  8478. var isKeyedIter = isKeyed(iterable);
  8479. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  8480. iterable.__iterate(function(v, k) {
  8481. groups.update(
  8482. grouper.call(context, v, k, iterable),
  8483. function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
  8484. );
  8485. });
  8486. var coerce = iterableClass(iterable);
  8487. return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
  8488. }
  8489. function sliceFactory(iterable, begin, end, useKeys) {
  8490. var originalSize = iterable.size;
  8491. // Sanitize begin & end using this shorthand for ToInt32(argument)
  8492. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  8493. if (begin !== undefined) {
  8494. begin = begin | 0;
  8495. }
  8496. if (end !== undefined) {
  8497. end = end | 0;
  8498. }
  8499. if (wholeSlice(begin, end, originalSize)) {
  8500. return iterable;
  8501. }
  8502. var resolvedBegin = resolveBegin(begin, originalSize);
  8503. var resolvedEnd = resolveEnd(end, originalSize);
  8504. // begin or end will be NaN if they were provided as negative numbers and
  8505. // this iterable's size is unknown. In that case, cache first so there is
  8506. // a known size and these do not resolve to NaN.
  8507. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  8508. return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
  8509. }
  8510. // Note: resolvedEnd is undefined when the original sequence's length is
  8511. // unknown and this slice did not supply an end and should contain all
  8512. // elements after resolvedBegin.
  8513. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  8514. var resolvedSize = resolvedEnd - resolvedBegin;
  8515. var sliceSize;
  8516. if (resolvedSize === resolvedSize) {
  8517. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  8518. }
  8519. var sliceSeq = makeSequence(iterable);
  8520. // If iterable.size is undefined, the size of the realized sliceSeq is
  8521. // unknown at this point unless the number of items to slice is 0
  8522. sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
  8523. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  8524. sliceSeq.get = function (index, notSetValue) {
  8525. index = wrapIndex(this, index);
  8526. return index >= 0 && index < sliceSize ?
  8527. iterable.get(index + resolvedBegin, notSetValue) :
  8528. notSetValue;
  8529. };
  8530. }
  8531. sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
  8532. if (sliceSize === 0) {
  8533. return 0;
  8534. }
  8535. if (reverse) {
  8536. return this.cacheResult().__iterate(fn, reverse);
  8537. }
  8538. var skipped = 0;
  8539. var isSkipping = true;
  8540. var iterations = 0;
  8541. iterable.__iterate(function(v, k) {
  8542. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  8543. iterations++;
  8544. return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  8545. iterations !== sliceSize;
  8546. }
  8547. });
  8548. return iterations;
  8549. };
  8550. sliceSeq.__iteratorUncached = function(type, reverse) {
  8551. if (sliceSize !== 0 && reverse) {
  8552. return this.cacheResult().__iterator(type, reverse);
  8553. }
  8554. // Don't bother instantiating parent iterator if taking 0.
  8555. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  8556. var skipped = 0;
  8557. var iterations = 0;
  8558. return new Iterator(function() {
  8559. while (skipped++ < resolvedBegin) {
  8560. iterator.next();
  8561. }
  8562. if (++iterations > sliceSize) {
  8563. return iteratorDone();
  8564. }
  8565. var step = iterator.next();
  8566. if (useKeys || type === ITERATE_VALUES) {
  8567. return step;
  8568. } else if (type === ITERATE_KEYS) {
  8569. return iteratorValue(type, iterations - 1, undefined, step);
  8570. } else {
  8571. return iteratorValue(type, iterations - 1, step.value[1], step);
  8572. }
  8573. });
  8574. };
  8575. return sliceSeq;
  8576. }
  8577. function takeWhileFactory(iterable, predicate, context) {
  8578. var takeSequence = makeSequence(iterable);
  8579. takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  8580. if (reverse) {
  8581. return this.cacheResult().__iterate(fn, reverse);
  8582. }
  8583. var iterations = 0;
  8584. iterable.__iterate(function(v, k, c)
  8585. {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
  8586. );
  8587. return iterations;
  8588. };
  8589. takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  8590. if (reverse) {
  8591. return this.cacheResult().__iterator(type, reverse);
  8592. }
  8593. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  8594. var iterating = true;
  8595. return new Iterator(function() {
  8596. if (!iterating) {
  8597. return iteratorDone();
  8598. }
  8599. var step = iterator.next();
  8600. if (step.done) {
  8601. return step;
  8602. }
  8603. var entry = step.value;
  8604. var k = entry[0];
  8605. var v = entry[1];
  8606. if (!predicate.call(context, v, k, this$0)) {
  8607. iterating = false;
  8608. return iteratorDone();
  8609. }
  8610. return type === ITERATE_ENTRIES ? step :
  8611. iteratorValue(type, k, v, step);
  8612. });
  8613. };
  8614. return takeSequence;
  8615. }
  8616. function skipWhileFactory(iterable, predicate, context, useKeys) {
  8617. var skipSequence = makeSequence(iterable);
  8618. skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  8619. if (reverse) {
  8620. return this.cacheResult().__iterate(fn, reverse);
  8621. }
  8622. var isSkipping = true;
  8623. var iterations = 0;
  8624. iterable.__iterate(function(v, k, c) {
  8625. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  8626. iterations++;
  8627. return fn(v, useKeys ? k : iterations - 1, this$0);
  8628. }
  8629. });
  8630. return iterations;
  8631. };
  8632. skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  8633. if (reverse) {
  8634. return this.cacheResult().__iterator(type, reverse);
  8635. }
  8636. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  8637. var skipping = true;
  8638. var iterations = 0;
  8639. return new Iterator(function() {
  8640. var step, k, v;
  8641. do {
  8642. step = iterator.next();
  8643. if (step.done) {
  8644. if (useKeys || type === ITERATE_VALUES) {
  8645. return step;
  8646. } else if (type === ITERATE_KEYS) {
  8647. return iteratorValue(type, iterations++, undefined, step);
  8648. } else {
  8649. return iteratorValue(type, iterations++, step.value[1], step);
  8650. }
  8651. }
  8652. var entry = step.value;
  8653. k = entry[0];
  8654. v = entry[1];
  8655. skipping && (skipping = predicate.call(context, v, k, this$0));
  8656. } while (skipping);
  8657. return type === ITERATE_ENTRIES ? step :
  8658. iteratorValue(type, k, v, step);
  8659. });
  8660. };
  8661. return skipSequence;
  8662. }
  8663. function concatFactory(iterable, values) {
  8664. var isKeyedIterable = isKeyed(iterable);
  8665. var iters = [iterable].concat(values).map(function(v ) {
  8666. if (!isIterable(v)) {
  8667. v = isKeyedIterable ?
  8668. keyedSeqFromValue(v) :
  8669. indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  8670. } else if (isKeyedIterable) {
  8671. v = KeyedIterable(v);
  8672. }
  8673. return v;
  8674. }).filter(function(v ) {return v.size !== 0});
  8675. if (iters.length === 0) {
  8676. return iterable;
  8677. }
  8678. if (iters.length === 1) {
  8679. var singleton = iters[0];
  8680. if (singleton === iterable ||
  8681. isKeyedIterable && isKeyed(singleton) ||
  8682. isIndexed(iterable) && isIndexed(singleton)) {
  8683. return singleton;
  8684. }
  8685. }
  8686. var concatSeq = new ArraySeq(iters);
  8687. if (isKeyedIterable) {
  8688. concatSeq = concatSeq.toKeyedSeq();
  8689. } else if (!isIndexed(iterable)) {
  8690. concatSeq = concatSeq.toSetSeq();
  8691. }
  8692. concatSeq = concatSeq.flatten(true);
  8693. concatSeq.size = iters.reduce(
  8694. function(sum, seq) {
  8695. if (sum !== undefined) {
  8696. var size = seq.size;
  8697. if (size !== undefined) {
  8698. return sum + size;
  8699. }
  8700. }
  8701. },
  8702. 0
  8703. );
  8704. return concatSeq;
  8705. }
  8706. function flattenFactory(iterable, depth, useKeys) {
  8707. var flatSequence = makeSequence(iterable);
  8708. flatSequence.__iterateUncached = function(fn, reverse) {
  8709. var iterations = 0;
  8710. var stopped = false;
  8711. function flatDeep(iter, currentDepth) {var this$0 = this;
  8712. iter.__iterate(function(v, k) {
  8713. if ((!depth || currentDepth < depth) && isIterable(v)) {
  8714. flatDeep(v, currentDepth + 1);
  8715. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  8716. stopped = true;
  8717. }
  8718. return !stopped;
  8719. }, reverse);
  8720. }
  8721. flatDeep(iterable, 0);
  8722. return iterations;
  8723. };
  8724. flatSequence.__iteratorUncached = function(type, reverse) {
  8725. var iterator = iterable.__iterator(type, reverse);
  8726. var stack = [];
  8727. var iterations = 0;
  8728. return new Iterator(function() {
  8729. while (iterator) {
  8730. var step = iterator.next();
  8731. if (step.done !== false) {
  8732. iterator = stack.pop();
  8733. continue;
  8734. }
  8735. var v = step.value;
  8736. if (type === ITERATE_ENTRIES) {
  8737. v = v[1];
  8738. }
  8739. if ((!depth || stack.length < depth) && isIterable(v)) {
  8740. stack.push(iterator);
  8741. iterator = v.__iterator(type, reverse);
  8742. } else {
  8743. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  8744. }
  8745. }
  8746. return iteratorDone();
  8747. });
  8748. };
  8749. return flatSequence;
  8750. }
  8751. function flatMapFactory(iterable, mapper, context) {
  8752. var coerce = iterableClass(iterable);
  8753. return iterable.toSeq().map(
  8754. function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
  8755. ).flatten(true);
  8756. }
  8757. function interposeFactory(iterable, separator) {
  8758. var interposedSequence = makeSequence(iterable);
  8759. interposedSequence.size = iterable.size && iterable.size * 2 -1;
  8760. interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  8761. var iterations = 0;
  8762. iterable.__iterate(function(v, k)
  8763. {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
  8764. fn(v, iterations++, this$0) !== false},
  8765. reverse
  8766. );
  8767. return iterations;
  8768. };
  8769. interposedSequence.__iteratorUncached = function(type, reverse) {
  8770. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  8771. var iterations = 0;
  8772. var step;
  8773. return new Iterator(function() {
  8774. if (!step || iterations % 2) {
  8775. step = iterator.next();
  8776. if (step.done) {
  8777. return step;
  8778. }
  8779. }
  8780. return iterations % 2 ?
  8781. iteratorValue(type, iterations++, separator) :
  8782. iteratorValue(type, iterations++, step.value, step);
  8783. });
  8784. };
  8785. return interposedSequence;
  8786. }
  8787. function sortFactory(iterable, comparator, mapper) {
  8788. if (!comparator) {
  8789. comparator = defaultComparator;
  8790. }
  8791. var isKeyedIterable = isKeyed(iterable);
  8792. var index = 0;
  8793. var entries = iterable.toSeq().map(
  8794. function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
  8795. ).toArray();
  8796. entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
  8797. isKeyedIterable ?
  8798. function(v, i) { entries[i].length = 2; } :
  8799. function(v, i) { entries[i] = v[1]; }
  8800. );
  8801. return isKeyedIterable ? KeyedSeq(entries) :
  8802. isIndexed(iterable) ? IndexedSeq(entries) :
  8803. SetSeq(entries);
  8804. }
  8805. function maxFactory(iterable, comparator, mapper) {
  8806. if (!comparator) {
  8807. comparator = defaultComparator;
  8808. }
  8809. if (mapper) {
  8810. var entry = iterable.toSeq()
  8811. .map(function(v, k) {return [v, mapper(v, k, iterable)]})
  8812. .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
  8813. return entry && entry[0];
  8814. } else {
  8815. return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
  8816. }
  8817. }
  8818. function maxCompare(comparator, a, b) {
  8819. var comp = comparator(b, a);
  8820. // b is considered the new max if the comparator declares them equal, but
  8821. // they are not equal and b is in fact a nullish value.
  8822. return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
  8823. }
  8824. function zipWithFactory(keyIter, zipper, iters) {
  8825. var zipSequence = makeSequence(keyIter);
  8826. zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
  8827. // Note: this a generic base implementation of __iterate in terms of
  8828. // __iterator which may be more generically useful in the future.
  8829. zipSequence.__iterate = function(fn, reverse) {
  8830. /* generic:
  8831. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  8832. var step;
  8833. var iterations = 0;
  8834. while (!(step = iterator.next()).done) {
  8835. iterations++;
  8836. if (fn(step.value[1], step.value[0], this) === false) {
  8837. break;
  8838. }
  8839. }
  8840. return iterations;
  8841. */
  8842. // indexed:
  8843. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  8844. var step;
  8845. var iterations = 0;
  8846. while (!(step = iterator.next()).done) {
  8847. if (fn(step.value, iterations++, this) === false) {
  8848. break;
  8849. }
  8850. }
  8851. return iterations;
  8852. };
  8853. zipSequence.__iteratorUncached = function(type, reverse) {
  8854. var iterators = iters.map(function(i )
  8855. {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
  8856. );
  8857. var iterations = 0;
  8858. var isDone = false;
  8859. return new Iterator(function() {
  8860. var steps;
  8861. if (!isDone) {
  8862. steps = iterators.map(function(i ) {return i.next()});
  8863. isDone = steps.some(function(s ) {return s.done});
  8864. }
  8865. if (isDone) {
  8866. return iteratorDone();
  8867. }
  8868. return iteratorValue(
  8869. type,
  8870. iterations++,
  8871. zipper.apply(null, steps.map(function(s ) {return s.value}))
  8872. );
  8873. });
  8874. };
  8875. return zipSequence
  8876. }
  8877. // #pragma Helper Functions
  8878. function reify(iter, seq) {
  8879. return isSeq(iter) ? seq : iter.constructor(seq);
  8880. }
  8881. function validateEntry(entry) {
  8882. if (entry !== Object(entry)) {
  8883. throw new TypeError('Expected [K, V] tuple: ' + entry);
  8884. }
  8885. }
  8886. function resolveSize(iter) {
  8887. assertNotInfinite(iter.size);
  8888. return ensureSize(iter);
  8889. }
  8890. function iterableClass(iterable) {
  8891. return isKeyed(iterable) ? KeyedIterable :
  8892. isIndexed(iterable) ? IndexedIterable :
  8893. SetIterable;
  8894. }
  8895. function makeSequence(iterable) {
  8896. return Object.create(
  8897. (
  8898. isKeyed(iterable) ? KeyedSeq :
  8899. isIndexed(iterable) ? IndexedSeq :
  8900. SetSeq
  8901. ).prototype
  8902. );
  8903. }
  8904. function cacheResultThrough() {
  8905. if (this._iter.cacheResult) {
  8906. this._iter.cacheResult();
  8907. this.size = this._iter.size;
  8908. return this;
  8909. } else {
  8910. return Seq.prototype.cacheResult.call(this);
  8911. }
  8912. }
  8913. function defaultComparator(a, b) {
  8914. return a > b ? 1 : a < b ? -1 : 0;
  8915. }
  8916. function forceIterator(keyPath) {
  8917. var iter = getIterator(keyPath);
  8918. if (!iter) {
  8919. // Array might not be iterable in this environment, so we need a fallback
  8920. // to our wrapped type.
  8921. if (!isArrayLike(keyPath)) {
  8922. throw new TypeError('Expected iterable or array-like: ' + keyPath);
  8923. }
  8924. iter = getIterator(Iterable(keyPath));
  8925. }
  8926. return iter;
  8927. }
  8928. createClass(Record, KeyedCollection);
  8929. function Record(defaultValues, name) {
  8930. var hasInitialized;
  8931. var RecordType = function Record(values) {
  8932. if (values instanceof RecordType) {
  8933. return values;
  8934. }
  8935. if (!(this instanceof RecordType)) {
  8936. return new RecordType(values);
  8937. }
  8938. if (!hasInitialized) {
  8939. hasInitialized = true;
  8940. var keys = Object.keys(defaultValues);
  8941. setProps(RecordTypePrototype, keys);
  8942. RecordTypePrototype.size = keys.length;
  8943. RecordTypePrototype._name = name;
  8944. RecordTypePrototype._keys = keys;
  8945. RecordTypePrototype._defaultValues = defaultValues;
  8946. }
  8947. this._map = Map(values);
  8948. };
  8949. var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
  8950. RecordTypePrototype.constructor = RecordType;
  8951. return RecordType;
  8952. }
  8953. Record.prototype.toString = function() {
  8954. return this.__toString(recordName(this) + ' {', '}');
  8955. };
  8956. // @pragma Access
  8957. Record.prototype.has = function(k) {
  8958. return this._defaultValues.hasOwnProperty(k);
  8959. };
  8960. Record.prototype.get = function(k, notSetValue) {
  8961. if (!this.has(k)) {
  8962. return notSetValue;
  8963. }
  8964. var defaultVal = this._defaultValues[k];
  8965. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  8966. };
  8967. // @pragma Modification
  8968. Record.prototype.clear = function() {
  8969. if (this.__ownerID) {
  8970. this._map && this._map.clear();
  8971. return this;
  8972. }
  8973. var RecordType = this.constructor;
  8974. return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
  8975. };
  8976. Record.prototype.set = function(k, v) {
  8977. if (!this.has(k)) {
  8978. throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
  8979. }
  8980. var newMap = this._map && this._map.set(k, v);
  8981. if (this.__ownerID || newMap === this._map) {
  8982. return this;
  8983. }
  8984. return makeRecord(this, newMap);
  8985. };
  8986. Record.prototype.remove = function(k) {
  8987. if (!this.has(k)) {
  8988. return this;
  8989. }
  8990. var newMap = this._map && this._map.remove(k);
  8991. if (this.__ownerID || newMap === this._map) {
  8992. return this;
  8993. }
  8994. return makeRecord(this, newMap);
  8995. };
  8996. Record.prototype.wasAltered = function() {
  8997. return this._map.wasAltered();
  8998. };
  8999. Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
  9000. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
  9001. };
  9002. Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  9003. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
  9004. };
  9005. Record.prototype.__ensureOwner = function(ownerID) {
  9006. if (ownerID === this.__ownerID) {
  9007. return this;
  9008. }
  9009. var newMap = this._map && this._map.__ensureOwner(ownerID);
  9010. if (!ownerID) {
  9011. this.__ownerID = ownerID;
  9012. this._map = newMap;
  9013. return this;
  9014. }
  9015. return makeRecord(this, newMap, ownerID);
  9016. };
  9017. var RecordPrototype = Record.prototype;
  9018. RecordPrototype[DELETE] = RecordPrototype.remove;
  9019. RecordPrototype.deleteIn =
  9020. RecordPrototype.removeIn = MapPrototype.removeIn;
  9021. RecordPrototype.merge = MapPrototype.merge;
  9022. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  9023. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  9024. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  9025. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  9026. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  9027. RecordPrototype.setIn = MapPrototype.setIn;
  9028. RecordPrototype.update = MapPrototype.update;
  9029. RecordPrototype.updateIn = MapPrototype.updateIn;
  9030. RecordPrototype.withMutations = MapPrototype.withMutations;
  9031. RecordPrototype.asMutable = MapPrototype.asMutable;
  9032. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  9033. function makeRecord(likeRecord, map, ownerID) {
  9034. var record = Object.create(Object.getPrototypeOf(likeRecord));
  9035. record._map = map;
  9036. record.__ownerID = ownerID;
  9037. return record;
  9038. }
  9039. function recordName(record) {
  9040. return record._name || record.constructor.name || 'Record';
  9041. }
  9042. function setProps(prototype, names) {
  9043. try {
  9044. names.forEach(setProp.bind(undefined, prototype));
  9045. } catch (error) {
  9046. // Object.defineProperty failed. Probably IE8.
  9047. }
  9048. }
  9049. function setProp(prototype, name) {
  9050. Object.defineProperty(prototype, name, {
  9051. get: function() {
  9052. return this.get(name);
  9053. },
  9054. set: function(value) {
  9055. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  9056. this.set(name, value);
  9057. }
  9058. });
  9059. }
  9060. createClass(Set, SetCollection);
  9061. // @pragma Construction
  9062. function Set(value) {
  9063. return value === null || value === undefined ? emptySet() :
  9064. isSet(value) && !isOrdered(value) ? value :
  9065. emptySet().withMutations(function(set ) {
  9066. var iter = SetIterable(value);
  9067. assertNotInfinite(iter.size);
  9068. iter.forEach(function(v ) {return set.add(v)});
  9069. });
  9070. }
  9071. Set.of = function(/*...values*/) {
  9072. return this(arguments);
  9073. };
  9074. Set.fromKeys = function(value) {
  9075. return this(KeyedIterable(value).keySeq());
  9076. };
  9077. Set.prototype.toString = function() {
  9078. return this.__toString('Set {', '}');
  9079. };
  9080. // @pragma Access
  9081. Set.prototype.has = function(value) {
  9082. return this._map.has(value);
  9083. };
  9084. // @pragma Modification
  9085. Set.prototype.add = function(value) {
  9086. return updateSet(this, this._map.set(value, true));
  9087. };
  9088. Set.prototype.remove = function(value) {
  9089. return updateSet(this, this._map.remove(value));
  9090. };
  9091. Set.prototype.clear = function() {
  9092. return updateSet(this, this._map.clear());
  9093. };
  9094. // @pragma Composition
  9095. Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
  9096. iters = iters.filter(function(x ) {return x.size !== 0});
  9097. if (iters.length === 0) {
  9098. return this;
  9099. }
  9100. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  9101. return this.constructor(iters[0]);
  9102. }
  9103. return this.withMutations(function(set ) {
  9104. for (var ii = 0; ii < iters.length; ii++) {
  9105. SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
  9106. }
  9107. });
  9108. };
  9109. Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
  9110. if (iters.length === 0) {
  9111. return this;
  9112. }
  9113. iters = iters.map(function(iter ) {return SetIterable(iter)});
  9114. var originalSet = this;
  9115. return this.withMutations(function(set ) {
  9116. originalSet.forEach(function(value ) {
  9117. if (!iters.every(function(iter ) {return iter.includes(value)})) {
  9118. set.remove(value);
  9119. }
  9120. });
  9121. });
  9122. };
  9123. Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
  9124. if (iters.length === 0) {
  9125. return this;
  9126. }
  9127. iters = iters.map(function(iter ) {return SetIterable(iter)});
  9128. var originalSet = this;
  9129. return this.withMutations(function(set ) {
  9130. originalSet.forEach(function(value ) {
  9131. if (iters.some(function(iter ) {return iter.includes(value)})) {
  9132. set.remove(value);
  9133. }
  9134. });
  9135. });
  9136. };
  9137. Set.prototype.merge = function() {
  9138. return this.union.apply(this, arguments);
  9139. };
  9140. Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  9141. return this.union.apply(this, iters);
  9142. };
  9143. Set.prototype.sort = function(comparator) {
  9144. // Late binding
  9145. return OrderedSet(sortFactory(this, comparator));
  9146. };
  9147. Set.prototype.sortBy = function(mapper, comparator) {
  9148. // Late binding
  9149. return OrderedSet(sortFactory(this, comparator, mapper));
  9150. };
  9151. Set.prototype.wasAltered = function() {
  9152. return this._map.wasAltered();
  9153. };
  9154. Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  9155. return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
  9156. };
  9157. Set.prototype.__iterator = function(type, reverse) {
  9158. return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
  9159. };
  9160. Set.prototype.__ensureOwner = function(ownerID) {
  9161. if (ownerID === this.__ownerID) {
  9162. return this;
  9163. }
  9164. var newMap = this._map.__ensureOwner(ownerID);
  9165. if (!ownerID) {
  9166. this.__ownerID = ownerID;
  9167. this._map = newMap;
  9168. return this;
  9169. }
  9170. return this.__make(newMap, ownerID);
  9171. };
  9172. function isSet(maybeSet) {
  9173. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  9174. }
  9175. Set.isSet = isSet;
  9176. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  9177. var SetPrototype = Set.prototype;
  9178. SetPrototype[IS_SET_SENTINEL] = true;
  9179. SetPrototype[DELETE] = SetPrototype.remove;
  9180. SetPrototype.mergeDeep = SetPrototype.merge;
  9181. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  9182. SetPrototype.withMutations = MapPrototype.withMutations;
  9183. SetPrototype.asMutable = MapPrototype.asMutable;
  9184. SetPrototype.asImmutable = MapPrototype.asImmutable;
  9185. SetPrototype.__empty = emptySet;
  9186. SetPrototype.__make = makeSet;
  9187. function updateSet(set, newMap) {
  9188. if (set.__ownerID) {
  9189. set.size = newMap.size;
  9190. set._map = newMap;
  9191. return set;
  9192. }
  9193. return newMap === set._map ? set :
  9194. newMap.size === 0 ? set.__empty() :
  9195. set.__make(newMap);
  9196. }
  9197. function makeSet(map, ownerID) {
  9198. var set = Object.create(SetPrototype);
  9199. set.size = map ? map.size : 0;
  9200. set._map = map;
  9201. set.__ownerID = ownerID;
  9202. return set;
  9203. }
  9204. var EMPTY_SET;
  9205. function emptySet() {
  9206. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  9207. }
  9208. createClass(OrderedSet, Set);
  9209. // @pragma Construction
  9210. function OrderedSet(value) {
  9211. return value === null || value === undefined ? emptyOrderedSet() :
  9212. isOrderedSet(value) ? value :
  9213. emptyOrderedSet().withMutations(function(set ) {
  9214. var iter = SetIterable(value);
  9215. assertNotInfinite(iter.size);
  9216. iter.forEach(function(v ) {return set.add(v)});
  9217. });
  9218. }
  9219. OrderedSet.of = function(/*...values*/) {
  9220. return this(arguments);
  9221. };
  9222. OrderedSet.fromKeys = function(value) {
  9223. return this(KeyedIterable(value).keySeq());
  9224. };
  9225. OrderedSet.prototype.toString = function() {
  9226. return this.__toString('OrderedSet {', '}');
  9227. };
  9228. function isOrderedSet(maybeOrderedSet) {
  9229. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  9230. }
  9231. OrderedSet.isOrderedSet = isOrderedSet;
  9232. var OrderedSetPrototype = OrderedSet.prototype;
  9233. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  9234. OrderedSetPrototype.__empty = emptyOrderedSet;
  9235. OrderedSetPrototype.__make = makeOrderedSet;
  9236. function makeOrderedSet(map, ownerID) {
  9237. var set = Object.create(OrderedSetPrototype);
  9238. set.size = map ? map.size : 0;
  9239. set._map = map;
  9240. set.__ownerID = ownerID;
  9241. return set;
  9242. }
  9243. var EMPTY_ORDERED_SET;
  9244. function emptyOrderedSet() {
  9245. return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
  9246. }
  9247. createClass(Stack, IndexedCollection);
  9248. // @pragma Construction
  9249. function Stack(value) {
  9250. return value === null || value === undefined ? emptyStack() :
  9251. isStack(value) ? value :
  9252. emptyStack().unshiftAll(value);
  9253. }
  9254. Stack.of = function(/*...values*/) {
  9255. return this(arguments);
  9256. };
  9257. Stack.prototype.toString = function() {
  9258. return this.__toString('Stack [', ']');
  9259. };
  9260. // @pragma Access
  9261. Stack.prototype.get = function(index, notSetValue) {
  9262. var head = this._head;
  9263. index = wrapIndex(this, index);
  9264. while (head && index--) {
  9265. head = head.next;
  9266. }
  9267. return head ? head.value : notSetValue;
  9268. };
  9269. Stack.prototype.peek = function() {
  9270. return this._head && this._head.value;
  9271. };
  9272. // @pragma Modification
  9273. Stack.prototype.push = function(/*...values*/) {
  9274. if (arguments.length === 0) {
  9275. return this;
  9276. }
  9277. var newSize = this.size + arguments.length;
  9278. var head = this._head;
  9279. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  9280. head = {
  9281. value: arguments[ii],
  9282. next: head
  9283. };
  9284. }
  9285. if (this.__ownerID) {
  9286. this.size = newSize;
  9287. this._head = head;
  9288. this.__hash = undefined;
  9289. this.__altered = true;
  9290. return this;
  9291. }
  9292. return makeStack(newSize, head);
  9293. };
  9294. Stack.prototype.pushAll = function(iter) {
  9295. iter = IndexedIterable(iter);
  9296. if (iter.size === 0) {
  9297. return this;
  9298. }
  9299. assertNotInfinite(iter.size);
  9300. var newSize = this.size;
  9301. var head = this._head;
  9302. iter.reverse().forEach(function(value ) {
  9303. newSize++;
  9304. head = {
  9305. value: value,
  9306. next: head
  9307. };
  9308. });
  9309. if (this.__ownerID) {
  9310. this.size = newSize;
  9311. this._head = head;
  9312. this.__hash = undefined;
  9313. this.__altered = true;
  9314. return this;
  9315. }
  9316. return makeStack(newSize, head);
  9317. };
  9318. Stack.prototype.pop = function() {
  9319. return this.slice(1);
  9320. };
  9321. Stack.prototype.unshift = function(/*...values*/) {
  9322. return this.push.apply(this, arguments);
  9323. };
  9324. Stack.prototype.unshiftAll = function(iter) {
  9325. return this.pushAll(iter);
  9326. };
  9327. Stack.prototype.shift = function() {
  9328. return this.pop.apply(this, arguments);
  9329. };
  9330. Stack.prototype.clear = function() {
  9331. if (this.size === 0) {
  9332. return this;
  9333. }
  9334. if (this.__ownerID) {
  9335. this.size = 0;
  9336. this._head = undefined;
  9337. this.__hash = undefined;
  9338. this.__altered = true;
  9339. return this;
  9340. }
  9341. return emptyStack();
  9342. };
  9343. Stack.prototype.slice = function(begin, end) {
  9344. if (wholeSlice(begin, end, this.size)) {
  9345. return this;
  9346. }
  9347. var resolvedBegin = resolveBegin(begin, this.size);
  9348. var resolvedEnd = resolveEnd(end, this.size);
  9349. if (resolvedEnd !== this.size) {
  9350. // super.slice(begin, end);
  9351. return IndexedCollection.prototype.slice.call(this, begin, end);
  9352. }
  9353. var newSize = this.size - resolvedBegin;
  9354. var head = this._head;
  9355. while (resolvedBegin--) {
  9356. head = head.next;
  9357. }
  9358. if (this.__ownerID) {
  9359. this.size = newSize;
  9360. this._head = head;
  9361. this.__hash = undefined;
  9362. this.__altered = true;
  9363. return this;
  9364. }
  9365. return makeStack(newSize, head);
  9366. };
  9367. // @pragma Mutability
  9368. Stack.prototype.__ensureOwner = function(ownerID) {
  9369. if (ownerID === this.__ownerID) {
  9370. return this;
  9371. }
  9372. if (!ownerID) {
  9373. this.__ownerID = ownerID;
  9374. this.__altered = false;
  9375. return this;
  9376. }
  9377. return makeStack(this.size, this._head, ownerID, this.__hash);
  9378. };
  9379. // @pragma Iteration
  9380. Stack.prototype.__iterate = function(fn, reverse) {
  9381. if (reverse) {
  9382. return this.reverse().__iterate(fn);
  9383. }
  9384. var iterations = 0;
  9385. var node = this._head;
  9386. while (node) {
  9387. if (fn(node.value, iterations++, this) === false) {
  9388. break;
  9389. }
  9390. node = node.next;
  9391. }
  9392. return iterations;
  9393. };
  9394. Stack.prototype.__iterator = function(type, reverse) {
  9395. if (reverse) {
  9396. return this.reverse().__iterator(type);
  9397. }
  9398. var iterations = 0;
  9399. var node = this._head;
  9400. return new Iterator(function() {
  9401. if (node) {
  9402. var value = node.value;
  9403. node = node.next;
  9404. return iteratorValue(type, iterations++, value);
  9405. }
  9406. return iteratorDone();
  9407. });
  9408. };
  9409. function isStack(maybeStack) {
  9410. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  9411. }
  9412. Stack.isStack = isStack;
  9413. var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  9414. var StackPrototype = Stack.prototype;
  9415. StackPrototype[IS_STACK_SENTINEL] = true;
  9416. StackPrototype.withMutations = MapPrototype.withMutations;
  9417. StackPrototype.asMutable = MapPrototype.asMutable;
  9418. StackPrototype.asImmutable = MapPrototype.asImmutable;
  9419. StackPrototype.wasAltered = MapPrototype.wasAltered;
  9420. function makeStack(size, head, ownerID, hash) {
  9421. var map = Object.create(StackPrototype);
  9422. map.size = size;
  9423. map._head = head;
  9424. map.__ownerID = ownerID;
  9425. map.__hash = hash;
  9426. map.__altered = false;
  9427. return map;
  9428. }
  9429. var EMPTY_STACK;
  9430. function emptyStack() {
  9431. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  9432. }
  9433. /**
  9434. * Contributes additional methods to a constructor
  9435. */
  9436. function mixin(ctor, methods) {
  9437. var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
  9438. Object.keys(methods).forEach(keyCopier);
  9439. Object.getOwnPropertySymbols &&
  9440. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  9441. return ctor;
  9442. }
  9443. Iterable.Iterator = Iterator;
  9444. mixin(Iterable, {
  9445. // ### Conversion to other types
  9446. toArray: function() {
  9447. assertNotInfinite(this.size);
  9448. var array = new Array(this.size || 0);
  9449. this.valueSeq().__iterate(function(v, i) { array[i] = v; });
  9450. return array;
  9451. },
  9452. toIndexedSeq: function() {
  9453. return new ToIndexedSequence(this);
  9454. },
  9455. toJS: function() {
  9456. return this.toSeq().map(
  9457. function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
  9458. ).__toJS();
  9459. },
  9460. toJSON: function() {
  9461. return this.toSeq().map(
  9462. function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
  9463. ).__toJS();
  9464. },
  9465. toKeyedSeq: function() {
  9466. return new ToKeyedSequence(this, true);
  9467. },
  9468. toMap: function() {
  9469. // Use Late Binding here to solve the circular dependency.
  9470. return Map(this.toKeyedSeq());
  9471. },
  9472. toObject: function() {
  9473. assertNotInfinite(this.size);
  9474. var object = {};
  9475. this.__iterate(function(v, k) { object[k] = v; });
  9476. return object;
  9477. },
  9478. toOrderedMap: function() {
  9479. // Use Late Binding here to solve the circular dependency.
  9480. return OrderedMap(this.toKeyedSeq());
  9481. },
  9482. toOrderedSet: function() {
  9483. // Use Late Binding here to solve the circular dependency.
  9484. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  9485. },
  9486. toSet: function() {
  9487. // Use Late Binding here to solve the circular dependency.
  9488. return Set(isKeyed(this) ? this.valueSeq() : this);
  9489. },
  9490. toSetSeq: function() {
  9491. return new ToSetSequence(this);
  9492. },
  9493. toSeq: function() {
  9494. return isIndexed(this) ? this.toIndexedSeq() :
  9495. isKeyed(this) ? this.toKeyedSeq() :
  9496. this.toSetSeq();
  9497. },
  9498. toStack: function() {
  9499. // Use Late Binding here to solve the circular dependency.
  9500. return Stack(isKeyed(this) ? this.valueSeq() : this);
  9501. },
  9502. toList: function() {
  9503. // Use Late Binding here to solve the circular dependency.
  9504. return List(isKeyed(this) ? this.valueSeq() : this);
  9505. },
  9506. // ### Common JavaScript methods and properties
  9507. toString: function() {
  9508. return '[Iterable]';
  9509. },
  9510. __toString: function(head, tail) {
  9511. if (this.size === 0) {
  9512. return head + tail;
  9513. }
  9514. return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
  9515. },
  9516. // ### ES6 Collection methods (ES6 Array and Map)
  9517. concat: function() {var values = SLICE$0.call(arguments, 0);
  9518. return reify(this, concatFactory(this, values));
  9519. },
  9520. includes: function(searchValue) {
  9521. return this.some(function(value ) {return is(value, searchValue)});
  9522. },
  9523. entries: function() {
  9524. return this.__iterator(ITERATE_ENTRIES);
  9525. },
  9526. every: function(predicate, context) {
  9527. assertNotInfinite(this.size);
  9528. var returnValue = true;
  9529. this.__iterate(function(v, k, c) {
  9530. if (!predicate.call(context, v, k, c)) {
  9531. returnValue = false;
  9532. return false;
  9533. }
  9534. });
  9535. return returnValue;
  9536. },
  9537. filter: function(predicate, context) {
  9538. return reify(this, filterFactory(this, predicate, context, true));
  9539. },
  9540. find: function(predicate, context, notSetValue) {
  9541. var entry = this.findEntry(predicate, context);
  9542. return entry ? entry[1] : notSetValue;
  9543. },
  9544. findEntry: function(predicate, context) {
  9545. var found;
  9546. this.__iterate(function(v, k, c) {
  9547. if (predicate.call(context, v, k, c)) {
  9548. found = [k, v];
  9549. return false;
  9550. }
  9551. });
  9552. return found;
  9553. },
  9554. findLastEntry: function(predicate, context) {
  9555. return this.toSeq().reverse().findEntry(predicate, context);
  9556. },
  9557. forEach: function(sideEffect, context) {
  9558. assertNotInfinite(this.size);
  9559. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  9560. },
  9561. join: function(separator) {
  9562. assertNotInfinite(this.size);
  9563. separator = separator !== undefined ? '' + separator : ',';
  9564. var joined = '';
  9565. var isFirst = true;
  9566. this.__iterate(function(v ) {
  9567. isFirst ? (isFirst = false) : (joined += separator);
  9568. joined += v !== null && v !== undefined ? v.toString() : '';
  9569. });
  9570. return joined;
  9571. },
  9572. keys: function() {
  9573. return this.__iterator(ITERATE_KEYS);
  9574. },
  9575. map: function(mapper, context) {
  9576. return reify(this, mapFactory(this, mapper, context));
  9577. },
  9578. reduce: function(reducer, initialReduction, context) {
  9579. assertNotInfinite(this.size);
  9580. var reduction;
  9581. var useFirst;
  9582. if (arguments.length < 2) {
  9583. useFirst = true;
  9584. } else {
  9585. reduction = initialReduction;
  9586. }
  9587. this.__iterate(function(v, k, c) {
  9588. if (useFirst) {
  9589. useFirst = false;
  9590. reduction = v;
  9591. } else {
  9592. reduction = reducer.call(context, reduction, v, k, c);
  9593. }
  9594. });
  9595. return reduction;
  9596. },
  9597. reduceRight: function(reducer, initialReduction, context) {
  9598. var reversed = this.toKeyedSeq().reverse();
  9599. return reversed.reduce.apply(reversed, arguments);
  9600. },
  9601. reverse: function() {
  9602. return reify(this, reverseFactory(this, true));
  9603. },
  9604. slice: function(begin, end) {
  9605. return reify(this, sliceFactory(this, begin, end, true));
  9606. },
  9607. some: function(predicate, context) {
  9608. return !this.every(not(predicate), context);
  9609. },
  9610. sort: function(comparator) {
  9611. return reify(this, sortFactory(this, comparator));
  9612. },
  9613. values: function() {
  9614. return this.__iterator(ITERATE_VALUES);
  9615. },
  9616. // ### More sequential methods
  9617. butLast: function() {
  9618. return this.slice(0, -1);
  9619. },
  9620. isEmpty: function() {
  9621. return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
  9622. },
  9623. count: function(predicate, context) {
  9624. return ensureSize(
  9625. predicate ? this.toSeq().filter(predicate, context) : this
  9626. );
  9627. },
  9628. countBy: function(grouper, context) {
  9629. return countByFactory(this, grouper, context);
  9630. },
  9631. equals: function(other) {
  9632. return deepEqual(this, other);
  9633. },
  9634. entrySeq: function() {
  9635. var iterable = this;
  9636. if (iterable._cache) {
  9637. // We cache as an entries array, so we can just return the cache!
  9638. return new ArraySeq(iterable._cache);
  9639. }
  9640. var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
  9641. entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
  9642. return entriesSequence;
  9643. },
  9644. filterNot: function(predicate, context) {
  9645. return this.filter(not(predicate), context);
  9646. },
  9647. findLast: function(predicate, context, notSetValue) {
  9648. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  9649. },
  9650. first: function() {
  9651. return this.find(returnTrue);
  9652. },
  9653. flatMap: function(mapper, context) {
  9654. return reify(this, flatMapFactory(this, mapper, context));
  9655. },
  9656. flatten: function(depth) {
  9657. return reify(this, flattenFactory(this, depth, true));
  9658. },
  9659. fromEntrySeq: function() {
  9660. return new FromEntriesSequence(this);
  9661. },
  9662. get: function(searchKey, notSetValue) {
  9663. return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
  9664. },
  9665. getIn: function(searchKeyPath, notSetValue) {
  9666. var nested = this;
  9667. // Note: in an ES6 environment, we would prefer:
  9668. // for (var key of searchKeyPath) {
  9669. var iter = forceIterator(searchKeyPath);
  9670. var step;
  9671. while (!(step = iter.next()).done) {
  9672. var key = step.value;
  9673. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  9674. if (nested === NOT_SET) {
  9675. return notSetValue;
  9676. }
  9677. }
  9678. return nested;
  9679. },
  9680. groupBy: function(grouper, context) {
  9681. return groupByFactory(this, grouper, context);
  9682. },
  9683. has: function(searchKey) {
  9684. return this.get(searchKey, NOT_SET) !== NOT_SET;
  9685. },
  9686. hasIn: function(searchKeyPath) {
  9687. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  9688. },
  9689. isSubset: function(iter) {
  9690. iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
  9691. return this.every(function(value ) {return iter.includes(value)});
  9692. },
  9693. isSuperset: function(iter) {
  9694. iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
  9695. return iter.isSubset(this);
  9696. },
  9697. keySeq: function() {
  9698. return this.toSeq().map(keyMapper).toIndexedSeq();
  9699. },
  9700. last: function() {
  9701. return this.toSeq().reverse().first();
  9702. },
  9703. max: function(comparator) {
  9704. return maxFactory(this, comparator);
  9705. },
  9706. maxBy: function(mapper, comparator) {
  9707. return maxFactory(this, comparator, mapper);
  9708. },
  9709. min: function(comparator) {
  9710. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
  9711. },
  9712. minBy: function(mapper, comparator) {
  9713. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
  9714. },
  9715. rest: function() {
  9716. return this.slice(1);
  9717. },
  9718. skip: function(amount) {
  9719. return this.slice(Math.max(0, amount));
  9720. },
  9721. skipLast: function(amount) {
  9722. return reify(this, this.toSeq().reverse().skip(amount).reverse());
  9723. },
  9724. skipWhile: function(predicate, context) {
  9725. return reify(this, skipWhileFactory(this, predicate, context, true));
  9726. },
  9727. skipUntil: function(predicate, context) {
  9728. return this.skipWhile(not(predicate), context);
  9729. },
  9730. sortBy: function(mapper, comparator) {
  9731. return reify(this, sortFactory(this, comparator, mapper));
  9732. },
  9733. take: function(amount) {
  9734. return this.slice(0, Math.max(0, amount));
  9735. },
  9736. takeLast: function(amount) {
  9737. return reify(this, this.toSeq().reverse().take(amount).reverse());
  9738. },
  9739. takeWhile: function(predicate, context) {
  9740. return reify(this, takeWhileFactory(this, predicate, context));
  9741. },
  9742. takeUntil: function(predicate, context) {
  9743. return this.takeWhile(not(predicate), context);
  9744. },
  9745. valueSeq: function() {
  9746. return this.toIndexedSeq();
  9747. },
  9748. // ### Hashable Object
  9749. hashCode: function() {
  9750. return this.__hash || (this.__hash = hashIterable(this));
  9751. }
  9752. // ### Internal
  9753. // abstract __iterate(fn, reverse)
  9754. // abstract __iterator(type, reverse)
  9755. });
  9756. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  9757. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  9758. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  9759. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  9760. var IterablePrototype = Iterable.prototype;
  9761. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  9762. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  9763. IterablePrototype.__toJS = IterablePrototype.toArray;
  9764. IterablePrototype.__toStringMapper = quoteString;
  9765. IterablePrototype.inspect =
  9766. IterablePrototype.toSource = function() { return this.toString(); };
  9767. IterablePrototype.chain = IterablePrototype.flatMap;
  9768. IterablePrototype.contains = IterablePrototype.includes;
  9769. // Temporary warning about using length
  9770. (function () {
  9771. try {
  9772. Object.defineProperty(IterablePrototype, 'length', {
  9773. get: function () {
  9774. if (!Iterable.noLengthWarning) {
  9775. var stack;
  9776. try {
  9777. throw new Error();
  9778. } catch (error) {
  9779. stack = error.stack;
  9780. }
  9781. if (stack.indexOf('_wrapObject') === -1) {
  9782. console && console.warn && console.warn(
  9783. 'iterable.length has been deprecated, '+
  9784. 'use iterable.size or iterable.count(). '+
  9785. 'This warning will become a silent error in a future version. ' +
  9786. stack
  9787. );
  9788. return this.size;
  9789. }
  9790. }
  9791. }
  9792. });
  9793. } catch (e) {}
  9794. })();
  9795. mixin(KeyedIterable, {
  9796. // ### More sequential methods
  9797. flip: function() {
  9798. return reify(this, flipFactory(this));
  9799. },
  9800. findKey: function(predicate, context) {
  9801. var entry = this.findEntry(predicate, context);
  9802. return entry && entry[0];
  9803. },
  9804. findLastKey: function(predicate, context) {
  9805. return this.toSeq().reverse().findKey(predicate, context);
  9806. },
  9807. keyOf: function(searchValue) {
  9808. return this.findKey(function(value ) {return is(value, searchValue)});
  9809. },
  9810. lastKeyOf: function(searchValue) {
  9811. return this.findLastKey(function(value ) {return is(value, searchValue)});
  9812. },
  9813. mapEntries: function(mapper, context) {var this$0 = this;
  9814. var iterations = 0;
  9815. return reify(this,
  9816. this.toSeq().map(
  9817. function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
  9818. ).fromEntrySeq()
  9819. );
  9820. },
  9821. mapKeys: function(mapper, context) {var this$0 = this;
  9822. return reify(this,
  9823. this.toSeq().flip().map(
  9824. function(k, v) {return mapper.call(context, k, v, this$0)}
  9825. ).flip()
  9826. );
  9827. }
  9828. });
  9829. var KeyedIterablePrototype = KeyedIterable.prototype;
  9830. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  9831. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  9832. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  9833. KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
  9834. mixin(IndexedIterable, {
  9835. // ### Conversion to other types
  9836. toKeyedSeq: function() {
  9837. return new ToKeyedSequence(this, false);
  9838. },
  9839. // ### ES6 Collection methods (ES6 Array and Map)
  9840. filter: function(predicate, context) {
  9841. return reify(this, filterFactory(this, predicate, context, false));
  9842. },
  9843. findIndex: function(predicate, context) {
  9844. var entry = this.findEntry(predicate, context);
  9845. return entry ? entry[0] : -1;
  9846. },
  9847. indexOf: function(searchValue) {
  9848. var key = this.toKeyedSeq().keyOf(searchValue);
  9849. return key === undefined ? -1 : key;
  9850. },
  9851. lastIndexOf: function(searchValue) {
  9852. var key = this.toKeyedSeq().reverse().keyOf(searchValue);
  9853. return key === undefined ? -1 : key;
  9854. // var index =
  9855. // return this.toSeq().reverse().indexOf(searchValue);
  9856. },
  9857. reverse: function() {
  9858. return reify(this, reverseFactory(this, false));
  9859. },
  9860. slice: function(begin, end) {
  9861. return reify(this, sliceFactory(this, begin, end, false));
  9862. },
  9863. splice: function(index, removeNum /*, ...values*/) {
  9864. var numArgs = arguments.length;
  9865. removeNum = Math.max(removeNum | 0, 0);
  9866. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  9867. return this;
  9868. }
  9869. // If index is negative, it should resolve relative to the size of the
  9870. // collection. However size may be expensive to compute if not cached, so
  9871. // only call count() if the number is in fact negative.
  9872. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  9873. var spliced = this.slice(0, index);
  9874. return reify(
  9875. this,
  9876. numArgs === 1 ?
  9877. spliced :
  9878. spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  9879. );
  9880. },
  9881. // ### More collection methods
  9882. findLastIndex: function(predicate, context) {
  9883. var key = this.toKeyedSeq().findLastKey(predicate, context);
  9884. return key === undefined ? -1 : key;
  9885. },
  9886. first: function() {
  9887. return this.get(0);
  9888. },
  9889. flatten: function(depth) {
  9890. return reify(this, flattenFactory(this, depth, false));
  9891. },
  9892. get: function(index, notSetValue) {
  9893. index = wrapIndex(this, index);
  9894. return (index < 0 || (this.size === Infinity ||
  9895. (this.size !== undefined && index > this.size))) ?
  9896. notSetValue :
  9897. this.find(function(_, key) {return key === index}, undefined, notSetValue);
  9898. },
  9899. has: function(index) {
  9900. index = wrapIndex(this, index);
  9901. return index >= 0 && (this.size !== undefined ?
  9902. this.size === Infinity || index < this.size :
  9903. this.indexOf(index) !== -1
  9904. );
  9905. },
  9906. interpose: function(separator) {
  9907. return reify(this, interposeFactory(this, separator));
  9908. },
  9909. interleave: function(/*...iterables*/) {
  9910. var iterables = [this].concat(arrCopy(arguments));
  9911. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  9912. var interleaved = zipped.flatten(true);
  9913. if (zipped.size) {
  9914. interleaved.size = zipped.size * iterables.length;
  9915. }
  9916. return reify(this, interleaved);
  9917. },
  9918. last: function() {
  9919. return this.get(-1);
  9920. },
  9921. skipWhile: function(predicate, context) {
  9922. return reify(this, skipWhileFactory(this, predicate, context, false));
  9923. },
  9924. zip: function(/*, ...iterables */) {
  9925. var iterables = [this].concat(arrCopy(arguments));
  9926. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  9927. },
  9928. zipWith: function(zipper/*, ...iterables */) {
  9929. var iterables = arrCopy(arguments);
  9930. iterables[0] = this;
  9931. return reify(this, zipWithFactory(this, zipper, iterables));
  9932. }
  9933. });
  9934. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  9935. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  9936. mixin(SetIterable, {
  9937. // ### ES6 Collection methods (ES6 Array and Map)
  9938. get: function(value, notSetValue) {
  9939. return this.has(value) ? value : notSetValue;
  9940. },
  9941. includes: function(value) {
  9942. return this.has(value);
  9943. },
  9944. // ### More sequential methods
  9945. keySeq: function() {
  9946. return this.valueSeq();
  9947. }
  9948. });
  9949. SetIterable.prototype.has = IterablePrototype.includes;
  9950. // Mixin subclasses
  9951. mixin(KeyedSeq, KeyedIterable.prototype);
  9952. mixin(IndexedSeq, IndexedIterable.prototype);
  9953. mixin(SetSeq, SetIterable.prototype);
  9954. mixin(KeyedCollection, KeyedIterable.prototype);
  9955. mixin(IndexedCollection, IndexedIterable.prototype);
  9956. mixin(SetCollection, SetIterable.prototype);
  9957. // #pragma Helper functions
  9958. function keyMapper(v, k) {
  9959. return k;
  9960. }
  9961. function entryMapper(v, k) {
  9962. return [k, v];
  9963. }
  9964. function not(predicate) {
  9965. return function() {
  9966. return !predicate.apply(this, arguments);
  9967. }
  9968. }
  9969. function neg(predicate) {
  9970. return function() {
  9971. return -predicate.apply(this, arguments);
  9972. }
  9973. }
  9974. function quoteString(value) {
  9975. return typeof value === 'string' ? JSON.stringify(value) : value;
  9976. }
  9977. function defaultZipper() {
  9978. return arrCopy(arguments);
  9979. }
  9980. function defaultNegComparator(a, b) {
  9981. return a < b ? 1 : a > b ? -1 : 0;
  9982. }
  9983. function hashIterable(iterable) {
  9984. if (iterable.size === Infinity) {
  9985. return 0;
  9986. }
  9987. var ordered = isOrdered(iterable);
  9988. var keyed = isKeyed(iterable);
  9989. var h = ordered ? 1 : 0;
  9990. var size = iterable.__iterate(
  9991. keyed ?
  9992. ordered ?
  9993. function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
  9994. function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
  9995. ordered ?
  9996. function(v ) { h = 31 * h + hash(v) | 0; } :
  9997. function(v ) { h = h + hash(v) | 0; }
  9998. );
  9999. return murmurHashOfSize(size, h);
  10000. }
  10001. function murmurHashOfSize(size, h) {
  10002. h = imul(h, 0xCC9E2D51);
  10003. h = imul(h << 15 | h >>> -15, 0x1B873593);
  10004. h = imul(h << 13 | h >>> -13, 5);
  10005. h = (h + 0xE6546B64 | 0) ^ size;
  10006. h = imul(h ^ h >>> 16, 0x85EBCA6B);
  10007. h = imul(h ^ h >>> 13, 0xC2B2AE35);
  10008. h = smi(h ^ h >>> 16);
  10009. return h;
  10010. }
  10011. function hashMerge(a, b) {
  10012. return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
  10013. }
  10014. var Immutable = {
  10015. Iterable: Iterable,
  10016. Seq: Seq,
  10017. Collection: Collection,
  10018. Map: Map,
  10019. OrderedMap: OrderedMap,
  10020. List: List,
  10021. Stack: Stack,
  10022. Set: Set,
  10023. OrderedSet: OrderedSet,
  10024. Record: Record,
  10025. Range: Range,
  10026. Repeat: Repeat,
  10027. is: is,
  10028. fromJS: fromJS
  10029. };
  10030. return Immutable;
  10031. }));
  10032. });
  10033. var parseHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10034. Object.defineProperty(exports, "__esModule", {
  10035. value: true
  10036. });
  10037. exports["default"] = parseHTML;
  10038. var fallback = function fallback(html) {
  10039. var doc = document.implementation.createHTMLDocument('');
  10040. doc.documentElement.innerHTML = html;
  10041. return doc;
  10042. };
  10043. function parseHTML(html) {
  10044. var doc;
  10045. if (typeof DOMParser !== 'undefined') {
  10046. var parser = new DOMParser();
  10047. doc = parser.parseFromString(html, 'text/html');
  10048. if (doc === null || doc.body === null) {
  10049. doc = fallback(html);
  10050. }
  10051. } else {
  10052. doc = fallback(html);
  10053. }
  10054. return doc.body;
  10055. }
  10056. });
  10057. _commonjsHelpers.unwrapExports(parseHTML_1);
  10058. var convertFromHTML_1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10059. Object.defineProperty(exports, "__esModule", {
  10060. value: true
  10061. });
  10062. exports["default"] = void 0;
  10063. var _parseHTML = interopRequireDefault(parseHTML_1);
  10064. var _rangeSort = interopRequireDefault(rangeSort);
  10065. /**
  10066. * Copyright (c) 2013-present, Facebook, Inc.
  10067. * All rights reserved.
  10068. *
  10069. * Copyright (c) 2013-present, Facebook, Inc.
  10070. * All rights reserved.
  10071. *
  10072. * This source code is licensed under the BSD-style license found in the
  10073. * LICENSE file in the /src directory of this source tree. An additional grant
  10074. * of patent rights can be found in the PATENTS file in the same directory.
  10075. */
  10076. var NBSP = '&nbsp;';
  10077. var SPACE = ' '; // Arbitrary max indent
  10078. var MAX_DEPTH = 4; // used for replacing characters in HTML
  10079. /* eslint-disable no-control-regex */
  10080. var REGEX_CR = new RegExp('\r', 'g');
  10081. var REGEX_LF = new RegExp('\n', 'g');
  10082. var REGEX_NBSP = new RegExp(NBSP, 'g');
  10083. var REGEX_BLOCK_DELIMITER = new RegExp('\r', 'g');
  10084. /* eslint-enable no-control-regex */
  10085. // Block tag flow is different because LIs do not have
  10086. // a deterministic style ;_;
  10087. var blockTags = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'li', 'blockquote', 'pre'];
  10088. var inlineTags = {
  10089. b: 'BOLD',
  10090. code: 'CODE',
  10091. del: 'STRIKETHROUGH',
  10092. em: 'ITALIC',
  10093. i: 'ITALIC',
  10094. s: 'STRIKETHROUGH',
  10095. strike: 'STRIKETHROUGH',
  10096. strong: 'BOLD',
  10097. u: 'UNDERLINE'
  10098. };
  10099. var handleMiddleware = function handleMiddleware(maybeMiddleware, base) {
  10100. if (maybeMiddleware && maybeMiddleware.__isMiddleware === true) {
  10101. return maybeMiddleware(base);
  10102. }
  10103. return maybeMiddleware;
  10104. };
  10105. var defaultHTMLToBlock = function defaultHTMLToBlock(nodeName, node, lastList) {
  10106. return undefined;
  10107. };
  10108. var defaultHTMLToStyle = function defaultHTMLToStyle(nodeName, node, currentStyle) {
  10109. return currentStyle;
  10110. };
  10111. var defaultHTMLToEntity = function defaultHTMLToEntity(nodeName, node) {
  10112. return undefined;
  10113. };
  10114. var defaultTextToEntity = function defaultTextToEntity(text) {
  10115. return [];
  10116. };
  10117. var nullthrows = function nullthrows(x) {
  10118. if (x != null) {
  10119. return x;
  10120. }
  10121. throw new Error('Got unexpected null or undefined');
  10122. };
  10123. var sanitizeDraftText = function sanitizeDraftText(input) {
  10124. return input.replace(REGEX_BLOCK_DELIMITER, '');
  10125. };
  10126. function getEmptyChunk() {
  10127. return {
  10128. text: '',
  10129. inlines: [],
  10130. entities: [],
  10131. blocks: []
  10132. };
  10133. }
  10134. function getWhitespaceChunk(inEntity) {
  10135. var entities = new Array(1);
  10136. if (inEntity) {
  10137. entities[0] = inEntity;
  10138. }
  10139. return {
  10140. text: SPACE,
  10141. inlines: [(0, immutable$1.OrderedSet)()],
  10142. entities: entities,
  10143. blocks: []
  10144. };
  10145. }
  10146. function getSoftNewlineChunk(block, depth) {
  10147. var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10148. var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : (0, immutable$1.Map)();
  10149. if (flat === true) {
  10150. return {
  10151. text: '\r',
  10152. inlines: [(0, immutable$1.OrderedSet)()],
  10153. entities: new Array(1),
  10154. blocks: [{
  10155. type: block,
  10156. data: data,
  10157. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  10158. }],
  10159. isNewline: true
  10160. };
  10161. }
  10162. return {
  10163. text: '\n',
  10164. inlines: [(0, immutable$1.OrderedSet)()],
  10165. entities: new Array(1),
  10166. blocks: []
  10167. };
  10168. }
  10169. function getBlockDividerChunk(block, depth) {
  10170. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, immutable$1.Map)();
  10171. return {
  10172. text: '\r',
  10173. inlines: [(0, immutable$1.OrderedSet)()],
  10174. entities: new Array(1),
  10175. blocks: [{
  10176. type: block,
  10177. data: data,
  10178. depth: Math.max(0, Math.min(MAX_DEPTH, depth))
  10179. }]
  10180. };
  10181. }
  10182. function getBlockTypeForTag(tag, lastList) {
  10183. switch (tag) {
  10184. case 'h1':
  10185. return 'header-one';
  10186. case 'h2':
  10187. return 'header-two';
  10188. case 'h3':
  10189. return 'header-three';
  10190. case 'h4':
  10191. return 'header-four';
  10192. case 'h5':
  10193. return 'header-five';
  10194. case 'h6':
  10195. return 'header-six';
  10196. case 'li':
  10197. if (lastList === 'ol') {
  10198. return 'ordered-list-item';
  10199. }
  10200. return 'unordered-list-item';
  10201. case 'blockquote':
  10202. return 'blockquote';
  10203. case 'pre':
  10204. return 'code-block';
  10205. case 'div':
  10206. case 'p':
  10207. return 'unstyled';
  10208. default:
  10209. return null;
  10210. }
  10211. }
  10212. function baseCheckBlockType(nodeName, node, lastList) {
  10213. return getBlockTypeForTag(nodeName, lastList);
  10214. }
  10215. function processInlineTag(tag, node, currentStyle) {
  10216. var styleToCheck = inlineTags[tag];
  10217. if (styleToCheck) {
  10218. currentStyle = currentStyle.add(styleToCheck).toOrderedSet();
  10219. } else if (node instanceof HTMLElement) {
  10220. var htmlElement = node;
  10221. currentStyle = currentStyle.withMutations(function (style) {
  10222. if (htmlElement.style.fontWeight === 'bold') {
  10223. style.add('BOLD');
  10224. }
  10225. if (htmlElement.style.fontStyle === 'italic') {
  10226. style.add('ITALIC');
  10227. }
  10228. if (htmlElement.style.textDecoration === 'underline') {
  10229. style.add('UNDERLINE');
  10230. }
  10231. if (htmlElement.style.textDecoration === 'line-through') {
  10232. style.add('STRIKETHROUGH');
  10233. }
  10234. }).toOrderedSet();
  10235. }
  10236. return currentStyle;
  10237. }
  10238. function baseProcessInlineTag(tag, node) {
  10239. var inlineStyles = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : (0, immutable$1.OrderedSet)();
  10240. return processInlineTag(tag, node, inlineStyles);
  10241. }
  10242. function joinChunks(A, B) {
  10243. var flat = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
  10244. // Sometimes two blocks will touch in the DOM and we need to strip the
  10245. // extra delimiter to preserve niceness.
  10246. var firstInB = B.text.slice(0, 1);
  10247. var lastInA = A.text.slice(-1);
  10248. var adjacentDividers = lastInA === '\r' && firstInB === '\r';
  10249. var isJoiningBlocks = A.text !== '\r' && B.text !== '\r'; // when joining two full blocks like this we want to pop one divider
  10250. var addingNewlineToEmptyBlock = A.text === '\r' && !A.isNewline && B.isNewline; // when joining a newline to an empty block we want to remove the newline
  10251. if (adjacentDividers && (isJoiningBlocks || addingNewlineToEmptyBlock)) {
  10252. A.text = A.text.slice(0, -1);
  10253. A.inlines.pop();
  10254. A.entities.pop();
  10255. A.blocks.pop();
  10256. } // Kill whitespace after blocks if flat mode is on
  10257. if (A.text.slice(-1) === '\r' && flat === true) {
  10258. if (B.text === SPACE || B.text === '\n') {
  10259. return A;
  10260. } else if (firstInB === SPACE || firstInB === '\n') {
  10261. B.text = B.text.slice(1);
  10262. B.inlines.shift();
  10263. B.entities.shift();
  10264. }
  10265. }
  10266. var isNewline = A.text.length === 0 && B.isNewline;
  10267. return {
  10268. text: A.text + B.text,
  10269. inlines: A.inlines.concat(B.inlines),
  10270. entities: A.entities.concat(B.entities),
  10271. blocks: A.blocks.concat(B.blocks),
  10272. isNewline: isNewline
  10273. };
  10274. }
  10275. /*
  10276. * Check to see if we have anything like <p> <blockquote> <h1>... to create
  10277. * block tags from. If we do, we can use those and ignore <div> tags. If we
  10278. * don't, we can treat <div> tags as meaningful (unstyled) blocks.
  10279. */
  10280. function containsSemanticBlockMarkup(html) {
  10281. return blockTags.some(function (tag) {
  10282. return html.indexOf("<".concat(tag)) !== -1;
  10283. });
  10284. }
  10285. function genFragment(node, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, inEntity) {
  10286. var nodeName = node.nodeName.toLowerCase();
  10287. var newBlock = false;
  10288. var nextBlockType = 'unstyled'; // Base Case
  10289. if (nodeName === '#text') {
  10290. var text = node.textContent;
  10291. if (text.trim() === '' && inBlock === null) {
  10292. return getEmptyChunk();
  10293. }
  10294. if (text.trim() === '' && inBlock !== 'code-block') {
  10295. return getWhitespaceChunk(inEntity);
  10296. }
  10297. if (inBlock !== 'code-block') {
  10298. // Can't use empty string because MSWord
  10299. text = text.replace(REGEX_LF, SPACE);
  10300. }
  10301. var entities = Array(text.length).fill(inEntity);
  10302. var offsetChange = 0;
  10303. var textEntities = checkEntityText(text, createEntity, getEntity, mergeEntityData, replaceEntityData).sort(_rangeSort["default"]);
  10304. textEntities.forEach(function (_ref) {
  10305. var entity = _ref.entity,
  10306. offset = _ref.offset,
  10307. length = _ref.length,
  10308. result = _ref.result;
  10309. var adjustedOffset = offset + offsetChange;
  10310. if (result === null || result === undefined) {
  10311. result = text.substr(adjustedOffset, length);
  10312. }
  10313. var textArray = text.split('');
  10314. textArray.splice.bind(textArray, adjustedOffset, length).apply(textArray, result.split(''));
  10315. text = textArray.join('');
  10316. entities.splice.bind(entities, adjustedOffset, length).apply(entities, Array(result.length).fill(entity));
  10317. offsetChange += result.length - length;
  10318. });
  10319. return {
  10320. text: text,
  10321. inlines: Array(text.length).fill(inlineStyle),
  10322. entities: entities,
  10323. blocks: []
  10324. };
  10325. } // BR tags
  10326. if (nodeName === 'br') {
  10327. var _blockType = inBlock;
  10328. if (_blockType === null) {
  10329. // BR tag is at top level, treat it as an unstyled block
  10330. return getSoftNewlineChunk('unstyled', depth, true);
  10331. }
  10332. return getSoftNewlineChunk(_blockType || 'unstyled', depth, options.flat);
  10333. }
  10334. var chunk = getEmptyChunk();
  10335. var newChunk = null; // Inline tags
  10336. inlineStyle = processInlineTag(nodeName, node, inlineStyle);
  10337. inlineStyle = processCustomInlineStyles(nodeName, node, inlineStyle); // Handle lists
  10338. if (nodeName === 'ul' || nodeName === 'ol') {
  10339. if (lastList) {
  10340. depth += 1;
  10341. }
  10342. lastList = nodeName;
  10343. inBlock = null;
  10344. } // Block Tags
  10345. var blockInfo = checkBlockType(nodeName, node, lastList, inBlock);
  10346. var blockType;
  10347. var blockDataMap;
  10348. if (blockInfo === false) {
  10349. return getEmptyChunk();
  10350. }
  10351. blockInfo = blockInfo || {};
  10352. if (typeof blockInfo === 'string') {
  10353. blockType = blockInfo;
  10354. blockDataMap = (0, immutable$1.Map)();
  10355. } else {
  10356. blockType = typeof blockInfo === 'string' ? blockInfo : blockInfo.type;
  10357. blockDataMap = blockInfo.data ? (0, immutable$1.Map)(blockInfo.data) : (0, immutable$1.Map)();
  10358. }
  10359. if (!inBlock && (fragmentBlockTags.indexOf(nodeName) !== -1 || blockType)) {
  10360. chunk = getBlockDividerChunk(blockType || getBlockTypeForTag(nodeName, lastList), depth, blockDataMap);
  10361. inBlock = blockType || getBlockTypeForTag(nodeName, lastList);
  10362. newBlock = true;
  10363. } else if (lastList && (inBlock === 'ordered-list-item' || inBlock === 'unordered-list-item') && nodeName === 'li') {
  10364. var listItemBlockType = getBlockTypeForTag(nodeName, lastList);
  10365. chunk = getBlockDividerChunk(listItemBlockType, depth);
  10366. inBlock = listItemBlockType;
  10367. newBlock = true;
  10368. nextBlockType = lastList === 'ul' ? 'unordered-list-item' : 'ordered-list-item';
  10369. } else if (inBlock && inBlock !== 'atomic' && blockType === 'atomic') {
  10370. inBlock = blockType;
  10371. newBlock = true;
  10372. chunk = getSoftNewlineChunk(blockType, depth, true, // atomic blocks within non-atomic blocks must always be split out
  10373. blockDataMap);
  10374. } // Recurse through children
  10375. var child = node.firstChild; // hack to allow conversion of atomic blocks from HTML (e.g. <figure><img
  10376. // src="..." /></figure>). since metadata must be stored on an entity text
  10377. // must exist for the entity to apply to. the way chunks are joined strips
  10378. // whitespace at the end so it cannot be a space character.
  10379. if (child == null && inEntity && (blockType === 'atomic' || inBlock === 'atomic')) {
  10380. child = document.createTextNode('a');
  10381. }
  10382. if (child != null) {
  10383. nodeName = child.nodeName.toLowerCase();
  10384. }
  10385. var entityId = null;
  10386. while (child) {
  10387. entityId = checkEntityNode(nodeName, child, createEntity, getEntity, mergeEntityData, replaceEntityData);
  10388. newChunk = genFragment(child, inlineStyle, lastList, inBlock, fragmentBlockTags, depth, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, entityId || inEntity);
  10389. chunk = joinChunks(chunk, newChunk, options.flat);
  10390. var sibling = child.nextSibling; // Put in a newline to break up blocks inside blocks
  10391. if (sibling && fragmentBlockTags.indexOf(nodeName) >= 0 && inBlock) {
  10392. var newBlockInfo = checkBlockType(nodeName, child, lastList, inBlock);
  10393. var newBlockType = void 0;
  10394. var newBlockData = void 0;
  10395. if (newBlockInfo !== false) {
  10396. newBlockInfo = newBlockInfo || {};
  10397. if (typeof newBlockInfo === 'string') {
  10398. newBlockType = newBlockInfo;
  10399. newBlockData = (0, immutable$1.Map)();
  10400. } else {
  10401. newBlockType = newBlockInfo.type || getBlockTypeForTag(nodeName, lastList);
  10402. newBlockData = newBlockInfo.data ? (0, immutable$1.Map)(newBlockInfo.data) : (0, immutable$1.Map)();
  10403. }
  10404. chunk = joinChunks(chunk, getSoftNewlineChunk(newBlockType, depth, options.flat, newBlockData), options.flat);
  10405. }
  10406. }
  10407. if (sibling) {
  10408. nodeName = sibling.nodeName.toLowerCase();
  10409. }
  10410. child = sibling;
  10411. }
  10412. if (newBlock) {
  10413. chunk = joinChunks(chunk, getBlockDividerChunk(nextBlockType, depth, (0, immutable$1.Map)()), options.flat);
  10414. }
  10415. return chunk;
  10416. }
  10417. function getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder) {
  10418. html = html.trim().replace(REGEX_CR, '').replace(REGEX_NBSP, SPACE);
  10419. var safeBody = DOMBuilder(html);
  10420. if (!safeBody) {
  10421. return null;
  10422. } // Sometimes we aren't dealing with content that contains nice semantic
  10423. // tags. In this case, use divs to separate everything out into paragraphs
  10424. // and hope for the best.
  10425. var workingBlocks = containsSemanticBlockMarkup(html) ? blockTags.concat(['div']) : ['div']; // Start with -1 block depth to offset the fact that we are passing in a fake
  10426. // UL block to sta rt with.
  10427. 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
  10428. if (chunk.text.indexOf('\r') === 0) {
  10429. chunk = {
  10430. text: chunk.text.slice(1),
  10431. inlines: chunk.inlines.slice(1),
  10432. entities: chunk.entities.slice(1),
  10433. blocks: chunk.blocks
  10434. };
  10435. } // Kill block delimiter at the end
  10436. if (chunk.text.slice(-1) === '\r') {
  10437. chunk.text = chunk.text.slice(0, -1);
  10438. chunk.inlines = chunk.inlines.slice(0, -1);
  10439. chunk.entities = chunk.entities.slice(0, -1);
  10440. chunk.blocks.pop();
  10441. } // If we saw no block tags, put an unstyled one in
  10442. if (chunk.blocks.length === 0) {
  10443. chunk.blocks.push({
  10444. type: 'unstyled',
  10445. data: (0, immutable$1.Map)(),
  10446. depth: 0
  10447. });
  10448. } // Sometimes we start with text that isn't in a block, which is then
  10449. // followed by blocks. Need to fix up the blocks to add in
  10450. // an unstyled block for this content
  10451. if (chunk.text.split('\r').length === chunk.blocks.length + 1) {
  10452. chunk.blocks.unshift({
  10453. type: 'unstyled',
  10454. data: (0, immutable$1.Map)(),
  10455. depth: 0
  10456. });
  10457. }
  10458. return chunk;
  10459. }
  10460. function convertFromHTMLtoContentBlocks(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder, generateKey) {
  10461. // Be ABSOLUTELY SURE that the dom builder you pass hare won't execute
  10462. // arbitrary code in whatever environment you're running this in. For an
  10463. // example of how we try to do this in-browser, see getSafeBodyFromHTML.
  10464. var chunk = getChunkForHTML(html, processCustomInlineStyles, checkEntityNode, checkEntityText, checkBlockType, createEntity, getEntity, mergeEntityData, replaceEntityData, options, DOMBuilder);
  10465. if (chunk == null) {
  10466. return [];
  10467. }
  10468. var start = 0;
  10469. return chunk.text.split('\r').map(function (textBlock, blockIndex) {
  10470. // Make absolutely certain that our text is acceptable.
  10471. textBlock = sanitizeDraftText(textBlock);
  10472. var end = start + textBlock.length;
  10473. var inlines = nullthrows(chunk).inlines.slice(start, end);
  10474. var entities = nullthrows(chunk).entities.slice(start, end);
  10475. var characterList = (0, immutable$1.List)(inlines.map(function (style, entityIndex) {
  10476. var data = {
  10477. style: style,
  10478. entity: null
  10479. };
  10480. if (entities[entityIndex]) {
  10481. data.entity = entities[entityIndex];
  10482. }
  10483. return Draft.Draft.CharacterMetadata.create(data);
  10484. }));
  10485. start = end + 1;
  10486. return new Draft.Draft.ContentBlock({
  10487. key: generateKey(),
  10488. type: nullthrows(chunk).blocks[blockIndex].type,
  10489. data: nullthrows(chunk).blocks[blockIndex].data,
  10490. depth: nullthrows(chunk).blocks[blockIndex].depth,
  10491. text: textBlock,
  10492. characterList: characterList
  10493. });
  10494. });
  10495. }
  10496. var convertFromHTML = function convertFromHTML(_ref2) {
  10497. var _ref2$htmlToStyle = _ref2.htmlToStyle,
  10498. htmlToStyle = _ref2$htmlToStyle === void 0 ? defaultHTMLToStyle : _ref2$htmlToStyle,
  10499. _ref2$htmlToEntity = _ref2.htmlToEntity,
  10500. htmlToEntity = _ref2$htmlToEntity === void 0 ? defaultHTMLToEntity : _ref2$htmlToEntity,
  10501. _ref2$textToEntity = _ref2.textToEntity,
  10502. textToEntity = _ref2$textToEntity === void 0 ? defaultTextToEntity : _ref2$textToEntity,
  10503. _ref2$htmlToBlock = _ref2.htmlToBlock,
  10504. htmlToBlock = _ref2$htmlToBlock === void 0 ? defaultHTMLToBlock : _ref2$htmlToBlock;
  10505. return function (html) {
  10506. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
  10507. flat: false
  10508. };
  10509. var DOMBuilder = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _parseHTML["default"];
  10510. var generateKey = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Draft.Draft.genKey;
  10511. var contentState = Draft.Draft.ContentState.createFromText('');
  10512. var createEntityWithContentState = function createEntityWithContentState() {
  10513. if (contentState.createEntity) {
  10514. var _contentState;
  10515. contentState = (_contentState = contentState).createEntity.apply(_contentState, arguments);
  10516. return contentState.getLastCreatedEntityKey();
  10517. }
  10518. return Draft.Draft.Entity.create.apply(Draft.Draft.Entity, arguments);
  10519. };
  10520. var getEntityWithContentState = function getEntityWithContentState() {
  10521. if (contentState.getEntity) {
  10522. var _contentState2;
  10523. return (_contentState2 = contentState).getEntity.apply(_contentState2, arguments);
  10524. }
  10525. return Draft.Draft.Entity.get.apply(Draft.Draft.Entity, arguments);
  10526. };
  10527. var mergeEntityDataWithContentState = function mergeEntityDataWithContentState() {
  10528. if (contentState.mergeEntityData) {
  10529. var _contentState3;
  10530. contentState = (_contentState3 = contentState).mergeEntityData.apply(_contentState3, arguments);
  10531. return;
  10532. }
  10533. Draft.Draft.Entity.mergeData.apply(Draft.Draft.Entity, arguments);
  10534. };
  10535. var replaceEntityDataWithContentState = function replaceEntityDataWithContentState() {
  10536. if (contentState.replaceEntityData) {
  10537. var _contentState4;
  10538. contentState = (_contentState4 = contentState).replaceEntityData.apply(_contentState4, arguments);
  10539. return;
  10540. }
  10541. Draft.Draft.Entity.replaceData.apply(Draft.Draft.Entity, arguments);
  10542. };
  10543. var contentBlocks = convertFromHTMLtoContentBlocks(html, handleMiddleware(htmlToStyle, baseProcessInlineTag), handleMiddleware(htmlToEntity, defaultHTMLToEntity), handleMiddleware(textToEntity, defaultTextToEntity), handleMiddleware(htmlToBlock, baseCheckBlockType), createEntityWithContentState, getEntityWithContentState, mergeEntityDataWithContentState, replaceEntityDataWithContentState, options, DOMBuilder, generateKey);
  10544. var blockMap = Draft.Draft.BlockMapBuilder.createFromArray(contentBlocks);
  10545. var firstBlockKey = contentBlocks[0].getKey();
  10546. return contentState.merge({
  10547. blockMap: blockMap,
  10548. selectionBefore: Draft.Draft.SelectionState.createEmpty(firstBlockKey),
  10549. selectionAfter: Draft.Draft.SelectionState.createEmpty(firstBlockKey)
  10550. });
  10551. };
  10552. };
  10553. var _default = function _default() {
  10554. if (arguments.length >= 1 && typeof (arguments.length <= 0 ? undefined : arguments[0]) === 'string') {
  10555. return convertFromHTML({}).apply(void 0, arguments);
  10556. }
  10557. return convertFromHTML.apply(void 0, arguments);
  10558. };
  10559. exports["default"] = _default;
  10560. });
  10561. _commonjsHelpers.unwrapExports(convertFromHTML_1);
  10562. var lib = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10563. Object.defineProperty(exports, "__esModule", {
  10564. value: true
  10565. });
  10566. Object.defineProperty(exports, "convertToHTML", {
  10567. enumerable: true,
  10568. get: function get() {
  10569. return _convertToHTML["default"];
  10570. }
  10571. });
  10572. Object.defineProperty(exports, "convertFromHTML", {
  10573. enumerable: true,
  10574. get: function get() {
  10575. return _convertFromHTML["default"];
  10576. }
  10577. });
  10578. Object.defineProperty(exports, "parseHTML", {
  10579. enumerable: true,
  10580. get: function get() {
  10581. return _parseHTML["default"];
  10582. }
  10583. });
  10584. var _convertToHTML = interopRequireDefault(convertToHTML_1);
  10585. var _convertFromHTML = interopRequireDefault(convertFromHTML_1);
  10586. var _parseHTML = interopRequireDefault(parseHTML_1);
  10587. });
  10588. _commonjsHelpers.unwrapExports(lib);
  10589. var configs = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  10590. Object.defineProperty(exports, "__esModule", {
  10591. value: true
  10592. });
  10593. exports.getFromHTMLConfig = exports.getToHTMLConfig = exports.blocks = exports.getHexColor = exports.defaultFontFamilies = exports.namedColors = undefined;
  10594. 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; };
  10595. var _react2 = _interopRequireDefault(React__default);
  10596. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10597. 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; }
  10598. var namedColors = exports.namedColors = {
  10599. "aliceblue": "#f0f8ff",
  10600. "antiquewhite": "#faebd7",
  10601. "aqua": "#00ffff",
  10602. "aquamarine": "#7fffd4",
  10603. "azure": "#f0ffff",
  10604. "beige": "#f5f5dc",
  10605. "bisque": "#ffe4c4",
  10606. "black": "#000000",
  10607. "blanchedalmond": "#ffebcd",
  10608. "blue": "#0000ff",
  10609. "blueviolet": "#8a2be2",
  10610. "brown": "#a52a2a",
  10611. "burlywood": "#deb887",
  10612. "cadetblue": "#5f9ea0",
  10613. "chartreuse": "#7fff00",
  10614. "chocolate": "#d2691e",
  10615. "coral": "#ff7f50",
  10616. "cornflowerblue": "#6495ed",
  10617. "cornsilk": "#fff8dc",
  10618. "crimson": "#dc143c",
  10619. "cyan": "#00ffff",
  10620. "darkblue": "#00008b",
  10621. "darkcyan": "#008b8b",
  10622. "darkgoldenrod": "#b8860b",
  10623. "darkgray": "#a9a9a9",
  10624. "darkgreen": "#006400",
  10625. "darkkhaki": "#bdb76b",
  10626. "darkmagenta": "#8b008b",
  10627. "darkolivegreen": "#556b2f",
  10628. "darkorange": "#ff8c00",
  10629. "darkorchid": "#9932cc",
  10630. "darkred": "#8b0000",
  10631. "darksalmon": "#e9967a",
  10632. "darkseagreen": "#8fbc8f",
  10633. "darkslateblue": "#483d8b",
  10634. "darkslategray": "#2f4f4f",
  10635. "darkturquoise": "#00ced1",
  10636. "darkviolet": "#9400d3",
  10637. "deeppink": "#ff1493",
  10638. "deepskyblue": "#00bfff",
  10639. "dimgray": "#696969",
  10640. "dodgerblue": "#1e90ff",
  10641. "firebrick": "#b22222",
  10642. "floralwhite": "#fffaf0",
  10643. "forestgreen": "#228b22",
  10644. "fuchsia": "#ff00ff",
  10645. "gainsboro": "#dcdcdc",
  10646. "ghostwhite": "#f8f8ff",
  10647. "gold": "#ffd700",
  10648. "goldenrod": "#daa520",
  10649. "gray": "#808080",
  10650. "green": "#008000",
  10651. "greenyellow": "#adff2f",
  10652. "honeydew": "#f0fff0",
  10653. "hotpink": "#ff69b4",
  10654. "indianred ": "#cd5c5c",
  10655. "indigo": "#4b0082",
  10656. "ivory": "#fffff0",
  10657. "khaki": "#f0e68c",
  10658. "lavender": "#e6e6fa",
  10659. "lavenderblush": "#fff0f5",
  10660. "lawngreen": "#7cfc00",
  10661. "lemonchiffon": "#fffacd",
  10662. "lightblue": "#add8e6",
  10663. "lightcoral": "#f08080",
  10664. "lightcyan": "#e0ffff",
  10665. "lightgoldenrodyellow": "#fafad2",
  10666. "lightgrey": "#d3d3d3",
  10667. "lightgreen": "#90ee90",
  10668. "lightpink": "#ffb6c1",
  10669. "lightsalmon": "#ffa07a",
  10670. "lightseagreen": "#20b2aa",
  10671. "lightskyblue": "#87cefa",
  10672. "lightslategray": "#778899",
  10673. "lightsteelblue": "#b0c4de",
  10674. "lightyellow": "#ffffe0",
  10675. "lime": "#00ff00",
  10676. "limegreen": "#32cd32",
  10677. "linen": "#faf0e6",
  10678. "magenta": "#ff00ff",
  10679. "maroon": "#800000",
  10680. "mediumaquamarine": "#66cdaa",
  10681. "mediumblue": "#0000cd",
  10682. "mediumorchid": "#ba55d3",
  10683. "mediumpurple": "#9370d8",
  10684. "mediumseagreen": "#3cb371",
  10685. "mediumslateblue": "#7b68ee",
  10686. "mediumspringgreen": "#00fa9a",
  10687. "mediumturquoise": "#48d1cc",
  10688. "mediumvioletred": "#c71585",
  10689. "midnightblue": "#191970",
  10690. "mintcream": "#f5fffa",
  10691. "mistyrose": "#ffe4e1",
  10692. "moccasin": "#ffe4b5",
  10693. "navajowhite": "#ffdead",
  10694. "navy": "#000080",
  10695. "oldlace": "#fdf5e6",
  10696. "olive": "#808000",
  10697. "olivedrab": "#6b8e23",
  10698. "orange": "#ffa500",
  10699. "orangered": "#ff4500",
  10700. "orchid": "#da70d6",
  10701. "palegoldenrod": "#eee8aa",
  10702. "palegreen": "#98fb98",
  10703. "paleturquoise": "#afeeee",
  10704. "palevioletred": "#d87093",
  10705. "papayawhip": "#ffefd5",
  10706. "peachpuff": "#ffdab9",
  10707. "peru": "#cd853f",
  10708. "pink": "#ffc0cb",
  10709. "plum": "#dda0dd",
  10710. "powderblue": "#b0e0e6",
  10711. "purple": "#800080",
  10712. "rebeccapurple": "#663399",
  10713. "red": "#ff0000",
  10714. "rosybrown": "#bc8f8f",
  10715. "royalblue": "#4169e1",
  10716. "saddlebrown": "#8b4513",
  10717. "salmon": "#fa8072",
  10718. "sandybrown": "#f4a460",
  10719. "seagreen": "#2e8b57",
  10720. "seashell": "#fff5ee",
  10721. "sienna": "#a0522d",
  10722. "silver": "#c0c0c0",
  10723. "skyblue": "#87ceeb",
  10724. "slateblue": "#6a5acd",
  10725. "slategray": "#708090",
  10726. "snow": "#fffafa",
  10727. "springgreen": "#00ff7f",
  10728. "steelblue": "#4682b4",
  10729. "tan": "#d2b48c",
  10730. "teal": "#008080",
  10731. "thistle": "#d8bfd8",
  10732. "tomato": "#ff6347",
  10733. "turquoise": "#40e0d0",
  10734. "violet": "#ee82ee",
  10735. "wheat": "#f5deb3",
  10736. "white": "#ffffff",
  10737. "whitesmoke": "#f5f5f5",
  10738. "yellow": "#ffff00",
  10739. "yellowgreen": "#9acd32"
  10740. };
  10741. var getStyleValue = function getStyleValue(style) {
  10742. return style.split('-')[1];
  10743. };
  10744. var defaultUnitExportFn = function defaultUnitExportFn(unit) {
  10745. return unit + 'px';
  10746. };
  10747. var defaultUnitImportFn = function defaultUnitImportFn(unit) {
  10748. return unit.replace('px', '');
  10749. };
  10750. var ignoredNodeAttributes = ['style'];
  10751. var ignoredEntityNodeAttributes = ['style', 'href', 'target', 'alt', 'title', 'id', 'controls', 'autoplay', 'loop', 'poster'];
  10752. var spreadNodeAttributes = function spreadNodeAttributes(attributesObject) {
  10753. return Object.keys(attributesObject).reduce(function (attributeString, attributeName) {
  10754. return attributeString + " " + attributeName + "=\"" + attributesObject[attributeName] + "\"";
  10755. }, '').replace(/^\s$/, '');
  10756. };
  10757. var defaultFontFamilies = exports.defaultFontFamilies = [{
  10758. name: 'Araial',
  10759. family: 'Arial, Helvetica, sans-serif'
  10760. }, {
  10761. name: 'Georgia',
  10762. family: 'Georgia, serif'
  10763. }, {
  10764. name: 'Impact',
  10765. family: 'Impact, serif'
  10766. }, {
  10767. name: 'Monospace',
  10768. family: '"Courier New", Courier, monospace'
  10769. }, {
  10770. name: 'Tahoma',
  10771. family: "tahoma, arial, 'Hiragino Sans GB', 宋体, sans-serif"
  10772. }];
  10773. var getHexColor = exports.getHexColor = function getHexColor(color) {
  10774. color = color.replace('color:', '').replace(';', '').replace(' ', '');
  10775. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  10776. return color;
  10777. } else if (namedColors[color]) {
  10778. return namedColors[color];
  10779. } else if (color.indexOf('rgb') === 0) {
  10780. var rgbArray = color.split(',');
  10781. var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
  10782. var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
  10783. return hex.length === 1 ? '0' + hex : hex;
  10784. }).join('');
  10785. return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
  10786. );
  10787. } else {
  10788. return null;
  10789. }
  10790. };
  10791. var blocks = exports.blocks = {
  10792. 'header-one': 'h1',
  10793. 'header-two': 'h2',
  10794. 'header-three': 'h3',
  10795. 'header-four': 'h4',
  10796. 'header-five': 'h5',
  10797. 'header-six': 'h6',
  10798. 'unstyled': 'p',
  10799. 'blockquote': 'blockquote'
  10800. };
  10801. var blockTypes = Object.keys(blocks);
  10802. var blockNames = blockTypes.map(function (key) {
  10803. return blocks[key];
  10804. });
  10805. var convertAtomicBlock = function convertAtomicBlock(block, contentState, blockNodeAttributes) {
  10806. if (!block || !block.key) {
  10807. return _react2.default.createElement("p", null);
  10808. }
  10809. var contentBlock = contentState.getBlockForKey(block.key);
  10810. var className = blockNodeAttributes.class,
  10811. nodeAttrAsProps = _objectWithoutProperties(blockNodeAttributes, ["class"]);
  10812. nodeAttrAsProps.className = className;
  10813. if (!contentBlock) {
  10814. return _react2.default.createElement("p", null);
  10815. }
  10816. var entityKey = contentBlock.getEntityAt(0);
  10817. if (!entityKey) {
  10818. return _react2.default.createElement("p", null);
  10819. }
  10820. var entity = contentState.getEntity(entityKey);
  10821. var mediaType = entity.getType().toLowerCase();
  10822. var _block$data = block.data,
  10823. float = _block$data.float,
  10824. alignment = _block$data.alignment;
  10825. var _entity$getData = entity.getData(),
  10826. url = _entity$getData.url,
  10827. link = _entity$getData.link,
  10828. link_target = _entity$getData.link_target,
  10829. width = _entity$getData.width,
  10830. height = _entity$getData.height,
  10831. meta = _entity$getData.meta;
  10832. if (mediaType === 'image') {
  10833. var imageWrapStyle = {};
  10834. var styledClassName = '';
  10835. if (float) {
  10836. imageWrapStyle.float = float;
  10837. styledClassName += ' float-' + float;
  10838. } else if (alignment) {
  10839. imageWrapStyle.textAlign = alignment;
  10840. styledClassName += ' align-' + alignment;
  10841. }
  10842. if (link) {
  10843. return _react2.default.createElement(
  10844. "div",
  10845. { className: "media-wrap image-wrap" + styledClassName, style: imageWrapStyle },
  10846. _react2.default.createElement(
  10847. "a",
  10848. { style: { display: 'inline-block' }, href: link, target: link_target },
  10849. _react2.default.createElement("img", _extends({}, nodeAttrAsProps, meta, { src: url, width: width, height: height, style: { width: width, height: height } }))
  10850. )
  10851. );
  10852. } else {
  10853. return _react2.default.createElement(
  10854. "div",
  10855. { className: "media-wrap image-wrap" + styledClassName, style: imageWrapStyle },
  10856. _react2.default.createElement("img", _extends({}, nodeAttrAsProps, meta, { src: url, width: width, height: height, style: { width: width, height: height } }))
  10857. );
  10858. }
  10859. } else if (mediaType === 'audio') {
  10860. return _react2.default.createElement(
  10861. "div",
  10862. { className: "media-wrap audio-wrap" },
  10863. _react2.default.createElement("audio", _extends({ controls: true }, nodeAttrAsProps, meta, { src: url }))
  10864. );
  10865. } else if (mediaType === 'video') {
  10866. return _react2.default.createElement(
  10867. "div",
  10868. { className: "media-wrap video-wrap" },
  10869. _react2.default.createElement("video", _extends({ controls: true }, nodeAttrAsProps, meta, { src: url, width: width, height: height }))
  10870. );
  10871. } else if (mediaType === 'embed') {
  10872. return _react2.default.createElement(
  10873. "div",
  10874. { className: "media-wrap embed-wrap" },
  10875. _react2.default.createElement("div", { dangerouslySetInnerHTML: { __html: url } })
  10876. );
  10877. } else if (mediaType === 'hr') {
  10878. return _react2.default.createElement("hr", null);
  10879. } else {
  10880. return _react2.default.createElement("p", null);
  10881. }
  10882. };
  10883. var entityToHTML = function entityToHTML(options) {
  10884. return function (entity, originalText) {
  10885. var entityExportFn = options.entityExportFn;
  10886. var entityType = entity.type.toLowerCase();
  10887. if (entityExportFn) {
  10888. var customOutput = entityExportFn(entity, originalText);
  10889. if (customOutput) {
  10890. return customOutput;
  10891. }
  10892. }
  10893. if (entityType === 'link') {
  10894. var _ref = entity.data.nodeAttributes || {},
  10895. className = _ref.class,
  10896. nodeAttrAsProps = _objectWithoutProperties(_ref, ["class"]);
  10897. nodeAttrAsProps.className = className;
  10898. return _react2.default.createElement("a", _extends({ href: entity.data.href, target: entity.data.target }, nodeAttrAsProps));
  10899. }
  10900. };
  10901. };
  10902. var styleToHTML = function styleToHTML(options) {
  10903. return function (style) {
  10904. var unitExportFn = options.unitExportFn || defaultUnitExportFn;
  10905. if (options.styleExportFn) {
  10906. var customOutput = options.styleExportFn(style, options);
  10907. if (customOutput) {
  10908. return customOutput;
  10909. }
  10910. }
  10911. style = style.toLowerCase();
  10912. if (style === 'strikethrough') {
  10913. return _react2.default.createElement("span", { style: { textDecoration: 'line-through' } });
  10914. } else if (style === 'superscript') {
  10915. return _react2.default.createElement("sup", null);
  10916. } else if (style === 'subscript') {
  10917. return _react2.default.createElement("sub", null);
  10918. } else if (style.indexOf('color-') === 0) {
  10919. return _react2.default.createElement("span", { style: { color: '#' + getStyleValue(style) } });
  10920. } else if (style.indexOf('bgcolor-') === 0) {
  10921. return _react2.default.createElement("span", { style: { backgroundColor: '#' + getStyleValue(style) } });
  10922. } else if (style.indexOf('fontsize-') === 0) {
  10923. return _react2.default.createElement("span", { style: { fontSize: unitExportFn(getStyleValue(style), 'font-size', 'html') } });
  10924. } else if (style.indexOf('lineheight-') === 0) {
  10925. return _react2.default.createElement("span", { style: { lineHeight: unitExportFn(getStyleValue(style), 'line-height', 'html') } });
  10926. } else if (style.indexOf('letterspacing-') === 0) {
  10927. return _react2.default.createElement("span", { style: { letterSpacing: unitExportFn(getStyleValue(style), 'letter-spacing', 'html') } });
  10928. } else if (style.indexOf('fontfamily-') === 0) {
  10929. var fontFamily = options.fontFamilies.find(function (item) {
  10930. return item.name.toLowerCase() === getStyleValue(style);
  10931. });
  10932. if (!fontFamily) return;
  10933. return _react2.default.createElement("span", { style: { fontFamily: fontFamily.family } });
  10934. }
  10935. };
  10936. };
  10937. var blockToHTML = function blockToHTML(options) {
  10938. return function (block) {
  10939. var blockExportFn = options.blockExportFn,
  10940. contentState = options.contentState;
  10941. if (blockExportFn) {
  10942. var customOutput = blockExportFn(contentState, block);
  10943. if (customOutput) {
  10944. return customOutput;
  10945. }
  10946. }
  10947. var blockStyle = '';
  10948. var blockType = block.type.toLowerCase();
  10949. var _block$data2 = block.data,
  10950. textAlign = _block$data2.textAlign,
  10951. textIndent = _block$data2.textIndent,
  10952. _block$data2$nodeAttr = _block$data2.nodeAttributes,
  10953. nodeAttributes = _block$data2$nodeAttr === undefined ? {} : _block$data2$nodeAttr;
  10954. var attributeString = spreadNodeAttributes(nodeAttributes);
  10955. if (textAlign || textIndent) {
  10956. blockStyle = ' style="';
  10957. if (textAlign) {
  10958. blockStyle += "text-align:" + textAlign + ";";
  10959. }
  10960. if (textIndent && !isNaN(textIndent) && textIndent > 0) {
  10961. blockStyle += "text-indent:" + textIndent * 2 + "em;";
  10962. }
  10963. blockStyle += '"';
  10964. }
  10965. if (blockType === 'atomic') {
  10966. return convertAtomicBlock(block, contentState, nodeAttributes);
  10967. } else if (blockType === 'code-block') {
  10968. var previousBlock = contentState.getBlockBefore(block.key);
  10969. var nextBlock = contentState.getBlockAfter(block.key);
  10970. var previousBlockType = previousBlock && previousBlock.getType();
  10971. var nextBlockType = nextBlock && nextBlock.getType();
  10972. var start = '';
  10973. var end = '';
  10974. if (previousBlockType !== 'code-block') {
  10975. start = "<pre" + attributeString + "><code>";
  10976. } else {
  10977. start = '';
  10978. }
  10979. if (nextBlockType !== 'code-block') {
  10980. end = '</code></pre>';
  10981. } else {
  10982. end = '<br/>';
  10983. }
  10984. return { start: start, end: end };
  10985. } else if (blocks[blockType]) {
  10986. return {
  10987. start: "<" + blocks[blockType] + blockStyle + attributeString + ">",
  10988. end: "</" + blocks[blockType] + ">"
  10989. };
  10990. } else if (blockType === 'unordered-list-item') {
  10991. return {
  10992. start: "<li" + blockStyle + attributeString + ">",
  10993. end: '</li>',
  10994. nest: _react2.default.createElement("ul", null)
  10995. };
  10996. } else if (blockType === 'ordered-list-item') {
  10997. return {
  10998. start: "<li" + blockStyle + attributeString + ">",
  10999. end: '</li>',
  11000. nest: _react2.default.createElement("ol", null)
  11001. };
  11002. }
  11003. };
  11004. };
  11005. var htmlToStyle = function htmlToStyle(options, source) {
  11006. return function (nodeName, node, currentStyle) {
  11007. if (!node || !node.style) {
  11008. return currentStyle;
  11009. }
  11010. var unitImportFn = options.unitImportFn || defaultUnitImportFn;
  11011. var newStyle = currentStyle;
  11012. [].forEach.call(node.style, function (style) {
  11013. if (nodeName === 'span' && style === 'color') {
  11014. var color = getHexColor(node.style.color);
  11015. newStyle = color ? newStyle.add('COLOR-' + color.replace('#', '').toUpperCase()) : newStyle;
  11016. } else if (nodeName === 'span' && style === 'background-color') {
  11017. var _color = getHexColor(node.style.backgroundColor);
  11018. newStyle = _color ? newStyle.add('BGCOLOR-' + _color.replace('#', '').toUpperCase()) : newStyle;
  11019. } else if (nodeName === 'span' && style === 'font-size') {
  11020. newStyle = newStyle.add('FONTSIZE-' + unitImportFn(node.style.fontSize, 'font-size', source));
  11021. } else if (nodeName === 'span' && style === 'line-height' && !isNaN(parseFloat(node.style.lineHeight, 10))) {
  11022. newStyle = newStyle.add('LINEHEIGHT-' + unitImportFn(node.style.lineHeight, 'line-height', source));
  11023. } else if (nodeName === 'span' && style === 'letter-spacing' && !isNaN(parseFloat(node.style.letterSpacing, 10))) {
  11024. newStyle = newStyle.add('LETTERSPACING-' + unitImportFn(node.style.letterSpacing, 'letter-spacing', source));
  11025. } else if (nodeName === 'span' && style === 'text-decoration') {
  11026. if (node.style.textDecoration === 'line-through') {
  11027. newStyle = newStyle.add('STRIKETHROUGH');
  11028. } else if (node.style.textDecoration === 'underline') {
  11029. newStyle = newStyle.add('UNDERLINE');
  11030. }
  11031. } else if (nodeName === 'span' && style === 'font-family') {
  11032. var fontFamily = options.fontFamilies.find(function (item) {
  11033. return item.family.toLowerCase() === node.style.fontFamily.toLowerCase();
  11034. });
  11035. if (!fontFamily) return;
  11036. newStyle = newStyle.add('FONTFAMILY-' + fontFamily.name.toUpperCase());
  11037. }
  11038. });
  11039. if (nodeName === 'sup') {
  11040. newStyle = newStyle.add('SUPERSCRIPT');
  11041. } else if (nodeName === 'sub') {
  11042. newStyle = newStyle.add('SUBSCRIPT');
  11043. }
  11044. options.styleImportFn && (newStyle = options.styleImportFn(nodeName, node, newStyle, source) || newStyle);
  11045. return newStyle;
  11046. };
  11047. };
  11048. var htmlToEntity = function htmlToEntity(options, source) {
  11049. return function (nodeName, node, createEntity) {
  11050. if (options && options.entityImportFn) {
  11051. var customInput = options.entityImportFn(nodeName, node, createEntity, source);
  11052. if (customInput) {
  11053. return customInput;
  11054. }
  11055. }
  11056. nodeName = nodeName.toLowerCase();
  11057. var alt = node.alt,
  11058. title = node.title,
  11059. id = node.id,
  11060. controls = node.controls,
  11061. autoplay = node.autoplay,
  11062. loop = node.loop,
  11063. poster = node.poster;
  11064. var meta = {};
  11065. var nodeAttributes = {};
  11066. id && (meta.id = id);
  11067. alt && (meta.alt = alt);
  11068. title && (meta.title = title);
  11069. controls && (meta.controls = controls);
  11070. autoplay && (meta.autoPlay = autoplay);
  11071. loop && (meta.loop = loop);
  11072. poster && (meta.poster = poster);
  11073. node.attributes && Object.keys(node.attributes).forEach(function (key) {
  11074. var attr = node.attributes[key];
  11075. ignoredEntityNodeAttributes.indexOf(attr.name) === -1 && (nodeAttributes[attr.name] = attr.value);
  11076. });
  11077. if (nodeName === 'a' && !node.querySelectorAll('img').length) {
  11078. var href = node.getAttribute('href');
  11079. var _target = node.getAttribute('target');
  11080. return createEntity('LINK', 'MUTABLE', { href: href, target: _target, nodeAttributes: nodeAttributes });
  11081. } else if (nodeName === 'audio') {
  11082. return createEntity('AUDIO', 'IMMUTABLE', { url: node.getAttribute('src'), meta: meta, nodeAttributes: nodeAttributes });
  11083. } else if (nodeName === 'video') {
  11084. return createEntity('VIDEO', 'IMMUTABLE', { url: node.getAttribute('src'), meta: meta, nodeAttributes: nodeAttributes });
  11085. } else if (nodeName === 'img') {
  11086. var parentNode = node.parentNode;
  11087. var entityData = { meta: meta };
  11088. var _node$style = node.style,
  11089. width = _node$style.width,
  11090. height = _node$style.height;
  11091. entityData.url = node.getAttribute('src');
  11092. width && (entityData.width = width);
  11093. height && (entityData.height = height);
  11094. if (parentNode.nodeName.toLowerCase() === 'a') {
  11095. entityData.link = parentNode.getAttribute('href');
  11096. entityData.link_target = parentNode.getAttribute('target');
  11097. }
  11098. return createEntity('IMAGE', 'IMMUTABLE', entityData);
  11099. } else if (nodeName === 'hr') {
  11100. return createEntity('HR', 'IMMUTABLE', {});
  11101. } else if (node.parentNode && node.parentNode.classList.contains('embed-wrap')) {
  11102. var embedContent = node.innerHTML || node.outerHTML;
  11103. if (embedContent) {
  11104. return createEntity('EMBED', 'IMMUTABLE', {
  11105. url: embedContent
  11106. });
  11107. }
  11108. }
  11109. };
  11110. };
  11111. var htmlToBlock = function htmlToBlock(options, source) {
  11112. return function (nodeName, node) {
  11113. if (options && options.blockImportFn) {
  11114. var customInput = options.blockImportFn(nodeName, node, source);
  11115. if (customInput) {
  11116. return customInput;
  11117. }
  11118. }
  11119. var nodeAttributes = {};
  11120. var nodeStyle = node.style || {};
  11121. node.attributes && Object.keys(node.attributes).forEach(function (key) {
  11122. var attr = node.attributes[key];
  11123. ignoredNodeAttributes.indexOf(attr.name) === -1 && (nodeAttributes[attr.name] = attr.value);
  11124. });
  11125. if (node.classList && node.classList.contains('media-wrap')) {
  11126. return {
  11127. type: 'atomic',
  11128. data: {
  11129. nodeAttributes: nodeAttributes,
  11130. float: nodeStyle.float,
  11131. alignment: nodeStyle.textAlign
  11132. }
  11133. };
  11134. } else if (nodeName === 'img') {
  11135. return {
  11136. type: 'atomic',
  11137. data: {
  11138. nodeAttributes: nodeAttributes,
  11139. float: nodeStyle.float,
  11140. alignment: nodeStyle.textAlign
  11141. }
  11142. };
  11143. } else if (nodeName === 'hr') {
  11144. return {
  11145. type: 'atomic',
  11146. data: { nodeAttributes: nodeAttributes }
  11147. };
  11148. } else if (nodeName === 'pre') {
  11149. node.innerHTML = node.innerHTML.replace(/<code(.*?)>/g, '').replace(/<\/code>/g, '');
  11150. return {
  11151. type: 'code-block',
  11152. data: { nodeAttributes: nodeAttributes }
  11153. };
  11154. } else if (blockNames.indexOf(nodeName) !== -1) {
  11155. var blockData = { nodeAttributes: nodeAttributes };
  11156. if (nodeStyle.textAlign) {
  11157. blockData.textAlign = nodeStyle.textAlign;
  11158. }
  11159. if (nodeStyle.textIndent) {
  11160. blockData.textIndent = /^\d+em$/.test(nodeStyle.textIndent) ? Math.ceil(parseInt(nodeStyle.textIndent, 10) / 2) : 1;
  11161. }
  11162. return {
  11163. type: blockTypes[blockNames.indexOf(nodeName)],
  11164. data: blockData
  11165. };
  11166. }
  11167. };
  11168. };
  11169. var getToHTMLConfig = exports.getToHTMLConfig = function getToHTMLConfig(options) {
  11170. return {
  11171. styleToHTML: styleToHTML(options),
  11172. entityToHTML: entityToHTML(options),
  11173. blockToHTML: blockToHTML(options)
  11174. };
  11175. };
  11176. var getFromHTMLConfig = exports.getFromHTMLConfig = function getFromHTMLConfig(options) {
  11177. var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unknow';
  11178. return {
  11179. htmlToStyle: htmlToStyle(options, source),
  11180. htmlToEntity: htmlToEntity(options, source),
  11181. htmlToBlock: htmlToBlock(options, source)
  11182. };
  11183. };
  11184. });
  11185. _commonjsHelpers.unwrapExports(configs);
  11186. var configs_1 = configs.getFromHTMLConfig;
  11187. var configs_2 = configs.getToHTMLConfig;
  11188. var configs_3 = configs.blocks;
  11189. var configs_4 = configs.getHexColor;
  11190. var configs_5 = configs.defaultFontFamilies;
  11191. var configs_6 = configs.namedColors;
  11192. var dist = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11193. Object.defineProperty(exports, "__esModule", {
  11194. value: true
  11195. });
  11196. exports.convertRawToEditorState = exports.convertEditorStateToRaw = exports.convertHTMLToEditorState = exports.convertEditorStateToHTML = exports.convertHTMLToRaw = exports.convertRawToHTML = undefined;
  11197. 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; };
  11198. var defaultConvertOptions = {
  11199. fontFamilies: configs.defaultFontFamilies
  11200. };
  11201. var convertRawToHTML = exports.convertRawToHTML = function convertRawToHTML(rawContent, options) {
  11202. options = _extends({}, defaultConvertOptions, options);
  11203. try {
  11204. var contentState = (0, Draft.Draft.convertFromRaw)(rawContent);
  11205. options.contentState = contentState;
  11206. return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(contentState);
  11207. } catch (error) {
  11208. console.warn(error);
  11209. return '';
  11210. }
  11211. };
  11212. var convertHTMLToRaw = exports.convertHTMLToRaw = function convertHTMLToRaw(HTMLString, options, source) {
  11213. options = _extends({}, defaultConvertOptions, options);
  11214. try {
  11215. var contentState = (0, lib.convertFromHTML)((0, configs.getFromHTMLConfig)(options, source))(HTMLString);
  11216. return (0, Draft.Draft.convertToRaw)(contentState);
  11217. } catch (error) {
  11218. console.warn(error);
  11219. return {};
  11220. }
  11221. };
  11222. var convertEditorStateToHTML = exports.convertEditorStateToHTML = function convertEditorStateToHTML(editorState, options) {
  11223. options = _extends({}, defaultConvertOptions, options);
  11224. try {
  11225. var contentState = editorState.getCurrentContent();
  11226. options.contentState = contentState;
  11227. return (0, lib.convertToHTML)((0, configs.getToHTMLConfig)(options))(contentState);
  11228. } catch (error) {
  11229. console.warn(error);
  11230. return '';
  11231. }
  11232. };
  11233. var convertHTMLToEditorState = exports.convertHTMLToEditorState = function convertHTMLToEditorState(HTMLString, editorDecorators, options, source) {
  11234. options = _extends({}, defaultConvertOptions, options);
  11235. try {
  11236. return Draft.Draft.EditorState.createWithContent((0, lib.convertFromHTML)((0, configs.getFromHTMLConfig)(options, source))(HTMLString), editorDecorators);
  11237. } catch (error) {
  11238. console.warn(error);
  11239. return Draft.Draft.EditorState.createEmpty(editorDecorators);
  11240. }
  11241. };
  11242. var convertEditorStateToRaw = exports.convertEditorStateToRaw = function convertEditorStateToRaw(editorState) {
  11243. return (0, Draft.Draft.convertToRaw)(editorState.getCurrentContent());
  11244. };
  11245. var convertRawToEditorState = exports.convertRawToEditorState = function convertRawToEditorState(rawContent, editorDecorators) {
  11246. try {
  11247. return Draft.Draft.EditorState.createWithContent((0, Draft.Draft.convertFromRaw)(rawContent), editorDecorators);
  11248. } catch (error) {
  11249. console.warn(error);
  11250. return Draft.Draft.EditorState.createEmpty(editorDecorators);
  11251. }
  11252. };
  11253. });
  11254. _commonjsHelpers.unwrapExports(dist);
  11255. var dist_1 = dist.convertRawToEditorState;
  11256. var dist_2 = dist.convertEditorStateToRaw;
  11257. var dist_3 = dist.convertHTMLToEditorState;
  11258. var dist_4 = dist.convertEditorStateToHTML;
  11259. var dist_5 = dist.convertHTMLToRaw;
  11260. var dist_6 = dist.convertRawToHTML;
  11261. var content = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11262. Object.defineProperty(exports, "__esModule", {
  11263. value: true
  11264. });
  11265. 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;
  11266. var _immutable2 = _interopRequireDefault(immutable);
  11267. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11268. var strictBlockTypes = ['atomic'];
  11269. var registerStrictBlockType = exports.registerStrictBlockType = function registerStrictBlockType(blockType) {
  11270. strictBlockTypes.indexOf(blockType) === -1 && strictBlockTypes.push(blockType);
  11271. };
  11272. var isEditorState = exports.isEditorState = function isEditorState(editorState) {
  11273. return editorState instanceof Draft.Draft.EditorState;
  11274. };
  11275. var createEmptyEditorState = exports.createEmptyEditorState = function createEmptyEditorState(editorDecorators) {
  11276. return Draft.Draft.EditorState.createEmpty(editorDecorators);
  11277. };
  11278. var createEditorState = exports.createEditorState = function createEditorState(contentState, editorDecorators) {
  11279. return Draft.Draft.EditorState.createWithContent(contentState, editorDecorators);
  11280. };
  11281. var isSelectionCollapsed = exports.isSelectionCollapsed = function isSelectionCollapsed(editorState) {
  11282. return editorState.getSelection().isCollapsed();
  11283. };
  11284. var selectionContainsBlockType = exports.selectionContainsBlockType = function selectionContainsBlockType(editorState, blockType) {
  11285. return getSelectedBlocks(editorState).find(function (block) {
  11286. return block.getType() === blockType;
  11287. });
  11288. };
  11289. var selectionContainsStrictBlock = exports.selectionContainsStrictBlock = function selectionContainsStrictBlock(editorState) {
  11290. return getSelectedBlocks(editorState).find(function (block) {
  11291. return ~strictBlockTypes.indexOf(block.getType());
  11292. });
  11293. };
  11294. var selectBlock = exports.selectBlock = function selectBlock(editorState, block) {
  11295. var blockKey = block.getKey();
  11296. return Draft.Draft.EditorState.forceSelection(editorState, new Draft.Draft.SelectionState({
  11297. anchorKey: blockKey,
  11298. anchorOffset: 0,
  11299. focusKey: blockKey,
  11300. focusOffset: block.getLength()
  11301. }));
  11302. };
  11303. var selectNextBlock = exports.selectNextBlock = function selectNextBlock(editorState, block) {
  11304. var nextBlock = editorState.getCurrentContent().getBlockAfter(block.getKey());
  11305. return nextBlock ? selectBlock(editorState, nextBlock) : editorState;
  11306. };
  11307. var removeBlock = exports.removeBlock = function removeBlock(editorState, block) {
  11308. var lastSelection = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  11309. var nextContentState = void 0,
  11310. nextEditorState = void 0;
  11311. var blockKey = block.getKey();
  11312. nextContentState = Draft.Draft.Modifier.removeRange(editorState.getCurrentContent(), new Draft.Draft.SelectionState({
  11313. anchorKey: blockKey,
  11314. anchorOffset: 0,
  11315. focusKey: blockKey,
  11316. focusOffset: block.getLength()
  11317. }), 'backward');
  11318. nextContentState = Draft.Draft.Modifier.setBlockType(nextContentState, nextContentState.getSelectionAfter(), 'unstyled');
  11319. nextEditorState = Draft.Draft.EditorState.push(editorState, nextContentState, 'remove-range');
  11320. return Draft.Draft.EditorState.forceSelection(nextEditorState, lastSelection || nextContentState.getSelectionAfter());
  11321. };
  11322. var getSelectionBlock = exports.getSelectionBlock = function getSelectionBlock(editorState) {
  11323. return editorState.getCurrentContent().getBlockForKey(editorState.getSelection().getAnchorKey());
  11324. };
  11325. var updateEachCharacterOfSelection = exports.updateEachCharacterOfSelection = function updateEachCharacterOfSelection(editorState, callback) {
  11326. var selectionState = editorState.getSelection();
  11327. var contentState = editorState.getCurrentContent();
  11328. var contentBlocks = contentState.getBlockMap();
  11329. var selectedBlocks = getSelectedBlocks(editorState);
  11330. if (selectedBlocks.length === 0) {
  11331. return editorState;
  11332. }
  11333. var startKey = selectionState.getStartKey();
  11334. var startOffset = selectionState.getStartOffset();
  11335. var endKey = selectionState.getEndKey();
  11336. var endOffset = selectionState.getEndOffset();
  11337. var nextContentBlocks = contentBlocks.map(function (block) {
  11338. if (selectedBlocks.indexOf(block) === -1) {
  11339. return block;
  11340. }
  11341. var blockKey = block.getKey();
  11342. var charactersList = block.getCharacterList();
  11343. var nextCharactersList = null;
  11344. if (blockKey === startKey && blockKey === endKey) {
  11345. nextCharactersList = charactersList.map(function (character, index) {
  11346. if (index >= startOffset && index < endOffset) {
  11347. return callback(character);
  11348. }
  11349. return character;
  11350. });
  11351. } else if (blockKey === startKey) {
  11352. nextCharactersList = charactersList.map(function (character, index) {
  11353. if (index >= startOffset) {
  11354. return callback(character);
  11355. }
  11356. return character;
  11357. });
  11358. } else if (blockKey === endKey) {
  11359. nextCharactersList = charactersList.map(function (character, index) {
  11360. if (index < endOffset) {
  11361. return callback(character);
  11362. }
  11363. return character;
  11364. });
  11365. } else {
  11366. nextCharactersList = charactersList.map(function (character) {
  11367. return callback(character);
  11368. });
  11369. }
  11370. return block.merge({
  11371. 'characterList': nextCharactersList
  11372. });
  11373. });
  11374. return Draft.Draft.EditorState.push(editorState, contentState.merge({
  11375. blockMap: nextContentBlocks,
  11376. selectionBefore: selectionState,
  11377. selectionAfter: selectionState
  11378. }), 'update-selection-character-list');
  11379. };
  11380. var getSelectedBlocks = exports.getSelectedBlocks = function getSelectedBlocks(editorState) {
  11381. var selectionState = editorState.getSelection();
  11382. var contentState = editorState.getCurrentContent();
  11383. var startKey = selectionState.getStartKey();
  11384. var endKey = selectionState.getEndKey();
  11385. var isSameBlock = startKey === endKey;
  11386. var startingBlock = contentState.getBlockForKey(startKey);
  11387. var selectedBlocks = [startingBlock];
  11388. if (!isSameBlock) {
  11389. var blockKey = startKey;
  11390. while (blockKey !== endKey) {
  11391. var nextBlock = contentState.getBlockAfter(blockKey);
  11392. selectedBlocks.push(nextBlock);
  11393. blockKey = nextBlock.getKey();
  11394. }
  11395. }
  11396. return selectedBlocks;
  11397. };
  11398. var setSelectionBlockData = exports.setSelectionBlockData = function setSelectionBlockData(editorState, blockData, override) {
  11399. var newBlockData = override ? blockData : Object.assign({}, getSelectionBlockData(editorState).toJS(), blockData);
  11400. Object.keys(newBlockData).forEach(function (key) {
  11401. if (newBlockData.hasOwnProperty(key) && newBlockData[key] === undefined) {
  11402. delete newBlockData[key];
  11403. }
  11404. });
  11405. return (0, draftjsUtils.setBlockData)(editorState, newBlockData);
  11406. };
  11407. var getSelectionBlockData = exports.getSelectionBlockData = function getSelectionBlockData(editorState, name) {
  11408. var blockData = getSelectionBlock(editorState).getData();
  11409. return name ? blockData.get(name) : blockData;
  11410. };
  11411. var getSelectionBlockType = exports.getSelectionBlockType = function getSelectionBlockType(editorState) {
  11412. return getSelectionBlock(editorState).getType();
  11413. };
  11414. var getSelectionText = exports.getSelectionText = function getSelectionText(editorState) {
  11415. var selectionState = editorState.getSelection();
  11416. var contentState = editorState.getCurrentContent();
  11417. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  11418. return '';
  11419. }
  11420. var anchorKey = selectionState.getAnchorKey();
  11421. var currentContentBlock = contentState.getBlockForKey(anchorKey);
  11422. var start = selectionState.getStartOffset();
  11423. var end = selectionState.getEndOffset();
  11424. return currentContentBlock.getText().slice(start, end);
  11425. };
  11426. var toggleSelectionBlockType = exports.toggleSelectionBlockType = function toggleSelectionBlockType(editorState, blockType) {
  11427. if (selectionContainsStrictBlock(editorState)) {
  11428. return editorState;
  11429. }
  11430. return Draft.Draft.RichUtils.toggleBlockType(editorState, blockType);
  11431. };
  11432. var getSelectionEntityType = exports.getSelectionEntityType = function getSelectionEntityType(editorState) {
  11433. var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
  11434. if (entityKey) {
  11435. var entity = editorState.getCurrentContent().getEntity(entityKey);
  11436. return entity ? entity.get('type') : null;
  11437. }
  11438. return null;
  11439. };
  11440. var getSelectionEntityData = exports.getSelectionEntityData = function getSelectionEntityData(editorState, type) {
  11441. var entityKey = (0, draftjsUtils.getSelectionEntity)(editorState);
  11442. if (entityKey) {
  11443. var entity = editorState.getCurrentContent().getEntity(entityKey);
  11444. if (entity && entity.get('type') === type) {
  11445. return entity.getData();
  11446. } else {
  11447. return {};
  11448. }
  11449. } else {
  11450. return {};
  11451. }
  11452. };
  11453. var toggleSelectionEntity = exports.toggleSelectionEntity = function toggleSelectionEntity(editorState, entity) {
  11454. var contentState = editorState.getCurrentContent();
  11455. var selectionState = editorState.getSelection();
  11456. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  11457. return editorState;
  11458. }
  11459. if (!entity || !entity.type || getSelectionEntityType(editorState) === entity.type) {
  11460. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.applyEntity(contentState, selectionState, null), 'apply-entity');
  11461. }
  11462. try {
  11463. var nextContentState = contentState.createEntity(entity.type, entity.mutability, entity.data);
  11464. var entityKey = nextContentState.getLastCreatedEntityKey();
  11465. var nextEditorState = Draft.Draft.EditorState.set(editorState, {
  11466. currentContent: nextContentState
  11467. });
  11468. return Draft.Draft.EditorState.push(nextEditorState, Draft.Draft.Modifier.applyEntity(nextContentState, selectionState, entityKey), 'apply-entity');
  11469. } catch (error) {
  11470. console.warn(error);
  11471. return editorState;
  11472. }
  11473. };
  11474. var toggleSelectionLink = exports.toggleSelectionLink = function toggleSelectionLink(editorState, href, target) {
  11475. var contentState = editorState.getCurrentContent();
  11476. var selectionState = editorState.getSelection();
  11477. var entityData = { href: href, target: target };
  11478. if (selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  11479. return editorState;
  11480. }
  11481. if (href === false) {
  11482. return Draft.Draft.RichUtils.toggleLink(editorState, selectionState, null);
  11483. }
  11484. if (href === null) {
  11485. delete entityData.href;
  11486. }
  11487. try {
  11488. var nextContentState = contentState.createEntity('LINK', 'MUTABLE', entityData);
  11489. var entityKey = nextContentState.getLastCreatedEntityKey();
  11490. var nextEditorState = Draft.Draft.EditorState.set(editorState, {
  11491. currentContent: nextContentState
  11492. });
  11493. nextEditorState = Draft.Draft.RichUtils.toggleLink(nextEditorState, selectionState, entityKey);
  11494. nextEditorState = Draft.Draft.EditorState.forceSelection(nextEditorState, selectionState.merge({
  11495. anchorOffset: selectionState.getEndOffset(),
  11496. focusOffset: selectionState.getEndOffset()
  11497. }));
  11498. nextEditorState = Draft.Draft.EditorState.push(nextEditorState, Draft.Draft.Modifier.insertText(nextEditorState.getCurrentContent(), nextEditorState.getSelection(), ''), 'insert-text');
  11499. return nextEditorState;
  11500. } catch (error) {
  11501. console.warn(error);
  11502. return editorState;
  11503. }
  11504. };
  11505. var getSelectionInlineStyle = exports.getSelectionInlineStyle = function getSelectionInlineStyle(editorState) {
  11506. return editorState.getCurrentInlineStyle();
  11507. };
  11508. var selectionHasInlineStyle = exports.selectionHasInlineStyle = function selectionHasInlineStyle(editorState, style) {
  11509. return getSelectionInlineStyle(editorState).has(style.toUpperCase());
  11510. };
  11511. var toggleSelectionInlineStyle = exports.toggleSelectionInlineStyle = function toggleSelectionInlineStyle(editorState, style) {
  11512. var prefix = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '';
  11513. var nextEditorState = editorState;
  11514. style = prefix + style.toUpperCase();
  11515. if (prefix) {
  11516. nextEditorState = updateEachCharacterOfSelection(nextEditorState, function (characterMetadata) {
  11517. return characterMetadata.toJS().style.reduce(function (characterMetadata, characterStyle) {
  11518. if (characterStyle.indexOf(prefix) === 0 && style !== characterStyle) {
  11519. return Draft.Draft.CharacterMetadata.removeStyle(characterMetadata, characterStyle);
  11520. } else {
  11521. return characterMetadata;
  11522. }
  11523. }, characterMetadata);
  11524. });
  11525. }
  11526. return Draft.Draft.RichUtils.toggleInlineStyle(nextEditorState, style);
  11527. };
  11528. var removeSelectionInlineStyles = exports.removeSelectionInlineStyles = function removeSelectionInlineStyles(editorState) {
  11529. return updateEachCharacterOfSelection(editorState, function (characterMetadata) {
  11530. return characterMetadata.merge({
  11531. style: _immutable2.default.OrderedSet([])
  11532. });
  11533. });
  11534. };
  11535. var toggleSelectionAlignment = exports.toggleSelectionAlignment = function toggleSelectionAlignment(editorState, alignment) {
  11536. return setSelectionBlockData(editorState, {
  11537. textAlign: getSelectionBlockData(editorState, 'textAlign') !== alignment ? alignment : undefined
  11538. });
  11539. };
  11540. var toggleSelectionIndent = exports.toggleSelectionIndent = function toggleSelectionIndent(editorState, textIndent) {
  11541. var maxIndent = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 6;
  11542. return textIndent < 0 || textIndent > maxIndent || isNaN(textIndent) ? editorState : setSelectionBlockData(editorState, {
  11543. textIndent: textIndent || undefined
  11544. });
  11545. };
  11546. var increaseSelectionIndent = exports.increaseSelectionIndent = function increaseSelectionIndent(editorState) {
  11547. var maxIndent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 6;
  11548. var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
  11549. return toggleSelectionIndent(editorState, currentIndent + 1, maxIndent);
  11550. };
  11551. var decreaseSelectionIndent = exports.decreaseSelectionIndent = function decreaseSelectionIndent(editorState) {
  11552. var currentIndent = getSelectionBlockData(editorState, 'textIndent') || 0;
  11553. return toggleSelectionIndent(editorState, currentIndent - 1);
  11554. };
  11555. var toggleSelectionColor = exports.toggleSelectionColor = function toggleSelectionColor(editorState, color) {
  11556. return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'COLOR-');
  11557. };
  11558. var toggleSelectionBackgroundColor = exports.toggleSelectionBackgroundColor = function toggleSelectionBackgroundColor(editorState, color) {
  11559. return toggleSelectionInlineStyle(editorState, color.replace('#', ''), 'BGCOLOR-');
  11560. };
  11561. var toggleSelectionFontSize = exports.toggleSelectionFontSize = function toggleSelectionFontSize(editorState, fontSize) {
  11562. return toggleSelectionInlineStyle(editorState, fontSize, 'FONTSIZE-');
  11563. };
  11564. var toggleSelectionLineHeight = exports.toggleSelectionLineHeight = function toggleSelectionLineHeight(editorState, lineHeight) {
  11565. return toggleSelectionInlineStyle(editorState, lineHeight, 'LINEHEIGHT-');
  11566. };
  11567. var toggleSelectionFontFamily = exports.toggleSelectionFontFamily = function toggleSelectionFontFamily(editorState, fontFamily) {
  11568. return toggleSelectionInlineStyle(editorState, fontFamily, 'FONTFAMILY-');
  11569. };
  11570. var toggleSelectionLetterSpacing = exports.toggleSelectionLetterSpacing = function toggleSelectionLetterSpacing(editorState, letterSpacing) {
  11571. return toggleSelectionInlineStyle(editorState, letterSpacing, 'LETTERSPACING-');
  11572. };
  11573. var insertText = exports.insertText = function insertText(editorState, text, inlineStyle, entity) {
  11574. var selectionState = editorState.getSelection();
  11575. var currentSelectedBlockType = getSelectionBlockType(editorState);
  11576. if (currentSelectedBlockType === 'atomic') {
  11577. return editorState;
  11578. }
  11579. var entityKey = void 0;
  11580. var contentState = editorState.getCurrentContent();
  11581. if (entity && entity.type) {
  11582. contentState = contentState.createEntity(entity.type, entity.mutability || 'MUTABLE', entity.data || entityData);
  11583. entityKey = contentState.getLastCreatedEntityKey();
  11584. }
  11585. if (!selectionState.isCollapsed()) {
  11586. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.replaceText(contentState, selectionState, text, inlineStyle, entityKey), 'replace-text');
  11587. } else {
  11588. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.insertText(contentState, selectionState, text, inlineStyle, entityKey), 'insert-text');
  11589. }
  11590. };
  11591. var insertHTML = exports.insertHTML = function insertHTML(editorState, htmlString, source) {
  11592. if (!htmlString) {
  11593. return editorState;
  11594. }
  11595. var selectionState = editorState.getSelection();
  11596. var contentState = editorState.getCurrentContent();
  11597. var options = editorState.convertOptions || {};
  11598. try {
  11599. var _convertFromRaw = (0, Draft.Draft.convertFromRaw)((0, dist.convertHTMLToRaw)(htmlString, options, source)),
  11600. blockMap = _convertFromRaw.blockMap;
  11601. return Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.replaceWithFragment(contentState, selectionState, blockMap), 'insert-fragment');
  11602. } catch (error) {
  11603. console.warn(error);
  11604. return editorState;
  11605. }
  11606. };
  11607. var insertAtomicBlock = exports.insertAtomicBlock = function insertAtomicBlock(editorState, type) {
  11608. var immutable = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
  11609. var data = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
  11610. if (selectionContainsStrictBlock(editorState)) {
  11611. return insertAtomicBlock(selectNextBlock(editorState, getSelectionBlock(editorState)), type, immutable, data);
  11612. }
  11613. var selectionState = editorState.getSelection();
  11614. var contentState = editorState.getCurrentContent();
  11615. if (!selectionState.isCollapsed() || getSelectionBlockType(editorState) === 'atomic') {
  11616. return editorState;
  11617. }
  11618. var contentStateWithEntity = contentState.createEntity(type, immutable ? 'IMMUTABLE' : 'MUTABLE', data);
  11619. var entityKey = contentStateWithEntity.getLastCreatedEntityKey();
  11620. var newEditorState = Draft.Draft.AtomicBlockUtils.insertAtomicBlock(editorState, entityKey, ' ');
  11621. return newEditorState;
  11622. };
  11623. var insertHorizontalLine = exports.insertHorizontalLine = function insertHorizontalLine(editorState) {
  11624. return insertAtomicBlock(editorState, 'HR');
  11625. };
  11626. var insertMedias = exports.insertMedias = function insertMedias(editorState) {
  11627. var medias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
  11628. if (!medias.length) {
  11629. return editorState;
  11630. }
  11631. return medias.reduce(function (editorState, media) {
  11632. var url = media.url,
  11633. link = media.link,
  11634. link_target = media.link_target,
  11635. name = media.name,
  11636. type = media.type,
  11637. width = media.width,
  11638. height = media.height,
  11639. meta = media.meta;
  11640. return insertAtomicBlock(editorState, type, true, { url: url, link: link, link_target: link_target, name: name, type: type, width: width, height: height, meta: meta });
  11641. }, editorState);
  11642. };
  11643. var setMediaData = exports.setMediaData = function setMediaData(editorState, entityKey, data) {
  11644. return Draft.Draft.EditorState.push(editorState, editorState.getCurrentContent().mergeEntityData(entityKey, data), 'change-block-data');
  11645. };
  11646. var removeMedia = exports.removeMedia = function removeMedia(editorState, mediaBlock) {
  11647. return removeBlock(editorState, mediaBlock);
  11648. };
  11649. var setMediaPosition = exports.setMediaPosition = function setMediaPosition(editorState, mediaBlock, position) {
  11650. var newPosition = {};
  11651. var float = position.float,
  11652. alignment = position.alignment;
  11653. if (typeof float !== 'undefined') {
  11654. newPosition.float = mediaBlock.getData().get('float') === float ? null : float;
  11655. }
  11656. if (typeof alignment !== 'undefined') {
  11657. newPosition.alignment = mediaBlock.getData().get('alignment') === alignment ? null : alignment;
  11658. }
  11659. return setSelectionBlockData(selectBlock(editorState, mediaBlock), newPosition);
  11660. };
  11661. var clear = exports.clear = function clear(editorState) {
  11662. var contentState = editorState.getCurrentContent();
  11663. var firstBlock = contentState.getFirstBlock();
  11664. var lastBlock = contentState.getLastBlock();
  11665. var allSelected = new Draft.Draft.SelectionState({
  11666. anchorKey: firstBlock.getKey(),
  11667. anchorOffset: 0,
  11668. focusKey: lastBlock.getKey(),
  11669. focusOffset: lastBlock.getLength(),
  11670. hasFocus: true
  11671. });
  11672. return Draft.Draft.RichUtils.toggleBlockType(Draft.Draft.EditorState.push(editorState, Draft.Draft.Modifier.removeRange(contentState, allSelected, 'backward'), 'remove-range'), 'unstyled');
  11673. };
  11674. var handleKeyCommand = exports.handleKeyCommand = function handleKeyCommand(editorState, command) {
  11675. return Draft.Draft.RichUtils.handleKeyCommand(editorState, command);
  11676. };
  11677. var undo = exports.undo = function undo(editorState) {
  11678. return Draft.Draft.EditorState.undo(editorState);
  11679. };
  11680. var redo = exports.redo = function redo(editorState) {
  11681. return Draft.Draft.EditorState.redo(editorState);
  11682. };
  11683. });
  11684. _commonjsHelpers.unwrapExports(content);
  11685. var content_1 = content.redo;
  11686. var content_2 = content.undo;
  11687. var content_3 = content.handleKeyCommand;
  11688. var content_4 = content.clear;
  11689. var content_5 = content.setMediaPosition;
  11690. var content_6 = content.removeMedia;
  11691. var content_7 = content.setMediaData;
  11692. var content_8 = content.insertMedias;
  11693. var content_9 = content.insertHorizontalLine;
  11694. var content_10 = content.insertAtomicBlock;
  11695. var content_11 = content.insertHTML;
  11696. var content_12 = content.insertText;
  11697. var content_13 = content.toggleSelectionLetterSpacing;
  11698. var content_14 = content.toggleSelectionFontFamily;
  11699. var content_15 = content.toggleSelectionLineHeight;
  11700. var content_16 = content.toggleSelectionFontSize;
  11701. var content_17 = content.toggleSelectionBackgroundColor;
  11702. var content_18 = content.toggleSelectionColor;
  11703. var content_19 = content.decreaseSelectionIndent;
  11704. var content_20 = content.increaseSelectionIndent;
  11705. var content_21 = content.toggleSelectionIndent;
  11706. var content_22 = content.toggleSelectionAlignment;
  11707. var content_23 = content.removeSelectionInlineStyles;
  11708. var content_24 = content.toggleSelectionInlineStyle;
  11709. var content_25 = content.selectionHasInlineStyle;
  11710. var content_26 = content.getSelectionInlineStyle;
  11711. var content_27 = content.toggleSelectionLink;
  11712. var content_28 = content.toggleSelectionEntity;
  11713. var content_29 = content.getSelectionEntityData;
  11714. var content_30 = content.getSelectionEntityType;
  11715. var content_31 = content.toggleSelectionBlockType;
  11716. var content_32 = content.getSelectionText;
  11717. var content_33 = content.getSelectionBlockType;
  11718. var content_34 = content.getSelectionBlockData;
  11719. var content_35 = content.setSelectionBlockData;
  11720. var content_36 = content.getSelectedBlocks;
  11721. var content_37 = content.updateEachCharacterOfSelection;
  11722. var content_38 = content.getSelectionBlock;
  11723. var content_39 = content.removeBlock;
  11724. var content_40 = content.selectNextBlock;
  11725. var content_41 = content.selectBlock;
  11726. var content_42 = content.selectionContainsStrictBlock;
  11727. var content_43 = content.selectionContainsBlockType;
  11728. var content_44 = content.isSelectionCollapsed;
  11729. var content_45 = content.createEditorState;
  11730. var content_46 = content.createEmptyEditorState;
  11731. var content_47 = content.isEditorState;
  11732. var content_48 = content.registerStrictBlockType;
  11733. var base = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11734. Object.defineProperty(exports, "__esModule", {
  11735. value: true
  11736. });
  11737. var braftUniqueIndex = 0;
  11738. var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
  11739. return braftUniqueIndex += 1;
  11740. };
  11741. });
  11742. _commonjsHelpers.unwrapExports(base);
  11743. var base_1 = base.UniqueIndex;
  11744. var color = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11745. Object.defineProperty(exports, "__esModule", {
  11746. value: true
  11747. });
  11748. var _namedColors = {
  11749. "aliceblue": "#f0f8ff",
  11750. "antiquewhite": "#faebd7",
  11751. "aqua": "#00ffff",
  11752. "aquamarine": "#7fffd4",
  11753. "azure": "#f0ffff",
  11754. "beige": "#f5f5dc",
  11755. "bisque": "#ffe4c4",
  11756. "black": "#000000",
  11757. "blanchedalmond": "#ffebcd",
  11758. "blue": "#0000ff",
  11759. "blueviolet": "#8a2be2",
  11760. "brown": "#a52a2a",
  11761. "burlywood": "#deb887",
  11762. "cadetblue": "#5f9ea0",
  11763. "chartreuse": "#7fff00",
  11764. "chocolate": "#d2691e",
  11765. "coral": "#ff7f50",
  11766. "cornflowerblue": "#6495ed",
  11767. "cornsilk": "#fff8dc",
  11768. "crimson": "#dc143c",
  11769. "cyan": "#00ffff",
  11770. "darkblue": "#00008b",
  11771. "darkcyan": "#008b8b",
  11772. "darkgoldenrod": "#b8860b",
  11773. "darkgray": "#a9a9a9",
  11774. "darkgreen": "#006400",
  11775. "darkkhaki": "#bdb76b",
  11776. "darkmagenta": "#8b008b",
  11777. "darkolivegreen": "#556b2f",
  11778. "darkorange": "#ff8c00",
  11779. "darkorchid": "#9932cc",
  11780. "darkred": "#8b0000",
  11781. "darksalmon": "#e9967a",
  11782. "darkseagreen": "#8fbc8f",
  11783. "darkslateblue": "#483d8b",
  11784. "darkslategray": "#2f4f4f",
  11785. "darkturquoise": "#00ced1",
  11786. "darkviolet": "#9400d3",
  11787. "deeppink": "#ff1493",
  11788. "deepskyblue": "#00bfff",
  11789. "dimgray": "#696969",
  11790. "dodgerblue": "#1e90ff",
  11791. "firebrick": "#b22222",
  11792. "floralwhite": "#fffaf0",
  11793. "forestgreen": "#228b22",
  11794. "fuchsia": "#ff00ff",
  11795. "gainsboro": "#dcdcdc",
  11796. "ghostwhite": "#f8f8ff",
  11797. "gold": "#ffd700",
  11798. "goldenrod": "#daa520",
  11799. "gray": "#808080",
  11800. "green": "#008000",
  11801. "greenyellow": "#adff2f",
  11802. "honeydew": "#f0fff0",
  11803. "hotpink": "#ff69b4",
  11804. "indianred ": "#cd5c5c",
  11805. "indigo": "#4b0082",
  11806. "ivory": "#fffff0",
  11807. "khaki": "#f0e68c",
  11808. "lavender": "#e6e6fa",
  11809. "lavenderblush": "#fff0f5",
  11810. "lawngreen": "#7cfc00",
  11811. "lemonchiffon": "#fffacd",
  11812. "lightblue": "#add8e6",
  11813. "lightcoral": "#f08080",
  11814. "lightcyan": "#e0ffff",
  11815. "lightgoldenrodyellow": "#fafad2",
  11816. "lightgrey": "#d3d3d3",
  11817. "lightgreen": "#90ee90",
  11818. "lightpink": "#ffb6c1",
  11819. "lightsalmon": "#ffa07a",
  11820. "lightseagreen": "#20b2aa",
  11821. "lightskyblue": "#87cefa",
  11822. "lightslategray": "#778899",
  11823. "lightsteelblue": "#b0c4de",
  11824. "lightyellow": "#ffffe0",
  11825. "lime": "#00ff00",
  11826. "limegreen": "#32cd32",
  11827. "linen": "#faf0e6",
  11828. "magenta": "#ff00ff",
  11829. "maroon": "#800000",
  11830. "mediumaquamarine": "#66cdaa",
  11831. "mediumblue": "#0000cd",
  11832. "mediumorchid": "#ba55d3",
  11833. "mediumpurple": "#9370d8",
  11834. "mediumseagreen": "#3cb371",
  11835. "mediumslateblue": "#7b68ee",
  11836. "mediumspringgreen": "#00fa9a",
  11837. "mediumturquoise": "#48d1cc",
  11838. "mediumvioletred": "#c71585",
  11839. "midnightblue": "#191970",
  11840. "mintcream": "#f5fffa",
  11841. "mistyrose": "#ffe4e1",
  11842. "moccasin": "#ffe4b5",
  11843. "navajowhite": "#ffdead",
  11844. "navy": "#000080",
  11845. "oldlace": "#fdf5e6",
  11846. "olive": "#808000",
  11847. "olivedrab": "#6b8e23",
  11848. "orange": "#ffa500",
  11849. "orangered": "#ff4500",
  11850. "orchid": "#da70d6",
  11851. "palegoldenrod": "#eee8aa",
  11852. "palegreen": "#98fb98",
  11853. "paleturquoise": "#afeeee",
  11854. "palevioletred": "#d87093",
  11855. "papayawhip": "#ffefd5",
  11856. "peachpuff": "#ffdab9",
  11857. "peru": "#cd853f",
  11858. "pink": "#ffc0cb",
  11859. "plum": "#dda0dd",
  11860. "powderblue": "#b0e0e6",
  11861. "purple": "#800080",
  11862. "rebeccapurple": "#663399",
  11863. "red": "#ff0000",
  11864. "rosybrown": "#bc8f8f",
  11865. "royalblue": "#4169e1",
  11866. "saddlebrown": "#8b4513",
  11867. "salmon": "#fa8072",
  11868. "sandybrown": "#f4a460",
  11869. "seagreen": "#2e8b57",
  11870. "seashell": "#fff5ee",
  11871. "sienna": "#a0522d",
  11872. "silver": "#c0c0c0",
  11873. "skyblue": "#87ceeb",
  11874. "slateblue": "#6a5acd",
  11875. "slategray": "#708090",
  11876. "snow": "#fffafa",
  11877. "springgreen": "#00ff7f",
  11878. "steelblue": "#4682b4",
  11879. "tan": "#d2b48c",
  11880. "teal": "#008080",
  11881. "thistle": "#d8bfd8",
  11882. "tomato": "#ff6347",
  11883. "turquoise": "#40e0d0",
  11884. "violet": "#ee82ee",
  11885. "wheat": "#f5deb3",
  11886. "white": "#ffffff",
  11887. "whitesmoke": "#f5f5f5",
  11888. "yellow": "#ffff00",
  11889. "yellowgreen": "#9acd32"
  11890. };
  11891. var _getHexColor = function _getHexColor(color) {
  11892. color = color.replace('color:', '').replace(';', '').replace(' ', '');
  11893. if (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(color)) {
  11894. return color;
  11895. } else if (namedColors[color]) {
  11896. return namedColors[color];
  11897. } else if (color.indexOf('rgb') === 0) {
  11898. var rgbArray = color.split(',');
  11899. var convertedColor = rgbArray.length < 3 ? null : '#' + [rgbArray[0], rgbArray[1], rgbArray[2]].map(function (x) {
  11900. var hex = parseInt(x.replace(/\D/g, ''), 10).toString(16);
  11901. return hex.length === 1 ? '0' + hex : hex;
  11902. }).join('');
  11903. return (/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/.test(convertedColor) ? convertedColor : null
  11904. );
  11905. } else {
  11906. return null;
  11907. }
  11908. };
  11909. var namedColors = exports.namedColors = _namedColors;
  11910. var getHexColor = exports.getHexColor = _getHexColor;
  11911. var detectColorsFromHTMLString = exports.detectColorsFromHTMLString = function detectColorsFromHTMLString(html) {
  11912. return typeof html !== 'string' ? [] : (html.match(/color:[^;]{3,24};/g) || []).map(getHexColor).filter(function (color) {
  11913. return color;
  11914. });
  11915. };
  11916. var detectColorsFromDraftState = exports.detectColorsFromDraftState = function detectColorsFromDraftState(draftState) {
  11917. var result = [];
  11918. if (!draftState || !draftState.blocks || !draftState.blocks.length) {
  11919. return result;
  11920. }
  11921. draftState.blocks.forEach(function (block) {
  11922. if (block && block.inlineStyleRanges && block.inlineStyleRanges.length) {
  11923. block.inlineStyleRanges.forEach(function (inlineStyle) {
  11924. if (inlineStyle.style && inlineStyle.style.indexOf('COLOR-') >= 0) {
  11925. result.push('#' + inlineStyle.style.split('COLOR-')[1]);
  11926. }
  11927. });
  11928. }
  11929. });
  11930. return result.filter(function (color) {
  11931. return color;
  11932. });
  11933. };
  11934. });
  11935. _commonjsHelpers.unwrapExports(color);
  11936. var color_1 = color.namedColors;
  11937. var color_2 = color.getHexColor;
  11938. var color_3 = color.detectColorsFromHTMLString;
  11939. var color_4 = color.detectColorsFromDraftState;
  11940. var dist$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11941. Object.defineProperty(exports, "__esModule", {
  11942. value: true
  11943. });
  11944. exports.ColorUtils = exports.BaseUtils = exports.ContentUtils = undefined;
  11945. var _ContentUtils = _interopRequireWildcard(content);
  11946. var _BaseUtils = _interopRequireWildcard(base);
  11947. var _ColorUtils = _interopRequireWildcard(color);
  11948. 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; } }
  11949. var ContentUtils = exports.ContentUtils = _ContentUtils;
  11950. var BaseUtils = exports.BaseUtils = _BaseUtils;
  11951. var ColorUtils = exports.ColorUtils = _ColorUtils;
  11952. });
  11953. _commonjsHelpers.unwrapExports(dist$1);
  11954. var dist_1$1 = dist$1.ColorUtils;
  11955. var dist_2$1 = dist$1.BaseUtils;
  11956. var dist_3$1 = dist$1.ContentUtils;
  11957. var immutable$2 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  11958. /**
  11959. * Copyright (c) 2014-2015, Facebook, Inc.
  11960. * All rights reserved.
  11961. *
  11962. * This source code is licensed under the BSD-style license found in the
  11963. * LICENSE file in the root directory of this source tree. An additional grant
  11964. * of patent rights can be found in the PATENTS file in the same directory.
  11965. */
  11966. (function (global, factory) {
  11967. module.exports = factory() ;
  11968. }(_commonjsHelpers.commonjsGlobal, function () {var SLICE$0 = Array.prototype.slice;
  11969. function createClass(ctor, superClass) {
  11970. if (superClass) {
  11971. ctor.prototype = Object.create(superClass.prototype);
  11972. }
  11973. ctor.prototype.constructor = ctor;
  11974. }
  11975. function Iterable(value) {
  11976. return isIterable(value) ? value : Seq(value);
  11977. }
  11978. createClass(KeyedIterable, Iterable);
  11979. function KeyedIterable(value) {
  11980. return isKeyed(value) ? value : KeyedSeq(value);
  11981. }
  11982. createClass(IndexedIterable, Iterable);
  11983. function IndexedIterable(value) {
  11984. return isIndexed(value) ? value : IndexedSeq(value);
  11985. }
  11986. createClass(SetIterable, Iterable);
  11987. function SetIterable(value) {
  11988. return isIterable(value) && !isAssociative(value) ? value : SetSeq(value);
  11989. }
  11990. function isIterable(maybeIterable) {
  11991. return !!(maybeIterable && maybeIterable[IS_ITERABLE_SENTINEL]);
  11992. }
  11993. function isKeyed(maybeKeyed) {
  11994. return !!(maybeKeyed && maybeKeyed[IS_KEYED_SENTINEL]);
  11995. }
  11996. function isIndexed(maybeIndexed) {
  11997. return !!(maybeIndexed && maybeIndexed[IS_INDEXED_SENTINEL]);
  11998. }
  11999. function isAssociative(maybeAssociative) {
  12000. return isKeyed(maybeAssociative) || isIndexed(maybeAssociative);
  12001. }
  12002. function isOrdered(maybeOrdered) {
  12003. return !!(maybeOrdered && maybeOrdered[IS_ORDERED_SENTINEL]);
  12004. }
  12005. Iterable.isIterable = isIterable;
  12006. Iterable.isKeyed = isKeyed;
  12007. Iterable.isIndexed = isIndexed;
  12008. Iterable.isAssociative = isAssociative;
  12009. Iterable.isOrdered = isOrdered;
  12010. Iterable.Keyed = KeyedIterable;
  12011. Iterable.Indexed = IndexedIterable;
  12012. Iterable.Set = SetIterable;
  12013. var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  12014. var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  12015. var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  12016. var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  12017. // Used for setting prototype methods that IE8 chokes on.
  12018. var DELETE = 'delete';
  12019. // Constants describing the size of trie nodes.
  12020. var SHIFT = 5; // Resulted in best performance after ______?
  12021. var SIZE = 1 << SHIFT;
  12022. var MASK = SIZE - 1;
  12023. // A consistent shared value representing "not set" which equals nothing other
  12024. // than itself, and nothing that could be provided externally.
  12025. var NOT_SET = {};
  12026. // Boolean references, Rough equivalent of `bool &`.
  12027. var CHANGE_LENGTH = { value: false };
  12028. var DID_ALTER = { value: false };
  12029. function MakeRef(ref) {
  12030. ref.value = false;
  12031. return ref;
  12032. }
  12033. function SetRef(ref) {
  12034. ref && (ref.value = true);
  12035. }
  12036. // A function which returns a value representing an "owner" for transient writes
  12037. // to tries. The return value will only ever equal itself, and will not equal
  12038. // the return of any subsequent call of this function.
  12039. function OwnerID() {}
  12040. // http://jsperf.com/copy-array-inline
  12041. function arrCopy(arr, offset) {
  12042. offset = offset || 0;
  12043. var len = Math.max(0, arr.length - offset);
  12044. var newArr = new Array(len);
  12045. for (var ii = 0; ii < len; ii++) {
  12046. newArr[ii] = arr[ii + offset];
  12047. }
  12048. return newArr;
  12049. }
  12050. function ensureSize(iter) {
  12051. if (iter.size === undefined) {
  12052. iter.size = iter.__iterate(returnTrue);
  12053. }
  12054. return iter.size;
  12055. }
  12056. function wrapIndex(iter, index) {
  12057. // This implements "is array index" which the ECMAString spec defines as:
  12058. //
  12059. // A String property name P is an array index if and only if
  12060. // ToString(ToUint32(P)) is equal to P and ToUint32(P) is not equal
  12061. // to 2^32−1.
  12062. //
  12063. // http://www.ecma-international.org/ecma-262/6.0/#sec-array-exotic-objects
  12064. if (typeof index !== 'number') {
  12065. var uint32Index = index >>> 0; // N >>> 0 is shorthand for ToUint32
  12066. if ('' + uint32Index !== index || uint32Index === 4294967295) {
  12067. return NaN;
  12068. }
  12069. index = uint32Index;
  12070. }
  12071. return index < 0 ? ensureSize(iter) + index : index;
  12072. }
  12073. function returnTrue() {
  12074. return true;
  12075. }
  12076. function wholeSlice(begin, end, size) {
  12077. return (begin === 0 || (size !== undefined && begin <= -size)) &&
  12078. (end === undefined || (size !== undefined && end >= size));
  12079. }
  12080. function resolveBegin(begin, size) {
  12081. return resolveIndex(begin, size, 0);
  12082. }
  12083. function resolveEnd(end, size) {
  12084. return resolveIndex(end, size, size);
  12085. }
  12086. function resolveIndex(index, size, defaultIndex) {
  12087. return index === undefined ?
  12088. defaultIndex :
  12089. index < 0 ?
  12090. Math.max(0, size + index) :
  12091. size === undefined ?
  12092. index :
  12093. Math.min(size, index);
  12094. }
  12095. /* global Symbol */
  12096. var ITERATE_KEYS = 0;
  12097. var ITERATE_VALUES = 1;
  12098. var ITERATE_ENTRIES = 2;
  12099. var REAL_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
  12100. var FAUX_ITERATOR_SYMBOL = '@@iterator';
  12101. var ITERATOR_SYMBOL = REAL_ITERATOR_SYMBOL || FAUX_ITERATOR_SYMBOL;
  12102. function Iterator(next) {
  12103. this.next = next;
  12104. }
  12105. Iterator.prototype.toString = function() {
  12106. return '[Iterator]';
  12107. };
  12108. Iterator.KEYS = ITERATE_KEYS;
  12109. Iterator.VALUES = ITERATE_VALUES;
  12110. Iterator.ENTRIES = ITERATE_ENTRIES;
  12111. Iterator.prototype.inspect =
  12112. Iterator.prototype.toSource = function () { return this.toString(); };
  12113. Iterator.prototype[ITERATOR_SYMBOL] = function () {
  12114. return this;
  12115. };
  12116. function iteratorValue(type, k, v, iteratorResult) {
  12117. var value = type === 0 ? k : type === 1 ? v : [k, v];
  12118. iteratorResult ? (iteratorResult.value = value) : (iteratorResult = {
  12119. value: value, done: false
  12120. });
  12121. return iteratorResult;
  12122. }
  12123. function iteratorDone() {
  12124. return { value: undefined, done: true };
  12125. }
  12126. function hasIterator(maybeIterable) {
  12127. return !!getIteratorFn(maybeIterable);
  12128. }
  12129. function isIterator(maybeIterator) {
  12130. return maybeIterator && typeof maybeIterator.next === 'function';
  12131. }
  12132. function getIterator(iterable) {
  12133. var iteratorFn = getIteratorFn(iterable);
  12134. return iteratorFn && iteratorFn.call(iterable);
  12135. }
  12136. function getIteratorFn(iterable) {
  12137. var iteratorFn = iterable && (
  12138. (REAL_ITERATOR_SYMBOL && iterable[REAL_ITERATOR_SYMBOL]) ||
  12139. iterable[FAUX_ITERATOR_SYMBOL]
  12140. );
  12141. if (typeof iteratorFn === 'function') {
  12142. return iteratorFn;
  12143. }
  12144. }
  12145. function isArrayLike(value) {
  12146. return value && typeof value.length === 'number';
  12147. }
  12148. createClass(Seq, Iterable);
  12149. function Seq(value) {
  12150. return value === null || value === undefined ? emptySequence() :
  12151. isIterable(value) ? value.toSeq() : seqFromValue(value);
  12152. }
  12153. Seq.of = function(/*...values*/) {
  12154. return Seq(arguments);
  12155. };
  12156. Seq.prototype.toSeq = function() {
  12157. return this;
  12158. };
  12159. Seq.prototype.toString = function() {
  12160. return this.__toString('Seq {', '}');
  12161. };
  12162. Seq.prototype.cacheResult = function() {
  12163. if (!this._cache && this.__iterateUncached) {
  12164. this._cache = this.entrySeq().toArray();
  12165. this.size = this._cache.length;
  12166. }
  12167. return this;
  12168. };
  12169. // abstract __iterateUncached(fn, reverse)
  12170. Seq.prototype.__iterate = function(fn, reverse) {
  12171. return seqIterate(this, fn, reverse, true);
  12172. };
  12173. // abstract __iteratorUncached(type, reverse)
  12174. Seq.prototype.__iterator = function(type, reverse) {
  12175. return seqIterator(this, type, reverse, true);
  12176. };
  12177. createClass(KeyedSeq, Seq);
  12178. function KeyedSeq(value) {
  12179. return value === null || value === undefined ?
  12180. emptySequence().toKeyedSeq() :
  12181. isIterable(value) ?
  12182. (isKeyed(value) ? value.toSeq() : value.fromEntrySeq()) :
  12183. keyedSeqFromValue(value);
  12184. }
  12185. KeyedSeq.prototype.toKeyedSeq = function() {
  12186. return this;
  12187. };
  12188. createClass(IndexedSeq, Seq);
  12189. function IndexedSeq(value) {
  12190. return value === null || value === undefined ? emptySequence() :
  12191. !isIterable(value) ? indexedSeqFromValue(value) :
  12192. isKeyed(value) ? value.entrySeq() : value.toIndexedSeq();
  12193. }
  12194. IndexedSeq.of = function(/*...values*/) {
  12195. return IndexedSeq(arguments);
  12196. };
  12197. IndexedSeq.prototype.toIndexedSeq = function() {
  12198. return this;
  12199. };
  12200. IndexedSeq.prototype.toString = function() {
  12201. return this.__toString('Seq [', ']');
  12202. };
  12203. IndexedSeq.prototype.__iterate = function(fn, reverse) {
  12204. return seqIterate(this, fn, reverse, false);
  12205. };
  12206. IndexedSeq.prototype.__iterator = function(type, reverse) {
  12207. return seqIterator(this, type, reverse, false);
  12208. };
  12209. createClass(SetSeq, Seq);
  12210. function SetSeq(value) {
  12211. return (
  12212. value === null || value === undefined ? emptySequence() :
  12213. !isIterable(value) ? indexedSeqFromValue(value) :
  12214. isKeyed(value) ? value.entrySeq() : value
  12215. ).toSetSeq();
  12216. }
  12217. SetSeq.of = function(/*...values*/) {
  12218. return SetSeq(arguments);
  12219. };
  12220. SetSeq.prototype.toSetSeq = function() {
  12221. return this;
  12222. };
  12223. Seq.isSeq = isSeq;
  12224. Seq.Keyed = KeyedSeq;
  12225. Seq.Set = SetSeq;
  12226. Seq.Indexed = IndexedSeq;
  12227. var IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
  12228. Seq.prototype[IS_SEQ_SENTINEL] = true;
  12229. createClass(ArraySeq, IndexedSeq);
  12230. function ArraySeq(array) {
  12231. this._array = array;
  12232. this.size = array.length;
  12233. }
  12234. ArraySeq.prototype.get = function(index, notSetValue) {
  12235. return this.has(index) ? this._array[wrapIndex(this, index)] : notSetValue;
  12236. };
  12237. ArraySeq.prototype.__iterate = function(fn, reverse) {
  12238. var array = this._array;
  12239. var maxIndex = array.length - 1;
  12240. for (var ii = 0; ii <= maxIndex; ii++) {
  12241. if (fn(array[reverse ? maxIndex - ii : ii], ii, this) === false) {
  12242. return ii + 1;
  12243. }
  12244. }
  12245. return ii;
  12246. };
  12247. ArraySeq.prototype.__iterator = function(type, reverse) {
  12248. var array = this._array;
  12249. var maxIndex = array.length - 1;
  12250. var ii = 0;
  12251. return new Iterator(function()
  12252. {return ii > maxIndex ?
  12253. iteratorDone() :
  12254. iteratorValue(type, ii, array[reverse ? maxIndex - ii++ : ii++])}
  12255. );
  12256. };
  12257. createClass(ObjectSeq, KeyedSeq);
  12258. function ObjectSeq(object) {
  12259. var keys = Object.keys(object);
  12260. this._object = object;
  12261. this._keys = keys;
  12262. this.size = keys.length;
  12263. }
  12264. ObjectSeq.prototype.get = function(key, notSetValue) {
  12265. if (notSetValue !== undefined && !this.has(key)) {
  12266. return notSetValue;
  12267. }
  12268. return this._object[key];
  12269. };
  12270. ObjectSeq.prototype.has = function(key) {
  12271. return this._object.hasOwnProperty(key);
  12272. };
  12273. ObjectSeq.prototype.__iterate = function(fn, reverse) {
  12274. var object = this._object;
  12275. var keys = this._keys;
  12276. var maxIndex = keys.length - 1;
  12277. for (var ii = 0; ii <= maxIndex; ii++) {
  12278. var key = keys[reverse ? maxIndex - ii : ii];
  12279. if (fn(object[key], key, this) === false) {
  12280. return ii + 1;
  12281. }
  12282. }
  12283. return ii;
  12284. };
  12285. ObjectSeq.prototype.__iterator = function(type, reverse) {
  12286. var object = this._object;
  12287. var keys = this._keys;
  12288. var maxIndex = keys.length - 1;
  12289. var ii = 0;
  12290. return new Iterator(function() {
  12291. var key = keys[reverse ? maxIndex - ii : ii];
  12292. return ii++ > maxIndex ?
  12293. iteratorDone() :
  12294. iteratorValue(type, key, object[key]);
  12295. });
  12296. };
  12297. ObjectSeq.prototype[IS_ORDERED_SENTINEL] = true;
  12298. createClass(IterableSeq, IndexedSeq);
  12299. function IterableSeq(iterable) {
  12300. this._iterable = iterable;
  12301. this.size = iterable.length || iterable.size;
  12302. }
  12303. IterableSeq.prototype.__iterateUncached = function(fn, reverse) {
  12304. if (reverse) {
  12305. return this.cacheResult().__iterate(fn, reverse);
  12306. }
  12307. var iterable = this._iterable;
  12308. var iterator = getIterator(iterable);
  12309. var iterations = 0;
  12310. if (isIterator(iterator)) {
  12311. var step;
  12312. while (!(step = iterator.next()).done) {
  12313. if (fn(step.value, iterations++, this) === false) {
  12314. break;
  12315. }
  12316. }
  12317. }
  12318. return iterations;
  12319. };
  12320. IterableSeq.prototype.__iteratorUncached = function(type, reverse) {
  12321. if (reverse) {
  12322. return this.cacheResult().__iterator(type, reverse);
  12323. }
  12324. var iterable = this._iterable;
  12325. var iterator = getIterator(iterable);
  12326. if (!isIterator(iterator)) {
  12327. return new Iterator(iteratorDone);
  12328. }
  12329. var iterations = 0;
  12330. return new Iterator(function() {
  12331. var step = iterator.next();
  12332. return step.done ? step : iteratorValue(type, iterations++, step.value);
  12333. });
  12334. };
  12335. createClass(IteratorSeq, IndexedSeq);
  12336. function IteratorSeq(iterator) {
  12337. this._iterator = iterator;
  12338. this._iteratorCache = [];
  12339. }
  12340. IteratorSeq.prototype.__iterateUncached = function(fn, reverse) {
  12341. if (reverse) {
  12342. return this.cacheResult().__iterate(fn, reverse);
  12343. }
  12344. var iterator = this._iterator;
  12345. var cache = this._iteratorCache;
  12346. var iterations = 0;
  12347. while (iterations < cache.length) {
  12348. if (fn(cache[iterations], iterations++, this) === false) {
  12349. return iterations;
  12350. }
  12351. }
  12352. var step;
  12353. while (!(step = iterator.next()).done) {
  12354. var val = step.value;
  12355. cache[iterations] = val;
  12356. if (fn(val, iterations++, this) === false) {
  12357. break;
  12358. }
  12359. }
  12360. return iterations;
  12361. };
  12362. IteratorSeq.prototype.__iteratorUncached = function(type, reverse) {
  12363. if (reverse) {
  12364. return this.cacheResult().__iterator(type, reverse);
  12365. }
  12366. var iterator = this._iterator;
  12367. var cache = this._iteratorCache;
  12368. var iterations = 0;
  12369. return new Iterator(function() {
  12370. if (iterations >= cache.length) {
  12371. var step = iterator.next();
  12372. if (step.done) {
  12373. return step;
  12374. }
  12375. cache[iterations] = step.value;
  12376. }
  12377. return iteratorValue(type, iterations, cache[iterations++]);
  12378. });
  12379. };
  12380. // # pragma Helper functions
  12381. function isSeq(maybeSeq) {
  12382. return !!(maybeSeq && maybeSeq[IS_SEQ_SENTINEL]);
  12383. }
  12384. var EMPTY_SEQ;
  12385. function emptySequence() {
  12386. return EMPTY_SEQ || (EMPTY_SEQ = new ArraySeq([]));
  12387. }
  12388. function keyedSeqFromValue(value) {
  12389. var seq =
  12390. Array.isArray(value) ? new ArraySeq(value).fromEntrySeq() :
  12391. isIterator(value) ? new IteratorSeq(value).fromEntrySeq() :
  12392. hasIterator(value) ? new IterableSeq(value).fromEntrySeq() :
  12393. typeof value === 'object' ? new ObjectSeq(value) :
  12394. undefined;
  12395. if (!seq) {
  12396. throw new TypeError(
  12397. 'Expected Array or iterable object of [k, v] entries, '+
  12398. 'or keyed object: ' + value
  12399. );
  12400. }
  12401. return seq;
  12402. }
  12403. function indexedSeqFromValue(value) {
  12404. var seq = maybeIndexedSeqFromValue(value);
  12405. if (!seq) {
  12406. throw new TypeError(
  12407. 'Expected Array or iterable object of values: ' + value
  12408. );
  12409. }
  12410. return seq;
  12411. }
  12412. function seqFromValue(value) {
  12413. var seq = maybeIndexedSeqFromValue(value) ||
  12414. (typeof value === 'object' && new ObjectSeq(value));
  12415. if (!seq) {
  12416. throw new TypeError(
  12417. 'Expected Array or iterable object of values, or keyed object: ' + value
  12418. );
  12419. }
  12420. return seq;
  12421. }
  12422. function maybeIndexedSeqFromValue(value) {
  12423. return (
  12424. isArrayLike(value) ? new ArraySeq(value) :
  12425. isIterator(value) ? new IteratorSeq(value) :
  12426. hasIterator(value) ? new IterableSeq(value) :
  12427. undefined
  12428. );
  12429. }
  12430. function seqIterate(seq, fn, reverse, useKeys) {
  12431. var cache = seq._cache;
  12432. if (cache) {
  12433. var maxIndex = cache.length - 1;
  12434. for (var ii = 0; ii <= maxIndex; ii++) {
  12435. var entry = cache[reverse ? maxIndex - ii : ii];
  12436. if (fn(entry[1], useKeys ? entry[0] : ii, seq) === false) {
  12437. return ii + 1;
  12438. }
  12439. }
  12440. return ii;
  12441. }
  12442. return seq.__iterateUncached(fn, reverse);
  12443. }
  12444. function seqIterator(seq, type, reverse, useKeys) {
  12445. var cache = seq._cache;
  12446. if (cache) {
  12447. var maxIndex = cache.length - 1;
  12448. var ii = 0;
  12449. return new Iterator(function() {
  12450. var entry = cache[reverse ? maxIndex - ii : ii];
  12451. return ii++ > maxIndex ?
  12452. iteratorDone() :
  12453. iteratorValue(type, useKeys ? entry[0] : ii - 1, entry[1]);
  12454. });
  12455. }
  12456. return seq.__iteratorUncached(type, reverse);
  12457. }
  12458. function fromJS(json, converter) {
  12459. return converter ?
  12460. fromJSWith(converter, json, '', {'': json}) :
  12461. fromJSDefault(json);
  12462. }
  12463. function fromJSWith(converter, json, key, parentJSON) {
  12464. if (Array.isArray(json)) {
  12465. return converter.call(parentJSON, key, IndexedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  12466. }
  12467. if (isPlainObj(json)) {
  12468. return converter.call(parentJSON, key, KeyedSeq(json).map(function(v, k) {return fromJSWith(converter, v, k, json)}));
  12469. }
  12470. return json;
  12471. }
  12472. function fromJSDefault(json) {
  12473. if (Array.isArray(json)) {
  12474. return IndexedSeq(json).map(fromJSDefault).toList();
  12475. }
  12476. if (isPlainObj(json)) {
  12477. return KeyedSeq(json).map(fromJSDefault).toMap();
  12478. }
  12479. return json;
  12480. }
  12481. function isPlainObj(value) {
  12482. return value && (value.constructor === Object || value.constructor === undefined);
  12483. }
  12484. /**
  12485. * An extension of the "same-value" algorithm as [described for use by ES6 Map
  12486. * and Set](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map#Key_equality)
  12487. *
  12488. * NaN is considered the same as NaN, however -0 and 0 are considered the same
  12489. * value, which is different from the algorithm described by
  12490. * [`Object.is`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is).
  12491. *
  12492. * This is extended further to allow Objects to describe the values they
  12493. * represent, by way of `valueOf` or `equals` (and `hashCode`).
  12494. *
  12495. * Note: because of this extension, the key equality of Immutable.Map and the
  12496. * value equality of Immutable.Set will differ from ES6 Map and Set.
  12497. *
  12498. * ### Defining custom values
  12499. *
  12500. * The easiest way to describe the value an object represents is by implementing
  12501. * `valueOf`. For example, `Date` represents a value by returning a unix
  12502. * timestamp for `valueOf`:
  12503. *
  12504. * var date1 = new Date(1234567890000); // Fri Feb 13 2009 ...
  12505. * var date2 = new Date(1234567890000);
  12506. * date1.valueOf(); // 1234567890000
  12507. * assert( date1 !== date2 );
  12508. * assert( Immutable.is( date1, date2 ) );
  12509. *
  12510. * Note: overriding `valueOf` may have other implications if you use this object
  12511. * where JavaScript expects a primitive, such as implicit string coercion.
  12512. *
  12513. * For more complex types, especially collections, implementing `valueOf` may
  12514. * not be performant. An alternative is to implement `equals` and `hashCode`.
  12515. *
  12516. * `equals` takes another object, presumably of similar type, and returns true
  12517. * if the it is equal. Equality is symmetrical, so the same result should be
  12518. * returned if this and the argument are flipped.
  12519. *
  12520. * assert( a.equals(b) === b.equals(a) );
  12521. *
  12522. * `hashCode` returns a 32bit integer number representing the object which will
  12523. * be used to determine how to store the value object in a Map or Set. You must
  12524. * provide both or neither methods, one must not exist without the other.
  12525. *
  12526. * Also, an important relationship between these methods must be upheld: if two
  12527. * values are equal, they *must* return the same hashCode. If the values are not
  12528. * equal, they might have the same hashCode; this is called a hash collision,
  12529. * and while undesirable for performance reasons, it is acceptable.
  12530. *
  12531. * if (a.equals(b)) {
  12532. * assert( a.hashCode() === b.hashCode() );
  12533. * }
  12534. *
  12535. * All Immutable collections implement `equals` and `hashCode`.
  12536. *
  12537. */
  12538. function is(valueA, valueB) {
  12539. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  12540. return true;
  12541. }
  12542. if (!valueA || !valueB) {
  12543. return false;
  12544. }
  12545. if (typeof valueA.valueOf === 'function' &&
  12546. typeof valueB.valueOf === 'function') {
  12547. valueA = valueA.valueOf();
  12548. valueB = valueB.valueOf();
  12549. if (valueA === valueB || (valueA !== valueA && valueB !== valueB)) {
  12550. return true;
  12551. }
  12552. if (!valueA || !valueB) {
  12553. return false;
  12554. }
  12555. }
  12556. if (typeof valueA.equals === 'function' &&
  12557. typeof valueB.equals === 'function' &&
  12558. valueA.equals(valueB)) {
  12559. return true;
  12560. }
  12561. return false;
  12562. }
  12563. function deepEqual(a, b) {
  12564. if (a === b) {
  12565. return true;
  12566. }
  12567. if (
  12568. !isIterable(b) ||
  12569. a.size !== undefined && b.size !== undefined && a.size !== b.size ||
  12570. a.__hash !== undefined && b.__hash !== undefined && a.__hash !== b.__hash ||
  12571. isKeyed(a) !== isKeyed(b) ||
  12572. isIndexed(a) !== isIndexed(b) ||
  12573. isOrdered(a) !== isOrdered(b)
  12574. ) {
  12575. return false;
  12576. }
  12577. if (a.size === 0 && b.size === 0) {
  12578. return true;
  12579. }
  12580. var notAssociative = !isAssociative(a);
  12581. if (isOrdered(a)) {
  12582. var entries = a.entries();
  12583. return b.every(function(v, k) {
  12584. var entry = entries.next().value;
  12585. return entry && is(entry[1], v) && (notAssociative || is(entry[0], k));
  12586. }) && entries.next().done;
  12587. }
  12588. var flipped = false;
  12589. if (a.size === undefined) {
  12590. if (b.size === undefined) {
  12591. if (typeof a.cacheResult === 'function') {
  12592. a.cacheResult();
  12593. }
  12594. } else {
  12595. flipped = true;
  12596. var _ = a;
  12597. a = b;
  12598. b = _;
  12599. }
  12600. }
  12601. var allEqual = true;
  12602. var bSize = b.__iterate(function(v, k) {
  12603. if (notAssociative ? !a.has(v) :
  12604. flipped ? !is(v, a.get(k, NOT_SET)) : !is(a.get(k, NOT_SET), v)) {
  12605. allEqual = false;
  12606. return false;
  12607. }
  12608. });
  12609. return allEqual && a.size === bSize;
  12610. }
  12611. createClass(Repeat, IndexedSeq);
  12612. function Repeat(value, times) {
  12613. if (!(this instanceof Repeat)) {
  12614. return new Repeat(value, times);
  12615. }
  12616. this._value = value;
  12617. this.size = times === undefined ? Infinity : Math.max(0, times);
  12618. if (this.size === 0) {
  12619. if (EMPTY_REPEAT) {
  12620. return EMPTY_REPEAT;
  12621. }
  12622. EMPTY_REPEAT = this;
  12623. }
  12624. }
  12625. Repeat.prototype.toString = function() {
  12626. if (this.size === 0) {
  12627. return 'Repeat []';
  12628. }
  12629. return 'Repeat [ ' + this._value + ' ' + this.size + ' times ]';
  12630. };
  12631. Repeat.prototype.get = function(index, notSetValue) {
  12632. return this.has(index) ? this._value : notSetValue;
  12633. };
  12634. Repeat.prototype.includes = function(searchValue) {
  12635. return is(this._value, searchValue);
  12636. };
  12637. Repeat.prototype.slice = function(begin, end) {
  12638. var size = this.size;
  12639. return wholeSlice(begin, end, size) ? this :
  12640. new Repeat(this._value, resolveEnd(end, size) - resolveBegin(begin, size));
  12641. };
  12642. Repeat.prototype.reverse = function() {
  12643. return this;
  12644. };
  12645. Repeat.prototype.indexOf = function(searchValue) {
  12646. if (is(this._value, searchValue)) {
  12647. return 0;
  12648. }
  12649. return -1;
  12650. };
  12651. Repeat.prototype.lastIndexOf = function(searchValue) {
  12652. if (is(this._value, searchValue)) {
  12653. return this.size;
  12654. }
  12655. return -1;
  12656. };
  12657. Repeat.prototype.__iterate = function(fn, reverse) {
  12658. for (var ii = 0; ii < this.size; ii++) {
  12659. if (fn(this._value, ii, this) === false) {
  12660. return ii + 1;
  12661. }
  12662. }
  12663. return ii;
  12664. };
  12665. Repeat.prototype.__iterator = function(type, reverse) {var this$0 = this;
  12666. var ii = 0;
  12667. return new Iterator(function()
  12668. {return ii < this$0.size ? iteratorValue(type, ii++, this$0._value) : iteratorDone()}
  12669. );
  12670. };
  12671. Repeat.prototype.equals = function(other) {
  12672. return other instanceof Repeat ?
  12673. is(this._value, other._value) :
  12674. deepEqual(other);
  12675. };
  12676. var EMPTY_REPEAT;
  12677. function invariant(condition, error) {
  12678. if (!condition) throw new Error(error);
  12679. }
  12680. createClass(Range, IndexedSeq);
  12681. function Range(start, end, step) {
  12682. if (!(this instanceof Range)) {
  12683. return new Range(start, end, step);
  12684. }
  12685. invariant(step !== 0, 'Cannot step a Range by 0');
  12686. start = start || 0;
  12687. if (end === undefined) {
  12688. end = Infinity;
  12689. }
  12690. step = step === undefined ? 1 : Math.abs(step);
  12691. if (end < start) {
  12692. step = -step;
  12693. }
  12694. this._start = start;
  12695. this._end = end;
  12696. this._step = step;
  12697. this.size = Math.max(0, Math.ceil((end - start) / step - 1) + 1);
  12698. if (this.size === 0) {
  12699. if (EMPTY_RANGE) {
  12700. return EMPTY_RANGE;
  12701. }
  12702. EMPTY_RANGE = this;
  12703. }
  12704. }
  12705. Range.prototype.toString = function() {
  12706. if (this.size === 0) {
  12707. return 'Range []';
  12708. }
  12709. return 'Range [ ' +
  12710. this._start + '...' + this._end +
  12711. (this._step > 1 ? ' by ' + this._step : '') +
  12712. ' ]';
  12713. };
  12714. Range.prototype.get = function(index, notSetValue) {
  12715. return this.has(index) ?
  12716. this._start + wrapIndex(this, index) * this._step :
  12717. notSetValue;
  12718. };
  12719. Range.prototype.includes = function(searchValue) {
  12720. var possibleIndex = (searchValue - this._start) / this._step;
  12721. return possibleIndex >= 0 &&
  12722. possibleIndex < this.size &&
  12723. possibleIndex === Math.floor(possibleIndex);
  12724. };
  12725. Range.prototype.slice = function(begin, end) {
  12726. if (wholeSlice(begin, end, this.size)) {
  12727. return this;
  12728. }
  12729. begin = resolveBegin(begin, this.size);
  12730. end = resolveEnd(end, this.size);
  12731. if (end <= begin) {
  12732. return new Range(0, 0);
  12733. }
  12734. return new Range(this.get(begin, this._end), this.get(end, this._end), this._step);
  12735. };
  12736. Range.prototype.indexOf = function(searchValue) {
  12737. var offsetValue = searchValue - this._start;
  12738. if (offsetValue % this._step === 0) {
  12739. var index = offsetValue / this._step;
  12740. if (index >= 0 && index < this.size) {
  12741. return index
  12742. }
  12743. }
  12744. return -1;
  12745. };
  12746. Range.prototype.lastIndexOf = function(searchValue) {
  12747. return this.indexOf(searchValue);
  12748. };
  12749. Range.prototype.__iterate = function(fn, reverse) {
  12750. var maxIndex = this.size - 1;
  12751. var step = this._step;
  12752. var value = reverse ? this._start + maxIndex * step : this._start;
  12753. for (var ii = 0; ii <= maxIndex; ii++) {
  12754. if (fn(value, ii, this) === false) {
  12755. return ii + 1;
  12756. }
  12757. value += reverse ? -step : step;
  12758. }
  12759. return ii;
  12760. };
  12761. Range.prototype.__iterator = function(type, reverse) {
  12762. var maxIndex = this.size - 1;
  12763. var step = this._step;
  12764. var value = reverse ? this._start + maxIndex * step : this._start;
  12765. var ii = 0;
  12766. return new Iterator(function() {
  12767. var v = value;
  12768. value += reverse ? -step : step;
  12769. return ii > maxIndex ? iteratorDone() : iteratorValue(type, ii++, v);
  12770. });
  12771. };
  12772. Range.prototype.equals = function(other) {
  12773. return other instanceof Range ?
  12774. this._start === other._start &&
  12775. this._end === other._end &&
  12776. this._step === other._step :
  12777. deepEqual(this, other);
  12778. };
  12779. var EMPTY_RANGE;
  12780. createClass(Collection, Iterable);
  12781. function Collection() {
  12782. throw TypeError('Abstract');
  12783. }
  12784. createClass(KeyedCollection, Collection);function KeyedCollection() {}
  12785. createClass(IndexedCollection, Collection);function IndexedCollection() {}
  12786. createClass(SetCollection, Collection);function SetCollection() {}
  12787. Collection.Keyed = KeyedCollection;
  12788. Collection.Indexed = IndexedCollection;
  12789. Collection.Set = SetCollection;
  12790. var imul =
  12791. typeof Math.imul === 'function' && Math.imul(0xffffffff, 2) === -2 ?
  12792. Math.imul :
  12793. function imul(a, b) {
  12794. a = a | 0; // int
  12795. b = b | 0; // int
  12796. var c = a & 0xffff;
  12797. var d = b & 0xffff;
  12798. // Shift by 0 fixes the sign on the high part.
  12799. return (c * d) + ((((a >>> 16) * d + c * (b >>> 16)) << 16) >>> 0) | 0; // int
  12800. };
  12801. // v8 has an optimization for storing 31-bit signed numbers.
  12802. // Values which have either 00 or 11 as the high order bits qualify.
  12803. // This function drops the highest order bit in a signed number, maintaining
  12804. // the sign bit.
  12805. function smi(i32) {
  12806. return ((i32 >>> 1) & 0x40000000) | (i32 & 0xBFFFFFFF);
  12807. }
  12808. function hash(o) {
  12809. if (o === false || o === null || o === undefined) {
  12810. return 0;
  12811. }
  12812. if (typeof o.valueOf === 'function') {
  12813. o = o.valueOf();
  12814. if (o === false || o === null || o === undefined) {
  12815. return 0;
  12816. }
  12817. }
  12818. if (o === true) {
  12819. return 1;
  12820. }
  12821. var type = typeof o;
  12822. if (type === 'number') {
  12823. var h = o | 0;
  12824. if (h !== o) {
  12825. h ^= o * 0xFFFFFFFF;
  12826. }
  12827. while (o > 0xFFFFFFFF) {
  12828. o /= 0xFFFFFFFF;
  12829. h ^= o;
  12830. }
  12831. return smi(h);
  12832. }
  12833. if (type === 'string') {
  12834. return o.length > STRING_HASH_CACHE_MIN_STRLEN ? cachedHashString(o) : hashString(o);
  12835. }
  12836. if (typeof o.hashCode === 'function') {
  12837. return o.hashCode();
  12838. }
  12839. if (type === 'object') {
  12840. return hashJSObj(o);
  12841. }
  12842. if (typeof o.toString === 'function') {
  12843. return hashString(o.toString());
  12844. }
  12845. throw new Error('Value type ' + type + ' cannot be hashed.');
  12846. }
  12847. function cachedHashString(string) {
  12848. var hash = stringHashCache[string];
  12849. if (hash === undefined) {
  12850. hash = hashString(string);
  12851. if (STRING_HASH_CACHE_SIZE === STRING_HASH_CACHE_MAX_SIZE) {
  12852. STRING_HASH_CACHE_SIZE = 0;
  12853. stringHashCache = {};
  12854. }
  12855. STRING_HASH_CACHE_SIZE++;
  12856. stringHashCache[string] = hash;
  12857. }
  12858. return hash;
  12859. }
  12860. // http://jsperf.com/hashing-strings
  12861. function hashString(string) {
  12862. // This is the hash from JVM
  12863. // The hash code for a string is computed as
  12864. // s[0] * 31 ^ (n - 1) + s[1] * 31 ^ (n - 2) + ... + s[n - 1],
  12865. // where s[i] is the ith character of the string and n is the length of
  12866. // the string. We "mod" the result to make it between 0 (inclusive) and 2^31
  12867. // (exclusive) by dropping high bits.
  12868. var hash = 0;
  12869. for (var ii = 0; ii < string.length; ii++) {
  12870. hash = 31 * hash + string.charCodeAt(ii) | 0;
  12871. }
  12872. return smi(hash);
  12873. }
  12874. function hashJSObj(obj) {
  12875. var hash;
  12876. if (usingWeakMap) {
  12877. hash = weakMap.get(obj);
  12878. if (hash !== undefined) {
  12879. return hash;
  12880. }
  12881. }
  12882. hash = obj[UID_HASH_KEY];
  12883. if (hash !== undefined) {
  12884. return hash;
  12885. }
  12886. if (!canDefineProperty) {
  12887. hash = obj.propertyIsEnumerable && obj.propertyIsEnumerable[UID_HASH_KEY];
  12888. if (hash !== undefined) {
  12889. return hash;
  12890. }
  12891. hash = getIENodeHash(obj);
  12892. if (hash !== undefined) {
  12893. return hash;
  12894. }
  12895. }
  12896. hash = ++objHashUID;
  12897. if (objHashUID & 0x40000000) {
  12898. objHashUID = 0;
  12899. }
  12900. if (usingWeakMap) {
  12901. weakMap.set(obj, hash);
  12902. } else if (isExtensible !== undefined && isExtensible(obj) === false) {
  12903. throw new Error('Non-extensible objects are not allowed as keys.');
  12904. } else if (canDefineProperty) {
  12905. Object.defineProperty(obj, UID_HASH_KEY, {
  12906. 'enumerable': false,
  12907. 'configurable': false,
  12908. 'writable': false,
  12909. 'value': hash
  12910. });
  12911. } else if (obj.propertyIsEnumerable !== undefined &&
  12912. obj.propertyIsEnumerable === obj.constructor.prototype.propertyIsEnumerable) {
  12913. // Since we can't define a non-enumerable property on the object
  12914. // we'll hijack one of the less-used non-enumerable properties to
  12915. // save our hash on it. Since this is a function it will not show up in
  12916. // `JSON.stringify` which is what we want.
  12917. obj.propertyIsEnumerable = function() {
  12918. return this.constructor.prototype.propertyIsEnumerable.apply(this, arguments);
  12919. };
  12920. obj.propertyIsEnumerable[UID_HASH_KEY] = hash;
  12921. } else if (obj.nodeType !== undefined) {
  12922. // At this point we couldn't get the IE `uniqueID` to use as a hash
  12923. // and we couldn't use a non-enumerable property to exploit the
  12924. // dontEnum bug so we simply add the `UID_HASH_KEY` on the node
  12925. // itself.
  12926. obj[UID_HASH_KEY] = hash;
  12927. } else {
  12928. throw new Error('Unable to set a non-enumerable property on object.');
  12929. }
  12930. return hash;
  12931. }
  12932. // Get references to ES5 object methods.
  12933. var isExtensible = Object.isExtensible;
  12934. // True if Object.defineProperty works as expected. IE8 fails this test.
  12935. var canDefineProperty = (function() {
  12936. try {
  12937. Object.defineProperty({}, '@', {});
  12938. return true;
  12939. } catch (e) {
  12940. return false;
  12941. }
  12942. }());
  12943. // IE has a `uniqueID` property on DOM nodes. We can construct the hash from it
  12944. // and avoid memory leaks from the IE cloneNode bug.
  12945. function getIENodeHash(node) {
  12946. if (node && node.nodeType > 0) {
  12947. switch (node.nodeType) {
  12948. case 1: // Element
  12949. return node.uniqueID;
  12950. case 9: // Document
  12951. return node.documentElement && node.documentElement.uniqueID;
  12952. }
  12953. }
  12954. }
  12955. // If possible, use a WeakMap.
  12956. var usingWeakMap = typeof WeakMap === 'function';
  12957. var weakMap;
  12958. if (usingWeakMap) {
  12959. weakMap = new WeakMap();
  12960. }
  12961. var objHashUID = 0;
  12962. var UID_HASH_KEY = '__immutablehash__';
  12963. if (typeof Symbol === 'function') {
  12964. UID_HASH_KEY = Symbol(UID_HASH_KEY);
  12965. }
  12966. var STRING_HASH_CACHE_MIN_STRLEN = 16;
  12967. var STRING_HASH_CACHE_MAX_SIZE = 255;
  12968. var STRING_HASH_CACHE_SIZE = 0;
  12969. var stringHashCache = {};
  12970. function assertNotInfinite(size) {
  12971. invariant(
  12972. size !== Infinity,
  12973. 'Cannot perform this action with an infinite size.'
  12974. );
  12975. }
  12976. createClass(Map, KeyedCollection);
  12977. // @pragma Construction
  12978. function Map(value) {
  12979. return value === null || value === undefined ? emptyMap() :
  12980. isMap(value) && !isOrdered(value) ? value :
  12981. emptyMap().withMutations(function(map ) {
  12982. var iter = KeyedIterable(value);
  12983. assertNotInfinite(iter.size);
  12984. iter.forEach(function(v, k) {return map.set(k, v)});
  12985. });
  12986. }
  12987. Map.prototype.toString = function() {
  12988. return this.__toString('Map {', '}');
  12989. };
  12990. // @pragma Access
  12991. Map.prototype.get = function(k, notSetValue) {
  12992. return this._root ?
  12993. this._root.get(0, undefined, k, notSetValue) :
  12994. notSetValue;
  12995. };
  12996. // @pragma Modification
  12997. Map.prototype.set = function(k, v) {
  12998. return updateMap(this, k, v);
  12999. };
  13000. Map.prototype.setIn = function(keyPath, v) {
  13001. return this.updateIn(keyPath, NOT_SET, function() {return v});
  13002. };
  13003. Map.prototype.remove = function(k) {
  13004. return updateMap(this, k, NOT_SET);
  13005. };
  13006. Map.prototype.deleteIn = function(keyPath) {
  13007. return this.updateIn(keyPath, function() {return NOT_SET});
  13008. };
  13009. Map.prototype.update = function(k, notSetValue, updater) {
  13010. return arguments.length === 1 ?
  13011. k(this) :
  13012. this.updateIn([k], notSetValue, updater);
  13013. };
  13014. Map.prototype.updateIn = function(keyPath, notSetValue, updater) {
  13015. if (!updater) {
  13016. updater = notSetValue;
  13017. notSetValue = undefined;
  13018. }
  13019. var updatedValue = updateInDeepMap(
  13020. this,
  13021. forceIterator(keyPath),
  13022. notSetValue,
  13023. updater
  13024. );
  13025. return updatedValue === NOT_SET ? undefined : updatedValue;
  13026. };
  13027. Map.prototype.clear = function() {
  13028. if (this.size === 0) {
  13029. return this;
  13030. }
  13031. if (this.__ownerID) {
  13032. this.size = 0;
  13033. this._root = null;
  13034. this.__hash = undefined;
  13035. this.__altered = true;
  13036. return this;
  13037. }
  13038. return emptyMap();
  13039. };
  13040. // @pragma Composition
  13041. Map.prototype.merge = function(/*...iters*/) {
  13042. return mergeIntoMapWith(this, undefined, arguments);
  13043. };
  13044. Map.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  13045. return mergeIntoMapWith(this, merger, iters);
  13046. };
  13047. Map.prototype.mergeIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  13048. return this.updateIn(
  13049. keyPath,
  13050. emptyMap(),
  13051. function(m ) {return typeof m.merge === 'function' ?
  13052. m.merge.apply(m, iters) :
  13053. iters[iters.length - 1]}
  13054. );
  13055. };
  13056. Map.prototype.mergeDeep = function(/*...iters*/) {
  13057. return mergeIntoMapWith(this, deepMerger, arguments);
  13058. };
  13059. Map.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  13060. return mergeIntoMapWith(this, deepMergerWith(merger), iters);
  13061. };
  13062. Map.prototype.mergeDeepIn = function(keyPath) {var iters = SLICE$0.call(arguments, 1);
  13063. return this.updateIn(
  13064. keyPath,
  13065. emptyMap(),
  13066. function(m ) {return typeof m.mergeDeep === 'function' ?
  13067. m.mergeDeep.apply(m, iters) :
  13068. iters[iters.length - 1]}
  13069. );
  13070. };
  13071. Map.prototype.sort = function(comparator) {
  13072. // Late binding
  13073. return OrderedMap(sortFactory(this, comparator));
  13074. };
  13075. Map.prototype.sortBy = function(mapper, comparator) {
  13076. // Late binding
  13077. return OrderedMap(sortFactory(this, comparator, mapper));
  13078. };
  13079. // @pragma Mutability
  13080. Map.prototype.withMutations = function(fn) {
  13081. var mutable = this.asMutable();
  13082. fn(mutable);
  13083. return mutable.wasAltered() ? mutable.__ensureOwner(this.__ownerID) : this;
  13084. };
  13085. Map.prototype.asMutable = function() {
  13086. return this.__ownerID ? this : this.__ensureOwner(new OwnerID());
  13087. };
  13088. Map.prototype.asImmutable = function() {
  13089. return this.__ensureOwner();
  13090. };
  13091. Map.prototype.wasAltered = function() {
  13092. return this.__altered;
  13093. };
  13094. Map.prototype.__iterator = function(type, reverse) {
  13095. return new MapIterator(this, type, reverse);
  13096. };
  13097. Map.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  13098. var iterations = 0;
  13099. this._root && this._root.iterate(function(entry ) {
  13100. iterations++;
  13101. return fn(entry[1], entry[0], this$0);
  13102. }, reverse);
  13103. return iterations;
  13104. };
  13105. Map.prototype.__ensureOwner = function(ownerID) {
  13106. if (ownerID === this.__ownerID) {
  13107. return this;
  13108. }
  13109. if (!ownerID) {
  13110. this.__ownerID = ownerID;
  13111. this.__altered = false;
  13112. return this;
  13113. }
  13114. return makeMap(this.size, this._root, ownerID, this.__hash);
  13115. };
  13116. function isMap(maybeMap) {
  13117. return !!(maybeMap && maybeMap[IS_MAP_SENTINEL]);
  13118. }
  13119. Map.isMap = isMap;
  13120. var IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
  13121. var MapPrototype = Map.prototype;
  13122. MapPrototype[IS_MAP_SENTINEL] = true;
  13123. MapPrototype[DELETE] = MapPrototype.remove;
  13124. MapPrototype.removeIn = MapPrototype.deleteIn;
  13125. // #pragma Trie Nodes
  13126. function ArrayMapNode(ownerID, entries) {
  13127. this.ownerID = ownerID;
  13128. this.entries = entries;
  13129. }
  13130. ArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  13131. var entries = this.entries;
  13132. for (var ii = 0, len = entries.length; ii < len; ii++) {
  13133. if (is(key, entries[ii][0])) {
  13134. return entries[ii][1];
  13135. }
  13136. }
  13137. return notSetValue;
  13138. };
  13139. ArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13140. var removed = value === NOT_SET;
  13141. var entries = this.entries;
  13142. var idx = 0;
  13143. for (var len = entries.length; idx < len; idx++) {
  13144. if (is(key, entries[idx][0])) {
  13145. break;
  13146. }
  13147. }
  13148. var exists = idx < len;
  13149. if (exists ? entries[idx][1] === value : removed) {
  13150. return this;
  13151. }
  13152. SetRef(didAlter);
  13153. (removed || !exists) && SetRef(didChangeSize);
  13154. if (removed && entries.length === 1) {
  13155. return; // undefined
  13156. }
  13157. if (!exists && !removed && entries.length >= MAX_ARRAY_MAP_SIZE) {
  13158. return createNodes(ownerID, entries, key, value);
  13159. }
  13160. var isEditable = ownerID && ownerID === this.ownerID;
  13161. var newEntries = isEditable ? entries : arrCopy(entries);
  13162. if (exists) {
  13163. if (removed) {
  13164. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  13165. } else {
  13166. newEntries[idx] = [key, value];
  13167. }
  13168. } else {
  13169. newEntries.push([key, value]);
  13170. }
  13171. if (isEditable) {
  13172. this.entries = newEntries;
  13173. return this;
  13174. }
  13175. return new ArrayMapNode(ownerID, newEntries);
  13176. };
  13177. function BitmapIndexedNode(ownerID, bitmap, nodes) {
  13178. this.ownerID = ownerID;
  13179. this.bitmap = bitmap;
  13180. this.nodes = nodes;
  13181. }
  13182. BitmapIndexedNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  13183. if (keyHash === undefined) {
  13184. keyHash = hash(key);
  13185. }
  13186. var bit = (1 << ((shift === 0 ? keyHash : keyHash >>> shift) & MASK));
  13187. var bitmap = this.bitmap;
  13188. return (bitmap & bit) === 0 ? notSetValue :
  13189. this.nodes[popCount(bitmap & (bit - 1))].get(shift + SHIFT, keyHash, key, notSetValue);
  13190. };
  13191. BitmapIndexedNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13192. if (keyHash === undefined) {
  13193. keyHash = hash(key);
  13194. }
  13195. var keyHashFrag = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  13196. var bit = 1 << keyHashFrag;
  13197. var bitmap = this.bitmap;
  13198. var exists = (bitmap & bit) !== 0;
  13199. if (!exists && value === NOT_SET) {
  13200. return this;
  13201. }
  13202. var idx = popCount(bitmap & (bit - 1));
  13203. var nodes = this.nodes;
  13204. var node = exists ? nodes[idx] : undefined;
  13205. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  13206. if (newNode === node) {
  13207. return this;
  13208. }
  13209. if (!exists && newNode && nodes.length >= MAX_BITMAP_INDEXED_SIZE) {
  13210. return expandNodes(ownerID, nodes, bitmap, keyHashFrag, newNode);
  13211. }
  13212. if (exists && !newNode && nodes.length === 2 && isLeafNode(nodes[idx ^ 1])) {
  13213. return nodes[idx ^ 1];
  13214. }
  13215. if (exists && newNode && nodes.length === 1 && isLeafNode(newNode)) {
  13216. return newNode;
  13217. }
  13218. var isEditable = ownerID && ownerID === this.ownerID;
  13219. var newBitmap = exists ? newNode ? bitmap : bitmap ^ bit : bitmap | bit;
  13220. var newNodes = exists ? newNode ?
  13221. setIn(nodes, idx, newNode, isEditable) :
  13222. spliceOut(nodes, idx, isEditable) :
  13223. spliceIn(nodes, idx, newNode, isEditable);
  13224. if (isEditable) {
  13225. this.bitmap = newBitmap;
  13226. this.nodes = newNodes;
  13227. return this;
  13228. }
  13229. return new BitmapIndexedNode(ownerID, newBitmap, newNodes);
  13230. };
  13231. function HashArrayMapNode(ownerID, count, nodes) {
  13232. this.ownerID = ownerID;
  13233. this.count = count;
  13234. this.nodes = nodes;
  13235. }
  13236. HashArrayMapNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  13237. if (keyHash === undefined) {
  13238. keyHash = hash(key);
  13239. }
  13240. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  13241. var node = this.nodes[idx];
  13242. return node ? node.get(shift + SHIFT, keyHash, key, notSetValue) : notSetValue;
  13243. };
  13244. HashArrayMapNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13245. if (keyHash === undefined) {
  13246. keyHash = hash(key);
  13247. }
  13248. var idx = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  13249. var removed = value === NOT_SET;
  13250. var nodes = this.nodes;
  13251. var node = nodes[idx];
  13252. if (removed && !node) {
  13253. return this;
  13254. }
  13255. var newNode = updateNode(node, ownerID, shift + SHIFT, keyHash, key, value, didChangeSize, didAlter);
  13256. if (newNode === node) {
  13257. return this;
  13258. }
  13259. var newCount = this.count;
  13260. if (!node) {
  13261. newCount++;
  13262. } else if (!newNode) {
  13263. newCount--;
  13264. if (newCount < MIN_HASH_ARRAY_MAP_SIZE) {
  13265. return packNodes(ownerID, nodes, newCount, idx);
  13266. }
  13267. }
  13268. var isEditable = ownerID && ownerID === this.ownerID;
  13269. var newNodes = setIn(nodes, idx, newNode, isEditable);
  13270. if (isEditable) {
  13271. this.count = newCount;
  13272. this.nodes = newNodes;
  13273. return this;
  13274. }
  13275. return new HashArrayMapNode(ownerID, newCount, newNodes);
  13276. };
  13277. function HashCollisionNode(ownerID, keyHash, entries) {
  13278. this.ownerID = ownerID;
  13279. this.keyHash = keyHash;
  13280. this.entries = entries;
  13281. }
  13282. HashCollisionNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  13283. var entries = this.entries;
  13284. for (var ii = 0, len = entries.length; ii < len; ii++) {
  13285. if (is(key, entries[ii][0])) {
  13286. return entries[ii][1];
  13287. }
  13288. }
  13289. return notSetValue;
  13290. };
  13291. HashCollisionNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13292. if (keyHash === undefined) {
  13293. keyHash = hash(key);
  13294. }
  13295. var removed = value === NOT_SET;
  13296. if (keyHash !== this.keyHash) {
  13297. if (removed) {
  13298. return this;
  13299. }
  13300. SetRef(didAlter);
  13301. SetRef(didChangeSize);
  13302. return mergeIntoNode(this, ownerID, shift, keyHash, [key, value]);
  13303. }
  13304. var entries = this.entries;
  13305. var idx = 0;
  13306. for (var len = entries.length; idx < len; idx++) {
  13307. if (is(key, entries[idx][0])) {
  13308. break;
  13309. }
  13310. }
  13311. var exists = idx < len;
  13312. if (exists ? entries[idx][1] === value : removed) {
  13313. return this;
  13314. }
  13315. SetRef(didAlter);
  13316. (removed || !exists) && SetRef(didChangeSize);
  13317. if (removed && len === 2) {
  13318. return new ValueNode(ownerID, this.keyHash, entries[idx ^ 1]);
  13319. }
  13320. var isEditable = ownerID && ownerID === this.ownerID;
  13321. var newEntries = isEditable ? entries : arrCopy(entries);
  13322. if (exists) {
  13323. if (removed) {
  13324. idx === len - 1 ? newEntries.pop() : (newEntries[idx] = newEntries.pop());
  13325. } else {
  13326. newEntries[idx] = [key, value];
  13327. }
  13328. } else {
  13329. newEntries.push([key, value]);
  13330. }
  13331. if (isEditable) {
  13332. this.entries = newEntries;
  13333. return this;
  13334. }
  13335. return new HashCollisionNode(ownerID, this.keyHash, newEntries);
  13336. };
  13337. function ValueNode(ownerID, keyHash, entry) {
  13338. this.ownerID = ownerID;
  13339. this.keyHash = keyHash;
  13340. this.entry = entry;
  13341. }
  13342. ValueNode.prototype.get = function(shift, keyHash, key, notSetValue) {
  13343. return is(key, this.entry[0]) ? this.entry[1] : notSetValue;
  13344. };
  13345. ValueNode.prototype.update = function(ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13346. var removed = value === NOT_SET;
  13347. var keyMatch = is(key, this.entry[0]);
  13348. if (keyMatch ? value === this.entry[1] : removed) {
  13349. return this;
  13350. }
  13351. SetRef(didAlter);
  13352. if (removed) {
  13353. SetRef(didChangeSize);
  13354. return; // undefined
  13355. }
  13356. if (keyMatch) {
  13357. if (ownerID && ownerID === this.ownerID) {
  13358. this.entry[1] = value;
  13359. return this;
  13360. }
  13361. return new ValueNode(ownerID, this.keyHash, [key, value]);
  13362. }
  13363. SetRef(didChangeSize);
  13364. return mergeIntoNode(this, ownerID, shift, hash(key), [key, value]);
  13365. };
  13366. // #pragma Iterators
  13367. ArrayMapNode.prototype.iterate =
  13368. HashCollisionNode.prototype.iterate = function (fn, reverse) {
  13369. var entries = this.entries;
  13370. for (var ii = 0, maxIndex = entries.length - 1; ii <= maxIndex; ii++) {
  13371. if (fn(entries[reverse ? maxIndex - ii : ii]) === false) {
  13372. return false;
  13373. }
  13374. }
  13375. };
  13376. BitmapIndexedNode.prototype.iterate =
  13377. HashArrayMapNode.prototype.iterate = function (fn, reverse) {
  13378. var nodes = this.nodes;
  13379. for (var ii = 0, maxIndex = nodes.length - 1; ii <= maxIndex; ii++) {
  13380. var node = nodes[reverse ? maxIndex - ii : ii];
  13381. if (node && node.iterate(fn, reverse) === false) {
  13382. return false;
  13383. }
  13384. }
  13385. };
  13386. ValueNode.prototype.iterate = function (fn, reverse) {
  13387. return fn(this.entry);
  13388. };
  13389. createClass(MapIterator, Iterator);
  13390. function MapIterator(map, type, reverse) {
  13391. this._type = type;
  13392. this._reverse = reverse;
  13393. this._stack = map._root && mapIteratorFrame(map._root);
  13394. }
  13395. MapIterator.prototype.next = function() {
  13396. var type = this._type;
  13397. var stack = this._stack;
  13398. while (stack) {
  13399. var node = stack.node;
  13400. var index = stack.index++;
  13401. var maxIndex;
  13402. if (node.entry) {
  13403. if (index === 0) {
  13404. return mapIteratorValue(type, node.entry);
  13405. }
  13406. } else if (node.entries) {
  13407. maxIndex = node.entries.length - 1;
  13408. if (index <= maxIndex) {
  13409. return mapIteratorValue(type, node.entries[this._reverse ? maxIndex - index : index]);
  13410. }
  13411. } else {
  13412. maxIndex = node.nodes.length - 1;
  13413. if (index <= maxIndex) {
  13414. var subNode = node.nodes[this._reverse ? maxIndex - index : index];
  13415. if (subNode) {
  13416. if (subNode.entry) {
  13417. return mapIteratorValue(type, subNode.entry);
  13418. }
  13419. stack = this._stack = mapIteratorFrame(subNode, stack);
  13420. }
  13421. continue;
  13422. }
  13423. }
  13424. stack = this._stack = this._stack.__prev;
  13425. }
  13426. return iteratorDone();
  13427. };
  13428. function mapIteratorValue(type, entry) {
  13429. return iteratorValue(type, entry[0], entry[1]);
  13430. }
  13431. function mapIteratorFrame(node, prev) {
  13432. return {
  13433. node: node,
  13434. index: 0,
  13435. __prev: prev
  13436. };
  13437. }
  13438. function makeMap(size, root, ownerID, hash) {
  13439. var map = Object.create(MapPrototype);
  13440. map.size = size;
  13441. map._root = root;
  13442. map.__ownerID = ownerID;
  13443. map.__hash = hash;
  13444. map.__altered = false;
  13445. return map;
  13446. }
  13447. var EMPTY_MAP;
  13448. function emptyMap() {
  13449. return EMPTY_MAP || (EMPTY_MAP = makeMap(0));
  13450. }
  13451. function updateMap(map, k, v) {
  13452. var newRoot;
  13453. var newSize;
  13454. if (!map._root) {
  13455. if (v === NOT_SET) {
  13456. return map;
  13457. }
  13458. newSize = 1;
  13459. newRoot = new ArrayMapNode(map.__ownerID, [[k, v]]);
  13460. } else {
  13461. var didChangeSize = MakeRef(CHANGE_LENGTH);
  13462. var didAlter = MakeRef(DID_ALTER);
  13463. newRoot = updateNode(map._root, map.__ownerID, 0, undefined, k, v, didChangeSize, didAlter);
  13464. if (!didAlter.value) {
  13465. return map;
  13466. }
  13467. newSize = map.size + (didChangeSize.value ? v === NOT_SET ? -1 : 1 : 0);
  13468. }
  13469. if (map.__ownerID) {
  13470. map.size = newSize;
  13471. map._root = newRoot;
  13472. map.__hash = undefined;
  13473. map.__altered = true;
  13474. return map;
  13475. }
  13476. return newRoot ? makeMap(newSize, newRoot) : emptyMap();
  13477. }
  13478. function updateNode(node, ownerID, shift, keyHash, key, value, didChangeSize, didAlter) {
  13479. if (!node) {
  13480. if (value === NOT_SET) {
  13481. return node;
  13482. }
  13483. SetRef(didAlter);
  13484. SetRef(didChangeSize);
  13485. return new ValueNode(ownerID, keyHash, [key, value]);
  13486. }
  13487. return node.update(ownerID, shift, keyHash, key, value, didChangeSize, didAlter);
  13488. }
  13489. function isLeafNode(node) {
  13490. return node.constructor === ValueNode || node.constructor === HashCollisionNode;
  13491. }
  13492. function mergeIntoNode(node, ownerID, shift, keyHash, entry) {
  13493. if (node.keyHash === keyHash) {
  13494. return new HashCollisionNode(ownerID, keyHash, [node.entry, entry]);
  13495. }
  13496. var idx1 = (shift === 0 ? node.keyHash : node.keyHash >>> shift) & MASK;
  13497. var idx2 = (shift === 0 ? keyHash : keyHash >>> shift) & MASK;
  13498. var newNode;
  13499. var nodes = idx1 === idx2 ?
  13500. [mergeIntoNode(node, ownerID, shift + SHIFT, keyHash, entry)] :
  13501. ((newNode = new ValueNode(ownerID, keyHash, entry)), idx1 < idx2 ? [node, newNode] : [newNode, node]);
  13502. return new BitmapIndexedNode(ownerID, (1 << idx1) | (1 << idx2), nodes);
  13503. }
  13504. function createNodes(ownerID, entries, key, value) {
  13505. if (!ownerID) {
  13506. ownerID = new OwnerID();
  13507. }
  13508. var node = new ValueNode(ownerID, hash(key), [key, value]);
  13509. for (var ii = 0; ii < entries.length; ii++) {
  13510. var entry = entries[ii];
  13511. node = node.update(ownerID, 0, undefined, entry[0], entry[1]);
  13512. }
  13513. return node;
  13514. }
  13515. function packNodes(ownerID, nodes, count, excluding) {
  13516. var bitmap = 0;
  13517. var packedII = 0;
  13518. var packedNodes = new Array(count);
  13519. for (var ii = 0, bit = 1, len = nodes.length; ii < len; ii++, bit <<= 1) {
  13520. var node = nodes[ii];
  13521. if (node !== undefined && ii !== excluding) {
  13522. bitmap |= bit;
  13523. packedNodes[packedII++] = node;
  13524. }
  13525. }
  13526. return new BitmapIndexedNode(ownerID, bitmap, packedNodes);
  13527. }
  13528. function expandNodes(ownerID, nodes, bitmap, including, node) {
  13529. var count = 0;
  13530. var expandedNodes = new Array(SIZE);
  13531. for (var ii = 0; bitmap !== 0; ii++, bitmap >>>= 1) {
  13532. expandedNodes[ii] = bitmap & 1 ? nodes[count++] : undefined;
  13533. }
  13534. expandedNodes[including] = node;
  13535. return new HashArrayMapNode(ownerID, count + 1, expandedNodes);
  13536. }
  13537. function mergeIntoMapWith(map, merger, iterables) {
  13538. var iters = [];
  13539. for (var ii = 0; ii < iterables.length; ii++) {
  13540. var value = iterables[ii];
  13541. var iter = KeyedIterable(value);
  13542. if (!isIterable(value)) {
  13543. iter = iter.map(function(v ) {return fromJS(v)});
  13544. }
  13545. iters.push(iter);
  13546. }
  13547. return mergeIntoCollectionWith(map, merger, iters);
  13548. }
  13549. function deepMerger(existing, value, key) {
  13550. return existing && existing.mergeDeep && isIterable(value) ?
  13551. existing.mergeDeep(value) :
  13552. is(existing, value) ? existing : value;
  13553. }
  13554. function deepMergerWith(merger) {
  13555. return function(existing, value, key) {
  13556. if (existing && existing.mergeDeepWith && isIterable(value)) {
  13557. return existing.mergeDeepWith(merger, value);
  13558. }
  13559. var nextValue = merger(existing, value, key);
  13560. return is(existing, nextValue) ? existing : nextValue;
  13561. };
  13562. }
  13563. function mergeIntoCollectionWith(collection, merger, iters) {
  13564. iters = iters.filter(function(x ) {return x.size !== 0});
  13565. if (iters.length === 0) {
  13566. return collection;
  13567. }
  13568. if (collection.size === 0 && !collection.__ownerID && iters.length === 1) {
  13569. return collection.constructor(iters[0]);
  13570. }
  13571. return collection.withMutations(function(collection ) {
  13572. var mergeIntoMap = merger ?
  13573. function(value, key) {
  13574. collection.update(key, NOT_SET, function(existing )
  13575. {return existing === NOT_SET ? value : merger(existing, value, key)}
  13576. );
  13577. } :
  13578. function(value, key) {
  13579. collection.set(key, value);
  13580. };
  13581. for (var ii = 0; ii < iters.length; ii++) {
  13582. iters[ii].forEach(mergeIntoMap);
  13583. }
  13584. });
  13585. }
  13586. function updateInDeepMap(existing, keyPathIter, notSetValue, updater) {
  13587. var isNotSet = existing === NOT_SET;
  13588. var step = keyPathIter.next();
  13589. if (step.done) {
  13590. var existingValue = isNotSet ? notSetValue : existing;
  13591. var newValue = updater(existingValue);
  13592. return newValue === existingValue ? existing : newValue;
  13593. }
  13594. invariant(
  13595. isNotSet || (existing && existing.set),
  13596. 'invalid keyPath'
  13597. );
  13598. var key = step.value;
  13599. var nextExisting = isNotSet ? NOT_SET : existing.get(key, NOT_SET);
  13600. var nextUpdated = updateInDeepMap(
  13601. nextExisting,
  13602. keyPathIter,
  13603. notSetValue,
  13604. updater
  13605. );
  13606. return nextUpdated === nextExisting ? existing :
  13607. nextUpdated === NOT_SET ? existing.remove(key) :
  13608. (isNotSet ? emptyMap() : existing).set(key, nextUpdated);
  13609. }
  13610. function popCount(x) {
  13611. x = x - ((x >> 1) & 0x55555555);
  13612. x = (x & 0x33333333) + ((x >> 2) & 0x33333333);
  13613. x = (x + (x >> 4)) & 0x0f0f0f0f;
  13614. x = x + (x >> 8);
  13615. x = x + (x >> 16);
  13616. return x & 0x7f;
  13617. }
  13618. function setIn(array, idx, val, canEdit) {
  13619. var newArray = canEdit ? array : arrCopy(array);
  13620. newArray[idx] = val;
  13621. return newArray;
  13622. }
  13623. function spliceIn(array, idx, val, canEdit) {
  13624. var newLen = array.length + 1;
  13625. if (canEdit && idx + 1 === newLen) {
  13626. array[idx] = val;
  13627. return array;
  13628. }
  13629. var newArray = new Array(newLen);
  13630. var after = 0;
  13631. for (var ii = 0; ii < newLen; ii++) {
  13632. if (ii === idx) {
  13633. newArray[ii] = val;
  13634. after = -1;
  13635. } else {
  13636. newArray[ii] = array[ii + after];
  13637. }
  13638. }
  13639. return newArray;
  13640. }
  13641. function spliceOut(array, idx, canEdit) {
  13642. var newLen = array.length - 1;
  13643. if (canEdit && idx === newLen) {
  13644. array.pop();
  13645. return array;
  13646. }
  13647. var newArray = new Array(newLen);
  13648. var after = 0;
  13649. for (var ii = 0; ii < newLen; ii++) {
  13650. if (ii === idx) {
  13651. after = 1;
  13652. }
  13653. newArray[ii] = array[ii + after];
  13654. }
  13655. return newArray;
  13656. }
  13657. var MAX_ARRAY_MAP_SIZE = SIZE / 4;
  13658. var MAX_BITMAP_INDEXED_SIZE = SIZE / 2;
  13659. var MIN_HASH_ARRAY_MAP_SIZE = SIZE / 4;
  13660. createClass(List, IndexedCollection);
  13661. // @pragma Construction
  13662. function List(value) {
  13663. var empty = emptyList();
  13664. if (value === null || value === undefined) {
  13665. return empty;
  13666. }
  13667. if (isList(value)) {
  13668. return value;
  13669. }
  13670. var iter = IndexedIterable(value);
  13671. var size = iter.size;
  13672. if (size === 0) {
  13673. return empty;
  13674. }
  13675. assertNotInfinite(size);
  13676. if (size > 0 && size < SIZE) {
  13677. return makeList(0, size, SHIFT, null, new VNode(iter.toArray()));
  13678. }
  13679. return empty.withMutations(function(list ) {
  13680. list.setSize(size);
  13681. iter.forEach(function(v, i) {return list.set(i, v)});
  13682. });
  13683. }
  13684. List.of = function(/*...values*/) {
  13685. return this(arguments);
  13686. };
  13687. List.prototype.toString = function() {
  13688. return this.__toString('List [', ']');
  13689. };
  13690. // @pragma Access
  13691. List.prototype.get = function(index, notSetValue) {
  13692. index = wrapIndex(this, index);
  13693. if (index >= 0 && index < this.size) {
  13694. index += this._origin;
  13695. var node = listNodeFor(this, index);
  13696. return node && node.array[index & MASK];
  13697. }
  13698. return notSetValue;
  13699. };
  13700. // @pragma Modification
  13701. List.prototype.set = function(index, value) {
  13702. return updateList(this, index, value);
  13703. };
  13704. List.prototype.remove = function(index) {
  13705. return !this.has(index) ? this :
  13706. index === 0 ? this.shift() :
  13707. index === this.size - 1 ? this.pop() :
  13708. this.splice(index, 1);
  13709. };
  13710. List.prototype.insert = function(index, value) {
  13711. return this.splice(index, 0, value);
  13712. };
  13713. List.prototype.clear = function() {
  13714. if (this.size === 0) {
  13715. return this;
  13716. }
  13717. if (this.__ownerID) {
  13718. this.size = this._origin = this._capacity = 0;
  13719. this._level = SHIFT;
  13720. this._root = this._tail = null;
  13721. this.__hash = undefined;
  13722. this.__altered = true;
  13723. return this;
  13724. }
  13725. return emptyList();
  13726. };
  13727. List.prototype.push = function(/*...values*/) {
  13728. var values = arguments;
  13729. var oldSize = this.size;
  13730. return this.withMutations(function(list ) {
  13731. setListBounds(list, 0, oldSize + values.length);
  13732. for (var ii = 0; ii < values.length; ii++) {
  13733. list.set(oldSize + ii, values[ii]);
  13734. }
  13735. });
  13736. };
  13737. List.prototype.pop = function() {
  13738. return setListBounds(this, 0, -1);
  13739. };
  13740. List.prototype.unshift = function(/*...values*/) {
  13741. var values = arguments;
  13742. return this.withMutations(function(list ) {
  13743. setListBounds(list, -values.length);
  13744. for (var ii = 0; ii < values.length; ii++) {
  13745. list.set(ii, values[ii]);
  13746. }
  13747. });
  13748. };
  13749. List.prototype.shift = function() {
  13750. return setListBounds(this, 1);
  13751. };
  13752. // @pragma Composition
  13753. List.prototype.merge = function(/*...iters*/) {
  13754. return mergeIntoListWith(this, undefined, arguments);
  13755. };
  13756. List.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  13757. return mergeIntoListWith(this, merger, iters);
  13758. };
  13759. List.prototype.mergeDeep = function(/*...iters*/) {
  13760. return mergeIntoListWith(this, deepMerger, arguments);
  13761. };
  13762. List.prototype.mergeDeepWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  13763. return mergeIntoListWith(this, deepMergerWith(merger), iters);
  13764. };
  13765. List.prototype.setSize = function(size) {
  13766. return setListBounds(this, 0, size);
  13767. };
  13768. // @pragma Iteration
  13769. List.prototype.slice = function(begin, end) {
  13770. var size = this.size;
  13771. if (wholeSlice(begin, end, size)) {
  13772. return this;
  13773. }
  13774. return setListBounds(
  13775. this,
  13776. resolveBegin(begin, size),
  13777. resolveEnd(end, size)
  13778. );
  13779. };
  13780. List.prototype.__iterator = function(type, reverse) {
  13781. var index = 0;
  13782. var values = iterateList(this, reverse);
  13783. return new Iterator(function() {
  13784. var value = values();
  13785. return value === DONE ?
  13786. iteratorDone() :
  13787. iteratorValue(type, index++, value);
  13788. });
  13789. };
  13790. List.prototype.__iterate = function(fn, reverse) {
  13791. var index = 0;
  13792. var values = iterateList(this, reverse);
  13793. var value;
  13794. while ((value = values()) !== DONE) {
  13795. if (fn(value, index++, this) === false) {
  13796. break;
  13797. }
  13798. }
  13799. return index;
  13800. };
  13801. List.prototype.__ensureOwner = function(ownerID) {
  13802. if (ownerID === this.__ownerID) {
  13803. return this;
  13804. }
  13805. if (!ownerID) {
  13806. this.__ownerID = ownerID;
  13807. return this;
  13808. }
  13809. return makeList(this._origin, this._capacity, this._level, this._root, this._tail, ownerID, this.__hash);
  13810. };
  13811. function isList(maybeList) {
  13812. return !!(maybeList && maybeList[IS_LIST_SENTINEL]);
  13813. }
  13814. List.isList = isList;
  13815. var IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
  13816. var ListPrototype = List.prototype;
  13817. ListPrototype[IS_LIST_SENTINEL] = true;
  13818. ListPrototype[DELETE] = ListPrototype.remove;
  13819. ListPrototype.setIn = MapPrototype.setIn;
  13820. ListPrototype.deleteIn =
  13821. ListPrototype.removeIn = MapPrototype.removeIn;
  13822. ListPrototype.update = MapPrototype.update;
  13823. ListPrototype.updateIn = MapPrototype.updateIn;
  13824. ListPrototype.mergeIn = MapPrototype.mergeIn;
  13825. ListPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  13826. ListPrototype.withMutations = MapPrototype.withMutations;
  13827. ListPrototype.asMutable = MapPrototype.asMutable;
  13828. ListPrototype.asImmutable = MapPrototype.asImmutable;
  13829. ListPrototype.wasAltered = MapPrototype.wasAltered;
  13830. function VNode(array, ownerID) {
  13831. this.array = array;
  13832. this.ownerID = ownerID;
  13833. }
  13834. // TODO: seems like these methods are very similar
  13835. VNode.prototype.removeBefore = function(ownerID, level, index) {
  13836. if (index === level ? 1 << level : this.array.length === 0) {
  13837. return this;
  13838. }
  13839. var originIndex = (index >>> level) & MASK;
  13840. if (originIndex >= this.array.length) {
  13841. return new VNode([], ownerID);
  13842. }
  13843. var removingFirst = originIndex === 0;
  13844. var newChild;
  13845. if (level > 0) {
  13846. var oldChild = this.array[originIndex];
  13847. newChild = oldChild && oldChild.removeBefore(ownerID, level - SHIFT, index);
  13848. if (newChild === oldChild && removingFirst) {
  13849. return this;
  13850. }
  13851. }
  13852. if (removingFirst && !newChild) {
  13853. return this;
  13854. }
  13855. var editable = editableVNode(this, ownerID);
  13856. if (!removingFirst) {
  13857. for (var ii = 0; ii < originIndex; ii++) {
  13858. editable.array[ii] = undefined;
  13859. }
  13860. }
  13861. if (newChild) {
  13862. editable.array[originIndex] = newChild;
  13863. }
  13864. return editable;
  13865. };
  13866. VNode.prototype.removeAfter = function(ownerID, level, index) {
  13867. if (index === (level ? 1 << level : 0) || this.array.length === 0) {
  13868. return this;
  13869. }
  13870. var sizeIndex = ((index - 1) >>> level) & MASK;
  13871. if (sizeIndex >= this.array.length) {
  13872. return this;
  13873. }
  13874. var newChild;
  13875. if (level > 0) {
  13876. var oldChild = this.array[sizeIndex];
  13877. newChild = oldChild && oldChild.removeAfter(ownerID, level - SHIFT, index);
  13878. if (newChild === oldChild && sizeIndex === this.array.length - 1) {
  13879. return this;
  13880. }
  13881. }
  13882. var editable = editableVNode(this, ownerID);
  13883. editable.array.splice(sizeIndex + 1);
  13884. if (newChild) {
  13885. editable.array[sizeIndex] = newChild;
  13886. }
  13887. return editable;
  13888. };
  13889. var DONE = {};
  13890. function iterateList(list, reverse) {
  13891. var left = list._origin;
  13892. var right = list._capacity;
  13893. var tailPos = getTailOffset(right);
  13894. var tail = list._tail;
  13895. return iterateNodeOrLeaf(list._root, list._level, 0);
  13896. function iterateNodeOrLeaf(node, level, offset) {
  13897. return level === 0 ?
  13898. iterateLeaf(node, offset) :
  13899. iterateNode(node, level, offset);
  13900. }
  13901. function iterateLeaf(node, offset) {
  13902. var array = offset === tailPos ? tail && tail.array : node && node.array;
  13903. var from = offset > left ? 0 : left - offset;
  13904. var to = right - offset;
  13905. if (to > SIZE) {
  13906. to = SIZE;
  13907. }
  13908. return function() {
  13909. if (from === to) {
  13910. return DONE;
  13911. }
  13912. var idx = reverse ? --to : from++;
  13913. return array && array[idx];
  13914. };
  13915. }
  13916. function iterateNode(node, level, offset) {
  13917. var values;
  13918. var array = node && node.array;
  13919. var from = offset > left ? 0 : (left - offset) >> level;
  13920. var to = ((right - offset) >> level) + 1;
  13921. if (to > SIZE) {
  13922. to = SIZE;
  13923. }
  13924. return function() {
  13925. do {
  13926. if (values) {
  13927. var value = values();
  13928. if (value !== DONE) {
  13929. return value;
  13930. }
  13931. values = null;
  13932. }
  13933. if (from === to) {
  13934. return DONE;
  13935. }
  13936. var idx = reverse ? --to : from++;
  13937. values = iterateNodeOrLeaf(
  13938. array && array[idx], level - SHIFT, offset + (idx << level)
  13939. );
  13940. } while (true);
  13941. };
  13942. }
  13943. }
  13944. function makeList(origin, capacity, level, root, tail, ownerID, hash) {
  13945. var list = Object.create(ListPrototype);
  13946. list.size = capacity - origin;
  13947. list._origin = origin;
  13948. list._capacity = capacity;
  13949. list._level = level;
  13950. list._root = root;
  13951. list._tail = tail;
  13952. list.__ownerID = ownerID;
  13953. list.__hash = hash;
  13954. list.__altered = false;
  13955. return list;
  13956. }
  13957. var EMPTY_LIST;
  13958. function emptyList() {
  13959. return EMPTY_LIST || (EMPTY_LIST = makeList(0, 0, SHIFT));
  13960. }
  13961. function updateList(list, index, value) {
  13962. index = wrapIndex(list, index);
  13963. if (index !== index) {
  13964. return list;
  13965. }
  13966. if (index >= list.size || index < 0) {
  13967. return list.withMutations(function(list ) {
  13968. index < 0 ?
  13969. setListBounds(list, index).set(0, value) :
  13970. setListBounds(list, 0, index + 1).set(index, value);
  13971. });
  13972. }
  13973. index += list._origin;
  13974. var newTail = list._tail;
  13975. var newRoot = list._root;
  13976. var didAlter = MakeRef(DID_ALTER);
  13977. if (index >= getTailOffset(list._capacity)) {
  13978. newTail = updateVNode(newTail, list.__ownerID, 0, index, value, didAlter);
  13979. } else {
  13980. newRoot = updateVNode(newRoot, list.__ownerID, list._level, index, value, didAlter);
  13981. }
  13982. if (!didAlter.value) {
  13983. return list;
  13984. }
  13985. if (list.__ownerID) {
  13986. list._root = newRoot;
  13987. list._tail = newTail;
  13988. list.__hash = undefined;
  13989. list.__altered = true;
  13990. return list;
  13991. }
  13992. return makeList(list._origin, list._capacity, list._level, newRoot, newTail);
  13993. }
  13994. function updateVNode(node, ownerID, level, index, value, didAlter) {
  13995. var idx = (index >>> level) & MASK;
  13996. var nodeHas = node && idx < node.array.length;
  13997. if (!nodeHas && value === undefined) {
  13998. return node;
  13999. }
  14000. var newNode;
  14001. if (level > 0) {
  14002. var lowerNode = node && node.array[idx];
  14003. var newLowerNode = updateVNode(lowerNode, ownerID, level - SHIFT, index, value, didAlter);
  14004. if (newLowerNode === lowerNode) {
  14005. return node;
  14006. }
  14007. newNode = editableVNode(node, ownerID);
  14008. newNode.array[idx] = newLowerNode;
  14009. return newNode;
  14010. }
  14011. if (nodeHas && node.array[idx] === value) {
  14012. return node;
  14013. }
  14014. SetRef(didAlter);
  14015. newNode = editableVNode(node, ownerID);
  14016. if (value === undefined && idx === newNode.array.length - 1) {
  14017. newNode.array.pop();
  14018. } else {
  14019. newNode.array[idx] = value;
  14020. }
  14021. return newNode;
  14022. }
  14023. function editableVNode(node, ownerID) {
  14024. if (ownerID && node && ownerID === node.ownerID) {
  14025. return node;
  14026. }
  14027. return new VNode(node ? node.array.slice() : [], ownerID);
  14028. }
  14029. function listNodeFor(list, rawIndex) {
  14030. if (rawIndex >= getTailOffset(list._capacity)) {
  14031. return list._tail;
  14032. }
  14033. if (rawIndex < 1 << (list._level + SHIFT)) {
  14034. var node = list._root;
  14035. var level = list._level;
  14036. while (node && level > 0) {
  14037. node = node.array[(rawIndex >>> level) & MASK];
  14038. level -= SHIFT;
  14039. }
  14040. return node;
  14041. }
  14042. }
  14043. function setListBounds(list, begin, end) {
  14044. // Sanitize begin & end using this shorthand for ToInt32(argument)
  14045. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  14046. if (begin !== undefined) {
  14047. begin = begin | 0;
  14048. }
  14049. if (end !== undefined) {
  14050. end = end | 0;
  14051. }
  14052. var owner = list.__ownerID || new OwnerID();
  14053. var oldOrigin = list._origin;
  14054. var oldCapacity = list._capacity;
  14055. var newOrigin = oldOrigin + begin;
  14056. var newCapacity = end === undefined ? oldCapacity : end < 0 ? oldCapacity + end : oldOrigin + end;
  14057. if (newOrigin === oldOrigin && newCapacity === oldCapacity) {
  14058. return list;
  14059. }
  14060. // If it's going to end after it starts, it's empty.
  14061. if (newOrigin >= newCapacity) {
  14062. return list.clear();
  14063. }
  14064. var newLevel = list._level;
  14065. var newRoot = list._root;
  14066. // New origin might need creating a higher root.
  14067. var offsetShift = 0;
  14068. while (newOrigin + offsetShift < 0) {
  14069. newRoot = new VNode(newRoot && newRoot.array.length ? [undefined, newRoot] : [], owner);
  14070. newLevel += SHIFT;
  14071. offsetShift += 1 << newLevel;
  14072. }
  14073. if (offsetShift) {
  14074. newOrigin += offsetShift;
  14075. oldOrigin += offsetShift;
  14076. newCapacity += offsetShift;
  14077. oldCapacity += offsetShift;
  14078. }
  14079. var oldTailOffset = getTailOffset(oldCapacity);
  14080. var newTailOffset = getTailOffset(newCapacity);
  14081. // New size might need creating a higher root.
  14082. while (newTailOffset >= 1 << (newLevel + SHIFT)) {
  14083. newRoot = new VNode(newRoot && newRoot.array.length ? [newRoot] : [], owner);
  14084. newLevel += SHIFT;
  14085. }
  14086. // Locate or create the new tail.
  14087. var oldTail = list._tail;
  14088. var newTail = newTailOffset < oldTailOffset ?
  14089. listNodeFor(list, newCapacity - 1) :
  14090. newTailOffset > oldTailOffset ? new VNode([], owner) : oldTail;
  14091. // Merge Tail into tree.
  14092. if (oldTail && newTailOffset > oldTailOffset && newOrigin < oldCapacity && oldTail.array.length) {
  14093. newRoot = editableVNode(newRoot, owner);
  14094. var node = newRoot;
  14095. for (var level = newLevel; level > SHIFT; level -= SHIFT) {
  14096. var idx = (oldTailOffset >>> level) & MASK;
  14097. node = node.array[idx] = editableVNode(node.array[idx], owner);
  14098. }
  14099. node.array[(oldTailOffset >>> SHIFT) & MASK] = oldTail;
  14100. }
  14101. // If the size has been reduced, there's a chance the tail needs to be trimmed.
  14102. if (newCapacity < oldCapacity) {
  14103. newTail = newTail && newTail.removeAfter(owner, 0, newCapacity);
  14104. }
  14105. // If the new origin is within the tail, then we do not need a root.
  14106. if (newOrigin >= newTailOffset) {
  14107. newOrigin -= newTailOffset;
  14108. newCapacity -= newTailOffset;
  14109. newLevel = SHIFT;
  14110. newRoot = null;
  14111. newTail = newTail && newTail.removeBefore(owner, 0, newOrigin);
  14112. // Otherwise, if the root has been trimmed, garbage collect.
  14113. } else if (newOrigin > oldOrigin || newTailOffset < oldTailOffset) {
  14114. offsetShift = 0;
  14115. // Identify the new top root node of the subtree of the old root.
  14116. while (newRoot) {
  14117. var beginIndex = (newOrigin >>> newLevel) & MASK;
  14118. if (beginIndex !== (newTailOffset >>> newLevel) & MASK) {
  14119. break;
  14120. }
  14121. if (beginIndex) {
  14122. offsetShift += (1 << newLevel) * beginIndex;
  14123. }
  14124. newLevel -= SHIFT;
  14125. newRoot = newRoot.array[beginIndex];
  14126. }
  14127. // Trim the new sides of the new root.
  14128. if (newRoot && newOrigin > oldOrigin) {
  14129. newRoot = newRoot.removeBefore(owner, newLevel, newOrigin - offsetShift);
  14130. }
  14131. if (newRoot && newTailOffset < oldTailOffset) {
  14132. newRoot = newRoot.removeAfter(owner, newLevel, newTailOffset - offsetShift);
  14133. }
  14134. if (offsetShift) {
  14135. newOrigin -= offsetShift;
  14136. newCapacity -= offsetShift;
  14137. }
  14138. }
  14139. if (list.__ownerID) {
  14140. list.size = newCapacity - newOrigin;
  14141. list._origin = newOrigin;
  14142. list._capacity = newCapacity;
  14143. list._level = newLevel;
  14144. list._root = newRoot;
  14145. list._tail = newTail;
  14146. list.__hash = undefined;
  14147. list.__altered = true;
  14148. return list;
  14149. }
  14150. return makeList(newOrigin, newCapacity, newLevel, newRoot, newTail);
  14151. }
  14152. function mergeIntoListWith(list, merger, iterables) {
  14153. var iters = [];
  14154. var maxSize = 0;
  14155. for (var ii = 0; ii < iterables.length; ii++) {
  14156. var value = iterables[ii];
  14157. var iter = IndexedIterable(value);
  14158. if (iter.size > maxSize) {
  14159. maxSize = iter.size;
  14160. }
  14161. if (!isIterable(value)) {
  14162. iter = iter.map(function(v ) {return fromJS(v)});
  14163. }
  14164. iters.push(iter);
  14165. }
  14166. if (maxSize > list.size) {
  14167. list = list.setSize(maxSize);
  14168. }
  14169. return mergeIntoCollectionWith(list, merger, iters);
  14170. }
  14171. function getTailOffset(size) {
  14172. return size < SIZE ? 0 : (((size - 1) >>> SHIFT) << SHIFT);
  14173. }
  14174. createClass(OrderedMap, Map);
  14175. // @pragma Construction
  14176. function OrderedMap(value) {
  14177. return value === null || value === undefined ? emptyOrderedMap() :
  14178. isOrderedMap(value) ? value :
  14179. emptyOrderedMap().withMutations(function(map ) {
  14180. var iter = KeyedIterable(value);
  14181. assertNotInfinite(iter.size);
  14182. iter.forEach(function(v, k) {return map.set(k, v)});
  14183. });
  14184. }
  14185. OrderedMap.of = function(/*...values*/) {
  14186. return this(arguments);
  14187. };
  14188. OrderedMap.prototype.toString = function() {
  14189. return this.__toString('OrderedMap {', '}');
  14190. };
  14191. // @pragma Access
  14192. OrderedMap.prototype.get = function(k, notSetValue) {
  14193. var index = this._map.get(k);
  14194. return index !== undefined ? this._list.get(index)[1] : notSetValue;
  14195. };
  14196. // @pragma Modification
  14197. OrderedMap.prototype.clear = function() {
  14198. if (this.size === 0) {
  14199. return this;
  14200. }
  14201. if (this.__ownerID) {
  14202. this.size = 0;
  14203. this._map.clear();
  14204. this._list.clear();
  14205. return this;
  14206. }
  14207. return emptyOrderedMap();
  14208. };
  14209. OrderedMap.prototype.set = function(k, v) {
  14210. return updateOrderedMap(this, k, v);
  14211. };
  14212. OrderedMap.prototype.remove = function(k) {
  14213. return updateOrderedMap(this, k, NOT_SET);
  14214. };
  14215. OrderedMap.prototype.wasAltered = function() {
  14216. return this._map.wasAltered() || this._list.wasAltered();
  14217. };
  14218. OrderedMap.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  14219. return this._list.__iterate(
  14220. function(entry ) {return entry && fn(entry[1], entry[0], this$0)},
  14221. reverse
  14222. );
  14223. };
  14224. OrderedMap.prototype.__iterator = function(type, reverse) {
  14225. return this._list.fromEntrySeq().__iterator(type, reverse);
  14226. };
  14227. OrderedMap.prototype.__ensureOwner = function(ownerID) {
  14228. if (ownerID === this.__ownerID) {
  14229. return this;
  14230. }
  14231. var newMap = this._map.__ensureOwner(ownerID);
  14232. var newList = this._list.__ensureOwner(ownerID);
  14233. if (!ownerID) {
  14234. this.__ownerID = ownerID;
  14235. this._map = newMap;
  14236. this._list = newList;
  14237. return this;
  14238. }
  14239. return makeOrderedMap(newMap, newList, ownerID, this.__hash);
  14240. };
  14241. function isOrderedMap(maybeOrderedMap) {
  14242. return isMap(maybeOrderedMap) && isOrdered(maybeOrderedMap);
  14243. }
  14244. OrderedMap.isOrderedMap = isOrderedMap;
  14245. OrderedMap.prototype[IS_ORDERED_SENTINEL] = true;
  14246. OrderedMap.prototype[DELETE] = OrderedMap.prototype.remove;
  14247. function makeOrderedMap(map, list, ownerID, hash) {
  14248. var omap = Object.create(OrderedMap.prototype);
  14249. omap.size = map ? map.size : 0;
  14250. omap._map = map;
  14251. omap._list = list;
  14252. omap.__ownerID = ownerID;
  14253. omap.__hash = hash;
  14254. return omap;
  14255. }
  14256. var EMPTY_ORDERED_MAP;
  14257. function emptyOrderedMap() {
  14258. return EMPTY_ORDERED_MAP || (EMPTY_ORDERED_MAP = makeOrderedMap(emptyMap(), emptyList()));
  14259. }
  14260. function updateOrderedMap(omap, k, v) {
  14261. var map = omap._map;
  14262. var list = omap._list;
  14263. var i = map.get(k);
  14264. var has = i !== undefined;
  14265. var newMap;
  14266. var newList;
  14267. if (v === NOT_SET) { // removed
  14268. if (!has) {
  14269. return omap;
  14270. }
  14271. if (list.size >= SIZE && list.size >= map.size * 2) {
  14272. newList = list.filter(function(entry, idx) {return entry !== undefined && i !== idx});
  14273. newMap = newList.toKeyedSeq().map(function(entry ) {return entry[0]}).flip().toMap();
  14274. if (omap.__ownerID) {
  14275. newMap.__ownerID = newList.__ownerID = omap.__ownerID;
  14276. }
  14277. } else {
  14278. newMap = map.remove(k);
  14279. newList = i === list.size - 1 ? list.pop() : list.set(i, undefined);
  14280. }
  14281. } else {
  14282. if (has) {
  14283. if (v === list.get(i)[1]) {
  14284. return omap;
  14285. }
  14286. newMap = map;
  14287. newList = list.set(i, [k, v]);
  14288. } else {
  14289. newMap = map.set(k, list.size);
  14290. newList = list.set(list.size, [k, v]);
  14291. }
  14292. }
  14293. if (omap.__ownerID) {
  14294. omap.size = newMap.size;
  14295. omap._map = newMap;
  14296. omap._list = newList;
  14297. omap.__hash = undefined;
  14298. return omap;
  14299. }
  14300. return makeOrderedMap(newMap, newList);
  14301. }
  14302. createClass(ToKeyedSequence, KeyedSeq);
  14303. function ToKeyedSequence(indexed, useKeys) {
  14304. this._iter = indexed;
  14305. this._useKeys = useKeys;
  14306. this.size = indexed.size;
  14307. }
  14308. ToKeyedSequence.prototype.get = function(key, notSetValue) {
  14309. return this._iter.get(key, notSetValue);
  14310. };
  14311. ToKeyedSequence.prototype.has = function(key) {
  14312. return this._iter.has(key);
  14313. };
  14314. ToKeyedSequence.prototype.valueSeq = function() {
  14315. return this._iter.valueSeq();
  14316. };
  14317. ToKeyedSequence.prototype.reverse = function() {var this$0 = this;
  14318. var reversedSequence = reverseFactory(this, true);
  14319. if (!this._useKeys) {
  14320. reversedSequence.valueSeq = function() {return this$0._iter.toSeq().reverse()};
  14321. }
  14322. return reversedSequence;
  14323. };
  14324. ToKeyedSequence.prototype.map = function(mapper, context) {var this$0 = this;
  14325. var mappedSequence = mapFactory(this, mapper, context);
  14326. if (!this._useKeys) {
  14327. mappedSequence.valueSeq = function() {return this$0._iter.toSeq().map(mapper, context)};
  14328. }
  14329. return mappedSequence;
  14330. };
  14331. ToKeyedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  14332. var ii;
  14333. return this._iter.__iterate(
  14334. this._useKeys ?
  14335. function(v, k) {return fn(v, k, this$0)} :
  14336. ((ii = reverse ? resolveSize(this) : 0),
  14337. function(v ) {return fn(v, reverse ? --ii : ii++, this$0)}),
  14338. reverse
  14339. );
  14340. };
  14341. ToKeyedSequence.prototype.__iterator = function(type, reverse) {
  14342. if (this._useKeys) {
  14343. return this._iter.__iterator(type, reverse);
  14344. }
  14345. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  14346. var ii = reverse ? resolveSize(this) : 0;
  14347. return new Iterator(function() {
  14348. var step = iterator.next();
  14349. return step.done ? step :
  14350. iteratorValue(type, reverse ? --ii : ii++, step.value, step);
  14351. });
  14352. };
  14353. ToKeyedSequence.prototype[IS_ORDERED_SENTINEL] = true;
  14354. createClass(ToIndexedSequence, IndexedSeq);
  14355. function ToIndexedSequence(iter) {
  14356. this._iter = iter;
  14357. this.size = iter.size;
  14358. }
  14359. ToIndexedSequence.prototype.includes = function(value) {
  14360. return this._iter.includes(value);
  14361. };
  14362. ToIndexedSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  14363. var iterations = 0;
  14364. return this._iter.__iterate(function(v ) {return fn(v, iterations++, this$0)}, reverse);
  14365. };
  14366. ToIndexedSequence.prototype.__iterator = function(type, reverse) {
  14367. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  14368. var iterations = 0;
  14369. return new Iterator(function() {
  14370. var step = iterator.next();
  14371. return step.done ? step :
  14372. iteratorValue(type, iterations++, step.value, step)
  14373. });
  14374. };
  14375. createClass(ToSetSequence, SetSeq);
  14376. function ToSetSequence(iter) {
  14377. this._iter = iter;
  14378. this.size = iter.size;
  14379. }
  14380. ToSetSequence.prototype.has = function(key) {
  14381. return this._iter.includes(key);
  14382. };
  14383. ToSetSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  14384. return this._iter.__iterate(function(v ) {return fn(v, v, this$0)}, reverse);
  14385. };
  14386. ToSetSequence.prototype.__iterator = function(type, reverse) {
  14387. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  14388. return new Iterator(function() {
  14389. var step = iterator.next();
  14390. return step.done ? step :
  14391. iteratorValue(type, step.value, step.value, step);
  14392. });
  14393. };
  14394. createClass(FromEntriesSequence, KeyedSeq);
  14395. function FromEntriesSequence(entries) {
  14396. this._iter = entries;
  14397. this.size = entries.size;
  14398. }
  14399. FromEntriesSequence.prototype.entrySeq = function() {
  14400. return this._iter.toSeq();
  14401. };
  14402. FromEntriesSequence.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  14403. return this._iter.__iterate(function(entry ) {
  14404. // Check if entry exists first so array access doesn't throw for holes
  14405. // in the parent iteration.
  14406. if (entry) {
  14407. validateEntry(entry);
  14408. var indexedIterable = isIterable(entry);
  14409. return fn(
  14410. indexedIterable ? entry.get(1) : entry[1],
  14411. indexedIterable ? entry.get(0) : entry[0],
  14412. this$0
  14413. );
  14414. }
  14415. }, reverse);
  14416. };
  14417. FromEntriesSequence.prototype.__iterator = function(type, reverse) {
  14418. var iterator = this._iter.__iterator(ITERATE_VALUES, reverse);
  14419. return new Iterator(function() {
  14420. while (true) {
  14421. var step = iterator.next();
  14422. if (step.done) {
  14423. return step;
  14424. }
  14425. var entry = step.value;
  14426. // Check if entry exists first so array access doesn't throw for holes
  14427. // in the parent iteration.
  14428. if (entry) {
  14429. validateEntry(entry);
  14430. var indexedIterable = isIterable(entry);
  14431. return iteratorValue(
  14432. type,
  14433. indexedIterable ? entry.get(0) : entry[0],
  14434. indexedIterable ? entry.get(1) : entry[1],
  14435. step
  14436. );
  14437. }
  14438. }
  14439. });
  14440. };
  14441. ToIndexedSequence.prototype.cacheResult =
  14442. ToKeyedSequence.prototype.cacheResult =
  14443. ToSetSequence.prototype.cacheResult =
  14444. FromEntriesSequence.prototype.cacheResult =
  14445. cacheResultThrough;
  14446. function flipFactory(iterable) {
  14447. var flipSequence = makeSequence(iterable);
  14448. flipSequence._iter = iterable;
  14449. flipSequence.size = iterable.size;
  14450. flipSequence.flip = function() {return iterable};
  14451. flipSequence.reverse = function () {
  14452. var reversedSequence = iterable.reverse.apply(this); // super.reverse()
  14453. reversedSequence.flip = function() {return iterable.reverse()};
  14454. return reversedSequence;
  14455. };
  14456. flipSequence.has = function(key ) {return iterable.includes(key)};
  14457. flipSequence.includes = function(key ) {return iterable.has(key)};
  14458. flipSequence.cacheResult = cacheResultThrough;
  14459. flipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  14460. return iterable.__iterate(function(v, k) {return fn(k, v, this$0) !== false}, reverse);
  14461. };
  14462. flipSequence.__iteratorUncached = function(type, reverse) {
  14463. if (type === ITERATE_ENTRIES) {
  14464. var iterator = iterable.__iterator(type, reverse);
  14465. return new Iterator(function() {
  14466. var step = iterator.next();
  14467. if (!step.done) {
  14468. var k = step.value[0];
  14469. step.value[0] = step.value[1];
  14470. step.value[1] = k;
  14471. }
  14472. return step;
  14473. });
  14474. }
  14475. return iterable.__iterator(
  14476. type === ITERATE_VALUES ? ITERATE_KEYS : ITERATE_VALUES,
  14477. reverse
  14478. );
  14479. };
  14480. return flipSequence;
  14481. }
  14482. function mapFactory(iterable, mapper, context) {
  14483. var mappedSequence = makeSequence(iterable);
  14484. mappedSequence.size = iterable.size;
  14485. mappedSequence.has = function(key ) {return iterable.has(key)};
  14486. mappedSequence.get = function(key, notSetValue) {
  14487. var v = iterable.get(key, NOT_SET);
  14488. return v === NOT_SET ?
  14489. notSetValue :
  14490. mapper.call(context, v, key, iterable);
  14491. };
  14492. mappedSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  14493. return iterable.__iterate(
  14494. function(v, k, c) {return fn(mapper.call(context, v, k, c), k, this$0) !== false},
  14495. reverse
  14496. );
  14497. };
  14498. mappedSequence.__iteratorUncached = function (type, reverse) {
  14499. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  14500. return new Iterator(function() {
  14501. var step = iterator.next();
  14502. if (step.done) {
  14503. return step;
  14504. }
  14505. var entry = step.value;
  14506. var key = entry[0];
  14507. return iteratorValue(
  14508. type,
  14509. key,
  14510. mapper.call(context, entry[1], key, iterable),
  14511. step
  14512. );
  14513. });
  14514. };
  14515. return mappedSequence;
  14516. }
  14517. function reverseFactory(iterable, useKeys) {
  14518. var reversedSequence = makeSequence(iterable);
  14519. reversedSequence._iter = iterable;
  14520. reversedSequence.size = iterable.size;
  14521. reversedSequence.reverse = function() {return iterable};
  14522. if (iterable.flip) {
  14523. reversedSequence.flip = function () {
  14524. var flipSequence = flipFactory(iterable);
  14525. flipSequence.reverse = function() {return iterable.flip()};
  14526. return flipSequence;
  14527. };
  14528. }
  14529. reversedSequence.get = function(key, notSetValue)
  14530. {return iterable.get(useKeys ? key : -1 - key, notSetValue)};
  14531. reversedSequence.has = function(key )
  14532. {return iterable.has(useKeys ? key : -1 - key)};
  14533. reversedSequence.includes = function(value ) {return iterable.includes(value)};
  14534. reversedSequence.cacheResult = cacheResultThrough;
  14535. reversedSequence.__iterate = function (fn, reverse) {var this$0 = this;
  14536. return iterable.__iterate(function(v, k) {return fn(v, k, this$0)}, !reverse);
  14537. };
  14538. reversedSequence.__iterator =
  14539. function(type, reverse) {return iterable.__iterator(type, !reverse)};
  14540. return reversedSequence;
  14541. }
  14542. function filterFactory(iterable, predicate, context, useKeys) {
  14543. var filterSequence = makeSequence(iterable);
  14544. if (useKeys) {
  14545. filterSequence.has = function(key ) {
  14546. var v = iterable.get(key, NOT_SET);
  14547. return v !== NOT_SET && !!predicate.call(context, v, key, iterable);
  14548. };
  14549. filterSequence.get = function(key, notSetValue) {
  14550. var v = iterable.get(key, NOT_SET);
  14551. return v !== NOT_SET && predicate.call(context, v, key, iterable) ?
  14552. v : notSetValue;
  14553. };
  14554. }
  14555. filterSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  14556. var iterations = 0;
  14557. iterable.__iterate(function(v, k, c) {
  14558. if (predicate.call(context, v, k, c)) {
  14559. iterations++;
  14560. return fn(v, useKeys ? k : iterations - 1, this$0);
  14561. }
  14562. }, reverse);
  14563. return iterations;
  14564. };
  14565. filterSequence.__iteratorUncached = function (type, reverse) {
  14566. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  14567. var iterations = 0;
  14568. return new Iterator(function() {
  14569. while (true) {
  14570. var step = iterator.next();
  14571. if (step.done) {
  14572. return step;
  14573. }
  14574. var entry = step.value;
  14575. var key = entry[0];
  14576. var value = entry[1];
  14577. if (predicate.call(context, value, key, iterable)) {
  14578. return iteratorValue(type, useKeys ? key : iterations++, value, step);
  14579. }
  14580. }
  14581. });
  14582. };
  14583. return filterSequence;
  14584. }
  14585. function countByFactory(iterable, grouper, context) {
  14586. var groups = Map().asMutable();
  14587. iterable.__iterate(function(v, k) {
  14588. groups.update(
  14589. grouper.call(context, v, k, iterable),
  14590. 0,
  14591. function(a ) {return a + 1}
  14592. );
  14593. });
  14594. return groups.asImmutable();
  14595. }
  14596. function groupByFactory(iterable, grouper, context) {
  14597. var isKeyedIter = isKeyed(iterable);
  14598. var groups = (isOrdered(iterable) ? OrderedMap() : Map()).asMutable();
  14599. iterable.__iterate(function(v, k) {
  14600. groups.update(
  14601. grouper.call(context, v, k, iterable),
  14602. function(a ) {return (a = a || [], a.push(isKeyedIter ? [k, v] : v), a)}
  14603. );
  14604. });
  14605. var coerce = iterableClass(iterable);
  14606. return groups.map(function(arr ) {return reify(iterable, coerce(arr))});
  14607. }
  14608. function sliceFactory(iterable, begin, end, useKeys) {
  14609. var originalSize = iterable.size;
  14610. // Sanitize begin & end using this shorthand for ToInt32(argument)
  14611. // http://www.ecma-international.org/ecma-262/6.0/#sec-toint32
  14612. if (begin !== undefined) {
  14613. begin = begin | 0;
  14614. }
  14615. if (end !== undefined) {
  14616. end = end | 0;
  14617. }
  14618. if (wholeSlice(begin, end, originalSize)) {
  14619. return iterable;
  14620. }
  14621. var resolvedBegin = resolveBegin(begin, originalSize);
  14622. var resolvedEnd = resolveEnd(end, originalSize);
  14623. // begin or end will be NaN if they were provided as negative numbers and
  14624. // this iterable's size is unknown. In that case, cache first so there is
  14625. // a known size and these do not resolve to NaN.
  14626. if (resolvedBegin !== resolvedBegin || resolvedEnd !== resolvedEnd) {
  14627. return sliceFactory(iterable.toSeq().cacheResult(), begin, end, useKeys);
  14628. }
  14629. // Note: resolvedEnd is undefined when the original sequence's length is
  14630. // unknown and this slice did not supply an end and should contain all
  14631. // elements after resolvedBegin.
  14632. // In that case, resolvedSize will be NaN and sliceSize will remain undefined.
  14633. var resolvedSize = resolvedEnd - resolvedBegin;
  14634. var sliceSize;
  14635. if (resolvedSize === resolvedSize) {
  14636. sliceSize = resolvedSize < 0 ? 0 : resolvedSize;
  14637. }
  14638. var sliceSeq = makeSequence(iterable);
  14639. // If iterable.size is undefined, the size of the realized sliceSeq is
  14640. // unknown at this point unless the number of items to slice is 0
  14641. sliceSeq.size = sliceSize === 0 ? sliceSize : iterable.size && sliceSize || undefined;
  14642. if (!useKeys && isSeq(iterable) && sliceSize >= 0) {
  14643. sliceSeq.get = function (index, notSetValue) {
  14644. index = wrapIndex(this, index);
  14645. return index >= 0 && index < sliceSize ?
  14646. iterable.get(index + resolvedBegin, notSetValue) :
  14647. notSetValue;
  14648. };
  14649. }
  14650. sliceSeq.__iterateUncached = function(fn, reverse) {var this$0 = this;
  14651. if (sliceSize === 0) {
  14652. return 0;
  14653. }
  14654. if (reverse) {
  14655. return this.cacheResult().__iterate(fn, reverse);
  14656. }
  14657. var skipped = 0;
  14658. var isSkipping = true;
  14659. var iterations = 0;
  14660. iterable.__iterate(function(v, k) {
  14661. if (!(isSkipping && (isSkipping = skipped++ < resolvedBegin))) {
  14662. iterations++;
  14663. return fn(v, useKeys ? k : iterations - 1, this$0) !== false &&
  14664. iterations !== sliceSize;
  14665. }
  14666. });
  14667. return iterations;
  14668. };
  14669. sliceSeq.__iteratorUncached = function(type, reverse) {
  14670. if (sliceSize !== 0 && reverse) {
  14671. return this.cacheResult().__iterator(type, reverse);
  14672. }
  14673. // Don't bother instantiating parent iterator if taking 0.
  14674. var iterator = sliceSize !== 0 && iterable.__iterator(type, reverse);
  14675. var skipped = 0;
  14676. var iterations = 0;
  14677. return new Iterator(function() {
  14678. while (skipped++ < resolvedBegin) {
  14679. iterator.next();
  14680. }
  14681. if (++iterations > sliceSize) {
  14682. return iteratorDone();
  14683. }
  14684. var step = iterator.next();
  14685. if (useKeys || type === ITERATE_VALUES) {
  14686. return step;
  14687. } else if (type === ITERATE_KEYS) {
  14688. return iteratorValue(type, iterations - 1, undefined, step);
  14689. } else {
  14690. return iteratorValue(type, iterations - 1, step.value[1], step);
  14691. }
  14692. });
  14693. };
  14694. return sliceSeq;
  14695. }
  14696. function takeWhileFactory(iterable, predicate, context) {
  14697. var takeSequence = makeSequence(iterable);
  14698. takeSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  14699. if (reverse) {
  14700. return this.cacheResult().__iterate(fn, reverse);
  14701. }
  14702. var iterations = 0;
  14703. iterable.__iterate(function(v, k, c)
  14704. {return predicate.call(context, v, k, c) && ++iterations && fn(v, k, this$0)}
  14705. );
  14706. return iterations;
  14707. };
  14708. takeSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  14709. if (reverse) {
  14710. return this.cacheResult().__iterator(type, reverse);
  14711. }
  14712. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  14713. var iterating = true;
  14714. return new Iterator(function() {
  14715. if (!iterating) {
  14716. return iteratorDone();
  14717. }
  14718. var step = iterator.next();
  14719. if (step.done) {
  14720. return step;
  14721. }
  14722. var entry = step.value;
  14723. var k = entry[0];
  14724. var v = entry[1];
  14725. if (!predicate.call(context, v, k, this$0)) {
  14726. iterating = false;
  14727. return iteratorDone();
  14728. }
  14729. return type === ITERATE_ENTRIES ? step :
  14730. iteratorValue(type, k, v, step);
  14731. });
  14732. };
  14733. return takeSequence;
  14734. }
  14735. function skipWhileFactory(iterable, predicate, context, useKeys) {
  14736. var skipSequence = makeSequence(iterable);
  14737. skipSequence.__iterateUncached = function (fn, reverse) {var this$0 = this;
  14738. if (reverse) {
  14739. return this.cacheResult().__iterate(fn, reverse);
  14740. }
  14741. var isSkipping = true;
  14742. var iterations = 0;
  14743. iterable.__iterate(function(v, k, c) {
  14744. if (!(isSkipping && (isSkipping = predicate.call(context, v, k, c)))) {
  14745. iterations++;
  14746. return fn(v, useKeys ? k : iterations - 1, this$0);
  14747. }
  14748. });
  14749. return iterations;
  14750. };
  14751. skipSequence.__iteratorUncached = function(type, reverse) {var this$0 = this;
  14752. if (reverse) {
  14753. return this.cacheResult().__iterator(type, reverse);
  14754. }
  14755. var iterator = iterable.__iterator(ITERATE_ENTRIES, reverse);
  14756. var skipping = true;
  14757. var iterations = 0;
  14758. return new Iterator(function() {
  14759. var step, k, v;
  14760. do {
  14761. step = iterator.next();
  14762. if (step.done) {
  14763. if (useKeys || type === ITERATE_VALUES) {
  14764. return step;
  14765. } else if (type === ITERATE_KEYS) {
  14766. return iteratorValue(type, iterations++, undefined, step);
  14767. } else {
  14768. return iteratorValue(type, iterations++, step.value[1], step);
  14769. }
  14770. }
  14771. var entry = step.value;
  14772. k = entry[0];
  14773. v = entry[1];
  14774. skipping && (skipping = predicate.call(context, v, k, this$0));
  14775. } while (skipping);
  14776. return type === ITERATE_ENTRIES ? step :
  14777. iteratorValue(type, k, v, step);
  14778. });
  14779. };
  14780. return skipSequence;
  14781. }
  14782. function concatFactory(iterable, values) {
  14783. var isKeyedIterable = isKeyed(iterable);
  14784. var iters = [iterable].concat(values).map(function(v ) {
  14785. if (!isIterable(v)) {
  14786. v = isKeyedIterable ?
  14787. keyedSeqFromValue(v) :
  14788. indexedSeqFromValue(Array.isArray(v) ? v : [v]);
  14789. } else if (isKeyedIterable) {
  14790. v = KeyedIterable(v);
  14791. }
  14792. return v;
  14793. }).filter(function(v ) {return v.size !== 0});
  14794. if (iters.length === 0) {
  14795. return iterable;
  14796. }
  14797. if (iters.length === 1) {
  14798. var singleton = iters[0];
  14799. if (singleton === iterable ||
  14800. isKeyedIterable && isKeyed(singleton) ||
  14801. isIndexed(iterable) && isIndexed(singleton)) {
  14802. return singleton;
  14803. }
  14804. }
  14805. var concatSeq = new ArraySeq(iters);
  14806. if (isKeyedIterable) {
  14807. concatSeq = concatSeq.toKeyedSeq();
  14808. } else if (!isIndexed(iterable)) {
  14809. concatSeq = concatSeq.toSetSeq();
  14810. }
  14811. concatSeq = concatSeq.flatten(true);
  14812. concatSeq.size = iters.reduce(
  14813. function(sum, seq) {
  14814. if (sum !== undefined) {
  14815. var size = seq.size;
  14816. if (size !== undefined) {
  14817. return sum + size;
  14818. }
  14819. }
  14820. },
  14821. 0
  14822. );
  14823. return concatSeq;
  14824. }
  14825. function flattenFactory(iterable, depth, useKeys) {
  14826. var flatSequence = makeSequence(iterable);
  14827. flatSequence.__iterateUncached = function(fn, reverse) {
  14828. var iterations = 0;
  14829. var stopped = false;
  14830. function flatDeep(iter, currentDepth) {var this$0 = this;
  14831. iter.__iterate(function(v, k) {
  14832. if ((!depth || currentDepth < depth) && isIterable(v)) {
  14833. flatDeep(v, currentDepth + 1);
  14834. } else if (fn(v, useKeys ? k : iterations++, this$0) === false) {
  14835. stopped = true;
  14836. }
  14837. return !stopped;
  14838. }, reverse);
  14839. }
  14840. flatDeep(iterable, 0);
  14841. return iterations;
  14842. };
  14843. flatSequence.__iteratorUncached = function(type, reverse) {
  14844. var iterator = iterable.__iterator(type, reverse);
  14845. var stack = [];
  14846. var iterations = 0;
  14847. return new Iterator(function() {
  14848. while (iterator) {
  14849. var step = iterator.next();
  14850. if (step.done !== false) {
  14851. iterator = stack.pop();
  14852. continue;
  14853. }
  14854. var v = step.value;
  14855. if (type === ITERATE_ENTRIES) {
  14856. v = v[1];
  14857. }
  14858. if ((!depth || stack.length < depth) && isIterable(v)) {
  14859. stack.push(iterator);
  14860. iterator = v.__iterator(type, reverse);
  14861. } else {
  14862. return useKeys ? step : iteratorValue(type, iterations++, v, step);
  14863. }
  14864. }
  14865. return iteratorDone();
  14866. });
  14867. };
  14868. return flatSequence;
  14869. }
  14870. function flatMapFactory(iterable, mapper, context) {
  14871. var coerce = iterableClass(iterable);
  14872. return iterable.toSeq().map(
  14873. function(v, k) {return coerce(mapper.call(context, v, k, iterable))}
  14874. ).flatten(true);
  14875. }
  14876. function interposeFactory(iterable, separator) {
  14877. var interposedSequence = makeSequence(iterable);
  14878. interposedSequence.size = iterable.size && iterable.size * 2 -1;
  14879. interposedSequence.__iterateUncached = function(fn, reverse) {var this$0 = this;
  14880. var iterations = 0;
  14881. iterable.__iterate(function(v, k)
  14882. {return (!iterations || fn(separator, iterations++, this$0) !== false) &&
  14883. fn(v, iterations++, this$0) !== false},
  14884. reverse
  14885. );
  14886. return iterations;
  14887. };
  14888. interposedSequence.__iteratorUncached = function(type, reverse) {
  14889. var iterator = iterable.__iterator(ITERATE_VALUES, reverse);
  14890. var iterations = 0;
  14891. var step;
  14892. return new Iterator(function() {
  14893. if (!step || iterations % 2) {
  14894. step = iterator.next();
  14895. if (step.done) {
  14896. return step;
  14897. }
  14898. }
  14899. return iterations % 2 ?
  14900. iteratorValue(type, iterations++, separator) :
  14901. iteratorValue(type, iterations++, step.value, step);
  14902. });
  14903. };
  14904. return interposedSequence;
  14905. }
  14906. function sortFactory(iterable, comparator, mapper) {
  14907. if (!comparator) {
  14908. comparator = defaultComparator;
  14909. }
  14910. var isKeyedIterable = isKeyed(iterable);
  14911. var index = 0;
  14912. var entries = iterable.toSeq().map(
  14913. function(v, k) {return [k, v, index++, mapper ? mapper(v, k, iterable) : v]}
  14914. ).toArray();
  14915. entries.sort(function(a, b) {return comparator(a[3], b[3]) || a[2] - b[2]}).forEach(
  14916. isKeyedIterable ?
  14917. function(v, i) { entries[i].length = 2; } :
  14918. function(v, i) { entries[i] = v[1]; }
  14919. );
  14920. return isKeyedIterable ? KeyedSeq(entries) :
  14921. isIndexed(iterable) ? IndexedSeq(entries) :
  14922. SetSeq(entries);
  14923. }
  14924. function maxFactory(iterable, comparator, mapper) {
  14925. if (!comparator) {
  14926. comparator = defaultComparator;
  14927. }
  14928. if (mapper) {
  14929. var entry = iterable.toSeq()
  14930. .map(function(v, k) {return [v, mapper(v, k, iterable)]})
  14931. .reduce(function(a, b) {return maxCompare(comparator, a[1], b[1]) ? b : a});
  14932. return entry && entry[0];
  14933. } else {
  14934. return iterable.reduce(function(a, b) {return maxCompare(comparator, a, b) ? b : a});
  14935. }
  14936. }
  14937. function maxCompare(comparator, a, b) {
  14938. var comp = comparator(b, a);
  14939. // b is considered the new max if the comparator declares them equal, but
  14940. // they are not equal and b is in fact a nullish value.
  14941. return (comp === 0 && b !== a && (b === undefined || b === null || b !== b)) || comp > 0;
  14942. }
  14943. function zipWithFactory(keyIter, zipper, iters) {
  14944. var zipSequence = makeSequence(keyIter);
  14945. zipSequence.size = new ArraySeq(iters).map(function(i ) {return i.size}).min();
  14946. // Note: this a generic base implementation of __iterate in terms of
  14947. // __iterator which may be more generically useful in the future.
  14948. zipSequence.__iterate = function(fn, reverse) {
  14949. /* generic:
  14950. var iterator = this.__iterator(ITERATE_ENTRIES, reverse);
  14951. var step;
  14952. var iterations = 0;
  14953. while (!(step = iterator.next()).done) {
  14954. iterations++;
  14955. if (fn(step.value[1], step.value[0], this) === false) {
  14956. break;
  14957. }
  14958. }
  14959. return iterations;
  14960. */
  14961. // indexed:
  14962. var iterator = this.__iterator(ITERATE_VALUES, reverse);
  14963. var step;
  14964. var iterations = 0;
  14965. while (!(step = iterator.next()).done) {
  14966. if (fn(step.value, iterations++, this) === false) {
  14967. break;
  14968. }
  14969. }
  14970. return iterations;
  14971. };
  14972. zipSequence.__iteratorUncached = function(type, reverse) {
  14973. var iterators = iters.map(function(i )
  14974. {return (i = Iterable(i), getIterator(reverse ? i.reverse() : i))}
  14975. );
  14976. var iterations = 0;
  14977. var isDone = false;
  14978. return new Iterator(function() {
  14979. var steps;
  14980. if (!isDone) {
  14981. steps = iterators.map(function(i ) {return i.next()});
  14982. isDone = steps.some(function(s ) {return s.done});
  14983. }
  14984. if (isDone) {
  14985. return iteratorDone();
  14986. }
  14987. return iteratorValue(
  14988. type,
  14989. iterations++,
  14990. zipper.apply(null, steps.map(function(s ) {return s.value}))
  14991. );
  14992. });
  14993. };
  14994. return zipSequence
  14995. }
  14996. // #pragma Helper Functions
  14997. function reify(iter, seq) {
  14998. return isSeq(iter) ? seq : iter.constructor(seq);
  14999. }
  15000. function validateEntry(entry) {
  15001. if (entry !== Object(entry)) {
  15002. throw new TypeError('Expected [K, V] tuple: ' + entry);
  15003. }
  15004. }
  15005. function resolveSize(iter) {
  15006. assertNotInfinite(iter.size);
  15007. return ensureSize(iter);
  15008. }
  15009. function iterableClass(iterable) {
  15010. return isKeyed(iterable) ? KeyedIterable :
  15011. isIndexed(iterable) ? IndexedIterable :
  15012. SetIterable;
  15013. }
  15014. function makeSequence(iterable) {
  15015. return Object.create(
  15016. (
  15017. isKeyed(iterable) ? KeyedSeq :
  15018. isIndexed(iterable) ? IndexedSeq :
  15019. SetSeq
  15020. ).prototype
  15021. );
  15022. }
  15023. function cacheResultThrough() {
  15024. if (this._iter.cacheResult) {
  15025. this._iter.cacheResult();
  15026. this.size = this._iter.size;
  15027. return this;
  15028. } else {
  15029. return Seq.prototype.cacheResult.call(this);
  15030. }
  15031. }
  15032. function defaultComparator(a, b) {
  15033. return a > b ? 1 : a < b ? -1 : 0;
  15034. }
  15035. function forceIterator(keyPath) {
  15036. var iter = getIterator(keyPath);
  15037. if (!iter) {
  15038. // Array might not be iterable in this environment, so we need a fallback
  15039. // to our wrapped type.
  15040. if (!isArrayLike(keyPath)) {
  15041. throw new TypeError('Expected iterable or array-like: ' + keyPath);
  15042. }
  15043. iter = getIterator(Iterable(keyPath));
  15044. }
  15045. return iter;
  15046. }
  15047. createClass(Record, KeyedCollection);
  15048. function Record(defaultValues, name) {
  15049. var hasInitialized;
  15050. var RecordType = function Record(values) {
  15051. if (values instanceof RecordType) {
  15052. return values;
  15053. }
  15054. if (!(this instanceof RecordType)) {
  15055. return new RecordType(values);
  15056. }
  15057. if (!hasInitialized) {
  15058. hasInitialized = true;
  15059. var keys = Object.keys(defaultValues);
  15060. setProps(RecordTypePrototype, keys);
  15061. RecordTypePrototype.size = keys.length;
  15062. RecordTypePrototype._name = name;
  15063. RecordTypePrototype._keys = keys;
  15064. RecordTypePrototype._defaultValues = defaultValues;
  15065. }
  15066. this._map = Map(values);
  15067. };
  15068. var RecordTypePrototype = RecordType.prototype = Object.create(RecordPrototype);
  15069. RecordTypePrototype.constructor = RecordType;
  15070. return RecordType;
  15071. }
  15072. Record.prototype.toString = function() {
  15073. return this.__toString(recordName(this) + ' {', '}');
  15074. };
  15075. // @pragma Access
  15076. Record.prototype.has = function(k) {
  15077. return this._defaultValues.hasOwnProperty(k);
  15078. };
  15079. Record.prototype.get = function(k, notSetValue) {
  15080. if (!this.has(k)) {
  15081. return notSetValue;
  15082. }
  15083. var defaultVal = this._defaultValues[k];
  15084. return this._map ? this._map.get(k, defaultVal) : defaultVal;
  15085. };
  15086. // @pragma Modification
  15087. Record.prototype.clear = function() {
  15088. if (this.__ownerID) {
  15089. this._map && this._map.clear();
  15090. return this;
  15091. }
  15092. var RecordType = this.constructor;
  15093. return RecordType._empty || (RecordType._empty = makeRecord(this, emptyMap()));
  15094. };
  15095. Record.prototype.set = function(k, v) {
  15096. if (!this.has(k)) {
  15097. throw new Error('Cannot set unknown key "' + k + '" on ' + recordName(this));
  15098. }
  15099. var newMap = this._map && this._map.set(k, v);
  15100. if (this.__ownerID || newMap === this._map) {
  15101. return this;
  15102. }
  15103. return makeRecord(this, newMap);
  15104. };
  15105. Record.prototype.remove = function(k) {
  15106. if (!this.has(k)) {
  15107. return this;
  15108. }
  15109. var newMap = this._map && this._map.remove(k);
  15110. if (this.__ownerID || newMap === this._map) {
  15111. return this;
  15112. }
  15113. return makeRecord(this, newMap);
  15114. };
  15115. Record.prototype.wasAltered = function() {
  15116. return this._map.wasAltered();
  15117. };
  15118. Record.prototype.__iterator = function(type, reverse) {var this$0 = this;
  15119. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterator(type, reverse);
  15120. };
  15121. Record.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  15122. return KeyedIterable(this._defaultValues).map(function(_, k) {return this$0.get(k)}).__iterate(fn, reverse);
  15123. };
  15124. Record.prototype.__ensureOwner = function(ownerID) {
  15125. if (ownerID === this.__ownerID) {
  15126. return this;
  15127. }
  15128. var newMap = this._map && this._map.__ensureOwner(ownerID);
  15129. if (!ownerID) {
  15130. this.__ownerID = ownerID;
  15131. this._map = newMap;
  15132. return this;
  15133. }
  15134. return makeRecord(this, newMap, ownerID);
  15135. };
  15136. var RecordPrototype = Record.prototype;
  15137. RecordPrototype[DELETE] = RecordPrototype.remove;
  15138. RecordPrototype.deleteIn =
  15139. RecordPrototype.removeIn = MapPrototype.removeIn;
  15140. RecordPrototype.merge = MapPrototype.merge;
  15141. RecordPrototype.mergeWith = MapPrototype.mergeWith;
  15142. RecordPrototype.mergeIn = MapPrototype.mergeIn;
  15143. RecordPrototype.mergeDeep = MapPrototype.mergeDeep;
  15144. RecordPrototype.mergeDeepWith = MapPrototype.mergeDeepWith;
  15145. RecordPrototype.mergeDeepIn = MapPrototype.mergeDeepIn;
  15146. RecordPrototype.setIn = MapPrototype.setIn;
  15147. RecordPrototype.update = MapPrototype.update;
  15148. RecordPrototype.updateIn = MapPrototype.updateIn;
  15149. RecordPrototype.withMutations = MapPrototype.withMutations;
  15150. RecordPrototype.asMutable = MapPrototype.asMutable;
  15151. RecordPrototype.asImmutable = MapPrototype.asImmutable;
  15152. function makeRecord(likeRecord, map, ownerID) {
  15153. var record = Object.create(Object.getPrototypeOf(likeRecord));
  15154. record._map = map;
  15155. record.__ownerID = ownerID;
  15156. return record;
  15157. }
  15158. function recordName(record) {
  15159. return record._name || record.constructor.name || 'Record';
  15160. }
  15161. function setProps(prototype, names) {
  15162. try {
  15163. names.forEach(setProp.bind(undefined, prototype));
  15164. } catch (error) {
  15165. // Object.defineProperty failed. Probably IE8.
  15166. }
  15167. }
  15168. function setProp(prototype, name) {
  15169. Object.defineProperty(prototype, name, {
  15170. get: function() {
  15171. return this.get(name);
  15172. },
  15173. set: function(value) {
  15174. invariant(this.__ownerID, 'Cannot set on an immutable record.');
  15175. this.set(name, value);
  15176. }
  15177. });
  15178. }
  15179. createClass(Set, SetCollection);
  15180. // @pragma Construction
  15181. function Set(value) {
  15182. return value === null || value === undefined ? emptySet() :
  15183. isSet(value) && !isOrdered(value) ? value :
  15184. emptySet().withMutations(function(set ) {
  15185. var iter = SetIterable(value);
  15186. assertNotInfinite(iter.size);
  15187. iter.forEach(function(v ) {return set.add(v)});
  15188. });
  15189. }
  15190. Set.of = function(/*...values*/) {
  15191. return this(arguments);
  15192. };
  15193. Set.fromKeys = function(value) {
  15194. return this(KeyedIterable(value).keySeq());
  15195. };
  15196. Set.prototype.toString = function() {
  15197. return this.__toString('Set {', '}');
  15198. };
  15199. // @pragma Access
  15200. Set.prototype.has = function(value) {
  15201. return this._map.has(value);
  15202. };
  15203. // @pragma Modification
  15204. Set.prototype.add = function(value) {
  15205. return updateSet(this, this._map.set(value, true));
  15206. };
  15207. Set.prototype.remove = function(value) {
  15208. return updateSet(this, this._map.remove(value));
  15209. };
  15210. Set.prototype.clear = function() {
  15211. return updateSet(this, this._map.clear());
  15212. };
  15213. // @pragma Composition
  15214. Set.prototype.union = function() {var iters = SLICE$0.call(arguments, 0);
  15215. iters = iters.filter(function(x ) {return x.size !== 0});
  15216. if (iters.length === 0) {
  15217. return this;
  15218. }
  15219. if (this.size === 0 && !this.__ownerID && iters.length === 1) {
  15220. return this.constructor(iters[0]);
  15221. }
  15222. return this.withMutations(function(set ) {
  15223. for (var ii = 0; ii < iters.length; ii++) {
  15224. SetIterable(iters[ii]).forEach(function(value ) {return set.add(value)});
  15225. }
  15226. });
  15227. };
  15228. Set.prototype.intersect = function() {var iters = SLICE$0.call(arguments, 0);
  15229. if (iters.length === 0) {
  15230. return this;
  15231. }
  15232. iters = iters.map(function(iter ) {return SetIterable(iter)});
  15233. var originalSet = this;
  15234. return this.withMutations(function(set ) {
  15235. originalSet.forEach(function(value ) {
  15236. if (!iters.every(function(iter ) {return iter.includes(value)})) {
  15237. set.remove(value);
  15238. }
  15239. });
  15240. });
  15241. };
  15242. Set.prototype.subtract = function() {var iters = SLICE$0.call(arguments, 0);
  15243. if (iters.length === 0) {
  15244. return this;
  15245. }
  15246. iters = iters.map(function(iter ) {return SetIterable(iter)});
  15247. var originalSet = this;
  15248. return this.withMutations(function(set ) {
  15249. originalSet.forEach(function(value ) {
  15250. if (iters.some(function(iter ) {return iter.includes(value)})) {
  15251. set.remove(value);
  15252. }
  15253. });
  15254. });
  15255. };
  15256. Set.prototype.merge = function() {
  15257. return this.union.apply(this, arguments);
  15258. };
  15259. Set.prototype.mergeWith = function(merger) {var iters = SLICE$0.call(arguments, 1);
  15260. return this.union.apply(this, iters);
  15261. };
  15262. Set.prototype.sort = function(comparator) {
  15263. // Late binding
  15264. return OrderedSet(sortFactory(this, comparator));
  15265. };
  15266. Set.prototype.sortBy = function(mapper, comparator) {
  15267. // Late binding
  15268. return OrderedSet(sortFactory(this, comparator, mapper));
  15269. };
  15270. Set.prototype.wasAltered = function() {
  15271. return this._map.wasAltered();
  15272. };
  15273. Set.prototype.__iterate = function(fn, reverse) {var this$0 = this;
  15274. return this._map.__iterate(function(_, k) {return fn(k, k, this$0)}, reverse);
  15275. };
  15276. Set.prototype.__iterator = function(type, reverse) {
  15277. return this._map.map(function(_, k) {return k}).__iterator(type, reverse);
  15278. };
  15279. Set.prototype.__ensureOwner = function(ownerID) {
  15280. if (ownerID === this.__ownerID) {
  15281. return this;
  15282. }
  15283. var newMap = this._map.__ensureOwner(ownerID);
  15284. if (!ownerID) {
  15285. this.__ownerID = ownerID;
  15286. this._map = newMap;
  15287. return this;
  15288. }
  15289. return this.__make(newMap, ownerID);
  15290. };
  15291. function isSet(maybeSet) {
  15292. return !!(maybeSet && maybeSet[IS_SET_SENTINEL]);
  15293. }
  15294. Set.isSet = isSet;
  15295. var IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
  15296. var SetPrototype = Set.prototype;
  15297. SetPrototype[IS_SET_SENTINEL] = true;
  15298. SetPrototype[DELETE] = SetPrototype.remove;
  15299. SetPrototype.mergeDeep = SetPrototype.merge;
  15300. SetPrototype.mergeDeepWith = SetPrototype.mergeWith;
  15301. SetPrototype.withMutations = MapPrototype.withMutations;
  15302. SetPrototype.asMutable = MapPrototype.asMutable;
  15303. SetPrototype.asImmutable = MapPrototype.asImmutable;
  15304. SetPrototype.__empty = emptySet;
  15305. SetPrototype.__make = makeSet;
  15306. function updateSet(set, newMap) {
  15307. if (set.__ownerID) {
  15308. set.size = newMap.size;
  15309. set._map = newMap;
  15310. return set;
  15311. }
  15312. return newMap === set._map ? set :
  15313. newMap.size === 0 ? set.__empty() :
  15314. set.__make(newMap);
  15315. }
  15316. function makeSet(map, ownerID) {
  15317. var set = Object.create(SetPrototype);
  15318. set.size = map ? map.size : 0;
  15319. set._map = map;
  15320. set.__ownerID = ownerID;
  15321. return set;
  15322. }
  15323. var EMPTY_SET;
  15324. function emptySet() {
  15325. return EMPTY_SET || (EMPTY_SET = makeSet(emptyMap()));
  15326. }
  15327. createClass(OrderedSet, Set);
  15328. // @pragma Construction
  15329. function OrderedSet(value) {
  15330. return value === null || value === undefined ? emptyOrderedSet() :
  15331. isOrderedSet(value) ? value :
  15332. emptyOrderedSet().withMutations(function(set ) {
  15333. var iter = SetIterable(value);
  15334. assertNotInfinite(iter.size);
  15335. iter.forEach(function(v ) {return set.add(v)});
  15336. });
  15337. }
  15338. OrderedSet.of = function(/*...values*/) {
  15339. return this(arguments);
  15340. };
  15341. OrderedSet.fromKeys = function(value) {
  15342. return this(KeyedIterable(value).keySeq());
  15343. };
  15344. OrderedSet.prototype.toString = function() {
  15345. return this.__toString('OrderedSet {', '}');
  15346. };
  15347. function isOrderedSet(maybeOrderedSet) {
  15348. return isSet(maybeOrderedSet) && isOrdered(maybeOrderedSet);
  15349. }
  15350. OrderedSet.isOrderedSet = isOrderedSet;
  15351. var OrderedSetPrototype = OrderedSet.prototype;
  15352. OrderedSetPrototype[IS_ORDERED_SENTINEL] = true;
  15353. OrderedSetPrototype.__empty = emptyOrderedSet;
  15354. OrderedSetPrototype.__make = makeOrderedSet;
  15355. function makeOrderedSet(map, ownerID) {
  15356. var set = Object.create(OrderedSetPrototype);
  15357. set.size = map ? map.size : 0;
  15358. set._map = map;
  15359. set.__ownerID = ownerID;
  15360. return set;
  15361. }
  15362. var EMPTY_ORDERED_SET;
  15363. function emptyOrderedSet() {
  15364. return EMPTY_ORDERED_SET || (EMPTY_ORDERED_SET = makeOrderedSet(emptyOrderedMap()));
  15365. }
  15366. createClass(Stack, IndexedCollection);
  15367. // @pragma Construction
  15368. function Stack(value) {
  15369. return value === null || value === undefined ? emptyStack() :
  15370. isStack(value) ? value :
  15371. emptyStack().unshiftAll(value);
  15372. }
  15373. Stack.of = function(/*...values*/) {
  15374. return this(arguments);
  15375. };
  15376. Stack.prototype.toString = function() {
  15377. return this.__toString('Stack [', ']');
  15378. };
  15379. // @pragma Access
  15380. Stack.prototype.get = function(index, notSetValue) {
  15381. var head = this._head;
  15382. index = wrapIndex(this, index);
  15383. while (head && index--) {
  15384. head = head.next;
  15385. }
  15386. return head ? head.value : notSetValue;
  15387. };
  15388. Stack.prototype.peek = function() {
  15389. return this._head && this._head.value;
  15390. };
  15391. // @pragma Modification
  15392. Stack.prototype.push = function(/*...values*/) {
  15393. if (arguments.length === 0) {
  15394. return this;
  15395. }
  15396. var newSize = this.size + arguments.length;
  15397. var head = this._head;
  15398. for (var ii = arguments.length - 1; ii >= 0; ii--) {
  15399. head = {
  15400. value: arguments[ii],
  15401. next: head
  15402. };
  15403. }
  15404. if (this.__ownerID) {
  15405. this.size = newSize;
  15406. this._head = head;
  15407. this.__hash = undefined;
  15408. this.__altered = true;
  15409. return this;
  15410. }
  15411. return makeStack(newSize, head);
  15412. };
  15413. Stack.prototype.pushAll = function(iter) {
  15414. iter = IndexedIterable(iter);
  15415. if (iter.size === 0) {
  15416. return this;
  15417. }
  15418. assertNotInfinite(iter.size);
  15419. var newSize = this.size;
  15420. var head = this._head;
  15421. iter.reverse().forEach(function(value ) {
  15422. newSize++;
  15423. head = {
  15424. value: value,
  15425. next: head
  15426. };
  15427. });
  15428. if (this.__ownerID) {
  15429. this.size = newSize;
  15430. this._head = head;
  15431. this.__hash = undefined;
  15432. this.__altered = true;
  15433. return this;
  15434. }
  15435. return makeStack(newSize, head);
  15436. };
  15437. Stack.prototype.pop = function() {
  15438. return this.slice(1);
  15439. };
  15440. Stack.prototype.unshift = function(/*...values*/) {
  15441. return this.push.apply(this, arguments);
  15442. };
  15443. Stack.prototype.unshiftAll = function(iter) {
  15444. return this.pushAll(iter);
  15445. };
  15446. Stack.prototype.shift = function() {
  15447. return this.pop.apply(this, arguments);
  15448. };
  15449. Stack.prototype.clear = function() {
  15450. if (this.size === 0) {
  15451. return this;
  15452. }
  15453. if (this.__ownerID) {
  15454. this.size = 0;
  15455. this._head = undefined;
  15456. this.__hash = undefined;
  15457. this.__altered = true;
  15458. return this;
  15459. }
  15460. return emptyStack();
  15461. };
  15462. Stack.prototype.slice = function(begin, end) {
  15463. if (wholeSlice(begin, end, this.size)) {
  15464. return this;
  15465. }
  15466. var resolvedBegin = resolveBegin(begin, this.size);
  15467. var resolvedEnd = resolveEnd(end, this.size);
  15468. if (resolvedEnd !== this.size) {
  15469. // super.slice(begin, end);
  15470. return IndexedCollection.prototype.slice.call(this, begin, end);
  15471. }
  15472. var newSize = this.size - resolvedBegin;
  15473. var head = this._head;
  15474. while (resolvedBegin--) {
  15475. head = head.next;
  15476. }
  15477. if (this.__ownerID) {
  15478. this.size = newSize;
  15479. this._head = head;
  15480. this.__hash = undefined;
  15481. this.__altered = true;
  15482. return this;
  15483. }
  15484. return makeStack(newSize, head);
  15485. };
  15486. // @pragma Mutability
  15487. Stack.prototype.__ensureOwner = function(ownerID) {
  15488. if (ownerID === this.__ownerID) {
  15489. return this;
  15490. }
  15491. if (!ownerID) {
  15492. this.__ownerID = ownerID;
  15493. this.__altered = false;
  15494. return this;
  15495. }
  15496. return makeStack(this.size, this._head, ownerID, this.__hash);
  15497. };
  15498. // @pragma Iteration
  15499. Stack.prototype.__iterate = function(fn, reverse) {
  15500. if (reverse) {
  15501. return this.reverse().__iterate(fn);
  15502. }
  15503. var iterations = 0;
  15504. var node = this._head;
  15505. while (node) {
  15506. if (fn(node.value, iterations++, this) === false) {
  15507. break;
  15508. }
  15509. node = node.next;
  15510. }
  15511. return iterations;
  15512. };
  15513. Stack.prototype.__iterator = function(type, reverse) {
  15514. if (reverse) {
  15515. return this.reverse().__iterator(type);
  15516. }
  15517. var iterations = 0;
  15518. var node = this._head;
  15519. return new Iterator(function() {
  15520. if (node) {
  15521. var value = node.value;
  15522. node = node.next;
  15523. return iteratorValue(type, iterations++, value);
  15524. }
  15525. return iteratorDone();
  15526. });
  15527. };
  15528. function isStack(maybeStack) {
  15529. return !!(maybeStack && maybeStack[IS_STACK_SENTINEL]);
  15530. }
  15531. Stack.isStack = isStack;
  15532. var IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
  15533. var StackPrototype = Stack.prototype;
  15534. StackPrototype[IS_STACK_SENTINEL] = true;
  15535. StackPrototype.withMutations = MapPrototype.withMutations;
  15536. StackPrototype.asMutable = MapPrototype.asMutable;
  15537. StackPrototype.asImmutable = MapPrototype.asImmutable;
  15538. StackPrototype.wasAltered = MapPrototype.wasAltered;
  15539. function makeStack(size, head, ownerID, hash) {
  15540. var map = Object.create(StackPrototype);
  15541. map.size = size;
  15542. map._head = head;
  15543. map.__ownerID = ownerID;
  15544. map.__hash = hash;
  15545. map.__altered = false;
  15546. return map;
  15547. }
  15548. var EMPTY_STACK;
  15549. function emptyStack() {
  15550. return EMPTY_STACK || (EMPTY_STACK = makeStack(0));
  15551. }
  15552. /**
  15553. * Contributes additional methods to a constructor
  15554. */
  15555. function mixin(ctor, methods) {
  15556. var keyCopier = function(key ) { ctor.prototype[key] = methods[key]; };
  15557. Object.keys(methods).forEach(keyCopier);
  15558. Object.getOwnPropertySymbols &&
  15559. Object.getOwnPropertySymbols(methods).forEach(keyCopier);
  15560. return ctor;
  15561. }
  15562. Iterable.Iterator = Iterator;
  15563. mixin(Iterable, {
  15564. // ### Conversion to other types
  15565. toArray: function() {
  15566. assertNotInfinite(this.size);
  15567. var array = new Array(this.size || 0);
  15568. this.valueSeq().__iterate(function(v, i) { array[i] = v; });
  15569. return array;
  15570. },
  15571. toIndexedSeq: function() {
  15572. return new ToIndexedSequence(this);
  15573. },
  15574. toJS: function() {
  15575. return this.toSeq().map(
  15576. function(value ) {return value && typeof value.toJS === 'function' ? value.toJS() : value}
  15577. ).__toJS();
  15578. },
  15579. toJSON: function() {
  15580. return this.toSeq().map(
  15581. function(value ) {return value && typeof value.toJSON === 'function' ? value.toJSON() : value}
  15582. ).__toJS();
  15583. },
  15584. toKeyedSeq: function() {
  15585. return new ToKeyedSequence(this, true);
  15586. },
  15587. toMap: function() {
  15588. // Use Late Binding here to solve the circular dependency.
  15589. return Map(this.toKeyedSeq());
  15590. },
  15591. toObject: function() {
  15592. assertNotInfinite(this.size);
  15593. var object = {};
  15594. this.__iterate(function(v, k) { object[k] = v; });
  15595. return object;
  15596. },
  15597. toOrderedMap: function() {
  15598. // Use Late Binding here to solve the circular dependency.
  15599. return OrderedMap(this.toKeyedSeq());
  15600. },
  15601. toOrderedSet: function() {
  15602. // Use Late Binding here to solve the circular dependency.
  15603. return OrderedSet(isKeyed(this) ? this.valueSeq() : this);
  15604. },
  15605. toSet: function() {
  15606. // Use Late Binding here to solve the circular dependency.
  15607. return Set(isKeyed(this) ? this.valueSeq() : this);
  15608. },
  15609. toSetSeq: function() {
  15610. return new ToSetSequence(this);
  15611. },
  15612. toSeq: function() {
  15613. return isIndexed(this) ? this.toIndexedSeq() :
  15614. isKeyed(this) ? this.toKeyedSeq() :
  15615. this.toSetSeq();
  15616. },
  15617. toStack: function() {
  15618. // Use Late Binding here to solve the circular dependency.
  15619. return Stack(isKeyed(this) ? this.valueSeq() : this);
  15620. },
  15621. toList: function() {
  15622. // Use Late Binding here to solve the circular dependency.
  15623. return List(isKeyed(this) ? this.valueSeq() : this);
  15624. },
  15625. // ### Common JavaScript methods and properties
  15626. toString: function() {
  15627. return '[Iterable]';
  15628. },
  15629. __toString: function(head, tail) {
  15630. if (this.size === 0) {
  15631. return head + tail;
  15632. }
  15633. return head + ' ' + this.toSeq().map(this.__toStringMapper).join(', ') + ' ' + tail;
  15634. },
  15635. // ### ES6 Collection methods (ES6 Array and Map)
  15636. concat: function() {var values = SLICE$0.call(arguments, 0);
  15637. return reify(this, concatFactory(this, values));
  15638. },
  15639. includes: function(searchValue) {
  15640. return this.some(function(value ) {return is(value, searchValue)});
  15641. },
  15642. entries: function() {
  15643. return this.__iterator(ITERATE_ENTRIES);
  15644. },
  15645. every: function(predicate, context) {
  15646. assertNotInfinite(this.size);
  15647. var returnValue = true;
  15648. this.__iterate(function(v, k, c) {
  15649. if (!predicate.call(context, v, k, c)) {
  15650. returnValue = false;
  15651. return false;
  15652. }
  15653. });
  15654. return returnValue;
  15655. },
  15656. filter: function(predicate, context) {
  15657. return reify(this, filterFactory(this, predicate, context, true));
  15658. },
  15659. find: function(predicate, context, notSetValue) {
  15660. var entry = this.findEntry(predicate, context);
  15661. return entry ? entry[1] : notSetValue;
  15662. },
  15663. findEntry: function(predicate, context) {
  15664. var found;
  15665. this.__iterate(function(v, k, c) {
  15666. if (predicate.call(context, v, k, c)) {
  15667. found = [k, v];
  15668. return false;
  15669. }
  15670. });
  15671. return found;
  15672. },
  15673. findLastEntry: function(predicate, context) {
  15674. return this.toSeq().reverse().findEntry(predicate, context);
  15675. },
  15676. forEach: function(sideEffect, context) {
  15677. assertNotInfinite(this.size);
  15678. return this.__iterate(context ? sideEffect.bind(context) : sideEffect);
  15679. },
  15680. join: function(separator) {
  15681. assertNotInfinite(this.size);
  15682. separator = separator !== undefined ? '' + separator : ',';
  15683. var joined = '';
  15684. var isFirst = true;
  15685. this.__iterate(function(v ) {
  15686. isFirst ? (isFirst = false) : (joined += separator);
  15687. joined += v !== null && v !== undefined ? v.toString() : '';
  15688. });
  15689. return joined;
  15690. },
  15691. keys: function() {
  15692. return this.__iterator(ITERATE_KEYS);
  15693. },
  15694. map: function(mapper, context) {
  15695. return reify(this, mapFactory(this, mapper, context));
  15696. },
  15697. reduce: function(reducer, initialReduction, context) {
  15698. assertNotInfinite(this.size);
  15699. var reduction;
  15700. var useFirst;
  15701. if (arguments.length < 2) {
  15702. useFirst = true;
  15703. } else {
  15704. reduction = initialReduction;
  15705. }
  15706. this.__iterate(function(v, k, c) {
  15707. if (useFirst) {
  15708. useFirst = false;
  15709. reduction = v;
  15710. } else {
  15711. reduction = reducer.call(context, reduction, v, k, c);
  15712. }
  15713. });
  15714. return reduction;
  15715. },
  15716. reduceRight: function(reducer, initialReduction, context) {
  15717. var reversed = this.toKeyedSeq().reverse();
  15718. return reversed.reduce.apply(reversed, arguments);
  15719. },
  15720. reverse: function() {
  15721. return reify(this, reverseFactory(this, true));
  15722. },
  15723. slice: function(begin, end) {
  15724. return reify(this, sliceFactory(this, begin, end, true));
  15725. },
  15726. some: function(predicate, context) {
  15727. return !this.every(not(predicate), context);
  15728. },
  15729. sort: function(comparator) {
  15730. return reify(this, sortFactory(this, comparator));
  15731. },
  15732. values: function() {
  15733. return this.__iterator(ITERATE_VALUES);
  15734. },
  15735. // ### More sequential methods
  15736. butLast: function() {
  15737. return this.slice(0, -1);
  15738. },
  15739. isEmpty: function() {
  15740. return this.size !== undefined ? this.size === 0 : !this.some(function() {return true});
  15741. },
  15742. count: function(predicate, context) {
  15743. return ensureSize(
  15744. predicate ? this.toSeq().filter(predicate, context) : this
  15745. );
  15746. },
  15747. countBy: function(grouper, context) {
  15748. return countByFactory(this, grouper, context);
  15749. },
  15750. equals: function(other) {
  15751. return deepEqual(this, other);
  15752. },
  15753. entrySeq: function() {
  15754. var iterable = this;
  15755. if (iterable._cache) {
  15756. // We cache as an entries array, so we can just return the cache!
  15757. return new ArraySeq(iterable._cache);
  15758. }
  15759. var entriesSequence = iterable.toSeq().map(entryMapper).toIndexedSeq();
  15760. entriesSequence.fromEntrySeq = function() {return iterable.toSeq()};
  15761. return entriesSequence;
  15762. },
  15763. filterNot: function(predicate, context) {
  15764. return this.filter(not(predicate), context);
  15765. },
  15766. findLast: function(predicate, context, notSetValue) {
  15767. return this.toKeyedSeq().reverse().find(predicate, context, notSetValue);
  15768. },
  15769. first: function() {
  15770. return this.find(returnTrue);
  15771. },
  15772. flatMap: function(mapper, context) {
  15773. return reify(this, flatMapFactory(this, mapper, context));
  15774. },
  15775. flatten: function(depth) {
  15776. return reify(this, flattenFactory(this, depth, true));
  15777. },
  15778. fromEntrySeq: function() {
  15779. return new FromEntriesSequence(this);
  15780. },
  15781. get: function(searchKey, notSetValue) {
  15782. return this.find(function(_, key) {return is(key, searchKey)}, undefined, notSetValue);
  15783. },
  15784. getIn: function(searchKeyPath, notSetValue) {
  15785. var nested = this;
  15786. // Note: in an ES6 environment, we would prefer:
  15787. // for (var key of searchKeyPath) {
  15788. var iter = forceIterator(searchKeyPath);
  15789. var step;
  15790. while (!(step = iter.next()).done) {
  15791. var key = step.value;
  15792. nested = nested && nested.get ? nested.get(key, NOT_SET) : NOT_SET;
  15793. if (nested === NOT_SET) {
  15794. return notSetValue;
  15795. }
  15796. }
  15797. return nested;
  15798. },
  15799. groupBy: function(grouper, context) {
  15800. return groupByFactory(this, grouper, context);
  15801. },
  15802. has: function(searchKey) {
  15803. return this.get(searchKey, NOT_SET) !== NOT_SET;
  15804. },
  15805. hasIn: function(searchKeyPath) {
  15806. return this.getIn(searchKeyPath, NOT_SET) !== NOT_SET;
  15807. },
  15808. isSubset: function(iter) {
  15809. iter = typeof iter.includes === 'function' ? iter : Iterable(iter);
  15810. return this.every(function(value ) {return iter.includes(value)});
  15811. },
  15812. isSuperset: function(iter) {
  15813. iter = typeof iter.isSubset === 'function' ? iter : Iterable(iter);
  15814. return iter.isSubset(this);
  15815. },
  15816. keySeq: function() {
  15817. return this.toSeq().map(keyMapper).toIndexedSeq();
  15818. },
  15819. last: function() {
  15820. return this.toSeq().reverse().first();
  15821. },
  15822. max: function(comparator) {
  15823. return maxFactory(this, comparator);
  15824. },
  15825. maxBy: function(mapper, comparator) {
  15826. return maxFactory(this, comparator, mapper);
  15827. },
  15828. min: function(comparator) {
  15829. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator);
  15830. },
  15831. minBy: function(mapper, comparator) {
  15832. return maxFactory(this, comparator ? neg(comparator) : defaultNegComparator, mapper);
  15833. },
  15834. rest: function() {
  15835. return this.slice(1);
  15836. },
  15837. skip: function(amount) {
  15838. return this.slice(Math.max(0, amount));
  15839. },
  15840. skipLast: function(amount) {
  15841. return reify(this, this.toSeq().reverse().skip(amount).reverse());
  15842. },
  15843. skipWhile: function(predicate, context) {
  15844. return reify(this, skipWhileFactory(this, predicate, context, true));
  15845. },
  15846. skipUntil: function(predicate, context) {
  15847. return this.skipWhile(not(predicate), context);
  15848. },
  15849. sortBy: function(mapper, comparator) {
  15850. return reify(this, sortFactory(this, comparator, mapper));
  15851. },
  15852. take: function(amount) {
  15853. return this.slice(0, Math.max(0, amount));
  15854. },
  15855. takeLast: function(amount) {
  15856. return reify(this, this.toSeq().reverse().take(amount).reverse());
  15857. },
  15858. takeWhile: function(predicate, context) {
  15859. return reify(this, takeWhileFactory(this, predicate, context));
  15860. },
  15861. takeUntil: function(predicate, context) {
  15862. return this.takeWhile(not(predicate), context);
  15863. },
  15864. valueSeq: function() {
  15865. return this.toIndexedSeq();
  15866. },
  15867. // ### Hashable Object
  15868. hashCode: function() {
  15869. return this.__hash || (this.__hash = hashIterable(this));
  15870. }
  15871. // ### Internal
  15872. // abstract __iterate(fn, reverse)
  15873. // abstract __iterator(type, reverse)
  15874. });
  15875. // var IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
  15876. // var IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
  15877. // var IS_INDEXED_SENTINEL = '@@__IMMUTABLE_INDEXED__@@';
  15878. // var IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
  15879. var IterablePrototype = Iterable.prototype;
  15880. IterablePrototype[IS_ITERABLE_SENTINEL] = true;
  15881. IterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.values;
  15882. IterablePrototype.__toJS = IterablePrototype.toArray;
  15883. IterablePrototype.__toStringMapper = quoteString;
  15884. IterablePrototype.inspect =
  15885. IterablePrototype.toSource = function() { return this.toString(); };
  15886. IterablePrototype.chain = IterablePrototype.flatMap;
  15887. IterablePrototype.contains = IterablePrototype.includes;
  15888. // Temporary warning about using length
  15889. (function () {
  15890. try {
  15891. Object.defineProperty(IterablePrototype, 'length', {
  15892. get: function () {
  15893. if (!Iterable.noLengthWarning) {
  15894. var stack;
  15895. try {
  15896. throw new Error();
  15897. } catch (error) {
  15898. stack = error.stack;
  15899. }
  15900. if (stack.indexOf('_wrapObject') === -1) {
  15901. console && console.warn && console.warn(
  15902. 'iterable.length has been deprecated, '+
  15903. 'use iterable.size or iterable.count(). '+
  15904. 'This warning will become a silent error in a future version. ' +
  15905. stack
  15906. );
  15907. return this.size;
  15908. }
  15909. }
  15910. }
  15911. });
  15912. } catch (e) {}
  15913. })();
  15914. mixin(KeyedIterable, {
  15915. // ### More sequential methods
  15916. flip: function() {
  15917. return reify(this, flipFactory(this));
  15918. },
  15919. findKey: function(predicate, context) {
  15920. var entry = this.findEntry(predicate, context);
  15921. return entry && entry[0];
  15922. },
  15923. findLastKey: function(predicate, context) {
  15924. return this.toSeq().reverse().findKey(predicate, context);
  15925. },
  15926. keyOf: function(searchValue) {
  15927. return this.findKey(function(value ) {return is(value, searchValue)});
  15928. },
  15929. lastKeyOf: function(searchValue) {
  15930. return this.findLastKey(function(value ) {return is(value, searchValue)});
  15931. },
  15932. mapEntries: function(mapper, context) {var this$0 = this;
  15933. var iterations = 0;
  15934. return reify(this,
  15935. this.toSeq().map(
  15936. function(v, k) {return mapper.call(context, [k, v], iterations++, this$0)}
  15937. ).fromEntrySeq()
  15938. );
  15939. },
  15940. mapKeys: function(mapper, context) {var this$0 = this;
  15941. return reify(this,
  15942. this.toSeq().flip().map(
  15943. function(k, v) {return mapper.call(context, k, v, this$0)}
  15944. ).flip()
  15945. );
  15946. }
  15947. });
  15948. var KeyedIterablePrototype = KeyedIterable.prototype;
  15949. KeyedIterablePrototype[IS_KEYED_SENTINEL] = true;
  15950. KeyedIterablePrototype[ITERATOR_SYMBOL] = IterablePrototype.entries;
  15951. KeyedIterablePrototype.__toJS = IterablePrototype.toObject;
  15952. KeyedIterablePrototype.__toStringMapper = function(v, k) {return JSON.stringify(k) + ': ' + quoteString(v)};
  15953. mixin(IndexedIterable, {
  15954. // ### Conversion to other types
  15955. toKeyedSeq: function() {
  15956. return new ToKeyedSequence(this, false);
  15957. },
  15958. // ### ES6 Collection methods (ES6 Array and Map)
  15959. filter: function(predicate, context) {
  15960. return reify(this, filterFactory(this, predicate, context, false));
  15961. },
  15962. findIndex: function(predicate, context) {
  15963. var entry = this.findEntry(predicate, context);
  15964. return entry ? entry[0] : -1;
  15965. },
  15966. indexOf: function(searchValue) {
  15967. var key = this.toKeyedSeq().keyOf(searchValue);
  15968. return key === undefined ? -1 : key;
  15969. },
  15970. lastIndexOf: function(searchValue) {
  15971. var key = this.toKeyedSeq().reverse().keyOf(searchValue);
  15972. return key === undefined ? -1 : key;
  15973. // var index =
  15974. // return this.toSeq().reverse().indexOf(searchValue);
  15975. },
  15976. reverse: function() {
  15977. return reify(this, reverseFactory(this, false));
  15978. },
  15979. slice: function(begin, end) {
  15980. return reify(this, sliceFactory(this, begin, end, false));
  15981. },
  15982. splice: function(index, removeNum /*, ...values*/) {
  15983. var numArgs = arguments.length;
  15984. removeNum = Math.max(removeNum | 0, 0);
  15985. if (numArgs === 0 || (numArgs === 2 && !removeNum)) {
  15986. return this;
  15987. }
  15988. // If index is negative, it should resolve relative to the size of the
  15989. // collection. However size may be expensive to compute if not cached, so
  15990. // only call count() if the number is in fact negative.
  15991. index = resolveBegin(index, index < 0 ? this.count() : this.size);
  15992. var spliced = this.slice(0, index);
  15993. return reify(
  15994. this,
  15995. numArgs === 1 ?
  15996. spliced :
  15997. spliced.concat(arrCopy(arguments, 2), this.slice(index + removeNum))
  15998. );
  15999. },
  16000. // ### More collection methods
  16001. findLastIndex: function(predicate, context) {
  16002. var key = this.toKeyedSeq().findLastKey(predicate, context);
  16003. return key === undefined ? -1 : key;
  16004. },
  16005. first: function() {
  16006. return this.get(0);
  16007. },
  16008. flatten: function(depth) {
  16009. return reify(this, flattenFactory(this, depth, false));
  16010. },
  16011. get: function(index, notSetValue) {
  16012. index = wrapIndex(this, index);
  16013. return (index < 0 || (this.size === Infinity ||
  16014. (this.size !== undefined && index > this.size))) ?
  16015. notSetValue :
  16016. this.find(function(_, key) {return key === index}, undefined, notSetValue);
  16017. },
  16018. has: function(index) {
  16019. index = wrapIndex(this, index);
  16020. return index >= 0 && (this.size !== undefined ?
  16021. this.size === Infinity || index < this.size :
  16022. this.indexOf(index) !== -1
  16023. );
  16024. },
  16025. interpose: function(separator) {
  16026. return reify(this, interposeFactory(this, separator));
  16027. },
  16028. interleave: function(/*...iterables*/) {
  16029. var iterables = [this].concat(arrCopy(arguments));
  16030. var zipped = zipWithFactory(this.toSeq(), IndexedSeq.of, iterables);
  16031. var interleaved = zipped.flatten(true);
  16032. if (zipped.size) {
  16033. interleaved.size = zipped.size * iterables.length;
  16034. }
  16035. return reify(this, interleaved);
  16036. },
  16037. last: function() {
  16038. return this.get(-1);
  16039. },
  16040. skipWhile: function(predicate, context) {
  16041. return reify(this, skipWhileFactory(this, predicate, context, false));
  16042. },
  16043. zip: function(/*, ...iterables */) {
  16044. var iterables = [this].concat(arrCopy(arguments));
  16045. return reify(this, zipWithFactory(this, defaultZipper, iterables));
  16046. },
  16047. zipWith: function(zipper/*, ...iterables */) {
  16048. var iterables = arrCopy(arguments);
  16049. iterables[0] = this;
  16050. return reify(this, zipWithFactory(this, zipper, iterables));
  16051. }
  16052. });
  16053. IndexedIterable.prototype[IS_INDEXED_SENTINEL] = true;
  16054. IndexedIterable.prototype[IS_ORDERED_SENTINEL] = true;
  16055. mixin(SetIterable, {
  16056. // ### ES6 Collection methods (ES6 Array and Map)
  16057. get: function(value, notSetValue) {
  16058. return this.has(value) ? value : notSetValue;
  16059. },
  16060. includes: function(value) {
  16061. return this.has(value);
  16062. },
  16063. // ### More sequential methods
  16064. keySeq: function() {
  16065. return this.valueSeq();
  16066. }
  16067. });
  16068. SetIterable.prototype.has = IterablePrototype.includes;
  16069. // Mixin subclasses
  16070. mixin(KeyedSeq, KeyedIterable.prototype);
  16071. mixin(IndexedSeq, IndexedIterable.prototype);
  16072. mixin(SetSeq, SetIterable.prototype);
  16073. mixin(KeyedCollection, KeyedIterable.prototype);
  16074. mixin(IndexedCollection, IndexedIterable.prototype);
  16075. mixin(SetCollection, SetIterable.prototype);
  16076. // #pragma Helper functions
  16077. function keyMapper(v, k) {
  16078. return k;
  16079. }
  16080. function entryMapper(v, k) {
  16081. return [k, v];
  16082. }
  16083. function not(predicate) {
  16084. return function() {
  16085. return !predicate.apply(this, arguments);
  16086. }
  16087. }
  16088. function neg(predicate) {
  16089. return function() {
  16090. return -predicate.apply(this, arguments);
  16091. }
  16092. }
  16093. function quoteString(value) {
  16094. return typeof value === 'string' ? JSON.stringify(value) : value;
  16095. }
  16096. function defaultZipper() {
  16097. return arrCopy(arguments);
  16098. }
  16099. function defaultNegComparator(a, b) {
  16100. return a < b ? 1 : a > b ? -1 : 0;
  16101. }
  16102. function hashIterable(iterable) {
  16103. if (iterable.size === Infinity) {
  16104. return 0;
  16105. }
  16106. var ordered = isOrdered(iterable);
  16107. var keyed = isKeyed(iterable);
  16108. var h = ordered ? 1 : 0;
  16109. var size = iterable.__iterate(
  16110. keyed ?
  16111. ordered ?
  16112. function(v, k) { h = 31 * h + hashMerge(hash(v), hash(k)) | 0; } :
  16113. function(v, k) { h = h + hashMerge(hash(v), hash(k)) | 0; } :
  16114. ordered ?
  16115. function(v ) { h = 31 * h + hash(v) | 0; } :
  16116. function(v ) { h = h + hash(v) | 0; }
  16117. );
  16118. return murmurHashOfSize(size, h);
  16119. }
  16120. function murmurHashOfSize(size, h) {
  16121. h = imul(h, 0xCC9E2D51);
  16122. h = imul(h << 15 | h >>> -15, 0x1B873593);
  16123. h = imul(h << 13 | h >>> -13, 5);
  16124. h = (h + 0xE6546B64 | 0) ^ size;
  16125. h = imul(h ^ h >>> 16, 0x85EBCA6B);
  16126. h = imul(h ^ h >>> 13, 0xC2B2AE35);
  16127. h = smi(h ^ h >>> 16);
  16128. return h;
  16129. }
  16130. function hashMerge(a, b) {
  16131. return a ^ b + 0x9E3779B9 + (a << 6) + (a >> 2) | 0; // int
  16132. }
  16133. var Immutable = {
  16134. Iterable: Iterable,
  16135. Seq: Seq,
  16136. Collection: Collection,
  16137. Map: Map,
  16138. OrderedMap: OrderedMap,
  16139. List: List,
  16140. Stack: Stack,
  16141. Set: Set,
  16142. OrderedSet: OrderedSet,
  16143. Record: Record,
  16144. Range: Range,
  16145. Repeat: Repeat,
  16146. is: is,
  16147. fromJS: fromJS
  16148. };
  16149. return Immutable;
  16150. }));
  16151. });
  16152. var dist$2 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  16153. (function webpackUniversalModuleDefinition(root, factory) {
  16154. module.exports = factory(React__default);
  16155. })(window, function(__WEBPACK_EXTERNAL_MODULE__2__) {
  16156. return /******/ (function(modules) { // webpackBootstrap
  16157. /******/ // The module cache
  16158. /******/ var installedModules = {};
  16159. /******/
  16160. /******/ // The require function
  16161. /******/ function __webpack_require__(moduleId) {
  16162. /******/
  16163. /******/ // Check if module is in cache
  16164. /******/ if(installedModules[moduleId]) {
  16165. /******/ return installedModules[moduleId].exports;
  16166. /******/ }
  16167. /******/ // Create a new module (and put it into the cache)
  16168. /******/ var module = installedModules[moduleId] = {
  16169. /******/ i: moduleId,
  16170. /******/ l: false,
  16171. /******/ exports: {}
  16172. /******/ };
  16173. /******/
  16174. /******/ // Execute the module function
  16175. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  16176. /******/
  16177. /******/ // Flag the module as loaded
  16178. /******/ module.l = true;
  16179. /******/
  16180. /******/ // Return the exports of the module
  16181. /******/ return module.exports;
  16182. /******/ }
  16183. /******/
  16184. /******/
  16185. /******/ // expose the modules object (__webpack_modules__)
  16186. /******/ __webpack_require__.m = modules;
  16187. /******/
  16188. /******/ // expose the module cache
  16189. /******/ __webpack_require__.c = installedModules;
  16190. /******/
  16191. /******/ // define getter function for harmony exports
  16192. /******/ __webpack_require__.d = function(exports, name, getter) {
  16193. /******/ if(!__webpack_require__.o(exports, name)) {
  16194. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  16195. /******/ }
  16196. /******/ };
  16197. /******/
  16198. /******/ // define __esModule on exports
  16199. /******/ __webpack_require__.r = function(exports) {
  16200. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  16201. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  16202. /******/ }
  16203. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  16204. /******/ };
  16205. /******/
  16206. /******/ // create a fake namespace object
  16207. /******/ // mode & 1: value is a module id, require it
  16208. /******/ // mode & 2: merge all properties of value into the ns
  16209. /******/ // mode & 4: return value when already ns object
  16210. /******/ // mode & 8|1: behave like require
  16211. /******/ __webpack_require__.t = function(value, mode) {
  16212. /******/ if(mode & 1) value = __webpack_require__(value);
  16213. /******/ if(mode & 8) return value;
  16214. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  16215. /******/ var ns = Object.create(null);
  16216. /******/ __webpack_require__.r(ns);
  16217. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  16218. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  16219. /******/ return ns;
  16220. /******/ };
  16221. /******/
  16222. /******/ // getDefaultExport function for compatibility with non-harmony modules
  16223. /******/ __webpack_require__.n = function(module) {
  16224. /******/ var getter = module && module.__esModule ?
  16225. /******/ function getDefault() { return module['default']; } :
  16226. /******/ function getModuleExports() { return module; };
  16227. /******/ __webpack_require__.d(getter, 'a', getter);
  16228. /******/ return getter;
  16229. /******/ };
  16230. /******/
  16231. /******/ // Object.prototype.hasOwnProperty.call
  16232. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  16233. /******/
  16234. /******/ // __webpack_public_path__
  16235. /******/ __webpack_require__.p = "/";
  16236. /******/
  16237. /******/
  16238. /******/ // Load entry module and return exports
  16239. /******/ return __webpack_require__(__webpack_require__.s = 20);
  16240. /******/ })
  16241. /************************************************************************/
  16242. /******/ ([
  16243. /* 0 */
  16244. /***/ (function(module, exports, __webpack_require__) {
  16245. Object.defineProperty(exports, "__esModule", {
  16246. value: true
  16247. });
  16248. var compressImage = exports.compressImage = function compressImage(url) {
  16249. var width = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1280;
  16250. var height = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 800;
  16251. return new Promise(function (resolve, reject) {
  16252. var image = new Image();
  16253. image.src = url;
  16254. image.onerror = function (error) {
  16255. reject(error);
  16256. };
  16257. image.onload = function () {
  16258. try {
  16259. var compressCanvas = document.createElement('canvas');
  16260. var scale = this.width > width || this.height > height ? this.width > this.height ? width / this.width : height / this.height : 1;
  16261. compressCanvas.width = this.width * scale;
  16262. compressCanvas.height = this.height * scale;
  16263. var canvasContext = compressCanvas.getContext('2d');
  16264. canvasContext.drawImage(this, 0, 0, compressCanvas.width, compressCanvas.height);
  16265. resolve({
  16266. url: compressCanvas.toDataURL('image/png', 1),
  16267. width: compressCanvas.width,
  16268. height: compressCanvas.height
  16269. });
  16270. } catch (error) {
  16271. reject(error);
  16272. }
  16273. };
  16274. });
  16275. };
  16276. /***/ }),
  16277. /* 1 */
  16278. /***/ (function(module, exports, __webpack_require__) {
  16279. Object.defineProperty(exports, "__esModule", {
  16280. value: true
  16281. });
  16282. var UniqueIndex = exports.UniqueIndex = function UniqueIndex() {
  16283. if (isNaN(window.__BRAFT_MM_UNIQUE_INDEX__)) {
  16284. window.__BRAFT_MM_UNIQUE_INDEX__ = 1;
  16285. } else {
  16286. window.__BRAFT_MM_UNIQUE_INDEX__ += 1;
  16287. }
  16288. return window.__BRAFT_MM_UNIQUE_INDEX__;
  16289. };
  16290. /***/ }),
  16291. /* 2 */
  16292. /***/ (function(module, exports) {
  16293. module.exports = __WEBPACK_EXTERNAL_MODULE__2__;
  16294. /***/ }),
  16295. /* 3 */
  16296. /***/ (function(module, exports, __webpack_require__) {
  16297. Object.defineProperty(exports, "__esModule", {
  16298. value: true
  16299. });
  16300. exports.default = {
  16301. remove: 'Kaldır',
  16302. cancel: 'İptal',
  16303. confirm: 'Onayla',
  16304. insert: 'Seçilenleri ekle',
  16305. width: 'Genişlik',
  16306. height: 'Yükseklik',
  16307. image: 'Resim',
  16308. video: 'Görüntü',
  16309. audio: 'Ses',
  16310. embed: 'Nesne göm',
  16311. caption: 'Kitaplık',
  16312. dragTip: 'Tıkla ya da dosya sürükle',
  16313. dropTip: 'Yüklemek için sürükleyin',
  16314. selectAll: 'Tümünü seç',
  16315. deselect: 'Seçimi kaldır',
  16316. removeSelected: 'Seçilenleri kaldır',
  16317. externalInputPlaceHolder: 'Kaynak adı|Kaynak bağlantısı',
  16318. externalInputTip: 'Kaynak asını ve bağlantısını "|" ile ayırın ve Enter\' a basın.',
  16319. addLocalFile: 'Yerel\' den ekle',
  16320. addExternalSource: 'Harici kaynaktan ekle',
  16321. unnamedItem: 'Adlandırılmamış giriş',
  16322. confirmInsert: 'Seçilenleri ekle'
  16323. };
  16324. /***/ }),
  16325. /* 4 */
  16326. /***/ (function(module, exports, __webpack_require__) {
  16327. Object.defineProperty(exports, "__esModule", {
  16328. value: true
  16329. });
  16330. exports.default = {
  16331. remove: '削除する',
  16332. cancel: 'キャンセル',
  16333. confirm: '確認する',
  16334. insert: '選択したアイテムを挿入',
  16335. width: '幅',
  16336. height: '身長',
  16337. image: '絵',
  16338. video: 'ビデオ',
  16339. audio: '音声',
  16340. embed: '埋め込みメディア',
  16341. caption: 'メディアライブラリー',
  16342. dragTip: 'ファイルをこの位置までクリックまたはドラッグします',
  16343. dropTip: 'アップロードするマウスを放します',
  16344. selectAll: 'すべて選択',
  16345. deselect: '選択を解除',
  16346. removeSelected: '選択したアイテムを削除',
  16347. externalInputPlaceHolder: 'リソース名|リソースアドレス',
  16348. externalInputTip: 'リソース名とリソースアドレスは "|"で区切ります。',
  16349. addLocalFile: 'ローカルリソースを追加する',
  16350. addExternalSource: 'ネットワークリソースを追加する',
  16351. unnamedItem: '名前のないアイテム',
  16352. confirmInsert: '選択したアイテムを挿入'
  16353. };
  16354. /***/ }),
  16355. /* 5 */
  16356. /***/ (function(module, exports, __webpack_require__) {
  16357. Object.defineProperty(exports, "__esModule", {
  16358. value: true
  16359. });
  16360. exports.default = {
  16361. remove: '삭제',
  16362. cancel: '취소',
  16363. confirm: '확인',
  16364. insert: '선택한항목삽입',
  16365. width: '너비',
  16366. height: '높이',
  16367. image: '그림',
  16368. video: '비디오',
  16369. audio: '오디오',
  16370. embed: '임베디드미디어',
  16371. caption: '미디어라이브러리',
  16372. dragTip: '파일을 클릭하거나이 지점으로 드래그하십시오.',
  16373. dropTip: '업로드하려면마우스를놓으십시오.',
  16374. selectAll: '모두 선택',
  16375. deselect: '선택 취소',
  16376. removeSelected: '선택한 항목 삭제',
  16377. externalInputPlaceHolder: '리소스 이름 | 리소스 주소',
  16378. externalInputTip: '자원 이름과 자원 주소를 "|"',
  16379. addLocalFile: '로컬 리소스 추가',
  16380. addExternalSource: '네트워크 리소스 추가',
  16381. unnamedItem: '이름없는 항목',
  16382. confirmInsert: '선택한 항목 삽입'
  16383. };
  16384. /***/ }),
  16385. /* 6 */
  16386. /***/ (function(module, exports, __webpack_require__) {
  16387. Object.defineProperty(exports, "__esModule", {
  16388. value: true
  16389. });
  16390. exports.default = {
  16391. remove: 'Usuń',
  16392. cancel: 'Anuluj',
  16393. confirm: 'Potwierdź',
  16394. insert: 'Wstaw wybrane elementy',
  16395. width: 'Szerokość',
  16396. height: 'Wysokość',
  16397. image: 'Obraz',
  16398. video: 'Wideo',
  16399. audio: 'Dźwięk',
  16400. embed: 'Obiekt',
  16401. caption: 'Biblioteka mediów',
  16402. dragTip: 'Kliknij lub przenieś tu pliki',
  16403. dropTip: 'Upuść aby dodać plik',
  16404. selectAll: 'Zaznacz wszystko',
  16405. deselect: 'Odznacz',
  16406. removeSelected: 'Usuń wybrane',
  16407. externalInputPlaceHolder: 'Nazwa źródła|Adres URL',
  16408. externalInputTip: 'Oddziel nazwę i adres URL źródła z pomocą "|", Potwierdź Enter-em',
  16409. addLocalFile: 'Dodaj z komputera',
  16410. addExternalSource: 'Dodaj z Internetu',
  16411. unnamedItem: 'Bez nazwy',
  16412. confirmInsert: 'Dodaj wybrane elementy'
  16413. };
  16414. /***/ }),
  16415. /* 7 */
  16416. /***/ (function(module, exports, __webpack_require__) {
  16417. Object.defineProperty(exports, "__esModule", {
  16418. value: true
  16419. });
  16420. exports.default = {
  16421. remove: '删除',
  16422. cancel: '取消',
  16423. confirm: '确认',
  16424. insert: '插入所选项目',
  16425. width: '宽度',
  16426. height: '高度',
  16427. image: '图片',
  16428. video: '视频',
  16429. audio: '音频',
  16430. embed: '嵌入式媒体',
  16431. caption: '媒体库',
  16432. dragTip: '点击或拖动文件至此',
  16433. dropTip: '放开鼠标以上传',
  16434. selectAll: '选择全部',
  16435. deselect: '取消选择',
  16436. removeSelected: '删除选中项目',
  16437. externalInputPlaceHolder: '资源名称|资源地址',
  16438. externalInputTip: '使用“|”分隔资源名称和资源地址',
  16439. addLocalFile: '添加本地资源',
  16440. addExternalSource: '添加网络资源',
  16441. unnamedItem: '未命名项目',
  16442. confirmInsert: '插入选中项目'
  16443. };
  16444. /***/ }),
  16445. /* 8 */
  16446. /***/ (function(module, exports, __webpack_require__) {
  16447. Object.defineProperty(exports, "__esModule", {
  16448. value: true
  16449. });
  16450. exports.default = {
  16451. remove: '删除',
  16452. cancel: '取消',
  16453. confirm: '确认',
  16454. insert: '插入所选项目',
  16455. width: '宽度',
  16456. height: '高度',
  16457. image: '图片',
  16458. video: '视频',
  16459. audio: '音频',
  16460. embed: '嵌入式媒体',
  16461. caption: '媒体库',
  16462. dragTip: '点击或拖动文件至此',
  16463. dropTip: '放开鼠标以上传',
  16464. selectAll: '选择全部',
  16465. deselect: '取消选择',
  16466. removeSelected: '删除选中项目',
  16467. externalInputPlaceHolder: '资源名称|资源地址',
  16468. externalInputTip: '使用“|”分隔资源名称和资源地址',
  16469. addLocalFile: '添加本地资源',
  16470. addExternalSource: '添加网络资源',
  16471. unnamedItem: '未命名项目',
  16472. confirmInsert: '插入选中项目'
  16473. };
  16474. /***/ }),
  16475. /* 9 */
  16476. /***/ (function(module, exports, __webpack_require__) {
  16477. Object.defineProperty(exports, "__esModule", {
  16478. value: true
  16479. });
  16480. exports.default = {
  16481. remove: 'Remove',
  16482. cancel: 'Cancel',
  16483. confirm: 'Confirm',
  16484. insert: 'Insert Selected Items',
  16485. width: 'Width',
  16486. height: 'Height',
  16487. image: 'Image',
  16488. video: 'Video',
  16489. audio: 'Audio',
  16490. embed: 'Embed',
  16491. caption: 'Media Library',
  16492. dragTip: 'Click Or Drag Files Here',
  16493. dropTip: 'Drop To Upload',
  16494. selectAll: 'Select All',
  16495. deselect: 'Deselect',
  16496. removeSelected: 'Remove Selected Items',
  16497. externalInputPlaceHolder: 'Source Name|Source URL',
  16498. externalInputTip: 'Split source name and source URL with "|", confirm by hit Enter.',
  16499. addLocalFile: 'Add from local',
  16500. addExternalSource: 'Add from Internet',
  16501. unnamedItem: 'Unnamed Item',
  16502. confirmInsert: 'Insert selected items'
  16503. };
  16504. /***/ }),
  16505. /* 10 */
  16506. /***/ (function(module, exports, __webpack_require__) {
  16507. Object.defineProperty(exports, "__esModule", {
  16508. value: true
  16509. });
  16510. var _en = __webpack_require__(9);
  16511. var _en2 = _interopRequireDefault(_en);
  16512. var _zh = __webpack_require__(8);
  16513. var _zh2 = _interopRequireDefault(_zh);
  16514. var _zhHant = __webpack_require__(7);
  16515. var _zhHant2 = _interopRequireDefault(_zhHant);
  16516. var _pl = __webpack_require__(6);
  16517. var _pl2 = _interopRequireDefault(_pl);
  16518. var _kr = __webpack_require__(5);
  16519. var _kr2 = _interopRequireDefault(_kr);
  16520. var _jpn = __webpack_require__(4);
  16521. var _jpn2 = _interopRequireDefault(_jpn);
  16522. var _tr = __webpack_require__(3);
  16523. var _tr2 = _interopRequireDefault(_tr);
  16524. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  16525. exports.default = {
  16526. "en": _en2.default,
  16527. "zh": _zh2.default,
  16528. "zh-hant": _zhHant2.default,
  16529. "pl": _pl2.default,
  16530. "kr": _kr2.default,
  16531. "jpn": _jpn2.default,
  16532. "tr": _tr2.default
  16533. };
  16534. /***/ }),
  16535. /* 11 */
  16536. /***/ (function(module, exports) {
  16537. /**
  16538. * When source maps are enabled, `style-loader` uses a link element with a data-uri to
  16539. * embed the css on the page. This breaks all relative urls because now they are relative to a
  16540. * bundle instead of the current page.
  16541. *
  16542. * One solution is to only use full urls, but that may be impossible.
  16543. *
  16544. * Instead, this function "fixes" the relative urls to be absolute according to the current page location.
  16545. *
  16546. * A rudimentary test suite is located at `test/fixUrls.js` and can be run via the `npm test` command.
  16547. *
  16548. */
  16549. module.exports = function (css) {
  16550. // get current location
  16551. var location = typeof window !== "undefined" && window.location;
  16552. if (!location) {
  16553. throw new Error("fixUrls requires window.location");
  16554. }
  16555. // blank or null?
  16556. if (!css || typeof css !== "string") {
  16557. return css;
  16558. }
  16559. var baseUrl = location.protocol + "//" + location.host;
  16560. var currentDir = baseUrl + location.pathname.replace(/\/[^\/]*$/, "/");
  16561. // convert each url(...)
  16562. /*
  16563. This regular expression is just a way to recursively match brackets within
  16564. a string.
  16565. /url\s*\( = Match on the word "url" with any whitespace after it and then a parens
  16566. ( = Start a capturing group
  16567. (?: = Start a non-capturing group
  16568. [^)(] = Match anything that isn't a parentheses
  16569. | = OR
  16570. \( = Match a start parentheses
  16571. (?: = Start another non-capturing groups
  16572. [^)(]+ = Match anything that isn't a parentheses
  16573. | = OR
  16574. \( = Match a start parentheses
  16575. [^)(]* = Match anything that isn't a parentheses
  16576. \) = Match a end parentheses
  16577. ) = End Group
  16578. *\) = Match anything and then a close parens
  16579. ) = Close non-capturing group
  16580. * = Match anything
  16581. ) = Close capturing group
  16582. \) = Match a close parens
  16583. /gi = Get all matches, not the first. Be case insensitive.
  16584. */
  16585. var fixedCss = css.replace(/url\s*\(((?:[^)(]|\((?:[^)(]+|\([^)(]*\))*\))*)\)/gi, function(fullMatch, origUrl) {
  16586. // strip quotes (if they exist)
  16587. var unquotedOrigUrl = origUrl
  16588. .trim()
  16589. .replace(/^"(.*)"$/, function(o, $1){ return $1; })
  16590. .replace(/^'(.*)'$/, function(o, $1){ return $1; });
  16591. // already a full url? no change
  16592. if (/^(#|data:|http:\/\/|https:\/\/|file:\/\/\/|\s*$)/i.test(unquotedOrigUrl)) {
  16593. return fullMatch;
  16594. }
  16595. // convert the url to a full url
  16596. var newUrl;
  16597. if (unquotedOrigUrl.indexOf("//") === 0) {
  16598. //TODO: should we add protocol?
  16599. newUrl = unquotedOrigUrl;
  16600. } else if (unquotedOrigUrl.indexOf("/") === 0) {
  16601. // path should be relative to the base url
  16602. newUrl = baseUrl + unquotedOrigUrl; // already starts with '/'
  16603. } else {
  16604. // path should be relative to current directory
  16605. newUrl = currentDir + unquotedOrigUrl.replace(/^\.\//, ""); // Strip leading './'
  16606. }
  16607. // send back the fixed url(...)
  16608. return "url(" + JSON.stringify(newUrl) + ")";
  16609. });
  16610. // send back the fixed css
  16611. return fixedCss;
  16612. };
  16613. /***/ }),
  16614. /* 12 */
  16615. /***/ (function(module, exports, __webpack_require__) {
  16616. /*
  16617. MIT License http://www.opensource.org/licenses/mit-license.php
  16618. Author Tobias Koppers @sokra
  16619. */
  16620. var stylesInDom = {};
  16621. var memoize = function (fn) {
  16622. var memo;
  16623. return function () {
  16624. if (typeof memo === "undefined") memo = fn.apply(this, arguments);
  16625. return memo;
  16626. };
  16627. };
  16628. var isOldIE = memoize(function () {
  16629. // Test for IE <= 9 as proposed by Browserhacks
  16630. // @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805
  16631. // Tests for existence of standard globals is to allow style-loader
  16632. // to operate correctly into non-standard environments
  16633. // @see https://github.com/webpack-contrib/style-loader/issues/177
  16634. return window && document && document.all && !window.atob;
  16635. });
  16636. var getTarget = function (target) {
  16637. return document.querySelector(target);
  16638. };
  16639. var getElement = (function (fn) {
  16640. var memo = {};
  16641. return function(target) {
  16642. // If passing function in options, then use it for resolve "head" element.
  16643. // Useful for Shadow Root style i.e
  16644. // {
  16645. // insertInto: function () { return document.querySelector("#foo").shadowRoot }
  16646. // }
  16647. if (typeof target === 'function') {
  16648. return target();
  16649. }
  16650. if (typeof memo[target] === "undefined") {
  16651. var styleTarget = getTarget.call(this, target);
  16652. // Special case to return head of iframe instead of iframe itself
  16653. if (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {
  16654. try {
  16655. // This will throw an exception if access to iframe is blocked
  16656. // due to cross-origin restrictions
  16657. styleTarget = styleTarget.contentDocument.head;
  16658. } catch(e) {
  16659. styleTarget = null;
  16660. }
  16661. }
  16662. memo[target] = styleTarget;
  16663. }
  16664. return memo[target]
  16665. };
  16666. })();
  16667. var singleton = null;
  16668. var singletonCounter = 0;
  16669. var stylesInsertedAtTop = [];
  16670. var fixUrls = __webpack_require__(11);
  16671. module.exports = function(list, options) {
  16672. if (typeof DEBUG !== "undefined" && DEBUG) {
  16673. if (typeof document !== "object") throw new Error("The style-loader cannot be used in a non-browser environment");
  16674. }
  16675. options = options || {};
  16676. options.attrs = typeof options.attrs === "object" ? options.attrs : {};
  16677. // Force single-tag solution on IE6-9, which has a hard limit on the # of <style>
  16678. // tags it will allow on a page
  16679. if (!options.singleton && typeof options.singleton !== "boolean") options.singleton = isOldIE();
  16680. // By default, add <style> tags to the <head> element
  16681. if (!options.insertInto) options.insertInto = "head";
  16682. // By default, add <style> tags to the bottom of the target
  16683. if (!options.insertAt) options.insertAt = "bottom";
  16684. var styles = listToStyles(list, options);
  16685. addStylesToDom(styles, options);
  16686. return function update (newList) {
  16687. var mayRemove = [];
  16688. for (var i = 0; i < styles.length; i++) {
  16689. var item = styles[i];
  16690. var domStyle = stylesInDom[item.id];
  16691. domStyle.refs--;
  16692. mayRemove.push(domStyle);
  16693. }
  16694. if(newList) {
  16695. var newStyles = listToStyles(newList, options);
  16696. addStylesToDom(newStyles, options);
  16697. }
  16698. for (var i = 0; i < mayRemove.length; i++) {
  16699. var domStyle = mayRemove[i];
  16700. if(domStyle.refs === 0) {
  16701. for (var j = 0; j < domStyle.parts.length; j++) domStyle.parts[j]();
  16702. delete stylesInDom[domStyle.id];
  16703. }
  16704. }
  16705. };
  16706. };
  16707. function addStylesToDom (styles, options) {
  16708. for (var i = 0; i < styles.length; i++) {
  16709. var item = styles[i];
  16710. var domStyle = stylesInDom[item.id];
  16711. if(domStyle) {
  16712. domStyle.refs++;
  16713. for(var j = 0; j < domStyle.parts.length; j++) {
  16714. domStyle.parts[j](item.parts[j]);
  16715. }
  16716. for(; j < item.parts.length; j++) {
  16717. domStyle.parts.push(addStyle(item.parts[j], options));
  16718. }
  16719. } else {
  16720. var parts = [];
  16721. for(var j = 0; j < item.parts.length; j++) {
  16722. parts.push(addStyle(item.parts[j], options));
  16723. }
  16724. stylesInDom[item.id] = {id: item.id, refs: 1, parts: parts};
  16725. }
  16726. }
  16727. }
  16728. function listToStyles (list, options) {
  16729. var styles = [];
  16730. var newStyles = {};
  16731. for (var i = 0; i < list.length; i++) {
  16732. var item = list[i];
  16733. var id = options.base ? item[0] + options.base : item[0];
  16734. var css = item[1];
  16735. var media = item[2];
  16736. var sourceMap = item[3];
  16737. var part = {css: css, media: media, sourceMap: sourceMap};
  16738. if(!newStyles[id]) styles.push(newStyles[id] = {id: id, parts: [part]});
  16739. else newStyles[id].parts.push(part);
  16740. }
  16741. return styles;
  16742. }
  16743. function insertStyleElement (options, style) {
  16744. var target = getElement(options.insertInto);
  16745. if (!target) {
  16746. throw new Error("Couldn't find a style target. This probably means that the value for the 'insertInto' parameter is invalid.");
  16747. }
  16748. var lastStyleElementInsertedAtTop = stylesInsertedAtTop[stylesInsertedAtTop.length - 1];
  16749. if (options.insertAt === "top") {
  16750. if (!lastStyleElementInsertedAtTop) {
  16751. target.insertBefore(style, target.firstChild);
  16752. } else if (lastStyleElementInsertedAtTop.nextSibling) {
  16753. target.insertBefore(style, lastStyleElementInsertedAtTop.nextSibling);
  16754. } else {
  16755. target.appendChild(style);
  16756. }
  16757. stylesInsertedAtTop.push(style);
  16758. } else if (options.insertAt === "bottom") {
  16759. target.appendChild(style);
  16760. } else if (typeof options.insertAt === "object" && options.insertAt.before) {
  16761. var nextSibling = getElement(options.insertInto + " " + options.insertAt.before);
  16762. target.insertBefore(style, nextSibling);
  16763. } else {
  16764. 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");
  16765. }
  16766. }
  16767. function removeStyleElement (style) {
  16768. if (style.parentNode === null) return false;
  16769. style.parentNode.removeChild(style);
  16770. var idx = stylesInsertedAtTop.indexOf(style);
  16771. if(idx >= 0) {
  16772. stylesInsertedAtTop.splice(idx, 1);
  16773. }
  16774. }
  16775. function createStyleElement (options) {
  16776. var style = document.createElement("style");
  16777. if(options.attrs.type === undefined) {
  16778. options.attrs.type = "text/css";
  16779. }
  16780. addAttrs(style, options.attrs);
  16781. insertStyleElement(options, style);
  16782. return style;
  16783. }
  16784. function createLinkElement (options) {
  16785. var link = document.createElement("link");
  16786. if(options.attrs.type === undefined) {
  16787. options.attrs.type = "text/css";
  16788. }
  16789. options.attrs.rel = "stylesheet";
  16790. addAttrs(link, options.attrs);
  16791. insertStyleElement(options, link);
  16792. return link;
  16793. }
  16794. function addAttrs (el, attrs) {
  16795. Object.keys(attrs).forEach(function (key) {
  16796. el.setAttribute(key, attrs[key]);
  16797. });
  16798. }
  16799. function addStyle (obj, options) {
  16800. var style, update, remove, result;
  16801. // If a transform function was defined, run it on the css
  16802. if (options.transform && obj.css) {
  16803. result = options.transform(obj.css);
  16804. if (result) {
  16805. // If transform returns a value, use that instead of the original css.
  16806. // This allows running runtime transformations on the css.
  16807. obj.css = result;
  16808. } else {
  16809. // If the transform function returns a falsy value, don't add this css.
  16810. // This allows conditional loading of css
  16811. return function() {
  16812. // noop
  16813. };
  16814. }
  16815. }
  16816. if (options.singleton) {
  16817. var styleIndex = singletonCounter++;
  16818. style = singleton || (singleton = createStyleElement(options));
  16819. update = applyToSingletonTag.bind(null, style, styleIndex, false);
  16820. remove = applyToSingletonTag.bind(null, style, styleIndex, true);
  16821. } else if (
  16822. obj.sourceMap &&
  16823. typeof URL === "function" &&
  16824. typeof URL.createObjectURL === "function" &&
  16825. typeof URL.revokeObjectURL === "function" &&
  16826. typeof Blob === "function" &&
  16827. typeof btoa === "function"
  16828. ) {
  16829. style = createLinkElement(options);
  16830. update = updateLink.bind(null, style, options);
  16831. remove = function () {
  16832. removeStyleElement(style);
  16833. if(style.href) URL.revokeObjectURL(style.href);
  16834. };
  16835. } else {
  16836. style = createStyleElement(options);
  16837. update = applyToTag.bind(null, style);
  16838. remove = function () {
  16839. removeStyleElement(style);
  16840. };
  16841. }
  16842. update(obj);
  16843. return function updateStyle (newObj) {
  16844. if (newObj) {
  16845. if (
  16846. newObj.css === obj.css &&
  16847. newObj.media === obj.media &&
  16848. newObj.sourceMap === obj.sourceMap
  16849. ) {
  16850. return;
  16851. }
  16852. update(obj = newObj);
  16853. } else {
  16854. remove();
  16855. }
  16856. };
  16857. }
  16858. var replaceText = (function () {
  16859. var textStore = [];
  16860. return function (index, replacement) {
  16861. textStore[index] = replacement;
  16862. return textStore.filter(Boolean).join('\n');
  16863. };
  16864. })();
  16865. function applyToSingletonTag (style, index, remove, obj) {
  16866. var css = remove ? "" : obj.css;
  16867. if (style.styleSheet) {
  16868. style.styleSheet.cssText = replaceText(index, css);
  16869. } else {
  16870. var cssNode = document.createTextNode(css);
  16871. var childNodes = style.childNodes;
  16872. if (childNodes[index]) style.removeChild(childNodes[index]);
  16873. if (childNodes.length) {
  16874. style.insertBefore(cssNode, childNodes[index]);
  16875. } else {
  16876. style.appendChild(cssNode);
  16877. }
  16878. }
  16879. }
  16880. function applyToTag (style, obj) {
  16881. var css = obj.css;
  16882. var media = obj.media;
  16883. if(media) {
  16884. style.setAttribute("media", media);
  16885. }
  16886. if(style.styleSheet) {
  16887. style.styleSheet.cssText = css;
  16888. } else {
  16889. while(style.firstChild) {
  16890. style.removeChild(style.firstChild);
  16891. }
  16892. style.appendChild(document.createTextNode(css));
  16893. }
  16894. }
  16895. function updateLink (link, options, obj) {
  16896. var css = obj.css;
  16897. var sourceMap = obj.sourceMap;
  16898. /*
  16899. If convertToAbsoluteUrls isn't defined, but sourcemaps are enabled
  16900. and there is no publicPath defined then lets turn convertToAbsoluteUrls
  16901. on by default. Otherwise default to the convertToAbsoluteUrls option
  16902. directly
  16903. */
  16904. var autoFixUrls = options.convertToAbsoluteUrls === undefined && sourceMap;
  16905. if (options.convertToAbsoluteUrls || autoFixUrls) {
  16906. css = fixUrls(css);
  16907. }
  16908. if (sourceMap) {
  16909. // http://stackoverflow.com/a/26603875
  16910. css += "\n/*# sourceMappingURL=data:application/json;base64," + btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap)))) + " */";
  16911. }
  16912. var blob = new Blob([css], { type: "text/css" });
  16913. var oldSrc = link.href;
  16914. link.href = URL.createObjectURL(blob);
  16915. if(oldSrc) URL.revokeObjectURL(oldSrc);
  16916. }
  16917. /***/ }),
  16918. /* 13 */
  16919. /***/ (function(module, exports) {
  16920. 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=";
  16921. /***/ }),
  16922. /* 14 */
  16923. /***/ (function(module, exports) {
  16924. /*
  16925. MIT License http://www.opensource.org/licenses/mit-license.php
  16926. Author Tobias Koppers @sokra
  16927. */
  16928. // css base code, injected by the css-loader
  16929. module.exports = function(useSourceMap) {
  16930. var list = [];
  16931. // return the list of modules as css string
  16932. list.toString = function toString() {
  16933. return this.map(function (item) {
  16934. var content = cssWithMappingToString(item, useSourceMap);
  16935. if(item[2]) {
  16936. return "@media " + item[2] + "{" + content + "}";
  16937. } else {
  16938. return content;
  16939. }
  16940. }).join("");
  16941. };
  16942. // import a list of modules into the list
  16943. list.i = function(modules, mediaQuery) {
  16944. if(typeof modules === "string")
  16945. modules = [[null, modules, ""]];
  16946. var alreadyImportedModules = {};
  16947. for(var i = 0; i < this.length; i++) {
  16948. var id = this[i][0];
  16949. if(typeof id === "number")
  16950. alreadyImportedModules[id] = true;
  16951. }
  16952. for(i = 0; i < modules.length; i++) {
  16953. var item = modules[i];
  16954. // skip already imported module
  16955. // this implementation is not 100% perfect for weird media query combinations
  16956. // when a module is imported multiple times with different media queries.
  16957. // I hope this will never occur (Hey this way we have smaller bundles)
  16958. if(typeof item[0] !== "number" || !alreadyImportedModules[item[0]]) {
  16959. if(mediaQuery && !item[2]) {
  16960. item[2] = mediaQuery;
  16961. } else if(mediaQuery) {
  16962. item[2] = "(" + item[2] + ") and (" + mediaQuery + ")";
  16963. }
  16964. list.push(item);
  16965. }
  16966. }
  16967. };
  16968. return list;
  16969. };
  16970. function cssWithMappingToString(item, useSourceMap) {
  16971. var content = item[1] || '';
  16972. var cssMapping = item[3];
  16973. if (!cssMapping) {
  16974. return content;
  16975. }
  16976. if (useSourceMap && typeof btoa === 'function') {
  16977. var sourceMapping = toComment(cssMapping);
  16978. var sourceURLs = cssMapping.sources.map(function (source) {
  16979. return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */'
  16980. });
  16981. return [content].concat(sourceURLs).concat([sourceMapping]).join('\n');
  16982. }
  16983. return [content].join('\n');
  16984. }
  16985. // Adapted from convert-source-map (MIT)
  16986. function toComment(sourceMap) {
  16987. // eslint-disable-next-line no-undef
  16988. var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));
  16989. var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;
  16990. return '/*# ' + data + ' */';
  16991. }
  16992. /***/ }),
  16993. /* 15 */
  16994. /***/ (function(module, exports) {
  16995. module.exports = function escape(url) {
  16996. if (typeof url !== 'string') {
  16997. return url
  16998. }
  16999. // If url is already wrapped in quotes, remove them
  17000. if (/^['"].*['"]$/.test(url)) {
  17001. url = url.slice(1, -1);
  17002. }
  17003. // Should url be wrapped?
  17004. // See https://drafts.csswg.org/css-values-3/#urls
  17005. if (/["'() \t\n]/.test(url)) {
  17006. return '"' + url.replace(/"/g, '\\"').replace(/\n/g, '\\n') + '"'
  17007. }
  17008. return url
  17009. };
  17010. /***/ }),
  17011. /* 16 */
  17012. /***/ (function(module, exports, __webpack_require__) {
  17013. var escape = __webpack_require__(15);
  17014. exports = module.exports = __webpack_require__(14)(false);
  17015. // imports
  17016. // module
  17017. 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", ""]);
  17018. // exports
  17019. /***/ }),
  17020. /* 17 */
  17021. /***/ (function(module, exports, __webpack_require__) {
  17022. var content = __webpack_require__(16);
  17023. if(typeof content === 'string') content = [[module.i, content, '']];
  17024. var transform;
  17025. var options = {"hmr":true};
  17026. options.transform = transform;
  17027. options.insertInto = undefined;
  17028. var update = __webpack_require__(12)(content, options);
  17029. if(content.locals) module.exports = content.locals;
  17030. /***/ }),
  17031. /* 18 */
  17032. /***/ (function(module, exports, __webpack_require__) {
  17033. Object.defineProperty(exports, "__esModule", {
  17034. value: true
  17035. });
  17036. 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; };
  17037. 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; }; }();
  17038. __webpack_require__(17);
  17039. var _react = __webpack_require__(2);
  17040. var _react2 = _interopRequireDefault(_react);
  17041. var _base = __webpack_require__(1);
  17042. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17043. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17044. 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; }
  17045. 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; }
  17046. var defaultAccepts = {
  17047. image: 'image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg',
  17048. video: 'video/mp4',
  17049. audio: 'audio/mp3'
  17050. };
  17051. var BraftFinderView = function (_React$Component) {
  17052. _inherits(BraftFinderView, _React$Component);
  17053. function BraftFinderView(props) {
  17054. _classCallCheck(this, BraftFinderView);
  17055. var _this = _possibleConstructorReturn(this, (BraftFinderView.__proto__ || Object.getPrototypeOf(BraftFinderView)).call(this, props));
  17056. _this.toggleSelectItem = function (event) {
  17057. var itemId = event.currentTarget.dataset.id;
  17058. var item = _this.controller.getMediaItem(itemId);
  17059. if (!item) {
  17060. return false;
  17061. }
  17062. if (item.selected) {
  17063. if (!_this.props.onBeforeDeselect || _this.props.onBeforeDeselect([item], _this.controller.getItems()) !== false) {
  17064. _this.controller.deselectMediaItem(itemId);
  17065. _this.props.onDeselect && _this.props.onDeselect([item], _this.controller.getItems());
  17066. }
  17067. } else {
  17068. if (!_this.props.onBeforeSelect || _this.props.onBeforeSelect([item], _this.controller.getItems()) !== false) {
  17069. _this.controller.selectMediaItem(itemId);
  17070. _this.props.onSelect && _this.props.onSelect([item], _this.controller.getItems());
  17071. }
  17072. }
  17073. };
  17074. _this.removeItem = function (event) {
  17075. var itemId = event.currentTarget.dataset.id;
  17076. var item = _this.controller.getMediaItem(itemId);
  17077. if (!item) {
  17078. return false;
  17079. }
  17080. if (!_this.props.onBeforeRemove || _this.props.onBeforeRemove([item], _this.controller.getItems()) !== false) {
  17081. _this.controller.removeMediaItem(itemId);
  17082. _this.props.onRemove && _this.props.onRemove([item], _this.controller.getItems());
  17083. }
  17084. event.stopPropagation();
  17085. };
  17086. _this.selectAllItems = function () {
  17087. var allItems = _this.controller.getItems();
  17088. if (!_this.props.onBeforeSelect || _this.props.onBeforeSelect(allItems, allItems) !== false) {
  17089. _this.controller.selectAllItems();
  17090. _this.props.onSelect && _this.props.onSelect(allItems, allItems);
  17091. }
  17092. };
  17093. _this.deselectAllItems = function () {
  17094. var allItems = _this.controller.getItems();
  17095. if (!_this.props.onBeforeDeselect || _this.props.onBeforeDeselect(allItems, allItems) !== false) {
  17096. _this.controller.deselectAllItems();
  17097. _this.props.onDeselect && _this.props.onDeselect(allItems, allItems);
  17098. }
  17099. };
  17100. _this.removeSelectedItems = function () {
  17101. var selectedItems = _this.controller.getSelectedItems();
  17102. if (!_this.props.onBeforeRemove || _this.props.onBeforeRemove(selectedItems, _this.controller.getItems()) !== false) {
  17103. _this.controller.removeSelectedItems();
  17104. _this.props.onRemove && _this.props.onRemove(selectedItems, _this.controller.getItems());
  17105. }
  17106. };
  17107. _this.handleDragLeave = function (event) {
  17108. event.preventDefault();
  17109. _this.dragCounter--;
  17110. _this.dragCounter === 0 && _this.setState({
  17111. draging: false
  17112. });
  17113. };
  17114. _this.handleDragDrop = function (event) {
  17115. event.preventDefault();
  17116. _this.dragCounter = 0;
  17117. _this.setState({ draging: false });
  17118. _this.reslovePickedFiles(event);
  17119. };
  17120. _this.handleDragEnter = function (event) {
  17121. event.preventDefault();
  17122. _this.dragCounter++;
  17123. _this.setState({ draging: true });
  17124. };
  17125. _this.reslovePickedFiles = function (event) {
  17126. event.persist();
  17127. var _ref = event.type === 'drop' ? event.dataTransfer : event.target,
  17128. files = _ref.files;
  17129. if (_this.props.onFileSelect) {
  17130. var result = _this.props.onFileSelect(files);
  17131. if (result === false) {
  17132. return false;
  17133. } else if (result instanceof FileList || result instanceof Array) {
  17134. files = result;
  17135. }
  17136. }
  17137. var accepts = _extends({}, defaultAccepts, _this.props.accepts);
  17138. _this.controller.resolveFiles({
  17139. files: files,
  17140. onItemReady: function onItemReady(_ref2) {
  17141. var id = _ref2.id;
  17142. return _this.controller.selectMediaItem(id);
  17143. },
  17144. onAllReady: function onAllReady() {
  17145. return event.target.value = null;
  17146. }
  17147. }, 0, accepts);
  17148. };
  17149. _this.inputExternal = function (event) {
  17150. _this.setState({
  17151. external: _extends({}, _this.state.external, {
  17152. url: event.target.value
  17153. })
  17154. });
  17155. };
  17156. _this.switchExternalType = function (event) {
  17157. _this.setState({
  17158. external: _extends({}, _this.state.external, { type: event.target.dataset.type })
  17159. });
  17160. };
  17161. _this.confirmAddExternal = function (event) {
  17162. if (event.target.nodeName.toLowerCase() === 'button' || event.keyCode === 13) {
  17163. var _this$state$external = _this.state.external,
  17164. url = _this$state$external.url,
  17165. type = _this$state$external.type;
  17166. url = url.split('|');
  17167. var name = url.length > 1 ? url[0] : _this.props.language.unnamedItem;
  17168. url = url.length > 1 ? url[1] : url[0];
  17169. var thumbnail = type === 'IMAGE' ? url : null;
  17170. _this.controller.addItems([{
  17171. thumbnail: thumbnail, url: url, name: name, type: type,
  17172. id: new Date().getTime() + '_' + (0, _base.UniqueIndex)(),
  17173. uploading: false,
  17174. uploadProgress: 1,
  17175. selected: true
  17176. }]);
  17177. _this.setState({
  17178. showExternalForm: false,
  17179. external: {
  17180. url: '',
  17181. type: 'IMAGE'
  17182. }
  17183. });
  17184. }
  17185. };
  17186. _this.toggleExternalForm = function () {
  17187. _this.setState({
  17188. showExternalForm: !_this.state.showExternalForm
  17189. });
  17190. };
  17191. _this.cancelInsert = function () {
  17192. _this.props.onCancel && _this.props.onCancel();
  17193. };
  17194. _this.confirmInsert = function () {
  17195. var selectedItems = _this.controller.getSelectedItems();
  17196. if (_this.props.onBeforeInsert) {
  17197. var filteredItems = _this.props.onBeforeInsert(selectedItems);
  17198. if (filteredItems && filteredItems instanceof Array) {
  17199. _this.controller.deselectAllItems();
  17200. _this.props.onInsert && _this.props.onInsert(filteredItems);
  17201. } else if (filteredItems !== false) {
  17202. _this.controller.deselectAllItems();
  17203. _this.props.onInsert && _this.props.onInsert(selectedItems);
  17204. }
  17205. } else {
  17206. _this.controller.deselectAllItems();
  17207. _this.props.onInsert && _this.props.onInsert(selectedItems);
  17208. }
  17209. };
  17210. _this.dragCounter = 0;
  17211. _this.controller = _this.props.controller;
  17212. var initialItems = _this.controller.getItems();
  17213. _this.state = {
  17214. draging: false,
  17215. error: false,
  17216. confirmable: initialItems.find(function (_ref3) {
  17217. var selected = _ref3.selected;
  17218. return selected;
  17219. }),
  17220. external: {
  17221. url: '',
  17222. type: 'IMAGE'
  17223. },
  17224. fileAccept: '',
  17225. showExternalForm: false,
  17226. allowExternal: false,
  17227. items: initialItems
  17228. };
  17229. _this.changeListenerId = _this.controller.onChange(function (items) {
  17230. _this.setState({ items: items, confirmable: items.find(function (_ref4) {
  17231. var selected = _ref4.selected;
  17232. return selected;
  17233. }) });
  17234. _this.props.onChange && _this.props.onChange(items);
  17235. });
  17236. return _this;
  17237. }
  17238. _createClass(BraftFinderView, [{
  17239. key: 'mapPropsToState',
  17240. value: function mapPropsToState(props) {
  17241. var accepts = props.accepts,
  17242. externals = props.externals;
  17243. accepts = _extends({}, defaultAccepts, accepts);
  17244. var fileAccept = !accepts ? [defaultAccepts.image, defaultAccepts.video, defaultAccepts.audio].join(',') : [accepts.image, accepts.video, accepts.audio].filter(function (item) {
  17245. return item;
  17246. }).join(',');
  17247. var external = {
  17248. url: '',
  17249. type: externals.image ? 'IMAGE' : externals.audio ? 'AUDIO' : externals.video ? 'VIDEO' : externals.embed ? 'EMBED' : ''
  17250. };
  17251. return {
  17252. fileAccept: fileAccept,
  17253. external: external,
  17254. allowExternal: externals && (externals.image || externals.audio || externals.video || externals.embed)
  17255. };
  17256. }
  17257. }, {
  17258. key: 'componentDidMount',
  17259. value: function componentDidMount() {
  17260. this.setState(this.mapPropsToState(this.props));
  17261. }
  17262. }, {
  17263. key: 'componentWillReceiveProps',
  17264. value: function componentWillReceiveProps(nextProps) {
  17265. this.setState(this.mapPropsToState(nextProps));
  17266. }
  17267. }, {
  17268. key: 'componentWillUnmount',
  17269. value: function componentWillUnmount() {
  17270. this.controller.offChange(this.changeListenerId);
  17271. }
  17272. }, {
  17273. key: 'render',
  17274. value: function render() {
  17275. var _props = this.props,
  17276. language = _props.language,
  17277. externals = _props.externals;
  17278. var _state = this.state,
  17279. items = _state.items,
  17280. draging = _state.draging,
  17281. confirmable = _state.confirmable,
  17282. fileAccept = _state.fileAccept,
  17283. external = _state.external,
  17284. showExternalForm = _state.showExternalForm,
  17285. allowExternal = _state.allowExternal;
  17286. return _react2.default.createElement(
  17287. 'div',
  17288. { className: 'braft-finder' },
  17289. _react2.default.createElement(
  17290. 'div',
  17291. {
  17292. onDragEnter: this.handleDragEnter,
  17293. onDragOver: this.handleDragEnter,
  17294. onDragLeave: this.handleDragLeave,
  17295. onDrop: this.handleDragDrop,
  17296. className: 'bf-uploader'
  17297. },
  17298. _react2.default.createElement(
  17299. 'div',
  17300. { className: "bf-drag-uploader " + (draging || !items.length ? 'active ' : ' ') + (draging ? 'draging' : '') },
  17301. _react2.default.createElement(
  17302. 'span',
  17303. { className: 'bf-drag-tip' },
  17304. _react2.default.createElement('input', { accept: fileAccept, onChange: this.reslovePickedFiles, multiple: true, type: 'file' }),
  17305. draging ? language.dropTip : language.dragTip
  17306. )
  17307. ),
  17308. items.length ? _react2.default.createElement(
  17309. 'div',
  17310. { className: 'bf-list-wrap' },
  17311. _react2.default.createElement(
  17312. 'div',
  17313. { className: 'bf-list-tools' },
  17314. _react2.default.createElement(
  17315. 'span',
  17316. { onClick: this.selectAllItems, className: 'bf-select-all' },
  17317. _react2.default.createElement('i', { className: 'braft-icon-done' }),
  17318. ' ',
  17319. language.selectAll
  17320. ),
  17321. _react2.default.createElement(
  17322. 'span',
  17323. { onClick: this.deselectAllItems, disabled: !confirmable, className: 'bf-deselect-all' },
  17324. _react2.default.createElement('i', { className: 'braft-icon-close' }),
  17325. ' ',
  17326. language.deselect
  17327. ),
  17328. _react2.default.createElement(
  17329. 'span',
  17330. { onClick: this.removeSelectedItems, disabled: !confirmable, className: 'bf-remove-selected' },
  17331. _react2.default.createElement('i', { className: 'braft-icon-bin' }),
  17332. ' ',
  17333. language.removeSelected
  17334. )
  17335. ),
  17336. this.buildItemList()
  17337. ) : null,
  17338. showExternalForm && allowExternal ? _react2.default.createElement(
  17339. 'div',
  17340. { className: 'bf-add-external' },
  17341. _react2.default.createElement(
  17342. 'div',
  17343. { className: 'bf-external-form' },
  17344. _react2.default.createElement(
  17345. 'div',
  17346. { className: 'bf-external-input' },
  17347. _react2.default.createElement(
  17348. 'div',
  17349. null,
  17350. _react2.default.createElement('input', { onKeyDown: this.confirmAddExternal, value: external.url, onChange: this.inputExternal, placeholder: language.externalInputPlaceHolder })
  17351. ),
  17352. _react2.default.createElement(
  17353. 'button',
  17354. { type: 'button', onClick: this.confirmAddExternal, disabled: !external.url.trim().length },
  17355. language.confirm
  17356. )
  17357. ),
  17358. _react2.default.createElement(
  17359. 'div',
  17360. { 'data-type': external.type, className: 'bf-switch-external-type' },
  17361. externals.image ? _react2.default.createElement(
  17362. 'button',
  17363. { type: 'button', onClick: this.switchExternalType, 'data-type': 'IMAGE' },
  17364. language.image
  17365. ) : null,
  17366. externals.audio ? _react2.default.createElement(
  17367. 'button',
  17368. { type: 'button', onClick: this.switchExternalType, 'data-type': 'AUDIO' },
  17369. language.audio
  17370. ) : null,
  17371. externals.video ? _react2.default.createElement(
  17372. 'button',
  17373. { type: 'button', onClick: this.switchExternalType, 'data-type': 'VIDEO' },
  17374. language.video
  17375. ) : null,
  17376. externals.embed ? _react2.default.createElement(
  17377. 'button',
  17378. { type: 'button', onClick: this.switchExternalType, 'data-type': 'EMBED' },
  17379. language.embed
  17380. ) : null
  17381. ),
  17382. _react2.default.createElement(
  17383. 'span',
  17384. { className: 'bf-external-tip' },
  17385. language.externalInputTip
  17386. )
  17387. )
  17388. ) : null
  17389. ),
  17390. _react2.default.createElement(
  17391. 'footer',
  17392. { className: 'bf-manager-footer' },
  17393. _react2.default.createElement(
  17394. 'div',
  17395. { className: 'pull-left' },
  17396. allowExternal ? _react2.default.createElement(
  17397. 'span',
  17398. {
  17399. onClick: this.toggleExternalForm,
  17400. className: 'bf-toggle-external-form'
  17401. },
  17402. showExternalForm ? _react2.default.createElement(
  17403. 'span',
  17404. { className: 'bf-bottom-text' },
  17405. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  17406. ' ',
  17407. language.addLocalFile
  17408. ) : _react2.default.createElement(
  17409. 'span',
  17410. { className: 'bf-bottom-text' },
  17411. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  17412. ' ',
  17413. language.addExternalSource
  17414. )
  17415. ) : null
  17416. ),
  17417. _react2.default.createElement(
  17418. 'div',
  17419. { className: 'pull-right' },
  17420. _react2.default.createElement(
  17421. 'button',
  17422. { onClick: this.confirmInsert, className: 'button button-insert', disabled: !confirmable },
  17423. language.insert
  17424. ),
  17425. _react2.default.createElement(
  17426. 'button',
  17427. { onClick: this.cancelInsert, className: 'button button-cancel' },
  17428. language.cancel
  17429. )
  17430. )
  17431. )
  17432. );
  17433. }
  17434. }, {
  17435. key: 'buildItemList',
  17436. value: function buildItemList() {
  17437. var _this2 = this;
  17438. return _react2.default.createElement(
  17439. 'ul',
  17440. { className: 'bf-list' },
  17441. _react2.default.createElement(
  17442. 'li',
  17443. { className: 'bf-add-item' },
  17444. _react2.default.createElement('i', { className: 'braft-icon-add' }),
  17445. _react2.default.createElement('input', { accept: this.state.fileAccept, onChange: this.reslovePickedFiles, multiple: true, type: 'file' })
  17446. ),
  17447. this.state.items.map(function (item, index) {
  17448. var previewerComponents = null;
  17449. var progressMarker = item.uploading && !_this2.props.hideProgress ? _react2.default.createElement(
  17450. 'div',
  17451. { className: 'bf-item-uploading' },
  17452. _react2.default.createElement('div', { className: 'bf-item-uploading-bar', style: { width: item.uploadProgress / 1 + '%' } })
  17453. ) : '';
  17454. switch (item.type) {
  17455. case 'IMAGE':
  17456. previewerComponents = _react2.default.createElement(
  17457. 'div',
  17458. { className: 'bf-image' },
  17459. progressMarker,
  17460. _react2.default.createElement('img', { src: item.thumbnail || item.url })
  17461. );
  17462. break;
  17463. case 'VIDEO':
  17464. previewerComponents = _react2.default.createElement(
  17465. 'div',
  17466. { className: 'bf-icon bf-video', title: item.url },
  17467. progressMarker,
  17468. _react2.default.createElement('i', { className: 'braft-icon-film' }),
  17469. _react2.default.createElement(
  17470. 'span',
  17471. null,
  17472. item.name || item.url
  17473. )
  17474. );
  17475. break;
  17476. case 'AUDIO':
  17477. previewerComponents = _react2.default.createElement(
  17478. 'div',
  17479. { className: 'bf-icon bf-audio', title: item.url },
  17480. progressMarker,
  17481. _react2.default.createElement('i', { className: 'braft-icon-music' }),
  17482. _react2.default.createElement(
  17483. 'span',
  17484. null,
  17485. item.name || item.url
  17486. )
  17487. );
  17488. break;
  17489. case 'EMBED':
  17490. previewerComponents = _react2.default.createElement(
  17491. 'div',
  17492. { className: 'bf-icon bf-embed', title: item.url },
  17493. progressMarker,
  17494. _react2.default.createElement('i', { className: 'braft-icon-code' }),
  17495. _react2.default.createElement(
  17496. 'span',
  17497. null,
  17498. item.name || _this2.props.language.embed
  17499. )
  17500. );
  17501. break;
  17502. default:
  17503. previewerComponents = _react2.default.createElement(
  17504. 'a',
  17505. { className: 'bf-icon bf-file', title: item.url, href: item.url },
  17506. progressMarker,
  17507. _react2.default.createElement('i', { className: 'braft-icon-file-text' }),
  17508. _react2.default.createElement(
  17509. 'span',
  17510. null,
  17511. item.name || item.url
  17512. )
  17513. );
  17514. break;
  17515. }
  17516. var className = ['bf-item'];
  17517. item.selected && className.push('active');
  17518. item.uploading && className.push('uploading');
  17519. item.error && className.push('error');
  17520. return _react2.default.createElement(
  17521. 'li',
  17522. {
  17523. key: index,
  17524. title: item.name,
  17525. 'data-id': item.id,
  17526. className: className.join(' '),
  17527. onClick: _this2.toggleSelectItem
  17528. },
  17529. previewerComponents,
  17530. _react2.default.createElement('span', { 'data-id': item.id, onClick: _this2.removeItem, className: 'bf-item-remove braft-icon-close' }),
  17531. _react2.default.createElement(
  17532. 'span',
  17533. { className: 'bf-item-title' },
  17534. item.name
  17535. )
  17536. );
  17537. })
  17538. );
  17539. }
  17540. }]);
  17541. return BraftFinderView;
  17542. }(_react2.default.Component);
  17543. BraftFinderView.defaultProps = {
  17544. accepts: defaultAccepts,
  17545. externals: {
  17546. image: true,
  17547. video: true,
  17548. audio: true,
  17549. embed: true
  17550. }
  17551. };
  17552. exports.default = BraftFinderView;
  17553. /***/ }),
  17554. /* 19 */
  17555. /***/ (function(module, exports, __webpack_require__) {
  17556. Object.defineProperty(exports, "__esModule", {
  17557. value: true
  17558. });
  17559. 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; };
  17560. var _base = __webpack_require__(1);
  17561. var _image = __webpack_require__(0);
  17562. 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); } }
  17563. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17564. var defaultValidator = function defaultValidator() {
  17565. return true;
  17566. };
  17567. var BraftFinderController = function BraftFinderController() {
  17568. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  17569. _classCallCheck(this, BraftFinderController);
  17570. _initialiseProps.call(this);
  17571. this.items = props.items || [];
  17572. this.uploadFn = props.uploader;
  17573. this.validateFn = props.validator || defaultValidator;
  17574. this.changeListeners = [];
  17575. }
  17576. // resolvePastedFiles ({ clipboardData }, callback) {
  17577. // if (clipboardData && clipboardData.items && clipboardData.items[0].type.indexOf('image') > -1) {
  17578. // this.uploadImage(clipboardData.items[0].getAsFile(), callback)
  17579. // }
  17580. // }
  17581. ;
  17582. var _initialiseProps = function _initialiseProps() {
  17583. var _this = this;
  17584. this.setProps = function () {
  17585. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  17586. _this.items = props.items || _this.items || [];
  17587. _this.uploadFn = props.uploader;
  17588. _this.validateFn = props.validator || defaultValidator;
  17589. };
  17590. this.getMediaItem = function (id) {
  17591. return _this.items.find(function (item) {
  17592. return item.id === id;
  17593. });
  17594. };
  17595. this.getSelectedItems = function () {
  17596. return _this.items.filter(function (item) {
  17597. return item.selected;
  17598. });
  17599. };
  17600. this.getItems = function () {
  17601. return _this.items;
  17602. };
  17603. this.setItems = function (items) {
  17604. _this.items = items.map(function (item) {
  17605. return _extends({}, item, { id: item.id.toString() });
  17606. }) || [];
  17607. _this.applyChange();
  17608. _this.uploadItems();
  17609. };
  17610. this.addMediaItem = function (item) {
  17611. _this.addItems([item]);
  17612. };
  17613. this.addItems = function (items) {
  17614. _this.items = [].concat(_toConsumableArray(_this.items), _toConsumableArray(items.map(function (item) {
  17615. return _extends({}, item, { id: item.id.toString() });
  17616. })));
  17617. _this.applyChange();
  17618. _this.uploadItems();
  17619. };
  17620. this.selectMediaItem = function (id) {
  17621. var item = _this.getMediaItem(id);
  17622. if (item && (item.uploading || item.error)) {
  17623. return false;
  17624. }
  17625. _this.setMediaItemState(id, {
  17626. selected: true
  17627. });
  17628. };
  17629. this.selectAllItems = function () {
  17630. _this.items = _this.items.filter(function (item) {
  17631. return !item.error && !item.uploading;
  17632. }).map(function (item) {
  17633. return _extends({}, item, { selected: true });
  17634. });
  17635. _this.applyChange();
  17636. };
  17637. this.deselectMediaItem = function (id) {
  17638. _this.setMediaItemState(id, {
  17639. selected: false
  17640. });
  17641. };
  17642. this.deselectAllItems = function () {
  17643. _this.items = _this.items.map(function (item) {
  17644. return _extends({}, item, { selected: false });
  17645. });
  17646. _this.applyChange();
  17647. };
  17648. this.removeMediaItem = function (id) {
  17649. _this.items = _this.items.filter(function (item) {
  17650. return item.id !== id;
  17651. });
  17652. _this.applyChange();
  17653. };
  17654. this.removeItems = function () {
  17655. var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
  17656. _this.items = _this.items.filter(function (item) {
  17657. return !ids.includes(item.id);
  17658. });
  17659. _this.applyChange();
  17660. };
  17661. this.removeSelectedItems = function () {
  17662. _this.items = _this.items.filter(function (item) {
  17663. return !item.selected;
  17664. });
  17665. _this.applyChange();
  17666. };
  17667. this.removeErrorItems = function () {
  17668. _this.items = _this.items.filter(function (item) {
  17669. return !item.error;
  17670. });
  17671. _this.applyChange();
  17672. };
  17673. this.removeAllItems = function () {
  17674. _this.items = [];
  17675. _this.applyChange();
  17676. };
  17677. this.setMediaItemState = function (id, state) {
  17678. _this.items = _this.items.map(function (item) {
  17679. return item.id === id ? _extends({}, item, state) : item;
  17680. });
  17681. _this.applyChange();
  17682. };
  17683. this.reuploadErrorItems = function () {
  17684. _this.uploadItems(true);
  17685. };
  17686. this.uploadItems = function () {
  17687. var ignoreError = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
  17688. _this.items.forEach(function (item, index) {
  17689. if (item.uploading || item.url) {
  17690. return false;
  17691. }
  17692. if (!ignoreError && item.error) {
  17693. return false;
  17694. }
  17695. if (item.type === 'IMAGE') {
  17696. _this.createThumbnail(item);
  17697. _this.uploadFn = _this.uploadFn || _this.createInlineImage;
  17698. } else if (!_this.uploadFn) {
  17699. _this.setMediaItemState(item.id, { error: 1 });
  17700. return false;
  17701. }
  17702. _this.setMediaItemState(item.id, {
  17703. uploading: true,
  17704. uploadProgress: 0,
  17705. error: 0
  17706. });
  17707. _this.uploadFn({
  17708. id: item.id,
  17709. file: item.file,
  17710. success: function success(res) {
  17711. _this.handleUploadSuccess(item.id, res);
  17712. },
  17713. progress: function progress(_progress) {
  17714. _this.setMediaItemState(item.id, {
  17715. uploading: true,
  17716. uploadProgress: _progress
  17717. });
  17718. },
  17719. error: function error(_error) {
  17720. _this.setMediaItemState(item.id, {
  17721. uploading: false,
  17722. error: 2
  17723. });
  17724. }
  17725. });
  17726. });
  17727. };
  17728. this.createThumbnail = function (_ref) {
  17729. var id = _ref.id,
  17730. file = _ref.file;
  17731. (0, _image.compressImage)(URL.createObjectURL(file), 226, 226).then(function (result) {
  17732. _this.setMediaItemState(id, { thumbnail: result.url });
  17733. });
  17734. };
  17735. this.createInlineImage = function (param) {
  17736. (0, _image.compressImage)(URL.createObjectURL(param.file), 1280, 800).then(function (result) {
  17737. param.success({ url: result.url });
  17738. }).catch(function (error) {
  17739. param.error(error);
  17740. });
  17741. };
  17742. this.handleUploadSuccess = function (id, data) {
  17743. _this.setMediaItemState(id, _extends({}, data, {
  17744. file: null,
  17745. uploadProgress: 1,
  17746. uploading: false,
  17747. selected: false
  17748. }));
  17749. var item = _this.getMediaItem(data.id || id);
  17750. item.onReady && item.onReady(item);
  17751. };
  17752. this.applyChange = function () {
  17753. _this.changeListeners.forEach(function (_ref2) {
  17754. var callback = _ref2.callback;
  17755. return callback(_this.items);
  17756. });
  17757. };
  17758. this.uploadImage = function (file, callback) {
  17759. var fileId = new Date().getTime() + '_' + (0, _base.UniqueIndex)();
  17760. _this.addMediaItem({
  17761. type: 'IMAGE',
  17762. id: fileId,
  17763. file: file,
  17764. name: fileId,
  17765. size: file.size,
  17766. uploadProgress: 0,
  17767. uploading: false,
  17768. selected: false,
  17769. error: 0,
  17770. onReady: callback
  17771. });
  17772. };
  17773. this.uploadImageRecursively = function (files, callback) {
  17774. var index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
  17775. if (files[index] && files[index].type.indexOf('image') > -1) {
  17776. _this.uploadImage(files[index], function (image) {
  17777. callback && callback(image);
  17778. index < files.length - 1 && _this.uploadImageRecursively(files, callback, index + 1);
  17779. });
  17780. } else {
  17781. index < files.length - 1 && _this.uploadImageRecursively(files, callback, index + 1);
  17782. }
  17783. };
  17784. this.addResolvedFiles = function (param, index, accepts) {
  17785. var data = {
  17786. id: new Date().getTime() + '_' + (0, _base.UniqueIndex)(),
  17787. file: param.files[index],
  17788. name: param.files[index].name,
  17789. size: param.files[index].size,
  17790. uploadProgress: 0,
  17791. uploading: false,
  17792. selected: false,
  17793. error: 0,
  17794. onReady: function onReady(item) {
  17795. param.onItemReady && param.onItemReady(item);
  17796. }
  17797. };
  17798. if (param.files[index].type.indexOf('image/') === 0 && accepts.image) {
  17799. data.type = 'IMAGE';
  17800. _this.addMediaItem(data);
  17801. } else if (param.files[index].type.indexOf('video/') === 0 && accepts.video) {
  17802. data.type = 'VIDEO';
  17803. _this.addMediaItem(data);
  17804. } else if (param.files[index].type.indexOf('audio/') === 0 && accepts.audio) {
  17805. data.type = 'AUDIO';
  17806. _this.addMediaItem(data);
  17807. }
  17808. setTimeout(function () {
  17809. _this.resolveFiles(param, index + 1, accepts);
  17810. }, 60);
  17811. };
  17812. this.resolveFiles = function (param, index, accepts) {
  17813. if (index < param.files.length) {
  17814. var validateResult = _this.validateFn(param.files[index]);
  17815. if (validateResult instanceof Promise) {
  17816. validateResult.then(function () {
  17817. _this.addResolvedFiles(param, index, accepts);
  17818. });
  17819. } else if (validateResult) {
  17820. _this.addResolvedFiles(param, index, accepts);
  17821. }
  17822. } else {
  17823. param.onAllReady && param.onAllReady();
  17824. }
  17825. };
  17826. this.onChange = function (callback) {
  17827. var listenerId = (0, _base.UniqueIndex)();
  17828. _this.changeListeners.push({
  17829. id: listenerId,
  17830. callback: callback
  17831. });
  17832. return listenerId;
  17833. };
  17834. this.offChange = function (listenerId) {
  17835. _this.changeListeners = _this.changeListeners.filter(function (_ref3) {
  17836. var id = _ref3.id;
  17837. return id !== listenerId;
  17838. });
  17839. };
  17840. };
  17841. exports.default = BraftFinderController;
  17842. /***/ }),
  17843. /* 20 */
  17844. /***/ (function(module, exports, __webpack_require__) {
  17845. Object.defineProperty(exports, "__esModule", {
  17846. value: true
  17847. });
  17848. exports.ImageUtils = undefined;
  17849. 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; };
  17850. var _react = __webpack_require__(2);
  17851. var _react2 = _interopRequireDefault(_react);
  17852. var _controller = __webpack_require__(19);
  17853. var _controller2 = _interopRequireDefault(_controller);
  17854. var _view = __webpack_require__(18);
  17855. var _view2 = _interopRequireDefault(_view);
  17856. var _languages = __webpack_require__(10);
  17857. var _languages2 = _interopRequireDefault(_languages);
  17858. var _image = __webpack_require__(0);
  17859. var ImageUtils = _interopRequireWildcard(_image);
  17860. 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; } }
  17861. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  17862. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17863. 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; }
  17864. 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; }
  17865. var BraftFinder = function (_FinderController) {
  17866. _inherits(BraftFinder, _FinderController);
  17867. function BraftFinder(props) {
  17868. _classCallCheck(this, BraftFinder);
  17869. var _this = _possibleConstructorReturn(this, (BraftFinder.__proto__ || Object.getPrototypeOf(BraftFinder)).call(this, props));
  17870. _initialiseProps.call(_this);
  17871. _this.superProps = props;
  17872. return _this;
  17873. }
  17874. return BraftFinder;
  17875. }(_controller2.default);
  17876. var _initialiseProps = function _initialiseProps() {
  17877. var _this2 = this;
  17878. this.ReactComponent = function () {
  17879. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  17880. var componentProps = _extends({}, _this2.superProps, props);
  17881. var language = (typeof componentProps.language === 'function' ? componentProps.language(_languages2.default, 'braft-finder') : _languages2.default[componentProps.language]) || _languages2.default['zh'];
  17882. return _react2.default.createElement(_view2.default, _extends({}, componentProps, {
  17883. language: language,
  17884. controller: _this2
  17885. }));
  17886. };
  17887. };
  17888. exports.default = BraftFinder;
  17889. exports.ImageUtils = ImageUtils;
  17890. /***/ })
  17891. /******/ ]);
  17892. });
  17893. });
  17894. _commonjsHelpers.unwrapExports(dist$2);
  17895. var draftjsUtils$1 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  17896. !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);}])});
  17897. });
  17898. _commonjsHelpers.unwrapExports(draftjsUtils$1);
  17899. var draftjsUtils_1$1 = draftjsUtils$1.draftjsUtils;
  17900. var dist$3 = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  17901. (function webpackUniversalModuleDefinition(root, factory) {
  17902. module.exports = factory(React__default, dist$1, Draft.Draft, immutable$2, dist, _reactDom_commonjsExternal.require$$3, dist$2, draftjsUtils$1);
  17903. })(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__) {
  17904. return /******/ (function(modules) { // webpackBootstrap
  17905. /******/ // The module cache
  17906. /******/ var installedModules = {};
  17907. /******/
  17908. /******/ // The require function
  17909. /******/ function __webpack_require__(moduleId) {
  17910. /******/
  17911. /******/ // Check if module is in cache
  17912. /******/ if(installedModules[moduleId]) {
  17913. /******/ return installedModules[moduleId].exports;
  17914. /******/ }
  17915. /******/ // Create a new module (and put it into the cache)
  17916. /******/ var module = installedModules[moduleId] = {
  17917. /******/ i: moduleId,
  17918. /******/ l: false,
  17919. /******/ exports: {}
  17920. /******/ };
  17921. /******/
  17922. /******/ // Execute the module function
  17923. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  17924. /******/
  17925. /******/ // Flag the module as loaded
  17926. /******/ module.l = true;
  17927. /******/
  17928. /******/ // Return the exports of the module
  17929. /******/ return module.exports;
  17930. /******/ }
  17931. /******/
  17932. /******/
  17933. /******/ // expose the modules object (__webpack_modules__)
  17934. /******/ __webpack_require__.m = modules;
  17935. /******/
  17936. /******/ // expose the module cache
  17937. /******/ __webpack_require__.c = installedModules;
  17938. /******/
  17939. /******/ // define getter function for harmony exports
  17940. /******/ __webpack_require__.d = function(exports, name, getter) {
  17941. /******/ if(!__webpack_require__.o(exports, name)) {
  17942. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  17943. /******/ }
  17944. /******/ };
  17945. /******/
  17946. /******/ // define __esModule on exports
  17947. /******/ __webpack_require__.r = function(exports) {
  17948. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  17949. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  17950. /******/ }
  17951. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  17952. /******/ };
  17953. /******/
  17954. /******/ // create a fake namespace object
  17955. /******/ // mode & 1: value is a module id, require it
  17956. /******/ // mode & 2: merge all properties of value into the ns
  17957. /******/ // mode & 4: return value when already ns object
  17958. /******/ // mode & 8|1: behave like require
  17959. /******/ __webpack_require__.t = function(value, mode) {
  17960. /******/ if(mode & 1) value = __webpack_require__(value);
  17961. /******/ if(mode & 8) return value;
  17962. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  17963. /******/ var ns = Object.create(null);
  17964. /******/ __webpack_require__.r(ns);
  17965. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  17966. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  17967. /******/ return ns;
  17968. /******/ };
  17969. /******/
  17970. /******/ // getDefaultExport function for compatibility with non-harmony modules
  17971. /******/ __webpack_require__.n = function(module) {
  17972. /******/ var getter = module && module.__esModule ?
  17973. /******/ function getDefault() { return module['default']; } :
  17974. /******/ function getModuleExports() { return module; };
  17975. /******/ __webpack_require__.d(getter, 'a', getter);
  17976. /******/ return getter;
  17977. /******/ };
  17978. /******/
  17979. /******/ // Object.prototype.hasOwnProperty.call
  17980. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  17981. /******/
  17982. /******/ // __webpack_public_path__
  17983. /******/ __webpack_require__.p = "/";
  17984. /******/
  17985. /******/
  17986. /******/ // Load entry module and return exports
  17987. /******/ return __webpack_require__(__webpack_require__.s = 39);
  17988. /******/ })
  17989. /************************************************************************/
  17990. /******/ ([
  17991. /* 0 */
  17992. /***/ (function(module, exports) {
  17993. module.exports = __WEBPACK_EXTERNAL_MODULE__0__;
  17994. /***/ }),
  17995. /* 1 */
  17996. /***/ (function(module, exports) {
  17997. function _assertThisInitialized(self) {
  17998. if (self === void 0) {
  17999. throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
  18000. }
  18001. return self;
  18002. }
  18003. module.exports = _assertThisInitialized;
  18004. /***/ }),
  18005. /* 2 */
  18006. /***/ (function(module, exports) {
  18007. function _defineProperty(obj, key, value) {
  18008. if (key in obj) {
  18009. Object.defineProperty(obj, key, {
  18010. value: value,
  18011. enumerable: true,
  18012. configurable: true,
  18013. writable: true
  18014. });
  18015. } else {
  18016. obj[key] = value;
  18017. }
  18018. return obj;
  18019. }
  18020. module.exports = _defineProperty;
  18021. /***/ }),
  18022. /* 3 */
  18023. /***/ (function(module, exports) {
  18024. module.exports = __WEBPACK_EXTERNAL_MODULE__3__;
  18025. /***/ }),
  18026. /* 4 */
  18027. /***/ (function(module, exports) {
  18028. function _classCallCheck(instance, Constructor) {
  18029. if (!(instance instanceof Constructor)) {
  18030. throw new TypeError("Cannot call a class as a function");
  18031. }
  18032. }
  18033. module.exports = _classCallCheck;
  18034. /***/ }),
  18035. /* 5 */
  18036. /***/ (function(module, exports, __webpack_require__) {
  18037. var defineProperty = __webpack_require__(2);
  18038. function _objectSpread(target) {
  18039. for (var i = 1; i < arguments.length; i++) {
  18040. var source = arguments[i] != null ? arguments[i] : {};
  18041. var ownKeys = Object.keys(source);
  18042. if (typeof Object.getOwnPropertySymbols === 'function') {
  18043. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  18044. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  18045. }));
  18046. }
  18047. ownKeys.forEach(function (key) {
  18048. defineProperty(target, key, source[key]);
  18049. });
  18050. }
  18051. return target;
  18052. }
  18053. module.exports = _objectSpread;
  18054. /***/ }),
  18055. /* 6 */
  18056. /***/ (function(module, exports) {
  18057. module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
  18058. /***/ }),
  18059. /* 7 */
  18060. /***/ (function(module, exports) {
  18061. function _defineProperties(target, props) {
  18062. for (var i = 0; i < props.length; i++) {
  18063. var descriptor = props[i];
  18064. descriptor.enumerable = descriptor.enumerable || false;
  18065. descriptor.configurable = true;
  18066. if ("value" in descriptor) descriptor.writable = true;
  18067. Object.defineProperty(target, descriptor.key, descriptor);
  18068. }
  18069. }
  18070. function _createClass(Constructor, protoProps, staticProps) {
  18071. if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  18072. if (staticProps) _defineProperties(Constructor, staticProps);
  18073. return Constructor;
  18074. }
  18075. module.exports = _createClass;
  18076. /***/ }),
  18077. /* 8 */
  18078. /***/ (function(module, exports, __webpack_require__) {
  18079. var _typeof = __webpack_require__(15);
  18080. var assertThisInitialized = __webpack_require__(1);
  18081. function _possibleConstructorReturn(self, call) {
  18082. if (call && (_typeof(call) === "object" || typeof call === "function")) {
  18083. return call;
  18084. }
  18085. return assertThisInitialized(self);
  18086. }
  18087. module.exports = _possibleConstructorReturn;
  18088. /***/ }),
  18089. /* 9 */
  18090. /***/ (function(module, exports) {
  18091. function _getPrototypeOf(o) {
  18092. module.exports = _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
  18093. return o.__proto__ || Object.getPrototypeOf(o);
  18094. };
  18095. return _getPrototypeOf(o);
  18096. }
  18097. module.exports = _getPrototypeOf;
  18098. /***/ }),
  18099. /* 10 */
  18100. /***/ (function(module, exports, __webpack_require__) {
  18101. var setPrototypeOf = __webpack_require__(26);
  18102. function _inherits(subClass, superClass) {
  18103. if (typeof superClass !== "function" && superClass !== null) {
  18104. throw new TypeError("Super expression must either be null or a function");
  18105. }
  18106. subClass.prototype = Object.create(superClass && superClass.prototype, {
  18107. constructor: {
  18108. value: subClass,
  18109. writable: true,
  18110. configurable: true
  18111. }
  18112. });
  18113. if (superClass) setPrototypeOf(subClass, superClass);
  18114. }
  18115. module.exports = _inherits;
  18116. /***/ }),
  18117. /* 11 */
  18118. /***/ (function(module, exports) {
  18119. function _extends() {
  18120. module.exports = _extends = Object.assign || function (target) {
  18121. for (var i = 1; i < arguments.length; i++) {
  18122. var source = arguments[i];
  18123. for (var key in source) {
  18124. if (Object.prototype.hasOwnProperty.call(source, key)) {
  18125. target[key] = source[key];
  18126. }
  18127. }
  18128. }
  18129. return target;
  18130. };
  18131. return _extends.apply(this, arguments);
  18132. }
  18133. module.exports = _extends;
  18134. /***/ }),
  18135. /* 12 */
  18136. /***/ (function(module, exports, __webpack_require__) {
  18137. var arrayWithoutHoles = __webpack_require__(27);
  18138. var iterableToArray = __webpack_require__(28);
  18139. var nonIterableSpread = __webpack_require__(29);
  18140. function _toConsumableArray(arr) {
  18141. return arrayWithoutHoles(arr) || iterableToArray(arr) || nonIterableSpread();
  18142. }
  18143. module.exports = _toConsumableArray;
  18144. /***/ }),
  18145. /* 13 */
  18146. /***/ (function(module, exports) {
  18147. module.exports = __WEBPACK_EXTERNAL_MODULE__13__;
  18148. /***/ }),
  18149. /* 14 */
  18150. /***/ (function(module, exports) {
  18151. module.exports = __WEBPACK_EXTERNAL_MODULE__14__;
  18152. /***/ }),
  18153. /* 15 */
  18154. /***/ (function(module, exports) {
  18155. 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); }
  18156. function _typeof(obj) {
  18157. if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") {
  18158. module.exports = _typeof = function _typeof(obj) {
  18159. return _typeof2(obj);
  18160. };
  18161. } else {
  18162. module.exports = _typeof = function _typeof(obj) {
  18163. return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj);
  18164. };
  18165. }
  18166. return _typeof(obj);
  18167. }
  18168. module.exports = _typeof;
  18169. /***/ }),
  18170. /* 16 */
  18171. /***/ (function(module, exports) {
  18172. module.exports = __WEBPACK_EXTERNAL_MODULE__16__;
  18173. /***/ }),
  18174. /* 17 */
  18175. /***/ (function(module, exports) {
  18176. module.exports = __WEBPACK_EXTERNAL_MODULE__17__;
  18177. /***/ }),
  18178. /* 18 */
  18179. /***/ (function(module, exports, __webpack_require__) {
  18180. var Immutable = __webpack_require__(13);
  18181. var KEY_SEPARATOR = '-';
  18182. function MultiDecorator(decorators) {
  18183. this.decorators = Immutable.List(decorators);
  18184. }
  18185. /**
  18186. Return list of decoration IDs per character
  18187. @param {ContentBlock}
  18188. @return {List<String>}
  18189. */
  18190. MultiDecorator.prototype.getDecorations = function(block) {
  18191. var decorations = Array(block.getText().length).fill(null);
  18192. this.decorators.forEach(function(decorator, i) {
  18193. var _decorations = decorator.getDecorations(block);
  18194. _decorations.forEach(function(key, offset) {
  18195. if (!key) {
  18196. return;
  18197. }
  18198. key = i + KEY_SEPARATOR + key;
  18199. decorations[offset] = key;
  18200. });
  18201. });
  18202. return Immutable.List(decorations);
  18203. };
  18204. /**
  18205. Return component to render a decoration
  18206. @param {String}
  18207. @return {Function}
  18208. */
  18209. MultiDecorator.prototype.getComponentForKey = function(key) {
  18210. var decorator = this.getDecoratorForKey(key);
  18211. return decorator.getComponentForKey(
  18212. this.getInnerKey(key)
  18213. );
  18214. };
  18215. /**
  18216. Return props to render a decoration
  18217. @param {String}
  18218. @return {Object}
  18219. */
  18220. MultiDecorator.prototype.getPropsForKey = function(key) {
  18221. var decorator = this.getDecoratorForKey(key);
  18222. return decorator.getPropsForKey(
  18223. this.getInnerKey(key)
  18224. );
  18225. };
  18226. /**
  18227. Return a decorator for a specific key
  18228. @param {String}
  18229. @return {Decorator}
  18230. */
  18231. MultiDecorator.prototype.getDecoratorForKey = function(key) {
  18232. var parts = key.split(KEY_SEPARATOR);
  18233. var index = Number(parts[0]);
  18234. return this.decorators.get(index);
  18235. };
  18236. /**
  18237. Return inner key for a decorator
  18238. @param {String}
  18239. @return {String}
  18240. */
  18241. MultiDecorator.prototype.getInnerKey = function(key) {
  18242. var parts = key.split(KEY_SEPARATOR);
  18243. return parts.slice(1).join(KEY_SEPARATOR);
  18244. };
  18245. module.exports = MultiDecorator;
  18246. /***/ }),
  18247. /* 19 */
  18248. /***/ (function(module, exports, __webpack_require__) {
  18249. /**
  18250. * Copyright (c) 2013-present, Facebook, Inc.
  18251. * All rights reserved.
  18252. *
  18253. * This source code is licensed under the BSD-style license found in the
  18254. * LICENSE file in the root directory of this source tree. An additional grant
  18255. * of patent rights can be found in the PATENTS file in the same directory.
  18256. *
  18257. * @providesModule CharacterMetadata
  18258. * @format
  18259. *
  18260. */
  18261. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18262. 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; }
  18263. 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; }
  18264. var _require = __webpack_require__(13),
  18265. Map = _require.Map,
  18266. OrderedSet = _require.OrderedSet,
  18267. Record = _require.Record;
  18268. // Immutable.map is typed such that the value for every key in the map
  18269. // must be the same type
  18270. var EMPTY_SET = OrderedSet();
  18271. var defaultRecord = {
  18272. style: EMPTY_SET,
  18273. entity: null
  18274. };
  18275. var CharacterMetadataRecord = Record(defaultRecord);
  18276. var CharacterMetadata = function (_CharacterMetadataRec) {
  18277. _inherits(CharacterMetadata, _CharacterMetadataRec);
  18278. function CharacterMetadata() {
  18279. _classCallCheck(this, CharacterMetadata);
  18280. return _possibleConstructorReturn(this, _CharacterMetadataRec.apply(this, arguments));
  18281. }
  18282. CharacterMetadata.prototype.getStyle = function getStyle() {
  18283. return this.get('style');
  18284. };
  18285. CharacterMetadata.prototype.getEntity = function getEntity() {
  18286. return this.get('entity');
  18287. };
  18288. CharacterMetadata.prototype.hasStyle = function hasStyle(style) {
  18289. return this.getStyle().includes(style);
  18290. };
  18291. CharacterMetadata.applyStyle = function applyStyle(record, style) {
  18292. var withStyle = record.set('style', record.getStyle().add(style));
  18293. return CharacterMetadata.create(withStyle);
  18294. };
  18295. CharacterMetadata.removeStyle = function removeStyle(record, style) {
  18296. var withoutStyle = record.set('style', record.getStyle().remove(style));
  18297. return CharacterMetadata.create(withoutStyle);
  18298. };
  18299. CharacterMetadata.applyEntity = function applyEntity(record, entityKey) {
  18300. var withEntity = record.getEntity() === entityKey ? record : record.set('entity', entityKey);
  18301. return CharacterMetadata.create(withEntity);
  18302. };
  18303. /**
  18304. * Use this function instead of the `CharacterMetadata` constructor.
  18305. * Since most content generally uses only a very small number of
  18306. * style/entity permutations, we can reuse these objects as often as
  18307. * possible.
  18308. */
  18309. CharacterMetadata.create = function create(config) {
  18310. if (!config) {
  18311. return EMPTY;
  18312. }
  18313. var defaultConfig = {
  18314. style: EMPTY_SET,
  18315. entity: null
  18316. };
  18317. // Fill in unspecified properties, if necessary.
  18318. var configMap = Map(defaultConfig).merge(config);
  18319. var existing = pool.get(configMap);
  18320. if (existing) {
  18321. return existing;
  18322. }
  18323. var newCharacter = new CharacterMetadata(configMap);
  18324. pool = pool.set(configMap, newCharacter);
  18325. return newCharacter;
  18326. };
  18327. return CharacterMetadata;
  18328. }(CharacterMetadataRecord);
  18329. var EMPTY = new CharacterMetadata();
  18330. var pool = Map([[Map(defaultRecord), EMPTY]]);
  18331. CharacterMetadata.EMPTY = EMPTY;
  18332. module.exports = CharacterMetadata;
  18333. /***/ }),
  18334. /* 20 */
  18335. /***/ (function(module, exports, __webpack_require__) {
  18336. /**
  18337. * Copyright (c) 2013-present, Facebook, Inc.
  18338. * All rights reserved.
  18339. *
  18340. * This source code is licensed under the BSD-style license found in the
  18341. * LICENSE file in the root directory of this source tree. An additional grant
  18342. * of patent rights can be found in the PATENTS file in the same directory.
  18343. *
  18344. * @providesModule findRangesImmutable
  18345. * @format
  18346. *
  18347. */
  18348. /**
  18349. * Search through an array to find contiguous stretches of elements that
  18350. * match a specified filter function.
  18351. *
  18352. * When ranges are found, execute a specified `found` function to supply
  18353. * the values to the caller.
  18354. */
  18355. function findRangesImmutable(haystack, areEqualFn, filterFn, foundFn) {
  18356. if (!haystack.size) {
  18357. return;
  18358. }
  18359. var cursor = 0;
  18360. haystack.reduce(function (value, nextValue, nextIndex) {
  18361. if (!areEqualFn(value, nextValue)) {
  18362. if (filterFn(value)) {
  18363. foundFn(cursor, nextIndex);
  18364. }
  18365. cursor = nextIndex;
  18366. }
  18367. return nextValue;
  18368. });
  18369. filterFn(haystack.last()) && foundFn(cursor, haystack.count());
  18370. }
  18371. module.exports = findRangesImmutable;
  18372. /***/ }),
  18373. /* 21 */
  18374. /***/ (function(module, exports, __webpack_require__) {
  18375. var objectWithoutPropertiesLoose = __webpack_require__(25);
  18376. function _objectWithoutProperties(source, excluded) {
  18377. if (source == null) return {};
  18378. var target = objectWithoutPropertiesLoose(source, excluded);
  18379. var key, i;
  18380. if (Object.getOwnPropertySymbols) {
  18381. var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
  18382. for (i = 0; i < sourceSymbolKeys.length; i++) {
  18383. key = sourceSymbolKeys[i];
  18384. if (excluded.indexOf(key) >= 0) continue;
  18385. if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
  18386. target[key] = source[key];
  18387. }
  18388. }
  18389. return target;
  18390. }
  18391. module.exports = _objectWithoutProperties;
  18392. /***/ }),
  18393. /* 22 */
  18394. /***/ (function(module, exports, __webpack_require__) {
  18395. /**
  18396. * Copyright (c) 2013-present, Facebook, Inc.
  18397. * All rights reserved.
  18398. *
  18399. * This source code is licensed under the BSD-style license found in the
  18400. * LICENSE file in the root directory of this source tree. An additional grant
  18401. * of patent rights can be found in the PATENTS file in the same directory.
  18402. *
  18403. * @providesModule getFragmentFromSelection
  18404. * @format
  18405. *
  18406. */
  18407. var getContentStateFragment = __webpack_require__(30);
  18408. function getFragmentFromSelection(editorState) {
  18409. var selectionState = editorState.getSelection();
  18410. if (selectionState.isCollapsed()) {
  18411. return null;
  18412. }
  18413. return getContentStateFragment(editorState.getCurrentContent(), selectionState);
  18414. }
  18415. module.exports = getFragmentFromSelection;
  18416. /***/ }),
  18417. /* 23 */
  18418. /***/ (function(module, exports) {
  18419. module.exports = __WEBPACK_EXTERNAL_MODULE__23__;
  18420. /***/ }),
  18421. /* 24 */
  18422. /***/ (function(module, exports, __webpack_require__) {
  18423. var arrayWithHoles = __webpack_require__(36);
  18424. var iterableToArrayLimit = __webpack_require__(37);
  18425. var nonIterableRest = __webpack_require__(38);
  18426. function _slicedToArray(arr, i) {
  18427. return arrayWithHoles(arr) || iterableToArrayLimit(arr, i) || nonIterableRest();
  18428. }
  18429. module.exports = _slicedToArray;
  18430. /***/ }),
  18431. /* 25 */
  18432. /***/ (function(module, exports) {
  18433. function _objectWithoutPropertiesLoose(source, excluded) {
  18434. if (source == null) return {};
  18435. var target = {};
  18436. var sourceKeys = Object.keys(source);
  18437. var key, i;
  18438. for (i = 0; i < sourceKeys.length; i++) {
  18439. key = sourceKeys[i];
  18440. if (excluded.indexOf(key) >= 0) continue;
  18441. target[key] = source[key];
  18442. }
  18443. return target;
  18444. }
  18445. module.exports = _objectWithoutPropertiesLoose;
  18446. /***/ }),
  18447. /* 26 */
  18448. /***/ (function(module, exports) {
  18449. function _setPrototypeOf(o, p) {
  18450. module.exports = _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
  18451. o.__proto__ = p;
  18452. return o;
  18453. };
  18454. return _setPrototypeOf(o, p);
  18455. }
  18456. module.exports = _setPrototypeOf;
  18457. /***/ }),
  18458. /* 27 */
  18459. /***/ (function(module, exports) {
  18460. function _arrayWithoutHoles(arr) {
  18461. if (Array.isArray(arr)) {
  18462. for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) {
  18463. arr2[i] = arr[i];
  18464. }
  18465. return arr2;
  18466. }
  18467. }
  18468. module.exports = _arrayWithoutHoles;
  18469. /***/ }),
  18470. /* 28 */
  18471. /***/ (function(module, exports) {
  18472. function _iterableToArray(iter) {
  18473. if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter);
  18474. }
  18475. module.exports = _iterableToArray;
  18476. /***/ }),
  18477. /* 29 */
  18478. /***/ (function(module, exports) {
  18479. function _nonIterableSpread() {
  18480. throw new TypeError("Invalid attempt to spread non-iterable instance");
  18481. }
  18482. module.exports = _nonIterableSpread;
  18483. /***/ }),
  18484. /* 30 */
  18485. /***/ (function(module, exports, __webpack_require__) {
  18486. /**
  18487. * Copyright (c) 2013-present, Facebook, Inc.
  18488. * All rights reserved.
  18489. *
  18490. * This source code is licensed under the BSD-style license found in the
  18491. * LICENSE file in the root directory of this source tree. An additional grant
  18492. * of patent rights can be found in the PATENTS file in the same directory.
  18493. *
  18494. * @providesModule getContentStateFragment
  18495. * @format
  18496. *
  18497. */
  18498. var randomizeBlockMapKeys = __webpack_require__(31);
  18499. var removeEntitiesAtEdges = __webpack_require__(34);
  18500. var getContentStateFragment = function getContentStateFragment(contentState, selectionState) {
  18501. var startKey = selectionState.getStartKey();
  18502. var startOffset = selectionState.getStartOffset();
  18503. var endKey = selectionState.getEndKey();
  18504. var endOffset = selectionState.getEndOffset();
  18505. // Edge entities should be stripped to ensure that we don't preserve
  18506. // invalid partial entities when the fragment is reused. We do, however,
  18507. // preserve entities that are entirely within the selection range.
  18508. var contentWithoutEdgeEntities = removeEntitiesAtEdges(contentState, selectionState);
  18509. var blockMap = contentWithoutEdgeEntities.getBlockMap();
  18510. var blockKeys = blockMap.keySeq();
  18511. var startIndex = blockKeys.indexOf(startKey);
  18512. var endIndex = blockKeys.indexOf(endKey) + 1;
  18513. return randomizeBlockMapKeys(blockMap.slice(startIndex, endIndex).map(function (block, blockKey) {
  18514. var text = block.getText();
  18515. var chars = block.getCharacterList();
  18516. if (startKey === endKey) {
  18517. return block.merge({
  18518. text: text.slice(startOffset, endOffset),
  18519. characterList: chars.slice(startOffset, endOffset)
  18520. });
  18521. }
  18522. if (blockKey === startKey) {
  18523. return block.merge({
  18524. text: text.slice(startOffset),
  18525. characterList: chars.slice(startOffset)
  18526. });
  18527. }
  18528. if (blockKey === endKey) {
  18529. return block.merge({
  18530. text: text.slice(0, endOffset),
  18531. characterList: chars.slice(0, endOffset)
  18532. });
  18533. }
  18534. return block;
  18535. }));
  18536. };
  18537. module.exports = getContentStateFragment;
  18538. /***/ }),
  18539. /* 31 */
  18540. /***/ (function(module, exports, __webpack_require__) {
  18541. /**
  18542. * Copyright (c) 2013-present, Facebook, Inc.
  18543. * All rights reserved.
  18544. *
  18545. * This source code is licensed under the BSD-style license found in the
  18546. * LICENSE file in the root directory of this source tree. An additional grant
  18547. * of patent rights can be found in the PATENTS file in the same directory.
  18548. *
  18549. * @providesModule randomizeBlockMapKeys
  18550. * @format
  18551. *
  18552. */
  18553. var ContentBlockNode = __webpack_require__(32);
  18554. var Immutable = __webpack_require__(13);
  18555. var generateRandomKey = __webpack_require__(33);
  18556. var OrderedMap = Immutable.OrderedMap;
  18557. var randomizeContentBlockNodeKeys = function randomizeContentBlockNodeKeys(blockMap) {
  18558. var newKeysRef = {};
  18559. // we keep track of root blocks in order to update subsequent sibling links
  18560. var lastRootBlock = void 0;
  18561. return OrderedMap(blockMap.withMutations(function (blockMapState) {
  18562. blockMapState.forEach(function (block, index) {
  18563. var oldKey = block.getKey();
  18564. var nextKey = block.getNextSiblingKey();
  18565. var prevKey = block.getPrevSiblingKey();
  18566. var childrenKeys = block.getChildKeys();
  18567. var parentKey = block.getParentKey();
  18568. // new key that we will use to build linking
  18569. var key = generateRandomKey();
  18570. // we will add it here to re-use it later
  18571. newKeysRef[oldKey] = key;
  18572. if (nextKey) {
  18573. var nextBlock = blockMapState.get(nextKey);
  18574. if (nextBlock) {
  18575. blockMapState.setIn([nextKey, 'prevSibling'], key);
  18576. } else {
  18577. // this can happen when generating random keys for fragments
  18578. blockMapState.setIn([oldKey, 'nextSibling'], null);
  18579. }
  18580. }
  18581. if (prevKey) {
  18582. var prevBlock = blockMapState.get(prevKey);
  18583. if (prevBlock) {
  18584. blockMapState.setIn([prevKey, 'nextSibling'], key);
  18585. } else {
  18586. // this can happen when generating random keys for fragments
  18587. blockMapState.setIn([oldKey, 'prevSibling'], null);
  18588. }
  18589. }
  18590. if (parentKey && blockMapState.get(parentKey)) {
  18591. var parentBlock = blockMapState.get(parentKey);
  18592. var parentChildrenList = parentBlock.getChildKeys();
  18593. blockMapState.setIn([parentKey, 'children'], parentChildrenList.set(parentChildrenList.indexOf(block.getKey()), key));
  18594. } else {
  18595. // blocks will then be treated as root block nodes
  18596. blockMapState.setIn([oldKey, 'parent'], null);
  18597. if (lastRootBlock) {
  18598. blockMapState.setIn([lastRootBlock.getKey(), 'nextSibling'], key);
  18599. blockMapState.setIn([oldKey, 'prevSibling'], newKeysRef[lastRootBlock.getKey()]);
  18600. }
  18601. lastRootBlock = blockMapState.get(oldKey);
  18602. }
  18603. childrenKeys.forEach(function (childKey) {
  18604. var childBlock = blockMapState.get(childKey);
  18605. if (childBlock) {
  18606. blockMapState.setIn([childKey, 'parent'], key);
  18607. } else {
  18608. blockMapState.setIn([oldKey, 'children'], block.getChildKeys().filter(function (child) {
  18609. return child !== childKey;
  18610. }));
  18611. }
  18612. });
  18613. });
  18614. }).toArray().map(function (block) {
  18615. return [newKeysRef[block.getKey()], block.set('key', newKeysRef[block.getKey()])];
  18616. }));
  18617. };
  18618. var randomizeContentBlockKeys = function randomizeContentBlockKeys(blockMap) {
  18619. return OrderedMap(blockMap.toArray().map(function (block) {
  18620. var key = generateRandomKey();
  18621. return [key, block.set('key', key)];
  18622. }));
  18623. };
  18624. var randomizeBlockMapKeys = function randomizeBlockMapKeys(blockMap) {
  18625. var isTreeBasedBlockMap = blockMap.first() instanceof ContentBlockNode;
  18626. if (!isTreeBasedBlockMap) {
  18627. return randomizeContentBlockKeys(blockMap);
  18628. }
  18629. return randomizeContentBlockNodeKeys(blockMap);
  18630. };
  18631. module.exports = randomizeBlockMapKeys;
  18632. /***/ }),
  18633. /* 32 */
  18634. /***/ (function(module, exports, __webpack_require__) {
  18635. /**
  18636. * Copyright (c) 2013-present, Facebook, Inc.
  18637. * All rights reserved.
  18638. *
  18639. * This source code is licensed under the BSD-style license found in the
  18640. * LICENSE file in the root directory of this source tree. An additional grant
  18641. * of patent rights can be found in the PATENTS file in the same directory.
  18642. *
  18643. * @providesModule ContentBlockNode
  18644. * @format
  18645. *
  18646. *
  18647. * This file is a fork of ContentBlock adding support for nesting references by
  18648. * providing links to children, parent, prevSibling, and nextSibling.
  18649. *
  18650. * This is unstable and not part of the public API and should not be used by
  18651. * production systems. This file may be update/removed without notice.
  18652. */
  18653. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18654. 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; }
  18655. 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; }
  18656. var CharacterMetadata = __webpack_require__(19);
  18657. var Immutable = __webpack_require__(13);
  18658. var findRangesImmutable = __webpack_require__(20);
  18659. var List = Immutable.List,
  18660. Map = Immutable.Map,
  18661. OrderedSet = Immutable.OrderedSet,
  18662. Record = Immutable.Record,
  18663. Repeat = Immutable.Repeat;
  18664. var EMPTY_SET = OrderedSet();
  18665. var defaultRecord = {
  18666. parent: null,
  18667. characterList: List(),
  18668. data: Map(),
  18669. depth: 0,
  18670. key: '',
  18671. text: '',
  18672. type: 'unstyled',
  18673. children: List(),
  18674. prevSibling: null,
  18675. nextSibling: null
  18676. };
  18677. var haveEqualStyle = function haveEqualStyle(charA, charB) {
  18678. return charA.getStyle() === charB.getStyle();
  18679. };
  18680. var haveEqualEntity = function haveEqualEntity(charA, charB) {
  18681. return charA.getEntity() === charB.getEntity();
  18682. };
  18683. var decorateCharacterList = function decorateCharacterList(config) {
  18684. if (!config) {
  18685. return config;
  18686. }
  18687. var characterList = config.characterList,
  18688. text = config.text;
  18689. if (text && !characterList) {
  18690. config.characterList = List(Repeat(CharacterMetadata.EMPTY, text.length));
  18691. }
  18692. return config;
  18693. };
  18694. var ContentBlockNode = function (_Record) {
  18695. _inherits(ContentBlockNode, _Record);
  18696. function ContentBlockNode() {
  18697. var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultRecord;
  18698. _classCallCheck(this, ContentBlockNode);
  18699. return _possibleConstructorReturn(this, _Record.call(this, decorateCharacterList(props)));
  18700. }
  18701. ContentBlockNode.prototype.getKey = function getKey() {
  18702. return this.get('key');
  18703. };
  18704. ContentBlockNode.prototype.getType = function getType() {
  18705. return this.get('type');
  18706. };
  18707. ContentBlockNode.prototype.getText = function getText() {
  18708. return this.get('text');
  18709. };
  18710. ContentBlockNode.prototype.getCharacterList = function getCharacterList() {
  18711. return this.get('characterList');
  18712. };
  18713. ContentBlockNode.prototype.getLength = function getLength() {
  18714. return this.getText().length;
  18715. };
  18716. ContentBlockNode.prototype.getDepth = function getDepth() {
  18717. return this.get('depth');
  18718. };
  18719. ContentBlockNode.prototype.getData = function getData() {
  18720. return this.get('data');
  18721. };
  18722. ContentBlockNode.prototype.getInlineStyleAt = function getInlineStyleAt(offset) {
  18723. var character = this.getCharacterList().get(offset);
  18724. return character ? character.getStyle() : EMPTY_SET;
  18725. };
  18726. ContentBlockNode.prototype.getEntityAt = function getEntityAt(offset) {
  18727. var character = this.getCharacterList().get(offset);
  18728. return character ? character.getEntity() : null;
  18729. };
  18730. ContentBlockNode.prototype.getChildKeys = function getChildKeys() {
  18731. return this.get('children');
  18732. };
  18733. ContentBlockNode.prototype.getParentKey = function getParentKey() {
  18734. return this.get('parent');
  18735. };
  18736. ContentBlockNode.prototype.getPrevSiblingKey = function getPrevSiblingKey() {
  18737. return this.get('prevSibling');
  18738. };
  18739. ContentBlockNode.prototype.getNextSiblingKey = function getNextSiblingKey() {
  18740. return this.get('nextSibling');
  18741. };
  18742. ContentBlockNode.prototype.findStyleRanges = function findStyleRanges(filterFn, callback) {
  18743. findRangesImmutable(this.getCharacterList(), haveEqualStyle, filterFn, callback);
  18744. };
  18745. ContentBlockNode.prototype.findEntityRanges = function findEntityRanges(filterFn, callback) {
  18746. findRangesImmutable(this.getCharacterList(), haveEqualEntity, filterFn, callback);
  18747. };
  18748. return ContentBlockNode;
  18749. }(Record(defaultRecord));
  18750. module.exports = ContentBlockNode;
  18751. /***/ }),
  18752. /* 33 */
  18753. /***/ (function(module, exports, __webpack_require__) {
  18754. /**
  18755. * Copyright (c) 2013-present, Facebook, Inc.
  18756. * All rights reserved.
  18757. *
  18758. * This source code is licensed under the BSD-style license found in the
  18759. * LICENSE file in the root directory of this source tree. An additional grant
  18760. * of patent rights can be found in the PATENTS file in the same directory.
  18761. *
  18762. * @providesModule generateRandomKey
  18763. * @format
  18764. *
  18765. */
  18766. var seenKeys = {};
  18767. var MULTIPLIER = Math.pow(2, 24);
  18768. function generateRandomKey() {
  18769. var key = void 0;
  18770. while (key === undefined || seenKeys.hasOwnProperty(key) || !isNaN(+key)) {
  18771. key = Math.floor(Math.random() * MULTIPLIER).toString(32);
  18772. }
  18773. seenKeys[key] = true;
  18774. return key;
  18775. }
  18776. module.exports = generateRandomKey;
  18777. /***/ }),
  18778. /* 34 */
  18779. /***/ (function(module, exports, __webpack_require__) {
  18780. /**
  18781. * Copyright (c) 2013-present, Facebook, Inc.
  18782. * All rights reserved.
  18783. *
  18784. * This source code is licensed under the BSD-style license found in the
  18785. * LICENSE file in the root directory of this source tree. An additional grant
  18786. * of patent rights can be found in the PATENTS file in the same directory.
  18787. *
  18788. * @providesModule removeEntitiesAtEdges
  18789. * @format
  18790. *
  18791. */
  18792. var CharacterMetadata = __webpack_require__(19);
  18793. var findRangesImmutable = __webpack_require__(20);
  18794. var invariant = __webpack_require__(35);
  18795. function removeEntitiesAtEdges(contentState, selectionState) {
  18796. var blockMap = contentState.getBlockMap();
  18797. var entityMap = contentState.getEntityMap();
  18798. var updatedBlocks = {};
  18799. var startKey = selectionState.getStartKey();
  18800. var startOffset = selectionState.getStartOffset();
  18801. var startBlock = blockMap.get(startKey);
  18802. var updatedStart = removeForBlock(entityMap, startBlock, startOffset);
  18803. if (updatedStart !== startBlock) {
  18804. updatedBlocks[startKey] = updatedStart;
  18805. }
  18806. var endKey = selectionState.getEndKey();
  18807. var endOffset = selectionState.getEndOffset();
  18808. var endBlock = blockMap.get(endKey);
  18809. if (startKey === endKey) {
  18810. endBlock = updatedStart;
  18811. }
  18812. var updatedEnd = removeForBlock(entityMap, endBlock, endOffset);
  18813. if (updatedEnd !== endBlock) {
  18814. updatedBlocks[endKey] = updatedEnd;
  18815. }
  18816. if (!Object.keys(updatedBlocks).length) {
  18817. return contentState.set('selectionAfter', selectionState);
  18818. }
  18819. return contentState.merge({
  18820. blockMap: blockMap.merge(updatedBlocks),
  18821. selectionAfter: selectionState
  18822. });
  18823. }
  18824. function getRemovalRange(characters, key, offset) {
  18825. var removalRange;
  18826. findRangesImmutable(characters, function (a, b) {
  18827. return a.getEntity() === b.getEntity();
  18828. }, function (element) {
  18829. return element.getEntity() === key;
  18830. }, function (start, end) {
  18831. if (start <= offset && end >= offset) {
  18832. removalRange = { start: start, end: end };
  18833. }
  18834. });
  18835. !(typeof removalRange === 'object') ? invariant(false) : void 0;
  18836. return removalRange;
  18837. }
  18838. function removeForBlock(entityMap, block, offset) {
  18839. var chars = block.getCharacterList();
  18840. var charBefore = offset > 0 ? chars.get(offset - 1) : undefined;
  18841. var charAfter = offset < chars.count() ? chars.get(offset) : undefined;
  18842. var entityBeforeCursor = charBefore ? charBefore.getEntity() : undefined;
  18843. var entityAfterCursor = charAfter ? charAfter.getEntity() : undefined;
  18844. if (entityAfterCursor && entityAfterCursor === entityBeforeCursor) {
  18845. var entity = entityMap.__get(entityAfterCursor);
  18846. if (entity.getMutability() !== 'MUTABLE') {
  18847. var _getRemovalRange = getRemovalRange(chars, entityAfterCursor, offset),
  18848. start = _getRemovalRange.start,
  18849. end = _getRemovalRange.end;
  18850. var current;
  18851. while (start < end) {
  18852. current = chars.get(start);
  18853. chars = chars.set(start, CharacterMetadata.applyEntity(current, null));
  18854. start++;
  18855. }
  18856. return block.set('characterList', chars);
  18857. }
  18858. }
  18859. return block;
  18860. }
  18861. module.exports = removeEntitiesAtEdges;
  18862. /***/ }),
  18863. /* 35 */
  18864. /***/ (function(module, exports, __webpack_require__) {
  18865. function invariant(condition, format, a, b, c, d, e, f) {
  18866. if (!condition) {
  18867. var error;
  18868. if (format === undefined) {
  18869. error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
  18870. } else {
  18871. var args = [a, b, c, d, e, f];
  18872. var argIndex = 0;
  18873. error = new Error(format.replace(/%s/g, function () {
  18874. return args[argIndex++];
  18875. }));
  18876. error.name = 'Invariant Violation';
  18877. }
  18878. error.framesToPop = 1; // we don't care about invariant's own frame
  18879. throw error;
  18880. }
  18881. }
  18882. module.exports = invariant;
  18883. /***/ }),
  18884. /* 36 */
  18885. /***/ (function(module, exports) {
  18886. function _arrayWithHoles(arr) {
  18887. if (Array.isArray(arr)) return arr;
  18888. }
  18889. module.exports = _arrayWithHoles;
  18890. /***/ }),
  18891. /* 37 */
  18892. /***/ (function(module, exports) {
  18893. function _iterableToArrayLimit(arr, i) {
  18894. var _arr = [];
  18895. var _n = true;
  18896. var _d = false;
  18897. var _e = undefined;
  18898. try {
  18899. for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
  18900. _arr.push(_s.value);
  18901. if (i && _arr.length === i) break;
  18902. }
  18903. } catch (err) {
  18904. _d = true;
  18905. _e = err;
  18906. } finally {
  18907. try {
  18908. if (!_n && _i["return"] != null) _i["return"]();
  18909. } finally {
  18910. if (_d) throw _e;
  18911. }
  18912. }
  18913. return _arr;
  18914. }
  18915. module.exports = _iterableToArrayLimit;
  18916. /***/ }),
  18917. /* 38 */
  18918. /***/ (function(module, exports) {
  18919. function _nonIterableRest() {
  18920. throw new TypeError("Invalid attempt to destructure non-iterable instance");
  18921. }
  18922. module.exports = _nonIterableRest;
  18923. /***/ }),
  18924. /* 39 */
  18925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18926. __webpack_require__.r(__webpack_exports__);
  18927. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/typeof.js
  18928. var helpers_typeof = __webpack_require__(15);
  18929. var typeof_default = /*#__PURE__*/__webpack_require__.n(helpers_typeof);
  18930. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectSpread.js
  18931. var objectSpread = __webpack_require__(5);
  18932. var objectSpread_default = /*#__PURE__*/__webpack_require__.n(objectSpread);
  18933. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/objectWithoutProperties.js
  18934. var objectWithoutProperties = __webpack_require__(21);
  18935. var objectWithoutProperties_default = /*#__PURE__*/__webpack_require__.n(objectWithoutProperties);
  18936. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/classCallCheck.js
  18937. var classCallCheck = __webpack_require__(4);
  18938. var classCallCheck_default = /*#__PURE__*/__webpack_require__.n(classCallCheck);
  18939. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/createClass.js
  18940. var createClass = __webpack_require__(7);
  18941. var createClass_default = /*#__PURE__*/__webpack_require__.n(createClass);
  18942. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/possibleConstructorReturn.js
  18943. var possibleConstructorReturn = __webpack_require__(8);
  18944. var possibleConstructorReturn_default = /*#__PURE__*/__webpack_require__.n(possibleConstructorReturn);
  18945. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/getPrototypeOf.js
  18946. var getPrototypeOf = __webpack_require__(9);
  18947. var getPrototypeOf_default = /*#__PURE__*/__webpack_require__.n(getPrototypeOf);
  18948. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/inherits.js
  18949. var inherits = __webpack_require__(10);
  18950. var inherits_default = /*#__PURE__*/__webpack_require__.n(inherits);
  18951. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/assertThisInitialized.js
  18952. var assertThisInitialized = __webpack_require__(1);
  18953. var assertThisInitialized_default = /*#__PURE__*/__webpack_require__.n(assertThisInitialized);
  18954. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/defineProperty.js
  18955. var defineProperty = __webpack_require__(2);
  18956. var defineProperty_default = /*#__PURE__*/__webpack_require__.n(defineProperty);
  18957. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/toConsumableArray.js
  18958. var toConsumableArray = __webpack_require__(12);
  18959. var toConsumableArray_default = /*#__PURE__*/__webpack_require__.n(toConsumableArray);
  18960. // EXTERNAL MODULE: ../node_modules/draft-js/dist/Draft.css
  18961. var Draft = __webpack_require__(40);
  18962. // EXTERNAL MODULE: ./assets/scss/_base.scss
  18963. var _base = __webpack_require__(42);
  18964. // EXTERNAL MODULE: external "react"
  18965. var external_react_ = __webpack_require__(0);
  18966. var external_react_default = /*#__PURE__*/__webpack_require__.n(external_react_);
  18967. // CONCATENATED MODULE: ./languages/en.js
  18968. /* harmony default export */ var en = ({
  18969. base: {
  18970. remove: 'Remove',
  18971. cancel: 'Cancel',
  18972. confirm: 'Confirm',
  18973. inert: 'Insert',
  18974. width: 'Width',
  18975. height: 'Height'
  18976. },
  18977. controls: {
  18978. clear: 'Clear',
  18979. undo: 'Undo',
  18980. redo: 'Redo',
  18981. fontSize: 'Font Size',
  18982. color: 'Color',
  18983. textColor: 'Text',
  18984. tempColors: 'Temp Colors',
  18985. backgroundColor: 'Background',
  18986. bold: 'Bold',
  18987. lineHeight: 'Line Height',
  18988. letterSpacing: 'Letter Spacing',
  18989. textIndent: 'Text Indent',
  18990. increaseIndent: 'Increase Indent',
  18991. decreaseIndent: 'Decrease Indent',
  18992. italic: 'Italic',
  18993. underline: 'Underline',
  18994. strikeThrough: 'Strike Through',
  18995. fontFamily: 'Font Family',
  18996. textAlign: 'Text Alignment',
  18997. alignLeft: 'Left Alignment',
  18998. alignCenter: 'Center Alignment',
  18999. alignRight: 'Right Alignment',
  19000. alignJustify: 'Justify Alignment',
  19001. floatLeft: 'Left Float',
  19002. floatRight: 'Right Float',
  19003. superScript: 'Super Script',
  19004. subScript: 'Sub Script',
  19005. removeStyles: 'Remove Styles',
  19006. headings: 'Headings',
  19007. header: 'Header',
  19008. normal: 'Normal',
  19009. orderedList: 'Ordered List',
  19010. unorderedList: 'Unordered List',
  19011. blockQuote: 'Quote',
  19012. code: 'Code',
  19013. link: 'Link',
  19014. unlink: 'Unlink',
  19015. hr: 'Horizontal Line',
  19016. media: 'Media',
  19017. mediaLibirary: 'Media Library',
  19018. emoji: 'Emoji',
  19019. fullscreen: 'Fullscreen',
  19020. exitFullscreen: 'Exit Fullscreen'
  19021. },
  19022. linkEditor: {
  19023. textInputPlaceHolder: 'Input link text',
  19024. linkInputPlaceHolder: 'Input link URL',
  19025. inputWithEnterPlaceHolder: 'Input link URL and press Enter',
  19026. openInNewWindow: 'Open in new window',
  19027. removeLink: 'Remove Link'
  19028. },
  19029. audioPlayer: {
  19030. title: 'Play Audio'
  19031. },
  19032. videoPlayer: {
  19033. title: 'Play Video',
  19034. embedTitle: 'Embed Media'
  19035. },
  19036. media: {
  19037. image: 'Image',
  19038. video: 'Video',
  19039. audio: 'Audio',
  19040. embed: 'Embed'
  19041. }
  19042. });
  19043. // CONCATENATED MODULE: ./languages/zh.js
  19044. /* harmony default export */ var zh = ({
  19045. base: {
  19046. remove: '删除',
  19047. cancel: '取消',
  19048. confirm: '确定',
  19049. inert: '插入',
  19050. width: '宽度',
  19051. height: '高度'
  19052. },
  19053. controls: {
  19054. clear: '清除内容',
  19055. undo: '撤销',
  19056. redo: '重做',
  19057. fontSize: '字号',
  19058. lineHeight: '行高',
  19059. letterSpacing: '字间距',
  19060. textIndent: '段落缩进',
  19061. increaseIndent: '增加缩进',
  19062. decreaseIndent: '减少缩进',
  19063. border: '边框',
  19064. color: '颜色',
  19065. textColor: '文字颜色',
  19066. backgroundColor: '背景颜色',
  19067. tempColors: '临时颜色',
  19068. bold: '加粗',
  19069. italic: '斜体',
  19070. underline: '下划线',
  19071. strikeThrough: '删除线',
  19072. fontFamily: '字体',
  19073. textAlign: '文本对齐',
  19074. alignLeft: '居左',
  19075. alignCenter: '居中',
  19076. alignRight: '居右',
  19077. alignJustify: '两端',
  19078. floatLeft: '左浮动',
  19079. floatRight: '右浮动',
  19080. superScript: '上标',
  19081. subScript: '下标',
  19082. removeStyles: '清除样式',
  19083. headings: '标题',
  19084. header: '标题',
  19085. normal: '常规',
  19086. orderedList: '有序列表',
  19087. unorderedList: '无序列表',
  19088. blockQuote: '引用',
  19089. code: '代码',
  19090. link: '链接',
  19091. unlink: '清除链接',
  19092. hr: '水平线',
  19093. media: '媒体',
  19094. mediaLibirary: '媒体库',
  19095. emoji: '小表情',
  19096. fullscreen: '全屏',
  19097. exitFullscreen: '退出全屏'
  19098. },
  19099. linkEditor: {
  19100. textInputPlaceHolder: '输入链接文字',
  19101. linkInputPlaceHolder: '输入链接地址',
  19102. inputWithEnterPlaceHolder: '输入链接地址并回车',
  19103. openInNewWindow: '在新窗口打开',
  19104. removeLink: '移除链接'
  19105. },
  19106. audioPlayer: {
  19107. title: '播放音频文件'
  19108. },
  19109. videoPlayer: {
  19110. title: '播放视频文件',
  19111. embedTitle: '嵌入式媒体'
  19112. },
  19113. media: {
  19114. image: '图像',
  19115. video: '视频',
  19116. audio: '音频',
  19117. embed: '嵌入式媒体'
  19118. }
  19119. });
  19120. // CONCATENATED MODULE: ./languages/zh-hant.js
  19121. /* harmony default export */ var zh_hant = ({
  19122. base: {
  19123. remove: '刪除',
  19124. cancel: '取消',
  19125. confirm: '確定',
  19126. inert: '插入',
  19127. width: '宽度',
  19128. height: '高度'
  19129. },
  19130. controls: {
  19131. clear: '清除内容',
  19132. undo: '撤銷',
  19133. redo: '重做',
  19134. fontSize: '字號',
  19135. color: '顏色',
  19136. textColor: '文字顏色',
  19137. backgroundColor: '背景顏色',
  19138. tempColors: '臨時顏色',
  19139. bold: '加粗',
  19140. lineHeight: '行高',
  19141. letterSpacing: '字間距',
  19142. textIndent: '段落縮進',
  19143. increaseIndent: '增加縮進',
  19144. decreaseIndent: '减少縮進',
  19145. border: '邊框',
  19146. italic: '斜體',
  19147. underline: '下劃線',
  19148. strikeThrough: '刪除線',
  19149. fontFamily: '字體',
  19150. textAlign: '文本對齊',
  19151. alignLeft: '居左',
  19152. alignCenter: '居中',
  19153. alignRight: '居右',
  19154. alignJustify: '兩端對齊',
  19155. floatLeft: '左浮動',
  19156. floatRight: '右浮動',
  19157. superScript: '上標',
  19158. subScript: '下標',
  19159. removeStyles: '清除样式',
  19160. headings: '標題',
  19161. header: '標題',
  19162. normal: '常規',
  19163. orderedList: '有序列表',
  19164. unorderedList: '無序列表',
  19165. blockQuote: '引用',
  19166. code: '代碼',
  19167. link: '鏈接',
  19168. unlink: '清除鏈接',
  19169. hr: '水平线',
  19170. media: '媒體',
  19171. mediaLibirary: '媒體库',
  19172. emoji: '小表情',
  19173. fullscreen: '全熒幕',
  19174. exitFullscreen: '退出全熒幕'
  19175. },
  19176. linkEditor: {
  19177. textInputPlaceHolder: '輸入鏈接文字',
  19178. linkInputPlaceHolder: '輸入鏈接地址',
  19179. inputWithEnterPlaceHolder: '輸入鏈接地址並回車',
  19180. openInNewWindow: '在新窗口打開',
  19181. removeLink: '移除鏈接'
  19182. },
  19183. audioPlayer: {
  19184. title: '播放音頻文件'
  19185. },
  19186. videoPlayer: {
  19187. title: '播放視頻文件',
  19188. embedTitle: '嵌入式媒體'
  19189. },
  19190. media: {
  19191. image: '圖像',
  19192. video: '視頻',
  19193. audio: '音頻',
  19194. embed: '嵌入式媒體'
  19195. }
  19196. });
  19197. // CONCATENATED MODULE: ./languages/pl.js
  19198. /* harmony default export */ var pl = ({
  19199. base: {
  19200. remove: 'Usuń',
  19201. cancel: 'Anuluj',
  19202. confirm: 'Potwierdź',
  19203. inert: 'Wstaw',
  19204. width: 'Szerokość',
  19205. height: 'Wysokość'
  19206. },
  19207. controls: {
  19208. clear: 'Wyczyść',
  19209. undo: 'Cofnij',
  19210. redo: 'Przywróć',
  19211. fontSize: 'Wielkość',
  19212. color: 'Kolor',
  19213. textColor: 'Kolor tekstu',
  19214. tempColors: 'Kolory',
  19215. backgroundColor: 'Tło',
  19216. bold: 'Pogrubienie',
  19217. lineHeight: 'Wysokość linii',
  19218. letterSpacing: 'Odstęp znaków',
  19219. textIndent: 'Wcięcie tekstu',
  19220. increaseIndent: 'Zwiększ wcięcie',
  19221. decreaseIndent: 'Zmniejsz wcięcie',
  19222. italic: 'Italiki',
  19223. underline: 'Podkreślenie',
  19224. strikeThrough: 'Przekreślenie',
  19225. fontFamily: 'Czcionka',
  19226. textAlign: 'Wyrównanie tekstu',
  19227. alignLeft: 'Do lewej',
  19228. alignCenter: 'Wycentruj',
  19229. alignRight: 'Do prawej',
  19230. alignJustify: 'Wyjustuj',
  19231. floatLeft: 'Do lewej',
  19232. floatRight: 'Do prawej',
  19233. superScript: 'Superskrypt',
  19234. subScript: 'Subskrypt',
  19235. removeStyles: 'Usuń stylowanie',
  19236. headings: 'Nagłówki',
  19237. header: 'Nagłówek',
  19238. normal: 'Normalny',
  19239. orderedList: 'Lista uporządkowana',
  19240. unorderedList: 'Lista nieuporządkowana',
  19241. blockQuote: 'Cytat',
  19242. code: 'Kod',
  19243. link: 'Link',
  19244. unlink: 'Usuń link',
  19245. hr: 'Linia pozioma',
  19246. media: 'Media',
  19247. mediaLibirary: 'Biblioteka mediów',
  19248. emoji: 'Emoji'
  19249. },
  19250. linkEditor: {
  19251. textInputPlaceHolder: 'Wpisz tekst linku',
  19252. linkInputPlaceHolder: 'Wpisz Adres URL',
  19253. inputWithEnterPlaceHolder: 'Wpisz adres URL i naciśnij Enter',
  19254. openInNewWindow: 'Otwórz w nowym oknie',
  19255. removeLink: 'Usuń link'
  19256. },
  19257. audioPlayer: {
  19258. title: 'Odtwórz audio'
  19259. },
  19260. videoPlayer: {
  19261. title: 'Odtwórz wideo',
  19262. embedTitle: 'Tytuł'
  19263. },
  19264. media: {
  19265. image: 'Obraz',
  19266. video: 'Wideo',
  19267. audio: 'Audio',
  19268. embed: 'Obiekt osadzony'
  19269. }
  19270. });
  19271. // CONCATENATED MODULE: ./languages/kr.js
  19272. /* harmony default export */ var kr = ({
  19273. base: {
  19274. remove: '삭제',
  19275. cancel: '취소',
  19276. confirm: '결정',
  19277. inert: '삽입',
  19278. width: '너비',
  19279. height: '높이'
  19280. },
  19281. controls: {
  19282. clear: '콘텐츠지우기',
  19283. undo: '취소',
  19284. redo: '다시하기',
  19285. fontSize: '글자크기',
  19286. lineHeight: '행높이',
  19287. letterSpacing: '단어간격',
  19288. textIndent: '단락들여쓰기',
  19289. increaseIndent: '들여쓰기늘리기',
  19290. decreaseIndent: '들여쓰기줄이기',
  19291. border: '국경',
  19292. color: '색상',
  19293. textColor: '텍스트색상',
  19294. backgroundColor: '배경색상',
  19295. tempColors: '임시색',
  19296. bold: '굵게',
  19297. italic: '기울임꼴',
  19298. underline: '밑줄',
  19299. strikeThrough: '취소선',
  19300. fontFamily: '글꼴',
  19301. textAlign: '텍스트정렬',
  19302. alignLeft: '왼쪽',
  19303. alignCenter: '중심',
  19304. alignRight: '오른쪽',
  19305. alignJustify: '양쪽끝',
  19306. floatLeft: '떠다니기',
  19307. floatRight: '오른쪽부동',
  19308. superScript: '위첨자',
  19309. subScript: '첨자',
  19310. removeStyles: '스타일지우기',
  19311. headings: '제목',
  19312. header: '제목',
  19313. normal: '재래식',
  19314. orderedList: '순서가지정된목록',
  19315. unorderedList: '정렬되지않은목록',
  19316. blockQuote: '참고문헌',
  19317. code: '코드',
  19318. link: '링크',
  19319. unlink: '링크삭제',
  19320. hr: '수평선',
  19321. media: '미디어',
  19322. mediaLibirary: '미디어라이브러리',
  19323. emoji: '작은표현',
  19324. fullscreen: '전체화면',
  19325. exitFullscreen: '전체화면종료'
  19326. },
  19327. linkEditor: {
  19328. textInputPlaceHolder: '링크텍스트입력',
  19329. linkInputPlaceHolder: '링크주소입력',
  19330. inputWithEnterPlaceHolder: '링크주소입력.',
  19331. openInNewWindow: '새창열기',
  19332. removeLink: '링크삭제'
  19333. },
  19334. audioPlayer: {
  19335. title: '오디오파일재생'
  19336. },
  19337. videoPlayer: {
  19338. title: '비디오파일재생',
  19339. embedTitle: '임베디드미디어'
  19340. },
  19341. media: {
  19342. image: '이미지',
  19343. video: '비디오',
  19344. audio: '오디오',
  19345. embed: '임베디드미디어'
  19346. }
  19347. });
  19348. // CONCATENATED MODULE: ./languages/tr.js
  19349. /* harmony default export */ var tr = ({
  19350. base: {
  19351. remove: 'Kaldır',
  19352. cancel: 'İptal',
  19353. confirm: 'Onayla',
  19354. inert: 'Ekle',
  19355. width: 'Genişlik',
  19356. height: 'Yükseklik'
  19357. },
  19358. controls: {
  19359. clear: 'Temizle',
  19360. undo: 'Geri al',
  19361. redo: 'İleri al',
  19362. fontSize: 'Yazı boyutu',
  19363. color: 'Renk',
  19364. textColor: 'Yazı rengi',
  19365. tempColors: 'Geçici renkler',
  19366. backgroundColor: 'Arkaplan',
  19367. bold: 'Kalın',
  19368. lineHeight: 'Satır yüksekliği',
  19369. letterSpacing: 'Harf aralığı',
  19370. textIndent: 'Çentik aralığı',
  19371. increaseIndent: 'Çentiği genişlet',
  19372. decreaseIndent: 'Çentiği daralt',
  19373. italic: 'Eğik',
  19374. underline: 'Altı çizili',
  19375. strikeThrough: 'Üstü çizili',
  19376. fontFamily: 'Yazı tipi',
  19377. textAlign: 'Metin Hizalama',
  19378. alignLeft: 'Sola hizala',
  19379. alignCenter: 'Ortaya hizala',
  19380. alignRight: 'Sağa hizala',
  19381. alignJustify: 'Her iki tarafa hizala',
  19382. floatLeft: 'Sola yatır',
  19383. floatRight: 'Sağa yatır',
  19384. superScript: 'Ana kod',
  19385. subScript: 'Alt kod',
  19386. removeStyles: 'Stilleri kaldır',
  19387. headings: 'Başlıklar',
  19388. header: 'Başlık',
  19389. normal: 'Normal',
  19390. orderedList: 'Sıralı liste',
  19391. unorderedList: 'Sırasız liste',
  19392. blockQuote: 'Alıntı',
  19393. code: 'Kod',
  19394. link: 'Bağlantı',
  19395. unlink: 'Bağlantıyı kaldır',
  19396. hr: 'Yatay çizgi',
  19397. media: 'Medya',
  19398. mediaLibirary: 'Kütüphane',
  19399. emoji: 'İfade',
  19400. fullscreen: 'Tam ekran',
  19401. exitFullscreen: 'Tam ekrandan çık'
  19402. },
  19403. linkEditor: {
  19404. textInputPlaceHolder: 'Bağlantı metnini girin',
  19405. linkInputPlaceHolder: 'Bağlantı URL\' si girin',
  19406. inputWithEnterPlaceHolder: 'Bağlantı URL\'si girin ve Enter\' a basın',
  19407. openInNewWindow: 'Yeni pencerede aç',
  19408. removeLink: 'Bağlantıyı kaldır'
  19409. },
  19410. audioPlayer: {
  19411. title: 'Ses çal'
  19412. },
  19413. videoPlayer: {
  19414. title: 'Görüntü oynat',
  19415. embedTitle: 'Görüntüyü göm'
  19416. },
  19417. media: {
  19418. image: 'Resim',
  19419. video: 'Görüntü',
  19420. audio: 'Ses',
  19421. embed: 'Gömülü nesne'
  19422. }
  19423. });
  19424. // CONCATENATED MODULE: ./languages/jpn.js
  19425. /* harmony default export */ var jpn = ({
  19426. base: {
  19427. remove: '削除',
  19428. cancel: 'キャンセル',
  19429. confirm: '決定',
  19430. inert: '挿入',
  19431. width: '幅',
  19432. height: '高さ'
  19433. },
  19434. controls: {
  19435. clear: 'クリアコンテンツ',
  19436. undo: 'キャンセル',
  19437. redo: 'キャンセル',
  19438. fontSize: 'フォントサイズ',
  19439. lineHeight: 'フォントサイズ',
  19440. letterSpacing: 'ワード間隔',
  19441. textIndent: '段落のインデント',
  19442. increaseIndent: 'インデントを増やす',
  19443. decreaseIndent: 'インデントを減らす',
  19444. border: '国境',
  19445. color: '色',
  19446. textColor: 'テキストの色',
  19447. backgroundColor: '背景色',
  19448. tempColors: '仮色',
  19449. bold: '太字',
  19450. italic: 'イタリック体',
  19451. underline: '下線',
  19452. strikeThrough: '取り消し線',
  19453. fontFamily: 'フォント',
  19454. textAlign: 'テキストの配置',
  19455. alignLeft: '左',
  19456. alignCenter: '中央揃え',
  19457. alignRight: '右に立つ',
  19458. alignJustify: '両端',
  19459. floatLeft: '左フローティング',
  19460. floatRight: '右フローティング',
  19461. superScript: '上付き',
  19462. subScript: '下付き文字',
  19463. removeStyles: 'クリアスタイル',
  19464. headings: '役職',
  19465. header: '役職',
  19466. normal: '従来の',
  19467. orderedList: '順序付きリスト',
  19468. unorderedList: '番号なしリスト',
  19469. blockQuote: '参照',
  19470. code: 'コード',
  19471. link: 'リンク',
  19472. unlink: 'リンクを解除',
  19473. hr: '横線',
  19474. media: 'メディア',
  19475. mediaLibirary: 'メディアライブラリー',
  19476. emoji: '小さな表現',
  19477. fullscreen: '全画面',
  19478. exitFullscreen: '全画面を退く'
  19479. },
  19480. linkEditor: {
  19481. textInputPlaceHolder: 'リンクテキストを入力',
  19482. linkInputPlaceHolder: 'リンクアドレスを入力',
  19483. inputWithEnterPlaceHolder: 'リンクアドレスを入力して戻ります',
  19484. openInNewWindow: '新しいウィンドウで開く',
  19485. removeLink: '新しいウィンドウで開く'
  19486. },
  19487. audioPlayer: {
  19488. title: 'オーディオファイルを再生する'
  19489. },
  19490. videoPlayer: {
  19491. title: 'ビデオファイルを再生する',
  19492. embedTitle: '埋め込みメディア'
  19493. },
  19494. media: {
  19495. image: '画像',
  19496. video: 'ビデオ',
  19497. audio: '音声',
  19498. embed: '埋め込みメディア'
  19499. }
  19500. });
  19501. // CONCATENATED MODULE: ./languages/ru.js
  19502. /* harmony default export */ var ru = ({
  19503. base: {
  19504. remove: 'Удалить',
  19505. cancel: 'Отмена',
  19506. confirm: 'Подтвердить',
  19507. insert: 'Вставить',
  19508. width: 'Ширина',
  19509. height: 'Высота'
  19510. },
  19511. controls: {
  19512. clear: 'Очистить',
  19513. undo: 'Отменить',
  19514. redo: 'Повторить',
  19515. fontSize: 'Размер шрифта',
  19516. color: 'Цвет',
  19517. textColor: 'Цвет текста',
  19518. tempColors: 'Temp Colors',
  19519. backgroundColor: 'Цвет фона',
  19520. bold: 'Жирный',
  19521. lineHeight: 'Межстрочный интервал',
  19522. letterSpacing: 'Межбуквенный интервал',
  19523. textIndent: 'Отступ',
  19524. increaseIndent: 'Увеличить отступ',
  19525. decreaseIndent: 'Уменьшить отступ',
  19526. italic: 'Курсив',
  19527. underline: 'Подчеркнутый',
  19528. strikeThrough: 'Перечеркнутый',
  19529. fontFamily: 'Шрифт',
  19530. textAlign: 'Расположение текста',
  19531. alignLeft: 'По левому краю',
  19532. alignCenter: 'По центру',
  19533. alignRight: 'По правому краю',
  19534. alignJustify: 'По ширине',
  19535. floatLeft: 'Обтекание слева',
  19536. floatRight: 'Обтекание справа',
  19537. superScript: 'Надстрочный индекс',
  19538. subScript: 'Подстрочный индекс',
  19539. removeStyles: 'Убрать стили',
  19540. headings: 'Заголовки',
  19541. header: 'Заголовок',
  19542. normal: 'Обычный',
  19543. orderedList: 'Упорядоченный список',
  19544. unorderedList: 'Неупорядоченный список',
  19545. blockQuote: 'Цитата',
  19546. code: 'Код',
  19547. link: 'Вставить ссылку',
  19548. unlink: 'Убрать ссылку',
  19549. hr: 'Горизонтальная линия',
  19550. media: 'Медиа',
  19551. mediaLibirary: 'Медиа библиотека',
  19552. emoji: 'Emoji',
  19553. fullscreen: 'Полноэкранный режим',
  19554. exitFullscreen: 'Выйти из полноэкранного режима'
  19555. },
  19556. linkEditor: {
  19557. textInputPlaceHolder: 'Введите текст ссылки',
  19558. linkInputPlaceHolder: 'Вставить ссылку',
  19559. inputWithEnterPlaceHolder: 'Вставить ссылку и нажать Enter',
  19560. openInNewWindow: 'Открыть в новом окне',
  19561. removeLink: 'Убрать ссылку'
  19562. },
  19563. audioPlayer: {
  19564. title: 'Воспроизвести аудиофайл'
  19565. },
  19566. videoPlayer: {
  19567. title: 'Воспроизвести видеофайл',
  19568. embedTitle: 'Embed Media'
  19569. },
  19570. media: {
  19571. image: 'Картинка',
  19572. video: 'Видео',
  19573. audio: 'Аудио',
  19574. embed: 'Встроенное'
  19575. }
  19576. });
  19577. // CONCATENATED MODULE: ./languages/fr.js
  19578. /* harmony default export */ var fr = ({
  19579. base: {
  19580. remove: 'Supprimer',
  19581. cancel: 'Annuler',
  19582. confirm: 'Confirmer',
  19583. inert: 'Insérer',
  19584. width: 'Largeur',
  19585. height: 'Hauteur'
  19586. },
  19587. controls: {
  19588. clear: 'Effacer',
  19589. undo: 'Annuler',
  19590. redo: 'Refaire',
  19591. fontSize: 'Taille de police',
  19592. color: 'Couleur',
  19593. textColor: 'Texte',
  19594. tempColors: 'Couleurs temporaire',
  19595. backgroundColor: 'Couleur d\'arrière plan',
  19596. bold: 'Gras',
  19597. lineHeight: 'Hauteur de ligne',
  19598. letterSpacing: 'Espacement des lettres',
  19599. textIndent: 'Indentation du texte',
  19600. increaseIndent: 'Augmenter l\'indentation',
  19601. decreaseIndent: 'Réduire l\'indentation',
  19602. italic: 'Italique',
  19603. underline: 'Souligner',
  19604. strikeThrough: 'Barrer',
  19605. fontFamily: 'Police d\'écriture',
  19606. textAlign: 'Alignement du texte',
  19607. alignLeft: 'Aligner à gauche',
  19608. alignCenter: 'Aligner au centre',
  19609. alignRight: 'Aligner à droite',
  19610. alignJustify: 'Justifier',
  19611. floatLeft: 'Déplacer à gauche',
  19612. floatRight: 'Déplacer à droite',
  19613. superScript: 'Super-script',
  19614. subScript: 'Sous-script',
  19615. removeStyles: 'Supprimer les styles',
  19616. headings: 'Titres',
  19617. header: 'Entêtes',
  19618. normal: 'Normal',
  19619. orderedList: 'Liste ordonnée',
  19620. unorderedList: 'Liste non-ordonnée',
  19621. blockQuote: 'Citation',
  19622. code: 'Code',
  19623. link: 'Insérer un lien',
  19624. unlink: 'Supprimer le lien',
  19625. hr: 'Ligne horizontale',
  19626. media: 'Média',
  19627. mediaLibirary: 'Bibliothêque',
  19628. emoji: 'Emoji',
  19629. fullscreen: 'Plein écran',
  19630. exitFullscreen: 'Quitter le plein écran'
  19631. },
  19632. linkEditor: {
  19633. textInputPlaceHolder: 'Insérer le texte à afficher',
  19634. linkInputPlaceHolder: 'Insérer le lien URL',
  19635. inputWithEnterPlaceHolder: 'Insérer le lien URL puis appuyer sur Entrée',
  19636. openInNewWindow: 'Ouvrir dans une nouvelle fenêtre',
  19637. removeLink: 'Supprimer le lien'
  19638. },
  19639. audioPlayer: {
  19640. title: 'Lancer le son audio'
  19641. },
  19642. videoPlayer: {
  19643. title: 'Lancer la video',
  19644. embedTitle: 'Intégrer média'
  19645. },
  19646. media: {
  19647. image: 'Image',
  19648. video: 'Vidéo',
  19649. audio: 'Audio',
  19650. embed: 'Intégré'
  19651. }
  19652. });
  19653. // CONCATENATED MODULE: ./languages/pt-br.js
  19654. /* harmony default export */ var pt_br = ({
  19655. base: {
  19656. remove: 'Remover',
  19657. cancel: 'Cancelar',
  19658. confirm: 'Confirmar',
  19659. inert: 'Inserir',
  19660. width: 'Largura',
  19661. height: 'Altura'
  19662. },
  19663. controls: {
  19664. clear: 'Limpar',
  19665. undo: 'Desfazer',
  19666. redo: 'Refazer',
  19667. fontSize: 'Tamanho da Fonte',
  19668. color: 'Cor',
  19669. textColor: 'Texto',
  19670. tempColors: 'Temp Colors',
  19671. backgroundColor: 'Cor de Fundo',
  19672. bold: 'Negrito',
  19673. lineHeight: 'Altura da LinhaLine Height',
  19674. letterSpacing: 'Espaçamento entre Letras',
  19675. textIndent: 'Identação de Texto',
  19676. increaseIndent: 'Aumentar Identação',
  19677. decreaseIndent: 'Diminuir Identção',
  19678. italic: 'Itálico',
  19679. underline: 'Sublinhado',
  19680. strikeThrough: 'Riscado',
  19681. fontFamily: 'Família da Fonte',
  19682. textAlign: 'Alinhamento de Texto',
  19683. alignLeft: 'Alinhamento à Esquerda',
  19684. alignCenter: 'Alinhamento Centralizado',
  19685. alignRight: 'Alinhamento à Direita',
  19686. alignJustify: 'Alinhamento Justificado',
  19687. floatLeft: 'Flutuação à Esquerda',
  19688. floatRight: 'Flutuação à Direita',
  19689. superScript: 'Sobrescrito',
  19690. subScript: 'Subscrito',
  19691. removeStyles: 'Remover Estilos',
  19692. headings: 'Cabeçalhos',
  19693. header: 'Cabeçalho',
  19694. normal: 'Normal',
  19695. orderedList: 'Lista Ordenada',
  19696. unorderedList: 'Lista Não Ordenada',
  19697. blockQuote: 'Citação',
  19698. code: 'Código',
  19699. link: 'Link',
  19700. unlink: 'Remover Link',
  19701. hr: 'Linha Horizontal',
  19702. media: 'Mídia',
  19703. mediaLibirary: 'Biblioteca de Mídia',
  19704. emoji: 'Emoji',
  19705. fullscreen: 'Tela Cheia',
  19706. exitFullscreen: 'Sair de Tela Cheia'
  19707. },
  19708. linkEditor: {
  19709. textInputPlaceHolder: 'Insira o texto do link',
  19710. linkInputPlaceHolder: 'Insira a URL do link',
  19711. inputWithEnterPlaceHolder: 'Insira a URL do link e aperte Enter',
  19712. openInNewWindow: 'Abrir em nova janela',
  19713. removeLink: 'Remover Link'
  19714. },
  19715. audioPlayer: {
  19716. title: 'Tocar Áudio'
  19717. },
  19718. videoPlayer: {
  19719. title: 'Tocar Vídeo',
  19720. embedTitle: 'Mídia Embutida'
  19721. },
  19722. media: {
  19723. image: 'Imagem',
  19724. video: 'Vídeo',
  19725. audio: 'Áudio',
  19726. embed: 'Embutido'
  19727. }
  19728. });
  19729. // CONCATENATED MODULE: ./languages/index.js
  19730. /* harmony default export */ var languages = ({
  19731. 'en': en,
  19732. 'zh': zh,
  19733. 'zh-hant': zh_hant,
  19734. 'pl': pl,
  19735. 'kr': kr,
  19736. 'tr': tr,
  19737. 'jpn': jpn,
  19738. 'ru': ru,
  19739. 'fr': fr,
  19740. 'pt-br': pt_br
  19741. });
  19742. // EXTERNAL MODULE: external "braft-finder"
  19743. var external_braft_finder_ = __webpack_require__(17);
  19744. var external_braft_finder_default = /*#__PURE__*/__webpack_require__.n(external_braft_finder_);
  19745. // EXTERNAL MODULE: external "braft-utils"
  19746. var external_braft_utils_ = __webpack_require__(3);
  19747. // EXTERNAL MODULE: external "draft-js"
  19748. var external_draft_js_ = __webpack_require__(6);
  19749. // EXTERNAL MODULE: external "immutable"
  19750. var external_immutable_ = __webpack_require__(13);
  19751. var external_immutable_default = /*#__PURE__*/__webpack_require__.n(external_immutable_);
  19752. // CONCATENATED MODULE: ./configs/keybindings.js
  19753. // TODO
  19754. // 允许自定义的快捷键设置
  19755. /* harmony default export */ var keybindings = (function (customKeyBindingFn) {
  19756. return function (event) {
  19757. if (event.keyCode === 83 && (external_draft_js_["KeyBindingUtil"].hasCommandModifier(event) || external_draft_js_["KeyBindingUtil"].isCtrlKeyCommand(event))) {
  19758. return 'braft-save';
  19759. }
  19760. if (customKeyBindingFn) {
  19761. return customKeyBindingFn(event) || Object(external_draft_js_["getDefaultKeyBinding"])(event);
  19762. }
  19763. return Object(external_draft_js_["getDefaultKeyBinding"])(event);
  19764. };
  19765. });
  19766. // CONCATENATED MODULE: ./configs/props.js
  19767. /* harmony default export */ var configs_props = ({
  19768. language: 'zh',
  19769. 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'],
  19770. excludeControls: [],
  19771. extendControls: [],
  19772. extendAtomics: [],
  19773. componentBelowControlBar: null,
  19774. media: {
  19775. pasteImage: true,
  19776. imagePasteLimit: 5,
  19777. image: true,
  19778. video: true,
  19779. audio: true,
  19780. uploadFn: null,
  19781. validateFn: null,
  19782. onBeforeDeselect: null,
  19783. onDeselect: null,
  19784. onBeforeSelect: null,
  19785. onSelect: null,
  19786. onBeforeRemove: null,
  19787. onRemove: null,
  19788. onCancel: null,
  19789. onFileSelect: null,
  19790. onBeforeInsert: null,
  19791. onInsert: null,
  19792. onChange: null,
  19793. accepts: {
  19794. image: 'image/png,image/jpeg,image/gif,image/webp,image/apng,image/svg',
  19795. video: 'video/mp4',
  19796. audio: 'audio/mp3'
  19797. },
  19798. externals: {
  19799. audio: true,
  19800. video: true,
  19801. image: true,
  19802. embed: true
  19803. }
  19804. },
  19805. imageControls: ['float-left', 'float-right', 'align-left', 'align-center', 'align-right', 'link', 'size', 'remove'],
  19806. imageResizable: true,
  19807. colors: ['#000000', '#333333', '#666666', '#999999', '#cccccc', '#ffffff', '#61a951', '#16a085', '#07a9fe', '#003ba5', '#8e44ad', '#f32784', '#c0392b', '#d35400', '#f39c12', '#fdda00'],
  19808. colorPicker: null,
  19809. colorPickerTheme: 'dark',
  19810. colorPickerAutoHide: true,
  19811. codeTabIndents: 2,
  19812. headings: ['header-one', 'header-two', 'header-three', 'header-four', 'header-five', 'header-six', 'unstyled'],
  19813. textAligns: ['left', 'center', 'right', 'justify'],
  19814. textBackgroundColor: true,
  19815. allowInsertLinkText: false,
  19816. defaultLinkTarget: '',
  19817. letterSpacings: [0, 1, 2, 3, 4, 5, 6],
  19818. lineHeights: [1, 1.2, 1.5, 1.75, 2, 2.5, 3, 4],
  19819. fontSizes: [12, 14, 16, 18, 20, 24, 28, 30, 32, 36, 40, 48, 56, 64, 72, 96, 120, 144],
  19820. fontFamilies: [{
  19821. name: 'Araial',
  19822. family: 'Arial, Helvetica, sans-serif'
  19823. }, {
  19824. name: 'Georgia',
  19825. family: 'Georgia, serif'
  19826. }, {
  19827. name: 'Impact',
  19828. family: 'Impact, serif'
  19829. }, {
  19830. name: 'Monospace',
  19831. family: '"Courier New", Courier, monospace'
  19832. }, {
  19833. name: 'Tahoma',
  19834. family: 'tahoma, arial, "Hiragino Sans GB", 宋体, sans-serif'
  19835. }],
  19836. converts: {
  19837. unitExportFn: function unitExportFn(value, type) {
  19838. return type === 'line-height' ? value : "".concat(value, "px");
  19839. }
  19840. },
  19841. emojis: ['🤣', '🙌', '💚', '💛', '👏', '😉', '💯', '💕', '💞', '💘', '💙', '💝', '🖤', '💜', '❤️', '😍', '😻', '💓', '💗', '😋', '😇', '😂', '😹', '😘', '💖', '😁', '😀', '🤞', '😲', '😄', '😊', '👍', '😌', '😃', '😅', '✌️', '🤗', '💋', '😗', '😽', '😚', '🤠', '😙', '😺', '👄', '😸', '😏', '😼', '👌', '😎', '😆', '😛', '🙏', '🤝', '🙂', '🤑', '😝', '😐', '😑', '🤤', '😤', '🙃', '🤡', '😶', '😪', '😴', '😵', '😓', '👊', '😦', '😷', '🤐', '😜', '🤓', '👻', '😥', '🙄', '🤔', '🤒', '🙁', '😔', '😯', '☹️', '☠️', '😰', '😩', '😖', '😕', '😒', '😣', '😢', '😮', '😿', '🤧', '😫', '🤥', '😞', '😬', '👎', '💀', '😳', '😨', '🤕', '🤢', '😱', '😭', '😠', '😈', '😧', '💔', '😟', '🙀', '💩', '👿', '😡', '😾', '🖕'],
  19842. stripPastedStyles: false,
  19843. triggerChangeOnMount: true,
  19844. className: '',
  19845. style: {},
  19846. controlBarClassName: '',
  19847. controlBarStyle: {},
  19848. contentClassName: '',
  19849. contentStyle: {},
  19850. draftProps: {},
  19851. hooks: {},
  19852. onChange: null,
  19853. onFocus: null,
  19854. onBlur: null,
  19855. onTab: null,
  19856. onDelete: null,
  19857. onSave: null,
  19858. fixPlaceholder: false
  19859. });
  19860. // EXTERNAL MODULE: ../node_modules/draft-js/lib/getFragmentFromSelection.js
  19861. var getFragmentFromSelection = __webpack_require__(22);
  19862. var getFragmentFromSelection_default = /*#__PURE__*/__webpack_require__.n(getFragmentFromSelection);
  19863. // EXTERNAL MODULE: external "draftjs-utils"
  19864. var external_draftjs_utils_ = __webpack_require__(23);
  19865. // CONCATENATED MODULE: ./configs/handlers.js
  19866. var handlers_keyCommandHandlers = function keyCommandHandlers(command, editorState, editor) {
  19867. if (editor.editorProps.handleKeyCommand && editor.editorProps.handleKeyCommand(command, editorState, editor) === 'handled') {
  19868. return 'handled';
  19869. }
  19870. if (command === 'braft-save') {
  19871. editor.editorProps.onSave && editor.editorProps.onSave(editorState);
  19872. return 'handled';
  19873. }
  19874. var _editor$editorProps = editor.editorProps,
  19875. controls = _editor$editorProps.controls,
  19876. excludeControls = _editor$editorProps.excludeControls;
  19877. var allowIndent = (controls.indexOf('text-indent') !== 0 || controls.find(function (item) {
  19878. return item.key === 'text-indent';
  19879. })) && excludeControls.indexOf('text-indent') === -1;
  19880. var cursorStart = editorState.getSelection().getStartOffset();
  19881. var cursorEnd = editorState.getSelection().getEndOffset();
  19882. var cursorIsAtFirst = cursorStart === 0 && cursorEnd === 0;
  19883. if (command === 'backspace') {
  19884. if (editor.editorProps.onDelete && editor.editorProps.onDelete(editorState) === false) {
  19885. return 'handled';
  19886. }
  19887. var blockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  19888. if (allowIndent && cursorIsAtFirst && blockType !== 'code-block') {
  19889. editor.setValue(external_braft_utils_["ContentUtils"].decreaseSelectionIndent(editorState));
  19890. }
  19891. }
  19892. if (command === 'tab') {
  19893. var _blockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  19894. if (_blockType === 'code-block') {
  19895. editor.setValue(external_braft_utils_["ContentUtils"].insertText(editorState, ' '.repeat(editor.editorProps.codeTabIndents)));
  19896. return 'handled';
  19897. } else if (_blockType === 'ordered-list-item' || _blockType === 'unordered-list-item') {
  19898. var newEditorState = external_draft_js_["RichUtils"].onTab(event, editorState, 4);
  19899. if (newEditorState !== editorState) {
  19900. editor.setValue(newEditorState);
  19901. }
  19902. return 'handled';
  19903. } else if (_blockType !== 'atomic' && allowIndent && cursorIsAtFirst) {
  19904. editor.setValue(external_braft_utils_["ContentUtils"].increaseSelectionIndent(editorState));
  19905. return 'handled';
  19906. }
  19907. }
  19908. var nextEditorState = external_braft_utils_["ContentUtils"].handleKeyCommand(editorState, command);
  19909. if (nextEditorState) {
  19910. editor.setValue(nextEditorState);
  19911. return 'handled';
  19912. }
  19913. return 'not-handled';
  19914. };
  19915. var handlers_returnHandlers = function returnHandlers(event, editorState, editor) {
  19916. if (editor.editorProps.handleReturn && editor.editorProps.handleReturn(event, editorState, editor) === 'handled') {
  19917. return 'handled';
  19918. }
  19919. var currentBlock = external_braft_utils_["ContentUtils"].getSelectionBlock(editorState);
  19920. var currentBlockType = currentBlock.getType();
  19921. if (currentBlockType === 'unordered-list-item' || currentBlockType === 'ordered-list-item') {
  19922. if (currentBlock.getLength() === 0) {
  19923. editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, 'unstyled'));
  19924. return 'handled';
  19925. }
  19926. return 'not-handled';
  19927. } else if (currentBlockType === 'code-block') {
  19928. if (event.which === 13 && (event.getModifierState('Shift') || event.getModifierState('Alt') || event.getModifierState('Control'))) {
  19929. editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, 'unstyled'));
  19930. return 'handled';
  19931. }
  19932. return 'not-handled';
  19933. } else if (currentBlockType === 'blockquote') {
  19934. if (event.which === 13) {
  19935. if (event.getModifierState('Shift') || event.getModifierState('Alt') || event.getModifierState('Control')) {
  19936. event.which = 0;
  19937. } else {
  19938. editor.setValue(external_draft_js_["RichUtils"].insertSoftNewline(editorState));
  19939. return 'handled';
  19940. }
  19941. }
  19942. }
  19943. var nextEditorState = Object(external_draftjs_utils_["handleNewLine"])(editorState, event);
  19944. if (nextEditorState) {
  19945. editor.setValue(nextEditorState);
  19946. return 'handled';
  19947. }
  19948. return 'not-handled';
  19949. };
  19950. var beforeInputHandlers = function beforeInputHandlers(chars, editorState, editor) {
  19951. if (editor.editorProps.handleBeforeInput && editor.editorProps.handleBeforeInput(chars, editorState, editor) === 'handled') {
  19952. return 'handled';
  19953. }
  19954. return 'not-handled';
  19955. };
  19956. var handlers_compositionStartHandler = function compositionStartHandler(_, editor) {
  19957. var editorState = editor.state.editorState;
  19958. var selectedBlocks = external_braft_utils_["ContentUtils"].getSelectedBlocks(editorState);
  19959. if (selectedBlocks && selectedBlocks.length > 1) {
  19960. var nextEditorState = external_draft_js_["EditorState"].push(editorState, external_draft_js_["Modifier"].removeRange(editorState.getCurrentContent(), editorState.getSelection(), 'backward'), 'remove-range');
  19961. editor.setValue(nextEditorState);
  19962. }
  19963. };
  19964. var handlers_dropHandlers = function dropHandlers(selectionState, dataTransfer, editor) {
  19965. if (editor.editorProps.readOnly || editor.editorProps.disabled) {
  19966. return 'handled';
  19967. }
  19968. if (window && window.__BRAFT_DRAGING__IMAGE__) {
  19969. var nextEditorState = external_draft_js_["EditorState"].forceSelection(editor.state.editorState, selectionState);
  19970. nextEditorState = external_braft_utils_["ContentUtils"].insertMedias(nextEditorState, [window.__BRAFT_DRAGING__IMAGE__.mediaData]);
  19971. nextEditorState = external_braft_utils_["ContentUtils"].removeBlock(nextEditorState, window.__BRAFT_DRAGING__IMAGE__.block, nextEditorState.getSelection());
  19972. window.__BRAFT_DRAGING__IMAGE__ = null;
  19973. editor.lockOrUnlockEditor(true);
  19974. editor.setValue(nextEditorState);
  19975. return 'handled';
  19976. } else if (!dataTransfer || !dataTransfer.getText()) {
  19977. return 'handled';
  19978. }
  19979. return 'not-handled';
  19980. };
  19981. var handlers_handleFiles = function handleFiles(files, editor) {
  19982. var _editor$constructor$d = objectSpread_default()({}, editor.constructor.defaultProps.media, editor.editorProps.media),
  19983. pasteImage = _editor$constructor$d.pasteImage,
  19984. validateFn = _editor$constructor$d.validateFn,
  19985. imagePasteLimit = _editor$constructor$d.imagePasteLimit;
  19986. pasteImage && files.slice(0, imagePasteLimit).forEach(function (file) {
  19987. if (file && file.type.indexOf('image') > -1 && editor.braftFinder) {
  19988. var validateResult = validateFn ? validateFn(file) : true;
  19989. if (validateResult instanceof Promise) {
  19990. validateResult.then(function () {
  19991. editor.braftFinder.uploadImage(file, function (image) {
  19992. editor.isLiving && editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(editor.state.editorState, [image]));
  19993. });
  19994. });
  19995. } else if (validateResult) {
  19996. editor.braftFinder.uploadImage(file, function (image) {
  19997. editor.isLiving && editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(editor.state.editorState, [image]));
  19998. });
  19999. }
  20000. }
  20001. });
  20002. if (files[0] && files[0].type.indexOf('image') > -1 && pasteImage) {
  20003. return 'handled';
  20004. }
  20005. return 'not-handled';
  20006. };
  20007. var droppedFilesHandlers = function droppedFilesHandlers(selectionState, files, editor) {
  20008. if (editor.editorProps.handleDroppedFiles && editor.editorProps.handleDroppedFiles(selectionState, files, editor) === 'handled') {
  20009. return 'handled';
  20010. }
  20011. return handlers_handleFiles(files, editor);
  20012. };
  20013. var pastedFilesHandlers = function pastedFilesHandlers(files, editor) {
  20014. if (editor.editorProps.handlePastedFiles && editor.editorProps.handlePastedFiles(files, editor) === 'handled') {
  20015. return 'handled';
  20016. }
  20017. return handlers_handleFiles(files, editor);
  20018. };
  20019. var handlers_copyHandlers = function copyHandlers(event, editor) {
  20020. var blockMap = getFragmentFromSelection_default()(editor.state.editorState);
  20021. if (blockMap && blockMap.toArray) {
  20022. try {
  20023. var tempContentState = external_draft_js_["ContentState"].createFromBlockArray(blockMap.toArray());
  20024. var tempEditorState = external_draft_js_["EditorState"].createWithContent(tempContentState);
  20025. var clipboardData = event.clipboardData || window.clipboardData || event.originalEvent.clipboardData;
  20026. tempEditorState.setConvertOptions(editor.state.editorState.convertOptions);
  20027. clipboardData.setData('text/html', tempEditorState.toHTML());
  20028. clipboardData.setData('text/plain', tempEditorState.toText());
  20029. event.preventDefault();
  20030. } catch (error) {
  20031. console.warn(error);
  20032. }
  20033. }
  20034. };
  20035. var handlers_pastedTextHandlers = function pastedTextHandlers(text, html, editorState, editor) {
  20036. if (editor.editorProps.handlePastedText && editor.editorProps.handlePastedText(text, html, editorState, editor) === 'handled') {
  20037. return 'handled';
  20038. }
  20039. if (!html || editor.editorProps.stripPastedStyles) {
  20040. return false;
  20041. }
  20042. var tempColors = external_braft_utils_["ColorUtils"].detectColorsFromHTMLString(html);
  20043. editor.setState({
  20044. tempColors: toConsumableArray_default()(editor.state.tempColors).concat(toConsumableArray_default()(tempColors)).filter(function (item) {
  20045. return editor.editorProps.colors.indexOf(item) === -1;
  20046. }).filter(function (item, index, array) {
  20047. return array.indexOf(item) === index;
  20048. })
  20049. }, function () {
  20050. editor.setValue(external_braft_utils_["ContentUtils"].insertHTML(editorState, html, 'paste'));
  20051. });
  20052. return 'handled';
  20053. };
  20054. // CONCATENATED MODULE: ./helpers/extension.js
  20055. // TODO
  20056. // - block-style和atomic类型的扩展支持
  20057. var extension_extensionControls = [];
  20058. var extension_extensionDecorators = [];
  20059. var extension_propInterceptors = [];
  20060. var extension_extensionBlockRenderMaps = [];
  20061. var extension_extensionBlockRendererFns = [];
  20062. var extensionInlineStyleMaps = [];
  20063. var extension_extensionInlineStyleFns = [];
  20064. var extensionEntities = [];
  20065. var inlineStyleImporters = [];
  20066. var inlineStyleExporters = [];
  20067. var blockImporters = [];
  20068. var blockExporters = [];
  20069. var filterByEditorId = function filterByEditorId(items, editorId) {
  20070. if (!editorId) {
  20071. return items.filter(function (item) {
  20072. return !item.includeEditors;
  20073. }).map(function (item) {
  20074. return item.data;
  20075. });
  20076. }
  20077. return items.map(function (item) {
  20078. if (!item.includeEditors && !item.excludeEditors) {
  20079. return item.data;
  20080. }
  20081. if (item.includeEditors) {
  20082. return item.includeEditors.indexOf(editorId) !== -1 ? item.data : false;
  20083. }
  20084. if (item.excludeEditors) {
  20085. return item.excludeEditors.indexOf(editorId) !== -1 ? false : item.data;
  20086. }
  20087. return false;
  20088. }).filter(function (item) {
  20089. return item;
  20090. });
  20091. };
  20092. var getPropInterceptors = function getPropInterceptors(editorId) {
  20093. return filterByEditorId(extension_propInterceptors, editorId);
  20094. };
  20095. var getExtensionControls = function getExtensionControls(editorId) {
  20096. return filterByEditorId(extension_extensionControls, editorId);
  20097. };
  20098. var getExtensionDecorators = function getExtensionDecorators(editorId) {
  20099. return filterByEditorId(extension_extensionDecorators, editorId);
  20100. };
  20101. var getExtensionBlockRenderMaps = function getExtensionBlockRenderMaps(editorId) {
  20102. return filterByEditorId(extension_extensionBlockRenderMaps, editorId);
  20103. };
  20104. var getExtensionBlockRendererFns = function getExtensionBlockRendererFns(editorId) {
  20105. return filterByEditorId(extension_extensionBlockRendererFns, editorId);
  20106. };
  20107. var getExtensionInlineStyleMap = function getExtensionInlineStyleMap(editorId) {
  20108. var inlineStyleMap = {};
  20109. filterByEditorId(extensionInlineStyleMaps, editorId).forEach(function (item) {
  20110. inlineStyleMap[item.inlineStyleName] = item.styleMap;
  20111. });
  20112. return inlineStyleMap;
  20113. };
  20114. var getExtensionInlineStyleFns = function getExtensionInlineStyleFns(editorId) {
  20115. return filterByEditorId(extension_extensionInlineStyleFns, editorId);
  20116. };
  20117. var compositeStyleImportFn = function compositeStyleImportFn(styleImportFn, editorId) {
  20118. return function (nodeName, node, style) {
  20119. filterByEditorId(inlineStyleImporters, editorId).forEach(function (styleImporter) {
  20120. if (styleImporter.importer && styleImporter.importer(nodeName, node)) {
  20121. style = style.add(styleImporter.inlineStyleName);
  20122. }
  20123. });
  20124. return styleImportFn ? styleImportFn(nodeName, node, style) : style;
  20125. };
  20126. };
  20127. var compositeStyleExportFn = function compositeStyleExportFn(styleExportFn, editorId) {
  20128. return function (style) {
  20129. style = style.toUpperCase();
  20130. var result = styleExportFn ? styleExportFn(style) : undefined;
  20131. if (result) {
  20132. return result;
  20133. }
  20134. filterByEditorId(inlineStyleExporters, editorId).find(function (item) {
  20135. if (item.inlineStyleName === style) {
  20136. result = item.exporter;
  20137. return true;
  20138. }
  20139. });
  20140. return result;
  20141. };
  20142. };
  20143. var compositeEntityImportFn = function compositeEntityImportFn(entityImportFn, editorId) {
  20144. return function (nodeName, node, createEntity, source) {
  20145. var result = entityImportFn ? entityImportFn(nodeName, node, createEntity, source) : null;
  20146. if (result) {
  20147. return result;
  20148. }
  20149. filterByEditorId(extensionEntities, editorId).find(function (entityItem) {
  20150. var matched = entityItem.importer ? entityItem.importer(nodeName, node, source) : null;
  20151. matched && (result = createEntity(entityItem.entityType, matched.mutability || 'MUTABLE', matched.data || {}));
  20152. return !!matched;
  20153. });
  20154. return result;
  20155. };
  20156. };
  20157. var compositeEntityExportFn = function compositeEntityExportFn(entityExportFn, editorId) {
  20158. return function (entity, originalText) {
  20159. var result = entityExportFn ? entityExportFn(entity, originalText) : undefined;
  20160. if (result) {
  20161. return result;
  20162. }
  20163. var entityType = entity.type.toUpperCase();
  20164. filterByEditorId(extensionEntities, editorId).find(function (entityItem) {
  20165. if (entityItem.entityType === entityType) {
  20166. result = entityItem.exporter ? entityItem.exporter(entity, originalText) : undefined;
  20167. return true;
  20168. }
  20169. });
  20170. return result;
  20171. };
  20172. };
  20173. var compositeBlockImportFn = function compositeBlockImportFn(blockImportFn, editorId) {
  20174. return function (nodeName, node, source) {
  20175. var result = blockImportFn ? blockImportFn(nodeName, node, source) : null;
  20176. if (result) {
  20177. return result;
  20178. }
  20179. filterByEditorId(blockImporters, editorId).find(function (blockImporter) {
  20180. var matched = blockImporter.importer ? blockImporter.importer(nodeName, node, source) : undefined;
  20181. matched && (result = matched);
  20182. return !!matched;
  20183. });
  20184. return result;
  20185. };
  20186. };
  20187. var compositeBlockExportFn = function compositeBlockExportFn(blockExportFn, editorId) {
  20188. return function (contentState, block) {
  20189. var result = blockExportFn ? blockExportFn(contentState, block) : null;
  20190. if (result) {
  20191. return result;
  20192. }
  20193. filterByEditorId(blockExporters, editorId).find(function (blockExporter) {
  20194. var matched = blockExporter.exporter ? blockExporter.exporter(contentState, block) : undefined;
  20195. matched && (result = matched);
  20196. return !!matched;
  20197. });
  20198. return result;
  20199. };
  20200. };
  20201. var extension_useExtension = function useExtension(extension) {
  20202. if (extension instanceof Array) {
  20203. extension.forEach(useExtension);
  20204. return false;
  20205. }
  20206. if (!extension || !extension.type || typeof extension.type !== 'string') {
  20207. return false;
  20208. }
  20209. var includeEditors = extension.includeEditors,
  20210. excludeEditors = extension.excludeEditors;
  20211. if (extension.type === 'control') {
  20212. extension_extensionControls.push({
  20213. includeEditors: includeEditors,
  20214. excludeEditors: excludeEditors,
  20215. data: extension.control
  20216. });
  20217. } else if (extension.type === 'inline-style') {
  20218. var inlineStyleName = extension.name.toUpperCase();
  20219. if (extension.control) {
  20220. extension_extensionControls.push({
  20221. includeEditors: includeEditors,
  20222. excludeEditors: excludeEditors,
  20223. data: objectSpread_default()({
  20224. key: inlineStyleName,
  20225. type: 'inline-style',
  20226. command: inlineStyleName
  20227. }, extension.control)
  20228. });
  20229. }
  20230. if (extension.style) {
  20231. extensionInlineStyleMaps.push({
  20232. includeEditors: includeEditors,
  20233. excludeEditors: excludeEditors,
  20234. data: {
  20235. inlineStyleName: inlineStyleName,
  20236. styleMap: extension.style
  20237. }
  20238. });
  20239. }
  20240. if (extension.styleFn) {
  20241. extension_extensionInlineStyleFns.push({
  20242. includeEditors: includeEditors,
  20243. excludeEditors: excludeEditors,
  20244. data: {
  20245. inlineStyleName: inlineStyleName,
  20246. styleFn: extension.styleFn
  20247. }
  20248. });
  20249. }
  20250. if (extension.importer) {
  20251. inlineStyleImporters.push({
  20252. includeEditors: includeEditors,
  20253. excludeEditors: excludeEditors,
  20254. data: {
  20255. inlineStyleName: inlineStyleName,
  20256. importer: extension.importer
  20257. }
  20258. });
  20259. }
  20260. inlineStyleExporters.push({
  20261. includeEditors: includeEditors,
  20262. excludeEditors: excludeEditors,
  20263. data: {
  20264. inlineStyleName: inlineStyleName,
  20265. exporter: extension.exporter ? extension.exporter(extension) : external_react_default.a.createElement("span", {
  20266. style: extension.style
  20267. })
  20268. }
  20269. });
  20270. } else if (extension.type === 'block-style') ; else if (extension.type === 'entity') {
  20271. var entityType = extension.name.toUpperCase();
  20272. if (extension.control) {
  20273. extension_extensionControls.push({
  20274. includeEditors: includeEditors,
  20275. excludeEditors: excludeEditors,
  20276. data: typeof extension.control === 'function' ? extension.control : objectSpread_default()({
  20277. key: entityType,
  20278. type: 'entity',
  20279. command: entityType,
  20280. data: {
  20281. mutability: extension.mutability || 'MUTABLE',
  20282. data: extension.data || {}
  20283. }
  20284. }, extension.control)
  20285. });
  20286. }
  20287. extensionEntities.push({
  20288. includeEditors: includeEditors,
  20289. excludeEditors: excludeEditors,
  20290. data: {
  20291. entityType: entityType,
  20292. importer: extension.importer,
  20293. exporter: extension.exporter
  20294. }
  20295. });
  20296. extension_extensionDecorators.push({
  20297. includeEditors: includeEditors,
  20298. excludeEditors: excludeEditors,
  20299. data: {
  20300. type: 'entity',
  20301. decorator: {
  20302. key: entityType,
  20303. component: extension.component
  20304. }
  20305. }
  20306. });
  20307. } else if (extension.type === 'block') {
  20308. var blockType = extension.name;
  20309. if (extension.renderMap) {
  20310. extension_extensionBlockRenderMaps.push({
  20311. includeEditors: includeEditors,
  20312. excludeEditors: excludeEditors,
  20313. data: {
  20314. blockType: blockType,
  20315. renderMap: extension.renderMap
  20316. }
  20317. });
  20318. }
  20319. if (extension.rendererFn) {
  20320. extension_extensionBlockRendererFns.push({
  20321. includeEditors: includeEditors,
  20322. excludeEditors: excludeEditors,
  20323. data: {
  20324. blockType: blockType,
  20325. rendererFn: extension.rendererFn
  20326. }
  20327. });
  20328. }
  20329. if (extension.importer) {
  20330. blockImporters.push({
  20331. includeEditors: includeEditors,
  20332. excludeEditors: excludeEditors,
  20333. data: {
  20334. blockType: blockType,
  20335. importer: extension.importer
  20336. }
  20337. });
  20338. }
  20339. if (extension.exporter) {
  20340. blockExporters.push({
  20341. includeEditors: includeEditors,
  20342. excludeEditors: excludeEditors,
  20343. data: {
  20344. blockType: blockType,
  20345. exporter: extension.exporter
  20346. }
  20347. });
  20348. }
  20349. } else if (extension.type === 'atomic') ; else if (extension.type === 'decorator') {
  20350. var decorator = extension.decorator;
  20351. if (decorator && decorator.strategy && decorator.component) {
  20352. extension_extensionDecorators.push({
  20353. includeEditors: includeEditors,
  20354. excludeEditors: excludeEditors,
  20355. data: {
  20356. type: 'strategy',
  20357. decorator: decorator
  20358. }
  20359. });
  20360. } else if (decorator && decorator.getDecorations) {
  20361. extension_extensionDecorators.push({
  20362. includeEditors: includeEditors,
  20363. excludeEditors: excludeEditors,
  20364. data: {
  20365. type: 'class',
  20366. decorator: decorator
  20367. }
  20368. });
  20369. }
  20370. } else if (extension.type === 'prop-interception') {
  20371. extension_propInterceptors.push({
  20372. includeEditors: includeEditors,
  20373. excludeEditors: excludeEditors,
  20374. data: extension.interceptor
  20375. });
  20376. }
  20377. };
  20378. var createExtensibleEditor = function createExtensibleEditor(BraftEditor) {
  20379. BraftEditor.use = extension_useExtension;
  20380. return BraftEditor;
  20381. };
  20382. // CONCATENATED MODULE: ./renderers/block/blockRenderMap.js
  20383. /* harmony default export */ var block_blockRenderMap = (function (props, blockRenderMap) {
  20384. var customBlockRenderMap = Object(external_immutable_["Map"])({
  20385. 'atomic': {
  20386. element: ''
  20387. },
  20388. 'code-block': {
  20389. element: 'code',
  20390. wrapper: external_react_default.a.createElement("pre", {
  20391. className: "braft-code-block"
  20392. })
  20393. }
  20394. });
  20395. try {
  20396. var extensionBlockRenderMaps = getExtensionBlockRenderMaps(props.editorId);
  20397. customBlockRenderMap = extensionBlockRenderMaps.reduce(function (customBlockRenderMap, item) {
  20398. return customBlockRenderMap.merge(typeof item.renderMap === 'function' ? item.renderMap(props) : item.renderMap);
  20399. }, customBlockRenderMap);
  20400. if (blockRenderMap) {
  20401. if (typeof blockRenderMap === 'function') {
  20402. customBlockRenderMap = customBlockRenderMap.merge(blockRenderMap(props));
  20403. } else {
  20404. customBlockRenderMap = customBlockRenderMap.merge(blockRenderMap);
  20405. }
  20406. }
  20407. customBlockRenderMap = external_draft_js_["DefaultDraftBlockRenderMap"].merge(customBlockRenderMap);
  20408. } catch (error) {
  20409. console.warn(error);
  20410. }
  20411. return customBlockRenderMap;
  20412. });
  20413. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/extends.js
  20414. var helpers_extends = __webpack_require__(11);
  20415. var extends_default = /*#__PURE__*/__webpack_require__.n(helpers_extends);
  20416. // EXTERNAL MODULE: ../node_modules/@babel/runtime/helpers/slicedToArray.js
  20417. var slicedToArray = __webpack_require__(24);
  20418. var slicedToArray_default = /*#__PURE__*/__webpack_require__.n(slicedToArray);
  20419. // EXTERNAL MODULE: ./renderers/atomics/Image/style.scss
  20420. var Image_style = __webpack_require__(45);
  20421. // EXTERNAL MODULE: ./components/common/Switch/style.scss
  20422. var Switch_style = __webpack_require__(46);
  20423. // CONCATENATED MODULE: ./components/common/Switch/index.jsx
  20424. /* harmony default export */ var Switch = (function (props) {
  20425. var active = props.active,
  20426. _onClick = props.onClick,
  20427. className = props.className;
  20428. return external_react_default.a.createElement("div", {
  20429. onClick: function onClick() {
  20430. return _onClick();
  20431. },
  20432. className: 'bf-switch ' + className + (active ? ' active' : '')
  20433. });
  20434. });
  20435. // CONCATENATED MODULE: ./configs/controls.js
  20436. /* harmony default export */ var configs_controls = (function (lang, editor) {
  20437. return [{
  20438. key: 'undo',
  20439. title: lang.controls.undo,
  20440. text: external_react_default.a.createElement("i", {
  20441. className: "bfi-undo"
  20442. }),
  20443. type: 'editor-method',
  20444. command: 'undo'
  20445. }, {
  20446. key: 'redo',
  20447. title: lang.controls.redo,
  20448. text: external_react_default.a.createElement("i", {
  20449. className: "bfi-redo"
  20450. }),
  20451. type: 'editor-method',
  20452. command: 'redo'
  20453. }, {
  20454. key: 'remove-styles',
  20455. title: lang.controls.removeStyles,
  20456. text: external_react_default.a.createElement("i", {
  20457. className: "bfi-format_clear"
  20458. }),
  20459. type: 'editor-method',
  20460. command: 'removeSelectionInlineStyles'
  20461. }, {
  20462. key: 'hr',
  20463. title: lang.controls.hr,
  20464. text: external_react_default.a.createElement("i", {
  20465. className: "bfi-hr"
  20466. }),
  20467. type: 'editor-method',
  20468. command: 'insertHorizontalLine'
  20469. }, {
  20470. key: 'bold',
  20471. title: lang.controls.bold,
  20472. text: external_react_default.a.createElement("i", {
  20473. className: "bfi-bold"
  20474. }),
  20475. type: 'inline-style',
  20476. command: 'bold'
  20477. }, {
  20478. key: 'italic',
  20479. title: lang.controls.italic,
  20480. text: external_react_default.a.createElement("i", {
  20481. className: "bfi-italic"
  20482. }),
  20483. type: 'inline-style',
  20484. command: 'italic'
  20485. }, {
  20486. key: 'underline',
  20487. title: lang.controls.underline,
  20488. text: external_react_default.a.createElement("i", {
  20489. className: "bfi-underlined"
  20490. }),
  20491. type: 'inline-style',
  20492. command: 'underline'
  20493. }, {
  20494. key: 'strike-through',
  20495. title: lang.controls.strikeThrough,
  20496. text: external_react_default.a.createElement("i", {
  20497. className: "bfi-strikethrough"
  20498. }),
  20499. type: 'inline-style',
  20500. command: 'strikethrough'
  20501. }, {
  20502. key: 'superscript',
  20503. title: lang.controls.superScript,
  20504. text: external_react_default.a.createElement("i", {
  20505. className: "bfi-superscript"
  20506. }),
  20507. type: 'inline-style',
  20508. command: 'superscript'
  20509. }, {
  20510. key: 'subscript',
  20511. title: lang.controls.subScript,
  20512. text: external_react_default.a.createElement("i", {
  20513. className: "bfi-subscript"
  20514. }),
  20515. type: 'inline-style',
  20516. command: 'subscript'
  20517. }, {
  20518. key: 'headings',
  20519. title: lang.controls.headings,
  20520. type: 'headings'
  20521. }, {
  20522. key: 'blockquote',
  20523. title: lang.controls.blockQuote,
  20524. text: external_react_default.a.createElement("i", {
  20525. className: "bfi-quote"
  20526. }),
  20527. type: 'block-type',
  20528. command: 'blockquote'
  20529. }, {
  20530. key: 'code',
  20531. title: lang.controls.code,
  20532. text: external_react_default.a.createElement("i", {
  20533. className: "bfi-code"
  20534. }),
  20535. type: 'block-type',
  20536. command: 'code-block'
  20537. }, {
  20538. key: 'list-ul',
  20539. title: lang.controls.unorderedList,
  20540. text: external_react_default.a.createElement("i", {
  20541. className: "bfi-list"
  20542. }),
  20543. type: 'block-type',
  20544. command: 'unordered-list-item'
  20545. }, {
  20546. key: 'list-ol',
  20547. title: lang.controls.orderedList,
  20548. text: external_react_default.a.createElement("i", {
  20549. className: "bfi-list-numbered"
  20550. }),
  20551. type: 'block-type',
  20552. command: 'ordered-list-item'
  20553. }, {
  20554. key: 'link',
  20555. title: lang.controls.link,
  20556. type: 'link'
  20557. }, {
  20558. key: 'text-color',
  20559. title: lang.controls.color,
  20560. type: 'text-color'
  20561. }, {
  20562. key: 'line-height',
  20563. title: lang.controls.lineHeight,
  20564. type: 'line-height'
  20565. }, {
  20566. key: 'letter-spacing',
  20567. title: lang.controls.letterSpacing,
  20568. type: 'letter-spacing'
  20569. }, {
  20570. key: 'text-indent',
  20571. title: lang.controls.textIndent,
  20572. type: 'text-indent'
  20573. }, {
  20574. key: 'font-size',
  20575. title: lang.controls.fontSize,
  20576. type: 'font-size'
  20577. }, {
  20578. key: 'font-family',
  20579. title: lang.controls.fontFamily,
  20580. type: 'font-family'
  20581. }, {
  20582. key: 'text-align',
  20583. title: lang.controls.textAlign,
  20584. type: 'text-align'
  20585. }, {
  20586. key: 'media',
  20587. title: lang.controls.media,
  20588. text: external_react_default.a.createElement("i", {
  20589. className: "bfi-media"
  20590. }),
  20591. type: 'media'
  20592. }, {
  20593. key: 'emoji',
  20594. title: lang.controls.emoji,
  20595. text: external_react_default.a.createElement("i", {
  20596. className: "bfi-emoji"
  20597. }),
  20598. type: 'emoji'
  20599. }, {
  20600. key: 'clear',
  20601. title: lang.controls.clear,
  20602. text: external_react_default.a.createElement("i", {
  20603. className: "bfi-clear_all"
  20604. }),
  20605. type: 'editor-method',
  20606. command: 'clearEditorContent'
  20607. }, {
  20608. key: 'fullscreen',
  20609. title: editor.state.isFullscreen ? lang.controls.exitFullscreen : lang.controls.fullscreen,
  20610. text: external_react_default.a.createElement("i", {
  20611. className: editor.state.isFullscreen ? 'bfi-fullscreen-exit' : 'bfi-fullscreen'
  20612. }),
  20613. type: 'editor-method',
  20614. command: 'toggleFullscreen'
  20615. }, {
  20616. key: 'modal',
  20617. type: 'modal'
  20618. }, {
  20619. key: 'button',
  20620. type: 'button'
  20621. }, {
  20622. key: 'dropdown',
  20623. type: 'dropdown'
  20624. }, {
  20625. key: 'component',
  20626. type: 'component'
  20627. }];
  20628. });
  20629. var imageControlItems = {
  20630. 'float-left': {
  20631. text: external_react_default.a.createElement("span", {
  20632. "data-float": "left"
  20633. }, "\uE91E"),
  20634. command: 'setImageFloat|left'
  20635. },
  20636. 'float-right': {
  20637. text: external_react_default.a.createElement("span", {
  20638. "data-float": "right"
  20639. }, "\uE914"),
  20640. command: 'setImageFloat|right'
  20641. },
  20642. 'align-left': {
  20643. text: external_react_default.a.createElement("span", {
  20644. "data-align": "left"
  20645. }, "\uE027"),
  20646. command: 'setImageAlignment|left'
  20647. },
  20648. 'align-center': {
  20649. text: external_react_default.a.createElement("span", {
  20650. "data-align": "center"
  20651. }, "\uE028"),
  20652. command: 'setImageAlignment|center'
  20653. },
  20654. 'align-right': {
  20655. text: external_react_default.a.createElement("span", {
  20656. "data-align": "right"
  20657. }, "\uE029"),
  20658. command: 'setImageAlignment|right'
  20659. },
  20660. 'size': {
  20661. text: external_react_default.a.createElement("span", null, "\uE3C2"),
  20662. command: 'toggleSizeEditor'
  20663. },
  20664. 'link': {
  20665. text: external_react_default.a.createElement("span", null, "\uE91A"),
  20666. command: 'toggleLinkEditor'
  20667. },
  20668. 'remove': {
  20669. text: external_react_default.a.createElement("span", null, "\uE9AC"),
  20670. command: 'removeImage'
  20671. }
  20672. };
  20673. // CONCATENATED MODULE: ./renderers/atomics/Image/index.jsx
  20674. var Image_Image =
  20675. /*#__PURE__*/
  20676. function (_React$Component) {
  20677. inherits_default()(Image, _React$Component);
  20678. function Image() {
  20679. var _getPrototypeOf2;
  20680. var _this;
  20681. classCallCheck_default()(this, Image);
  20682. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  20683. args[_key] = arguments[_key];
  20684. }
  20685. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Image)).call.apply(_getPrototypeOf2, [this].concat(args)));
  20686. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  20687. toolbarVisible: false,
  20688. toolbarOffset: 0,
  20689. linkEditorVisible: false,
  20690. sizeEditorVisible: false,
  20691. tempLink: null,
  20692. tempWidth: null,
  20693. tempHeight: null
  20694. });
  20695. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialLeft", void 0);
  20696. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialTop", void 0);
  20697. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialWidth", void 0);
  20698. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "initialHeight", void 0);
  20699. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "reSizeType", void 0);
  20700. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "changeSize", function (e) {
  20701. var type = _this.reSizeType;
  20702. if (!_this.initialLeft) {
  20703. _this.initialLeft = e.screenX;
  20704. _this.initialTop = e.screenY;
  20705. }
  20706. if (type === 'rightbottom') {
  20707. _this.initialHeight += e.screenY - _this.initialTop;
  20708. _this.initialWidth += e.screenX - _this.initialLeft;
  20709. }
  20710. if (type === 'leftbottom') {
  20711. _this.initialHeight += e.screenY - _this.initialTop;
  20712. _this.initialWidth += -e.screenX + _this.initialLeft;
  20713. }
  20714. _this.initialLeft = e.screenX;
  20715. _this.initialTop = e.screenY;
  20716. });
  20717. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "moveImage", function (e) {
  20718. _this.changeSize(e);
  20719. _this.setState({
  20720. tempWidth: Math.abs(_this.initialWidth),
  20721. tempHeight: Math.abs(_this.initialHeight)
  20722. });
  20723. });
  20724. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "upImage", function () {
  20725. _this.confirmImageSize();
  20726. document.removeEventListener('mousemove', _this.moveImage);
  20727. document.removeEventListener('mouseup', _this.upImage);
  20728. });
  20729. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "repareChangeSize", function (type) {
  20730. return function (e) {
  20731. _this.reSizeType = type;
  20732. var imageRect = _this.imageElement.getBoundingClientRect();
  20733. _this.initialLeft = _this.initialTop = 0;
  20734. _this.initialWidth = imageRect.width;
  20735. _this.initialHeight = imageRect.height;
  20736. e.preventDefault();
  20737. document.addEventListener('mousemove', _this.moveImage);
  20738. document.addEventListener('mouseup', _this.upImage);
  20739. };
  20740. });
  20741. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "preventDragEvent", function (event) {
  20742. event.stopPropagation();
  20743. event.preventDefault();
  20744. });
  20745. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDragStart", function () {
  20746. if (_this.props.editor.editorProps.readOnly || _this.props.editor.editorProps.disabled) {
  20747. return false;
  20748. }
  20749. window.__BRAFT_DRAGING__IMAGE__ = {
  20750. block: _this.props.block,
  20751. mediaData: objectSpread_default()({
  20752. type: 'IMAGE'
  20753. }, _this.props.mediaData)
  20754. };
  20755. _this.setState({
  20756. toolbarVisible: false
  20757. }, function () {
  20758. _this.unlockEditor();
  20759. });
  20760. return true;
  20761. });
  20762. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDragEnd", function () {
  20763. window.__BRAFT_DRAGING__IMAGE__ = null;
  20764. return false;
  20765. });
  20766. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "executeCommand", function (command) {
  20767. if (typeof command === 'string') {
  20768. var _command$split = command.split('|'),
  20769. _command$split2 = slicedToArray_default()(_command$split, 2),
  20770. method = _command$split2[0],
  20771. param = _command$split2[1];
  20772. _this[method] && _this[method](param);
  20773. } else if (typeof command === 'function') {
  20774. command(_this.props.block, _this.props.mediaData, _this.props.editor.getValue());
  20775. }
  20776. });
  20777. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeImage", function () {
  20778. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editor.getValue(), _this.props.block));
  20779. _this.unlockEditor();
  20780. });
  20781. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleLinkEditor", function () {
  20782. _this.setState({
  20783. linkEditorVisible: !_this.state.linkEditorVisible,
  20784. sizeEditorVisible: false
  20785. });
  20786. });
  20787. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleSizeEditor", function () {
  20788. _this.setState({
  20789. linkEditorVisible: false,
  20790. sizeEditorVisible: !_this.state.sizeEditorVisible
  20791. });
  20792. });
  20793. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleLinkInputKeyDown", function (e) {
  20794. if (e.keyCode === 13) {
  20795. _this.confirmImageLink();
  20796. } else {
  20797. return;
  20798. }
  20799. });
  20800. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageLink", function (e) {
  20801. _this.setState({
  20802. tempLink: e.currentTarget.value
  20803. });
  20804. return;
  20805. });
  20806. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "confirmImageLink", function () {
  20807. var link = _this.state.tempLink;
  20808. var hookReturns = _this.props.hooks('set-image-link', link)(link);
  20809. if (hookReturns === false) {
  20810. return false;
  20811. }
  20812. if (typeof hookReturns === 'string') {
  20813. link = hookReturns;
  20814. }
  20815. if (link !== null) {
  20816. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(_this.props.editor.getValue(), _this.props.entityKey, {
  20817. link: link
  20818. }));
  20819. window.setImmediate(_this.props.editor.forceRender);
  20820. }
  20821. });
  20822. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleSizeInputKeyDown", function (e) {
  20823. if (e.keyCode === 13) {
  20824. _this.confirmImageSize();
  20825. } else {
  20826. return;
  20827. }
  20828. });
  20829. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageWidth", function (_ref) {
  20830. var currentTarget = _ref.currentTarget;
  20831. var value = currentTarget.value;
  20832. value && !isNaN(value) && (value = value + 'px');
  20833. _this.setState({
  20834. tempWidth: value
  20835. });
  20836. return;
  20837. });
  20838. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageHeight", function (_ref2) {
  20839. var currentTarget = _ref2.currentTarget;
  20840. var value = currentTarget.value;
  20841. value && !isNaN(value) && (value = value + 'px');
  20842. _this.setState({
  20843. tempHeight: value
  20844. });
  20845. return;
  20846. });
  20847. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "confirmImageSize", function () {
  20848. var _this$state = _this.state,
  20849. width = _this$state.tempWidth,
  20850. height = _this$state.tempHeight;
  20851. var newImageSize = {};
  20852. width !== null && (newImageSize.width = width);
  20853. height !== null && (newImageSize.height = height);
  20854. var hookReturns = _this.props.hooks('set-image-size', newImageSize)(newImageSize);
  20855. if (hookReturns === false) {
  20856. return false;
  20857. }
  20858. if (hookReturns && (hookReturns.width || hookReturns.height)) {
  20859. newImageSize = hookReturns;
  20860. }
  20861. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(_this.props.editor.getValue(), _this.props.entityKey, newImageSize));
  20862. window.setImmediate(_this.props.editor.forceRender);
  20863. });
  20864. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageFloat", function (float) {
  20865. var hookReturns = _this.props.hooks('set-image-float', float)(float);
  20866. if (hookReturns === false) {
  20867. return false;
  20868. }
  20869. if (typeof hookReturns === 'string') {
  20870. float = hookReturns;
  20871. }
  20872. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaPosition(_this.props.editor.getValue(), _this.props.block, {
  20873. float: float
  20874. }));
  20875. _this.unlockEditor();
  20876. });
  20877. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setImageAlignment", function (alignment) {
  20878. var hookReturns = _this.props.hooks('set-image-alignment', alignment)(alignment);
  20879. if (hookReturns === false) {
  20880. return false;
  20881. }
  20882. if (typeof hookReturns === 'string') {
  20883. alignment = hookReturns;
  20884. }
  20885. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaPosition(_this.props.editor.getValue(), _this.props.block, {
  20886. alignment: alignment
  20887. }));
  20888. _this.unlockEditor();
  20889. });
  20890. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "showToolbar", function (event) {
  20891. if (_this.props.editor.editorProps.readOnly || _this.props.editor.editorProps.disabled) {
  20892. return false;
  20893. }
  20894. event.preventDefault();
  20895. if (!_this.state.toolbarVisible) {
  20896. _this.setState({
  20897. toolbarVisible: true
  20898. }, function () {
  20899. _this.lockEditor();
  20900. _this.setState({
  20901. toolbarOffset: _this.calcToolbarOffset()
  20902. });
  20903. });
  20904. }
  20905. });
  20906. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "hideToolbar", function (event) {
  20907. event.preventDefault();
  20908. _this.setState({
  20909. toolbarVisible: false
  20910. }, function () {
  20911. _this.unlockEditor(); // this.props.editor.requestFocus()
  20912. });
  20913. });
  20914. return _this;
  20915. }
  20916. createClass_default()(Image, [{
  20917. key: "render",
  20918. value: function render() {
  20919. var _this2 = this;
  20920. var _this$props = this.props,
  20921. mediaData = _this$props.mediaData,
  20922. language = _this$props.language,
  20923. imageControls = _this$props.imageControls,
  20924. imageResizable = _this$props.imageResizable;
  20925. var _this$state2 = this.state,
  20926. toolbarVisible = _this$state2.toolbarVisible,
  20927. toolbarOffset = _this$state2.toolbarOffset,
  20928. linkEditorVisible = _this$state2.linkEditorVisible,
  20929. sizeEditorVisible = _this$state2.sizeEditorVisible,
  20930. tempWidth = _this$state2.tempWidth,
  20931. tempHeight = _this$state2.tempHeight;
  20932. var blockData = this.props.block.getData();
  20933. var float = blockData.get('float');
  20934. var alignment = blockData.get('alignment');
  20935. var url = mediaData.url,
  20936. link = mediaData.link,
  20937. link_target = mediaData.link_target,
  20938. width = mediaData.width,
  20939. height = mediaData.height,
  20940. meta = mediaData.meta;
  20941. var imageStyles = {};
  20942. var clearFix = false;
  20943. if (float) {
  20944. alignment = null;
  20945. } else if (alignment === 'left') {
  20946. imageStyles.float = 'left';
  20947. clearFix = true;
  20948. } else if (alignment === 'right') {
  20949. imageStyles.float = 'right';
  20950. clearFix = true;
  20951. } else if (alignment === 'center') {
  20952. imageStyles.textAlign = 'center';
  20953. } else {
  20954. imageStyles.float = 'left';
  20955. clearFix = true;
  20956. }
  20957. var renderedControlItems = imageControls.map(function (item, index) {
  20958. if (typeof item === 'string' && imageControlItems[item]) {
  20959. return external_react_default.a.createElement("a", {
  20960. className: item === 'link' && link ? 'active' : '',
  20961. key: index,
  20962. onClick: function onClick() {
  20963. return _this2.executeCommand(imageControlItems[item].command);
  20964. }
  20965. }, imageControlItems[item].text);
  20966. } else if (item && (item.render || item.text)) {
  20967. return item.render ? item.render(mediaData, _this2.props.block) : external_react_default.a.createElement("a", {
  20968. key: index,
  20969. onClick: function onClick() {
  20970. return item.onClick && _this2.executeCommand(item.onClick);
  20971. }
  20972. }, item.text);
  20973. } else {
  20974. return null;
  20975. }
  20976. });
  20977. return external_react_default.a.createElement("div", {
  20978. className: "bf-media"
  20979. }, external_react_default.a.createElement("div", {
  20980. style: imageStyles,
  20981. draggable: true,
  20982. onMouseEnter: this.showToolbar,
  20983. onMouseMove: this.showToolbar,
  20984. onMouseLeave: this.hideToolbar,
  20985. onDragStart: this.handleDragStart,
  20986. onDragEnd: this.handleDragEnd,
  20987. ref: function ref(instance) {
  20988. return _this2.mediaEmbederInstance = instance;
  20989. },
  20990. className: "bf-image"
  20991. }, toolbarVisible ? external_react_default.a.createElement("div", {
  20992. style: {
  20993. marginLeft: toolbarOffset
  20994. },
  20995. ref: function ref(instance) {
  20996. return _this2.toolbarElement = instance;
  20997. },
  20998. "data-float": float,
  20999. "data-align": alignment,
  21000. className: "bf-media-toolbar"
  21001. }, linkEditorVisible ? external_react_default.a.createElement("div", {
  21002. className: "bf-image-link-editor"
  21003. }, external_react_default.a.createElement("div", {
  21004. className: "editor-input-group"
  21005. }, external_react_default.a.createElement("input", {
  21006. type: "text",
  21007. placeholder: language.linkEditor.inputWithEnterPlaceHolder,
  21008. onKeyDown: this.handleLinkInputKeyDown,
  21009. onChange: this.setImageLink,
  21010. defaultValue: link
  21011. }), external_react_default.a.createElement("button", {
  21012. type: "button",
  21013. onClick: this.confirmImageLink
  21014. }, language.base.confirm)), external_react_default.a.createElement("div", {
  21015. className: "switch-group"
  21016. }, external_react_default.a.createElement(Switch, {
  21017. active: link_target === '_blank',
  21018. onClick: function onClick() {
  21019. return _this2.setImageLinkTarget(link_target);
  21020. }
  21021. }), external_react_default.a.createElement("label", null, language.linkEditor.openInNewWindow))) : null, sizeEditorVisible ? external_react_default.a.createElement("div", {
  21022. className: "bf-image-size-editor"
  21023. }, external_react_default.a.createElement("div", {
  21024. className: "editor-input-group"
  21025. }, external_react_default.a.createElement("input", {
  21026. type: "text",
  21027. placeholder: language.base.width,
  21028. onKeyDown: this.handleSizeInputKeyDown,
  21029. onChange: this.setImageWidth,
  21030. defaultValue: width
  21031. }), external_react_default.a.createElement("input", {
  21032. type: "text",
  21033. placeholder: language.base.height,
  21034. onKeyDown: this.handleSizeInputKeyDown,
  21035. onChange: this.setImageHeight,
  21036. defaultValue: height
  21037. }), external_react_default.a.createElement("button", {
  21038. type: "button",
  21039. onClick: this.confirmImageSize
  21040. }, language.base.confirm))) : null, renderedControlItems, external_react_default.a.createElement("i", {
  21041. style: {
  21042. marginLeft: toolbarOffset * -1
  21043. },
  21044. className: "bf-media-toolbar-arrow"
  21045. })) : null, external_react_default.a.createElement("div", {
  21046. style: {
  21047. position: 'relative',
  21048. width: "".concat(width, "px"),
  21049. height: "".concat(height, "px"),
  21050. display: 'inline-block'
  21051. }
  21052. }, external_react_default.a.createElement("img", extends_default()({
  21053. ref: function ref(instance) {
  21054. return _this2.imageElement = instance;
  21055. },
  21056. src: url,
  21057. width: width,
  21058. height: height
  21059. }, meta)), toolbarVisible && imageResizable ? external_react_default.a.createElement("div", {
  21060. className: "bf-csize-icon right-bottom",
  21061. onMouseDown: this.repareChangeSize('rightbottom')
  21062. }) : null, toolbarVisible && imageResizable ? external_react_default.a.createElement("div", {
  21063. className: "bf-csize-icon left-bottom",
  21064. onMouseDown: this.repareChangeSize('leftbottom')
  21065. }) : null, external_react_default.a.createElement("div", {
  21066. className: "bf-pre-csize ".concat(this.reSizeType),
  21067. style: {
  21068. width: "".concat(tempWidth, "px"),
  21069. height: "".concat(tempHeight, "px")
  21070. }
  21071. }))), clearFix && external_react_default.a.createElement("div", {
  21072. className: "clearfix",
  21073. style: {
  21074. clear: 'both',
  21075. height: 0,
  21076. lineHeight: 0,
  21077. float: 'none'
  21078. }
  21079. }));
  21080. }
  21081. }, {
  21082. key: "lockEditor",
  21083. value: function lockEditor() {
  21084. this.props.editor.lockOrUnlockEditor(true);
  21085. }
  21086. }, {
  21087. key: "unlockEditor",
  21088. value: function unlockEditor() {
  21089. this.props.editor.lockOrUnlockEditor(false);
  21090. }
  21091. }, {
  21092. key: "calcToolbarOffset",
  21093. value: function calcToolbarOffset() {
  21094. var _this$props2 = this.props,
  21095. getContainerNode = _this$props2.getContainerNode,
  21096. containerNode = _this$props2.containerNode;
  21097. var container = getContainerNode ? getContainerNode() : containerNode;
  21098. if (!container) {
  21099. return 0;
  21100. }
  21101. var viewRect = container.querySelector('.bf-content').getBoundingClientRect();
  21102. var toolbarRect = this.toolbarElement.getBoundingClientRect();
  21103. var imageRect = this.imageElement.getBoundingClientRect();
  21104. var right = viewRect.right - (imageRect.right - imageRect.width / 2 + toolbarRect.width / 2);
  21105. var left = imageRect.left + imageRect.width / 2 - toolbarRect.width / 2 - viewRect.left;
  21106. if (right < 10) {
  21107. return right - 10;
  21108. } else if (left < 10) {
  21109. return left * -1 + 10;
  21110. } else {
  21111. return 0;
  21112. }
  21113. }
  21114. }, {
  21115. key: "setImageLinkTarget",
  21116. value: function setImageLinkTarget(link_target) {
  21117. var hookReturns = this.props.hooks('set-image-link-target', link_target)(link_target);
  21118. if (hookReturns === false) {
  21119. return false;
  21120. }
  21121. if (typeof hookReturns === 'string') {
  21122. link_target = hookReturns;
  21123. }
  21124. link_target = link_target === '_blank' ? '' : '_blank';
  21125. this.props.editor.setValue(external_braft_utils_["ContentUtils"].setMediaData(this.props.editor.getValue(), this.props.entityKey, {
  21126. link_target: link_target
  21127. }));
  21128. window.setImmediate(this.props.editor.forceRender);
  21129. }
  21130. }]);
  21131. return Image;
  21132. }(external_react_default.a.Component);
  21133. // EXTERNAL MODULE: ./renderers/atomics/Video/style.scss
  21134. var Video_style = __webpack_require__(47);
  21135. // EXTERNAL MODULE: ./components/common/Modal/style.scss
  21136. var Modal_style = __webpack_require__(48);
  21137. // EXTERNAL MODULE: external "react-dom"
  21138. var external_react_dom_ = __webpack_require__(16);
  21139. var external_react_dom_default = /*#__PURE__*/__webpack_require__.n(external_react_dom_);
  21140. // CONCATENATED MODULE: ./components/common/Modal/index.jsx
  21141. var Modal_Modal =
  21142. /*#__PURE__*/
  21143. function (_React$Component) {
  21144. inherits_default()(Modal, _React$Component);
  21145. function Modal(props) {
  21146. var _this;
  21147. classCallCheck_default()(this, Modal);
  21148. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(Modal).call(this, props));
  21149. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleTransitionEnd", function () {
  21150. if (!_this.rootElement || !_this.rootElement.classList) {
  21151. return false;
  21152. }
  21153. if (!_this.rootElement.classList.contains('active')) {
  21154. external_react_dom_default.a.unmountComponentAtNode(_this.rootElement) && _this.rootElement.parentNode.removeChild(_this.rootElement);
  21155. }
  21156. });
  21157. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleMouseDown", function (event) {
  21158. var tagName = event.target.tagName.toLowerCase();
  21159. if (tagName === 'input' || tagName === 'textarea') {
  21160. return false;
  21161. }
  21162. event.preventDefault();
  21163. });
  21164. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCancel", function () {
  21165. _this.props.closeOnCancel && _this.close();
  21166. _this.props.onCancel && _this.props.onCancel();
  21167. });
  21168. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleConfirm", function () {
  21169. _this.props.closeOnConfirm && _this.close();
  21170. _this.props.onConfirm && _this.props.onConfirm();
  21171. });
  21172. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleMaskClick", function () {
  21173. _this.props.closeOnBlur && _this.close();
  21174. _this.props.onBlue && _this.props.onBlue();
  21175. });
  21176. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "close", function () {
  21177. _this.unrenderComponent();
  21178. _this.props.onClose && _this.props.onClose();
  21179. });
  21180. _this.active = false;
  21181. _this.componentId = 'BRAFT-MODAL-' + external_braft_utils_["BaseUtils"].UniqueIndex();
  21182. return _this;
  21183. }
  21184. createClass_default()(Modal, [{
  21185. key: "componentDidMount",
  21186. value: function componentDidMount() {
  21187. if (this.props.visible) {
  21188. this.active = true;
  21189. this.renderComponent(this.props);
  21190. }
  21191. }
  21192. }, {
  21193. key: "componentWillReceiveProps",
  21194. value: function componentWillReceiveProps(next) {
  21195. if (this.props.visible && !next.visible) {
  21196. this.unrenderComponent();
  21197. } else if (this.props.visible || next.visible) {
  21198. this.active = true;
  21199. this.renderComponent(next);
  21200. }
  21201. }
  21202. }, {
  21203. key: "render",
  21204. value: function render() {
  21205. return null;
  21206. }
  21207. }, {
  21208. key: "unrenderComponent",
  21209. value: function unrenderComponent() {
  21210. this.active = false;
  21211. this.activeId && window.clearImmediate(this.activeId);
  21212. if (this.rootElement && this.rootElement.classList) {
  21213. this.rootElement.classList.remove('active');
  21214. }
  21215. }
  21216. }, {
  21217. key: "renderComponent",
  21218. value: function renderComponent(props) {
  21219. var _this2 = this;
  21220. if (!this.active) {
  21221. return false;
  21222. }
  21223. var title = props.title,
  21224. className = props.className,
  21225. width = props.width,
  21226. height = props.height,
  21227. children = props.children,
  21228. component = props.component,
  21229. confirmable = props.confirmable,
  21230. showFooter = props.showFooter,
  21231. showCancel = props.showCancel,
  21232. showConfirm = props.showConfirm,
  21233. showClose = props.showClose,
  21234. cancelText = props.cancelText,
  21235. confirmText = props.confirmText,
  21236. bottomText = props.bottomText,
  21237. language = props.language;
  21238. typeof showCancel === 'undefined' && (showCancel = true);
  21239. typeof showClose === 'undefined' && (showClose = true);
  21240. typeof showConfirm === 'undefined' && (showConfirm = true);
  21241. typeof showFooter === 'undefined' && (showFooter = true);
  21242. var childComponent = external_react_default.a.createElement("div", {
  21243. onMouseDown: this.handleMouseDown,
  21244. className: 'bf-modal ' + (className || '')
  21245. }, external_react_default.a.createElement("div", {
  21246. className: "bf-modal-mask",
  21247. onClick: this.handleMaskClick
  21248. }), external_react_default.a.createElement("div", {
  21249. onTransitionEnd: this.handleTransitionEnd,
  21250. style: {
  21251. width: width,
  21252. height: height
  21253. },
  21254. className: "bf-modal-content"
  21255. }, external_react_default.a.createElement("div", {
  21256. className: "bf-modal-header"
  21257. }, external_react_default.a.createElement("h3", {
  21258. className: "bf-modal-caption"
  21259. }, title), showClose && external_react_default.a.createElement("button", {
  21260. type: "button",
  21261. onClick: this.close,
  21262. className: "bf-modal-close-button"
  21263. }, external_react_default.a.createElement("i", {
  21264. className: "bfi-close"
  21265. }))), external_react_default.a.createElement("div", {
  21266. className: "bf-modal-body"
  21267. }, children || component), showFooter ? external_react_default.a.createElement("div", {
  21268. className: "bf-modal-footer"
  21269. }, external_react_default.a.createElement("div", {
  21270. className: "bf-modal-addon-text"
  21271. }, bottomText), external_react_default.a.createElement("div", {
  21272. className: "bf-modal-buttons"
  21273. }, showCancel && external_react_default.a.createElement("button", {
  21274. type: "button",
  21275. onClick: this.handleCancel,
  21276. className: "bf-modal-cancel"
  21277. }, cancelText || language.base.cancel), showConfirm && external_react_default.a.createElement("button", {
  21278. type: "button",
  21279. onClick: this.handleConfirm,
  21280. className: 'bf-modal-confirm ' + (!confirmable ? 'disabled' : '')
  21281. }, confirmText || language.base.confirm))) : null));
  21282. this.rootElement = document.querySelector('#' + this.componentId);
  21283. if (!this.rootElement) {
  21284. this.rootElement = document.createElement('div');
  21285. this.rootElement.id = this.componentId;
  21286. this.rootElement.className = 'bf-modal-root';
  21287. document.body.appendChild(this.rootElement);
  21288. }
  21289. external_react_dom_default.a.render(childComponent, this.rootElement);
  21290. this.activeId = window.setImmediate(function () {
  21291. _this2.rootElement.classList.add('active');
  21292. });
  21293. }
  21294. }]);
  21295. return Modal;
  21296. }(external_react_default.a.Component);
  21297. defineProperty_default()(Modal_Modal, "defaultProps", {
  21298. showFooter: true,
  21299. closeOnBlur: true
  21300. });
  21301. var Modal_showModal = function showModal(props) {
  21302. var hostNode = document.createElement('div');
  21303. hostNode.style.display = 'none';
  21304. document.body.appendChild(hostNode);
  21305. props = objectSpread_default()({
  21306. visible: true,
  21307. closeOnConfirm: true,
  21308. closeOnCancel: true
  21309. }, props);
  21310. var close = function close() {
  21311. external_react_dom_default.a.unmountComponentAtNode(hostNode) && hostNode.parentNode.removeChild(hostNode);
  21312. };
  21313. var onConfirm = function onConfirm() {
  21314. props.onConfirm && props.onConfirm();
  21315. };
  21316. var onCancel = function onCancel() {
  21317. props.onCancel && props.onCancel();
  21318. };
  21319. var onClose = function onClose() {
  21320. close();
  21321. props.onClose && props.onClose();
  21322. };
  21323. var modalInstance = external_react_dom_default.a.render(external_react_default.a.createElement(Modal_Modal, extends_default()({}, props, {
  21324. onConfirm: onConfirm,
  21325. onCancel: onCancel,
  21326. onClose: onClose
  21327. })), hostNode);
  21328. modalInstance.destroy = close;
  21329. modalInstance.update = modalInstance.renderComponent;
  21330. return modalInstance;
  21331. };
  21332. // EXTERNAL MODULE: ./components/business/PlayerModal/style.scss
  21333. var PlayerModal_style = __webpack_require__(49);
  21334. // CONCATENATED MODULE: ./components/business/PlayerModal/index.jsx
  21335. var PlayerModal_playViaModal = function playViaModal(title, component, language) {
  21336. return Modal_showModal({
  21337. title: title,
  21338. component: component,
  21339. language: language,
  21340. showFooter: false
  21341. });
  21342. };
  21343. var typeIconsMap = {
  21344. 'video': 'bfi-film',
  21345. 'audio': 'bfi-music',
  21346. 'embed': 'bfi-code'
  21347. };
  21348. /* harmony default export */ var PlayerModal = (function (_ref) {
  21349. var title = _ref.title,
  21350. type = _ref.type,
  21351. language = _ref.language,
  21352. name = _ref.name,
  21353. url = _ref.url,
  21354. poster = _ref.poster,
  21355. children = _ref.children,
  21356. onRemove = _ref.onRemove;
  21357. return external_react_default.a.createElement("div", {
  21358. className: "bf-player-holder ".concat(type)
  21359. }, external_react_default.a.createElement("div", {
  21360. className: "icon-badge"
  21361. }, external_react_default.a.createElement("i", {
  21362. className: typeIconsMap[type]
  21363. }), external_react_default.a.createElement("span", {
  21364. className: "text"
  21365. }, language.media[type])), external_react_default.a.createElement("button", {
  21366. onMouseDown: onRemove,
  21367. className: "button-remove"
  21368. }, external_react_default.a.createElement("i", {
  21369. className: "bfi-close"
  21370. })), external_react_default.a.createElement("button", {
  21371. onMouseDown: function onMouseDown() {
  21372. return PlayerModal_playViaModal(name ? "".concat(title, ":").concat(name) : title, children, language);
  21373. },
  21374. className: "button-play"
  21375. }, external_react_default.a.createElement("i", {
  21376. className: "bfi-play_arrow"
  21377. })), name ? external_react_default.a.createElement("h5", {
  21378. className: "bf-name"
  21379. }, name) : null, external_react_default.a.createElement("h6", {
  21380. className: "bf-url"
  21381. }, url), poster ? external_react_default.a.createElement("div", {
  21382. className: "bf-poster",
  21383. style: {
  21384. backgroundImage: "url(".concat(poster, ")")
  21385. }
  21386. }) : null);
  21387. });
  21388. // CONCATENATED MODULE: ./renderers/atomics/Video/index.jsx
  21389. var Video_Video =
  21390. /*#__PURE__*/
  21391. function (_React$Component) {
  21392. inherits_default()(Video, _React$Component);
  21393. function Video() {
  21394. var _getPrototypeOf2;
  21395. var _this;
  21396. classCallCheck_default()(this, Video);
  21397. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  21398. args[_key] = arguments[_key];
  21399. }
  21400. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Video)).call.apply(_getPrototypeOf2, [this].concat(args)));
  21401. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeVideo", function () {
  21402. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  21403. });
  21404. return _this;
  21405. }
  21406. createClass_default()(Video, [{
  21407. key: "render",
  21408. value: function render() {
  21409. var _this$props = this.props,
  21410. mediaData = _this$props.mediaData,
  21411. language = _this$props.language;
  21412. var url = mediaData.url,
  21413. name = mediaData.name,
  21414. meta = mediaData.meta;
  21415. return external_react_default.a.createElement("div", {
  21416. className: "bf-video-wrap"
  21417. }, external_react_default.a.createElement(PlayerModal, {
  21418. type: "video",
  21419. onRemove: this.removeVideo,
  21420. poster: meta ? meta.poster || '' : '',
  21421. language: language,
  21422. url: url,
  21423. name: name,
  21424. title: language.videoPlayer.title
  21425. }, external_react_default.a.createElement("div", {
  21426. className: "bf-video-player"
  21427. }, external_react_default.a.createElement("video", {
  21428. controls: true,
  21429. poster: meta ? meta.poster || '' : ''
  21430. }, external_react_default.a.createElement("source", {
  21431. src: url
  21432. })))));
  21433. }
  21434. }]);
  21435. return Video;
  21436. }(external_react_default.a.Component);
  21437. // EXTERNAL MODULE: ./renderers/atomics/Audio/style.scss
  21438. var Audio_style = __webpack_require__(50);
  21439. // CONCATENATED MODULE: ./renderers/atomics/Audio/index.jsx
  21440. var Audio_Audio =
  21441. /*#__PURE__*/
  21442. function (_React$Component) {
  21443. inherits_default()(Audio, _React$Component);
  21444. function Audio() {
  21445. var _getPrototypeOf2;
  21446. var _this;
  21447. classCallCheck_default()(this, Audio);
  21448. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  21449. args[_key] = arguments[_key];
  21450. }
  21451. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Audio)).call.apply(_getPrototypeOf2, [this].concat(args)));
  21452. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeAudio", function () {
  21453. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  21454. });
  21455. return _this;
  21456. }
  21457. createClass_default()(Audio, [{
  21458. key: "render",
  21459. value: function render() {
  21460. var _this$props = this.props,
  21461. mediaData = _this$props.mediaData,
  21462. language = _this$props.language;
  21463. var url = mediaData.url,
  21464. name = mediaData.name,
  21465. meta = mediaData.meta;
  21466. return external_react_default.a.createElement("div", {
  21467. className: "bf-audio-wrap"
  21468. }, external_react_default.a.createElement(PlayerModal, {
  21469. type: "audio",
  21470. onRemove: this.removeAudio,
  21471. poster: meta ? meta.poster || '' : '',
  21472. language: language,
  21473. url: url,
  21474. name: name,
  21475. title: language.audioPlayer.title
  21476. }, external_react_default.a.createElement("div", {
  21477. className: "bf-audio-player"
  21478. }, external_react_default.a.createElement("audio", {
  21479. controls: true,
  21480. src: url
  21481. }))));
  21482. }
  21483. }]);
  21484. return Audio;
  21485. }(external_react_default.a.Component);
  21486. // EXTERNAL MODULE: ./renderers/atomics/Embed/style.scss
  21487. var Embed_style = __webpack_require__(51);
  21488. // CONCATENATED MODULE: ./renderers/atomics/Embed/index.jsx
  21489. var Embed_Embed =
  21490. /*#__PURE__*/
  21491. function (_React$Component) {
  21492. inherits_default()(Embed, _React$Component);
  21493. function Embed() {
  21494. var _getPrototypeOf2;
  21495. var _this;
  21496. classCallCheck_default()(this, Embed);
  21497. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  21498. args[_key] = arguments[_key];
  21499. }
  21500. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(Embed)).call.apply(_getPrototypeOf2, [this].concat(args)));
  21501. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeEmbed", function () {
  21502. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  21503. });
  21504. return _this;
  21505. }
  21506. createClass_default()(Embed, [{
  21507. key: "render",
  21508. value: function render() {
  21509. var _this$props = this.props,
  21510. mediaData = _this$props.mediaData,
  21511. language = _this$props.language;
  21512. var name = mediaData.name,
  21513. url = mediaData.url,
  21514. meta = mediaData.meta;
  21515. return external_react_default.a.createElement("div", {
  21516. className: "bf-embed-wrap"
  21517. }, external_react_default.a.createElement(PlayerModal, {
  21518. type: "embed",
  21519. onRemove: this.removeEmbed,
  21520. poster: meta ? meta.poster || '' : '',
  21521. language: language,
  21522. url: url,
  21523. name: name,
  21524. title: language.videoPlayer.embedTitle
  21525. }, external_react_default.a.createElement("div", {
  21526. className: "bf-embed-player",
  21527. dangerouslySetInnerHTML: {
  21528. __html: url
  21529. }
  21530. })));
  21531. }
  21532. }]);
  21533. return Embed;
  21534. }(external_react_default.a.Component);
  21535. // EXTERNAL MODULE: ./renderers/atomics/HorizontalLine/style.scss
  21536. var HorizontalLine_style = __webpack_require__(52);
  21537. // CONCATENATED MODULE: ./renderers/atomics/HorizontalLine/index.jsx
  21538. var HorizontalLine_HorizontalLine =
  21539. /*#__PURE__*/
  21540. function (_React$Component) {
  21541. inherits_default()(HorizontalLine, _React$Component);
  21542. function HorizontalLine() {
  21543. var _getPrototypeOf2;
  21544. var _this;
  21545. classCallCheck_default()(this, HorizontalLine);
  21546. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  21547. args[_key] = arguments[_key];
  21548. }
  21549. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(HorizontalLine)).call.apply(_getPrototypeOf2, [this].concat(args)));
  21550. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeHorizontalLine", function () {
  21551. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].removeBlock(_this.props.editorState, _this.props.block));
  21552. });
  21553. return _this;
  21554. }
  21555. createClass_default()(HorizontalLine, [{
  21556. key: "render",
  21557. value: function render() {
  21558. return external_react_default.a.createElement("div", {
  21559. className: "bf-hr"
  21560. }, external_react_default.a.createElement("div", {
  21561. className: "bf-media-toolbar"
  21562. }, external_react_default.a.createElement("a", {
  21563. onClick: this.removeHorizontalLine
  21564. }, "\uE9AC")));
  21565. }
  21566. }]);
  21567. return HorizontalLine;
  21568. }(external_react_default.a.Component);
  21569. // CONCATENATED MODULE: ./renderers/block/blockRendererFn.js
  21570. var blockRendererFn_BlockRenderFnContext = function BlockRenderFnContext() {
  21571. var _this = this;
  21572. classCallCheck_default()(this, BlockRenderFnContext);
  21573. defineProperty_default()(this, "superProps", void 0);
  21574. defineProperty_default()(this, "customBlockRendererFn", void 0);
  21575. defineProperty_default()(this, "getRenderFn", function (superProps, customBlockRendererFn) {
  21576. _this.superProps = superProps;
  21577. _this.customBlockRendererFn = customBlockRendererFn;
  21578. return _this.blockRendererFn;
  21579. });
  21580. defineProperty_default()(this, "renderAtomicBlock", function (props) {
  21581. var superProps = _this.superProps;
  21582. var entityKey = props.block.getEntityAt(0);
  21583. if (!entityKey) {
  21584. return null;
  21585. }
  21586. var entity = props.contentState.getEntity(entityKey);
  21587. var mediaData = entity.getData();
  21588. var mediaType = entity.getType();
  21589. var mediaProps = objectSpread_default()({}, superProps, {
  21590. block: props.block,
  21591. mediaData: mediaData,
  21592. entityKey: entityKey
  21593. });
  21594. if (mediaType === 'IMAGE') {
  21595. return external_react_default.a.createElement(Image_Image, mediaProps);
  21596. } else if (mediaType === 'AUDIO') {
  21597. return external_react_default.a.createElement(Audio_Audio, mediaProps);
  21598. } else if (mediaType === 'VIDEO') {
  21599. return external_react_default.a.createElement(Video_Video, mediaProps);
  21600. } else if (mediaType === 'EMBED') {
  21601. return external_react_default.a.createElement(Embed_Embed, mediaProps);
  21602. } else if (mediaType === 'HR') {
  21603. return external_react_default.a.createElement(HorizontalLine_HorizontalLine, mediaProps);
  21604. }
  21605. if (superProps.extendAtomics) {
  21606. var atomics = superProps.extendAtomics;
  21607. for (var i = 0; i < atomics.length; i++) {
  21608. if (mediaType === atomics[i].type) {
  21609. var Component = atomics[i].component;
  21610. return external_react_default.a.createElement(Component, mediaProps);
  21611. }
  21612. }
  21613. }
  21614. return null;
  21615. });
  21616. defineProperty_default()(this, "blockRendererFn", function (block) {
  21617. var customBlockRendererFn = _this.customBlockRendererFn,
  21618. superProps = _this.superProps;
  21619. var blockType = block.getType();
  21620. var blockRenderer = null;
  21621. if (customBlockRendererFn) {
  21622. blockRenderer = customBlockRendererFn(block, superProps) || null;
  21623. }
  21624. if (blockRenderer) {
  21625. return blockRenderer;
  21626. }
  21627. var extensionBlockRendererFns = getExtensionBlockRendererFns(superProps.editorId);
  21628. extensionBlockRendererFns.find(function (item) {
  21629. if (item.blockType === blockType || item.blockType instanceof RegExp && item.blockType.test(blockType)) {
  21630. blockRenderer = item.rendererFn ? item.rendererFn(superProps) : null;
  21631. return true;
  21632. }
  21633. });
  21634. if (blockRenderer) {
  21635. return blockRenderer;
  21636. }
  21637. if (blockType === 'atomic') {
  21638. blockRenderer = {
  21639. component: _this.renderAtomicBlock,
  21640. editable: false
  21641. };
  21642. }
  21643. return blockRenderer;
  21644. });
  21645. };
  21646. var blockRenderFnContext = new blockRendererFn_BlockRenderFnContext();
  21647. /* harmony default export */ var block_blockRendererFn = (blockRenderFnContext.getRenderFn);
  21648. // CONCATENATED MODULE: ./renderers/block/blockStyleFn.js
  21649. /* harmony default export */ var block_blockStyleFn = (function (customBlockStyleFn) {
  21650. return function (block) {
  21651. var blockAlignment = block.getData() && block.getData().get('textAlign');
  21652. var blockIndent = block.getData() && block.getData().get('textIndent');
  21653. var blockFloat = block.getData() && block.getData().get('float');
  21654. var result = '';
  21655. if (blockAlignment) {
  21656. result = "bfa-".concat(blockAlignment);
  21657. }
  21658. if (blockIndent && blockIndent !== 0) {
  21659. result += " bftd-".concat(blockIndent);
  21660. }
  21661. if (blockFloat) {
  21662. result += " bff-".concat(blockFloat);
  21663. }
  21664. if (customBlockStyleFn) {
  21665. result += customBlockStyleFn(block) || '';
  21666. }
  21667. return result;
  21668. };
  21669. });
  21670. // CONCATENATED MODULE: ./renderers/inline/inlineStyleMap.js
  21671. /* harmony default export */ var inlineStyleMap = (function (props) {
  21672. var customStyleMap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  21673. var extensionInlineStyleMap = getExtensionInlineStyleMap(props.editorId);
  21674. return objectSpread_default()({
  21675. 'SUPERSCRIPT': {
  21676. position: 'relative',
  21677. top: '-8px',
  21678. fontSize: '11px'
  21679. },
  21680. 'SUBSCRIPT': {
  21681. position: 'relative',
  21682. bottom: '-8px',
  21683. fontSize: '11px'
  21684. }
  21685. }, extensionInlineStyleMap, customStyleMap);
  21686. });
  21687. // CONCATENATED MODULE: ./renderers/inline/inlineStyleFn.js
  21688. var getStyleValue = function getStyleValue(style) {
  21689. return style.split('-')[1];
  21690. };
  21691. /* harmony default export */ var inlineStyleFn = (function (props, options) {
  21692. return function (styles, block) {
  21693. var output = {};
  21694. var fontFamilies = options.fontFamilies,
  21695. unitExportFn = options.unitExportFn,
  21696. customStyleFn = options.customStyleFn;
  21697. var extensionInlineStyleFns = getExtensionInlineStyleFns(props.editorId);
  21698. extensionInlineStyleFns.forEach(function (item) {
  21699. output = item.styleFn ? item.styleFn(styles, block, output) : output;
  21700. });
  21701. output = customStyleFn ? customStyleFn(styles, block, output) : {};
  21702. styles.forEach(function (style) {
  21703. if (style.indexOf('COLOR-') === 0) {
  21704. output.color = '#' + getStyleValue(style);
  21705. } else if (style.indexOf('BGCOLOR-') === 0) {
  21706. output.backgroundColor = '#' + getStyleValue(style);
  21707. } else if (style.indexOf('FONTSIZE-') === 0) {
  21708. output.fontSize = unitExportFn(getStyleValue(style), 'font-size', 'editor');
  21709. } else if (style.indexOf('LINEHEIGHT-') === 0) {
  21710. output.lineHeight = unitExportFn(getStyleValue(style), 'line-height', 'editor');
  21711. } else if (style.indexOf('LETTERSPACING-') === 0) {
  21712. output.letterSpacing = unitExportFn(getStyleValue(style), 'letter-spacing', 'editor');
  21713. } else if (style.indexOf('TEXTINDENT-') === 0) {
  21714. output.textIndent = unitExportFn(getStyleValue(style), 'text-indent', 'editor');
  21715. } else if (style.indexOf('FONTFAMILY-') === 0) {
  21716. output.fontFamily = (fontFamilies.find(function (item) {
  21717. return item.name.toUpperCase() === getStyleValue(style);
  21718. }) || {}).family || '';
  21719. }
  21720. });
  21721. return output;
  21722. };
  21723. });
  21724. // EXTERNAL MODULE: ../node_modules/draft-js-multidecorators/index.js
  21725. var draft_js_multidecorators = __webpack_require__(18);
  21726. var draft_js_multidecorators_default = /*#__PURE__*/__webpack_require__.n(draft_js_multidecorators);
  21727. // CONCATENATED MODULE: ./renderers/decorators/Link/index.jsx
  21728. /* harmony default export */ var Link = (function (props) {
  21729. var children = props.children,
  21730. entityKey = props.entityKey,
  21731. contentState = props.contentState;
  21732. var _contentState$getEnti = contentState.getEntity(entityKey).getData(),
  21733. href = _contentState$getEnti.href,
  21734. target = _contentState$getEnti.target;
  21735. return external_react_default.a.createElement("span", {
  21736. className: "bf-link-wrap"
  21737. }, external_react_default.a.createElement("a", {
  21738. onClick: function onClick(event) {
  21739. return viewLink(event, href);
  21740. },
  21741. className: "bf-link",
  21742. href: href,
  21743. target: target
  21744. }, children));
  21745. });
  21746. var viewLink = function viewLink(event, link) {
  21747. // 当按下Ctrl/command键时,点击打开链接文字中的url
  21748. if (event.getModifierState('Control') || event.getModifierState('Meta')) {
  21749. var tempLink = document.createElement('a');
  21750. tempLink.href = link;
  21751. tempLink.target = event.currentTarget.target;
  21752. tempLink.click();
  21753. }
  21754. };
  21755. // CONCATENATED MODULE: ./renderers/decorators/index.js
  21756. var KEY_SEPARATOR = '-';
  21757. draft_js_multidecorators_default.a.prototype.getDecorations = function (block, contentState) {
  21758. var decorations = Array(block.getText().length).fill(null);
  21759. this.decorators.forEach(function (decorator, i) {
  21760. decorator.getDecorations(block, contentState).forEach(function (key, offset) {
  21761. if (!key) {
  21762. return;
  21763. }
  21764. key = i + KEY_SEPARATOR + key;
  21765. decorations[offset] = key;
  21766. });
  21767. });
  21768. return external_immutable_default.a.List(decorations);
  21769. };
  21770. var builtinDecorators = [{
  21771. type: 'entity',
  21772. decorator: {
  21773. key: 'LINK',
  21774. component: Link
  21775. }
  21776. }];
  21777. var createStrategy = function createStrategy(type) {
  21778. return function (block, callback, contentState) {
  21779. block.findEntityRanges(function (character) {
  21780. var entityKey = character.getEntity();
  21781. return entityKey !== null && contentState.getEntity(entityKey).getType() === type;
  21782. }, callback);
  21783. };
  21784. };
  21785. /* harmony default export */ var decorators = (function (editorId) {
  21786. var extensionDecorators = getExtensionDecorators(editorId);
  21787. var entityDecorators = builtinDecorators.concat(toConsumableArray_default()(extensionDecorators.filter(function (item) {
  21788. return item.type === 'entity';
  21789. })));
  21790. var strategyDecorators = extensionDecorators.filter(function (item) {
  21791. return item.type === 'strategy';
  21792. });
  21793. var classDecorators = extensionDecorators.filter(function (item) {
  21794. return item.type === 'class';
  21795. });
  21796. return new draft_js_multidecorators_default.a(toConsumableArray_default()(classDecorators.map(function (item) {
  21797. return item.decorator;
  21798. })).concat([// combine decorators created with strategy
  21799. new external_draft_js_["CompositeDecorator"](strategyDecorators.map(function (item) {
  21800. return item.decorator;
  21801. })), // combine decorators for entities
  21802. new external_draft_js_["CompositeDecorator"](entityDecorators.map(function (item) {
  21803. return {
  21804. strategy: createStrategy(item.decorator.key),
  21805. component: item.decorator.component
  21806. };
  21807. }))]));
  21808. });
  21809. // CONCATENATED MODULE: ./renderers/index.js
  21810. var getBlockRenderMap = block_blockRenderMap;
  21811. var getBlockRendererFn = block_blockRendererFn;
  21812. var getBlockStyleFn = block_blockStyleFn;
  21813. var getCustomStyleMap = inlineStyleMap;
  21814. var getCustomStyleFn = inlineStyleFn;
  21815. var getDecorators = decorators;
  21816. // EXTERNAL MODULE: ./components/business/ControlBar/style.scss
  21817. var ControlBar_style = __webpack_require__(53);
  21818. // EXTERNAL MODULE: ./components/business/LinkEditor/style.scss
  21819. var LinkEditor_style = __webpack_require__(54);
  21820. // EXTERNAL MODULE: ./components/common/DropDown/style.scss
  21821. var DropDown_style = __webpack_require__(55);
  21822. // CONCATENATED MODULE: ./helpers/responsive.js
  21823. var resizeEventHandlers = [];
  21824. var responsiveHelperInited = false;
  21825. var debouce = false;
  21826. /* harmony default export */ var responsive = ({
  21827. resolve: function resolve(eventHandler) {
  21828. var id = external_braft_utils_["BaseUtils"].UniqueIndex();
  21829. resizeEventHandlers.push({
  21830. id: id,
  21831. eventHandler: eventHandler
  21832. });
  21833. return id;
  21834. },
  21835. unresolve: function unresolve(id) {
  21836. resizeEventHandlers = resizeEventHandlers.filter(function (item) {
  21837. return item.id !== id;
  21838. });
  21839. }
  21840. });
  21841. if (!responsiveHelperInited && (typeof window === "undefined" ? "undefined" : typeof_default()(window)) === 'object') {
  21842. window.addEventListener('resize', function (event) {
  21843. clearTimeout(debouce);
  21844. debouce = setTimeout(function () {
  21845. resizeEventHandlers.map(function (item) {
  21846. typeof item.eventHandler === 'function' && item.eventHandler(event);
  21847. });
  21848. debouce = false;
  21849. }, 100);
  21850. });
  21851. responsiveHelperInited = true;
  21852. }
  21853. // CONCATENATED MODULE: ./components/common/DropDown/index.jsx
  21854. var DropDown_DropDown =
  21855. /*#__PURE__*/
  21856. function (_React$Component) {
  21857. inherits_default()(DropDown, _React$Component);
  21858. function DropDown() {
  21859. var _getPrototypeOf2;
  21860. var _this;
  21861. classCallCheck_default()(this, DropDown);
  21862. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  21863. args[_key] = arguments[_key];
  21864. }
  21865. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(DropDown)).call.apply(_getPrototypeOf2, [this].concat(args)));
  21866. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "responsiveResolveId", null);
  21867. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownHandlerElement", null);
  21868. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownContentElement", null);
  21869. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  21870. active: false,
  21871. offset: 0
  21872. });
  21873. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "fixDropDownPosition", function () {
  21874. var viewRect = _this.props.getContainerNode().getBoundingClientRect();
  21875. var handlerRect = _this.dropDownHandlerElement.getBoundingClientRect();
  21876. var contentRect = _this.dropDownContentElement.getBoundingClientRect();
  21877. var offset = 0;
  21878. var right = handlerRect.right - handlerRect.width / 2 + contentRect.width / 2;
  21879. var left = handlerRect.left + handlerRect.width / 2 - contentRect.width / 2;
  21880. right = viewRect.right - right;
  21881. left = left - viewRect.left;
  21882. if (right < 10) {
  21883. offset = right - 10;
  21884. } else if (left < 10) {
  21885. offset = left * -1 + 10;
  21886. }
  21887. if (offset !== _this.state.offset) {
  21888. _this.setState({
  21889. offset: offset
  21890. });
  21891. }
  21892. });
  21893. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "registerClickEvent", function (event) {
  21894. var autoHide = _this.props.autoHide;
  21895. var active = _this.state.active;
  21896. if (_this.dropDownContentElement.contains(event.target) || _this.dropDownHandlerElement.contains(event.target)) {
  21897. return false;
  21898. }
  21899. autoHide && active && _this.hide();
  21900. });
  21901. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggle", function () {
  21902. _this.setState({
  21903. active: !_this.state.active
  21904. });
  21905. });
  21906. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "show", function () {
  21907. _this.setState({
  21908. active: true
  21909. });
  21910. });
  21911. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "hide", function () {
  21912. _this.setState({
  21913. active: false
  21914. });
  21915. });
  21916. return _this;
  21917. }
  21918. createClass_default()(DropDown, [{
  21919. key: "componentDidMount",
  21920. value: function componentDidMount() {
  21921. if (document) {
  21922. document.body.addEventListener('click', this.registerClickEvent);
  21923. this.responsiveResolveId = responsive.resolve(this.fixDropDownPosition);
  21924. }
  21925. }
  21926. }, {
  21927. key: "componentWillReceiveProps",
  21928. value: function componentWillReceiveProps(next) {
  21929. if (!this.props.disabled && next.disabled) {
  21930. this.hide();
  21931. }
  21932. }
  21933. }, {
  21934. key: "componentDidUpdate",
  21935. value: function componentDidUpdate(prevState) {
  21936. if (!prevState.active && this.state.active) {
  21937. this.fixDropDownPosition();
  21938. }
  21939. }
  21940. }, {
  21941. key: "componentWillUnmount",
  21942. value: function componentWillUnmount() {
  21943. if (document) {
  21944. document.body.removeEventListener('click', this.registerClickEvent);
  21945. responsive.unresolve(this.responsiveResolveId);
  21946. }
  21947. }
  21948. }, {
  21949. key: "render",
  21950. value: function render() {
  21951. var _this2 = this;
  21952. var _this$state = this.state,
  21953. active = _this$state.active,
  21954. offset = _this$state.offset;
  21955. var _this$props = this.props,
  21956. caption = _this$props.caption,
  21957. htmlCaption = _this$props.htmlCaption,
  21958. title = _this$props.title,
  21959. disabled = _this$props.disabled,
  21960. showArrow = _this$props.showArrow,
  21961. arrowActive = _this$props.arrowActive,
  21962. className = _this$props.className,
  21963. children = _this$props.children,
  21964. theme = _this$props.theme;
  21965. disabled && (active = false);
  21966. theme === 'light' && (className = ' light-theme ' + className);
  21967. return external_react_default.a.createElement("div", {
  21968. className: 'bf-dropdown ' + (active ? 'active ' : '') + (disabled ? 'disabled ' : '') + className
  21969. }, htmlCaption ? external_react_default.a.createElement("button", {
  21970. type: "button",
  21971. className: "dropdown-handler",
  21972. "data-title": title,
  21973. onClick: this.toggle,
  21974. dangerouslySetInnerHTML: htmlCaption ? {
  21975. __html: htmlCaption
  21976. } : null,
  21977. ref: function ref(instance) {
  21978. return _this2.dropDownHandlerElement = instance;
  21979. }
  21980. }) : external_react_default.a.createElement("button", {
  21981. type: "button",
  21982. className: "dropdown-handler",
  21983. "data-title": title,
  21984. onClick: this.toggle,
  21985. ref: function ref(instance) {
  21986. return _this2.dropDownHandlerElement = instance;
  21987. }
  21988. }, external_react_default.a.createElement("span", null, caption), showArrow !== false ? external_react_default.a.createElement("i", {
  21989. className: "bfi-drop-down"
  21990. }) : null), external_react_default.a.createElement("div", {
  21991. className: "dropdown-content",
  21992. style: {
  21993. marginLeft: offset
  21994. },
  21995. ref: function ref(instance) {
  21996. return _this2.dropDownContentElement = instance;
  21997. }
  21998. }, external_react_default.a.createElement("i", {
  21999. style: {
  22000. marginLeft: offset * -1
  22001. },
  22002. className: 'dropdown-arrow' + (arrowActive ? ' active' : '')
  22003. }), external_react_default.a.createElement("div", {
  22004. className: "dropdown-content-inner"
  22005. }, children)));
  22006. }
  22007. }]);
  22008. return DropDown;
  22009. }(external_react_default.a.Component);
  22010. // CONCATENATED MODULE: ./components/business/ControlGroup/index.jsx
  22011. /* harmony default export */ var ControlGroup = (function (props) {
  22012. if (external_react_default.a.Fragment) {
  22013. return external_react_default.a.createElement(external_react_default.a.Fragment, null, props.children);
  22014. } else {
  22015. return external_react_default.a.createElement("div", {
  22016. className: "control-item-group"
  22017. }, props.children);
  22018. }
  22019. });
  22020. // CONCATENATED MODULE: ./components/business/LinkEditor/index.jsx
  22021. var LinkEditor_LinkEditor =
  22022. /*#__PURE__*/
  22023. function (_React$Component) {
  22024. inherits_default()(LinkEditor, _React$Component);
  22025. function LinkEditor(props) {
  22026. var _this;
  22027. classCallCheck_default()(this, LinkEditor);
  22028. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(LinkEditor).call(this, props));
  22029. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "dropDownInstance", null);
  22030. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handeKeyDown", function (e) {
  22031. if (e.keyCode === 13) {
  22032. _this.handleConfirm();
  22033. e.preventDefault();
  22034. return false;
  22035. }
  22036. });
  22037. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleTnputText", function (e) {
  22038. _this.setState({
  22039. text: e.currentTarget.value
  22040. });
  22041. });
  22042. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleInputLink", function (e) {
  22043. _this.setState({
  22044. href: e.currentTarget.value
  22045. });
  22046. });
  22047. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setTarget", function () {
  22048. _this.setState({
  22049. target: _this.state.target === '_blank' ? '' : '_blank'
  22050. });
  22051. });
  22052. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCancel", function () {
  22053. _this.dropDownInstance.hide();
  22054. });
  22055. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleUnlink", function () {
  22056. _this.dropDownInstance.hide();
  22057. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, false));
  22058. });
  22059. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleConfirm", function () {
  22060. var _this$state = _this.state,
  22061. text = _this$state.text,
  22062. href = _this$state.href,
  22063. target = _this$state.target,
  22064. textSelected = _this$state.textSelected;
  22065. var hookReturns = _this.props.hooks('toggle-link', {
  22066. href: href,
  22067. target: target
  22068. })({
  22069. href: href,
  22070. target: target
  22071. });
  22072. _this.dropDownInstance.hide();
  22073. _this.props.editor.requestFocus();
  22074. if (hookReturns === false) {
  22075. return false;
  22076. }
  22077. if (hookReturns) {
  22078. typeof hookReturns.href === 'string' && (href = hookReturns.href);
  22079. typeof hookReturns.target === 'string' && (target = hookReturns.target);
  22080. }
  22081. if (textSelected) {
  22082. if (href) {
  22083. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, href, target));
  22084. } else {
  22085. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLink(_this.props.editorState, false));
  22086. }
  22087. } else {
  22088. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].insertText(_this.props.editorState, text || href, null, {
  22089. type: 'LINK',
  22090. data: {
  22091. href: href,
  22092. target: target
  22093. }
  22094. }));
  22095. }
  22096. });
  22097. _this.state = {
  22098. text: '',
  22099. href: '',
  22100. target: props.defaultLinkTarget || '',
  22101. textSelected: false
  22102. };
  22103. return _this;
  22104. }
  22105. createClass_default()(LinkEditor, [{
  22106. key: "componentWillReceiveProps",
  22107. value: function componentWillReceiveProps(nextProps) {
  22108. var _ContentUtils$getSele = external_braft_utils_["ContentUtils"].getSelectionEntityData(nextProps.editorState, 'LINK'),
  22109. href = _ContentUtils$getSele.href,
  22110. target = _ContentUtils$getSele.target;
  22111. var textSelected = !external_braft_utils_["ContentUtils"].isSelectionCollapsed(this.props.editorState) && external_braft_utils_["ContentUtils"].getSelectionBlockType(this.props.editorState) !== 'atomic';
  22112. var selectedText = '';
  22113. if (textSelected) {
  22114. selectedText = external_braft_utils_["ContentUtils"].getSelectionText(this.props.editorState);
  22115. }
  22116. this.setState({
  22117. textSelected: textSelected,
  22118. text: selectedText,
  22119. href: href || '',
  22120. target: typeof target === 'undefined' ? nextProps.defaultLinkTarget || '' : target || ''
  22121. });
  22122. }
  22123. }, {
  22124. key: "render",
  22125. value: function render() {
  22126. var _this2 = this;
  22127. var allowInsertLinkText = this.props.allowInsertLinkText;
  22128. var _this$state2 = this.state,
  22129. text = _this$state2.text,
  22130. href = _this$state2.href,
  22131. target = _this$state2.target,
  22132. textSelected = _this$state2.textSelected;
  22133. var caption = external_react_default.a.createElement("i", {
  22134. className: "bfi-link"
  22135. });
  22136. return external_react_default.a.createElement(ControlGroup, null, external_react_default.a.createElement(DropDown_DropDown, {
  22137. key: 0,
  22138. caption: caption,
  22139. title: this.props.language.controls.link,
  22140. autoHide: true,
  22141. getContainerNode: this.props.getContainerNode,
  22142. showArrow: false,
  22143. ref: function ref(instance) {
  22144. return _this2.dropDownInstance = instance;
  22145. },
  22146. className: 'control-item dropdown link-editor-dropdown'
  22147. }, external_react_default.a.createElement("div", {
  22148. className: "bf-link-editor"
  22149. }, allowInsertLinkText ? external_react_default.a.createElement("div", {
  22150. className: "input-group"
  22151. }, external_react_default.a.createElement("input", {
  22152. type: "text",
  22153. value: text,
  22154. spellCheck: false,
  22155. disabled: textSelected,
  22156. placeholder: this.props.language.linkEditor.textInputPlaceHolder,
  22157. onKeyDown: this.handeKeyDown,
  22158. onChange: this.handleTnputText
  22159. })) : null, external_react_default.a.createElement("div", {
  22160. className: "input-group"
  22161. }, external_react_default.a.createElement("input", {
  22162. type: "text",
  22163. value: href,
  22164. spellCheck: false,
  22165. placeholder: this.props.language.linkEditor.linkInputPlaceHolder,
  22166. onKeyDown: this.handeKeyDown,
  22167. onChange: this.handleInputLink
  22168. })), external_react_default.a.createElement("div", {
  22169. className: "switch-group"
  22170. }, external_react_default.a.createElement(Switch, {
  22171. active: target === '_blank',
  22172. onClick: this.setTarget
  22173. }), external_react_default.a.createElement("label", null, this.props.language.linkEditor.openInNewWindow)), external_react_default.a.createElement("div", {
  22174. className: "buttons"
  22175. }, external_react_default.a.createElement("a", {
  22176. onClick: this.handleUnlink,
  22177. className: "primary button-remove-link pull-left"
  22178. }, external_react_default.a.createElement("i", {
  22179. className: "bfi-close"
  22180. }), external_react_default.a.createElement("span", null, this.props.language.linkEditor.removeLink)), external_react_default.a.createElement("button", {
  22181. type: "button",
  22182. onClick: this.handleConfirm,
  22183. className: "primary pull-right"
  22184. }, this.props.language.base.confirm), external_react_default.a.createElement("button", {
  22185. type: "button",
  22186. onClick: this.handleCancel,
  22187. className: "default pull-right"
  22188. }, this.props.language.base.cancel)))), external_react_default.a.createElement("button", {
  22189. key: 1,
  22190. type: "button",
  22191. "data-title": this.props.language.controls.unlink,
  22192. className: "control-item button",
  22193. onClick: this.handleUnlink,
  22194. disabled: !textSelected || !href
  22195. }, external_react_default.a.createElement("i", {
  22196. className: "bfi-link-off"
  22197. })));
  22198. }
  22199. }]);
  22200. return LinkEditor;
  22201. }(external_react_default.a.Component);
  22202. // EXTERNAL MODULE: ./components/business/Headings/style.scss
  22203. var Headings_style = __webpack_require__(56);
  22204. // CONCATENATED MODULE: ./configs/maps.js
  22205. var maps_getHeadings = function getHeadings(lang) {
  22206. return [{
  22207. key: 'header-one',
  22208. title: lang.controls.header + ' 1',
  22209. text: external_react_default.a.createElement("h1", null, lang.controls.header, " 1"),
  22210. type: 'block-type',
  22211. command: 'header-one'
  22212. }, {
  22213. key: 'header-two',
  22214. title: lang.controls.header + ' 2',
  22215. text: external_react_default.a.createElement("h2", null, lang.controls.header, " 2"),
  22216. type: 'block-type',
  22217. command: 'header-two'
  22218. }, {
  22219. key: 'header-three',
  22220. title: lang.controls.header + ' 3',
  22221. text: external_react_default.a.createElement("h3", null, lang.controls.header, " 3"),
  22222. type: 'block-type',
  22223. command: 'header-three'
  22224. }, {
  22225. key: 'header-four',
  22226. title: lang.controls.header + ' 4',
  22227. text: external_react_default.a.createElement("h4", null, lang.controls.header, " 4"),
  22228. type: 'block-type',
  22229. command: 'header-four'
  22230. }, {
  22231. key: 'header-five',
  22232. title: lang.controls.header + ' 5',
  22233. text: external_react_default.a.createElement("h5", null, lang.controls.header, " 5"),
  22234. type: 'block-type',
  22235. command: 'header-five'
  22236. }, {
  22237. key: 'header-six',
  22238. title: lang.controls.header + ' 6',
  22239. text: external_react_default.a.createElement("h6", null, lang.controls.header, " 6"),
  22240. type: 'block-type',
  22241. command: 'header-six'
  22242. }, {
  22243. key: 'unstyled',
  22244. title: lang.controls.normal,
  22245. text: lang.controls.normal,
  22246. type: 'block-type',
  22247. command: 'unstyled'
  22248. }];
  22249. };
  22250. // CONCATENATED MODULE: ./components/business/Headings/index.jsx
  22251. /* harmony default export */ var Headings = (function (props) {
  22252. var dropDownInstance = null;
  22253. var headings = maps_getHeadings(props.language).filter(function (item) {
  22254. return props.headings.indexOf(item.key) !== -1;
  22255. });
  22256. var currentHeadingIndex = headings.findIndex(function (item) {
  22257. return item.command === props.current;
  22258. });
  22259. var caption = headings[currentHeadingIndex] ? headings[currentHeadingIndex].title : props.language.controls.normal;
  22260. return external_react_default.a.createElement(DropDown_DropDown, {
  22261. caption: caption,
  22262. autoHide: true,
  22263. getContainerNode: props.getContainerNode,
  22264. title: props.language.controls.headings,
  22265. arrowActive: currentHeadingIndex === 0,
  22266. ref: function ref(instance) {
  22267. return dropDownInstance = instance;
  22268. },
  22269. className: 'control-item dropdown headings-dropdown'
  22270. }, external_react_default.a.createElement("ul", {
  22271. className: "menu"
  22272. }, headings.map(function (item, index) {
  22273. var isActive = props.current === item.command;
  22274. return external_react_default.a.createElement("li", {
  22275. key: index,
  22276. className: 'menu-item' + (isActive ? ' active' : ''),
  22277. onClick: function onClick() {
  22278. props.onChange(item.command, item.type), dropDownInstance.hide();
  22279. }
  22280. }, item.text);
  22281. })));
  22282. });
  22283. // EXTERNAL MODULE: ./components/business/TextColor/style.scss
  22284. var TextColor_style = __webpack_require__(57);
  22285. // EXTERNAL MODULE: ./components/common/ColorPicker/style.scss
  22286. var ColorPicker_style = __webpack_require__(58);
  22287. // CONCATENATED MODULE: ./components/common/ColorPicker/index.jsx
  22288. /* harmony default export */ var common_ColorPicker = (function (props) {
  22289. return external_react_default.a.createElement("div", {
  22290. className: "bf-colors-wrap"
  22291. }, external_react_default.a.createElement("ul", {
  22292. className: "bf-colors"
  22293. }, props.presetColors.map(function (item, index) {
  22294. var className = props.color && item.toLowerCase() === props.color.toLowerCase() ? 'color-item active' : 'color-item';
  22295. return external_react_default.a.createElement("li", {
  22296. key: index,
  22297. title: item,
  22298. className: className,
  22299. style: {
  22300. color: item
  22301. },
  22302. "data-color": item.replace('#', ''),
  22303. onClick: function onClick(e) {
  22304. props.onChange(e.currentTarget.dataset.color, true);
  22305. }
  22306. });
  22307. })));
  22308. });
  22309. // CONCATENATED MODULE: ./components/business/TextColor/index.jsx
  22310. var TextColor_TextColor =
  22311. /*#__PURE__*/
  22312. function (_React$Component) {
  22313. inherits_default()(TextColor, _React$Component);
  22314. function TextColor() {
  22315. var _getPrototypeOf2;
  22316. var _this;
  22317. classCallCheck_default()(this, TextColor);
  22318. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  22319. args[_key] = arguments[_key];
  22320. }
  22321. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextColor)).call.apply(_getPrototypeOf2, [this].concat(args)));
  22322. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  22323. colorType: 'color'
  22324. });
  22325. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "switchColorType", function (_ref) {
  22326. var currentTarget = _ref.currentTarget;
  22327. _this.setState({
  22328. colorType: currentTarget.dataset.type
  22329. });
  22330. });
  22331. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleColor", function (color, closePicker) {
  22332. if (color) {
  22333. var hookReturns = _this.props.hooks("toggle-text-".concat(_this.state.colorType), color)(color);
  22334. if (hookReturns === false) {
  22335. return false;
  22336. }
  22337. if (typeof hookReturns === 'string') {
  22338. color = hookReturns;
  22339. }
  22340. if (_this.state.colorType === 'color') {
  22341. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionColor(_this.props.editorState, color));
  22342. } else {
  22343. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBackgroundColor(_this.props.editorState, color));
  22344. }
  22345. }
  22346. if (closePicker) {
  22347. _this.dropDownInstance.hide();
  22348. _this.props.editor.requestFocus();
  22349. }
  22350. });
  22351. return _this;
  22352. }
  22353. createClass_default()(TextColor, [{
  22354. key: "render",
  22355. value: function render() {
  22356. var _this2 = this;
  22357. var captionStyle = {};
  22358. var currentColor = null;
  22359. var colorType = this.state.colorType;
  22360. var selectionStyles = this.props.editorState.getCurrentInlineStyle().toJS();
  22361. selectionStyles.forEach(function (style) {
  22362. if (style.indexOf('COLOR-') === 0) {
  22363. captionStyle.color = '#' + style.split('-')[1];
  22364. colorType === 'color' && (currentColor = captionStyle.color);
  22365. }
  22366. if (style.indexOf('BGCOLOR-') === 0) {
  22367. captionStyle.backgroundColor = '#' + style.split('-')[1];
  22368. colorType === 'background-color' && (currentColor = captionStyle.backgroundColor);
  22369. }
  22370. });
  22371. var caption = external_react_default.a.createElement("i", {
  22372. style: captionStyle,
  22373. className: "bfi-text-color"
  22374. }, external_react_default.a.createElement("span", {
  22375. className: "path1"
  22376. }), external_react_default.a.createElement("span", {
  22377. className: "path2"
  22378. }));
  22379. var ColorPicker = this.props.colorPicker || common_ColorPicker;
  22380. return external_react_default.a.createElement(DropDown_DropDown, {
  22381. caption: caption,
  22382. title: this.props.language.controls.color,
  22383. showArrow: false,
  22384. autoHide: this.props.autoHide,
  22385. theme: this.props.theme,
  22386. getContainerNode: this.props.getContainerNode,
  22387. ref: function ref(instance) {
  22388. return _this2.dropDownInstance = instance;
  22389. },
  22390. className: 'control-item dropdown text-color-dropdown'
  22391. }, external_react_default.a.createElement("div", {
  22392. className: "bf-text-color-picker-wrap"
  22393. }, external_react_default.a.createElement("div", {
  22394. className: "bf-color-switch-buttons",
  22395. style: this.props.enableBackgroundColor ? {} : {
  22396. display: 'none'
  22397. }
  22398. }, external_react_default.a.createElement("button", {
  22399. type: "button",
  22400. "data-type": "color",
  22401. className: colorType === 'color' ? 'active' : '',
  22402. onClick: this.switchColorType
  22403. }, this.props.language.controls.textColor), external_react_default.a.createElement("button", {
  22404. type: "button",
  22405. "data-type": "background-color",
  22406. className: colorType === 'background-color' ? 'active' : '',
  22407. onClick: this.switchColorType
  22408. }, this.props.language.controls.backgroundColor)), external_react_default.a.createElement(ColorPicker, {
  22409. width: 200,
  22410. color: currentColor,
  22411. disableAlpha: true,
  22412. presetColors: this.props.colors,
  22413. onChange: this.toggleColor
  22414. })));
  22415. }
  22416. }]);
  22417. return TextColor;
  22418. }(external_react_default.a.Component);
  22419. // EXTERNAL MODULE: ./components/business/FontSize/style.scss
  22420. var FontSize_style = __webpack_require__(59);
  22421. // CONCATENATED MODULE: ./components/business/FontSize/index.jsx
  22422. var FontSize_toggleFontSize = function toggleFontSize(event, props) {
  22423. var fontSize = event.currentTarget.dataset.size;
  22424. var hookReturns = props.hooks('toggle-font-size', fontSize)(fontSize);
  22425. if (hookReturns === false) {
  22426. return false;
  22427. }
  22428. if (!isNaN(fontSize)) {
  22429. fontSize = hookReturns;
  22430. }
  22431. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionFontSize(props.editorState, fontSize));
  22432. props.editor.requestFocus();
  22433. };
  22434. /* harmony default export */ var FontSize = (function (props) {
  22435. var caption = null;
  22436. var currentFontSize = null;
  22437. var dropDownInstance = null;
  22438. props.fontSizes.find(function (item) {
  22439. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'FONTSIZE-' + item)) {
  22440. caption = item;
  22441. currentFontSize = item;
  22442. return true;
  22443. }
  22444. return false;
  22445. });
  22446. return external_react_default.a.createElement(DropDown_DropDown, {
  22447. autoHide: true,
  22448. caption: caption || props.defaultCaption,
  22449. getContainerNode: props.getContainerNode,
  22450. title: props.language.controls.fontSize,
  22451. ref: function ref(instance) {
  22452. return dropDownInstance = instance;
  22453. },
  22454. className: 'control-item dropdown bf-font-size-dropdown'
  22455. }, external_react_default.a.createElement("ul", {
  22456. className: "bf-font-sizes"
  22457. }, props.fontSizes.map(function (item, index) {
  22458. return external_react_default.a.createElement("li", {
  22459. key: index,
  22460. className: item === currentFontSize ? 'active' : null,
  22461. "data-size": item,
  22462. onClick: function onClick(event) {
  22463. FontSize_toggleFontSize(event, props), dropDownInstance.hide();
  22464. }
  22465. }, item);
  22466. })));
  22467. });
  22468. // EXTERNAL MODULE: ./components/business/LineHeight/style.scss
  22469. var LineHeight_style = __webpack_require__(60);
  22470. // CONCATENATED MODULE: ./components/business/LineHeight/index.jsx
  22471. var LineHeight_toggleLineHeight = function toggleLineHeight(event, props) {
  22472. var lineHeight = event.currentTarget.dataset.size;
  22473. var hookReturns = props.hooks('toggle-line-height', lineHeight)(lineHeight);
  22474. if (hookReturns === false) {
  22475. return false;
  22476. }
  22477. if (!isNaN(hookReturns)) {
  22478. lineHeight = hookReturns;
  22479. }
  22480. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLineHeight(props.editorState, lineHeight));
  22481. props.editor.requestFocus();
  22482. };
  22483. /* harmony default export */ var LineHeight = (function (props) {
  22484. var caption = null;
  22485. var currentLineHeight = null;
  22486. var dropDownInstance = null;
  22487. props.lineHeights.find(function (item) {
  22488. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'LINEHEIGHT-' + item)) {
  22489. caption = item;
  22490. currentLineHeight = item;
  22491. return true;
  22492. }
  22493. return false;
  22494. });
  22495. return external_react_default.a.createElement(DropDown_DropDown, {
  22496. autoHide: true,
  22497. caption: caption || props.defaultCaption,
  22498. getContainerNode: props.getContainerNode,
  22499. title: props.language.controls.lineHeight,
  22500. ref: function ref(instance) {
  22501. return dropDownInstance = instance;
  22502. },
  22503. className: 'control-item dropdown bf-line-height-dropdown'
  22504. }, external_react_default.a.createElement("ul", {
  22505. className: "bf-line-heights"
  22506. }, props.lineHeights.map(function (item, index) {
  22507. return external_react_default.a.createElement("li", {
  22508. key: index,
  22509. className: item === currentLineHeight ? 'active' : null,
  22510. "data-size": item,
  22511. onClick: function onClick(event) {
  22512. LineHeight_toggleLineHeight(event, props), dropDownInstance.hide();
  22513. }
  22514. }, item);
  22515. })));
  22516. });
  22517. // EXTERNAL MODULE: ./components/business/FontFamily/style.scss
  22518. var FontFamily_style = __webpack_require__(61);
  22519. // CONCATENATED MODULE: ./components/business/FontFamily/index.jsx
  22520. var FontFamily_toggleFontFamily = function toggleFontFamily(event, props) {
  22521. var fontFamilyName = event.currentTarget.dataset.name;
  22522. var hookReturns = props.hooks('toggle-font-family', fontFamilyName)(fontFamilyName, props.fontFamilies);
  22523. if (hookReturns === false) {
  22524. return false;
  22525. }
  22526. if (typeof hookReturns === 'string') {
  22527. fontFamilyName = hookReturns;
  22528. }
  22529. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionFontFamily(props.editorState, fontFamilyName));
  22530. props.editor.requestFocus();
  22531. };
  22532. /* harmony default export */ var FontFamily = (function (props) {
  22533. var caption = null;
  22534. var currentIndex = null;
  22535. var dropDownInstance = null;
  22536. props.fontFamilies.find(function (item, index) {
  22537. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'FONTFAMILY-' + item.name)) {
  22538. caption = item.name;
  22539. currentIndex = index;
  22540. return true;
  22541. }
  22542. return false;
  22543. });
  22544. return external_react_default.a.createElement(DropDown_DropDown, {
  22545. caption: caption || props.defaultCaption,
  22546. getContainerNode: props.getContainerNode,
  22547. title: props.language.controls.fontFamily,
  22548. autoHide: true,
  22549. arrowActive: currentIndex === 0,
  22550. ref: function ref(instance) {
  22551. return dropDownInstance = instance;
  22552. },
  22553. className: 'control-item dropdown font-family-dropdown'
  22554. }, external_react_default.a.createElement("ul", {
  22555. className: "menu"
  22556. }, props.fontFamilies.map(function (item, index) {
  22557. return external_react_default.a.createElement("li", {
  22558. key: index,
  22559. className: 'menu-item ' + (index === currentIndex ? 'active' : ''),
  22560. "data-name": item.name,
  22561. onClick: function onClick(event) {
  22562. FontFamily_toggleFontFamily(event, props), dropDownInstance.hide();
  22563. }
  22564. }, external_react_default.a.createElement("span", {
  22565. style: {
  22566. fontFamily: item.family
  22567. }
  22568. }, item.name));
  22569. })));
  22570. });
  22571. // CONCATENATED MODULE: ./components/business/TextAlign/index.jsx
  22572. var TextAlign_TextAlign =
  22573. /*#__PURE__*/
  22574. function (_React$Component) {
  22575. inherits_default()(TextAlign, _React$Component);
  22576. function TextAlign() {
  22577. var _getPrototypeOf2;
  22578. var _this;
  22579. classCallCheck_default()(this, TextAlign);
  22580. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  22581. args[_key] = arguments[_key];
  22582. }
  22583. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextAlign)).call.apply(_getPrototypeOf2, [this].concat(args)));
  22584. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  22585. currentAlignment: undefined
  22586. });
  22587. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setAlignment", function (event) {
  22588. var alignment = event.currentTarget.dataset.alignment;
  22589. var hookReturns = _this.props.hooks('toggle-text-alignment', alignment)(alignment);
  22590. if (_this.props.textAligns.indexOf(hookReturns) > -1) {
  22591. alignment = hookReturns;
  22592. }
  22593. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionAlignment(_this.props.editorState, alignment));
  22594. _this.props.editor.requestFocus();
  22595. });
  22596. return _this;
  22597. }
  22598. createClass_default()(TextAlign, [{
  22599. key: "componentWillReceiveProps",
  22600. value: function componentWillReceiveProps(next) {
  22601. this.setState({
  22602. currentAlignment: external_braft_utils_["ContentUtils"].getSelectionBlockData(next.editorState, 'textAlign')
  22603. });
  22604. }
  22605. }, {
  22606. key: "render",
  22607. value: function render() {
  22608. var _this2 = this;
  22609. var textAlignmentTitles = [this.props.language.controls.alignLeft, this.props.language.controls.alignCenter, this.props.language.controls.alignRight, this.props.language.controls.alignJustify];
  22610. return external_react_default.a.createElement(ControlGroup, null, this.props.textAligns.map(function (item, index) {
  22611. return external_react_default.a.createElement("button", {
  22612. type: "button",
  22613. key: index,
  22614. "data-title": textAlignmentTitles[index],
  22615. "data-alignment": item,
  22616. className: 'control-item button ' + (item === _this2.state.currentAlignment ? 'active' : null),
  22617. onClick: _this2.setAlignment
  22618. }, external_react_default.a.createElement("i", {
  22619. className: 'bfi-align-' + item
  22620. }));
  22621. }));
  22622. }
  22623. }]);
  22624. return TextAlign;
  22625. }(external_react_default.a.Component);
  22626. // EXTERNAL MODULE: ./components/business/EmojiPicker/style.scss
  22627. var EmojiPicker_style = __webpack_require__(62);
  22628. // CONCATENATED MODULE: ./components/business/EmojiPicker/index.jsx
  22629. var EmojiPicker_insertEmoji = function insertEmoji(event, props) {
  22630. var emoji = event.currentTarget.dataset.emoji;
  22631. var hookReturns = props.hooks('insert-emoji', emoji)(emoji);
  22632. if (hookReturns === false) {
  22633. return false;
  22634. }
  22635. if (typeof hookReturns === 'string') {
  22636. emoji = hookReturns;
  22637. }
  22638. props.editor.setValue(external_braft_utils_["ContentUtils"].insertText(props.editorState, emoji));
  22639. props.editor.requestFocus();
  22640. };
  22641. /* harmony default export */ var EmojiPicker = (function (props) {
  22642. return external_react_default.a.createElement(DropDown_DropDown, {
  22643. caption: props.defaultCaption,
  22644. autoHide: true,
  22645. showArrow: false,
  22646. getContainerNode: props.getContainerNode,
  22647. title: props.language.controls.emoji,
  22648. className: 'control-item dropdown bf-emoji-dropdown'
  22649. }, external_react_default.a.createElement("div", {
  22650. className: "bf-emojis-wrap"
  22651. }, external_react_default.a.createElement("ul", {
  22652. className: "bf-emojis"
  22653. }, props.emojis.map(function (item, index) {
  22654. return external_react_default.a.createElement("li", {
  22655. key: index,
  22656. "data-emoji": item,
  22657. onClick: function onClick(event) {
  22658. return EmojiPicker_insertEmoji(event, props);
  22659. }
  22660. }, item);
  22661. }))));
  22662. });
  22663. // EXTERNAL MODULE: ./components/business/LetterSpacing/style.scss
  22664. var LetterSpacing_style = __webpack_require__(63);
  22665. // CONCATENATED MODULE: ./components/business/LetterSpacing/index.jsx
  22666. var LetterSpacing_toggleLetterSpacing = function toggleLetterSpacing(event, props) {
  22667. var letterSpacing = event.currentTarget.dataset.size;
  22668. var hookReturns = props.hooks('toggle-letter-spacing', letterSpacing)(letterSpacing);
  22669. if (hookReturns === false) {
  22670. return false;
  22671. }
  22672. if (!isNaN(hookReturns)) {
  22673. letterSpacing = hookReturns;
  22674. }
  22675. props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionLetterSpacing(props.editorState, letterSpacing));
  22676. props.editor.requestFocus();
  22677. };
  22678. /* harmony default export */ var LetterSpacing = (function (props) {
  22679. var caption = null;
  22680. var currentLetterSpacing = null;
  22681. var dropDownInstance = null;
  22682. props.letterSpacings.find(function (item) {
  22683. if (external_braft_utils_["ContentUtils"].selectionHasInlineStyle(props.editorState, 'LETTERSPACING-' + item)) {
  22684. caption = item;
  22685. currentLetterSpacing = item;
  22686. return true;
  22687. }
  22688. return false;
  22689. });
  22690. return external_react_default.a.createElement(DropDown_DropDown, {
  22691. autoHide: true,
  22692. caption: caption || props.defaultCaption,
  22693. getContainerNode: props.getContainerNode,
  22694. title: props.language.controls.letterSpacing,
  22695. ref: function ref(instance) {
  22696. return dropDownInstance = instance;
  22697. },
  22698. className: 'control-item dropdown bf-letter-spacing-dropdown'
  22699. }, external_react_default.a.createElement("ul", {
  22700. className: "bf-letter-spacings"
  22701. }, props.letterSpacings.map(function (item, index) {
  22702. return external_react_default.a.createElement("li", {
  22703. key: index,
  22704. className: item === currentLetterSpacing ? 'active' : null,
  22705. "data-size": item,
  22706. onClick: function onClick(event) {
  22707. LetterSpacing_toggleLetterSpacing(event, props), dropDownInstance.hide();
  22708. }
  22709. }, item);
  22710. })));
  22711. });
  22712. // CONCATENATED MODULE: ./components/business/TextIndent/index.jsx
  22713. var TextIndent_TextAlign =
  22714. /*#__PURE__*/
  22715. function (_React$Component) {
  22716. inherits_default()(TextAlign, _React$Component);
  22717. function TextAlign() {
  22718. var _getPrototypeOf2;
  22719. var _this;
  22720. classCallCheck_default()(this, TextAlign);
  22721. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  22722. args[_key] = arguments[_key];
  22723. }
  22724. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(TextAlign)).call.apply(_getPrototypeOf2, [this].concat(args)));
  22725. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "state", {
  22726. currentIndent: 0
  22727. });
  22728. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "increaseIndent", function () {
  22729. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].increaseSelectionIndent(_this.props.editorState));
  22730. _this.props.editor.requestFocus();
  22731. });
  22732. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "decreaseIndent", function () {
  22733. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].decreaseSelectionIndent(_this.props.editorState));
  22734. _this.props.editor.requestFocus();
  22735. });
  22736. return _this;
  22737. }
  22738. createClass_default()(TextAlign, [{
  22739. key: "componentWillReceiveProps",
  22740. value: function componentWillReceiveProps(nextProps) {
  22741. this.setState({
  22742. currentIndent: external_braft_utils_["ContentUtils"].getSelectionBlockData(nextProps.editorState, 'textIndent') || 0
  22743. });
  22744. }
  22745. }, {
  22746. key: "render",
  22747. value: function render() {
  22748. var currentIndent = this.state.currentIndent;
  22749. var language = this.props.language;
  22750. return external_react_default.a.createElement(ControlGroup, null, external_react_default.a.createElement("button", {
  22751. key: 0,
  22752. type: "button",
  22753. "data-title": language.controls.increaseIndent,
  22754. disabled: currentIndent >= 6,
  22755. className: "control-item button button-indent-increase".concat(currentIndent > 0 && currentIndent < 6 ? ' active' : ''),
  22756. onClick: this.increaseIndent
  22757. }, external_react_default.a.createElement("i", {
  22758. className: 'bfi-indent-increase'
  22759. })), external_react_default.a.createElement("button", {
  22760. key: 1,
  22761. type: "button",
  22762. "data-title": language.controls.decreaseIndent,
  22763. disabled: currentIndent <= 0,
  22764. className: "control-item button button-indent-decrease",
  22765. onClick: this.decreaseIndent
  22766. }, external_react_default.a.createElement("i", {
  22767. className: 'bfi-indent-decrease'
  22768. })));
  22769. }
  22770. }]);
  22771. return TextAlign;
  22772. }(external_react_default.a.Component);
  22773. // CONCATENATED MODULE: ./components/business/ControlBar/index.jsx
  22774. var commandHookMap = {
  22775. 'inline-style': 'toggle-inline-style',
  22776. 'block-type': 'change-block-type',
  22777. 'editor-method': 'exec-editor-command'
  22778. };
  22779. var exclusiveInlineStyles = {
  22780. 'superscript': 'subscript',
  22781. 'subscript': 'superscript'
  22782. };
  22783. var mergeControls = function mergeControls(commonProps, builtControls, extensionControls, extendControls) {
  22784. extensionControls = extensionControls.map(function (item) {
  22785. return typeof item === 'function' ? item(commonProps) : item;
  22786. });
  22787. extendControls = extendControls.map(function (item) {
  22788. return typeof item === 'function' ? item(commonProps) : item;
  22789. });
  22790. if (extensionControls.length === 0 && extendControls.length === 0) {
  22791. return builtControls;
  22792. }
  22793. return builtControls.map(function (item) {
  22794. return extendControls.find(function (subItem) {
  22795. return subItem.replace === (item.key || item);
  22796. }) || extensionControls.find(function (subItem) {
  22797. return subItem.replace === (item.key || item);
  22798. }) || item;
  22799. }).concat(extensionControls.length ? 'separator' : '').concat(extensionControls.filter(function (item) {
  22800. return !item.replace;
  22801. })).concat(extendControls.filter(function (item) {
  22802. return typeof item === 'string' || !item.replace;
  22803. }));
  22804. };
  22805. var ControlBar_ControlBar =
  22806. /*#__PURE__*/
  22807. function (_React$Component) {
  22808. inherits_default()(ControlBar, _React$Component);
  22809. function ControlBar() {
  22810. var _getPrototypeOf2;
  22811. var _this;
  22812. classCallCheck_default()(this, ControlBar);
  22813. for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
  22814. args[_key] = arguments[_key];
  22815. }
  22816. _this = possibleConstructorReturn_default()(this, (_getPrototypeOf2 = getPrototypeOf_default()(ControlBar)).call.apply(_getPrototypeOf2, [this].concat(args)));
  22817. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "allControls", []);
  22818. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "mediaLibiraryModal", null);
  22819. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "extendedModals", {});
  22820. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "openBraftFinder", function () {
  22821. if (!_this.props.braftFinder || !_this.props.braftFinder.ReactComponent) {
  22822. return false;
  22823. }
  22824. if (_this.props.hooks('open-braft-finder')() === false) {
  22825. return false;
  22826. }
  22827. var mediaProps = _this.props.media;
  22828. var MediaLibrary = _this.props.braftFinder.ReactComponent;
  22829. _this.mediaLibiraryModal = Modal_showModal({
  22830. title: _this.props.language.controls.mediaLibirary,
  22831. language: _this.props.language,
  22832. width: 640,
  22833. showFooter: false,
  22834. component: external_react_default.a.createElement(MediaLibrary, {
  22835. accepts: mediaProps.accepts,
  22836. onCancel: _this.closeBraftFinder,
  22837. onInsert: _this.insertMedias,
  22838. onChange: mediaProps.onChange,
  22839. externals: mediaProps.externals,
  22840. onBeforeSelect: _this.bindBraftFinderHook('select-medias'),
  22841. onBeforeDeselect: _this.bindBraftFinderHook('deselect-medias'),
  22842. onBeforeRemove: _this.bindBraftFinderHook('remove-medias'),
  22843. onBeforeInsert: _this.bindBraftFinderHook('insert-medias'),
  22844. onFileSelect: _this.bindBraftFinderHook('select-files')
  22845. })
  22846. });
  22847. });
  22848. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "bindBraftFinderHook", function (hookName) {
  22849. return function () {
  22850. return _this.props.hooks(hookName, arguments.length <= 0 ? undefined : arguments[0]).apply(void 0, arguments);
  22851. };
  22852. });
  22853. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "insertMedias", function (medias) {
  22854. _this.props.editor.setValue(external_braft_utils_["ContentUtils"].insertMedias(_this.props.editorState, medias));
  22855. _this.props.editor.requestFocus();
  22856. _this.props.media.onInsert && _this.props.media.onInsert(medias);
  22857. _this.closeBraftFinder();
  22858. });
  22859. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "closeBraftFinder", function () {
  22860. _this.props.media.onCancel && _this.props.media.onCancel();
  22861. _this.mediaLibiraryModal && _this.mediaLibiraryModal.close();
  22862. });
  22863. return _this;
  22864. }
  22865. createClass_default()(ControlBar, [{
  22866. key: "componentDidUpdate",
  22867. value: function componentDidUpdate() {
  22868. var _this2 = this;
  22869. var language = this.props.language;
  22870. this.allControls.forEach(function (item) {
  22871. if (item.type === 'modal') {
  22872. if (item.modal && item.modal.id && _this2.extendedModals[item.modal.id]) {
  22873. _this2.extendedModals[item.modal.id].update(objectSpread_default()({}, item.modal, {
  22874. language: language
  22875. }));
  22876. }
  22877. }
  22878. });
  22879. }
  22880. }, {
  22881. key: "getControlItemClassName",
  22882. value: function getControlItemClassName(data) {
  22883. var className = 'control-item button';
  22884. var type = data.type,
  22885. command = data.command;
  22886. if (type === 'inline-style' && external_braft_utils_["ContentUtils"].selectionHasInlineStyle(this.props.editorState, command)) {
  22887. className += ' active';
  22888. } else if (type === 'block-type' && external_braft_utils_["ContentUtils"].getSelectionBlockType(this.props.editorState) === command) {
  22889. className += ' active';
  22890. } else if (type === 'entity' && external_braft_utils_["ContentUtils"].getSelectionEntityType(this.props.editorState) === command) {
  22891. className += ' active';
  22892. }
  22893. return className;
  22894. }
  22895. }, {
  22896. key: "applyControl",
  22897. value: function applyControl(command, type) {
  22898. var data = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  22899. var hookReturns = this.props.hooks(commandHookMap[type] || type, command)(command);
  22900. var editorState = this.props.editorState;
  22901. if (hookReturns === false) {
  22902. return false;
  22903. }
  22904. if (typeof hookReturns === 'string') {
  22905. command = hookReturns;
  22906. }
  22907. if (type === 'inline-style') {
  22908. var exclusiveInlineStyle = exclusiveInlineStyles[command];
  22909. if (exclusiveInlineStyle && external_braft_utils_["ContentUtils"].selectionHasInlineStyle(editorState, exclusiveInlineStyle)) {
  22910. editorState = external_braft_utils_["ContentUtils"].toggleSelectionInlineStyle(editorState, exclusiveInlineStyle);
  22911. }
  22912. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionInlineStyle(editorState, command));
  22913. } else if (type === 'block-type') {
  22914. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionBlockType(editorState, command));
  22915. } else if (type === 'entity') {
  22916. this.props.editor.setValue(external_braft_utils_["ContentUtils"].toggleSelectionEntity(editorState, {
  22917. type: command,
  22918. mutability: data.mutability || 'MUTABLE',
  22919. data: data.data || {}
  22920. }));
  22921. } else if (type === 'editor-method') {
  22922. this.props.editor[command] && this.props.editor[command]();
  22923. }
  22924. }
  22925. }, {
  22926. key: "render",
  22927. value: function render() {
  22928. var _this3 = this;
  22929. var _this$props = this.props,
  22930. editor = _this$props.editor,
  22931. editorId = _this$props.editorId,
  22932. editorState = _this$props.editorState,
  22933. className = _this$props.className,
  22934. style = _this$props.style,
  22935. controls = _this$props.controls,
  22936. media = _this$props.media,
  22937. extendControls = _this$props.extendControls,
  22938. language = _this$props.language,
  22939. hooks = _this$props.hooks,
  22940. colors = _this$props.colors,
  22941. colorPicker = _this$props.colorPicker,
  22942. colorPickerTheme = _this$props.colorPickerTheme,
  22943. colorPickerAutoHide = _this$props.colorPickerAutoHide,
  22944. headings = _this$props.headings,
  22945. fontSizes = _this$props.fontSizes,
  22946. fontFamilies = _this$props.fontFamilies,
  22947. emojis = _this$props.emojis,
  22948. getContainerNode = _this$props.getContainerNode,
  22949. lineHeights = _this$props.lineHeights,
  22950. letterSpacings = _this$props.letterSpacings,
  22951. textAligns = _this$props.textAligns,
  22952. textBackgroundColor = _this$props.textBackgroundColor,
  22953. allowInsertLinkText = _this$props.allowInsertLinkText,
  22954. defaultLinkTarget = _this$props.defaultLinkTarget;
  22955. var currentBlockType = external_braft_utils_["ContentUtils"].getSelectionBlockType(editorState);
  22956. var commonProps = {
  22957. editor: editor,
  22958. editorId: editorId,
  22959. editorState: editorState,
  22960. language: language,
  22961. getContainerNode: getContainerNode,
  22962. hooks: hooks
  22963. };
  22964. var renderedControls = [];
  22965. var editorControls = configs_controls(language, editor);
  22966. var extensionControls = getExtensionControls(editorId);
  22967. var allControls = mergeControls(commonProps, controls, extensionControls, extendControls);
  22968. this.allControls = allControls;
  22969. return external_react_default.a.createElement("div", {
  22970. className: "bf-controlbar ".concat(className || ''),
  22971. style: style,
  22972. onMouseDown: this.preventDefault
  22973. }, allControls.map(function (item, index) {
  22974. var itemKey = typeof item === 'string' ? item : item.key;
  22975. if (typeof itemKey !== 'string') {
  22976. return null;
  22977. }
  22978. if (renderedControls.indexOf(itemKey) > -1) {
  22979. return null;
  22980. }
  22981. if (itemKey.toLowerCase() === 'separator') {
  22982. return external_react_default.a.createElement("span", {
  22983. key: index,
  22984. className: "separator-line"
  22985. });
  22986. }
  22987. var controlItem = editorControls.find(function (subItem) {
  22988. return subItem.key.toLowerCase() === itemKey.toLowerCase();
  22989. });
  22990. if (typeof item !== 'string') {
  22991. controlItem = objectSpread_default()({}, controlItem, item);
  22992. }
  22993. if (!controlItem) {
  22994. return null;
  22995. }
  22996. renderedControls.push(itemKey);
  22997. if (controlItem.type === 'headings') {
  22998. return external_react_default.a.createElement(Headings, extends_default()({
  22999. key: index,
  23000. headings: headings,
  23001. current: currentBlockType,
  23002. onChange: function onChange(command) {
  23003. return _this3.applyControl(command, 'block-type');
  23004. }
  23005. }, commonProps));
  23006. } else if (controlItem.type === 'text-color') {
  23007. return external_react_default.a.createElement(TextColor_TextColor, extends_default()({
  23008. key: index,
  23009. colors: colors,
  23010. colorPicker: colorPicker,
  23011. theme: colorPickerTheme,
  23012. autoHide: colorPickerAutoHide,
  23013. enableBackgroundColor: textBackgroundColor
  23014. }, commonProps));
  23015. } else if (controlItem.type === 'font-size') {
  23016. return external_react_default.a.createElement(FontSize, extends_default()({
  23017. key: index,
  23018. fontSizes: fontSizes,
  23019. defaultCaption: controlItem.title
  23020. }, commonProps));
  23021. } else if (controlItem.type === 'line-height') {
  23022. return external_react_default.a.createElement(LineHeight, extends_default()({
  23023. key: index,
  23024. lineHeights: lineHeights,
  23025. defaultCaption: controlItem.title
  23026. }, commonProps));
  23027. } else if (controlItem.type === 'letter-spacing') {
  23028. return external_react_default.a.createElement(LetterSpacing, extends_default()({
  23029. key: index,
  23030. letterSpacings: letterSpacings,
  23031. defaultCaption: controlItem.title
  23032. }, commonProps));
  23033. } else if (controlItem.type === 'text-indent') {
  23034. return external_react_default.a.createElement(TextIndent_TextAlign, extends_default()({
  23035. key: index,
  23036. defaultCaption: controlItem.title
  23037. }, commonProps));
  23038. } else if (controlItem.type === 'font-family') {
  23039. return external_react_default.a.createElement(FontFamily, extends_default()({
  23040. key: index,
  23041. fontFamilies: fontFamilies,
  23042. defaultCaption: controlItem.title
  23043. }, commonProps));
  23044. } else if (controlItem.type === 'emoji') {
  23045. return external_react_default.a.createElement(EmojiPicker, extends_default()({
  23046. key: index,
  23047. emojis: emojis,
  23048. defaultCaption: controlItem.text
  23049. }, commonProps));
  23050. } else if (controlItem.type === 'link') {
  23051. return external_react_default.a.createElement(LinkEditor_LinkEditor, extends_default()({
  23052. key: index,
  23053. defaultLinkTarget: defaultLinkTarget,
  23054. allowInsertLinkText: allowInsertLinkText
  23055. }, commonProps));
  23056. } else if (controlItem.type === 'text-align') {
  23057. return external_react_default.a.createElement(TextAlign_TextAlign, extends_default()({
  23058. key: index,
  23059. textAligns: textAligns
  23060. }, commonProps));
  23061. } else if (controlItem.type === 'media') {
  23062. if (!media.image && !media.video && !media.audio) {
  23063. return null;
  23064. }
  23065. return external_react_default.a.createElement("button", {
  23066. type: "button",
  23067. key: index,
  23068. "data-title": controlItem.title,
  23069. disabled: controlItem.disabled,
  23070. className: "control-item media button",
  23071. onClick: _this3.openBraftFinder
  23072. }, controlItem.text);
  23073. } else if (controlItem.type === 'dropdown') {
  23074. return external_react_default.a.createElement(DropDown_DropDown, extends_default()({
  23075. key: index,
  23076. className: "control-item extend-control-item dropdown ".concat(controlItem.className || ''),
  23077. caption: controlItem.text,
  23078. htmlCaption: controlItem.html,
  23079. showArrow: controlItem.showArrow,
  23080. title: controlItem.title,
  23081. arrowActive: controlItem.arrowActive,
  23082. theme: controlItem.theme,
  23083. autoHide: controlItem.autoHide,
  23084. disabled: controlItem.disabled,
  23085. ref: controlItem.ref
  23086. }, commonProps), controlItem.component);
  23087. } else if (controlItem.type === 'modal') {
  23088. return external_react_default.a.createElement("button", {
  23089. type: "button",
  23090. key: index,
  23091. "data-title": controlItem.title,
  23092. disabled: controlItem.disabled,
  23093. className: "control-item extend-control-item button ".concat(controlItem.className || ''),
  23094. dangerouslySetInnerHTML: controlItem.html ? {
  23095. __html: controlItem.html
  23096. } : null,
  23097. onClick: function onClick(event) {
  23098. if (controlItem.modal && controlItem.modal.id) {
  23099. if (_this3.extendedModals[controlItem.modal.id]) {
  23100. _this3.extendedModals[controlItem.modal.id].active = true;
  23101. _this3.extendedModals[controlItem.modal.id].update(objectSpread_default()({}, controlItem.modal, {
  23102. language: language
  23103. }));
  23104. } else {
  23105. _this3.extendedModals[controlItem.modal.id] = Modal_showModal(objectSpread_default()({}, controlItem.modal, {
  23106. language: language
  23107. }));
  23108. controlItem.modal.onCreate && controlItem.modal.onCreate(_this3.extendedModals[controlItem.modal.id]);
  23109. }
  23110. }
  23111. controlItem.onClick && controlItem.onClick(event);
  23112. }
  23113. }, !controlItem.html ? controlItem.text : null);
  23114. } else if (controlItem.type === 'component') {
  23115. return external_react_default.a.createElement("div", {
  23116. key: index,
  23117. className: "component-wrapper ".concat(controlItem.className || '')
  23118. }, controlItem.component);
  23119. } else if (controlItem.type === 'button') {
  23120. return external_react_default.a.createElement("button", {
  23121. type: "button",
  23122. key: index,
  23123. "data-title": controlItem.title,
  23124. disabled: controlItem.disabled,
  23125. className: "control-item button ".concat(controlItem.className || ''),
  23126. dangerouslySetInnerHTML: controlItem.html ? {
  23127. __html: controlItem.html
  23128. } : null,
  23129. onClick: function onClick(event) {
  23130. return controlItem.onClick && controlItem.onClick(event);
  23131. }
  23132. }, !controlItem.html ? controlItem.text : null);
  23133. } else if (controlItem) {
  23134. var disabled = false;
  23135. if (controlItem.command === 'undo') {
  23136. disabled = editorState.getUndoStack().size === 0;
  23137. } else if (controlItem.command === 'redo') {
  23138. disabled = editorState.getRedoStack().size === 0;
  23139. }
  23140. return external_react_default.a.createElement("button", {
  23141. type: "button",
  23142. key: index,
  23143. disabled: disabled,
  23144. "data-title": controlItem.title,
  23145. className: _this3.getControlItemClassName({
  23146. type: controlItem.type,
  23147. command: controlItem.command
  23148. }),
  23149. onClick: function onClick() {
  23150. return _this3.applyControl(controlItem.command, controlItem.type, controlItem.data);
  23151. }
  23152. }, controlItem.text);
  23153. }
  23154. }));
  23155. }
  23156. }, {
  23157. key: "preventDefault",
  23158. value: function preventDefault(event) {
  23159. var tagName = event.target.tagName.toLowerCase();
  23160. if (tagName === 'input' || tagName === 'label') ; else {
  23161. event.preventDefault();
  23162. }
  23163. }
  23164. }]);
  23165. return ControlBar;
  23166. }(external_react_default.a.Component);
  23167. // CONCATENATED MODULE: ./editor/index.jsx
  23168. var buildHooks = function buildHooks(hooks) {
  23169. return function (hookName) {
  23170. var defaultReturns = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  23171. return hooks[hookName] || function () {
  23172. return defaultReturns;
  23173. };
  23174. };
  23175. };
  23176. var filterColors = function filterColors(colors, colors2) {
  23177. return colors.filter(function (item) {
  23178. return !colors2.find(function (color) {
  23179. return color.toLowerCase() === item.toLowerCase();
  23180. });
  23181. }).filter(function (item, index, array) {
  23182. return array.indexOf(item) === index;
  23183. });
  23184. };
  23185. var editor_isControlEnabled = function isControlEnabled(props, controlName) {
  23186. return toConsumableArray_default()(props.controls).concat(toConsumableArray_default()(props.extendControls)).find(function (item) {
  23187. return item === controlName || item.key === controlName;
  23188. }) && props.excludeControls.indexOf(controlName) === -1;
  23189. };
  23190. var editor_getConvertOptions = function getConvertOptions(props) {
  23191. var editorId = props.editorId || props.id;
  23192. var convertOptions = objectSpread_default()({}, configs_props.converts, props.converts, {
  23193. fontFamilies: props.fontFamilies
  23194. });
  23195. convertOptions.styleImportFn = compositeStyleImportFn(convertOptions.styleImportFn, editorId);
  23196. convertOptions.styleExportFn = compositeStyleExportFn(convertOptions.styleExportFn, editorId);
  23197. convertOptions.entityImportFn = compositeEntityImportFn(convertOptions.entityImportFn, editorId);
  23198. convertOptions.entityExportFn = compositeEntityExportFn(convertOptions.entityExportFn, editorId);
  23199. convertOptions.blockImportFn = compositeBlockImportFn(convertOptions.blockImportFn, editorId);
  23200. convertOptions.blockExportFn = compositeBlockExportFn(convertOptions.blockExportFn, editorId);
  23201. return convertOptions;
  23202. };
  23203. var editor_BraftEditor =
  23204. /*#__PURE__*/
  23205. function (_React$Component) {
  23206. inherits_default()(BraftEditor, _React$Component);
  23207. function BraftEditor(props) {
  23208. var _this;
  23209. classCallCheck_default()(this, BraftEditor);
  23210. _this = possibleConstructorReturn_default()(this, getPrototypeOf_default()(BraftEditor).call(this, props));
  23211. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onChange", function (editorState, callback) {
  23212. if (!(editorState instanceof external_draft_js_["EditorState"])) {
  23213. editorState = external_draft_js_["EditorState"].set(editorState, {
  23214. decorator: _this.editorDecorators
  23215. });
  23216. }
  23217. if (!editorState.convertOptions) {
  23218. editorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  23219. }
  23220. _this.setState({
  23221. editorState: editorState
  23222. }, function () {
  23223. _this.props.onChange && _this.props.onChange(editorState);
  23224. callback && callback(editorState);
  23225. });
  23226. });
  23227. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getDraftInstance", function () {
  23228. return _this.draftInstance;
  23229. });
  23230. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getFinderInstance", function () {
  23231. return _this.braftFinder;
  23232. });
  23233. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "getValue", function () {
  23234. return _this.state.editorState;
  23235. });
  23236. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setValue", function (editorState, callback) {
  23237. return _this.onChange(editorState, callback);
  23238. });
  23239. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "forceRender", function () {
  23240. var selectionState = _this.state.editorState.getSelection();
  23241. _this.setValue(external_draft_js_["EditorState"].set(_this.state.editorState, {
  23242. decorator: _this.editorDecorators
  23243. }), function () {
  23244. _this.setValue(external_draft_js_["EditorState"].forceSelection(_this.state.editorState, selectionState));
  23245. });
  23246. });
  23247. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onTab", function (event) {
  23248. if (handlers_keyCommandHandlers('tab', _this.state.editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this))) === 'handled') {
  23249. event.preventDefault();
  23250. }
  23251. _this.editorProps.onTab && _this.editorProps.onTab(event);
  23252. });
  23253. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onFocus", function () {
  23254. _this.isFocused = true;
  23255. _this.editorProps.onFocus && _this.editorProps.onFocus(_this.state.editorState);
  23256. });
  23257. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "onBlur", function () {
  23258. _this.isFocused = false;
  23259. _this.editorProps.onBlur && _this.editorProps.onBlur(_this.state.editorState);
  23260. });
  23261. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "requestFocus", function () {
  23262. setTimeout(function () {
  23263. return _this.draftInstance.focus();
  23264. }, 0);
  23265. });
  23266. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleKeyCommand", function (command, editorState) {
  23267. return handlers_keyCommandHandlers(command, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23268. });
  23269. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleReturn", function (event, editorState) {
  23270. return handlers_returnHandlers(event, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23271. });
  23272. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleBeforeInput", function (chars, editorState) {
  23273. return beforeInputHandlers(chars, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23274. });
  23275. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDrop", function (selectionState, dataTransfer) {
  23276. return handlers_dropHandlers(selectionState, dataTransfer, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23277. });
  23278. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleDroppedFiles", function (selectionState, files) {
  23279. return droppedFilesHandlers(selectionState, files, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23280. });
  23281. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handlePastedFiles", function (files) {
  23282. return pastedFilesHandlers(files, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23283. });
  23284. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCopyContent", function (event) {
  23285. return handlers_copyHandlers(event, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23286. });
  23287. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handlePastedText", function (text, html, editorState) {
  23288. return handlers_pastedTextHandlers(text, html, editorState, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23289. });
  23290. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "handleCompositionStart", function (event) {
  23291. return handlers_compositionStartHandler(event, assertThisInitialized_default()(assertThisInitialized_default()(_this)));
  23292. });
  23293. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "undo", function () {
  23294. _this.setValue(external_braft_utils_["ContentUtils"].undo(_this.state.editorState));
  23295. });
  23296. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "redo", function () {
  23297. _this.setValue(external_braft_utils_["ContentUtils"].redo(_this.state.editorState));
  23298. });
  23299. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "removeSelectionInlineStyles", function () {
  23300. _this.setValue(external_braft_utils_["ContentUtils"].removeSelectionInlineStyles(_this.state.editorState));
  23301. });
  23302. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "insertHorizontalLine", function () {
  23303. _this.setValue(external_braft_utils_["ContentUtils"].insertHorizontalLine(_this.state.editorState));
  23304. });
  23305. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "clearEditorContent", function () {
  23306. _this.setValue(external_braft_utils_["ContentUtils"].clear(_this.state.editorState), function (editorState) {
  23307. _this.setValue(external_braft_utils_["ContentUtils"].toggleSelectionIndent(editorState, 0));
  23308. });
  23309. });
  23310. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "toggleFullscreen", function (fullscreen) {
  23311. _this.setState({
  23312. isFullscreen: typeof fullscreen !== 'undefined' ? fullscreen : !_this.state.isFullscreen
  23313. }, function () {
  23314. _this.editorProps.onFullscreen && _this.editorProps.onFullscreen(_this.state.isFullscreen);
  23315. });
  23316. });
  23317. defineProperty_default()(assertThisInitialized_default()(assertThisInitialized_default()(_this)), "setEditorContainerNode", function (containerNode) {
  23318. _this.containerNode = containerNode;
  23319. });
  23320. _this.editorProps = _this.getEditorProps(props);
  23321. _this.editorDecorators = getDecorators(_this.editorProps.editorId || _this.editorProps.id);
  23322. _this.isFocused = false;
  23323. _this.isLiving = false;
  23324. _this.braftFinder = null;
  23325. _this.valueInitialized = !!(_this.props.defaultValue || _this.props.value);
  23326. 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);
  23327. defaultEditorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  23328. var tempColors = [];
  23329. if (external_braft_utils_["ContentUtils"].isEditorState(defaultEditorState)) {
  23330. var colors = external_braft_utils_["ColorUtils"].detectColorsFromDraftState(defaultEditorState.toRAW(true));
  23331. defaultEditorState.setConvertOptions(editor_getConvertOptions(_this.editorProps));
  23332. tempColors = filterColors(colors, _this.editorProps.colors);
  23333. }
  23334. _this.state = {
  23335. tempColors: tempColors,
  23336. editorState: defaultEditorState,
  23337. isFullscreen: false,
  23338. draftProps: {}
  23339. };
  23340. _this.containerNode = null;
  23341. return _this;
  23342. }
  23343. createClass_default()(BraftEditor, [{
  23344. key: "getEditorProps",
  23345. value: function getEditorProps(props) {
  23346. var _this2 = this;
  23347. props = props || this.props;
  23348. var _props = props,
  23349. value = _props.value,
  23350. defaultValue = _props.defaultValue,
  23351. onChange = _props.onChange,
  23352. restProps = objectWithoutProperties_default()(_props, ["value", "defaultValue", "onChange"]); // eslint-disable-line no-unused-vars
  23353. var propInterceptors = getPropInterceptors(restProps.editorId || restProps.id);
  23354. if (propInterceptors.length === 0) {
  23355. return restProps;
  23356. }
  23357. var porpsMap = Object(external_immutable_["Map"])(restProps);
  23358. propInterceptors.forEach(function (interceptor) {
  23359. porpsMap = porpsMap.merge(Object(external_immutable_["Map"])(interceptor(porpsMap.toJS(), _this2) || {}));
  23360. });
  23361. return porpsMap.toJS();
  23362. }
  23363. }, {
  23364. key: "componentWillMount",
  23365. value: function componentWillMount() {
  23366. if (editor_isControlEnabled(this.editorProps, 'media')) {
  23367. var _this$editorProps = this.editorProps,
  23368. language = _this$editorProps.language,
  23369. media = _this$editorProps.media;
  23370. var _defaultProps$media$m = objectSpread_default()({}, configs_props.media, media),
  23371. uploadFn = _defaultProps$media$m.uploadFn,
  23372. validateFn = _defaultProps$media$m.validateFn,
  23373. items = _defaultProps$media$m.items;
  23374. this.braftFinder = new external_braft_finder_default.a({
  23375. items: items,
  23376. language: language,
  23377. uploader: uploadFn,
  23378. validator: validateFn
  23379. });
  23380. this.forceUpdate();
  23381. }
  23382. }
  23383. }, {
  23384. key: "componentDidMount",
  23385. value: function componentDidMount() {
  23386. this.isLiving = true;
  23387. }
  23388. }, {
  23389. key: "componentDidUpdate",
  23390. value: function componentDidUpdate(_, prevState) {
  23391. if (prevState.editorState !== this.state.editorState) {
  23392. this.state.editorState.setConvertOptions(editor_getConvertOptions(this.editorProps));
  23393. }
  23394. }
  23395. }, {
  23396. key: "componentWillReceiveProps",
  23397. value: function componentWillReceiveProps(props) {
  23398. var _this3 = this;
  23399. this.editorProps = this.getEditorProps(props);
  23400. var editorState = props.value;
  23401. var _this$editorProps2 = this.editorProps,
  23402. media = _this$editorProps2.media,
  23403. language = _this$editorProps2.language;
  23404. var currentProps = this.getEditorProps();
  23405. if (!editor_isControlEnabled(currentProps, 'media') && editor_isControlEnabled(this.editorProps, 'media') && !this.braftFinder) {
  23406. var _defaultProps$media$m2 = objectSpread_default()({}, configs_props.media, media),
  23407. uploadFn = _defaultProps$media$m2.uploadFn,
  23408. validateFn = _defaultProps$media$m2.validateFn,
  23409. items = _defaultProps$media$m2.items;
  23410. this.braftFinder = new external_braft_finder_default.a({
  23411. items: items,
  23412. language: language,
  23413. uploader: uploadFn,
  23414. validator: validateFn
  23415. });
  23416. this.forceUpdate();
  23417. }
  23418. if (media && media.items && this.braftFinder) {
  23419. this.braftFinder.setItems(media.items);
  23420. }
  23421. var nextEditorState;
  23422. if (!this.valueInitialized && typeof this.props.defaultValue === 'undefined' && external_braft_utils_["ContentUtils"].isEditorState(props.defaultValue)) {
  23423. nextEditorState = props.defaultValue;
  23424. } else if (external_braft_utils_["ContentUtils"].isEditorState(editorState)) {
  23425. nextEditorState = editorState;
  23426. }
  23427. if (nextEditorState) {
  23428. if (nextEditorState && nextEditorState !== this.state.editorState) {
  23429. var tempColors = external_braft_utils_["ColorUtils"].detectColorsFromDraftState(nextEditorState.toRAW(true));
  23430. nextEditorState.setConvertOptions(editor_getConvertOptions(this.editorProps));
  23431. this.setState({
  23432. tempColors: filterColors(toConsumableArray_default()(this.state.tempColors).concat(toConsumableArray_default()(tempColors)), currentProps.colors),
  23433. editorState: nextEditorState
  23434. }, function () {
  23435. _this3.props.onChange && _this3.props.onChange(nextEditorState);
  23436. });
  23437. } else {
  23438. this.setState({
  23439. editorState: nextEditorState
  23440. });
  23441. }
  23442. }
  23443. }
  23444. }, {
  23445. key: "componentWillUnmount",
  23446. value: function componentWillUnmount() {
  23447. this.isLiving = false;
  23448. this.controlBarInstance && this.controlBarInstance.closeBraftFinder();
  23449. }
  23450. }, {
  23451. key: "lockOrUnlockEditor",
  23452. value: function lockOrUnlockEditor(editorLocked) {
  23453. this.setState({
  23454. editorLocked: editorLocked
  23455. });
  23456. }
  23457. }, {
  23458. key: "render",
  23459. value: function render() {
  23460. var _this4 = this;
  23461. var _this$editorProps3 = this.editorProps,
  23462. id = _this$editorProps3.id,
  23463. editorId = _this$editorProps3.editorId,
  23464. controls = _this$editorProps3.controls,
  23465. excludeControls = _this$editorProps3.excludeControls,
  23466. extendControls = _this$editorProps3.extendControls,
  23467. readOnly = _this$editorProps3.readOnly,
  23468. disabled = _this$editorProps3.disabled,
  23469. media = _this$editorProps3.media,
  23470. language = _this$editorProps3.language,
  23471. colors = _this$editorProps3.colors,
  23472. colorPicker = _this$editorProps3.colorPicker,
  23473. colorPickerTheme = _this$editorProps3.colorPickerTheme,
  23474. colorPickerAutoHide = _this$editorProps3.colorPickerAutoHide,
  23475. hooks = _this$editorProps3.hooks,
  23476. fontSizes = _this$editorProps3.fontSizes,
  23477. fontFamilies = _this$editorProps3.fontFamilies,
  23478. emojis = _this$editorProps3.emojis,
  23479. placeholder = _this$editorProps3.placeholder,
  23480. fixPlaceholder = _this$editorProps3.fixPlaceholder,
  23481. headings = _this$editorProps3.headings,
  23482. imageControls = _this$editorProps3.imageControls,
  23483. imageResizable = _this$editorProps3.imageResizable,
  23484. lineHeights = _this$editorProps3.lineHeights,
  23485. letterSpacings = _this$editorProps3.letterSpacings,
  23486. textAligns = _this$editorProps3.textAligns,
  23487. textBackgroundColor = _this$editorProps3.textBackgroundColor,
  23488. allowInsertLinkText = _this$editorProps3.allowInsertLinkText,
  23489. defaultLinkTarget = _this$editorProps3.defaultLinkTarget,
  23490. extendAtomics = _this$editorProps3.extendAtomics,
  23491. className = _this$editorProps3.className,
  23492. style = _this$editorProps3.style,
  23493. controlBarClassName = _this$editorProps3.controlBarClassName,
  23494. controlBarStyle = _this$editorProps3.controlBarStyle,
  23495. contentClassName = _this$editorProps3.contentClassName,
  23496. contentStyle = _this$editorProps3.contentStyle,
  23497. stripPastedStyles = _this$editorProps3.stripPastedStyles,
  23498. componentBelowControlBar = _this$editorProps3.componentBelowControlBar;
  23499. var _this$state = this.state,
  23500. isFullscreen = _this$state.isFullscreen,
  23501. editorState = _this$state.editorState;
  23502. editorId = editorId || id;
  23503. hooks = buildHooks(hooks);
  23504. controls = controls.filter(function (item) {
  23505. return excludeControls.indexOf(item) === -1;
  23506. });
  23507. language = (typeof language === 'function' ? language(languages, 'braft-editor') : languages[language]) || languages[configs_props.language];
  23508. var externalMedias = media && media.externals ? objectSpread_default()({}, configs_props.media.externals, media.externals) : configs_props.media.externals;
  23509. var accepts = media && media.accepts ? objectSpread_default()({}, configs_props.media.accepts, media.accepts) : configs_props.media.accepts;
  23510. media = objectSpread_default()({}, configs_props.media, media, {
  23511. externalMedias: externalMedias,
  23512. accepts: accepts
  23513. });
  23514. if (!media.uploadFn) {
  23515. media.video = false;
  23516. media.audio = false;
  23517. }
  23518. var controlBarProps = {
  23519. editor: this,
  23520. editorState: editorState,
  23521. braftFinder: this.braftFinder,
  23522. ref: function ref(instance) {
  23523. return _this4.controlBarInstance = instance;
  23524. },
  23525. getContainerNode: function getContainerNode() {
  23526. return _this4.containerNode;
  23527. },
  23528. className: controlBarClassName,
  23529. style: controlBarStyle,
  23530. colors: toConsumableArray_default()(colors).concat(toConsumableArray_default()(this.state.tempColors)),
  23531. colorPicker: colorPicker,
  23532. colorPickerTheme: colorPickerTheme,
  23533. colorPickerAutoHide: colorPickerAutoHide,
  23534. hooks: hooks,
  23535. editorId: editorId,
  23536. media: media,
  23537. controls: controls,
  23538. language: language,
  23539. extendControls: extendControls,
  23540. headings: headings,
  23541. fontSizes: fontSizes,
  23542. fontFamilies: fontFamilies,
  23543. emojis: emojis,
  23544. lineHeights: lineHeights,
  23545. letterSpacings: letterSpacings,
  23546. textAligns: textAligns,
  23547. textBackgroundColor: textBackgroundColor,
  23548. allowInsertLinkText: allowInsertLinkText,
  23549. defaultLinkTarget: defaultLinkTarget
  23550. };
  23551. var unitExportFn = editorState.convertOptions.unitExportFn;
  23552. var commonProps = {
  23553. editor: this,
  23554. editorId: editorId,
  23555. hooks: hooks,
  23556. editorState: editorState,
  23557. containerNode: this.containerNode,
  23558. imageControls: imageControls,
  23559. imageResizable: imageResizable,
  23560. language: language,
  23561. extendAtomics: extendAtomics
  23562. };
  23563. var blockRendererFn = getBlockRendererFn(commonProps, this.editorProps.blockRendererFn);
  23564. var blockRenderMap = getBlockRenderMap(commonProps, this.editorProps.blockRenderMap);
  23565. var blockStyleFn = getBlockStyleFn(this.editorProps.blockStyleFn);
  23566. var customStyleMap = getCustomStyleMap(commonProps, this.editorProps.customStyleMap);
  23567. var customStyleFn = getCustomStyleFn(commonProps, {
  23568. fontFamilies: fontFamilies,
  23569. unitExportFn: unitExportFn,
  23570. customStyleFn: this.editorProps.customStyleFn
  23571. });
  23572. var keyBindingFn = keybindings(this.editorProps.keyBindingFn);
  23573. var mixedProps = {};
  23574. if (this.state.editorLocked || this.editorProps.disabled || this.editorProps.readOnly || this.editorProps.draftProps.readOnly) {
  23575. mixedProps.readOnly = true;
  23576. }
  23577. if (placeholder && fixPlaceholder && editorState.isEmpty() && editorState.getCurrentContent().getFirstBlock().getType() !== 'unstyled') {
  23578. placeholder = '';
  23579. }
  23580. var draftProps = objectSpread_default()({
  23581. ref: function ref(instance) {
  23582. _this4.draftInstance = instance;
  23583. },
  23584. editorState: editorState,
  23585. handleKeyCommand: this.handleKeyCommand,
  23586. handleReturn: this.handleReturn,
  23587. handleBeforeInput: this.handleBeforeInput,
  23588. handleDrop: this.handleDrop,
  23589. handleDroppedFiles: this.handleDroppedFiles,
  23590. handlePastedText: this.handlePastedText,
  23591. handlePastedFiles: this.handlePastedFiles,
  23592. onChange: this.onChange,
  23593. onTab: this.onTab,
  23594. onFocus: this.onFocus,
  23595. onBlur: this.onBlur,
  23596. blockRenderMap: blockRenderMap,
  23597. blockRendererFn: blockRendererFn,
  23598. blockStyleFn: blockStyleFn,
  23599. customStyleMap: customStyleMap,
  23600. customStyleFn: customStyleFn,
  23601. keyBindingFn: keyBindingFn,
  23602. placeholder: placeholder,
  23603. stripPastedStyles: stripPastedStyles
  23604. }, this.editorProps.draftProps, mixedProps);
  23605. return external_react_default.a.createElement("div", {
  23606. style: style,
  23607. ref: this.setEditorContainerNode,
  23608. className: "bf-container ".concat(className).concat(disabled ? ' disabled' : '').concat(readOnly ? ' read-only' : '').concat(isFullscreen ? ' fullscreen' : '')
  23609. }, external_react_default.a.createElement(ControlBar_ControlBar, controlBarProps), componentBelowControlBar, external_react_default.a.createElement("div", {
  23610. onCompositionStart: this.handleCompositionStart,
  23611. className: "bf-content ".concat(contentClassName),
  23612. onCopy: this.handleCopyContent,
  23613. style: contentStyle
  23614. }, external_react_default.a.createElement(external_draft_js_["Editor"], draftProps)));
  23615. }
  23616. }]);
  23617. return BraftEditor;
  23618. }(external_react_default.a.Component);
  23619. defineProperty_default()(editor_BraftEditor, "defaultProps", configs_props);
  23620. // EXTERNAL MODULE: external "braft-convert"
  23621. var external_braft_convert_ = __webpack_require__(14);
  23622. // CONCATENATED MODULE: ./index.jsx
  23623. /* concated harmony reexport EditorState */__webpack_require__.d(__webpack_exports__, "EditorState", function() { return external_draft_js_["EditorState"]; });
  23624. /* concated harmony reexport getDecorators */__webpack_require__.d(__webpack_exports__, "getDecorators", function() { return getDecorators; });
  23625. external_draft_js_["EditorState"].prototype.setConvertOptions = function () {
  23626. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  23627. this.convertOptions = options;
  23628. };
  23629. external_draft_js_["EditorState"].prototype.toHTML = function () {
  23630. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  23631. var convertOptions = this.convertOptions || {};
  23632. return Object(external_braft_convert_["convertEditorStateToHTML"])(this, objectSpread_default()({}, convertOptions, options));
  23633. };
  23634. external_draft_js_["EditorState"].prototype.toRAW = function (noStringify) {
  23635. return noStringify ? Object(external_braft_convert_["convertEditorStateToRaw"])(this) : JSON.stringify(Object(external_braft_convert_["convertEditorStateToRaw"])(this));
  23636. };
  23637. external_draft_js_["EditorState"].prototype.toText = function () {
  23638. return this.getCurrentContent().getPlainText();
  23639. };
  23640. external_draft_js_["EditorState"].prototype.isEmpty = function () {
  23641. return !this.getCurrentContent().hasText();
  23642. };
  23643. editor_BraftEditor.createEditorState = external_draft_js_["EditorState"].createFrom = function (content) {
  23644. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  23645. options.unitExportFn = options.unitExportFn || editor_BraftEditor.defaultProps.converts.unitExportFn;
  23646. options.styleImportFn = compositeStyleImportFn(options.styleImportFn, options.editorId);
  23647. options.entityImportFn = compositeEntityImportFn(options.entityImportFn, options.editorId);
  23648. options.blockImportFn = compositeBlockImportFn(options.blockImportFn, options.editorId);
  23649. var editorState = null;
  23650. if (content instanceof external_draft_js_["EditorState"]) {
  23651. editorState = content;
  23652. } else if (typeof_default()(content) === 'object' && content && content.blocks && content.entityMap) {
  23653. editorState = Object(external_braft_convert_["convertRawToEditorState"])(content, getDecorators(options.editorId));
  23654. } else if (typeof content === 'string') {
  23655. try {
  23656. if (/^(-)?\d+$/.test(content)) {
  23657. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content, getDecorators(options.editorId), options, 'create');
  23658. } else {
  23659. editorState = external_draft_js_["EditorState"].createFrom(JSON.parse(content), options);
  23660. }
  23661. } catch (error) {
  23662. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content, getDecorators(options.editorId), options, 'create');
  23663. }
  23664. } else if (typeof content === 'number') {
  23665. editorState = Object(external_braft_convert_["convertHTMLToEditorState"])(content.toLocaleString().replace(/,/g, ''), getDecorators(options.editorId), options, 'create');
  23666. } else {
  23667. editorState = external_draft_js_["EditorState"].createEmpty(getDecorators(options.editorId));
  23668. }
  23669. options.styleExportFn = compositeStyleExportFn(options.styleExportFn, options.editorId);
  23670. options.entityExportFn = compositeEntityExportFn(options.entityExportFn, options.editorId);
  23671. options.blockExportFn = compositeBlockExportFn(options.blockExportFn, options.editorId);
  23672. editorState.setConvertOptions(options);
  23673. return editorState;
  23674. };
  23675. /* harmony default export */ var index_0 = __webpack_exports__["default"] = (createExtensibleEditor(editor_BraftEditor));
  23676. // 2.1版本开发计划
  23677. // [ ]优化选中多行文字是插入链接报错的问题
  23678. // [ ]新增编辑器内图片删除hook
  23679. // 2.2版本开发计划
  23680. // [ ]表格功能
  23681. // [ ]美化UI,包括图标和界面风格
  23682. // 2.3版本开发计划
  23683. // [ ]初级md快捷输入支持
  23684. // [ ]图片裁切等简单的编辑功能
  23685. // [ ]允许自定义快捷键
  23686. /***/ }),
  23687. /* 40 */
  23688. /***/ (function(module, exports) {
  23689. // removed by extract-text-webpack-plugin
  23690. /***/ }),
  23691. /* 41 */,
  23692. /* 42 */
  23693. /***/ (function(module, exports) {
  23694. // removed by extract-text-webpack-plugin
  23695. /***/ }),
  23696. /* 43 */,
  23697. /* 44 */,
  23698. /* 45 */
  23699. /***/ (function(module, exports) {
  23700. // removed by extract-text-webpack-plugin
  23701. /***/ }),
  23702. /* 46 */
  23703. /***/ (function(module, exports) {
  23704. // removed by extract-text-webpack-plugin
  23705. /***/ }),
  23706. /* 47 */
  23707. /***/ (function(module, exports) {
  23708. // removed by extract-text-webpack-plugin
  23709. /***/ }),
  23710. /* 48 */
  23711. /***/ (function(module, exports) {
  23712. // removed by extract-text-webpack-plugin
  23713. /***/ }),
  23714. /* 49 */
  23715. /***/ (function(module, exports) {
  23716. // removed by extract-text-webpack-plugin
  23717. /***/ }),
  23718. /* 50 */
  23719. /***/ (function(module, exports) {
  23720. // removed by extract-text-webpack-plugin
  23721. /***/ }),
  23722. /* 51 */
  23723. /***/ (function(module, exports) {
  23724. // removed by extract-text-webpack-plugin
  23725. /***/ }),
  23726. /* 52 */
  23727. /***/ (function(module, exports) {
  23728. // removed by extract-text-webpack-plugin
  23729. /***/ }),
  23730. /* 53 */
  23731. /***/ (function(module, exports) {
  23732. // removed by extract-text-webpack-plugin
  23733. /***/ }),
  23734. /* 54 */
  23735. /***/ (function(module, exports) {
  23736. // removed by extract-text-webpack-plugin
  23737. /***/ }),
  23738. /* 55 */
  23739. /***/ (function(module, exports) {
  23740. // removed by extract-text-webpack-plugin
  23741. /***/ }),
  23742. /* 56 */
  23743. /***/ (function(module, exports) {
  23744. // removed by extract-text-webpack-plugin
  23745. /***/ }),
  23746. /* 57 */
  23747. /***/ (function(module, exports) {
  23748. // removed by extract-text-webpack-plugin
  23749. /***/ }),
  23750. /* 58 */
  23751. /***/ (function(module, exports) {
  23752. // removed by extract-text-webpack-plugin
  23753. /***/ }),
  23754. /* 59 */
  23755. /***/ (function(module, exports) {
  23756. // removed by extract-text-webpack-plugin
  23757. /***/ }),
  23758. /* 60 */
  23759. /***/ (function(module, exports) {
  23760. // removed by extract-text-webpack-plugin
  23761. /***/ }),
  23762. /* 61 */
  23763. /***/ (function(module, exports) {
  23764. // removed by extract-text-webpack-plugin
  23765. /***/ }),
  23766. /* 62 */
  23767. /***/ (function(module, exports) {
  23768. // removed by extract-text-webpack-plugin
  23769. /***/ }),
  23770. /* 63 */
  23771. /***/ (function(module, exports) {
  23772. // removed by extract-text-webpack-plugin
  23773. /***/ })
  23774. /******/ ]);
  23775. });
  23776. });
  23777. var BraftEditor = _commonjsHelpers.unwrapExports(dist$3);
  23778. 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)}";
  23779. styleInject_es.styleInject(css);
  23780. 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}";
  23781. styleInject_es.styleInject(css$1);
  23782. var emoticon = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  23783. (function webpackUniversalModuleDefinition(root, factory) {
  23784. module.exports = factory(React__default, dist$1);
  23785. })(window, function(__WEBPACK_EXTERNAL_MODULE__1__, __WEBPACK_EXTERNAL_MODULE__6__) {
  23786. return /******/ (function(modules) { // webpackBootstrap
  23787. /******/ // The module cache
  23788. /******/ var installedModules = {};
  23789. /******/
  23790. /******/ // The require function
  23791. /******/ function __webpack_require__(moduleId) {
  23792. /******/
  23793. /******/ // Check if module is in cache
  23794. /******/ if(installedModules[moduleId]) {
  23795. /******/ return installedModules[moduleId].exports;
  23796. /******/ }
  23797. /******/ // Create a new module (and put it into the cache)
  23798. /******/ var module = installedModules[moduleId] = {
  23799. /******/ i: moduleId,
  23800. /******/ l: false,
  23801. /******/ exports: {}
  23802. /******/ };
  23803. /******/
  23804. /******/ // Execute the module function
  23805. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  23806. /******/
  23807. /******/ // Flag the module as loaded
  23808. /******/ module.l = true;
  23809. /******/
  23810. /******/ // Return the exports of the module
  23811. /******/ return module.exports;
  23812. /******/ }
  23813. /******/
  23814. /******/
  23815. /******/ // expose the modules object (__webpack_modules__)
  23816. /******/ __webpack_require__.m = modules;
  23817. /******/
  23818. /******/ // expose the module cache
  23819. /******/ __webpack_require__.c = installedModules;
  23820. /******/
  23821. /******/ // define getter function for harmony exports
  23822. /******/ __webpack_require__.d = function(exports, name, getter) {
  23823. /******/ if(!__webpack_require__.o(exports, name)) {
  23824. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  23825. /******/ }
  23826. /******/ };
  23827. /******/
  23828. /******/ // define __esModule on exports
  23829. /******/ __webpack_require__.r = function(exports) {
  23830. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  23831. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  23832. /******/ }
  23833. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  23834. /******/ };
  23835. /******/
  23836. /******/ // create a fake namespace object
  23837. /******/ // mode & 1: value is a module id, require it
  23838. /******/ // mode & 2: merge all properties of value into the ns
  23839. /******/ // mode & 4: return value when already ns object
  23840. /******/ // mode & 8|1: behave like require
  23841. /******/ __webpack_require__.t = function(value, mode) {
  23842. /******/ if(mode & 1) value = __webpack_require__(value);
  23843. /******/ if(mode & 8) return value;
  23844. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  23845. /******/ var ns = Object.create(null);
  23846. /******/ __webpack_require__.r(ns);
  23847. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  23848. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  23849. /******/ return ns;
  23850. /******/ };
  23851. /******/
  23852. /******/ // getDefaultExport function for compatibility with non-harmony modules
  23853. /******/ __webpack_require__.n = function(module) {
  23854. /******/ var getter = module && module.__esModule ?
  23855. /******/ function getDefault() { return module['default']; } :
  23856. /******/ function getModuleExports() { return module; };
  23857. /******/ __webpack_require__.d(getter, 'a', getter);
  23858. /******/ return getter;
  23859. /******/ };
  23860. /******/
  23861. /******/ // Object.prototype.hasOwnProperty.call
  23862. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  23863. /******/
  23864. /******/ // __webpack_public_path__
  23865. /******/ __webpack_require__.p = "/";
  23866. /******/
  23867. /******/
  23868. /******/ // Load entry module and return exports
  23869. /******/ return __webpack_require__(__webpack_require__.s = 33);
  23870. /******/ })
  23871. /************************************************************************/
  23872. /******/ ({
  23873. /***/ 1:
  23874. /***/ (function(module, exports) {
  23875. module.exports = __WEBPACK_EXTERNAL_MODULE__1__;
  23876. /***/ }),
  23877. /***/ 2:
  23878. /***/ (function(module, exports) {
  23879. function _defineProperty(obj, key, value) {
  23880. if (key in obj) {
  23881. Object.defineProperty(obj, key, {
  23882. value: value,
  23883. enumerable: true,
  23884. configurable: true,
  23885. writable: true
  23886. });
  23887. } else {
  23888. obj[key] = value;
  23889. }
  23890. return obj;
  23891. }
  23892. module.exports = _defineProperty;
  23893. /***/ }),
  23894. /***/ 33:
  23895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23896. __webpack_require__.r(__webpack_exports__);
  23897. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultEmoticons", function() { return defaultEmoticons; });
  23898. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
  23899. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);
  23900. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1);
  23901. /* harmony import */ var react__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(react__WEBPACK_IMPORTED_MODULE_1__);
  23902. /* harmony import */ var braft_utils__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(6);
  23903. /* harmony import */ var _styles_scss__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(48);
  23904. // https://www.iconfinder.com/iconsets/emoji-18
  23905. 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) {
  23906. return "".concat(item, ".png");
  23907. });
  23908. var insertEmoticon = function insertEmoticon(editor, editorState, src) {
  23909. editor.setValue(braft_utils__WEBPACK_IMPORTED_MODULE_2__["ContentUtils"].insertText(editorState, ' ', null, {
  23910. type: 'EMOTICON',
  23911. mutability: 'IMMUTABLE',
  23912. data: {
  23913. src: src
  23914. }
  23915. }));
  23916. };
  23917. var controlRef = null;
  23918. var bindControlRef = function bindControlRef(ref) {
  23919. return controlRef = ref;
  23920. };
  23921. /* harmony default export */ __webpack_exports__["default"] = (function (options) {
  23922. options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({
  23923. emoticons: [],
  23924. closeOnSelect: false,
  23925. closeOnBlur: false
  23926. }, options);
  23927. var _options = options,
  23928. emoticons = _options.emoticons,
  23929. closeOnSelect = _options.closeOnSelect,
  23930. closeOnBlur = _options.closeOnBlur,
  23931. includeEditors = _options.includeEditors,
  23932. excludeEditors = _options.excludeEditors;
  23933. return {
  23934. type: 'entity',
  23935. includeEditors: includeEditors,
  23936. excludeEditors: excludeEditors,
  23937. name: 'EMOTICON',
  23938. control: function control(props) {
  23939. return {
  23940. key: 'EMOTICON',
  23941. replace: 'emoji',
  23942. type: 'dropdown',
  23943. text: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("i", {
  23944. className: "bfi-emoji"
  23945. }),
  23946. showArrow: false,
  23947. ref: bindControlRef,
  23948. autoHide: closeOnBlur,
  23949. component: react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("div", {
  23950. className: "braft-emoticon-picker"
  23951. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("div", {
  23952. className: "braft-emoticons-list"
  23953. }, emoticons.map(function (item, index) {
  23954. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  23955. onClick: function onClick() {
  23956. insertEmoticon(props.editor, props.editorState, item);
  23957. closeOnSelect && controlRef && controlRef.hide();
  23958. },
  23959. key: index,
  23960. src: item
  23961. });
  23962. })))
  23963. };
  23964. },
  23965. mutability: 'IMMUTABLE',
  23966. component: function component(props) {
  23967. var entity = props.contentState.getEntity(props.entityKey);
  23968. var _entity$getData = entity.getData(),
  23969. src = _entity$getData.src;
  23970. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("span", {
  23971. className: "braft-emoticon-in-editor"
  23972. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  23973. src: src
  23974. }), props.children);
  23975. },
  23976. importer: function importer(nodeName, node) {
  23977. if (nodeName.toLowerCase() === 'span' && node.classList && node.classList.contains('braft-emoticon-wrap')) {
  23978. var imgNode = node.querySelector('img');
  23979. var src = imgNode.getAttribute('src'); // 移除img节点以避免生成atomic block
  23980. node.removeChild(imgNode);
  23981. return {
  23982. mutability: 'IMMUTABLE',
  23983. data: {
  23984. src: src
  23985. }
  23986. };
  23987. }
  23988. },
  23989. exporter: function exporter(entityObject, initialText) {
  23990. var src = entityObject.data.src;
  23991. return react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("span", {
  23992. className: "braft-emoticon-wrap"
  23993. }, react__WEBPACK_IMPORTED_MODULE_1___default.a.createElement("img", {
  23994. src: src
  23995. }), initialText);
  23996. }
  23997. };
  23998. });
  23999. /***/ }),
  24000. /***/ 48:
  24001. /***/ (function(module, exports) {
  24002. // removed by extract-text-webpack-plugin
  24003. /***/ }),
  24004. /***/ 5:
  24005. /***/ (function(module, exports, __webpack_require__) {
  24006. var defineProperty = __webpack_require__(2);
  24007. function _objectSpread(target) {
  24008. for (var i = 1; i < arguments.length; i++) {
  24009. var source = arguments[i] != null ? arguments[i] : {};
  24010. var ownKeys = Object.keys(source);
  24011. if (typeof Object.getOwnPropertySymbols === 'function') {
  24012. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  24013. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  24014. }));
  24015. }
  24016. ownKeys.forEach(function (key) {
  24017. defineProperty(target, key, source[key]);
  24018. });
  24019. }
  24020. return target;
  24021. }
  24022. module.exports = _objectSpread;
  24023. /***/ }),
  24024. /***/ 6:
  24025. /***/ (function(module, exports) {
  24026. module.exports = __WEBPACK_EXTERNAL_MODULE__6__;
  24027. /***/ })
  24028. /******/ });
  24029. });
  24030. });
  24031. var Emoticon = _commonjsHelpers.unwrapExports(emoticon);
  24032. var emoticon_1 = emoticon.defaultEmoticons;
  24033. var maxLength = _commonjsHelpers.createCommonjsModule(function (module, exports) {
  24034. (function webpackUniversalModuleDefinition(root, factory) {
  24035. module.exports = factory();
  24036. })(window, function() {
  24037. return /******/ (function(modules) { // webpackBootstrap
  24038. /******/ // The module cache
  24039. /******/ var installedModules = {};
  24040. /******/
  24041. /******/ // The require function
  24042. /******/ function __webpack_require__(moduleId) {
  24043. /******/
  24044. /******/ // Check if module is in cache
  24045. /******/ if(installedModules[moduleId]) {
  24046. /******/ return installedModules[moduleId].exports;
  24047. /******/ }
  24048. /******/ // Create a new module (and put it into the cache)
  24049. /******/ var module = installedModules[moduleId] = {
  24050. /******/ i: moduleId,
  24051. /******/ l: false,
  24052. /******/ exports: {}
  24053. /******/ };
  24054. /******/
  24055. /******/ // Execute the module function
  24056. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  24057. /******/
  24058. /******/ // Flag the module as loaded
  24059. /******/ module.l = true;
  24060. /******/
  24061. /******/ // Return the exports of the module
  24062. /******/ return module.exports;
  24063. /******/ }
  24064. /******/
  24065. /******/
  24066. /******/ // expose the modules object (__webpack_modules__)
  24067. /******/ __webpack_require__.m = modules;
  24068. /******/
  24069. /******/ // expose the module cache
  24070. /******/ __webpack_require__.c = installedModules;
  24071. /******/
  24072. /******/ // define getter function for harmony exports
  24073. /******/ __webpack_require__.d = function(exports, name, getter) {
  24074. /******/ if(!__webpack_require__.o(exports, name)) {
  24075. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  24076. /******/ }
  24077. /******/ };
  24078. /******/
  24079. /******/ // define __esModule on exports
  24080. /******/ __webpack_require__.r = function(exports) {
  24081. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  24082. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  24083. /******/ }
  24084. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  24085. /******/ };
  24086. /******/
  24087. /******/ // create a fake namespace object
  24088. /******/ // mode & 1: value is a module id, require it
  24089. /******/ // mode & 2: merge all properties of value into the ns
  24090. /******/ // mode & 4: return value when already ns object
  24091. /******/ // mode & 8|1: behave like require
  24092. /******/ __webpack_require__.t = function(value, mode) {
  24093. /******/ if(mode & 1) value = __webpack_require__(value);
  24094. /******/ if(mode & 8) return value;
  24095. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  24096. /******/ var ns = Object.create(null);
  24097. /******/ __webpack_require__.r(ns);
  24098. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  24099. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  24100. /******/ return ns;
  24101. /******/ };
  24102. /******/
  24103. /******/ // getDefaultExport function for compatibility with non-harmony modules
  24104. /******/ __webpack_require__.n = function(module) {
  24105. /******/ var getter = module && module.__esModule ?
  24106. /******/ function getDefault() { return module['default']; } :
  24107. /******/ function getModuleExports() { return module; };
  24108. /******/ __webpack_require__.d(getter, 'a', getter);
  24109. /******/ return getter;
  24110. /******/ };
  24111. /******/
  24112. /******/ // Object.prototype.hasOwnProperty.call
  24113. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  24114. /******/
  24115. /******/ // __webpack_public_path__
  24116. /******/ __webpack_require__.p = "/";
  24117. /******/
  24118. /******/
  24119. /******/ // Load entry module and return exports
  24120. /******/ return __webpack_require__(__webpack_require__.s = 34);
  24121. /******/ })
  24122. /************************************************************************/
  24123. /******/ ({
  24124. /***/ 2:
  24125. /***/ (function(module, exports) {
  24126. function _defineProperty(obj, key, value) {
  24127. if (key in obj) {
  24128. Object.defineProperty(obj, key, {
  24129. value: value,
  24130. enumerable: true,
  24131. configurable: true,
  24132. writable: true
  24133. });
  24134. } else {
  24135. obj[key] = value;
  24136. }
  24137. return obj;
  24138. }
  24139. module.exports = _defineProperty;
  24140. /***/ }),
  24141. /***/ 34:
  24142. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24143. __webpack_require__.r(__webpack_exports__);
  24144. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(5);
  24145. /* harmony import */ var _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0__);
  24146. var getSelectedTextLength = function getSelectedTextLength(editorState) {
  24147. var currentSelection = editorState.getSelection();
  24148. var isCollapsed = currentSelection.isCollapsed();
  24149. var length = 0;
  24150. if (!isCollapsed) {
  24151. var currentContent = editorState.getCurrentContent();
  24152. var startKey = currentSelection.getStartKey();
  24153. var endKey = currentSelection.getEndKey();
  24154. var startBlock = currentContent.getBlockForKey(startKey);
  24155. var isStartAndEndBlockAreTheSame = startKey === endKey;
  24156. var startBlockTextLength = startBlock.getLength();
  24157. var startSelectedTextLength = startBlockTextLength - currentSelection.getStartOffset();
  24158. var endSelectedTextLength = currentSelection.getEndOffset();
  24159. var keyAfterEnd = currentContent.getKeyAfter(endKey);
  24160. if (isStartAndEndBlockAreTheSame) {
  24161. length += currentSelection.getEndOffset() - currentSelection.getStartOffset();
  24162. } else {
  24163. var currentKey = startKey;
  24164. while (currentKey && currentKey !== keyAfterEnd) {
  24165. if (currentKey === startKey) {
  24166. length += startSelectedTextLength + 1;
  24167. } else if (currentKey === endKey) {
  24168. length += endSelectedTextLength;
  24169. } else {
  24170. length += currentContent.getBlockForKey(currentKey).getLength() + 1;
  24171. }
  24172. currentKey = currentContent.getKeyAfter(currentKey);
  24173. }
  24174. }
  24175. }
  24176. return length;
  24177. };
  24178. /* harmony default export */ __webpack_exports__["default"] = (function (options) {
  24179. options = _babel_runtime_helpers_objectSpread__WEBPACK_IMPORTED_MODULE_0___default()({
  24180. defaultValue: Infinity
  24181. }, options);
  24182. var _options = options,
  24183. includeEditors = _options.includeEditors,
  24184. excludeEditors = _options.excludeEditors,
  24185. defaultValue = _options.defaultValue;
  24186. return {
  24187. type: 'prop-interception',
  24188. includeEditors: includeEditors,
  24189. excludeEditors: excludeEditors,
  24190. interceptor: function interceptor(editorProps) {
  24191. var maxLength = editorProps.maxLength || defaultValue;
  24192. editorProps.handleBeforeInput = function (_, editorState) {
  24193. if (maxLength === Infinity) {
  24194. return 'not-handled';
  24195. }
  24196. var currentContentLength = editorState.toText().length;
  24197. var selectedTextLength = getSelectedTextLength(editorState);
  24198. if (currentContentLength - selectedTextLength > maxLength - 1) {
  24199. editorProps.onReachMaxLength && editorProps.onReachMaxLength(maxLength);
  24200. return 'handled';
  24201. }
  24202. };
  24203. editorProps.handlePastedText = function (pastedText, _, editorState) {
  24204. if (maxLength === Infinity) {
  24205. return 'not-handled';
  24206. }
  24207. var currentContentLength = editorState.toText().length;
  24208. var selectedTextLength = getSelectedTextLength(editorState);
  24209. if (currentContentLength + pastedText.length - selectedTextLength > maxLength) {
  24210. editorProps.onReachMaxLength && editorProps.onReachMaxLength(maxLength);
  24211. return 'handled';
  24212. }
  24213. };
  24214. return editorProps;
  24215. }
  24216. };
  24217. });
  24218. /***/ }),
  24219. /***/ 5:
  24220. /***/ (function(module, exports, __webpack_require__) {
  24221. var defineProperty = __webpack_require__(2);
  24222. function _objectSpread(target) {
  24223. for (var i = 1; i < arguments.length; i++) {
  24224. var source = arguments[i] != null ? arguments[i] : {};
  24225. var ownKeys = Object.keys(source);
  24226. if (typeof Object.getOwnPropertySymbols === 'function') {
  24227. ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
  24228. return Object.getOwnPropertyDescriptor(source, sym).enumerable;
  24229. }));
  24230. }
  24231. ownKeys.forEach(function (key) {
  24232. defineProperty(target, key, source[key]);
  24233. });
  24234. }
  24235. return target;
  24236. }
  24237. module.exports = _objectSpread;
  24238. /***/ })
  24239. /******/ });
  24240. });
  24241. });
  24242. var MaxLength = _commonjsHelpers.unwrapExports(maxLength);
  24243. var lengthOptions = {
  24244. defaultValue: 100 // 指定默认限制数,如不指定则为Infinity(无限)
  24245. // includeEditors: ['editor-id-1'], // 指定该模块对哪些BraftEditor生效,不传此属性则对所有BraftEditor有效
  24246. // excludeEditors: ['editor-id-2'], // 指定该模块对哪些BraftEditor无效
  24247. };
  24248. BraftEditor.use(MaxLength(lengthOptions)); // 转换默认表情包列表,让webpack可以正确加载到默认表情包中的图片,请确保已对png格式的文件配置了loader
  24249. // 如果你使用的webpack版本不支持动态require,或者使用的其他打包工具,请勿使用此写法
  24250. var emoticons = emoticon_1.map(function (item) {
  24251. return require("braft-extensions/dist/assets/".concat(item));
  24252. }); // 也可以使用自己的表情包资源,不受打包工具限制
  24253. // 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', ...]
  24254. var emotionOptions = {
  24255. // includeEditors: ['editor-id-1'], // 指定该模块对哪些BraftEditor生效,不传此属性则对所有BraftEditor有效
  24256. // excludeEditors: ['editor-id-2'], // 指定该模块对哪些BraftEditor无效
  24257. emoticons: emoticons,
  24258. // 指定可用表情图片列表,默认为空
  24259. closeOnBlur: true,
  24260. // 指定是否在点击表情选择器之外的地方时关闭表情选择器,默认false
  24261. closeOnSelect: false // 指定是否在选择表情后关闭表情选择器,默认false
  24262. };
  24263. BraftEditor.use(Emoticon(emotionOptions));
  24264. var BarftEditorPage = function BarftEditorPage(_ref) {
  24265. var value = _ref.value;
  24266. var controls = ["bold", "italic", "underline", "separator", "link", "emoji", "separator", "media"];
  24267. var _useState = React.useState(BraftEditor.createEditorState(value || "<p>Hello <b>World!</b></p>")),
  24268. _useState2 = _rollupPluginBabelHelpers._slicedToArray(_useState, 2),
  24269. editorState = _useState2[0],
  24270. setEditorState = _useState2[1];
  24271. return React__default.createElement("div", {
  24272. className: "editor-wrapper"
  24273. }, React__default.createElement(BraftEditor, {
  24274. value: editorState,
  24275. onChange: setEditorState,
  24276. controls: controls,
  24277. contentStyle: {
  24278. boxShadow: "inset 0 1px 3px rgba(0,0,0,.1)"
  24279. }
  24280. }));
  24281. };
  24282. exports.BarftEditorPage = BarftEditorPage;
  24283. exports.default = BarftEditorPage;
  24284. //# sourceMappingURL=index.js.map