@shimotsuki/core 3.0.2 → 3.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shimotsuki_core.js +1 -1
- package/package.json +1 -1
package/dist/shimotsuki_core.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"@babel/runtime-corejs3/core-js/global-this";import{AudioSource as e,_decorator as i,AudioClip as s,error as o,Node as n,director as r,log as a,Component as l,Prefab as c,instantiate as h,isValid as p,Layers as u,view as d,Widget as m,v3 as _,tween as f,Enum as g,game as y,Label as v,UIOpacity as b,Tween as E,BlockInputEvents as C,Button as w,Director as S,warn as T,AsyncDelegate as A,Game as I,assetManager as k,Asset as O,resources as N,sys as R,SpriteFrame as D,Sprite as M}from"cc";import F from"@babel/runtime-corejs3/core-js-stable/reflect/get";import x from"@babel/runtime-corejs3/core-js-stable/reflect/set";import U from"@babel/runtime-corejs3/core-js-stable/object/assign";import P from"@babel/runtime-corejs3/core-js-stable/promise";import L from"eventemitter3";import B from"@babel/runtime-corejs3/core-js-stable/instance/includes";import j from"@babel/runtime-corejs3/core-js-stable/json/stringify";import H from"@babel/runtime-corejs3/core-js-stable/map";import G from"@babel/runtime-corejs3/core-js-stable/instance/for-each";import $ from"@babel/runtime-corejs3/core-js-stable/instance/filter";import K from"@babel/runtime-corejs3/core-js-stable/array/is-array";import W from"@babel/runtime-corejs3/core-js-stable/reflect/own-keys";import V from"@babel/runtime-corejs3/core-js-stable/instance/bind";import{makeObservable as z,observable as q,autorun as Q,reaction as J}from"@shimotsuki/mobx";import X from"@babel/runtime-corejs3/core-js-stable/set-timeout";import Z from"@babel/runtime-corejs3/core-js-stable/instance/map";import Y from"@babel/runtime-corejs3/core-js-stable/array/from";import tt from"@babel/runtime-corejs3/core-js-stable/instance/every";import{SocketConnectStatus as et}from"pitayaclient";import{DEBUG as it,WECHAT as st,PREVIEW as ot}from"cc/env";import{SocialGameClient as nt}from"sgc";import rt from"crypto-es";import at from"@babel/runtime-corejs3/core-js-stable/date/now";import lt from"@babel/runtime-corejs3/core-js-stable/set-interval";import ct from"@babel/runtime-corejs3/core-js-stable/instance/values";import ht from"@babel/runtime-corejs3/core-js-stable/instance/entries";class pt extends e{cat;initAudio(t){return this.cat=t,this}}const{ccclass:ut,menu:dt}=i;let mt=class extends pt{effects=(()=>new H)();load(t,e){return new P((i,o)=>{let n,r=null;void 0!==e?(r=t,n=e):n=t;const a=(t,e)=>{if(t)return o(t);this.effects.set(n,e),this.playOneShot(e,this.volume),i(e)};r?this.cat.res.load(r,n,s,a):this.cat.res.load(n,s,a)})}release(){for(let t in this.effects)this.cat.res.release(t);this.effects.clear()}};const{ccclass:_t,menu:ft}=i;class gt extends pt{onComplete=null;_progress=0;_url=null;_isPlay=!1;get progress(){return this.duration>0&&(this._progress=this.currentTime/this.duration),this._progress}set progress(t){this._progress=t,this.currentTime=t*this.duration}load(t,e){return new P((i,n)=>{let r,a=null;void 0!==e?(a=t,r=e):r=t;const l=(t,e)=>{if(t)return o(t),n(t);this.playing&&(this._isPlay=!1,this.stop(),this.cat.res.release(this._url)),this.playOnAwake=!1,this.enabled=!0,this.clip=e,this._url=r,i(e)};a?this.cat.res.load(a,r,s,l):this.cat.res.load(r,s,l)})}update(t){this.currentTime>0&&(this._isPlay=!0),this._isPlay&&0==this.playing&&(this._isPlay=!1,this.enabled=!1,this.onComplete&&this.onComplete())}release(){this._url&&(this.cat.res.release(this._url),this._url=null)}}class yt{cat;constructor(t){this.cat=t}}var vt;!function(t){t.MUSIC_ON="AudioEventConstant/MUSIC_ON",t.MUSIC_OFF="AudioEventConstant/MUSIC_OFF",t.EFFECT_ON="AudioEventConstant/EFFECT_ON",t.EFFECT_OFF="AudioEventConstant/EFFECT_OFF",t.PAUSE_AUDIO="AudioEventConstant/PAUSE_AUDIO",t.RESUME_AUDIO="AudioEventConstant/RESUME_AUDIO"}(vt||(vt={}));class bt extends yt{local_data={};music;effect;_volume_music=1;_volume_effect=1;_switch_music=!0;_switch_effect=!0;local_store_key="game_audio";extra={};constructor(t){super(t),this.local_store_key=this.cat.audio_local_store_key;var e=new n("UIAudioManager");r.addPersistRootNode(e);var i=new n("UIMusic");i.parent=e,this.music=i.addComponent(gt).initAudio(t);var s=new n("UIEffect");s.parent=e,this.effect=s.addComponent(mt).initAudio(t),this.load()}setMusicComplete(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.music.onComplete=t}async playMusic(t,e){if(this.music.loop=!0,!this._switch_music)return;let i,s;void 0!==e?(s=t,i=e):i=t,i.length&&await(s?this.music.load(s,i):this.music.load(i)).then(()=>{this._switch_music&&this.music.play()})}stopMusic(){0!=this.music.state&&this.music?.stop()}pauseMusic(){1==this.music.state&&this.music?.pause()}resumeMusic(){var t;B(t=[0,2]).call(t,this.music.state)&&this.music?.play()}get progressMusic(){return this.music.progress}set progressMusic(t){this.music.progress=t}get volumeMusic(){return this._volume_music}set volumeMusic(t){this._volume_music=t,this.music.volume=t}get switchMusic(){return this._switch_music}set switchMusic(t){if(a("设置背景音乐开关值",t,this._switch_music),t==this._switch_music)return;this._switch_music=t,t?this.resumeMusic():this.pauseMusic();const e=t?vt.MUSIC_ON:vt.MUSIC_OFF;this.cat.event.emit(e),this.save()}async playEffect(t,e){if(!this._switch_effect)return;let i,s;void 0!==e?(s=t,i=e):i=t,i.length&&await(s?this.effect.load(s,i):this.effect.load(i)).then(()=>{this.effect.play()})}stopEffect(){this.effect?.stop()}get volumeEffect(){return this._volume_effect}set volumeEffect(t){this._volume_effect=t,this.effect.volume=t}get switchEffect(){return this._switch_effect}set switchEffect(t){if(t==this._switch_effect)return;this._switch_effect=t,t?this.effect?.play():this.effect?.stop();const e=t?vt.EFFECT_ON:vt.EFFECT_OFF;this.cat.event.emit(e),this.save()}resumeAll(){this.switchMusic&&this.music?.play(),this.switchEffect&&this.effect?.play()}pauseAll(){this.music?.pause(),this.effect?.pause()}stopAll(){this.music?.stop(),this.effect?.stop()}save(){this.local_data.volume_music=this._volume_music,this.local_data.volume_effect=this._volume_effect,this.local_data.switch_music=this._switch_music,this.local_data.switch_effect=this._switch_effect,this.local_data.extra=this.extra;let t=j(this.local_data);return this.cat.storage.set(this.local_store_key,t),this}load(){try{let t=this.cat.storage.get(this.local_store_key);this.local_data=JSON.parse(t),this._volume_music=this.local_data.volume_music,this._volume_effect=this.local_data.volume_effect,this._switch_music=this.local_data.switch_music,this._switch_effect=this.local_data.switch_effect,this.extra=this.local_data.extra}catch(t){this.local_data={},this._volume_music=.6,this._volume_effect=1,this._switch_music=!0,this._switch_effect=!0,this.extra={}}this.music&&(this.music.volume=this._volume_music),this.effect&&(this.effect.volume=this._volume_effect)}}function Et(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function Ct(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}"function"==typeof SuppressedError&&SuppressedError;class wt extends l{props={};data={};cat=(()=>t._cat)();autorunDisposers=[];reactionDisposers=[];eventEmitter=[];hook={destroyed:()=>{},started:()=>{}};initUI(){}__preload(){this.initUI(),this.onAutoObserver()}constructor(){super(),z(this,{props:q,data:q})}onAutoObserver(){}addAutorun(t){const e=K(t)?t:[t];return G(e).call(e,t=>{const e=Q(t);this.autorunDisposers.push(e)}),this}addReaction(t,e,i){const s=J(t,e,i);return this.reactionDisposers.push(s),this}addAudoListener(t){var e;return B(e=this.eventEmitter).call(e,t)||t===this.cat.event||this.eventEmitter.push(t),t}_onPreDestroy(){var t,e;if(G(t=this.autorunDisposers).call(t,t=>{t()}),G(e=this.reactionDisposers).call(e,t=>{t()}),this.autorunDisposers=[],this.reactionDisposers=[],!super._onPreDestroy)throw new Error("_onPreDestroy已弃用");super._onPreDestroy()}onDisable(){var t;this.onHide(),this.deleteAllEventByEmitter(this.cat.event),G(t=this.eventEmitter).call(t,t=>{this.deleteAllEventByEmitter(t)}),this.eventEmitter=[],this.removeListener()}deleteAllEventByEmitter(t){const e=t._events;for(const i in e){let s=e[i];K(s)||(s=[s]),G(s).call(s,e=>{e.context===this&&t.off(i,e.fn,this)})}}onEnable(){this.onShow(),this.addListener(),this.onEventListener()}onEventListener(){}addListener(){}removeListener(){}addToParent(t,e,i){const s=t instanceof c?h(t):t instanceof l?t.node:t;if("number"==typeof e){const t=e,o=i;this.setOptions(o),s.insertChild(this.node,t)}else{const t=e;this.setOptions(t),s.addChild(this.node)}return this}setOptions(t){if(t)for(let e in t)switch(e){case"hook":t.hook&&(this.hook=t.hook);break;case"props":null!==t.props&&"object"==typeof t.props&&(this.props=t.props);break;case"data":null!==t.data&&"object"==typeof t.data&&(this.data=t.data)}}setUpdateData(t){if(this.data)return t&&U(this.data,this.toPlainObject(t)),this}setUpdateProps(t){if(this.props)return t&&U(this.props,this.toPlainObject(t)),this}toPlainObject(t){const e={};for(const i of W(t))if("string"==typeof i)try{e[i]=t[i]}catch{}return e}removeAndDestroy(){p(this?.node)&&(this.node.removeFromParent(),this.node.destroy())}setPosition(t){return this.node.setPosition(t),this}setScale(t){return this.node.setScale(t),this}setAngle(t){return this.node.angle=t,this}setRotation(t){return this.node.setRotation(t),this}setRotationFromEuler(t){return this.node.setRotationFromEuler(t),this}onShow(){}onHide(){}setNodeAndChildrenLayer(t){return St(this.node,t),this}}const St=(t,e)=>{var i,s,o;t.layer="string"==typeof e?2**u.nameToLayer(e):e,(null==(i=t)?void 0:V(o=Function.call).call(o,G(s=i.children),s))?.(t=>{St(t,e)})};class Tt extends wt{lastEnterDirection="center";screen;isClosing=!1;root;constructor(){super(),this._init()}_init(){this.root=this.node,this.screen=d.getVisibleSize()}async showTween(t){let{isMotion:e=!0,direction:i="center",duration:s=.1,isBounce:o=!0,bounceDuration:n=.05}=t;if(this.lastEnterDirection=i,e){const t=this.node.getComponent(m);let e,n;t&&(t.updateAlignment(),t.enabled=!1),_(1.1,1.1,1),"center"==i?(e=_(.01,.01,.01),n=_(1,1,1)):(e="left"==i?_(-this.screen.width,0,0):"right"==i?_(this.screen.width,0,0):_(0,"top"==i?this.screen.height:-this.screen.height,0),n=_(0,0,0)),await this.handle(i,s,e,n,o),t&&(t.enabled=!0)}}async hideTween(t){let{isMotion:e=!0,direction:i,duration:s=.1}=t;if(i=i||this.lastEnterDirection,!this.isClosing){if(this.isClosing=!0,f(this.node).removeSelf(),e){const t=this.node.getComponent(m);let e,o;t&&(t.enabled=!1),"center"==i?(e=this.node.scale,o=_(0,0,0)):(o="left"==i?_(-this.screen.width,0,0):"right"==i?_(this.screen.width,0,0):_(0,"top"==i?this.screen.height:-this.screen.height,0),e=this.node.getPosition()),await this.handle(i,s,e,o,!1)}this.removeAndDestroy()}}async handle(t,e,i,s,o){"center"==t?this.node.setScale(i):this.node.setPosition(i),await this.deftween(e,{["center"==t?"scale":"position"]:s},o)}deftween(t,e,i,s){return new P((i,s)=>{f(this.node).to(t,e).call(()=>{i()}).start()})}}const{ccclass:At,property:It}=i;var kt;!function(t){t[t.EFFECT=0]="EFFECT",t[t.BGM=1]="BGM"}(kt||(kt={}));class Ot extends wt{type=(()=>kt.EFFECT)();clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=(()=>new e)();onEnable(){super.onEnable(),this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,this.cat.event.on(vt.EFFECT_ON,this.onPlayEffectHandler,this).on(vt.EFFECT_OFF,this.onStopEffectHandler,this).on(vt.MUSIC_ON,this.onPlayMusicHandler,this).on(vt.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){super.__preload();const{volumeEffect:t,volumeMusic:e}=this.cat.audio;this.audioSource.volume=this.type===kt.BGM?e:t}start(){}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:t,switchMusic:e}=this.cat.audio;this.audioSource.playing||!(this.type===kt.BGM?e:t)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}Et([It({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(kt)}),Ct("design:type",Number)],Ot.prototype,"type",void 0),Et([It({tooltip:"音源",type:s}),Ct("design:type",s)],Ot.prototype,"clip",void 0),Et([It({tooltip:"循环"}),Ct("design:type",Boolean)],Ot.prototype,"loop",void 0),Et([It({tooltip:"音量"}),Ct("design:type",Number)],Ot.prototype,"volume",void 0),Et([It({tooltip:"是否启用自动播放"}),Ct("design:type",Boolean)],Ot.prototype,"playOnAwake",void 0);const{ccclass:Nt,property:Rt}=i;class Dt extends Tt{type=(()=>kt.EFFECT)();clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=(()=>new e)();onEnable(){super.onEnable(),this.cat.event.on(vt.EFFECT_ON,this.onPlayEffectHandler,this).on(vt.EFFECT_OFF,this.onStopEffectHandler,this).on(vt.MUSIC_ON,this.onPlayMusicHandler,this).on(vt.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,super.__preload();const{volumeEffect:t,volumeMusic:e}=this.cat.audio;this.audioSource.volume=this.type===kt.BGM?e:t}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:t,switchMusic:e}=this.cat.audio;this.audioSource.playing||!(this.type===kt.BGM?e:t)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}Et([Rt({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(kt)}),Ct("design:type",Number)],Dt.prototype,"type",void 0),Et([Rt({tooltip:"音源",type:s}),Ct("design:type",s)],Dt.prototype,"clip",void 0),Et([Rt({tooltip:"循环"}),Ct("design:type",Boolean)],Dt.prototype,"loop",void 0),Et([Rt({tooltip:"音量"}),Ct("design:type",Number)],Dt.prototype,"volume",void 0),Et([Rt({tooltip:"是否启用自动播放"}),Ct("design:type",Boolean)],Dt.prototype,"playOnAwake",void 0);const{ccclass:Mt,property:Ft,menu:xt}=i;var Ut;!function(t){t[t.FIXED=0]="FIXED",t[t.SLIDE=1]="SLIDE"}(Ut||(Ut={}));let Pt=class extends wt{fixed_node;slide_node;fixed_label;slide_label;onLoad(){this.fixed_node.active=this.slide_node.active=!1}start(){this.show()}async show(){return new P(async(t,e)=>{const{title:i,type:s,fixed_time:o}=this.props;s==Ut.FIXED?(this.fixed_node.active=!0,this.fixed_label.string=`${i}`,this.scheduleOnce(()=>{this.node.destroy(),t()},o)):(this.slide_node.active=!0,this.slide_label.string=`${i}`,this.playAnim(this.node).then(()=>{t()}))})}playAnim(t){return new P((e,i)=>{const s=this.node.getComponent(b),o=f(s).delay(1.2).to(.5,{opacity:0}).call(()=>{E.stopAllByTarget(t),this.node.destroy(),e()});f(t).by(.5,{position:_(0,400,0)}).call(()=>{o.start()}).start()})}onDestroy(){E.stopAllByTarget(this.node),this.unscheduleAllCallbacks()}};var Lt;Et([Ft({type:n,tooltip:"固定节点"}),Ct("design:type",n)],Pt.prototype,"fixed_node",void 0),Et([Ft({type:n,tooltip:"滑动节点"}),Ct("design:type",n)],Pt.prototype,"slide_node",void 0),Et([Ft({type:v,tooltip:"固定标签节点"}),Ct("design:type",v)],Pt.prototype,"fixed_label",void 0),Et([Ft({type:v,tooltip:"滑动标签节点"}),Ct("design:type",v)],Pt.prototype,"slide_label",void 0),Pt=Et([Mt("CoreToast"),xt("CATCORE/CoreToast")],Pt),function(t){t.EVENT_SHOW="GlobalEventConstant/EVENT_SHOW",t.EVENT_HIDE="GlobalEventConstant/EVENT_HIDE",t.GAME_RESIZE="GlobalEventConstant/GAME_RESIZE",t.EVENT_CLOSE="GlobalEventConstant/EVENT_CLOSE",t.ONLINE="GlobalEventConstant/ONLINE",t.OFFLINE="GlobalEventConstant/OFFLINE",t.ROOT_MASK_UPDATE="GlobalEventConstant/ROOT_MASK_UPDATE",t.ROOT_MASK_CHANGE="GlobalEventConstant/ROOT_MASK_CHANGE"}(Lt||(Lt={}));const{ccclass:Bt,property:jt,menu:Ht}=i;let Gt=class extends wt{tween};Et([jt({type:n,tooltip:"动画节点"}),Ct("design:type",n)],Gt.prototype,"tween",void 0),Gt=Et([Bt("CoreBlackMask"),Ht("CATCORE/CoreBlackMask")],Gt);const{ccclass:$t,property:Kt,menu:Wt}=i;let Vt=class extends Tt{scene_mask_node;ui_container;gui=null;onLoad(){this.setSceneMaskActive(!1)}get scene_mask(){return this.scene_mask_node.getComponent(Gt)}get brother(){return this.ui_container.children||[]}get tweenChildren(){return this.scene_mask.tween.children}onEventListener(){this.cat.event.on(Lt.ROOT_MASK_CHANGE,this.uiMaskChanged,this)}addMask(){const t=this.brother[this.brother.length-1];t&&this.scene_mask.node.setSiblingIndex(t.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}subMask(){const t=this.brother[this.brother.length-2];t&&this.scene_mask.node.setSiblingIndex(t.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}blockMaskSiblingIndexChanged(){this.tweenChildren.length>1||this.brother.length>1?this.show():this.hide()}addNodeToTween(t){return p(this)&&this.scene_mask&&this.scene_mask.tween.addChild(t),this}show(){this.setSceneMaskActive(!0)}hide(){this.setSceneMaskActive(!1)}setGui(t){return this.gui=t,this}uiMaskChanged(){this.blockMaskSiblingIndexChanged()}setSceneMaskActive(t){this.scene_mask.node.active=t}};Et([Kt({type:n}),Ct("design:type",n)],Vt.prototype,"scene_mask_node",void 0),Et([Kt({type:n}),Ct("design:type",n)],Vt.prototype,"ui_container",void 0),Vt=Et([$t("CoreUIContainer"),Wt("CATCORE/CoreUIContainer")],Vt);class zt extends Tt{onEnable(){super.onEnable(),this.updateMask()}onDisable(){super.onDisable(),this.updateMask()}updateMask(){this.cat.event.emit(Lt.ROOT_MASK_UPDATE)}}const{ccclass:qt,property:Qt,menu:Jt}=i;let Xt=class extends zt{title;loadingTween;loading_rotate=0;onAutoObserver(){this.addAutorun([()=>{this.props?.title&&(this.title.string=`${this.props?.title}`),this.title.node.active=!!this.props?.title?.length},()=>{this.getComponent(C).enabled=!!this.props?.mask}])}update(t){this.loading_rotate+=220*t,this.loadingTween.setRotationFromEuler(0,0,-this.loading_rotate%360),this.loading_rotate>360&&(this.loading_rotate-=360)}};var Zt;Et([Qt({type:v,tooltip:"标题"}),Ct("design:type",v)],Xt.prototype,"title",void 0),Et([Qt({type:n,tooltip:"动画"}),Ct("design:type",n)],Xt.prototype,"loadingTween",void 0),Xt=Et([qt("CoreShowLoading"),Jt("CATCORE/CoreShowLoading")],Xt),function(t){t.RECONNECTED="重连成功",t.RECONNECTING="正在重连",t.MAX_RECONNECT="重连次数超出限制,请检查网络",t.RECONNECTED_ERROR="重连失败,请检查网络",t.CONNECT_PARAM_ERROR="游戏参数错误,请重新加载",t.KICK="账号已下线",t.OFFLINE="网络已断开",t.ONLINE="网络已连接",t.GAME_ERROR="连接游戏服错误"}(Zt||(Zt={}));const{ccclass:Yt,property:te,menu:ee}=i;let ie=class extends zt{common_prompt_text;btn_confirm;btn_close;is_close=!1;props={content:null};initUI(){}onLoad(){this.btn_confirm.node.on(w.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(w.EventType.CLICK,this.onConfirmHandler,this),this.addAutorun([()=>{this.common_prompt_text.string=this.props.content??""}])}onDestroy(){this.unscheduleAllCallbacks()}updateProps(t){this.updatePromptText(t,t==Zt.RECONNECTING)}updatePromptText(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.unscheduleAllCallbacks(),this.props.content=t,a("更新提示文案:",t),e){let e=0;const i=()=>{e=(e+1)%4,this.common_prompt_text.string=t+["","·","··","···"][e]};this.schedule(i,.5)}}onConfirmHandler(){this.is_close=!0,this.cat.gui.hideReconnect()}};Et([te({type:v,tooltip:"通用提示文本"}),Ct("design:type",v)],ie.prototype,"common_prompt_text",void 0),Et([te({type:w,tooltip:"确定按钮"}),Ct("design:type",w)],ie.prototype,"btn_confirm",void 0),Et([te({type:w,tooltip:"关闭按钮"}),Ct("design:type",w)],ie.prototype,"btn_close",void 0),ie=Et([Yt("CoreReconnection"),ee("CATCORE/CoreReconnection")],ie);const{ccclass:se,property:oe,menu:ne}=i;let re=class extends zt{text;btn_confirm;btn_close;onLoad(){this.btn_confirm.node.on(w.EventType.CLICK,this.onConfrimHandler,this)}start(){this.props&&this.updateProps(this.props)}onConfrimHandler(){this.props?.confrim?.(),this.cat.gui.hideNotice()}updateProps(t){this.text.string=`${t.text}`}};Et([oe({type:v,tooltip:"提示文本"}),Ct("design:type",v)],re.prototype,"text",void 0),Et([oe({type:w,tooltip:"确定按钮"}),Ct("design:type",w)],re.prototype,"btn_confirm",void 0),Et([oe({type:w,tooltip:"关闭按钮"}),Ct("design:type",w)],re.prototype,"btn_close",void 0),re=Et([se("CoreNotice"),ne("CATCORE/CoreNotice")],re);class ae extends wt{isReload}const{ccclass:le,property:ce,menu:he}=i;var pe;!function(t){t[t.UI=0]="UI",t[t.LOADING=1]="LOADING",t[t.TOAST=2]="TOAST",t[t.RECONNECTTION=3]="RECONNECTTION",t[t.NOTICE=4]="NOTICE"}(pe||(pe={}));let ue=class extends wt{reconnection_ui_prefab;toast_ui_prefab;loading_ui_prefab;notice_ui_prefab;ui_prefab;root_ui;root_toast;root_mask;ui_container_component;reconnection_ui_component;notice_ui_component;loading_ui_component;toast_ui_component;currentScene;onEventListener(){this.cat.event.on(Lt.ROOT_MASK_UPDATE,this.onRootUpdate,this)}init(t){this.cat=t;const e=r.getScene();return a("init scene"),e&&this.changeScene(e),this}start(){this.onRootUpdate()}toastQueue=[];isScheduling=!1;minInterval=.2;showToast(t){this.toastQueue.push(t),this.isScheduling||this.processQueueWithInterval()}processQueueWithInterval(){if(0===this.toastQueue.length)return void(this.isScheduling=!1);this.isScheduling=!0;const t=this.toastQueue.shift(),e=()=>{h(this.toast_ui_prefab).getComponent(Pt).addToParent(this.root_toast,{props:t}),this.scheduleOnce(()=>{this.processQueueWithInterval()},this.minInterval)};0===this.root_toast.children.length?e():this.scheduleOnce(e,this.minInterval)}hideToast(){var t;this.root_toast&&G(t=this.root_toast.children).call(t,t=>{t.getComponent(Pt)?.removeAndDestroy()});return this.toastQueue=[],this.unschedule(this.processQueueWithInterval),this.isScheduling=!1,this}showLoading(){let{title:t="",mask:e=!0,black:i=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a("showLoading",t),this.loading_ui_component)this.loading_ui_component.setOptions({props:{title:t,mask:e,black:i}});else{const s=h(this.loading_ui_prefab);this.loading_ui_component=s.getComponent(Xt).addToParent(this.root_ui,{props:{title:t,mask:e,black:i}})}return this}hideLoading(){return this.loading_ui_component?.removeAndDestroy(),this.loading_ui_component=null,this}showReconnect(t){if(this.reconnection_ui_component)this.reconnection_ui_component.setUpdateProps({content:t});else{const e=h(this.reconnection_ui_prefab);this.reconnection_ui_component=e.getComponent(ie).addToParent(this.root_ui,{props:{content:t}})}return this}hideReconnect(){return this.reconnection_ui_component?.removeAndDestroy(),this.reconnection_ui_component=null,this}showNotice(t){const e=h(this.notice_ui_prefab);return this.notice_ui_component=e.getComponent(re).addToParent(this.root_ui,{props:t}),this}hideNotice(){return this.notice_ui_component?.removeAndDestroy(),this}loadScene(t,e,i){a("[加载场景名][参数][重新加载]",t,e,i);let s={},o=i??!1;return"boolean"==typeof e?o=e:s=e??{},r.once(S.EVENT_BEFORE_SCENE_LAUNCH,t=>{a("Director.EVENT_BEFORE_SCENE_LAUNCH",t),this.changeScene(t,s,o)}),"string"==typeof t?r.loadScene(t):r.runScene(t),this}resetScene(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return t=t||this.currentScene,this.loadScene(t)}cleanScene(){this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast()}changeScene(t,e,i){this.currentScene=t.name,this.createUILayer(t);const s=t.getComponentInChildren(ae);s&&(s.isReload=i??!1),s?.setOptions(e)}createUILayer(t){this.ui_container_component?.removeAndDestroy(),this.ui_container_component=null;const e=h(this.ui_prefab);this.ui_container_component=e.getComponent(Vt),this.ui_container_component?.setGui(this).addToParent(t,this.node.getSiblingIndex())}reloadScene(){this.loadScene(this.currentScene,!0)}async closeUI(t,e){const{component:i}=this.findUIBaseLayer(t,!1);i&&(i.setOptions({...e?.hook??{},...e?.props??{}}),await i.hideTween(e||{}),this.ui_container_component?.subMask())}async openUI(t,e){const{rootNode:i,component:s}=this.findUIBaseLayer(t,!0);i.getComponent(Tt),s?.setOptions(e),i&&this.ui_container_component?.addNodeToTween(i).addMask(),s&&await s.showTween(e||{}),this.ui_container_component?.ui_container&&s?.addToParent(this.ui_container_component.ui_container)}findUIBaseLayer(t,e){let i,s=null;if(t instanceof n){var r;i=t;const e=$(r=t.components).call(r,t=>t instanceof Tt);if(!e.length)return o(`${t.name}节点未找到继承自BaseLayer的组件`),{rootNode:i,component:s};1==e.length?s=e[0]:T(`${t.name}节点存在多个继承自BaseLayer的组件`)}else if(i=t.node,s=t,e){for(;i.parent;)i=i.parent;s.root=i}else i=t.root;return{rootNode:i,component:s}}onRootUpdate(){const t=this.root_ui.children.findLastIndex(t=>t.active&&t!=this.root_mask);if(this.root_mask.active=-1!=t,t>-1){const e=this.root_ui.children[t].getSiblingIndex()-1;this.root_mask.setSiblingIndex(e<0?0:e)}this.cat.event.emit(Lt.ROOT_MASK_CHANGE)}};var de;Et([ce({type:c,tooltip:"断线重连UI预制体"}),Ct("design:type",c)],ue.prototype,"reconnection_ui_prefab",void 0),Et([ce({type:c,tooltip:"提示UI预制体"}),Ct("design:type",c)],ue.prototype,"toast_ui_prefab",void 0),Et([ce({type:c,tooltip:"加载UI预制体"}),Ct("design:type",c)],ue.prototype,"loading_ui_prefab",void 0),Et([ce({type:c,tooltip:"公告UI预制体"}),Ct("design:type",c)],ue.prototype,"notice_ui_prefab",void 0),Et([ce({type:c,tooltip:"UI层预制体"}),Ct("design:type",c)],ue.prototype,"ui_prefab",void 0),Et([ce({type:n,tooltip:"root-UI层"}),Ct("design:type",n)],ue.prototype,"root_ui",void 0),Et([ce({type:n,tooltip:"root-组件层"}),Ct("design:type",n)],ue.prototype,"root_toast",void 0),Et([ce({type:n,tooltip:"root-mask"}),Ct("design:type",n)],ue.prototype,"root_mask",void 0),ue=Et([le("Gui"),he("CATCORE/Gui")],ue),function(t){t.Root="prefabs/root",t.Toast="prefabs/toast",t.BlackMask="prefabs/black-mask",t.Loading="prefabs/loading",t.Notice="prefabs/notice",t.Reconnection="prefabs/reconnection"}(de||(de={}));class me extends yt{gui;#t="core";getGuiPrefabByType=(t,e)=>new P((i,s)=>{a(t,`${e}`),this.cat.res.load(t,e,(t,e)=>{t?s(t):i(e)})});async init(){this.cat.gui_bundle_name&&(this.#t=this.cat.gui_bundle_name);const t=await this.getGuiPrefabByType(this.#t,de.Root),e=h(t);return this.gui=e.getComponent(ue).init(this.cat),r.addPersistRootNode(e),this}}class _e extends nt{showRequestErrInfo=!1;logBlackList=[];ignore=t=>{var e;return B(e=this.logBlackList).call(e,t)};constructor(t,e,i,s){super(e,i,s,t),this.showRequestErrInfo=s?.showRequestErrInfo??!1}destroy(){this.disconnect(!0),t._cat.socialGameClient.unregister(this)}async GameRequest(e,i,s){let{forwardReq:o=!1,forwardResp:n=!1}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new P((r,l)=>{super.GameRequest(e,i,s,{forwardReq:o,forwardResp:n}).then(t=>{it&&a(`%c ws服务端消息 %c [Response][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",i),r(t)},e=>{this.showRequestErrInfo&&e?.msg&&t._cat.gui.showToast({title:e.msg}),l(e)})})}subscribe(e,i,s){return super.subscribe(e,i,i=>{it&&!this.ignore(e)&&a(`%c ws服务端消息:[subscribe][${new Date}] %c ${e} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",i),t._cat.event.emit(e,i),s?.(i)}),this}}class fe extends yt{managedClients=(()=>new H)();isGlobalOnline=!0;isInBackground=!1;reconnecting=!1;onEventHideDelegate=(()=>new A)();onEventShowDelegate=(()=>new A)();onEventReloadSceneDelegate=(()=>new A)();reconnectTimer=null;scheduleReconnect(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectTimer=X(()=>{this.reconnectTimer=null,this.triggerReconnectAll()},t)}get activeClients(){var t,e;return $(t=Z(e=Y(this.managedClients)).call(e,t=>{let[e,i]=t;return i})).call(t,t=>t.socket)}constructor(t){super(t),this.initGlobalListeners()}createWebSocket(t,e,i,s){if(this.managedClients.has(t)){this.managedClients.get(t).destroy(),a(`清理旧的 ${t} 客户端`)}const o=new _e(t,i,s,U({reconnectMaxAttempts:1/0},{...e,isAutoConnect:!1,isArrayBuffer:st}));return this.register(o),o}register(t){t.on("reconnected",this.handleSingleReconnect),t.on("close",this.handleSingleClose),t.on("kick",this.handleSingleKick),this.managedClients.set(t.name,t)}unregister(t){t.off("reconnected",this.handleSingleReconnect),t.off("close",this.handleSingleClose),t.off("kick",this.handleSingleKick),this.managedClients.delete(t.name)}initGlobalListeners(){this.cat.event.on(Lt.ONLINE,()=>this.handleGlobalStateChange("online"),this).on(Lt.OFFLINE,()=>this.handleGlobalStateChange("offline"),this),y.on(I.EVENT_SHOW,()=>this.handleGlobalStateChange("show")),y.on(I.EVENT_HIDE,()=>this.handleGlobalStateChange("hide"))}async handleGlobalStateChange(t){switch(t){case"online":this.cat.gui.hideLoading().showToast({title:Zt.ONLINE}),this.isGlobalOnline=!0,this.triggerReconnectAll();break;case"offline":this.isGlobalOnline=!1,this.disconnectAll(!0),this.cat.gui.showLoading({title:Zt.OFFLINE});break;case"show":this.isInBackground=!1,await this.triggerReconnectAll(),await this.onEventShowDelegate.dispatch();break;case"hide":await this.onEventHideDelegate.dispatch(),this.isInBackground=!0,this.disconnectAll(!0)}}async triggerReconnectAll(){if(a("触发所有客户端重连",this.reconnecting,!this.isGlobalOnline,this.isInBackground,this.managedClients.size),!this.reconnecting&&this.isGlobalOnline&&!this.isInBackground&&0!==this.managedClients.size){this.reconnecting=!0,this.cat.gui.showLoading({title:"正在重连"});try{var t,e;await P.allSettled(Z(t=this.activeClients).call(t,async t=>{try{await t.reconnectPromise()}catch(e){o(`${t.name}服重连失败`,e)}}));const i=$(e=this.activeClients).call(e,t=>t.socketConnectStatus!==et.CONNECTED);i.length>0?(console.error("部分WS重连失败:",Z(i).call(i,t=>t)),a("2s后重连所有客户端"),this.reconnecting=!1,this.scheduleReconnect()):this.reconnecting=!1}catch(t){throw this.reconnecting=!1,t}}}disconnectAll(t){var e;G(e=this.managedClients).call(e,e=>{a("断开连接",e.name,t,e.socket),e.disconnect(t)})}handleSingleClose=()=>{this.reconnecting||(a("3s后重连所有客户端"),this.scheduleReconnect(3e3))};handleSingleReconnect=async()=>{var t,e;tt(t=this.activeClients).call(t,t=>t.socketConnectStatus===et.CONNECTED)&&(a("单个WS重连成功回调===",this.managedClients),await P.allSettled(Z(e=this.activeClients).call(e,async t=>{try{await t.connectRequest()}catch(e){o(`${t.name}服登录错误`,e),this.cat.gui.showToast({title:`登录${t.name}服错误`})}})),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),await this.onEventReloadSceneDelegate.dispatch(),this.cat.gui.hideLoading(),r.getScene()?.getComponentInChildren(ae)?.isReload&&this.cat.gui.reloadScene())};handleSingleKick=()=>{this.cat.gui.showReconnect(Zt.KICK)}}class ge{get=(()=>function(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"resources";return k.getBundle(i).get(t,e)})();isAssetType=t=>"function"==typeof t&&t.prototype instanceof O;async load(){let t=null,e=null,i=null;for(var s=arguments.length,o=new Array(s),n=0;n<s;n++)o[n]=arguments[n];"string"==typeof o[0]&&"string"==typeof o[1]&&(t=o.shift());let r=o.shift();this.isAssetType(o[0])&&(e=o.shift()),2==o.length&&(i=o.shift());const a=o.shift();let l=N;if(t&&"resources"!=t){k.bundles.has(t)||await this.loadBundle(t);let e=k.bundles.get(t);e&&(l=e)}i&&a?l.load(r,e,i,a):a?l.load(r,e,a):l.load(r,e)}async loadDir(){let t=null,e=null,i=null,s=null;for(var o=arguments.length,n=new Array(o),r=0;r<o;r++)n[r]=arguments[r];"string"==typeof n[0]&&"string"==typeof n[1]&&(t=n.shift());let a=n.shift();this.isAssetType(n[0])&&(e=n.shift()),2==n.length&&(i=n.shift()),s=n.shift();let l=N;if(t&&"resources"!=t){k.bundles.has(t)||await this.loadBundle(t);let e=k.bundles.get(t);e&&(l=e)}i&&s?l.loadDir(a,e,i,s):s?l.loadDir(a,e,s):l.loadDir(a,e)}loadRemote(t){for(var e,i=null,s=arguments.length,o=new Array(s>1?s-1:0),n=1;n<s;n++)o[n-1]=arguments[n];2==o.length&&(i=o.shift()),e=o.shift(),k.loadRemote(t,{ext:".png",...i},e)}loadBundle=(t,e)=>new P((i,s)=>{const o=(t,e)=>{if(t)return s(t);i(e)};e?k.loadBundle(t,{version:e},o):k.loadBundle(t,o)});releasePrefabtDepsRecursively=t=>{var e=k.assets.get(t);if(k.releaseAsset(e),e instanceof c){var i=k.dependUtil.getDepsRecursively(t);G(i).call(i,t=>{k.assets.get(t).decRef()})}};release=(()=>{var t=this;return function(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"resources";var s=k.getBundle(i);if(s){var o=s.get(e);o&&t.releasePrefabtDepsRecursively(o._uuid)}}})();releaseDir=(()=>{var t=this;return function(e){var i,s;let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"resources";var n=k.getBundle(o),r=n?.getDirWithPath(e);(null==(i=r)?void 0:V(s=Function.call).call(s,Z(i),i))?.(e=>{t.releasePrefabtDepsRecursively(e.uuid)}),!e&&"resources"!=o&&n&&k.removeBundle(n)}})();dump=()=>{var t;G(t=k.assets).call(t,(t,e)=>{a(k.assets.get(e))}),a(`当前资源总数:${k.assets.count}`)};loadAssetsWithProgress(t,e){return new P((i,s)=>{const o=t.getDirWithPath(""),n=o.length;let r=0;if(0===n)return e(1),void i();G(o).call(o,o=>{t.load(o.path,t=>{t?s(t):(r++,e(r/n),r===n&&i())})})})}}class ye{rootStore;constructor(t){this.rootStore=t}}class ve extends yt{}let be=null;const Ee={stringify:t=>{const e={ct:t.ciphertext.toString(rt.enc.Base64)};return t.iv&&(e.iv=t.iv.toString()),t.salt&&(e.s=t.salt.toString()),j(e)},parse:t=>{const e=JSON.parse(t),i=rt.lib.CipherParams.create({ciphertext:rt.enc.Base64.parse(e.ct)});return e.iv&&(i.iv=rt.enc.Hex.parse(e.iv)),e.s&&(i.salt=rt.enc.Hex.parse(e.s)),i}};var Ce=Object.freeze({__proto__:null,JsonFormatter:Ee,aesDecrypt:(t,e,i)=>rt.AES.decrypt(t,e,{iv:be,format:Ee}).toString(rt.enc.Utf8),aesEncrypt:(t,e,i)=>rt.AES.encrypt(t,e,{iv:be,format:Ee}).toString(),initCrypto:(t,e)=>{be=rt.enc.Hex.parse(e)},md5:t=>rt.MD5(t).toString()});class we extends yt{encryptUtil=(()=>Ce)()}class Se extends yt{_key=null;_iv=null;_id="";init(t,e){this.cat.util.encryptUtil.initCrypto(t,e),this._key=this.cat.util.encryptUtil.md5(t),this._iv=this.cat.util.encryptUtil.md5(e)}setUser(t){this._id=t}set(t,e){if(null!=(t=`${t}_${this._id}`)){if(ot||(t=this.cat.util.encryptUtil.md5(t)),null==e)return console.warn("存储的值为空,则直接移除该存储"),void this.remove(t);if("function"!=typeof e){if("object"==typeof e)try{e=j(e)}catch(t){return void console.error(`解析失败,str = ${e}`)}else"number"==typeof e&&(e+="");ot||null==this._key||null==this._iv||(e=this.cat.util.encryptUtil.aesEncrypt(`${e}`,this._key,this._iv)),R.localStorage.setItem(t,e)}else console.error("储存的值不能为方法")}else console.error("存储的key不能为空")}get(t,e){if(null==t)return console.error("存储的key不能为空"),null;t=`${t}_${this._id}`,ot||(t=this.cat.util.encryptUtil.md5(t));let i=R.localStorage.getItem(t);return null==i||""===i||ot||null==this._key||null==this._iv||(i=this.cat.util.encryptUtil.aesDecrypt(i,this._key,this._iv)),null===i?e:i}getNumber(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;var i=this.get(t);return Number(i)||e}getBoolean(t){var e=this.get(t);return Boolean(e)||!1}getJson(t,e){var i=this.get(t);return i&&JSON.parse(i)||e}remove(t){null!=t?(t=`${t}_${this._id}`,ot||(t=this.cat.util.encryptUtil.md5(t)),R.localStorage.removeItem(t)):console.error("存储的key不能为空")}clear(){R.localStorage.clear()}}class Te{static#e=null;#i=!1;static get instance(){return this.#e??(this.#e=new Te)}onAppInitDelegate=(()=>new A)();onPlugInInitDelegate=(()=>new A)();#s=null;get audio(){return this.#s}#o=null;get event(){return this.#o}#n=null;get gui(){return this.#n}#r=null;get storage(){return this.#r}#a=null;get res(){return this.#a}#l=null;get util(){return this.#l}#c=null;get socialGameClient(){return this.#c}#h=null;get store(){return this.#h}#p="";get gui_bundle_name(){return this.#p}#u="";get audio_local_store_key(){return this.#u}#d="";get default_audio_effect(){return this.#d}setConfig=(()=>{var t=this;return function(){let{default_audio_effect:e="",gui_bundleName:i="resources",audio_local_store_key:s="game_audio"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t.#i)throw new Error("[CAT] 已初始化,无法修改配置");return t.#p=i,t.#u=s,t.#d=e,t}})();async boot(){if(this.#i)throw new Error("[CAT] 已初始化");try{this.#h=new ve(this),this.#a=new ge,this.#l=new we(this),this.#r=new Se(this),this.#o=new L,this.#s=new bt(this),this.#c=new fe(this),this.#n=(await new me(this).init()).gui,this.#i=!0}catch(t){throw console.error("[CAT] 初始化失败:",t),t}}merge(t,e){if(!this.#i)throw new Error("[CAT] 未初始化");if("string"!=typeof t)throw new Error("merge方法第一个参数应该为string类型");return F(this,t)||x(this,t,e),U(F(this,t),e),this}appendPlugInInitDelegate(t){return this.#i?P.resolve().then(t).catch(t=>{console.error("[CAT] appendPlugInInitDelegate 回调执行失败:",t)}):this.onPlugInInitDelegate.add(t),this}}const{ccclass:Ae,property:Ie,menu:ke}=i;let Oe=class extends Tt{default_title=null;title;prompt_content_str;prompt_content_spriteFrame;btn_confirm;confirm_spriteFrame;btn_cancel;cancel_spriteFrame;btn_close;isConfirm=!1;props={title:this.default_title,content:null,confirmCB:()=>{},cancelCB:()=>{},style:null};onLoad(){this.btn_cancel.node.on(w.EventType.CLICK,this.onCancelHandler,this),this.btn_confirm.node.on(w.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(w.EventType.CLICK,this.onCloseHandler,this),this.addAutorun([()=>{this.title.spriteFrame=this.props?.title||this.default_title},()=>{this.props.content&&(this.props.content instanceof D?this.prompt_content_spriteFrame.spriteFrame=this.props.content:"string"==typeof this.props.content?this.prompt_content_str.string=this.props.content:console.error("未知类型的【UIModal】内容"))},()=>{null===this.props?.style?.confirm?this.btn_confirm.node.active=!1:(this.btn_confirm.node.active=!0,this.btn_confirm.getComponent(M).spriteFrame=this.props.style?.confirm||this.confirm_spriteFrame),null===this.props?.style?.cancel?this.btn_cancel.node.active=!1:(this.btn_cancel.node.active=!0,this.btn_cancel.getComponent(M).spriteFrame=this.props.style?.cancel||this.cancel_spriteFrame)}])}close(){this.props.cancelCB?.(),this.cat.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};var Ne;Et([Ie({type:D,tooltip:"默认标题"}),Ct("design:type",D)],Oe.prototype,"default_title",void 0),Et([Ie({type:M,tooltip:"标题节点"}),Ct("design:type",M)],Oe.prototype,"title",void 0),Et([Ie({type:v,tooltip:"字符串内容按钮"}),Ct("design:type",v)],Oe.prototype,"prompt_content_str",void 0),Et([Ie({type:M,tooltip:"图片精灵内容按钮"}),Ct("design:type",M)],Oe.prototype,"prompt_content_spriteFrame",void 0),Et([Ie({type:w,tooltip:"确认按钮"}),Ct("design:type",w)],Oe.prototype,"btn_confirm",void 0),Et([Ie({type:D,tooltip:"确认按钮精灵图"}),Ct("design:type",D)],Oe.prototype,"confirm_spriteFrame",void 0),Et([Ie({type:w,tooltip:"取消按钮"}),Ct("design:type",w)],Oe.prototype,"btn_cancel",void 0),Et([Ie({type:D,tooltip:"取消按钮精灵图"}),Ct("design:type",D)],Oe.prototype,"cancel_spriteFrame",void 0),Et([Ie({type:w,tooltip:"关闭按钮"}),Ct("design:type",w)],Oe.prototype,"btn_close",void 0),Oe=Et([Ae("CoreUIModal"),ke("CATCORE/CoreUIModal")],Oe),function(t){t[t.Delay=0]="Delay",t[t.Interval=1]="Interval"}(Ne||(Ne={}));class Re{tag;type;callback;remainingTime;executionTime=0;initialTime;constructor(t,e,i,s){this.tag=t,this.type=e,this.remainingTime=i,this.initialTime=i,this.callback=s}}class De extends yt{timers=(()=>new H)();lastUpdateTime=(()=>at())();constructor(t){var e;super(t),t.event.on(Lt.EVENT_HIDE,this.onHandleAppBackground,this),t.event.on(Lt.EVENT_SHOW,this.onHandleAppForeground,this),lt(V(e=this.update).call(e,this),1e3)}onHandleAppBackground(){this.lastUpdateTime=at()}onHandleAppForeground(){const t=at(),e=t-this.lastUpdateTime;a("elapsedTime",e);for(const t of ct(i=this.timers).call(i)){var i;t.remainingTime>0&&(t.remainingTime-=e,t.executionTime+=e)}this.lastUpdateTime=t}registerInterval(t,e,i){if(this.has(t))return o(`${t}定时器已存在,请勿重复注册`);const s=new Re(t,Ne.Interval,e,i);this.timers.set(t,s)}registerDelay(t,e,i){if(this.has(t))return o(`${t}延时器已存在,请勿重复注册`);const s=new Re(t,Ne.Delay,e,i);this.timers.set(t,s)}unregister(t){this.has(t)&&this.timers.delete(t)}has(t){return this.timers.has(t)}update(){const t=[];for(const[i,s]of ht(e=this.timers).call(e)){var e;s.remainingTime-=1e3,s.remainingTime<=0&&(s.type===Ne.Interval&&(s.executionTime+=s.initialTime),s.callback(s.executionTime),s.type===Ne.Interval?s.remainingTime=s.initialTime:t.push(i))}for(const e of t)this.timers.delete(e)}}const Me=(e,i)=>(s,o,n)=>{let r=n.value;return n.value=function(){const s=e??t._cat.default_audio_effect;s?t._cat.audio.playEffect(s):console.warn("请添加音效路径参数"),i&&i();for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];r.apply(this,n)},n},Fe=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;return function(i,s,o){let n=o.value,r=!1;return o.value=function(){if(r)e&&e();else{r=!0,X(()=>{r=!1},1e3*t);for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];n.apply(this,s)}},o}},xe=t._cat??=Te.instance;y.onPostProjectInitDelegate.add(async()=>{console.time("[Init App]");try{await xe.boot(),await xe.onAppInitDelegate.dispatch(),await xe.onPlugInInitDelegate.dispatch()}catch(t){throw o(`[Init App] 初始化失败: ${t instanceof Error?t.message:String(t)}`),t}finally{console.timeEnd("[Init App]")}});export{Me as AudioEffect,vt as AudioEventConstant,bt as AudioManager,Ot as AudioSourceBaseComponent,Dt as AudioSourceUILayer,kt as AudioTypeEnum,wt as BaseComponent,yt as BaseManager,de as BasePrefab,ye as BaseStore,Fe as ButtonLock,Gt as CoreBlackMask,re as CoreNotice,ie as CoreReconnection,Xt as CoreShowLoading,ve as CoreStore,Pt as CoreToast,Vt as CoreUIContainer,Oe as CoreUIModal,we as CoreUtil,Lt as GlobalEventConstant,ue as Gui,me as GuiManager,pe as LayerType,Te as Manager,Zt as ReconnectPrompt,zt as RootUILayer,ae as SceneLayer,De as TimerManager,Ut as ToastType,Tt as UILayer,_e as WrapperSocialGameClient,xe as cat};
|
|
1
|
+
import t from"@babel/runtime-corejs3/core-js/global-this";import{AudioSource as e,_decorator as i,AudioClip as s,error as o,Node as n,director as r,log as a,Component as l,Prefab as c,instantiate as h,isValid as p,Layers as u,view as d,Widget as m,v3 as _,tween as f,Enum as g,game as y,Label as v,UIOpacity as b,Tween as E,BlockInputEvents as C,Button as w,Director as S,warn as T,AsyncDelegate as A,Game as I,assetManager as k,Asset as O,resources as N,sys as R,SpriteFrame as D,Sprite as M}from"cc";import F from"@babel/runtime-corejs3/core-js-stable/reflect/get";import x from"@babel/runtime-corejs3/core-js-stable/reflect/set";import U from"@babel/runtime-corejs3/core-js-stable/object/assign";import P from"@babel/runtime-corejs3/core-js-stable/promise";import L from"eventemitter3";import B from"@babel/runtime-corejs3/core-js-stable/instance/includes";import j from"@babel/runtime-corejs3/core-js-stable/json/stringify";import H from"@babel/runtime-corejs3/core-js-stable/map";import G from"@babel/runtime-corejs3/core-js-stable/instance/for-each";import $ from"@babel/runtime-corejs3/core-js-stable/instance/filter";import K from"@babel/runtime-corejs3/core-js-stable/array/is-array";import W from"@babel/runtime-corejs3/core-js-stable/reflect/own-keys";import V from"@babel/runtime-corejs3/core-js-stable/instance/bind";import{makeObservable as z,observable as q,autorun as Q,reaction as J}from"@shimotsuki/mobx";import X from"@babel/runtime-corejs3/core-js-stable/set-timeout";import Z from"@babel/runtime-corejs3/core-js-stable/instance/map";import Y from"@babel/runtime-corejs3/core-js-stable/array/from";import tt from"@babel/runtime-corejs3/core-js-stable/instance/every";import{SocketConnectStatus as et}from"pitayaclient";import{DEBUG as it,WECHAT as st,PREVIEW as ot}from"cc/env";import{SocialGameClient as nt}from"sgc";import rt from"crypto-es";import at from"@babel/runtime-corejs3/core-js-stable/date/now";import lt from"@babel/runtime-corejs3/core-js-stable/set-interval";import ct from"@babel/runtime-corejs3/core-js-stable/instance/values";import ht from"@babel/runtime-corejs3/core-js-stable/instance/entries";class pt extends e{cat;initAudio(t){return this.cat=t,this}}const{ccclass:ut,menu:dt}=i;let mt=class extends pt{effects=(()=>new H)();load(t,e){return new P((i,o)=>{let n,r=null;void 0!==e?(r=t,n=e):n=t;const a=(t,e)=>{if(t)return o(t);this.effects.set(n,e),this.playOneShot(e,this.volume),i(e)};r?this.cat.res.load(r,n,s,a):this.cat.res.load(n,s,a)})}release(){for(let t in this.effects)this.cat.res.release(t);this.effects.clear()}};const{ccclass:_t,menu:ft}=i;class gt extends pt{onComplete=null;_progress=0;_url=null;_isPlay=!1;get progress(){return this.duration>0&&(this._progress=this.currentTime/this.duration),this._progress}set progress(t){this._progress=t,this.currentTime=t*this.duration}load(t,e){return new P((i,n)=>{let r,a=null;void 0!==e?(a=t,r=e):r=t;const l=(t,e)=>{if(t)return o(t),n(t);this.playing&&(this._isPlay=!1,this.stop(),this.cat.res.release(this._url)),this.playOnAwake=!1,this.enabled=!0,this.clip=e,this._url=r,i(e)};a?this.cat.res.load(a,r,s,l):this.cat.res.load(r,s,l)})}update(t){this.currentTime>0&&(this._isPlay=!0),this._isPlay&&0==this.playing&&(this._isPlay=!1,this.enabled=!1,this.onComplete&&this.onComplete())}release(){this._url&&(this.cat.res.release(this._url),this._url=null)}}class yt{cat;constructor(t){this.cat=t}}var vt;!function(t){t.MUSIC_ON="AudioEventConstant/MUSIC_ON",t.MUSIC_OFF="AudioEventConstant/MUSIC_OFF",t.EFFECT_ON="AudioEventConstant/EFFECT_ON",t.EFFECT_OFF="AudioEventConstant/EFFECT_OFF",t.PAUSE_AUDIO="AudioEventConstant/PAUSE_AUDIO",t.RESUME_AUDIO="AudioEventConstant/RESUME_AUDIO"}(vt||(vt={}));class bt extends yt{local_data={};music;effect;_volume_music=1;_volume_effect=1;_switch_music=!0;_switch_effect=!0;local_store_key="game_audio";extra={};constructor(t){super(t),this.local_store_key=this.cat.audio_local_store_key;var e=new n("UIAudioManager");r.addPersistRootNode(e);var i=new n("UIMusic");i.parent=e,this.music=i.addComponent(gt).initAudio(t);var s=new n("UIEffect");s.parent=e,this.effect=s.addComponent(mt).initAudio(t),this.load()}setMusicComplete(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;this.music.onComplete=t}async playMusic(t,e){if(this.music.loop=!0,!this._switch_music)return;let i,s;void 0!==e?(s=t,i=e):i=t,i.length&&await(s?this.music.load(s,i):this.music.load(i)).then(()=>{this._switch_music&&this.music.play()})}stopMusic(){0!=this.music.state&&this.music?.stop()}pauseMusic(){1==this.music.state&&this.music?.pause()}resumeMusic(){var t;B(t=[0,2]).call(t,this.music.state)&&this.music?.play()}get progressMusic(){return this.music.progress}set progressMusic(t){this.music.progress=t}get volumeMusic(){return this._volume_music}set volumeMusic(t){this._volume_music=t,this.music.volume=t}get switchMusic(){return this._switch_music}set switchMusic(t){if(a("设置背景音乐开关值",t,this._switch_music),t==this._switch_music)return;this._switch_music=t,t?this.resumeMusic():this.pauseMusic();const e=t?vt.MUSIC_ON:vt.MUSIC_OFF;this.cat.event.emit(e),this.save()}async playEffect(t,e){if(!this._switch_effect)return;let i,s;void 0!==e?(s=t,i=e):i=t,i.length&&await(s?this.effect.load(s,i):this.effect.load(i)).then(()=>{this.effect.play()})}stopEffect(){this.effect?.stop()}get volumeEffect(){return this._volume_effect}set volumeEffect(t){this._volume_effect=t,this.effect.volume=t}get switchEffect(){return this._switch_effect}set switchEffect(t){if(t==this._switch_effect)return;this._switch_effect=t,t?this.effect?.play():this.effect?.stop();const e=t?vt.EFFECT_ON:vt.EFFECT_OFF;this.cat.event.emit(e),this.save()}resumeAll(){this.switchMusic&&this.music?.play(),this.switchEffect&&this.effect?.play()}pauseAll(){this.music?.pause(),this.effect?.pause()}stopAll(){this.music?.stop(),this.effect?.stop()}save(){this.local_data.volume_music=this._volume_music,this.local_data.volume_effect=this._volume_effect,this.local_data.switch_music=this._switch_music,this.local_data.switch_effect=this._switch_effect,this.local_data.extra=this.extra;let t=j(this.local_data);return this.cat.storage.set(this.local_store_key,t),this}load(){try{let t=this.cat.storage.get(this.local_store_key);this.local_data=JSON.parse(t),this._volume_music=this.local_data.volume_music,this._volume_effect=this.local_data.volume_effect,this._switch_music=this.local_data.switch_music,this._switch_effect=this.local_data.switch_effect,this.extra=this.local_data.extra}catch(t){this.local_data={},this._volume_music=.6,this._volume_effect=1,this._switch_music=!0,this._switch_effect=!0,this.extra={}}this.music&&(this.music.volume=this._volume_music),this.effect&&(this.effect.volume=this._volume_effect)}}function Et(t,e,i,s){var o,n=arguments.length,r=n<3?e:null===s?s=Object.getOwnPropertyDescriptor(e,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,s);else for(var a=t.length-1;a>=0;a--)(o=t[a])&&(r=(n<3?o(r):n>3?o(e,i,r):o(e,i))||r);return n>3&&r&&Object.defineProperty(e,i,r),r}function Ct(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)}"function"==typeof SuppressedError&&SuppressedError;class wt extends l{props={};data={};cat=(()=>t._cat)();autorunDisposers=[];reactionDisposers=[];eventEmitter=[];hook={destroyed:()=>{},started:()=>{}};initUI(){}__preload(){this.initUI(),this.onAutoObserver()}constructor(){super(),z(this,{props:q,data:q})}onAutoObserver(){}addAutorun(t){const e=K(t)?t:[t];return G(e).call(e,t=>{const e=Q(t);this.autorunDisposers.push(e)}),this}addReaction(t,e,i){const s=J(t,e,i);return this.reactionDisposers.push(s),this}addAudoListener(t){var e;return B(e=this.eventEmitter).call(e,t)||t===this.cat.event||this.eventEmitter.push(t),t}_onPreDestroy(){var t,e;if(G(t=this.autorunDisposers).call(t,t=>{t()}),G(e=this.reactionDisposers).call(e,t=>{t()}),this.autorunDisposers=[],this.reactionDisposers=[],!super._onPreDestroy)throw new Error("_onPreDestroy已弃用");super._onPreDestroy()}onDisable(){var t;this.onHide(),this.deleteAllEventByEmitter(this.cat.event),G(t=this.eventEmitter).call(t,t=>{this.deleteAllEventByEmitter(t)}),this.eventEmitter=[],this.removeListener()}deleteAllEventByEmitter(t){const e=t._events;for(const i in e){let s=e[i];K(s)||(s=[s]),G(s).call(s,e=>{e.context===this&&t.off(i,e.fn,this)})}}onEnable(){this.onShow(),this.addListener(),this.onEventListener()}onEventListener(){}addListener(){}removeListener(){}addToParent(t,e,i){const s=t instanceof c?h(t):t instanceof l?t.node:t;if("number"==typeof e){const t=e,o=i;this.setOptions(o),s.insertChild(this.node,t)}else{const t=e;this.setOptions(t),s.addChild(this.node)}return this}setOptions(t){if(t)for(let e in t)switch(e){case"hook":t.hook&&(this.hook=t.hook);break;case"props":null!==t.props&&"object"==typeof t.props&&(this.props=t.props);break;case"data":null!==t.data&&"object"==typeof t.data&&(this.data=t.data)}}setUpdateData(t){if(this.data)return t&&U(this.data,this.toPlainObject(t)),this}setUpdateProps(t){if(this.props)return t&&U(this.props,this.toPlainObject(t)),this}toPlainObject(t){const e={};for(const i of W(t))if("string"==typeof i)try{e[i]=t[i]}catch{}return e}removeAndDestroy(){p(this?.node)&&(this.node.removeFromParent(),this.node.destroy())}setPosition(t){return this.node.setPosition(t),this}setScale(t){return this.node.setScale(t),this}setAngle(t){return this.node.angle=t,this}setRotation(t){return this.node.setRotation(t),this}setRotationFromEuler(t){return this.node.setRotationFromEuler(t),this}onShow(){}onHide(){}setNodeAndChildrenLayer(t){return St(this.node,t),this}}const St=(t,e)=>{var i,s,o;t.layer="string"==typeof e?2**u.nameToLayer(e):e,(null==(i=t)?void 0:V(o=Function.call).call(o,G(s=i.children),s))?.(t=>{St(t,e)})};class Tt extends wt{lastEnterDirection="center";screen;isClosing=!1;root;constructor(){super(),this._init()}_init(){this.root=this.node,this.screen=d.getVisibleSize()}async showTween(t){let{isMotion:e=!0,direction:i="center",duration:s=.1,isBounce:o=!0,bounceDuration:n=.05}=t;if(this.lastEnterDirection=i,e){const t=this.node.getComponent(m);let e,n;t&&(t.updateAlignment(),t.enabled=!1),_(1.1,1.1,1),"center"==i?(e=_(.01,.01,.01),n=_(1,1,1)):(e="left"==i?_(-this.screen.width,0,0):"right"==i?_(this.screen.width,0,0):_(0,"top"==i?this.screen.height:-this.screen.height,0),n=_(0,0,0)),await this.handle(i,s,e,n,o),t&&(t.enabled=!0)}}async hideTween(t){let{isMotion:e=!0,direction:i,duration:s=.1}=t;if(i=i||this.lastEnterDirection,!this.isClosing){if(this.isClosing=!0,f(this.node).removeSelf(),e){const t=this.node.getComponent(m);let e,o;t&&(t.enabled=!1),"center"==i?(e=this.node.scale,o=_(0,0,0)):(o="left"==i?_(-this.screen.width,0,0):"right"==i?_(this.screen.width,0,0):_(0,"top"==i?this.screen.height:-this.screen.height,0),e=this.node.getPosition()),await this.handle(i,s,e,o,!1)}this.removeAndDestroy()}}async handle(t,e,i,s,o){"center"==t?this.node.setScale(i):this.node.setPosition(i),await this.deftween(e,{["center"==t?"scale":"position"]:s},o)}deftween(t,e,i,s){return new P((i,s)=>{f(this.node).to(t,e).call(()=>{i()}).start()})}}const{ccclass:At,property:It}=i;var kt;!function(t){t[t.EFFECT=0]="EFFECT",t[t.BGM=1]="BGM"}(kt||(kt={}));class Ot extends wt{type=(()=>kt.EFFECT)();clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=(()=>new e)();onEnable(){super.onEnable(),this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,this.cat.event.on(vt.EFFECT_ON,this.onPlayEffectHandler,this).on(vt.EFFECT_OFF,this.onStopEffectHandler,this).on(vt.MUSIC_ON,this.onPlayMusicHandler,this).on(vt.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){super.__preload();const{volumeEffect:t,volumeMusic:e}=this.cat.audio;this.audioSource.volume=this.type===kt.BGM?e:t}start(){}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:t,switchMusic:e}=this.cat.audio;this.audioSource.playing||!(this.type===kt.BGM?e:t)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}Et([It({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(kt)}),Ct("design:type",Number)],Ot.prototype,"type",void 0),Et([It({tooltip:"音源",type:s}),Ct("design:type",s)],Ot.prototype,"clip",void 0),Et([It({tooltip:"循环"}),Ct("design:type",Boolean)],Ot.prototype,"loop",void 0),Et([It({tooltip:"音量"}),Ct("design:type",Number)],Ot.prototype,"volume",void 0),Et([It({tooltip:"是否启用自动播放"}),Ct("design:type",Boolean)],Ot.prototype,"playOnAwake",void 0);const{ccclass:Nt,property:Rt}=i;class Dt extends Tt{type=(()=>kt.EFFECT)();clip=null;loop=!1;volume=1;playOnAwake=!1;audioSource=(()=>new e)();onEnable(){super.onEnable(),this.cat.event.on(vt.EFFECT_ON,this.onPlayEffectHandler,this).on(vt.EFFECT_OFF,this.onStopEffectHandler,this).on(vt.MUSIC_ON,this.onPlayMusicHandler,this).on(vt.MUSIC_OFF,this.onStopMusicHandler,this)}__preload(){this.clip&&(this.audioSource.clip=this.clip),this.audioSource.loop=this.loop,this.audioSource.volume=this.volume,this.audioSource.playOnAwake=this.playOnAwake,super.__preload();const{volumeEffect:t,volumeMusic:e}=this.cat.audio;this.audioSource.volume=this.type===kt.BGM?e:t}stopAudio(){this.audioSource.stop()}playAudio(){const{switchEffect:t,switchMusic:e}=this.cat.audio;this.audioSource.playing||!(this.type===kt.BGM?e:t)||y._paused||this.audioSource.play()}onPlayEffectHandler(){}onStopEffectHandler(){this.stopAudio()}onPlayMusicHandler(){}onStopMusicHandler(){this.stopAudio()}_onPreDestroy(){this.onStopMusicHandler(),super._onPreDestroy()}}Et([Rt({tooltip:"类型:\n EFFECT 音效\n BGM 音乐",type:g(kt)}),Ct("design:type",Number)],Dt.prototype,"type",void 0),Et([Rt({tooltip:"音源",type:s}),Ct("design:type",s)],Dt.prototype,"clip",void 0),Et([Rt({tooltip:"循环"}),Ct("design:type",Boolean)],Dt.prototype,"loop",void 0),Et([Rt({tooltip:"音量"}),Ct("design:type",Number)],Dt.prototype,"volume",void 0),Et([Rt({tooltip:"是否启用自动播放"}),Ct("design:type",Boolean)],Dt.prototype,"playOnAwake",void 0);const{ccclass:Mt,property:Ft,menu:xt}=i;var Ut;!function(t){t[t.FIXED=0]="FIXED",t[t.SLIDE=1]="SLIDE"}(Ut||(Ut={}));let Pt=class extends wt{fixed_node;slide_node;fixed_label;slide_label;onLoad(){this.fixed_node.active=this.slide_node.active=!1}start(){this.show()}async show(){return new P(async(t,e)=>{const{title:i,type:s,fixed_time:o}=this.props;s==Ut.FIXED?(this.fixed_node.active=!0,this.fixed_label.string=`${i}`,this.scheduleOnce(()=>{this.node.destroy(),t()},o)):(this.slide_node.active=!0,this.slide_label.string=`${i}`,this.playAnim(this.node).then(()=>{t()}))})}playAnim(t){return new P((e,i)=>{const s=this.node.getComponent(b),o=f(s).delay(1.2).to(.5,{opacity:0}).call(()=>{E.stopAllByTarget(t),this.node.destroy(),e()});f(t).by(.5,{position:_(0,400,0)}).call(()=>{o.start()}).start()})}onDestroy(){E.stopAllByTarget(this.node),this.unscheduleAllCallbacks()}};var Lt;Et([Ft({type:n,tooltip:"固定节点"}),Ct("design:type",n)],Pt.prototype,"fixed_node",void 0),Et([Ft({type:n,tooltip:"滑动节点"}),Ct("design:type",n)],Pt.prototype,"slide_node",void 0),Et([Ft({type:v,tooltip:"固定标签节点"}),Ct("design:type",v)],Pt.prototype,"fixed_label",void 0),Et([Ft({type:v,tooltip:"滑动标签节点"}),Ct("design:type",v)],Pt.prototype,"slide_label",void 0),Pt=Et([Mt("CoreToast"),xt("CATCORE/CoreToast")],Pt),function(t){t.EVENT_SHOW="GlobalEventConstant/EVENT_SHOW",t.EVENT_HIDE="GlobalEventConstant/EVENT_HIDE",t.GAME_RESIZE="GlobalEventConstant/GAME_RESIZE",t.EVENT_CLOSE="GlobalEventConstant/EVENT_CLOSE",t.ONLINE="GlobalEventConstant/ONLINE",t.OFFLINE="GlobalEventConstant/OFFLINE",t.ROOT_MASK_UPDATE="GlobalEventConstant/ROOT_MASK_UPDATE",t.ROOT_MASK_CHANGE="GlobalEventConstant/ROOT_MASK_CHANGE"}(Lt||(Lt={}));const{ccclass:Bt,property:jt,menu:Ht}=i;let Gt=class extends wt{tween};Et([jt({type:n,tooltip:"动画节点"}),Ct("design:type",n)],Gt.prototype,"tween",void 0),Gt=Et([Bt("CoreBlackMask"),Ht("CATCORE/CoreBlackMask")],Gt);const{ccclass:$t,property:Kt,menu:Wt}=i;let Vt=class extends Tt{scene_mask_node;ui_container;gui=null;onLoad(){this.setSceneMaskActive(!1)}get scene_mask(){return this.scene_mask_node.getComponent(Gt)}get brother(){return this.ui_container.children||[]}get tweenChildren(){return this.scene_mask.tween.children}onEventListener(){this.cat.event.on(Lt.ROOT_MASK_CHANGE,this.uiMaskChanged,this)}addMask(){const t=this.brother[this.brother.length-1];t&&this.scene_mask.node.setSiblingIndex(t.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}subMask(){const t=this.brother[this.brother.length-2];t&&this.scene_mask.node.setSiblingIndex(t.getSiblingIndex()),this.blockMaskSiblingIndexChanged()}blockMaskSiblingIndexChanged(){this.tweenChildren.length>1||this.brother.length>1?this.show():this.hide()}addNodeToTween(t){return p(this)&&this.scene_mask&&this.scene_mask.tween.addChild(t),this}show(){this.setSceneMaskActive(!0)}hide(){this.setSceneMaskActive(!1)}setGui(t){return this.gui=t,this}uiMaskChanged(){this.blockMaskSiblingIndexChanged()}setSceneMaskActive(t){this.scene_mask.node.active=t}};Et([Kt({type:n}),Ct("design:type",n)],Vt.prototype,"scene_mask_node",void 0),Et([Kt({type:n}),Ct("design:type",n)],Vt.prototype,"ui_container",void 0),Vt=Et([$t("CoreUIContainer"),Wt("CATCORE/CoreUIContainer")],Vt);class zt extends Tt{onEnable(){super.onEnable(),this.updateMask()}onDisable(){super.onDisable(),this.updateMask()}updateMask(){this.cat.event.emit(Lt.ROOT_MASK_UPDATE)}}const{ccclass:qt,property:Qt,menu:Jt}=i;let Xt=class extends zt{title;loadingTween;loading_rotate=0;onAutoObserver(){this.addAutorun([()=>{this.props?.title&&(this.title.string=`${this.props?.title}`),this.title.node.active=!!this.props?.title?.length},()=>{this.getComponent(C).enabled=!!this.props?.mask}])}update(t){this.loading_rotate+=220*t,this.loadingTween.setRotationFromEuler(0,0,-this.loading_rotate%360),this.loading_rotate>360&&(this.loading_rotate-=360)}};var Zt;Et([Qt({type:v,tooltip:"标题"}),Ct("design:type",v)],Xt.prototype,"title",void 0),Et([Qt({type:n,tooltip:"动画"}),Ct("design:type",n)],Xt.prototype,"loadingTween",void 0),Xt=Et([qt("CoreShowLoading"),Jt("CATCORE/CoreShowLoading")],Xt),function(t){t.RECONNECTED="重连成功",t.RECONNECTING="正在重连",t.MAX_RECONNECT="重连次数超出限制,请检查网络",t.RECONNECTED_ERROR="重连失败,请检查网络",t.CONNECT_PARAM_ERROR="游戏参数错误,请重新加载",t.KICK="账号已下线",t.OFFLINE="网络已断开",t.ONLINE="网络已连接",t.GAME_ERROR="连接游戏服错误"}(Zt||(Zt={}));const{ccclass:Yt,property:te,menu:ee}=i;let ie=class extends zt{common_prompt_text;btn_confirm;btn_close;is_close=!1;props={content:null};initUI(){}onLoad(){this.btn_confirm.node.on(w.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(w.EventType.CLICK,this.onConfirmHandler,this),this.addAutorun([()=>{this.common_prompt_text.string=this.props.content??""}])}onDestroy(){this.unscheduleAllCallbacks()}updateProps(t){this.updatePromptText(t,t==Zt.RECONNECTING)}updatePromptText(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.unscheduleAllCallbacks(),this.props.content=t,a("更新提示文案:",t),e){let e=0;const i=()=>{e=(e+1)%4,this.common_prompt_text.string=t+["","·","··","···"][e]};this.schedule(i,.5)}}onConfirmHandler(){this.is_close=!0,this.cat.gui.hideReconnect()}};Et([te({type:v,tooltip:"通用提示文本"}),Ct("design:type",v)],ie.prototype,"common_prompt_text",void 0),Et([te({type:w,tooltip:"确定按钮"}),Ct("design:type",w)],ie.prototype,"btn_confirm",void 0),Et([te({type:w,tooltip:"关闭按钮"}),Ct("design:type",w)],ie.prototype,"btn_close",void 0),ie=Et([Yt("CoreReconnection"),ee("CATCORE/CoreReconnection")],ie);const{ccclass:se,property:oe,menu:ne}=i;let re=class extends zt{text;btn_confirm;btn_close;onLoad(){this.btn_confirm.node.on(w.EventType.CLICK,this.onConfrimHandler,this)}start(){this.props&&this.updateProps(this.props)}onConfrimHandler(){this.props?.confrim?.(),this.cat.gui.hideNotice()}updateProps(t){this.text.string=`${t.text}`}};Et([oe({type:v,tooltip:"提示文本"}),Ct("design:type",v)],re.prototype,"text",void 0),Et([oe({type:w,tooltip:"确定按钮"}),Ct("design:type",w)],re.prototype,"btn_confirm",void 0),Et([oe({type:w,tooltip:"关闭按钮"}),Ct("design:type",w)],re.prototype,"btn_close",void 0),re=Et([se("CoreNotice"),ne("CATCORE/CoreNotice")],re);class ae extends wt{isReload}const{ccclass:le,property:ce,menu:he}=i;var pe;!function(t){t[t.UI=0]="UI",t[t.LOADING=1]="LOADING",t[t.TOAST=2]="TOAST",t[t.RECONNECTTION=3]="RECONNECTTION",t[t.NOTICE=4]="NOTICE"}(pe||(pe={}));let ue=class extends wt{reconnection_ui_prefab;toast_ui_prefab;loading_ui_prefab;notice_ui_prefab;ui_prefab;root_ui;root_toast;root_mask;ui_container_component;reconnection_ui_component;notice_ui_component;loading_ui_component;toast_ui_component;currentScene;onEventListener(){this.cat.event.on(Lt.ROOT_MASK_UPDATE,this.onRootUpdate,this)}init(t){this.cat=t;const e=r.getScene();return a("init scene"),e&&this.changeScene(e),this}start(){this.onRootUpdate()}toastQueue=[];isScheduling=!1;minInterval=.2;showToast(t){this.toastQueue.push(t),this.isScheduling||this.processQueueWithInterval()}processQueueWithInterval(){if(0===this.toastQueue.length)return void(this.isScheduling=!1);this.isScheduling=!0;const t=this.toastQueue.shift(),e=()=>{h(this.toast_ui_prefab).getComponent(Pt).addToParent(this.root_toast,{props:t}),this.scheduleOnce(()=>{this.processQueueWithInterval()},this.minInterval)};0===this.root_toast.children.length?e():this.scheduleOnce(e,this.minInterval)}hideToast(){var t;this.root_toast&&G(t=this.root_toast.children).call(t,t=>{t.getComponent(Pt)?.removeAndDestroy()});return this.toastQueue=[],this.unschedule(this.processQueueWithInterval),this.isScheduling=!1,this}showLoading(){let{title:t="",mask:e=!0,black:i=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(a("showLoading",t),this.loading_ui_component)this.loading_ui_component.setOptions({props:{title:t,mask:e,black:i}});else{const s=h(this.loading_ui_prefab);this.loading_ui_component=s.getComponent(Xt).addToParent(this.root_ui,{props:{title:t,mask:e,black:i}})}return this}hideLoading(){return this.loading_ui_component?.removeAndDestroy(),this.loading_ui_component=null,this}showReconnect(t){if(this.reconnection_ui_component)this.reconnection_ui_component.setUpdateProps({content:t});else{const e=h(this.reconnection_ui_prefab);this.reconnection_ui_component=e.getComponent(ie).addToParent(this.root_ui,{props:{content:t}})}return this}hideReconnect(){return this.reconnection_ui_component?.removeAndDestroy(),this.reconnection_ui_component=null,this}showNotice(t){const e=h(this.notice_ui_prefab);return this.notice_ui_component=e.getComponent(re).addToParent(this.root_ui,{props:t}),this}hideNotice(){return this.notice_ui_component?.removeAndDestroy(),this}loadScene(t,e,i){a("[加载场景名][参数][重新加载]",t,e,i);let s={},o=i??!0;return"boolean"==typeof e?o=e:s=e??{},r.once(S.EVENT_BEFORE_SCENE_LAUNCH,t=>{a("Director.EVENT_BEFORE_SCENE_LAUNCH",t),this.changeScene(t,s,o)}),"string"==typeof t?r.loadScene(t):r.runScene(t),this}resetScene(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";return t=t||this.currentScene,this.loadScene(t)}cleanScene(){this.resetScene().hideLoading().hideNotice().hideReconnect().hideToast()}changeScene(t,e,i){this.currentScene=t.name,this.createUILayer(t);const s=t.getComponentInChildren(ae);a("给场景传递属性值=======",s),s&&(s.isReload=i??!1),s?.setOptions(e)}createUILayer(t){this.ui_container_component?.removeAndDestroy(),this.ui_container_component=null;const e=h(this.ui_prefab);this.ui_container_component=e.getComponent(Vt),this.ui_container_component?.setGui(this).addToParent(t,this.node.getSiblingIndex())}reloadScene(){a("重新加载当前场景"),this.loadScene(this.currentScene,!0)}async closeUI(t,e){const{component:i}=this.findUIBaseLayer(t,!1);i&&(i.setOptions({...e?.hook??{},...e?.props??{}}),await i.hideTween(e||{}),this.ui_container_component?.subMask())}async openUI(t,e){const{rootNode:i,component:s}=this.findUIBaseLayer(t,!0);i.getComponent(Tt),s?.setOptions(e),i&&this.ui_container_component?.addNodeToTween(i).addMask(),s&&await s.showTween(e||{}),this.ui_container_component?.ui_container&&s?.addToParent(this.ui_container_component.ui_container)}findUIBaseLayer(t,e){let i,s=null;if(t instanceof n){var r;i=t;const e=$(r=t.components).call(r,t=>t instanceof Tt);if(!e.length)return o(`${t.name}节点未找到继承自BaseLayer的组件`),{rootNode:i,component:s};1==e.length?s=e[0]:T(`${t.name}节点存在多个继承自BaseLayer的组件`)}else if(i=t.node,s=t,e){for(;i.parent;)i=i.parent;s.root=i}else i=t.root;return{rootNode:i,component:s}}onRootUpdate(){const t=this.root_ui.children.findLastIndex(t=>t.active&&t!=this.root_mask);if(this.root_mask.active=-1!=t,t>-1){const e=this.root_ui.children[t].getSiblingIndex()-1;this.root_mask.setSiblingIndex(e<0?0:e)}this.cat.event.emit(Lt.ROOT_MASK_CHANGE)}};var de;Et([ce({type:c,tooltip:"断线重连UI预制体"}),Ct("design:type",c)],ue.prototype,"reconnection_ui_prefab",void 0),Et([ce({type:c,tooltip:"提示UI预制体"}),Ct("design:type",c)],ue.prototype,"toast_ui_prefab",void 0),Et([ce({type:c,tooltip:"加载UI预制体"}),Ct("design:type",c)],ue.prototype,"loading_ui_prefab",void 0),Et([ce({type:c,tooltip:"公告UI预制体"}),Ct("design:type",c)],ue.prototype,"notice_ui_prefab",void 0),Et([ce({type:c,tooltip:"UI层预制体"}),Ct("design:type",c)],ue.prototype,"ui_prefab",void 0),Et([ce({type:n,tooltip:"root-UI层"}),Ct("design:type",n)],ue.prototype,"root_ui",void 0),Et([ce({type:n,tooltip:"root-组件层"}),Ct("design:type",n)],ue.prototype,"root_toast",void 0),Et([ce({type:n,tooltip:"root-mask"}),Ct("design:type",n)],ue.prototype,"root_mask",void 0),ue=Et([le("Gui"),he("CATCORE/Gui")],ue),function(t){t.Root="prefabs/root",t.Toast="prefabs/toast",t.BlackMask="prefabs/black-mask",t.Loading="prefabs/loading",t.Notice="prefabs/notice",t.Reconnection="prefabs/reconnection"}(de||(de={}));class me extends yt{gui;#t="core";getGuiPrefabByType=(t,e)=>new P((i,s)=>{a(t,`${e}`),this.cat.res.load(t,e,(t,e)=>{t?s(t):i(e)})});async init(){this.cat.gui_bundle_name&&(this.#t=this.cat.gui_bundle_name);const t=await this.getGuiPrefabByType(this.#t,de.Root),e=h(t);return this.gui=e.getComponent(ue).init(this.cat),r.addPersistRootNode(e),this}}class _e extends nt{showRequestErrInfo=!1;logBlackList=[];ignore=t=>{var e;return B(e=this.logBlackList).call(e,t)};constructor(t,e,i,s){super(e,i,s,t),this.showRequestErrInfo=s?.showRequestErrInfo??!1}destroy(){this.disconnect(!0),t._cat.socialGameClient.unregister(this)}async GameRequest(e,i,s){let{forwardReq:n=!1,forwardResp:r=!1}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return new P((l,c)=>{super.GameRequest(e,i,s,{forwardReq:n,forwardResp:r}).then(t=>{it&&a(`%c ws服务端消息 %c [Response][${new Date}] %c ${e} %c`,"background:#ff00ff ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#3d7daa ; padding: 1px; color: #fff","background:#ff00ff ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",i),l(t)},e=>{o(e),this.showRequestErrInfo&&e?.msg&&t._cat.gui.showToast({title:e.msg}),c(e)})})}subscribe(e,i,s){return super.subscribe(e,i,i=>{it&&!this.ignore(e)&&a(`%c ws服务端消息:[subscribe][${new Date}] %c ${e} %c`,"background:#35495e ; padding: 1px; border-radius: 3px 0 0 3px; color: #fff","background:#410083 ; padding: 1px; border-radius: 0 3px 3px 0; color: #fff","background:transparent",i),t._cat.event.emit(e,i),s?.(i)}),this}}class fe extends yt{managedClients=(()=>new H)();isGlobalOnline=!0;isInBackground=!1;reconnecting=!1;onEventHideDelegate=(()=>new A)();onEventShowDelegate=(()=>new A)();onEventReloadSceneDelegate=(()=>new A)();reconnectTimer=null;scheduleReconnect(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3;this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),this.reconnectTimer=X(()=>{this.reconnectTimer=null,this.triggerReconnectAll()},t)}get activeClients(){var t,e;return $(t=Z(e=Y(this.managedClients)).call(e,t=>{let[e,i]=t;return i})).call(t,t=>t.socket)}constructor(t){super(t),this.initGlobalListeners()}createWebSocket(t,e,i,s){if(this.managedClients.has(t)){this.managedClients.get(t).destroy(),a(`清理旧的 ${t} 客户端`)}const o=new _e(t,i,s,U({reconnectMaxAttempts:1/0},{...e,isAutoConnect:!1,isArrayBuffer:st}));return this.register(o),o}register(t){t.on("reconnected",this.handleSingleReconnect),t.on("close",this.handleSingleClose),t.on("kick",this.handleSingleKick),this.managedClients.set(t.name,t)}unregister(t){t.off("reconnected",this.handleSingleReconnect),t.off("close",this.handleSingleClose),t.off("kick",this.handleSingleKick),this.managedClients.delete(t.name)}initGlobalListeners(){this.cat.event.on(Lt.ONLINE,()=>this.handleGlobalStateChange("online"),this).on(Lt.OFFLINE,()=>this.handleGlobalStateChange("offline"),this),y.on(I.EVENT_SHOW,()=>this.handleGlobalStateChange("show")),y.on(I.EVENT_HIDE,()=>this.handleGlobalStateChange("hide"))}async handleGlobalStateChange(t){switch(t){case"online":this.cat.gui.hideLoading().showToast({title:Zt.ONLINE}),this.isGlobalOnline=!0,this.triggerReconnectAll();break;case"offline":this.isGlobalOnline=!1,this.disconnectAll(!0),this.cat.gui.showLoading({title:Zt.OFFLINE});break;case"show":this.isInBackground=!1,await this.triggerReconnectAll(),await this.onEventShowDelegate.dispatch();break;case"hide":await this.onEventHideDelegate.dispatch(),this.isInBackground=!0,this.disconnectAll(!0)}}async triggerReconnectAll(){if(a("触发所有客户端重连[正在重连][在线][后台][ws数量]",this.reconnecting,this.isGlobalOnline,this.isInBackground,this.managedClients.size),this.reconnecting||!this.isGlobalOnline||this.isInBackground||0===this.managedClients.size)return this.onEventReloadSceneDelegate.dispatch();this.reconnecting=!0,this.cat.gui.showLoading({title:"正在重连"});try{var t,e;await P.allSettled(Z(t=this.activeClients).call(t,async t=>{try{await t.reconnectPromise()}catch(e){o(`${t.name}服重连失败`,e)}}));const i=$(e=this.activeClients).call(e,t=>t.socketConnectStatus!==et.CONNECTED);i.length>0?(console.error("部分WS重连失败:",Z(i).call(i,t=>t)),a("2s后重连所有客户端"),this.reconnecting=!1,this.scheduleReconnect()):this.reconnecting=!1}catch(t){throw this.reconnecting=!1,t}}disconnectAll(t){var e;G(e=this.managedClients).call(e,e=>{a("断开连接",e.name,t,e.socket),e.disconnect(t)})}handleSingleClose=()=>{this.reconnecting||(a("3s后重连所有客户端"),this.scheduleReconnect(3e3))};handleSingleReconnect=async()=>{var t,e;tt(t=this.activeClients).call(t,t=>t.socketConnectStatus===et.CONNECTED)&&(a("单个WS重连成功回调===",this.managedClients),await P.allSettled(Z(e=this.activeClients).call(e,async t=>{try{await t.connectRequest()}catch(e){o(`${t.name}服登录错误`,e),this.cat.gui.showToast({title:`登录${t.name}服错误`})}})),this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null),await this.onEventReloadSceneDelegate.dispatch(),this.cat.gui.hideLoading(),r.getScene()?.getComponentInChildren(ae)?.isReload&&this.cat.gui.reloadScene())};handleSingleKick=()=>{this.cat.gui.showReconnect(Zt.KICK)}}class ge{get=(()=>function(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"resources";return k.getBundle(i).get(t,e)})();isAssetType=t=>"function"==typeof t&&t.prototype instanceof O;async load(){let t=null,e=null,i=null;for(var s=arguments.length,o=new Array(s),n=0;n<s;n++)o[n]=arguments[n];"string"==typeof o[0]&&"string"==typeof o[1]&&(t=o.shift());let r=o.shift();this.isAssetType(o[0])&&(e=o.shift()),2==o.length&&(i=o.shift());const a=o.shift();let l=N;if(t&&"resources"!=t){k.bundles.has(t)||await this.loadBundle(t);let e=k.bundles.get(t);e&&(l=e)}i&&a?l.load(r,e,i,a):a?l.load(r,e,a):l.load(r,e)}async loadDir(){let t=null,e=null,i=null,s=null;for(var o=arguments.length,n=new Array(o),r=0;r<o;r++)n[r]=arguments[r];"string"==typeof n[0]&&"string"==typeof n[1]&&(t=n.shift());let a=n.shift();this.isAssetType(n[0])&&(e=n.shift()),2==n.length&&(i=n.shift()),s=n.shift();let l=N;if(t&&"resources"!=t){k.bundles.has(t)||await this.loadBundle(t);let e=k.bundles.get(t);e&&(l=e)}i&&s?l.loadDir(a,e,i,s):s?l.loadDir(a,e,s):l.loadDir(a,e)}loadRemote(t){for(var e,i=null,s=arguments.length,o=new Array(s>1?s-1:0),n=1;n<s;n++)o[n-1]=arguments[n];2==o.length&&(i=o.shift()),e=o.shift(),k.loadRemote(t,{ext:".png",...i},e)}loadBundle=(t,e)=>new P((i,s)=>{const o=(t,e)=>{if(t)return s(t);i(e)};e?k.loadBundle(t,{version:e},o):k.loadBundle(t,o)});releasePrefabtDepsRecursively=t=>{var e=k.assets.get(t);if(k.releaseAsset(e),e instanceof c){var i=k.dependUtil.getDepsRecursively(t);G(i).call(i,t=>{k.assets.get(t).decRef()})}};release=(()=>{var t=this;return function(e){let i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"resources";var s=k.getBundle(i);if(s){var o=s.get(e);o&&t.releasePrefabtDepsRecursively(o._uuid)}}})();releaseDir=(()=>{var t=this;return function(e){var i,s;let o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"resources";var n=k.getBundle(o),r=n?.getDirWithPath(e);(null==(i=r)?void 0:V(s=Function.call).call(s,Z(i),i))?.(e=>{t.releasePrefabtDepsRecursively(e.uuid)}),!e&&"resources"!=o&&n&&k.removeBundle(n)}})();dump=()=>{var t;G(t=k.assets).call(t,(t,e)=>{a(k.assets.get(e))}),a(`当前资源总数:${k.assets.count}`)};loadAssetsWithProgress(t,e){return new P((i,s)=>{const o=t.getDirWithPath(""),n=o.length;let r=0;if(0===n)return e(1),void i();G(o).call(o,o=>{t.load(o.path,t=>{t?s(t):(r++,e(r/n),r===n&&i())})})})}}class ye{rootStore;constructor(t){this.rootStore=t}}class ve extends yt{}let be=null;const Ee={stringify:t=>{const e={ct:t.ciphertext.toString(rt.enc.Base64)};return t.iv&&(e.iv=t.iv.toString()),t.salt&&(e.s=t.salt.toString()),j(e)},parse:t=>{const e=JSON.parse(t),i=rt.lib.CipherParams.create({ciphertext:rt.enc.Base64.parse(e.ct)});return e.iv&&(i.iv=rt.enc.Hex.parse(e.iv)),e.s&&(i.salt=rt.enc.Hex.parse(e.s)),i}};var Ce=Object.freeze({__proto__:null,JsonFormatter:Ee,aesDecrypt:(t,e,i)=>rt.AES.decrypt(t,e,{iv:be,format:Ee}).toString(rt.enc.Utf8),aesEncrypt:(t,e,i)=>rt.AES.encrypt(t,e,{iv:be,format:Ee}).toString(),initCrypto:(t,e)=>{be=rt.enc.Hex.parse(e)},md5:t=>rt.MD5(t).toString()});class we extends yt{encryptUtil=(()=>Ce)()}class Se extends yt{_key=null;_iv=null;_id="";init(t,e){this.cat.util.encryptUtil.initCrypto(t,e),this._key=this.cat.util.encryptUtil.md5(t),this._iv=this.cat.util.encryptUtil.md5(e)}setUser(t){this._id=t}set(t,e){if(null!=(t=`${t}_${this._id}`)){if(ot||(t=this.cat.util.encryptUtil.md5(t)),null==e)return console.warn("存储的值为空,则直接移除该存储"),void this.remove(t);if("function"!=typeof e){if("object"==typeof e)try{e=j(e)}catch(t){return void console.error(`解析失败,str = ${e}`)}else"number"==typeof e&&(e+="");ot||null==this._key||null==this._iv||(e=this.cat.util.encryptUtil.aesEncrypt(`${e}`,this._key,this._iv)),R.localStorage.setItem(t,e)}else console.error("储存的值不能为方法")}else console.error("存储的key不能为空")}get(t,e){if(null==t)return console.error("存储的key不能为空"),null;t=`${t}_${this._id}`,ot||(t=this.cat.util.encryptUtil.md5(t));let i=R.localStorage.getItem(t);return null==i||""===i||ot||null==this._key||null==this._iv||(i=this.cat.util.encryptUtil.aesDecrypt(i,this._key,this._iv)),null===i?e:i}getNumber(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;var i=this.get(t);return Number(i)||e}getBoolean(t){var e=this.get(t);return Boolean(e)||!1}getJson(t,e){var i=this.get(t);return i&&JSON.parse(i)||e}remove(t){null!=t?(t=`${t}_${this._id}`,ot||(t=this.cat.util.encryptUtil.md5(t)),R.localStorage.removeItem(t)):console.error("存储的key不能为空")}clear(){R.localStorage.clear()}}class Te{static#e=null;#i=!1;static get instance(){return this.#e??(this.#e=new Te)}onAppInitDelegate=(()=>new A)();onPlugInInitDelegate=(()=>new A)();#s=null;get audio(){return this.#s}#o=null;get event(){return this.#o}#n=null;get gui(){return this.#n}#r=null;get storage(){return this.#r}#a=null;get res(){return this.#a}#l=null;get util(){return this.#l}#c=null;get socialGameClient(){return this.#c}#h=null;get store(){return this.#h}#p="";get gui_bundle_name(){return this.#p}#u="";get audio_local_store_key(){return this.#u}#d="";get default_audio_effect(){return this.#d}setConfig=(()=>{var t=this;return function(){let{default_audio_effect:e="",gui_bundleName:i="resources",audio_local_store_key:s="game_audio"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(t.#i)throw new Error("[CAT] 已初始化,无法修改配置");return t.#p=i,t.#u=s,t.#d=e,t}})();async boot(){if(this.#i)throw new Error("[CAT] 已初始化");try{this.#h=new ve(this),this.#a=new ge,this.#l=new we(this),this.#r=new Se(this),this.#o=new L,this.#s=new bt(this),this.#c=new fe(this),this.#n=(await new me(this).init()).gui,this.#i=!0}catch(t){throw console.error("[CAT] 初始化失败:",t),t}}merge(t,e){if(!this.#i)throw new Error("[CAT] 未初始化");if("string"!=typeof t)throw new Error("merge方法第一个参数应该为string类型");return F(this,t)||x(this,t,e),U(F(this,t),e),this}appendPlugInInitDelegate(t){return this.#i?P.resolve().then(t).catch(t=>{console.error("[CAT] appendPlugInInitDelegate 回调执行失败:",t)}):this.onPlugInInitDelegate.add(t),this}}const{ccclass:Ae,property:Ie,menu:ke}=i;let Oe=class extends Tt{default_title=null;title;prompt_content_str;prompt_content_spriteFrame;btn_confirm;confirm_spriteFrame;btn_cancel;cancel_spriteFrame;btn_close;isConfirm=!1;props={title:this.default_title,content:null,confirmCB:()=>{},cancelCB:()=>{},style:null};onLoad(){this.btn_cancel.node.on(w.EventType.CLICK,this.onCancelHandler,this),this.btn_confirm.node.on(w.EventType.CLICK,this.onConfirmHandler,this),this.btn_close.node.on(w.EventType.CLICK,this.onCloseHandler,this),this.addAutorun([()=>{this.title.spriteFrame=this.props?.title||this.default_title},()=>{this.props.content&&(this.props.content instanceof D?this.prompt_content_spriteFrame.spriteFrame=this.props.content:"string"==typeof this.props.content?this.prompt_content_str.string=this.props.content:console.error("未知类型的【UIModal】内容"))},()=>{null===this.props?.style?.confirm?this.btn_confirm.node.active=!1:(this.btn_confirm.node.active=!0,this.btn_confirm.getComponent(M).spriteFrame=this.props.style?.confirm||this.confirm_spriteFrame),null===this.props?.style?.cancel?this.btn_cancel.node.active=!1:(this.btn_cancel.node.active=!0,this.btn_cancel.getComponent(M).spriteFrame=this.props.style?.cancel||this.cancel_spriteFrame)}])}close(){this.props.cancelCB?.(),this.cat.gui.closeUI(this)}onCancelHandler(){this.close()}onConfirmHandler(){this.props.confirmCB?.()}onDestroy(){this.isConfirm&&this.props.onDestroy?.()}onCloseHandler(){this.close()}};var Ne;Et([Ie({type:D,tooltip:"默认标题"}),Ct("design:type",D)],Oe.prototype,"default_title",void 0),Et([Ie({type:M,tooltip:"标题节点"}),Ct("design:type",M)],Oe.prototype,"title",void 0),Et([Ie({type:v,tooltip:"字符串内容按钮"}),Ct("design:type",v)],Oe.prototype,"prompt_content_str",void 0),Et([Ie({type:M,tooltip:"图片精灵内容按钮"}),Ct("design:type",M)],Oe.prototype,"prompt_content_spriteFrame",void 0),Et([Ie({type:w,tooltip:"确认按钮"}),Ct("design:type",w)],Oe.prototype,"btn_confirm",void 0),Et([Ie({type:D,tooltip:"确认按钮精灵图"}),Ct("design:type",D)],Oe.prototype,"confirm_spriteFrame",void 0),Et([Ie({type:w,tooltip:"取消按钮"}),Ct("design:type",w)],Oe.prototype,"btn_cancel",void 0),Et([Ie({type:D,tooltip:"取消按钮精灵图"}),Ct("design:type",D)],Oe.prototype,"cancel_spriteFrame",void 0),Et([Ie({type:w,tooltip:"关闭按钮"}),Ct("design:type",w)],Oe.prototype,"btn_close",void 0),Oe=Et([Ae("CoreUIModal"),ke("CATCORE/CoreUIModal")],Oe),function(t){t[t.Delay=0]="Delay",t[t.Interval=1]="Interval"}(Ne||(Ne={}));class Re{tag;type;callback;remainingTime;executionTime=0;initialTime;constructor(t,e,i,s){this.tag=t,this.type=e,this.remainingTime=i,this.initialTime=i,this.callback=s}}class De extends yt{timers=(()=>new H)();lastUpdateTime=(()=>at())();constructor(t){var e;super(t),t.event.on(Lt.EVENT_HIDE,this.onHandleAppBackground,this),t.event.on(Lt.EVENT_SHOW,this.onHandleAppForeground,this),lt(V(e=this.update).call(e,this),1e3)}onHandleAppBackground(){this.lastUpdateTime=at()}onHandleAppForeground(){const t=at(),e=t-this.lastUpdateTime;a("elapsedTime",e);for(const t of ct(i=this.timers).call(i)){var i;t.remainingTime>0&&(t.remainingTime-=e,t.executionTime+=e)}this.lastUpdateTime=t}registerInterval(t,e,i){if(this.has(t))return o(`${t}定时器已存在,请勿重复注册`);const s=new Re(t,Ne.Interval,e,i);this.timers.set(t,s)}registerDelay(t,e,i){if(this.has(t))return o(`${t}延时器已存在,请勿重复注册`);const s=new Re(t,Ne.Delay,e,i);this.timers.set(t,s)}unregister(t){this.has(t)&&this.timers.delete(t)}has(t){return this.timers.has(t)}update(){const t=[];for(const[i,s]of ht(e=this.timers).call(e)){var e;s.remainingTime-=1e3,s.remainingTime<=0&&(s.type===Ne.Interval&&(s.executionTime+=s.initialTime),s.callback(s.executionTime),s.type===Ne.Interval?s.remainingTime=s.initialTime:t.push(i))}for(const e of t)this.timers.delete(e)}}const Me=(e,i)=>(s,o,n)=>{let r=n.value;return n.value=function(){const s=e??t._cat.default_audio_effect;s?t._cat.audio.playEffect(s):console.warn("请添加音效路径参数"),i&&i();for(var o=arguments.length,n=new Array(o),a=0;a<o;a++)n[a]=arguments[a];r.apply(this,n)},n},Fe=function(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1,e=arguments.length>1?arguments[1]:void 0;return function(i,s,o){let n=o.value,r=!1;return o.value=function(){if(r)e&&e();else{r=!0,X(()=>{r=!1},1e3*t);for(var i=arguments.length,s=new Array(i),o=0;o<i;o++)s[o]=arguments[o];n.apply(this,s)}},o}},xe=t._cat??=Te.instance;y.onPostProjectInitDelegate.add(async()=>{console.time("[Init App]");try{await xe.boot(),await xe.onAppInitDelegate.dispatch(),await xe.onPlugInInitDelegate.dispatch()}catch(t){throw o(`[Init App] 初始化失败: ${t instanceof Error?t.message:String(t)}`),t}finally{console.timeEnd("[Init App]")}});export{Me as AudioEffect,vt as AudioEventConstant,bt as AudioManager,Ot as AudioSourceBaseComponent,Dt as AudioSourceUILayer,kt as AudioTypeEnum,wt as BaseComponent,yt as BaseManager,de as BasePrefab,ye as BaseStore,Fe as ButtonLock,Gt as CoreBlackMask,re as CoreNotice,ie as CoreReconnection,Xt as CoreShowLoading,ve as CoreStore,Pt as CoreToast,Vt as CoreUIContainer,Oe as CoreUIModal,we as CoreUtil,Lt as GlobalEventConstant,ue as Gui,me as GuiManager,pe as LayerType,Te as Manager,Zt as ReconnectPrompt,zt as RootUILayer,ae as SceneLayer,De as TimerManager,Ut as ToastType,Tt as UILayer,_e as WrapperSocialGameClient,xe as cat};
|