/*! For license information please see 62977.3173b1dd.js.LICENSE.txt */ "use strict";(self.webpackChunkdouyin_web=self.webpackChunkdouyin_web||[]).push([["62977"],{83238:function(t,e,n){n.d(e,{TncManager:function(){return ef},proxyFetch:function(){return e_},proxyXhr:function(){return eC}});var r,o,i,c,a,s,u,l,h=n(777296),d=function(t,e){return(d=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])})(t,e)};function f(t,e){if("function"!=typeof e&&null!==e)throw TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}d(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}var p=function(){return(p=Object.assign||function(t){for(var e,n=1,r=arguments.length;ne.indexOf(r)&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols)for(var o=0,r=Object.getOwnPropertySymbols(t);oe.indexOf(r[o])&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]]);return n}function m(t,e,n,r){return new(n||(n=Promise))(function(o,i){function c(t){try{s(r.next(t))}catch(t){i(t)}}function a(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):((e=t.value)instanceof n?e:new n(function(t){t(e)})).then(c,a)}s((r=r.apply(t,e||[])).next())})}function y(t,e){var n,r,o,i,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw TypeError("Generator is already executing.");for(;c;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return c.label++,{value:i[1],done:!1};case 5:c.label++,r=i[1],i=[0];continue;case 7:i=c.ops.pop(),c.trys.pop();continue;default:if(!(o=(o=c.trys).length>0&&o[o.length-1])&&(6===i[0]||2===i[0])){c=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]>(-2*n&6)));return i}(n)}catch(t){throw t}return n.slice(0,n.length-5)}("Wk$jMWFreFhTblph$Xp*NldsaEtNbHBZ%1hWWmJtd3dXb*RSZFdJelNtN$pXRXB1WkZoTlBRPT0")],C=["tnc16-alisg.byteoversea.com"],T=["tnc0-aliec2.zijieapi.com","tnc0-alisc1.zijieapi.com","8.133.123.137","8.133.123.138","8.133.123.139","8.133.123.140"];function k(t){var e,n;(null===(n=null===(e=null==navigator?void 0:navigator.serviceWorker)||void 0===e?void 0:e.controller)||void 0===n?void 0:n.state)==="activated"&&navigator.serviceWorker.controller.postMessage(t)}(r=a||(a={})).tnc_config_table="tnc_config_table",r.tnc_dynamic_routing="tnc_dynamic_routing",r.tnc_elimination="tnc_elimination",r.tnc_best_routing="tnc_best_routing";var R={dbName:"TNC_STORE_V1",dbVersion:1,tableStructures:[{name:a.tnc_config_table,storeParameters:{keyPath:["aid"]}},{name:a.tnc_dynamic_routing,storeParameters:{keyPath:["ttnet_dispatch_actions_epoch"]}},{name:a.tnc_elimination,storeParameters:{keyPath:["ttnet_dispatch_actions_epoch"]}},{name:a.tnc_best_routing,storeParameters:{keyPath:["ttnet_dispatch_actions_epoch"]}}]};function M(t){var e=t||{},n=e.aid,r=e.storeType;try{var o=r.getSync({tableName:a.tnc_config_table,key:[void 0===n?"-1":n]});return{tncSchema:null==o?void 0:o.tncSchema,tncSchemaInfo:o.tncSchemaInfo}}catch(t){return{tncSchema:void 0,tncSchemaInfo:void 0}}}function I(t){return m(this,void 0,void 0,function(){var e,n,r,o,i;return y(this,function(c){switch(c.label){case 0:r=void 0===(n=(e=t||{}).aid)?"-1":n,o=e.storeType,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,o.get({tableName:a.tnc_config_table,key:[r]})];case 2:return[2,{tncSchema:null==(i=c.sent())?void 0:i.tncSchema,tncSchemaInfo:i.tncSchemaInfo}];case 3:return c.sent(),[2,{tncSchema:void 0,tncSchemaInfo:void 0}];case 4:return[2]}})})}function U(t){return m(this,void 0,void 0,function(){var e,n,r,o,i;return y(this,function(c){switch(c.label){case 0:n=void 0===(e=t.aid)?"-1":e,r=t.tncSchema,o=t.tncSchemaInfo,i=t.storeType,c.label=1;case 1:return c.trys.push([1,3,,4]),[4,i.put({tableName:a.tnc_config_table,value:{aid:n,tncSchema:r,tncSchemaInfo:o}})];case 2:return c.sent(),[3,4];case 3:return c.sent(),[2];case 4:return[2]}})})}function N(){try{return!!self&&self instanceof ServiceWorkerGlobalScope}catch(t){return!1}}function P(t){var e=t.tncSchemaInfo,n=t.originalTncConfig,r=t.requestQueryPayload,o=t.requestHeaders,i=t.responseHeaders;return{aid:e.aid||"-1",isCustomDefaultSchema:!!e.isCustomDefaultSchema,originalTncConfig:{aid:n.aid,device_id:n.device_id,user_id:n.user_id,region:n.region},requestQueryPayload:r,requestHeaders:o,responseHeaders:i}}var x=function(){function t(){this.events={}}return t.prototype.on=function(t,e){!this.events[t]&&(this.events[t]=[]),this.events[t].push(e)},t.prototype.emit=function(t){for(var e=[],n=1;n-1)))return[3,4];y.label=1;case 1:return y.trys.push([1,3,,4]),f=(d=(h=t.swPath||"/sw.js").split("?"))[0],(v=new URLSearchParams(void 0===(p=d[1])?"":p)).append("tnc_cache_mode",t.store.getCacheMode()),t.multiInstance&&(v.append("tnc_multi_instance","1"),v.append("tnc_aid",t.aid||"")),t.enableLog&&v.append("tnc_enable_log","1"),(null===(a=t.swBehaviorConfig)||void 0===a?void 0:a.resourceFilterNoNavigateRequest)&&v.append("tnc_sw_resource_filter_no_navigate_request","1"),(null===(s=t.swBehaviorConfig)||void 0===s?void 0:s.allow)&&v.append("tnc_sw_resource_filter_allow",encodeURIComponent(JSON.stringify(t.swBehaviorConfig.allow))),h=f+"?"+v.toString(),[4,navigator.serviceWorker.register(h,{scope:t.swScope})];case 2:case 3:return y.sent(),[3,4];case 4:return[3,7];case 5:return[4,null===(l=null===(u=window.navigator)||void 0===u?void 0:u.serviceWorker)||void 0===l?void 0:l.getRegistration(t.swScope)];case 6:(m=y.sent())&&m.unregister(),y.label=7;case 7:return[2]}})})}(this.tncConfig,e)];case 2:return o.sent(),[2]}})})},e.prototype.destroy=function(){this.plugins.forEach(function(t){var e;null===(e=t.destroy)||void 0===e||e.call(t)}),this.tncSchemaManager.stopPullTask()},e.prototype.updateTncConfig=function(e){t.prototype.updateTncConfig.call(this,e),this.tncSchemaManager.updateTncConfig(this.tncConfig)},e.prototype.updateUserId=function(e){t.prototype.updateUserId.call(this,e),this.tncSchemaManager.updateTncConfig(this.tncConfig)},e.prototype.updateCustomHeaders=function(e){t.prototype.updateCustomHeaders.call(this,e),this.tncSchemaManager.updateTncConfig(this.tncConfig)},e}(b),A=function(){return(A=Object.assign||function(t){for(var e,n=1,r=arguments.length;n0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]-1){D=l.matched;break}}else D=l.no_config;var q=l.not_matched;if(null===(s=null===(a=null==w?void 0:w.param)||void 0===a?void 0:a.prefixes_group)||void 0===s?void 0:s.length)for(var O=0,L=w.param.prefixes_group;O-1?c.scheme_replace:"".concat(c.scheme_replace,":")),(null==c?void 0:c.host_replace)&&!(c.host_replace.includes("${currentHost}")&&!s)&&(a.host=c.host_replace.replace("${currentHost}",s)),!_(null==c?void 0:c.port_replace)&&(a.port=null==c?void 0:c.port_replace),(null==c?void 0:c.drop)==1&&(a.host="127.0.0.1"),(null==c?void 0:c.path_replace)&&(a.pathname=null==c?void 0:c.path_replace),o.fullUrlGroupMatched===l.matched&&(null===(e=null==c?void 0:c.full_url_group)||void 0===e?void 0:e.length)===1&&c.replace&&!(c.replace.includes("${currentHost}")&&!s))try{a=new URL(a.toString().replace(new RegExp(c.full_url_group[0]),c.replace.replace("${currentHost}",s)))}catch(t){}if(o.patternGroupMatched===l.matched&&(null===(n=null==c?void 0:c.pattern_group)||void 0===n?void 0:n.length)===1&&c.pattern_replace)try{a.pathname=a.pathname.replace(new RegExp(c.pattern_group[0]),c.pattern_replace)}catch(t){}return a}(c=l||(l={})).no_config="no_config",c.matched="matched",c.not_matched="not_matched";var tw={ttnetUrlDispatch:function(t){var e=t.urlObj,n=t.matchActionResult,r=t.referrer,o=t.actionConfig;return o.action!==s.tc&&o.action!==s.web_tc?{result:[],actionRan:!1}:{result:[tS({urlObj:e,matchActionResult:n,referrer:r,processParams:o.param})],actionRan:!0}}};function tC(t){var e,n=t.tncSchema,r=t.storeType,o=(n||{}).ttnet_dispatch_actions_epoch;if(!!o&&!!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.bestRouting})))try{return r.getSync({tableName:a.tnc_best_routing,key:[o]})}catch(t){return}}function tT(t){var e;return m(this,void 0,void 0,function(){var n,r,o,i,c,s,l,h,d,f,p,v,m,g;return y(this,function(y){switch(y.label){case 0:if(n=t.processResults,r=t.responseStatus,o=t.tncSchema,i=t.storeType,c=(o||{}).ttnet_dispatch_actions_epoch,!o||!c)return[2];s=0,l=n,y.label=1;case 1:if(!(sh?(l=[e],h=n):n===h&&l.push(e)}),!(null==l?void 0:l.length)||(_(i.use_default_host)||i.use_default_host>0)&&l.includes(n))?n:l[0]}({host:e.host,actionConfig:n,bestRoutingResult:r}),i=new URL(e);return o&&(i.host=o),{result:[i],actionRan:!0}},tM=function(){function t(){var t=this;this.beforeProcess=function(e){var n=e.tncSchema,r=e.store;return m(t,void 0,void 0,function(){var t;return y(this,function(e){switch(e.label){case 0:if(!r.isSupportSync)return[3,1];return t=tC({tncSchema:n,storeType:r}),[3,3];case 1:return[4,function(t){var e;return m(this,void 0,void 0,function(){var n,r,o;return y(this,function(i){if(n=t.tncSchema,r=t.storeType,!(o=(n||{}).ttnet_dispatch_actions_epoch)||!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.bestRouting})))return[2];try{return[2,r.get({tableName:a.tnc_best_routing,key:[o]})]}catch(t){}return[2]})})}({tncSchema:n,storeType:r})];case 2:t=e.sent(),e.label=3;case 3:return[2,{ttnetUrlDispatchData:t}]}})})},this.beforeProcessSync=function(t){var e,n=t.tncSchema,r=t.store;return{ttnetUrlDispatchData:e=r.isSupportSync?tC({tncSchema:n,storeType:r}):void 0}},this.getTtnetUrlDispatchData=function(e){var n=e.preGetData;return m(t,void 0,void 0,function(){return y(this,function(t){return[2,n]})})},this.ttnetUrlDispatch=tR}return t.prototype.afterSchemaLoadInit=function(t){!function(t){m(this,void 0,void 0,function(){var e,n,r,o;return y(this,function(i){switch(i.label){case 0:if(e=t.tncSchema,n=t.storeType,r=t.value,!(o=(e||{}).ttnet_dispatch_actions_epoch))return[2];i.label=1;case 1:if(i.trys.push([1,5,,6]),!r)return[3,2];return n.setCache({tableName:a.tnc_best_routing,key:[o],value:r}),[2,r];case 2:return[4,n.readDataToCache({tableName:a.tnc_best_routing,key:[o]})];case 3:return[2,i.sent()];case 4:return[3,6];case 5:return i.sent(),[2];case 6:return[2]}})})}({tncSchema:t.tncSchema,storeType:t.store})},t.prototype.beforeFetch=function(t){return{needResponseStatus:t.processResults.some(function(t){var e=t.actionConfig;return(e.action===s.dispatch||e.action===s.web_dispatch)&&e.param.dispatch_strategy===u.bestRouting})}},t.prototype.afterFetchSuccess=function(t){var e=t.processResults,n=t.tncSchema,r=t.responseStatus,o=t.storeType;return m(this,void 0,void 0,function(){return y(this,function(t){return tT({processResults:e,tncSchema:n,responseStatus:r,storeType:o}),[2]})})},t.prototype.afterFetchError=function(t){var e=t.processResults,n=t.tncSchema,r=t.storeType;return m(this,void 0,void 0,function(){return y(this,function(t){return tT({processResults:e,tncSchema:n,responseStatus:null,storeType:r}),[2]})})},t}();function tI(t){var e,n=t.tncSchema,r=t.storeType,o=(n||{}).ttnet_dispatch_actions_epoch;if(!!o&&!!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.dynamicRouting})))try{return r.getSync({tableName:a.tnc_dynamic_routing,key:[o]})}catch(t){return}}function tU(t){return m(this,void 0,void 0,function(){var e,n,r,o;return y(this,function(i){if(e=t.tncSchema,n=t.storeType,r=t.value,!(o=(e||{}).ttnet_dispatch_actions_epoch))return[2];try{if(r)return n.setCache({tableName:a.tnc_dynamic_routing,key:[o],value:r}),[2,r];return[2,n.readDataToCache({tableName:a.tnc_dynamic_routing,key:[o]})]}catch(t){}return[2]})})}function tN(t){var e;return m(this,void 0,void 0,function(){var n,r,o;return y(this,function(i){if(n=t.tncSchema,r=t.storeType,!(o=(n||{}).ttnet_dispatch_actions_epoch)||!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.dynamicRouting})))return[2];try{return[2,r.get({tableName:a.tnc_dynamic_routing,key:[o]})]}catch(t){}return[2]})})}function tP(t){return m(this,void 0,void 0,function(){var e,n,r,o,i,c,s,u;return y(this,function(l){switch(l.label){case 0:if(e=t.sign,n=t.host,r=t.tncSchema,o=t.storeType,!(i=(r||{}).ttnet_dispatch_actions_epoch))return[2];l.label=1;case 1:return l.trys.push([1,5,,6]),[4,o.createTransaction({tableNames:[a.tnc_dynamic_routing],mode:"readwrite"})];case 2:return c=l.sent(),[4,o.get({tableName:a.tnc_dynamic_routing,key:[i],transaction:c,notUseCache:!0})];case 3:return s=l.sent(),u=function(t){var e=t.tncSchema,n=t.dynamicRoutingData,r=t.sign,o=t.host,i=(e||{}).ttnet_dispatch_actions_epoch,c=n||{ttnet_dispatch_actions_epoch:i,routing:{}};return o?c.routing[r]={result:o}:Reflect.deleteProperty(c.routing,r),c}({tncSchema:r,dynamicRoutingData:s,sign:e,host:n}),[4,o.put({tableName:a.tnc_dynamic_routing,key:[i],value:u,transaction:c})];case 4:return l.sent(),[2,u];case 5:return l.sent(),[2];case 6:return[2]}})})}var tx="tnc_update_dynamic_routing",tD=function(){function t(t){var e=this;this.status="stop",this.aid=t.aid,this.tncSchema=t.tncSchema,this.storeType=t.storeType,this.internalFetch=t.internalFetch,N()&&self.addEventListener("message",function(t){var n,r,o=t.data;o.action===tx&&((null===(n=o.payload.tncSchema)||void 0===n?void 0:n.ttnet_dispatch_actions_epoch)===(null===(r=e.tncSchema)||void 0===r?void 0:r.ttnet_dispatch_actions_epoch)||o.payload.aid===e.aid)&&tU({tncSchema:o.payload.tncSchema,storeType:e.storeType})})}return t.prototype.start=function(){this.status="running",this.startRoutingTask({firstDelay:3e3})},t.prototype.stop=function(){this.routingTaskTimer&&clearTimeout(this.routingTaskTimer),this.status="stop"},t.prototype.setTncSchema=function(t){var e,n=this.tncSchema;this.tncSchema=t,"running"===this.status&&(n?(null==n?void 0:n.ttnet_dispatch_actions_epoch)!==(null===(e=this.tncSchema)||void 0===e?void 0:e.ttnet_dispatch_actions_epoch)&&this.startRoutingTask():this.startRoutingTask({firstDelay:3e3}))},t.prototype.runRoutingTaskOnce=function(){var t,e,n;return m(this,void 0,void 0,function(){var r,o=this;return y(this,function(i){switch(i.label){case 0:r=null===(n=null===(e=null===(t=this.tncSchema)||void 0===t?void 0:t.ttnet_dispatch_actions)||void 0===e?void 0:e.filter(function(t){return t.param.dispatch_strategy===u.dynamicRouting}))||void 0===n?void 0:n.map(function(t){return o.routingActionTask(t)}),i.label=1;case 1:if(i.trys.push([1,6,,7]),!(null==r?void 0:r.length))return[3,3];return[4,Promise.all(r)];case 2:return i.sent(),[3,5];case 3:return[4,Promise.resolve()];case 4:i.sent(),i.label=5;case 5:return[3,7];case 6:return i.sent(),[3,7];case 7:return[2]}})})},t.prototype.startRoutingTask=function(t){var e=this;if(this.routingTaskTimer&&clearTimeout(this.routingTaskTimer),!!this.tncSchema){var n=function(){return m(e,void 0,void 0,function(){var t,e,r,o,i,c=this;return y(this,function(a){switch(a.label){case 0:t=null===(o=null===(r=null===(e=this.tncSchema)||void 0===e?void 0:e.ttnet_dispatch_actions)||void 0===r?void 0:r.filter(function(t){return t.param.dispatch_strategy===u.dynamicRouting}))||void 0===o?void 0:o.map(function(t){return c.routingActionTask(t)}),a.label=1;case 1:if(a.trys.push([1,6,,7]),!(null==t?void 0:t.length))return[3,3];return[4,Promise.all(t)];case 2:return a.sent(),[3,5];case 3:return[4,Promise.resolve()];case 4:a.sent(),a.label=5;case 5:return[3,7];case 6:return a.sent(),[3,7];case 7:return this.routingTaskTimer=setTimeout(n,(null===(i=this.tncSchema)||void 0===i?void 0:i.route_selection_trigger_interval)?1e3*this.tncSchema.route_selection_trigger_interval:18e5),[2]}})})};(null==t?void 0:t.firstDelay)?this.routingTaskTimer=setTimeout(n,t.firstDelay):n()}},t.prototype.routingActionTask=function(t){var e,n,r;return m(this,void 0,void 0,function(){var o,i,c,a,s,l,h,d,f,p,v,m=this;return y(this,function(g){switch(g.label){case 0:if(!this.tncSchema||t.param.dispatch_strategy!==u.dynamicRouting)return[2];return o=t.param.strategy_info,[4,tN({tncSchema:this.tncSchema,storeType:this.storeType})];case 1:if(i=null===(r=null===(n=null===(e=g.sent())||void 0===e?void 0:e.routing)||void 0===n?void 0:n[t.sign])||void 0===r?void 0:r.result,1!==o.working_mode)return[3,7];c=void 0,a=0,s=function(t){var e;return y(this,function(t){switch(t.label){case 0:return[4,Promise.all(o.candidates.map(function(t){return m.fetchRoutingPath({path:"".concat(t.host).concat(t.speed_path||"/ies/speed/").concat(1===t.speed_random_query?"?speed_random_query="+Math.random().toString().split(".")[1]:""),threshold:t.threshold,scheme_option:o.scheme_option,error_code:o.error_code})}))];case 1:if(t.sent().forEach(function(t,n){if(0!==t.status){var r=o.candidates[n],c=(r.host===i&&r.weight_increase_percent_if_using?t.time*((100-r.weight_increase_percent_if_using)/100)+(r.weight||0):t.time)+(r.weight||0);(!e||c=e.candidate.consecutive_fastest)return[2,"break"];return[2]}})},l=0,g.label=2;case 2:if(!(l<10))return[3,5];return[5,s(l)];case 3:if("break"===g.sent())return[3,5];g.label=4;case 4:return l++,[3,2];case 5:return[4,tP({sign:t.sign,host:c,tncSchema:this.tncSchema,storeType:this.storeType})];case 6:(h=g.sent())&&this.tncSchema&&k(d={action:tx,payload:{aid:this.aid,tncSchema:this.tncSchema,dynamicRouting:h}}),g.label=7;case 7:if(2!==o.working_mode)return[3,13];f=void 0,l=0,g.label=8;case 8:if(!(l=(c||0)&&(u.forbidTime=Date.now()),s.hosts[o]=u}else 1===i&&(s.usingHost=o,delete s.hosts[o]);return a.elimination[r]=s,a}({ttnet_dispatch_actions_epoch:s,eliminationData:g,sign:p.sign,host:f,status:_(r)||(null===(e=null==v?void 0:v.error_code)||void 0===e?void 0:e.includes(r))||o&&(null==v?void 0:v.timeout)&&o>(null==v?void 0:v.timeout)?-1:1,least_sample:null==v?void 0:v.least_sample}),[4,c.put({tableName:a.tnc_elimination,key:[s],value:b,transaction:m})];case 5:return y.sent(),[3,7];case 6:return y.sent(),[2];case 7:return l++,[3,1];case 8:return[2]}})})}var tA=function(t){var e=t.urlObj,n=t.actionConfig,r=t.ttnetDispatchActionData;if(n.action!==s.dispatch&&n.action!==s.web_dispatch||n.param.dispatch_strategy!==u.elimination)return{result:[],actionRan:!1};var o=function(t){var e,n,r,o,i=t.host,c=t.actionConfig,a=t.eliminationResult,s=null===(n=null==c?void 0:c.param)||void 0===n?void 0:n.strategy_info;if((null==c?void 0:c.param.dispatch_strategy)!==u.elimination||!s)return i;var l=null===(r=s.target_hosts)||void 0===r?void 0:r.filter(function(t){var e,n,r=null===(n=null===(e=null==a?void 0:a.elimination[c.sign])||void 0===e?void 0:e.hosts)||void 0===n?void 0:n[t];return!r||!r.failSamples||!r.forbidTime||!(r.failSamples>=(s.least_sample||0)&&r.forbidTime+1e3*(s.forbid_duration||0)>=Date.now())&&!0});if(!(null==l?void 0:l.length)||(_(s.use_default_host)||s.use_default_host>0)&&l.includes(i))return i;var h=null===(o=null==a?void 0:a.elimination[c.sign])||void 0===o?void 0:o.usingHost;if(h&&l.includes(h))return h;if(!_(s.random_select)&&s.random_select>0){;return(e=l)[Math.floor(Math.random()*e.length)]}return l[0]}({host:e.host,actionConfig:n,eliminationResult:r}),i=new URL(e);return o&&(i.host=o),{result:[i],actionRan:!0}},tF=function(){function t(){var t=this;this.getTtnetUrlDispatchData=function(e){var n=e.preGetData;return m(t,void 0,void 0,function(){return y(this,function(t){return[2,n]})})},this.ttnetUrlDispatch=tA}return t.prototype.afterSchemaLoadInit=function(t){!function(t){m(this,void 0,void 0,function(){var e,n,r,o;return y(this,function(i){if(e=t.tncSchema,n=t.storeType,r=t.value,!(o=(e||{}).ttnet_dispatch_actions_epoch))return[2];try{if(r)return n.setCache({tableName:a.tnc_elimination,key:[o],value:r}),[2,r];return[2,n.readDataToCache({tableName:a.tnc_elimination,key:[o]})]}catch(t){}return[2]})})}({tncSchema:t.tncSchema,storeType:t.store})},t.prototype.beforeProcess=function(t){var e=t.tncSchema,n=t.store;return m(this,void 0,void 0,function(){var t;return y(this,function(r){switch(r.label){case 0:if(!n.isSupportSync)return[3,1];return t=tO({tncSchema:e,storeType:n}),[3,3];case 1:return[4,function(t){var e;return m(this,void 0,void 0,function(){var n,r,o;return y(this,function(i){if(n=t.tncSchema,r=t.storeType,!(o=(n||{}).ttnet_dispatch_actions_epoch)||!(null===(e=null==n?void 0:n.ttnet_dispatch_actions)||void 0===e?void 0:e.some(function(t){var e;return(null===(e=null==t?void 0:t.param)||void 0===e?void 0:e.dispatch_strategy)===u.elimination})))return[2];try{return[2,r.get({tableName:a.tnc_elimination,key:[o]})]}catch(t){}return[2]})})}({tncSchema:e,storeType:n})];case 2:t=r.sent(),r.label=3;case 3:return[2,{ttnetUrlDispatchData:t}]}})})},t.prototype.beforeProcessSync=function(t){var e,n=t.tncSchema,r=t.store;return{ttnetUrlDispatchData:e=r.isSupportSync?tO({tncSchema:n,storeType:r}):void 0}},t.prototype.beforeFetch=function(t){return{needResponseStatus:t.processResults.some(function(t){var e=t.actionConfig;return(e.action===s.dispatch||e.action===s.web_dispatch)&&e.param.dispatch_strategy===u.elimination})}},t.prototype.afterFetchSuccess=function(t){var e=t.processResults,n=t.tncSchema,r=t.responseStatus,o=t.storeType,i=t.timeConsuming;return m(this,void 0,void 0,function(){return y(this,function(t){return tL({processResults:e,tncSchema:n,responseStatus:r,timeConsuming:i,storeType:o}),[2]})})},t.prototype.afterFetchError=function(t){var e=t.processResults,n=t.tncSchema,r=t.storeType;return m(this,void 0,void 0,function(){return y(this,function(t){return tL({processResults:e,timeConsuming:void 0,tncSchema:n,responseStatus:null,storeType:r}),[2]})})},t}(),tH={ttnetUrlDispatch:function(t){var e,n,r,o,i,c,a=t.urlObj,l=t.matchActionResult,h=t.referrer,d=t.actionConfig;if(d.action!==s.dispatch&&d.action!==s.web_dispatch||d.param.dispatch_strategy!==u.orderTry)return{result:[],actionRan:!1};return{result:(n=(e={urlObj:a,matchActionResult:l,referrer:h,actionConfig:d}).urlObj,r=e.matchActionResult,o=e.referrer,c=null==(i=e.actionConfig)?void 0:i.param.strategy_info,(null==i?void 0:i.param.dispatch_strategy)===u.orderTry&&(null==c?void 0:c.targets.length)?(0===c.use_default_host?c.targets:c.targets.sort(function(t,e){return t.host_replace&&t.host_replace!==n.host?e.host_replace&&e.host_replace!==n.host?0:1:-1})).map(function(t){return tS({urlObj:n,matchActionResult:r,referrer:o,processParams:p({full_url_group:i.param.full_url_group,pattern_group:i.param.pattern_group},t)})}):[n]),actionRan:!0}},beforeFetch:function(t){return{retryErrorResponseStatuses:function(t){for(var e,n=t.processResults,r=n.length-1;r>=0;r--){var o=n[r].actionConfig;if((o.action===s.dispatch||o.action===s.web_dispatch)&&o.param.dispatch_strategy===u.orderTry)return null===(e=o.param.strategy_info)||void 0===e?void 0:e.error_code}}({processResults:t.processResults})}}};function tG(t){var e,n=t.url,r=t.tncSchema,o={};if(!(null==r?void 0:r.web_request_control))return o;try{e=new URL(n)}catch(t){return o}if(Array.isArray(r.web_request_control.mode_change))for(var i=0,c=r.web_request_control.mode_change;i0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]0&&o[o.length-1])&&(6===a[0]||2===a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]=this.getSendLogSize()))return[3,2];return a=this.logs,this.logs=[],this.restartTimer(),[4,this.sendLogs(a)];case 1:s.sent(),s.label=2;case 2:return[3,4];case 3:this.cacheLogBeforeGetSchema.pushLog({log_type:e,log_data:t,event_time:Date.now()}),s.label=4;case 4:return[2]}})})},t.prototype.sendLogs=function(t){return et(this,void 0,void 0,function(){return ee(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,function(t){var e,n,r,o;return et(this,void 0,void 0,function(){var i,c,a,s,u,l,h,d,f,p,v,m,y;return ee(this,function(g){switch(g.label){case 0:var b;return i=t.clsSchema,c=t.clsConfig,[4,(b=JSON.stringify(t.logData),(null==self?void 0:self.CompressionStream)?new Response(new Blob([b]).stream().pipeThrough(new self.CompressionStream("gzip"))).arrayBuffer():b)];case 1:switch(a=g.sent(),s=[],c.region){case"boe":s=s.concat(["cls-boe.zijieapi.com"]);break;case"abroad":s=s.concat(["cls.byteintlapi.com"]);break;default:s=s.concat(["cls.zijieapi.com"])}(null===(n=null===(e=null==i?void 0:i.config_data)||void 0===e?void 0:e.common)||void 0===n?void 0:n.report_hosts)&&(s=s.concat(null===(o=null===(r=null==i?void 0:i.config_data)||void 0===r?void 0:r.common)||void 0===o?void 0:o.report_hosts)),!(u=c.device_platform)&&(u=er()),l={aid:c.aid,device_platform:u,device_id:c.device_id,version_code:c.version_code,cls_sdk_version:ei,update_version_code:c.update_version_code,device_model:c.device_model,os_version:c.os_version,channel:c.channel,sdk_id:c.sdk_id},h=new URLSearchParams,Object.entries(l).map(function(t){var e=t[0],n=t[1];!en(n)&&h.append(e,n.toString())}),d=h.toString(),p=function(t){var e,n;return ee(this,function(r){switch(r.label){case 0:e="https://".concat(t,"/cls/log/json_collect?").concat(d),r.label=1;case 1:return r.trys.push([1,3,,4]),[4,new Promise(function(t,n){c.internalFetch({url:e,method:"POST",expectResponseType:"json",data:a,header:{"content-type":"application/json;encoding=utf-8","content-encoding":"gzip"},success:function(e){t(e.data)},fail:function(){n()}})})];case 2:if((n=r.sent()).data&&"ok"===n.message)return f=n.data,[2,"break"];return[2,"continue"];case 3:return r.sent(),[3,4];case 4:return[2]}})},v=0,m=s,g.label=2;case 2:if(!(v0&&(t.sendLogs(t.logs),t.logs=[],t.restartTimer())},this.getSendLogInterval())},t.prototype.stopTimer=function(){clearInterval(this.timer),this.timer=null},t.prototype.restartTimer=function(){this.stopTimer(),this.startTimer()},t.prototype.getSendLogInterval=function(){var t,e,n,r,o,i;return(null===(n=null===(e=null===(t=this.clsSchemaManager.getClsSchema())||void 0===t?void 0:t.config_data)||void 0===e?void 0:e.report)||void 0===n?void 0:n.interval)?1e3*Number(null===(i=null===(o=null===(r=this.clsSchemaManager.getClsSchema())||void 0===r?void 0:r.config_data)||void 0===o?void 0:o.report)||void 0===i?void 0:i.interval):1e4},t.prototype.getSendLogSize=function(){var t,e,n,r,o,i;return(null===(n=null===(e=null===(t=this.clsSchemaManager.getClsSchema())||void 0===t?void 0:t.config_data)||void 0===e?void 0:e.report)||void 0===n?void 0:n.max_log_number)?Number(null===(i=null===(o=null===(r=this.clsSchemaManager.getClsSchema())||void 0===r?void 0:r.config_data)||void 0===o?void 0:o.report)||void 0===i?void 0:i.max_log_number):32},t.prototype.clearCacheLogBeforeGetSchema=function(){return et(this,void 0,void 0,function(){var t;return ee(this,function(e){switch(e.label){case 0:if(this.cacheLogBeforeGetSchemaPopped)return[2];this.cacheLogBeforeGetSchemaPopped=!0,e.label=1;case 1:if(!(t=this.cacheLogBeforeGetSchema.popLog()))return[3,3];return[4,this.addLog(t.log_data,t.log_type,t.event_time)];case 2:return e.sent(),[3,4];case 3:return[3,5];case 4:return[3,1];case 5:return[2]}})})},t}(),ea=function(){function t(){this.events={}}return t.prototype.on=function(t,e){!this.events[t]&&(this.events[t]=[]),this.events[t].push(e)},t.prototype.emit=function(t){for(var e=[],n=1;n1)))return[3,5];if(e=eS.clients,!(r=null===(u=null==i?void 0:i.tncFetchEvent)||void 0===u?void 0:u.clientId))return[3,5];if(!("get"in e))return[3,3];return[4,e.get(r)];case 2:return t=(c=null==(o=l.sent())?void 0:o.url)||"",[3,5];case 3:return[4,e.matchAll({type:"window"})];case 4:(a=l.sent().filter(function(t){return t.id===r})).length>0&&(t=(c=a[0].url)||""),l.label=5;case 5:return[3,7];case 6:return l.sent(),[3,7];case 7:return[2,t]}})})}})]})})}})}({tncServiceWorkerManager:n,normalFetch:fetch}),n}f(e,t),e.prototype.destroy=function(){this.addedFetchListeners.forEach(function(t){eS.removeEventListener("fetch",t)}),this.addedFetchListeners=[],t.prototype.destroy.call(this)},e.prototype.listenFetchEvent=function(t){var e=this,n=(t||{}).fetchFilter,r=function(t){if(n&&!n(t))return;var r=e.tncSchemaManager.getTncSchemaInCache().tncSchema;if(!r||!!function(t){var e,n=t.url,r=t.schema,o=t.referrer,i=t.ignore_referrer;if(!r||1!==r.ttnet_url_dispatcher_enabled||!(null===(e=r.ttnet_dispatch_actions)||void 0===e?void 0:e.length))return!1;for(var c=ey(r),a=eg({url:n,referrer:o}),s=0,u=c||[];s1)))return[3,5];if(e=ew.clients,!(r=null===(u=null==o?void 0:o.tncFetchEvent)||void 0===u?void 0:u.clientId))return[3,5];if(!("get"in e))return[3,3];return[4,e.get(r)];case 2:return t=(c=null==(i=l.sent())?void 0:i.url)||"",[3,5];case 3:return[4,e.matchAll({type:"window"})];case 4:(a=l.sent().filter(function(t){return t.id===r})).length>0&&(t=(c=a[0].url)||""),l.label=5;case 5:return[3,7];case 6:return l.sent(),[3,7];case 7:return[2,t]}})})}})]}return[2,e.apply(void 0,r)]})})}});e.isTncProxyFetch=!0,ew.fetch=e},t.prototype.addTncInstance=function(t){if(!!t.tncManager.tncConfig.aid)this.tncInstances[t.tncManager.tncConfig.aid]={matcher:t.matcher,tncManager:t.tncManager}},t.prototype.removeTncInstance=function(t){if(!!t.tncManager.tncConfig.aid)delete this.tncInstances[t.tncManager.tncConfig.aid]}}();var eT=function(t){var e=t.url,n=t.method,r=t.data,o=t.header,i=t.success,c=t.fail,a=t.complete,s=t.expectResponseType,u=tm();if(!u)throw Error("Unable to get global object");null==u||u.request({url:e,method:n,dataType:void 0===s&&"undefined"!=typeof my?"text":void 0,data:r,header:o,success:i,fail:c||function(){},complete:a||function(){}})};!function(t){function e(e){var n,r=this,o=e.tncConfig,i=o.device_id,c=o.enableLog,a=v(o,["device_id","enableLog"]),s=new X({webStoreCore:new t4({dbStructure:R,backbone:tm()}),cacheMode:o.storeCacheMode});return(r=t.call(this,{tncConfig:p(p({internalFetch:eT},a),{store:s,device_id:null!=i?i:null===(n=t8())||void 0===n?void 0:n.toString()}),plugins:g([tp,tw,new tM,new tq,new tF,tH,tW,new tB],c?[new ed]:[],!0)})||this).store=s,r}f(e,t),e.prototype.updateTncConfig=function(e){var n,r;t.prototype.updateTncConfig.call(this,{tncConfig:p(p({},e.tncConfig),{store:this.store,internalFetch:eT,device_id:null!==(n=e.tncConfig.device_id)&&void 0!==n?n:null===(r=t8())||void 0===r?void 0:r.toString()})})}}(L),tm()}}]);