sdk.js 849 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692
  1. /*
  2. * JsSIP v3.4.3
  3. * the Javascript SIP library
  4. * Copyright: 2012-2020 José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)
  5. * Homepage: https://jssip.net
  6. * License: MIT
  7. */
  8. (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.JsSIP = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  9. "use strict";
  10. function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  11. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  12. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  13. var Utils = require('./Utils');
  14. var JsSIP_C = require('./Constants');
  15. var Grammar = require('./Grammar');
  16. var URI = require('./URI');
  17. var Socket = require('./Socket');
  18. var Exceptions = require('./Exceptions'); // Default settings.
  19. exports.settings = {
  20. // SIP authentication.
  21. authorization_user: null,
  22. password: null,
  23. realm: null,
  24. ha1: null,
  25. // SIP account.
  26. display_name: null,
  27. uri: null,
  28. contact_uri: null,
  29. // SIP instance id (GRUU).
  30. instance_id: null,
  31. // Preloaded SIP Route header field.
  32. use_preloaded_route: false,
  33. // Session parameters.
  34. session_timers: true,
  35. session_timers_refresh_method: JsSIP_C.UPDATE,
  36. no_answer_timeout: 60,
  37. // Registration parameters.
  38. register: true,
  39. register_expires: 600,
  40. registrar_server: null,
  41. // Connection options.
  42. sockets: null,
  43. connection_recovery_max_interval: JsSIP_C.CONNECTION_RECOVERY_MAX_INTERVAL,
  44. connection_recovery_min_interval: JsSIP_C.CONNECTION_RECOVERY_MIN_INTERVAL,
  45. /*
  46. * Host address.
  47. * Value to be set in Via sent_by and host part of Contact FQDN.
  48. */
  49. via_host: "".concat(Utils.createRandomToken(12), ".invalid")
  50. }; // Configuration checks.
  51. var checks = {
  52. mandatory: {
  53. sockets: function sockets(_sockets2) {
  54. /* Allow defining sockets parameter as:
  55. * Socket: socket
  56. * Array of Socket: [socket1, socket2]
  57. * Array of Objects: [{socket: socket1, weight:1}, {socket: Socket2, weight:0}]
  58. * Array of Objects and Socket: [{socket: socket1}, socket2]
  59. */
  60. var _sockets = [];
  61. if (Socket.isSocket(_sockets2)) {
  62. _sockets.push({
  63. socket: _sockets2
  64. });
  65. } else if (Array.isArray(_sockets2) && _sockets2.length) {
  66. var _iterator = _createForOfIteratorHelper(_sockets2),
  67. _step;
  68. try {
  69. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  70. var socket = _step.value;
  71. if (Object.prototype.hasOwnProperty.call(socket, 'socket') && Socket.isSocket(socket.socket)) {
  72. _sockets.push(socket);
  73. } else if (Socket.isSocket(socket)) {
  74. _sockets.push({
  75. socket: socket
  76. });
  77. }
  78. }
  79. } catch (err) {
  80. _iterator.e(err);
  81. } finally {
  82. _iterator.f();
  83. }
  84. } else {
  85. return;
  86. }
  87. return _sockets;
  88. },
  89. uri: function uri(_uri) {
  90. if (!/^sip:/i.test(_uri)) {
  91. _uri = "".concat(JsSIP_C.SIP, ":").concat(_uri);
  92. }
  93. var parsed = URI.parse(_uri);
  94. if (!parsed) {
  95. return;
  96. } else if (!parsed.user) {
  97. return;
  98. } else {
  99. return parsed;
  100. }
  101. }
  102. },
  103. optional: {
  104. authorization_user: function authorization_user(_authorization_user) {
  105. if (Grammar.parse("\"".concat(_authorization_user, "\""), 'quoted_string') === -1) {
  106. return;
  107. } else {
  108. return _authorization_user;
  109. }
  110. },
  111. authorization_jwt: function authorization_jwt(_authorization_jwt) {
  112. if (typeof _authorization_jwt === 'string') {
  113. return _authorization_jwt;
  114. }
  115. },
  116. user_agent: function user_agent(_user_agent) {
  117. if (typeof _user_agent === 'string') {
  118. return _user_agent;
  119. }
  120. },
  121. connection_recovery_max_interval: function connection_recovery_max_interval(_connection_recovery_max_interval) {
  122. if (Utils.isDecimal(_connection_recovery_max_interval)) {
  123. var value = Number(_connection_recovery_max_interval);
  124. if (value > 0) {
  125. return value;
  126. }
  127. }
  128. },
  129. connection_recovery_min_interval: function connection_recovery_min_interval(_connection_recovery_min_interval) {
  130. if (Utils.isDecimal(_connection_recovery_min_interval)) {
  131. var value = Number(_connection_recovery_min_interval);
  132. if (value > 0) {
  133. return value;
  134. }
  135. }
  136. },
  137. contact_uri: function contact_uri(_contact_uri) {
  138. if (typeof _contact_uri === 'string') {
  139. var uri = Grammar.parse(_contact_uri, 'SIP_URI');
  140. if (uri !== -1) {
  141. return uri;
  142. }
  143. }
  144. },
  145. display_name: function display_name(_display_name) {
  146. return _display_name;
  147. },
  148. instance_id: function instance_id(_instance_id) {
  149. if (/^uuid:/i.test(_instance_id)) {
  150. _instance_id = _instance_id.substr(5);
  151. }
  152. if (Grammar.parse(_instance_id, 'uuid') === -1) {
  153. return;
  154. } else {
  155. return _instance_id;
  156. }
  157. },
  158. no_answer_timeout: function no_answer_timeout(_no_answer_timeout) {
  159. if (Utils.isDecimal(_no_answer_timeout)) {
  160. var value = Number(_no_answer_timeout);
  161. if (value > 0) {
  162. return value;
  163. }
  164. }
  165. },
  166. session_timers: function session_timers(_session_timers) {
  167. if (typeof _session_timers === 'boolean') {
  168. return _session_timers;
  169. }
  170. },
  171. session_timers_refresh_method: function session_timers_refresh_method(method) {
  172. if (typeof method === 'string') {
  173. method = method.toUpperCase();
  174. if (method === JsSIP_C.INVITE || method === JsSIP_C.UPDATE) {
  175. return method;
  176. }
  177. }
  178. },
  179. password: function password(_password) {
  180. return String(_password);
  181. },
  182. realm: function realm(_realm) {
  183. return String(_realm);
  184. },
  185. ha1: function ha1(_ha) {
  186. return String(_ha);
  187. },
  188. register: function register(_register) {
  189. if (typeof _register === 'boolean') {
  190. return _register;
  191. }
  192. },
  193. register_expires: function register_expires(_register_expires) {
  194. if (Utils.isDecimal(_register_expires)) {
  195. var value = Number(_register_expires);
  196. if (value > 0) {
  197. return value;
  198. }
  199. }
  200. },
  201. registrar_server: function registrar_server(_registrar_server) {
  202. if (!/^sip:/i.test(_registrar_server)) {
  203. _registrar_server = "".concat(JsSIP_C.SIP, ":").concat(_registrar_server);
  204. }
  205. var parsed = URI.parse(_registrar_server);
  206. if (!parsed) {
  207. return;
  208. } else if (parsed.user) {
  209. return;
  210. } else {
  211. return parsed;
  212. }
  213. },
  214. use_preloaded_route: function use_preloaded_route(_use_preloaded_route) {
  215. if (typeof _use_preloaded_route === 'boolean') {
  216. return _use_preloaded_route;
  217. }
  218. }
  219. }
  220. };
  221. exports.load = function (dst, src) {
  222. // Check Mandatory parameters.
  223. for (var parameter in checks.mandatory) {
  224. if (!src.hasOwnProperty(parameter)) {
  225. throw new Exceptions.ConfigurationError(parameter);
  226. } else {
  227. var value = src[parameter];
  228. var checked_value = checks.mandatory[parameter](value);
  229. if (checked_value !== undefined) {
  230. dst[parameter] = checked_value;
  231. } else {
  232. throw new Exceptions.ConfigurationError(parameter, value);
  233. }
  234. }
  235. } // Check Optional parameters.
  236. for (var _parameter in checks.optional) {
  237. if (src.hasOwnProperty(_parameter)) {
  238. var _value = src[_parameter];
  239. /* If the parameter value is null, empty string, undefined, empty array
  240. * or it's a number with NaN value, then apply its default value.
  241. */
  242. if (Utils.isEmpty(_value)) {
  243. continue;
  244. }
  245. var _checked_value = checks.optional[_parameter](_value);
  246. if (_checked_value !== undefined) {
  247. dst[_parameter] = _checked_value;
  248. } else {
  249. throw new Exceptions.ConfigurationError(_parameter, _value);
  250. }
  251. }
  252. }
  253. };
  254. },{"./Constants":2,"./Exceptions":6,"./Grammar":7,"./Socket":20,"./URI":25,"./Utils":26}],2:[function(require,module,exports){
  255. "use strict";
  256. var pkg = require('../package.json');
  257. module.exports = {
  258. USER_AGENT: "".concat(pkg.title, " ").concat(pkg.version),
  259. // SIP scheme.
  260. SIP: 'sip',
  261. SIPS: 'sips',
  262. // End and Failure causes.
  263. causes: {
  264. // Generic error causes.
  265. CONNECTION_ERROR: 'Connection Error',
  266. REQUEST_TIMEOUT: 'Request Timeout',
  267. SIP_FAILURE_CODE: 'SIP Failure Code',
  268. INTERNAL_ERROR: 'Internal Error',
  269. // SIP error causes.
  270. BUSY: 'Busy',
  271. REJECTED: 'Rejected',
  272. REDIRECTED: 'Redirected',
  273. UNAVAILABLE: 'Unavailable',
  274. NOT_FOUND: 'Not Found',
  275. ADDRESS_INCOMPLETE: 'Address Incomplete',
  276. INCOMPATIBLE_SDP: 'Incompatible SDP',
  277. MISSING_SDP: 'Missing SDP',
  278. AUTHENTICATION_ERROR: 'Authentication Error',
  279. // Session error causes.
  280. BYE: 'Terminated',
  281. WEBRTC_ERROR: 'WebRTC Error',
  282. CANCELED: 'Canceled',
  283. NO_ANSWER: 'No Answer',
  284. EXPIRES: 'Expires',
  285. NO_ACK: 'No ACK',
  286. DIALOG_ERROR: 'Dialog Error',
  287. USER_DENIED_MEDIA_ACCESS: 'User Denied Media Access',
  288. BAD_MEDIA_DESCRIPTION: 'Bad Media Description',
  289. RTP_TIMEOUT: 'RTP Timeout'
  290. },
  291. SIP_ERROR_CAUSES: {
  292. REDIRECTED: [300, 301, 302, 305, 380],
  293. BUSY: [486, 600],
  294. REJECTED: [403, 603],
  295. NOT_FOUND: [404, 604],
  296. UNAVAILABLE: [480, 410, 408, 430],
  297. ADDRESS_INCOMPLETE: [484, 424],
  298. INCOMPATIBLE_SDP: [488, 606],
  299. AUTHENTICATION_ERROR: [401, 407]
  300. },
  301. // SIP Methods.
  302. ACK: 'ACK',
  303. BYE: 'BYE',
  304. CANCEL: 'CANCEL',
  305. INFO: 'INFO',
  306. INVITE: 'INVITE',
  307. MESSAGE: 'MESSAGE',
  308. NOTIFY: 'NOTIFY',
  309. OPTIONS: 'OPTIONS',
  310. REGISTER: 'REGISTER',
  311. REFER: 'REFER',
  312. UPDATE: 'UPDATE',
  313. SUBSCRIBE: 'SUBSCRIBE',
  314. /* SIP Response Reasons
  315. * DOC: https://www.iana.org/assignments/sip-parameters
  316. * Copied from https://github.com/versatica/OverSIP/blob/master/lib/oversip/sip/constants.rb#L7
  317. */
  318. REASON_PHRASE: {
  319. 100: 'Trying',
  320. 180: 'Ringing',
  321. 181: 'Call Is Being Forwarded',
  322. 182: 'Queued',
  323. 183: 'Session Progress',
  324. 199: 'Early Dialog Terminated',
  325. // draft-ietf-sipcore-199
  326. 200: 'OK',
  327. 202: 'Accepted',
  328. // RFC 3265
  329. 204: 'No Notification',
  330. // RFC 5839
  331. 300: 'Multiple Choices',
  332. 301: 'Moved Permanently',
  333. 302: 'Moved Temporarily',
  334. 305: 'Use Proxy',
  335. 380: 'Alternative Service',
  336. 400: 'Bad Request',
  337. 401: 'Unauthorized',
  338. 402: 'Payment Required',
  339. 403: 'Forbidden',
  340. 404: 'Not Found',
  341. 405: 'Method Not Allowed',
  342. 406: 'Not Acceptable',
  343. 407: 'Proxy Authentication Required',
  344. 408: 'Request Timeout',
  345. 410: 'Gone',
  346. 412: 'Conditional Request Failed',
  347. // RFC 3903
  348. 413: 'Request Entity Too Large',
  349. 414: 'Request-URI Too Long',
  350. 415: 'Unsupported Media Type',
  351. 416: 'Unsupported URI Scheme',
  352. 417: 'Unknown Resource-Priority',
  353. // RFC 4412
  354. 420: 'Bad Extension',
  355. 421: 'Extension Required',
  356. 422: 'Session Interval Too Small',
  357. // RFC 4028
  358. 423: 'Interval Too Brief',
  359. 424: 'Bad Location Information',
  360. // RFC 6442
  361. 428: 'Use Identity Header',
  362. // RFC 4474
  363. 429: 'Provide Referrer Identity',
  364. // RFC 3892
  365. 430: 'Flow Failed',
  366. // RFC 5626
  367. 433: 'Anonymity Disallowed',
  368. // RFC 5079
  369. 436: 'Bad Identity-Info',
  370. // RFC 4474
  371. 437: 'Unsupported Certificate',
  372. // RFC 4744
  373. 438: 'Invalid Identity Header',
  374. // RFC 4744
  375. 439: 'First Hop Lacks Outbound Support',
  376. // RFC 5626
  377. 440: 'Max-Breadth Exceeded',
  378. // RFC 5393
  379. 469: 'Bad Info Package',
  380. // draft-ietf-sipcore-info-events
  381. 470: 'Consent Needed',
  382. // RFC 5360
  383. 478: 'Unresolvable Destination',
  384. // Custom code copied from Kamailio.
  385. 480: 'Temporarily Unavailable',
  386. 481: 'Call/Transaction Does Not Exist',
  387. 482: 'Loop Detected',
  388. 483: 'Too Many Hops',
  389. 484: 'Address Incomplete',
  390. 485: 'Ambiguous',
  391. 486: 'Busy Here',
  392. 487: 'Request Terminated',
  393. 488: 'Not Acceptable Here',
  394. 489: 'Bad Event',
  395. // RFC 3265
  396. 491: 'Request Pending',
  397. 493: 'Undecipherable',
  398. 494: 'Security Agreement Required',
  399. // RFC 3329
  400. 500: 'JsSIP Internal Error',
  401. 501: 'Not Implemented',
  402. 502: 'Bad Gateway',
  403. 503: 'Service Unavailable',
  404. 504: 'Server Time-out',
  405. 505: 'Version Not Supported',
  406. 513: 'Message Too Large',
  407. 580: 'Precondition Failure',
  408. // RFC 3312
  409. 600: 'Busy Everywhere',
  410. 603: 'Decline',
  411. 604: 'Does Not Exist Anywhere',
  412. 606: 'Not Acceptable'
  413. },
  414. ALLOWED_METHODS: 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY',
  415. ACCEPTED_BODY_TYPES: 'application/sdp, application/dtmf-relay',
  416. MAX_FORWARDS: 69,
  417. SESSION_EXPIRES: 90,
  418. MIN_SESSION_EXPIRES: 60,
  419. CONNECTION_RECOVERY_MAX_INTERVAL: 30,
  420. CONNECTION_RECOVERY_MIN_INTERVAL: 2
  421. };
  422. },{"../package.json":38}],3:[function(require,module,exports){
  423. "use strict";
  424. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  425. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  426. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  427. var SIPMessage = require('./SIPMessage');
  428. var JsSIP_C = require('./Constants');
  429. var Transactions = require('./Transactions');
  430. var Dialog_RequestSender = require('./Dialog/RequestSender');
  431. var Utils = require('./Utils');
  432. var debug = require('debug')('JsSIP:Dialog');
  433. var C = {
  434. // Dialog states.
  435. STATUS_EARLY: 1,
  436. STATUS_CONFIRMED: 2
  437. }; // RFC 3261 12.1.
  438. module.exports = /*#__PURE__*/function () {
  439. _createClass(Dialog, null, [{
  440. key: "C",
  441. // Expose C object.
  442. get: function get() {
  443. return C;
  444. }
  445. }]);
  446. function Dialog(owner, message, type) {
  447. var state = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : C.STATUS_CONFIRMED;
  448. _classCallCheck(this, Dialog);
  449. this._owner = owner;
  450. this._ua = owner._ua;
  451. this._uac_pending_reply = false;
  452. this._uas_pending_reply = false;
  453. if (!message.hasHeader('contact')) {
  454. return {
  455. error: 'unable to create a Dialog without Contact header field'
  456. };
  457. }
  458. if (message instanceof SIPMessage.IncomingResponse) {
  459. state = message.status_code < 200 ? C.STATUS_EARLY : C.STATUS_CONFIRMED;
  460. }
  461. var contact = message.parseHeader('contact'); // RFC 3261 12.1.1.
  462. if (type === 'UAS') {
  463. this._id = {
  464. call_id: message.call_id,
  465. local_tag: message.to_tag,
  466. remote_tag: message.from_tag,
  467. toString: function toString() {
  468. return this.call_id + this.local_tag + this.remote_tag;
  469. }
  470. };
  471. this._state = state;
  472. this._remote_seqnum = message.cseq;
  473. this._local_uri = message.parseHeader('to').uri;
  474. this._remote_uri = message.parseHeader('from').uri;
  475. this._remote_target = contact.uri;
  476. this._route_set = message.getHeaders('record-route');
  477. this._ack_seqnum = this._remote_seqnum;
  478. } // RFC 3261 12.1.2.
  479. else if (type === 'UAC') {
  480. this._id = {
  481. call_id: message.call_id,
  482. local_tag: message.from_tag,
  483. remote_tag: message.to_tag,
  484. toString: function toString() {
  485. return this.call_id + this.local_tag + this.remote_tag;
  486. }
  487. };
  488. this._state = state;
  489. this._local_seqnum = message.cseq;
  490. this._local_uri = message.parseHeader('from').uri;
  491. this._remote_uri = message.parseHeader('to').uri;
  492. this._remote_target = contact.uri;
  493. this._route_set = message.getHeaders('record-route').reverse();
  494. this._ack_seqnum = null;
  495. }
  496. this._ua.newDialog(this);
  497. debug("new ".concat(type, " dialog created with status ").concat(this._state === C.STATUS_EARLY ? 'EARLY' : 'CONFIRMED'));
  498. }
  499. _createClass(Dialog, [{
  500. key: "update",
  501. value: function update(message, type) {
  502. this._state = C.STATUS_CONFIRMED;
  503. debug("dialog ".concat(this._id.toString(), " changed to CONFIRMED state"));
  504. if (type === 'UAC') {
  505. // RFC 3261 13.2.2.4.
  506. this._route_set = message.getHeaders('record-route').reverse();
  507. }
  508. }
  509. }, {
  510. key: "terminate",
  511. value: function terminate() {
  512. debug("dialog ".concat(this._id.toString(), " deleted"));
  513. this._ua.destroyDialog(this);
  514. }
  515. }, {
  516. key: "sendRequest",
  517. value: function sendRequest(method) {
  518. var _this = this;
  519. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  520. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  521. var eventHandlers = Utils.cloneObject(options.eventHandlers);
  522. var body = options.body || null;
  523. var request = this._createRequest(method, extraHeaders, body); // Increase the local CSeq on authentication.
  524. eventHandlers.onAuthenticated = function () {
  525. _this._local_seqnum += 1;
  526. };
  527. var request_sender = new Dialog_RequestSender(this, request, eventHandlers);
  528. request_sender.send(); // Return the instance of OutgoingRequest.
  529. return request;
  530. }
  531. }, {
  532. key: "receiveRequest",
  533. value: function receiveRequest(request) {
  534. // Check in-dialog request.
  535. if (!this._checkInDialogRequest(request)) {
  536. return;
  537. } // ACK received. Cleanup this._ack_seqnum.
  538. if (request.method === JsSIP_C.ACK && this._ack_seqnum !== null) {
  539. this._ack_seqnum = null;
  540. } // INVITE received. Set this._ack_seqnum.
  541. else if (request.method === JsSIP_C.INVITE) {
  542. this._ack_seqnum = request.cseq;
  543. }
  544. this._owner.receiveRequest(request);
  545. } // RFC 3261 12.2.1.1.
  546. }, {
  547. key: "_createRequest",
  548. value: function _createRequest(method, extraHeaders, body) {
  549. extraHeaders = Utils.cloneArray(extraHeaders);
  550. if (!this._local_seqnum) {
  551. this._local_seqnum = Math.floor(Math.random() * 10000);
  552. }
  553. var cseq = method === JsSIP_C.CANCEL || method === JsSIP_C.ACK ? this._local_seqnum : this._local_seqnum += 1;
  554. var request = new SIPMessage.OutgoingRequest(method, this._remote_target, this._ua, {
  555. 'cseq': cseq,
  556. 'call_id': this._id.call_id,
  557. 'from_uri': this._local_uri,
  558. 'from_tag': this._id.local_tag,
  559. 'to_uri': this._remote_uri,
  560. 'to_tag': this._id.remote_tag,
  561. 'route_set': this._route_set
  562. }, extraHeaders, body);
  563. return request;
  564. } // RFC 3261 12.2.2.
  565. }, {
  566. key: "_checkInDialogRequest",
  567. value: function _checkInDialogRequest(request) {
  568. var _this2 = this;
  569. if (!this._remote_seqnum) {
  570. this._remote_seqnum = request.cseq;
  571. } else if (request.cseq < this._remote_seqnum) {
  572. if (request.method === JsSIP_C.ACK) {
  573. // We are not expecting any ACK with lower seqnum than the current one.
  574. // Or this is not the ACK we are waiting for.
  575. if (this._ack_seqnum === null || request.cseq !== this._ack_seqnum) {
  576. return false;
  577. }
  578. } else {
  579. request.reply(500);
  580. return false;
  581. }
  582. } else if (request.cseq > this._remote_seqnum) {
  583. this._remote_seqnum = request.cseq;
  584. } // RFC3261 14.2 Modifying an Existing Session -UAS BEHAVIOR-.
  585. if (request.method === JsSIP_C.INVITE || request.method === JsSIP_C.UPDATE && request.body) {
  586. if (this._uac_pending_reply === true) {
  587. request.reply(491);
  588. } else if (this._uas_pending_reply === true) {
  589. var retryAfter = (Math.random() * 10 | 0) + 1;
  590. request.reply(500, null, ["Retry-After:".concat(retryAfter)]);
  591. return false;
  592. } else {
  593. this._uas_pending_reply = true;
  594. var stateChanged = function stateChanged() {
  595. if (request.server_transaction.state === Transactions.C.STATUS_ACCEPTED || request.server_transaction.state === Transactions.C.STATUS_COMPLETED || request.server_transaction.state === Transactions.C.STATUS_TERMINATED) {
  596. request.server_transaction.removeListener('stateChanged', stateChanged);
  597. _this2._uas_pending_reply = false;
  598. }
  599. };
  600. request.server_transaction.on('stateChanged', stateChanged);
  601. } // RFC3261 12.2.2 Replace the dialog`s remote target URI if the request is accepted.
  602. if (request.hasHeader('contact')) {
  603. request.server_transaction.on('stateChanged', function () {
  604. if (request.server_transaction.state === Transactions.C.STATUS_ACCEPTED) {
  605. _this2._remote_target = request.parseHeader('contact').uri;
  606. }
  607. });
  608. }
  609. } else if (request.method === JsSIP_C.NOTIFY) {
  610. // RFC6665 3.2 Replace the dialog`s remote target URI if the request is accepted.
  611. if (request.hasHeader('contact')) {
  612. request.server_transaction.on('stateChanged', function () {
  613. if (request.server_transaction.state === Transactions.C.STATUS_COMPLETED) {
  614. _this2._remote_target = request.parseHeader('contact').uri;
  615. }
  616. });
  617. }
  618. }
  619. return true;
  620. }
  621. }, {
  622. key: "id",
  623. get: function get() {
  624. return this._id;
  625. }
  626. }, {
  627. key: "local_seqnum",
  628. get: function get() {
  629. return this._local_seqnum;
  630. },
  631. set: function set(num) {
  632. this._local_seqnum = num;
  633. }
  634. }, {
  635. key: "owner",
  636. get: function get() {
  637. return this._owner;
  638. }
  639. }, {
  640. key: "uac_pending_reply",
  641. get: function get() {
  642. return this._uac_pending_reply;
  643. },
  644. set: function set(pending) {
  645. this._uac_pending_reply = pending;
  646. }
  647. }, {
  648. key: "uas_pending_reply",
  649. get: function get() {
  650. return this._uas_pending_reply;
  651. }
  652. }]);
  653. return Dialog;
  654. }();
  655. },{"./Constants":2,"./Dialog/RequestSender":4,"./SIPMessage":19,"./Transactions":22,"./Utils":26,"debug":30}],4:[function(require,module,exports){
  656. "use strict";
  657. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  658. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  659. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  660. var JsSIP_C = require('../Constants');
  661. var Transactions = require('../Transactions');
  662. var RTCSession = require('../RTCSession');
  663. var RequestSender = require('../RequestSender'); // Default event handlers.
  664. var EventHandlers = {
  665. onRequestTimeout: function onRequestTimeout() {},
  666. onTransportError: function onTransportError() {},
  667. onSuccessResponse: function onSuccessResponse() {},
  668. onErrorResponse: function onErrorResponse() {},
  669. onAuthenticated: function onAuthenticated() {},
  670. onDialogError: function onDialogError() {}
  671. };
  672. module.exports = /*#__PURE__*/function () {
  673. function DialogRequestSender(dialog, request, eventHandlers) {
  674. _classCallCheck(this, DialogRequestSender);
  675. this._dialog = dialog;
  676. this._ua = dialog._ua;
  677. this._request = request;
  678. this._eventHandlers = eventHandlers; // RFC3261 14.1 Modifying an Existing Session. UAC Behavior.
  679. this._reattempt = false;
  680. this._reattemptTimer = null; // Define the undefined handlers.
  681. for (var handler in EventHandlers) {
  682. if (Object.prototype.hasOwnProperty.call(EventHandlers, handler)) {
  683. if (!this._eventHandlers[handler]) {
  684. this._eventHandlers[handler] = EventHandlers[handler];
  685. }
  686. }
  687. }
  688. }
  689. _createClass(DialogRequestSender, [{
  690. key: "send",
  691. value: function send() {
  692. var _this = this;
  693. var request_sender = new RequestSender(this._ua, this._request, {
  694. onRequestTimeout: function onRequestTimeout() {
  695. _this._eventHandlers.onRequestTimeout();
  696. },
  697. onTransportError: function onTransportError() {
  698. _this._eventHandlers.onTransportError();
  699. },
  700. onAuthenticated: function onAuthenticated(request) {
  701. _this._eventHandlers.onAuthenticated(request);
  702. },
  703. onReceiveResponse: function onReceiveResponse(response) {
  704. _this._receiveResponse(response);
  705. }
  706. });
  707. request_sender.send(); // RFC3261 14.2 Modifying an Existing Session -UAC BEHAVIOR-.
  708. if ((this._request.method === JsSIP_C.INVITE || this._request.method === JsSIP_C.UPDATE && this._request.body) && request_sender.clientTransaction.state !== Transactions.C.STATUS_TERMINATED) {
  709. this._dialog.uac_pending_reply = true;
  710. var stateChanged = function stateChanged() {
  711. if (request_sender.clientTransaction.state === Transactions.C.STATUS_ACCEPTED || request_sender.clientTransaction.state === Transactions.C.STATUS_COMPLETED || request_sender.clientTransaction.state === Transactions.C.STATUS_TERMINATED) {
  712. request_sender.clientTransaction.removeListener('stateChanged', stateChanged);
  713. _this._dialog.uac_pending_reply = false;
  714. }
  715. };
  716. request_sender.clientTransaction.on('stateChanged', stateChanged);
  717. }
  718. }
  719. }, {
  720. key: "_receiveResponse",
  721. value: function _receiveResponse(response) {
  722. var _this2 = this;
  723. // RFC3261 12.2.1.2 408 or 481 is received for a request within a dialog.
  724. if (response.status_code === 408 || response.status_code === 481) {
  725. this._eventHandlers.onDialogError(response);
  726. } else if (response.method === JsSIP_C.INVITE && response.status_code === 491) {
  727. if (this._reattempt) {
  728. if (response.status_code >= 200 && response.status_code < 300) {
  729. this._eventHandlers.onSuccessResponse(response);
  730. } else if (response.status_code >= 300) {
  731. this._eventHandlers.onErrorResponse(response);
  732. }
  733. } else {
  734. this._request.cseq.value = this._dialog.local_seqnum += 1;
  735. this._reattemptTimer = setTimeout(function () {
  736. // TODO: look at dialog state instead.
  737. if (_this2._dialog.owner.status !== RTCSession.C.STATUS_TERMINATED) {
  738. _this2._reattempt = true;
  739. _this2._request_sender.send();
  740. }
  741. }, 1000);
  742. }
  743. } else if (response.status_code >= 200 && response.status_code < 300) {
  744. this._eventHandlers.onSuccessResponse(response);
  745. } else if (response.status_code >= 300) {
  746. this._eventHandlers.onErrorResponse(response);
  747. }
  748. }
  749. }, {
  750. key: "request",
  751. get: function get() {
  752. return this._request;
  753. }
  754. }]);
  755. return DialogRequestSender;
  756. }();
  757. },{"../Constants":2,"../RTCSession":12,"../RequestSender":18,"../Transactions":22}],5:[function(require,module,exports){
  758. "use strict";
  759. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  760. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  761. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  762. var Utils = require('./Utils');
  763. var debug = require('debug')('JsSIP:DigestAuthentication');
  764. var debugerror = require('debug')('JsSIP:ERROR:DigestAuthentication');
  765. debugerror.log = console.warn.bind(console);
  766. module.exports = /*#__PURE__*/function () {
  767. function DigestAuthentication(credentials) {
  768. _classCallCheck(this, DigestAuthentication);
  769. this._credentials = credentials;
  770. this._cnonce = null;
  771. this._nc = 0;
  772. this._ncHex = '00000000';
  773. this._algorithm = null;
  774. this._realm = null;
  775. this._nonce = null;
  776. this._opaque = null;
  777. this._stale = null;
  778. this._qop = null;
  779. this._method = null;
  780. this._uri = null;
  781. this._ha1 = null;
  782. this._response = null;
  783. }
  784. _createClass(DigestAuthentication, [{
  785. key: "get",
  786. value: function get(parameter) {
  787. switch (parameter) {
  788. case 'realm':
  789. return this._realm;
  790. case 'ha1':
  791. return this._ha1;
  792. default:
  793. debugerror('get() | cannot get "%s" parameter', parameter);
  794. return undefined;
  795. }
  796. }
  797. /**
  798. * Performs Digest authentication given a SIP request and the challenge
  799. * received in a response to that request.
  800. * Returns true if auth was successfully generated, false otherwise.
  801. */
  802. }, {
  803. key: "authenticate",
  804. value: function authenticate(_ref, challenge)
  805. /* test interface */
  806. {
  807. var method = _ref.method,
  808. ruri = _ref.ruri,
  809. body = _ref.body;
  810. var cnonce = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
  811. this._algorithm = challenge.algorithm;
  812. this._realm = challenge.realm;
  813. this._nonce = challenge.nonce;
  814. this._opaque = challenge.opaque;
  815. this._stale = challenge.stale;
  816. if (this._algorithm) {
  817. if (this._algorithm !== 'MD5') {
  818. debugerror('authenticate() | challenge with Digest algorithm different than "MD5", authentication aborted');
  819. return false;
  820. }
  821. } else {
  822. this._algorithm = 'MD5';
  823. }
  824. if (!this._nonce) {
  825. debugerror('authenticate() | challenge without Digest nonce, authentication aborted');
  826. return false;
  827. }
  828. if (!this._realm) {
  829. debugerror('authenticate() | challenge without Digest realm, authentication aborted');
  830. return false;
  831. } // If no plain SIP password is provided.
  832. if (!this._credentials.password) {
  833. // If ha1 is not provided we cannot authenticate.
  834. if (!this._credentials.ha1) {
  835. debugerror('authenticate() | no plain SIP password nor ha1 provided, authentication aborted');
  836. return false;
  837. } // If the realm does not match the stored realm we cannot authenticate.
  838. if (this._credentials.realm !== this._realm) {
  839. debugerror('authenticate() | no plain SIP password, and stored `realm` does not match the given `realm`, cannot authenticate [stored:"%s", given:"%s"]', this._credentials.realm, this._realm);
  840. return false;
  841. }
  842. } // 'qop' can contain a list of values (Array). Let's choose just one.
  843. if (challenge.qop) {
  844. if (challenge.qop.indexOf('auth-int') > -1) {
  845. this._qop = 'auth-int';
  846. } else if (challenge.qop.indexOf('auth') > -1) {
  847. this._qop = 'auth';
  848. } else {
  849. // Otherwise 'qop' is present but does not contain 'auth' or 'auth-int', so abort here.
  850. debugerror('authenticate() | challenge without Digest qop different than "auth" or "auth-int", authentication aborted');
  851. return false;
  852. }
  853. } else {
  854. this._qop = null;
  855. } // Fill other attributes.
  856. this._method = method;
  857. this._uri = ruri;
  858. this._cnonce = cnonce || Utils.createRandomToken(12);
  859. this._nc += 1;
  860. var hex = Number(this._nc).toString(16);
  861. this._ncHex = '00000000'.substr(0, 8 - hex.length) + hex; // Nc-value = 8LHEX. Max value = 'FFFFFFFF'.
  862. if (this._nc === 4294967296) {
  863. this._nc = 1;
  864. this._ncHex = '00000001';
  865. } // Calculate the Digest "response" value.
  866. // If we have plain SIP password then regenerate ha1.
  867. if (this._credentials.password) {
  868. // HA1 = MD5(A1) = MD5(username:realm:password).
  869. this._ha1 = Utils.calculateMD5("".concat(this._credentials.username, ":").concat(this._realm, ":").concat(this._credentials.password));
  870. } // Otherwise reuse the stored ha1.
  871. else {
  872. this._ha1 = this._credentials.ha1;
  873. }
  874. var a2;
  875. var ha2;
  876. if (this._qop === 'auth') {
  877. // HA2 = MD5(A2) = MD5(method:digestURI).
  878. a2 = "".concat(this._method, ":").concat(this._uri);
  879. ha2 = Utils.calculateMD5(a2);
  880. debug('authenticate() | using qop=auth [a2:"%s"]', a2); // Response = MD5(HA1:nonce:nonceCount:credentialsNonce:qop:HA2).
  881. this._response = Utils.calculateMD5("".concat(this._ha1, ":").concat(this._nonce, ":").concat(this._ncHex, ":").concat(this._cnonce, ":auth:").concat(ha2));
  882. } else if (this._qop === 'auth-int') {
  883. // HA2 = MD5(A2) = MD5(method:digestURI:MD5(entityBody)).
  884. a2 = "".concat(this._method, ":").concat(this._uri, ":").concat(Utils.calculateMD5(body ? body : ''));
  885. ha2 = Utils.calculateMD5(a2);
  886. debug('authenticate() | using qop=auth-int [a2:"%s"]', a2); // Response = MD5(HA1:nonce:nonceCount:credentialsNonce:qop:HA2).
  887. this._response = Utils.calculateMD5("".concat(this._ha1, ":").concat(this._nonce, ":").concat(this._ncHex, ":").concat(this._cnonce, ":auth-int:").concat(ha2));
  888. } else if (this._qop === null) {
  889. // HA2 = MD5(A2) = MD5(method:digestURI).
  890. a2 = "".concat(this._method, ":").concat(this._uri);
  891. ha2 = Utils.calculateMD5(a2);
  892. debug('authenticate() | using qop=null [a2:"%s"]', a2); // Response = MD5(HA1:nonce:HA2).
  893. this._response = Utils.calculateMD5("".concat(this._ha1, ":").concat(this._nonce, ":").concat(ha2));
  894. }
  895. debug('authenticate() | response generated');
  896. return true;
  897. }
  898. /**
  899. * Return the Proxy-Authorization or WWW-Authorization header value.
  900. */
  901. }, {
  902. key: "toString",
  903. value: function toString() {
  904. var auth_params = [];
  905. if (!this._response) {
  906. throw new Error('response field does not exist, cannot generate Authorization header');
  907. }
  908. auth_params.push("algorithm=".concat(this._algorithm));
  909. auth_params.push("username=\"".concat(this._credentials.username, "\""));
  910. auth_params.push("realm=\"".concat(this._realm, "\""));
  911. auth_params.push("nonce=\"".concat(this._nonce, "\""));
  912. auth_params.push("uri=\"".concat(this._uri, "\""));
  913. auth_params.push("response=\"".concat(this._response, "\""));
  914. if (this._opaque) {
  915. auth_params.push("opaque=\"".concat(this._opaque, "\""));
  916. }
  917. if (this._qop) {
  918. auth_params.push("qop=".concat(this._qop));
  919. auth_params.push("cnonce=\"".concat(this._cnonce, "\""));
  920. auth_params.push("nc=".concat(this._ncHex));
  921. }
  922. return "Digest ".concat(auth_params.join(', '));
  923. }
  924. }]);
  925. return DigestAuthentication;
  926. }();
  927. },{"./Utils":26,"debug":30}],6:[function(require,module,exports){
  928. "use strict";
  929. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  930. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  931. function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  932. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  933. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  934. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  935. function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== "function") { throw new TypeError("Super expression must either be null or a function"); } if (typeof _cache !== "undefined") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }
  936. function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
  937. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  938. function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
  939. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  940. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  941. var ConfigurationError = /*#__PURE__*/function (_Error) {
  942. _inherits(ConfigurationError, _Error);
  943. var _super = _createSuper(ConfigurationError);
  944. function ConfigurationError(parameter, value) {
  945. var _this;
  946. _classCallCheck(this, ConfigurationError);
  947. _this = _super.call(this);
  948. _this.code = 1;
  949. _this.name = 'CONFIGURATION_ERROR';
  950. _this.parameter = parameter;
  951. _this.value = value;
  952. _this.message = !_this.value ? "Missing parameter: ".concat(_this.parameter) : "Invalid value ".concat(JSON.stringify(_this.value), " for parameter \"").concat(_this.parameter, "\"");
  953. return _this;
  954. }
  955. return ConfigurationError;
  956. }( /*#__PURE__*/_wrapNativeSuper(Error));
  957. var InvalidStateError = /*#__PURE__*/function (_Error2) {
  958. _inherits(InvalidStateError, _Error2);
  959. var _super2 = _createSuper(InvalidStateError);
  960. function InvalidStateError(status) {
  961. var _this2;
  962. _classCallCheck(this, InvalidStateError);
  963. _this2 = _super2.call(this);
  964. _this2.code = 2;
  965. _this2.name = 'INVALID_STATE_ERROR';
  966. _this2.status = status;
  967. _this2.message = "Invalid status: ".concat(status);
  968. return _this2;
  969. }
  970. return InvalidStateError;
  971. }( /*#__PURE__*/_wrapNativeSuper(Error));
  972. var NotSupportedError = /*#__PURE__*/function (_Error3) {
  973. _inherits(NotSupportedError, _Error3);
  974. var _super3 = _createSuper(NotSupportedError);
  975. function NotSupportedError(message) {
  976. var _this3;
  977. _classCallCheck(this, NotSupportedError);
  978. _this3 = _super3.call(this);
  979. _this3.code = 3;
  980. _this3.name = 'NOT_SUPPORTED_ERROR';
  981. _this3.message = message;
  982. return _this3;
  983. }
  984. return NotSupportedError;
  985. }( /*#__PURE__*/_wrapNativeSuper(Error));
  986. var NotReadyError = /*#__PURE__*/function (_Error4) {
  987. _inherits(NotReadyError, _Error4);
  988. var _super4 = _createSuper(NotReadyError);
  989. function NotReadyError(message) {
  990. var _this4;
  991. _classCallCheck(this, NotReadyError);
  992. _this4 = _super4.call(this);
  993. _this4.code = 4;
  994. _this4.name = 'NOT_READY_ERROR';
  995. _this4.message = message;
  996. return _this4;
  997. }
  998. return NotReadyError;
  999. }( /*#__PURE__*/_wrapNativeSuper(Error));
  1000. module.exports = {
  1001. ConfigurationError: ConfigurationError,
  1002. InvalidStateError: InvalidStateError,
  1003. NotSupportedError: NotSupportedError,
  1004. NotReadyError: NotReadyError
  1005. };
  1006. },{}],7:[function(require,module,exports){
  1007. "use strict";
  1008. module.exports = function () {
  1009. /*
  1010. * Generated by PEG.js 0.7.0.
  1011. *
  1012. * http://pegjs.majda.cz/
  1013. */
  1014. function quote(s) {
  1015. /*
  1016. * ECMA-262, 5th ed., 7.8.4: All characters may appear literally in a
  1017. * string literal except for the closing quote character, backslash,
  1018. * carriage return, line separator, paragraph separator, and line feed.
  1019. * Any character may appear in the form of an escape sequence.
  1020. *
  1021. * For portability, we also escape escape all control and non-ASCII
  1022. * characters. Note that "\0" and "\v" escape sequences are not used
  1023. * because JSHint does not like the first and IE the second.
  1024. */
  1025. return '"' + s.replace(/\\/g, '\\\\') // backslash
  1026. .replace(/"/g, '\\"') // closing quote character
  1027. .replace(/\x08/g, '\\b') // backspace
  1028. .replace(/\t/g, '\\t') // horizontal tab
  1029. .replace(/\n/g, '\\n') // line feed
  1030. .replace(/\f/g, '\\f') // form feed
  1031. .replace(/\r/g, '\\r') // carriage return
  1032. .replace(/[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]/g, escape) + '"';
  1033. }
  1034. var result = {
  1035. /*
  1036. * Parses the input with a generated parser. If the parsing is successfull,
  1037. * returns a value explicitly or implicitly specified by the grammar from
  1038. * which the parser was generated (see |PEG.buildParser|). If the parsing is
  1039. * unsuccessful, throws |PEG.parser.SyntaxError| describing the error.
  1040. */
  1041. parse: function parse(input, startRule) {
  1042. var parseFunctions = {
  1043. "CRLF": parse_CRLF,
  1044. "DIGIT": parse_DIGIT,
  1045. "ALPHA": parse_ALPHA,
  1046. "HEXDIG": parse_HEXDIG,
  1047. "WSP": parse_WSP,
  1048. "OCTET": parse_OCTET,
  1049. "DQUOTE": parse_DQUOTE,
  1050. "SP": parse_SP,
  1051. "HTAB": parse_HTAB,
  1052. "alphanum": parse_alphanum,
  1053. "reserved": parse_reserved,
  1054. "unreserved": parse_unreserved,
  1055. "mark": parse_mark,
  1056. "escaped": parse_escaped,
  1057. "LWS": parse_LWS,
  1058. "SWS": parse_SWS,
  1059. "HCOLON": parse_HCOLON,
  1060. "TEXT_UTF8_TRIM": parse_TEXT_UTF8_TRIM,
  1061. "TEXT_UTF8char": parse_TEXT_UTF8char,
  1062. "UTF8_NONASCII": parse_UTF8_NONASCII,
  1063. "UTF8_CONT": parse_UTF8_CONT,
  1064. "LHEX": parse_LHEX,
  1065. "token": parse_token,
  1066. "token_nodot": parse_token_nodot,
  1067. "separators": parse_separators,
  1068. "word": parse_word,
  1069. "STAR": parse_STAR,
  1070. "SLASH": parse_SLASH,
  1071. "EQUAL": parse_EQUAL,
  1072. "LPAREN": parse_LPAREN,
  1073. "RPAREN": parse_RPAREN,
  1074. "RAQUOT": parse_RAQUOT,
  1075. "LAQUOT": parse_LAQUOT,
  1076. "COMMA": parse_COMMA,
  1077. "SEMI": parse_SEMI,
  1078. "COLON": parse_COLON,
  1079. "LDQUOT": parse_LDQUOT,
  1080. "RDQUOT": parse_RDQUOT,
  1081. "comment": parse_comment,
  1082. "ctext": parse_ctext,
  1083. "quoted_string": parse_quoted_string,
  1084. "quoted_string_clean": parse_quoted_string_clean,
  1085. "qdtext": parse_qdtext,
  1086. "quoted_pair": parse_quoted_pair,
  1087. "SIP_URI_noparams": parse_SIP_URI_noparams,
  1088. "SIP_URI": parse_SIP_URI,
  1089. "uri_scheme": parse_uri_scheme,
  1090. "uri_scheme_sips": parse_uri_scheme_sips,
  1091. "uri_scheme_sip": parse_uri_scheme_sip,
  1092. "userinfo": parse_userinfo,
  1093. "user": parse_user,
  1094. "user_unreserved": parse_user_unreserved,
  1095. "password": parse_password,
  1096. "hostport": parse_hostport,
  1097. "host": parse_host,
  1098. "hostname": parse_hostname,
  1099. "domainlabel": parse_domainlabel,
  1100. "toplabel": parse_toplabel,
  1101. "IPv6reference": parse_IPv6reference,
  1102. "IPv6address": parse_IPv6address,
  1103. "h16": parse_h16,
  1104. "ls32": parse_ls32,
  1105. "IPv4address": parse_IPv4address,
  1106. "dec_octet": parse_dec_octet,
  1107. "port": parse_port,
  1108. "uri_parameters": parse_uri_parameters,
  1109. "uri_parameter": parse_uri_parameter,
  1110. "transport_param": parse_transport_param,
  1111. "user_param": parse_user_param,
  1112. "method_param": parse_method_param,
  1113. "ttl_param": parse_ttl_param,
  1114. "maddr_param": parse_maddr_param,
  1115. "lr_param": parse_lr_param,
  1116. "other_param": parse_other_param,
  1117. "pname": parse_pname,
  1118. "pvalue": parse_pvalue,
  1119. "paramchar": parse_paramchar,
  1120. "param_unreserved": parse_param_unreserved,
  1121. "headers": parse_headers,
  1122. "header": parse_header,
  1123. "hname": parse_hname,
  1124. "hvalue": parse_hvalue,
  1125. "hnv_unreserved": parse_hnv_unreserved,
  1126. "Request_Response": parse_Request_Response,
  1127. "Request_Line": parse_Request_Line,
  1128. "Request_URI": parse_Request_URI,
  1129. "absoluteURI": parse_absoluteURI,
  1130. "hier_part": parse_hier_part,
  1131. "net_path": parse_net_path,
  1132. "abs_path": parse_abs_path,
  1133. "opaque_part": parse_opaque_part,
  1134. "uric": parse_uric,
  1135. "uric_no_slash": parse_uric_no_slash,
  1136. "path_segments": parse_path_segments,
  1137. "segment": parse_segment,
  1138. "param": parse_param,
  1139. "pchar": parse_pchar,
  1140. "scheme": parse_scheme,
  1141. "authority": parse_authority,
  1142. "srvr": parse_srvr,
  1143. "reg_name": parse_reg_name,
  1144. "query": parse_query,
  1145. "SIP_Version": parse_SIP_Version,
  1146. "INVITEm": parse_INVITEm,
  1147. "ACKm": parse_ACKm,
  1148. "OPTIONSm": parse_OPTIONSm,
  1149. "BYEm": parse_BYEm,
  1150. "CANCELm": parse_CANCELm,
  1151. "REGISTERm": parse_REGISTERm,
  1152. "SUBSCRIBEm": parse_SUBSCRIBEm,
  1153. "NOTIFYm": parse_NOTIFYm,
  1154. "REFERm": parse_REFERm,
  1155. "Method": parse_Method,
  1156. "Status_Line": parse_Status_Line,
  1157. "Status_Code": parse_Status_Code,
  1158. "extension_code": parse_extension_code,
  1159. "Reason_Phrase": parse_Reason_Phrase,
  1160. "Allow_Events": parse_Allow_Events,
  1161. "Call_ID": parse_Call_ID,
  1162. "Contact": parse_Contact,
  1163. "contact_param": parse_contact_param,
  1164. "name_addr": parse_name_addr,
  1165. "display_name": parse_display_name,
  1166. "contact_params": parse_contact_params,
  1167. "c_p_q": parse_c_p_q,
  1168. "c_p_expires": parse_c_p_expires,
  1169. "delta_seconds": parse_delta_seconds,
  1170. "qvalue": parse_qvalue,
  1171. "generic_param": parse_generic_param,
  1172. "gen_value": parse_gen_value,
  1173. "Content_Disposition": parse_Content_Disposition,
  1174. "disp_type": parse_disp_type,
  1175. "disp_param": parse_disp_param,
  1176. "handling_param": parse_handling_param,
  1177. "Content_Encoding": parse_Content_Encoding,
  1178. "Content_Length": parse_Content_Length,
  1179. "Content_Type": parse_Content_Type,
  1180. "media_type": parse_media_type,
  1181. "m_type": parse_m_type,
  1182. "discrete_type": parse_discrete_type,
  1183. "composite_type": parse_composite_type,
  1184. "extension_token": parse_extension_token,
  1185. "x_token": parse_x_token,
  1186. "m_subtype": parse_m_subtype,
  1187. "m_parameter": parse_m_parameter,
  1188. "m_value": parse_m_value,
  1189. "CSeq": parse_CSeq,
  1190. "CSeq_value": parse_CSeq_value,
  1191. "Expires": parse_Expires,
  1192. "Event": parse_Event,
  1193. "event_type": parse_event_type,
  1194. "From": parse_From,
  1195. "from_param": parse_from_param,
  1196. "tag_param": parse_tag_param,
  1197. "Max_Forwards": parse_Max_Forwards,
  1198. "Min_Expires": parse_Min_Expires,
  1199. "Name_Addr_Header": parse_Name_Addr_Header,
  1200. "Proxy_Authenticate": parse_Proxy_Authenticate,
  1201. "challenge": parse_challenge,
  1202. "other_challenge": parse_other_challenge,
  1203. "auth_param": parse_auth_param,
  1204. "digest_cln": parse_digest_cln,
  1205. "realm": parse_realm,
  1206. "realm_value": parse_realm_value,
  1207. "domain": parse_domain,
  1208. "URI": parse_URI,
  1209. "nonce": parse_nonce,
  1210. "nonce_value": parse_nonce_value,
  1211. "opaque": parse_opaque,
  1212. "stale": parse_stale,
  1213. "algorithm": parse_algorithm,
  1214. "qop_options": parse_qop_options,
  1215. "qop_value": parse_qop_value,
  1216. "Proxy_Require": parse_Proxy_Require,
  1217. "Record_Route": parse_Record_Route,
  1218. "rec_route": parse_rec_route,
  1219. "Reason": parse_Reason,
  1220. "reason_param": parse_reason_param,
  1221. "reason_cause": parse_reason_cause,
  1222. "Require": parse_Require,
  1223. "Route": parse_Route,
  1224. "route_param": parse_route_param,
  1225. "Subscription_State": parse_Subscription_State,
  1226. "substate_value": parse_substate_value,
  1227. "subexp_params": parse_subexp_params,
  1228. "event_reason_value": parse_event_reason_value,
  1229. "Subject": parse_Subject,
  1230. "Supported": parse_Supported,
  1231. "To": parse_To,
  1232. "to_param": parse_to_param,
  1233. "Via": parse_Via,
  1234. "via_param": parse_via_param,
  1235. "via_params": parse_via_params,
  1236. "via_ttl": parse_via_ttl,
  1237. "via_maddr": parse_via_maddr,
  1238. "via_received": parse_via_received,
  1239. "via_branch": parse_via_branch,
  1240. "response_port": parse_response_port,
  1241. "sent_protocol": parse_sent_protocol,
  1242. "protocol_name": parse_protocol_name,
  1243. "transport": parse_transport,
  1244. "sent_by": parse_sent_by,
  1245. "via_host": parse_via_host,
  1246. "via_port": parse_via_port,
  1247. "ttl": parse_ttl,
  1248. "WWW_Authenticate": parse_WWW_Authenticate,
  1249. "Session_Expires": parse_Session_Expires,
  1250. "s_e_expires": parse_s_e_expires,
  1251. "s_e_params": parse_s_e_params,
  1252. "s_e_refresher": parse_s_e_refresher,
  1253. "extension_header": parse_extension_header,
  1254. "header_value": parse_header_value,
  1255. "message_body": parse_message_body,
  1256. "uuid_URI": parse_uuid_URI,
  1257. "uuid": parse_uuid,
  1258. "hex4": parse_hex4,
  1259. "hex8": parse_hex8,
  1260. "hex12": parse_hex12,
  1261. "Refer_To": parse_Refer_To,
  1262. "Replaces": parse_Replaces,
  1263. "call_id": parse_call_id,
  1264. "replaces_param": parse_replaces_param,
  1265. "to_tag": parse_to_tag,
  1266. "from_tag": parse_from_tag,
  1267. "early_flag": parse_early_flag
  1268. };
  1269. if (startRule !== undefined) {
  1270. if (parseFunctions[startRule] === undefined) {
  1271. throw new Error("Invalid rule name: " + quote(startRule) + ".");
  1272. }
  1273. } else {
  1274. startRule = "CRLF";
  1275. }
  1276. var pos = 0;
  1277. var reportFailures = 0;
  1278. var rightmostFailuresPos = 0;
  1279. var rightmostFailuresExpected = [];
  1280. function padLeft(input, padding, length) {
  1281. var result = input;
  1282. var padLength = length - input.length;
  1283. for (var i = 0; i < padLength; i++) {
  1284. result = padding + result;
  1285. }
  1286. return result;
  1287. }
  1288. function escape(ch) {
  1289. var charCode = ch.charCodeAt(0);
  1290. var escapeChar;
  1291. var length;
  1292. if (charCode <= 0xFF) {
  1293. escapeChar = 'x';
  1294. length = 2;
  1295. } else {
  1296. escapeChar = 'u';
  1297. length = 4;
  1298. }
  1299. return '\\' + escapeChar + padLeft(charCode.toString(16).toUpperCase(), '0', length);
  1300. }
  1301. function matchFailed(failure) {
  1302. if (pos < rightmostFailuresPos) {
  1303. return;
  1304. }
  1305. if (pos > rightmostFailuresPos) {
  1306. rightmostFailuresPos = pos;
  1307. rightmostFailuresExpected = [];
  1308. }
  1309. rightmostFailuresExpected.push(failure);
  1310. }
  1311. function parse_CRLF() {
  1312. var result0;
  1313. if (input.substr(pos, 2) === "\r\n") {
  1314. result0 = "\r\n";
  1315. pos += 2;
  1316. } else {
  1317. result0 = null;
  1318. if (reportFailures === 0) {
  1319. matchFailed("\"\\r\\n\"");
  1320. }
  1321. }
  1322. return result0;
  1323. }
  1324. function parse_DIGIT() {
  1325. var result0;
  1326. if (/^[0-9]/.test(input.charAt(pos))) {
  1327. result0 = input.charAt(pos);
  1328. pos++;
  1329. } else {
  1330. result0 = null;
  1331. if (reportFailures === 0) {
  1332. matchFailed("[0-9]");
  1333. }
  1334. }
  1335. return result0;
  1336. }
  1337. function parse_ALPHA() {
  1338. var result0;
  1339. if (/^[a-zA-Z]/.test(input.charAt(pos))) {
  1340. result0 = input.charAt(pos);
  1341. pos++;
  1342. } else {
  1343. result0 = null;
  1344. if (reportFailures === 0) {
  1345. matchFailed("[a-zA-Z]");
  1346. }
  1347. }
  1348. return result0;
  1349. }
  1350. function parse_HEXDIG() {
  1351. var result0;
  1352. if (/^[0-9a-fA-F]/.test(input.charAt(pos))) {
  1353. result0 = input.charAt(pos);
  1354. pos++;
  1355. } else {
  1356. result0 = null;
  1357. if (reportFailures === 0) {
  1358. matchFailed("[0-9a-fA-F]");
  1359. }
  1360. }
  1361. return result0;
  1362. }
  1363. function parse_WSP() {
  1364. var result0;
  1365. result0 = parse_SP();
  1366. if (result0 === null) {
  1367. result0 = parse_HTAB();
  1368. }
  1369. return result0;
  1370. }
  1371. function parse_OCTET() {
  1372. var result0;
  1373. if (/^[\0-\xFF]/.test(input.charAt(pos))) {
  1374. result0 = input.charAt(pos);
  1375. pos++;
  1376. } else {
  1377. result0 = null;
  1378. if (reportFailures === 0) {
  1379. matchFailed("[\\0-\\xFF]");
  1380. }
  1381. }
  1382. return result0;
  1383. }
  1384. function parse_DQUOTE() {
  1385. var result0;
  1386. if (/^["]/.test(input.charAt(pos))) {
  1387. result0 = input.charAt(pos);
  1388. pos++;
  1389. } else {
  1390. result0 = null;
  1391. if (reportFailures === 0) {
  1392. matchFailed("[\"]");
  1393. }
  1394. }
  1395. return result0;
  1396. }
  1397. function parse_SP() {
  1398. var result0;
  1399. if (input.charCodeAt(pos) === 32) {
  1400. result0 = " ";
  1401. pos++;
  1402. } else {
  1403. result0 = null;
  1404. if (reportFailures === 0) {
  1405. matchFailed("\" \"");
  1406. }
  1407. }
  1408. return result0;
  1409. }
  1410. function parse_HTAB() {
  1411. var result0;
  1412. if (input.charCodeAt(pos) === 9) {
  1413. result0 = "\t";
  1414. pos++;
  1415. } else {
  1416. result0 = null;
  1417. if (reportFailures === 0) {
  1418. matchFailed("\"\\t\"");
  1419. }
  1420. }
  1421. return result0;
  1422. }
  1423. function parse_alphanum() {
  1424. var result0;
  1425. if (/^[a-zA-Z0-9]/.test(input.charAt(pos))) {
  1426. result0 = input.charAt(pos);
  1427. pos++;
  1428. } else {
  1429. result0 = null;
  1430. if (reportFailures === 0) {
  1431. matchFailed("[a-zA-Z0-9]");
  1432. }
  1433. }
  1434. return result0;
  1435. }
  1436. function parse_reserved() {
  1437. var result0;
  1438. if (input.charCodeAt(pos) === 59) {
  1439. result0 = ";";
  1440. pos++;
  1441. } else {
  1442. result0 = null;
  1443. if (reportFailures === 0) {
  1444. matchFailed("\";\"");
  1445. }
  1446. }
  1447. if (result0 === null) {
  1448. if (input.charCodeAt(pos) === 47) {
  1449. result0 = "/";
  1450. pos++;
  1451. } else {
  1452. result0 = null;
  1453. if (reportFailures === 0) {
  1454. matchFailed("\"/\"");
  1455. }
  1456. }
  1457. if (result0 === null) {
  1458. if (input.charCodeAt(pos) === 63) {
  1459. result0 = "?";
  1460. pos++;
  1461. } else {
  1462. result0 = null;
  1463. if (reportFailures === 0) {
  1464. matchFailed("\"?\"");
  1465. }
  1466. }
  1467. if (result0 === null) {
  1468. if (input.charCodeAt(pos) === 58) {
  1469. result0 = ":";
  1470. pos++;
  1471. } else {
  1472. result0 = null;
  1473. if (reportFailures === 0) {
  1474. matchFailed("\":\"");
  1475. }
  1476. }
  1477. if (result0 === null) {
  1478. if (input.charCodeAt(pos) === 64) {
  1479. result0 = "@";
  1480. pos++;
  1481. } else {
  1482. result0 = null;
  1483. if (reportFailures === 0) {
  1484. matchFailed("\"@\"");
  1485. }
  1486. }
  1487. if (result0 === null) {
  1488. if (input.charCodeAt(pos) === 38) {
  1489. result0 = "&";
  1490. pos++;
  1491. } else {
  1492. result0 = null;
  1493. if (reportFailures === 0) {
  1494. matchFailed("\"&\"");
  1495. }
  1496. }
  1497. if (result0 === null) {
  1498. if (input.charCodeAt(pos) === 61) {
  1499. result0 = "=";
  1500. pos++;
  1501. } else {
  1502. result0 = null;
  1503. if (reportFailures === 0) {
  1504. matchFailed("\"=\"");
  1505. }
  1506. }
  1507. if (result0 === null) {
  1508. if (input.charCodeAt(pos) === 43) {
  1509. result0 = "+";
  1510. pos++;
  1511. } else {
  1512. result0 = null;
  1513. if (reportFailures === 0) {
  1514. matchFailed("\"+\"");
  1515. }
  1516. }
  1517. if (result0 === null) {
  1518. if (input.charCodeAt(pos) === 36) {
  1519. result0 = "$";
  1520. pos++;
  1521. } else {
  1522. result0 = null;
  1523. if (reportFailures === 0) {
  1524. matchFailed("\"$\"");
  1525. }
  1526. }
  1527. if (result0 === null) {
  1528. if (input.charCodeAt(pos) === 44) {
  1529. result0 = ",";
  1530. pos++;
  1531. } else {
  1532. result0 = null;
  1533. if (reportFailures === 0) {
  1534. matchFailed("\",\"");
  1535. }
  1536. }
  1537. }
  1538. }
  1539. }
  1540. }
  1541. }
  1542. }
  1543. }
  1544. }
  1545. }
  1546. return result0;
  1547. }
  1548. function parse_unreserved() {
  1549. var result0;
  1550. result0 = parse_alphanum();
  1551. if (result0 === null) {
  1552. result0 = parse_mark();
  1553. }
  1554. return result0;
  1555. }
  1556. function parse_mark() {
  1557. var result0;
  1558. if (input.charCodeAt(pos) === 45) {
  1559. result0 = "-";
  1560. pos++;
  1561. } else {
  1562. result0 = null;
  1563. if (reportFailures === 0) {
  1564. matchFailed("\"-\"");
  1565. }
  1566. }
  1567. if (result0 === null) {
  1568. if (input.charCodeAt(pos) === 95) {
  1569. result0 = "_";
  1570. pos++;
  1571. } else {
  1572. result0 = null;
  1573. if (reportFailures === 0) {
  1574. matchFailed("\"_\"");
  1575. }
  1576. }
  1577. if (result0 === null) {
  1578. if (input.charCodeAt(pos) === 46) {
  1579. result0 = ".";
  1580. pos++;
  1581. } else {
  1582. result0 = null;
  1583. if (reportFailures === 0) {
  1584. matchFailed("\".\"");
  1585. }
  1586. }
  1587. if (result0 === null) {
  1588. if (input.charCodeAt(pos) === 33) {
  1589. result0 = "!";
  1590. pos++;
  1591. } else {
  1592. result0 = null;
  1593. if (reportFailures === 0) {
  1594. matchFailed("\"!\"");
  1595. }
  1596. }
  1597. if (result0 === null) {
  1598. if (input.charCodeAt(pos) === 126) {
  1599. result0 = "~";
  1600. pos++;
  1601. } else {
  1602. result0 = null;
  1603. if (reportFailures === 0) {
  1604. matchFailed("\"~\"");
  1605. }
  1606. }
  1607. if (result0 === null) {
  1608. if (input.charCodeAt(pos) === 42) {
  1609. result0 = "*";
  1610. pos++;
  1611. } else {
  1612. result0 = null;
  1613. if (reportFailures === 0) {
  1614. matchFailed("\"*\"");
  1615. }
  1616. }
  1617. if (result0 === null) {
  1618. if (input.charCodeAt(pos) === 39) {
  1619. result0 = "'";
  1620. pos++;
  1621. } else {
  1622. result0 = null;
  1623. if (reportFailures === 0) {
  1624. matchFailed("\"'\"");
  1625. }
  1626. }
  1627. if (result0 === null) {
  1628. if (input.charCodeAt(pos) === 40) {
  1629. result0 = "(";
  1630. pos++;
  1631. } else {
  1632. result0 = null;
  1633. if (reportFailures === 0) {
  1634. matchFailed("\"(\"");
  1635. }
  1636. }
  1637. if (result0 === null) {
  1638. if (input.charCodeAt(pos) === 41) {
  1639. result0 = ")";
  1640. pos++;
  1641. } else {
  1642. result0 = null;
  1643. if (reportFailures === 0) {
  1644. matchFailed("\")\"");
  1645. }
  1646. }
  1647. }
  1648. }
  1649. }
  1650. }
  1651. }
  1652. }
  1653. }
  1654. }
  1655. return result0;
  1656. }
  1657. function parse_escaped() {
  1658. var result0, result1, result2;
  1659. var pos0, pos1;
  1660. pos0 = pos;
  1661. pos1 = pos;
  1662. if (input.charCodeAt(pos) === 37) {
  1663. result0 = "%";
  1664. pos++;
  1665. } else {
  1666. result0 = null;
  1667. if (reportFailures === 0) {
  1668. matchFailed("\"%\"");
  1669. }
  1670. }
  1671. if (result0 !== null) {
  1672. result1 = parse_HEXDIG();
  1673. if (result1 !== null) {
  1674. result2 = parse_HEXDIG();
  1675. if (result2 !== null) {
  1676. result0 = [result0, result1, result2];
  1677. } else {
  1678. result0 = null;
  1679. pos = pos1;
  1680. }
  1681. } else {
  1682. result0 = null;
  1683. pos = pos1;
  1684. }
  1685. } else {
  1686. result0 = null;
  1687. pos = pos1;
  1688. }
  1689. if (result0 !== null) {
  1690. result0 = function (offset, escaped) {
  1691. return escaped.join('');
  1692. }(pos0, result0);
  1693. }
  1694. if (result0 === null) {
  1695. pos = pos0;
  1696. }
  1697. return result0;
  1698. }
  1699. function parse_LWS() {
  1700. var result0, result1, result2;
  1701. var pos0, pos1, pos2;
  1702. pos0 = pos;
  1703. pos1 = pos;
  1704. pos2 = pos;
  1705. result0 = [];
  1706. result1 = parse_WSP();
  1707. while (result1 !== null) {
  1708. result0.push(result1);
  1709. result1 = parse_WSP();
  1710. }
  1711. if (result0 !== null) {
  1712. result1 = parse_CRLF();
  1713. if (result1 !== null) {
  1714. result0 = [result0, result1];
  1715. } else {
  1716. result0 = null;
  1717. pos = pos2;
  1718. }
  1719. } else {
  1720. result0 = null;
  1721. pos = pos2;
  1722. }
  1723. result0 = result0 !== null ? result0 : "";
  1724. if (result0 !== null) {
  1725. result2 = parse_WSP();
  1726. if (result2 !== null) {
  1727. result1 = [];
  1728. while (result2 !== null) {
  1729. result1.push(result2);
  1730. result2 = parse_WSP();
  1731. }
  1732. } else {
  1733. result1 = null;
  1734. }
  1735. if (result1 !== null) {
  1736. result0 = [result0, result1];
  1737. } else {
  1738. result0 = null;
  1739. pos = pos1;
  1740. }
  1741. } else {
  1742. result0 = null;
  1743. pos = pos1;
  1744. }
  1745. if (result0 !== null) {
  1746. result0 = function (offset) {
  1747. return " ";
  1748. }(pos0);
  1749. }
  1750. if (result0 === null) {
  1751. pos = pos0;
  1752. }
  1753. return result0;
  1754. }
  1755. function parse_SWS() {
  1756. var result0;
  1757. result0 = parse_LWS();
  1758. result0 = result0 !== null ? result0 : "";
  1759. return result0;
  1760. }
  1761. function parse_HCOLON() {
  1762. var result0, result1, result2;
  1763. var pos0, pos1;
  1764. pos0 = pos;
  1765. pos1 = pos;
  1766. result0 = [];
  1767. result1 = parse_SP();
  1768. if (result1 === null) {
  1769. result1 = parse_HTAB();
  1770. }
  1771. while (result1 !== null) {
  1772. result0.push(result1);
  1773. result1 = parse_SP();
  1774. if (result1 === null) {
  1775. result1 = parse_HTAB();
  1776. }
  1777. }
  1778. if (result0 !== null) {
  1779. if (input.charCodeAt(pos) === 58) {
  1780. result1 = ":";
  1781. pos++;
  1782. } else {
  1783. result1 = null;
  1784. if (reportFailures === 0) {
  1785. matchFailed("\":\"");
  1786. }
  1787. }
  1788. if (result1 !== null) {
  1789. result2 = parse_SWS();
  1790. if (result2 !== null) {
  1791. result0 = [result0, result1, result2];
  1792. } else {
  1793. result0 = null;
  1794. pos = pos1;
  1795. }
  1796. } else {
  1797. result0 = null;
  1798. pos = pos1;
  1799. }
  1800. } else {
  1801. result0 = null;
  1802. pos = pos1;
  1803. }
  1804. if (result0 !== null) {
  1805. result0 = function (offset) {
  1806. return ':';
  1807. }(pos0);
  1808. }
  1809. if (result0 === null) {
  1810. pos = pos0;
  1811. }
  1812. return result0;
  1813. }
  1814. function parse_TEXT_UTF8_TRIM() {
  1815. var result0, result1, result2, result3;
  1816. var pos0, pos1, pos2;
  1817. pos0 = pos;
  1818. pos1 = pos;
  1819. result1 = parse_TEXT_UTF8char();
  1820. if (result1 !== null) {
  1821. result0 = [];
  1822. while (result1 !== null) {
  1823. result0.push(result1);
  1824. result1 = parse_TEXT_UTF8char();
  1825. }
  1826. } else {
  1827. result0 = null;
  1828. }
  1829. if (result0 !== null) {
  1830. result1 = [];
  1831. pos2 = pos;
  1832. result2 = [];
  1833. result3 = parse_LWS();
  1834. while (result3 !== null) {
  1835. result2.push(result3);
  1836. result3 = parse_LWS();
  1837. }
  1838. if (result2 !== null) {
  1839. result3 = parse_TEXT_UTF8char();
  1840. if (result3 !== null) {
  1841. result2 = [result2, result3];
  1842. } else {
  1843. result2 = null;
  1844. pos = pos2;
  1845. }
  1846. } else {
  1847. result2 = null;
  1848. pos = pos2;
  1849. }
  1850. while (result2 !== null) {
  1851. result1.push(result2);
  1852. pos2 = pos;
  1853. result2 = [];
  1854. result3 = parse_LWS();
  1855. while (result3 !== null) {
  1856. result2.push(result3);
  1857. result3 = parse_LWS();
  1858. }
  1859. if (result2 !== null) {
  1860. result3 = parse_TEXT_UTF8char();
  1861. if (result3 !== null) {
  1862. result2 = [result2, result3];
  1863. } else {
  1864. result2 = null;
  1865. pos = pos2;
  1866. }
  1867. } else {
  1868. result2 = null;
  1869. pos = pos2;
  1870. }
  1871. }
  1872. if (result1 !== null) {
  1873. result0 = [result0, result1];
  1874. } else {
  1875. result0 = null;
  1876. pos = pos1;
  1877. }
  1878. } else {
  1879. result0 = null;
  1880. pos = pos1;
  1881. }
  1882. if (result0 !== null) {
  1883. result0 = function (offset) {
  1884. return input.substring(pos, offset);
  1885. }(pos0);
  1886. }
  1887. if (result0 === null) {
  1888. pos = pos0;
  1889. }
  1890. return result0;
  1891. }
  1892. function parse_TEXT_UTF8char() {
  1893. var result0;
  1894. if (/^[!-~]/.test(input.charAt(pos))) {
  1895. result0 = input.charAt(pos);
  1896. pos++;
  1897. } else {
  1898. result0 = null;
  1899. if (reportFailures === 0) {
  1900. matchFailed("[!-~]");
  1901. }
  1902. }
  1903. if (result0 === null) {
  1904. result0 = parse_UTF8_NONASCII();
  1905. }
  1906. return result0;
  1907. }
  1908. function parse_UTF8_NONASCII() {
  1909. var result0;
  1910. if (/^[\x80-\uFFFF]/.test(input.charAt(pos))) {
  1911. result0 = input.charAt(pos);
  1912. pos++;
  1913. } else {
  1914. result0 = null;
  1915. if (reportFailures === 0) {
  1916. matchFailed("[\\x80-\\uFFFF]");
  1917. }
  1918. }
  1919. return result0;
  1920. }
  1921. function parse_UTF8_CONT() {
  1922. var result0;
  1923. if (/^[\x80-\xBF]/.test(input.charAt(pos))) {
  1924. result0 = input.charAt(pos);
  1925. pos++;
  1926. } else {
  1927. result0 = null;
  1928. if (reportFailures === 0) {
  1929. matchFailed("[\\x80-\\xBF]");
  1930. }
  1931. }
  1932. return result0;
  1933. }
  1934. function parse_LHEX() {
  1935. var result0;
  1936. result0 = parse_DIGIT();
  1937. if (result0 === null) {
  1938. if (/^[a-f]/.test(input.charAt(pos))) {
  1939. result0 = input.charAt(pos);
  1940. pos++;
  1941. } else {
  1942. result0 = null;
  1943. if (reportFailures === 0) {
  1944. matchFailed("[a-f]");
  1945. }
  1946. }
  1947. }
  1948. return result0;
  1949. }
  1950. function parse_token() {
  1951. var result0, result1;
  1952. var pos0;
  1953. pos0 = pos;
  1954. result1 = parse_alphanum();
  1955. if (result1 === null) {
  1956. if (input.charCodeAt(pos) === 45) {
  1957. result1 = "-";
  1958. pos++;
  1959. } else {
  1960. result1 = null;
  1961. if (reportFailures === 0) {
  1962. matchFailed("\"-\"");
  1963. }
  1964. }
  1965. if (result1 === null) {
  1966. if (input.charCodeAt(pos) === 46) {
  1967. result1 = ".";
  1968. pos++;
  1969. } else {
  1970. result1 = null;
  1971. if (reportFailures === 0) {
  1972. matchFailed("\".\"");
  1973. }
  1974. }
  1975. if (result1 === null) {
  1976. if (input.charCodeAt(pos) === 33) {
  1977. result1 = "!";
  1978. pos++;
  1979. } else {
  1980. result1 = null;
  1981. if (reportFailures === 0) {
  1982. matchFailed("\"!\"");
  1983. }
  1984. }
  1985. if (result1 === null) {
  1986. if (input.charCodeAt(pos) === 37) {
  1987. result1 = "%";
  1988. pos++;
  1989. } else {
  1990. result1 = null;
  1991. if (reportFailures === 0) {
  1992. matchFailed("\"%\"");
  1993. }
  1994. }
  1995. if (result1 === null) {
  1996. if (input.charCodeAt(pos) === 42) {
  1997. result1 = "*";
  1998. pos++;
  1999. } else {
  2000. result1 = null;
  2001. if (reportFailures === 0) {
  2002. matchFailed("\"*\"");
  2003. }
  2004. }
  2005. if (result1 === null) {
  2006. if (input.charCodeAt(pos) === 95) {
  2007. result1 = "_";
  2008. pos++;
  2009. } else {
  2010. result1 = null;
  2011. if (reportFailures === 0) {
  2012. matchFailed("\"_\"");
  2013. }
  2014. }
  2015. if (result1 === null) {
  2016. if (input.charCodeAt(pos) === 43) {
  2017. result1 = "+";
  2018. pos++;
  2019. } else {
  2020. result1 = null;
  2021. if (reportFailures === 0) {
  2022. matchFailed("\"+\"");
  2023. }
  2024. }
  2025. if (result1 === null) {
  2026. if (input.charCodeAt(pos) === 96) {
  2027. result1 = "`";
  2028. pos++;
  2029. } else {
  2030. result1 = null;
  2031. if (reportFailures === 0) {
  2032. matchFailed("\"`\"");
  2033. }
  2034. }
  2035. if (result1 === null) {
  2036. if (input.charCodeAt(pos) === 39) {
  2037. result1 = "'";
  2038. pos++;
  2039. } else {
  2040. result1 = null;
  2041. if (reportFailures === 0) {
  2042. matchFailed("\"'\"");
  2043. }
  2044. }
  2045. if (result1 === null) {
  2046. if (input.charCodeAt(pos) === 126) {
  2047. result1 = "~";
  2048. pos++;
  2049. } else {
  2050. result1 = null;
  2051. if (reportFailures === 0) {
  2052. matchFailed("\"~\"");
  2053. }
  2054. }
  2055. }
  2056. }
  2057. }
  2058. }
  2059. }
  2060. }
  2061. }
  2062. }
  2063. }
  2064. }
  2065. if (result1 !== null) {
  2066. result0 = [];
  2067. while (result1 !== null) {
  2068. result0.push(result1);
  2069. result1 = parse_alphanum();
  2070. if (result1 === null) {
  2071. if (input.charCodeAt(pos) === 45) {
  2072. result1 = "-";
  2073. pos++;
  2074. } else {
  2075. result1 = null;
  2076. if (reportFailures === 0) {
  2077. matchFailed("\"-\"");
  2078. }
  2079. }
  2080. if (result1 === null) {
  2081. if (input.charCodeAt(pos) === 46) {
  2082. result1 = ".";
  2083. pos++;
  2084. } else {
  2085. result1 = null;
  2086. if (reportFailures === 0) {
  2087. matchFailed("\".\"");
  2088. }
  2089. }
  2090. if (result1 === null) {
  2091. if (input.charCodeAt(pos) === 33) {
  2092. result1 = "!";
  2093. pos++;
  2094. } else {
  2095. result1 = null;
  2096. if (reportFailures === 0) {
  2097. matchFailed("\"!\"");
  2098. }
  2099. }
  2100. if (result1 === null) {
  2101. if (input.charCodeAt(pos) === 37) {
  2102. result1 = "%";
  2103. pos++;
  2104. } else {
  2105. result1 = null;
  2106. if (reportFailures === 0) {
  2107. matchFailed("\"%\"");
  2108. }
  2109. }
  2110. if (result1 === null) {
  2111. if (input.charCodeAt(pos) === 42) {
  2112. result1 = "*";
  2113. pos++;
  2114. } else {
  2115. result1 = null;
  2116. if (reportFailures === 0) {
  2117. matchFailed("\"*\"");
  2118. }
  2119. }
  2120. if (result1 === null) {
  2121. if (input.charCodeAt(pos) === 95) {
  2122. result1 = "_";
  2123. pos++;
  2124. } else {
  2125. result1 = null;
  2126. if (reportFailures === 0) {
  2127. matchFailed("\"_\"");
  2128. }
  2129. }
  2130. if (result1 === null) {
  2131. if (input.charCodeAt(pos) === 43) {
  2132. result1 = "+";
  2133. pos++;
  2134. } else {
  2135. result1 = null;
  2136. if (reportFailures === 0) {
  2137. matchFailed("\"+\"");
  2138. }
  2139. }
  2140. if (result1 === null) {
  2141. if (input.charCodeAt(pos) === 96) {
  2142. result1 = "`";
  2143. pos++;
  2144. } else {
  2145. result1 = null;
  2146. if (reportFailures === 0) {
  2147. matchFailed("\"`\"");
  2148. }
  2149. }
  2150. if (result1 === null) {
  2151. if (input.charCodeAt(pos) === 39) {
  2152. result1 = "'";
  2153. pos++;
  2154. } else {
  2155. result1 = null;
  2156. if (reportFailures === 0) {
  2157. matchFailed("\"'\"");
  2158. }
  2159. }
  2160. if (result1 === null) {
  2161. if (input.charCodeAt(pos) === 126) {
  2162. result1 = "~";
  2163. pos++;
  2164. } else {
  2165. result1 = null;
  2166. if (reportFailures === 0) {
  2167. matchFailed("\"~\"");
  2168. }
  2169. }
  2170. }
  2171. }
  2172. }
  2173. }
  2174. }
  2175. }
  2176. }
  2177. }
  2178. }
  2179. }
  2180. }
  2181. } else {
  2182. result0 = null;
  2183. }
  2184. if (result0 !== null) {
  2185. result0 = function (offset) {
  2186. return input.substring(pos, offset);
  2187. }(pos0);
  2188. }
  2189. if (result0 === null) {
  2190. pos = pos0;
  2191. }
  2192. return result0;
  2193. }
  2194. function parse_token_nodot() {
  2195. var result0, result1;
  2196. var pos0;
  2197. pos0 = pos;
  2198. result1 = parse_alphanum();
  2199. if (result1 === null) {
  2200. if (input.charCodeAt(pos) === 45) {
  2201. result1 = "-";
  2202. pos++;
  2203. } else {
  2204. result1 = null;
  2205. if (reportFailures === 0) {
  2206. matchFailed("\"-\"");
  2207. }
  2208. }
  2209. if (result1 === null) {
  2210. if (input.charCodeAt(pos) === 33) {
  2211. result1 = "!";
  2212. pos++;
  2213. } else {
  2214. result1 = null;
  2215. if (reportFailures === 0) {
  2216. matchFailed("\"!\"");
  2217. }
  2218. }
  2219. if (result1 === null) {
  2220. if (input.charCodeAt(pos) === 37) {
  2221. result1 = "%";
  2222. pos++;
  2223. } else {
  2224. result1 = null;
  2225. if (reportFailures === 0) {
  2226. matchFailed("\"%\"");
  2227. }
  2228. }
  2229. if (result1 === null) {
  2230. if (input.charCodeAt(pos) === 42) {
  2231. result1 = "*";
  2232. pos++;
  2233. } else {
  2234. result1 = null;
  2235. if (reportFailures === 0) {
  2236. matchFailed("\"*\"");
  2237. }
  2238. }
  2239. if (result1 === null) {
  2240. if (input.charCodeAt(pos) === 95) {
  2241. result1 = "_";
  2242. pos++;
  2243. } else {
  2244. result1 = null;
  2245. if (reportFailures === 0) {
  2246. matchFailed("\"_\"");
  2247. }
  2248. }
  2249. if (result1 === null) {
  2250. if (input.charCodeAt(pos) === 43) {
  2251. result1 = "+";
  2252. pos++;
  2253. } else {
  2254. result1 = null;
  2255. if (reportFailures === 0) {
  2256. matchFailed("\"+\"");
  2257. }
  2258. }
  2259. if (result1 === null) {
  2260. if (input.charCodeAt(pos) === 96) {
  2261. result1 = "`";
  2262. pos++;
  2263. } else {
  2264. result1 = null;
  2265. if (reportFailures === 0) {
  2266. matchFailed("\"`\"");
  2267. }
  2268. }
  2269. if (result1 === null) {
  2270. if (input.charCodeAt(pos) === 39) {
  2271. result1 = "'";
  2272. pos++;
  2273. } else {
  2274. result1 = null;
  2275. if (reportFailures === 0) {
  2276. matchFailed("\"'\"");
  2277. }
  2278. }
  2279. if (result1 === null) {
  2280. if (input.charCodeAt(pos) === 126) {
  2281. result1 = "~";
  2282. pos++;
  2283. } else {
  2284. result1 = null;
  2285. if (reportFailures === 0) {
  2286. matchFailed("\"~\"");
  2287. }
  2288. }
  2289. }
  2290. }
  2291. }
  2292. }
  2293. }
  2294. }
  2295. }
  2296. }
  2297. }
  2298. if (result1 !== null) {
  2299. result0 = [];
  2300. while (result1 !== null) {
  2301. result0.push(result1);
  2302. result1 = parse_alphanum();
  2303. if (result1 === null) {
  2304. if (input.charCodeAt(pos) === 45) {
  2305. result1 = "-";
  2306. pos++;
  2307. } else {
  2308. result1 = null;
  2309. if (reportFailures === 0) {
  2310. matchFailed("\"-\"");
  2311. }
  2312. }
  2313. if (result1 === null) {
  2314. if (input.charCodeAt(pos) === 33) {
  2315. result1 = "!";
  2316. pos++;
  2317. } else {
  2318. result1 = null;
  2319. if (reportFailures === 0) {
  2320. matchFailed("\"!\"");
  2321. }
  2322. }
  2323. if (result1 === null) {
  2324. if (input.charCodeAt(pos) === 37) {
  2325. result1 = "%";
  2326. pos++;
  2327. } else {
  2328. result1 = null;
  2329. if (reportFailures === 0) {
  2330. matchFailed("\"%\"");
  2331. }
  2332. }
  2333. if (result1 === null) {
  2334. if (input.charCodeAt(pos) === 42) {
  2335. result1 = "*";
  2336. pos++;
  2337. } else {
  2338. result1 = null;
  2339. if (reportFailures === 0) {
  2340. matchFailed("\"*\"");
  2341. }
  2342. }
  2343. if (result1 === null) {
  2344. if (input.charCodeAt(pos) === 95) {
  2345. result1 = "_";
  2346. pos++;
  2347. } else {
  2348. result1 = null;
  2349. if (reportFailures === 0) {
  2350. matchFailed("\"_\"");
  2351. }
  2352. }
  2353. if (result1 === null) {
  2354. if (input.charCodeAt(pos) === 43) {
  2355. result1 = "+";
  2356. pos++;
  2357. } else {
  2358. result1 = null;
  2359. if (reportFailures === 0) {
  2360. matchFailed("\"+\"");
  2361. }
  2362. }
  2363. if (result1 === null) {
  2364. if (input.charCodeAt(pos) === 96) {
  2365. result1 = "`";
  2366. pos++;
  2367. } else {
  2368. result1 = null;
  2369. if (reportFailures === 0) {
  2370. matchFailed("\"`\"");
  2371. }
  2372. }
  2373. if (result1 === null) {
  2374. if (input.charCodeAt(pos) === 39) {
  2375. result1 = "'";
  2376. pos++;
  2377. } else {
  2378. result1 = null;
  2379. if (reportFailures === 0) {
  2380. matchFailed("\"'\"");
  2381. }
  2382. }
  2383. if (result1 === null) {
  2384. if (input.charCodeAt(pos) === 126) {
  2385. result1 = "~";
  2386. pos++;
  2387. } else {
  2388. result1 = null;
  2389. if (reportFailures === 0) {
  2390. matchFailed("\"~\"");
  2391. }
  2392. }
  2393. }
  2394. }
  2395. }
  2396. }
  2397. }
  2398. }
  2399. }
  2400. }
  2401. }
  2402. }
  2403. } else {
  2404. result0 = null;
  2405. }
  2406. if (result0 !== null) {
  2407. result0 = function (offset) {
  2408. return input.substring(pos, offset);
  2409. }(pos0);
  2410. }
  2411. if (result0 === null) {
  2412. pos = pos0;
  2413. }
  2414. return result0;
  2415. }
  2416. function parse_separators() {
  2417. var result0;
  2418. if (input.charCodeAt(pos) === 40) {
  2419. result0 = "(";
  2420. pos++;
  2421. } else {
  2422. result0 = null;
  2423. if (reportFailures === 0) {
  2424. matchFailed("\"(\"");
  2425. }
  2426. }
  2427. if (result0 === null) {
  2428. if (input.charCodeAt(pos) === 41) {
  2429. result0 = ")";
  2430. pos++;
  2431. } else {
  2432. result0 = null;
  2433. if (reportFailures === 0) {
  2434. matchFailed("\")\"");
  2435. }
  2436. }
  2437. if (result0 === null) {
  2438. if (input.charCodeAt(pos) === 60) {
  2439. result0 = "<";
  2440. pos++;
  2441. } else {
  2442. result0 = null;
  2443. if (reportFailures === 0) {
  2444. matchFailed("\"<\"");
  2445. }
  2446. }
  2447. if (result0 === null) {
  2448. if (input.charCodeAt(pos) === 62) {
  2449. result0 = ">";
  2450. pos++;
  2451. } else {
  2452. result0 = null;
  2453. if (reportFailures === 0) {
  2454. matchFailed("\">\"");
  2455. }
  2456. }
  2457. if (result0 === null) {
  2458. if (input.charCodeAt(pos) === 64) {
  2459. result0 = "@";
  2460. pos++;
  2461. } else {
  2462. result0 = null;
  2463. if (reportFailures === 0) {
  2464. matchFailed("\"@\"");
  2465. }
  2466. }
  2467. if (result0 === null) {
  2468. if (input.charCodeAt(pos) === 44) {
  2469. result0 = ",";
  2470. pos++;
  2471. } else {
  2472. result0 = null;
  2473. if (reportFailures === 0) {
  2474. matchFailed("\",\"");
  2475. }
  2476. }
  2477. if (result0 === null) {
  2478. if (input.charCodeAt(pos) === 59) {
  2479. result0 = ";";
  2480. pos++;
  2481. } else {
  2482. result0 = null;
  2483. if (reportFailures === 0) {
  2484. matchFailed("\";\"");
  2485. }
  2486. }
  2487. if (result0 === null) {
  2488. if (input.charCodeAt(pos) === 58) {
  2489. result0 = ":";
  2490. pos++;
  2491. } else {
  2492. result0 = null;
  2493. if (reportFailures === 0) {
  2494. matchFailed("\":\"");
  2495. }
  2496. }
  2497. if (result0 === null) {
  2498. if (input.charCodeAt(pos) === 92) {
  2499. result0 = "\\";
  2500. pos++;
  2501. } else {
  2502. result0 = null;
  2503. if (reportFailures === 0) {
  2504. matchFailed("\"\\\\\"");
  2505. }
  2506. }
  2507. if (result0 === null) {
  2508. result0 = parse_DQUOTE();
  2509. if (result0 === null) {
  2510. if (input.charCodeAt(pos) === 47) {
  2511. result0 = "/";
  2512. pos++;
  2513. } else {
  2514. result0 = null;
  2515. if (reportFailures === 0) {
  2516. matchFailed("\"/\"");
  2517. }
  2518. }
  2519. if (result0 === null) {
  2520. if (input.charCodeAt(pos) === 91) {
  2521. result0 = "[";
  2522. pos++;
  2523. } else {
  2524. result0 = null;
  2525. if (reportFailures === 0) {
  2526. matchFailed("\"[\"");
  2527. }
  2528. }
  2529. if (result0 === null) {
  2530. if (input.charCodeAt(pos) === 93) {
  2531. result0 = "]";
  2532. pos++;
  2533. } else {
  2534. result0 = null;
  2535. if (reportFailures === 0) {
  2536. matchFailed("\"]\"");
  2537. }
  2538. }
  2539. if (result0 === null) {
  2540. if (input.charCodeAt(pos) === 63) {
  2541. result0 = "?";
  2542. pos++;
  2543. } else {
  2544. result0 = null;
  2545. if (reportFailures === 0) {
  2546. matchFailed("\"?\"");
  2547. }
  2548. }
  2549. if (result0 === null) {
  2550. if (input.charCodeAt(pos) === 61) {
  2551. result0 = "=";
  2552. pos++;
  2553. } else {
  2554. result0 = null;
  2555. if (reportFailures === 0) {
  2556. matchFailed("\"=\"");
  2557. }
  2558. }
  2559. if (result0 === null) {
  2560. if (input.charCodeAt(pos) === 123) {
  2561. result0 = "{";
  2562. pos++;
  2563. } else {
  2564. result0 = null;
  2565. if (reportFailures === 0) {
  2566. matchFailed("\"{\"");
  2567. }
  2568. }
  2569. if (result0 === null) {
  2570. if (input.charCodeAt(pos) === 125) {
  2571. result0 = "}";
  2572. pos++;
  2573. } else {
  2574. result0 = null;
  2575. if (reportFailures === 0) {
  2576. matchFailed("\"}\"");
  2577. }
  2578. }
  2579. if (result0 === null) {
  2580. result0 = parse_SP();
  2581. if (result0 === null) {
  2582. result0 = parse_HTAB();
  2583. }
  2584. }
  2585. }
  2586. }
  2587. }
  2588. }
  2589. }
  2590. }
  2591. }
  2592. }
  2593. }
  2594. }
  2595. }
  2596. }
  2597. }
  2598. }
  2599. }
  2600. }
  2601. return result0;
  2602. }
  2603. function parse_word() {
  2604. var result0, result1;
  2605. var pos0;
  2606. pos0 = pos;
  2607. result1 = parse_alphanum();
  2608. if (result1 === null) {
  2609. if (input.charCodeAt(pos) === 45) {
  2610. result1 = "-";
  2611. pos++;
  2612. } else {
  2613. result1 = null;
  2614. if (reportFailures === 0) {
  2615. matchFailed("\"-\"");
  2616. }
  2617. }
  2618. if (result1 === null) {
  2619. if (input.charCodeAt(pos) === 46) {
  2620. result1 = ".";
  2621. pos++;
  2622. } else {
  2623. result1 = null;
  2624. if (reportFailures === 0) {
  2625. matchFailed("\".\"");
  2626. }
  2627. }
  2628. if (result1 === null) {
  2629. if (input.charCodeAt(pos) === 33) {
  2630. result1 = "!";
  2631. pos++;
  2632. } else {
  2633. result1 = null;
  2634. if (reportFailures === 0) {
  2635. matchFailed("\"!\"");
  2636. }
  2637. }
  2638. if (result1 === null) {
  2639. if (input.charCodeAt(pos) === 37) {
  2640. result1 = "%";
  2641. pos++;
  2642. } else {
  2643. result1 = null;
  2644. if (reportFailures === 0) {
  2645. matchFailed("\"%\"");
  2646. }
  2647. }
  2648. if (result1 === null) {
  2649. if (input.charCodeAt(pos) === 42) {
  2650. result1 = "*";
  2651. pos++;
  2652. } else {
  2653. result1 = null;
  2654. if (reportFailures === 0) {
  2655. matchFailed("\"*\"");
  2656. }
  2657. }
  2658. if (result1 === null) {
  2659. if (input.charCodeAt(pos) === 95) {
  2660. result1 = "_";
  2661. pos++;
  2662. } else {
  2663. result1 = null;
  2664. if (reportFailures === 0) {
  2665. matchFailed("\"_\"");
  2666. }
  2667. }
  2668. if (result1 === null) {
  2669. if (input.charCodeAt(pos) === 43) {
  2670. result1 = "+";
  2671. pos++;
  2672. } else {
  2673. result1 = null;
  2674. if (reportFailures === 0) {
  2675. matchFailed("\"+\"");
  2676. }
  2677. }
  2678. if (result1 === null) {
  2679. if (input.charCodeAt(pos) === 96) {
  2680. result1 = "`";
  2681. pos++;
  2682. } else {
  2683. result1 = null;
  2684. if (reportFailures === 0) {
  2685. matchFailed("\"`\"");
  2686. }
  2687. }
  2688. if (result1 === null) {
  2689. if (input.charCodeAt(pos) === 39) {
  2690. result1 = "'";
  2691. pos++;
  2692. } else {
  2693. result1 = null;
  2694. if (reportFailures === 0) {
  2695. matchFailed("\"'\"");
  2696. }
  2697. }
  2698. if (result1 === null) {
  2699. if (input.charCodeAt(pos) === 126) {
  2700. result1 = "~";
  2701. pos++;
  2702. } else {
  2703. result1 = null;
  2704. if (reportFailures === 0) {
  2705. matchFailed("\"~\"");
  2706. }
  2707. }
  2708. if (result1 === null) {
  2709. if (input.charCodeAt(pos) === 40) {
  2710. result1 = "(";
  2711. pos++;
  2712. } else {
  2713. result1 = null;
  2714. if (reportFailures === 0) {
  2715. matchFailed("\"(\"");
  2716. }
  2717. }
  2718. if (result1 === null) {
  2719. if (input.charCodeAt(pos) === 41) {
  2720. result1 = ")";
  2721. pos++;
  2722. } else {
  2723. result1 = null;
  2724. if (reportFailures === 0) {
  2725. matchFailed("\")\"");
  2726. }
  2727. }
  2728. if (result1 === null) {
  2729. if (input.charCodeAt(pos) === 60) {
  2730. result1 = "<";
  2731. pos++;
  2732. } else {
  2733. result1 = null;
  2734. if (reportFailures === 0) {
  2735. matchFailed("\"<\"");
  2736. }
  2737. }
  2738. if (result1 === null) {
  2739. if (input.charCodeAt(pos) === 62) {
  2740. result1 = ">";
  2741. pos++;
  2742. } else {
  2743. result1 = null;
  2744. if (reportFailures === 0) {
  2745. matchFailed("\">\"");
  2746. }
  2747. }
  2748. if (result1 === null) {
  2749. if (input.charCodeAt(pos) === 58) {
  2750. result1 = ":";
  2751. pos++;
  2752. } else {
  2753. result1 = null;
  2754. if (reportFailures === 0) {
  2755. matchFailed("\":\"");
  2756. }
  2757. }
  2758. if (result1 === null) {
  2759. if (input.charCodeAt(pos) === 92) {
  2760. result1 = "\\";
  2761. pos++;
  2762. } else {
  2763. result1 = null;
  2764. if (reportFailures === 0) {
  2765. matchFailed("\"\\\\\"");
  2766. }
  2767. }
  2768. if (result1 === null) {
  2769. result1 = parse_DQUOTE();
  2770. if (result1 === null) {
  2771. if (input.charCodeAt(pos) === 47) {
  2772. result1 = "/";
  2773. pos++;
  2774. } else {
  2775. result1 = null;
  2776. if (reportFailures === 0) {
  2777. matchFailed("\"/\"");
  2778. }
  2779. }
  2780. if (result1 === null) {
  2781. if (input.charCodeAt(pos) === 91) {
  2782. result1 = "[";
  2783. pos++;
  2784. } else {
  2785. result1 = null;
  2786. if (reportFailures === 0) {
  2787. matchFailed("\"[\"");
  2788. }
  2789. }
  2790. if (result1 === null) {
  2791. if (input.charCodeAt(pos) === 93) {
  2792. result1 = "]";
  2793. pos++;
  2794. } else {
  2795. result1 = null;
  2796. if (reportFailures === 0) {
  2797. matchFailed("\"]\"");
  2798. }
  2799. }
  2800. if (result1 === null) {
  2801. if (input.charCodeAt(pos) === 63) {
  2802. result1 = "?";
  2803. pos++;
  2804. } else {
  2805. result1 = null;
  2806. if (reportFailures === 0) {
  2807. matchFailed("\"?\"");
  2808. }
  2809. }
  2810. if (result1 === null) {
  2811. if (input.charCodeAt(pos) === 123) {
  2812. result1 = "{";
  2813. pos++;
  2814. } else {
  2815. result1 = null;
  2816. if (reportFailures === 0) {
  2817. matchFailed("\"{\"");
  2818. }
  2819. }
  2820. if (result1 === null) {
  2821. if (input.charCodeAt(pos) === 125) {
  2822. result1 = "}";
  2823. pos++;
  2824. } else {
  2825. result1 = null;
  2826. if (reportFailures === 0) {
  2827. matchFailed("\"}\"");
  2828. }
  2829. }
  2830. }
  2831. }
  2832. }
  2833. }
  2834. }
  2835. }
  2836. }
  2837. }
  2838. }
  2839. }
  2840. }
  2841. }
  2842. }
  2843. }
  2844. }
  2845. }
  2846. }
  2847. }
  2848. }
  2849. }
  2850. }
  2851. }
  2852. }
  2853. if (result1 !== null) {
  2854. result0 = [];
  2855. while (result1 !== null) {
  2856. result0.push(result1);
  2857. result1 = parse_alphanum();
  2858. if (result1 === null) {
  2859. if (input.charCodeAt(pos) === 45) {
  2860. result1 = "-";
  2861. pos++;
  2862. } else {
  2863. result1 = null;
  2864. if (reportFailures === 0) {
  2865. matchFailed("\"-\"");
  2866. }
  2867. }
  2868. if (result1 === null) {
  2869. if (input.charCodeAt(pos) === 46) {
  2870. result1 = ".";
  2871. pos++;
  2872. } else {
  2873. result1 = null;
  2874. if (reportFailures === 0) {
  2875. matchFailed("\".\"");
  2876. }
  2877. }
  2878. if (result1 === null) {
  2879. if (input.charCodeAt(pos) === 33) {
  2880. result1 = "!";
  2881. pos++;
  2882. } else {
  2883. result1 = null;
  2884. if (reportFailures === 0) {
  2885. matchFailed("\"!\"");
  2886. }
  2887. }
  2888. if (result1 === null) {
  2889. if (input.charCodeAt(pos) === 37) {
  2890. result1 = "%";
  2891. pos++;
  2892. } else {
  2893. result1 = null;
  2894. if (reportFailures === 0) {
  2895. matchFailed("\"%\"");
  2896. }
  2897. }
  2898. if (result1 === null) {
  2899. if (input.charCodeAt(pos) === 42) {
  2900. result1 = "*";
  2901. pos++;
  2902. } else {
  2903. result1 = null;
  2904. if (reportFailures === 0) {
  2905. matchFailed("\"*\"");
  2906. }
  2907. }
  2908. if (result1 === null) {
  2909. if (input.charCodeAt(pos) === 95) {
  2910. result1 = "_";
  2911. pos++;
  2912. } else {
  2913. result1 = null;
  2914. if (reportFailures === 0) {
  2915. matchFailed("\"_\"");
  2916. }
  2917. }
  2918. if (result1 === null) {
  2919. if (input.charCodeAt(pos) === 43) {
  2920. result1 = "+";
  2921. pos++;
  2922. } else {
  2923. result1 = null;
  2924. if (reportFailures === 0) {
  2925. matchFailed("\"+\"");
  2926. }
  2927. }
  2928. if (result1 === null) {
  2929. if (input.charCodeAt(pos) === 96) {
  2930. result1 = "`";
  2931. pos++;
  2932. } else {
  2933. result1 = null;
  2934. if (reportFailures === 0) {
  2935. matchFailed("\"`\"");
  2936. }
  2937. }
  2938. if (result1 === null) {
  2939. if (input.charCodeAt(pos) === 39) {
  2940. result1 = "'";
  2941. pos++;
  2942. } else {
  2943. result1 = null;
  2944. if (reportFailures === 0) {
  2945. matchFailed("\"'\"");
  2946. }
  2947. }
  2948. if (result1 === null) {
  2949. if (input.charCodeAt(pos) === 126) {
  2950. result1 = "~";
  2951. pos++;
  2952. } else {
  2953. result1 = null;
  2954. if (reportFailures === 0) {
  2955. matchFailed("\"~\"");
  2956. }
  2957. }
  2958. if (result1 === null) {
  2959. if (input.charCodeAt(pos) === 40) {
  2960. result1 = "(";
  2961. pos++;
  2962. } else {
  2963. result1 = null;
  2964. if (reportFailures === 0) {
  2965. matchFailed("\"(\"");
  2966. }
  2967. }
  2968. if (result1 === null) {
  2969. if (input.charCodeAt(pos) === 41) {
  2970. result1 = ")";
  2971. pos++;
  2972. } else {
  2973. result1 = null;
  2974. if (reportFailures === 0) {
  2975. matchFailed("\")\"");
  2976. }
  2977. }
  2978. if (result1 === null) {
  2979. if (input.charCodeAt(pos) === 60) {
  2980. result1 = "<";
  2981. pos++;
  2982. } else {
  2983. result1 = null;
  2984. if (reportFailures === 0) {
  2985. matchFailed("\"<\"");
  2986. }
  2987. }
  2988. if (result1 === null) {
  2989. if (input.charCodeAt(pos) === 62) {
  2990. result1 = ">";
  2991. pos++;
  2992. } else {
  2993. result1 = null;
  2994. if (reportFailures === 0) {
  2995. matchFailed("\">\"");
  2996. }
  2997. }
  2998. if (result1 === null) {
  2999. if (input.charCodeAt(pos) === 58) {
  3000. result1 = ":";
  3001. pos++;
  3002. } else {
  3003. result1 = null;
  3004. if (reportFailures === 0) {
  3005. matchFailed("\":\"");
  3006. }
  3007. }
  3008. if (result1 === null) {
  3009. if (input.charCodeAt(pos) === 92) {
  3010. result1 = "\\";
  3011. pos++;
  3012. } else {
  3013. result1 = null;
  3014. if (reportFailures === 0) {
  3015. matchFailed("\"\\\\\"");
  3016. }
  3017. }
  3018. if (result1 === null) {
  3019. result1 = parse_DQUOTE();
  3020. if (result1 === null) {
  3021. if (input.charCodeAt(pos) === 47) {
  3022. result1 = "/";
  3023. pos++;
  3024. } else {
  3025. result1 = null;
  3026. if (reportFailures === 0) {
  3027. matchFailed("\"/\"");
  3028. }
  3029. }
  3030. if (result1 === null) {
  3031. if (input.charCodeAt(pos) === 91) {
  3032. result1 = "[";
  3033. pos++;
  3034. } else {
  3035. result1 = null;
  3036. if (reportFailures === 0) {
  3037. matchFailed("\"[\"");
  3038. }
  3039. }
  3040. if (result1 === null) {
  3041. if (input.charCodeAt(pos) === 93) {
  3042. result1 = "]";
  3043. pos++;
  3044. } else {
  3045. result1 = null;
  3046. if (reportFailures === 0) {
  3047. matchFailed("\"]\"");
  3048. }
  3049. }
  3050. if (result1 === null) {
  3051. if (input.charCodeAt(pos) === 63) {
  3052. result1 = "?";
  3053. pos++;
  3054. } else {
  3055. result1 = null;
  3056. if (reportFailures === 0) {
  3057. matchFailed("\"?\"");
  3058. }
  3059. }
  3060. if (result1 === null) {
  3061. if (input.charCodeAt(pos) === 123) {
  3062. result1 = "{";
  3063. pos++;
  3064. } else {
  3065. result1 = null;
  3066. if (reportFailures === 0) {
  3067. matchFailed("\"{\"");
  3068. }
  3069. }
  3070. if (result1 === null) {
  3071. if (input.charCodeAt(pos) === 125) {
  3072. result1 = "}";
  3073. pos++;
  3074. } else {
  3075. result1 = null;
  3076. if (reportFailures === 0) {
  3077. matchFailed("\"}\"");
  3078. }
  3079. }
  3080. }
  3081. }
  3082. }
  3083. }
  3084. }
  3085. }
  3086. }
  3087. }
  3088. }
  3089. }
  3090. }
  3091. }
  3092. }
  3093. }
  3094. }
  3095. }
  3096. }
  3097. }
  3098. }
  3099. }
  3100. }
  3101. }
  3102. }
  3103. }
  3104. } else {
  3105. result0 = null;
  3106. }
  3107. if (result0 !== null) {
  3108. result0 = function (offset) {
  3109. return input.substring(pos, offset);
  3110. }(pos0);
  3111. }
  3112. if (result0 === null) {
  3113. pos = pos0;
  3114. }
  3115. return result0;
  3116. }
  3117. function parse_STAR() {
  3118. var result0, result1, result2;
  3119. var pos0, pos1;
  3120. pos0 = pos;
  3121. pos1 = pos;
  3122. result0 = parse_SWS();
  3123. if (result0 !== null) {
  3124. if (input.charCodeAt(pos) === 42) {
  3125. result1 = "*";
  3126. pos++;
  3127. } else {
  3128. result1 = null;
  3129. if (reportFailures === 0) {
  3130. matchFailed("\"*\"");
  3131. }
  3132. }
  3133. if (result1 !== null) {
  3134. result2 = parse_SWS();
  3135. if (result2 !== null) {
  3136. result0 = [result0, result1, result2];
  3137. } else {
  3138. result0 = null;
  3139. pos = pos1;
  3140. }
  3141. } else {
  3142. result0 = null;
  3143. pos = pos1;
  3144. }
  3145. } else {
  3146. result0 = null;
  3147. pos = pos1;
  3148. }
  3149. if (result0 !== null) {
  3150. result0 = function (offset) {
  3151. return "*";
  3152. }(pos0);
  3153. }
  3154. if (result0 === null) {
  3155. pos = pos0;
  3156. }
  3157. return result0;
  3158. }
  3159. function parse_SLASH() {
  3160. var result0, result1, result2;
  3161. var pos0, pos1;
  3162. pos0 = pos;
  3163. pos1 = pos;
  3164. result0 = parse_SWS();
  3165. if (result0 !== null) {
  3166. if (input.charCodeAt(pos) === 47) {
  3167. result1 = "/";
  3168. pos++;
  3169. } else {
  3170. result1 = null;
  3171. if (reportFailures === 0) {
  3172. matchFailed("\"/\"");
  3173. }
  3174. }
  3175. if (result1 !== null) {
  3176. result2 = parse_SWS();
  3177. if (result2 !== null) {
  3178. result0 = [result0, result1, result2];
  3179. } else {
  3180. result0 = null;
  3181. pos = pos1;
  3182. }
  3183. } else {
  3184. result0 = null;
  3185. pos = pos1;
  3186. }
  3187. } else {
  3188. result0 = null;
  3189. pos = pos1;
  3190. }
  3191. if (result0 !== null) {
  3192. result0 = function (offset) {
  3193. return "/";
  3194. }(pos0);
  3195. }
  3196. if (result0 === null) {
  3197. pos = pos0;
  3198. }
  3199. return result0;
  3200. }
  3201. function parse_EQUAL() {
  3202. var result0, result1, result2;
  3203. var pos0, pos1;
  3204. pos0 = pos;
  3205. pos1 = pos;
  3206. result0 = parse_SWS();
  3207. if (result0 !== null) {
  3208. if (input.charCodeAt(pos) === 61) {
  3209. result1 = "=";
  3210. pos++;
  3211. } else {
  3212. result1 = null;
  3213. if (reportFailures === 0) {
  3214. matchFailed("\"=\"");
  3215. }
  3216. }
  3217. if (result1 !== null) {
  3218. result2 = parse_SWS();
  3219. if (result2 !== null) {
  3220. result0 = [result0, result1, result2];
  3221. } else {
  3222. result0 = null;
  3223. pos = pos1;
  3224. }
  3225. } else {
  3226. result0 = null;
  3227. pos = pos1;
  3228. }
  3229. } else {
  3230. result0 = null;
  3231. pos = pos1;
  3232. }
  3233. if (result0 !== null) {
  3234. result0 = function (offset) {
  3235. return "=";
  3236. }(pos0);
  3237. }
  3238. if (result0 === null) {
  3239. pos = pos0;
  3240. }
  3241. return result0;
  3242. }
  3243. function parse_LPAREN() {
  3244. var result0, result1, result2;
  3245. var pos0, pos1;
  3246. pos0 = pos;
  3247. pos1 = pos;
  3248. result0 = parse_SWS();
  3249. if (result0 !== null) {
  3250. if (input.charCodeAt(pos) === 40) {
  3251. result1 = "(";
  3252. pos++;
  3253. } else {
  3254. result1 = null;
  3255. if (reportFailures === 0) {
  3256. matchFailed("\"(\"");
  3257. }
  3258. }
  3259. if (result1 !== null) {
  3260. result2 = parse_SWS();
  3261. if (result2 !== null) {
  3262. result0 = [result0, result1, result2];
  3263. } else {
  3264. result0 = null;
  3265. pos = pos1;
  3266. }
  3267. } else {
  3268. result0 = null;
  3269. pos = pos1;
  3270. }
  3271. } else {
  3272. result0 = null;
  3273. pos = pos1;
  3274. }
  3275. if (result0 !== null) {
  3276. result0 = function (offset) {
  3277. return "(";
  3278. }(pos0);
  3279. }
  3280. if (result0 === null) {
  3281. pos = pos0;
  3282. }
  3283. return result0;
  3284. }
  3285. function parse_RPAREN() {
  3286. var result0, result1, result2;
  3287. var pos0, pos1;
  3288. pos0 = pos;
  3289. pos1 = pos;
  3290. result0 = parse_SWS();
  3291. if (result0 !== null) {
  3292. if (input.charCodeAt(pos) === 41) {
  3293. result1 = ")";
  3294. pos++;
  3295. } else {
  3296. result1 = null;
  3297. if (reportFailures === 0) {
  3298. matchFailed("\")\"");
  3299. }
  3300. }
  3301. if (result1 !== null) {
  3302. result2 = parse_SWS();
  3303. if (result2 !== null) {
  3304. result0 = [result0, result1, result2];
  3305. } else {
  3306. result0 = null;
  3307. pos = pos1;
  3308. }
  3309. } else {
  3310. result0 = null;
  3311. pos = pos1;
  3312. }
  3313. } else {
  3314. result0 = null;
  3315. pos = pos1;
  3316. }
  3317. if (result0 !== null) {
  3318. result0 = function (offset) {
  3319. return ")";
  3320. }(pos0);
  3321. }
  3322. if (result0 === null) {
  3323. pos = pos0;
  3324. }
  3325. return result0;
  3326. }
  3327. function parse_RAQUOT() {
  3328. var result0, result1;
  3329. var pos0, pos1;
  3330. pos0 = pos;
  3331. pos1 = pos;
  3332. if (input.charCodeAt(pos) === 62) {
  3333. result0 = ">";
  3334. pos++;
  3335. } else {
  3336. result0 = null;
  3337. if (reportFailures === 0) {
  3338. matchFailed("\">\"");
  3339. }
  3340. }
  3341. if (result0 !== null) {
  3342. result1 = parse_SWS();
  3343. if (result1 !== null) {
  3344. result0 = [result0, result1];
  3345. } else {
  3346. result0 = null;
  3347. pos = pos1;
  3348. }
  3349. } else {
  3350. result0 = null;
  3351. pos = pos1;
  3352. }
  3353. if (result0 !== null) {
  3354. result0 = function (offset) {
  3355. return ">";
  3356. }(pos0);
  3357. }
  3358. if (result0 === null) {
  3359. pos = pos0;
  3360. }
  3361. return result0;
  3362. }
  3363. function parse_LAQUOT() {
  3364. var result0, result1;
  3365. var pos0, pos1;
  3366. pos0 = pos;
  3367. pos1 = pos;
  3368. result0 = parse_SWS();
  3369. if (result0 !== null) {
  3370. if (input.charCodeAt(pos) === 60) {
  3371. result1 = "<";
  3372. pos++;
  3373. } else {
  3374. result1 = null;
  3375. if (reportFailures === 0) {
  3376. matchFailed("\"<\"");
  3377. }
  3378. }
  3379. if (result1 !== null) {
  3380. result0 = [result0, result1];
  3381. } else {
  3382. result0 = null;
  3383. pos = pos1;
  3384. }
  3385. } else {
  3386. result0 = null;
  3387. pos = pos1;
  3388. }
  3389. if (result0 !== null) {
  3390. result0 = function (offset) {
  3391. return "<";
  3392. }(pos0);
  3393. }
  3394. if (result0 === null) {
  3395. pos = pos0;
  3396. }
  3397. return result0;
  3398. }
  3399. function parse_COMMA() {
  3400. var result0, result1, result2;
  3401. var pos0, pos1;
  3402. pos0 = pos;
  3403. pos1 = pos;
  3404. result0 = parse_SWS();
  3405. if (result0 !== null) {
  3406. if (input.charCodeAt(pos) === 44) {
  3407. result1 = ",";
  3408. pos++;
  3409. } else {
  3410. result1 = null;
  3411. if (reportFailures === 0) {
  3412. matchFailed("\",\"");
  3413. }
  3414. }
  3415. if (result1 !== null) {
  3416. result2 = parse_SWS();
  3417. if (result2 !== null) {
  3418. result0 = [result0, result1, result2];
  3419. } else {
  3420. result0 = null;
  3421. pos = pos1;
  3422. }
  3423. } else {
  3424. result0 = null;
  3425. pos = pos1;
  3426. }
  3427. } else {
  3428. result0 = null;
  3429. pos = pos1;
  3430. }
  3431. if (result0 !== null) {
  3432. result0 = function (offset) {
  3433. return ",";
  3434. }(pos0);
  3435. }
  3436. if (result0 === null) {
  3437. pos = pos0;
  3438. }
  3439. return result0;
  3440. }
  3441. function parse_SEMI() {
  3442. var result0, result1, result2;
  3443. var pos0, pos1;
  3444. pos0 = pos;
  3445. pos1 = pos;
  3446. result0 = parse_SWS();
  3447. if (result0 !== null) {
  3448. if (input.charCodeAt(pos) === 59) {
  3449. result1 = ";";
  3450. pos++;
  3451. } else {
  3452. result1 = null;
  3453. if (reportFailures === 0) {
  3454. matchFailed("\";\"");
  3455. }
  3456. }
  3457. if (result1 !== null) {
  3458. result2 = parse_SWS();
  3459. if (result2 !== null) {
  3460. result0 = [result0, result1, result2];
  3461. } else {
  3462. result0 = null;
  3463. pos = pos1;
  3464. }
  3465. } else {
  3466. result0 = null;
  3467. pos = pos1;
  3468. }
  3469. } else {
  3470. result0 = null;
  3471. pos = pos1;
  3472. }
  3473. if (result0 !== null) {
  3474. result0 = function (offset) {
  3475. return ";";
  3476. }(pos0);
  3477. }
  3478. if (result0 === null) {
  3479. pos = pos0;
  3480. }
  3481. return result0;
  3482. }
  3483. function parse_COLON() {
  3484. var result0, result1, result2;
  3485. var pos0, pos1;
  3486. pos0 = pos;
  3487. pos1 = pos;
  3488. result0 = parse_SWS();
  3489. if (result0 !== null) {
  3490. if (input.charCodeAt(pos) === 58) {
  3491. result1 = ":";
  3492. pos++;
  3493. } else {
  3494. result1 = null;
  3495. if (reportFailures === 0) {
  3496. matchFailed("\":\"");
  3497. }
  3498. }
  3499. if (result1 !== null) {
  3500. result2 = parse_SWS();
  3501. if (result2 !== null) {
  3502. result0 = [result0, result1, result2];
  3503. } else {
  3504. result0 = null;
  3505. pos = pos1;
  3506. }
  3507. } else {
  3508. result0 = null;
  3509. pos = pos1;
  3510. }
  3511. } else {
  3512. result0 = null;
  3513. pos = pos1;
  3514. }
  3515. if (result0 !== null) {
  3516. result0 = function (offset) {
  3517. return ":";
  3518. }(pos0);
  3519. }
  3520. if (result0 === null) {
  3521. pos = pos0;
  3522. }
  3523. return result0;
  3524. }
  3525. function parse_LDQUOT() {
  3526. var result0, result1;
  3527. var pos0, pos1;
  3528. pos0 = pos;
  3529. pos1 = pos;
  3530. result0 = parse_SWS();
  3531. if (result0 !== null) {
  3532. result1 = parse_DQUOTE();
  3533. if (result1 !== null) {
  3534. result0 = [result0, result1];
  3535. } else {
  3536. result0 = null;
  3537. pos = pos1;
  3538. }
  3539. } else {
  3540. result0 = null;
  3541. pos = pos1;
  3542. }
  3543. if (result0 !== null) {
  3544. result0 = function (offset) {
  3545. return "\"";
  3546. }(pos0);
  3547. }
  3548. if (result0 === null) {
  3549. pos = pos0;
  3550. }
  3551. return result0;
  3552. }
  3553. function parse_RDQUOT() {
  3554. var result0, result1;
  3555. var pos0, pos1;
  3556. pos0 = pos;
  3557. pos1 = pos;
  3558. result0 = parse_DQUOTE();
  3559. if (result0 !== null) {
  3560. result1 = parse_SWS();
  3561. if (result1 !== null) {
  3562. result0 = [result0, result1];
  3563. } else {
  3564. result0 = null;
  3565. pos = pos1;
  3566. }
  3567. } else {
  3568. result0 = null;
  3569. pos = pos1;
  3570. }
  3571. if (result0 !== null) {
  3572. result0 = function (offset) {
  3573. return "\"";
  3574. }(pos0);
  3575. }
  3576. if (result0 === null) {
  3577. pos = pos0;
  3578. }
  3579. return result0;
  3580. }
  3581. function parse_comment() {
  3582. var result0, result1, result2;
  3583. var pos0;
  3584. pos0 = pos;
  3585. result0 = parse_LPAREN();
  3586. if (result0 !== null) {
  3587. result1 = [];
  3588. result2 = parse_ctext();
  3589. if (result2 === null) {
  3590. result2 = parse_quoted_pair();
  3591. if (result2 === null) {
  3592. result2 = parse_comment();
  3593. }
  3594. }
  3595. while (result2 !== null) {
  3596. result1.push(result2);
  3597. result2 = parse_ctext();
  3598. if (result2 === null) {
  3599. result2 = parse_quoted_pair();
  3600. if (result2 === null) {
  3601. result2 = parse_comment();
  3602. }
  3603. }
  3604. }
  3605. if (result1 !== null) {
  3606. result2 = parse_RPAREN();
  3607. if (result2 !== null) {
  3608. result0 = [result0, result1, result2];
  3609. } else {
  3610. result0 = null;
  3611. pos = pos0;
  3612. }
  3613. } else {
  3614. result0 = null;
  3615. pos = pos0;
  3616. }
  3617. } else {
  3618. result0 = null;
  3619. pos = pos0;
  3620. }
  3621. return result0;
  3622. }
  3623. function parse_ctext() {
  3624. var result0;
  3625. if (/^[!-']/.test(input.charAt(pos))) {
  3626. result0 = input.charAt(pos);
  3627. pos++;
  3628. } else {
  3629. result0 = null;
  3630. if (reportFailures === 0) {
  3631. matchFailed("[!-']");
  3632. }
  3633. }
  3634. if (result0 === null) {
  3635. if (/^[*-[]/.test(input.charAt(pos))) {
  3636. result0 = input.charAt(pos);
  3637. pos++;
  3638. } else {
  3639. result0 = null;
  3640. if (reportFailures === 0) {
  3641. matchFailed("[*-[]");
  3642. }
  3643. }
  3644. if (result0 === null) {
  3645. if (/^[\]-~]/.test(input.charAt(pos))) {
  3646. result0 = input.charAt(pos);
  3647. pos++;
  3648. } else {
  3649. result0 = null;
  3650. if (reportFailures === 0) {
  3651. matchFailed("[\\]-~]");
  3652. }
  3653. }
  3654. if (result0 === null) {
  3655. result0 = parse_UTF8_NONASCII();
  3656. if (result0 === null) {
  3657. result0 = parse_LWS();
  3658. }
  3659. }
  3660. }
  3661. }
  3662. return result0;
  3663. }
  3664. function parse_quoted_string() {
  3665. var result0, result1, result2, result3;
  3666. var pos0, pos1;
  3667. pos0 = pos;
  3668. pos1 = pos;
  3669. result0 = parse_SWS();
  3670. if (result0 !== null) {
  3671. result1 = parse_DQUOTE();
  3672. if (result1 !== null) {
  3673. result2 = [];
  3674. result3 = parse_qdtext();
  3675. if (result3 === null) {
  3676. result3 = parse_quoted_pair();
  3677. }
  3678. while (result3 !== null) {
  3679. result2.push(result3);
  3680. result3 = parse_qdtext();
  3681. if (result3 === null) {
  3682. result3 = parse_quoted_pair();
  3683. }
  3684. }
  3685. if (result2 !== null) {
  3686. result3 = parse_DQUOTE();
  3687. if (result3 !== null) {
  3688. result0 = [result0, result1, result2, result3];
  3689. } else {
  3690. result0 = null;
  3691. pos = pos1;
  3692. }
  3693. } else {
  3694. result0 = null;
  3695. pos = pos1;
  3696. }
  3697. } else {
  3698. result0 = null;
  3699. pos = pos1;
  3700. }
  3701. } else {
  3702. result0 = null;
  3703. pos = pos1;
  3704. }
  3705. if (result0 !== null) {
  3706. result0 = function (offset) {
  3707. return input.substring(pos, offset);
  3708. }(pos0);
  3709. }
  3710. if (result0 === null) {
  3711. pos = pos0;
  3712. }
  3713. return result0;
  3714. }
  3715. function parse_quoted_string_clean() {
  3716. var result0, result1, result2, result3;
  3717. var pos0, pos1;
  3718. pos0 = pos;
  3719. pos1 = pos;
  3720. result0 = parse_SWS();
  3721. if (result0 !== null) {
  3722. result1 = parse_DQUOTE();
  3723. if (result1 !== null) {
  3724. result2 = [];
  3725. result3 = parse_qdtext();
  3726. if (result3 === null) {
  3727. result3 = parse_quoted_pair();
  3728. }
  3729. while (result3 !== null) {
  3730. result2.push(result3);
  3731. result3 = parse_qdtext();
  3732. if (result3 === null) {
  3733. result3 = parse_quoted_pair();
  3734. }
  3735. }
  3736. if (result2 !== null) {
  3737. result3 = parse_DQUOTE();
  3738. if (result3 !== null) {
  3739. result0 = [result0, result1, result2, result3];
  3740. } else {
  3741. result0 = null;
  3742. pos = pos1;
  3743. }
  3744. } else {
  3745. result0 = null;
  3746. pos = pos1;
  3747. }
  3748. } else {
  3749. result0 = null;
  3750. pos = pos1;
  3751. }
  3752. } else {
  3753. result0 = null;
  3754. pos = pos1;
  3755. }
  3756. if (result0 !== null) {
  3757. result0 = function (offset) {
  3758. var trimmed = input.substring(pos, offset).trim();
  3759. return trimmed.substring(1, trimmed.length - 1) // remove outer quotes
  3760. .replace(/\\([\x00-\x09\x0b-\x0c\x0e-\x7f])/g, '$1');
  3761. }(pos0);
  3762. }
  3763. if (result0 === null) {
  3764. pos = pos0;
  3765. }
  3766. return result0;
  3767. }
  3768. function parse_qdtext() {
  3769. var result0;
  3770. result0 = parse_LWS();
  3771. if (result0 === null) {
  3772. if (input.charCodeAt(pos) === 33) {
  3773. result0 = "!";
  3774. pos++;
  3775. } else {
  3776. result0 = null;
  3777. if (reportFailures === 0) {
  3778. matchFailed("\"!\"");
  3779. }
  3780. }
  3781. if (result0 === null) {
  3782. if (/^[#-[]/.test(input.charAt(pos))) {
  3783. result0 = input.charAt(pos);
  3784. pos++;
  3785. } else {
  3786. result0 = null;
  3787. if (reportFailures === 0) {
  3788. matchFailed("[#-[]");
  3789. }
  3790. }
  3791. if (result0 === null) {
  3792. if (/^[\]-~]/.test(input.charAt(pos))) {
  3793. result0 = input.charAt(pos);
  3794. pos++;
  3795. } else {
  3796. result0 = null;
  3797. if (reportFailures === 0) {
  3798. matchFailed("[\\]-~]");
  3799. }
  3800. }
  3801. if (result0 === null) {
  3802. result0 = parse_UTF8_NONASCII();
  3803. }
  3804. }
  3805. }
  3806. }
  3807. return result0;
  3808. }
  3809. function parse_quoted_pair() {
  3810. var result0, result1;
  3811. var pos0;
  3812. pos0 = pos;
  3813. if (input.charCodeAt(pos) === 92) {
  3814. result0 = "\\";
  3815. pos++;
  3816. } else {
  3817. result0 = null;
  3818. if (reportFailures === 0) {
  3819. matchFailed("\"\\\\\"");
  3820. }
  3821. }
  3822. if (result0 !== null) {
  3823. if (/^[\0-\t]/.test(input.charAt(pos))) {
  3824. result1 = input.charAt(pos);
  3825. pos++;
  3826. } else {
  3827. result1 = null;
  3828. if (reportFailures === 0) {
  3829. matchFailed("[\\0-\\t]");
  3830. }
  3831. }
  3832. if (result1 === null) {
  3833. if (/^[\x0B-\f]/.test(input.charAt(pos))) {
  3834. result1 = input.charAt(pos);
  3835. pos++;
  3836. } else {
  3837. result1 = null;
  3838. if (reportFailures === 0) {
  3839. matchFailed("[\\x0B-\\f]");
  3840. }
  3841. }
  3842. if (result1 === null) {
  3843. if (/^[\x0E-]/.test(input.charAt(pos))) {
  3844. result1 = input.charAt(pos);
  3845. pos++;
  3846. } else {
  3847. result1 = null;
  3848. if (reportFailures === 0) {
  3849. matchFailed("[\\x0E-]");
  3850. }
  3851. }
  3852. }
  3853. }
  3854. if (result1 !== null) {
  3855. result0 = [result0, result1];
  3856. } else {
  3857. result0 = null;
  3858. pos = pos0;
  3859. }
  3860. } else {
  3861. result0 = null;
  3862. pos = pos0;
  3863. }
  3864. return result0;
  3865. }
  3866. function parse_SIP_URI_noparams() {
  3867. var result0, result1, result2, result3;
  3868. var pos0, pos1;
  3869. pos0 = pos;
  3870. pos1 = pos;
  3871. result0 = parse_uri_scheme();
  3872. if (result0 !== null) {
  3873. if (input.charCodeAt(pos) === 58) {
  3874. result1 = ":";
  3875. pos++;
  3876. } else {
  3877. result1 = null;
  3878. if (reportFailures === 0) {
  3879. matchFailed("\":\"");
  3880. }
  3881. }
  3882. if (result1 !== null) {
  3883. result2 = parse_userinfo();
  3884. result2 = result2 !== null ? result2 : "";
  3885. if (result2 !== null) {
  3886. result3 = parse_hostport();
  3887. if (result3 !== null) {
  3888. result0 = [result0, result1, result2, result3];
  3889. } else {
  3890. result0 = null;
  3891. pos = pos1;
  3892. }
  3893. } else {
  3894. result0 = null;
  3895. pos = pos1;
  3896. }
  3897. } else {
  3898. result0 = null;
  3899. pos = pos1;
  3900. }
  3901. } else {
  3902. result0 = null;
  3903. pos = pos1;
  3904. }
  3905. if (result0 !== null) {
  3906. result0 = function (offset) {
  3907. try {
  3908. data.uri = new URI(data.scheme, data.user, data.host, data.port);
  3909. delete data.scheme;
  3910. delete data.user;
  3911. delete data.host;
  3912. delete data.host_type;
  3913. delete data.port;
  3914. } catch (e) {
  3915. data = -1;
  3916. }
  3917. }(pos0);
  3918. }
  3919. if (result0 === null) {
  3920. pos = pos0;
  3921. }
  3922. return result0;
  3923. }
  3924. function parse_SIP_URI() {
  3925. var result0, result1, result2, result3, result4, result5;
  3926. var pos0, pos1;
  3927. pos0 = pos;
  3928. pos1 = pos;
  3929. result0 = parse_uri_scheme();
  3930. if (result0 !== null) {
  3931. if (input.charCodeAt(pos) === 58) {
  3932. result1 = ":";
  3933. pos++;
  3934. } else {
  3935. result1 = null;
  3936. if (reportFailures === 0) {
  3937. matchFailed("\":\"");
  3938. }
  3939. }
  3940. if (result1 !== null) {
  3941. result2 = parse_userinfo();
  3942. result2 = result2 !== null ? result2 : "";
  3943. if (result2 !== null) {
  3944. result3 = parse_hostport();
  3945. if (result3 !== null) {
  3946. result4 = parse_uri_parameters();
  3947. if (result4 !== null) {
  3948. result5 = parse_headers();
  3949. result5 = result5 !== null ? result5 : "";
  3950. if (result5 !== null) {
  3951. result0 = [result0, result1, result2, result3, result4, result5];
  3952. } else {
  3953. result0 = null;
  3954. pos = pos1;
  3955. }
  3956. } else {
  3957. result0 = null;
  3958. pos = pos1;
  3959. }
  3960. } else {
  3961. result0 = null;
  3962. pos = pos1;
  3963. }
  3964. } else {
  3965. result0 = null;
  3966. pos = pos1;
  3967. }
  3968. } else {
  3969. result0 = null;
  3970. pos = pos1;
  3971. }
  3972. } else {
  3973. result0 = null;
  3974. pos = pos1;
  3975. }
  3976. if (result0 !== null) {
  3977. result0 = function (offset) {
  3978. var header;
  3979. try {
  3980. data.uri = new URI(data.scheme, data.user, data.host, data.port, data.uri_params, data.uri_headers);
  3981. delete data.scheme;
  3982. delete data.user;
  3983. delete data.host;
  3984. delete data.host_type;
  3985. delete data.port;
  3986. delete data.uri_params;
  3987. if (startRule === 'SIP_URI') {
  3988. data = data.uri;
  3989. }
  3990. } catch (e) {
  3991. data = -1;
  3992. }
  3993. }(pos0);
  3994. }
  3995. if (result0 === null) {
  3996. pos = pos0;
  3997. }
  3998. return result0;
  3999. }
  4000. function parse_uri_scheme() {
  4001. var result0;
  4002. result0 = parse_uri_scheme_sips();
  4003. if (result0 === null) {
  4004. result0 = parse_uri_scheme_sip();
  4005. }
  4006. return result0;
  4007. }
  4008. function parse_uri_scheme_sips() {
  4009. var result0;
  4010. var pos0;
  4011. pos0 = pos;
  4012. if (input.substr(pos, 4).toLowerCase() === "sips") {
  4013. result0 = input.substr(pos, 4);
  4014. pos += 4;
  4015. } else {
  4016. result0 = null;
  4017. if (reportFailures === 0) {
  4018. matchFailed("\"sips\"");
  4019. }
  4020. }
  4021. if (result0 !== null) {
  4022. result0 = function (offset, scheme) {
  4023. data.scheme = scheme.toLowerCase();
  4024. }(pos0, result0);
  4025. }
  4026. if (result0 === null) {
  4027. pos = pos0;
  4028. }
  4029. return result0;
  4030. }
  4031. function parse_uri_scheme_sip() {
  4032. var result0;
  4033. var pos0;
  4034. pos0 = pos;
  4035. if (input.substr(pos, 3).toLowerCase() === "sip") {
  4036. result0 = input.substr(pos, 3);
  4037. pos += 3;
  4038. } else {
  4039. result0 = null;
  4040. if (reportFailures === 0) {
  4041. matchFailed("\"sip\"");
  4042. }
  4043. }
  4044. if (result0 !== null) {
  4045. result0 = function (offset, scheme) {
  4046. data.scheme = scheme.toLowerCase();
  4047. }(pos0, result0);
  4048. }
  4049. if (result0 === null) {
  4050. pos = pos0;
  4051. }
  4052. return result0;
  4053. }
  4054. function parse_userinfo() {
  4055. var result0, result1, result2;
  4056. var pos0, pos1, pos2;
  4057. pos0 = pos;
  4058. pos1 = pos;
  4059. result0 = parse_user();
  4060. if (result0 !== null) {
  4061. pos2 = pos;
  4062. if (input.charCodeAt(pos) === 58) {
  4063. result1 = ":";
  4064. pos++;
  4065. } else {
  4066. result1 = null;
  4067. if (reportFailures === 0) {
  4068. matchFailed("\":\"");
  4069. }
  4070. }
  4071. if (result1 !== null) {
  4072. result2 = parse_password();
  4073. if (result2 !== null) {
  4074. result1 = [result1, result2];
  4075. } else {
  4076. result1 = null;
  4077. pos = pos2;
  4078. }
  4079. } else {
  4080. result1 = null;
  4081. pos = pos2;
  4082. }
  4083. result1 = result1 !== null ? result1 : "";
  4084. if (result1 !== null) {
  4085. if (input.charCodeAt(pos) === 64) {
  4086. result2 = "@";
  4087. pos++;
  4088. } else {
  4089. result2 = null;
  4090. if (reportFailures === 0) {
  4091. matchFailed("\"@\"");
  4092. }
  4093. }
  4094. if (result2 !== null) {
  4095. result0 = [result0, result1, result2];
  4096. } else {
  4097. result0 = null;
  4098. pos = pos1;
  4099. }
  4100. } else {
  4101. result0 = null;
  4102. pos = pos1;
  4103. }
  4104. } else {
  4105. result0 = null;
  4106. pos = pos1;
  4107. }
  4108. if (result0 !== null) {
  4109. result0 = function (offset) {
  4110. data.user = decodeURIComponent(input.substring(pos - 1, offset));
  4111. }(pos0);
  4112. }
  4113. if (result0 === null) {
  4114. pos = pos0;
  4115. }
  4116. return result0;
  4117. }
  4118. function parse_user() {
  4119. var result0, result1;
  4120. result1 = parse_unreserved();
  4121. if (result1 === null) {
  4122. result1 = parse_escaped();
  4123. if (result1 === null) {
  4124. result1 = parse_user_unreserved();
  4125. }
  4126. }
  4127. if (result1 !== null) {
  4128. result0 = [];
  4129. while (result1 !== null) {
  4130. result0.push(result1);
  4131. result1 = parse_unreserved();
  4132. if (result1 === null) {
  4133. result1 = parse_escaped();
  4134. if (result1 === null) {
  4135. result1 = parse_user_unreserved();
  4136. }
  4137. }
  4138. }
  4139. } else {
  4140. result0 = null;
  4141. }
  4142. return result0;
  4143. }
  4144. function parse_user_unreserved() {
  4145. var result0;
  4146. if (input.charCodeAt(pos) === 38) {
  4147. result0 = "&";
  4148. pos++;
  4149. } else {
  4150. result0 = null;
  4151. if (reportFailures === 0) {
  4152. matchFailed("\"&\"");
  4153. }
  4154. }
  4155. if (result0 === null) {
  4156. if (input.charCodeAt(pos) === 61) {
  4157. result0 = "=";
  4158. pos++;
  4159. } else {
  4160. result0 = null;
  4161. if (reportFailures === 0) {
  4162. matchFailed("\"=\"");
  4163. }
  4164. }
  4165. if (result0 === null) {
  4166. if (input.charCodeAt(pos) === 43) {
  4167. result0 = "+";
  4168. pos++;
  4169. } else {
  4170. result0 = null;
  4171. if (reportFailures === 0) {
  4172. matchFailed("\"+\"");
  4173. }
  4174. }
  4175. if (result0 === null) {
  4176. if (input.charCodeAt(pos) === 36) {
  4177. result0 = "$";
  4178. pos++;
  4179. } else {
  4180. result0 = null;
  4181. if (reportFailures === 0) {
  4182. matchFailed("\"$\"");
  4183. }
  4184. }
  4185. if (result0 === null) {
  4186. if (input.charCodeAt(pos) === 44) {
  4187. result0 = ",";
  4188. pos++;
  4189. } else {
  4190. result0 = null;
  4191. if (reportFailures === 0) {
  4192. matchFailed("\",\"");
  4193. }
  4194. }
  4195. if (result0 === null) {
  4196. if (input.charCodeAt(pos) === 59) {
  4197. result0 = ";";
  4198. pos++;
  4199. } else {
  4200. result0 = null;
  4201. if (reportFailures === 0) {
  4202. matchFailed("\";\"");
  4203. }
  4204. }
  4205. if (result0 === null) {
  4206. if (input.charCodeAt(pos) === 63) {
  4207. result0 = "?";
  4208. pos++;
  4209. } else {
  4210. result0 = null;
  4211. if (reportFailures === 0) {
  4212. matchFailed("\"?\"");
  4213. }
  4214. }
  4215. if (result0 === null) {
  4216. if (input.charCodeAt(pos) === 47) {
  4217. result0 = "/";
  4218. pos++;
  4219. } else {
  4220. result0 = null;
  4221. if (reportFailures === 0) {
  4222. matchFailed("\"/\"");
  4223. }
  4224. }
  4225. }
  4226. }
  4227. }
  4228. }
  4229. }
  4230. }
  4231. }
  4232. return result0;
  4233. }
  4234. function parse_password() {
  4235. var result0, result1;
  4236. var pos0;
  4237. pos0 = pos;
  4238. result0 = [];
  4239. result1 = parse_unreserved();
  4240. if (result1 === null) {
  4241. result1 = parse_escaped();
  4242. if (result1 === null) {
  4243. if (input.charCodeAt(pos) === 38) {
  4244. result1 = "&";
  4245. pos++;
  4246. } else {
  4247. result1 = null;
  4248. if (reportFailures === 0) {
  4249. matchFailed("\"&\"");
  4250. }
  4251. }
  4252. if (result1 === null) {
  4253. if (input.charCodeAt(pos) === 61) {
  4254. result1 = "=";
  4255. pos++;
  4256. } else {
  4257. result1 = null;
  4258. if (reportFailures === 0) {
  4259. matchFailed("\"=\"");
  4260. }
  4261. }
  4262. if (result1 === null) {
  4263. if (input.charCodeAt(pos) === 43) {
  4264. result1 = "+";
  4265. pos++;
  4266. } else {
  4267. result1 = null;
  4268. if (reportFailures === 0) {
  4269. matchFailed("\"+\"");
  4270. }
  4271. }
  4272. if (result1 === null) {
  4273. if (input.charCodeAt(pos) === 36) {
  4274. result1 = "$";
  4275. pos++;
  4276. } else {
  4277. result1 = null;
  4278. if (reportFailures === 0) {
  4279. matchFailed("\"$\"");
  4280. }
  4281. }
  4282. if (result1 === null) {
  4283. if (input.charCodeAt(pos) === 44) {
  4284. result1 = ",";
  4285. pos++;
  4286. } else {
  4287. result1 = null;
  4288. if (reportFailures === 0) {
  4289. matchFailed("\",\"");
  4290. }
  4291. }
  4292. }
  4293. }
  4294. }
  4295. }
  4296. }
  4297. }
  4298. while (result1 !== null) {
  4299. result0.push(result1);
  4300. result1 = parse_unreserved();
  4301. if (result1 === null) {
  4302. result1 = parse_escaped();
  4303. if (result1 === null) {
  4304. if (input.charCodeAt(pos) === 38) {
  4305. result1 = "&";
  4306. pos++;
  4307. } else {
  4308. result1 = null;
  4309. if (reportFailures === 0) {
  4310. matchFailed("\"&\"");
  4311. }
  4312. }
  4313. if (result1 === null) {
  4314. if (input.charCodeAt(pos) === 61) {
  4315. result1 = "=";
  4316. pos++;
  4317. } else {
  4318. result1 = null;
  4319. if (reportFailures === 0) {
  4320. matchFailed("\"=\"");
  4321. }
  4322. }
  4323. if (result1 === null) {
  4324. if (input.charCodeAt(pos) === 43) {
  4325. result1 = "+";
  4326. pos++;
  4327. } else {
  4328. result1 = null;
  4329. if (reportFailures === 0) {
  4330. matchFailed("\"+\"");
  4331. }
  4332. }
  4333. if (result1 === null) {
  4334. if (input.charCodeAt(pos) === 36) {
  4335. result1 = "$";
  4336. pos++;
  4337. } else {
  4338. result1 = null;
  4339. if (reportFailures === 0) {
  4340. matchFailed("\"$\"");
  4341. }
  4342. }
  4343. if (result1 === null) {
  4344. if (input.charCodeAt(pos) === 44) {
  4345. result1 = ",";
  4346. pos++;
  4347. } else {
  4348. result1 = null;
  4349. if (reportFailures === 0) {
  4350. matchFailed("\",\"");
  4351. }
  4352. }
  4353. }
  4354. }
  4355. }
  4356. }
  4357. }
  4358. }
  4359. }
  4360. if (result0 !== null) {
  4361. result0 = function (offset) {
  4362. data.password = input.substring(pos, offset);
  4363. }(pos0);
  4364. }
  4365. if (result0 === null) {
  4366. pos = pos0;
  4367. }
  4368. return result0;
  4369. }
  4370. function parse_hostport() {
  4371. var result0, result1, result2;
  4372. var pos0, pos1;
  4373. pos0 = pos;
  4374. result0 = parse_host();
  4375. if (result0 !== null) {
  4376. pos1 = pos;
  4377. if (input.charCodeAt(pos) === 58) {
  4378. result1 = ":";
  4379. pos++;
  4380. } else {
  4381. result1 = null;
  4382. if (reportFailures === 0) {
  4383. matchFailed("\":\"");
  4384. }
  4385. }
  4386. if (result1 !== null) {
  4387. result2 = parse_port();
  4388. if (result2 !== null) {
  4389. result1 = [result1, result2];
  4390. } else {
  4391. result1 = null;
  4392. pos = pos1;
  4393. }
  4394. } else {
  4395. result1 = null;
  4396. pos = pos1;
  4397. }
  4398. result1 = result1 !== null ? result1 : "";
  4399. if (result1 !== null) {
  4400. result0 = [result0, result1];
  4401. } else {
  4402. result0 = null;
  4403. pos = pos0;
  4404. }
  4405. } else {
  4406. result0 = null;
  4407. pos = pos0;
  4408. }
  4409. return result0;
  4410. }
  4411. function parse_host() {
  4412. var result0;
  4413. var pos0;
  4414. pos0 = pos;
  4415. result0 = parse_hostname();
  4416. if (result0 === null) {
  4417. result0 = parse_IPv4address();
  4418. if (result0 === null) {
  4419. result0 = parse_IPv6reference();
  4420. }
  4421. }
  4422. if (result0 !== null) {
  4423. result0 = function (offset) {
  4424. data.host = input.substring(pos, offset).toLowerCase();
  4425. return data.host;
  4426. }(pos0);
  4427. }
  4428. if (result0 === null) {
  4429. pos = pos0;
  4430. }
  4431. return result0;
  4432. }
  4433. function parse_hostname() {
  4434. var result0, result1, result2;
  4435. var pos0, pos1, pos2;
  4436. pos0 = pos;
  4437. pos1 = pos;
  4438. result0 = [];
  4439. pos2 = pos;
  4440. result1 = parse_domainlabel();
  4441. if (result1 !== null) {
  4442. if (input.charCodeAt(pos) === 46) {
  4443. result2 = ".";
  4444. pos++;
  4445. } else {
  4446. result2 = null;
  4447. if (reportFailures === 0) {
  4448. matchFailed("\".\"");
  4449. }
  4450. }
  4451. if (result2 !== null) {
  4452. result1 = [result1, result2];
  4453. } else {
  4454. result1 = null;
  4455. pos = pos2;
  4456. }
  4457. } else {
  4458. result1 = null;
  4459. pos = pos2;
  4460. }
  4461. while (result1 !== null) {
  4462. result0.push(result1);
  4463. pos2 = pos;
  4464. result1 = parse_domainlabel();
  4465. if (result1 !== null) {
  4466. if (input.charCodeAt(pos) === 46) {
  4467. result2 = ".";
  4468. pos++;
  4469. } else {
  4470. result2 = null;
  4471. if (reportFailures === 0) {
  4472. matchFailed("\".\"");
  4473. }
  4474. }
  4475. if (result2 !== null) {
  4476. result1 = [result1, result2];
  4477. } else {
  4478. result1 = null;
  4479. pos = pos2;
  4480. }
  4481. } else {
  4482. result1 = null;
  4483. pos = pos2;
  4484. }
  4485. }
  4486. if (result0 !== null) {
  4487. result1 = parse_toplabel();
  4488. if (result1 !== null) {
  4489. if (input.charCodeAt(pos) === 46) {
  4490. result2 = ".";
  4491. pos++;
  4492. } else {
  4493. result2 = null;
  4494. if (reportFailures === 0) {
  4495. matchFailed("\".\"");
  4496. }
  4497. }
  4498. result2 = result2 !== null ? result2 : "";
  4499. if (result2 !== null) {
  4500. result0 = [result0, result1, result2];
  4501. } else {
  4502. result0 = null;
  4503. pos = pos1;
  4504. }
  4505. } else {
  4506. result0 = null;
  4507. pos = pos1;
  4508. }
  4509. } else {
  4510. result0 = null;
  4511. pos = pos1;
  4512. }
  4513. if (result0 !== null) {
  4514. result0 = function (offset) {
  4515. data.host_type = 'domain';
  4516. return input.substring(pos, offset);
  4517. }(pos0);
  4518. }
  4519. if (result0 === null) {
  4520. pos = pos0;
  4521. }
  4522. return result0;
  4523. }
  4524. function parse_domainlabel() {
  4525. var result0, result1, result2;
  4526. var pos0;
  4527. pos0 = pos;
  4528. result0 = parse_alphanum();
  4529. if (result0 !== null) {
  4530. result1 = [];
  4531. result2 = parse_alphanum();
  4532. if (result2 === null) {
  4533. if (input.charCodeAt(pos) === 45) {
  4534. result2 = "-";
  4535. pos++;
  4536. } else {
  4537. result2 = null;
  4538. if (reportFailures === 0) {
  4539. matchFailed("\"-\"");
  4540. }
  4541. }
  4542. if (result2 === null) {
  4543. if (input.charCodeAt(pos) === 95) {
  4544. result2 = "_";
  4545. pos++;
  4546. } else {
  4547. result2 = null;
  4548. if (reportFailures === 0) {
  4549. matchFailed("\"_\"");
  4550. }
  4551. }
  4552. }
  4553. }
  4554. while (result2 !== null) {
  4555. result1.push(result2);
  4556. result2 = parse_alphanum();
  4557. if (result2 === null) {
  4558. if (input.charCodeAt(pos) === 45) {
  4559. result2 = "-";
  4560. pos++;
  4561. } else {
  4562. result2 = null;
  4563. if (reportFailures === 0) {
  4564. matchFailed("\"-\"");
  4565. }
  4566. }
  4567. if (result2 === null) {
  4568. if (input.charCodeAt(pos) === 95) {
  4569. result2 = "_";
  4570. pos++;
  4571. } else {
  4572. result2 = null;
  4573. if (reportFailures === 0) {
  4574. matchFailed("\"_\"");
  4575. }
  4576. }
  4577. }
  4578. }
  4579. }
  4580. if (result1 !== null) {
  4581. result0 = [result0, result1];
  4582. } else {
  4583. result0 = null;
  4584. pos = pos0;
  4585. }
  4586. } else {
  4587. result0 = null;
  4588. pos = pos0;
  4589. }
  4590. return result0;
  4591. }
  4592. function parse_toplabel() {
  4593. var result0, result1, result2;
  4594. var pos0;
  4595. pos0 = pos;
  4596. result0 = parse_ALPHA();
  4597. if (result0 !== null) {
  4598. result1 = [];
  4599. result2 = parse_alphanum();
  4600. if (result2 === null) {
  4601. if (input.charCodeAt(pos) === 45) {
  4602. result2 = "-";
  4603. pos++;
  4604. } else {
  4605. result2 = null;
  4606. if (reportFailures === 0) {
  4607. matchFailed("\"-\"");
  4608. }
  4609. }
  4610. if (result2 === null) {
  4611. if (input.charCodeAt(pos) === 95) {
  4612. result2 = "_";
  4613. pos++;
  4614. } else {
  4615. result2 = null;
  4616. if (reportFailures === 0) {
  4617. matchFailed("\"_\"");
  4618. }
  4619. }
  4620. }
  4621. }
  4622. while (result2 !== null) {
  4623. result1.push(result2);
  4624. result2 = parse_alphanum();
  4625. if (result2 === null) {
  4626. if (input.charCodeAt(pos) === 45) {
  4627. result2 = "-";
  4628. pos++;
  4629. } else {
  4630. result2 = null;
  4631. if (reportFailures === 0) {
  4632. matchFailed("\"-\"");
  4633. }
  4634. }
  4635. if (result2 === null) {
  4636. if (input.charCodeAt(pos) === 95) {
  4637. result2 = "_";
  4638. pos++;
  4639. } else {
  4640. result2 = null;
  4641. if (reportFailures === 0) {
  4642. matchFailed("\"_\"");
  4643. }
  4644. }
  4645. }
  4646. }
  4647. }
  4648. if (result1 !== null) {
  4649. result0 = [result0, result1];
  4650. } else {
  4651. result0 = null;
  4652. pos = pos0;
  4653. }
  4654. } else {
  4655. result0 = null;
  4656. pos = pos0;
  4657. }
  4658. return result0;
  4659. }
  4660. function parse_IPv6reference() {
  4661. var result0, result1, result2;
  4662. var pos0, pos1;
  4663. pos0 = pos;
  4664. pos1 = pos;
  4665. if (input.charCodeAt(pos) === 91) {
  4666. result0 = "[";
  4667. pos++;
  4668. } else {
  4669. result0 = null;
  4670. if (reportFailures === 0) {
  4671. matchFailed("\"[\"");
  4672. }
  4673. }
  4674. if (result0 !== null) {
  4675. result1 = parse_IPv6address();
  4676. if (result1 !== null) {
  4677. if (input.charCodeAt(pos) === 93) {
  4678. result2 = "]";
  4679. pos++;
  4680. } else {
  4681. result2 = null;
  4682. if (reportFailures === 0) {
  4683. matchFailed("\"]\"");
  4684. }
  4685. }
  4686. if (result2 !== null) {
  4687. result0 = [result0, result1, result2];
  4688. } else {
  4689. result0 = null;
  4690. pos = pos1;
  4691. }
  4692. } else {
  4693. result0 = null;
  4694. pos = pos1;
  4695. }
  4696. } else {
  4697. result0 = null;
  4698. pos = pos1;
  4699. }
  4700. if (result0 !== null) {
  4701. result0 = function (offset) {
  4702. data.host_type = 'IPv6';
  4703. return input.substring(pos, offset);
  4704. }(pos0);
  4705. }
  4706. if (result0 === null) {
  4707. pos = pos0;
  4708. }
  4709. return result0;
  4710. }
  4711. function parse_IPv6address() {
  4712. var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12;
  4713. var pos0, pos1, pos2;
  4714. pos0 = pos;
  4715. pos1 = pos;
  4716. result0 = parse_h16();
  4717. if (result0 !== null) {
  4718. if (input.charCodeAt(pos) === 58) {
  4719. result1 = ":";
  4720. pos++;
  4721. } else {
  4722. result1 = null;
  4723. if (reportFailures === 0) {
  4724. matchFailed("\":\"");
  4725. }
  4726. }
  4727. if (result1 !== null) {
  4728. result2 = parse_h16();
  4729. if (result2 !== null) {
  4730. if (input.charCodeAt(pos) === 58) {
  4731. result3 = ":";
  4732. pos++;
  4733. } else {
  4734. result3 = null;
  4735. if (reportFailures === 0) {
  4736. matchFailed("\":\"");
  4737. }
  4738. }
  4739. if (result3 !== null) {
  4740. result4 = parse_h16();
  4741. if (result4 !== null) {
  4742. if (input.charCodeAt(pos) === 58) {
  4743. result5 = ":";
  4744. pos++;
  4745. } else {
  4746. result5 = null;
  4747. if (reportFailures === 0) {
  4748. matchFailed("\":\"");
  4749. }
  4750. }
  4751. if (result5 !== null) {
  4752. result6 = parse_h16();
  4753. if (result6 !== null) {
  4754. if (input.charCodeAt(pos) === 58) {
  4755. result7 = ":";
  4756. pos++;
  4757. } else {
  4758. result7 = null;
  4759. if (reportFailures === 0) {
  4760. matchFailed("\":\"");
  4761. }
  4762. }
  4763. if (result7 !== null) {
  4764. result8 = parse_h16();
  4765. if (result8 !== null) {
  4766. if (input.charCodeAt(pos) === 58) {
  4767. result9 = ":";
  4768. pos++;
  4769. } else {
  4770. result9 = null;
  4771. if (reportFailures === 0) {
  4772. matchFailed("\":\"");
  4773. }
  4774. }
  4775. if (result9 !== null) {
  4776. result10 = parse_h16();
  4777. if (result10 !== null) {
  4778. if (input.charCodeAt(pos) === 58) {
  4779. result11 = ":";
  4780. pos++;
  4781. } else {
  4782. result11 = null;
  4783. if (reportFailures === 0) {
  4784. matchFailed("\":\"");
  4785. }
  4786. }
  4787. if (result11 !== null) {
  4788. result12 = parse_ls32();
  4789. if (result12 !== null) {
  4790. result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12];
  4791. } else {
  4792. result0 = null;
  4793. pos = pos1;
  4794. }
  4795. } else {
  4796. result0 = null;
  4797. pos = pos1;
  4798. }
  4799. } else {
  4800. result0 = null;
  4801. pos = pos1;
  4802. }
  4803. } else {
  4804. result0 = null;
  4805. pos = pos1;
  4806. }
  4807. } else {
  4808. result0 = null;
  4809. pos = pos1;
  4810. }
  4811. } else {
  4812. result0 = null;
  4813. pos = pos1;
  4814. }
  4815. } else {
  4816. result0 = null;
  4817. pos = pos1;
  4818. }
  4819. } else {
  4820. result0 = null;
  4821. pos = pos1;
  4822. }
  4823. } else {
  4824. result0 = null;
  4825. pos = pos1;
  4826. }
  4827. } else {
  4828. result0 = null;
  4829. pos = pos1;
  4830. }
  4831. } else {
  4832. result0 = null;
  4833. pos = pos1;
  4834. }
  4835. } else {
  4836. result0 = null;
  4837. pos = pos1;
  4838. }
  4839. } else {
  4840. result0 = null;
  4841. pos = pos1;
  4842. }
  4843. if (result0 === null) {
  4844. pos1 = pos;
  4845. if (input.substr(pos, 2) === "::") {
  4846. result0 = "::";
  4847. pos += 2;
  4848. } else {
  4849. result0 = null;
  4850. if (reportFailures === 0) {
  4851. matchFailed("\"::\"");
  4852. }
  4853. }
  4854. if (result0 !== null) {
  4855. result1 = parse_h16();
  4856. if (result1 !== null) {
  4857. if (input.charCodeAt(pos) === 58) {
  4858. result2 = ":";
  4859. pos++;
  4860. } else {
  4861. result2 = null;
  4862. if (reportFailures === 0) {
  4863. matchFailed("\":\"");
  4864. }
  4865. }
  4866. if (result2 !== null) {
  4867. result3 = parse_h16();
  4868. if (result3 !== null) {
  4869. if (input.charCodeAt(pos) === 58) {
  4870. result4 = ":";
  4871. pos++;
  4872. } else {
  4873. result4 = null;
  4874. if (reportFailures === 0) {
  4875. matchFailed("\":\"");
  4876. }
  4877. }
  4878. if (result4 !== null) {
  4879. result5 = parse_h16();
  4880. if (result5 !== null) {
  4881. if (input.charCodeAt(pos) === 58) {
  4882. result6 = ":";
  4883. pos++;
  4884. } else {
  4885. result6 = null;
  4886. if (reportFailures === 0) {
  4887. matchFailed("\":\"");
  4888. }
  4889. }
  4890. if (result6 !== null) {
  4891. result7 = parse_h16();
  4892. if (result7 !== null) {
  4893. if (input.charCodeAt(pos) === 58) {
  4894. result8 = ":";
  4895. pos++;
  4896. } else {
  4897. result8 = null;
  4898. if (reportFailures === 0) {
  4899. matchFailed("\":\"");
  4900. }
  4901. }
  4902. if (result8 !== null) {
  4903. result9 = parse_h16();
  4904. if (result9 !== null) {
  4905. if (input.charCodeAt(pos) === 58) {
  4906. result10 = ":";
  4907. pos++;
  4908. } else {
  4909. result10 = null;
  4910. if (reportFailures === 0) {
  4911. matchFailed("\":\"");
  4912. }
  4913. }
  4914. if (result10 !== null) {
  4915. result11 = parse_ls32();
  4916. if (result11 !== null) {
  4917. result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11];
  4918. } else {
  4919. result0 = null;
  4920. pos = pos1;
  4921. }
  4922. } else {
  4923. result0 = null;
  4924. pos = pos1;
  4925. }
  4926. } else {
  4927. result0 = null;
  4928. pos = pos1;
  4929. }
  4930. } else {
  4931. result0 = null;
  4932. pos = pos1;
  4933. }
  4934. } else {
  4935. result0 = null;
  4936. pos = pos1;
  4937. }
  4938. } else {
  4939. result0 = null;
  4940. pos = pos1;
  4941. }
  4942. } else {
  4943. result0 = null;
  4944. pos = pos1;
  4945. }
  4946. } else {
  4947. result0 = null;
  4948. pos = pos1;
  4949. }
  4950. } else {
  4951. result0 = null;
  4952. pos = pos1;
  4953. }
  4954. } else {
  4955. result0 = null;
  4956. pos = pos1;
  4957. }
  4958. } else {
  4959. result0 = null;
  4960. pos = pos1;
  4961. }
  4962. } else {
  4963. result0 = null;
  4964. pos = pos1;
  4965. }
  4966. if (result0 === null) {
  4967. pos1 = pos;
  4968. if (input.substr(pos, 2) === "::") {
  4969. result0 = "::";
  4970. pos += 2;
  4971. } else {
  4972. result0 = null;
  4973. if (reportFailures === 0) {
  4974. matchFailed("\"::\"");
  4975. }
  4976. }
  4977. if (result0 !== null) {
  4978. result1 = parse_h16();
  4979. if (result1 !== null) {
  4980. if (input.charCodeAt(pos) === 58) {
  4981. result2 = ":";
  4982. pos++;
  4983. } else {
  4984. result2 = null;
  4985. if (reportFailures === 0) {
  4986. matchFailed("\":\"");
  4987. }
  4988. }
  4989. if (result2 !== null) {
  4990. result3 = parse_h16();
  4991. if (result3 !== null) {
  4992. if (input.charCodeAt(pos) === 58) {
  4993. result4 = ":";
  4994. pos++;
  4995. } else {
  4996. result4 = null;
  4997. if (reportFailures === 0) {
  4998. matchFailed("\":\"");
  4999. }
  5000. }
  5001. if (result4 !== null) {
  5002. result5 = parse_h16();
  5003. if (result5 !== null) {
  5004. if (input.charCodeAt(pos) === 58) {
  5005. result6 = ":";
  5006. pos++;
  5007. } else {
  5008. result6 = null;
  5009. if (reportFailures === 0) {
  5010. matchFailed("\":\"");
  5011. }
  5012. }
  5013. if (result6 !== null) {
  5014. result7 = parse_h16();
  5015. if (result7 !== null) {
  5016. if (input.charCodeAt(pos) === 58) {
  5017. result8 = ":";
  5018. pos++;
  5019. } else {
  5020. result8 = null;
  5021. if (reportFailures === 0) {
  5022. matchFailed("\":\"");
  5023. }
  5024. }
  5025. if (result8 !== null) {
  5026. result9 = parse_ls32();
  5027. if (result9 !== null) {
  5028. result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9];
  5029. } else {
  5030. result0 = null;
  5031. pos = pos1;
  5032. }
  5033. } else {
  5034. result0 = null;
  5035. pos = pos1;
  5036. }
  5037. } else {
  5038. result0 = null;
  5039. pos = pos1;
  5040. }
  5041. } else {
  5042. result0 = null;
  5043. pos = pos1;
  5044. }
  5045. } else {
  5046. result0 = null;
  5047. pos = pos1;
  5048. }
  5049. } else {
  5050. result0 = null;
  5051. pos = pos1;
  5052. }
  5053. } else {
  5054. result0 = null;
  5055. pos = pos1;
  5056. }
  5057. } else {
  5058. result0 = null;
  5059. pos = pos1;
  5060. }
  5061. } else {
  5062. result0 = null;
  5063. pos = pos1;
  5064. }
  5065. } else {
  5066. result0 = null;
  5067. pos = pos1;
  5068. }
  5069. if (result0 === null) {
  5070. pos1 = pos;
  5071. if (input.substr(pos, 2) === "::") {
  5072. result0 = "::";
  5073. pos += 2;
  5074. } else {
  5075. result0 = null;
  5076. if (reportFailures === 0) {
  5077. matchFailed("\"::\"");
  5078. }
  5079. }
  5080. if (result0 !== null) {
  5081. result1 = parse_h16();
  5082. if (result1 !== null) {
  5083. if (input.charCodeAt(pos) === 58) {
  5084. result2 = ":";
  5085. pos++;
  5086. } else {
  5087. result2 = null;
  5088. if (reportFailures === 0) {
  5089. matchFailed("\":\"");
  5090. }
  5091. }
  5092. if (result2 !== null) {
  5093. result3 = parse_h16();
  5094. if (result3 !== null) {
  5095. if (input.charCodeAt(pos) === 58) {
  5096. result4 = ":";
  5097. pos++;
  5098. } else {
  5099. result4 = null;
  5100. if (reportFailures === 0) {
  5101. matchFailed("\":\"");
  5102. }
  5103. }
  5104. if (result4 !== null) {
  5105. result5 = parse_h16();
  5106. if (result5 !== null) {
  5107. if (input.charCodeAt(pos) === 58) {
  5108. result6 = ":";
  5109. pos++;
  5110. } else {
  5111. result6 = null;
  5112. if (reportFailures === 0) {
  5113. matchFailed("\":\"");
  5114. }
  5115. }
  5116. if (result6 !== null) {
  5117. result7 = parse_ls32();
  5118. if (result7 !== null) {
  5119. result0 = [result0, result1, result2, result3, result4, result5, result6, result7];
  5120. } else {
  5121. result0 = null;
  5122. pos = pos1;
  5123. }
  5124. } else {
  5125. result0 = null;
  5126. pos = pos1;
  5127. }
  5128. } else {
  5129. result0 = null;
  5130. pos = pos1;
  5131. }
  5132. } else {
  5133. result0 = null;
  5134. pos = pos1;
  5135. }
  5136. } else {
  5137. result0 = null;
  5138. pos = pos1;
  5139. }
  5140. } else {
  5141. result0 = null;
  5142. pos = pos1;
  5143. }
  5144. } else {
  5145. result0 = null;
  5146. pos = pos1;
  5147. }
  5148. } else {
  5149. result0 = null;
  5150. pos = pos1;
  5151. }
  5152. if (result0 === null) {
  5153. pos1 = pos;
  5154. if (input.substr(pos, 2) === "::") {
  5155. result0 = "::";
  5156. pos += 2;
  5157. } else {
  5158. result0 = null;
  5159. if (reportFailures === 0) {
  5160. matchFailed("\"::\"");
  5161. }
  5162. }
  5163. if (result0 !== null) {
  5164. result1 = parse_h16();
  5165. if (result1 !== null) {
  5166. if (input.charCodeAt(pos) === 58) {
  5167. result2 = ":";
  5168. pos++;
  5169. } else {
  5170. result2 = null;
  5171. if (reportFailures === 0) {
  5172. matchFailed("\":\"");
  5173. }
  5174. }
  5175. if (result2 !== null) {
  5176. result3 = parse_h16();
  5177. if (result3 !== null) {
  5178. if (input.charCodeAt(pos) === 58) {
  5179. result4 = ":";
  5180. pos++;
  5181. } else {
  5182. result4 = null;
  5183. if (reportFailures === 0) {
  5184. matchFailed("\":\"");
  5185. }
  5186. }
  5187. if (result4 !== null) {
  5188. result5 = parse_ls32();
  5189. if (result5 !== null) {
  5190. result0 = [result0, result1, result2, result3, result4, result5];
  5191. } else {
  5192. result0 = null;
  5193. pos = pos1;
  5194. }
  5195. } else {
  5196. result0 = null;
  5197. pos = pos1;
  5198. }
  5199. } else {
  5200. result0 = null;
  5201. pos = pos1;
  5202. }
  5203. } else {
  5204. result0 = null;
  5205. pos = pos1;
  5206. }
  5207. } else {
  5208. result0 = null;
  5209. pos = pos1;
  5210. }
  5211. } else {
  5212. result0 = null;
  5213. pos = pos1;
  5214. }
  5215. if (result0 === null) {
  5216. pos1 = pos;
  5217. if (input.substr(pos, 2) === "::") {
  5218. result0 = "::";
  5219. pos += 2;
  5220. } else {
  5221. result0 = null;
  5222. if (reportFailures === 0) {
  5223. matchFailed("\"::\"");
  5224. }
  5225. }
  5226. if (result0 !== null) {
  5227. result1 = parse_h16();
  5228. if (result1 !== null) {
  5229. if (input.charCodeAt(pos) === 58) {
  5230. result2 = ":";
  5231. pos++;
  5232. } else {
  5233. result2 = null;
  5234. if (reportFailures === 0) {
  5235. matchFailed("\":\"");
  5236. }
  5237. }
  5238. if (result2 !== null) {
  5239. result3 = parse_ls32();
  5240. if (result3 !== null) {
  5241. result0 = [result0, result1, result2, result3];
  5242. } else {
  5243. result0 = null;
  5244. pos = pos1;
  5245. }
  5246. } else {
  5247. result0 = null;
  5248. pos = pos1;
  5249. }
  5250. } else {
  5251. result0 = null;
  5252. pos = pos1;
  5253. }
  5254. } else {
  5255. result0 = null;
  5256. pos = pos1;
  5257. }
  5258. if (result0 === null) {
  5259. pos1 = pos;
  5260. if (input.substr(pos, 2) === "::") {
  5261. result0 = "::";
  5262. pos += 2;
  5263. } else {
  5264. result0 = null;
  5265. if (reportFailures === 0) {
  5266. matchFailed("\"::\"");
  5267. }
  5268. }
  5269. if (result0 !== null) {
  5270. result1 = parse_ls32();
  5271. if (result1 !== null) {
  5272. result0 = [result0, result1];
  5273. } else {
  5274. result0 = null;
  5275. pos = pos1;
  5276. }
  5277. } else {
  5278. result0 = null;
  5279. pos = pos1;
  5280. }
  5281. if (result0 === null) {
  5282. pos1 = pos;
  5283. if (input.substr(pos, 2) === "::") {
  5284. result0 = "::";
  5285. pos += 2;
  5286. } else {
  5287. result0 = null;
  5288. if (reportFailures === 0) {
  5289. matchFailed("\"::\"");
  5290. }
  5291. }
  5292. if (result0 !== null) {
  5293. result1 = parse_h16();
  5294. if (result1 !== null) {
  5295. result0 = [result0, result1];
  5296. } else {
  5297. result0 = null;
  5298. pos = pos1;
  5299. }
  5300. } else {
  5301. result0 = null;
  5302. pos = pos1;
  5303. }
  5304. if (result0 === null) {
  5305. pos1 = pos;
  5306. result0 = parse_h16();
  5307. if (result0 !== null) {
  5308. if (input.substr(pos, 2) === "::") {
  5309. result1 = "::";
  5310. pos += 2;
  5311. } else {
  5312. result1 = null;
  5313. if (reportFailures === 0) {
  5314. matchFailed("\"::\"");
  5315. }
  5316. }
  5317. if (result1 !== null) {
  5318. result2 = parse_h16();
  5319. if (result2 !== null) {
  5320. if (input.charCodeAt(pos) === 58) {
  5321. result3 = ":";
  5322. pos++;
  5323. } else {
  5324. result3 = null;
  5325. if (reportFailures === 0) {
  5326. matchFailed("\":\"");
  5327. }
  5328. }
  5329. if (result3 !== null) {
  5330. result4 = parse_h16();
  5331. if (result4 !== null) {
  5332. if (input.charCodeAt(pos) === 58) {
  5333. result5 = ":";
  5334. pos++;
  5335. } else {
  5336. result5 = null;
  5337. if (reportFailures === 0) {
  5338. matchFailed("\":\"");
  5339. }
  5340. }
  5341. if (result5 !== null) {
  5342. result6 = parse_h16();
  5343. if (result6 !== null) {
  5344. if (input.charCodeAt(pos) === 58) {
  5345. result7 = ":";
  5346. pos++;
  5347. } else {
  5348. result7 = null;
  5349. if (reportFailures === 0) {
  5350. matchFailed("\":\"");
  5351. }
  5352. }
  5353. if (result7 !== null) {
  5354. result8 = parse_h16();
  5355. if (result8 !== null) {
  5356. if (input.charCodeAt(pos) === 58) {
  5357. result9 = ":";
  5358. pos++;
  5359. } else {
  5360. result9 = null;
  5361. if (reportFailures === 0) {
  5362. matchFailed("\":\"");
  5363. }
  5364. }
  5365. if (result9 !== null) {
  5366. result10 = parse_ls32();
  5367. if (result10 !== null) {
  5368. result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10];
  5369. } else {
  5370. result0 = null;
  5371. pos = pos1;
  5372. }
  5373. } else {
  5374. result0 = null;
  5375. pos = pos1;
  5376. }
  5377. } else {
  5378. result0 = null;
  5379. pos = pos1;
  5380. }
  5381. } else {
  5382. result0 = null;
  5383. pos = pos1;
  5384. }
  5385. } else {
  5386. result0 = null;
  5387. pos = pos1;
  5388. }
  5389. } else {
  5390. result0 = null;
  5391. pos = pos1;
  5392. }
  5393. } else {
  5394. result0 = null;
  5395. pos = pos1;
  5396. }
  5397. } else {
  5398. result0 = null;
  5399. pos = pos1;
  5400. }
  5401. } else {
  5402. result0 = null;
  5403. pos = pos1;
  5404. }
  5405. } else {
  5406. result0 = null;
  5407. pos = pos1;
  5408. }
  5409. } else {
  5410. result0 = null;
  5411. pos = pos1;
  5412. }
  5413. if (result0 === null) {
  5414. pos1 = pos;
  5415. result0 = parse_h16();
  5416. if (result0 !== null) {
  5417. pos2 = pos;
  5418. if (input.charCodeAt(pos) === 58) {
  5419. result1 = ":";
  5420. pos++;
  5421. } else {
  5422. result1 = null;
  5423. if (reportFailures === 0) {
  5424. matchFailed("\":\"");
  5425. }
  5426. }
  5427. if (result1 !== null) {
  5428. result2 = parse_h16();
  5429. if (result2 !== null) {
  5430. result1 = [result1, result2];
  5431. } else {
  5432. result1 = null;
  5433. pos = pos2;
  5434. }
  5435. } else {
  5436. result1 = null;
  5437. pos = pos2;
  5438. }
  5439. result1 = result1 !== null ? result1 : "";
  5440. if (result1 !== null) {
  5441. if (input.substr(pos, 2) === "::") {
  5442. result2 = "::";
  5443. pos += 2;
  5444. } else {
  5445. result2 = null;
  5446. if (reportFailures === 0) {
  5447. matchFailed("\"::\"");
  5448. }
  5449. }
  5450. if (result2 !== null) {
  5451. result3 = parse_h16();
  5452. if (result3 !== null) {
  5453. if (input.charCodeAt(pos) === 58) {
  5454. result4 = ":";
  5455. pos++;
  5456. } else {
  5457. result4 = null;
  5458. if (reportFailures === 0) {
  5459. matchFailed("\":\"");
  5460. }
  5461. }
  5462. if (result4 !== null) {
  5463. result5 = parse_h16();
  5464. if (result5 !== null) {
  5465. if (input.charCodeAt(pos) === 58) {
  5466. result6 = ":";
  5467. pos++;
  5468. } else {
  5469. result6 = null;
  5470. if (reportFailures === 0) {
  5471. matchFailed("\":\"");
  5472. }
  5473. }
  5474. if (result6 !== null) {
  5475. result7 = parse_h16();
  5476. if (result7 !== null) {
  5477. if (input.charCodeAt(pos) === 58) {
  5478. result8 = ":";
  5479. pos++;
  5480. } else {
  5481. result8 = null;
  5482. if (reportFailures === 0) {
  5483. matchFailed("\":\"");
  5484. }
  5485. }
  5486. if (result8 !== null) {
  5487. result9 = parse_ls32();
  5488. if (result9 !== null) {
  5489. result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9];
  5490. } else {
  5491. result0 = null;
  5492. pos = pos1;
  5493. }
  5494. } else {
  5495. result0 = null;
  5496. pos = pos1;
  5497. }
  5498. } else {
  5499. result0 = null;
  5500. pos = pos1;
  5501. }
  5502. } else {
  5503. result0 = null;
  5504. pos = pos1;
  5505. }
  5506. } else {
  5507. result0 = null;
  5508. pos = pos1;
  5509. }
  5510. } else {
  5511. result0 = null;
  5512. pos = pos1;
  5513. }
  5514. } else {
  5515. result0 = null;
  5516. pos = pos1;
  5517. }
  5518. } else {
  5519. result0 = null;
  5520. pos = pos1;
  5521. }
  5522. } else {
  5523. result0 = null;
  5524. pos = pos1;
  5525. }
  5526. } else {
  5527. result0 = null;
  5528. pos = pos1;
  5529. }
  5530. if (result0 === null) {
  5531. pos1 = pos;
  5532. result0 = parse_h16();
  5533. if (result0 !== null) {
  5534. pos2 = pos;
  5535. if (input.charCodeAt(pos) === 58) {
  5536. result1 = ":";
  5537. pos++;
  5538. } else {
  5539. result1 = null;
  5540. if (reportFailures === 0) {
  5541. matchFailed("\":\"");
  5542. }
  5543. }
  5544. if (result1 !== null) {
  5545. result2 = parse_h16();
  5546. if (result2 !== null) {
  5547. result1 = [result1, result2];
  5548. } else {
  5549. result1 = null;
  5550. pos = pos2;
  5551. }
  5552. } else {
  5553. result1 = null;
  5554. pos = pos2;
  5555. }
  5556. result1 = result1 !== null ? result1 : "";
  5557. if (result1 !== null) {
  5558. pos2 = pos;
  5559. if (input.charCodeAt(pos) === 58) {
  5560. result2 = ":";
  5561. pos++;
  5562. } else {
  5563. result2 = null;
  5564. if (reportFailures === 0) {
  5565. matchFailed("\":\"");
  5566. }
  5567. }
  5568. if (result2 !== null) {
  5569. result3 = parse_h16();
  5570. if (result3 !== null) {
  5571. result2 = [result2, result3];
  5572. } else {
  5573. result2 = null;
  5574. pos = pos2;
  5575. }
  5576. } else {
  5577. result2 = null;
  5578. pos = pos2;
  5579. }
  5580. result2 = result2 !== null ? result2 : "";
  5581. if (result2 !== null) {
  5582. if (input.substr(pos, 2) === "::") {
  5583. result3 = "::";
  5584. pos += 2;
  5585. } else {
  5586. result3 = null;
  5587. if (reportFailures === 0) {
  5588. matchFailed("\"::\"");
  5589. }
  5590. }
  5591. if (result3 !== null) {
  5592. result4 = parse_h16();
  5593. if (result4 !== null) {
  5594. if (input.charCodeAt(pos) === 58) {
  5595. result5 = ":";
  5596. pos++;
  5597. } else {
  5598. result5 = null;
  5599. if (reportFailures === 0) {
  5600. matchFailed("\":\"");
  5601. }
  5602. }
  5603. if (result5 !== null) {
  5604. result6 = parse_h16();
  5605. if (result6 !== null) {
  5606. if (input.charCodeAt(pos) === 58) {
  5607. result7 = ":";
  5608. pos++;
  5609. } else {
  5610. result7 = null;
  5611. if (reportFailures === 0) {
  5612. matchFailed("\":\"");
  5613. }
  5614. }
  5615. if (result7 !== null) {
  5616. result8 = parse_ls32();
  5617. if (result8 !== null) {
  5618. result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8];
  5619. } else {
  5620. result0 = null;
  5621. pos = pos1;
  5622. }
  5623. } else {
  5624. result0 = null;
  5625. pos = pos1;
  5626. }
  5627. } else {
  5628. result0 = null;
  5629. pos = pos1;
  5630. }
  5631. } else {
  5632. result0 = null;
  5633. pos = pos1;
  5634. }
  5635. } else {
  5636. result0 = null;
  5637. pos = pos1;
  5638. }
  5639. } else {
  5640. result0 = null;
  5641. pos = pos1;
  5642. }
  5643. } else {
  5644. result0 = null;
  5645. pos = pos1;
  5646. }
  5647. } else {
  5648. result0 = null;
  5649. pos = pos1;
  5650. }
  5651. } else {
  5652. result0 = null;
  5653. pos = pos1;
  5654. }
  5655. if (result0 === null) {
  5656. pos1 = pos;
  5657. result0 = parse_h16();
  5658. if (result0 !== null) {
  5659. pos2 = pos;
  5660. if (input.charCodeAt(pos) === 58) {
  5661. result1 = ":";
  5662. pos++;
  5663. } else {
  5664. result1 = null;
  5665. if (reportFailures === 0) {
  5666. matchFailed("\":\"");
  5667. }
  5668. }
  5669. if (result1 !== null) {
  5670. result2 = parse_h16();
  5671. if (result2 !== null) {
  5672. result1 = [result1, result2];
  5673. } else {
  5674. result1 = null;
  5675. pos = pos2;
  5676. }
  5677. } else {
  5678. result1 = null;
  5679. pos = pos2;
  5680. }
  5681. result1 = result1 !== null ? result1 : "";
  5682. if (result1 !== null) {
  5683. pos2 = pos;
  5684. if (input.charCodeAt(pos) === 58) {
  5685. result2 = ":";
  5686. pos++;
  5687. } else {
  5688. result2 = null;
  5689. if (reportFailures === 0) {
  5690. matchFailed("\":\"");
  5691. }
  5692. }
  5693. if (result2 !== null) {
  5694. result3 = parse_h16();
  5695. if (result3 !== null) {
  5696. result2 = [result2, result3];
  5697. } else {
  5698. result2 = null;
  5699. pos = pos2;
  5700. }
  5701. } else {
  5702. result2 = null;
  5703. pos = pos2;
  5704. }
  5705. result2 = result2 !== null ? result2 : "";
  5706. if (result2 !== null) {
  5707. pos2 = pos;
  5708. if (input.charCodeAt(pos) === 58) {
  5709. result3 = ":";
  5710. pos++;
  5711. } else {
  5712. result3 = null;
  5713. if (reportFailures === 0) {
  5714. matchFailed("\":\"");
  5715. }
  5716. }
  5717. if (result3 !== null) {
  5718. result4 = parse_h16();
  5719. if (result4 !== null) {
  5720. result3 = [result3, result4];
  5721. } else {
  5722. result3 = null;
  5723. pos = pos2;
  5724. }
  5725. } else {
  5726. result3 = null;
  5727. pos = pos2;
  5728. }
  5729. result3 = result3 !== null ? result3 : "";
  5730. if (result3 !== null) {
  5731. if (input.substr(pos, 2) === "::") {
  5732. result4 = "::";
  5733. pos += 2;
  5734. } else {
  5735. result4 = null;
  5736. if (reportFailures === 0) {
  5737. matchFailed("\"::\"");
  5738. }
  5739. }
  5740. if (result4 !== null) {
  5741. result5 = parse_h16();
  5742. if (result5 !== null) {
  5743. if (input.charCodeAt(pos) === 58) {
  5744. result6 = ":";
  5745. pos++;
  5746. } else {
  5747. result6 = null;
  5748. if (reportFailures === 0) {
  5749. matchFailed("\":\"");
  5750. }
  5751. }
  5752. if (result6 !== null) {
  5753. result7 = parse_ls32();
  5754. if (result7 !== null) {
  5755. result0 = [result0, result1, result2, result3, result4, result5, result6, result7];
  5756. } else {
  5757. result0 = null;
  5758. pos = pos1;
  5759. }
  5760. } else {
  5761. result0 = null;
  5762. pos = pos1;
  5763. }
  5764. } else {
  5765. result0 = null;
  5766. pos = pos1;
  5767. }
  5768. } else {
  5769. result0 = null;
  5770. pos = pos1;
  5771. }
  5772. } else {
  5773. result0 = null;
  5774. pos = pos1;
  5775. }
  5776. } else {
  5777. result0 = null;
  5778. pos = pos1;
  5779. }
  5780. } else {
  5781. result0 = null;
  5782. pos = pos1;
  5783. }
  5784. } else {
  5785. result0 = null;
  5786. pos = pos1;
  5787. }
  5788. if (result0 === null) {
  5789. pos1 = pos;
  5790. result0 = parse_h16();
  5791. if (result0 !== null) {
  5792. pos2 = pos;
  5793. if (input.charCodeAt(pos) === 58) {
  5794. result1 = ":";
  5795. pos++;
  5796. } else {
  5797. result1 = null;
  5798. if (reportFailures === 0) {
  5799. matchFailed("\":\"");
  5800. }
  5801. }
  5802. if (result1 !== null) {
  5803. result2 = parse_h16();
  5804. if (result2 !== null) {
  5805. result1 = [result1, result2];
  5806. } else {
  5807. result1 = null;
  5808. pos = pos2;
  5809. }
  5810. } else {
  5811. result1 = null;
  5812. pos = pos2;
  5813. }
  5814. result1 = result1 !== null ? result1 : "";
  5815. if (result1 !== null) {
  5816. pos2 = pos;
  5817. if (input.charCodeAt(pos) === 58) {
  5818. result2 = ":";
  5819. pos++;
  5820. } else {
  5821. result2 = null;
  5822. if (reportFailures === 0) {
  5823. matchFailed("\":\"");
  5824. }
  5825. }
  5826. if (result2 !== null) {
  5827. result3 = parse_h16();
  5828. if (result3 !== null) {
  5829. result2 = [result2, result3];
  5830. } else {
  5831. result2 = null;
  5832. pos = pos2;
  5833. }
  5834. } else {
  5835. result2 = null;
  5836. pos = pos2;
  5837. }
  5838. result2 = result2 !== null ? result2 : "";
  5839. if (result2 !== null) {
  5840. pos2 = pos;
  5841. if (input.charCodeAt(pos) === 58) {
  5842. result3 = ":";
  5843. pos++;
  5844. } else {
  5845. result3 = null;
  5846. if (reportFailures === 0) {
  5847. matchFailed("\":\"");
  5848. }
  5849. }
  5850. if (result3 !== null) {
  5851. result4 = parse_h16();
  5852. if (result4 !== null) {
  5853. result3 = [result3, result4];
  5854. } else {
  5855. result3 = null;
  5856. pos = pos2;
  5857. }
  5858. } else {
  5859. result3 = null;
  5860. pos = pos2;
  5861. }
  5862. result3 = result3 !== null ? result3 : "";
  5863. if (result3 !== null) {
  5864. pos2 = pos;
  5865. if (input.charCodeAt(pos) === 58) {
  5866. result4 = ":";
  5867. pos++;
  5868. } else {
  5869. result4 = null;
  5870. if (reportFailures === 0) {
  5871. matchFailed("\":\"");
  5872. }
  5873. }
  5874. if (result4 !== null) {
  5875. result5 = parse_h16();
  5876. if (result5 !== null) {
  5877. result4 = [result4, result5];
  5878. } else {
  5879. result4 = null;
  5880. pos = pos2;
  5881. }
  5882. } else {
  5883. result4 = null;
  5884. pos = pos2;
  5885. }
  5886. result4 = result4 !== null ? result4 : "";
  5887. if (result4 !== null) {
  5888. if (input.substr(pos, 2) === "::") {
  5889. result5 = "::";
  5890. pos += 2;
  5891. } else {
  5892. result5 = null;
  5893. if (reportFailures === 0) {
  5894. matchFailed("\"::\"");
  5895. }
  5896. }
  5897. if (result5 !== null) {
  5898. result6 = parse_ls32();
  5899. if (result6 !== null) {
  5900. result0 = [result0, result1, result2, result3, result4, result5, result6];
  5901. } else {
  5902. result0 = null;
  5903. pos = pos1;
  5904. }
  5905. } else {
  5906. result0 = null;
  5907. pos = pos1;
  5908. }
  5909. } else {
  5910. result0 = null;
  5911. pos = pos1;
  5912. }
  5913. } else {
  5914. result0 = null;
  5915. pos = pos1;
  5916. }
  5917. } else {
  5918. result0 = null;
  5919. pos = pos1;
  5920. }
  5921. } else {
  5922. result0 = null;
  5923. pos = pos1;
  5924. }
  5925. } else {
  5926. result0 = null;
  5927. pos = pos1;
  5928. }
  5929. if (result0 === null) {
  5930. pos1 = pos;
  5931. result0 = parse_h16();
  5932. if (result0 !== null) {
  5933. pos2 = pos;
  5934. if (input.charCodeAt(pos) === 58) {
  5935. result1 = ":";
  5936. pos++;
  5937. } else {
  5938. result1 = null;
  5939. if (reportFailures === 0) {
  5940. matchFailed("\":\"");
  5941. }
  5942. }
  5943. if (result1 !== null) {
  5944. result2 = parse_h16();
  5945. if (result2 !== null) {
  5946. result1 = [result1, result2];
  5947. } else {
  5948. result1 = null;
  5949. pos = pos2;
  5950. }
  5951. } else {
  5952. result1 = null;
  5953. pos = pos2;
  5954. }
  5955. result1 = result1 !== null ? result1 : "";
  5956. if (result1 !== null) {
  5957. pos2 = pos;
  5958. if (input.charCodeAt(pos) === 58) {
  5959. result2 = ":";
  5960. pos++;
  5961. } else {
  5962. result2 = null;
  5963. if (reportFailures === 0) {
  5964. matchFailed("\":\"");
  5965. }
  5966. }
  5967. if (result2 !== null) {
  5968. result3 = parse_h16();
  5969. if (result3 !== null) {
  5970. result2 = [result2, result3];
  5971. } else {
  5972. result2 = null;
  5973. pos = pos2;
  5974. }
  5975. } else {
  5976. result2 = null;
  5977. pos = pos2;
  5978. }
  5979. result2 = result2 !== null ? result2 : "";
  5980. if (result2 !== null) {
  5981. pos2 = pos;
  5982. if (input.charCodeAt(pos) === 58) {
  5983. result3 = ":";
  5984. pos++;
  5985. } else {
  5986. result3 = null;
  5987. if (reportFailures === 0) {
  5988. matchFailed("\":\"");
  5989. }
  5990. }
  5991. if (result3 !== null) {
  5992. result4 = parse_h16();
  5993. if (result4 !== null) {
  5994. result3 = [result3, result4];
  5995. } else {
  5996. result3 = null;
  5997. pos = pos2;
  5998. }
  5999. } else {
  6000. result3 = null;
  6001. pos = pos2;
  6002. }
  6003. result3 = result3 !== null ? result3 : "";
  6004. if (result3 !== null) {
  6005. pos2 = pos;
  6006. if (input.charCodeAt(pos) === 58) {
  6007. result4 = ":";
  6008. pos++;
  6009. } else {
  6010. result4 = null;
  6011. if (reportFailures === 0) {
  6012. matchFailed("\":\"");
  6013. }
  6014. }
  6015. if (result4 !== null) {
  6016. result5 = parse_h16();
  6017. if (result5 !== null) {
  6018. result4 = [result4, result5];
  6019. } else {
  6020. result4 = null;
  6021. pos = pos2;
  6022. }
  6023. } else {
  6024. result4 = null;
  6025. pos = pos2;
  6026. }
  6027. result4 = result4 !== null ? result4 : "";
  6028. if (result4 !== null) {
  6029. pos2 = pos;
  6030. if (input.charCodeAt(pos) === 58) {
  6031. result5 = ":";
  6032. pos++;
  6033. } else {
  6034. result5 = null;
  6035. if (reportFailures === 0) {
  6036. matchFailed("\":\"");
  6037. }
  6038. }
  6039. if (result5 !== null) {
  6040. result6 = parse_h16();
  6041. if (result6 !== null) {
  6042. result5 = [result5, result6];
  6043. } else {
  6044. result5 = null;
  6045. pos = pos2;
  6046. }
  6047. } else {
  6048. result5 = null;
  6049. pos = pos2;
  6050. }
  6051. result5 = result5 !== null ? result5 : "";
  6052. if (result5 !== null) {
  6053. if (input.substr(pos, 2) === "::") {
  6054. result6 = "::";
  6055. pos += 2;
  6056. } else {
  6057. result6 = null;
  6058. if (reportFailures === 0) {
  6059. matchFailed("\"::\"");
  6060. }
  6061. }
  6062. if (result6 !== null) {
  6063. result7 = parse_h16();
  6064. if (result7 !== null) {
  6065. result0 = [result0, result1, result2, result3, result4, result5, result6, result7];
  6066. } else {
  6067. result0 = null;
  6068. pos = pos1;
  6069. }
  6070. } else {
  6071. result0 = null;
  6072. pos = pos1;
  6073. }
  6074. } else {
  6075. result0 = null;
  6076. pos = pos1;
  6077. }
  6078. } else {
  6079. result0 = null;
  6080. pos = pos1;
  6081. }
  6082. } else {
  6083. result0 = null;
  6084. pos = pos1;
  6085. }
  6086. } else {
  6087. result0 = null;
  6088. pos = pos1;
  6089. }
  6090. } else {
  6091. result0 = null;
  6092. pos = pos1;
  6093. }
  6094. } else {
  6095. result0 = null;
  6096. pos = pos1;
  6097. }
  6098. if (result0 === null) {
  6099. pos1 = pos;
  6100. result0 = parse_h16();
  6101. if (result0 !== null) {
  6102. pos2 = pos;
  6103. if (input.charCodeAt(pos) === 58) {
  6104. result1 = ":";
  6105. pos++;
  6106. } else {
  6107. result1 = null;
  6108. if (reportFailures === 0) {
  6109. matchFailed("\":\"");
  6110. }
  6111. }
  6112. if (result1 !== null) {
  6113. result2 = parse_h16();
  6114. if (result2 !== null) {
  6115. result1 = [result1, result2];
  6116. } else {
  6117. result1 = null;
  6118. pos = pos2;
  6119. }
  6120. } else {
  6121. result1 = null;
  6122. pos = pos2;
  6123. }
  6124. result1 = result1 !== null ? result1 : "";
  6125. if (result1 !== null) {
  6126. pos2 = pos;
  6127. if (input.charCodeAt(pos) === 58) {
  6128. result2 = ":";
  6129. pos++;
  6130. } else {
  6131. result2 = null;
  6132. if (reportFailures === 0) {
  6133. matchFailed("\":\"");
  6134. }
  6135. }
  6136. if (result2 !== null) {
  6137. result3 = parse_h16();
  6138. if (result3 !== null) {
  6139. result2 = [result2, result3];
  6140. } else {
  6141. result2 = null;
  6142. pos = pos2;
  6143. }
  6144. } else {
  6145. result2 = null;
  6146. pos = pos2;
  6147. }
  6148. result2 = result2 !== null ? result2 : "";
  6149. if (result2 !== null) {
  6150. pos2 = pos;
  6151. if (input.charCodeAt(pos) === 58) {
  6152. result3 = ":";
  6153. pos++;
  6154. } else {
  6155. result3 = null;
  6156. if (reportFailures === 0) {
  6157. matchFailed("\":\"");
  6158. }
  6159. }
  6160. if (result3 !== null) {
  6161. result4 = parse_h16();
  6162. if (result4 !== null) {
  6163. result3 = [result3, result4];
  6164. } else {
  6165. result3 = null;
  6166. pos = pos2;
  6167. }
  6168. } else {
  6169. result3 = null;
  6170. pos = pos2;
  6171. }
  6172. result3 = result3 !== null ? result3 : "";
  6173. if (result3 !== null) {
  6174. pos2 = pos;
  6175. if (input.charCodeAt(pos) === 58) {
  6176. result4 = ":";
  6177. pos++;
  6178. } else {
  6179. result4 = null;
  6180. if (reportFailures === 0) {
  6181. matchFailed("\":\"");
  6182. }
  6183. }
  6184. if (result4 !== null) {
  6185. result5 = parse_h16();
  6186. if (result5 !== null) {
  6187. result4 = [result4, result5];
  6188. } else {
  6189. result4 = null;
  6190. pos = pos2;
  6191. }
  6192. } else {
  6193. result4 = null;
  6194. pos = pos2;
  6195. }
  6196. result4 = result4 !== null ? result4 : "";
  6197. if (result4 !== null) {
  6198. pos2 = pos;
  6199. if (input.charCodeAt(pos) === 58) {
  6200. result5 = ":";
  6201. pos++;
  6202. } else {
  6203. result5 = null;
  6204. if (reportFailures === 0) {
  6205. matchFailed("\":\"");
  6206. }
  6207. }
  6208. if (result5 !== null) {
  6209. result6 = parse_h16();
  6210. if (result6 !== null) {
  6211. result5 = [result5, result6];
  6212. } else {
  6213. result5 = null;
  6214. pos = pos2;
  6215. }
  6216. } else {
  6217. result5 = null;
  6218. pos = pos2;
  6219. }
  6220. result5 = result5 !== null ? result5 : "";
  6221. if (result5 !== null) {
  6222. pos2 = pos;
  6223. if (input.charCodeAt(pos) === 58) {
  6224. result6 = ":";
  6225. pos++;
  6226. } else {
  6227. result6 = null;
  6228. if (reportFailures === 0) {
  6229. matchFailed("\":\"");
  6230. }
  6231. }
  6232. if (result6 !== null) {
  6233. result7 = parse_h16();
  6234. if (result7 !== null) {
  6235. result6 = [result6, result7];
  6236. } else {
  6237. result6 = null;
  6238. pos = pos2;
  6239. }
  6240. } else {
  6241. result6 = null;
  6242. pos = pos2;
  6243. }
  6244. result6 = result6 !== null ? result6 : "";
  6245. if (result6 !== null) {
  6246. if (input.substr(pos, 2) === "::") {
  6247. result7 = "::";
  6248. pos += 2;
  6249. } else {
  6250. result7 = null;
  6251. if (reportFailures === 0) {
  6252. matchFailed("\"::\"");
  6253. }
  6254. }
  6255. if (result7 !== null) {
  6256. result0 = [result0, result1, result2, result3, result4, result5, result6, result7];
  6257. } else {
  6258. result0 = null;
  6259. pos = pos1;
  6260. }
  6261. } else {
  6262. result0 = null;
  6263. pos = pos1;
  6264. }
  6265. } else {
  6266. result0 = null;
  6267. pos = pos1;
  6268. }
  6269. } else {
  6270. result0 = null;
  6271. pos = pos1;
  6272. }
  6273. } else {
  6274. result0 = null;
  6275. pos = pos1;
  6276. }
  6277. } else {
  6278. result0 = null;
  6279. pos = pos1;
  6280. }
  6281. } else {
  6282. result0 = null;
  6283. pos = pos1;
  6284. }
  6285. } else {
  6286. result0 = null;
  6287. pos = pos1;
  6288. }
  6289. }
  6290. }
  6291. }
  6292. }
  6293. }
  6294. }
  6295. }
  6296. }
  6297. }
  6298. }
  6299. }
  6300. }
  6301. }
  6302. }
  6303. if (result0 !== null) {
  6304. result0 = function (offset) {
  6305. data.host_type = 'IPv6';
  6306. return input.substring(pos, offset);
  6307. }(pos0);
  6308. }
  6309. if (result0 === null) {
  6310. pos = pos0;
  6311. }
  6312. return result0;
  6313. }
  6314. function parse_h16() {
  6315. var result0, result1, result2, result3;
  6316. var pos0;
  6317. pos0 = pos;
  6318. result0 = parse_HEXDIG();
  6319. if (result0 !== null) {
  6320. result1 = parse_HEXDIG();
  6321. result1 = result1 !== null ? result1 : "";
  6322. if (result1 !== null) {
  6323. result2 = parse_HEXDIG();
  6324. result2 = result2 !== null ? result2 : "";
  6325. if (result2 !== null) {
  6326. result3 = parse_HEXDIG();
  6327. result3 = result3 !== null ? result3 : "";
  6328. if (result3 !== null) {
  6329. result0 = [result0, result1, result2, result3];
  6330. } else {
  6331. result0 = null;
  6332. pos = pos0;
  6333. }
  6334. } else {
  6335. result0 = null;
  6336. pos = pos0;
  6337. }
  6338. } else {
  6339. result0 = null;
  6340. pos = pos0;
  6341. }
  6342. } else {
  6343. result0 = null;
  6344. pos = pos0;
  6345. }
  6346. return result0;
  6347. }
  6348. function parse_ls32() {
  6349. var result0, result1, result2;
  6350. var pos0;
  6351. pos0 = pos;
  6352. result0 = parse_h16();
  6353. if (result0 !== null) {
  6354. if (input.charCodeAt(pos) === 58) {
  6355. result1 = ":";
  6356. pos++;
  6357. } else {
  6358. result1 = null;
  6359. if (reportFailures === 0) {
  6360. matchFailed("\":\"");
  6361. }
  6362. }
  6363. if (result1 !== null) {
  6364. result2 = parse_h16();
  6365. if (result2 !== null) {
  6366. result0 = [result0, result1, result2];
  6367. } else {
  6368. result0 = null;
  6369. pos = pos0;
  6370. }
  6371. } else {
  6372. result0 = null;
  6373. pos = pos0;
  6374. }
  6375. } else {
  6376. result0 = null;
  6377. pos = pos0;
  6378. }
  6379. if (result0 === null) {
  6380. result0 = parse_IPv4address();
  6381. }
  6382. return result0;
  6383. }
  6384. function parse_IPv4address() {
  6385. var result0, result1, result2, result3, result4, result5, result6;
  6386. var pos0, pos1;
  6387. pos0 = pos;
  6388. pos1 = pos;
  6389. result0 = parse_dec_octet();
  6390. if (result0 !== null) {
  6391. if (input.charCodeAt(pos) === 46) {
  6392. result1 = ".";
  6393. pos++;
  6394. } else {
  6395. result1 = null;
  6396. if (reportFailures === 0) {
  6397. matchFailed("\".\"");
  6398. }
  6399. }
  6400. if (result1 !== null) {
  6401. result2 = parse_dec_octet();
  6402. if (result2 !== null) {
  6403. if (input.charCodeAt(pos) === 46) {
  6404. result3 = ".";
  6405. pos++;
  6406. } else {
  6407. result3 = null;
  6408. if (reportFailures === 0) {
  6409. matchFailed("\".\"");
  6410. }
  6411. }
  6412. if (result3 !== null) {
  6413. result4 = parse_dec_octet();
  6414. if (result4 !== null) {
  6415. if (input.charCodeAt(pos) === 46) {
  6416. result5 = ".";
  6417. pos++;
  6418. } else {
  6419. result5 = null;
  6420. if (reportFailures === 0) {
  6421. matchFailed("\".\"");
  6422. }
  6423. }
  6424. if (result5 !== null) {
  6425. result6 = parse_dec_octet();
  6426. if (result6 !== null) {
  6427. result0 = [result0, result1, result2, result3, result4, result5, result6];
  6428. } else {
  6429. result0 = null;
  6430. pos = pos1;
  6431. }
  6432. } else {
  6433. result0 = null;
  6434. pos = pos1;
  6435. }
  6436. } else {
  6437. result0 = null;
  6438. pos = pos1;
  6439. }
  6440. } else {
  6441. result0 = null;
  6442. pos = pos1;
  6443. }
  6444. } else {
  6445. result0 = null;
  6446. pos = pos1;
  6447. }
  6448. } else {
  6449. result0 = null;
  6450. pos = pos1;
  6451. }
  6452. } else {
  6453. result0 = null;
  6454. pos = pos1;
  6455. }
  6456. if (result0 !== null) {
  6457. result0 = function (offset) {
  6458. data.host_type = 'IPv4';
  6459. return input.substring(pos, offset);
  6460. }(pos0);
  6461. }
  6462. if (result0 === null) {
  6463. pos = pos0;
  6464. }
  6465. return result0;
  6466. }
  6467. function parse_dec_octet() {
  6468. var result0, result1, result2;
  6469. var pos0;
  6470. pos0 = pos;
  6471. if (input.substr(pos, 2) === "25") {
  6472. result0 = "25";
  6473. pos += 2;
  6474. } else {
  6475. result0 = null;
  6476. if (reportFailures === 0) {
  6477. matchFailed("\"25\"");
  6478. }
  6479. }
  6480. if (result0 !== null) {
  6481. if (/^[0-5]/.test(input.charAt(pos))) {
  6482. result1 = input.charAt(pos);
  6483. pos++;
  6484. } else {
  6485. result1 = null;
  6486. if (reportFailures === 0) {
  6487. matchFailed("[0-5]");
  6488. }
  6489. }
  6490. if (result1 !== null) {
  6491. result0 = [result0, result1];
  6492. } else {
  6493. result0 = null;
  6494. pos = pos0;
  6495. }
  6496. } else {
  6497. result0 = null;
  6498. pos = pos0;
  6499. }
  6500. if (result0 === null) {
  6501. pos0 = pos;
  6502. if (input.charCodeAt(pos) === 50) {
  6503. result0 = "2";
  6504. pos++;
  6505. } else {
  6506. result0 = null;
  6507. if (reportFailures === 0) {
  6508. matchFailed("\"2\"");
  6509. }
  6510. }
  6511. if (result0 !== null) {
  6512. if (/^[0-4]/.test(input.charAt(pos))) {
  6513. result1 = input.charAt(pos);
  6514. pos++;
  6515. } else {
  6516. result1 = null;
  6517. if (reportFailures === 0) {
  6518. matchFailed("[0-4]");
  6519. }
  6520. }
  6521. if (result1 !== null) {
  6522. result2 = parse_DIGIT();
  6523. if (result2 !== null) {
  6524. result0 = [result0, result1, result2];
  6525. } else {
  6526. result0 = null;
  6527. pos = pos0;
  6528. }
  6529. } else {
  6530. result0 = null;
  6531. pos = pos0;
  6532. }
  6533. } else {
  6534. result0 = null;
  6535. pos = pos0;
  6536. }
  6537. if (result0 === null) {
  6538. pos0 = pos;
  6539. if (input.charCodeAt(pos) === 49) {
  6540. result0 = "1";
  6541. pos++;
  6542. } else {
  6543. result0 = null;
  6544. if (reportFailures === 0) {
  6545. matchFailed("\"1\"");
  6546. }
  6547. }
  6548. if (result0 !== null) {
  6549. result1 = parse_DIGIT();
  6550. if (result1 !== null) {
  6551. result2 = parse_DIGIT();
  6552. if (result2 !== null) {
  6553. result0 = [result0, result1, result2];
  6554. } else {
  6555. result0 = null;
  6556. pos = pos0;
  6557. }
  6558. } else {
  6559. result0 = null;
  6560. pos = pos0;
  6561. }
  6562. } else {
  6563. result0 = null;
  6564. pos = pos0;
  6565. }
  6566. if (result0 === null) {
  6567. pos0 = pos;
  6568. if (/^[1-9]/.test(input.charAt(pos))) {
  6569. result0 = input.charAt(pos);
  6570. pos++;
  6571. } else {
  6572. result0 = null;
  6573. if (reportFailures === 0) {
  6574. matchFailed("[1-9]");
  6575. }
  6576. }
  6577. if (result0 !== null) {
  6578. result1 = parse_DIGIT();
  6579. if (result1 !== null) {
  6580. result0 = [result0, result1];
  6581. } else {
  6582. result0 = null;
  6583. pos = pos0;
  6584. }
  6585. } else {
  6586. result0 = null;
  6587. pos = pos0;
  6588. }
  6589. if (result0 === null) {
  6590. result0 = parse_DIGIT();
  6591. }
  6592. }
  6593. }
  6594. }
  6595. return result0;
  6596. }
  6597. function parse_port() {
  6598. var result0, result1, result2, result3, result4;
  6599. var pos0, pos1;
  6600. pos0 = pos;
  6601. pos1 = pos;
  6602. result0 = parse_DIGIT();
  6603. result0 = result0 !== null ? result0 : "";
  6604. if (result0 !== null) {
  6605. result1 = parse_DIGIT();
  6606. result1 = result1 !== null ? result1 : "";
  6607. if (result1 !== null) {
  6608. result2 = parse_DIGIT();
  6609. result2 = result2 !== null ? result2 : "";
  6610. if (result2 !== null) {
  6611. result3 = parse_DIGIT();
  6612. result3 = result3 !== null ? result3 : "";
  6613. if (result3 !== null) {
  6614. result4 = parse_DIGIT();
  6615. result4 = result4 !== null ? result4 : "";
  6616. if (result4 !== null) {
  6617. result0 = [result0, result1, result2, result3, result4];
  6618. } else {
  6619. result0 = null;
  6620. pos = pos1;
  6621. }
  6622. } else {
  6623. result0 = null;
  6624. pos = pos1;
  6625. }
  6626. } else {
  6627. result0 = null;
  6628. pos = pos1;
  6629. }
  6630. } else {
  6631. result0 = null;
  6632. pos = pos1;
  6633. }
  6634. } else {
  6635. result0 = null;
  6636. pos = pos1;
  6637. }
  6638. if (result0 !== null) {
  6639. result0 = function (offset, port) {
  6640. port = parseInt(port.join(''));
  6641. data.port = port;
  6642. return port;
  6643. }(pos0, result0);
  6644. }
  6645. if (result0 === null) {
  6646. pos = pos0;
  6647. }
  6648. return result0;
  6649. }
  6650. function parse_uri_parameters() {
  6651. var result0, result1, result2;
  6652. var pos0;
  6653. result0 = [];
  6654. pos0 = pos;
  6655. if (input.charCodeAt(pos) === 59) {
  6656. result1 = ";";
  6657. pos++;
  6658. } else {
  6659. result1 = null;
  6660. if (reportFailures === 0) {
  6661. matchFailed("\";\"");
  6662. }
  6663. }
  6664. if (result1 !== null) {
  6665. result2 = parse_uri_parameter();
  6666. if (result2 !== null) {
  6667. result1 = [result1, result2];
  6668. } else {
  6669. result1 = null;
  6670. pos = pos0;
  6671. }
  6672. } else {
  6673. result1 = null;
  6674. pos = pos0;
  6675. }
  6676. while (result1 !== null) {
  6677. result0.push(result1);
  6678. pos0 = pos;
  6679. if (input.charCodeAt(pos) === 59) {
  6680. result1 = ";";
  6681. pos++;
  6682. } else {
  6683. result1 = null;
  6684. if (reportFailures === 0) {
  6685. matchFailed("\";\"");
  6686. }
  6687. }
  6688. if (result1 !== null) {
  6689. result2 = parse_uri_parameter();
  6690. if (result2 !== null) {
  6691. result1 = [result1, result2];
  6692. } else {
  6693. result1 = null;
  6694. pos = pos0;
  6695. }
  6696. } else {
  6697. result1 = null;
  6698. pos = pos0;
  6699. }
  6700. }
  6701. return result0;
  6702. }
  6703. function parse_uri_parameter() {
  6704. var result0;
  6705. result0 = parse_transport_param();
  6706. if (result0 === null) {
  6707. result0 = parse_user_param();
  6708. if (result0 === null) {
  6709. result0 = parse_method_param();
  6710. if (result0 === null) {
  6711. result0 = parse_ttl_param();
  6712. if (result0 === null) {
  6713. result0 = parse_maddr_param();
  6714. if (result0 === null) {
  6715. result0 = parse_lr_param();
  6716. if (result0 === null) {
  6717. result0 = parse_other_param();
  6718. }
  6719. }
  6720. }
  6721. }
  6722. }
  6723. }
  6724. return result0;
  6725. }
  6726. function parse_transport_param() {
  6727. var result0, result1;
  6728. var pos0, pos1;
  6729. pos0 = pos;
  6730. pos1 = pos;
  6731. if (input.substr(pos, 10).toLowerCase() === "transport=") {
  6732. result0 = input.substr(pos, 10);
  6733. pos += 10;
  6734. } else {
  6735. result0 = null;
  6736. if (reportFailures === 0) {
  6737. matchFailed("\"transport=\"");
  6738. }
  6739. }
  6740. if (result0 !== null) {
  6741. if (input.substr(pos, 3).toLowerCase() === "udp") {
  6742. result1 = input.substr(pos, 3);
  6743. pos += 3;
  6744. } else {
  6745. result1 = null;
  6746. if (reportFailures === 0) {
  6747. matchFailed("\"udp\"");
  6748. }
  6749. }
  6750. if (result1 === null) {
  6751. if (input.substr(pos, 3).toLowerCase() === "tcp") {
  6752. result1 = input.substr(pos, 3);
  6753. pos += 3;
  6754. } else {
  6755. result1 = null;
  6756. if (reportFailures === 0) {
  6757. matchFailed("\"tcp\"");
  6758. }
  6759. }
  6760. if (result1 === null) {
  6761. if (input.substr(pos, 4).toLowerCase() === "sctp") {
  6762. result1 = input.substr(pos, 4);
  6763. pos += 4;
  6764. } else {
  6765. result1 = null;
  6766. if (reportFailures === 0) {
  6767. matchFailed("\"sctp\"");
  6768. }
  6769. }
  6770. if (result1 === null) {
  6771. if (input.substr(pos, 3).toLowerCase() === "tls") {
  6772. result1 = input.substr(pos, 3);
  6773. pos += 3;
  6774. } else {
  6775. result1 = null;
  6776. if (reportFailures === 0) {
  6777. matchFailed("\"tls\"");
  6778. }
  6779. }
  6780. if (result1 === null) {
  6781. result1 = parse_token();
  6782. }
  6783. }
  6784. }
  6785. }
  6786. if (result1 !== null) {
  6787. result0 = [result0, result1];
  6788. } else {
  6789. result0 = null;
  6790. pos = pos1;
  6791. }
  6792. } else {
  6793. result0 = null;
  6794. pos = pos1;
  6795. }
  6796. if (result0 !== null) {
  6797. result0 = function (offset, transport) {
  6798. if (!data.uri_params) data.uri_params = {};
  6799. data.uri_params['transport'] = transport.toLowerCase();
  6800. }(pos0, result0[1]);
  6801. }
  6802. if (result0 === null) {
  6803. pos = pos0;
  6804. }
  6805. return result0;
  6806. }
  6807. function parse_user_param() {
  6808. var result0, result1;
  6809. var pos0, pos1;
  6810. pos0 = pos;
  6811. pos1 = pos;
  6812. if (input.substr(pos, 5).toLowerCase() === "user=") {
  6813. result0 = input.substr(pos, 5);
  6814. pos += 5;
  6815. } else {
  6816. result0 = null;
  6817. if (reportFailures === 0) {
  6818. matchFailed("\"user=\"");
  6819. }
  6820. }
  6821. if (result0 !== null) {
  6822. if (input.substr(pos, 5).toLowerCase() === "phone") {
  6823. result1 = input.substr(pos, 5);
  6824. pos += 5;
  6825. } else {
  6826. result1 = null;
  6827. if (reportFailures === 0) {
  6828. matchFailed("\"phone\"");
  6829. }
  6830. }
  6831. if (result1 === null) {
  6832. if (input.substr(pos, 2).toLowerCase() === "ip") {
  6833. result1 = input.substr(pos, 2);
  6834. pos += 2;
  6835. } else {
  6836. result1 = null;
  6837. if (reportFailures === 0) {
  6838. matchFailed("\"ip\"");
  6839. }
  6840. }
  6841. if (result1 === null) {
  6842. result1 = parse_token();
  6843. }
  6844. }
  6845. if (result1 !== null) {
  6846. result0 = [result0, result1];
  6847. } else {
  6848. result0 = null;
  6849. pos = pos1;
  6850. }
  6851. } else {
  6852. result0 = null;
  6853. pos = pos1;
  6854. }
  6855. if (result0 !== null) {
  6856. result0 = function (offset, user) {
  6857. if (!data.uri_params) data.uri_params = {};
  6858. data.uri_params['user'] = user.toLowerCase();
  6859. }(pos0, result0[1]);
  6860. }
  6861. if (result0 === null) {
  6862. pos = pos0;
  6863. }
  6864. return result0;
  6865. }
  6866. function parse_method_param() {
  6867. var result0, result1;
  6868. var pos0, pos1;
  6869. pos0 = pos;
  6870. pos1 = pos;
  6871. if (input.substr(pos, 7).toLowerCase() === "method=") {
  6872. result0 = input.substr(pos, 7);
  6873. pos += 7;
  6874. } else {
  6875. result0 = null;
  6876. if (reportFailures === 0) {
  6877. matchFailed("\"method=\"");
  6878. }
  6879. }
  6880. if (result0 !== null) {
  6881. result1 = parse_Method();
  6882. if (result1 !== null) {
  6883. result0 = [result0, result1];
  6884. } else {
  6885. result0 = null;
  6886. pos = pos1;
  6887. }
  6888. } else {
  6889. result0 = null;
  6890. pos = pos1;
  6891. }
  6892. if (result0 !== null) {
  6893. result0 = function (offset, method) {
  6894. if (!data.uri_params) data.uri_params = {};
  6895. data.uri_params['method'] = method;
  6896. }(pos0, result0[1]);
  6897. }
  6898. if (result0 === null) {
  6899. pos = pos0;
  6900. }
  6901. return result0;
  6902. }
  6903. function parse_ttl_param() {
  6904. var result0, result1;
  6905. var pos0, pos1;
  6906. pos0 = pos;
  6907. pos1 = pos;
  6908. if (input.substr(pos, 4).toLowerCase() === "ttl=") {
  6909. result0 = input.substr(pos, 4);
  6910. pos += 4;
  6911. } else {
  6912. result0 = null;
  6913. if (reportFailures === 0) {
  6914. matchFailed("\"ttl=\"");
  6915. }
  6916. }
  6917. if (result0 !== null) {
  6918. result1 = parse_ttl();
  6919. if (result1 !== null) {
  6920. result0 = [result0, result1];
  6921. } else {
  6922. result0 = null;
  6923. pos = pos1;
  6924. }
  6925. } else {
  6926. result0 = null;
  6927. pos = pos1;
  6928. }
  6929. if (result0 !== null) {
  6930. result0 = function (offset, ttl) {
  6931. if (!data.params) data.params = {};
  6932. data.params['ttl'] = ttl;
  6933. }(pos0, result0[1]);
  6934. }
  6935. if (result0 === null) {
  6936. pos = pos0;
  6937. }
  6938. return result0;
  6939. }
  6940. function parse_maddr_param() {
  6941. var result0, result1;
  6942. var pos0, pos1;
  6943. pos0 = pos;
  6944. pos1 = pos;
  6945. if (input.substr(pos, 6).toLowerCase() === "maddr=") {
  6946. result0 = input.substr(pos, 6);
  6947. pos += 6;
  6948. } else {
  6949. result0 = null;
  6950. if (reportFailures === 0) {
  6951. matchFailed("\"maddr=\"");
  6952. }
  6953. }
  6954. if (result0 !== null) {
  6955. result1 = parse_host();
  6956. if (result1 !== null) {
  6957. result0 = [result0, result1];
  6958. } else {
  6959. result0 = null;
  6960. pos = pos1;
  6961. }
  6962. } else {
  6963. result0 = null;
  6964. pos = pos1;
  6965. }
  6966. if (result0 !== null) {
  6967. result0 = function (offset, maddr) {
  6968. if (!data.uri_params) data.uri_params = {};
  6969. data.uri_params['maddr'] = maddr;
  6970. }(pos0, result0[1]);
  6971. }
  6972. if (result0 === null) {
  6973. pos = pos0;
  6974. }
  6975. return result0;
  6976. }
  6977. function parse_lr_param() {
  6978. var result0, result1, result2;
  6979. var pos0, pos1, pos2;
  6980. pos0 = pos;
  6981. pos1 = pos;
  6982. if (input.substr(pos, 2).toLowerCase() === "lr") {
  6983. result0 = input.substr(pos, 2);
  6984. pos += 2;
  6985. } else {
  6986. result0 = null;
  6987. if (reportFailures === 0) {
  6988. matchFailed("\"lr\"");
  6989. }
  6990. }
  6991. if (result0 !== null) {
  6992. pos2 = pos;
  6993. if (input.charCodeAt(pos) === 61) {
  6994. result1 = "=";
  6995. pos++;
  6996. } else {
  6997. result1 = null;
  6998. if (reportFailures === 0) {
  6999. matchFailed("\"=\"");
  7000. }
  7001. }
  7002. if (result1 !== null) {
  7003. result2 = parse_token();
  7004. if (result2 !== null) {
  7005. result1 = [result1, result2];
  7006. } else {
  7007. result1 = null;
  7008. pos = pos2;
  7009. }
  7010. } else {
  7011. result1 = null;
  7012. pos = pos2;
  7013. }
  7014. result1 = result1 !== null ? result1 : "";
  7015. if (result1 !== null) {
  7016. result0 = [result0, result1];
  7017. } else {
  7018. result0 = null;
  7019. pos = pos1;
  7020. }
  7021. } else {
  7022. result0 = null;
  7023. pos = pos1;
  7024. }
  7025. if (result0 !== null) {
  7026. result0 = function (offset) {
  7027. if (!data.uri_params) data.uri_params = {};
  7028. data.uri_params['lr'] = undefined;
  7029. }(pos0);
  7030. }
  7031. if (result0 === null) {
  7032. pos = pos0;
  7033. }
  7034. return result0;
  7035. }
  7036. function parse_other_param() {
  7037. var result0, result1, result2;
  7038. var pos0, pos1, pos2;
  7039. pos0 = pos;
  7040. pos1 = pos;
  7041. result0 = parse_pname();
  7042. if (result0 !== null) {
  7043. pos2 = pos;
  7044. if (input.charCodeAt(pos) === 61) {
  7045. result1 = "=";
  7046. pos++;
  7047. } else {
  7048. result1 = null;
  7049. if (reportFailures === 0) {
  7050. matchFailed("\"=\"");
  7051. }
  7052. }
  7053. if (result1 !== null) {
  7054. result2 = parse_pvalue();
  7055. if (result2 !== null) {
  7056. result1 = [result1, result2];
  7057. } else {
  7058. result1 = null;
  7059. pos = pos2;
  7060. }
  7061. } else {
  7062. result1 = null;
  7063. pos = pos2;
  7064. }
  7065. result1 = result1 !== null ? result1 : "";
  7066. if (result1 !== null) {
  7067. result0 = [result0, result1];
  7068. } else {
  7069. result0 = null;
  7070. pos = pos1;
  7071. }
  7072. } else {
  7073. result0 = null;
  7074. pos = pos1;
  7075. }
  7076. if (result0 !== null) {
  7077. result0 = function (offset, param, value) {
  7078. if (!data.uri_params) data.uri_params = {};
  7079. if (typeof value === 'undefined') {
  7080. value = undefined;
  7081. } else {
  7082. value = value[1];
  7083. }
  7084. data.uri_params[param.toLowerCase()] = value;
  7085. }(pos0, result0[0], result0[1]);
  7086. }
  7087. if (result0 === null) {
  7088. pos = pos0;
  7089. }
  7090. return result0;
  7091. }
  7092. function parse_pname() {
  7093. var result0, result1;
  7094. var pos0;
  7095. pos0 = pos;
  7096. result1 = parse_paramchar();
  7097. if (result1 !== null) {
  7098. result0 = [];
  7099. while (result1 !== null) {
  7100. result0.push(result1);
  7101. result1 = parse_paramchar();
  7102. }
  7103. } else {
  7104. result0 = null;
  7105. }
  7106. if (result0 !== null) {
  7107. result0 = function (offset, pname) {
  7108. return pname.join('');
  7109. }(pos0, result0);
  7110. }
  7111. if (result0 === null) {
  7112. pos = pos0;
  7113. }
  7114. return result0;
  7115. }
  7116. function parse_pvalue() {
  7117. var result0, result1;
  7118. var pos0;
  7119. pos0 = pos;
  7120. result1 = parse_paramchar();
  7121. if (result1 !== null) {
  7122. result0 = [];
  7123. while (result1 !== null) {
  7124. result0.push(result1);
  7125. result1 = parse_paramchar();
  7126. }
  7127. } else {
  7128. result0 = null;
  7129. }
  7130. if (result0 !== null) {
  7131. result0 = function (offset, pvalue) {
  7132. return pvalue.join('');
  7133. }(pos0, result0);
  7134. }
  7135. if (result0 === null) {
  7136. pos = pos0;
  7137. }
  7138. return result0;
  7139. }
  7140. function parse_paramchar() {
  7141. var result0;
  7142. result0 = parse_param_unreserved();
  7143. if (result0 === null) {
  7144. result0 = parse_unreserved();
  7145. if (result0 === null) {
  7146. result0 = parse_escaped();
  7147. }
  7148. }
  7149. return result0;
  7150. }
  7151. function parse_param_unreserved() {
  7152. var result0;
  7153. if (input.charCodeAt(pos) === 91) {
  7154. result0 = "[";
  7155. pos++;
  7156. } else {
  7157. result0 = null;
  7158. if (reportFailures === 0) {
  7159. matchFailed("\"[\"");
  7160. }
  7161. }
  7162. if (result0 === null) {
  7163. if (input.charCodeAt(pos) === 93) {
  7164. result0 = "]";
  7165. pos++;
  7166. } else {
  7167. result0 = null;
  7168. if (reportFailures === 0) {
  7169. matchFailed("\"]\"");
  7170. }
  7171. }
  7172. if (result0 === null) {
  7173. if (input.charCodeAt(pos) === 47) {
  7174. result0 = "/";
  7175. pos++;
  7176. } else {
  7177. result0 = null;
  7178. if (reportFailures === 0) {
  7179. matchFailed("\"/\"");
  7180. }
  7181. }
  7182. if (result0 === null) {
  7183. if (input.charCodeAt(pos) === 58) {
  7184. result0 = ":";
  7185. pos++;
  7186. } else {
  7187. result0 = null;
  7188. if (reportFailures === 0) {
  7189. matchFailed("\":\"");
  7190. }
  7191. }
  7192. if (result0 === null) {
  7193. if (input.charCodeAt(pos) === 38) {
  7194. result0 = "&";
  7195. pos++;
  7196. } else {
  7197. result0 = null;
  7198. if (reportFailures === 0) {
  7199. matchFailed("\"&\"");
  7200. }
  7201. }
  7202. if (result0 === null) {
  7203. if (input.charCodeAt(pos) === 43) {
  7204. result0 = "+";
  7205. pos++;
  7206. } else {
  7207. result0 = null;
  7208. if (reportFailures === 0) {
  7209. matchFailed("\"+\"");
  7210. }
  7211. }
  7212. if (result0 === null) {
  7213. if (input.charCodeAt(pos) === 36) {
  7214. result0 = "$";
  7215. pos++;
  7216. } else {
  7217. result0 = null;
  7218. if (reportFailures === 0) {
  7219. matchFailed("\"$\"");
  7220. }
  7221. }
  7222. }
  7223. }
  7224. }
  7225. }
  7226. }
  7227. }
  7228. return result0;
  7229. }
  7230. function parse_headers() {
  7231. var result0, result1, result2, result3, result4;
  7232. var pos0, pos1;
  7233. pos0 = pos;
  7234. if (input.charCodeAt(pos) === 63) {
  7235. result0 = "?";
  7236. pos++;
  7237. } else {
  7238. result0 = null;
  7239. if (reportFailures === 0) {
  7240. matchFailed("\"?\"");
  7241. }
  7242. }
  7243. if (result0 !== null) {
  7244. result1 = parse_header();
  7245. if (result1 !== null) {
  7246. result2 = [];
  7247. pos1 = pos;
  7248. if (input.charCodeAt(pos) === 38) {
  7249. result3 = "&";
  7250. pos++;
  7251. } else {
  7252. result3 = null;
  7253. if (reportFailures === 0) {
  7254. matchFailed("\"&\"");
  7255. }
  7256. }
  7257. if (result3 !== null) {
  7258. result4 = parse_header();
  7259. if (result4 !== null) {
  7260. result3 = [result3, result4];
  7261. } else {
  7262. result3 = null;
  7263. pos = pos1;
  7264. }
  7265. } else {
  7266. result3 = null;
  7267. pos = pos1;
  7268. }
  7269. while (result3 !== null) {
  7270. result2.push(result3);
  7271. pos1 = pos;
  7272. if (input.charCodeAt(pos) === 38) {
  7273. result3 = "&";
  7274. pos++;
  7275. } else {
  7276. result3 = null;
  7277. if (reportFailures === 0) {
  7278. matchFailed("\"&\"");
  7279. }
  7280. }
  7281. if (result3 !== null) {
  7282. result4 = parse_header();
  7283. if (result4 !== null) {
  7284. result3 = [result3, result4];
  7285. } else {
  7286. result3 = null;
  7287. pos = pos1;
  7288. }
  7289. } else {
  7290. result3 = null;
  7291. pos = pos1;
  7292. }
  7293. }
  7294. if (result2 !== null) {
  7295. result0 = [result0, result1, result2];
  7296. } else {
  7297. result0 = null;
  7298. pos = pos0;
  7299. }
  7300. } else {
  7301. result0 = null;
  7302. pos = pos0;
  7303. }
  7304. } else {
  7305. result0 = null;
  7306. pos = pos0;
  7307. }
  7308. return result0;
  7309. }
  7310. function parse_header() {
  7311. var result0, result1, result2;
  7312. var pos0, pos1;
  7313. pos0 = pos;
  7314. pos1 = pos;
  7315. result0 = parse_hname();
  7316. if (result0 !== null) {
  7317. if (input.charCodeAt(pos) === 61) {
  7318. result1 = "=";
  7319. pos++;
  7320. } else {
  7321. result1 = null;
  7322. if (reportFailures === 0) {
  7323. matchFailed("\"=\"");
  7324. }
  7325. }
  7326. if (result1 !== null) {
  7327. result2 = parse_hvalue();
  7328. if (result2 !== null) {
  7329. result0 = [result0, result1, result2];
  7330. } else {
  7331. result0 = null;
  7332. pos = pos1;
  7333. }
  7334. } else {
  7335. result0 = null;
  7336. pos = pos1;
  7337. }
  7338. } else {
  7339. result0 = null;
  7340. pos = pos1;
  7341. }
  7342. if (result0 !== null) {
  7343. result0 = function (offset, hname, hvalue) {
  7344. hname = hname.join('').toLowerCase();
  7345. hvalue = hvalue.join('');
  7346. if (!data.uri_headers) data.uri_headers = {};
  7347. if (!data.uri_headers[hname]) {
  7348. data.uri_headers[hname] = [hvalue];
  7349. } else {
  7350. data.uri_headers[hname].push(hvalue);
  7351. }
  7352. }(pos0, result0[0], result0[2]);
  7353. }
  7354. if (result0 === null) {
  7355. pos = pos0;
  7356. }
  7357. return result0;
  7358. }
  7359. function parse_hname() {
  7360. var result0, result1;
  7361. result1 = parse_hnv_unreserved();
  7362. if (result1 === null) {
  7363. result1 = parse_unreserved();
  7364. if (result1 === null) {
  7365. result1 = parse_escaped();
  7366. }
  7367. }
  7368. if (result1 !== null) {
  7369. result0 = [];
  7370. while (result1 !== null) {
  7371. result0.push(result1);
  7372. result1 = parse_hnv_unreserved();
  7373. if (result1 === null) {
  7374. result1 = parse_unreserved();
  7375. if (result1 === null) {
  7376. result1 = parse_escaped();
  7377. }
  7378. }
  7379. }
  7380. } else {
  7381. result0 = null;
  7382. }
  7383. return result0;
  7384. }
  7385. function parse_hvalue() {
  7386. var result0, result1;
  7387. result0 = [];
  7388. result1 = parse_hnv_unreserved();
  7389. if (result1 === null) {
  7390. result1 = parse_unreserved();
  7391. if (result1 === null) {
  7392. result1 = parse_escaped();
  7393. }
  7394. }
  7395. while (result1 !== null) {
  7396. result0.push(result1);
  7397. result1 = parse_hnv_unreserved();
  7398. if (result1 === null) {
  7399. result1 = parse_unreserved();
  7400. if (result1 === null) {
  7401. result1 = parse_escaped();
  7402. }
  7403. }
  7404. }
  7405. return result0;
  7406. }
  7407. function parse_hnv_unreserved() {
  7408. var result0;
  7409. if (input.charCodeAt(pos) === 91) {
  7410. result0 = "[";
  7411. pos++;
  7412. } else {
  7413. result0 = null;
  7414. if (reportFailures === 0) {
  7415. matchFailed("\"[\"");
  7416. }
  7417. }
  7418. if (result0 === null) {
  7419. if (input.charCodeAt(pos) === 93) {
  7420. result0 = "]";
  7421. pos++;
  7422. } else {
  7423. result0 = null;
  7424. if (reportFailures === 0) {
  7425. matchFailed("\"]\"");
  7426. }
  7427. }
  7428. if (result0 === null) {
  7429. if (input.charCodeAt(pos) === 47) {
  7430. result0 = "/";
  7431. pos++;
  7432. } else {
  7433. result0 = null;
  7434. if (reportFailures === 0) {
  7435. matchFailed("\"/\"");
  7436. }
  7437. }
  7438. if (result0 === null) {
  7439. if (input.charCodeAt(pos) === 63) {
  7440. result0 = "?";
  7441. pos++;
  7442. } else {
  7443. result0 = null;
  7444. if (reportFailures === 0) {
  7445. matchFailed("\"?\"");
  7446. }
  7447. }
  7448. if (result0 === null) {
  7449. if (input.charCodeAt(pos) === 58) {
  7450. result0 = ":";
  7451. pos++;
  7452. } else {
  7453. result0 = null;
  7454. if (reportFailures === 0) {
  7455. matchFailed("\":\"");
  7456. }
  7457. }
  7458. if (result0 === null) {
  7459. if (input.charCodeAt(pos) === 43) {
  7460. result0 = "+";
  7461. pos++;
  7462. } else {
  7463. result0 = null;
  7464. if (reportFailures === 0) {
  7465. matchFailed("\"+\"");
  7466. }
  7467. }
  7468. if (result0 === null) {
  7469. if (input.charCodeAt(pos) === 36) {
  7470. result0 = "$";
  7471. pos++;
  7472. } else {
  7473. result0 = null;
  7474. if (reportFailures === 0) {
  7475. matchFailed("\"$\"");
  7476. }
  7477. }
  7478. }
  7479. }
  7480. }
  7481. }
  7482. }
  7483. }
  7484. return result0;
  7485. }
  7486. function parse_Request_Response() {
  7487. var result0;
  7488. result0 = parse_Status_Line();
  7489. if (result0 === null) {
  7490. result0 = parse_Request_Line();
  7491. }
  7492. return result0;
  7493. }
  7494. function parse_Request_Line() {
  7495. var result0, result1, result2, result3, result4;
  7496. var pos0;
  7497. pos0 = pos;
  7498. result0 = parse_Method();
  7499. if (result0 !== null) {
  7500. result1 = parse_SP();
  7501. if (result1 !== null) {
  7502. result2 = parse_Request_URI();
  7503. if (result2 !== null) {
  7504. result3 = parse_SP();
  7505. if (result3 !== null) {
  7506. result4 = parse_SIP_Version();
  7507. if (result4 !== null) {
  7508. result0 = [result0, result1, result2, result3, result4];
  7509. } else {
  7510. result0 = null;
  7511. pos = pos0;
  7512. }
  7513. } else {
  7514. result0 = null;
  7515. pos = pos0;
  7516. }
  7517. } else {
  7518. result0 = null;
  7519. pos = pos0;
  7520. }
  7521. } else {
  7522. result0 = null;
  7523. pos = pos0;
  7524. }
  7525. } else {
  7526. result0 = null;
  7527. pos = pos0;
  7528. }
  7529. return result0;
  7530. }
  7531. function parse_Request_URI() {
  7532. var result0;
  7533. result0 = parse_SIP_URI();
  7534. if (result0 === null) {
  7535. result0 = parse_absoluteURI();
  7536. }
  7537. return result0;
  7538. }
  7539. function parse_absoluteURI() {
  7540. var result0, result1, result2;
  7541. var pos0;
  7542. pos0 = pos;
  7543. result0 = parse_scheme();
  7544. if (result0 !== null) {
  7545. if (input.charCodeAt(pos) === 58) {
  7546. result1 = ":";
  7547. pos++;
  7548. } else {
  7549. result1 = null;
  7550. if (reportFailures === 0) {
  7551. matchFailed("\":\"");
  7552. }
  7553. }
  7554. if (result1 !== null) {
  7555. result2 = parse_hier_part();
  7556. if (result2 === null) {
  7557. result2 = parse_opaque_part();
  7558. }
  7559. if (result2 !== null) {
  7560. result0 = [result0, result1, result2];
  7561. } else {
  7562. result0 = null;
  7563. pos = pos0;
  7564. }
  7565. } else {
  7566. result0 = null;
  7567. pos = pos0;
  7568. }
  7569. } else {
  7570. result0 = null;
  7571. pos = pos0;
  7572. }
  7573. return result0;
  7574. }
  7575. function parse_hier_part() {
  7576. var result0, result1, result2;
  7577. var pos0, pos1;
  7578. pos0 = pos;
  7579. result0 = parse_net_path();
  7580. if (result0 === null) {
  7581. result0 = parse_abs_path();
  7582. }
  7583. if (result0 !== null) {
  7584. pos1 = pos;
  7585. if (input.charCodeAt(pos) === 63) {
  7586. result1 = "?";
  7587. pos++;
  7588. } else {
  7589. result1 = null;
  7590. if (reportFailures === 0) {
  7591. matchFailed("\"?\"");
  7592. }
  7593. }
  7594. if (result1 !== null) {
  7595. result2 = parse_query();
  7596. if (result2 !== null) {
  7597. result1 = [result1, result2];
  7598. } else {
  7599. result1 = null;
  7600. pos = pos1;
  7601. }
  7602. } else {
  7603. result1 = null;
  7604. pos = pos1;
  7605. }
  7606. result1 = result1 !== null ? result1 : "";
  7607. if (result1 !== null) {
  7608. result0 = [result0, result1];
  7609. } else {
  7610. result0 = null;
  7611. pos = pos0;
  7612. }
  7613. } else {
  7614. result0 = null;
  7615. pos = pos0;
  7616. }
  7617. return result0;
  7618. }
  7619. function parse_net_path() {
  7620. var result0, result1, result2;
  7621. var pos0;
  7622. pos0 = pos;
  7623. if (input.substr(pos, 2) === "//") {
  7624. result0 = "//";
  7625. pos += 2;
  7626. } else {
  7627. result0 = null;
  7628. if (reportFailures === 0) {
  7629. matchFailed("\"//\"");
  7630. }
  7631. }
  7632. if (result0 !== null) {
  7633. result1 = parse_authority();
  7634. if (result1 !== null) {
  7635. result2 = parse_abs_path();
  7636. result2 = result2 !== null ? result2 : "";
  7637. if (result2 !== null) {
  7638. result0 = [result0, result1, result2];
  7639. } else {
  7640. result0 = null;
  7641. pos = pos0;
  7642. }
  7643. } else {
  7644. result0 = null;
  7645. pos = pos0;
  7646. }
  7647. } else {
  7648. result0 = null;
  7649. pos = pos0;
  7650. }
  7651. return result0;
  7652. }
  7653. function parse_abs_path() {
  7654. var result0, result1;
  7655. var pos0;
  7656. pos0 = pos;
  7657. if (input.charCodeAt(pos) === 47) {
  7658. result0 = "/";
  7659. pos++;
  7660. } else {
  7661. result0 = null;
  7662. if (reportFailures === 0) {
  7663. matchFailed("\"/\"");
  7664. }
  7665. }
  7666. if (result0 !== null) {
  7667. result1 = parse_path_segments();
  7668. if (result1 !== null) {
  7669. result0 = [result0, result1];
  7670. } else {
  7671. result0 = null;
  7672. pos = pos0;
  7673. }
  7674. } else {
  7675. result0 = null;
  7676. pos = pos0;
  7677. }
  7678. return result0;
  7679. }
  7680. function parse_opaque_part() {
  7681. var result0, result1, result2;
  7682. var pos0;
  7683. pos0 = pos;
  7684. result0 = parse_uric_no_slash();
  7685. if (result0 !== null) {
  7686. result1 = [];
  7687. result2 = parse_uric();
  7688. while (result2 !== null) {
  7689. result1.push(result2);
  7690. result2 = parse_uric();
  7691. }
  7692. if (result1 !== null) {
  7693. result0 = [result0, result1];
  7694. } else {
  7695. result0 = null;
  7696. pos = pos0;
  7697. }
  7698. } else {
  7699. result0 = null;
  7700. pos = pos0;
  7701. }
  7702. return result0;
  7703. }
  7704. function parse_uric() {
  7705. var result0;
  7706. result0 = parse_reserved();
  7707. if (result0 === null) {
  7708. result0 = parse_unreserved();
  7709. if (result0 === null) {
  7710. result0 = parse_escaped();
  7711. }
  7712. }
  7713. return result0;
  7714. }
  7715. function parse_uric_no_slash() {
  7716. var result0;
  7717. result0 = parse_unreserved();
  7718. if (result0 === null) {
  7719. result0 = parse_escaped();
  7720. if (result0 === null) {
  7721. if (input.charCodeAt(pos) === 59) {
  7722. result0 = ";";
  7723. pos++;
  7724. } else {
  7725. result0 = null;
  7726. if (reportFailures === 0) {
  7727. matchFailed("\";\"");
  7728. }
  7729. }
  7730. if (result0 === null) {
  7731. if (input.charCodeAt(pos) === 63) {
  7732. result0 = "?";
  7733. pos++;
  7734. } else {
  7735. result0 = null;
  7736. if (reportFailures === 0) {
  7737. matchFailed("\"?\"");
  7738. }
  7739. }
  7740. if (result0 === null) {
  7741. if (input.charCodeAt(pos) === 58) {
  7742. result0 = ":";
  7743. pos++;
  7744. } else {
  7745. result0 = null;
  7746. if (reportFailures === 0) {
  7747. matchFailed("\":\"");
  7748. }
  7749. }
  7750. if (result0 === null) {
  7751. if (input.charCodeAt(pos) === 64) {
  7752. result0 = "@";
  7753. pos++;
  7754. } else {
  7755. result0 = null;
  7756. if (reportFailures === 0) {
  7757. matchFailed("\"@\"");
  7758. }
  7759. }
  7760. if (result0 === null) {
  7761. if (input.charCodeAt(pos) === 38) {
  7762. result0 = "&";
  7763. pos++;
  7764. } else {
  7765. result0 = null;
  7766. if (reportFailures === 0) {
  7767. matchFailed("\"&\"");
  7768. }
  7769. }
  7770. if (result0 === null) {
  7771. if (input.charCodeAt(pos) === 61) {
  7772. result0 = "=";
  7773. pos++;
  7774. } else {
  7775. result0 = null;
  7776. if (reportFailures === 0) {
  7777. matchFailed("\"=\"");
  7778. }
  7779. }
  7780. if (result0 === null) {
  7781. if (input.charCodeAt(pos) === 43) {
  7782. result0 = "+";
  7783. pos++;
  7784. } else {
  7785. result0 = null;
  7786. if (reportFailures === 0) {
  7787. matchFailed("\"+\"");
  7788. }
  7789. }
  7790. if (result0 === null) {
  7791. if (input.charCodeAt(pos) === 36) {
  7792. result0 = "$";
  7793. pos++;
  7794. } else {
  7795. result0 = null;
  7796. if (reportFailures === 0) {
  7797. matchFailed("\"$\"");
  7798. }
  7799. }
  7800. if (result0 === null) {
  7801. if (input.charCodeAt(pos) === 44) {
  7802. result0 = ",";
  7803. pos++;
  7804. } else {
  7805. result0 = null;
  7806. if (reportFailures === 0) {
  7807. matchFailed("\",\"");
  7808. }
  7809. }
  7810. }
  7811. }
  7812. }
  7813. }
  7814. }
  7815. }
  7816. }
  7817. }
  7818. }
  7819. }
  7820. return result0;
  7821. }
  7822. function parse_path_segments() {
  7823. var result0, result1, result2, result3;
  7824. var pos0, pos1;
  7825. pos0 = pos;
  7826. result0 = parse_segment();
  7827. if (result0 !== null) {
  7828. result1 = [];
  7829. pos1 = pos;
  7830. if (input.charCodeAt(pos) === 47) {
  7831. result2 = "/";
  7832. pos++;
  7833. } else {
  7834. result2 = null;
  7835. if (reportFailures === 0) {
  7836. matchFailed("\"/\"");
  7837. }
  7838. }
  7839. if (result2 !== null) {
  7840. result3 = parse_segment();
  7841. if (result3 !== null) {
  7842. result2 = [result2, result3];
  7843. } else {
  7844. result2 = null;
  7845. pos = pos1;
  7846. }
  7847. } else {
  7848. result2 = null;
  7849. pos = pos1;
  7850. }
  7851. while (result2 !== null) {
  7852. result1.push(result2);
  7853. pos1 = pos;
  7854. if (input.charCodeAt(pos) === 47) {
  7855. result2 = "/";
  7856. pos++;
  7857. } else {
  7858. result2 = null;
  7859. if (reportFailures === 0) {
  7860. matchFailed("\"/\"");
  7861. }
  7862. }
  7863. if (result2 !== null) {
  7864. result3 = parse_segment();
  7865. if (result3 !== null) {
  7866. result2 = [result2, result3];
  7867. } else {
  7868. result2 = null;
  7869. pos = pos1;
  7870. }
  7871. } else {
  7872. result2 = null;
  7873. pos = pos1;
  7874. }
  7875. }
  7876. if (result1 !== null) {
  7877. result0 = [result0, result1];
  7878. } else {
  7879. result0 = null;
  7880. pos = pos0;
  7881. }
  7882. } else {
  7883. result0 = null;
  7884. pos = pos0;
  7885. }
  7886. return result0;
  7887. }
  7888. function parse_segment() {
  7889. var result0, result1, result2, result3;
  7890. var pos0, pos1;
  7891. pos0 = pos;
  7892. result0 = [];
  7893. result1 = parse_pchar();
  7894. while (result1 !== null) {
  7895. result0.push(result1);
  7896. result1 = parse_pchar();
  7897. }
  7898. if (result0 !== null) {
  7899. result1 = [];
  7900. pos1 = pos;
  7901. if (input.charCodeAt(pos) === 59) {
  7902. result2 = ";";
  7903. pos++;
  7904. } else {
  7905. result2 = null;
  7906. if (reportFailures === 0) {
  7907. matchFailed("\";\"");
  7908. }
  7909. }
  7910. if (result2 !== null) {
  7911. result3 = parse_param();
  7912. if (result3 !== null) {
  7913. result2 = [result2, result3];
  7914. } else {
  7915. result2 = null;
  7916. pos = pos1;
  7917. }
  7918. } else {
  7919. result2 = null;
  7920. pos = pos1;
  7921. }
  7922. while (result2 !== null) {
  7923. result1.push(result2);
  7924. pos1 = pos;
  7925. if (input.charCodeAt(pos) === 59) {
  7926. result2 = ";";
  7927. pos++;
  7928. } else {
  7929. result2 = null;
  7930. if (reportFailures === 0) {
  7931. matchFailed("\";\"");
  7932. }
  7933. }
  7934. if (result2 !== null) {
  7935. result3 = parse_param();
  7936. if (result3 !== null) {
  7937. result2 = [result2, result3];
  7938. } else {
  7939. result2 = null;
  7940. pos = pos1;
  7941. }
  7942. } else {
  7943. result2 = null;
  7944. pos = pos1;
  7945. }
  7946. }
  7947. if (result1 !== null) {
  7948. result0 = [result0, result1];
  7949. } else {
  7950. result0 = null;
  7951. pos = pos0;
  7952. }
  7953. } else {
  7954. result0 = null;
  7955. pos = pos0;
  7956. }
  7957. return result0;
  7958. }
  7959. function parse_param() {
  7960. var result0, result1;
  7961. result0 = [];
  7962. result1 = parse_pchar();
  7963. while (result1 !== null) {
  7964. result0.push(result1);
  7965. result1 = parse_pchar();
  7966. }
  7967. return result0;
  7968. }
  7969. function parse_pchar() {
  7970. var result0;
  7971. result0 = parse_unreserved();
  7972. if (result0 === null) {
  7973. result0 = parse_escaped();
  7974. if (result0 === null) {
  7975. if (input.charCodeAt(pos) === 58) {
  7976. result0 = ":";
  7977. pos++;
  7978. } else {
  7979. result0 = null;
  7980. if (reportFailures === 0) {
  7981. matchFailed("\":\"");
  7982. }
  7983. }
  7984. if (result0 === null) {
  7985. if (input.charCodeAt(pos) === 64) {
  7986. result0 = "@";
  7987. pos++;
  7988. } else {
  7989. result0 = null;
  7990. if (reportFailures === 0) {
  7991. matchFailed("\"@\"");
  7992. }
  7993. }
  7994. if (result0 === null) {
  7995. if (input.charCodeAt(pos) === 38) {
  7996. result0 = "&";
  7997. pos++;
  7998. } else {
  7999. result0 = null;
  8000. if (reportFailures === 0) {
  8001. matchFailed("\"&\"");
  8002. }
  8003. }
  8004. if (result0 === null) {
  8005. if (input.charCodeAt(pos) === 61) {
  8006. result0 = "=";
  8007. pos++;
  8008. } else {
  8009. result0 = null;
  8010. if (reportFailures === 0) {
  8011. matchFailed("\"=\"");
  8012. }
  8013. }
  8014. if (result0 === null) {
  8015. if (input.charCodeAt(pos) === 43) {
  8016. result0 = "+";
  8017. pos++;
  8018. } else {
  8019. result0 = null;
  8020. if (reportFailures === 0) {
  8021. matchFailed("\"+\"");
  8022. }
  8023. }
  8024. if (result0 === null) {
  8025. if (input.charCodeAt(pos) === 36) {
  8026. result0 = "$";
  8027. pos++;
  8028. } else {
  8029. result0 = null;
  8030. if (reportFailures === 0) {
  8031. matchFailed("\"$\"");
  8032. }
  8033. }
  8034. if (result0 === null) {
  8035. if (input.charCodeAt(pos) === 44) {
  8036. result0 = ",";
  8037. pos++;
  8038. } else {
  8039. result0 = null;
  8040. if (reportFailures === 0) {
  8041. matchFailed("\",\"");
  8042. }
  8043. }
  8044. }
  8045. }
  8046. }
  8047. }
  8048. }
  8049. }
  8050. }
  8051. }
  8052. return result0;
  8053. }
  8054. function parse_scheme() {
  8055. var result0, result1, result2;
  8056. var pos0, pos1;
  8057. pos0 = pos;
  8058. pos1 = pos;
  8059. result0 = parse_ALPHA();
  8060. if (result0 !== null) {
  8061. result1 = [];
  8062. result2 = parse_ALPHA();
  8063. if (result2 === null) {
  8064. result2 = parse_DIGIT();
  8065. if (result2 === null) {
  8066. if (input.charCodeAt(pos) === 43) {
  8067. result2 = "+";
  8068. pos++;
  8069. } else {
  8070. result2 = null;
  8071. if (reportFailures === 0) {
  8072. matchFailed("\"+\"");
  8073. }
  8074. }
  8075. if (result2 === null) {
  8076. if (input.charCodeAt(pos) === 45) {
  8077. result2 = "-";
  8078. pos++;
  8079. } else {
  8080. result2 = null;
  8081. if (reportFailures === 0) {
  8082. matchFailed("\"-\"");
  8083. }
  8084. }
  8085. if (result2 === null) {
  8086. if (input.charCodeAt(pos) === 46) {
  8087. result2 = ".";
  8088. pos++;
  8089. } else {
  8090. result2 = null;
  8091. if (reportFailures === 0) {
  8092. matchFailed("\".\"");
  8093. }
  8094. }
  8095. }
  8096. }
  8097. }
  8098. }
  8099. while (result2 !== null) {
  8100. result1.push(result2);
  8101. result2 = parse_ALPHA();
  8102. if (result2 === null) {
  8103. result2 = parse_DIGIT();
  8104. if (result2 === null) {
  8105. if (input.charCodeAt(pos) === 43) {
  8106. result2 = "+";
  8107. pos++;
  8108. } else {
  8109. result2 = null;
  8110. if (reportFailures === 0) {
  8111. matchFailed("\"+\"");
  8112. }
  8113. }
  8114. if (result2 === null) {
  8115. if (input.charCodeAt(pos) === 45) {
  8116. result2 = "-";
  8117. pos++;
  8118. } else {
  8119. result2 = null;
  8120. if (reportFailures === 0) {
  8121. matchFailed("\"-\"");
  8122. }
  8123. }
  8124. if (result2 === null) {
  8125. if (input.charCodeAt(pos) === 46) {
  8126. result2 = ".";
  8127. pos++;
  8128. } else {
  8129. result2 = null;
  8130. if (reportFailures === 0) {
  8131. matchFailed("\".\"");
  8132. }
  8133. }
  8134. }
  8135. }
  8136. }
  8137. }
  8138. }
  8139. if (result1 !== null) {
  8140. result0 = [result0, result1];
  8141. } else {
  8142. result0 = null;
  8143. pos = pos1;
  8144. }
  8145. } else {
  8146. result0 = null;
  8147. pos = pos1;
  8148. }
  8149. if (result0 !== null) {
  8150. result0 = function (offset) {
  8151. data.scheme = input.substring(pos, offset);
  8152. }(pos0);
  8153. }
  8154. if (result0 === null) {
  8155. pos = pos0;
  8156. }
  8157. return result0;
  8158. }
  8159. function parse_authority() {
  8160. var result0;
  8161. result0 = parse_srvr();
  8162. if (result0 === null) {
  8163. result0 = parse_reg_name();
  8164. }
  8165. return result0;
  8166. }
  8167. function parse_srvr() {
  8168. var result0, result1;
  8169. var pos0, pos1;
  8170. pos0 = pos;
  8171. pos1 = pos;
  8172. result0 = parse_userinfo();
  8173. if (result0 !== null) {
  8174. if (input.charCodeAt(pos) === 64) {
  8175. result1 = "@";
  8176. pos++;
  8177. } else {
  8178. result1 = null;
  8179. if (reportFailures === 0) {
  8180. matchFailed("\"@\"");
  8181. }
  8182. }
  8183. if (result1 !== null) {
  8184. result0 = [result0, result1];
  8185. } else {
  8186. result0 = null;
  8187. pos = pos1;
  8188. }
  8189. } else {
  8190. result0 = null;
  8191. pos = pos1;
  8192. }
  8193. result0 = result0 !== null ? result0 : "";
  8194. if (result0 !== null) {
  8195. result1 = parse_hostport();
  8196. if (result1 !== null) {
  8197. result0 = [result0, result1];
  8198. } else {
  8199. result0 = null;
  8200. pos = pos0;
  8201. }
  8202. } else {
  8203. result0 = null;
  8204. pos = pos0;
  8205. }
  8206. result0 = result0 !== null ? result0 : "";
  8207. return result0;
  8208. }
  8209. function parse_reg_name() {
  8210. var result0, result1;
  8211. result1 = parse_unreserved();
  8212. if (result1 === null) {
  8213. result1 = parse_escaped();
  8214. if (result1 === null) {
  8215. if (input.charCodeAt(pos) === 36) {
  8216. result1 = "$";
  8217. pos++;
  8218. } else {
  8219. result1 = null;
  8220. if (reportFailures === 0) {
  8221. matchFailed("\"$\"");
  8222. }
  8223. }
  8224. if (result1 === null) {
  8225. if (input.charCodeAt(pos) === 44) {
  8226. result1 = ",";
  8227. pos++;
  8228. } else {
  8229. result1 = null;
  8230. if (reportFailures === 0) {
  8231. matchFailed("\",\"");
  8232. }
  8233. }
  8234. if (result1 === null) {
  8235. if (input.charCodeAt(pos) === 59) {
  8236. result1 = ";";
  8237. pos++;
  8238. } else {
  8239. result1 = null;
  8240. if (reportFailures === 0) {
  8241. matchFailed("\";\"");
  8242. }
  8243. }
  8244. if (result1 === null) {
  8245. if (input.charCodeAt(pos) === 58) {
  8246. result1 = ":";
  8247. pos++;
  8248. } else {
  8249. result1 = null;
  8250. if (reportFailures === 0) {
  8251. matchFailed("\":\"");
  8252. }
  8253. }
  8254. if (result1 === null) {
  8255. if (input.charCodeAt(pos) === 64) {
  8256. result1 = "@";
  8257. pos++;
  8258. } else {
  8259. result1 = null;
  8260. if (reportFailures === 0) {
  8261. matchFailed("\"@\"");
  8262. }
  8263. }
  8264. if (result1 === null) {
  8265. if (input.charCodeAt(pos) === 38) {
  8266. result1 = "&";
  8267. pos++;
  8268. } else {
  8269. result1 = null;
  8270. if (reportFailures === 0) {
  8271. matchFailed("\"&\"");
  8272. }
  8273. }
  8274. if (result1 === null) {
  8275. if (input.charCodeAt(pos) === 61) {
  8276. result1 = "=";
  8277. pos++;
  8278. } else {
  8279. result1 = null;
  8280. if (reportFailures === 0) {
  8281. matchFailed("\"=\"");
  8282. }
  8283. }
  8284. if (result1 === null) {
  8285. if (input.charCodeAt(pos) === 43) {
  8286. result1 = "+";
  8287. pos++;
  8288. } else {
  8289. result1 = null;
  8290. if (reportFailures === 0) {
  8291. matchFailed("\"+\"");
  8292. }
  8293. }
  8294. }
  8295. }
  8296. }
  8297. }
  8298. }
  8299. }
  8300. }
  8301. }
  8302. }
  8303. if (result1 !== null) {
  8304. result0 = [];
  8305. while (result1 !== null) {
  8306. result0.push(result1);
  8307. result1 = parse_unreserved();
  8308. if (result1 === null) {
  8309. result1 = parse_escaped();
  8310. if (result1 === null) {
  8311. if (input.charCodeAt(pos) === 36) {
  8312. result1 = "$";
  8313. pos++;
  8314. } else {
  8315. result1 = null;
  8316. if (reportFailures === 0) {
  8317. matchFailed("\"$\"");
  8318. }
  8319. }
  8320. if (result1 === null) {
  8321. if (input.charCodeAt(pos) === 44) {
  8322. result1 = ",";
  8323. pos++;
  8324. } else {
  8325. result1 = null;
  8326. if (reportFailures === 0) {
  8327. matchFailed("\",\"");
  8328. }
  8329. }
  8330. if (result1 === null) {
  8331. if (input.charCodeAt(pos) === 59) {
  8332. result1 = ";";
  8333. pos++;
  8334. } else {
  8335. result1 = null;
  8336. if (reportFailures === 0) {
  8337. matchFailed("\";\"");
  8338. }
  8339. }
  8340. if (result1 === null) {
  8341. if (input.charCodeAt(pos) === 58) {
  8342. result1 = ":";
  8343. pos++;
  8344. } else {
  8345. result1 = null;
  8346. if (reportFailures === 0) {
  8347. matchFailed("\":\"");
  8348. }
  8349. }
  8350. if (result1 === null) {
  8351. if (input.charCodeAt(pos) === 64) {
  8352. result1 = "@";
  8353. pos++;
  8354. } else {
  8355. result1 = null;
  8356. if (reportFailures === 0) {
  8357. matchFailed("\"@\"");
  8358. }
  8359. }
  8360. if (result1 === null) {
  8361. if (input.charCodeAt(pos) === 38) {
  8362. result1 = "&";
  8363. pos++;
  8364. } else {
  8365. result1 = null;
  8366. if (reportFailures === 0) {
  8367. matchFailed("\"&\"");
  8368. }
  8369. }
  8370. if (result1 === null) {
  8371. if (input.charCodeAt(pos) === 61) {
  8372. result1 = "=";
  8373. pos++;
  8374. } else {
  8375. result1 = null;
  8376. if (reportFailures === 0) {
  8377. matchFailed("\"=\"");
  8378. }
  8379. }
  8380. if (result1 === null) {
  8381. if (input.charCodeAt(pos) === 43) {
  8382. result1 = "+";
  8383. pos++;
  8384. } else {
  8385. result1 = null;
  8386. if (reportFailures === 0) {
  8387. matchFailed("\"+\"");
  8388. }
  8389. }
  8390. }
  8391. }
  8392. }
  8393. }
  8394. }
  8395. }
  8396. }
  8397. }
  8398. }
  8399. }
  8400. } else {
  8401. result0 = null;
  8402. }
  8403. return result0;
  8404. }
  8405. function parse_query() {
  8406. var result0, result1;
  8407. result0 = [];
  8408. result1 = parse_uric();
  8409. while (result1 !== null) {
  8410. result0.push(result1);
  8411. result1 = parse_uric();
  8412. }
  8413. return result0;
  8414. }
  8415. function parse_SIP_Version() {
  8416. var result0, result1, result2, result3, result4, result5;
  8417. var pos0, pos1;
  8418. pos0 = pos;
  8419. pos1 = pos;
  8420. if (input.substr(pos, 3).toLowerCase() === "sip") {
  8421. result0 = input.substr(pos, 3);
  8422. pos += 3;
  8423. } else {
  8424. result0 = null;
  8425. if (reportFailures === 0) {
  8426. matchFailed("\"SIP\"");
  8427. }
  8428. }
  8429. if (result0 !== null) {
  8430. if (input.charCodeAt(pos) === 47) {
  8431. result1 = "/";
  8432. pos++;
  8433. } else {
  8434. result1 = null;
  8435. if (reportFailures === 0) {
  8436. matchFailed("\"/\"");
  8437. }
  8438. }
  8439. if (result1 !== null) {
  8440. result3 = parse_DIGIT();
  8441. if (result3 !== null) {
  8442. result2 = [];
  8443. while (result3 !== null) {
  8444. result2.push(result3);
  8445. result3 = parse_DIGIT();
  8446. }
  8447. } else {
  8448. result2 = null;
  8449. }
  8450. if (result2 !== null) {
  8451. if (input.charCodeAt(pos) === 46) {
  8452. result3 = ".";
  8453. pos++;
  8454. } else {
  8455. result3 = null;
  8456. if (reportFailures === 0) {
  8457. matchFailed("\".\"");
  8458. }
  8459. }
  8460. if (result3 !== null) {
  8461. result5 = parse_DIGIT();
  8462. if (result5 !== null) {
  8463. result4 = [];
  8464. while (result5 !== null) {
  8465. result4.push(result5);
  8466. result5 = parse_DIGIT();
  8467. }
  8468. } else {
  8469. result4 = null;
  8470. }
  8471. if (result4 !== null) {
  8472. result0 = [result0, result1, result2, result3, result4];
  8473. } else {
  8474. result0 = null;
  8475. pos = pos1;
  8476. }
  8477. } else {
  8478. result0 = null;
  8479. pos = pos1;
  8480. }
  8481. } else {
  8482. result0 = null;
  8483. pos = pos1;
  8484. }
  8485. } else {
  8486. result0 = null;
  8487. pos = pos1;
  8488. }
  8489. } else {
  8490. result0 = null;
  8491. pos = pos1;
  8492. }
  8493. if (result0 !== null) {
  8494. result0 = function (offset) {
  8495. data.sip_version = input.substring(pos, offset);
  8496. }(pos0);
  8497. }
  8498. if (result0 === null) {
  8499. pos = pos0;
  8500. }
  8501. return result0;
  8502. }
  8503. function parse_INVITEm() {
  8504. var result0;
  8505. if (input.substr(pos, 6) === "INVITE") {
  8506. result0 = "INVITE";
  8507. pos += 6;
  8508. } else {
  8509. result0 = null;
  8510. if (reportFailures === 0) {
  8511. matchFailed("\"INVITE\"");
  8512. }
  8513. }
  8514. return result0;
  8515. }
  8516. function parse_ACKm() {
  8517. var result0;
  8518. if (input.substr(pos, 3) === "ACK") {
  8519. result0 = "ACK";
  8520. pos += 3;
  8521. } else {
  8522. result0 = null;
  8523. if (reportFailures === 0) {
  8524. matchFailed("\"ACK\"");
  8525. }
  8526. }
  8527. return result0;
  8528. }
  8529. function parse_OPTIONSm() {
  8530. var result0;
  8531. if (input.substr(pos, 7) === "OPTIONS") {
  8532. result0 = "OPTIONS";
  8533. pos += 7;
  8534. } else {
  8535. result0 = null;
  8536. if (reportFailures === 0) {
  8537. matchFailed("\"OPTIONS\"");
  8538. }
  8539. }
  8540. return result0;
  8541. }
  8542. function parse_BYEm() {
  8543. var result0;
  8544. if (input.substr(pos, 3) === "BYE") {
  8545. result0 = "BYE";
  8546. pos += 3;
  8547. } else {
  8548. result0 = null;
  8549. if (reportFailures === 0) {
  8550. matchFailed("\"BYE\"");
  8551. }
  8552. }
  8553. return result0;
  8554. }
  8555. function parse_CANCELm() {
  8556. var result0;
  8557. if (input.substr(pos, 6) === "CANCEL") {
  8558. result0 = "CANCEL";
  8559. pos += 6;
  8560. } else {
  8561. result0 = null;
  8562. if (reportFailures === 0) {
  8563. matchFailed("\"CANCEL\"");
  8564. }
  8565. }
  8566. return result0;
  8567. }
  8568. function parse_REGISTERm() {
  8569. var result0;
  8570. if (input.substr(pos, 8) === "REGISTER") {
  8571. result0 = "REGISTER";
  8572. pos += 8;
  8573. } else {
  8574. result0 = null;
  8575. if (reportFailures === 0) {
  8576. matchFailed("\"REGISTER\"");
  8577. }
  8578. }
  8579. return result0;
  8580. }
  8581. function parse_SUBSCRIBEm() {
  8582. var result0;
  8583. if (input.substr(pos, 9) === "SUBSCRIBE") {
  8584. result0 = "SUBSCRIBE";
  8585. pos += 9;
  8586. } else {
  8587. result0 = null;
  8588. if (reportFailures === 0) {
  8589. matchFailed("\"SUBSCRIBE\"");
  8590. }
  8591. }
  8592. return result0;
  8593. }
  8594. function parse_NOTIFYm() {
  8595. var result0;
  8596. if (input.substr(pos, 6) === "NOTIFY") {
  8597. result0 = "NOTIFY";
  8598. pos += 6;
  8599. } else {
  8600. result0 = null;
  8601. if (reportFailures === 0) {
  8602. matchFailed("\"NOTIFY\"");
  8603. }
  8604. }
  8605. return result0;
  8606. }
  8607. function parse_REFERm() {
  8608. var result0;
  8609. if (input.substr(pos, 5) === "REFER") {
  8610. result0 = "REFER";
  8611. pos += 5;
  8612. } else {
  8613. result0 = null;
  8614. if (reportFailures === 0) {
  8615. matchFailed("\"REFER\"");
  8616. }
  8617. }
  8618. return result0;
  8619. }
  8620. function parse_Method() {
  8621. var result0;
  8622. var pos0;
  8623. pos0 = pos;
  8624. result0 = parse_INVITEm();
  8625. if (result0 === null) {
  8626. result0 = parse_ACKm();
  8627. if (result0 === null) {
  8628. result0 = parse_OPTIONSm();
  8629. if (result0 === null) {
  8630. result0 = parse_BYEm();
  8631. if (result0 === null) {
  8632. result0 = parse_CANCELm();
  8633. if (result0 === null) {
  8634. result0 = parse_REGISTERm();
  8635. if (result0 === null) {
  8636. result0 = parse_SUBSCRIBEm();
  8637. if (result0 === null) {
  8638. result0 = parse_NOTIFYm();
  8639. if (result0 === null) {
  8640. result0 = parse_REFERm();
  8641. if (result0 === null) {
  8642. result0 = parse_token();
  8643. }
  8644. }
  8645. }
  8646. }
  8647. }
  8648. }
  8649. }
  8650. }
  8651. }
  8652. if (result0 !== null) {
  8653. result0 = function (offset) {
  8654. data.method = input.substring(pos, offset);
  8655. return data.method;
  8656. }(pos0);
  8657. }
  8658. if (result0 === null) {
  8659. pos = pos0;
  8660. }
  8661. return result0;
  8662. }
  8663. function parse_Status_Line() {
  8664. var result0, result1, result2, result3, result4;
  8665. var pos0;
  8666. pos0 = pos;
  8667. result0 = parse_SIP_Version();
  8668. if (result0 !== null) {
  8669. result1 = parse_SP();
  8670. if (result1 !== null) {
  8671. result2 = parse_Status_Code();
  8672. if (result2 !== null) {
  8673. result3 = parse_SP();
  8674. if (result3 !== null) {
  8675. result4 = parse_Reason_Phrase();
  8676. if (result4 !== null) {
  8677. result0 = [result0, result1, result2, result3, result4];
  8678. } else {
  8679. result0 = null;
  8680. pos = pos0;
  8681. }
  8682. } else {
  8683. result0 = null;
  8684. pos = pos0;
  8685. }
  8686. } else {
  8687. result0 = null;
  8688. pos = pos0;
  8689. }
  8690. } else {
  8691. result0 = null;
  8692. pos = pos0;
  8693. }
  8694. } else {
  8695. result0 = null;
  8696. pos = pos0;
  8697. }
  8698. return result0;
  8699. }
  8700. function parse_Status_Code() {
  8701. var result0;
  8702. var pos0;
  8703. pos0 = pos;
  8704. result0 = parse_extension_code();
  8705. if (result0 !== null) {
  8706. result0 = function (offset, status_code) {
  8707. data.status_code = parseInt(status_code.join(''));
  8708. }(pos0, result0);
  8709. }
  8710. if (result0 === null) {
  8711. pos = pos0;
  8712. }
  8713. return result0;
  8714. }
  8715. function parse_extension_code() {
  8716. var result0, result1, result2;
  8717. var pos0;
  8718. pos0 = pos;
  8719. result0 = parse_DIGIT();
  8720. if (result0 !== null) {
  8721. result1 = parse_DIGIT();
  8722. if (result1 !== null) {
  8723. result2 = parse_DIGIT();
  8724. if (result2 !== null) {
  8725. result0 = [result0, result1, result2];
  8726. } else {
  8727. result0 = null;
  8728. pos = pos0;
  8729. }
  8730. } else {
  8731. result0 = null;
  8732. pos = pos0;
  8733. }
  8734. } else {
  8735. result0 = null;
  8736. pos = pos0;
  8737. }
  8738. return result0;
  8739. }
  8740. function parse_Reason_Phrase() {
  8741. var result0, result1;
  8742. var pos0;
  8743. pos0 = pos;
  8744. result0 = [];
  8745. result1 = parse_reserved();
  8746. if (result1 === null) {
  8747. result1 = parse_unreserved();
  8748. if (result1 === null) {
  8749. result1 = parse_escaped();
  8750. if (result1 === null) {
  8751. result1 = parse_UTF8_NONASCII();
  8752. if (result1 === null) {
  8753. result1 = parse_UTF8_CONT();
  8754. if (result1 === null) {
  8755. result1 = parse_SP();
  8756. if (result1 === null) {
  8757. result1 = parse_HTAB();
  8758. }
  8759. }
  8760. }
  8761. }
  8762. }
  8763. }
  8764. while (result1 !== null) {
  8765. result0.push(result1);
  8766. result1 = parse_reserved();
  8767. if (result1 === null) {
  8768. result1 = parse_unreserved();
  8769. if (result1 === null) {
  8770. result1 = parse_escaped();
  8771. if (result1 === null) {
  8772. result1 = parse_UTF8_NONASCII();
  8773. if (result1 === null) {
  8774. result1 = parse_UTF8_CONT();
  8775. if (result1 === null) {
  8776. result1 = parse_SP();
  8777. if (result1 === null) {
  8778. result1 = parse_HTAB();
  8779. }
  8780. }
  8781. }
  8782. }
  8783. }
  8784. }
  8785. }
  8786. if (result0 !== null) {
  8787. result0 = function (offset) {
  8788. data.reason_phrase = input.substring(pos, offset);
  8789. }(pos0);
  8790. }
  8791. if (result0 === null) {
  8792. pos = pos0;
  8793. }
  8794. return result0;
  8795. }
  8796. function parse_Allow_Events() {
  8797. var result0, result1, result2, result3;
  8798. var pos0, pos1;
  8799. pos0 = pos;
  8800. result0 = parse_event_type();
  8801. if (result0 !== null) {
  8802. result1 = [];
  8803. pos1 = pos;
  8804. result2 = parse_COMMA();
  8805. if (result2 !== null) {
  8806. result3 = parse_event_type();
  8807. if (result3 !== null) {
  8808. result2 = [result2, result3];
  8809. } else {
  8810. result2 = null;
  8811. pos = pos1;
  8812. }
  8813. } else {
  8814. result2 = null;
  8815. pos = pos1;
  8816. }
  8817. while (result2 !== null) {
  8818. result1.push(result2);
  8819. pos1 = pos;
  8820. result2 = parse_COMMA();
  8821. if (result2 !== null) {
  8822. result3 = parse_event_type();
  8823. if (result3 !== null) {
  8824. result2 = [result2, result3];
  8825. } else {
  8826. result2 = null;
  8827. pos = pos1;
  8828. }
  8829. } else {
  8830. result2 = null;
  8831. pos = pos1;
  8832. }
  8833. }
  8834. if (result1 !== null) {
  8835. result0 = [result0, result1];
  8836. } else {
  8837. result0 = null;
  8838. pos = pos0;
  8839. }
  8840. } else {
  8841. result0 = null;
  8842. pos = pos0;
  8843. }
  8844. return result0;
  8845. }
  8846. function parse_Call_ID() {
  8847. var result0, result1, result2;
  8848. var pos0, pos1, pos2;
  8849. pos0 = pos;
  8850. pos1 = pos;
  8851. result0 = parse_word();
  8852. if (result0 !== null) {
  8853. pos2 = pos;
  8854. if (input.charCodeAt(pos) === 64) {
  8855. result1 = "@";
  8856. pos++;
  8857. } else {
  8858. result1 = null;
  8859. if (reportFailures === 0) {
  8860. matchFailed("\"@\"");
  8861. }
  8862. }
  8863. if (result1 !== null) {
  8864. result2 = parse_word();
  8865. if (result2 !== null) {
  8866. result1 = [result1, result2];
  8867. } else {
  8868. result1 = null;
  8869. pos = pos2;
  8870. }
  8871. } else {
  8872. result1 = null;
  8873. pos = pos2;
  8874. }
  8875. result1 = result1 !== null ? result1 : "";
  8876. if (result1 !== null) {
  8877. result0 = [result0, result1];
  8878. } else {
  8879. result0 = null;
  8880. pos = pos1;
  8881. }
  8882. } else {
  8883. result0 = null;
  8884. pos = pos1;
  8885. }
  8886. if (result0 !== null) {
  8887. result0 = function (offset) {
  8888. data = input.substring(pos, offset);
  8889. }(pos0);
  8890. }
  8891. if (result0 === null) {
  8892. pos = pos0;
  8893. }
  8894. return result0;
  8895. }
  8896. function parse_Contact() {
  8897. var result0, result1, result2, result3;
  8898. var pos0, pos1, pos2;
  8899. pos0 = pos;
  8900. result0 = parse_STAR();
  8901. if (result0 === null) {
  8902. pos1 = pos;
  8903. result0 = parse_contact_param();
  8904. if (result0 !== null) {
  8905. result1 = [];
  8906. pos2 = pos;
  8907. result2 = parse_COMMA();
  8908. if (result2 !== null) {
  8909. result3 = parse_contact_param();
  8910. if (result3 !== null) {
  8911. result2 = [result2, result3];
  8912. } else {
  8913. result2 = null;
  8914. pos = pos2;
  8915. }
  8916. } else {
  8917. result2 = null;
  8918. pos = pos2;
  8919. }
  8920. while (result2 !== null) {
  8921. result1.push(result2);
  8922. pos2 = pos;
  8923. result2 = parse_COMMA();
  8924. if (result2 !== null) {
  8925. result3 = parse_contact_param();
  8926. if (result3 !== null) {
  8927. result2 = [result2, result3];
  8928. } else {
  8929. result2 = null;
  8930. pos = pos2;
  8931. }
  8932. } else {
  8933. result2 = null;
  8934. pos = pos2;
  8935. }
  8936. }
  8937. if (result1 !== null) {
  8938. result0 = [result0, result1];
  8939. } else {
  8940. result0 = null;
  8941. pos = pos1;
  8942. }
  8943. } else {
  8944. result0 = null;
  8945. pos = pos1;
  8946. }
  8947. }
  8948. if (result0 !== null) {
  8949. result0 = function (offset) {
  8950. var idx, length;
  8951. length = data.multi_header.length;
  8952. for (idx = 0; idx < length; idx++) {
  8953. if (data.multi_header[idx].parsed === null) {
  8954. data = null;
  8955. break;
  8956. }
  8957. }
  8958. if (data !== null) {
  8959. data = data.multi_header;
  8960. } else {
  8961. data = -1;
  8962. }
  8963. }(pos0);
  8964. }
  8965. if (result0 === null) {
  8966. pos = pos0;
  8967. }
  8968. return result0;
  8969. }
  8970. function parse_contact_param() {
  8971. var result0, result1, result2, result3;
  8972. var pos0, pos1, pos2;
  8973. pos0 = pos;
  8974. pos1 = pos;
  8975. result0 = parse_SIP_URI_noparams();
  8976. if (result0 === null) {
  8977. result0 = parse_name_addr();
  8978. }
  8979. if (result0 !== null) {
  8980. result1 = [];
  8981. pos2 = pos;
  8982. result2 = parse_SEMI();
  8983. if (result2 !== null) {
  8984. result3 = parse_contact_params();
  8985. if (result3 !== null) {
  8986. result2 = [result2, result3];
  8987. } else {
  8988. result2 = null;
  8989. pos = pos2;
  8990. }
  8991. } else {
  8992. result2 = null;
  8993. pos = pos2;
  8994. }
  8995. while (result2 !== null) {
  8996. result1.push(result2);
  8997. pos2 = pos;
  8998. result2 = parse_SEMI();
  8999. if (result2 !== null) {
  9000. result3 = parse_contact_params();
  9001. if (result3 !== null) {
  9002. result2 = [result2, result3];
  9003. } else {
  9004. result2 = null;
  9005. pos = pos2;
  9006. }
  9007. } else {
  9008. result2 = null;
  9009. pos = pos2;
  9010. }
  9011. }
  9012. if (result1 !== null) {
  9013. result0 = [result0, result1];
  9014. } else {
  9015. result0 = null;
  9016. pos = pos1;
  9017. }
  9018. } else {
  9019. result0 = null;
  9020. pos = pos1;
  9021. }
  9022. if (result0 !== null) {
  9023. result0 = function (offset) {
  9024. var header;
  9025. if (!data.multi_header) data.multi_header = [];
  9026. try {
  9027. header = new NameAddrHeader(data.uri, data.display_name, data.params);
  9028. delete data.uri;
  9029. delete data.display_name;
  9030. delete data.params;
  9031. } catch (e) {
  9032. header = null;
  9033. }
  9034. data.multi_header.push({
  9035. 'possition': pos,
  9036. 'offset': offset,
  9037. 'parsed': header
  9038. });
  9039. }(pos0);
  9040. }
  9041. if (result0 === null) {
  9042. pos = pos0;
  9043. }
  9044. return result0;
  9045. }
  9046. function parse_name_addr() {
  9047. var result0, result1, result2, result3;
  9048. var pos0;
  9049. pos0 = pos;
  9050. result0 = parse_display_name();
  9051. result0 = result0 !== null ? result0 : "";
  9052. if (result0 !== null) {
  9053. result1 = parse_LAQUOT();
  9054. if (result1 !== null) {
  9055. result2 = parse_SIP_URI();
  9056. if (result2 !== null) {
  9057. result3 = parse_RAQUOT();
  9058. if (result3 !== null) {
  9059. result0 = [result0, result1, result2, result3];
  9060. } else {
  9061. result0 = null;
  9062. pos = pos0;
  9063. }
  9064. } else {
  9065. result0 = null;
  9066. pos = pos0;
  9067. }
  9068. } else {
  9069. result0 = null;
  9070. pos = pos0;
  9071. }
  9072. } else {
  9073. result0 = null;
  9074. pos = pos0;
  9075. }
  9076. return result0;
  9077. }
  9078. function parse_display_name() {
  9079. var result0, result1, result2, result3;
  9080. var pos0, pos1, pos2;
  9081. pos0 = pos;
  9082. pos1 = pos;
  9083. result0 = parse_token();
  9084. if (result0 !== null) {
  9085. result1 = [];
  9086. pos2 = pos;
  9087. result2 = parse_LWS();
  9088. if (result2 !== null) {
  9089. result3 = parse_token();
  9090. if (result3 !== null) {
  9091. result2 = [result2, result3];
  9092. } else {
  9093. result2 = null;
  9094. pos = pos2;
  9095. }
  9096. } else {
  9097. result2 = null;
  9098. pos = pos2;
  9099. }
  9100. while (result2 !== null) {
  9101. result1.push(result2);
  9102. pos2 = pos;
  9103. result2 = parse_LWS();
  9104. if (result2 !== null) {
  9105. result3 = parse_token();
  9106. if (result3 !== null) {
  9107. result2 = [result2, result3];
  9108. } else {
  9109. result2 = null;
  9110. pos = pos2;
  9111. }
  9112. } else {
  9113. result2 = null;
  9114. pos = pos2;
  9115. }
  9116. }
  9117. if (result1 !== null) {
  9118. result0 = [result0, result1];
  9119. } else {
  9120. result0 = null;
  9121. pos = pos1;
  9122. }
  9123. } else {
  9124. result0 = null;
  9125. pos = pos1;
  9126. }
  9127. if (result0 === null) {
  9128. result0 = parse_quoted_string_clean();
  9129. }
  9130. if (result0 !== null) {
  9131. result0 = function (offset, display_name) {
  9132. if (typeof display_name === 'string') {
  9133. // quoted_string_clean
  9134. data.display_name = display_name;
  9135. } else {
  9136. // token ( LWS token )*
  9137. data.display_name = display_name[1].reduce(function (acc, cur) {
  9138. return acc + cur[0] + cur[1];
  9139. }, display_name[0]);
  9140. }
  9141. }(pos0, result0);
  9142. }
  9143. if (result0 === null) {
  9144. pos = pos0;
  9145. }
  9146. return result0;
  9147. }
  9148. function parse_contact_params() {
  9149. var result0;
  9150. result0 = parse_c_p_q();
  9151. if (result0 === null) {
  9152. result0 = parse_c_p_expires();
  9153. if (result0 === null) {
  9154. result0 = parse_generic_param();
  9155. }
  9156. }
  9157. return result0;
  9158. }
  9159. function parse_c_p_q() {
  9160. var result0, result1, result2;
  9161. var pos0, pos1;
  9162. pos0 = pos;
  9163. pos1 = pos;
  9164. if (input.substr(pos, 1).toLowerCase() === "q") {
  9165. result0 = input.substr(pos, 1);
  9166. pos++;
  9167. } else {
  9168. result0 = null;
  9169. if (reportFailures === 0) {
  9170. matchFailed("\"q\"");
  9171. }
  9172. }
  9173. if (result0 !== null) {
  9174. result1 = parse_EQUAL();
  9175. if (result1 !== null) {
  9176. result2 = parse_qvalue();
  9177. if (result2 !== null) {
  9178. result0 = [result0, result1, result2];
  9179. } else {
  9180. result0 = null;
  9181. pos = pos1;
  9182. }
  9183. } else {
  9184. result0 = null;
  9185. pos = pos1;
  9186. }
  9187. } else {
  9188. result0 = null;
  9189. pos = pos1;
  9190. }
  9191. if (result0 !== null) {
  9192. result0 = function (offset, q) {
  9193. if (!data.params) data.params = {};
  9194. data.params['q'] = q;
  9195. }(pos0, result0[2]);
  9196. }
  9197. if (result0 === null) {
  9198. pos = pos0;
  9199. }
  9200. return result0;
  9201. }
  9202. function parse_c_p_expires() {
  9203. var result0, result1, result2;
  9204. var pos0, pos1;
  9205. pos0 = pos;
  9206. pos1 = pos;
  9207. if (input.substr(pos, 7).toLowerCase() === "expires") {
  9208. result0 = input.substr(pos, 7);
  9209. pos += 7;
  9210. } else {
  9211. result0 = null;
  9212. if (reportFailures === 0) {
  9213. matchFailed("\"expires\"");
  9214. }
  9215. }
  9216. if (result0 !== null) {
  9217. result1 = parse_EQUAL();
  9218. if (result1 !== null) {
  9219. result2 = parse_delta_seconds();
  9220. if (result2 !== null) {
  9221. result0 = [result0, result1, result2];
  9222. } else {
  9223. result0 = null;
  9224. pos = pos1;
  9225. }
  9226. } else {
  9227. result0 = null;
  9228. pos = pos1;
  9229. }
  9230. } else {
  9231. result0 = null;
  9232. pos = pos1;
  9233. }
  9234. if (result0 !== null) {
  9235. result0 = function (offset, expires) {
  9236. if (!data.params) data.params = {};
  9237. data.params['expires'] = expires;
  9238. }(pos0, result0[2]);
  9239. }
  9240. if (result0 === null) {
  9241. pos = pos0;
  9242. }
  9243. return result0;
  9244. }
  9245. function parse_delta_seconds() {
  9246. var result0, result1;
  9247. var pos0;
  9248. pos0 = pos;
  9249. result1 = parse_DIGIT();
  9250. if (result1 !== null) {
  9251. result0 = [];
  9252. while (result1 !== null) {
  9253. result0.push(result1);
  9254. result1 = parse_DIGIT();
  9255. }
  9256. } else {
  9257. result0 = null;
  9258. }
  9259. if (result0 !== null) {
  9260. result0 = function (offset, delta_seconds) {
  9261. return parseInt(delta_seconds.join(''));
  9262. }(pos0, result0);
  9263. }
  9264. if (result0 === null) {
  9265. pos = pos0;
  9266. }
  9267. return result0;
  9268. }
  9269. function parse_qvalue() {
  9270. var result0, result1, result2, result3, result4;
  9271. var pos0, pos1, pos2;
  9272. pos0 = pos;
  9273. pos1 = pos;
  9274. if (input.charCodeAt(pos) === 48) {
  9275. result0 = "0";
  9276. pos++;
  9277. } else {
  9278. result0 = null;
  9279. if (reportFailures === 0) {
  9280. matchFailed("\"0\"");
  9281. }
  9282. }
  9283. if (result0 !== null) {
  9284. pos2 = pos;
  9285. if (input.charCodeAt(pos) === 46) {
  9286. result1 = ".";
  9287. pos++;
  9288. } else {
  9289. result1 = null;
  9290. if (reportFailures === 0) {
  9291. matchFailed("\".\"");
  9292. }
  9293. }
  9294. if (result1 !== null) {
  9295. result2 = parse_DIGIT();
  9296. result2 = result2 !== null ? result2 : "";
  9297. if (result2 !== null) {
  9298. result3 = parse_DIGIT();
  9299. result3 = result3 !== null ? result3 : "";
  9300. if (result3 !== null) {
  9301. result4 = parse_DIGIT();
  9302. result4 = result4 !== null ? result4 : "";
  9303. if (result4 !== null) {
  9304. result1 = [result1, result2, result3, result4];
  9305. } else {
  9306. result1 = null;
  9307. pos = pos2;
  9308. }
  9309. } else {
  9310. result1 = null;
  9311. pos = pos2;
  9312. }
  9313. } else {
  9314. result1 = null;
  9315. pos = pos2;
  9316. }
  9317. } else {
  9318. result1 = null;
  9319. pos = pos2;
  9320. }
  9321. result1 = result1 !== null ? result1 : "";
  9322. if (result1 !== null) {
  9323. result0 = [result0, result1];
  9324. } else {
  9325. result0 = null;
  9326. pos = pos1;
  9327. }
  9328. } else {
  9329. result0 = null;
  9330. pos = pos1;
  9331. }
  9332. if (result0 !== null) {
  9333. result0 = function (offset) {
  9334. return parseFloat(input.substring(pos, offset));
  9335. }(pos0);
  9336. }
  9337. if (result0 === null) {
  9338. pos = pos0;
  9339. }
  9340. return result0;
  9341. }
  9342. function parse_generic_param() {
  9343. var result0, result1, result2;
  9344. var pos0, pos1, pos2;
  9345. pos0 = pos;
  9346. pos1 = pos;
  9347. result0 = parse_token();
  9348. if (result0 !== null) {
  9349. pos2 = pos;
  9350. result1 = parse_EQUAL();
  9351. if (result1 !== null) {
  9352. result2 = parse_gen_value();
  9353. if (result2 !== null) {
  9354. result1 = [result1, result2];
  9355. } else {
  9356. result1 = null;
  9357. pos = pos2;
  9358. }
  9359. } else {
  9360. result1 = null;
  9361. pos = pos2;
  9362. }
  9363. result1 = result1 !== null ? result1 : "";
  9364. if (result1 !== null) {
  9365. result0 = [result0, result1];
  9366. } else {
  9367. result0 = null;
  9368. pos = pos1;
  9369. }
  9370. } else {
  9371. result0 = null;
  9372. pos = pos1;
  9373. }
  9374. if (result0 !== null) {
  9375. result0 = function (offset, param, value) {
  9376. if (!data.params) data.params = {};
  9377. if (typeof value === 'undefined') {
  9378. value = undefined;
  9379. } else {
  9380. value = value[1];
  9381. }
  9382. data.params[param.toLowerCase()] = value;
  9383. }(pos0, result0[0], result0[1]);
  9384. }
  9385. if (result0 === null) {
  9386. pos = pos0;
  9387. }
  9388. return result0;
  9389. }
  9390. function parse_gen_value() {
  9391. var result0;
  9392. result0 = parse_token();
  9393. if (result0 === null) {
  9394. result0 = parse_host();
  9395. if (result0 === null) {
  9396. result0 = parse_quoted_string();
  9397. }
  9398. }
  9399. return result0;
  9400. }
  9401. function parse_Content_Disposition() {
  9402. var result0, result1, result2, result3;
  9403. var pos0, pos1;
  9404. pos0 = pos;
  9405. result0 = parse_disp_type();
  9406. if (result0 !== null) {
  9407. result1 = [];
  9408. pos1 = pos;
  9409. result2 = parse_SEMI();
  9410. if (result2 !== null) {
  9411. result3 = parse_disp_param();
  9412. if (result3 !== null) {
  9413. result2 = [result2, result3];
  9414. } else {
  9415. result2 = null;
  9416. pos = pos1;
  9417. }
  9418. } else {
  9419. result2 = null;
  9420. pos = pos1;
  9421. }
  9422. while (result2 !== null) {
  9423. result1.push(result2);
  9424. pos1 = pos;
  9425. result2 = parse_SEMI();
  9426. if (result2 !== null) {
  9427. result3 = parse_disp_param();
  9428. if (result3 !== null) {
  9429. result2 = [result2, result3];
  9430. } else {
  9431. result2 = null;
  9432. pos = pos1;
  9433. }
  9434. } else {
  9435. result2 = null;
  9436. pos = pos1;
  9437. }
  9438. }
  9439. if (result1 !== null) {
  9440. result0 = [result0, result1];
  9441. } else {
  9442. result0 = null;
  9443. pos = pos0;
  9444. }
  9445. } else {
  9446. result0 = null;
  9447. pos = pos0;
  9448. }
  9449. return result0;
  9450. }
  9451. function parse_disp_type() {
  9452. var result0;
  9453. if (input.substr(pos, 6).toLowerCase() === "render") {
  9454. result0 = input.substr(pos, 6);
  9455. pos += 6;
  9456. } else {
  9457. result0 = null;
  9458. if (reportFailures === 0) {
  9459. matchFailed("\"render\"");
  9460. }
  9461. }
  9462. if (result0 === null) {
  9463. if (input.substr(pos, 7).toLowerCase() === "session") {
  9464. result0 = input.substr(pos, 7);
  9465. pos += 7;
  9466. } else {
  9467. result0 = null;
  9468. if (reportFailures === 0) {
  9469. matchFailed("\"session\"");
  9470. }
  9471. }
  9472. if (result0 === null) {
  9473. if (input.substr(pos, 4).toLowerCase() === "icon") {
  9474. result0 = input.substr(pos, 4);
  9475. pos += 4;
  9476. } else {
  9477. result0 = null;
  9478. if (reportFailures === 0) {
  9479. matchFailed("\"icon\"");
  9480. }
  9481. }
  9482. if (result0 === null) {
  9483. if (input.substr(pos, 5).toLowerCase() === "alert") {
  9484. result0 = input.substr(pos, 5);
  9485. pos += 5;
  9486. } else {
  9487. result0 = null;
  9488. if (reportFailures === 0) {
  9489. matchFailed("\"alert\"");
  9490. }
  9491. }
  9492. if (result0 === null) {
  9493. result0 = parse_token();
  9494. }
  9495. }
  9496. }
  9497. }
  9498. return result0;
  9499. }
  9500. function parse_disp_param() {
  9501. var result0;
  9502. result0 = parse_handling_param();
  9503. if (result0 === null) {
  9504. result0 = parse_generic_param();
  9505. }
  9506. return result0;
  9507. }
  9508. function parse_handling_param() {
  9509. var result0, result1, result2;
  9510. var pos0;
  9511. pos0 = pos;
  9512. if (input.substr(pos, 8).toLowerCase() === "handling") {
  9513. result0 = input.substr(pos, 8);
  9514. pos += 8;
  9515. } else {
  9516. result0 = null;
  9517. if (reportFailures === 0) {
  9518. matchFailed("\"handling\"");
  9519. }
  9520. }
  9521. if (result0 !== null) {
  9522. result1 = parse_EQUAL();
  9523. if (result1 !== null) {
  9524. if (input.substr(pos, 8).toLowerCase() === "optional") {
  9525. result2 = input.substr(pos, 8);
  9526. pos += 8;
  9527. } else {
  9528. result2 = null;
  9529. if (reportFailures === 0) {
  9530. matchFailed("\"optional\"");
  9531. }
  9532. }
  9533. if (result2 === null) {
  9534. if (input.substr(pos, 8).toLowerCase() === "required") {
  9535. result2 = input.substr(pos, 8);
  9536. pos += 8;
  9537. } else {
  9538. result2 = null;
  9539. if (reportFailures === 0) {
  9540. matchFailed("\"required\"");
  9541. }
  9542. }
  9543. if (result2 === null) {
  9544. result2 = parse_token();
  9545. }
  9546. }
  9547. if (result2 !== null) {
  9548. result0 = [result0, result1, result2];
  9549. } else {
  9550. result0 = null;
  9551. pos = pos0;
  9552. }
  9553. } else {
  9554. result0 = null;
  9555. pos = pos0;
  9556. }
  9557. } else {
  9558. result0 = null;
  9559. pos = pos0;
  9560. }
  9561. return result0;
  9562. }
  9563. function parse_Content_Encoding() {
  9564. var result0, result1, result2, result3;
  9565. var pos0, pos1;
  9566. pos0 = pos;
  9567. result0 = parse_token();
  9568. if (result0 !== null) {
  9569. result1 = [];
  9570. pos1 = pos;
  9571. result2 = parse_COMMA();
  9572. if (result2 !== null) {
  9573. result3 = parse_token();
  9574. if (result3 !== null) {
  9575. result2 = [result2, result3];
  9576. } else {
  9577. result2 = null;
  9578. pos = pos1;
  9579. }
  9580. } else {
  9581. result2 = null;
  9582. pos = pos1;
  9583. }
  9584. while (result2 !== null) {
  9585. result1.push(result2);
  9586. pos1 = pos;
  9587. result2 = parse_COMMA();
  9588. if (result2 !== null) {
  9589. result3 = parse_token();
  9590. if (result3 !== null) {
  9591. result2 = [result2, result3];
  9592. } else {
  9593. result2 = null;
  9594. pos = pos1;
  9595. }
  9596. } else {
  9597. result2 = null;
  9598. pos = pos1;
  9599. }
  9600. }
  9601. if (result1 !== null) {
  9602. result0 = [result0, result1];
  9603. } else {
  9604. result0 = null;
  9605. pos = pos0;
  9606. }
  9607. } else {
  9608. result0 = null;
  9609. pos = pos0;
  9610. }
  9611. return result0;
  9612. }
  9613. function parse_Content_Length() {
  9614. var result0, result1;
  9615. var pos0;
  9616. pos0 = pos;
  9617. result1 = parse_DIGIT();
  9618. if (result1 !== null) {
  9619. result0 = [];
  9620. while (result1 !== null) {
  9621. result0.push(result1);
  9622. result1 = parse_DIGIT();
  9623. }
  9624. } else {
  9625. result0 = null;
  9626. }
  9627. if (result0 !== null) {
  9628. result0 = function (offset, length) {
  9629. data = parseInt(length.join(''));
  9630. }(pos0, result0);
  9631. }
  9632. if (result0 === null) {
  9633. pos = pos0;
  9634. }
  9635. return result0;
  9636. }
  9637. function parse_Content_Type() {
  9638. var result0;
  9639. var pos0;
  9640. pos0 = pos;
  9641. result0 = parse_media_type();
  9642. if (result0 !== null) {
  9643. result0 = function (offset) {
  9644. data = input.substring(pos, offset);
  9645. }(pos0);
  9646. }
  9647. if (result0 === null) {
  9648. pos = pos0;
  9649. }
  9650. return result0;
  9651. }
  9652. function parse_media_type() {
  9653. var result0, result1, result2, result3, result4, result5;
  9654. var pos0, pos1;
  9655. pos0 = pos;
  9656. result0 = parse_m_type();
  9657. if (result0 !== null) {
  9658. result1 = parse_SLASH();
  9659. if (result1 !== null) {
  9660. result2 = parse_m_subtype();
  9661. if (result2 !== null) {
  9662. result3 = [];
  9663. pos1 = pos;
  9664. result4 = parse_SEMI();
  9665. if (result4 !== null) {
  9666. result5 = parse_m_parameter();
  9667. if (result5 !== null) {
  9668. result4 = [result4, result5];
  9669. } else {
  9670. result4 = null;
  9671. pos = pos1;
  9672. }
  9673. } else {
  9674. result4 = null;
  9675. pos = pos1;
  9676. }
  9677. while (result4 !== null) {
  9678. result3.push(result4);
  9679. pos1 = pos;
  9680. result4 = parse_SEMI();
  9681. if (result4 !== null) {
  9682. result5 = parse_m_parameter();
  9683. if (result5 !== null) {
  9684. result4 = [result4, result5];
  9685. } else {
  9686. result4 = null;
  9687. pos = pos1;
  9688. }
  9689. } else {
  9690. result4 = null;
  9691. pos = pos1;
  9692. }
  9693. }
  9694. if (result3 !== null) {
  9695. result0 = [result0, result1, result2, result3];
  9696. } else {
  9697. result0 = null;
  9698. pos = pos0;
  9699. }
  9700. } else {
  9701. result0 = null;
  9702. pos = pos0;
  9703. }
  9704. } else {
  9705. result0 = null;
  9706. pos = pos0;
  9707. }
  9708. } else {
  9709. result0 = null;
  9710. pos = pos0;
  9711. }
  9712. return result0;
  9713. }
  9714. function parse_m_type() {
  9715. var result0;
  9716. result0 = parse_discrete_type();
  9717. if (result0 === null) {
  9718. result0 = parse_composite_type();
  9719. }
  9720. return result0;
  9721. }
  9722. function parse_discrete_type() {
  9723. var result0;
  9724. if (input.substr(pos, 4).toLowerCase() === "text") {
  9725. result0 = input.substr(pos, 4);
  9726. pos += 4;
  9727. } else {
  9728. result0 = null;
  9729. if (reportFailures === 0) {
  9730. matchFailed("\"text\"");
  9731. }
  9732. }
  9733. if (result0 === null) {
  9734. if (input.substr(pos, 5).toLowerCase() === "image") {
  9735. result0 = input.substr(pos, 5);
  9736. pos += 5;
  9737. } else {
  9738. result0 = null;
  9739. if (reportFailures === 0) {
  9740. matchFailed("\"image\"");
  9741. }
  9742. }
  9743. if (result0 === null) {
  9744. if (input.substr(pos, 5).toLowerCase() === "audio") {
  9745. result0 = input.substr(pos, 5);
  9746. pos += 5;
  9747. } else {
  9748. result0 = null;
  9749. if (reportFailures === 0) {
  9750. matchFailed("\"audio\"");
  9751. }
  9752. }
  9753. if (result0 === null) {
  9754. if (input.substr(pos, 5).toLowerCase() === "video") {
  9755. result0 = input.substr(pos, 5);
  9756. pos += 5;
  9757. } else {
  9758. result0 = null;
  9759. if (reportFailures === 0) {
  9760. matchFailed("\"video\"");
  9761. }
  9762. }
  9763. if (result0 === null) {
  9764. if (input.substr(pos, 11).toLowerCase() === "application") {
  9765. result0 = input.substr(pos, 11);
  9766. pos += 11;
  9767. } else {
  9768. result0 = null;
  9769. if (reportFailures === 0) {
  9770. matchFailed("\"application\"");
  9771. }
  9772. }
  9773. if (result0 === null) {
  9774. result0 = parse_extension_token();
  9775. }
  9776. }
  9777. }
  9778. }
  9779. }
  9780. return result0;
  9781. }
  9782. function parse_composite_type() {
  9783. var result0;
  9784. if (input.substr(pos, 7).toLowerCase() === "message") {
  9785. result0 = input.substr(pos, 7);
  9786. pos += 7;
  9787. } else {
  9788. result0 = null;
  9789. if (reportFailures === 0) {
  9790. matchFailed("\"message\"");
  9791. }
  9792. }
  9793. if (result0 === null) {
  9794. if (input.substr(pos, 9).toLowerCase() === "multipart") {
  9795. result0 = input.substr(pos, 9);
  9796. pos += 9;
  9797. } else {
  9798. result0 = null;
  9799. if (reportFailures === 0) {
  9800. matchFailed("\"multipart\"");
  9801. }
  9802. }
  9803. if (result0 === null) {
  9804. result0 = parse_extension_token();
  9805. }
  9806. }
  9807. return result0;
  9808. }
  9809. function parse_extension_token() {
  9810. var result0;
  9811. result0 = parse_token();
  9812. if (result0 === null) {
  9813. result0 = parse_x_token();
  9814. }
  9815. return result0;
  9816. }
  9817. function parse_x_token() {
  9818. var result0, result1;
  9819. var pos0;
  9820. pos0 = pos;
  9821. if (input.substr(pos, 2).toLowerCase() === "x-") {
  9822. result0 = input.substr(pos, 2);
  9823. pos += 2;
  9824. } else {
  9825. result0 = null;
  9826. if (reportFailures === 0) {
  9827. matchFailed("\"x-\"");
  9828. }
  9829. }
  9830. if (result0 !== null) {
  9831. result1 = parse_token();
  9832. if (result1 !== null) {
  9833. result0 = [result0, result1];
  9834. } else {
  9835. result0 = null;
  9836. pos = pos0;
  9837. }
  9838. } else {
  9839. result0 = null;
  9840. pos = pos0;
  9841. }
  9842. return result0;
  9843. }
  9844. function parse_m_subtype() {
  9845. var result0;
  9846. result0 = parse_extension_token();
  9847. if (result0 === null) {
  9848. result0 = parse_token();
  9849. }
  9850. return result0;
  9851. }
  9852. function parse_m_parameter() {
  9853. var result0, result1, result2;
  9854. var pos0;
  9855. pos0 = pos;
  9856. result0 = parse_token();
  9857. if (result0 !== null) {
  9858. result1 = parse_EQUAL();
  9859. if (result1 !== null) {
  9860. result2 = parse_m_value();
  9861. if (result2 !== null) {
  9862. result0 = [result0, result1, result2];
  9863. } else {
  9864. result0 = null;
  9865. pos = pos0;
  9866. }
  9867. } else {
  9868. result0 = null;
  9869. pos = pos0;
  9870. }
  9871. } else {
  9872. result0 = null;
  9873. pos = pos0;
  9874. }
  9875. return result0;
  9876. }
  9877. function parse_m_value() {
  9878. var result0;
  9879. result0 = parse_token();
  9880. if (result0 === null) {
  9881. result0 = parse_quoted_string();
  9882. }
  9883. return result0;
  9884. }
  9885. function parse_CSeq() {
  9886. var result0, result1, result2;
  9887. var pos0;
  9888. pos0 = pos;
  9889. result0 = parse_CSeq_value();
  9890. if (result0 !== null) {
  9891. result1 = parse_LWS();
  9892. if (result1 !== null) {
  9893. result2 = parse_Method();
  9894. if (result2 !== null) {
  9895. result0 = [result0, result1, result2];
  9896. } else {
  9897. result0 = null;
  9898. pos = pos0;
  9899. }
  9900. } else {
  9901. result0 = null;
  9902. pos = pos0;
  9903. }
  9904. } else {
  9905. result0 = null;
  9906. pos = pos0;
  9907. }
  9908. return result0;
  9909. }
  9910. function parse_CSeq_value() {
  9911. var result0, result1;
  9912. var pos0;
  9913. pos0 = pos;
  9914. result1 = parse_DIGIT();
  9915. if (result1 !== null) {
  9916. result0 = [];
  9917. while (result1 !== null) {
  9918. result0.push(result1);
  9919. result1 = parse_DIGIT();
  9920. }
  9921. } else {
  9922. result0 = null;
  9923. }
  9924. if (result0 !== null) {
  9925. result0 = function (offset, cseq_value) {
  9926. data.value = parseInt(cseq_value.join(''));
  9927. }(pos0, result0);
  9928. }
  9929. if (result0 === null) {
  9930. pos = pos0;
  9931. }
  9932. return result0;
  9933. }
  9934. function parse_Expires() {
  9935. var result0;
  9936. var pos0;
  9937. pos0 = pos;
  9938. result0 = parse_delta_seconds();
  9939. if (result0 !== null) {
  9940. result0 = function (offset, expires) {
  9941. data = expires;
  9942. }(pos0, result0);
  9943. }
  9944. if (result0 === null) {
  9945. pos = pos0;
  9946. }
  9947. return result0;
  9948. }
  9949. function parse_Event() {
  9950. var result0, result1, result2, result3;
  9951. var pos0, pos1, pos2;
  9952. pos0 = pos;
  9953. pos1 = pos;
  9954. result0 = parse_event_type();
  9955. if (result0 !== null) {
  9956. result1 = [];
  9957. pos2 = pos;
  9958. result2 = parse_SEMI();
  9959. if (result2 !== null) {
  9960. result3 = parse_generic_param();
  9961. if (result3 !== null) {
  9962. result2 = [result2, result3];
  9963. } else {
  9964. result2 = null;
  9965. pos = pos2;
  9966. }
  9967. } else {
  9968. result2 = null;
  9969. pos = pos2;
  9970. }
  9971. while (result2 !== null) {
  9972. result1.push(result2);
  9973. pos2 = pos;
  9974. result2 = parse_SEMI();
  9975. if (result2 !== null) {
  9976. result3 = parse_generic_param();
  9977. if (result3 !== null) {
  9978. result2 = [result2, result3];
  9979. } else {
  9980. result2 = null;
  9981. pos = pos2;
  9982. }
  9983. } else {
  9984. result2 = null;
  9985. pos = pos2;
  9986. }
  9987. }
  9988. if (result1 !== null) {
  9989. result0 = [result0, result1];
  9990. } else {
  9991. result0 = null;
  9992. pos = pos1;
  9993. }
  9994. } else {
  9995. result0 = null;
  9996. pos = pos1;
  9997. }
  9998. if (result0 !== null) {
  9999. result0 = function (offset, event_type) {
  10000. data.event = event_type.join('').toLowerCase();
  10001. }(pos0, result0[0]);
  10002. }
  10003. if (result0 === null) {
  10004. pos = pos0;
  10005. }
  10006. return result0;
  10007. }
  10008. function parse_event_type() {
  10009. var result0, result1, result2, result3;
  10010. var pos0, pos1;
  10011. pos0 = pos;
  10012. result0 = parse_token_nodot();
  10013. if (result0 !== null) {
  10014. result1 = [];
  10015. pos1 = pos;
  10016. if (input.charCodeAt(pos) === 46) {
  10017. result2 = ".";
  10018. pos++;
  10019. } else {
  10020. result2 = null;
  10021. if (reportFailures === 0) {
  10022. matchFailed("\".\"");
  10023. }
  10024. }
  10025. if (result2 !== null) {
  10026. result3 = parse_token_nodot();
  10027. if (result3 !== null) {
  10028. result2 = [result2, result3];
  10029. } else {
  10030. result2 = null;
  10031. pos = pos1;
  10032. }
  10033. } else {
  10034. result2 = null;
  10035. pos = pos1;
  10036. }
  10037. while (result2 !== null) {
  10038. result1.push(result2);
  10039. pos1 = pos;
  10040. if (input.charCodeAt(pos) === 46) {
  10041. result2 = ".";
  10042. pos++;
  10043. } else {
  10044. result2 = null;
  10045. if (reportFailures === 0) {
  10046. matchFailed("\".\"");
  10047. }
  10048. }
  10049. if (result2 !== null) {
  10050. result3 = parse_token_nodot();
  10051. if (result3 !== null) {
  10052. result2 = [result2, result3];
  10053. } else {
  10054. result2 = null;
  10055. pos = pos1;
  10056. }
  10057. } else {
  10058. result2 = null;
  10059. pos = pos1;
  10060. }
  10061. }
  10062. if (result1 !== null) {
  10063. result0 = [result0, result1];
  10064. } else {
  10065. result0 = null;
  10066. pos = pos0;
  10067. }
  10068. } else {
  10069. result0 = null;
  10070. pos = pos0;
  10071. }
  10072. return result0;
  10073. }
  10074. function parse_From() {
  10075. var result0, result1, result2, result3;
  10076. var pos0, pos1, pos2;
  10077. pos0 = pos;
  10078. pos1 = pos;
  10079. result0 = parse_SIP_URI_noparams();
  10080. if (result0 === null) {
  10081. result0 = parse_name_addr();
  10082. }
  10083. if (result0 !== null) {
  10084. result1 = [];
  10085. pos2 = pos;
  10086. result2 = parse_SEMI();
  10087. if (result2 !== null) {
  10088. result3 = parse_from_param();
  10089. if (result3 !== null) {
  10090. result2 = [result2, result3];
  10091. } else {
  10092. result2 = null;
  10093. pos = pos2;
  10094. }
  10095. } else {
  10096. result2 = null;
  10097. pos = pos2;
  10098. }
  10099. while (result2 !== null) {
  10100. result1.push(result2);
  10101. pos2 = pos;
  10102. result2 = parse_SEMI();
  10103. if (result2 !== null) {
  10104. result3 = parse_from_param();
  10105. if (result3 !== null) {
  10106. result2 = [result2, result3];
  10107. } else {
  10108. result2 = null;
  10109. pos = pos2;
  10110. }
  10111. } else {
  10112. result2 = null;
  10113. pos = pos2;
  10114. }
  10115. }
  10116. if (result1 !== null) {
  10117. result0 = [result0, result1];
  10118. } else {
  10119. result0 = null;
  10120. pos = pos1;
  10121. }
  10122. } else {
  10123. result0 = null;
  10124. pos = pos1;
  10125. }
  10126. if (result0 !== null) {
  10127. result0 = function (offset) {
  10128. var tag = data.tag;
  10129. try {
  10130. data = new NameAddrHeader(data.uri, data.display_name, data.params);
  10131. if (tag) {
  10132. data.setParam('tag', tag);
  10133. }
  10134. } catch (e) {
  10135. data = -1;
  10136. }
  10137. }(pos0);
  10138. }
  10139. if (result0 === null) {
  10140. pos = pos0;
  10141. }
  10142. return result0;
  10143. }
  10144. function parse_from_param() {
  10145. var result0;
  10146. result0 = parse_tag_param();
  10147. if (result0 === null) {
  10148. result0 = parse_generic_param();
  10149. }
  10150. return result0;
  10151. }
  10152. function parse_tag_param() {
  10153. var result0, result1, result2;
  10154. var pos0, pos1;
  10155. pos0 = pos;
  10156. pos1 = pos;
  10157. if (input.substr(pos, 3).toLowerCase() === "tag") {
  10158. result0 = input.substr(pos, 3);
  10159. pos += 3;
  10160. } else {
  10161. result0 = null;
  10162. if (reportFailures === 0) {
  10163. matchFailed("\"tag\"");
  10164. }
  10165. }
  10166. if (result0 !== null) {
  10167. result1 = parse_EQUAL();
  10168. if (result1 !== null) {
  10169. result2 = parse_token();
  10170. if (result2 !== null) {
  10171. result0 = [result0, result1, result2];
  10172. } else {
  10173. result0 = null;
  10174. pos = pos1;
  10175. }
  10176. } else {
  10177. result0 = null;
  10178. pos = pos1;
  10179. }
  10180. } else {
  10181. result0 = null;
  10182. pos = pos1;
  10183. }
  10184. if (result0 !== null) {
  10185. result0 = function (offset, tag) {
  10186. data.tag = tag;
  10187. }(pos0, result0[2]);
  10188. }
  10189. if (result0 === null) {
  10190. pos = pos0;
  10191. }
  10192. return result0;
  10193. }
  10194. function parse_Max_Forwards() {
  10195. var result0, result1;
  10196. var pos0;
  10197. pos0 = pos;
  10198. result1 = parse_DIGIT();
  10199. if (result1 !== null) {
  10200. result0 = [];
  10201. while (result1 !== null) {
  10202. result0.push(result1);
  10203. result1 = parse_DIGIT();
  10204. }
  10205. } else {
  10206. result0 = null;
  10207. }
  10208. if (result0 !== null) {
  10209. result0 = function (offset, forwards) {
  10210. data = parseInt(forwards.join(''));
  10211. }(pos0, result0);
  10212. }
  10213. if (result0 === null) {
  10214. pos = pos0;
  10215. }
  10216. return result0;
  10217. }
  10218. function parse_Min_Expires() {
  10219. var result0;
  10220. var pos0;
  10221. pos0 = pos;
  10222. result0 = parse_delta_seconds();
  10223. if (result0 !== null) {
  10224. result0 = function (offset, min_expires) {
  10225. data = min_expires;
  10226. }(pos0, result0);
  10227. }
  10228. if (result0 === null) {
  10229. pos = pos0;
  10230. }
  10231. return result0;
  10232. }
  10233. function parse_Name_Addr_Header() {
  10234. var result0, result1, result2, result3, result4, result5, result6;
  10235. var pos0, pos1, pos2;
  10236. pos0 = pos;
  10237. pos1 = pos;
  10238. result0 = [];
  10239. result1 = parse_display_name();
  10240. while (result1 !== null) {
  10241. result0.push(result1);
  10242. result1 = parse_display_name();
  10243. }
  10244. if (result0 !== null) {
  10245. result1 = parse_LAQUOT();
  10246. if (result1 !== null) {
  10247. result2 = parse_SIP_URI();
  10248. if (result2 !== null) {
  10249. result3 = parse_RAQUOT();
  10250. if (result3 !== null) {
  10251. result4 = [];
  10252. pos2 = pos;
  10253. result5 = parse_SEMI();
  10254. if (result5 !== null) {
  10255. result6 = parse_generic_param();
  10256. if (result6 !== null) {
  10257. result5 = [result5, result6];
  10258. } else {
  10259. result5 = null;
  10260. pos = pos2;
  10261. }
  10262. } else {
  10263. result5 = null;
  10264. pos = pos2;
  10265. }
  10266. while (result5 !== null) {
  10267. result4.push(result5);
  10268. pos2 = pos;
  10269. result5 = parse_SEMI();
  10270. if (result5 !== null) {
  10271. result6 = parse_generic_param();
  10272. if (result6 !== null) {
  10273. result5 = [result5, result6];
  10274. } else {
  10275. result5 = null;
  10276. pos = pos2;
  10277. }
  10278. } else {
  10279. result5 = null;
  10280. pos = pos2;
  10281. }
  10282. }
  10283. if (result4 !== null) {
  10284. result0 = [result0, result1, result2, result3, result4];
  10285. } else {
  10286. result0 = null;
  10287. pos = pos1;
  10288. }
  10289. } else {
  10290. result0 = null;
  10291. pos = pos1;
  10292. }
  10293. } else {
  10294. result0 = null;
  10295. pos = pos1;
  10296. }
  10297. } else {
  10298. result0 = null;
  10299. pos = pos1;
  10300. }
  10301. } else {
  10302. result0 = null;
  10303. pos = pos1;
  10304. }
  10305. if (result0 !== null) {
  10306. result0 = function (offset) {
  10307. try {
  10308. data = new NameAddrHeader(data.uri, data.display_name, data.params);
  10309. } catch (e) {
  10310. data = -1;
  10311. }
  10312. }(pos0);
  10313. }
  10314. if (result0 === null) {
  10315. pos = pos0;
  10316. }
  10317. return result0;
  10318. }
  10319. function parse_Proxy_Authenticate() {
  10320. var result0;
  10321. result0 = parse_challenge();
  10322. return result0;
  10323. }
  10324. function parse_challenge() {
  10325. var result0, result1, result2, result3, result4, result5;
  10326. var pos0, pos1;
  10327. pos0 = pos;
  10328. if (input.substr(pos, 6).toLowerCase() === "digest") {
  10329. result0 = input.substr(pos, 6);
  10330. pos += 6;
  10331. } else {
  10332. result0 = null;
  10333. if (reportFailures === 0) {
  10334. matchFailed("\"Digest\"");
  10335. }
  10336. }
  10337. if (result0 !== null) {
  10338. result1 = parse_LWS();
  10339. if (result1 !== null) {
  10340. result2 = parse_digest_cln();
  10341. if (result2 !== null) {
  10342. result3 = [];
  10343. pos1 = pos;
  10344. result4 = parse_COMMA();
  10345. if (result4 !== null) {
  10346. result5 = parse_digest_cln();
  10347. if (result5 !== null) {
  10348. result4 = [result4, result5];
  10349. } else {
  10350. result4 = null;
  10351. pos = pos1;
  10352. }
  10353. } else {
  10354. result4 = null;
  10355. pos = pos1;
  10356. }
  10357. while (result4 !== null) {
  10358. result3.push(result4);
  10359. pos1 = pos;
  10360. result4 = parse_COMMA();
  10361. if (result4 !== null) {
  10362. result5 = parse_digest_cln();
  10363. if (result5 !== null) {
  10364. result4 = [result4, result5];
  10365. } else {
  10366. result4 = null;
  10367. pos = pos1;
  10368. }
  10369. } else {
  10370. result4 = null;
  10371. pos = pos1;
  10372. }
  10373. }
  10374. if (result3 !== null) {
  10375. result0 = [result0, result1, result2, result3];
  10376. } else {
  10377. result0 = null;
  10378. pos = pos0;
  10379. }
  10380. } else {
  10381. result0 = null;
  10382. pos = pos0;
  10383. }
  10384. } else {
  10385. result0 = null;
  10386. pos = pos0;
  10387. }
  10388. } else {
  10389. result0 = null;
  10390. pos = pos0;
  10391. }
  10392. if (result0 === null) {
  10393. result0 = parse_other_challenge();
  10394. }
  10395. return result0;
  10396. }
  10397. function parse_other_challenge() {
  10398. var result0, result1, result2, result3, result4, result5;
  10399. var pos0, pos1;
  10400. pos0 = pos;
  10401. result0 = parse_token();
  10402. if (result0 !== null) {
  10403. result1 = parse_LWS();
  10404. if (result1 !== null) {
  10405. result2 = parse_auth_param();
  10406. if (result2 !== null) {
  10407. result3 = [];
  10408. pos1 = pos;
  10409. result4 = parse_COMMA();
  10410. if (result4 !== null) {
  10411. result5 = parse_auth_param();
  10412. if (result5 !== null) {
  10413. result4 = [result4, result5];
  10414. } else {
  10415. result4 = null;
  10416. pos = pos1;
  10417. }
  10418. } else {
  10419. result4 = null;
  10420. pos = pos1;
  10421. }
  10422. while (result4 !== null) {
  10423. result3.push(result4);
  10424. pos1 = pos;
  10425. result4 = parse_COMMA();
  10426. if (result4 !== null) {
  10427. result5 = parse_auth_param();
  10428. if (result5 !== null) {
  10429. result4 = [result4, result5];
  10430. } else {
  10431. result4 = null;
  10432. pos = pos1;
  10433. }
  10434. } else {
  10435. result4 = null;
  10436. pos = pos1;
  10437. }
  10438. }
  10439. if (result3 !== null) {
  10440. result0 = [result0, result1, result2, result3];
  10441. } else {
  10442. result0 = null;
  10443. pos = pos0;
  10444. }
  10445. } else {
  10446. result0 = null;
  10447. pos = pos0;
  10448. }
  10449. } else {
  10450. result0 = null;
  10451. pos = pos0;
  10452. }
  10453. } else {
  10454. result0 = null;
  10455. pos = pos0;
  10456. }
  10457. return result0;
  10458. }
  10459. function parse_auth_param() {
  10460. var result0, result1, result2;
  10461. var pos0;
  10462. pos0 = pos;
  10463. result0 = parse_token();
  10464. if (result0 !== null) {
  10465. result1 = parse_EQUAL();
  10466. if (result1 !== null) {
  10467. result2 = parse_token();
  10468. if (result2 === null) {
  10469. result2 = parse_quoted_string();
  10470. }
  10471. if (result2 !== null) {
  10472. result0 = [result0, result1, result2];
  10473. } else {
  10474. result0 = null;
  10475. pos = pos0;
  10476. }
  10477. } else {
  10478. result0 = null;
  10479. pos = pos0;
  10480. }
  10481. } else {
  10482. result0 = null;
  10483. pos = pos0;
  10484. }
  10485. return result0;
  10486. }
  10487. function parse_digest_cln() {
  10488. var result0;
  10489. result0 = parse_realm();
  10490. if (result0 === null) {
  10491. result0 = parse_domain();
  10492. if (result0 === null) {
  10493. result0 = parse_nonce();
  10494. if (result0 === null) {
  10495. result0 = parse_opaque();
  10496. if (result0 === null) {
  10497. result0 = parse_stale();
  10498. if (result0 === null) {
  10499. result0 = parse_algorithm();
  10500. if (result0 === null) {
  10501. result0 = parse_qop_options();
  10502. if (result0 === null) {
  10503. result0 = parse_auth_param();
  10504. }
  10505. }
  10506. }
  10507. }
  10508. }
  10509. }
  10510. }
  10511. return result0;
  10512. }
  10513. function parse_realm() {
  10514. var result0, result1, result2;
  10515. var pos0;
  10516. pos0 = pos;
  10517. if (input.substr(pos, 5).toLowerCase() === "realm") {
  10518. result0 = input.substr(pos, 5);
  10519. pos += 5;
  10520. } else {
  10521. result0 = null;
  10522. if (reportFailures === 0) {
  10523. matchFailed("\"realm\"");
  10524. }
  10525. }
  10526. if (result0 !== null) {
  10527. result1 = parse_EQUAL();
  10528. if (result1 !== null) {
  10529. result2 = parse_realm_value();
  10530. if (result2 !== null) {
  10531. result0 = [result0, result1, result2];
  10532. } else {
  10533. result0 = null;
  10534. pos = pos0;
  10535. }
  10536. } else {
  10537. result0 = null;
  10538. pos = pos0;
  10539. }
  10540. } else {
  10541. result0 = null;
  10542. pos = pos0;
  10543. }
  10544. return result0;
  10545. }
  10546. function parse_realm_value() {
  10547. var result0;
  10548. var pos0;
  10549. pos0 = pos;
  10550. result0 = parse_quoted_string_clean();
  10551. if (result0 !== null) {
  10552. result0 = function (offset, realm) {
  10553. data.realm = realm;
  10554. }(pos0, result0);
  10555. }
  10556. if (result0 === null) {
  10557. pos = pos0;
  10558. }
  10559. return result0;
  10560. }
  10561. function parse_domain() {
  10562. var result0, result1, result2, result3, result4, result5, result6;
  10563. var pos0, pos1;
  10564. pos0 = pos;
  10565. if (input.substr(pos, 6).toLowerCase() === "domain") {
  10566. result0 = input.substr(pos, 6);
  10567. pos += 6;
  10568. } else {
  10569. result0 = null;
  10570. if (reportFailures === 0) {
  10571. matchFailed("\"domain\"");
  10572. }
  10573. }
  10574. if (result0 !== null) {
  10575. result1 = parse_EQUAL();
  10576. if (result1 !== null) {
  10577. result2 = parse_LDQUOT();
  10578. if (result2 !== null) {
  10579. result3 = parse_URI();
  10580. if (result3 !== null) {
  10581. result4 = [];
  10582. pos1 = pos;
  10583. result6 = parse_SP();
  10584. if (result6 !== null) {
  10585. result5 = [];
  10586. while (result6 !== null) {
  10587. result5.push(result6);
  10588. result6 = parse_SP();
  10589. }
  10590. } else {
  10591. result5 = null;
  10592. }
  10593. if (result5 !== null) {
  10594. result6 = parse_URI();
  10595. if (result6 !== null) {
  10596. result5 = [result5, result6];
  10597. } else {
  10598. result5 = null;
  10599. pos = pos1;
  10600. }
  10601. } else {
  10602. result5 = null;
  10603. pos = pos1;
  10604. }
  10605. while (result5 !== null) {
  10606. result4.push(result5);
  10607. pos1 = pos;
  10608. result6 = parse_SP();
  10609. if (result6 !== null) {
  10610. result5 = [];
  10611. while (result6 !== null) {
  10612. result5.push(result6);
  10613. result6 = parse_SP();
  10614. }
  10615. } else {
  10616. result5 = null;
  10617. }
  10618. if (result5 !== null) {
  10619. result6 = parse_URI();
  10620. if (result6 !== null) {
  10621. result5 = [result5, result6];
  10622. } else {
  10623. result5 = null;
  10624. pos = pos1;
  10625. }
  10626. } else {
  10627. result5 = null;
  10628. pos = pos1;
  10629. }
  10630. }
  10631. if (result4 !== null) {
  10632. result5 = parse_RDQUOT();
  10633. if (result5 !== null) {
  10634. result0 = [result0, result1, result2, result3, result4, result5];
  10635. } else {
  10636. result0 = null;
  10637. pos = pos0;
  10638. }
  10639. } else {
  10640. result0 = null;
  10641. pos = pos0;
  10642. }
  10643. } else {
  10644. result0 = null;
  10645. pos = pos0;
  10646. }
  10647. } else {
  10648. result0 = null;
  10649. pos = pos0;
  10650. }
  10651. } else {
  10652. result0 = null;
  10653. pos = pos0;
  10654. }
  10655. } else {
  10656. result0 = null;
  10657. pos = pos0;
  10658. }
  10659. return result0;
  10660. }
  10661. function parse_URI() {
  10662. var result0;
  10663. result0 = parse_absoluteURI();
  10664. if (result0 === null) {
  10665. result0 = parse_abs_path();
  10666. }
  10667. return result0;
  10668. }
  10669. function parse_nonce() {
  10670. var result0, result1, result2;
  10671. var pos0;
  10672. pos0 = pos;
  10673. if (input.substr(pos, 5).toLowerCase() === "nonce") {
  10674. result0 = input.substr(pos, 5);
  10675. pos += 5;
  10676. } else {
  10677. result0 = null;
  10678. if (reportFailures === 0) {
  10679. matchFailed("\"nonce\"");
  10680. }
  10681. }
  10682. if (result0 !== null) {
  10683. result1 = parse_EQUAL();
  10684. if (result1 !== null) {
  10685. result2 = parse_nonce_value();
  10686. if (result2 !== null) {
  10687. result0 = [result0, result1, result2];
  10688. } else {
  10689. result0 = null;
  10690. pos = pos0;
  10691. }
  10692. } else {
  10693. result0 = null;
  10694. pos = pos0;
  10695. }
  10696. } else {
  10697. result0 = null;
  10698. pos = pos0;
  10699. }
  10700. return result0;
  10701. }
  10702. function parse_nonce_value() {
  10703. var result0;
  10704. var pos0;
  10705. pos0 = pos;
  10706. result0 = parse_quoted_string_clean();
  10707. if (result0 !== null) {
  10708. result0 = function (offset, nonce) {
  10709. data.nonce = nonce;
  10710. }(pos0, result0);
  10711. }
  10712. if (result0 === null) {
  10713. pos = pos0;
  10714. }
  10715. return result0;
  10716. }
  10717. function parse_opaque() {
  10718. var result0, result1, result2;
  10719. var pos0, pos1;
  10720. pos0 = pos;
  10721. pos1 = pos;
  10722. if (input.substr(pos, 6).toLowerCase() === "opaque") {
  10723. result0 = input.substr(pos, 6);
  10724. pos += 6;
  10725. } else {
  10726. result0 = null;
  10727. if (reportFailures === 0) {
  10728. matchFailed("\"opaque\"");
  10729. }
  10730. }
  10731. if (result0 !== null) {
  10732. result1 = parse_EQUAL();
  10733. if (result1 !== null) {
  10734. result2 = parse_quoted_string_clean();
  10735. if (result2 !== null) {
  10736. result0 = [result0, result1, result2];
  10737. } else {
  10738. result0 = null;
  10739. pos = pos1;
  10740. }
  10741. } else {
  10742. result0 = null;
  10743. pos = pos1;
  10744. }
  10745. } else {
  10746. result0 = null;
  10747. pos = pos1;
  10748. }
  10749. if (result0 !== null) {
  10750. result0 = function (offset, opaque) {
  10751. data.opaque = opaque;
  10752. }(pos0, result0[2]);
  10753. }
  10754. if (result0 === null) {
  10755. pos = pos0;
  10756. }
  10757. return result0;
  10758. }
  10759. function parse_stale() {
  10760. var result0, result1, result2;
  10761. var pos0, pos1;
  10762. pos0 = pos;
  10763. if (input.substr(pos, 5).toLowerCase() === "stale") {
  10764. result0 = input.substr(pos, 5);
  10765. pos += 5;
  10766. } else {
  10767. result0 = null;
  10768. if (reportFailures === 0) {
  10769. matchFailed("\"stale\"");
  10770. }
  10771. }
  10772. if (result0 !== null) {
  10773. result1 = parse_EQUAL();
  10774. if (result1 !== null) {
  10775. pos1 = pos;
  10776. if (input.substr(pos, 4).toLowerCase() === "true") {
  10777. result2 = input.substr(pos, 4);
  10778. pos += 4;
  10779. } else {
  10780. result2 = null;
  10781. if (reportFailures === 0) {
  10782. matchFailed("\"true\"");
  10783. }
  10784. }
  10785. if (result2 !== null) {
  10786. result2 = function (offset) {
  10787. data.stale = true;
  10788. }(pos1);
  10789. }
  10790. if (result2 === null) {
  10791. pos = pos1;
  10792. }
  10793. if (result2 === null) {
  10794. pos1 = pos;
  10795. if (input.substr(pos, 5).toLowerCase() === "false") {
  10796. result2 = input.substr(pos, 5);
  10797. pos += 5;
  10798. } else {
  10799. result2 = null;
  10800. if (reportFailures === 0) {
  10801. matchFailed("\"false\"");
  10802. }
  10803. }
  10804. if (result2 !== null) {
  10805. result2 = function (offset) {
  10806. data.stale = false;
  10807. }(pos1);
  10808. }
  10809. if (result2 === null) {
  10810. pos = pos1;
  10811. }
  10812. }
  10813. if (result2 !== null) {
  10814. result0 = [result0, result1, result2];
  10815. } else {
  10816. result0 = null;
  10817. pos = pos0;
  10818. }
  10819. } else {
  10820. result0 = null;
  10821. pos = pos0;
  10822. }
  10823. } else {
  10824. result0 = null;
  10825. pos = pos0;
  10826. }
  10827. return result0;
  10828. }
  10829. function parse_algorithm() {
  10830. var result0, result1, result2;
  10831. var pos0, pos1;
  10832. pos0 = pos;
  10833. pos1 = pos;
  10834. if (input.substr(pos, 9).toLowerCase() === "algorithm") {
  10835. result0 = input.substr(pos, 9);
  10836. pos += 9;
  10837. } else {
  10838. result0 = null;
  10839. if (reportFailures === 0) {
  10840. matchFailed("\"algorithm\"");
  10841. }
  10842. }
  10843. if (result0 !== null) {
  10844. result1 = parse_EQUAL();
  10845. if (result1 !== null) {
  10846. if (input.substr(pos, 3).toLowerCase() === "md5") {
  10847. result2 = input.substr(pos, 3);
  10848. pos += 3;
  10849. } else {
  10850. result2 = null;
  10851. if (reportFailures === 0) {
  10852. matchFailed("\"MD5\"");
  10853. }
  10854. }
  10855. if (result2 === null) {
  10856. if (input.substr(pos, 8).toLowerCase() === "md5-sess") {
  10857. result2 = input.substr(pos, 8);
  10858. pos += 8;
  10859. } else {
  10860. result2 = null;
  10861. if (reportFailures === 0) {
  10862. matchFailed("\"MD5-sess\"");
  10863. }
  10864. }
  10865. if (result2 === null) {
  10866. result2 = parse_token();
  10867. }
  10868. }
  10869. if (result2 !== null) {
  10870. result0 = [result0, result1, result2];
  10871. } else {
  10872. result0 = null;
  10873. pos = pos1;
  10874. }
  10875. } else {
  10876. result0 = null;
  10877. pos = pos1;
  10878. }
  10879. } else {
  10880. result0 = null;
  10881. pos = pos1;
  10882. }
  10883. if (result0 !== null) {
  10884. result0 = function (offset, algorithm) {
  10885. data.algorithm = algorithm.toUpperCase();
  10886. }(pos0, result0[2]);
  10887. }
  10888. if (result0 === null) {
  10889. pos = pos0;
  10890. }
  10891. return result0;
  10892. }
  10893. function parse_qop_options() {
  10894. var result0, result1, result2, result3, result4, result5, result6;
  10895. var pos0, pos1, pos2;
  10896. pos0 = pos;
  10897. if (input.substr(pos, 3).toLowerCase() === "qop") {
  10898. result0 = input.substr(pos, 3);
  10899. pos += 3;
  10900. } else {
  10901. result0 = null;
  10902. if (reportFailures === 0) {
  10903. matchFailed("\"qop\"");
  10904. }
  10905. }
  10906. if (result0 !== null) {
  10907. result1 = parse_EQUAL();
  10908. if (result1 !== null) {
  10909. result2 = parse_LDQUOT();
  10910. if (result2 !== null) {
  10911. pos1 = pos;
  10912. result3 = parse_qop_value();
  10913. if (result3 !== null) {
  10914. result4 = [];
  10915. pos2 = pos;
  10916. if (input.charCodeAt(pos) === 44) {
  10917. result5 = ",";
  10918. pos++;
  10919. } else {
  10920. result5 = null;
  10921. if (reportFailures === 0) {
  10922. matchFailed("\",\"");
  10923. }
  10924. }
  10925. if (result5 !== null) {
  10926. result6 = parse_qop_value();
  10927. if (result6 !== null) {
  10928. result5 = [result5, result6];
  10929. } else {
  10930. result5 = null;
  10931. pos = pos2;
  10932. }
  10933. } else {
  10934. result5 = null;
  10935. pos = pos2;
  10936. }
  10937. while (result5 !== null) {
  10938. result4.push(result5);
  10939. pos2 = pos;
  10940. if (input.charCodeAt(pos) === 44) {
  10941. result5 = ",";
  10942. pos++;
  10943. } else {
  10944. result5 = null;
  10945. if (reportFailures === 0) {
  10946. matchFailed("\",\"");
  10947. }
  10948. }
  10949. if (result5 !== null) {
  10950. result6 = parse_qop_value();
  10951. if (result6 !== null) {
  10952. result5 = [result5, result6];
  10953. } else {
  10954. result5 = null;
  10955. pos = pos2;
  10956. }
  10957. } else {
  10958. result5 = null;
  10959. pos = pos2;
  10960. }
  10961. }
  10962. if (result4 !== null) {
  10963. result3 = [result3, result4];
  10964. } else {
  10965. result3 = null;
  10966. pos = pos1;
  10967. }
  10968. } else {
  10969. result3 = null;
  10970. pos = pos1;
  10971. }
  10972. if (result3 !== null) {
  10973. result4 = parse_RDQUOT();
  10974. if (result4 !== null) {
  10975. result0 = [result0, result1, result2, result3, result4];
  10976. } else {
  10977. result0 = null;
  10978. pos = pos0;
  10979. }
  10980. } else {
  10981. result0 = null;
  10982. pos = pos0;
  10983. }
  10984. } else {
  10985. result0 = null;
  10986. pos = pos0;
  10987. }
  10988. } else {
  10989. result0 = null;
  10990. pos = pos0;
  10991. }
  10992. } else {
  10993. result0 = null;
  10994. pos = pos0;
  10995. }
  10996. return result0;
  10997. }
  10998. function parse_qop_value() {
  10999. var result0;
  11000. var pos0;
  11001. pos0 = pos;
  11002. if (input.substr(pos, 8).toLowerCase() === "auth-int") {
  11003. result0 = input.substr(pos, 8);
  11004. pos += 8;
  11005. } else {
  11006. result0 = null;
  11007. if (reportFailures === 0) {
  11008. matchFailed("\"auth-int\"");
  11009. }
  11010. }
  11011. if (result0 === null) {
  11012. if (input.substr(pos, 4).toLowerCase() === "auth") {
  11013. result0 = input.substr(pos, 4);
  11014. pos += 4;
  11015. } else {
  11016. result0 = null;
  11017. if (reportFailures === 0) {
  11018. matchFailed("\"auth\"");
  11019. }
  11020. }
  11021. if (result0 === null) {
  11022. result0 = parse_token();
  11023. }
  11024. }
  11025. if (result0 !== null) {
  11026. result0 = function (offset, qop_value) {
  11027. data.qop || (data.qop = []);
  11028. data.qop.push(qop_value.toLowerCase());
  11029. }(pos0, result0);
  11030. }
  11031. if (result0 === null) {
  11032. pos = pos0;
  11033. }
  11034. return result0;
  11035. }
  11036. function parse_Proxy_Require() {
  11037. var result0, result1, result2, result3;
  11038. var pos0, pos1;
  11039. pos0 = pos;
  11040. result0 = parse_token();
  11041. if (result0 !== null) {
  11042. result1 = [];
  11043. pos1 = pos;
  11044. result2 = parse_COMMA();
  11045. if (result2 !== null) {
  11046. result3 = parse_token();
  11047. if (result3 !== null) {
  11048. result2 = [result2, result3];
  11049. } else {
  11050. result2 = null;
  11051. pos = pos1;
  11052. }
  11053. } else {
  11054. result2 = null;
  11055. pos = pos1;
  11056. }
  11057. while (result2 !== null) {
  11058. result1.push(result2);
  11059. pos1 = pos;
  11060. result2 = parse_COMMA();
  11061. if (result2 !== null) {
  11062. result3 = parse_token();
  11063. if (result3 !== null) {
  11064. result2 = [result2, result3];
  11065. } else {
  11066. result2 = null;
  11067. pos = pos1;
  11068. }
  11069. } else {
  11070. result2 = null;
  11071. pos = pos1;
  11072. }
  11073. }
  11074. if (result1 !== null) {
  11075. result0 = [result0, result1];
  11076. } else {
  11077. result0 = null;
  11078. pos = pos0;
  11079. }
  11080. } else {
  11081. result0 = null;
  11082. pos = pos0;
  11083. }
  11084. return result0;
  11085. }
  11086. function parse_Record_Route() {
  11087. var result0, result1, result2, result3;
  11088. var pos0, pos1, pos2;
  11089. pos0 = pos;
  11090. pos1 = pos;
  11091. result0 = parse_rec_route();
  11092. if (result0 !== null) {
  11093. result1 = [];
  11094. pos2 = pos;
  11095. result2 = parse_COMMA();
  11096. if (result2 !== null) {
  11097. result3 = parse_rec_route();
  11098. if (result3 !== null) {
  11099. result2 = [result2, result3];
  11100. } else {
  11101. result2 = null;
  11102. pos = pos2;
  11103. }
  11104. } else {
  11105. result2 = null;
  11106. pos = pos2;
  11107. }
  11108. while (result2 !== null) {
  11109. result1.push(result2);
  11110. pos2 = pos;
  11111. result2 = parse_COMMA();
  11112. if (result2 !== null) {
  11113. result3 = parse_rec_route();
  11114. if (result3 !== null) {
  11115. result2 = [result2, result3];
  11116. } else {
  11117. result2 = null;
  11118. pos = pos2;
  11119. }
  11120. } else {
  11121. result2 = null;
  11122. pos = pos2;
  11123. }
  11124. }
  11125. if (result1 !== null) {
  11126. result0 = [result0, result1];
  11127. } else {
  11128. result0 = null;
  11129. pos = pos1;
  11130. }
  11131. } else {
  11132. result0 = null;
  11133. pos = pos1;
  11134. }
  11135. if (result0 !== null) {
  11136. result0 = function (offset) {
  11137. var idx, length;
  11138. length = data.multi_header.length;
  11139. for (idx = 0; idx < length; idx++) {
  11140. if (data.multi_header[idx].parsed === null) {
  11141. data = null;
  11142. break;
  11143. }
  11144. }
  11145. if (data !== null) {
  11146. data = data.multi_header;
  11147. } else {
  11148. data = -1;
  11149. }
  11150. }(pos0);
  11151. }
  11152. if (result0 === null) {
  11153. pos = pos0;
  11154. }
  11155. return result0;
  11156. }
  11157. function parse_rec_route() {
  11158. var result0, result1, result2, result3;
  11159. var pos0, pos1, pos2;
  11160. pos0 = pos;
  11161. pos1 = pos;
  11162. result0 = parse_name_addr();
  11163. if (result0 !== null) {
  11164. result1 = [];
  11165. pos2 = pos;
  11166. result2 = parse_SEMI();
  11167. if (result2 !== null) {
  11168. result3 = parse_generic_param();
  11169. if (result3 !== null) {
  11170. result2 = [result2, result3];
  11171. } else {
  11172. result2 = null;
  11173. pos = pos2;
  11174. }
  11175. } else {
  11176. result2 = null;
  11177. pos = pos2;
  11178. }
  11179. while (result2 !== null) {
  11180. result1.push(result2);
  11181. pos2 = pos;
  11182. result2 = parse_SEMI();
  11183. if (result2 !== null) {
  11184. result3 = parse_generic_param();
  11185. if (result3 !== null) {
  11186. result2 = [result2, result3];
  11187. } else {
  11188. result2 = null;
  11189. pos = pos2;
  11190. }
  11191. } else {
  11192. result2 = null;
  11193. pos = pos2;
  11194. }
  11195. }
  11196. if (result1 !== null) {
  11197. result0 = [result0, result1];
  11198. } else {
  11199. result0 = null;
  11200. pos = pos1;
  11201. }
  11202. } else {
  11203. result0 = null;
  11204. pos = pos1;
  11205. }
  11206. if (result0 !== null) {
  11207. result0 = function (offset) {
  11208. var header;
  11209. if (!data.multi_header) data.multi_header = [];
  11210. try {
  11211. header = new NameAddrHeader(data.uri, data.display_name, data.params);
  11212. delete data.uri;
  11213. delete data.display_name;
  11214. delete data.params;
  11215. } catch (e) {
  11216. header = null;
  11217. }
  11218. data.multi_header.push({
  11219. 'possition': pos,
  11220. 'offset': offset,
  11221. 'parsed': header
  11222. });
  11223. }(pos0);
  11224. }
  11225. if (result0 === null) {
  11226. pos = pos0;
  11227. }
  11228. return result0;
  11229. }
  11230. function parse_Reason() {
  11231. var result0, result1, result2, result3;
  11232. var pos0, pos1, pos2;
  11233. pos0 = pos;
  11234. pos1 = pos;
  11235. if (input.substr(pos, 3).toLowerCase() === "sip") {
  11236. result0 = input.substr(pos, 3);
  11237. pos += 3;
  11238. } else {
  11239. result0 = null;
  11240. if (reportFailures === 0) {
  11241. matchFailed("\"SIP\"");
  11242. }
  11243. }
  11244. if (result0 === null) {
  11245. result0 = parse_token();
  11246. }
  11247. if (result0 !== null) {
  11248. result1 = [];
  11249. pos2 = pos;
  11250. result2 = parse_SEMI();
  11251. if (result2 !== null) {
  11252. result3 = parse_reason_param();
  11253. if (result3 !== null) {
  11254. result2 = [result2, result3];
  11255. } else {
  11256. result2 = null;
  11257. pos = pos2;
  11258. }
  11259. } else {
  11260. result2 = null;
  11261. pos = pos2;
  11262. }
  11263. while (result2 !== null) {
  11264. result1.push(result2);
  11265. pos2 = pos;
  11266. result2 = parse_SEMI();
  11267. if (result2 !== null) {
  11268. result3 = parse_reason_param();
  11269. if (result3 !== null) {
  11270. result2 = [result2, result3];
  11271. } else {
  11272. result2 = null;
  11273. pos = pos2;
  11274. }
  11275. } else {
  11276. result2 = null;
  11277. pos = pos2;
  11278. }
  11279. }
  11280. if (result1 !== null) {
  11281. result0 = [result0, result1];
  11282. } else {
  11283. result0 = null;
  11284. pos = pos1;
  11285. }
  11286. } else {
  11287. result0 = null;
  11288. pos = pos1;
  11289. }
  11290. if (result0 !== null) {
  11291. result0 = function (offset, protocol) {
  11292. data.protocol = protocol.toLowerCase();
  11293. if (!data.params) data.params = {};
  11294. if (data.params.text && data.params.text[0] === '"') {
  11295. var text = data.params.text;
  11296. data.text = text.substring(1, text.length - 1);
  11297. delete data.params.text;
  11298. }
  11299. }(pos0, result0[0]);
  11300. }
  11301. if (result0 === null) {
  11302. pos = pos0;
  11303. }
  11304. return result0;
  11305. }
  11306. function parse_reason_param() {
  11307. var result0;
  11308. result0 = parse_reason_cause();
  11309. if (result0 === null) {
  11310. result0 = parse_generic_param();
  11311. }
  11312. return result0;
  11313. }
  11314. function parse_reason_cause() {
  11315. var result0, result1, result2, result3;
  11316. var pos0, pos1;
  11317. pos0 = pos;
  11318. pos1 = pos;
  11319. if (input.substr(pos, 5).toLowerCase() === "cause") {
  11320. result0 = input.substr(pos, 5);
  11321. pos += 5;
  11322. } else {
  11323. result0 = null;
  11324. if (reportFailures === 0) {
  11325. matchFailed("\"cause\"");
  11326. }
  11327. }
  11328. if (result0 !== null) {
  11329. result1 = parse_EQUAL();
  11330. if (result1 !== null) {
  11331. result3 = parse_DIGIT();
  11332. if (result3 !== null) {
  11333. result2 = [];
  11334. while (result3 !== null) {
  11335. result2.push(result3);
  11336. result3 = parse_DIGIT();
  11337. }
  11338. } else {
  11339. result2 = null;
  11340. }
  11341. if (result2 !== null) {
  11342. result0 = [result0, result1, result2];
  11343. } else {
  11344. result0 = null;
  11345. pos = pos1;
  11346. }
  11347. } else {
  11348. result0 = null;
  11349. pos = pos1;
  11350. }
  11351. } else {
  11352. result0 = null;
  11353. pos = pos1;
  11354. }
  11355. if (result0 !== null) {
  11356. result0 = function (offset, cause) {
  11357. data.cause = parseInt(cause.join(''));
  11358. }(pos0, result0[2]);
  11359. }
  11360. if (result0 === null) {
  11361. pos = pos0;
  11362. }
  11363. return result0;
  11364. }
  11365. function parse_Require() {
  11366. var result0, result1, result2, result3;
  11367. var pos0, pos1;
  11368. pos0 = pos;
  11369. result0 = parse_token();
  11370. if (result0 !== null) {
  11371. result1 = [];
  11372. pos1 = pos;
  11373. result2 = parse_COMMA();
  11374. if (result2 !== null) {
  11375. result3 = parse_token();
  11376. if (result3 !== null) {
  11377. result2 = [result2, result3];
  11378. } else {
  11379. result2 = null;
  11380. pos = pos1;
  11381. }
  11382. } else {
  11383. result2 = null;
  11384. pos = pos1;
  11385. }
  11386. while (result2 !== null) {
  11387. result1.push(result2);
  11388. pos1 = pos;
  11389. result2 = parse_COMMA();
  11390. if (result2 !== null) {
  11391. result3 = parse_token();
  11392. if (result3 !== null) {
  11393. result2 = [result2, result3];
  11394. } else {
  11395. result2 = null;
  11396. pos = pos1;
  11397. }
  11398. } else {
  11399. result2 = null;
  11400. pos = pos1;
  11401. }
  11402. }
  11403. if (result1 !== null) {
  11404. result0 = [result0, result1];
  11405. } else {
  11406. result0 = null;
  11407. pos = pos0;
  11408. }
  11409. } else {
  11410. result0 = null;
  11411. pos = pos0;
  11412. }
  11413. return result0;
  11414. }
  11415. function parse_Route() {
  11416. var result0, result1, result2, result3;
  11417. var pos0, pos1;
  11418. pos0 = pos;
  11419. result0 = parse_route_param();
  11420. if (result0 !== null) {
  11421. result1 = [];
  11422. pos1 = pos;
  11423. result2 = parse_COMMA();
  11424. if (result2 !== null) {
  11425. result3 = parse_route_param();
  11426. if (result3 !== null) {
  11427. result2 = [result2, result3];
  11428. } else {
  11429. result2 = null;
  11430. pos = pos1;
  11431. }
  11432. } else {
  11433. result2 = null;
  11434. pos = pos1;
  11435. }
  11436. while (result2 !== null) {
  11437. result1.push(result2);
  11438. pos1 = pos;
  11439. result2 = parse_COMMA();
  11440. if (result2 !== null) {
  11441. result3 = parse_route_param();
  11442. if (result3 !== null) {
  11443. result2 = [result2, result3];
  11444. } else {
  11445. result2 = null;
  11446. pos = pos1;
  11447. }
  11448. } else {
  11449. result2 = null;
  11450. pos = pos1;
  11451. }
  11452. }
  11453. if (result1 !== null) {
  11454. result0 = [result0, result1];
  11455. } else {
  11456. result0 = null;
  11457. pos = pos0;
  11458. }
  11459. } else {
  11460. result0 = null;
  11461. pos = pos0;
  11462. }
  11463. return result0;
  11464. }
  11465. function parse_route_param() {
  11466. var result0, result1, result2, result3;
  11467. var pos0, pos1;
  11468. pos0 = pos;
  11469. result0 = parse_name_addr();
  11470. if (result0 !== null) {
  11471. result1 = [];
  11472. pos1 = pos;
  11473. result2 = parse_SEMI();
  11474. if (result2 !== null) {
  11475. result3 = parse_generic_param();
  11476. if (result3 !== null) {
  11477. result2 = [result2, result3];
  11478. } else {
  11479. result2 = null;
  11480. pos = pos1;
  11481. }
  11482. } else {
  11483. result2 = null;
  11484. pos = pos1;
  11485. }
  11486. while (result2 !== null) {
  11487. result1.push(result2);
  11488. pos1 = pos;
  11489. result2 = parse_SEMI();
  11490. if (result2 !== null) {
  11491. result3 = parse_generic_param();
  11492. if (result3 !== null) {
  11493. result2 = [result2, result3];
  11494. } else {
  11495. result2 = null;
  11496. pos = pos1;
  11497. }
  11498. } else {
  11499. result2 = null;
  11500. pos = pos1;
  11501. }
  11502. }
  11503. if (result1 !== null) {
  11504. result0 = [result0, result1];
  11505. } else {
  11506. result0 = null;
  11507. pos = pos0;
  11508. }
  11509. } else {
  11510. result0 = null;
  11511. pos = pos0;
  11512. }
  11513. return result0;
  11514. }
  11515. function parse_Subscription_State() {
  11516. var result0, result1, result2, result3;
  11517. var pos0, pos1;
  11518. pos0 = pos;
  11519. result0 = parse_substate_value();
  11520. if (result0 !== null) {
  11521. result1 = [];
  11522. pos1 = pos;
  11523. result2 = parse_SEMI();
  11524. if (result2 !== null) {
  11525. result3 = parse_subexp_params();
  11526. if (result3 !== null) {
  11527. result2 = [result2, result3];
  11528. } else {
  11529. result2 = null;
  11530. pos = pos1;
  11531. }
  11532. } else {
  11533. result2 = null;
  11534. pos = pos1;
  11535. }
  11536. while (result2 !== null) {
  11537. result1.push(result2);
  11538. pos1 = pos;
  11539. result2 = parse_SEMI();
  11540. if (result2 !== null) {
  11541. result3 = parse_subexp_params();
  11542. if (result3 !== null) {
  11543. result2 = [result2, result3];
  11544. } else {
  11545. result2 = null;
  11546. pos = pos1;
  11547. }
  11548. } else {
  11549. result2 = null;
  11550. pos = pos1;
  11551. }
  11552. }
  11553. if (result1 !== null) {
  11554. result0 = [result0, result1];
  11555. } else {
  11556. result0 = null;
  11557. pos = pos0;
  11558. }
  11559. } else {
  11560. result0 = null;
  11561. pos = pos0;
  11562. }
  11563. return result0;
  11564. }
  11565. function parse_substate_value() {
  11566. var result0;
  11567. var pos0;
  11568. pos0 = pos;
  11569. if (input.substr(pos, 6).toLowerCase() === "active") {
  11570. result0 = input.substr(pos, 6);
  11571. pos += 6;
  11572. } else {
  11573. result0 = null;
  11574. if (reportFailures === 0) {
  11575. matchFailed("\"active\"");
  11576. }
  11577. }
  11578. if (result0 === null) {
  11579. if (input.substr(pos, 7).toLowerCase() === "pending") {
  11580. result0 = input.substr(pos, 7);
  11581. pos += 7;
  11582. } else {
  11583. result0 = null;
  11584. if (reportFailures === 0) {
  11585. matchFailed("\"pending\"");
  11586. }
  11587. }
  11588. if (result0 === null) {
  11589. if (input.substr(pos, 10).toLowerCase() === "terminated") {
  11590. result0 = input.substr(pos, 10);
  11591. pos += 10;
  11592. } else {
  11593. result0 = null;
  11594. if (reportFailures === 0) {
  11595. matchFailed("\"terminated\"");
  11596. }
  11597. }
  11598. if (result0 === null) {
  11599. result0 = parse_token();
  11600. }
  11601. }
  11602. }
  11603. if (result0 !== null) {
  11604. result0 = function (offset) {
  11605. data.state = input.substring(pos, offset);
  11606. }(pos0);
  11607. }
  11608. if (result0 === null) {
  11609. pos = pos0;
  11610. }
  11611. return result0;
  11612. }
  11613. function parse_subexp_params() {
  11614. var result0, result1, result2;
  11615. var pos0, pos1;
  11616. pos0 = pos;
  11617. pos1 = pos;
  11618. if (input.substr(pos, 6).toLowerCase() === "reason") {
  11619. result0 = input.substr(pos, 6);
  11620. pos += 6;
  11621. } else {
  11622. result0 = null;
  11623. if (reportFailures === 0) {
  11624. matchFailed("\"reason\"");
  11625. }
  11626. }
  11627. if (result0 !== null) {
  11628. result1 = parse_EQUAL();
  11629. if (result1 !== null) {
  11630. result2 = parse_event_reason_value();
  11631. if (result2 !== null) {
  11632. result0 = [result0, result1, result2];
  11633. } else {
  11634. result0 = null;
  11635. pos = pos1;
  11636. }
  11637. } else {
  11638. result0 = null;
  11639. pos = pos1;
  11640. }
  11641. } else {
  11642. result0 = null;
  11643. pos = pos1;
  11644. }
  11645. if (result0 !== null) {
  11646. result0 = function (offset, reason) {
  11647. if (typeof reason !== 'undefined') data.reason = reason;
  11648. }(pos0, result0[2]);
  11649. }
  11650. if (result0 === null) {
  11651. pos = pos0;
  11652. }
  11653. if (result0 === null) {
  11654. pos0 = pos;
  11655. pos1 = pos;
  11656. if (input.substr(pos, 7).toLowerCase() === "expires") {
  11657. result0 = input.substr(pos, 7);
  11658. pos += 7;
  11659. } else {
  11660. result0 = null;
  11661. if (reportFailures === 0) {
  11662. matchFailed("\"expires\"");
  11663. }
  11664. }
  11665. if (result0 !== null) {
  11666. result1 = parse_EQUAL();
  11667. if (result1 !== null) {
  11668. result2 = parse_delta_seconds();
  11669. if (result2 !== null) {
  11670. result0 = [result0, result1, result2];
  11671. } else {
  11672. result0 = null;
  11673. pos = pos1;
  11674. }
  11675. } else {
  11676. result0 = null;
  11677. pos = pos1;
  11678. }
  11679. } else {
  11680. result0 = null;
  11681. pos = pos1;
  11682. }
  11683. if (result0 !== null) {
  11684. result0 = function (offset, expires) {
  11685. if (typeof expires !== 'undefined') data.expires = expires;
  11686. }(pos0, result0[2]);
  11687. }
  11688. if (result0 === null) {
  11689. pos = pos0;
  11690. }
  11691. if (result0 === null) {
  11692. pos0 = pos;
  11693. pos1 = pos;
  11694. if (input.substr(pos, 11).toLowerCase() === "retry_after") {
  11695. result0 = input.substr(pos, 11);
  11696. pos += 11;
  11697. } else {
  11698. result0 = null;
  11699. if (reportFailures === 0) {
  11700. matchFailed("\"retry_after\"");
  11701. }
  11702. }
  11703. if (result0 !== null) {
  11704. result1 = parse_EQUAL();
  11705. if (result1 !== null) {
  11706. result2 = parse_delta_seconds();
  11707. if (result2 !== null) {
  11708. result0 = [result0, result1, result2];
  11709. } else {
  11710. result0 = null;
  11711. pos = pos1;
  11712. }
  11713. } else {
  11714. result0 = null;
  11715. pos = pos1;
  11716. }
  11717. } else {
  11718. result0 = null;
  11719. pos = pos1;
  11720. }
  11721. if (result0 !== null) {
  11722. result0 = function (offset, retry_after) {
  11723. if (typeof retry_after !== 'undefined') data.retry_after = retry_after;
  11724. }(pos0, result0[2]);
  11725. }
  11726. if (result0 === null) {
  11727. pos = pos0;
  11728. }
  11729. if (result0 === null) {
  11730. result0 = parse_generic_param();
  11731. }
  11732. }
  11733. }
  11734. return result0;
  11735. }
  11736. function parse_event_reason_value() {
  11737. var result0;
  11738. if (input.substr(pos, 11).toLowerCase() === "deactivated") {
  11739. result0 = input.substr(pos, 11);
  11740. pos += 11;
  11741. } else {
  11742. result0 = null;
  11743. if (reportFailures === 0) {
  11744. matchFailed("\"deactivated\"");
  11745. }
  11746. }
  11747. if (result0 === null) {
  11748. if (input.substr(pos, 9).toLowerCase() === "probation") {
  11749. result0 = input.substr(pos, 9);
  11750. pos += 9;
  11751. } else {
  11752. result0 = null;
  11753. if (reportFailures === 0) {
  11754. matchFailed("\"probation\"");
  11755. }
  11756. }
  11757. if (result0 === null) {
  11758. if (input.substr(pos, 8).toLowerCase() === "rejected") {
  11759. result0 = input.substr(pos, 8);
  11760. pos += 8;
  11761. } else {
  11762. result0 = null;
  11763. if (reportFailures === 0) {
  11764. matchFailed("\"rejected\"");
  11765. }
  11766. }
  11767. if (result0 === null) {
  11768. if (input.substr(pos, 7).toLowerCase() === "timeout") {
  11769. result0 = input.substr(pos, 7);
  11770. pos += 7;
  11771. } else {
  11772. result0 = null;
  11773. if (reportFailures === 0) {
  11774. matchFailed("\"timeout\"");
  11775. }
  11776. }
  11777. if (result0 === null) {
  11778. if (input.substr(pos, 6).toLowerCase() === "giveup") {
  11779. result0 = input.substr(pos, 6);
  11780. pos += 6;
  11781. } else {
  11782. result0 = null;
  11783. if (reportFailures === 0) {
  11784. matchFailed("\"giveup\"");
  11785. }
  11786. }
  11787. if (result0 === null) {
  11788. if (input.substr(pos, 10).toLowerCase() === "noresource") {
  11789. result0 = input.substr(pos, 10);
  11790. pos += 10;
  11791. } else {
  11792. result0 = null;
  11793. if (reportFailures === 0) {
  11794. matchFailed("\"noresource\"");
  11795. }
  11796. }
  11797. if (result0 === null) {
  11798. if (input.substr(pos, 9).toLowerCase() === "invariant") {
  11799. result0 = input.substr(pos, 9);
  11800. pos += 9;
  11801. } else {
  11802. result0 = null;
  11803. if (reportFailures === 0) {
  11804. matchFailed("\"invariant\"");
  11805. }
  11806. }
  11807. if (result0 === null) {
  11808. result0 = parse_token();
  11809. }
  11810. }
  11811. }
  11812. }
  11813. }
  11814. }
  11815. }
  11816. return result0;
  11817. }
  11818. function parse_Subject() {
  11819. var result0;
  11820. result0 = parse_TEXT_UTF8_TRIM();
  11821. result0 = result0 !== null ? result0 : "";
  11822. return result0;
  11823. }
  11824. function parse_Supported() {
  11825. var result0, result1, result2, result3;
  11826. var pos0, pos1;
  11827. pos0 = pos;
  11828. result0 = parse_token();
  11829. if (result0 !== null) {
  11830. result1 = [];
  11831. pos1 = pos;
  11832. result2 = parse_COMMA();
  11833. if (result2 !== null) {
  11834. result3 = parse_token();
  11835. if (result3 !== null) {
  11836. result2 = [result2, result3];
  11837. } else {
  11838. result2 = null;
  11839. pos = pos1;
  11840. }
  11841. } else {
  11842. result2 = null;
  11843. pos = pos1;
  11844. }
  11845. while (result2 !== null) {
  11846. result1.push(result2);
  11847. pos1 = pos;
  11848. result2 = parse_COMMA();
  11849. if (result2 !== null) {
  11850. result3 = parse_token();
  11851. if (result3 !== null) {
  11852. result2 = [result2, result3];
  11853. } else {
  11854. result2 = null;
  11855. pos = pos1;
  11856. }
  11857. } else {
  11858. result2 = null;
  11859. pos = pos1;
  11860. }
  11861. }
  11862. if (result1 !== null) {
  11863. result0 = [result0, result1];
  11864. } else {
  11865. result0 = null;
  11866. pos = pos0;
  11867. }
  11868. } else {
  11869. result0 = null;
  11870. pos = pos0;
  11871. }
  11872. result0 = result0 !== null ? result0 : "";
  11873. return result0;
  11874. }
  11875. function parse_To() {
  11876. var result0, result1, result2, result3;
  11877. var pos0, pos1, pos2;
  11878. pos0 = pos;
  11879. pos1 = pos;
  11880. result0 = parse_SIP_URI_noparams();
  11881. if (result0 === null) {
  11882. result0 = parse_name_addr();
  11883. }
  11884. if (result0 !== null) {
  11885. result1 = [];
  11886. pos2 = pos;
  11887. result2 = parse_SEMI();
  11888. if (result2 !== null) {
  11889. result3 = parse_to_param();
  11890. if (result3 !== null) {
  11891. result2 = [result2, result3];
  11892. } else {
  11893. result2 = null;
  11894. pos = pos2;
  11895. }
  11896. } else {
  11897. result2 = null;
  11898. pos = pos2;
  11899. }
  11900. while (result2 !== null) {
  11901. result1.push(result2);
  11902. pos2 = pos;
  11903. result2 = parse_SEMI();
  11904. if (result2 !== null) {
  11905. result3 = parse_to_param();
  11906. if (result3 !== null) {
  11907. result2 = [result2, result3];
  11908. } else {
  11909. result2 = null;
  11910. pos = pos2;
  11911. }
  11912. } else {
  11913. result2 = null;
  11914. pos = pos2;
  11915. }
  11916. }
  11917. if (result1 !== null) {
  11918. result0 = [result0, result1];
  11919. } else {
  11920. result0 = null;
  11921. pos = pos1;
  11922. }
  11923. } else {
  11924. result0 = null;
  11925. pos = pos1;
  11926. }
  11927. if (result0 !== null) {
  11928. result0 = function (offset) {
  11929. var tag = data.tag;
  11930. try {
  11931. data = new NameAddrHeader(data.uri, data.display_name, data.params);
  11932. if (tag) {
  11933. data.setParam('tag', tag);
  11934. }
  11935. } catch (e) {
  11936. data = -1;
  11937. }
  11938. }(pos0);
  11939. }
  11940. if (result0 === null) {
  11941. pos = pos0;
  11942. }
  11943. return result0;
  11944. }
  11945. function parse_to_param() {
  11946. var result0;
  11947. result0 = parse_tag_param();
  11948. if (result0 === null) {
  11949. result0 = parse_generic_param();
  11950. }
  11951. return result0;
  11952. }
  11953. function parse_Via() {
  11954. var result0, result1, result2, result3;
  11955. var pos0, pos1;
  11956. pos0 = pos;
  11957. result0 = parse_via_param();
  11958. if (result0 !== null) {
  11959. result1 = [];
  11960. pos1 = pos;
  11961. result2 = parse_COMMA();
  11962. if (result2 !== null) {
  11963. result3 = parse_via_param();
  11964. if (result3 !== null) {
  11965. result2 = [result2, result3];
  11966. } else {
  11967. result2 = null;
  11968. pos = pos1;
  11969. }
  11970. } else {
  11971. result2 = null;
  11972. pos = pos1;
  11973. }
  11974. while (result2 !== null) {
  11975. result1.push(result2);
  11976. pos1 = pos;
  11977. result2 = parse_COMMA();
  11978. if (result2 !== null) {
  11979. result3 = parse_via_param();
  11980. if (result3 !== null) {
  11981. result2 = [result2, result3];
  11982. } else {
  11983. result2 = null;
  11984. pos = pos1;
  11985. }
  11986. } else {
  11987. result2 = null;
  11988. pos = pos1;
  11989. }
  11990. }
  11991. if (result1 !== null) {
  11992. result0 = [result0, result1];
  11993. } else {
  11994. result0 = null;
  11995. pos = pos0;
  11996. }
  11997. } else {
  11998. result0 = null;
  11999. pos = pos0;
  12000. }
  12001. return result0;
  12002. }
  12003. function parse_via_param() {
  12004. var result0, result1, result2, result3, result4, result5;
  12005. var pos0, pos1;
  12006. pos0 = pos;
  12007. result0 = parse_sent_protocol();
  12008. if (result0 !== null) {
  12009. result1 = parse_LWS();
  12010. if (result1 !== null) {
  12011. result2 = parse_sent_by();
  12012. if (result2 !== null) {
  12013. result3 = [];
  12014. pos1 = pos;
  12015. result4 = parse_SEMI();
  12016. if (result4 !== null) {
  12017. result5 = parse_via_params();
  12018. if (result5 !== null) {
  12019. result4 = [result4, result5];
  12020. } else {
  12021. result4 = null;
  12022. pos = pos1;
  12023. }
  12024. } else {
  12025. result4 = null;
  12026. pos = pos1;
  12027. }
  12028. while (result4 !== null) {
  12029. result3.push(result4);
  12030. pos1 = pos;
  12031. result4 = parse_SEMI();
  12032. if (result4 !== null) {
  12033. result5 = parse_via_params();
  12034. if (result5 !== null) {
  12035. result4 = [result4, result5];
  12036. } else {
  12037. result4 = null;
  12038. pos = pos1;
  12039. }
  12040. } else {
  12041. result4 = null;
  12042. pos = pos1;
  12043. }
  12044. }
  12045. if (result3 !== null) {
  12046. result0 = [result0, result1, result2, result3];
  12047. } else {
  12048. result0 = null;
  12049. pos = pos0;
  12050. }
  12051. } else {
  12052. result0 = null;
  12053. pos = pos0;
  12054. }
  12055. } else {
  12056. result0 = null;
  12057. pos = pos0;
  12058. }
  12059. } else {
  12060. result0 = null;
  12061. pos = pos0;
  12062. }
  12063. return result0;
  12064. }
  12065. function parse_via_params() {
  12066. var result0;
  12067. result0 = parse_via_ttl();
  12068. if (result0 === null) {
  12069. result0 = parse_via_maddr();
  12070. if (result0 === null) {
  12071. result0 = parse_via_received();
  12072. if (result0 === null) {
  12073. result0 = parse_via_branch();
  12074. if (result0 === null) {
  12075. result0 = parse_response_port();
  12076. if (result0 === null) {
  12077. result0 = parse_generic_param();
  12078. }
  12079. }
  12080. }
  12081. }
  12082. }
  12083. return result0;
  12084. }
  12085. function parse_via_ttl() {
  12086. var result0, result1, result2;
  12087. var pos0, pos1;
  12088. pos0 = pos;
  12089. pos1 = pos;
  12090. if (input.substr(pos, 3).toLowerCase() === "ttl") {
  12091. result0 = input.substr(pos, 3);
  12092. pos += 3;
  12093. } else {
  12094. result0 = null;
  12095. if (reportFailures === 0) {
  12096. matchFailed("\"ttl\"");
  12097. }
  12098. }
  12099. if (result0 !== null) {
  12100. result1 = parse_EQUAL();
  12101. if (result1 !== null) {
  12102. result2 = parse_ttl();
  12103. if (result2 !== null) {
  12104. result0 = [result0, result1, result2];
  12105. } else {
  12106. result0 = null;
  12107. pos = pos1;
  12108. }
  12109. } else {
  12110. result0 = null;
  12111. pos = pos1;
  12112. }
  12113. } else {
  12114. result0 = null;
  12115. pos = pos1;
  12116. }
  12117. if (result0 !== null) {
  12118. result0 = function (offset, via_ttl_value) {
  12119. data.ttl = via_ttl_value;
  12120. }(pos0, result0[2]);
  12121. }
  12122. if (result0 === null) {
  12123. pos = pos0;
  12124. }
  12125. return result0;
  12126. }
  12127. function parse_via_maddr() {
  12128. var result0, result1, result2;
  12129. var pos0, pos1;
  12130. pos0 = pos;
  12131. pos1 = pos;
  12132. if (input.substr(pos, 5).toLowerCase() === "maddr") {
  12133. result0 = input.substr(pos, 5);
  12134. pos += 5;
  12135. } else {
  12136. result0 = null;
  12137. if (reportFailures === 0) {
  12138. matchFailed("\"maddr\"");
  12139. }
  12140. }
  12141. if (result0 !== null) {
  12142. result1 = parse_EQUAL();
  12143. if (result1 !== null) {
  12144. result2 = parse_host();
  12145. if (result2 !== null) {
  12146. result0 = [result0, result1, result2];
  12147. } else {
  12148. result0 = null;
  12149. pos = pos1;
  12150. }
  12151. } else {
  12152. result0 = null;
  12153. pos = pos1;
  12154. }
  12155. } else {
  12156. result0 = null;
  12157. pos = pos1;
  12158. }
  12159. if (result0 !== null) {
  12160. result0 = function (offset, via_maddr) {
  12161. data.maddr = via_maddr;
  12162. }(pos0, result0[2]);
  12163. }
  12164. if (result0 === null) {
  12165. pos = pos0;
  12166. }
  12167. return result0;
  12168. }
  12169. function parse_via_received() {
  12170. var result0, result1, result2;
  12171. var pos0, pos1;
  12172. pos0 = pos;
  12173. pos1 = pos;
  12174. if (input.substr(pos, 8).toLowerCase() === "received") {
  12175. result0 = input.substr(pos, 8);
  12176. pos += 8;
  12177. } else {
  12178. result0 = null;
  12179. if (reportFailures === 0) {
  12180. matchFailed("\"received\"");
  12181. }
  12182. }
  12183. if (result0 !== null) {
  12184. result1 = parse_EQUAL();
  12185. if (result1 !== null) {
  12186. result2 = parse_IPv4address();
  12187. if (result2 === null) {
  12188. result2 = parse_IPv6address();
  12189. }
  12190. if (result2 !== null) {
  12191. result0 = [result0, result1, result2];
  12192. } else {
  12193. result0 = null;
  12194. pos = pos1;
  12195. }
  12196. } else {
  12197. result0 = null;
  12198. pos = pos1;
  12199. }
  12200. } else {
  12201. result0 = null;
  12202. pos = pos1;
  12203. }
  12204. if (result0 !== null) {
  12205. result0 = function (offset, via_received) {
  12206. data.received = via_received;
  12207. }(pos0, result0[2]);
  12208. }
  12209. if (result0 === null) {
  12210. pos = pos0;
  12211. }
  12212. return result0;
  12213. }
  12214. function parse_via_branch() {
  12215. var result0, result1, result2;
  12216. var pos0, pos1;
  12217. pos0 = pos;
  12218. pos1 = pos;
  12219. if (input.substr(pos, 6).toLowerCase() === "branch") {
  12220. result0 = input.substr(pos, 6);
  12221. pos += 6;
  12222. } else {
  12223. result0 = null;
  12224. if (reportFailures === 0) {
  12225. matchFailed("\"branch\"");
  12226. }
  12227. }
  12228. if (result0 !== null) {
  12229. result1 = parse_EQUAL();
  12230. if (result1 !== null) {
  12231. result2 = parse_token();
  12232. if (result2 !== null) {
  12233. result0 = [result0, result1, result2];
  12234. } else {
  12235. result0 = null;
  12236. pos = pos1;
  12237. }
  12238. } else {
  12239. result0 = null;
  12240. pos = pos1;
  12241. }
  12242. } else {
  12243. result0 = null;
  12244. pos = pos1;
  12245. }
  12246. if (result0 !== null) {
  12247. result0 = function (offset, via_branch) {
  12248. data.branch = via_branch;
  12249. }(pos0, result0[2]);
  12250. }
  12251. if (result0 === null) {
  12252. pos = pos0;
  12253. }
  12254. return result0;
  12255. }
  12256. function parse_response_port() {
  12257. var result0, result1, result2, result3;
  12258. var pos0, pos1, pos2;
  12259. pos0 = pos;
  12260. pos1 = pos;
  12261. if (input.substr(pos, 5).toLowerCase() === "rport") {
  12262. result0 = input.substr(pos, 5);
  12263. pos += 5;
  12264. } else {
  12265. result0 = null;
  12266. if (reportFailures === 0) {
  12267. matchFailed("\"rport\"");
  12268. }
  12269. }
  12270. if (result0 !== null) {
  12271. pos2 = pos;
  12272. result1 = parse_EQUAL();
  12273. if (result1 !== null) {
  12274. result2 = [];
  12275. result3 = parse_DIGIT();
  12276. while (result3 !== null) {
  12277. result2.push(result3);
  12278. result3 = parse_DIGIT();
  12279. }
  12280. if (result2 !== null) {
  12281. result1 = [result1, result2];
  12282. } else {
  12283. result1 = null;
  12284. pos = pos2;
  12285. }
  12286. } else {
  12287. result1 = null;
  12288. pos = pos2;
  12289. }
  12290. result1 = result1 !== null ? result1 : "";
  12291. if (result1 !== null) {
  12292. result0 = [result0, result1];
  12293. } else {
  12294. result0 = null;
  12295. pos = pos1;
  12296. }
  12297. } else {
  12298. result0 = null;
  12299. pos = pos1;
  12300. }
  12301. if (result0 !== null) {
  12302. result0 = function (offset) {
  12303. if (typeof response_port !== 'undefined') data.rport = response_port.join('');
  12304. }(pos0);
  12305. }
  12306. if (result0 === null) {
  12307. pos = pos0;
  12308. }
  12309. return result0;
  12310. }
  12311. function parse_sent_protocol() {
  12312. var result0, result1, result2, result3, result4;
  12313. var pos0;
  12314. pos0 = pos;
  12315. result0 = parse_protocol_name();
  12316. if (result0 !== null) {
  12317. result1 = parse_SLASH();
  12318. if (result1 !== null) {
  12319. result2 = parse_token();
  12320. if (result2 !== null) {
  12321. result3 = parse_SLASH();
  12322. if (result3 !== null) {
  12323. result4 = parse_transport();
  12324. if (result4 !== null) {
  12325. result0 = [result0, result1, result2, result3, result4];
  12326. } else {
  12327. result0 = null;
  12328. pos = pos0;
  12329. }
  12330. } else {
  12331. result0 = null;
  12332. pos = pos0;
  12333. }
  12334. } else {
  12335. result0 = null;
  12336. pos = pos0;
  12337. }
  12338. } else {
  12339. result0 = null;
  12340. pos = pos0;
  12341. }
  12342. } else {
  12343. result0 = null;
  12344. pos = pos0;
  12345. }
  12346. return result0;
  12347. }
  12348. function parse_protocol_name() {
  12349. var result0;
  12350. var pos0;
  12351. pos0 = pos;
  12352. if (input.substr(pos, 3).toLowerCase() === "sip") {
  12353. result0 = input.substr(pos, 3);
  12354. pos += 3;
  12355. } else {
  12356. result0 = null;
  12357. if (reportFailures === 0) {
  12358. matchFailed("\"SIP\"");
  12359. }
  12360. }
  12361. if (result0 === null) {
  12362. result0 = parse_token();
  12363. }
  12364. if (result0 !== null) {
  12365. result0 = function (offset, via_protocol) {
  12366. data.protocol = via_protocol;
  12367. }(pos0, result0);
  12368. }
  12369. if (result0 === null) {
  12370. pos = pos0;
  12371. }
  12372. return result0;
  12373. }
  12374. function parse_transport() {
  12375. var result0;
  12376. var pos0;
  12377. pos0 = pos;
  12378. if (input.substr(pos, 3).toLowerCase() === "udp") {
  12379. result0 = input.substr(pos, 3);
  12380. pos += 3;
  12381. } else {
  12382. result0 = null;
  12383. if (reportFailures === 0) {
  12384. matchFailed("\"UDP\"");
  12385. }
  12386. }
  12387. if (result0 === null) {
  12388. if (input.substr(pos, 3).toLowerCase() === "tcp") {
  12389. result0 = input.substr(pos, 3);
  12390. pos += 3;
  12391. } else {
  12392. result0 = null;
  12393. if (reportFailures === 0) {
  12394. matchFailed("\"TCP\"");
  12395. }
  12396. }
  12397. if (result0 === null) {
  12398. if (input.substr(pos, 3).toLowerCase() === "tls") {
  12399. result0 = input.substr(pos, 3);
  12400. pos += 3;
  12401. } else {
  12402. result0 = null;
  12403. if (reportFailures === 0) {
  12404. matchFailed("\"TLS\"");
  12405. }
  12406. }
  12407. if (result0 === null) {
  12408. if (input.substr(pos, 4).toLowerCase() === "sctp") {
  12409. result0 = input.substr(pos, 4);
  12410. pos += 4;
  12411. } else {
  12412. result0 = null;
  12413. if (reportFailures === 0) {
  12414. matchFailed("\"SCTP\"");
  12415. }
  12416. }
  12417. if (result0 === null) {
  12418. result0 = parse_token();
  12419. }
  12420. }
  12421. }
  12422. }
  12423. if (result0 !== null) {
  12424. result0 = function (offset, via_transport) {
  12425. data.transport = via_transport;
  12426. }(pos0, result0);
  12427. }
  12428. if (result0 === null) {
  12429. pos = pos0;
  12430. }
  12431. return result0;
  12432. }
  12433. function parse_sent_by() {
  12434. var result0, result1, result2;
  12435. var pos0, pos1;
  12436. pos0 = pos;
  12437. result0 = parse_via_host();
  12438. if (result0 !== null) {
  12439. pos1 = pos;
  12440. result1 = parse_COLON();
  12441. if (result1 !== null) {
  12442. result2 = parse_via_port();
  12443. if (result2 !== null) {
  12444. result1 = [result1, result2];
  12445. } else {
  12446. result1 = null;
  12447. pos = pos1;
  12448. }
  12449. } else {
  12450. result1 = null;
  12451. pos = pos1;
  12452. }
  12453. result1 = result1 !== null ? result1 : "";
  12454. if (result1 !== null) {
  12455. result0 = [result0, result1];
  12456. } else {
  12457. result0 = null;
  12458. pos = pos0;
  12459. }
  12460. } else {
  12461. result0 = null;
  12462. pos = pos0;
  12463. }
  12464. return result0;
  12465. }
  12466. function parse_via_host() {
  12467. var result0;
  12468. var pos0;
  12469. pos0 = pos;
  12470. result0 = parse_IPv4address();
  12471. if (result0 === null) {
  12472. result0 = parse_IPv6reference();
  12473. if (result0 === null) {
  12474. result0 = parse_hostname();
  12475. }
  12476. }
  12477. if (result0 !== null) {
  12478. result0 = function (offset) {
  12479. data.host = input.substring(pos, offset);
  12480. }(pos0);
  12481. }
  12482. if (result0 === null) {
  12483. pos = pos0;
  12484. }
  12485. return result0;
  12486. }
  12487. function parse_via_port() {
  12488. var result0, result1, result2, result3, result4;
  12489. var pos0, pos1;
  12490. pos0 = pos;
  12491. pos1 = pos;
  12492. result0 = parse_DIGIT();
  12493. result0 = result0 !== null ? result0 : "";
  12494. if (result0 !== null) {
  12495. result1 = parse_DIGIT();
  12496. result1 = result1 !== null ? result1 : "";
  12497. if (result1 !== null) {
  12498. result2 = parse_DIGIT();
  12499. result2 = result2 !== null ? result2 : "";
  12500. if (result2 !== null) {
  12501. result3 = parse_DIGIT();
  12502. result3 = result3 !== null ? result3 : "";
  12503. if (result3 !== null) {
  12504. result4 = parse_DIGIT();
  12505. result4 = result4 !== null ? result4 : "";
  12506. if (result4 !== null) {
  12507. result0 = [result0, result1, result2, result3, result4];
  12508. } else {
  12509. result0 = null;
  12510. pos = pos1;
  12511. }
  12512. } else {
  12513. result0 = null;
  12514. pos = pos1;
  12515. }
  12516. } else {
  12517. result0 = null;
  12518. pos = pos1;
  12519. }
  12520. } else {
  12521. result0 = null;
  12522. pos = pos1;
  12523. }
  12524. } else {
  12525. result0 = null;
  12526. pos = pos1;
  12527. }
  12528. if (result0 !== null) {
  12529. result0 = function (offset, via_sent_by_port) {
  12530. data.port = parseInt(via_sent_by_port.join(''));
  12531. }(pos0, result0);
  12532. }
  12533. if (result0 === null) {
  12534. pos = pos0;
  12535. }
  12536. return result0;
  12537. }
  12538. function parse_ttl() {
  12539. var result0, result1, result2;
  12540. var pos0, pos1;
  12541. pos0 = pos;
  12542. pos1 = pos;
  12543. result0 = parse_DIGIT();
  12544. if (result0 !== null) {
  12545. result1 = parse_DIGIT();
  12546. result1 = result1 !== null ? result1 : "";
  12547. if (result1 !== null) {
  12548. result2 = parse_DIGIT();
  12549. result2 = result2 !== null ? result2 : "";
  12550. if (result2 !== null) {
  12551. result0 = [result0, result1, result2];
  12552. } else {
  12553. result0 = null;
  12554. pos = pos1;
  12555. }
  12556. } else {
  12557. result0 = null;
  12558. pos = pos1;
  12559. }
  12560. } else {
  12561. result0 = null;
  12562. pos = pos1;
  12563. }
  12564. if (result0 !== null) {
  12565. result0 = function (offset, ttl) {
  12566. return parseInt(ttl.join(''));
  12567. }(pos0, result0);
  12568. }
  12569. if (result0 === null) {
  12570. pos = pos0;
  12571. }
  12572. return result0;
  12573. }
  12574. function parse_WWW_Authenticate() {
  12575. var result0;
  12576. result0 = parse_challenge();
  12577. return result0;
  12578. }
  12579. function parse_Session_Expires() {
  12580. var result0, result1, result2, result3;
  12581. var pos0, pos1;
  12582. pos0 = pos;
  12583. result0 = parse_s_e_expires();
  12584. if (result0 !== null) {
  12585. result1 = [];
  12586. pos1 = pos;
  12587. result2 = parse_SEMI();
  12588. if (result2 !== null) {
  12589. result3 = parse_s_e_params();
  12590. if (result3 !== null) {
  12591. result2 = [result2, result3];
  12592. } else {
  12593. result2 = null;
  12594. pos = pos1;
  12595. }
  12596. } else {
  12597. result2 = null;
  12598. pos = pos1;
  12599. }
  12600. while (result2 !== null) {
  12601. result1.push(result2);
  12602. pos1 = pos;
  12603. result2 = parse_SEMI();
  12604. if (result2 !== null) {
  12605. result3 = parse_s_e_params();
  12606. if (result3 !== null) {
  12607. result2 = [result2, result3];
  12608. } else {
  12609. result2 = null;
  12610. pos = pos1;
  12611. }
  12612. } else {
  12613. result2 = null;
  12614. pos = pos1;
  12615. }
  12616. }
  12617. if (result1 !== null) {
  12618. result0 = [result0, result1];
  12619. } else {
  12620. result0 = null;
  12621. pos = pos0;
  12622. }
  12623. } else {
  12624. result0 = null;
  12625. pos = pos0;
  12626. }
  12627. return result0;
  12628. }
  12629. function parse_s_e_expires() {
  12630. var result0;
  12631. var pos0;
  12632. pos0 = pos;
  12633. result0 = parse_delta_seconds();
  12634. if (result0 !== null) {
  12635. result0 = function (offset, expires) {
  12636. data.expires = expires;
  12637. }(pos0, result0);
  12638. }
  12639. if (result0 === null) {
  12640. pos = pos0;
  12641. }
  12642. return result0;
  12643. }
  12644. function parse_s_e_params() {
  12645. var result0;
  12646. result0 = parse_s_e_refresher();
  12647. if (result0 === null) {
  12648. result0 = parse_generic_param();
  12649. }
  12650. return result0;
  12651. }
  12652. function parse_s_e_refresher() {
  12653. var result0, result1, result2;
  12654. var pos0, pos1;
  12655. pos0 = pos;
  12656. pos1 = pos;
  12657. if (input.substr(pos, 9).toLowerCase() === "refresher") {
  12658. result0 = input.substr(pos, 9);
  12659. pos += 9;
  12660. } else {
  12661. result0 = null;
  12662. if (reportFailures === 0) {
  12663. matchFailed("\"refresher\"");
  12664. }
  12665. }
  12666. if (result0 !== null) {
  12667. result1 = parse_EQUAL();
  12668. if (result1 !== null) {
  12669. if (input.substr(pos, 3).toLowerCase() === "uac") {
  12670. result2 = input.substr(pos, 3);
  12671. pos += 3;
  12672. } else {
  12673. result2 = null;
  12674. if (reportFailures === 0) {
  12675. matchFailed("\"uac\"");
  12676. }
  12677. }
  12678. if (result2 === null) {
  12679. if (input.substr(pos, 3).toLowerCase() === "uas") {
  12680. result2 = input.substr(pos, 3);
  12681. pos += 3;
  12682. } else {
  12683. result2 = null;
  12684. if (reportFailures === 0) {
  12685. matchFailed("\"uas\"");
  12686. }
  12687. }
  12688. }
  12689. if (result2 !== null) {
  12690. result0 = [result0, result1, result2];
  12691. } else {
  12692. result0 = null;
  12693. pos = pos1;
  12694. }
  12695. } else {
  12696. result0 = null;
  12697. pos = pos1;
  12698. }
  12699. } else {
  12700. result0 = null;
  12701. pos = pos1;
  12702. }
  12703. if (result0 !== null) {
  12704. result0 = function (offset, s_e_refresher_value) {
  12705. data.refresher = s_e_refresher_value.toLowerCase();
  12706. }(pos0, result0[2]);
  12707. }
  12708. if (result0 === null) {
  12709. pos = pos0;
  12710. }
  12711. return result0;
  12712. }
  12713. function parse_extension_header() {
  12714. var result0, result1, result2;
  12715. var pos0;
  12716. pos0 = pos;
  12717. result0 = parse_token();
  12718. if (result0 !== null) {
  12719. result1 = parse_HCOLON();
  12720. if (result1 !== null) {
  12721. result2 = parse_header_value();
  12722. if (result2 !== null) {
  12723. result0 = [result0, result1, result2];
  12724. } else {
  12725. result0 = null;
  12726. pos = pos0;
  12727. }
  12728. } else {
  12729. result0 = null;
  12730. pos = pos0;
  12731. }
  12732. } else {
  12733. result0 = null;
  12734. pos = pos0;
  12735. }
  12736. return result0;
  12737. }
  12738. function parse_header_value() {
  12739. var result0, result1;
  12740. result0 = [];
  12741. result1 = parse_TEXT_UTF8char();
  12742. if (result1 === null) {
  12743. result1 = parse_UTF8_CONT();
  12744. if (result1 === null) {
  12745. result1 = parse_LWS();
  12746. }
  12747. }
  12748. while (result1 !== null) {
  12749. result0.push(result1);
  12750. result1 = parse_TEXT_UTF8char();
  12751. if (result1 === null) {
  12752. result1 = parse_UTF8_CONT();
  12753. if (result1 === null) {
  12754. result1 = parse_LWS();
  12755. }
  12756. }
  12757. }
  12758. return result0;
  12759. }
  12760. function parse_message_body() {
  12761. var result0, result1;
  12762. result0 = [];
  12763. result1 = parse_OCTET();
  12764. while (result1 !== null) {
  12765. result0.push(result1);
  12766. result1 = parse_OCTET();
  12767. }
  12768. return result0;
  12769. }
  12770. function parse_uuid_URI() {
  12771. var result0, result1;
  12772. var pos0;
  12773. pos0 = pos;
  12774. if (input.substr(pos, 5) === "uuid:") {
  12775. result0 = "uuid:";
  12776. pos += 5;
  12777. } else {
  12778. result0 = null;
  12779. if (reportFailures === 0) {
  12780. matchFailed("\"uuid:\"");
  12781. }
  12782. }
  12783. if (result0 !== null) {
  12784. result1 = parse_uuid();
  12785. if (result1 !== null) {
  12786. result0 = [result0, result1];
  12787. } else {
  12788. result0 = null;
  12789. pos = pos0;
  12790. }
  12791. } else {
  12792. result0 = null;
  12793. pos = pos0;
  12794. }
  12795. return result0;
  12796. }
  12797. function parse_uuid() {
  12798. var result0, result1, result2, result3, result4, result5, result6, result7, result8;
  12799. var pos0, pos1;
  12800. pos0 = pos;
  12801. pos1 = pos;
  12802. result0 = parse_hex8();
  12803. if (result0 !== null) {
  12804. if (input.charCodeAt(pos) === 45) {
  12805. result1 = "-";
  12806. pos++;
  12807. } else {
  12808. result1 = null;
  12809. if (reportFailures === 0) {
  12810. matchFailed("\"-\"");
  12811. }
  12812. }
  12813. if (result1 !== null) {
  12814. result2 = parse_hex4();
  12815. if (result2 !== null) {
  12816. if (input.charCodeAt(pos) === 45) {
  12817. result3 = "-";
  12818. pos++;
  12819. } else {
  12820. result3 = null;
  12821. if (reportFailures === 0) {
  12822. matchFailed("\"-\"");
  12823. }
  12824. }
  12825. if (result3 !== null) {
  12826. result4 = parse_hex4();
  12827. if (result4 !== null) {
  12828. if (input.charCodeAt(pos) === 45) {
  12829. result5 = "-";
  12830. pos++;
  12831. } else {
  12832. result5 = null;
  12833. if (reportFailures === 0) {
  12834. matchFailed("\"-\"");
  12835. }
  12836. }
  12837. if (result5 !== null) {
  12838. result6 = parse_hex4();
  12839. if (result6 !== null) {
  12840. if (input.charCodeAt(pos) === 45) {
  12841. result7 = "-";
  12842. pos++;
  12843. } else {
  12844. result7 = null;
  12845. if (reportFailures === 0) {
  12846. matchFailed("\"-\"");
  12847. }
  12848. }
  12849. if (result7 !== null) {
  12850. result8 = parse_hex12();
  12851. if (result8 !== null) {
  12852. result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8];
  12853. } else {
  12854. result0 = null;
  12855. pos = pos1;
  12856. }
  12857. } else {
  12858. result0 = null;
  12859. pos = pos1;
  12860. }
  12861. } else {
  12862. result0 = null;
  12863. pos = pos1;
  12864. }
  12865. } else {
  12866. result0 = null;
  12867. pos = pos1;
  12868. }
  12869. } else {
  12870. result0 = null;
  12871. pos = pos1;
  12872. }
  12873. } else {
  12874. result0 = null;
  12875. pos = pos1;
  12876. }
  12877. } else {
  12878. result0 = null;
  12879. pos = pos1;
  12880. }
  12881. } else {
  12882. result0 = null;
  12883. pos = pos1;
  12884. }
  12885. } else {
  12886. result0 = null;
  12887. pos = pos1;
  12888. }
  12889. if (result0 !== null) {
  12890. result0 = function (offset, uuid) {
  12891. data = input.substring(pos + 5, offset);
  12892. }(pos0, result0[0]);
  12893. }
  12894. if (result0 === null) {
  12895. pos = pos0;
  12896. }
  12897. return result0;
  12898. }
  12899. function parse_hex4() {
  12900. var result0, result1, result2, result3;
  12901. var pos0;
  12902. pos0 = pos;
  12903. result0 = parse_HEXDIG();
  12904. if (result0 !== null) {
  12905. result1 = parse_HEXDIG();
  12906. if (result1 !== null) {
  12907. result2 = parse_HEXDIG();
  12908. if (result2 !== null) {
  12909. result3 = parse_HEXDIG();
  12910. if (result3 !== null) {
  12911. result0 = [result0, result1, result2, result3];
  12912. } else {
  12913. result0 = null;
  12914. pos = pos0;
  12915. }
  12916. } else {
  12917. result0 = null;
  12918. pos = pos0;
  12919. }
  12920. } else {
  12921. result0 = null;
  12922. pos = pos0;
  12923. }
  12924. } else {
  12925. result0 = null;
  12926. pos = pos0;
  12927. }
  12928. return result0;
  12929. }
  12930. function parse_hex8() {
  12931. var result0, result1;
  12932. var pos0;
  12933. pos0 = pos;
  12934. result0 = parse_hex4();
  12935. if (result0 !== null) {
  12936. result1 = parse_hex4();
  12937. if (result1 !== null) {
  12938. result0 = [result0, result1];
  12939. } else {
  12940. result0 = null;
  12941. pos = pos0;
  12942. }
  12943. } else {
  12944. result0 = null;
  12945. pos = pos0;
  12946. }
  12947. return result0;
  12948. }
  12949. function parse_hex12() {
  12950. var result0, result1, result2;
  12951. var pos0;
  12952. pos0 = pos;
  12953. result0 = parse_hex4();
  12954. if (result0 !== null) {
  12955. result1 = parse_hex4();
  12956. if (result1 !== null) {
  12957. result2 = parse_hex4();
  12958. if (result2 !== null) {
  12959. result0 = [result0, result1, result2];
  12960. } else {
  12961. result0 = null;
  12962. pos = pos0;
  12963. }
  12964. } else {
  12965. result0 = null;
  12966. pos = pos0;
  12967. }
  12968. } else {
  12969. result0 = null;
  12970. pos = pos0;
  12971. }
  12972. return result0;
  12973. }
  12974. function parse_Refer_To() {
  12975. var result0, result1, result2, result3;
  12976. var pos0, pos1, pos2;
  12977. pos0 = pos;
  12978. pos1 = pos;
  12979. result0 = parse_SIP_URI_noparams();
  12980. if (result0 === null) {
  12981. result0 = parse_name_addr();
  12982. }
  12983. if (result0 !== null) {
  12984. result1 = [];
  12985. pos2 = pos;
  12986. result2 = parse_SEMI();
  12987. if (result2 !== null) {
  12988. result3 = parse_generic_param();
  12989. if (result3 !== null) {
  12990. result2 = [result2, result3];
  12991. } else {
  12992. result2 = null;
  12993. pos = pos2;
  12994. }
  12995. } else {
  12996. result2 = null;
  12997. pos = pos2;
  12998. }
  12999. while (result2 !== null) {
  13000. result1.push(result2);
  13001. pos2 = pos;
  13002. result2 = parse_SEMI();
  13003. if (result2 !== null) {
  13004. result3 = parse_generic_param();
  13005. if (result3 !== null) {
  13006. result2 = [result2, result3];
  13007. } else {
  13008. result2 = null;
  13009. pos = pos2;
  13010. }
  13011. } else {
  13012. result2 = null;
  13013. pos = pos2;
  13014. }
  13015. }
  13016. if (result1 !== null) {
  13017. result0 = [result0, result1];
  13018. } else {
  13019. result0 = null;
  13020. pos = pos1;
  13021. }
  13022. } else {
  13023. result0 = null;
  13024. pos = pos1;
  13025. }
  13026. if (result0 !== null) {
  13027. result0 = function (offset) {
  13028. try {
  13029. data = new NameAddrHeader(data.uri, data.display_name, data.params);
  13030. } catch (e) {
  13031. data = -1;
  13032. }
  13033. }(pos0);
  13034. }
  13035. if (result0 === null) {
  13036. pos = pos0;
  13037. }
  13038. return result0;
  13039. }
  13040. function parse_Replaces() {
  13041. var result0, result1, result2, result3;
  13042. var pos0, pos1;
  13043. pos0 = pos;
  13044. result0 = parse_call_id();
  13045. if (result0 !== null) {
  13046. result1 = [];
  13047. pos1 = pos;
  13048. result2 = parse_SEMI();
  13049. if (result2 !== null) {
  13050. result3 = parse_replaces_param();
  13051. if (result3 !== null) {
  13052. result2 = [result2, result3];
  13053. } else {
  13054. result2 = null;
  13055. pos = pos1;
  13056. }
  13057. } else {
  13058. result2 = null;
  13059. pos = pos1;
  13060. }
  13061. while (result2 !== null) {
  13062. result1.push(result2);
  13063. pos1 = pos;
  13064. result2 = parse_SEMI();
  13065. if (result2 !== null) {
  13066. result3 = parse_replaces_param();
  13067. if (result3 !== null) {
  13068. result2 = [result2, result3];
  13069. } else {
  13070. result2 = null;
  13071. pos = pos1;
  13072. }
  13073. } else {
  13074. result2 = null;
  13075. pos = pos1;
  13076. }
  13077. }
  13078. if (result1 !== null) {
  13079. result0 = [result0, result1];
  13080. } else {
  13081. result0 = null;
  13082. pos = pos0;
  13083. }
  13084. } else {
  13085. result0 = null;
  13086. pos = pos0;
  13087. }
  13088. return result0;
  13089. }
  13090. function parse_call_id() {
  13091. var result0, result1, result2;
  13092. var pos0, pos1, pos2;
  13093. pos0 = pos;
  13094. pos1 = pos;
  13095. result0 = parse_word();
  13096. if (result0 !== null) {
  13097. pos2 = pos;
  13098. if (input.charCodeAt(pos) === 64) {
  13099. result1 = "@";
  13100. pos++;
  13101. } else {
  13102. result1 = null;
  13103. if (reportFailures === 0) {
  13104. matchFailed("\"@\"");
  13105. }
  13106. }
  13107. if (result1 !== null) {
  13108. result2 = parse_word();
  13109. if (result2 !== null) {
  13110. result1 = [result1, result2];
  13111. } else {
  13112. result1 = null;
  13113. pos = pos2;
  13114. }
  13115. } else {
  13116. result1 = null;
  13117. pos = pos2;
  13118. }
  13119. result1 = result1 !== null ? result1 : "";
  13120. if (result1 !== null) {
  13121. result0 = [result0, result1];
  13122. } else {
  13123. result0 = null;
  13124. pos = pos1;
  13125. }
  13126. } else {
  13127. result0 = null;
  13128. pos = pos1;
  13129. }
  13130. if (result0 !== null) {
  13131. result0 = function (offset) {
  13132. data.call_id = input.substring(pos, offset);
  13133. }(pos0);
  13134. }
  13135. if (result0 === null) {
  13136. pos = pos0;
  13137. }
  13138. return result0;
  13139. }
  13140. function parse_replaces_param() {
  13141. var result0;
  13142. result0 = parse_to_tag();
  13143. if (result0 === null) {
  13144. result0 = parse_from_tag();
  13145. if (result0 === null) {
  13146. result0 = parse_early_flag();
  13147. if (result0 === null) {
  13148. result0 = parse_generic_param();
  13149. }
  13150. }
  13151. }
  13152. return result0;
  13153. }
  13154. function parse_to_tag() {
  13155. var result0, result1, result2;
  13156. var pos0, pos1;
  13157. pos0 = pos;
  13158. pos1 = pos;
  13159. if (input.substr(pos, 6) === "to-tag") {
  13160. result0 = "to-tag";
  13161. pos += 6;
  13162. } else {
  13163. result0 = null;
  13164. if (reportFailures === 0) {
  13165. matchFailed("\"to-tag\"");
  13166. }
  13167. }
  13168. if (result0 !== null) {
  13169. result1 = parse_EQUAL();
  13170. if (result1 !== null) {
  13171. result2 = parse_token();
  13172. if (result2 !== null) {
  13173. result0 = [result0, result1, result2];
  13174. } else {
  13175. result0 = null;
  13176. pos = pos1;
  13177. }
  13178. } else {
  13179. result0 = null;
  13180. pos = pos1;
  13181. }
  13182. } else {
  13183. result0 = null;
  13184. pos = pos1;
  13185. }
  13186. if (result0 !== null) {
  13187. result0 = function (offset, to_tag) {
  13188. data.to_tag = to_tag;
  13189. }(pos0, result0[2]);
  13190. }
  13191. if (result0 === null) {
  13192. pos = pos0;
  13193. }
  13194. return result0;
  13195. }
  13196. function parse_from_tag() {
  13197. var result0, result1, result2;
  13198. var pos0, pos1;
  13199. pos0 = pos;
  13200. pos1 = pos;
  13201. if (input.substr(pos, 8) === "from-tag") {
  13202. result0 = "from-tag";
  13203. pos += 8;
  13204. } else {
  13205. result0 = null;
  13206. if (reportFailures === 0) {
  13207. matchFailed("\"from-tag\"");
  13208. }
  13209. }
  13210. if (result0 !== null) {
  13211. result1 = parse_EQUAL();
  13212. if (result1 !== null) {
  13213. result2 = parse_token();
  13214. if (result2 !== null) {
  13215. result0 = [result0, result1, result2];
  13216. } else {
  13217. result0 = null;
  13218. pos = pos1;
  13219. }
  13220. } else {
  13221. result0 = null;
  13222. pos = pos1;
  13223. }
  13224. } else {
  13225. result0 = null;
  13226. pos = pos1;
  13227. }
  13228. if (result0 !== null) {
  13229. result0 = function (offset, from_tag) {
  13230. data.from_tag = from_tag;
  13231. }(pos0, result0[2]);
  13232. }
  13233. if (result0 === null) {
  13234. pos = pos0;
  13235. }
  13236. return result0;
  13237. }
  13238. function parse_early_flag() {
  13239. var result0;
  13240. var pos0;
  13241. pos0 = pos;
  13242. if (input.substr(pos, 10) === "early-only") {
  13243. result0 = "early-only";
  13244. pos += 10;
  13245. } else {
  13246. result0 = null;
  13247. if (reportFailures === 0) {
  13248. matchFailed("\"early-only\"");
  13249. }
  13250. }
  13251. if (result0 !== null) {
  13252. result0 = function (offset) {
  13253. data.early_only = true;
  13254. }(pos0);
  13255. }
  13256. if (result0 === null) {
  13257. pos = pos0;
  13258. }
  13259. return result0;
  13260. }
  13261. function cleanupExpected(expected) {
  13262. expected.sort();
  13263. var lastExpected = null;
  13264. var cleanExpected = [];
  13265. for (var i = 0; i < expected.length; i++) {
  13266. if (expected[i] !== lastExpected) {
  13267. cleanExpected.push(expected[i]);
  13268. lastExpected = expected[i];
  13269. }
  13270. }
  13271. return cleanExpected;
  13272. }
  13273. function computeErrorPosition() {
  13274. /*
  13275. * The first idea was to use |String.split| to break the input up to the
  13276. * error position along newlines and derive the line and column from
  13277. * there. However IE's |split| implementation is so broken that it was
  13278. * enough to prevent it.
  13279. */
  13280. var line = 1;
  13281. var column = 1;
  13282. var seenCR = false;
  13283. for (var i = 0; i < Math.max(pos, rightmostFailuresPos); i++) {
  13284. var ch = input.charAt(i);
  13285. if (ch === "\n") {
  13286. if (!seenCR) {
  13287. line++;
  13288. }
  13289. column = 1;
  13290. seenCR = false;
  13291. } else if (ch === "\r" || ch === "\u2028" || ch === "\u2029") {
  13292. line++;
  13293. column = 1;
  13294. seenCR = true;
  13295. } else {
  13296. column++;
  13297. seenCR = false;
  13298. }
  13299. }
  13300. return {
  13301. line: line,
  13302. column: column
  13303. };
  13304. }
  13305. var URI = require('./URI');
  13306. var NameAddrHeader = require('./NameAddrHeader');
  13307. var data = {};
  13308. var result = parseFunctions[startRule]();
  13309. /*
  13310. * The parser is now in one of the following three states:
  13311. *
  13312. * 1. The parser successfully parsed the whole input.
  13313. *
  13314. * - |result !== null|
  13315. * - |pos === input.length|
  13316. * - |rightmostFailuresExpected| may or may not contain something
  13317. *
  13318. * 2. The parser successfully parsed only a part of the input.
  13319. *
  13320. * - |result !== null|
  13321. * - |pos < input.length|
  13322. * - |rightmostFailuresExpected| may or may not contain something
  13323. *
  13324. * 3. The parser did not successfully parse any part of the input.
  13325. *
  13326. * - |result === null|
  13327. * - |pos === 0|
  13328. * - |rightmostFailuresExpected| contains at least one failure
  13329. *
  13330. * All code following this comment (including called functions) must
  13331. * handle these states.
  13332. */
  13333. if (result === null || pos !== input.length) {
  13334. var offset = Math.max(pos, rightmostFailuresPos);
  13335. var found = offset < input.length ? input.charAt(offset) : null;
  13336. var errorPosition = computeErrorPosition();
  13337. new this.SyntaxError(cleanupExpected(rightmostFailuresExpected), found, offset, errorPosition.line, errorPosition.column);
  13338. return -1;
  13339. }
  13340. return data;
  13341. },
  13342. /* Returns the parser source code. */
  13343. toSource: function toSource() {
  13344. return this._source;
  13345. }
  13346. };
  13347. /* Thrown when a parser encounters a syntax error. */
  13348. result.SyntaxError = function (expected, found, offset, line, column) {
  13349. function buildMessage(expected, found) {
  13350. var expectedHumanized, foundHumanized;
  13351. switch (expected.length) {
  13352. case 0:
  13353. expectedHumanized = "end of input";
  13354. break;
  13355. case 1:
  13356. expectedHumanized = expected[0];
  13357. break;
  13358. default:
  13359. expectedHumanized = expected.slice(0, expected.length - 1).join(", ") + " or " + expected[expected.length - 1];
  13360. }
  13361. foundHumanized = found ? quote(found) : "end of input";
  13362. return "Expected " + expectedHumanized + " but " + foundHumanized + " found.";
  13363. }
  13364. this.name = "SyntaxError";
  13365. this.expected = expected;
  13366. this.found = found;
  13367. this.message = buildMessage(expected, found);
  13368. this.offset = offset;
  13369. this.line = line;
  13370. this.column = column;
  13371. };
  13372. result.SyntaxError.prototype = Error.prototype;
  13373. return result;
  13374. }();
  13375. },{"./NameAddrHeader":10,"./URI":25}],8:[function(require,module,exports){
  13376. "use strict";
  13377. var pkg = require('../package.json');
  13378. var C = require('./Constants');
  13379. var Exceptions = require('./Exceptions');
  13380. var Utils = require('./Utils');
  13381. var UA = require('./UA');
  13382. var URI = require('./URI');
  13383. var NameAddrHeader = require('./NameAddrHeader');
  13384. var Grammar = require('./Grammar');
  13385. var WebSocketInterface = require('./WebSocketInterface');
  13386. var debug = require('debug')('JsSIP');
  13387. debug('version %s', pkg.version);
  13388. /**
  13389. * Expose the JsSIP module.
  13390. */
  13391. module.exports = {
  13392. C: C,
  13393. Exceptions: Exceptions,
  13394. Utils: Utils,
  13395. UA: UA,
  13396. URI: URI,
  13397. NameAddrHeader: NameAddrHeader,
  13398. WebSocketInterface: WebSocketInterface,
  13399. Grammar: Grammar,
  13400. // Expose the debug module.
  13401. debug: require('debug'),
  13402. get name() {
  13403. return pkg.title;
  13404. },
  13405. get version() {
  13406. return pkg.version;
  13407. }
  13408. };
  13409. },{"../package.json":38,"./Constants":2,"./Exceptions":6,"./Grammar":7,"./NameAddrHeader":10,"./UA":24,"./URI":25,"./Utils":26,"./WebSocketInterface":27,"debug":30}],9:[function(require,module,exports){
  13410. "use strict";
  13411. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  13412. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13413. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13414. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13415. function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  13416. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  13417. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  13418. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  13419. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  13420. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  13421. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  13422. var EventEmitter = require('events').EventEmitter;
  13423. var JsSIP_C = require('./Constants');
  13424. var SIPMessage = require('./SIPMessage');
  13425. var Utils = require('./Utils');
  13426. var RequestSender = require('./RequestSender');
  13427. var Exceptions = require('./Exceptions');
  13428. var debug = require('debug')('JsSIP:Message');
  13429. module.exports = /*#__PURE__*/function (_EventEmitter) {
  13430. _inherits(Message, _EventEmitter);
  13431. var _super = _createSuper(Message);
  13432. function Message(ua) {
  13433. var _this;
  13434. _classCallCheck(this, Message);
  13435. _this = _super.call(this);
  13436. _this._ua = ua;
  13437. _this._request = null;
  13438. _this._closed = false;
  13439. _this._direction = null;
  13440. _this._local_identity = null;
  13441. _this._remote_identity = null; // Whether an incoming message has been replied.
  13442. _this._is_replied = false; // Custom message empty object for high level use.
  13443. _this._data = {};
  13444. return _this;
  13445. }
  13446. _createClass(Message, [{
  13447. key: "send",
  13448. value: function send(target, body) {
  13449. var _this2 = this;
  13450. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  13451. var originalTarget = target;
  13452. if (target === undefined || body === undefined) {
  13453. throw new TypeError('Not enough arguments');
  13454. } // Check target validity.
  13455. target = this._ua.normalizeTarget(target);
  13456. if (!target) {
  13457. throw new TypeError("Invalid target: ".concat(originalTarget));
  13458. } // Get call options.
  13459. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  13460. var eventHandlers = Utils.cloneObject(options.eventHandlers);
  13461. var contentType = options.contentType || 'text/plain'; // Set event handlers.
  13462. for (var event in eventHandlers) {
  13463. if (Object.prototype.hasOwnProperty.call(eventHandlers, event)) {
  13464. this.on(event, eventHandlers[event]);
  13465. }
  13466. }
  13467. extraHeaders.push("Content-Type: ".concat(contentType));
  13468. this._request = new SIPMessage.OutgoingRequest(JsSIP_C.MESSAGE, target, this._ua, null, extraHeaders);
  13469. if (body) {
  13470. this._request.body = body;
  13471. }
  13472. var request_sender = new RequestSender(this._ua, this._request, {
  13473. onRequestTimeout: function onRequestTimeout() {
  13474. _this2._onRequestTimeout();
  13475. },
  13476. onTransportError: function onTransportError() {
  13477. _this2._onTransportError();
  13478. },
  13479. onReceiveResponse: function onReceiveResponse(response) {
  13480. _this2._receiveResponse(response);
  13481. }
  13482. });
  13483. this._newMessage('local', this._request);
  13484. request_sender.send();
  13485. }
  13486. }, {
  13487. key: "init_incoming",
  13488. value: function init_incoming(request) {
  13489. this._request = request;
  13490. this._newMessage('remote', request); // Reply with a 200 OK if the user didn't reply.
  13491. if (!this._is_replied) {
  13492. this._is_replied = true;
  13493. request.reply(200);
  13494. }
  13495. this._close();
  13496. }
  13497. /**
  13498. * Accept the incoming Message
  13499. * Only valid for incoming Messages
  13500. */
  13501. }, {
  13502. key: "accept",
  13503. value: function accept() {
  13504. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  13505. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  13506. var body = options.body;
  13507. if (this._direction !== 'incoming') {
  13508. throw new Exceptions.NotSupportedError('"accept" not supported for outgoing Message');
  13509. }
  13510. if (this._is_replied) {
  13511. throw new Error('incoming Message already replied');
  13512. }
  13513. this._is_replied = true;
  13514. this._request.reply(200, null, extraHeaders, body);
  13515. }
  13516. /**
  13517. * Reject the incoming Message
  13518. * Only valid for incoming Messages
  13519. */
  13520. }, {
  13521. key: "reject",
  13522. value: function reject() {
  13523. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  13524. var status_code = options.status_code || 480;
  13525. var reason_phrase = options.reason_phrase;
  13526. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  13527. var body = options.body;
  13528. if (this._direction !== 'incoming') {
  13529. throw new Exceptions.NotSupportedError('"reject" not supported for outgoing Message');
  13530. }
  13531. if (this._is_replied) {
  13532. throw new Error('incoming Message already replied');
  13533. }
  13534. if (status_code < 300 || status_code >= 700) {
  13535. throw new TypeError("Invalid status_code: ".concat(status_code));
  13536. }
  13537. this._is_replied = true;
  13538. this._request.reply(status_code, reason_phrase, extraHeaders, body);
  13539. }
  13540. }, {
  13541. key: "_receiveResponse",
  13542. value: function _receiveResponse(response) {
  13543. if (this._closed) {
  13544. return;
  13545. }
  13546. switch (true) {
  13547. case /^1[0-9]{2}$/.test(response.status_code):
  13548. // Ignore provisional responses.
  13549. break;
  13550. case /^2[0-9]{2}$/.test(response.status_code):
  13551. this._succeeded('remote', response);
  13552. break;
  13553. default:
  13554. {
  13555. var cause = Utils.sipErrorCause(response.status_code);
  13556. this._failed('remote', response, cause);
  13557. break;
  13558. }
  13559. }
  13560. }
  13561. }, {
  13562. key: "_onRequestTimeout",
  13563. value: function _onRequestTimeout() {
  13564. if (this._closed) {
  13565. return;
  13566. }
  13567. this._failed('system', null, JsSIP_C.causes.REQUEST_TIMEOUT);
  13568. }
  13569. }, {
  13570. key: "_onTransportError",
  13571. value: function _onTransportError() {
  13572. if (this._closed) {
  13573. return;
  13574. }
  13575. this._failed('system', null, JsSIP_C.causes.CONNECTION_ERROR);
  13576. }
  13577. }, {
  13578. key: "_close",
  13579. value: function _close() {
  13580. this._closed = true;
  13581. this._ua.destroyMessage(this);
  13582. }
  13583. /**
  13584. * Internal Callbacks
  13585. */
  13586. }, {
  13587. key: "_newMessage",
  13588. value: function _newMessage(originator, request) {
  13589. if (originator === 'remote') {
  13590. this._direction = 'incoming';
  13591. this._local_identity = request.to;
  13592. this._remote_identity = request.from;
  13593. } else if (originator === 'local') {
  13594. this._direction = 'outgoing';
  13595. this._local_identity = request.from;
  13596. this._remote_identity = request.to;
  13597. }
  13598. this._ua.newMessage(this, {
  13599. originator: originator,
  13600. message: this,
  13601. request: request
  13602. });
  13603. }
  13604. }, {
  13605. key: "_failed",
  13606. value: function _failed(originator, response, cause) {
  13607. debug('MESSAGE failed');
  13608. this._close();
  13609. debug('emit "failed"');
  13610. this.emit('failed', {
  13611. originator: originator,
  13612. response: response || null,
  13613. cause: cause
  13614. });
  13615. }
  13616. }, {
  13617. key: "_succeeded",
  13618. value: function _succeeded(originator, response) {
  13619. debug('MESSAGE succeeded');
  13620. this._close();
  13621. debug('emit "succeeded"');
  13622. this.emit('succeeded', {
  13623. originator: originator,
  13624. response: response
  13625. });
  13626. }
  13627. }, {
  13628. key: "direction",
  13629. get: function get() {
  13630. return this._direction;
  13631. }
  13632. }, {
  13633. key: "local_identity",
  13634. get: function get() {
  13635. return this._local_identity;
  13636. }
  13637. }, {
  13638. key: "remote_identity",
  13639. get: function get() {
  13640. return this._remote_identity;
  13641. }
  13642. }]);
  13643. return Message;
  13644. }(EventEmitter);
  13645. },{"./Constants":2,"./Exceptions":6,"./RequestSender":18,"./SIPMessage":19,"./Utils":26,"debug":30,"events":29}],10:[function(require,module,exports){
  13646. "use strict";
  13647. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  13648. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  13649. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  13650. var URI = require('./URI');
  13651. var Grammar = require('./Grammar');
  13652. module.exports = /*#__PURE__*/function () {
  13653. _createClass(NameAddrHeader, null, [{
  13654. key: "parse",
  13655. /**
  13656. * Parse the given string and returns a NameAddrHeader instance or undefined if
  13657. * it is an invalid NameAddrHeader.
  13658. */
  13659. value: function parse(name_addr_header) {
  13660. name_addr_header = Grammar.parse(name_addr_header, 'Name_Addr_Header');
  13661. if (name_addr_header !== -1) {
  13662. return name_addr_header;
  13663. } else {
  13664. return undefined;
  13665. }
  13666. }
  13667. }]);
  13668. function NameAddrHeader(uri, display_name, parameters) {
  13669. _classCallCheck(this, NameAddrHeader);
  13670. // Checks.
  13671. if (!uri || !(uri instanceof URI)) {
  13672. throw new TypeError('missing or invalid "uri" parameter');
  13673. } // Initialize parameters.
  13674. this._uri = uri;
  13675. this._parameters = {};
  13676. this.display_name = display_name;
  13677. for (var param in parameters) {
  13678. if (Object.prototype.hasOwnProperty.call(parameters, param)) {
  13679. this.setParam(param, parameters[param]);
  13680. }
  13681. }
  13682. }
  13683. _createClass(NameAddrHeader, [{
  13684. key: "setParam",
  13685. value: function setParam(key, value) {
  13686. if (key) {
  13687. this._parameters[key.toLowerCase()] = typeof value === 'undefined' || value === null ? null : value.toString();
  13688. }
  13689. }
  13690. }, {
  13691. key: "getParam",
  13692. value: function getParam(key) {
  13693. if (key) {
  13694. return this._parameters[key.toLowerCase()];
  13695. }
  13696. }
  13697. }, {
  13698. key: "hasParam",
  13699. value: function hasParam(key) {
  13700. if (key) {
  13701. return this._parameters.hasOwnProperty(key.toLowerCase()) && true || false;
  13702. }
  13703. }
  13704. }, {
  13705. key: "deleteParam",
  13706. value: function deleteParam(parameter) {
  13707. parameter = parameter.toLowerCase();
  13708. if (this._parameters.hasOwnProperty(parameter)) {
  13709. var value = this._parameters[parameter];
  13710. delete this._parameters[parameter];
  13711. return value;
  13712. }
  13713. }
  13714. }, {
  13715. key: "clearParams",
  13716. value: function clearParams() {
  13717. this._parameters = {};
  13718. }
  13719. }, {
  13720. key: "clone",
  13721. value: function clone() {
  13722. return new NameAddrHeader(this._uri.clone(), this._display_name, JSON.parse(JSON.stringify(this._parameters)));
  13723. }
  13724. }, {
  13725. key: "_quote",
  13726. value: function _quote(str) {
  13727. return str.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
  13728. }
  13729. }, {
  13730. key: "toString",
  13731. value: function toString() {
  13732. var body = this._display_name ? "\"".concat(this._quote(this._display_name), "\" ") : '';
  13733. body += "<".concat(this._uri.toString(), ">");
  13734. for (var parameter in this._parameters) {
  13735. if (Object.prototype.hasOwnProperty.call(this._parameters, parameter)) {
  13736. body += ";".concat(parameter);
  13737. if (this._parameters[parameter] !== null) {
  13738. body += "=".concat(this._parameters[parameter]);
  13739. }
  13740. }
  13741. }
  13742. return body;
  13743. }
  13744. }, {
  13745. key: "uri",
  13746. get: function get() {
  13747. return this._uri;
  13748. }
  13749. }, {
  13750. key: "display_name",
  13751. get: function get() {
  13752. return this._display_name;
  13753. },
  13754. set: function set(value) {
  13755. this._display_name = value === 0 ? '0' : value;
  13756. }
  13757. }]);
  13758. return NameAddrHeader;
  13759. }();
  13760. },{"./Grammar":7,"./URI":25}],11:[function(require,module,exports){
  13761. "use strict";
  13762. function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  13763. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  13764. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  13765. var Grammar = require('./Grammar');
  13766. var SIPMessage = require('./SIPMessage');
  13767. var debugerror = require('debug')('JsSIP:ERROR:Parser');
  13768. debugerror.log = console.warn.bind(console);
  13769. /**
  13770. * Parse SIP Message
  13771. */
  13772. exports.parseMessage = function (data, ua) {
  13773. var message;
  13774. var bodyStart;
  13775. var headerEnd = data.indexOf('\r\n');
  13776. if (headerEnd === -1) {
  13777. debugerror('parseMessage() | no CRLF found, not a SIP message');
  13778. return;
  13779. } // Parse first line. Check if it is a Request or a Reply.
  13780. var firstLine = data.substring(0, headerEnd);
  13781. var parsed = Grammar.parse(firstLine, 'Request_Response');
  13782. if (parsed === -1) {
  13783. debugerror("parseMessage() | error parsing first line of SIP message: \"".concat(firstLine, "\""));
  13784. return;
  13785. } else if (!parsed.status_code) {
  13786. message = new SIPMessage.IncomingRequest(ua);
  13787. message.method = parsed.method;
  13788. message.ruri = parsed.uri;
  13789. } else {
  13790. message = new SIPMessage.IncomingResponse();
  13791. message.status_code = parsed.status_code;
  13792. message.reason_phrase = parsed.reason_phrase;
  13793. }
  13794. message.data = data;
  13795. var headerStart = headerEnd + 2;
  13796. /* Loop over every line in data. Detect the end of each header and parse
  13797. * it or simply add to the headers collection.
  13798. */
  13799. while (true) {
  13800. headerEnd = getHeader(data, headerStart); // The SIP message has normally finished.
  13801. if (headerEnd === -2) {
  13802. bodyStart = headerStart + 2;
  13803. break;
  13804. } // Data.indexOf returned -1 due to a malformed message.
  13805. else if (headerEnd === -1) {
  13806. debugerror('parseMessage() | malformed message');
  13807. return;
  13808. }
  13809. parsed = parseHeader(message, data, headerStart, headerEnd);
  13810. if (parsed !== true) {
  13811. debugerror('parseMessage() |', parsed.error);
  13812. return;
  13813. }
  13814. headerStart = headerEnd + 2;
  13815. }
  13816. /* RFC3261 18.3.
  13817. * If there are additional bytes in the transport packet
  13818. * beyond the end of the body, they MUST be discarded.
  13819. */
  13820. if (message.hasHeader('content-length')) {
  13821. var contentLength = message.getHeader('content-length');
  13822. message.body = data.substr(bodyStart, contentLength);
  13823. } else {
  13824. message.body = data.substring(bodyStart);
  13825. }
  13826. return message;
  13827. };
  13828. /**
  13829. * Extract and parse every header of a SIP message.
  13830. */
  13831. function getHeader(data, headerStart) {
  13832. // 'start' position of the header.
  13833. var start = headerStart; // 'end' position of the header.
  13834. var end = 0; // 'partial end' position of the header.
  13835. var partialEnd = 0; // End of message.
  13836. if (data.substring(start, start + 2).match(/(^\r\n)/)) {
  13837. return -2;
  13838. }
  13839. while (end === 0) {
  13840. // Partial End of Header.
  13841. partialEnd = data.indexOf('\r\n', start); // 'indexOf' returns -1 if the value to be found never occurs.
  13842. if (partialEnd === -1) {
  13843. return partialEnd;
  13844. }
  13845. if (!data.substring(partialEnd + 2, partialEnd + 4).match(/(^\r\n)/) && data.charAt(partialEnd + 2).match(/(^\s+)/)) {
  13846. // Not the end of the message. Continue from the next position.
  13847. start = partialEnd + 2;
  13848. } else {
  13849. end = partialEnd;
  13850. }
  13851. }
  13852. return end;
  13853. }
  13854. function parseHeader(message, data, headerStart, headerEnd) {
  13855. var parsed;
  13856. var hcolonIndex = data.indexOf(':', headerStart);
  13857. var headerName = data.substring(headerStart, hcolonIndex).trim();
  13858. var headerValue = data.substring(hcolonIndex + 1, headerEnd).trim(); // If header-field is well-known, parse it.
  13859. switch (headerName.toLowerCase()) {
  13860. case 'via':
  13861. case 'v':
  13862. message.addHeader('via', headerValue);
  13863. if (message.getHeaders('via').length === 1) {
  13864. parsed = message.parseHeader('Via');
  13865. if (parsed) {
  13866. message.via = parsed;
  13867. message.via_branch = parsed.branch;
  13868. }
  13869. } else {
  13870. parsed = 0;
  13871. }
  13872. break;
  13873. case 'from':
  13874. case 'f':
  13875. message.setHeader('from', headerValue);
  13876. parsed = message.parseHeader('from');
  13877. if (parsed) {
  13878. message.from = parsed;
  13879. message.from_tag = parsed.getParam('tag');
  13880. }
  13881. break;
  13882. case 'to':
  13883. case 't':
  13884. message.setHeader('to', headerValue);
  13885. parsed = message.parseHeader('to');
  13886. if (parsed) {
  13887. message.to = parsed;
  13888. message.to_tag = parsed.getParam('tag');
  13889. }
  13890. break;
  13891. case 'record-route':
  13892. parsed = Grammar.parse(headerValue, 'Record_Route');
  13893. if (parsed === -1) {
  13894. parsed = undefined;
  13895. } else {
  13896. var _iterator = _createForOfIteratorHelper(parsed),
  13897. _step;
  13898. try {
  13899. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  13900. var header = _step.value;
  13901. message.addHeader('record-route', headerValue.substring(header.possition, header.offset));
  13902. message.headers['Record-Route'][message.getHeaders('record-route').length - 1].parsed = header.parsed;
  13903. }
  13904. } catch (err) {
  13905. _iterator.e(err);
  13906. } finally {
  13907. _iterator.f();
  13908. }
  13909. }
  13910. break;
  13911. case 'call-id':
  13912. case 'i':
  13913. message.setHeader('call-id', headerValue);
  13914. parsed = message.parseHeader('call-id');
  13915. if (parsed) {
  13916. message.call_id = headerValue;
  13917. }
  13918. break;
  13919. case 'contact':
  13920. case 'm':
  13921. parsed = Grammar.parse(headerValue, 'Contact');
  13922. if (parsed === -1) {
  13923. parsed = undefined;
  13924. } else {
  13925. var _iterator2 = _createForOfIteratorHelper(parsed),
  13926. _step2;
  13927. try {
  13928. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  13929. var _header = _step2.value;
  13930. message.addHeader('contact', headerValue.substring(_header.possition, _header.offset));
  13931. message.headers.Contact[message.getHeaders('contact').length - 1].parsed = _header.parsed;
  13932. }
  13933. } catch (err) {
  13934. _iterator2.e(err);
  13935. } finally {
  13936. _iterator2.f();
  13937. }
  13938. }
  13939. break;
  13940. case 'content-length':
  13941. case 'l':
  13942. message.setHeader('content-length', headerValue);
  13943. parsed = message.parseHeader('content-length');
  13944. break;
  13945. case 'content-type':
  13946. case 'c':
  13947. message.setHeader('content-type', headerValue);
  13948. parsed = message.parseHeader('content-type');
  13949. break;
  13950. case 'cseq':
  13951. message.setHeader('cseq', headerValue);
  13952. parsed = message.parseHeader('cseq');
  13953. if (parsed) {
  13954. message.cseq = parsed.value;
  13955. }
  13956. if (message instanceof SIPMessage.IncomingResponse) {
  13957. message.method = parsed.method;
  13958. }
  13959. break;
  13960. case 'max-forwards':
  13961. message.setHeader('max-forwards', headerValue);
  13962. parsed = message.parseHeader('max-forwards');
  13963. break;
  13964. case 'www-authenticate':
  13965. message.setHeader('www-authenticate', headerValue);
  13966. parsed = message.parseHeader('www-authenticate');
  13967. break;
  13968. case 'proxy-authenticate':
  13969. message.setHeader('proxy-authenticate', headerValue);
  13970. parsed = message.parseHeader('proxy-authenticate');
  13971. break;
  13972. case 'session-expires':
  13973. case 'x':
  13974. message.setHeader('session-expires', headerValue);
  13975. parsed = message.parseHeader('session-expires');
  13976. if (parsed) {
  13977. message.session_expires = parsed.expires;
  13978. message.session_expires_refresher = parsed.refresher;
  13979. }
  13980. break;
  13981. case 'refer-to':
  13982. case 'r':
  13983. message.setHeader('refer-to', headerValue);
  13984. parsed = message.parseHeader('refer-to');
  13985. if (parsed) {
  13986. message.refer_to = parsed;
  13987. }
  13988. break;
  13989. case 'replaces':
  13990. message.setHeader('replaces', headerValue);
  13991. parsed = message.parseHeader('replaces');
  13992. if (parsed) {
  13993. message.replaces = parsed;
  13994. }
  13995. break;
  13996. case 'event':
  13997. case 'o':
  13998. message.setHeader('event', headerValue);
  13999. parsed = message.parseHeader('event');
  14000. if (parsed) {
  14001. message.event = parsed;
  14002. }
  14003. break;
  14004. default:
  14005. // Do not parse this header.
  14006. message.addHeader(headerName, headerValue);
  14007. parsed = 0;
  14008. }
  14009. if (parsed === undefined) {
  14010. return {
  14011. error: "error parsing header \"".concat(headerName, "\"")
  14012. };
  14013. } else {
  14014. return true;
  14015. }
  14016. }
  14017. },{"./Grammar":7,"./SIPMessage":19,"debug":30}],12:[function(require,module,exports){
  14018. "use strict";
  14019. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  14020. function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  14021. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  14022. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  14023. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  14024. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  14025. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  14026. function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  14027. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  14028. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  14029. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  14030. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  14031. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  14032. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  14033. /* globals RTCPeerConnection: false, RTCSessionDescription: false */
  14034. var EventEmitter = require('events').EventEmitter;
  14035. var sdp_transform = require('sdp-transform');
  14036. var JsSIP_C = require('./Constants');
  14037. var Exceptions = require('./Exceptions');
  14038. var Transactions = require('./Transactions');
  14039. var Utils = require('./Utils');
  14040. var Timers = require('./Timers');
  14041. var SIPMessage = require('./SIPMessage');
  14042. var Dialog = require('./Dialog');
  14043. var RequestSender = require('./RequestSender');
  14044. var RTCSession_DTMF = require('./RTCSession/DTMF');
  14045. var RTCSession_Info = require('./RTCSession/Info');
  14046. var RTCSession_ReferNotifier = require('./RTCSession/ReferNotifier');
  14047. var RTCSession_ReferSubscriber = require('./RTCSession/ReferSubscriber');
  14048. var URI = require('./URI');
  14049. var debug = require('debug')('JsSIP:RTCSession');
  14050. var debugerror = require('debug')('JsSIP:ERROR:RTCSession');
  14051. debugerror.log = console.warn.bind(console);
  14052. var C = {
  14053. // RTCSession states.
  14054. STATUS_NULL: 0,
  14055. STATUS_INVITE_SENT: 1,
  14056. STATUS_1XX_RECEIVED: 2,
  14057. STATUS_INVITE_RECEIVED: 3,
  14058. STATUS_WAITING_FOR_ANSWER: 4,
  14059. STATUS_ANSWERED: 5,
  14060. STATUS_WAITING_FOR_ACK: 6,
  14061. STATUS_CANCELED: 7,
  14062. STATUS_TERMINATED: 8,
  14063. STATUS_CONFIRMED: 9
  14064. };
  14065. /**
  14066. * Local variables.
  14067. */
  14068. var holdMediaTypes = ['audio', 'video'];
  14069. module.exports = /*#__PURE__*/function (_EventEmitter) {
  14070. _inherits(RTCSession, _EventEmitter);
  14071. var _super = _createSuper(RTCSession);
  14072. _createClass(RTCSession, null, [{
  14073. key: "C",
  14074. /**
  14075. * Expose C object.
  14076. */
  14077. get: function get() {
  14078. return C;
  14079. }
  14080. }]);
  14081. function RTCSession(ua) {
  14082. var _this;
  14083. _classCallCheck(this, RTCSession);
  14084. debug('new');
  14085. _this = _super.call(this);
  14086. _this._id = null;
  14087. _this._ua = ua;
  14088. _this._status = C.STATUS_NULL;
  14089. _this._dialog = null;
  14090. _this._earlyDialogs = {};
  14091. _this._contact = null;
  14092. _this._from_tag = null;
  14093. _this._to_tag = null; // The RTCPeerConnection instance (public attribute).
  14094. _this._connection = null; // Prevent races on serial PeerConnction operations.
  14095. _this._connectionPromiseQueue = Promise.resolve(); // Incoming/Outgoing request being currently processed.
  14096. _this._request = null; // Cancel state for initial outgoing request.
  14097. _this._is_canceled = false;
  14098. _this._cancel_reason = ''; // RTCSession confirmation flag.
  14099. _this._is_confirmed = false; // Is late SDP being negotiated.
  14100. _this._late_sdp = false; // Default rtcOfferConstraints and rtcAnswerConstrainsts (passed in connect() or answer()).
  14101. _this._rtcOfferConstraints = null;
  14102. _this._rtcAnswerConstraints = null; // Local MediaStream.
  14103. _this._localMediaStream = null;
  14104. _this._localMediaStreamLocallyGenerated = false; // Flag to indicate PeerConnection ready for new actions.
  14105. _this._rtcReady = true; // SIP Timers.
  14106. _this._timers = {
  14107. ackTimer: null,
  14108. expiresTimer: null,
  14109. invite2xxTimer: null,
  14110. userNoAnswerTimer: null
  14111. }; // Session info.
  14112. _this._direction = null;
  14113. _this._local_identity = null;
  14114. _this._remote_identity = null;
  14115. _this._start_time = null;
  14116. _this._end_time = null;
  14117. _this._tones = null; // Mute/Hold state.
  14118. _this._audioMuted = false;
  14119. _this._videoMuted = false;
  14120. _this._localHold = false;
  14121. _this._remoteHold = false; // Session Timers (RFC 4028).
  14122. _this._sessionTimers = {
  14123. enabled: _this._ua.configuration.session_timers,
  14124. refreshMethod: _this._ua.configuration.session_timers_refresh_method,
  14125. defaultExpires: JsSIP_C.SESSION_EXPIRES,
  14126. currentExpires: null,
  14127. running: false,
  14128. refresher: false,
  14129. timer: null // A setTimeout.
  14130. }; // Map of ReferSubscriber instances indexed by the REFER's CSeq number.
  14131. _this._referSubscribers = {}; // Custom session empty object for high level use.
  14132. _this._data = {};
  14133. return _this;
  14134. }
  14135. /**
  14136. * User API
  14137. */
  14138. // Expose RTCSession constants as a property of the RTCSession instance.
  14139. _createClass(RTCSession, [{
  14140. key: "isInProgress",
  14141. value: function isInProgress() {
  14142. switch (this._status) {
  14143. case C.STATUS_NULL:
  14144. case C.STATUS_INVITE_SENT:
  14145. case C.STATUS_1XX_RECEIVED:
  14146. case C.STATUS_INVITE_RECEIVED:
  14147. case C.STATUS_WAITING_FOR_ANSWER:
  14148. return true;
  14149. default:
  14150. return false;
  14151. }
  14152. }
  14153. }, {
  14154. key: "isEstablished",
  14155. value: function isEstablished() {
  14156. switch (this._status) {
  14157. case C.STATUS_ANSWERED:
  14158. case C.STATUS_WAITING_FOR_ACK:
  14159. case C.STATUS_CONFIRMED:
  14160. return true;
  14161. default:
  14162. return false;
  14163. }
  14164. }
  14165. }, {
  14166. key: "isEnded",
  14167. value: function isEnded() {
  14168. switch (this._status) {
  14169. case C.STATUS_CANCELED:
  14170. case C.STATUS_TERMINATED:
  14171. return true;
  14172. default:
  14173. return false;
  14174. }
  14175. }
  14176. }, {
  14177. key: "isMuted",
  14178. value: function isMuted() {
  14179. return {
  14180. audio: this._audioMuted,
  14181. video: this._videoMuted
  14182. };
  14183. }
  14184. }, {
  14185. key: "isOnHold",
  14186. value: function isOnHold() {
  14187. return {
  14188. local: this._localHold,
  14189. remote: this._remoteHold
  14190. };
  14191. }
  14192. }, {
  14193. key: "connect",
  14194. value: function connect(target) {
  14195. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  14196. var initCallback = arguments.length > 2 ? arguments[2] : undefined;
  14197. debug('connect()');
  14198. var originalTarget = target;
  14199. var eventHandlers = Utils.cloneObject(options.eventHandlers);
  14200. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  14201. var mediaConstraints = Utils.cloneObject(options.mediaConstraints, {
  14202. audio: true,
  14203. video: true
  14204. });
  14205. var mediaStream = options.mediaStream || null;
  14206. var pcConfig = Utils.cloneObject(options.pcConfig, {
  14207. iceServers: []
  14208. });
  14209. var rtcConstraints = options.rtcConstraints || null;
  14210. var rtcOfferConstraints = options.rtcOfferConstraints || null;
  14211. this._rtcOfferConstraints = rtcOfferConstraints;
  14212. this._rtcAnswerConstraints = options.rtcAnswerConstraints || null;
  14213. this._data = options.data || this._data; // Check target.
  14214. if (target === undefined) {
  14215. throw new TypeError('Not enough arguments');
  14216. } // Check Session Status.
  14217. if (this._status !== C.STATUS_NULL) {
  14218. throw new Exceptions.InvalidStateError(this._status);
  14219. } // Check WebRTC support.
  14220. if (!window.RTCPeerConnection) {
  14221. throw new Exceptions.NotSupportedError('WebRTC not supported');
  14222. } // Check target validity.
  14223. target = this._ua.normalizeTarget(target);
  14224. if (!target) {
  14225. throw new TypeError("Invalid target: ".concat(originalTarget));
  14226. } // Session Timers.
  14227. if (this._sessionTimers.enabled) {
  14228. if (Utils.isDecimal(options.sessionTimersExpires)) {
  14229. if (options.sessionTimersExpires >= JsSIP_C.MIN_SESSION_EXPIRES) {
  14230. this._sessionTimers.defaultExpires = options.sessionTimersExpires;
  14231. } else {
  14232. this._sessionTimers.defaultExpires = JsSIP_C.SESSION_EXPIRES;
  14233. }
  14234. }
  14235. } // Set event handlers.
  14236. for (var event in eventHandlers) {
  14237. if (Object.prototype.hasOwnProperty.call(eventHandlers, event)) {
  14238. this.on(event, eventHandlers[event]);
  14239. }
  14240. } // Session parameter initialization.
  14241. this._from_tag = Utils.newTag(); // Set anonymous property.
  14242. var anonymous = options.anonymous || false;
  14243. var requestParams = {
  14244. from_tag: this._from_tag
  14245. };
  14246. this._contact = this._ua.contact.toString({
  14247. anonymous: anonymous,
  14248. outbound: true
  14249. });
  14250. if (anonymous) {
  14251. requestParams.from_display_name = 'Anonymous';
  14252. requestParams.from_uri = new URI('sip', 'anonymous', 'anonymous.invalid');
  14253. extraHeaders.push("P-Preferred-Identity: ".concat(this._ua.configuration.uri.toString()));
  14254. extraHeaders.push('Privacy: id');
  14255. }
  14256. extraHeaders.push("Contact: ".concat(this._contact));
  14257. extraHeaders.push('Content-Type: application/sdp');
  14258. if (this._sessionTimers.enabled) {
  14259. extraHeaders.push("Session-Expires: ".concat(this._sessionTimers.defaultExpires));
  14260. }
  14261. this._request = new SIPMessage.InitialOutgoingInviteRequest(target, this._ua, requestParams, extraHeaders);
  14262. this._id = this._request.call_id + this._from_tag; // Create a new RTCPeerConnection instance.
  14263. this._createRTCConnection(pcConfig, rtcConstraints); // Set internal properties.
  14264. this._direction = 'outgoing';
  14265. this._local_identity = this._request.from;
  14266. this._remote_identity = this._request.to; // User explicitly provided a newRTCSession callback for this session.
  14267. if (initCallback) {
  14268. initCallback(this);
  14269. }
  14270. this._newRTCSession('local', this._request);
  14271. this._sendInitialRequest(mediaConstraints, rtcOfferConstraints, mediaStream);
  14272. }
  14273. }, {
  14274. key: "init_incoming",
  14275. value: function init_incoming(request, initCallback) {
  14276. var _this2 = this;
  14277. debug('init_incoming()');
  14278. var expires;
  14279. var contentType = request.getHeader('Content-Type'); // Check body and content type.
  14280. if (request.body && contentType !== 'application/sdp') {
  14281. request.reply(415);
  14282. return;
  14283. } // Session parameter initialization.
  14284. this._status = C.STATUS_INVITE_RECEIVED;
  14285. this._from_tag = request.from_tag;
  14286. this._id = request.call_id + this._from_tag;
  14287. this._request = request;
  14288. this._contact = this._ua.contact.toString(); // Get the Expires header value if exists.
  14289. if (request.hasHeader('expires')) {
  14290. expires = request.getHeader('expires') * 1000;
  14291. }
  14292. /* Set the to_tag before
  14293. * replying a response code that will create a dialog.
  14294. */
  14295. request.to_tag = Utils.newTag(); // An error on dialog creation will fire 'failed' event.
  14296. if (!this._createDialog(request, 'UAS', true)) {
  14297. request.reply(500, 'Missing Contact header field');
  14298. return;
  14299. }
  14300. if (request.body) {
  14301. this._late_sdp = false;
  14302. } else {
  14303. this._late_sdp = true;
  14304. }
  14305. this._status = C.STATUS_WAITING_FOR_ANSWER; // Set userNoAnswerTimer.
  14306. this._timers.userNoAnswerTimer = setTimeout(function () {
  14307. request.reply(408);
  14308. _this2._failed('local', null, JsSIP_C.causes.NO_ANSWER);
  14309. }, this._ua.configuration.no_answer_timeout);
  14310. /* Set expiresTimer
  14311. * RFC3261 13.3.1
  14312. */
  14313. if (expires) {
  14314. this._timers.expiresTimer = setTimeout(function () {
  14315. if (_this2._status === C.STATUS_WAITING_FOR_ANSWER) {
  14316. request.reply(487);
  14317. _this2._failed('system', null, JsSIP_C.causes.EXPIRES);
  14318. }
  14319. }, expires);
  14320. } // Set internal properties.
  14321. this._direction = 'incoming';
  14322. this._local_identity = request.to;
  14323. this._remote_identity = request.from; // A init callback was specifically defined.
  14324. if (initCallback) {
  14325. initCallback(this);
  14326. } // Fire 'newRTCSession' event.
  14327. this._newRTCSession('remote', request); // The user may have rejected the call in the 'newRTCSession' event.
  14328. if (this._status === C.STATUS_TERMINATED) {
  14329. return;
  14330. } // Reply 180.
  14331. request.reply(180, null, ["Contact: ".concat(this._contact)]); // Fire 'progress' event.
  14332. // TODO: Document that 'response' field in 'progress' event is null for incoming calls.
  14333. this._progress('local', null);
  14334. }
  14335. /**
  14336. * Answer the call.
  14337. */
  14338. }, {
  14339. key: "answer",
  14340. value: function answer() {
  14341. var _this3 = this;
  14342. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  14343. debug('answer()');
  14344. var request = this._request;
  14345. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  14346. var mediaConstraints = Utils.cloneObject(options.mediaConstraints);
  14347. var mediaStream = options.mediaStream || null;
  14348. var pcConfig = Utils.cloneObject(options.pcConfig, {
  14349. iceServers: []
  14350. });
  14351. var rtcConstraints = options.rtcConstraints || null;
  14352. var rtcAnswerConstraints = options.rtcAnswerConstraints || null;
  14353. var rtcOfferConstraints = options.rtcOfferConstraints || {};
  14354. var tracks;
  14355. var peerHasAudioLine = false;
  14356. var peerHasVideoLine = false;
  14357. var peerOffersFullAudio = false;
  14358. var peerOffersFullVideo = false;
  14359. this._rtcAnswerConstraints = rtcAnswerConstraints;
  14360. this._rtcOfferConstraints = options.rtcOfferConstraints || null;
  14361. this._data = options.data || this._data; // Check Session Direction and Status.
  14362. if (this._direction !== 'incoming') {
  14363. throw new Exceptions.NotSupportedError('"answer" not supported for outgoing RTCSession');
  14364. } // Check Session status.
  14365. if (this._status !== C.STATUS_WAITING_FOR_ANSWER) {
  14366. throw new Exceptions.InvalidStateError(this._status);
  14367. } // Session Timers.
  14368. if (this._sessionTimers.enabled) {
  14369. if (Utils.isDecimal(options.sessionTimersExpires)) {
  14370. if (options.sessionTimersExpires >= JsSIP_C.MIN_SESSION_EXPIRES) {
  14371. this._sessionTimers.defaultExpires = options.sessionTimersExpires;
  14372. } else {
  14373. this._sessionTimers.defaultExpires = JsSIP_C.SESSION_EXPIRES;
  14374. }
  14375. }
  14376. }
  14377. this._status = C.STATUS_ANSWERED; // An error on dialog creation will fire 'failed' event.
  14378. if (!this._createDialog(request, 'UAS')) {
  14379. request.reply(500, 'Error creating dialog');
  14380. return;
  14381. }
  14382. clearTimeout(this._timers.userNoAnswerTimer);
  14383. extraHeaders.unshift("Contact: ".concat(this._contact)); // Determine incoming media from incoming SDP offer (if any).
  14384. var sdp = request.parseSDP(); // Make sure sdp.media is an array, not the case if there is only one media.
  14385. if (!Array.isArray(sdp.media)) {
  14386. sdp.media = [sdp.media];
  14387. } // Go through all medias in SDP to find offered capabilities to answer with.
  14388. var _iterator = _createForOfIteratorHelper(sdp.media),
  14389. _step;
  14390. try {
  14391. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  14392. var m = _step.value;
  14393. if (m.type === 'audio') {
  14394. peerHasAudioLine = true;
  14395. if (!m.direction || m.direction === 'sendrecv') {
  14396. peerOffersFullAudio = true;
  14397. }
  14398. }
  14399. if (m.type === 'video') {
  14400. peerHasVideoLine = true;
  14401. if (!m.direction || m.direction === 'sendrecv') {
  14402. peerOffersFullVideo = true;
  14403. }
  14404. }
  14405. } // Remove audio from mediaStream if suggested by mediaConstraints.
  14406. } catch (err) {
  14407. _iterator.e(err);
  14408. } finally {
  14409. _iterator.f();
  14410. }
  14411. if (mediaStream && mediaConstraints.audio === false) {
  14412. tracks = mediaStream.getAudioTracks();
  14413. var _iterator2 = _createForOfIteratorHelper(tracks),
  14414. _step2;
  14415. try {
  14416. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  14417. var track = _step2.value;
  14418. mediaStream.removeTrack(track);
  14419. }
  14420. } catch (err) {
  14421. _iterator2.e(err);
  14422. } finally {
  14423. _iterator2.f();
  14424. }
  14425. } // Remove video from mediaStream if suggested by mediaConstraints.
  14426. if (mediaStream && mediaConstraints.video === false) {
  14427. tracks = mediaStream.getVideoTracks();
  14428. var _iterator3 = _createForOfIteratorHelper(tracks),
  14429. _step3;
  14430. try {
  14431. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  14432. var _track = _step3.value;
  14433. mediaStream.removeTrack(_track);
  14434. }
  14435. } catch (err) {
  14436. _iterator3.e(err);
  14437. } finally {
  14438. _iterator3.f();
  14439. }
  14440. } // Set audio constraints based on incoming stream if not supplied.
  14441. if (!mediaStream && mediaConstraints.audio === undefined) {
  14442. mediaConstraints.audio = peerOffersFullAudio;
  14443. } // Set video constraints based on incoming stream if not supplied.
  14444. if (!mediaStream && mediaConstraints.video === undefined) {
  14445. mediaConstraints.video = peerOffersFullVideo;
  14446. } // Don't ask for audio if the incoming offer has no audio section.
  14447. if (!mediaStream && !peerHasAudioLine && !rtcOfferConstraints.offerToReceiveAudio) {
  14448. mediaConstraints.audio = false;
  14449. } // Don't ask for video if the incoming offer has no video section.
  14450. if (!mediaStream && !peerHasVideoLine && !rtcOfferConstraints.offerToReceiveVideo) {
  14451. mediaConstraints.video = false;
  14452. } // Create a new RTCPeerConnection instance.
  14453. // TODO: This may throw an error, should react.
  14454. this._createRTCConnection(pcConfig, rtcConstraints);
  14455. Promise.resolve() // Handle local MediaStream.
  14456. .then(function () {
  14457. // A local MediaStream is given, use it.
  14458. if (mediaStream) {
  14459. return mediaStream;
  14460. } // Audio and/or video requested, prompt getUserMedia.
  14461. else if (mediaConstraints.audio || mediaConstraints.video) {
  14462. _this3._localMediaStreamLocallyGenerated = true;
  14463. return navigator.mediaDevices.getUserMedia(mediaConstraints)["catch"](function (error) {
  14464. if (_this3._status === C.STATUS_TERMINATED) {
  14465. throw new Error('terminated');
  14466. }
  14467. request.reply(480);
  14468. _this3._failed('local', null, JsSIP_C.causes.USER_DENIED_MEDIA_ACCESS);
  14469. debugerror('emit "getusermediafailed" [error:%o]', error);
  14470. _this3.emit('getusermediafailed', error);
  14471. throw new Error('getUserMedia() failed');
  14472. });
  14473. }
  14474. }) // Attach MediaStream to RTCPeerconnection.
  14475. .then(function (stream) {
  14476. if (_this3._status === C.STATUS_TERMINATED) {
  14477. throw new Error('terminated');
  14478. }
  14479. _this3._localMediaStream = stream;
  14480. if (stream) {
  14481. stream.getTracks().forEach(function (track) {
  14482. _this3._connection.addTrack(track, stream);
  14483. });
  14484. }
  14485. }) // Set remote description.
  14486. .then(function () {
  14487. if (_this3._late_sdp) {
  14488. return;
  14489. }
  14490. var e = {
  14491. originator: 'remote',
  14492. type: 'offer',
  14493. sdp: request.body
  14494. };
  14495. debug('emit "sdp"');
  14496. _this3.emit('sdp', e);
  14497. var offer = new RTCSessionDescription({
  14498. type: 'offer',
  14499. sdp: e.sdp
  14500. });
  14501. _this3._connectionPromiseQueue = _this3._connectionPromiseQueue.then(function () {
  14502. return _this3._connection.setRemoteDescription(offer);
  14503. })["catch"](function (error) {
  14504. request.reply(488);
  14505. _this3._failed('system', null, JsSIP_C.causes.WEBRTC_ERROR);
  14506. debugerror('emit "peerconnection:setremotedescriptionfailed" [error:%o]', error);
  14507. _this3.emit('peerconnection:setremotedescriptionfailed', error);
  14508. throw new Error('peerconnection.setRemoteDescription() failed');
  14509. });
  14510. return _this3._connectionPromiseQueue;
  14511. }) // Create local description.
  14512. .then(function () {
  14513. if (_this3._status === C.STATUS_TERMINATED) {
  14514. throw new Error('terminated');
  14515. } // TODO: Is this event already useful?
  14516. _this3._connecting(request);
  14517. if (!_this3._late_sdp) {
  14518. return _this3._createLocalDescription('answer', rtcAnswerConstraints)["catch"](function () {
  14519. request.reply(500);
  14520. throw new Error('_createLocalDescription() failed');
  14521. });
  14522. } else {
  14523. return _this3._createLocalDescription('offer', _this3._rtcOfferConstraints)["catch"](function () {
  14524. request.reply(500);
  14525. throw new Error('_createLocalDescription() failed');
  14526. });
  14527. }
  14528. }) // Send reply.
  14529. .then(function (desc) {
  14530. if (_this3._status === C.STATUS_TERMINATED) {
  14531. throw new Error('terminated');
  14532. }
  14533. _this3._handleSessionTimersInIncomingRequest(request, extraHeaders);
  14534. request.reply(200, null, extraHeaders, desc, function () {
  14535. _this3._status = C.STATUS_WAITING_FOR_ACK;
  14536. _this3._setInvite2xxTimer(request, desc);
  14537. _this3._setACKTimer();
  14538. _this3._accepted('local');
  14539. }, function () {
  14540. _this3._failed('system', null, JsSIP_C.causes.CONNECTION_ERROR);
  14541. });
  14542. })["catch"](function (error) {
  14543. if (_this3._status === C.STATUS_TERMINATED) {
  14544. return;
  14545. }
  14546. debugerror(error);
  14547. });
  14548. }
  14549. /**
  14550. * Terminate the call.
  14551. */
  14552. }, {
  14553. key: "terminate",
  14554. value: function terminate() {
  14555. var _this4 = this;
  14556. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  14557. debug('terminate()');
  14558. var cause = options.cause || JsSIP_C.causes.BYE;
  14559. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  14560. var body = options.body;
  14561. var cancel_reason;
  14562. var status_code = options.status_code;
  14563. var reason_phrase = options.reason_phrase; // Check Session Status.
  14564. if (this._status === C.STATUS_TERMINATED) {
  14565. throw new Exceptions.InvalidStateError(this._status);
  14566. }
  14567. switch (this._status) {
  14568. // - UAC -
  14569. case C.STATUS_NULL:
  14570. case C.STATUS_INVITE_SENT:
  14571. case C.STATUS_1XX_RECEIVED:
  14572. debug('canceling session');
  14573. if (status_code && (status_code < 200 || status_code >= 700)) {
  14574. throw new TypeError("Invalid status_code: ".concat(status_code));
  14575. } else if (status_code) {
  14576. reason_phrase = reason_phrase || JsSIP_C.REASON_PHRASE[status_code] || '';
  14577. cancel_reason = "SIP ;cause=".concat(status_code, " ;text=\"").concat(reason_phrase, "\"");
  14578. } // Check Session Status.
  14579. if (this._status === C.STATUS_NULL || this._status === C.STATUS_INVITE_SENT) {
  14580. this._is_canceled = true;
  14581. this._cancel_reason = cancel_reason;
  14582. } else if (this._status === C.STATUS_1XX_RECEIVED) {
  14583. this._request.cancel(cancel_reason);
  14584. }
  14585. this._status = C.STATUS_CANCELED;
  14586. this._failed('local', null, JsSIP_C.causes.CANCELED);
  14587. break;
  14588. // - UAS -
  14589. case C.STATUS_WAITING_FOR_ANSWER:
  14590. case C.STATUS_ANSWERED:
  14591. debug('rejecting session');
  14592. status_code = status_code || 480;
  14593. if (status_code < 300 || status_code >= 700) {
  14594. throw new TypeError("Invalid status_code: ".concat(status_code));
  14595. }
  14596. this._request.reply(status_code, reason_phrase, extraHeaders, body);
  14597. this._failed('local', null, JsSIP_C.causes.REJECTED);
  14598. break;
  14599. case C.STATUS_WAITING_FOR_ACK:
  14600. case C.STATUS_CONFIRMED:
  14601. debug('terminating session');
  14602. reason_phrase = options.reason_phrase || JsSIP_C.REASON_PHRASE[status_code] || '';
  14603. if (status_code && (status_code < 200 || status_code >= 700)) {
  14604. throw new TypeError("Invalid status_code: ".concat(status_code));
  14605. } else if (status_code) {
  14606. extraHeaders.push("Reason: SIP ;cause=".concat(status_code, "; text=\"").concat(reason_phrase, "\""));
  14607. }
  14608. /* RFC 3261 section 15 (Terminating a session):
  14609. *
  14610. * "...the callee's UA MUST NOT send a BYE on a confirmed dialog
  14611. * until it has received an ACK for its 2xx response or until the server
  14612. * transaction times out."
  14613. */
  14614. if (this._status === C.STATUS_WAITING_FOR_ACK && this._direction === 'incoming' && this._request.server_transaction.state !== Transactions.C.STATUS_TERMINATED) {
  14615. // Save the dialog for later restoration.
  14616. var dialog = this._dialog; // Send the BYE as soon as the ACK is received...
  14617. this.receiveRequest = function (_ref) {
  14618. var method = _ref.method;
  14619. if (method === JsSIP_C.ACK) {
  14620. _this4.sendRequest(JsSIP_C.BYE, {
  14621. extraHeaders: extraHeaders,
  14622. body: body
  14623. });
  14624. dialog.terminate();
  14625. }
  14626. }; // .., or when the INVITE transaction times out
  14627. this._request.server_transaction.on('stateChanged', function () {
  14628. if (_this4._request.server_transaction.state === Transactions.C.STATUS_TERMINATED) {
  14629. _this4.sendRequest(JsSIP_C.BYE, {
  14630. extraHeaders: extraHeaders,
  14631. body: body
  14632. });
  14633. dialog.terminate();
  14634. }
  14635. });
  14636. this._ended('local', null, cause); // Restore the dialog into 'this' in order to be able to send the in-dialog BYE :-).
  14637. this._dialog = dialog; // Restore the dialog into 'ua' so the ACK can reach 'this' session.
  14638. this._ua.newDialog(dialog);
  14639. } else {
  14640. this.sendRequest(JsSIP_C.BYE, {
  14641. extraHeaders: extraHeaders,
  14642. body: body
  14643. });
  14644. this._ended('local', null, cause);
  14645. }
  14646. }
  14647. }
  14648. }, {
  14649. key: "sendDTMF",
  14650. value: function sendDTMF(tones) {
  14651. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  14652. debug('sendDTMF() | tones: %s', tones);
  14653. var position = 0;
  14654. var duration = options.duration || null;
  14655. var interToneGap = options.interToneGap || null;
  14656. if (tones === undefined) {
  14657. throw new TypeError('Not enough arguments');
  14658. } // Check Session Status.
  14659. if (this._status !== C.STATUS_CONFIRMED && this._status !== C.STATUS_WAITING_FOR_ACK) {
  14660. throw new Exceptions.InvalidStateError(this._status);
  14661. } // Convert to string.
  14662. if (typeof tones === 'number') {
  14663. tones = tones.toString();
  14664. } // Check tones.
  14665. if (!tones || typeof tones !== 'string' || !tones.match(/^[0-9A-DR#*,]+$/i)) {
  14666. throw new TypeError("Invalid tones: ".concat(tones));
  14667. } // Check duration.
  14668. if (duration && !Utils.isDecimal(duration)) {
  14669. throw new TypeError("Invalid tone duration: ".concat(duration));
  14670. } else if (!duration) {
  14671. duration = RTCSession_DTMF.C.DEFAULT_DURATION;
  14672. } else if (duration < RTCSession_DTMF.C.MIN_DURATION) {
  14673. debug("\"duration\" value is lower than the minimum allowed, setting it to ".concat(RTCSession_DTMF.C.MIN_DURATION, " milliseconds"));
  14674. duration = RTCSession_DTMF.C.MIN_DURATION;
  14675. } else if (duration > RTCSession_DTMF.C.MAX_DURATION) {
  14676. debug("\"duration\" value is greater than the maximum allowed, setting it to ".concat(RTCSession_DTMF.C.MAX_DURATION, " milliseconds"));
  14677. duration = RTCSession_DTMF.C.MAX_DURATION;
  14678. } else {
  14679. duration = Math.abs(duration);
  14680. }
  14681. options.duration = duration; // Check interToneGap.
  14682. if (interToneGap && !Utils.isDecimal(interToneGap)) {
  14683. throw new TypeError("Invalid interToneGap: ".concat(interToneGap));
  14684. } else if (!interToneGap) {
  14685. interToneGap = RTCSession_DTMF.C.DEFAULT_INTER_TONE_GAP;
  14686. } else if (interToneGap < RTCSession_DTMF.C.MIN_INTER_TONE_GAP) {
  14687. debug("\"interToneGap\" value is lower than the minimum allowed, setting it to ".concat(RTCSession_DTMF.C.MIN_INTER_TONE_GAP, " milliseconds"));
  14688. interToneGap = RTCSession_DTMF.C.MIN_INTER_TONE_GAP;
  14689. } else {
  14690. interToneGap = Math.abs(interToneGap);
  14691. }
  14692. if (this._tones) {
  14693. // Tones are already queued, just add to the queue.
  14694. this._tones += tones;
  14695. return;
  14696. }
  14697. this._tones = tones; // Send the first tone.
  14698. _sendDTMF.call(this);
  14699. function _sendDTMF() {
  14700. var _this5 = this;
  14701. var timeout;
  14702. if (this._status === C.STATUS_TERMINATED || !this._tones || position >= this._tones.length) {
  14703. // Stop sending DTMF.
  14704. this._tones = null;
  14705. return;
  14706. }
  14707. var tone = this._tones[position];
  14708. position += 1;
  14709. if (tone === ',') {
  14710. timeout = 2000;
  14711. } else {
  14712. var dtmf = new RTCSession_DTMF(this);
  14713. options.eventHandlers = {
  14714. onFailed: function onFailed() {
  14715. _this5._tones = null;
  14716. }
  14717. };
  14718. dtmf.send(tone, options);
  14719. timeout = duration + interToneGap;
  14720. } // Set timeout for the next tone.
  14721. setTimeout(_sendDTMF.bind(this), timeout);
  14722. }
  14723. }
  14724. }, {
  14725. key: "sendInfo",
  14726. value: function sendInfo(contentType, body) {
  14727. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  14728. debug('sendInfo()'); // Check Session Status.
  14729. if (this._status !== C.STATUS_CONFIRMED && this._status !== C.STATUS_WAITING_FOR_ACK) {
  14730. throw new Exceptions.InvalidStateError(this._status);
  14731. }
  14732. var info = new RTCSession_Info(this);
  14733. info.send(contentType, body, options);
  14734. }
  14735. /**
  14736. * Mute
  14737. */
  14738. }, {
  14739. key: "mute",
  14740. value: function mute() {
  14741. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  14742. audio: true,
  14743. video: false
  14744. };
  14745. debug('mute()');
  14746. var audioMuted = false,
  14747. videoMuted = false;
  14748. if (this._audioMuted === false && options.audio) {
  14749. audioMuted = true;
  14750. this._audioMuted = true;
  14751. this._toggleMuteAudio(true);
  14752. }
  14753. if (this._videoMuted === false && options.video) {
  14754. videoMuted = true;
  14755. this._videoMuted = true;
  14756. this._toggleMuteVideo(true);
  14757. }
  14758. if (audioMuted === true || videoMuted === true) {
  14759. this._onmute({
  14760. audio: audioMuted,
  14761. video: videoMuted
  14762. });
  14763. }
  14764. }
  14765. /**
  14766. * Unmute
  14767. */
  14768. }, {
  14769. key: "unmute",
  14770. value: function unmute() {
  14771. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
  14772. audio: true,
  14773. video: true
  14774. };
  14775. debug('unmute()');
  14776. var audioUnMuted = false,
  14777. videoUnMuted = false;
  14778. if (this._audioMuted === true && options.audio) {
  14779. audioUnMuted = true;
  14780. this._audioMuted = false;
  14781. if (this._localHold === false) {
  14782. this._toggleMuteAudio(false);
  14783. }
  14784. }
  14785. if (this._videoMuted === true && options.video) {
  14786. videoUnMuted = true;
  14787. this._videoMuted = false;
  14788. if (this._localHold === false) {
  14789. this._toggleMuteVideo(false);
  14790. }
  14791. }
  14792. if (audioUnMuted === true || videoUnMuted === true) {
  14793. this._onunmute({
  14794. audio: audioUnMuted,
  14795. video: videoUnMuted
  14796. });
  14797. }
  14798. }
  14799. /**
  14800. * Hold
  14801. */
  14802. }, {
  14803. key: "hold",
  14804. value: function hold() {
  14805. var _this6 = this;
  14806. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  14807. var done = arguments.length > 1 ? arguments[1] : undefined;
  14808. debug('hold()');
  14809. if (this._status !== C.STATUS_WAITING_FOR_ACK && this._status !== C.STATUS_CONFIRMED) {
  14810. return false;
  14811. }
  14812. if (this._localHold === true) {
  14813. return false;
  14814. }
  14815. if (!this._isReadyToReOffer()) {
  14816. return false;
  14817. }
  14818. this._localHold = true;
  14819. this._onhold('local');
  14820. var eventHandlers = {
  14821. succeeded: function succeeded() {
  14822. if (done) {
  14823. done();
  14824. }
  14825. },
  14826. failed: function failed() {
  14827. _this6.terminate({
  14828. cause: JsSIP_C.causes.WEBRTC_ERROR,
  14829. status_code: 500,
  14830. reason_phrase: 'Hold Failed'
  14831. });
  14832. }
  14833. };
  14834. if (options.useUpdate) {
  14835. this._sendUpdate({
  14836. sdpOffer: true,
  14837. eventHandlers: eventHandlers,
  14838. extraHeaders: options.extraHeaders
  14839. });
  14840. } else {
  14841. this._sendReinvite({
  14842. eventHandlers: eventHandlers,
  14843. extraHeaders: options.extraHeaders
  14844. });
  14845. }
  14846. return true;
  14847. }
  14848. }, {
  14849. key: "unhold",
  14850. value: function unhold() {
  14851. var _this7 = this;
  14852. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  14853. var done = arguments.length > 1 ? arguments[1] : undefined;
  14854. debug('unhold()');
  14855. if (this._status !== C.STATUS_WAITING_FOR_ACK && this._status !== C.STATUS_CONFIRMED) {
  14856. return false;
  14857. }
  14858. if (this._localHold === false) {
  14859. return false;
  14860. }
  14861. if (!this._isReadyToReOffer()) {
  14862. return false;
  14863. }
  14864. this._localHold = false;
  14865. this._onunhold('local');
  14866. var eventHandlers = {
  14867. succeeded: function succeeded() {
  14868. if (done) {
  14869. done();
  14870. }
  14871. },
  14872. failed: function failed() {
  14873. _this7.terminate({
  14874. cause: JsSIP_C.causes.WEBRTC_ERROR,
  14875. status_code: 500,
  14876. reason_phrase: 'Unhold Failed'
  14877. });
  14878. }
  14879. };
  14880. if (options.useUpdate) {
  14881. this._sendUpdate({
  14882. sdpOffer: true,
  14883. eventHandlers: eventHandlers,
  14884. extraHeaders: options.extraHeaders
  14885. });
  14886. } else {
  14887. this._sendReinvite({
  14888. eventHandlers: eventHandlers,
  14889. extraHeaders: options.extraHeaders
  14890. });
  14891. }
  14892. return true;
  14893. }
  14894. }, {
  14895. key: "renegotiate",
  14896. value: function renegotiate() {
  14897. var _this8 = this;
  14898. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  14899. var done = arguments.length > 1 ? arguments[1] : undefined;
  14900. debug('renegotiate()');
  14901. var rtcOfferConstraints = options.rtcOfferConstraints || null;
  14902. if (this._status !== C.STATUS_WAITING_FOR_ACK && this._status !== C.STATUS_CONFIRMED) {
  14903. return false;
  14904. }
  14905. if (!this._isReadyToReOffer()) {
  14906. return false;
  14907. }
  14908. var eventHandlers = {
  14909. succeeded: function succeeded() {
  14910. if (done) {
  14911. done();
  14912. }
  14913. },
  14914. failed: function failed() {
  14915. _this8.terminate({
  14916. cause: JsSIP_C.causes.WEBRTC_ERROR,
  14917. status_code: 500,
  14918. reason_phrase: 'Media Renegotiation Failed'
  14919. });
  14920. }
  14921. };
  14922. this._setLocalMediaStatus();
  14923. if (options.useUpdate) {
  14924. this._sendUpdate({
  14925. sdpOffer: true,
  14926. eventHandlers: eventHandlers,
  14927. rtcOfferConstraints: rtcOfferConstraints,
  14928. extraHeaders: options.extraHeaders
  14929. });
  14930. } else {
  14931. this._sendReinvite({
  14932. eventHandlers: eventHandlers,
  14933. rtcOfferConstraints: rtcOfferConstraints,
  14934. extraHeaders: options.extraHeaders
  14935. });
  14936. }
  14937. return true;
  14938. }
  14939. /**
  14940. * Refer
  14941. */
  14942. }, {
  14943. key: "refer",
  14944. value: function refer(target, options) {
  14945. var _this9 = this;
  14946. debug('refer()');
  14947. var originalTarget = target;
  14948. if (this._status !== C.STATUS_WAITING_FOR_ACK && this._status !== C.STATUS_CONFIRMED) {
  14949. return false;
  14950. } // Check target validity.
  14951. target = this._ua.normalizeTarget(target);
  14952. if (!target) {
  14953. throw new TypeError("Invalid target: ".concat(originalTarget));
  14954. }
  14955. var referSubscriber = new RTCSession_ReferSubscriber(this);
  14956. referSubscriber.sendRefer(target, options); // Store in the map.
  14957. var id = referSubscriber.id;
  14958. this._referSubscribers[id] = referSubscriber; // Listen for ending events so we can remove it from the map.
  14959. referSubscriber.on('requestFailed', function () {
  14960. delete _this9._referSubscribers[id];
  14961. });
  14962. referSubscriber.on('accepted', function () {
  14963. delete _this9._referSubscribers[id];
  14964. });
  14965. referSubscriber.on('failed', function () {
  14966. delete _this9._referSubscribers[id];
  14967. });
  14968. return referSubscriber;
  14969. }
  14970. /**
  14971. * Send a generic in-dialog Request
  14972. */
  14973. }, {
  14974. key: "sendRequest",
  14975. value: function sendRequest(method, options) {
  14976. debug('sendRequest()');
  14977. return this._dialog.sendRequest(method, options);
  14978. }
  14979. /**
  14980. * In dialog Request Reception
  14981. */
  14982. }, {
  14983. key: "receiveRequest",
  14984. value: function receiveRequest(request) {
  14985. var _this10 = this;
  14986. debug('receiveRequest()');
  14987. if (request.method === JsSIP_C.CANCEL) {
  14988. /* RFC3261 15 States that a UAS may have accepted an invitation while a CANCEL
  14989. * was in progress and that the UAC MAY continue with the session established by
  14990. * any 2xx response, or MAY terminate with BYE. JsSIP does continue with the
  14991. * established session. So the CANCEL is processed only if the session is not yet
  14992. * established.
  14993. */
  14994. /*
  14995. * Terminate the whole session in case the user didn't accept (or yet send the answer)
  14996. * nor reject the request opening the session.
  14997. */
  14998. if (this._status === C.STATUS_WAITING_FOR_ANSWER || this._status === C.STATUS_ANSWERED) {
  14999. this._status = C.STATUS_CANCELED;
  15000. this._request.reply(487);
  15001. this._failed('remote', request, JsSIP_C.causes.CANCELED);
  15002. }
  15003. } else {
  15004. // Requests arriving here are in-dialog requests.
  15005. switch (request.method) {
  15006. case JsSIP_C.ACK:
  15007. if (this._status !== C.STATUS_WAITING_FOR_ACK) {
  15008. return;
  15009. } // Update signaling status.
  15010. this._status = C.STATUS_CONFIRMED;
  15011. clearTimeout(this._timers.ackTimer);
  15012. clearTimeout(this._timers.invite2xxTimer);
  15013. if (this._late_sdp) {
  15014. if (!request.body) {
  15015. this.terminate({
  15016. cause: JsSIP_C.causes.MISSING_SDP,
  15017. status_code: 400
  15018. });
  15019. break;
  15020. }
  15021. var e = {
  15022. originator: 'remote',
  15023. type: 'answer',
  15024. sdp: request.body
  15025. };
  15026. debug('emit "sdp"');
  15027. this.emit('sdp', e);
  15028. var answer = new RTCSessionDescription({
  15029. type: 'answer',
  15030. sdp: e.sdp
  15031. });
  15032. this._connectionPromiseQueue = this._connectionPromiseQueue.then(function () {
  15033. return _this10._connection.setRemoteDescription(answer);
  15034. }).then(function () {
  15035. if (!_this10._is_confirmed) {
  15036. _this10._confirmed('remote', request);
  15037. }
  15038. })["catch"](function (error) {
  15039. _this10.terminate({
  15040. cause: JsSIP_C.causes.BAD_MEDIA_DESCRIPTION,
  15041. status_code: 488
  15042. });
  15043. debugerror('emit "peerconnection:setremotedescriptionfailed" [error:%o]', error);
  15044. _this10.emit('peerconnection:setremotedescriptionfailed', error);
  15045. });
  15046. } else if (!this._is_confirmed) {
  15047. this._confirmed('remote', request);
  15048. }
  15049. break;
  15050. case JsSIP_C.BYE:
  15051. if (this._status === C.STATUS_CONFIRMED || this._status === C.STATUS_WAITING_FOR_ACK) {
  15052. request.reply(200);
  15053. this._ended('remote', request, JsSIP_C.causes.BYE);
  15054. } else if (this._status === C.STATUS_INVITE_RECEIVED) {
  15055. request.reply(200);
  15056. this._request.reply(487, 'BYE Received');
  15057. this._ended('remote', request, JsSIP_C.causes.BYE);
  15058. } else {
  15059. request.reply(403, 'Wrong Status');
  15060. }
  15061. break;
  15062. case JsSIP_C.INVITE:
  15063. if (this._status === C.STATUS_CONFIRMED) {
  15064. if (request.hasHeader('replaces')) {
  15065. this._receiveReplaces(request);
  15066. } else {
  15067. this._receiveReinvite(request);
  15068. }
  15069. } else {
  15070. request.reply(403, 'Wrong Status');
  15071. }
  15072. break;
  15073. case JsSIP_C.INFO:
  15074. if (this._status === C.STATUS_1XX_RECEIVED || this._status === C.STATUS_WAITING_FOR_ANSWER || this._status === C.STATUS_ANSWERED || this._status === C.STATUS_WAITING_FOR_ACK || this._status === C.STATUS_CONFIRMED) {
  15075. var contentType = request.getHeader('content-type');
  15076. if (contentType && contentType.match(/^application\/dtmf-relay/i)) {
  15077. new RTCSession_DTMF(this).init_incoming(request);
  15078. } else if (contentType !== undefined) {
  15079. new RTCSession_Info(this).init_incoming(request);
  15080. } else {
  15081. request.reply(415);
  15082. }
  15083. } else {
  15084. request.reply(403, 'Wrong Status');
  15085. }
  15086. break;
  15087. case JsSIP_C.UPDATE:
  15088. if (this._status === C.STATUS_CONFIRMED) {
  15089. this._receiveUpdate(request);
  15090. } else {
  15091. request.reply(403, 'Wrong Status');
  15092. }
  15093. break;
  15094. case JsSIP_C.REFER:
  15095. if (this._status === C.STATUS_CONFIRMED) {
  15096. this._receiveRefer(request);
  15097. } else {
  15098. request.reply(403, 'Wrong Status');
  15099. }
  15100. break;
  15101. case JsSIP_C.NOTIFY:
  15102. if (this._status === C.STATUS_CONFIRMED) {
  15103. this._receiveNotify(request);
  15104. } else {
  15105. request.reply(403, 'Wrong Status');
  15106. }
  15107. break;
  15108. default:
  15109. request.reply(501);
  15110. }
  15111. }
  15112. }
  15113. /**
  15114. * Session Callbacks
  15115. */
  15116. }, {
  15117. key: "onTransportError",
  15118. value: function onTransportError() {
  15119. debugerror('onTransportError()');
  15120. if (this._status !== C.STATUS_TERMINATED) {
  15121. this.terminate({
  15122. status_code: 500,
  15123. reason_phrase: JsSIP_C.causes.CONNECTION_ERROR,
  15124. cause: JsSIP_C.causes.CONNECTION_ERROR
  15125. });
  15126. }
  15127. }
  15128. }, {
  15129. key: "onRequestTimeout",
  15130. value: function onRequestTimeout() {
  15131. debugerror('onRequestTimeout()');
  15132. if (this._status !== C.STATUS_TERMINATED) {
  15133. this.terminate({
  15134. status_code: 408,
  15135. reason_phrase: JsSIP_C.causes.REQUEST_TIMEOUT,
  15136. cause: JsSIP_C.causes.REQUEST_TIMEOUT
  15137. });
  15138. }
  15139. }
  15140. }, {
  15141. key: "onDialogError",
  15142. value: function onDialogError() {
  15143. debugerror('onDialogError()');
  15144. if (this._status !== C.STATUS_TERMINATED) {
  15145. this.terminate({
  15146. status_code: 500,
  15147. reason_phrase: JsSIP_C.causes.DIALOG_ERROR,
  15148. cause: JsSIP_C.causes.DIALOG_ERROR
  15149. });
  15150. }
  15151. } // Called from DTMF handler.
  15152. }, {
  15153. key: "newDTMF",
  15154. value: function newDTMF(data) {
  15155. debug('newDTMF()');
  15156. this.emit('newDTMF', data);
  15157. } // Called from Info handler.
  15158. }, {
  15159. key: "newInfo",
  15160. value: function newInfo(data) {
  15161. debug('newInfo()');
  15162. this.emit('newInfo', data);
  15163. }
  15164. /**
  15165. * Check if RTCSession is ready for an outgoing re-INVITE or UPDATE with SDP.
  15166. */
  15167. }, {
  15168. key: "_isReadyToReOffer",
  15169. value: function _isReadyToReOffer() {
  15170. if (!this._rtcReady) {
  15171. debug('_isReadyToReOffer() | internal WebRTC status not ready');
  15172. return false;
  15173. } // No established yet.
  15174. if (!this._dialog) {
  15175. debug('_isReadyToReOffer() | session not established yet');
  15176. return false;
  15177. } // Another INVITE transaction is in progress.
  15178. if (this._dialog.uac_pending_reply === true || this._dialog.uas_pending_reply === true) {
  15179. debug('_isReadyToReOffer() | there is another INVITE/UPDATE transaction in progress');
  15180. return false;
  15181. }
  15182. return true;
  15183. }
  15184. }, {
  15185. key: "_close",
  15186. value: function _close() {
  15187. debug('close()');
  15188. if (this._status === C.STATUS_TERMINATED) {
  15189. return;
  15190. }
  15191. this._status = C.STATUS_TERMINATED; // Terminate RTC.
  15192. if (this._connection) {
  15193. try {
  15194. this._connection.close();
  15195. } catch (error) {
  15196. debugerror('close() | error closing the RTCPeerConnection: %o', error);
  15197. }
  15198. } // Close local MediaStream if it was not given by the user.
  15199. if (this._localMediaStream && this._localMediaStreamLocallyGenerated) {
  15200. debug('close() | closing local MediaStream');
  15201. Utils.closeMediaStream(this._localMediaStream);
  15202. } // Terminate signaling.
  15203. // Clear SIP timers.
  15204. for (var timer in this._timers) {
  15205. if (Object.prototype.hasOwnProperty.call(this._timers, timer)) {
  15206. clearTimeout(this._timers[timer]);
  15207. }
  15208. } // Clear Session Timers.
  15209. clearTimeout(this._sessionTimers.timer); // Terminate confirmed dialog.
  15210. if (this._dialog) {
  15211. this._dialog.terminate();
  15212. delete this._dialog;
  15213. } // Terminate early dialogs.
  15214. for (var dialog in this._earlyDialogs) {
  15215. if (Object.prototype.hasOwnProperty.call(this._earlyDialogs, dialog)) {
  15216. this._earlyDialogs[dialog].terminate();
  15217. delete this._earlyDialogs[dialog];
  15218. }
  15219. } // Terminate REFER subscribers.
  15220. for (var subscriber in this._referSubscribers) {
  15221. if (Object.prototype.hasOwnProperty.call(this._referSubscribers, subscriber)) {
  15222. delete this._referSubscribers[subscriber];
  15223. }
  15224. }
  15225. this._ua.destroyRTCSession(this);
  15226. }
  15227. /**
  15228. * Private API.
  15229. */
  15230. /**
  15231. * RFC3261 13.3.1.4
  15232. * Response retransmissions cannot be accomplished by transaction layer
  15233. * since it is destroyed when receiving the first 2xx answer
  15234. */
  15235. }, {
  15236. key: "_setInvite2xxTimer",
  15237. value: function _setInvite2xxTimer(request, body) {
  15238. var timeout = Timers.T1;
  15239. function invite2xxRetransmission() {
  15240. if (this._status !== C.STATUS_WAITING_FOR_ACK) {
  15241. return;
  15242. }
  15243. request.reply(200, null, ["Contact: ".concat(this._contact)], body);
  15244. if (timeout < Timers.T2) {
  15245. timeout = timeout * 2;
  15246. if (timeout > Timers.T2) {
  15247. timeout = Timers.T2;
  15248. }
  15249. }
  15250. this._timers.invite2xxTimer = setTimeout(invite2xxRetransmission.bind(this), timeout);
  15251. }
  15252. this._timers.invite2xxTimer = setTimeout(invite2xxRetransmission.bind(this), timeout);
  15253. }
  15254. /**
  15255. * RFC3261 14.2
  15256. * If a UAS generates a 2xx response and never receives an ACK,
  15257. * it SHOULD generate a BYE to terminate the dialog.
  15258. */
  15259. }, {
  15260. key: "_setACKTimer",
  15261. value: function _setACKTimer() {
  15262. var _this11 = this;
  15263. this._timers.ackTimer = setTimeout(function () {
  15264. if (_this11._status === C.STATUS_WAITING_FOR_ACK) {
  15265. debug('no ACK received, terminating the session');
  15266. clearTimeout(_this11._timers.invite2xxTimer);
  15267. _this11.sendRequest(JsSIP_C.BYE);
  15268. _this11._ended('remote', null, JsSIP_C.causes.NO_ACK);
  15269. }
  15270. }, Timers.TIMER_H);
  15271. }
  15272. }, {
  15273. key: "_createRTCConnection",
  15274. value: function _createRTCConnection(pcConfig, rtcConstraints) {
  15275. var _this12 = this;
  15276. this._connection = new RTCPeerConnection(pcConfig, rtcConstraints);
  15277. this._connection.addEventListener('iceconnectionstatechange', function () {
  15278. var state = _this12._connection.iceConnectionState; // TODO: Do more with different states.
  15279. if (state === 'failed') {
  15280. _this12.terminate({
  15281. cause: JsSIP_C.causes.RTP_TIMEOUT,
  15282. status_code: 408,
  15283. reason_phrase: JsSIP_C.causes.RTP_TIMEOUT
  15284. });
  15285. }
  15286. });
  15287. debug('emit "peerconnection"');
  15288. this.emit('peerconnection', {
  15289. peerconnection: this._connection
  15290. });
  15291. }
  15292. }, {
  15293. key: "_createLocalDescription",
  15294. value: function _createLocalDescription(type, constraints) {
  15295. var _this13 = this;
  15296. debug('createLocalDescription()');
  15297. if (type !== 'offer' && type !== 'answer') throw new Error("createLocalDescription() | invalid type \"".concat(type, "\""));
  15298. var connection = this._connection;
  15299. this._rtcReady = false;
  15300. return Promise.resolve() // Create Offer or Answer.
  15301. .then(function () {
  15302. if (type === 'offer') {
  15303. return connection.createOffer(constraints)["catch"](function (error) {
  15304. debugerror('emit "peerconnection:createofferfailed" [error:%o]', error);
  15305. _this13.emit('peerconnection:createofferfailed', error);
  15306. return Promise.reject(error);
  15307. });
  15308. } else {
  15309. return connection.createAnswer(constraints)["catch"](function (error) {
  15310. debugerror('emit "peerconnection:createanswerfailed" [error:%o]', error);
  15311. _this13.emit('peerconnection:createanswerfailed', error);
  15312. return Promise.reject(error);
  15313. });
  15314. }
  15315. }) // Set local description.
  15316. .then(function (desc) {
  15317. return connection.setLocalDescription(desc)["catch"](function (error) {
  15318. _this13._rtcReady = true;
  15319. debugerror('emit "peerconnection:setlocaldescriptionfailed" [error:%o]', error);
  15320. _this13.emit('peerconnection:setlocaldescriptionfailed', error);
  15321. return Promise.reject(error);
  15322. });
  15323. }).then(function () {
  15324. // Resolve right away if 'pc.iceGatheringState' is 'complete'.
  15325. if (connection.iceGatheringState === 'complete') {
  15326. _this13._rtcReady = true;
  15327. var e = {
  15328. originator: 'local',
  15329. type: type,
  15330. sdp: connection.localDescription.sdp
  15331. };
  15332. debug('emit "sdp"');
  15333. _this13.emit('sdp', e);
  15334. return Promise.resolve(e.sdp);
  15335. } // Add 'pc.onicencandidate' event handler to resolve on last candidate.
  15336. return new Promise(function (resolve) {
  15337. var finished = false;
  15338. var iceCandidateListener;
  15339. var iceGatheringStateListener;
  15340. var ready = function ready() {
  15341. connection.removeEventListener('icecandidate', iceCandidateListener);
  15342. connection.removeEventListener('icegatheringstatechange', iceGatheringStateListener);
  15343. var sdpbody = connection.localDescription.sdp;
  15344. var sdplines = sdpbody.split("\r\n");
  15345. var sdpcontent = "";
  15346. for (var i = 0; i < sdplines.length; i++) {
  15347. if (sdplines[i].indexOf("a=candidate") > -1 && sdplines[i].split(" ")[4].indexOf(":") > -1) {
  15348. continue;
  15349. } else {
  15350. sdpcontent += sdplines[i] + "\r\n";
  15351. }
  15352. }
  15353. finished = true;
  15354. _this13._rtcReady = true;
  15355. var e = {
  15356. originator: 'local',
  15357. type: type,
  15358. sdp: sdpcontent
  15359. };
  15360. debug('emit "sdp"');
  15361. _this13.emit('sdp', e);
  15362. resolve(e.sdp);
  15363. };
  15364. connection.addEventListener('icecandidate', iceCandidateListener = function iceCandidateListener(event) {
  15365. var candidate = event.candidate;
  15366. if (candidate) {
  15367. _this13.emit('icecandidate', {
  15368. candidate: candidate,
  15369. ready: ready
  15370. });
  15371. } else if (!finished) {
  15372. ready();
  15373. }
  15374. });
  15375. connection.addEventListener('icegatheringstatechange', iceGatheringStateListener = function iceGatheringStateListener() {
  15376. if (connection.iceGatheringState === 'complete' && !finished) {
  15377. ready();
  15378. }
  15379. });
  15380. });
  15381. });
  15382. }
  15383. /**
  15384. * Dialog Management
  15385. */
  15386. }, {
  15387. key: "_createDialog",
  15388. value: function _createDialog(message, type, early) {
  15389. var local_tag = type === 'UAS' ? message.to_tag : message.from_tag;
  15390. var remote_tag = type === 'UAS' ? message.from_tag : message.to_tag;
  15391. var id = message.call_id + local_tag + remote_tag;
  15392. var early_dialog = this._earlyDialogs[id]; // Early Dialog.
  15393. if (early) {
  15394. if (early_dialog) {
  15395. return true;
  15396. } else {
  15397. early_dialog = new Dialog(this, message, type, Dialog.C.STATUS_EARLY); // Dialog has been successfully created.
  15398. if (early_dialog.error) {
  15399. debug(early_dialog.error);
  15400. this._failed('remote', message, JsSIP_C.causes.INTERNAL_ERROR);
  15401. return false;
  15402. } else {
  15403. this._earlyDialogs[id] = early_dialog;
  15404. return true;
  15405. }
  15406. }
  15407. } // Confirmed Dialog.
  15408. else {
  15409. this._from_tag = message.from_tag;
  15410. this._to_tag = message.to_tag; // In case the dialog is in _early_ state, update it.
  15411. if (early_dialog) {
  15412. early_dialog.update(message, type);
  15413. this._dialog = early_dialog;
  15414. delete this._earlyDialogs[id];
  15415. return true;
  15416. } // Otherwise, create a _confirmed_ dialog.
  15417. var dialog = new Dialog(this, message, type);
  15418. if (dialog.error) {
  15419. debug(dialog.error);
  15420. this._failed('remote', message, JsSIP_C.causes.INTERNAL_ERROR);
  15421. return false;
  15422. } else {
  15423. this._dialog = dialog;
  15424. return true;
  15425. }
  15426. }
  15427. }
  15428. /**
  15429. * In dialog INVITE Reception
  15430. */
  15431. }, {
  15432. key: "_receiveReinvite",
  15433. value: function _receiveReinvite(request) {
  15434. var _this14 = this;
  15435. debug('receiveReinvite()');
  15436. var contentType = request.getHeader('Content-Type');
  15437. var data = {
  15438. request: request,
  15439. callback: undefined,
  15440. reject: reject.bind(this)
  15441. };
  15442. var rejected = false;
  15443. function reject() {
  15444. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  15445. rejected = true;
  15446. var status_code = options.status_code || 403;
  15447. var reason_phrase = options.reason_phrase || '';
  15448. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  15449. if (this._status !== C.STATUS_CONFIRMED) {
  15450. return false;
  15451. }
  15452. if (status_code < 300 || status_code >= 700) {
  15453. throw new TypeError("Invalid status_code: ".concat(status_code));
  15454. }
  15455. request.reply(status_code, reason_phrase, extraHeaders);
  15456. } // Emit 'reinvite'.
  15457. this.emit('reinvite', data);
  15458. if (rejected) {
  15459. return;
  15460. }
  15461. this._late_sdp = false; // Request without SDP.
  15462. if (!request.body) {
  15463. this._late_sdp = true;
  15464. if (this._remoteHold) {
  15465. this._remoteHold = false;
  15466. this._onunhold('remote');
  15467. }
  15468. this._connectionPromiseQueue = this._connectionPromiseQueue.then(function () {
  15469. return _this14._createLocalDescription('offer', _this14._rtcOfferConstraints);
  15470. }).then(function (sdp) {
  15471. sendAnswer.call(_this14, sdp);
  15472. })["catch"](function () {
  15473. request.reply(500);
  15474. });
  15475. return;
  15476. } // Request with SDP.
  15477. if (contentType !== 'application/sdp') {
  15478. debug('invalid Content-Type');
  15479. request.reply(415);
  15480. return;
  15481. }
  15482. this._processInDialogSdpOffer(request) // Send answer.
  15483. .then(function (desc) {
  15484. if (_this14._status === C.STATUS_TERMINATED) {
  15485. return;
  15486. }
  15487. sendAnswer.call(_this14, desc);
  15488. })["catch"](function (error) {
  15489. debugerror(error);
  15490. });
  15491. function sendAnswer(desc) {
  15492. var _this15 = this;
  15493. var extraHeaders = ["Contact: ".concat(this._contact)];
  15494. this._handleSessionTimersInIncomingRequest(request, extraHeaders);
  15495. if (this._late_sdp) {
  15496. desc = this._mangleOffer(desc);
  15497. }
  15498. request.reply(200, null, extraHeaders, desc, function () {
  15499. _this15._status = C.STATUS_WAITING_FOR_ACK;
  15500. _this15._setInvite2xxTimer(request, desc);
  15501. _this15._setACKTimer();
  15502. }); // If callback is given execute it.
  15503. if (typeof data.callback === 'function') {
  15504. data.callback();
  15505. }
  15506. }
  15507. }
  15508. /**
  15509. * In dialog UPDATE Reception
  15510. */
  15511. }, {
  15512. key: "_receiveUpdate",
  15513. value: function _receiveUpdate(request) {
  15514. var _this16 = this;
  15515. debug('receiveUpdate()');
  15516. var contentType = request.getHeader('Content-Type');
  15517. var data = {
  15518. request: request,
  15519. callback: undefined,
  15520. reject: reject.bind(this)
  15521. };
  15522. var rejected = false;
  15523. function reject() {
  15524. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  15525. rejected = true;
  15526. var status_code = options.status_code || 403;
  15527. var reason_phrase = options.reason_phrase || '';
  15528. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  15529. if (this._status !== C.STATUS_CONFIRMED) {
  15530. return false;
  15531. }
  15532. if (status_code < 300 || status_code >= 700) {
  15533. throw new TypeError("Invalid status_code: ".concat(status_code));
  15534. }
  15535. request.reply(status_code, reason_phrase, extraHeaders);
  15536. } // Emit 'update'.
  15537. this.emit('update', data);
  15538. if (rejected) {
  15539. return;
  15540. }
  15541. if (!request.body) {
  15542. sendAnswer.call(this, null);
  15543. return;
  15544. }
  15545. if (contentType !== 'application/sdp') {
  15546. debug('invalid Content-Type');
  15547. request.reply(415);
  15548. return;
  15549. }
  15550. this._processInDialogSdpOffer(request) // Send answer.
  15551. .then(function (desc) {
  15552. if (_this16._status === C.STATUS_TERMINATED) {
  15553. return;
  15554. }
  15555. sendAnswer.call(_this16, desc);
  15556. })["catch"](function (error) {
  15557. debugerror(error);
  15558. });
  15559. function sendAnswer(desc) {
  15560. var extraHeaders = ["Contact: ".concat(this._contact)];
  15561. this._handleSessionTimersInIncomingRequest(request, extraHeaders);
  15562. request.reply(200, null, extraHeaders, desc); // If callback is given execute it.
  15563. if (typeof data.callback === 'function') {
  15564. data.callback();
  15565. }
  15566. }
  15567. }
  15568. }, {
  15569. key: "_processInDialogSdpOffer",
  15570. value: function _processInDialogSdpOffer(request) {
  15571. var _this17 = this;
  15572. debug('_processInDialogSdpOffer()');
  15573. var sdp = request.parseSDP();
  15574. var hold = false;
  15575. var _iterator4 = _createForOfIteratorHelper(sdp.media),
  15576. _step4;
  15577. try {
  15578. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  15579. var m = _step4.value;
  15580. if (holdMediaTypes.indexOf(m.type) === -1) {
  15581. continue;
  15582. }
  15583. var direction = m.direction || sdp.direction || 'sendrecv';
  15584. if (direction === 'sendonly' || direction === 'inactive') {
  15585. hold = true;
  15586. } // If at least one of the streams is active don't emit 'hold'.
  15587. else {
  15588. hold = false;
  15589. break;
  15590. }
  15591. }
  15592. } catch (err) {
  15593. _iterator4.e(err);
  15594. } finally {
  15595. _iterator4.f();
  15596. }
  15597. var e = {
  15598. originator: 'remote',
  15599. type: 'offer',
  15600. sdp: request.body
  15601. };
  15602. debug('emit "sdp"');
  15603. this.emit('sdp', e);
  15604. var offer = new RTCSessionDescription({
  15605. type: 'offer',
  15606. sdp: e.sdp
  15607. });
  15608. this._connectionPromiseQueue = this._connectionPromiseQueue // Set remote description.
  15609. .then(function () {
  15610. if (_this17._status === C.STATUS_TERMINATED) {
  15611. throw new Error('terminated');
  15612. }
  15613. return _this17._connection.setRemoteDescription(offer)["catch"](function (error) {
  15614. request.reply(488);
  15615. debugerror('emit "peerconnection:setremotedescriptionfailed" [error:%o]', error);
  15616. _this17.emit('peerconnection:setremotedescriptionfailed', error);
  15617. throw new Error('peerconnection.setRemoteDescription() failed');
  15618. });
  15619. }).then(function () {
  15620. if (_this17._status === C.STATUS_TERMINATED) {
  15621. throw new Error('terminated');
  15622. }
  15623. if (_this17._remoteHold === true && hold === false) {
  15624. _this17._remoteHold = false;
  15625. _this17._onunhold('remote');
  15626. } else if (_this17._remoteHold === false && hold === true) {
  15627. _this17._remoteHold = true;
  15628. _this17._onhold('remote');
  15629. }
  15630. }) // Create local description.
  15631. .then(function () {
  15632. if (_this17._status === C.STATUS_TERMINATED) {
  15633. throw new Error('terminated');
  15634. }
  15635. return _this17._createLocalDescription('answer', _this17._rtcAnswerConstraints)["catch"](function () {
  15636. request.reply(500);
  15637. throw new Error('_createLocalDescription() failed');
  15638. });
  15639. });
  15640. return this._connectionPromiseQueue;
  15641. }
  15642. /**
  15643. * In dialog Refer Reception
  15644. */
  15645. }, {
  15646. key: "_receiveRefer",
  15647. value: function _receiveRefer(request) {
  15648. var _this18 = this;
  15649. debug('receiveRefer()');
  15650. if (!request.refer_to) {
  15651. debug('no Refer-To header field present in REFER');
  15652. request.reply(400);
  15653. return;
  15654. }
  15655. if (request.refer_to.uri.scheme !== JsSIP_C.SIP) {
  15656. debug('Refer-To header field points to a non-SIP URI scheme');
  15657. request.reply(416);
  15658. return;
  15659. } // Reply before the transaction timer expires.
  15660. request.reply(202);
  15661. var notifier = new RTCSession_ReferNotifier(this, request.cseq);
  15662. debug('emit "refer"'); // Emit 'refer'.
  15663. this.emit('refer', {
  15664. request: request,
  15665. accept: function accept(initCallback, options) {
  15666. _accept.call(_this18, initCallback, options);
  15667. },
  15668. reject: function reject() {
  15669. _reject.call(_this18);
  15670. }
  15671. });
  15672. function _accept(initCallback) {
  15673. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  15674. initCallback = typeof initCallback === 'function' ? initCallback : null;
  15675. if (this._status !== C.STATUS_WAITING_FOR_ACK && this._status !== C.STATUS_CONFIRMED) {
  15676. return false;
  15677. }
  15678. var session = new RTCSession(this._ua);
  15679. session.on('progress', function (_ref2) {
  15680. var response = _ref2.response;
  15681. notifier.notify(response.status_code, response.reason_phrase);
  15682. });
  15683. session.on('accepted', function (_ref3) {
  15684. var response = _ref3.response;
  15685. notifier.notify(response.status_code, response.reason_phrase);
  15686. });
  15687. session.on('_failed', function (_ref4) {
  15688. var message = _ref4.message,
  15689. cause = _ref4.cause;
  15690. if (message) {
  15691. notifier.notify(message.status_code, message.reason_phrase);
  15692. } else {
  15693. notifier.notify(487, cause);
  15694. }
  15695. }); // Consider the Replaces header present in the Refer-To URI.
  15696. if (request.refer_to.uri.hasHeader('replaces')) {
  15697. var replaces = decodeURIComponent(request.refer_to.uri.getHeader('replaces'));
  15698. options.extraHeaders = Utils.cloneArray(options.extraHeaders);
  15699. options.extraHeaders.push("Replaces: ".concat(replaces));
  15700. }
  15701. session.connect(request.refer_to.uri.toAor(), options, initCallback);
  15702. }
  15703. function _reject() {
  15704. notifier.notify(603);
  15705. }
  15706. }
  15707. /**
  15708. * In dialog Notify Reception
  15709. */
  15710. }, {
  15711. key: "_receiveNotify",
  15712. value: function _receiveNotify(request) {
  15713. debug('receiveNotify()');
  15714. if (!request.event) {
  15715. request.reply(400);
  15716. }
  15717. switch (request.event.event) {
  15718. case 'refer':
  15719. {
  15720. var id;
  15721. var referSubscriber;
  15722. if (request.event.params && request.event.params.id) {
  15723. id = request.event.params.id;
  15724. referSubscriber = this._referSubscribers[id];
  15725. } else if (Object.keys(this._referSubscribers).length === 1) {
  15726. referSubscriber = this._referSubscribers[Object.keys(this._referSubscribers)[0]];
  15727. } else {
  15728. request.reply(400, 'Missing event id parameter');
  15729. return;
  15730. }
  15731. if (!referSubscriber) {
  15732. request.reply(481, 'Subscription does not exist');
  15733. return;
  15734. }
  15735. referSubscriber.receiveNotify(request);
  15736. request.reply(200);
  15737. break;
  15738. }
  15739. default:
  15740. {
  15741. request.reply(489);
  15742. }
  15743. }
  15744. }
  15745. /**
  15746. * INVITE with Replaces Reception
  15747. */
  15748. }, {
  15749. key: "_receiveReplaces",
  15750. value: function _receiveReplaces(request) {
  15751. var _this20 = this;
  15752. debug('receiveReplaces()');
  15753. function _accept2(initCallback) {
  15754. var _this19 = this;
  15755. if (this._status !== C.STATUS_WAITING_FOR_ACK && this._status !== C.STATUS_CONFIRMED) {
  15756. return false;
  15757. }
  15758. var session = new RTCSession(this._ua); // Terminate the current session when the new one is confirmed.
  15759. session.on('confirmed', function () {
  15760. _this19.terminate();
  15761. });
  15762. session.init_incoming(request, initCallback);
  15763. }
  15764. function _reject2() {
  15765. debug('Replaced INVITE rejected by the user');
  15766. request.reply(486);
  15767. } // Emit 'replace'.
  15768. this.emit('replaces', {
  15769. request: request,
  15770. accept: function accept(initCallback) {
  15771. _accept2.call(_this20, initCallback);
  15772. },
  15773. reject: function reject() {
  15774. _reject2.call(_this20);
  15775. }
  15776. });
  15777. }
  15778. /**
  15779. * Initial Request Sender
  15780. */
  15781. }, {
  15782. key: "_sendInitialRequest",
  15783. value: function _sendInitialRequest(mediaConstraints, rtcOfferConstraints, mediaStream) {
  15784. var _this21 = this;
  15785. var request_sender = new RequestSender(this._ua, this._request, {
  15786. onRequestTimeout: function onRequestTimeout() {
  15787. _this21.onRequestTimeout();
  15788. },
  15789. onTransportError: function onTransportError() {
  15790. _this21.onTransportError();
  15791. },
  15792. // Update the request on authentication.
  15793. onAuthenticated: function onAuthenticated(request) {
  15794. _this21._request = request;
  15795. },
  15796. onReceiveResponse: function onReceiveResponse(response) {
  15797. _this21._receiveInviteResponse(response);
  15798. }
  15799. }); // This Promise is resolved within the next iteration, so the app has now
  15800. // a chance to set events such as 'peerconnection' and 'connecting'.
  15801. Promise.resolve() // Get a stream if required.
  15802. .then(function () {
  15803. // A stream is given, let the app set events such as 'peerconnection' and 'connecting'.
  15804. if (mediaStream) {
  15805. return mediaStream;
  15806. } // Request for user media access.
  15807. else if (mediaConstraints.audio || mediaConstraints.video) {
  15808. _this21._localMediaStreamLocallyGenerated = true;
  15809. return navigator.mediaDevices.getUserMedia(mediaConstraints)["catch"](function (error) {
  15810. if (_this21._status === C.STATUS_TERMINATED) {
  15811. throw new Error('terminated');
  15812. }
  15813. _this21._failed('local', null, JsSIP_C.causes.USER_DENIED_MEDIA_ACCESS);
  15814. debugerror('emit "getusermediafailed" [error:%o]', error);
  15815. _this21.emit('getusermediafailed', error);
  15816. throw error;
  15817. });
  15818. }
  15819. }).then(function (stream) {
  15820. if (_this21._status === C.STATUS_TERMINATED) {
  15821. throw new Error('terminated');
  15822. }
  15823. _this21._localMediaStream = stream;
  15824. if (stream) {
  15825. stream.getTracks().forEach(function (track) {
  15826. _this21._connection.addTrack(track, stream);
  15827. });
  15828. } // TODO: should this be triggered here?
  15829. _this21._connecting(_this21._request);
  15830. return _this21._createLocalDescription('offer', rtcOfferConstraints)["catch"](function (error) {
  15831. _this21._failed('local', null, JsSIP_C.causes.WEBRTC_ERROR);
  15832. throw error;
  15833. });
  15834. }).then(function (desc) {
  15835. if (_this21._is_canceled || _this21._status === C.STATUS_TERMINATED) {
  15836. throw new Error('terminated');
  15837. }
  15838. _this21._request.body = desc;
  15839. _this21._status = C.STATUS_INVITE_SENT;
  15840. debug('emit "sending" [request:%o]', _this21._request); // Emit 'sending' so the app can mangle the body before the request is sent.
  15841. _this21.emit('sending', {
  15842. request: _this21._request
  15843. });
  15844. request_sender.send();
  15845. })["catch"](function (error) {
  15846. if (_this21._status === C.STATUS_TERMINATED) {
  15847. return;
  15848. }
  15849. debugerror(error);
  15850. });
  15851. }
  15852. /**
  15853. * Reception of Response for Initial INVITE
  15854. */
  15855. }, {
  15856. key: "_receiveInviteResponse",
  15857. value: function _receiveInviteResponse(response) {
  15858. var _this22 = this;
  15859. debug('receiveInviteResponse()'); // Handle 2XX retransmissions and responses from forked requests.
  15860. if (this._dialog && response.status_code >= 200 && response.status_code <= 299) {
  15861. /*
  15862. * If it is a retransmission from the endpoint that established
  15863. * the dialog, send an ACK
  15864. */
  15865. if (this._dialog.id.call_id === response.call_id && this._dialog.id.local_tag === response.from_tag && this._dialog.id.remote_tag === response.to_tag) {
  15866. this.sendRequest(JsSIP_C.ACK);
  15867. return;
  15868. } // If not, send an ACK and terminate.
  15869. else {
  15870. var dialog = new Dialog(this, response, 'UAC');
  15871. if (dialog.error !== undefined) {
  15872. debug(dialog.error);
  15873. return;
  15874. }
  15875. this.sendRequest(JsSIP_C.ACK);
  15876. this.sendRequest(JsSIP_C.BYE);
  15877. return;
  15878. }
  15879. } // Proceed to cancellation if the user requested.
  15880. if (this._is_canceled) {
  15881. if (response.status_code >= 100 && response.status_code < 200) {
  15882. this._request.cancel(this._cancel_reason);
  15883. } else if (response.status_code >= 200 && response.status_code < 299) {
  15884. this._acceptAndTerminate(response);
  15885. }
  15886. return;
  15887. }
  15888. if (this._status !== C.STATUS_INVITE_SENT && this._status !== C.STATUS_1XX_RECEIVED) {
  15889. return;
  15890. }
  15891. switch (true) {
  15892. case /^100$/.test(response.status_code):
  15893. this._status = C.STATUS_1XX_RECEIVED;
  15894. break;
  15895. case /^1[0-9]{2}$/.test(response.status_code):
  15896. {
  15897. // Do nothing with 1xx responses without To tag.
  15898. if (!response.to_tag) {
  15899. debug('1xx response received without to tag');
  15900. break;
  15901. } // Create Early Dialog if 1XX comes with contact.
  15902. if (response.hasHeader('contact')) {
  15903. // An error on dialog creation will fire 'failed' event.
  15904. if (!this._createDialog(response, 'UAC', true)) {
  15905. break;
  15906. }
  15907. }
  15908. this._status = C.STATUS_1XX_RECEIVED;
  15909. this._progress('remote', response);
  15910. if (!response.body) {
  15911. break;
  15912. }
  15913. var e = {
  15914. originator: 'remote',
  15915. type: 'answer',
  15916. sdp: response.body
  15917. };
  15918. debug('emit "sdp"');
  15919. this.emit('sdp', e);
  15920. var answer = new RTCSessionDescription({
  15921. type: 'answer',
  15922. sdp: e.sdp
  15923. });
  15924. this._connectionPromiseQueue = this._connectionPromiseQueue.then(function () {
  15925. return _this22._connection.setRemoteDescription(answer);
  15926. })["catch"](function (error) {
  15927. debugerror('emit "peerconnection:setremotedescriptionfailed" [error:%o]', error);
  15928. _this22.emit('peerconnection:setremotedescriptionfailed', error);
  15929. });
  15930. break;
  15931. }
  15932. case /^2[0-9]{2}$/.test(response.status_code):
  15933. {
  15934. this._status = C.STATUS_CONFIRMED;
  15935. if (!response.body) {
  15936. this._acceptAndTerminate(response, 400, JsSIP_C.causes.MISSING_SDP);
  15937. this._failed('remote', response, JsSIP_C.causes.BAD_MEDIA_DESCRIPTION);
  15938. break;
  15939. } // An error on dialog creation will fire 'failed' event.
  15940. if (!this._createDialog(response, 'UAC')) {
  15941. break;
  15942. }
  15943. var _e = {
  15944. originator: 'remote',
  15945. type: 'answer',
  15946. sdp: response.body
  15947. };
  15948. debug('emit "sdp"');
  15949. this.emit('sdp', _e);
  15950. var _answer = new RTCSessionDescription({
  15951. type: 'answer',
  15952. sdp: _e.sdp
  15953. });
  15954. this._connectionPromiseQueue = this._connectionPromiseQueue.then(function () {
  15955. // Be ready for 200 with SDP after a 180/183 with SDP.
  15956. // We created a SDP 'answer' for it, so check the current signaling state.
  15957. if (_this22._connection.signalingState === 'stable') {
  15958. return _this22._connection.createOffer(_this22._rtcOfferConstraints).then(function (offer) {
  15959. return _this22._connection.setLocalDescription(offer);
  15960. })["catch"](function (error) {
  15961. _this22._acceptAndTerminate(response, 500, error.toString());
  15962. _this22._failed('local', response, JsSIP_C.causes.WEBRTC_ERROR);
  15963. });
  15964. }
  15965. }).then(function () {
  15966. _this22._connection.setRemoteDescription(_answer).then(function () {
  15967. // Handle Session Timers.
  15968. _this22._handleSessionTimersInIncomingResponse(response);
  15969. _this22._accepted('remote', response);
  15970. _this22.sendRequest(JsSIP_C.ACK);
  15971. _this22._confirmed('local', null);
  15972. })["catch"](function (error) {
  15973. _this22._acceptAndTerminate(response, 488, 'Not Acceptable Here');
  15974. _this22._failed('remote', response, JsSIP_C.causes.BAD_MEDIA_DESCRIPTION);
  15975. debugerror('emit "peerconnection:setremotedescriptionfailed" [error:%o]', error);
  15976. _this22.emit('peerconnection:setremotedescriptionfailed', error);
  15977. });
  15978. });
  15979. break;
  15980. }
  15981. default:
  15982. {
  15983. var cause = Utils.sipErrorCause(response.status_code);
  15984. this._failed('remote', response, cause);
  15985. }
  15986. }
  15987. }
  15988. /**
  15989. * Send Re-INVITE
  15990. */
  15991. }, {
  15992. key: "_sendReinvite",
  15993. value: function _sendReinvite() {
  15994. var _this23 = this;
  15995. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  15996. debug('sendReinvite()');
  15997. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  15998. var eventHandlers = Utils.cloneObject(options.eventHandlers);
  15999. var rtcOfferConstraints = options.rtcOfferConstraints || this._rtcOfferConstraints || null;
  16000. var succeeded = false;
  16001. extraHeaders.push("Contact: ".concat(this._contact));
  16002. extraHeaders.push('Content-Type: application/sdp'); // Session Timers.
  16003. if (this._sessionTimers.running) {
  16004. extraHeaders.push("Session-Expires: ".concat(this._sessionTimers.currentExpires, ";refresher=").concat(this._sessionTimers.refresher ? 'uac' : 'uas'));
  16005. }
  16006. this._connectionPromiseQueue = this._connectionPromiseQueue.then(function () {
  16007. return _this23._createLocalDescription('offer', rtcOfferConstraints);
  16008. }).then(function (sdp) {
  16009. sdp = _this23._mangleOffer(sdp);
  16010. var e = {
  16011. originator: 'local',
  16012. type: 'offer',
  16013. sdp: sdp
  16014. };
  16015. debug('emit "sdp"');
  16016. _this23.emit('sdp', e);
  16017. _this23.sendRequest(JsSIP_C.INVITE, {
  16018. extraHeaders: extraHeaders,
  16019. body: sdp,
  16020. eventHandlers: {
  16021. onSuccessResponse: function onSuccessResponse(response) {
  16022. onSucceeded.call(_this23, response);
  16023. succeeded = true;
  16024. },
  16025. onErrorResponse: function onErrorResponse(response) {
  16026. onFailed.call(_this23, response);
  16027. },
  16028. onTransportError: function onTransportError() {
  16029. _this23.onTransportError(); // Do nothing because session ends.
  16030. },
  16031. onRequestTimeout: function onRequestTimeout() {
  16032. _this23.onRequestTimeout(); // Do nothing because session ends.
  16033. },
  16034. onDialogError: function onDialogError() {
  16035. _this23.onDialogError(); // Do nothing because session ends.
  16036. }
  16037. }
  16038. });
  16039. })["catch"](function () {
  16040. onFailed();
  16041. });
  16042. function onSucceeded(response) {
  16043. var _this24 = this;
  16044. if (this._status === C.STATUS_TERMINATED) {
  16045. return;
  16046. }
  16047. this.sendRequest(JsSIP_C.ACK); // If it is a 2XX retransmission exit now.
  16048. if (succeeded) {
  16049. return;
  16050. } // Handle Session Timers.
  16051. this._handleSessionTimersInIncomingResponse(response); // Must have SDP answer.
  16052. if (!response.body) {
  16053. onFailed.call(this);
  16054. return;
  16055. } else if (response.getHeader('Content-Type') !== 'application/sdp') {
  16056. onFailed.call(this);
  16057. return;
  16058. }
  16059. var e = {
  16060. originator: 'remote',
  16061. type: 'answer',
  16062. sdp: response.body
  16063. };
  16064. debug('emit "sdp"');
  16065. this.emit('sdp', e);
  16066. var answer = new RTCSessionDescription({
  16067. type: 'answer',
  16068. sdp: e.sdp
  16069. });
  16070. this._connectionPromiseQueue = this._connectionPromiseQueue.then(function () {
  16071. return _this24._connection.setRemoteDescription(answer);
  16072. }).then(function () {
  16073. if (eventHandlers.succeeded) {
  16074. eventHandlers.succeeded(response);
  16075. }
  16076. })["catch"](function (error) {
  16077. onFailed.call(_this24);
  16078. debugerror('emit "peerconnection:setremotedescriptionfailed" [error:%o]', error);
  16079. _this24.emit('peerconnection:setremotedescriptionfailed', error);
  16080. });
  16081. }
  16082. function onFailed(response) {
  16083. if (eventHandlers.failed) {
  16084. eventHandlers.failed(response);
  16085. }
  16086. }
  16087. }
  16088. /**
  16089. * Send UPDATE
  16090. */
  16091. }, {
  16092. key: "_sendUpdate",
  16093. value: function _sendUpdate() {
  16094. var _this25 = this;
  16095. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  16096. debug('sendUpdate()');
  16097. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  16098. var eventHandlers = Utils.cloneObject(options.eventHandlers);
  16099. var rtcOfferConstraints = options.rtcOfferConstraints || this._rtcOfferConstraints || null;
  16100. var sdpOffer = options.sdpOffer || false;
  16101. var succeeded = false;
  16102. extraHeaders.push("Contact: ".concat(this._contact)); // Session Timers.
  16103. if (this._sessionTimers.running) {
  16104. extraHeaders.push("Session-Expires: ".concat(this._sessionTimers.currentExpires, ";refresher=").concat(this._sessionTimers.refresher ? 'uac' : 'uas'));
  16105. }
  16106. if (sdpOffer) {
  16107. extraHeaders.push('Content-Type: application/sdp');
  16108. this._connectionPromiseQueue = this._connectionPromiseQueue.then(function () {
  16109. return _this25._createLocalDescription('offer', rtcOfferConstraints);
  16110. }).then(function (sdp) {
  16111. sdp = _this25._mangleOffer(sdp);
  16112. var e = {
  16113. originator: 'local',
  16114. type: 'offer',
  16115. sdp: sdp
  16116. };
  16117. debug('emit "sdp"');
  16118. _this25.emit('sdp', e);
  16119. _this25.sendRequest(JsSIP_C.UPDATE, {
  16120. extraHeaders: extraHeaders,
  16121. body: sdp,
  16122. eventHandlers: {
  16123. onSuccessResponse: function onSuccessResponse(response) {
  16124. onSucceeded.call(_this25, response);
  16125. succeeded = true;
  16126. },
  16127. onErrorResponse: function onErrorResponse(response) {
  16128. onFailed.call(_this25, response);
  16129. },
  16130. onTransportError: function onTransportError() {
  16131. _this25.onTransportError(); // Do nothing because session ends.
  16132. },
  16133. onRequestTimeout: function onRequestTimeout() {
  16134. _this25.onRequestTimeout(); // Do nothing because session ends.
  16135. },
  16136. onDialogError: function onDialogError() {
  16137. _this25.onDialogError(); // Do nothing because session ends.
  16138. }
  16139. }
  16140. });
  16141. })["catch"](function () {
  16142. onFailed.call(_this25);
  16143. });
  16144. } // No SDP.
  16145. else {
  16146. this.sendRequest(JsSIP_C.UPDATE, {
  16147. extraHeaders: extraHeaders,
  16148. eventHandlers: {
  16149. onSuccessResponse: function onSuccessResponse(response) {
  16150. onSucceeded.call(_this25, response);
  16151. },
  16152. onErrorResponse: function onErrorResponse(response) {
  16153. onFailed.call(_this25, response);
  16154. },
  16155. onTransportError: function onTransportError() {
  16156. _this25.onTransportError(); // Do nothing because session ends.
  16157. },
  16158. onRequestTimeout: function onRequestTimeout() {
  16159. _this25.onRequestTimeout(); // Do nothing because session ends.
  16160. },
  16161. onDialogError: function onDialogError() {
  16162. _this25.onDialogError(); // Do nothing because session ends.
  16163. }
  16164. }
  16165. });
  16166. }
  16167. function onSucceeded(response) {
  16168. var _this26 = this;
  16169. if (this._status === C.STATUS_TERMINATED) {
  16170. return;
  16171. } // If it is a 2XX retransmission exit now.
  16172. if (succeeded) {
  16173. return;
  16174. } // Handle Session Timers.
  16175. this._handleSessionTimersInIncomingResponse(response); // Must have SDP answer.
  16176. if (sdpOffer) {
  16177. if (!response.body) {
  16178. onFailed.call(this);
  16179. return;
  16180. } else if (response.getHeader('Content-Type') !== 'application/sdp') {
  16181. onFailed.call(this);
  16182. return;
  16183. }
  16184. var e = {
  16185. originator: 'remote',
  16186. type: 'answer',
  16187. sdp: response.body
  16188. };
  16189. debug('emit "sdp"');
  16190. this.emit('sdp', e);
  16191. var answer = new RTCSessionDescription({
  16192. type: 'answer',
  16193. sdp: e.sdp
  16194. });
  16195. this._connectionPromiseQueue = this._connectionPromiseQueue.then(function () {
  16196. return _this26._connection.setRemoteDescription(answer);
  16197. }).then(function () {
  16198. if (eventHandlers.succeeded) {
  16199. eventHandlers.succeeded(response);
  16200. }
  16201. })["catch"](function (error) {
  16202. onFailed.call(_this26);
  16203. debugerror('emit "peerconnection:setremotedescriptionfailed" [error:%o]', error);
  16204. _this26.emit('peerconnection:setremotedescriptionfailed', error);
  16205. });
  16206. } // No SDP answer.
  16207. else if (eventHandlers.succeeded) {
  16208. eventHandlers.succeeded(response);
  16209. }
  16210. }
  16211. function onFailed(response) {
  16212. if (eventHandlers.failed) {
  16213. eventHandlers.failed(response);
  16214. }
  16215. }
  16216. }
  16217. }, {
  16218. key: "_acceptAndTerminate",
  16219. value: function _acceptAndTerminate(response, status_code, reason_phrase) {
  16220. debug('acceptAndTerminate()');
  16221. var extraHeaders = [];
  16222. if (status_code) {
  16223. reason_phrase = reason_phrase || JsSIP_C.REASON_PHRASE[status_code] || '';
  16224. extraHeaders.push("Reason: SIP ;cause=".concat(status_code, "; text=\"").concat(reason_phrase, "\""));
  16225. } // An error on dialog creation will fire 'failed' event.
  16226. if (this._dialog || this._createDialog(response, 'UAC')) {
  16227. this.sendRequest(JsSIP_C.ACK);
  16228. this.sendRequest(JsSIP_C.BYE, {
  16229. extraHeaders: extraHeaders
  16230. });
  16231. } // Update session status.
  16232. this._status = C.STATUS_TERMINATED;
  16233. }
  16234. /**
  16235. * Correctly set the SDP direction attributes if the call is on local hold
  16236. */
  16237. }, {
  16238. key: "_mangleOffer",
  16239. value: function _mangleOffer(sdp) {
  16240. if (!this._localHold && !this._remoteHold) {
  16241. return sdp;
  16242. }
  16243. sdp = sdp_transform.parse(sdp); // Local hold.
  16244. if (this._localHold && !this._remoteHold) {
  16245. debug('mangleOffer() | me on hold, mangling offer');
  16246. var _iterator5 = _createForOfIteratorHelper(sdp.media),
  16247. _step5;
  16248. try {
  16249. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  16250. var m = _step5.value;
  16251. if (holdMediaTypes.indexOf(m.type) === -1) {
  16252. continue;
  16253. }
  16254. if (!m.direction) {
  16255. m.direction = 'sendonly';
  16256. } else if (m.direction === 'sendrecv') {
  16257. m.direction = 'sendonly';
  16258. } else if (m.direction === 'recvonly') {
  16259. m.direction = 'inactive';
  16260. }
  16261. }
  16262. } catch (err) {
  16263. _iterator5.e(err);
  16264. } finally {
  16265. _iterator5.f();
  16266. }
  16267. } // Local and remote hold.
  16268. else if (this._localHold && this._remoteHold) {
  16269. debug('mangleOffer() | both on hold, mangling offer');
  16270. var _iterator6 = _createForOfIteratorHelper(sdp.media),
  16271. _step6;
  16272. try {
  16273. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  16274. var _m = _step6.value;
  16275. if (holdMediaTypes.indexOf(_m.type) === -1) {
  16276. continue;
  16277. }
  16278. _m.direction = 'inactive';
  16279. }
  16280. } catch (err) {
  16281. _iterator6.e(err);
  16282. } finally {
  16283. _iterator6.f();
  16284. }
  16285. } // Remote hold.
  16286. else if (this._remoteHold) {
  16287. debug('mangleOffer() | remote on hold, mangling offer');
  16288. var _iterator7 = _createForOfIteratorHelper(sdp.media),
  16289. _step7;
  16290. try {
  16291. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  16292. var _m2 = _step7.value;
  16293. if (holdMediaTypes.indexOf(_m2.type) === -1) {
  16294. continue;
  16295. }
  16296. if (!_m2.direction) {
  16297. _m2.direction = 'recvonly';
  16298. } else if (_m2.direction === 'sendrecv') {
  16299. _m2.direction = 'recvonly';
  16300. } else if (_m2.direction === 'recvonly') {
  16301. _m2.direction = 'inactive';
  16302. }
  16303. }
  16304. } catch (err) {
  16305. _iterator7.e(err);
  16306. } finally {
  16307. _iterator7.f();
  16308. }
  16309. }
  16310. return sdp_transform.write(sdp);
  16311. }
  16312. }, {
  16313. key: "_setLocalMediaStatus",
  16314. value: function _setLocalMediaStatus() {
  16315. var enableAudio = true,
  16316. enableVideo = true;
  16317. if (this._localHold || this._remoteHold) {
  16318. enableAudio = false;
  16319. enableVideo = false;
  16320. }
  16321. if (this._audioMuted) {
  16322. enableAudio = false;
  16323. }
  16324. if (this._videoMuted) {
  16325. enableVideo = false;
  16326. }
  16327. this._toggleMuteAudio(!enableAudio);
  16328. this._toggleMuteVideo(!enableVideo);
  16329. }
  16330. /**
  16331. * Handle SessionTimers for an incoming INVITE or UPDATE.
  16332. * @param {IncomingRequest} request
  16333. * @param {Array} responseExtraHeaders Extra headers for the 200 response.
  16334. */
  16335. }, {
  16336. key: "_handleSessionTimersInIncomingRequest",
  16337. value: function _handleSessionTimersInIncomingRequest(request, responseExtraHeaders) {
  16338. if (!this._sessionTimers.enabled) {
  16339. return;
  16340. }
  16341. var session_expires_refresher;
  16342. if (request.session_expires && request.session_expires >= JsSIP_C.MIN_SESSION_EXPIRES) {
  16343. this._sessionTimers.currentExpires = request.session_expires;
  16344. session_expires_refresher = request.session_expires_refresher || 'uas';
  16345. } else {
  16346. this._sessionTimers.currentExpires = this._sessionTimers.defaultExpires;
  16347. session_expires_refresher = 'uas';
  16348. }
  16349. responseExtraHeaders.push("Session-Expires: ".concat(this._sessionTimers.currentExpires, ";refresher=").concat(session_expires_refresher));
  16350. this._sessionTimers.refresher = session_expires_refresher === 'uas';
  16351. this._runSessionTimer();
  16352. }
  16353. /**
  16354. * Handle SessionTimers for an incoming response to INVITE or UPDATE.
  16355. * @param {IncomingResponse} response
  16356. */
  16357. }, {
  16358. key: "_handleSessionTimersInIncomingResponse",
  16359. value: function _handleSessionTimersInIncomingResponse(response) {
  16360. if (!this._sessionTimers.enabled) {
  16361. return;
  16362. }
  16363. var session_expires_refresher;
  16364. if (response.session_expires && response.session_expires >= JsSIP_C.MIN_SESSION_EXPIRES) {
  16365. this._sessionTimers.currentExpires = response.session_expires;
  16366. session_expires_refresher = response.session_expires_refresher || 'uac';
  16367. } else {
  16368. this._sessionTimers.currentExpires = this._sessionTimers.defaultExpires;
  16369. session_expires_refresher = 'uac';
  16370. }
  16371. this._sessionTimers.refresher = session_expires_refresher === 'uac';
  16372. this._runSessionTimer();
  16373. }
  16374. }, {
  16375. key: "_runSessionTimer",
  16376. value: function _runSessionTimer() {
  16377. var _this27 = this;
  16378. var expires = this._sessionTimers.currentExpires;
  16379. this._sessionTimers.running = true;
  16380. clearTimeout(this._sessionTimers.timer); // I'm the refresher.
  16381. if (this._sessionTimers.refresher) {
  16382. this._sessionTimers.timer = setTimeout(function () {
  16383. if (_this27._status === C.STATUS_TERMINATED) {
  16384. return;
  16385. }
  16386. debug('runSessionTimer() | sending session refresh request');
  16387. if (_this27._sessionTimers.refreshMethod === JsSIP_C.UPDATE) {
  16388. _this27._sendUpdate();
  16389. } else {
  16390. _this27._sendReinvite();
  16391. }
  16392. }, expires * 500); // Half the given interval (as the RFC states).
  16393. } // I'm not the refresher.
  16394. else {
  16395. this._sessionTimers.timer = setTimeout(function () {
  16396. if (_this27._status === C.STATUS_TERMINATED) {
  16397. return;
  16398. }
  16399. debugerror('runSessionTimer() | timer expired, terminating the session');
  16400. _this27.terminate({
  16401. cause: JsSIP_C.causes.REQUEST_TIMEOUT,
  16402. status_code: 408,
  16403. reason_phrase: 'Session Timer Expired'
  16404. });
  16405. }, expires * 1100);
  16406. }
  16407. }
  16408. }, {
  16409. key: "_toggleMuteAudio",
  16410. value: function _toggleMuteAudio(mute) {
  16411. var senders = this._connection.getSenders().filter(function (sender) {
  16412. return sender.track && sender.track.kind === 'audio';
  16413. });
  16414. var _iterator8 = _createForOfIteratorHelper(senders),
  16415. _step8;
  16416. try {
  16417. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  16418. var sender = _step8.value;
  16419. sender.track.enabled = !mute;
  16420. }
  16421. } catch (err) {
  16422. _iterator8.e(err);
  16423. } finally {
  16424. _iterator8.f();
  16425. }
  16426. }
  16427. }, {
  16428. key: "_toggleMuteVideo",
  16429. value: function _toggleMuteVideo(mute) {
  16430. var senders = this._connection.getSenders().filter(function (sender) {
  16431. return sender.track && sender.track.kind === 'video';
  16432. });
  16433. var _iterator9 = _createForOfIteratorHelper(senders),
  16434. _step9;
  16435. try {
  16436. for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
  16437. var sender = _step9.value;
  16438. sender.track.enabled = !mute;
  16439. }
  16440. } catch (err) {
  16441. _iterator9.e(err);
  16442. } finally {
  16443. _iterator9.f();
  16444. }
  16445. }
  16446. }, {
  16447. key: "_newRTCSession",
  16448. value: function _newRTCSession(originator, request) {
  16449. debug('newRTCSession()');
  16450. this._ua.newRTCSession(this, {
  16451. originator: originator,
  16452. session: this,
  16453. request: request
  16454. });
  16455. }
  16456. }, {
  16457. key: "_connecting",
  16458. value: function _connecting(request) {
  16459. debug('session connecting');
  16460. debug('emit "connecting"');
  16461. this.emit('connecting', {
  16462. request: request
  16463. });
  16464. }
  16465. }, {
  16466. key: "_progress",
  16467. value: function _progress(originator, response) {
  16468. debug('session progress');
  16469. debug('emit "progress"');
  16470. this.emit('progress', {
  16471. originator: originator,
  16472. response: response || null
  16473. });
  16474. }
  16475. }, {
  16476. key: "_accepted",
  16477. value: function _accepted(originator, message) {
  16478. debug('session accepted');
  16479. this._start_time = new Date();
  16480. debug('emit "accepted"');
  16481. this.emit('accepted', {
  16482. originator: originator,
  16483. response: message || null
  16484. });
  16485. }
  16486. }, {
  16487. key: "_confirmed",
  16488. value: function _confirmed(originator, ack) {
  16489. debug('session confirmed');
  16490. this._is_confirmed = true;
  16491. debug('emit "confirmed"');
  16492. this.emit('confirmed', {
  16493. originator: originator,
  16494. ack: ack || null
  16495. });
  16496. }
  16497. }, {
  16498. key: "_ended",
  16499. value: function _ended(originator, message, cause) {
  16500. debug('session ended');
  16501. this._end_time = new Date();
  16502. this._close();
  16503. debug('emit "ended"');
  16504. this.emit('ended', {
  16505. originator: originator,
  16506. message: message || null,
  16507. cause: cause
  16508. });
  16509. }
  16510. }, {
  16511. key: "_failed",
  16512. value: function _failed(originator, message, cause) {
  16513. debug('session failed'); // Emit private '_failed' event first.
  16514. debug('emit "_failed"');
  16515. this.emit('_failed', {
  16516. originator: originator,
  16517. message: message || null,
  16518. cause: cause
  16519. });
  16520. this._close();
  16521. debug('emit "failed"');
  16522. this.emit('failed', {
  16523. originator: originator,
  16524. message: message || null,
  16525. cause: cause
  16526. });
  16527. }
  16528. }, {
  16529. key: "_onhold",
  16530. value: function _onhold(originator) {
  16531. debug('session onhold');
  16532. this._setLocalMediaStatus();
  16533. debug('emit "hold"');
  16534. this.emit('hold', {
  16535. originator: originator
  16536. });
  16537. }
  16538. }, {
  16539. key: "_onunhold",
  16540. value: function _onunhold(originator) {
  16541. debug('session onunhold');
  16542. this._setLocalMediaStatus();
  16543. debug('emit "unhold"');
  16544. this.emit('unhold', {
  16545. originator: originator
  16546. });
  16547. }
  16548. }, {
  16549. key: "_onmute",
  16550. value: function _onmute(_ref5) {
  16551. var audio = _ref5.audio,
  16552. video = _ref5.video;
  16553. debug('session onmute');
  16554. this._setLocalMediaStatus();
  16555. debug('emit "muted"');
  16556. this.emit('muted', {
  16557. audio: audio,
  16558. video: video
  16559. });
  16560. }
  16561. }, {
  16562. key: "_onunmute",
  16563. value: function _onunmute(_ref6) {
  16564. var audio = _ref6.audio,
  16565. video = _ref6.video;
  16566. debug('session onunmute');
  16567. this._setLocalMediaStatus();
  16568. debug('emit "unmuted"');
  16569. this.emit('unmuted', {
  16570. audio: audio,
  16571. video: video
  16572. });
  16573. }
  16574. }, {
  16575. key: "C",
  16576. get: function get() {
  16577. return C;
  16578. } // Expose session failed/ended causes as a property of the RTCSession instance.
  16579. }, {
  16580. key: "causes",
  16581. get: function get() {
  16582. return JsSIP_C.causes;
  16583. }
  16584. }, {
  16585. key: "id",
  16586. get: function get() {
  16587. return this._id;
  16588. }
  16589. }, {
  16590. key: "connection",
  16591. get: function get() {
  16592. return this._connection;
  16593. }
  16594. }, {
  16595. key: "contact",
  16596. get: function get() {
  16597. return this._contact;
  16598. }
  16599. }, {
  16600. key: "direction",
  16601. get: function get() {
  16602. return this._direction;
  16603. }
  16604. }, {
  16605. key: "local_identity",
  16606. get: function get() {
  16607. return this._local_identity;
  16608. }
  16609. }, {
  16610. key: "remote_identity",
  16611. get: function get() {
  16612. return this._remote_identity;
  16613. }
  16614. }, {
  16615. key: "start_time",
  16616. get: function get() {
  16617. return this._start_time;
  16618. }
  16619. }, {
  16620. key: "end_time",
  16621. get: function get() {
  16622. return this._end_time;
  16623. }
  16624. }, {
  16625. key: "data",
  16626. get: function get() {
  16627. return this._data;
  16628. },
  16629. set: function set(_data) {
  16630. this._data = _data;
  16631. }
  16632. }, {
  16633. key: "status",
  16634. get: function get() {
  16635. return this._status;
  16636. }
  16637. }]);
  16638. return RTCSession;
  16639. }(EventEmitter);
  16640. },{"./Constants":2,"./Dialog":3,"./Exceptions":6,"./RTCSession/DTMF":13,"./RTCSession/Info":14,"./RTCSession/ReferNotifier":15,"./RTCSession/ReferSubscriber":16,"./RequestSender":18,"./SIPMessage":19,"./Timers":21,"./Transactions":22,"./URI":25,"./Utils":26,"debug":30,"events":29,"sdp-transform":35}],13:[function(require,module,exports){
  16641. "use strict";
  16642. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16643. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16644. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16645. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16646. function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16647. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16648. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16649. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  16650. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16651. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  16652. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16653. var EventEmitter = require('events').EventEmitter;
  16654. var JsSIP_C = require('../Constants');
  16655. var Exceptions = require('../Exceptions');
  16656. var Utils = require('../Utils');
  16657. var debug = require('debug')('JsSIP:RTCSession:DTMF');
  16658. var debugerror = require('debug')('JsSIP:ERROR:RTCSession:DTMF');
  16659. debugerror.log = console.warn.bind(console);
  16660. var C = {
  16661. MIN_DURATION: 70,
  16662. MAX_DURATION: 6000,
  16663. DEFAULT_DURATION: 100,
  16664. MIN_INTER_TONE_GAP: 50,
  16665. DEFAULT_INTER_TONE_GAP: 500
  16666. };
  16667. module.exports = /*#__PURE__*/function (_EventEmitter) {
  16668. _inherits(DTMF, _EventEmitter);
  16669. var _super = _createSuper(DTMF);
  16670. function DTMF(session) {
  16671. var _this;
  16672. _classCallCheck(this, DTMF);
  16673. _this = _super.call(this);
  16674. _this._session = session;
  16675. _this._direction = null;
  16676. _this._tone = null;
  16677. _this._duration = null;
  16678. _this._request = null;
  16679. return _this;
  16680. }
  16681. _createClass(DTMF, [{
  16682. key: "send",
  16683. value: function send(tone) {
  16684. var _this2 = this;
  16685. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  16686. if (tone === undefined) {
  16687. throw new TypeError('Not enough arguments');
  16688. }
  16689. this._direction = 'outgoing'; // Check RTCSession Status.
  16690. if (this._session.status !== this._session.C.STATUS_CONFIRMED && this._session.status !== this._session.C.STATUS_WAITING_FOR_ACK) {
  16691. throw new Exceptions.InvalidStateError(this._session.status);
  16692. }
  16693. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  16694. this.eventHandlers = Utils.cloneObject(options.eventHandlers); // Check tone type.
  16695. if (typeof tone === 'string') {
  16696. tone = tone.toUpperCase();
  16697. } else if (typeof tone === 'number') {
  16698. tone = tone.toString();
  16699. } else {
  16700. throw new TypeError("Invalid tone: ".concat(tone));
  16701. } // Check tone value.
  16702. if (!tone.match(/^[0-9A-DR#*]$/)) {
  16703. throw new TypeError("Invalid tone: ".concat(tone));
  16704. } else {
  16705. this._tone = tone;
  16706. } // Duration is checked/corrected in RTCSession.
  16707. this._duration = options.duration;
  16708. extraHeaders.push('Content-Type: application/dtmf-relay');
  16709. var body = "Signal=".concat(this._tone, "\r\n");
  16710. body += "Duration=".concat(this._duration);
  16711. this._session.newDTMF({
  16712. originator: 'local',
  16713. dtmf: this,
  16714. request: this._request
  16715. });
  16716. this._session.sendRequest(JsSIP_C.INFO, {
  16717. extraHeaders: extraHeaders,
  16718. eventHandlers: {
  16719. onSuccessResponse: function onSuccessResponse(response) {
  16720. _this2.emit('succeeded', {
  16721. originator: 'remote',
  16722. response: response
  16723. });
  16724. },
  16725. onErrorResponse: function onErrorResponse(response) {
  16726. if (_this2.eventHandlers.onFailed) {
  16727. _this2.eventHandlers.onFailed();
  16728. }
  16729. _this2.emit('failed', {
  16730. originator: 'remote',
  16731. response: response
  16732. });
  16733. },
  16734. onRequestTimeout: function onRequestTimeout() {
  16735. _this2._session.onRequestTimeout();
  16736. },
  16737. onTransportError: function onTransportError() {
  16738. _this2._session.onTransportError();
  16739. },
  16740. onDialogError: function onDialogError() {
  16741. _this2._session.onDialogError();
  16742. }
  16743. },
  16744. body: body
  16745. });
  16746. }
  16747. }, {
  16748. key: "init_incoming",
  16749. value: function init_incoming(request) {
  16750. var reg_tone = /^(Signal\s*?=\s*?)([0-9A-D#*]{1})(\s)?.*/;
  16751. var reg_duration = /^(Duration\s?=\s?)([0-9]{1,4})(\s)?.*/;
  16752. this._direction = 'incoming';
  16753. this._request = request;
  16754. request.reply(200);
  16755. if (request.body) {
  16756. var body = request.body.split('\n');
  16757. if (body.length >= 1) {
  16758. if (reg_tone.test(body[0])) {
  16759. this._tone = body[0].replace(reg_tone, '$2');
  16760. }
  16761. }
  16762. if (body.length >= 2) {
  16763. if (reg_duration.test(body[1])) {
  16764. this._duration = parseInt(body[1].replace(reg_duration, '$2'), 10);
  16765. }
  16766. }
  16767. }
  16768. if (!this._duration) {
  16769. this._duration = C.DEFAULT_DURATION;
  16770. }
  16771. if (!this._tone) {
  16772. debug('invalid INFO DTMF received, discarded');
  16773. } else {
  16774. this._session.newDTMF({
  16775. originator: 'remote',
  16776. dtmf: this,
  16777. request: request
  16778. });
  16779. }
  16780. }
  16781. }, {
  16782. key: "tone",
  16783. get: function get() {
  16784. return this._tone;
  16785. }
  16786. }, {
  16787. key: "duration",
  16788. get: function get() {
  16789. return this._duration;
  16790. }
  16791. }]);
  16792. return DTMF;
  16793. }(EventEmitter);
  16794. /**
  16795. * Expose C object.
  16796. */
  16797. module.exports.C = C;
  16798. },{"../Constants":2,"../Exceptions":6,"../Utils":26,"debug":30,"events":29}],14:[function(require,module,exports){
  16799. "use strict";
  16800. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16801. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16802. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16803. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16804. function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16805. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16806. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16807. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  16808. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16809. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  16810. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16811. var EventEmitter = require('events').EventEmitter;
  16812. var debugerror = require('debug')('JsSIP:ERROR:RTCSession:Info');
  16813. debugerror.log = console.warn.bind(console);
  16814. var JsSIP_C = require('../Constants');
  16815. var Exceptions = require('../Exceptions');
  16816. var Utils = require('../Utils');
  16817. module.exports = /*#__PURE__*/function (_EventEmitter) {
  16818. _inherits(Info, _EventEmitter);
  16819. var _super = _createSuper(Info);
  16820. function Info(session) {
  16821. var _this;
  16822. _classCallCheck(this, Info);
  16823. _this = _super.call(this);
  16824. _this._session = session;
  16825. _this._direction = null;
  16826. _this._contentType = null;
  16827. _this._body = null;
  16828. return _this;
  16829. }
  16830. _createClass(Info, [{
  16831. key: "send",
  16832. value: function send(contentType, body) {
  16833. var _this2 = this;
  16834. var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
  16835. this._direction = 'outgoing';
  16836. if (contentType === undefined) {
  16837. throw new TypeError('Not enough arguments');
  16838. } // Check RTCSession Status.
  16839. if (this._session.status !== this._session.C.STATUS_CONFIRMED && this._session.status !== this._session.C.STATUS_WAITING_FOR_ACK) {
  16840. throw new Exceptions.InvalidStateError(this._session.status);
  16841. }
  16842. this._contentType = contentType;
  16843. this._body = body;
  16844. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  16845. extraHeaders.push("Content-Type: ".concat(contentType));
  16846. this._session.newInfo({
  16847. originator: 'local',
  16848. info: this,
  16849. request: this.request
  16850. });
  16851. this._session.sendRequest(JsSIP_C.INFO, {
  16852. extraHeaders: extraHeaders,
  16853. eventHandlers: {
  16854. onSuccessResponse: function onSuccessResponse(response) {
  16855. _this2.emit('succeeded', {
  16856. originator: 'remote',
  16857. response: response
  16858. });
  16859. },
  16860. onErrorResponse: function onErrorResponse(response) {
  16861. _this2.emit('failed', {
  16862. originator: 'remote',
  16863. response: response
  16864. });
  16865. },
  16866. onTransportError: function onTransportError() {
  16867. _this2._session.onTransportError();
  16868. },
  16869. onRequestTimeout: function onRequestTimeout() {
  16870. _this2._session.onRequestTimeout();
  16871. },
  16872. onDialogError: function onDialogError() {
  16873. _this2._session.onDialogError();
  16874. }
  16875. },
  16876. body: body
  16877. });
  16878. }
  16879. }, {
  16880. key: "init_incoming",
  16881. value: function init_incoming(request) {
  16882. this._direction = 'incoming';
  16883. this.request = request;
  16884. request.reply(200);
  16885. this._contentType = request.getHeader('content-type');
  16886. this._body = request.body;
  16887. this._session.newInfo({
  16888. originator: 'remote',
  16889. info: this,
  16890. request: request
  16891. });
  16892. }
  16893. }, {
  16894. key: "contentType",
  16895. get: function get() {
  16896. return this._contentType;
  16897. }
  16898. }, {
  16899. key: "body",
  16900. get: function get() {
  16901. return this._body;
  16902. }
  16903. }]);
  16904. return Info;
  16905. }(EventEmitter);
  16906. },{"../Constants":2,"../Exceptions":6,"../Utils":26,"debug":30,"events":29}],15:[function(require,module,exports){
  16907. "use strict";
  16908. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16909. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16910. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16911. var JsSIP_C = require('../Constants');
  16912. var debug = require('debug')('JsSIP:RTCSession:ReferNotifier');
  16913. var C = {
  16914. event_type: 'refer',
  16915. body_type: 'message/sipfrag;version=2.0',
  16916. expires: 300
  16917. };
  16918. module.exports = /*#__PURE__*/function () {
  16919. function ReferNotifier(session, id, expires) {
  16920. _classCallCheck(this, ReferNotifier);
  16921. this._session = session;
  16922. this._id = id;
  16923. this._expires = expires || C.expires;
  16924. this._active = true; // The creation of a Notifier results in an immediate NOTIFY.
  16925. this.notify(100);
  16926. }
  16927. _createClass(ReferNotifier, [{
  16928. key: "notify",
  16929. value: function notify(code, reason) {
  16930. debug('notify()');
  16931. if (this._active === false) {
  16932. return;
  16933. }
  16934. reason = reason || JsSIP_C.REASON_PHRASE[code] || '';
  16935. var state;
  16936. if (code >= 200) {
  16937. state = 'terminated;reason=noresource';
  16938. } else {
  16939. state = "active;expires=".concat(this._expires);
  16940. } // Put this in a try/catch block.
  16941. this._session.sendRequest(JsSIP_C.NOTIFY, {
  16942. extraHeaders: ["Event: ".concat(C.event_type, ";id=").concat(this._id), "Subscription-State: ".concat(state), "Content-Type: ".concat(C.body_type)],
  16943. body: "SIP/2.0 ".concat(code, " ").concat(reason),
  16944. eventHandlers: {
  16945. // If a negative response is received, subscription is canceled.
  16946. onErrorResponse: function onErrorResponse() {
  16947. this._active = false;
  16948. }
  16949. }
  16950. });
  16951. }
  16952. }]);
  16953. return ReferNotifier;
  16954. }();
  16955. },{"../Constants":2,"debug":30}],16:[function(require,module,exports){
  16956. "use strict";
  16957. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  16958. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  16959. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  16960. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  16961. function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  16962. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  16963. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  16964. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  16965. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  16966. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  16967. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  16968. var EventEmitter = require('events').EventEmitter;
  16969. var JsSIP_C = require('../Constants');
  16970. var Grammar = require('../Grammar');
  16971. var Utils = require('../Utils');
  16972. var debug = require('debug')('JsSIP:RTCSession:ReferSubscriber');
  16973. module.exports = /*#__PURE__*/function (_EventEmitter) {
  16974. _inherits(ReferSubscriber, _EventEmitter);
  16975. var _super = _createSuper(ReferSubscriber);
  16976. function ReferSubscriber(session) {
  16977. var _this;
  16978. _classCallCheck(this, ReferSubscriber);
  16979. _this = _super.call(this);
  16980. _this._id = null;
  16981. _this._session = session;
  16982. return _this;
  16983. }
  16984. _createClass(ReferSubscriber, [{
  16985. key: "sendRefer",
  16986. value: function sendRefer(target) {
  16987. var _this2 = this;
  16988. var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  16989. debug('sendRefer()');
  16990. var extraHeaders = Utils.cloneArray(options.extraHeaders);
  16991. var eventHandlers = Utils.cloneObject(options.eventHandlers); // Set event handlers.
  16992. for (var event in eventHandlers) {
  16993. if (Object.prototype.hasOwnProperty.call(eventHandlers, event)) {
  16994. this.on(event, eventHandlers[event]);
  16995. }
  16996. } // Replaces URI header field.
  16997. var replaces = null;
  16998. if (options.replaces) {
  16999. replaces = options.replaces._request.call_id;
  17000. replaces += ";to-tag=".concat(options.replaces._to_tag);
  17001. replaces += ";from-tag=".concat(options.replaces._from_tag);
  17002. replaces = encodeURIComponent(replaces);
  17003. } // Refer-To header field.
  17004. var referTo = "Refer-To: <".concat(target).concat(replaces ? "?Replaces=".concat(replaces) : '', ">");
  17005. extraHeaders.push(referTo); // Referred-By header field.
  17006. var referredBy = "Referred-By: <".concat(this._session._ua._configuration.uri._scheme, ":").concat(this._session._ua._configuration.uri._user, "@").concat(this._session._ua._configuration.uri._host, ">");
  17007. extraHeaders.push(referredBy);
  17008. extraHeaders.push("Contact: ".concat(this._session.contact));
  17009. var request = this._session.sendRequest(JsSIP_C.REFER, {
  17010. extraHeaders: extraHeaders,
  17011. eventHandlers: {
  17012. onSuccessResponse: function onSuccessResponse(response) {
  17013. _this2._requestSucceeded(response);
  17014. },
  17015. onErrorResponse: function onErrorResponse(response) {
  17016. _this2._requestFailed(response, JsSIP_C.causes.REJECTED);
  17017. },
  17018. onTransportError: function onTransportError() {
  17019. _this2._requestFailed(null, JsSIP_C.causes.CONNECTION_ERROR);
  17020. },
  17021. onRequestTimeout: function onRequestTimeout() {
  17022. _this2._requestFailed(null, JsSIP_C.causes.REQUEST_TIMEOUT);
  17023. },
  17024. onDialogError: function onDialogError() {
  17025. _this2._requestFailed(null, JsSIP_C.causes.DIALOG_ERROR);
  17026. }
  17027. }
  17028. });
  17029. this._id = request.cseq;
  17030. }
  17031. }, {
  17032. key: "receiveNotify",
  17033. value: function receiveNotify(request) {
  17034. debug('receiveNotify()');
  17035. if (!request.body) {
  17036. return;
  17037. }
  17038. var status_line = Grammar.parse(request.body.trim(), 'Status_Line');
  17039. if (status_line === -1) {
  17040. debug("receiveNotify() | error parsing NOTIFY body: \"".concat(request.body, "\""));
  17041. return;
  17042. }
  17043. switch (true) {
  17044. case /^100$/.test(status_line.status_code):
  17045. this.emit('trying', {
  17046. request: request,
  17047. status_line: status_line
  17048. });
  17049. break;
  17050. case /^1[0-9]{2}$/.test(status_line.status_code):
  17051. this.emit('progress', {
  17052. request: request,
  17053. status_line: status_line
  17054. });
  17055. break;
  17056. case /^2[0-9]{2}$/.test(status_line.status_code):
  17057. this.emit('accepted', {
  17058. request: request,
  17059. status_line: status_line
  17060. });
  17061. break;
  17062. default:
  17063. this.emit('failed', {
  17064. request: request,
  17065. status_line: status_line
  17066. });
  17067. break;
  17068. }
  17069. }
  17070. }, {
  17071. key: "_requestSucceeded",
  17072. value: function _requestSucceeded(response) {
  17073. debug('REFER succeeded');
  17074. debug('emit "requestSucceeded"');
  17075. this.emit('requestSucceeded', {
  17076. response: response
  17077. });
  17078. }
  17079. }, {
  17080. key: "_requestFailed",
  17081. value: function _requestFailed(response, cause) {
  17082. debug('REFER failed');
  17083. debug('emit "requestFailed"');
  17084. this.emit('requestFailed', {
  17085. response: response || null,
  17086. cause: cause
  17087. });
  17088. }
  17089. }, {
  17090. key: "id",
  17091. get: function get() {
  17092. return this._id;
  17093. }
  17094. }]);
  17095. return ReferSubscriber;
  17096. }(EventEmitter);
  17097. },{"../Constants":2,"../Grammar":7,"../Utils":26,"debug":30,"events":29}],17:[function(require,module,exports){
  17098. "use strict";
  17099. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17100. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  17101. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17102. var Utils = require('./Utils');
  17103. var JsSIP_C = require('./Constants');
  17104. var SIPMessage = require('./SIPMessage');
  17105. var RequestSender = require('./RequestSender');
  17106. var debug = require('debug')('JsSIP:Registrator');
  17107. var MIN_REGISTER_EXPIRES = 10; // In seconds.
  17108. module.exports = /*#__PURE__*/function () {
  17109. function Registrator(ua, transport) {
  17110. _classCallCheck(this, Registrator);
  17111. var reg_id = 1; // Force reg_id to 1.
  17112. this._ua = ua;
  17113. this._transport = transport;
  17114. this._registrar = ua.configuration.registrar_server;
  17115. this._expires = ua.configuration.register_expires; // Call-ID and CSeq values RFC3261 10.2.
  17116. this._call_id = Utils.createRandomToken(22);
  17117. this._cseq = 0;
  17118. this._to_uri = ua.configuration.uri;
  17119. this._registrationTimer = null; // Ongoing Register request.
  17120. this._registering = false; // Set status.
  17121. this._registered = false; // Contact header.
  17122. this._contact = this._ua.contact.toString(); // Sip.ice media feature tag (RFC 5768).
  17123. this._contact += ';+sip.ice'; // Custom headers for REGISTER and un-REGISTER.
  17124. this._extraHeaders = []; // Custom Contact header params for REGISTER and un-REGISTER.
  17125. this._extraContactParams = '';
  17126. if (reg_id) {
  17127. this._contact += ";reg-id=".concat(reg_id);
  17128. this._contact += ";+sip.instance=\"<urn:uuid:".concat(this._ua.configuration.instance_id, ">\"");
  17129. }
  17130. }
  17131. _createClass(Registrator, [{
  17132. key: "setExtraHeaders",
  17133. value: function setExtraHeaders(extraHeaders) {
  17134. if (!Array.isArray(extraHeaders)) {
  17135. extraHeaders = [];
  17136. }
  17137. this._extraHeaders = extraHeaders.slice();
  17138. }
  17139. }, {
  17140. key: "setExtraContactParams",
  17141. value: function setExtraContactParams(extraContactParams) {
  17142. if (!(extraContactParams instanceof Object)) {
  17143. extraContactParams = {};
  17144. } // Reset it.
  17145. this._extraContactParams = '';
  17146. for (var param_key in extraContactParams) {
  17147. if (Object.prototype.hasOwnProperty.call(extraContactParams, param_key)) {
  17148. var param_value = extraContactParams[param_key];
  17149. this._extraContactParams += ";".concat(param_key);
  17150. if (param_value) {
  17151. this._extraContactParams += "=".concat(param_value);
  17152. }
  17153. }
  17154. }
  17155. }
  17156. }, {
  17157. key: "register",
  17158. value: function register() {
  17159. var _this = this;
  17160. if (this._registering) {
  17161. debug('Register request in progress...');
  17162. return;
  17163. }
  17164. var extraHeaders = this._extraHeaders.slice();
  17165. extraHeaders.push("Contact: ".concat(this._contact, ";expires=").concat(this._expires).concat(this._extraContactParams));
  17166. extraHeaders.push("Expires: ".concat(this._expires));
  17167. var request = new SIPMessage.OutgoingRequest(JsSIP_C.REGISTER, this._registrar, this._ua, {
  17168. 'to_uri': this._to_uri,
  17169. 'call_id': this._call_id,
  17170. 'cseq': this._cseq += 1
  17171. }, extraHeaders);
  17172. var request_sender = new RequestSender(this._ua, request, {
  17173. onRequestTimeout: function onRequestTimeout() {
  17174. _this._registrationFailure(null, JsSIP_C.causes.REQUEST_TIMEOUT);
  17175. },
  17176. onTransportError: function onTransportError() {
  17177. _this._registrationFailure(null, JsSIP_C.causes.CONNECTION_ERROR);
  17178. },
  17179. // Increase the CSeq on authentication.
  17180. onAuthenticated: function onAuthenticated() {
  17181. _this._cseq += 1;
  17182. },
  17183. onReceiveResponse: function onReceiveResponse(response) {
  17184. // Discard responses to older REGISTER/un-REGISTER requests.
  17185. if (response.cseq !== _this._cseq) {
  17186. return;
  17187. } // Clear registration timer.
  17188. if (_this._registrationTimer !== null) {
  17189. clearTimeout(_this._registrationTimer);
  17190. _this._registrationTimer = null;
  17191. }
  17192. switch (true) {
  17193. case /^1[0-9]{2}$/.test(response.status_code):
  17194. {
  17195. // Ignore provisional responses.
  17196. break;
  17197. }
  17198. case /^2[0-9]{2}$/.test(response.status_code):
  17199. {
  17200. _this._registering = false;
  17201. if (!response.hasHeader('Contact')) {
  17202. debug('no Contact header in response to REGISTER, response ignored');
  17203. break;
  17204. }
  17205. var contacts = response.headers['Contact'].reduce(function (a, b) {
  17206. return a.concat(b.parsed);
  17207. }, []); // Get the Contact pointing to us and update the expires value accordingly.
  17208. var contact = contacts.find(function (element) {
  17209. return element.uri.user === _this._ua.contact.uri.user;
  17210. });
  17211. if (!contact) {
  17212. debug('no Contact header pointing to us, response ignored');
  17213. break;
  17214. }
  17215. var expires = contact.getParam('expires');
  17216. if (!expires && response.hasHeader('expires')) {
  17217. expires = response.getHeader('expires');
  17218. }
  17219. if (!expires) {
  17220. expires = _this._expires;
  17221. }
  17222. expires = Number(expires);
  17223. if (expires < MIN_REGISTER_EXPIRES) expires = MIN_REGISTER_EXPIRES; // Re-Register or emit an event before the expiration interval has elapsed.
  17224. // For that, decrease the expires value. ie: 3 seconds.
  17225. _this._registrationTimer = setTimeout(function () {
  17226. _this._registrationTimer = null; // If there are no listeners for registrationExpiring, renew registration.
  17227. // If there are listeners, let the function listening do the register call.
  17228. if (_this._ua.listeners('registrationExpiring').length === 0) {
  17229. _this.register();
  17230. } else {
  17231. _this._ua.emit('registrationExpiring');
  17232. }
  17233. }, expires * 1000 - 5000); // Save gruu values.
  17234. if (contact.hasParam('temp-gruu')) {
  17235. _this._ua.contact.temp_gruu = contact.getParam('temp-gruu').replace(/"/g, '');
  17236. }
  17237. if (contact.hasParam('pub-gruu')) {
  17238. _this._ua.contact.pub_gruu = contact.getParam('pub-gruu').replace(/"/g, '');
  17239. }
  17240. if (!_this._registered) {
  17241. _this._registered = true;
  17242. _this._ua.registered({
  17243. response: response
  17244. });
  17245. }
  17246. break;
  17247. }
  17248. // Interval too brief RFC3261 10.2.8.
  17249. case /^423$/.test(response.status_code):
  17250. {
  17251. if (response.hasHeader('min-expires')) {
  17252. // Increase our registration interval to the suggested minimum.
  17253. _this._expires = Number(response.getHeader('min-expires'));
  17254. if (_this._expires < MIN_REGISTER_EXPIRES) _this._expires = MIN_REGISTER_EXPIRES; // Attempt the registration again immediately.
  17255. _this.register();
  17256. } else {
  17257. // This response MUST contain a Min-Expires header field.
  17258. debug('423 response received for REGISTER without Min-Expires');
  17259. _this._registrationFailure(response, JsSIP_C.causes.SIP_FAILURE_CODE);
  17260. }
  17261. break;
  17262. }
  17263. default:
  17264. {
  17265. var cause = Utils.sipErrorCause(response.status_code);
  17266. _this._registrationFailure(response, cause);
  17267. }
  17268. }
  17269. }
  17270. });
  17271. this._registering = true;
  17272. request_sender.send();
  17273. }
  17274. }, {
  17275. key: "unregister",
  17276. value: function unregister() {
  17277. var _this2 = this;
  17278. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  17279. if (!this._registered) {
  17280. debug('already unregistered');
  17281. return;
  17282. }
  17283. this._registered = false; // Clear the registration timer.
  17284. if (this._registrationTimer !== null) {
  17285. clearTimeout(this._registrationTimer);
  17286. this._registrationTimer = null;
  17287. }
  17288. var extraHeaders = this._extraHeaders.slice();
  17289. if (options.all) {
  17290. extraHeaders.push("Contact: *".concat(this._extraContactParams));
  17291. } else {
  17292. extraHeaders.push("Contact: ".concat(this._contact, ";expires=0").concat(this._extraContactParams));
  17293. }
  17294. extraHeaders.push('Expires: 0');
  17295. var request = new SIPMessage.OutgoingRequest(JsSIP_C.REGISTER, this._registrar, this._ua, {
  17296. 'to_uri': this._to_uri,
  17297. 'call_id': this._call_id,
  17298. 'cseq': this._cseq += 1
  17299. }, extraHeaders);
  17300. var request_sender = new RequestSender(this._ua, request, {
  17301. onRequestTimeout: function onRequestTimeout() {
  17302. _this2._unregistered(null, JsSIP_C.causes.REQUEST_TIMEOUT);
  17303. },
  17304. onTransportError: function onTransportError() {
  17305. _this2._unregistered(null, JsSIP_C.causes.CONNECTION_ERROR);
  17306. },
  17307. // Increase the CSeq on authentication.
  17308. onAuthenticated: function onAuthenticated() {
  17309. _this2._cseq += 1;
  17310. },
  17311. onReceiveResponse: function onReceiveResponse(response) {
  17312. switch (true) {
  17313. case /^1[0-9]{2}$/.test(response.status_code):
  17314. // Ignore provisional responses.
  17315. break;
  17316. case /^2[0-9]{2}$/.test(response.status_code):
  17317. _this2._unregistered(response);
  17318. break;
  17319. default:
  17320. {
  17321. var cause = Utils.sipErrorCause(response.status_code);
  17322. _this2._unregistered(response, cause);
  17323. }
  17324. }
  17325. }
  17326. });
  17327. request_sender.send();
  17328. }
  17329. }, {
  17330. key: "close",
  17331. value: function close() {
  17332. if (this._registered) {
  17333. this.unregister();
  17334. }
  17335. }
  17336. }, {
  17337. key: "onTransportClosed",
  17338. value: function onTransportClosed() {
  17339. this._registering = false;
  17340. if (this._registrationTimer !== null) {
  17341. clearTimeout(this._registrationTimer);
  17342. this._registrationTimer = null;
  17343. }
  17344. if (this._registered) {
  17345. this._registered = false;
  17346. this._ua.unregistered({});
  17347. }
  17348. }
  17349. }, {
  17350. key: "_registrationFailure",
  17351. value: function _registrationFailure(response, cause) {
  17352. this._registering = false;
  17353. this._ua.registrationFailed({
  17354. response: response || null,
  17355. cause: cause
  17356. });
  17357. if (this._registered) {
  17358. this._registered = false;
  17359. this._ua.unregistered({
  17360. response: response || null,
  17361. cause: cause
  17362. });
  17363. }
  17364. }
  17365. }, {
  17366. key: "_unregistered",
  17367. value: function _unregistered(response, cause) {
  17368. this._registering = false;
  17369. this._registered = false;
  17370. this._ua.unregistered({
  17371. response: response || null,
  17372. cause: cause || null
  17373. });
  17374. }
  17375. }, {
  17376. key: "registered",
  17377. get: function get() {
  17378. return this._registered;
  17379. }
  17380. }]);
  17381. return Registrator;
  17382. }();
  17383. },{"./Constants":2,"./RequestSender":18,"./SIPMessage":19,"./Utils":26,"debug":30}],18:[function(require,module,exports){
  17384. "use strict";
  17385. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17386. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  17387. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17388. var JsSIP_C = require('./Constants');
  17389. var DigestAuthentication = require('./DigestAuthentication');
  17390. var Transactions = require('./Transactions');
  17391. var debug = require('debug')('JsSIP:RequestSender'); // Default event handlers.
  17392. var EventHandlers = {
  17393. onRequestTimeout: function onRequestTimeout() {},
  17394. onTransportError: function onTransportError() {},
  17395. onReceiveResponse: function onReceiveResponse() {},
  17396. onAuthenticated: function onAuthenticated() {}
  17397. };
  17398. module.exports = /*#__PURE__*/function () {
  17399. function RequestSender(ua, request, eventHandlers) {
  17400. _classCallCheck(this, RequestSender);
  17401. this._ua = ua;
  17402. this._eventHandlers = eventHandlers;
  17403. this._method = request.method;
  17404. this._request = request;
  17405. this._auth = null;
  17406. this._challenged = false;
  17407. this._staled = false; // Define the undefined handlers.
  17408. for (var handler in EventHandlers) {
  17409. if (Object.prototype.hasOwnProperty.call(EventHandlers, handler)) {
  17410. if (!this._eventHandlers[handler]) {
  17411. this._eventHandlers[handler] = EventHandlers[handler];
  17412. }
  17413. }
  17414. } // If ua is in closing process or even closed just allow sending Bye and ACK.
  17415. if (ua.status === ua.C.STATUS_USER_CLOSED && (this._method !== JsSIP_C.BYE || this._method !== JsSIP_C.ACK)) {
  17416. this._eventHandlers.onTransportError();
  17417. }
  17418. }
  17419. /**
  17420. * Create the client transaction and send the message.
  17421. */
  17422. _createClass(RequestSender, [{
  17423. key: "send",
  17424. value: function send() {
  17425. var _this = this;
  17426. var eventHandlers = {
  17427. onRequestTimeout: function onRequestTimeout() {
  17428. _this._eventHandlers.onRequestTimeout();
  17429. },
  17430. onTransportError: function onTransportError() {
  17431. _this._eventHandlers.onTransportError();
  17432. },
  17433. onReceiveResponse: function onReceiveResponse(response) {
  17434. _this._receiveResponse(response);
  17435. }
  17436. };
  17437. switch (this._method) {
  17438. case 'INVITE':
  17439. this.clientTransaction = new Transactions.InviteClientTransaction(this._ua, this._ua.transport, this._request, eventHandlers);
  17440. break;
  17441. case 'ACK':
  17442. this.clientTransaction = new Transactions.AckClientTransaction(this._ua, this._ua.transport, this._request, eventHandlers);
  17443. break;
  17444. default:
  17445. this.clientTransaction = new Transactions.NonInviteClientTransaction(this._ua, this._ua.transport, this._request, eventHandlers);
  17446. } // If authorization JWT is present, use it.
  17447. if (this._ua._configuration.authorization_jwt) {
  17448. this._request.setHeader('Authorization', this._ua._configuration.authorization_jwt);
  17449. }
  17450. this.clientTransaction.send();
  17451. }
  17452. /**
  17453. * Called from client transaction when receiving a correct response to the request.
  17454. * Authenticate request if needed or pass the response back to the applicant.
  17455. */
  17456. }, {
  17457. key: "_receiveResponse",
  17458. value: function _receiveResponse(response) {
  17459. var challenge;
  17460. var authorization_header_name;
  17461. var status_code = response.status_code;
  17462. /*
  17463. * Authentication
  17464. * Authenticate once. _challenged_ flag used to avoid infinite authentications.
  17465. */
  17466. if ((status_code === 401 || status_code === 407) && (this._ua.configuration.password !== null || this._ua.configuration.ha1 !== null)) {
  17467. // Get and parse the appropriate WWW-Authenticate or Proxy-Authenticate header.
  17468. if (response.status_code === 401) {
  17469. challenge = response.parseHeader('www-authenticate');
  17470. authorization_header_name = 'authorization';
  17471. } else {
  17472. challenge = response.parseHeader('proxy-authenticate');
  17473. authorization_header_name = 'proxy-authorization';
  17474. } // Verify it seems a valid challenge.
  17475. if (!challenge) {
  17476. debug("".concat(response.status_code, " with wrong or missing challenge, cannot authenticate"));
  17477. this._eventHandlers.onReceiveResponse(response);
  17478. return;
  17479. }
  17480. if (!this._challenged || !this._staled && challenge.stale === true) {
  17481. if (!this._auth) {
  17482. this._auth = new DigestAuthentication({
  17483. username: this._ua.configuration.authorization_user,
  17484. password: this._ua.configuration.password,
  17485. realm: this._ua.configuration.realm,
  17486. ha1: this._ua.configuration.ha1
  17487. });
  17488. } // Verify that the challenge is really valid.
  17489. if (!this._auth.authenticate(this._request, challenge)) {
  17490. this._eventHandlers.onReceiveResponse(response);
  17491. return;
  17492. }
  17493. this._challenged = true; // Update ha1 and realm in the UA.
  17494. this._ua.set('realm', this._auth.get('realm'));
  17495. this._ua.set('ha1', this._auth.get('ha1'));
  17496. if (challenge.stale) {
  17497. this._staled = true;
  17498. }
  17499. this._request = this._request.clone();
  17500. this._request.cseq += 1;
  17501. this._request.setHeader('cseq', "".concat(this._request.cseq, " ").concat(this._method));
  17502. this._request.setHeader(authorization_header_name, this._auth.toString());
  17503. this._eventHandlers.onAuthenticated(this._request);
  17504. this.send();
  17505. } else {
  17506. this._eventHandlers.onReceiveResponse(response);
  17507. }
  17508. } else {
  17509. this._eventHandlers.onReceiveResponse(response);
  17510. }
  17511. }
  17512. }]);
  17513. return RequestSender;
  17514. }();
  17515. },{"./Constants":2,"./DigestAuthentication":5,"./Transactions":22,"debug":30}],19:[function(require,module,exports){
  17516. "use strict";
  17517. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  17518. function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  17519. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  17520. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  17521. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  17522. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  17523. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  17524. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  17525. function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  17526. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  17527. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  17528. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  17529. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  17530. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  17531. var sdp_transform = require('sdp-transform');
  17532. var JsSIP_C = require('./Constants');
  17533. var Utils = require('./Utils');
  17534. var NameAddrHeader = require('./NameAddrHeader');
  17535. var Grammar = require('./Grammar');
  17536. var debug = require('debug')('JsSIP:SIPMessage');
  17537. /**
  17538. * -param {String} method request method
  17539. * -param {String} ruri request uri
  17540. * -param {UA} ua
  17541. * -param {Object} params parameters that will have priority over ua.configuration parameters:
  17542. * <br>
  17543. * - cseq, call_id, from_tag, from_uri, from_display_name, to_uri, to_tag, route_set
  17544. * -param {Object} [headers] extra headers
  17545. * -param {String} [body]
  17546. */
  17547. var OutgoingRequest = /*#__PURE__*/function () {
  17548. function OutgoingRequest(method, ruri, ua, params, extraHeaders, body) {
  17549. _classCallCheck(this, OutgoingRequest);
  17550. // Mandatory parameters check.
  17551. if (!method || !ruri || !ua) {
  17552. return null;
  17553. }
  17554. params = params || {};
  17555. this.ua = ua;
  17556. this.headers = {};
  17557. this.method = method;
  17558. this.ruri = ruri;
  17559. this.body = body;
  17560. this.extraHeaders = Utils.cloneArray(extraHeaders); // Fill the Common SIP Request Headers.
  17561. // Route.
  17562. if (params.route_set) {
  17563. this.setHeader('route', params.route_set);
  17564. } else if (ua.configuration.use_preloaded_route) {
  17565. this.setHeader('route', "<".concat(ua.transport.sip_uri, ";lr>"));
  17566. } // Via.
  17567. // Empty Via header. Will be filled by the client transaction.
  17568. this.setHeader('via', ''); // Max-Forwards.
  17569. this.setHeader('max-forwards', JsSIP_C.MAX_FORWARDS); // To
  17570. var to_uri = params.to_uri || ruri;
  17571. var to_params = params.to_tag ? {
  17572. tag: params.to_tag
  17573. } : null;
  17574. var to_display_name = typeof params.to_display_name !== 'undefined' ? params.to_display_name : null;
  17575. this.to = new NameAddrHeader(to_uri, to_display_name, to_params);
  17576. this.setHeader('to', this.to.toString()); // From.
  17577. var from_uri = params.from_uri || ua.configuration.uri;
  17578. var from_params = {
  17579. tag: params.from_tag || Utils.newTag()
  17580. };
  17581. var display_name;
  17582. if (typeof params.from_display_name !== 'undefined') {
  17583. display_name = params.from_display_name;
  17584. } else if (ua.configuration.display_name) {
  17585. display_name = ua.configuration.display_name;
  17586. } else {
  17587. display_name = null;
  17588. }
  17589. this.from = new NameAddrHeader(from_uri, display_name, from_params);
  17590. this.setHeader('from', this.from.toString()); // Call-ID.
  17591. var call_id = params.call_id || ua.configuration.jssip_id + Utils.createRandomToken(15);
  17592. this.call_id = call_id;
  17593. this.setHeader('call-id', call_id); // CSeq.
  17594. var cseq = params.cseq || Math.floor(Math.random() * 10000);
  17595. this.cseq = cseq;
  17596. this.setHeader('cseq', "".concat(cseq, " ").concat(method));
  17597. }
  17598. /**
  17599. * Replace the the given header by the given value.
  17600. * -param {String} name header name
  17601. * -param {String | Array} value header value
  17602. */
  17603. _createClass(OutgoingRequest, [{
  17604. key: "setHeader",
  17605. value: function setHeader(name, value) {
  17606. // Remove the header from extraHeaders if present.
  17607. var regexp = new RegExp("^\\s*".concat(name, "\\s*:"), 'i');
  17608. for (var idx = 0; idx < this.extraHeaders.length; idx++) {
  17609. if (regexp.test(this.extraHeaders[idx])) {
  17610. this.extraHeaders.splice(idx, 1);
  17611. }
  17612. }
  17613. this.headers[Utils.headerize(name)] = Array.isArray(value) ? value : [value];
  17614. }
  17615. /**
  17616. * Get the value of the given header name at the given position.
  17617. * -param {String} name header name
  17618. * -returns {String|undefined} Returns the specified header, null if header doesn't exist.
  17619. */
  17620. }, {
  17621. key: "getHeader",
  17622. value: function getHeader(name) {
  17623. var headers = this.headers[Utils.headerize(name)];
  17624. if (headers) {
  17625. if (headers[0]) {
  17626. return headers[0];
  17627. }
  17628. } else {
  17629. var regexp = new RegExp("^\\s*".concat(name, "\\s*:"), 'i');
  17630. var _iterator = _createForOfIteratorHelper(this.extraHeaders),
  17631. _step;
  17632. try {
  17633. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  17634. var header = _step.value;
  17635. if (regexp.test(header)) {
  17636. return header.substring(header.indexOf(':') + 1).trim();
  17637. }
  17638. }
  17639. } catch (err) {
  17640. _iterator.e(err);
  17641. } finally {
  17642. _iterator.f();
  17643. }
  17644. }
  17645. return;
  17646. }
  17647. /**
  17648. * Get the header/s of the given name.
  17649. * -param {String} name header name
  17650. * -returns {Array} Array with all the headers of the specified name.
  17651. */
  17652. }, {
  17653. key: "getHeaders",
  17654. value: function getHeaders(name) {
  17655. var headers = this.headers[Utils.headerize(name)];
  17656. var result = [];
  17657. if (headers) {
  17658. var _iterator2 = _createForOfIteratorHelper(headers),
  17659. _step2;
  17660. try {
  17661. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  17662. var header = _step2.value;
  17663. result.push(header);
  17664. }
  17665. } catch (err) {
  17666. _iterator2.e(err);
  17667. } finally {
  17668. _iterator2.f();
  17669. }
  17670. return result;
  17671. } else {
  17672. var regexp = new RegExp("^\\s*".concat(name, "\\s*:"), 'i');
  17673. var _iterator3 = _createForOfIteratorHelper(this.extraHeaders),
  17674. _step3;
  17675. try {
  17676. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  17677. var _header = _step3.value;
  17678. if (regexp.test(_header)) {
  17679. result.push(_header.substring(_header.indexOf(':') + 1).trim());
  17680. }
  17681. }
  17682. } catch (err) {
  17683. _iterator3.e(err);
  17684. } finally {
  17685. _iterator3.f();
  17686. }
  17687. return result;
  17688. }
  17689. }
  17690. /**
  17691. * Verify the existence of the given header.
  17692. * -param {String} name header name
  17693. * -returns {boolean} true if header with given name exists, false otherwise
  17694. */
  17695. }, {
  17696. key: "hasHeader",
  17697. value: function hasHeader(name) {
  17698. if (this.headers[Utils.headerize(name)]) {
  17699. return true;
  17700. } else {
  17701. var regexp = new RegExp("^\\s*".concat(name, "\\s*:"), 'i');
  17702. var _iterator4 = _createForOfIteratorHelper(this.extraHeaders),
  17703. _step4;
  17704. try {
  17705. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  17706. var header = _step4.value;
  17707. if (regexp.test(header)) {
  17708. return true;
  17709. }
  17710. }
  17711. } catch (err) {
  17712. _iterator4.e(err);
  17713. } finally {
  17714. _iterator4.f();
  17715. }
  17716. }
  17717. return false;
  17718. }
  17719. /**
  17720. * Parse the current body as a SDP and store the resulting object
  17721. * into this.sdp.
  17722. * -param {Boolean} force: Parse even if this.sdp already exists.
  17723. *
  17724. * Returns this.sdp.
  17725. */
  17726. }, {
  17727. key: "parseSDP",
  17728. value: function parseSDP(force) {
  17729. if (!force && this.sdp) {
  17730. return this.sdp;
  17731. } else {
  17732. this.sdp = sdp_transform.parse(this.body || '');
  17733. return this.sdp;
  17734. }
  17735. }
  17736. }, {
  17737. key: "toString",
  17738. value: function toString() {
  17739. var msg = "".concat(this.method, " ").concat(this.ruri, " SIP/2.0\r\n");
  17740. for (var headerName in this.headers) {
  17741. if (Object.prototype.hasOwnProperty.call(this.headers, headerName)) {
  17742. var _iterator5 = _createForOfIteratorHelper(this.headers[headerName]),
  17743. _step5;
  17744. try {
  17745. for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {
  17746. var headerValue = _step5.value;
  17747. msg += "".concat(headerName, ": ").concat(headerValue, "\r\n");
  17748. }
  17749. } catch (err) {
  17750. _iterator5.e(err);
  17751. } finally {
  17752. _iterator5.f();
  17753. }
  17754. }
  17755. }
  17756. var _iterator6 = _createForOfIteratorHelper(this.extraHeaders),
  17757. _step6;
  17758. try {
  17759. for (_iterator6.s(); !(_step6 = _iterator6.n()).done;) {
  17760. var header = _step6.value;
  17761. msg += "".concat(header.trim(), "\r\n");
  17762. } // Supported.
  17763. } catch (err) {
  17764. _iterator6.e(err);
  17765. } finally {
  17766. _iterator6.f();
  17767. }
  17768. var supported = [];
  17769. switch (this.method) {
  17770. case JsSIP_C.REGISTER:
  17771. supported.push('path', 'gruu');
  17772. break;
  17773. case JsSIP_C.INVITE:
  17774. if (this.ua.configuration.session_timers) {
  17775. supported.push('timer');
  17776. }
  17777. if (this.ua.contact.pub_gruu || this.ua.contact.temp_gruu) {
  17778. supported.push('gruu');
  17779. }
  17780. supported.push('ice', 'replaces');
  17781. break;
  17782. case JsSIP_C.UPDATE:
  17783. if (this.ua.configuration.session_timers) {
  17784. supported.push('timer');
  17785. }
  17786. supported.push('ice');
  17787. break;
  17788. }
  17789. supported.push('outbound');
  17790. var userAgent = this.ua.configuration.user_agent || JsSIP_C.USER_AGENT; // Allow.
  17791. msg += "Allow: ".concat(JsSIP_C.ALLOWED_METHODS, "\r\n");
  17792. msg += "Supported: ".concat(supported, "\r\n");
  17793. msg += "User-Agent: ".concat(userAgent, "\r\n");
  17794. if (this.body) {
  17795. var length = Utils.str_utf8_length(this.body);
  17796. msg += "Content-Length: ".concat(length, "\r\n\r\n");
  17797. msg += this.body;
  17798. } else {
  17799. msg += 'Content-Length: 0\r\n\r\n';
  17800. }
  17801. return msg;
  17802. }
  17803. }, {
  17804. key: "clone",
  17805. value: function clone() {
  17806. var request = new OutgoingRequest(this.method, this.ruri, this.ua);
  17807. Object.keys(this.headers).forEach(function (name) {
  17808. request.headers[name] = this.headers[name].slice();
  17809. }, this);
  17810. request.body = this.body;
  17811. request.extraHeaders = Utils.cloneArray(this.extraHeaders);
  17812. request.to = this.to;
  17813. request.from = this.from;
  17814. request.call_id = this.call_id;
  17815. request.cseq = this.cseq;
  17816. return request;
  17817. }
  17818. }]);
  17819. return OutgoingRequest;
  17820. }();
  17821. var InitialOutgoingInviteRequest = /*#__PURE__*/function (_OutgoingRequest) {
  17822. _inherits(InitialOutgoingInviteRequest, _OutgoingRequest);
  17823. var _super = _createSuper(InitialOutgoingInviteRequest);
  17824. function InitialOutgoingInviteRequest(ruri, ua, params, extraHeaders, body) {
  17825. var _this;
  17826. _classCallCheck(this, InitialOutgoingInviteRequest);
  17827. _this = _super.call(this, JsSIP_C.INVITE, ruri, ua, params, extraHeaders, body);
  17828. _this.transaction = null;
  17829. return _this;
  17830. }
  17831. _createClass(InitialOutgoingInviteRequest, [{
  17832. key: "cancel",
  17833. value: function cancel(reason) {
  17834. this.transaction.cancel(reason);
  17835. }
  17836. }, {
  17837. key: "clone",
  17838. value: function clone() {
  17839. var request = new InitialOutgoingInviteRequest(this.ruri, this.ua);
  17840. Object.keys(this.headers).forEach(function (name) {
  17841. request.headers[name] = this.headers[name].slice();
  17842. }, this);
  17843. request.body = this.body;
  17844. request.extraHeaders = Utils.cloneArray(this.extraHeaders);
  17845. request.to = this.to;
  17846. request.from = this.from;
  17847. request.call_id = this.call_id;
  17848. request.cseq = this.cseq;
  17849. request.transaction = this.transaction;
  17850. return request;
  17851. }
  17852. }]);
  17853. return InitialOutgoingInviteRequest;
  17854. }(OutgoingRequest);
  17855. var IncomingMessage = /*#__PURE__*/function () {
  17856. function IncomingMessage() {
  17857. _classCallCheck(this, IncomingMessage);
  17858. this.data = null;
  17859. this.headers = null;
  17860. this.method = null;
  17861. this.via = null;
  17862. this.via_branch = null;
  17863. this.call_id = null;
  17864. this.cseq = null;
  17865. this.from = null;
  17866. this.from_tag = null;
  17867. this.to = null;
  17868. this.to_tag = null;
  17869. this.body = null;
  17870. this.sdp = null;
  17871. }
  17872. /**
  17873. * Insert a header of the given name and value into the last position of the
  17874. * header array.
  17875. */
  17876. _createClass(IncomingMessage, [{
  17877. key: "addHeader",
  17878. value: function addHeader(name, value) {
  17879. var header = {
  17880. raw: value
  17881. };
  17882. name = Utils.headerize(name);
  17883. if (this.headers[name]) {
  17884. this.headers[name].push(header);
  17885. } else {
  17886. this.headers[name] = [header];
  17887. }
  17888. }
  17889. /**
  17890. * Get the value of the given header name at the given position.
  17891. */
  17892. }, {
  17893. key: "getHeader",
  17894. value: function getHeader(name) {
  17895. var header = this.headers[Utils.headerize(name)];
  17896. if (header) {
  17897. if (header[0]) {
  17898. return header[0].raw;
  17899. }
  17900. } else {
  17901. return;
  17902. }
  17903. }
  17904. /**
  17905. * Get the header/s of the given name.
  17906. */
  17907. }, {
  17908. key: "getHeaders",
  17909. value: function getHeaders(name) {
  17910. var headers = this.headers[Utils.headerize(name)];
  17911. var result = [];
  17912. if (!headers) {
  17913. return [];
  17914. }
  17915. var _iterator7 = _createForOfIteratorHelper(headers),
  17916. _step7;
  17917. try {
  17918. for (_iterator7.s(); !(_step7 = _iterator7.n()).done;) {
  17919. var header = _step7.value;
  17920. result.push(header.raw);
  17921. }
  17922. } catch (err) {
  17923. _iterator7.e(err);
  17924. } finally {
  17925. _iterator7.f();
  17926. }
  17927. return result;
  17928. }
  17929. /**
  17930. * Verify the existence of the given header.
  17931. */
  17932. }, {
  17933. key: "hasHeader",
  17934. value: function hasHeader(name) {
  17935. return this.headers[Utils.headerize(name)] ? true : false;
  17936. }
  17937. /**
  17938. * Parse the given header on the given index.
  17939. * -param {String} name header name
  17940. * -param {Number} [idx=0] header index
  17941. * -returns {Object|undefined} Parsed header object, undefined if the header
  17942. * is not present or in case of a parsing error.
  17943. */
  17944. }, {
  17945. key: "parseHeader",
  17946. value: function parseHeader(name) {
  17947. var idx = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
  17948. name = Utils.headerize(name);
  17949. if (!this.headers[name]) {
  17950. debug("header \"".concat(name, "\" not present"));
  17951. return;
  17952. } else if (idx >= this.headers[name].length) {
  17953. debug("not so many \"".concat(name, "\" headers present"));
  17954. return;
  17955. }
  17956. var header = this.headers[name][idx];
  17957. var value = header.raw;
  17958. if (header.parsed) {
  17959. return header.parsed;
  17960. } // Substitute '-' by '_' for grammar rule matching.
  17961. var parsed = Grammar.parse(value, name.replace(/-/g, '_'));
  17962. if (parsed === -1) {
  17963. this.headers[name].splice(idx, 1); // delete from headers
  17964. debug("error parsing \"".concat(name, "\" header field with value \"").concat(value, "\""));
  17965. return;
  17966. } else {
  17967. header.parsed = parsed;
  17968. return parsed;
  17969. }
  17970. }
  17971. /**
  17972. * Message Header attribute selector. Alias of parseHeader.
  17973. * -param {String} name header name
  17974. * -param {Number} [idx=0] header index
  17975. * -returns {Object|undefined} Parsed header object, undefined if the header
  17976. * is not present or in case of a parsing error.
  17977. *
  17978. * -example
  17979. * message.s('via',3).port
  17980. */
  17981. }, {
  17982. key: "s",
  17983. value: function s(name, idx) {
  17984. return this.parseHeader(name, idx);
  17985. }
  17986. /**
  17987. * Replace the value of the given header by the value.
  17988. * -param {String} name header name
  17989. * -param {String} value header value
  17990. */
  17991. }, {
  17992. key: "setHeader",
  17993. value: function setHeader(name, value) {
  17994. var header = {
  17995. raw: value
  17996. };
  17997. this.headers[Utils.headerize(name)] = [header];
  17998. }
  17999. /**
  18000. * Parse the current body as a SDP and store the resulting object
  18001. * into this.sdp.
  18002. * -param {Boolean} force: Parse even if this.sdp already exists.
  18003. *
  18004. * Returns this.sdp.
  18005. */
  18006. }, {
  18007. key: "parseSDP",
  18008. value: function parseSDP(force) {
  18009. if (!force && this.sdp) {
  18010. return this.sdp;
  18011. } else {
  18012. this.sdp = sdp_transform.parse(this.body || '');
  18013. return this.sdp;
  18014. }
  18015. }
  18016. }, {
  18017. key: "toString",
  18018. value: function toString() {
  18019. return this.data;
  18020. }
  18021. }]);
  18022. return IncomingMessage;
  18023. }();
  18024. var IncomingRequest = /*#__PURE__*/function (_IncomingMessage) {
  18025. _inherits(IncomingRequest, _IncomingMessage);
  18026. var _super2 = _createSuper(IncomingRequest);
  18027. function IncomingRequest(ua) {
  18028. var _this2;
  18029. _classCallCheck(this, IncomingRequest);
  18030. _this2 = _super2.call(this);
  18031. _this2.ua = ua;
  18032. _this2.headers = {};
  18033. _this2.ruri = null;
  18034. _this2.transport = null;
  18035. _this2.server_transaction = null;
  18036. return _this2;
  18037. }
  18038. /**
  18039. * Stateful reply.
  18040. * -param {Number} code status code
  18041. * -param {String} reason reason phrase
  18042. * -param {Object} headers extra headers
  18043. * -param {String} body body
  18044. * -param {Function} [onSuccess] onSuccess callback
  18045. * -param {Function} [onFailure] onFailure callback
  18046. */
  18047. _createClass(IncomingRequest, [{
  18048. key: "reply",
  18049. value: function reply(code, reason, extraHeaders, body, onSuccess, onFailure) {
  18050. var supported = [];
  18051. var to = this.getHeader('To');
  18052. code = code || null;
  18053. reason = reason || null; // Validate code and reason values.
  18054. if (!code || code < 100 || code > 699) {
  18055. throw new TypeError("Invalid status_code: ".concat(code));
  18056. } else if (reason && typeof reason !== 'string' && !(reason instanceof String)) {
  18057. throw new TypeError("Invalid reason_phrase: ".concat(reason));
  18058. }
  18059. reason = reason || JsSIP_C.REASON_PHRASE[code] || '';
  18060. extraHeaders = Utils.cloneArray(extraHeaders);
  18061. var response = "SIP/2.0 ".concat(code, " ").concat(reason, "\r\n");
  18062. if (this.method === JsSIP_C.INVITE && code > 100 && code <= 200) {
  18063. var headers = this.getHeaders('record-route');
  18064. var _iterator8 = _createForOfIteratorHelper(headers),
  18065. _step8;
  18066. try {
  18067. for (_iterator8.s(); !(_step8 = _iterator8.n()).done;) {
  18068. var header = _step8.value;
  18069. response += "Record-Route: ".concat(header, "\r\n");
  18070. }
  18071. } catch (err) {
  18072. _iterator8.e(err);
  18073. } finally {
  18074. _iterator8.f();
  18075. }
  18076. }
  18077. var vias = this.getHeaders('via');
  18078. var _iterator9 = _createForOfIteratorHelper(vias),
  18079. _step9;
  18080. try {
  18081. for (_iterator9.s(); !(_step9 = _iterator9.n()).done;) {
  18082. var via = _step9.value;
  18083. response += "Via: ".concat(via, "\r\n");
  18084. }
  18085. } catch (err) {
  18086. _iterator9.e(err);
  18087. } finally {
  18088. _iterator9.f();
  18089. }
  18090. if (!this.to_tag && code > 100) {
  18091. to += ";tag=".concat(Utils.newTag());
  18092. } else if (this.to_tag && !this.s('to').hasParam('tag')) {
  18093. to += ";tag=".concat(this.to_tag);
  18094. }
  18095. response += "To: ".concat(to, "\r\n");
  18096. response += "From: ".concat(this.getHeader('From'), "\r\n");
  18097. response += "Call-ID: ".concat(this.call_id, "\r\n");
  18098. response += "CSeq: ".concat(this.cseq, " ").concat(this.method, "\r\n");
  18099. var _iterator10 = _createForOfIteratorHelper(extraHeaders),
  18100. _step10;
  18101. try {
  18102. for (_iterator10.s(); !(_step10 = _iterator10.n()).done;) {
  18103. var _header2 = _step10.value;
  18104. response += "".concat(_header2.trim(), "\r\n");
  18105. } // Supported.
  18106. } catch (err) {
  18107. _iterator10.e(err);
  18108. } finally {
  18109. _iterator10.f();
  18110. }
  18111. switch (this.method) {
  18112. case JsSIP_C.INVITE:
  18113. if (this.ua.configuration.session_timers) {
  18114. supported.push('timer');
  18115. }
  18116. if (this.ua.contact.pub_gruu || this.ua.contact.temp_gruu) {
  18117. supported.push('gruu');
  18118. }
  18119. supported.push('ice', 'replaces');
  18120. break;
  18121. case JsSIP_C.UPDATE:
  18122. if (this.ua.configuration.session_timers) {
  18123. supported.push('timer');
  18124. }
  18125. if (body) {
  18126. supported.push('ice');
  18127. }
  18128. supported.push('replaces');
  18129. }
  18130. supported.push('outbound'); // Allow and Accept.
  18131. if (this.method === JsSIP_C.OPTIONS) {
  18132. response += "Allow: ".concat(JsSIP_C.ALLOWED_METHODS, "\r\n");
  18133. response += "Accept: ".concat(JsSIP_C.ACCEPTED_BODY_TYPES, "\r\n");
  18134. } else if (code === 405) {
  18135. response += "Allow: ".concat(JsSIP_C.ALLOWED_METHODS, "\r\n");
  18136. } else if (code === 415) {
  18137. response += "Accept: ".concat(JsSIP_C.ACCEPTED_BODY_TYPES, "\r\n");
  18138. }
  18139. response += "Supported: ".concat(supported, "\r\n");
  18140. if (body) {
  18141. var length = Utils.str_utf8_length(body);
  18142. response += 'Content-Type: application/sdp\r\n';
  18143. response += "Content-Length: ".concat(length, "\r\n\r\n");
  18144. response += body;
  18145. } else {
  18146. response += "Content-Length: ".concat(0, "\r\n\r\n");
  18147. }
  18148. this.server_transaction.receiveResponse(code, response, onSuccess, onFailure);
  18149. }
  18150. /**
  18151. * Stateless reply.
  18152. * -param {Number} code status code
  18153. * -param {String} reason reason phrase
  18154. */
  18155. }, {
  18156. key: "reply_sl",
  18157. value: function reply_sl() {
  18158. var code = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
  18159. var reason = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
  18160. var vias = this.getHeaders('via'); // Validate code and reason values.
  18161. if (!code || code < 100 || code > 699) {
  18162. throw new TypeError("Invalid status_code: ".concat(code));
  18163. } else if (reason && typeof reason !== 'string' && !(reason instanceof String)) {
  18164. throw new TypeError("Invalid reason_phrase: ".concat(reason));
  18165. }
  18166. reason = reason || JsSIP_C.REASON_PHRASE[code] || '';
  18167. var response = "SIP/2.0 ".concat(code, " ").concat(reason, "\r\n");
  18168. var _iterator11 = _createForOfIteratorHelper(vias),
  18169. _step11;
  18170. try {
  18171. for (_iterator11.s(); !(_step11 = _iterator11.n()).done;) {
  18172. var via = _step11.value;
  18173. response += "Via: ".concat(via, "\r\n");
  18174. }
  18175. } catch (err) {
  18176. _iterator11.e(err);
  18177. } finally {
  18178. _iterator11.f();
  18179. }
  18180. var to = this.getHeader('To');
  18181. if (!this.to_tag && code > 100) {
  18182. to += ";tag=".concat(Utils.newTag());
  18183. } else if (this.to_tag && !this.s('to').hasParam('tag')) {
  18184. to += ";tag=".concat(this.to_tag);
  18185. }
  18186. response += "To: ".concat(to, "\r\n");
  18187. response += "From: ".concat(this.getHeader('From'), "\r\n");
  18188. response += "Call-ID: ".concat(this.call_id, "\r\n");
  18189. response += "CSeq: ".concat(this.cseq, " ").concat(this.method, "\r\n");
  18190. response += "Content-Length: ".concat(0, "\r\n\r\n");
  18191. this.transport.send(response);
  18192. }
  18193. }]);
  18194. return IncomingRequest;
  18195. }(IncomingMessage);
  18196. var IncomingResponse = /*#__PURE__*/function (_IncomingMessage2) {
  18197. _inherits(IncomingResponse, _IncomingMessage2);
  18198. var _super3 = _createSuper(IncomingResponse);
  18199. function IncomingResponse() {
  18200. var _this3;
  18201. _classCallCheck(this, IncomingResponse);
  18202. _this3 = _super3.call(this);
  18203. _this3.headers = {};
  18204. _this3.status_code = null;
  18205. _this3.reason_phrase = null;
  18206. return _this3;
  18207. }
  18208. return IncomingResponse;
  18209. }(IncomingMessage);
  18210. module.exports = {
  18211. OutgoingRequest: OutgoingRequest,
  18212. InitialOutgoingInviteRequest: InitialOutgoingInviteRequest,
  18213. IncomingRequest: IncomingRequest,
  18214. IncomingResponse: IncomingResponse
  18215. };
  18216. },{"./Constants":2,"./Grammar":7,"./NameAddrHeader":10,"./Utils":26,"debug":30,"sdp-transform":35}],20:[function(require,module,exports){
  18217. "use strict";
  18218. var Utils = require('./Utils');
  18219. var Grammar = require('./Grammar');
  18220. var debugerror = require('debug')('JsSIP:ERROR:Socket');
  18221. debugerror.log = console.warn.bind(console);
  18222. /**
  18223. * Interface documentation: https://jssip.net/documentation/$last_version/api/socket/
  18224. *
  18225. * interface Socket {
  18226. * attribute String via_transport
  18227. * attribute String url
  18228. * attribute String sip_uri
  18229. *
  18230. * method connect();
  18231. * method disconnect();
  18232. * method send(data);
  18233. *
  18234. * attribute EventHandler onconnect
  18235. * attribute EventHandler ondisconnect
  18236. * attribute EventHandler ondata
  18237. * }
  18238. *
  18239. */
  18240. exports.isSocket = function (socket) {
  18241. // Ignore if an array is given.
  18242. if (Array.isArray(socket)) {
  18243. return false;
  18244. }
  18245. if (typeof socket === 'undefined') {
  18246. debugerror('undefined JsSIP.Socket instance');
  18247. return false;
  18248. } // Check Properties.
  18249. try {
  18250. if (!Utils.isString(socket.url)) {
  18251. debugerror('missing or invalid JsSIP.Socket url property');
  18252. throw new Error();
  18253. }
  18254. if (!Utils.isString(socket.via_transport)) {
  18255. debugerror('missing or invalid JsSIP.Socket via_transport property');
  18256. throw new Error();
  18257. }
  18258. if (Grammar.parse(socket.sip_uri, 'SIP_URI') === -1) {
  18259. debugerror('missing or invalid JsSIP.Socket sip_uri property');
  18260. throw new Error();
  18261. }
  18262. } catch (e) {
  18263. return false;
  18264. } // Check Methods.
  18265. try {
  18266. ['connect', 'disconnect', 'send'].forEach(function (method) {
  18267. if (!Utils.isFunction(socket[method])) {
  18268. debugerror("missing or invalid JsSIP.Socket method: ".concat(method));
  18269. throw new Error();
  18270. }
  18271. });
  18272. } catch (e) {
  18273. return false;
  18274. }
  18275. return true;
  18276. };
  18277. },{"./Grammar":7,"./Utils":26,"debug":30}],21:[function(require,module,exports){
  18278. "use strict";
  18279. var T1 = 500,
  18280. T2 = 4000,
  18281. T4 = 5000;
  18282. module.exports = {
  18283. T1: T1,
  18284. T2: T2,
  18285. T4: T4,
  18286. TIMER_B: 64 * T1,
  18287. TIMER_D: 0 * T1,
  18288. TIMER_F: 64 * T1,
  18289. TIMER_H: 64 * T1,
  18290. TIMER_I: 0 * T1,
  18291. TIMER_J: 0 * T1,
  18292. TIMER_K: 0 * T4,
  18293. TIMER_L: 64 * T1,
  18294. TIMER_M: 64 * T1,
  18295. PROVISIONAL_RESPONSE_INTERVAL: 60000 // See RFC 3261 Section 13.3.1.1
  18296. };
  18297. },{}],22:[function(require,module,exports){
  18298. "use strict";
  18299. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  18300. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18301. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  18302. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18303. function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  18304. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  18305. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  18306. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  18307. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  18308. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  18309. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  18310. var EventEmitter = require('events').EventEmitter;
  18311. var JsSIP_C = require('./Constants');
  18312. var SIPMessage = require('./SIPMessage');
  18313. var Timers = require('./Timers');
  18314. var debugnict = require('debug')('JsSIP:NonInviteClientTransaction');
  18315. var debugict = require('debug')('JsSIP:InviteClientTransaction');
  18316. var debugact = require('debug')('JsSIP:AckClientTransaction');
  18317. var debugnist = require('debug')('JsSIP:NonInviteServerTransaction');
  18318. var debugist = require('debug')('JsSIP:InviteServerTransaction');
  18319. var C = {
  18320. // Transaction states.
  18321. STATUS_TRYING: 1,
  18322. STATUS_PROCEEDING: 2,
  18323. STATUS_CALLING: 3,
  18324. STATUS_ACCEPTED: 4,
  18325. STATUS_COMPLETED: 5,
  18326. STATUS_TERMINATED: 6,
  18327. STATUS_CONFIRMED: 7,
  18328. // Transaction types.
  18329. NON_INVITE_CLIENT: 'nict',
  18330. NON_INVITE_SERVER: 'nist',
  18331. INVITE_CLIENT: 'ict',
  18332. INVITE_SERVER: 'ist'
  18333. };
  18334. var NonInviteClientTransaction = /*#__PURE__*/function (_EventEmitter) {
  18335. _inherits(NonInviteClientTransaction, _EventEmitter);
  18336. var _super = _createSuper(NonInviteClientTransaction);
  18337. function NonInviteClientTransaction(ua, transport, request, eventHandlers) {
  18338. var _this;
  18339. _classCallCheck(this, NonInviteClientTransaction);
  18340. _this = _super.call(this);
  18341. _this.type = C.NON_INVITE_CLIENT;
  18342. _this.id = "z9hG4bK".concat(Math.floor(Math.random() * 10000000));
  18343. _this.ua = ua;
  18344. _this.transport = transport;
  18345. _this.request = request;
  18346. _this.eventHandlers = eventHandlers;
  18347. var via = "SIP/2.0/".concat(transport.via_transport);
  18348. via += " ".concat(ua.configuration.via_host, ";branch=").concat(_this.id);
  18349. _this.request.setHeader('via', via);
  18350. _this.ua.newTransaction(_assertThisInitialized(_this));
  18351. return _this;
  18352. }
  18353. _createClass(NonInviteClientTransaction, [{
  18354. key: "stateChanged",
  18355. value: function stateChanged(state) {
  18356. this.state = state;
  18357. this.emit('stateChanged');
  18358. }
  18359. }, {
  18360. key: "send",
  18361. value: function send() {
  18362. var _this2 = this;
  18363. this.stateChanged(C.STATUS_TRYING);
  18364. this.F = setTimeout(function () {
  18365. _this2.timer_F();
  18366. }, Timers.TIMER_F);
  18367. if (!this.transport.send(this.request)) {
  18368. this.onTransportError();
  18369. }
  18370. }
  18371. }, {
  18372. key: "onTransportError",
  18373. value: function onTransportError() {
  18374. debugnict("transport error occurred, deleting transaction ".concat(this.id));
  18375. clearTimeout(this.F);
  18376. clearTimeout(this.K);
  18377. this.stateChanged(C.STATUS_TERMINATED);
  18378. this.ua.destroyTransaction(this);
  18379. this.eventHandlers.onTransportError();
  18380. }
  18381. }, {
  18382. key: "timer_F",
  18383. value: function timer_F() {
  18384. debugnict("Timer F expired for transaction ".concat(this.id));
  18385. this.stateChanged(C.STATUS_TERMINATED);
  18386. this.ua.destroyTransaction(this);
  18387. this.eventHandlers.onRequestTimeout();
  18388. }
  18389. }, {
  18390. key: "timer_K",
  18391. value: function timer_K() {
  18392. this.stateChanged(C.STATUS_TERMINATED);
  18393. this.ua.destroyTransaction(this);
  18394. }
  18395. }, {
  18396. key: "receiveResponse",
  18397. value: function receiveResponse(response) {
  18398. var _this3 = this;
  18399. var status_code = response.status_code;
  18400. if (status_code < 200) {
  18401. switch (this.state) {
  18402. case C.STATUS_TRYING:
  18403. case C.STATUS_PROCEEDING:
  18404. this.stateChanged(C.STATUS_PROCEEDING);
  18405. this.eventHandlers.onReceiveResponse(response);
  18406. break;
  18407. }
  18408. } else {
  18409. switch (this.state) {
  18410. case C.STATUS_TRYING:
  18411. case C.STATUS_PROCEEDING:
  18412. this.stateChanged(C.STATUS_COMPLETED);
  18413. clearTimeout(this.F);
  18414. if (status_code === 408) {
  18415. this.eventHandlers.onRequestTimeout();
  18416. } else {
  18417. this.eventHandlers.onReceiveResponse(response);
  18418. }
  18419. this.K = setTimeout(function () {
  18420. _this3.timer_K();
  18421. }, Timers.TIMER_K);
  18422. break;
  18423. case C.STATUS_COMPLETED:
  18424. break;
  18425. }
  18426. }
  18427. }
  18428. }, {
  18429. key: "C",
  18430. get: function get() {
  18431. return C;
  18432. }
  18433. }]);
  18434. return NonInviteClientTransaction;
  18435. }(EventEmitter);
  18436. var InviteClientTransaction = /*#__PURE__*/function (_EventEmitter2) {
  18437. _inherits(InviteClientTransaction, _EventEmitter2);
  18438. var _super2 = _createSuper(InviteClientTransaction);
  18439. function InviteClientTransaction(ua, transport, request, eventHandlers) {
  18440. var _this4;
  18441. _classCallCheck(this, InviteClientTransaction);
  18442. _this4 = _super2.call(this);
  18443. _this4.type = C.INVITE_CLIENT;
  18444. _this4.id = "z9hG4bK".concat(Math.floor(Math.random() * 10000000));
  18445. _this4.ua = ua;
  18446. _this4.transport = transport;
  18447. _this4.request = request;
  18448. _this4.eventHandlers = eventHandlers;
  18449. request.transaction = _assertThisInitialized(_this4);
  18450. var via = "SIP/2.0/".concat(transport.via_transport);
  18451. via += " ".concat(ua.configuration.via_host, ";branch=").concat(_this4.id);
  18452. _this4.request.setHeader('via', via);
  18453. _this4.ua.newTransaction(_assertThisInitialized(_this4));
  18454. return _this4;
  18455. }
  18456. _createClass(InviteClientTransaction, [{
  18457. key: "stateChanged",
  18458. value: function stateChanged(state) {
  18459. this.state = state;
  18460. this.emit('stateChanged');
  18461. }
  18462. }, {
  18463. key: "send",
  18464. value: function send() {
  18465. var _this5 = this;
  18466. this.stateChanged(C.STATUS_CALLING);
  18467. this.B = setTimeout(function () {
  18468. _this5.timer_B();
  18469. }, Timers.TIMER_B);
  18470. if (!this.transport.send(this.request)) {
  18471. this.onTransportError();
  18472. }
  18473. }
  18474. }, {
  18475. key: "onTransportError",
  18476. value: function onTransportError() {
  18477. clearTimeout(this.B);
  18478. clearTimeout(this.D);
  18479. clearTimeout(this.M);
  18480. if (this.state !== C.STATUS_ACCEPTED) {
  18481. debugict("transport error occurred, deleting transaction ".concat(this.id));
  18482. this.eventHandlers.onTransportError();
  18483. }
  18484. this.stateChanged(C.STATUS_TERMINATED);
  18485. this.ua.destroyTransaction(this);
  18486. } // RFC 6026 7.2.
  18487. }, {
  18488. key: "timer_M",
  18489. value: function timer_M() {
  18490. debugict("Timer M expired for transaction ".concat(this.id));
  18491. if (this.state === C.STATUS_ACCEPTED) {
  18492. clearTimeout(this.B);
  18493. this.stateChanged(C.STATUS_TERMINATED);
  18494. this.ua.destroyTransaction(this);
  18495. }
  18496. } // RFC 3261 17.1.1.
  18497. }, {
  18498. key: "timer_B",
  18499. value: function timer_B() {
  18500. debugict("Timer B expired for transaction ".concat(this.id));
  18501. if (this.state === C.STATUS_CALLING) {
  18502. this.stateChanged(C.STATUS_TERMINATED);
  18503. this.ua.destroyTransaction(this);
  18504. this.eventHandlers.onRequestTimeout();
  18505. }
  18506. }
  18507. }, {
  18508. key: "timer_D",
  18509. value: function timer_D() {
  18510. debugict("Timer D expired for transaction ".concat(this.id));
  18511. clearTimeout(this.B);
  18512. this.stateChanged(C.STATUS_TERMINATED);
  18513. this.ua.destroyTransaction(this);
  18514. }
  18515. }, {
  18516. key: "sendACK",
  18517. value: function sendACK(response) {
  18518. var _this6 = this;
  18519. var ack = new SIPMessage.OutgoingRequest(JsSIP_C.ACK, this.request.ruri, this.ua, {
  18520. 'route_set': this.request.getHeaders('route'),
  18521. 'call_id': this.request.getHeader('call-id'),
  18522. 'cseq': this.request.cseq
  18523. });
  18524. ack.setHeader('from', this.request.getHeader('from'));
  18525. ack.setHeader('via', this.request.getHeader('via'));
  18526. ack.setHeader('to', response.getHeader('to'));
  18527. this.D = setTimeout(function () {
  18528. _this6.timer_D();
  18529. }, Timers.TIMER_D);
  18530. this.transport.send(ack);
  18531. }
  18532. }, {
  18533. key: "cancel",
  18534. value: function cancel(reason) {
  18535. // Send only if a provisional response (>100) has been received.
  18536. if (this.state !== C.STATUS_PROCEEDING) {
  18537. return;
  18538. }
  18539. var cancel = new SIPMessage.OutgoingRequest(JsSIP_C.CANCEL, this.request.ruri, this.ua, {
  18540. 'route_set': this.request.getHeaders('route'),
  18541. 'call_id': this.request.getHeader('call-id'),
  18542. 'cseq': this.request.cseq
  18543. });
  18544. cancel.setHeader('from', this.request.getHeader('from'));
  18545. cancel.setHeader('via', this.request.getHeader('via'));
  18546. cancel.setHeader('to', this.request.getHeader('to'));
  18547. if (reason) {
  18548. cancel.setHeader('reason', reason);
  18549. }
  18550. this.transport.send(cancel);
  18551. }
  18552. }, {
  18553. key: "receiveResponse",
  18554. value: function receiveResponse(response) {
  18555. var _this7 = this;
  18556. var status_code = response.status_code;
  18557. if (status_code >= 100 && status_code <= 199) {
  18558. switch (this.state) {
  18559. case C.STATUS_CALLING:
  18560. this.stateChanged(C.STATUS_PROCEEDING);
  18561. this.eventHandlers.onReceiveResponse(response);
  18562. break;
  18563. case C.STATUS_PROCEEDING:
  18564. this.eventHandlers.onReceiveResponse(response);
  18565. break;
  18566. }
  18567. } else if (status_code >= 200 && status_code <= 299) {
  18568. switch (this.state) {
  18569. case C.STATUS_CALLING:
  18570. case C.STATUS_PROCEEDING:
  18571. this.stateChanged(C.STATUS_ACCEPTED);
  18572. this.M = setTimeout(function () {
  18573. _this7.timer_M();
  18574. }, Timers.TIMER_M);
  18575. this.eventHandlers.onReceiveResponse(response);
  18576. break;
  18577. case C.STATUS_ACCEPTED:
  18578. this.eventHandlers.onReceiveResponse(response);
  18579. break;
  18580. }
  18581. } else if (status_code >= 300 && status_code <= 699) {
  18582. switch (this.state) {
  18583. case C.STATUS_CALLING:
  18584. case C.STATUS_PROCEEDING:
  18585. this.stateChanged(C.STATUS_COMPLETED);
  18586. this.sendACK(response);
  18587. this.eventHandlers.onReceiveResponse(response);
  18588. break;
  18589. case C.STATUS_COMPLETED:
  18590. this.sendACK(response);
  18591. break;
  18592. }
  18593. }
  18594. }
  18595. }, {
  18596. key: "C",
  18597. get: function get() {
  18598. return C;
  18599. }
  18600. }]);
  18601. return InviteClientTransaction;
  18602. }(EventEmitter);
  18603. var AckClientTransaction = /*#__PURE__*/function (_EventEmitter3) {
  18604. _inherits(AckClientTransaction, _EventEmitter3);
  18605. var _super3 = _createSuper(AckClientTransaction);
  18606. function AckClientTransaction(ua, transport, request, eventHandlers) {
  18607. var _this8;
  18608. _classCallCheck(this, AckClientTransaction);
  18609. _this8 = _super3.call(this);
  18610. _this8.id = "z9hG4bK".concat(Math.floor(Math.random() * 10000000));
  18611. _this8.transport = transport;
  18612. _this8.request = request;
  18613. _this8.eventHandlers = eventHandlers;
  18614. var via = "SIP/2.0/".concat(transport.via_transport);
  18615. via += " ".concat(ua.configuration.via_host, ";branch=").concat(_this8.id);
  18616. _this8.request.setHeader('via', via);
  18617. return _this8;
  18618. }
  18619. _createClass(AckClientTransaction, [{
  18620. key: "send",
  18621. value: function send() {
  18622. if (!this.transport.send(this.request)) {
  18623. this.onTransportError();
  18624. }
  18625. }
  18626. }, {
  18627. key: "onTransportError",
  18628. value: function onTransportError() {
  18629. debugact("transport error occurred for transaction ".concat(this.id));
  18630. this.eventHandlers.onTransportError();
  18631. }
  18632. }, {
  18633. key: "C",
  18634. get: function get() {
  18635. return C;
  18636. }
  18637. }]);
  18638. return AckClientTransaction;
  18639. }(EventEmitter);
  18640. var NonInviteServerTransaction = /*#__PURE__*/function (_EventEmitter4) {
  18641. _inherits(NonInviteServerTransaction, _EventEmitter4);
  18642. var _super4 = _createSuper(NonInviteServerTransaction);
  18643. function NonInviteServerTransaction(ua, transport, request) {
  18644. var _this9;
  18645. _classCallCheck(this, NonInviteServerTransaction);
  18646. _this9 = _super4.call(this);
  18647. _this9.type = C.NON_INVITE_SERVER;
  18648. _this9.id = request.via_branch;
  18649. _this9.ua = ua;
  18650. _this9.transport = transport;
  18651. _this9.request = request;
  18652. _this9.last_response = '';
  18653. request.server_transaction = _assertThisInitialized(_this9);
  18654. _this9.state = C.STATUS_TRYING;
  18655. ua.newTransaction(_assertThisInitialized(_this9));
  18656. return _this9;
  18657. }
  18658. _createClass(NonInviteServerTransaction, [{
  18659. key: "stateChanged",
  18660. value: function stateChanged(state) {
  18661. this.state = state;
  18662. this.emit('stateChanged');
  18663. }
  18664. }, {
  18665. key: "timer_J",
  18666. value: function timer_J() {
  18667. debugnist("Timer J expired for transaction ".concat(this.id));
  18668. this.stateChanged(C.STATUS_TERMINATED);
  18669. this.ua.destroyTransaction(this);
  18670. }
  18671. }, {
  18672. key: "onTransportError",
  18673. value: function onTransportError() {
  18674. if (!this.transportError) {
  18675. this.transportError = true;
  18676. debugnist("transport error occurred, deleting transaction ".concat(this.id));
  18677. clearTimeout(this.J);
  18678. this.stateChanged(C.STATUS_TERMINATED);
  18679. this.ua.destroyTransaction(this);
  18680. }
  18681. }
  18682. }, {
  18683. key: "receiveResponse",
  18684. value: function receiveResponse(status_code, response, onSuccess, onFailure) {
  18685. var _this10 = this;
  18686. if (status_code === 100) {
  18687. /* RFC 4320 4.1
  18688. * 'A SIP element MUST NOT
  18689. * send any provisional response with a
  18690. * Status-Code other than 100 to a non-INVITE request.'
  18691. */
  18692. switch (this.state) {
  18693. case C.STATUS_TRYING:
  18694. this.stateChanged(C.STATUS_PROCEEDING);
  18695. if (!this.transport.send(response)) {
  18696. this.onTransportError();
  18697. }
  18698. break;
  18699. case C.STATUS_PROCEEDING:
  18700. this.last_response = response;
  18701. if (!this.transport.send(response)) {
  18702. this.onTransportError();
  18703. if (onFailure) {
  18704. onFailure();
  18705. }
  18706. } else if (onSuccess) {
  18707. onSuccess();
  18708. }
  18709. break;
  18710. }
  18711. } else if (status_code >= 200 && status_code <= 699) {
  18712. switch (this.state) {
  18713. case C.STATUS_TRYING:
  18714. case C.STATUS_PROCEEDING:
  18715. this.stateChanged(C.STATUS_COMPLETED);
  18716. this.last_response = response;
  18717. this.J = setTimeout(function () {
  18718. _this10.timer_J();
  18719. }, Timers.TIMER_J);
  18720. if (!this.transport.send(response)) {
  18721. this.onTransportError();
  18722. if (onFailure) {
  18723. onFailure();
  18724. }
  18725. } else if (onSuccess) {
  18726. onSuccess();
  18727. }
  18728. break;
  18729. case C.STATUS_COMPLETED:
  18730. break;
  18731. }
  18732. }
  18733. }
  18734. }, {
  18735. key: "C",
  18736. get: function get() {
  18737. return C;
  18738. }
  18739. }]);
  18740. return NonInviteServerTransaction;
  18741. }(EventEmitter);
  18742. var InviteServerTransaction = /*#__PURE__*/function (_EventEmitter5) {
  18743. _inherits(InviteServerTransaction, _EventEmitter5);
  18744. var _super5 = _createSuper(InviteServerTransaction);
  18745. function InviteServerTransaction(ua, transport, request) {
  18746. var _this11;
  18747. _classCallCheck(this, InviteServerTransaction);
  18748. _this11 = _super5.call(this);
  18749. _this11.type = C.INVITE_SERVER;
  18750. _this11.id = request.via_branch;
  18751. _this11.ua = ua;
  18752. _this11.transport = transport;
  18753. _this11.request = request;
  18754. _this11.last_response = '';
  18755. request.server_transaction = _assertThisInitialized(_this11);
  18756. _this11.state = C.STATUS_PROCEEDING;
  18757. ua.newTransaction(_assertThisInitialized(_this11));
  18758. _this11.resendProvisionalTimer = null;
  18759. request.reply(100);
  18760. return _this11;
  18761. }
  18762. _createClass(InviteServerTransaction, [{
  18763. key: "stateChanged",
  18764. value: function stateChanged(state) {
  18765. this.state = state;
  18766. this.emit('stateChanged');
  18767. }
  18768. }, {
  18769. key: "timer_H",
  18770. value: function timer_H() {
  18771. debugist("Timer H expired for transaction ".concat(this.id));
  18772. if (this.state === C.STATUS_COMPLETED) {
  18773. debugist('ACK not received, dialog will be terminated');
  18774. }
  18775. this.stateChanged(C.STATUS_TERMINATED);
  18776. this.ua.destroyTransaction(this);
  18777. }
  18778. }, {
  18779. key: "timer_I",
  18780. value: function timer_I() {
  18781. this.stateChanged(C.STATUS_TERMINATED);
  18782. this.ua.destroyTransaction(this);
  18783. } // RFC 6026 7.1.
  18784. }, {
  18785. key: "timer_L",
  18786. value: function timer_L() {
  18787. debugist("Timer L expired for transaction ".concat(this.id));
  18788. if (this.state === C.STATUS_ACCEPTED) {
  18789. this.stateChanged(C.STATUS_TERMINATED);
  18790. this.ua.destroyTransaction(this);
  18791. }
  18792. }
  18793. }, {
  18794. key: "onTransportError",
  18795. value: function onTransportError() {
  18796. if (!this.transportError) {
  18797. this.transportError = true;
  18798. debugist("transport error occurred, deleting transaction ".concat(this.id));
  18799. if (this.resendProvisionalTimer !== null) {
  18800. clearInterval(this.resendProvisionalTimer);
  18801. this.resendProvisionalTimer = null;
  18802. }
  18803. clearTimeout(this.L);
  18804. clearTimeout(this.H);
  18805. clearTimeout(this.I);
  18806. this.stateChanged(C.STATUS_TERMINATED);
  18807. this.ua.destroyTransaction(this);
  18808. }
  18809. }
  18810. }, {
  18811. key: "resend_provisional",
  18812. value: function resend_provisional() {
  18813. if (!this.transport.send(this.last_response)) {
  18814. this.onTransportError();
  18815. }
  18816. } // INVITE Server Transaction RFC 3261 17.2.1.
  18817. }, {
  18818. key: "receiveResponse",
  18819. value: function receiveResponse(status_code, response, onSuccess, onFailure) {
  18820. var _this12 = this;
  18821. if (status_code >= 100 && status_code <= 199) {
  18822. switch (this.state) {
  18823. case C.STATUS_PROCEEDING:
  18824. if (!this.transport.send(response)) {
  18825. this.onTransportError();
  18826. }
  18827. this.last_response = response;
  18828. break;
  18829. }
  18830. }
  18831. if (status_code > 100 && status_code <= 199 && this.state === C.STATUS_PROCEEDING) {
  18832. // Trigger the resendProvisionalTimer only for the first non 100 provisional response.
  18833. if (this.resendProvisionalTimer === null) {
  18834. this.resendProvisionalTimer = setInterval(function () {
  18835. _this12.resend_provisional();
  18836. }, Timers.PROVISIONAL_RESPONSE_INTERVAL);
  18837. }
  18838. } else if (status_code >= 200 && status_code <= 299) {
  18839. switch (this.state) {
  18840. case C.STATUS_PROCEEDING:
  18841. this.stateChanged(C.STATUS_ACCEPTED);
  18842. this.last_response = response;
  18843. this.L = setTimeout(function () {
  18844. _this12.timer_L();
  18845. }, Timers.TIMER_L);
  18846. if (this.resendProvisionalTimer !== null) {
  18847. clearInterval(this.resendProvisionalTimer);
  18848. this.resendProvisionalTimer = null;
  18849. }
  18850. /* falls through */
  18851. case C.STATUS_ACCEPTED:
  18852. // Note that this point will be reached for proceeding this.state also.
  18853. if (!this.transport.send(response)) {
  18854. this.onTransportError();
  18855. if (onFailure) {
  18856. onFailure();
  18857. }
  18858. } else if (onSuccess) {
  18859. onSuccess();
  18860. }
  18861. break;
  18862. }
  18863. } else if (status_code >= 300 && status_code <= 699) {
  18864. switch (this.state) {
  18865. case C.STATUS_PROCEEDING:
  18866. if (this.resendProvisionalTimer !== null) {
  18867. clearInterval(this.resendProvisionalTimer);
  18868. this.resendProvisionalTimer = null;
  18869. }
  18870. if (!this.transport.send(response)) {
  18871. this.onTransportError();
  18872. if (onFailure) {
  18873. onFailure();
  18874. }
  18875. } else {
  18876. this.stateChanged(C.STATUS_COMPLETED);
  18877. this.H = setTimeout(function () {
  18878. _this12.timer_H();
  18879. }, Timers.TIMER_H);
  18880. if (onSuccess) {
  18881. onSuccess();
  18882. }
  18883. }
  18884. break;
  18885. }
  18886. }
  18887. }
  18888. }, {
  18889. key: "C",
  18890. get: function get() {
  18891. return C;
  18892. }
  18893. }]);
  18894. return InviteServerTransaction;
  18895. }(EventEmitter);
  18896. /**
  18897. * INVITE:
  18898. * _true_ if retransmission
  18899. * _false_ new request
  18900. *
  18901. * ACK:
  18902. * _true_ ACK to non2xx response
  18903. * _false_ ACK must be passed to TU (accepted state)
  18904. * ACK to 2xx response
  18905. *
  18906. * CANCEL:
  18907. * _true_ no matching invite transaction
  18908. * _false_ matching invite transaction and no final response sent
  18909. *
  18910. * OTHER:
  18911. * _true_ retransmission
  18912. * _false_ new request
  18913. */
  18914. function checkTransaction(_ref, request) {
  18915. var _transactions = _ref._transactions;
  18916. var tr;
  18917. switch (request.method) {
  18918. case JsSIP_C.INVITE:
  18919. tr = _transactions.ist[request.via_branch];
  18920. if (tr) {
  18921. switch (tr.state) {
  18922. case C.STATUS_PROCEEDING:
  18923. tr.transport.send(tr.last_response);
  18924. break;
  18925. // RFC 6026 7.1 Invite retransmission.
  18926. // Received while in C.STATUS_ACCEPTED state. Absorb it.
  18927. case C.STATUS_ACCEPTED:
  18928. break;
  18929. }
  18930. return true;
  18931. }
  18932. break;
  18933. case JsSIP_C.ACK:
  18934. tr = _transactions.ist[request.via_branch]; // RFC 6026 7.1.
  18935. if (tr) {
  18936. if (tr.state === C.STATUS_ACCEPTED) {
  18937. return false;
  18938. } else if (tr.state === C.STATUS_COMPLETED) {
  18939. tr.state = C.STATUS_CONFIRMED;
  18940. tr.I = setTimeout(function () {
  18941. tr.timer_I();
  18942. }, Timers.TIMER_I);
  18943. return true;
  18944. }
  18945. } // ACK to 2XX Response.
  18946. else {
  18947. return false;
  18948. }
  18949. break;
  18950. case JsSIP_C.CANCEL:
  18951. tr = _transactions.ist[request.via_branch];
  18952. if (tr) {
  18953. request.reply_sl(200);
  18954. if (tr.state === C.STATUS_PROCEEDING) {
  18955. return false;
  18956. } else {
  18957. return true;
  18958. }
  18959. } else {
  18960. request.reply_sl(481);
  18961. return true;
  18962. }
  18963. default:
  18964. // Non-INVITE Server Transaction RFC 3261 17.2.2.
  18965. tr = _transactions.nist[request.via_branch];
  18966. if (tr) {
  18967. switch (tr.state) {
  18968. case C.STATUS_TRYING:
  18969. break;
  18970. case C.STATUS_PROCEEDING:
  18971. case C.STATUS_COMPLETED:
  18972. tr.transport.send(tr.last_response);
  18973. break;
  18974. }
  18975. return true;
  18976. }
  18977. break;
  18978. }
  18979. }
  18980. module.exports = {
  18981. C: C,
  18982. NonInviteClientTransaction: NonInviteClientTransaction,
  18983. InviteClientTransaction: InviteClientTransaction,
  18984. AckClientTransaction: AckClientTransaction,
  18985. NonInviteServerTransaction: NonInviteServerTransaction,
  18986. InviteServerTransaction: InviteServerTransaction,
  18987. checkTransaction: checkTransaction
  18988. };
  18989. },{"./Constants":2,"./SIPMessage":19,"./Timers":21,"debug":30,"events":29}],23:[function(require,module,exports){
  18990. "use strict";
  18991. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  18992. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  18993. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  18994. var Socket = require('./Socket');
  18995. var debug = require('debug')('JsSIP:Transport');
  18996. var debugerror = require('debug')('JsSIP:ERROR:Transport');
  18997. var JsSIP_C = require('./Constants');
  18998. debugerror.log = console.warn.bind(console);
  18999. /**
  19000. * Constants
  19001. */
  19002. var C = {
  19003. // Transport status.
  19004. STATUS_CONNECTED: 0,
  19005. STATUS_CONNECTING: 1,
  19006. STATUS_DISCONNECTED: 2,
  19007. // Socket status.
  19008. SOCKET_STATUS_READY: 0,
  19009. SOCKET_STATUS_ERROR: 1,
  19010. // Recovery options.
  19011. recovery_options: {
  19012. // minimum interval in seconds between recover attempts.
  19013. min_interval: JsSIP_C.CONNECTION_RECOVERY_MIN_INTERVAL,
  19014. // maximum interval in seconds between recover attempts.
  19015. max_interval: JsSIP_C.CONNECTION_RECOVERY_MAX_INTERVAL
  19016. }
  19017. };
  19018. /*
  19019. * Manages one or multiple JsSIP.Socket instances.
  19020. * Is reponsible for transport recovery logic among all socket instances.
  19021. *
  19022. * @socket JsSIP::Socket instance
  19023. */
  19024. module.exports = /*#__PURE__*/function () {
  19025. function Transport(sockets) {
  19026. var recovery_options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : C.recovery_options;
  19027. _classCallCheck(this, Transport);
  19028. debug('new()');
  19029. this.status = C.STATUS_DISCONNECTED; // Current socket.
  19030. this.socket = null; // Socket collection.
  19031. this.sockets = [];
  19032. this.recovery_options = recovery_options;
  19033. this.recover_attempts = 0;
  19034. this.recovery_timer = null;
  19035. this.close_requested = false;
  19036. if (typeof sockets === 'undefined') {
  19037. throw new TypeError('Invalid argument.' + ' undefined \'sockets\' argument');
  19038. }
  19039. if (!(sockets instanceof Array)) {
  19040. sockets = [sockets];
  19041. }
  19042. sockets.forEach(function (socket) {
  19043. if (!Socket.isSocket(socket.socket)) {
  19044. throw new TypeError('Invalid argument.' + ' invalid \'JsSIP.Socket\' instance');
  19045. }
  19046. if (socket.weight && !Number(socket.weight)) {
  19047. throw new TypeError('Invalid argument.' + ' \'weight\' attribute is not a number');
  19048. }
  19049. this.sockets.push({
  19050. socket: socket.socket,
  19051. weight: socket.weight || 0,
  19052. status: C.SOCKET_STATUS_READY
  19053. });
  19054. }, this); // Get the socket with higher weight.
  19055. this._getSocket();
  19056. }
  19057. /**
  19058. * Instance Methods
  19059. */
  19060. _createClass(Transport, [{
  19061. key: "connect",
  19062. value: function connect() {
  19063. debug('connect()');
  19064. if (this.isConnected()) {
  19065. debug('Transport is already connected');
  19066. return;
  19067. } else if (this.isConnecting()) {
  19068. debug('Transport is connecting');
  19069. return;
  19070. }
  19071. this.close_requested = false;
  19072. this.status = C.STATUS_CONNECTING;
  19073. this.onconnecting({
  19074. socket: this.socket,
  19075. attempts: this.recover_attempts
  19076. });
  19077. if (!this.close_requested) {
  19078. // Bind socket event callbacks.
  19079. this.socket.onconnect = this._onConnect.bind(this);
  19080. this.socket.ondisconnect = this._onDisconnect.bind(this);
  19081. this.socket.ondata = this._onData.bind(this);
  19082. this.socket.connect();
  19083. }
  19084. return;
  19085. }
  19086. }, {
  19087. key: "disconnect",
  19088. value: function disconnect() {
  19089. debug('close()');
  19090. this.close_requested = true;
  19091. this.recover_attempts = 0;
  19092. this.status = C.STATUS_DISCONNECTED; // Clear recovery_timer.
  19093. if (this.recovery_timer !== null) {
  19094. clearTimeout(this.recovery_timer);
  19095. this.recovery_timer = null;
  19096. } // Unbind socket event callbacks.
  19097. this.socket.onconnect = function () {};
  19098. this.socket.ondisconnect = function () {};
  19099. this.socket.ondata = function () {};
  19100. this.socket.disconnect();
  19101. this.ondisconnect({
  19102. socket: this.socket,
  19103. error: false
  19104. });
  19105. }
  19106. }, {
  19107. key: "send",
  19108. value: function send(data) {
  19109. debug('send()');
  19110. if (!this.isConnected()) {
  19111. debugerror('unable to send message, transport is not connected');
  19112. return false;
  19113. }
  19114. var message = data.toString();
  19115. debug("sending message:\n\n".concat(message, "\n"));
  19116. return this.socket.send(message);
  19117. }
  19118. }, {
  19119. key: "isConnected",
  19120. value: function isConnected() {
  19121. return this.status === C.STATUS_CONNECTED;
  19122. }
  19123. }, {
  19124. key: "isConnecting",
  19125. value: function isConnecting() {
  19126. return this.status === C.STATUS_CONNECTING;
  19127. }
  19128. /**
  19129. * Private API.
  19130. */
  19131. }, {
  19132. key: "_reconnect",
  19133. value: function _reconnect() {
  19134. var _this = this;
  19135. this.recover_attempts += 1;
  19136. var k = Math.floor(Math.random() * Math.pow(2, this.recover_attempts) + 1);
  19137. if (k < this.recovery_options.min_interval) {
  19138. k = this.recovery_options.min_interval;
  19139. } else if (k > this.recovery_options.max_interval) {
  19140. k = this.recovery_options.max_interval;
  19141. }
  19142. debug("reconnection attempt: ".concat(this.recover_attempts, ". next connection attempt in ").concat(k, " seconds"));
  19143. this.recovery_timer = setTimeout(function () {
  19144. if (!_this.close_requested && !(_this.isConnected() || _this.isConnecting())) {
  19145. // Get the next available socket with higher weight.
  19146. _this._getSocket(); // Connect the socket.
  19147. _this.connect();
  19148. }
  19149. }, k * 1000);
  19150. }
  19151. /**
  19152. * get the next available socket with higher weight
  19153. */
  19154. }, {
  19155. key: "_getSocket",
  19156. value: function _getSocket() {
  19157. var candidates = [];
  19158. this.sockets.forEach(function (socket) {
  19159. if (socket.status === C.SOCKET_STATUS_ERROR) {
  19160. return; // continue the array iteration
  19161. } else if (candidates.length === 0) {
  19162. candidates.push(socket);
  19163. } else if (socket.weight > candidates[0].weight) {
  19164. candidates = [socket];
  19165. } else if (socket.weight === candidates[0].weight) {
  19166. candidates.push(socket);
  19167. }
  19168. });
  19169. if (candidates.length === 0) {
  19170. // All sockets have failed. reset sockets status.
  19171. this.sockets.forEach(function (socket) {
  19172. socket.status = C.SOCKET_STATUS_READY;
  19173. }); // Get next available socket.
  19174. this._getSocket();
  19175. return;
  19176. }
  19177. var idx = Math.floor(Math.random() * candidates.length);
  19178. this.socket = candidates[idx].socket;
  19179. }
  19180. /**
  19181. * Socket Event Handlers
  19182. */
  19183. }, {
  19184. key: "_onConnect",
  19185. value: function _onConnect() {
  19186. this.recover_attempts = 0;
  19187. this.status = C.STATUS_CONNECTED; // Clear recovery_timer.
  19188. if (this.recovery_timer !== null) {
  19189. clearTimeout(this.recovery_timer);
  19190. this.recovery_timer = null;
  19191. }
  19192. this.onconnect({
  19193. socket: this
  19194. });
  19195. }
  19196. }, {
  19197. key: "_onDisconnect",
  19198. value: function _onDisconnect(error, code, reason) {
  19199. this.status = C.STATUS_DISCONNECTED;
  19200. this.ondisconnect({
  19201. socket: this.socket,
  19202. error: error,
  19203. code: code,
  19204. reason: reason
  19205. });
  19206. if (this.close_requested) {
  19207. return;
  19208. } // Update socket status.
  19209. else {
  19210. this.sockets.forEach(function (socket) {
  19211. if (this.socket === socket.socket) {
  19212. socket.status = C.SOCKET_STATUS_ERROR;
  19213. }
  19214. }, this);
  19215. }
  19216. this._reconnect(error);
  19217. }
  19218. }, {
  19219. key: "_onData",
  19220. value: function _onData(data) {
  19221. // CRLF Keep Alive response from server. Ignore it.
  19222. if (data === '\r\n') {
  19223. debug('received message with CRLF Keep Alive response');
  19224. return;
  19225. } // Binary message.
  19226. else if (typeof data !== 'string') {
  19227. try {
  19228. data = String.fromCharCode.apply(null, new Uint8Array(data));
  19229. } catch (evt) {
  19230. debug('received binary message failed to be converted into string,' + ' message discarded');
  19231. return;
  19232. }
  19233. debug("received binary message:\n\n".concat(data, "\n"));
  19234. } // Text message.
  19235. else {
  19236. debug("received text message:\n\n".concat(data, "\n"));
  19237. }
  19238. this.ondata({
  19239. transport: this,
  19240. message: data
  19241. });
  19242. }
  19243. }, {
  19244. key: "via_transport",
  19245. get: function get() {
  19246. return this.socket.via_transport;
  19247. }
  19248. }, {
  19249. key: "url",
  19250. get: function get() {
  19251. return this.socket.url;
  19252. }
  19253. }, {
  19254. key: "sip_uri",
  19255. get: function get() {
  19256. return this.socket.sip_uri;
  19257. }
  19258. }]);
  19259. return Transport;
  19260. }();
  19261. },{"./Constants":2,"./Socket":20,"debug":30}],24:[function(require,module,exports){
  19262. "use strict";
  19263. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  19264. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  19265. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  19266. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  19267. function _createSuper(Derived) { return function () { var Super = _getPrototypeOf(Derived), result; if (_isNativeReflectConstruct()) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
  19268. function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
  19269. function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
  19270. function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
  19271. function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
  19272. function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
  19273. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  19274. var EventEmitter = require('events').EventEmitter;
  19275. var JsSIP_C = require('./Constants');
  19276. var Registrator = require('./Registrator');
  19277. var RTCSession = require('./RTCSession');
  19278. var Message = require('./Message');
  19279. var Transactions = require('./Transactions');
  19280. var Transport = require('./Transport');
  19281. var Utils = require('./Utils');
  19282. var Exceptions = require('./Exceptions');
  19283. var URI = require('./URI');
  19284. var Parser = require('./Parser');
  19285. var SIPMessage = require('./SIPMessage');
  19286. var sanityCheck = require('./sanityCheck');
  19287. var config = require('./Config');
  19288. var debug = require('debug')('JsSIP:UA');
  19289. var debugerror = require('debug')('JsSIP:ERROR:UA');
  19290. debugerror.log = console.warn.bind(console);
  19291. var C = {
  19292. // UA status codes.
  19293. STATUS_INIT: 0,
  19294. STATUS_READY: 1,
  19295. STATUS_USER_CLOSED: 2,
  19296. STATUS_NOT_READY: 3,
  19297. // UA error codes.
  19298. CONFIGURATION_ERROR: 1,
  19299. NETWORK_ERROR: 2
  19300. };
  19301. /**
  19302. * The User-Agent class.
  19303. * @class JsSIP.UA
  19304. * @param {Object} configuration Configuration parameters.
  19305. * @throws {JsSIP.Exceptions.ConfigurationError} If a configuration parameter is invalid.
  19306. * @throws {TypeError} If no configuration is given.
  19307. */
  19308. module.exports = /*#__PURE__*/function (_EventEmitter) {
  19309. _inherits(UA, _EventEmitter);
  19310. var _super = _createSuper(UA);
  19311. _createClass(UA, null, [{
  19312. key: "C",
  19313. // Expose C object.
  19314. get: function get() {
  19315. return C;
  19316. }
  19317. }]);
  19318. function UA(configuration) {
  19319. var _this;
  19320. _classCallCheck(this, UA);
  19321. debug('new() [configuration:%o]', configuration);
  19322. _this = _super.call(this);
  19323. _this._cache = {
  19324. credentials: {}
  19325. };
  19326. _this._configuration = Object.assign({}, config.settings);
  19327. _this._dynConfiguration = {};
  19328. _this._dialogs = {}; // User actions outside any session/dialog (MESSAGE).
  19329. _this._applicants = {};
  19330. _this._sessions = {};
  19331. _this._transport = null;
  19332. _this._contact = null;
  19333. _this._status = C.STATUS_INIT;
  19334. _this._error = null;
  19335. _this._transactions = {
  19336. nist: {},
  19337. nict: {},
  19338. ist: {},
  19339. ict: {}
  19340. }; // Custom UA empty object for high level use.
  19341. _this._data = {};
  19342. _this._closeTimer = null; // Check configuration argument.
  19343. if (configuration === undefined) {
  19344. throw new TypeError('Not enough arguments');
  19345. } // Load configuration.
  19346. try {
  19347. _this._loadConfig(configuration);
  19348. } catch (e) {
  19349. _this._status = C.STATUS_NOT_READY;
  19350. _this._error = C.CONFIGURATION_ERROR;
  19351. throw e;
  19352. } // Initialize registrator.
  19353. _this._registrator = new Registrator(_assertThisInitialized(_this));
  19354. return _this;
  19355. }
  19356. _createClass(UA, [{
  19357. key: "start",
  19358. // =================
  19359. // High Level API
  19360. // =================
  19361. /**
  19362. * Connect to the server if status = STATUS_INIT.
  19363. * Resume UA after being closed.
  19364. */
  19365. value: function start() {
  19366. debug('start()');
  19367. if (this._status === C.STATUS_INIT) {
  19368. this._transport.connect();
  19369. } else if (this._status === C.STATUS_USER_CLOSED) {
  19370. debug('restarting UA'); // Disconnect.
  19371. if (this._closeTimer !== null) {
  19372. clearTimeout(this._closeTimer);
  19373. this._closeTimer = null;
  19374. this._transport.disconnect();
  19375. } // Reconnect.
  19376. this._status = C.STATUS_INIT;
  19377. this._transport.connect();
  19378. } else if (this._status === C.STATUS_READY) {
  19379. debug('UA is in READY status, not restarted');
  19380. } else {
  19381. debug('ERROR: connection is down, Auto-Recovery system is trying to reconnect');
  19382. } // Set dynamic configuration.
  19383. this._dynConfiguration.register = this._configuration.register;
  19384. }
  19385. /**
  19386. * Register.
  19387. */
  19388. }, {
  19389. key: "register",
  19390. value: function register() {
  19391. debug('register()');
  19392. this._dynConfiguration.register = true;
  19393. this._registrator.register();
  19394. }
  19395. /**
  19396. * Unregister.
  19397. */
  19398. }, {
  19399. key: "unregister",
  19400. value: function unregister(options) {
  19401. debug('unregister()');
  19402. this._dynConfiguration.register = false;
  19403. this._registrator.unregister(options);
  19404. }
  19405. /**
  19406. * Get the Registrator instance.
  19407. */
  19408. }, {
  19409. key: "registrator",
  19410. value: function registrator() {
  19411. return this._registrator;
  19412. }
  19413. /**
  19414. * Registration state.
  19415. */
  19416. }, {
  19417. key: "isRegistered",
  19418. value: function isRegistered() {
  19419. return this._registrator.registered;
  19420. }
  19421. /**
  19422. * Connection state.
  19423. */
  19424. }, {
  19425. key: "isConnected",
  19426. value: function isConnected() {
  19427. return this._transport.isConnected();
  19428. }
  19429. /**
  19430. * Make an outgoing call.
  19431. *
  19432. * -param {String} target
  19433. * -param {Object} [options]
  19434. *
  19435. * -throws {TypeError}
  19436. *
  19437. */
  19438. }, {
  19439. key: "call",
  19440. value: function call(target, options) {
  19441. debug('call()');
  19442. var session = new RTCSession(this);
  19443. session.connect(target, options);
  19444. return session;
  19445. }
  19446. /**
  19447. * Send a message.
  19448. *
  19449. * -param {String} target
  19450. * -param {String} body
  19451. * -param {Object} [options]
  19452. *
  19453. * -throws {TypeError}
  19454. *
  19455. */
  19456. }, {
  19457. key: "sendMessage",
  19458. value: function sendMessage(target, body, options) {
  19459. debug('sendMessage()');
  19460. var message = new Message(this);
  19461. message.send(target, body, options);
  19462. return message;
  19463. }
  19464. /**
  19465. * Terminate ongoing sessions.
  19466. */
  19467. }, {
  19468. key: "terminateSessions",
  19469. value: function terminateSessions(options) {
  19470. debug('terminateSessions()');
  19471. for (var idx in this._sessions) {
  19472. if (!this._sessions[idx].isEnded()) {
  19473. this._sessions[idx].terminate(options);
  19474. }
  19475. }
  19476. }
  19477. /**
  19478. * Gracefully close.
  19479. *
  19480. */
  19481. }, {
  19482. key: "stop",
  19483. value: function stop() {
  19484. var _this2 = this;
  19485. debug('stop()'); // Remove dynamic settings.
  19486. this._dynConfiguration = {};
  19487. if (this._status === C.STATUS_USER_CLOSED) {
  19488. debug('UA already closed');
  19489. return;
  19490. } // Close registrator.
  19491. this._registrator.close(); // If there are session wait a bit so CANCEL/BYE can be sent and their responses received.
  19492. var num_sessions = Object.keys(this._sessions).length; // Run _terminate_ on every Session.
  19493. for (var session in this._sessions) {
  19494. if (Object.prototype.hasOwnProperty.call(this._sessions, session)) {
  19495. debug("closing session ".concat(session));
  19496. try {
  19497. this._sessions[session].terminate();
  19498. } catch (error) {}
  19499. }
  19500. } // Run _close_ on every applicant.
  19501. for (var applicant in this._applicants) {
  19502. if (Object.prototype.hasOwnProperty.call(this._applicants, applicant)) try {
  19503. this._applicants[applicant].close();
  19504. } catch (error) {}
  19505. }
  19506. this._status = C.STATUS_USER_CLOSED;
  19507. var num_transactions = Object.keys(this._transactions.nict).length + Object.keys(this._transactions.nist).length + Object.keys(this._transactions.ict).length + Object.keys(this._transactions.ist).length;
  19508. if (num_transactions === 0 && num_sessions === 0) {
  19509. this._transport.disconnect();
  19510. } else {
  19511. this._closeTimer = setTimeout(function () {
  19512. _this2._closeTimer = null;
  19513. _this2._transport.disconnect();
  19514. }, 2000);
  19515. }
  19516. }
  19517. /**
  19518. * Normalice a string into a valid SIP request URI
  19519. * -param {String} target
  19520. * -returns {JsSIP.URI|undefined}
  19521. */
  19522. }, {
  19523. key: "normalizeTarget",
  19524. value: function normalizeTarget(target) {
  19525. return Utils.normalizeTarget(target, this._configuration.hostport_params);
  19526. }
  19527. /**
  19528. * Allow retrieving configuration and autogenerated fields in runtime.
  19529. */
  19530. }, {
  19531. key: "get",
  19532. value: function get(parameter) {
  19533. switch (parameter) {
  19534. case 'realm':
  19535. return this._configuration.realm;
  19536. case 'ha1':
  19537. return this._configuration.ha1;
  19538. default:
  19539. debugerror('get() | cannot get "%s" parameter in runtime', parameter);
  19540. return undefined;
  19541. }
  19542. }
  19543. /**
  19544. * Allow configuration changes in runtime.
  19545. * Returns true if the parameter could be set.
  19546. */
  19547. }, {
  19548. key: "set",
  19549. value: function set(parameter, value) {
  19550. switch (parameter) {
  19551. case 'password':
  19552. {
  19553. this._configuration.password = String(value);
  19554. break;
  19555. }
  19556. case 'realm':
  19557. {
  19558. this._configuration.realm = String(value);
  19559. break;
  19560. }
  19561. case 'ha1':
  19562. {
  19563. this._configuration.ha1 = String(value); // Delete the plain SIP password.
  19564. this._configuration.password = null;
  19565. break;
  19566. }
  19567. case 'display_name':
  19568. {
  19569. this._configuration.display_name = value;
  19570. break;
  19571. }
  19572. default:
  19573. debugerror('set() | cannot set "%s" parameter in runtime', parameter);
  19574. return false;
  19575. }
  19576. return true;
  19577. } // ==========================
  19578. // Event Handlers.
  19579. // ==========================
  19580. /**
  19581. * new Transaction
  19582. */
  19583. }, {
  19584. key: "newTransaction",
  19585. value: function newTransaction(transaction) {
  19586. this._transactions[transaction.type][transaction.id] = transaction;
  19587. this.emit('newTransaction', {
  19588. transaction: transaction
  19589. });
  19590. }
  19591. /**
  19592. * Transaction destroyed.
  19593. */
  19594. }, {
  19595. key: "destroyTransaction",
  19596. value: function destroyTransaction(transaction) {
  19597. delete this._transactions[transaction.type][transaction.id];
  19598. this.emit('transactionDestroyed', {
  19599. transaction: transaction
  19600. });
  19601. }
  19602. /**
  19603. * new Dialog
  19604. */
  19605. }, {
  19606. key: "newDialog",
  19607. value: function newDialog(dialog) {
  19608. this._dialogs[dialog.id] = dialog;
  19609. }
  19610. /**
  19611. * Dialog destroyed.
  19612. */
  19613. }, {
  19614. key: "destroyDialog",
  19615. value: function destroyDialog(dialog) {
  19616. delete this._dialogs[dialog.id];
  19617. }
  19618. /**
  19619. * new Message
  19620. */
  19621. }, {
  19622. key: "newMessage",
  19623. value: function newMessage(message, data) {
  19624. this._applicants[message] = message;
  19625. this.emit('newMessage', data);
  19626. }
  19627. /**
  19628. * Message destroyed.
  19629. */
  19630. }, {
  19631. key: "destroyMessage",
  19632. value: function destroyMessage(message) {
  19633. delete this._applicants[message];
  19634. }
  19635. /**
  19636. * new RTCSession
  19637. */
  19638. }, {
  19639. key: "newRTCSession",
  19640. value: function newRTCSession(session, data) {
  19641. this._sessions[session.id] = session;
  19642. this.emit('newRTCSession', data);
  19643. }
  19644. /**
  19645. * RTCSession destroyed.
  19646. */
  19647. }, {
  19648. key: "destroyRTCSession",
  19649. value: function destroyRTCSession(session) {
  19650. delete this._sessions[session.id];
  19651. }
  19652. /**
  19653. * Registered
  19654. */
  19655. }, {
  19656. key: "registered",
  19657. value: function registered(data) {
  19658. this.emit('registered', data);
  19659. }
  19660. /**
  19661. * Unregistered
  19662. */
  19663. }, {
  19664. key: "unregistered",
  19665. value: function unregistered(data) {
  19666. this.emit('unregistered', data);
  19667. }
  19668. /**
  19669. * Registration Failed
  19670. */
  19671. }, {
  19672. key: "registrationFailed",
  19673. value: function registrationFailed(data) {
  19674. this.emit('registrationFailed', data);
  19675. } // =========================
  19676. // ReceiveRequest.
  19677. // =========================
  19678. /**
  19679. * Request reception
  19680. */
  19681. }, {
  19682. key: "receiveRequest",
  19683. value: function receiveRequest(request) {
  19684. var method = request.method; // Check that request URI points to us.
  19685. if (request.ruri.user !== this._configuration.uri.user && request.ruri.user !== this._contact.uri.user) {
  19686. debug('Request-URI does not point to us');
  19687. if (request.method !== JsSIP_C.ACK) {
  19688. request.reply_sl(404);
  19689. }
  19690. return;
  19691. } // Check request URI scheme.
  19692. if (request.ruri.scheme === JsSIP_C.SIPS) {
  19693. request.reply_sl(416);
  19694. return;
  19695. } // Check transaction.
  19696. if (Transactions.checkTransaction(this, request)) {
  19697. return;
  19698. } // Create the server transaction.
  19699. if (method === JsSIP_C.INVITE) {
  19700. /* eslint-disable no-new */
  19701. new Transactions.InviteServerTransaction(this, this._transport, request);
  19702. /* eslint-enable no-new */
  19703. } else if (method !== JsSIP_C.ACK && method !== JsSIP_C.CANCEL) {
  19704. /* eslint-disable no-new */
  19705. new Transactions.NonInviteServerTransaction(this, this._transport, request);
  19706. /* eslint-enable no-new */
  19707. }
  19708. /* RFC3261 12.2.2
  19709. * Requests that do not change in any way the state of a dialog may be
  19710. * received within a dialog (for example, an OPTIONS request).
  19711. * They are processed as if they had been received outside the dialog.
  19712. */
  19713. if (method === JsSIP_C.OPTIONS) {
  19714. request.reply(200);
  19715. } else if (method === JsSIP_C.MESSAGE) {
  19716. if (this.listeners('newMessage').length === 0) {
  19717. request.reply(405);
  19718. return;
  19719. }
  19720. var message = new Message(this);
  19721. message.init_incoming(request);
  19722. } else if (method === JsSIP_C.INVITE) {
  19723. // Initial INVITE.
  19724. if (!request.to_tag && this.listeners('newRTCSession').length === 0) {
  19725. console.log("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
  19726. request.reply(405);
  19727. return;
  19728. }
  19729. }
  19730. var dialog;
  19731. var session; // Initial Request.
  19732. if (!request.to_tag) {
  19733. switch (method) {
  19734. case JsSIP_C.INVITE:
  19735. if (window.RTCPeerConnection) {
  19736. // TODO
  19737. if (request.hasHeader('replaces')) {
  19738. var replaces = request.replaces;
  19739. dialog = this._findDialog(replaces.call_id, replaces.from_tag, replaces.to_tag);
  19740. if (dialog) {
  19741. session = dialog.owner;
  19742. if (!session.isEnded()) {
  19743. session.receiveRequest(request);
  19744. } else {
  19745. request.reply(603);
  19746. }
  19747. } else {
  19748. request.reply(481);
  19749. }
  19750. } else {
  19751. session = new RTCSession(this);
  19752. session.init_incoming(request);
  19753. }
  19754. } else {
  19755. debugerror('INVITE received but WebRTC is not supported');
  19756. request.reply(488);
  19757. }
  19758. break;
  19759. case JsSIP_C.BYE:
  19760. // Out of dialog BYE received.
  19761. request.reply(481);
  19762. break;
  19763. case JsSIP_C.CANCEL:
  19764. session = this._findSession(request);
  19765. if (session) {
  19766. session.receiveRequest(request);
  19767. } else {
  19768. debug('received CANCEL request for a non existent session');
  19769. }
  19770. break;
  19771. case JsSIP_C.ACK:
  19772. /* Absorb it.
  19773. * ACK request without a corresponding Invite Transaction
  19774. * and without To tag.
  19775. */
  19776. break;
  19777. case JsSIP_C.NOTIFY:
  19778. // Receive new sip event.
  19779. this.emit('sipEvent', {
  19780. event: request.event,
  19781. request: request
  19782. });
  19783. request.reply(200);
  19784. break;
  19785. default:
  19786. request.reply(405);
  19787. break;
  19788. }
  19789. } // In-dialog request.
  19790. else {
  19791. dialog = this._findDialog(request.call_id, request.from_tag, request.to_tag);
  19792. if (dialog) {
  19793. dialog.receiveRequest(request);
  19794. } else if (method === JsSIP_C.NOTIFY) {
  19795. session = this._findSession(request);
  19796. if (session) {
  19797. session.receiveRequest(request);
  19798. } else {
  19799. debug('received NOTIFY request for a non existent subscription');
  19800. request.reply(481, 'Subscription does not exist');
  19801. }
  19802. }
  19803. /* RFC3261 12.2.2
  19804. * Request with to tag, but no matching dialog found.
  19805. * Exception: ACK for an Invite request for which a dialog has not
  19806. * been created.
  19807. */
  19808. else if (method !== JsSIP_C.ACK) {
  19809. request.reply(481);
  19810. }
  19811. }
  19812. } // =================
  19813. // Utils.
  19814. // =================
  19815. /**
  19816. * Get the session to which the request belongs to, if any.
  19817. */
  19818. }, {
  19819. key: "_findSession",
  19820. value: function _findSession(_ref) {
  19821. var call_id = _ref.call_id,
  19822. from_tag = _ref.from_tag,
  19823. to_tag = _ref.to_tag;
  19824. var sessionIDa = call_id + from_tag;
  19825. var sessionA = this._sessions[sessionIDa];
  19826. var sessionIDb = call_id + to_tag;
  19827. var sessionB = this._sessions[sessionIDb];
  19828. if (sessionA) {
  19829. return sessionA;
  19830. } else if (sessionB) {
  19831. return sessionB;
  19832. } else {
  19833. return null;
  19834. }
  19835. }
  19836. /**
  19837. * Get the dialog to which the request belongs to, if any.
  19838. */
  19839. }, {
  19840. key: "_findDialog",
  19841. value: function _findDialog(call_id, from_tag, to_tag) {
  19842. var id = call_id + from_tag + to_tag;
  19843. var dialog = this._dialogs[id];
  19844. if (dialog) {
  19845. return dialog;
  19846. } else {
  19847. id = call_id + to_tag + from_tag;
  19848. dialog = this._dialogs[id];
  19849. if (dialog) {
  19850. return dialog;
  19851. } else {
  19852. return null;
  19853. }
  19854. }
  19855. }
  19856. }, {
  19857. key: "_loadConfig",
  19858. value: function _loadConfig(configuration) {
  19859. // Check and load the given configuration.
  19860. try {
  19861. config.load(this._configuration, configuration);
  19862. } catch (e) {
  19863. throw e;
  19864. } // Post Configuration Process.
  19865. // Allow passing 0 number as display_name.
  19866. if (this._configuration.display_name === 0) {
  19867. this._configuration.display_name = '0';
  19868. } // Instance-id for GRUU.
  19869. if (!this._configuration.instance_id) {
  19870. this._configuration.instance_id = Utils.newUUID();
  19871. } // Jssip_id instance parameter. Static random tag of length 5.
  19872. this._configuration.jssip_id = Utils.createRandomToken(5); // String containing this._configuration.uri without scheme and user.
  19873. var hostport_params = this._configuration.uri.clone();
  19874. hostport_params.user = null;
  19875. this._configuration.hostport_params = hostport_params.toString().replace(/^sip:/i, ''); // Transport.
  19876. try {
  19877. this._transport = new Transport(this._configuration.sockets, {
  19878. // Recovery options.
  19879. max_interval: this._configuration.connection_recovery_max_interval,
  19880. min_interval: this._configuration.connection_recovery_min_interval
  19881. }); // Transport event callbacks.
  19882. this._transport.onconnecting = onTransportConnecting.bind(this);
  19883. this._transport.onconnect = onTransportConnect.bind(this);
  19884. this._transport.ondisconnect = onTransportDisconnect.bind(this);
  19885. this._transport.ondata = onTransportData.bind(this);
  19886. } catch (e) {
  19887. debugerror(e);
  19888. throw new Exceptions.ConfigurationError('sockets', this._configuration.sockets);
  19889. } // Remove sockets instance from configuration object.
  19890. delete this._configuration.sockets; // Check whether authorization_user is explicitly defined.
  19891. // Take 'this._configuration.uri.user' value if not.
  19892. if (!this._configuration.authorization_user) {
  19893. this._configuration.authorization_user = this._configuration.uri.user;
  19894. } // If no 'registrar_server' is set use the 'uri' value without user portion and
  19895. // without URI params/headers.
  19896. if (!this._configuration.registrar_server) {
  19897. var registrar_server = this._configuration.uri.clone();
  19898. registrar_server.user = null;
  19899. registrar_server.clearParams();
  19900. registrar_server.clearHeaders();
  19901. this._configuration.registrar_server = registrar_server;
  19902. } // User no_answer_timeout.
  19903. this._configuration.no_answer_timeout *= 1000; // Via Host.
  19904. if (this._configuration.contact_uri) {
  19905. this._configuration.via_host = this._configuration.contact_uri.host;
  19906. } // Contact URI.
  19907. else {
  19908. this._configuration.contact_uri = new URI('sip', Utils.createRandomToken(8), this._configuration.via_host, null, {
  19909. transport: 'ws'
  19910. });
  19911. }
  19912. this._contact = {
  19913. pub_gruu: null,
  19914. temp_gruu: null,
  19915. uri: this._configuration.contact_uri,
  19916. toString: function toString() {
  19917. var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
  19918. var anonymous = options.anonymous || null;
  19919. var outbound = options.outbound || null;
  19920. var contact = '<';
  19921. if (anonymous) {
  19922. contact += this.temp_gruu || 'sip:anonymous@anonymous.invalid;transport=ws';
  19923. } else {
  19924. contact += this.pub_gruu || this.uri.toString();
  19925. }
  19926. if (outbound && (anonymous ? !this.temp_gruu : !this.pub_gruu)) {
  19927. contact += ';ob';
  19928. }
  19929. contact += '>';
  19930. return contact;
  19931. }
  19932. }; // Seal the configuration.
  19933. var writable_parameters = ['password', 'realm', 'ha1', 'display_name', 'register'];
  19934. for (var parameter in this._configuration) {
  19935. if (Object.prototype.hasOwnProperty.call(this._configuration, parameter)) {
  19936. if (writable_parameters.indexOf(parameter) !== -1) {
  19937. Object.defineProperty(this._configuration, parameter, {
  19938. writable: true,
  19939. configurable: false
  19940. });
  19941. } else {
  19942. Object.defineProperty(this._configuration, parameter, {
  19943. writable: false,
  19944. configurable: false
  19945. });
  19946. }
  19947. }
  19948. }
  19949. debug('configuration parameters after validation:');
  19950. for (var _parameter in this._configuration) {
  19951. // Only show the user user configurable parameters.
  19952. if (Object.prototype.hasOwnProperty.call(config.settings, _parameter)) {
  19953. switch (_parameter) {
  19954. case 'uri':
  19955. case 'registrar_server':
  19956. debug("- ".concat(_parameter, ": ").concat(this._configuration[_parameter]));
  19957. break;
  19958. case 'password':
  19959. case 'ha1':
  19960. debug("- ".concat(_parameter, ": NOT SHOWN"));
  19961. break;
  19962. default:
  19963. debug("- ".concat(_parameter, ": ").concat(JSON.stringify(this._configuration[_parameter])));
  19964. }
  19965. }
  19966. }
  19967. return;
  19968. }
  19969. }, {
  19970. key: "C",
  19971. get: function get() {
  19972. return C;
  19973. }
  19974. }, {
  19975. key: "status",
  19976. get: function get() {
  19977. return this._status;
  19978. }
  19979. }, {
  19980. key: "contact",
  19981. get: function get() {
  19982. return this._contact;
  19983. }
  19984. }, {
  19985. key: "configuration",
  19986. get: function get() {
  19987. return this._configuration;
  19988. }
  19989. }, {
  19990. key: "transport",
  19991. get: function get() {
  19992. return this._transport;
  19993. }
  19994. }]);
  19995. return UA;
  19996. }(EventEmitter);
  19997. /**
  19998. * Transport event handlers
  19999. */
  20000. // Transport connecting event.
  20001. function onTransportConnecting(data) {
  20002. this.emit('connecting', data);
  20003. } // Transport connected event.
  20004. function onTransportConnect(data) {
  20005. if (this._status === C.STATUS_USER_CLOSED) {
  20006. return;
  20007. }
  20008. this._status = C.STATUS_READY;
  20009. this._error = null;
  20010. this.emit('connected', data);
  20011. if (this._dynConfiguration.register) {
  20012. this._registrator.register();
  20013. }
  20014. } // Transport disconnected event.
  20015. function onTransportDisconnect(data) {
  20016. // Run _onTransportError_ callback on every client transaction using _transport_.
  20017. var client_transactions = ['nict', 'ict', 'nist', 'ist'];
  20018. for (var _i = 0, _client_transactions = client_transactions; _i < _client_transactions.length; _i++) {
  20019. var type = _client_transactions[_i];
  20020. for (var id in this._transactions[type]) {
  20021. if (Object.prototype.hasOwnProperty.call(this._transactions[type], id)) {
  20022. this._transactions[type][id].onTransportError();
  20023. }
  20024. }
  20025. }
  20026. this.emit('disconnected', data); // Call registrator _onTransportClosed_.
  20027. this._registrator.onTransportClosed();
  20028. if (this._status !== C.STATUS_USER_CLOSED) {
  20029. this._status = C.STATUS_NOT_READY;
  20030. this._error = C.NETWORK_ERROR;
  20031. }
  20032. } // Transport data event.
  20033. function onTransportData(data) {
  20034. var transport = data.transport;
  20035. var message = data.message;
  20036. message = Parser.parseMessage(message, this);
  20037. if (!message) {
  20038. return;
  20039. }
  20040. if (this._status === C.STATUS_USER_CLOSED && message instanceof SIPMessage.IncomingRequest) {
  20041. return;
  20042. } // Do some sanity check.
  20043. if (!sanityCheck(message, this, transport)) {
  20044. return;
  20045. }
  20046. if (message instanceof SIPMessage.IncomingRequest) {
  20047. message.transport = transport;
  20048. this.receiveRequest(message);
  20049. } else if (message instanceof SIPMessage.IncomingResponse) {
  20050. /* Unike stated in 18.1.2, if a response does not match
  20051. * any transaction, it is discarded here and no passed to the core
  20052. * in order to be discarded there.
  20053. */
  20054. var transaction;
  20055. switch (message.method) {
  20056. case JsSIP_C.INVITE:
  20057. transaction = this._transactions.ict[message.via_branch];
  20058. if (transaction) {
  20059. transaction.receiveResponse(message);
  20060. }
  20061. break;
  20062. case JsSIP_C.ACK:
  20063. // Just in case ;-).
  20064. break;
  20065. default:
  20066. transaction = this._transactions.nict[message.via_branch];
  20067. if (transaction) {
  20068. transaction.receiveResponse(message);
  20069. }
  20070. break;
  20071. }
  20072. }
  20073. }
  20074. },{"./Config":1,"./Constants":2,"./Exceptions":6,"./Message":9,"./Parser":11,"./RTCSession":12,"./Registrator":17,"./SIPMessage":19,"./Transactions":22,"./Transport":23,"./URI":25,"./Utils":26,"./sanityCheck":28,"debug":30,"events":29}],25:[function(require,module,exports){
  20075. "use strict";
  20076. function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  20077. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  20078. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  20079. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20080. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  20081. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  20082. var JsSIP_C = require('./Constants');
  20083. var Utils = require('./Utils');
  20084. var Grammar = require('./Grammar');
  20085. /**
  20086. * -param {String} [scheme]
  20087. * -param {String} [user]
  20088. * -param {String} host
  20089. * -param {String} [port]
  20090. * -param {Object} [parameters]
  20091. * -param {Object} [headers]
  20092. *
  20093. */
  20094. module.exports = /*#__PURE__*/function () {
  20095. _createClass(URI, null, [{
  20096. key: "parse",
  20097. /**
  20098. * Parse the given string and returns a JsSIP.URI instance or undefined if
  20099. * it is an invalid URI.
  20100. */
  20101. value: function parse(uri) {
  20102. uri = Grammar.parse(uri, 'SIP_URI');
  20103. if (uri !== -1) {
  20104. return uri;
  20105. } else {
  20106. return undefined;
  20107. }
  20108. }
  20109. }]);
  20110. function URI(scheme, user, host, port) {
  20111. var parameters = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
  20112. var headers = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : {};
  20113. _classCallCheck(this, URI);
  20114. // Checks.
  20115. if (!host) {
  20116. throw new TypeError('missing or invalid "host" parameter');
  20117. } // Initialize parameters.
  20118. this._parameters = {};
  20119. this._headers = {};
  20120. this._scheme = scheme || JsSIP_C.SIP;
  20121. this._user = user;
  20122. this._host = host;
  20123. this._port = port;
  20124. for (var param in parameters) {
  20125. if (Object.prototype.hasOwnProperty.call(parameters, param)) {
  20126. this.setParam(param, parameters[param]);
  20127. }
  20128. }
  20129. for (var header in headers) {
  20130. if (Object.prototype.hasOwnProperty.call(headers, header)) {
  20131. this.setHeader(header, headers[header]);
  20132. }
  20133. }
  20134. }
  20135. _createClass(URI, [{
  20136. key: "setParam",
  20137. value: function setParam(key, value) {
  20138. if (key) {
  20139. this._parameters[key.toLowerCase()] = typeof value === 'undefined' || value === null ? null : value.toString();
  20140. }
  20141. }
  20142. }, {
  20143. key: "getParam",
  20144. value: function getParam(key) {
  20145. if (key) {
  20146. return this._parameters[key.toLowerCase()];
  20147. }
  20148. }
  20149. }, {
  20150. key: "hasParam",
  20151. value: function hasParam(key) {
  20152. if (key) {
  20153. return this._parameters.hasOwnProperty(key.toLowerCase()) && true || false;
  20154. }
  20155. }
  20156. }, {
  20157. key: "deleteParam",
  20158. value: function deleteParam(parameter) {
  20159. parameter = parameter.toLowerCase();
  20160. if (this._parameters.hasOwnProperty(parameter)) {
  20161. var value = this._parameters[parameter];
  20162. delete this._parameters[parameter];
  20163. return value;
  20164. }
  20165. }
  20166. }, {
  20167. key: "clearParams",
  20168. value: function clearParams() {
  20169. this._parameters = {};
  20170. }
  20171. }, {
  20172. key: "setHeader",
  20173. value: function setHeader(name, value) {
  20174. this._headers[Utils.headerize(name)] = Array.isArray(value) ? value : [value];
  20175. }
  20176. }, {
  20177. key: "getHeader",
  20178. value: function getHeader(name) {
  20179. if (name) {
  20180. return this._headers[Utils.headerize(name)];
  20181. }
  20182. }
  20183. }, {
  20184. key: "hasHeader",
  20185. value: function hasHeader(name) {
  20186. if (name) {
  20187. return this._headers.hasOwnProperty(Utils.headerize(name)) && true || false;
  20188. }
  20189. }
  20190. }, {
  20191. key: "deleteHeader",
  20192. value: function deleteHeader(header) {
  20193. header = Utils.headerize(header);
  20194. if (this._headers.hasOwnProperty(header)) {
  20195. var value = this._headers[header];
  20196. delete this._headers[header];
  20197. return value;
  20198. }
  20199. }
  20200. }, {
  20201. key: "clearHeaders",
  20202. value: function clearHeaders() {
  20203. this._headers = {};
  20204. }
  20205. }, {
  20206. key: "clone",
  20207. value: function clone() {
  20208. return new URI(this._scheme, this._user, this._host, this._port, JSON.parse(JSON.stringify(this._parameters)), JSON.parse(JSON.stringify(this._headers)));
  20209. }
  20210. }, {
  20211. key: "toString",
  20212. value: function toString() {
  20213. var headers = [];
  20214. var uri = "".concat(this._scheme, ":");
  20215. if (this._user) {
  20216. uri += "".concat(Utils.escapeUser(this._user), "@");
  20217. }
  20218. uri += this._host;
  20219. if (this._port || this._port === 0) {
  20220. uri += ":".concat(this._port);
  20221. }
  20222. for (var parameter in this._parameters) {
  20223. if (Object.prototype.hasOwnProperty.call(this._parameters, parameter)) {
  20224. uri += ";".concat(parameter);
  20225. if (this._parameters[parameter] !== null) {
  20226. uri += "=".concat(this._parameters[parameter]);
  20227. }
  20228. }
  20229. }
  20230. for (var header in this._headers) {
  20231. if (Object.prototype.hasOwnProperty.call(this._headers, header)) {
  20232. var _iterator = _createForOfIteratorHelper(this._headers[header]),
  20233. _step;
  20234. try {
  20235. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  20236. var item = _step.value;
  20237. headers.push("".concat(header, "=").concat(item));
  20238. }
  20239. } catch (err) {
  20240. _iterator.e(err);
  20241. } finally {
  20242. _iterator.f();
  20243. }
  20244. }
  20245. }
  20246. if (headers.length > 0) {
  20247. uri += "?".concat(headers.join('&'));
  20248. }
  20249. return uri;
  20250. }
  20251. }, {
  20252. key: "toAor",
  20253. value: function toAor(show_port) {
  20254. var aor = "".concat(this._scheme, ":");
  20255. if (this._user) {
  20256. aor += "".concat(Utils.escapeUser(this._user), "@");
  20257. }
  20258. aor += this._host;
  20259. if (show_port && (this._port || this._port === 0)) {
  20260. aor += ":".concat(this._port);
  20261. }
  20262. return aor;
  20263. }
  20264. }, {
  20265. key: "scheme",
  20266. get: function get() {
  20267. return this._scheme;
  20268. },
  20269. set: function set(value) {
  20270. this._scheme = value.toLowerCase();
  20271. }
  20272. }, {
  20273. key: "user",
  20274. get: function get() {
  20275. return this._user;
  20276. },
  20277. set: function set(value) {
  20278. this._user = value;
  20279. }
  20280. }, {
  20281. key: "host",
  20282. get: function get() {
  20283. return this._host;
  20284. },
  20285. set: function set(value) {
  20286. this._host = value.toLowerCase();
  20287. }
  20288. }, {
  20289. key: "port",
  20290. get: function get() {
  20291. return this._port;
  20292. },
  20293. set: function set(value) {
  20294. this._port = value === 0 ? value : parseInt(value, 10) || null;
  20295. }
  20296. }]);
  20297. return URI;
  20298. }();
  20299. },{"./Constants":2,"./Grammar":7,"./Utils":26}],26:[function(require,module,exports){
  20300. "use strict";
  20301. function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
  20302. function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  20303. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  20304. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  20305. var JsSIP_C = require('./Constants');
  20306. var URI = require('./URI');
  20307. var Grammar = require('./Grammar');
  20308. exports.str_utf8_length = function (string) {
  20309. return unescape(encodeURIComponent(string)).length;
  20310. }; // Used by 'hasMethods'.
  20311. var isFunction = exports.isFunction = function (fn) {
  20312. if (fn !== undefined) {
  20313. return Object.prototype.toString.call(fn) === '[object Function]' ? true : false;
  20314. } else {
  20315. return false;
  20316. }
  20317. };
  20318. exports.isString = function (str) {
  20319. if (str !== undefined) {
  20320. return Object.prototype.toString.call(str) === '[object String]' ? true : false;
  20321. } else {
  20322. return false;
  20323. }
  20324. };
  20325. exports.isDecimal = function (num) {
  20326. return !isNaN(num) && parseFloat(num) === parseInt(num, 10);
  20327. };
  20328. exports.isEmpty = function (value) {
  20329. return value === null || value === '' || value === undefined || Array.isArray(value) && value.length === 0 || typeof value === 'number' && isNaN(value);
  20330. };
  20331. exports.hasMethods = function (obj) {
  20332. for (var _len = arguments.length, methodNames = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
  20333. methodNames[_key - 1] = arguments[_key];
  20334. }
  20335. for (var _i = 0, _methodNames = methodNames; _i < _methodNames.length; _i++) {
  20336. var methodName = _methodNames[_i];
  20337. if (isFunction(obj[methodName])) {
  20338. return false;
  20339. }
  20340. }
  20341. return true;
  20342. }; // Used by 'newTag'.
  20343. var createRandomToken = exports.createRandomToken = function (size) {
  20344. var base = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 32;
  20345. var i,
  20346. r,
  20347. token = '';
  20348. for (i = 0; i < size; i++) {
  20349. r = Math.random() * base | 0;
  20350. token += r.toString(base);
  20351. }
  20352. return token;
  20353. };
  20354. exports.newTag = function () {
  20355. return createRandomToken(10);
  20356. }; // https://stackoverflow.com/users/109538/broofa.
  20357. exports.newUUID = function () {
  20358. var UUID = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  20359. var r = Math.random() * 16 | 0,
  20360. v = c === 'x' ? r : r & 0x3 | 0x8;
  20361. return v.toString(16);
  20362. });
  20363. return UUID;
  20364. };
  20365. exports.hostType = function (host) {
  20366. if (!host) {
  20367. return;
  20368. } else {
  20369. host = Grammar.parse(host, 'host');
  20370. if (host !== -1) {
  20371. return host.host_type;
  20372. }
  20373. }
  20374. };
  20375. /**
  20376. * Hex-escape a SIP URI user.
  20377. * Don't hex-escape ':' (%3A), '+' (%2B), '?' (%3F"), '/' (%2F).
  20378. *
  20379. * Used by 'normalizeTarget'.
  20380. */
  20381. var escapeUser = exports.escapeUser = function (user) {
  20382. return encodeURIComponent(decodeURIComponent(user)).replace(/%3A/ig, ':').replace(/%2B/ig, '+').replace(/%3F/ig, '?').replace(/%2F/ig, '/');
  20383. };
  20384. /**
  20385. * Normalize SIP URI.
  20386. * NOTE: It does not allow a SIP URI without username.
  20387. * Accepts 'sip', 'sips' and 'tel' URIs and convert them into 'sip'.
  20388. * Detects the domain part (if given) and properly hex-escapes the user portion.
  20389. * If the user portion has only 'tel' number symbols the user portion is clean of 'tel' visual separators.
  20390. */
  20391. exports.normalizeTarget = function (target, domain) {
  20392. // If no target is given then raise an error.
  20393. if (!target) {
  20394. return; // If a URI instance is given then return it.
  20395. } else if (target instanceof URI) {
  20396. return target; // If a string is given split it by '@':
  20397. // - Last fragment is the desired domain.
  20398. // - Otherwise append the given domain argument.
  20399. } else if (typeof target === 'string') {
  20400. var target_array = target.split('@');
  20401. var target_user;
  20402. var target_domain;
  20403. switch (target_array.length) {
  20404. case 1:
  20405. if (!domain) {
  20406. return;
  20407. }
  20408. target_user = target;
  20409. target_domain = domain;
  20410. break;
  20411. case 2:
  20412. target_user = target_array[0];
  20413. target_domain = target_array[1];
  20414. break;
  20415. default:
  20416. target_user = target_array.slice(0, target_array.length - 1).join('@');
  20417. target_domain = target_array[target_array.length - 1];
  20418. } // Remove the URI scheme (if present).
  20419. target_user = target_user.replace(/^(sips?|tel):/i, ''); // Remove 'tel' visual separators if the user portion just contains 'tel' number symbols.
  20420. if (/^[-.()]*\+?[0-9\-.()]+$/.test(target_user)) {
  20421. target_user = target_user.replace(/[-.()]/g, '');
  20422. } // Build the complete SIP URI.
  20423. target = "".concat(JsSIP_C.SIP, ":").concat(escapeUser(target_user), "@").concat(target_domain); // Finally parse the resulting URI.
  20424. var uri;
  20425. if (uri = URI.parse(target)) {
  20426. return uri;
  20427. } else {
  20428. return;
  20429. }
  20430. } else {
  20431. return;
  20432. }
  20433. };
  20434. exports.headerize = function (string) {
  20435. var exceptions = {
  20436. 'Call-Id': 'Call-ID',
  20437. 'Cseq': 'CSeq',
  20438. 'Www-Authenticate': 'WWW-Authenticate'
  20439. };
  20440. var name = string.toLowerCase().replace(/_/g, '-').split('-');
  20441. var hname = '';
  20442. var parts = name.length;
  20443. var part;
  20444. for (part = 0; part < parts; part++) {
  20445. if (part !== 0) {
  20446. hname += '-';
  20447. }
  20448. hname += name[part].charAt(0).toUpperCase() + name[part].substring(1);
  20449. }
  20450. if (exceptions[hname]) {
  20451. hname = exceptions[hname];
  20452. }
  20453. return hname;
  20454. };
  20455. exports.sipErrorCause = function (status_code) {
  20456. for (var cause in JsSIP_C.SIP_ERROR_CAUSES) {
  20457. if (JsSIP_C.SIP_ERROR_CAUSES[cause].indexOf(status_code) !== -1) {
  20458. return JsSIP_C.causes[cause];
  20459. }
  20460. }
  20461. return JsSIP_C.causes.SIP_FAILURE_CODE;
  20462. };
  20463. /**
  20464. * Generate a random Test-Net IP (https://tools.ietf.org/html/rfc5735)
  20465. */
  20466. exports.getRandomTestNetIP = function () {
  20467. function getOctet(from, to) {
  20468. return Math.floor(Math.random() * (to - from + 1) + from);
  20469. }
  20470. return "192.0.2.".concat(getOctet(1, 254));
  20471. }; // MD5 (Message-Digest Algorithm) https://www.webtoolkit.info.
  20472. exports.calculateMD5 = function (string) {
  20473. function rotateLeft(lValue, iShiftBits) {
  20474. return lValue << iShiftBits | lValue >>> 32 - iShiftBits;
  20475. }
  20476. function addUnsigned(lX, lY) {
  20477. var lX8 = lX & 0x80000000;
  20478. var lY8 = lY & 0x80000000;
  20479. var lX4 = lX & 0x40000000;
  20480. var lY4 = lY & 0x40000000;
  20481. var lResult = (lX & 0x3FFFFFFF) + (lY & 0x3FFFFFFF);
  20482. if (lX4 & lY4) {
  20483. return lResult ^ 0x80000000 ^ lX8 ^ lY8;
  20484. }
  20485. if (lX4 | lY4) {
  20486. if (lResult & 0x40000000) {
  20487. return lResult ^ 0xC0000000 ^ lX8 ^ lY8;
  20488. } else {
  20489. return lResult ^ 0x40000000 ^ lX8 ^ lY8;
  20490. }
  20491. } else {
  20492. return lResult ^ lX8 ^ lY8;
  20493. }
  20494. }
  20495. function doF(x, y, z) {
  20496. return x & y | ~x & z;
  20497. }
  20498. function doG(x, y, z) {
  20499. return x & z | y & ~z;
  20500. }
  20501. function doH(x, y, z) {
  20502. return x ^ y ^ z;
  20503. }
  20504. function doI(x, y, z) {
  20505. return y ^ (x | ~z);
  20506. }
  20507. function doFF(a, b, c, d, x, s, ac) {
  20508. a = addUnsigned(a, addUnsigned(addUnsigned(doF(b, c, d), x), ac));
  20509. return addUnsigned(rotateLeft(a, s), b);
  20510. }
  20511. function doGG(a, b, c, d, x, s, ac) {
  20512. a = addUnsigned(a, addUnsigned(addUnsigned(doG(b, c, d), x), ac));
  20513. return addUnsigned(rotateLeft(a, s), b);
  20514. }
  20515. function doHH(a, b, c, d, x, s, ac) {
  20516. a = addUnsigned(a, addUnsigned(addUnsigned(doH(b, c, d), x), ac));
  20517. return addUnsigned(rotateLeft(a, s), b);
  20518. }
  20519. function doII(a, b, c, d, x, s, ac) {
  20520. a = addUnsigned(a, addUnsigned(addUnsigned(doI(b, c, d), x), ac));
  20521. return addUnsigned(rotateLeft(a, s), b);
  20522. }
  20523. function convertToWordArray(str) {
  20524. var lWordCount;
  20525. var lMessageLength = str.length;
  20526. var lNumberOfWords_temp1 = lMessageLength + 8;
  20527. var lNumberOfWords_temp2 = (lNumberOfWords_temp1 - lNumberOfWords_temp1 % 64) / 64;
  20528. var lNumberOfWords = (lNumberOfWords_temp2 + 1) * 16;
  20529. var lWordArray = new Array(lNumberOfWords - 1);
  20530. var lBytePosition = 0;
  20531. var lByteCount = 0;
  20532. while (lByteCount < lMessageLength) {
  20533. lWordCount = (lByteCount - lByteCount % 4) / 4;
  20534. lBytePosition = lByteCount % 4 * 8;
  20535. lWordArray[lWordCount] = lWordArray[lWordCount] | str.charCodeAt(lByteCount) << lBytePosition;
  20536. lByteCount++;
  20537. }
  20538. lWordCount = (lByteCount - lByteCount % 4) / 4;
  20539. lBytePosition = lByteCount % 4 * 8;
  20540. lWordArray[lWordCount] = lWordArray[lWordCount] | 0x80 << lBytePosition;
  20541. lWordArray[lNumberOfWords - 2] = lMessageLength << 3;
  20542. lWordArray[lNumberOfWords - 1] = lMessageLength >>> 29;
  20543. return lWordArray;
  20544. }
  20545. function wordToHex(lValue) {
  20546. var wordToHexValue = '',
  20547. wordToHexValue_temp = '',
  20548. lByte,
  20549. lCount;
  20550. for (lCount = 0; lCount <= 3; lCount++) {
  20551. lByte = lValue >>> lCount * 8 & 255;
  20552. wordToHexValue_temp = "0".concat(lByte.toString(16));
  20553. wordToHexValue = wordToHexValue + wordToHexValue_temp.substr(wordToHexValue_temp.length - 2, 2);
  20554. }
  20555. return wordToHexValue;
  20556. }
  20557. function utf8Encode(str) {
  20558. str = str.replace(/\r\n/g, '\n');
  20559. var utftext = '';
  20560. for (var n = 0; n < str.length; n++) {
  20561. var _c = str.charCodeAt(n);
  20562. if (_c < 128) {
  20563. utftext += String.fromCharCode(_c);
  20564. } else if (_c > 127 && _c < 2048) {
  20565. utftext += String.fromCharCode(_c >> 6 | 192);
  20566. utftext += String.fromCharCode(_c & 63 | 128);
  20567. } else {
  20568. utftext += String.fromCharCode(_c >> 12 | 224);
  20569. utftext += String.fromCharCode(_c >> 6 & 63 | 128);
  20570. utftext += String.fromCharCode(_c & 63 | 128);
  20571. }
  20572. }
  20573. return utftext;
  20574. }
  20575. var x = [];
  20576. var k, AA, BB, CC, DD, a, b, c, d;
  20577. var S11 = 7,
  20578. S12 = 12,
  20579. S13 = 17,
  20580. S14 = 22;
  20581. var S21 = 5,
  20582. S22 = 9,
  20583. S23 = 14,
  20584. S24 = 20;
  20585. var S31 = 4,
  20586. S32 = 11,
  20587. S33 = 16,
  20588. S34 = 23;
  20589. var S41 = 6,
  20590. S42 = 10,
  20591. S43 = 15,
  20592. S44 = 21;
  20593. string = utf8Encode(string);
  20594. x = convertToWordArray(string);
  20595. a = 0x67452301;
  20596. b = 0xEFCDAB89;
  20597. c = 0x98BADCFE;
  20598. d = 0x10325476;
  20599. for (k = 0; k < x.length; k += 16) {
  20600. AA = a;
  20601. BB = b;
  20602. CC = c;
  20603. DD = d;
  20604. a = doFF(a, b, c, d, x[k + 0], S11, 0xD76AA478);
  20605. d = doFF(d, a, b, c, x[k + 1], S12, 0xE8C7B756);
  20606. c = doFF(c, d, a, b, x[k + 2], S13, 0x242070DB);
  20607. b = doFF(b, c, d, a, x[k + 3], S14, 0xC1BDCEEE);
  20608. a = doFF(a, b, c, d, x[k + 4], S11, 0xF57C0FAF);
  20609. d = doFF(d, a, b, c, x[k + 5], S12, 0x4787C62A);
  20610. c = doFF(c, d, a, b, x[k + 6], S13, 0xA8304613);
  20611. b = doFF(b, c, d, a, x[k + 7], S14, 0xFD469501);
  20612. a = doFF(a, b, c, d, x[k + 8], S11, 0x698098D8);
  20613. d = doFF(d, a, b, c, x[k + 9], S12, 0x8B44F7AF);
  20614. c = doFF(c, d, a, b, x[k + 10], S13, 0xFFFF5BB1);
  20615. b = doFF(b, c, d, a, x[k + 11], S14, 0x895CD7BE);
  20616. a = doFF(a, b, c, d, x[k + 12], S11, 0x6B901122);
  20617. d = doFF(d, a, b, c, x[k + 13], S12, 0xFD987193);
  20618. c = doFF(c, d, a, b, x[k + 14], S13, 0xA679438E);
  20619. b = doFF(b, c, d, a, x[k + 15], S14, 0x49B40821);
  20620. a = doGG(a, b, c, d, x[k + 1], S21, 0xF61E2562);
  20621. d = doGG(d, a, b, c, x[k + 6], S22, 0xC040B340);
  20622. c = doGG(c, d, a, b, x[k + 11], S23, 0x265E5A51);
  20623. b = doGG(b, c, d, a, x[k + 0], S24, 0xE9B6C7AA);
  20624. a = doGG(a, b, c, d, x[k + 5], S21, 0xD62F105D);
  20625. d = doGG(d, a, b, c, x[k + 10], S22, 0x2441453);
  20626. c = doGG(c, d, a, b, x[k + 15], S23, 0xD8A1E681);
  20627. b = doGG(b, c, d, a, x[k + 4], S24, 0xE7D3FBC8);
  20628. a = doGG(a, b, c, d, x[k + 9], S21, 0x21E1CDE6);
  20629. d = doGG(d, a, b, c, x[k + 14], S22, 0xC33707D6);
  20630. c = doGG(c, d, a, b, x[k + 3], S23, 0xF4D50D87);
  20631. b = doGG(b, c, d, a, x[k + 8], S24, 0x455A14ED);
  20632. a = doGG(a, b, c, d, x[k + 13], S21, 0xA9E3E905);
  20633. d = doGG(d, a, b, c, x[k + 2], S22, 0xFCEFA3F8);
  20634. c = doGG(c, d, a, b, x[k + 7], S23, 0x676F02D9);
  20635. b = doGG(b, c, d, a, x[k + 12], S24, 0x8D2A4C8A);
  20636. a = doHH(a, b, c, d, x[k + 5], S31, 0xFFFA3942);
  20637. d = doHH(d, a, b, c, x[k + 8], S32, 0x8771F681);
  20638. c = doHH(c, d, a, b, x[k + 11], S33, 0x6D9D6122);
  20639. b = doHH(b, c, d, a, x[k + 14], S34, 0xFDE5380C);
  20640. a = doHH(a, b, c, d, x[k + 1], S31, 0xA4BEEA44);
  20641. d = doHH(d, a, b, c, x[k + 4], S32, 0x4BDECFA9);
  20642. c = doHH(c, d, a, b, x[k + 7], S33, 0xF6BB4B60);
  20643. b = doHH(b, c, d, a, x[k + 10], S34, 0xBEBFBC70);
  20644. a = doHH(a, b, c, d, x[k + 13], S31, 0x289B7EC6);
  20645. d = doHH(d, a, b, c, x[k + 0], S32, 0xEAA127FA);
  20646. c = doHH(c, d, a, b, x[k + 3], S33, 0xD4EF3085);
  20647. b = doHH(b, c, d, a, x[k + 6], S34, 0x4881D05);
  20648. a = doHH(a, b, c, d, x[k + 9], S31, 0xD9D4D039);
  20649. d = doHH(d, a, b, c, x[k + 12], S32, 0xE6DB99E5);
  20650. c = doHH(c, d, a, b, x[k + 15], S33, 0x1FA27CF8);
  20651. b = doHH(b, c, d, a, x[k + 2], S34, 0xC4AC5665);
  20652. a = doII(a, b, c, d, x[k + 0], S41, 0xF4292244);
  20653. d = doII(d, a, b, c, x[k + 7], S42, 0x432AFF97);
  20654. c = doII(c, d, a, b, x[k + 14], S43, 0xAB9423A7);
  20655. b = doII(b, c, d, a, x[k + 5], S44, 0xFC93A039);
  20656. a = doII(a, b, c, d, x[k + 12], S41, 0x655B59C3);
  20657. d = doII(d, a, b, c, x[k + 3], S42, 0x8F0CCC92);
  20658. c = doII(c, d, a, b, x[k + 10], S43, 0xFFEFF47D);
  20659. b = doII(b, c, d, a, x[k + 1], S44, 0x85845DD1);
  20660. a = doII(a, b, c, d, x[k + 8], S41, 0x6FA87E4F);
  20661. d = doII(d, a, b, c, x[k + 15], S42, 0xFE2CE6E0);
  20662. c = doII(c, d, a, b, x[k + 6], S43, 0xA3014314);
  20663. b = doII(b, c, d, a, x[k + 13], S44, 0x4E0811A1);
  20664. a = doII(a, b, c, d, x[k + 4], S41, 0xF7537E82);
  20665. d = doII(d, a, b, c, x[k + 11], S42, 0xBD3AF235);
  20666. c = doII(c, d, a, b, x[k + 2], S43, 0x2AD7D2BB);
  20667. b = doII(b, c, d, a, x[k + 9], S44, 0xEB86D391);
  20668. a = addUnsigned(a, AA);
  20669. b = addUnsigned(b, BB);
  20670. c = addUnsigned(c, CC);
  20671. d = addUnsigned(d, DD);
  20672. }
  20673. var temp = wordToHex(a) + wordToHex(b) + wordToHex(c) + wordToHex(d);
  20674. return temp.toLowerCase();
  20675. };
  20676. exports.closeMediaStream = function (stream) {
  20677. if (!stream) {
  20678. return;
  20679. } // Latest spec states that MediaStream has no stop() method and instead must
  20680. // call stop() on every MediaStreamTrack.
  20681. try {
  20682. var tracks;
  20683. if (stream.getTracks) {
  20684. tracks = stream.getTracks();
  20685. var _iterator = _createForOfIteratorHelper(tracks),
  20686. _step;
  20687. try {
  20688. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  20689. var track = _step.value;
  20690. track.stop();
  20691. }
  20692. } catch (err) {
  20693. _iterator.e(err);
  20694. } finally {
  20695. _iterator.f();
  20696. }
  20697. } else {
  20698. tracks = stream.getAudioTracks();
  20699. var _iterator2 = _createForOfIteratorHelper(tracks),
  20700. _step2;
  20701. try {
  20702. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  20703. var _track = _step2.value;
  20704. _track.stop();
  20705. }
  20706. } catch (err) {
  20707. _iterator2.e(err);
  20708. } finally {
  20709. _iterator2.f();
  20710. }
  20711. tracks = stream.getVideoTracks();
  20712. var _iterator3 = _createForOfIteratorHelper(tracks),
  20713. _step3;
  20714. try {
  20715. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  20716. var _track2 = _step3.value;
  20717. _track2.stop();
  20718. }
  20719. } catch (err) {
  20720. _iterator3.e(err);
  20721. } finally {
  20722. _iterator3.f();
  20723. }
  20724. }
  20725. } catch (error) {
  20726. // Deprecated by the spec, but still in use.
  20727. // NOTE: In Temasys IE plugin stream.stop is a callable 'object'.
  20728. if (typeof stream.stop === 'function' || _typeof(stream.stop) === 'object') {
  20729. stream.stop();
  20730. }
  20731. }
  20732. };
  20733. exports.cloneArray = function (array) {
  20734. return array && array.slice() || [];
  20735. };
  20736. exports.cloneObject = function (obj) {
  20737. var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
  20738. return obj && Object.assign({}, obj) || fallback;
  20739. };
  20740. },{"./Constants":2,"./Grammar":7,"./URI":25}],27:[function(require,module,exports){
  20741. "use strict";
  20742. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  20743. function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
  20744. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  20745. var Grammar = require('./Grammar');
  20746. var debug = require('debug')('JsSIP:WebSocketInterface');
  20747. var debugerror = require('debug')('JsSIP:ERROR:WebSocketInterface');
  20748. debugerror.log = console.warn.bind(console);
  20749. module.exports = /*#__PURE__*/function () {
  20750. function WebSocketInterface(url) {
  20751. _classCallCheck(this, WebSocketInterface);
  20752. debug('new() [url:"%s"]', url);
  20753. this._url = url;
  20754. this._sip_uri = null;
  20755. this._via_transport = null;
  20756. this._ws = null;
  20757. var parsed_url = Grammar.parse(url, 'absoluteURI');
  20758. if (parsed_url === -1) {
  20759. debugerror("invalid WebSocket URI: ".concat(url));
  20760. throw new TypeError("Invalid argument: ".concat(url));
  20761. } else if (parsed_url.scheme !== 'wss' && parsed_url.scheme !== 'ws') {
  20762. debugerror("invalid WebSocket URI scheme: ".concat(parsed_url.scheme));
  20763. throw new TypeError("Invalid argument: ".concat(url));
  20764. } else {
  20765. this._sip_uri = "sip:".concat(parsed_url.host).concat(parsed_url.port ? ":".concat(parsed_url.port) : '', ";transport=ws");
  20766. this._via_transport = parsed_url.scheme.toUpperCase();
  20767. }
  20768. }
  20769. _createClass(WebSocketInterface, [{
  20770. key: "connect",
  20771. value: function connect() {
  20772. debug('connect()');
  20773. if (this.isConnected()) {
  20774. debug("WebSocket ".concat(this._url, " is already connected"));
  20775. return;
  20776. } else if (this.isConnecting()) {
  20777. debug("WebSocket ".concat(this._url, " is connecting"));
  20778. return;
  20779. }
  20780. if (this._ws) {
  20781. this.disconnect();
  20782. }
  20783. debug("connecting to WebSocket ".concat(this._url));
  20784. try {
  20785. this._ws = new WebSocket(this._url, 'sip');
  20786. this._ws.binaryType = 'arraybuffer';
  20787. this._ws.onopen = this._onOpen.bind(this);
  20788. this._ws.onclose = this._onClose.bind(this);
  20789. this._ws.onmessage = this._onMessage.bind(this);
  20790. this._ws.onerror = this._onError.bind(this);
  20791. } catch (e) {
  20792. this._onError(e);
  20793. }
  20794. }
  20795. }, {
  20796. key: "disconnect",
  20797. value: function disconnect() {
  20798. debug('disconnect()');
  20799. if (this._ws) {
  20800. // Unbind websocket event callbacks.
  20801. this._ws.onopen = function () {};
  20802. this._ws.onclose = function () {};
  20803. this._ws.onmessage = function () {};
  20804. this._ws.onerror = function () {};
  20805. this._ws.close();
  20806. this._ws = null;
  20807. }
  20808. }
  20809. }, {
  20810. key: "send",
  20811. value: function send(message) {
  20812. debug('send()');
  20813. if (this.isConnected()) {
  20814. this._ws.send(message);
  20815. return true;
  20816. } else {
  20817. debugerror('unable to send message, WebSocket is not open');
  20818. return false;
  20819. }
  20820. }
  20821. }, {
  20822. key: "isConnected",
  20823. value: function isConnected() {
  20824. return this._ws && this._ws.readyState === this._ws.OPEN;
  20825. }
  20826. }, {
  20827. key: "isConnecting",
  20828. value: function isConnecting() {
  20829. return this._ws && this._ws.readyState === this._ws.CONNECTING;
  20830. }
  20831. /**
  20832. * WebSocket Event Handlers
  20833. */
  20834. }, {
  20835. key: "_onOpen",
  20836. value: function _onOpen() {
  20837. debug("WebSocket ".concat(this._url, " connected"));
  20838. this.onconnect();
  20839. }
  20840. }, {
  20841. key: "_onClose",
  20842. value: function _onClose(_ref) {
  20843. var wasClean = _ref.wasClean,
  20844. code = _ref.code,
  20845. reason = _ref.reason;
  20846. debug("WebSocket ".concat(this._url, " closed"));
  20847. if (wasClean === false) {
  20848. debug('WebSocket abrupt disconnection');
  20849. }
  20850. var data = {
  20851. socket: this,
  20852. error: !wasClean,
  20853. code: code,
  20854. reason: reason
  20855. };
  20856. this.ondisconnect(data);
  20857. }
  20858. }, {
  20859. key: "_onMessage",
  20860. value: function _onMessage(_ref2) {
  20861. var data = _ref2.data;
  20862. debug('received WebSocket message');
  20863. this.ondata(data);
  20864. }
  20865. }, {
  20866. key: "_onError",
  20867. value: function _onError(e) {
  20868. debugerror("WebSocket ".concat(this._url, " error: ").concat(e));
  20869. }
  20870. }, {
  20871. key: "via_transport",
  20872. get: function get() {
  20873. return this._via_transport;
  20874. },
  20875. set: function set(value) {
  20876. this._via_transport = value.toUpperCase();
  20877. }
  20878. }, {
  20879. key: "sip_uri",
  20880. get: function get() {
  20881. return this._sip_uri;
  20882. }
  20883. }, {
  20884. key: "url",
  20885. get: function get() {
  20886. return this._url;
  20887. }
  20888. }]);
  20889. return WebSocketInterface;
  20890. }();
  20891. },{"./Grammar":7,"debug":30}],28:[function(require,module,exports){
  20892. "use strict";
  20893. function _createForOfIteratorHelper(o) { if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (o = _unsupportedIterableToArray(o))) { var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var it, normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
  20894. function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(n); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
  20895. function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
  20896. var JsSIP_C = require('./Constants');
  20897. var SIPMessage = require('./SIPMessage');
  20898. var Utils = require('./Utils');
  20899. var debug = require('debug')('JsSIP:sanityCheck'); // Checks for requests and responses.
  20900. var all = [minimumHeaders]; // Checks for requests.
  20901. var requests = [rfc3261_8_2_2_1, rfc3261_16_3_4, rfc3261_18_3_request, rfc3261_8_2_2_2]; // Checks for responses.
  20902. var responses = [rfc3261_8_1_3_3, rfc3261_18_3_response]; // local variables.
  20903. var message;
  20904. var ua;
  20905. var transport;
  20906. module.exports = function (m, u, t) {
  20907. message = m;
  20908. ua = u;
  20909. transport = t;
  20910. var _iterator = _createForOfIteratorHelper(all),
  20911. _step;
  20912. try {
  20913. for (_iterator.s(); !(_step = _iterator.n()).done;) {
  20914. var _check2 = _step.value;
  20915. if (_check2() === false) {
  20916. return false;
  20917. }
  20918. }
  20919. } catch (err) {
  20920. _iterator.e(err);
  20921. } finally {
  20922. _iterator.f();
  20923. }
  20924. if (message instanceof SIPMessage.IncomingRequest) {
  20925. var _iterator2 = _createForOfIteratorHelper(requests),
  20926. _step2;
  20927. try {
  20928. for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
  20929. var check = _step2.value;
  20930. if (check() === false) {
  20931. return false;
  20932. }
  20933. }
  20934. } catch (err) {
  20935. _iterator2.e(err);
  20936. } finally {
  20937. _iterator2.f();
  20938. }
  20939. } else if (message instanceof SIPMessage.IncomingResponse) {
  20940. var _iterator3 = _createForOfIteratorHelper(responses),
  20941. _step3;
  20942. try {
  20943. for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
  20944. var _check = _step3.value;
  20945. if (_check() === false) {
  20946. return false;
  20947. }
  20948. }
  20949. } catch (err) {
  20950. _iterator3.e(err);
  20951. } finally {
  20952. _iterator3.f();
  20953. }
  20954. } // Everything is OK.
  20955. return true;
  20956. };
  20957. /*
  20958. * Sanity Check for incoming Messages
  20959. *
  20960. * Requests:
  20961. * - _rfc3261_8_2_2_1_ Receive a Request with a non supported URI scheme
  20962. * - _rfc3261_16_3_4_ Receive a Request already sent by us
  20963. * Does not look at via sent-by but at jssip_id, which is inserted as
  20964. * a prefix in all initial requests generated by the ua
  20965. * - _rfc3261_18_3_request_ Body Content-Length
  20966. * - _rfc3261_8_2_2_2_ Merged Requests
  20967. *
  20968. * Responses:
  20969. * - _rfc3261_8_1_3_3_ Multiple Via headers
  20970. * - _rfc3261_18_3_response_ Body Content-Length
  20971. *
  20972. * All:
  20973. * - Minimum headers in a SIP message
  20974. */
  20975. // Sanity Check functions for requests.
  20976. function rfc3261_8_2_2_1() {
  20977. if (message.s('to').uri.scheme !== 'sip') {
  20978. reply(416);
  20979. return false;
  20980. }
  20981. }
  20982. function rfc3261_16_3_4() {
  20983. if (!message.to_tag) {
  20984. if (message.call_id.substr(0, 5) === ua.configuration.jssip_id) {
  20985. reply(482);
  20986. return false;
  20987. }
  20988. }
  20989. }
  20990. function rfc3261_18_3_request() {
  20991. var len = Utils.str_utf8_length(message.body);
  20992. var contentLength = message.getHeader('content-length');
  20993. if (len < contentLength) {
  20994. reply(400);
  20995. return false;
  20996. }
  20997. }
  20998. function rfc3261_8_2_2_2() {
  20999. var fromTag = message.from_tag;
  21000. var call_id = message.call_id;
  21001. var cseq = message.cseq;
  21002. var tr; // Accept any in-dialog request.
  21003. if (message.to_tag) {
  21004. return;
  21005. } // INVITE request.
  21006. if (message.method === JsSIP_C.INVITE) {
  21007. // If the branch matches the key of any IST then assume it is a retransmission
  21008. // and ignore the INVITE.
  21009. // TODO: we should reply the last response.
  21010. if (ua._transactions.ist[message.via_branch]) {
  21011. return false;
  21012. } // Otherwise check whether it is a merged request.
  21013. else {
  21014. for (var transaction in ua._transactions.ist) {
  21015. if (Object.prototype.hasOwnProperty.call(ua._transactions.ist, transaction)) {
  21016. tr = ua._transactions.ist[transaction];
  21017. if (tr.request.from_tag === fromTag && tr.request.call_id === call_id && tr.request.cseq === cseq) {
  21018. reply(482);
  21019. return false;
  21020. }
  21021. }
  21022. }
  21023. }
  21024. } // Non INVITE request.
  21025. // If the branch matches the key of any NIST then assume it is a retransmission
  21026. // and ignore the request.
  21027. // TODO: we should reply the last response.
  21028. else if (ua._transactions.nist[message.via_branch]) {
  21029. return false;
  21030. } // Otherwise check whether it is a merged request.
  21031. else {
  21032. for (var _transaction in ua._transactions.nist) {
  21033. if (Object.prototype.hasOwnProperty.call(ua._transactions.nist, _transaction)) {
  21034. tr = ua._transactions.nist[_transaction];
  21035. if (tr.request.from_tag === fromTag && tr.request.call_id === call_id && tr.request.cseq === cseq) {
  21036. reply(482);
  21037. return false;
  21038. }
  21039. }
  21040. }
  21041. }
  21042. } // Sanity Check functions for responses.
  21043. function rfc3261_8_1_3_3() {
  21044. if (message.getHeaders('via').length > 1) {
  21045. debug('more than one Via header field present in the response, dropping the response');
  21046. return false;
  21047. }
  21048. }
  21049. function rfc3261_18_3_response() {
  21050. var len = Utils.str_utf8_length(message.body),
  21051. contentLength = message.getHeader('content-length');
  21052. if (len < contentLength) {
  21053. debug('message body length is lower than the value in Content-Length header field, dropping the response');
  21054. return false;
  21055. }
  21056. } // Sanity Check functions for requests and responses.
  21057. function minimumHeaders() {
  21058. var mandatoryHeaders = ['from', 'to', 'call_id', 'cseq', 'via'];
  21059. for (var _i = 0, _mandatoryHeaders = mandatoryHeaders; _i < _mandatoryHeaders.length; _i++) {
  21060. var header = _mandatoryHeaders[_i];
  21061. if (!message.hasHeader(header)) {
  21062. debug("missing mandatory header field : ".concat(header, ", dropping the response"));
  21063. return false;
  21064. }
  21065. }
  21066. } // Reply.
  21067. function reply(status_code) {
  21068. var vias = message.getHeaders('via');
  21069. var to;
  21070. var response = "SIP/2.0 ".concat(status_code, " ").concat(JsSIP_C.REASON_PHRASE[status_code], "\r\n");
  21071. var _iterator4 = _createForOfIteratorHelper(vias),
  21072. _step4;
  21073. try {
  21074. for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {
  21075. var via = _step4.value;
  21076. response += "Via: ".concat(via, "\r\n");
  21077. }
  21078. } catch (err) {
  21079. _iterator4.e(err);
  21080. } finally {
  21081. _iterator4.f();
  21082. }
  21083. to = message.getHeader('To');
  21084. if (!message.to_tag) {
  21085. to += ";tag=".concat(Utils.newTag());
  21086. }
  21087. response += "To: ".concat(to, "\r\n");
  21088. response += "From: ".concat(message.getHeader('From'), "\r\n");
  21089. response += "Call-ID: ".concat(message.call_id, "\r\n");
  21090. response += "CSeq: ".concat(message.cseq, " ").concat(message.method, "\r\n");
  21091. response += '\r\n';
  21092. transport.send(response);
  21093. }
  21094. },{"./Constants":2,"./SIPMessage":19,"./Utils":26,"debug":30}],29:[function(require,module,exports){
  21095. // Copyright Joyent, Inc. and other Node contributors.
  21096. //
  21097. // Permission is hereby granted, free of charge, to any person obtaining a
  21098. // copy of this software and associated documentation files (the
  21099. // "Software"), to deal in the Software without restriction, including
  21100. // without limitation the rights to use, copy, modify, merge, publish,
  21101. // distribute, sublicense, and/or sell copies of the Software, and to permit
  21102. // persons to whom the Software is furnished to do so, subject to the
  21103. // following conditions:
  21104. //
  21105. // The above copyright notice and this permission notice shall be included
  21106. // in all copies or substantial portions of the Software.
  21107. //
  21108. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  21109. // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21110. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
  21111. // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  21112. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  21113. // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  21114. // USE OR OTHER DEALINGS IN THE SOFTWARE.
  21115. var objectCreate = Object.create || objectCreatePolyfill
  21116. var objectKeys = Object.keys || objectKeysPolyfill
  21117. var bind = Function.prototype.bind || functionBindPolyfill
  21118. function EventEmitter() {
  21119. if (!this._events || !Object.prototype.hasOwnProperty.call(this, '_events')) {
  21120. this._events = objectCreate(null);
  21121. this._eventsCount = 0;
  21122. }
  21123. this._maxListeners = this._maxListeners || undefined;
  21124. }
  21125. module.exports = EventEmitter;
  21126. // Backwards-compat with node 0.10.x
  21127. EventEmitter.EventEmitter = EventEmitter;
  21128. EventEmitter.prototype._events = undefined;
  21129. EventEmitter.prototype._maxListeners = undefined;
  21130. // By default EventEmitters will print a warning if more than 10 listeners are
  21131. // added to it. This is a useful default which helps finding memory leaks.
  21132. var defaultMaxListeners = 10;
  21133. var hasDefineProperty;
  21134. try {
  21135. var o = {};
  21136. if (Object.defineProperty) Object.defineProperty(o, 'x', { value: 0 });
  21137. hasDefineProperty = o.x === 0;
  21138. } catch (err) { hasDefineProperty = false }
  21139. if (hasDefineProperty) {
  21140. Object.defineProperty(EventEmitter, 'defaultMaxListeners', {
  21141. enumerable: true,
  21142. get: function() {
  21143. return defaultMaxListeners;
  21144. },
  21145. set: function(arg) {
  21146. // check whether the input is a positive number (whose value is zero or
  21147. // greater and not a NaN).
  21148. if (typeof arg !== 'number' || arg < 0 || arg !== arg)
  21149. throw new TypeError('"defaultMaxListeners" must be a positive number');
  21150. defaultMaxListeners = arg;
  21151. }
  21152. });
  21153. } else {
  21154. EventEmitter.defaultMaxListeners = defaultMaxListeners;
  21155. }
  21156. // Obviously not all Emitters should be limited to 10. This function allows
  21157. // that to be increased. Set to zero for unlimited.
  21158. EventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {
  21159. if (typeof n !== 'number' || n < 0 || isNaN(n))
  21160. throw new TypeError('"n" argument must be a positive number');
  21161. this._maxListeners = n;
  21162. return this;
  21163. };
  21164. function $getMaxListeners(that) {
  21165. if (that._maxListeners === undefined)
  21166. return EventEmitter.defaultMaxListeners;
  21167. return that._maxListeners;
  21168. }
  21169. EventEmitter.prototype.getMaxListeners = function getMaxListeners() {
  21170. return $getMaxListeners(this);
  21171. };
  21172. // These standalone emit* functions are used to optimize calling of event
  21173. // handlers for fast cases because emit() itself often has a variable number of
  21174. // arguments and can be deoptimized because of that. These functions always have
  21175. // the same number of arguments and thus do not get deoptimized, so the code
  21176. // inside them can execute faster.
  21177. function emitNone(handler, isFn, self) {
  21178. if (isFn)
  21179. handler.call(self);
  21180. else {
  21181. var len = handler.length;
  21182. var listeners = arrayClone(handler, len);
  21183. for (var i = 0; i < len; ++i)
  21184. listeners[i].call(self);
  21185. }
  21186. }
  21187. function emitOne(handler, isFn, self, arg1) {
  21188. if (isFn)
  21189. handler.call(self, arg1);
  21190. else {
  21191. var len = handler.length;
  21192. var listeners = arrayClone(handler, len);
  21193. for (var i = 0; i < len; ++i)
  21194. listeners[i].call(self, arg1);
  21195. }
  21196. }
  21197. function emitTwo(handler, isFn, self, arg1, arg2) {
  21198. if (isFn)
  21199. handler.call(self, arg1, arg2);
  21200. else {
  21201. var len = handler.length;
  21202. var listeners = arrayClone(handler, len);
  21203. for (var i = 0; i < len; ++i)
  21204. listeners[i].call(self, arg1, arg2);
  21205. }
  21206. }
  21207. function emitThree(handler, isFn, self, arg1, arg2, arg3) {
  21208. if (isFn)
  21209. handler.call(self, arg1, arg2, arg3);
  21210. else {
  21211. var len = handler.length;
  21212. var listeners = arrayClone(handler, len);
  21213. for (var i = 0; i < len; ++i)
  21214. listeners[i].call(self, arg1, arg2, arg3);
  21215. }
  21216. }
  21217. function emitMany(handler, isFn, self, args) {
  21218. if (isFn)
  21219. handler.apply(self, args);
  21220. else {
  21221. var len = handler.length;
  21222. var listeners = arrayClone(handler, len);
  21223. for (var i = 0; i < len; ++i)
  21224. listeners[i].apply(self, args);
  21225. }
  21226. }
  21227. EventEmitter.prototype.emit = function emit(type) {
  21228. var er, handler, len, args, i, events;
  21229. var doError = (type === 'error');
  21230. events = this._events;
  21231. if (events)
  21232. doError = (doError && events.error == null);
  21233. else if (!doError)
  21234. return false;
  21235. // If there is no 'error' event listener then throw.
  21236. if (doError) {
  21237. if (arguments.length > 1)
  21238. er = arguments[1];
  21239. if (er instanceof Error) {
  21240. throw er; // Unhandled 'error' event
  21241. } else {
  21242. // At least give some kind of context to the user
  21243. var err = new Error('Unhandled "error" event. (' + er + ')');
  21244. err.context = er;
  21245. throw err;
  21246. }
  21247. return false;
  21248. }
  21249. handler = events[type];
  21250. if (!handler)
  21251. return false;
  21252. var isFn = typeof handler === 'function';
  21253. len = arguments.length;
  21254. switch (len) {
  21255. // fast cases
  21256. case 1:
  21257. emitNone(handler, isFn, this);
  21258. break;
  21259. case 2:
  21260. emitOne(handler, isFn, this, arguments[1]);
  21261. break;
  21262. case 3:
  21263. emitTwo(handler, isFn, this, arguments[1], arguments[2]);
  21264. break;
  21265. case 4:
  21266. emitThree(handler, isFn, this, arguments[1], arguments[2], arguments[3]);
  21267. break;
  21268. // slower
  21269. default:
  21270. args = new Array(len - 1);
  21271. for (i = 1; i < len; i++)
  21272. args[i - 1] = arguments[i];
  21273. emitMany(handler, isFn, this, args);
  21274. }
  21275. return true;
  21276. };
  21277. function _addListener(target, type, listener, prepend) {
  21278. var m;
  21279. var events;
  21280. var existing;
  21281. if (typeof listener !== 'function')
  21282. throw new TypeError('"listener" argument must be a function');
  21283. events = target._events;
  21284. if (!events) {
  21285. events = target._events = objectCreate(null);
  21286. target._eventsCount = 0;
  21287. } else {
  21288. // To avoid recursion in the case that type === "newListener"! Before
  21289. // adding it to the listeners, first emit "newListener".
  21290. if (events.newListener) {
  21291. target.emit('newListener', type,
  21292. listener.listener ? listener.listener : listener);
  21293. // Re-assign `events` because a newListener handler could have caused the
  21294. // this._events to be assigned to a new object
  21295. events = target._events;
  21296. }
  21297. existing = events[type];
  21298. }
  21299. if (!existing) {
  21300. // Optimize the case of one listener. Don't need the extra array object.
  21301. existing = events[type] = listener;
  21302. ++target._eventsCount;
  21303. } else {
  21304. if (typeof existing === 'function') {
  21305. // Adding the second element, need to change to array.
  21306. existing = events[type] =
  21307. prepend ? [listener, existing] : [existing, listener];
  21308. } else {
  21309. // If we've already got an array, just append.
  21310. if (prepend) {
  21311. existing.unshift(listener);
  21312. } else {
  21313. existing.push(listener);
  21314. }
  21315. }
  21316. // Check for listener leak
  21317. if (!existing.warned) {
  21318. m = $getMaxListeners(target);
  21319. if (m && m > 0 && existing.length > m) {
  21320. existing.warned = true;
  21321. var w = new Error('Possible EventEmitter memory leak detected. ' +
  21322. existing.length + ' "' + String(type) + '" listeners ' +
  21323. 'added. Use emitter.setMaxListeners() to ' +
  21324. 'increase limit.');
  21325. w.name = 'MaxListenersExceededWarning';
  21326. w.emitter = target;
  21327. w.type = type;
  21328. w.count = existing.length;
  21329. if (typeof console === 'object' && console.warn) {
  21330. console.warn('%s: %s', w.name, w.message);
  21331. }
  21332. }
  21333. }
  21334. }
  21335. return target;
  21336. }
  21337. EventEmitter.prototype.addListener = function addListener(type, listener) {
  21338. return _addListener(this, type, listener, false);
  21339. };
  21340. EventEmitter.prototype.on = EventEmitter.prototype.addListener;
  21341. EventEmitter.prototype.prependListener =
  21342. function prependListener(type, listener) {
  21343. return _addListener(this, type, listener, true);
  21344. };
  21345. function onceWrapper() {
  21346. if (!this.fired) {
  21347. this.target.removeListener(this.type, this.wrapFn);
  21348. this.fired = true;
  21349. switch (arguments.length) {
  21350. case 0:
  21351. return this.listener.call(this.target);
  21352. case 1:
  21353. return this.listener.call(this.target, arguments[0]);
  21354. case 2:
  21355. return this.listener.call(this.target, arguments[0], arguments[1]);
  21356. case 3:
  21357. return this.listener.call(this.target, arguments[0], arguments[1],
  21358. arguments[2]);
  21359. default:
  21360. var args = new Array(arguments.length);
  21361. for (var i = 0; i < args.length; ++i)
  21362. args[i] = arguments[i];
  21363. this.listener.apply(this.target, args);
  21364. }
  21365. }
  21366. }
  21367. function _onceWrap(target, type, listener) {
  21368. var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };
  21369. var wrapped = bind.call(onceWrapper, state);
  21370. wrapped.listener = listener;
  21371. state.wrapFn = wrapped;
  21372. return wrapped;
  21373. }
  21374. EventEmitter.prototype.once = function once(type, listener) {
  21375. if (typeof listener !== 'function')
  21376. throw new TypeError('"listener" argument must be a function');
  21377. this.on(type, _onceWrap(this, type, listener));
  21378. return this;
  21379. };
  21380. EventEmitter.prototype.prependOnceListener =
  21381. function prependOnceListener(type, listener) {
  21382. if (typeof listener !== 'function')
  21383. throw new TypeError('"listener" argument must be a function');
  21384. this.prependListener(type, _onceWrap(this, type, listener));
  21385. return this;
  21386. };
  21387. // Emits a 'removeListener' event if and only if the listener was removed.
  21388. EventEmitter.prototype.removeListener =
  21389. function removeListener(type, listener) {
  21390. var list, events, position, i, originalListener;
  21391. if (typeof listener !== 'function')
  21392. throw new TypeError('"listener" argument must be a function');
  21393. events = this._events;
  21394. if (!events)
  21395. return this;
  21396. list = events[type];
  21397. if (!list)
  21398. return this;
  21399. if (list === listener || list.listener === listener) {
  21400. if (--this._eventsCount === 0)
  21401. this._events = objectCreate(null);
  21402. else {
  21403. delete events[type];
  21404. if (events.removeListener)
  21405. this.emit('removeListener', type, list.listener || listener);
  21406. }
  21407. } else if (typeof list !== 'function') {
  21408. position = -1;
  21409. for (i = list.length - 1; i >= 0; i--) {
  21410. if (list[i] === listener || list[i].listener === listener) {
  21411. originalListener = list[i].listener;
  21412. position = i;
  21413. break;
  21414. }
  21415. }
  21416. if (position < 0)
  21417. return this;
  21418. if (position === 0)
  21419. list.shift();
  21420. else
  21421. spliceOne(list, position);
  21422. if (list.length === 1)
  21423. events[type] = list[0];
  21424. if (events.removeListener)
  21425. this.emit('removeListener', type, originalListener || listener);
  21426. }
  21427. return this;
  21428. };
  21429. EventEmitter.prototype.removeAllListeners =
  21430. function removeAllListeners(type) {
  21431. var listeners, events, i;
  21432. events = this._events;
  21433. if (!events)
  21434. return this;
  21435. // not listening for removeListener, no need to emit
  21436. if (!events.removeListener) {
  21437. if (arguments.length === 0) {
  21438. this._events = objectCreate(null);
  21439. this._eventsCount = 0;
  21440. } else if (events[type]) {
  21441. if (--this._eventsCount === 0)
  21442. this._events = objectCreate(null);
  21443. else
  21444. delete events[type];
  21445. }
  21446. return this;
  21447. }
  21448. // emit removeListener for all listeners on all events
  21449. if (arguments.length === 0) {
  21450. var keys = objectKeys(events);
  21451. var key;
  21452. for (i = 0; i < keys.length; ++i) {
  21453. key = keys[i];
  21454. if (key === 'removeListener') continue;
  21455. this.removeAllListeners(key);
  21456. }
  21457. this.removeAllListeners('removeListener');
  21458. this._events = objectCreate(null);
  21459. this._eventsCount = 0;
  21460. return this;
  21461. }
  21462. listeners = events[type];
  21463. if (typeof listeners === 'function') {
  21464. this.removeListener(type, listeners);
  21465. } else if (listeners) {
  21466. // LIFO order
  21467. for (i = listeners.length - 1; i >= 0; i--) {
  21468. this.removeListener(type, listeners[i]);
  21469. }
  21470. }
  21471. return this;
  21472. };
  21473. function _listeners(target, type, unwrap) {
  21474. var events = target._events;
  21475. if (!events)
  21476. return [];
  21477. var evlistener = events[type];
  21478. if (!evlistener)
  21479. return [];
  21480. if (typeof evlistener === 'function')
  21481. return unwrap ? [evlistener.listener || evlistener] : [evlistener];
  21482. return unwrap ? unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);
  21483. }
  21484. EventEmitter.prototype.listeners = function listeners(type) {
  21485. return _listeners(this, type, true);
  21486. };
  21487. EventEmitter.prototype.rawListeners = function rawListeners(type) {
  21488. return _listeners(this, type, false);
  21489. };
  21490. EventEmitter.listenerCount = function(emitter, type) {
  21491. if (typeof emitter.listenerCount === 'function') {
  21492. return emitter.listenerCount(type);
  21493. } else {
  21494. return listenerCount.call(emitter, type);
  21495. }
  21496. };
  21497. EventEmitter.prototype.listenerCount = listenerCount;
  21498. function listenerCount(type) {
  21499. var events = this._events;
  21500. if (events) {
  21501. var evlistener = events[type];
  21502. if (typeof evlistener === 'function') {
  21503. return 1;
  21504. } else if (evlistener) {
  21505. return evlistener.length;
  21506. }
  21507. }
  21508. return 0;
  21509. }
  21510. EventEmitter.prototype.eventNames = function eventNames() {
  21511. return this._eventsCount > 0 ? Reflect.ownKeys(this._events) : [];
  21512. };
  21513. // About 1.5x faster than the two-arg version of Array#splice().
  21514. function spliceOne(list, index) {
  21515. for (var i = index, k = i + 1, n = list.length; k < n; i += 1, k += 1)
  21516. list[i] = list[k];
  21517. list.pop();
  21518. }
  21519. function arrayClone(arr, n) {
  21520. var copy = new Array(n);
  21521. for (var i = 0; i < n; ++i)
  21522. copy[i] = arr[i];
  21523. return copy;
  21524. }
  21525. function unwrapListeners(arr) {
  21526. var ret = new Array(arr.length);
  21527. for (var i = 0; i < ret.length; ++i) {
  21528. ret[i] = arr[i].listener || arr[i];
  21529. }
  21530. return ret;
  21531. }
  21532. function objectCreatePolyfill(proto) {
  21533. var F = function() {};
  21534. F.prototype = proto;
  21535. return new F;
  21536. }
  21537. function objectKeysPolyfill(obj) {
  21538. var keys = [];
  21539. for (var k in obj) if (Object.prototype.hasOwnProperty.call(obj, k)) {
  21540. keys.push(k);
  21541. }
  21542. return k;
  21543. }
  21544. function functionBindPolyfill(context) {
  21545. var fn = this;
  21546. return function () {
  21547. return fn.apply(context, arguments);
  21548. };
  21549. }
  21550. },{}],30:[function(require,module,exports){
  21551. (function (process){
  21552. /* eslint-env browser */
  21553. /**
  21554. * This is the web browser implementation of `debug()`.
  21555. */
  21556. exports.log = log;
  21557. exports.formatArgs = formatArgs;
  21558. exports.save = save;
  21559. exports.load = load;
  21560. exports.useColors = useColors;
  21561. exports.storage = localstorage();
  21562. /**
  21563. * Colors.
  21564. */
  21565. exports.colors = [
  21566. '#0000CC',
  21567. '#0000FF',
  21568. '#0033CC',
  21569. '#0033FF',
  21570. '#0066CC',
  21571. '#0066FF',
  21572. '#0099CC',
  21573. '#0099FF',
  21574. '#00CC00',
  21575. '#00CC33',
  21576. '#00CC66',
  21577. '#00CC99',
  21578. '#00CCCC',
  21579. '#00CCFF',
  21580. '#3300CC',
  21581. '#3300FF',
  21582. '#3333CC',
  21583. '#3333FF',
  21584. '#3366CC',
  21585. '#3366FF',
  21586. '#3399CC',
  21587. '#3399FF',
  21588. '#33CC00',
  21589. '#33CC33',
  21590. '#33CC66',
  21591. '#33CC99',
  21592. '#33CCCC',
  21593. '#33CCFF',
  21594. '#6600CC',
  21595. '#6600FF',
  21596. '#6633CC',
  21597. '#6633FF',
  21598. '#66CC00',
  21599. '#66CC33',
  21600. '#9900CC',
  21601. '#9900FF',
  21602. '#9933CC',
  21603. '#9933FF',
  21604. '#99CC00',
  21605. '#99CC33',
  21606. '#CC0000',
  21607. '#CC0033',
  21608. '#CC0066',
  21609. '#CC0099',
  21610. '#CC00CC',
  21611. '#CC00FF',
  21612. '#CC3300',
  21613. '#CC3333',
  21614. '#CC3366',
  21615. '#CC3399',
  21616. '#CC33CC',
  21617. '#CC33FF',
  21618. '#CC6600',
  21619. '#CC6633',
  21620. '#CC9900',
  21621. '#CC9933',
  21622. '#CCCC00',
  21623. '#CCCC33',
  21624. '#FF0000',
  21625. '#FF0033',
  21626. '#FF0066',
  21627. '#FF0099',
  21628. '#FF00CC',
  21629. '#FF00FF',
  21630. '#FF3300',
  21631. '#FF3333',
  21632. '#FF3366',
  21633. '#FF3399',
  21634. '#FF33CC',
  21635. '#FF33FF',
  21636. '#FF6600',
  21637. '#FF6633',
  21638. '#FF9900',
  21639. '#FF9933',
  21640. '#FFCC00',
  21641. '#FFCC33'
  21642. ];
  21643. /**
  21644. * Currently only WebKit-based Web Inspectors, Firefox >= v31,
  21645. * and the Firebug extension (any Firefox version) are known
  21646. * to support "%c" CSS customizations.
  21647. *
  21648. * TODO: add a `localStorage` variable to explicitly enable/disable colors
  21649. */
  21650. // eslint-disable-next-line complexity
  21651. function useColors() {
  21652. // NB: In an Electron preload script, document will be defined but not fully
  21653. // initialized. Since we know we're in Chrome, we'll just detect this case
  21654. // explicitly
  21655. if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
  21656. return true;
  21657. }
  21658. // Internet Explorer and Edge do not support colors.
  21659. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
  21660. return false;
  21661. }
  21662. // Is webkit? http://stackoverflow.com/a/16459606/376773
  21663. // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
  21664. return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
  21665. // Is firebug? http://stackoverflow.com/a/398120/376773
  21666. (typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
  21667. // Is firefox >= v31?
  21668. // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
  21669. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31) ||
  21670. // Double check webkit in userAgent just in case we are in a worker
  21671. (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
  21672. }
  21673. /**
  21674. * Colorize log arguments if enabled.
  21675. *
  21676. * @api public
  21677. */
  21678. function formatArgs(args) {
  21679. args[0] = (this.useColors ? '%c' : '') +
  21680. this.namespace +
  21681. (this.useColors ? ' %c' : ' ') +
  21682. args[0] +
  21683. (this.useColors ? '%c ' : ' ') +
  21684. '+' + module.exports.humanize(this.diff);
  21685. if (!this.useColors) {
  21686. return;
  21687. }
  21688. const c = 'color: ' + this.color;
  21689. args.splice(1, 0, c, 'color: inherit');
  21690. // The final "%c" is somewhat tricky, because there could be other
  21691. // arguments passed either before or after the %c, so we need to
  21692. // figure out the correct index to insert the CSS into
  21693. let index = 0;
  21694. let lastC = 0;
  21695. args[0].replace(/%[a-zA-Z%]/g, match => {
  21696. if (match === '%%') {
  21697. return;
  21698. }
  21699. index++;
  21700. if (match === '%c') {
  21701. // We only are interested in the *last* %c
  21702. // (the user may have provided their own)
  21703. lastC = index;
  21704. }
  21705. });
  21706. args.splice(lastC, 0, c);
  21707. }
  21708. /**
  21709. * Invokes `console.log()` when available.
  21710. * No-op when `console.log` is not a "function".
  21711. *
  21712. * @api public
  21713. */
  21714. function log(...args) {
  21715. // This hackery is required for IE8/9, where
  21716. // the `console.log` function doesn't have 'apply'
  21717. return typeof console === 'object' &&
  21718. console.log &&
  21719. console.log(...args);
  21720. }
  21721. /**
  21722. * Save `namespaces`.
  21723. *
  21724. * @param {String} namespaces
  21725. * @api private
  21726. */
  21727. function save(namespaces) {
  21728. try {
  21729. if (namespaces) {
  21730. exports.storage.setItem('debug', namespaces);
  21731. } else {
  21732. exports.storage.removeItem('debug');
  21733. }
  21734. } catch (error) {
  21735. // Swallow
  21736. // XXX (@Qix-) should we be logging these?
  21737. }
  21738. }
  21739. /**
  21740. * Load `namespaces`.
  21741. *
  21742. * @return {String} returns the previously persisted debug modes
  21743. * @api private
  21744. */
  21745. function load() {
  21746. let r;
  21747. try {
  21748. r = exports.storage.getItem('debug');
  21749. } catch (error) {
  21750. // Swallow
  21751. // XXX (@Qix-) should we be logging these?
  21752. }
  21753. // If debug isn't set in LS, and we're in Electron, try to load $DEBUG
  21754. if (!r && typeof process !== 'undefined' && 'env' in process) {
  21755. r = process.env.DEBUG;
  21756. }
  21757. return r;
  21758. }
  21759. /**
  21760. * Localstorage attempts to return the localstorage.
  21761. *
  21762. * This is necessary because safari throws
  21763. * when a user disables cookies/localstorage
  21764. * and you attempt to access it.
  21765. *
  21766. * @return {LocalStorage}
  21767. * @api private
  21768. */
  21769. function localstorage() {
  21770. try {
  21771. // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
  21772. // The Browser also has localStorage in the global context.
  21773. return localStorage;
  21774. } catch (error) {
  21775. // Swallow
  21776. // XXX (@Qix-) should we be logging these?
  21777. }
  21778. }
  21779. module.exports = require('./common')(exports);
  21780. const {formatters} = module.exports;
  21781. /**
  21782. * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
  21783. */
  21784. formatters.j = function (v) {
  21785. try {
  21786. return JSON.stringify(v);
  21787. } catch (error) {
  21788. return '[UnexpectedJSONParseError]: ' + error.message;
  21789. }
  21790. };
  21791. }).call(this,require('_process'))
  21792. },{"./common":31,"_process":33}],31:[function(require,module,exports){
  21793. /**
  21794. * This is the common logic for both the Node.js and web browser
  21795. * implementations of `debug()`.
  21796. */
  21797. function setup(env) {
  21798. createDebug.debug = createDebug;
  21799. createDebug.default = createDebug;
  21800. createDebug.coerce = coerce;
  21801. createDebug.disable = disable;
  21802. createDebug.enable = enable;
  21803. createDebug.enabled = enabled;
  21804. createDebug.humanize = require('ms');
  21805. Object.keys(env).forEach(key => {
  21806. createDebug[key] = env[key];
  21807. });
  21808. /**
  21809. * Active `debug` instances.
  21810. */
  21811. createDebug.instances = [];
  21812. /**
  21813. * The currently active debug mode names, and names to skip.
  21814. */
  21815. createDebug.names = [];
  21816. createDebug.skips = [];
  21817. /**
  21818. * Map of special "%n" handling functions, for the debug "format" argument.
  21819. *
  21820. * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
  21821. */
  21822. createDebug.formatters = {};
  21823. /**
  21824. * Selects a color for a debug namespace
  21825. * @param {String} namespace The namespace string for the for the debug instance to be colored
  21826. * @return {Number|String} An ANSI color code for the given namespace
  21827. * @api private
  21828. */
  21829. function selectColor(namespace) {
  21830. let hash = 0;
  21831. for (let i = 0; i < namespace.length; i++) {
  21832. hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
  21833. hash |= 0; // Convert to 32bit integer
  21834. }
  21835. return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
  21836. }
  21837. createDebug.selectColor = selectColor;
  21838. /**
  21839. * Create a debugger with the given `namespace`.
  21840. *
  21841. * @param {String} namespace
  21842. * @return {Function}
  21843. * @api public
  21844. */
  21845. function createDebug(namespace) {
  21846. let prevTime;
  21847. function debug(...args) {
  21848. // Disabled?
  21849. if (!debug.enabled) {
  21850. return;
  21851. }
  21852. const self = debug;
  21853. // Set `diff` timestamp
  21854. const curr = Number(new Date());
  21855. const ms = curr - (prevTime || curr);
  21856. self.diff = ms;
  21857. self.prev = prevTime;
  21858. self.curr = curr;
  21859. prevTime = curr;
  21860. args[0] = createDebug.coerce(args[0]);
  21861. if (typeof args[0] !== 'string') {
  21862. // Anything else let's inspect with %O
  21863. args.unshift('%O');
  21864. }
  21865. // Apply any `formatters` transformations
  21866. let index = 0;
  21867. args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
  21868. // If we encounter an escaped % then don't increase the array index
  21869. if (match === '%%') {
  21870. return match;
  21871. }
  21872. index++;
  21873. const formatter = createDebug.formatters[format];
  21874. if (typeof formatter === 'function') {
  21875. const val = args[index];
  21876. match = formatter.call(self, val);
  21877. // Now we need to remove `args[index]` since it's inlined in the `format`
  21878. args.splice(index, 1);
  21879. index--;
  21880. }
  21881. return match;
  21882. });
  21883. // Apply env-specific formatting (colors, etc.)
  21884. createDebug.formatArgs.call(self, args);
  21885. const logFn = self.log || createDebug.log;
  21886. logFn.apply(self, args);
  21887. }
  21888. debug.namespace = namespace;
  21889. debug.enabled = createDebug.enabled(namespace);
  21890. debug.useColors = createDebug.useColors();
  21891. debug.color = selectColor(namespace);
  21892. debug.destroy = destroy;
  21893. debug.extend = extend;
  21894. // Debug.formatArgs = formatArgs;
  21895. // debug.rawLog = rawLog;
  21896. // env-specific initialization logic for debug instances
  21897. if (typeof createDebug.init === 'function') {
  21898. createDebug.init(debug);
  21899. }
  21900. createDebug.instances.push(debug);
  21901. return debug;
  21902. }
  21903. function destroy() {
  21904. const index = createDebug.instances.indexOf(this);
  21905. if (index !== -1) {
  21906. createDebug.instances.splice(index, 1);
  21907. return true;
  21908. }
  21909. return false;
  21910. }
  21911. function extend(namespace, delimiter) {
  21912. const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
  21913. newDebug.log = this.log;
  21914. return newDebug;
  21915. }
  21916. /**
  21917. * Enables a debug mode by namespaces. This can include modes
  21918. * separated by a colon and wildcards.
  21919. *
  21920. * @param {String} namespaces
  21921. * @api public
  21922. */
  21923. function enable(namespaces) {
  21924. createDebug.save(namespaces);
  21925. createDebug.names = [];
  21926. createDebug.skips = [];
  21927. let i;
  21928. const split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/);
  21929. const len = split.length;
  21930. for (i = 0; i < len; i++) {
  21931. if (!split[i]) {
  21932. // ignore empty strings
  21933. continue;
  21934. }
  21935. namespaces = split[i].replace(/\*/g, '.*?');
  21936. if (namespaces[0] === '-') {
  21937. createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
  21938. } else {
  21939. createDebug.names.push(new RegExp('^' + namespaces + '$'));
  21940. }
  21941. }
  21942. for (i = 0; i < createDebug.instances.length; i++) {
  21943. const instance = createDebug.instances[i];
  21944. instance.enabled = createDebug.enabled(instance.namespace);
  21945. }
  21946. }
  21947. /**
  21948. * Disable debug output.
  21949. *
  21950. * @return {String} namespaces
  21951. * @api public
  21952. */
  21953. function disable() {
  21954. const namespaces = [
  21955. ...createDebug.names.map(toNamespace),
  21956. ...createDebug.skips.map(toNamespace).map(namespace => '-' + namespace)
  21957. ].join(',');
  21958. createDebug.enable('');
  21959. return namespaces;
  21960. }
  21961. /**
  21962. * Returns true if the given mode name is enabled, false otherwise.
  21963. *
  21964. * @param {String} name
  21965. * @return {Boolean}
  21966. * @api public
  21967. */
  21968. function enabled(name) {
  21969. if (name[name.length - 1] === '*') {
  21970. return true;
  21971. }
  21972. let i;
  21973. let len;
  21974. for (i = 0, len = createDebug.skips.length; i < len; i++) {
  21975. if (createDebug.skips[i].test(name)) {
  21976. return false;
  21977. }
  21978. }
  21979. for (i = 0, len = createDebug.names.length; i < len; i++) {
  21980. if (createDebug.names[i].test(name)) {
  21981. return true;
  21982. }
  21983. }
  21984. return false;
  21985. }
  21986. /**
  21987. * Convert regexp to namespace
  21988. *
  21989. * @param {RegExp} regxep
  21990. * @return {String} namespace
  21991. * @api private
  21992. */
  21993. function toNamespace(regexp) {
  21994. return regexp.toString()
  21995. .substring(2, regexp.toString().length - 2)
  21996. .replace(/\.\*\?$/, '*');
  21997. }
  21998. /**
  21999. * Coerce `val`.
  22000. *
  22001. * @param {Mixed} val
  22002. * @return {Mixed}
  22003. * @api private
  22004. */
  22005. function coerce(val) {
  22006. if (val instanceof Error) {
  22007. return val.stack || val.message;
  22008. }
  22009. return val;
  22010. }
  22011. createDebug.enable(createDebug.load());
  22012. return createDebug;
  22013. }
  22014. module.exports = setup;
  22015. },{"ms":32}],32:[function(require,module,exports){
  22016. /**
  22017. * Helpers.
  22018. */
  22019. var s = 1000;
  22020. var m = s * 60;
  22021. var h = m * 60;
  22022. var d = h * 24;
  22023. var w = d * 7;
  22024. var y = d * 365.25;
  22025. /**
  22026. * Parse or format the given `val`.
  22027. *
  22028. * Options:
  22029. *
  22030. * - `long` verbose formatting [false]
  22031. *
  22032. * @param {String|Number} val
  22033. * @param {Object} [options]
  22034. * @throws {Error} throw an error if val is not a non-empty string or a number
  22035. * @return {String|Number}
  22036. * @api public
  22037. */
  22038. module.exports = function(val, options) {
  22039. options = options || {};
  22040. var type = typeof val;
  22041. if (type === 'string' && val.length > 0) {
  22042. return parse(val);
  22043. } else if (type === 'number' && isFinite(val)) {
  22044. return options.long ? fmtLong(val) : fmtShort(val);
  22045. }
  22046. throw new Error(
  22047. 'val is not a non-empty string or a valid number. val=' +
  22048. JSON.stringify(val)
  22049. );
  22050. };
  22051. /**
  22052. * Parse the given `str` and return milliseconds.
  22053. *
  22054. * @param {String} str
  22055. * @return {Number}
  22056. * @api private
  22057. */
  22058. function parse(str) {
  22059. str = String(str);
  22060. if (str.length > 100) {
  22061. return;
  22062. }
  22063. var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
  22064. str
  22065. );
  22066. if (!match) {
  22067. return;
  22068. }
  22069. var n = parseFloat(match[1]);
  22070. var type = (match[2] || 'ms').toLowerCase();
  22071. switch (type) {
  22072. case 'years':
  22073. case 'year':
  22074. case 'yrs':
  22075. case 'yr':
  22076. case 'y':
  22077. return n * y;
  22078. case 'weeks':
  22079. case 'week':
  22080. case 'w':
  22081. return n * w;
  22082. case 'days':
  22083. case 'day':
  22084. case 'd':
  22085. return n * d;
  22086. case 'hours':
  22087. case 'hour':
  22088. case 'hrs':
  22089. case 'hr':
  22090. case 'h':
  22091. return n * h;
  22092. case 'minutes':
  22093. case 'minute':
  22094. case 'mins':
  22095. case 'min':
  22096. case 'm':
  22097. return n * m;
  22098. case 'seconds':
  22099. case 'second':
  22100. case 'secs':
  22101. case 'sec':
  22102. case 's':
  22103. return n * s;
  22104. case 'milliseconds':
  22105. case 'millisecond':
  22106. case 'msecs':
  22107. case 'msec':
  22108. case 'ms':
  22109. return n;
  22110. default:
  22111. return undefined;
  22112. }
  22113. }
  22114. /**
  22115. * Short format for `ms`.
  22116. *
  22117. * @param {Number} ms
  22118. * @return {String}
  22119. * @api private
  22120. */
  22121. function fmtShort(ms) {
  22122. var msAbs = Math.abs(ms);
  22123. if (msAbs >= d) {
  22124. return Math.round(ms / d) + 'd';
  22125. }
  22126. if (msAbs >= h) {
  22127. return Math.round(ms / h) + 'h';
  22128. }
  22129. if (msAbs >= m) {
  22130. return Math.round(ms / m) + 'm';
  22131. }
  22132. if (msAbs >= s) {
  22133. return Math.round(ms / s) + 's';
  22134. }
  22135. return ms + 'ms';
  22136. }
  22137. /**
  22138. * Long format for `ms`.
  22139. *
  22140. * @param {Number} ms
  22141. * @return {String}
  22142. * @api private
  22143. */
  22144. function fmtLong(ms) {
  22145. var msAbs = Math.abs(ms);
  22146. if (msAbs >= d) {
  22147. return plural(ms, msAbs, d, 'day');
  22148. }
  22149. if (msAbs >= h) {
  22150. return plural(ms, msAbs, h, 'hour');
  22151. }
  22152. if (msAbs >= m) {
  22153. return plural(ms, msAbs, m, 'minute');
  22154. }
  22155. if (msAbs >= s) {
  22156. return plural(ms, msAbs, s, 'second');
  22157. }
  22158. return ms + ' ms';
  22159. }
  22160. /**
  22161. * Pluralization helper.
  22162. */
  22163. function plural(ms, msAbs, n, name) {
  22164. var isPlural = msAbs >= n * 1.5;
  22165. return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
  22166. }
  22167. },{}],33:[function(require,module,exports){
  22168. // shim for using process in browser
  22169. var process = module.exports = {};
  22170. // cached from whatever global is present so that test runners that stub it
  22171. // don't break things. But we need to wrap it in a try catch in case it is
  22172. // wrapped in strict mode code which doesn't define any globals. It's inside a
  22173. // function because try/catches deoptimize in certain engines.
  22174. var cachedSetTimeout;
  22175. var cachedClearTimeout;
  22176. function defaultSetTimout() {
  22177. throw new Error('setTimeout has not been defined');
  22178. }
  22179. function defaultClearTimeout () {
  22180. throw new Error('clearTimeout has not been defined');
  22181. }
  22182. (function () {
  22183. try {
  22184. if (typeof setTimeout === 'function') {
  22185. cachedSetTimeout = setTimeout;
  22186. } else {
  22187. cachedSetTimeout = defaultSetTimout;
  22188. }
  22189. } catch (e) {
  22190. cachedSetTimeout = defaultSetTimout;
  22191. }
  22192. try {
  22193. if (typeof clearTimeout === 'function') {
  22194. cachedClearTimeout = clearTimeout;
  22195. } else {
  22196. cachedClearTimeout = defaultClearTimeout;
  22197. }
  22198. } catch (e) {
  22199. cachedClearTimeout = defaultClearTimeout;
  22200. }
  22201. } ())
  22202. function runTimeout(fun) {
  22203. if (cachedSetTimeout === setTimeout) {
  22204. //normal enviroments in sane situations
  22205. return setTimeout(fun, 0);
  22206. }
  22207. // if setTimeout wasn't available but was latter defined
  22208. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  22209. cachedSetTimeout = setTimeout;
  22210. return setTimeout(fun, 0);
  22211. }
  22212. try {
  22213. // when when somebody has screwed with setTimeout but no I.E. maddness
  22214. return cachedSetTimeout(fun, 0);
  22215. } catch(e){
  22216. try {
  22217. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  22218. return cachedSetTimeout.call(null, fun, 0);
  22219. } catch(e){
  22220. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error
  22221. return cachedSetTimeout.call(this, fun, 0);
  22222. }
  22223. }
  22224. }
  22225. function runClearTimeout(marker) {
  22226. if (cachedClearTimeout === clearTimeout) {
  22227. //normal enviroments in sane situations
  22228. return clearTimeout(marker);
  22229. }
  22230. // if clearTimeout wasn't available but was latter defined
  22231. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  22232. cachedClearTimeout = clearTimeout;
  22233. return clearTimeout(marker);
  22234. }
  22235. try {
  22236. // when when somebody has screwed with setTimeout but no I.E. maddness
  22237. return cachedClearTimeout(marker);
  22238. } catch (e){
  22239. try {
  22240. // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally
  22241. return cachedClearTimeout.call(null, marker);
  22242. } catch (e){
  22243. // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error.
  22244. // Some versions of I.E. have different rules for clearTimeout vs setTimeout
  22245. return cachedClearTimeout.call(this, marker);
  22246. }
  22247. }
  22248. }
  22249. var queue = [];
  22250. var draining = false;
  22251. var currentQueue;
  22252. var queueIndex = -1;
  22253. function cleanUpNextTick() {
  22254. if (!draining || !currentQueue) {
  22255. return;
  22256. }
  22257. draining = false;
  22258. if (currentQueue.length) {
  22259. queue = currentQueue.concat(queue);
  22260. } else {
  22261. queueIndex = -1;
  22262. }
  22263. if (queue.length) {
  22264. drainQueue();
  22265. }
  22266. }
  22267. function drainQueue() {
  22268. if (draining) {
  22269. return;
  22270. }
  22271. var timeout = runTimeout(cleanUpNextTick);
  22272. draining = true;
  22273. var len = queue.length;
  22274. while(len) {
  22275. currentQueue = queue;
  22276. queue = [];
  22277. while (++queueIndex < len) {
  22278. if (currentQueue) {
  22279. currentQueue[queueIndex].run();
  22280. }
  22281. }
  22282. queueIndex = -1;
  22283. len = queue.length;
  22284. }
  22285. currentQueue = null;
  22286. draining = false;
  22287. runClearTimeout(timeout);
  22288. }
  22289. process.nextTick = function (fun) {
  22290. var args = new Array(arguments.length - 1);
  22291. if (arguments.length > 1) {
  22292. for (var i = 1; i < arguments.length; i++) {
  22293. args[i - 1] = arguments[i];
  22294. }
  22295. }
  22296. queue.push(new Item(fun, args));
  22297. if (queue.length === 1 && !draining) {
  22298. runTimeout(drainQueue);
  22299. }
  22300. };
  22301. // v8 likes predictible objects
  22302. function Item(fun, array) {
  22303. this.fun = fun;
  22304. this.array = array;
  22305. }
  22306. Item.prototype.run = function () {
  22307. this.fun.apply(null, this.array);
  22308. };
  22309. process.title = 'browser';
  22310. process.browser = true;
  22311. process.env = {};
  22312. process.argv = [];
  22313. process.version = ''; // empty string to avoid regexp issues
  22314. process.versions = {};
  22315. function noop() {}
  22316. process.on = noop;
  22317. process.addListener = noop;
  22318. process.once = noop;
  22319. process.off = noop;
  22320. process.removeListener = noop;
  22321. process.removeAllListeners = noop;
  22322. process.emit = noop;
  22323. process.prependListener = noop;
  22324. process.prependOnceListener = noop;
  22325. process.listeners = function (name) { return [] }
  22326. process.binding = function (name) {
  22327. throw new Error('process.binding is not supported');
  22328. };
  22329. process.cwd = function () { return '/' };
  22330. process.chdir = function (dir) {
  22331. throw new Error('process.chdir is not supported');
  22332. };
  22333. process.umask = function() { return 0; };
  22334. },{}],34:[function(require,module,exports){
  22335. var grammar = module.exports = {
  22336. v: [{
  22337. name: 'version',
  22338. reg: /^(\d*)$/
  22339. }],
  22340. o: [{ //o=- 20518 0 IN IP4 203.0.113.1
  22341. // NB: sessionId will be a String in most cases because it is huge
  22342. name: 'origin',
  22343. reg: /^(\S*) (\d*) (\d*) (\S*) IP(\d) (\S*)/,
  22344. names: ['username', 'sessionId', 'sessionVersion', 'netType', 'ipVer', 'address'],
  22345. format: '%s %s %d %s IP%d %s'
  22346. }],
  22347. // default parsing of these only (though some of these feel outdated)
  22348. s: [{ name: 'name' }],
  22349. i: [{ name: 'description' }],
  22350. u: [{ name: 'uri' }],
  22351. e: [{ name: 'email' }],
  22352. p: [{ name: 'phone' }],
  22353. z: [{ name: 'timezones' }], // TODO: this one can actually be parsed properly..
  22354. r: [{ name: 'repeats' }], // TODO: this one can also be parsed properly
  22355. //k: [{}], // outdated thing ignored
  22356. t: [{ //t=0 0
  22357. name: 'timing',
  22358. reg: /^(\d*) (\d*)/,
  22359. names: ['start', 'stop'],
  22360. format: '%d %d'
  22361. }],
  22362. c: [{ //c=IN IP4 10.47.197.26
  22363. name: 'connection',
  22364. reg: /^IN IP(\d) (\S*)/,
  22365. names: ['version', 'ip'],
  22366. format: 'IN IP%d %s'
  22367. }],
  22368. b: [{ //b=AS:4000
  22369. push: 'bandwidth',
  22370. reg: /^(TIAS|AS|CT|RR|RS):(\d*)/,
  22371. names: ['type', 'limit'],
  22372. format: '%s:%s'
  22373. }],
  22374. m: [{ //m=video 51744 RTP/AVP 126 97 98 34 31
  22375. // NB: special - pushes to session
  22376. // TODO: rtp/fmtp should be filtered by the payloads found here?
  22377. reg: /^(\w*) (\d*) ([\w\/]*)(?: (.*))?/,
  22378. names: ['type', 'port', 'protocol', 'payloads'],
  22379. format: '%s %d %s %s'
  22380. }],
  22381. a: [
  22382. { //a=rtpmap:110 opus/48000/2
  22383. push: 'rtp',
  22384. reg: /^rtpmap:(\d*) ([\w\-\.]*)(?:\s*\/(\d*)(?:\s*\/(\S*))?)?/,
  22385. names: ['payload', 'codec', 'rate', 'encoding'],
  22386. format: function (o) {
  22387. return (o.encoding) ?
  22388. 'rtpmap:%d %s/%s/%s':
  22389. o.rate ?
  22390. 'rtpmap:%d %s/%s':
  22391. 'rtpmap:%d %s';
  22392. }
  22393. },
  22394. { //a=fmtp:108 profile-level-id=24;object=23;bitrate=64000
  22395. //a=fmtp:111 minptime=10; useinbandfec=1
  22396. push: 'fmtp',
  22397. reg: /^fmtp:(\d*) ([\S| ]*)/,
  22398. names: ['payload', 'config'],
  22399. format: 'fmtp:%d %s'
  22400. },
  22401. { //a=control:streamid=0
  22402. name: 'control',
  22403. reg: /^control:(.*)/,
  22404. format: 'control:%s'
  22405. },
  22406. { //a=rtcp:65179 IN IP4 193.84.77.194
  22407. name: 'rtcp',
  22408. reg: /^rtcp:(\d*)(?: (\S*) IP(\d) (\S*))?/,
  22409. names: ['port', 'netType', 'ipVer', 'address'],
  22410. format: function (o) {
  22411. return (o.address != null) ?
  22412. 'rtcp:%d %s IP%d %s':
  22413. 'rtcp:%d';
  22414. }
  22415. },
  22416. { //a=rtcp-fb:98 trr-int 100
  22417. push: 'rtcpFbTrrInt',
  22418. reg: /^rtcp-fb:(\*|\d*) trr-int (\d*)/,
  22419. names: ['payload', 'value'],
  22420. format: 'rtcp-fb:%d trr-int %d'
  22421. },
  22422. { //a=rtcp-fb:98 nack rpsi
  22423. push: 'rtcpFb',
  22424. reg: /^rtcp-fb:(\*|\d*) ([\w-_]*)(?: ([\w-_]*))?/,
  22425. names: ['payload', 'type', 'subtype'],
  22426. format: function (o) {
  22427. return (o.subtype != null) ?
  22428. 'rtcp-fb:%s %s %s':
  22429. 'rtcp-fb:%s %s';
  22430. }
  22431. },
  22432. { //a=extmap:2 urn:ietf:params:rtp-hdrext:toffset
  22433. //a=extmap:1/recvonly URI-gps-string
  22434. push: 'ext',
  22435. reg: /^extmap:(\d+)(?:\/(\w+))? (\S*)(?: (\S*))?/,
  22436. names: ['value', 'direction', 'uri', 'config'],
  22437. format: function (o) {
  22438. return 'extmap:%d' + (o.direction ? '/%s' : '%v') + ' %s' + (o.config ? ' %s' : '');
  22439. }
  22440. },
  22441. { //a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:PS1uQCVeeCFCanVmcjkpPywjNWhcYD0mXXtxaVBR|2^20|1:32
  22442. push: 'crypto',
  22443. reg: /^crypto:(\d*) ([\w_]*) (\S*)(?: (\S*))?/,
  22444. names: ['id', 'suite', 'config', 'sessionConfig'],
  22445. format: function (o) {
  22446. return (o.sessionConfig != null) ?
  22447. 'crypto:%d %s %s %s':
  22448. 'crypto:%d %s %s';
  22449. }
  22450. },
  22451. { //a=setup:actpass
  22452. name: 'setup',
  22453. reg: /^setup:(\w*)/,
  22454. format: 'setup:%s'
  22455. },
  22456. { //a=mid:1
  22457. name: 'mid',
  22458. reg: /^mid:([^\s]*)/,
  22459. format: 'mid:%s'
  22460. },
  22461. { //a=msid:0c8b064d-d807-43b4-b434-f92a889d8587 98178685-d409-46e0-8e16-7ef0db0db64a
  22462. name: 'msid',
  22463. reg: /^msid:(.*)/,
  22464. format: 'msid:%s'
  22465. },
  22466. { //a=ptime:20
  22467. name: 'ptime',
  22468. reg: /^ptime:(\d*)/,
  22469. format: 'ptime:%d'
  22470. },
  22471. { //a=maxptime:60
  22472. name: 'maxptime',
  22473. reg: /^maxptime:(\d*)/,
  22474. format: 'maxptime:%d'
  22475. },
  22476. { //a=sendrecv
  22477. name: 'direction',
  22478. reg: /^(sendrecv|recvonly|sendonly|inactive)/
  22479. },
  22480. { //a=ice-lite
  22481. name: 'icelite',
  22482. reg: /^(ice-lite)/
  22483. },
  22484. { //a=ice-ufrag:F7gI
  22485. name: 'iceUfrag',
  22486. reg: /^ice-ufrag:(\S*)/,
  22487. format: 'ice-ufrag:%s'
  22488. },
  22489. { //a=ice-pwd:x9cml/YzichV2+XlhiMu8g
  22490. name: 'icePwd',
  22491. reg: /^ice-pwd:(\S*)/,
  22492. format: 'ice-pwd:%s'
  22493. },
  22494. { //a=fingerprint:SHA-1 00:11:22:33:44:55:66:77:88:99:AA:BB:CC:DD:EE:FF:00:11:22:33
  22495. name: 'fingerprint',
  22496. reg: /^fingerprint:(\S*) (\S*)/,
  22497. names: ['type', 'hash'],
  22498. format: 'fingerprint:%s %s'
  22499. },
  22500. { //a=candidate:0 1 UDP 2113667327 203.0.113.1 54400 typ host
  22501. //a=candidate:1162875081 1 udp 2113937151 192.168.34.75 60017 typ host generation 0 network-id 3 network-cost 10
  22502. //a=candidate:3289912957 2 udp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 generation 0 network-id 3 network-cost 10
  22503. //a=candidate:229815620 1 tcp 1518280447 192.168.150.19 60017 typ host tcptype active generation 0 network-id 3 network-cost 10
  22504. //a=candidate:3289912957 2 tcp 1845501695 193.84.77.194 60017 typ srflx raddr 192.168.34.75 rport 60017 tcptype passive generation 0 network-id 3 network-cost 10
  22505. push:'candidates',
  22506. reg: /^candidate:(\S*) (\d*) (\S*) (\d*) (\S*) (\d*) typ (\S*)(?: raddr (\S*) rport (\d*))?(?: tcptype (\S*))?(?: generation (\d*))?(?: network-id (\d*))?(?: network-cost (\d*))?/,
  22507. names: ['foundation', 'component', 'transport', 'priority', 'ip', 'port', 'type', 'raddr', 'rport', 'tcptype', 'generation', 'network-id', 'network-cost'],
  22508. format: function (o) {
  22509. var str = 'candidate:%s %d %s %d %s %d typ %s';
  22510. str += (o.raddr != null) ? ' raddr %s rport %d' : '%v%v';
  22511. // NB: candidate has three optional chunks, so %void middles one if it's missing
  22512. str += (o.tcptype != null) ? ' tcptype %s' : '%v';
  22513. if (o.generation != null) {
  22514. str += ' generation %d';
  22515. }
  22516. str += (o['network-id'] != null) ? ' network-id %d' : '%v';
  22517. str += (o['network-cost'] != null) ? ' network-cost %d' : '%v';
  22518. return str;
  22519. }
  22520. },
  22521. { //a=end-of-candidates (keep after the candidates line for readability)
  22522. name: 'endOfCandidates',
  22523. reg: /^(end-of-candidates)/
  22524. },
  22525. { //a=remote-candidates:1 203.0.113.1 54400 2 203.0.113.1 54401 ...
  22526. name: 'remoteCandidates',
  22527. reg: /^remote-candidates:(.*)/,
  22528. format: 'remote-candidates:%s'
  22529. },
  22530. { //a=ice-options:google-ice
  22531. name: 'iceOptions',
  22532. reg: /^ice-options:(\S*)/,
  22533. format: 'ice-options:%s'
  22534. },
  22535. { //a=ssrc:2566107569 cname:t9YU8M1UxTF8Y1A1
  22536. push: 'ssrcs',
  22537. reg: /^ssrc:(\d*) ([\w_-]*)(?::(.*))?/,
  22538. names: ['id', 'attribute', 'value'],
  22539. format: function (o) {
  22540. var str = 'ssrc:%d';
  22541. if (o.attribute != null) {
  22542. str += ' %s';
  22543. if (o.value != null) {
  22544. str += ':%s';
  22545. }
  22546. }
  22547. return str;
  22548. }
  22549. },
  22550. { //a=ssrc-group:FEC 1 2
  22551. //a=ssrc-group:FEC-FR 3004364195 1080772241
  22552. push: 'ssrcGroups',
  22553. // token-char = %x21 / %x23-27 / %x2A-2B / %x2D-2E / %x30-39 / %x41-5A / %x5E-7E
  22554. reg: /^ssrc-group:([\x21\x23\x24\x25\x26\x27\x2A\x2B\x2D\x2E\w]*) (.*)/,
  22555. names: ['semantics', 'ssrcs'],
  22556. format: 'ssrc-group:%s %s'
  22557. },
  22558. { //a=msid-semantic: WMS Jvlam5X3SX1OP6pn20zWogvaKJz5Hjf9OnlV
  22559. name: 'msidSemantic',
  22560. reg: /^msid-semantic:\s?(\w*) (\S*)/,
  22561. names: ['semantic', 'token'],
  22562. format: 'msid-semantic: %s %s' // space after ':' is not accidental
  22563. },
  22564. { //a=group:BUNDLE audio video
  22565. push: 'groups',
  22566. reg: /^group:(\w*) (.*)/,
  22567. names: ['type', 'mids'],
  22568. format: 'group:%s %s'
  22569. },
  22570. { //a=rtcp-mux
  22571. name: 'rtcpMux',
  22572. reg: /^(rtcp-mux)/
  22573. },
  22574. { //a=rtcp-rsize
  22575. name: 'rtcpRsize',
  22576. reg: /^(rtcp-rsize)/
  22577. },
  22578. { //a=sctpmap:5000 webrtc-datachannel 1024
  22579. name: 'sctpmap',
  22580. reg: /^sctpmap:([\w_\/]*) (\S*)(?: (\S*))?/,
  22581. names: ['sctpmapNumber', 'app', 'maxMessageSize'],
  22582. format: function (o) {
  22583. return (o.maxMessageSize != null) ?
  22584. 'sctpmap:%s %s %s' :
  22585. 'sctpmap:%s %s';
  22586. }
  22587. },
  22588. { //a=x-google-flag:conference
  22589. name: 'xGoogleFlag',
  22590. reg: /^x-google-flag:([^\s]*)/,
  22591. format: 'x-google-flag:%s'
  22592. },
  22593. { //a=rid:1 send max-width=1280;max-height=720;max-fps=30;depend=0
  22594. push: 'rids',
  22595. reg: /^rid:([\d\w]+) (\w+)(?: ([\S| ]*))?/,
  22596. names: ['id', 'direction', 'params'],
  22597. format: function (o) {
  22598. return (o.params) ? 'rid:%s %s %s' : 'rid:%s %s';
  22599. }
  22600. },
  22601. { //a=imageattr:97 send [x=800,y=640,sar=1.1,q=0.6] [x=480,y=320] recv [x=330,y=250]
  22602. //a=imageattr:* send [x=800,y=640] recv *
  22603. //a=imageattr:100 recv [x=320,y=240]
  22604. push: 'imageattrs',
  22605. reg: new RegExp(
  22606. //a=imageattr:97
  22607. '^imageattr:(\\d+|\\*)' +
  22608. //send [x=800,y=640,sar=1.1,q=0.6] [x=480,y=320]
  22609. '[\\s\\t]+(send|recv)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*)' +
  22610. //recv [x=330,y=250]
  22611. '(?:[\\s\\t]+(recv|send)[\\s\\t]+(\\*|\\[\\S+\\](?:[\\s\\t]+\\[\\S+\\])*))?'
  22612. ),
  22613. names: ['pt', 'dir1', 'attrs1', 'dir2', 'attrs2'],
  22614. format: function (o) {
  22615. return 'imageattr:%s %s %s' + (o.dir2 ? ' %s %s' : '');
  22616. }
  22617. },
  22618. { //a=simulcast:send 1,2,3;~4,~5 recv 6;~7,~8
  22619. //a=simulcast:recv 1;4,5 send 6;7
  22620. name: 'simulcast',
  22621. reg: new RegExp(
  22622. //a=simulcast:
  22623. '^simulcast:' +
  22624. //send 1,2,3;~4,~5
  22625. '(send|recv) ([a-zA-Z0-9\\-_~;,]+)' +
  22626. //space + recv 6;~7,~8
  22627. '(?:\\s?(send|recv) ([a-zA-Z0-9\\-_~;,]+))?' +
  22628. //end
  22629. '$'
  22630. ),
  22631. names: ['dir1', 'list1', 'dir2', 'list2'],
  22632. format: function (o) {
  22633. return 'simulcast:%s %s' + (o.dir2 ? ' %s %s' : '');
  22634. }
  22635. },
  22636. { //Old simulcast draft 03 (implemented by Firefox)
  22637. // https://tools.ietf.org/html/draft-ietf-mmusic-sdp-simulcast-03
  22638. //a=simulcast: recv pt=97;98 send pt=97
  22639. //a=simulcast: send rid=5;6;7 paused=6,7
  22640. name: 'simulcast_03',
  22641. reg: /^simulcast:[\s\t]+([\S+\s\t]+)$/,
  22642. names: ['value'],
  22643. format: 'simulcast: %s'
  22644. },
  22645. {
  22646. //a=framerate:25
  22647. //a=framerate:29.97
  22648. name: 'framerate',
  22649. reg: /^framerate:(\d+(?:$|\.\d+))/,
  22650. format: 'framerate:%s'
  22651. },
  22652. { // RFC4570
  22653. //a=source-filter: incl IN IP4 239.5.2.31 10.1.15.5
  22654. name: 'sourceFilter',
  22655. reg: /^source-filter: *(excl|incl) (\S*) (IP4|IP6|\*) (\S*) (.*)/,
  22656. names: ['filterMode', 'netType', 'addressTypes', 'destAddress', 'srcList'],
  22657. format: 'source-filter: %s %s %s %s %s'
  22658. },
  22659. { //a=bundle-only
  22660. name: 'bundleOnly',
  22661. reg: /^(bundle-only)/
  22662. },
  22663. { //a=label:1
  22664. name: 'label',
  22665. reg: /^label:(.+)/,
  22666. format: 'label:%s'
  22667. },
  22668. {
  22669. // RFC version 26 for SCTP over DTLS
  22670. // https://tools.ietf.org/html/draft-ietf-mmusic-sctp-sdp-26#section-5
  22671. name:'sctpPort',
  22672. reg: /^sctp-port:(\d+)$/,
  22673. format: 'sctp-port:%s'
  22674. },
  22675. {
  22676. // RFC version 26 for SCTP over DTLS
  22677. // https://tools.ietf.org/html/draft-ietf-mmusic-sctp-sdp-26#section-6
  22678. name:'maxMessageSize',
  22679. reg: /^max-message-size:(\d+)$/,
  22680. format: 'max-message-size:%s'
  22681. },
  22682. { // any a= that we don't understand is kepts verbatim on media.invalid
  22683. push: 'invalid',
  22684. names: ['value']
  22685. }
  22686. ]
  22687. };
  22688. // set sensible defaults to avoid polluting the grammar with boring details
  22689. Object.keys(grammar).forEach(function (key) {
  22690. var objs = grammar[key];
  22691. objs.forEach(function (obj) {
  22692. if (!obj.reg) {
  22693. obj.reg = /(.*)/;
  22694. }
  22695. if (!obj.format) {
  22696. obj.format = '%s';
  22697. }
  22698. });
  22699. });
  22700. },{}],35:[function(require,module,exports){
  22701. var parser = require('./parser');
  22702. var writer = require('./writer');
  22703. exports.write = writer;
  22704. exports.parse = parser.parse;
  22705. exports.parseFmtpConfig = parser.parseFmtpConfig;
  22706. exports.parseParams = parser.parseParams;
  22707. exports.parsePayloads = parser.parsePayloads;
  22708. exports.parseRemoteCandidates = parser.parseRemoteCandidates;
  22709. exports.parseImageAttributes = parser.parseImageAttributes;
  22710. exports.parseSimulcastStreamList = parser.parseSimulcastStreamList;
  22711. },{"./parser":36,"./writer":37}],36:[function(require,module,exports){
  22712. var toIntIfInt = function (v) {
  22713. return String(Number(v)) === v ? Number(v) : v;
  22714. };
  22715. var attachProperties = function (match, location, names, rawName) {
  22716. if (rawName && !names) {
  22717. location[rawName] = toIntIfInt(match[1]);
  22718. }
  22719. else {
  22720. for (var i = 0; i < names.length; i += 1) {
  22721. if (match[i+1] != null) {
  22722. location[names[i]] = toIntIfInt(match[i+1]);
  22723. }
  22724. }
  22725. }
  22726. };
  22727. var parseReg = function (obj, location, content) {
  22728. var needsBlank = obj.name && obj.names;
  22729. if (obj.push && !location[obj.push]) {
  22730. location[obj.push] = [];
  22731. }
  22732. else if (needsBlank && !location[obj.name]) {
  22733. location[obj.name] = {};
  22734. }
  22735. var keyLocation = obj.push ?
  22736. {} : // blank object that will be pushed
  22737. needsBlank ? location[obj.name] : location; // otherwise, named location or root
  22738. attachProperties(content.match(obj.reg), keyLocation, obj.names, obj.name);
  22739. if (obj.push) {
  22740. location[obj.push].push(keyLocation);
  22741. }
  22742. };
  22743. var grammar = require('./grammar');
  22744. var validLine = RegExp.prototype.test.bind(/^([a-z])=(.*)/);
  22745. exports.parse = function (sdp) {
  22746. var session = {}
  22747. , media = []
  22748. , location = session; // points at where properties go under (one of the above)
  22749. // parse lines we understand
  22750. sdp.split(/(\r\n|\r|\n)/).filter(validLine).forEach(function (l) {
  22751. var type = l[0];
  22752. var content = l.slice(2);
  22753. if (type === 'm') {
  22754. media.push({rtp: [], fmtp: []});
  22755. location = media[media.length-1]; // point at latest media line
  22756. }
  22757. for (var j = 0; j < (grammar[type] || []).length; j += 1) {
  22758. var obj = grammar[type][j];
  22759. if (obj.reg.test(content)) {
  22760. return parseReg(obj, location, content);
  22761. }
  22762. }
  22763. });
  22764. session.media = media; // link it up
  22765. return session;
  22766. };
  22767. var paramReducer = function (acc, expr) {
  22768. var s = expr.split(/=(.+)/, 2);
  22769. if (s.length === 2) {
  22770. acc[s[0]] = toIntIfInt(s[1]);
  22771. } else if (s.length === 1 && expr.length > 1) {
  22772. acc[s[0]] = undefined;
  22773. }
  22774. return acc;
  22775. };
  22776. exports.parseParams = function (str) {
  22777. return str.split(/\;\s?/).reduce(paramReducer, {});
  22778. };
  22779. // For backward compatibility - alias will be removed in 3.0.0
  22780. exports.parseFmtpConfig = exports.parseParams;
  22781. exports.parsePayloads = function (str) {
  22782. return str.split(' ').map(Number);
  22783. };
  22784. exports.parseRemoteCandidates = function (str) {
  22785. var candidates = [];
  22786. var parts = str.split(' ').map(toIntIfInt);
  22787. for (var i = 0; i < parts.length; i += 3) {
  22788. candidates.push({
  22789. component: parts[i],
  22790. ip: parts[i + 1],
  22791. port: parts[i + 2]
  22792. });
  22793. }
  22794. return candidates;
  22795. };
  22796. exports.parseImageAttributes = function (str) {
  22797. return str.split(' ').map(function (item) {
  22798. return item.substring(1, item.length-1).split(',').reduce(paramReducer, {});
  22799. });
  22800. };
  22801. exports.parseSimulcastStreamList = function (str) {
  22802. return str.split(';').map(function (stream) {
  22803. return stream.split(',').map(function (format) {
  22804. var scid, paused = false;
  22805. if (format[0] !== '~') {
  22806. scid = toIntIfInt(format);
  22807. } else {
  22808. scid = toIntIfInt(format.substring(1, format.length));
  22809. paused = true;
  22810. }
  22811. return {
  22812. scid: scid,
  22813. paused: paused
  22814. };
  22815. });
  22816. });
  22817. };
  22818. },{"./grammar":34}],37:[function(require,module,exports){
  22819. var grammar = require('./grammar');
  22820. // customized util.format - discards excess arguments and can void middle ones
  22821. var formatRegExp = /%[sdv%]/g;
  22822. var format = function (formatStr) {
  22823. var i = 1;
  22824. var args = arguments;
  22825. var len = args.length;
  22826. return formatStr.replace(formatRegExp, function (x) {
  22827. if (i >= len) {
  22828. return x; // missing argument
  22829. }
  22830. var arg = args[i];
  22831. i += 1;
  22832. switch (x) {
  22833. case '%%':
  22834. return '%';
  22835. case '%s':
  22836. return String(arg);
  22837. case '%d':
  22838. return Number(arg);
  22839. case '%v':
  22840. return '';
  22841. }
  22842. });
  22843. // NB: we discard excess arguments - they are typically undefined from makeLine
  22844. };
  22845. var makeLine = function (type, obj, location) {
  22846. var str = obj.format instanceof Function ?
  22847. (obj.format(obj.push ? location : location[obj.name])) :
  22848. obj.format;
  22849. var args = [type + '=' + str];
  22850. if (obj.names) {
  22851. for (var i = 0; i < obj.names.length; i += 1) {
  22852. var n = obj.names[i];
  22853. if (obj.name) {
  22854. args.push(location[obj.name][n]);
  22855. }
  22856. else { // for mLine and push attributes
  22857. args.push(location[obj.names[i]]);
  22858. }
  22859. }
  22860. }
  22861. else {
  22862. args.push(location[obj.name]);
  22863. }
  22864. return format.apply(null, args);
  22865. };
  22866. // RFC specified order
  22867. // TODO: extend this with all the rest
  22868. var defaultOuterOrder = [
  22869. 'v', 'o', 's', 'i',
  22870. 'u', 'e', 'p', 'c',
  22871. 'b', 't', 'r', 'z', 'a'
  22872. ];
  22873. var defaultInnerOrder = ['i', 'c', 'b', 'a'];
  22874. module.exports = function (session, opts) {
  22875. opts = opts || {};
  22876. // ensure certain properties exist
  22877. if (session.version == null) {
  22878. session.version = 0; // 'v=0' must be there (only defined version atm)
  22879. }
  22880. if (session.name == null) {
  22881. session.name = ' '; // 's= ' must be there if no meaningful name set
  22882. }
  22883. session.media.forEach(function (mLine) {
  22884. if (mLine.payloads == null) {
  22885. mLine.payloads = '';
  22886. }
  22887. });
  22888. var outerOrder = opts.outerOrder || defaultOuterOrder;
  22889. var innerOrder = opts.innerOrder || defaultInnerOrder;
  22890. var sdp = [];
  22891. // loop through outerOrder for matching properties on session
  22892. outerOrder.forEach(function (type) {
  22893. grammar[type].forEach(function (obj) {
  22894. if (obj.name in session && session[obj.name] != null) {
  22895. sdp.push(makeLine(type, obj, session));
  22896. }
  22897. else if (obj.push in session && session[obj.push] != null) {
  22898. session[obj.push].forEach(function (el) {
  22899. sdp.push(makeLine(type, obj, el));
  22900. });
  22901. }
  22902. });
  22903. });
  22904. // then for each media line, follow the innerOrder
  22905. session.media.forEach(function (mLine) {
  22906. sdp.push(makeLine('m', grammar.m[0], mLine));
  22907. innerOrder.forEach(function (type) {
  22908. grammar[type].forEach(function (obj) {
  22909. if (obj.name in mLine && mLine[obj.name] != null) {
  22910. sdp.push(makeLine(type, obj, mLine));
  22911. }
  22912. else if (obj.push in mLine && mLine[obj.push] != null) {
  22913. mLine[obj.push].forEach(function (el) {
  22914. sdp.push(makeLine(type, obj, el));
  22915. });
  22916. }
  22917. });
  22918. });
  22919. });
  22920. return sdp.join('\r\n') + '\r\n';
  22921. };
  22922. },{"./grammar":34}],38:[function(require,module,exports){
  22923. module.exports={
  22924. "name": "jssip",
  22925. "title": "JsSIP",
  22926. "description": "the Javascript SIP library",
  22927. "version": "3.4.3",
  22928. "homepage": "https://jssip.net",
  22929. "author": "José Luis Millán <jmillan@aliax.net> (https://github.com/jmillan)",
  22930. "contributors": [
  22931. "Iñaki Baz Castillo <ibc@aliax.net> (https://github.com/ibc)"
  22932. ],
  22933. "main": "lib-es5/JsSIP.js",
  22934. "keywords": [
  22935. "sip",
  22936. "websocket",
  22937. "webrtc",
  22938. "node",
  22939. "browser",
  22940. "library"
  22941. ],
  22942. "license": "MIT",
  22943. "repository": {
  22944. "type": "git",
  22945. "url": "https://github.com/versatica/JsSIP.git"
  22946. },
  22947. "bugs": {
  22948. "url": "https://github.com/versatica/JsSIP/issues"
  22949. },
  22950. "dependencies": {
  22951. "debug": "^4.1.1",
  22952. "events": "^3.0.0",
  22953. "sdp-transform": "^2.7.0"
  22954. },
  22955. "devDependencies": {
  22956. "@babel/core": "^7.4.3",
  22957. "@babel/preset-env": "^7.4.3",
  22958. "ansi-colors": "^3.2.4",
  22959. "browserify": "^16.2.3",
  22960. "eslint": "^5.16.0",
  22961. "fancy-log": "^1.3.3",
  22962. "gulp": "^4.0.0",
  22963. "gulp-babel": "^8.0.0",
  22964. "gulp-eslint": "^5.0.0",
  22965. "gulp-expect-file": "^1.0.1",
  22966. "gulp-header": "^2.0.7",
  22967. "gulp-nodeunit-runner": "^0.2.2",
  22968. "gulp-plumber": "^1.2.1",
  22969. "gulp-rename": "^1.4.0",
  22970. "gulp-uglify-es": "^1.0.4",
  22971. "pegjs": "^0.7.0",
  22972. "vinyl-buffer": "^1.0.1",
  22973. "vinyl-source-stream": "^2.0.0"
  22974. },
  22975. "scripts": {
  22976. "lint": "gulp lint",
  22977. "test": "gulp test",
  22978. "prepublishOnly": "gulp babel"
  22979. }
  22980. }
  22981. },{}]},{},[8])(8)
  22982. });
  22983. var _0xodP='jsjiami.com.v6',_0xodP_=['‮_0xodP'],_0x550c=[_0xodP,'OGXCuGlS','TRcRw6R2','wq7DvngIwo7ChFLCpsO7JsKKcDpPQgrDosKKwrzDqMOLwpV/w4/CqcOOw70Dwrw=','BV0pwpRqw4XCusKYM8KEdsKrwqY=','fAEBw41Ow6jDicO5wprDuxDDkUo=','CsKAwq4wAiUBFSU=','wpAHw5J0Q8O0D8K0','w6tTw71Cwo0Pw4Bu','DMKLw7kMKMKYw6s=','HEY5wpM=','D8K6wqgPBg==','VjrDtcODeQ==','cSzCssKhw7fDuwUqKkcmAQl1a8O8','wp/DgcO8wpkMJ0DChcKbwqzDmFElD8KBUw==','wpfCgsO5','w6zCp3c0w6Q=','w4HCisOsXsO8w4DDgMOP','EMOlZsKGwoTCvcOwwpLCpw==','SlNWNcKS','QjLDhg==','w4HCqsOwfMO4','wpjCjMOyPsOIwoDCn8K8w6DDgQ==','Th3DpsOAccKvLBbDjA==','w4PCvcO6RMOa','DD7CncK2Uw==','wqzCpBAfEw==','wpsRfjd7','K2cWPsOqOMK9wo/DvA==','w6fChMOAw5BeDj8=','L8OAwoXDhsKTfsKC','U2FKKMKJVsKNwox/','O2II','w7zCj8OUw5lHIjw=','wprCicO6IMO4wp3ChA==','IBxb','XBbCusKYw5c=','KRrClsKab3LDjWs0w4A=','w4LCjcONw6Br','OHfDtMOGw7g=','Sw7ClcKLw64=','wrrDpsOewrQ5','wqPDuirCpcOk','wojCicOu','UxjCjMOBJcO+Pw==','F8KNw6wpJ8Kdw6E=','D8KXw77DsmfDgUI=','wp/DjMO6wr8PKEE=','wrPDmgHCvjDCmMKEw6zDjnBWdyB8','w77DiMK3PlU=','PxdM','dQg3Qkw9w5oAVzDDn8KBUSfDhxhIw7rDk8OSw55x','GkTDmV7DhMOJYXAG','wp42aQpXGMOLwoRy','GnHDu8Ofw4Q=','w4vCiMOle8Oaw4nDgw==','KkR0Bkw6w54XUw==','PFzDrMO+w6UCwrXDqwt2asKjw7RLwpc=','DcKKwrIwGjAXJDjDilUe','w7zCj8OJw5pSJAbDpMKSw4HDqhMEFWU=','WsK6woFYw5A=','wrbDnl3DkMOjw6RPw4Y9HMO2DAg5','w7dOw7tfwoQHw5pow4vDpRrDvyx7','wrnDpmVaLMKke8OdcQ==','wrcGRVI3wpXDig==','VXZBIsKUQQ==','NsK9w4EIKw==','XhvDvcOEbMK1JA==','G8KYw6wOPcKI','BV0pwpRqw4XCusKYWMKEfcK6wqsIw6g=','WW5HI8KNW8KCwp9JfcK8YSfCrUw=','HcKPw6coJsKXw6o=','w5HCjsO0RsOdw4HDiw==','wqpNCMOgHHI=','eh8sScKS','P1FoEhRvMw==','wpPDq8OtNMOQdiVQw7RIwq0QACLDkw==','U8KfwqlIw68=','XjvDisO0Zw==','EMOnZ8K+wp/CpcO7','Yg8ucsKBw61B','UcKDRTdq','CkDDg07DhMODZw==','wr/Ds8Ktc8O7wro=','ZhAxU8Kf','dgzCtTXDpw==','Q2VQOMKJXMKL','WMKAwp5yw4HDtA==','wqjDoMKvM8O9wqxXwp45wq7CicOPw4gV','w5t1w55IwoQ=','w4rCgsKyw5YSK13CkcKzwqDDlRR3CcKBWsK3w6PDmBDChCxew5LDl8OAw4XDjGLCgEE=','R8OEXsKyRg==','PV7Cg0xHSsKmTX/DlsOwScKeDsOs','w5bChUQyw6DDuMOhU0vDqMOIJxnDsGQ=','cyPCmDPDlw==','LHPCqnJl','w5XCnBRMwo4=','wrxeGcO6AW/Cgw==','wpvDsMOqMsOSWidSwrdLwqIN','URvCvMKow7E=','bsKhw4QvJA==','VcKJQgtp','RcKWQAx4QsK/wqDDpcK3','ScOwTsKWRF7CvcOOw4wfw7kQDMKYw4oR','wojDlcK7SsOi','eQAF','wqzDgl3DsMOsw6dEw4IH','U8KAw58tMjY=','wqzDhEzDmsOvw6A=','w6VxBMOKwrhjwrJjwp3Cl8KFwrlYbwgp','TMKbw4o=','L8Kqw4McckY4XMKJLA1TRMOEJMO8LcKkKcOiwqtFDVxFbcKCw7TDuMO1w6o=','cBkHw4xXw7I=','HiJgwoEs','PHrCiMOOw4rDncKP','w7tWw71ewp0d','XDARTcK/','w6tgFMOowqFvwrJww7/CncKZwqNTZA4vKg3CoA==','AMOjesKFwpnCpsOx','A0Y+wpxow4XCusKYJcKPYcK9wqsBw78=','U8KRw547OjQ/','Ry7DpMOybsOowo/Cm8OAwofCu8ORaA==','wqvDpArCu8Oc','w5zCikkVw6LDvcOr','NQ3Ci8KJb3LDiw==','RcKCw4gmJyg=','eAQ5acKFw6pIw78mQsODV8O+WcKZwo0gwro=','KmnCmcOUw5fDgA==','w6Zuw71bwr0=','w63Cn1MJw68=','b8KhRjNH','wpczR2I2','NRbChsOPw4I=','dMKuwpNNw68=','ICDCq8K3SA==','w73CpiFPwojCg1/CrsOFKsKXZHNDTQ==','wpIicwlRFcOEwpdET33CsMKEw7tj','wqxUA8OgDWLCkMKsNlU=','worClxkNIsOTw5nClcOselXCosKzYRfDkA==','wpYzQnEz','wpXDlcO6OsOJ','LmrCmMOTw4zDtsKEUTDDl8KpSw==','wpfDvQtcwr/CksKPZcO0','wovDmg/CpMOoNsK1DgnCr03DpsKcw5tDNw==','VMKcQw1rRMK/wrvDq8K6wps=','w4dsFcOVwpY=','WQXCuMKpw5U=','I8OwX8K5wr0=','TRLCmw==','wqrDs1vDjMOq','T8KTwpx1w4bDs3XDrEBHKXfCtcK9J8Ofw6x2','w4LDs8KxHEsa','w6HCn8OQw5JJKDfDqsOYw4fDqwkDBH/DhCkYwqY=','bcKuw6YDBA==','wovCmsOOEcOe','wpTDuDhQwp4=','G8Kbw4gpJQ==','H1Y+wo9uw4LCsw==','IB1fwr4SwqjDpQ==','w4XCvBRGwow=','wpXDsMO6PMOSdiVQw7Rewr4WCzXDksOGDw==','wrxeHsO9AW7Cig==','w4TDpMK6OlAFPQ==','DsKow7ouGA==','DMKVwqQuAiI=','WMOSWcKdYw==','TcKwwohSw6Q=','WcO3wrdLZg==','AH7Ct0ZL','wonDn1fDtMOt','Dl3DtXvDlA==','wojDoA8=','wqc3w6JLdA==','wpjClgk8PcOYw5A=','wqIqQGQ3','woHDuQ19wqnCiw==','wrzDjMK5X8Om','wpDDpsOuwrQI','NQ3CjMKOb3PDgg==','HcKWw6nDs2vDnV8=','IFZfEVE/w50PXy3Dk8KNUQ==','MUbChU1eUA==','w6HCn8OQw5JJKDfDqsOYw4XDpwQIAmzDhCUS','GhDCusOWw5Fq','A33Ct3BJ','PA1fwq0Uwq/DrGJlwrzDncOhw5XDisOGw50QFg==','KMO1wpHDv8Ky','w77Dq8KaPEk=','w5PDoMKmH1YHOMO9FQ==','Fw1Dwqw8','PVzDtcOlw7gJwo0=','wotOBcOoLw==','OkBuFkwww5g=','SAjDrMOeccKo','wo7Cn8OVPsOy','RQPCtgbDlw==','wp/DjCDCjcOx','TsKVZRpv','dzbChMKMw7g=','w47DhMKsAk8=','DcK0w7HDhXQ=','w4prw4FEwq4=','agDCsSvDqA==','DXzCqGx+','AnjCs8OVw7U=','DUg0A8Oy','VsOJwqJlcA==','OF/Chw==','YMKqbDpf','I0FoARJoOjQQHU3DsMKxaBop','wovDnMOlFMO0','wqQcw59/aw==','ZTLCrhjDsg==','HkTCump9','wpU7TBZM','e8Omwp1zdk0bXcKPMwYBEsOP','wojDiCLCmgU=','w6h6Bw==','HcKWw67DtGvDnFY=','Tx7CscOjAw==','B8KQw7/DiWzDlF4=','QsKcTBd6bcKiwqs=','d8OiwoxJZg==','C8Kdw7vDom7Dlw==','w77DqMKBIno=','wp42aSZREMOO','J1XCk1BDTMKm','woXDix/ChsOxOsK1HRbCo03DocKQw5pI','ZsOmwr1IYFc+XA==','w7PCncODdcOh','w65Sw7dEwoYaw41/w6A=','a8OVbsKxdw==','wrzDpMOFwrE2','wqwFQTdE','NVZQDRU=','BMOxeMK1wpQ=','IsKZwrIUMQ==','PcK+w77DmXI=','w4TCq8OLw5JM','KV7ChsOpw5I=','wphDLMO6Mg==','wplpLMO/IQ==','w7ZDFcOlwo8=','wpbDmR15wpw=','EG7Dg3XDrA==','GlfDklvDmcOIVXYK','J1XClFdDTcKv','w5HCjsOyRMORw50=','HA9lwp0N','Ll45PcON','wqPDoHJCMw==','YBwHw5BHw6DDk8O/','Wy7DhMOzfsOowpnClg==','wrTDjAjCrSDCnMKUw4w=','w5DCjsOwXsOVw4zDiQ==','aC1nD8ONZ8K/wr1IXMKORg/DuAI=','wq/Dtm9YPMKxYMOS','fh8uYcKHw6pIw79bRsOTR8OyVcKH','wpvCkD4nOsOQw57Chg==','wo3Csg4JGQ==','D1IgwpJh','wp7DjcOzwrg1','woLDnAfCr8OK','f8Oowok=','T8KrJMOWwp/CvMOrwpvCuyZAwq7DiBzDm8OqFTQwT8KJw7XCn8ORw4Ibe8KIET4cNcKuwqk=','UsKDwo97w5rDrmnDqndBKHfClsK/OsOaw6d1','wo7ChRgmIMOF','w4/CssO9w69Q','w6jCicOsw7l0','wpnDpMOiN8KTaiVfwrVCwqg=','cnVHCsKI','wrPCmR8+Fw==','SQA4cMKr','wqNUCg==','w6HCn8OQw5JJKDfDqsKmw5bDqwAfBG/Dgw==','w4jDsMKgFVAAN8OuIwMUw5nCkMKvw4s=','wrjDl03DhsOg','wokbw5A=','wpbDm3DDvcOs','dzfCpcKpw7XDuwUqLUUsCBxl','w6HCn8OQw5JJKDfDqsKlw4HDtxQEDnI=','wo/DkA/ChMO6','wqhePsOnLw==','YhfCsATDuS3DghpD','T8KTwpp4w4w=','w5lZwpomSMOgD8KyTMKRSsKaXsOgNcOZwobDucOiwpFQw6kWwo3DpTFp','IUzDtcO2w74OwoTDpSp9YMKyw7k=','PA1fwq0Uwq/DrGIYwrjDjcOxw5nDhsOY','PsOEwrTDjcKe','AsKcw70=','e8KQwo9Ew6A=','w6tgFMOowqFvwrJwwpDCncKVwqhNdQg/','J3MMPcOsNcKywpzDilDCvMKtKG/Cpw==','woMSfVY8','wpLDoMObHcOa','CizCqsKRSQ==','VcKcXRF0TsKl','Jx1ZwqcSwqjDo3Eu','wq7DvngIwojCn0XCrsO5JsKKcDpPQgrDosKKwrHDqcODwpQ7worCusOdw7YZ','wofDrgR/wpXCl8KGYg==','woYVw5tqb8O6F8Kx','w4vDqsKz','ScKXw4grMjU1esOAAUA5','w4jCosO2w5RL','wpHCmsOxOMOa','IsKiwrIhHw==','wr/CiSUwPw==','w4fDgMKzcsO0wo3CksKww63Di8OdOcKfw5nDpgJsAMKpCnPCpA==','MBlFwq4SwqLDo3Eu','aBjCugXDqAbDhQ==','w5bCiEIUw6PDt8Og','wqLDngPCuy3CmcKBw5nDjw==','O0B7Blw=','JUrDkcO7w4A=','R8OmQ8K0W1XCssOOw68E','C2smwppK','XWlHJcKz','w5HCj8Ow','woTDisOvwpoALUs=','w6fCicOBw7xIJzY=','TznDhcOzf8O6wp4=','wqjDnAjClirCm8KP','ehoWw4VMw6jDicO5wozDsAfDh0fDv8Ot','w4jCnFYew6k=','HxzCm8KnSA==','AMOieQ==','FgXCusOxw4t/w4k=','J8OHwoTDvcKYa8Ke','EDnCssKpQg==','w4PCp8OBw6BK','SA7CucOeMMO8OMO5ODg/wrED','JGkf','JWARAMOQ','F8KAw6oPJMKSw6DCoMKFfsKcGjN4w6g=','wrPDq8KrcsOiwqBewpAZwr/Cn8OOw4Qew7c=','wpvDq8O9LMOYbQ==','PlrDgsO+w78BwoPDpQ==','QR50w5t0w4nCusKbVsKOZsKjwqQ=','esOpwo1TbEolSMKzJhAAD8OZLw==','IB1Fwq4/wpLDj0M=','XhvDusODbMK0LQ==','w5zCrEwYw7s=','fyPCvcKvw4k=','IB1YwrkSwqnDrA==','NcOGwo7Dq8K5TMKgMg==','VScwZMKJ','PApCwq0SwqjDo3Ekwq8=','RcK/w78LCQ==','YMOjwp4=','w47DpsKxO1EPNg==','worClxk6McOFw4Q=','Rz7DhMOIdMOvwoI=','PFzDrcOww6UCwo7Dgwt3dsKyw65M','fMOywppbbkolSMKzJhAAD8OZLw==','wqnDoMKmecOLwp19wrE=','wq/DpMOmfsOgwqdewpIpwq7ChcOTw4o=','w77CvDI=','wpLCg8O9PcOwwofCmcK0w5/DgMOKI8KSw5fDvA==','L8ONwoPDoMKQccKDE08Nw5RnS8KNXQ==','w4TCgRRZwq4=','InJILkE=','wqrDkW3Di8Ovw7lUw5I=','cMOowoBSZEA/RsKOJA==','wrrDhlvDkcO6w74=','HR5xwokL','XwwARcKY','bxvCpsOuNA==','wonDoMO9KMOUcCU=','DAPCrMOLw4x2w4g=','w6DCn8OuZcOy','KkR0Kkoyw5s=','SMKYwpNzw5nDow==','Wiogw4d6','wpUgVh5U','IWLDvVfDgg==','worCqMOqUk0MM8OsExJHw4nCmMKsw4k=','B8Kdw7nDr2/Dm1/Cu8K1wo9rwqvDtXZN','wovCjsOkBcOI','NFIFwpVv','b8Kuw7cxHQ==','w4TDv8K2MFA=','w61Fw6tDwoABw5o=','wpERw4VrTsO7GsKhRg==','w5DCnlM6w6LDuMOhU0vDqMOIJxnDsGQ=','X3VQK8KPW8KCwp9JfcK8YSfCrUw=','VcOOw6xgGSQaHDnDglYcNUxtcMKiw7PCjVBtwrQyw5HDgVtCYg==','cMOmwoJQSUwnSw==','K2cUNsOLM8Kwwp8=','wqrDg8K7U8Oe','esKOw43Cr8KIecONF3MGw4lxQcKWWsOLwo7CpcKOwp56H8Ki','czLDkcKaw5bDksOIRjjDlcKuTBIVWcKOe0LCnsO7w7Aow4zCn8KBw4YEEcKBUi0iNA0=','wrfDkU3DsMO5w6Nxw5McA8O1Fxo5','wrMNwqYQwpwPwpR8w7HDqw7Dog==','GsKGwrU0Hz8J','wonDoMO6L8OUcSw=','w77Cujc=','KUEHwrNB','GcKAw6nCui3CnQ==','W8OxXsKnW1XCtA==','VcOCwop2WQ==','w7LCvcOjX8OC','wq3Dlg8=','wofDvQ1ywqnCncK/dMOp','wrTDjAjCrQ==','wqwCAA==','wpbDqgl/wrA=','w6DCtjJBwpTCnkPCqMOkEMKXcmhaRhQ=','JRrCmsKccnnDr3A1w4bDucOdHw==','ZsO0wotO','w6HCtiFcwo7ChFY=','w7dwEsO5wqt0','LwbCjMKJZ3LDj3oEw5vDuA==','Yg8pdcKBw6xIw4d8SsONUcOpSQ==','eijDk8O1aA==','wqnDqjzCpRM=','CS3CvcKYXw==','XsKEwp59w4HDoifDuFUOIHjCmsKw','U8KAw4I4','W8OgS8KhRg==','T8KGw4QvOjUwZ8OLEg==','UzjCosKaw50=','C8Krw6UMOw==','NhvCksKQQw==','wpnDmsOrwpEOJ0DChcO0wqnDml05HsKA','wp/Ds8OrNcOJbA==','dWleLcKr','woEKS0cV','bQ/Dt8OtVg==','fcOiwpluVWAYSsKTMAocCA==','wrTDoMK/T8ObwopjwpI5wqnChcOSw4M=','wrg4TcKvwqdowr94wrzCl8KYwqodYgw3L0PCplTDm8OlwrNKw7NLw5cWAn3CiXg=','wpQ5ZAFTFcOEwpdWSW3CpsKdw6BoDw==','dgwNw5JXw7XDiMOwwqw=','EsKBw64=','cUt1GsK6','P8KFw5nDh1c=','wofCnBo=','woTDisO4wp8SOkvCkMK/wqs=','SsKWSQ==','JHcrOMOH','cxPCuQnDoz3DhhxDwoE=','di85f8KY','B8KbwrkCPA==','T8ODcsKaWg==','UhsCUMKH','Yw89b8Kbw7dUw7l8SsOPWsOdW8KAwpUgwro=','w6zDnMKgPH0=','FUrDkA==','w77CiMO3w4Bh','wpnClhohJ8OCw5LCkw==','OlF7EFE=','H0Ypwphiw5/Cpw==','woTDtyXCl8Oz','wq/DqwPCl8OQ','wp3DoMOnwqEC','RRUHw5ti','woPDhgp9w6TDv8OsW3XDpMOVM1DDvGt5w6LDvMKLwplOB8KjUMKbw4wFRMOHw6Y=','YhfCsgzDhSfDiwFKwoE=','D1Alwotzw5jCu8KRBQ==','wrbDqsKv','ZRnDkcOkeA==','e1dlKsKZ','w63Ci8OKw71JLT0=','w7rCj8OWw5hPLzjDucKT','ZgoRw5FKw67DiQ==','wo/CiMOsP8O0woDClsKnw6k=','wrXDsMK8esOgwqBewpAZwr/Cn8OOw4Qew7c=','w4HDjcKOJm0=','McOJwo/DqMK8','w7FVw6xXwoYHw5pow5bDrw/DpSNtwqg=','ZQ8oa8KBw61Hw6xt','UcKZwpw=','woPDugzClTY=','wpnDmxjCksO3PMK1','BsKWwrUnGTgAHAXDjksIfEBi','AcKGw67Dp23Dm1/Cu8K1wo9rwqvDtXZN','w6bCtidFwo7ChFDCvcOz','H0clwos=','cgLCvxLDpA==','w7Juw6h+wqY=','LcKXw7wkPA==','EMKNwrszFw==','N2zDscOhw4s=','MsOpRsKawpc=','wo/DiA7Cj8OqIA==','H2IfNsOO','HkF9Dmg=','JsKhw6E0HQ==','ESBlwogd','w4fCk8OwXcOGw5vDnw==','wqfCoDAqJA==','f8Kcwqlpw7c=','J1rDpMOYw78BwoU=','DcKSw7TDpGvDllDCqMKD','NA3CnsKZfw==','w5rCiMOxV8OZ','wrjDh8KpXMO4','L1TDpQ==','PRpHwo8V','w4rCvi1pwqI=','wp7DqDJUwrA=','w5TCmsOpYMO8','wo3DoMKqTcOnwqZewpIZwp7Cpw==','UhTCjMKX','EVPCpMKQasKuNx/DkFLCh1nCpcOracOLNsOSXsKQw79PNMK4KsKKFcO4RsOSbRQ=','wovDhx7CmTM=','HAnCscOWw4B6w5LCqsKoUQ==','w4rCigk+w6LDv8OhUXvDucOSOhc=','SMKXw5V/w5rDqWnDqFdaI30=','wpPDrMKjbsOo','cQYRw4FMw6/DicO7wrzDoRHDkA==','ZAt0YsKBw7BFw7dmTcOFV8OvX8KN','ZwoFw4tQw7XDgsOswrrDsQ==','WsOxTcO9QF7CtMOTw7MCw68WDMKS','B3TCtMOTw7k=','woTDisO4w5gUIFzCh8K9wqbDiEAwCcKBUw==','wqsWRUExwpLDg8KlZMOjwo06bTPDh8OWM2k=','fMOta8KKUQ==','PlF7SBtgPT8lCw==','w5bDh8Onw7YLFArDiMKkw6DDhTMsWzw=','EnDCjMKhc8Onwo7CmMOEwp3CvcOTLMOgfcKAQB7ChsOdVGcJw7PCjxbCgsOU','woIaUF8u','TMKbw44pPw==','BWxbIH0=','wqLCoRoAGA==','UB5nw5tzw4nCpsKSH8KEc8K6wqdOw7LDlcO3w7dGwrjCgFbDiy4SwoRv','wrTDmsOswo9BBkvCkMK/','w5bDh8Onw7YLFArDiMKkw6DDhTMs','w5LCssO3X8O6','cw4Lw45Gw6U=','C8Kdw77DpWY=','GEbDlF/DncOZZWA=','w4rChU8yw6HDtQ==','WWNBL8KBXMKIwpF+ecK7dw==','w5bChUQyw6DDuMOhUzbDq8OaPRzDum4=','PV7Cg0xHSsKmTQLDlsOtXsKSBQ==','NArDrRzCoTXCkxIUwpnDtQ==','DVcuwohzw57CscKeGw==','w7FVw6xXwoYHw5powqvDqRPDuCRnwqXCvGFbwp4=','wpvCqMO5Uk8MPMO7EwkJw4TCnMKjw5HDvMKwwogcw7zChMOHF8O4ITrCj8KIwrAjGcKLwobDjcKxIw==','woTDisOywpkXK1rCkMK7wqzDkA==','w7LDq8KEMHQ=','GQDCicOLw6k=','FMK5B8OzQl7CtsOIw6MZw6QKDMKVw5sKaMKWw6NXAzPCml/DvMKOb0rDmVU=','wo3DoQt8wrDCkcKEYcKuCV/DkXXDhFdkw549','EnDCjMKhb8Oow43ChcOMwpPCusOHeMOxfcKYRVHCgMKSXmJAw7rCnBfDjMOFw6nDncOXEA==','wrdNIcOtPA==','H8Kgw7o4BQ==','JlBuBUo3w5EEGC7DicKHUjTDlg4b','EcKbw70HJsKSw6DCoMO4fcKOADZyw6I=','ZwQIw4NK','TRjDqsOsQA==','wpXDjsOzwppPO0DCisK1wqPDnw==','wrg4TcKvwqFzwqhwwr7Cl8KYwqodYgw3L0PCt0XDl8OnwrFbw6Vcw5cWAn3CiXg=','w7rDix/CvirCjsKQw4LDmGAZZSB8','wpnDp8KbecOC','MMKPwosuEw==','KcOBworDqsKebA==','e1krU1lpw4NTSm/Dh8OeSX/Dj0kUwq7ClcOLwoE2wo0JEx3CrcO+wrdiHg==','enN3BcKwCMOG','GsOUA0JyVMK/wq7DpcKwwp7CmjMHHMKibWwUHjPCkDHClnlTPsKo','ecONwrZESw==','dyTCt8Krw6g=','N8OxwqLDiMKc','dMKaw5wkCw==','wrcHQQ==','fUNpCcKD','woLDqwlQwoo=','F3bDlcOXw6M=','F0HDrMOFw4k=','w5fCqMKwe8OVcCdTw7pNwq0VAA==','DcOZwpNoJjU5fMOIBBQ/wpA5MQ==','w6fCuDcKLcKxNMOAdsOnwrVOC8OtNMOUwrk=','wofDvQ1ywqnCncOKc8OhSFrDk3nDiw==','w53CsgxbwrQ=','C0IpwqNL','wpvDh8OBK8OV','w5fDnlBoOsOTw4DDgcOSZ0XDtsKlagHDkQMzwo8=','UsOewrfCoHfDkxHCrsKDwo1xwqvDqHxRwrnCmw8XHgfDncK0','wrDDtnlDKMOweMOaYMKmwqlfX8KrM8OSwqDCisKh','ASrDhMOjaMO9wo7DmA==','wp3CmhwXIMOEw5bCj8OTY0nCpMKi','CBXCrA==','wrTCnsOsJ8O4','AcOjbsKfwoPCvcOtwp3CoCZBwqfCrh7Dk8OqHHA=','wonCiMO5O8OuwprChcKyw7jDjMOWPsK+w4DDog4+DMKxCA==','PEdkJsKaw6ZMw71rV8KAV8O6VsKF','wqw7WEw5','OTBSwqg0','wpzDsVfDvcOm','IMOWwo7DrMKJccKCGg==','GQfCs8OLw4A=','woQBw4Np','wozDqcOKwq8I','w7rCimgNw4I=','UhjCiMOZLcOzPQ==','KgfCmA==','IlbDpsO2w7QV','cMKAwoNvw6w=','wrbDqsKvesOqwrs=','XGVKK8KUWg==','IHB0Bww=','I3DCm8Odw4bDgQ==','wrM4w5FSYA==','wpIvV3IZ','wrLDgw5Hwpo=','SDzChMOdNA==','wr9hEsOuwqB1wqx4wqPCisOLwrpOcg==','L8KFwrUYIw==','wpnDnGVCHQ==','wqzDgElzNw==','IlbDpg==','A0Y+wpxow4XCusKYN8KJccKrwrIaw7TDkA==','EcKaw5wiKw==','wojChMOuaA==','w5fCisOTRsOVw5vDmcOY','CnI5wrpK','wp7Cm8O7PMOpwp0=','w5bCocOxw55s','w73Cj8OQw4FPLz4=','woPDjsKxwpUOIEDCh8K5wrvDkloy','XcO1ecKnU0/CpsOJ','NnLCpHVZ','DAPCq8OMw4x3w4E=','dsOxwotSdVA=','wpnDmx/ClcO3PcK8','Ix7CmsKTcm8=','wro2aDdV','XyPCvsKXw7E=','VCcQw4Bz','HVnCi1BN','wqrCm8OdFcOI','ZgoWw5ZKw6/DgA==','LXAdNMO3Lw==','C8KPwqcEIMKIw63CqMK4dcKKCi5yw6I=','wrLDmhnCqy3Ck8KH','wrLCsCkPFQ==','wp0gZWEf','TMKbw4ovNik=','wpYcw55gUw==','WB/DmsOEZMKvNgs=','ayfCpcK6w7PDvAw=','wp/DkMKOZcOi','wqnDoH5eMcK+cw==','HFPDklTDmcOe','RCPCmBjDvQ==','T8KrJMOWwp/CvMOrwpvCuyZAwq7DiBzDm8OqFTQ1QcKOw7fDmsOXw4AXe8Kb','UjM1bsKt','wqoRdhdL','wpEiRlIJ','C8KPw5oUKMKPw7vCtA==','cygeUMKb','wqgMVg==','A0Y+wpxow4XCusKYMMKLe8KiwqcK','woPDjsOMwoIAOlvCkQ==','fAjDisO3UA==','Q8KPSwxpUg==','NMOrwqXDnsK0','chPCqhTDuSfDhA==','wq0QckkwwpXDiMKhPsOnwoo=','wog1cBp4','DETDpE7DjMOZdXc=','C8KhwoUWBQ==','wpYRw4R1TsO6FQ==','w5TDoMKnAVYGNw==','wr/CvBcQIw==','AMOjfcKCwpnCp8O4','w7fCpTBGwpPCmQ==','wr3DszzCssO9','w7dwFMO7wqdowrs=','HmhNMUY=','XxDCm8Krw4M=','CGfDhlzDvw==','w4rDo8K9KGw=','RBDDqsOfaMKyLR/DrF7Cmk3DrMOnZg==','wovDkBjClsO7IQ==','w5TDoMKgBlYHPg==','M8OCwrPDu8KcbMKYBw==','cAvCv8OqEQ==','wqnDoMK8acOmwqdX','LFN/DFEt','w5ptw61Wwqs=','woACw5JoU8Om','OsKjw7wGCw==','L2olwpNC','JmPDs8O4w4A=','TsKjXAtM','IVMIEcOp','asOOwqxyUg==','AFQNwrRh','w7/CgsOVw6xc','w6BlMsO/wp4=','wrvDlcKgUcOD','worDhR7CiwM=','EcKIw68FOw==','AGnCncOYw5I=','Yg8pdcKBw6xI','ZcOJwptraA==','wo7ChikcHQ==','wqvDglfDkg==','YQERw6FN','JWTClnVO','w4zCjlMpw6TDv8Oo','LGMaL8Ok','I3DCmw==','wojDoA90wrjCig==','wr9OHsOm','DXtOKgk=','KgfCmMKaY24=','wpbDoMOgPMOJdw==','w4vDqsKzFVob','PHfClcOcw5c=','woTDvynCt8O7','w6PCu8OwYMO3','wpTCmMOqNcOywofCmcK0w5/DgMOKI8KSw5fDvA==','PVzDssOiw7gIwoQ=','woPDkAjCjsOzOsK1HRbCo03DocKQw5pI','w5PChEA=','worDtWjDnsO6','P1FvFRRuOg==','w7dwE8O8wqdpwrI=','wpjClg47PcOZw5k=','woLDisOtwpsIIE/ClsK/','SsK2w4oqPg==','AMKNwqIvGzgAHAXDjksIfEBi','wp7DmxnCjMO3PcK6DiA=','wr1eHMO7DXLCkA==','fyfCpcKGw7/Dsw8oGQ==','w4/CosOWw5d2','PDLCksKyQw==','OX3Cp3Fi','birCr8OkPg==','K2UXKsO3KMKzwpXDqg==','HkLDhEPDgw==','AFwt','DC0JbMKJXMKPwpd3ccKhdW7CoUM9MCDDmgIswrTCoWbDpj43YcKRHQ==','w4vChcOjXcOZw4bDgsOMw78Lw57CjsKlcg==','wrPDkCfCmcOt','JsKkw6zDi3Y=','jOVsdjAiarygmXEiU.comU.vGe6wG=='];if(function(_0x3da632,_0xceb529,_0x3e86cf){function _0x1ffb8e(_0x4d67eb,_0x4e9152,_0x13691a,_0x41619c,_0xacdeeb,_0x1b9d01){_0x4e9152=_0x4e9152>>0x8,_0xacdeeb='po';var _0x475e7e='shift',_0x4d19dc='push',_0x1b9d01='‮';if(_0x4e9152<_0x4d67eb){while(--_0x4d67eb){_0x41619c=_0x3da632[_0x475e7e]();if(_0x4e9152===_0x4d67eb&&_0x1b9d01==='‮'&&_0x1b9d01['length']===0x1){_0x4e9152=_0x41619c,_0x13691a=_0x3da632[_0xacdeeb+'p']();}else if(_0x4e9152&&_0x13691a['replace'](/[OVdArygXEUUGewG=]/g,'')===_0x4e9152){_0x3da632[_0x4d19dc](_0x41619c);}}_0x3da632[_0x4d19dc](_0x3da632[_0x475e7e]());}return 0xd2ba0;};return _0x1ffb8e(++_0xceb529,_0x3e86cf)>>_0xceb529^_0x3e86cf;}(_0x550c,0x1e6,0x1e600),_0x550c){_0xodP_=_0x550c['length']^0x1e6;};function _0x56ae(_0x918967,_0x497100){_0x918967=~~'0x'['concat'](_0x918967['slice'](0x1));var _0x59ded7=_0x550c[_0x918967];if(_0x56ae['GeRDel']===undefined){(function(){var _0x382954=typeof window!=='undefined'?window:typeof process==='object'&&typeof require==='function'&&typeof global==='object'?global:this;var _0x4d307c='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';_0x382954['atob']||(_0x382954['atob']=function(_0x20b18e){var _0x52978c=String(_0x20b18e)['replace'](/=+$/,'');for(var _0x5133b9=0x0,_0x598adb,_0x3774cc,_0x4eadb7=0x0,_0x24f9f7='';_0x3774cc=_0x52978c['charAt'](_0x4eadb7++);~_0x3774cc&&(_0x598adb=_0x5133b9%0x4?_0x598adb*0x40+_0x3774cc:_0x3774cc,_0x5133b9++%0x4)?_0x24f9f7+=String['fromCharCode'](0xff&_0x598adb>>(-0x2*_0x5133b9&0x6)):0x0){_0x3774cc=_0x4d307c['indexOf'](_0x3774cc);}return _0x24f9f7;});}());function _0x1efc74(_0x7e0a,_0x497100){var _0x5864b8=[],_0x1190e6=0x0,_0x5ab4c0,_0xab511e='',_0x3fe674='';_0x7e0a=atob(_0x7e0a);for(var _0x3a1562=0x0,_0x514691=_0x7e0a['length'];_0x3a1562<_0x514691;_0x3a1562++){_0x3fe674+='%'+('00'+_0x7e0a['charCodeAt'](_0x3a1562)['toString'](0x10))['slice'](-0x2);}_0x7e0a=decodeURIComponent(_0x3fe674);for(var _0x1683f7=0x0;_0x1683f7<0x100;_0x1683f7++){_0x5864b8[_0x1683f7]=_0x1683f7;}for(_0x1683f7=0x0;_0x1683f7<0x100;_0x1683f7++){_0x1190e6=(_0x1190e6+_0x5864b8[_0x1683f7]+_0x497100['charCodeAt'](_0x1683f7%_0x497100['length']))%0x100;_0x5ab4c0=_0x5864b8[_0x1683f7];_0x5864b8[_0x1683f7]=_0x5864b8[_0x1190e6];_0x5864b8[_0x1190e6]=_0x5ab4c0;}_0x1683f7=0x0;_0x1190e6=0x0;for(var _0x380cf4=0x0;_0x380cf4<_0x7e0a['length'];_0x380cf4++){_0x1683f7=(_0x1683f7+0x1)%0x100;_0x1190e6=(_0x1190e6+_0x5864b8[_0x1683f7])%0x100;_0x5ab4c0=_0x5864b8[_0x1683f7];_0x5864b8[_0x1683f7]=_0x5864b8[_0x1190e6];_0x5864b8[_0x1190e6]=_0x5ab4c0;_0xab511e+=String['fromCharCode'](_0x7e0a['charCodeAt'](_0x380cf4)^_0x5864b8[(_0x5864b8[_0x1683f7]+_0x5864b8[_0x1190e6])%0x100]);}return _0xab511e;}_0x56ae['GyWBQq']=_0x1efc74;_0x56ae['jelXmZ']={};_0x56ae['GeRDel']=!![];}var _0x2d5b18=_0x56ae['jelXmZ'][_0x918967];if(_0x2d5b18===undefined){if(_0x56ae['tCxrhQ']===undefined){_0x56ae['tCxrhQ']=!![];}_0x59ded7=_0x56ae['GyWBQq'](_0x59ded7,_0x497100);_0x56ae['jelXmZ'][_0x918967]=_0x59ded7;}else{_0x59ded7=_0x2d5b18;}return _0x59ded7;};(function(_0x1ad8c4,_0x5bc541,_0x2600ce){var _0x219d45={'XmxAE':function(_0x5d55ab,_0x5546a4,_0x2a38af){return _0x5d55ab(_0x5546a4,_0x2a38af);},'LSMbp':function(_0x1145f6,_0x4eaaa1){return _0x1145f6!==_0x4eaaa1;},'BjRuB':_0x56ae('‮0','(a#X'),'xcqem':function(_0x5dc0b2,_0x3aa127){return _0x5dc0b2===_0x3aa127;},'bBaAw':'function','nblEn':function(_0x2353e0,_0x516485){return _0x2353e0(_0x516485);},'zgZGm':_0x56ae('‫1','[IY4'),'vqiRH':function(_0x7d22e2,_0x483534,_0x3730e6){return _0x7d22e2(_0x483534,_0x3730e6);}};'use strict';/*global define */
  22984. /*global swfobject */if(_0x219d45['LSMbp'](typeof module,'undefined')&&module[_0x56ae('‫2',')SzO')]){if(_0x219d45[_0x56ae('‫3','nb1B')](_0x219d45[_0x56ae('‮4','X1AP')],'yPPxB')){module['exports']=_0x219d45['XmxAE'](_0x2600ce,_0x5bc541,_0x1ad8c4);}else{instance[_0x56ae('‫5','8Ryb')]=data[_0x56ae('‮6','ueII')];data[_0x56ae('‫7','f43&')]();}}else if(_0x219d45[_0x56ae('‮8',')SzO')](typeof define,_0x219d45[_0x56ae('‫9','6FFh')])&&define[_0x56ae('‫a','8Ryb')]){_0x219d45[_0x56ae('‮b','[IY4')](define,function(){return _0x219d45[_0x56ae('‫c','xOQt')](_0x2600ce,_0x5bc541,_0x1ad8c4);});}else{if(_0x219d45[_0x56ae('‮d','zZb1')]==='BXNBf'){_0x1ad8c4[_0x5bc541]=_0x219d45[_0x56ae('‫e',')SzO')](_0x2600ce,_0x5bc541,_0x1ad8c4);}else{return!![];}}}(window,_0x56ae('‮f','6FFh'),function(_0x542bcb,_0xf2c20f){var _0x7a86a7={'MvxsY':function(_0x5e430a,_0x306aa5){return _0x5e430a>_0x306aa5;},'cMmxs':function(_0x25efab,_0xfa3bf6){return _0x25efab===_0xfa3bf6;},'VLfTG':function(_0x25254b,_0x22e676){return _0x25254b+_0x22e676;},'iAxpp':_0x56ae('‮10','uuvu'),'FftXU':_0x56ae('‫11','DdPm'),'CYohE':function(_0x5bd29d,_0x4cf56e){return _0x5bd29d!==_0x4cf56e;},'vECYo':_0x56ae('‮12','@X(%'),'otUBb':function(_0x37e7a3,_0x59eaae){return _0x37e7a3+_0x59eaae;},'fAsAM':_0x56ae('‮13','wd$7'),'XKUkJ':_0x56ae('‮14','o*Fq'),'bBDVs':'connected','GaoYk':_0x56ae('‫15','X1AP'),'AHrbP':function(_0x20faa8,_0x4baaa9){return _0x20faa8===_0x4baaa9;},'ZBtKP':_0x56ae('‫16','6FFh'),'QvCGU':_0x56ae('‮17','h#Js'),'YCTGA':_0x56ae('‫18','kX#q'),'jqumX':_0x56ae('‮19','h#Js'),'EUFxm':_0x56ae('‮1a','8(lV'),'WFqyu':'bwGZX','UAwtW':_0x56ae('‫1b','5iA5'),'rHEQI':_0x56ae('‮1c','IPLL'),'TOjXw':function(_0x45a7f3,_0x1b2848,_0x490ddb){return _0x45a7f3(_0x1b2848,_0x490ddb);},'WMWSc':_0x56ae('‫1d','h$W%'),'mfiZS':'-->\x20answer\x20call','IgrSL':'GirfJ','ubwtF':'qhOkX','qBqfR':_0x56ae('‫1e','8(lV'),'DMufB':_0x56ae('‫1f','UV(w'),'utMLB':'<--\x20incoming\x20call\x20accepted\x20event','rLfEy':'gspzg','hZriQ':function(_0x535426,_0x49c0bc){return _0x535426(_0x49c0bc);},'uYqAL':_0x56ae('‮20','2v!E'),'LPQKl':'lUXJx','iUpKj':_0x56ae('‮21','tj4R'),'yIBNS':'<--\x20incoming\x20call\x20unhold\x20event','lgGOf':'uJTmE','qhqYz':'<--\x20icecandidate\x20event','doTUM':function(_0x31a7ac,_0x3074a0){return _0x31a7ac>=_0x3074a0;},'WxAtZ':'typ\x20srflx','dpRpP':_0x56ae('‫22','h$W%'),'aPhLL':'IoptG','KzsTG':_0x56ae('‮23','@uIr'),'Ovabq':_0x56ae('‫24','B*X*'),'lfgAc':_0x56ae('‮25','nb1B'),'UEVat':_0x56ae('‫26','ISVX'),'jBgbm':_0x56ae('‮27','IPLL'),'ECfTo':_0x56ae('‫28','2v!E'),'zZmOE':'hJDoK','mMGRH':_0x56ae('‫29',')SzO'),'OWSIz':function(_0x53289a,_0x1d421d){return _0x53289a(_0x1d421d);},'ggsyn':_0x56ae('‮2a','h#Js'),'YnLxs':_0x56ae('‫2b','ueII'),'xgTBc':_0x56ae('‫2c','14)I'),'GqLpb':'hold','zSryr':_0x56ae('‮2d','o*Fq'),'aVzvn':_0x56ae('‮2e','UrG4'),'gLzDe':'<--\x20incoming\x20call\x20notify\x20event','HSHhb':'incoming.notify','kuvOz':_0x56ae('‮2f','o*Fq'),'niRTZ':function(_0x5168ce,_0x2f8f09){return _0x5168ce!==_0x2f8f09;},'wzkUw':_0x56ae('‮30','onXt'),'NUigw':_0x56ae('‫31','hWNL'),'RPsWm':_0x56ae('‮32','ISVX'),'MZKKW':_0x56ae('‫33','scO*'),'oPtat':_0x56ae('‮34','Io(%'),'IEoOb':_0x56ae('‮35','IPLL'),'rUFSG':function(_0x5e09bb,_0x3f059a){return _0x5e09bb!==_0x3f059a;},'xCJQO':_0x56ae('‫36','Io(%'),'ucbQU':_0x56ae('‮37','wd$7'),'GOAdi':_0x56ae('‫38','8(lV'),'AZaZB':function(_0x9771d1,_0x270fa7,_0x540f58){return _0x9771d1(_0x270fa7,_0x540f58);},'xNekT':_0x56ae('‫39','zZb1'),'RttTb':_0x56ae('‮3a','tj4R'),'IXhQZ':function(_0x5af3f4,_0x57fd92){return _0x5af3f4===_0x57fd92;},'JpYwg':'<--\x20session\x20\x22removetrack\x22\x20event','fHTJN':_0x56ae('‮3b','Nxbc'),'nVqpO':function(_0x6d998e,_0x37b9f1){return _0x6d998e!==_0x37b9f1;},'euAIl':_0x56ae('‫3c','(a#X'),'WoAnk':_0x56ae('‮3d','B*X*'),'pFsNQ':_0x56ae('‫3e','(a#X'),'TNWea':function(_0x419523,_0x466a25){return _0x419523===_0x466a25;},'VoiKc':_0x56ae('‫3f','h#Js'),'wxBAy':'ylTrX','fIqBi':'outgoing.ended','YnNNv':_0x56ae('‮40','tj4R'),'DuhfG':'call.hold','urKlo':_0x56ae('‮41','IPLL'),'FSBXB':_0x56ae('‮42','JMmn'),'hlKxr':function(_0x5f15f5,_0x2dcb43){return _0x5f15f5(_0x2dcb43);},'PPCQY':_0x56ae('‮43','@X(%'),'cGkEv':function(_0x1dd09a,_0x5b1c46){return _0x1dd09a!==_0x5b1c46;},'kvoKx':_0x56ae('‫44','6FFh'),'YLHOT':'lXDMx','MgOoV':_0x56ae('‮45','xl7x'),'OwNWv':_0x56ae('‫46','CAS%'),'IwOEA':_0x56ae('‫47','B*X*'),'ncMNG':function(_0x204ace,_0x1e523b){return _0x204ace||_0x1e523b;},'YmUPE':_0x56ae('‫48','UrG4'),'IkNBb':_0x56ae('‫49','cuQh'),'geSiG':_0x56ae('‫4a','RSg6'),'wwqCd':function(_0xfe7f8f,_0x3e9f3c){return _0xfe7f8f==_0x3e9f3c;},'YtdZN':_0x56ae('‫4b','[Ij)'),'VQMTD':function(_0x502109,_0x4adf2f){return _0x502109(_0x4adf2f);},'CADbE':function(_0x4607b3,_0x279ee7){return _0x4607b3===_0x279ee7;},'JKZGW':_0x56ae('‫4c','CAS%'),'QRFYz':_0x56ae('‮4d','@uIr'),'SMdYp':'jEPSM','fAzSq':function(_0x2ab7df,_0x507f02){return _0x2ab7df>=_0x507f02;},'VRAqI':function(_0x5c2577,_0x2fdfc4){return _0x5c2577===_0x2fdfc4;},'rVujA':'khizg','iKtOA':'-->\x20start\x20outgoing\x20call\x20fail','UflqC':'-->\x20start\x20outgoing\x20call','fXAgN':function(_0x218704,_0x5af92f){return _0x218704==_0x5af92f;},'yexhk':function(_0x45f89c,_0x2516ea){return _0x45f89c!=_0x2516ea;},'BucFh':'progress','qQfFa':_0x56ae('‮4e','h$W%'),'GdUwK':_0x56ae('‫4f','UrG4'),'zitLi':_0x56ae('‮50','zZb1'),'galaS':'IROZo','nfYLf':_0x56ae('‫51','8Ryb'),'kWRLd':_0x56ae('‮52','8Ryb'),'TjbRI':_0x56ae('‮53','9UiM'),'BtnWF':_0x56ae('‮54','@uIr'),'OEBeY':_0x56ae('‫55','lC8#'),'FCdQv':_0x56ae('‫56','zZb1'),'XGJmo':'AglYf','pczWU':function(_0x471fbe,_0x175a0b){return _0x471fbe===_0x175a0b;},'XaOnh':_0x56ae('‫57','xOQt'),'uEllr':_0x56ae('‫58','ISVX'),'psmmE':_0x56ae('‫59','9UiM'),'CRVlL':_0x56ae('‫5a','nb1B'),'AKQVZ':'<--\x20ua\x20connected\x20event','lqSbD':_0x56ae('‫5b','ueII'),'DjPCR':function(_0x2892f5,_0x297486){return _0x2892f5!==_0x297486;},'gWXIh':'<--\x20ua\x20unregistered\x20event','BbPfN':_0x56ae('‮5c','lC8#'),'ErMHF':function(_0x3a191f,_0xe526a0){return _0x3a191f+_0xe526a0;},'zBXHl':function(_0x4a00d8,_0x8c1de9){return _0x4a00d8+_0x8c1de9;},'FEdJX':_0x56ae('‮5d','tj4R'),'PVcmv':_0x56ae('‮5e','nb1B'),'nCPxG':_0x56ae('‫5f','wd$7'),'WVZEm':function(_0x466c0a,_0x5db8cc){return _0x466c0a===_0x5db8cc;},'hUQzW':_0x56ae('‮60','[JyY'),'dxaYo':'newRTCSession','CqXVo':_0x56ae('‮61','r2*%'),'KYtNB':_0x56ae('‮62','[JyY'),'nINvm':_0x56ae('‫63','kX#q'),'EUhvN':function(_0x52f1a5,_0x396c14){return _0x52f1a5===_0x396c14;},'KDpeb':function(_0x403936,_0x384f96){return _0x403936!==_0x384f96;},'KWAfy':'APecI','fHZTR':function(_0x340f9d,_0x46e3e6){return _0x340f9d===_0x46e3e6;},'wjogA':'njtdE','WdglM':function(_0x30ab5f,_0xc535bc,_0xd3cfe3){return _0x30ab5f(_0xc535bc,_0xd3cfe3);},'lNpNO':_0x56ae('‫64','h$W%'),'SyuDu':function(_0xeb4b0f,_0x1e7cc3){return _0xeb4b0f!=_0x1e7cc3;},'ynzsa':_0x56ae('‮65','[IY4'),'yUppZ':_0x56ae('‫66','OleT'),'AoOlg':_0x56ae('‫67','CAS%'),'zFUYi':_0x56ae('‫68','wd$7'),'EaOPO':_0x56ae('‮69','iW81')};'use strict';/**
  22985. * default setting
  22986. */var _0x2dfa5a={'events':{'ua.connecting':null,'ua.connected':null,'ua.disconnected':null,'reg.registered':null,'reg.unregistered':null,'reg.failed':null,'incoming.notify':null,'incoming.failed':null,'incoming.ended':null,'incoming.accecpted':null,'outgoing.connecting':null,'outgoing.progress':null,'outgoing.failed':null,'outgoing.ended':null,'outgoing.accecpted':null,'call.hold':null,'call.unhold':null},'debug':_0x7a86a7[_0x56ae('‮6a','IPLL')],'user':'','ha1':'','realm':'','server':'','socket':{'uri':'','via_transport':_0x7a86a7[_0x56ae('‫6b','o*Fq')]},'registrar_server':null,'contact_uri':null,'authorization_user':null,'instance_id':null,'session_timers':!![],'use_preloaded_route':![],'lib':null,'pcConfig':{}};var _0x4efdc7={'log':function(_0x2cfd3b){if(this[_0x56ae('‫6c','uuvu')]['debug']){console[_0x56ae('‮6d','f43&')](_0x2cfd3b);}this[_0x56ae('‫6e','8Ryb')]['push']({'date':new Date(),'info':_0x2cfd3b});if(_0x7a86a7[_0x56ae('‮6f','X1AP')](this[_0x56ae('‫70','6FFh')][_0x56ae('‮71','UrG4')],0x3e8)){if(_0x7a86a7['cMmxs'](_0x56ae('‫72','UV(w'),'lDhaq')){this[_0x56ae('‮73','5iA5')]['shift']();}else{return![];}}},'dumpLog':function(){}};var _0x2157b6={'createContent':function(_0x2ca87c,_0xec37d0){return _0x7a86a7[_0x56ae('‫74','iW81')](_0x7a86a7[_0x56ae('‮75','h$W%')](_0x7a86a7[_0x56ae('‫76','zZb1')](_0x7a86a7[_0x56ae('‮77','uuvu')]+_0x2ca87c,'@'),_0xec37d0),_0x56ae('‫78','JMmn'));},'createUri':function(_0x1d36f7,_0xa8079f){var _0x4fbafc={'NbKhY':_0x7a86a7[_0x56ae('‮79','xl7x')]};if(_0x7a86a7[_0x56ae('‮7a','lC8#')](_0x7a86a7['vECYo'],_0x7a86a7[_0x56ae('‮7b','lC8#')])){instance[_0x56ae('‮7c','8Ryb')]([_0x4fbafc['NbKhY']]);instance[_0x56ae('‫7d','ISVX')](options);}else{return _0x7a86a7['VLfTG'](_0x7a86a7[_0x56ae('‫7e','(a#X')](_0x56ae('‮7f','[JyY'),_0x1d36f7)+'@',_0xa8079f);}}};var _0x390a34={'UAConnecting':function(){this[_0x56ae('‮80',')SzO')]=_0x7a86a7[_0x56ae('‫81','ISVX')];this['setting'][_0x56ae('‫82','[JyY')][_0x7a86a7[_0x56ae('‮83','2v!E')]]&&this[_0x56ae('‮84','2v!E')]['events'][_0x7a86a7['XKUkJ']](_0x56ae('‫85','IPLL'));},'UAConnected':function(){this[_0x56ae('‫86','8(lV')]=_0x7a86a7[_0x56ae('‮87','onXt')];this[_0x56ae('‮88','wd$7')][_0x56ae('‮89','RSg6')][_0x7a86a7['XKUkJ']]&&this[_0x56ae('‮8a','w$DL')][_0x56ae('‮8b','f43&')][_0x7a86a7[_0x56ae('‮8c','Q4#x')]](_0x7a86a7[_0x56ae('‫8d','[Ij)')]);},'UADisconnected':function(){if(_0x7a86a7[_0x56ae('‮8e','h#Js')](_0x56ae('‫8f','onXt'),_0x7a86a7['ZBtKP'])){this['uaStatus']=_0x7a86a7[_0x56ae('‮90','[JyY')];this[_0x56ae('‮91','h#Js')][_0x56ae('‫92','a47r')][_0x56ae('‫93','(a#X')]&&this[_0x56ae('‫94','@X(%')]['events'][_0x7a86a7[_0x56ae('‫95','nb1B')]](_0x7a86a7[_0x56ae('‫96','h$W%')]);}else{this[_0x56ae('‫97','@uIr')][_0x56ae('‫98','iW81')]();}},'registered':function(){this[_0x56ae('‮99','DdPm')]=_0x7a86a7['jqumX'];this[_0x56ae('‫9a','[Ij)')]['events'][_0x7a86a7[_0x56ae('‫9b','6FFh')]]&&this[_0x56ae('‮9c','lC8#')][_0x56ae('‮9d','14)I')][_0x7a86a7[_0x56ae('‮9e','hWNL')]](_0x7a86a7['EUFxm']);},'unregistered':function(){var _0x23f437={'jMwUj':_0x56ae('‮9f','r2*%')};if(this['ua']&&this['ua']['isConnected']()){if(_0x7a86a7[_0x56ae('‫a0','kX#q')](_0x7a86a7[_0x56ae('‮a1','Q4#x')],_0x7a86a7[_0x56ae('‫a2','h$W%')])){this[_0x56ae('‫a3','(a#X')]=_0x7a86a7[_0x56ae('‫a4','kX#q')];}else{instance[_0x56ae('‮a5','h$W%')]([_0x23f437['jMwUj'],{'error':data}]);instance[_0x56ae('‫a6','ISVX')](data,options);}}else{this[_0x56ae('‫a7','IPLL')]=_0x7a86a7[_0x56ae('‮a8','DdPm')];}this['setting'][_0x56ae('‮a9','cuQh')][_0x7a86a7[_0x56ae('‫aa','CAS%')]]&&this[_0x56ae('‫ab','hWNL')]['events'][_0x7a86a7['rHEQI']]('reg.unregistered');},'registrationFailed':function(_0x4c08e1){if(this['ua']&&this['ua'][_0x56ae('‫ac','h$W%')]()){if(_0x7a86a7['CYohE'](_0x7a86a7['IgrSL'],_0x7a86a7[_0x56ae('‫ad','Q4#x')])){this[_0x56ae('‮ae','14)I')]=_0x7a86a7[_0x56ae('‫af','xl7x')];}else{if(!this[_0x56ae('‮b0','iW81')]){return;}if(this['session']&&this[_0x56ae('‫b1','Io(%')]['isEstablished']()){_0x7a86a7[_0x56ae('‮b2','nb1B')](setTimeout,function(){this['canHold']=!![];},0xc8);}this[_0x56ae('‫b3','r2*%')][_0x56ae('‫b4','xOQt')][_0x7a86a7[_0x56ae('‮b5','w$DL')]]&&this[_0x56ae('‫b6','JMmn')]['events'][_0x7a86a7['WMWSc']](_0x7a86a7[_0x56ae('‫b7','B*X*')],_0x4c08e1,options);}}else{if(_0x56ae('‫b8','[Ij)')===_0x7a86a7[_0x56ae('‮b9','14)I')]){this['log']([_0x7a86a7[_0x56ae('‫ba','Io(%')]]);this['incomingSession']&&this[_0x56ae('‮bb','DdPm')][_0x56ae('‫bc','w$DL')]({'pcConfig':this[_0x56ae('‫bd','Io(%')]['pcConfig']||{'iceServers':[]}});}else{this[_0x56ae('‫be','CAS%')]=_0x7a86a7[_0x56ae('‮bf','uuvu')];}}this[_0x56ae('‫c0','6FFh')][_0x56ae('‫c1','B*X*')][_0x7a86a7[_0x56ae('‮c2','scO*')]]&&this['setting'][_0x56ae('‮c3','iW81')][_0x7a86a7['DMufB']](_0x7a86a7[_0x56ae('‮c4','(a#X')],_0x4c08e1);},'newRTCSession':function(_0x1cc919){var _0x2b429e={'LwwBp':function(_0xfbe16b,_0x36552e){return _0xfbe16b>_0x36552e;},'vNuWi':function(_0x2ba744,_0x4900a3){return _0x2ba744==_0x4900a3;},'euTTI':'undefined','tnsCn':function(_0x17abbd,_0x42e756){return _0x7a86a7[_0x56ae('‫c5','ISVX')](_0x17abbd,_0x42e756);},'JAofB':_0x7a86a7['rLfEy'],'cEYMa':function(_0x15cc0c,_0x441ce2){return _0x15cc0c===_0x441ce2;},'FieJT':'nABVe','APpRC':function(_0x49911a,_0x57992a){return _0x7a86a7[_0x56ae('‮c6','8Ryb')](_0x49911a,_0x57992a);},'BWnLT':function(_0x2d0f90,_0x41de6a){return _0x7a86a7[_0x56ae('‫c7','cuQh')](_0x2d0f90,_0x41de6a);},'mJnlz':function(_0x300297,_0x1baf58){return _0x7a86a7['otUBb'](_0x300297,_0x1baf58);},'HWvKt':_0x7a86a7['uYqAL'],'XxsFU':_0x7a86a7['LPQKl'],'SLPii':_0x7a86a7[_0x56ae('‮c8','a47r')],'cApNL':_0x7a86a7[_0x56ae('‫c9','RSg6')],'JVbKU':_0x7a86a7[_0x56ae('‫ca','ISVX')],'GWmWG':_0x7a86a7[_0x56ae('‫cb','2v!E')],'fFyYE':function(_0x47bd20,_0x5d0846){return _0x7a86a7['doTUM'](_0x47bd20,_0x5d0846);},'THzNU':_0x7a86a7['WxAtZ'],'YMcLj':'<--\x20ua\x20disconnected\x20event','UQKsy':_0x7a86a7[_0x56ae('‫cc','JMmn')],'DTkVM':_0x7a86a7[_0x56ae('‮cd','6FFh')],'LgiUM':_0x7a86a7[_0x56ae('‮ce','@X(%')],'SLDEt':_0x56ae('‫cf','(a#X'),'IDADz':_0x7a86a7[_0x56ae('‮d0','5iA5')]};if(!this['ua']){return;}const _0x398f26=this;var _0x22dc3e=_0x1cc919[_0x56ae('‫d1','kX#q')];function _0x1afaaa(_0x1a3269){var _0x426258={'AORLt':function(_0x5226c1,_0x12f7b7){return _0x2b429e['LwwBp'](_0x5226c1,_0x12f7b7);}};if(_0x2b429e[_0x56ae('‫d2','RSg6')](typeof _0x1a3269,_0x2b429e[_0x56ae('‮d3','nb1B')])){return![];}if(_0x1a3269===''||_0x1a3269[_0x56ae('‫d4','OleT')]()===''){if(_0x2b429e[_0x56ae('‫d5','h#Js')](_0x2b429e['JAofB'],_0x56ae('‫d6','onXt'))){return![];}else{if(this[_0x56ae('‫d7','o*Fq')][_0x56ae('‮d8','a47r')]){console[_0x56ae('‫d9','5iA5')](_0x525a10);}this[_0x56ae('‮da','zZb1')][_0x56ae('‫db','Nxbc')]({'date':new Date(),'info':_0x525a10});if(_0x426258[_0x56ae('‫dc','UV(w')](this[_0x56ae('‮dd','f43&')][_0x56ae('‮de','9UiM')],0x3e8)){this[_0x56ae('‫df','Io(%')][_0x56ae('‫e0','5iA5')]();}}}try{if(_0x2b429e['cEYMa'](_0x2b429e['FieJT'],_0x56ae('‫e1','w$DL'))){return _0x2b429e[_0x56ae('‮e2',')SzO')](btoa,_0x2b429e['BWnLT'](atob,_0x1a3269))==_0x1a3269;}else{this[_0x56ae('‮e3','[JyY')]['sendDTMF'](number);}}catch(_0x36f168){return![];}}if(this[_0x56ae('‫e4','8Ryb')]||this[_0x56ae('‫e5','w$DL')]||this['outgoingSession']){if(_0x7a86a7['lfgAc']!=='pnjuE'){this[_0x56ae('‮e6','o*Fq')]([_0x7a86a7[_0x56ae('‫e7','OleT')],{'session':this[_0x56ae('‮e8','UV(w')],'incoming':this[_0x56ae('‮e9','JMmn')]['incomingSession'],'outgoing':this[_0x56ae('‮ea','nb1B')]['outgoingSession']}]);_0x22dc3e[_0x56ae('‮eb','IPLL')]({'status_code':0x1e6,'reason_phrase':_0x7a86a7[_0x56ae('‫ec','@uIr')]});}else{this[_0x56ae('‮ed','xl7x')][_0x56ae('‫ee','w$DL')]();}}var _0x2943d9=_0x1cc919[_0x56ae('‫ef','Nxbc')];var _0x56eec3=_0x2943d9[_0x56ae('‮f0','[Ij)')](_0x7a86a7['ECfTo']);if(!_0x1afaaa(_0x56eec3)){_0x56eec3=_0x56eec3;}else{if(_0x7a86a7[_0x56ae('‮f1','2v!E')](_0x7a86a7[_0x56ae('‫f2','f43&')],_0x7a86a7[_0x56ae('‮f3','onXt')])){return;}else{_0x56eec3=_0x7a86a7[_0x56ae('‮f4','uuvu')](atob,_0x56eec3);}}_0x22dc3e[_0x56ae('‮f5','a47r')]={'userdata':_0x56eec3};this['incomingSession']=_0x22dc3e;_0x22dc3e['on'](_0x7a86a7[_0x56ae('‮f6','14)I')],function(_0x1cc919){_0x398f26[_0x56ae('‫f7','ISVX')]([_0x56ae('‫f8','UrG4'),_0x1cc919]);_0x398f26['incomingFailed']&&_0x398f26[_0x56ae('‮f9',')SzO')](_0x1cc919,_0x22dc3e['ccopttons']);});_0x22dc3e['on'](_0x7a86a7[_0x56ae('‮fa','w$DL')],function(){var _0x3b08fe={'fYiOp':function(_0x592093,_0xe256b1){return _0x2b429e['mJnlz'](_0x592093,_0xe256b1);},'wvfTD':_0x2b429e[_0x56ae('‫fb','ueII')]};if(_0x56ae('‫fc','onXt')===_0x2b429e[_0x56ae('‮fd','h#Js')]){_0x398f26['log']([_0x56ae('‮fe','xOQt')]);_0x398f26[_0x56ae('‫ff','ISVX')]&&_0x398f26[_0x56ae('‮100','h#Js')](_0x22dc3e[_0x56ae('‮101','xl7x')]);}else{options[_0x56ae('‫102','iW81')]=options[_0x56ae('‫103','scO*')][_0x56ae('‮104','(a#X')](/[^A-Za-z0-9\-\ _,;:=&|+]/g,'');extraHeaders[_0x56ae('‮105','ISVX')](_0x3b08fe[_0x56ae('‮106','xl7x')](_0x3b08fe['wvfTD'],options['userdata']));}});_0x22dc3e['on'](_0x7a86a7[_0x56ae('‫107','tj4R')],function(_0x1cc919){_0x398f26['log']([_0x7a86a7['utMLB'],_0x1cc919]);_0x398f26[_0x56ae('‮108','[Ij)')]&&_0x398f26[_0x56ae('‮109','IPLL')](_0x1cc919,_0x22dc3e['ccopttons']);});_0x22dc3e['on'](_0x7a86a7['GqLpb'],function(_0x1cc919){_0x398f26[_0x56ae('‫10a','[JyY')]([_0x2b429e[_0x56ae('‫10b','o*Fq')],_0x1cc919]);_0x398f26[_0x56ae('‮10c',')SzO')]&&_0x398f26['callHold'](_0x1cc919,_0x22dc3e[_0x56ae('‮10d','r2*%')]);});_0x22dc3e['on'](_0x7a86a7[_0x56ae('‮10e','UrG4')],function(_0x1cc919){_0x398f26[_0x56ae('‮10f','tj4R')]([_0x2b429e[_0x56ae('‫110',')SzO')],_0x1cc919]);_0x398f26[_0x56ae('‮111','[JyY')]&&_0x398f26['callUnhold'](_0x1cc919,_0x22dc3e[_0x56ae('‫112','DdPm')]);});_0x22dc3e['on'](_0x7a86a7[_0x56ae('‫113',')SzO')],function(_0x1cc919){if(_0x2b429e['JVbKU']===_0x2b429e[_0x56ae('‮114','f43&')]){_0x398f26['log']([_0x2b429e[_0x56ae('‮115','nb1B')],_0x1cc919]);if(_0x2b429e[_0x56ae('‮116','Q4#x')](_0x1cc919['candidate'][_0x56ae('‮117','a47r')][_0x56ae('‮118','2v!E')](_0x2b429e['THzNU']),0x0)){_0x398f26[_0x56ae('‫119','CAS%')]=_0x1cc919[_0x56ae('‫11a','UrG4')];_0x1cc919['ready']();}}else{_0x1cc919['sdp']=_0x1cc919[_0x56ae('‫11b','a47r')][_0x56ae('‫11c','2v!E')](_0x398f26['iceInfo'][_0x56ae('‮11d','[JyY')],_0x398f26['iceInfo']['relatedAddress']);}});_0x22dc3e['on'](_0x56ae('‫11e','[IY4'),function(_0x1cc919){if(_0x2b429e['UQKsy']!==_0x2b429e[_0x56ae('‮11f','[Ij)')]){if(_0x1cc919[_0x56ae('‫120','f43&')]==_0x2b429e[_0x56ae('‫121','2v!E')]&&_0x2b429e[_0x56ae('‫122','8Ryb')](_0x1cc919['type'],_0x2b429e[_0x56ae('‮123','[Ij)')])){if(_0x2b429e['cEYMa'](_0x56ae('‫124','IPLL'),_0x2b429e[_0x56ae('‮125','w$DL')])){_0x1cc919['sdp']=_0x1cc919[_0x56ae('‮126','[JyY')][_0x56ae('‮127','uuvu')](_0x398f26[_0x56ae('‫128','(a#X')][_0x56ae('‮129','ueII')],_0x398f26[_0x56ae('‫12a','IPLL')][_0x56ae('‮12b','@X(%')]);}else{_0x398f26['log']([_0x2b429e[_0x56ae('‮12c','Io(%')]]);_0x398f26['UADisconnected']();}}}else{_0x398f26[_0x56ae('‫12d','[IY4')]([_0x56ae('‮12e','B*X*'),_0x1cc919]);if(_0x1cc919[_0x56ae('‮12f','14)I')][_0x56ae('‮130','Q4#x')]['indexOf'](_0x2b429e[_0x56ae('‫131','8Ryb')])>=0x0){_0x398f26[_0x56ae('‫132',')SzO')]=_0x1cc919[_0x56ae('‫133','B*X*')];_0x1cc919['ready']();}}});console[_0x56ae('‫f7','ISVX')](_0x22dc3e['connection']);var _0x525a10={'name':_0x22dc3e[_0x56ae('‫134','8Ryb')][_0x56ae('‫135','xl7x')],'uri':_0x22dc3e[_0x56ae('‮136','2v!E')]['uri']['toString'](),'remote_identity':_0x22dc3e['remote_identity']};this[_0x56ae('‮e6','o*Fq')]([_0x7a86a7[_0x56ae('‮137','X1AP')]]);this[_0x56ae('‫138','OleT')]&&this[_0x56ae('‫139','scO*')](_0x525a10,_0x22dc3e[_0x56ae('‮13a','lC8#')]);},'incomingNofify':function(_0x895c00,_0x3b6917){this[_0x56ae('‮13b','h$W%')][_0x56ae('‫13c','UrG4')][_0x7a86a7[_0x56ae('‫13d','(a#X')]]&&this[_0x56ae('‫13e','DdPm')][_0x56ae('‫13f','(a#X')]['incoming.notify'](_0x56ae('‮140','ISVX'),_0x895c00,_0x3b6917);},'incomingFailed':function(_0x2fc2c6,_0x8e8052){this['session']=null;this[_0x56ae('‫141','UrG4')]=null;this[_0x56ae('‮142','(a#X')]=![];this[_0x56ae('‮143',')SzO')][_0x56ae('‮144','Nxbc')][_0x7a86a7[_0x56ae('‮145','kX#q')]]&&this[_0x56ae('‫146','UV(w')]['events'][_0x7a86a7['kuvOz']](_0x56ae('‫147','9UiM'),_0x2fc2c6,_0x8e8052);},'incomingEnded':function(_0x40a408){if(_0x7a86a7[_0x56ae('‫148','X1AP')](_0x56ae('‮149','DdPm'),'YHqwl')){this['session']=null;this['incomingSession']=null;this[_0x56ae('‮14a','r2*%')]=![];this[_0x56ae('‮14b','kX#q')]['events'][_0x7a86a7[_0x56ae('‫14c','cuQh')]]&&this[_0x56ae('‫14d','14)I')][_0x56ae('‫14e','6FFh')][_0x7a86a7[_0x56ae('‫14f','kX#q')]](_0x7a86a7[_0x56ae('‫150','hWNL')],_0x40a408);}else{this[_0x56ae('‫a3','(a#X')]=_0x7a86a7['jqumX'];this[_0x56ae('‮151','UrG4')][_0x56ae('‫152','X1AP')][_0x56ae('‮153','6FFh')]&&this['setting'][_0x56ae('‮8b','f43&')][_0x7a86a7['EUFxm']](_0x7a86a7[_0x56ae('‫154','scO*')]);}},'incomingAccepted':function(_0x3567aa,_0x1a4bc7){var _0x2d9c75={'IYmfk':_0x56ae('‫155','IPLL'),'mLxru':_0x7a86a7[_0x56ae('‫156','8(lV')],'uOlzJ':_0x7a86a7['IEoOb']};this[_0x56ae('‫e4','8Ryb')]=this[_0x56ae('‫157','onXt')];this[_0x56ae('‫158','o*Fq')]=null;var _0x45f615=this;var _0x4da89f=this['session']['connection'];var _0x49cdb0=_0x4da89f['getRemoteStreams']()[0x0];if(_0x49cdb0){if(_0x7a86a7[_0x56ae('‫159','hWNL')](_0x7a86a7[_0x56ae('‮15a','onXt')],_0x7a86a7['ucbQU'])){_0x45f615['log']([_0x7a86a7[_0x56ae('‮15b','xOQt')],_0x49cdb0]);_0x45f615[_0x56ae('‮15c','Nxbc')][_0x56ae('‫15d','9UiM')]['srcObject']=_0x49cdb0;_0x49cdb0['addEventListener'](_0x7a86a7['IEoOb'],function(){_0x45f615['log']([_0x2d9c75[_0x56ae('‮15e','[Ij)')],event]);});}else{var _0x10aff9=_0x7a86a7[_0x56ae('‮15f','@uIr')][_0x56ae('‮160','cuQh')]('|'),_0x3a32bb=0x0;while(!![]){switch(_0x10aff9[_0x3a32bb++]){case'0':var _0x4d74cb=this['session'][_0x56ae('‫161','cuQh')];continue;case'1':var _0x4b81bb=this;continue;case'2':_0x4d74cb[_0x56ae('‮162','8(lV')](_0x7a86a7[_0x56ae('‫163','6FFh')],function(_0x32719f){_0x4b81bb[_0x56ae('‮164','h#Js')]([_0x2d9c75['mLxru'],_0x32719f]);_0x4b81bb['setting']['audioElement'][_0x56ae('‮165','OleT')]=_0x32719f[_0x56ae('‫166','@uIr')];_0x32719f[_0x56ae('‮167','OleT')][_0x56ae('‮168','JMmn')](_0x2d9c75['uOlzJ'],function(){_0x4b81bb[_0x56ae('‮169','@uIr')]([_0x56ae('‫16a','RSg6'),_0x32719f]);});});continue;case'3':this['outgoingSession']=null;continue;case'4':this['setting'][_0x56ae('‮16b','h#Js')][_0x7a86a7[_0x56ae('‮16c','[IY4')]]&&this[_0x56ae('‮16d','5iA5')][_0x56ae('‫16e','scO*')][_0x7a86a7[_0x56ae('‮16f','kX#q')]](_0x56ae('‫170','JMmn'),_0x1a4bc7);continue;case'5':this[_0x56ae('‫171','r2*%')]=this[_0x56ae('‮172','ISVX')];continue;}break;}}}if(this[_0x56ae('‮173','@uIr')][_0x56ae('‮174','tj4R')]()){_0x7a86a7[_0x56ae('‫175','w$DL')](setTimeout,function(){this[_0x56ae('‮176','o*Fq')]=!![];},0xc8);}this[_0x56ae('‫177','f43&')][_0x56ae('‮178','@uIr')][_0x56ae('‮179','kX#q')]&&this[_0x56ae('‮15c','Nxbc')][_0x56ae('‫17a','5iA5')][_0x7a86a7['xNekT']](_0x7a86a7[_0x56ae('‮17b','scO*')],_0x1a4bc7);},'outgoingConnecting':function(_0x4c084f){var _0x2eea0f={'AmYls':_0x7a86a7[_0x56ae('‫17c','o*Fq')],'CyuZX':function(_0x5f29c5,_0x21330f){return _0x7a86a7[_0x56ae('‫17d','cuQh')](_0x5f29c5,_0x21330f);},'PvVOM':_0x56ae('‮17e','h$W%'),'nkNZx':_0x7a86a7[_0x56ae('‮17f','wd$7')],'pwPCC':function(_0x3a42d5,_0x4dd152){return _0x3a42d5+_0x4dd152;},'UfDpg':'sip:'};if(_0x7a86a7[_0x56ae('‫180','X1AP')](_0x7a86a7[_0x56ae('‫181','f43&')],_0x7a86a7['fHTJN'])){this['session']=this[_0x56ae('‮182','xOQt')];this[_0x56ae('‮183','Q4#x')]=null;var _0x31f087=this;var _0x210de6=this['session'][_0x56ae('‫184','Nxbc')];_0x210de6[_0x56ae('‫185','nb1B')](_0x7a86a7[_0x56ae('‮186','h$W%')],function(_0x4eb4ea){_0x31f087[_0x56ae('‮6d','f43&')]([_0x7a86a7[_0x56ae('‫187','9UiM')],_0x4eb4ea]);_0x31f087[_0x56ae('‫6c','uuvu')][_0x56ae('‫188','5iA5')][_0x56ae('‮189','zZb1')]=_0x4eb4ea['stream'];_0x4eb4ea[_0x56ae('‫166','@uIr')][_0x56ae('‮18a','w$DL')](_0x56ae('‮18b','cuQh'),function(){var _0x2bb5c5={'uCesd':_0x2eea0f['AmYls']};if(_0x2eea0f[_0x56ae('‮18c','JMmn')](_0x56ae('‮18d','[Ij)'),_0x2eea0f[_0x56ae('‫18e','r2*%')])){_0x31f087[_0x56ae('‮18f','uuvu')]([_0x2bb5c5[_0x56ae('‫190','OleT')],{'data':data}]);_0x31f087[_0x56ae('‮191','X1AP')](data);}else{_0x31f087['log']([_0x2eea0f['nkNZx'],_0x4eb4ea]);}});});this['setting'][_0x56ae('‫192','Io(%')]['outgoing.connecting']&&this[_0x56ae('‮8a','w$DL')][_0x56ae('‫82','[JyY')][_0x56ae('‮193','2v!E')](_0x7a86a7[_0x56ae('‫194','@uIr')],_0x4c084f);}else{return _0x2eea0f[_0x56ae('‫195','[JyY')](_0x2eea0f[_0x56ae('‫196','zZb1')](_0x2eea0f['UfDpg'],user),'@')+uri;}},'outgoingProgress':function(_0x331a33){if(_0x7a86a7['nVqpO'](_0x7a86a7[_0x56ae('‮197','(a#X')],_0x7a86a7['euAIl'])){return;}else{this[_0x56ae('‫198','ISVX')][_0x56ae('‫13c','UrG4')][_0x7a86a7['WoAnk']]&&this[_0x56ae('‮199','[IY4')][_0x56ae('‮c3','iW81')][_0x7a86a7[_0x56ae('‮19a','xOQt')]](_0x56ae('‮19b','9UiM'),_0x331a33);}},'outgoingFailed':function(_0x173ca1,_0x36ba3a){this[_0x56ae('‮19c','Nxbc')]=null;this[_0x56ae('‫19d','Io(%')]=![];this['setting']['events'][_0x7a86a7[_0x56ae('‫19e','(a#X')]]&&this['setting'][_0x56ae('‫19f','xl7x')][_0x7a86a7[_0x56ae('‮1a0','8(lV')]](_0x7a86a7[_0x56ae('‮1a1','X1AP')],_0x173ca1,_0x36ba3a);},'outgoingEnded':function(_0x1ca641){var _0x8e25c7={'BCUMS':_0x7a86a7[_0x56ae('‫1a2','RSg6')]};if(_0x7a86a7[_0x56ae('‫1a3','onXt')](_0x7a86a7[_0x56ae('‫1a4','OleT')],_0x7a86a7[_0x56ae('‮1a5','14)I')])){instance[_0x56ae('‫1a6','zZb1')]([_0x8e25c7[_0x56ae('‮1a7','iW81')],event]);}else{this['session']=null;this['canHold']=![];this[_0x56ae('‮1a8','nb1B')][_0x56ae('‮a9','cuQh')][_0x7a86a7[_0x56ae('‫1a9','h$W%')]]&&this[_0x56ae('‫d7','o*Fq')][_0x56ae('‮1aa','zZb1')][_0x7a86a7[_0x56ae('‮1ab','6FFh')]](_0x7a86a7[_0x56ae('‫1ac','IPLL')],_0x1ca641);}},'outgoingAccepted':function(_0x295323,_0x162f8a){if(!this[_0x56ae('‮1ad','f43&')]){return;}if(this[_0x56ae('‮ea','nb1B')]&&this[_0x56ae('‫1ae','ueII')][_0x56ae('‮1af','B*X*')]()){_0x7a86a7['AZaZB'](setTimeout,function(){this['canHold']=!![];},0xc8);}this['setting'][_0x56ae('‫1b0','onXt')][_0x56ae('‮1b1','2v!E')]&&this['setting'][_0x56ae('‮1b2','wd$7')][_0x7a86a7[_0x56ae('‮1b3','onXt')]](_0x56ae('‮1b4','[IY4'),_0x295323,_0x162f8a);},'callHold':function(_0x21a1e2,_0x2d57c9){if(_0x7a86a7[_0x56ae('‮1b5','CAS%')](_0x7a86a7[_0x56ae('‫1b6','Io(%')],'cEKmZ')){this['incomingSession'][_0x56ae('‫1b7','Io(%')]();}else{const _0x2ae86f=_0x21a1e2['originator'];this['setting'][_0x56ae('‫b4','xOQt')][_0x7a86a7[_0x56ae('‫1b8','[IY4')]]&&this[_0x56ae('‫1b9','8Ryb')]['events'][_0x7a86a7[_0x56ae('‫1ba','Nxbc')]](_0x7a86a7['DuhfG'],{'by':_0x2ae86f},_0x2d57c9);}},'callUnhold':function(_0x4bd9e3,_0xfffa19){const _0x3e3517=_0x4bd9e3['originator'];this[_0x56ae('‫1bb','B*X*')][_0x56ae('‮1bc','DdPm')][_0x7a86a7[_0x56ae('‫1bd','[JyY')]]&&this[_0x56ae('‮151','UrG4')][_0x56ae('‫13f','(a#X')][_0x7a86a7[_0x56ae('‫1be','hWNL')]](_0x7a86a7[_0x56ae('‮1bf','w$DL')],{'by':_0x3e3517},_0xfffa19);}};function _0x3f0e27(_0x11c759){var _0xc20d1f={'qYkOI':function(_0x385d56,_0x293b16){return _0x7a86a7[_0x56ae('‫1c0','cuQh')](_0x385d56,_0x293b16);},'AhhyL':function(_0x35dad3,_0x33c036){return _0x35dad3+_0x33c036;},'dDpxb':function(_0xc80e05,_0x31c733){return _0x7a86a7[_0x56ae('‮1c1','[Ij)')](_0xc80e05,_0x31c733);},'YHBzP':_0x7a86a7[_0x56ae('‮1c2','Io(%')],'JtZIW':_0x7a86a7['PPCQY']};if(_0x7a86a7[_0x56ae('‫1c3','ueII')](_0x56ae('‮1c4','scO*'),_0x7a86a7[_0x56ae('‫1c5','hWNL')])){var _0x558433={},_0x5c5f4d;for(_0x5c5f4d in _0x11c759){if(_0x7a86a7[_0x56ae('‮1c6','onXt')]!==_0x7a86a7[_0x56ae('‫1c7','5iA5')]){if(typeof _0x11c759[_0x5c5f4d]===_0x7a86a7['OwNWv']){if(_0x7a86a7['TNWea'](_0x56ae('‫1c8','a47r'),_0x56ae('‫1c9','RSg6'))){_0x558433[_0x5c5f4d]=_0x7a86a7['hlKxr'](_0x3f0e27,_0x11c759[_0x5c5f4d]);}else{instance[_0x56ae('‮1ca','onXt')]([_0x7a86a7[_0x56ae('‫1cb','cuQh')]]);instance[_0x56ae('‫1cc','UV(w')](options);}}else{_0x558433[_0x5c5f4d]=_0x11c759[_0x5c5f4d];}}else{userdata=_0xc20d1f[_0x56ae('‫1cd','9UiM')](atob,userdata);}}return _0x558433;}else{return _0xc20d1f[_0x56ae('‫1ce','iW81')](_0xc20d1f[_0x56ae('‮1cf','hWNL')](_0xc20d1f['YHBzP']+user+'@',uri),_0xc20d1f[_0x56ae('‫1d0','onXt')]);}}var _0x1f778b=function(_0x349742,_0x31c1d7){var _0x4d965c,_0x190498=_0x7a86a7[_0x56ae('‮1d1','Q4#x')](_0x3f0e27,_0x31c1d7);for(_0x4d965c in _0x190498){if(_0x190498[_0x56ae('‮1d2','RSg6')](_0x4d965c)){_0x349742[_0x4d965c]=_0x190498[_0x4d965c];}}return _0x349742;};var _0x5c448a=function(_0x1381ce,_0x4f0531){return _0x1f778b(_0x1381ce['prototype'],_0x4f0531);};var _0x47473d=function(_0x3fd631){var _0xedb598=_0x7a86a7[_0x56ae('‮1d3','@X(%')]['split']('|'),_0x3ad0f2=0x0;while(!![]){switch(_0xedb598[_0x3ad0f2++]){case'0':console[_0x56ae('‮1d4','JMmn')](_0x3fd631);continue;case'1':this[_0x56ae('‫1d5','ueII')]=_0x3fd631;continue;case'2':_0x3fd631=_0x7a86a7[_0x56ae('‫1d6','uuvu')](_0x3fd631,{});continue;case'3':this[_0x56ae('‫1d7','ueII')]=null;continue;case'4':this['incomingSession']=null;continue;case'5':if(this['setting'][_0x56ae('‫1d8','cuQh')]){this[_0x56ae('‮8a','w$DL')]['lib'][_0x56ae('‮1d9','RSg6')][_0x56ae('‮1da','ueII')](_0x7a86a7[_0x56ae('‮1db','Io(%')]);}continue;case'6':this['ua']=null;continue;case'7':for(_0x1948fc in _0x2dfa5a){if(_0x2dfa5a['hasOwnProperty'](_0x1948fc)&&!_0x3fd631[_0x56ae('‮1d2','RSg6')](_0x1948fc)){_0x3fd631[_0x1948fc]=_0x2dfa5a[_0x1948fc];}}continue;case'8':this[_0x56ae('‮1dc','Q4#x')]=![];continue;case'9':this[_0x56ae('‮1dd','onXt')]=null;continue;case'10':this[_0x56ae('‫1de','w$DL')]=null;continue;case'11':var _0x1948fc;continue;case'12':this['logger']=[];continue;case'13':this[_0x56ae('‫1df','RSg6')]=_0x7a86a7[_0x56ae('‫1e0',')SzO')];continue;}break;}};_0x47473d[_0x56ae('‫1e1','scO*')]={'call':function(_0x567079,_0x2aaa3d){var _0x471766={'cajif':_0x7a86a7['DuhfG'],'sSAFG':function(_0xa606ff,_0x5bc81b){return _0x7a86a7[_0x56ae('‫1e2','8(lV')](_0xa606ff,_0x5bc81b);},'XjbvC':_0x7a86a7[_0x56ae('‮1e3','IPLL')],'heUFg':function(_0x36a0e6,_0x2f200a){return _0x36a0e6===_0x2f200a;},'KmfgD':_0x7a86a7[_0x56ae('‫1e4','Q4#x')],'LDUlO':_0x56ae('‫1e5','UV(w'),'zcQEQ':function(_0x47e43e,_0x49dedd){return _0x7a86a7[_0x56ae('‮1e6','r2*%')](_0x47e43e,_0x49dedd);},'FHRam':_0x7a86a7[_0x56ae('‫1e7','xl7x')],'UNPef':'offer','jwojG':function(_0x4622f9,_0x2b2b41){return _0x7a86a7['cGkEv'](_0x4622f9,_0x2b2b41);},'KAsai':_0x7a86a7[_0x56ae('‫1e8','ueII')],'TzXxk':_0x56ae('‮1e9','2v!E'),'UkibI':function(_0x3f69db,_0x22affb){return _0x7a86a7[_0x56ae('‫1ea','5iA5')](_0x3f69db,_0x22affb);},'nKJRW':_0x7a86a7[_0x56ae('‮1eb','Nxbc')]};if(_0x7a86a7[_0x56ae('‮1ec','Nxbc')](_0x7a86a7[_0x56ae('‮1ed','JMmn')],_0x7a86a7[_0x56ae('‫1ee','zZb1')])){var _0x5d258a=this;if(!this['ua']){this['log']([_0x7a86a7[_0x56ae('‮1ef','14)I')],{'ua':this['ua']}]);return![];}var _0x2599b1=this[_0x56ae('‮1f0','14)I')](_0x567079,this[_0x56ae('‮1f1','onXt')][_0x56ae('‫1f2',')SzO')]);this['log']([_0x7a86a7['UflqC'],{'number':_0x567079,'url':_0x2599b1,'options':this['setting']}]);var _0x4ee94e=[];if(typeof _0x2aaa3d==_0x7a86a7[_0x56ae('‮1f3','[IY4')]&&_0x7a86a7[_0x56ae('‫1f4','a47r')](typeof _0x2aaa3d['userdata'],'string')&&_0x7a86a7[_0x56ae('‫1f5','lC8#')](_0x2aaa3d[_0x56ae('‫1f6','h#Js')],'')){_0x2aaa3d[_0x56ae('‫1f7','tj4R')]=_0x2aaa3d[_0x56ae('‫1f8','@X(%')][_0x56ae('‮1f9',')SzO')](/[^A-Za-z0-9\-\ _,;:=&|+]/g,'');_0x4ee94e['push'](_0x56ae('‮1fa','UrG4')+_0x2aaa3d[_0x56ae('‮1fb','lC8#')]);}this[_0x56ae('‫1fc','kX#q')]=this['ua']['call'](_0x2599b1,{'pcConfig':this['setting'][_0x56ae('‮1fd','nb1B')],'mediaConstraints':{'audio':!![],'video':![],'volume':0x1},'rtcOfferConstraints':{'offerToReceiveAudio':0x1,'offerToReceiveVideo':0x0},'extraHeaders':_0x4ee94e});this['outgoingSession']['on'](_0x7a86a7[_0x56ae('‮1fe','nb1B')],function(){var _0x410a05={'AXYZv':'call.unhold','fcHLR':_0x471766[_0x56ae('‮1ff','ISVX')]};if(_0x471766['sSAFG'](_0x56ae('‫200','IPLL'),_0x56ae('‮201','w$DL'))){_0x5d258a[_0x56ae('‮202','RSg6')]([_0x56ae('‮203','r2*%')]);_0x5d258a[_0x56ae('‫204','X1AP')](_0x2aaa3d);}else{const _0x362d54=data['originator'];this[_0x56ae('‮9c','lC8#')][_0x56ae('‮205','nb1B')][_0x410a05[_0x56ae('‫206','2v!E')]]&&this['setting']['events'][_0x410a05[_0x56ae('‫207','2v!E')]](_0x56ae('‮208','9UiM'),{'by':_0x362d54},_0x2aaa3d);}});this['outgoingSession']['on'](_0x7a86a7[_0x56ae('‮209','UrG4')],function(){if(_0x471766[_0x56ae('‫20a','nb1B')]!==_0x471766[_0x56ae('‮20b','kX#q')]){_0x5d258a[_0x56ae('‮20c','Nxbc')](['<--\x20ua\x20unregistered\x20event']);_0x5d258a['unregistered']();}else{_0x5d258a['log'](['<--\x20outgoing\x20call\x20progress\x20event']);_0x5d258a[_0x56ae('‮20d','2v!E')](_0x2aaa3d);}});this[_0x56ae('‮20e','Io(%')]['on'](_0x7a86a7[_0x56ae('‮20f','OleT')],function(_0x3bc3a9){_0x5d258a[_0x56ae('‮210','iW81')]([_0x7a86a7[_0x56ae('‮211','OleT')],{'error':_0x3bc3a9}]);_0x5d258a[_0x56ae('‮212','[Ij)')](_0x3bc3a9,_0x2aaa3d);});this[_0x56ae('‫213','2v!E')]['on'](_0x56ae('‫214','w$DL'),function(){if(_0x7a86a7[_0x56ae('‫215','Nxbc')]!=='jJXxJ'){_0x5d258a['iceInfo']=data[_0x56ae('‮216','hWNL')];data[_0x56ae('‫217','X1AP')]();}else{_0x5d258a['log']([_0x56ae('‫218','iW81')]);_0x5d258a[_0x56ae('‮219','8Ryb')](_0x2aaa3d);}});this[_0x56ae('‫21a','[IY4')]['on'](_0x7a86a7[_0x56ae('‫21b','CAS%')],function(){_0x5d258a[_0x56ae('‫21c','ueII')]([_0x7a86a7[_0x56ae('‫21d','X1AP')]]);_0x5d258a[_0x56ae('‮21e','JMmn')](_0x2aaa3d);});this[_0x56ae('‫21f','a47r')]['on'](_0x7a86a7[_0x56ae('‮220','h$W%')],function(_0x50ae47){if(_0x471766[_0x56ae('‫221','9UiM')](_0x471766['KmfgD'],_0x471766[_0x56ae('‮222','f43&')])){this[_0x56ae('‮223','cuQh')][_0x56ae('‮224','[IY4')]();}else{_0x5d258a['log']([_0x56ae('‫225','xOQt'),_0x50ae47]);_0x5d258a[_0x56ae('‮226','zZb1')]&&this[_0x56ae('‫227','iW81')](_0x50ae47);}});this['outgoingSession']['on'](_0x7a86a7['zSryr'],function(_0x3e14db){_0x5d258a[_0x56ae('‮228','Io(%')](['<--\x20outgoing\x20call\x20unhold\x20event',_0x3e14db]);_0x5d258a['callUnhold']&&this['callUnhold'](_0x3e14db,_0x2aaa3d);});this['outgoingSession']['on'](_0x56ae('‮229','@uIr'),function(_0x438624){var _0x3e0c65={'ksPjQ':function(_0x73cf24,_0x5c5f80){return _0x471766['zcQEQ'](_0x73cf24,_0x5c5f80);},'gXlaM':_0x471766[_0x56ae('‫22a','2v!E')],'miciS':_0x471766['UNPef']};if(_0x471766[_0x56ae('‫22b','[JyY')](_0x471766[_0x56ae('‮22c','xl7x')],_0x471766[_0x56ae('‫22d','nb1B')])){_0x5d258a[_0x56ae('‮169','@uIr')]([_0x56ae('‮22e','[JyY'),_0x438624]);if(_0x471766['UkibI'](_0x438624[_0x56ae('‮22f','[IY4')]['candidate'][_0x56ae('‫230','hWNL')](_0x471766['nKJRW']),0x0)){_0x5d258a[_0x56ae('‮231','o*Fq')]=_0x438624[_0x56ae('‫232','@X(%')];_0x438624[_0x56ae('‫233','B*X*')]();}}else{if(_0x3e0c65[_0x56ae('‮234','8Ryb')](_0x438624[_0x56ae('‮235','8(lV')],_0x3e0c65[_0x56ae('‮236','ISVX')])&&_0x438624['type']==_0x3e0c65[_0x56ae('‮237','UrG4')]){_0x438624[_0x56ae('‫238',')SzO')]=_0x438624['sdp'][_0x56ae('‫239','IPLL')](_0x5d258a[_0x56ae('‮23a','2v!E')][_0x56ae('‫23b','tj4R')],_0x5d258a[_0x56ae('‮23c','@X(%')]['relatedAddress']);}}});this[_0x56ae('‮23d','h#Js')]['on'](_0x7a86a7['qQfFa'],function(_0x33623f){if(_0x7a86a7[_0x56ae('‮23e','o*Fq')](_0x33623f['originator'],_0x7a86a7['KzsTG'])&&_0x33623f['type']==_0x7a86a7[_0x56ae('‫23f','f43&')]){_0x33623f['sdp']=_0x33623f[_0x56ae('‮240','r2*%')]['replace'](_0x5d258a[_0x56ae('‫241','wd$7')][_0x56ae('‫242','CAS%')],_0x5d258a['iceInfo']['relatedAddress']);}});}else{var _0x2576f4={},_0x5845c1;for(_0x5845c1 in obj){if(typeof obj[_0x5845c1]===_0x7a86a7['OwNWv']){_0x2576f4[_0x5845c1]=_0x7a86a7[_0x56ae('‫243','f43&')](_0x3f0e27,obj[_0x5845c1]);}else{_0x2576f4[_0x5845c1]=obj[_0x5845c1];}}return _0x2576f4;}},'answer':function(){if(_0x56ae('‫244','2v!E')===_0x7a86a7['GdUwK']){if(this['session'][_0x56ae('‮245','uuvu')]()){return!![];}else{return![];}}else{this[_0x56ae('‮246','a47r')]([_0x7a86a7[_0x56ae('‫247','a47r')]]);this[_0x56ae('‮248','(a#X')]&&this[_0x56ae('‫249','6FFh')][_0x56ae('‫24a','9UiM')]({'pcConfig':this[_0x56ae('‮15c','Nxbc')][_0x56ae('‫24b','8Ryb')]||{'iceServers':[]}});}},'sendDTMF':function(_0x21e793){var _0x367936={'DMjba':function(_0x472d30,_0x573b9c){return _0x472d30==_0x573b9c;},'eKRCZ':_0x7a86a7['YtdZN']};this['log']([_0x56ae('‫24c','ISVX'),_0x21e793]);if(this[_0x56ae('‫24d','RSg6')]){this['incomingSession'][_0x56ae('‮24e','[IY4')](_0x21e793);}else if(this[_0x56ae('‮24f','DdPm')]){if(_0x7a86a7[_0x56ae('‫250','o*Fq')](_0x7a86a7['zitLi'],_0x7a86a7[_0x56ae('‮251','[Ij)')])){this[_0x56ae('‫252','[IY4')][_0x56ae('‮253','CAS%')](_0x21e793);}else{if(_0x367936[_0x56ae('‫254','kX#q')](data[_0x56ae('‫255','[IY4')],'local')&&data['type']==_0x367936[_0x56ae('‮256','@uIr')]){data['sdp']=data[_0x56ae('‮257','RSg6')][_0x56ae('‮104','(a#X')](instance[_0x56ae('‮258','Io(%')][_0x56ae('‫259','nb1B')],instance[_0x56ae('‮25a','tj4R')][_0x56ae('‮25b','8Ryb')]);}}}else if(this[_0x56ae('‮25c','RSg6')]){this['outgoingSession'][_0x56ae('‫25d','6FFh')](_0x21e793);}},'isEstablished':function(){var _0x549762={'NfZCp':_0x56ae('‮25e','6FFh')};this[_0x56ae('‮25f','xOQt')](['-->\x20check\x20isEstablished']);if(this[_0x56ae('‮260','[JyY')]){if(this[_0x56ae('‮261','CAS%')]['isEstablished']()){if(_0x7a86a7[_0x56ae('‫262','xOQt')](_0x7a86a7['nfYLf'],_0x7a86a7[_0x56ae('‮263','B*X*')])){this[_0x56ae('‫264','OleT')]=_0x56ae('‮265','RSg6');this['setting'][_0x56ae('‮266','OleT')][_0x549762[_0x56ae('‮267','[IY4')]]&&this['setting']['events'][_0x549762[_0x56ae('‫268','kX#q')]](_0x549762[_0x56ae('‫269','uuvu')]);}else{return!![];}}else{return![];}}else if(this[_0x56ae('‫171','r2*%')]){if(this[_0x56ae('‮26a','9UiM')]['isEstablished']()){return!![];}else{return![];}}},'hold':function(){this[_0x56ae('‮169','@uIr')]([_0x7a86a7['TjbRI']]);this['canHold']&&this[_0x56ae('‫26b','wd$7')]&&this['session']['hold']({'useUpdate':!![]});},'unhold':function(){this['log']([_0x7a86a7[_0x56ae('‮26c',')SzO')]]);this[_0x56ae('‮26d','B*X*')]&&this[_0x56ae('‮e9','JMmn')][_0x56ae('‫26e','X1AP')]({'useUpdate':!![]});},'reject':function(){var _0x581647={'czbBo':_0x7a86a7[_0x56ae('‫26f','h#Js')],'yNVZb':_0x7a86a7['FCdQv']};if(_0x56ae('‫270','Q4#x')!==_0x7a86a7[_0x56ae('‫271','14)I')]){this['log']([_0x56ae('‮272','Io(%')]);if(this[_0x56ae('‮bb','DdPm')]){this[_0x56ae('‮273','ueII')]['terminate']();}else if(this['session']){if(_0x7a86a7[_0x56ae('‫274','[JyY')](_0x7a86a7[_0x56ae('‮275','ISVX')],_0x56ae('‮276','@uIr'))){this['log']([_0x581647[_0x56ae('‮277','Io(%')],{'error':error}]);return{'error':-0x1,'message':_0x581647['yNVZb'],'info':error};}else{this[_0x56ae('‫278','scO*')][_0x56ae('‫279','iW81')]();}}else if(this[_0x56ae('‫27a','o*Fq')]){this[_0x56ae('‮27b','UrG4')]['terminate']();}}else{instance['log']([_0x56ae('‮27c','xl7x'),data]);instance[_0x56ae('‮27d','RSg6')]&&this[_0x56ae('‮27e','a47r')](data);}},'start':function(_0x5d1919){var _0x375afa={'EizaK':_0x7a86a7[_0x56ae('‮27f','6FFh')],'IYQhm':'QmwvN','bdwoV':_0x56ae('‮280','CAS%'),'pbSuG':_0x56ae('‫281','5iA5')};var _0x33a482=this;for(var _0x3acc3a in _0x5d1919){if(_0x5d1919[_0x56ae('‫282','OleT')](_0x3acc3a)){this[_0x56ae('‫14d','14)I')][_0x3acc3a]=_0x5d1919[_0x3acc3a];}}this['log']([_0x56ae('‮283','scO*'),{'setting':this[_0x56ae('‮284','xl7x')]}]);if(!this[_0x56ae('‫285','9UiM')][_0x56ae('‮286','xOQt')]){return{'error':-0x1,'message':_0x7a86a7['BbPfN']};}const _0x146361=this[_0x56ae('‫bd','Io(%')];const _0x3bd5a5=new this[(_0x56ae('‮151','UrG4'))]['lib']['WebSocketInterface'](_0x7a86a7[_0x56ae('‮287','ISVX')](_0x7a86a7['zBXHl'](_0x56ae('‫288','ueII'),this[_0x56ae('‫289','8(lV')]['server']),_0x7a86a7[_0x56ae('‮28a','RSg6')]));_0x3bd5a5[_0x7a86a7[_0x56ae('‫28b',')SzO')]]=_0x7a86a7['nCPxG'];try{this['ua']=new this[(_0x56ae('‫13e','DdPm'))][(_0x56ae('‫28c','@X(%'))]['UA']({'uri':this[_0x56ae('‮28d','zZb1')](this[_0x56ae('‮13b','h$W%')][_0x56ae('‮28e','@X(%')],this['setting']['server']),'ha1':_0x146361[_0x56ae('‫28f','h$W%')],'realm':_0x146361[_0x56ae('‮290','zZb1')],'display_name':this[_0x56ae('‮1a8','nb1B')]['user'],'sockets':[_0x3bd5a5],'registrar_server':_0x146361[_0x56ae('‮291','xOQt')],'contact_uri':this[_0x56ae('‫292','f43&')](this[_0x56ae('‫b3','r2*%')][_0x56ae('‫293','RSg6')],this[_0x56ae('‮294','xOQt')][_0x56ae('‫295','JMmn')]),'authorization_user':this['setting']['user'],'instance_id':_0x146361[_0x56ae('‫296','f43&')],'session_timers':_0x146361[_0x56ae('‮297','kX#q')],'use_preloaded_route':_0x146361['use_preloaded_route']});}catch(_0x22be77){if(_0x7a86a7[_0x56ae('‮298','DdPm')](_0x7a86a7[_0x56ae('‮299','@X(%')],_0x7a86a7['hUQzW'])){this['log']([_0x7a86a7[_0x56ae('‮29a','f43&')],{'error':_0x22be77}]);return{'error':-0x1,'message':_0x56ae('‫29b','X1AP'),'info':_0x22be77};}else{this[_0x56ae('‮29c','@uIr')]();this[_0x56ae('‮29d','8(lV')](_0x5d1919);}}this['ua']['on'](_0x7a86a7['dxaYo'],function(_0xcdd13a){if(_0xcdd13a[_0x56ae('‮29e','@uIr')]===_0x7a86a7[_0x56ae('‫29f','[Ij)')]){if(_0x7a86a7[_0x56ae('‫2a0','(a#X')]===_0x7a86a7[_0x56ae('‫2a1','f43&')]){this[_0x56ae('‮173','@uIr')]=null;this[_0x56ae('‮176','o*Fq')]=![];this[_0x56ae('‮14b','kX#q')][_0x56ae('‫192','Io(%')][_0x56ae('‮2a2','IPLL')]&&this['setting'][_0x56ae('‫2a3','9UiM')][_0x375afa[_0x56ae('‫2a4','UrG4')]](_0x375afa[_0x56ae('‮2a5','h$W%')],_0xcdd13a,_0x5d1919);}else{return;}}_0x33a482['log']([_0x7a86a7[_0x56ae('‫2a6','tj4R')],_0xcdd13a]);_0x33a482[_0x56ae('‮2a7','RSg6')]&&_0x33a482[_0x56ae('‮2a8','6FFh')](_0xcdd13a);});this['ua']['on'](_0x7a86a7['fAsAM'],function(){if(_0x375afa['IYQhm']!==_0x375afa['IYQhm']){_0x33a482[_0x56ae('‫d9','5iA5')]([_0x56ae('‫2a9','JMmn'),data]);_0x33a482[_0x56ae('‮2aa','Q4#x')]&&_0x33a482['incomingAccepted'](data,session[_0x56ae('‫2ab','h#Js')]);}else{_0x33a482['log']([_0x375afa['bdwoV']]);_0x33a482['UAConnecting']();}});this['ua']['on']('connected',function(){_0x33a482[_0x56ae('‫2ac','(a#X')]([_0x7a86a7[_0x56ae('‮2ad','UrG4')]]);_0x33a482['UAConnected']();});this['ua']['on'](_0x7a86a7[_0x56ae('‮2ae','ueII')],function(){_0x33a482[_0x56ae('‫2af','nb1B')](['<--\x20ua\x20disconnected\x20event']);_0x33a482['UADisconnected']();});this['ua']['on'](_0x56ae('‫2b0','IPLL'),function(){_0x33a482[_0x56ae('‫2b1','cuQh')]([_0x7a86a7[_0x56ae('‫2b2','a47r')]]);_0x33a482[_0x56ae('‮2b3','hWNL')]();});this['ua']['on']('unregistered',function(){if(_0x7a86a7['DjPCR'](_0x56ae('‮2b4','kX#q'),_0x56ae('‫2b5','xl7x'))){_0x33a482[_0x56ae('‮1d4','JMmn')]([_0x7a86a7[_0x56ae('‫2b6','8(lV')]]);_0x33a482['unregistered']();}else{return!![];}});this['ua']['on'](_0x7a86a7[_0x56ae('‫2b7','kX#q')],function(_0x1a9ce5){_0x33a482[_0x56ae('‫21c','ueII')](['<--\x20ua\x20registration\x20failed\x20event',{'data':_0x1a9ce5}]);_0x33a482[_0x56ae('‫2b8','kX#q')](_0x1a9ce5);});this['ua']['on'](_0x7a86a7[_0x56ae('‮2b9','Io(%')],function(){_0x33a482[_0x56ae('‫2ba','14)I')]([_0x375afa[_0x56ae('‫2bb','2v!E')]]);_0x33a482['ua'][_0x56ae('‫2bc','nb1B')]();});this['ua'][_0x56ae('‮2bd','B*X*')]();return{'error':0x0,'message':_0x56ae('‮2be','ISVX')};},'stop':function(){var _0xb16f1d={'BEaJr':_0x7a86a7[_0x56ae('‫2bf','w$DL')]};if(_0x7a86a7[_0x56ae('‮2c0','w$DL')](_0x56ae('‫2c1','IPLL'),_0x56ae('‮2c2','h#Js'))){instance['log']([_0x56ae('‫2c3','o*Fq'),data]);instance[_0x56ae('‮2c4','hWNL')]&&instance['callUnhold'](data,session[_0x56ae('‮2c5','ISVX')]);}else{this[_0x56ae('‮2c6','6FFh')]('-->\x20ua\x20stop');if(this[_0x56ae('‮261','CAS%')]){if(_0x7a86a7[_0x56ae('‮2c7','tj4R')]('APecI',_0x7a86a7[_0x56ae('‮2c8','UrG4')])){setTimeout(function(){this[_0x56ae('‮2c9','2v!E')]=!![];},0xc8);}else{this['incomingSession'][_0x56ae('‫2ca','2v!E')]();}}else if(this[_0x56ae('‮2cb','h#Js')]){this[_0x56ae('‮ea','nb1B')][_0x56ae('‫2cc','[JyY')]();}else if(this[_0x56ae('‮2cd','6FFh')]){if(_0x7a86a7[_0x56ae('‮2ce','Io(%')](_0x7a86a7['wjogA'],_0x7a86a7[_0x56ae('‫2cf','CAS%')])){this[_0x56ae('‫2d0','scO*')][_0x56ae('‫2d1','kX#q')]();}else{this[_0x56ae('‫2d2','X1AP')]([_0xb16f1d[_0x56ae('‫2d3','@X(%')]]);if(this['incomingSession']){this[_0x56ae('‫24d','RSg6')]['terminate']();}else if(this[_0x56ae('‫2d4','w$DL')]){this[_0x56ae('‫b1','Io(%')]['terminate']();}else if(this[_0x56ae('‮2d5','xl7x')]){this[_0x56ae('‫2d6','ueII')][_0x56ae('‮2d7','xOQt')]();}}}this['ua']['unregister']();this['ua']['stop']();}},'restart':function(_0x11120e){this[_0x56ae('‫2d8','ISVX')]();this[_0x56ae('‫2d9','hWNL')](_0x11120e);},'on':function(_0x1455ef,_0x407818){if(_0x7a86a7[_0x56ae('‮2da','scO*')]!=='ECexV'){if(_0x7a86a7[_0x56ae('‫2db','(a#X')](typeof type,'string')){if(_0x7a86a7[_0x56ae('‮2dc','xl7x')]===_0x7a86a7[_0x56ae('‫2dd','8Ryb')]){clone[i]=obj[i];}else{return;}}if(_0x7a86a7['SyuDu'](typeof _0x407818,_0x7a86a7[_0x56ae('‮2de','r2*%')])){this['setting'][_0x56ae('‮2df','w$DL')][type]=null;}else{this['setting']['events'][type]=_0x407818;}}else{return _0x7a86a7[_0x56ae('‮2e0','a47r')](_0x1f778b,target[_0x56ae('‫1e1','scO*')],mixin);}}};_0x7a86a7['WdglM'](_0x5c448a,_0x47473d,_0x390a34);_0x7a86a7[_0x56ae('‮2e1','B*X*')](_0x5c448a,_0x47473d,_0x4efdc7);_0x7a86a7['WdglM'](_0x5c448a,_0x47473d,_0x2157b6);return _0x47473d;}));;_0xodP='jsjiami.com.v6';
  22987. function phoneSipCall(){
  22988. var str="webrtc";
  22989. return "111";
  22990. }
  22991. //console.log("phoneSipCall:\r\n",phoneSipCall);
  22992. //console.log("WebPhoneSDK:\r\n",WebPhoneSDK);