"use strict";(self.webpackChunkflow_web_extension=self.webpackChunkflow_web_extension||[]).push([["24409"],{793245:function(e,r,c){c.r(r),c.d(r,{SocketClientProxy:()=>M,checkConnection:()=>x,connectSocketIfNeeded:()=>g,discardPort:()=>y,fetchStreamProxyToSW:()=>l,forceReconnectWs:()=>u,keepPort:()=>p});var t,o=c(698127),n=c(702945),s=c(263165),a=c(872193),i=c(641422),d=c(935396),_=c(916874),m=c(48812),f=c(896798),h=new class{constructor(){var e=this;this._recoder=void 0,this._recoderName="",this.start=function(r){var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"cici_im_fetch_stream_action_perf",t=d.zd.get("cici_summary_page_action_perf");t?(e._recoderName="cici_summary_page_action_perf",e._recoder=t):(e._recoder=d.zd.create(c,!0),e._recoderName=c),e._recoder.mark(r),(0,m.cM)("[ts] ImCorePerfRecoder start ".concat(e._recoderName,"[").concat(r,"]"))},this.mark=function(r){var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"cici_im_fetch_stream_action_perf";if(!e._recoder){e.start(r,c);return}(0,m.cM)("[ts] ImCorePerfRecoder mark ".concat(e._recoderName,"[").concat(r,"]")),e._recoder.mark(r)},this.end=function(r){var c=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e._recoder&&((0,m.cM)("[ts] ImCorePerfRecoder end ".concat(e._recoderName,"[").concat(r,"], categories: "),c),e._recoder.end(r,c),d.zd.remove(e._recoderName),e._recoderName="",e._recoder=void 0)}}},l=e=>{var{req:r,reportMeta:c,onMessage:t,onError:n,onFinish:a,subscribeAbortTrigger:d,getCommonHttpParams:_}=e;(0,m.cM)(null==c?void 0:c.conversationId);var l=(0,i.sc)();null==d||d(e=>{f.cQ.abort(l,e)}),h.mark("start_fetch_stream"),(0,m.cM)("[lwx] start fetch stream...",e);var v={};f.cQ.fetch({reportMeta:c,req:(0,o._)({},{params:null==_?void 0:_()},r)},{id:l,onUpdate:e=>{var{body:r,logId:c=""}=e;if("1"==="".concat(null==r?void 0:null===(o=r.message)||void 0===o?void 0:o.chunk_seq)){(0,m.cM)("[lwx] fetch stream first message",r);var o,n,{source:s,input_skill:a}=(null==r?void 0:null===(n=r.message)||void 0===n?void 0:n.ext)||{};if(s&&(v.source=s),a)try{var{skill_type:i}=JSON.parse(a)||{};v.inputSkillType="".concat(i)}catch(e){(0,m.vU)("parse input skill type error: ",e)}h.mark("fetch_stream_first_message")}t(r,c)},onError:e=>{var{jsonData:r,logId:c=""}=e;h.mark("fetch_stream_error"),h.end("end_fetch_stream",v);var t={code:s.jK.ServerError,message:r};(0,m.vU)("fetchStreamProxyToSW onError: ",t,c),n(t,c)},onDone:()=>{h.end("end_fetch_stream",v),(0,m.cM)("[lwx] fetch stream done"),a(!0)}})},v=(t=(0,_.E)("im-sdk-socket"),()=>t),k=(e,r)=>v().postMessage({body:{type:e,payload:r}}),p=()=>{k("keep-port")},u=()=>{k("force-reconnect")},g=e=>{k("connect-if-needed",{options:e})},y=()=>{k("discard-port")},x=()=>{h.start("check_connection","cici_im_connection_action_perf"),k("check-connection")};class M extends a.Z{constructor(){super(),this.reconnect=n.Z,this.close=n.Z,this.destroy=n.Z,this.send=e=>{(0,m.cM)("[Daniel] - send \uD83D\uDD3C",e),"string"==typeof e&&(h.mark("send_socket_message"),k("message",(0,o._)({},JSON.parse(e))))},this.init=e=>{(0,m.cM)("[zoei] socketClientProxy.init - connectSocketIfNeeded",e),h.mark("socket_proxy_init_begin"),g(e),v().onMessage.addListener(e=>{(0,m.cM)("[Daniel] - recv \uD83D\uDD3D",e),e.body&&this.emit("message",e.body)}),h.end("socket_proxy_init_end")}}}}}]);
//# sourceMappingURL=24409.js.map