2
0

aliyun-rtc-sdk.js 624 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707
  1. var Wn = Object.defineProperty, $n = Object.defineProperties;
  2. var Kn = Object.getOwnPropertyDescriptors;
  3. var li = Object.getOwnPropertySymbols, qn = Object.getPrototypeOf, Ss = Object.prototype.hasOwnProperty, xs = Object.prototype.propertyIsEnumerable, Jn = Reflect.get;
  4. var Bi = (r, a, e) => a in r ? Wn(r, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[a] = e, J = (r, a) => {
  5. for (var e in a || (a = {}))
  6. Ss.call(a, e) && Bi(r, e, a[e]);
  7. if (li)
  8. for (var e of li(a))
  9. xs.call(a, e) && Bi(r, e, a[e]);
  10. return r;
  11. }, ut = (r, a) => $n(r, Kn(a));
  12. var Dt = (r, a) => {
  13. var e = {};
  14. for (var t in r)
  15. Ss.call(r, t) && a.indexOf(t) < 0 && (e[t] = r[t]);
  16. if (r != null && li)
  17. for (var t of li(r))
  18. a.indexOf(t) < 0 && xs.call(r, t) && (e[t] = r[t]);
  19. return e;
  20. };
  21. var g = (r, a, e) => (Bi(r, typeof a != "symbol" ? a + "" : a, e), e);
  22. var Ni = (r, a, e) => Jn(qn(r), e, a);
  23. var w = (r, a, e) => new Promise((t, i) => {
  24. var s = (o) => {
  25. try {
  26. c(e.next(o));
  27. } catch (u) {
  28. i(u);
  29. }
  30. }, n = (o) => {
  31. try {
  32. c(e.throw(o));
  33. } catch (u) {
  34. i(u);
  35. }
  36. }, c = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(s, n);
  37. c((e = e.apply(r, a)).next());
  38. });
  39. import { AliRTS as le, EConnectStatus as Mi, EDatachannelStatus as vs } from "aliyun-rts-sdk";
  40. import De from "eventemitter3";
  41. var Gn = Object.defineProperty, Xn = (r, a, e) => a in r ? Gn(r, a, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[a] = e, Tt = (r, a, e) => (Xn(r, typeof a != "symbol" ? a + "" : a, e), e), Li = { exports: {} }, Fi = { exports: {} }, Vi, bs;
  42. function Fe() {
  43. if (bs)
  44. return Vi;
  45. bs = 1, Date.now = Date.now || function() {
  46. return (/* @__PURE__ */ new Date()).getTime();
  47. };
  48. var r = Date.now(), a = function() {
  49. }, e = function() {
  50. var i = typeof console == "object" ? console.warn : a;
  51. try {
  52. var s = {
  53. warn: i
  54. };
  55. s.warn.call(s);
  56. } catch (n) {
  57. return a;
  58. }
  59. return i;
  60. }, t = {
  61. noop: a,
  62. warn: e(),
  63. key: "__bl",
  64. selfErrKey: "ARMS_SDK_ERROR",
  65. selfErrPage: "ARMSSDK",
  66. win: typeof window == "object" && window.document ? window : void 0,
  67. regionMap: {
  68. cn: "https://arms-retcode.aliyuncs.com/r.png?",
  69. sg: "https://arms-retcode-sg.aliyuncs.com/r.png?",
  70. sg_2: "https://retcode-sg-lazada.arms.aliyuncs.com/r.png?",
  71. daily: "http://arms-retcode-daily.alibaba.net/r.png?",
  72. daily_2: "https://arms-retcode-daily.alibaba.net/r.png?",
  73. daily_3: "http://arms-retcode-daily.aliyun.test/r.png?",
  74. us: "https://retcode-us-west-1.arms.aliyuncs.com/r.png?",
  75. tw: "https://arms-retcode.orientalgame.com.tw/r.png?",
  76. tw_sg: "https://arms-retcode-sg.orientalgame.com.tw/r.png?",
  77. hz_finance: "https://arms-retcode-hz-finance.aliyuncs.com/r.png?"
  78. },
  79. defaultImgUrl: "https://arms-retcode.aliyuncs.com/r.png?",
  80. createObject: function(i) {
  81. if (Object.create)
  82. return Object.create(i);
  83. var s = function() {
  84. };
  85. return s.prototype = i, new s();
  86. },
  87. each: function(i, s) {
  88. var n = 0, c = i.length;
  89. if (this.T(i, "Array"))
  90. for (; n < c && s.call(i[n], i[n], n) !== !1; n++)
  91. ;
  92. else
  93. for (n in i)
  94. if (s.call(i[n], i[n], n) === !1)
  95. break;
  96. return i;
  97. },
  98. safetyCall: function(i, s, n) {
  99. if (typeof i != "function")
  100. return n;
  101. try {
  102. return i.apply(this, s);
  103. } catch (c) {
  104. return n;
  105. }
  106. },
  107. T: function(i, s) {
  108. var n = Object.prototype.toString.call(i).substring(8).replace("]", "");
  109. return s ? n === s : n;
  110. },
  111. duration: function() {
  112. var i = Date;
  113. try {
  114. performance && this.T(performance.now, "Function") && (i = performance);
  115. } catch (n) {
  116. i = Date;
  117. }
  118. var s = i.now();
  119. return function() {
  120. return Math.round(i.now() - s);
  121. };
  122. },
  123. filterByRule: function() {
  124. var i = [].slice.call(arguments), s = i.length;
  125. if (s < 2)
  126. return i[0];
  127. var n = i[s - 1], c = i[0];
  128. if (!c)
  129. return "";
  130. if (!n)
  131. return c;
  132. var o = this, u = o.T(n), h = i.slice(0, s - 1);
  133. return u === "Function" ? o.safetyCall(n, h, c) : u === "Array" ? (this.each(n, function(p) {
  134. h[0] = c = o.filterByRule.apply(o, [].concat(h, p));
  135. }), c) : u === "Object" ? c.replace(n.rule, n.target || "") : c.replace(n, "");
  136. },
  137. ignoreByRule: function(i, s) {
  138. if (!i || !s)
  139. return !1;
  140. if ((this.isString(s) || s.source || this.T(s) === "Function") && (s = [s]), !this.isArray(s))
  141. return this.warn("[arms] invalid rules of ignore config, (list of) String/RegExp/Funcitons are available"), !1;
  142. for (var n, c = [], o = 0, u = s.length; o < u; o++)
  143. if (n = s[o], this.isString(n))
  144. c.push(n.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1"));
  145. else if (n && n.source)
  146. c.push(n.source);
  147. else if (n && this.T(n) === "Function" && this.safetyCall(n, [i], !1) === !0)
  148. return !0;
  149. var h = new RegExp(c.join("|"), "i");
  150. return !!(c.length && h.test && h.test(i));
  151. },
  152. J: function(i) {
  153. if (!i || typeof i != "string")
  154. return i;
  155. var s = null;
  156. try {
  157. s = JSON.parse(i);
  158. } catch (n) {
  159. }
  160. return s;
  161. },
  162. pick: function(i) {
  163. return i === 1 || Math.ceil(Math.random() * i) === 1;
  164. },
  165. verifyConfig: function(i) {
  166. if ("sample" in i) {
  167. var s = i.sample, n = s;
  168. s && /^\d+(\.\d+)?%$/.test(s) && (n = parseInt(100 / parseFloat(s))), 0 < n && 1 > n && (n = parseInt(1 / n)), n >= 1 && n <= 100 ? i.sample = n : delete i.sample;
  169. }
  170. return i;
  171. },
  172. on: function(i, s, n, c, o) {
  173. return i.addEventListener ? (o = o || !1, i.addEventListener(s, function u(h) {
  174. c && i.removeEventListener(s, u, o), n.call(this, h);
  175. }, o)) : i.attachEvent && i.attachEvent("on" + s, function u(h) {
  176. c && i.detachEvent("on" + s, u), n.call(this, h);
  177. }), this;
  178. },
  179. off: function(i, s, n) {
  180. return n ? (i.removeEventListener ? i.removeEventListener(s, n) : i.detachEvent && i.detachEvent(s, n), this) : this;
  181. },
  182. delay: function(i, s) {
  183. return s === -1 ? (i(), null) : setTimeout(i, s || 0);
  184. },
  185. ext: function(i) {
  186. for (var s = 1, n = arguments.length; s < n; s++) {
  187. var c = arguments[s];
  188. for (var o in c)
  189. Object.prototype.hasOwnProperty.call(c, o) && (i[o] = c[o]);
  190. }
  191. return i;
  192. },
  193. sub: function(i, s) {
  194. var n = {};
  195. return this.each(i, function(c, o) {
  196. s.indexOf(o) !== -1 && (n[o] = c);
  197. }), n;
  198. },
  199. uu: function() {
  200. for (var i, s, n = 20, c = new Array(n), o = Date.now().toString(36).split(""); n-- > 0; )
  201. s = (i = 36 * Math.random() | 0).toString(36), c[n] = i % 3 ? s : s.toUpperCase();
  202. for (var u = 0; u < 8; u++)
  203. c.splice(3 * u + 2, 0, o[u]);
  204. return c.join("");
  205. },
  206. guid: function() {
  207. return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(i) {
  208. var s = 16 * Math.random() | 0;
  209. return (i === "x" ? s : 3 & s | 8).toString(16);
  210. });
  211. },
  212. seq: function() {
  213. return (r++).toString(36);
  214. },
  215. decode: function(i) {
  216. try {
  217. i = decodeURIComponent(i);
  218. } catch (s) {
  219. }
  220. return i;
  221. },
  222. encode: function(i, s) {
  223. try {
  224. i = s ? encodeURIComponent(i).replace(/\(/g, "%28").replace(/\)/g, "%29") : encodeURIComponent(i);
  225. } catch (n) {
  226. }
  227. return i;
  228. },
  229. serialize: function(i) {
  230. i = i || {};
  231. var s = [];
  232. for (var n in i)
  233. Object.prototype.hasOwnProperty.call(i, n) && i[n] !== void 0 && s.push(n + "=" + this.encode(i[n], n === "msg"));
  234. return s.join("&");
  235. },
  236. checkAPI: function(i, s) {
  237. if (!i || typeof i != "string")
  238. return !1;
  239. var n = /arms-retcode[\w-]*\.aliyuncs/.test(i);
  240. return !n && s && (n = /(alicdn\.com)|(mmstat\.com)/.test(i)), !n;
  241. },
  242. checkAutoError: function(i) {
  243. return !(!i || !i.message) && !/failed[\w\s]+fetch/i.test(i.message);
  244. },
  245. cutUrlSearch: function(i) {
  246. return i && typeof i == "string" ? i.replace(/^(https?:)?\/\//, "").replace(/\?.*$/, "") : "";
  247. },
  248. removeUrlSearch: function(i) {
  249. return i && typeof i == "string" ? i.replace(/\?.*$/, "") : "";
  250. },
  251. createFakeToString: function(i) {
  252. return function() {
  253. return i + "() { [native code] }";
  254. };
  255. },
  256. checkSameOrigin: function(i, s) {
  257. if (!s || !i)
  258. return !1;
  259. var n = "//" + s.split("/")[2];
  260. return i === s || i.slice(0, s.length + 1) === s + "/" || i === n || i.slice(0, n.length + 1) === n + "/" || !/^(\/\/|http:|https:).*/.test(i);
  261. },
  262. getRandIP: function() {
  263. for (var i = [], s = 0; s < 4; s++) {
  264. var n = Math.floor(256 * Math.random());
  265. i[s] = (n > 15 ? "" : "0") + n.toString(16);
  266. }
  267. return i.join("").replace(/^0/, "1");
  268. },
  269. getSortNum: function(i) {
  270. return i ? (i += 1) >= 1e3 && i <= 9999 ? i : i < 1e3 ? i + 1e3 : i % 1e4 + 1e3 : 1e3;
  271. },
  272. getRandNum: function(i) {
  273. return i && typeof i == "string" ? i.length < 5 ? this.getNum(5) : i.substring(i.length - 5) : this.getNum(5);
  274. },
  275. getNum: function(i) {
  276. for (var s = [], n = 0; n < i; n++) {
  277. var c = Math.floor(16 * Math.random());
  278. s[n] = c.toString(16);
  279. }
  280. return s.join("");
  281. },
  282. getCurDomain: function() {
  283. return location && location.hostname || "";
  284. },
  285. getSrcType: function(i, s) {
  286. var n = location && location.host || "";
  287. if (!n)
  288. return "";
  289. var c = new URL(i).host;
  290. if (c === n)
  291. return "self";
  292. for (var o = 0; o < s.length; o += 1)
  293. if (c.includes(s[o]))
  294. return "cdn";
  295. return "others";
  296. },
  297. parseFetchHeaders: function(i) {
  298. if (!i)
  299. return {};
  300. var s = {};
  301. try {
  302. if (typeof i.keys == "function")
  303. for (var n = i.keys(), c = n.next(); !c.done; ) {
  304. var o = c.value;
  305. s[o] = i.get(o), c = n.next();
  306. }
  307. else
  308. s = i;
  309. } catch (u) {
  310. s = {};
  311. }
  312. return s;
  313. },
  314. parseXhrHeaders: function(i) {
  315. if (!i && typeof i != "string")
  316. return {};
  317. var s = {};
  318. try {
  319. var n = i.split(`\r
  320. `);
  321. s = n.reduce(function(c, o) {
  322. var u = o.split(": ");
  323. return c[u[0]] = u[1], c;
  324. }, {});
  325. } catch (c) {
  326. s = {};
  327. }
  328. return s;
  329. },
  330. getQuerys: function(i) {
  331. if (!i)
  332. return "";
  333. var s = {}, n = [], c = "", o = "";
  334. try {
  335. var u = [];
  336. if (i.indexOf("?") >= 0 && (u = i.substring(i.indexOf("?") + 1, i.length).split("&")), u.length > 0)
  337. for (var h in u)
  338. c = (n = u[h].split("="))[0], o = n[1], s[c] = o;
  339. } catch (p) {
  340. s = {};
  341. }
  342. return s;
  343. },
  344. getURL: function(i) {
  345. if (!i)
  346. return null;
  347. var s = {}, n = i.length, c = i.indexOf("://");
  348. if (c < 0)
  349. return null;
  350. s.protocol = i.substring(0, c + 1);
  351. var o = i.indexOf("#"), u = i.indexOf("?");
  352. o < 0 && (o = n), u < 0 && (u = o), s.search = i.substring(u, o).substring(0, 1e3);
  353. var h = i.substring(c + 3, u), p = h.indexOf("/");
  354. return p < 0 && (p = h.length), s.domain = h.substring(0, p).split(":")[0], s.path = h.substring(p, h.length).substring(0, 1e3), s;
  355. },
  356. getResType: function(i, s) {
  357. if (["script", "img", "other"].indexOf(i) > -1)
  358. return i;
  359. if (["video"].indexOf(i) > -1)
  360. return "media";
  361. if (["document", "iframe"].indexOf(i) > -1)
  362. return "doc";
  363. var n = s ? this.getURL(s) : null, c = n && n.path ? n.path.lastIndexOf(".") : -1, o = (c > 0 ? n.path.substr(c + 1) : "").toLowerCase();
  364. if (o) {
  365. if (["eot", "woff", "woff2", "ttf"].indexOf(o) > -1)
  366. return "font";
  367. if (o === "css")
  368. return "css";
  369. if (o === "js")
  370. return "script";
  371. }
  372. return ["fetch", "xmlhttprequest", "beacon"].indexOf(i) > -1 ? "api" : "others";
  373. },
  374. areInOrder: function() {
  375. for (var i = 1; i < arguments.length; i += 1)
  376. if (arguments[i - 1] > arguments[i])
  377. return !1;
  378. return !0;
  379. },
  380. getFetchSnapshot: function(i, s, n) {
  381. var c, o;
  382. try {
  383. var u = (i && typeof i[0] != "string" ? i[0].url : i[0]) || "", h = (i && typeof i[0] != "string" ? i[0] : i[1]) || {}, p = h.method.toUpperCase() === "POST" ? h.body : this.getQuerys(u);
  384. c = {
  385. originApi: u,
  386. method: h.method || "unknown",
  387. params: p,
  388. response: s || "",
  389. reqHeaders: this.parseFetchHeaders(h.headers || null),
  390. resHeaders: this.parseFetchHeaders(n)
  391. }, o = JSON && JSON.stringify(c) || "{}";
  392. } catch (d) {
  393. o = "{}";
  394. }
  395. return o;
  396. },
  397. getXhrSnapshot: function(i, s, n) {
  398. if (!i || !s || !n)
  399. return {};
  400. var c, o;
  401. try {
  402. var u = "";
  403. n.responseType === "" || n.responseType === "text" ? u = n.responseText : n.responseType === "document" && (u = n.responseXML), c = {
  404. originApi: i,
  405. method: s,
  406. params: this.getQuerys(i),
  407. response: u,
  408. reqHeaders: {},
  409. resHeaders: this.parseXhrHeaders(typeof n.getAllResponseHeaders == "function" && n.getAllResponseHeaders() || "")
  410. }, o = JSON && JSON.stringify(c) || "{}";
  411. } catch (h) {
  412. o = "{}";
  413. }
  414. return o;
  415. },
  416. isRobot: function() {
  417. var i = ["nuhk", "googlebot/", "googlebot-image", "yammybot", "openbot", "slurp", "msnbot", "ask jeeves/teoma", "ia_archiver", "baiduspider", "bingbot/", "adsbot"];
  418. if (!navigator || typeof navigator.userAgent != "string")
  419. return !1;
  420. try {
  421. for (var s = navigator.userAgent.toLowerCase(), n = 0; n < i.length; n++) {
  422. var c = i[n];
  423. if (s.lastIndexOf(c) >= 0)
  424. return !0;
  425. }
  426. } catch (o) {
  427. this.warn("[arms] useragent parse error");
  428. }
  429. return !1;
  430. },
  431. isFunction: function(i) {
  432. return typeof i == "function";
  433. },
  434. isPlainObject: function(i) {
  435. return Object.prototype.toString.call(i) === "[object Object]";
  436. },
  437. isString: function(i) {
  438. return Object.prototype.toString.call(i) === "[object String]";
  439. },
  440. isArray: function(i) {
  441. return Object.prototype.toString.call(i) === "[object Array]";
  442. },
  443. joinRegExp: function(i) {
  444. for (var s, n = [], c = 0, o = i.length; c < o; c++)
  445. s = i[c], this.isString(s) ? n.push(s.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1")) : s && s.source && n.push(s.source);
  446. return new RegExp(n.join("|"), "i");
  447. },
  448. reWriteMethod: function(i, s, n) {
  449. if (i !== null) {
  450. var c = i[s];
  451. i[s] = n(c);
  452. }
  453. },
  454. checkSDKError: function(i, s) {
  455. return !i && !s ? !1 : new RegExp(this.selfErrKey, "i").test(i) ? !0 : !!this.ignoreByRule(s, [/retcode.alicdn.com\/retcode\/bl.js/, /g.alicdn.com\/retcode\/cloud-sdk\/bl.js/, /laz-g-cdn.alicdn.com\/retcode\/cloud-sdk\/bl.js/, /local.taobao.com:8880\/build\/bl/]);
  456. },
  457. sdkError: function(i) {
  458. return {
  459. msg: i,
  460. message: this.selfErrKey
  461. };
  462. },
  463. dealParam: function(i, s, n) {
  464. var c = {};
  465. try {
  466. c = this.isPlainObject(i) ? this.ext({
  467. key: i.key || "default",
  468. val: i.val || i.value || n
  469. }, i, {
  470. begin: Date.now()
  471. }) : {
  472. key: i || "default",
  473. val: s || n,
  474. begin: Date.now()
  475. };
  476. } catch (o) {
  477. this.warn("[retcode] baseLog error: " + o);
  478. }
  479. return c;
  480. }
  481. };
  482. return Vi = t, Vi;
  483. }
  484. var Oi = { exports: {} }, Ui = { exports: {} }, Hi, Es;
  485. function Yn() {
  486. if (Es)
  487. return Hi;
  488. Es = 1;
  489. var r = Fe();
  490. return Hi = function(a, e, t) {
  491. typeof a == "object" && (a = r.serialize(a));
  492. var i = e + a + (t ? "&post_res=" : "");
  493. window && window.navigator && typeof window.navigator.sendBeacon == "function" ? window.navigator.sendBeacon(i, t || "&post_res=") : r.warn("[arms] navigator.sendBeacon not surported");
  494. }, Hi;
  495. }
  496. var _s;
  497. function Zn() {
  498. if (_s)
  499. return Ui.exports;
  500. _s = 1;
  501. var r = Fe(), a = Yn(), e = "aokcdqn3ly@e629dabd48a9933", t = function(s, n) {
  502. var c;
  503. if (n.t === "error" && (c = s.requestQueue[0]) && c.t === "error" && n.msg === c.msg)
  504. return n.times = c.times + 1, void (s.requestQueue[0] = n);
  505. if (n.t === "behavior") {
  506. var o = s.requestQueue && s.requestQueue.length;
  507. if (o > 0 && s.requestQueue[o - 1].t === "behavior") {
  508. var u = n.behavior || [];
  509. s.requestQueue[o - 1].behavior.concat(u);
  510. } else
  511. s.requestQueue.push(n);
  512. } else
  513. s.requestQueue.unshift(n);
  514. return s.onReady(function() {
  515. s.requestTimmer = r.delay(function() {
  516. s.clear();
  517. }, s.requestQueue[0] && s.requestQueue[0].t === "error" ? 3e3 : -1);
  518. }), !0;
  519. }, i = function(s) {
  520. return this.ver = "1.8.36-beta.12", this._conf = r.ext({}, i.dftCon), this.sampleCache = {}, this.requestQueue = [], this.selfQueue = [], this.sdkFlag = !0, this.hash = r.seq(), this.resetPageview(), this.setConfig(s), this.rip = r.getRandIP(), this.record = 999, this["EagleEye-TraceID"] = this.getTraceId()["EagleEye-TraceID"], this._common = {}, this;
  521. };
  522. return i.dftCon = {
  523. sample: 1,
  524. pvSample: 1,
  525. tag: "",
  526. imgUrl: "https://arms-retcode.aliyuncs.com/r.png?",
  527. region: null,
  528. ignore: {
  529. ignoreUrls: [],
  530. ignoreApis: [],
  531. ignoreErrors: [/^Script error\.?$/],
  532. ignoreResErrors: [],
  533. ignoreResources: [/\/(bl|wl)(.debug)?.js$/]
  534. },
  535. release: void 0,
  536. environment: "prod",
  537. beforeReport: null,
  538. parseTraceId: null
  539. }, i.prototype = {
  540. constructor: i,
  541. onReady: function(s) {
  542. return s();
  543. },
  544. getPage: function() {
  545. var s = this._conf.page;
  546. return r.safetyCall(s, [], s + "");
  547. },
  548. setPage: function() {
  549. },
  550. setConfig: function(s) {
  551. s && typeof s == "object" && (r.verifyConfig(s), s = this.setImgUrl(s), this._conf = r.ext({}, this._conf, s));
  552. },
  553. setImgUrl: function(s) {
  554. var n = s.region, c = s.imgUrl;
  555. if (n) {
  556. var o = r.regionMap[n];
  557. return s.imgUrl = o || r.defaultImgUrl, s;
  558. }
  559. return c && (s.imgUrl = c), s;
  560. },
  561. checkImgUrl: function() {
  562. return !0;
  563. },
  564. sendRequest: function() {
  565. },
  566. sendBeacon: function(s, n, c) {
  567. a(s, n || this.getConfig("imgUrl"), c);
  568. },
  569. postData: function() {
  570. },
  571. commonInfo: function() {
  572. return {};
  573. },
  574. setCommonInfo: function(s) {
  575. s && typeof s == "object" && (this._common = r.ext({}, this._common, s));
  576. },
  577. resetPageview: function() {
  578. this.pageview = r.uu(), this.sBegin = Date.now();
  579. },
  580. getUsername: function() {
  581. if (this.username)
  582. return this.username;
  583. var s = this._conf, n = s && s.setUsername;
  584. if (typeof n == "function")
  585. try {
  586. var c = n();
  587. typeof c == "string" && (c = c.substr(0, 40), this.username = c);
  588. } catch (o) {
  589. r.warn("[arms] setUsername fail", o);
  590. }
  591. return this.username;
  592. },
  593. getTraceId: function() {
  594. var s = this.rip, n = Date.now(), c = r.getSortNum(this.record), o = s + n + c + r.getRandNum(this._conf.pid);
  595. return this["EagleEye-TraceID"] = o, this.record = c, {
  596. "EagleEye-TraceID": o
  597. };
  598. },
  599. getUberTraceId: function(s) {
  600. var n = this.rip, c = Date.now(), o = r.getSortNum(this.record), u = r.getRandNum(this._conf.pid), h = n + c + o + r.getNum(2) + u, p = h.substring(0, 16);
  601. return s = s ? "1" : "0", h[0] === "0" && (h[0] = "1"), h[16] === "0" && (h[16] = "1"), {
  602. "uber-trace-id": h + ":" + p + ":0:" + s,
  603. traceId: h
  604. };
  605. },
  606. getB3TraceId: function(s) {
  607. var n = this.rip, c = Date.now(), o = r.getSortNum(this.record), u = r.getRandNum(this._conf.pid), h = n + c + o + r.getNum(2) + u, p = h.substring(0, 16);
  608. return s = s ? "1" : "0", h[0] === "0" && (h[0] = "1"), h[16] === "0" && (h[16] = "1"), {
  609. b3: h + "-" + p + "-" + s + "-0",
  610. "X-B3-TraceId": h,
  611. "X-B3-ParentSpanId": "0",
  612. "X-B3-SpanId": p,
  613. "X-B3-Sampled": s
  614. };
  615. },
  616. getPageviewId: function() {
  617. return {
  618. "EagleEye-SessionID": this.pageview
  619. };
  620. },
  621. getConfig: function(s) {
  622. return s ? this._conf[s] : r.ext({}, this._conf);
  623. },
  624. sampling: function(s) {
  625. return s === 1 || (typeof this.sampleCache[s] == "boolean" ? this.sampleCache[s] : (this.sampleCache[s] = r.pick(s), this.sampleCache[s]));
  626. },
  627. clear: function(s) {
  628. var n;
  629. clearTimeout(this.requestTimmer), this.requestTimmer = null;
  630. for (var c = this._conf && typeof this._conf.sendRequest == "function"; n = this.requestQueue.pop(); )
  631. if (n.t === "res")
  632. this.postData(n, "res");
  633. else if (n.t === "error")
  634. this.postData(n, "err");
  635. else if (n.t === "api")
  636. this.postData(n, "apiSnapshot");
  637. else if (n.t === "behavior")
  638. this.postData(n, "behavior");
  639. else if (n.t === "health" && !c && window && window.navigator && typeof window.navigator.sendBeacon == "function")
  640. this.sendBeacon(n);
  641. else if (n.t === "resource" && !c && window && window.navigator && typeof window.navigator.sendBeacon == "function") {
  642. var o = JSON.stringify({
  643. resource: n.resource
  644. });
  645. delete n.resource, this.sendBeacon(n, null, o);
  646. } else
  647. n.t === "resource" ? this.postData(n, "resource") : this.sendRequest(n);
  648. return s && this.clearSelf(), this;
  649. },
  650. clearSelf: function() {
  651. var s;
  652. for (clearTimeout(this.Timmer), this.Timmer = null; s = this.selfQueue.pop(); )
  653. this.postData(s, "err");
  654. return this;
  655. },
  656. _lg: function(s, n, c, o) {
  657. var u = this, h = u._conf, p = u.getPage(), d = h.ignore || {}, f = d.ignoreErrors, m = d.ignoreResErrors, l = d.ignoreUrls, S = d.ignoreApis;
  658. if (u._isRobot || r.ignoreByRule(p, l) || r.ignoreByRule(r.decode(p), l) || s === "error" && (r.ignoreByRule(n.msg, f) || r.ignoreByRule(r.decode(n.msg), f)) || s === "resourceError" && (r.ignoreByRule(n.src, m) || r.ignoreByRule(r.decode(n.src), m)) || s === "api" && (r.ignoreByRule(n.api, S) || r.ignoreByRule(r.decode(n.api), S)) || !u.checkImgUrl(h.imgUrl) || !n || h.disabled || !h.pid || o === 0)
  659. return u;
  660. var v = n.dl;
  661. if (delete n.dl, n = r.ext({
  662. t: s,
  663. times: 1,
  664. page: p,
  665. tag: h.tag || "",
  666. release: h.release || "",
  667. environment: h.environment,
  668. begin: Date.now(),
  669. c1: h.c1,
  670. c2: h.c2,
  671. c3: h.c3
  672. }, n, u.commonInfo(), u._common, {
  673. pid: h.pid,
  674. _v: u.ver,
  675. pv_id: u.pageview,
  676. username: u.getUsername(),
  677. sampling: c || 1,
  678. dl: v,
  679. z: r.seq()
  680. }), r.T(h.beforeReport) === "Function")
  681. try {
  682. if (!(n = h.beforeReport(n)))
  683. return u;
  684. } catch (x) {
  685. return u;
  686. }
  687. return o === 1 ? t(u, n) : c && !u.sampling(c) ? u : t(u, n);
  688. },
  689. _self: function(s, n, c) {
  690. var o = this, u = o._conf;
  691. if (s !== "error" || !o.checkImgUrl(u.imgUrl) || !n || u.disabled || !u.pid || !e || c && !o.sampling(c))
  692. return o;
  693. n = r.ext({
  694. t: s,
  695. times: 1,
  696. page: r.selfErrPage,
  697. tag: u.pid,
  698. begin: Date.now()
  699. }, n, {
  700. pid: e,
  701. _v: o.ver,
  702. sampling: c || 1,
  703. z: r.seq()
  704. });
  705. var h = o.selfQueue[0];
  706. if (h) {
  707. h.times++;
  708. try {
  709. h.err && n.err && h.err.msg_raw && n.err.msg_raw && h.err.msg_raw.split("&").indexOf(n.err.msg_raw) < 0 && h.err.msg_raw.length < 1e3 && (h.err.msg_raw += "&" + n.err.msg_raw);
  710. } catch (p) {
  711. }
  712. } else
  713. o.selfQueue.unshift(n), o.onReady(function() {
  714. o.sdkFlag && (o.sdkFlag = !1, o.Timmer = r.delay(function() {
  715. o.clearSelf();
  716. }, 1e4));
  717. });
  718. },
  719. custom: function(s, n) {
  720. if (!s || typeof s != "object")
  721. return this;
  722. var c = !1, o = {
  723. begin: Date.now()
  724. };
  725. return r.each(s, function(u, h) {
  726. return !(c = h && h.length <= 20) && r.warn("[retcode] invalid key: " + h), o["x-" + h] = u, c;
  727. }), c ? this._lg("custom", o, n || 1) : this;
  728. }
  729. }, Ui.exports = i, Ui.exports;
  730. }
  731. var As;
  732. function Qn() {
  733. if (As)
  734. return Oi.exports;
  735. As = 1;
  736. var r = Fe(), a = Zn(), e = ["api", "success", "time", "code", "msg", "trace", "traceId", "begin", "pv_id", "sid", "seq", "domain", "flag", "apiSnapshot", "tag", "c1", "c2", "c3"], t = function(s) {
  737. var n = (s.key || "default").split("::");
  738. return n.length > 1 ? r.ext(s, {
  739. group: n[0],
  740. key: n[1]
  741. }) : r.ext(s, {
  742. group: "default_group",
  743. key: n[0]
  744. });
  745. }, i = function(s) {
  746. a.call(this, s);
  747. var n;
  748. try {
  749. n = typeof performance == "object" ? performance.timing.fetchStart : Date.now();
  750. } catch (c) {
  751. n = Date.now();
  752. }
  753. return this._startTime = n, this;
  754. };
  755. return i.prototype = r.createObject(a.prototype), r.ext(a.dftCon, {
  756. startTime: null
  757. }), r.ext(i.prototype, {
  758. constructor: i,
  759. _super: a,
  760. sum: function(s, n, c) {
  761. try {
  762. var o = r.dealParam(s, n, 1);
  763. return this._lg("sum", t(o), c);
  764. } catch (u) {
  765. r.warn("[retcode] can not get parseStatData: " + u);
  766. }
  767. },
  768. avg: function(s, n, c) {
  769. try {
  770. var o = r.dealParam(s, n, 0);
  771. return this._lg("avg", t(o), c);
  772. } catch (u) {
  773. r.warn("[retcode] can not get parseStatData: " + u);
  774. }
  775. },
  776. percent: function(s, n, c, o) {
  777. try {
  778. return this._lg("percent", t({
  779. key: s,
  780. subkey: n,
  781. val: c || 0,
  782. begin: Date.now()
  783. }), o);
  784. } catch (u) {
  785. r.warn("[retcode] can not get parseStatData: " + u);
  786. }
  787. },
  788. msg: function(s, n) {
  789. if (s && !(s.length > 180))
  790. return this.custom({
  791. msg: s
  792. }, n);
  793. },
  794. error: function(s, n) {
  795. if (!s)
  796. return r.warn("[retcode] invalid param e: " + s), this;
  797. arguments.length === 1 ? (typeof s == "string" && (s = {
  798. message: s
  799. }, n = {}), typeof s == "object" && (n = s = s.error || s)) : (typeof s == "string" && (s = {
  800. message: s
  801. }), typeof n != "object" && (n = {}));
  802. var c = s.name || "CustomError", o = s.message || "", u = s.stack || "";
  803. n = n || {};
  804. var h = typeof location == "object" && typeof location.href == "string" && location.href.substring(0, 500) || "";
  805. if (r.checkSDKError(o, n.filename)) {
  806. var p = /^Script error\.?$/, d = s.msg || s.message;
  807. if (r.ignoreByRule(d, p) || r.ignoreByRule(r.decode(d), p))
  808. return this;
  809. var f = {
  810. msg: r.selfErrKey,
  811. err: {
  812. msg_raw: r.encode(s.msg || s.message)
  813. }
  814. };
  815. return this._self("error", f, 1);
  816. }
  817. for (var m = {
  818. begin: Date.now(),
  819. cate: c,
  820. msg: o && o.substring(0, 1e3),
  821. stack: u && u.substring(0, 1e3),
  822. file: r.removeUrlSearch(n.filename || ""),
  823. line: n.lineno || "",
  824. col: n.colno || "",
  825. err: {
  826. msg_raw: r.encode(o),
  827. stack_raw: r.encode(u)
  828. },
  829. dl: h
  830. }, l = ["tag", "c1", "c2", "c3"], S = 0; S < l.length; S++) {
  831. var v = l[S];
  832. n[v] && (m[v] = n[v]);
  833. }
  834. var x = (this.getConfig("ignore") || {}).ignoreErrors;
  835. return r.ignoreByRule(m.msg, x) || r.ignoreByRule(r.decode(m.msg), x) ? this : (this.beforeSend && this.beforeSend("error", m), this._lg("error", m, 1));
  836. },
  837. behavior: function(s) {
  838. if (s) {
  839. var n = typeof s == "object" && s.behavior ? s : {
  840. behavior: s
  841. };
  842. return this.beforeSend && this.beforeSend("behavior", n), this._lg("behavior", n, 1);
  843. }
  844. },
  845. api: function(s, n, c, o, u, h, p, d, f, m, l, S, v, x, b, E) {
  846. if (!s)
  847. return r.warn("[retcode] api is null"), this;
  848. if (s = typeof s == "string" ? {
  849. api: s,
  850. success: n,
  851. time: c,
  852. code: o,
  853. msg: u,
  854. begin: h,
  855. traceId: p,
  856. pv_id: d,
  857. apiSnapshot: f,
  858. domain: m,
  859. flag: S,
  860. tag: v,
  861. c1: x,
  862. c2: b,
  863. c3: E
  864. } : r.sub(s, e), !r.checkAPI(s.api, !0))
  865. return this;
  866. s.code = s.code || "";
  867. var _ = s.msg || "";
  868. if (_ = typeof _ == "string" ? _.substring(0, 1e3) : _, s.msg = _, s.success = s.success ? 1 : 0, s.time = +s.time, s.begin = s.begin, s.traceId = s.traceId || "", s.pv_id = s.pv_id || "", s.domain = s.domain || "", s.flag = s.flag, s.dl = typeof location == "object" && typeof location.href == "string" && location.href.substring(0, 500) || "", s.apiSnapshot && (typeof s.apiSnapshot == "object" && (s.apiSnapshot = JSON.stringify(s.apiSnapshot)), typeof s.apiSnapshot != "string" && delete s.apiSnapshot, s.apiSnapshot.length > 2e3 && (s.apiSnapshot = s.apiSnapshot.substring(0, 2e3))), l && (s.traceOrigin = l), !s.api || isNaN(s.time))
  869. return r.warn("[retcode] invalid time or api"), this;
  870. var y = (this.getConfig("ignore") || {}).ignoreApis;
  871. return r.ignoreByRule(s.api, y) || r.ignoreByRule(r.decode(s.api), y) ? this : s.time < 0 ? this : (this.beforeSend && this.beforeSend("api", s), this._lg("api", s, s.success && this.getConfig("sample"), s.flag));
  872. },
  873. speed: function(s, n, c) {
  874. var o = this, u = this.getConfig("startTime") || this._startTime;
  875. return /^s(\d|1[0])$/.test(s) ? (n = typeof n != "number" ? Date.now() - u : n >= u ? n - u : n, o.speedCache = o.speedCache || {}, o.speedCache[s] = n, o.speedCache.begin = u, clearTimeout(o.speedTimmer), o.speedTimmer = setTimeout(function() {
  876. c || (o.speedCache.page = o.getPage(!0)), o._lg("speed", o.speedCache), o.speedCache = null;
  877. }, 5e3), o) : (r.warn("[retcode] invalid point: " + s), o);
  878. },
  879. performance: function(s) {
  880. if (s && typeof s == "object" && !this.hasSendPerf) {
  881. var n = {}, c = {}, o = this.getConfig("autoSendPerf");
  882. if (s.autoSend && o)
  883. return c = r.ext(this.perfData || {}, s), this.hasSendPerf = !0, this._lg("perf", c, this.getConfig("sample"));
  884. if (s.autoSend && !o)
  885. return delete s.autoSend, this.perfData ? (c = r.ext(this.perfData || {}, s), this.hasSendPerf = !0, this._lg("perf", c, this.getConfig("sample"))) : void (this.perfData = s);
  886. for (var u in s)
  887. (/^t([1-9]|1[0])$/.test(u) || u === "ctti" || u === "cfpt") && (n[u] = s[u]);
  888. if (s.autoSend === !0 || !o && (o || this.perfData))
  889. return s.autoSend !== !0 && o === !1 && this.perfData ? (n = r.ext(this.perfData || {}, n), this.hasSendPerf = !0, this._lg("perf", n, this.getConfig("sample"))) : void 0;
  890. this.perfData = r.ext(this.perfData || {}, n);
  891. }
  892. },
  893. resource: function(s, n) {
  894. if (!s || !r.isPlainObject(s))
  895. return r.warn("[arms] invalid param data: " + s), this;
  896. var c = Object.keys(s), o = ["begin", "dom", "load", "res", "dl"], u = !1;
  897. for (var h in o)
  898. if (c.indexOf(o[h]) < 0) {
  899. u = !0;
  900. break;
  901. }
  902. if (u)
  903. return r.warn("[arms] lack param data: " + s), this;
  904. var p = {
  905. begin: s.begin || Date.now(),
  906. dom: s.dom || "",
  907. load: s.load || "",
  908. res: r.isArray(s.res) ? JSON.stringify(s.res) : JSON.stringify([]),
  909. dl: s.dl || ""
  910. };
  911. return this._lg("res", p, n);
  912. },
  913. event: function(s, n) {
  914. if (typeof s == "object" && s && s.key) {
  915. var c = {}, o = ["key", "success", "time", "c1", "c2", "c3"];
  916. for (var u in s)
  917. o.indexOf(u) > -1 && (c[u] = s[u]);
  918. c.success = s.success === !1 ? 0 : 1, this._lg("event", c, n);
  919. }
  920. }
  921. }), i._super = a, i._root = a, a.Reporter = i, Oi.exports = i, Oi.exports;
  922. }
  923. var ji = { exports: {} }, ys;
  924. function eo() {
  925. if (ys)
  926. return ji.exports;
  927. ys = 1;
  928. var r = Fe(), a = typeof window == "object" ? window : {}, e = "catch", t = a.__oFetch_ || a.fetch;
  929. return t = typeof t == "function" ? t : void 0, ji.exports = function(i, s) {
  930. var n = -1;
  931. typeof i == "object" && (n = i.z, i = r.serialize(i));
  932. var c = s + i;
  933. if (t)
  934. return t(c, {
  935. method: "HEAD",
  936. mode: "no-cors"
  937. })[e](r.noop);
  938. if (a.document && a.document.createElement) {
  939. var o = "__request_hold_" + n, u = a[o] = new Image();
  940. u.onload = u.onerror = function() {
  941. a[o] = void 0;
  942. }, u.src = c, u = null;
  943. }
  944. }, ji.exports;
  945. }
  946. var zi = { exports: {} }, Cs;
  947. function to() {
  948. if (Cs)
  949. return zi.exports;
  950. Cs = 1;
  951. var r = Fe(), a = typeof window == "object" ? window : {}, e = a.__oXMLHttpRequest_ || a.XMLHttpRequest;
  952. return e = typeof e == "function" ? e : void 0, zi.exports = function(t, i) {
  953. try {
  954. var s = new e();
  955. s.open("POST", i, !0), s.setRequestHeader("Content-Type", "text/plain"), s.send(JSON.stringify(t));
  956. } catch (n) {
  957. r.warn(`[retcode] Failed to log, exception is :
  958. ` + n);
  959. }
  960. }, zi.exports;
  961. }
  962. var Wi, Rs;
  963. function io() {
  964. if (Rs)
  965. return Wi;
  966. Rs = 1;
  967. var r = Fe();
  968. return Wi = function(a, e) {
  969. var t = [], i = null, s = e && e.location && e.location.href, n = void 0, c = null, o = function(d, f, m) {
  970. if (d !== null) {
  971. var l = d[f];
  972. d[f] = m(l);
  973. }
  974. }, u = function(d) {
  975. var f, m, l, S, v, x = [];
  976. if (!d || typeof d.tagName != "string")
  977. return "";
  978. if (x.push(d.tagName.toLowerCase()), typeof d.id == "string" && x.push("#".concat(d.id)), typeof (f = d.className) == "string")
  979. for (m = f.split(/\s+/), v = 0; v < m.length; v++)
  980. x.push(".".concat(m[v]));
  981. var b = ["type", "name", "title", "alt", "data-arms-attr"];
  982. for (v = 0; v < b.length; v++)
  983. l = b[v], typeof (S = d.getAttribute(l)) == "string" && x.push("[".concat(l, '="').concat(S, '"]'));
  984. return x.join("");
  985. }, h = function(d, f) {
  986. return function(m) {
  987. if (m && m !== c) {
  988. c = m;
  989. var l;
  990. try {
  991. l = m.target;
  992. } catch (v) {
  993. l = "<unknown>";
  994. }
  995. if (l.length !== 0) {
  996. var S = {
  997. type: "ui.".concat(d),
  998. data: {
  999. message: function(v) {
  1000. if (!v || v.nodeType !== 1)
  1001. return "";
  1002. for (var x = v || null, b = [], E = 0, _ = 0, y = 3, A = ""; x && E++ < 5 && !((A = u(x)) === "html" || E > 1 && _ + b.length * y + A.length >= 80); )
  1003. b.push(A), _ += A.length, x = x.parentNode;
  1004. return b.reverse().join(" > ");
  1005. }(l)
  1006. },
  1007. timestamp: Date.now()
  1008. };
  1009. d === "click" ? i && i.addBehavior(S) : d === "keypress" && (n || i && i.addBehavior(S), clearTimeout(n), n = setTimeout(function() {
  1010. n = void 0;
  1011. }, 100));
  1012. }
  1013. }
  1014. };
  1015. }, p = function() {
  1016. if (function() {
  1017. var l = e && e.chrome, S = l && l.app && l.app.runtime, v = "history" in e && !!e.history.pushState && !!e.history.replaceState;
  1018. return !S && v;
  1019. }()) {
  1020. var d = function(l, S) {
  1021. var v = {
  1022. type: "navigation",
  1023. data: {
  1024. from: l,
  1025. to: S
  1026. }
  1027. };
  1028. i && i.addBehavior(v), s = S;
  1029. }, f = e.onpopstate;
  1030. e.onpopstate = function() {
  1031. for (var l = arguments.length, S = new Array(l), v = 0; v < l; v++)
  1032. S[v] = arguments[v];
  1033. var x = e.location.href;
  1034. if (d(s, x), f)
  1035. return f.apply(this, S);
  1036. };
  1037. var m = function(l) {
  1038. return function() {
  1039. for (var S = arguments.length, v = new Array(S), x = 0; x < S; x++)
  1040. v[x] = arguments[x];
  1041. var b = v.length > 2 ? v[2] : void 0;
  1042. return b && d(s, String(b)), l.apply(this, v);
  1043. };
  1044. };
  1045. o(e.history, "pushState", m), o(e.history, "replaceState", m);
  1046. }
  1047. };
  1048. r.ext(a.prototype, {
  1049. addBehavior: function(d) {
  1050. if (this.getConfig("behavior") && d && typeof d == "object") {
  1051. var f = {}, m = d.data || {};
  1052. if (d.type)
  1053. f = m;
  1054. else {
  1055. if (typeof m.name != "string" || typeof m.message != "string")
  1056. return;
  1057. f.name = m.name.substr(0, 20), f.message = m.message.substr(0, 200);
  1058. }
  1059. f.message && (f.message = r.encode(f.message));
  1060. var l = {
  1061. type: d.type || "custom",
  1062. data: f || {},
  1063. timestamp: d.timestamp || Date.now(),
  1064. page: d.page || e && e.location && e.location.pathname
  1065. };
  1066. return t.push(l), t = t.slice(-100);
  1067. }
  1068. },
  1069. getBehavior: function() {
  1070. return t || [];
  1071. },
  1072. setBehavior: function(d) {
  1073. return d && (t = d), t;
  1074. },
  1075. reportBehavior: function(d) {
  1076. var f = this;
  1077. f.getConfig("behavior") && (f.sendBhTimer && (clearTimeout(f.sendBhTimer), f.sendBhTimer = void 0), f.sendBhTimer = setTimeout(function() {
  1078. t && t.length > 0 && (f.behavior(t), t = [], f.sendBhTimer = void 0, d && typeof d == "function" && d());
  1079. }, 0));
  1080. },
  1081. initBehavior: function() {
  1082. if (!this.hasInitBehavior && !i) {
  1083. try {
  1084. (function() {
  1085. if (document && document.referrer && document.location) {
  1086. var f = document.referrer, m = document.location.href;
  1087. if (f !== "") {
  1088. var l = {
  1089. type: "navigation",
  1090. data: {
  1091. from: f,
  1092. to: m
  1093. }
  1094. };
  1095. s = m, i && i.addBehavior(l);
  1096. }
  1097. }
  1098. })(), e && e.document && e.document.addEventListener && (e.document.addEventListener("click", h("click"), !1), e.document.addEventListener("keypress", h("keypress"), !1)), p();
  1099. var d = this.getConfig("enableConsole");
  1100. d && function(f) {
  1101. if (e && e.console) {
  1102. var m = ["debug", "info", "warn", "log", "error", "assert"];
  1103. r.isArray(f) && (m = f);
  1104. for (var l = 0; l < m.length; l++) {
  1105. var S = m[l];
  1106. S && r.isString(S) && e.console[S] && typeof e.console[S] == "function" && o(e.console, S, function(v) {
  1107. var x = S;
  1108. return function() {
  1109. for (var b = arguments.length, E = new Array(b), _ = 0; _ < b; _++)
  1110. E[_] = arguments[_];
  1111. var y = {
  1112. type: "console",
  1113. data: {
  1114. level: x,
  1115. message: E
  1116. }
  1117. };
  1118. if (i && i.addBehavior(y), x === "error")
  1119. for (var A = 0; A < E.length; A++) {
  1120. var R = E[A];
  1121. R && R.message && R.stack && i && i.errorHandler(new ErrorEvent("error", {
  1122. error: R,
  1123. message: R.message
  1124. }));
  1125. }
  1126. v && Function.prototype.apply.call(v, e.console, E);
  1127. };
  1128. });
  1129. }
  1130. }
  1131. }(d);
  1132. } catch (f) {
  1133. r.warn("[arms] error in initBehavior", f);
  1134. }
  1135. i = this, this.hasInitBehavior = !0;
  1136. }
  1137. return this;
  1138. }
  1139. });
  1140. }, Wi;
  1141. }
  1142. var Is = {}, ws;
  1143. function Kr() {
  1144. return ws || (ws = 1, Is.TIMING_KEYS = ["startTime", "fetchStart", "domainLookupStart", "domainLookupEnd", "connectStart", "connectEnd", "requestStart", "responseStart", "responseEnd", "", "domInteractive", "", "domContentLoadedEventEnd", "", "loadEventStart", "", "msFirstPaint", "secureConnectionStart", "redirectStart", "redirectEnd"]), Is;
  1145. }
  1146. var $i, Ds;
  1147. function ro() {
  1148. if (Ds)
  1149. return $i;
  1150. Ds = 1;
  1151. var r = Fe(), a = Kr(), e = a.TIMING_KEYS;
  1152. return $i = function() {
  1153. var t = r.win || {}, i = t.performance;
  1154. if (!i || typeof i != "object" || typeof i.getEntriesByType != "function")
  1155. return null;
  1156. var s = {}, n = i.timing || {}, c = i.getEntriesByType("resource") || [];
  1157. if (s.begin = n[e[1]] || Date.now(), typeof t.PerformanceNavigationTiming == "function") {
  1158. var o = i.getEntriesByType("navigation")[0];
  1159. o && (n = o);
  1160. }
  1161. return r.each({
  1162. dom: [10, 8],
  1163. load: [14, 1]
  1164. }, function(u, h) {
  1165. var p = n[e[u[1]]], d = n[e[u[0]]];
  1166. if (p > 0 && d > 0) {
  1167. var f = Math.round(d - p);
  1168. f >= 0 && f < 6e5 && (s[h] = f);
  1169. }
  1170. }), s.res = JSON.stringify(c), s;
  1171. }, $i;
  1172. }
  1173. var Ki, Ts;
  1174. function so() {
  1175. if (Ts)
  1176. return Ki;
  1177. Ts = 1;
  1178. var r = Fe(), a = Kr(), e = a.TIMING_KEYS;
  1179. return Ki = function() {
  1180. var t = r.win || {}, i = t.performance;
  1181. if (!i || typeof i != "object")
  1182. return null;
  1183. var s = {}, n = i.timing || {}, c = Date.now(), o = 1;
  1184. if (typeof t.PerformanceNavigationTiming == "function") {
  1185. var u = i.getEntriesByType("navigation")[0];
  1186. u && (n = u, o = 2);
  1187. }
  1188. r.each({
  1189. dns: [3, 2],
  1190. tcp: [5, 4],
  1191. ssl: [5, 17],
  1192. ttfb: [7, 6],
  1193. trans: [8, 7],
  1194. dom: [10, 8],
  1195. res: [14, 12],
  1196. firstbyte: [7, 2],
  1197. fpt: [8, 1],
  1198. tti: [10, 1],
  1199. ready: [12, 1],
  1200. load: [14, 1]
  1201. }, function(m, l) {
  1202. var S = n[e[m[1]]], v = n[e[m[0]]];
  1203. if (o === 2 || S > 0 && v > 0) {
  1204. var x = Math.round(v - S);
  1205. x >= 0 && x < 6e5 && (s[l] = x);
  1206. }
  1207. });
  1208. var h = t.navigator.connection, p = i.navigation || {};
  1209. s.ct = h ? h.effectiveType || h.type : "";
  1210. var d = h && (h.downlink || h.downlinkMax || h.bandwidth) || null;
  1211. if ((d = d > 999 ? 999 : d) && (s.bandwidth = d), s.navtype = p.type === 1 ? "Reload" : "Other", o === 1 && n[e[16]] > 0 && n[e[1]] > 0) {
  1212. var f = n[e[16]] - n[e[1]];
  1213. f >= 0 && f < 36e5 && (s.fpt = f);
  1214. }
  1215. return o === 1 && n[e[1]] > 0 ? s.begin = n[e[1]] : o === 2 && s.load > 0 ? s.begin = c - s.load : s.begin = c, s;
  1216. }, Ki;
  1217. }
  1218. var Ps, ks;
  1219. function ao() {
  1220. return ks || (ks = 1, Ps = function(r, a, e) {
  1221. var t = Fe(), i = ro(), s = so(), n = null, c = e.documentElement, o = a.innerWidth || c.clientWidth || e.body.clientWidth, u = a.innerHeight || c.clientHeight || e.body.clientHeight, h = a.navigator.connection, p = {
  1222. sr: screen.width + "x" + screen.height,
  1223. vp: o + "x" + u,
  1224. ct: h ? h.effectiveType || h.type : ""
  1225. }, d = {}, f = function(l, S, v, x, b) {
  1226. if (S === void 0) {
  1227. var E, _;
  1228. if (!d[l]) {
  1229. E = new RegExp(l + "=([^;]+)");
  1230. try {
  1231. _ = E.exec(e.cookie);
  1232. } catch (A) {
  1233. return t.warn("[retcode] can not get cookie:", A), null;
  1234. }
  1235. _ && (d[l] = _[1]);
  1236. }
  1237. return d[l];
  1238. }
  1239. var y = l + "=" + S;
  1240. y += "; path=/", v && (y += "; max-age=" + v);
  1241. try {
  1242. return e.cookie = y, !!e.cookie;
  1243. } catch (A) {
  1244. return t.warn("[retcode] can not set cookie: ", A), !1;
  1245. }
  1246. }, m = function(l) {
  1247. var S = l._conf.uid || f("_nk_") || f("_bl_uid");
  1248. return !S && (S = t.uu(), !f("_bl_uid", S, 15552e3)) ? null : S;
  1249. };
  1250. return t.ext(r.prototype, {
  1251. activeErrHandler: function(l) {
  1252. return n && !l ? this : (n = this, this);
  1253. },
  1254. errorHandler: function(l) {
  1255. if (!l)
  1256. return this;
  1257. var S = l.type;
  1258. if (S === "error") {
  1259. var v = l.target || l.srcElement;
  1260. !v || !v.tagName || l.message || l.filename || l.lineno || l.colno ? this.error(l.error || {
  1261. message: l.message
  1262. }, l) : this.resourceErrorHandler(l);
  1263. } else
  1264. S === "unhandledrejection" && t.T(l.reason, "Error") && t.checkAutoError(l.reason) && this.error(l.reason);
  1265. try {
  1266. this.getConfig("behavior") && this.reportBehavior && this.reportBehavior();
  1267. } catch (x) {
  1268. }
  1269. return this;
  1270. },
  1271. resourceErrorHandler: function(l) {
  1272. var S = this, v = l.target || l.srcElement;
  1273. try {
  1274. var x = S.getSrc(v), b = typeof v.tagName == "string" ? v.tagName.toLowerCase() : "", E = S.getXPath(v, 5), _ = t.getURL(x), y = {
  1275. src: x && x.substring(0, 1e3),
  1276. node_name: b,
  1277. xpath: E,
  1278. res_type: t.getResType(b, x),
  1279. res_name: _.path,
  1280. domain: _.domain
  1281. };
  1282. return S._conf.enableResource && S.fixResourceStatus && l.timeStamp && S.fixResourceStatus({
  1283. src: x,
  1284. node_name: b,
  1285. res_type: t.getResType(b, x),
  1286. timeStamp: l.timeStamp,
  1287. domain: _.domain
  1288. }), S._lg("resourceError", y), S;
  1289. } catch (A) {
  1290. return t.warn("[ARMS] resourceErrorHandler error :", A), S;
  1291. }
  1292. },
  1293. getSrc: function(l) {
  1294. var S = l.src || l.href;
  1295. try {
  1296. if (!S) {
  1297. var v = (typeof l.tagName == "string" ? l.tagName.toLowerCase() : "") === "object", x = l.getAttribute("classid") && l.getAttribute("classid").toLowerCase() === "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" || l.getAttribute("type") === "application/x-shockwave-flash";
  1298. v && x && (S = l.getAttribute("data") || l.getAttribute("codebase")), S || (S = l.outerHTML || l.innerHTML);
  1299. }
  1300. } catch (b) {
  1301. S = "";
  1302. }
  1303. return S;
  1304. },
  1305. getXPath: function(l, S) {
  1306. var v = l.id ? "#" + l.id : "", x = typeof l.className == "string" ? "." + l.className.split(" ").join(".") : "", b = (typeof l.tagName == "string" ? l.tagName.toLowerCase() : "") + v + x;
  1307. return l.parentNode && l.parentNode.tagName && S - 1 != 0 ? this.getXPath(l.parentNode, S - 1) + " > " + b : b;
  1308. },
  1309. sendPerformance: function(l) {
  1310. var S = this;
  1311. S.onReady(function() {
  1312. var v = s();
  1313. v && v.load && v.load > 0 && (v.page = S.getPage(!0), l && (v = t.ext(v, l)), v.autoSend = !0, S.performance(v));
  1314. });
  1315. },
  1316. sendResources: function(l) {
  1317. var S = this;
  1318. S.onReady(function() {
  1319. var v = i();
  1320. v && v.load && v.load > 0 && (v.load && v.load <= 2e3 || v.load && v.load <= 8e3 && Math.random() > 0.05 || (v.page = S.getPage(!0), v.dl = location.href, l && (v = t.ext(v, l)), S._lg("res", v, S.getConfig("sample"))));
  1321. });
  1322. },
  1323. sendPV: function() {
  1324. var l = this;
  1325. l.onReady(function() {
  1326. var S = function(v) {
  1327. var x = m(v), b = a.devicePixelRatio || 1;
  1328. return {
  1329. uid: x,
  1330. dt: e.title,
  1331. dl: location.href,
  1332. dr: e.referrer,
  1333. dpr: b.toFixed(2),
  1334. de: (e.characterSet || e.defaultCharset || "").toLowerCase(),
  1335. ul: c.lang,
  1336. begin: Date.now()
  1337. };
  1338. }(l);
  1339. S && S.uid && l._lg("pv", S, l.getConfig("pvSample"));
  1340. });
  1341. },
  1342. commonInfo: function() {
  1343. return p.uid = m(this), p.sid = function(l) {
  1344. if (l.session)
  1345. return l.session;
  1346. var S;
  1347. try {
  1348. if (typeof window == "object" && typeof sessionStorage == "object" && typeof sessionStorage.getItem == "function")
  1349. return typeof (S = sessionStorage.getItem("_bl_sid")) == "string" ? (l.session = S, S) : (S = t.uu(), l.session = S, typeof sessionStorage.setItem == "function" && sessionStorage.setItem("_bl_sid", S), S);
  1350. } catch (v) {
  1351. t.warn("[ARMS] getSid error :", v);
  1352. }
  1353. return l.session = S = t.uu(), S;
  1354. }(this), p;
  1355. },
  1356. handleUnload: function(l) {
  1357. var S = Date.now();
  1358. if (S - this._lastUnload < 200)
  1359. return this;
  1360. this._lastUnload = S, this.sendHealth(l), this.speedCache && (this._lg("speed", this.speedCache), this.speedCache = null, clearTimeout(this.speedTimmer)), this._conf && this._conf.enableResource && this.resourceComboReport(), this.clear(!0);
  1361. },
  1362. bindHashChange: function(l) {
  1363. var S = this;
  1364. if (!l ^ S.hashChangeHandler)
  1365. return S;
  1366. l ? (S.hackHistoryState(), S.hashChangeHandler = function(v) {
  1367. var x = S._conf.parseHash(location.hash);
  1368. x && S.setPage(x, v !== !1);
  1369. }, S.stateChangeHandler = function(v) {
  1370. var x = S._conf.parseHash(v.detail);
  1371. x && S.setPage(x);
  1372. }, t.on(a, "hashchange", S.hashChangeHandler), t.on(a, "historystatechange", S.stateChangeHandler), S.hashChangeHandler(!1)) : (t.off(a, "hashchange", S.hashChangeHandler), t.off(a, "historystatechange", S.stateChangeHandler), S.hashChangeHandler = null, S.stateChangeHandler = null);
  1373. },
  1374. initHandler: function() {
  1375. var l = this;
  1376. if (l.hasInitHandler)
  1377. return l;
  1378. var S = l._conf;
  1379. return t.on(a, "beforeunload", function() {
  1380. l.handleUnload(0);
  1381. }), l.bindHashChange(S.enableSPA), l.activeErrHandler(!1), l.hasInitHandler = !0, l;
  1382. }
  1383. }), t.on(a, "error", function(l) {
  1384. n && n.errorHandler(l);
  1385. }, !1, !0).on(a, "unhandledrejection", function(l) {
  1386. n && n.errorHandler(l);
  1387. }), r;
  1388. }), Ps;
  1389. }
  1390. var qi, Bs;
  1391. function no() {
  1392. if (Bs)
  1393. return qi;
  1394. Bs = 1;
  1395. var r = Fe(), a = 500;
  1396. return qi = function(e, t, i) {
  1397. function s(p, d, f) {
  1398. var m = 0, l = p.tagName;
  1399. if (l !== "SCRIPT" && l !== "STYLE" && l !== "META" && l !== "HEAD") {
  1400. var S = p.children ? p.children.length : 0;
  1401. if (S > 0)
  1402. for (var v = p.children, x = S - 1; x >= 0; x--)
  1403. m += s(v[x], d + 1, m > 0);
  1404. if (m <= 0 && !f && !(p.getBoundingClientRect && p.getBoundingClientRect().top < c))
  1405. return 0;
  1406. m += 1 + 0.5 * d;
  1407. }
  1408. return m;
  1409. }
  1410. function n(p) {
  1411. for (var d = 1; d < p.length; d++)
  1412. if (p[d].score < p[d - 1].score)
  1413. return p.splice(d, 1), n(p);
  1414. return p;
  1415. }
  1416. var c = t.innerHeight || 0, o = [], u = null, h = 0;
  1417. r.ext(e.prototype, {
  1418. initFmpObserver: function(p) {
  1419. var d = this;
  1420. if (!d._conf || !d._conf.useFmp)
  1421. return null;
  1422. if (!t.MutationObserver)
  1423. return r.warn("[retcode] first meaningful paint can not be retrieved"), d.sendPerformance(), null;
  1424. r.on(t, "beforeunload", function() {
  1425. d.endObserving(0, !0);
  1426. });
  1427. var f = t.MutationObserver;
  1428. return (u = new f(function() {
  1429. (function(m) {
  1430. var l = Date.now() - m, S = i.querySelector("body");
  1431. if (S) {
  1432. var v = 0;
  1433. v += s(S, 1, !1), o.push({
  1434. score: v,
  1435. t: l
  1436. });
  1437. } else
  1438. o.push({
  1439. score: 0,
  1440. t: l
  1441. });
  1442. })(d._startTime);
  1443. })).observe(document, {
  1444. childList: !0,
  1445. subtree: !0
  1446. }), h = 1, d.onReady(function() {
  1447. d.endObserving(p);
  1448. }), u;
  1449. },
  1450. endObserving: function(p, d) {
  1451. var f = this;
  1452. if (u && h)
  1453. if (f.fmpTimmer && (clearTimeout(f.fmpTimmer), f.fmpTimmer = null), d || !function(v, x) {
  1454. var b = Date.now() - v;
  1455. return !(b > x || b - (o && o.length && o[o.length - 1].t || 0) > 2 * a);
  1456. }(f._startTime, p)) {
  1457. u.disconnect(), h = 0, o = n(o);
  1458. for (var m = null, l = 1; l < o.length; l++)
  1459. if (o[l].t >= o[l - 1].t) {
  1460. var S = o[l].score - o[l - 1].score;
  1461. (!m || m.rate <= S) && (m = {
  1462. t: o[l].t,
  1463. rate: S
  1464. });
  1465. }
  1466. m && m.t > 0 && m.t < 36e5 ? f.sendPerformance({
  1467. fmp: m.t
  1468. }) : f.sendPerformance();
  1469. } else
  1470. f.fmpTimmer = r.delay(function() {
  1471. f.endObserving(p);
  1472. }, a);
  1473. }
  1474. });
  1475. }, qi;
  1476. }
  1477. var Ns, Ms;
  1478. function oo() {
  1479. return Ms || (Ms = 1, Ns = function(r, a) {
  1480. var e = Fe(), t = null, i = e.getCurDomain(), s = function(h, p, d, f, m, l, S, v, x, b, E, _, y) {
  1481. var A = e.J(m) || null, R = e.safetyCall(p, [A, f], null);
  1482. if (!R)
  1483. return !1;
  1484. var M = R.code || l, C = !("success" in R) || R.success;
  1485. h.api(d, C, S, M, R.msg, v, x, b, C ? {} : E, i, _, y);
  1486. }, n = "fetch", c = "__oFetch_", o = "__oXMLHttpRequest_", u = "XMLHttpRequest";
  1487. return e.ext(r.prototype, {
  1488. removeHook: function(h, p) {
  1489. return t && (p || this === t) ? (a[c] && (a[n] = a[c], delete a[c]), a[o] && (a[u] = a[o], delete a[o]), t = null, this) : this;
  1490. },
  1491. addHook: function(h) {
  1492. return !h && t ? this : (t || (function() {
  1493. if (typeof a[n] == "function") {
  1494. var p = a[n];
  1495. a[c] = p, a[n] = function(d, f) {
  1496. var m = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments), l = t;
  1497. if (!l || !l.api || f && (f.method === "HEAD" || f.mode === "no-cors"))
  1498. return p.apply(a, m);
  1499. f || (f = {});
  1500. var S = Date.now(), v = l._conf, x = e.duration(), b = (d && typeof d != "string" ? d.url : d) || "", E = b;
  1501. b = e.cutUrlSearch(b);
  1502. var _ = (v.ignore || {}).ignoreApis, y = v.parseTraceId;
  1503. if (!e.checkAPI(b, !0) || e.ignoreByRule(b, _))
  1504. return p.apply(a, m);
  1505. b = e.filterByRule(b, E, v.ignoreApiPath ? v.ignoreApiPath : v.apiHelper);
  1506. var A = v.enableLinkTrace, R = "", M = "", C = l.getConfig("pid"), I = null, P = l.getConfig("sample"), B = l.getConfig("linkType"), $ = 1;
  1507. if (P && !l.sampling(P) && ($ = 0), A) {
  1508. var q = "";
  1509. try {
  1510. q = location.origin ? location.origin : location.protocol + "//" + location.hostname + (location.port ? ":" + location.port : "");
  1511. } catch (G) {
  1512. q = "";
  1513. }
  1514. var X = e.checkSameOrigin(E, q);
  1515. if (l.getConfig("enableApiCors") || X)
  1516. if (d && typeof d != "string")
  1517. try {
  1518. if (m[0].headers && typeof m[0].headers.get == "function" && typeof m[0].headers.append == "function")
  1519. switch (B) {
  1520. case "arms":
  1521. var ae = m[0].headers.get("EagleEye-TraceID"), Q = m[0].headers.get("EagleEye-SessionID"), te = m[0].headers.get("EagleEye-pAppName");
  1522. ae ? R = ae : (R = l.getTraceId()["EagleEye-TraceID"], m[0].headers.append("EagleEye-TraceID", R)), Q ? M = Q : (M = l.getPageviewId()["EagleEye-SessionID"], m[0].headers.append("EagleEye-SessionID", M)), te || m[0].headers.append("EagleEye-pAppName", C);
  1523. break;
  1524. case "b3":
  1525. var ee = m[0].headers.get("X-B3-TraceId");
  1526. if (ee)
  1527. R = ee;
  1528. else {
  1529. var k = l.getB3TraceId($);
  1530. m[0].headers.append("X-B3-TraceId", k["X-B3-TraceId"]), m[0].headers.append("X-B3-ParentSpanId", k["X-B3-ParentSpanId"]), m[0].headers.append("X-B3-SpanId", k["X-B3-SpanId"]), m[0].headers.append("X-B3-Sampled", k["X-B3-Sampled"]), m[0].headers.append("X-Request-ID", e.guid()), R = k["X-B3-TraceId"];
  1531. }
  1532. M = l.pageview;
  1533. break;
  1534. case "tracing":
  1535. default:
  1536. var L = m[0].headers.get("uber-trace-id");
  1537. L ? R = L.split(":")[0] : (L = l.getUberTraceId($), m[0].headers.append("uber-trace-id", L["uber-trace-id"]), R = L.traceId), M = l.pageview;
  1538. }
  1539. } catch (G) {
  1540. e.warn(`[retcode] fetch failed to set header, exception is :
  1541. ` + G);
  1542. }
  1543. else
  1544. switch (f.headers = f.headers ? f.headers : {}, B) {
  1545. case "arms":
  1546. f.headers["EagleEye-TraceID"] ? R = f.headers["EagleEye-TraceID"] : (R = l.getTraceId()["EagleEye-TraceID"], f.headers["EagleEye-TraceID"] = R), f.headers["EagleEye-SessionID"] ? M = f.headers["EagleEye-SessionID"] : (M = l.getPageviewId()["EagleEye-SessionID"], f.headers["EagleEye-SessionID"] = M), f.headers["EagleEye-pAppName"] || (f.headers["EagleEye-pAppName"] = C);
  1547. break;
  1548. case "b3":
  1549. if (f.headers["X-B3-TraceId"])
  1550. R = f.headers["X-B3-TraceId"];
  1551. else {
  1552. var F = l.getB3TraceId($);
  1553. f.headers["X-B3-TraceId"] = F["X-B3-TraceId"], f.headers["X-B3-ParentSpanId"] = F["X-B3-ParentSpanId"], f.headers["X-B3-SpanId"] = F["X-B3-SpanId"], f.headers["X-B3-Sampled"] = F["X-B3-Sampled"], f.headers["X-Request-ID"] = e.guid(), R = F["X-B3-TraceId"];
  1554. }
  1555. M = l.getPageviewId()["EagleEye-SessionID"];
  1556. break;
  1557. case "tracing":
  1558. default:
  1559. if (f.headers["uber-trace-id"])
  1560. R = f.headers["uber-trace-id"].split(":")[0];
  1561. else {
  1562. var N = l.getUberTraceId($);
  1563. f.headers["uber-trace-id"] = N["uber-trace-id"], R = N.traceId;
  1564. }
  1565. M = l.getPageviewId()["EagleEye-SessionID"];
  1566. }
  1567. }
  1568. return p.apply(a, m).then(function(G) {
  1569. if (!l || !l.api)
  1570. return G;
  1571. try {
  1572. if (!G || typeof G.clone != "function")
  1573. return G;
  1574. var j = G.clone(), ce = j.headers;
  1575. if (ce && typeof ce.get == "function") {
  1576. var Z = ce.get("content-type");
  1577. if (Z && !/(text)|(json)/.test(Z))
  1578. return G;
  1579. if (!R) {
  1580. var Ve = e.parseFetchHeaders(ce);
  1581. typeof Ve == "object" && Ve["eagleeye-traceid"] && (R = Ve["eagleeye-traceid"], I = "response");
  1582. }
  1583. }
  1584. var ze = x();
  1585. return j.text().then(function(Qe) {
  1586. if (!R && e.isFunction(y)) {
  1587. var et = y(j, Qe);
  1588. et && e.isString(et) && (R = et);
  1589. }
  1590. var xe = e.getFetchSnapshot(m, Qe, ce);
  1591. j.ok ? s(l, v.parseResponse, b, E, Qe, j.status || 200, ze, S, R, M, xe, I, $) : (l.api(b, !1, ze, j.status || 404, j.statusText, S, R, M, xe, i, I, $), v.enableResource && t.fixResourceStatus && t.fixResourceStatus({
  1592. src: j.url,
  1593. res_type: "api"
  1594. }));
  1595. }), G;
  1596. } catch (Qe) {
  1597. return e.warn("[ARMS] fetch response error :", Qe), G;
  1598. }
  1599. }).catch(function(G) {
  1600. if (!l || !l.api)
  1601. throw G;
  1602. var j = x();
  1603. throw l.api(b, !1, j, G.name || "Error", G.message, S, R, M, {}, i), v.enableResource && t.fixResourceStatus && t.fixResourceStatus({
  1604. src: E,
  1605. res_type: "api"
  1606. }), G;
  1607. });
  1608. }, a[n].toString = e.createFakeToString(n);
  1609. }
  1610. }(), function() {
  1611. if (typeof a[u] == "function") {
  1612. var p, d = a[u];
  1613. a[o] = d;
  1614. var f = function(m) {
  1615. var l = new d(m), S = t;
  1616. if (!S || !S.api || !l.addEventListener)
  1617. return l;
  1618. var v, x, b, E, _ = l.send, y = l.open, A = l.setRequestHeader, R = S._conf, M = (R.ignore || {}).ignoreApis, C = R.parseTraceId, I = S.getConfig("enableLinkTrace"), P = "", B = "", $ = "", q = null, X = S.getConfig("sample"), ae = S.getConfig("linkType"), Q = 1;
  1619. return X && !S.sampling(X) && (Q = 0), l.open = function(te, ee) {
  1620. p = te;
  1621. var k = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
  1622. y.apply(l, k), E = ee || "", b = e.cutUrlSearch(E);
  1623. var L = !e.checkAPI(b, !0) || e.ignoreByRule(b, M);
  1624. if (b = b ? e.filterByRule(b, E, R.ignoreApiPath ? R.ignoreApiPath : R.apiHelper) : "", !L && I) {
  1625. var F = "";
  1626. try {
  1627. F = location.origin ? location.origin : location.protocol + "//" + location.hostname + (location.port ? ":" + location.port : "");
  1628. } catch (ce) {
  1629. F = "";
  1630. }
  1631. var N = e.checkSameOrigin(E, F);
  1632. if ((S.getConfig("enableApiCors") || N) && A && typeof A == "function")
  1633. switch (ae) {
  1634. case "arms":
  1635. P = S.getTraceId()["EagleEye-TraceID"], A.apply(l, ["EagleEye-TraceID", P]), B = S.getPageviewId()["EagleEye-SessionID"], A.apply(l, ["EagleEye-SessionID", B]), $ = S.getConfig("pid"), A.apply(l, ["EagleEye-pAppName", $]);
  1636. break;
  1637. case "b3":
  1638. var G = S.getB3TraceId(Q);
  1639. A.apply(l, ["X-B3-TraceId", G["X-B3-TraceId"]]), A.apply(l, ["X-B3-ParentSpanId", G["X-B3-ParentSpanId"]]), A.apply(l, ["X-B3-SpanId", G["X-B3-SpanId"]]), A.apply(l, ["X-B3-Sampled", G["X-B3-Sampled"]]), A.apply(l, ["X-Request-ID", e.guid()]), P = G["X-B3-TraceId"], B = S.getPageviewId()["EagleEye-SessionID"];
  1640. break;
  1641. case "tracing":
  1642. default:
  1643. var j = S.getUberTraceId(Q);
  1644. A.apply(l, ["uber-trace-id", j["uber-trace-id"]]), P = j.traceId, B = S.getPageviewId()["EagleEye-SessionID"];
  1645. }
  1646. }
  1647. }, l.send = function() {
  1648. v = Date.now(), x = e.duration();
  1649. var te = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
  1650. _.apply(l, te);
  1651. }, e.on(l, "readystatechange", function() {
  1652. if (b && l.readyState === 4) {
  1653. var te = x(), ee = e.getXhrSnapshot(E, p, l);
  1654. if (!P) {
  1655. var k = e.parseXhrHeaders(typeof l.getAllResponseHeaders == "function" && l.getAllResponseHeaders() || "");
  1656. typeof k == "object" && k["eagleeye-traceid"] && (P = k["eagleeye-traceid"], q = "response");
  1657. }
  1658. if (!P && e.isFunction(C)) {
  1659. var L = C(l);
  1660. L && e.isString(L) && (P = L);
  1661. }
  1662. if (l.status >= 200 && l.status <= 299) {
  1663. var F = l.status || 200;
  1664. if (typeof l.getResponseHeader == "function") {
  1665. var N = l.getResponseHeader("Content-Type");
  1666. if (N && !/(text)|(json)/.test(N))
  1667. return;
  1668. }
  1669. l.responseType && l.responseType !== "text" ? S.api(b, !0, te, F, "", v, P, B, {}, i, q, Q) : s(S, R.parseResponse, b, E, l.responseText, F, te, v, P, B, ee, q, Q);
  1670. } else
  1671. S.api(b, !1, te, l.status || "FAILED", l.statusText, v, P, B, ee, i, q, Q), R.enableResource && t.fixResourceStatus && t.fixResourceStatus({
  1672. src: l.responseURL || E,
  1673. res_type: "api"
  1674. });
  1675. }
  1676. }), l;
  1677. };
  1678. f.prototype = d.prototype, e.each(Object.keys(d), function(m) {
  1679. f[m] = d[m];
  1680. }), a[u] = f, a[u].toString = e.createFakeToString(u);
  1681. }
  1682. }()), t = this, this);
  1683. },
  1684. initHook: function() {
  1685. return this.hasInitHook ? this : (this.getConfig("disableHook") || this.addHook(), this.hasInitHook = !0, this);
  1686. }
  1687. }), r;
  1688. }), Ns;
  1689. }
  1690. var Ls, Fs;
  1691. function co() {
  1692. return Fs || (Fs = 1, Ls = function(r, a) {
  1693. var e = Fe(), t = a.history || {}, i = a.document, s = function(c, o) {
  1694. var u;
  1695. a.CustomEvent ? u = new CustomEvent(c, {
  1696. detail: o
  1697. }) : ((u = i.createEvent("HTMLEvents")).initEvent(c, !1, !0), u.detail = o), a.dispatchEvent(u);
  1698. }, n = function(c) {
  1699. var o = t[c];
  1700. typeof o == "function" && (t[c] = function(u, h, p) {
  1701. var d = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments), f = location.href, m = o.apply(t, d);
  1702. if (!p || typeof p != "string" || p === f)
  1703. return m;
  1704. try {
  1705. var l = f.split("#"), S = p.split("#"), v = e.cutUrlSearch(l[0]), x = e.cutUrlSearch(S[0]), b = l[1] && l[1].replace(/^\/?(.*)/, "$1"), E = S[1] && S[1].replace(/^\/?(.*)/, "$1");
  1706. b !== E ? s("historystatechange", E) : v !== x && s("historystatechange", x);
  1707. } catch (_) {
  1708. e.warn("[retcode] error in " + c + ": " + _);
  1709. }
  1710. return m;
  1711. }, t[c].toString = e.createFakeToString(c));
  1712. };
  1713. e.ext(r.prototype, {
  1714. hackHistoryState: function() {
  1715. return this.hasHackedHistoryState ? this : (n("pushState"), n("replaceState"), this.hasHackedHistoryState = !0, this);
  1716. }
  1717. });
  1718. }), Ls;
  1719. }
  1720. var Ji, Vs;
  1721. function uo() {
  1722. if (Vs)
  1723. return Ji;
  1724. Vs = 1;
  1725. var r = Fe(), a = Kr(), e = a.TIMING_KEYS;
  1726. return Ji = function(t, i) {
  1727. function s(o, u, h) {
  1728. if (o instanceof i.PerformanceResourceTiming && o.initiatorType) {
  1729. var p = r.getResType(o.initiatorType, o.name), d = u.resourceTypes || [], f = (u.ignore || {}).ignoreResources;
  1730. if (p && d.includes(p) && !r.ignoreByRule(o.name, f) && !r.ignoreByRule(r.decode(o.name), f)) {
  1731. var m = o[e[0]], l = o[e[1]], S = o[e[2]], v = o[e[3]], x = o[e[4]], b = o[e[5]], E = o[e[6]], _ = o[e[7]], y = o[e[8]], A = o[e[18]], R = o[e[19]];
  1732. if (!h.has(o) && (!r.areInOrder(m, l, S, v, x, b, E, _, y) || m > _))
  1733. return;
  1734. if (A < m && (A = m), R < m && (R = l), r.areInOrder(m, A, R, l))
  1735. return {
  1736. domain: r.getURL(o.name).domain,
  1737. res_type: p,
  1738. src_type: r.getSrcType(o.name, u.cdnHostList),
  1739. success: 1,
  1740. size: Math.round(o.decodedBodySize),
  1741. duration: Math.round(o.duration),
  1742. timeStamp: o.responseEnd,
  1743. timing: o
  1744. };
  1745. }
  1746. }
  1747. }
  1748. var n = "_resource-" + Date.now(), c = "_resource_error-" + Date.now();
  1749. r.ext(t.prototype, {
  1750. initResource: function() {
  1751. var o = this, u = i.performance, h = i.PerformanceObserver;
  1752. if (o[c] || (o[c] = /* @__PURE__ */ new WeakMap()), !u || !h || typeof u != "object" || typeof u.getEntriesByType != "function")
  1753. return null;
  1754. var p = u.getEntriesByType("resource") || [];
  1755. return setTimeout(function() {
  1756. o.setResource(p);
  1757. }, 10), new h(function(d) {
  1758. setTimeout(function() {
  1759. o.setResource(d.getEntries());
  1760. }, 10);
  1761. }).observe({
  1762. entryTypes: ["resource"]
  1763. }), this.onReady(function() {
  1764. setTimeout(o.resourceComboReport.bind(o), 5e3);
  1765. }), o;
  1766. },
  1767. setResource: function(o) {
  1768. var u = this._conf, h = this[c];
  1769. if (r.isArray(o) && o.length) {
  1770. this[n] || (this[n] = {});
  1771. for (var p = this[n], d = 0, f = o.length; d < f; d += 1) {
  1772. var m = o[d];
  1773. if (r.checkAPI(m.name, !1)) {
  1774. var l = s(m, u, h);
  1775. if (l) {
  1776. var S = l.res_type + "-" + l.domain;
  1777. S in p || (p[S] = []), p[S].push(l);
  1778. }
  1779. }
  1780. }
  1781. return this;
  1782. }
  1783. },
  1784. fixResourceStatus: function(o) {
  1785. var u = i.performance;
  1786. if (!u || typeof u.getEntriesByName != "function")
  1787. return null;
  1788. var h = this[c];
  1789. if (!o.src || !r.checkAPI(o.src, !1))
  1790. return this;
  1791. var p = o.timeStamp || u.now(), d = u.getEntriesByName(o.src, "resource");
  1792. return r.each(d, function(f) {
  1793. h.has(f) || p - f.responseEnd < 100 && h.set(f, {
  1794. success: 0
  1795. });
  1796. }), this;
  1797. },
  1798. resourceComboReport: function() {
  1799. var o = this[n] || {}, u = this._conf.resourceSlow || 2e3, h = this[c];
  1800. this[n] = {};
  1801. var p = Object.keys(o);
  1802. if (p.length !== 0) {
  1803. var d = [];
  1804. r.each(p, function(S) {
  1805. var v = o[S], x = {
  1806. domain: "",
  1807. res_type: "",
  1808. src_type: "",
  1809. size: 0,
  1810. duration: 0,
  1811. count: 0,
  1812. err_count: 0,
  1813. err_duration: 0,
  1814. slow_count: 0,
  1815. slow_duration: 0,
  1816. timings: []
  1817. };
  1818. r.each(v, function(b) {
  1819. var E = b.timing || {}, _ = h.get(b.timing), y = _ ? _.success : 1, A = b.duration > u ? 1 : 0;
  1820. x.domain = b.domain, x.res_type = b.res_type, x.src_type = b.src_type, x.count += 1, x.duration += b.duration, x.size += b.size, y || (x.err_count += 1, x.err_duration += b.duration), A && (x.slow_count += 1, x.slow_duration += b.duration);
  1821. try {
  1822. var R = JSON.parse(JSON.stringify(E));
  1823. R.success = y, R.resourceSlow = u, R.isSlow = A, x.timings.push(R);
  1824. } catch (M) {
  1825. }
  1826. }), x.count && (x.size = Math.round(x.size / x.count), x.duration = Math.round(x.duration / x.count)), x.slow_count && (x.slow_duration = Math.round(x.slow_duration / x.slow_count)), x.err_count && (x.err_duration = Math.round(x.err_duration / x.err_count)), x.timings.length > 20 && (x.timings.sort(function(b, E) {
  1827. return E.duration - b.duration;
  1828. }), x.timings.length = 20), x.timings = encodeURIComponent(JSON.stringify(x.timings)), d.push(x);
  1829. });
  1830. var f = {
  1831. _combo: 1,
  1832. resource: JSON.stringify(d)
  1833. }, m = i.navigator.connection;
  1834. f.ct = m ? m.effectiveType || m.type : "";
  1835. var l = m && (m.downlink || m.downlinkMax || m.bandwidth) || null;
  1836. (l = l > 999 ? 999 : l) && (f.bandwidth = l), this._lg("resource", f, this.getConfig("sample"));
  1837. }
  1838. }
  1839. });
  1840. }, Ji;
  1841. }
  1842. var Os;
  1843. function ho() {
  1844. if (Os)
  1845. return Fi.exports;
  1846. Os = 1;
  1847. var r = Fe(), a = Qn(), e = eo(), t = to(), i = r.win, s = i.document, n = /^(error|api|speed|sum|avg|percent|custom|msg|setPage|setConfig|behavior|performance)$/, c = function(o) {
  1848. var u = this;
  1849. return a.call(u, o), u._initialPage = o.page && r.safetyCall(o.page, [], o.page + "") || null, u._isRobot = r.isRobot(), u._health = {
  1850. errcount: 0,
  1851. apisucc: 0,
  1852. apifail: 0
  1853. }, u.beforeSend = function(h, p) {
  1854. h === "error" ? u._health.errcount++ : h === "api" && u._health[p.success ? "apisucc" : "apifail"]++;
  1855. }, o.enableInstanceAutoSend !== !1 && (u.initHandler(), u.initHook(), u.initFmpObserver(1e4), u._conf && u._conf.behavior && typeof u.initBehavior == "function" && u.initBehavior(), u._conf && u._conf.enableResource && typeof u.initResource == "function" && u.initResource()), Object.defineProperty && i.addEventListener && Object.defineProperty(u, "pipe", {
  1856. set: u.sendPipe
  1857. }), u;
  1858. };
  1859. return c.prototype = r.createObject(a.prototype), r.ext(a._root.dftCon, {
  1860. uid: null,
  1861. setUsername: null,
  1862. ignoreUrlPath: null,
  1863. ignoreApiPath: null,
  1864. urlHelper: [{
  1865. rule: /\/([a-z\-_]+)?\d{2,20}/g,
  1866. target: "/$1**"
  1867. }, /\/$/],
  1868. resourceHelper: [],
  1869. apiHelper: {
  1870. rule: /\/([a-z\-_]+)?\d{2,20}/g,
  1871. target: "/$1**"
  1872. },
  1873. ignoreUrlCase: !0,
  1874. imgUrl: "https://arms-retcode.aliyuncs.com/r.png?",
  1875. cdnHostList: [],
  1876. resourceTypes: ["css", "script", "img", "font"],
  1877. resourceSlow: 2e3,
  1878. disableHook: !1,
  1879. autoSendPv: !0,
  1880. autoSendPerf: !0,
  1881. enableSPA: !1,
  1882. enableLinkTrace: !1,
  1883. linkType: "arms",
  1884. enableApiCors: !1,
  1885. sendResource: !0,
  1886. behavior: !0,
  1887. enableConsole: !1,
  1888. parseHash: function(o) {
  1889. return (o ? r.cutUrlSearch(o.replace(/^#\/?/, "")) : "") || "[index]";
  1890. },
  1891. parseResponse: function(o) {
  1892. if (!o || typeof o != "object")
  1893. return {};
  1894. var u = o.code, h = o.msg || o.message || o.subMsg || o.errorMsg || o.ret || o.errorResponse || "";
  1895. return typeof h == "object" && (u = u || h.code, h = h.msg || h.message || h.info || h.ret || JSON.stringify(h)), {
  1896. msg: h,
  1897. code: u,
  1898. success: !0
  1899. };
  1900. }
  1901. }), r.ext(c.prototype, {
  1902. constructor: c,
  1903. _super: a,
  1904. onReady: function(o) {
  1905. var u = this;
  1906. if (u.hasReady)
  1907. return o();
  1908. s.readyState === "complete" ? (u.hasReady = !0, o()) : r.on(i, "load", function() {
  1909. u.hasReady = !0, o();
  1910. }, !0);
  1911. },
  1912. getPage: function(o) {
  1913. var u = this._conf, h = u.page, p = location, d = p.host + p.pathname;
  1914. return h && !o ? r.safetyCall(h, [], h + "") : this._initialPage || r.filterByRule(u.ignoreUrlCase ? d.toLowerCase() : d, p.href, u.ignoreUrlPath ? u.ignoreUrlPath : u.urlHelper);
  1915. },
  1916. setPage: function(o, u) {
  1917. var h = this, p = h.prevPage;
  1918. if (u !== !1) {
  1919. if (!o || o === p)
  1920. return h;
  1921. h.prevPage = o, clearTimeout(h.sendPVTimmer), h.handleUnload(1), h.resetPageview(), h.sendPVTimmer = setTimeout(function() {
  1922. h.sendPV();
  1923. }, 10);
  1924. } else
  1925. h.prevPage = o;
  1926. return h._conf.page = o, h;
  1927. },
  1928. setConfig: function(o, u) {
  1929. if (o && typeof o == "object") {
  1930. r.verifyConfig(o), o = this.setImgUrl(o);
  1931. var h = this._conf;
  1932. if (this._conf = r.ext({}, h, o), !u) {
  1933. var p = "disableHook";
  1934. p in o && h[p] !== o[p] && (o[p] ? this.removeHook() : this.addHook()), (p = "enableSPA") in o && h[p] !== o[p] && this.bindHashChange(o[p]);
  1935. }
  1936. }
  1937. },
  1938. sendRequest: function(o) {
  1939. e(o, this.getConfig("imgUrl"));
  1940. },
  1941. postData: function(o, u) {
  1942. var h = {};
  1943. h[u] = o[u], delete o[u];
  1944. var p = "";
  1945. typeof o == "object" && (p = r.serialize(o)), t(h, this.getConfig("imgUrl") + p + "&post_res=");
  1946. },
  1947. sendPipe: function(o) {
  1948. var u = this;
  1949. if (!o || !o.length)
  1950. return u;
  1951. try {
  1952. if (r.T(o[0]) === "Array")
  1953. return r.each(o, function(p) {
  1954. return u.sendPipe(p);
  1955. });
  1956. if (r.T(o) !== "Array")
  1957. return u;
  1958. var h = o.shift();
  1959. if (!n.test(h))
  1960. return u;
  1961. u[h].apply(u, o);
  1962. } catch (p) {
  1963. return r.warn("[retcode] error in sendPipe", p), u;
  1964. }
  1965. },
  1966. sendHealth: function() {
  1967. var o = r.ext({}, this._health);
  1968. o.healthy = o.errcount > 0 ? 0 : 1, o.begin = Date.now();
  1969. var u = o.begin - this.sBegin;
  1970. o.stay = u, this._lg("health", o, 1), this._health = {
  1971. errcount: 0,
  1972. apisucc: 0,
  1973. apifail: 0
  1974. };
  1975. },
  1976. createInstance: function(o) {
  1977. o = r.ext({
  1978. pid: this._conf.pid
  1979. }, o);
  1980. var u = this.__proto__.constructor(o);
  1981. return o.page && u.sendPV(), u;
  1982. }
  1983. }), io()(c, i), ao()(c, i, s), no()(c, i, s), oo()(c, i), co()(c, i), uo()(c, i), c._super = a, c._root = a._root, a.Browser = c, Fi.exports = c, Fi.exports;
  1984. }
  1985. var Us;
  1986. function lo() {
  1987. if (Us)
  1988. return Li.exports;
  1989. Us = 1;
  1990. function r(c, o) {
  1991. var u = e[i] = new t(c);
  1992. u.sendPipe(o);
  1993. var h = u._conf;
  1994. return h.autoSendPv !== !1 && u.sendPV(), h && h.useFmp || u.sendPerformance(), h && h.sendResource && u.sendResources(), e[s] = !0, u;
  1995. }
  1996. function a() {
  1997. if (e[s])
  1998. return e[i];
  1999. var c = {}, o = [];
  2000. return i in e && (c = e[i].config || {}, o = e[i].pipe || []), r(c, o);
  2001. }
  2002. var e = window, t = e.BrowserLogger = ho(), i = Fe().key, s = "__hasInitBlSdk";
  2003. t.singleton = function(c, o) {
  2004. return e[s] ? e[i] : r(c, o);
  2005. }, t.createExtraInstance = function(c) {
  2006. c && typeof c == "object" && c.enableInstanceAutoSend !== !0 && (c.enableInstanceAutoSend = !1);
  2007. var o = new t(c), u = o._conf;
  2008. return u.enableInstanceAutoSend && (u.autoSendPv !== !1 && o.sendPV(), u && u.useFmp || o.sendPerformance(), u && u.sendResource && o.sendResources()), o;
  2009. };
  2010. var n = typeof window == "object" && !!window.navigator;
  2011. return n && e[i] && (t.bl = a()), Li.exports = t, Li.exports;
  2012. }
  2013. function fo() {
  2014. return lo();
  2015. }
  2016. var po = {
  2017. getArmsLogger: fo
  2018. };
  2019. const Hs = "https://arms-retcode.aliyuncs.com/r.png?", js = "https://arms-retcode-sg.aliyuncs.com/r.png?", zs = "https://retcode-us-west-1.arms.aliyuncs.com/r.png?", Ws = "e1iftji1w7@7ec1cef2cc88733", $s = "e1iftji1w7@10a06d1ec260adc", Ks = "e1iftji1w7@10a06d1ec260adc", Gi = {
  2020. cn: {
  2021. reportUrl: Hs,
  2022. pid: Ws
  2023. },
  2024. "cn-hangzhou": {
  2025. reportUrl: Hs,
  2026. pid: Ws
  2027. },
  2028. sg: {
  2029. reportUrl: js,
  2030. pid: $s
  2031. },
  2032. "ap-southeast-1": {
  2033. reportUrl: js,
  2034. pid: $s
  2035. },
  2036. usw: {
  2037. reportUrl: zs,
  2038. pid: Ks
  2039. },
  2040. "us-west-1": {
  2041. reportUrl: zs,
  2042. pid: Ks
  2043. }
  2044. }, go = (r) => r !== null && typeof r == "object", mo = (r) => Object.prototype.toString.call(r).slice(8, -1), So = (r) => Object.isExtensible(r) ? mo(r) === "Object" : !1;
  2045. function xo(r, a, e) {
  2046. var n;
  2047. if (Reflect.get(r, "__v_skip") === !0)
  2048. return r;
  2049. const t = [], i = typeof Object.getOwnPropertyDescriptors == "function" ? Object.getOwnPropertyDescriptors((n = Object.getPrototypeOf(r)) != null ? n : {}) : {};
  2050. for (const c of Object.keys(i))
  2051. i[c].get && t.push(c);
  2052. const s = {
  2053. MediaboxWrapperObjectGetter(c, o) {
  2054. if (typeof o == "string" && t.indexOf(o) > -1) {
  2055. let u;
  2056. try {
  2057. u = c[o];
  2058. } catch (h) {
  2059. throw e(h), h;
  2060. }
  2061. return ft(u, a, e);
  2062. }
  2063. return a > 10 ? c[o] : ft(c[o], a, e);
  2064. },
  2065. MediaboxWrapperObjectSetter(c, o, u) {
  2066. return c[o] = ft(u, a, e), !0;
  2067. }
  2068. };
  2069. return Object.defineProperty(r, "__v_skip", {
  2070. configurable: !0,
  2071. enumerable: !1,
  2072. writable: !1,
  2073. value: !0
  2074. }), new Proxy(r, {
  2075. get: s.MediaboxWrapperObjectGetter,
  2076. set: s.MediaboxWrapperObjectSetter
  2077. });
  2078. }
  2079. function vo(r, a, e) {
  2080. const t = {
  2081. MediaboxWrapperFunctionApply(i, s, n) {
  2082. let c;
  2083. try {
  2084. c = Reflect.apply(i, s, n);
  2085. } catch (o) {
  2086. throw e(o), o;
  2087. }
  2088. return ft(c, a, e);
  2089. },
  2090. MediaboxWrapperFunctionGet(i, s) {
  2091. const n = Object.getOwnPropertyDescriptor(i, s);
  2092. return n && !n.writable && !n.configurable ? i[s] : ft(i[s], a, e);
  2093. },
  2094. MediaboxWrapperClassConstructor(i, s) {
  2095. let n;
  2096. try {
  2097. n = new i(...s);
  2098. } catch (c) {
  2099. throw e(c), c;
  2100. }
  2101. return ft(n, a, e);
  2102. }
  2103. };
  2104. return new Proxy(r, {
  2105. apply: t.MediaboxWrapperFunctionApply,
  2106. get: t.MediaboxWrapperFunctionGet,
  2107. construct: t.MediaboxWrapperClassConstructor
  2108. });
  2109. }
  2110. function bo(r, a) {
  2111. if (typeof r != "string")
  2112. return a;
  2113. if (on(r, a))
  2114. return r;
  2115. const e = r.indexOf(`
  2116. `);
  2117. return e < 0 ? `${r}${a}` : `${r.slice(0, e)}${a}${r.slice(e)}`;
  2118. }
  2119. function on(r, a) {
  2120. if (typeof r != "string")
  2121. return !1;
  2122. const e = r.indexOf(a);
  2123. if (e < 0)
  2124. return !1;
  2125. const t = r.indexOf(`
  2126. `);
  2127. return t < 0 ? !0 : e < t;
  2128. }
  2129. function ft(r, a, e) {
  2130. return typeof r == "function" ? vo(r, a + 1, e) : r instanceof Promise ? r.then((t) => ft(t, a + 1, e)).catch((t) => (e(t), Promise.reject(t))) : Array.isArray(r) ? (r.forEach((t, i) => {
  2131. r[i] = ft(t, a + 1, e);
  2132. }), r) : go(r) && So(r) ? xo(r, a + 1, e) : r;
  2133. }
  2134. function Eo(r) {
  2135. return typeof r != "string" ? !1 : r.indexOf("g.alicdn.com/apsara-media-") > -1 || r.indexOf("g.alicdn.com/thor-server") > -1;
  2136. }
  2137. function qs(r) {
  2138. return typeof r != "string" ? !1 : r.indexOf("g.alicdn.com/apsara-media-") > -1 || r.indexOf("g.alicdn.com/thor-server") > -1 || r.indexOf("MediaboxWrapper") > -1;
  2139. }
  2140. class Js extends Error {
  2141. constructor(a) {
  2142. super(a), this.name = "MQTError";
  2143. }
  2144. }
  2145. let _o = 1;
  2146. class qr {
  2147. constructor(a) {
  2148. var e, t;
  2149. Tt(this, "armsLogger"), Tt(this, "isReady", !1), Tt(this, "isDestroyed", !1), Tt(this, "options"), Tt(this, "queue", []), Tt(this, "marker"), Tt(this, "helper", {
  2150. MediaboxWrapperQueue(i) {
  2151. return new Js(i);
  2152. },
  2153. MediaboxWrapperInitiative(i) {
  2154. return new Js(i);
  2155. }
  2156. }), this.options = ut(J({}, a), {
  2157. region: a.deferRegionSet ? void 0 : (e = a.region) != null ? e : "cn",
  2158. env: (t = a.env) != null ? t : "prod"
  2159. }), this.marker = `-${_o++}-`, this.initArmsLogger();
  2160. }
  2161. static get version() {
  2162. return "0.23.0";
  2163. }
  2164. initArmsLogger(a) {
  2165. const { region: e, env: t, disabled: i } = this.options;
  2166. if (i || this.armsLogger)
  2167. return;
  2168. if (a && !e)
  2169. throw new Error("region is required");
  2170. if (!e)
  2171. return;
  2172. if (!Gi[e])
  2173. throw new Error(`region ${e} is not supported`);
  2174. const s = (c) => {
  2175. var o;
  2176. if (this.isDestroyed || on(c.stack, this.marker) || c.t !== "pv" && c.t !== "error")
  2177. return !1;
  2178. if (c.c1 = (o = this.options.cid) != null ? o : window.location.host, c.c2 = qr.version, this.options.customData && (c.c3 = new URLSearchParams(this.options.customData).toString()), c.t === "error") {
  2179. if (Eo(c.file) || qs(c.stack)) {
  2180. let u = c;
  2181. return this.options.beforeSend && (u = this.options.beforeSend(c)), this.isReady ? u : (u && this.queue.push(u), !1);
  2182. }
  2183. return !1;
  2184. }
  2185. return c;
  2186. }, n = po.getArmsLogger();
  2187. this.armsLogger = n.createExtraInstance({
  2188. enableInstanceAutoSend: !0,
  2189. pid: Gi[e].pid,
  2190. tag: this.options.businessName,
  2191. release: `${this.options.businessName}_${this.options.version}`,
  2192. // release 参数只能初始化时设置
  2193. // appType: "web",
  2194. imgUrl: Gi[e].reportUrl,
  2195. // sendResource: true,
  2196. behavior: !0,
  2197. sample: 1,
  2198. // 100% 采样
  2199. disableHook: !0,
  2200. // 禁止对 xhr, fetch 进行覆盖
  2201. environment: t,
  2202. // (可选)拦截不想上报的数据,返回 null、undefined、0、false 等,会取消本次上报
  2203. beforeReport: s
  2204. });
  2205. }
  2206. wrap(a) {
  2207. return this.options.disabled || typeof Proxy > "u" ? a : ft(a, 0, (e) => {
  2208. var t;
  2209. e instanceof Error && typeof e.stack == "string" && qs(e.stack) && ((t = this.armsLogger) == null || t.error(e), e.stack = bo(e.stack, this.marker));
  2210. });
  2211. }
  2212. updateOptions(a) {
  2213. this.options = J(J({}, this.options), a);
  2214. }
  2215. setReady() {
  2216. this.initArmsLogger(!0), this.isReady = !0, this.queue.length && this.queue.forEach((a) => {
  2217. var e;
  2218. (e = this.armsLogger) == null || e.error(this.helper.MediaboxWrapperQueue(a.msg), {
  2219. filename: a.file,
  2220. lineno: a.line,
  2221. colno: a.col
  2222. });
  2223. });
  2224. }
  2225. // 主动上报
  2226. report(a, e) {
  2227. var t;
  2228. (t = this.armsLogger) == null || t.error(
  2229. this.helper.MediaboxWrapperInitiative(a),
  2230. e
  2231. );
  2232. }
  2233. destroy() {
  2234. this.isDestroyed = !0;
  2235. }
  2236. }
  2237. var oe = /* @__PURE__ */ ((r) => (r.PullStreamStats = "remoteStat", r.RtsSubscribeExceeds = "rtsSubscribeExceeds", r.UserJoined = "userJoined", r.UserLeft = "userLeft", r.Bye = "bye", r.MuteAudio = "muteAudio", r.UnmuteAudio = "unmuteAudio", r.MuteVideo = "muteVideo", r.UnmuteVideo = "unmuteVideo", r.MuteScreen = "muteScreen", r.UnmuteScreen = "unmuteScreen", r.Error = "error", r))(oe || {}), Le = /* @__PURE__ */ ((r) => (r.Local = "local-device-status-change", r.Remote = "remote-device-status-change", r))(Le || {}), T = /* @__PURE__ */ ((r) => (r.Audio = "sophon_audio", r.VideoLarge = "sophon_video_camera_large", r.VideoSmall = "sophon_video_camera_small", r.Screen = "sophon_video_screen_share", r.Data = "sophon_data", r))(T || {}), Jr = /* @__PURE__ */ ((r) => (r.Audio = "rts audio", r.VideoLarge = "rts video", r))(Jr || {}), xt = /* @__PURE__ */ ((r) => (r.Add = "add", r.Delete = "delete", r.Replace = "replace", r.Stop = "stop", r.UnPublish = "unpublish", r))(xt || {}), Jt = /* @__PURE__ */ ((r) => (r[r.Camera = 0] = "Camera", r[r.Screen = 1] = "Screen", r[r.Image = 2] = "Image", r))(Jt || {}), xi = /* @__PURE__ */ ((r) => (r[r.Microphone = 0] = "Microphone", r[r.Screen = 1] = "Screen", r[r.Mixed = 2] = "Mixed", r))(xi || {}), de = /* @__PURE__ */ ((r) => (r.InRoom = "inRoom", r.Join = "join", r.Publish = "publish", r.User = "user", r.Resume = "resume", r.Retry = "retry", r.Reconnect = "reconnect", r))(de || {}), nt = /* @__PURE__ */ ((r) => (r[r.MANUAL = 0] = "MANUAL", r[r.JOIN_CHANNEL = 1] = "JOIN_CHANNEL", r[r.ROLE_CHANGE = 2] = "ROLE_CHANGE", r[r.RECONNECT = 3] = "RECONNECT", r))(nt || {}), Ie = [];
  2238. for (var Xi = 0; Xi < 256; ++Xi)
  2239. Ie.push((Xi + 256).toString(16).slice(1));
  2240. function Ao(r, a = 0) {
  2241. return (Ie[r[a + 0]] + Ie[r[a + 1]] + Ie[r[a + 2]] + Ie[r[a + 3]] + "-" + Ie[r[a + 4]] + Ie[r[a + 5]] + "-" + Ie[r[a + 6]] + Ie[r[a + 7]] + "-" + Ie[r[a + 8]] + Ie[r[a + 9]] + "-" + Ie[r[a + 10]] + Ie[r[a + 11]] + Ie[r[a + 12]] + Ie[r[a + 13]] + Ie[r[a + 14]] + Ie[r[a + 15]]).toLowerCase();
  2242. }
  2243. var fi, yo = new Uint8Array(16);
  2244. function Co() {
  2245. if (!fi && (fi = typeof crypto != "undefined" && crypto.getRandomValues && crypto.getRandomValues.bind(crypto), !fi))
  2246. throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
  2247. return fi(yo);
  2248. }
  2249. var Ro = typeof crypto != "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
  2250. const Gs = {
  2251. randomUUID: Ro
  2252. };
  2253. function rt(r, a, e) {
  2254. if (Gs.randomUUID && !a && !r)
  2255. return Gs.randomUUID();
  2256. r = r || {};
  2257. var t = r.random || (r.rng || Co)();
  2258. if (t[6] = t[6] & 15 | 64, t[8] = t[8] & 63 | 128, a) {
  2259. e = e || 0;
  2260. for (var i = 0; i < 16; ++i)
  2261. a[e + i] = t[i];
  2262. return a;
  2263. }
  2264. return Ao(t);
  2265. }
  2266. var vi = /* @__PURE__ */ ((r) => (r.prod = "rs.rtn.aliyuncs.com", r.pre = "prs.rtn.aliyuncs.com", r))(vi || {});
  2267. const yi = "6.14.6", Xs = "web";
  2268. class He {
  2269. /**
  2270. * 将版本号转换为number
  2271. */
  2272. static getVersionNumber() {
  2273. let a = yi.split("."), e = "";
  2274. return a.forEach((t) => {
  2275. t.length === 1 ? e += "0" + t : e += t;
  2276. }), parseInt(e);
  2277. }
  2278. /**
  2279. *
  2280. * @param param
  2281. * @returns
  2282. */
  2283. static queryingParam(a) {
  2284. let e = [];
  2285. if (a)
  2286. for (let t in a)
  2287. e.push(t + "=" + a[t]);
  2288. return e.join("&");
  2289. }
  2290. /**
  2291. *
  2292. * @param param
  2293. * @returns
  2294. */
  2295. static getQueryParams(a) {
  2296. const t = window.location.search.substring(1).split("&");
  2297. for (let i = 0; i < t.length; i++) {
  2298. const s = t[i].split("=");
  2299. if (decodeURIComponent(s[0]) === a)
  2300. return decodeURIComponent(s[1]);
  2301. }
  2302. }
  2303. /**
  2304. * 生成Sub Callid
  2305. * 每次Sub都会重新生成这个Callid
  2306. * @returns
  2307. */
  2308. static createCallid(a = "") {
  2309. const e = rt();
  2310. return a && e && e.length > a.length ? `${a}${e.substring(a.length)}` : e;
  2311. }
  2312. /**
  2313. * 检查订阅配置是否合法
  2314. * @param {SubscribeOptions} options
  2315. * @returns {boolean}
  2316. */
  2317. static checkSubOptionsValid(a) {
  2318. if (a) {
  2319. const { audio: e, video: t, screen: i } = a;
  2320. if (e === !1 && t === !1 && i === !1)
  2321. return !1;
  2322. }
  2323. return !0;
  2324. }
  2325. /**
  2326. * 检查网络是否正常
  2327. * @returns {Promise<boolean>}
  2328. */
  2329. static isNetworkAvailable() {
  2330. return w(this, null, function* () {
  2331. const a = vi.prod, { onLine: e } = navigator;
  2332. if (!e)
  2333. return !1;
  2334. try {
  2335. return yield fetch(`https://${a}/roomserver/v1/ws/version`), !0;
  2336. } catch (t) {
  2337. return !1;
  2338. }
  2339. });
  2340. }
  2341. /**
  2342. * 安全转换为字符串
  2343. *
  2344. * @param {*} obj
  2345. * @return {string}
  2346. */
  2347. static toString(a) {
  2348. let e;
  2349. if (a instanceof Error)
  2350. e = a.message;
  2351. else if (typeof a == "string")
  2352. e = a;
  2353. else
  2354. try {
  2355. e = JSON.stringify(a);
  2356. } catch (t) {
  2357. e = "undefined";
  2358. }
  2359. return e;
  2360. }
  2361. /**
  2362. * 将参数数组安全转换为字符串
  2363. * @param {any[]} rest
  2364. * @return {string}
  2365. * @memberof AliRtcUtil
  2366. */
  2367. static paramArrayToString(a) {
  2368. let e = "";
  2369. for (let t = 0; t < a.length; t++) {
  2370. e !== "" && (e += " ");
  2371. let i = He.toString(a[t]);
  2372. e += i;
  2373. }
  2374. return e;
  2375. }
  2376. }
  2377. function Ys(r, a, e) {
  2378. Object.defineProperty(r, a, {
  2379. writable: !0,
  2380. enumerable: !0,
  2381. configurable: !0,
  2382. value: e
  2383. });
  2384. }
  2385. function cn(r, a, e, t) {
  2386. t ? t(() => {
  2387. Ys(r, a, e);
  2388. }) : Ys(r, a, e);
  2389. }
  2390. Array(32);
  2391. class Io {
  2392. constructor(a) {
  2393. this.timer = null, this.time = 10, this.count = 10, this.arr = [];
  2394. var e, t;
  2395. this.time = (e = a.time) != null ? e : 10, this.count = (t = a.count) != null ? t : 10, a.host.startsWith("http://") || a.host.startsWith("https://") ? this.url = a.host + "/logstores/" + a.logstore + "/track" : this.url = "https://" + a.project + "." + a.host + "/logstores/" + a.logstore + "/track", this.opt = a, a.installUnloadHook && typeof a.installUnloadHook == "function" && a.installUnloadHook(() => {
  2396. this.sendImmediateInner();
  2397. });
  2398. }
  2399. assemblePayload(a) {
  2400. const e = {
  2401. __logs__: a
  2402. };
  2403. return this.opt.tags && (e.__tags__ = this.opt.tags), this.opt.topic && (e.__topic__ = this.opt.topic), this.opt.source && (e.__source__ = this.opt.source), JSON.stringify(e);
  2404. }
  2405. platformSend() {
  2406. if (this.opt.sendPayload && typeof this.opt.sendPayload == "function") {
  2407. const a = this.assemblePayload(this.arr);
  2408. this.opt.sendPayload(this.url, a);
  2409. }
  2410. }
  2411. transString(a) {
  2412. let e = {};
  2413. for (let t in a)
  2414. typeof a[t] == "object" ? e[t] = JSON.stringify(a[t]) : e[t] = String(a[t]);
  2415. return e;
  2416. }
  2417. sendImmediateInner() {
  2418. this.arr && this.arr.length > 0 && (this.platformSend(), this.timer != null && (clearTimeout(this.timer), this.timer = null), this.arr = []);
  2419. }
  2420. sendInner() {
  2421. if (this.timer)
  2422. this.arr.length >= this.count && (clearTimeout(this.timer), this.timer = null, this.sendImmediateInner());
  2423. else {
  2424. const a = this;
  2425. this.arr.length >= this.count || this.time <= 0 ? this.sendImmediateInner() : this.timer = setTimeout(function() {
  2426. a.sendImmediateInner();
  2427. }, this.time * 1e3);
  2428. }
  2429. }
  2430. send(a) {
  2431. const e = this.transString(a);
  2432. this.arr.push(e), this.sendInner();
  2433. }
  2434. sendImmediate(a) {
  2435. const e = this.transString(a);
  2436. this.arr.push(e), this.sendImmediateInner();
  2437. }
  2438. sendBatchLogs(a) {
  2439. const e = a.map((t) => this.transString(t));
  2440. this.arr.push(...e), this.sendInner();
  2441. }
  2442. sendBatchLogsImmediate(a) {
  2443. const e = a.map((t) => this.transString(t));
  2444. this.arr.push(...e), this.sendImmediateInner();
  2445. }
  2446. overwriteTransString(a) {
  2447. this.transString = a.transString;
  2448. }
  2449. getOpt() {
  2450. return this.opt;
  2451. }
  2452. }
  2453. var wo = (r, a, e) => new Promise((t, i) => {
  2454. var s = (o) => {
  2455. try {
  2456. c(e.next(o));
  2457. } catch (u) {
  2458. i(u);
  2459. }
  2460. }, n = (o) => {
  2461. try {
  2462. c(e.throw(o));
  2463. } catch (u) {
  2464. i(u);
  2465. }
  2466. }, c = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(s, n);
  2467. c((e = e.apply(r, a)).next());
  2468. });
  2469. function Do(r, a) {
  2470. return navigator && navigator.sendBeacon ? navigator.sendBeacon(`${r}?APIVersion=0.6.0`, a) : !1;
  2471. }
  2472. function Zs(r, a) {
  2473. const e = new window.XMLHttpRequest();
  2474. e.open("POST", `${r}?APIVersion=0.6.0`, !0), e.send(a);
  2475. }
  2476. function To(r, a) {
  2477. try {
  2478. if (a.length >= 32768) {
  2479. Zs(r, a);
  2480. return;
  2481. }
  2482. Do(r, a) || Zs(r, a);
  2483. } catch (e) {
  2484. window && window.console && typeof window.console.error == "function" && (console.error(`Failed to log to ali log service because of this exception:
  2485. ` + e), console.error("Failed log data:", r));
  2486. }
  2487. }
  2488. function Po(r, a, e) {
  2489. return wo(this, null, function* () {
  2490. try {
  2491. r = r.slice(0, -6);
  2492. const { data: t, header: i } = yield e.process(r, a), s = new window.XMLHttpRequest();
  2493. s.open("POST", r, !0);
  2494. for (let n in i)
  2495. s.setRequestHeader(n, i[n]);
  2496. s.send(t);
  2497. } catch (t) {
  2498. window && window.console && typeof window.console.error == "function" && (console.error(`Failed to log to ali log service because of this exception:
  2499. ` + t), console.error("Failed log data:", r));
  2500. }
  2501. });
  2502. }
  2503. class Gr extends Io {
  2504. constructor(a) {
  2505. const e = Object.assign({}, a, {
  2506. installUnloadHook: (t) => {
  2507. window.addEventListener("beforeunload", () => {
  2508. t();
  2509. });
  2510. },
  2511. sendPayload: (t, i) => {
  2512. To(t, i);
  2513. }
  2514. });
  2515. super(e);
  2516. }
  2517. useStsPlugin(a) {
  2518. this.getOpt().sendPayload = (e, t) => {
  2519. Po(e, t, a);
  2520. }, this.overwriteTransString(a);
  2521. }
  2522. }
  2523. cn(window, "SLS_Tracker", Gr);
  2524. var ie = typeof globalThis != "undefined" ? globalThis : typeof window != "undefined" ? window : typeof global != "undefined" ? global : typeof self != "undefined" ? self : {};
  2525. function ko(r) {
  2526. return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
  2527. }
  2528. function Bo(r) {
  2529. if (r.__esModule)
  2530. return r;
  2531. var a = r.default;
  2532. if (typeof a == "function") {
  2533. var e = function t() {
  2534. return this instanceof t ? Reflect.construct(a, arguments, this.constructor) : a.apply(this, arguments);
  2535. };
  2536. e.prototype = a.prototype;
  2537. } else
  2538. e = {};
  2539. return Object.defineProperty(e, "__esModule", { value: !0 }), Object.keys(r).forEach(function(t) {
  2540. var i = Object.getOwnPropertyDescriptor(r, t);
  2541. Object.defineProperty(e, t, i.get ? i : {
  2542. enumerable: !0,
  2543. get: function() {
  2544. return r[t];
  2545. }
  2546. });
  2547. }), e;
  2548. }
  2549. var un = { exports: {} };
  2550. function No(r) {
  2551. throw new Error('Could not dynamically require "' + r + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
  2552. }
  2553. var Yi = { exports: {} };
  2554. const Mo = {}, Lo = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  2555. __proto__: null,
  2556. default: Mo
  2557. }, Symbol.toStringTag, { value: "Module" })), Fo = /* @__PURE__ */ Bo(Lo);
  2558. var Qs;
  2559. function ne() {
  2560. return Qs || (Qs = 1, function(r, a) {
  2561. (function(e, t) {
  2562. r.exports = t();
  2563. })(ie, function() {
  2564. var e = e || function(t, i) {
  2565. var s;
  2566. if (typeof window != "undefined" && window.crypto && (s = window.crypto), typeof self != "undefined" && self.crypto && (s = self.crypto), typeof globalThis != "undefined" && globalThis.crypto && (s = globalThis.crypto), !s && typeof window != "undefined" && window.msCrypto && (s = window.msCrypto), !s && typeof ie != "undefined" && ie.crypto && (s = ie.crypto), !s && typeof No == "function")
  2567. try {
  2568. s = Fo;
  2569. } catch (x) {
  2570. }
  2571. var n = function() {
  2572. if (s) {
  2573. if (typeof s.getRandomValues == "function")
  2574. try {
  2575. return s.getRandomValues(new Uint32Array(1))[0];
  2576. } catch (x) {
  2577. }
  2578. if (typeof s.randomBytes == "function")
  2579. try {
  2580. return s.randomBytes(4).readInt32LE();
  2581. } catch (x) {
  2582. }
  2583. }
  2584. throw new Error("Native crypto module could not be used to get secure random number.");
  2585. }, c = Object.create || function() {
  2586. function x() {
  2587. }
  2588. return function(b) {
  2589. var E;
  2590. return x.prototype = b, E = new x(), x.prototype = null, E;
  2591. };
  2592. }(), o = {}, u = o.lib = {}, h = u.Base = function() {
  2593. return {
  2594. /**
  2595. * Creates a new object that inherits from this object.
  2596. *
  2597. * @param {Object} overrides Properties to copy into the new object.
  2598. *
  2599. * @return {Object} The new object.
  2600. *
  2601. * @static
  2602. *
  2603. * @example
  2604. *
  2605. * var MyType = CryptoJS.lib.Base.extend({
  2606. * field: 'value',
  2607. *
  2608. * method: function () {
  2609. * }
  2610. * });
  2611. */
  2612. extend: function(x) {
  2613. var b = c(this);
  2614. return x && b.mixIn(x), (!b.hasOwnProperty("init") || this.init === b.init) && (b.init = function() {
  2615. b.$super.init.apply(this, arguments);
  2616. }), b.init.prototype = b, b.$super = this, b;
  2617. },
  2618. /**
  2619. * Extends this object and runs the init method.
  2620. * Arguments to create() will be passed to init().
  2621. *
  2622. * @return {Object} The new object.
  2623. *
  2624. * @static
  2625. *
  2626. * @example
  2627. *
  2628. * var instance = MyType.create();
  2629. */
  2630. create: function() {
  2631. var x = this.extend();
  2632. return x.init.apply(x, arguments), x;
  2633. },
  2634. /**
  2635. * Initializes a newly created object.
  2636. * Override this method to add some logic when your objects are created.
  2637. *
  2638. * @example
  2639. *
  2640. * var MyType = CryptoJS.lib.Base.extend({
  2641. * init: function () {
  2642. * // ...
  2643. * }
  2644. * });
  2645. */
  2646. init: function() {
  2647. },
  2648. /**
  2649. * Copies properties into this object.
  2650. *
  2651. * @param {Object} properties The properties to mix in.
  2652. *
  2653. * @example
  2654. *
  2655. * MyType.mixIn({
  2656. * field: 'value'
  2657. * });
  2658. */
  2659. mixIn: function(x) {
  2660. for (var b in x)
  2661. x.hasOwnProperty(b) && (this[b] = x[b]);
  2662. x.hasOwnProperty("toString") && (this.toString = x.toString);
  2663. },
  2664. /**
  2665. * Creates a copy of this object.
  2666. *
  2667. * @return {Object} The clone.
  2668. *
  2669. * @example
  2670. *
  2671. * var clone = instance.clone();
  2672. */
  2673. clone: function() {
  2674. return this.init.prototype.extend(this);
  2675. }
  2676. };
  2677. }(), p = u.WordArray = h.extend({
  2678. /**
  2679. * Initializes a newly created word array.
  2680. *
  2681. * @param {Array} words (Optional) An array of 32-bit words.
  2682. * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  2683. *
  2684. * @example
  2685. *
  2686. * var wordArray = CryptoJS.lib.WordArray.create();
  2687. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]);
  2688. * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6);
  2689. */
  2690. init: function(x, b) {
  2691. x = this.words = x || [], b != i ? this.sigBytes = b : this.sigBytes = x.length * 4;
  2692. },
  2693. /**
  2694. * Converts this word array to a string.
  2695. *
  2696. * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex
  2697. *
  2698. * @return {string} The stringified word array.
  2699. *
  2700. * @example
  2701. *
  2702. * var string = wordArray + '';
  2703. * var string = wordArray.toString();
  2704. * var string = wordArray.toString(CryptoJS.enc.Utf8);
  2705. */
  2706. toString: function(x) {
  2707. return (x || f).stringify(this);
  2708. },
  2709. /**
  2710. * Concatenates a word array to this word array.
  2711. *
  2712. * @param {WordArray} wordArray The word array to append.
  2713. *
  2714. * @return {WordArray} This word array.
  2715. *
  2716. * @example
  2717. *
  2718. * wordArray1.concat(wordArray2);
  2719. */
  2720. concat: function(x) {
  2721. var b = this.words, E = x.words, _ = this.sigBytes, y = x.sigBytes;
  2722. if (this.clamp(), _ % 4)
  2723. for (var A = 0; A < y; A++) {
  2724. var R = E[A >>> 2] >>> 24 - A % 4 * 8 & 255;
  2725. b[_ + A >>> 2] |= R << 24 - (_ + A) % 4 * 8;
  2726. }
  2727. else
  2728. for (var M = 0; M < y; M += 4)
  2729. b[_ + M >>> 2] = E[M >>> 2];
  2730. return this.sigBytes += y, this;
  2731. },
  2732. /**
  2733. * Removes insignificant bits.
  2734. *
  2735. * @example
  2736. *
  2737. * wordArray.clamp();
  2738. */
  2739. clamp: function() {
  2740. var x = this.words, b = this.sigBytes;
  2741. x[b >>> 2] &= 4294967295 << 32 - b % 4 * 8, x.length = t.ceil(b / 4);
  2742. },
  2743. /**
  2744. * Creates a copy of this word array.
  2745. *
  2746. * @return {WordArray} The clone.
  2747. *
  2748. * @example
  2749. *
  2750. * var clone = wordArray.clone();
  2751. */
  2752. clone: function() {
  2753. var x = h.clone.call(this);
  2754. return x.words = this.words.slice(0), x;
  2755. },
  2756. /**
  2757. * Creates a word array filled with random bytes.
  2758. *
  2759. * @param {number} nBytes The number of random bytes to generate.
  2760. *
  2761. * @return {WordArray} The random word array.
  2762. *
  2763. * @static
  2764. *
  2765. * @example
  2766. *
  2767. * var wordArray = CryptoJS.lib.WordArray.random(16);
  2768. */
  2769. random: function(x) {
  2770. for (var b = [], E = 0; E < x; E += 4)
  2771. b.push(n());
  2772. return new p.init(b, x);
  2773. }
  2774. }), d = o.enc = {}, f = d.Hex = {
  2775. /**
  2776. * Converts a word array to a hex string.
  2777. *
  2778. * @param {WordArray} wordArray The word array.
  2779. *
  2780. * @return {string} The hex string.
  2781. *
  2782. * @static
  2783. *
  2784. * @example
  2785. *
  2786. * var hexString = CryptoJS.enc.Hex.stringify(wordArray);
  2787. */
  2788. stringify: function(x) {
  2789. for (var b = x.words, E = x.sigBytes, _ = [], y = 0; y < E; y++) {
  2790. var A = b[y >>> 2] >>> 24 - y % 4 * 8 & 255;
  2791. _.push((A >>> 4).toString(16)), _.push((A & 15).toString(16));
  2792. }
  2793. return _.join("");
  2794. },
  2795. /**
  2796. * Converts a hex string to a word array.
  2797. *
  2798. * @param {string} hexStr The hex string.
  2799. *
  2800. * @return {WordArray} The word array.
  2801. *
  2802. * @static
  2803. *
  2804. * @example
  2805. *
  2806. * var wordArray = CryptoJS.enc.Hex.parse(hexString);
  2807. */
  2808. parse: function(x) {
  2809. for (var b = x.length, E = [], _ = 0; _ < b; _ += 2)
  2810. E[_ >>> 3] |= parseInt(x.substr(_, 2), 16) << 24 - _ % 8 * 4;
  2811. return new p.init(E, b / 2);
  2812. }
  2813. }, m = d.Latin1 = {
  2814. /**
  2815. * Converts a word array to a Latin1 string.
  2816. *
  2817. * @param {WordArray} wordArray The word array.
  2818. *
  2819. * @return {string} The Latin1 string.
  2820. *
  2821. * @static
  2822. *
  2823. * @example
  2824. *
  2825. * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray);
  2826. */
  2827. stringify: function(x) {
  2828. for (var b = x.words, E = x.sigBytes, _ = [], y = 0; y < E; y++) {
  2829. var A = b[y >>> 2] >>> 24 - y % 4 * 8 & 255;
  2830. _.push(String.fromCharCode(A));
  2831. }
  2832. return _.join("");
  2833. },
  2834. /**
  2835. * Converts a Latin1 string to a word array.
  2836. *
  2837. * @param {string} latin1Str The Latin1 string.
  2838. *
  2839. * @return {WordArray} The word array.
  2840. *
  2841. * @static
  2842. *
  2843. * @example
  2844. *
  2845. * var wordArray = CryptoJS.enc.Latin1.parse(latin1String);
  2846. */
  2847. parse: function(x) {
  2848. for (var b = x.length, E = [], _ = 0; _ < b; _++)
  2849. E[_ >>> 2] |= (x.charCodeAt(_) & 255) << 24 - _ % 4 * 8;
  2850. return new p.init(E, b);
  2851. }
  2852. }, l = d.Utf8 = {
  2853. /**
  2854. * Converts a word array to a UTF-8 string.
  2855. *
  2856. * @param {WordArray} wordArray The word array.
  2857. *
  2858. * @return {string} The UTF-8 string.
  2859. *
  2860. * @static
  2861. *
  2862. * @example
  2863. *
  2864. * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray);
  2865. */
  2866. stringify: function(x) {
  2867. try {
  2868. return decodeURIComponent(escape(m.stringify(x)));
  2869. } catch (b) {
  2870. throw new Error("Malformed UTF-8 data");
  2871. }
  2872. },
  2873. /**
  2874. * Converts a UTF-8 string to a word array.
  2875. *
  2876. * @param {string} utf8Str The UTF-8 string.
  2877. *
  2878. * @return {WordArray} The word array.
  2879. *
  2880. * @static
  2881. *
  2882. * @example
  2883. *
  2884. * var wordArray = CryptoJS.enc.Utf8.parse(utf8String);
  2885. */
  2886. parse: function(x) {
  2887. return m.parse(unescape(encodeURIComponent(x)));
  2888. }
  2889. }, S = u.BufferedBlockAlgorithm = h.extend({
  2890. /**
  2891. * Resets this block algorithm's data buffer to its initial state.
  2892. *
  2893. * @example
  2894. *
  2895. * bufferedBlockAlgorithm.reset();
  2896. */
  2897. reset: function() {
  2898. this._data = new p.init(), this._nDataBytes = 0;
  2899. },
  2900. /**
  2901. * Adds new data to this block algorithm's buffer.
  2902. *
  2903. * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8.
  2904. *
  2905. * @example
  2906. *
  2907. * bufferedBlockAlgorithm._append('data');
  2908. * bufferedBlockAlgorithm._append(wordArray);
  2909. */
  2910. _append: function(x) {
  2911. typeof x == "string" && (x = l.parse(x)), this._data.concat(x), this._nDataBytes += x.sigBytes;
  2912. },
  2913. /**
  2914. * Processes available data blocks.
  2915. *
  2916. * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype.
  2917. *
  2918. * @param {boolean} doFlush Whether all blocks and partial blocks should be processed.
  2919. *
  2920. * @return {WordArray} The processed data.
  2921. *
  2922. * @example
  2923. *
  2924. * var processedData = bufferedBlockAlgorithm._process();
  2925. * var processedData = bufferedBlockAlgorithm._process(!!'flush');
  2926. */
  2927. _process: function(x) {
  2928. var b, E = this._data, _ = E.words, y = E.sigBytes, A = this.blockSize, R = A * 4, M = y / R;
  2929. x ? M = t.ceil(M) : M = t.max((M | 0) - this._minBufferSize, 0);
  2930. var C = M * A, I = t.min(C * 4, y);
  2931. if (C) {
  2932. for (var P = 0; P < C; P += A)
  2933. this._doProcessBlock(_, P);
  2934. b = _.splice(0, C), E.sigBytes -= I;
  2935. }
  2936. return new p.init(b, I);
  2937. },
  2938. /**
  2939. * Creates a copy of this object.
  2940. *
  2941. * @return {Object} The clone.
  2942. *
  2943. * @example
  2944. *
  2945. * var clone = bufferedBlockAlgorithm.clone();
  2946. */
  2947. clone: function() {
  2948. var x = h.clone.call(this);
  2949. return x._data = this._data.clone(), x;
  2950. },
  2951. _minBufferSize: 0
  2952. });
  2953. u.Hasher = S.extend({
  2954. /**
  2955. * Configuration options.
  2956. */
  2957. cfg: h.extend(),
  2958. /**
  2959. * Initializes a newly created hasher.
  2960. *
  2961. * @param {Object} cfg (Optional) The configuration options to use for this hash computation.
  2962. *
  2963. * @example
  2964. *
  2965. * var hasher = CryptoJS.algo.SHA256.create();
  2966. */
  2967. init: function(x) {
  2968. this.cfg = this.cfg.extend(x), this.reset();
  2969. },
  2970. /**
  2971. * Resets this hasher to its initial state.
  2972. *
  2973. * @example
  2974. *
  2975. * hasher.reset();
  2976. */
  2977. reset: function() {
  2978. S.reset.call(this), this._doReset();
  2979. },
  2980. /**
  2981. * Updates this hasher with a message.
  2982. *
  2983. * @param {WordArray|string} messageUpdate The message to append.
  2984. *
  2985. * @return {Hasher} This hasher.
  2986. *
  2987. * @example
  2988. *
  2989. * hasher.update('message');
  2990. * hasher.update(wordArray);
  2991. */
  2992. update: function(x) {
  2993. return this._append(x), this._process(), this;
  2994. },
  2995. /**
  2996. * Finalizes the hash computation.
  2997. * Note that the finalize operation is effectively a destructive, read-once operation.
  2998. *
  2999. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  3000. *
  3001. * @return {WordArray} The hash.
  3002. *
  3003. * @example
  3004. *
  3005. * var hash = hasher.finalize();
  3006. * var hash = hasher.finalize('message');
  3007. * var hash = hasher.finalize(wordArray);
  3008. */
  3009. finalize: function(x) {
  3010. x && this._append(x);
  3011. var b = this._doFinalize();
  3012. return b;
  3013. },
  3014. blockSize: 16,
  3015. /**
  3016. * Creates a shortcut function to a hasher's object interface.
  3017. *
  3018. * @param {Hasher} hasher The hasher to create a helper for.
  3019. *
  3020. * @return {Function} The shortcut function.
  3021. *
  3022. * @static
  3023. *
  3024. * @example
  3025. *
  3026. * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256);
  3027. */
  3028. _createHelper: function(x) {
  3029. return function(b, E) {
  3030. return new x.init(E).finalize(b);
  3031. };
  3032. },
  3033. /**
  3034. * Creates a shortcut function to the HMAC's object interface.
  3035. *
  3036. * @param {Hasher} hasher The hasher to use in this HMAC helper.
  3037. *
  3038. * @return {Function} The shortcut function.
  3039. *
  3040. * @static
  3041. *
  3042. * @example
  3043. *
  3044. * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256);
  3045. */
  3046. _createHmacHelper: function(x) {
  3047. return function(b, E) {
  3048. return new v.HMAC.init(x, E).finalize(b);
  3049. };
  3050. }
  3051. });
  3052. var v = o.algo = {};
  3053. return o;
  3054. }(Math);
  3055. return e;
  3056. });
  3057. }(Yi)), Yi.exports;
  3058. }
  3059. var Zi = { exports: {} }, ea;
  3060. function Ci() {
  3061. return ea || (ea = 1, function(r, a) {
  3062. (function(e, t) {
  3063. r.exports = t(ne());
  3064. })(ie, function(e) {
  3065. return function(t) {
  3066. var i = e, s = i.lib, n = s.Base, c = s.WordArray, o = i.x64 = {};
  3067. o.Word = n.extend({
  3068. /**
  3069. * Initializes a newly created 64-bit word.
  3070. *
  3071. * @param {number} high The high 32 bits.
  3072. * @param {number} low The low 32 bits.
  3073. *
  3074. * @example
  3075. *
  3076. * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607);
  3077. */
  3078. init: function(u, h) {
  3079. this.high = u, this.low = h;
  3080. }
  3081. /**
  3082. * Bitwise NOTs this word.
  3083. *
  3084. * @return {X64Word} A new x64-Word object after negating.
  3085. *
  3086. * @example
  3087. *
  3088. * var negated = x64Word.not();
  3089. */
  3090. // not: function () {
  3091. // var high = ~this.high;
  3092. // var low = ~this.low;
  3093. // return X64Word.create(high, low);
  3094. // },
  3095. /**
  3096. * Bitwise ANDs this word with the passed word.
  3097. *
  3098. * @param {X64Word} word The x64-Word to AND with this word.
  3099. *
  3100. * @return {X64Word} A new x64-Word object after ANDing.
  3101. *
  3102. * @example
  3103. *
  3104. * var anded = x64Word.and(anotherX64Word);
  3105. */
  3106. // and: function (word) {
  3107. // var high = this.high & word.high;
  3108. // var low = this.low & word.low;
  3109. // return X64Word.create(high, low);
  3110. // },
  3111. /**
  3112. * Bitwise ORs this word with the passed word.
  3113. *
  3114. * @param {X64Word} word The x64-Word to OR with this word.
  3115. *
  3116. * @return {X64Word} A new x64-Word object after ORing.
  3117. *
  3118. * @example
  3119. *
  3120. * var ored = x64Word.or(anotherX64Word);
  3121. */
  3122. // or: function (word) {
  3123. // var high = this.high | word.high;
  3124. // var low = this.low | word.low;
  3125. // return X64Word.create(high, low);
  3126. // },
  3127. /**
  3128. * Bitwise XORs this word with the passed word.
  3129. *
  3130. * @param {X64Word} word The x64-Word to XOR with this word.
  3131. *
  3132. * @return {X64Word} A new x64-Word object after XORing.
  3133. *
  3134. * @example
  3135. *
  3136. * var xored = x64Word.xor(anotherX64Word);
  3137. */
  3138. // xor: function (word) {
  3139. // var high = this.high ^ word.high;
  3140. // var low = this.low ^ word.low;
  3141. // return X64Word.create(high, low);
  3142. // },
  3143. /**
  3144. * Shifts this word n bits to the left.
  3145. *
  3146. * @param {number} n The number of bits to shift.
  3147. *
  3148. * @return {X64Word} A new x64-Word object after shifting.
  3149. *
  3150. * @example
  3151. *
  3152. * var shifted = x64Word.shiftL(25);
  3153. */
  3154. // shiftL: function (n) {
  3155. // if (n < 32) {
  3156. // var high = (this.high << n) | (this.low >>> (32 - n));
  3157. // var low = this.low << n;
  3158. // } else {
  3159. // var high = this.low << (n - 32);
  3160. // var low = 0;
  3161. // }
  3162. // return X64Word.create(high, low);
  3163. // },
  3164. /**
  3165. * Shifts this word n bits to the right.
  3166. *
  3167. * @param {number} n The number of bits to shift.
  3168. *
  3169. * @return {X64Word} A new x64-Word object after shifting.
  3170. *
  3171. * @example
  3172. *
  3173. * var shifted = x64Word.shiftR(7);
  3174. */
  3175. // shiftR: function (n) {
  3176. // if (n < 32) {
  3177. // var low = (this.low >>> n) | (this.high << (32 - n));
  3178. // var high = this.high >>> n;
  3179. // } else {
  3180. // var low = this.high >>> (n - 32);
  3181. // var high = 0;
  3182. // }
  3183. // return X64Word.create(high, low);
  3184. // },
  3185. /**
  3186. * Rotates this word n bits to the left.
  3187. *
  3188. * @param {number} n The number of bits to rotate.
  3189. *
  3190. * @return {X64Word} A new x64-Word object after rotating.
  3191. *
  3192. * @example
  3193. *
  3194. * var rotated = x64Word.rotL(25);
  3195. */
  3196. // rotL: function (n) {
  3197. // return this.shiftL(n).or(this.shiftR(64 - n));
  3198. // },
  3199. /**
  3200. * Rotates this word n bits to the right.
  3201. *
  3202. * @param {number} n The number of bits to rotate.
  3203. *
  3204. * @return {X64Word} A new x64-Word object after rotating.
  3205. *
  3206. * @example
  3207. *
  3208. * var rotated = x64Word.rotR(7);
  3209. */
  3210. // rotR: function (n) {
  3211. // return this.shiftR(n).or(this.shiftL(64 - n));
  3212. // },
  3213. /**
  3214. * Adds this word with the passed word.
  3215. *
  3216. * @param {X64Word} word The x64-Word to add with this word.
  3217. *
  3218. * @return {X64Word} A new x64-Word object after adding.
  3219. *
  3220. * @example
  3221. *
  3222. * var added = x64Word.add(anotherX64Word);
  3223. */
  3224. // add: function (word) {
  3225. // var low = (this.low + word.low) | 0;
  3226. // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0;
  3227. // var high = (this.high + word.high + carry) | 0;
  3228. // return X64Word.create(high, low);
  3229. // }
  3230. }), o.WordArray = n.extend({
  3231. /**
  3232. * Initializes a newly created word array.
  3233. *
  3234. * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects.
  3235. * @param {number} sigBytes (Optional) The number of significant bytes in the words.
  3236. *
  3237. * @example
  3238. *
  3239. * var wordArray = CryptoJS.x64.WordArray.create();
  3240. *
  3241. * var wordArray = CryptoJS.x64.WordArray.create([
  3242. * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
  3243. * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
  3244. * ]);
  3245. *
  3246. * var wordArray = CryptoJS.x64.WordArray.create([
  3247. * CryptoJS.x64.Word.create(0x00010203, 0x04050607),
  3248. * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f)
  3249. * ], 10);
  3250. */
  3251. init: function(u, h) {
  3252. u = this.words = u || [], h != t ? this.sigBytes = h : this.sigBytes = u.length * 8;
  3253. },
  3254. /**
  3255. * Converts this 64-bit word array to a 32-bit word array.
  3256. *
  3257. * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array.
  3258. *
  3259. * @example
  3260. *
  3261. * var x32WordArray = x64WordArray.toX32();
  3262. */
  3263. toX32: function() {
  3264. for (var u = this.words, h = u.length, p = [], d = 0; d < h; d++) {
  3265. var f = u[d];
  3266. p.push(f.high), p.push(f.low);
  3267. }
  3268. return c.create(p, this.sigBytes);
  3269. },
  3270. /**
  3271. * Creates a copy of this word array.
  3272. *
  3273. * @return {X64WordArray} The clone.
  3274. *
  3275. * @example
  3276. *
  3277. * var clone = x64WordArray.clone();
  3278. */
  3279. clone: function() {
  3280. for (var u = n.clone.call(this), h = u.words = this.words.slice(0), p = h.length, d = 0; d < p; d++)
  3281. h[d] = h[d].clone();
  3282. return u;
  3283. }
  3284. });
  3285. }(), e;
  3286. });
  3287. }(Zi)), Zi.exports;
  3288. }
  3289. var Qi = { exports: {} }, ta;
  3290. function Vo() {
  3291. return ta || (ta = 1, function(r, a) {
  3292. (function(e, t) {
  3293. r.exports = t(ne());
  3294. })(ie, function(e) {
  3295. return function() {
  3296. if (typeof ArrayBuffer == "function") {
  3297. var t = e, i = t.lib, s = i.WordArray, n = s.init, c = s.init = function(o) {
  3298. if (o instanceof ArrayBuffer && (o = new Uint8Array(o)), (o instanceof Int8Array || typeof Uint8ClampedArray != "undefined" && o instanceof Uint8ClampedArray || o instanceof Int16Array || o instanceof Uint16Array || o instanceof Int32Array || o instanceof Uint32Array || o instanceof Float32Array || o instanceof Float64Array) && (o = new Uint8Array(o.buffer, o.byteOffset, o.byteLength)), o instanceof Uint8Array) {
  3299. for (var u = o.byteLength, h = [], p = 0; p < u; p++)
  3300. h[p >>> 2] |= o[p] << 24 - p % 4 * 8;
  3301. n.call(this, h, u);
  3302. } else
  3303. n.apply(this, arguments);
  3304. };
  3305. c.prototype = s;
  3306. }
  3307. }(), e.lib.WordArray;
  3308. });
  3309. }(Qi)), Qi.exports;
  3310. }
  3311. var er = { exports: {} }, ia;
  3312. function Oo() {
  3313. return ia || (ia = 1, function(r, a) {
  3314. (function(e, t) {
  3315. r.exports = t(ne());
  3316. })(ie, function(e) {
  3317. return function() {
  3318. var t = e, i = t.lib, s = i.WordArray, n = t.enc;
  3319. n.Utf16 = n.Utf16BE = {
  3320. /**
  3321. * Converts a word array to a UTF-16 BE string.
  3322. *
  3323. * @param {WordArray} wordArray The word array.
  3324. *
  3325. * @return {string} The UTF-16 BE string.
  3326. *
  3327. * @static
  3328. *
  3329. * @example
  3330. *
  3331. * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray);
  3332. */
  3333. stringify: function(o) {
  3334. for (var u = o.words, h = o.sigBytes, p = [], d = 0; d < h; d += 2) {
  3335. var f = u[d >>> 2] >>> 16 - d % 4 * 8 & 65535;
  3336. p.push(String.fromCharCode(f));
  3337. }
  3338. return p.join("");
  3339. },
  3340. /**
  3341. * Converts a UTF-16 BE string to a word array.
  3342. *
  3343. * @param {string} utf16Str The UTF-16 BE string.
  3344. *
  3345. * @return {WordArray} The word array.
  3346. *
  3347. * @static
  3348. *
  3349. * @example
  3350. *
  3351. * var wordArray = CryptoJS.enc.Utf16.parse(utf16String);
  3352. */
  3353. parse: function(o) {
  3354. for (var u = o.length, h = [], p = 0; p < u; p++)
  3355. h[p >>> 1] |= o.charCodeAt(p) << 16 - p % 2 * 16;
  3356. return s.create(h, u * 2);
  3357. }
  3358. }, n.Utf16LE = {
  3359. /**
  3360. * Converts a word array to a UTF-16 LE string.
  3361. *
  3362. * @param {WordArray} wordArray The word array.
  3363. *
  3364. * @return {string} The UTF-16 LE string.
  3365. *
  3366. * @static
  3367. *
  3368. * @example
  3369. *
  3370. * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray);
  3371. */
  3372. stringify: function(o) {
  3373. for (var u = o.words, h = o.sigBytes, p = [], d = 0; d < h; d += 2) {
  3374. var f = c(u[d >>> 2] >>> 16 - d % 4 * 8 & 65535);
  3375. p.push(String.fromCharCode(f));
  3376. }
  3377. return p.join("");
  3378. },
  3379. /**
  3380. * Converts a UTF-16 LE string to a word array.
  3381. *
  3382. * @param {string} utf16Str The UTF-16 LE string.
  3383. *
  3384. * @return {WordArray} The word array.
  3385. *
  3386. * @static
  3387. *
  3388. * @example
  3389. *
  3390. * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str);
  3391. */
  3392. parse: function(o) {
  3393. for (var u = o.length, h = [], p = 0; p < u; p++)
  3394. h[p >>> 1] |= c(o.charCodeAt(p) << 16 - p % 2 * 16);
  3395. return s.create(h, u * 2);
  3396. }
  3397. };
  3398. function c(o) {
  3399. return o << 8 & 4278255360 | o >>> 8 & 16711935;
  3400. }
  3401. }(), e.enc.Utf16;
  3402. });
  3403. }(er)), er.exports;
  3404. }
  3405. var tr = { exports: {} }, ra;
  3406. function Ot() {
  3407. return ra || (ra = 1, function(r, a) {
  3408. (function(e, t) {
  3409. r.exports = t(ne());
  3410. })(ie, function(e) {
  3411. return function() {
  3412. var t = e, i = t.lib, s = i.WordArray, n = t.enc;
  3413. n.Base64 = {
  3414. /**
  3415. * Converts a word array to a Base64 string.
  3416. *
  3417. * @param {WordArray} wordArray The word array.
  3418. *
  3419. * @return {string} The Base64 string.
  3420. *
  3421. * @static
  3422. *
  3423. * @example
  3424. *
  3425. * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
  3426. */
  3427. stringify: function(o) {
  3428. var u = o.words, h = o.sigBytes, p = this._map;
  3429. o.clamp();
  3430. for (var d = [], f = 0; f < h; f += 3)
  3431. for (var m = u[f >>> 2] >>> 24 - f % 4 * 8 & 255, l = u[f + 1 >>> 2] >>> 24 - (f + 1) % 4 * 8 & 255, S = u[f + 2 >>> 2] >>> 24 - (f + 2) % 4 * 8 & 255, v = m << 16 | l << 8 | S, x = 0; x < 4 && f + x * 0.75 < h; x++)
  3432. d.push(p.charAt(v >>> 6 * (3 - x) & 63));
  3433. var b = p.charAt(64);
  3434. if (b)
  3435. for (; d.length % 4; )
  3436. d.push(b);
  3437. return d.join("");
  3438. },
  3439. /**
  3440. * Converts a Base64 string to a word array.
  3441. *
  3442. * @param {string} base64Str The Base64 string.
  3443. *
  3444. * @return {WordArray} The word array.
  3445. *
  3446. * @static
  3447. *
  3448. * @example
  3449. *
  3450. * var wordArray = CryptoJS.enc.Base64.parse(base64String);
  3451. */
  3452. parse: function(o) {
  3453. var u = o.length, h = this._map, p = this._reverseMap;
  3454. if (!p) {
  3455. p = this._reverseMap = [];
  3456. for (var d = 0; d < h.length; d++)
  3457. p[h.charCodeAt(d)] = d;
  3458. }
  3459. var f = h.charAt(64);
  3460. if (f) {
  3461. var m = o.indexOf(f);
  3462. m !== -1 && (u = m);
  3463. }
  3464. return c(o, u, p);
  3465. },
  3466. _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
  3467. };
  3468. function c(o, u, h) {
  3469. for (var p = [], d = 0, f = 0; f < u; f++)
  3470. if (f % 4) {
  3471. var m = h[o.charCodeAt(f - 1)] << f % 4 * 2, l = h[o.charCodeAt(f)] >>> 6 - f % 4 * 2, S = m | l;
  3472. p[d >>> 2] |= S << 24 - d % 4 * 8, d++;
  3473. }
  3474. return s.create(p, d);
  3475. }
  3476. }(), e.enc.Base64;
  3477. });
  3478. }(tr)), tr.exports;
  3479. }
  3480. var ir = { exports: {} }, sa;
  3481. function Uo() {
  3482. return sa || (sa = 1, function(r, a) {
  3483. (function(e, t) {
  3484. r.exports = t(ne());
  3485. })(ie, function(e) {
  3486. return function() {
  3487. var t = e, i = t.lib, s = i.WordArray, n = t.enc;
  3488. n.Base64url = {
  3489. /**
  3490. * Converts a word array to a Base64url string.
  3491. *
  3492. * @param {WordArray} wordArray The word array.
  3493. *
  3494. * @param {boolean} urlSafe Whether to use url safe
  3495. *
  3496. * @return {string} The Base64url string.
  3497. *
  3498. * @static
  3499. *
  3500. * @example
  3501. *
  3502. * var base64String = CryptoJS.enc.Base64url.stringify(wordArray);
  3503. */
  3504. stringify: function(o, u) {
  3505. u === void 0 && (u = !0);
  3506. var h = o.words, p = o.sigBytes, d = u ? this._safe_map : this._map;
  3507. o.clamp();
  3508. for (var f = [], m = 0; m < p; m += 3)
  3509. for (var l = h[m >>> 2] >>> 24 - m % 4 * 8 & 255, S = h[m + 1 >>> 2] >>> 24 - (m + 1) % 4 * 8 & 255, v = h[m + 2 >>> 2] >>> 24 - (m + 2) % 4 * 8 & 255, x = l << 16 | S << 8 | v, b = 0; b < 4 && m + b * 0.75 < p; b++)
  3510. f.push(d.charAt(x >>> 6 * (3 - b) & 63));
  3511. var E = d.charAt(64);
  3512. if (E)
  3513. for (; f.length % 4; )
  3514. f.push(E);
  3515. return f.join("");
  3516. },
  3517. /**
  3518. * Converts a Base64url string to a word array.
  3519. *
  3520. * @param {string} base64Str The Base64url string.
  3521. *
  3522. * @param {boolean} urlSafe Whether to use url safe
  3523. *
  3524. * @return {WordArray} The word array.
  3525. *
  3526. * @static
  3527. *
  3528. * @example
  3529. *
  3530. * var wordArray = CryptoJS.enc.Base64url.parse(base64String);
  3531. */
  3532. parse: function(o, u) {
  3533. u === void 0 && (u = !0);
  3534. var h = o.length, p = u ? this._safe_map : this._map, d = this._reverseMap;
  3535. if (!d) {
  3536. d = this._reverseMap = [];
  3537. for (var f = 0; f < p.length; f++)
  3538. d[p.charCodeAt(f)] = f;
  3539. }
  3540. var m = p.charAt(64);
  3541. if (m) {
  3542. var l = o.indexOf(m);
  3543. l !== -1 && (h = l);
  3544. }
  3545. return c(o, h, d);
  3546. },
  3547. _map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
  3548. _safe_map: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
  3549. };
  3550. function c(o, u, h) {
  3551. for (var p = [], d = 0, f = 0; f < u; f++)
  3552. if (f % 4) {
  3553. var m = h[o.charCodeAt(f - 1)] << f % 4 * 2, l = h[o.charCodeAt(f)] >>> 6 - f % 4 * 2, S = m | l;
  3554. p[d >>> 2] |= S << 24 - d % 4 * 8, d++;
  3555. }
  3556. return s.create(p, d);
  3557. }
  3558. }(), e.enc.Base64url;
  3559. });
  3560. }(ir)), ir.exports;
  3561. }
  3562. var rr = { exports: {} }, aa;
  3563. function Ut() {
  3564. return aa || (aa = 1, function(r, a) {
  3565. (function(e, t) {
  3566. r.exports = t(ne());
  3567. })(ie, function(e) {
  3568. return function(t) {
  3569. var i = e, s = i.lib, n = s.WordArray, c = s.Hasher, o = i.algo, u = [];
  3570. (function() {
  3571. for (var l = 0; l < 64; l++)
  3572. u[l] = t.abs(t.sin(l + 1)) * 4294967296 | 0;
  3573. })();
  3574. var h = o.MD5 = c.extend({
  3575. _doReset: function() {
  3576. this._hash = new n.init([
  3577. 1732584193,
  3578. 4023233417,
  3579. 2562383102,
  3580. 271733878
  3581. ]);
  3582. },
  3583. _doProcessBlock: function(l, S) {
  3584. for (var v = 0; v < 16; v++) {
  3585. var x = S + v, b = l[x];
  3586. l[x] = (b << 8 | b >>> 24) & 16711935 | (b << 24 | b >>> 8) & 4278255360;
  3587. }
  3588. var E = this._hash.words, _ = l[S + 0], y = l[S + 1], A = l[S + 2], R = l[S + 3], M = l[S + 4], C = l[S + 5], I = l[S + 6], P = l[S + 7], B = l[S + 8], $ = l[S + 9], q = l[S + 10], X = l[S + 11], ae = l[S + 12], Q = l[S + 13], te = l[S + 14], ee = l[S + 15], k = E[0], L = E[1], F = E[2], N = E[3];
  3589. k = p(k, L, F, N, _, 7, u[0]), N = p(N, k, L, F, y, 12, u[1]), F = p(F, N, k, L, A, 17, u[2]), L = p(L, F, N, k, R, 22, u[3]), k = p(k, L, F, N, M, 7, u[4]), N = p(N, k, L, F, C, 12, u[5]), F = p(F, N, k, L, I, 17, u[6]), L = p(L, F, N, k, P, 22, u[7]), k = p(k, L, F, N, B, 7, u[8]), N = p(N, k, L, F, $, 12, u[9]), F = p(F, N, k, L, q, 17, u[10]), L = p(L, F, N, k, X, 22, u[11]), k = p(k, L, F, N, ae, 7, u[12]), N = p(N, k, L, F, Q, 12, u[13]), F = p(F, N, k, L, te, 17, u[14]), L = p(L, F, N, k, ee, 22, u[15]), k = d(k, L, F, N, y, 5, u[16]), N = d(N, k, L, F, I, 9, u[17]), F = d(F, N, k, L, X, 14, u[18]), L = d(L, F, N, k, _, 20, u[19]), k = d(k, L, F, N, C, 5, u[20]), N = d(N, k, L, F, q, 9, u[21]), F = d(F, N, k, L, ee, 14, u[22]), L = d(L, F, N, k, M, 20, u[23]), k = d(k, L, F, N, $, 5, u[24]), N = d(N, k, L, F, te, 9, u[25]), F = d(F, N, k, L, R, 14, u[26]), L = d(L, F, N, k, B, 20, u[27]), k = d(k, L, F, N, Q, 5, u[28]), N = d(N, k, L, F, A, 9, u[29]), F = d(F, N, k, L, P, 14, u[30]), L = d(L, F, N, k, ae, 20, u[31]), k = f(k, L, F, N, C, 4, u[32]), N = f(N, k, L, F, B, 11, u[33]), F = f(F, N, k, L, X, 16, u[34]), L = f(L, F, N, k, te, 23, u[35]), k = f(k, L, F, N, y, 4, u[36]), N = f(N, k, L, F, M, 11, u[37]), F = f(F, N, k, L, P, 16, u[38]), L = f(L, F, N, k, q, 23, u[39]), k = f(k, L, F, N, Q, 4, u[40]), N = f(N, k, L, F, _, 11, u[41]), F = f(F, N, k, L, R, 16, u[42]), L = f(L, F, N, k, I, 23, u[43]), k = f(k, L, F, N, $, 4, u[44]), N = f(N, k, L, F, ae, 11, u[45]), F = f(F, N, k, L, ee, 16, u[46]), L = f(L, F, N, k, A, 23, u[47]), k = m(k, L, F, N, _, 6, u[48]), N = m(N, k, L, F, P, 10, u[49]), F = m(F, N, k, L, te, 15, u[50]), L = m(L, F, N, k, C, 21, u[51]), k = m(k, L, F, N, ae, 6, u[52]), N = m(N, k, L, F, R, 10, u[53]), F = m(F, N, k, L, q, 15, u[54]), L = m(L, F, N, k, y, 21, u[55]), k = m(k, L, F, N, B, 6, u[56]), N = m(N, k, L, F, ee, 10, u[57]), F = m(F, N, k, L, I, 15, u[58]), L = m(L, F, N, k, Q, 21, u[59]), k = m(k, L, F, N, M, 6, u[60]), N = m(N, k, L, F, X, 10, u[61]), F = m(F, N, k, L, A, 15, u[62]), L = m(L, F, N, k, $, 21, u[63]), E[0] = E[0] + k | 0, E[1] = E[1] + L | 0, E[2] = E[2] + F | 0, E[3] = E[3] + N | 0;
  3590. },
  3591. _doFinalize: function() {
  3592. var l = this._data, S = l.words, v = this._nDataBytes * 8, x = l.sigBytes * 8;
  3593. S[x >>> 5] |= 128 << 24 - x % 32;
  3594. var b = t.floor(v / 4294967296), E = v;
  3595. S[(x + 64 >>> 9 << 4) + 15] = (b << 8 | b >>> 24) & 16711935 | (b << 24 | b >>> 8) & 4278255360, S[(x + 64 >>> 9 << 4) + 14] = (E << 8 | E >>> 24) & 16711935 | (E << 24 | E >>> 8) & 4278255360, l.sigBytes = (S.length + 1) * 4, this._process();
  3596. for (var _ = this._hash, y = _.words, A = 0; A < 4; A++) {
  3597. var R = y[A];
  3598. y[A] = (R << 8 | R >>> 24) & 16711935 | (R << 24 | R >>> 8) & 4278255360;
  3599. }
  3600. return _;
  3601. },
  3602. clone: function() {
  3603. var l = c.clone.call(this);
  3604. return l._hash = this._hash.clone(), l;
  3605. }
  3606. });
  3607. function p(l, S, v, x, b, E, _) {
  3608. var y = l + (S & v | ~S & x) + b + _;
  3609. return (y << E | y >>> 32 - E) + S;
  3610. }
  3611. function d(l, S, v, x, b, E, _) {
  3612. var y = l + (S & x | v & ~x) + b + _;
  3613. return (y << E | y >>> 32 - E) + S;
  3614. }
  3615. function f(l, S, v, x, b, E, _) {
  3616. var y = l + (S ^ v ^ x) + b + _;
  3617. return (y << E | y >>> 32 - E) + S;
  3618. }
  3619. function m(l, S, v, x, b, E, _) {
  3620. var y = l + (v ^ (S | ~x)) + b + _;
  3621. return (y << E | y >>> 32 - E) + S;
  3622. }
  3623. i.MD5 = c._createHelper(h), i.HmacMD5 = c._createHmacHelper(h);
  3624. }(Math), e.MD5;
  3625. });
  3626. }(rr)), rr.exports;
  3627. }
  3628. var sr = { exports: {} }, na;
  3629. function hn() {
  3630. return na || (na = 1, function(r, a) {
  3631. (function(e, t) {
  3632. r.exports = t(ne());
  3633. })(ie, function(e) {
  3634. return function() {
  3635. var t = e, i = t.lib, s = i.WordArray, n = i.Hasher, c = t.algo, o = [], u = c.SHA1 = n.extend({
  3636. _doReset: function() {
  3637. this._hash = new s.init([
  3638. 1732584193,
  3639. 4023233417,
  3640. 2562383102,
  3641. 271733878,
  3642. 3285377520
  3643. ]);
  3644. },
  3645. _doProcessBlock: function(h, p) {
  3646. for (var d = this._hash.words, f = d[0], m = d[1], l = d[2], S = d[3], v = d[4], x = 0; x < 80; x++) {
  3647. if (x < 16)
  3648. o[x] = h[p + x] | 0;
  3649. else {
  3650. var b = o[x - 3] ^ o[x - 8] ^ o[x - 14] ^ o[x - 16];
  3651. o[x] = b << 1 | b >>> 31;
  3652. }
  3653. var E = (f << 5 | f >>> 27) + v + o[x];
  3654. x < 20 ? E += (m & l | ~m & S) + 1518500249 : x < 40 ? E += (m ^ l ^ S) + 1859775393 : x < 60 ? E += (m & l | m & S | l & S) - 1894007588 : E += (m ^ l ^ S) - 899497514, v = S, S = l, l = m << 30 | m >>> 2, m = f, f = E;
  3655. }
  3656. d[0] = d[0] + f | 0, d[1] = d[1] + m | 0, d[2] = d[2] + l | 0, d[3] = d[3] + S | 0, d[4] = d[4] + v | 0;
  3657. },
  3658. _doFinalize: function() {
  3659. var h = this._data, p = h.words, d = this._nDataBytes * 8, f = h.sigBytes * 8;
  3660. return p[f >>> 5] |= 128 << 24 - f % 32, p[(f + 64 >>> 9 << 4) + 14] = Math.floor(d / 4294967296), p[(f + 64 >>> 9 << 4) + 15] = d, h.sigBytes = p.length * 4, this._process(), this._hash;
  3661. },
  3662. clone: function() {
  3663. var h = n.clone.call(this);
  3664. return h._hash = this._hash.clone(), h;
  3665. }
  3666. });
  3667. t.SHA1 = n._createHelper(u), t.HmacSHA1 = n._createHmacHelper(u);
  3668. }(), e.SHA1;
  3669. });
  3670. }(sr)), sr.exports;
  3671. }
  3672. var ar = { exports: {} }, oa;
  3673. function Xr() {
  3674. return oa || (oa = 1, function(r, a) {
  3675. (function(e, t) {
  3676. r.exports = t(ne());
  3677. })(ie, function(e) {
  3678. return function(t) {
  3679. var i = e, s = i.lib, n = s.WordArray, c = s.Hasher, o = i.algo, u = [], h = [];
  3680. (function() {
  3681. function f(v) {
  3682. for (var x = t.sqrt(v), b = 2; b <= x; b++)
  3683. if (!(v % b))
  3684. return !1;
  3685. return !0;
  3686. }
  3687. function m(v) {
  3688. return (v - (v | 0)) * 4294967296 | 0;
  3689. }
  3690. for (var l = 2, S = 0; S < 64; )
  3691. f(l) && (S < 8 && (u[S] = m(t.pow(l, 1 / 2))), h[S] = m(t.pow(l, 1 / 3)), S++), l++;
  3692. })();
  3693. var p = [], d = o.SHA256 = c.extend({
  3694. _doReset: function() {
  3695. this._hash = new n.init(u.slice(0));
  3696. },
  3697. _doProcessBlock: function(f, m) {
  3698. for (var l = this._hash.words, S = l[0], v = l[1], x = l[2], b = l[3], E = l[4], _ = l[5], y = l[6], A = l[7], R = 0; R < 64; R++) {
  3699. if (R < 16)
  3700. p[R] = f[m + R] | 0;
  3701. else {
  3702. var M = p[R - 15], C = (M << 25 | M >>> 7) ^ (M << 14 | M >>> 18) ^ M >>> 3, I = p[R - 2], P = (I << 15 | I >>> 17) ^ (I << 13 | I >>> 19) ^ I >>> 10;
  3703. p[R] = C + p[R - 7] + P + p[R - 16];
  3704. }
  3705. var B = E & _ ^ ~E & y, $ = S & v ^ S & x ^ v & x, q = (S << 30 | S >>> 2) ^ (S << 19 | S >>> 13) ^ (S << 10 | S >>> 22), X = (E << 26 | E >>> 6) ^ (E << 21 | E >>> 11) ^ (E << 7 | E >>> 25), ae = A + X + B + h[R] + p[R], Q = q + $;
  3706. A = y, y = _, _ = E, E = b + ae | 0, b = x, x = v, v = S, S = ae + Q | 0;
  3707. }
  3708. l[0] = l[0] + S | 0, l[1] = l[1] + v | 0, l[2] = l[2] + x | 0, l[3] = l[3] + b | 0, l[4] = l[4] + E | 0, l[5] = l[5] + _ | 0, l[6] = l[6] + y | 0, l[7] = l[7] + A | 0;
  3709. },
  3710. _doFinalize: function() {
  3711. var f = this._data, m = f.words, l = this._nDataBytes * 8, S = f.sigBytes * 8;
  3712. return m[S >>> 5] |= 128 << 24 - S % 32, m[(S + 64 >>> 9 << 4) + 14] = t.floor(l / 4294967296), m[(S + 64 >>> 9 << 4) + 15] = l, f.sigBytes = m.length * 4, this._process(), this._hash;
  3713. },
  3714. clone: function() {
  3715. var f = c.clone.call(this);
  3716. return f._hash = this._hash.clone(), f;
  3717. }
  3718. });
  3719. i.SHA256 = c._createHelper(d), i.HmacSHA256 = c._createHmacHelper(d);
  3720. }(Math), e.SHA256;
  3721. });
  3722. }(ar)), ar.exports;
  3723. }
  3724. var nr = { exports: {} }, ca;
  3725. function Ho() {
  3726. return ca || (ca = 1, function(r, a) {
  3727. (function(e, t, i) {
  3728. r.exports = t(ne(), Xr());
  3729. })(ie, function(e) {
  3730. return function() {
  3731. var t = e, i = t.lib, s = i.WordArray, n = t.algo, c = n.SHA256, o = n.SHA224 = c.extend({
  3732. _doReset: function() {
  3733. this._hash = new s.init([
  3734. 3238371032,
  3735. 914150663,
  3736. 812702999,
  3737. 4144912697,
  3738. 4290775857,
  3739. 1750603025,
  3740. 1694076839,
  3741. 3204075428
  3742. ]);
  3743. },
  3744. _doFinalize: function() {
  3745. var u = c._doFinalize.call(this);
  3746. return u.sigBytes -= 4, u;
  3747. }
  3748. });
  3749. t.SHA224 = c._createHelper(o), t.HmacSHA224 = c._createHmacHelper(o);
  3750. }(), e.SHA224;
  3751. });
  3752. }(nr)), nr.exports;
  3753. }
  3754. var or = { exports: {} }, ua;
  3755. function dn() {
  3756. return ua || (ua = 1, function(r, a) {
  3757. (function(e, t, i) {
  3758. r.exports = t(ne(), Ci());
  3759. })(ie, function(e) {
  3760. return function() {
  3761. var t = e, i = t.lib, s = i.Hasher, n = t.x64, c = n.Word, o = n.WordArray, u = t.algo;
  3762. function h() {
  3763. return c.create.apply(c, arguments);
  3764. }
  3765. var p = [
  3766. h(1116352408, 3609767458),
  3767. h(1899447441, 602891725),
  3768. h(3049323471, 3964484399),
  3769. h(3921009573, 2173295548),
  3770. h(961987163, 4081628472),
  3771. h(1508970993, 3053834265),
  3772. h(2453635748, 2937671579),
  3773. h(2870763221, 3664609560),
  3774. h(3624381080, 2734883394),
  3775. h(310598401, 1164996542),
  3776. h(607225278, 1323610764),
  3777. h(1426881987, 3590304994),
  3778. h(1925078388, 4068182383),
  3779. h(2162078206, 991336113),
  3780. h(2614888103, 633803317),
  3781. h(3248222580, 3479774868),
  3782. h(3835390401, 2666613458),
  3783. h(4022224774, 944711139),
  3784. h(264347078, 2341262773),
  3785. h(604807628, 2007800933),
  3786. h(770255983, 1495990901),
  3787. h(1249150122, 1856431235),
  3788. h(1555081692, 3175218132),
  3789. h(1996064986, 2198950837),
  3790. h(2554220882, 3999719339),
  3791. h(2821834349, 766784016),
  3792. h(2952996808, 2566594879),
  3793. h(3210313671, 3203337956),
  3794. h(3336571891, 1034457026),
  3795. h(3584528711, 2466948901),
  3796. h(113926993, 3758326383),
  3797. h(338241895, 168717936),
  3798. h(666307205, 1188179964),
  3799. h(773529912, 1546045734),
  3800. h(1294757372, 1522805485),
  3801. h(1396182291, 2643833823),
  3802. h(1695183700, 2343527390),
  3803. h(1986661051, 1014477480),
  3804. h(2177026350, 1206759142),
  3805. h(2456956037, 344077627),
  3806. h(2730485921, 1290863460),
  3807. h(2820302411, 3158454273),
  3808. h(3259730800, 3505952657),
  3809. h(3345764771, 106217008),
  3810. h(3516065817, 3606008344),
  3811. h(3600352804, 1432725776),
  3812. h(4094571909, 1467031594),
  3813. h(275423344, 851169720),
  3814. h(430227734, 3100823752),
  3815. h(506948616, 1363258195),
  3816. h(659060556, 3750685593),
  3817. h(883997877, 3785050280),
  3818. h(958139571, 3318307427),
  3819. h(1322822218, 3812723403),
  3820. h(1537002063, 2003034995),
  3821. h(1747873779, 3602036899),
  3822. h(1955562222, 1575990012),
  3823. h(2024104815, 1125592928),
  3824. h(2227730452, 2716904306),
  3825. h(2361852424, 442776044),
  3826. h(2428436474, 593698344),
  3827. h(2756734187, 3733110249),
  3828. h(3204031479, 2999351573),
  3829. h(3329325298, 3815920427),
  3830. h(3391569614, 3928383900),
  3831. h(3515267271, 566280711),
  3832. h(3940187606, 3454069534),
  3833. h(4118630271, 4000239992),
  3834. h(116418474, 1914138554),
  3835. h(174292421, 2731055270),
  3836. h(289380356, 3203993006),
  3837. h(460393269, 320620315),
  3838. h(685471733, 587496836),
  3839. h(852142971, 1086792851),
  3840. h(1017036298, 365543100),
  3841. h(1126000580, 2618297676),
  3842. h(1288033470, 3409855158),
  3843. h(1501505948, 4234509866),
  3844. h(1607167915, 987167468),
  3845. h(1816402316, 1246189591)
  3846. ], d = [];
  3847. (function() {
  3848. for (var m = 0; m < 80; m++)
  3849. d[m] = h();
  3850. })();
  3851. var f = u.SHA512 = s.extend({
  3852. _doReset: function() {
  3853. this._hash = new o.init([
  3854. new c.init(1779033703, 4089235720),
  3855. new c.init(3144134277, 2227873595),
  3856. new c.init(1013904242, 4271175723),
  3857. new c.init(2773480762, 1595750129),
  3858. new c.init(1359893119, 2917565137),
  3859. new c.init(2600822924, 725511199),
  3860. new c.init(528734635, 4215389547),
  3861. new c.init(1541459225, 327033209)
  3862. ]);
  3863. },
  3864. _doProcessBlock: function(m, l) {
  3865. for (var S = this._hash.words, v = S[0], x = S[1], b = S[2], E = S[3], _ = S[4], y = S[5], A = S[6], R = S[7], M = v.high, C = v.low, I = x.high, P = x.low, B = b.high, $ = b.low, q = E.high, X = E.low, ae = _.high, Q = _.low, te = y.high, ee = y.low, k = A.high, L = A.low, F = R.high, N = R.low, G = M, j = C, ce = I, Z = P, Ve = B, ze = $, Qe = q, et = X, xe = ae, ke = Q, ot = te, Ct = ee, Ht = k, Rt = L, Yt = F, It = N, Be = 0; Be < 80; Be++) {
  3866. var Re, tt, wt = d[Be];
  3867. if (Be < 16)
  3868. tt = wt.high = m[l + Be * 2] | 0, Re = wt.low = m[l + Be * 2 + 1] | 0;
  3869. else {
  3870. var gt = d[Be - 15], it = gt.high, ct = gt.low, ki = (it >>> 1 | ct << 31) ^ (it >>> 8 | ct << 24) ^ it >>> 7, ui = (ct >>> 1 | it << 31) ^ (ct >>> 8 | it << 24) ^ (ct >>> 7 | it << 25), hi = d[Be - 2], We = hi.high, mt = hi.low, di = (We >>> 19 | mt << 13) ^ (We << 3 | mt >>> 29) ^ We >>> 6, Zt = (mt >>> 19 | We << 13) ^ (mt << 3 | We >>> 29) ^ (mt >>> 6 | We << 26), us = d[Be - 7], Bn = us.high, Nn = us.low, hs = d[Be - 16], Mn = hs.high, ds = hs.low;
  3871. Re = ui + Nn, tt = ki + Bn + (Re >>> 0 < ui >>> 0 ? 1 : 0), Re = Re + Zt, tt = tt + di + (Re >>> 0 < Zt >>> 0 ? 1 : 0), Re = Re + ds, tt = tt + Mn + (Re >>> 0 < ds >>> 0 ? 1 : 0), wt.high = tt, wt.low = Re;
  3872. }
  3873. var Ln = xe & ot ^ ~xe & Ht, ls = ke & Ct ^ ~ke & Rt, Fn = G & ce ^ G & Ve ^ ce & Ve, Vn = j & Z ^ j & ze ^ Z & ze, On = (G >>> 28 | j << 4) ^ (G << 30 | j >>> 2) ^ (G << 25 | j >>> 7), fs = (j >>> 28 | G << 4) ^ (j << 30 | G >>> 2) ^ (j << 25 | G >>> 7), Un = (xe >>> 14 | ke << 18) ^ (xe >>> 18 | ke << 14) ^ (xe << 23 | ke >>> 9), Hn = (ke >>> 14 | xe << 18) ^ (ke >>> 18 | xe << 14) ^ (ke << 23 | xe >>> 9), ps = p[Be], jn = ps.high, gs = ps.low, $e = It + Hn, St = Yt + Un + ($e >>> 0 < It >>> 0 ? 1 : 0), $e = $e + ls, St = St + Ln + ($e >>> 0 < ls >>> 0 ? 1 : 0), $e = $e + gs, St = St + jn + ($e >>> 0 < gs >>> 0 ? 1 : 0), $e = $e + Re, St = St + tt + ($e >>> 0 < Re >>> 0 ? 1 : 0), ms = fs + Vn, zn = On + Fn + (ms >>> 0 < fs >>> 0 ? 1 : 0);
  3874. Yt = Ht, It = Rt, Ht = ot, Rt = Ct, ot = xe, Ct = ke, ke = et + $e | 0, xe = Qe + St + (ke >>> 0 < et >>> 0 ? 1 : 0) | 0, Qe = Ve, et = ze, Ve = ce, ze = Z, ce = G, Z = j, j = $e + ms | 0, G = St + zn + (j >>> 0 < $e >>> 0 ? 1 : 0) | 0;
  3875. }
  3876. C = v.low = C + j, v.high = M + G + (C >>> 0 < j >>> 0 ? 1 : 0), P = x.low = P + Z, x.high = I + ce + (P >>> 0 < Z >>> 0 ? 1 : 0), $ = b.low = $ + ze, b.high = B + Ve + ($ >>> 0 < ze >>> 0 ? 1 : 0), X = E.low = X + et, E.high = q + Qe + (X >>> 0 < et >>> 0 ? 1 : 0), Q = _.low = Q + ke, _.high = ae + xe + (Q >>> 0 < ke >>> 0 ? 1 : 0), ee = y.low = ee + Ct, y.high = te + ot + (ee >>> 0 < Ct >>> 0 ? 1 : 0), L = A.low = L + Rt, A.high = k + Ht + (L >>> 0 < Rt >>> 0 ? 1 : 0), N = R.low = N + It, R.high = F + Yt + (N >>> 0 < It >>> 0 ? 1 : 0);
  3877. },
  3878. _doFinalize: function() {
  3879. var m = this._data, l = m.words, S = this._nDataBytes * 8, v = m.sigBytes * 8;
  3880. l[v >>> 5] |= 128 << 24 - v % 32, l[(v + 128 >>> 10 << 5) + 30] = Math.floor(S / 4294967296), l[(v + 128 >>> 10 << 5) + 31] = S, m.sigBytes = l.length * 4, this._process();
  3881. var x = this._hash.toX32();
  3882. return x;
  3883. },
  3884. clone: function() {
  3885. var m = s.clone.call(this);
  3886. return m._hash = this._hash.clone(), m;
  3887. },
  3888. blockSize: 1024 / 32
  3889. });
  3890. t.SHA512 = s._createHelper(f), t.HmacSHA512 = s._createHmacHelper(f);
  3891. }(), e.SHA512;
  3892. });
  3893. }(or)), or.exports;
  3894. }
  3895. var cr = { exports: {} }, ha;
  3896. function jo() {
  3897. return ha || (ha = 1, function(r, a) {
  3898. (function(e, t, i) {
  3899. r.exports = t(ne(), Ci(), dn());
  3900. })(ie, function(e) {
  3901. return function() {
  3902. var t = e, i = t.x64, s = i.Word, n = i.WordArray, c = t.algo, o = c.SHA512, u = c.SHA384 = o.extend({
  3903. _doReset: function() {
  3904. this._hash = new n.init([
  3905. new s.init(3418070365, 3238371032),
  3906. new s.init(1654270250, 914150663),
  3907. new s.init(2438529370, 812702999),
  3908. new s.init(355462360, 4144912697),
  3909. new s.init(1731405415, 4290775857),
  3910. new s.init(2394180231, 1750603025),
  3911. new s.init(3675008525, 1694076839),
  3912. new s.init(1203062813, 3204075428)
  3913. ]);
  3914. },
  3915. _doFinalize: function() {
  3916. var h = o._doFinalize.call(this);
  3917. return h.sigBytes -= 16, h;
  3918. }
  3919. });
  3920. t.SHA384 = o._createHelper(u), t.HmacSHA384 = o._createHmacHelper(u);
  3921. }(), e.SHA384;
  3922. });
  3923. }(cr)), cr.exports;
  3924. }
  3925. var ur = { exports: {} }, da;
  3926. function zo() {
  3927. return da || (da = 1, function(r, a) {
  3928. (function(e, t, i) {
  3929. r.exports = t(ne(), Ci());
  3930. })(ie, function(e) {
  3931. return function(t) {
  3932. var i = e, s = i.lib, n = s.WordArray, c = s.Hasher, o = i.x64, u = o.Word, h = i.algo, p = [], d = [], f = [];
  3933. (function() {
  3934. for (var S = 1, v = 0, x = 0; x < 24; x++) {
  3935. p[S + 5 * v] = (x + 1) * (x + 2) / 2 % 64;
  3936. var b = v % 5, E = (2 * S + 3 * v) % 5;
  3937. S = b, v = E;
  3938. }
  3939. for (var S = 0; S < 5; S++)
  3940. for (var v = 0; v < 5; v++)
  3941. d[S + 5 * v] = v + (2 * S + 3 * v) % 5 * 5;
  3942. for (var _ = 1, y = 0; y < 24; y++) {
  3943. for (var A = 0, R = 0, M = 0; M < 7; M++) {
  3944. if (_ & 1) {
  3945. var C = (1 << M) - 1;
  3946. C < 32 ? R ^= 1 << C : A ^= 1 << C - 32;
  3947. }
  3948. _ & 128 ? _ = _ << 1 ^ 113 : _ <<= 1;
  3949. }
  3950. f[y] = u.create(A, R);
  3951. }
  3952. })();
  3953. var m = [];
  3954. (function() {
  3955. for (var S = 0; S < 25; S++)
  3956. m[S] = u.create();
  3957. })();
  3958. var l = h.SHA3 = c.extend({
  3959. /**
  3960. * Configuration options.
  3961. *
  3962. * @property {number} outputLength
  3963. * The desired number of bits in the output hash.
  3964. * Only values permitted are: 224, 256, 384, 512.
  3965. * Default: 512
  3966. */
  3967. cfg: c.cfg.extend({
  3968. outputLength: 512
  3969. }),
  3970. _doReset: function() {
  3971. for (var S = this._state = [], v = 0; v < 25; v++)
  3972. S[v] = new u.init();
  3973. this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32;
  3974. },
  3975. _doProcessBlock: function(S, v) {
  3976. for (var x = this._state, b = this.blockSize / 2, E = 0; E < b; E++) {
  3977. var _ = S[v + 2 * E], y = S[v + 2 * E + 1];
  3978. _ = (_ << 8 | _ >>> 24) & 16711935 | (_ << 24 | _ >>> 8) & 4278255360, y = (y << 8 | y >>> 24) & 16711935 | (y << 24 | y >>> 8) & 4278255360;
  3979. var A = x[E];
  3980. A.high ^= y, A.low ^= _;
  3981. }
  3982. for (var R = 0; R < 24; R++) {
  3983. for (var M = 0; M < 5; M++) {
  3984. for (var C = 0, I = 0, P = 0; P < 5; P++) {
  3985. var A = x[M + 5 * P];
  3986. C ^= A.high, I ^= A.low;
  3987. }
  3988. var B = m[M];
  3989. B.high = C, B.low = I;
  3990. }
  3991. for (var M = 0; M < 5; M++)
  3992. for (var $ = m[(M + 4) % 5], q = m[(M + 1) % 5], X = q.high, ae = q.low, C = $.high ^ (X << 1 | ae >>> 31), I = $.low ^ (ae << 1 | X >>> 31), P = 0; P < 5; P++) {
  3993. var A = x[M + 5 * P];
  3994. A.high ^= C, A.low ^= I;
  3995. }
  3996. for (var Q = 1; Q < 25; Q++) {
  3997. var C, I, A = x[Q], te = A.high, ee = A.low, k = p[Q];
  3998. k < 32 ? (C = te << k | ee >>> 32 - k, I = ee << k | te >>> 32 - k) : (C = ee << k - 32 | te >>> 64 - k, I = te << k - 32 | ee >>> 64 - k);
  3999. var L = m[d[Q]];
  4000. L.high = C, L.low = I;
  4001. }
  4002. var F = m[0], N = x[0];
  4003. F.high = N.high, F.low = N.low;
  4004. for (var M = 0; M < 5; M++)
  4005. for (var P = 0; P < 5; P++) {
  4006. var Q = M + 5 * P, A = x[Q], G = m[Q], j = m[(M + 1) % 5 + 5 * P], ce = m[(M + 2) % 5 + 5 * P];
  4007. A.high = G.high ^ ~j.high & ce.high, A.low = G.low ^ ~j.low & ce.low;
  4008. }
  4009. var A = x[0], Z = f[R];
  4010. A.high ^= Z.high, A.low ^= Z.low;
  4011. }
  4012. },
  4013. _doFinalize: function() {
  4014. var S = this._data, v = S.words;
  4015. this._nDataBytes * 8;
  4016. var x = S.sigBytes * 8, b = this.blockSize * 32;
  4017. v[x >>> 5] |= 1 << 24 - x % 32, v[(t.ceil((x + 1) / b) * b >>> 5) - 1] |= 128, S.sigBytes = v.length * 4, this._process();
  4018. for (var E = this._state, _ = this.cfg.outputLength / 8, y = _ / 8, A = [], R = 0; R < y; R++) {
  4019. var M = E[R], C = M.high, I = M.low;
  4020. C = (C << 8 | C >>> 24) & 16711935 | (C << 24 | C >>> 8) & 4278255360, I = (I << 8 | I >>> 24) & 16711935 | (I << 24 | I >>> 8) & 4278255360, A.push(I), A.push(C);
  4021. }
  4022. return new n.init(A, _);
  4023. },
  4024. clone: function() {
  4025. for (var S = c.clone.call(this), v = S._state = this._state.slice(0), x = 0; x < 25; x++)
  4026. v[x] = v[x].clone();
  4027. return S;
  4028. }
  4029. });
  4030. i.SHA3 = c._createHelper(l), i.HmacSHA3 = c._createHmacHelper(l);
  4031. }(Math), e.SHA3;
  4032. });
  4033. }(ur)), ur.exports;
  4034. }
  4035. var hr = { exports: {} }, la;
  4036. function Wo() {
  4037. return la || (la = 1, function(r, a) {
  4038. (function(e, t) {
  4039. r.exports = t(ne());
  4040. })(ie, function(e) {
  4041. /** @preserve
  4042. (c) 2012 by Cédric Mesnil. All rights reserved.
  4043. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  4044. - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  4045. - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  4046. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  4047. */
  4048. return function(t) {
  4049. var i = e, s = i.lib, n = s.WordArray, c = s.Hasher, o = i.algo, u = n.create([
  4050. 0,
  4051. 1,
  4052. 2,
  4053. 3,
  4054. 4,
  4055. 5,
  4056. 6,
  4057. 7,
  4058. 8,
  4059. 9,
  4060. 10,
  4061. 11,
  4062. 12,
  4063. 13,
  4064. 14,
  4065. 15,
  4066. 7,
  4067. 4,
  4068. 13,
  4069. 1,
  4070. 10,
  4071. 6,
  4072. 15,
  4073. 3,
  4074. 12,
  4075. 0,
  4076. 9,
  4077. 5,
  4078. 2,
  4079. 14,
  4080. 11,
  4081. 8,
  4082. 3,
  4083. 10,
  4084. 14,
  4085. 4,
  4086. 9,
  4087. 15,
  4088. 8,
  4089. 1,
  4090. 2,
  4091. 7,
  4092. 0,
  4093. 6,
  4094. 13,
  4095. 11,
  4096. 5,
  4097. 12,
  4098. 1,
  4099. 9,
  4100. 11,
  4101. 10,
  4102. 0,
  4103. 8,
  4104. 12,
  4105. 4,
  4106. 13,
  4107. 3,
  4108. 7,
  4109. 15,
  4110. 14,
  4111. 5,
  4112. 6,
  4113. 2,
  4114. 4,
  4115. 0,
  4116. 5,
  4117. 9,
  4118. 7,
  4119. 12,
  4120. 2,
  4121. 10,
  4122. 14,
  4123. 1,
  4124. 3,
  4125. 8,
  4126. 11,
  4127. 6,
  4128. 15,
  4129. 13
  4130. ]), h = n.create([
  4131. 5,
  4132. 14,
  4133. 7,
  4134. 0,
  4135. 9,
  4136. 2,
  4137. 11,
  4138. 4,
  4139. 13,
  4140. 6,
  4141. 15,
  4142. 8,
  4143. 1,
  4144. 10,
  4145. 3,
  4146. 12,
  4147. 6,
  4148. 11,
  4149. 3,
  4150. 7,
  4151. 0,
  4152. 13,
  4153. 5,
  4154. 10,
  4155. 14,
  4156. 15,
  4157. 8,
  4158. 12,
  4159. 4,
  4160. 9,
  4161. 1,
  4162. 2,
  4163. 15,
  4164. 5,
  4165. 1,
  4166. 3,
  4167. 7,
  4168. 14,
  4169. 6,
  4170. 9,
  4171. 11,
  4172. 8,
  4173. 12,
  4174. 2,
  4175. 10,
  4176. 0,
  4177. 4,
  4178. 13,
  4179. 8,
  4180. 6,
  4181. 4,
  4182. 1,
  4183. 3,
  4184. 11,
  4185. 15,
  4186. 0,
  4187. 5,
  4188. 12,
  4189. 2,
  4190. 13,
  4191. 9,
  4192. 7,
  4193. 10,
  4194. 14,
  4195. 12,
  4196. 15,
  4197. 10,
  4198. 4,
  4199. 1,
  4200. 5,
  4201. 8,
  4202. 7,
  4203. 6,
  4204. 2,
  4205. 13,
  4206. 14,
  4207. 0,
  4208. 3,
  4209. 9,
  4210. 11
  4211. ]), p = n.create([
  4212. 11,
  4213. 14,
  4214. 15,
  4215. 12,
  4216. 5,
  4217. 8,
  4218. 7,
  4219. 9,
  4220. 11,
  4221. 13,
  4222. 14,
  4223. 15,
  4224. 6,
  4225. 7,
  4226. 9,
  4227. 8,
  4228. 7,
  4229. 6,
  4230. 8,
  4231. 13,
  4232. 11,
  4233. 9,
  4234. 7,
  4235. 15,
  4236. 7,
  4237. 12,
  4238. 15,
  4239. 9,
  4240. 11,
  4241. 7,
  4242. 13,
  4243. 12,
  4244. 11,
  4245. 13,
  4246. 6,
  4247. 7,
  4248. 14,
  4249. 9,
  4250. 13,
  4251. 15,
  4252. 14,
  4253. 8,
  4254. 13,
  4255. 6,
  4256. 5,
  4257. 12,
  4258. 7,
  4259. 5,
  4260. 11,
  4261. 12,
  4262. 14,
  4263. 15,
  4264. 14,
  4265. 15,
  4266. 9,
  4267. 8,
  4268. 9,
  4269. 14,
  4270. 5,
  4271. 6,
  4272. 8,
  4273. 6,
  4274. 5,
  4275. 12,
  4276. 9,
  4277. 15,
  4278. 5,
  4279. 11,
  4280. 6,
  4281. 8,
  4282. 13,
  4283. 12,
  4284. 5,
  4285. 12,
  4286. 13,
  4287. 14,
  4288. 11,
  4289. 8,
  4290. 5,
  4291. 6
  4292. ]), d = n.create([
  4293. 8,
  4294. 9,
  4295. 9,
  4296. 11,
  4297. 13,
  4298. 15,
  4299. 15,
  4300. 5,
  4301. 7,
  4302. 7,
  4303. 8,
  4304. 11,
  4305. 14,
  4306. 14,
  4307. 12,
  4308. 6,
  4309. 9,
  4310. 13,
  4311. 15,
  4312. 7,
  4313. 12,
  4314. 8,
  4315. 9,
  4316. 11,
  4317. 7,
  4318. 7,
  4319. 12,
  4320. 7,
  4321. 6,
  4322. 15,
  4323. 13,
  4324. 11,
  4325. 9,
  4326. 7,
  4327. 15,
  4328. 11,
  4329. 8,
  4330. 6,
  4331. 6,
  4332. 14,
  4333. 12,
  4334. 13,
  4335. 5,
  4336. 14,
  4337. 13,
  4338. 13,
  4339. 7,
  4340. 5,
  4341. 15,
  4342. 5,
  4343. 8,
  4344. 11,
  4345. 14,
  4346. 14,
  4347. 6,
  4348. 14,
  4349. 6,
  4350. 9,
  4351. 12,
  4352. 9,
  4353. 12,
  4354. 5,
  4355. 15,
  4356. 8,
  4357. 8,
  4358. 5,
  4359. 12,
  4360. 9,
  4361. 12,
  4362. 5,
  4363. 14,
  4364. 6,
  4365. 8,
  4366. 13,
  4367. 6,
  4368. 5,
  4369. 15,
  4370. 13,
  4371. 11,
  4372. 11
  4373. ]), f = n.create([0, 1518500249, 1859775393, 2400959708, 2840853838]), m = n.create([1352829926, 1548603684, 1836072691, 2053994217, 0]), l = o.RIPEMD160 = c.extend({
  4374. _doReset: function() {
  4375. this._hash = n.create([1732584193, 4023233417, 2562383102, 271733878, 3285377520]);
  4376. },
  4377. _doProcessBlock: function(y, A) {
  4378. for (var R = 0; R < 16; R++) {
  4379. var M = A + R, C = y[M];
  4380. y[M] = (C << 8 | C >>> 24) & 16711935 | (C << 24 | C >>> 8) & 4278255360;
  4381. }
  4382. var I = this._hash.words, P = f.words, B = m.words, $ = u.words, q = h.words, X = p.words, ae = d.words, Q, te, ee, k, L, F, N, G, j, ce;
  4383. F = Q = I[0], N = te = I[1], G = ee = I[2], j = k = I[3], ce = L = I[4];
  4384. for (var Z, R = 0; R < 80; R += 1)
  4385. Z = Q + y[A + $[R]] | 0, R < 16 ? Z += S(te, ee, k) + P[0] : R < 32 ? Z += v(te, ee, k) + P[1] : R < 48 ? Z += x(te, ee, k) + P[2] : R < 64 ? Z += b(te, ee, k) + P[3] : Z += E(te, ee, k) + P[4], Z = Z | 0, Z = _(Z, X[R]), Z = Z + L | 0, Q = L, L = k, k = _(ee, 10), ee = te, te = Z, Z = F + y[A + q[R]] | 0, R < 16 ? Z += E(N, G, j) + B[0] : R < 32 ? Z += b(N, G, j) + B[1] : R < 48 ? Z += x(N, G, j) + B[2] : R < 64 ? Z += v(N, G, j) + B[3] : Z += S(N, G, j) + B[4], Z = Z | 0, Z = _(Z, ae[R]), Z = Z + ce | 0, F = ce, ce = j, j = _(G, 10), G = N, N = Z;
  4386. Z = I[1] + ee + j | 0, I[1] = I[2] + k + ce | 0, I[2] = I[3] + L + F | 0, I[3] = I[4] + Q + N | 0, I[4] = I[0] + te + G | 0, I[0] = Z;
  4387. },
  4388. _doFinalize: function() {
  4389. var y = this._data, A = y.words, R = this._nDataBytes * 8, M = y.sigBytes * 8;
  4390. A[M >>> 5] |= 128 << 24 - M % 32, A[(M + 64 >>> 9 << 4) + 14] = (R << 8 | R >>> 24) & 16711935 | (R << 24 | R >>> 8) & 4278255360, y.sigBytes = (A.length + 1) * 4, this._process();
  4391. for (var C = this._hash, I = C.words, P = 0; P < 5; P++) {
  4392. var B = I[P];
  4393. I[P] = (B << 8 | B >>> 24) & 16711935 | (B << 24 | B >>> 8) & 4278255360;
  4394. }
  4395. return C;
  4396. },
  4397. clone: function() {
  4398. var y = c.clone.call(this);
  4399. return y._hash = this._hash.clone(), y;
  4400. }
  4401. });
  4402. function S(y, A, R) {
  4403. return y ^ A ^ R;
  4404. }
  4405. function v(y, A, R) {
  4406. return y & A | ~y & R;
  4407. }
  4408. function x(y, A, R) {
  4409. return (y | ~A) ^ R;
  4410. }
  4411. function b(y, A, R) {
  4412. return y & R | A & ~R;
  4413. }
  4414. function E(y, A, R) {
  4415. return y ^ (A | ~R);
  4416. }
  4417. function _(y, A) {
  4418. return y << A | y >>> 32 - A;
  4419. }
  4420. i.RIPEMD160 = c._createHelper(l), i.HmacRIPEMD160 = c._createHmacHelper(l);
  4421. }(), e.RIPEMD160;
  4422. });
  4423. }(hr)), hr.exports;
  4424. }
  4425. var dr = { exports: {} }, fa;
  4426. function Yr() {
  4427. return fa || (fa = 1, function(r, a) {
  4428. (function(e, t) {
  4429. r.exports = t(ne());
  4430. })(ie, function(e) {
  4431. (function() {
  4432. var t = e, i = t.lib, s = i.Base, n = t.enc, c = n.Utf8, o = t.algo;
  4433. o.HMAC = s.extend({
  4434. /**
  4435. * Initializes a newly created HMAC.
  4436. *
  4437. * @param {Hasher} hasher The hash algorithm to use.
  4438. * @param {WordArray|string} key The secret key.
  4439. *
  4440. * @example
  4441. *
  4442. * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key);
  4443. */
  4444. init: function(u, h) {
  4445. u = this._hasher = new u.init(), typeof h == "string" && (h = c.parse(h));
  4446. var p = u.blockSize, d = p * 4;
  4447. h.sigBytes > d && (h = u.finalize(h)), h.clamp();
  4448. for (var f = this._oKey = h.clone(), m = this._iKey = h.clone(), l = f.words, S = m.words, v = 0; v < p; v++)
  4449. l[v] ^= 1549556828, S[v] ^= 909522486;
  4450. f.sigBytes = m.sigBytes = d, this.reset();
  4451. },
  4452. /**
  4453. * Resets this HMAC to its initial state.
  4454. *
  4455. * @example
  4456. *
  4457. * hmacHasher.reset();
  4458. */
  4459. reset: function() {
  4460. var u = this._hasher;
  4461. u.reset(), u.update(this._iKey);
  4462. },
  4463. /**
  4464. * Updates this HMAC with a message.
  4465. *
  4466. * @param {WordArray|string} messageUpdate The message to append.
  4467. *
  4468. * @return {HMAC} This HMAC instance.
  4469. *
  4470. * @example
  4471. *
  4472. * hmacHasher.update('message');
  4473. * hmacHasher.update(wordArray);
  4474. */
  4475. update: function(u) {
  4476. return this._hasher.update(u), this;
  4477. },
  4478. /**
  4479. * Finalizes the HMAC computation.
  4480. * Note that the finalize operation is effectively a destructive, read-once operation.
  4481. *
  4482. * @param {WordArray|string} messageUpdate (Optional) A final message update.
  4483. *
  4484. * @return {WordArray} The HMAC.
  4485. *
  4486. * @example
  4487. *
  4488. * var hmac = hmacHasher.finalize();
  4489. * var hmac = hmacHasher.finalize('message');
  4490. * var hmac = hmacHasher.finalize(wordArray);
  4491. */
  4492. finalize: function(u) {
  4493. var h = this._hasher, p = h.finalize(u);
  4494. h.reset();
  4495. var d = h.finalize(this._oKey.clone().concat(p));
  4496. return d;
  4497. }
  4498. });
  4499. })();
  4500. });
  4501. }(dr)), dr.exports;
  4502. }
  4503. var lr = { exports: {} }, pa;
  4504. function $o() {
  4505. return pa || (pa = 1, function(r, a) {
  4506. (function(e, t, i) {
  4507. r.exports = t(ne(), Xr(), Yr());
  4508. })(ie, function(e) {
  4509. return function() {
  4510. var t = e, i = t.lib, s = i.Base, n = i.WordArray, c = t.algo, o = c.SHA256, u = c.HMAC, h = c.PBKDF2 = s.extend({
  4511. /**
  4512. * Configuration options.
  4513. *
  4514. * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  4515. * @property {Hasher} hasher The hasher to use. Default: SHA256
  4516. * @property {number} iterations The number of iterations to perform. Default: 250000
  4517. */
  4518. cfg: s.extend({
  4519. keySize: 128 / 32,
  4520. hasher: o,
  4521. iterations: 25e4
  4522. }),
  4523. /**
  4524. * Initializes a newly created key derivation function.
  4525. *
  4526. * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  4527. *
  4528. * @example
  4529. *
  4530. * var kdf = CryptoJS.algo.PBKDF2.create();
  4531. * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 });
  4532. * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 });
  4533. */
  4534. init: function(p) {
  4535. this.cfg = this.cfg.extend(p);
  4536. },
  4537. /**
  4538. * Computes the Password-Based Key Derivation Function 2.
  4539. *
  4540. * @param {WordArray|string} password The password.
  4541. * @param {WordArray|string} salt A salt.
  4542. *
  4543. * @return {WordArray} The derived key.
  4544. *
  4545. * @example
  4546. *
  4547. * var key = kdf.compute(password, salt);
  4548. */
  4549. compute: function(p, d) {
  4550. for (var f = this.cfg, m = u.create(f.hasher, p), l = n.create(), S = n.create([1]), v = l.words, x = S.words, b = f.keySize, E = f.iterations; v.length < b; ) {
  4551. var _ = m.update(d).finalize(S);
  4552. m.reset();
  4553. for (var y = _.words, A = y.length, R = _, M = 1; M < E; M++) {
  4554. R = m.finalize(R), m.reset();
  4555. for (var C = R.words, I = 0; I < A; I++)
  4556. y[I] ^= C[I];
  4557. }
  4558. l.concat(_), x[0]++;
  4559. }
  4560. return l.sigBytes = b * 4, l;
  4561. }
  4562. });
  4563. t.PBKDF2 = function(p, d, f) {
  4564. return h.create(f).compute(p, d);
  4565. };
  4566. }(), e.PBKDF2;
  4567. });
  4568. }(lr)), lr.exports;
  4569. }
  4570. var fr = { exports: {} }, ga;
  4571. function yt() {
  4572. return ga || (ga = 1, function(r, a) {
  4573. (function(e, t, i) {
  4574. r.exports = t(ne(), hn(), Yr());
  4575. })(ie, function(e) {
  4576. return function() {
  4577. var t = e, i = t.lib, s = i.Base, n = i.WordArray, c = t.algo, o = c.MD5, u = c.EvpKDF = s.extend({
  4578. /**
  4579. * Configuration options.
  4580. *
  4581. * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
  4582. * @property {Hasher} hasher The hash algorithm to use. Default: MD5
  4583. * @property {number} iterations The number of iterations to perform. Default: 1
  4584. */
  4585. cfg: s.extend({
  4586. keySize: 128 / 32,
  4587. hasher: o,
  4588. iterations: 1
  4589. }),
  4590. /**
  4591. * Initializes a newly created key derivation function.
  4592. *
  4593. * @param {Object} cfg (Optional) The configuration options to use for the derivation.
  4594. *
  4595. * @example
  4596. *
  4597. * var kdf = CryptoJS.algo.EvpKDF.create();
  4598. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
  4599. * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
  4600. */
  4601. init: function(h) {
  4602. this.cfg = this.cfg.extend(h);
  4603. },
  4604. /**
  4605. * Derives a key from a password.
  4606. *
  4607. * @param {WordArray|string} password The password.
  4608. * @param {WordArray|string} salt A salt.
  4609. *
  4610. * @return {WordArray} The derived key.
  4611. *
  4612. * @example
  4613. *
  4614. * var key = kdf.compute(password, salt);
  4615. */
  4616. compute: function(h, p) {
  4617. for (var d, f = this.cfg, m = f.hasher.create(), l = n.create(), S = l.words, v = f.keySize, x = f.iterations; S.length < v; ) {
  4618. d && m.update(d), d = m.update(h).finalize(p), m.reset();
  4619. for (var b = 1; b < x; b++)
  4620. d = m.finalize(d), m.reset();
  4621. l.concat(d);
  4622. }
  4623. return l.sigBytes = v * 4, l;
  4624. }
  4625. });
  4626. t.EvpKDF = function(h, p, d) {
  4627. return u.create(d).compute(h, p);
  4628. };
  4629. }(), e.EvpKDF;
  4630. });
  4631. }(fr)), fr.exports;
  4632. }
  4633. var pr = { exports: {} }, ma;
  4634. function ye() {
  4635. return ma || (ma = 1, function(r, a) {
  4636. (function(e, t, i) {
  4637. r.exports = t(ne(), yt());
  4638. })(ie, function(e) {
  4639. e.lib.Cipher || function(t) {
  4640. var i = e, s = i.lib, n = s.Base, c = s.WordArray, o = s.BufferedBlockAlgorithm, u = i.enc;
  4641. u.Utf8;
  4642. var h = u.Base64, p = i.algo, d = p.EvpKDF, f = s.Cipher = o.extend({
  4643. /**
  4644. * Configuration options.
  4645. *
  4646. * @property {WordArray} iv The IV to use for this operation.
  4647. */
  4648. cfg: n.extend(),
  4649. /**
  4650. * Creates this cipher in encryption mode.
  4651. *
  4652. * @param {WordArray} key The key.
  4653. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  4654. *
  4655. * @return {Cipher} A cipher instance.
  4656. *
  4657. * @static
  4658. *
  4659. * @example
  4660. *
  4661. * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
  4662. */
  4663. createEncryptor: function(C, I) {
  4664. return this.create(this._ENC_XFORM_MODE, C, I);
  4665. },
  4666. /**
  4667. * Creates this cipher in decryption mode.
  4668. *
  4669. * @param {WordArray} key The key.
  4670. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  4671. *
  4672. * @return {Cipher} A cipher instance.
  4673. *
  4674. * @static
  4675. *
  4676. * @example
  4677. *
  4678. * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
  4679. */
  4680. createDecryptor: function(C, I) {
  4681. return this.create(this._DEC_XFORM_MODE, C, I);
  4682. },
  4683. /**
  4684. * Initializes a newly created cipher.
  4685. *
  4686. * @param {number} xformMode Either the encryption or decryption transormation mode constant.
  4687. * @param {WordArray} key The key.
  4688. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  4689. *
  4690. * @example
  4691. *
  4692. * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
  4693. */
  4694. init: function(C, I, P) {
  4695. this.cfg = this.cfg.extend(P), this._xformMode = C, this._key = I, this.reset();
  4696. },
  4697. /**
  4698. * Resets this cipher to its initial state.
  4699. *
  4700. * @example
  4701. *
  4702. * cipher.reset();
  4703. */
  4704. reset: function() {
  4705. o.reset.call(this), this._doReset();
  4706. },
  4707. /**
  4708. * Adds data to be encrypted or decrypted.
  4709. *
  4710. * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
  4711. *
  4712. * @return {WordArray} The data after processing.
  4713. *
  4714. * @example
  4715. *
  4716. * var encrypted = cipher.process('data');
  4717. * var encrypted = cipher.process(wordArray);
  4718. */
  4719. process: function(C) {
  4720. return this._append(C), this._process();
  4721. },
  4722. /**
  4723. * Finalizes the encryption or decryption process.
  4724. * Note that the finalize operation is effectively a destructive, read-once operation.
  4725. *
  4726. * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
  4727. *
  4728. * @return {WordArray} The data after final processing.
  4729. *
  4730. * @example
  4731. *
  4732. * var encrypted = cipher.finalize();
  4733. * var encrypted = cipher.finalize('data');
  4734. * var encrypted = cipher.finalize(wordArray);
  4735. */
  4736. finalize: function(C) {
  4737. C && this._append(C);
  4738. var I = this._doFinalize();
  4739. return I;
  4740. },
  4741. keySize: 128 / 32,
  4742. ivSize: 128 / 32,
  4743. _ENC_XFORM_MODE: 1,
  4744. _DEC_XFORM_MODE: 2,
  4745. /**
  4746. * Creates shortcut functions to a cipher's object interface.
  4747. *
  4748. * @param {Cipher} cipher The cipher to create a helper for.
  4749. *
  4750. * @return {Object} An object with encrypt and decrypt shortcut functions.
  4751. *
  4752. * @static
  4753. *
  4754. * @example
  4755. *
  4756. * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
  4757. */
  4758. _createHelper: function() {
  4759. function C(I) {
  4760. return typeof I == "string" ? M : y;
  4761. }
  4762. return function(I) {
  4763. return {
  4764. encrypt: function(P, B, $) {
  4765. return C(B).encrypt(I, P, B, $);
  4766. },
  4767. decrypt: function(P, B, $) {
  4768. return C(B).decrypt(I, P, B, $);
  4769. }
  4770. };
  4771. };
  4772. }()
  4773. });
  4774. s.StreamCipher = f.extend({
  4775. _doFinalize: function() {
  4776. var C = this._process(!0);
  4777. return C;
  4778. },
  4779. blockSize: 1
  4780. });
  4781. var m = i.mode = {}, l = s.BlockCipherMode = n.extend({
  4782. /**
  4783. * Creates this mode for encryption.
  4784. *
  4785. * @param {Cipher} cipher A block cipher instance.
  4786. * @param {Array} iv The IV words.
  4787. *
  4788. * @static
  4789. *
  4790. * @example
  4791. *
  4792. * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
  4793. */
  4794. createEncryptor: function(C, I) {
  4795. return this.Encryptor.create(C, I);
  4796. },
  4797. /**
  4798. * Creates this mode for decryption.
  4799. *
  4800. * @param {Cipher} cipher A block cipher instance.
  4801. * @param {Array} iv The IV words.
  4802. *
  4803. * @static
  4804. *
  4805. * @example
  4806. *
  4807. * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
  4808. */
  4809. createDecryptor: function(C, I) {
  4810. return this.Decryptor.create(C, I);
  4811. },
  4812. /**
  4813. * Initializes a newly created mode.
  4814. *
  4815. * @param {Cipher} cipher A block cipher instance.
  4816. * @param {Array} iv The IV words.
  4817. *
  4818. * @example
  4819. *
  4820. * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
  4821. */
  4822. init: function(C, I) {
  4823. this._cipher = C, this._iv = I;
  4824. }
  4825. }), S = m.CBC = function() {
  4826. var C = l.extend();
  4827. C.Encryptor = C.extend({
  4828. /**
  4829. * Processes the data block at offset.
  4830. *
  4831. * @param {Array} words The data words to operate on.
  4832. * @param {number} offset The offset where the block starts.
  4833. *
  4834. * @example
  4835. *
  4836. * mode.processBlock(data.words, offset);
  4837. */
  4838. processBlock: function(P, B) {
  4839. var $ = this._cipher, q = $.blockSize;
  4840. I.call(this, P, B, q), $.encryptBlock(P, B), this._prevBlock = P.slice(B, B + q);
  4841. }
  4842. }), C.Decryptor = C.extend({
  4843. /**
  4844. * Processes the data block at offset.
  4845. *
  4846. * @param {Array} words The data words to operate on.
  4847. * @param {number} offset The offset where the block starts.
  4848. *
  4849. * @example
  4850. *
  4851. * mode.processBlock(data.words, offset);
  4852. */
  4853. processBlock: function(P, B) {
  4854. var $ = this._cipher, q = $.blockSize, X = P.slice(B, B + q);
  4855. $.decryptBlock(P, B), I.call(this, P, B, q), this._prevBlock = X;
  4856. }
  4857. });
  4858. function I(P, B, $) {
  4859. var q, X = this._iv;
  4860. X ? (q = X, this._iv = t) : q = this._prevBlock;
  4861. for (var ae = 0; ae < $; ae++)
  4862. P[B + ae] ^= q[ae];
  4863. }
  4864. return C;
  4865. }(), v = i.pad = {}, x = v.Pkcs7 = {
  4866. /**
  4867. * Pads data using the algorithm defined in PKCS #5/7.
  4868. *
  4869. * @param {WordArray} data The data to pad.
  4870. * @param {number} blockSize The multiple that the data should be padded to.
  4871. *
  4872. * @static
  4873. *
  4874. * @example
  4875. *
  4876. * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
  4877. */
  4878. pad: function(C, I) {
  4879. for (var P = I * 4, B = P - C.sigBytes % P, $ = B << 24 | B << 16 | B << 8 | B, q = [], X = 0; X < B; X += 4)
  4880. q.push($);
  4881. var ae = c.create(q, B);
  4882. C.concat(ae);
  4883. },
  4884. /**
  4885. * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
  4886. *
  4887. * @param {WordArray} data The data to unpad.
  4888. *
  4889. * @static
  4890. *
  4891. * @example
  4892. *
  4893. * CryptoJS.pad.Pkcs7.unpad(wordArray);
  4894. */
  4895. unpad: function(C) {
  4896. var I = C.words[C.sigBytes - 1 >>> 2] & 255;
  4897. C.sigBytes -= I;
  4898. }
  4899. };
  4900. s.BlockCipher = f.extend({
  4901. /**
  4902. * Configuration options.
  4903. *
  4904. * @property {Mode} mode The block mode to use. Default: CBC
  4905. * @property {Padding} padding The padding strategy to use. Default: Pkcs7
  4906. */
  4907. cfg: f.cfg.extend({
  4908. mode: S,
  4909. padding: x
  4910. }),
  4911. reset: function() {
  4912. var C;
  4913. f.reset.call(this);
  4914. var I = this.cfg, P = I.iv, B = I.mode;
  4915. this._xformMode == this._ENC_XFORM_MODE ? C = B.createEncryptor : (C = B.createDecryptor, this._minBufferSize = 1), this._mode && this._mode.__creator == C ? this._mode.init(this, P && P.words) : (this._mode = C.call(B, this, P && P.words), this._mode.__creator = C);
  4916. },
  4917. _doProcessBlock: function(C, I) {
  4918. this._mode.processBlock(C, I);
  4919. },
  4920. _doFinalize: function() {
  4921. var C, I = this.cfg.padding;
  4922. return this._xformMode == this._ENC_XFORM_MODE ? (I.pad(this._data, this.blockSize), C = this._process(!0)) : (C = this._process(!0), I.unpad(C)), C;
  4923. },
  4924. blockSize: 128 / 32
  4925. });
  4926. var b = s.CipherParams = n.extend({
  4927. /**
  4928. * Initializes a newly created cipher params object.
  4929. *
  4930. * @param {Object} cipherParams An object with any of the possible cipher parameters.
  4931. *
  4932. * @example
  4933. *
  4934. * var cipherParams = CryptoJS.lib.CipherParams.create({
  4935. * ciphertext: ciphertextWordArray,
  4936. * key: keyWordArray,
  4937. * iv: ivWordArray,
  4938. * salt: saltWordArray,
  4939. * algorithm: CryptoJS.algo.AES,
  4940. * mode: CryptoJS.mode.CBC,
  4941. * padding: CryptoJS.pad.PKCS7,
  4942. * blockSize: 4,
  4943. * formatter: CryptoJS.format.OpenSSL
  4944. * });
  4945. */
  4946. init: function(C) {
  4947. this.mixIn(C);
  4948. },
  4949. /**
  4950. * Converts this cipher params object to a string.
  4951. *
  4952. * @param {Format} formatter (Optional) The formatting strategy to use.
  4953. *
  4954. * @return {string} The stringified cipher params.
  4955. *
  4956. * @throws Error If neither the formatter nor the default formatter is set.
  4957. *
  4958. * @example
  4959. *
  4960. * var string = cipherParams + '';
  4961. * var string = cipherParams.toString();
  4962. * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
  4963. */
  4964. toString: function(C) {
  4965. return (C || this.formatter).stringify(this);
  4966. }
  4967. }), E = i.format = {}, _ = E.OpenSSL = {
  4968. /**
  4969. * Converts a cipher params object to an OpenSSL-compatible string.
  4970. *
  4971. * @param {CipherParams} cipherParams The cipher params object.
  4972. *
  4973. * @return {string} The OpenSSL-compatible string.
  4974. *
  4975. * @static
  4976. *
  4977. * @example
  4978. *
  4979. * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
  4980. */
  4981. stringify: function(C) {
  4982. var I, P = C.ciphertext, B = C.salt;
  4983. return B ? I = c.create([1398893684, 1701076831]).concat(B).concat(P) : I = P, I.toString(h);
  4984. },
  4985. /**
  4986. * Converts an OpenSSL-compatible string to a cipher params object.
  4987. *
  4988. * @param {string} openSSLStr The OpenSSL-compatible string.
  4989. *
  4990. * @return {CipherParams} The cipher params object.
  4991. *
  4992. * @static
  4993. *
  4994. * @example
  4995. *
  4996. * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
  4997. */
  4998. parse: function(C) {
  4999. var I, P = h.parse(C), B = P.words;
  5000. return B[0] == 1398893684 && B[1] == 1701076831 && (I = c.create(B.slice(2, 4)), B.splice(0, 4), P.sigBytes -= 16), b.create({ ciphertext: P, salt: I });
  5001. }
  5002. }, y = s.SerializableCipher = n.extend({
  5003. /**
  5004. * Configuration options.
  5005. *
  5006. * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
  5007. */
  5008. cfg: n.extend({
  5009. format: _
  5010. }),
  5011. /**
  5012. * Encrypts a message.
  5013. *
  5014. * @param {Cipher} cipher The cipher algorithm to use.
  5015. * @param {WordArray|string} message The message to encrypt.
  5016. * @param {WordArray} key The key.
  5017. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  5018. *
  5019. * @return {CipherParams} A cipher params object.
  5020. *
  5021. * @static
  5022. *
  5023. * @example
  5024. *
  5025. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
  5026. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
  5027. * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  5028. */
  5029. encrypt: function(C, I, P, B) {
  5030. B = this.cfg.extend(B);
  5031. var $ = C.createEncryptor(P, B), q = $.finalize(I), X = $.cfg;
  5032. return b.create({
  5033. ciphertext: q,
  5034. key: P,
  5035. iv: X.iv,
  5036. algorithm: C,
  5037. mode: X.mode,
  5038. padding: X.padding,
  5039. blockSize: C.blockSize,
  5040. formatter: B.format
  5041. });
  5042. },
  5043. /**
  5044. * Decrypts serialized ciphertext.
  5045. *
  5046. * @param {Cipher} cipher The cipher algorithm to use.
  5047. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  5048. * @param {WordArray} key The key.
  5049. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  5050. *
  5051. * @return {WordArray} The plaintext.
  5052. *
  5053. * @static
  5054. *
  5055. * @example
  5056. *
  5057. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  5058. * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
  5059. */
  5060. decrypt: function(C, I, P, B) {
  5061. B = this.cfg.extend(B), I = this._parse(I, B.format);
  5062. var $ = C.createDecryptor(P, B).finalize(I.ciphertext);
  5063. return $;
  5064. },
  5065. /**
  5066. * Converts serialized ciphertext to CipherParams,
  5067. * else assumed CipherParams already and returns ciphertext unchanged.
  5068. *
  5069. * @param {CipherParams|string} ciphertext The ciphertext.
  5070. * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
  5071. *
  5072. * @return {CipherParams} The unserialized ciphertext.
  5073. *
  5074. * @static
  5075. *
  5076. * @example
  5077. *
  5078. * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
  5079. */
  5080. _parse: function(C, I) {
  5081. return typeof C == "string" ? I.parse(C, this) : C;
  5082. }
  5083. }), A = i.kdf = {}, R = A.OpenSSL = {
  5084. /**
  5085. * Derives a key and IV from a password.
  5086. *
  5087. * @param {string} password The password to derive from.
  5088. * @param {number} keySize The size in words of the key to generate.
  5089. * @param {number} ivSize The size in words of the IV to generate.
  5090. * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
  5091. *
  5092. * @return {CipherParams} A cipher params object with the key, IV, and salt.
  5093. *
  5094. * @static
  5095. *
  5096. * @example
  5097. *
  5098. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
  5099. * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
  5100. */
  5101. execute: function(C, I, P, B, $) {
  5102. if (B || (B = c.random(64 / 8)), $)
  5103. var q = d.create({ keySize: I + P, hasher: $ }).compute(C, B);
  5104. else
  5105. var q = d.create({ keySize: I + P }).compute(C, B);
  5106. var X = c.create(q.words.slice(I), P * 4);
  5107. return q.sigBytes = I * 4, b.create({ key: q, iv: X, salt: B });
  5108. }
  5109. }, M = s.PasswordBasedCipher = y.extend({
  5110. /**
  5111. * Configuration options.
  5112. *
  5113. * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
  5114. */
  5115. cfg: y.cfg.extend({
  5116. kdf: R
  5117. }),
  5118. /**
  5119. * Encrypts a message using a password.
  5120. *
  5121. * @param {Cipher} cipher The cipher algorithm to use.
  5122. * @param {WordArray|string} message The message to encrypt.
  5123. * @param {string} password The password.
  5124. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  5125. *
  5126. * @return {CipherParams} A cipher params object.
  5127. *
  5128. * @static
  5129. *
  5130. * @example
  5131. *
  5132. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
  5133. * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
  5134. */
  5135. encrypt: function(C, I, P, B) {
  5136. B = this.cfg.extend(B);
  5137. var $ = B.kdf.execute(P, C.keySize, C.ivSize, B.salt, B.hasher);
  5138. B.iv = $.iv;
  5139. var q = y.encrypt.call(this, C, I, $.key, B);
  5140. return q.mixIn($), q;
  5141. },
  5142. /**
  5143. * Decrypts serialized ciphertext using a password.
  5144. *
  5145. * @param {Cipher} cipher The cipher algorithm to use.
  5146. * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
  5147. * @param {string} password The password.
  5148. * @param {Object} cfg (Optional) The configuration options to use for this operation.
  5149. *
  5150. * @return {WordArray} The plaintext.
  5151. *
  5152. * @static
  5153. *
  5154. * @example
  5155. *
  5156. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
  5157. * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
  5158. */
  5159. decrypt: function(C, I, P, B) {
  5160. B = this.cfg.extend(B), I = this._parse(I, B.format);
  5161. var $ = B.kdf.execute(P, C.keySize, C.ivSize, I.salt, B.hasher);
  5162. B.iv = $.iv;
  5163. var q = y.decrypt.call(this, C, I, $.key, B);
  5164. return q;
  5165. }
  5166. });
  5167. }();
  5168. });
  5169. }(pr)), pr.exports;
  5170. }
  5171. var gr = { exports: {} }, Sa;
  5172. function Ko() {
  5173. return Sa || (Sa = 1, function(r, a) {
  5174. (function(e, t, i) {
  5175. r.exports = t(ne(), ye());
  5176. })(ie, function(e) {
  5177. return e.mode.CFB = function() {
  5178. var t = e.lib.BlockCipherMode.extend();
  5179. t.Encryptor = t.extend({
  5180. processBlock: function(s, n) {
  5181. var c = this._cipher, o = c.blockSize;
  5182. i.call(this, s, n, o, c), this._prevBlock = s.slice(n, n + o);
  5183. }
  5184. }), t.Decryptor = t.extend({
  5185. processBlock: function(s, n) {
  5186. var c = this._cipher, o = c.blockSize, u = s.slice(n, n + o);
  5187. i.call(this, s, n, o, c), this._prevBlock = u;
  5188. }
  5189. });
  5190. function i(s, n, c, o) {
  5191. var u, h = this._iv;
  5192. h ? (u = h.slice(0), this._iv = void 0) : u = this._prevBlock, o.encryptBlock(u, 0);
  5193. for (var p = 0; p < c; p++)
  5194. s[n + p] ^= u[p];
  5195. }
  5196. return t;
  5197. }(), e.mode.CFB;
  5198. });
  5199. }(gr)), gr.exports;
  5200. }
  5201. var mr = { exports: {} }, xa;
  5202. function qo() {
  5203. return xa || (xa = 1, function(r, a) {
  5204. (function(e, t, i) {
  5205. r.exports = t(ne(), ye());
  5206. })(ie, function(e) {
  5207. return e.mode.CTR = function() {
  5208. var t = e.lib.BlockCipherMode.extend(), i = t.Encryptor = t.extend({
  5209. processBlock: function(s, n) {
  5210. var c = this._cipher, o = c.blockSize, u = this._iv, h = this._counter;
  5211. u && (h = this._counter = u.slice(0), this._iv = void 0);
  5212. var p = h.slice(0);
  5213. c.encryptBlock(p, 0), h[o - 1] = h[o - 1] + 1 | 0;
  5214. for (var d = 0; d < o; d++)
  5215. s[n + d] ^= p[d];
  5216. }
  5217. });
  5218. return t.Decryptor = i, t;
  5219. }(), e.mode.CTR;
  5220. });
  5221. }(mr)), mr.exports;
  5222. }
  5223. var Sr = { exports: {} }, va;
  5224. function Jo() {
  5225. return va || (va = 1, function(r, a) {
  5226. (function(e, t, i) {
  5227. r.exports = t(ne(), ye());
  5228. })(ie, function(e) {
  5229. /** @preserve
  5230. * Counter block mode compatible with Dr Brian Gladman fileenc.c
  5231. * derived from CryptoJS.mode.CTR
  5232. * Jan Hruby jhruby.web@gmail.com
  5233. */
  5234. return e.mode.CTRGladman = function() {
  5235. var t = e.lib.BlockCipherMode.extend();
  5236. function i(c) {
  5237. if ((c >> 24 & 255) === 255) {
  5238. var o = c >> 16 & 255, u = c >> 8 & 255, h = c & 255;
  5239. o === 255 ? (o = 0, u === 255 ? (u = 0, h === 255 ? h = 0 : ++h) : ++u) : ++o, c = 0, c += o << 16, c += u << 8, c += h;
  5240. } else
  5241. c += 1 << 24;
  5242. return c;
  5243. }
  5244. function s(c) {
  5245. return (c[0] = i(c[0])) === 0 && (c[1] = i(c[1])), c;
  5246. }
  5247. var n = t.Encryptor = t.extend({
  5248. processBlock: function(c, o) {
  5249. var u = this._cipher, h = u.blockSize, p = this._iv, d = this._counter;
  5250. p && (d = this._counter = p.slice(0), this._iv = void 0), s(d);
  5251. var f = d.slice(0);
  5252. u.encryptBlock(f, 0);
  5253. for (var m = 0; m < h; m++)
  5254. c[o + m] ^= f[m];
  5255. }
  5256. });
  5257. return t.Decryptor = n, t;
  5258. }(), e.mode.CTRGladman;
  5259. });
  5260. }(Sr)), Sr.exports;
  5261. }
  5262. var xr = { exports: {} }, ba;
  5263. function Go() {
  5264. return ba || (ba = 1, function(r, a) {
  5265. (function(e, t, i) {
  5266. r.exports = t(ne(), ye());
  5267. })(ie, function(e) {
  5268. return e.mode.OFB = function() {
  5269. var t = e.lib.BlockCipherMode.extend(), i = t.Encryptor = t.extend({
  5270. processBlock: function(s, n) {
  5271. var c = this._cipher, o = c.blockSize, u = this._iv, h = this._keystream;
  5272. u && (h = this._keystream = u.slice(0), this._iv = void 0), c.encryptBlock(h, 0);
  5273. for (var p = 0; p < o; p++)
  5274. s[n + p] ^= h[p];
  5275. }
  5276. });
  5277. return t.Decryptor = i, t;
  5278. }(), e.mode.OFB;
  5279. });
  5280. }(xr)), xr.exports;
  5281. }
  5282. var vr = { exports: {} }, Ea;
  5283. function Xo() {
  5284. return Ea || (Ea = 1, function(r, a) {
  5285. (function(e, t, i) {
  5286. r.exports = t(ne(), ye());
  5287. })(ie, function(e) {
  5288. return e.mode.ECB = function() {
  5289. var t = e.lib.BlockCipherMode.extend();
  5290. return t.Encryptor = t.extend({
  5291. processBlock: function(i, s) {
  5292. this._cipher.encryptBlock(i, s);
  5293. }
  5294. }), t.Decryptor = t.extend({
  5295. processBlock: function(i, s) {
  5296. this._cipher.decryptBlock(i, s);
  5297. }
  5298. }), t;
  5299. }(), e.mode.ECB;
  5300. });
  5301. }(vr)), vr.exports;
  5302. }
  5303. var br = { exports: {} }, _a;
  5304. function Yo() {
  5305. return _a || (_a = 1, function(r, a) {
  5306. (function(e, t, i) {
  5307. r.exports = t(ne(), ye());
  5308. })(ie, function(e) {
  5309. return e.pad.AnsiX923 = {
  5310. pad: function(t, i) {
  5311. var s = t.sigBytes, n = i * 4, c = n - s % n, o = s + c - 1;
  5312. t.clamp(), t.words[o >>> 2] |= c << 24 - o % 4 * 8, t.sigBytes += c;
  5313. },
  5314. unpad: function(t) {
  5315. var i = t.words[t.sigBytes - 1 >>> 2] & 255;
  5316. t.sigBytes -= i;
  5317. }
  5318. }, e.pad.Ansix923;
  5319. });
  5320. }(br)), br.exports;
  5321. }
  5322. var Er = { exports: {} }, Aa;
  5323. function Zo() {
  5324. return Aa || (Aa = 1, function(r, a) {
  5325. (function(e, t, i) {
  5326. r.exports = t(ne(), ye());
  5327. })(ie, function(e) {
  5328. return e.pad.Iso10126 = {
  5329. pad: function(t, i) {
  5330. var s = i * 4, n = s - t.sigBytes % s;
  5331. t.concat(e.lib.WordArray.random(n - 1)).concat(e.lib.WordArray.create([n << 24], 1));
  5332. },
  5333. unpad: function(t) {
  5334. var i = t.words[t.sigBytes - 1 >>> 2] & 255;
  5335. t.sigBytes -= i;
  5336. }
  5337. }, e.pad.Iso10126;
  5338. });
  5339. }(Er)), Er.exports;
  5340. }
  5341. var _r = { exports: {} }, ya;
  5342. function Qo() {
  5343. return ya || (ya = 1, function(r, a) {
  5344. (function(e, t, i) {
  5345. r.exports = t(ne(), ye());
  5346. })(ie, function(e) {
  5347. return e.pad.Iso97971 = {
  5348. pad: function(t, i) {
  5349. t.concat(e.lib.WordArray.create([2147483648], 1)), e.pad.ZeroPadding.pad(t, i);
  5350. },
  5351. unpad: function(t) {
  5352. e.pad.ZeroPadding.unpad(t), t.sigBytes--;
  5353. }
  5354. }, e.pad.Iso97971;
  5355. });
  5356. }(_r)), _r.exports;
  5357. }
  5358. var Ar = { exports: {} }, Ca;
  5359. function e0() {
  5360. return Ca || (Ca = 1, function(r, a) {
  5361. (function(e, t, i) {
  5362. r.exports = t(ne(), ye());
  5363. })(ie, function(e) {
  5364. return e.pad.ZeroPadding = {
  5365. pad: function(t, i) {
  5366. var s = i * 4;
  5367. t.clamp(), t.sigBytes += s - (t.sigBytes % s || s);
  5368. },
  5369. unpad: function(t) {
  5370. for (var i = t.words, s = t.sigBytes - 1, s = t.sigBytes - 1; s >= 0; s--)
  5371. if (i[s >>> 2] >>> 24 - s % 4 * 8 & 255) {
  5372. t.sigBytes = s + 1;
  5373. break;
  5374. }
  5375. }
  5376. }, e.pad.ZeroPadding;
  5377. });
  5378. }(Ar)), Ar.exports;
  5379. }
  5380. var yr = { exports: {} }, Ra;
  5381. function t0() {
  5382. return Ra || (Ra = 1, function(r, a) {
  5383. (function(e, t, i) {
  5384. r.exports = t(ne(), ye());
  5385. })(ie, function(e) {
  5386. return e.pad.NoPadding = {
  5387. pad: function() {
  5388. },
  5389. unpad: function() {
  5390. }
  5391. }, e.pad.NoPadding;
  5392. });
  5393. }(yr)), yr.exports;
  5394. }
  5395. var Cr = { exports: {} }, Ia;
  5396. function i0() {
  5397. return Ia || (Ia = 1, function(r, a) {
  5398. (function(e, t, i) {
  5399. r.exports = t(ne(), ye());
  5400. })(ie, function(e) {
  5401. return function(t) {
  5402. var i = e, s = i.lib, n = s.CipherParams, c = i.enc, o = c.Hex, u = i.format;
  5403. u.Hex = {
  5404. /**
  5405. * Converts the ciphertext of a cipher params object to a hexadecimally encoded string.
  5406. *
  5407. * @param {CipherParams} cipherParams The cipher params object.
  5408. *
  5409. * @return {string} The hexadecimally encoded string.
  5410. *
  5411. * @static
  5412. *
  5413. * @example
  5414. *
  5415. * var hexString = CryptoJS.format.Hex.stringify(cipherParams);
  5416. */
  5417. stringify: function(h) {
  5418. return h.ciphertext.toString(o);
  5419. },
  5420. /**
  5421. * Converts a hexadecimally encoded ciphertext string to a cipher params object.
  5422. *
  5423. * @param {string} input The hexadecimally encoded string.
  5424. *
  5425. * @return {CipherParams} The cipher params object.
  5426. *
  5427. * @static
  5428. *
  5429. * @example
  5430. *
  5431. * var cipherParams = CryptoJS.format.Hex.parse(hexString);
  5432. */
  5433. parse: function(h) {
  5434. var p = o.parse(h);
  5435. return n.create({ ciphertext: p });
  5436. }
  5437. };
  5438. }(), e.format.Hex;
  5439. });
  5440. }(Cr)), Cr.exports;
  5441. }
  5442. var Rr = { exports: {} }, wa;
  5443. function r0() {
  5444. return wa || (wa = 1, function(r, a) {
  5445. (function(e, t, i) {
  5446. r.exports = t(ne(), Ot(), Ut(), yt(), ye());
  5447. })(ie, function(e) {
  5448. return function() {
  5449. var t = e, i = t.lib, s = i.BlockCipher, n = t.algo, c = [], o = [], u = [], h = [], p = [], d = [], f = [], m = [], l = [], S = [];
  5450. (function() {
  5451. for (var b = [], E = 0; E < 256; E++)
  5452. E < 128 ? b[E] = E << 1 : b[E] = E << 1 ^ 283;
  5453. for (var _ = 0, y = 0, E = 0; E < 256; E++) {
  5454. var A = y ^ y << 1 ^ y << 2 ^ y << 3 ^ y << 4;
  5455. A = A >>> 8 ^ A & 255 ^ 99, c[_] = A, o[A] = _;
  5456. var R = b[_], M = b[R], C = b[M], I = b[A] * 257 ^ A * 16843008;
  5457. u[_] = I << 24 | I >>> 8, h[_] = I << 16 | I >>> 16, p[_] = I << 8 | I >>> 24, d[_] = I;
  5458. var I = C * 16843009 ^ M * 65537 ^ R * 257 ^ _ * 16843008;
  5459. f[A] = I << 24 | I >>> 8, m[A] = I << 16 | I >>> 16, l[A] = I << 8 | I >>> 24, S[A] = I, _ ? (_ = R ^ b[b[b[C ^ R]]], y ^= b[b[y]]) : _ = y = 1;
  5460. }
  5461. })();
  5462. var v = [0, 1, 2, 4, 8, 16, 32, 64, 128, 27, 54], x = n.AES = s.extend({
  5463. _doReset: function() {
  5464. var b;
  5465. if (!(this._nRounds && this._keyPriorReset === this._key)) {
  5466. for (var E = this._keyPriorReset = this._key, _ = E.words, y = E.sigBytes / 4, A = this._nRounds = y + 6, R = (A + 1) * 4, M = this._keySchedule = [], C = 0; C < R; C++)
  5467. C < y ? M[C] = _[C] : (b = M[C - 1], C % y ? y > 6 && C % y == 4 && (b = c[b >>> 24] << 24 | c[b >>> 16 & 255] << 16 | c[b >>> 8 & 255] << 8 | c[b & 255]) : (b = b << 8 | b >>> 24, b = c[b >>> 24] << 24 | c[b >>> 16 & 255] << 16 | c[b >>> 8 & 255] << 8 | c[b & 255], b ^= v[C / y | 0] << 24), M[C] = M[C - y] ^ b);
  5468. for (var I = this._invKeySchedule = [], P = 0; P < R; P++) {
  5469. var C = R - P;
  5470. if (P % 4)
  5471. var b = M[C];
  5472. else
  5473. var b = M[C - 4];
  5474. P < 4 || C <= 4 ? I[P] = b : I[P] = f[c[b >>> 24]] ^ m[c[b >>> 16 & 255]] ^ l[c[b >>> 8 & 255]] ^ S[c[b & 255]];
  5475. }
  5476. }
  5477. },
  5478. encryptBlock: function(b, E) {
  5479. this._doCryptBlock(b, E, this._keySchedule, u, h, p, d, c);
  5480. },
  5481. decryptBlock: function(b, E) {
  5482. var _ = b[E + 1];
  5483. b[E + 1] = b[E + 3], b[E + 3] = _, this._doCryptBlock(b, E, this._invKeySchedule, f, m, l, S, o);
  5484. var _ = b[E + 1];
  5485. b[E + 1] = b[E + 3], b[E + 3] = _;
  5486. },
  5487. _doCryptBlock: function(b, E, _, y, A, R, M, C) {
  5488. for (var I = this._nRounds, P = b[E] ^ _[0], B = b[E + 1] ^ _[1], $ = b[E + 2] ^ _[2], q = b[E + 3] ^ _[3], X = 4, ae = 1; ae < I; ae++) {
  5489. var Q = y[P >>> 24] ^ A[B >>> 16 & 255] ^ R[$ >>> 8 & 255] ^ M[q & 255] ^ _[X++], te = y[B >>> 24] ^ A[$ >>> 16 & 255] ^ R[q >>> 8 & 255] ^ M[P & 255] ^ _[X++], ee = y[$ >>> 24] ^ A[q >>> 16 & 255] ^ R[P >>> 8 & 255] ^ M[B & 255] ^ _[X++], k = y[q >>> 24] ^ A[P >>> 16 & 255] ^ R[B >>> 8 & 255] ^ M[$ & 255] ^ _[X++];
  5490. P = Q, B = te, $ = ee, q = k;
  5491. }
  5492. var Q = (C[P >>> 24] << 24 | C[B >>> 16 & 255] << 16 | C[$ >>> 8 & 255] << 8 | C[q & 255]) ^ _[X++], te = (C[B >>> 24] << 24 | C[$ >>> 16 & 255] << 16 | C[q >>> 8 & 255] << 8 | C[P & 255]) ^ _[X++], ee = (C[$ >>> 24] << 24 | C[q >>> 16 & 255] << 16 | C[P >>> 8 & 255] << 8 | C[B & 255]) ^ _[X++], k = (C[q >>> 24] << 24 | C[P >>> 16 & 255] << 16 | C[B >>> 8 & 255] << 8 | C[$ & 255]) ^ _[X++];
  5493. b[E] = Q, b[E + 1] = te, b[E + 2] = ee, b[E + 3] = k;
  5494. },
  5495. keySize: 256 / 32
  5496. });
  5497. t.AES = s._createHelper(x);
  5498. }(), e.AES;
  5499. });
  5500. }(Rr)), Rr.exports;
  5501. }
  5502. var Ir = { exports: {} }, Da;
  5503. function s0() {
  5504. return Da || (Da = 1, function(r, a) {
  5505. (function(e, t, i) {
  5506. r.exports = t(ne(), Ot(), Ut(), yt(), ye());
  5507. })(ie, function(e) {
  5508. return function() {
  5509. var t = e, i = t.lib, s = i.WordArray, n = i.BlockCipher, c = t.algo, o = [
  5510. 57,
  5511. 49,
  5512. 41,
  5513. 33,
  5514. 25,
  5515. 17,
  5516. 9,
  5517. 1,
  5518. 58,
  5519. 50,
  5520. 42,
  5521. 34,
  5522. 26,
  5523. 18,
  5524. 10,
  5525. 2,
  5526. 59,
  5527. 51,
  5528. 43,
  5529. 35,
  5530. 27,
  5531. 19,
  5532. 11,
  5533. 3,
  5534. 60,
  5535. 52,
  5536. 44,
  5537. 36,
  5538. 63,
  5539. 55,
  5540. 47,
  5541. 39,
  5542. 31,
  5543. 23,
  5544. 15,
  5545. 7,
  5546. 62,
  5547. 54,
  5548. 46,
  5549. 38,
  5550. 30,
  5551. 22,
  5552. 14,
  5553. 6,
  5554. 61,
  5555. 53,
  5556. 45,
  5557. 37,
  5558. 29,
  5559. 21,
  5560. 13,
  5561. 5,
  5562. 28,
  5563. 20,
  5564. 12,
  5565. 4
  5566. ], u = [
  5567. 14,
  5568. 17,
  5569. 11,
  5570. 24,
  5571. 1,
  5572. 5,
  5573. 3,
  5574. 28,
  5575. 15,
  5576. 6,
  5577. 21,
  5578. 10,
  5579. 23,
  5580. 19,
  5581. 12,
  5582. 4,
  5583. 26,
  5584. 8,
  5585. 16,
  5586. 7,
  5587. 27,
  5588. 20,
  5589. 13,
  5590. 2,
  5591. 41,
  5592. 52,
  5593. 31,
  5594. 37,
  5595. 47,
  5596. 55,
  5597. 30,
  5598. 40,
  5599. 51,
  5600. 45,
  5601. 33,
  5602. 48,
  5603. 44,
  5604. 49,
  5605. 39,
  5606. 56,
  5607. 34,
  5608. 53,
  5609. 46,
  5610. 42,
  5611. 50,
  5612. 36,
  5613. 29,
  5614. 32
  5615. ], h = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28], p = [
  5616. {
  5617. 0: 8421888,
  5618. 268435456: 32768,
  5619. 536870912: 8421378,
  5620. 805306368: 2,
  5621. 1073741824: 512,
  5622. 1342177280: 8421890,
  5623. 1610612736: 8389122,
  5624. 1879048192: 8388608,
  5625. 2147483648: 514,
  5626. 2415919104: 8389120,
  5627. 2684354560: 33280,
  5628. 2952790016: 8421376,
  5629. 3221225472: 32770,
  5630. 3489660928: 8388610,
  5631. 3758096384: 0,
  5632. 4026531840: 33282,
  5633. 134217728: 0,
  5634. 402653184: 8421890,
  5635. 671088640: 33282,
  5636. 939524096: 32768,
  5637. 1207959552: 8421888,
  5638. 1476395008: 512,
  5639. 1744830464: 8421378,
  5640. 2013265920: 2,
  5641. 2281701376: 8389120,
  5642. 2550136832: 33280,
  5643. 2818572288: 8421376,
  5644. 3087007744: 8389122,
  5645. 3355443200: 8388610,
  5646. 3623878656: 32770,
  5647. 3892314112: 514,
  5648. 4160749568: 8388608,
  5649. 1: 32768,
  5650. 268435457: 2,
  5651. 536870913: 8421888,
  5652. 805306369: 8388608,
  5653. 1073741825: 8421378,
  5654. 1342177281: 33280,
  5655. 1610612737: 512,
  5656. 1879048193: 8389122,
  5657. 2147483649: 8421890,
  5658. 2415919105: 8421376,
  5659. 2684354561: 8388610,
  5660. 2952790017: 33282,
  5661. 3221225473: 514,
  5662. 3489660929: 8389120,
  5663. 3758096385: 32770,
  5664. 4026531841: 0,
  5665. 134217729: 8421890,
  5666. 402653185: 8421376,
  5667. 671088641: 8388608,
  5668. 939524097: 512,
  5669. 1207959553: 32768,
  5670. 1476395009: 8388610,
  5671. 1744830465: 2,
  5672. 2013265921: 33282,
  5673. 2281701377: 32770,
  5674. 2550136833: 8389122,
  5675. 2818572289: 514,
  5676. 3087007745: 8421888,
  5677. 3355443201: 8389120,
  5678. 3623878657: 0,
  5679. 3892314113: 33280,
  5680. 4160749569: 8421378
  5681. },
  5682. {
  5683. 0: 1074282512,
  5684. 16777216: 16384,
  5685. 33554432: 524288,
  5686. 50331648: 1074266128,
  5687. 67108864: 1073741840,
  5688. 83886080: 1074282496,
  5689. 100663296: 1073758208,
  5690. 117440512: 16,
  5691. 134217728: 540672,
  5692. 150994944: 1073758224,
  5693. 167772160: 1073741824,
  5694. 184549376: 540688,
  5695. 201326592: 524304,
  5696. 218103808: 0,
  5697. 234881024: 16400,
  5698. 251658240: 1074266112,
  5699. 8388608: 1073758208,
  5700. 25165824: 540688,
  5701. 41943040: 16,
  5702. 58720256: 1073758224,
  5703. 75497472: 1074282512,
  5704. 92274688: 1073741824,
  5705. 109051904: 524288,
  5706. 125829120: 1074266128,
  5707. 142606336: 524304,
  5708. 159383552: 0,
  5709. 176160768: 16384,
  5710. 192937984: 1074266112,
  5711. 209715200: 1073741840,
  5712. 226492416: 540672,
  5713. 243269632: 1074282496,
  5714. 260046848: 16400,
  5715. 268435456: 0,
  5716. 285212672: 1074266128,
  5717. 301989888: 1073758224,
  5718. 318767104: 1074282496,
  5719. 335544320: 1074266112,
  5720. 352321536: 16,
  5721. 369098752: 540688,
  5722. 385875968: 16384,
  5723. 402653184: 16400,
  5724. 419430400: 524288,
  5725. 436207616: 524304,
  5726. 452984832: 1073741840,
  5727. 469762048: 540672,
  5728. 486539264: 1073758208,
  5729. 503316480: 1073741824,
  5730. 520093696: 1074282512,
  5731. 276824064: 540688,
  5732. 293601280: 524288,
  5733. 310378496: 1074266112,
  5734. 327155712: 16384,
  5735. 343932928: 1073758208,
  5736. 360710144: 1074282512,
  5737. 377487360: 16,
  5738. 394264576: 1073741824,
  5739. 411041792: 1074282496,
  5740. 427819008: 1073741840,
  5741. 444596224: 1073758224,
  5742. 461373440: 524304,
  5743. 478150656: 0,
  5744. 494927872: 16400,
  5745. 511705088: 1074266128,
  5746. 528482304: 540672
  5747. },
  5748. {
  5749. 0: 260,
  5750. 1048576: 0,
  5751. 2097152: 67109120,
  5752. 3145728: 65796,
  5753. 4194304: 65540,
  5754. 5242880: 67108868,
  5755. 6291456: 67174660,
  5756. 7340032: 67174400,
  5757. 8388608: 67108864,
  5758. 9437184: 67174656,
  5759. 10485760: 65792,
  5760. 11534336: 67174404,
  5761. 12582912: 67109124,
  5762. 13631488: 65536,
  5763. 14680064: 4,
  5764. 15728640: 256,
  5765. 524288: 67174656,
  5766. 1572864: 67174404,
  5767. 2621440: 0,
  5768. 3670016: 67109120,
  5769. 4718592: 67108868,
  5770. 5767168: 65536,
  5771. 6815744: 65540,
  5772. 7864320: 260,
  5773. 8912896: 4,
  5774. 9961472: 256,
  5775. 11010048: 67174400,
  5776. 12058624: 65796,
  5777. 13107200: 65792,
  5778. 14155776: 67109124,
  5779. 15204352: 67174660,
  5780. 16252928: 67108864,
  5781. 16777216: 67174656,
  5782. 17825792: 65540,
  5783. 18874368: 65536,
  5784. 19922944: 67109120,
  5785. 20971520: 256,
  5786. 22020096: 67174660,
  5787. 23068672: 67108868,
  5788. 24117248: 0,
  5789. 25165824: 67109124,
  5790. 26214400: 67108864,
  5791. 27262976: 4,
  5792. 28311552: 65792,
  5793. 29360128: 67174400,
  5794. 30408704: 260,
  5795. 31457280: 65796,
  5796. 32505856: 67174404,
  5797. 17301504: 67108864,
  5798. 18350080: 260,
  5799. 19398656: 67174656,
  5800. 20447232: 0,
  5801. 21495808: 65540,
  5802. 22544384: 67109120,
  5803. 23592960: 256,
  5804. 24641536: 67174404,
  5805. 25690112: 65536,
  5806. 26738688: 67174660,
  5807. 27787264: 65796,
  5808. 28835840: 67108868,
  5809. 29884416: 67109124,
  5810. 30932992: 67174400,
  5811. 31981568: 4,
  5812. 33030144: 65792
  5813. },
  5814. {
  5815. 0: 2151682048,
  5816. 65536: 2147487808,
  5817. 131072: 4198464,
  5818. 196608: 2151677952,
  5819. 262144: 0,
  5820. 327680: 4198400,
  5821. 393216: 2147483712,
  5822. 458752: 4194368,
  5823. 524288: 2147483648,
  5824. 589824: 4194304,
  5825. 655360: 64,
  5826. 720896: 2147487744,
  5827. 786432: 2151678016,
  5828. 851968: 4160,
  5829. 917504: 4096,
  5830. 983040: 2151682112,
  5831. 32768: 2147487808,
  5832. 98304: 64,
  5833. 163840: 2151678016,
  5834. 229376: 2147487744,
  5835. 294912: 4198400,
  5836. 360448: 2151682112,
  5837. 425984: 0,
  5838. 491520: 2151677952,
  5839. 557056: 4096,
  5840. 622592: 2151682048,
  5841. 688128: 4194304,
  5842. 753664: 4160,
  5843. 819200: 2147483648,
  5844. 884736: 4194368,
  5845. 950272: 4198464,
  5846. 1015808: 2147483712,
  5847. 1048576: 4194368,
  5848. 1114112: 4198400,
  5849. 1179648: 2147483712,
  5850. 1245184: 0,
  5851. 1310720: 4160,
  5852. 1376256: 2151678016,
  5853. 1441792: 2151682048,
  5854. 1507328: 2147487808,
  5855. 1572864: 2151682112,
  5856. 1638400: 2147483648,
  5857. 1703936: 2151677952,
  5858. 1769472: 4198464,
  5859. 1835008: 2147487744,
  5860. 1900544: 4194304,
  5861. 1966080: 64,
  5862. 2031616: 4096,
  5863. 1081344: 2151677952,
  5864. 1146880: 2151682112,
  5865. 1212416: 0,
  5866. 1277952: 4198400,
  5867. 1343488: 4194368,
  5868. 1409024: 2147483648,
  5869. 1474560: 2147487808,
  5870. 1540096: 64,
  5871. 1605632: 2147483712,
  5872. 1671168: 4096,
  5873. 1736704: 2147487744,
  5874. 1802240: 2151678016,
  5875. 1867776: 4160,
  5876. 1933312: 2151682048,
  5877. 1998848: 4194304,
  5878. 2064384: 4198464
  5879. },
  5880. {
  5881. 0: 128,
  5882. 4096: 17039360,
  5883. 8192: 262144,
  5884. 12288: 536870912,
  5885. 16384: 537133184,
  5886. 20480: 16777344,
  5887. 24576: 553648256,
  5888. 28672: 262272,
  5889. 32768: 16777216,
  5890. 36864: 537133056,
  5891. 40960: 536871040,
  5892. 45056: 553910400,
  5893. 49152: 553910272,
  5894. 53248: 0,
  5895. 57344: 17039488,
  5896. 61440: 553648128,
  5897. 2048: 17039488,
  5898. 6144: 553648256,
  5899. 10240: 128,
  5900. 14336: 17039360,
  5901. 18432: 262144,
  5902. 22528: 537133184,
  5903. 26624: 553910272,
  5904. 30720: 536870912,
  5905. 34816: 537133056,
  5906. 38912: 0,
  5907. 43008: 553910400,
  5908. 47104: 16777344,
  5909. 51200: 536871040,
  5910. 55296: 553648128,
  5911. 59392: 16777216,
  5912. 63488: 262272,
  5913. 65536: 262144,
  5914. 69632: 128,
  5915. 73728: 536870912,
  5916. 77824: 553648256,
  5917. 81920: 16777344,
  5918. 86016: 553910272,
  5919. 90112: 537133184,
  5920. 94208: 16777216,
  5921. 98304: 553910400,
  5922. 102400: 553648128,
  5923. 106496: 17039360,
  5924. 110592: 537133056,
  5925. 114688: 262272,
  5926. 118784: 536871040,
  5927. 122880: 0,
  5928. 126976: 17039488,
  5929. 67584: 553648256,
  5930. 71680: 16777216,
  5931. 75776: 17039360,
  5932. 79872: 537133184,
  5933. 83968: 536870912,
  5934. 88064: 17039488,
  5935. 92160: 128,
  5936. 96256: 553910272,
  5937. 100352: 262272,
  5938. 104448: 553910400,
  5939. 108544: 0,
  5940. 112640: 553648128,
  5941. 116736: 16777344,
  5942. 120832: 262144,
  5943. 124928: 537133056,
  5944. 129024: 536871040
  5945. },
  5946. {
  5947. 0: 268435464,
  5948. 256: 8192,
  5949. 512: 270532608,
  5950. 768: 270540808,
  5951. 1024: 268443648,
  5952. 1280: 2097152,
  5953. 1536: 2097160,
  5954. 1792: 268435456,
  5955. 2048: 0,
  5956. 2304: 268443656,
  5957. 2560: 2105344,
  5958. 2816: 8,
  5959. 3072: 270532616,
  5960. 3328: 2105352,
  5961. 3584: 8200,
  5962. 3840: 270540800,
  5963. 128: 270532608,
  5964. 384: 270540808,
  5965. 640: 8,
  5966. 896: 2097152,
  5967. 1152: 2105352,
  5968. 1408: 268435464,
  5969. 1664: 268443648,
  5970. 1920: 8200,
  5971. 2176: 2097160,
  5972. 2432: 8192,
  5973. 2688: 268443656,
  5974. 2944: 270532616,
  5975. 3200: 0,
  5976. 3456: 270540800,
  5977. 3712: 2105344,
  5978. 3968: 268435456,
  5979. 4096: 268443648,
  5980. 4352: 270532616,
  5981. 4608: 270540808,
  5982. 4864: 8200,
  5983. 5120: 2097152,
  5984. 5376: 268435456,
  5985. 5632: 268435464,
  5986. 5888: 2105344,
  5987. 6144: 2105352,
  5988. 6400: 0,
  5989. 6656: 8,
  5990. 6912: 270532608,
  5991. 7168: 8192,
  5992. 7424: 268443656,
  5993. 7680: 270540800,
  5994. 7936: 2097160,
  5995. 4224: 8,
  5996. 4480: 2105344,
  5997. 4736: 2097152,
  5998. 4992: 268435464,
  5999. 5248: 268443648,
  6000. 5504: 8200,
  6001. 5760: 270540808,
  6002. 6016: 270532608,
  6003. 6272: 270540800,
  6004. 6528: 270532616,
  6005. 6784: 8192,
  6006. 7040: 2105352,
  6007. 7296: 2097160,
  6008. 7552: 0,
  6009. 7808: 268435456,
  6010. 8064: 268443656
  6011. },
  6012. {
  6013. 0: 1048576,
  6014. 16: 33555457,
  6015. 32: 1024,
  6016. 48: 1049601,
  6017. 64: 34604033,
  6018. 80: 0,
  6019. 96: 1,
  6020. 112: 34603009,
  6021. 128: 33555456,
  6022. 144: 1048577,
  6023. 160: 33554433,
  6024. 176: 34604032,
  6025. 192: 34603008,
  6026. 208: 1025,
  6027. 224: 1049600,
  6028. 240: 33554432,
  6029. 8: 34603009,
  6030. 24: 0,
  6031. 40: 33555457,
  6032. 56: 34604032,
  6033. 72: 1048576,
  6034. 88: 33554433,
  6035. 104: 33554432,
  6036. 120: 1025,
  6037. 136: 1049601,
  6038. 152: 33555456,
  6039. 168: 34603008,
  6040. 184: 1048577,
  6041. 200: 1024,
  6042. 216: 34604033,
  6043. 232: 1,
  6044. 248: 1049600,
  6045. 256: 33554432,
  6046. 272: 1048576,
  6047. 288: 33555457,
  6048. 304: 34603009,
  6049. 320: 1048577,
  6050. 336: 33555456,
  6051. 352: 34604032,
  6052. 368: 1049601,
  6053. 384: 1025,
  6054. 400: 34604033,
  6055. 416: 1049600,
  6056. 432: 1,
  6057. 448: 0,
  6058. 464: 34603008,
  6059. 480: 33554433,
  6060. 496: 1024,
  6061. 264: 1049600,
  6062. 280: 33555457,
  6063. 296: 34603009,
  6064. 312: 1,
  6065. 328: 33554432,
  6066. 344: 1048576,
  6067. 360: 1025,
  6068. 376: 34604032,
  6069. 392: 33554433,
  6070. 408: 34603008,
  6071. 424: 0,
  6072. 440: 34604033,
  6073. 456: 1049601,
  6074. 472: 1024,
  6075. 488: 33555456,
  6076. 504: 1048577
  6077. },
  6078. {
  6079. 0: 134219808,
  6080. 1: 131072,
  6081. 2: 134217728,
  6082. 3: 32,
  6083. 4: 131104,
  6084. 5: 134350880,
  6085. 6: 134350848,
  6086. 7: 2048,
  6087. 8: 134348800,
  6088. 9: 134219776,
  6089. 10: 133120,
  6090. 11: 134348832,
  6091. 12: 2080,
  6092. 13: 0,
  6093. 14: 134217760,
  6094. 15: 133152,
  6095. 2147483648: 2048,
  6096. 2147483649: 134350880,
  6097. 2147483650: 134219808,
  6098. 2147483651: 134217728,
  6099. 2147483652: 134348800,
  6100. 2147483653: 133120,
  6101. 2147483654: 133152,
  6102. 2147483655: 32,
  6103. 2147483656: 134217760,
  6104. 2147483657: 2080,
  6105. 2147483658: 131104,
  6106. 2147483659: 134350848,
  6107. 2147483660: 0,
  6108. 2147483661: 134348832,
  6109. 2147483662: 134219776,
  6110. 2147483663: 131072,
  6111. 16: 133152,
  6112. 17: 134350848,
  6113. 18: 32,
  6114. 19: 2048,
  6115. 20: 134219776,
  6116. 21: 134217760,
  6117. 22: 134348832,
  6118. 23: 131072,
  6119. 24: 0,
  6120. 25: 131104,
  6121. 26: 134348800,
  6122. 27: 134219808,
  6123. 28: 134350880,
  6124. 29: 133120,
  6125. 30: 2080,
  6126. 31: 134217728,
  6127. 2147483664: 131072,
  6128. 2147483665: 2048,
  6129. 2147483666: 134348832,
  6130. 2147483667: 133152,
  6131. 2147483668: 32,
  6132. 2147483669: 134348800,
  6133. 2147483670: 134217728,
  6134. 2147483671: 134219808,
  6135. 2147483672: 134350880,
  6136. 2147483673: 134217760,
  6137. 2147483674: 134219776,
  6138. 2147483675: 0,
  6139. 2147483676: 133120,
  6140. 2147483677: 2080,
  6141. 2147483678: 131104,
  6142. 2147483679: 134350848
  6143. }
  6144. ], d = [
  6145. 4160749569,
  6146. 528482304,
  6147. 33030144,
  6148. 2064384,
  6149. 129024,
  6150. 8064,
  6151. 504,
  6152. 2147483679
  6153. ], f = c.DES = n.extend({
  6154. _doReset: function() {
  6155. for (var v = this._key, x = v.words, b = [], E = 0; E < 56; E++) {
  6156. var _ = o[E] - 1;
  6157. b[E] = x[_ >>> 5] >>> 31 - _ % 32 & 1;
  6158. }
  6159. for (var y = this._subKeys = [], A = 0; A < 16; A++) {
  6160. for (var R = y[A] = [], M = h[A], E = 0; E < 24; E++)
  6161. R[E / 6 | 0] |= b[(u[E] - 1 + M) % 28] << 31 - E % 6, R[4 + (E / 6 | 0)] |= b[28 + (u[E + 24] - 1 + M) % 28] << 31 - E % 6;
  6162. R[0] = R[0] << 1 | R[0] >>> 31;
  6163. for (var E = 1; E < 7; E++)
  6164. R[E] = R[E] >>> (E - 1) * 4 + 3;
  6165. R[7] = R[7] << 5 | R[7] >>> 27;
  6166. }
  6167. for (var C = this._invSubKeys = [], E = 0; E < 16; E++)
  6168. C[E] = y[15 - E];
  6169. },
  6170. encryptBlock: function(v, x) {
  6171. this._doCryptBlock(v, x, this._subKeys);
  6172. },
  6173. decryptBlock: function(v, x) {
  6174. this._doCryptBlock(v, x, this._invSubKeys);
  6175. },
  6176. _doCryptBlock: function(v, x, b) {
  6177. this._lBlock = v[x], this._rBlock = v[x + 1], m.call(this, 4, 252645135), m.call(this, 16, 65535), l.call(this, 2, 858993459), l.call(this, 8, 16711935), m.call(this, 1, 1431655765);
  6178. for (var E = 0; E < 16; E++) {
  6179. for (var _ = b[E], y = this._lBlock, A = this._rBlock, R = 0, M = 0; M < 8; M++)
  6180. R |= p[M][((A ^ _[M]) & d[M]) >>> 0];
  6181. this._lBlock = A, this._rBlock = y ^ R;
  6182. }
  6183. var C = this._lBlock;
  6184. this._lBlock = this._rBlock, this._rBlock = C, m.call(this, 1, 1431655765), l.call(this, 8, 16711935), l.call(this, 2, 858993459), m.call(this, 16, 65535), m.call(this, 4, 252645135), v[x] = this._lBlock, v[x + 1] = this._rBlock;
  6185. },
  6186. keySize: 64 / 32,
  6187. ivSize: 64 / 32,
  6188. blockSize: 64 / 32
  6189. });
  6190. function m(v, x) {
  6191. var b = (this._lBlock >>> v ^ this._rBlock) & x;
  6192. this._rBlock ^= b, this._lBlock ^= b << v;
  6193. }
  6194. function l(v, x) {
  6195. var b = (this._rBlock >>> v ^ this._lBlock) & x;
  6196. this._lBlock ^= b, this._rBlock ^= b << v;
  6197. }
  6198. t.DES = n._createHelper(f);
  6199. var S = c.TripleDES = n.extend({
  6200. _doReset: function() {
  6201. var v = this._key, x = v.words;
  6202. if (x.length !== 2 && x.length !== 4 && x.length < 6)
  6203. throw new Error("Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.");
  6204. var b = x.slice(0, 2), E = x.length < 4 ? x.slice(0, 2) : x.slice(2, 4), _ = x.length < 6 ? x.slice(0, 2) : x.slice(4, 6);
  6205. this._des1 = f.createEncryptor(s.create(b)), this._des2 = f.createEncryptor(s.create(E)), this._des3 = f.createEncryptor(s.create(_));
  6206. },
  6207. encryptBlock: function(v, x) {
  6208. this._des1.encryptBlock(v, x), this._des2.decryptBlock(v, x), this._des3.encryptBlock(v, x);
  6209. },
  6210. decryptBlock: function(v, x) {
  6211. this._des3.decryptBlock(v, x), this._des2.encryptBlock(v, x), this._des1.decryptBlock(v, x);
  6212. },
  6213. keySize: 192 / 32,
  6214. ivSize: 64 / 32,
  6215. blockSize: 64 / 32
  6216. });
  6217. t.TripleDES = n._createHelper(S);
  6218. }(), e.TripleDES;
  6219. });
  6220. }(Ir)), Ir.exports;
  6221. }
  6222. var wr = { exports: {} }, Ta;
  6223. function a0() {
  6224. return Ta || (Ta = 1, function(r, a) {
  6225. (function(e, t, i) {
  6226. r.exports = t(ne(), Ot(), Ut(), yt(), ye());
  6227. })(ie, function(e) {
  6228. return function() {
  6229. var t = e, i = t.lib, s = i.StreamCipher, n = t.algo, c = n.RC4 = s.extend({
  6230. _doReset: function() {
  6231. for (var h = this._key, p = h.words, d = h.sigBytes, f = this._S = [], m = 0; m < 256; m++)
  6232. f[m] = m;
  6233. for (var m = 0, l = 0; m < 256; m++) {
  6234. var S = m % d, v = p[S >>> 2] >>> 24 - S % 4 * 8 & 255;
  6235. l = (l + f[m] + v) % 256;
  6236. var x = f[m];
  6237. f[m] = f[l], f[l] = x;
  6238. }
  6239. this._i = this._j = 0;
  6240. },
  6241. _doProcessBlock: function(h, p) {
  6242. h[p] ^= o.call(this);
  6243. },
  6244. keySize: 256 / 32,
  6245. ivSize: 0
  6246. });
  6247. function o() {
  6248. for (var h = this._S, p = this._i, d = this._j, f = 0, m = 0; m < 4; m++) {
  6249. p = (p + 1) % 256, d = (d + h[p]) % 256;
  6250. var l = h[p];
  6251. h[p] = h[d], h[d] = l, f |= h[(h[p] + h[d]) % 256] << 24 - m * 8;
  6252. }
  6253. return this._i = p, this._j = d, f;
  6254. }
  6255. t.RC4 = s._createHelper(c);
  6256. var u = n.RC4Drop = c.extend({
  6257. /**
  6258. * Configuration options.
  6259. *
  6260. * @property {number} drop The number of keystream words to drop. Default 192
  6261. */
  6262. cfg: c.cfg.extend({
  6263. drop: 192
  6264. }),
  6265. _doReset: function() {
  6266. c._doReset.call(this);
  6267. for (var h = this.cfg.drop; h > 0; h--)
  6268. o.call(this);
  6269. }
  6270. });
  6271. t.RC4Drop = s._createHelper(u);
  6272. }(), e.RC4;
  6273. });
  6274. }(wr)), wr.exports;
  6275. }
  6276. var Dr = { exports: {} }, Pa;
  6277. function n0() {
  6278. return Pa || (Pa = 1, function(r, a) {
  6279. (function(e, t, i) {
  6280. r.exports = t(ne(), Ot(), Ut(), yt(), ye());
  6281. })(ie, function(e) {
  6282. return function() {
  6283. var t = e, i = t.lib, s = i.StreamCipher, n = t.algo, c = [], o = [], u = [], h = n.Rabbit = s.extend({
  6284. _doReset: function() {
  6285. for (var d = this._key.words, f = this.cfg.iv, m = 0; m < 4; m++)
  6286. d[m] = (d[m] << 8 | d[m] >>> 24) & 16711935 | (d[m] << 24 | d[m] >>> 8) & 4278255360;
  6287. var l = this._X = [
  6288. d[0],
  6289. d[3] << 16 | d[2] >>> 16,
  6290. d[1],
  6291. d[0] << 16 | d[3] >>> 16,
  6292. d[2],
  6293. d[1] << 16 | d[0] >>> 16,
  6294. d[3],
  6295. d[2] << 16 | d[1] >>> 16
  6296. ], S = this._C = [
  6297. d[2] << 16 | d[2] >>> 16,
  6298. d[0] & 4294901760 | d[1] & 65535,
  6299. d[3] << 16 | d[3] >>> 16,
  6300. d[1] & 4294901760 | d[2] & 65535,
  6301. d[0] << 16 | d[0] >>> 16,
  6302. d[2] & 4294901760 | d[3] & 65535,
  6303. d[1] << 16 | d[1] >>> 16,
  6304. d[3] & 4294901760 | d[0] & 65535
  6305. ];
  6306. this._b = 0;
  6307. for (var m = 0; m < 4; m++)
  6308. p.call(this);
  6309. for (var m = 0; m < 8; m++)
  6310. S[m] ^= l[m + 4 & 7];
  6311. if (f) {
  6312. var v = f.words, x = v[0], b = v[1], E = (x << 8 | x >>> 24) & 16711935 | (x << 24 | x >>> 8) & 4278255360, _ = (b << 8 | b >>> 24) & 16711935 | (b << 24 | b >>> 8) & 4278255360, y = E >>> 16 | _ & 4294901760, A = _ << 16 | E & 65535;
  6313. S[0] ^= E, S[1] ^= y, S[2] ^= _, S[3] ^= A, S[4] ^= E, S[5] ^= y, S[6] ^= _, S[7] ^= A;
  6314. for (var m = 0; m < 4; m++)
  6315. p.call(this);
  6316. }
  6317. },
  6318. _doProcessBlock: function(d, f) {
  6319. var m = this._X;
  6320. p.call(this), c[0] = m[0] ^ m[5] >>> 16 ^ m[3] << 16, c[1] = m[2] ^ m[7] >>> 16 ^ m[5] << 16, c[2] = m[4] ^ m[1] >>> 16 ^ m[7] << 16, c[3] = m[6] ^ m[3] >>> 16 ^ m[1] << 16;
  6321. for (var l = 0; l < 4; l++)
  6322. c[l] = (c[l] << 8 | c[l] >>> 24) & 16711935 | (c[l] << 24 | c[l] >>> 8) & 4278255360, d[f + l] ^= c[l];
  6323. },
  6324. blockSize: 128 / 32,
  6325. ivSize: 64 / 32
  6326. });
  6327. function p() {
  6328. for (var d = this._X, f = this._C, m = 0; m < 8; m++)
  6329. o[m] = f[m];
  6330. f[0] = f[0] + 1295307597 + this._b | 0, f[1] = f[1] + 3545052371 + (f[0] >>> 0 < o[0] >>> 0 ? 1 : 0) | 0, f[2] = f[2] + 886263092 + (f[1] >>> 0 < o[1] >>> 0 ? 1 : 0) | 0, f[3] = f[3] + 1295307597 + (f[2] >>> 0 < o[2] >>> 0 ? 1 : 0) | 0, f[4] = f[4] + 3545052371 + (f[3] >>> 0 < o[3] >>> 0 ? 1 : 0) | 0, f[5] = f[5] + 886263092 + (f[4] >>> 0 < o[4] >>> 0 ? 1 : 0) | 0, f[6] = f[6] + 1295307597 + (f[5] >>> 0 < o[5] >>> 0 ? 1 : 0) | 0, f[7] = f[7] + 3545052371 + (f[6] >>> 0 < o[6] >>> 0 ? 1 : 0) | 0, this._b = f[7] >>> 0 < o[7] >>> 0 ? 1 : 0;
  6331. for (var m = 0; m < 8; m++) {
  6332. var l = d[m] + f[m], S = l & 65535, v = l >>> 16, x = ((S * S >>> 17) + S * v >>> 15) + v * v, b = ((l & 4294901760) * l | 0) + ((l & 65535) * l | 0);
  6333. u[m] = x ^ b;
  6334. }
  6335. d[0] = u[0] + (u[7] << 16 | u[7] >>> 16) + (u[6] << 16 | u[6] >>> 16) | 0, d[1] = u[1] + (u[0] << 8 | u[0] >>> 24) + u[7] | 0, d[2] = u[2] + (u[1] << 16 | u[1] >>> 16) + (u[0] << 16 | u[0] >>> 16) | 0, d[3] = u[3] + (u[2] << 8 | u[2] >>> 24) + u[1] | 0, d[4] = u[4] + (u[3] << 16 | u[3] >>> 16) + (u[2] << 16 | u[2] >>> 16) | 0, d[5] = u[5] + (u[4] << 8 | u[4] >>> 24) + u[3] | 0, d[6] = u[6] + (u[5] << 16 | u[5] >>> 16) + (u[4] << 16 | u[4] >>> 16) | 0, d[7] = u[7] + (u[6] << 8 | u[6] >>> 24) + u[5] | 0;
  6336. }
  6337. t.Rabbit = s._createHelper(h);
  6338. }(), e.Rabbit;
  6339. });
  6340. }(Dr)), Dr.exports;
  6341. }
  6342. var Tr = { exports: {} }, ka;
  6343. function o0() {
  6344. return ka || (ka = 1, function(r, a) {
  6345. (function(e, t, i) {
  6346. r.exports = t(ne(), Ot(), Ut(), yt(), ye());
  6347. })(ie, function(e) {
  6348. return function() {
  6349. var t = e, i = t.lib, s = i.StreamCipher, n = t.algo, c = [], o = [], u = [], h = n.RabbitLegacy = s.extend({
  6350. _doReset: function() {
  6351. var d = this._key.words, f = this.cfg.iv, m = this._X = [
  6352. d[0],
  6353. d[3] << 16 | d[2] >>> 16,
  6354. d[1],
  6355. d[0] << 16 | d[3] >>> 16,
  6356. d[2],
  6357. d[1] << 16 | d[0] >>> 16,
  6358. d[3],
  6359. d[2] << 16 | d[1] >>> 16
  6360. ], l = this._C = [
  6361. d[2] << 16 | d[2] >>> 16,
  6362. d[0] & 4294901760 | d[1] & 65535,
  6363. d[3] << 16 | d[3] >>> 16,
  6364. d[1] & 4294901760 | d[2] & 65535,
  6365. d[0] << 16 | d[0] >>> 16,
  6366. d[2] & 4294901760 | d[3] & 65535,
  6367. d[1] << 16 | d[1] >>> 16,
  6368. d[3] & 4294901760 | d[0] & 65535
  6369. ];
  6370. this._b = 0;
  6371. for (var S = 0; S < 4; S++)
  6372. p.call(this);
  6373. for (var S = 0; S < 8; S++)
  6374. l[S] ^= m[S + 4 & 7];
  6375. if (f) {
  6376. var v = f.words, x = v[0], b = v[1], E = (x << 8 | x >>> 24) & 16711935 | (x << 24 | x >>> 8) & 4278255360, _ = (b << 8 | b >>> 24) & 16711935 | (b << 24 | b >>> 8) & 4278255360, y = E >>> 16 | _ & 4294901760, A = _ << 16 | E & 65535;
  6377. l[0] ^= E, l[1] ^= y, l[2] ^= _, l[3] ^= A, l[4] ^= E, l[5] ^= y, l[6] ^= _, l[7] ^= A;
  6378. for (var S = 0; S < 4; S++)
  6379. p.call(this);
  6380. }
  6381. },
  6382. _doProcessBlock: function(d, f) {
  6383. var m = this._X;
  6384. p.call(this), c[0] = m[0] ^ m[5] >>> 16 ^ m[3] << 16, c[1] = m[2] ^ m[7] >>> 16 ^ m[5] << 16, c[2] = m[4] ^ m[1] >>> 16 ^ m[7] << 16, c[3] = m[6] ^ m[3] >>> 16 ^ m[1] << 16;
  6385. for (var l = 0; l < 4; l++)
  6386. c[l] = (c[l] << 8 | c[l] >>> 24) & 16711935 | (c[l] << 24 | c[l] >>> 8) & 4278255360, d[f + l] ^= c[l];
  6387. },
  6388. blockSize: 128 / 32,
  6389. ivSize: 64 / 32
  6390. });
  6391. function p() {
  6392. for (var d = this._X, f = this._C, m = 0; m < 8; m++)
  6393. o[m] = f[m];
  6394. f[0] = f[0] + 1295307597 + this._b | 0, f[1] = f[1] + 3545052371 + (f[0] >>> 0 < o[0] >>> 0 ? 1 : 0) | 0, f[2] = f[2] + 886263092 + (f[1] >>> 0 < o[1] >>> 0 ? 1 : 0) | 0, f[3] = f[3] + 1295307597 + (f[2] >>> 0 < o[2] >>> 0 ? 1 : 0) | 0, f[4] = f[4] + 3545052371 + (f[3] >>> 0 < o[3] >>> 0 ? 1 : 0) | 0, f[5] = f[5] + 886263092 + (f[4] >>> 0 < o[4] >>> 0 ? 1 : 0) | 0, f[6] = f[6] + 1295307597 + (f[5] >>> 0 < o[5] >>> 0 ? 1 : 0) | 0, f[7] = f[7] + 3545052371 + (f[6] >>> 0 < o[6] >>> 0 ? 1 : 0) | 0, this._b = f[7] >>> 0 < o[7] >>> 0 ? 1 : 0;
  6395. for (var m = 0; m < 8; m++) {
  6396. var l = d[m] + f[m], S = l & 65535, v = l >>> 16, x = ((S * S >>> 17) + S * v >>> 15) + v * v, b = ((l & 4294901760) * l | 0) + ((l & 65535) * l | 0);
  6397. u[m] = x ^ b;
  6398. }
  6399. d[0] = u[0] + (u[7] << 16 | u[7] >>> 16) + (u[6] << 16 | u[6] >>> 16) | 0, d[1] = u[1] + (u[0] << 8 | u[0] >>> 24) + u[7] | 0, d[2] = u[2] + (u[1] << 16 | u[1] >>> 16) + (u[0] << 16 | u[0] >>> 16) | 0, d[3] = u[3] + (u[2] << 8 | u[2] >>> 24) + u[1] | 0, d[4] = u[4] + (u[3] << 16 | u[3] >>> 16) + (u[2] << 16 | u[2] >>> 16) | 0, d[5] = u[5] + (u[4] << 8 | u[4] >>> 24) + u[3] | 0, d[6] = u[6] + (u[5] << 16 | u[5] >>> 16) + (u[4] << 16 | u[4] >>> 16) | 0, d[7] = u[7] + (u[6] << 8 | u[6] >>> 24) + u[5] | 0;
  6400. }
  6401. t.RabbitLegacy = s._createHelper(h);
  6402. }(), e.RabbitLegacy;
  6403. });
  6404. }(Tr)), Tr.exports;
  6405. }
  6406. var Pr = { exports: {} }, Ba;
  6407. function c0() {
  6408. return Ba || (Ba = 1, function(r, a) {
  6409. (function(e, t, i) {
  6410. r.exports = t(ne(), Ot(), Ut(), yt(), ye());
  6411. })(ie, function(e) {
  6412. return function() {
  6413. var t = e, i = t.lib, s = i.BlockCipher, n = t.algo;
  6414. const c = 16, o = [
  6415. 608135816,
  6416. 2242054355,
  6417. 320440878,
  6418. 57701188,
  6419. 2752067618,
  6420. 698298832,
  6421. 137296536,
  6422. 3964562569,
  6423. 1160258022,
  6424. 953160567,
  6425. 3193202383,
  6426. 887688300,
  6427. 3232508343,
  6428. 3380367581,
  6429. 1065670069,
  6430. 3041331479,
  6431. 2450970073,
  6432. 2306472731
  6433. ], u = [
  6434. [
  6435. 3509652390,
  6436. 2564797868,
  6437. 805139163,
  6438. 3491422135,
  6439. 3101798381,
  6440. 1780907670,
  6441. 3128725573,
  6442. 4046225305,
  6443. 614570311,
  6444. 3012652279,
  6445. 134345442,
  6446. 2240740374,
  6447. 1667834072,
  6448. 1901547113,
  6449. 2757295779,
  6450. 4103290238,
  6451. 227898511,
  6452. 1921955416,
  6453. 1904987480,
  6454. 2182433518,
  6455. 2069144605,
  6456. 3260701109,
  6457. 2620446009,
  6458. 720527379,
  6459. 3318853667,
  6460. 677414384,
  6461. 3393288472,
  6462. 3101374703,
  6463. 2390351024,
  6464. 1614419982,
  6465. 1822297739,
  6466. 2954791486,
  6467. 3608508353,
  6468. 3174124327,
  6469. 2024746970,
  6470. 1432378464,
  6471. 3864339955,
  6472. 2857741204,
  6473. 1464375394,
  6474. 1676153920,
  6475. 1439316330,
  6476. 715854006,
  6477. 3033291828,
  6478. 289532110,
  6479. 2706671279,
  6480. 2087905683,
  6481. 3018724369,
  6482. 1668267050,
  6483. 732546397,
  6484. 1947742710,
  6485. 3462151702,
  6486. 2609353502,
  6487. 2950085171,
  6488. 1814351708,
  6489. 2050118529,
  6490. 680887927,
  6491. 999245976,
  6492. 1800124847,
  6493. 3300911131,
  6494. 1713906067,
  6495. 1641548236,
  6496. 4213287313,
  6497. 1216130144,
  6498. 1575780402,
  6499. 4018429277,
  6500. 3917837745,
  6501. 3693486850,
  6502. 3949271944,
  6503. 596196993,
  6504. 3549867205,
  6505. 258830323,
  6506. 2213823033,
  6507. 772490370,
  6508. 2760122372,
  6509. 1774776394,
  6510. 2652871518,
  6511. 566650946,
  6512. 4142492826,
  6513. 1728879713,
  6514. 2882767088,
  6515. 1783734482,
  6516. 3629395816,
  6517. 2517608232,
  6518. 2874225571,
  6519. 1861159788,
  6520. 326777828,
  6521. 3124490320,
  6522. 2130389656,
  6523. 2716951837,
  6524. 967770486,
  6525. 1724537150,
  6526. 2185432712,
  6527. 2364442137,
  6528. 1164943284,
  6529. 2105845187,
  6530. 998989502,
  6531. 3765401048,
  6532. 2244026483,
  6533. 1075463327,
  6534. 1455516326,
  6535. 1322494562,
  6536. 910128902,
  6537. 469688178,
  6538. 1117454909,
  6539. 936433444,
  6540. 3490320968,
  6541. 3675253459,
  6542. 1240580251,
  6543. 122909385,
  6544. 2157517691,
  6545. 634681816,
  6546. 4142456567,
  6547. 3825094682,
  6548. 3061402683,
  6549. 2540495037,
  6550. 79693498,
  6551. 3249098678,
  6552. 1084186820,
  6553. 1583128258,
  6554. 426386531,
  6555. 1761308591,
  6556. 1047286709,
  6557. 322548459,
  6558. 995290223,
  6559. 1845252383,
  6560. 2603652396,
  6561. 3431023940,
  6562. 2942221577,
  6563. 3202600964,
  6564. 3727903485,
  6565. 1712269319,
  6566. 422464435,
  6567. 3234572375,
  6568. 1170764815,
  6569. 3523960633,
  6570. 3117677531,
  6571. 1434042557,
  6572. 442511882,
  6573. 3600875718,
  6574. 1076654713,
  6575. 1738483198,
  6576. 4213154764,
  6577. 2393238008,
  6578. 3677496056,
  6579. 1014306527,
  6580. 4251020053,
  6581. 793779912,
  6582. 2902807211,
  6583. 842905082,
  6584. 4246964064,
  6585. 1395751752,
  6586. 1040244610,
  6587. 2656851899,
  6588. 3396308128,
  6589. 445077038,
  6590. 3742853595,
  6591. 3577915638,
  6592. 679411651,
  6593. 2892444358,
  6594. 2354009459,
  6595. 1767581616,
  6596. 3150600392,
  6597. 3791627101,
  6598. 3102740896,
  6599. 284835224,
  6600. 4246832056,
  6601. 1258075500,
  6602. 768725851,
  6603. 2589189241,
  6604. 3069724005,
  6605. 3532540348,
  6606. 1274779536,
  6607. 3789419226,
  6608. 2764799539,
  6609. 1660621633,
  6610. 3471099624,
  6611. 4011903706,
  6612. 913787905,
  6613. 3497959166,
  6614. 737222580,
  6615. 2514213453,
  6616. 2928710040,
  6617. 3937242737,
  6618. 1804850592,
  6619. 3499020752,
  6620. 2949064160,
  6621. 2386320175,
  6622. 2390070455,
  6623. 2415321851,
  6624. 4061277028,
  6625. 2290661394,
  6626. 2416832540,
  6627. 1336762016,
  6628. 1754252060,
  6629. 3520065937,
  6630. 3014181293,
  6631. 791618072,
  6632. 3188594551,
  6633. 3933548030,
  6634. 2332172193,
  6635. 3852520463,
  6636. 3043980520,
  6637. 413987798,
  6638. 3465142937,
  6639. 3030929376,
  6640. 4245938359,
  6641. 2093235073,
  6642. 3534596313,
  6643. 375366246,
  6644. 2157278981,
  6645. 2479649556,
  6646. 555357303,
  6647. 3870105701,
  6648. 2008414854,
  6649. 3344188149,
  6650. 4221384143,
  6651. 3956125452,
  6652. 2067696032,
  6653. 3594591187,
  6654. 2921233993,
  6655. 2428461,
  6656. 544322398,
  6657. 577241275,
  6658. 1471733935,
  6659. 610547355,
  6660. 4027169054,
  6661. 1432588573,
  6662. 1507829418,
  6663. 2025931657,
  6664. 3646575487,
  6665. 545086370,
  6666. 48609733,
  6667. 2200306550,
  6668. 1653985193,
  6669. 298326376,
  6670. 1316178497,
  6671. 3007786442,
  6672. 2064951626,
  6673. 458293330,
  6674. 2589141269,
  6675. 3591329599,
  6676. 3164325604,
  6677. 727753846,
  6678. 2179363840,
  6679. 146436021,
  6680. 1461446943,
  6681. 4069977195,
  6682. 705550613,
  6683. 3059967265,
  6684. 3887724982,
  6685. 4281599278,
  6686. 3313849956,
  6687. 1404054877,
  6688. 2845806497,
  6689. 146425753,
  6690. 1854211946
  6691. ],
  6692. [
  6693. 1266315497,
  6694. 3048417604,
  6695. 3681880366,
  6696. 3289982499,
  6697. 290971e4,
  6698. 1235738493,
  6699. 2632868024,
  6700. 2414719590,
  6701. 3970600049,
  6702. 1771706367,
  6703. 1449415276,
  6704. 3266420449,
  6705. 422970021,
  6706. 1963543593,
  6707. 2690192192,
  6708. 3826793022,
  6709. 1062508698,
  6710. 1531092325,
  6711. 1804592342,
  6712. 2583117782,
  6713. 2714934279,
  6714. 4024971509,
  6715. 1294809318,
  6716. 4028980673,
  6717. 1289560198,
  6718. 2221992742,
  6719. 1669523910,
  6720. 35572830,
  6721. 157838143,
  6722. 1052438473,
  6723. 1016535060,
  6724. 1802137761,
  6725. 1753167236,
  6726. 1386275462,
  6727. 3080475397,
  6728. 2857371447,
  6729. 1040679964,
  6730. 2145300060,
  6731. 2390574316,
  6732. 1461121720,
  6733. 2956646967,
  6734. 4031777805,
  6735. 4028374788,
  6736. 33600511,
  6737. 2920084762,
  6738. 1018524850,
  6739. 629373528,
  6740. 3691585981,
  6741. 3515945977,
  6742. 2091462646,
  6743. 2486323059,
  6744. 586499841,
  6745. 988145025,
  6746. 935516892,
  6747. 3367335476,
  6748. 2599673255,
  6749. 2839830854,
  6750. 265290510,
  6751. 3972581182,
  6752. 2759138881,
  6753. 3795373465,
  6754. 1005194799,
  6755. 847297441,
  6756. 406762289,
  6757. 1314163512,
  6758. 1332590856,
  6759. 1866599683,
  6760. 4127851711,
  6761. 750260880,
  6762. 613907577,
  6763. 1450815602,
  6764. 3165620655,
  6765. 3734664991,
  6766. 3650291728,
  6767. 3012275730,
  6768. 3704569646,
  6769. 1427272223,
  6770. 778793252,
  6771. 1343938022,
  6772. 2676280711,
  6773. 2052605720,
  6774. 1946737175,
  6775. 3164576444,
  6776. 3914038668,
  6777. 3967478842,
  6778. 3682934266,
  6779. 1661551462,
  6780. 3294938066,
  6781. 4011595847,
  6782. 840292616,
  6783. 3712170807,
  6784. 616741398,
  6785. 312560963,
  6786. 711312465,
  6787. 1351876610,
  6788. 322626781,
  6789. 1910503582,
  6790. 271666773,
  6791. 2175563734,
  6792. 1594956187,
  6793. 70604529,
  6794. 3617834859,
  6795. 1007753275,
  6796. 1495573769,
  6797. 4069517037,
  6798. 2549218298,
  6799. 2663038764,
  6800. 504708206,
  6801. 2263041392,
  6802. 3941167025,
  6803. 2249088522,
  6804. 1514023603,
  6805. 1998579484,
  6806. 1312622330,
  6807. 694541497,
  6808. 2582060303,
  6809. 2151582166,
  6810. 1382467621,
  6811. 776784248,
  6812. 2618340202,
  6813. 3323268794,
  6814. 2497899128,
  6815. 2784771155,
  6816. 503983604,
  6817. 4076293799,
  6818. 907881277,
  6819. 423175695,
  6820. 432175456,
  6821. 1378068232,
  6822. 4145222326,
  6823. 3954048622,
  6824. 3938656102,
  6825. 3820766613,
  6826. 2793130115,
  6827. 2977904593,
  6828. 26017576,
  6829. 3274890735,
  6830. 3194772133,
  6831. 1700274565,
  6832. 1756076034,
  6833. 4006520079,
  6834. 3677328699,
  6835. 720338349,
  6836. 1533947780,
  6837. 354530856,
  6838. 688349552,
  6839. 3973924725,
  6840. 1637815568,
  6841. 332179504,
  6842. 3949051286,
  6843. 53804574,
  6844. 2852348879,
  6845. 3044236432,
  6846. 1282449977,
  6847. 3583942155,
  6848. 3416972820,
  6849. 4006381244,
  6850. 1617046695,
  6851. 2628476075,
  6852. 3002303598,
  6853. 1686838959,
  6854. 431878346,
  6855. 2686675385,
  6856. 1700445008,
  6857. 1080580658,
  6858. 1009431731,
  6859. 832498133,
  6860. 3223435511,
  6861. 2605976345,
  6862. 2271191193,
  6863. 2516031870,
  6864. 1648197032,
  6865. 4164389018,
  6866. 2548247927,
  6867. 300782431,
  6868. 375919233,
  6869. 238389289,
  6870. 3353747414,
  6871. 2531188641,
  6872. 2019080857,
  6873. 1475708069,
  6874. 455242339,
  6875. 2609103871,
  6876. 448939670,
  6877. 3451063019,
  6878. 1395535956,
  6879. 2413381860,
  6880. 1841049896,
  6881. 1491858159,
  6882. 885456874,
  6883. 4264095073,
  6884. 4001119347,
  6885. 1565136089,
  6886. 3898914787,
  6887. 1108368660,
  6888. 540939232,
  6889. 1173283510,
  6890. 2745871338,
  6891. 3681308437,
  6892. 4207628240,
  6893. 3343053890,
  6894. 4016749493,
  6895. 1699691293,
  6896. 1103962373,
  6897. 3625875870,
  6898. 2256883143,
  6899. 3830138730,
  6900. 1031889488,
  6901. 3479347698,
  6902. 1535977030,
  6903. 4236805024,
  6904. 3251091107,
  6905. 2132092099,
  6906. 1774941330,
  6907. 1199868427,
  6908. 1452454533,
  6909. 157007616,
  6910. 2904115357,
  6911. 342012276,
  6912. 595725824,
  6913. 1480756522,
  6914. 206960106,
  6915. 497939518,
  6916. 591360097,
  6917. 863170706,
  6918. 2375253569,
  6919. 3596610801,
  6920. 1814182875,
  6921. 2094937945,
  6922. 3421402208,
  6923. 1082520231,
  6924. 3463918190,
  6925. 2785509508,
  6926. 435703966,
  6927. 3908032597,
  6928. 1641649973,
  6929. 2842273706,
  6930. 3305899714,
  6931. 1510255612,
  6932. 2148256476,
  6933. 2655287854,
  6934. 3276092548,
  6935. 4258621189,
  6936. 236887753,
  6937. 3681803219,
  6938. 274041037,
  6939. 1734335097,
  6940. 3815195456,
  6941. 3317970021,
  6942. 1899903192,
  6943. 1026095262,
  6944. 4050517792,
  6945. 356393447,
  6946. 2410691914,
  6947. 3873677099,
  6948. 3682840055
  6949. ],
  6950. [
  6951. 3913112168,
  6952. 2491498743,
  6953. 4132185628,
  6954. 2489919796,
  6955. 1091903735,
  6956. 1979897079,
  6957. 3170134830,
  6958. 3567386728,
  6959. 3557303409,
  6960. 857797738,
  6961. 1136121015,
  6962. 1342202287,
  6963. 507115054,
  6964. 2535736646,
  6965. 337727348,
  6966. 3213592640,
  6967. 1301675037,
  6968. 2528481711,
  6969. 1895095763,
  6970. 1721773893,
  6971. 3216771564,
  6972. 62756741,
  6973. 2142006736,
  6974. 835421444,
  6975. 2531993523,
  6976. 1442658625,
  6977. 3659876326,
  6978. 2882144922,
  6979. 676362277,
  6980. 1392781812,
  6981. 170690266,
  6982. 3921047035,
  6983. 1759253602,
  6984. 3611846912,
  6985. 1745797284,
  6986. 664899054,
  6987. 1329594018,
  6988. 3901205900,
  6989. 3045908486,
  6990. 2062866102,
  6991. 2865634940,
  6992. 3543621612,
  6993. 3464012697,
  6994. 1080764994,
  6995. 553557557,
  6996. 3656615353,
  6997. 3996768171,
  6998. 991055499,
  6999. 499776247,
  7000. 1265440854,
  7001. 648242737,
  7002. 3940784050,
  7003. 980351604,
  7004. 3713745714,
  7005. 1749149687,
  7006. 3396870395,
  7007. 4211799374,
  7008. 3640570775,
  7009. 1161844396,
  7010. 3125318951,
  7011. 1431517754,
  7012. 545492359,
  7013. 4268468663,
  7014. 3499529547,
  7015. 1437099964,
  7016. 2702547544,
  7017. 3433638243,
  7018. 2581715763,
  7019. 2787789398,
  7020. 1060185593,
  7021. 1593081372,
  7022. 2418618748,
  7023. 4260947970,
  7024. 69676912,
  7025. 2159744348,
  7026. 86519011,
  7027. 2512459080,
  7028. 3838209314,
  7029. 1220612927,
  7030. 3339683548,
  7031. 133810670,
  7032. 1090789135,
  7033. 1078426020,
  7034. 1569222167,
  7035. 845107691,
  7036. 3583754449,
  7037. 4072456591,
  7038. 1091646820,
  7039. 628848692,
  7040. 1613405280,
  7041. 3757631651,
  7042. 526609435,
  7043. 236106946,
  7044. 48312990,
  7045. 2942717905,
  7046. 3402727701,
  7047. 1797494240,
  7048. 859738849,
  7049. 992217954,
  7050. 4005476642,
  7051. 2243076622,
  7052. 3870952857,
  7053. 3732016268,
  7054. 765654824,
  7055. 3490871365,
  7056. 2511836413,
  7057. 1685915746,
  7058. 3888969200,
  7059. 1414112111,
  7060. 2273134842,
  7061. 3281911079,
  7062. 4080962846,
  7063. 172450625,
  7064. 2569994100,
  7065. 980381355,
  7066. 4109958455,
  7067. 2819808352,
  7068. 2716589560,
  7069. 2568741196,
  7070. 3681446669,
  7071. 3329971472,
  7072. 1835478071,
  7073. 660984891,
  7074. 3704678404,
  7075. 4045999559,
  7076. 3422617507,
  7077. 3040415634,
  7078. 1762651403,
  7079. 1719377915,
  7080. 3470491036,
  7081. 2693910283,
  7082. 3642056355,
  7083. 3138596744,
  7084. 1364962596,
  7085. 2073328063,
  7086. 1983633131,
  7087. 926494387,
  7088. 3423689081,
  7089. 2150032023,
  7090. 4096667949,
  7091. 1749200295,
  7092. 3328846651,
  7093. 309677260,
  7094. 2016342300,
  7095. 1779581495,
  7096. 3079819751,
  7097. 111262694,
  7098. 1274766160,
  7099. 443224088,
  7100. 298511866,
  7101. 1025883608,
  7102. 3806446537,
  7103. 1145181785,
  7104. 168956806,
  7105. 3641502830,
  7106. 3584813610,
  7107. 1689216846,
  7108. 3666258015,
  7109. 3200248200,
  7110. 1692713982,
  7111. 2646376535,
  7112. 4042768518,
  7113. 1618508792,
  7114. 1610833997,
  7115. 3523052358,
  7116. 4130873264,
  7117. 2001055236,
  7118. 3610705100,
  7119. 2202168115,
  7120. 4028541809,
  7121. 2961195399,
  7122. 1006657119,
  7123. 2006996926,
  7124. 3186142756,
  7125. 1430667929,
  7126. 3210227297,
  7127. 1314452623,
  7128. 4074634658,
  7129. 4101304120,
  7130. 2273951170,
  7131. 1399257539,
  7132. 3367210612,
  7133. 3027628629,
  7134. 1190975929,
  7135. 2062231137,
  7136. 2333990788,
  7137. 2221543033,
  7138. 2438960610,
  7139. 1181637006,
  7140. 548689776,
  7141. 2362791313,
  7142. 3372408396,
  7143. 3104550113,
  7144. 3145860560,
  7145. 296247880,
  7146. 1970579870,
  7147. 3078560182,
  7148. 3769228297,
  7149. 1714227617,
  7150. 3291629107,
  7151. 3898220290,
  7152. 166772364,
  7153. 1251581989,
  7154. 493813264,
  7155. 448347421,
  7156. 195405023,
  7157. 2709975567,
  7158. 677966185,
  7159. 3703036547,
  7160. 1463355134,
  7161. 2715995803,
  7162. 1338867538,
  7163. 1343315457,
  7164. 2802222074,
  7165. 2684532164,
  7166. 233230375,
  7167. 2599980071,
  7168. 2000651841,
  7169. 3277868038,
  7170. 1638401717,
  7171. 4028070440,
  7172. 3237316320,
  7173. 6314154,
  7174. 819756386,
  7175. 300326615,
  7176. 590932579,
  7177. 1405279636,
  7178. 3267499572,
  7179. 3150704214,
  7180. 2428286686,
  7181. 3959192993,
  7182. 3461946742,
  7183. 1862657033,
  7184. 1266418056,
  7185. 963775037,
  7186. 2089974820,
  7187. 2263052895,
  7188. 1917689273,
  7189. 448879540,
  7190. 3550394620,
  7191. 3981727096,
  7192. 150775221,
  7193. 3627908307,
  7194. 1303187396,
  7195. 508620638,
  7196. 2975983352,
  7197. 2726630617,
  7198. 1817252668,
  7199. 1876281319,
  7200. 1457606340,
  7201. 908771278,
  7202. 3720792119,
  7203. 3617206836,
  7204. 2455994898,
  7205. 1729034894,
  7206. 1080033504
  7207. ],
  7208. [
  7209. 976866871,
  7210. 3556439503,
  7211. 2881648439,
  7212. 1522871579,
  7213. 1555064734,
  7214. 1336096578,
  7215. 3548522304,
  7216. 2579274686,
  7217. 3574697629,
  7218. 3205460757,
  7219. 3593280638,
  7220. 3338716283,
  7221. 3079412587,
  7222. 564236357,
  7223. 2993598910,
  7224. 1781952180,
  7225. 1464380207,
  7226. 3163844217,
  7227. 3332601554,
  7228. 1699332808,
  7229. 1393555694,
  7230. 1183702653,
  7231. 3581086237,
  7232. 1288719814,
  7233. 691649499,
  7234. 2847557200,
  7235. 2895455976,
  7236. 3193889540,
  7237. 2717570544,
  7238. 1781354906,
  7239. 1676643554,
  7240. 2592534050,
  7241. 3230253752,
  7242. 1126444790,
  7243. 2770207658,
  7244. 2633158820,
  7245. 2210423226,
  7246. 2615765581,
  7247. 2414155088,
  7248. 3127139286,
  7249. 673620729,
  7250. 2805611233,
  7251. 1269405062,
  7252. 4015350505,
  7253. 3341807571,
  7254. 4149409754,
  7255. 1057255273,
  7256. 2012875353,
  7257. 2162469141,
  7258. 2276492801,
  7259. 2601117357,
  7260. 993977747,
  7261. 3918593370,
  7262. 2654263191,
  7263. 753973209,
  7264. 36408145,
  7265. 2530585658,
  7266. 25011837,
  7267. 3520020182,
  7268. 2088578344,
  7269. 530523599,
  7270. 2918365339,
  7271. 1524020338,
  7272. 1518925132,
  7273. 3760827505,
  7274. 3759777254,
  7275. 1202760957,
  7276. 3985898139,
  7277. 3906192525,
  7278. 674977740,
  7279. 4174734889,
  7280. 2031300136,
  7281. 2019492241,
  7282. 3983892565,
  7283. 4153806404,
  7284. 3822280332,
  7285. 352677332,
  7286. 2297720250,
  7287. 60907813,
  7288. 90501309,
  7289. 3286998549,
  7290. 1016092578,
  7291. 2535922412,
  7292. 2839152426,
  7293. 457141659,
  7294. 509813237,
  7295. 4120667899,
  7296. 652014361,
  7297. 1966332200,
  7298. 2975202805,
  7299. 55981186,
  7300. 2327461051,
  7301. 676427537,
  7302. 3255491064,
  7303. 2882294119,
  7304. 3433927263,
  7305. 1307055953,
  7306. 942726286,
  7307. 933058658,
  7308. 2468411793,
  7309. 3933900994,
  7310. 4215176142,
  7311. 1361170020,
  7312. 2001714738,
  7313. 2830558078,
  7314. 3274259782,
  7315. 1222529897,
  7316. 1679025792,
  7317. 2729314320,
  7318. 3714953764,
  7319. 1770335741,
  7320. 151462246,
  7321. 3013232138,
  7322. 1682292957,
  7323. 1483529935,
  7324. 471910574,
  7325. 1539241949,
  7326. 458788160,
  7327. 3436315007,
  7328. 1807016891,
  7329. 3718408830,
  7330. 978976581,
  7331. 1043663428,
  7332. 3165965781,
  7333. 1927990952,
  7334. 4200891579,
  7335. 2372276910,
  7336. 3208408903,
  7337. 3533431907,
  7338. 1412390302,
  7339. 2931980059,
  7340. 4132332400,
  7341. 1947078029,
  7342. 3881505623,
  7343. 4168226417,
  7344. 2941484381,
  7345. 1077988104,
  7346. 1320477388,
  7347. 886195818,
  7348. 18198404,
  7349. 3786409e3,
  7350. 2509781533,
  7351. 112762804,
  7352. 3463356488,
  7353. 1866414978,
  7354. 891333506,
  7355. 18488651,
  7356. 661792760,
  7357. 1628790961,
  7358. 3885187036,
  7359. 3141171499,
  7360. 876946877,
  7361. 2693282273,
  7362. 1372485963,
  7363. 791857591,
  7364. 2686433993,
  7365. 3759982718,
  7366. 3167212022,
  7367. 3472953795,
  7368. 2716379847,
  7369. 445679433,
  7370. 3561995674,
  7371. 3504004811,
  7372. 3574258232,
  7373. 54117162,
  7374. 3331405415,
  7375. 2381918588,
  7376. 3769707343,
  7377. 4154350007,
  7378. 1140177722,
  7379. 4074052095,
  7380. 668550556,
  7381. 3214352940,
  7382. 367459370,
  7383. 261225585,
  7384. 2610173221,
  7385. 4209349473,
  7386. 3468074219,
  7387. 3265815641,
  7388. 314222801,
  7389. 3066103646,
  7390. 3808782860,
  7391. 282218597,
  7392. 3406013506,
  7393. 3773591054,
  7394. 379116347,
  7395. 1285071038,
  7396. 846784868,
  7397. 2669647154,
  7398. 3771962079,
  7399. 3550491691,
  7400. 2305946142,
  7401. 453669953,
  7402. 1268987020,
  7403. 3317592352,
  7404. 3279303384,
  7405. 3744833421,
  7406. 2610507566,
  7407. 3859509063,
  7408. 266596637,
  7409. 3847019092,
  7410. 517658769,
  7411. 3462560207,
  7412. 3443424879,
  7413. 370717030,
  7414. 4247526661,
  7415. 2224018117,
  7416. 4143653529,
  7417. 4112773975,
  7418. 2788324899,
  7419. 2477274417,
  7420. 1456262402,
  7421. 2901442914,
  7422. 1517677493,
  7423. 1846949527,
  7424. 2295493580,
  7425. 3734397586,
  7426. 2176403920,
  7427. 1280348187,
  7428. 1908823572,
  7429. 3871786941,
  7430. 846861322,
  7431. 1172426758,
  7432. 3287448474,
  7433. 3383383037,
  7434. 1655181056,
  7435. 3139813346,
  7436. 901632758,
  7437. 1897031941,
  7438. 2986607138,
  7439. 3066810236,
  7440. 3447102507,
  7441. 1393639104,
  7442. 373351379,
  7443. 950779232,
  7444. 625454576,
  7445. 3124240540,
  7446. 4148612726,
  7447. 2007998917,
  7448. 544563296,
  7449. 2244738638,
  7450. 2330496472,
  7451. 2058025392,
  7452. 1291430526,
  7453. 424198748,
  7454. 50039436,
  7455. 29584100,
  7456. 3605783033,
  7457. 2429876329,
  7458. 2791104160,
  7459. 1057563949,
  7460. 3255363231,
  7461. 3075367218,
  7462. 3463963227,
  7463. 1469046755,
  7464. 985887462
  7465. ]
  7466. ];
  7467. var h = {
  7468. pbox: [],
  7469. sbox: []
  7470. };
  7471. function p(S, v) {
  7472. let x = v >> 24 & 255, b = v >> 16 & 255, E = v >> 8 & 255, _ = v & 255, y = S.sbox[0][x] + S.sbox[1][b];
  7473. return y = y ^ S.sbox[2][E], y = y + S.sbox[3][_], y;
  7474. }
  7475. function d(S, v, x) {
  7476. let b = v, E = x, _;
  7477. for (let y = 0; y < c; ++y)
  7478. b = b ^ S.pbox[y], E = p(S, b) ^ E, _ = b, b = E, E = _;
  7479. return _ = b, b = E, E = _, E = E ^ S.pbox[c], b = b ^ S.pbox[c + 1], { left: b, right: E };
  7480. }
  7481. function f(S, v, x) {
  7482. let b = v, E = x, _;
  7483. for (let y = c + 1; y > 1; --y)
  7484. b = b ^ S.pbox[y], E = p(S, b) ^ E, _ = b, b = E, E = _;
  7485. return _ = b, b = E, E = _, E = E ^ S.pbox[1], b = b ^ S.pbox[0], { left: b, right: E };
  7486. }
  7487. function m(S, v, x) {
  7488. for (let A = 0; A < 4; A++) {
  7489. S.sbox[A] = [];
  7490. for (let R = 0; R < 256; R++)
  7491. S.sbox[A][R] = u[A][R];
  7492. }
  7493. let b = 0;
  7494. for (let A = 0; A < c + 2; A++)
  7495. S.pbox[A] = o[A] ^ v[b], b++, b >= x && (b = 0);
  7496. let E = 0, _ = 0, y = 0;
  7497. for (let A = 0; A < c + 2; A += 2)
  7498. y = d(S, E, _), E = y.left, _ = y.right, S.pbox[A] = E, S.pbox[A + 1] = _;
  7499. for (let A = 0; A < 4; A++)
  7500. for (let R = 0; R < 256; R += 2)
  7501. y = d(S, E, _), E = y.left, _ = y.right, S.sbox[A][R] = E, S.sbox[A][R + 1] = _;
  7502. return !0;
  7503. }
  7504. var l = n.Blowfish = s.extend({
  7505. _doReset: function() {
  7506. if (this._keyPriorReset !== this._key) {
  7507. var S = this._keyPriorReset = this._key, v = S.words, x = S.sigBytes / 4;
  7508. m(h, v, x);
  7509. }
  7510. },
  7511. encryptBlock: function(S, v) {
  7512. var x = d(h, S[v], S[v + 1]);
  7513. S[v] = x.left, S[v + 1] = x.right;
  7514. },
  7515. decryptBlock: function(S, v) {
  7516. var x = f(h, S[v], S[v + 1]);
  7517. S[v] = x.left, S[v + 1] = x.right;
  7518. },
  7519. blockSize: 64 / 32,
  7520. keySize: 128 / 32,
  7521. ivSize: 64 / 32
  7522. });
  7523. t.Blowfish = s._createHelper(l);
  7524. }(), e.Blowfish;
  7525. });
  7526. }(Pr)), Pr.exports;
  7527. }
  7528. (function(r, a) {
  7529. (function(e, t, i) {
  7530. r.exports = t(ne(), Ci(), Vo(), Oo(), Ot(), Uo(), Ut(), hn(), Xr(), Ho(), dn(), jo(), zo(), Wo(), Yr(), $o(), yt(), ye(), Ko(), qo(), Jo(), Go(), Xo(), Yo(), Zo(), Qo(), e0(), t0(), i0(), r0(), s0(), a0(), n0(), o0(), c0());
  7531. })(ie, function(e) {
  7532. return e;
  7533. });
  7534. })(un);
  7535. var u0 = un.exports;
  7536. const ai = /* @__PURE__ */ ko(u0);
  7537. function h0(r) {
  7538. return ai.MD5(r).toString().toUpperCase();
  7539. }
  7540. function d0(r, a, e, t, i, s, n, c) {
  7541. var o;
  7542. let u = "";
  7543. s.set("x-log-apiversion", "0.6.0"), s.set("x-log-signaturemethod", "hmac-sha1"), u += r + `
  7544. ` + n + `
  7545. ` + ((o = s.get("Content-Type")) != null ? o : "") + `
  7546. ` + c + `
  7547. `;
  7548. const h = (m, l) => m[0].localeCompare(l[0]), p = (m) => m[0].startsWith("x-log-") || m[0].startsWith("x-acs-");
  7549. try {
  7550. const m = [...s.entries()].filter(p).sort(h).map((l) => l[0] + ":" + l[1] + `
  7551. `).join("");
  7552. u += m;
  7553. } catch (m) {
  7554. }
  7555. u += a, i.size > 0 && (u += "?");
  7556. try {
  7557. u += [...i.entries()].sort(h).map((m) => m[0] + "=" + m[1]).join("&");
  7558. } catch (m) {
  7559. }
  7560. const d = ai.HmacSHA1(u, t).toString(ai.enc.Base64), f = "LOG " + e + ":" + d;
  7561. return s.set("Authorization", f), s.set("x-log-date", c), f;
  7562. }
  7563. var l0 = (r, a, e) => new Promise((t, i) => {
  7564. var s = (o) => {
  7565. try {
  7566. c(e.next(o));
  7567. } catch (u) {
  7568. i(u);
  7569. }
  7570. }, n = (o) => {
  7571. try {
  7572. c(e.throw(o));
  7573. } catch (u) {
  7574. i(u);
  7575. }
  7576. }, c = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(s, n);
  7577. c((e = e.apply(r, a)).next());
  7578. });
  7579. function f0(r) {
  7580. return l0(this, null, function* () {
  7581. const a = /* @__PURE__ */ new Date();
  7582. if (r.refreshSTSTokenInterval || (r.refreshSTSTokenInterval = 3e5), !r.stsTokenFreshTime || +a - r.stsTokenFreshTime >= r.refreshSTSTokenInterval) {
  7583. r.stsTokenFreshTime = a;
  7584. try {
  7585. yield r.refreshSTSToken();
  7586. } catch (e) {
  7587. typeof console.error == "function" && console.error(`Some error occured during excuting refreshSTSToken, see:
  7588. ` + e);
  7589. }
  7590. }
  7591. return null;
  7592. });
  7593. }
  7594. var p0 = (r, a, e) => new Promise((t, i) => {
  7595. var s = (o) => {
  7596. try {
  7597. c(e.next(o));
  7598. } catch (u) {
  7599. i(u);
  7600. }
  7601. }, n = (o) => {
  7602. try {
  7603. c(e.throw(o));
  7604. } catch (u) {
  7605. i(u);
  7606. }
  7607. }, c = (o) => o.done ? t(o.value) : Promise.resolve(o.value).then(s, n);
  7608. c((e = e.apply(r, a)).next());
  7609. });
  7610. function Zr(r) {
  7611. return {
  7612. transString: function(a) {
  7613. let e = {}, t = 0, i = !1;
  7614. for (let s in a) {
  7615. if ((s === "time" || s === "__time__") && typeof a[s] == "number") {
  7616. t = a[s], i = !0;
  7617. continue;
  7618. }
  7619. typeof a[s] == "object" ? e[s] = JSON.stringify(a[s]) : e[s] = String(a[s]);
  7620. }
  7621. return e.__time__ = i ? t : Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3), e;
  7622. },
  7623. process: function(a, e) {
  7624. return p0(this, null, function* () {
  7625. yield f0(r);
  7626. let t = a.slice(a.indexOf("/logstores")), i = e.length, s = h0(e), n = (/* @__PURE__ */ new Date()).toUTCString(), c = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map([
  7627. ["Content-Type", "application/json"],
  7628. ["Content-MD5", s],
  7629. ["x-log-bodyrawsize", i.toString()]
  7630. ]);
  7631. r.securityToken && o.set("x-acs-security-token", r.securityToken), d0("POST", t, r.accessKeyId, r.accessKeySecret, c, o, s, n);
  7632. let u = Object.fromEntries(o);
  7633. return {
  7634. data: e,
  7635. header: u
  7636. };
  7637. });
  7638. }
  7639. };
  7640. }
  7641. typeof window != "undefined" && cn(window, "stsPlugin", Zr);
  7642. var g0 = /d{1,4}|D{3,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|W{1,2}|[LlopSZN]|"[^"]*"|'[^']*'/g, m0 = /\b(?:[A-Z]{1,3}[A-Z][TC])(?:[-+]\d{4})?|((?:Australian )?(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time)\b/g, S0 = /[^-+\dA-Z]/g;
  7643. function Qr(r, a, e, t) {
  7644. if (arguments.length === 1 && typeof r == "string" && !/\d/.test(r) && (a = r, r = void 0), r = r || r === 0 ? r : /* @__PURE__ */ new Date(), r instanceof Date || (r = new Date(r)), isNaN(r))
  7645. throw TypeError("Invalid date");
  7646. a = String(Na[a] || a || Na.default);
  7647. var i = a.slice(0, 4);
  7648. (i === "UTC:" || i === "GMT:") && (a = a.slice(4), e = !0, i === "GMT:" && (t = !0));
  7649. var s = function() {
  7650. return e ? "getUTC" : "get";
  7651. }, n = function() {
  7652. return r[s() + "Date"]();
  7653. }, c = function() {
  7654. return r[s() + "Day"]();
  7655. }, o = function() {
  7656. return r[s() + "Month"]();
  7657. }, u = function() {
  7658. return r[s() + "FullYear"]();
  7659. }, h = function() {
  7660. return r[s() + "Hours"]();
  7661. }, p = function() {
  7662. return r[s() + "Minutes"]();
  7663. }, d = function() {
  7664. return r[s() + "Seconds"]();
  7665. }, f = function() {
  7666. return r[s() + "Milliseconds"]();
  7667. }, m = function() {
  7668. return e ? 0 : r.getTimezoneOffset();
  7669. }, l = function() {
  7670. return x0(r);
  7671. }, S = function() {
  7672. return v0(r);
  7673. }, v = { d: function() {
  7674. return n();
  7675. }, dd: function() {
  7676. return Ke(n());
  7677. }, ddd: function() {
  7678. return Oe.dayNames[c()];
  7679. }, DDD: function() {
  7680. return Ma({ y: u(), m: o(), d: n(), _: s(), dayName: Oe.dayNames[c()], short: !0 });
  7681. }, dddd: function() {
  7682. return Oe.dayNames[c() + 7];
  7683. }, DDDD: function() {
  7684. return Ma({ y: u(), m: o(), d: n(), _: s(), dayName: Oe.dayNames[c() + 7] });
  7685. }, m: function() {
  7686. return o() + 1;
  7687. }, mm: function() {
  7688. return Ke(o() + 1);
  7689. }, mmm: function() {
  7690. return Oe.monthNames[o()];
  7691. }, mmmm: function() {
  7692. return Oe.monthNames[o() + 12];
  7693. }, yy: function() {
  7694. return String(u()).slice(2);
  7695. }, yyyy: function() {
  7696. return Ke(u(), 4);
  7697. }, h: function() {
  7698. return h() % 12 || 12;
  7699. }, hh: function() {
  7700. return Ke(h() % 12 || 12);
  7701. }, H: function() {
  7702. return h();
  7703. }, HH: function() {
  7704. return Ke(h());
  7705. }, M: function() {
  7706. return p();
  7707. }, MM: function() {
  7708. return Ke(p());
  7709. }, s: function() {
  7710. return d();
  7711. }, ss: function() {
  7712. return Ke(d());
  7713. }, l: function() {
  7714. return Ke(f(), 3);
  7715. }, L: function() {
  7716. return Ke(Math.floor(f() / 10));
  7717. }, t: function() {
  7718. return h() < 12 ? Oe.timeNames[0] : Oe.timeNames[1];
  7719. }, tt: function() {
  7720. return h() < 12 ? Oe.timeNames[2] : Oe.timeNames[3];
  7721. }, T: function() {
  7722. return h() < 12 ? Oe.timeNames[4] : Oe.timeNames[5];
  7723. }, TT: function() {
  7724. return h() < 12 ? Oe.timeNames[6] : Oe.timeNames[7];
  7725. }, Z: function() {
  7726. return t ? "GMT" : e ? "UTC" : b0(r);
  7727. }, o: function() {
  7728. return (m() > 0 ? "-" : "+") + Ke(Math.floor(Math.abs(m()) / 60) * 100 + Math.abs(m()) % 60, 4);
  7729. }, p: function() {
  7730. return (m() > 0 ? "-" : "+") + Ke(Math.floor(Math.abs(m()) / 60), 2) + ":" + Ke(Math.floor(Math.abs(m()) % 60), 2);
  7731. }, S: function() {
  7732. return ["th", "st", "nd", "rd"][n() % 10 > 3 ? 0 : (n() % 100 - n() % 10 != 10) * n() % 10];
  7733. }, W: function() {
  7734. return l();
  7735. }, WW: function() {
  7736. return Ke(l());
  7737. }, N: function() {
  7738. return S();
  7739. } };
  7740. return a.replace(g0, function(x) {
  7741. return x in v ? v[x]() : x.slice(1, x.length - 1);
  7742. });
  7743. }
  7744. var Na = { default: "ddd mmm dd yyyy HH:MM:ss", shortDate: "m/d/yy", paddedShortDate: "mm/dd/yyyy", mediumDate: "mmm d, yyyy", longDate: "mmmm d, yyyy", fullDate: "dddd, mmmm d, yyyy", shortTime: "h:MM TT", mediumTime: "h:MM:ss TT", longTime: "h:MM:ss TT Z", isoDate: "yyyy-mm-dd", isoTime: "HH:MM:ss", isoDateTime: "yyyy-mm-dd'T'HH:MM:sso", isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'", expiresHeaderFormat: "ddd, dd mmm yyyy HH:MM:ss Z" }, Oe = { dayNames: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], monthNames: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], timeNames: ["a", "p", "am", "pm", "A", "P", "AM", "PM"] }, Ke = function(a) {
  7745. var e = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 2;
  7746. return String(a).padStart(e, "0");
  7747. }, Ma = function(a) {
  7748. var e = a.y, t = a.m, i = a.d, s = a._, n = a.dayName, c = a.short, o = c === void 0 ? !1 : c, u = /* @__PURE__ */ new Date(), h = /* @__PURE__ */ new Date();
  7749. h.setDate(h[s + "Date"]() - 1);
  7750. var p = /* @__PURE__ */ new Date();
  7751. p.setDate(p[s + "Date"]() + 1);
  7752. var d = function() {
  7753. return u[s + "Date"]();
  7754. }, f = function() {
  7755. return u[s + "Month"]();
  7756. }, m = function() {
  7757. return u[s + "FullYear"]();
  7758. }, l = function() {
  7759. return h[s + "Date"]();
  7760. }, S = function() {
  7761. return h[s + "Month"]();
  7762. }, v = function() {
  7763. return h[s + "FullYear"]();
  7764. }, x = function() {
  7765. return p[s + "Date"]();
  7766. }, b = function() {
  7767. return p[s + "Month"]();
  7768. }, E = function() {
  7769. return p[s + "FullYear"]();
  7770. };
  7771. return m() === e && f() === t && d() === i ? o ? "Tdy" : "Today" : v() === e && S() === t && l() === i ? o ? "Ysd" : "Yesterday" : E() === e && b() === t && x() === i ? o ? "Tmw" : "Tomorrow" : n;
  7772. }, x0 = function(a) {
  7773. var e = new Date(a.getFullYear(), a.getMonth(), a.getDate());
  7774. e.setDate(e.getDate() - (e.getDay() + 6) % 7 + 3);
  7775. var t = new Date(e.getFullYear(), 0, 4);
  7776. t.setDate(t.getDate() - (t.getDay() + 6) % 7 + 3);
  7777. var i = e.getTimezoneOffset() - t.getTimezoneOffset();
  7778. e.setHours(e.getHours() - i);
  7779. var s = (e - t) / (864e5 * 7);
  7780. return 1 + Math.floor(s);
  7781. }, v0 = function(a) {
  7782. var e = a.getDay();
  7783. return e === 0 && (e = 7), e;
  7784. }, b0 = function(a) {
  7785. return (String(a).match(m0) || [""]).pop().replace(S0, "").replace(/GMT\+0000/g, "UTC");
  7786. };
  7787. const { BrowserUtil: E0 } = le, jt = {
  7788. EdgeHTML: "EdgeHTML",
  7789. Blink: "Blink",
  7790. Trident: "Trident",
  7791. Gecko: "Gecko",
  7792. WebKit: "WebKit"
  7793. }, pi = (r, a) => {
  7794. const e = a.match(r);
  7795. return e && e.length > 0 && e[1] || "";
  7796. }, _0 = [
  7797. /* EdgeHTML */
  7798. {
  7799. test: [/\sedg\//i, [/edg([ea]|ios)/i]],
  7800. describe(r) {
  7801. if (/\sedg\//i.test(r))
  7802. return {
  7803. name: jt.Blink
  7804. };
  7805. const e = pi(/edge\/(\d+(\.?_?\d+)+)/i, r);
  7806. return {
  7807. name: jt.EdgeHTML,
  7808. version: e
  7809. };
  7810. }
  7811. },
  7812. /* Trident */
  7813. {
  7814. test: [/trident/i],
  7815. describe(r) {
  7816. const a = {
  7817. name: jt.Trident
  7818. }, e = pi(/trident\/(\d+(\.?_?\d+)+)/i, r);
  7819. return e && (a.version = e), a;
  7820. }
  7821. },
  7822. /* Gecko */
  7823. {
  7824. test(r) {
  7825. const a = /gecko/i.test(r), e = /like gecko/i.test(r);
  7826. return a && !e;
  7827. },
  7828. describe(r) {
  7829. const a = {
  7830. name: jt.Gecko
  7831. }, e = pi(/gecko\/(\d+(\.?_?\d+)+)/i, r);
  7832. return e && (a.version = e), a;
  7833. }
  7834. },
  7835. /* Blink */
  7836. {
  7837. test: [/(apple)?webkit\/537\.36/i],
  7838. describe() {
  7839. return {
  7840. name: jt.Blink
  7841. };
  7842. }
  7843. },
  7844. /* WebKit */
  7845. {
  7846. test: [/(apple)?webkit/i],
  7847. describe(r) {
  7848. const a = {
  7849. name: jt.WebKit
  7850. }, e = pi(/webkit\/(\d+(\.?_?\d+)+)/i, r);
  7851. return e && (a.version = e), a;
  7852. }
  7853. }
  7854. ], es = (r, a) => r.find((e) => {
  7855. if (typeof e.test == "function")
  7856. return e.test(a);
  7857. if (Array.isArray(e.test))
  7858. return e.test.some((t) => typeof t == "string" ? a.indexOf(t) > -1 : t instanceof RegExp ? t.test(a) : !1);
  7859. }), A0 = () => {
  7860. try {
  7861. const r = navigator.userAgent || "", a = es(_0, r);
  7862. if (a) {
  7863. const e = a.describe(r);
  7864. return `${e.name}/${e.version || E0.browserVersion}`;
  7865. }
  7866. } catch (r) {
  7867. }
  7868. return navigator.userAgent;
  7869. }, y0 = [
  7870. {
  7871. test: ["wow64", "win64", "x64"],
  7872. describe() {
  7873. return "amd64";
  7874. }
  7875. },
  7876. {
  7877. test: ["i686", "x86"],
  7878. describe() {
  7879. return "x86";
  7880. }
  7881. },
  7882. {
  7883. test: ["aarch64", "arm64"],
  7884. describe() {
  7885. return "arm64";
  7886. }
  7887. },
  7888. {
  7889. test: ["arm"],
  7890. describe() {
  7891. return "arm";
  7892. }
  7893. }
  7894. ], ln = () => {
  7895. let r = "unknown";
  7896. try {
  7897. const a = navigator.userAgent || "", e = es(y0, a);
  7898. if (!e)
  7899. return r;
  7900. r = e.describe(a);
  7901. } catch (a) {
  7902. }
  7903. return r;
  7904. }, C0 = [
  7905. {
  7906. test: [/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i, /samsung[- ]([-\w]+)/i, /sec-(sgh\w+)/i],
  7907. describe() {
  7908. return "Samsung";
  7909. }
  7910. },
  7911. {
  7912. test: [/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i, /\((ipad);[-\w\),; ]+apple/i, /(macintosh);/i],
  7913. describe() {
  7914. return "Apple";
  7915. }
  7916. },
  7917. {
  7918. test: [/(?:huawei)([-\w ]+)[;\)]/i, /\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],
  7919. describe() {
  7920. return "Huawei";
  7921. }
  7922. },
  7923. {
  7924. test: [/(?:honor)([-\w ]+)[;\)]/i],
  7925. describe() {
  7926. return "Honor";
  7927. }
  7928. },
  7929. {
  7930. test: [
  7931. /\b(poco[\w ]+|m2\d{3}j\d\d[a-z]{2})(?: bui|\))/i,
  7932. // Xiaomi POCO
  7933. /\b; (\w+) build\/hm\1/i,
  7934. // Xiaomi Hongmi 'numeric' models
  7935. /\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,
  7936. // Xiaomi Hongmi
  7937. /\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,
  7938. // Xiaomi Redmi
  7939. /oid[^\)]+; (m?[12][0-389][01]\w{3,6}[c-y])( bui|; wv|\))/i,
  7940. // Xiaomi Redmi 'numeric' models
  7941. /\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i
  7942. // Xiaomi Mi
  7943. ],
  7944. describe() {
  7945. return "Xiaomi";
  7946. }
  7947. },
  7948. {
  7949. test: [/; (\w+) bui.+ oppo/i, /\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],
  7950. describe() {
  7951. return "Oppo";
  7952. }
  7953. },
  7954. {
  7955. test: [/vivo (\w+)(?: bui|\))/i, /\b(v[12]\d{3}\w?[at])(?: bui|;)/i],
  7956. describe() {
  7957. return "Vivo";
  7958. }
  7959. },
  7960. {
  7961. test: [/\b(rmx[1-3]\d{3})(?: bui|;|\))/i],
  7962. describe() {
  7963. return "Realme";
  7964. }
  7965. },
  7966. {
  7967. test: [
  7968. /(pixel c)\b/i,
  7969. // Google Pixel C
  7970. /droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i
  7971. // Google Pixel
  7972. ],
  7973. describe() {
  7974. return "Google";
  7975. }
  7976. },
  7977. {
  7978. test: [
  7979. /(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,
  7980. /(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i
  7981. // Alcatel/GeeksPhone/Nexian/Panasonic/Sony
  7982. ],
  7983. describe() {
  7984. return "ZTE";
  7985. }
  7986. },
  7987. {
  7988. test: [/droid.+; (m[1-5] note) bui/i, /\bmz-([-\w]{2,})/i],
  7989. describe() {
  7990. return "Meizu";
  7991. }
  7992. }
  7993. ], R0 = () => {
  7994. let r = "Unknown";
  7995. try {
  7996. const a = navigator.userAgent || "", e = es(C0, a);
  7997. if (!e)
  7998. return r;
  7999. r = e.describe(a);
  8000. } catch (a) {
  8001. }
  8002. return r;
  8003. }, { BrowserUtil: La, SystenUtil: Fa } = le, I0 = ln(), w0 = "woMMssV6jmyol9fr", D0 = 200, gi = 10 * 60 * 1e3, mi = {
  8004. host: "cn-hangzhou.log.aliyuncs.com",
  8005. // 所在地域的服务入口。例如cn-hangzhou.log.aliyuncs.com
  8006. project: "alivc-aio",
  8007. // Project名称。
  8008. logstore: "logger",
  8009. // Logstore名称。
  8010. time: 10,
  8011. // 发送日志的时间间隔,默认是10秒。
  8012. count: 10
  8013. // 发送日志的数量大小,默认是10条。
  8014. };
  8015. function kr() {
  8016. return Qr(/* @__PURE__ */ new Date(), "HH:MM:ss.l");
  8017. }
  8018. function Va() {
  8019. return Qr(/* @__PURE__ */ new Date(), "isoDate");
  8020. }
  8021. var fn = /* @__PURE__ */ ((r) => (r[r.DEBUG = 0] = "DEBUG", r[r.INFO = 1] = "INFO", r[r.API = 2] = "API", r[r.WARNING = 3] = "WARNING", r[r.ERROR = 4] = "ERROR", r[r.NONE = 5] = "NONE", r))(fn || {});
  8022. class T0 {
  8023. constructor() {
  8024. g(this, "tracker");
  8025. g(this, "slsPlugin");
  8026. g(this, "stsData");
  8027. g(this, "stsExpiration", Date.now());
  8028. g(this, "clientId", rt());
  8029. g(this, "bSesid", rt());
  8030. g(this, "logLevel", 3);
  8031. g(this, "appId", "");
  8032. g(this, "sessionId", "");
  8033. g(this, "logCache", []);
  8034. g(this, "updateTaskTimer");
  8035. g(this, "endReported", !0);
  8036. // 是否已上传结束事件,避免重复
  8037. g(this, "logSequence", 0);
  8038. g(this, "sendLogBeforeUnload", (a) => w(this, null, function* () {
  8039. if (!this.slsPlugin)
  8040. return;
  8041. this.logSequence += 1, a.unshift(
  8042. this.getLogParams(710203, {
  8043. log: `[${Va()} ${kr()}] [INF] beforeunload`,
  8044. stat_log_seq: this.logSequence
  8045. })
  8046. );
  8047. const e = `https://${mi.project}.${mi.host}/logstores/${mi.logstore}`, t = {
  8048. __logs__: a.map((n) => this.slsPlugin.transString(n))
  8049. }, { data: i, header: s } = yield this.slsPlugin.process(e, JSON.stringify(t));
  8050. fetch(e, {
  8051. keepalive: !0,
  8052. method: "POST",
  8053. headers: s,
  8054. body: i
  8055. });
  8056. }));
  8057. g(this, "logMethod", (a, e = console.log) => (...t) => {
  8058. let i = kr();
  8059. this.logLevel <= a && e(i, ...t);
  8060. let s = He.paramArrayToString(t);
  8061. a > 0 && this.addLog(s);
  8062. });
  8063. // debug level message
  8064. g(this, "d", this.logMethod(0, console.debug));
  8065. g(this, "i", this.logMethod(
  8066. 1
  8067. /* INFO */
  8068. ));
  8069. g(this, "w", this.logMethod(3, console.warn));
  8070. g(this, "e", this.logMethod(4, (...a) => {
  8071. const [e, ...t] = a;
  8072. console.error(e, "<error>", t);
  8073. }));
  8074. g(this, "ev", this.logMethod(
  8075. 2
  8076. /* API */
  8077. ));
  8078. g(this, "a", this.logMethod(2, (...a) => {
  8079. const [e, ...t] = a;
  8080. if (t.length > 2) {
  8081. const i = `${t[1]}`;
  8082. i.startsWith("__g__") && console.group(`${i.substring(5)}_${t[2]}`);
  8083. }
  8084. console.log(e, ...t);
  8085. }));
  8086. g(this, "ar", this.logMethod(2, (...a) => {
  8087. const [e, ...t] = a;
  8088. console.log(e, ...t), t.length > 2 && `${t[1]}`.startsWith("__g__") && console.groupEnd();
  8089. }));
  8090. g(this, "ae", this.logMethod(2, (...a) => {
  8091. const [e, ...t] = a;
  8092. console.error(e, "<error>", ...t), t.length > 2 && `${t[1]}`.startsWith("__g__") && console.groupEnd();
  8093. }));
  8094. window.addEventListener("beforeunload", () => {
  8095. this.reportEnd(!0);
  8096. });
  8097. }
  8098. init() {
  8099. this.reset(), this.startSTSUpdateTask();
  8100. }
  8101. destroy() {
  8102. this.updateTaskTimer && clearTimeout(this.updateTaskTimer);
  8103. }
  8104. reset() {
  8105. this.bSesid = rt(), this.endReported = !0, this.logSequence = 0, this.appId = "", this.sessionId = "";
  8106. }
  8107. startSTSUpdateTask() {
  8108. return w(this, null, function* () {
  8109. this.updateTaskTimer && clearTimeout(this.updateTaskTimer);
  8110. try {
  8111. const a = yield this.refreshSTSToken();
  8112. this.createTracker(a);
  8113. } catch (a) {
  8114. }
  8115. this.updateTaskTimer = setTimeout(() => {
  8116. this.startSTSUpdateTask();
  8117. }, gi);
  8118. });
  8119. }
  8120. refreshSTSToken() {
  8121. return w(this, null, function* () {
  8122. if (!this.stsData || this.stsExpiration <= Date.now() - gi) {
  8123. const a = yield this.requestSTSToken(), e = new Date(a == null ? void 0 : a.Expiration).getTime() || 0, t = Date.now() + gi;
  8124. this.stsExpiration = Math.max(e, t), this.stsData = a;
  8125. }
  8126. return this.stsData;
  8127. });
  8128. }
  8129. requestSTSToken() {
  8130. const a = Date.now(), e = `${this.clientId}|${w0}|${a}`, i = {
  8131. Action: "AssumeSlsRoleV2",
  8132. AuthInfo: ai.MD5(e).toString(ai.enc.Hex),
  8133. ClientId: this.clientId,
  8134. BusinessType: "logger",
  8135. AppVersion: "1.0",
  8136. Version: "2017-03-14",
  8137. AuthTimestamp: `${a}`,
  8138. TerminalType: "web",
  8139. DeviceModel: "",
  8140. Format: "JSON",
  8141. SignatureMethod: "HMAC-SHA1",
  8142. SignatureVersion: "1.0",
  8143. Timestamp: Qr(a, "isoUtcDateTime")
  8144. // SignatureNonce: generateRandomString(64),
  8145. }, n = `https://slsrole.alicdn.com/?${new URLSearchParams(i).toString()}`;
  8146. return fetch(n).then((c) => c.json()).then((c) => JSON.parse(window.atob(c.SlsAuthResult)));
  8147. }
  8148. createTracker(a) {
  8149. if (!this.tracker) {
  8150. const e = {
  8151. accessKeyId: a.AccessKeyId,
  8152. accessKeySecret: a.AccessKeySecret,
  8153. securityToken: a.SecurityToken,
  8154. refreshSTSTokenInterval: gi,
  8155. stsTokenFreshTime: void 0,
  8156. refreshSTSToken: () => {
  8157. this.refreshSTSToken().then((s) => {
  8158. e.accessKeyId = s.AccessKeyId, e.accessKeySecret = s.AccessKeySecret, e.securityToken = s.SecurityToken;
  8159. }).catch(() => {
  8160. });
  8161. }
  8162. }, t = new Gr(mi), i = Zr(e);
  8163. t.useStsPlugin(i), this.slsPlugin = i, this.tracker = t, this.reportStartAndCache();
  8164. }
  8165. }
  8166. changeConfig(a) {
  8167. a.logLevel !== void 0 && a.logLevel >= 0 && a.logLevel <= 5 && (this.logLevel = a.logLevel);
  8168. }
  8169. // set session id
  8170. setSessionID(a, e) {
  8171. !a || !e || (this.appId = a, this.sessionId = e, this.reportStartAndCache());
  8172. }
  8173. reportStartAndCache() {
  8174. if (!this.tracker || !this.sessionId)
  8175. return;
  8176. this.endReported = !1;
  8177. const a = {
  8178. task_btm_sec: 0,
  8179. task_duration: 0,
  8180. task_etm_sec: 0,
  8181. task_type: "session"
  8182. }, e = [
  8183. this.getLogParams(710201, a),
  8184. this.getLogParams(710202, a)
  8185. ];
  8186. this.tracker.sendBatchLogsImmediate(e), this.logCache.forEach((t) => {
  8187. this.sendLog(t);
  8188. });
  8189. }
  8190. reportEnd(a = !1) {
  8191. if (!this.tracker || !this.sessionId || this.endReported) {
  8192. this.reset();
  8193. return;
  8194. }
  8195. const e = {
  8196. task_btm_sec: 0,
  8197. task_duration: 0,
  8198. task_etm_sec: 0,
  8199. task_type: "session"
  8200. }, t = [
  8201. this.getLogParams(710204, e),
  8202. this.getLogParams(710205, e)
  8203. ];
  8204. a ? this.sendLogBeforeUnload(t) : (this.tracker.sendBatchLogsImmediate(t), this.endReported = !0), this.reset();
  8205. }
  8206. getLogParams(a, e) {
  8207. return J({
  8208. appid: `${window.location.host}`,
  8209. // 其他端是应用的包id,不是rtcsdk的appId
  8210. appid_list: this.appId,
  8211. // rtcsdk的appId
  8212. appver: "",
  8213. b_sesid: this.bSesid,
  8214. // 与其他端对齐,用于该字段标记某个上传任务
  8215. biz_type: "rtc",
  8216. cpu_info: I0,
  8217. db: La.browserName,
  8218. dm: La.browserVersion,
  8219. install_uuid: this.clientId,
  8220. logger_v: "0.0.1",
  8221. os: Fa.systemName,
  8222. osv: Fa.systemVersion,
  8223. p_sesid: this.bSesid,
  8224. // 与其他端对齐,用于该字段标记某个上传任务
  8225. sdk_version: yi,
  8226. sdkname: "AliRTCSdk",
  8227. stm: Date.now(),
  8228. tar_pf: "web",
  8229. traceid: this.sessionId,
  8230. // 与其他端对齐,用于traceid标记某个会话
  8231. event_id: a
  8232. }, e || {});
  8233. }
  8234. sendLog(a) {
  8235. if (!this.tracker || !this.sessionId)
  8236. return;
  8237. this.logSequence += 1;
  8238. const e = this.getLogParams(710203, {
  8239. log: a,
  8240. stat_log_seq: this.logSequence
  8241. });
  8242. this.tracker.send(e);
  8243. }
  8244. addLog(a) {
  8245. const e = kr(), i = `[${Va()} ${e}] ${a}`;
  8246. !this.sessionId || !this.tracker ? (this.logCache.push(i), this.logCache.length >= D0 && this.logCache.shift()) : this.sendLog(i);
  8247. }
  8248. }
  8249. class O {
  8250. static getLogger() {
  8251. return this.logger || (this.logger = new T0()), this.logger;
  8252. }
  8253. static init() {
  8254. this.getLogger().init();
  8255. }
  8256. static destroy() {
  8257. this.getLogger().destroy();
  8258. }
  8259. static setLogLevel(a) {
  8260. this.getLogger().changeConfig({ logLevel: a });
  8261. }
  8262. static setSessionID(a, e) {
  8263. this.getLogger().setSessionID(a, e);
  8264. }
  8265. static reportEnd() {
  8266. this.getLogger().reportEnd();
  8267. }
  8268. static interface(...a) {
  8269. this.getLogger().a("[API]", ...a);
  8270. }
  8271. static interfaceResult(a, e, t, ...i) {
  8272. t ? this.getLogger().ar("[ARE]", a, e, ...i) : this.getLogger().ae("[ARE]", a, e, ...i);
  8273. }
  8274. static event(...a) {
  8275. this.getLogger().ev("[EVT]", ...a);
  8276. }
  8277. // debug
  8278. static debug(...a) {
  8279. this.getLogger().d("[DBG]", ...a);
  8280. }
  8281. // info
  8282. static info(...a) {
  8283. this.getLogger().i("[INF]", ...a);
  8284. }
  8285. // warning
  8286. static warn(...a) {
  8287. this.getLogger().w("[WARN]", ...a);
  8288. }
  8289. // error
  8290. static error(...a) {
  8291. this.getLogger().e("[ERR]", ...a);
  8292. }
  8293. }
  8294. g(O, "logger");
  8295. const P0 = (r) => w(void 0, null, function* () {
  8296. const a = new le.SupportUtil();
  8297. let e = {
  8298. support: !1,
  8299. detail: {
  8300. isWebRTCSupported: a.checkMediaDevices() && a.checkWebRtcSupport(),
  8301. isH264DecodeSupported: !1,
  8302. isH264EncodeSupported: !1,
  8303. isScreenShareSupported: !1,
  8304. isSendMediaExtensionMsgSupported: !1,
  8305. isBrowserSupported: !0
  8306. }
  8307. }, t = !1;
  8308. try {
  8309. yield a.isSupport({
  8310. isReceiveVideo: !0
  8311. }), t = !0;
  8312. } catch (i) {
  8313. t = !1, e.detail.isBrowserSupported = a.checkBrowser({ errorCode: 0, message: "" });
  8314. }
  8315. if (e.support = t, a.checkWebRtcSupport() && r !== "sendonly") {
  8316. const i = yield a.checkH264Decode();
  8317. e.detail.isH264DecodeSupported = i, e.support = e.support && i;
  8318. }
  8319. if (a.checkWebRtcSupport() && r !== "recvonly") {
  8320. const i = yield a.checkH264Encode();
  8321. e.detail.isH264EncodeSupported = i, e.support = e.support && i;
  8322. }
  8323. return e.detail.isScreenShareSupported = a.checkWebRtcSupport() && a.checkScreenCapture() && !le.SystenUtil.isAndroid && !le.SystenUtil.isIos, e.detail.isSendMediaExtensionMsgSupported = a.checkWebRtcSupport() && a.checkEncodedTransformSupport(), e;
  8324. }), k0 = () => new le.SupportUtil().checkScreenCapture();
  8325. var be = /* @__PURE__ */ ((r) => (r[r.AliRtcSdkStreamTypeCapture = 0] = "AliRtcSdkStreamTypeCapture", r[r.AliRtcSdkStreamTypeScreen = 1] = "AliRtcSdkStreamTypeScreen", r))(be || {}), B0 = /* @__PURE__ */ ((r) => (r[r.PRE_PROCESSOR = 0] = "PRE_PROCESSOR", r[r.POST_PROCESSOR = 1] = "POST_PROCESSOR", r))(B0 || {}), Ri = /* @__PURE__ */ ((r) => (r[r.AUDIO = 0] = "AUDIO", r[r.VIDEO = 1] = "VIDEO", r[r.BOTH = 2] = "BOTH", r))(Ri || {});
  8326. class Gt extends De {
  8327. constructor(e, t = be.AliRtcSdkStreamTypeCapture, i = 1) {
  8328. super();
  8329. // 扩展名
  8330. g(this, "name");
  8331. // 插件配置
  8332. g(this, "options");
  8333. // 扩展类型,当前均为前置处理
  8334. g(this, "type", 0);
  8335. // 流类型,主流/辅流
  8336. g(this, "streamType");
  8337. // 扩展处理的流类型
  8338. g(this, "trackType");
  8339. // 层级,越小越先执行
  8340. g(this, "zIndex", 1);
  8341. // 是否启用
  8342. g(this, "_isEnable", !0);
  8343. g(this, "lastInputAudioTrack");
  8344. g(this, "lastOutputAudioTrack");
  8345. g(this, "lastInputVideoTrack");
  8346. g(this, "lastOutputVideoTrack");
  8347. // 是否被清空,用于移除 Plugin 后重新添加强制执行
  8348. g(this, "_hasCleared", !0);
  8349. this.name = e, this.streamType = t, this.trackType = i, this.options = this.initOptions;
  8350. }
  8351. get initOptions() {
  8352. return {};
  8353. }
  8354. getOptions() {
  8355. return this.options;
  8356. }
  8357. init() {
  8358. return w(this, null, function* () {
  8359. });
  8360. }
  8361. enable() {
  8362. this._isEnable || (this._isEnable = !0, this.init(), this.emit("enabled"));
  8363. }
  8364. disable() {
  8365. this._isEnable && (this._isEnable = !1, this.clear(), this.emit("disabled"));
  8366. }
  8367. get isEnable() {
  8368. return this._isEnable;
  8369. }
  8370. audioUpdated(e) {
  8371. var t, i;
  8372. return ((t = this.lastInputAudioTrack) == null ? void 0 : t.id) !== ((i = e.currentAudioTrack) == null ? void 0 : i.id);
  8373. }
  8374. videoUpdated(e) {
  8375. var t, i;
  8376. return ((t = this.lastInputVideoTrack) == null ? void 0 : t.id) !== ((i = e.currentVideoTrack) == null ? void 0 : i.id);
  8377. }
  8378. execute(e, t) {
  8379. return w(this, null, function* () {
  8380. const i = this.shouldUpdate(e, t);
  8381. this.lastInputAudioTrack = e.currentAudioTrack, this.lastInputVideoTrack = e.currentVideoTrack, this._hasCleared || i ? (yield this.process(e, t), this._hasCleared = !1) : (this.lastOutputAudioTrack && (this.trackType === 2 || this.trackType === 0) && this.lastOutputAudioTrack && e.updateAudioTrack(this.lastOutputAudioTrack), this.lastOutputVideoTrack && (this.trackType === 2 || this.trackType === 1) && this.lastOutputVideoTrack && e.updateVideoTrack(this.lastOutputVideoTrack)), this.lastOutputAudioTrack = e.currentAudioTrack, this.lastOutputVideoTrack = e.currentVideoTrack;
  8382. });
  8383. }
  8384. // eslint-disable-next-line @ali/no-unused-vars
  8385. clear(e) {
  8386. this._hasCleared = !0, this.lastInputAudioTrack = void 0, this.lastInputVideoTrack = void 0, this.lastOutputAudioTrack = void 0, this.lastOutputVideoTrack = void 0;
  8387. }
  8388. }
  8389. var bi = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingSingle = 0] = "LiveTranscodingSingle", r[r.LiveTranscodingMix = 1] = "LiveTranscodingMix", r))(bi || {}), pn = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingOrigin = 0] = "LiveTranscodingOrigin", r[r.LiveTranscodingAudio = 1] = "LiveTranscodingAudio", r[r.LiveTranscodingVideo = 2] = "LiveTranscodingVideo", r))(pn || {}), ni = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingCamera = 0] = "LiveTranscodingCamera", r[r.LiveTranscodingShareScreen = 1] = "LiveTranscodingShareScreen", r))(ni || {});
  8390. const ii = {
  8391. 0: "camera",
  8392. 1: "shareScreen"
  8393. };
  8394. var gn = /* @__PURE__ */ ((r) => (r[r.LiveTranscoding_Profile_1IN_1080P = 0] = "LiveTranscoding_Profile_1IN_1080P", r[r.LiveTranscoding_Profile_1IN_720P = 1] = "LiveTranscoding_Profile_1IN_720P", r[r.LiveTranscoding_Profile_1IN_360P = 2] = "LiveTranscoding_Profile_1IN_360P", r[r.LiveTranscoding_Profile_2IN_1080P = 3] = "LiveTranscoding_Profile_2IN_1080P", r[r.LiveTranscoding_Profile_2IN_720P = 4] = "LiveTranscoding_Profile_2IN_720P", r[r.LiveTranscoding_Profile_2IN_360P = 5] = "LiveTranscoding_Profile_2IN_360P", r[r.LiveTranscoding_Profile_4IN_1080P = 6] = "LiveTranscoding_Profile_4IN_1080P", r[r.LiveTranscoding_Profile_4IN_720P = 7] = "LiveTranscoding_Profile_4IN_720P", r[r.LiveTranscoding_Profile_4IN_360P = 8] = "LiveTranscoding_Profile_4IN_360P", r[r.LiveTranscoding_Profile_9IN_1080P = 9] = "LiveTranscoding_Profile_9IN_1080P", r[r.LiveTranscoding_Profile_9IN_720P = 10] = "LiveTranscoding_Profile_9IN_720P", r[r.LiveTranscoding_Profile_9IN_360P = 11] = "LiveTranscoding_Profile_9IN_360P", r[r.LiveTranscoding_Profile_12IN_1080P = 12] = "LiveTranscoding_Profile_12IN_1080P", r[r.LiveTranscoding_Profile_12IN_720P = 13] = "LiveTranscoding_Profile_12IN_720P", r[r.LiveTranscoding_Profile_12IN_360P = 14] = "LiveTranscoding_Profile_12IN_360P", r[r.LiveTranscoding_Profile_16IN_1080P = 15] = "LiveTranscoding_Profile_16IN_1080P", r[r.LiveTranscoding_Profile_16IN_720P = 16] = "LiveTranscoding_Profile_16IN_720P", r[r.LiveTranscoding_Profile_16IN_360P = 17] = "LiveTranscoding_Profile_16IN_360P", r[r.LiveTranscoding_Profile_Mixed = 9999] = "LiveTranscoding_Profile_Mixed", r))(gn || {});
  8395. const N0 = {
  8396. 0: "1IN_1080P",
  8397. 1: "1IN_720P",
  8398. 2: "1IN_360P",
  8399. 3: "2IN_1080P",
  8400. 4: "2IN_720P",
  8401. 5: "2IN_360P",
  8402. 6: "4IN_1080P",
  8403. 7: "4IN_720P",
  8404. 8: "4IN_360P",
  8405. 9: "9IN_1080P",
  8406. 10: "9IN_720P",
  8407. 11: "9IN_360P",
  8408. 12: "12IN_1080P",
  8409. 13: "12IN_720P",
  8410. 14: "12IN_360P",
  8411. 15: "16IN_1080P",
  8412. 16: "16IN_720P",
  8413. 17: "16IN_360P",
  8414. 9999: "Mixed_Audio"
  8415. };
  8416. var ts = /* @__PURE__ */ ((r) => (r[r.LiveTranscoding_HZ_48000 = 48e3] = "LiveTranscoding_HZ_48000", r[r.LiveTranscoding_HZ_44100 = 44100] = "LiveTranscoding_HZ_44100", r[r.LiveTranscoding_HZ_32000 = 32e3] = "LiveTranscoding_HZ_32000", r[r.LiveTranscoding_HZ_16000 = 16e3] = "LiveTranscoding_HZ_16000", r[r.LiveTranscoding_HZ_8000 = 8e3] = "LiveTranscoding_HZ_8000", r))(ts || {}), Ei = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingNoBody = 0] = "LiveTranscodingNoBody", r[r.LiveTranscodingBody = 1] = "LiveTranscodingBody", r))(Ei || {}), Ii = /* @__PURE__ */ ((r) => (r[r.NOTO_SERIF_CJKSC_REGULAR = 0] = "NOTO_SERIF_CJKSC_REGULAR", r[r.ALIBABA_PUHUITI_REGULAR = 1] = "ALIBABA_PUHUITI_REGULAR", r[r.ALIBABA_PUHUITI_BOLD = 2] = "ALIBABA_PUHUITI_BOLD", r[r.ALIBABA_PUHUITI_Heavy = 3] = "ALIBABA_PUHUITI_Heavy", r[r.ALIBABA_PUHUITI_LIGHT = 4] = "ALIBABA_PUHUITI_LIGHT", r[r.ALIBABA_PUHUITI_MEDIUM = 5] = "ALIBABA_PUHUITI_MEDIUM", r))(Ii || {}), mn = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingOrigin = 0] = "LiveTranscodingOrigin", r[r.LiveTranscodingCrop = 1] = "LiveTranscodingCrop", r[r.LiveTranscodingFill = 2] = "LiveTranscodingFill", r))(mn || {}), is = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingNormal = 0] = "LiveTranscodingNormal", r[r.LiveTranscodingVirtualBackground = 1] = "LiveTranscodingVirtualBackground", r))(is || {}), Sn = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingState_IDLE = 0] = "LiveTranscodingState_IDLE", r[r.LiveTranscodingState_CONNNECT = 1] = "LiveTranscodingState_CONNNECT", r[r.LiveTranscodingState_RUNNING = 2] = "LiveTranscodingState_RUNNING", r[r.LiveTranscodingState_RECOVERING = 3] = "LiveTranscodingState_RECOVERING", r[r.LiveTranscodingState_FAILURE = 4] = "LiveTranscodingState_FAILURE", r[r.LiveTranscodingState_END = 5] = "LiveTranscodingState_END", r))(Sn || {}), ht = /* @__PURE__ */ ((r) => (r[r.LiveTranscodingErrorPublishOk = 0] = "LiveTranscodingErrorPublishOk", r[r.LiveTranscodingErrorStreamNotFound = 17825793] = "LiveTranscodingErrorStreamNotFound", r[r.LiveTranscodingErrorStreamAlreadyExist = 17825794] = "LiveTranscodingErrorStreamAlreadyExist", r[r.LiveTranscodingErrorInvalidParam = 17825795] = "LiveTranscodingErrorInvalidParam", r[r.LiveTranscodingErrorInternalError = 17825796] = "LiveTranscodingErrorInternalError", r[r.LiveTranscodingErrorRtmpServerError = 17825797] = "LiveTranscodingErrorRtmpServerError", r[r.LiveTranscodingErrorRtmpStreamUrlError = 17825798] = "LiveTranscodingErrorRtmpStreamUrlError", r[r.LiveTranscodingErrorPublishTimeout = 17825799] = "LiveTranscodingErrorPublishTimeout", r[r.LiveTranscodingErrorNotAuthorized = 17825800] = "LiveTranscodingErrorNotAuthorized", r))(ht || {}), xn = /* @__PURE__ */ ((r) => (r[r.TrascodingPublishTaskStatusStart = 0] = "TrascodingPublishTaskStatusStart", r[r.TrascodingPublishTaskStatusUpdate = 1] = "TrascodingPublishTaskStatusUpdate", r[r.TrascodingPublishTaskStatusStop = 2] = "TrascodingPublishTaskStatusStop", r))(xn || {}), Ue = /* @__PURE__ */ ((r) => (r[r.MPU_TASK_TRANSACTION_START = 0] = "MPU_TASK_TRANSACTION_START", r[r.MPU_TASK_TRANSACTION_UPDATE = 1] = "MPU_TASK_TRANSACTION_UPDATE", r[r.MPU_TASK_TRANSACTION_STOP = 2] = "MPU_TASK_TRANSACTION_STOP", r[r.MPU_TASK_TRANSACTION_LIST = 3] = "MPU_TASK_TRANSACTION_LIST", r[r.MPU_TASK_TRANSACTION_POLLING = 4] = "MPU_TASK_TRANSACTION_POLLING", r[r.MPU_TASK_TRANSACTION_ACKNOWLEDGE = 5] = "MPU_TASK_TRANSACTION_ACKNOWLEDGE", r[r.MPU_TASK_TRANSACTION_END = 6] = "MPU_TASK_TRANSACTION_END", r))(Ue || {});
  8417. const M0 = {
  8418. 0: "/libra/v1/sdk/start-task",
  8419. 1: "/libra/v1/sdk/update-task",
  8420. 2: "/libra/v1/sdk/stop-task",
  8421. 3: "/libra/v1/sdk/list-task",
  8422. 4: "/libra/v1/sdk/polling",
  8423. 5: "/libra/v1/sdk/acknowledge",
  8424. 6: "/"
  8425. };
  8426. class vn {
  8427. //[1,2]
  8428. constructor(a, e, t, i, s, n, c, o) {
  8429. g(this, "videoWidth");
  8430. //(0-1920]
  8431. g(this, "videoHeight");
  8432. //(0-1920]
  8433. g(this, "videoFramerate", 20);
  8434. //[1,60]
  8435. g(this, "videoBitrate", 2e3);
  8436. //[1kbps,10000kbps]
  8437. g(this, "videoGop", 30);
  8438. //[1,60]
  8439. g(this, "audioSamplerate", ts.LiveTranscoding_HZ_44100);
  8440. g(this, "audioBitrate", 500);
  8441. //[8kbps,500kbps]
  8442. g(this, "audioChannels", 1);
  8443. this.videoWidth = a, this.videoHeight = e, t && (this.videoFramerate = t), i && (this.videoBitrate = i), s && (this.videoGop = s), n && (this.audioSamplerate = n), c && (this.audioBitrate = c), o && (this.audioChannels = o);
  8444. }
  8445. }
  8446. const rs = (r) => ((r & 16711680) >> 16) + (r & 65280) + ((r & 255) << 16), Ye = (r = 0, a) => {
  8447. if (a == 0)
  8448. return 0;
  8449. let e = r / a;
  8450. return e < 0 && (e = 0), e > 1 && (e = 1), e;
  8451. };
  8452. class Fr {
  8453. constructor(a, e, t) {
  8454. /*! 旁路模式 */
  8455. g(this, "mixMode", bi.LiveTranscodingSingle);
  8456. /*! 路模式单路参数 */
  8457. g(this, "singleParam");
  8458. /*! 旁路模式混流参数 */
  8459. g(this, "mixParam");
  8460. a && (this.mixMode = a), e && (this.singleParam = e), t && (this.mixParam = t);
  8461. }
  8462. toJson(a, e, t, i, s) {
  8463. const n = {
  8464. appid: e.appId,
  8465. channelid: e.channelId
  8466. };
  8467. if (a === Ue.MPU_TASK_TRANSACTION_POLLING || a === Ue.MPU_TASK_TRANSACTION_LIST || a === Ue.MPU_TASK_TRANSACTION_ACKNOWLEDGE)
  8468. return a === Ue.MPU_TASK_TRANSACTION_ACKNOWLEDGE && (n.messageid = s), n;
  8469. if (n.taskid = t, a !== Ue.MPU_TASK_TRANSACTION_STOP) {
  8470. if (n.mixmode = this.mixMode, i && (n.streamurl = i), this.mixMode === bi.LiveTranscodingSingle) {
  8471. const c = this.singleParam;
  8472. if (c) {
  8473. n.streamtype = c.streamType, c.sourceType === ni.LiveTranscodingShareScreen ? n.sourcetype = ii[c.sourceType] : n.sourcetype = ii[ni.LiveTranscodingCamera];
  8474. const o = [];
  8475. c.userId && o.push(c.userId), n.subspecusers = o;
  8476. }
  8477. } else if (a === Ue.MPU_TASK_TRANSACTION_START || a === Ue.MPU_TASK_TRANSACTION_UPDATE) {
  8478. const c = this.mixParam;
  8479. if (c) {
  8480. c.taskProfile && (n.taskprofile = N0[c.taskProfile]);
  8481. const o = c.encodeParam || new vn(1280, 720);
  8482. let u = o.videoWidth, h = o.videoHeight;
  8483. const p = {};
  8484. Object.keys(o).forEach((f) => {
  8485. const m = o[f];
  8486. m > 0 && (p[f.toLowerCase()] = m);
  8487. }), p.lowbitratehighquality = 0, n.encodeparam = p, n.backgrounds = c.backgrounds.map((f) => f.toJson(u, h)), n.watermarks = c.watermarks.map((f) => f.toJson(u, h)), n.clockwidgets = c.clockWidgets.map((f) => f.toJson(u, h));
  8488. const d = c.users.map((f) => f.userId);
  8489. n.subspecusers = [...new Set(d)], n.layouts = [
  8490. {
  8491. audiomixcount: c.users.length,
  8492. panes: c.users.map(
  8493. (f, m) => f.toJson(m, u, h, c.mediaProcessMode)
  8494. )
  8495. }
  8496. ], n.layoutids = ["0"], n.cropmode = c.cropMode, n.backgroundcolor = rs(c.backgroundColor), n.taskmode = c.mediaProcessMode;
  8497. }
  8498. }
  8499. }
  8500. return n;
  8501. }
  8502. }
  8503. var pt = /* @__PURE__ */ ((r) => (r.pre = "pre", r.prod = "prod", r))(pt || {}), bt = /* @__PURE__ */ ((r) => (r.AliRtcSdkCommunication = "communication", r.AliRtcSdkInteractiveLive = "interactive_live", r.AliRtcSdkInteractiveWithLowLatencyLive = "cdn_live", r))(bt || {}), Nt = /* @__PURE__ */ ((r) => (r.AliRtcSdkInteractive = "interactive", r.AliRtcSdkLive = "live", r))(Nt || {}), dt = /* @__PURE__ */ ((r) => (r[r.AliEngineLocalDeviceTypeUnknown = 0] = "AliEngineLocalDeviceTypeUnknown", r[r.AliEngineLocalDeviceTypeMic = 1] = "AliEngineLocalDeviceTypeMic", r[r.AliEngineLocalDeviceTypeSpeaker = 2] = "AliEngineLocalDeviceTypeSpeaker", r[r.AliEngineLocalDeviceTypeAudioDevice = 3] = "AliEngineLocalDeviceTypeAudioDevice", r[r.AliEngineLocalDeviceTypeCamera = 4] = "AliEngineLocalDeviceTypeCamera", r[r.AliEngineLocalDeviceTypeDisplay = 5] = "AliEngineLocalDeviceTypeDisplay", r[r.AliEngineLocalDeviceTypeVideoDevice = 6] = "AliEngineLocalDeviceTypeVideoDevice", r))(dt || {}), _e = /* @__PURE__ */ ((r) => (r[r.AliEngineLocalDeviceExceptionTypeUnknown = 0] = "AliEngineLocalDeviceExceptionTypeUnknown", r[r.AliEngineLocalDeviceExceptionTypeMicOpenFail = 1] = "AliEngineLocalDeviceExceptionTypeMicOpenFail", r[r.AliEngineLocalDeviceExceptionTypeMicInterrupt = 2] = "AliEngineLocalDeviceExceptionTypeMicInterrupt", r[r.AliEngineLocalDeviceExceptionTypeMicAuthFail = 3] = "AliEngineLocalDeviceExceptionTypeMicAuthFail", r[r.AliEngineLocalDeviceExceptionTypeMicNotAvailable = 4] = "AliEngineLocalDeviceExceptionTypeMicNotAvailable", r[r.AliEngineLocalDeviceExceptionTypeSpeakerOpenFail = 5] = "AliEngineLocalDeviceExceptionTypeSpeakerOpenFail", r[r.AliEngineLocalDeviceExceptionTypeSpeakerInterrupt = 6] = "AliEngineLocalDeviceExceptionTypeSpeakerInterrupt", r[r.AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable = 7] = "AliEngineLocalDeviceExceptionTypeSpeakerNotAvailable", r[r.AliEngineLocalDeviceExceptionTypeAudioDeviceException = 8] = "AliEngineLocalDeviceExceptionTypeAudioDeviceException", r[r.AliEngineLocalDeviceExceptionTypeCameraOpenFail = 9] = "AliEngineLocalDeviceExceptionTypeCameraOpenFail", r[r.AliEngineLocalDeviceExceptionTypeCameraInterrupt = 10] = "AliEngineLocalDeviceExceptionTypeCameraInterrupt", r[r.AliEngineLocalDeviceExceptionTypeCameraAuthFail = 11] = "AliEngineLocalDeviceExceptionTypeCameraAuthFail", r[r.AliEngineLocalDeviceExceptionTypeDisplayException = 12] = "AliEngineLocalDeviceExceptionTypeDisplayException", r[r.AliEngineLocalDeviceExceptionTypeVideoDeviceException = 13] = "AliEngineLocalDeviceExceptionTypeVideoDeviceException", r))(_e || {}), ue = /* @__PURE__ */ ((r) => (r[r.AliRtcConnectionStatusInit = 0] = "AliRtcConnectionStatusInit", r[r.AliRtcConnectionStatusDisconnected = 1] = "AliRtcConnectionStatusDisconnected", r[r.AliRtcConnectionStatusConnecting = 2] = "AliRtcConnectionStatusConnecting", r[r.AliRtcConnectionStatusConnected = 3] = "AliRtcConnectionStatusConnected", r[r.AliRtcConnectionStatusReconnecting = 4] = "AliRtcConnectionStatusReconnecting", r[r.AliRtcConnectionStatusFailed = 5] = "AliRtcConnectionStatusFailed", r))(ue || {}), Wt = /* @__PURE__ */ ((r) => (r[r.AliRtcConnectionChangedDummyReason = 0] = "AliRtcConnectionChangedDummyReason", r[r.AliRtcConnectionMediaPathChanged = 1] = "AliRtcConnectionMediaPathChanged", r[r.AliRtcConnectionSignalingHeartbeatTimeout = 2] = "AliRtcConnectionSignalingHeartbeatTimeout", r[r.AliRtcConnectionSignalingHeartbeatAlive = 3] = "AliRtcConnectionSignalingHeartbeatAlive", r[r.AliRtcConnectionSignalingHttpDnsResolved = 4] = "AliRtcConnectionSignalingHttpDnsResolved", r[r.AliRtcConnectionSignalingHttpDnsFailure = 5] = "AliRtcConnectionSignalingHttpDnsFailure", r[r.AliRtcConnectionSignalingGslbFailure = 6] = "AliRtcConnectionSignalingGslbFailure", r[r.AliRtcConnectionSignalingGslbSuccess = 7] = "AliRtcConnectionSignalingGslbSuccess", r[r.AliRtcConnectionSignalingJoinRoomFailure = 8] = "AliRtcConnectionSignalingJoinRoomFailure", r[r.AliRtcConnectionSignalingJoinRoomSuccess = 9] = "AliRtcConnectionSignalingJoinRoomSuccess", r[r.AliRtcConnectionSignalingLeaveRoom = 10] = "AliRtcConnectionSignalingLeaveRoom", r[r.AliRtcConnectionSignalingConnecting = 11] = "AliRtcConnectionSignalingConnecting", r[r.AliRtcConnectionChangedNetworkInterrupted = 12] = "AliRtcConnectionChangedNetworkInterrupted", r))(Wt || {}), ss = /* @__PURE__ */ ((r) => (r[r.AliRtcUserOfflineQuit = 0] = "AliRtcUserOfflineQuit", r[r.AliRtcUserOfflineDropped = 1] = "AliRtcUserOfflineDropped", r[r.AliRtcUserOfflineBecomeAudience = 2] = "AliRtcUserOfflineBecomeAudience", r))(ss || {}), Xt = /* @__PURE__ */ ((r) => (r[r.AliRtcAudioTrackNo = 0] = "AliRtcAudioTrackNo", r[r.AliRtcAudioTrackMic = 1] = "AliRtcAudioTrackMic", r[r.AliRtcAudioTrackDual = 2] = "AliRtcAudioTrackDual", r))(Xt || {}), se = /* @__PURE__ */ ((r) => (r[r.AliRtcVideoTrackNo = 0] = "AliRtcVideoTrackNo", r[r.AliRtcVideoTrackCamera = 1] = "AliRtcVideoTrackCamera", r[r.AliRtcVideoTrackScreen = 2] = "AliRtcVideoTrackScreen", r[r.AliRtcVideoTrackBoth = 3] = "AliRtcVideoTrackBoth", r))(se || {}), Y = /* @__PURE__ */ ((r) => (r[r.AliRtcStatePublishIdle = 0] = "AliRtcStatePublishIdle", r[r.AliRtcStateNoPublish = 1] = "AliRtcStateNoPublish", r[r.AliRtcStatePublishing = 2] = "AliRtcStatePublishing", r[r.AliRtcStatePublished = 3] = "AliRtcStatePublished", r))(Y || {}), he = /* @__PURE__ */ ((r) => (r[r.AliRtcStateSubscribeIdle = 0] = "AliRtcStateSubscribeIdle", r[r.AliRtcStateNoSubscribe = 1] = "AliRtcStateNoSubscribe", r[r.AliRtcStateSubscribing = 2] = "AliRtcStateSubscribing", r[r.AliRtcStateSubscribed = 3] = "AliRtcStateSubscribed", r))(he || {}), we = /* @__PURE__ */ ((r) => (r[r.AliRtcVideoStreamTypeNone = 0] = "AliRtcVideoStreamTypeNone", r[r.AliRtcVideoStreamTypeHigh = 1] = "AliRtcVideoStreamTypeHigh", r[r.AliRtcVideoStreamTypeLow = 2] = "AliRtcVideoStreamTypeLow", r))(we || {}), oi = /* @__PURE__ */ ((r) => (r[r.CAMERA_INVALID = -1] = "CAMERA_INVALID", r[r.CAMERA_REAR = 0] = "CAMERA_REAR", r[r.CAMERA_FRONT = 1] = "CAMERA_FRONT", r))(oi || {});
  8504. const Oa = 12, Ua = 5e3, $t = class $t extends De {
  8505. constructor(e) {
  8506. super();
  8507. g(this, "ws");
  8508. // websocket对象
  8509. g(this, "socketStatus", 0);
  8510. // websocket当前的连接状态
  8511. g(this, "wsUrl", "");
  8512. // 建立连接时候使用的url
  8513. g(this, "lastConnectStartTime", 0);
  8514. // 上一次开始连接的时间
  8515. g(this, "maxConnectRetryCount", Oa);
  8516. g(this, "connectRetryCount", 0);
  8517. // 尝试重连了多少次
  8518. g(this, "gotErr", !1);
  8519. g(this, "closedByInvoke", !0);
  8520. // 是否调用 close() 关闭的
  8521. g(this, "isReconnecting", !1);
  8522. g(this, "networkAvailableChecked", !0);
  8523. g(this, "reconnectTimeoutId", 0);
  8524. this.maxConnectRetryCount = e != null ? e : Oa, this.onOpen = this.onOpen.bind(this), this.onMessage = this.onMessage.bind(this), this.onError = this.onError.bind(this), this.onClose = this.onClose.bind(this);
  8525. }
  8526. get connectUrl() {
  8527. return this.wsUrl;
  8528. }
  8529. /**
  8530. * 返回websocket连接的状态
  8531. */
  8532. get connectStatus() {
  8533. return this.socketStatus;
  8534. }
  8535. /**
  8536. * 开始连接
  8537. * @param wsUrl
  8538. */
  8539. start(e) {
  8540. this.wsUrl = e, this.initWebSocket();
  8541. }
  8542. /**
  8543. * 发送消息
  8544. * @param pkg
  8545. */
  8546. send(e) {
  8547. return this.ws && this.socketStatus === 2 ? (this.ws.send(JSON.stringify(e)), !0) : !1;
  8548. }
  8549. /**
  8550. * 主动断开连接
  8551. */
  8552. close() {
  8553. this.closedByInvoke = !0, this.uninitWebsocket();
  8554. }
  8555. reconnect() {
  8556. this.reconnectTimeoutId && (clearTimeout(this.reconnectTimeoutId), this.reconnectTimeoutId = 0), this.emit("onReconnectStart"), this.isReconnecting = !0, this.initWebSocket();
  8557. }
  8558. /**
  8559. * 连接成功
  8560. * @param event
  8561. */
  8562. onOpen(e) {
  8563. O.info(`[${$t.logName}]`, "onOpen"), this.socketStatus = 2, this.connectRetryCount = 0, this.networkAvailableChecked = !1, this.closedByInvoke = !1, this.gotErr = !1, this.isReconnecting = !1, this.emit("onOpen", e);
  8564. }
  8565. /**
  8566. * 收到消息
  8567. * @param event
  8568. */
  8569. onMessage(e) {
  8570. this.emit("onMessage", e);
  8571. }
  8572. /**
  8573. * 收到错误
  8574. * @param event
  8575. */
  8576. onError(e) {
  8577. this.isReconnecting && this.emit("onReconnectFail", e), this.emit("onError", e), this.isReconnecting = !1, this.socketStatus !== 2 && He.isNetworkAvailable().then((t) => {
  8578. t && console.error($t.logName, "onError, Network is available, token may be invalid");
  8579. });
  8580. }
  8581. /**
  8582. * 连接断开
  8583. * @param event
  8584. */
  8585. onClose(e) {
  8586. return w(this, null, function* () {
  8587. if (this.closedByInvoke) {
  8588. this.socketStatus = 0;
  8589. return;
  8590. }
  8591. if (O.info(
  8592. `[${$t.logName}]`,
  8593. `onClose, code: ${e.code}, reason: ${e.reason}, status: ${status}, retryCount: ${this.connectRetryCount}`
  8594. ), (yield He.isNetworkAvailable()) && !this.networkAvailableChecked) {
  8595. this.reconnect(), this.networkAvailableChecked = !0;
  8596. return;
  8597. } else
  8598. this.connectRetryCount || this.emit("onNetworkError"), this.reconnectTimeoutId || (this.connectRetryCount += 1, this.connectRetryCount > this.maxConnectRetryCount ? this.emit("onConnectFail") : Date.now() - this.lastConnectStartTime >= Ua ? this.reconnect() : this.reconnectTimeoutId = window.setTimeout(() => {
  8599. this.reconnect();
  8600. }, Ua));
  8601. this.socketStatus = 0, this.emit("onClose", e);
  8602. });
  8603. }
  8604. /**
  8605. * 初始化websocket
  8606. */
  8607. initWebSocket() {
  8608. this.uninitWebsocket(), this.socketStatus = 1, this.lastConnectStartTime = Date.now(), this.ws = new WebSocket(this.wsUrl), this.ws.addEventListener("open", this.onOpen), this.ws.addEventListener("message", this.onMessage), this.ws.addEventListener("error", this.onError), this.ws.addEventListener("close", this.onClose);
  8609. }
  8610. /**
  8611. * 反初始化websocket
  8612. */
  8613. uninitWebsocket() {
  8614. this.ws && (this.ws.removeEventListener("open", this.onOpen), this.ws.removeEventListener("message", this.onMessage), this.ws.removeEventListener("error", this.onError), this.ws.removeEventListener("close", this.onClose), this.ws.readyState !== WebSocket.CLOSED && this.ws.close(), this.ws = void 0, this.socketStatus = 0);
  8615. }
  8616. };
  8617. /**
  8618. * @ignore
  8619. */
  8620. g($t, "logName", "Socket");
  8621. let Vr = $t;
  8622. var ve = /* @__PURE__ */ ((r) => (r.KEEPALIVE = "keepalive", r.JOINCHANNEL = "joinchannel", r.NOTIFYJOIN = "notifyjoin", r.NOTIFYSTATUS = "notifystatus", r.STATUSREPORT = "statusreport", r.LEAVECHANNEL = "leavechannel", r.NOTIFYLEAVE = "notifyleave", r.NOTIFYPUBLISH = "notifypublish", r.BYE = "bye", r.RECONNECT = "reconnect", r.PUBLISH = "publish", r.REFRESHURL = "refreshurl", r.UNSUBSCRIBE = "unsubscribe", r.ROLEUPDATE = "roleupdate", r))(ve || {});
  8623. class L0 {
  8624. constructor(a, e) {
  8625. g(this, "authInfo");
  8626. g(this, "userName");
  8627. g(this, "seqIndex", 0);
  8628. this.authInfo = a, this.userName = e;
  8629. }
  8630. get roleAuth() {
  8631. if (this.authInfo.role) {
  8632. const { timestamp: a, nonce: e, token: t, role: i } = this.authInfo;
  8633. return { timestamp: a, nonce: e, token: t, tokenrole: i };
  8634. }
  8635. }
  8636. refreshAuthInfo(a) {
  8637. this.authInfo = a;
  8638. }
  8639. getSeqIndex() {
  8640. return this.seqIndex;
  8641. }
  8642. /**
  8643. * 创建一个心跳包
  8644. * @returns
  8645. */
  8646. createKeepAlivePackage() {
  8647. return this.createBaseSendPackage(
  8648. "keepalive"
  8649. /* KEEPALIVE */
  8650. );
  8651. }
  8652. /**
  8653. * 创建一个用于发送入会消息的Package
  8654. * @returns
  8655. */
  8656. createJoinPackage() {
  8657. let a = this.createBaseSendPackage(
  8658. "joinchannel"
  8659. /* JOINCHANNEL */
  8660. );
  8661. return a.header.displayName = this.userName, a.header.clientversion = He.getVersionNumber().toString(), a.header.platform = Xs, this.roleAuth && (a.data.auth = this.roleAuth), a;
  8662. }
  8663. /**
  8664. * 创建一个用于发送离会消息的Package
  8665. * @returns
  8666. */
  8667. crateLeavePackage() {
  8668. return this.createBaseSendPackage(
  8669. "leavechannel"
  8670. /* LEAVECHANNEL */
  8671. );
  8672. }
  8673. createStatusPackage(a) {
  8674. let e = this.createBaseSendPackage(
  8675. "statusreport"
  8676. /* STATUSREPORT */
  8677. );
  8678. return e.header.displayName = this.userName, e.data.status = a, e;
  8679. }
  8680. /**
  8681. * 创建一个用于发送推流消息的Package
  8682. * @returns
  8683. */
  8684. createPublishPackage() {
  8685. let a = this.createBaseSendPackage(
  8686. "publish"
  8687. /* PUBLISH */
  8688. );
  8689. return a.data.users = [{}], this.roleAuth && (a.data.auth = this.roleAuth), a;
  8690. }
  8691. createRoleUpdatePackage() {
  8692. let a = this.createBaseSendPackage(
  8693. "roleupdate"
  8694. /* ROLEUPDATE */
  8695. );
  8696. return a.header.displayName = this.userName, a;
  8697. }
  8698. createReconnectPackage(a) {
  8699. let e = this.createBaseSendPackage(
  8700. "reconnect"
  8701. /* RECONNECT */
  8702. );
  8703. return e.header.displayName = this.userName, e.header.clientversion = He.getVersionNumber().toString(), e.header.platform = Xs, e.data = J(J({}, e.data), a != null ? a : {}), this.roleAuth && (e.data.auth = this.roleAuth), e;
  8704. }
  8705. createRefreshUrlPackage() {
  8706. let a = this.createBaseSendPackage(
  8707. "refreshurl"
  8708. /* REFRESHURL */
  8709. );
  8710. return a.header.displayName = this.userName, a;
  8711. }
  8712. /**
  8713. * 创建一个Response包
  8714. * @param {string} tid Notify消息的tid
  8715. * @param {MessageType} msgType 消息类型
  8716. * @returns {IResponse}
  8717. */
  8718. createResponsePackage(a, e) {
  8719. return {
  8720. version: 1,
  8721. code: 200,
  8722. tid: a,
  8723. msgtype: e
  8724. };
  8725. }
  8726. /**
  8727. *
  8728. * @param messageType
  8729. * @returns
  8730. */
  8731. createBaseSendPackage(a) {
  8732. var t;
  8733. return ++this.seqIndex, {
  8734. version: 1,
  8735. msgtype: a,
  8736. tid: rt(),
  8737. header: {
  8738. appid: this.authInfo.appId,
  8739. channelid: this.authInfo.channelId,
  8740. sessionid: (t = this.authInfo.sessionId) != null ? t : "",
  8741. userid: this.authInfo.userId
  8742. },
  8743. data: {
  8744. seq: this.seqIndex
  8745. }
  8746. };
  8747. }
  8748. }
  8749. var U = /* @__PURE__ */ ((r) => (r[r.ERR_JOIN_ALREADY_JOINED = 16843521] = "ERR_JOIN_ALREADY_JOINED", r[r.ERR_JOIN_BAD_APPID = 33620481] = "ERR_JOIN_BAD_APPID", r[r.ERR_JOIN_INVALID_APPID = 33620482] = "ERR_JOIN_INVALID_APPID", r[r.ERR_JOIN_BAD_CHANNEL = 33620484] = "ERR_JOIN_BAD_CHANNEL", r[r.ERR_JOIN_INVALID_CHANNEL = 33620483] = "ERR_JOIN_INVALID_CHANNEL", r[r.ERR_JOIN_BAD_TOKEN = 33620485] = "ERR_JOIN_BAD_TOKEN", r[r.ERR_JOIN_TIMEOUT = 16908804] = "ERR_JOIN_TIMEOUT", r[r.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD = 16974081] = "ERR_JOIN_ERR_JOIN_BAD_PARAMBAD", r[r.ERR_JOIN_CHANNEL_FAILED = 16974338] = "ERR_JOIN_CHANNEL_FAILED", r[r.ERR_LOG_ALREADY_INIT = 16974085] = "ERR_LOG_ALREADY_INIT", r[r.ERR_LOG_ROOT_PATH_ERROR = 16974086] = "ERR_LOG_ROOT_PATH_ERROR", r[r.ERR_MIC_OPEN_FAIL = 17040388] = "ERR_MIC_OPEN_FAIL", r[r.ERR_SPEAKER_OPEN_FAIL = 17040389] = "ERR_SPEAKER_OPEN_FAIL", r[r.ERR_MIC_INTERRUPT = 17040390] = "ERR_MIC_INTERRUPT", r[r.ERR_SPEAKER_INTERRUPT = 17040391] = "ERR_SPEAKER_INTERRUPT", r[r.ERR_MIC_AUTH_FAIL = 17040392] = "ERR_MIC_AUTH_FAIL", r[r.ERR_MIC_NOT_AVAILABLE = 17040393] = "ERR_MIC_NOT_AVAILABLE", r[r.ERR_SPEAKER_NOT_AVAILABLE = 17040400] = "ERR_SPEAKER_NOT_AVAILABLE", r[r.ERR_CAMERA_OPEN_FAIL = 17039620] = "ERR_CAMERA_OPEN_FAIL", r[r.ERR_CAMERA_AUTH_FAIL = 17039621] = "ERR_CAMERA_AUTH_FAIL", r[r.ERR_CAMERA_INTERRUPT = 17039622] = "ERR_CAMERA_INTERRUPT", r[r.ERR_CAMERA_NOT_AVAILABLE = 17039623] = "ERR_CAMERA_NOT_AVAILABLE", r[r.ERR_VIDEO_DISPLAY_OPEN_FAIL = 17039873] = "ERR_VIDEO_DISPLAY_OPEN_FAIL", r[r.ERR_VIDEO_DISPLAY_INTERRUPT = 1064992] = "ERR_VIDEO_DISPLAY_INTERRUPT", r[r.ERR_ICE_CONNECTION_CONNECT_FAIL = 17105409] = "ERR_ICE_CONNECTION_CONNECT_FAIL", r[r.ERR_ICE_CONNECTION_RECONNECT_FAI = 17105410] = "ERR_ICE_CONNECTION_RECONNECT_FAI", r[r.ERR_ICE_CONNECTION_MOBILITY_FAIL = 17105411] = "ERR_ICE_CONNECTION_MOBILITY_FAIL", r[r.ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT = 16908812] = "ERR_ICE_CONNECTION_HEARTBEAT_TIMEOUT", r[r.ERR_LATENCY_LIVE_COMMUNICATION_FAILED = 17235971] = "ERR_LATENCY_LIVE_COMMUNICATION_FAILED", r[r.ERR_LATENCY_LIVE_MEIDASETTING_FAILED = 17235972] = "ERR_LATENCY_LIVE_MEIDASETTING_FAILED", r[r.ERR_LATENCY_LIVE_NONE_BROADCASTER = 17235973] = "ERR_LATENCY_LIVE_NONE_BROADCASTER", r[r.ERR_LATENCY_LIVE_NEED_RESTART = 17235974] = "ERR_LATENCY_LIVE_NEED_RESTART", r[r.ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER = 17235975] = "ERR_LATENCY_LIVE_NEED_RESTART_AGAIN_LATER", r[r.ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE = 17235976] = "ERR_LATENCY_LIVE_SERVICE_UNAVAILABLE", r[r.ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION = 17235977] = "ERR_LATENCY_LIVE_MEDIACONNECTION_INTERRUPTION", r[r.ERR_SDK_PUBLISH_INVAILD = 16974597] = "ERR_SDK_PUBLISH_INVAILD", r[r.ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL = 16843782] = "ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL", r[r.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED = 16843856] = "ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED", r[r.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED = 16843857] = "ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED", r[r.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED = 16843858] = "ERR_SDK_PUBLISH_DUAL_STREAM_FAILED", r[r.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED = 16843859] = "ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED", r[r.ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR = 16843860] = "ERR_SDK_PUBLISH_SCREEN_SHARE_CONFIG_ERROR", r[r.ERR_SDK_SUBSCRIBE_INVAILD = 16974852] = "ERR_SDK_SUBSCRIBE_INVAILD", r[r.ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL = 16844112] = "ERR_SDK_SUBSCRIBE_NOT_JOIN_CHANNEL", r[r.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED = 16844113] = "ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED", r[r.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED = 16844114] = "ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED", r[r.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED = 16844115] = "ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED", r[r.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED = 16844116] = "ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED", r[r.ERR_SDK_SUBSCRIBE_DATA_FAILED = 16844117] = "ERR_SDK_SUBSCRIBE_DATA_FAILED", r[r.ERR_SDK_SUBSCRIBE_DATA_ERROR = 16844118] = "ERR_SDK_SUBSCRIBE_DATA_ERROR", r[r.ERR_SDK_INVALID_STATE = 16974340] = "ERR_SDK_INVALID_STATE", r[r.ERR_INVALID_ARGUMENTS = 16974083] = "ERR_INVALID_ARGUMENTS", r[r.ERR_SESSION_REMOVED = 33620229] = "ERR_SESSION_REMOVED", r[r.ERR_SDK_UPDATE_ROLE_CHANNEL = 16908801] = "ERR_SDK_UPDATE_ROLE_CHANNEL", r[r.ERR_INNER = -1] = "ERR_INNER", r[r.ERR_SDK_MPU_TASK_PUBLISH_OK = 0] = "ERR_SDK_MPU_TASK_PUBLISH_OK", r[r.ERR_SDK_MPU_TASK_STREAM_NOT_FOUND = 17825793] = "ERR_SDK_MPU_TASK_STREAM_NOT_FOUND", r[r.ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST = 17825794] = "ERR_SDK_MPU_TASK_STREAM_ALREADY_EXIST", r[r.ERR_SDK_MPU_TASK_INVALID_PARAM = 17825795] = "ERR_SDK_MPU_TASK_INVALID_PARAM", r[r.ERR_SDK_MPU_TASK_INTERNAL_ERROR = 17825796] = "ERR_SDK_MPU_TASK_INTERNAL_ERROR", r[r.ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR = 17825797] = "ERR_SDK_MPU_TASK_RTMP_SERVER_ERROR", r[r.ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR = 17825798] = "ERR_SDK_MPU_TASK_RTMP_STREAM_URL_ERROR", r[r.ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT = 17825799] = "ERR_SDK_MPU_TASK_PUBLISH_TIMEOUT", r[r.ERR_SDK_MPU_TASK_NOT_AUTHORIZED = 17825800] = "ERR_SDK_MPU_TASK_NOT_AUTHORIZED", r[r.ERR_SDK_CHANNEL_RELAY_STATE_ERROR = 18874369] = "ERR_SDK_CHANNEL_RELAY_STATE_ERROR", r[r.ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW = 18874370] = "ERR_SDK_CHANNEL_RELAY_SRC_NOT_ALLOW", r[r.ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED = 18874371] = "ERR_SDK_CHANNEL_RELAY_JOIN_DEST_FAILED", r[r.ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID = 18874372] = "ERR_SDK_CHANNEL_RELAY_TOKEN_INVALID", r[r.ERR_SDK_CHANNEL_RELAY_ROLE_ERROR = 18874373] = "ERR_SDK_CHANNEL_RELAY_ROLE_ERROR", r[r.ERR_SDK_CHANNEL_RELAY_INVALID_PARAM = 18874374] = "ERR_SDK_CHANNEL_RELAY_INVALID_PARAM", r[r.ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR = 18874375] = "ERR_SDK_CHANNEL_RELAY_TO_SELF_ERROR", r))(U || {});
  8750. class V extends Error {
  8751. constructor(e, t, i) {
  8752. super(t);
  8753. g(this, "_code");
  8754. g(this, "_extra");
  8755. this._code = e, this._extra = i;
  8756. }
  8757. static fromRtsError(e) {
  8758. return e instanceof V ? e : new V((e == null ? void 0 : e.errorCode) || -1, (e == null ? void 0 : e.message) || (e == null ? void 0 : e.errorCodeName) || "rts error", e);
  8759. }
  8760. static fromError(e, t = -1, i = "") {
  8761. return new V(t, (e == null ? void 0 : e.message) || (e == null ? void 0 : e.reason) || i || "error", e);
  8762. }
  8763. get code() {
  8764. return this._code;
  8765. }
  8766. set code(e) {
  8767. this._code = e;
  8768. }
  8769. get reason() {
  8770. return this.message;
  8771. }
  8772. get extra() {
  8773. return this._extra;
  8774. }
  8775. }
  8776. const F0 = 3e4, qe = class qe extends De {
  8777. // 发送重连信令时,房间信令凭这些信息找回 session
  8778. constructor(e, t, i, s, n, c) {
  8779. super();
  8780. g(this, "authInfo");
  8781. // 登陆信息AliRtcAuthInfo
  8782. g(this, "userName");
  8783. g(this, "channelProfile");
  8784. g(this, "clientRole");
  8785. g(this, "slsReporter");
  8786. g(this, "wsClient");
  8787. // websocket类
  8788. g(this, "packageCreater");
  8789. // 负责生成和解析业务信令数据包
  8790. g(this, "keepAliveTimer", 0);
  8791. // 心跳包计时器
  8792. g(this, "packageCache", /* @__PURE__ */ new Map());
  8793. // 已经发送的消息缓存队列,没有回复则需要触发消息重发
  8794. g(this, "isFirstConnect", !0);
  8795. // 是否是首次连接
  8796. g(this, "aliveChecker", 0);
  8797. // 心跳检查定时器
  8798. g(this, "reconnectData");
  8799. this.authInfo = e, this.userName = t, this.packageCreater = new L0(e, t), this.channelProfile = i, this.clientRole = s, this.slsReporter = n, this.wsClient = new Vr(c), this.wsClient.on("onOpen", this.onOpen.bind(this)), this.wsClient.on("onMessage", this.onMessage.bind(this)), this.wsClient.on("onError", this.onError.bind(this)), this.wsClient.on("onClose", this.onClose.bind(this)), this.wsClient.on("onConnectFail", this.onConnectFail.bind(this)), this.wsClient.on("onAuthInvalid", this.onAuthInvalid.bind(this)), this.wsClient.on("onNetworkError", this.onNetworkError.bind(this)), this.wsClient.on("onReconnectStart", this.onReconnectStart.bind(this)), this.wsClient.on("onReconnectFail", this.onReconnectFail.bind(this));
  8800. }
  8801. get retryCount() {
  8802. return this.wsClient.connectRetryCount;
  8803. }
  8804. /**
  8805. * 开始连接信令
  8806. * @param roomserverurl
  8807. */
  8808. start(e) {
  8809. this.wsClient.start(e);
  8810. }
  8811. /**
  8812. * 开始心跳计时器,并自动发送心跳包
  8813. */
  8814. startKeepAlive() {
  8815. this.keepAliveTimer === 0 && (this.keepAliveTimer = window.setInterval(() => {
  8816. let e = this.packageCreater.createKeepAlivePackage();
  8817. this.sendPackage(e);
  8818. }, 5e3)), this.checkAlive();
  8819. }
  8820. /**
  8821. * 停止心跳计时器
  8822. */
  8823. stopKeepAlive() {
  8824. this.keepAliveTimer !== 0 && (clearInterval(this.keepAliveTimer), this.keepAliveTimer = 0), this.aliveChecker && (window.clearTimeout(this.aliveChecker), this.aliveChecker = 0);
  8825. }
  8826. /**
  8827. * 发送入会、重连前所缓存信息
  8828. */
  8829. sendPkgCache() {
  8830. this.packageCache.forEach((e) => {
  8831. this.wsClient.send(e);
  8832. });
  8833. }
  8834. /**
  8835. * 发送离开房间
  8836. */
  8837. leave() {
  8838. let e = this.packageCreater.crateLeavePackage();
  8839. this.sendPackage(e);
  8840. }
  8841. /**
  8842. * 透明通道消息上报
  8843. * @param status
  8844. */
  8845. reportStatus(e) {
  8846. let t = this.packageCreater.createStatusPackage(e);
  8847. this.sendPackage(t);
  8848. }
  8849. /**
  8850. * 发送推流消息
  8851. */
  8852. publish(e) {
  8853. const o = e, { l1ip: t } = o, i = Dt(o, ["l1ip"]);
  8854. let s = this.packageCreater.createPublishPackage();
  8855. s.data.users = [], s.data.l1ip = t, i.subscribe.signal = this.wsClient.connectUrl;
  8856. const { tracks: n, resume: c } = i;
  8857. n.forEach((u) => {
  8858. const { codec: h, ssrc: p } = u;
  8859. u.userdata = JSON.stringify({
  8860. codec: h
  8861. }), u.ssrc = `${p}`, c && (u.attr = {
  8862. reason: "reconnect"
  8863. });
  8864. }), s.data.users.push(i), this.sendPackage(s);
  8865. }
  8866. /**
  8867. * 更新角色
  8868. */
  8869. roleUpdate(e) {
  8870. let t = this.packageCreater.createRoleUpdatePackage();
  8871. t.data.clientrole = e, this.sendPackage(t);
  8872. }
  8873. /**
  8874. * 更新推拉流地址
  8875. * @param {RefreshInfo} info
  8876. */
  8877. refreshUrl(e) {
  8878. const t = this.packageCreater.createRefreshUrlPackage();
  8879. t.data = J(ut(J({}, t.data), {
  8880. sessionid: t.header.sessionid
  8881. }), e), this.sendPackage(t);
  8882. }
  8883. refreshAuthInfo(e) {
  8884. this.authInfo = e, this.packageCreater.refreshAuthInfo(e);
  8885. }
  8886. /**
  8887. * 关闭websocket连接,并销毁
  8888. */
  8889. close() {
  8890. O.info(`[${qe.logName}] close`), this.stopKeepAlive(), this.wsClient.off("onOpen", this.onOpen.bind(this)), this.wsClient.off("onMessage", this.onMessage.bind(this)), this.wsClient.off("onError", this.onError.bind(this)), this.wsClient.off("onClose", this.onClose.bind(this)), this.wsClient.off("onConnectFail", this.onConnectFail.bind(this)), this.wsClient.off("onAuthInvalid", this.onAuthInvalid.bind(this)), this.wsClient.off("onReconnectStart"), this.wsClient.off("onReconnectFail"), this.wsClient.close();
  8891. }
  8892. /**
  8893. * 通过此方法发送数据到业务信令
  8894. * 此方法会自动保存发送的package,并做重发.
  8895. * response包不要通过此方法发送
  8896. * @param pkg
  8897. */
  8898. sendPackage(e) {
  8899. [ve.KEEPALIVE, ve.RECONNECT, ve.JOINCHANNEL].includes(e.msgtype) || this.packageCache.set(e.tid, e), this.wsClient.send(e), e.msgtype !== ve.KEEPALIVE && this.slsReporter.reportRoomServerEvent(!0, e.msgtype, e.tid, e);
  8900. }
  8901. /**
  8902. * 更新重连 payload
  8903. * @param {ReconnectData} reconnectData
  8904. */
  8905. updateReconnectData(e) {
  8906. this.reconnectData = e;
  8907. }
  8908. /**
  8909. * 收到websocket连接成功的消息
  8910. * ws连接建立成功后立刻发送join消息
  8911. */
  8912. onOpen() {
  8913. if (O.info(`[${qe.logName}] onOpen`), this.isFirstConnect) {
  8914. let e = this.packageCreater.createJoinPackage();
  8915. e.data.configure = {
  8916. channelprofile: this.channelProfile
  8917. }, (this.channelProfile === bt.AliRtcSdkInteractiveLive || this.channelProfile === bt.AliRtcSdkInteractiveWithLowLatencyLive) && (e.data.configure.clientrole = this.clientRole), this.sendPackage(e);
  8918. } else {
  8919. this.stopKeepAlive();
  8920. const e = this.packageCreater.createReconnectPackage(this.reconnectData);
  8921. this.sendPackage(e);
  8922. }
  8923. }
  8924. /**
  8925. * 收到业务信令消息
  8926. * @param event
  8927. */
  8928. onMessage(e) {
  8929. try {
  8930. let t = JSON.parse(e.data);
  8931. this.packageCache.delete(t.tid), this.onRecvMessage(t), t != null && t.msgtype && (t == null ? void 0 : t.msgtype) !== ve.KEEPALIVE && this.slsReporter.reportRoomServerEvent(!1, t.msgtype, t.tid, t);
  8932. } catch (t) {
  8933. O.warn(`[${qe.logName}] onMessage err`, t, e);
  8934. }
  8935. }
  8936. /**
  8937. * 收到错误消息
  8938. * @param event
  8939. */
  8940. onError(e) {
  8941. O.warn(`[${qe.logName}] onError`, e), this.isFirstConnect && this.onConnectFail();
  8942. }
  8943. /**
  8944. * 连接失败
  8945. */
  8946. onConnectFail() {
  8947. O.warn(`[${qe.logName}] onConnectFail`);
  8948. const e = new V(U.ERR_INNER, "Signaling connect failed.");
  8949. this.isFirstConnect ? this.emit("onJoinChannelResult", e) : this.emit("onConnectFail", e);
  8950. }
  8951. /**
  8952. * 鉴权失败
  8953. */
  8954. onAuthInvalid() {
  8955. O.warn(`[${qe.logName}] onAuthInvalid`), this.isFirstConnect && this.emit("onAuthInvalid");
  8956. }
  8957. /**
  8958. * 网络异常
  8959. */
  8960. onNetworkError() {
  8961. O.warn(`[${qe.logName}] onNetworkError`);
  8962. const e = new V(U.ERR_INNER, "Network error, signaling connect failed.");
  8963. this.emit("onNetworkError", e);
  8964. }
  8965. /**
  8966. * 收到websocket断开消息
  8967. * @param event
  8968. */
  8969. onClose(e) {
  8970. O.info(`[${qe.logName}] onClose`, e), this.stopKeepAlive();
  8971. }
  8972. onKeepAliveRsp() {
  8973. this.emit("onKeepAliveRsp"), this.checkAlive();
  8974. }
  8975. onReconnectStart() {
  8976. this.emit("onReconnectStart");
  8977. }
  8978. onReconnectFail() {
  8979. this.emit("onReconnectFail", new V(U.ERR_INNER, "signaling reconnect failed."));
  8980. }
  8981. /**
  8982. * 处理 Keepalive 心跳,加速判断网络异常
  8983. */
  8984. checkAlive() {
  8985. window.clearTimeout(this.aliveChecker), this.aliveChecker = window.setTimeout(() => {
  8986. O.info(`[${qe.logName}] not alive, reconnect`), this.stopKeepAlive(), this.emit("onReconnectStart"), this.wsClient.reconnect();
  8987. }, F0);
  8988. }
  8989. /**
  8990. * 处理收到的业务信令
  8991. * @param response
  8992. */
  8993. onRecvMessage(e) {
  8994. switch (e.msgtype !== ve.KEEPALIVE && O.info(`[${qe.logName}] recv msg: ${e.msgtype}`), e.msgtype) {
  8995. case ve.JOINCHANNEL:
  8996. this.onJoinResult(e);
  8997. break;
  8998. case ve.KEEPALIVE:
  8999. this.onKeepAliveRsp();
  9000. break;
  9001. case ve.PUBLISH:
  9002. this.onPublishResult(e);
  9003. break;
  9004. case ve.NOTIFYJOIN:
  9005. this.onNotifyJoin(e);
  9006. break;
  9007. case ve.NOTIFYSTATUS:
  9008. this.onNotifyStatus(e);
  9009. break;
  9010. case ve.LEAVECHANNEL:
  9011. this.onLeaveResult(e);
  9012. break;
  9013. case ve.NOTIFYLEAVE:
  9014. this.onNotifyLeave(e);
  9015. break;
  9016. case ve.NOTIFYPUBLISH:
  9017. this.onNotifyPublish(e);
  9018. break;
  9019. case ve.STATUSREPORT:
  9020. this.onStatusReport(e);
  9021. break;
  9022. case ve.BYE:
  9023. this.onBye(e);
  9024. break;
  9025. case ve.ROLEUPDATE:
  9026. this.onRoleUpdateResult(e);
  9027. break;
  9028. case ve.REFRESHURL:
  9029. this.onRefreshUrlResult(e);
  9030. break;
  9031. case ve.RECONNECT:
  9032. this.onReconnectResult(e);
  9033. break;
  9034. }
  9035. }
  9036. /**
  9037. * 收到入会消息的response
  9038. * @param response
  9039. */
  9040. onJoinResult(e) {
  9041. this.isFirstConnect = !1, this.emit("onJoinChannelResult", e);
  9042. }
  9043. /**
  9044. * 收到离开消息的response
  9045. * @param response
  9046. */
  9047. onLeaveResult(e) {
  9048. this.emit("onLeaveResult", e.code, e.tid);
  9049. }
  9050. /**
  9051. * 收到publish消息的response
  9052. * @param response
  9053. */
  9054. onPublishResult(e) {
  9055. this.emit("onPublishResult", e.code, e.tid, e.description);
  9056. }
  9057. /**
  9058. * 收到roleUpdate消息的response
  9059. * @param response
  9060. */
  9061. onRoleUpdateResult(e) {
  9062. this.emit("onRoleUpdateResult", e.code, e.tid, e.description);
  9063. }
  9064. /**
  9065. * 收到 refreshurl 消息的response
  9066. * @param response
  9067. */
  9068. onRefreshUrlResult(e) {
  9069. this.emit("onRefreshUrlResult", e);
  9070. }
  9071. /**
  9072. * 收到重联消息的response
  9073. * @param response
  9074. */
  9075. onReconnectResult(e) {
  9076. if (e.code === 200)
  9077. this.sendPkgCache(), this.startKeepAlive(), this.emit("onReconnectSuccess", e.data.users);
  9078. else {
  9079. const t = new V(
  9080. U.ERR_INNER,
  9081. `reconnect failed, code: ${e.code};description: ${e.description}`
  9082. );
  9083. e.code === 403 && (t.code = 403), this.emit("onReconnectFail", t), this.close();
  9084. }
  9085. }
  9086. /**
  9087. * 收到业务信令下发的消息
  9088. * @param response
  9089. */
  9090. onNotifyJoin(e) {
  9091. let t = this.packageCreater.createResponsePackage(e.tid, e.msgtype);
  9092. this.wsClient.send(t), e && e.data && e.data.users && this.emit("onNotifyJoin", e.data.users);
  9093. }
  9094. /**
  9095. * 收到业务信令下发的透明通道消息
  9096. * @param response
  9097. */
  9098. onNotifyStatus(e) {
  9099. let t = this.packageCreater.createResponsePackage(e.tid, e.msgtype);
  9100. this.wsClient.send(t), e.data && e.data.status && e.data.status.length && this.emit("onNotifyStatus", e.data.status);
  9101. }
  9102. /**
  9103. * 收到远端用户离开的通知
  9104. * @param response
  9105. */
  9106. onNotifyLeave(e) {
  9107. let t = this.packageCreater.createResponsePackage(e.tid, e.msgtype);
  9108. this.wsClient.send(t), e.data && e.data.users && e.data.users.length && this.emit("onNotifyLeave", e.data.users);
  9109. }
  9110. /**
  9111. * 收到远端用户推流的通知
  9112. * @param response
  9113. */
  9114. onNotifyPublish(e) {
  9115. let t = this.packageCreater.createResponsePackage(e.tid, e.msgtype);
  9116. this.wsClient.send(t), e.data && e.data.users && e.data.users.length && this.emit("onNotifyPublish", e.data.users);
  9117. }
  9118. /**
  9119. * 收到statusreport的response
  9120. * @param response
  9121. */
  9122. onStatusReport(e) {
  9123. this.emit("onStatusReport", e.code, e.tid, e.description);
  9124. }
  9125. /**
  9126. * 收到被踢出频道的消息
  9127. * @param {any} response
  9128. */
  9129. onBye(e) {
  9130. this.stopKeepAlive(), this.emit("onBye", e.reason, e.description);
  9131. }
  9132. };
  9133. g(qe, "logName", "RSMessageCenter");
  9134. let Or = qe;
  9135. const D = (r, a) => (e, t, i) => {
  9136. const s = i.value;
  9137. return i.value = function(...n) {
  9138. var p;
  9139. const c = `[${((p = e.constructor) == null ? void 0 : p.logName) || ""}]`, o = Date.now();
  9140. let u = [];
  9141. if (r)
  9142. try {
  9143. u = r(n);
  9144. } catch (d) {
  9145. }
  9146. O.interface(c, t, ...u);
  9147. const h = s.apply(this, n);
  9148. return Promise.resolve(h).then((d) => d).catch((d) => d).then((d) => {
  9149. var S;
  9150. let f = "";
  9151. const m = d instanceof Error, l = m && ((S = e.constructor) == null ? void 0 : S.logError);
  9152. if (!(!a && !m)) {
  9153. if (l)
  9154. f = d;
  9155. else if (m)
  9156. f = d.message || "";
  9157. else if (a)
  9158. if (d === void 0)
  9159. f = "";
  9160. else
  9161. try {
  9162. f = a(d);
  9163. } catch (v) {
  9164. }
  9165. else
  9166. return;
  9167. O.interfaceResult(
  9168. c,
  9169. t,
  9170. !(m && l),
  9171. `${Date.now() - o}ms`,
  9172. f
  9173. );
  9174. }
  9175. }), h;
  9176. }, i;
  9177. }, H = (r) => r;
  9178. var V0 = Object.defineProperty, O0 = Object.getOwnPropertyDescriptor, as = (r, a, e, t) => {
  9179. for (var i = t > 1 ? void 0 : t ? O0(a, e) : a, s = r.length - 1, n; s >= 0; s--)
  9180. (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i);
  9181. return t && i && V0(a, e, i), i;
  9182. }, Ne;
  9183. const wi = (Ne = class extends De {
  9184. constructor(e, t, i, s = pt.prod) {
  9185. super();
  9186. g(this, "messageCenter");
  9187. g(this, "authInfo");
  9188. g(this, "userName");
  9189. g(this, "channelProfile");
  9190. g(this, "clientRole");
  9191. g(this, "slsReporter");
  9192. g(this, "reconnectData");
  9193. // 重连房间信令的信息,在服务器宕机的时候,reconnect 成功
  9194. g(this, "roomServerUri", "");
  9195. this.channelProfile = e, this.clientRole = t, this.slsReporter = i, this.reconnectData = {
  9196. role: {
  9197. channelprofile: e,
  9198. clientrole: t
  9199. }
  9200. };
  9201. const n = s === pt.pre ? vi.pre : vi.prod;
  9202. this.roomServerUri = `wss://${n}/roomserver/v1/ws`;
  9203. }
  9204. /**
  9205. * 更新重连数据
  9206. * @param {ReconnectData} reconnectData
  9207. */
  9208. updateReconnectData(e) {
  9209. var t;
  9210. this.reconnectData = e, (t = this.messageCenter) == null || t.updateReconnectData(this.reconnectData);
  9211. }
  9212. /**
  9213. * 释放资源
  9214. */
  9215. reset() {
  9216. O.info("[roomsig] reset"), this.messageCenter && (this.messageCenter.close(), this.messageCenter = void 0), this.authInfo = void 0;
  9217. }
  9218. join(e, t, i) {
  9219. return w(this, null, function* () {
  9220. return new Promise((s, n) => {
  9221. const c = {};
  9222. this.authInfo = e, this.userName = t, this.messageCenter = new Or(
  9223. e,
  9224. t,
  9225. this.channelProfile,
  9226. this.clientRole,
  9227. this.slsReporter,
  9228. i
  9229. ), this.initMessageCenter(), this.messageCenter.once("onJoinChannelResult", (u) => {
  9230. var h, p, d;
  9231. if (O.info(`[${Ne.logName}]`, "join result: ", u), c.taskretrynum = ((h = this.messageCenter) == null ? void 0 : h.retryCount) || 0, u.code == 200) {
  9232. (p = this.messageCenter) == null || p.sendPkgCache(), (d = this.messageCenter) == null || d.startKeepAlive();
  9233. let f = u.data;
  9234. f.tid = u.tid, f.users = u.data.users, f.timestamp = u.timestamp, c.est && (c.joinconnecttc = Date.now() - c.est), this.slsReporter.reportJoinConnection(c), s(f);
  9235. } else
  9236. this.reset(), n(this.handleSignalError(u.code, u.reason, U.ERR_JOIN_CHANNEL_FAILED));
  9237. }), this.messageCenter.once("onAuthInvalid", () => {
  9238. this.reset(), n(new V(U.ERR_JOIN_BAD_TOKEN, "join failed because authentication failed"));
  9239. }), O.info(
  9240. `[${Ne.logName}]`,
  9241. "start ws connecting roomserver and auto join when connected"
  9242. );
  9243. const o = {
  9244. appid: this.authInfo.appId,
  9245. callid: this.authInfo.sessionId,
  9246. channelid: this.authInfo.channelId,
  9247. userid: this.authInfo.userId,
  9248. nonce: this.authInfo.nonce || "",
  9249. timestamp: this.authInfo.timestamp,
  9250. token: this.authInfo.token,
  9251. authtype: "app",
  9252. tid: rt()
  9253. };
  9254. e.role && (o.tokenrole = e.role), c.est = Date.now(), this.messageCenter.start(this.roomServerUri + "?" + He.queryingParam(o));
  9255. });
  9256. });
  9257. }
  9258. /**
  9259. * 离开频道
  9260. * @returns
  9261. */
  9262. leave() {
  9263. return O.info("[roomsig] leave .."), new Promise((e, t) => {
  9264. this.messageCenter ? (this.messageCenter.on("onLeaveResult", (i, s) => {
  9265. O.info(`[${Ne.logName}]`, "recv leave response " + i), i === 200 ? (this.updateReconnectData(), this.reset(), e({ tid: s })) : t(this.handleSignalError(i, "leave error"));
  9266. }), O.info(`[${Ne.logName}]`, "send leave request"), this.messageCenter.leave()) : (O.info(`[${Ne.logName}]`, "no message center, ok to leave"), e({ tid: "" }));
  9267. });
  9268. }
  9269. publish(e) {
  9270. return new Promise((t, i) => {
  9271. var s;
  9272. this.messageCenter ? (this.messageCenter.once("onPublishResult", (n, c, o) => {
  9273. O.info(`[${Ne.logName}]`, "recv pubish response " + n), n === 200 ? (this.updateReconnectData(ut(J({}, this.reconnectData), {
  9274. publish: {
  9275. users: [e]
  9276. }
  9277. })), t({ tid: c })) : i(this.handleSignalError(n, `publish error, ${o}`));
  9278. }), this.authInfo && (e.sessionid = (s = this.authInfo.sessionId) != null ? s : ""), e.callid || (e.callid = rt()), O.info(
  9279. `[${Ne.logName}]`,
  9280. "assign callid " + e.callid + " and send publish request"
  9281. ), this.messageCenter.publish(e)) : i(this.handleSignalError(-1, "publish error, no message center"));
  9282. });
  9283. }
  9284. roleUpdate(e) {
  9285. return new Promise((t, i) => {
  9286. if (!this.messageCenter) {
  9287. i(this.handleSignalError(-1, "role update error, no message center"));
  9288. return;
  9289. }
  9290. this.messageCenter.on("onRoleUpdateResult", (s, n, c) => {
  9291. var o, u;
  9292. O.info(`[${Ne.logName}]`, "recv role update response " + s), s === 200 ? ((u = (o = this.reconnectData) == null ? void 0 : o.role) != null && u.clientrole && (this.reconnectData.role.clientrole = e, this.updateReconnectData(this.reconnectData)), t({ tid: n })) : i(this.handleSignalError(s, `role update error, ${c}`));
  9293. }), this.messageCenter.roleUpdate(e);
  9294. });
  9295. }
  9296. setChannelProfile(e) {
  9297. this.channelProfile = e;
  9298. }
  9299. /**
  9300. * 更新推流地址
  9301. */
  9302. refreshUrl(e) {
  9303. return O.info(`[${Ne.logName}]`, "refreshUrl .."), new Promise((t, i) => {
  9304. if (!this.messageCenter) {
  9305. i(this.handleSignalError(-1, "refresh url error, no message center"));
  9306. return;
  9307. }
  9308. this.messageCenter.on("onRefreshUrlResult", (s) => {
  9309. const { code: n, description: c, data: o = {} } = s || {};
  9310. O.info("recv refresh url response " + n), n === 200 ? t(o) : i(this.handleSignalError(n, `refresh url error, ${c}`));
  9311. }), O.info("send refresh url request"), this.messageCenter.refreshUrl(e);
  9312. });
  9313. }
  9314. /**
  9315. * 上报设备状态
  9316. * @param status
  9317. */
  9318. reportStatus(e) {
  9319. return O.info(`[${Ne.logName}]`, "reportStatus " + e), new Promise((t, i) => {
  9320. this.messageCenter ? (this.messageCenter.once("onStatusReport", (s, n) => {
  9321. s === 200 ? t() : i(new V(s, n));
  9322. }), this.messageCenter.reportStatus(e)) : i(new V(-1, "No messageCenter"));
  9323. });
  9324. }
  9325. handleSignalError(e, t, i = U.ERR_INNER) {
  9326. const s = `signal error: code - ${e}; description - ${t}`;
  9327. return new V(i, s);
  9328. }
  9329. refreshAuthInfo(e) {
  9330. return w(this, null, function* () {
  9331. var t;
  9332. this.authInfo && (this.authInfo = e, (t = this.messageCenter) == null || t.refreshAuthInfo(this.authInfo));
  9333. });
  9334. }
  9335. /**
  9336. * 初始化MessageCenter,增加事件监听
  9337. */
  9338. initMessageCenter() {
  9339. var e, t, i, s, n, c, o, u, h, p, d, f;
  9340. (e = this.messageCenter) == null || e.on("onKeepAliveRsp", () => {
  9341. this.emit("onKeepAliveRsp");
  9342. }), (t = this.messageCenter) == null || t.on("onNotifyJoin", (m) => {
  9343. this.emit("onNotifyJoin", m);
  9344. }), (i = this.messageCenter) == null || i.on("onNotifyStatus", (m) => {
  9345. this.emit("onNotifyStatus", m);
  9346. }), (s = this.messageCenter) == null || s.on("onNotifyLeave", (m) => {
  9347. this.emit("onNotifyLeave", m);
  9348. }), (n = this.messageCenter) == null || n.on("onNotifyPublish", (m) => {
  9349. this.emit("onNotifyPublish", m);
  9350. }), (c = this.messageCenter) == null || c.on("onBye", (m, l) => {
  9351. this.emit("onBye", m, l);
  9352. }), (o = this.messageCenter) == null || o.on("onReconnectStart", () => {
  9353. this.emit("onReconnectStart");
  9354. }), (u = this.messageCenter) == null || u.on("onReconnectSuccess", (m) => {
  9355. this.emit("onReconnectSuccess", m);
  9356. }), (h = this.messageCenter) == null || h.on("onReconnectFail", (m) => {
  9357. this.emit("onReconnectFail", m);
  9358. }), (p = this.messageCenter) == null || p.on("onConnectFail", (m) => {
  9359. this.emit("onConnectFail", m), this.reset();
  9360. }), (d = this.messageCenter) == null || d.on("onNetworkError", (m) => {
  9361. this.emit("onNetworkError", m);
  9362. }), (f = this.messageCenter) == null || f.on("onAuthInvalid", () => {
  9363. this.emit("onAuthInvalid");
  9364. });
  9365. }
  9366. }, /**
  9367. * @ignore
  9368. */
  9369. g(Ne, "logName", "RoomServerSignaling"), Ne);
  9370. as([
  9371. D()
  9372. ], wi.prototype, "join", 1);
  9373. as([
  9374. D()
  9375. ], wi.prototype, "publish", 1);
  9376. as([
  9377. D()
  9378. ], wi.prototype, "roleUpdate", 1);
  9379. let U0 = wi;
  9380. const H0 = "https://pgw.rtn.aliyuncs.com", j0 = "https://gw.rtn.aliyuncs.com", Ha = 10 * 60 * 1e3, z0 = 12, ri = class ri extends De {
  9381. constructor(e, t) {
  9382. super();
  9383. g(this, "env");
  9384. g(this, "authInfo");
  9385. g(this, "timer");
  9386. g(this, "slsReporter");
  9387. g(this, "expiration", 0);
  9388. g(this, "skipTime", 0);
  9389. g(this, "requestToken", () => w(this, null, function* () {
  9390. if (this.skipTime = 0, !this.authInfo)
  9391. return;
  9392. const { appId: e, channelId: t, userId: i, nonce: s = "", token: n, timestamp: c, sessionId: o, role: u } = this.authInfo;
  9393. let h = j0;
  9394. this.env === pt.pre && (h = H0);
  9395. const p = `${h}/gslb/v1/stsupdate?appid=${e}&channelid=${t}&userid=${i}&nonce=${s}&token=${n}&timestamp=${c}&session=${o}${u ? `&tokenrole=${u}` : ""}&slstoken=true&osstoken=true&tokensid=false`, d = Date.now();
  9396. fetch(p).then((f) => f.json()).then((f) => {
  9397. var m, l;
  9398. if (f.code === 0) {
  9399. const S = (m = f.data) == null ? void 0 : m.oss, v = (l = f.data) == null ? void 0 : l.sls;
  9400. this.expiration = S.expiration || v.expiration, this.emit("onTokenUpdate", S, v), O.event(`[${ri.logName}]`, "getToken", S, v);
  9401. } else
  9402. throw new Error();
  9403. this.slsReporter.reportSTSResult(200, d);
  9404. }).catch((f) => {
  9405. this.slsReporter.reportSTSResult(-1, d), O.error(`[${ri.logName}]`, "getToken", f.message);
  9406. });
  9407. }));
  9408. this.slsReporter = e, this.env = t;
  9409. }
  9410. refreshAuthInfo(e) {
  9411. this.authInfo = e;
  9412. }
  9413. startSTSUpdate(e) {
  9414. this.authInfo = e, this.requestToken(), this.timer && clearInterval(this.timer), this.timer = window.setInterval(() => {
  9415. if (this.expiration && Math.floor((Date.now() + Ha * 1.5) / 1e3) < this.expiration && this.skipTime < z0) {
  9416. this.skipTime += 1;
  9417. return;
  9418. }
  9419. this.requestToken();
  9420. }, Ha);
  9421. }
  9422. clear() {
  9423. this.timer && clearInterval(this.timer);
  9424. }
  9425. };
  9426. g(ri, "logName", "StsManager");
  9427. let Ur = ri;
  9428. var W0 = Object.defineProperty, $0 = Object.getOwnPropertyDescriptor, K0 = (r, a, e, t) => {
  9429. for (var i = t > 1 ? void 0 : t ? $0(a, e) : a, s = r.length - 1, n; s >= 0; s--)
  9430. (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i);
  9431. return t && i && W0(a, e, i), i;
  9432. };
  9433. class ns extends De {
  9434. constructor(e, t, i, s = pt.prod) {
  9435. super();
  9436. g(this, "signaling");
  9437. g(this, "authInfo");
  9438. g(this, "userName");
  9439. g(this, "channelProfile");
  9440. g(this, "clientRole");
  9441. g(this, "env", pt.prod);
  9442. g(this, "maxConnectRetryCount");
  9443. g(this, "stsManager");
  9444. g(this, "slsReporter");
  9445. this.channelProfile = e, this.clientRole = t, this.env = s, this.slsReporter = i, this.stsManager = new Ur(i, s);
  9446. }
  9447. reset() {
  9448. var e;
  9449. O.info("[signalingmanager] reset"), (e = this.signaling) == null || e.reset(), this.stsManager.clear(), this.signaling = void 0, this.authInfo = void 0;
  9450. }
  9451. /**
  9452. * 向业务信令发送入会
  9453. * @param {AliRtcAuthInfo} authInfo
  9454. * @returns
  9455. */
  9456. join(e, t = e.userId, i, s) {
  9457. return this.maxConnectRetryCount = i, this.userName = t, new Promise((n, c) => {
  9458. this.signaling ? c(new V(U.ERR_JOIN_ALREADY_JOINED, "already joined")) : (O.info("[signalingmanager] create signaling"), this.signaling = new U0(this.channelProfile, this.clientRole, this.slsReporter, this.env), this.initSignaling(), s && (s.rs = Date.now()), this.signaling.join(e, t, i).then((o) => {
  9459. this.authInfo = e, s && (s.re = Date.now()), n(o);
  9460. }).catch((o) => {
  9461. this.reset(), c(o);
  9462. }), this.stsManager.startSTSUpdate(e));
  9463. });
  9464. }
  9465. retryJoin() {
  9466. const e = this.authInfo;
  9467. this.reset(), e && this.join(e, this.userName, this.maxConnectRetryCount);
  9468. }
  9469. /**
  9470. * 向业务信令发送离会
  9471. * @returns
  9472. */
  9473. leave() {
  9474. return new Promise((e, t) => {
  9475. this.signaling ? this.signaling.leave().then((i) => {
  9476. this.reset(), e(i);
  9477. }).catch((i) => {
  9478. t(i);
  9479. }) : e({ tid: "" });
  9480. });
  9481. }
  9482. publish(e) {
  9483. return new Promise((t, i) => {
  9484. var s;
  9485. this.signaling && this.authInfo ? (e.userid = this.authInfo.userId, e.displayname = (s = this.userName) != null ? s : this.authInfo.userId, this.signaling.publish(e).then((n) => {
  9486. t(n);
  9487. }).catch((n) => {
  9488. i(n);
  9489. })) : i(new V(U.ERR_SDK_PUBLISH_NOT_JOIN_CHANNEL, "no signaling"));
  9490. });
  9491. }
  9492. /**
  9493. * 通过透明通道发送设备状态
  9494. * @param {string} status
  9495. * @returns
  9496. */
  9497. reportStatus(e) {
  9498. return new Promise((t, i) => {
  9499. this.signaling ? this.signaling.reportStatus(e).then(() => {
  9500. t();
  9501. }).catch((s) => {
  9502. i(s);
  9503. }) : i(new V(-1, "no signaling"));
  9504. });
  9505. }
  9506. /**
  9507. * 切换角色
  9508. * @param {AliRtcSdkClientRole} role
  9509. * @returns
  9510. */
  9511. setClientRole(e) {
  9512. return w(this, null, function* () {
  9513. const t = this.clientRole;
  9514. if (!this.signaling) {
  9515. this.clientRole = e;
  9516. return;
  9517. }
  9518. const i = Date.now();
  9519. try {
  9520. const s = yield this.signaling.roleUpdate(e);
  9521. return this.slsReporter.reportRoleUpdateResult(t, e, Date.now() - i, 0), s;
  9522. } catch (s) {
  9523. this.slsReporter.reportRoleUpdateResult(t, e, Date.now() - i, s.code || -1);
  9524. }
  9525. });
  9526. }
  9527. /**
  9528. * 切换模式
  9529. * @param {AliRtcSdkChannelProfile} channelProfile
  9530. */
  9531. setChannelProfile(e) {
  9532. this.signaling ? this.signaling.setChannelProfile(e) : this.channelProfile = e;
  9533. }
  9534. /**
  9535. * 更新推流url
  9536. * @param {RefreshInfo} info
  9537. * @returns
  9538. */
  9539. refreshUrl(e) {
  9540. return this.signaling ? this.signaling.refreshUrl(e) : Promise.reject(new V(U.ERR_SDK_INVALID_STATE, "should join first"));
  9541. }
  9542. refreshAuthInfo(e) {
  9543. return w(this, null, function* () {
  9544. var t;
  9545. try {
  9546. this.authInfo && (this.authInfo = J(J({}, this.authInfo), e), (t = this.signaling) == null || t.refreshAuthInfo(this.authInfo), this.stsManager.refreshAuthInfo(this.authInfo));
  9547. } catch (i) {
  9548. throw i;
  9549. }
  9550. });
  9551. }
  9552. /**
  9553. * 监听业务信令相关的事件
  9554. */
  9555. initSignaling() {
  9556. var e, t, i, s, n, c, o, u, h, p, d, f, m;
  9557. (e = this.signaling) == null || e.on("onKeepAliveRsp", this.onKeepAliveRsp.bind(this)), (t = this.signaling) == null || t.on("onNotifyJoin", this.onNotifyJoin.bind(this)), (i = this.signaling) == null || i.on("onNotifyStatus", this.onNotifyStatus.bind(this)), (s = this.signaling) == null || s.on("onNotifyLeave", this.onNotifyLeave.bind(this)), (n = this.signaling) == null || n.on("onNotifyPublish", this.onNotifyPublish.bind(this)), (c = this.signaling) == null || c.on("onBye", this.onBye.bind(this)), (o = this.signaling) == null || o.on("onReconnectStart", this.onReconnectStart.bind(this)), (u = this.signaling) == null || u.on("onReconnectSuccess", this.onReconnectSuccess.bind(this)), (h = this.signaling) == null || h.on("onReconnectFail", this.onReconnectFail.bind(this)), (p = this.signaling) == null || p.on("onConnectFail", this.onConnectFail.bind(this)), (d = this.signaling) == null || d.on("onNetworkError", this.onNetworkError.bind(this)), (f = this.signaling) == null || f.on("onAuthInvalid", this.onAuthInvalid.bind(this)), (m = this.signaling) == null || m.on("onError", this.onError.bind(this));
  9558. }
  9559. /**
  9560. * 收到心跳消息
  9561. */
  9562. onKeepAliveRsp() {
  9563. this.emit("onKeepAliveRsp");
  9564. }
  9565. /**
  9566. * 收到远端用户入会消息
  9567. * @param {JoinInfo[]} users
  9568. */
  9569. onNotifyJoin(e) {
  9570. this.emit("onNotifyJoin", e);
  9571. }
  9572. /**
  9573. * 收到远端用户的透明通道消息
  9574. * @param {RemoteUserStatus[]} users
  9575. */
  9576. onNotifyStatus(e) {
  9577. this.emit("onNotifyStatus", e);
  9578. }
  9579. /**
  9580. * 收到远端用户的离会消息
  9581. * @param {LeaveInfo[]} users
  9582. */
  9583. onNotifyLeave(e) {
  9584. this.emit("onNotifyLeave", e);
  9585. }
  9586. /**
  9587. * 收到远端用户推流状态变化消息
  9588. * @param {PublishInfo[]} users
  9589. */
  9590. onNotifyPublish(e) {
  9591. this.emit("onNotifyPublish", e);
  9592. }
  9593. /**
  9594. * 收到被踢掉消息
  9595. * @param {string} reason
  9596. * @param {string} description
  9597. */
  9598. onBye(e, t) {
  9599. this.emit("onBye", e, t);
  9600. }
  9601. /**
  9602. * 收到连接失败消息
  9603. * @param {AliRtcError} err
  9604. */
  9605. onConnectFail(e) {
  9606. this.reset(), this.emit("onConnectFail", e);
  9607. }
  9608. /**
  9609. * 收到网络异常消息
  9610. * @param {AliRtcError} err
  9611. */
  9612. onNetworkError(e) {
  9613. this.emit("onNetworkError", e);
  9614. }
  9615. /**
  9616. * 收到网络异常消息
  9617. */
  9618. // eslint-disable-next-line @ali/no-unused-vars
  9619. onAuthInvalid() {
  9620. }
  9621. onReconnectStart() {
  9622. this.emit("onReconnectStart");
  9623. }
  9624. /**
  9625. * 收到重连成功消息
  9626. * @param {JoinInfo[]} users
  9627. */
  9628. onReconnectSuccess(e) {
  9629. this.emit("onReconnectSuccess", e);
  9630. }
  9631. /**
  9632. * 收到重连失败消息
  9633. */
  9634. onReconnectFail(e) {
  9635. this.emit("onReconnectFail", e);
  9636. }
  9637. /**
  9638. * 收到错误消息
  9639. * @param {AliRtcError} err
  9640. */
  9641. onError(e) {
  9642. this.emit("onError", e);
  9643. }
  9644. }
  9645. /**
  9646. * @ignore
  9647. */
  9648. g(ns, "logName", "SignalingManager");
  9649. K0([
  9650. D(H)
  9651. ], ns.prototype, "publish", 1);
  9652. function Kt() {
  9653. }
  9654. const Mt = class Mt {
  9655. static getInstance() {
  9656. var a;
  9657. return Mt.instance || (Mt.instance = new AudioContext()), (a = Mt.instance.resume()) == null || a.then(Kt, Kt).catch(Kt), Mt.instance;
  9658. }
  9659. };
  9660. g(Mt, "instance");
  9661. let Ft = Mt;
  9662. const _i = () => {
  9663. var a;
  9664. const r = Ft.getInstance();
  9665. r.state !== "running" && r.state !== "closed" && ((a = r.resume()) == null || a.then(Kt, Kt).catch(Kt)), window.removeEventListener("mousedown", _i), window.removeEventListener("touchstart", _i);
  9666. };
  9667. window.addEventListener("mousedown", _i);
  9668. window.addEventListener("touchstart", _i);
  9669. function q0(r, a, e, t, i) {
  9670. let s = t, n = 0, c;
  9671. const o = r.createAnalyser();
  9672. o.fftSize = 256;
  9673. const u = new Uint8Array(o.frequencyBinCount);
  9674. a.connect(o), o.connect(e);
  9675. const h = () => {
  9676. c && window.clearInterval(c);
  9677. }, p = () => {
  9678. r.state === "suspended" && r.resume(), c = window.setInterval(() => {
  9679. o.getByteFrequencyData(u);
  9680. let d = Math.round(u.reduce((f, m) => f + m) / u.length);
  9681. d = Math.min(100, d), n = d, i && i(d);
  9682. }, s);
  9683. };
  9684. return p(), {
  9685. updateInterval: (d) => {
  9686. h(), s = d, p();
  9687. },
  9688. getLevel: () => n,
  9689. dispose: () => {
  9690. h(), a.disconnect(), o.disconnect();
  9691. }
  9692. };
  9693. }
  9694. class J0 extends De {
  9695. constructor() {
  9696. super();
  9697. g(this, "audioContext");
  9698. g(this, "stream");
  9699. g(this, "sourceNode");
  9700. g(this, "analyser");
  9701. this.audioContext = Ft.getInstance(), this.stream = new MediaStream();
  9702. }
  9703. getLevel() {
  9704. return this.analyser ? this.analyser.getLevel() : 0;
  9705. }
  9706. /**
  9707. * 开启监听 audio level 的变化
  9708. *
  9709. * @param {MediaStreamTrack} track 音频轨
  9710. * @param {number} [interval=1000] 检测间隔,单位毫秒,默认 1000ms
  9711. */
  9712. start(e, t = 1e3) {
  9713. this.sourceNode && this.stop(), this.stream.addTrack(e), this.sourceNode = this.audioContext.createMediaStreamSource(this.stream);
  9714. const i = this.audioContext.createMediaStreamDestination();
  9715. this.analyser = q0(this.audioContext, this.sourceNode, i, t, (s) => {
  9716. this.emit("audioLevel", s);
  9717. });
  9718. }
  9719. stop() {
  9720. this.analyser && this.analyser.dispose(), this.analyser = void 0, this.sourceNode = void 0, this.stream.getAudioTracks().forEach((e) => {
  9721. this.stream.removeTrack(e);
  9722. });
  9723. }
  9724. dispose() {
  9725. this.stop();
  9726. }
  9727. }
  9728. class bn extends De {
  9729. constructor(e, t, i, s) {
  9730. super();
  9731. g(this, "uid");
  9732. g(this, "name");
  9733. g(this, "rtsManager");
  9734. g(this, "callId", "");
  9735. // 本地音量检测
  9736. g(this, "audioLevelMonitor");
  9737. g(this, "audioVolumeIndicationInterval", 0);
  9738. this.uid = e, this.name = t, this.rtsManager = i, this.audioVolumeIndicationInterval = s, this.audioLevelMonitor = new J0();
  9739. }
  9740. get userId() {
  9741. return this.uid;
  9742. }
  9743. get displayname() {
  9744. return this.name;
  9745. }
  9746. createCallId() {
  9747. this.callId || (this.callId = He.createCallid());
  9748. }
  9749. setUserInfo(e, t) {
  9750. this.uid = e, this.name = t;
  9751. }
  9752. refreshUserInfo(e) {
  9753. this.uid = e;
  9754. }
  9755. /**
  9756. * 获取音频 level
  9757. */
  9758. getAudioLevel() {
  9759. return this.audioLevelMonitor.getLevel();
  9760. }
  9761. enableAudioVolumeIndication(e) {
  9762. this.audioVolumeIndicationInterval = e;
  9763. }
  9764. /**
  9765. * 销毁用户,清空数据
  9766. */
  9767. clear() {
  9768. this.audioLevelMonitor.dispose();
  9769. }
  9770. }
  9771. class En {
  9772. /**
  9773. * 将设备状态转换成String通过同名通道发送出去
  9774. * @param status
  9775. * @returns
  9776. */
  9777. static getCurrentStatus(a) {
  9778. let e = 0;
  9779. a.micOpen && (e += 1), a.micInterrupted && (e += 2), a.cameraOpen && (e += 4), a.screenShare && (e += 128), a.audioDisable && (e += 8), a.videoDisable && (e += 16), a.screenDisable && (e += 256);
  9780. let t = e.toString(16);
  9781. for (; t.length < 16; )
  9782. t = "0" + t;
  9783. return t;
  9784. }
  9785. /**
  9786. * 解析收到的status值
  9787. * @param status
  9788. */
  9789. static parseStatus(a) {
  9790. let e = parseInt(a, 16);
  9791. return {
  9792. micOpen: !!(e & 1),
  9793. micInterrupted: !!(e & 2),
  9794. cameraOpen: !!(e & 4),
  9795. screenShare: !!(e & 128),
  9796. audioDisable: !!(e & 8),
  9797. videoDisable: !!(e & 16),
  9798. screenDisable: !!(e & 256),
  9799. backgroundMode: !!(e & 32),
  9800. accompanyPlaying: !!(e & 64)
  9801. };
  9802. }
  9803. }
  9804. const _n = "customVideoProfile", An = "customScreenProfile", Hr = {
  9805. width: 1280,
  9806. height: 720,
  9807. frameRate: 30,
  9808. maxBitrate: 2e3
  9809. }, ja = {
  9810. width: 1920,
  9811. height: 1080,
  9812. frameRate: 30,
  9813. maxBitrate: 2600
  9814. };
  9815. var ti = /* @__PURE__ */ ((r) => (r[r.ERROR_DEVICE_UNKNOWNERROR = 1e4] = "ERROR_DEVICE_UNKNOWNERROR", r[r.ERROR_DEVICE_AUDIODEVICE_NOTFOUND = 10001] = "ERROR_DEVICE_AUDIODEVICE_NOTFOUND", r[r.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED = 10002] = "ERROR_DEVICE_AUDIODEVICE_NOTALLOWED", r[r.ERROR_DEVICE_AUDIODEVICE_NOTREADABLE = 10003] = "ERROR_DEVICE_AUDIODEVICE_NOTREADABLE", r[r.ERROR_DEVICE_VIDEODEVICE_NOTFOUND = 10004] = "ERROR_DEVICE_VIDEODEVICE_NOTFOUND", r[r.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED = 10005] = "ERROR_DEVICE_VIDEODEVICE_NOTALLOWED", r[r.ERROR_DEVICE_VIDEODEVICE_NOTREADABLE = 10006] = "ERROR_DEVICE_VIDEODEVICE_NOTREADABLE", r[r.ERROR_SCREENSHARE_NOTSUPPORT = 10010] = "ERROR_SCREENSHARE_NOTSUPPORT", r[r.ERROR_SCREENSHARE_NOTALLOWED = 10011] = "ERROR_SCREENSHARE_NOTALLOWED", r[r.ERROR_SCREENSHARE_ENDED = 10012] = "ERROR_SCREENSHARE_ENDED", r[r.ERROR_SCREENSHARE_NOPERMISSION = 10013] = "ERROR_SCREENSHARE_NOPERMISSION", r[r.ERROR_SCREENSHARE_SAFARI_INVALIDACCESS = 10014] = "ERROR_SCREENSHARE_SAFARI_INVALIDACCESS", r[r.ERROR_SCREENSHARE_UNKNOWNERRO = 10019] = "ERROR_SCREENSHARE_UNKNOWNERRO", r[r.ERROR_DEVICE_NOTSUPPORT = 2e4] = "ERROR_DEVICE_NOTSUPPORT", r))(ti || {});
  9816. const G0 = {
  9817. 1e4: _e.AliEngineLocalDeviceExceptionTypeUnknown,
  9818. 2e4: _e.AliEngineLocalDeviceExceptionTypeUnknown,
  9819. 10001: _e.AliEngineLocalDeviceExceptionTypeMicNotAvailable,
  9820. 10002: _e.AliEngineLocalDeviceExceptionTypeMicAuthFail,
  9821. 10003: _e.AliEngineLocalDeviceExceptionTypeMicOpenFail,
  9822. 10005: _e.AliEngineLocalDeviceExceptionTypeCameraAuthFail,
  9823. 10004: _e.AliEngineLocalDeviceExceptionTypeVideoDeviceException,
  9824. 10006: _e.AliEngineLocalDeviceExceptionTypeCameraOpenFail,
  9825. 10010: _e.AliEngineLocalDeviceExceptionTypeDisplayException,
  9826. 10011: _e.AliEngineLocalDeviceExceptionTypeDisplayException,
  9827. 10012: _e.AliEngineLocalDeviceExceptionTypeDisplayException,
  9828. 10013: _e.AliEngineLocalDeviceExceptionTypeDisplayException,
  9829. 10014: _e.AliEngineLocalDeviceExceptionTypeDisplayException,
  9830. 10019: _e.AliEngineLocalDeviceExceptionTypeDisplayException
  9831. };
  9832. var Je = /* @__PURE__ */ ((r) => (r.CREATE_ENGINE = "create_engine", r.JOIN = "join", r.WANT_INSERT_PUB_TASK = "wantInsertPubTask", r.INSERT_PUB_TASK = "InsertPubTask", r.HANDLE_PUB_TASK = "HandlePubTask", r.RECV_NOTIFY_PUBLISH = "RecvNotifyPublish", r.INSERT_SUB_TASK = "InsertSubTask", r.HANDLE_SUB_TASK = "HandleSubTask", r.FIRST_REMOTE = "first_remote", r))(Je || {}), Xe = /* @__PURE__ */ ((r) => (r.START = "start", r.SEND_SIG = "send_sig", r.RECV_RST = "recv_rst", r.END = "end", r.RECEIVED = "received", r.DECODED = "decoded", r.PLAYED = "played", r))(Xe || {});
  9833. const X0 = (r) => r.getAudioTracks()[0];
  9834. function za(r) {
  9835. var a;
  9836. if (((a = r == null ? void 0 : r.nodeName) == null ? void 0 : a.toLowerCase()) === "video")
  9837. return r.setAttribute("playsinline", ""), r;
  9838. if (typeof r == "string") {
  9839. let e = document.getElementById(r);
  9840. if (e) {
  9841. if (e.nodeName.toLocaleLowerCase() === "video")
  9842. return e.setAttribute("playsinline", ""), e;
  9843. throw new V(U.ERR_INVALID_ARGUMENTS, "element should be HtmlVideoElement");
  9844. } else
  9845. throw new V(U.ERR_INVALID_ARGUMENTS, "element not founded");
  9846. } else
  9847. throw new V(U.ERR_INVALID_ARGUMENTS, "element id should be string");
  9848. }
  9849. function jr(r) {
  9850. var e;
  9851. const a = [];
  9852. if (Array.isArray(r))
  9853. r.forEach((t) => {
  9854. try {
  9855. a.push(za(t));
  9856. } catch (i) {
  9857. }
  9858. });
  9859. else if (typeof r == "string" || ((e = r == null ? void 0 : r.nodeName) == null ? void 0 : e.toLowerCase()) === "video")
  9860. try {
  9861. a.push(za(r));
  9862. } catch (t) {
  9863. }
  9864. return a;
  9865. }
  9866. function Et(r) {
  9867. return new Promise((a) => setTimeout(a, r));
  9868. }
  9869. function Wa(r, a, e = 1e3, t = (i) => !0) {
  9870. return w(this, null, function* () {
  9871. let i = 0, s;
  9872. for (; i < a; )
  9873. try {
  9874. return yield r(i);
  9875. } catch (n) {
  9876. if (i++, i >= a || !t(n))
  9877. throw n || s;
  9878. yield new Promise((c) => setTimeout(c, e));
  9879. }
  9880. });
  9881. }
  9882. function Y0(r, a) {
  9883. let e = 0;
  9884. const t = [];
  9885. for (; e < r.byteLength; ) {
  9886. const i = Math.min(a, r.byteLength - e), s = r.slice(e, e + i);
  9887. t.push(s), e += i;
  9888. }
  9889. return t;
  9890. }
  9891. function Z0(r) {
  9892. var a, e;
  9893. try {
  9894. const t = new URL(r), [i, s] = t.pathname.slice(1).split("/"), n = /(\w+)(web\w{5}-\w{4}-\w{4}-\w{4}-\w{12})/.exec(s), c = n == null ? void 0 : n[1], o = n == null ? void 0 : n[2], u = new URLSearchParams(t.search), h = parseInt((e = (a = u.get("auth_key")) == null ? void 0 : a.split("-")[0]) != null ? e : "0") * 1e3;
  9895. return {
  9896. appId: i,
  9897. channelId: c,
  9898. sessionId: o,
  9899. timeoutTs: h
  9900. };
  9901. } catch (t) {
  9902. return null;
  9903. }
  9904. }
  9905. function $a(r, a) {
  9906. let e = a;
  9907. return typeof window.__ali_prefer_media_server == "string" && window.__ali_prefer_media_server !== "" && (e = window.__ali_prefer_media_server), e ? `${r}&ali_prefer_media_server=${e}` : r;
  9908. }
  9909. const yn = (r, a, e = !1) => {
  9910. const t = () => (r.muted = !0, Promise.race([Et(500), r._playPromise || Promise.resolve()]).catch(() => {
  9911. }).then(() => {
  9912. let i;
  9913. return e && r.srcObject === a ? i = Promise.resolve() : (r.load(), r.srcObject = a, i = r.play(), r._playPromise = i), i;
  9914. }));
  9915. return new Promise((i) => {
  9916. if (le.BrowserUtil.isMicroMessenger) {
  9917. const s = window.top !== window.self, n = window.WeixinJSBridge || window.top.WeixinJSBridge;
  9918. n ? n.invoke("getNetworkType", {}, () => {
  9919. i(t());
  9920. }) : (s ? window.top.document : document).addEventListener("WeixinJSBridgeReady", () => {
  9921. n.invoke("getNetworkType", {}, () => {
  9922. i(t());
  9923. });
  9924. }), setTimeout(() => {
  9925. i(t());
  9926. }, 1e3);
  9927. } else
  9928. setTimeout(() => {
  9929. i(t());
  9930. }, 0);
  9931. });
  9932. }, at = (r) => {
  9933. Promise.race([Et(100), r._playPromise || Promise.resolve()]).catch(() => {
  9934. }).then(() => {
  9935. r.srcObject = null, r._playPromise = void 0;
  9936. });
  9937. };
  9938. var Cn = /* @__PURE__ */ ((r) => (r[r.AliEngineDataMsgNone = 0] = "AliEngineDataMsgNone", r[r.AliEngineDataMsgMusicProgress = 1] = "AliEngineDataMsgMusicProgress", r[r.AliEngineDataMsgCustom = 2] = "AliEngineDataMsgCustom", r))(Cn || {});
  9939. class Di {
  9940. constructor(a, e, t, i = 0) {
  9941. g(this, "msgType");
  9942. g(this, "msgId");
  9943. g(this, "protocolVersion");
  9944. g(this, "tlvVersion");
  9945. this.msgType = a, this.msgId = e, this.protocolVersion = t, this.tlvVersion = i;
  9946. }
  9947. build() {
  9948. const a = new Uint8Array(4);
  9949. return a.set(Uint8Array.from([this.protocolVersion, this.tlvVersion << 4 | this.msgType & 15]), 0), a.set(Uint16Array.from([this.msgId]), 2), a;
  9950. }
  9951. static parse(a) {
  9952. const e = new DataView(a), t = e.getUint8(0), i = e.getUint8(1) >> 4, s = e.getUint8(1) & 15, n = e.getUint16(2);
  9953. return new Di(s, n, t, i);
  9954. }
  9955. }
  9956. const Pt = 5;
  9957. class Si {
  9958. constructor(a, e, t) {
  9959. g(this, "_byteArray");
  9960. if (this._byteArray = new Uint8Array(0), a !== void 0 && e !== void 0 && t !== void 0) {
  9961. const s = new Di(a, e, t).build();
  9962. this._byteArray = new Uint8Array(s.byteLength + this._byteArray.byteLength), this._byteArray.set(s, 0);
  9963. }
  9964. }
  9965. write(a, e) {
  9966. const t = this._byteArray, i = new ArrayBuffer(Pt), s = new DataView(i);
  9967. s.setUint8(0, a), s.setUint32(1, e.byteLength);
  9968. const n = new Uint8Array(t.byteLength + Pt + e.byteLength);
  9969. n.set(t, 0), n.set(new Uint8Array(i), t.byteLength), n.set(new Uint8Array(e), t.byteLength + Pt), this._byteArray = n;
  9970. }
  9971. static parse(a) {
  9972. const e = {}, t = new DataView(a);
  9973. let i = 0;
  9974. for (; i < a.byteLength; ) {
  9975. const s = t.getUint8(i), n = t.getUint32(i + 1);
  9976. if (i + Pt + n <= a.byteLength) {
  9977. const c = a.slice(i + Pt, i + Pt + n);
  9978. e[s] = c, i += Pt + n;
  9979. } else
  9980. break;
  9981. }
  9982. return e;
  9983. }
  9984. get buffer() {
  9985. return this._byteArray.buffer;
  9986. }
  9987. }
  9988. class ci {
  9989. constructor(a = 0, e = !0, t = 1, i = !1, s = 0, n = !1, c = !1, o = 3) {
  9990. g(this, "_fin", !0);
  9991. g(this, "_hasExtension", !1);
  9992. g(this, "_version", 0);
  9993. g(this, "_frameType", 1);
  9994. g(this, "_isEncrypted", !1);
  9995. g(this, "_isCompressed", !1);
  9996. g(this, "_signalType", 3);
  9997. g(this, "_payloadLength", 0);
  9998. this._fin = e, this._hasExtension = i, this._version = s, this._frameType = t, this._isEncrypted = n, this._isCompressed = c, this._signalType = o, this._payloadLength = a;
  9999. }
  10000. get fin() {
  10001. return this._fin;
  10002. }
  10003. get hasExtension() {
  10004. return this._hasExtension;
  10005. }
  10006. get version() {
  10007. return this._version;
  10008. }
  10009. get frameType() {
  10010. return this._frameType;
  10011. }
  10012. get isEncrypted() {
  10013. return this._isEncrypted;
  10014. }
  10015. get isCompressed() {
  10016. return this._isCompressed;
  10017. }
  10018. get signalType() {
  10019. return this._signalType;
  10020. }
  10021. get payloadLength() {
  10022. return this._payloadLength;
  10023. }
  10024. toBuffer() {
  10025. const a = new ArrayBuffer(4), e = new DataView(a);
  10026. return e.setUint8(
  10027. 0,
  10028. (this._fin ? 1 : 0) << 7 | (this._hasExtension ? 1 : 0) << 6 | this._version << 4 | this._frameType & 15
  10029. ), e.setUint8(
  10030. 1,
  10031. (this._isEncrypted ? 1 : 0) << 7 | (this._isCompressed ? 1 : 0) << 6 | this._signalType & 15
  10032. ), e.setUint16(2, this._payloadLength), a;
  10033. }
  10034. static parse(a) {
  10035. const e = new DataView(a), t = e.getUint8(0) >> 7 === 1, i = (e.getUint8(0) & 64) >> 6 === 1, s = (e.getUint8(0) & 48) >> 4, n = e.getUint8(0) & 15, c = e.getUint8(1) >> 7 === 1, o = (e.getUint8(1) & 64) >> 6 === 1, u = e.getUint8(1) & 15, h = e.getUint16(2);
  10036. return new ci(
  10037. h,
  10038. t,
  10039. n,
  10040. i,
  10041. s,
  10042. c,
  10043. o,
  10044. u
  10045. );
  10046. }
  10047. }
  10048. class Ti {
  10049. constructor(a, e) {
  10050. g(this, "_body");
  10051. g(this, "_header", new ci());
  10052. this._header = a, this._body = e;
  10053. }
  10054. get header() {
  10055. return this._header;
  10056. }
  10057. get isFin() {
  10058. return this._header.fin;
  10059. }
  10060. get body() {
  10061. return this._body;
  10062. }
  10063. toGRTNBuffer() {
  10064. const a = this._header.toBuffer(), e = this._body, t = new ArrayBuffer(4);
  10065. new DataView(t).setUint8(0, 1 * Math.pow(2, 4));
  10066. const i = new Uint8Array(t.byteLength + a.byteLength + e.byteLength);
  10067. return i.set(new Uint8Array(t), 0), i.set(new Uint8Array(a), t.byteLength), i.set(new Uint8Array(e), t.byteLength + a.byteLength), i.buffer;
  10068. }
  10069. static parse(a) {
  10070. const e = a.slice(0, 4), t = ci.parse(e);
  10071. let i = new ArrayBuffer(0);
  10072. return a.byteLength - 4 >= t.payloadLength && (i = a.slice(4, 4 + t.payloadLength)), new Ti(t, i);
  10073. }
  10074. }
  10075. const Br = (r) => {
  10076. const a = r.byteLength, e = new DataView(r);
  10077. let t = 0;
  10078. for (let i = 0; i < a; i++)
  10079. t = t * 256 + e.getUint8(i);
  10080. return t;
  10081. };
  10082. let Ka = 0;
  10083. class qt {
  10084. constructor(a, e = 0, t = 0, i = 0) {
  10085. g(this, "data");
  10086. g(this, "networkTime");
  10087. g(this, "futureOrProgress");
  10088. g(this, "type");
  10089. this.data = a, this.type = e, this.networkTime = t, this.futureOrProgress = i;
  10090. }
  10091. toBuffer() {
  10092. const a = new Si(0, 0, 0);
  10093. a.write(1, Uint8Array.from([0]).buffer), a.write(2, Uint16Array.from([0]).buffer), Ka++, a.write(3, Uint32Array.from([Ka]).buffer);
  10094. const e = new Si();
  10095. return e.write(1, Uint8Array.from([0]).buffer), e.write(2, Uint8Array.from([this.type]).buffer), e.write(3, Uint32Array.from([this.futureOrProgress]).buffer), e.write(
  10096. 4,
  10097. Uint32Array.from([Number(this.networkTime >> 32 & 4294967295), Number(this.networkTime & 4294967295)]).buffer
  10098. ), e.write(5, this.data), a.write(30, e.buffer), a.buffer;
  10099. }
  10100. static parse(a) {
  10101. if (!a || a.byteLength < 4)
  10102. return;
  10103. Di.parse(a.slice(0, 4));
  10104. const t = Si.parse(a.slice(4))[
  10105. 30
  10106. /* TLV_TAG_Music */
  10107. ];
  10108. if (!t)
  10109. return;
  10110. const i = Si.parse(t), s = i[
  10111. 2
  10112. /* TLV_TAG_Command */
  10113. ], n = i[
  10114. 3
  10115. /* TLV_TAG_FutureOrProgress */
  10116. ], c = i[
  10117. 4
  10118. /* TLV_TAG_NetworkTime */
  10119. ], o = i[
  10120. 5
  10121. /* TLV_TAG_UserMsg */
  10122. ];
  10123. if (o.byteLength !== 0)
  10124. return new qt(
  10125. o,
  10126. Br(s),
  10127. Br(c),
  10128. Br(n)
  10129. );
  10130. }
  10131. }
  10132. var Q0 = Object.defineProperty, ec = Object.getOwnPropertyDescriptor, me = (r, a, e, t) => {
  10133. for (var i = t > 1 ? void 0 : t ? ec(a, e) : a, s = r.length - 1, n; s >= 0; s--)
  10134. (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i);
  10135. return t && i && Q0(a, e, i), i;
  10136. };
  10137. const qa = 30;
  10138. class Qt extends De {
  10139. constructor() {
  10140. super();
  10141. g(this, "_state");
  10142. g(this, "time");
  10143. this._state = Y.AliRtcStatePublishIdle, this.time = Date.now();
  10144. }
  10145. get state() {
  10146. return this._state;
  10147. }
  10148. setState(e) {
  10149. const t = this._state, i = this.time;
  10150. this._state = e, this.time = Date.now(), this.emit("change", t, e, Math.floor((this.time - i) / 1e3));
  10151. }
  10152. }
  10153. var lt;
  10154. const ge = (lt = class extends bn {
  10155. constructor(e) {
  10156. const { rtsManager: t, localStreamManager: i, slsReporter: s, signalingManager: n, audioVolumeIndicationInterval: c, parameter: o } = e;
  10157. super("", "", t, c);
  10158. g(this, "_url", "");
  10159. g(this, "joinTime", 0);
  10160. g(this, "_isPublishing", !1);
  10161. g(this, "publishPromise", Promise.resolve({
  10162. traceId: "",
  10163. l1ip: void 0
  10164. }));
  10165. g(this, "previewElements", []);
  10166. // 本地主流预览容器元素列表
  10167. g(this, "screenPreviewElements", []);
  10168. // 本地辅流预览容器元素列表
  10169. g(this, "streamManager");
  10170. g(this, "dc");
  10171. g(this, "streamTracks");
  10172. // 本地流 track 信息
  10173. g(this, "publishId", rt());
  10174. g(this, "signalingManager");
  10175. g(this, "traceId", "");
  10176. g(this, "monitorTimerId");
  10177. g(this, "monitorDataCache", {});
  10178. g(this, "trackTraceIdMap", {});
  10179. g(this, "candidateDataCache", []);
  10180. g(this, "pcMediaStatsMap", {});
  10181. g(this, "slsReporter");
  10182. g(this, "audioPubState");
  10183. g(this, "videoPubState");
  10184. g(this, "videoSmallPubState");
  10185. g(this, "screenPubState");
  10186. g(this, "dataPubState");
  10187. // @ts-ignore
  10188. g(this, "parameter", {});
  10189. g(this, "onTrackEnd", (e) => {
  10190. this.emit(e);
  10191. });
  10192. this.streamManager = i, this.signalingManager = n, this.slsReporter = s, this.parameter = o, this.streamManager.on("trackended", (u) => {
  10193. this.onTrackEnd(u);
  10194. }), this.streamManager.on("publishupdate", () => {
  10195. this.publishUpdate();
  10196. }), this.audioPubState = new Qt(), this.audioPubState.on("change", (u, h, p) => {
  10197. this.emit("audioPublishStateChanged", u, h, p);
  10198. }), this.videoPubState = new Qt(), this.videoPubState.on("change", (u, h, p) => {
  10199. this.emit("videoPublishStateChanged", u, h, p);
  10200. }), this.videoSmallPubState = new Qt(), this.videoSmallPubState.on("change", (u, h, p) => {
  10201. this.emit("dualStreamPublishStateChanged", u, h, p);
  10202. }), this.screenPubState = new Qt(), this.screenPubState.on("change", (u, h, p) => {
  10203. this.emit("screenPublishStateChanged", u, h, p);
  10204. }), this.dataPubState = new Qt(), this.dataPubState.on("change", (u, h, p) => {
  10205. this.emit("dataPublishStateChanged", u, h, p);
  10206. }), this.startStreamMonitor();
  10207. }
  10208. get url() {
  10209. return this._url;
  10210. }
  10211. set url(e) {
  10212. this._url = e, this.rtsManager.updateAuth(e);
  10213. }
  10214. get joined() {
  10215. return !!this.uid;
  10216. }
  10217. get isPublishing() {
  10218. return this._isPublishing;
  10219. }
  10220. get publishStreams() {
  10221. return this.streamManager.publishStreams;
  10222. }
  10223. get cameraTrack() {
  10224. return this.streamManager.cameraStreamInfo.originVideoTrack;
  10225. }
  10226. get screenTrack() {
  10227. return this.streamManager.screenStreamInfo.originVideoTrack;
  10228. }
  10229. get audioTrack() {
  10230. return this.streamManager.cameraStreamInfo.originAudioTrack;
  10231. }
  10232. get hasCamera() {
  10233. return !!this.streamManager.cameraStreamInfo.originVideoTrack;
  10234. }
  10235. get hasMicrophone() {
  10236. return !!this.streamManager.cameraStreamInfo.originAudioTrack;
  10237. }
  10238. get hasScreenShare() {
  10239. return !!this.streamManager.screenStreamInfo.originVideoTrack;
  10240. }
  10241. // 媒体信令层面上有 camera 流
  10242. get hasCameraTrackInMS() {
  10243. var e;
  10244. return !!((e = this.streamTracks) != null && e.find(
  10245. ({ ssrc: t, type: i, msid: s }) => i === "video" && t && s === T.VideoLarge
  10246. ));
  10247. }
  10248. get hasCameraDualTrackInMS() {
  10249. var e;
  10250. return !!((e = this.streamTracks) != null && e.find(
  10251. ({ ssrc: t, type: i, msid: s }) => i === "video" && t && s === T.VideoSmall
  10252. ));
  10253. }
  10254. // 媒体信令层面上有 screen 流
  10255. get hasScreenTrackInMS() {
  10256. var e;
  10257. return !!((e = this.streamTracks) != null && e.find(({ ssrc: t, type: i, msid: s }) => i === "video" && t && s === T.Screen));
  10258. }
  10259. // 媒体信令层面上有 audio 流(主流)
  10260. get hasAudioTrackInMS() {
  10261. var e;
  10262. return !!((e = this.streamTracks) != null && e.find(({ ssrc: t, type: i, msid: s }) => i === "audio" && t && s === T.Audio));
  10263. }
  10264. get cameraDirection() {
  10265. var e, t;
  10266. return (t = (e = this.streamManager.cameraStreamInfo) == null ? void 0 : e.cameraVideoConstraints) == null ? void 0 : t.facingMode;
  10267. }
  10268. get audioCaptureDisabled() {
  10269. return this.streamManager.audioCaptureDisabled;
  10270. }
  10271. get cameraCaptureDisabled() {
  10272. return this.streamManager.cameraCaptureDisabled;
  10273. }
  10274. get publishLocalVideoStreamEnabled() {
  10275. return this.streamManager.publishLocalVideoStreamEnabled;
  10276. }
  10277. get publishLocalAudioStreamEnabled() {
  10278. return this.streamManager.publishLocalAudioStreamEnabled;
  10279. }
  10280. get publishLocalScreenStreamEnabled() {
  10281. return this.streamManager.publishLocalScreenStreamEnabled;
  10282. }
  10283. setPublishLocalAudioStreamEnabled(e) {
  10284. this.streamManager.publishLocalAudioStreamEnabled = e;
  10285. }
  10286. setPublishLocalVideoStreamEnabled(e) {
  10287. this.streamManager.publishLocalVideoStreamEnabled = e;
  10288. }
  10289. setPublishLocalScreenStreamEnabled(e) {
  10290. this.streamManager.publishLocalScreenStreamEnabled = e;
  10291. }
  10292. initInfo(e, t) {
  10293. this.joinTime = Date.now(), this.rtsManager.localJoinTime = this.joinTime, this.setUserInfo(e.userId, e.userId), this.url = t, this.callId = e.sessionId || He.createCallid(), this.updatePubId();
  10294. }
  10295. setVideoProfile(e) {
  10296. return w(this, null, function* () {
  10297. yield this.streamManager.setVideoProfile(_n, e);
  10298. });
  10299. }
  10300. setVideoContentHint(e) {
  10301. this.streamManager.setVideoContentHint(e);
  10302. }
  10303. setScreenContentHint(e) {
  10304. this.streamManager.setScreenContentHint(e);
  10305. }
  10306. setAudioProfile(e) {
  10307. return w(this, null, function* () {
  10308. yield this.streamManager.setAudioProfile(e);
  10309. });
  10310. }
  10311. setScreenProfile(e) {
  10312. return w(this, null, function* () {
  10313. yield this.streamManager.setScreenProfile(An, e);
  10314. });
  10315. }
  10316. setCameraDirection(e) {
  10317. if (e === oi.CAMERA_FRONT)
  10318. this.streamManager.setCameraVideoConstraints({
  10319. facingMode: "user"
  10320. });
  10321. else if (e === oi.CAMERA_REAR)
  10322. this.streamManager.setCameraVideoConstraints({
  10323. facingMode: "environment"
  10324. });
  10325. else
  10326. throw new V(U.ERR_CAMERA_OPEN_FAIL, `camera direction set to ${e} failed`);
  10327. }
  10328. setCameraDeviceId(e) {
  10329. this.streamManager.setCameraVideoConstraints({
  10330. deviceId: e
  10331. });
  10332. }
  10333. muteLocalCamera(e) {
  10334. this.streamManager.setCameraMuted(e), this.slsReporter.reportMute(this.callId, !e, "video");
  10335. }
  10336. muteLocalMic(e) {
  10337. this.streamManager.setAudioMuted(e), this.slsReporter.reportMute(this.callId, !e, "audio");
  10338. }
  10339. muteLocalScreen(e) {
  10340. this.streamManager.setScreenMuted(e), this.slsReporter.reportMute(this.callId, !e, "screen");
  10341. }
  10342. setMicrophoneDeviceId(e) {
  10343. this.streamManager.setMicAudioConstraints({
  10344. deviceId: e
  10345. });
  10346. }
  10347. setMicrophoneConstraints(e) {
  10348. this.streamManager.setMicAudioConstraints(e);
  10349. }
  10350. updatePubId() {
  10351. this.publishId = rt();
  10352. }
  10353. clearPublishState() {
  10354. this.streamTracks = void 0;
  10355. }
  10356. // 离会,对于本地用户来说核心是停止推流
  10357. leave() {
  10358. return w(this, null, function* () {
  10359. this._isPublishing && (this._isPublishing = !1, yield this.unPublish()), this.joinTime = 0, this.dc = void 0;
  10360. });
  10361. }
  10362. clear() {
  10363. return w(this, null, function* () {
  10364. Ni(lt.prototype, this, "clear").call(this), this.stopPreview(), this.resetPreviewElements(), this.resetSecondayPreviewElements(), this.clearStream(), yield this.leave(), this.streamManager.cameraCaptureDisabled = !1;
  10365. });
  10366. }
  10367. resetElement(e) {
  10368. this.previewElements.includes(e) && (at(e), this.previewElements.splice(this.previewElements.indexOf(e), 1)), this.screenPreviewElements.includes(e) && (at(e), this.screenPreviewElements.splice(this.screenPreviewElements.indexOf(e), 1));
  10369. }
  10370. setPreviewElement(e) {
  10371. const { videoElement: t, screen: i } = e;
  10372. i ? this.screenPreviewElements.includes(t) || this.screenPreviewElements.push(t) : this.previewElements.includes(t) || this.previewElements.push(t);
  10373. }
  10374. startDefaultCamera(e) {
  10375. return w(this, null, function* () {
  10376. const { hasCamera: t, cameraCaptureDisabled: i, publishLocalVideoStreamEnabled: s } = this;
  10377. if (!t && !e && !i && s)
  10378. try {
  10379. yield this.startCameraCapture();
  10380. } catch (n) {
  10381. const c = n.errorCode;
  10382. let o = U.ERR_CAMERA_OPEN_FAIL;
  10383. throw c === ti.ERROR_DEVICE_AUDIODEVICE_NOTFOUND ? o = U.ERR_CAMERA_NOT_AVAILABLE : c === ti.ERROR_DEVICE_VIDEODEVICE_NOTALLOWED && (o = U.ERR_CAMERA_AUTH_FAIL), new V(o, `camera open fail: ${n.message}`);
  10384. }
  10385. });
  10386. }
  10387. startDefaultAudio() {
  10388. return w(this, null, function* () {
  10389. const { hasMicrophone: e, audioCaptureDisabled: t, publishLocalAudioStreamEnabled: i } = this;
  10390. if (!e && !t && i)
  10391. try {
  10392. yield this.startAudioCapture();
  10393. } catch (s) {
  10394. const n = s.errorCode;
  10395. let c = U.ERR_MIC_OPEN_FAIL;
  10396. throw n === ti.ERROR_DEVICE_AUDIODEVICE_NOTFOUND ? c = U.ERR_MIC_NOT_AVAILABLE : n === ti.ERROR_DEVICE_AUDIODEVICE_NOTALLOWED && (c = U.ERR_MIC_AUTH_FAIL), new V(c, `mic open fail: ${s.message}`);
  10397. }
  10398. });
  10399. }
  10400. setViewConfig(e, t) {
  10401. if (!e) {
  10402. t === se.AliRtcVideoTrackCamera ? this.stopPreview({
  10403. primary: !0,
  10404. screen: !1
  10405. }) : this.stopPreview({
  10406. primary: !1,
  10407. screen: !0
  10408. });
  10409. return;
  10410. }
  10411. if (![se.AliRtcVideoTrackCamera, se.AliRtcVideoTrackScreen].includes(t))
  10412. throw new V(U.ERR_INVALID_ARGUMENTS, "set view config invalid track", { track: t });
  10413. e.forEach((i) => {
  10414. this.setPreviewElement({
  10415. videoElement: i,
  10416. screen: t === se.AliRtcVideoTrackScreen
  10417. });
  10418. });
  10419. }
  10420. startCameraCapture() {
  10421. return w(this, null, function* () {
  10422. return this.streamManager.cameraCaptureDisabled = !1, yield this.createLocalStream({
  10423. video: !0
  10424. });
  10425. });
  10426. }
  10427. stopCameraCapture() {
  10428. return w(this, null, function* () {
  10429. this.streamManager.cameraCaptureDisabled = !0, yield this.stopLocalStream({
  10430. video: !0
  10431. });
  10432. });
  10433. }
  10434. startAudioCapture() {
  10435. return w(this, null, function* () {
  10436. return this.streamManager.audioCaptureDisabled = !1, yield this.createLocalStream({
  10437. audio: !0
  10438. });
  10439. });
  10440. }
  10441. stopAudioCapture() {
  10442. return w(this, null, function* () {
  10443. this.streamManager.audioCaptureDisabled = !0, yield this.stopLocalStream({
  10444. audio: !0
  10445. });
  10446. });
  10447. }
  10448. /**
  10449. * 预览本地流
  10450. * @param {PreviewConfig} previewParams
  10451. * @returns {Promise<MediaStream>}
  10452. */
  10453. preview(e) {
  10454. return w(this, null, function* () {
  10455. const { videoElement: t, screen: i } = e != null ? e : {};
  10456. try {
  10457. let s = i ? this.streamManager.screenStreamInfo.previewStream : this.streamManager.cameraStreamInfo.previewStream;
  10458. if (!t)
  10459. throw new V(U.ERR_INVALID_ARGUMENTS, "no video element found", {
  10460. videoElement: t
  10461. });
  10462. if (!s) {
  10463. O.info(`[${lt.logName}]`, "preview no stream founded");
  10464. return;
  10465. }
  10466. return yn(t, s.mediaStream), this.setPreviewElement(e), s.mediaStream;
  10467. } catch (s) {
  10468. const n = U.ERR_INNER;
  10469. throw V.fromError(s, n, "preview failed");
  10470. }
  10471. });
  10472. }
  10473. /**
  10474. * 在所有预览容器中预览当前流
  10475. * @param {boolean} screen 是否指定预览辅流
  10476. */
  10477. previewAll(e) {
  10478. return w(this, null, function* () {
  10479. const { primary: t = !0, screen: i = !0 } = e != null ? e : {};
  10480. if (t && this.previewElements.length)
  10481. for (let s = 0; s < this.previewElements.length; s++) {
  10482. const n = this.previewElements[s];
  10483. yield this.preview({ videoElement: n });
  10484. }
  10485. if (i && this.screenPreviewElements.length)
  10486. for (let s = 0; s < this.screenPreviewElements.length; s++) {
  10487. const n = this.screenPreviewElements[s];
  10488. yield this.preview({ videoElement: n, screen: !0 });
  10489. }
  10490. });
  10491. }
  10492. stopPreview(e) {
  10493. const { videoElement: t, primary: i = !0, screen: s = !0 } = e || {};
  10494. if (!t)
  10495. i && (this.previewElements.forEach((n) => {
  10496. at(n);
  10497. }), this.previewElements = []), s && (this.screenPreviewElements.forEach((n) => {
  10498. at(n);
  10499. }), this.screenPreviewElements = []);
  10500. else {
  10501. const n = this.previewElements.findIndex((c) => c === t);
  10502. if (n >= 0)
  10503. this.previewElements.splice(n, 1), at(t);
  10504. else {
  10505. const c = this.screenPreviewElements.findIndex((o) => o === t);
  10506. c >= 0 && (this.screenPreviewElements.splice(c, 1), at(t));
  10507. }
  10508. }
  10509. }
  10510. resumePublish() {
  10511. return w(this, null, function* () {
  10512. this._isPublishing = !1, yield this.startPublish(!0);
  10513. });
  10514. }
  10515. createLocalStream(e) {
  10516. return w(this, null, function* () {
  10517. try {
  10518. if (e.video)
  10519. for (let i = 0; i < this.previewElements.length; i++) {
  10520. const s = this.previewElements[i];
  10521. at(s);
  10522. }
  10523. else if (e.screen)
  10524. for (let i = 0; i < this.screenPreviewElements.length; i++) {
  10525. const s = this.screenPreviewElements[i];
  10526. at(s);
  10527. }
  10528. const t = yield this.streamManager.createLocalStream(e);
  10529. return t != null && t.audioTrack && this.audioVolumeIndicationInterval > 0 && this.audioLevelMonitor.start(t.audioTrack, this.audioVolumeIndicationInterval), e.video ? this.previewAll({ primary: !0 }) : e.screen && this.previewAll({ screen: !0 }), t;
  10530. } catch (t) {
  10531. const i = G0[t.errorCode];
  10532. throw i && (e.audio ? this.emit(
  10533. "localDeviceException",
  10534. dt.AliEngineLocalDeviceTypeMic,
  10535. i,
  10536. ""
  10537. ) : e.video ? this.emit(
  10538. "localDeviceException",
  10539. dt.AliEngineLocalDeviceTypeCamera,
  10540. i,
  10541. ""
  10542. ) : e.screen ? this.emit(
  10543. "localDeviceException",
  10544. dt.AliEngineLocalDeviceTypeDisplay,
  10545. i,
  10546. ""
  10547. ) : this.emit(
  10548. "localDeviceException",
  10549. dt.AliEngineLocalDeviceTypeUnknown,
  10550. i,
  10551. ""
  10552. )), t;
  10553. }
  10554. });
  10555. }
  10556. stopLocalStream(e) {
  10557. return w(this, null, function* () {
  10558. e.audio && this.audioLevelMonitor.stop(), yield this.streamManager.stopLocalStream(e);
  10559. });
  10560. }
  10561. compareAndPublish(e, t, i) {
  10562. return w(this, null, function* () {
  10563. var n, c;
  10564. if (!e && !t)
  10565. return;
  10566. if (e && !t) {
  10567. const o = {};
  10568. return i === T.Audio ? o.audio = !0 : i === T.VideoLarge || i === T.VideoSmall ? (o.video = !0, o.vMsid = i) : i === T.Screen && (o.screen = !0), yield this.publishDeleteTracks(o);
  10569. }
  10570. const s = {};
  10571. if (t != null && t.hasVideo && (s.isScreen = i === T.Screen, s.vMsid = i), t != null && t.hasAudio && (s.aMsid = i), !e && t)
  10572. return yield this.publishAdd(t, s, !1);
  10573. if (e && t) {
  10574. const o = e.trackId, u = ((n = t.videoTrack) == null ? void 0 : n.id) || ((c = t.audioTrack) == null ? void 0 : c.id);
  10575. if (o !== u)
  10576. return yield this.publishReplace(t, s);
  10577. }
  10578. });
  10579. }
  10580. reportAudioProfile() {
  10581. const e = this.streamManager.cameraStreamInfo.audioProfile || "standard", t = le.AudioProfileMap.get(e);
  10582. this.slsReporter.reportPublishProfile(T.Audio, {
  10583. a_profile: e,
  10584. bits: (t == null ? void 0 : t.maxBitrate) || 0,
  10585. samplerate: (t == null ? void 0 : t.sampleRate) || 0,
  10586. channel: (t == null ? void 0 : t.channelCount) || 0
  10587. });
  10588. }
  10589. reportVideoProfile() {
  10590. const e = this.streamManager.cameraStreamInfo.videoProfile || "", t = le.VideoProfileMap.get(e);
  10591. t && this.slsReporter.reportPublishProfile(T.VideoLarge, {
  10592. v_profile: e,
  10593. wdth: (t == null ? void 0 : t.width) || 0,
  10594. hgt: (t == null ? void 0 : t.height) || 0,
  10595. fps: (t == null ? void 0 : t.frameRate) || 0,
  10596. bitrate: (t == null ? void 0 : t.maxBitrate) || 0
  10597. });
  10598. }
  10599. reportScreenProfile() {
  10600. const e = this.streamManager.screenStreamInfo.videoProfile || "", t = le.VideoProfileMap.get(e);
  10601. t && this.slsReporter.reportPublishProfile(T.Screen, {
  10602. v_profile: e,
  10603. wdth: (t == null ? void 0 : t.width) || 0,
  10604. hgt: (t == null ? void 0 : t.height) || 0,
  10605. fps: (t == null ? void 0 : t.frameRate) || 0,
  10606. bitrate: (t == null ? void 0 : t.maxBitrate) || 0
  10607. });
  10608. }
  10609. updateDataChannel(e) {
  10610. e && (this.dc = e, this.dc.datachannel && (this.dc.datachannel.binaryType = "arraybuffer"));
  10611. }
  10612. publishDataChannel() {
  10613. return w(this, null, function* () {
  10614. if (this.dataPubState.state !== Y.AliRtcStatePublishing) {
  10615. this.dataPubState.setState(Y.AliRtcStatePublishing);
  10616. try {
  10617. const e = yield this.rtsManager.publishAddDataChannel(this.url);
  10618. e ? (this.updateDataChannel(e), this.dataPubState.setState(Y.AliRtcStatePublished)) : (this.dataPubState.setState(Y.AliRtcStateNoPublish), this.emit("publishDataError", new V(U.ERR_INNER, "publishDataError")));
  10619. } catch (e) {
  10620. this.dataPubState.setState(Y.AliRtcStateNoPublish);
  10621. }
  10622. }
  10623. });
  10624. }
  10625. startPublish() {
  10626. return w(this, arguments, function* (e = !1, t = nt.MANUAL) {
  10627. var u;
  10628. if (!this.joined)
  10629. return;
  10630. const i = this.streamManager.publishStreams, { audio: s, video: n, videoSmall: c, screen: o } = i;
  10631. if (!s && !n && !c && !o) {
  10632. O.event(`[${lt.logName}]`, "startPublish no stream founded");
  10633. return;
  10634. }
  10635. this.createCallId();
  10636. try {
  10637. const h = (/* @__PURE__ */ new Date()).getTime();
  10638. s && this.audioPubState.setState(Y.AliRtcStatePublishing), n && this.videoPubState.setState(Y.AliRtcStatePublishing), c && this.videoSmallPubState.setState(Y.AliRtcStatePublishing), o && this.screenPubState.setState(Y.AliRtcStatePublishing), this.publishPromise = this.rtsManager.publish(this.url, this.callId, e, t);
  10639. const { traceId: p, l1ip: d } = yield this.publishPromise;
  10640. this._isPublishing = !0, this.streamTracks = this.rtsManager.publishingTracks, this.traceId = p, (u = this.parameter.data) != null && u.enablePubDataChannel && (yield this.publishDataChannel()), s && (this.trackTraceIdMap[T.Audio] = p, this.reportAudioProfile()), c && (this.trackTraceIdMap[T.VideoSmall] = p), n && (this.trackTraceIdMap[T.VideoLarge] = p, this.reportVideoProfile()), o && (this.trackTraceIdMap[T.Screen] = p, this.reportScreenProfile());
  10641. const f = {
  10642. type: xt.Add,
  10643. userid: this.userId,
  10644. sessionid: "",
  10645. displayname: this.name,
  10646. pubid: this.publishId,
  10647. resume: e,
  10648. subscribe: {
  10649. signal: "",
  10650. pullstreamurl: this.url
  10651. },
  10652. l1ip: this.parameter.reportL1IP ? d : void 0,
  10653. callid: this.callId,
  10654. tracks: this.streamTracks,
  10655. traceid: p
  10656. };
  10657. yield this.syncPublishToRoomServer(f, i, h), s && this.audioPubState.setState(Y.AliRtcStatePublished), n && this.videoPubState.setState(Y.AliRtcStatePublished), c && this.videoSmallPubState.setState(Y.AliRtcStatePublished), o && this.screenPubState.setState(Y.AliRtcStatePublished);
  10658. } catch (h) {
  10659. throw s && this.audioPubState.setState(Y.AliRtcStateNoPublish), n && this.videoPubState.setState(Y.AliRtcStateNoPublish), c && this.videoSmallPubState.setState(Y.AliRtcStateNoPublish), o && this.screenPubState.setState(Y.AliRtcStateNoPublish), h;
  10660. }
  10661. });
  10662. }
  10663. updateStreams() {
  10664. return w(this, null, function* () {
  10665. yield this.streamManager.updateStreams();
  10666. });
  10667. }
  10668. publishUpdate(e) {
  10669. return w(this, null, function* () {
  10670. var n, c, o, u, h, p;
  10671. if (!this._isPublishing)
  10672. return;
  10673. yield this.publishPromise;
  10674. const t = this.streamManager.publishStreams;
  10675. let i;
  10676. const s = (/* @__PURE__ */ new Date()).getTime();
  10677. try {
  10678. const d = (n = this.streamTracks) == null ? void 0 : n.find(
  10679. ({ ssrc: E, type: _, msid: y }) => _ === "audio" && E && y === T.Audio
  10680. ), f = yield this.compareAndPublish(d, t.audio, T.Audio);
  10681. f && (i = f);
  10682. const m = (c = this.streamTracks) == null ? void 0 : c.find(
  10683. ({ ssrc: E, type: _, msid: y }) => _ === "video" && E && y === T.VideoLarge
  10684. ), l = yield this.compareAndPublish(m, t.video, T.VideoLarge);
  10685. l && (i = l);
  10686. const S = (o = this.streamTracks) == null ? void 0 : o.find(
  10687. ({ ssrc: E, type: _, msid: y }) => _ === "video" && E && y === T.VideoSmall
  10688. ), v = yield this.compareAndPublish(
  10689. S,
  10690. t.videoSmall,
  10691. T.VideoSmall
  10692. );
  10693. v && (i = v);
  10694. const x = (u = this.streamTracks) == null ? void 0 : u.find(
  10695. ({ ssrc: E, type: _, msid: y }) => _ === "video" && E && y === T.Screen
  10696. ), b = yield this.compareAndPublish(x, t.screen, T.Screen);
  10697. if (b && (i = b), !i)
  10698. if (e === nt.RECONNECT && this.rtsManager.publishingTracks.length > 0) {
  10699. if ((h = this.parameter.data) != null && h.enablePubDataChannel) {
  10700. const y = this.rtsManager.getDatachannelByMsid({
  10701. url: this.url,
  10702. msid: T.Data
  10703. });
  10704. this.updateDataChannel(y);
  10705. }
  10706. const E = this.rtsManager.publishingTracks.find(({ type: y }) => y === "video"), _ = this.rtsManager.publishingTracks.find(({ type: y }) => y === "audio");
  10707. (E || _) && (yield this.rtsManager.waitPublishSender(
  10708. this.url,
  10709. !E,
  10710. E ? E.msid : _ == null ? void 0 : _.msid
  10711. )), i = {
  10712. type: xt.Add,
  10713. userid: this.userId,
  10714. sessionid: "",
  10715. displayname: this.name,
  10716. pubid: this.publishId,
  10717. resume: !0,
  10718. subscribe: {
  10719. signal: "",
  10720. pullstreamurl: this.url
  10721. },
  10722. callid: this.callId,
  10723. tracks: this.rtsManager.publishingTracks,
  10724. traceid: this.traceId
  10725. };
  10726. } else
  10727. return;
  10728. (p = this.parameter.data) != null && p.enablePubDataChannel && !this.dc && (yield this.publishDataChannel()), yield this.syncPublishToRoomServer(i, t, s);
  10729. } catch (d) {
  10730. const { code: f } = d != null ? d : {}, m = this.url;
  10731. throw f === 403 && m && (yield this.refreshPushStreamUrl(), i = yield this.publishUpdate()), d;
  10732. }
  10733. return i;
  10734. });
  10735. }
  10736. syncPublishToRoomServer(e, t, i) {
  10737. return w(this, null, function* () {
  10738. var o;
  10739. if (!e)
  10740. throw new V(U.ERR_INNER, "sync publish to room server failed because no publishInfo");
  10741. let s = e;
  10742. if (this.dc) {
  10743. const c = e, { tracks: u } = c, h = Dt(c, ["tracks"]);
  10744. s = ut(J({}, h), {
  10745. tracks: [
  10746. ...u,
  10747. {
  10748. type: "data",
  10749. msid: T.Data,
  10750. ssrc: `${((o = this.callId) == null ? void 0 : o.length) > 8 ? this.callId.substring(0, 8) : "web"}${this.dc.datachannel.id || "0"}`,
  10751. codec: "text"
  10752. }
  10753. ]
  10754. });
  10755. }
  10756. const n = yield this.signalingManager.publish(s);
  10757. e.signaltid = n.tid;
  10758. });
  10759. }
  10760. refreshPushStreamUrl() {
  10761. return w(this, null, function* () {
  10762. const e = new V(U.ERR_INNER, "refresh push stream url error"), t = this.url;
  10763. if (!t)
  10764. throw e;
  10765. const i = yield this.signalingManager.refreshUrl({
  10766. pushstreamurl: t
  10767. });
  10768. if (!(i != null && i.pushstreamurl))
  10769. throw e;
  10770. this.url = i.pushstreamurl;
  10771. });
  10772. }
  10773. publishAdd(e, t, i = !1, s = 0) {
  10774. return w(this, null, function* () {
  10775. this.createCallId();
  10776. const n = (t == null ? void 0 : t.aMsid) === T.Audio, c = (t == null ? void 0 : t.vMsid) === T.VideoLarge, o = (t == null ? void 0 : t.vMsid) === T.VideoSmall, u = (t == null ? void 0 : t.vMsid) === T.Screen;
  10777. n && this.audioPubState.setState(Y.AliRtcStatePublishing), c && this.videoPubState.setState(Y.AliRtcStatePublishing), o && this.videoSmallPubState.setState(Y.AliRtcStatePublishing), u && this.screenPubState.setState(Y.AliRtcStatePublishing);
  10778. try {
  10779. const h = yield this.rtsManager.publishAdd(this.url, e, this.callId, t, !1, !0);
  10780. n && (this.audioPubState.setState(Y.AliRtcStatePublished), this.reportAudioProfile(), this.trackTraceIdMap[T.Audio] = h), c && (this.videoPubState.setState(Y.AliRtcStatePublished), this.reportVideoProfile(), this.trackTraceIdMap[T.VideoLarge] = h), o && (this.videoSmallPubState.setState(Y.AliRtcStatePublished), this.trackTraceIdMap[T.VideoSmall] = h), u && (this.screenPubState.setState(Y.AliRtcStatePublished), this.reportScreenProfile(), this.trackTraceIdMap[T.Screen] = h), this.streamTracks = this.rtsManager.publishingTracks;
  10781. const p = {
  10782. type: xt.Add,
  10783. userid: this.userId,
  10784. sessionid: "",
  10785. displayname: this.name,
  10786. pubid: this.publishId,
  10787. resume: i,
  10788. subscribe: {
  10789. signal: "",
  10790. pullstreamurl: this.url
  10791. },
  10792. callid: this.callId,
  10793. tracks: this.streamTracks,
  10794. traceid: h
  10795. };
  10796. return this.reportSelfDeviceStatus(), this.monitorTimerId || this.startStreamMonitor(), p;
  10797. } catch (h) {
  10798. let p = U.ERR_SDK_PUBLISH_INVAILD;
  10799. if (n && (this.audioPubState.setState(Y.AliRtcStateNoPublish), p = U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED), c && (this.videoPubState.setState(Y.AliRtcStateNoPublish), p = U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED), o && (this.videoSmallPubState.setState(Y.AliRtcStateNoPublish), p = U.ERR_SDK_PUBLISH_DUAL_STREAM_FAILED), u && (this.screenPubState.setState(Y.AliRtcStateNoPublish), p = U.ERR_SDK_PUBLISH_SCEEN_SHARE_FAILED), h.errorCode === 15006 && s < 3)
  10800. return this.publishAdd(e, t, i, s + 1);
  10801. throw V.fromError(h, p, "publish add failed");
  10802. }
  10803. });
  10804. }
  10805. publishReplace(e, t) {
  10806. return w(this, null, function* () {
  10807. try {
  10808. yield this.rtsManager.publishReplace(this.url, e, t), this.streamTracks = this.rtsManager.publishingTracks;
  10809. const i = (t == null ? void 0 : t.vMsid) === T.VideoLarge, s = (t == null ? void 0 : t.vMsid) === T.Screen;
  10810. i && this.streamManager.setVideoProfile(void 0, void 0, !0), s && this.streamManager.setScreenProfile(void 0, void 0);
  10811. const n = {
  10812. type: xt.Replace,
  10813. userid: this.userId,
  10814. sessionid: "",
  10815. pubid: this.publishId,
  10816. displayname: this.name,
  10817. subscribe: {
  10818. signal: "",
  10819. pullstreamurl: this.url
  10820. },
  10821. callid: this.callId,
  10822. tracks: this.streamTracks
  10823. };
  10824. return this.reportSelfDeviceStatus(), n;
  10825. } catch (i) {
  10826. throw V.fromError(
  10827. i,
  10828. U.ERR_INNER,
  10829. `publish replace failed, vMsid: ${t == null ? void 0 : t.vMsid} aMsid: ${t == null ? void 0 : t.aMsid}`
  10830. );
  10831. }
  10832. });
  10833. }
  10834. publishDeleteTracks(e) {
  10835. return w(this, null, function* () {
  10836. const t = {
  10837. type: xt.Delete,
  10838. userid: this.userId,
  10839. sessionid: "",
  10840. displayname: this.displayname,
  10841. callid: this.callId,
  10842. pubid: this.publishId,
  10843. subscribe: {
  10844. signal: "",
  10845. pullstreamurl: this.url
  10846. },
  10847. tracks: []
  10848. };
  10849. try {
  10850. return yield this.rtsManager.publishDelete(this.url, e), this.streamTracks = this.rtsManager.publishingTracks, e.audio && this.audioPubState.setState(Y.AliRtcStateNoPublish), e.video && (e.vMsid === T.VideoSmall ? this.videoSmallPubState.setState(Y.AliRtcStateNoPublish) : this.videoPubState.setState(Y.AliRtcStateNoPublish)), e.screen && this.screenPubState.setState(Y.AliRtcStateNoPublish), t.tracks = this.streamTracks, this.reportSelfDeviceStatus(), t;
  10851. } catch (i) {
  10852. throw V.fromError(i, U.ERR_INNER, "publish delete tracks failed");
  10853. }
  10854. });
  10855. }
  10856. publishStop() {
  10857. return w(this, null, function* () {
  10858. if (!this._isPublishing)
  10859. throw new V(
  10860. U.ERR_INNER,
  10861. "publish stop failed, previous localStream is required for publishing stopping"
  10862. );
  10863. O.info(`[${lt.logName}]`, "publishStop", { url: this.url });
  10864. const e = (/* @__PURE__ */ new Date()).getTime();
  10865. try {
  10866. const t = this.hasAudioTrackInMS, i = this.hasCameraTrackInMS, s = this.hasCameraDualTrackInMS, n = this.hasScreenTrackInMS;
  10867. yield this.rtsManager.publishStop(this.url), t && this.audioPubState.setState(Y.AliRtcStateNoPublish), i && this.videoPubState.setState(Y.AliRtcStateNoPublish), s && this.videoSmallPubState.setState(Y.AliRtcStateNoPublish), n && this.screenPubState.setState(Y.AliRtcStateNoPublish), this.traceId = "", Object.keys(this.monitorDataCache).forEach((o) => {
  10868. this.reportPublishMonitor(o);
  10869. }), this.streamTracks = [];
  10870. const c = {
  10871. type: xt.Stop,
  10872. userid: this.userId,
  10873. sessionid: "",
  10874. displayname: this.displayname,
  10875. callid: this.callId,
  10876. pubid: this.publishId,
  10877. subscribe: {
  10878. signal: "",
  10879. pullstreamurl: this.url
  10880. },
  10881. tracks: []
  10882. };
  10883. return this.syncPublishToRoomServer(c, {}, e), c;
  10884. } catch (t) {
  10885. throw V.fromError(t, U.ERR_INNER, "publish stop failed");
  10886. }
  10887. });
  10888. }
  10889. unPublish() {
  10890. return w(this, null, function* () {
  10891. const e = (/* @__PURE__ */ new Date()).getTime();
  10892. let t = {
  10893. type: xt.UnPublish,
  10894. userid: this.userId,
  10895. sessionid: "",
  10896. displayname: this.displayname,
  10897. callid: this.callId,
  10898. pubid: this.publishId,
  10899. subscribe: {
  10900. signal: "",
  10901. pullstreamurl: this.url
  10902. },
  10903. tracks: []
  10904. };
  10905. try {
  10906. if (this._isPublishing) {
  10907. const i = this.hasAudioTrackInMS, s = this.hasCameraTrackInMS, n = this.hasCameraDualTrackInMS, c = this.hasScreenTrackInMS;
  10908. yield this.rtsManager.unpublish(), this.streamTracks = [], this.stopStreamMonitor(), i && this.audioPubState.setState(Y.AliRtcStateNoPublish), s && this.videoPubState.setState(Y.AliRtcStateNoPublish), n && this.videoSmallPubState.setState(Y.AliRtcStateNoPublish), c && this.screenPubState.setState(Y.AliRtcStateNoPublish), this._isPublishing = !1, this.traceId = "", this.clearStream();
  10909. }
  10910. return this.dc && (this.rtsManager.publishStopDataChannel(this.url, this.dc), this.dataPubState.setState(Y.AliRtcStateNoPublish), this.dc = void 0), this.slsReporter.reportUnpublish(this.callId || "", e, 0, ""), t;
  10911. } catch (i) {
  10912. throw V.fromError(i, U.ERR_INNER, "unpublish failed");
  10913. }
  10914. });
  10915. }
  10916. /**
  10917. * 事件通知本地的设备使用状态
  10918. */
  10919. reportSelfDeviceStatus() {
  10920. this.emit(Le.Local, this.getDeviceStatus());
  10921. }
  10922. /**
  10923. * 从localStream 中获取当前的设备状态
  10924. * @returns {string}
  10925. */
  10926. getDeviceStatus() {
  10927. var t, i, s, n;
  10928. let e = {
  10929. micOpen: !1,
  10930. micInterrupted: !1,
  10931. cameraOpen: !1,
  10932. screenShare: !1,
  10933. audioDisable: !0,
  10934. videoDisable: !0,
  10935. screenDisable: !0,
  10936. backgroundMode: !1,
  10937. accompanyPlaying: !1
  10938. };
  10939. return e.cameraOpen = this.hasCamera, e.micOpen = this.hasMicrophone, e.screenShare = this.hasScreenShare, e.audioDisable = !((t = this.streamManager.cameraStreamInfo.originAudioTrack) != null && t.enabled), e.videoDisable = !((i = this.streamManager.cameraStreamInfo.originVideoTrack) != null && i.enabled), e.screenDisable = !this.hasScreenShare || !((n = (s = this.streamManager.screenStreamInfo) == null ? void 0 : s.originVideoTrack) != null && n.enabled), En.getCurrentStatus(e);
  10940. }
  10941. resetPreviewElements() {
  10942. this.previewElements.forEach((e) => {
  10943. e.srcObject = null, e._playPromise = void 0;
  10944. }, []), this.previewElements = [];
  10945. }
  10946. resetSecondayPreviewElements() {
  10947. this.screenPreviewElements.forEach((e) => {
  10948. e.srcObject = null, e._playPromise = void 0;
  10949. }, []), this.screenPreviewElements = [];
  10950. }
  10951. getMediaStats(e) {
  10952. return this.pcMediaStatsMap[e];
  10953. }
  10954. reportPublishMonitor(e) {
  10955. if (!e)
  10956. return;
  10957. let t;
  10958. try {
  10959. e === T.Audio ? t = this.rtsManager.getStreamByMsid({
  10960. url: this.url,
  10961. aMsid: e
  10962. }).audioTrack : t = this.rtsManager.getStreamByMsid({
  10963. url: this.url,
  10964. vMsid: e
  10965. }).videoTrack;
  10966. } catch (i) {
  10967. }
  10968. this.slsReporter.reportPublishMonitor(
  10969. this.callId,
  10970. this.trackTraceIdMap[e] || "",
  10971. e,
  10972. t,
  10973. this.monitorDataCache[e]
  10974. ), this.monitorDataCache[e] = [];
  10975. }
  10976. reportNetwork() {
  10977. this.slsReporter.reportNetworkMonitor(this.candidateDataCache), this.candidateDataCache = [];
  10978. }
  10979. startStreamMonitor() {
  10980. this.monitorTimerId || (this.monitorTimerId = window.setInterval(() => w(this, null, function* () {
  10981. var e, i;
  10982. try {
  10983. const s = yield this.rtsManager.getPCStats();
  10984. let n;
  10985. s == null || s.forEach((u) => {
  10986. u.type === "media-source" || u.type === "media-playout" ? u.id && (this.pcMediaStatsMap[u.id] = u) : u.type === "candidate-pair" && u.state === "succeeded" && (n = u);
  10987. });
  10988. let c;
  10989. if (((e = this.candidateDataCache) == null ? void 0 : e.length) > 0) {
  10990. const t = this.candidateDataCache[this.candidateDataCache.length - 1] || {}, { _last: h } = t;
  10991. c = Dt(t, ["_last"]);
  10992. }
  10993. ((i = this.candidateDataCache) == null ? void 0 : i.length) >= qa && this.reportNetwork(), n && (n._last = c, this.candidateDataCache.push(n));
  10994. let o = Object.keys(this.monitorDataCache).filter((u) => {
  10995. var h;
  10996. return ((h = this.monitorDataCache[u]) == null ? void 0 : h.length) > 0;
  10997. });
  10998. (this.streamTracks || []).forEach((u) => {
  10999. const h = u.msid;
  11000. if (!h)
  11001. return;
  11002. o.includes(h) && (o = o.filter((f) => f !== h));
  11003. let p;
  11004. h === T.Audio ? p = this.rtsManager.getPublishAudioStats(this.url) : p = this.rtsManager.getPublishVideoStats(this.url, h), p.then((f) => {
  11005. if (!f.timestamp)
  11006. return;
  11007. this.monitorDataCache[h] || (this.monitorDataCache[h] = []);
  11008. const m = this.getMediaStats(f.mediaSourceId);
  11009. f._source = m;
  11010. const l = this.monitorDataCache[h];
  11011. let S;
  11012. if ((l == null ? void 0 : l.length) > 0) {
  11013. const v = l[l.length - 1] || {}, { _last: b } = v;
  11014. S = Dt(v, ["_last"]);
  11015. }
  11016. (l == null ? void 0 : l.length) >= qa && this.reportPublishMonitor(h), f._last = S, f._codec = u.codec || "", this.monitorDataCache[h].push(f);
  11017. });
  11018. }), o.forEach((u) => {
  11019. this.reportPublishMonitor(u);
  11020. });
  11021. } catch (s) {
  11022. }
  11023. }), 1e3));
  11024. }
  11025. /**
  11026. * 停止本地流数据采集
  11027. */
  11028. stopStreamMonitor() {
  11029. this.monitorTimerId && (clearInterval(this.monitorTimerId), this.monitorTimerId = void 0), Object.keys(this.monitorDataCache).forEach((e) => {
  11030. this.reportPublishMonitor(e);
  11031. });
  11032. }
  11033. /**
  11034. * 清除本地流
  11035. * @returns {void}
  11036. */
  11037. clearStream() {
  11038. this.streamManager.stop(), this.audioPubState.setState(Y.AliRtcStatePublishIdle), this.videoPubState.setState(Y.AliRtcStatePublishIdle), this.videoSmallPubState.setState(Y.AliRtcStatePublishIdle), this.screenPubState.setState(Y.AliRtcStatePublishIdle);
  11039. }
  11040. /**
  11041. * 获取当前使用的摄像头 deviceId
  11042. * @returns {string | undefined}
  11043. */
  11044. getCurrentCameraDeviceId() {
  11045. var e;
  11046. return (e = this.streamManager.cameraStreamInfo.originVideoTrack) == null ? void 0 : e.getSettings().deviceId;
  11047. }
  11048. /**
  11049. * 获取当前使用的摄像头 deviceId
  11050. * @returns {string | undefined}
  11051. */
  11052. getCurrentMicDeviceId() {
  11053. var e;
  11054. return (e = this.streamManager.cameraStreamInfo.originAudioTrack) == null ? void 0 : e.getSettings().deviceId;
  11055. }
  11056. enableAudioVolumeIndication(e) {
  11057. this.audioVolumeIndicationInterval !== e && (this.audioVolumeIndicationInterval > 0 && e <= 0 && this.audioLevelMonitor.stop(), e > 0 && this.streamManager.cameraStreamInfo.originAudioTrack && this.audioLevelMonitor.start(this.streamManager.cameraStreamInfo.originAudioTrack, e), this.audioVolumeIndicationInterval = e);
  11058. }
  11059. sendSEI(e, t, i) {
  11060. return w(this, null, function* () {
  11061. if (!this.url)
  11062. return;
  11063. let s = 0;
  11064. return !t || t < 1 ? s = 1 : s = t - 1, this.rtsManager.sendSEI(this.url, e, s, i);
  11065. });
  11066. }
  11067. sendDataChannelMessage(e) {
  11068. return w(this, null, function* () {
  11069. var s;
  11070. if (!((s = this.parameter.data) != null && s.enablePubDataChannel))
  11071. throw new V(U.ERR_INNER, "data channel publish is not enabled");
  11072. if (!this.dc)
  11073. throw new V(U.ERR_INNER, "data channel is not ready");
  11074. const t = e.toBuffer(), i = Y0(t, 1156);
  11075. i.forEach((n, c) => {
  11076. const o = new Ti(
  11077. new ci(n.byteLength, c === i.length - 1, c === 0 ? 1 : 0),
  11078. n
  11079. );
  11080. this.dc.send(o.toGRTNBuffer());
  11081. });
  11082. });
  11083. }
  11084. getStats() {
  11085. return w(this, null, function* () {
  11086. const e = [];
  11087. if (this.hasAudioTrackInMS) {
  11088. const n = yield this.rtsManager.getPublishAudioStats(this.url);
  11089. n && e.push({ stats: n, track: Xt.AliRtcAudioTrackMic });
  11090. }
  11091. const t = [];
  11092. if (this.hasCameraTrackInMS) {
  11093. const n = yield this.rtsManager.getPublishVideoStats(this.url, T.VideoLarge);
  11094. n && t.push({
  11095. track: se.AliRtcVideoTrackCamera,
  11096. streamType: we.AliRtcVideoStreamTypeHigh,
  11097. stats: n
  11098. });
  11099. }
  11100. if (this.hasCameraDualTrackInMS) {
  11101. const n = yield this.rtsManager.getPublishVideoStats(this.url, T.VideoSmall);
  11102. n && t.push({
  11103. track: se.AliRtcVideoTrackCamera,
  11104. streamType: we.AliRtcVideoStreamTypeLow,
  11105. stats: n
  11106. });
  11107. }
  11108. if (this.hasScreenTrackInMS) {
  11109. const n = yield this.rtsManager.getPublishVideoStats(this.url, T.Screen);
  11110. n && t.push({
  11111. track: se.AliRtcVideoTrackScreen,
  11112. stats: n
  11113. });
  11114. }
  11115. let i;
  11116. const s = yield this.rtsManager.getPCStats();
  11117. return s == null || s.forEach((n) => {
  11118. n.type === "candidate-pair" && n.state === "succeeded" && (i = n);
  11119. }), { audio: e, video: t, candidate: i };
  11120. });
  11121. }
  11122. }, /**
  11123. * @ignore
  11124. */
  11125. g(lt, "logName", "LocalUser"), lt);
  11126. me([
  11127. D()
  11128. ], ge.prototype, "clearPublishState", 1);
  11129. me([
  11130. D()
  11131. ], ge.prototype, "clear", 1);
  11132. me([
  11133. D(H)
  11134. ], ge.prototype, "startDefaultCamera", 1);
  11135. me([
  11136. D(H)
  11137. ], ge.prototype, "startDefaultAudio", 1);
  11138. me([
  11139. D()
  11140. ], ge.prototype, "setViewConfig", 1);
  11141. me([
  11142. D()
  11143. ], ge.prototype, "startCameraCapture", 1);
  11144. me([
  11145. D()
  11146. ], ge.prototype, "stopCameraCapture", 1);
  11147. me([
  11148. D()
  11149. ], ge.prototype, "startAudioCapture", 1);
  11150. me([
  11151. D()
  11152. ], ge.prototype, "stopAudioCapture", 1);
  11153. me([
  11154. D()
  11155. ], ge.prototype, "stopPreview", 1);
  11156. me([
  11157. D()
  11158. ], ge.prototype, "resumePublish", 1);
  11159. me([
  11160. D()
  11161. ], ge.prototype, "createLocalStream", 1);
  11162. me([
  11163. D()
  11164. ], ge.prototype, "stopLocalStream", 1);
  11165. me([
  11166. D(H)
  11167. ], ge.prototype, "startPublish", 1);
  11168. me([
  11169. D()
  11170. ], ge.prototype, "updateStreams", 1);
  11171. me([
  11172. D(H)
  11173. ], ge.prototype, "publishUpdate", 1);
  11174. me([
  11175. D(([r]) => [r])
  11176. ], ge.prototype, "syncPublishToRoomServer", 1);
  11177. me([
  11178. D()
  11179. ], ge.prototype, "refreshPushStreamUrl", 1);
  11180. me([
  11181. D(([r, a, e]) => [JSON.stringify(e)])
  11182. ], ge.prototype, "publishAdd", 1);
  11183. me([
  11184. D(([r, a]) => [JSON.stringify(a)])
  11185. ], ge.prototype, "publishReplace", 1);
  11186. me([
  11187. D(H)
  11188. ], ge.prototype, "publishDeleteTracks", 1);
  11189. me([
  11190. D()
  11191. ], ge.prototype, "publishStop", 1);
  11192. me([
  11193. D()
  11194. ], ge.prototype, "unPublish", 1);
  11195. me([
  11196. D(([r, a, e]) => [r.length, a, e])
  11197. ], ge.prototype, "sendSEI", 1);
  11198. let tc = ge;
  11199. var vt = /* @__PURE__ */ ((r) => (r.OPUS = "opus", r.H264 = "H264", r.UNKNOWN = "", r))(vt || {}), re = /* @__PURE__ */ ((r) => (r[r.NotSubscribe = 0] = "NotSubscribe", r[r.Subscribing = 1] = "Subscribing", r[r.Subscribed = 2] = "Subscribed", r))(re || {}), Vt = /* @__PURE__ */ ((r) => (r.VideoTrackEnded = "videoTrackEnded", r.AudioTrackEnded = "audioTrackEnded", r.ScreenTrackEnded = "screenTrackEnded", r))(Vt || {});
  11200. const ic = (r) => {
  11201. const a = new MediaStream();
  11202. return a.addTrack(r), a;
  11203. }, Rn = (r) => w(void 0, null, function* () {
  11204. return yield le.createStream({
  11205. custom: !0,
  11206. mediaStream: r
  11207. });
  11208. }), ei = (r) => w(void 0, null, function* () {
  11209. const a = ic(r);
  11210. return yield Rn(a);
  11211. }), rc = (r) => {
  11212. const { audio: a, video: e, screen: t } = r;
  11213. if (e && t)
  11214. throw new V(U.ERR_INNER, "create stream error, cannot create video && screen together");
  11215. return !(!e && !a && !t);
  11216. }, sc = (r) => r === T.Audio || r === Jr.Audio, ac = (r) => r === T.VideoLarge || r === Jr.VideoLarge, nc = (r) => r === T.VideoSmall, oc = (r) => r === T.Screen, cc = (r) => r === T.Data;
  11217. var uc = Object.defineProperty, hc = Object.getOwnPropertyDescriptor, dc = (r, a, e, t) => {
  11218. for (var i = t > 1 ? void 0 : t ? hc(a, e) : a, s = r.length - 1, n; s >= 0; s--)
  11219. (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i);
  11220. return t && i && uc(a, e, i), i;
  11221. };
  11222. class Ai extends De {
  11223. constructor() {
  11224. super();
  11225. g(this, "audioInfo", {
  11226. subscribeState: re.NotSubscribe,
  11227. ssrc: "",
  11228. msid: "",
  11229. pt: 0,
  11230. red: 0,
  11231. codec: vt.UNKNOWN
  11232. });
  11233. g(this, "videoLargeInfo", {
  11234. subscribeState: re.NotSubscribe,
  11235. ssrc: "",
  11236. msid: "",
  11237. pt: 0,
  11238. red: 0,
  11239. codec: vt.UNKNOWN
  11240. });
  11241. g(this, "videoSmallInfo", {
  11242. subscribeState: re.NotSubscribe,
  11243. ssrc: "",
  11244. msid: "",
  11245. pt: 0,
  11246. red: 0,
  11247. codec: vt.UNKNOWN
  11248. });
  11249. g(this, "screenInfo", {
  11250. subscribeState: re.NotSubscribe,
  11251. ssrc: "",
  11252. msid: "",
  11253. pt: 0,
  11254. red: 0,
  11255. codec: vt.UNKNOWN
  11256. });
  11257. g(this, "dataInfo", {
  11258. subscribeState: re.NotSubscribe,
  11259. ssrc: "",
  11260. msid: "",
  11261. pt: 0,
  11262. red: 0,
  11263. codec: vt.UNKNOWN
  11264. });
  11265. g(this, "audioVolume", 1);
  11266. g(this, "audioMuted", !1);
  11267. g(this, "userStatus");
  11268. }
  11269. /**
  11270. * 远端流音频轨道信息
  11271. * @returns
  11272. */
  11273. getAudioInfo() {
  11274. return this.audioInfo;
  11275. }
  11276. /**
  11277. * 远端流视频轨道信息
  11278. * @returns
  11279. */
  11280. getVideoSmallInfo() {
  11281. return this.videoSmallInfo;
  11282. }
  11283. /**
  11284. * 远端流视频轨道信息
  11285. * @returns
  11286. */
  11287. getVideoLargeInfo() {
  11288. return this.videoLargeInfo;
  11289. }
  11290. /**
  11291. * 远端流屏幕共享轨道信息
  11292. * @returns
  11293. */
  11294. getScreenInfo() {
  11295. return this.screenInfo;
  11296. }
  11297. getDataInfo() {
  11298. return this.dataInfo;
  11299. }
  11300. get subscribingInfos() {
  11301. return [this.audioInfo, this.videoLargeInfo, this.videoSmallInfo, this.screenInfo].filter(
  11302. (e) => e.msid && e.subscribeState === re.Subscribed
  11303. );
  11304. }
  11305. get hasTrack() {
  11306. return this.hasAudio || this.hasVideo || this.hasScreen || this.hasData;
  11307. }
  11308. /**
  11309. * 远端流是否包含音频轨道
  11310. * @returns
  11311. */
  11312. get hasAudio() {
  11313. return this.audioInfo.ssrc !== "";
  11314. }
  11315. /**
  11316. * 远端流是否包含视频轨道
  11317. * @returns
  11318. */
  11319. get hasVideo() {
  11320. return this.videoLargeInfo.ssrc !== "" || this.videoSmallInfo.ssrc !== "";
  11321. }
  11322. /**
  11323. * 远端流是否包含视频大流轨道
  11324. * @returns
  11325. */
  11326. get hasVideoLarge() {
  11327. return this.videoLargeInfo.ssrc !== "";
  11328. }
  11329. /**
  11330. * 远端流是否包含视频小流轨道
  11331. * @returns
  11332. */
  11333. get hasVideoSmall() {
  11334. return this.videoSmallInfo.ssrc !== "";
  11335. }
  11336. /**
  11337. * 远端流是否包含屏幕共享轨道
  11338. * @returns
  11339. */
  11340. get hasScreen() {
  11341. return this.screenInfo.ssrc !== "";
  11342. }
  11343. get hasData() {
  11344. return this.dataInfo.ssrc !== "";
  11345. }
  11346. /**
  11347. * 是否订阅远端流音频轨道
  11348. * @returns
  11349. */
  11350. get isAudioSubscribed() {
  11351. return this.audioInfo.subscribeState === re.Subscribed;
  11352. }
  11353. get isAudioSubscribing() {
  11354. return this.audioInfo.subscribeState === re.Subscribing;
  11355. }
  11356. /**
  11357. * 是否订阅远端流视频轨道
  11358. * @returns
  11359. */
  11360. get isVideoSubscribed() {
  11361. return this.isVideoLargeSubscribed || this.isVideoSmallSubscribed;
  11362. }
  11363. get isVideoSubscribing() {
  11364. return this.isVideoLargeSubscribing || this.isVideoSmallSubscribing;
  11365. }
  11366. /**
  11367. * 是否订阅远端流视频大流轨道
  11368. * @returns
  11369. */
  11370. get isVideoLargeSubscribed() {
  11371. return this.videoLargeInfo.subscribeState === re.Subscribed;
  11372. }
  11373. get isVideoLargeSubscribing() {
  11374. return this.videoLargeInfo.subscribeState === re.Subscribing;
  11375. }
  11376. /**
  11377. * 是否订阅远端流视频小流轨道
  11378. * @returns
  11379. */
  11380. get isVideoSmallSubscribed() {
  11381. return this.videoSmallInfo.subscribeState === re.Subscribed;
  11382. }
  11383. get isVideoSmallSubscribing() {
  11384. return this.videoSmallInfo.subscribeState === re.Subscribing;
  11385. }
  11386. /**
  11387. * 是否订阅远端流屏幕共享轨道
  11388. * @returns
  11389. */
  11390. get isScreenSubscribed() {
  11391. return this.screenInfo.subscribeState === re.Subscribed;
  11392. }
  11393. get isScreenSubscribing() {
  11394. return this.screenInfo.subscribeState === re.Subscribing;
  11395. }
  11396. get isDataSubscribed() {
  11397. return this.dataInfo.subscribeState === re.Subscribed;
  11398. }
  11399. get isDataSubscribing() {
  11400. return this.dataInfo.subscribeState === re.Subscribing;
  11401. }
  11402. get audioCodec() {
  11403. return this.audioInfo.codec;
  11404. }
  11405. get videoCodec() {
  11406. return this.hasVideoLarge ? this.videoLargeInfo.codec : this.hasVideoSmall ? this.videoSmallInfo.codec : this.hasScreen ? this.screenInfo.codec : vt.UNKNOWN;
  11407. }
  11408. get audioTrackInfo() {
  11409. return this.hasAudio ? Xt.AliRtcAudioTrackMic : Xt.AliRtcAudioTrackNo;
  11410. }
  11411. get videoTrackInfo() {
  11412. return this.hasVideo && this.hasScreen ? se.AliRtcVideoTrackBoth : this.hasVideo ? se.AliRtcVideoTrackCamera : this.hasScreen ? se.AliRtcVideoTrackScreen : se.AliRtcVideoTrackNo;
  11413. }
  11414. // 更新远端推流信息
  11415. updateTracks(e) {
  11416. let t = "", i = "", s = "", n = "", c = "";
  11417. return e ? (e.forEach((o) => {
  11418. var p;
  11419. let u = vt.UNKNOWN;
  11420. const h = ((p = o == null ? void 0 : o.attr) == null ? void 0 : p.reason) === "reconnect";
  11421. if (o.userdata) {
  11422. const { codec: d } = JSON.parse(o.userdata);
  11423. d && (u = d);
  11424. }
  11425. sc(o.msid) ? (t = o.ssrc, this.audioInfo.msid = o.msid, this.audioInfo.codec = u, (h || this.audioInfo.ssrc !== t) && (this.audioInfo.subscribeState = re.NotSubscribe)) : nc(o.msid) ? (s = o.ssrc, this.videoSmallInfo.msid = o.msid, this.videoSmallInfo.codec = u, (h || this.videoSmallInfo.ssrc !== s) && (this.videoSmallInfo.subscribeState = re.NotSubscribe)) : ac(o.msid) ? (i = o.ssrc, this.videoLargeInfo.msid = o.msid, this.videoLargeInfo.codec = u, (h || this.videoLargeInfo.ssrc !== i) && (this.videoLargeInfo.subscribeState = re.NotSubscribe)) : oc(o.msid) ? (n = o.ssrc, this.screenInfo.msid = o.msid, this.screenInfo.codec = u, (h || this.screenInfo.ssrc !== n) && (this.screenInfo.subscribeState = re.NotSubscribe)) : cc(o.msid) && (c = o.ssrc, this.dataInfo.msid = o.msid, this.dataInfo.codec = u, (h || this.dataInfo.ssrc !== c) && (this.dataInfo.subscribeState = re.NotSubscribe));
  11426. }), this.updateRemoteTrackSsrc(t, i, s, n, c)) : this.updateRemoteTrackSsrc(t, i, s, n, c), {};
  11427. }
  11428. updateRemoteTrackSsrc(e, t, i, s, n) {
  11429. this.audioInfo.ssrc = e, this.videoSmallInfo.ssrc = i, this.videoLargeInfo.ssrc = t, this.screenInfo.ssrc = s, this.dataInfo.ssrc = n;
  11430. }
  11431. markRemoteTrackSubscribing(e) {
  11432. return e.video && (e.vMsid === this.videoSmallInfo.msid && (this.videoSmallInfo.subscribeState = re.Subscribing), (e.vMsid === this.videoLargeInfo.msid || !e.vMsid) && (this.videoLargeInfo.subscribeState = re.Subscribing)), e.screen && (this.screenInfo.subscribeState = re.Subscribing), e.audio && (this.audioInfo.subscribeState = re.Subscribing), e.data && (this.dataInfo.subscribeState = re.Subscribing), {
  11433. videoLargeInfo: this.videoLargeInfo,
  11434. videoSmallInfo: this.videoSmallInfo
  11435. };
  11436. }
  11437. updateRemoteTrackSubState(e) {
  11438. return e.video !== void 0 && ((e.vMsid === this.videoSmallInfo.msid || !e.vMsid) && (this.videoSmallInfo.subscribeState = e.video ? re.Subscribed : re.NotSubscribe), (e.vMsid === this.videoLargeInfo.msid || !e.vMsid) && (this.videoLargeInfo.subscribeState = e.video ? re.Subscribed : re.NotSubscribe)), e.screen !== void 0 && (this.screenInfo.subscribeState = e.screen ? re.Subscribed : re.NotSubscribe), e.audio !== void 0 && (this.audioInfo.subscribeState = e.audio ? re.Subscribed : re.NotSubscribe), e.data !== void 0 && (this.dataInfo.subscribeState = e.data ? re.Subscribed : re.NotSubscribe), {
  11439. audioInfo: this.audioInfo,
  11440. videoLargeInfo: this.videoLargeInfo,
  11441. videoSmallInfo: this.videoSmallInfo,
  11442. screenInfo: this.screenInfo,
  11443. dataInfo: this.dataInfo
  11444. };
  11445. }
  11446. /**
  11447. * 更新远端用户设备状态
  11448. * @param status
  11449. * @returns {boolean} 状态改变返回true,否则返回false
  11450. */
  11451. updateRemoteUserDeviceStatus(e) {
  11452. let t = En.parseStatus(e);
  11453. const { audioDisable: i, videoDisable: s, screenDisable: n } = t;
  11454. return this.userStatus ? (this.userStatus.audioDisable != i && (this.userStatus.audioDisable = i, this.emit(Le.Remote, i ? oe.MuteAudio : oe.UnmuteAudio)), this.userStatus.videoDisable != s && (this.userStatus.videoDisable = s, this.emit(Le.Remote, s ? oe.MuteVideo : oe.UnmuteVideo)), this.userStatus.screenDisable != n && (this.userStatus.screenDisable = n, this.emit(Le.Remote, n ? oe.MuteScreen : oe.UnmuteScreen))) : (this.userStatus = t, this.emit(Le.Remote, i ? oe.MuteAudio : oe.UnmuteAudio), this.emit(Le.Remote, s ? oe.MuteVideo : oe.UnmuteVideo), this.emit(Le.Remote, n ? oe.MuteScreen : oe.UnmuteScreen)), !1;
  11455. }
  11456. }
  11457. /**
  11458. * @ignore
  11459. */
  11460. g(Ai, "logName", "RemoteStreamInfo");
  11461. dc([
  11462. D()
  11463. ], Ai.prototype, "updateRemoteTrackSubState", 1);
  11464. class lc {
  11465. constructor(a) {
  11466. g(this, "remoteUser");
  11467. this.remoteUser = a;
  11468. }
  11469. get userId() {
  11470. return this.remoteUser.userId;
  11471. }
  11472. get displayName() {
  11473. return this.remoteUser.displayname;
  11474. }
  11475. get isMuteAudioPlaying() {
  11476. return this.remoteUser.getAudioMuted();
  11477. }
  11478. get hasAudio() {
  11479. return this.remoteUser.hasAudioTrack;
  11480. }
  11481. get hasCamera() {
  11482. return this.remoteUser.hasVideoTrack;
  11483. }
  11484. get hasCameraLarge() {
  11485. return this.remoteUser.hasVideoLargeTrack;
  11486. }
  11487. get hasCameraSmall() {
  11488. return this.remoteUser.hasVideoSmallTrack;
  11489. }
  11490. get hasScreenShare() {
  11491. return this.remoteUser.hasScreenTrack;
  11492. }
  11493. get isAudioSubscribing() {
  11494. return this.remoteUser.isAudioSubscribing;
  11495. }
  11496. get isVideoSubscribing() {
  11497. return this.remoteUser.isVideoSubscribing;
  11498. }
  11499. get isVideoLargeSubscribing() {
  11500. return this.remoteUser.isVideoLargeSubscribing;
  11501. }
  11502. get isVideoSmallSubscribing() {
  11503. return this.remoteUser.isVideoSmallSubscribing;
  11504. }
  11505. get isScreenSubscribing() {
  11506. return this.remoteUser.isScreenSubscribing;
  11507. }
  11508. get audioElement() {
  11509. return this.remoteUser.getAudioElement();
  11510. }
  11511. }
  11512. var fc = Object.defineProperty, pc = Object.getOwnPropertyDescriptor, Te = (r, a, e, t) => {
  11513. for (var i = t > 1 ? void 0 : t ? pc(a, e) : a, s = r.length - 1, n; s >= 0; s--)
  11514. (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i);
  11515. return t && i && fc(a, e, i), i;
  11516. };
  11517. class zt extends De {
  11518. constructor() {
  11519. super();
  11520. g(this, "state");
  11521. g(this, "time");
  11522. g(this, "_enabled");
  11523. this.state = he.AliRtcStateSubscribeIdle, this.time = Date.now(), this._enabled = !0;
  11524. }
  11525. setState(e) {
  11526. if (this.state === e)
  11527. return;
  11528. const t = this.state, i = this.time;
  11529. this.state = e, this.time = Date.now(), this.emit("change", t, e, Math.floor((this.time - i) / 1e3));
  11530. }
  11531. get currentState() {
  11532. return this.state;
  11533. }
  11534. getEnabled() {
  11535. return this._enabled;
  11536. }
  11537. setEnabled(e) {
  11538. this._enabled = e;
  11539. }
  11540. }
  11541. const gc = 30;
  11542. var Me;
  11543. const Ce = (Me = class extends bn {
  11544. constructor(e) {
  11545. var f;
  11546. const {
  11547. userId: t,
  11548. displayName: i,
  11549. rtsManager: s,
  11550. usersViewMap: n,
  11551. slsReporter: c,
  11552. signalingManager: o,
  11553. localUser: u,
  11554. audioVolumeIndicationInterval: h,
  11555. playoutVolume: p,
  11556. parameter: d
  11557. } = e;
  11558. super(t, i, s, h);
  11559. g(this, "remoteCallid", "");
  11560. g(this, "remoteUserInfo");
  11561. g(this, "localUser");
  11562. g(this, "lastPubId", "");
  11563. g(this, "stream");
  11564. g(this, "screenStream");
  11565. // 辅流
  11566. g(this, "viewMap");
  11567. g(this, "audioTrack");
  11568. g(this, "audioElement");
  11569. g(this, "subscribed", !1);
  11570. // 是否有过订阅
  11571. g(this, "mediaStream");
  11572. g(this, "secondaryMediaStream");
  11573. g(this, "prevSubConfig");
  11574. g(this, "signalingManager");
  11575. g(this, "slsReporter");
  11576. g(this, "wantSubAudio", !1);
  11577. g(this, "wantSubVideo", !1);
  11578. g(this, "wantSubScreen", !1);
  11579. g(this, "defaultVideoStreamType", we.AliRtcVideoStreamTypeHigh);
  11580. g(this, "audioMuted", !1);
  11581. g(this, "playoutVolume", 1);
  11582. g(this, "playoutGainNode");
  11583. g(this, "audioSubState");
  11584. g(this, "videoSubState");
  11585. g(this, "videoLargeSubState", new zt());
  11586. g(this, "videoSmallSubState", new zt());
  11587. g(this, "screenSubState");
  11588. // DataChannel 通道相关
  11589. g(this, "dataSubState");
  11590. g(this, "dc");
  11591. g(this, "dcMsgWaitingPieces", []);
  11592. g(this, "streamInfo");
  11593. g(this, "_streamUrl", "");
  11594. g(this, "parameter", {});
  11595. // 统计相关
  11596. g(this, "monitorTimerId");
  11597. g(this, "monitorDataCache", {});
  11598. g(this, "trackTraceIdMap", {});
  11599. g(this, "handleAudioContextSuspended", (e) => {
  11600. e.target.state === "suspended" && this.emit("remoteAudioPlayError", this.uid, "AudioContext suspended");
  11601. });
  11602. g(this, "onDataChannelMessage", (e) => {
  11603. var s;
  11604. const t = Ti.parse(e.slice(4));
  11605. let i;
  11606. if (t.body)
  11607. if (t.isFin) {
  11608. if (this.dcMsgWaitingPieces.length > 0) {
  11609. const n = this.dcMsgWaitingPieces.reduce(
  11610. (c, o) => c + o.byteLength,
  11611. t.body.byteLength
  11612. );
  11613. try {
  11614. const c = new ArrayBuffer(n);
  11615. let o = 0;
  11616. for (let h = 0; h < this.dcMsgWaitingPieces.length; h++) {
  11617. const p = this.dcMsgWaitingPieces[h];
  11618. new Uint8Array(c, o, p.byteLength).set(new Uint8Array(p)), o += p.byteLength;
  11619. }
  11620. new Uint8Array(c, o, t.body.byteLength).set(new Uint8Array(t.body)), i = qt.parse(c);
  11621. } catch (c) {
  11622. }
  11623. this.dcMsgWaitingPieces = [], i || (i = qt.parse(t.body));
  11624. } else
  11625. i = qt.parse(t.body);
  11626. i || O.event(
  11627. `[${Me.logName}]`,
  11628. `parse data channel message fail, piece count: ${this.dcMsgWaitingPieces.length + 1}`
  11629. );
  11630. } else {
  11631. t.header.frameType === 1 && (this.dcMsgWaitingPieces = []), this.dcMsgWaitingPieces.push(t.body);
  11632. return;
  11633. }
  11634. i && (O.event(
  11635. `[${Me.logName}]`,
  11636. `receive data channel message, length: ${(s = i.data) == null ? void 0 : s.byteLength}`
  11637. ), this.emit("remoteDataChannelMessage", this.uid, i));
  11638. });
  11639. g(this, "onDataChannelError", (e) => {
  11640. this.emit("occurError", V.fromError(e, U.ERR_SDK_SUBSCRIBE_DATA_ERROR));
  11641. });
  11642. g(this, "dataChannelConnected", (e) => {
  11643. e && (this.dc = e, this.dc.datachannel && (this.dc.datachannel.binaryType = "arraybuffer"), this.dc.off("message", this.onDataChannelMessage), this.dc.off("error", this.onDataChannelError), this.dc.on("message", this.onDataChannelMessage), this.dc.on("error", this.onDataChannelError));
  11644. });
  11645. g(this, "handleAudioPaused", () => {
  11646. this.emit("remoteAudioPlayError", this.uid, "paused");
  11647. });
  11648. this.streamInfo = new Ai(), this.remoteUserInfo = new lc(this), this.parameter = d, this.streamInfo.on(Le.Remote, (m) => {
  11649. this.emit(Le.Remote, m, this.userId);
  11650. }), this.signalingManager = o, this.viewMap = (f = n[t]) != null ? f : { cameraViews: [], screenViews: [] }, n[t] = this.viewMap, this.slsReporter = c, this.localUser = u, this.audioSubState = new zt(), this.audioSubState.on("change", (m, l, S) => {
  11651. this.emit("audioSubscribeStateChanged", this.uid, m, l, S);
  11652. }), this.videoSubState = new zt(), this.videoSubState.on("change", (m, l, S) => {
  11653. this.emit("videoSubscribeStateChanged", this.uid, m, l, S);
  11654. }), this.screenSubState = new zt(), this.screenSubState.on("change", (m, l, S) => {
  11655. this.emit("screenSubscribeStateChanged", this.uid, m, l, S);
  11656. }), this.dataSubState = new zt(), this.dataSubState.on("change", (m, l, S) => {
  11657. this.emit("dataSubscribeStateChanged", this.uid, m, l, S);
  11658. }), this.playoutVolume = p;
  11659. }
  11660. get streamUrl() {
  11661. return this._streamUrl;
  11662. }
  11663. set streamUrl(e) {
  11664. this._streamUrl = e, this.rtsManager.updateAuth(e);
  11665. }
  11666. isWantSubAudio() {
  11667. return this.wantSubAudio;
  11668. }
  11669. setWantSubAudio(e) {
  11670. this.wantSubAudio = e;
  11671. }
  11672. isWantSubVideo() {
  11673. return this.wantSubVideo;
  11674. }
  11675. setWantSubVideo(e) {
  11676. this.wantSubVideo = e;
  11677. }
  11678. isWantSubScreen() {
  11679. return this.wantSubScreen;
  11680. }
  11681. setWantSubScreen(e) {
  11682. this.wantSubScreen = e;
  11683. }
  11684. setRemoteDefaultVideoStreamType(e) {
  11685. e !== this.defaultVideoStreamType && (this.defaultVideoStreamType = e, this.updateSubscribe(de.User));
  11686. }
  11687. setAudioMuted(e) {
  11688. this.audioMuted = e, this.toggleAudio(!e);
  11689. }
  11690. getAudioElement() {
  11691. return this.audioElement;
  11692. }
  11693. setPlayoutVolume(e) {
  11694. if (this.playoutVolume = e, this.audioElement)
  11695. if (this.parameter.enableAudioContextPlayoutVolume)
  11696. if (this.playoutGainNode)
  11697. this.playoutGainNode.gain.value = e;
  11698. else {
  11699. const t = this.audioElement.srcObject;
  11700. if (t) {
  11701. const i = Ft.getInstance();
  11702. i.addEventListener("statechange", this.handleAudioContextSuspended);
  11703. const s = i.createMediaStreamSource(t);
  11704. this.audioElement.muted = !0, this.playoutGainNode = i.createGain(), s.connect(this.playoutGainNode), this.playoutGainNode.gain.value = e, this.playoutGainNode.connect(i.destination);
  11705. }
  11706. }
  11707. else
  11708. this.audioElement.volume = e;
  11709. }
  11710. getAudioMuted() {
  11711. return this.audioMuted;
  11712. }
  11713. get hasAudioTrack() {
  11714. var e;
  11715. return !!((e = this.streamInfo) != null && e.hasAudio);
  11716. }
  11717. get hasVideoTrack() {
  11718. var e;
  11719. return !!((e = this.streamInfo) != null && e.hasVideo);
  11720. }
  11721. get hasVideoLargeTrack() {
  11722. var e;
  11723. return !!((e = this.streamInfo) != null && e.hasVideoLarge);
  11724. }
  11725. get hasVideoSmallTrack() {
  11726. var e;
  11727. return !!((e = this.streamInfo) != null && e.hasVideoSmall);
  11728. }
  11729. get hasScreenTrack() {
  11730. var e;
  11731. return !!((e = this.streamInfo) != null && e.hasScreen);
  11732. }
  11733. get isAudioSubscribing() {
  11734. var e, t;
  11735. return !!((e = this.streamInfo) != null && e.isAudioSubscribed) || !!((t = this.streamInfo) != null && t.isAudioSubscribing);
  11736. }
  11737. get isVideoSubscribing() {
  11738. var e, t;
  11739. return !!((e = this.streamInfo) != null && e.isVideoSubscribed) || !!((t = this.streamInfo) != null && t.isVideoSubscribing);
  11740. }
  11741. get isVideoLargeSubscribing() {
  11742. var e, t;
  11743. return !!((e = this.streamInfo) != null && e.isVideoLargeSubscribed) || !!((t = this.streamInfo) != null && t.isVideoLargeSubscribing);
  11744. }
  11745. get isVideoSmallSubscribing() {
  11746. var e, t;
  11747. return !!((e = this.streamInfo) != null && e.isVideoSmallSubscribed) || !!((t = this.streamInfo) != null && t.isVideoSmallSubscribing);
  11748. }
  11749. get isScreenSubscribing() {
  11750. var e, t;
  11751. return !!((e = this.streamInfo) != null && e.isScreenSubscribed) || !!((t = this.streamInfo) != null && t.isScreenSubscribing);
  11752. }
  11753. get isDataSubscribing() {
  11754. var e, t;
  11755. return !!((e = this.streamInfo) != null && e.isDataSubscribed) || !!((t = this.streamInfo) != null && t.isDataSubscribing);
  11756. }
  11757. get audioEnabled() {
  11758. var e, t;
  11759. return !!((t = (e = this.stream) == null ? void 0 : e.audioTrack) != null && t.enabled);
  11760. }
  11761. get videoEnabled() {
  11762. var e, t;
  11763. return !!((t = (e = this.stream) == null ? void 0 : e.videoTrack) != null && t.enabled);
  11764. }
  11765. get screenEnabled() {
  11766. var e, t;
  11767. return !!((t = (e = this.screenStream) == null ? void 0 : e.videoTrack) != null && t.enabled);
  11768. }
  11769. get getAudioTrack() {
  11770. return this.audioTrack;
  11771. }
  11772. get getCameraStream() {
  11773. return this.stream;
  11774. }
  11775. get getScreenStream() {
  11776. return this.screenStream;
  11777. }
  11778. setViewConfig(e, t) {
  11779. if (t !== se.AliRtcVideoTrackScreen && t !== se.AliRtcVideoTrackCamera)
  11780. throw new V(
  11781. U.ERR_INVALID_ARGUMENTS,
  11782. "track is not AliRtcVideoTrackScreen or AliRtcVideoTrackCamera"
  11783. );
  11784. e ? jr(e).forEach((s) => {
  11785. s.setAttribute("playsinline", ""), le.BrowserUtil.isMicroMessenger && (s.setAttribute("x5-video-player-type", "h5-page"), s.setAttribute("x5-playsinline", ""), le.SystenUtil.isAndroid || le.SystenUtil.isIos && s.setAttribute("x-webkit-airplay", "allow")), t === se.AliRtcVideoTrackScreen ? this.viewMap.screenViews.push(s) : this.viewMap.cameraViews.push(s), this.play(s, t === se.AliRtcVideoTrackScreen);
  11786. }) : (this.stopPlayAll(t === se.AliRtcVideoTrackScreen), t === se.AliRtcVideoTrackScreen ? this.viewMap.screenViews = [] : this.viewMap.cameraViews = []);
  11787. }
  11788. clear(e = !0) {
  11789. return w(this, null, function* () {
  11790. var t;
  11791. this.subscribeStopDataChannel(), e && this.doStopSubscribe(this.streamUrl), Ni(Me.prototype, this, "clear").call(this), this.stopPlayAudio(), this.clearStream(), this.clearScreenStream(), this.playoutGainNode && (this.playoutGainNode.disconnect(), this.playoutGainNode = void 0, Ft.getInstance().removeEventListener("statechange", this.handleAudioContextSuspended)), (t = this.streamInfo) == null || t.removeAllListeners(Le.Remote);
  11792. });
  11793. }
  11794. updateRemoteUserDeviceStatus(e) {
  11795. var t;
  11796. (t = this.streamInfo) == null || t.updateRemoteUserDeviceStatus(e);
  11797. }
  11798. updateRemoteTracks(e, t, i, s) {
  11799. return w(this, null, function* () {
  11800. var c;
  11801. return this.remoteCallid = e, (!this.streamUrl || !this.streamInfo.hasTrack) && (this.streamUrl = t), this.callId = e != null ? e : "", this.streamInfo || (this.streamInfo = new Ai()), (c = this.streamInfo) == null ? void 0 : c.updateTracks(s);
  11802. });
  11803. }
  11804. subscribe(s, n) {
  11805. return w(this, arguments, function* (e, t, i = Date.now()) {
  11806. var f, m;
  11807. let c = e;
  11808. if (!c) {
  11809. const { hasAudio: l, hasVideo: S, hasScreen: v, hasData: x } = (f = this.streamInfo) != null ? f : {};
  11810. c = {
  11811. audio: this.wantSubAudio && l,
  11812. video: this.wantSubVideo && S,
  11813. screen: this.wantSubScreen && v,
  11814. data: ((m = this.parameter.data) == null ? void 0 : m.enableSubDataChannel) && x
  11815. };
  11816. }
  11817. this.streamInfo.markRemoteTrackSubscribing(c);
  11818. const { screen: o, audio: u, video: h, vMsid: p } = c, d = [];
  11819. (h || u) && d.push({
  11820. audio: u,
  11821. video: h,
  11822. vMsid: p
  11823. }), o && d.push({
  11824. screen: o
  11825. }), !(d.length === 0 && !(e != null && e.data)) && (yield Promise.all(d.map((l) => this.subscribeProxy(l, t || de.User, i))), e != null && e.data && this.subscribeDataChannel());
  11826. });
  11827. }
  11828. subscribeProxy(e, t, i) {
  11829. return w(this, null, function* () {
  11830. var c, o, u, h;
  11831. let s = (/* @__PURE__ */ new Date()).getTime(), n = "";
  11832. try {
  11833. e.audio && this.audioSubState.setState(he.AliRtcStateSubscribing), e.video && (this.videoSubState.currentState === he.AliRtcStateSubscribeIdle || this.videoSubState.currentState === he.AliRtcStateNoSubscribe) && this.videoSubState.setState(he.AliRtcStateSubscribing), e.screen && this.screenSubState.setState(he.AliRtcStateSubscribing);
  11834. const p = yield this.rtsManager.subscribe(
  11835. {
  11836. remoteUser: this,
  11837. options: e
  11838. },
  11839. t,
  11840. ((c = this.localUser) == null ? void 0 : c.callId) || "",
  11841. this.callId,
  11842. i
  11843. );
  11844. this.streamInfo.updateRemoteTrackSubState(e), n = p.traceId || "";
  11845. const { stream: d } = p;
  11846. if (e.audio) {
  11847. this.trackTraceIdMap[T.Audio] = n;
  11848. const m = d.audioTrack;
  11849. m && (this.audioTrack = m, (o = d.mediaStream) == null || o.removeTrack(m), this.playAudio(), this.audioVolumeIndicationInterval && this.audioLevelMonitor.start(m, this.audioVolumeIndicationInterval)), this.audioSubState.setState(he.AliRtcStateSubscribed), this.audioSubState.getEnabled() || this.toggleAudio(!1);
  11850. }
  11851. e.video && (this.videoSubState.setState(he.AliRtcStateSubscribed), e.vMsid === T.VideoSmall ? (this.trackTraceIdMap[T.VideoSmall] = n, this.videoSmallSubState.setState(he.AliRtcStateSubscribed)) : (this.trackTraceIdMap[T.VideoLarge] = n, this.videoLargeSubState.setState(he.AliRtcStateSubscribed)), this.videoSubState.getEnabled() || this.toggleVideo(!1), this.updateStream(d, this.isVideoLargeSubscribing && this.isVideoSmallSubscribing)), e.screen && (this.screenSubState.setState(he.AliRtcStateSubscribed), this.trackTraceIdMap[T.Screen] = n, this.videoSubState.getEnabled() || this.toggleScreen(!1), this.updateScreenStream(d));
  11852. const f = (/* @__PURE__ */ new Date()).getTime() - s;
  11853. this.slsReporter.reportSubscribe(
  11854. ((u = this.localUser) == null ? void 0 : u.callId) || "",
  11855. this.callId,
  11856. !!e.video && e.vMsid === T.VideoLarge,
  11857. !!e.video && e.vMsid === T.VideoSmall,
  11858. !!e.screen,
  11859. !!e.audio,
  11860. 0,
  11861. "",
  11862. f,
  11863. {
  11864. pctid: this.rtsManager.pcTraceId,
  11865. subtid: n,
  11866. ajsub: t === de.Join ? 1 : 0,
  11867. url: this.streamUrl,
  11868. est: s
  11869. }
  11870. ), this.startStreamMonitor();
  11871. } catch (p) {
  11872. const d = (/* @__PURE__ */ new Date()).getTime() - s;
  11873. e.audio && this.audioSubState.setState(he.AliRtcStateNoSubscribe), e.video && this.videoSubState.setState(he.AliRtcStateNoSubscribe), e.screen && this.screenSubState.setState(he.AliRtcStateNoSubscribe), p && (p.message = `user(${this.uid}) subscribe error, ${(p == null ? void 0 : p.message) || ""}`);
  11874. let f = U.ERR_INNER;
  11875. e.audio && (f = U.ERR_SDK_SUBSCRIBE_AUDIO_STREAM_FAILED), e.video && (e.vMsid === T.VideoSmall ? f = U.ERR_SDK_SUBSCRIBE_DUAL_STREAM_FAILED : f = U.ERR_SDK_SUBSCRIBE_VIDEO_STREAM_FAILED), e.screen && (f = U.ERR_SDK_SUBSCRIBE_SCREEN_SHARE_FAILED), this.slsReporter.reportSubscribe(
  11876. ((h = this.localUser) == null ? void 0 : h.callId) || "",
  11877. this.callId,
  11878. !!e.video && e.vMsid === T.VideoLarge,
  11879. !!e.video && e.vMsid === T.VideoSmall,
  11880. !!e.screen,
  11881. !!e.audio,
  11882. f,
  11883. "",
  11884. d,
  11885. {
  11886. pctid: this.rtsManager.pcTraceId,
  11887. subtid: "",
  11888. ajsub: t === de.Join ? 1 : 0,
  11889. url: this.streamUrl,
  11890. est: s
  11891. }
  11892. );
  11893. const m = V.fromError(p, f);
  11894. throw this.emit("remoteSubscribeError", m), m;
  11895. }
  11896. });
  11897. }
  11898. /**
  11899. * 移除对某些轨道的订阅
  11900. * @param {UnSubscribeOptions} options 取消订阅轨道配置
  11901. * @returns {Promise<SubscribeResult>}
  11902. */
  11903. subscribeDeleteTracks(e) {
  11904. return w(this, null, function* () {
  11905. const { audio: t, video: i, screen: s, data: n, vMsid: c } = e, o = [];
  11906. (t || i || n) && o.push({
  11907. audio: t,
  11908. video: i,
  11909. vMsid: c
  11910. }), s && o.push({
  11911. screen: s
  11912. }), o.length !== 0 && (yield Promise.all(o.map((u) => this.subscribeDeleteProxy(u))), e.data && this.subscribeStopDataChannel());
  11913. });
  11914. }
  11915. subscribeDeleteProxy(e) {
  11916. return w(this, null, function* () {
  11917. try {
  11918. const t = yield this.rtsManager.subscribeDelete({
  11919. remoteUser: this,
  11920. options: e
  11921. }), { stream: i } = t != null ? t : {}, s = {};
  11922. e.audio === !0 && (s.audio = !1, this.audioSubState.setState(he.AliRtcStateNoSubscribe)), e.video === !0 && (s.video = !1, e.vMsid === T.VideoSmall ? (this.videoSmallSubState.setState(he.AliRtcStateNoSubscribe), (this.videoLargeSubState.currentState === he.AliRtcStateNoSubscribe || this.videoLargeSubState.currentState === he.AliRtcStateSubscribeIdle) && this.videoSubState.setState(he.AliRtcStateNoSubscribe)) : (this.videoLargeSubState.setState(he.AliRtcStateNoSubscribe), (this.videoSmallSubState.currentState === he.AliRtcStateNoSubscribe || this.videoSmallSubState.currentState === he.AliRtcStateSubscribeIdle) && this.videoSubState.setState(he.AliRtcStateNoSubscribe))), e.screen === !0 && (s.screen = !1, this.screenSubState.setState(he.AliRtcStateNoSubscribe));
  11923. const { callId: n, remoteCallid: c } = this, o = {
  11924. callid: n,
  11925. remoteCallid: c,
  11926. remoteStream: i
  11927. };
  11928. return e.audio && (this.audioLevelMonitor.stop(), this.stopPlayAudio(), this.audioTrack = void 0), this.streamInfo.updateRemoteTrackSubState({
  11929. audio: e.audio === !0 ? !1 : void 0,
  11930. video: e.video === !0 ? !1 : void 0,
  11931. screen: e.screen === !0 ? !1 : void 0,
  11932. vMsid: e.vMsid
  11933. }), o;
  11934. } catch (t) {
  11935. throw V.fromError(t, U.ERR_INNER, "subscribe delete failed");
  11936. }
  11937. });
  11938. }
  11939. restore() {
  11940. this.callId = "", this.clearStream(), this.clearScreenStream(), this.audioTrack = void 0, this.streamInfo.updateRemoteTrackSubState({
  11941. audio: !1,
  11942. video: !1,
  11943. screen: !1,
  11944. data: !1
  11945. }), this.audioElement && this.audioElement.removeEventListener("pause", this.handleAudioPaused);
  11946. }
  11947. resumeAudio() {
  11948. return w(this, null, function* () {
  11949. const e = Ft.getInstance();
  11950. return e.state !== "running" && e.resume(), this.audioElement ? this.audioElement.play() : this.playAudio();
  11951. });
  11952. }
  11953. resumeVideo(e) {
  11954. return w(this, null, function* () {
  11955. if (!e || e === se.AliRtcVideoTrackCamera || e === se.AliRtcVideoTrackBoth)
  11956. return this.playAll();
  11957. if (!e || e === se.AliRtcVideoTrackScreen || e === se.AliRtcVideoTrackBoth)
  11958. return this.playAll(!0);
  11959. });
  11960. }
  11961. resumePlay() {
  11962. this.playAudio(), this.playAll(), this.playAll(!0);
  11963. }
  11964. stopSubscribe(e) {
  11965. return w(this, null, function* () {
  11966. var i, s;
  11967. let t = (/* @__PURE__ */ new Date()).getTime();
  11968. try {
  11969. let n;
  11970. e ? n = yield this.subscribeDeleteTracks(e) : n = yield this.doStopSubscribe(this.streamUrl), this.slsReporter.reportUnsubscribe(
  11971. ((i = this.localUser) == null ? void 0 : i.callId) || (n == null ? void 0 : n.callid) || "",
  11972. this.callId,
  11973. (/* @__PURE__ */ new Date()).getTime() - t,
  11974. 0,
  11975. ""
  11976. );
  11977. } catch (n) {
  11978. throw this.slsReporter.reportUnsubscribe(((s = this.localUser) == null ? void 0 : s.callId) || "", this.callId, (/* @__PURE__ */ new Date()).getTime() - t, 0, ""), n;
  11979. }
  11980. });
  11981. }
  11982. doStopSubscribe(e) {
  11983. return w(this, null, function* () {
  11984. var s, n, c, o;
  11985. const { callId: t, remoteCallid: i } = this;
  11986. if ((this.isAudioSubscribing || this.isVideoSubscribing || this.isScreenSubscribing) && e)
  11987. try {
  11988. this.stopStreamMonitor(), yield this.rtsManager.subscibeStop(e), this.restore();
  11989. const u = {
  11990. callid: t,
  11991. remoteCallid: i,
  11992. remoteStream: this.stream
  11993. };
  11994. return this.callId = "", u;
  11995. } catch (u) {
  11996. if (((o = (c = (n = (s = u == null ? void 0 : u.extraInfo) == null ? void 0 : s.parsedData) == null ? void 0 : n.streams) == null ? void 0 : c[0]) == null ? void 0 : o.res_code) !== 404)
  11997. throw V.fromError(u, U.ERR_INNER, "subscribe stop failed");
  11998. }
  11999. });
  12000. }
  12001. updateStream(e, t = !1) {
  12002. return w(this, null, function* () {
  12003. this.stream && this.stream.videoTrack && e.mediaStream && t && (yield new Promise((i) => {
  12004. let s, n;
  12005. if (e.mediaStream) {
  12006. n = document.createElement("video");
  12007. const c = () => {
  12008. O.event(`uid: ${this.userId} new mediaStream canplay`), n && n.removeEventListener("canplaythrough", c, !1), n = void 0, clearTimeout(s), i(!0);
  12009. };
  12010. n.addEventListener("canplaythrough", c, !1), (n._playPromise || Promise.resolve()).then(() => {
  12011. n && e.mediaStream && (n.srcObject = e.mediaStream);
  12012. });
  12013. } else
  12014. i(!0);
  12015. s = window.setTimeout(() => {
  12016. O.event(`uid: ${this.userId} new mediaStream timeout`), n = void 0, i(!0);
  12017. }, 3e3);
  12018. }), this.updateSubscribe(de.User)), this.stream = e, this.playAll(!1, t), !this.subscribed && e && (this.subscribed = !0), e.hasAudio && this.isAudioSubscribing && e.enableAudio(), e.hasVideo && this.isVideoSubscribing && e.enableVideo();
  12019. });
  12020. }
  12021. updateScreenStream(e) {
  12022. this.screenStream = e, this.playAll(!0), !this.subscribed && e && (this.subscribed = !0), e.hasVideo && this.isScreenSubscribing && e.enableVideo();
  12023. }
  12024. clearStream() {
  12025. var e;
  12026. (e = this.stream) == null || e.stop(), this.stream = void 0;
  12027. }
  12028. clearScreenStream() {
  12029. var e;
  12030. (e = this.screenStream) == null || e.stop(), this.screenStream = void 0;
  12031. }
  12032. subscribeDataChannel() {
  12033. if (this.dc)
  12034. try {
  12035. this.dc.dispose(), this.dcMsgWaitingPieces = [], this.dc.off("message", this.onDataChannelMessage), this.dc = void 0;
  12036. } catch (e) {
  12037. }
  12038. !this.streamInfo.hasAudio && !this.streamInfo.hasVideo && !this.streamInfo.hasScreen || (this.dataSubState.setState(he.AliRtcStateSubscribing), this.rtsManager.subscribeAddDataChannel(this.streamUrl).then((e) => {
  12039. if (e) {
  12040. this.dataChannelConnected(e), this.dataSubState.setState(he.AliRtcStateSubscribed), this.streamInfo.updateRemoteTrackSubState({
  12041. data: !0
  12042. });
  12043. return;
  12044. } else
  12045. throw new Error("no dc founded");
  12046. }).catch((e) => {
  12047. const t = V.fromError(e, U.ERR_INNER, "subscribe data failed");
  12048. this.emit("remoteSubscribeError", t), this.dataSubState.setState(he.AliRtcStateNoSubscribe);
  12049. }));
  12050. }
  12051. subscribeStopDataChannel() {
  12052. if (this.dc) {
  12053. try {
  12054. this.rtsManager.subscribeStopDatachannel(this.streamUrl, this.dc);
  12055. } catch (e) {
  12056. }
  12057. this.dcMsgWaitingPieces = [], this.dc.off("message", this.onDataChannelMessage), this.dc.off("error", this.onDataChannelError), this.dataSubState.setState(he.AliRtcStateNoSubscribe), this.dc = void 0, this.streamInfo.updateRemoteTrackSubState({
  12058. data: !1
  12059. });
  12060. }
  12061. }
  12062. getRetryOptions() {
  12063. var i, s, n, c, o, u, h;
  12064. const e = {};
  12065. this.wantSubAudio && ((i = this.streamInfo) != null && i.hasAudio) && (e.audio = !0, e.aMsid = ((s = this.streamInfo.getAudioInfo()) == null ? void 0 : s.msid) || T.Audio), this.wantSubVideo && ((n = this.streamInfo) != null && n.hasVideo) && (this.defaultVideoStreamType === we.AliRtcVideoStreamTypeLow && ((c = this.streamInfo) != null && c.hasVideoSmall) ? (e.video = !0, e.vMsid = T.VideoSmall) : (o = this.streamInfo) != null && o.hasVideoLarge && (e.video = !0, e.vMsid = ((u = this.streamInfo.getVideoLargeInfo()) == null ? void 0 : u.msid) || T.VideoLarge)), this.wantSubScreen && ((h = this.streamInfo) != null && h.hasScreen) && (e.screen = !0);
  12066. let t = {};
  12067. if (e.audio || e.video)
  12068. t = {
  12069. audio: e.audio,
  12070. video: e.video
  12071. }, this.streamInfo.updateRemoteTrackSubState({
  12072. screen: !1,
  12073. data: !1
  12074. });
  12075. else if (e.screen)
  12076. t = {
  12077. screen: e.screen
  12078. }, this.streamInfo.updateRemoteTrackSubState({
  12079. data: !1
  12080. });
  12081. else
  12082. return;
  12083. return {
  12084. remoteUser: this,
  12085. options: t
  12086. };
  12087. }
  12088. updateSubscribe(e) {
  12089. var n, c, o, u, h, p, d, f, m, l, S, v, x, b, E, _, y;
  12090. const t = Date.now(), i = {}, s = {};
  12091. if (this.wantSubAudio && !this.isAudioSubscribing && ((n = this.streamInfo) != null && n.hasAudio) ? (i.audio = !0, i.aMsid = ((c = this.streamInfo.getAudioInfo()) == null ? void 0 : c.msid) || T.Audio) : (!this.wantSubAudio || !((o = this.streamInfo) != null && o.hasAudio)) && this.isAudioSubscribing && (s.audio = !0, s.aMsid = ((u = this.streamInfo.getAudioInfo()) == null ? void 0 : u.msid) || T.Audio), this.wantSubVideo && ((h = this.streamInfo) != null && h.hasVideo) ? (this.defaultVideoStreamType === we.AliRtcVideoStreamTypeLow && !this.isVideoSmallSubscribing && ((p = this.streamInfo) != null && p.hasVideoSmall) ? (i.video = !0, i.vMsid = T.VideoSmall) : !this.isVideoLargeSubscribing && ((d = this.streamInfo) != null && d.hasVideoLarge) && !(this.defaultVideoStreamType === we.AliRtcVideoStreamTypeLow && this.isVideoSmallSubscribing) && (i.video = !0, i.vMsid = ((f = this.streamInfo.getVideoLargeInfo()) == null ? void 0 : f.msid) || T.VideoLarge), this.defaultVideoStreamType === we.AliRtcVideoStreamTypeLow && this.isVideoLargeSubscribing && this.isVideoSmallSubscribing && this.streamInfo.hasVideoSmall ? (s.video = !0, s.vMsid = T.VideoLarge) : this.defaultVideoStreamType === we.AliRtcVideoStreamTypeHigh && this.isVideoLargeSubscribing && this.isVideoSmallSubscribing && (s.video = !0, s.vMsid = T.VideoSmall)) : (!this.wantSubVideo || !((m = this.streamInfo) != null && m.hasVideo)) && this.isVideoSubscribing && (s.video = !0, s.vMsid = this.streamInfo.isVideoSmallSubscribed || this.streamInfo.isVideoSmallSubscribing ? T.VideoSmall : ((l = this.streamInfo.getVideoLargeInfo()) == null ? void 0 : l.msid) || T.VideoLarge), this.wantSubScreen && !this.isScreenSubscribing && ((S = this.streamInfo) != null && S.hasScreen) ? i.screen = !0 : (!this.wantSubScreen || !((v = this.streamInfo) != null && v.hasScreen)) && this.isScreenSubscribing && (s.screen = !0), (x = this.parameter.data) != null && x.enableSubDataChannel && !this.isDataSubscribing && ((b = this.streamInfo) != null && b.hasData) ? i.data = !0 : (!((E = this.parameter.data) != null && E.enableSubDataChannel) || !((_ = this.streamInfo) != null && _.hasData)) && this.isDataSubscribing && (s.data = !0), (i.audio || i.video || i.screen || i.data) && (this.createCallId(), this.subscribe(i, e, t)), (s.audio || s.video || s.screen) && this.subscribeDeleteTracks(s), e === de.Reconnect) {
  12092. if (O.event(`[${Me.logName}]`, "reconnect, try to resume"), this.streamInfo.hasData && !i.data) {
  12093. const A = this.rtsManager.getDatachannelByMsid({
  12094. url: this.streamUrl,
  12095. msid: this.streamInfo.getDataInfo().msid || T.Data
  12096. });
  12097. this.dataChannelConnected(A);
  12098. }
  12099. if (this.streamInfo.hasAudio && !i.audio) {
  12100. const A = this.rtsManager.getStreamByMsid({
  12101. url: this.streamUrl,
  12102. aMsid: this.streamInfo.getAudioInfo().msid || T.Audio
  12103. }).audioTrack;
  12104. A && (this.audioTrack = A, this.playAudio());
  12105. }
  12106. if (this.streamInfo.hasVideo && !i.video) {
  12107. const A = this.rtsManager.getStreamByMsid({
  12108. url: this.streamUrl,
  12109. vMsid: this.streamInfo.isVideoSmallSubscribed || this.streamInfo.isVideoSmallSubscribing ? T.VideoSmall : ((y = this.streamInfo.getVideoLargeInfo()) == null ? void 0 : y.msid) || T.VideoLarge
  12110. });
  12111. A && A.mediaStream && (this.stream = A, this.playAll(!1));
  12112. }
  12113. if (this.streamInfo.hasScreen && !i.screen) {
  12114. const A = this.rtsManager.getStreamByMsid({
  12115. url: this.streamUrl,
  12116. sMsid: this.streamInfo.getScreenInfo().msid || T.Screen
  12117. });
  12118. A && A.mediaStream && (this.screenStream = A, this.playAll(!0));
  12119. }
  12120. }
  12121. return {
  12122. addOption: i,
  12123. deleteOption: s
  12124. };
  12125. }
  12126. handleAutoPlayFailed() {
  12127. O.event(`[${Me.logName}]`, "auto play failed"), this.emit("remoteAudioAutoPlayFail", this.uid);
  12128. const e = () => {
  12129. this.resumeAudio().then(() => {
  12130. document.removeEventListener("click", e, !1), document.removeEventListener("touchstart", e, !1);
  12131. });
  12132. };
  12133. document.addEventListener("click", e, !1), document.addEventListener("touchstart", e, !1);
  12134. }
  12135. handleVideoPlayFailded(e, t) {
  12136. this.emit("remoteVideoAutoPlayFail", this.uid, t);
  12137. const i = () => {
  12138. var n;
  12139. const s = (n = t === se.AliRtcVideoTrackScreen ? this.screenStream : this.stream) == null ? void 0 : n.mediaStream;
  12140. e.srcObject === s && this.play(e, t === se.AliRtcVideoTrackScreen), document.removeEventListener("click", i, !1), document.removeEventListener("touchstart", i, !1);
  12141. };
  12142. document.addEventListener("click", i, !1), document.addEventListener("touchstart", i, !1);
  12143. }
  12144. playAudio() {
  12145. return w(this, null, function* () {
  12146. var e, t;
  12147. if (!this.audioTrack) {
  12148. O.event(`[${Me.logName}]`, this.userId, "audio track is null");
  12149. return;
  12150. }
  12151. if (this.toggleAudio(!this.audioMuted), this.audioElement || (O.event(`[${Me.logName}]`, this.userId, "create audio element"), this.audioElement = document.createElement("audio"), this.audioElement.setAttribute("autoplay", "autoplay"), this.audioElement.addEventListener("pause", this.handleAudioPaused), this.setPlayoutVolume(this.playoutVolume)), ((t = (e = this.audioElement.srcObject) == null ? void 0 : e.getAudioTracks()) == null ? void 0 : t[0]) !== this.audioTrack) {
  12152. let i = this.audioElement.srcObject;
  12153. i ? i.getAudioTracks().forEach((s) => {
  12154. i.removeTrack(s);
  12155. }) : (i = new MediaStream(), this.audioElement.srcObject = i), i.addTrack(this.audioTrack);
  12156. }
  12157. if (le.SystenUtil.isIos && parseInt(le.SystenUtil.systemVersion) <= 13) {
  12158. O.event(`[${Me.logName}]`, "play audio for iOS 13-");
  12159. const i = this.audioElement;
  12160. i.setAttribute("autoplay", "");
  12161. const s = () => {
  12162. i.removeEventListener("playing", s), i.pause(), i.play().catch(() => {
  12163. this.handleAutoPlayFailed();
  12164. });
  12165. };
  12166. this.audioElement.addEventListener("playing", s);
  12167. } else
  12168. (() => {
  12169. var s;
  12170. O.event(`[${Me.logName}]`, "try play audio"), (s = this.audioElement) == null || s.play().then(() => {
  12171. O.event(`[${Me.logName}]`, "play audio success");
  12172. }).catch(() => {
  12173. this.handleAutoPlayFailed();
  12174. });
  12175. })();
  12176. });
  12177. }
  12178. stopPlayAudio() {
  12179. this.audioElement && (this.audioElement.pause(), this.audioElement.removeEventListener("pause", this.handleAudioPaused));
  12180. }
  12181. playAll(e = !1, t = !1) {
  12182. e ? (this.viewMap.screenViews || []).forEach((i) => {
  12183. this.play(i, e, t);
  12184. }) : (this.viewMap.cameraViews || []).forEach((i) => {
  12185. this.play(i, e, t);
  12186. });
  12187. }
  12188. play(e, t = !1, i = !1) {
  12189. const s = t ? this.screenStream : this.stream;
  12190. !e || !s || !s.mediaStream || yn(e, s.mediaStream, i).catch((n) => {
  12191. n.code === 20 || n.name === "AbortError" || this.handleVideoPlayFailded(
  12192. e,
  12193. t ? se.AliRtcVideoTrackScreen : se.AliRtcVideoTrackCamera
  12194. );
  12195. });
  12196. }
  12197. stopPlayAll(e = !1) {
  12198. e ? this.viewMap.screenViews.forEach((t) => {
  12199. at(t);
  12200. }) : this.viewMap.cameraViews.forEach((t) => {
  12201. at(t);
  12202. });
  12203. }
  12204. /**
  12205. * 是否开启声音
  12206. * @param {boolean} enable
  12207. * @returns {void}
  12208. */
  12209. toggleAudio(e = !0) {
  12210. this.audioSubState.setEnabled(e), this.audioElement && (this.audioElement.muted = !e);
  12211. }
  12212. /**
  12213. * 是否开启画面
  12214. * @param {boolean} enable
  12215. * @returns {void}
  12216. */
  12217. toggleVideo(e = !0) {
  12218. this.videoSubState.setEnabled(e), this.stream && (e ? this.stream.enableVideo() : this.stream.disableVideo());
  12219. }
  12220. /**
  12221. * 是否开启画面
  12222. * @param {boolean} enable
  12223. * @returns {void}
  12224. */
  12225. toggleScreen(e = !0) {
  12226. this.screenSubState.setEnabled(e), this.screenStream && (e ? this.screenStream.enableVideo() : this.screenStream.disableVideo());
  12227. }
  12228. getStats() {
  12229. return w(this, null, function* () {
  12230. var i, s, n, c, o;
  12231. const e = [];
  12232. if (this.isAudioSubscribing) {
  12233. const u = yield this.rtsManager.getSubscribeAudioStats(this.streamUrl);
  12234. u && e.push({ uid: this.uid, track: Xt.AliRtcAudioTrackMic, stats: u });
  12235. }
  12236. const t = [];
  12237. if ((i = this.streamInfo) != null && i.isVideoLargeSubscribed) {
  12238. const u = yield this.rtsManager.getSubscribeVideoStats(
  12239. this.streamUrl,
  12240. ((s = this.streamInfo.getVideoLargeInfo()) == null ? void 0 : s.msid) || T.VideoLarge
  12241. );
  12242. u && t.push({
  12243. uid: this.uid,
  12244. track: se.AliRtcVideoTrackCamera,
  12245. streamType: we.AliRtcVideoStreamTypeHigh,
  12246. stats: u
  12247. });
  12248. }
  12249. if ((n = this.streamInfo) != null && n.isVideoSmallSubscribed) {
  12250. const u = yield this.rtsManager.getSubscribeVideoStats(
  12251. this.streamUrl,
  12252. ((c = this.streamInfo.getVideoSmallInfo()) == null ? void 0 : c.msid) || T.VideoSmall
  12253. );
  12254. u && t.push({
  12255. uid: this.uid,
  12256. track: se.AliRtcVideoTrackCamera,
  12257. streamType: we.AliRtcVideoStreamTypeLow,
  12258. stats: u
  12259. });
  12260. }
  12261. if (this.isScreenSubscribing) {
  12262. const u = yield this.rtsManager.getSubscribeVideoStats(
  12263. this.streamUrl,
  12264. ((o = this.streamInfo.getScreenInfo()) == null ? void 0 : o.msid) || T.Screen
  12265. );
  12266. u && t.push({
  12267. uid: this.uid,
  12268. track: se.AliRtcVideoTrackScreen,
  12269. stats: u
  12270. });
  12271. }
  12272. return { audio: e, video: t };
  12273. });
  12274. }
  12275. /**
  12276. * 开启音量检测
  12277. * @param {number} interval 时间间隔
  12278. */
  12279. enableAudioVolumeIndication(e) {
  12280. this.audioVolumeIndicationInterval !== e && (this.audioVolumeIndicationInterval > 0 && e <= 0 && this.audioLevelMonitor.stop(), e > 0 && this.audioTrack && this.audioLevelMonitor.start(this.audioTrack, e), this.audioVolumeIndicationInterval = e);
  12281. }
  12282. reportSubscribeMonitor(e) {
  12283. var t;
  12284. e && (this.slsReporter.reportSubscribeMonitor(
  12285. ((t = this.localUser) == null ? void 0 : t.callId) || "",
  12286. this.callId,
  12287. this.trackTraceIdMap[e] || "",
  12288. e,
  12289. this.monitorDataCache[e]
  12290. ), this.monitorDataCache[e] = []);
  12291. }
  12292. startStreamMonitor() {
  12293. this.monitorTimerId || (this.monitorTimerId = window.setInterval(() => w(this, null, function* () {
  12294. try {
  12295. if (this.streamInfo.subscribingInfos.length === 0) {
  12296. this.stopStreamMonitor();
  12297. return;
  12298. }
  12299. let e = Object.keys(this.monitorDataCache).filter((t) => {
  12300. var i;
  12301. return ((i = this.monitorDataCache[t]) == null ? void 0 : i.length) > 0;
  12302. });
  12303. this.streamInfo.subscribingInfos.forEach((t) => {
  12304. const i = t.msid;
  12305. if (!i)
  12306. return;
  12307. e.includes(i) && (e = e.filter((c) => c !== i));
  12308. let s;
  12309. const n = i === T.Audio;
  12310. n ? s = this.rtsManager.getSubscribeAudioStats(this.streamUrl) : s = this.rtsManager.getSubscribeVideoStats(this.streamUrl, i), s.then((c) => {
  12311. var p;
  12312. if (!c.timestamp)
  12313. return;
  12314. this.monitorDataCache[i] || (this.monitorDataCache[i] = []);
  12315. const o = this.monitorDataCache[i];
  12316. let u;
  12317. if ((o == null ? void 0 : o.length) > 0) {
  12318. const h = o[o.length - 1] || {}, { _last: f } = h;
  12319. u = Dt(h, ["_last"]);
  12320. }
  12321. (o == null ? void 0 : o.length) >= gc && this.reportSubscribeMonitor(i), c._last = u, c._codec = t.codec, n && (c._source = (p = this.localUser) == null ? void 0 : p.getMediaStats(c.playoutId)), this.monitorDataCache[i].push(c);
  12322. });
  12323. }), e.forEach((t) => {
  12324. this.reportSubscribeMonitor(t);
  12325. });
  12326. } catch (e) {
  12327. }
  12328. }), 1e3));
  12329. }
  12330. /**
  12331. * 停止本地流数据采集
  12332. */
  12333. stopStreamMonitor() {
  12334. this.monitorTimerId && (clearInterval(this.monitorTimerId), this.monitorTimerId = void 0), Object.keys(this.monitorDataCache).forEach((e) => {
  12335. this.reportSubscribeMonitor(e);
  12336. });
  12337. }
  12338. }, /**
  12339. * @ignore
  12340. */
  12341. g(Me, "logName", "RemoteUser"), Me);
  12342. Te([
  12343. D()
  12344. ], Ce.prototype, "clear", 1);
  12345. Te([
  12346. D()
  12347. ], Ce.prototype, "updateRemoteUserDeviceStatus", 1);
  12348. Te([
  12349. D()
  12350. ], Ce.prototype, "updateRemoteTracks", 1);
  12351. Te([
  12352. D(H)
  12353. ], Ce.prototype, "subscribe", 1);
  12354. Te([
  12355. D()
  12356. ], Ce.prototype, "subscribeProxy", 1);
  12357. Te([
  12358. D(H)
  12359. ], Ce.prototype, "subscribeDeleteProxy", 1);
  12360. Te([
  12361. D()
  12362. ], Ce.prototype, "restore", 1);
  12363. Te([
  12364. D(H)
  12365. ], Ce.prototype, "resumeAudio", 1);
  12366. Te([
  12367. D(H)
  12368. ], Ce.prototype, "stopSubscribe", 1);
  12369. Te([
  12370. D(H)
  12371. ], Ce.prototype, "doStopSubscribe", 1);
  12372. Te([
  12373. D()
  12374. ], Ce.prototype, "clearStream", 1);
  12375. Te([
  12376. D()
  12377. ], Ce.prototype, "clearScreenStream", 1);
  12378. Te([
  12379. D()
  12380. ], Ce.prototype, "updateSubscribe", 1);
  12381. Te([
  12382. D()
  12383. ], Ce.prototype, "playAudio", 1);
  12384. Te([
  12385. D()
  12386. ], Ce.prototype, "stopPlayAudio", 1);
  12387. Te([
  12388. D((r, a, e) => [
  12389. typeof r == "string" ? r : r == null ? void 0 : r.nodeType,
  12390. a,
  12391. e
  12392. ])
  12393. ], Ce.prototype, "play", 1);
  12394. Te([
  12395. D()
  12396. ], Ce.prototype, "stopPlayAll", 1);
  12397. let mc = Ce;
  12398. var _t = /* @__PURE__ */ ((r) => (r[r.AliRtcPluginErrorCodeSuccess = 0] = "AliRtcPluginErrorCodeSuccess", r[r.AliRtcPluginErrorCodeFailed = -1] = "AliRtcPluginErrorCodeFailed", r[r.AliRtcPluginErrorNoFindPlugin = -2] = "AliRtcPluginErrorNoFindPlugin", r[r.AliRtcPluginErrorParameterError = -3] = "AliRtcPluginErrorParameterError", r[r.AliRtcPluginErrorLoadError = -4] = "AliRtcPluginErrorLoadError", r[r.AliRtcPluginErrorCreateError = -5] = "AliRtcPluginErrorCreateError", r[r.AliRtcPluginErrorInitError = -6] = "AliRtcPluginErrorInitError", r[r.AliRtcPluginErrorInitTokenError = -7] = "AliRtcPluginErrorInitTokenError", r))(_t || {});
  12399. class Sc extends De {
  12400. constructor() {
  12401. super(...arguments);
  12402. g(this, "plugins", /* @__PURE__ */ new Map());
  12403. }
  12404. add(e, t) {
  12405. if (this.plugins.has(e.name))
  12406. throw new V(_t.AliRtcPluginErrorCreateError, `Plugin ${e.name} already exists`);
  12407. this.plugins.set(e.name, e), t && e.setOptions(t), this.emit("added", e), e.on("enabled", () => this.emit("added", e)), e.on("disabled", () => this.emit("removed", e)), e.on("updated", () => this.emit("updated", e));
  12408. }
  12409. remove(e) {
  12410. const t = this.plugins.get(e);
  12411. if (!t)
  12412. throw new V(_t.AliRtcPluginErrorNoFindPlugin, `Plugin ${e} not founded`);
  12413. this.plugins.delete(e), t.removeAllListeners(), this.emit("removed", t);
  12414. }
  12415. removeAll() {
  12416. this.plugins.forEach((e) => {
  12417. this.remove(e.name);
  12418. });
  12419. }
  12420. get(e) {
  12421. return this.plugins.get(e);
  12422. }
  12423. has(e) {
  12424. return !!this.plugins.get(e);
  12425. }
  12426. getAll() {
  12427. return Array.from(this.plugins.values());
  12428. }
  12429. }
  12430. var xc = Object.defineProperty, vc = Object.getOwnPropertyDescriptor, Ee = (r, a, e, t) => {
  12431. for (var i = t > 1 ? void 0 : t ? vc(a, e) : a, s = r.length - 1, n; s >= 0; s--)
  12432. (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i);
  12433. return t && i && xc(a, e, i), i;
  12434. };
  12435. const Pi = ([r]) => {
  12436. const { remoteUser: a, options: e } = r;
  12437. return [`user(${a.userId})`, e];
  12438. }, Ja = 5, Ga = 17, Xa = 5e3;
  12439. var Ae;
  12440. const Se = (Ae = class extends De {
  12441. constructor(e, t, i) {
  12442. super();
  12443. g(this, "rts");
  12444. g(this, "encodedInsertableStreams", !0);
  12445. g(this, "audioRedEnabled", !1);
  12446. g(this, "localStreamManager");
  12447. g(this, "slsReporter");
  12448. g(this, "_rtsReconnecting", !1);
  12449. g(this, "_rtsPeerConnectionType", "publish");
  12450. g(this, "connecting", !1);
  12451. g(this, "connected", !1);
  12452. g(this, "_pcTraceId", "");
  12453. g(this, "_localJoinTime", 0);
  12454. g(this, "connectionResolve");
  12455. g(this, "connectingPromise");
  12456. g(this, "dcResolve");
  12457. g(this, "dcReject");
  12458. g(this, "dcConnectingPromise");
  12459. g(this, "_publishingTracks", []);
  12460. g(this, "parameter", {});
  12461. this.localStreamManager = e, this.slsReporter = t, this.parameter = i, this.rts = le.createClient({
  12462. singlePcConfig: {
  12463. usePcReconnect: !0
  12464. }
  12465. }), this.addRTSListener();
  12466. }
  12467. addRTSListener() {
  12468. this.rts.on("connectStatusChange", (e) => {
  12469. var t, i, s, n;
  12470. if (O.event(`[${Ae.logName}]`, "rts connectStatusChange to:", e.status), e.status === Mi.CONNECT_STATUS_DISCONNECTED)
  12471. this.dcReject && this.dcReject(), this.setConnected(!1), this.slsReporter.reportWarning("rts disconnected"), this.emit("disconnected");
  12472. else if (e.status === Mi.CONNECT_STATUS_RECONNECTING)
  12473. this._rtsReconnecting = !0;
  12474. else if (e.status === Mi.CONNECT_STATUS_CONNECTED) {
  12475. const c = (n = (s = (i = (t = this.rts.commonController) == null ? void 0 : t.peerCore) == null ? void 0 : i.getSignal()) == null ? void 0 : s.getDatachannelCore()) == null ? void 0 : n.readyState;
  12476. O.event(`[${Ae.logName}]`, "dcReadyState:", c), c === "open" && this.dcResolve && this.dcResolve(!0), this._rtsReconnecting && this._rtsPeerConnectionType === "publish" && (this._publishingTracks = this.rts.getPublishTrackInfoList()), this.setConnected(!0);
  12477. }
  12478. }), this.rts.on("reconnectFinish", () => {
  12479. O.event(`[${Ae.logName}]`, "rts reconnectFinish");
  12480. try {
  12481. this.emit("connected", !0, this._rtsPeerConnectionType);
  12482. } catch (e) {
  12483. O.error(`[${Ae.logName}]`, "emit connected error:", e);
  12484. }
  12485. }), this.rts.on("datachannelStatusChange", (e) => {
  12486. O.event(`[${Ae.logName}]`, "rts datachannelStatusChange to:", e.status), e.status === vs.DATACHANNEL_STATUS_OPEN ? this.dcResolve && this.dcResolve(!0) : e.status === vs.DATACHANNEL_STATUS_CLOSE && (this.dcReject && this.dcReject(), this.dcConnectingPromise = new Promise((t, i) => {
  12487. this.dcResolve = t, this.dcReject = i;
  12488. }));
  12489. }), this.rts.on("receivedSEI", (e) => {
  12490. this.emit("seimessage", e.url, e.sei.payloadType, e.sei.data);
  12491. }), this.rts.on("onError", (e) => {
  12492. O.event(`[${Ae.logName}]`, "rts onError event:", e);
  12493. }), this.rts.on("reconnect", (e) => {
  12494. O.event(`[${Ae.logName}]`, "rts reconnect event:", e);
  12495. });
  12496. }
  12497. /**
  12498. * 更新鉴权信息,传入一个新的带鉴权的 URL,RTS 会去除鉴权信息做更新
  12499. * @param newUrlWithAuth
  12500. */
  12501. updateAuth(e) {
  12502. this.rts.updateAuth(e);
  12503. }
  12504. get pcTraceId() {
  12505. return this._pcTraceId;
  12506. }
  12507. set localJoinTime(e) {
  12508. this._localJoinTime = e;
  12509. }
  12510. setEncodedInsertableStreams(e) {
  12511. this.encodedInsertableStreams = e;
  12512. }
  12513. setAudioRedEnabled(e) {
  12514. var t;
  12515. if (e !== this.audioRedEnabled) {
  12516. try {
  12517. const s = [...((t = RTCRtpReceiver.getCapabilities("audio")) == null ? void 0 : t.codecs) || []];
  12518. if (s.length > 0) {
  12519. if (e) {
  12520. const n = s.findIndex((o) => o.mimeType === "audio/red"), c = s.findIndex((o) => o.mimeType === "audio/opus");
  12521. if (n > -1 && c > -1 && n > c) {
  12522. const o = s[c];
  12523. s[c] = s[n], s[n] = o;
  12524. }
  12525. }
  12526. this.rts.setSenderCodecPreferences({
  12527. audio: s
  12528. }), this.rts.setReceiverCodecPreferences({
  12529. audio: s
  12530. });
  12531. }
  12532. } catch (i) {
  12533. }
  12534. this.audioRedEnabled = e;
  12535. }
  12536. }
  12537. clear() {
  12538. this.setConnected(!1);
  12539. try {
  12540. this.rts.unpublish();
  12541. } catch (e) {
  12542. }
  12543. this.rts = le.createClient(), this.addRTSListener();
  12544. }
  12545. startConnect() {
  12546. this.connecting = !0, this.connectingPromise = new Promise((e) => {
  12547. this.connectionResolve = e;
  12548. }), this.dcConnectingPromise = new Promise((e, t) => {
  12549. this.dcResolve = e, this.dcReject = t;
  12550. });
  12551. }
  12552. setConnected(e) {
  12553. var t;
  12554. this.connected = e, this.connecting = !1, this._rtsReconnecting = !1, (t = this.connectionResolve) == null || t.call(this, !0);
  12555. }
  12556. get isConnecting() {
  12557. return this.connecting;
  12558. }
  12559. get isConnected() {
  12560. return this.connected;
  12561. }
  12562. get publishingTracks() {
  12563. return this._publishingTracks;
  12564. }
  12565. getPubMsid(e, t) {
  12566. const { aMsid: i, vMsid: s } = t != null ? t : {}, n = {};
  12567. return e.hasAudio && (n.aMsid = [i != null ? i : T.Audio]), e.hasScreen && (n.vMsid = [T.Screen]), e.hasVideo && (n.vMsid = [s != null ? s : t != null && t.isScreen ? T.Screen : T.VideoLarge]), n;
  12568. }
  12569. updatePublishingTracks(e) {
  12570. e && (this._publishingTracks = e.map(({ msid: t, from: i, ssrc: s, codec: n, type: c, trackId: o }) => ({
  12571. msid: t,
  12572. from: i,
  12573. type: c,
  12574. ssrc: `${s}`,
  12575. codec: n != null ? n : "",
  12576. trackId: o
  12577. })));
  12578. }
  12579. httpPublish(n, c) {
  12580. return w(this, arguments, function* (e, t, i = !1, s = nt.MANUAL) {
  12581. var b, E;
  12582. let o;
  12583. const u = Date.now(), { publishStream: h, videoSmallStream: p, screenStream: d, vMsid: f } = yield this.localStreamManager.createHTTPPublishStream();
  12584. if (!h)
  12585. return O.warn(`[${Ae.logName}]`, "publishStream is null"), {
  12586. traceId: "",
  12587. l1ip: o
  12588. };
  12589. const m = this.getPubMsid(h, {
  12590. vMsid: f
  12591. });
  12592. this.encodedInsertableStreams && (m.encodedInsertableStreams = !0), m.answerSdpHook = (_) => {
  12593. const y = /\d+\.\d+\.\d+\.\d+(?=\s+1106|\s+8000)/.exec(_);
  12594. return y != null && y[0] && (o = y[0]), _;
  12595. }, (E = (b = this.parameter) == null ? void 0 : b.net) != null && E.useTCP && (m.tcpOnly = !0), m.retryTimes = Ga, m.retryInterval = Xa, this._rtsPeerConnectionType = "publish";
  12596. let l = !h.hasVideo, S = f, v = "";
  12597. this.startConnect();
  12598. const x = Date.now();
  12599. try {
  12600. v = yield this.rts.publish($a(e), h, m);
  12601. } catch (_) {
  12602. this.setConnected(!1);
  12603. const y = 2e3 - (Date.now() - x);
  12604. throw y <= 0 ? this.emit("disconnected") : setTimeout(() => {
  12605. this.emit("disconnected");
  12606. }, y), this.slsReporter.reportPublish(
  12607. i,
  12608. e,
  12609. t,
  12610. h.hasVideo && (!f || f === T.VideoLarge),
  12611. h.hasVideo && f === T.VideoSmall,
  12612. h.hasVideo && f === T.Screen,
  12613. h.hasAudio,
  12614. (_ == null ? void 0 : _.errorCode) || -1,
  12615. this.pcTraceId,
  12616. "",
  12617. x
  12618. ), V.fromRtsError(_);
  12619. }
  12620. O.event(`[${Ae.logName}]`, "rts publish success", v), this.slsReporter.reportPublish(
  12621. i,
  12622. e,
  12623. t,
  12624. h.hasVideo && (!f || f === T.VideoLarge),
  12625. h.hasVideo && f === T.VideoSmall,
  12626. h.hasVideo && f === T.Screen,
  12627. h.hasAudio,
  12628. 0,
  12629. v,
  12630. v,
  12631. x
  12632. ), this.slsReporter.reportConnectionLatencyEvent(
  12633. Je.HANDLE_PUB_TASK,
  12634. Xe.START,
  12635. t,
  12636. v,
  12637. u
  12638. ), this.slsReporter.reportConnectionLatencyEvent(
  12639. Je.HANDLE_PUB_TASK,
  12640. Xe.END,
  12641. t,
  12642. v,
  12643. Date.now()
  12644. );
  12645. try {
  12646. const _ = Date.now();
  12647. return this._pcTraceId = v, this.setConnected(!0), this._publishingTracks = this.rts.getPublishTrackInfoList(), p && (yield this.publishAdd(
  12648. e,
  12649. p,
  12650. t,
  12651. {
  12652. vMsid: T.VideoSmall
  12653. },
  12654. i
  12655. ), l = !1, S = T.VideoSmall), d && (yield this.publishAdd(
  12656. e,
  12657. d,
  12658. t,
  12659. {
  12660. vMsid: T.Screen
  12661. },
  12662. i
  12663. ), l = !1, S = T.Screen), yield this.waitPublishSender(e, l, S), this.slsReporter.reportPublishFirstPacket(
  12664. i,
  12665. t,
  12666. x,
  12667. _,
  12668. this._localJoinTime,
  12669. l ? T.Audio : m.vMsid,
  12670. v || "",
  12671. v || "",
  12672. s
  12673. ), {
  12674. traceId: v,
  12675. l1ip: o
  12676. };
  12677. } catch (_) {
  12678. throw this.setConnected(!1), V.fromError(_);
  12679. }
  12680. });
  12681. }
  12682. waitPublishSender(e, t = !1, i) {
  12683. return w(this, null, function* () {
  12684. const s = (n, c) => {
  12685. let o = 0;
  12686. const u = () => (t ? this.rts.getPublishAudioStats(e, i) : this.rts.getPublishVideoStats(e, i)).then((p) => !(p.bytesSent > 0) && o < n ? (o++, new Promise((f) => setTimeout(() => f(u()), c))) : Promise.resolve());
  12687. return u();
  12688. };
  12689. return Promise.race([Et(1e3), s(5, 100)]).catch(() => {
  12690. });
  12691. });
  12692. }
  12693. getPublishVideoStats(e, t) {
  12694. return w(this, null, function* () {
  12695. return yield this.rts.getPublishVideoStats(e, t);
  12696. });
  12697. }
  12698. getPublishAudioStats(e, t) {
  12699. return w(this, null, function* () {
  12700. return yield this.rts.getPublishAudioStats(e, t);
  12701. });
  12702. }
  12703. publishAdd(u, h, p, d) {
  12704. return w(this, arguments, function* (e, t, i, s, n = !1, c = !1, o = nt.MANUAL) {
  12705. var l, S, v, x, b, E, _, y;
  12706. yield this.dcConnectingPromise;
  12707. const f = Date.now(), m = this.getPubMsid(t, s);
  12708. try {
  12709. const A = yield Wa(
  12710. (R) => w(this, null, function* () {
  12711. return R > 0 && O.event(`[${Ae.logName}]`, `publishAdd retry times: ${R}`), this.isConnected ? (yield this.dcConnectingPromise, this.rts.publishAdd([
  12712. J({
  12713. url: e,
  12714. stream: t,
  12715. updateSourceStream: !1
  12716. }, m)
  12717. ])) : Promise.reject(new V(U.ERR_INNER, "rts not connected"));
  12718. }),
  12719. Ja,
  12720. 0,
  12721. (R) => (R == null ? void 0 : R.errorCode) === 15006
  12722. );
  12723. if (A) {
  12724. const R = Date.now(), [M] = A;
  12725. return this.slsReporter.reportPublish(
  12726. !1,
  12727. e,
  12728. i,
  12729. ((l = m.vMsid) == null ? void 0 : l[0]) === T.VideoLarge,
  12730. ((S = m.vMsid) == null ? void 0 : S[0]) === T.VideoSmall,
  12731. ((v = m.vMsid) == null ? void 0 : v[0]) === T.Screen,
  12732. ((x = m.aMsid) == null ? void 0 : x[0]) === T.Audio,
  12733. 0,
  12734. this.pcTraceId,
  12735. M.traceId || "",
  12736. f
  12737. ), this.updatePublishingTracks(M.trackInfoList), c && (yield this.waitPublishSender(e, !t.hasVideo, t.hasVideo ? s == null ? void 0 : s.vMsid : s == null ? void 0 : s.aMsid)), this.slsReporter.reportPublishFirstPacket(
  12738. n,
  12739. i,
  12740. f,
  12741. R,
  12742. this._localJoinTime,
  12743. (t.hasVideo ? s == null ? void 0 : s.vMsid : s == null ? void 0 : s.aMsid) || "",
  12744. this.pcTraceId,
  12745. M.traceId || "",
  12746. o
  12747. ), M.traceId || "";
  12748. }
  12749. } catch (A) {
  12750. throw this.slsReporter.reportPublish(
  12751. !1,
  12752. e,
  12753. i,
  12754. ((b = m.vMsid) == null ? void 0 : b[0]) === T.VideoLarge,
  12755. ((E = m.vMsid) == null ? void 0 : E[0]) === T.VideoSmall,
  12756. ((_ = m.vMsid) == null ? void 0 : _[0]) === T.Screen,
  12757. ((y = m.aMsid) == null ? void 0 : y[0]) === T.Audio,
  12758. (A == null ? void 0 : A.errorCode) || -1,
  12759. this.pcTraceId,
  12760. "",
  12761. f
  12762. ), A != null && A.errorCode ? V.fromRtsError(A) : V.fromError(A);
  12763. }
  12764. return "";
  12765. });
  12766. }
  12767. publishDelete(e, t) {
  12768. return w(this, null, function* () {
  12769. var u, h, p, d, f, m, l, S;
  12770. yield this.dcConnectingPromise;
  12771. const i = (h = (u = this.publishingTracks) == null ? void 0 : u.find(({ msid: v }) => v === T.Audio)) == null ? void 0 : h.msid, s = (d = (p = this.publishingTracks) == null ? void 0 : p.find(({ msid: v }) => v === T.VideoLarge)) == null ? void 0 : d.msid, n = (m = (f = this.publishingTracks) == null ? void 0 : f.find(({ msid: v }) => v === T.Screen)) == null ? void 0 : m.msid, c = [];
  12772. t.screen && n ? c.push(n) : t.video && c.push(t.vMsid || s);
  12773. const o = [];
  12774. t.audio && i && o.push(i), O.event(Ae.logName, "publishDelete", { streamUrl: e, aMsid: o, vMsid: c });
  12775. try {
  12776. const [v] = (yield this.rts.publishDeleteTracks([
  12777. {
  12778. url: e,
  12779. aMsid: o,
  12780. vMsid: c
  12781. }
  12782. ])) || [];
  12783. return O.event(Ae.logName, "publishDelete", { result: v }), v && this.updatePublishingTracks(v.trackInfoList), ((S = (l = v == null ? void 0 : v.trackInfoList) == null ? void 0 : l[0]) == null ? void 0 : S.trackId) || "";
  12784. } catch (v) {
  12785. throw V.fromRtsError(v);
  12786. }
  12787. });
  12788. }
  12789. publishReplace(e, t, i) {
  12790. return w(this, null, function* () {
  12791. var c, o;
  12792. yield this.dcConnectingPromise;
  12793. const { vMsid: s, aMsid: n } = i != null ? i : {};
  12794. try {
  12795. const u = yield this.rts.publishReplaceTracks([
  12796. {
  12797. url: e,
  12798. stream: t,
  12799. vMsid: s,
  12800. aMsid: n
  12801. }
  12802. ]), [h] = u;
  12803. return this.updatePublishingTracks(h.trackInfoList), ((o = (c = h == null ? void 0 : h.trackInfoList) == null ? void 0 : c[0]) == null ? void 0 : o.trackId) || "";
  12804. } catch (u) {
  12805. throw V.fromRtsError(u);
  12806. }
  12807. });
  12808. }
  12809. publishStop(e) {
  12810. return w(this, null, function* () {
  12811. return yield this.rts.publishStop([
  12812. {
  12813. url: e
  12814. }
  12815. ]), this._publishingTracks = [], "";
  12816. });
  12817. }
  12818. publishAddDataChannel(e) {
  12819. return w(this, null, function* () {
  12820. yield this.dcConnectingPromise;
  12821. const t = yield this.rts.publishAddDatachannel({
  12822. signalUrl: e,
  12823. url: e,
  12824. label: T.Data,
  12825. msid: T.Data
  12826. }), i = t == null ? void 0 : t.datachannel;
  12827. if (i && i.send) {
  12828. const s = new ArrayBuffer(4);
  12829. new DataView(s).setUint8(0, 240), i.datachannel.send(s);
  12830. }
  12831. return i;
  12832. });
  12833. }
  12834. publishStopDataChannel(e, t) {
  12835. return w(this, null, function* () {
  12836. return yield this.rts.publishStopDatachannel({
  12837. url: e,
  12838. datachannel: t
  12839. });
  12840. });
  12841. }
  12842. unpublish() {
  12843. return w(this, null, function* () {
  12844. yield this.rts.unpublish(), this.connecting = !1, this.connected = !1;
  12845. });
  12846. }
  12847. /**
  12848. * 获取 sub/subAdd config
  12849. * @param {ISubscribeConfig | ISubConfigItem} options
  12850. * @returns {Omit<ISignalConfig | ISubConfigItem, 'url'>}
  12851. */
  12852. getSubConfig(e, t) {
  12853. let i = t != null ? t : {};
  12854. t || (i = {
  12855. audio: !0,
  12856. video: !0,
  12857. screen: !0
  12858. });
  12859. const s = {};
  12860. return i.audio && (s.aMsid = [(e == null ? void 0 : e.getAudioInfo().msid) || T.Audio]), i.video ? i.vMsid ? s.vMsid = [i.vMsid] : e != null && e.hasVideoLarge ? s.vMsid = [(e == null ? void 0 : e.getVideoLargeInfo().msid) || T.VideoLarge] : e != null && e.hasVideoSmall ? s.vMsid = [(e == null ? void 0 : e.getVideoSmallInfo().msid) || T.VideoSmall] : s.vMsid = [T.VideoLarge] : i.screen && (s.vMsid = [(e == null ? void 0 : e.getScreenInfo().msid) || T.Screen]), s;
  12861. }
  12862. httpSubscribe(e) {
  12863. return w(this, null, function* () {
  12864. var c, o, u, h, p, d;
  12865. const { remoteUser: t, options: i } = e;
  12866. let s = t.streamUrl;
  12867. i.video || i.screen ? i != null && i.audio || (s += "@subaudio=no") : s += "@subvideo=no";
  12868. const n = this.getSubConfig(t.streamInfo, i);
  12869. if (this.encodedInsertableStreams && (n.encodedInsertableStreams = !0), (o = (c = this.parameter) == null ? void 0 : c.net) != null && o.useTCP && (n.tcpOnly = !0), (h = (u = this.parameter) == null ? void 0 : u.net) != null && h.mediaTimeout) {
  12870. const f = (d = (p = this.parameter) == null ? void 0 : p.net) == null ? void 0 : d.mediaTimeout;
  12871. f > 1e3 && f < 1e5 && (n.mediaTimeout = f);
  12872. }
  12873. n.retryTimes = Ga, n.retryInterval = Xa, this._rtsPeerConnectionType = "subscribe";
  12874. try {
  12875. this.startConnect();
  12876. const f = yield this.rts.subscribe($a(s), n);
  12877. return this._pcTraceId = f.traceId, this.setConnected(!0), {
  12878. traceId: f.traceId,
  12879. stream: f
  12880. };
  12881. } catch (f) {
  12882. throw this.setConnected(!1), this.emit("disconnected"), V.fromRtsError(f);
  12883. }
  12884. });
  12885. }
  12886. subscribeAdd(e) {
  12887. return w(this, null, function* () {
  12888. var n, c, o, u;
  12889. const { remoteUser: t, options: i } = e, s = ut(J({
  12890. url: t.streamUrl,
  12891. subAudio: !!i.audio,
  12892. subVideo: !!(i.screen || i.video)
  12893. }, this.getSubConfig(t.streamInfo, i)), {
  12894. targetStream: i.screen ? t.getScreenStream : t.getCameraStream
  12895. });
  12896. yield this.dcConnectingPromise;
  12897. try {
  12898. return (yield Wa(
  12899. (p) => w(this, null, function* () {
  12900. return yield this.dcConnectingPromise, p > 0 && O.event(`[${Ae.logName}]`, `subscribeAdd retry times: ${p}`), this.isConnected ? this.rts.subscribeAdd([s]) : Promise.reject();
  12901. }),
  12902. Ja,
  12903. 0,
  12904. // 仅超时重试
  12905. (p) => (p == null ? void 0 : p.errorCode) === 15006
  12906. ))[0];
  12907. } catch (h) {
  12908. if (((u = (o = (c = (n = h == null ? void 0 : h.extraInfo) == null ? void 0 : n.parsedData) == null ? void 0 : c.streams) == null ? void 0 : o[0]) == null ? void 0 : u.res_code) === 508)
  12909. return this.emit("subscribeexceeds"), null;
  12910. throw V.fromRtsError(h);
  12911. }
  12912. });
  12913. }
  12914. subscribeDelete(e) {
  12915. return w(this, null, function* () {
  12916. var n, c, o, u;
  12917. const { remoteUser: t, options: i } = e, s = ut(J({
  12918. url: t.streamUrl,
  12919. subAudio: !!i.audio,
  12920. subVideo: !!(i.screen || i.video)
  12921. }, this.getSubConfig(t.streamInfo, i)), {
  12922. targetStream: i.screen ? t.getScreenStream : t.getCameraStream
  12923. });
  12924. yield this.dcConnectingPromise;
  12925. try {
  12926. return (yield this.rts.subscribeDeleteTracks([s]))[0];
  12927. } catch (h) {
  12928. if (((u = (o = (c = (n = h == null ? void 0 : h.extraInfo) == null ? void 0 : n.parsedData) == null ? void 0 : c.streams) == null ? void 0 : o[0]) == null ? void 0 : u.res_code) === 404)
  12929. return;
  12930. throw V.fromRtsError(h);
  12931. }
  12932. });
  12933. }
  12934. subscibeStop(e) {
  12935. return w(this, null, function* () {
  12936. var t, i, s, n;
  12937. try {
  12938. yield this.rts.subscribeStop([
  12939. {
  12940. url: e
  12941. }
  12942. ]);
  12943. } catch (c) {
  12944. if (((n = (s = (i = (t = c == null ? void 0 : c.extraInfo) == null ? void 0 : t.parsedData) == null ? void 0 : i.streams) == null ? void 0 : s[0]) == null ? void 0 : n.res_code) === 404)
  12945. return;
  12946. throw V.fromRtsError(c);
  12947. }
  12948. });
  12949. }
  12950. subscribeAddDataChannel(e) {
  12951. return w(this, null, function* () {
  12952. yield this.dcConnectingPromise;
  12953. const t = yield this.rts.subscribeAddDatachannel({
  12954. signalUrl: e,
  12955. url: e,
  12956. label: T.Data,
  12957. msid: T.Data
  12958. }), i = t == null ? void 0 : t.datachannel;
  12959. if (i && i.send) {
  12960. const s = new ArrayBuffer(4);
  12961. new DataView(s).setUint8(0, 240), i.send(s);
  12962. }
  12963. return i;
  12964. });
  12965. }
  12966. subscribeStopDatachannel(e, t) {
  12967. return w(this, null, function* () {
  12968. let i;
  12969. try {
  12970. i = yield this.rts.subscribeStopDatachannel({
  12971. url: e,
  12972. datachannel: t
  12973. });
  12974. } catch (s) {
  12975. }
  12976. return t == null || t.dispose(), i;
  12977. });
  12978. }
  12979. publish(n, c) {
  12980. return w(this, arguments, function* (e, t, i = !1, s = nt.MANUAL) {
  12981. let o = "", u;
  12982. if (this.connecting && (yield this.connectingPromise), this.connected) {
  12983. yield this.dcConnectingPromise;
  12984. let h = !1, p;
  12985. const { audio: d, video: f, videoSmall: m, screen: l } = this.localStreamManager.publishStreams;
  12986. d && (o = yield this.publishAdd(
  12987. e,
  12988. d,
  12989. t,
  12990. {
  12991. aMsid: T.Audio
  12992. },
  12993. i
  12994. ), h = !0, p = T.Audio, yield Et(100)), f && (o = yield this.publishAdd(
  12995. e,
  12996. f,
  12997. t,
  12998. {
  12999. vMsid: T.VideoLarge
  13000. },
  13001. i
  13002. ), h = !1, p = T.VideoLarge, yield Et(100)), m && (o = yield this.publishAdd(
  13003. e,
  13004. m,
  13005. t,
  13006. {
  13007. vMsid: T.VideoSmall
  13008. },
  13009. i
  13010. ), h = !1, p = T.VideoSmall, yield Et(100)), l && (o = yield this.publishAdd(
  13011. e,
  13012. l,
  13013. t,
  13014. {
  13015. isScreen: !0,
  13016. vMsid: T.Screen
  13017. },
  13018. i
  13019. ), h = !1, p = T.Screen), p && (yield this.waitPublishSender(e, h, p));
  13020. } else {
  13021. const h = yield this.httpPublish(e, t, i, s);
  13022. o = h.traceId, u = h.l1ip;
  13023. }
  13024. return {
  13025. traceId: o,
  13026. l1ip: u
  13027. };
  13028. });
  13029. }
  13030. reportSubscribeLatency(e, t, i, s) {
  13031. const n = [];
  13032. e.audio && n.push(e.aMsid || T.Audio), e.video ? n.push(e.vMsid || T.VideoLarge) : e.screen && n.push(T.Screen), n.forEach((c) => {
  13033. this.slsReporter.reportConnectionLatencyEvent(
  13034. Je.HANDLE_SUB_TASK,
  13035. Xe.START,
  13036. t,
  13037. c,
  13038. i,
  13039. 0,
  13040. s
  13041. ), this.slsReporter.reportConnectionLatencyEvent(
  13042. Je.HANDLE_SUB_TASK,
  13043. Xe.END,
  13044. t,
  13045. c,
  13046. Date.now(),
  13047. 0,
  13048. s
  13049. );
  13050. });
  13051. }
  13052. subscribe(e, t, i, s, n) {
  13053. return w(this, null, function* () {
  13054. let c = !1;
  13055. const { options: o, remoteUser: u } = e;
  13056. if (o.video && o.screen)
  13057. throw new V(
  13058. U.ERR_INNER,
  13059. "subscribe error, video and screen cannot be subscribed at the same time"
  13060. );
  13061. this.connecting && (yield this.connectingPromise);
  13062. let h, p = Date.now();
  13063. this.connected ? h = yield this.subscribeAdd(e) : (c = !0, h = yield this.httpSubscribe(e)), this.reportSubscribeLatency(o, i, p, c);
  13064. const d = Date.now();
  13065. let f = T.VideoLarge, m = o.video || o.screen, l = o.audio;
  13066. o.video && o.vMsid ? f = o.vMsid : o.screen && (f = T.Screen);
  13067. let S = 0, v = 0, x = 0;
  13068. const E = ((_, y) => {
  13069. let A = 0;
  13070. const R = () => {
  13071. let M;
  13072. return l && !S && (M = this.rts.getSubscribeAudioStats(u.streamUrl).then((C) => {
  13073. if (C.packetsReceived > 0)
  13074. S = Date.now();
  13075. else if (!m)
  13076. return A < _ ? (A++, new Promise((I) => setTimeout(() => I(R()), y))) : !1;
  13077. return !0;
  13078. })), m && !x && (M = this.rts.getSubscribeVideoStats(u.streamUrl, f).then((C) => {
  13079. if (C.packetsReceived > 0 && (v = Date.now()), C.framesDecoded > 0)
  13080. x = Date.now();
  13081. else
  13082. return A < _ ? (A++, new Promise((I) => setTimeout(() => I(R()), y))) : (O.event(`[${Ae.logName}]`, u.userId, "尝试获取首帧数据失败"), !1);
  13083. return !0;
  13084. })), Promise.resolve(M);
  13085. };
  13086. return R();
  13087. })(40, 100);
  13088. return E.then(() => {
  13089. v && this.slsReporter.reportSubscribeFirstPacket(
  13090. t === de.Resume,
  13091. i,
  13092. s,
  13093. f,
  13094. {
  13095. fprt: v - p,
  13096. ifsprtc: x ? x - p : 0,
  13097. ajsub: t === de.Join ? 1 : 0,
  13098. pctid: this.pcTraceId,
  13099. subtid: (h == null ? void 0 : h.traceId) || "",
  13100. sstc: d - p
  13101. }
  13102. ), x && this.slsReporter.reportSubscribeFirstFrame(
  13103. t === de.Resume,
  13104. i,
  13105. s,
  13106. f,
  13107. {
  13108. fvfrt: x - p,
  13109. fp2fftc: x - v,
  13110. ajsub: t === de.Join ? 1 : 0,
  13111. tffrtc: t === de.Join ? x - this.localJoinTime : x - n,
  13112. pctid: this.pcTraceId,
  13113. subtid: (h == null ? void 0 : h.traceId) || "",
  13114. fvfdtc: x - p
  13115. }
  13116. ), S && (this.slsReporter.reportConnectionLatencyEvent(
  13117. Je.FIRST_REMOTE,
  13118. Xe.DECODED,
  13119. i,
  13120. T.Audio,
  13121. S
  13122. ), this.slsReporter.reportSubscribeFirstPacket(
  13123. t === de.Resume,
  13124. i,
  13125. s,
  13126. T.Audio,
  13127. {
  13128. fprt: S - p,
  13129. ifsprtc: S - p,
  13130. ajsub: t === de.Join ? 1 : 0,
  13131. pctid: this.pcTraceId,
  13132. subtid: (h == null ? void 0 : h.traceId) || "",
  13133. sstc: d - p
  13134. }
  13135. ));
  13136. }), c && (yield Promise.race([E, Et(1500)])), h;
  13137. });
  13138. }
  13139. getSubscribeVideoStats(e, t) {
  13140. return w(this, null, function* () {
  13141. return yield this.rts.getSubscribeVideoStats(e, t);
  13142. });
  13143. }
  13144. getSubscribeAudioStats(e, t) {
  13145. return w(this, null, function* () {
  13146. return yield this.rts.getSubscribeAudioStats(e, t);
  13147. });
  13148. }
  13149. getStreamByMsid(e) {
  13150. return this.rts.commonController.streamManager.getStreamByMsid(e);
  13151. }
  13152. getDatachannelByMsid(e) {
  13153. return this.rts.commonController.streamManager.getDatachannelByMsid(e);
  13154. }
  13155. getPCStats() {
  13156. return w(this, null, function* () {
  13157. var e, t;
  13158. return (t = (e = this.rts.commonController.peerCore) == null ? void 0 : e.pc) == null ? void 0 : t.getStats();
  13159. });
  13160. }
  13161. sendSEI(e, t, i, s) {
  13162. return w(this, null, function* () {
  13163. return this.rts.sendSEI({
  13164. url: e,
  13165. vMsid: T.VideoLarge,
  13166. data: t,
  13167. repeatCount: i,
  13168. payloadType: s
  13169. });
  13170. });
  13171. }
  13172. }, /**
  13173. * @ignore
  13174. */
  13175. g(Ae, "logName", "RtsManager"), Ae);
  13176. Ee([
  13177. D(H)
  13178. ], Se.prototype, "startConnect", 1);
  13179. Ee([
  13180. D()
  13181. ], Se.prototype, "updatePublishingTracks", 1);
  13182. Ee([
  13183. D(H, H)
  13184. ], Se.prototype, "httpPublish", 1);
  13185. Ee([
  13186. D(H, H)
  13187. ], Se.prototype, "waitPublishSender", 1);
  13188. Ee([
  13189. D(([r, a, e]) => [r, JSON.stringify(e)], H)
  13190. ], Se.prototype, "publishAdd", 1);
  13191. Ee([
  13192. D(H, H)
  13193. ], Se.prototype, "publishDelete", 1);
  13194. Ee([
  13195. D(([r, a, e]) => [r, JSON.stringify(e)])
  13196. ], Se.prototype, "publishReplace", 1);
  13197. Ee([
  13198. D(H)
  13199. ], Se.prototype, "publishStop", 1);
  13200. Ee([
  13201. D(H)
  13202. ], Se.prototype, "publishAddDataChannel", 1);
  13203. Ee([
  13204. D(H)
  13205. ], Se.prototype, "publishStopDataChannel", 1);
  13206. Ee([
  13207. D()
  13208. ], Se.prototype, "unpublish", 1);
  13209. Ee([
  13210. D(Pi, ({ traceId: r }) => r)
  13211. ], Se.prototype, "httpSubscribe", 1);
  13212. Ee([
  13213. D(Pi, ({ traceId: r }) => r)
  13214. ], Se.prototype, "subscribeAdd", 1);
  13215. Ee([
  13216. D(Pi)
  13217. ], Se.prototype, "subscribeDelete", 1);
  13218. Ee([
  13219. D(H)
  13220. ], Se.prototype, "subscibeStop", 1);
  13221. Ee([
  13222. D(H)
  13223. ], Se.prototype, "subscribeAddDataChannel", 1);
  13224. Ee([
  13225. D(H)
  13226. ], Se.prototype, "subscribeStopDatachannel", 1);
  13227. Ee([
  13228. D(H)
  13229. ], Se.prototype, "publish", 1);
  13230. Ee([
  13231. D(Pi)
  13232. ], Se.prototype, "subscribe", 1);
  13233. Ee([
  13234. D()
  13235. ], Se.prototype, "sendSEI", 1);
  13236. let bc = Se;
  13237. class Nr {
  13238. constructor(a = Hr) {
  13239. g(this, "defaultProfile");
  13240. g(this, "profile");
  13241. g(this, "profileMap", /* @__PURE__ */ new Map());
  13242. g(this, "audioProfile");
  13243. g(this, "contentHint");
  13244. this.defaultProfile = J({}, a);
  13245. }
  13246. updateProfile(a, e) {
  13247. this.profileMap.set(a, J(J(J({}, this.defaultProfile), this.profileMap.get(a) || {}), e || {})), this.profile = a;
  13248. }
  13249. get videoProfile() {
  13250. return this.profile;
  13251. }
  13252. updateAudioProfile(a) {
  13253. this.audioProfile = a;
  13254. }
  13255. setContentHint(a, e) {
  13256. e && (this.contentHint = e), this.contentHint && a && (a.contentHint = this.contentHint);
  13257. }
  13258. /**
  13259. * 更新源流 Constraints
  13260. * 更新 PeerConnectiong Sender 相关配置
  13261. * @param stream
  13262. */
  13263. setVideoProfile(a, e, t = !1) {
  13264. return w(this, null, function* () {
  13265. if (!this.profile)
  13266. return;
  13267. const i = this.profileMap.get(this.profile) || (e == null ? void 0 : e.VideoProfileMap.get(this.profile));
  13268. if (i) {
  13269. if (!t && a && // iOS 上如果 track 状态为 ended,applyConstraints 会无返回
  13270. a.readyState === "live" && // @ts-ignore
  13271. a.applyConstraints)
  13272. try {
  13273. yield a.applyConstraints(i);
  13274. } catch (s) {
  13275. }
  13276. if (e) {
  13277. const s = J({}, i);
  13278. i.maxSendFrameRate && (s.frameRate = i.maxSendFrameRate), e == null || e.VideoProfileMap.set(this.profile, s), yield e.setVideoProfile(this.profile);
  13279. }
  13280. }
  13281. });
  13282. }
  13283. }
  13284. class Ya extends De {
  13285. constructor(e) {
  13286. super();
  13287. g(this, "type");
  13288. // 源视频流
  13289. g(this, "originVideoTrack");
  13290. g(this, "videoSource");
  13291. g(this, "_videoMuted", !1);
  13292. // 源音频流
  13293. g(this, "originAudioTrack");
  13294. g(this, "audioSource");
  13295. g(this, "_audioMuted", !1);
  13296. // 目标音频流,用于流处理
  13297. g(this, "_targetVideoTrack");
  13298. // 小流
  13299. g(this, "_targetDualVideoTrack");
  13300. // 目标音频流,用于推流
  13301. g(this, "_targetAudioTrack");
  13302. // 目标视频流,用于推流
  13303. g(this, "_publishVideoStream");
  13304. // 目标辅流,用于推流
  13305. g(this, "_publishDualVideoStream");
  13306. // 目标音频流,用于推流
  13307. g(this, "_publishAudioStream");
  13308. // 用来预览
  13309. g(this, "_previewStream");
  13310. g(this, "plugins", []);
  13311. // 管理 Profile 相关配置
  13312. g(this, "_profileManager");
  13313. g(this, "cameraVideoConstraints");
  13314. g(this, "micAudioConstraints");
  13315. g(this, "onVideoTrackEnded", () => {
  13316. this.emit("videotrackended");
  13317. });
  13318. g(this, "onAudioTrackEnded", () => {
  13319. this.emit("audiotrackended");
  13320. });
  13321. this.type = e;
  13322. }
  13323. get profileManager() {
  13324. return this._profileManager;
  13325. }
  13326. get audioProfile() {
  13327. var e;
  13328. return (e = this.profileManager) == null ? void 0 : e.audioProfile;
  13329. }
  13330. updateSource(e, t, i) {
  13331. return w(this, null, function* () {
  13332. var c, o, u, h, p, d;
  13333. const { videoTrack: s, audioTrack: n } = e;
  13334. s && ((c = this.originVideoTrack) == null || c.removeEventListener("ended", this.onVideoTrackEnded)), n && ((o = this.originAudioTrack) == null || o.removeEventListener("ended", this.onAudioTrackEnded)), this.type === be.AliRtcSdkStreamTypeScreen ? this.stop() : (s && ((u = this.originVideoTrack) == null || u.stop()), n && ((h = this.originAudioTrack) == null || h.stop())), s && (this.originVideoTrack = s, (p = this.originVideoTrack) == null || p.addEventListener("ended", this.onVideoTrackEnded), this.videoSource = t || Jt.Camera, this.updateVideoTrack(s)), n && (this.originAudioTrack = n, (d = this.originAudioTrack) == null || d.addEventListener("ended", this.onAudioTrackEnded), this.audioSource = i || xi.Microphone, this.updateAudioTrack(n));
  13335. });
  13336. }
  13337. get currentProfile() {
  13338. var e;
  13339. return (e = this.profileManager) == null ? void 0 : e.profile;
  13340. }
  13341. get currentVideoTrack() {
  13342. return this._targetVideoTrack;
  13343. }
  13344. get currentDualVideoTrack() {
  13345. return this._targetDualVideoTrack;
  13346. }
  13347. get publishVideoStream() {
  13348. return this._publishVideoStream;
  13349. }
  13350. get publishDualVideoStream() {
  13351. return this._publishDualVideoStream;
  13352. }
  13353. get currentAudioTrack() {
  13354. return this._targetAudioTrack;
  13355. }
  13356. get publishAudioStream() {
  13357. return this._publishAudioStream;
  13358. }
  13359. get previewStream() {
  13360. return this._previewStream;
  13361. }
  13362. /**
  13363. * 更新 VideoTrack
  13364. * @param videoTrack
  13365. */
  13366. updateVideoTrack(e, t = !1) {
  13367. return w(this, null, function* () {
  13368. (this._targetVideoTrack !== e || t) && (this._targetVideoTrack = e);
  13369. });
  13370. }
  13371. /**
  13372. * 更新 DualVideoTrack
  13373. * @param videoTrack
  13374. * @param force
  13375. */
  13376. updateDualVideoTrack(e, t = !1) {
  13377. return w(this, null, function* () {
  13378. (this._targetDualVideoTrack !== e || t) && (this._targetDualVideoTrack = e);
  13379. });
  13380. }
  13381. /**
  13382. * 更新 AudioTrack
  13383. * @param audioTrack
  13384. */
  13385. updateAudioTrack(e, t = !1) {
  13386. return w(this, null, function* () {
  13387. (this._targetAudioTrack !== e || t) && (this._targetAudioTrack = e);
  13388. });
  13389. }
  13390. /**
  13391. * 设置音频流静音
  13392. * @param muted
  13393. */
  13394. setAudioMuted(e) {
  13395. var t, i;
  13396. this._audioMuted = e, e ? (t = this.publishAudioStream) == null || t.disableAudio() : (i = this.publishAudioStream) == null || i.enableAudio();
  13397. }
  13398. get isAudioMuted() {
  13399. return this._audioMuted;
  13400. }
  13401. /**
  13402. * 设置视频流静音
  13403. * @param muted
  13404. */
  13405. setVideoMuted(e) {
  13406. var t, i;
  13407. this._videoMuted = e, e ? (t = this.publishVideoStream) == null || t.disableVideo() : (i = this.publishVideoStream) == null || i.enableVideo();
  13408. }
  13409. get isVideoMuted() {
  13410. return this._videoMuted;
  13411. }
  13412. process(e) {
  13413. return w(this, null, function* () {
  13414. var t, i, s, n, c, o, u, h, p, d, f, m;
  13415. this._targetAudioTrack = this.originAudioTrack, this._targetVideoTrack = this.originVideoTrack;
  13416. for (const l of this.plugins)
  13417. try {
  13418. yield l.execute(this, e);
  13419. } catch (S) {
  13420. console.error(`error in plugin-${l.name}, error: ${S}`);
  13421. }
  13422. this._targetVideoTrack ? ((i = (t = this._publishVideoStream) == null ? void 0 : t.videoTrack) == null ? void 0 : i.id) !== this._targetVideoTrack.id && (this._publishVideoStream = yield ei(this._targetVideoTrack), this.setVideoMuted(this._videoMuted), (s = this.profileManager) == null || s.setVideoProfile(this.originVideoTrack, this._publishVideoStream, !0), (n = this.profileManager) == null || n.setContentHint(this._targetVideoTrack), this.previewStream ? (c = this.previewStream) == null || c.mergeStream(this._publishVideoStream) : this._previewStream = yield ei(this._targetVideoTrack)) : (this._publishVideoStream = void 0, (o = this.previewStream) == null || o.deleteTracks({ video: !0 })), this._targetDualVideoTrack ? ((h = (u = this._publishDualVideoStream) == null ? void 0 : u.videoTrack) == null ? void 0 : h.id) !== this._targetDualVideoTrack.id && (this._publishDualVideoStream = yield ei(this._targetDualVideoTrack), this._videoMuted ? this._publishDualVideoStream.disableVideo() : this._publishDualVideoStream.enableVideo()) : this._publishDualVideoStream = void 0, this._targetAudioTrack ? ((d = (p = this._publishAudioStream) == null ? void 0 : p.audioTrack) == null ? void 0 : d.id) !== this._targetAudioTrack.id && (this._publishAudioStream = yield ei(this._targetAudioTrack), this.setAudioMuted(this._audioMuted), this.previewStream ? (f = this.previewStream) == null || f.mergeStream(this._publishAudioStream) : this._previewStream = yield ei(this._targetAudioTrack)) : (this._publishAudioStream = void 0, (m = this.previewStream) == null || m.deleteTracks({ audio: !0 }));
  13423. });
  13424. }
  13425. /**
  13426. * 停止视频流
  13427. */
  13428. stopVideo() {
  13429. var e, t;
  13430. this.originVideoTrack && ((e = this.originVideoTrack) == null || e.removeEventListener("ended", this.onAudioTrackEnded), (t = this.originVideoTrack) == null || t.stop(), this.originVideoTrack = void 0), this.updateVideoTrack(void 0);
  13431. }
  13432. /**
  13433. * 停止音频流
  13434. */
  13435. stopAudio() {
  13436. var e, t;
  13437. this.originAudioTrack && ((e = this.originAudioTrack) == null || e.removeEventListener("ended", this.onAudioTrackEnded), (t = this.originAudioTrack) == null || t.stop(), this.originAudioTrack = void 0), this.updateAudioTrack(void 0);
  13438. }
  13439. /**
  13440. * 停止视频流和音频流
  13441. */
  13442. stop() {
  13443. this.stopVideo(), this.stopAudio();
  13444. }
  13445. /**
  13446. * 应该在执行完 plugin 后调用
  13447. * @param profileName
  13448. * @param profileValue
  13449. */
  13450. updateVideoProfile(e, t, i = !1) {
  13451. return w(this, null, function* () {
  13452. this._profileManager || (this._profileManager = new Nr(
  13453. this.type === be.AliRtcSdkStreamTypeScreen ? ja : Hr
  13454. )), e && this._profileManager.updateProfile(e, t), yield this._profileManager.setVideoProfile(
  13455. this.originVideoTrack,
  13456. this._publishVideoStream,
  13457. i || this.type === be.AliRtcSdkStreamTypeScreen
  13458. );
  13459. });
  13460. }
  13461. get videoProfile() {
  13462. var e;
  13463. return (e = this.profileManager) == null ? void 0 : e.videoProfile;
  13464. }
  13465. setVideoContentHint(e) {
  13466. this._profileManager || (this._profileManager = new Nr(
  13467. this.type === be.AliRtcSdkStreamTypeScreen ? ja : Hr
  13468. )), this._profileManager.setContentHint(this.currentVideoTrack, e);
  13469. }
  13470. /**
  13471. * 应该在执行完 plugin 后调用
  13472. * @param profileName
  13473. */
  13474. updateAudioProfile(e) {
  13475. return w(this, null, function* () {
  13476. this._profileManager || (this._profileManager = new Nr()), this._profileManager.updateAudioProfile(e);
  13477. });
  13478. }
  13479. /**
  13480. * 复制视频 profile 到指定 LocalStream
  13481. * @param publishStream
  13482. */
  13483. cloneVideoProfile(e) {
  13484. return w(this, null, function* () {
  13485. var t;
  13486. yield (t = this.profileManager) == null ? void 0 : t.setVideoProfile(void 0, e);
  13487. });
  13488. }
  13489. // 添加 plugin
  13490. addPlugin(e) {
  13491. const t = this.plugins.findIndex((i) => i.zIndex > e.zIndex);
  13492. t > -1 ? this.plugins.splice(t, 0, e) : this.plugins.push(e);
  13493. }
  13494. // 移除 plugin
  13495. removePlugin(e) {
  13496. const t = this.plugins.indexOf(e);
  13497. return t > -1 ? (e.clear(this), this.plugins.splice(t, 1), !0) : !1;
  13498. }
  13499. }
  13500. var Ec = Object.defineProperty, _c = Object.getOwnPropertyDescriptor, st = (r, a, e, t) => {
  13501. for (var i = t > 1 ? void 0 : t ? _c(a, e) : a, s = r.length - 1, n; s >= 0; s--)
  13502. (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i);
  13503. return t && i && Ec(a, e, i), i;
  13504. }, At;
  13505. const Ze = (At = class extends De {
  13506. // 设置是否发布屏幕流
  13507. constructor(e, t) {
  13508. super();
  13509. g(this, "pluginManager");
  13510. g(this, "slsReporter");
  13511. // 当前正在推流的流,只有在使用 HTTP 推流的时候才有值,用于设置 peerconnection 的参数
  13512. g(this, "publishingCameraVideoStream");
  13513. g(this, "publishingScreenVideoStream");
  13514. g(this, "cameraStreamInfo", new Ya(be.AliRtcSdkStreamTypeCapture));
  13515. g(this, "screenStreamInfo", new Ya(be.AliRtcSdkStreamTypeScreen));
  13516. g(this, "streamInfos", [this.cameraStreamInfo, this.screenStreamInfo]);
  13517. g(this, "_audioCaptureDisabled", !1);
  13518. // 离会再入会,若不另外设置,则保持音频采集关闭
  13519. g(this, "_cameraCaptureDisabled", !1);
  13520. // 相机采集关闭,离会再入会则重置
  13521. g(this, "_publishLocalAudioStreamEnabled", !0);
  13522. // 设置是否发布音频流
  13523. g(this, "_publishLocalVideoStreamEnabled", !0);
  13524. // 设置是否发布视频流
  13525. g(this, "_publishLocalScreenStreamEnabled", !0);
  13526. this.screenStreamInfo.setVideoContentHint("motion"), this.pluginManager = e, this.slsReporter = t;
  13527. const i = (s) => w(this, null, function* () {
  13528. if (O.info(`[${At.logName}]`, "plugin added", s.name), !s.isSupported("6.14.6")) {
  13529. console.warn(`${s.name} is not supported!!!`), s.emit("unsupported");
  13530. return;
  13531. }
  13532. try {
  13533. yield s.init();
  13534. } catch (n) {
  13535. s.emit("error", V.fromError(n, _t.AliRtcPluginErrorInitError));
  13536. }
  13537. s.streamType === be.AliRtcSdkStreamTypeCapture && (this.cameraStreamInfo.addPlugin(s), yield this.cameraStreamInfo.process(this.streamInfos)), s.streamType === be.AliRtcSdkStreamTypeScreen && (this.screenStreamInfo.addPlugin(s), yield this.screenStreamInfo.process(this.streamInfos)), this.emit("publishupdate");
  13538. });
  13539. this.cameraStreamInfo.on("videotrackended", () => w(this, null, function* () {
  13540. yield this.stopLocalStream({
  13541. video: !0
  13542. }), this.emit("trackended", Vt.VideoTrackEnded);
  13543. })), this.cameraStreamInfo.on("audiotrackended", () => w(this, null, function* () {
  13544. yield this.stopLocalStream({
  13545. audio: !0
  13546. }), this.emit("trackended", Vt.AudioTrackEnded);
  13547. })), this.screenStreamInfo.on("videotrackended", () => w(this, null, function* () {
  13548. yield this.stopLocalStream({
  13549. screen: !0
  13550. }), this.emit("trackended", Vt.ScreenTrackEnded);
  13551. })), this.pluginManager.on("added", i), this.pluginManager.on("removed", (s) => w(this, null, function* () {
  13552. this.cameraStreamInfo.removePlugin(s) && (yield this.cameraStreamInfo.process(this.streamInfos)), this.screenStreamInfo.removePlugin(s) && (yield this.screenStreamInfo.process(this.streamInfos)), this.emit("publishupdate");
  13553. })), this.pluginManager.on("updated", () => w(this, null, function* () {
  13554. yield this.updateStreams();
  13555. }));
  13556. }
  13557. get hasCamera() {
  13558. return !!this.cameraStreamInfo.originVideoTrack;
  13559. }
  13560. get audioCaptureDisabled() {
  13561. return this._audioCaptureDisabled;
  13562. }
  13563. set audioCaptureDisabled(e) {
  13564. this._audioCaptureDisabled = e;
  13565. }
  13566. get cameraCaptureDisabled() {
  13567. return this._cameraCaptureDisabled;
  13568. }
  13569. set cameraCaptureDisabled(e) {
  13570. this._cameraCaptureDisabled = e;
  13571. }
  13572. setAudioMuted(e) {
  13573. this.cameraStreamInfo.setAudioMuted(e);
  13574. }
  13575. get isAudioMuted() {
  13576. return this.cameraStreamInfo.isAudioMuted;
  13577. }
  13578. setCameraMuted(e) {
  13579. this.cameraStreamInfo.setVideoMuted(e);
  13580. }
  13581. get isCameraMuted() {
  13582. return this.cameraStreamInfo.isVideoMuted;
  13583. }
  13584. setScreenMuted(e) {
  13585. this.screenStreamInfo.setVideoMuted(e);
  13586. }
  13587. get isScreenMuted() {
  13588. return this.screenStreamInfo.isVideoMuted;
  13589. }
  13590. get publishLocalAudioStreamEnabled() {
  13591. return this._publishLocalAudioStreamEnabled;
  13592. }
  13593. set publishLocalAudioStreamEnabled(e) {
  13594. this._publishLocalAudioStreamEnabled = e;
  13595. }
  13596. get publishLocalVideoStreamEnabled() {
  13597. return this._publishLocalVideoStreamEnabled;
  13598. }
  13599. set publishLocalVideoStreamEnabled(e) {
  13600. this._publishLocalVideoStreamEnabled = e;
  13601. }
  13602. get publishLocalScreenStreamEnabled() {
  13603. return this._publishLocalScreenStreamEnabled;
  13604. }
  13605. set publishLocalScreenStreamEnabled(e) {
  13606. this._publishLocalScreenStreamEnabled = e;
  13607. }
  13608. updateStreams() {
  13609. return w(this, null, function* () {
  13610. yield this.cameraStreamInfo.process(this.streamInfos), yield this.screenStreamInfo.process(this.streamInfos), this.emit("publishupdate");
  13611. });
  13612. }
  13613. // 设置有效的 camera deviceId
  13614. setAvailableCameraDeviceId() {
  13615. return w(this, null, function* () {
  13616. var e, t, i, s;
  13617. if ((e = this.cameraStreamInfo.cameraVideoConstraints) != null && e.deviceId) {
  13618. let n = (t = this.cameraStreamInfo.cameraVideoConstraints) == null ? void 0 : t.deviceId;
  13619. const c = yield le.getCameraList();
  13620. c.find((o) => o.deviceId === n) || (n = (s = (i = c.find((o) => !!o.deviceId)) == null ? void 0 : i.deviceId) != null ? s : ""), this.cameraStreamInfo.cameraVideoConstraints.deviceId = n;
  13621. }
  13622. });
  13623. }
  13624. // 设置有效的 microphone deviceId
  13625. setAvailableMicrophoneDeviceId() {
  13626. return w(this, null, function* () {
  13627. var e, t, i, s;
  13628. if ((e = this.cameraStreamInfo.micAudioConstraints) != null && e.deviceId) {
  13629. let n = (t = this.cameraStreamInfo.micAudioConstraints) == null ? void 0 : t.deviceId;
  13630. const c = yield le.getMicList();
  13631. c.find((o) => o.deviceId === n) || (n = (s = (i = c.find((o) => !!o.deviceId)) == null ? void 0 : i.deviceId) != null ? s : ""), this.cameraStreamInfo.micAudioConstraints.deviceId = n;
  13632. }
  13633. });
  13634. }
  13635. createLocalStream(e) {
  13636. return w(this, null, function* () {
  13637. var p;
  13638. const { screen: t, mediaStream: i, videoProfile: s, screenProfile: n } = e;
  13639. let { video: c, audio: o } = e;
  13640. const u = rc(e);
  13641. let h;
  13642. if (u) {
  13643. i || (c === !0 && this.cameraStreamInfo.cameraVideoConstraints ? (yield this.setAvailableCameraDeviceId(), c = J({}, this.cameraStreamInfo.cameraVideoConstraints)) : typeof c == "object" && (yield this.setAvailableCameraDeviceId(), c = J(J({}, c), this.cameraStreamInfo.cameraVideoConstraints)), o === void 0 && this.audioCaptureDisabled ? o = !1 : o && (o === !0 && this.cameraStreamInfo.micAudioConstraints ? (yield this.setAvailableMicrophoneDeviceId(), o = J({}, this.cameraStreamInfo.micAudioConstraints)) : typeof o == "object" && (yield this.setAvailableMicrophoneDeviceId(), o = J(J({}, o), this.cameraStreamInfo.micAudioConstraints)), this._audioCaptureDisabled = !1));
  13644. const d = Date.now();
  13645. try {
  13646. h = yield le.createStream({
  13647. audio: o,
  13648. video: c,
  13649. screen: t,
  13650. custom: !!i,
  13651. mediaStream: i,
  13652. skipProfile: !0
  13653. }), O.info(`[${At.logName}]`, "createLocalStream", {
  13654. audio: o,
  13655. video: c,
  13656. screen: t,
  13657. custom: !!i,
  13658. time: Date.now() - d
  13659. }), o && !i && this.slsReporter.reportAudio(null, Date.now() - d, ((p = h == null ? void 0 : h.audioTrack) == null ? void 0 : p.label) || ""), t && !i && this.slsReporter.reportScreen(null, Date.now() - d);
  13660. } catch (f) {
  13661. throw o && !i && this.slsReporter.reportAudio(f, Date.now() - d, ""), t && !i && this.slsReporter.reportScreen(null, Date.now() - d), f;
  13662. }
  13663. if (t)
  13664. yield this.screenStreamInfo.updateSource(h, Jt.Screen, xi.Screen), yield this.setScreenProfile(n || An), this.setScreenContentHint(), this.publishingScreenVideoStream = void 0;
  13665. else if (yield this.cameraStreamInfo.updateSource(h, Jt.Camera, xi.Microphone), h.hasVideo && (yield this.setVideoProfile(s || _n), this.setVideoContentHint(), this.publishingCameraVideoStream = void 0), h.hasAudio && typeof o == "boolean") {
  13666. const f = this.cameraStreamInfo.audioProfile;
  13667. f && (yield h.setAudioProfile(f));
  13668. }
  13669. }
  13670. return le.SystenUtil.isIos && le.SystenUtil.compareVersion("15.1") && !le.SystenUtil.compareVersion("15.2") && (yield Et(1e3)), yield this.updateStreams(), h;
  13671. });
  13672. }
  13673. stopLocalStream(e) {
  13674. return w(this, null, function* () {
  13675. const { screen: t, video: i, audio: s } = e != null ? e : {};
  13676. let n = !1;
  13677. i && this.cameraStreamInfo.originVideoTrack && (n = !0, this.cameraStreamInfo.stopVideo(), this.publishingCameraVideoStream = void 0), s && this.cameraStreamInfo.originAudioTrack && (n = !0, this.cameraStreamInfo.stopAudio()), t && this.screenStreamInfo.originVideoTrack && (n = !0, this.screenStreamInfo.stop(), this.publishingScreenVideoStream = void 0, this.slsReporter.reportScreenStop(null)), n && (yield this.updateStreams());
  13678. });
  13679. }
  13680. get publishStreams() {
  13681. const {
  13682. publishLocalVideoStreamEnabled: e,
  13683. publishLocalAudioStreamEnabled: t,
  13684. publishLocalScreenStreamEnabled: i
  13685. } = this;
  13686. return {
  13687. video: e ? this.cameraStreamInfo.publishVideoStream : void 0,
  13688. videoSmall: e ? this.cameraStreamInfo.publishDualVideoStream : void 0,
  13689. audio: t ? this.cameraStreamInfo.publishAudioStream : void 0,
  13690. screen: i ? this.screenStreamInfo.publishVideoStream : void 0
  13691. };
  13692. }
  13693. createHTTPPublishStream() {
  13694. return w(this, null, function* () {
  13695. var o, u, h, p;
  13696. let e, t = !1, i, s, n;
  13697. const c = this.publishStreams;
  13698. try {
  13699. if (!c.audio && !c.video && !c.videoSmall && !c.screen)
  13700. throw O.error(`[${At.logName}]`, "no tracks founded"), new V(U.ERR_SDK_PUBLISH_INVAILD, "no tracks founded");
  13701. const d = new MediaStream();
  13702. (o = c.audio) != null && o.audioTrack && d.addTrack(c.audio.audioTrack), (u = c.video) != null && u.videoTrack ? (d.addTrack(c.video.videoTrack), s = c.videoSmall, n = c.screen) : (h = c.screen) != null && h.videoTrack && (i = T.Screen, d.addTrack((p = c.screen) == null ? void 0 : p.videoTrack), t = !0), e = yield Rn(d), t ? (this.screenStreamInfo.cloneVideoProfile(e), this.publishingScreenVideoStream = e) : (this.cameraStreamInfo.cloneVideoProfile(e), this.publishingCameraVideoStream = e);
  13703. } catch (d) {
  13704. }
  13705. return { publishStream: e, videoSmallStream: s, screenStream: n, vMsid: i };
  13706. });
  13707. }
  13708. stop() {
  13709. this.cameraStreamInfo.stop(), this.screenStreamInfo.stop(), this.updateStreams();
  13710. }
  13711. setVideoProfile(e, t, i = !1) {
  13712. return w(this, null, function* () {
  13713. yield this.cameraStreamInfo.updateVideoProfile(e, t, i), this.publishingCameraVideoStream && this.cameraStreamInfo.cloneVideoProfile(this.publishingCameraVideoStream);
  13714. });
  13715. }
  13716. setVideoContentHint(e) {
  13717. this.cameraStreamInfo.setVideoContentHint(e);
  13718. }
  13719. setAudioProfile(e) {
  13720. return w(this, null, function* () {
  13721. var t;
  13722. yield this.cameraStreamInfo.updateAudioProfile(e), yield (t = this.publishingCameraVideoStream) == null ? void 0 : t.setAudioProfile(e);
  13723. });
  13724. }
  13725. setScreenProfile(e, t) {
  13726. return w(this, null, function* () {
  13727. yield this.screenStreamInfo.updateVideoProfile(e, t), this.publishingScreenVideoStream && this.screenStreamInfo.cloneVideoProfile(this.publishingScreenVideoStream);
  13728. });
  13729. }
  13730. setScreenContentHint(e) {
  13731. this.screenStreamInfo.setVideoContentHint(e);
  13732. }
  13733. setCameraVideoConstraints(e) {
  13734. var t;
  13735. this.cameraStreamInfo.cameraVideoConstraints = J(J({}, (t = this.cameraStreamInfo.cameraVideoConstraints) != null ? t : {}), e);
  13736. }
  13737. setMicAudioConstraints(e) {
  13738. var t;
  13739. this.cameraStreamInfo.micAudioConstraints = J(J({}, (t = this.cameraStreamInfo.micAudioConstraints) != null ? t : {}), e);
  13740. }
  13741. }, /**
  13742. * @ignore
  13743. */
  13744. g(At, "logName", "LocalStreamManager"), At);
  13745. st([
  13746. D(([r]) => {
  13747. const { audio: a, video: e, screen: t, custom: i, skipProfile: s, videoProfile: n, screenProfile: c } = r;
  13748. return [
  13749. {
  13750. audio: a,
  13751. video: e,
  13752. screen: t,
  13753. custom: i,
  13754. skipProfile: s,
  13755. videoProfile: n,
  13756. screenProfile: c
  13757. }
  13758. ];
  13759. })
  13760. ], Ze.prototype, "createLocalStream", 1);
  13761. st([
  13762. D(H)
  13763. ], Ze.prototype, "stopLocalStream", 1);
  13764. st([
  13765. D()
  13766. ], Ze.prototype, "createHTTPPublishStream", 1);
  13767. st([
  13768. D()
  13769. ], Ze.prototype, "stop", 1);
  13770. st([
  13771. D(H)
  13772. ], Ze.prototype, "setVideoProfile", 1);
  13773. st([
  13774. D(H)
  13775. ], Ze.prototype, "setVideoContentHint", 1);
  13776. st([
  13777. D(H)
  13778. ], Ze.prototype, "setAudioProfile", 1);
  13779. st([
  13780. D(H)
  13781. ], Ze.prototype, "setScreenProfile", 1);
  13782. st([
  13783. D(H)
  13784. ], Ze.prototype, "setScreenContentHint", 1);
  13785. st([
  13786. D(H)
  13787. ], Ze.prototype, "setCameraVideoConstraints", 1);
  13788. st([
  13789. D(H)
  13790. ], Ze.prototype, "setMicAudioConstraints", 1);
  13791. let Ac = Ze;
  13792. class yc extends Gt {
  13793. constructor() {
  13794. super("AliRtcScreenStandardize", be.AliRtcSdkStreamTypeScreen);
  13795. g(this, "canvas");
  13796. g(this, "lastWidth");
  13797. g(this, "lastHeight");
  13798. g(this, "hasScreenTrack", !1);
  13799. }
  13800. get initOptions() {
  13801. return {
  13802. base: 4
  13803. };
  13804. }
  13805. setOptions(e) {
  13806. this.options = e;
  13807. }
  13808. isSupported() {
  13809. return !(typeof TransformStream == "undefined" || typeof MediaStreamTrackProcessor == "undefined" || typeof MediaStreamTrackGenerator == "undefined");
  13810. }
  13811. updateProcessCanvas(e, t) {
  13812. if (this.canvas && this.lastWidth === e && this.lastHeight === t)
  13813. return;
  13814. const i = Math.ceil(e / this.options.base) * this.options.base, s = Math.ceil(t / this.options.base) * this.options.base;
  13815. if (this.canvas || (this.canvas = document.createElement("canvas")), this.canvas.width = i, this.canvas.height = s, this.lastWidth && e > this.lastWidth || this.lastHeight && t > this.lastHeight) {
  13816. const n = this.canvas.getContext("2d");
  13817. n && n.clearRect(0, 0, i, s);
  13818. }
  13819. this.lastWidth = e, this.lastHeight = t;
  13820. }
  13821. shouldUpdate(e) {
  13822. return this.hasScreenTrack !== (!!e.originVideoTrack && e.videoSource === Jt.Screen);
  13823. }
  13824. handleFrame(e, t) {
  13825. return w(this, null, function* () {
  13826. var c;
  13827. const { displayWidth: i, displayHeight: s } = e;
  13828. if (!i || !s || i % this.options.base === 0 && s % this.options.base === 0)
  13829. return this.clear(t), e;
  13830. this.updateProcessCanvas(i, s);
  13831. const n = (c = this.canvas) == null ? void 0 : c.getContext("2d");
  13832. if (this.canvas && n) {
  13833. n.drawImage(e, 0, 0, i, s);
  13834. const o = new VideoFrame(this.canvas, {
  13835. timestamp: e.timestamp
  13836. });
  13837. return e.close(), o;
  13838. }
  13839. return e;
  13840. });
  13841. }
  13842. process(e) {
  13843. return w(this, null, function* () {
  13844. var h;
  13845. if (!e.originVideoTrack || e.videoSource !== Jt.Screen) {
  13846. this.clear(e), this.hasScreenTrack = !1;
  13847. return;
  13848. }
  13849. const t = new MediaStreamTrackProcessor({ track: e.originVideoTrack }), i = new MediaStreamTrackGenerator({ kind: "video" }), s = new MediaStream([i]), n = this, c = new TransformStream({
  13850. transform(p, d) {
  13851. return w(this, null, function* () {
  13852. const f = yield n.handleFrame(p, e);
  13853. yield d.enqueue(f), f == null || f.close();
  13854. });
  13855. }
  13856. });
  13857. t.readable.pipeThrough(c).pipeTo(i.writable);
  13858. const o = (h = s.getVideoTracks()) == null ? void 0 : h[0];
  13859. e.updateVideoTrack(o), this.hasScreenTrack = !0;
  13860. });
  13861. }
  13862. clear(e) {
  13863. this.canvas = void 0, this.lastWidth = void 0, this.lastHeight = void 0, super.clear(e);
  13864. }
  13865. }
  13866. class Cc extends Gt {
  13867. constructor() {
  13868. super("blankAudio", be.AliRtcSdkStreamTypeCapture, Ri.BOTH);
  13869. g(this, "hasTrack", !1);
  13870. g(this, "oscillator", null);
  13871. g(this, "audioTrack", null);
  13872. g(this, "createAudioTrack", () => {
  13873. const e = new AudioContext();
  13874. this.oscillator = e.createOscillator();
  13875. const t = e.createGain();
  13876. t.gain.value = 0;
  13877. const i = e.createMediaStreamDestination();
  13878. this.oscillator.connect(t), t.connect(i), this.oscillator.start();
  13879. const s = i.stream;
  13880. return this.audioTrack = s.getAudioTracks()[0], this.audioTrack;
  13881. });
  13882. this.zIndex = 9;
  13883. }
  13884. isSupported() {
  13885. return !0;
  13886. }
  13887. setOptions() {
  13888. throw new Error("Method not implemented.");
  13889. }
  13890. shouldUpdate(e, t) {
  13891. return this.hasTrack !== t.some((i) => i.originVideoTrack || i.originAudioTrack);
  13892. }
  13893. process(e, t) {
  13894. return w(this, null, function* () {
  13895. var s;
  13896. const i = t.some((n) => n.originVideoTrack || n.originAudioTrack);
  13897. this.hasTrack = i, i ? this.audioTrack && ((s = this.oscillator) == null || s.stop(), this.oscillator = null, this.audioTrack.stop(), this.audioTrack = null) : (this.audioTrack || (this.audioTrack = this.createAudioTrack()), e.updateAudioTrack(this.audioTrack));
  13898. });
  13899. }
  13900. }
  13901. class In {
  13902. constructor(a) {
  13903. g(this, "name", "COMMON");
  13904. this.name = a || this.name;
  13905. }
  13906. info(...a) {
  13907. }
  13908. warn(...a) {
  13909. }
  13910. print(a, ...e) {
  13911. const t = a.toLowerCase();
  13912. t && console[t](`[${a}][${this.name}]`, ...e);
  13913. }
  13914. }
  13915. g(In, "LEVEL", 0);
  13916. class Rc {
  13917. constructor() {
  13918. g(this, "logger", new In("AudioMixer"));
  13919. g(this, "audioContext", new AudioContext());
  13920. g(this, "audioDestination", this.audioContext.createMediaStreamDestination());
  13921. g(this, "audioTrack", X0(this.audioDestination.stream));
  13922. g(this, "sourceNodeMap", {});
  13923. }
  13924. get sourceNodeList() {
  13925. return Object.values(this.sourceNodeMap).map((a) => a.sourceNode).filter((a) => !!a);
  13926. }
  13927. get gainNodeList() {
  13928. return Object.values(this.sourceNodeMap).map((a) => a.gainNode).filter((a) => !!a);
  13929. }
  13930. get sourceCount() {
  13931. return this.sourceNodeList.length;
  13932. }
  13933. resume() {
  13934. var a;
  13935. return (a = this.audioContext) == null ? void 0 : a.resume();
  13936. }
  13937. addTrack(a) {
  13938. this.connectTrack(a);
  13939. }
  13940. hasTrack(a) {
  13941. return !!this.sourceNodeMap[a];
  13942. }
  13943. removeTrack(a) {
  13944. const { sourceNode: e, gainNode: t } = this.sourceNodeMap[a] || {};
  13945. t == null || t.disconnect(), e == null || e.disconnect(), delete this.sourceNodeMap[a], e ? this.logger.info("SourceNode disconnected. Active source node:", this.sourceNodeList.length) : this.logger.warn(`SourceNode ${a} does not exit. Active source node: ${this.sourceNodeList.length}`);
  13946. }
  13947. getAudioTrack() {
  13948. return this.audioTrack;
  13949. }
  13950. setVolume(a, e) {
  13951. const { gainNode: t } = this.sourceNodeMap[e] || {};
  13952. t ? (this.logger.info(`Setting node(${e}) volume to ${this.scale(a)}`), t.gain.value = this.scale(a)) : this.logger.warn(`GainNode ${e} does not exit.`);
  13953. }
  13954. reset() {
  13955. this.disconnectSourceNode(), this.sourceNodeMap = {};
  13956. }
  13957. dispose() {
  13958. var a;
  13959. this.reset(), (a = this.audioTrack) == null || a.stop(), this.audioDestination.disconnect(), this.audioContext.close();
  13960. }
  13961. /**
  13962. * sourceNode -> gainNode -> destionationNode
  13963. */
  13964. connectTrack(a) {
  13965. if (!this.audioContext)
  13966. return this.logger.warn("AudioContext not initialized");
  13967. let e = new MediaStream();
  13968. e.addTrack(a);
  13969. const t = this.audioContext.createMediaStreamSource(e), i = this.audioContext.createGain();
  13970. i.gain.value = 1, t.connect(i), i.connect(this.audioDestination), this.sourceNodeMap[a.id] = { track: a, sourceNode: t, gainNode: i }, this.logger.info("New sourceNode connected. Active source node:", this.sourceNodeList.length);
  13971. }
  13972. disconnectSourceNode() {
  13973. this.sourceNodeList.forEach((a) => a.disconnect()), this.gainNodeList.forEach((a) => a.disconnect());
  13974. }
  13975. /**
  13976. * volume [0-100]
  13977. * scale to [0-1]
  13978. */
  13979. scale(a) {
  13980. return a / 100;
  13981. }
  13982. }
  13983. const Ic = 4;
  13984. class wc extends Gt {
  13985. constructor() {
  13986. super("audioMixer", be.AliRtcSdkStreamTypeCapture, Ri.AUDIO);
  13987. g(this, "audioMixer");
  13988. g(this, "primaryAudioTrackId");
  13989. g(this, "screenAudioTrackId");
  13990. g(this, "dirty", !1);
  13991. this.zIndex = 8;
  13992. }
  13993. get initOptions() {
  13994. return {
  13995. audio: 1,
  13996. screen: 1
  13997. };
  13998. }
  13999. setOptions(e) {
  14000. Object.entries(e).forEach(([t, i]) => {
  14001. this.isValidVolume(i) && (this.options[t] = i);
  14002. }), this.dirty = !0, this.emit("updated");
  14003. }
  14004. isSupported() {
  14005. return "AudioContext" in window;
  14006. }
  14007. shouldUpdate(e, t) {
  14008. var n, c;
  14009. if (e.type !== be.AliRtcSdkStreamTypeCapture)
  14010. return !1;
  14011. const i = t.find(
  14012. (o) => o.type === be.AliRtcSdkStreamTypeCapture
  14013. ), s = t.find(
  14014. (o) => o.type === be.AliRtcSdkStreamTypeScreen
  14015. );
  14016. return !(this.primaryAudioTrackId === ((n = i == null ? void 0 : i.currentAudioTrack) == null ? void 0 : n.id) && this.screenAudioTrackId === ((c = s == null ? void 0 : s.currentAudioTrack) == null ? void 0 : c.id) && !this.dirty);
  14017. }
  14018. process(e, t) {
  14019. return w(this, null, function* () {
  14020. var c, o;
  14021. this.dirty = !1;
  14022. const i = t.find(
  14023. (u) => u.type === be.AliRtcSdkStreamTypeScreen
  14024. ), s = e.currentAudioTrack, n = i == null ? void 0 : i.currentAudioTrack;
  14025. if (!n && this.options.audio === 1) {
  14026. this.audioMixer && (this.audioMixer.dispose(), this.audioMixer = void 0), this.primaryAudioTrackId = s == null ? void 0 : s.id, e.updateAudioTrack(s);
  14027. return;
  14028. }
  14029. this.audioMixer || (this.audioMixer = new Rc()), yield this.audioMixer.resume(), this.primaryAudioTrackId && (s == null ? void 0 : s.id) !== this.primaryAudioTrackId && ((c = this.audioMixer) == null || c.removeTrack(this.primaryAudioTrackId)), s && !this.audioMixer.hasTrack(s == null ? void 0 : s.id) && this.audioMixer.addTrack(s), this.primaryAudioTrackId = s == null ? void 0 : s.id, this.screenAudioTrackId && (n == null ? void 0 : n.id) !== this.screenAudioTrackId && ((o = this.audioMixer) == null || o.removeTrack(this.screenAudioTrackId)), n && !this.audioMixer.hasTrack(n == null ? void 0 : n.id) && this.audioMixer.addTrack(n), this.screenAudioTrackId = n == null ? void 0 : n.id, this.updateVolume(), e.updateAudioTrack(this.audioMixer.getAudioTrack());
  14030. });
  14031. }
  14032. isValidVolume(e) {
  14033. return e !== void 0 && e >= 0 && e <= Ic;
  14034. }
  14035. updateVolume() {
  14036. this.audioMixer && (this.primaryAudioTrackId && this.audioMixer.setVolume(this.options.audio * 100, this.primaryAudioTrackId), this.screenAudioTrackId && this.audioMixer.setVolume(this.options.screen * 100, this.screenAudioTrackId));
  14037. }
  14038. clear(e) {
  14039. var t;
  14040. (t = this.audioMixer) == null || t.dispose(), super.clear(e);
  14041. }
  14042. }
  14043. class os {
  14044. constructor(a, e) {
  14045. g(this, "originTrack");
  14046. g(this, "originVideo");
  14047. g(this, "targetWidth");
  14048. g(this, "targetHeight");
  14049. g(this, "targetFrameRate");
  14050. g(this, "targetCanvas");
  14051. g(this, "animationFrameId");
  14052. g(this, "resultTrack");
  14053. this.targetWidth = e.width, this.targetHeight = e.height, this.targetFrameRate = e.frameRate, this.originTrack = a, this.originVideo = document.createElement("video"), this.originVideo.muted = !0, this.originVideo.autoplay = !0, this.originVideo.controls = !1, this.targetCanvas = document.createElement("canvas"), this.targetCanvas.width = this.targetWidth, this.targetCanvas.height = this.targetHeight;
  14054. }
  14055. updateOptions(a) {
  14056. this.targetWidth = a.width, this.targetHeight = a.height, this.targetFrameRate = a.frameRate, this.targetCanvas.width = this.targetWidth, this.targetCanvas.height = this.targetHeight, this.resultTrack && this.resultTrack.applyConstraints({ frameRate: this.targetFrameRate });
  14057. }
  14058. dispose() {
  14059. }
  14060. getVideoTrack() {
  14061. return this.resultTrack || (this.resultTrack = this.targetCanvas.captureStream().getVideoTracks()[0], this.resultTrack.applyConstraints({ frameRate: this.targetFrameRate })), this.resultTrack;
  14062. }
  14063. cancelAnimation() {
  14064. this.animationFrameId && (cancelAnimationFrame(this.animationFrameId), this.animationFrameId = void 0);
  14065. }
  14066. /**
  14067. * 当原始比例跟用户设置的目标分辨率不一致时需要裁切到目标分辨率
  14068. * 效果类似:object-fit: cover
  14069. */
  14070. getPositionAndSize(a, e, t, i) {
  14071. const s = e / a, n = i / t;
  14072. let c = t, o = i, u = 0, h = 0;
  14073. return n > s ? (c = Math.round(o / s), u = Math.round((t - c) / 2)) : n < s && (o = Math.round(c * s), h = Math.round((i - o) / 2)), { x: u, y: h, width: c, height: o };
  14074. }
  14075. }
  14076. class Dc extends os {
  14077. constructor(e, t) {
  14078. super(e, t);
  14079. g(this, "targetCtx");
  14080. this.targetCtx = this.targetCanvas.getContext("2d"), this.startRender = this.startRender.bind(this), this.stopRender = this.startRender.bind(this), this.initStream(e);
  14081. }
  14082. initStream(e) {
  14083. const t = new MediaStream();
  14084. t.addTrack(e), this.originVideo.srcObject = t, this.originVideo.play(), this.originVideo.addEventListener("canplay", this.startRender), this.originVideo.addEventListener("pause", this.stopRender), this.originVideo.addEventListener("ended", this.stopRender);
  14085. }
  14086. startRender() {
  14087. this.cancelAnimation();
  14088. const e = () => {
  14089. if (!this.targetCtx)
  14090. return;
  14091. const t = this.getPositionAndSize(
  14092. this.originVideo.videoWidth,
  14093. this.originVideo.videoHeight,
  14094. this.targetWidth,
  14095. this.targetHeight
  14096. );
  14097. this.targetCtx.drawImage(
  14098. this.originVideo,
  14099. 0,
  14100. 0,
  14101. this.originVideo.videoWidth,
  14102. this.originVideo.videoHeight,
  14103. t.x,
  14104. t.y,
  14105. t.width,
  14106. t.height
  14107. ), !this.originVideo.paused && !this.originVideo.ended && (this.animationFrameId = requestAnimationFrame(e));
  14108. };
  14109. e();
  14110. }
  14111. stopRender() {
  14112. this.cancelAnimation();
  14113. }
  14114. dispose() {
  14115. this.stopRender(), this.originVideo.removeEventListener("play", this.startRender), this.originVideo.removeEventListener("pause", this.stopRender), this.originVideo.removeEventListener("ended", this.stopRender), this.originVideo.pause(), this.originVideo.srcObject = null;
  14116. }
  14117. }
  14118. const Tc = `
  14119. attribute vec2 a_position;
  14120. attribute vec2 a_texCoord;
  14121. uniform vec2 u_resolution;
  14122. varying vec2 v_texCoord;
  14123. void main() {
  14124. // convert the rectangle from pixels to 0.0 to 1.0
  14125. vec2 zeroToOne = a_position / u_resolution;
  14126. // convert from 0->1 to 0->2
  14127. vec2 zeroToTwo = zeroToOne * 2.0;
  14128. // convert from 0->2 to -1->+1 (clipspace)
  14129. vec2 clipSpace = zeroToTwo - 1.0;
  14130. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1);
  14131. v_texCoord = a_texCoord;
  14132. }
  14133. `, Pc = `
  14134. precision mediump float;
  14135. varying lowp vec2 v_texCoord;
  14136. uniform sampler2D u_texture;
  14137. void main() {
  14138. gl_FragColor = texture2D(u_texture, v_texCoord);
  14139. }
  14140. `;
  14141. function kc() {
  14142. let r;
  14143. try {
  14144. const a = document.createElement("canvas");
  14145. a.width = 1, a.height = 1;
  14146. const e = {
  14147. alpha: !1,
  14148. depth: !1,
  14149. stencil: !1,
  14150. antialias: !1,
  14151. preferLowPowerToHighPerformance: !0
  14152. };
  14153. r = a.getContext("webgl2", e);
  14154. } catch (a) {
  14155. return !1;
  14156. }
  14157. return !!r;
  14158. }
  14159. function Bc(r) {
  14160. const a = r.createTexture();
  14161. return r.bindTexture(r.TEXTURE_2D, a), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_S, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_WRAP_T, r.CLAMP_TO_EDGE), r.texParameteri(r.TEXTURE_2D, r.TEXTURE_MIN_FILTER, r.LINEAR), a;
  14162. }
  14163. function Za(r, a, e) {
  14164. const t = r.createShader(a);
  14165. if (!t) {
  14166. console.error("create shader failed");
  14167. return;
  14168. }
  14169. return r.shaderSource(t, e), r.compileShader(t), r.getShaderParameter(t, r.COMPILE_STATUS) ? t : (console.error(`An error occurred compiling the shaders: ${r.getShaderInfoLog(t)}`), r.deleteShader(t), null);
  14170. }
  14171. function Nc(r, a, e) {
  14172. const t = Za(r, r.VERTEX_SHADER, a), i = Za(r, r.FRAGMENT_SHADER, e), s = r.createProgram();
  14173. if (!(!s || !t || !i))
  14174. return r.attachShader(s, t), r.attachShader(s, i), r.linkProgram(s), r.getProgramParameter(s, r.LINK_STATUS) ? s : (console.error(`Unable to initialize the shader program: ${r.getProgramInfoLog(s)}`), null);
  14175. }
  14176. function Mc(r, a, e, t = 0, i = 0) {
  14177. const s = r.createBuffer();
  14178. r.bindBuffer(r.ARRAY_BUFFER, s);
  14179. const n = t, c = i, o = a + t, u = e + i, h = [n, c, o, c, n, u, n, u, o, c, o, u];
  14180. return r.bufferData(r.ARRAY_BUFFER, new Float32Array(h), r.STATIC_DRAW), s;
  14181. }
  14182. class Qa extends os {
  14183. constructor(e, t) {
  14184. super(e, t);
  14185. g(this, "targetCtx");
  14186. g(this, "targetTexture");
  14187. g(this, "locationMap");
  14188. this.targetCtx = this.targetCanvas.getContext("webgl2"), this.locationMap = {}, this.startRender = this.startRender.bind(this), this.stopRender = this.startRender.bind(this), this.updateBuffer = this.updateBuffer.bind(this), this.initGL(), this.initStream(e);
  14189. }
  14190. static isSupport() {
  14191. return kc();
  14192. }
  14193. initGL() {
  14194. const e = this.targetCtx;
  14195. if (!e)
  14196. return;
  14197. this.targetTexture = Bc(e);
  14198. const t = Nc(e, Tc, Pc);
  14199. if (!t) {
  14200. console.log("[ScalerWebGL] program is null.");
  14201. return;
  14202. }
  14203. e.useProgram(t);
  14204. const i = e.getAttribLocation(t, "a_position"), s = e.getAttribLocation(t, "a_texCoord"), n = e.getUniformLocation(t, "u_resolution");
  14205. if (!n) {
  14206. console.log("[ScalerWebGL] resolutionLocation is null.");
  14207. return;
  14208. }
  14209. const c = e.getUniformLocation(t, "u_texture");
  14210. if (!c) {
  14211. console.log("[ScalerWebGL] textureLocation is null.");
  14212. return;
  14213. }
  14214. this.locationMap = {
  14215. program: t,
  14216. positionLocation: i,
  14217. texCoordLocation: s,
  14218. resolutionLocation: n,
  14219. textureLocation: c
  14220. }, this.updateBuffer();
  14221. }
  14222. initStream(e) {
  14223. const t = new MediaStream();
  14224. t.addTrack(e), this.originVideo.srcObject = t, this.originVideo.play(), this.originVideo.addEventListener("canplay", this.startRender), this.originVideo.addEventListener("pause", this.stopRender), this.originVideo.addEventListener("ended", this.stopRender), this.originVideo.addEventListener("resize", this.updateBuffer);
  14225. }
  14226. startRender() {
  14227. this.cancelAnimation();
  14228. const e = () => {
  14229. this.targetCtx && (this.renderTexture(), !this.originVideo.paused && !this.originVideo.ended && (this.animationFrameId = requestAnimationFrame(e)));
  14230. };
  14231. e();
  14232. }
  14233. updateBuffer() {
  14234. const e = this.targetCtx, t = this.locationMap.positionLocation, i = this.locationMap.texCoordLocation, s = this.locationMap.resolutionLocation;
  14235. if (!e || !this.originVideo.videoWidth || !this.originVideo.videoHeight)
  14236. return;
  14237. const n = this.getPositionAndSize(
  14238. this.originVideo.videoWidth,
  14239. this.originVideo.videoHeight,
  14240. this.targetWidth,
  14241. this.targetHeight
  14242. ), c = Mc(e, n.width, n.height, n.x, n.y);
  14243. e.enableVertexAttribArray(t), e.bindBuffer(e.ARRAY_BUFFER, c), e.vertexAttribPointer(t, 2, e.FLOAT, !1, 0, 0), e.enableVertexAttribArray(i);
  14244. const o = e.createBuffer();
  14245. e.bindBuffer(e.ARRAY_BUFFER, o), e.bufferData(
  14246. e.ARRAY_BUFFER,
  14247. new Float32Array([0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]),
  14248. e.STATIC_DRAW
  14249. ), e.bindBuffer(e.ARRAY_BUFFER, o), e.vertexAttribPointer(i, 2, e.FLOAT, !1, 0, 0), e.uniform2f(s, this.targetWidth, this.targetHeight);
  14250. }
  14251. renderTexture() {
  14252. const e = this.targetTexture, t = this.targetCtx, i = this.locationMap.textureLocation;
  14253. !e || !t || (t.bindTexture(t.TEXTURE_2D, e), t.texImage2D(t.TEXTURE_2D, 0, t.RGBA, t.RGBA, t.UNSIGNED_BYTE, this.originVideo), t.useProgram(this.locationMap.program), t.activeTexture(t.TEXTURE0), t.bindTexture(t.TEXTURE_2D, e), t.uniform1i(i, 0), t.viewport(0, 0, t.canvas.width, t.canvas.height), t.clearColor(0, 0, 0, 0), t.clear(t.COLOR_BUFFER_BIT), t.drawArrays(t.TRIANGLES, 0, 6));
  14254. }
  14255. stopRender() {
  14256. this.cancelAnimation();
  14257. }
  14258. updateOptions(e) {
  14259. super.updateOptions(e), this.updateBuffer();
  14260. }
  14261. dispose() {
  14262. this.stopRender(), this.originVideo.removeEventListener("play", this.startRender), this.originVideo.removeEventListener("pause", this.stopRender), this.originVideo.removeEventListener("ended", this.stopRender), this.originVideo.removeEventListener("resize", this.updateBuffer), this.originVideo.pause(), this.originVideo.srcObject = null;
  14263. }
  14264. }
  14265. const Lc = `
  14266. var targetOptions={
  14267. width: 320,
  14268. height: 180,
  14269. ratio: 0.5625,
  14270. interval: 66,
  14271. };
  14272. var timer;
  14273. var reader;
  14274. var writer;
  14275. function updateOptions(data) {
  14276. targetOptions.width=data.width||320;
  14277. targetOptions.height=data.height||180;
  14278. targetOptions.ratio=targetOptions.height/targetOptions.width;
  14279. targetOptions.interval=Math.floor(1000/data.frameRate)||66;
  14280. }
  14281. function postError(err, defaultMsg) {
  14282. var msg=err ? err.message : '';
  14283. postMessage({ type: 'error', messge: msg || defaultMsg });
  14284. }
  14285. function startLoop(data) {
  14286. if(timer){
  14287. clearInterval(timer);
  14288. }
  14289. timer=setInterval(() => {
  14290. reader.read().then(function (ret){
  14291. var videoFrame=ret.value;
  14292. if(ret.done || !videoFrame) {
  14293. return;
  14294. }
  14295. var vratio=videoFrame.displayHeight/videoFrame.displayWidth;
  14296. var vw=videoFrame.displayWidth;
  14297. var vh=videoFrame.displayHeight;
  14298. var vx=0;
  14299. var vy=0;
  14300. if(targetOptions.ratio>vratio){
  14301. vw=Math.round(vh/targetOptions.ratio);
  14302. vx=Math.round((videoFrame.displayWidth-vw)/2);
  14303. }else if(targetOptions.ratio<vratio){
  14304. vh=Math.round(vw*targetOptions.ratio);
  14305. vy=Math.round((videoFrame.displayHeight-vh)/2);
  14306. }
  14307. var newFrame=new VideoFrame(videoFrame,{
  14308. displayWidth:targetOptions.width,
  14309. displayHeight:targetOptions.height,
  14310. visibleRect:{
  14311. x:vx,
  14312. y:vy,
  14313. width:vw,
  14314. height:vh,
  14315. },
  14316. timestamp:videoFrame.timestamp,
  14317. });
  14318. writer.write(newFrame).catch(function (err){
  14319. postError(err, 'write error');
  14320. });
  14321. videoFrame.close();
  14322. }).catch(function (err){
  14323. postError(err, 'read error');
  14324. });
  14325. }, targetOptions.interval);
  14326. }
  14327. onmessage = function(evt) {
  14328. var data=evt.data;
  14329. switch (data.type) {
  14330. case 'startRender':
  14331. updateOptions(data);
  14332. reader=data.readable.getReader();
  14333. writer=data.writable.getWriter();
  14334. startLoop(data);
  14335. break;
  14336. case 'updateOptions':
  14337. updateOptions(data);
  14338. startLoop(data);
  14339. break;
  14340. default:
  14341. break;
  14342. }
  14343. }
  14344. `;
  14345. class en extends os {
  14346. constructor(e, t) {
  14347. super(e, t);
  14348. g(this, "processor");
  14349. g(this, "trackGenerator");
  14350. g(this, "worker");
  14351. this.processor = new MediaStreamTrackProcessor({ track: e }), this.trackGenerator = new MediaStreamTrackGenerator({ kind: "video" }), this.startTransform();
  14352. }
  14353. static isSupport() {
  14354. return "MediaStreamTrackProcessor" in window && "MediaStreamTrackGenerator" in window && "TransformStream" in window && "VideoFrame" in window;
  14355. }
  14356. startTransform() {
  14357. const e = new Blob([Lc], { type: "text/javascript" }), i = (window.URL || window.webkitURL).createObjectURL(e);
  14358. this.worker = new Worker(i);
  14359. const { readable: s } = this.processor, { writable: n } = this.trackGenerator;
  14360. this.worker.postMessage(
  14361. {
  14362. type: "startRender",
  14363. readable: s,
  14364. writable: n,
  14365. width: this.targetWidth,
  14366. height: this.targetHeight,
  14367. frameRate: this.targetFrameRate
  14368. },
  14369. [s, n]
  14370. );
  14371. }
  14372. updateOptions(e) {
  14373. super.updateOptions(e), this.worker && this.worker.postMessage(J({
  14374. type: "updateOptions"
  14375. }, e));
  14376. }
  14377. dispose() {
  14378. try {
  14379. this.processor.readable.cancel(), this.trackGenerator.writable.close();
  14380. } catch (e) {
  14381. }
  14382. }
  14383. getVideoTrack() {
  14384. return this.trackGenerator;
  14385. }
  14386. }
  14387. class zr {
  14388. static isSupport() {
  14389. return typeof HTMLCanvasElement.prototype.captureStream == "function";
  14390. }
  14391. /**
  14392. * 获取实例
  14393. * @param {MediaStreamTrack} videoTrack
  14394. * @param {IProfile} profile
  14395. * @return {VideoScaler}
  14396. */
  14397. static getInstance(a, e) {
  14398. return en.isSupport() ? new en(a, e) : Qa.isSupport() ? new Qa(a, e) : new Dc(a, e);
  14399. }
  14400. }
  14401. class Fc extends Gt {
  14402. constructor() {
  14403. super(...arguments);
  14404. g(this, "hasVideoTrack", !1);
  14405. g(this, "videoScaler");
  14406. }
  14407. get initOptions() {
  14408. return {
  14409. width: 320,
  14410. height: 180,
  14411. frameRate: 15
  14412. };
  14413. }
  14414. setOptions(e) {
  14415. var t;
  14416. this.options = e, (t = this.videoScaler) == null || t.updateOptions(e);
  14417. }
  14418. isSupported() {
  14419. return zr.isSupport();
  14420. }
  14421. shouldUpdate(e) {
  14422. return this.hasVideoTrack !== !!e.currentVideoTrack;
  14423. }
  14424. process(e) {
  14425. return w(this, null, function* () {
  14426. if (e.currentVideoTrack) {
  14427. if (this.hasVideoTrack = !0, !this.videoScaler) {
  14428. const i = this.options || this.initOptions;
  14429. this.videoScaler = zr.getInstance(e.currentVideoTrack, i);
  14430. }
  14431. const t = this.videoScaler.getVideoTrack();
  14432. t && e.updateDualVideoTrack(t);
  14433. } else
  14434. e.updateDualVideoTrack(), this.emit("updated"), this.videoScaler && this.videoScaler.dispose();
  14435. });
  14436. }
  14437. clear(e) {
  14438. super.clear(e), this.hasVideoTrack = !1, e == null || e.updateDualVideoTrack();
  14439. }
  14440. }
  14441. var Vc = Object.defineProperty, Oc = Object.getOwnPropertyDescriptor, je = (r, a, e, t) => {
  14442. for (var i = t > 1 ? void 0 : t ? Oc(a, e) : a, s = r.length - 1, n; s >= 0; s--)
  14443. (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i);
  14444. return t && i && Vc(a, e, i), i;
  14445. };
  14446. class Pe extends De {
  14447. constructor(e) {
  14448. super();
  14449. g(this, "self");
  14450. g(this, "userMap", {});
  14451. g(this, "usersViewMap", {});
  14452. g(this, "rtsManager");
  14453. g(this, "localStreamManager");
  14454. g(this, "authInfo");
  14455. g(this, "signalingManager");
  14456. g(this, "pluginManager");
  14457. g(this, "audioMixerPlugin");
  14458. g(this, "dualVideoPlugin");
  14459. g(this, "blankAudioPlugin");
  14460. g(this, "slsReporter");
  14461. g(this, "statsMonitorId");
  14462. g(this, "autoSubAudio", !0);
  14463. g(this, "autoSubVideo", !0);
  14464. g(this, "autoSubScreen", !0);
  14465. g(this, "wantSubAudio", !0);
  14466. g(this, "wantSubVideo", !0);
  14467. g(this, "wantSubScreen", !0);
  14468. g(this, "defaultStreamType", we.AliRtcVideoStreamTypeHigh);
  14469. g(this, "audioMuted", !1);
  14470. g(this, "playoutVolume", 1);
  14471. // 更新所有人推拉流地址的定时器
  14472. g(this, "refreshUrlTimer");
  14473. // 音量检测时间间隔
  14474. g(this, "audioVolumeIndicationInterval", 0);
  14475. g(this, "indicationTimer", 0);
  14476. g(this, "parameter", {});
  14477. const { signalingManager: t, slsReporter: i } = e;
  14478. this.signalingManager = t, this.addSignalingManagerListener(), this.slsReporter = i, this.pluginManager = new Sc(), this.localStreamManager = new Ac(this.pluginManager, this.slsReporter), this.rtsManager = new bc(this.localStreamManager, this.slsReporter, this.parameter), this.self = new tc({
  14479. rtsManager: this.rtsManager,
  14480. localStreamManager: this.localStreamManager,
  14481. slsReporter: this.slsReporter,
  14482. signalingManager: this.signalingManager,
  14483. pluginManager: this.pluginManager,
  14484. audioVolumeIndicationInterval: this.audioVolumeIndicationInterval,
  14485. parameter: this.parameter
  14486. }), this.audioMixerPlugin = new wc(), this.pluginManager.add(this.audioMixerPlugin), this.dualVideoPlugin = new Fc("dualVideoPlugin"), k0() && this.pluginManager.add(new yc());
  14487. }
  14488. addSignalingManagerListener() {
  14489. this.signalingManager.on("onNotifyPublish", (e) => {
  14490. e.forEach((t) => {
  14491. var i;
  14492. (i = t == null ? void 0 : t.tracks) == null || i.forEach((s) => {
  14493. var n;
  14494. if (s.msid === T.Audio && s.userdata)
  14495. try {
  14496. const c = JSON.parse(s.userdata);
  14497. c.agent_instance && ((n = this.slsReporter) == null || n.setCustomFields({ ageniid: c.agent_instance }));
  14498. } catch (c) {
  14499. console.error("Failed to parse userdata:", c);
  14500. }
  14501. });
  14502. }), this.slsReporter.reportConnectionLatencyEvent(Je.RECV_NOTIFY_PUBLISH, "", "", ""), O.event("[Signaling] Notify Publish ", e), e.forEach((t) => {
  14503. this.onRemotePublishStateChange(t);
  14504. });
  14505. }), this.signalingManager.stsManager.on("onTokenUpdate", (e, t) => {
  14506. this.slsReporter.updateToken(t, e);
  14507. });
  14508. }
  14509. isAutoSubAudio() {
  14510. return this.autoSubAudio;
  14511. }
  14512. setAutoSubAudio(e) {
  14513. this.autoSubAudio = e;
  14514. }
  14515. isAutoSubVideo() {
  14516. return this.autoSubVideo;
  14517. }
  14518. setAutoSubVideo(e) {
  14519. this.autoSubVideo = e;
  14520. }
  14521. isAutoSubScreen() {
  14522. return this.autoSubScreen;
  14523. }
  14524. setAutoSubScreen(e) {
  14525. this.autoSubScreen = e;
  14526. }
  14527. isWantSubAudio() {
  14528. return this.wantSubAudio;
  14529. }
  14530. setWantSubAudio(e) {
  14531. this.wantSubAudio = e, this.remoteUsers.forEach((t) => {
  14532. t.setWantSubAudio(e), t.updateSubscribe(de.User);
  14533. });
  14534. }
  14535. isWantSubVideo() {
  14536. return this.wantSubVideo;
  14537. }
  14538. setWantSubVideo(e) {
  14539. this.wantSubVideo = e, this.remoteUsers.forEach((t) => {
  14540. t.setWantSubVideo(e), t.updateSubscribe(de.User);
  14541. });
  14542. }
  14543. isWantSubScreen() {
  14544. return this.wantSubScreen;
  14545. }
  14546. setWantSubScreen(e) {
  14547. this.wantSubScreen = e, this.remoteUsers.forEach((t) => {
  14548. t.setWantSubScreen(e), t.updateSubscribe(de.User);
  14549. });
  14550. }
  14551. setRemoteDefaultVideoStreamType(e) {
  14552. this.defaultStreamType = e, this.remoteUsers.forEach((t) => {
  14553. t.setRemoteDefaultVideoStreamType(e);
  14554. });
  14555. }
  14556. setRemoteUserVideoStreamType(e, t) {
  14557. var i;
  14558. (i = this.getRemoteUser(e)) == null || i.setRemoteDefaultVideoStreamType(t);
  14559. }
  14560. setAudioMuted(e) {
  14561. this.audioMuted = e, this.remoteUsers.forEach((t) => {
  14562. t.setAudioMuted(e);
  14563. });
  14564. }
  14565. // 放置到这里是为了保证单个 view 只被一个地方引用
  14566. setLocalViewConfig(e, t) {
  14567. var s;
  14568. if (!e)
  14569. return (s = this.publisher) == null ? void 0 : s.setViewConfig(null, t);
  14570. const i = jr(e);
  14571. i.length !== 0 && i.forEach((n) => {
  14572. var c, o;
  14573. (c = this.publisher) == null || c.resetElement(n), Object.values(this.usersViewMap).forEach(({ cameraViews: u = [], screenViews: h = [] }) => {
  14574. u.includes(n) && u.splice(u.indexOf(n), 1), h.includes(n) && h.splice(h.indexOf(n), 1);
  14575. }), (o = this.publisher) == null || o.setViewConfig(i, t);
  14576. });
  14577. }
  14578. // 放置到这里是为了保证单个 view 只被一个地方引用
  14579. setRemoteViewConfig(e, t, i) {
  14580. var n, c;
  14581. if (!t)
  14582. return (n = this.userMap[e]) == null ? void 0 : n.setViewConfig(null, i);
  14583. const s = jr(t);
  14584. s.length !== 0 && (s.forEach((o) => {
  14585. var u;
  14586. (u = this.publisher) == null || u.resetElement(o), Object.values(this.usersViewMap).forEach(({ cameraViews: h = [], screenViews: p = [] }) => {
  14587. h.includes(o) && h.splice(h.indexOf(o), 1), p.includes(o) && p.splice(p.indexOf(o), 1);
  14588. });
  14589. }), (c = this.userMap[e]) == null || c.setViewConfig(s, i));
  14590. }
  14591. get channel() {
  14592. var e;
  14593. return (e = this.authInfo) == null ? void 0 : e.channelId;
  14594. }
  14595. get userId() {
  14596. var e;
  14597. return (e = this.authInfo) == null ? void 0 : e.userId;
  14598. }
  14599. get remoteUsers() {
  14600. return Object.values(this.userMap);
  14601. }
  14602. /**
  14603. * 获取推流对象,只能是自己
  14604. */
  14605. get publisher() {
  14606. return this.self;
  14607. }
  14608. get isSubscribing() {
  14609. var e;
  14610. return ((e = this.remoteUsers) != null ? e : []).some((t) => {
  14611. const { isAudioSubscribing: i, isVideoSubscribing: s, isScreenSubscribing: n } = t;
  14612. return i || s || n;
  14613. });
  14614. }
  14615. /**
  14616. * 处理远端用户推流状态变化
  14617. * @param {string} userId
  14618. * @param {string} displayname
  14619. * @param {string} callid
  14620. * @param {string} pullStreamUrl
  14621. * @param {TrackInfo[]} tracks
  14622. * @returns {void}
  14623. */
  14624. onRemotePublishStateChange(e) {
  14625. var d;
  14626. const { userid: t, callid: i, subscribe: s, pubid: n = "", tracks: c } = e, o = (d = s == null ? void 0 : s.pullstreamurl) != null ? d : "";
  14627. let u = this.getRemoteUser(t);
  14628. if (!u)
  14629. return;
  14630. const h = u.streamInfo.audioTrackInfo, p = u.streamInfo.videoTrackInfo;
  14631. u.updateRemoteTracks(i, o, n, c), u.updateSubscribe(de.Publish), (h !== u.streamInfo.audioTrackInfo || p !== u.streamInfo.videoTrackInfo) && this.emit(
  14632. "remoteTrackAvailableChange",
  14633. t,
  14634. u.streamInfo.audioTrackInfo,
  14635. u.streamInfo.videoTrackInfo
  14636. );
  14637. }
  14638. /** 定期更新所有人的推拉流地址,便于重连
  14639. * @param pushStreamUrl 已有的推流地址,根据地址中的过期时间来设置定时器
  14640. * @private
  14641. */
  14642. setTimeoutToUpdateAllStreamUrls(e) {
  14643. var s;
  14644. if (!e)
  14645. return;
  14646. let t = 59 * 60 * 1e3;
  14647. const i = (s = Z0(e)) == null ? void 0 : s.timeoutTs;
  14648. i && (t = i - Date.now() - 60 * 1e3), this.refreshUrlTimer = window.setTimeout(() => w(this, null, function* () {
  14649. var c;
  14650. const n = yield this.signalingManager.refreshUrl({
  14651. pushstreamurl: this.self.url,
  14652. users: this.remoteUsers.map((o) => ({
  14653. userid: o.userId,
  14654. subscribe: {
  14655. pullstreamurl: o.streamUrl
  14656. }
  14657. }))
  14658. });
  14659. n.pushstreamurl && (this.self.url = n.pushstreamurl), (c = n.users) == null || c.forEach((o) => {
  14660. var h;
  14661. const u = this.getRemoteUser(o.userid);
  14662. u && ((h = o.subscribe) != null && h.pullstreamurl) && (u.streamUrl = o.subscribe.pullstreamurl);
  14663. }), this.setTimeoutToUpdateAllStreamUrls(n.pushstreamurl);
  14664. }), t);
  14665. }
  14666. init(e, t) {
  14667. this.authInfo = e, this.self.enableAudioVolumeIndication(this.audioVolumeIndicationInterval), this.self.initInfo(e, t.pushstreamurl), this.setTimeoutToUpdateAllStreamUrls(t.pushstreamurl), t.users.forEach((i) => {
  14668. const s = i.userid;
  14669. if (s) {
  14670. const n = this.addUser(s, i.displayname, de.InRoom), { callid: c, subscribe: o, tracks: u } = i;
  14671. n.updateRemoteTracks(c, (o == null ? void 0 : o.pullstreamurl) || "", "", u), this.emit(
  14672. "remoteTrackAvailableChange",
  14673. s,
  14674. n.streamInfo.audioTrackInfo,
  14675. n.streamInfo.videoTrackInfo
  14676. );
  14677. }
  14678. }), this.startStatsMonitor();
  14679. }
  14680. leave() {
  14681. return w(this, null, function* () {
  14682. this.stopStatsMonitor(), typeof this.refreshUrlTimer != "undefined" && (window.clearTimeout(this.refreshUrlTimer), this.refreshUrlTimer = void 0), Object.values(this.usersViewMap).forEach(({ cameraViews: e = [], screenViews: t = [] }) => {
  14683. e.forEach((i) => {
  14684. i.srcObject = null, i._playPromise = void 0;
  14685. }), t.forEach((i) => {
  14686. i.srcObject = null, i._playPromise = void 0;
  14687. });
  14688. }), this.usersViewMap = {};
  14689. for (let e in this.userMap)
  14690. this.userMap[e] && (this.userMap[e].clear(), delete this.userMap[e]);
  14691. this.self.leave(), this.localStreamManager.stop(), this.rtsManager.clear(), this.authInfo = void 0;
  14692. });
  14693. }
  14694. clear() {
  14695. return w(this, null, function* () {
  14696. yield this.leave(), this.self.clear(), this.pluginManager.removeAll();
  14697. });
  14698. }
  14699. startStatsMonitor() {
  14700. this.statsMonitorId = window.setInterval(() => w(this, null, function* () {
  14701. if (this.publisher) {
  14702. const { audio: i, video: s, candidate: n } = yield this.publisher.getStats();
  14703. i && i.length > 0 && this.emit("rtcLocalAudioStats", i), s && s.length > 0 && this.emit("rtcLocalVideoStats", s), n && this.emit("rtcStats", n);
  14704. }
  14705. const e = [], t = [];
  14706. for (const i of this.remoteUsers) {
  14707. const { audio: s, video: n } = yield i.getStats();
  14708. s && s.forEach((c) => {
  14709. e.push(c);
  14710. }), n && n.forEach((c) => {
  14711. t.push(c);
  14712. });
  14713. }
  14714. e.length > 0 && this.emit("rtcRemoteAudioStats", e), t.length > 0 && this.emit("rtcRemoteVideoStats", t);
  14715. }), 2e3);
  14716. }
  14717. stopStatsMonitor() {
  14718. this.statsMonitorId && clearInterval(this.statsMonitorId);
  14719. }
  14720. addUser(e, t, i) {
  14721. return this.userMap[e] || (this.userMap[e] = this.executeAddUser(e, t, i)), this.userMap[e];
  14722. }
  14723. /**
  14724. * 执行添加远端用户
  14725. * @param {string} userId
  14726. * @param {string} displayName
  14727. * @returns {RemoteUser}
  14728. */
  14729. executeAddUser(e, t, i) {
  14730. const s = new mc({
  14731. userId: e,
  14732. displayName: t,
  14733. rtsManager: this.rtsManager,
  14734. signalingManager: this.signalingManager,
  14735. usersViewMap: this.usersViewMap,
  14736. slsReporter: this.slsReporter,
  14737. localUser: this.self,
  14738. audioVolumeIndicationInterval: this.audioVolumeIndicationInterval,
  14739. playoutVolume: this.playoutVolume,
  14740. parameter: this.parameter
  14741. });
  14742. return s.on(Le.Remote, this.onRemoteDeviceStatusChange.bind(this)), s.on(oe.PullStreamStats, this.onRemoteStatReport.bind(this)), s.on(oe.RtsSubscribeExceeds, this.onSubscribeExceeds.bind(this)), s.on("audioSubscribeStateChanged", (n, c, o, u) => {
  14743. this.emit("audioSubscribeStateChanged", n, c, o, u, this.channel || "");
  14744. }), s.on("videoSubscribeStateChanged", (n, c, o, u) => {
  14745. this.emit("videoSubscribeStateChanged", n, c, o, u, this.channel || "");
  14746. }), s.on("screenSubscribeStateChanged", (n, c, o, u) => {
  14747. this.emit("screenSubscribeStateChanged", n, c, o, u, this.channel || "");
  14748. }), s.on("dataSubscribeStateChanged", (n, c, o, u) => {
  14749. this.emit("dataSubscribeStateChanged", n, c, o, u, this.channel || "");
  14750. }), s.on("remoteAudioAutoPlayFail", (n) => {
  14751. this.emit("remoteAudioAutoPlayFail", n);
  14752. }), s.on("remoteVideoAutoPlayFail", (n, c) => {
  14753. this.emit("remoteVideoAutoPlayFail", n, c);
  14754. }), s.on("remoteAudioPlayError", (n, c) => {
  14755. this.emit("remoteAudioPlayError", n, c);
  14756. }), s.on("remoteVideoPlayError", (n, c) => {
  14757. this.emit("remoteVideoPlayError", n, c);
  14758. }), s.on("remoteSubscribeError", (n) => {
  14759. this.emit("remoteSubscribeError", n, s.userId);
  14760. }), s.on("occurError", (n) => {
  14761. this.emit("occurError", n, s.userId);
  14762. }), s.on("remoteDataChannelMessage", (n, c) => {
  14763. this.emit("remoteDataChannelMessage", n, c);
  14764. }), s.setWantSubAudio(this.autoSubAudio && this.wantSubAudio), s.setWantSubVideo(this.autoSubVideo && this.wantSubVideo), s.setWantSubScreen(this.autoSubScreen && this.wantSubScreen), s.setRemoteDefaultVideoStreamType(this.defaultStreamType), s.setAudioMuted(this.audioMuted), (this.autoSubAudio || this.autoSubVideo || this.autoSubScreen) && s.updateSubscribe(i), s;
  14765. }
  14766. /**
  14767. * 远端用户设备状态变化
  14768. * @param {DeviceStatusChangeType} event
  14769. * @param {string} userId
  14770. */
  14771. onRemoteDeviceStatusChange(e, t) {
  14772. e === oe.MuteAudio ? this.emit("userAudioMuted", t, !0) : e === oe.UnmuteAudio ? this.emit("userAudioMuted", t, !1) : e === oe.MuteVideo ? this.emit("userVideoMuted", t, !0) : e === oe.UnmuteVideo ? this.emit("userVideoMuted", t, !1) : e === oe.MuteScreen ? this.emit("userScreenMuted", t, !0) : e === oe.UnmuteScreen && this.emit("userScreenMuted", t, !1);
  14773. }
  14774. /**
  14775. * 远端流数据采集上报
  14776. * @param {any} stat
  14777. */
  14778. onRemoteStatReport(e, t, i) {
  14779. this.emit(oe.PullStreamStats, e, t, i);
  14780. }
  14781. /**
  14782. * rts 单 PC 订阅超限
  14783. */
  14784. onSubscribeExceeds(e, t) {
  14785. this.emit(oe.RtsSubscribeExceeds, e, t);
  14786. }
  14787. removeLeftUser(e) {
  14788. return w(this, null, function* () {
  14789. e.userid && this.userMap[e.userid] && (yield this.userMap[e.userid].clear(!1), delete this.userMap[e.userid]);
  14790. });
  14791. }
  14792. updateUsers(e) {
  14793. const t = [], i = [], s = {};
  14794. e.forEach((o) => {
  14795. o.userid && (this.userMap[o.userid] ? (i.push(o), s[o.userid] = this.userMap[o.userid]) : (t.push(o), s[o.userid] = this.executeAddUser(o.userid, o.displayname, de.Resume)));
  14796. });
  14797. const n = Object.keys(this.userMap), c = [];
  14798. return n.forEach((o) => {
  14799. s[o] || c.push({
  14800. userid: o,
  14801. reason: "",
  14802. leavecode: ss.AliRtcUserOfflineQuit
  14803. });
  14804. }), this.userMap = s, { joinList: t, leaveList: c, presentList: i };
  14805. }
  14806. /**
  14807. * 根据 userId 获取 RemoteUser
  14808. * @param {string} userId
  14809. * @returns {RemoteUser | undefined}
  14810. */
  14811. getRemoteUser(e) {
  14812. return this.userMap[e];
  14813. }
  14814. /**
  14815. * 更新远端用户设备信息
  14816. * @param {RemoteUserStatus} user
  14817. * @returns {boolean} true: 用户状态改变 false: 用户状态没有改变
  14818. */
  14819. updateRemoteUserDeviceStatus(e) {
  14820. e && e.userid && this.userMap[e.userid] && this.userMap[e.userid].updateRemoteUserDeviceStatus(e.status);
  14821. }
  14822. updateAudioWant(e, t) {
  14823. const i = this.userMap[e];
  14824. if (!i)
  14825. throw new V(U.ERR_INNER, `no remote user(${e}) founded`);
  14826. i.setWantSubAudio(t), t ? i.updateSubscribe(de.User) : i.stopSubscribe({ audio: !0 });
  14827. }
  14828. updateVideoWant(e, t) {
  14829. const i = this.userMap[e];
  14830. if (!i)
  14831. throw new V(U.ERR_INNER, `no remote user(${e}) founded`);
  14832. i.setWantSubVideo(t), t ? i.updateSubscribe(de.User) : i.stopSubscribe({ video: !0 });
  14833. }
  14834. updateScreenWant(e, t) {
  14835. const i = this.userMap[e];
  14836. if (!i)
  14837. throw new V(U.ERR_INNER, `no remote user(${e}) founded`);
  14838. i.setWantSubScreen(t), t ? i.updateSubscribe(de.User) : i.stopSubscribe({ screen: !0 });
  14839. }
  14840. stopIndication() {
  14841. this.indicationTimer && window.clearInterval(this.indicationTimer);
  14842. }
  14843. startIndication(e) {
  14844. this.stopIndication(), this.indicationTimer = window.setInterval(() => {
  14845. const t = this.remoteUsers.map((i) => ({
  14846. userId: i.userId,
  14847. volume: i.getAudioLevel() || 0
  14848. }));
  14849. t.unshift({
  14850. userId: "",
  14851. // 空字符串代表是当前用户
  14852. volume: this.self.getAudioLevel() || 0
  14853. }), this.emit("audioVolume", t);
  14854. }, e);
  14855. }
  14856. setEnableDualVideoStream(e, t) {
  14857. if (!this.dualVideoPlugin)
  14858. return;
  14859. t && this.dualVideoPlugin.setOptions(t);
  14860. const i = this.pluginManager.has(this.dualVideoPlugin.name);
  14861. e ? !i && this.pluginManager.add(this.dualVideoPlugin) : i && this.pluginManager.remove(this.dualVideoPlugin.name);
  14862. }
  14863. setAudioVolume(e) {
  14864. var t;
  14865. (t = this.audioMixerPlugin) == null || t.setOptions(e);
  14866. }
  14867. enableAudioVolumeIndication(e) {
  14868. this.audioVolumeIndicationInterval !== e && (this.audioVolumeIndicationInterval > 0 && e <= 0 && this.stopIndication(), e > 0 && this.startIndication(e), this.audioVolumeIndicationInterval = e, this.remoteUsers.forEach((t) => {
  14869. t.enableAudioVolumeIndication(e);
  14870. }), this.self.enableAudioVolumeIndication(e));
  14871. }
  14872. setPlayoutVolume(e) {
  14873. this.playoutVolume = e, this.remoteUsers.forEach((t) => {
  14874. t.setPlayoutVolume(e);
  14875. });
  14876. }
  14877. refreshAuthInfo(e) {
  14878. this.authInfo && (this.authInfo = J(J({}, this.authInfo), e)), e.userId && this.self.refreshUserInfo(e.userId);
  14879. }
  14880. setEnableMediaExtensionMsg(e) {
  14881. this.rtsManager.setEncodedInsertableStreams(e);
  14882. }
  14883. setAudioRedEnabled(e) {
  14884. this.rtsManager.setAudioRedEnabled(e);
  14885. }
  14886. setParameter(e) {
  14887. var i, s, n;
  14888. const t = JSON.parse(e);
  14889. Object.keys(t).forEach((c) => {
  14890. const o = this.parameter[c], u = t[c];
  14891. typeof o == "object" && typeof u == "object" ? this.parameter[c] = J(J({}, o), u) : this.parameter[c] = u;
  14892. }), t.enableBlankAudio === !0 ? (this.blankAudioPlugin || (this.blankAudioPlugin = new Cc()), this.pluginManager.has((i = this.blankAudioPlugin) == null ? void 0 : i.name) || this.pluginManager.add(this.blankAudioPlugin)) : t.enableBlankAudio === !1 && (this.blankAudioPlugin && this.pluginManager.remove((s = this.blankAudioPlugin) == null ? void 0 : s.name), (n = this.blankAudioPlugin) == null || n.clear(), this.blankAudioPlugin = void 0);
  14893. }
  14894. getParameter() {
  14895. return JSON.stringify(this.parameter);
  14896. }
  14897. sendDataChannelMessage(e) {
  14898. return this.self.sendDataChannelMessage(e);
  14899. }
  14900. }
  14901. /**
  14902. * @ignore
  14903. */
  14904. g(Pe, "logName", "BizControl");
  14905. je([
  14906. D()
  14907. ], Pe.prototype, "init", 1);
  14908. je([
  14909. D()
  14910. ], Pe.prototype, "leave", 1);
  14911. je([
  14912. D()
  14913. ], Pe.prototype, "clear", 1);
  14914. je([
  14915. D(H)
  14916. ], Pe.prototype, "addUser", 1);
  14917. je([
  14918. D()
  14919. ], Pe.prototype, "removeLeftUser", 1);
  14920. je([
  14921. D()
  14922. ], Pe.prototype, "updateUsers", 1);
  14923. je([
  14924. D(H)
  14925. ], Pe.prototype, "updateAudioWant", 1);
  14926. je([
  14927. D(H)
  14928. ], Pe.prototype, "updateVideoWant", 1);
  14929. je([
  14930. D(H)
  14931. ], Pe.prototype, "updateScreenWant", 1);
  14932. je([
  14933. D()
  14934. ], Pe.prototype, "stopIndication", 1);
  14935. je([
  14936. D()
  14937. ], Pe.prototype, "startIndication", 1);
  14938. je([
  14939. D(H)
  14940. ], Pe.prototype, "setEnableDualVideoStream", 1);
  14941. je([
  14942. D(H)
  14943. ], Pe.prototype, "setAudioVolume", 1);
  14944. je([
  14945. D()
  14946. ], Pe.prototype, "enableAudioVolumeIndication", 1);
  14947. const Mr = (r) => w(void 0, null, function* () {
  14948. const a = new Uint8Array(160).fill(170), e = new TextEncoder().encode(r), t = yield window.crypto.subtle.importKey(
  14949. "raw",
  14950. // 密钥格式
  14951. a,
  14952. // 密钥数据
  14953. { name: "HMAC", hash: { name: "SHA-1" } },
  14954. // 算法详情
  14955. !1,
  14956. // 不可导出密钥
  14957. ["sign"]
  14958. // 可用操作
  14959. ), i = yield window.crypto.subtle.sign(
  14960. "HMAC",
  14961. t,
  14962. e
  14963. // 需要签名的数据
  14964. );
  14965. return Array.from(new Uint8Array(i)).map((s) => s.toString(16).padStart(2, "0")).join("");
  14966. });
  14967. class Uc {
  14968. constructor(a) {
  14969. g(this, "authInfo");
  14970. g(this, "slsReporter");
  14971. this.slsReporter = a;
  14972. }
  14973. doRequest(a, e) {
  14974. var u;
  14975. const t = this.authInfo;
  14976. if (!t)
  14977. return Promise.reject(ht.LiveTranscodingErrorInvalidParam);
  14978. const i = "https://gw.rtn.aliyuncs.com", s = M0[a], n = {
  14979. appid: t.appId,
  14980. userid: t.userId,
  14981. channelid: t.channelId,
  14982. timestamp: t.timestamp,
  14983. token: t.token,
  14984. nonce: t.nonce ? t.nonce : "",
  14985. requestid: He.createCallid(),
  14986. tokensid: !1,
  14987. session: (u = t.sessionId) != null ? u : He.createCallid()
  14988. }, c = Object.keys(n).map((h) => `${h}=${encodeURIComponent(n[h])}`).join("&"), o = `${i}${s}?${c}`;
  14989. return fetch(o, {
  14990. method: "POST",
  14991. headers: {
  14992. "Content-Type": "application/json; charset=UTF-8"
  14993. },
  14994. body: JSON.stringify(e)
  14995. }).then((h) => h.status !== 200 ? (this.slsReporter.reportTranscodingError(h.status, e.taskid || ""), Promise.reject(
  14996. new V(U.ERR_INNER, `transcoding request failed, status: ${h.status}`)
  14997. )) : h).catch((h) => Promise.reject(
  14998. new V(U.ERR_INNER, `transcoding request failed, err: ${h.message}`)
  14999. ));
  15000. }
  15001. setAuthInfo(a) {
  15002. this.authInfo = a;
  15003. }
  15004. clear() {
  15005. this.authInfo = void 0;
  15006. }
  15007. startPublishLiveStream(a, e) {
  15008. return w(this, null, function* () {
  15009. if (!this.authInfo)
  15010. return Promise.reject(ht.LiveTranscodingErrorInvalidParam);
  15011. const t = yield Mr(a.split("?")[0]), i = Ue.MPU_TASK_TRANSACTION_UPDATE, s = e.toJson(i, this.authInfo, t, a);
  15012. return this.doRequest(i, s);
  15013. });
  15014. }
  15015. startPublishLiveStreamWithTaskId(a, e) {
  15016. return w(this, null, function* () {
  15017. if (!this.authInfo)
  15018. return Promise.reject(ht.LiveTranscodingErrorInvalidParam);
  15019. const t = Ue.MPU_TASK_TRANSACTION_UPDATE, i = e.toJson(t, this.authInfo, a);
  15020. return this.doRequest(t, i);
  15021. });
  15022. }
  15023. updatePublishLiveStream(a, e) {
  15024. return w(this, null, function* () {
  15025. if (!this.authInfo)
  15026. return Promise.reject(ht.LiveTranscodingErrorInvalidParam);
  15027. const t = yield Mr(a.split("?")[0]), i = Ue.MPU_TASK_TRANSACTION_UPDATE, s = e.toJson(i, this.authInfo, t, a);
  15028. return this.doRequest(i, s);
  15029. });
  15030. }
  15031. updatePublishLiveStreamWithTaskId(a, e) {
  15032. return w(this, null, function* () {
  15033. if (!this.authInfo)
  15034. return Promise.reject(ht.LiveTranscodingErrorInvalidParam);
  15035. const t = Ue.MPU_TASK_TRANSACTION_UPDATE, i = e.toJson(t, this.authInfo, a);
  15036. return this.doRequest(t, i);
  15037. });
  15038. }
  15039. stopPublishLiveStream(a) {
  15040. return w(this, null, function* () {
  15041. if (!this.authInfo)
  15042. return Promise.reject(ht.LiveTranscodingErrorInvalidParam);
  15043. const e = yield Mr(a.split("?")[0]), t = Ue.MPU_TASK_TRANSACTION_STOP, i = new Fr().toJson(t, this.authInfo, e, a);
  15044. return this.doRequest(t, i);
  15045. });
  15046. }
  15047. stopPublishLiveStreamWithTaskId(a) {
  15048. if (!this.authInfo)
  15049. return Promise.reject(ht.LiveTranscodingErrorInvalidParam);
  15050. const e = Ue.MPU_TASK_TRANSACTION_STOP, t = new Fr().toJson(e, this.authInfo, a);
  15051. return this.doRequest(e, t);
  15052. }
  15053. refreshAuthInfo(a) {
  15054. this.authInfo && this.setAuthInfo(J(J({}, this.authInfo), a));
  15055. }
  15056. }
  15057. class cs {
  15058. /**
  15059. * 检测是否是string类型
  15060. * @param {any} param
  15061. * @returns true: 是string类型 false: 不是string类型
  15062. */
  15063. static checkString(a) {
  15064. return typeof a == "string";
  15065. }
  15066. /**
  15067. * 检测是否是number类型
  15068. * @param {any} param
  15069. * @returns true: 是number类型 false: 不是number类型
  15070. */
  15071. static checkNumber(a) {
  15072. return typeof a == "number";
  15073. }
  15074. /**
  15075. * 检测是否是HtmlVideoElement
  15076. * @param {any} param
  15077. * @returns true: 是HtmlVideoElement false: 不是HtmlVideoElement
  15078. */
  15079. static checkHtmlVideoElement(a) {
  15080. return a && a.nodeName === "VIDEO";
  15081. }
  15082. /**
  15083. * 检测是否是HtmlAudioElement
  15084. * @param {any} param
  15085. * @returns true: 是HtmlAudioElement false: 不是HtmlAudioElement
  15086. */
  15087. static checkHtmlAudioElement(a) {
  15088. return a && a.nodeName === "AUDIO";
  15089. }
  15090. /**
  15091. * 检查AuthInfo的值是否规范
  15092. * @param {any} authInfo
  15093. * @returns
  15094. */
  15095. static checkAuthInfo(a) {
  15096. if (!a)
  15097. return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no authInfo founded");
  15098. if (!a.appId)
  15099. return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no appId founded");
  15100. if (!a.channelId)
  15101. return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no channelId founded");
  15102. if (!a.userId)
  15103. return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no userId founded");
  15104. if (a.timestamp) {
  15105. if (!cs.checkNumber(a.timestamp))
  15106. return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "timestamp is not number");
  15107. } else
  15108. return new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no timestamp founded");
  15109. return a.token ? null : new V(U.ERR_JOIN_ERR_JOIN_BAD_PARAMBAD, "no token founded");
  15110. }
  15111. /**
  15112. * 检测是否是MediaStreamTrack类型
  15113. * @param {any} track
  15114. * @returns
  15115. */
  15116. static checkMediaStreamTrack(a) {
  15117. return a instanceof MediaStreamTrack;
  15118. }
  15119. /**
  15120. * 检查VideoProfile类型
  15121. * @param profile
  15122. * @returns
  15123. */
  15124. static checkVideoEncoderConfiguration(a) {
  15125. return a && (a.width || a.height || a.frameRate || a.bitrateMax);
  15126. }
  15127. }
  15128. class Hc {
  15129. constructor(a) {
  15130. g(this, "taskProfile");
  15131. g(this, "encodeParam");
  15132. g(this, "users", []);
  15133. g(this, "backgroundColor", 0);
  15134. g(this, "backgrounds", []);
  15135. g(this, "watermarks", []);
  15136. g(this, "clockWidgets", []);
  15137. g(this, "cropMode");
  15138. g(this, "mediaProcessMode");
  15139. this.taskProfile = a;
  15140. }
  15141. }
  15142. class jc {
  15143. constructor(a, e, t) {
  15144. g(this, "userId");
  15145. g(this, "streamType");
  15146. g(this, "sourceType");
  15147. this.userId = a, this.streamType = e, this.sourceType = t;
  15148. }
  15149. }
  15150. class zc {
  15151. constructor(a, e, t, i = 0, s = 16777215, n = Ii.NOTO_SERIF_CJKSC_REGULAR) {
  15152. g(this, "x");
  15153. g(this, "y");
  15154. g(this, "fontSize");
  15155. g(this, "zOrder");
  15156. g(this, "fontColor");
  15157. g(this, "fontType");
  15158. this.x = a, this.y = e, this.fontSize = t, this.zOrder = i, this.fontColor = s, this.fontType = n;
  15159. }
  15160. toJson(a, e) {
  15161. return {
  15162. x: Ye(this.x, a),
  15163. y: Ye(this.y, e),
  15164. fonttype: this.fontType,
  15165. fontsize: this.fontSize,
  15166. fontcolor: rs(this.fontColor),
  15167. zorder: this.zOrder
  15168. };
  15169. }
  15170. }
  15171. var wn = /* @__PURE__ */ ((r) => (r[r.NOT_DISPLAY = 0] = "NOT_DISPLAY", r[r.ALWAYS = 1] = "ALWAYS", r[r.WHEN_NO_VIDEO = 2] = "WHEN_NO_VIDEO", r))(wn || {});
  15172. class Dn {
  15173. constructor(a, e, t, i, s, n = 0, c = 1, o = 1) {
  15174. g(this, "url");
  15175. g(this, "x");
  15176. g(this, "y");
  15177. g(this, "width");
  15178. g(this, "height");
  15179. g(this, "alpha");
  15180. g(this, "display", 1);
  15181. g(this, "zOrder");
  15182. this.url = a, this.x = e, this.y = t, this.width = i, this.height = s, this.zOrder = n, this.alpha = c, this.display = o;
  15183. }
  15184. toJson(a, e) {
  15185. return {
  15186. url: this.url,
  15187. alpha: this.alpha,
  15188. display: this.display,
  15189. x: Ye(this.x, a),
  15190. y: Ye(this.y, e),
  15191. width: Ye(this.width, a),
  15192. height: Ye(this.height, e),
  15193. zorder: this.zOrder
  15194. };
  15195. }
  15196. }
  15197. g(Dn, "DisplayType", wn);
  15198. class Wc {
  15199. constructor(a, e, t, i, s = 0, n = 16777215, c = Ii.NOTO_SERIF_CJKSC_REGULAR) {
  15200. g(this, "text");
  15201. g(this, "x");
  15202. g(this, "y");
  15203. g(this, "fontSize");
  15204. g(this, "zOrder");
  15205. g(this, "fontColor");
  15206. g(this, "fontType");
  15207. this.text = a, this.x = e, this.y = t, this.fontSize = i, this.zOrder = s, this.fontColor = n, this.fontType = c;
  15208. }
  15209. toJson(a, e) {
  15210. return {
  15211. text: this.text,
  15212. x: Ye(this.x, a),
  15213. y: Ye(this.y, e),
  15214. fonttype: this.fontType,
  15215. fontsize: this.fontSize,
  15216. fontcolor: rs(this.fontColor),
  15217. zorder: this.zOrder
  15218. };
  15219. }
  15220. }
  15221. class $c {
  15222. constructor(a, e, t, i, s, n = 0, c) {
  15223. g(this, "userId");
  15224. g(this, "x");
  15225. g(this, "y");
  15226. g(this, "width");
  15227. g(this, "height");
  15228. g(this, "zOrder");
  15229. g(this, "sourceType");
  15230. g(this, "segmentType", Ei.LiveTranscodingNoBody);
  15231. g(this, "images", []);
  15232. g(this, "texts", []);
  15233. typeof a == "number" ? this.userId = a.toString() : this.userId = a, this.x = e, this.y = t, this.width = i, this.height = s, this.zOrder = n, c && (this.sourceType = c);
  15234. }
  15235. toJson(a, e, t, i) {
  15236. const s = {
  15237. paneid: a,
  15238. majorpane: 0,
  15239. x: Ye(this.x, e),
  15240. y: Ye(this.y, t),
  15241. width: Ye(this.width, e),
  15242. height: Ye(this.height, t),
  15243. zorder: this.zOrder,
  15244. userid: this.userId,
  15245. images: this.images.map((n) => n.toJson(e, t)),
  15246. texts: this.texts.map((n) => n.toJson(e, t))
  15247. };
  15248. return this.sourceType && ii[this.sourceType] ? s.sourcetype = ii[this.sourceType] : s.sourcetype = ii[ni.LiveTranscodingCamera], this.segmentType && i === is.LiveTranscodingVirtualBackground ? s.segmenttype = this.segmentType : s.segmenttype = Ei.LiveTranscodingNoBody, s;
  15249. }
  15250. }
  15251. const Lt = class Lt {
  15252. constructor() {
  15253. // 使用 static 声明实例
  15254. g(this, "ntpClock");
  15255. this.ntpClock = new le.Clock();
  15256. }
  15257. static getInstance() {
  15258. return Lt.instance || (Lt.instance = new Lt()), Lt.instance;
  15259. }
  15260. now() {
  15261. return this.ntpClock.now();
  15262. }
  15263. };
  15264. g(Lt, "instance");
  15265. let Wr = Lt;
  15266. const Tn = () => Wr.getInstance(), { BrowserUtil: Lr, SystenUtil: tn } = le;
  15267. class rn {
  15268. constructor() {
  15269. g(this, "tracker");
  15270. g(this, "param");
  15271. g(this, "msgCacheArr", []);
  15272. g(this, "index", 0);
  15273. g(this, "stsOpt");
  15274. g(this, "slsToken");
  15275. g(this, "ossToken");
  15276. g(this, "ntpClock");
  15277. this.ntpClock = Tn();
  15278. }
  15279. createTracker() {
  15280. if (!this.tracker && this.slsToken && this.param) {
  15281. const a = this.slsToken;
  15282. this.ossToken && (this.param.ossbn = this.ossToken.bucket_name, this.param.ossep = this.ossToken.region_endpoint);
  15283. const e = new Gr({
  15284. host: a.region_endpoint,
  15285. project: a.project,
  15286. logstore: a.log_store_stats
  15287. }), t = {
  15288. accessKeyId: a.access_key_id,
  15289. accessKeySecret: a.access_key_secret,
  15290. securityToken: a.security_token,
  15291. // 以下是一个 stsToken 刷新函数的简单示例
  15292. refreshSTSToken: () => {
  15293. this.slsToken && (t.accessKeyId = this.slsToken.access_key_id, t.accessKeySecret = this.slsToken.access_key_secret, t.securityToken = this.slsToken.security_token);
  15294. }
  15295. };
  15296. this.stsOpt = t;
  15297. const i = Zr(t);
  15298. e.useStsPlugin(i), this.tracker = e, this.msgCacheArr.forEach((s, n) => {
  15299. var c, o;
  15300. (o = this.tracker) == null || o.send(J(ut(J({}, this.param), { stat_log_id: `${((c = this.param) == null ? void 0 : c.sesid) || "nosession"}-${n}` }), s));
  15301. }), this.index = this.index + this.msgCacheArr.length, this.msgCacheArr = [];
  15302. }
  15303. }
  15304. start(a) {
  15305. this.initParam(a), this.createTracker();
  15306. }
  15307. updateToken(a, e) {
  15308. this.slsToken = a, this.ossToken = e, this.createTracker();
  15309. }
  15310. /**
  15311. * 断开连接
  15312. */
  15313. stop() {
  15314. this.tracker = void 0, this.param = void 0, this.msgCacheArr = [], this.index = 0, this.stsOpt = void 0, this.slsToken = void 0, this.ossToken = void 0;
  15315. }
  15316. /**
  15317. * 发送一条日志
  15318. * @param {any} log
  15319. */
  15320. sendReport(a) {
  15321. var t, i;
  15322. a.tm = Date.now();
  15323. let e;
  15324. try {
  15325. e = JSON.parse(
  15326. JSON.stringify(J(ut(J({
  15327. bt: Lr.browserName || "unknown",
  15328. ntptm: this.ntpClock.now(),
  15329. // NTP时间
  15330. ntpofs: this.ntpClock.now() - Date.now()
  15331. }, this.param), {
  15332. stat_log_id: `${((t = this.param) == null ? void 0 : t.sesid) || "nosession"}-${this.index}`
  15333. }), a))
  15334. );
  15335. } catch (s) {
  15336. }
  15337. if (e) {
  15338. if (!this.tracker) {
  15339. this.msgCacheArr.push(e);
  15340. return;
  15341. }
  15342. (i = this.tracker) == null || i.send(e), this.index++;
  15343. }
  15344. }
  15345. /**
  15346. * 初始化公共参数
  15347. */
  15348. initParam(a) {
  15349. let e = "";
  15350. try {
  15351. e = (localStorage == null ? void 0 : localStorage.getItem("AliRtcUUID")) || "", e || (e = rt(), localStorage == null || localStorage.setItem("AliRtcUUID", e));
  15352. } catch (t) {
  15353. }
  15354. this.param || (this.param = {
  15355. apid: a.appId,
  15356. usrid: a.userId,
  15357. statsvrs: "0.6.1",
  15358. evetid: 0,
  15359. sesid: a.sessionId,
  15360. sessionId: a.sessionId,
  15361. channelid: a.channelId,
  15362. usrn: a.userId,
  15363. osn: tn.systemName,
  15364. osv: tn.systemVersion,
  15365. deb: R0(),
  15366. den: A0(),
  15367. udid: e,
  15368. sdkvrs: yi,
  15369. acs: "Unknown",
  15370. cput: ln(),
  15371. dm: `${window.location.protocol}//${window.location.host}`,
  15372. // bt 需要保证不为空
  15373. bt: Lr.browserName,
  15374. bv: Lr.browserVersion,
  15375. envir: "PRODUCT",
  15376. args: "",
  15377. instid: rt()
  15378. // SDK 的实例ID
  15379. });
  15380. }
  15381. }
  15382. const fe = (r, a = 1, e = 6e4, t = 0) => {
  15383. let i = r;
  15384. return i || (i = 0), Math.min(e, Math.max(t, Math.round(i * a)));
  15385. }, Ge = (r, a, e = 2e7, t = 0) => {
  15386. let i = a;
  15387. (!a || a < 0 || a > 1e4) && (i = 1e3);
  15388. let s = r;
  15389. return s || (s = 0), Math.min(e, Math.max(t, Math.round(s / (i / 1e3))));
  15390. }, kt = (r, a) => {
  15391. if (a === 0 || !a)
  15392. return "0.00";
  15393. let e = r;
  15394. return (!e || e < 0) && (e = 0), (e / a * 100).toFixed(2);
  15395. }, sn = (r) => r >= 0 && r <= 1 ? fe(Math.floor(32767 * r), 1, 32767) : 0, pe = (r, a) => {
  15396. var t, i, s;
  15397. let e = ((t = r._last) == null ? void 0 : t[a]) || 0;
  15398. return r.ssrc && ((i = r._last) != null && i.ssrc) && r.ssrc !== ((s = r._last) == null ? void 0 : s.ssrc) && (e = 0), ((r == null ? void 0 : r[a]) || 0) - e;
  15399. }, Kc = (r, a) => {
  15400. var e, t, i;
  15401. return (((e = r == null ? void 0 : r._source) == null ? void 0 : e[a]) || 0) - (((i = (t = r == null ? void 0 : r._last) == null ? void 0 : t._source) == null ? void 0 : i[a]) || 0);
  15402. }, an = (r, a) => fe(pe(r, a), 1e3, 1e4), Bt = (r, a = 2e7) => fe(r, 1, a), si = class si {
  15403. constructor(a) {
  15404. g(this, "engine");
  15405. g(this, "logClient");
  15406. g(this, "authInfo");
  15407. g(this, "ntpClock");
  15408. g(this, "customFields", {});
  15409. this.logClient = new rn(), this.engine = a, this.ntpClock = Tn();
  15410. }
  15411. static getLogClient() {
  15412. return this.staticClient || (this.staticClient = new rn()), this.staticClient;
  15413. }
  15414. static reportOSSUpload(a, e, t = 0) {
  15415. si.getLogClient().sendReport({
  15416. errmsg: `${e}/${a}.log`,
  15417. errtype: t,
  15418. evetid: 70017,
  15419. sesid: a,
  15420. sessionId: a,
  15421. stat_log_id: `${a}-70017`
  15422. });
  15423. }
  15424. /**
  15425. * 设置通用字段
  15426. * @param fields 字段键值对
  15427. */
  15428. setCustomFields(a) {
  15429. this.customFields = J(J({}, this.customFields), a);
  15430. }
  15431. /**
  15432. * 获取通用字段
  15433. * @param key 字段键
  15434. * @returns 字段值或undefined
  15435. */
  15436. getCustomField(a) {
  15437. return this.customFields[a];
  15438. }
  15439. /**
  15440. * 开始建立连接
  15441. * @param authInfo
  15442. */
  15443. start(a) {
  15444. this.authInfo = a, this.logClient.start(a);
  15445. }
  15446. updateToken(a, e) {
  15447. this.logClient.updateToken(a, e), si.getLogClient().updateToken(a, e);
  15448. }
  15449. /**
  15450. * 断开连接
  15451. */
  15452. stop() {
  15453. this.logClient.stop();
  15454. }
  15455. reportPublishMonitor(a, e, t, i, s) {
  15456. if (!t || s.length <= 0)
  15457. return;
  15458. const n = t === T.Audio, c = {
  15459. ctm: Math.floor(s[0].timestamp || 0),
  15460. src: s[0].ssrc || "",
  15461. codec: s[0]._codec || ""
  15462. }, o = [], u = [], h = [], p = [], d = [], f = [], m = [], l = [], S = [], v = [], x = [], b = [], E = [], _ = [], y = [], A = [], R = [], M = [], C = [];
  15463. try {
  15464. if (s.forEach((I) => {
  15465. var F, N, G, j, ce, Z;
  15466. if (!I || !I.timestamp)
  15467. return;
  15468. const P = (F = I._last) != null && F.timestamp ? I.timestamp - I._last.timestamp : 1e3, B = pe(I, "bytesSent"), $ = pe(I, "headerBytesSent"), q = Ge(fe(B + $, 8, 2e7), P);
  15469. o.push(q);
  15470. const X = Ge(fe(B, 8, 2e7), P);
  15471. u.push(X);
  15472. const ae = Ge(fe($, 8, 2e7), P);
  15473. h.push(ae);
  15474. const Q = pe(I, "packetsSent"), te = Ge(Q, P);
  15475. p.push(te);
  15476. const ee = pe(I, "packetsLost"), k = Ge(ee, P);
  15477. d.push(k);
  15478. const L = kt(ee, Q);
  15479. if (f.push(L), n)
  15480. (N = I._source) != null && N.audioLevel && m.push(sn(I._source.audioLevel)), l.push(0);
  15481. else {
  15482. S.push(an(I, "totalEncodeTime")), v.push(Bt((G = I._source) == null ? void 0 : G.framesPerSecond, 100)), x.push(Bt((j = I._source) == null ? void 0 : j.framesPerSecond, 100)), b.push(Bt(I.framesPerSecond, 100)), E.push(Bt((ce = I._source) == null ? void 0 : ce.height, 4400)), _.push(Bt((Z = I._source) == null ? void 0 : Z.width, 7700)), y.push(Bt(I.frameHeight, 4400)), A.push(Bt(I.frameWidth, 7700));
  15483. const Ve = pe(I, "totalPacketSendDelay");
  15484. R.push(fe(Ve, 1 / (ee || 1), 2e3));
  15485. const ze = pe(I, "qpSum");
  15486. M.push(fe(ze, 1 / (I.framesPerSecond || 1), 51)), C.push(0);
  15487. }
  15488. }), c.sbr = o.join(","), c.mbrs = u.join(","), c.pbrs = h.join(","), c.ps = p.join(","), c.pl = d.join(","), c.plr = f.join(","), n) {
  15489. const I = (i == null ? void 0 : i.getSettings().sampleRate) || 0;
  15490. c.ailevel = m.join(","), c.arpc = l.join(","), c.arsr = I, c.aesr = I, c.publevel = -90, c.rawlevel = -90;
  15491. } else
  15492. c.em = S.join(","), c.cfps = v.join(","), c.ifps = x.join(","), c.sfps = b.join(","), c.ih = E.join(","), c.iw = _.join(","), c.sh = y.join(","), c.sw = A.join(","), c.sd = R.join(","), c.aqp = M.join(","), c.caf = C.join(","), c.can = C.join(","), c.cav = u.join(","), c.ifimax = C.join(","), c.ifimin = C.join(","), c.efimax = C.join(","), c.efimin = C.join(","), c.sfimax = C.join(","), c.sfimin = C.join(","), c.apsnr = C.join(",");
  15493. } catch (I) {
  15494. }
  15495. this.log({
  15496. evetid: 10070,
  15497. traceid: e,
  15498. calid: a,
  15499. args: this.data2String(J({
  15500. calid: a,
  15501. tckid: t,
  15502. traceid: e
  15503. }, c))
  15504. });
  15505. }
  15506. reportSubscribeMonitor(a, e, t, i, s) {
  15507. if (!i || !s || s.length <= 0)
  15508. return;
  15509. const n = i === T.Audio, c = {
  15510. ctm: Math.floor(s[0].timestamp || 0),
  15511. src: s[0].ssrc || "",
  15512. codec: s[0]._codec || ""
  15513. }, o = [], u = [], h = [], p = [], d = [], f = [], m = [], l = [], S = [], v = [], x = [], b = [], E = [], _ = [], y = [], A = [], R = [], M = [], C = [], I = [], P = [], B = [], $ = [], q = [], X = [], ae = [], Q = [], te = [], ee = [], k = [], L = [], F = [], N = [], G = [];
  15514. try {
  15515. s.forEach((j) => {
  15516. var tt, wt;
  15517. if (!j || !j.timestamp)
  15518. return;
  15519. const ce = (tt = j._last) != null && tt.timestamp ? j.timestamp - j._last.timestamp : 1e3, Z = pe(j, "bytesReceived"), Ve = pe(j, "headerBytesReceived"), ze = Ge(fe(Z + Ve, 8, 2e7), ce);
  15520. o.push(ze);
  15521. const Qe = Ge(fe(Z, 8, 2e7), ce);
  15522. u.push(Qe);
  15523. const et = Ge(fe(Ve, 8, 2e7), ce);
  15524. h.push(et);
  15525. const xe = pe(j, "packetsReceived"), ke = Ge(xe, ce);
  15526. p.push(ke);
  15527. const ot = pe(j, "packetsLost"), Ct = Ge(ot, ce);
  15528. d.push(Ct);
  15529. const Ht = kt(ot, xe);
  15530. f.push(Ht);
  15531. const Rt = pe(j, "jitterBufferDelay"), Yt = pe(j, "jitterBufferEmittedCount");
  15532. if (j.jitterBufferDelay && j.jitterBufferEmittedCount) {
  15533. const gt = fe(Rt, 1e3 / Yt, 1e4);
  15534. m.push(gt);
  15535. } else
  15536. m.push(0);
  15537. const It = pe(j, "fecPacketsReceived");
  15538. b.push(kt(It, xe));
  15539. const Be = pe(j, "retransmittedPacketsReceived"), Re = xe + ot - Be;
  15540. if (S.push(kt(xe - Be, Re)), v.push(kt(ot, Re)), l.push(kt(Be, Re)), x.push(Re), N.push(0), G.push(""), n) {
  15541. _.push(sn(j.audioLevel));
  15542. const gt = Kc(j, "synthesizedSamplesEvents");
  15543. y.push(gt);
  15544. const it = an(j, "synthesizedSamplesDuration");
  15545. A.push(it);
  15546. const ct = kt(it, ce);
  15547. E.push(ct), R.push(0);
  15548. } else {
  15549. const gt = (wt = j._last) != null && wt.totalInterFrameDelay ? j.totalInterFrameDelay - j._last.totalInterFrameDelay : 0;
  15550. M.push(fe(gt, 1e3 / (j.framesDecoded || 30), 500)), C.push(fe(j.framesPerSecond, 1, 100)), I.push(pe(j, "framesReceived")), F.push(pe(j, "framesRendered")), P.push(fe(j.frameHeight, 1, 4400)), B.push(fe(j.frameWidth, 1, 7700));
  15551. const it = pe(j, "totalProcessingDelay");
  15552. $.push(fe(it, 1e3 / (j.framesDecoded || 30), 12e4));
  15553. const ct = pe(j, "nackCount");
  15554. X.push(ct);
  15555. const ki = pe(j, "pliCount");
  15556. q.push(ki);
  15557. const ui = pe(j, "qpSum");
  15558. ae.push(fe(ui, 1 / (j.framesPerSecond || 1), 51)), Q.push(fe(j.framesDropped));
  15559. const hi = pe(j, "totalFreezesDuration");
  15560. te.push(fe(hi, 1e3, 3e4));
  15561. const We = pe(j, "jitterBufferEmittedCount"), mt = pe(j, "jitterBufferDelay");
  15562. mt && We ? ee.push(fe(mt, 1e3 / We, 3e4)) : ee.push(0);
  15563. const di = pe(j, "jitterBufferTargetDelay");
  15564. di && We ? k.push(fe(di, 1e3 / We, 3e4)) : k.push(0);
  15565. const Zt = pe(j, "jitterBufferMinimumDelay");
  15566. Zt && We ? L.push(fe(Zt, 1e3 / We, 3e4)) : L.push(0);
  15567. }
  15568. }), c.rbr = o.join(","), c.mbrs = u.join(","), c.pbrs = h.join(","), c.pr = p.join(","), c.pl = d.join(","), c.plr = f.join(","), c.jd = m.join(","), c.fecr = b.join(","), c.retransr = l.join(","), c.baser = S.join(","), c.basel = v.join(","), c.recoverr = N.join(","), c.alll = v.join(","), c.totalc = x.join(","), n ? (c.er = E.join(","), c.aolevel = _.join(","), c.asrc = R.join(","), c.scnt = y.join(","), c.sdura = A.join(",")) : (c.dm = M.join(","), c.dfps = C.join(","), c.rfps = I.join(","), c.rh = P.join(","), c.rw = B.join(","), c.fpt = G.join(","), c.ns = X.join(","), c.pliss = q.join(","), c.aqp = ae.join(","), c.ofimax = N.join(","), c.ofimin = N.join(","), c.dfimax = N.join(","), c.dfimin = N.join(","), c.rfimax = N.join(","), c.rfimin = N.join(","), c.vrstutter = te.join(","), c.cdm = ee.join(","), c.tdm = k.join(","), c.pdm = L.join(","), c.ofps = F.join(","), c.dfbd = Q.join(","));
  15569. } catch (j) {
  15570. }
  15571. this.log({
  15572. evetid: 10080,
  15573. traceid: t,
  15574. rmtid: e,
  15575. calid: a,
  15576. args: this.data2String(J({
  15577. calid: a,
  15578. rmtid: e,
  15579. tckid: i,
  15580. traceid: t
  15581. }, c))
  15582. });
  15583. }
  15584. reportNetworkMonitor(a) {
  15585. if (a.length <= 0)
  15586. return;
  15587. const e = [], t = [], i = [], s = [], n = [], c = [], o = [], u = [], h = [], p = [];
  15588. a.forEach((f, m) => {
  15589. var S;
  15590. if (!f.timestamp)
  15591. return;
  15592. const l = (S = f._last) != null && S.timestamp ? f.timestamp - f._last.timestamp : 1e3;
  15593. e.push(fe(f.currentRoundTripTime, 1e3)), t.push(fe(f.availableOutgoingBitrate, 8, 2e8)), i.push(Ge(fe(f.bytesSent, 8, 2e7), l, 25e6)), s.push(Ge(fe(f.bytesReceived, 8, 2e7), l, 25e6)), n.push(0), c.push(0), m % 5 === 0 && (o.push(""), u.push(""), h.push(""), p.push(""));
  15594. });
  15595. const d = {
  15596. ctm: Math.floor(a[0].timestamp || 0),
  15597. rtt: e.join(","),
  15598. bsps: i.join(","),
  15599. brps: s.join(","),
  15600. cpu: o.join(","),
  15601. mem: u.join(","),
  15602. sysmem: h.join(","),
  15603. systotalmem: p.join(","),
  15604. audioonly: this.engine.isAudioOnly() ? 1 : 0
  15605. };
  15606. this.log({
  15607. evetid: 10071,
  15608. args: this.data2String(J({
  15609. asb: t.join(","),
  15610. abms: n.join(","),
  15611. vbms: c.join(",")
  15612. }, d))
  15613. }), this.log({
  15614. evetid: 10081,
  15615. args: this.data2String(J({}, d))
  15616. });
  15617. }
  15618. /**
  15619. * 加入房间成功埋点
  15620. * @param {number} joinTime
  15621. * @param {number} result
  15622. * @param {string} tid
  15623. */
  15624. reportJoin(a, e, t = "") {
  15625. var p, d;
  15626. const { start: i, rs: s = 0, re: n = 0 } = e, c = Date.now() - i, o = n - s;
  15627. let u = 0;
  15628. s && (u = s - i);
  15629. let h = 0;
  15630. n && (h = n - s), this.log({
  15631. evetid: 10010,
  15632. args: this.data2String({
  15633. sesid: ((p = this.authInfo) == null ? void 0 : p.sessionId) || "",
  15634. joitm: c,
  15635. rslt: a,
  15636. gslbtm: 0,
  15637. dnstm: 0,
  15638. avcftm: 0,
  15639. gslbrslt: 0,
  15640. dnsrslt: 0,
  15641. avcfrslt: 0,
  15642. mode: 2,
  15643. jrtc: o,
  15644. usrn: (d = this.authInfo) == null ? void 0 : d.userId,
  15645. mgt: "cdn",
  15646. cttc: u,
  15647. iptc: h,
  15648. ndn: 1,
  15649. gslbloc: 1,
  15650. ccag: 0,
  15651. ucag: 0,
  15652. cpg: 0,
  15653. upg: 0,
  15654. tid: t
  15655. })
  15656. });
  15657. }
  15658. /**
  15659. * Join 链接细节
  15660. */
  15661. reportJoinConnection(a) {
  15662. this.log({
  15663. evetid: 20002,
  15664. args: this.data2String(J({
  15665. transretrynum: 0,
  15666. ldnstc: 0,
  15667. tcptc: 0,
  15668. ssltc: 0,
  15669. url: ""
  15670. }, a))
  15671. });
  15672. }
  15673. /**
  15674. * 用户离开频道事件埋点
  15675. * @param {number} leaveTime
  15676. * @param {number} result
  15677. * @param {string} tid
  15678. */
  15679. reportLeave(a, e, t) {
  15680. this.log({
  15681. evetid: 10020,
  15682. args: this.data2String({
  15683. lvetm: a,
  15684. rslt: e,
  15685. tid: t
  15686. })
  15687. });
  15688. }
  15689. /**
  15690. * 推流事件上报
  15691. * @param {string} callid
  15692. * @param {boolean} isLargeVideo
  15693. * @param {boolean} isSmallVideo
  15694. * @param {boolean} isScreenShare
  15695. * @param {boolean} isAudio
  15696. * @param {number} result
  15697. * @param {string} tid
  15698. * @param {number} pubTime
  15699. */
  15700. reportPublish(a, e, t, i, s, n, c, o, u, h, p) {
  15701. this.log({
  15702. evetid: a ? 10032 : 10030,
  15703. calid: t,
  15704. args: this.data2String({
  15705. calid: t,
  15706. url: e,
  15707. isvl: i ? 1 : 0,
  15708. isvs: s ? 1 : 0,
  15709. isvss: n ? 1 : 0,
  15710. isaudio: c ? 1 : 0,
  15711. rslt: o,
  15712. tid: "123",
  15713. pubtm: Date.now() - p,
  15714. pctid: u,
  15715. pubtid: h,
  15716. isvp: 0,
  15717. isarecording: 0,
  15718. isad: 0,
  15719. isdc: 0,
  15720. // TODO... 后续完善重试逻辑
  15721. pubretry: 0,
  15722. pbrttimes: 0
  15723. })
  15724. });
  15725. }
  15726. /**
  15727. * 首包上报
  15728. * @param {string} callid
  15729. * @param {number} startTime
  15730. * @param {number} publishTime
  15731. * @param {number} joinTime
  15732. * @param {string} tckid
  15733. * @param {string} pcTraceId
  15734. * @param {string} traceId
  15735. * @param {PublishReason} reason
  15736. */
  15737. reportPublishFirstPacket(a, e, t, i, s, n, c, o, u) {
  15738. const h = Date.now();
  15739. this.log({
  15740. evetid: a ? 10033 : 10031,
  15741. calid: e,
  15742. args: this.data2String({
  15743. calid: e,
  15744. fpst: h - t,
  15745. tckid: n,
  15746. est: t,
  15747. pctid: c,
  15748. pubtid: o,
  15749. totaltm: h - s,
  15750. jorm: u === nt.JOIN_CHANNEL ? 1 : 0,
  15751. cptc: 0,
  15752. sptc: i - t,
  15753. iptc: 0,
  15754. ipc2fptc: 0,
  15755. dctc: 0,
  15756. patc: 0
  15757. })
  15758. });
  15759. }
  15760. /**
  15761. * 停止推流事件上报
  15762. * @param {string} callid
  15763. * @param {number} unpubTime
  15764. * @param {number} result
  15765. * @param {string} tid
  15766. */
  15767. reportUnpublish(a, e, t, i) {
  15768. var s;
  15769. this.log({
  15770. evetid: 10040,
  15771. args: this.data2String({
  15772. calid: a,
  15773. unpubtm: e,
  15774. rslt: t,
  15775. tid: i,
  15776. sesid: ((s = this.authInfo) == null ? void 0 : s.sessionId) || ""
  15777. })
  15778. });
  15779. }
  15780. /**
  15781. * 订阅事件埋点
  15782. * @param {string} callid
  15783. * @param {string} remoteid
  15784. * @param {boolean} isLargeVideo
  15785. * @param {boolean} isSmallVideo
  15786. * @param {boolean} isScreenShare
  15787. * @param {boolean} isAudio
  15788. * @param {number} result
  15789. * @param {string} tid
  15790. * @param {number} subTime
  15791. */
  15792. reportSubscribe(a, e, t, i, s, n, c, o, u, h) {
  15793. this.log({
  15794. evetid: 10050,
  15795. calid: a,
  15796. rmtid: e,
  15797. args: this.data2String(J({
  15798. calid: a,
  15799. rmtid: e,
  15800. isvl: t ? 1 : 0,
  15801. isvs: i ? 1 : 0,
  15802. isvss: s ? 1 : 0,
  15803. isaudio: n ? 1 : 0,
  15804. rslt: c,
  15805. tid: o,
  15806. subtm: u,
  15807. isvp: 0,
  15808. isaplaying: 0,
  15809. isad: 0,
  15810. isdc: 0,
  15811. subretry: 0,
  15812. sbrttimes: 0
  15813. }, h))
  15814. });
  15815. }
  15816. reportSubscribeFirstPacket(a, e, t, i, s) {
  15817. this.log({
  15818. evetid: a ? 10054 : 10051,
  15819. calid: e,
  15820. rmtid: t,
  15821. args: this.data2String(J({
  15822. calid: e,
  15823. rmtid: t,
  15824. tckid: i,
  15825. cptc: 0,
  15826. iptc: 0,
  15827. ipc2fptc: 0,
  15828. dctc: 0,
  15829. patc: 0
  15830. }, s))
  15831. });
  15832. }
  15833. reportSubscribeFirstFrame(a, e, t, i, s) {
  15834. this.log({
  15835. evetid: a ? 10055 : 10052,
  15836. calid: e,
  15837. rmtid: t,
  15838. args: this.data2String(J({
  15839. calid: e,
  15840. rmtid: t,
  15841. tckid: i
  15842. }, s))
  15843. }), this.log({
  15844. evetid: a ? 10058 : 10057,
  15845. args: this.data2String(J({
  15846. calid: e,
  15847. rmtid: t,
  15848. tckid: i
  15849. }, s))
  15850. });
  15851. }
  15852. /**
  15853. * 停止订阅事件埋点
  15854. * @param {string} callid
  15855. * @param {string} remoteid
  15856. * @param {number} unsubTime
  15857. * @param {number} result
  15858. * @param {string} tid
  15859. */
  15860. reportUnsubscribe(a, e, t, i, s) {
  15861. this.log({
  15862. evetid: 10060,
  15863. calid: a,
  15864. args: this.data2String({
  15865. calid: a,
  15866. rmtid: e,
  15867. unsubtm: t,
  15868. rslt: i,
  15869. tid: s
  15870. })
  15871. });
  15872. }
  15873. reportMute(a, e, t) {
  15874. this.log({
  15875. evetid: 11030,
  15876. args: this.data2String({
  15877. calid: a,
  15878. rmtid: "",
  15879. enable: e ? 1 : 0,
  15880. mt: t
  15881. })
  15882. });
  15883. }
  15884. /**
  15885. * 更新角色埋点
  15886. * @param {string|undefined} or 旧的角色
  15887. * @param {string} nr 新的角色
  15888. */
  15889. reportRoleUpdate(a, e) {
  15890. this.log({
  15891. evetid: 11040,
  15892. args: this.data2String({
  15893. or: a || "",
  15894. nr: e,
  15895. ctm: Date.now(),
  15896. rslt: 0
  15897. })
  15898. });
  15899. }
  15900. /**
  15901. * 更新角色埋点
  15902. * @param {string|undefined} or 旧的角色
  15903. * @param {string} nr 新的角色
  15904. */
  15905. reportRoleUpdateResult(a, e, t, i) {
  15906. this.log({
  15907. evetid: 11041,
  15908. args: this.data2String({
  15909. or: a || "",
  15910. nr: e,
  15911. ctm: t,
  15912. rslt: i
  15913. })
  15914. });
  15915. }
  15916. /**
  15917. * 设置camera videoprofile
  15918. */
  15919. reportVideoProfile(a) {
  15920. this.log({
  15921. evetid: 20074,
  15922. args: this.data2String({
  15923. pf: a,
  15924. tckid: "sophon_camera_large"
  15925. })
  15926. });
  15927. }
  15928. /**
  15929. * 设置screenshare videoprofile
  15930. */
  15931. reportScreenProfile(a) {
  15932. this.log({
  15933. evetid: 20074,
  15934. args: this.data2String({
  15935. pf: a,
  15936. tckid: "sophon_screenshare"
  15937. })
  15938. });
  15939. }
  15940. /**
  15941. * 错误事件埋点
  15942. * @param err
  15943. */
  15944. reportError(a) {
  15945. this.log({
  15946. evetid: 10091,
  15947. args: this.data2String({
  15948. rslt: (a == null ? void 0 : a.code) || -1
  15949. })
  15950. });
  15951. }
  15952. /**
  15953. * 错误事件埋点
  15954. * @param err
  15955. */
  15956. reportWarning(a) {
  15957. this.log({
  15958. evetid: 10092,
  15959. args: this.data2String({
  15960. rslt: -1,
  15961. errmsg: a
  15962. })
  15963. });
  15964. }
  15965. reportRoomServerEvent(a, e, t, i) {
  15966. this.log({
  15967. evetid: 20005,
  15968. args: this.data2String({
  15969. calid: "",
  15970. rmtid: "",
  15971. rt: a ? 0 : 1,
  15972. dr: a ? "s" : "r",
  15973. mt: e,
  15974. ri: t,
  15975. cs: 1,
  15976. srt: Date.now(),
  15977. rspc: (i == null ? void 0 : i.code) || "",
  15978. mc: JSON.stringify(i)
  15979. })
  15980. });
  15981. }
  15982. reportTranscodingError(a, e) {
  15983. this.log({
  15984. evetid: 10101,
  15985. args: this.data2String({
  15986. rslt: a,
  15987. taskid: e
  15988. })
  15989. });
  15990. }
  15991. reportBye(a) {
  15992. var e;
  15993. this.log({
  15994. evetid: 10093,
  15995. args: this.data2String({
  15996. rslt: a,
  15997. sesid: ((e = this.authInfo) == null ? void 0 : e.sessionId) || ""
  15998. })
  15999. });
  16000. }
  16001. reportAudio(a, e, t) {
  16002. var i;
  16003. this.log({
  16004. evetid: 80013,
  16005. args: this.data2String({
  16006. rslt: a ? -1 : 0,
  16007. adm: 1,
  16008. adt: 0,
  16009. adr: a ? 2 : 0,
  16010. acms: e,
  16011. adrpn: t
  16012. })
  16013. }), this.log({
  16014. evetid: 80014,
  16015. args: this.data2String({
  16016. sesid: ((i = this.authInfo) == null ? void 0 : i.sessionId) || "",
  16017. rslt: a ? -1 : 0,
  16018. adm: 1,
  16019. adt: 0,
  16020. adr: a ? 2 : 0,
  16021. acms: e,
  16022. adrpn: t
  16023. })
  16024. });
  16025. }
  16026. reportScreen(a, e) {
  16027. var t, i, s, n;
  16028. this.log({
  16029. evetid: 90013,
  16030. args: this.data2String({
  16031. rslt: a ? -1 : 0,
  16032. vcms: e,
  16033. vde: (t = a == null ? void 0 : a.code) != null ? t : -1,
  16034. sesid: ((i = this.authInfo) == null ? void 0 : i.sessionId) || ""
  16035. })
  16036. }), this.log({
  16037. evetid: 90014,
  16038. args: this.data2String({
  16039. rslt: a ? -1 : 0,
  16040. vcms: e,
  16041. vde: (s = a == null ? void 0 : a.code) != null ? s : -1,
  16042. sesid: ((n = this.authInfo) == null ? void 0 : n.sessionId) || ""
  16043. })
  16044. });
  16045. }
  16046. reportScreenStop(a) {
  16047. this.log({
  16048. evetid: 90019,
  16049. args: this.data2String({
  16050. rslt: a ? a.code || -1 : 0
  16051. })
  16052. }), this.log({
  16053. evetid: 90020,
  16054. args: this.data2String({
  16055. rslt: a ? a.code || -1 : 0
  16056. })
  16057. });
  16058. }
  16059. reportSwitchCamera(a) {
  16060. var e;
  16061. this.log({
  16062. evetid: 90025,
  16063. args: this.data2String({
  16064. rslt: 0,
  16065. td: a,
  16066. sesid: ((e = this.authInfo) == null ? void 0 : e.sessionId) || ""
  16067. })
  16068. });
  16069. }
  16070. reportPublishProfile(a, e) {
  16071. this.log({
  16072. evetid: 10201,
  16073. args: this.data2String(J({
  16074. tckid: a
  16075. }, e))
  16076. });
  16077. }
  16078. reportSDKCreated(a) {
  16079. this.log({
  16080. evetid: 70011,
  16081. createtm: Date.now() - a,
  16082. tm: a
  16083. });
  16084. }
  16085. reportJoinInvoked(a) {
  16086. this.log({
  16087. evetid: 70012,
  16088. jnnonce: a.nonce || "",
  16089. jntoken: a.token || "",
  16090. jntm: a.timestamp || ""
  16091. });
  16092. }
  16093. reportJoinResult(a) {
  16094. this.log({
  16095. evetid: 70013,
  16096. rslt: a ? a.code || -1 : 0,
  16097. dnsrslt: 0
  16098. });
  16099. }
  16100. reportSTSResult(a, e) {
  16101. this.log({
  16102. evetid: 70014,
  16103. rslt: a,
  16104. asty: 1,
  16105. reqtm: Date.now() - e
  16106. });
  16107. }
  16108. reportLeaveInvoked() {
  16109. this.log({
  16110. evetid: 70015
  16111. /* LEAVE_INVOKED */
  16112. });
  16113. }
  16114. reportSEIMessage(a, e, t, i, s) {
  16115. this.log({
  16116. evetid: 40301,
  16117. args: this.data2String({
  16118. tm: Date.now(),
  16119. sei_pt: a,
  16120. sei_len: e,
  16121. sei_rep: t,
  16122. sei_delay: i,
  16123. sei_key: s
  16124. })
  16125. });
  16126. }
  16127. /**
  16128. * 接通耗时事件(12001)
  16129. * 用stage和status来区分接通过程中各个时间节点。
  16130. * @param state
  16131. * @param status
  16132. * @param calid
  16133. * @param tckid
  16134. */
  16135. reportConnectionLatencyEvent(a, e, t, i, s, n, c = !1) {
  16136. const o = {
  16137. ageniid: this.getCustomField("ageniid")
  16138. }, u = J({
  16139. tm: s || Date.now(),
  16140. ntptm: n || this.ntpClock.now(),
  16141. stage: a,
  16142. status: e,
  16143. calid: t,
  16144. tckid: i,
  16145. cltp: 1,
  16146. // AI场景profile:0,非ai场景;1,真人;2,机器人。
  16147. http: c ? 1 : 0
  16148. }, o);
  16149. this.log({
  16150. evetid: 12001,
  16151. args: this.data2String(u)
  16152. });
  16153. }
  16154. /**
  16155. * 日志埋点
  16156. * 在埋点中增加tm字段,表示发生埋点的客户端本地时间
  16157. * @param {any} param 埋点内容
  16158. */
  16159. log(a) {
  16160. a && (a.tm = (/* @__PURE__ */ new Date()).getTime(), O.debug("[ConsoleLogger]", "log", a), this.logClient.sendReport(a));
  16161. }
  16162. /**
  16163. * 将Object转换成string
  16164. * @param {any} data
  16165. * @returns {string}
  16166. */
  16167. data2String(a) {
  16168. let e = "";
  16169. for (let t in a)
  16170. e.length && (e += "&"), e += t + "=" + a[t];
  16171. return e;
  16172. }
  16173. };
  16174. g(si, "staticClient");
  16175. let $r = si;
  16176. var qc = Object.defineProperty, Jc = Object.getOwnPropertyDescriptor, W = (r, a, e, t) => {
  16177. for (var i = t > 1 ? void 0 : t ? Jc(a, e) : a, s = r.length - 1, n; s >= 0; s--)
  16178. (n = r[s]) && (i = (t ? n(a, e, i) : n(i)) || i);
  16179. return t && i && qc(a, e, i), i;
  16180. }, K;
  16181. const z = (K = class extends De {
  16182. constructor(e) {
  16183. super();
  16184. g(this, "channelProfile");
  16185. g(this, "clientRole");
  16186. g(this, "signalingManager");
  16187. g(this, "bizControl");
  16188. g(this, "liveTranscoding");
  16189. g(this, "maxSignalingConnectRetryCount");
  16190. // 房间信令重连最大次数
  16191. g(this, "slsReporter");
  16192. g(this, "connectState", ue.AliRtcConnectionStatusInit);
  16193. g(this, "networkError", !1);
  16194. g(this, "_audioOnlyMode", !1);
  16195. g(this, "_authInfoWillExpireTimer", null);
  16196. g(this, "_authInfoExpiredTimer", null);
  16197. g(this, "_serverCheckAuthInfoTimestamp", null);
  16198. g(this, "_localCheckAuthInfoTimestamp", null);
  16199. const t = Date.now();
  16200. O.init(), this.slsReporter = new $r(this), this.channelProfile = bt.AliRtcSdkCommunication, this.clientRole = Nt.AliRtcSdkLive, this.liveTranscoding = new Uc(this.slsReporter), this.signalingManager = new ns(
  16201. this.channelProfile,
  16202. this.clientRole,
  16203. this.slsReporter,
  16204. (e == null ? void 0 : e.env) === pt.pre ? pt.pre : pt.prod
  16205. ), this.addSignalingManagerListeners(), this.maxSignalingConnectRetryCount = e == null ? void 0 : e.maxSignalingConnectRetryCount, this.bizControl = new Pe({
  16206. slsReporter: this.slsReporter,
  16207. signalingManager: this.signalingManager
  16208. }), this.addBizControlListeners(), this.addPublisherListeners(), this.slsReporter.reportConnectionLatencyEvent(
  16209. Je.CREATE_ENGINE,
  16210. Xe.START,
  16211. "",
  16212. "",
  16213. t
  16214. ), this.slsReporter.reportConnectionLatencyEvent(
  16215. Je.CREATE_ENGINE,
  16216. Xe.END,
  16217. "",
  16218. "",
  16219. Date.now()
  16220. ), this.slsReporter.reportSDKCreated(t);
  16221. }
  16222. static getSdkVersion() {
  16223. return yi;
  16224. }
  16225. static setLogLevel(e) {
  16226. O.setLogLevel(e);
  16227. }
  16228. /**
  16229. * @brief 获取AliRtcEngine实例
  16230. * @param key key 可选参与,用于创建多个实例
  16231. * @details 该方法为同步调用,以单例的形式提供对象创建。
  16232. */
  16233. static getInstance(e) {
  16234. return K._instance || (K._instance = new K(e)), K._instance;
  16235. }
  16236. destroy() {
  16237. return w(this, null, function* () {
  16238. K._instance = void 0, yield this.leaveChannel(), yield this.bizControl.clear(), O.destroy();
  16239. });
  16240. }
  16241. /**
  16242. * 获取当前频道号,已经入会成功返回频道号,否则返回undefined
  16243. */
  16244. get channel() {
  16245. return this.bizControl.channel;
  16246. }
  16247. /**
  16248. * 获取当前用户的 userId,已经入会成功返回自己的 userId,否则返回 undefined
  16249. */
  16250. get userId() {
  16251. return this.bizControl.userId;
  16252. }
  16253. get remoteUsers() {
  16254. return this.bizControl.remoteUsers;
  16255. }
  16256. get publisher() {
  16257. return this.bizControl.publisher;
  16258. }
  16259. get publishAudioStream() {
  16260. var e;
  16261. return (e = this.publisher) == null ? void 0 : e.publishStreams.audio;
  16262. }
  16263. get isPublishing() {
  16264. const { publisher: e } = this.bizControl;
  16265. return e ? e.isPublishing : !1;
  16266. }
  16267. get currentRoleCanPublish() {
  16268. return this.channelProfile === bt.AliRtcSdkCommunication || this.clientRole === Nt.AliRtcSdkInteractive;
  16269. }
  16270. /**
  16271. * 监听 Publisher 事件
  16272. */
  16273. addPublisherListeners() {
  16274. var e, t, i, s, n, c, o, u, h, p;
  16275. (e = this.publisher) == null || e.on(Le.Local, (d) => {
  16276. O.event("[Publisher] Device Status Change", d), this.onLocalDeviceStatusChange(d);
  16277. }), (t = this.publisher) == null || t.on(Vt.VideoTrackEnded, () => {
  16278. O.event("[Publisher] VideoTrack Ended"), this.emit(
  16279. "localDeviceException",
  16280. dt.AliEngineLocalDeviceTypeCamera,
  16281. _e.AliEngineLocalDeviceExceptionTypeCameraInterrupt,
  16282. ""
  16283. );
  16284. }), (i = this.publisher) == null || i.on(Vt.ScreenTrackEnded, () => {
  16285. O.event("[Publisher] ScreenTrack Ended"), this.emit(
  16286. "localDeviceException",
  16287. dt.AliEngineLocalDeviceTypeDisplay,
  16288. _e.AliEngineLocalDeviceExceptionTypeDisplayException,
  16289. ""
  16290. );
  16291. }), (s = this.publisher) == null || s.on(Vt.AudioTrackEnded, () => {
  16292. O.event("[Publisher] AudioTrack Ended"), this.emit(
  16293. "localDeviceException",
  16294. dt.AliEngineLocalDeviceTypeMic,
  16295. _e.AliEngineLocalDeviceExceptionTypeMicInterrupt,
  16296. ""
  16297. );
  16298. }), (n = this.publisher) == null || n.on(
  16299. "localDeviceException",
  16300. (d, f, m = "") => {
  16301. this.emit("localDeviceException", d, f, m);
  16302. }
  16303. ), (c = this.publisher) == null || c.on("audioPublishStateChanged", (d, f, m) => {
  16304. var l;
  16305. this.emit("audioPublishStateChanged", d, f, m, (l = this.channel) != null ? l : "");
  16306. }), (o = this.publisher) == null || o.on("videoPublishStateChanged", (d, f, m) => {
  16307. var l;
  16308. this.emit("videoPublishStateChanged", d, f, m, (l = this.channel) != null ? l : "");
  16309. }), (u = this.publisher) == null || u.on("dualStreamPublishStateChanged", (d, f, m) => {
  16310. var l;
  16311. this.emit("dualStreamPublishStateChanged", d, f, m, (l = this.channel) != null ? l : "");
  16312. }), (h = this.publisher) == null || h.on("screenPublishStateChanged", (d, f, m) => {
  16313. var l;
  16314. this.emit("screenSharePublishStateChanged", d, f, m, (l = this.channel) != null ? l : "");
  16315. }), (p = this.publisher) == null || p.on("dataPublishStateChanged", (d, f, m) => {
  16316. var l;
  16317. this.emit("dataPublishStateChanged", d, f, m, (l = this.channel) != null ? l : "");
  16318. });
  16319. }
  16320. occurError(e, t) {
  16321. O.event(`[${K.logName}]`, "Occur Error", e, t), this.emit("onOccurError", e, t), this.emit("occurError", e, t);
  16322. }
  16323. /**
  16324. * 监听 UM 事件
  16325. */
  16326. addBizControlListeners() {
  16327. this.bizControl.rtsManager.on("connected", (e) => {
  16328. var t;
  16329. e && ((t = this.publisher) == null || t.publishUpdate(nt.RECONNECT), this.remoteUsers.forEach((i) => {
  16330. i.updateSubscribe(de.Reconnect);
  16331. }));
  16332. }), this.bizControl.rtsManager.on("disconnected", () => w(this, null, function* () {
  16333. O.event(`[${K.logName}]`, "RTS Disconnected"), (yield He.isNetworkAvailable()) ? this.onNetworkRecovery() : this.onNetworkError();
  16334. })), this.bizControl.rtsManager.on("subscribeexceeds", () => w(this, null, function* () {
  16335. yield this.resumePublishForNetworkRecovery(), yield this.resumeSubList();
  16336. })), this.bizControl.rtsManager.on("seimessage", (e, t, i) => {
  16337. const s = this.remoteUsers.find((n) => n.streamUrl === e);
  16338. s && this.emit("mediaExtensionMsgReceived", s.userId, i, t);
  16339. }), this.bizControl.on(Le.Remote, (e, t) => {
  16340. O.event(`[${K.logName}]`, "RemoteUser Device Status Change", e, t);
  16341. }), this.bizControl.on("remoteTrackAvailableChange", (e, t, i) => {
  16342. this.emit("remoteTrackAvailableNotify", e, t, i);
  16343. }), this.bizControl.on("audioSubscribeStateChanged", (e, t, i, s, n) => {
  16344. this.emit("audioSubscribeStateChanged", e, t, i, s, n);
  16345. }), this.bizControl.on("videoSubscribeStateChanged", (e, t, i, s, n) => {
  16346. this.emit("videoSubscribeStateChanged", e, t, i, s, n);
  16347. }), this.bizControl.on("screenSubscribeStateChanged", (e, t, i, s, n) => {
  16348. this.emit("screenShareSubscribeStateChanged", e, t, i, s, n);
  16349. }), this.bizControl.on("dataSubscribeStateChanged", (e, t, i, s, n) => {
  16350. this.emit("dataSubscribeStateChanged", e, t, i, s, n);
  16351. }), this.bizControl.on("userAudioMuted", (e, t) => {
  16352. this.emit("userAudioMuted", e, t);
  16353. }), this.bizControl.on("userVideoMuted", (e, t) => {
  16354. this.emit("userVideoMuted", e, t);
  16355. }), this.bizControl.on("userScreenMuted", (e, t) => {
  16356. this.emit("userScreenMuted", e, t);
  16357. }), this.bizControl.on("audioVolume", (e) => {
  16358. this.emit("audioVolume", e);
  16359. }), this.bizControl.on("remoteAudioAutoPlayFail", (e) => {
  16360. this.emit("remoteAudioAutoPlayFail", e);
  16361. }), this.bizControl.on("remoteVideoAutoPlayFail", (e, t) => {
  16362. this.emit("remoteVideoAutoPlayFail", e, t);
  16363. }), this.bizControl.on("remoteAudioPlayError", (e, t) => {
  16364. this.emit("remoteAudioPlayError", e, t);
  16365. }), this.bizControl.on("remoteVideoPlayError", (e, t) => {
  16366. this.emit("remoteVideoPlayError", e, t);
  16367. }), this.bizControl.on("rtcStats", (e) => {
  16368. this.emit("rtcStats", e);
  16369. }), this.bizControl.on("rtcLocalAudioStats", (e) => {
  16370. this.emit("rtcLocalAudioStats", e);
  16371. }), this.bizControl.on("rtcLocalVideoStats", (e) => {
  16372. this.emit("rtcLocalVideoStats", e);
  16373. }), this.bizControl.on("rtcRemoteAudioStats", (e) => {
  16374. this.emit("rtcRemoteAudioStats", e);
  16375. }), this.bizControl.on("rtcRemoteVideoStats", (e) => {
  16376. this.emit("rtcRemoteVideoStats", e);
  16377. }), this.bizControl.on("remoteSubscribeError", (e, t) => {
  16378. this.occurError(e, t), this.slsReporter.reportError(e);
  16379. }), this.bizControl.on("occurError", (e, t) => {
  16380. this.occurError(e, t), this.slsReporter.reportError(e);
  16381. }), this.bizControl.on("remoteDataChannelMessage", (e, t) => {
  16382. this.emit("dataChannelMsg", e, t);
  16383. });
  16384. }
  16385. /**
  16386. * 添加信令处理
  16387. * @returns {void}
  16388. */
  16389. addSignalingManagerListeners() {
  16390. this.signalingManager.on("onKeepAliveRsp", () => {
  16391. this.networkError && (O.event("[Signaling] Receive KeepAlive Response", `networkError: ${this.networkError}`), this.onNetworkRecovery());
  16392. }), this.signalingManager.on("onNotifyJoin", (e) => {
  16393. O.event("[Signaling] Notify Join ", e), this.handleUsersJoin(e), e.forEach((t) => {
  16394. this.emit("remoteUserOnLineNotify", t.userid, 0);
  16395. });
  16396. }), this.signalingManager.on("onNotifyStatus", (e) => {
  16397. O.event("[Signaling] Notify Status ", e), e.forEach((t) => {
  16398. this.bizControl.updateRemoteUserDeviceStatus(t);
  16399. });
  16400. }), this.signalingManager.on("onNotifyLeave", (e) => {
  16401. O.event("[Signaling] Notify Leave ", e), e.forEach((t) => w(this, null, function* () {
  16402. yield this.bizControl.removeLeftUser(t), this.emit("remoteUserOffLineNotify", t.userid, t.leavecode);
  16403. }));
  16404. }), this.signalingManager.on("onBye", (e, t) => {
  16405. O.event("[Signaling] Bye ", e, t), this.slsReporter.reportError({
  16406. message: `reason: ${e}, description: ${t}`
  16407. }), this.emit("bye", e), this.leaveChannel(), this.slsReporter.reportBye(e);
  16408. }), this.signalingManager.on("onConnectFail", (e) => {
  16409. O.event("[Signaling] Connect Failed ", e), this.onError(e), this.backToUnpublishStatus(), this.connectState = ue.AliRtcConnectionStatusFailed, this.emit(
  16410. "connectionStatusChange",
  16411. ue.AliRtcConnectionStatusFailed,
  16412. Wt.AliRtcConnectionChangedNetworkInterrupted
  16413. );
  16414. }), this.signalingManager.on("onNetworkError", (e) => {
  16415. this.slsReporter.reportWarning("signaling network error"), O.event("[Signaling] Network error ", e), this.onNetworkError();
  16416. }), this.signalingManager.on("onAuthInvalid", () => {
  16417. O.event("[Signaling] Auth Invalid");
  16418. }), this.signalingManager.on("onReconnectStart", () => {
  16419. O.event("[Signaling] Reconnect Start "), this.connectState = ue.AliRtcConnectionStatusReconnecting, this.emit(
  16420. "connectionStatusChange",
  16421. ue.AliRtcConnectionStatusReconnecting,
  16422. Wt.AliRtcConnectionSignalingConnecting
  16423. );
  16424. }), this.signalingManager.on("onReconnectSuccess", (e) => {
  16425. O.event("[Signaling] Reconnect Success ", e), this.onNetworkRecovery(e);
  16426. }), this.signalingManager.on("onReconnectFail", (e) => {
  16427. this.slsReporter.reportWarning("signaling reconnect fail: ${err.code}"), O.event("[Signaling] Reconnect Failed ", e), e.code === 403 && this.emit("authInfoExpired");
  16428. }), this.signalingManager.on("onError", (e) => {
  16429. this.slsReporter.reportWarning("signaling error: ${err.message}"), O.event("[Signaling] Error ", e), this.onError(e);
  16430. });
  16431. }
  16432. backToUnpublishStatus() {
  16433. var e, t;
  16434. this.connectState = ue.AliRtcConnectionStatusDisconnected, (e = this.publisher) != null && e.isPublishing && ((t = this.publisher) == null || t.clearPublishState()), this.networkError = !1;
  16435. }
  16436. /**
  16437. * 处理入会远程的用户
  16438. * @param {JoinInfo[]} users
  16439. * @returns {void}
  16440. */
  16441. handleUsersJoin(e) {
  16442. e.forEach((t) => {
  16443. const i = t.userid;
  16444. if (i) {
  16445. const s = this.bizControl.addUser(i, t.displayname, de.Join);
  16446. O.event(`[${K.logName}]`, oe.UserJoined, s);
  16447. }
  16448. });
  16449. }
  16450. /**
  16451. * 本地用户设备状态变化,通过信令发送给其他人
  16452. * @param {string} status
  16453. * @returns {void}
  16454. */
  16455. onLocalDeviceStatusChange(e) {
  16456. O.event(`[${K.logName}]`, Le.Local, e), this.signalingManager.reportStatus(e).then(() => {
  16457. O.debug("[signaling] reportStatus suc");
  16458. }).catch((t) => {
  16459. O.error("[signaling] reportStatus failed", t);
  16460. });
  16461. }
  16462. resumePublishForNetworkRecovery() {
  16463. return w(this, null, function* () {
  16464. var e;
  16465. try {
  16466. yield (e = this.publisher) == null ? void 0 : e.resumePublish();
  16467. } catch (t) {
  16468. const { code: i } = t;
  16469. if (i === 10205) {
  16470. let n = 1;
  16471. try {
  16472. yield new Promise((c, o) => {
  16473. const u = setInterval(() => w(this, null, function* () {
  16474. var h;
  16475. n > 1 && (clearInterval(u), o()), n += 1;
  16476. try {
  16477. yield (h = this.publisher) == null ? void 0 : h.resumePublish(), clearInterval(u), c();
  16478. } catch (p) {
  16479. const { code: d } = p;
  16480. d !== 10205 && (clearInterval(u), o());
  16481. }
  16482. }), 1e3);
  16483. });
  16484. } catch (c) {
  16485. }
  16486. }
  16487. throw t;
  16488. }
  16489. });
  16490. }
  16491. onNetworkRecovery(e) {
  16492. return w(this, null, function* () {
  16493. var t;
  16494. O.event(
  16495. K.logName,
  16496. "onNetworkRecovery",
  16497. `rts isConnected: ${this.bizControl.rtsManager.isConnected}; rts isConnecting: ${this.bizControl.rtsManager.isConnecting}`,
  16498. { users: e }
  16499. ), !this.bizControl.rtsManager.isConnected && !this.bizControl.rtsManager.isConnecting ? (this.currentRoleCanPublish && (yield this.resumePublishForNetworkRecovery()), yield this.resumeSubList()) : e && (yield this.resumeSubList(e)), this.networkError && (this.networkError = !1, (t = this.publisher) == null || t.reportSelfDeviceStatus(), this.connectState = ue.AliRtcConnectionStatusConnected, this.emit(
  16500. "connectionStatusChange",
  16501. ue.AliRtcConnectionStatusConnected,
  16502. Wt.AliRtcConnectionSignalingHeartbeatAlive
  16503. ));
  16504. });
  16505. }
  16506. resumeSubList(e) {
  16507. return w(this, null, function* () {
  16508. if (e != null && e.length) {
  16509. const { joinList: t, leaveList: i, presentList: s } = this.bizControl.updateUsers(e);
  16510. O.info(`[${K.logName}]`, "resumeSubList", {
  16511. joinList: t,
  16512. leaveList: i,
  16513. presentList: s
  16514. }), this.handleUsersJoin(t), i.forEach((n) => {
  16515. O.event(K.logName, oe.UserLeft, n.userid, n.reason), this.emit("remoteUserOffLineNotify", n.userid, ss.AliRtcUserOfflineQuit);
  16516. });
  16517. for (let n = 0; n < s.length; n++) {
  16518. const c = s[n], o = c.userid, u = this.bizControl.getRemoteUser(o);
  16519. this.bizControl.onRemotePublishStateChange(c), u == null || u.updateSubscribe(de.Resume);
  16520. }
  16521. } else
  16522. for (let t = 0; t < this.remoteUsers.length; t++) {
  16523. const i = this.remoteUsers[t];
  16524. try {
  16525. i.restore(), i.updateSubscribe(de.Resume);
  16526. } catch (s) {
  16527. }
  16528. }
  16529. });
  16530. }
  16531. retrySubscribe(e) {
  16532. return w(this, null, function* () {
  16533. const t = this.bizControl.getRemoteUser(e);
  16534. if (!t)
  16535. throw new V(U.ERR_INNER, `no remote user(${e}) founded`);
  16536. t.restore(), t.updateSubscribe(de.Retry);
  16537. });
  16538. }
  16539. /**
  16540. * 处理网络异常
  16541. * @param {AliRtcError} err
  16542. * @returns {void}
  16543. */
  16544. onNetworkError() {
  16545. this.connectState === ue.AliRtcConnectionStatusConnected && (this.networkError || (this.connectState = ue.AliRtcConnectionStatusDisconnected, this.emit(
  16546. "connectionStatusChange",
  16547. ue.AliRtcConnectionStatusDisconnected,
  16548. Wt.AliRtcConnectionChangedNetworkInterrupted
  16549. )), this.networkError = !0);
  16550. }
  16551. /**
  16552. * 处理错误
  16553. * @param {AliRtcError} err
  16554. * @returns {void}
  16555. */
  16556. onError(e) {
  16557. this.slsReporter.reportError(e), O.event(K.logName, oe.Error, e);
  16558. }
  16559. setEnableDualVideoStream(e, t) {
  16560. this.bizControl.setEnableDualVideoStream(e, t);
  16561. }
  16562. /**
  16563. * 对本地流的操作预检查
  16564. */
  16565. // @ts-ignore
  16566. hadPushStream(e) {
  16567. if (!(this.publisher && e))
  16568. throw new V(U.ERR_INNER, "stream is not publishing");
  16569. }
  16570. /**
  16571. * 获取当前使用的麦克风 deviceId
  16572. * @returns {string | undefined}
  16573. */
  16574. getCurrentMicDeviceId() {
  16575. var e;
  16576. return (e = this.publisher) == null ? void 0 : e.getCurrentMicDeviceId();
  16577. }
  16578. setChannelProfile(e) {
  16579. if (![
  16580. ue.AliRtcConnectionStatusInit,
  16581. ue.AliRtcConnectionStatusDisconnected,
  16582. ue.AliRtcConnectionStatusFailed
  16583. ].includes(this.connectState))
  16584. throw new V(U.ERR_INNER, "cannot set channel profile in call");
  16585. this.channelProfile = e, this.channelProfile === bt.AliRtcSdkCommunication && (this.clientRole = Nt.AliRtcSdkLive), this.signalingManager.setChannelProfile(e);
  16586. }
  16587. startAndPublishDefaultDevices(e) {
  16588. return w(this, null, function* () {
  16589. var c, o, u, h, p;
  16590. if (!this.publisher)
  16591. return;
  16592. const { hasCamera: t, hasMicrophone: i, hasScreenShare: s } = this.publisher;
  16593. if (!t && !i && !s) {
  16594. try {
  16595. yield (c = this.publisher) == null ? void 0 : c.startDefaultCamera(this._audioOnlyMode);
  16596. } catch (d) {
  16597. O.warn(`[${K.logName}]`, "startDefaultCamera failed", d.code, d.message), d instanceof V && this.occurError(d), this.occurError(
  16598. new V(
  16599. U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED,
  16600. `auto start video failed, ${d.message || ""}`
  16601. )
  16602. );
  16603. }
  16604. try {
  16605. yield (o = this.publisher) == null ? void 0 : o.startDefaultAudio();
  16606. } catch (d) {
  16607. O.warn(`[${K.logName}]`, "startDefaultAUdio failed", d.code, d.message), d instanceof V && this.occurError(d), this.occurError(
  16608. new V(
  16609. U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED,
  16610. `auto start audio failed, ${d.message || ""}`
  16611. )
  16612. );
  16613. }
  16614. yield (u = this.publisher) == null ? void 0 : u.previewAll();
  16615. }
  16616. const n = ((h = this.publisher) == null ? void 0 : h.publishStreams) || {};
  16617. if (Object.values(n).some((d) => d))
  16618. try {
  16619. yield (p = this.publisher) == null ? void 0 : p.startPublish(!1, e);
  16620. } catch (d) {
  16621. const f = [];
  16622. n != null && n.audio && f.push(U.ERR_SDK_PUBLISH_AUDIO_STREAM_FAILED), n != null && n.video && f.push(U.ERR_SDK_PUBLISH_VIDEO_STREAM_FAILED), f.forEach((m) => {
  16623. this.occurError(new V(m, `auto publish stream failed, ${d.message || ""}`));
  16624. });
  16625. }
  16626. });
  16627. }
  16628. setClientRole(e) {
  16629. return w(this, null, function* () {
  16630. var t, i;
  16631. try {
  16632. if (this.channelProfile === bt.AliRtcSdkCommunication)
  16633. return;
  16634. if (!Object.values(Nt).includes(e))
  16635. throw new V(
  16636. U.ERR_INVALID_ARGUMENTS,
  16637. `set client role error, role value(${e}) is invalid`
  16638. );
  16639. if (this.clientRole === e)
  16640. return;
  16641. this.slsReporter.reportRoleUpdate(this.clientRole, e), this.isInCall() ? this.clientRole === Nt.AliRtcSdkInteractive ? (this.bizControl.isSubscribing ? yield (t = this.publisher) == null ? void 0 : t.clearStream() : yield (i = this.publisher) == null ? void 0 : i.unPublish(), yield this.signalingManager.setClientRole(e)) : (yield this.signalingManager.setClientRole(e), yield this.startAndPublishDefaultDevices(nt.ROLE_CHANGE)) : yield this.signalingManager.setClientRole(e), this.clientRole = e;
  16642. } catch (s) {
  16643. throw s.code === 403 && this.emit("authInfoExpired"), s;
  16644. }
  16645. });
  16646. }
  16647. /**
  16648. * 获取用户角色
  16649. * @returns {AliRtcSdkClientRole}
  16650. */
  16651. getCurrentClientRole() {
  16652. return this.clientRole;
  16653. }
  16654. setAudioOnlyMode(e) {
  16655. if (this.isInCall())
  16656. throw new V(U.ERR_INNER, "can not change audioOnly mode in call");
  16657. this._audioOnlyMode = e;
  16658. }
  16659. setAudioRedEnabled(e) {
  16660. if (this.isInCall())
  16661. throw new V(U.ERR_INNER, "can not change audioRedEnabled in call");
  16662. this.bizControl.setAudioRedEnabled(e);
  16663. }
  16664. /**
  16665. * 设定鉴权信息过期事件定时器
  16666. * @param expireTimestamp 鉴权信息过期时间
  16667. * @param serverTimestamp 入会时服务端时间
  16668. */
  16669. setCheckAuthInfoTimer(e, t) {
  16670. const i = (e - t) * 1e3;
  16671. this._authInfoExpiredTimer = window.setTimeout(() => {
  16672. this.emit("authInfoExpired");
  16673. }, i), this._authInfoWillExpireTimer = window.setTimeout(() => {
  16674. this.emit("authInfoWillExpire");
  16675. }, i - 3e4), this._serverCheckAuthInfoTimestamp = t, this._localCheckAuthInfoTimestamp = +Date.now() / 1e3;
  16676. }
  16677. clearCheckAuthInfoTimer() {
  16678. this._authInfoExpiredTimer && window.clearTimeout(this._authInfoExpiredTimer), this._authInfoWillExpireTimer && window.clearTimeout(this._authInfoWillExpireTimer);
  16679. }
  16680. joinChannel(e, t) {
  16681. return w(this, null, function* () {
  16682. var u, h;
  16683. const i = Date.now();
  16684. let s, n = t;
  16685. if (typeof e == "string")
  16686. try {
  16687. const p = JSON.parse(window.atob(e));
  16688. s = {
  16689. appId: p.appid,
  16690. channelId: p.channelid,
  16691. userId: p.userid,
  16692. timestamp: p.timestamp,
  16693. nonce: p.nonce,
  16694. token: p.token
  16695. };
  16696. } catch (p) {
  16697. throw new V(U.ERR_INVALID_ARGUMENTS, `authInfo is invalid: ${p.message || ""}`);
  16698. }
  16699. else
  16700. s = e;
  16701. n || (n = s.userId);
  16702. const c = {
  16703. start: Date.now()
  16704. };
  16705. let o = cs.checkAuthInfo(s);
  16706. if (ue.AliRtcConnectionStatusInit === this.connectState || ue.AliRtcConnectionStatusDisconnected === this.connectState || ue.AliRtcConnectionStatusFailed === this.connectState) {
  16707. if (s.sessionId = He.createCallid("web"), this.slsReporter.start(s), this.slsReporter.reportConnectionLatencyEvent(
  16708. Je.JOIN,
  16709. Xe.START,
  16710. "",
  16711. "",
  16712. i
  16713. ), this.connectState = ue.AliRtcConnectionStatusConnecting, o)
  16714. throw this.connectState = ue.AliRtcConnectionStatusFailed, this.slsReporter.reportJoin(o.code, c, ""), this.slsReporter.reportJoinResult(o), o;
  16715. O.setSessionID(s.appId, s.sessionId);
  16716. try {
  16717. const p = Date.now(), d = yield this.signalingManager.join(
  16718. s,
  16719. n,
  16720. this.maxSignalingConnectRetryCount,
  16721. c
  16722. ), f = Date.now();
  16723. this.connectState = ue.AliRtcConnectionStatusConnected, (u = this.publisher) == null || u.reportSelfDeviceStatus(), this.bizControl.init(s, d), this.setCheckAuthInfoTimer(s.timestamp, d.timestamp), this.liveTranscoding.setAuthInfo(s), this.slsReporter.reportJoin(0, c, d.tid), this.slsReporter.reportJoinResult(null), this.slsReporter.reportConnectionLatencyEvent(
  16724. Je.JOIN,
  16725. Xe.SEND_SIG,
  16726. "",
  16727. "",
  16728. p
  16729. ), this.slsReporter.reportConnectionLatencyEvent(
  16730. Je.JOIN,
  16731. Xe.RECV_RST,
  16732. "",
  16733. "",
  16734. f
  16735. ), this.slsReporter.reportConnectionLatencyEvent(Je.JOIN, Xe.END, "", "");
  16736. } catch (p) {
  16737. const d = (h = p.code) != null ? h : -1, f = p.reason || p.message || "";
  16738. throw this.connectState = ue.AliRtcConnectionStatusDisconnected, this.slsReporter.reportJoin(d, c, ""), this.slsReporter.reportJoinResult(p), new V(d, f);
  16739. }
  16740. this.currentRoleCanPublish && (yield this.startAndPublishDefaultDevices(nt.JOIN_CHANNEL)), this.remoteUsers.forEach((p) => {
  16741. p.updateSubscribe(de.Join);
  16742. });
  16743. } else {
  16744. const p = new V(U.ERR_JOIN_ALREADY_JOINED, "already joined");
  16745. throw this.connectState === ue.AliRtcConnectionStatusConnecting && (p.message = "Repeated operation during login"), this.slsReporter.reportJoin(p.code, c, ""), p;
  16746. }
  16747. });
  16748. }
  16749. leaveChannel() {
  16750. return w(this, null, function* () {
  16751. var t;
  16752. this.slsReporter.reportLeaveInvoked(), yield this.bizControl.leave();
  16753. let e = (/* @__PURE__ */ new Date()).getTime();
  16754. if (ue.AliRtcConnectionStatusConnected === this.connectState)
  16755. try {
  16756. let i;
  16757. i = yield this.signalingManager.leave(), this.slsReporter.reportLeave((/* @__PURE__ */ new Date()).getTime() - e, 0, (t = i == null ? void 0 : i.tid) != null ? t : "");
  16758. } catch (i) {
  16759. this.slsReporter.reportLeave(
  16760. (/* @__PURE__ */ new Date()).getTime() - e,
  16761. i.code,
  16762. i.reason
  16763. );
  16764. }
  16765. else
  16766. this.slsReporter.reportLeave(0, 0, "");
  16767. this.networkError = !1, this.connectState = ue.AliRtcConnectionStatusDisconnected, this.clearCheckAuthInfoTimer(), this.liveTranscoding.clear(), this.slsReporter.stop(), this.signalingManager.reset(), O.reportEnd();
  16768. });
  16769. }
  16770. /**
  16771. * 检查当前是否在频道中
  16772. * @returns {boolean}
  16773. * - true:在频道中
  16774. * - false:不在频道中
  16775. */
  16776. isInCall() {
  16777. return this.connectState === ue.AliRtcConnectionStatusConnected;
  16778. }
  16779. refreshAuthInfo(e) {
  16780. return w(this, null, function* () {
  16781. let t;
  16782. if (typeof e == "string")
  16783. try {
  16784. const h = JSON.parse(window.atob(e));
  16785. t = {
  16786. userId: h.userid,
  16787. timestamp: h.timestamp,
  16788. nonce: h.nonce,
  16789. token: h.token
  16790. };
  16791. } catch (h) {
  16792. throw new V(U.ERR_INVALID_ARGUMENTS, `authInfo is invalid: ${h.message || ""}`);
  16793. }
  16794. else
  16795. t = e;
  16796. const { userId: i, nonce: s, timestamp: n, token: c, role: o } = t, u = { userId: i, nonce: s, timestamp: n, token: c, role: o };
  16797. try {
  16798. yield this.signalingManager.refreshAuthInfo(u), this.bizControl.refreshAuthInfo(u), this.liveTranscoding.refreshAuthInfo(u), this.clearCheckAuthInfoTimer(), this._serverCheckAuthInfoTimestamp && this._localCheckAuthInfoTimestamp && t.timestamp && this.setCheckAuthInfoTimer(
  16799. t.timestamp,
  16800. this._serverCheckAuthInfoTimestamp + (Date.now() - this._localCheckAuthInfoTimestamp)
  16801. );
  16802. } catch (h) {
  16803. throw h;
  16804. }
  16805. });
  16806. }
  16807. /**
  16808. * 检查当前是否纯音频模式
  16809. * @returns {boolean}
  16810. * - true:纯音频模式
  16811. * - false:音视频模式
  16812. */
  16813. isAudioOnly() {
  16814. return this._audioOnlyMode;
  16815. }
  16816. publishLocalAudioStream(e) {
  16817. return w(this, null, function* () {
  16818. var t, i, s, n;
  16819. (t = this.publisher) == null || t.setPublishLocalAudioStreamEnabled(e), this.connectState === ue.AliRtcConnectionStatusConnected && (e ? (i = this.publisher) != null && i.hasMicrophone ? yield (s = this.publisher) == null ? void 0 : s.updateStreams() : yield this.startAudioCapture() : yield (n = this.publisher) == null ? void 0 : n.publishUpdate());
  16820. });
  16821. }
  16822. /**
  16823. * @brief 查询是否设置推送音频流
  16824. * @return
  16825. * - true: 已设置推送
  16826. * - false: 未设置推送
  16827. * @note SDK默认设置推送音频流,如果需要取消推送音频流,可以通过 {@link publishLocalAudioStream}方法设置为不推送
  16828. */
  16829. isLocalAudioStreamPublished() {
  16830. var e, t;
  16831. return (t = (e = this.publisher) == null ? void 0 : e.publishLocalAudioStreamEnabled) != null ? t : !0;
  16832. }
  16833. setDefaultSubscribeAllRemoteAudioStreams(e) {
  16834. this.bizControl.setAutoSubAudio(e);
  16835. }
  16836. subscribeAllRemoteAudioStreams(e) {
  16837. this.bizControl.setWantSubAudio(e);
  16838. }
  16839. subscribeRemoteAudioStream(e, t) {
  16840. if (t && !this.bizControl.isWantSubAudio)
  16841. throw new V(
  16842. U.ERR_INVALID_ARGUMENTS,
  16843. "subscribeAllRemoteAudioStreams(true) must be called first"
  16844. );
  16845. this.bizControl.updateAudioWant(e, t);
  16846. }
  16847. resumeRemoteAudioStream(e) {
  16848. const t = this.bizControl.getRemoteUser(e);
  16849. if (!t)
  16850. throw new V(U.ERR_INNER, `no remote user(${e}) founded`);
  16851. t.resumeAudio();
  16852. }
  16853. stopRemoteAudioPlay(e) {
  16854. const t = this.bizControl.getRemoteUser(e);
  16855. if (!t)
  16856. throw new V(U.ERR_INNER, `no remote user(${e}) founded`);
  16857. t.stopPlayAudio();
  16858. }
  16859. publishLocalVideoStream(e) {
  16860. return w(this, null, function* () {
  16861. var t, i, s, n;
  16862. (t = this.publisher) == null || t.setPublishLocalVideoStreamEnabled(e), this.connectState === ue.AliRtcConnectionStatusConnected && (e ? (i = this.publisher) != null && i.hasCamera ? yield (s = this.publisher) == null ? void 0 : s.updateStreams() : yield this.enableLocalVideo() : yield (n = this.publisher) == null ? void 0 : n.publishUpdate());
  16863. });
  16864. }
  16865. /**
  16866. * @brief 查询是否设置推送视频流
  16867. * @return
  16868. * - true: 已设置推送
  16869. * - false: 未设置推送
  16870. * @note SDK默认设置推送视频流,如果需要取消推送视频流,可以通过 {@link publishLocalVideoStream} 方法设置为不推送
  16871. */
  16872. isLocalVideoStreamPublished() {
  16873. var e, t;
  16874. return (t = (e = this.publisher) == null ? void 0 : e.publishLocalVideoStreamEnabled) != null ? t : !0;
  16875. }
  16876. setRemoteDefaultVideoStreamType(e) {
  16877. [we.AliRtcVideoStreamTypeHigh, we.AliRtcVideoStreamTypeLow].includes(e) && this.bizControl.setRemoteDefaultVideoStreamType(e);
  16878. }
  16879. setRemoteUserVideoStreamType(e, t) {
  16880. [we.AliRtcVideoStreamTypeHigh, we.AliRtcVideoStreamTypeLow].includes(t) && this.bizControl.setRemoteUserVideoStreamType(e, t);
  16881. }
  16882. setDefaultSubscribeAllRemoteVideoStreams(e) {
  16883. this.bizControl.setAutoSubVideo(e), this.bizControl.setAutoSubScreen(e);
  16884. }
  16885. subscribeAllRemoteVideoStreams(e) {
  16886. this.bizControl.setWantSubVideo(e), this.bizControl.setWantSubScreen(e);
  16887. }
  16888. subscribeRemoteMediaStream(e, t, i, s) {
  16889. const n = this.bizControl.getRemoteUser(e);
  16890. if (!n)
  16891. throw new V(U.ERR_INNER, `no remote user(${e}) founded`);
  16892. i && (t === se.AliRtcVideoTrackScreen || t === se.AliRtcVideoTrackBoth) ? n.setWantSubScreen(!0) : n.setWantSubScreen(!1), i && (t === se.AliRtcVideoTrackCamera || t === se.AliRtcVideoTrackBoth) ? n.setWantSubVideo(!0) : n.setWantSubVideo(!1), n.setWantSubAudio(s), n.updateSubscribe(de.User);
  16893. }
  16894. resumeRemoteMediaStream(e, t) {
  16895. const i = this.bizControl.getRemoteUser(e);
  16896. i && i.resumeVideo(t);
  16897. }
  16898. /**
  16899. * @brief 订阅目标频道,指定用户的流
  16900. * @param channelId 目标频道
  16901. * @param uid 用户ID,从App server分配的唯一标示符
  16902. * @param track 订阅的视频流类型
  16903. * @param sub_audio 是否订阅远端用户的音频流
  16904. * - true:订阅指定用户的音频流
  16905. * - false:停止订阅指定用户的音频流
  16906. * @param sub 是否订阅远端用户的流
  16907. * - true:订阅指定用户的流
  16908. * - false:停止订阅指定用户的流
  16909. */
  16910. // public subscribeRemoteDestChannelStream(
  16911. // channelId: string,
  16912. // uid: string,
  16913. // track: AliRtcVideoTrack,
  16914. // sub_audio: boolean,
  16915. // sub: boolean
  16916. // ) {
  16917. // throw new Error('Method not implemented.');
  16918. // }
  16919. /**
  16920. * @brief 获取远端在线用户列表
  16921. * @return 当前频道内所有在线用户userid列表
  16922. * @note 若当前频道ChannelProfile设置为 {@link AliRtcSdkChannelProfile.AliRtcSdkInteractiveLive} 模式,只有设置角色为 {@link AliRtcSdkClientRole.AliRtcSdkInteractive} 的用户为在线用户,本方法不返回角色为 {@link AliRtcSdkClientRole.AliRtcSdkLive} 的用户
  16923. */
  16924. getOnlineRemoteUsers() {
  16925. return this.bizControl.remoteUsers.map((e) => e.userId);
  16926. }
  16927. /**
  16928. * @brief 查询远端用户状态
  16929. * @details 通过 uid 查询指定远端用户的状态信息.
  16930. * @param uid 用户ID。从App server分配的唯一标示符
  16931. * @return 返回一个远端用户对象。详见{@link RemoteUser}
  16932. */
  16933. getUserInfo(e) {
  16934. var t;
  16935. return (t = this.bizControl.getRemoteUser(e)) == null ? void 0 : t.remoteUserInfo;
  16936. }
  16937. /**
  16938. * @brief 查询用户是否在线
  16939. * @param uid 用户ID,从App server分配的唯一标示符。不可为NULL
  16940. * @return
  16941. * - true: 用户在线
  16942. * - false: 用户不在线
  16943. * @note 根据特定的UserID,查询该用户是否在线。
  16944. */
  16945. isUserOnline(e) {
  16946. return !!this.bizControl.remoteUsers.find((t) => t.userId === e);
  16947. }
  16948. startScreenShare(e) {
  16949. return w(this, null, function* () {
  16950. var c;
  16951. const t = {
  16952. video: !1,
  16953. audio: !1
  16954. }, { audio: i = !1, videoTrack: s, audioTrack: n } = e || {};
  16955. if (s || n) {
  16956. t.screen = !0;
  16957. const o = new MediaStream();
  16958. s && o.addTrack(s), n && o.addTrack(n), t.mediaStream = o;
  16959. } else
  16960. t.screen = i ? {
  16961. audio: !0
  16962. } : !0;
  16963. yield (c = this.publisher) == null ? void 0 : c.createLocalStream(t);
  16964. });
  16965. }
  16966. stopScreenShare() {
  16967. return w(this, null, function* () {
  16968. var e;
  16969. (e = this.publisher) == null || e.stopLocalStream({
  16970. screen: !0
  16971. });
  16972. });
  16973. }
  16974. setScreenShareConfiguration(e) {
  16975. return w(this, null, function* () {
  16976. var n;
  16977. const { frameRate: t, bitrate: i } = e, s = {};
  16978. t && (s.frameRate = t), i && (s.maxBitrate = i), yield (n = this.publisher) == null ? void 0 : n.setScreenProfile(s);
  16979. });
  16980. }
  16981. setScreenShareContentHint(e) {
  16982. return w(this, null, function* () {
  16983. var t;
  16984. e && ((t = this.publisher) == null || t.setScreenContentHint(e));
  16985. });
  16986. }
  16987. publishLocalScreenShareStream(e, t) {
  16988. return w(this, null, function* () {
  16989. var i, s, n;
  16990. (i = this.publisher) == null || i.setPublishLocalScreenStreamEnabled(e), this.connectState === ue.AliRtcConnectionStatusConnected && (e ? (s = this.publisher) != null && s.hasScreenShare ? yield this.publisher.updateStreams() : yield this.startScreenShare(t) : yield (n = this.publisher) == null ? void 0 : n.publishUpdate());
  16991. });
  16992. }
  16993. /**
  16994. * @brief 查询是否设置推送屏幕分享
  16995. * @return
  16996. - true: 已设置推送
  16997. - false: 未设置推送
  16998. * @note SDK默认设置不推送屏幕分享,如果需要推送屏幕共享,可以通过{@link startScreenShare}方法开启屏幕共享推送
  16999. */
  17000. isScreenSharePublished() {
  17001. var e, t;
  17002. return (t = (e = this.publisher) == null ? void 0 : e.publishLocalScreenStreamEnabled) != null ? t : !0;
  17003. }
  17004. setAudioShareVolume(e) {
  17005. if (typeof e != "number")
  17006. throw new V(U.ERR_INVALID_ARGUMENTS, "volume must be a number");
  17007. this.bizControl.setAudioVolume({
  17008. screen: Math.max(0, Math.min(e, 400)) / 100
  17009. });
  17010. }
  17011. enableAudioVolumeIndication(e) {
  17012. this.bizControl.enableAudioVolumeIndication(e);
  17013. }
  17014. muteLocalMic(e = !1) {
  17015. var t;
  17016. this.isPublishing && this.onLocalDeviceStatusChange(e ? oe.MuteAudio : oe.UnmuteAudio), (t = this.publisher) == null || t.muteLocalMic(e);
  17017. }
  17018. muteRemoteAudioPlaying(e, t = !1) {
  17019. const i = this.bizControl.getRemoteUser(e);
  17020. if (!i)
  17021. throw new V(U.ERR_INNER, `no remote user(${e}) founded`);
  17022. i.setAudioMuted(t);
  17023. }
  17024. muteAllRemoteAudioPlaying(e = !1) {
  17025. this.bizControl.setAudioMuted(e);
  17026. }
  17027. startAudioCapture(e) {
  17028. return w(this, null, function* () {
  17029. var i;
  17030. const t = {
  17031. audio: e || !0
  17032. };
  17033. yield (i = this.publisher) == null ? void 0 : i.createLocalStream(t);
  17034. });
  17035. }
  17036. setAudioConstraints(e) {
  17037. return w(this, null, function* () {
  17038. var t;
  17039. yield (t = this.publisher) == null ? void 0 : t.setMicrophoneConstraints(e);
  17040. });
  17041. }
  17042. stopAudioCapture() {
  17043. var e;
  17044. (e = this.publisher) == null || e.stopAudioCapture();
  17045. }
  17046. switchMicrophone(e, t) {
  17047. return w(this, null, function* () {
  17048. var i, s, n, c;
  17049. if (yield (i = this.publisher) == null ? void 0 : i.setMicrophoneDeviceId(e), !((s = this.publisher) != null && s.audioCaptureDisabled)) {
  17050. if (t) {
  17051. yield (n = this.publisher) == null ? void 0 : n.createLocalStream({
  17052. audio: !0,
  17053. mediaStream: new MediaStream([t])
  17054. });
  17055. return;
  17056. }
  17057. yield (c = this.publisher) == null ? void 0 : c.createLocalStream({
  17058. audio: {
  17059. deviceId: e
  17060. }
  17061. });
  17062. }
  17063. });
  17064. }
  17065. setRecordingVolume(e) {
  17066. if (typeof e != "number")
  17067. throw new V(U.ERR_INVALID_ARGUMENTS, "volume must be a number");
  17068. this.bizControl.setAudioVolume({
  17069. audio: Math.max(0, Math.min(e, 400)) / 100
  17070. });
  17071. }
  17072. setPlayoutVolume(e) {
  17073. if (typeof e != "number")
  17074. throw new V(U.ERR_INVALID_ARGUMENTS, "volume must be a number");
  17075. this.bizControl.setPlayoutVolume(Math.max(0, Math.min(e, 100)) / 100);
  17076. }
  17077. setRemoteAudioVolume(e, t) {
  17078. const i = this.bizControl.getRemoteUser(e);
  17079. if (!i)
  17080. throw new V(U.ERR_INNER, `no remote user(${e}) founded`);
  17081. if (typeof t != "number")
  17082. throw new V(U.ERR_INVALID_ARGUMENTS, "volume must be a number");
  17083. i.setPlayoutVolume(Math.max(0, Math.min(t, 100)) / 100);
  17084. }
  17085. setAudioProfile(e) {
  17086. return w(this, null, function* () {
  17087. var t;
  17088. yield (t = this.publisher) == null ? void 0 : t.setAudioProfile(e);
  17089. });
  17090. }
  17091. getAudioTrack(e) {
  17092. return w(this, null, function* () {
  17093. var i;
  17094. if (!e)
  17095. return (i = this.publisher) == null ? void 0 : i.audioTrack;
  17096. const t = this.bizControl.getRemoteUser(e);
  17097. return t == null ? void 0 : t.getAudioTrack;
  17098. });
  17099. }
  17100. setLocalViewConfig(e, t) {
  17101. return w(this, null, function* () {
  17102. var i, s, n;
  17103. if (this._audioOnlyMode)
  17104. throw new V(U.ERR_INNER, "Cannot set local view in audio only mode");
  17105. (i = this.bizControl) == null || i.setLocalViewConfig(e, t), t === se.AliRtcVideoTrackCamera && ((s = this.publisher) != null && s.hasCamera) ? yield this.startPreview() : t === se.AliRtcVideoTrackScreen && ((n = this.publisher) != null && n.hasScreenShare) && (yield this.startPreviewScreen());
  17106. });
  17107. }
  17108. setCameraCapturerConfiguration(e) {
  17109. return w(this, null, function* () {
  17110. var h, p, d;
  17111. const u = e, { cameraDirection: t, deviceId: i, bitrate: s, maxSendFrameRate: n } = u, c = Dt(u, ["cameraDirection", "deviceId", "bitrate", "maxSendFrameRate"]), o = J({}, c);
  17112. s && (o.maxBitrate = s), n && (o.maxSendFrameRate = n), Object.keys(o).length > 0 && (yield (h = this.publisher) == null ? void 0 : h.setVideoProfile(o)), t !== void 0 && ((p = this.publisher) == null || p.setCameraDirection(t)), i && ((d = this.publisher) == null || d.setCameraDeviceId(i));
  17113. });
  17114. }
  17115. setCameraCapturerContentHint(e) {
  17116. return w(this, null, function* () {
  17117. var t;
  17118. e && ((t = this.publisher) == null || t.setVideoContentHint(e));
  17119. });
  17120. }
  17121. enableLocalVideo(e = !0) {
  17122. return w(this, null, function* () {
  17123. var t, i, s, n, c, o, u, h, p, d, f;
  17124. if (this._audioOnlyMode)
  17125. throw new V(U.ERR_INNER, "Cannot enable local video in audio only mode");
  17126. e ? ((i = (t = this.publisher) == null ? void 0 : t.publishStreams) != null && i.video && ((c = (n = (s = this.publisher) == null ? void 0 : s.publishStreams) == null ? void 0 : n.video) == null || c.disableVideo(), (p = (h = (u = (o = this.publisher) == null ? void 0 : o.publishStreams) == null ? void 0 : u.video) == null ? void 0 : h.videoTrack) == null || p.stop()), yield (d = this.publisher) == null ? void 0 : d.startCameraCapture()) : yield (f = this.publisher) == null ? void 0 : f.stopCameraCapture();
  17127. });
  17128. }
  17129. muteLocalCamera(e) {
  17130. return w(this, null, function* () {
  17131. var t;
  17132. this.isPublishing && this.onLocalDeviceStatusChange(e ? oe.MuteVideo : oe.UnmuteVideo), (t = this.publisher) == null || t.muteLocalCamera(e);
  17133. });
  17134. }
  17135. muteLocalScreen(e) {
  17136. return w(this, null, function* () {
  17137. var t;
  17138. this.isPublishing && this.onLocalDeviceStatusChange(e ? oe.MuteScreen : oe.UnmuteScreen), (t = this.publisher) == null || t.muteLocalScreen(e);
  17139. });
  17140. }
  17141. setRemoteViewConfig(e, t, i) {
  17142. this.bizControl.setRemoteViewConfig(t, e, i);
  17143. }
  17144. /**
  17145. * 检查camera是否打开
  17146. * @return {boolean}
  17147. * - true: 摄像头已打开
  17148. * - false: 摄像头没有打开
  17149. * @note 该接口用于检查当前camera的状态
  17150. */
  17151. isCameraOn() {
  17152. var e, t;
  17153. return (t = (e = this.publisher) == null ? void 0 : e.hasCamera) != null ? t : !1;
  17154. }
  17155. switchCamera(e, t) {
  17156. return w(this, null, function* () {
  17157. var s, n, c, o, u, h;
  17158. if (this._audioOnlyMode)
  17159. throw new V(U.ERR_INNER, "Cannot switch camera in audio only mode");
  17160. const i = {};
  17161. if (e ? (i.deviceId = e, this.slsReporter.reportSwitchCamera(e)) : t || (i.cameraDirection = ((s = this.publisher) == null ? void 0 : s.cameraDirection) === "environment" ? oi.CAMERA_FRONT : oi.CAMERA_REAR, this.slsReporter.reportSwitchCamera(((n = this.publisher) == null ? void 0 : n.cameraDirection) || "")), yield this.setCameraCapturerConfiguration(i), !((c = this.publisher) != null && c.cameraCaptureDisabled)) {
  17162. (u = (o = this.publisher) == null ? void 0 : o.cameraTrack) == null || u.stop();
  17163. const p = {
  17164. video: !0
  17165. };
  17166. t && (p.mediaStream = new MediaStream([t])), yield (h = this.publisher) == null ? void 0 : h.createLocalStream(p);
  17167. }
  17168. });
  17169. }
  17170. /**
  17171. * 获取摄像头设备ID
  17172. * @return {string} 摄像头设备ID
  17173. */
  17174. getCurrentCameraDeviceId() {
  17175. var e;
  17176. return (e = this.publisher) == null ? void 0 : e.getCurrentCameraDeviceId();
  17177. }
  17178. startPreview() {
  17179. return w(this, null, function* () {
  17180. var e, t;
  17181. if (this._audioOnlyMode)
  17182. throw new V(U.ERR_INNER, "Cannot start preview camera in audio only mode");
  17183. (e = this.publisher) != null && e.hasCamera || (yield this.enableLocalVideo(!0)), yield (t = this.publisher) == null ? void 0 : t.previewAll({
  17184. screen: !1
  17185. });
  17186. });
  17187. }
  17188. startPreviewScreen(e) {
  17189. return w(this, null, function* () {
  17190. var t, i;
  17191. if (this._audioOnlyMode)
  17192. throw new V(U.ERR_INNER, "Cannot start preview screen share in audio only mode");
  17193. (t = this.publisher) != null && t.hasScreenShare || (yield this.startScreenShare(e)), yield (i = this.publisher) == null ? void 0 : i.previewAll({
  17194. primary: !1
  17195. });
  17196. });
  17197. }
  17198. stopPreview() {
  17199. return w(this, null, function* () {
  17200. var e;
  17201. yield (e = this.publisher) == null ? void 0 : e.stopPreview({
  17202. primary: !0,
  17203. screen: !1
  17204. });
  17205. });
  17206. }
  17207. stopPreviewScreen() {
  17208. return w(this, null, function* () {
  17209. var e;
  17210. yield (e = this.publisher) == null ? void 0 : e.stopPreview({
  17211. primary: !1,
  17212. screen: !0
  17213. });
  17214. });
  17215. }
  17216. /**
  17217. * @brief 获取当前用户或远端用户的视频轨道
  17218. * @param {AliRtcVideoTrackConfig} config 视频轨道配置
  17219. * @return {MediaStreamTrack} 视频轨道
  17220. *
  17221. */
  17222. getVideoTrack(e) {
  17223. return w(this, null, function* () {
  17224. var n, c, o, u;
  17225. const { userId: t, streamType: i } = e;
  17226. if (!t)
  17227. return i === be.AliRtcSdkStreamTypeCapture ? (n = this.publisher) == null ? void 0 : n.cameraTrack : (c = this.publisher) == null ? void 0 : c.screenTrack;
  17228. const s = this.bizControl.getRemoteUser(t);
  17229. return i === be.AliRtcSdkStreamTypeCapture ? (o = s == null ? void 0 : s.getCameraStream) == null ? void 0 : o.videoTrack : (u = s == null ? void 0 : s.getScreenStream) == null ? void 0 : u.videoTrack;
  17230. });
  17231. }
  17232. startPublishLiveStream(e, t) {
  17233. return w(this, null, function* () {
  17234. return this.liveTranscoding.startPublishLiveStream(e, t);
  17235. });
  17236. }
  17237. updatePublishLiveStream(e, t) {
  17238. return w(this, null, function* () {
  17239. return this.liveTranscoding.updatePublishLiveStream(e, t);
  17240. });
  17241. }
  17242. updatePublishLiveStreamWithTaskId(e, t) {
  17243. return this.liveTranscoding.updatePublishLiveStreamWithTaskId(e, t);
  17244. }
  17245. stopPublishLiveStream(e) {
  17246. return w(this, null, function* () {
  17247. return this.liveTranscoding.stopPublishLiveStream(e);
  17248. });
  17249. }
  17250. stopPublishLiveStreamWithTaskId(e) {
  17251. return this.liveTranscoding.stopPublishLiveStreamWithTaskId(e);
  17252. }
  17253. setEnableMediaExtensionMsg(e) {
  17254. var t;
  17255. (t = this.bizControl) == null || t.setEnableMediaExtensionMsg(!!e);
  17256. }
  17257. /**
  17258. * @brief 发送媒体扩展信息
  17259. * @details SDK提供了发送和接收媒体扩展信息的功能,接收端参考 {@link AliRtcEngineEventListener.mediaExtensionMsgReceived},使用场景:
  17260. * - 使用媒体扩展信息传递时间戳,计算端到端的网络延迟,或者跟自身其他业务做数据同步
  17261. * - 使用媒体扩展信息传递描述信息。目前可以传递最多 4k Byte数据,可以用来传输少量数据,建议使用Json或者纯字符串;
  17262. * - 内部使用SEI扩展协议来实现;
  17263. *
  17264. * @param message 媒体扩展信息,长度限制为最大4K字节
  17265. * @param repeatCount 重复次数,代表消息冗余度,用于防止网络丢包导致的消息丢失,-1为无限传输
  17266. *
  17267. * @note 启用此能力会增加客户端性能开销,如有需求需要在加入房间之前调用 setEnableMediaExtensionMsg
  17268. * @note 使用媒体扩展信息时需要复用音视频数据通道,因此必须控制自定义消息的发送频率和消息数据长度,使用限制如下:
  17269. * - 每秒最多发送profile条消息,因为sei信息是放到h264/h265流中传输,有视频帧编码才能附加扩展信息;
  17270. * - 为了不影响媒体数据的传输质量,自定义消息体长度限制为4k Byte,可以用来传输少量信息;
  17271. * - sendMediaExtensionMsg函数中repeatCount参数为自定义消息冗余度,若大于1,则会发送多次,
  17272. * - 防止网络丢包导致的消息丢失,此时房间里的其他人也会收到多次相同的消息,需要去重
  17273. * - 发送的自定义消息,在旁路直播时,房间里的订阅者也一样会收到
  17274. * - 同一时间只有一条MediaExtensionMsg在传输,多次调用sendMediaExtensionMsg,新调用的数据会覆盖前一次的数据;
  17275. */
  17276. sendMediaExtensionMsg(e, t) {
  17277. return w(this, null, function* () {
  17278. return this.sendMediaExtensionMsgEx(e, t, 5);
  17279. });
  17280. }
  17281. sendMediaExtensionMsgEx(e, t, i) {
  17282. return w(this, null, function* () {
  17283. var s;
  17284. if (!this.publisher || !this.isPublishing)
  17285. throw new V(U.ERR_INNER, "you should publish first");
  17286. return this.slsReporter.reportSEIMessage(i, e.byteLength, t, 0, !1), (s = this.publisher) == null ? void 0 : s.sendSEI(e, t, i);
  17287. });
  17288. }
  17289. enablePlugin(e, t) {
  17290. this.bizControl.pluginManager.add(e, t);
  17291. }
  17292. removePlugin(e) {
  17293. this.bizControl.pluginManager.remove(e);
  17294. }
  17295. setPluginOption(e, t) {
  17296. const i = this.bizControl.pluginManager.get(e);
  17297. i && t && i.setOptions(t);
  17298. }
  17299. getPluginOption(e) {
  17300. const t = this.bizControl.pluginManager.get(e);
  17301. return t == null ? void 0 : t.getOptions();
  17302. }
  17303. /**
  17304. * 美颜功能是否有效
  17305. * @return
  17306. * - true: 美颜功能有效
  17307. * - false: 无效
  17308. */
  17309. isBeautyAvailable() {
  17310. return this.bizControl.pluginManager.has("AliRtcBeauty");
  17311. }
  17312. /**
  17313. * 美颜功能是否开启
  17314. * @return
  17315. * - true: 美颜功能已开启
  17316. * - false: 已关闭
  17317. */
  17318. isBeautyEnabled() {
  17319. const e = this.bizControl.pluginManager.get("AliRtcBeauty");
  17320. if (!e)
  17321. throw new V(
  17322. _t.AliRtcPluginErrorNoFindPlugin,
  17323. "you should enable beautyPlugin first"
  17324. );
  17325. return !!(e != null && e.isEnable);
  17326. }
  17327. setBeautyEffect(e, t) {
  17328. const i = this.bizControl.pluginManager.get("AliRtcBeauty");
  17329. if (!i)
  17330. throw new V(
  17331. _t.AliRtcPluginErrorNoFindPlugin,
  17332. "you should enable beautyPlugin first"
  17333. );
  17334. e ? i.enable() : i.disable(), i.setOptions({
  17335. basicBeauty: {
  17336. skinBuffing: Math.max(Math.min(1, +t.smoothnessLevel), 0),
  17337. whitening: Math.max(Math.min(1, +t.whiteningLevel), 0)
  17338. }
  17339. });
  17340. }
  17341. enableBackgroundExchange(e, t) {
  17342. const i = this.bizControl.pluginManager.get("AliRtcBeauty");
  17343. if (!i || !i.isEnable)
  17344. throw new V(
  17345. _t.AliRtcPluginErrorNoFindPlugin,
  17346. "you should enable beautyPlugin first"
  17347. );
  17348. const s = {
  17349. setSegmentBackgroundImage: {
  17350. backgroundImgUrl: e ? t : ""
  17351. }
  17352. };
  17353. e && (s.segmentBackgroundProcess = {
  17354. enable: !1
  17355. }), i.setOptions(s);
  17356. }
  17357. enableBackgroundBlur(e) {
  17358. const t = this.bizControl.pluginManager.get("AliRtcBeauty");
  17359. if (!t || !t.isEnable)
  17360. throw new V(
  17361. _t.AliRtcPluginErrorNoFindPlugin,
  17362. "you should enable beautyPlugin first"
  17363. );
  17364. const i = {
  17365. segmentBackgroundProcess: {
  17366. type: 0,
  17367. enable: e
  17368. }
  17369. };
  17370. e && (i.setSegmentBackgroundImage = {
  17371. type: 0,
  17372. backgroundImgUrl: ""
  17373. }), t.setOptions(i);
  17374. }
  17375. setParameter(e) {
  17376. this.bizControl.setParameter(e);
  17377. }
  17378. getParameter() {
  17379. return this.bizControl.getParameter();
  17380. }
  17381. sendDataChannelMessage(e) {
  17382. this.bizControl.sendDataChannelMessage(e);
  17383. }
  17384. }, /**
  17385. * @ignore
  17386. */
  17387. g(K, "logName", "AliRtcEngine"), /**
  17388. * @ignore
  17389. */
  17390. g(K, "logError", !0), /**
  17391. * 检查浏览器是否支持 WebRTC
  17392. * @param {string} direction
  17393. * @returns {Promise<AliRtcCheckResult>}
  17394. */
  17395. g(K, "isSupported", P0), /**
  17396. * 检查浏览器是否支持开启大小流
  17397. * @returns {boolean}
  17398. */
  17399. g(K, "isDualVideoStreamSupported", zr.isSupport), /**
  17400. * 获取摄像头列表
  17401. * @returns {Promise<string[]>}
  17402. */
  17403. g(K, "getCameraList", () => w(K, null, function* () {
  17404. return (yield le.getCameraList()).filter((t) => t.deviceId);
  17405. })), g(K, "getMicrophoneList", () => w(K, null, function* () {
  17406. return (yield le.getMicList()).filter((t) => t.deviceId);
  17407. })), g(K, "getSpeakerList", () => w(K, null, function* () {
  17408. return (yield le.getSpeakerList()).filter((t) => t.deviceId);
  17409. })), g(K, "_instance"), g(K, "AliRtcSdkChannelProfile", bt), g(K, "AliRtcSdkClientRole", Nt), g(K, "AliRtcVideoStreamType", we), g(K, "AliRtcVideoTrack", se), g(K, "AliRtcAudioTrack", Xt), g(K, "AliRtcPublishState", Y), g(K, "AliRtcSubscribeState", he), g(K, "AliRtcRawDataStreamType", be), g(K, "AliRtcLogLevel", fn), g(K, "AliRtcEngineLocalDeviceType", dt), g(K, "AliRtcEngineLocalDeviceExceptionType", _e), g(K, "AliRtcConnectionStatus", ue), g(K, "AliRtcConnectionStatusChangeReason", Wt), g(K, "AliRtcPlugin", Gt), g(K, "AliRtcPluginTrackType", Ri), g(K, "AliRtcLiveTranscodingParam", Fr), g(K, "AliRtcLiveTranscodingEncodeParam", vn), g(K, "AliRtcLiveTranscodingMixParam", Hc), g(K, "AliRtcLiveTranscodingSingleParam", jc), g(K, "AliRtcTranscodingClockWidget", zc), g(K, "AliRtcTranscodingImage", Dn), g(K, "AliRtcTranscodingText", Wc), g(K, "AliRtcTranscodingUser", $c), g(K, "AliRtcLiveTranscodingMixMode", bi), g(K, "AliRtcLiveTranscodingStreamType", pn), g(K, "AliRtcLiveTranscodingSourceType", ni), g(K, "AliRtcLiveTranscodingTaskProfile", gn), g(K, "AliRtcLiveTranscodingAudioSampleRate", ts), g(K, "AliRtcLiveTranscodingSegmentType", Ei), g(K, "AliRtcLiveTranscodingFontType", Ii), g(K, "AliRtcLiveTranscodingCropMode", mn), g(K, "AliRtcLiveTranscodingMediaProcessMode", is), g(K, "AliRtcLiveTranscodingState", Sn), g(K, "AliRtcLiveTranscodingErrorCode", ht), g(K, "AliRtcTrascodingPublishTaskStatus", xn), g(K, "AliRtcDataChannelMsg", qt), g(K, "AliRtcDataMsgType", Cn), g(K, "Plugin", Gt), K);
  17410. W([
  17411. D()
  17412. ], z.prototype, "destroy", 1);
  17413. W([
  17414. D()
  17415. ], z.prototype, "backToUnpublishStatus", 1);
  17416. W([
  17417. D()
  17418. ], z.prototype, "resumePublishForNetworkRecovery", 1);
  17419. W([
  17420. D()
  17421. ], z.prototype, "onNetworkRecovery", 1);
  17422. W([
  17423. D()
  17424. ], z.prototype, "resumeSubList", 1);
  17425. W([
  17426. D(H)
  17427. ], z.prototype, "retrySubscribe", 1);
  17428. W([
  17429. D(H)
  17430. ], z.prototype, "setEnableDualVideoStream", 1);
  17431. W([
  17432. D(H)
  17433. ], z.prototype, "setChannelProfile", 1);
  17434. W([
  17435. D(H)
  17436. ], z.prototype, "setClientRole", 1);
  17437. W([
  17438. D(H)
  17439. ], z.prototype, "setAudioOnlyMode", 1);
  17440. W([
  17441. D()
  17442. ], z.prototype, "clearCheckAuthInfoTimer", 1);
  17443. W([
  17444. D(H)
  17445. ], z.prototype, "joinChannel", 1);
  17446. W([
  17447. D(H)
  17448. ], z.prototype, "leaveChannel", 1);
  17449. W([
  17450. D(H)
  17451. ], z.prototype, "refreshAuthInfo", 1);
  17452. W([
  17453. D(H)
  17454. ], z.prototype, "publishLocalAudioStream", 1);
  17455. W([
  17456. D(H)
  17457. ], z.prototype, "setDefaultSubscribeAllRemoteAudioStreams", 1);
  17458. W([
  17459. D(H)
  17460. ], z.prototype, "subscribeAllRemoteAudioStreams", 1);
  17461. W([
  17462. D(H)
  17463. ], z.prototype, "subscribeRemoteAudioStream", 1);
  17464. W([
  17465. D(H)
  17466. ], z.prototype, "resumeRemoteAudioStream", 1);
  17467. W([
  17468. D(H)
  17469. ], z.prototype, "stopRemoteAudioPlay", 1);
  17470. W([
  17471. D(H)
  17472. ], z.prototype, "publishLocalVideoStream", 1);
  17473. W([
  17474. D(H)
  17475. ], z.prototype, "setRemoteDefaultVideoStreamType", 1);
  17476. W([
  17477. D(H)
  17478. ], z.prototype, "setRemoteUserVideoStreamType", 1);
  17479. W([
  17480. D(H)
  17481. ], z.prototype, "setDefaultSubscribeAllRemoteVideoStreams", 1);
  17482. W([
  17483. D(H)
  17484. ], z.prototype, "subscribeAllRemoteVideoStreams", 1);
  17485. W([
  17486. D(H)
  17487. ], z.prototype, "subscribeRemoteMediaStream", 1);
  17488. W([
  17489. D(H)
  17490. ], z.prototype, "resumeRemoteMediaStream", 1);
  17491. W([
  17492. D(([r]) => [`${r == null ? void 0 : r.audio}`])
  17493. ], z.prototype, "startScreenShare", 1);
  17494. W([
  17495. D()
  17496. ], z.prototype, "stopScreenShare", 1);
  17497. W([
  17498. D(H)
  17499. ], z.prototype, "setScreenShareConfiguration", 1);
  17500. W([
  17501. D(H)
  17502. ], z.prototype, "setScreenShareContentHint", 1);
  17503. W([
  17504. D()
  17505. ], z.prototype, "publishLocalScreenShareStream", 1);
  17506. W([
  17507. D(H)
  17508. ], z.prototype, "setAudioShareVolume", 1);
  17509. W([
  17510. D(H)
  17511. ], z.prototype, "enableAudioVolumeIndication", 1);
  17512. W([
  17513. D(H)
  17514. ], z.prototype, "muteLocalMic", 1);
  17515. W([
  17516. D(H)
  17517. ], z.prototype, "muteRemoteAudioPlaying", 1);
  17518. W([
  17519. D(H)
  17520. ], z.prototype, "muteAllRemoteAudioPlaying", 1);
  17521. W([
  17522. D(H)
  17523. ], z.prototype, "startAudioCapture", 1);
  17524. W([
  17525. D(H)
  17526. ], z.prototype, "setAudioConstraints", 1);
  17527. W([
  17528. D()
  17529. ], z.prototype, "stopAudioCapture", 1);
  17530. W([
  17531. D(H)
  17532. ], z.prototype, "switchMicrophone", 1);
  17533. W([
  17534. D(H)
  17535. ], z.prototype, "setRecordingVolume", 1);
  17536. W([
  17537. D(H)
  17538. ], z.prototype, "setPlayoutVolume", 1);
  17539. W([
  17540. D(H)
  17541. ], z.prototype, "setRemoteAudioVolume", 1);
  17542. W([
  17543. D(H)
  17544. ], z.prototype, "setAudioProfile", 1);
  17545. W([
  17546. D(H)
  17547. ], z.prototype, "getAudioTrack", 1);
  17548. W([
  17549. D(H)
  17550. ], z.prototype, "setLocalViewConfig", 1);
  17551. W([
  17552. D(H)
  17553. ], z.prototype, "setCameraCapturerConfiguration", 1);
  17554. W([
  17555. D(H)
  17556. ], z.prototype, "setCameraCapturerContentHint", 1);
  17557. W([
  17558. D(H)
  17559. ], z.prototype, "enableLocalVideo", 1);
  17560. W([
  17561. D(H)
  17562. ], z.prototype, "muteLocalCamera", 1);
  17563. W([
  17564. D(H)
  17565. ], z.prototype, "muteLocalScreen", 1);
  17566. W([
  17567. D(H)
  17568. ], z.prototype, "setRemoteViewConfig", 1);
  17569. W([
  17570. D(H)
  17571. ], z.prototype, "switchCamera", 1);
  17572. W([
  17573. D()
  17574. ], z.prototype, "startPreview", 1);
  17575. W([
  17576. D()
  17577. ], z.prototype, "startPreviewScreen", 1);
  17578. W([
  17579. D()
  17580. ], z.prototype, "stopPreview", 1);
  17581. W([
  17582. D()
  17583. ], z.prototype, "stopPreviewScreen", 1);
  17584. W([
  17585. D()
  17586. ], z.prototype, "startPublishLiveStream", 1);
  17587. W([
  17588. D()
  17589. ], z.prototype, "updatePublishLiveStream", 1);
  17590. W([
  17591. D()
  17592. ], z.prototype, "updatePublishLiveStreamWithTaskId", 1);
  17593. W([
  17594. D()
  17595. ], z.prototype, "stopPublishLiveStream", 1);
  17596. W([
  17597. D()
  17598. ], z.prototype, "stopPublishLiveStreamWithTaskId", 1);
  17599. W([
  17600. D(H)
  17601. ], z.prototype, "setEnableMediaExtensionMsg", 1);
  17602. W([
  17603. D(([r, a, e]) => [r.byteLength, a, e])
  17604. ], z.prototype, "sendMediaExtensionMsgEx", 1);
  17605. W([
  17606. D(([r, a]) => [r.name || "", a])
  17607. ], z.prototype, "enablePlugin", 1);
  17608. W([
  17609. D(H)
  17610. ], z.prototype, "removePlugin", 1);
  17611. W([
  17612. D(H)
  17613. ], z.prototype, "setPluginOption", 1);
  17614. W([
  17615. D(H)
  17616. ], z.prototype, "getPluginOption", 1);
  17617. W([
  17618. D(H)
  17619. ], z.prototype, "setBeautyEffect", 1);
  17620. W([
  17621. D(H)
  17622. ], z.prototype, "enableBackgroundExchange", 1);
  17623. W([
  17624. D(H)
  17625. ], z.prototype, "enableBackgroundBlur", 1);
  17626. W([
  17627. D(H)
  17628. ], z.prototype, "setParameter", 1);
  17629. W([
  17630. D(([r]) => {
  17631. var a;
  17632. return [(a = r.data) == null ? void 0 : a.byteLength];
  17633. })
  17634. ], z.prototype, "sendDataChannelMessage", 1);
  17635. W([
  17636. D(H)
  17637. ], z, "setLogLevel", 1);
  17638. let Pn = z;
  17639. var nn;
  17640. const kn = new qr({
  17641. businessName: "imp-web-rtc",
  17642. version: (nn = Pn.getSdkVersion()) != null ? nn : "unknown",
  17643. env: "prod",
  17644. disabled: window.AliRtcOptionsDisableProxy === !0
  17645. });
  17646. kn.setReady();
  17647. const Zc = kn.wrap(Pn);
  17648. export {
  17649. ue as AliRtcConnectionStatus,
  17650. Wt as AliRtcConnectionStatusChangeReason,
  17651. qt as AliRtcDataChannelMsg,
  17652. Cn as AliRtcDataMsgType,
  17653. _e as AliRtcEngineLocalDeviceExceptionType,
  17654. dt as AliRtcEngineLocalDeviceType,
  17655. U as AliRtcErrorCode,
  17656. ts as AliRtcLiveTranscodingAudioSampleRate,
  17657. mn as AliRtcLiveTranscodingCropMode,
  17658. vn as AliRtcLiveTranscodingEncodeParam,
  17659. ht as AliRtcLiveTranscodingErrorCode,
  17660. Ii as AliRtcLiveTranscodingFontType,
  17661. is as AliRtcLiveTranscodingMediaProcessMode,
  17662. bi as AliRtcLiveTranscodingMixMode,
  17663. Hc as AliRtcLiveTranscodingMixParam,
  17664. Fr as AliRtcLiveTranscodingParam,
  17665. Ei as AliRtcLiveTranscodingSegmentType,
  17666. jc as AliRtcLiveTranscodingSingleParam,
  17667. ni as AliRtcLiveTranscodingSourceType,
  17668. Sn as AliRtcLiveTranscodingState,
  17669. pn as AliRtcLiveTranscodingStreamType,
  17670. gn as AliRtcLiveTranscodingTaskProfile,
  17671. Ya as AliRtcLocalStreamInfo,
  17672. fn as AliRtcLogLevel,
  17673. Gt as AliRtcPlugin,
  17674. Ri as AliRtcPluginTrackType,
  17675. B0 as AliRtcPluginType,
  17676. Y as AliRtcPublishState,
  17677. be as AliRtcRawDataStreamType,
  17678. lc as AliRtcRemoteUserInfo,
  17679. bt as AliRtcSdkChannelProfile,
  17680. Nt as AliRtcSdkClientRole,
  17681. he as AliRtcSubscribeState,
  17682. zc as AliRtcTranscodingClockWidget,
  17683. Dn as AliRtcTranscodingImage,
  17684. Wc as AliRtcTranscodingText,
  17685. $c as AliRtcTranscodingUser,
  17686. xn as AliRtcTrascodingPublishTaskStatus,
  17687. we as AliRtcVideoStreamType,
  17688. se as AliRtcVideoTrack,
  17689. Zc as default
  17690. };