cesium-ws-patch
Version:
Cesium WebSocket 多连接补丁,支持请求耗时统计、负载均衡、超时重试等功能
1 lines • 40.7 kB
JavaScript
(function(e,t){"object"===typeof exports&&"object"===typeof module?module.exports=t():"function"===typeof define&&define.amd?define([],t):"object"===typeof exports?exports["index"]=t():e["index"]=t()})(this,(function(){return function(){var e={321:function(e,t,r){var n=r(477);e.exports=function(){return n('(function(){let e,t=null;function r(){return t||(t=new Promise(((e,t)=>{const r=indexedDB.open("CesiumCacheDB",1);r.onupgradeneeded=e=>{const t=e.target.result;t.objectStoreNames.contains("files")||t.createObjectStore("files")},r.onsuccess=t=>e(t.target.result),r.onerror=e=>t(e.target.error)})),t)}async function s(t,s){return e||(e=await r()),new Promise(((r,o)=>{const a=e.transaction("files","readwrite");a.objectStore("files").put(s,t),a.oncomplete=()=>r(),a.onerror=e=>o(e.target.error)}))}async function o(t){return e||(e=await r()),new Promise(((r,s)=>{const o=e.transaction("files","readonly"),a=o.objectStore("files").get(t);a.onsuccess=()=>r(a.result||null),a.onerror=e=>s(e.target.error)}))}async function a(t){return e||(e=await r()),new Promise(((r,s)=>{const o=e.transaction("files","readwrite");o.objectStore("files").delete(t),o.oncomplete=()=>r(),o.onerror=e=>s(e.target.error)}))}async function n(){return e||(e=await r()),new Promise(((t,r)=>{const s=e.transaction("files","readonly"),o=s.objectStore("files"),a=[],n=o.openCursor();n.onsuccess=e=>{const r=e.target.result;r?(a.push({name:r.key,size:r.value.byteLength}),r.continue()):t(a)},n.onerror=e=>r(e.target.error)}))}async function c(){return e||(e=await r()),new Promise(((t,r)=>{const s=e.transaction("files","readwrite");s.objectStore("files").clear(),s.oncomplete=()=>t(),s.onerror=e=>r(e.target.error)}))}self.onmessage=async e=>{const{type:t,key:r,buffer:i}=e.data,l=r.replace(/[^\\w.-]/g,"_");try{switch(t){case"write":await s(l,i),self.postMessage({type:t,key:r,success:!0});break;case"read":{const e=await o(l);e?self.postMessage({type:t,key:r,buffer:e},[e]):self.postMessage({type:t,key:r,buffer:null});break}case"delete":await a(l),self.postMessage({type:t,key:r,success:!0});break;case"list":{const e=await n();self.postMessage({type:t,list:e});break}case"clear":await c(),self.postMessage({type:t,success:!0});break;case"quota":{const{usage:e,quota:r}=await navigator.storage.estimate();self.postMessage({type:t,usage:e,quota:r,free:r-e});break}default:throw new Error(`Unsupported type: ${t}`)}}catch(u){console.error(`[IDBWorker] Error in ${t}:`,u),self.postMessage({type:"error",key:r,error:u.message})}}})();',"Worker",void 0,void 0)}},564:function(e,t,r){var n=r(477);e.exports=function(){return n('(function(){let e;self.onmessage=function(r){if(!r?.data?.id)return;const{id:o,payload:s,modelWsLibPort:t}=r.data;try{if("init"===o)return e=t,void importScripts(`http://${e}/modelWsD/libs/pako.min.js`);const r=pako.inflate(new Uint8Array(s)).buffer;self.postMessage({id:o,buffer:r},[r])}catch(i){console.error("inflate.worker.js 解压失败",i),self.postMessage({id:o,error:i.message})}},self.onerror=function(e){console.error("Worker error:",e)}})();',"Worker",void 0,void 0)}},9931:function(e,t,r){var n=r(477);e.exports=function(){return n('(function(){self.onmessage=async e=>{const{type:a,key:t,data:s}=e.data,r=await navigator.storage.getDirectory();try{switch(a){case"list":{const e=[];for await(const[a,t]of r.entries())if("file"===t.kind){const s=await t.getFile();e.push({name:a,size:s.size})}self.postMessage({type:"list",list:e});break}case"read":{const e=await r.getFileHandle(t),a=await e.getFile(),s=await a.arrayBuffer();self.postMessage({type:"read",key:t,buffer:s},[s]);break}case"write":{const e=await r.getFileHandle(t,{create:!0}),a=await e.createWritable();await a.write(s),await a.close(),self.postMessage({type:"write",key:t,success:!0});break}case"delete":await r.removeEntry(t),self.postMessage({type:"delete",key:t,success:!0});break;case"clear":for await(const[e]of r.entries())await r.removeEntry(e);self.postMessage({type:"clear",success:!0});break;case"quota":{const{usage:e,quota:a}=await navigator.storage.estimate();self.postMessage({type:"quota",usage:e,quota:a,free:a-e});break}default:throw new Error(`Unsupported operation type: ${a}`)}}catch(o){console.error(`[OPFSWorker] 处理 ${a} 时出错:`,o),self.postMessage({type:"error",key:t,error:o.message})}}})();',"Worker",void 0,void 0)}},9662:function(e,t,r){var n=r(614),o=r(6330),i=TypeError;e.exports=function(e){if(n(e))return e;throw i(o(e)+" is not a function")}},6077:function(e,t,r){var n=r(614),o=String,i=TypeError;e.exports=function(e){if("object"==typeof e||n(e))return e;throw i("Can't set "+o(e)+" as a prototype")}},5787:function(e,t,r){var n=r(7976),o=TypeError;e.exports=function(e,t){if(n(t,e))return e;throw o("Incorrect invocation")}},9670:function(e,t,r){var n=r(111),o=String,i=TypeError;e.exports=function(e){if(n(e))return e;throw i(o(e)+" is not an object")}},3013:function(e){e.exports="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView},260:function(e,t,r){"use strict";var n,o,i,a=r(3013),s=r(9781),c=r(7854),u=r(614),f=r(111),l=r(2597),p=r(648),d=r(6330),y=r(8880),g=r(8052),m=r(7045),v=r(7976),h=r(9518),b=r(7674),w=r(5112),x=r(9711),E=r(9909),S=E.enforce,T=E.get,O=c.Int8Array,A=O&&O.prototype,R=c.Uint8ClampedArray,k=R&&R.prototype,I=O&&h(O),M=A&&h(A),_=Object.prototype,C=c.TypeError,j=w("toStringTag"),P=x("TYPED_ARRAY_TAG"),D="TypedArrayConstructor",B=a&&!!b&&"Opera"!==p(c.opera),W=!1,N={Int8Array:1,Uint8Array:1,Uint8ClampedArray:1,Int16Array:2,Uint16Array:2,Int32Array:4,Uint32Array:4,Float32Array:4,Float64Array:8},$={BigInt64Array:8,BigUint64Array:8},F=function(e){if(!f(e))return!1;var t=p(e);return"DataView"===t||l(N,t)||l($,t)},L=function(e){var t=h(e);if(f(t)){var r=T(t);return r&&l(r,D)?r[D]:L(t)}},U=function(e){if(!f(e))return!1;var t=p(e);return l(N,t)||l($,t)},q=function(e){if(U(e))return e;throw C("Target is not a typed array")},z=function(e){if(u(e)&&(!b||v(I,e)))return e;throw C(d(e)+" is not a typed array constructor")},H=function(e,t,r,n){if(s){if(r)for(var o in N){var i=c[o];if(i&&l(i.prototype,e))try{delete i.prototype[e]}catch(a){try{i.prototype[e]=t}catch(u){}}}M[e]&&!r||g(M,e,r?t:B&&A[e]||t,n)}},V=function(e,t,r){var n,o;if(s){if(b){if(r)for(n in N)if(o=c[n],o&&l(o,e))try{delete o[e]}catch(i){}if(I[e]&&!r)return;try{return g(I,e,r?t:B&&I[e]||t)}catch(i){}}for(n in N)o=c[n],!o||o[e]&&!r||g(o,e,t)}};for(n in N)o=c[n],i=o&&o.prototype,i?S(i)[D]=o:B=!1;for(n in $)o=c[n],i=o&&o.prototype,i&&(S(i)[D]=o);if((!B||!u(I)||I===Function.prototype)&&(I=function(){throw C("Incorrect invocation")},B))for(n in N)c[n]&&b(c[n],I);if((!B||!M||M===_)&&(M=I.prototype,B))for(n in N)c[n]&&b(c[n].prototype,M);if(B&&h(k)!==M&&b(k,M),s&&!l(M,j))for(n in W=!0,m(M,j,{configurable:!0,get:function(){return f(this)?this[P]:void 0}}),N)c[n]&&y(c[n],P,n);e.exports={NATIVE_ARRAY_BUFFER_VIEWS:B,TYPED_ARRAY_TAG:W&&P,aTypedArray:q,aTypedArrayConstructor:z,exportTypedArrayMethod:H,exportTypedArrayStaticMethod:V,getTypedArrayConstructor:L,isView:F,isTypedArray:U,TypedArray:I,TypedArrayPrototype:M}},7745:function(e,t,r){var n=r(6244);e.exports=function(e,t){var r=0,o=n(t),i=new e(o);while(o>r)i[r]=t[r++];return i}},1318:function(e,t,r){var n=r(5656),o=r(1400),i=r(6244),a=function(e){return function(t,r,a){var s,c=n(t),u=i(c),f=o(a,u);if(e&&r!=r){while(u>f)if(s=c[f++],s!=s)return!0}else for(;u>f;f++)if((e||f in c)&&c[f]===r)return e||f||0;return!e&&-1}};e.exports={includes:a(!0),indexOf:a(!1)}},3658:function(e,t,r){"use strict";var n=r(9781),o=r(3157),i=TypeError,a=Object.getOwnPropertyDescriptor,s=n&&!function(){if(void 0!==this)return!0;try{Object.defineProperty([],"length",{writable:!1}).length=1}catch(e){return e instanceof TypeError}}();e.exports=s?function(e,t){if(o(e)&&!a(e,"length").writable)throw i("Cannot set read only .length");return e.length=t}:function(e,t){return e.length=t}},1843:function(e,t,r){var n=r(6244);e.exports=function(e,t){for(var r=n(e),o=new t(r),i=0;i<r;i++)o[i]=e[r-i-1];return o}},1572:function(e,t,r){var n=r(6244),o=r(9303),i=RangeError;e.exports=function(e,t,r,a){var s=n(e),c=o(r),u=c<0?s+c:c;if(u>=s||u<0)throw i("Incorrect index");for(var f=new t(s),l=0;l<s;l++)f[l]=l===u?a:e[l];return f}},4326:function(e,t,r){var n=r(1702),o=n({}.toString),i=n("".slice);e.exports=function(e){return i(o(e),8,-1)}},648:function(e,t,r){var n=r(1694),o=r(614),i=r(4326),a=r(5112),s=a("toStringTag"),c=Object,u="Arguments"==i(function(){return arguments}()),f=function(e,t){try{return e[t]}catch(r){}};e.exports=n?i:function(e){var t,r,n;return void 0===e?"Undefined":null===e?"Null":"string"==typeof(r=f(t=c(e),s))?r:u?i(t):"Object"==(n=i(t))&&o(t.callee)?"Arguments":n}},9920:function(e,t,r){var n=r(2597),o=r(3887),i=r(1236),a=r(3070);e.exports=function(e,t,r){for(var s=o(t),c=a.f,u=i.f,f=0;f<s.length;f++){var l=s[f];n(e,l)||r&&n(r,l)||c(e,l,u(t,l))}}},8544:function(e,t,r){var n=r(7293);e.exports=!n((function(){function e(){}return e.prototype.constructor=null,Object.getPrototypeOf(new e)!==e.prototype}))},8880:function(e,t,r){var n=r(9781),o=r(3070),i=r(9114);e.exports=n?function(e,t,r){return o.f(e,t,i(1,r))}:function(e,t,r){return e[t]=r,e}},9114:function(e){e.exports=function(e,t){return{enumerable:!(1&e),configurable:!(2&e),writable:!(4&e),value:t}}},7045:function(e,t,r){var n=r(6339),o=r(3070);e.exports=function(e,t,r){return r.get&&n(r.get,t,{getter:!0}),r.set&&n(r.set,t,{setter:!0}),o.f(e,t,r)}},8052:function(e,t,r){var n=r(614),o=r(3070),i=r(6339),a=r(3072);e.exports=function(e,t,r,s){s||(s={});var c=s.enumerable,u=void 0!==s.name?s.name:t;if(n(r)&&i(r,u,s),s.global)c?e[t]=r:a(t,r);else{try{s.unsafe?e[t]&&(c=!0):delete e[t]}catch(f){}c?e[t]=r:o.f(e,t,{value:r,enumerable:!1,configurable:!s.nonConfigurable,writable:!s.nonWritable})}return e}},3072:function(e,t,r){var n=r(7854),o=Object.defineProperty;e.exports=function(e,t){try{o(n,e,{value:t,configurable:!0,writable:!0})}catch(r){n[e]=t}return t}},9781:function(e,t,r){var n=r(7293);e.exports=!n((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]}))},4154:function(e){var t="object"==typeof document&&document.all,r="undefined"==typeof t&&void 0!==t;e.exports={all:t,IS_HTMLDDA:r}},317:function(e,t,r){var n=r(7854),o=r(111),i=n.document,a=o(i)&&o(i.createElement);e.exports=function(e){return a?i.createElement(e):{}}},7207:function(e){var t=TypeError,r=9007199254740991;e.exports=function(e){if(e>r)throw t("Maximum allowed index exceeded");return e}},3678:function(e){e.exports={IndexSizeError:{s:"INDEX_SIZE_ERR",c:1,m:1},DOMStringSizeError:{s:"DOMSTRING_SIZE_ERR",c:2,m:0},HierarchyRequestError:{s:"HIERARCHY_REQUEST_ERR",c:3,m:1},WrongDocumentError:{s:"WRONG_DOCUMENT_ERR",c:4,m:1},InvalidCharacterError:{s:"INVALID_CHARACTER_ERR",c:5,m:1},NoDataAllowedError:{s:"NO_DATA_ALLOWED_ERR",c:6,m:0},NoModificationAllowedError:{s:"NO_MODIFICATION_ALLOWED_ERR",c:7,m:1},NotFoundError:{s:"NOT_FOUND_ERR",c:8,m:1},NotSupportedError:{s:"NOT_SUPPORTED_ERR",c:9,m:1},InUseAttributeError:{s:"INUSE_ATTRIBUTE_ERR",c:10,m:1},InvalidStateError:{s:"INVALID_STATE_ERR",c:11,m:1},SyntaxError:{s:"SYNTAX_ERR",c:12,m:1},InvalidModificationError:{s:"INVALID_MODIFICATION_ERR",c:13,m:1},NamespaceError:{s:"NAMESPACE_ERR",c:14,m:1},InvalidAccessError:{s:"INVALID_ACCESS_ERR",c:15,m:1},ValidationError:{s:"VALIDATION_ERR",c:16,m:0},TypeMismatchError:{s:"TYPE_MISMATCH_ERR",c:17,m:1},SecurityError:{s:"SECURITY_ERR",c:18,m:1},NetworkError:{s:"NETWORK_ERR",c:19,m:1},AbortError:{s:"ABORT_ERR",c:20,m:1},URLMismatchError:{s:"URL_MISMATCH_ERR",c:21,m:1},QuotaExceededError:{s:"QUOTA_EXCEEDED_ERR",c:22,m:1},TimeoutError:{s:"TIMEOUT_ERR",c:23,m:1},InvalidNodeTypeError:{s:"INVALID_NODE_TYPE_ERR",c:24,m:1},DataCloneError:{s:"DATA_CLONE_ERR",c:25,m:1}}},8113:function(e){e.exports="undefined"!=typeof navigator&&String(navigator.userAgent)||""},7392:function(e,t,r){var n,o,i=r(7854),a=r(8113),s=i.process,c=i.Deno,u=s&&s.versions||c&&c.version,f=u&&u.v8;f&&(n=f.split("."),o=n[0]>0&&n[0]<4?1:+(n[0]+n[1])),!o&&a&&(n=a.match(/Edge\/(\d+)/),(!n||n[1]>=74)&&(n=a.match(/Chrome\/(\d+)/),n&&(o=+n[1]))),e.exports=o},748:function(e){e.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]},1060:function(e,t,r){var n=r(1702),o=Error,i=n("".replace),a=function(e){return String(o(e).stack)}("zxcasd"),s=/\n\s*at [^:]*:[^\n]*/,c=s.test(a);e.exports=function(e,t){if(c&&"string"==typeof e&&!o.prepareStackTrace)while(t--)e=i(e,s,"");return e}},2109:function(e,t,r){var n=r(7854),o=r(1236).f,i=r(8880),a=r(8052),s=r(3072),c=r(9920),u=r(4705);e.exports=function(e,t){var r,f,l,p,d,y,g=e.target,m=e.global,v=e.stat;if(f=m?n:v?n[g]||s(g,{}):(n[g]||{}).prototype,f)for(l in t){if(d=t[l],e.dontCallGetSet?(y=o(f,l),p=y&&y.value):p=f[l],r=u(m?l:g+(v?".":"#")+l,e.forced),!r&&void 0!==p){if(typeof d==typeof p)continue;c(d,p)}(e.sham||p&&p.sham)&&i(d,"sham",!0),a(f,l,d,e)}}},7293:function(e){e.exports=function(e){try{return!!e()}catch(t){return!0}}},4374:function(e,t,r){var n=r(7293);e.exports=!n((function(){var e=function(){}.bind();return"function"!=typeof e||e.hasOwnProperty("prototype")}))},6916:function(e,t,r){var n=r(4374),o=Function.prototype.call;e.exports=n?o.bind(o):function(){return o.apply(o,arguments)}},6530:function(e,t,r){var n=r(9781),o=r(2597),i=Function.prototype,a=n&&Object.getOwnPropertyDescriptor,s=o(i,"name"),c=s&&"something"===function(){}.name,u=s&&(!n||n&&a(i,"name").configurable);e.exports={EXISTS:s,PROPER:c,CONFIGURABLE:u}},5668:function(e,t,r){var n=r(1702),o=r(9662);e.exports=function(e,t,r){try{return n(o(Object.getOwnPropertyDescriptor(e,t)[r]))}catch(i){}}},1702:function(e,t,r){var n=r(4374),o=Function.prototype,i=o.call,a=n&&o.bind.bind(i,i);e.exports=n?a:function(e){return function(){return i.apply(e,arguments)}}},5005:function(e,t,r){var n=r(7854),o=r(614),i=function(e){return o(e)?e:void 0};e.exports=function(e,t){return arguments.length<2?i(n[e]):n[e]&&n[e][t]}},8173:function(e,t,r){var n=r(9662),o=r(8554);e.exports=function(e,t){var r=e[t];return o(r)?void 0:n(r)}},7854:function(e,t,r){var n=function(e){return e&&e.Math==Math&&e};e.exports=n("object"==typeof globalThis&&globalThis)||n("object"==typeof window&&window)||n("object"==typeof self&&self)||n("object"==typeof r.g&&r.g)||function(){return this}()||Function("return this")()},2597:function(e,t,r){var n=r(1702),o=r(7908),i=n({}.hasOwnProperty);e.exports=Object.hasOwn||function(e,t){return i(o(e),t)}},3501:function(e){e.exports={}},4664:function(e,t,r){var n=r(9781),o=r(7293),i=r(317);e.exports=!n&&!o((function(){return 7!=Object.defineProperty(i("div"),"a",{get:function(){return 7}}).a}))},8361:function(e,t,r){var n=r(1702),o=r(7293),i=r(4326),a=Object,s=n("".split);e.exports=o((function(){return!a("z").propertyIsEnumerable(0)}))?function(e){return"String"==i(e)?s(e,""):a(e)}:a},9587:function(e,t,r){var n=r(614),o=r(111),i=r(7674);e.exports=function(e,t,r){var a,s;return i&&n(a=t.constructor)&&a!==r&&o(s=a.prototype)&&s!==r.prototype&&i(e,s),e}},2788:function(e,t,r){var n=r(1702),o=r(614),i=r(5465),a=n(Function.toString);o(i.inspectSource)||(i.inspectSource=function(e){return a(e)}),e.exports=i.inspectSource},9909:function(e,t,r){var n,o,i,a=r(4811),s=r(7854),c=r(111),u=r(8880),f=r(2597),l=r(5465),p=r(6200),d=r(3501),y="Object already initialized",g=s.TypeError,m=s.WeakMap,v=function(e){return i(e)?o(e):n(e,{})},h=function(e){return function(t){var r;if(!c(t)||(r=o(t)).type!==e)throw g("Incompatible receiver, "+e+" required");return r}};if(a||l.state){var b=l.state||(l.state=new m);b.get=b.get,b.has=b.has,b.set=b.set,n=function(e,t){if(b.has(e))throw g(y);return t.facade=e,b.set(e,t),t},o=function(e){return b.get(e)||{}},i=function(e){return b.has(e)}}else{var w=p("state");d[w]=!0,n=function(e,t){if(f(e,w))throw g(y);return t.facade=e,u(e,w,t),t},o=function(e){return f(e,w)?e[w]:{}},i=function(e){return f(e,w)}}e.exports={set:n,get:o,has:i,enforce:v,getterFor:h}},3157:function(e,t,r){var n=r(4326);e.exports=Array.isArray||function(e){return"Array"==n(e)}},4067:function(e,t,r){var n=r(648);e.exports=function(e){var t=n(e);return"BigInt64Array"==t||"BigUint64Array"==t}},614:function(e,t,r){var n=r(4154),o=n.all;e.exports=n.IS_HTMLDDA?function(e){return"function"==typeof e||e===o}:function(e){return"function"==typeof e}},4705:function(e,t,r){var n=r(7293),o=r(614),i=/#|\.prototype\./,a=function(e,t){var r=c[s(e)];return r==f||r!=u&&(o(t)?n(t):!!t)},s=a.normalize=function(e){return String(e).replace(i,".").toLowerCase()},c=a.data={},u=a.NATIVE="N",f=a.POLYFILL="P";e.exports=a},8554:function(e){e.exports=function(e){return null===e||void 0===e}},111:function(e,t,r){var n=r(614),o=r(4154),i=o.all;e.exports=o.IS_HTMLDDA?function(e){return"object"==typeof e?null!==e:n(e)||e===i}:function(e){return"object"==typeof e?null!==e:n(e)}},1913:function(e){e.exports=!1},2190:function(e,t,r){var n=r(5005),o=r(614),i=r(7976),a=r(3307),s=Object;e.exports=a?function(e){return"symbol"==typeof e}:function(e){var t=n("Symbol");return o(t)&&i(t.prototype,s(e))}},6244:function(e,t,r){var n=r(7466);e.exports=function(e){return n(e.length)}},6339:function(e,t,r){var n=r(1702),o=r(7293),i=r(614),a=r(2597),s=r(9781),c=r(6530).CONFIGURABLE,u=r(2788),f=r(9909),l=f.enforce,p=f.get,d=String,y=Object.defineProperty,g=n("".slice),m=n("".replace),v=n([].join),h=s&&!o((function(){return 8!==y((function(){}),"length",{value:8}).length})),b=String(String).split("String"),w=e.exports=function(e,t,r){"Symbol("===g(d(t),0,7)&&(t="["+m(d(t),/^Symbol\(([^)]*)\)/,"$1")+"]"),r&&r.getter&&(t="get "+t),r&&r.setter&&(t="set "+t),(!a(e,"name")||c&&e.name!==t)&&(s?y(e,"name",{value:t,configurable:!0}):e.name=t),h&&r&&a(r,"arity")&&e.length!==r.arity&&y(e,"length",{value:r.arity});try{r&&a(r,"constructor")&&r.constructor?s&&y(e,"prototype",{writable:!1}):e.prototype&&(e.prototype=void 0)}catch(o){}var n=l(e);return a(n,"source")||(n.source=v(b,"string"==typeof t?t:"")),e};Function.prototype.toString=w((function(){return i(this)&&p(this).source||u(this)}),"toString")},4758:function(e){var t=Math.ceil,r=Math.floor;e.exports=Math.trunc||function(e){var n=+e;return(n>0?r:t)(n)}},6277:function(e,t,r){var n=r(1340);e.exports=function(e,t){return void 0===e?arguments.length<2?"":t:n(e)}},3070:function(e,t,r){var n=r(9781),o=r(4664),i=r(3353),a=r(9670),s=r(4948),c=TypeError,u=Object.defineProperty,f=Object.getOwnPropertyDescriptor,l="enumerable",p="configurable",d="writable";t.f=n?i?function(e,t,r){if(a(e),t=s(t),a(r),"function"===typeof e&&"prototype"===t&&"value"in r&&d in r&&!r[d]){var n=f(e,t);n&&n[d]&&(e[t]=r.value,r={configurable:p in r?r[p]:n[p],enumerable:l in r?r[l]:n[l],writable:!1})}return u(e,t,r)}:u:function(e,t,r){if(a(e),t=s(t),a(r),o)try{return u(e,t,r)}catch(n){}if("get"in r||"set"in r)throw c("Accessors not supported");return"value"in r&&(e[t]=r.value),e}},1236:function(e,t,r){var n=r(9781),o=r(6916),i=r(5296),a=r(9114),s=r(5656),c=r(4948),u=r(2597),f=r(4664),l=Object.getOwnPropertyDescriptor;t.f=n?l:function(e,t){if(e=s(e),t=c(t),f)try{return l(e,t)}catch(r){}if(u(e,t))return a(!o(i.f,e,t),e[t])}},8006:function(e,t,r){var n=r(6324),o=r(748),i=o.concat("length","prototype");t.f=Object.getOwnPropertyNames||function(e){return n(e,i)}},5181:function(e,t){t.f=Object.getOwnPropertySymbols},9518:function(e,t,r){var n=r(2597),o=r(614),i=r(7908),a=r(6200),s=r(8544),c=a("IE_PROTO"),u=Object,f=u.prototype;e.exports=s?u.getPrototypeOf:function(e){var t=i(e);if(n(t,c))return t[c];var r=t.constructor;return o(r)&&t instanceof r?r.prototype:t instanceof u?f:null}},7976:function(e,t,r){var n=r(1702);e.exports=n({}.isPrototypeOf)},6324:function(e,t,r){var n=r(1702),o=r(2597),i=r(5656),a=r(1318).indexOf,s=r(3501),c=n([].push);e.exports=function(e,t){var r,n=i(e),u=0,f=[];for(r in n)!o(s,r)&&o(n,r)&&c(f,r);while(t.length>u)o(n,r=t[u++])&&(~a(f,r)||c(f,r));return f}},5296:function(e,t){"use strict";var r={}.propertyIsEnumerable,n=Object.getOwnPropertyDescriptor,o=n&&!r.call({1:2},1);t.f=o?function(e){var t=n(this,e);return!!t&&t.enumerable}:r},7674:function(e,t,r){var n=r(5668),o=r(9670),i=r(6077);e.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var e,t=!1,r={};try{e=n(Object.prototype,"__proto__","set"),e(r,[]),t=r instanceof Array}catch(a){}return function(r,n){return o(r),i(n),t?e(r,n):r.__proto__=n,r}}():void 0)},2140:function(e,t,r){var n=r(6916),o=r(614),i=r(111),a=TypeError;e.exports=function(e,t){var r,s;if("string"===t&&o(r=e.toString)&&!i(s=n(r,e)))return s;if(o(r=e.valueOf)&&!i(s=n(r,e)))return s;if("string"!==t&&o(r=e.toString)&&!i(s=n(r,e)))return s;throw a("Can't convert object to primitive value")}},3887:function(e,t,r){var n=r(5005),o=r(1702),i=r(8006),a=r(5181),s=r(9670),c=o([].concat);e.exports=n("Reflect","ownKeys")||function(e){var t=i.f(s(e)),r=a.f;return r?c(t,r(e)):t}},4488:function(e,t,r){var n=r(8554),o=TypeError;e.exports=function(e){if(n(e))throw o("Can't call method on "+e);return e}},6200:function(e,t,r){var n=r(2309),o=r(9711),i=n("keys");e.exports=function(e){return i[e]||(i[e]=o(e))}},5465:function(e,t,r){var n=r(7854),o=r(3072),i="__core-js_shared__",a=n[i]||o(i,{});e.exports=a},2309:function(e,t,r){var n=r(1913),o=r(5465);(e.exports=function(e,t){return o[e]||(o[e]=void 0!==t?t:{})})("versions",[]).push({version:"3.29.1",mode:n?"pure":"global",copyright:"© 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.29.1/LICENSE",source:"https://github.com/zloirock/core-js"})},6293:function(e,t,r){var n=r(7392),o=r(7293);e.exports=!!Object.getOwnPropertySymbols&&!o((function(){var e=Symbol();return!String(e)||!(Object(e)instanceof Symbol)||!Symbol.sham&&n&&n<41}))},1400:function(e,t,r){var n=r(9303),o=Math.max,i=Math.min;e.exports=function(e,t){var r=n(e);return r<0?o(r+t,0):i(r,t)}},4599:function(e,t,r){var n=r(7593),o=TypeError;e.exports=function(e){var t=n(e,"number");if("number"==typeof t)throw o("Can't convert number to bigint");return BigInt(t)}},5656:function(e,t,r){var n=r(8361),o=r(4488);e.exports=function(e){return n(o(e))}},9303:function(e,t,r){var n=r(4758);e.exports=function(e){var t=+e;return t!==t||0===t?0:n(t)}},7466:function(e,t,r){var n=r(9303),o=Math.min;e.exports=function(e){return e>0?o(n(e),9007199254740991):0}},7908:function(e,t,r){var n=r(4488),o=Object;e.exports=function(e){return o(n(e))}},7593:function(e,t,r){var n=r(6916),o=r(111),i=r(2190),a=r(8173),s=r(2140),c=r(5112),u=TypeError,f=c("toPrimitive");e.exports=function(e,t){if(!o(e)||i(e))return e;var r,c=a(e,f);if(c){if(void 0===t&&(t="default"),r=n(c,e,t),!o(r)||i(r))return r;throw u("Can't convert object to primitive value")}return void 0===t&&(t="number"),s(e,t)}},4948:function(e,t,r){var n=r(7593),o=r(2190);e.exports=function(e){var t=n(e,"string");return o(t)?t:t+""}},1694:function(e,t,r){var n=r(5112),o=n("toStringTag"),i={};i[o]="z",e.exports="[object z]"===String(i)},1340:function(e,t,r){var n=r(648),o=String;e.exports=function(e){if("Symbol"===n(e))throw TypeError("Cannot convert a Symbol value to a string");return o(e)}},6330:function(e){var t=String;e.exports=function(e){try{return t(e)}catch(r){return"Object"}}},9711:function(e,t,r){var n=r(1702),o=0,i=Math.random(),a=n(1..toString);e.exports=function(e){return"Symbol("+(void 0===e?"":e)+")_"+a(++o+i,36)}},3307:function(e,t,r){var n=r(6293);e.exports=n&&!Symbol.sham&&"symbol"==typeof Symbol.iterator},3353:function(e,t,r){var n=r(9781),o=r(7293);e.exports=n&&o((function(){return 42!=Object.defineProperty((function(){}),"prototype",{value:42,writable:!1}).prototype}))},4811:function(e,t,r){var n=r(7854),o=r(614),i=n.WeakMap;e.exports=o(i)&&/native code/.test(String(i))},5112:function(e,t,r){var n=r(7854),o=r(2309),i=r(2597),a=r(9711),s=r(6293),c=r(3307),u=n.Symbol,f=o("wks"),l=c?u["for"]||u:u&&u.withoutSetter||a;e.exports=function(e){return i(f,e)||(f[e]=s&&i(u,e)?u[e]:l("Symbol."+e)),f[e]}},7658:function(e,t,r){"use strict";var n=r(2109),o=r(7908),i=r(6244),a=r(3658),s=r(7207),c=r(7293),u=c((function(){return 4294967297!==[].push.call({length:4294967296},1)})),f=function(){try{Object.defineProperty([],"length",{writable:!1}).push()}catch(e){return e instanceof TypeError}},l=u||!f();n({target:"Array",proto:!0,arity:1,forced:l},{push:function(e){var t=o(this),r=i(t),n=arguments.length;s(r+n);for(var c=0;c<n;c++)t[r]=arguments[c],r++;return a(t,r),r}})},1439:function(e,t,r){"use strict";var n=r(1843),o=r(260),i=o.aTypedArray,a=o.exportTypedArrayMethod,s=o.getTypedArrayConstructor;a("toReversed",(function(){return n(i(this),s(this))}))},7585:function(e,t,r){"use strict";var n=r(260),o=r(1702),i=r(9662),a=r(7745),s=n.aTypedArray,c=n.getTypedArrayConstructor,u=n.exportTypedArrayMethod,f=o(n.TypedArrayPrototype.sort);u("toSorted",(function(e){void 0!==e&&i(e);var t=s(this),r=a(c(t),t);return f(r,e)}))},5315:function(e,t,r){"use strict";var n=r(1572),o=r(260),i=r(4067),a=r(9303),s=r(4599),c=o.aTypedArray,u=o.getTypedArrayConstructor,f=o.exportTypedArrayMethod,l=!!function(){try{new Int8Array(1)["with"](2,{valueOf:function(){throw 8}})}catch(e){return 8===e}}();f("with",{with:function(e,t){var r=c(this),o=a(e),f=i(r)?s(t):+t;return n(r,u(r),o,f)}}["with"],!l)},3767:function(e,t,r){r(1439)},8585:function(e,t,r){r(7585)},8696:function(e,t,r){r(5315)},2801:function(e,t,r){"use strict";var n=r(2109),o=r(7854),i=r(5005),a=r(9114),s=r(3070).f,c=r(2597),u=r(5787),f=r(9587),l=r(6277),p=r(3678),d=r(1060),y=r(9781),g=r(1913),m="DOMException",v=i("Error"),h=i(m),b=function(){u(this,w);var e=arguments.length,t=l(e<1?void 0:arguments[0]),r=l(e<2?void 0:arguments[1],"Error"),n=new h(t,r),o=v(t);return o.name=m,s(n,"stack",a(1,d(o.stack,1))),f(n,this,b),n},w=b.prototype=h.prototype,x="stack"in v(m),E="stack"in new h(1,2),S=h&&y&&Object.getOwnPropertyDescriptor(o,m),T=!!S&&!(S.writable&&S.configurable),O=x&&!T&&!E;n({global:!0,constructor:!0,forced:g||O},{DOMException:O?b:h});var A=i(m),R=A.prototype;if(R.constructor!==A)for(var k in g||s(R,"constructor",a(1,A)),p)if(c(p,k)){var I=p[k],M=I.s;c(A,M)||s(A,M,a(6,I.c))}},477:function(e){"use strict";e.exports=function(e,t,r,n){var o=self||window;try{try{var i;try{i=new o.Blob([e])}catch(f){var a=o.BlobBuilder||o.WebKitBlobBuilder||o.MozBlobBuilder||o.MSBlobBuilder;i=new a,i.append(e),i=i.getBlob()}var s=o.URL||o.webkitURL,c=s.createObjectURL(i),u=new o[t](c,r);return s.revokeObjectURL(c),u}catch(f){return new o[t]("data:application/javascript,".concat(encodeURIComponent(e)),r)}}catch(f){if(!n)throw Error("Inline worker is not supported");return new o[t](n,r)}}}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var i=t[n]={exports:{}};return e[n](i,i.exports,r),i.exports}!function(){r.n=function(e){var t=e&&e.__esModule?function(){return e["default"]}:function(){return e};return r.d(t,{a:t}),t}}(),function(){r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})}}(),function(){r.g=function(){if("object"===typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"===typeof window)return window}}()}(),function(){r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}}(),function(){r.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}}(),function(){r.p=""}();var n={};return function(){"use strict";if(r.r(n),r.d(n,{default:function(){return K}}),"undefined"!==typeof window){var e=window.document.currentScript,t=e&&e.src.match(/(.+\/)[^/]+\.js(\?.*)?$/);t&&(r.p=t[1])}r(7658),r(3767),r(8585),r(8696),r(2801);let o,i="ws-monitor-panel",a="ws-monitor-btn";function s(e){const t=document.getElementById(e);if(!t)return console.warn(`[cesium-ws-ui] 容器 #${e} 不存在`);const r=document.createElement("button");r.id=a,r.innerText="📊 模型加载监控",r.style="\n position: absolute;\n top: 10px;\n right: 10px;\n z-index: 10000;\n padding: 5px 10px;\n font-size: 12px;\n border: none;\n border-radius: 4px;\n background: #007aff;\n color: white;\n cursor: pointer;\n ",r.onclick=()=>{const e=document.getElementById(i);e&&(e.style.display="none"===e.style.display?"block":"none")};const n=document.createElement("div");n.id=i,n.style="\n position: absolute;\n top: 50px;\n right: 10px;\n width: 280px;\n max-height: 80%;\n overflow-y: auto;\n background: rgba(0,0,0,0.8);\n color: white;\n font-size: 12px;\n padding: 10px;\n border-radius: 8px;\n z-index: 9999;\n display: none;\n box-shadow: 0 0 8px rgba(0,0,0,0.3);\n scrollbar-width: thin;\n ";const o=document.createElement("div");o.id="ws-summary",o.innerHTML='\n <div style="font-size: 18px;"><b>总连接数:</b> <span id="ws-conn-count">-</span></div>\n <div style="font-size: 18px;"><b>当前剩余任务:</b> <span id="ws-task-count">-</span></div>\n <div style="font-size: 18px;"><b>总耗时:</b> <span id="ws-total-time">-</span> 秒</div>\n <hr>\n ',n.appendChild(o);const s=document.createElement("div");s.id="ws-monitor-content",n.appendChild(s),t.style.position="relative",t.appendChild(r),t.appendChild(n)}function c(e=1e3){function t(e,t){const r=document.getElementById(e);r&&(r.textContent=t)}o=setInterval((()=>{const e=document.getElementById("ws-monitor-content");if(!e||"none"===e.parentElement.style.display)return;const{connections:r,requestsMap:n,pendingRequestsCount:o,requestDurations:i,allCostTime:a}=window.WebSocketPoolDispatcher||{};if(!r)return;t("ws-conn-count",r.length),t("ws-task-count",o),t("ws-total-time",a[0]||"-");let s="";r.forEach(((e,t)=>{const r=["🟥关闭","🟡连接中","🟢已连接","🟣关闭中"][e.readyState]||"❓未知",o=n[t]?.size||0,a=i[t]||[],c=a.length?(a.reduce(((e,t)=>e+t),0)/a.length).toFixed(1):"-";s+=`\n <div><b>连接 ${t+1}</b> ${r}</div>\n <div> ➤ 剩余任务: ${o}</div>\n <div> ➤ 平均耗时: ${c}ms</div>\n <hr>\n `})),e.innerHTML=s}),e)}function u(e={}){let{containerId:t="cesiumcontainer",intervalMs:r=1e3}=e;const n="string"===typeof t?document.getElementById(t):document.getElementById(window.WebSocketPoolDispatcher.cesiumContainer);if(n){if(document.getElementById(i)||document.getElementById(a))return console.error("不可重复初始化");s(t||window.WebSocketPoolDispatcher.cesiumContainer),c(r)}else console.warn(`[WebSocketMonitor] 容器未找到: ${t}`)}function f(){const e=document.getElementById(i);e&&e.remove();const t=document.getElementById(a);t&&t.remove(),o&&clearInterval(o)}var l=r(9931),p=r.n(l);const d="opfs-cache-panel",y="opfs-toggle-button",g=new(p());let m=[],v={usage:0,quota:0,free:0},h=!1;function b(e){if(0===e)return"0 B";const t=1024,r=["B","KB","MB","GB","TB"],n=Math.floor(Math.log(e)/Math.log(t));return parseFloat((e/Math.pow(t,n)).toFixed(2))+" "+r[n]}function w(e){let t=document.getElementById(d);t||(t=document.createElement("div"),t.id=d,t.style.cssText="\n position: absolute;\n top: 80px;\n right: 10px;\n width: 320px;\n max-height: 60%;\n overflow-y: auto;\n background: rgba(0,0,0,0.85);\n color: #fff;\n padding: 10px;\n font-size: 13px;\n border-radius: 8px;\n z-index: 9999;\n display: none;\n ",e.appendChild(t));const r=m.reduce(((e,t)=>e+t.size),0),n=b(r),o=[`\n <div style="display: flex; justify-content: space-between; align-items: center;">\n <strong>OPFS 缓存管理</strong>\n <div>\n <button id="opfs-refresh" style="margin-right: 5px;">刷新</button>\n <button id="opfs-clear">清空</button>\n </div>\n </div>\n <div style="margin-top: 6px; font-size: 12px; color: #ccc;">\n 缓存总大小:${n}\n </div>\n <div style="margin-top: 4px; font-size: 12px; color: #ccc;">\n 已用空间:${b(v.usage)} / 可用空间:${b(v.quota)}\n </div>\n <div style="margin-top: 2px; font-size: 12px; color: #888;">\n 剩余空间:${b(v.free)}\n </div>\n <ul style="margin-top: 10px; list-style: none; padding-left: 0;">\n ${m?.length?m.map((e=>`\n <li style="margin-bottom: 6px;">\n ${e.name} (${b(e.size)})\n <button data-del="${e.name}" style="float: right;">删除</button>\n </li>\n `)).join(""):'<li style="color:#888;">暂无缓存文件</li>'}\n </ul>\n `];t.innerHTML=o.join(""),t.querySelectorAll("button[data-del]").forEach((e=>{e.onclick=()=>{const t=e.dataset.del;g.postMessage({type:"delete",key:t})}})),t.querySelector("#opfs-refresh").onclick=()=>{g.postMessage({type:"list"}),g.postMessage({type:"quota"})},t.querySelector("#opfs-clear").onclick=()=>{g.postMessage({type:"clear"})}}function x(e){const t=document.getElementById(d);t&&(h=!h,t.style.display=h?"block":"none")}function E(e){let t=document.getElementById(y);t||(t=document.createElement("button"),t.id=y,t.textContent="📦 缓存管理",t.style.cssText="\n position: absolute;\n top: 40px;\n right: 10px;\n z-index: 9999;\n background: #007aff;\n color: #fff;\n border: none;\n border-radius: 5px;\n padding: 5px 10px;\n cursor: pointer;\n ",e.appendChild(t)),t.onclick=()=>x(e)}function S(e){const t="string"===typeof e?document.getElementById(e):document.getElementById(WebSocketPoolDispatcher.cesiumContainer);if(t){if(document.getElementById(d)||document.getElementById(y))return console.error("不可重复初始化");E(t),w(t),g.onmessage=e=>{const{type:r,key:n,list:o,success:i,usage:a,quota:s,free:c}=e.data;switch(r){case"list":m=o,w(t);break;case"quota":v={usage:a,quota:s,free:c},w(t);break;case"delete":case"clear":g.postMessage({type:"list"}),g.postMessage({type:"quota"});break;case"error":console.warn(`[OPFSWorker] 错误: ${n} -> ${e.data.error}`);break;default:i&&console.log(`[OPFSWorker] ${r} ${n} 操作成功`)}},g.postMessage({type:"list"}),g.postMessage({type:"quota"})}else console.warn(`[OpfsManager] 容器未找到: ${e}`)}function T(){const e=document.getElementById(d);e&&e.remove();const t=document.getElementById(y);t&&t.remove(),g.terminate()}function O(e,t="初始化",r){let n=`cesium-ws-patch-${e}-progress`;const o=document.getElementById(n);o&&o.remove();const i=document.createElement("div");i.id=n,i.style.position="absolute",i.style.bottom="10px",i.style.right="10px",i.style.width="160px",i.style.padding="6px",i.style.background="rgba(0,0,0,0.6)",i.style.borderRadius="6px",i.style.color="#fff",i.style.fontSize="12px",i.style.zIndex=9999;const a=document.createElement("div");a.innerText=`${t}进度:0 / ${r}`,i.appendChild(a);const s=document.createElement("div");s.style.height="8px",s.style.marginTop="6px",s.style.background="#444",s.style.borderRadius="4px",s.style.overflow="hidden";const c=document.createElement("div");return c.style.height="100%",c.style.width="0%",c.style.background="#4caf50",c.style.transition="width 0.3s ease",s.appendChild(c),i.appendChild(s),{progressWrapper:i,progressInner:c,progressText:a}}function A({containerId:e,classtag:t,textTag:r,allTasksLen:n,ifAlwaysOnline:o}){const i=document.getElementById(e);if(!i)return void console.error(`容器 #${e} 不存在`);i.style.position="relative";let{progressWrapper:a,progressInner:s,progressText:c}=O(t,r,n||0);"loadmodel"===t&&(a.style.display="none"),i.appendChild(a);const u=setInterval((()=>{let e=n||window.WebSocketPoolDispatcher.allToRequestCount,i=0,f=0,l=0;"connect"===t?(l=window.WebSocketPoolDispatcher.connections,f=l.filter((e=>e&&e.readyState===WebSocket.OPEN)).length):"loadmodel"===t&&(f=e-window.WebSocketPoolDispatcher.pendingRequestsCount),i=f/e*100,s.style.width=`${i}%`,c.innerText=`${r}进度:${f} / ${e}`,f>=e?o?a.style.display="none":(clearInterval(u),a.remove()):a.style.display="block"}),500);return!0}var R=r(564),k=r.n(R),I=r(321),M=r.n(I);const _=4e5,C=80,j=3e3,P=5,D="connect",B="loadmodel";let W,N=new Map;function $(e){W=new(k()),W.postMessage({id:"init",modelWsLibPort:e}),W.onmessage=function(e){const{id:t,buffer:r}=e.data,n=N.get(t);n&&(N.delete(t),n(r))},W.onerror=e=>{console.error("inflateWorker 加载失败:",e)}}const F=new(M()),L=new Map;function U(e){return new Promise(((t,r)=>{L.set(e,{resolve:t,reject:r}),F.postMessage({type:"read",key:e})}))}function q(e,t){return new Promise(((r,n)=>{L.set(e,{resolve:r,reject:n}),F.postMessage({type:"write",key:e,buffer:t},[t])}))}function z(e){const t=new WebSocket(`ws://${e}`);return t.binaryType="arraybuffer",t}F.onmessage=function(e){const{type:t,key:r,buffer:n,error:o}=e.data,i=L.get(r);i&&(L.delete(r),"read"===t?i.resolve(n):"written"===t?i.resolve(!0):"error"===t&&i.reject(new Error(o)))},F.onerror=e=>{console.error("cacheWorker 加载失败:",e)};let H=null;const V=(()=>{const e=[],t=[],r=[],n=[],o=[],i=[],a=[];let s=[],c=1;function l(s,c){const u=z(c);e[s]=u,t[s]=t[s]||new Map,r[s]=r[s]||[],a[s]=a[s]||0,o[s]=new Promise((e=>{n[s]=e})),u.onopen=()=>{a[s]=0,n[s]()},u.onerror=()=>{const e=t[s];for(const{reject:t,timer:r}of e.values())clearTimeout(r),t(new Error("[cesium-ws-patch] 连接错误"));e.clear()},u.onclose=()=>{a[s]<P?i[s]=setTimeout((()=>{a[s]++,console.warn(`[cesium-ws-patch] 连接 ${s} 关闭,尝试重连(第 ${a[s]} 次)`),l(s,c)}),j):console.warn(`[cesium-ws-patch] 连接 ${s} 达到最大重连次数,放弃重连`)},u.onmessage=e=>{const n=performance.now(),o=t[s];try{if(e.data instanceof ArrayBuffer){const t=new DataView(e.data),i=t.getUint32(0,!0),a=e.data.slice(4),c=o.get(i);if(!c)return;clearTimeout(c.timer),o.delete(i),N.set(i,(e=>{if(c.resolve(e),p(),c.__startTime){const e=n-c.__startTime;r[s].push(e),r[s].length>C&&r[s].shift()}})),W.postMessage({id:i,payload:a},[a])}else if("string"===typeof e.data){const t=JSON.parse(e.data),{id:i,error:a,payload:c}=t,u=o.get(i);if(!u)return;if(clearTimeout(u.timer),o.delete(i),a)u.reject(new Error(a));else{const e=Uint8Array.from(atob(c),(e=>e.charCodeAt(0))).buffer;u.resolve(e)}if(u.__startTime){const e=n-u.__startTime;r[s].push(e),r[s].length>C&&r[s].shift()}p()}}catch(i){console.error("[cesium-ws-patch] 解析响应失败:",i)}}}function p(){if(V.pendingRequestsCount--,0===V.pendingRequestsCount){const e=(performance.now()-H).toFixed(2);s[0]=(e/1e3).toFixed(2),console.log(`[cesium-ws-patch] 加载完成,总耗时:${s[0]} 秒`);let t=`耗时:${s[0]} 秒`;V.calllFn&&"function"===typeof V.calllFn&&V.calllFn(t),H=null}}async function d(e,t){for(let r=0;r<t;r++)l(r,e)}function y(n){const o=e[n];if(!o||o.readyState!==WebSocket.OPEN)return 1/0;const i=t[n].size,a=r[n],s=0===a.length?1:a.reduce(((e,t)=>e+t),0)/a.length;return i*s}function g(){let e=0,r=y(0);for(let n=1;n<t.length;n++){const t=y(n);t<r&&(r=t,e=n)}return e}async function m(r,n,i,a=0){null===H&&(H=performance.now()),V.pendingRequestsCount++,V.allToRequestCount++;const s=r;try{const e=await U(s);if(e&&e.byteLength>0)return p(),e}catch(v){}0===e.length&&await d(n,i),await Promise.all(o);const u=g(),f=e[u],l=t[u];if(!f||f.readyState!==WebSocket.OPEN)return Promise.reject(new Error("[cesium-ws-patch] WebSocket未连接"));const y=c++,m=performance.now();return new Promise(((e,t)=>{const n=setTimeout((()=>{}),_);l.set(y,{url:r,resolve:async t=>{try{q(s,t.slice(0))}catch(v){console.warn(`[cache] 写入失败: ${s}`,v)}e(t)},reject:t,timer:n,__startTime:m});const o=JSON.stringify({id:y,filepath:r});f.send(o)}))}return{connections:e,requestsMap:t,requestDurations:r,connectionReadyPromises:o,allCostTime:s,pendingRequestsCount:0,allToRequestCount:0,initConnections:d,request:m,initWebSocketMonitor:u,initOPFSCacheManager:S,destroyWebSocketMonitor:f,destroyOPFSCacheManager:T}})();async function Y({cesiumContainer:e,serverUrl:t,modelWsLibPort:r,Cesium:n,filetypes:o=[".b3dm",".glb","tileset.json"],maxConnections:i=30,calllFn:a,useWsMonitor:s=!1,useOpfsManager:c=!1}){if(n&&n.Resource&&n.Resource.prototype)try{0===V.connections.length&&await V.initConnections(t,i),A({containerId:e,classtag:D,textTag:"初始化",allTasksLen:i}),c&&S(e),await Promise.all(V.connectionReadyPromises),V.STATUS_CODE=1,V.cesiumContainer=e,A({containerId:V.cesiumContainer,classtag:B,textTag:"加载",ifAlwaysOnline:!0}),s&&u({cesiumContainer:e}),V.calllFn=a;const f=n.Resource.prototype.fetchArrayBuffer;return n.Resource.prototype.fetchArrayBuffer=function(){const e=this.url,r=o.some((t=>e.endsWith(t)||e.includes(t)));return r?V.request(e,t,i):f.call(this)},$(r),{statuscode:V.STATUS_CODE,message:"初始化成功"}}catch(f){return V.STATUS_CODE=0,{statuscode:0,message:"初始化失败",errormessage:f.message}}else console.warn("[cesium-ws-patch] Cesium.Resource 未找到,初始化失败")}window.WebSocketPoolDispatcher=V,window.patchCesium=Y;var G=Y,K=G}(),n}()}));