simplebar.min.js 148 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479
  1. /**
  2. * SimpleBar.js - v4.2.3
  3. * Scrollbars, simpler.
  4. * https://grsmto.github.io/simplebar/
  5. *
  6. * Made by Adrien Denat from a fork by Jonathan Nicol
  7. * Under MIT License
  8. */
  9. (function (global, factory) {
  10. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  11. typeof define === 'function' && define.amd ? define(factory) :
  12. (global = global || self, global.SimpleBar = factory());
  13. }(this, function () { 'use strict';
  14. var aFunction = function (it) {
  15. if (typeof it != 'function') {
  16. throw TypeError(String(it) + ' is not a function');
  17. } return it;
  18. };
  19. // optional / simple context binding
  20. var bindContext = function (fn, that, length) {
  21. aFunction(fn);
  22. if (that === undefined) return fn;
  23. switch (length) {
  24. case 0: return function () {
  25. return fn.call(that);
  26. };
  27. case 1: return function (a) {
  28. return fn.call(that, a);
  29. };
  30. case 2: return function (a, b) {
  31. return fn.call(that, a, b);
  32. };
  33. case 3: return function (a, b, c) {
  34. return fn.call(that, a, b, c);
  35. };
  36. }
  37. return function (/* ...args */) {
  38. return fn.apply(that, arguments);
  39. };
  40. };
  41. var fails = function (exec) {
  42. try {
  43. return !!exec();
  44. } catch (error) {
  45. return true;
  46. }
  47. };
  48. var toString = {}.toString;
  49. var classofRaw = function (it) {
  50. return toString.call(it).slice(8, -1);
  51. };
  52. // fallback for non-array-like ES3 and non-enumerable old V8 strings
  53. var split = ''.split;
  54. var indexedObject = fails(function () {
  55. // throws an error in rhino, see https://github.com/mozilla/rhino/issues/346
  56. // eslint-disable-next-line no-prototype-builtins
  57. return !Object('z').propertyIsEnumerable(0);
  58. }) ? function (it) {
  59. return classofRaw(it) == 'String' ? split.call(it, '') : Object(it);
  60. } : Object;
  61. // `RequireObjectCoercible` abstract operation
  62. // https://tc39.github.io/ecma262/#sec-requireobjectcoercible
  63. var requireObjectCoercible = function (it) {
  64. if (it == undefined) throw TypeError("Can't call method on " + it);
  65. return it;
  66. };
  67. // `ToObject` abstract operation
  68. // https://tc39.github.io/ecma262/#sec-toobject
  69. var toObject = function (argument) {
  70. return Object(requireObjectCoercible(argument));
  71. };
  72. var ceil = Math.ceil;
  73. var floor = Math.floor;
  74. // `ToInteger` abstract operation
  75. // https://tc39.github.io/ecma262/#sec-tointeger
  76. var toInteger = function (argument) {
  77. return isNaN(argument = +argument) ? 0 : (argument > 0 ? floor : ceil)(argument);
  78. };
  79. var min = Math.min;
  80. // `ToLength` abstract operation
  81. // https://tc39.github.io/ecma262/#sec-tolength
  82. var toLength = function (argument) {
  83. return argument > 0 ? min(toInteger(argument), 0x1FFFFFFFFFFFFF) : 0; // 2 ** 53 - 1 == 9007199254740991
  84. };
  85. var isObject = function (it) {
  86. return typeof it === 'object' ? it !== null : typeof it === 'function';
  87. };
  88. // `IsArray` abstract operation
  89. // https://tc39.github.io/ecma262/#sec-isarray
  90. var isArray = Array.isArray || function isArray(arg) {
  91. return classofRaw(arg) == 'Array';
  92. };
  93. var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  94. function createCommonjsModule(fn, module) {
  95. return module = { exports: {} }, fn(module, module.exports), module.exports;
  96. }
  97. // https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
  98. var global$1 = typeof window == 'object' && window && window.Math == Math ? window
  99. : typeof self == 'object' && self && self.Math == Math ? self
  100. // eslint-disable-next-line no-new-func
  101. : Function('return this')();
  102. // Thank's IE8 for his funny defineProperty
  103. var descriptors = !fails(function () {
  104. return Object.defineProperty({}, 'a', { get: function () { return 7; } }).a != 7;
  105. });
  106. var document$1 = global$1.document;
  107. // typeof document.createElement is 'object' in old IE
  108. var exist = isObject(document$1) && isObject(document$1.createElement);
  109. var documentCreateElement = function (it) {
  110. return exist ? document$1.createElement(it) : {};
  111. };
  112. // Thank's IE8 for his funny defineProperty
  113. var ie8DomDefine = !descriptors && !fails(function () {
  114. return Object.defineProperty(documentCreateElement('div'), 'a', {
  115. get: function () { return 7; }
  116. }).a != 7;
  117. });
  118. var anObject = function (it) {
  119. if (!isObject(it)) {
  120. throw TypeError(String(it) + ' is not an object');
  121. } return it;
  122. };
  123. // 7.1.1 ToPrimitive(input [, PreferredType])
  124. // instead of the ES6 spec version, we didn't implement @@toPrimitive case
  125. // and the second argument - flag - preferred type is a string
  126. var toPrimitive = function (it, S) {
  127. if (!isObject(it)) return it;
  128. var fn, val;
  129. if (S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  130. if (typeof (fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val;
  131. if (!S && typeof (fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val;
  132. throw TypeError("Can't convert object to primitive value");
  133. };
  134. var nativeDefineProperty = Object.defineProperty;
  135. var f = descriptors ? nativeDefineProperty : function defineProperty(O, P, Attributes) {
  136. anObject(O);
  137. P = toPrimitive(P, true);
  138. anObject(Attributes);
  139. if (ie8DomDefine) try {
  140. return nativeDefineProperty(O, P, Attributes);
  141. } catch (error) { /* empty */ }
  142. if ('get' in Attributes || 'set' in Attributes) throw TypeError('Accessors not supported');
  143. if ('value' in Attributes) O[P] = Attributes.value;
  144. return O;
  145. };
  146. var objectDefineProperty = {
  147. f: f
  148. };
  149. var createPropertyDescriptor = function (bitmap, value) {
  150. return {
  151. enumerable: !(bitmap & 1),
  152. configurable: !(bitmap & 2),
  153. writable: !(bitmap & 4),
  154. value: value
  155. };
  156. };
  157. var hide = descriptors ? function (object, key, value) {
  158. return objectDefineProperty.f(object, key, createPropertyDescriptor(1, value));
  159. } : function (object, key, value) {
  160. object[key] = value;
  161. return object;
  162. };
  163. var setGlobal = function (key, value) {
  164. try {
  165. hide(global$1, key, value);
  166. } catch (error) {
  167. global$1[key] = value;
  168. } return value;
  169. };
  170. var shared = createCommonjsModule(function (module) {
  171. var SHARED = '__core-js_shared__';
  172. var store = global$1[SHARED] || setGlobal(SHARED, {});
  173. (module.exports = function (key, value) {
  174. return store[key] || (store[key] = value !== undefined ? value : {});
  175. })('versions', []).push({
  176. version: '3.0.1',
  177. mode: 'global',
  178. copyright: '© 2019 Denis Pushkarev (zloirock.ru)'
  179. });
  180. });
  181. var id = 0;
  182. var postfix = Math.random();
  183. var uid = function (key) {
  184. return 'Symbol('.concat(key === undefined ? '' : key, ')_', (++id + postfix).toString(36));
  185. };
  186. // Chrome 38 Symbol has incorrect toString conversion
  187. var nativeSymbol = !fails(function () {
  188. // eslint-disable-next-line no-undef
  189. return !String(Symbol());
  190. });
  191. var store = shared('wks');
  192. var Symbol$1 = global$1.Symbol;
  193. var wellKnownSymbol = function (name) {
  194. return store[name] || (store[name] = nativeSymbol && Symbol$1[name]
  195. || (nativeSymbol ? Symbol$1 : uid)('Symbol.' + name));
  196. };
  197. var SPECIES = wellKnownSymbol('species');
  198. // `ArraySpeciesCreate` abstract operation
  199. // https://tc39.github.io/ecma262/#sec-arrayspeciescreate
  200. var arraySpeciesCreate = function (originalArray, length) {
  201. var C;
  202. if (isArray(originalArray)) {
  203. C = originalArray.constructor;
  204. // cross-realm fallback
  205. if (typeof C == 'function' && (C === Array || isArray(C.prototype))) C = undefined;
  206. else if (isObject(C)) {
  207. C = C[SPECIES];
  208. if (C === null) C = undefined;
  209. }
  210. } return new (C === undefined ? Array : C)(length === 0 ? 0 : length);
  211. };
  212. // `Array.prototype.{ forEach, map, filter, some, every, find, findIndex }` methods implementation
  213. // 0 -> Array#forEach
  214. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  215. // 1 -> Array#map
  216. // https://tc39.github.io/ecma262/#sec-array.prototype.map
  217. // 2 -> Array#filter
  218. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  219. // 3 -> Array#some
  220. // https://tc39.github.io/ecma262/#sec-array.prototype.some
  221. // 4 -> Array#every
  222. // https://tc39.github.io/ecma262/#sec-array.prototype.every
  223. // 5 -> Array#find
  224. // https://tc39.github.io/ecma262/#sec-array.prototype.find
  225. // 6 -> Array#findIndex
  226. // https://tc39.github.io/ecma262/#sec-array.prototype.findIndex
  227. var arrayMethods = function (TYPE, specificCreate) {
  228. var IS_MAP = TYPE == 1;
  229. var IS_FILTER = TYPE == 2;
  230. var IS_SOME = TYPE == 3;
  231. var IS_EVERY = TYPE == 4;
  232. var IS_FIND_INDEX = TYPE == 6;
  233. var NO_HOLES = TYPE == 5 || IS_FIND_INDEX;
  234. var create = specificCreate || arraySpeciesCreate;
  235. return function ($this, callbackfn, that) {
  236. var O = toObject($this);
  237. var self = indexedObject(O);
  238. var boundFunction = bindContext(callbackfn, that, 3);
  239. var length = toLength(self.length);
  240. var index = 0;
  241. var target = IS_MAP ? create($this, length) : IS_FILTER ? create($this, 0) : undefined;
  242. var value, result;
  243. for (;length > index; index++) if (NO_HOLES || index in self) {
  244. value = self[index];
  245. result = boundFunction(value, index, O);
  246. if (TYPE) {
  247. if (IS_MAP) target[index] = result; // map
  248. else if (result) switch (TYPE) {
  249. case 3: return true; // some
  250. case 5: return value; // find
  251. case 6: return index; // findIndex
  252. case 2: target.push(value); // filter
  253. } else if (IS_EVERY) return false; // every
  254. }
  255. }
  256. return IS_FIND_INDEX ? -1 : IS_SOME || IS_EVERY ? IS_EVERY : target;
  257. };
  258. };
  259. var SPECIES$1 = wellKnownSymbol('species');
  260. var arrayMethodHasSpeciesSupport = function (METHOD_NAME) {
  261. return !fails(function () {
  262. var array = [];
  263. var constructor = array.constructor = {};
  264. constructor[SPECIES$1] = function () {
  265. return { foo: 1 };
  266. };
  267. return array[METHOD_NAME](Boolean).foo !== 1;
  268. });
  269. };
  270. var nativePropertyIsEnumerable = {}.propertyIsEnumerable;
  271. var nativeGetOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
  272. // Nashorn ~ JDK8 bug
  273. var NASHORN_BUG = nativeGetOwnPropertyDescriptor && !nativePropertyIsEnumerable.call({ 1: 2 }, 1);
  274. var f$1 = NASHORN_BUG ? function propertyIsEnumerable(V) {
  275. var descriptor = nativeGetOwnPropertyDescriptor(this, V);
  276. return !!descriptor && descriptor.enumerable;
  277. } : nativePropertyIsEnumerable;
  278. var objectPropertyIsEnumerable = {
  279. f: f$1
  280. };
  281. // toObject with fallback for non-array-like ES3 strings
  282. var toIndexedObject = function (it) {
  283. return indexedObject(requireObjectCoercible(it));
  284. };
  285. var hasOwnProperty = {}.hasOwnProperty;
  286. var has = function (it, key) {
  287. return hasOwnProperty.call(it, key);
  288. };
  289. var nativeGetOwnPropertyDescriptor$1 = Object.getOwnPropertyDescriptor;
  290. var f$2 = descriptors ? nativeGetOwnPropertyDescriptor$1 : function getOwnPropertyDescriptor(O, P) {
  291. O = toIndexedObject(O);
  292. P = toPrimitive(P, true);
  293. if (ie8DomDefine) try {
  294. return nativeGetOwnPropertyDescriptor$1(O, P);
  295. } catch (error) { /* empty */ }
  296. if (has(O, P)) return createPropertyDescriptor(!objectPropertyIsEnumerable.f.call(O, P), O[P]);
  297. };
  298. var objectGetOwnPropertyDescriptor = {
  299. f: f$2
  300. };
  301. var functionToString = shared('native-function-to-string', Function.toString);
  302. var WeakMap$1 = global$1.WeakMap;
  303. var nativeWeakMap = typeof WeakMap$1 === 'function' && /native code/.test(functionToString.call(WeakMap$1));
  304. var shared$1 = shared('keys');
  305. var sharedKey = function (key) {
  306. return shared$1[key] || (shared$1[key] = uid(key));
  307. };
  308. var hiddenKeys = {};
  309. var WeakMap$2 = global$1.WeakMap;
  310. var set, get, has$1;
  311. var enforce = function (it) {
  312. return has$1(it) ? get(it) : set(it, {});
  313. };
  314. var getterFor = function (TYPE) {
  315. return function (it) {
  316. var state;
  317. if (!isObject(it) || (state = get(it)).type !== TYPE) {
  318. throw TypeError('Incompatible receiver, ' + TYPE + ' required');
  319. } return state;
  320. };
  321. };
  322. if (nativeWeakMap) {
  323. var store$1 = new WeakMap$2();
  324. var wmget = store$1.get;
  325. var wmhas = store$1.has;
  326. var wmset = store$1.set;
  327. set = function (it, metadata) {
  328. wmset.call(store$1, it, metadata);
  329. return metadata;
  330. };
  331. get = function (it) {
  332. return wmget.call(store$1, it) || {};
  333. };
  334. has$1 = function (it) {
  335. return wmhas.call(store$1, it);
  336. };
  337. } else {
  338. var STATE = sharedKey('state');
  339. hiddenKeys[STATE] = true;
  340. set = function (it, metadata) {
  341. hide(it, STATE, metadata);
  342. return metadata;
  343. };
  344. get = function (it) {
  345. return has(it, STATE) ? it[STATE] : {};
  346. };
  347. has$1 = function (it) {
  348. return has(it, STATE);
  349. };
  350. }
  351. var internalState = {
  352. set: set,
  353. get: get,
  354. has: has$1,
  355. enforce: enforce,
  356. getterFor: getterFor
  357. };
  358. var redefine = createCommonjsModule(function (module) {
  359. var getInternalState = internalState.get;
  360. var enforceInternalState = internalState.enforce;
  361. var TEMPLATE = String(functionToString).split('toString');
  362. shared('inspectSource', function (it) {
  363. return functionToString.call(it);
  364. });
  365. (module.exports = function (O, key, value, options) {
  366. var unsafe = options ? !!options.unsafe : false;
  367. var simple = options ? !!options.enumerable : false;
  368. var noTargetGet = options ? !!options.noTargetGet : false;
  369. if (typeof value == 'function') {
  370. if (typeof key == 'string' && !has(value, 'name')) hide(value, 'name', key);
  371. enforceInternalState(value).source = TEMPLATE.join(typeof key == 'string' ? key : '');
  372. }
  373. if (O === global$1) {
  374. if (simple) O[key] = value;
  375. else setGlobal(key, value);
  376. return;
  377. } else if (!unsafe) {
  378. delete O[key];
  379. } else if (!noTargetGet && O[key]) {
  380. simple = true;
  381. }
  382. if (simple) O[key] = value;
  383. else hide(O, key, value);
  384. // add fake Function#toString for correct work wrapped methods / constructors with methods like LoDash isNative
  385. })(Function.prototype, 'toString', function toString() {
  386. return typeof this == 'function' && getInternalState(this).source || functionToString.call(this);
  387. });
  388. });
  389. var max = Math.max;
  390. var min$1 = Math.min;
  391. // Helper for a popular repeating case of the spec:
  392. // Let integer be ? ToInteger(index).
  393. // If integer < 0, let result be max((length + integer), 0); else let result be min(length, length).
  394. var toAbsoluteIndex = function (index, length) {
  395. var integer = toInteger(index);
  396. return integer < 0 ? max(integer + length, 0) : min$1(integer, length);
  397. };
  398. // `Array.prototype.{ indexOf, includes }` methods implementation
  399. // false -> Array#indexOf
  400. // https://tc39.github.io/ecma262/#sec-array.prototype.indexof
  401. // true -> Array#includes
  402. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  403. var arrayIncludes = function (IS_INCLUDES) {
  404. return function ($this, el, fromIndex) {
  405. var O = toIndexedObject($this);
  406. var length = toLength(O.length);
  407. var index = toAbsoluteIndex(fromIndex, length);
  408. var value;
  409. // Array#includes uses SameValueZero equality algorithm
  410. // eslint-disable-next-line no-self-compare
  411. if (IS_INCLUDES && el != el) while (length > index) {
  412. value = O[index++];
  413. // eslint-disable-next-line no-self-compare
  414. if (value != value) return true;
  415. // Array#indexOf ignores holes, Array#includes - not
  416. } else for (;length > index; index++) if (IS_INCLUDES || index in O) {
  417. if (O[index] === el) return IS_INCLUDES || index || 0;
  418. } return !IS_INCLUDES && -1;
  419. };
  420. };
  421. var arrayIndexOf = arrayIncludes(false);
  422. var objectKeysInternal = function (object, names) {
  423. var O = toIndexedObject(object);
  424. var i = 0;
  425. var result = [];
  426. var key;
  427. for (key in O) !has(hiddenKeys, key) && has(O, key) && result.push(key);
  428. // Don't enum bug & hidden keys
  429. while (names.length > i) if (has(O, key = names[i++])) {
  430. ~arrayIndexOf(result, key) || result.push(key);
  431. }
  432. return result;
  433. };
  434. // IE8- don't enum bug keys
  435. var enumBugKeys = [
  436. 'constructor',
  437. 'hasOwnProperty',
  438. 'isPrototypeOf',
  439. 'propertyIsEnumerable',
  440. 'toLocaleString',
  441. 'toString',
  442. 'valueOf'
  443. ];
  444. // 19.1.2.7 / 15.2.3.4 Object.getOwnPropertyNames(O)
  445. var hiddenKeys$1 = enumBugKeys.concat('length', 'prototype');
  446. var f$3 = Object.getOwnPropertyNames || function getOwnPropertyNames(O) {
  447. return objectKeysInternal(O, hiddenKeys$1);
  448. };
  449. var objectGetOwnPropertyNames = {
  450. f: f$3
  451. };
  452. var f$4 = Object.getOwnPropertySymbols;
  453. var objectGetOwnPropertySymbols = {
  454. f: f$4
  455. };
  456. var Reflect = global$1.Reflect;
  457. // all object keys, includes non-enumerable and symbols
  458. var ownKeys = Reflect && Reflect.ownKeys || function ownKeys(it) {
  459. var keys = objectGetOwnPropertyNames.f(anObject(it));
  460. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  461. return getOwnPropertySymbols ? keys.concat(getOwnPropertySymbols(it)) : keys;
  462. };
  463. var copyConstructorProperties = function (target, source) {
  464. var keys = ownKeys(source);
  465. var defineProperty = objectDefineProperty.f;
  466. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  467. for (var i = 0; i < keys.length; i++) {
  468. var key = keys[i];
  469. if (!has(target, key)) defineProperty(target, key, getOwnPropertyDescriptor(source, key));
  470. }
  471. };
  472. var replacement = /#|\.prototype\./;
  473. var isForced = function (feature, detection) {
  474. var value = data[normalize(feature)];
  475. return value == POLYFILL ? true
  476. : value == NATIVE ? false
  477. : typeof detection == 'function' ? fails(detection)
  478. : !!detection;
  479. };
  480. var normalize = isForced.normalize = function (string) {
  481. return String(string).replace(replacement, '.').toLowerCase();
  482. };
  483. var data = isForced.data = {};
  484. var NATIVE = isForced.NATIVE = 'N';
  485. var POLYFILL = isForced.POLYFILL = 'P';
  486. var isForced_1 = isForced;
  487. var getOwnPropertyDescriptor = objectGetOwnPropertyDescriptor.f;
  488. /*
  489. options.target - name of the target object
  490. options.global - target is the global object
  491. options.stat - export as static methods of target
  492. options.proto - export as prototype methods of target
  493. options.real - real prototype method for the `pure` version
  494. options.forced - export even if the native feature is available
  495. options.bind - bind methods to the target, required for the `pure` version
  496. options.wrap - wrap constructors to preventing global pollution, required for the `pure` version
  497. options.unsafe - use the simple assignment of property instead of delete + defineProperty
  498. options.sham - add a flag to not completely full polyfills
  499. options.enumerable - export as enumerable property
  500. options.noTargetGet - prevent calling a getter on target
  501. */
  502. var _export = function (options, source) {
  503. var TARGET = options.target;
  504. var GLOBAL = options.global;
  505. var STATIC = options.stat;
  506. var FORCED, target, key, targetProperty, sourceProperty, descriptor;
  507. if (GLOBAL) {
  508. target = global$1;
  509. } else if (STATIC) {
  510. target = global$1[TARGET] || setGlobal(TARGET, {});
  511. } else {
  512. target = (global$1[TARGET] || {}).prototype;
  513. }
  514. if (target) for (key in source) {
  515. sourceProperty = source[key];
  516. if (options.noTargetGet) {
  517. descriptor = getOwnPropertyDescriptor(target, key);
  518. targetProperty = descriptor && descriptor.value;
  519. } else targetProperty = target[key];
  520. FORCED = isForced_1(GLOBAL ? key : TARGET + (STATIC ? '.' : '#') + key, options.forced);
  521. // contained in target
  522. if (!FORCED && targetProperty !== undefined) {
  523. if (typeof sourceProperty === typeof targetProperty) continue;
  524. copyConstructorProperties(sourceProperty, targetProperty);
  525. }
  526. // add a flag to not completely full polyfills
  527. if (options.sham || (targetProperty && targetProperty.sham)) {
  528. hide(sourceProperty, 'sham', true);
  529. }
  530. // extend global
  531. redefine(target, key, sourceProperty, options);
  532. }
  533. };
  534. var internalFilter = arrayMethods(2);
  535. var SPECIES_SUPPORT = arrayMethodHasSpeciesSupport('filter');
  536. // `Array.prototype.filter` method
  537. // https://tc39.github.io/ecma262/#sec-array.prototype.filter
  538. // with adding support of @@species
  539. _export({ target: 'Array', proto: true, forced: !SPECIES_SUPPORT }, {
  540. filter: function filter(callbackfn /* , thisArg */) {
  541. return internalFilter(this, callbackfn, arguments[1]);
  542. }
  543. });
  544. var sloppyArrayMethod = function (METHOD_NAME, argument) {
  545. var method = [][METHOD_NAME];
  546. return !method || !fails(function () {
  547. // eslint-disable-next-line no-useless-call,no-throw-literal
  548. method.call(null, argument || function () { throw 1; }, 1);
  549. });
  550. };
  551. var nativeForEach = [].forEach;
  552. var internalForEach = arrayMethods(0);
  553. var SLOPPY_METHOD = sloppyArrayMethod('forEach');
  554. // `Array.prototype.forEach` method implementation
  555. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  556. var arrayForEach = SLOPPY_METHOD ? function forEach(callbackfn /* , thisArg */) {
  557. return internalForEach(this, callbackfn, arguments[1]);
  558. } : nativeForEach;
  559. // `Array.prototype.forEach` method
  560. // https://tc39.github.io/ecma262/#sec-array.prototype.foreach
  561. _export({ target: 'Array', proto: true, forced: [].forEach != arrayForEach }, { forEach: arrayForEach });
  562. // `Array.prototype.{ reduce, reduceRight }` methods implementation
  563. // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
  564. // https://tc39.github.io/ecma262/#sec-array.prototype.reduceright
  565. var arrayReduce = function (that, callbackfn, argumentsLength, memo, isRight) {
  566. aFunction(callbackfn);
  567. var O = toObject(that);
  568. var self = indexedObject(O);
  569. var length = toLength(O.length);
  570. var index = isRight ? length - 1 : 0;
  571. var i = isRight ? -1 : 1;
  572. if (argumentsLength < 2) while (true) {
  573. if (index in self) {
  574. memo = self[index];
  575. index += i;
  576. break;
  577. }
  578. index += i;
  579. if (isRight ? index < 0 : length <= index) {
  580. throw TypeError('Reduce of empty array with no initial value');
  581. }
  582. }
  583. for (;isRight ? index >= 0 : length > index; index += i) if (index in self) {
  584. memo = callbackfn(memo, self[index], index, O);
  585. }
  586. return memo;
  587. };
  588. var SLOPPY_METHOD$1 = sloppyArrayMethod('reduce');
  589. // `Array.prototype.reduce` method
  590. // https://tc39.github.io/ecma262/#sec-array.prototype.reduce
  591. _export({ target: 'Array', proto: true, forced: SLOPPY_METHOD$1 }, {
  592. reduce: function reduce(callbackfn /* , initialValue */) {
  593. return arrayReduce(this, callbackfn, arguments.length, arguments[1], false);
  594. }
  595. });
  596. var defineProperty = objectDefineProperty.f;
  597. var FunctionPrototype = Function.prototype;
  598. var FunctionPrototypeToString = FunctionPrototype.toString;
  599. var nameRE = /^\s*function ([^ (]*)/;
  600. var NAME = 'name';
  601. // Function instances `.name` property
  602. // https://tc39.github.io/ecma262/#sec-function-instances-name
  603. if (descriptors && !(NAME in FunctionPrototype)) {
  604. defineProperty(FunctionPrototype, NAME, {
  605. configurable: true,
  606. get: function () {
  607. try {
  608. return FunctionPrototypeToString.call(this).match(nameRE)[1];
  609. } catch (error) {
  610. return '';
  611. }
  612. }
  613. });
  614. }
  615. // 19.1.2.14 / 15.2.3.14 Object.keys(O)
  616. var objectKeys = Object.keys || function keys(O) {
  617. return objectKeysInternal(O, enumBugKeys);
  618. };
  619. // 19.1.2.1 Object.assign(target, source, ...)
  620. var nativeAssign = Object.assign;
  621. // should work with symbols and should have deterministic property order (V8 bug)
  622. var objectAssign = !nativeAssign || fails(function () {
  623. var A = {};
  624. var B = {};
  625. // eslint-disable-next-line no-undef
  626. var symbol = Symbol();
  627. var alphabet = 'abcdefghijklmnopqrst';
  628. A[symbol] = 7;
  629. alphabet.split('').forEach(function (chr) { B[chr] = chr; });
  630. return nativeAssign({}, A)[symbol] != 7 || objectKeys(nativeAssign({}, B)).join('') != alphabet;
  631. }) ? function assign(target, source) { // eslint-disable-line no-unused-vars
  632. var T = toObject(target);
  633. var argumentsLength = arguments.length;
  634. var index = 1;
  635. var getOwnPropertySymbols = objectGetOwnPropertySymbols.f;
  636. var propertyIsEnumerable = objectPropertyIsEnumerable.f;
  637. while (argumentsLength > index) {
  638. var S = indexedObject(arguments[index++]);
  639. var keys = getOwnPropertySymbols ? objectKeys(S).concat(getOwnPropertySymbols(S)) : objectKeys(S);
  640. var length = keys.length;
  641. var j = 0;
  642. var key;
  643. while (length > j) if (propertyIsEnumerable.call(S, key = keys[j++])) T[key] = S[key];
  644. } return T;
  645. } : nativeAssign;
  646. // `Object.assign` method
  647. // https://tc39.github.io/ecma262/#sec-object.assign
  648. _export({ target: 'Object', stat: true, forced: Object.assign !== objectAssign }, { assign: objectAssign });
  649. // a string of all valid unicode whitespaces
  650. // eslint-disable-next-line max-len
  651. var whitespaces = '\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF';
  652. var whitespace = '[' + whitespaces + ']';
  653. var ltrim = RegExp('^' + whitespace + whitespace + '*');
  654. var rtrim = RegExp(whitespace + whitespace + '*$');
  655. // 1 -> String#trimStart
  656. // 2 -> String#trimEnd
  657. // 3 -> String#trim
  658. var stringTrim = function (string, TYPE) {
  659. string = String(requireObjectCoercible(string));
  660. if (TYPE & 1) string = string.replace(ltrim, '');
  661. if (TYPE & 2) string = string.replace(rtrim, '');
  662. return string;
  663. };
  664. var nativeParseInt = global$1.parseInt;
  665. var hex = /^[-+]?0[xX]/;
  666. var FORCED = nativeParseInt(whitespaces + '08') !== 8 || nativeParseInt(whitespaces + '0x16') !== 22;
  667. var _parseInt = FORCED ? function parseInt(str, radix) {
  668. var string = stringTrim(String(str), 3);
  669. return nativeParseInt(string, (radix >>> 0) || (hex.test(string) ? 16 : 10));
  670. } : nativeParseInt;
  671. // `parseInt` method
  672. // https://tc39.github.io/ecma262/#sec-parseint-string-radix
  673. _export({ global: true, forced: parseInt != _parseInt }, {
  674. parseInt: _parseInt
  675. });
  676. // `RegExp.prototype.flags` getter implementation
  677. // https://tc39.github.io/ecma262/#sec-get-regexp.prototype.flags
  678. var regexpFlags = function () {
  679. var that = anObject(this);
  680. var result = '';
  681. if (that.global) result += 'g';
  682. if (that.ignoreCase) result += 'i';
  683. if (that.multiline) result += 'm';
  684. if (that.unicode) result += 'u';
  685. if (that.sticky) result += 'y';
  686. return result;
  687. };
  688. var nativeExec = RegExp.prototype.exec;
  689. // This always refers to the native implementation, because the
  690. // String#replace polyfill uses ./fix-regexp-well-known-symbol-logic.js,
  691. // which loads this file before patching the method.
  692. var nativeReplace = String.prototype.replace;
  693. var patchedExec = nativeExec;
  694. var UPDATES_LAST_INDEX_WRONG = (function () {
  695. var re1 = /a/;
  696. var re2 = /b*/g;
  697. nativeExec.call(re1, 'a');
  698. nativeExec.call(re2, 'a');
  699. return re1.lastIndex !== 0 || re2.lastIndex !== 0;
  700. })();
  701. // nonparticipating capturing group, copied from es5-shim's String#split patch.
  702. var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
  703. var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED;
  704. if (PATCH) {
  705. patchedExec = function exec(str) {
  706. var re = this;
  707. var lastIndex, reCopy, match, i;
  708. if (NPCG_INCLUDED) {
  709. reCopy = new RegExp('^' + re.source + '$(?!\\s)', regexpFlags.call(re));
  710. }
  711. if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
  712. match = nativeExec.call(re, str);
  713. if (UPDATES_LAST_INDEX_WRONG && match) {
  714. re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
  715. }
  716. if (NPCG_INCLUDED && match && match.length > 1) {
  717. // Fix browsers whose `exec` methods don't consistently return `undefined`
  718. // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
  719. nativeReplace.call(match[0], reCopy, function () {
  720. for (i = 1; i < arguments.length - 2; i++) {
  721. if (arguments[i] === undefined) match[i] = undefined;
  722. }
  723. });
  724. }
  725. return match;
  726. };
  727. }
  728. var regexpExec = patchedExec;
  729. _export({ target: 'RegExp', proto: true, forced: /./.exec !== regexpExec }, {
  730. exec: regexpExec
  731. });
  732. // CONVERT_TO_STRING: true -> String#at
  733. // CONVERT_TO_STRING: false -> String#codePointAt
  734. var stringAt = function (that, pos, CONVERT_TO_STRING) {
  735. var S = String(requireObjectCoercible(that));
  736. var position = toInteger(pos);
  737. var size = S.length;
  738. var first, second;
  739. if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
  740. first = S.charCodeAt(position);
  741. return first < 0xD800 || first > 0xDBFF || position + 1 === size
  742. || (second = S.charCodeAt(position + 1)) < 0xDC00 || second > 0xDFFF
  743. ? CONVERT_TO_STRING ? S.charAt(position) : first
  744. : CONVERT_TO_STRING ? S.slice(position, position + 2) : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
  745. };
  746. // `AdvanceStringIndex` abstract operation
  747. // https://tc39.github.io/ecma262/#sec-advancestringindex
  748. var advanceStringIndex = function (S, index, unicode) {
  749. return index + (unicode ? stringAt(S, index, true).length : 1);
  750. };
  751. // `RegExpExec` abstract operation
  752. // https://tc39.github.io/ecma262/#sec-regexpexec
  753. var regexpExecAbstract = function (R, S) {
  754. var exec = R.exec;
  755. if (typeof exec === 'function') {
  756. var result = exec.call(R, S);
  757. if (typeof result !== 'object') {
  758. throw TypeError('RegExp exec method returned something other than an Object or null');
  759. }
  760. return result;
  761. }
  762. if (classofRaw(R) !== 'RegExp') {
  763. throw TypeError('RegExp#exec called on incompatible receiver');
  764. }
  765. return regexpExec.call(R, S);
  766. };
  767. var SPECIES$2 = wellKnownSymbol('species');
  768. var REPLACE_SUPPORTS_NAMED_GROUPS = !fails(function () {
  769. // #replace needs built-in support for named groups.
  770. // #match works fine because it just return the exec results, even if it has
  771. // a "grops" property.
  772. var re = /./;
  773. re.exec = function () {
  774. var result = [];
  775. result.groups = { a: '7' };
  776. return result;
  777. };
  778. return ''.replace(re, '$<a>') !== '7';
  779. });
  780. // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
  781. // Weex JS has frozen built-in prototypes, so use try / catch wrapper
  782. var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
  783. var re = /(?:)/;
  784. var originalExec = re.exec;
  785. re.exec = function () { return originalExec.apply(this, arguments); };
  786. var result = 'ab'.split(re);
  787. return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
  788. });
  789. var fixRegexpWellKnownSymbolLogic = function (KEY, length, exec, sham) {
  790. var SYMBOL = wellKnownSymbol(KEY);
  791. var DELEGATES_TO_SYMBOL = !fails(function () {
  792. // String methods call symbol-named RegEp methods
  793. var O = {};
  794. O[SYMBOL] = function () { return 7; };
  795. return ''[KEY](O) != 7;
  796. });
  797. var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails(function () {
  798. // Symbol-named RegExp methods call .exec
  799. var execCalled = false;
  800. var re = /a/;
  801. re.exec = function () { execCalled = true; return null; };
  802. if (KEY === 'split') {
  803. // RegExp[@@split] doesn't call the regex's exec method, but first creates
  804. // a new one. We need to return the patched regex when creating the new one.
  805. re.constructor = {};
  806. re.constructor[SPECIES$2] = function () { return re; };
  807. }
  808. re[SYMBOL]('');
  809. return !execCalled;
  810. });
  811. if (
  812. !DELEGATES_TO_SYMBOL ||
  813. !DELEGATES_TO_EXEC ||
  814. (KEY === 'replace' && !REPLACE_SUPPORTS_NAMED_GROUPS) ||
  815. (KEY === 'split' && !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC)
  816. ) {
  817. var nativeRegExpMethod = /./[SYMBOL];
  818. var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
  819. if (regexp.exec === regexpExec) {
  820. if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
  821. // The native String method already delegates to @@method (this
  822. // polyfilled function), leasing to infinite recursion.
  823. // We avoid it by directly calling the native @@method method.
  824. return { done: true, value: nativeRegExpMethod.call(regexp, str, arg2) };
  825. }
  826. return { done: true, value: nativeMethod.call(str, regexp, arg2) };
  827. }
  828. return { done: false };
  829. });
  830. var stringMethod = methods[0];
  831. var regexMethod = methods[1];
  832. redefine(String.prototype, KEY, stringMethod);
  833. redefine(RegExp.prototype, SYMBOL, length == 2
  834. // 21.2.5.8 RegExp.prototype[@@replace](string, replaceValue)
  835. // 21.2.5.11 RegExp.prototype[@@split](string, limit)
  836. ? function (string, arg) { return regexMethod.call(string, this, arg); }
  837. // 21.2.5.6 RegExp.prototype[@@match](string)
  838. // 21.2.5.9 RegExp.prototype[@@search](string)
  839. : function (string) { return regexMethod.call(string, this); }
  840. );
  841. if (sham) hide(RegExp.prototype[SYMBOL], 'sham', true);
  842. }
  843. };
  844. // @@match logic
  845. fixRegexpWellKnownSymbolLogic(
  846. 'match',
  847. 1,
  848. function (MATCH, nativeMatch, maybeCallNative) {
  849. return [
  850. // `String.prototype.match` method
  851. // https://tc39.github.io/ecma262/#sec-string.prototype.match
  852. function match(regexp) {
  853. var O = requireObjectCoercible(this);
  854. var matcher = regexp == undefined ? undefined : regexp[MATCH];
  855. return matcher !== undefined ? matcher.call(regexp, O) : new RegExp(regexp)[MATCH](String(O));
  856. },
  857. // `RegExp.prototype[@@match]` method
  858. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@match
  859. function (regexp) {
  860. var res = maybeCallNative(nativeMatch, regexp, this);
  861. if (res.done) return res.value;
  862. var rx = anObject(regexp);
  863. var S = String(this);
  864. if (!rx.global) return regexpExecAbstract(rx, S);
  865. var fullUnicode = rx.unicode;
  866. rx.lastIndex = 0;
  867. var A = [];
  868. var n = 0;
  869. var result;
  870. while ((result = regexpExecAbstract(rx, S)) !== null) {
  871. var matchStr = String(result[0]);
  872. A[n] = matchStr;
  873. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  874. n++;
  875. }
  876. return n === 0 ? null : A;
  877. }
  878. ];
  879. }
  880. );
  881. var max$1 = Math.max;
  882. var min$2 = Math.min;
  883. var floor$1 = Math.floor;
  884. var SUBSTITUTION_SYMBOLS = /\$([$&`']|\d\d?|<[^>]*>)/g;
  885. var SUBSTITUTION_SYMBOLS_NO_NAMED = /\$([$&`']|\d\d?)/g;
  886. var maybeToString = function (it) {
  887. return it === undefined ? it : String(it);
  888. };
  889. // @@replace logic
  890. fixRegexpWellKnownSymbolLogic(
  891. 'replace',
  892. 2,
  893. function (REPLACE, nativeReplace, maybeCallNative) {
  894. return [
  895. // `String.prototype.replace` method
  896. // https://tc39.github.io/ecma262/#sec-string.prototype.replace
  897. function replace(searchValue, replaceValue) {
  898. var O = requireObjectCoercible(this);
  899. var replacer = searchValue == undefined ? undefined : searchValue[REPLACE];
  900. return replacer !== undefined
  901. ? replacer.call(searchValue, O, replaceValue)
  902. : nativeReplace.call(String(O), searchValue, replaceValue);
  903. },
  904. // `RegExp.prototype[@@replace]` method
  905. // https://tc39.github.io/ecma262/#sec-regexp.prototype-@@replace
  906. function (regexp, replaceValue) {
  907. var res = maybeCallNative(nativeReplace, regexp, this, replaceValue);
  908. if (res.done) return res.value;
  909. var rx = anObject(regexp);
  910. var S = String(this);
  911. var functionalReplace = typeof replaceValue === 'function';
  912. if (!functionalReplace) replaceValue = String(replaceValue);
  913. var global = rx.global;
  914. if (global) {
  915. var fullUnicode = rx.unicode;
  916. rx.lastIndex = 0;
  917. }
  918. var results = [];
  919. while (true) {
  920. var result = regexpExecAbstract(rx, S);
  921. if (result === null) break;
  922. results.push(result);
  923. if (!global) break;
  924. var matchStr = String(result[0]);
  925. if (matchStr === '') rx.lastIndex = advanceStringIndex(S, toLength(rx.lastIndex), fullUnicode);
  926. }
  927. var accumulatedResult = '';
  928. var nextSourcePosition = 0;
  929. for (var i = 0; i < results.length; i++) {
  930. result = results[i];
  931. var matched = String(result[0]);
  932. var position = max$1(min$2(toInteger(result.index), S.length), 0);
  933. var captures = [];
  934. // NOTE: This is equivalent to
  935. // captures = result.slice(1).map(maybeToString)
  936. // but for some reason `nativeSlice.call(result, 1, result.length)` (called in
  937. // the slice polyfill when slicing native arrays) "doesn't work" in safari 9 and
  938. // causes a crash (https://pastebin.com/N21QzeQA) when trying to debug it.
  939. for (var j = 1; j < result.length; j++) captures.push(maybeToString(result[j]));
  940. var namedCaptures = result.groups;
  941. if (functionalReplace) {
  942. var replacerArgs = [matched].concat(captures, position, S);
  943. if (namedCaptures !== undefined) replacerArgs.push(namedCaptures);
  944. var replacement = String(replaceValue.apply(undefined, replacerArgs));
  945. } else {
  946. replacement = getSubstitution(matched, S, position, captures, namedCaptures, replaceValue);
  947. }
  948. if (position >= nextSourcePosition) {
  949. accumulatedResult += S.slice(nextSourcePosition, position) + replacement;
  950. nextSourcePosition = position + matched.length;
  951. }
  952. }
  953. return accumulatedResult + S.slice(nextSourcePosition);
  954. }
  955. ];
  956. // https://tc39.github.io/ecma262/#sec-getsubstitution
  957. function getSubstitution(matched, str, position, captures, namedCaptures, replacement) {
  958. var tailPos = position + matched.length;
  959. var m = captures.length;
  960. var symbols = SUBSTITUTION_SYMBOLS_NO_NAMED;
  961. if (namedCaptures !== undefined) {
  962. namedCaptures = toObject(namedCaptures);
  963. symbols = SUBSTITUTION_SYMBOLS;
  964. }
  965. return nativeReplace.call(replacement, symbols, function (match, ch) {
  966. var capture;
  967. switch (ch.charAt(0)) {
  968. case '$': return '$';
  969. case '&': return matched;
  970. case '`': return str.slice(0, position);
  971. case "'": return str.slice(tailPos);
  972. case '<':
  973. capture = namedCaptures[ch.slice(1, -1)];
  974. break;
  975. default: // \d\d?
  976. var n = +ch;
  977. if (n === 0) return match;
  978. if (n > m) {
  979. var f = floor$1(n / 10);
  980. if (f === 0) return match;
  981. if (f <= m) return captures[f - 1] === undefined ? ch.charAt(1) : captures[f - 1] + ch.charAt(1);
  982. return match;
  983. }
  984. capture = captures[n - 1];
  985. }
  986. return capture === undefined ? '' : capture;
  987. });
  988. }
  989. }
  990. );
  991. // iterable DOM collections
  992. // flag - `iterable` interface - 'entries', 'keys', 'values', 'forEach' methods
  993. var domIterables = {
  994. CSSRuleList: 0,
  995. CSSStyleDeclaration: 0,
  996. CSSValueList: 0,
  997. ClientRectList: 0,
  998. DOMRectList: 0,
  999. DOMStringList: 0,
  1000. DOMTokenList: 1,
  1001. DataTransferItemList: 0,
  1002. FileList: 0,
  1003. HTMLAllCollection: 0,
  1004. HTMLCollection: 0,
  1005. HTMLFormElement: 0,
  1006. HTMLSelectElement: 0,
  1007. MediaList: 0,
  1008. MimeTypeArray: 0,
  1009. NamedNodeMap: 0,
  1010. NodeList: 1,
  1011. PaintRequestList: 0,
  1012. Plugin: 0,
  1013. PluginArray: 0,
  1014. SVGLengthList: 0,
  1015. SVGNumberList: 0,
  1016. SVGPathSegList: 0,
  1017. SVGPointList: 0,
  1018. SVGStringList: 0,
  1019. SVGTransformList: 0,
  1020. SourceBufferList: 0,
  1021. StyleSheetList: 0,
  1022. TextTrackCueList: 0,
  1023. TextTrackList: 0,
  1024. TouchList: 0
  1025. };
  1026. for (var COLLECTION_NAME in domIterables) {
  1027. var Collection = global$1[COLLECTION_NAME];
  1028. var CollectionPrototype = Collection && Collection.prototype;
  1029. // some Chrome versions have non-configurable methods on DOMTokenList
  1030. if (CollectionPrototype && CollectionPrototype.forEach !== arrayForEach) try {
  1031. hide(CollectionPrototype, 'forEach', arrayForEach);
  1032. } catch (error) {
  1033. CollectionPrototype.forEach = arrayForEach;
  1034. }
  1035. }
  1036. /**
  1037. * lodash (Custom Build) <https://lodash.com/>
  1038. * Build: `lodash modularize exports="npm" -o ./`
  1039. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1040. * Released under MIT license <https://lodash.com/license>
  1041. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1042. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1043. */
  1044. /** Used as the `TypeError` message for "Functions" methods. */
  1045. var FUNC_ERROR_TEXT = 'Expected a function';
  1046. /** Used as references for various `Number` constants. */
  1047. var NAN = 0 / 0;
  1048. /** `Object#toString` result references. */
  1049. var symbolTag = '[object Symbol]';
  1050. /** Used to match leading and trailing whitespace. */
  1051. var reTrim = /^\s+|\s+$/g;
  1052. /** Used to detect bad signed hexadecimal string values. */
  1053. var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
  1054. /** Used to detect binary string values. */
  1055. var reIsBinary = /^0b[01]+$/i;
  1056. /** Used to detect octal string values. */
  1057. var reIsOctal = /^0o[0-7]+$/i;
  1058. /** Built-in method references without a dependency on `root`. */
  1059. var freeParseInt = parseInt;
  1060. /** Detect free variable `global` from Node.js. */
  1061. var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1062. /** Detect free variable `self`. */
  1063. var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
  1064. /** Used as a reference to the global object. */
  1065. var root = freeGlobal || freeSelf || Function('return this')();
  1066. /** Used for built-in method references. */
  1067. var objectProto = Object.prototype;
  1068. /**
  1069. * Used to resolve the
  1070. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1071. * of values.
  1072. */
  1073. var objectToString = objectProto.toString;
  1074. /* Built-in method references for those with the same name as other `lodash` methods. */
  1075. var nativeMax = Math.max,
  1076. nativeMin = Math.min;
  1077. /**
  1078. * Gets the timestamp of the number of milliseconds that have elapsed since
  1079. * the Unix epoch (1 January 1970 00:00:00 UTC).
  1080. *
  1081. * @static
  1082. * @memberOf _
  1083. * @since 2.4.0
  1084. * @category Date
  1085. * @returns {number} Returns the timestamp.
  1086. * @example
  1087. *
  1088. * _.defer(function(stamp) {
  1089. * console.log(_.now() - stamp);
  1090. * }, _.now());
  1091. * // => Logs the number of milliseconds it took for the deferred invocation.
  1092. */
  1093. var now = function() {
  1094. return root.Date.now();
  1095. };
  1096. /**
  1097. * Creates a debounced function that delays invoking `func` until after `wait`
  1098. * milliseconds have elapsed since the last time the debounced function was
  1099. * invoked. The debounced function comes with a `cancel` method to cancel
  1100. * delayed `func` invocations and a `flush` method to immediately invoke them.
  1101. * Provide `options` to indicate whether `func` should be invoked on the
  1102. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  1103. * with the last arguments provided to the debounced function. Subsequent
  1104. * calls to the debounced function return the result of the last `func`
  1105. * invocation.
  1106. *
  1107. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1108. * invoked on the trailing edge of the timeout only if the debounced function
  1109. * is invoked more than once during the `wait` timeout.
  1110. *
  1111. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1112. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1113. *
  1114. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1115. * for details over the differences between `_.debounce` and `_.throttle`.
  1116. *
  1117. * @static
  1118. * @memberOf _
  1119. * @since 0.1.0
  1120. * @category Function
  1121. * @param {Function} func The function to debounce.
  1122. * @param {number} [wait=0] The number of milliseconds to delay.
  1123. * @param {Object} [options={}] The options object.
  1124. * @param {boolean} [options.leading=false]
  1125. * Specify invoking on the leading edge of the timeout.
  1126. * @param {number} [options.maxWait]
  1127. * The maximum time `func` is allowed to be delayed before it's invoked.
  1128. * @param {boolean} [options.trailing=true]
  1129. * Specify invoking on the trailing edge of the timeout.
  1130. * @returns {Function} Returns the new debounced function.
  1131. * @example
  1132. *
  1133. * // Avoid costly calculations while the window size is in flux.
  1134. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  1135. *
  1136. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  1137. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  1138. * 'leading': true,
  1139. * 'trailing': false
  1140. * }));
  1141. *
  1142. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  1143. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  1144. * var source = new EventSource('/stream');
  1145. * jQuery(source).on('message', debounced);
  1146. *
  1147. * // Cancel the trailing debounced invocation.
  1148. * jQuery(window).on('popstate', debounced.cancel);
  1149. */
  1150. function debounce(func, wait, options) {
  1151. var lastArgs,
  1152. lastThis,
  1153. maxWait,
  1154. result,
  1155. timerId,
  1156. lastCallTime,
  1157. lastInvokeTime = 0,
  1158. leading = false,
  1159. maxing = false,
  1160. trailing = true;
  1161. if (typeof func != 'function') {
  1162. throw new TypeError(FUNC_ERROR_TEXT);
  1163. }
  1164. wait = toNumber(wait) || 0;
  1165. if (isObject$1(options)) {
  1166. leading = !!options.leading;
  1167. maxing = 'maxWait' in options;
  1168. maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
  1169. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1170. }
  1171. function invokeFunc(time) {
  1172. var args = lastArgs,
  1173. thisArg = lastThis;
  1174. lastArgs = lastThis = undefined;
  1175. lastInvokeTime = time;
  1176. result = func.apply(thisArg, args);
  1177. return result;
  1178. }
  1179. function leadingEdge(time) {
  1180. // Reset any `maxWait` timer.
  1181. lastInvokeTime = time;
  1182. // Start the timer for the trailing edge.
  1183. timerId = setTimeout(timerExpired, wait);
  1184. // Invoke the leading edge.
  1185. return leading ? invokeFunc(time) : result;
  1186. }
  1187. function remainingWait(time) {
  1188. var timeSinceLastCall = time - lastCallTime,
  1189. timeSinceLastInvoke = time - lastInvokeTime,
  1190. result = wait - timeSinceLastCall;
  1191. return maxing ? nativeMin(result, maxWait - timeSinceLastInvoke) : result;
  1192. }
  1193. function shouldInvoke(time) {
  1194. var timeSinceLastCall = time - lastCallTime,
  1195. timeSinceLastInvoke = time - lastInvokeTime;
  1196. // Either this is the first call, activity has stopped and we're at the
  1197. // trailing edge, the system time has gone backwards and we're treating
  1198. // it as the trailing edge, or we've hit the `maxWait` limit.
  1199. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  1200. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  1201. }
  1202. function timerExpired() {
  1203. var time = now();
  1204. if (shouldInvoke(time)) {
  1205. return trailingEdge(time);
  1206. }
  1207. // Restart the timer.
  1208. timerId = setTimeout(timerExpired, remainingWait(time));
  1209. }
  1210. function trailingEdge(time) {
  1211. timerId = undefined;
  1212. // Only invoke if we have `lastArgs` which means `func` has been
  1213. // debounced at least once.
  1214. if (trailing && lastArgs) {
  1215. return invokeFunc(time);
  1216. }
  1217. lastArgs = lastThis = undefined;
  1218. return result;
  1219. }
  1220. function cancel() {
  1221. if (timerId !== undefined) {
  1222. clearTimeout(timerId);
  1223. }
  1224. lastInvokeTime = 0;
  1225. lastArgs = lastCallTime = lastThis = timerId = undefined;
  1226. }
  1227. function flush() {
  1228. return timerId === undefined ? result : trailingEdge(now());
  1229. }
  1230. function debounced() {
  1231. var time = now(),
  1232. isInvoking = shouldInvoke(time);
  1233. lastArgs = arguments;
  1234. lastThis = this;
  1235. lastCallTime = time;
  1236. if (isInvoking) {
  1237. if (timerId === undefined) {
  1238. return leadingEdge(lastCallTime);
  1239. }
  1240. if (maxing) {
  1241. // Handle invocations in a tight loop.
  1242. timerId = setTimeout(timerExpired, wait);
  1243. return invokeFunc(lastCallTime);
  1244. }
  1245. }
  1246. if (timerId === undefined) {
  1247. timerId = setTimeout(timerExpired, wait);
  1248. }
  1249. return result;
  1250. }
  1251. debounced.cancel = cancel;
  1252. debounced.flush = flush;
  1253. return debounced;
  1254. }
  1255. /**
  1256. * Creates a throttled function that only invokes `func` at most once per
  1257. * every `wait` milliseconds. The throttled function comes with a `cancel`
  1258. * method to cancel delayed `func` invocations and a `flush` method to
  1259. * immediately invoke them. Provide `options` to indicate whether `func`
  1260. * should be invoked on the leading and/or trailing edge of the `wait`
  1261. * timeout. The `func` is invoked with the last arguments provided to the
  1262. * throttled function. Subsequent calls to the throttled function return the
  1263. * result of the last `func` invocation.
  1264. *
  1265. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1266. * invoked on the trailing edge of the timeout only if the throttled function
  1267. * is invoked more than once during the `wait` timeout.
  1268. *
  1269. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1270. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1271. *
  1272. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1273. * for details over the differences between `_.throttle` and `_.debounce`.
  1274. *
  1275. * @static
  1276. * @memberOf _
  1277. * @since 0.1.0
  1278. * @category Function
  1279. * @param {Function} func The function to throttle.
  1280. * @param {number} [wait=0] The number of milliseconds to throttle invocations to.
  1281. * @param {Object} [options={}] The options object.
  1282. * @param {boolean} [options.leading=true]
  1283. * Specify invoking on the leading edge of the timeout.
  1284. * @param {boolean} [options.trailing=true]
  1285. * Specify invoking on the trailing edge of the timeout.
  1286. * @returns {Function} Returns the new throttled function.
  1287. * @example
  1288. *
  1289. * // Avoid excessively updating the position while scrolling.
  1290. * jQuery(window).on('scroll', _.throttle(updatePosition, 100));
  1291. *
  1292. * // Invoke `renewToken` when the click event is fired, but not more than once every 5 minutes.
  1293. * var throttled = _.throttle(renewToken, 300000, { 'trailing': false });
  1294. * jQuery(element).on('click', throttled);
  1295. *
  1296. * // Cancel the trailing throttled invocation.
  1297. * jQuery(window).on('popstate', throttled.cancel);
  1298. */
  1299. function throttle(func, wait, options) {
  1300. var leading = true,
  1301. trailing = true;
  1302. if (typeof func != 'function') {
  1303. throw new TypeError(FUNC_ERROR_TEXT);
  1304. }
  1305. if (isObject$1(options)) {
  1306. leading = 'leading' in options ? !!options.leading : leading;
  1307. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1308. }
  1309. return debounce(func, wait, {
  1310. 'leading': leading,
  1311. 'maxWait': wait,
  1312. 'trailing': trailing
  1313. });
  1314. }
  1315. /**
  1316. * Checks if `value` is the
  1317. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1318. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1319. *
  1320. * @static
  1321. * @memberOf _
  1322. * @since 0.1.0
  1323. * @category Lang
  1324. * @param {*} value The value to check.
  1325. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1326. * @example
  1327. *
  1328. * _.isObject({});
  1329. * // => true
  1330. *
  1331. * _.isObject([1, 2, 3]);
  1332. * // => true
  1333. *
  1334. * _.isObject(_.noop);
  1335. * // => true
  1336. *
  1337. * _.isObject(null);
  1338. * // => false
  1339. */
  1340. function isObject$1(value) {
  1341. var type = typeof value;
  1342. return !!value && (type == 'object' || type == 'function');
  1343. }
  1344. /**
  1345. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1346. * and has a `typeof` result of "object".
  1347. *
  1348. * @static
  1349. * @memberOf _
  1350. * @since 4.0.0
  1351. * @category Lang
  1352. * @param {*} value The value to check.
  1353. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1354. * @example
  1355. *
  1356. * _.isObjectLike({});
  1357. * // => true
  1358. *
  1359. * _.isObjectLike([1, 2, 3]);
  1360. * // => true
  1361. *
  1362. * _.isObjectLike(_.noop);
  1363. * // => false
  1364. *
  1365. * _.isObjectLike(null);
  1366. * // => false
  1367. */
  1368. function isObjectLike(value) {
  1369. return !!value && typeof value == 'object';
  1370. }
  1371. /**
  1372. * Checks if `value` is classified as a `Symbol` primitive or object.
  1373. *
  1374. * @static
  1375. * @memberOf _
  1376. * @since 4.0.0
  1377. * @category Lang
  1378. * @param {*} value The value to check.
  1379. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  1380. * @example
  1381. *
  1382. * _.isSymbol(Symbol.iterator);
  1383. * // => true
  1384. *
  1385. * _.isSymbol('abc');
  1386. * // => false
  1387. */
  1388. function isSymbol(value) {
  1389. return typeof value == 'symbol' ||
  1390. (isObjectLike(value) && objectToString.call(value) == symbolTag);
  1391. }
  1392. /**
  1393. * Converts `value` to a number.
  1394. *
  1395. * @static
  1396. * @memberOf _
  1397. * @since 4.0.0
  1398. * @category Lang
  1399. * @param {*} value The value to process.
  1400. * @returns {number} Returns the number.
  1401. * @example
  1402. *
  1403. * _.toNumber(3.2);
  1404. * // => 3.2
  1405. *
  1406. * _.toNumber(Number.MIN_VALUE);
  1407. * // => 5e-324
  1408. *
  1409. * _.toNumber(Infinity);
  1410. * // => Infinity
  1411. *
  1412. * _.toNumber('3.2');
  1413. * // => 3.2
  1414. */
  1415. function toNumber(value) {
  1416. if (typeof value == 'number') {
  1417. return value;
  1418. }
  1419. if (isSymbol(value)) {
  1420. return NAN;
  1421. }
  1422. if (isObject$1(value)) {
  1423. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  1424. value = isObject$1(other) ? (other + '') : other;
  1425. }
  1426. if (typeof value != 'string') {
  1427. return value === 0 ? value : +value;
  1428. }
  1429. value = value.replace(reTrim, '');
  1430. var isBinary = reIsBinary.test(value);
  1431. return (isBinary || reIsOctal.test(value))
  1432. ? freeParseInt(value.slice(2), isBinary ? 2 : 8)
  1433. : (reIsBadHex.test(value) ? NAN : +value);
  1434. }
  1435. var lodash_throttle = throttle;
  1436. /**
  1437. * lodash (Custom Build) <https://lodash.com/>
  1438. * Build: `lodash modularize exports="npm" -o ./`
  1439. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1440. * Released under MIT license <https://lodash.com/license>
  1441. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1442. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1443. */
  1444. /** Used as the `TypeError` message for "Functions" methods. */
  1445. var FUNC_ERROR_TEXT$1 = 'Expected a function';
  1446. /** Used as references for various `Number` constants. */
  1447. var NAN$1 = 0 / 0;
  1448. /** `Object#toString` result references. */
  1449. var symbolTag$1 = '[object Symbol]';
  1450. /** Used to match leading and trailing whitespace. */
  1451. var reTrim$1 = /^\s+|\s+$/g;
  1452. /** Used to detect bad signed hexadecimal string values. */
  1453. var reIsBadHex$1 = /^[-+]0x[0-9a-f]+$/i;
  1454. /** Used to detect binary string values. */
  1455. var reIsBinary$1 = /^0b[01]+$/i;
  1456. /** Used to detect octal string values. */
  1457. var reIsOctal$1 = /^0o[0-7]+$/i;
  1458. /** Built-in method references without a dependency on `root`. */
  1459. var freeParseInt$1 = parseInt;
  1460. /** Detect free variable `global` from Node.js. */
  1461. var freeGlobal$1 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1462. /** Detect free variable `self`. */
  1463. var freeSelf$1 = typeof self == 'object' && self && self.Object === Object && self;
  1464. /** Used as a reference to the global object. */
  1465. var root$1 = freeGlobal$1 || freeSelf$1 || Function('return this')();
  1466. /** Used for built-in method references. */
  1467. var objectProto$1 = Object.prototype;
  1468. /**
  1469. * Used to resolve the
  1470. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1471. * of values.
  1472. */
  1473. var objectToString$1 = objectProto$1.toString;
  1474. /* Built-in method references for those with the same name as other `lodash` methods. */
  1475. var nativeMax$1 = Math.max,
  1476. nativeMin$1 = Math.min;
  1477. /**
  1478. * Gets the timestamp of the number of milliseconds that have elapsed since
  1479. * the Unix epoch (1 January 1970 00:00:00 UTC).
  1480. *
  1481. * @static
  1482. * @memberOf _
  1483. * @since 2.4.0
  1484. * @category Date
  1485. * @returns {number} Returns the timestamp.
  1486. * @example
  1487. *
  1488. * _.defer(function(stamp) {
  1489. * console.log(_.now() - stamp);
  1490. * }, _.now());
  1491. * // => Logs the number of milliseconds it took for the deferred invocation.
  1492. */
  1493. var now$1 = function() {
  1494. return root$1.Date.now();
  1495. };
  1496. /**
  1497. * Creates a debounced function that delays invoking `func` until after `wait`
  1498. * milliseconds have elapsed since the last time the debounced function was
  1499. * invoked. The debounced function comes with a `cancel` method to cancel
  1500. * delayed `func` invocations and a `flush` method to immediately invoke them.
  1501. * Provide `options` to indicate whether `func` should be invoked on the
  1502. * leading and/or trailing edge of the `wait` timeout. The `func` is invoked
  1503. * with the last arguments provided to the debounced function. Subsequent
  1504. * calls to the debounced function return the result of the last `func`
  1505. * invocation.
  1506. *
  1507. * **Note:** If `leading` and `trailing` options are `true`, `func` is
  1508. * invoked on the trailing edge of the timeout only if the debounced function
  1509. * is invoked more than once during the `wait` timeout.
  1510. *
  1511. * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
  1512. * until to the next tick, similar to `setTimeout` with a timeout of `0`.
  1513. *
  1514. * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
  1515. * for details over the differences between `_.debounce` and `_.throttle`.
  1516. *
  1517. * @static
  1518. * @memberOf _
  1519. * @since 0.1.0
  1520. * @category Function
  1521. * @param {Function} func The function to debounce.
  1522. * @param {number} [wait=0] The number of milliseconds to delay.
  1523. * @param {Object} [options={}] The options object.
  1524. * @param {boolean} [options.leading=false]
  1525. * Specify invoking on the leading edge of the timeout.
  1526. * @param {number} [options.maxWait]
  1527. * The maximum time `func` is allowed to be delayed before it's invoked.
  1528. * @param {boolean} [options.trailing=true]
  1529. * Specify invoking on the trailing edge of the timeout.
  1530. * @returns {Function} Returns the new debounced function.
  1531. * @example
  1532. *
  1533. * // Avoid costly calculations while the window size is in flux.
  1534. * jQuery(window).on('resize', _.debounce(calculateLayout, 150));
  1535. *
  1536. * // Invoke `sendMail` when clicked, debouncing subsequent calls.
  1537. * jQuery(element).on('click', _.debounce(sendMail, 300, {
  1538. * 'leading': true,
  1539. * 'trailing': false
  1540. * }));
  1541. *
  1542. * // Ensure `batchLog` is invoked once after 1 second of debounced calls.
  1543. * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
  1544. * var source = new EventSource('/stream');
  1545. * jQuery(source).on('message', debounced);
  1546. *
  1547. * // Cancel the trailing debounced invocation.
  1548. * jQuery(window).on('popstate', debounced.cancel);
  1549. */
  1550. function debounce$1(func, wait, options) {
  1551. var lastArgs,
  1552. lastThis,
  1553. maxWait,
  1554. result,
  1555. timerId,
  1556. lastCallTime,
  1557. lastInvokeTime = 0,
  1558. leading = false,
  1559. maxing = false,
  1560. trailing = true;
  1561. if (typeof func != 'function') {
  1562. throw new TypeError(FUNC_ERROR_TEXT$1);
  1563. }
  1564. wait = toNumber$1(wait) || 0;
  1565. if (isObject$2(options)) {
  1566. leading = !!options.leading;
  1567. maxing = 'maxWait' in options;
  1568. maxWait = maxing ? nativeMax$1(toNumber$1(options.maxWait) || 0, wait) : maxWait;
  1569. trailing = 'trailing' in options ? !!options.trailing : trailing;
  1570. }
  1571. function invokeFunc(time) {
  1572. var args = lastArgs,
  1573. thisArg = lastThis;
  1574. lastArgs = lastThis = undefined;
  1575. lastInvokeTime = time;
  1576. result = func.apply(thisArg, args);
  1577. return result;
  1578. }
  1579. function leadingEdge(time) {
  1580. // Reset any `maxWait` timer.
  1581. lastInvokeTime = time;
  1582. // Start the timer for the trailing edge.
  1583. timerId = setTimeout(timerExpired, wait);
  1584. // Invoke the leading edge.
  1585. return leading ? invokeFunc(time) : result;
  1586. }
  1587. function remainingWait(time) {
  1588. var timeSinceLastCall = time - lastCallTime,
  1589. timeSinceLastInvoke = time - lastInvokeTime,
  1590. result = wait - timeSinceLastCall;
  1591. return maxing ? nativeMin$1(result, maxWait - timeSinceLastInvoke) : result;
  1592. }
  1593. function shouldInvoke(time) {
  1594. var timeSinceLastCall = time - lastCallTime,
  1595. timeSinceLastInvoke = time - lastInvokeTime;
  1596. // Either this is the first call, activity has stopped and we're at the
  1597. // trailing edge, the system time has gone backwards and we're treating
  1598. // it as the trailing edge, or we've hit the `maxWait` limit.
  1599. return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
  1600. (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
  1601. }
  1602. function timerExpired() {
  1603. var time = now$1();
  1604. if (shouldInvoke(time)) {
  1605. return trailingEdge(time);
  1606. }
  1607. // Restart the timer.
  1608. timerId = setTimeout(timerExpired, remainingWait(time));
  1609. }
  1610. function trailingEdge(time) {
  1611. timerId = undefined;
  1612. // Only invoke if we have `lastArgs` which means `func` has been
  1613. // debounced at least once.
  1614. if (trailing && lastArgs) {
  1615. return invokeFunc(time);
  1616. }
  1617. lastArgs = lastThis = undefined;
  1618. return result;
  1619. }
  1620. function cancel() {
  1621. if (timerId !== undefined) {
  1622. clearTimeout(timerId);
  1623. }
  1624. lastInvokeTime = 0;
  1625. lastArgs = lastCallTime = lastThis = timerId = undefined;
  1626. }
  1627. function flush() {
  1628. return timerId === undefined ? result : trailingEdge(now$1());
  1629. }
  1630. function debounced() {
  1631. var time = now$1(),
  1632. isInvoking = shouldInvoke(time);
  1633. lastArgs = arguments;
  1634. lastThis = this;
  1635. lastCallTime = time;
  1636. if (isInvoking) {
  1637. if (timerId === undefined) {
  1638. return leadingEdge(lastCallTime);
  1639. }
  1640. if (maxing) {
  1641. // Handle invocations in a tight loop.
  1642. timerId = setTimeout(timerExpired, wait);
  1643. return invokeFunc(lastCallTime);
  1644. }
  1645. }
  1646. if (timerId === undefined) {
  1647. timerId = setTimeout(timerExpired, wait);
  1648. }
  1649. return result;
  1650. }
  1651. debounced.cancel = cancel;
  1652. debounced.flush = flush;
  1653. return debounced;
  1654. }
  1655. /**
  1656. * Checks if `value` is the
  1657. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  1658. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  1659. *
  1660. * @static
  1661. * @memberOf _
  1662. * @since 0.1.0
  1663. * @category Lang
  1664. * @param {*} value The value to check.
  1665. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  1666. * @example
  1667. *
  1668. * _.isObject({});
  1669. * // => true
  1670. *
  1671. * _.isObject([1, 2, 3]);
  1672. * // => true
  1673. *
  1674. * _.isObject(_.noop);
  1675. * // => true
  1676. *
  1677. * _.isObject(null);
  1678. * // => false
  1679. */
  1680. function isObject$2(value) {
  1681. var type = typeof value;
  1682. return !!value && (type == 'object' || type == 'function');
  1683. }
  1684. /**
  1685. * Checks if `value` is object-like. A value is object-like if it's not `null`
  1686. * and has a `typeof` result of "object".
  1687. *
  1688. * @static
  1689. * @memberOf _
  1690. * @since 4.0.0
  1691. * @category Lang
  1692. * @param {*} value The value to check.
  1693. * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
  1694. * @example
  1695. *
  1696. * _.isObjectLike({});
  1697. * // => true
  1698. *
  1699. * _.isObjectLike([1, 2, 3]);
  1700. * // => true
  1701. *
  1702. * _.isObjectLike(_.noop);
  1703. * // => false
  1704. *
  1705. * _.isObjectLike(null);
  1706. * // => false
  1707. */
  1708. function isObjectLike$1(value) {
  1709. return !!value && typeof value == 'object';
  1710. }
  1711. /**
  1712. * Checks if `value` is classified as a `Symbol` primitive or object.
  1713. *
  1714. * @static
  1715. * @memberOf _
  1716. * @since 4.0.0
  1717. * @category Lang
  1718. * @param {*} value The value to check.
  1719. * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
  1720. * @example
  1721. *
  1722. * _.isSymbol(Symbol.iterator);
  1723. * // => true
  1724. *
  1725. * _.isSymbol('abc');
  1726. * // => false
  1727. */
  1728. function isSymbol$1(value) {
  1729. return typeof value == 'symbol' ||
  1730. (isObjectLike$1(value) && objectToString$1.call(value) == symbolTag$1);
  1731. }
  1732. /**
  1733. * Converts `value` to a number.
  1734. *
  1735. * @static
  1736. * @memberOf _
  1737. * @since 4.0.0
  1738. * @category Lang
  1739. * @param {*} value The value to process.
  1740. * @returns {number} Returns the number.
  1741. * @example
  1742. *
  1743. * _.toNumber(3.2);
  1744. * // => 3.2
  1745. *
  1746. * _.toNumber(Number.MIN_VALUE);
  1747. * // => 5e-324
  1748. *
  1749. * _.toNumber(Infinity);
  1750. * // => Infinity
  1751. *
  1752. * _.toNumber('3.2');
  1753. * // => 3.2
  1754. */
  1755. function toNumber$1(value) {
  1756. if (typeof value == 'number') {
  1757. return value;
  1758. }
  1759. if (isSymbol$1(value)) {
  1760. return NAN$1;
  1761. }
  1762. if (isObject$2(value)) {
  1763. var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
  1764. value = isObject$2(other) ? (other + '') : other;
  1765. }
  1766. if (typeof value != 'string') {
  1767. return value === 0 ? value : +value;
  1768. }
  1769. value = value.replace(reTrim$1, '');
  1770. var isBinary = reIsBinary$1.test(value);
  1771. return (isBinary || reIsOctal$1.test(value))
  1772. ? freeParseInt$1(value.slice(2), isBinary ? 2 : 8)
  1773. : (reIsBadHex$1.test(value) ? NAN$1 : +value);
  1774. }
  1775. var lodash_debounce = debounce$1;
  1776. /**
  1777. * lodash (Custom Build) <https://lodash.com/>
  1778. * Build: `lodash modularize exports="npm" -o ./`
  1779. * Copyright jQuery Foundation and other contributors <https://jquery.org/>
  1780. * Released under MIT license <https://lodash.com/license>
  1781. * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
  1782. * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
  1783. */
  1784. /** Used as the `TypeError` message for "Functions" methods. */
  1785. var FUNC_ERROR_TEXT$2 = 'Expected a function';
  1786. /** Used to stand-in for `undefined` hash values. */
  1787. var HASH_UNDEFINED = '__lodash_hash_undefined__';
  1788. /** `Object#toString` result references. */
  1789. var funcTag = '[object Function]',
  1790. genTag = '[object GeneratorFunction]';
  1791. /**
  1792. * Used to match `RegExp`
  1793. * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
  1794. */
  1795. var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
  1796. /** Used to detect host constructors (Safari). */
  1797. var reIsHostCtor = /^\[object .+?Constructor\]$/;
  1798. /** Detect free variable `global` from Node.js. */
  1799. var freeGlobal$2 = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
  1800. /** Detect free variable `self`. */
  1801. var freeSelf$2 = typeof self == 'object' && self && self.Object === Object && self;
  1802. /** Used as a reference to the global object. */
  1803. var root$2 = freeGlobal$2 || freeSelf$2 || Function('return this')();
  1804. /**
  1805. * Gets the value at `key` of `object`.
  1806. *
  1807. * @private
  1808. * @param {Object} [object] The object to query.
  1809. * @param {string} key The key of the property to get.
  1810. * @returns {*} Returns the property value.
  1811. */
  1812. function getValue(object, key) {
  1813. return object == null ? undefined : object[key];
  1814. }
  1815. /**
  1816. * Checks if `value` is a host object in IE < 9.
  1817. *
  1818. * @private
  1819. * @param {*} value The value to check.
  1820. * @returns {boolean} Returns `true` if `value` is a host object, else `false`.
  1821. */
  1822. function isHostObject(value) {
  1823. // Many host objects are `Object` objects that can coerce to strings
  1824. // despite having improperly defined `toString` methods.
  1825. var result = false;
  1826. if (value != null && typeof value.toString != 'function') {
  1827. try {
  1828. result = !!(value + '');
  1829. } catch (e) {}
  1830. }
  1831. return result;
  1832. }
  1833. /** Used for built-in method references. */
  1834. var arrayProto = Array.prototype,
  1835. funcProto = Function.prototype,
  1836. objectProto$2 = Object.prototype;
  1837. /** Used to detect overreaching core-js shims. */
  1838. var coreJsData = root$2['__core-js_shared__'];
  1839. /** Used to detect methods masquerading as native. */
  1840. var maskSrcKey = (function() {
  1841. var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
  1842. return uid ? ('Symbol(src)_1.' + uid) : '';
  1843. }());
  1844. /** Used to resolve the decompiled source of functions. */
  1845. var funcToString = funcProto.toString;
  1846. /** Used to check objects for own properties. */
  1847. var hasOwnProperty$1 = objectProto$2.hasOwnProperty;
  1848. /**
  1849. * Used to resolve the
  1850. * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
  1851. * of values.
  1852. */
  1853. var objectToString$2 = objectProto$2.toString;
  1854. /** Used to detect if a method is native. */
  1855. var reIsNative = RegExp('^' +
  1856. funcToString.call(hasOwnProperty$1).replace(reRegExpChar, '\\$&')
  1857. .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
  1858. );
  1859. /** Built-in value references. */
  1860. var splice = arrayProto.splice;
  1861. /* Built-in method references that are verified to be native. */
  1862. var Map$1 = getNative(root$2, 'Map'),
  1863. nativeCreate = getNative(Object, 'create');
  1864. /**
  1865. * Creates a hash object.
  1866. *
  1867. * @private
  1868. * @constructor
  1869. * @param {Array} [entries] The key-value pairs to cache.
  1870. */
  1871. function Hash(entries) {
  1872. var index = -1,
  1873. length = entries ? entries.length : 0;
  1874. this.clear();
  1875. while (++index < length) {
  1876. var entry = entries[index];
  1877. this.set(entry[0], entry[1]);
  1878. }
  1879. }
  1880. /**
  1881. * Removes all key-value entries from the hash.
  1882. *
  1883. * @private
  1884. * @name clear
  1885. * @memberOf Hash
  1886. */
  1887. function hashClear() {
  1888. this.__data__ = nativeCreate ? nativeCreate(null) : {};
  1889. }
  1890. /**
  1891. * Removes `key` and its value from the hash.
  1892. *
  1893. * @private
  1894. * @name delete
  1895. * @memberOf Hash
  1896. * @param {Object} hash The hash to modify.
  1897. * @param {string} key The key of the value to remove.
  1898. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1899. */
  1900. function hashDelete(key) {
  1901. return this.has(key) && delete this.__data__[key];
  1902. }
  1903. /**
  1904. * Gets the hash value for `key`.
  1905. *
  1906. * @private
  1907. * @name get
  1908. * @memberOf Hash
  1909. * @param {string} key The key of the value to get.
  1910. * @returns {*} Returns the entry value.
  1911. */
  1912. function hashGet(key) {
  1913. var data = this.__data__;
  1914. if (nativeCreate) {
  1915. var result = data[key];
  1916. return result === HASH_UNDEFINED ? undefined : result;
  1917. }
  1918. return hasOwnProperty$1.call(data, key) ? data[key] : undefined;
  1919. }
  1920. /**
  1921. * Checks if a hash value for `key` exists.
  1922. *
  1923. * @private
  1924. * @name has
  1925. * @memberOf Hash
  1926. * @param {string} key The key of the entry to check.
  1927. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  1928. */
  1929. function hashHas(key) {
  1930. var data = this.__data__;
  1931. return nativeCreate ? data[key] !== undefined : hasOwnProperty$1.call(data, key);
  1932. }
  1933. /**
  1934. * Sets the hash `key` to `value`.
  1935. *
  1936. * @private
  1937. * @name set
  1938. * @memberOf Hash
  1939. * @param {string} key The key of the value to set.
  1940. * @param {*} value The value to set.
  1941. * @returns {Object} Returns the hash instance.
  1942. */
  1943. function hashSet(key, value) {
  1944. var data = this.__data__;
  1945. data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
  1946. return this;
  1947. }
  1948. // Add methods to `Hash`.
  1949. Hash.prototype.clear = hashClear;
  1950. Hash.prototype['delete'] = hashDelete;
  1951. Hash.prototype.get = hashGet;
  1952. Hash.prototype.has = hashHas;
  1953. Hash.prototype.set = hashSet;
  1954. /**
  1955. * Creates an list cache object.
  1956. *
  1957. * @private
  1958. * @constructor
  1959. * @param {Array} [entries] The key-value pairs to cache.
  1960. */
  1961. function ListCache(entries) {
  1962. var index = -1,
  1963. length = entries ? entries.length : 0;
  1964. this.clear();
  1965. while (++index < length) {
  1966. var entry = entries[index];
  1967. this.set(entry[0], entry[1]);
  1968. }
  1969. }
  1970. /**
  1971. * Removes all key-value entries from the list cache.
  1972. *
  1973. * @private
  1974. * @name clear
  1975. * @memberOf ListCache
  1976. */
  1977. function listCacheClear() {
  1978. this.__data__ = [];
  1979. }
  1980. /**
  1981. * Removes `key` and its value from the list cache.
  1982. *
  1983. * @private
  1984. * @name delete
  1985. * @memberOf ListCache
  1986. * @param {string} key The key of the value to remove.
  1987. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  1988. */
  1989. function listCacheDelete(key) {
  1990. var data = this.__data__,
  1991. index = assocIndexOf(data, key);
  1992. if (index < 0) {
  1993. return false;
  1994. }
  1995. var lastIndex = data.length - 1;
  1996. if (index == lastIndex) {
  1997. data.pop();
  1998. } else {
  1999. splice.call(data, index, 1);
  2000. }
  2001. return true;
  2002. }
  2003. /**
  2004. * Gets the list cache value for `key`.
  2005. *
  2006. * @private
  2007. * @name get
  2008. * @memberOf ListCache
  2009. * @param {string} key The key of the value to get.
  2010. * @returns {*} Returns the entry value.
  2011. */
  2012. function listCacheGet(key) {
  2013. var data = this.__data__,
  2014. index = assocIndexOf(data, key);
  2015. return index < 0 ? undefined : data[index][1];
  2016. }
  2017. /**
  2018. * Checks if a list cache value for `key` exists.
  2019. *
  2020. * @private
  2021. * @name has
  2022. * @memberOf ListCache
  2023. * @param {string} key The key of the entry to check.
  2024. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2025. */
  2026. function listCacheHas(key) {
  2027. return assocIndexOf(this.__data__, key) > -1;
  2028. }
  2029. /**
  2030. * Sets the list cache `key` to `value`.
  2031. *
  2032. * @private
  2033. * @name set
  2034. * @memberOf ListCache
  2035. * @param {string} key The key of the value to set.
  2036. * @param {*} value The value to set.
  2037. * @returns {Object} Returns the list cache instance.
  2038. */
  2039. function listCacheSet(key, value) {
  2040. var data = this.__data__,
  2041. index = assocIndexOf(data, key);
  2042. if (index < 0) {
  2043. data.push([key, value]);
  2044. } else {
  2045. data[index][1] = value;
  2046. }
  2047. return this;
  2048. }
  2049. // Add methods to `ListCache`.
  2050. ListCache.prototype.clear = listCacheClear;
  2051. ListCache.prototype['delete'] = listCacheDelete;
  2052. ListCache.prototype.get = listCacheGet;
  2053. ListCache.prototype.has = listCacheHas;
  2054. ListCache.prototype.set = listCacheSet;
  2055. /**
  2056. * Creates a map cache object to store key-value pairs.
  2057. *
  2058. * @private
  2059. * @constructor
  2060. * @param {Array} [entries] The key-value pairs to cache.
  2061. */
  2062. function MapCache(entries) {
  2063. var index = -1,
  2064. length = entries ? entries.length : 0;
  2065. this.clear();
  2066. while (++index < length) {
  2067. var entry = entries[index];
  2068. this.set(entry[0], entry[1]);
  2069. }
  2070. }
  2071. /**
  2072. * Removes all key-value entries from the map.
  2073. *
  2074. * @private
  2075. * @name clear
  2076. * @memberOf MapCache
  2077. */
  2078. function mapCacheClear() {
  2079. this.__data__ = {
  2080. 'hash': new Hash,
  2081. 'map': new (Map$1 || ListCache),
  2082. 'string': new Hash
  2083. };
  2084. }
  2085. /**
  2086. * Removes `key` and its value from the map.
  2087. *
  2088. * @private
  2089. * @name delete
  2090. * @memberOf MapCache
  2091. * @param {string} key The key of the value to remove.
  2092. * @returns {boolean} Returns `true` if the entry was removed, else `false`.
  2093. */
  2094. function mapCacheDelete(key) {
  2095. return getMapData(this, key)['delete'](key);
  2096. }
  2097. /**
  2098. * Gets the map value for `key`.
  2099. *
  2100. * @private
  2101. * @name get
  2102. * @memberOf MapCache
  2103. * @param {string} key The key of the value to get.
  2104. * @returns {*} Returns the entry value.
  2105. */
  2106. function mapCacheGet(key) {
  2107. return getMapData(this, key).get(key);
  2108. }
  2109. /**
  2110. * Checks if a map value for `key` exists.
  2111. *
  2112. * @private
  2113. * @name has
  2114. * @memberOf MapCache
  2115. * @param {string} key The key of the entry to check.
  2116. * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
  2117. */
  2118. function mapCacheHas(key) {
  2119. return getMapData(this, key).has(key);
  2120. }
  2121. /**
  2122. * Sets the map `key` to `value`.
  2123. *
  2124. * @private
  2125. * @name set
  2126. * @memberOf MapCache
  2127. * @param {string} key The key of the value to set.
  2128. * @param {*} value The value to set.
  2129. * @returns {Object} Returns the map cache instance.
  2130. */
  2131. function mapCacheSet(key, value) {
  2132. getMapData(this, key).set(key, value);
  2133. return this;
  2134. }
  2135. // Add methods to `MapCache`.
  2136. MapCache.prototype.clear = mapCacheClear;
  2137. MapCache.prototype['delete'] = mapCacheDelete;
  2138. MapCache.prototype.get = mapCacheGet;
  2139. MapCache.prototype.has = mapCacheHas;
  2140. MapCache.prototype.set = mapCacheSet;
  2141. /**
  2142. * Gets the index at which the `key` is found in `array` of key-value pairs.
  2143. *
  2144. * @private
  2145. * @param {Array} array The array to inspect.
  2146. * @param {*} key The key to search for.
  2147. * @returns {number} Returns the index of the matched value, else `-1`.
  2148. */
  2149. function assocIndexOf(array, key) {
  2150. var length = array.length;
  2151. while (length--) {
  2152. if (eq(array[length][0], key)) {
  2153. return length;
  2154. }
  2155. }
  2156. return -1;
  2157. }
  2158. /**
  2159. * The base implementation of `_.isNative` without bad shim checks.
  2160. *
  2161. * @private
  2162. * @param {*} value The value to check.
  2163. * @returns {boolean} Returns `true` if `value` is a native function,
  2164. * else `false`.
  2165. */
  2166. function baseIsNative(value) {
  2167. if (!isObject$3(value) || isMasked(value)) {
  2168. return false;
  2169. }
  2170. var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
  2171. return pattern.test(toSource(value));
  2172. }
  2173. /**
  2174. * Gets the data for `map`.
  2175. *
  2176. * @private
  2177. * @param {Object} map The map to query.
  2178. * @param {string} key The reference key.
  2179. * @returns {*} Returns the map data.
  2180. */
  2181. function getMapData(map, key) {
  2182. var data = map.__data__;
  2183. return isKeyable(key)
  2184. ? data[typeof key == 'string' ? 'string' : 'hash']
  2185. : data.map;
  2186. }
  2187. /**
  2188. * Gets the native function at `key` of `object`.
  2189. *
  2190. * @private
  2191. * @param {Object} object The object to query.
  2192. * @param {string} key The key of the method to get.
  2193. * @returns {*} Returns the function if it's native, else `undefined`.
  2194. */
  2195. function getNative(object, key) {
  2196. var value = getValue(object, key);
  2197. return baseIsNative(value) ? value : undefined;
  2198. }
  2199. /**
  2200. * Checks if `value` is suitable for use as unique object key.
  2201. *
  2202. * @private
  2203. * @param {*} value The value to check.
  2204. * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
  2205. */
  2206. function isKeyable(value) {
  2207. var type = typeof value;
  2208. return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
  2209. ? (value !== '__proto__')
  2210. : (value === null);
  2211. }
  2212. /**
  2213. * Checks if `func` has its source masked.
  2214. *
  2215. * @private
  2216. * @param {Function} func The function to check.
  2217. * @returns {boolean} Returns `true` if `func` is masked, else `false`.
  2218. */
  2219. function isMasked(func) {
  2220. return !!maskSrcKey && (maskSrcKey in func);
  2221. }
  2222. /**
  2223. * Converts `func` to its source code.
  2224. *
  2225. * @private
  2226. * @param {Function} func The function to process.
  2227. * @returns {string} Returns the source code.
  2228. */
  2229. function toSource(func) {
  2230. if (func != null) {
  2231. try {
  2232. return funcToString.call(func);
  2233. } catch (e) {}
  2234. try {
  2235. return (func + '');
  2236. } catch (e) {}
  2237. }
  2238. return '';
  2239. }
  2240. /**
  2241. * Creates a function that memoizes the result of `func`. If `resolver` is
  2242. * provided, it determines the cache key for storing the result based on the
  2243. * arguments provided to the memoized function. By default, the first argument
  2244. * provided to the memoized function is used as the map cache key. The `func`
  2245. * is invoked with the `this` binding of the memoized function.
  2246. *
  2247. * **Note:** The cache is exposed as the `cache` property on the memoized
  2248. * function. Its creation may be customized by replacing the `_.memoize.Cache`
  2249. * constructor with one whose instances implement the
  2250. * [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
  2251. * method interface of `delete`, `get`, `has`, and `set`.
  2252. *
  2253. * @static
  2254. * @memberOf _
  2255. * @since 0.1.0
  2256. * @category Function
  2257. * @param {Function} func The function to have its output memoized.
  2258. * @param {Function} [resolver] The function to resolve the cache key.
  2259. * @returns {Function} Returns the new memoized function.
  2260. * @example
  2261. *
  2262. * var object = { 'a': 1, 'b': 2 };
  2263. * var other = { 'c': 3, 'd': 4 };
  2264. *
  2265. * var values = _.memoize(_.values);
  2266. * values(object);
  2267. * // => [1, 2]
  2268. *
  2269. * values(other);
  2270. * // => [3, 4]
  2271. *
  2272. * object.a = 2;
  2273. * values(object);
  2274. * // => [1, 2]
  2275. *
  2276. * // Modify the result cache.
  2277. * values.cache.set(object, ['a', 'b']);
  2278. * values(object);
  2279. * // => ['a', 'b']
  2280. *
  2281. * // Replace `_.memoize.Cache`.
  2282. * _.memoize.Cache = WeakMap;
  2283. */
  2284. function memoize(func, resolver) {
  2285. if (typeof func != 'function' || (resolver && typeof resolver != 'function')) {
  2286. throw new TypeError(FUNC_ERROR_TEXT$2);
  2287. }
  2288. var memoized = function() {
  2289. var args = arguments,
  2290. key = resolver ? resolver.apply(this, args) : args[0],
  2291. cache = memoized.cache;
  2292. if (cache.has(key)) {
  2293. return cache.get(key);
  2294. }
  2295. var result = func.apply(this, args);
  2296. memoized.cache = cache.set(key, result);
  2297. return result;
  2298. };
  2299. memoized.cache = new (memoize.Cache || MapCache);
  2300. return memoized;
  2301. }
  2302. // Assign cache to `_.memoize`.
  2303. memoize.Cache = MapCache;
  2304. /**
  2305. * Performs a
  2306. * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
  2307. * comparison between two values to determine if they are equivalent.
  2308. *
  2309. * @static
  2310. * @memberOf _
  2311. * @since 4.0.0
  2312. * @category Lang
  2313. * @param {*} value The value to compare.
  2314. * @param {*} other The other value to compare.
  2315. * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
  2316. * @example
  2317. *
  2318. * var object = { 'a': 1 };
  2319. * var other = { 'a': 1 };
  2320. *
  2321. * _.eq(object, object);
  2322. * // => true
  2323. *
  2324. * _.eq(object, other);
  2325. * // => false
  2326. *
  2327. * _.eq('a', 'a');
  2328. * // => true
  2329. *
  2330. * _.eq('a', Object('a'));
  2331. * // => false
  2332. *
  2333. * _.eq(NaN, NaN);
  2334. * // => true
  2335. */
  2336. function eq(value, other) {
  2337. return value === other || (value !== value && other !== other);
  2338. }
  2339. /**
  2340. * Checks if `value` is classified as a `Function` object.
  2341. *
  2342. * @static
  2343. * @memberOf _
  2344. * @since 0.1.0
  2345. * @category Lang
  2346. * @param {*} value The value to check.
  2347. * @returns {boolean} Returns `true` if `value` is a function, else `false`.
  2348. * @example
  2349. *
  2350. * _.isFunction(_);
  2351. * // => true
  2352. *
  2353. * _.isFunction(/abc/);
  2354. * // => false
  2355. */
  2356. function isFunction(value) {
  2357. // The use of `Object#toString` avoids issues with the `typeof` operator
  2358. // in Safari 8-9 which returns 'object' for typed array and other constructors.
  2359. var tag = isObject$3(value) ? objectToString$2.call(value) : '';
  2360. return tag == funcTag || tag == genTag;
  2361. }
  2362. /**
  2363. * Checks if `value` is the
  2364. * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
  2365. * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
  2366. *
  2367. * @static
  2368. * @memberOf _
  2369. * @since 0.1.0
  2370. * @category Lang
  2371. * @param {*} value The value to check.
  2372. * @returns {boolean} Returns `true` if `value` is an object, else `false`.
  2373. * @example
  2374. *
  2375. * _.isObject({});
  2376. * // => true
  2377. *
  2378. * _.isObject([1, 2, 3]);
  2379. * // => true
  2380. *
  2381. * _.isObject(_.noop);
  2382. * // => true
  2383. *
  2384. * _.isObject(null);
  2385. * // => false
  2386. */
  2387. function isObject$3(value) {
  2388. var type = typeof value;
  2389. return !!value && (type == 'object' || type == 'function');
  2390. }
  2391. var lodash_memoize = memoize;
  2392. /**
  2393. * A collection of shims that provide minimal functionality of the ES6 collections.
  2394. *
  2395. * These implementations are not meant to be used outside of the ResizeObserver
  2396. * modules as they cover only a limited range of use cases.
  2397. */
  2398. /* eslint-disable require-jsdoc, valid-jsdoc */
  2399. var MapShim = (function () {
  2400. if (typeof Map !== 'undefined') {
  2401. return Map;
  2402. }
  2403. /**
  2404. * Returns index in provided array that matches the specified key.
  2405. *
  2406. * @param {Array<Array>} arr
  2407. * @param {*} key
  2408. * @returns {number}
  2409. */
  2410. function getIndex(arr, key) {
  2411. var result = -1;
  2412. arr.some(function (entry, index) {
  2413. if (entry[0] === key) {
  2414. result = index;
  2415. return true;
  2416. }
  2417. return false;
  2418. });
  2419. return result;
  2420. }
  2421. return /** @class */ (function () {
  2422. function class_1() {
  2423. this.__entries__ = [];
  2424. }
  2425. Object.defineProperty(class_1.prototype, "size", {
  2426. /**
  2427. * @returns {boolean}
  2428. */
  2429. get: function () {
  2430. return this.__entries__.length;
  2431. },
  2432. enumerable: true,
  2433. configurable: true
  2434. });
  2435. /**
  2436. * @param {*} key
  2437. * @returns {*}
  2438. */
  2439. class_1.prototype.get = function (key) {
  2440. var index = getIndex(this.__entries__, key);
  2441. var entry = this.__entries__[index];
  2442. return entry && entry[1];
  2443. };
  2444. /**
  2445. * @param {*} key
  2446. * @param {*} value
  2447. * @returns {void}
  2448. */
  2449. class_1.prototype.set = function (key, value) {
  2450. var index = getIndex(this.__entries__, key);
  2451. if (~index) {
  2452. this.__entries__[index][1] = value;
  2453. }
  2454. else {
  2455. this.__entries__.push([key, value]);
  2456. }
  2457. };
  2458. /**
  2459. * @param {*} key
  2460. * @returns {void}
  2461. */
  2462. class_1.prototype.delete = function (key) {
  2463. var entries = this.__entries__;
  2464. var index = getIndex(entries, key);
  2465. if (~index) {
  2466. entries.splice(index, 1);
  2467. }
  2468. };
  2469. /**
  2470. * @param {*} key
  2471. * @returns {void}
  2472. */
  2473. class_1.prototype.has = function (key) {
  2474. return !!~getIndex(this.__entries__, key);
  2475. };
  2476. /**
  2477. * @returns {void}
  2478. */
  2479. class_1.prototype.clear = function () {
  2480. this.__entries__.splice(0);
  2481. };
  2482. /**
  2483. * @param {Function} callback
  2484. * @param {*} [ctx=null]
  2485. * @returns {void}
  2486. */
  2487. class_1.prototype.forEach = function (callback, ctx) {
  2488. if (ctx === void 0) { ctx = null; }
  2489. for (var _i = 0, _a = this.__entries__; _i < _a.length; _i++) {
  2490. var entry = _a[_i];
  2491. callback.call(ctx, entry[1], entry[0]);
  2492. }
  2493. };
  2494. return class_1;
  2495. }());
  2496. })();
  2497. /**
  2498. * Detects whether window and document objects are available in current environment.
  2499. */
  2500. var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && window.document === document;
  2501. // Returns global object of a current environment.
  2502. var global$1$1 = (function () {
  2503. if (typeof global !== 'undefined' && global.Math === Math) {
  2504. return global;
  2505. }
  2506. if (typeof self !== 'undefined' && self.Math === Math) {
  2507. return self;
  2508. }
  2509. if (typeof window !== 'undefined' && window.Math === Math) {
  2510. return window;
  2511. }
  2512. // eslint-disable-next-line no-new-func
  2513. return Function('return this')();
  2514. })();
  2515. /**
  2516. * A shim for the requestAnimationFrame which falls back to the setTimeout if
  2517. * first one is not supported.
  2518. *
  2519. * @returns {number} Requests' identifier.
  2520. */
  2521. var requestAnimationFrame$1 = (function () {
  2522. if (typeof requestAnimationFrame === 'function') {
  2523. // It's required to use a bounded function because IE sometimes throws
  2524. // an "Invalid calling object" error if rAF is invoked without the global
  2525. // object on the left hand side.
  2526. return requestAnimationFrame.bind(global$1$1);
  2527. }
  2528. return function (callback) { return setTimeout(function () { return callback(Date.now()); }, 1000 / 60); };
  2529. })();
  2530. // Defines minimum timeout before adding a trailing call.
  2531. var trailingTimeout = 2;
  2532. /**
  2533. * Creates a wrapper function which ensures that provided callback will be
  2534. * invoked only once during the specified delay period.
  2535. *
  2536. * @param {Function} callback - Function to be invoked after the delay period.
  2537. * @param {number} delay - Delay after which to invoke callback.
  2538. * @returns {Function}
  2539. */
  2540. function throttle$1 (callback, delay) {
  2541. var leadingCall = false, trailingCall = false, lastCallTime = 0;
  2542. /**
  2543. * Invokes the original callback function and schedules new invocation if
  2544. * the "proxy" was called during current request.
  2545. *
  2546. * @returns {void}
  2547. */
  2548. function resolvePending() {
  2549. if (leadingCall) {
  2550. leadingCall = false;
  2551. callback();
  2552. }
  2553. if (trailingCall) {
  2554. proxy();
  2555. }
  2556. }
  2557. /**
  2558. * Callback invoked after the specified delay. It will further postpone
  2559. * invocation of the original function delegating it to the
  2560. * requestAnimationFrame.
  2561. *
  2562. * @returns {void}
  2563. */
  2564. function timeoutCallback() {
  2565. requestAnimationFrame$1(resolvePending);
  2566. }
  2567. /**
  2568. * Schedules invocation of the original function.
  2569. *
  2570. * @returns {void}
  2571. */
  2572. function proxy() {
  2573. var timeStamp = Date.now();
  2574. if (leadingCall) {
  2575. // Reject immediately following calls.
  2576. if (timeStamp - lastCallTime < trailingTimeout) {
  2577. return;
  2578. }
  2579. // Schedule new call to be in invoked when the pending one is resolved.
  2580. // This is important for "transitions" which never actually start
  2581. // immediately so there is a chance that we might miss one if change
  2582. // happens amids the pending invocation.
  2583. trailingCall = true;
  2584. }
  2585. else {
  2586. leadingCall = true;
  2587. trailingCall = false;
  2588. setTimeout(timeoutCallback, delay);
  2589. }
  2590. lastCallTime = timeStamp;
  2591. }
  2592. return proxy;
  2593. }
  2594. // Minimum delay before invoking the update of observers.
  2595. var REFRESH_DELAY = 20;
  2596. // A list of substrings of CSS properties used to find transition events that
  2597. // might affect dimensions of observed elements.
  2598. var transitionKeys = ['top', 'right', 'bottom', 'left', 'width', 'height', 'size', 'weight'];
  2599. // Check if MutationObserver is available.
  2600. var mutationObserverSupported = typeof MutationObserver !== 'undefined';
  2601. /**
  2602. * Singleton controller class which handles updates of ResizeObserver instances.
  2603. */
  2604. var ResizeObserverController = /** @class */ (function () {
  2605. /**
  2606. * Creates a new instance of ResizeObserverController.
  2607. *
  2608. * @private
  2609. */
  2610. function ResizeObserverController() {
  2611. /**
  2612. * Indicates whether DOM listeners have been added.
  2613. *
  2614. * @private {boolean}
  2615. */
  2616. this.connected_ = false;
  2617. /**
  2618. * Tells that controller has subscribed for Mutation Events.
  2619. *
  2620. * @private {boolean}
  2621. */
  2622. this.mutationEventsAdded_ = false;
  2623. /**
  2624. * Keeps reference to the instance of MutationObserver.
  2625. *
  2626. * @private {MutationObserver}
  2627. */
  2628. this.mutationsObserver_ = null;
  2629. /**
  2630. * A list of connected observers.
  2631. *
  2632. * @private {Array<ResizeObserverSPI>}
  2633. */
  2634. this.observers_ = [];
  2635. this.onTransitionEnd_ = this.onTransitionEnd_.bind(this);
  2636. this.refresh = throttle$1(this.refresh.bind(this), REFRESH_DELAY);
  2637. }
  2638. /**
  2639. * Adds observer to observers list.
  2640. *
  2641. * @param {ResizeObserverSPI} observer - Observer to be added.
  2642. * @returns {void}
  2643. */
  2644. ResizeObserverController.prototype.addObserver = function (observer) {
  2645. if (!~this.observers_.indexOf(observer)) {
  2646. this.observers_.push(observer);
  2647. }
  2648. // Add listeners if they haven't been added yet.
  2649. if (!this.connected_) {
  2650. this.connect_();
  2651. }
  2652. };
  2653. /**
  2654. * Removes observer from observers list.
  2655. *
  2656. * @param {ResizeObserverSPI} observer - Observer to be removed.
  2657. * @returns {void}
  2658. */
  2659. ResizeObserverController.prototype.removeObserver = function (observer) {
  2660. var observers = this.observers_;
  2661. var index = observers.indexOf(observer);
  2662. // Remove observer if it's present in registry.
  2663. if (~index) {
  2664. observers.splice(index, 1);
  2665. }
  2666. // Remove listeners if controller has no connected observers.
  2667. if (!observers.length && this.connected_) {
  2668. this.disconnect_();
  2669. }
  2670. };
  2671. /**
  2672. * Invokes the update of observers. It will continue running updates insofar
  2673. * it detects changes.
  2674. *
  2675. * @returns {void}
  2676. */
  2677. ResizeObserverController.prototype.refresh = function () {
  2678. var changesDetected = this.updateObservers_();
  2679. // Continue running updates if changes have been detected as there might
  2680. // be future ones caused by CSS transitions.
  2681. if (changesDetected) {
  2682. this.refresh();
  2683. }
  2684. };
  2685. /**
  2686. * Updates every observer from observers list and notifies them of queued
  2687. * entries.
  2688. *
  2689. * @private
  2690. * @returns {boolean} Returns "true" if any observer has detected changes in
  2691. * dimensions of it's elements.
  2692. */
  2693. ResizeObserverController.prototype.updateObservers_ = function () {
  2694. // Collect observers that have active observations.
  2695. var activeObservers = this.observers_.filter(function (observer) {
  2696. return observer.gatherActive(), observer.hasActive();
  2697. });
  2698. // Deliver notifications in a separate cycle in order to avoid any
  2699. // collisions between observers, e.g. when multiple instances of
  2700. // ResizeObserver are tracking the same element and the callback of one
  2701. // of them changes content dimensions of the observed target. Sometimes
  2702. // this may result in notifications being blocked for the rest of observers.
  2703. activeObservers.forEach(function (observer) { return observer.broadcastActive(); });
  2704. return activeObservers.length > 0;
  2705. };
  2706. /**
  2707. * Initializes DOM listeners.
  2708. *
  2709. * @private
  2710. * @returns {void}
  2711. */
  2712. ResizeObserverController.prototype.connect_ = function () {
  2713. // Do nothing if running in a non-browser environment or if listeners
  2714. // have been already added.
  2715. if (!isBrowser || this.connected_) {
  2716. return;
  2717. }
  2718. // Subscription to the "Transitionend" event is used as a workaround for
  2719. // delayed transitions. This way it's possible to capture at least the
  2720. // final state of an element.
  2721. document.addEventListener('transitionend', this.onTransitionEnd_);
  2722. window.addEventListener('resize', this.refresh);
  2723. if (mutationObserverSupported) {
  2724. this.mutationsObserver_ = new MutationObserver(this.refresh);
  2725. this.mutationsObserver_.observe(document, {
  2726. attributes: true,
  2727. childList: true,
  2728. characterData: true,
  2729. subtree: true
  2730. });
  2731. }
  2732. else {
  2733. document.addEventListener('DOMSubtreeModified', this.refresh);
  2734. this.mutationEventsAdded_ = true;
  2735. }
  2736. this.connected_ = true;
  2737. };
  2738. /**
  2739. * Removes DOM listeners.
  2740. *
  2741. * @private
  2742. * @returns {void}
  2743. */
  2744. ResizeObserverController.prototype.disconnect_ = function () {
  2745. // Do nothing if running in a non-browser environment or if listeners
  2746. // have been already removed.
  2747. if (!isBrowser || !this.connected_) {
  2748. return;
  2749. }
  2750. document.removeEventListener('transitionend', this.onTransitionEnd_);
  2751. window.removeEventListener('resize', this.refresh);
  2752. if (this.mutationsObserver_) {
  2753. this.mutationsObserver_.disconnect();
  2754. }
  2755. if (this.mutationEventsAdded_) {
  2756. document.removeEventListener('DOMSubtreeModified', this.refresh);
  2757. }
  2758. this.mutationsObserver_ = null;
  2759. this.mutationEventsAdded_ = false;
  2760. this.connected_ = false;
  2761. };
  2762. /**
  2763. * "Transitionend" event handler.
  2764. *
  2765. * @private
  2766. * @param {TransitionEvent} event
  2767. * @returns {void}
  2768. */
  2769. ResizeObserverController.prototype.onTransitionEnd_ = function (_a) {
  2770. var _b = _a.propertyName, propertyName = _b === void 0 ? '' : _b;
  2771. // Detect whether transition may affect dimensions of an element.
  2772. var isReflowProperty = transitionKeys.some(function (key) {
  2773. return !!~propertyName.indexOf(key);
  2774. });
  2775. if (isReflowProperty) {
  2776. this.refresh();
  2777. }
  2778. };
  2779. /**
  2780. * Returns instance of the ResizeObserverController.
  2781. *
  2782. * @returns {ResizeObserverController}
  2783. */
  2784. ResizeObserverController.getInstance = function () {
  2785. if (!this.instance_) {
  2786. this.instance_ = new ResizeObserverController();
  2787. }
  2788. return this.instance_;
  2789. };
  2790. /**
  2791. * Holds reference to the controller's instance.
  2792. *
  2793. * @private {ResizeObserverController}
  2794. */
  2795. ResizeObserverController.instance_ = null;
  2796. return ResizeObserverController;
  2797. }());
  2798. /**
  2799. * Defines non-writable/enumerable properties of the provided target object.
  2800. *
  2801. * @param {Object} target - Object for which to define properties.
  2802. * @param {Object} props - Properties to be defined.
  2803. * @returns {Object} Target object.
  2804. */
  2805. var defineConfigurable = (function (target, props) {
  2806. for (var _i = 0, _a = Object.keys(props); _i < _a.length; _i++) {
  2807. var key = _a[_i];
  2808. Object.defineProperty(target, key, {
  2809. value: props[key],
  2810. enumerable: false,
  2811. writable: false,
  2812. configurable: true
  2813. });
  2814. }
  2815. return target;
  2816. });
  2817. /**
  2818. * Returns the global object associated with provided element.
  2819. *
  2820. * @param {Object} target
  2821. * @returns {Object}
  2822. */
  2823. var getWindowOf = (function (target) {
  2824. // Assume that the element is an instance of Node, which means that it
  2825. // has the "ownerDocument" property from which we can retrieve a
  2826. // corresponding global object.
  2827. var ownerGlobal = target && target.ownerDocument && target.ownerDocument.defaultView;
  2828. // Return the local global object if it's not possible extract one from
  2829. // provided element.
  2830. return ownerGlobal || global$1$1;
  2831. });
  2832. // Placeholder of an empty content rectangle.
  2833. var emptyRect = createRectInit(0, 0, 0, 0);
  2834. /**
  2835. * Converts provided string to a number.
  2836. *
  2837. * @param {number|string} value
  2838. * @returns {number}
  2839. */
  2840. function toFloat(value) {
  2841. return parseFloat(value) || 0;
  2842. }
  2843. /**
  2844. * Extracts borders size from provided styles.
  2845. *
  2846. * @param {CSSStyleDeclaration} styles
  2847. * @param {...string} positions - Borders positions (top, right, ...)
  2848. * @returns {number}
  2849. */
  2850. function getBordersSize(styles) {
  2851. var positions = [];
  2852. for (var _i = 1; _i < arguments.length; _i++) {
  2853. positions[_i - 1] = arguments[_i];
  2854. }
  2855. return positions.reduce(function (size, position) {
  2856. var value = styles['border-' + position + '-width'];
  2857. return size + toFloat(value);
  2858. }, 0);
  2859. }
  2860. /**
  2861. * Extracts paddings sizes from provided styles.
  2862. *
  2863. * @param {CSSStyleDeclaration} styles
  2864. * @returns {Object} Paddings box.
  2865. */
  2866. function getPaddings(styles) {
  2867. var positions = ['top', 'right', 'bottom', 'left'];
  2868. var paddings = {};
  2869. for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
  2870. var position = positions_1[_i];
  2871. var value = styles['padding-' + position];
  2872. paddings[position] = toFloat(value);
  2873. }
  2874. return paddings;
  2875. }
  2876. /**
  2877. * Calculates content rectangle of provided SVG element.
  2878. *
  2879. * @param {SVGGraphicsElement} target - Element content rectangle of which needs
  2880. * to be calculated.
  2881. * @returns {DOMRectInit}
  2882. */
  2883. function getSVGContentRect(target) {
  2884. var bbox = target.getBBox();
  2885. return createRectInit(0, 0, bbox.width, bbox.height);
  2886. }
  2887. /**
  2888. * Calculates content rectangle of provided HTMLElement.
  2889. *
  2890. * @param {HTMLElement} target - Element for which to calculate the content rectangle.
  2891. * @returns {DOMRectInit}
  2892. */
  2893. function getHTMLElementContentRect(target) {
  2894. // Client width & height properties can't be
  2895. // used exclusively as they provide rounded values.
  2896. var clientWidth = target.clientWidth, clientHeight = target.clientHeight;
  2897. // By this condition we can catch all non-replaced inline, hidden and
  2898. // detached elements. Though elements with width & height properties less
  2899. // than 0.5 will be discarded as well.
  2900. //
  2901. // Without it we would need to implement separate methods for each of
  2902. // those cases and it's not possible to perform a precise and performance
  2903. // effective test for hidden elements. E.g. even jQuery's ':visible' filter
  2904. // gives wrong results for elements with width & height less than 0.5.
  2905. if (!clientWidth && !clientHeight) {
  2906. return emptyRect;
  2907. }
  2908. var styles = getWindowOf(target).getComputedStyle(target);
  2909. var paddings = getPaddings(styles);
  2910. var horizPad = paddings.left + paddings.right;
  2911. var vertPad = paddings.top + paddings.bottom;
  2912. // Computed styles of width & height are being used because they are the
  2913. // only dimensions available to JS that contain non-rounded values. It could
  2914. // be possible to utilize the getBoundingClientRect if only it's data wasn't
  2915. // affected by CSS transformations let alone paddings, borders and scroll bars.
  2916. var width = toFloat(styles.width), height = toFloat(styles.height);
  2917. // Width & height include paddings and borders when the 'border-box' box
  2918. // model is applied (except for IE).
  2919. if (styles.boxSizing === 'border-box') {
  2920. // Following conditions are required to handle Internet Explorer which
  2921. // doesn't include paddings and borders to computed CSS dimensions.
  2922. //
  2923. // We can say that if CSS dimensions + paddings are equal to the "client"
  2924. // properties then it's either IE, and thus we don't need to subtract
  2925. // anything, or an element merely doesn't have paddings/borders styles.
  2926. if (Math.round(width + horizPad) !== clientWidth) {
  2927. width -= getBordersSize(styles, 'left', 'right') + horizPad;
  2928. }
  2929. if (Math.round(height + vertPad) !== clientHeight) {
  2930. height -= getBordersSize(styles, 'top', 'bottom') + vertPad;
  2931. }
  2932. }
  2933. // Following steps can't be applied to the document's root element as its
  2934. // client[Width/Height] properties represent viewport area of the window.
  2935. // Besides, it's as well not necessary as the <html> itself neither has
  2936. // rendered scroll bars nor it can be clipped.
  2937. if (!isDocumentElement(target)) {
  2938. // In some browsers (only in Firefox, actually) CSS width & height
  2939. // include scroll bars size which can be removed at this step as scroll
  2940. // bars are the only difference between rounded dimensions + paddings
  2941. // and "client" properties, though that is not always true in Chrome.
  2942. var vertScrollbar = Math.round(width + horizPad) - clientWidth;
  2943. var horizScrollbar = Math.round(height + vertPad) - clientHeight;
  2944. // Chrome has a rather weird rounding of "client" properties.
  2945. // E.g. for an element with content width of 314.2px it sometimes gives
  2946. // the client width of 315px and for the width of 314.7px it may give
  2947. // 314px. And it doesn't happen all the time. So just ignore this delta
  2948. // as a non-relevant.
  2949. if (Math.abs(vertScrollbar) !== 1) {
  2950. width -= vertScrollbar;
  2951. }
  2952. if (Math.abs(horizScrollbar) !== 1) {
  2953. height -= horizScrollbar;
  2954. }
  2955. }
  2956. return createRectInit(paddings.left, paddings.top, width, height);
  2957. }
  2958. /**
  2959. * Checks whether provided element is an instance of the SVGGraphicsElement.
  2960. *
  2961. * @param {Element} target - Element to be checked.
  2962. * @returns {boolean}
  2963. */
  2964. var isSVGGraphicsElement = (function () {
  2965. // Some browsers, namely IE and Edge, don't have the SVGGraphicsElement
  2966. // interface.
  2967. if (typeof SVGGraphicsElement !== 'undefined') {
  2968. return function (target) { return target instanceof getWindowOf(target).SVGGraphicsElement; };
  2969. }
  2970. // If it's so, then check that element is at least an instance of the
  2971. // SVGElement and that it has the "getBBox" method.
  2972. // eslint-disable-next-line no-extra-parens
  2973. return function (target) { return (target instanceof getWindowOf(target).SVGElement &&
  2974. typeof target.getBBox === 'function'); };
  2975. })();
  2976. /**
  2977. * Checks whether provided element is a document element (<html>).
  2978. *
  2979. * @param {Element} target - Element to be checked.
  2980. * @returns {boolean}
  2981. */
  2982. function isDocumentElement(target) {
  2983. return target === getWindowOf(target).document.documentElement;
  2984. }
  2985. /**
  2986. * Calculates an appropriate content rectangle for provided html or svg element.
  2987. *
  2988. * @param {Element} target - Element content rectangle of which needs to be calculated.
  2989. * @returns {DOMRectInit}
  2990. */
  2991. function getContentRect(target) {
  2992. if (!isBrowser) {
  2993. return emptyRect;
  2994. }
  2995. if (isSVGGraphicsElement(target)) {
  2996. return getSVGContentRect(target);
  2997. }
  2998. return getHTMLElementContentRect(target);
  2999. }
  3000. /**
  3001. * Creates rectangle with an interface of the DOMRectReadOnly.
  3002. * Spec: https://drafts.fxtf.org/geometry/#domrectreadonly
  3003. *
  3004. * @param {DOMRectInit} rectInit - Object with rectangle's x/y coordinates and dimensions.
  3005. * @returns {DOMRectReadOnly}
  3006. */
  3007. function createReadOnlyRect(_a) {
  3008. var x = _a.x, y = _a.y, width = _a.width, height = _a.height;
  3009. // If DOMRectReadOnly is available use it as a prototype for the rectangle.
  3010. var Constr = typeof DOMRectReadOnly !== 'undefined' ? DOMRectReadOnly : Object;
  3011. var rect = Object.create(Constr.prototype);
  3012. // Rectangle's properties are not writable and non-enumerable.
  3013. defineConfigurable(rect, {
  3014. x: x, y: y, width: width, height: height,
  3015. top: y,
  3016. right: x + width,
  3017. bottom: height + y,
  3018. left: x
  3019. });
  3020. return rect;
  3021. }
  3022. /**
  3023. * Creates DOMRectInit object based on the provided dimensions and the x/y coordinates.
  3024. * Spec: https://drafts.fxtf.org/geometry/#dictdef-domrectinit
  3025. *
  3026. * @param {number} x - X coordinate.
  3027. * @param {number} y - Y coordinate.
  3028. * @param {number} width - Rectangle's width.
  3029. * @param {number} height - Rectangle's height.
  3030. * @returns {DOMRectInit}
  3031. */
  3032. function createRectInit(x, y, width, height) {
  3033. return { x: x, y: y, width: width, height: height };
  3034. }
  3035. /**
  3036. * Class that is responsible for computations of the content rectangle of
  3037. * provided DOM element and for keeping track of it's changes.
  3038. */
  3039. var ResizeObservation = /** @class */ (function () {
  3040. /**
  3041. * Creates an instance of ResizeObservation.
  3042. *
  3043. * @param {Element} target - Element to be observed.
  3044. */
  3045. function ResizeObservation(target) {
  3046. /**
  3047. * Broadcasted width of content rectangle.
  3048. *
  3049. * @type {number}
  3050. */
  3051. this.broadcastWidth = 0;
  3052. /**
  3053. * Broadcasted height of content rectangle.
  3054. *
  3055. * @type {number}
  3056. */
  3057. this.broadcastHeight = 0;
  3058. /**
  3059. * Reference to the last observed content rectangle.
  3060. *
  3061. * @private {DOMRectInit}
  3062. */
  3063. this.contentRect_ = createRectInit(0, 0, 0, 0);
  3064. this.target = target;
  3065. }
  3066. /**
  3067. * Updates content rectangle and tells whether it's width or height properties
  3068. * have changed since the last broadcast.
  3069. *
  3070. * @returns {boolean}
  3071. */
  3072. ResizeObservation.prototype.isActive = function () {
  3073. var rect = getContentRect(this.target);
  3074. this.contentRect_ = rect;
  3075. return (rect.width !== this.broadcastWidth ||
  3076. rect.height !== this.broadcastHeight);
  3077. };
  3078. /**
  3079. * Updates 'broadcastWidth' and 'broadcastHeight' properties with a data
  3080. * from the corresponding properties of the last observed content rectangle.
  3081. *
  3082. * @returns {DOMRectInit} Last observed content rectangle.
  3083. */
  3084. ResizeObservation.prototype.broadcastRect = function () {
  3085. var rect = this.contentRect_;
  3086. this.broadcastWidth = rect.width;
  3087. this.broadcastHeight = rect.height;
  3088. return rect;
  3089. };
  3090. return ResizeObservation;
  3091. }());
  3092. var ResizeObserverEntry = /** @class */ (function () {
  3093. /**
  3094. * Creates an instance of ResizeObserverEntry.
  3095. *
  3096. * @param {Element} target - Element that is being observed.
  3097. * @param {DOMRectInit} rectInit - Data of the element's content rectangle.
  3098. */
  3099. function ResizeObserverEntry(target, rectInit) {
  3100. var contentRect = createReadOnlyRect(rectInit);
  3101. // According to the specification following properties are not writable
  3102. // and are also not enumerable in the native implementation.
  3103. //
  3104. // Property accessors are not being used as they'd require to define a
  3105. // private WeakMap storage which may cause memory leaks in browsers that
  3106. // don't support this type of collections.
  3107. defineConfigurable(this, { target: target, contentRect: contentRect });
  3108. }
  3109. return ResizeObserverEntry;
  3110. }());
  3111. var ResizeObserverSPI = /** @class */ (function () {
  3112. /**
  3113. * Creates a new instance of ResizeObserver.
  3114. *
  3115. * @param {ResizeObserverCallback} callback - Callback function that is invoked
  3116. * when one of the observed elements changes it's content dimensions.
  3117. * @param {ResizeObserverController} controller - Controller instance which
  3118. * is responsible for the updates of observer.
  3119. * @param {ResizeObserver} callbackCtx - Reference to the public
  3120. * ResizeObserver instance which will be passed to callback function.
  3121. */
  3122. function ResizeObserverSPI(callback, controller, callbackCtx) {
  3123. /**
  3124. * Collection of resize observations that have detected changes in dimensions
  3125. * of elements.
  3126. *
  3127. * @private {Array<ResizeObservation>}
  3128. */
  3129. this.activeObservations_ = [];
  3130. /**
  3131. * Registry of the ResizeObservation instances.
  3132. *
  3133. * @private {Map<Element, ResizeObservation>}
  3134. */
  3135. this.observations_ = new MapShim();
  3136. if (typeof callback !== 'function') {
  3137. throw new TypeError('The callback provided as parameter 1 is not a function.');
  3138. }
  3139. this.callback_ = callback;
  3140. this.controller_ = controller;
  3141. this.callbackCtx_ = callbackCtx;
  3142. }
  3143. /**
  3144. * Starts observing provided element.
  3145. *
  3146. * @param {Element} target - Element to be observed.
  3147. * @returns {void}
  3148. */
  3149. ResizeObserverSPI.prototype.observe = function (target) {
  3150. if (!arguments.length) {
  3151. throw new TypeError('1 argument required, but only 0 present.');
  3152. }
  3153. // Do nothing if current environment doesn't have the Element interface.
  3154. if (typeof Element === 'undefined' || !(Element instanceof Object)) {
  3155. return;
  3156. }
  3157. if (!(target instanceof getWindowOf(target).Element)) {
  3158. throw new TypeError('parameter 1 is not of type "Element".');
  3159. }
  3160. var observations = this.observations_;
  3161. // Do nothing if element is already being observed.
  3162. if (observations.has(target)) {
  3163. return;
  3164. }
  3165. observations.set(target, new ResizeObservation(target));
  3166. this.controller_.addObserver(this);
  3167. // Force the update of observations.
  3168. this.controller_.refresh();
  3169. };
  3170. /**
  3171. * Stops observing provided element.
  3172. *
  3173. * @param {Element} target - Element to stop observing.
  3174. * @returns {void}
  3175. */
  3176. ResizeObserverSPI.prototype.unobserve = function (target) {
  3177. if (!arguments.length) {
  3178. throw new TypeError('1 argument required, but only 0 present.');
  3179. }
  3180. // Do nothing if current environment doesn't have the Element interface.
  3181. if (typeof Element === 'undefined' || !(Element instanceof Object)) {
  3182. return;
  3183. }
  3184. if (!(target instanceof getWindowOf(target).Element)) {
  3185. throw new TypeError('parameter 1 is not of type "Element".');
  3186. }
  3187. var observations = this.observations_;
  3188. // Do nothing if element is not being observed.
  3189. if (!observations.has(target)) {
  3190. return;
  3191. }
  3192. observations.delete(target);
  3193. if (!observations.size) {
  3194. this.controller_.removeObserver(this);
  3195. }
  3196. };
  3197. /**
  3198. * Stops observing all elements.
  3199. *
  3200. * @returns {void}
  3201. */
  3202. ResizeObserverSPI.prototype.disconnect = function () {
  3203. this.clearActive();
  3204. this.observations_.clear();
  3205. this.controller_.removeObserver(this);
  3206. };
  3207. /**
  3208. * Collects observation instances the associated element of which has changed
  3209. * it's content rectangle.
  3210. *
  3211. * @returns {void}
  3212. */
  3213. ResizeObserverSPI.prototype.gatherActive = function () {
  3214. var _this = this;
  3215. this.clearActive();
  3216. this.observations_.forEach(function (observation) {
  3217. if (observation.isActive()) {
  3218. _this.activeObservations_.push(observation);
  3219. }
  3220. });
  3221. };
  3222. /**
  3223. * Invokes initial callback function with a list of ResizeObserverEntry
  3224. * instances collected from active resize observations.
  3225. *
  3226. * @returns {void}
  3227. */
  3228. ResizeObserverSPI.prototype.broadcastActive = function () {
  3229. // Do nothing if observer doesn't have active observations.
  3230. if (!this.hasActive()) {
  3231. return;
  3232. }
  3233. var ctx = this.callbackCtx_;
  3234. // Create ResizeObserverEntry instance for every active observation.
  3235. var entries = this.activeObservations_.map(function (observation) {
  3236. return new ResizeObserverEntry(observation.target, observation.broadcastRect());
  3237. });
  3238. this.callback_.call(ctx, entries, ctx);
  3239. this.clearActive();
  3240. };
  3241. /**
  3242. * Clears the collection of active observations.
  3243. *
  3244. * @returns {void}
  3245. */
  3246. ResizeObserverSPI.prototype.clearActive = function () {
  3247. this.activeObservations_.splice(0);
  3248. };
  3249. /**
  3250. * Tells whether observer has active observations.
  3251. *
  3252. * @returns {boolean}
  3253. */
  3254. ResizeObserverSPI.prototype.hasActive = function () {
  3255. return this.activeObservations_.length > 0;
  3256. };
  3257. return ResizeObserverSPI;
  3258. }());
  3259. // Registry of internal observers. If WeakMap is not available use current shim
  3260. // for the Map collection as it has all required methods and because WeakMap
  3261. // can't be fully polyfilled anyway.
  3262. var observers = typeof WeakMap !== 'undefined' ? new WeakMap() : new MapShim();
  3263. /**
  3264. * ResizeObserver API. Encapsulates the ResizeObserver SPI implementation
  3265. * exposing only those methods and properties that are defined in the spec.
  3266. */
  3267. var ResizeObserver = /** @class */ (function () {
  3268. /**
  3269. * Creates a new instance of ResizeObserver.
  3270. *
  3271. * @param {ResizeObserverCallback} callback - Callback that is invoked when
  3272. * dimensions of the observed elements change.
  3273. */
  3274. function ResizeObserver(callback) {
  3275. if (!(this instanceof ResizeObserver)) {
  3276. throw new TypeError('Cannot call a class as a function.');
  3277. }
  3278. if (!arguments.length) {
  3279. throw new TypeError('1 argument required, but only 0 present.');
  3280. }
  3281. var controller = ResizeObserverController.getInstance();
  3282. var observer = new ResizeObserverSPI(callback, controller, this);
  3283. observers.set(this, observer);
  3284. }
  3285. return ResizeObserver;
  3286. }());
  3287. // Expose public methods of ResizeObserver.
  3288. [
  3289. 'observe',
  3290. 'unobserve',
  3291. 'disconnect'
  3292. ].forEach(function (method) {
  3293. ResizeObserver.prototype[method] = function () {
  3294. var _a;
  3295. return (_a = observers.get(this))[method].apply(_a, arguments);
  3296. };
  3297. });
  3298. var index = (function () {
  3299. // Export existing implementation if available.
  3300. if (typeof global$1$1.ResizeObserver !== 'undefined') {
  3301. return global$1$1.ResizeObserver;
  3302. }
  3303. return ResizeObserver;
  3304. })();
  3305. var canUseDOM = !!(
  3306. typeof window !== 'undefined' &&
  3307. window.document &&
  3308. window.document.createElement
  3309. );
  3310. var canUseDom = canUseDOM;
  3311. function scrollbarWidth() {
  3312. if (typeof document === 'undefined') {
  3313. return 0;
  3314. }
  3315. var body = document.body;
  3316. var box = document.createElement('div');
  3317. var boxStyle = box.style;
  3318. boxStyle.position = 'fixed';
  3319. boxStyle.left = 0;
  3320. boxStyle.visibility = 'hidden';
  3321. boxStyle.overflowY = 'scroll';
  3322. body.appendChild(box);
  3323. var width = box.getBoundingClientRect().right;
  3324. body.removeChild(box);
  3325. return width;
  3326. }
  3327. var SimpleBar =
  3328. /*#__PURE__*/
  3329. function () {
  3330. function SimpleBar(element, options) {
  3331. var _this = this;
  3332. this.onScroll = function () {
  3333. if (!_this.scrollXTicking) {
  3334. window.requestAnimationFrame(_this.scrollX);
  3335. _this.scrollXTicking = true;
  3336. }
  3337. if (!_this.scrollYTicking) {
  3338. window.requestAnimationFrame(_this.scrollY);
  3339. _this.scrollYTicking = true;
  3340. }
  3341. };
  3342. this.scrollX = function () {
  3343. if (_this.axis.x.isOverflowing) {
  3344. _this.showScrollbar('x');
  3345. _this.positionScrollbar('x');
  3346. }
  3347. _this.scrollXTicking = false;
  3348. };
  3349. this.scrollY = function () {
  3350. if (_this.axis.y.isOverflowing) {
  3351. _this.showScrollbar('y');
  3352. _this.positionScrollbar('y');
  3353. }
  3354. _this.scrollYTicking = false;
  3355. };
  3356. this.onMouseEnter = function () {
  3357. _this.showScrollbar('x');
  3358. _this.showScrollbar('y');
  3359. };
  3360. this.onMouseMove = function (e) {
  3361. _this.mouseX = e.clientX;
  3362. _this.mouseY = e.clientY;
  3363. if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
  3364. _this.onMouseMoveForAxis('x');
  3365. }
  3366. if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
  3367. _this.onMouseMoveForAxis('y');
  3368. }
  3369. };
  3370. this.onMouseLeave = function () {
  3371. _this.onMouseMove.cancel();
  3372. if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
  3373. _this.onMouseLeaveForAxis('x');
  3374. }
  3375. if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
  3376. _this.onMouseLeaveForAxis('y');
  3377. }
  3378. _this.mouseX = -1;
  3379. _this.mouseY = -1;
  3380. };
  3381. this.onWindowResize = function () {
  3382. // Recalculate scrollbarWidth in case it's a zoom
  3383. _this.scrollbarWidth = scrollbarWidth();
  3384. _this.hideNativeScrollbar();
  3385. };
  3386. this.hideScrollbars = function () {
  3387. _this.axis.x.track.rect = _this.axis.x.track.el.getBoundingClientRect();
  3388. _this.axis.y.track.rect = _this.axis.y.track.el.getBoundingClientRect();
  3389. if (!_this.isWithinBounds(_this.axis.y.track.rect)) {
  3390. _this.axis.y.scrollbar.el.classList.remove(_this.classNames.visible);
  3391. _this.axis.y.isVisible = false;
  3392. }
  3393. if (!_this.isWithinBounds(_this.axis.x.track.rect)) {
  3394. _this.axis.x.scrollbar.el.classList.remove(_this.classNames.visible);
  3395. _this.axis.x.isVisible = false;
  3396. }
  3397. };
  3398. this.onPointerEvent = function (e) {
  3399. var isWithinBoundsY, isWithinBoundsX;
  3400. _this.axis.x.scrollbar.rect = _this.axis.x.scrollbar.el.getBoundingClientRect();
  3401. _this.axis.y.scrollbar.rect = _this.axis.y.scrollbar.el.getBoundingClientRect();
  3402. if (_this.axis.x.isOverflowing || _this.axis.x.forceVisible) {
  3403. isWithinBoundsX = _this.isWithinBounds(_this.axis.x.scrollbar.rect);
  3404. }
  3405. if (_this.axis.y.isOverflowing || _this.axis.y.forceVisible) {
  3406. isWithinBoundsY = _this.isWithinBounds(_this.axis.y.scrollbar.rect);
  3407. } // If any pointer event is called on the scrollbar
  3408. if (isWithinBoundsY || isWithinBoundsX) {
  3409. // Preventing the event's default action stops text being
  3410. // selectable during the drag.
  3411. e.preventDefault(); // Prevent event leaking
  3412. e.stopPropagation();
  3413. if (e.type === 'mousedown') {
  3414. if (isWithinBoundsY) {
  3415. _this.onDragStart(e, 'y');
  3416. }
  3417. if (isWithinBoundsX) {
  3418. _this.onDragStart(e, 'x');
  3419. }
  3420. }
  3421. }
  3422. };
  3423. this.drag = function (e) {
  3424. var eventOffset;
  3425. var track = _this.axis[_this.draggedAxis].track;
  3426. var trackSize = track.rect[_this.axis[_this.draggedAxis].sizeAttr];
  3427. var scrollbar = _this.axis[_this.draggedAxis].scrollbar;
  3428. var contentSize = _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollSizeAttr];
  3429. var hostSize = parseInt(_this.elStyles[_this.axis[_this.draggedAxis].sizeAttr], 10);
  3430. e.preventDefault();
  3431. e.stopPropagation();
  3432. if (_this.draggedAxis === 'y') {
  3433. eventOffset = e.pageY;
  3434. } else {
  3435. eventOffset = e.pageX;
  3436. } // Calculate how far the user's mouse is from the top/left of the scrollbar (minus the dragOffset).
  3437. var dragPos = eventOffset - track.rect[_this.axis[_this.draggedAxis].offsetAttr] - _this.axis[_this.draggedAxis].dragOffset; // Convert the mouse position into a percentage of the scrollbar height/width.
  3438. var dragPerc = dragPos / (trackSize - scrollbar.size); // Scroll the content by the same percentage.
  3439. var scrollPos = dragPerc * (contentSize - hostSize); // Fix browsers inconsistency on RTL
  3440. if (_this.draggedAxis === 'x') {
  3441. scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? scrollPos - (trackSize + scrollbar.size) : scrollPos;
  3442. scrollPos = _this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollPos : scrollPos;
  3443. }
  3444. _this.contentWrapperEl[_this.axis[_this.draggedAxis].scrollOffsetAttr] = scrollPos;
  3445. };
  3446. this.onEndDrag = function (e) {
  3447. e.preventDefault();
  3448. e.stopPropagation();
  3449. _this.el.classList.remove(_this.classNames.dragging);
  3450. document.removeEventListener('mousemove', _this.drag, true);
  3451. document.removeEventListener('mouseup', _this.onEndDrag, true);
  3452. _this.removePreventClickId = window.setTimeout(function () {
  3453. // Remove these asynchronously so we still suppress click events
  3454. // generated simultaneously with mouseup.
  3455. document.removeEventListener('click', _this.preventClick, true);
  3456. document.removeEventListener('dblclick', _this.preventClick, true);
  3457. _this.removePreventClickId = null;
  3458. });
  3459. };
  3460. this.preventClick = function (e) {
  3461. e.preventDefault();
  3462. e.stopPropagation();
  3463. };
  3464. this.el = element;
  3465. this.flashTimeout;
  3466. this.contentEl;
  3467. this.contentWrapperEl;
  3468. this.offsetEl;
  3469. this.maskEl;
  3470. this.globalObserver;
  3471. this.mutationObserver;
  3472. this.resizeObserver;
  3473. this.scrollbarWidth;
  3474. this.minScrollbarWidth = 20;
  3475. this.options = Object.assign({}, SimpleBar.defaultOptions, options);
  3476. this.classNames = Object.assign({}, SimpleBar.defaultOptions.classNames, this.options.classNames);
  3477. this.isRtl;
  3478. this.axis = {
  3479. x: {
  3480. scrollOffsetAttr: 'scrollLeft',
  3481. sizeAttr: 'width',
  3482. scrollSizeAttr: 'scrollWidth',
  3483. offsetAttr: 'left',
  3484. overflowAttr: 'overflowX',
  3485. dragOffset: 0,
  3486. isOverflowing: true,
  3487. isVisible: false,
  3488. forceVisible: false,
  3489. track: {},
  3490. scrollbar: {}
  3491. },
  3492. y: {
  3493. scrollOffsetAttr: 'scrollTop',
  3494. sizeAttr: 'height',
  3495. scrollSizeAttr: 'scrollHeight',
  3496. offsetAttr: 'top',
  3497. overflowAttr: 'overflowY',
  3498. dragOffset: 0,
  3499. isOverflowing: true,
  3500. isVisible: false,
  3501. forceVisible: false,
  3502. track: {},
  3503. scrollbar: {}
  3504. }
  3505. };
  3506. this.removePreventClickId = null; // Don't re-instantiate over an existing one
  3507. if (this.el.SimpleBar) {
  3508. return;
  3509. }
  3510. this.recalculate = lodash_throttle(this.recalculate.bind(this), 64);
  3511. this.onMouseMove = lodash_throttle(this.onMouseMove.bind(this), 64);
  3512. this.hideScrollbars = lodash_debounce(this.hideScrollbars.bind(this), this.options.timeout);
  3513. this.onWindowResize = lodash_debounce(this.onWindowResize.bind(this), 64, {
  3514. leading: true
  3515. });
  3516. SimpleBar.getRtlHelpers = lodash_memoize(SimpleBar.getRtlHelpers);
  3517. this.init();
  3518. }
  3519. /**
  3520. * Static properties
  3521. */
  3522. /**
  3523. * Helper to fix browsers inconsistency on RTL:
  3524. * - Firefox inverts the scrollbar initial position
  3525. * - IE11 inverts both scrollbar position and scrolling offset
  3526. * Directly inspired by @KingSora's OverlayScrollbars https://github.com/KingSora/OverlayScrollbars/blob/master/js/OverlayScrollbars.js#L1634
  3527. */
  3528. SimpleBar.getRtlHelpers = function getRtlHelpers() {
  3529. var dummyDiv = document.createElement('div');
  3530. dummyDiv.innerHTML = '<div class="hs-dummy-scrollbar-size"><div style="height: 200%; width: 200%; margin: 10px 0;"></div></div>';
  3531. var scrollbarDummyEl = dummyDiv.firstElementChild;
  3532. document.body.appendChild(scrollbarDummyEl);
  3533. var dummyContainerChild = scrollbarDummyEl.firstElementChild;
  3534. scrollbarDummyEl.scrollLeft = 0;
  3535. var dummyContainerOffset = SimpleBar.getOffset(scrollbarDummyEl);
  3536. var dummyContainerChildOffset = SimpleBar.getOffset(dummyContainerChild);
  3537. scrollbarDummyEl.scrollLeft = 999;
  3538. var dummyContainerScrollOffsetAfterScroll = SimpleBar.getOffset(dummyContainerChild);
  3539. return {
  3540. // determines if the scrolling is responding with negative values
  3541. isRtlScrollingInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left && dummyContainerChildOffset.left - dummyContainerScrollOffsetAfterScroll.left !== 0,
  3542. // determines if the origin scrollbar position is inverted or not (positioned on left or right)
  3543. isRtlScrollbarInverted: dummyContainerOffset.left !== dummyContainerChildOffset.left
  3544. };
  3545. };
  3546. SimpleBar.initHtmlApi = function initHtmlApi() {
  3547. this.initDOMLoadedElements = this.initDOMLoadedElements.bind(this); // MutationObserver is IE11+
  3548. if (typeof MutationObserver !== 'undefined') {
  3549. // Mutation observer to observe dynamically added elements
  3550. this.globalObserver = new MutationObserver(function (mutations) {
  3551. mutations.forEach(function (mutation) {
  3552. Array.prototype.forEach.call(mutation.addedNodes, function (addedNode) {
  3553. if (addedNode.nodeType === 1) {
  3554. if (addedNode.hasAttribute('data-simplebar')) {
  3555. !addedNode.SimpleBar && new SimpleBar(addedNode, SimpleBar.getElOptions(addedNode));
  3556. } else {
  3557. Array.prototype.forEach.call(addedNode.querySelectorAll('[data-simplebar]'), function (el) {
  3558. !el.SimpleBar && new SimpleBar(el, SimpleBar.getElOptions(el));
  3559. });
  3560. }
  3561. }
  3562. });
  3563. Array.prototype.forEach.call(mutation.removedNodes, function (removedNode) {
  3564. if (removedNode.nodeType === 1) {
  3565. if (removedNode.hasAttribute('data-simplebar')) {
  3566. removedNode.SimpleBar && removedNode.SimpleBar.unMount();
  3567. } else {
  3568. Array.prototype.forEach.call(removedNode.querySelectorAll('[data-simplebar]'), function (el) {
  3569. el.SimpleBar && el.SimpleBar.unMount();
  3570. });
  3571. }
  3572. }
  3573. });
  3574. });
  3575. });
  3576. this.globalObserver.observe(document, {
  3577. childList: true,
  3578. subtree: true
  3579. });
  3580. } // Taken from jQuery `ready` function
  3581. // Instantiate elements already present on the page
  3582. if (document.readyState === 'complete' || document.readyState !== 'loading' && !document.documentElement.doScroll) {
  3583. // Handle it asynchronously to allow scripts the opportunity to delay init
  3584. window.setTimeout(this.initDOMLoadedElements);
  3585. } else {
  3586. document.addEventListener('DOMContentLoaded', this.initDOMLoadedElements);
  3587. window.addEventListener('load', this.initDOMLoadedElements);
  3588. }
  3589. } // Helper function to retrieve options from element attributes
  3590. ;
  3591. SimpleBar.getElOptions = function getElOptions(el) {
  3592. var options = Array.prototype.reduce.call(el.attributes, function (acc, attribute) {
  3593. var option = attribute.name.match(/data-simplebar-(.+)/);
  3594. if (option) {
  3595. var key = option[1].replace(/\W+(.)/g, function (x, chr) {
  3596. return chr.toUpperCase();
  3597. });
  3598. switch (attribute.value) {
  3599. case 'true':
  3600. acc[key] = true;
  3601. break;
  3602. case 'false':
  3603. acc[key] = false;
  3604. break;
  3605. case undefined:
  3606. acc[key] = true;
  3607. break;
  3608. default:
  3609. acc[key] = attribute.value;
  3610. }
  3611. }
  3612. return acc;
  3613. }, {});
  3614. return options;
  3615. };
  3616. SimpleBar.removeObserver = function removeObserver() {
  3617. this.globalObserver.disconnect();
  3618. };
  3619. SimpleBar.initDOMLoadedElements = function initDOMLoadedElements() {
  3620. document.removeEventListener('DOMContentLoaded', this.initDOMLoadedElements);
  3621. window.removeEventListener('load', this.initDOMLoadedElements);
  3622. Array.prototype.forEach.call(document.querySelectorAll('[data-simplebar]'), function (el) {
  3623. if (!el.SimpleBar) new SimpleBar(el, SimpleBar.getElOptions(el));
  3624. });
  3625. };
  3626. SimpleBar.getOffset = function getOffset(el) {
  3627. var rect = el.getBoundingClientRect();
  3628. return {
  3629. top: rect.top + (window.pageYOffset || document.documentElement.scrollTop),
  3630. left: rect.left + (window.pageXOffset || document.documentElement.scrollLeft)
  3631. };
  3632. };
  3633. var _proto = SimpleBar.prototype;
  3634. _proto.init = function init() {
  3635. // Save a reference to the instance, so we know this DOM node has already been instancied
  3636. this.el.SimpleBar = this; // We stop here on server-side
  3637. if (canUseDom) {
  3638. this.initDOM();
  3639. this.scrollbarWidth = scrollbarWidth();
  3640. this.recalculate();
  3641. this.initListeners();
  3642. }
  3643. };
  3644. _proto.initDOM = function initDOM() {
  3645. var _this2 = this;
  3646. // make sure this element doesn't have the elements yet
  3647. if (Array.prototype.filter.call(this.el.children, function (child) {
  3648. return child.classList.contains(_this2.classNames.wrapper);
  3649. }).length) {
  3650. // assume that element has his DOM already initiated
  3651. this.wrapperEl = this.el.querySelector("." + this.classNames.wrapper);
  3652. this.contentWrapperEl = this.el.querySelector("." + this.classNames.contentWrapper);
  3653. this.offsetEl = this.el.querySelector("." + this.classNames.offset);
  3654. this.maskEl = this.el.querySelector("." + this.classNames.mask);
  3655. this.contentEl = this.el.querySelector("." + this.classNames.contentEl);
  3656. this.placeholderEl = this.el.querySelector("." + this.classNames.placeholder);
  3657. this.heightAutoObserverWrapperEl = this.el.querySelector("." + this.classNames.heightAutoObserverWrapperEl);
  3658. this.heightAutoObserverEl = this.el.querySelector("." + this.classNames.heightAutoObserverEl);
  3659. this.axis.x.track.el = this.findChild(this.el, "." + this.classNames.track + "." + this.classNames.horizontal);
  3660. this.axis.y.track.el = this.findChild(this.el, "." + this.classNames.track + "." + this.classNames.vertical);
  3661. } else {
  3662. // Prepare DOM
  3663. this.wrapperEl = document.createElement('div');
  3664. this.contentWrapperEl = document.createElement('div');
  3665. this.offsetEl = document.createElement('div');
  3666. this.maskEl = document.createElement('div');
  3667. this.contentEl = document.createElement('div');
  3668. this.placeholderEl = document.createElement('div');
  3669. this.heightAutoObserverWrapperEl = document.createElement('div');
  3670. this.heightAutoObserverEl = document.createElement('div');
  3671. this.wrapperEl.classList.add(this.classNames.wrapper);
  3672. this.contentWrapperEl.classList.add(this.classNames.contentWrapper);
  3673. this.offsetEl.classList.add(this.classNames.offset);
  3674. this.maskEl.classList.add(this.classNames.mask);
  3675. this.contentEl.classList.add(this.classNames.contentEl);
  3676. this.placeholderEl.classList.add(this.classNames.placeholder);
  3677. this.heightAutoObserverWrapperEl.classList.add(this.classNames.heightAutoObserverWrapperEl);
  3678. this.heightAutoObserverEl.classList.add(this.classNames.heightAutoObserverEl);
  3679. while (this.el.firstChild) {
  3680. this.contentEl.appendChild(this.el.firstChild);
  3681. }
  3682. this.contentWrapperEl.appendChild(this.contentEl);
  3683. this.offsetEl.appendChild(this.contentWrapperEl);
  3684. this.maskEl.appendChild(this.offsetEl);
  3685. this.heightAutoObserverWrapperEl.appendChild(this.heightAutoObserverEl);
  3686. this.wrapperEl.appendChild(this.heightAutoObserverWrapperEl);
  3687. this.wrapperEl.appendChild(this.maskEl);
  3688. this.wrapperEl.appendChild(this.placeholderEl);
  3689. this.el.appendChild(this.wrapperEl);
  3690. }
  3691. if (!this.axis.x.track.el || !this.axis.y.track.el) {
  3692. var track = document.createElement('div');
  3693. var scrollbar = document.createElement('div');
  3694. track.classList.add(this.classNames.track);
  3695. scrollbar.classList.add(this.classNames.scrollbar);
  3696. track.appendChild(scrollbar);
  3697. this.axis.x.track.el = track.cloneNode(true);
  3698. this.axis.x.track.el.classList.add(this.classNames.horizontal);
  3699. this.axis.y.track.el = track.cloneNode(true);
  3700. this.axis.y.track.el.classList.add(this.classNames.vertical);
  3701. this.el.appendChild(this.axis.x.track.el);
  3702. this.el.appendChild(this.axis.y.track.el);
  3703. }
  3704. this.axis.x.scrollbar.el = this.axis.x.track.el.querySelector("." + this.classNames.scrollbar);
  3705. this.axis.y.scrollbar.el = this.axis.y.track.el.querySelector("." + this.classNames.scrollbar);
  3706. if (!this.options.autoHide) {
  3707. this.axis.x.scrollbar.el.classList.add(this.classNames.visible);
  3708. this.axis.y.scrollbar.el.classList.add(this.classNames.visible);
  3709. }
  3710. this.el.setAttribute('data-simplebar', 'init');
  3711. };
  3712. _proto.initListeners = function initListeners() {
  3713. var _this3 = this;
  3714. // Event listeners
  3715. if (this.options.autoHide) {
  3716. this.el.addEventListener('mouseenter', this.onMouseEnter);
  3717. }
  3718. ['mousedown', 'click', 'dblclick'].forEach(function (e) {
  3719. _this3.el.addEventListener(e, _this3.onPointerEvent, true);
  3720. });
  3721. ['touchstart', 'touchend', 'touchmove'].forEach(function (e) {
  3722. _this3.el.addEventListener(e, _this3.onPointerEvent, {
  3723. capture: true,
  3724. passive: true
  3725. });
  3726. });
  3727. this.el.addEventListener('mousemove', this.onMouseMove);
  3728. this.el.addEventListener('mouseleave', this.onMouseLeave);
  3729. this.contentWrapperEl.addEventListener('scroll', this.onScroll); // Browser zoom triggers a window resize
  3730. window.addEventListener('resize', this.onWindowResize);
  3731. this.resizeObserver = new index(this.recalculate);
  3732. this.resizeObserver.observe(this.el);
  3733. this.resizeObserver.observe(this.contentEl);
  3734. };
  3735. _proto.recalculate = function recalculate() {
  3736. var isHeightAuto = this.heightAutoObserverEl.offsetHeight <= 1;
  3737. var isWidthAuto = this.heightAutoObserverEl.offsetWidth <= 1;
  3738. this.elStyles = window.getComputedStyle(this.el);
  3739. this.isRtl = this.elStyles.direction === 'rtl';
  3740. this.contentEl.style.padding = this.elStyles.paddingTop + " " + this.elStyles.paddingRight + " " + this.elStyles.paddingBottom + " " + this.elStyles.paddingLeft;
  3741. this.wrapperEl.style.margin = "-" + this.elStyles.paddingTop + " -" + this.elStyles.paddingRight + " -" + this.elStyles.paddingBottom + " -" + this.elStyles.paddingLeft;
  3742. this.contentWrapperEl.style.height = isHeightAuto ? 'auto' : '100%'; // Determine placeholder size
  3743. this.placeholderEl.style.width = isWidthAuto ? this.contentEl.offsetWidth + "px" : 'auto';
  3744. this.placeholderEl.style.height = this.contentEl.scrollHeight + "px"; // Set isOverflowing to false if scrollbar is not necessary (content is shorter than offset)
  3745. this.axis.x.isOverflowing = this.contentWrapperEl.scrollWidth > this.contentWrapperEl.offsetWidth;
  3746. this.axis.y.isOverflowing = this.contentWrapperEl.scrollHeight > this.contentWrapperEl.offsetHeight; // Set isOverflowing to false if user explicitely set hidden overflow
  3747. this.axis.x.isOverflowing = this.elStyles.overflowX === 'hidden' ? false : this.axis.x.isOverflowing;
  3748. this.axis.y.isOverflowing = this.elStyles.overflowY === 'hidden' ? false : this.axis.y.isOverflowing;
  3749. this.axis.x.forceVisible = this.options.forceVisible === 'x' || this.options.forceVisible === true;
  3750. this.axis.y.forceVisible = this.options.forceVisible === 'y' || this.options.forceVisible === true;
  3751. this.hideNativeScrollbar();
  3752. this.axis.x.track.rect = this.axis.x.track.el.getBoundingClientRect();
  3753. this.axis.y.track.rect = this.axis.y.track.el.getBoundingClientRect();
  3754. this.axis.x.scrollbar.size = this.getScrollbarSize('x');
  3755. this.axis.y.scrollbar.size = this.getScrollbarSize('y');
  3756. this.axis.x.scrollbar.el.style.width = this.axis.x.scrollbar.size + "px";
  3757. this.axis.y.scrollbar.el.style.height = this.axis.y.scrollbar.size + "px";
  3758. this.positionScrollbar('x');
  3759. this.positionScrollbar('y');
  3760. this.toggleTrackVisibility('x');
  3761. this.toggleTrackVisibility('y');
  3762. }
  3763. /**
  3764. * Calculate scrollbar size
  3765. */
  3766. ;
  3767. _proto.getScrollbarSize = function getScrollbarSize(axis) {
  3768. if (axis === void 0) {
  3769. axis = 'y';
  3770. }
  3771. var contentSize = this.scrollbarWidth ? this.contentWrapperEl[this.axis[axis].scrollSizeAttr] : this.contentWrapperEl[this.axis[axis].scrollSizeAttr] - this.minScrollbarWidth;
  3772. var trackSize = this.axis[axis].track.rect[this.axis[axis].sizeAttr];
  3773. var scrollbarSize;
  3774. if (!this.axis[axis].isOverflowing) {
  3775. return;
  3776. }
  3777. var scrollbarRatio = trackSize / contentSize; // Calculate new height/position of drag handle.
  3778. scrollbarSize = Math.max(~~(scrollbarRatio * trackSize), this.options.scrollbarMinSize);
  3779. if (this.options.scrollbarMaxSize) {
  3780. scrollbarSize = Math.min(scrollbarSize, this.options.scrollbarMaxSize);
  3781. }
  3782. return scrollbarSize;
  3783. };
  3784. _proto.positionScrollbar = function positionScrollbar(axis) {
  3785. if (axis === void 0) {
  3786. axis = 'y';
  3787. }
  3788. var contentSize = this.contentWrapperEl[this.axis[axis].scrollSizeAttr];
  3789. var trackSize = this.axis[axis].track.rect[this.axis[axis].sizeAttr];
  3790. var hostSize = parseInt(this.elStyles[this.axis[axis].sizeAttr], 10);
  3791. var scrollbar = this.axis[axis].scrollbar;
  3792. var scrollOffset = this.contentWrapperEl[this.axis[axis].scrollOffsetAttr];
  3793. scrollOffset = axis === 'x' && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollingInverted ? -scrollOffset : scrollOffset;
  3794. var scrollPourcent = scrollOffset / (contentSize - hostSize);
  3795. var handleOffset = ~~((trackSize - scrollbar.size) * scrollPourcent);
  3796. handleOffset = axis === 'x' && this.isRtl && SimpleBar.getRtlHelpers().isRtlScrollbarInverted ? handleOffset + (trackSize - scrollbar.size) : handleOffset;
  3797. scrollbar.el.style.transform = axis === 'x' ? "translate3d(" + handleOffset + "px, 0, 0)" : "translate3d(0, " + handleOffset + "px, 0)";
  3798. };
  3799. _proto.toggleTrackVisibility = function toggleTrackVisibility(axis) {
  3800. if (axis === void 0) {
  3801. axis = 'y';
  3802. }
  3803. var track = this.axis[axis].track.el;
  3804. var scrollbar = this.axis[axis].scrollbar.el;
  3805. if (this.axis[axis].isOverflowing || this.axis[axis].forceVisible) {
  3806. track.style.visibility = 'visible';
  3807. this.contentWrapperEl.style[this.axis[axis].overflowAttr] = 'scroll';
  3808. } else {
  3809. track.style.visibility = 'hidden';
  3810. this.contentWrapperEl.style[this.axis[axis].overflowAttr] = 'hidden';
  3811. } // Even if forceVisible is enabled, scrollbar itself should be hidden
  3812. if (this.axis[axis].isOverflowing) {
  3813. scrollbar.style.display = 'block';
  3814. } else {
  3815. scrollbar.style.display = 'none';
  3816. }
  3817. };
  3818. _proto.hideNativeScrollbar = function hideNativeScrollbar() {
  3819. this.offsetEl.style[this.isRtl ? 'left' : 'right'] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? "-" + (this.scrollbarWidth || this.minScrollbarWidth) + "px" : 0;
  3820. this.offsetEl.style.bottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? "-" + (this.scrollbarWidth || this.minScrollbarWidth) + "px" : 0; // If floating scrollbar
  3821. if (!this.scrollbarWidth) {
  3822. var paddingDirection = [this.isRtl ? 'paddingLeft' : 'paddingRight'];
  3823. this.contentWrapperEl.style[paddingDirection] = this.axis.y.isOverflowing || this.axis.y.forceVisible ? this.minScrollbarWidth + "px" : 0;
  3824. this.contentWrapperEl.style.paddingBottom = this.axis.x.isOverflowing || this.axis.x.forceVisible ? this.minScrollbarWidth + "px" : 0;
  3825. }
  3826. }
  3827. /**
  3828. * On scroll event handling
  3829. */
  3830. ;
  3831. _proto.onMouseMoveForAxis = function onMouseMoveForAxis(axis) {
  3832. if (axis === void 0) {
  3833. axis = 'y';
  3834. }
  3835. this.axis[axis].track.rect = this.axis[axis].track.el.getBoundingClientRect();
  3836. this.axis[axis].scrollbar.rect = this.axis[axis].scrollbar.el.getBoundingClientRect();
  3837. var isWithinScrollbarBoundsX = this.isWithinBounds(this.axis[axis].scrollbar.rect);
  3838. if (isWithinScrollbarBoundsX) {
  3839. this.axis[axis].scrollbar.el.classList.add(this.classNames.hover);
  3840. } else {
  3841. this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
  3842. }
  3843. if (this.isWithinBounds(this.axis[axis].track.rect)) {
  3844. this.showScrollbar(axis);
  3845. this.axis[axis].track.el.classList.add(this.classNames.hover);
  3846. } else {
  3847. this.axis[axis].track.el.classList.remove(this.classNames.hover);
  3848. }
  3849. };
  3850. _proto.onMouseLeaveForAxis = function onMouseLeaveForAxis(axis) {
  3851. if (axis === void 0) {
  3852. axis = 'y';
  3853. }
  3854. this.axis[axis].track.el.classList.remove(this.classNames.hover);
  3855. this.axis[axis].scrollbar.el.classList.remove(this.classNames.hover);
  3856. };
  3857. /**
  3858. * Show scrollbar
  3859. */
  3860. _proto.showScrollbar = function showScrollbar(axis) {
  3861. if (axis === void 0) {
  3862. axis = 'y';
  3863. }
  3864. var scrollbar = this.axis[axis].scrollbar.el;
  3865. if (!this.axis[axis].isVisible) {
  3866. scrollbar.classList.add(this.classNames.visible);
  3867. this.axis[axis].isVisible = true;
  3868. }
  3869. if (this.options.autoHide) {
  3870. this.hideScrollbars();
  3871. }
  3872. }
  3873. /**
  3874. * Hide Scrollbar
  3875. */
  3876. ;
  3877. /**
  3878. * on scrollbar handle drag movement starts
  3879. */
  3880. _proto.onDragStart = function onDragStart(e, axis) {
  3881. if (axis === void 0) {
  3882. axis = 'y';
  3883. }
  3884. var scrollbar = this.axis[axis].scrollbar.el; // Measure how far the user's mouse is from the top of the scrollbar drag handle.
  3885. var eventOffset = axis === 'y' ? e.pageY : e.pageX;
  3886. this.axis[axis].dragOffset = eventOffset - scrollbar.getBoundingClientRect()[this.axis[axis].offsetAttr];
  3887. this.draggedAxis = axis;
  3888. this.el.classList.add(this.classNames.dragging);
  3889. document.addEventListener('mousemove', this.drag, true);
  3890. document.addEventListener('mouseup', this.onEndDrag, true);
  3891. if (this.removePreventClickId === null) {
  3892. document.addEventListener('click', this.preventClick, true);
  3893. document.addEventListener('dblclick', this.preventClick, true);
  3894. } else {
  3895. window.clearTimeout(this.removePreventClickId);
  3896. this.removePreventClickId = null;
  3897. }
  3898. }
  3899. /**
  3900. * Drag scrollbar handle
  3901. */
  3902. ;
  3903. /**
  3904. * Getter for content element
  3905. */
  3906. _proto.getContentElement = function getContentElement() {
  3907. return this.contentEl;
  3908. }
  3909. /**
  3910. * Getter for original scrolling element
  3911. */
  3912. ;
  3913. _proto.getScrollElement = function getScrollElement() {
  3914. return this.contentWrapperEl;
  3915. };
  3916. _proto.removeListeners = function removeListeners() {
  3917. var _this4 = this;
  3918. // Event listeners
  3919. if (this.options.autoHide) {
  3920. this.el.removeEventListener('mouseenter', this.onMouseEnter);
  3921. }
  3922. ['mousedown', 'click', 'dblclick'].forEach(function (e) {
  3923. _this4.el.removeEventListener(e, _this4.onPointerEvent, true);
  3924. });
  3925. ['touchstart', 'touchend', 'touchmove'].forEach(function (e) {
  3926. _this4.el.removeEventListener(e, _this4.onPointerEvent, {
  3927. capture: true,
  3928. passive: true
  3929. });
  3930. });
  3931. this.el.removeEventListener('mousemove', this.onMouseMove);
  3932. this.el.removeEventListener('mouseleave', this.onMouseLeave);
  3933. this.contentWrapperEl.removeEventListener('scroll', this.onScroll);
  3934. window.removeEventListener('resize', this.onWindowResize);
  3935. this.mutationObserver && this.mutationObserver.disconnect();
  3936. this.resizeObserver.disconnect(); // Cancel all debounced functions
  3937. this.recalculate.cancel();
  3938. this.onMouseMove.cancel();
  3939. this.hideScrollbars.cancel();
  3940. this.onWindowResize.cancel();
  3941. }
  3942. /**
  3943. * UnMount mutation observer and delete SimpleBar instance from DOM element
  3944. */
  3945. ;
  3946. _proto.unMount = function unMount() {
  3947. this.removeListeners();
  3948. this.el.SimpleBar = null;
  3949. }
  3950. /**
  3951. * Recursively walks up the parent nodes looking for this.el
  3952. */
  3953. ;
  3954. _proto.isChildNode = function isChildNode(el) {
  3955. if (el === null) return false;
  3956. if (el === this.el) return true;
  3957. return this.isChildNode(el.parentNode);
  3958. }
  3959. /**
  3960. * Check if mouse is within bounds
  3961. */
  3962. ;
  3963. _proto.isWithinBounds = function isWithinBounds(bbox) {
  3964. return this.mouseX >= bbox.left && this.mouseX <= bbox.left + bbox.width && this.mouseY >= bbox.top && this.mouseY <= bbox.top + bbox.height;
  3965. }
  3966. /**
  3967. * Find element children matches query
  3968. */
  3969. ;
  3970. _proto.findChild = function findChild(el, query) {
  3971. var matches = el.matches || el.webkitMatchesSelector || el.mozMatchesSelector || el.msMatchesSelector;
  3972. return Array.prototype.filter.call(el.children, function (child) {
  3973. return matches.call(child, query);
  3974. })[0];
  3975. };
  3976. return SimpleBar;
  3977. }();
  3978. /**
  3979. * HTML API
  3980. * Called only in a browser env.
  3981. */
  3982. SimpleBar.defaultOptions = {
  3983. autoHide: true,
  3984. forceVisible: false,
  3985. classNames: {
  3986. contentEl: 'simplebar-content',
  3987. contentWrapper: 'simplebar-content-wrapper',
  3988. offset: 'simplebar-offset',
  3989. mask: 'simplebar-mask',
  3990. wrapper: 'simplebar-wrapper',
  3991. placeholder: 'simplebar-placeholder',
  3992. scrollbar: 'simplebar-scrollbar',
  3993. track: 'simplebar-track',
  3994. heightAutoObserverWrapperEl: 'simplebar-height-auto-observer-wrapper',
  3995. heightAutoObserverEl: 'simplebar-height-auto-observer',
  3996. visible: 'simplebar-visible',
  3997. horizontal: 'simplebar-horizontal',
  3998. vertical: 'simplebar-vertical',
  3999. hover: 'simplebar-hover',
  4000. dragging: 'simplebar-dragging'
  4001. },
  4002. scrollbarMinSize: 25,
  4003. scrollbarMaxSize: 0,
  4004. timeout: 1000
  4005. };
  4006. if (canUseDom) {
  4007. SimpleBar.initHtmlApi();
  4008. }
  4009. return SimpleBar;
  4010. }));